Fixed bug #251
authorSam Lantinga <slouken@libsdl.org>
Tue, 20 Jun 2006 05:55:23 +0000
changeset 1867887c3600826b
parent 1866 926aea04a595
child 1868 c8f42ed8805e
Fixed bug #251
src/stdlib/SDL_string.c
     1.1 --- a/src/stdlib/SDL_string.c	Tue Jun 20 05:49:53 2006 +0000
     1.2 +++ b/src/stdlib/SDL_string.c	Tue Jun 20 05:55:23 2006 +0000
     1.3 @@ -511,7 +511,15 @@
     1.4      size_t len;
     1.5      long value;
     1.6  
     1.7 -    len = SDL_ScanLong(string, base ? base : 10, &value);
     1.8 +    if ( !base ) {
     1.9 +        if ( (SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0) ) {
    1.10 +            base = 16;
    1.11 +        } else {
    1.12 +            base = 10;
    1.13 +        }
    1.14 +    }
    1.15 +
    1.16 +    len = SDL_ScanLong(string, base, &value);
    1.17      if ( endp ) {
    1.18          *endp = (char *)string + len;
    1.19      }
    1.20 @@ -525,7 +533,15 @@
    1.21      size_t len;
    1.22      unsigned long value;
    1.23  
    1.24 -    len = SDL_ScanUnsignedLong(string, base ? base : 10, &value);
    1.25 +    if ( !base ) {
    1.26 +        if ( (SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0) ) {
    1.27 +            base = 16;
    1.28 +        } else {
    1.29 +            base = 10;
    1.30 +        }
    1.31 +    }
    1.32 +
    1.33 +    len = SDL_ScanUnsignedLong(string, base, &value);
    1.34      if ( endp ) {
    1.35          *endp = (char *)string + len;
    1.36      }
    1.37 @@ -593,7 +609,15 @@
    1.38      size_t len;
    1.39      Sint64 value;
    1.40  
    1.41 -    len = SDL_ScanLongLong(string, base ? base : 10, &value);
    1.42 +    if ( !base ) {
    1.43 +        if ( (SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0) ) {
    1.44 +            base = 16;
    1.45 +        } else {
    1.46 +            base = 10;
    1.47 +        }
    1.48 +    }
    1.49 +
    1.50 +    len = SDL_ScanLongLong(string, base, &value);
    1.51      if ( endp ) {
    1.52          *endp = (char *)string + len;
    1.53      }
    1.54 @@ -607,7 +631,15 @@
    1.55      size_t len;
    1.56      Uint64 value;
    1.57  
    1.58 -    len = SDL_ScanUnsignedLongLong(string, base ? base : 10, &value);
    1.59 +    if ( !base ) {
    1.60 +        if ( (SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0) ) {
    1.61 +            base = 16;
    1.62 +        } else {
    1.63 +            base = 10;
    1.64 +        }
    1.65 +    }
    1.66 +
    1.67 +    len = SDL_ScanUnsignedLongLong(string, base, &value);
    1.68      if ( endp ) {
    1.69          *endp = (char *)string + len;
    1.70      }