From 7ec3e239b5b50d2adfdb177d550138b8a5f4a20d Mon Sep 17 00:00:00 2001 From: Connor-GH Date: Fri, 10 Apr 2026 11:19:55 -0500 Subject: [PATCH] printf: ignore zero flag on some conversions if precision is specified. --- src/header/stdio/printf.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/header/stdio/printf.rs b/src/header/stdio/printf.rs index d5057d3934..78883f0b54 100644 --- a/src/header/stdio/printf.rs +++ b/src/header/stdio/printf.rs @@ -704,6 +704,16 @@ impl<'a, T: c_str::Kind> Iterator for PrintfIter<'a, T> { } _ => return Some(Err(())), }; + // "For b, B, d, i, o, u, x, and X conversions, + // if a precision is specified, the 0 flag is ignored." + match fmt { + 'b' | 'B' | 'd' | 'i' | 'o' | 'u' | 'x' | 'X' => { + if precision.is_some() { + zero = false; + } + } + _ => (), + } Some(Ok(PrintfFmt::Arg(PrintfArg { index,