Fixing a ultoa bug, replacing both version with wine, copy the code from wine 0.9.0; I did add a NULL check for the string so it can not bsod. wine ntdll string only report one error, left to fix, I run wine test on windows 2000 and reactos to compare the result. Fireball report wine_ntdll_test string crach on windows xp, but it does not crash in windows 2000.

svn path=/trunk/; revision=21967
This commit is contained in:
Magnus Olsen
2006-05-21 18:54:21 +00:00
parent 80022e3b3d
commit eebf35125d
2 changed files with 49 additions and 54 deletions
+24 -29
View File
@@ -104,37 +104,32 @@ char* _ltoa(long value, char* string, int radix)
/*
* @implemented
* copy it from wine 0.9.0 with small modifcations do check for NULL
*/
char* _ultoa(unsigned long value, char* string, int radix)
char* ultoa(unsigned long value, char* string, int radix)
{
char tmp[33];
char* tp = tmp;
long i;
unsigned long v = value;
char* sp;
char buffer[33];
char *pos;
int digit;
pos = &buffer[32];
*pos = '\0';
if (radix > 36 || radix <= 1)
{
__set_errno(EDOM);
return 0;
}
if (string == NULL)
{
return NULL;
}
do {
digit = value % radix;
value = value / radix;
if (digit < 10) {
*--pos = '0' + digit;
} else {
*--pos = 'a' + digit - 10;
} /* if */
} while (value != 0L);
while (v || tp == tmp)
{
i = v % radix;
v = v / radix;
if (i < 10)
*tp++ = i+'0';
else
*tp++ = i + 'a' - 10;
}
if (string == 0)
string = (char*)malloc((tp-tmp)+1);
sp = string;
while (tp > tmp)
*sp++ = *--tp;
*sp = 0;
return string;
memcpy(string, pos, &buffer[32] - pos + 1);
return string;
}
+25 -25
View File
@@ -133,35 +133,35 @@ _ltoa(long value, char *string, int radix)
/*
* @implemented
* @implemented
* copy it from wine 0.9.0 with small modifcations do check for NULL
*/
char *
_ultoa(unsigned long value, char *string, int radix)
{
char tmp[33];
char *tp = tmp;
long i;
unsigned long v = value;
char *sp;
char buffer[33];
char *pos;
int digit;
pos = &buffer[32];
*pos = '\0';
if (radix > 36 || radix <= 1)
{
return 0;
}
if (string == NULL)
{
return NULL;
}
do {
digit = value % radix;
value = value / radix;
if (digit < 10) {
*--pos = '0' + digit;
} else {
*--pos = 'a' + digit - 10;
} /* if */
} while (value != 0L);
while (v || tp == tmp)
{
i = v % radix;
v = v / radix;
if (i < 10)
*tp++ = i+'0';
else
*tp++ = i + 'a' - 10;
}
sp = string;
while (tp > tmp)
*sp++ = *--tp;
*sp = 0;
return string;
memcpy(string, pos, &buffer[32] - pos + 1);
return string;
}