Fixed bug #251
authorSam Lantinga <slouken@libsdl.org>
Tue, 20 Jun 2006 05:55:23 +0000
changeset 1867 887c3600826b
parent 1866 926aea04a595
child 1868 c8f42ed8805e
Fixed bug #251
src/stdlib/SDL_string.c
--- a/src/stdlib/SDL_string.c	Tue Jun 20 05:49:53 2006 +0000
+++ b/src/stdlib/SDL_string.c	Tue Jun 20 05:55:23 2006 +0000
@@ -511,7 +511,15 @@
     size_t len;
     long value;
 
-    len = SDL_ScanLong(string, base ? base : 10, &value);
+    if ( !base ) {
+        if ( (SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0) ) {
+            base = 16;
+        } else {
+            base = 10;
+        }
+    }
+
+    len = SDL_ScanLong(string, base, &value);
     if ( endp ) {
         *endp = (char *)string + len;
     }
@@ -525,7 +533,15 @@
     size_t len;
     unsigned long value;
 
-    len = SDL_ScanUnsignedLong(string, base ? base : 10, &value);
+    if ( !base ) {
+        if ( (SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0) ) {
+            base = 16;
+        } else {
+            base = 10;
+        }
+    }
+
+    len = SDL_ScanUnsignedLong(string, base, &value);
     if ( endp ) {
         *endp = (char *)string + len;
     }
@@ -593,7 +609,15 @@
     size_t len;
     Sint64 value;
 
-    len = SDL_ScanLongLong(string, base ? base : 10, &value);
+    if ( !base ) {
+        if ( (SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0) ) {
+            base = 16;
+        } else {
+            base = 10;
+        }
+    }
+
+    len = SDL_ScanLongLong(string, base, &value);
     if ( endp ) {
         *endp = (char *)string + len;
     }
@@ -607,7 +631,15 @@
     size_t len;
     Uint64 value;
 
-    len = SDL_ScanUnsignedLongLong(string, base ? base : 10, &value);
+    if ( !base ) {
+        if ( (SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0) ) {
+            base = 16;
+        } else {
+            base = 10;
+        }
+    }
+
+    len = SDL_ScanUnsignedLongLong(string, base, &value);
     if ( endp ) {
         *endp = (char *)string + len;
     }