Don't encode zero width or precision in fmt string.
This commit is contained in:
parent
564c78fe62
commit
560b12d094
1 changed files with 10 additions and 4 deletions
|
|
@ -393,13 +393,19 @@ fn expand_format_args<'hir>(
|
|||
bytecode.extend_from_slice(&flags.to_le_bytes());
|
||||
if let Some(val) = &o.width {
|
||||
let (indirect, val) = make_count(val, &mut argmap);
|
||||
bytecode[i] |= 1 << 1 | (indirect as u8) << 4;
|
||||
bytecode.extend_from_slice(&val.to_le_bytes());
|
||||
// Only encode if nonzero; zero is the default.
|
||||
if indirect || val != 0 {
|
||||
bytecode[i] |= 1 << 1 | (indirect as u8) << 4;
|
||||
bytecode.extend_from_slice(&val.to_le_bytes());
|
||||
}
|
||||
}
|
||||
if let Some(val) = &o.precision {
|
||||
let (indirect, val) = make_count(val, &mut argmap);
|
||||
bytecode[i] |= 1 << 2 | (indirect as u8) << 5;
|
||||
bytecode.extend_from_slice(&val.to_le_bytes());
|
||||
// Only encode if nonzero; zero is the default.
|
||||
if indirect || val != 0 {
|
||||
bytecode[i] |= 1 << 2 | (indirect as u8) << 5;
|
||||
bytecode.extend_from_slice(&val.to_le_bytes());
|
||||
}
|
||||
}
|
||||
}
|
||||
if implicit_arg_index != position {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue