From 307305f28a07c8f355e8b809eb918129a6418001 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kau=C3=A3=20Klassmann?= Date: Thu, 22 Jan 2026 12:44:27 -0300 Subject: [PATCH 1/2] fix: scientific notation is incorrectly parsed in general sort --- src/uu/sort/src/sort.rs | 2 +- tests/by-util/test_sort.rs | 7 +++- .../exponents-positive-general.expected.debug | 36 +++++++++++++++++++ 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 tests/fixtures/sort/exponents-positive-general.expected.debug diff --git a/src/uu/sort/src/sort.rs b/src/uu/sort/src/sort.rs index 01ddc63fbe0..edbe52a9c67 100644 --- a/src/uu/sort/src/sort.rs +++ b/src/uu/sort/src/sort.rs @@ -2700,7 +2700,7 @@ fn get_leading_gen(inp: &[u8], decimal_pt: u8) -> Range { if let Some(&(_, &next_char)) = char_indices.peek() { if (next_char == b'+' || next_char == b'-') && matches!( - char_indices.peek_nth(2), + char_indices.peek_nth(1), Some((_, c)) if c.is_ascii_digit() ) { diff --git a/tests/by-util/test_sort.rs b/tests/by-util/test_sort.rs index e794898a286..6fd5903487c 100644 --- a/tests/by-util/test_sort.rs +++ b/tests/by-util/test_sort.rs @@ -458,10 +458,15 @@ fn test_non_printing_chars() { } #[test] -fn test_exponents_positive_general_fixed() { +fn test_exponents_general() { test_helper("exponents_general", &["-g"]); } +#[test] +fn test_exponents_positive_general() { + test_helper("exponents-positive-general", &["-g"]); +} + #[test] fn test_exponents_positive_numeric() { test_helper( diff --git a/tests/fixtures/sort/exponents-positive-general.expected.debug b/tests/fixtures/sort/exponents-positive-general.expected.debug new file mode 100644 index 00000000000..c209d01b45f --- /dev/null +++ b/tests/fixtures/sort/exponents-positive-general.expected.debug @@ -0,0 +1,36 @@ + +^ no match for key +^ no match for key + +^ no match for key +^ no match for key + +^ no match for key +^ no match for key + +^ no match for key +^ no match for key + +^ no match for key +^ no match for key + +^ no match for key +^ no match for key +10E +__ +___ +1000EDKLD +____ +_________ +10000K78 +_____ +________ ++100000 +_______ +_______ +100E6 +_____ +_____ +50e10 +_____ +_____ From df8f55babf2284fe8f8924196164e1af006ee647 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kau=C3=A3=20Klassmann?= Date: Sun, 25 Jan 2026 21:16:52 -0300 Subject: [PATCH 2/2] test(sort): refactor exponents_positive_general test --- tests/by-util/test_sort.rs | 6 +++- .../sort/exponents-positive-general.expected | 12 ------- .../exponents-positive-general.expected.debug | 36 ------------------- .../sort/exponents-positive-general.txt | 12 ------- 4 files changed, 5 insertions(+), 61 deletions(-) delete mode 100644 tests/fixtures/sort/exponents-positive-general.expected delete mode 100644 tests/fixtures/sort/exponents-positive-general.expected.debug delete mode 100644 tests/fixtures/sort/exponents-positive-general.txt diff --git a/tests/by-util/test_sort.rs b/tests/by-util/test_sort.rs index 6fd5903487c..d46dcf5206f 100644 --- a/tests/by-util/test_sort.rs +++ b/tests/by-util/test_sort.rs @@ -464,7 +464,11 @@ fn test_exponents_general() { #[test] fn test_exponents_positive_general() { - test_helper("exponents-positive-general", &["-g"]); + new_ucmd!() + .pipe_in("1\n2e3\n1e-5") + .arg("-g") + .succeeds() + .stdout_only("1e-5\n1\n2e3\n"); } #[test] diff --git a/tests/fixtures/sort/exponents-positive-general.expected b/tests/fixtures/sort/exponents-positive-general.expected deleted file mode 100644 index 3dbc92fe5cc..00000000000 --- a/tests/fixtures/sort/exponents-positive-general.expected +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - -10E -1000EDKLD -10000K78 -+100000 -100E6 -50e10 diff --git a/tests/fixtures/sort/exponents-positive-general.expected.debug b/tests/fixtures/sort/exponents-positive-general.expected.debug deleted file mode 100644 index c209d01b45f..00000000000 --- a/tests/fixtures/sort/exponents-positive-general.expected.debug +++ /dev/null @@ -1,36 +0,0 @@ - -^ no match for key -^ no match for key - -^ no match for key -^ no match for key - -^ no match for key -^ no match for key - -^ no match for key -^ no match for key - -^ no match for key -^ no match for key - -^ no match for key -^ no match for key -10E -__ -___ -1000EDKLD -____ -_________ -10000K78 -_____ -________ -+100000 -_______ -_______ -100E6 -_____ -_____ -50e10 -_____ -_____ diff --git a/tests/fixtures/sort/exponents-positive-general.txt b/tests/fixtures/sort/exponents-positive-general.txt deleted file mode 100644 index 23ea527718a..00000000000 --- a/tests/fixtures/sort/exponents-positive-general.txt +++ /dev/null @@ -1,12 +0,0 @@ -10000K78 -10E - - -1000EDKLD - - -100E6 - -50e10 -+100000 -