Skip to content
Permalink
Browse files

Fixed bug #251

  • Loading branch information
slouken committed Jun 20, 2006
1 parent 009c720 commit a4ce66a6fbbbf2b1d56c624914d708f283015734
Showing with 36 additions and 4 deletions.
  1. +36 −4 src/stdlib/SDL_string.c
@@ -511,7 +511,15 @@ long SDL_strtol(const char *string, char **endp, int base)
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 @@ unsigned long SDL_strtoul(const char *string, char **endp, int base)
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 @@ Sint64 SDL_strtoll(const char *string, char **endp, int base)
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 @@ Uint64 SDL_strtoull(const char *string, char **endp, int base)
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;
}

0 comments on commit a4ce66a

Please sign in to comment.