diff --git a/Tests/LibC/TestScanf.cpp b/Tests/LibC/TestScanf.cpp index 4291276a4d6..8efca5350c8 100644 --- a/Tests/LibC/TestScanf.cpp +++ b/Tests/LibC/TestScanf.cpp @@ -178,6 +178,7 @@ const TestSuite test_suites[] { { "%llu", "9223372036854775810", 1, 1, { unsignedlonglongarg0 }, { to_value_t(9223372036854775810ULL) } }, { "%n", "", 0, 1, { intarg0 }, { to_value_t(0) } }, { "%d %n", "1 a", 1, 2, { intarg0, intarg1 }, { to_value_t(1), to_value_t(2) } }, + { "%*d", " 42", 0, 0, {}, {} }, }; bool g_any_failed = false; diff --git a/Userland/Libraries/LibC/scanf.cpp b/Userland/Libraries/LibC/scanf.cpp index 12e928a3760..70c21cb6533 100644 --- a/Userland/Libraries/LibC/scanf.cpp +++ b/Userland/Libraries/LibC/scanf.cpp @@ -555,61 +555,61 @@ extern "C" int vsscanf(const char* input, const char* format, va_list ap) case ConversionSpecifier::Decimal: if (!ReadElement {}(length_modifier, input_lexer, ap_or_null)) format_lexer.consume_all(); - else + else if (!suppress_assignment) ++elements_matched; break; case ConversionSpecifier::Integer: if (!ReadElement {}(length_modifier, input_lexer, ap_or_null)) format_lexer.consume_all(); - else + else if (!suppress_assignment) ++elements_matched; break; case ConversionSpecifier::Octal: if (!ReadElement {}(length_modifier, input_lexer, ap_or_null)) format_lexer.consume_all(); - else + else if (!suppress_assignment) ++elements_matched; break; case ConversionSpecifier::Unsigned: if (!ReadElement {}(length_modifier, input_lexer, ap_or_null)) format_lexer.consume_all(); - else + else if (!suppress_assignment) ++elements_matched; break; case ConversionSpecifier::Hex: if (!ReadElement {}(length_modifier, input_lexer, ap_or_null)) format_lexer.consume_all(); - else + else if (!suppress_assignment) ++elements_matched; break; case ConversionSpecifier::Floating: if (!ReadElement {}(length_modifier, input_lexer, ap_or_null)) format_lexer.consume_all(); - else + else if (!suppress_assignment) ++elements_matched; break; case ConversionSpecifier::String: if (!ReadElement {}(length_modifier, input_lexer, ap_or_null)) format_lexer.consume_all(); - else + else if (!suppress_assignment) ++elements_matched; break; case ConversionSpecifier::UseScanList: if (!ReadElement { scanlist, invert_scanlist }(length_modifier, input_lexer, ap_or_null)) format_lexer.consume_all(); - else + else if (!suppress_assignment) ++elements_matched; break; case ConversionSpecifier::Character: if (!ReadElement {}(length_modifier, input_lexer, ap_or_null)) format_lexer.consume_all(); - else + else if (!suppress_assignment) ++elements_matched; break; case ConversionSpecifier::Pointer: if (!ReadElement {}(length_modifier, input_lexer, ap_or_null)) format_lexer.consume_all(); - else + else if (!suppress_assignment) ++elements_matched; break; case ConversionSpecifier::OutputNumberOfBytes: {