From 3a10266e5abe0914208d745a9823a0566792cb8f Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Mon, 21 Jul 2008 18:15:20 -0700 Subject: [PATCH] ntdll: Use our own implementation of atoi and atol. --- dlls/ntdll/string.c | 38 +++++++++++++++++++------------------- dlls/ntdll/tests/string.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 19 deletions(-) diff --git a/dlls/ntdll/string.c b/dlls/ntdll/string.c index ebfa6fb..604154c 100644 --- a/dlls/ntdll/string.c +++ b/dlls/ntdll/string.c @@ -465,24 +465,6 @@ ULONG __cdecl NTDLL_strtoul( const char *nptr, char **endptr, int base ) /********************************************************************* - * atoi (NTDLL.@) - */ -int __cdecl NTDLL_atoi( const char *nptr ) -{ - return atoi( nptr ); -} - - -/********************************************************************* - * atol (NTDLL.@) - */ -LONG __cdecl NTDLL_atol( const char *nptr ) -{ - return atol( nptr ); -} - - -/********************************************************************* * _ultoa (NTDLL.@) * * Convert an unsigned long integer to a string. @@ -727,7 +709,7 @@ char * __cdecl _i64toa( * - No check is made for value overflow, only the lower 64 bits are assigned. * - If str is NULL it crashes, as the native function does. */ -LONGLONG __cdecl _atoi64( char *str ) +LONGLONG __cdecl _atoi64( const char *str ) { ULONGLONG RunningTotal = 0; char bMinus = 0; @@ -753,6 +735,24 @@ LONGLONG __cdecl _atoi64( char *str ) /********************************************************************* + * atoi (NTDLL.@) + */ +int __cdecl NTDLL_atoi( const char *nptr ) +{ + return _atoi64( nptr ); +} + + +/********************************************************************* + * atol (NTDLL.@) + */ +LONG __cdecl NTDLL_atol( const char *nptr ) +{ + return _atoi64( nptr ); +} + + +/********************************************************************* * sprintf (NTDLL.@) */ int __cdecl NTDLL_sprintf( char *str, const char *format, ... ) diff --git a/dlls/ntdll/tests/string.c b/dlls/ntdll/tests/string.c index e9bf5e1..8a77048 100644 --- a/dlls/ntdll/tests/string.c +++ b/dlls/ntdll/tests/string.c @@ -893,6 +893,31 @@ static void test_wtoi(void) } /* for */ } +static void test_atoi(void) +{ + int test_num; + int result; + + for (test_num = 0; test_num < NB_STR2LONG; test_num++) { + result = patoi(str2long[test_num].str); + ok(result == str2long[test_num].value, + "(test %d): call failed: _atoi(\"%s\") has result %d, expected: %d\n", + test_num, str2long[test_num].str, result, str2long[test_num].value); + } /* for */ +} + +static void test_atol(void) +{ + int test_num; + int result; + + for (test_num = 0; test_num < NB_STR2LONG; test_num++) { + result = patol(str2long[test_num].str); + ok(result == str2long[test_num].value, + "(test %d): call failed: _atol(\"%s\") has result %d, expected: %d\n", + test_num, str2long[test_num].str, result, str2long[test_num].value); + } /* for */ +} static void test_wtol(void) { @@ -1095,4 +1120,8 @@ START_TEST(string) test_wtoi64(); if (p_wcschr && p_wcsrchr) test_wcsfuncs(); + if (patoi) + test_atoi(); + if (patol) + test_atol(); } -- 1.5.4.5