Skip to content

Commit

Permalink
Fixed bug #251
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Jun 20, 2006
1 parent 009c720 commit a4ce66a
Showing 1 changed file with 36 additions and 4 deletions.
40 changes: 36 additions & 4 deletions src/stdlib/SDL_string.c
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down

0 comments on commit a4ce66a

Please sign in to comment.