Author: mjansen
Date: Tue May 24 19:27:57 2016
New Revision: 71396

URL: http://svn.reactos.org/svn/reactos?rev=71396&view=rev
Log:
[CRT] Partially sync strtoi64 with Wine Staging 1.9.9. Patch by Samuel Serapión 
CORE-11174 #resolve #comment Thanks!

Modified:
    trunk/reactos/media/doc/README.WINE
    trunk/reactos/sdk/lib/crt/libcntpr.cmake
    trunk/reactos/sdk/lib/crt/string/strtoi64.c
    trunk/reactos/sdk/lib/crt/string/strtoul.c

Modified: trunk/reactos/media/doc/README.WINE
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=71396&r1=71395&r2=71396&view=diff
==============================================================================
--- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original)
+++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Tue May 24 19:27:57 2016
@@ -291,7 +291,8 @@
   reactos/lib/sdk/crt/process/_cwait.c          # Synced to WineStaging-1.7.37
   reactos/lib/sdk/crt/signal/xcptinfo.c         # Synced to WineStaging-1.7.37
   reactos/lib/sdk/crt/string/scanf.c/h          # Synced to Wine-1.7.17
-  reactos/lib/sdk/crt/string/strtoul.c          # Synced to WineStaging-1.7.37
+  reactos/lib/sdk/crt/string/strtoi64.c         # Synced to WineStaging-1.9.9
+  reactos/lib/sdk/crt/string/strtoul.c          # Synced to WineStaging-1.9.9
   reactos/lib/sdk/crt/strings/wcs.c             # Synced at 20080611
   reactos/lib/sdk/crt/wine/heap.c               # Synced at 20080529
   reactos/lib/sdk/crt/wine/undname.c            # Synced to WineStaging-1.7.55

Modified: trunk/reactos/sdk/lib/crt/libcntpr.cmake
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/crt/libcntpr.cmake?rev=71396&r1=71395&r2=71396&view=diff
==============================================================================
--- trunk/reactos/sdk/lib/crt/libcntpr.cmake    [iso-8859-1] (original)
+++ trunk/reactos/sdk/lib/crt/libcntpr.cmake    [iso-8859-1] Tue May 24 
19:27:57 2016
@@ -48,6 +48,7 @@
     string/itoa.c
     string/itow.c
     string/mbstowcs_nt.c
+    string/strtoi64.c
     string/strtol.c
     string/strtoul.c
     string/strtoull.c

Modified: trunk/reactos/sdk/lib/crt/string/strtoi64.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/crt/string/strtoi64.c?rev=71396&r1=71395&r2=71396&view=diff
==============================================================================
--- trunk/reactos/sdk/lib/crt/string/strtoi64.c [iso-8859-1] (original)
+++ trunk/reactos/sdk/lib/crt/string/strtoi64.c [iso-8859-1] Tue May 24 
19:27:57 2016
@@ -1,13 +1,28 @@
 #include <precomp.h>
 
+/* Based on Wine Staging 1.9.9 - dlls/msvcrt/string.c */
 
-__int64
-_strtoi64(const char *nptr, char **endptr, int base)
+/*********************************************************************
+*  _strtoi64_l (MSVCRT.@)
+*
+* FIXME: locale parameter is ignored
+*/
+__int64 CDECL strtoi64_l(const char *nptr, char **endptr, int base, _locale_t 
locale)
 {
+    const char *p = nptr;
     BOOL negative = FALSE;
+    BOOL got_digit = FALSE;
     __int64 ret = 0;
 
-   while(isspace((unsigned char)*nptr)) nptr++;
+#ifndef _LIBCNT_
+    TRACE("(%s %p %d %p)\n", debugstr_a(nptr), endptr, base, locale);
+#endif
+
+    if (!MSVCRT_CHECK_PMT(nptr != NULL)) return 0;
+    if (!MSVCRT_CHECK_PMT(base == 0 || base >= 2)) return 0;
+    if (!MSVCRT_CHECK_PMT(base <= 36)) return 0;
+
+    while (isspace(*nptr)) nptr++;
 
     if(*nptr == '-') {
         negative = TRUE;
@@ -31,7 +46,7 @@
         char cur = tolower(*nptr);
         int v;
 
-        if(isdigit((unsigned char)cur)) {
+        if(isdigit(cur)) {
             if(cur >= '0'+base)
                 break;
             v = cur-'0';
@@ -40,6 +55,7 @@
                 break;
             v = cur-'a'+10;
         }
+        got_digit = TRUE;
 
         if(negative)
             v = -v;
@@ -48,19 +64,31 @@
 
         if(!negative && (ret>_I64_MAX/base || ret*base>_I64_MAX-v)) {
             ret = _I64_MAX;
+#ifndef _LIBCNT_
             *_errno() = ERANGE;
-        } else if(negative && (ret<_I64_MIN/base || ret*base<_I64_MIN-v)) {
+#endif
+        }
+        else if (negative && (ret<_I64_MIN / base || ret*base<_I64_MIN - v)) {
             ret = _I64_MIN;
+#ifndef _LIBCNT_
             *_errno() = ERANGE;
-        } else
+#endif
+        }
+        else
             ret = ret*base + v;
     }
 
     if(endptr)
-        *endptr = (char*)nptr;
+        *endptr = (char*)(got_digit ? nptr : p);
 
     return ret;
 }
 
+__int64
+_strtoi64(const char *nptr, char **endptr, int base)
+{
+    return  strtoi64_l(nptr, endptr, base, NULL);
+}
+
 
 /* EOF */

Modified: trunk/reactos/sdk/lib/crt/string/strtoul.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/lib/crt/string/strtoul.c?rev=71396&r1=71395&r2=71396&view=diff
==============================================================================
--- trunk/reactos/sdk/lib/crt/string/strtoul.c  [iso-8859-1] (original)
+++ trunk/reactos/sdk/lib/crt/string/strtoul.c  [iso-8859-1] Tue May 24 
19:27:57 2016
@@ -1,83 +1,7 @@
 #include <precomp.h>
 
-/* Based on Wine Staging 1.7.37 - dlls/msvcrt/string.c */
-
-/*********************************************************************
- *  _strtoi64_l (MSVCRT.@)
- *
- * FIXME: locale parameter is ignored
- */
-__int64 CDECL strtoi64_l(const char *nptr, char **endptr, int base, _locale_t 
locale)
-{
-    BOOL negative = FALSE;
-    __int64 ret = 0;
-
-#ifndef _LIBCNT_
-    TRACE("(%s %p %d %p)\n", debugstr_a(nptr), endptr, base, locale);
-#endif
-
-    if (!MSVCRT_CHECK_PMT(nptr != NULL)) return 0;
-    if (!MSVCRT_CHECK_PMT(base == 0 || base >= 2)) return 0;
-    if (!MSVCRT_CHECK_PMT(base <= 36)) return 0;
-
-    while(isspace(*nptr)) nptr++;
-
-    if(*nptr == '-') {
-        negative = TRUE;
-        nptr++;
-    } else if(*nptr == '+')
-        nptr++;
-
-    if((base==0 || base==16) && *nptr=='0' && tolower(*(nptr+1))=='x') {
-        base = 16;
-        nptr += 2;
-    }
-
-    if(base == 0) {
-        if(*nptr=='0')
-            base = 8;
-        else
-            base = 10;
-    }
-
-    while(*nptr) {
-        char cur = tolower(*nptr);
-        int v;
-
-        if(isdigit(cur)) {
-            if(cur >= '0'+base)
-                break;
-            v = cur-'0';
-        } else {
-            if(cur<'a' || cur>='a'+base-10)
-                break;
-            v = cur-'a'+10;
-        }
-
-        if(negative)
-            v = -v;
-
-        nptr++;
-
-        if(!negative && (ret>_I64_MAX/base || ret*base>_I64_MAX-v)) {
-            ret = _I64_MAX;
-#ifndef _LIBCNT_
-            *_errno() = ERANGE;
-#endif
-        } else if(negative && (ret<_I64_MIN/base || ret*base<_I64_MIN-v)) {
-            ret = _I64_MIN;
-#ifndef _LIBCNT_
-            *_errno() = ERANGE;
-#endif
-        } else
-            ret = ret*base + v;
-    }
-
-    if(endptr)
-        *endptr = (char*)nptr;
-
-    return ret;
-}
+/* Based on Wine Staging 1.9.9 - dlls/msvcrt/string.c */
+__int64 CDECL strtoi64_l(const char *nptr, char **endptr, int base, _locale_t 
locale);
 
 /******************************************************************
  *             _strtoul_l (MSVCRT.@)


Reply via email to