Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/uu/numfmt/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,12 @@ fn format_string(
let padded_number = match padding {
0 => number_with_suffix,
p if p > 0 && options.format.zero_padding => {
let zero_padded = pad_string(&number_with_suffix, p as usize, '0', true);
let zero_padded = if let Some(unsigned) = number_with_suffix.strip_prefix(['-', '+']) {
let sign = &number_with_suffix[..1];
format!("{sign}{}", pad_string(unsigned, p as usize - 1, '0', true))
} else {
pad_string(&number_with_suffix, p as usize, '0', true)
};

match implicit_padding.unwrap_or(options.padding) {
0 => zero_padded,
Expand Down
1 change: 0 additions & 1 deletion tests/by-util/test_numfmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,6 @@ fn test_from_unit_fractional_precision_issue_11663() {
// Zero-padded `--format` places padding zeros before the sign for negative
// numbers; GNU (and C printf) puts the sign first.
#[test]
#[ignore = "GNU compat: see uutils/coreutils#11664"]
fn test_zero_pad_sign_order_issue_11664() {
new_ucmd!()
.args(&["--from=none", "--format=%018.2f", "--", "-9869647"])
Expand Down
Loading