mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09:00
LibC: Support X
modifier for scanf
This was currently crashing Half-Life because it was a considered an "Unknown" specifier. We can use the same case statement as the regular hex format conversion (lower case 'x'), as the backend to convert the number already supports upper/lower case input, hence we get it for free :^)
This commit is contained in:
parent
022b4a3ed3
commit
2de7f2021d
Notes:
sideshowbarker
2024-07-17 21:48:51 +09:00
Author: https://github.com/Quaker762
Commit: 2de7f2021d
Pull-request: https://github.com/SerenityOS/serenity/pull/11532
Reviewed-by: https://github.com/IdanHo ✅
Reviewed-by: https://github.com/alimpfard
2 changed files with 4 additions and 0 deletions
|
@ -153,6 +153,9 @@ const TestSuite test_suites[] {
|
|||
{ "%x", "0x519", 1, 1, { unsignedarg0 }, { to_value_t(0x519) } },
|
||||
{ "%x", "0x51g", 1, 1, { unsignedarg0 }, { to_value_t(0x51u) } },
|
||||
{ "%06x", "0xabcdef", 1, 1, { unsignedarg0 }, { to_value_t(0xabcdefu) } },
|
||||
{ "%X", "0xCAFEBABE", 1, 1, { unsignedarg0 }, { to_value_t(0xcafebabe) } },
|
||||
{ "%04X", "0x5E4E", 1, 1, { unsignedarg0 }, { to_value_t(0x5e4e) } },
|
||||
{ "%X", "0x51Eg", 1, 1, { unsignedarg0 }, { to_value_t(0x51e) } },
|
||||
{ "\"%%%d#", "\"%42#", 1, 1, { intarg0 }, { to_value_t(42) } },
|
||||
{ " %d", "42", 1, 1, { intarg0 }, { to_value_t(42) } },
|
||||
{ "%d", " 42", 1, 1, { intarg0 }, { to_value_t(42) } },
|
||||
|
|
|
@ -488,6 +488,7 @@ extern "C" int vsscanf(const char* input, const char* format, va_list ap)
|
|||
conversion_specifier = ConversionSpecifier::Unsigned;
|
||||
break;
|
||||
case 'x':
|
||||
case 'X':
|
||||
format_lexer.consume();
|
||||
conversion_specifier = ConversionSpecifier::Hex;
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue