Fixed bug #251 SDL-1.3
authorSam Lantinga <slouken@libsdl.org>
Tue, 20 Jun 2006 05:57:50 +0000
branchSDL-1.3
changeset 1693 504cb581ae1c
parent 1692 75f2ace8511a
child 1694 7b19e09f5481
Fixed bug #251
src/stdlib/SDL_string.c
--- a/src/stdlib/SDL_string.c	Tue Jun 20 05:50:12 2006 +0000
+++ b/src/stdlib/SDL_string.c	Tue Jun 20 05:57:50 2006 +0000
@@ -534,7 +534,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;
     }
@@ -549,7 +557,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;
     }
@@ -620,7 +636,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;
     }
@@ -635,7 +659,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;
     }