mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
printf: Default left-justify integer conversion to 1 width
When using left-justify with integer conversion (like `printf '%-o'`), default the minimum width to 1. Closes: https://github.com/uutils/coreutils/issues/3050 Signed-off-by: Hanif Ariffin <hanif.ariffin.4326@gmail.com>
This commit is contained in:
parent
f869fafd03
commit
2e60dce11a
2 changed files with 13 additions and 1 deletions
|
@ -152,7 +152,11 @@ impl SubParser {
|
||||||
if parser.min_width_is_asterisk {
|
if parser.min_width_is_asterisk {
|
||||||
CanAsterisk::Asterisk
|
CanAsterisk::Asterisk
|
||||||
} else {
|
} else {
|
||||||
CanAsterisk::Fixed(parser.min_width_tmp.map(|x| x.parse::<isize>().unwrap()))
|
CanAsterisk::Fixed(
|
||||||
|
parser
|
||||||
|
.min_width_tmp
|
||||||
|
.map(|x| x.parse::<isize>().unwrap_or(1)),
|
||||||
|
)
|
||||||
},
|
},
|
||||||
if parser.second_field_is_asterisk {
|
if parser.second_field_is_asterisk {
|
||||||
CanAsterisk::Asterisk
|
CanAsterisk::Asterisk
|
||||||
|
|
|
@ -446,6 +446,14 @@ fn sub_any_specifiers_after_period() {
|
||||||
.stdout_only("3");
|
.stdout_only("3");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn unspecified_left_justify_is_1_width() {
|
||||||
|
new_ucmd!()
|
||||||
|
.args(&["%-o"]) //spell-checker:disable-line
|
||||||
|
.succeeds()
|
||||||
|
.stdout_only("0");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn sub_any_specifiers_after_second_param() {
|
fn sub_any_specifiers_after_second_param() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue