Lei Zhang : ntdll: Use our own implementation of atoi and atol.

Alexandre Julliard julliard at winehq.org
Tue Jul 22 09:35:42 CDT 2008


Module: wine
Branch: master
Commit: ee60c49dd63fc65b9eb6813cb910ba581d80758d
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=ee60c49dd63fc65b9eb6813cb910ba581d80758d

Author: Lei Zhang <thestig at google.com>
Date:   Mon Jul 21 18:15:20 2008 -0700

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..40a39a4 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);
+    }
+}
+
+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);
+    }
+}
 
 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();
 }




More information about the wine-cvs mailing list