mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-06-14 18:27:50 +00:00
Fixed sscanf("026", "%1x%1x%1x", &r, &g, &b)
Fixes https://github.com/libsdl-org/SDL/issues/12510
(cherry picked from commit be6ed6e9c4)
This commit is contained in:
parent
9f32fafe21
commit
776f0a685c
2 changed files with 22 additions and 14 deletions
|
|
@ -368,14 +368,12 @@ static size_t SDL_ScanUnsignedLongLongInternal(const char *text, int count, int
|
|||
negative = *text == '-';
|
||||
++text;
|
||||
}
|
||||
if ((radix == 0 || radix == 16) && *text == '0' && text[1] != '\0') {
|
||||
if ((radix == 0 || radix == 16) && *text == '0' && (text[1] == 'x' || text[1] == 'X')) {
|
||||
text += 2;
|
||||
radix = 16;
|
||||
} else if (radix == 0 && *text == '0' && (text[1] >= '0' && text[1] <= '9')) {
|
||||
++text;
|
||||
if (*text == 'x' || *text == 'X') {
|
||||
radix = 16;
|
||||
++text;
|
||||
} else if (radix == 0) {
|
||||
radix = 8;
|
||||
}
|
||||
radix = 8;
|
||||
} else if (radix == 0) {
|
||||
radix = 10;
|
||||
}
|
||||
|
|
@ -462,14 +460,12 @@ static size_t SDL_ScanUnsignedLongLongInternalW(const wchar_t *text, int count,
|
|||
negative = *text == '-';
|
||||
++text;
|
||||
}
|
||||
if ((radix == 0 || radix == 16) && *text == '0') {
|
||||
if ((radix == 0 || radix == 16) && *text == '0' && (text[1] == 'x' || text[1] == 'X')) {
|
||||
text += 2;
|
||||
radix = 16;
|
||||
} else if (radix == 0 && *text == '0' && (text[1] >= '0' && text[1] <= '9')) {
|
||||
++text;
|
||||
if (*text == 'x' || *text == 'X') {
|
||||
radix = 16;
|
||||
++text;
|
||||
} else if (radix == 0) {
|
||||
radix = 8;
|
||||
}
|
||||
radix = 8;
|
||||
} else if (radix == 0) {
|
||||
radix = 10;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue