From 76dfcd82faed3c548fc262933aac054ef3a8cb40 Mon Sep 17 00:00:00 2001 From: Arthur Pin Date: Fri, 6 Dec 2024 15:58:40 -0300 Subject: [PATCH 1/2] seq: handle scientific notation with uppercase 'E' --- src/uu/seq/src/numberparse.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uu/seq/src/numberparse.rs b/src/uu/seq/src/numberparse.rs index adbaccc11..79e7068e3 100644 --- a/src/uu/seq/src/numberparse.rs +++ b/src/uu/seq/src/numberparse.rs @@ -333,7 +333,7 @@ impl FromStr for PreciseNumber { // number differently depending on its form. This is important // because the form of the input dictates how the output will be // presented. - match (s.find('.'), s.find('e')) { + match (s.find('.'), s.find(['e', 'E'])) { // For example, "123456" or "inf". (None, None) => parse_no_decimal_no_exponent(s), // For example, "123e456" or "1e-2". From 88e10478bc8f231c5a551e7efab30b8ba92493d7 Mon Sep 17 00:00:00 2001 From: Arthur Pin Date: Fri, 6 Dec 2024 17:47:22 -0300 Subject: [PATCH 2/2] tests/seq: test scientific notation with uppercase 'E' --- src/uu/seq/src/numberparse.rs | 1 + tests/by-util/test_seq.rs | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/uu/seq/src/numberparse.rs b/src/uu/seq/src/numberparse.rs index 79e7068e3..891fa2ce6 100644 --- a/src/uu/seq/src/numberparse.rs +++ b/src/uu/seq/src/numberparse.rs @@ -392,6 +392,7 @@ mod tests { fn test_parse_big_int() { assert_eq!(parse("0"), ExtendedBigDecimal::zero()); assert_eq!(parse("0.1e1"), ExtendedBigDecimal::one()); + assert_eq!(parse("0.1E1"), ExtendedBigDecimal::one()); assert_eq!( parse("1.0e1"), ExtendedBigDecimal::BigDecimal("10".parse::().unwrap()) diff --git a/tests/by-util/test_seq.rs b/tests/by-util/test_seq.rs index c14d30629..ab0659f21 100644 --- a/tests/by-util/test_seq.rs +++ b/tests/by-util/test_seq.rs @@ -333,6 +333,11 @@ fn test_width_scientific_notation() { .succeeds() .stdout_is("0999\n1000\n") .no_stderr(); + new_ucmd!() + .args(&["-w", "999", "1E3"]) + .succeeds() + .stdout_is("0999\n1000\n") + .no_stderr(); } #[test]