Skip to content
Open
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
13 changes: 13 additions & 0 deletions src/uu/numfmt/src/numfmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,19 @@
None => input_line,
};

// Return false if the input is in scientific notation
if let Some(pos) = line.iter().position(|&b| b == b'E' || b == b'e') {
if pos < line.len() - 1 {
if line[pos + 1] >= 48 && line[pos + 1] <= 57 {
let errormsg = format!(

Check failure on line 54 in src/uu/numfmt/src/numfmt.rs

View workflow job for this annotation

GitHub Actions / Style/spelling (ubuntu-latest, feat_os_unix)

ERROR: `cspell`: Unknown word 'errormsg' (file:'src/uu/numfmt/src/numfmt.rs', line:54)
"invalid suffix in input: '{}'",
NumfmtError::FormattingError(String::from_utf8_lossy(line).to_string())
);
return Err(Box::new(NumfmtError::FormattingError(errormsg)));

Check failure on line 58 in src/uu/numfmt/src/numfmt.rs

View workflow job for this annotation

GitHub Actions / Style/spelling (ubuntu-latest, feat_os_unix)

ERROR: `cspell`: Unknown word 'errormsg' (file:'src/uu/numfmt/src/numfmt.rs', line:58)
}
}
}

// In non-abort modes we buffer the formatted output so that on error we
// can emit the original line instead.
let buffer_output = !matches!(options.invalid, InvalidModes::Abort);
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 @@ -1405,7 +1405,6 @@ fn test_large_integer_precision_loss_issue_11654() {
// uutils accepts scientific notation (`1e9`, `5e-3`, ...); GNU rejects it
// as "invalid suffix in input".
#[test]
#[ignore = "GNU compat: see uutils/coreutils#11655"]
fn test_scientific_notation_rejected_by_gnu_issue_11655() {
new_ucmd!()
.arg("1e9")
Expand Down
Loading