Skip to content

Commit

Permalink
Refine the Win32 sprintf("%e") kludge. But it's getting to the point …
Browse files Browse the repository at this point in the history
…where

we may have to leave Win32 users to their own devices.


git-svn-id: https://svn.parrot.org/parrot/trunk@15496 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information
chip committed Nov 13, 2006
1 parent 5310bec commit d4e18b8
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/spf_render.c
Expand Up @@ -700,18 +700,20 @@ Parrot_sprintf_format(Interp *interp, STRING *pat,
}

#ifdef WIN32
/* Microsoft uses a retarded, broken, nonstandard
* behavior with regards to signs, exponents and
* precision: it doesn't count the + as part of the
* precision. We'll fix it ourselves if need be.
/* Microsoft defaults to three digits for exponents,
* even when fewer digits would suffice. For the sake
* of portability, we will here attempt to hide that.
*/

if (ch == 'g' || ch == 'G' || ch == 'e' || ch == 'E') {
UINTVAL j;
for (j=0; j < strlen(tc); j++) {
if(tolower(tc[j]) == 'e'
&& (tc[j+1] == '+' || tc[j+1] == '-')
&& tc[j+2] == '0')
size_t tclen = strlen(tc);
size_t j;
for (j = 0; j < tclen; j++) {
if ( (tc[j] == 'e' || tc[j] == 'E')
&& (tc[j+1] == '+' || tc[j+1] == '-')
&& tc[j+2] == '0'
&& isdigit((unsigned char)tc[j+3])
&& isdigit((unsigned char)tc[j+4]))
{
mem_sys_memmove(&tc[j+2], &tc[j+3], strlen(&tc[j+2]));

Expand All @@ -724,6 +726,9 @@ Parrot_sprintf_format(Interp *interp, STRING *pat,
tc[0] = ' ';
}
}

/* only one fix required per string */
break;
}
}
}
Expand Down

0 comments on commit d4e18b8

Please sign in to comment.