Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

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 59f1ef4 commit d17c1b8
Showing 1 changed file with 36 additions and 4 deletions.
40 changes: 36 additions & 4 deletions src/stdlib/SDL_string.c
Expand Up @@ -534,7 +534,15 @@ 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 @@ -549,7 +557,15 @@ 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 @@ -620,7 +636,15 @@ 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 @@ -635,7 +659,15 @@ 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 d17c1b8

Please sign in to comment.