Skip to content

Commit

Permalink
Check "ll" length specifier before "l"
Browse files Browse the repository at this point in the history
The "l" length specifier might match the first character of "ll" so
look for "ll" first.
  • Loading branch information
Ido Yariv committed Sep 10, 2023
1 parent 42ecde1 commit 83184bb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ fn take_conversion_specifier(s: &str) -> Result<(ConversionSpecifier, &str)> {
s = s2;
}
// check length specifier
for len_spec in ["hh", "h", "l", "ll", "q", "L", "j", "z", "Z", "t"] {
for len_spec in ["hh", "h", "ll", "l", "q", "L", "j", "z", "Z", "t"] {
if s.starts_with(len_spec) {
s = s.strip_prefix(len_spec).ok_or(PrintfError::ParseError)?;
break; // only allow one length specifier
Expand Down
1 change: 1 addition & 0 deletions tests/compare_to_libc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ fn test_int() {
check_fmt("%lX", -4_i64);
check_fmt("%ld", 48_i64);
check_fmt("%-8hd", -12_i16);
check_fmt("%llx", 0x0123456789abcdef_u64);
}

#[test]
Expand Down

0 comments on commit 83184bb

Please sign in to comment.