fix: scientific notation is incorrectly parsed in general numeric sort (#10437)

* fix: scientific notation is incorrectly parsed in general sort

* test(sort): refactor exponents_positive_general test

---------

Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
This commit is contained in:
Kaua Klassmann
2026-02-12 02:52:22 -08:00
committed by GitHub
co-authored by Sylvestre Ledru
parent 07567b1c63
commit 808865e4ac
4 changed files with 11 additions and 26 deletions
+1 -1
View File
@@ -2816,7 +2816,7 @@ fn get_leading_gen(inp: &[u8], decimal_pt: u8) -> Range<usize> {
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()
)
{
+10 -1
View File
@@ -478,10 +478,19 @@ 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() {
new_ucmd!()
.pipe_in("1\n2e3\n1e-5")
.arg("-g")
.succeeds()
.stdout_only("1e-5\n1\n2e3\n");
}
#[test]
fn test_exponents_positive_numeric() {
test_helper(
-12
View File
@@ -1,12 +0,0 @@
10E
1000EDKLD
10000K78
+100000
100E6
50e10
-12
View File
@@ -1,12 +0,0 @@
10000K78
10E
1000EDKLD
100E6
50e10
+100000