printf: ignore zero flag on some conversions if precision is specified.

This commit is contained in:
Connor-GH
2026-04-10 11:19:55 -05:00
parent da40ffa9ec
commit 7ec3e239b5
+10
View File
@@ -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,