Skip to content

Commit b860ce8

Browse files
authored
Merge pull request #7650 from drinkcat/seq-trim-fix
seq: Trim whitespaces, then try to remove +
2 parents bec2cb6 + e0a6482 commit b860ce8

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/uu/seq/src/numberparse.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ pub enum ParseNumberError {
2727
// need to be too careful.
2828
fn compute_num_digits(input: &str, ebd: ExtendedBigDecimal) -> PreciseNumber {
2929
let input = input.to_lowercase();
30+
let input = input.trim_start();
3031

3132
// Leading + is ignored for this.
32-
let input = input.trim_start().strip_prefix('+').unwrap_or(&input);
33+
let input = input.strip_prefix('+').unwrap_or(input);
3334

3435
// Integral digits for any hex number is ill-defined (0 is fine as an output)
3536
// Fractional digits for an floating hex number is ill-defined, return None

tests/by-util/test_seq.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,8 @@ fn test_parse_valid_hexadecimal_float_two_args() {
869869
(["0xA.A9p-1", "6"], "5.33008\n"),
870870
(["0xa.a9p-1", "6"], "5.33008\n"),
871871
(["0xffffffffffp-30", "1024"], "1024\n"), // spell-checker:disable-line
872+
([" 0XA.A9P-1", "6"], "5.33008\n"),
873+
([" 0xee.", " 0xef."], "238\n239\n"),
872874
];
873875

874876
for (input_arguments, expected_output) in &test_cases {

0 commit comments

Comments
 (0)