Author: greatlrd Date: Mon May 22 02:41:35 2006 New Revision: 21976
URL: http://svn.reactos.ru/svn/reactos?rev=21976&view=rev Log: replace follow _wtol, _wtoi, _i64tow, _ui64tow, _ltow, _ultow, _ui64toa, _itow, _ltow, ultow with wine from wine cvs 2006-05-21 for we did fail on wine test on all these. In windows 2000 wine test ntdll string did not fail.
Modified: trunk/reactos/lib/crt/stdlib/itow.c trunk/reactos/lib/crt/stdlib/witoa.c trunk/reactos/lib/string/itoa.c trunk/reactos/lib/string/itow.c trunk/reactos/lib/string/wtoi.c trunk/reactos/lib/string/wtol.c
Modified: trunk/reactos/lib/crt/stdlib/itow.c URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/lib/crt/stdlib/itow.c?rev=21... ============================================================================== --- trunk/reactos/lib/crt/stdlib/itow.c (original) +++ trunk/reactos/lib/crt/stdlib/itow.c Mon May 22 02:41:35 2006 @@ -16,138 +16,81 @@
/* * @implemented + * from wine cvs 2006-05-21 */ wchar_t* _itow(int value, wchar_t* string, int radix) { - wchar_t tmp [33]; - wchar_t * tp = tmp; - int i; - unsigned int v; - int sign; - wchar_t * sp; + return _ltow(value, string, radix); +}
- if (radix > 36 || radix <= 1) - { - __set_errno(EDOM); - return 0; - } +/* + * @implemented + * from wine cvs 2006-05-21 + */ +wchar_t* _ltow(long value, wchar_t* string, int radix) +{ + unsigned long val; + int negative; + WCHAR buffer[33]; + PWCHAR pos; + WCHAR digit;
- sign = ((radix == 10) && (value < 0)); - if (sign) { - v = -value; + if (value < 0 && radix == 10) { + negative = 1; + val = -value; } else { - v = (unsigned) value; - } - while (v || tp == tmp) { - i = v % radix; - v = v / radix; - if (i < 10) { - *tp++ = i+ (wchar_t) '0'; - } else { - *tp++ = i + (wchar_t) 'a' - 10; - } - } + negative = 0; + val = value; + } /* if */
- if (string == 0) { - string = (wchar_t*) malloc((tp-tmp) + (sign + 1) * sizeof(wchar_t)); - } - sp = string; + pos = &buffer[32]; + *pos = '\0';
- if (sign) { - *sp++ = (wchar_t) '-'; - } - while (tp > tmp) { - *sp++ = *--tp; - } - *sp = (wchar_t) 0; + do { + digit = val % radix; + val = val / radix; + if (digit < 10) { + *--pos = '0' + digit; + } else { + *--pos = 'a' + digit - 10; + } /* if */ + } while (val != 0L); + + if (negative) { + *--pos = '-'; + } /* if */ + + if (str != NULL) { + memcpy(string, pos, (&buffer[32] - pos + 1) * sizeof(WCHAR)); + } /* if */ return string; }
/* * @implemented - */ -wchar_t* _ltow(long value, wchar_t* string, int radix) -{ - wchar_t tmp [33]; - wchar_t* tp = tmp; - long int i; - unsigned long int v; - int sign; - wchar_t* sp; - - if (radix > 36 || radix <= 1) { - __set_errno(EDOM); - return 0; - } - - sign = ((radix == 10) && (value < 0)); - if (sign) { - v = -value; - } else { - v = (unsigned long) value; - } - while (v || tp == tmp) { - i = v % radix; - v = v / radix; - if (i < 10) { - *tp++ = i + (wchar_t) '0'; - } else { - *tp++ = i + (wchar_t) 'a' - 10; - } - } - - if (string == 0) { - string = (wchar_t*) malloc((tp - tmp) + (sign + 1) * sizeof(wchar_t)); - } - sp = string; - - if (sign) { - *sp++ = (wchar_t) '-'; - } - while (tp > tmp) { - *sp++ = *--tp; - } - *sp = (wchar_t) 0; - return string; -} - -/* - * @unimplemented + * from wine cvs 2006-05-21 */ wchar_t* _ultow(unsigned long value, wchar_t* string, int radix) { - wchar_t tmp [33]; - wchar_t* tp = tmp; - long int i; - unsigned long int v = value; - wchar_t* sp; + WCHAR buffer[33]; + PWCHAR pos; + WCHAR digit;
- if (radix > 36 || radix <= 1) { - __set_errno(EDOM); - return 0; - } - while (v || tp == tmp) { - i = v % radix; - v = v / radix; - if (i < 10) { - *tp++ = i + (wchar_t) '0'; - } else { - *tp++ = i + (wchar_t) 'a' - 10; - } - } + pos = &buffer[32]; + *pos = '\0';
- if (string == 0) { -#ifdef _MSVCRT_LIB_ // TODO: check on difference? - string = (wchar_t*)malloc(((tp-tmp)+1)*sizeof(wchar_t)); -#else // TODO: FIXME: review which is correct - string = (wchar_t*)malloc((tp - tmp) + sizeof(wchar_t)); -#endif /*_MSVCRT_LIB_*/ - } - sp = string; + do { + digit = value % radix; + value = value / radix; + if (digit < 10) { + *--pos = '0' + digit; + } else { + *--pos = 'a' + digit - 10; + } /* if */ + } while (value != 0L);
- while (tp > tmp) { - *sp++ = *--tp; - } - *sp = (wchar_t) 0; + if (string != NULL) { + memcpy(string, pos, (&buffer[32] - pos + 1) * sizeof(WCHAR)); + } /* if */ return string; }
Modified: trunk/reactos/lib/crt/stdlib/witoa.c URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/lib/crt/stdlib/witoa.c?rev=2... ============================================================================== --- trunk/reactos/lib/crt/stdlib/witoa.c (original) +++ trunk/reactos/lib/crt/stdlib/witoa.c Mon May 22 02:41:35 2006 @@ -7,8 +7,9 @@ * UPDATE HISTORY: * 1995: Created * 1998: Added ltoa Boudewijn Dekker + * 2006 : replace all api in this file to wine cvs 2006-05-21 */ -/* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* */ #include <precomp.h>
/* @@ -58,34 +59,23 @@ */ char* _ui64toa(unsigned __int64 value, char* string, int radix) { - char tmp[65]; - char *tp = tmp; - long i; - unsigned long v = value; - char *sp; + char buffer[65]; + char *pos; + int digit;
- if (radix > 36 || radix <= 1) - { - __set_errno(EDOM); - return 0; - } + pos = &buffer[64]; + *pos = '\0';
- while (v || tp == tmp) - { - i = v % radix; - v = v / radix; - if (i < 10) - *tp++ = i+'0'; - else - *tp++ = i + 'a' - 10; - } + do { + digit = value % radix; + value = value / radix; + if (digit < 10) { + *--pos = '0' + digit; + } else { + *--pos = 'a' + digit - 10; + } /* if */ + } while (value != 0L);
- if (string == 0) - string = (char *)malloc((tp-tmp)+1); - sp = string; - - while (tp > tmp) - *sp++ = *--tp; - *sp = 0; - return string; + memcpy(string, pos, &buffer[64] - pos + 1); + return string; }
Modified: trunk/reactos/lib/string/itoa.c URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/lib/string/itoa.c?rev=21976&... ============================================================================== --- trunk/reactos/lib/string/itoa.c (original) +++ trunk/reactos/lib/string/itoa.c Mon May 22 02:41:35 2006 @@ -47,37 +47,30 @@
/* * @implemented + * copy _i64toa from wine cvs 2006 month 05 day 21 */ char * _ui64toa(unsigned __int64 value, char *string, int radix) { - char tmp[65]; - char *tp = tmp; - __int64 i; - unsigned __int64 v; - char *sp; + char buffer[65]; + char *pos; + int digit;
- if (radix > 36 || radix <= 1) - { - return 0; - } + pos = &buffer[64]; + *pos = '\0';
- v = (unsigned __int64)value; - while (v || tp == tmp) - { - i = v % radix; - v = v / radix; - if (i < 10) - *tp++ = i+'0'; - else - *tp++ = i + 'a' - 10; - } + do { + digit = value % radix; + value = value / radix; + if (digit < 10) { + *--pos = '0' + digit; + } else { + *--pos = 'a' + digit - 10; + } /* if */ + } while (value != 0L);
- sp = string; - while (tp > tmp) - *sp++ = *--tp; - *sp = 0; - return string; + memcpy(string, pos, &buffer[64] - pos + 1); + return string; }
Modified: trunk/reactos/lib/string/itow.c URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/lib/string/itow.c?rev=21976&... ============================================================================== --- trunk/reactos/lib/string/itow.c (original) +++ trunk/reactos/lib/string/itow.c Mon May 22 02:41:35 2006 @@ -1,45 +1,48 @@ #include <string.h> +#include <windows.h>
/* * @implemented + * from wine cvs 2006-05-21 */ wchar_t * _i64tow(__int64 value, wchar_t *string, int radix) { - wchar_t tmp[65]; - wchar_t *tp = tmp; - __int64 i; - unsigned __int64 v; - __int64 sign; - wchar_t *sp; + ULONGLONG val; + int negative; + WCHAR buffer[65]; + PWCHAR pos; + WCHAR digit;
- if (radix > 36 || radix <= 1) - { - return 0; - } + if (value < 0 && radix == 10) { + negative = 1; + val = -value; + } else { + negative = 0; + val = value; + } /* if */
- sign = (radix == 10 && value < 0); - if (sign) - v = -value; - else - v = (unsigned __int64)value; - while (v || tp == tmp) - { - i = v % radix; - v = v / radix; - if (i < 10) - *tp++ = i+L'0'; - else - *tp++ = i + L'a' - 10; - } + pos = &buffer[64]; + *pos = '\0';
- sp = string; - if (sign) - *sp++ = L'-'; - while (tp > tmp) - *sp++ = *--tp; - *sp = 0; - return string; + do { + digit = val % radix; + val = val / radix; + if (digit < 10) { + *--pos = '0' + digit; + } else { + *--pos = 'a' + digit - 10; + } /* if */ + } while (val != 0L); + + if (negative) { + *--pos = '-'; + } /* if */ + + if (string != NULL) { + memcpy(string, pos, (&buffer[64] - pos + 1) * sizeof(WCHAR)); + } /* if */ + return string; }
@@ -49,152 +52,112 @@ wchar_t * _ui64tow(unsigned __int64 value, wchar_t *string, int radix) { - wchar_t tmp[65]; - wchar_t *tp = tmp; - __int64 i; - unsigned __int64 v; - wchar_t *sp; + WCHAR buffer[65]; + PWCHAR pos; + WCHAR digit;
- if (radix > 36 || radix <= 1) - { - return 0; - } + pos = &buffer[64]; + *pos = '\0';
- v = (unsigned __int64)value; - while (v || tp == tmp) - { - i = v % radix; - v = v / radix; - if (i < 10) - *tp++ = i+L'0'; - else - *tp++ = i + L'a' - 10; - } + do { + digit = value % radix; + value = value / radix; + if (digit < 10) { + *--pos = '0' + digit; + } else { + *--pos = 'a' + digit - 10; + } /* if */ + } while (value != 0L);
- sp = string; - while (tp > tmp) - *sp++ = *--tp; - *sp = 0; - return string; + if (string != NULL) { + memcpy(string, pos, (&buffer[64] - pos + 1) * sizeof(WCHAR)); + } /* if */ + return string; }
/* * @implemented + * from wine cvs 2006-05-21 */ wchar_t * _itow(int value, wchar_t *string, int radix) { - wchar_t tmp[33]; - wchar_t *tp = tmp; - int i; - unsigned v; - int sign; - wchar_t *sp; - - if (radix > 36 || radix <= 1) - { - return 0; - } - - sign = (radix == 10 && value < 0); - if (sign) - v = -value; - else - v = (unsigned)value; - while (v || tp == tmp) - { - i = v % radix; - v = v / radix; - if (i < 10) - *tp++ = i+L'0'; - else - *tp++ = i + L'a' - 10; - } - - sp = string; - if (sign) - *sp++ = L'-'; - while (tp > tmp) - *sp++ = *--tp; - *sp = 0; - return string; + return _ltow(value, string, radix); }
/* * @implemented + * from wine cvs 2006-05-21 */ wchar_t * _ltow(long value, wchar_t *string, int radix) { - wchar_t tmp[33]; - wchar_t *tp = tmp; - long i; - unsigned long v; - int sign; - wchar_t *sp; + unsigned long val; + int negative; + WCHAR buffer[33]; + PWCHAR pos; + WCHAR digit;
- if (radix > 36 || radix <= 1) - { - return 0; - } + if (value < 0 && radix == 10) { + negative = 1; + val = -value; + } else { + negative = 0; + val = value; + } /* if */
- sign = (radix == 10 && value < 0); - if (sign) - v = -value; - else - v = (unsigned long)value; - while (v || tp == tmp) - { - i = v % radix; - v = v / radix; - if (i < 10) - *tp++ = i+L'0'; - else - *tp++ = i + L'a' - 10; - } + pos = &buffer[32]; + *pos = '\0';
- sp = string; - if (sign) - *sp++ = L'-'; - while (tp > tmp) - *sp++ = *--tp; - *sp = 0; - return string; + do { + digit = val % radix; + val = val / radix; + if (digit < 10) { + *--pos = '0' + digit; + } else { + *--pos = 'a' + digit - 10; + } /* if */ + } while (val != 0L); + + if (negative) { + *--pos = '-'; + } /* if */ + + if (string != NULL) { + memcpy(string, pos, (&buffer[32] - pos + 1) * sizeof(WCHAR)); + } /* if */ + return string; }
/* * @implemented + * from wine cvs 2006-05-21 */ wchar_t * _ultow(unsigned long value, wchar_t *string, int radix) { - wchar_t tmp[33]; - wchar_t *tp = tmp; - long i; - unsigned long v = value; - wchar_t *sp; + WCHAR buffer[33]; + PWCHAR pos; + WCHAR digit;
- if (radix > 36 || radix <= 1) - { - return 0; - } + pos = &buffer[32]; + *pos = '\0';
- while (v || tp == tmp) - { - i = v % radix; - v = v / radix; - if (i < 10) - *tp++ = i+L'0'; - else - *tp++ = i + L'a' - 10; - } + do { + digit = value % radix; + value = value / radix; + if (digit < 10) { + *--pos = '0' + digit; + } else { + *--pos = 'a' + digit - 10; + } /* if */ + } while (value != 0L);
- sp = string; - while (tp > tmp) - *sp++ = *--tp; - *sp = 0; - return string; + if (string != NULL) { + memcpy(string, pos, (&buffer[32] - pos + 1) * sizeof(WCHAR)); + } /* if */ + return string; }
Modified: trunk/reactos/lib/string/wtoi.c URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/lib/string/wtoi.c?rev=21976&... ============================================================================== --- trunk/reactos/lib/string/wtoi.c (original) +++ trunk/reactos/lib/string/wtoi.c Mon May 22 02:41:35 2006 @@ -3,9 +3,10 @@
/* * @implemented + * copy _i64toa from wine cvs 2006 month 05 day 21 */ int _wtoi(const wchar_t *str) { - return (int)wcstol(str, 0, 10); + return _wtol(str); }
Modified: trunk/reactos/lib/string/wtol.c URL: http://svn.reactos.ru/svn/reactos/trunk/reactos/lib/string/wtol.c?rev=21976&... ============================================================================== --- trunk/reactos/lib/string/wtol.c (original) +++ trunk/reactos/lib/string/wtol.c Mon May 22 02:41:35 2006 @@ -1,5 +1,6 @@ #include <string.h> #include <stdlib.h> +#include <windows.h>
/* * @implemented @@ -7,5 +8,26 @@ long _wtol(const wchar_t *str) { - return wcstol(str, 0, 10); + ULONG RunningTotal = 0; + char bMinus = 0; + + while (iswctype(*str, _SPACE) ) { + str++; + } /* while */ + + if (*str == L'+') { + str++; + } else if (*str == L'-') { + bMinus = 1; + str++; + } /* if */ + + while (*str >= L'0' && *str <= L'9') { + RunningTotal = RunningTotal * 10 + *str - L'0'; + str++; + } /* while */ + + return bMinus ? -RunningTotal : RunningTotal; } + +