mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
seq: Trim whitespaces, then try to remove +
Otherwise, `seq` crashes with ` 0xee.` as input. Also update one of the tests to catch that.
This commit is contained in:
parent
bec2cb65b2
commit
e0a6482759
2 changed files with 4 additions and 1 deletions
|
@ -27,9 +27,10 @@ pub enum ParseNumberError {
|
||||||
// need to be too careful.
|
// need to be too careful.
|
||||||
fn compute_num_digits(input: &str, ebd: ExtendedBigDecimal) -> PreciseNumber {
|
fn compute_num_digits(input: &str, ebd: ExtendedBigDecimal) -> PreciseNumber {
|
||||||
let input = input.to_lowercase();
|
let input = input.to_lowercase();
|
||||||
|
let input = input.trim_start();
|
||||||
|
|
||||||
// Leading + is ignored for this.
|
// Leading + is ignored for this.
|
||||||
let input = input.trim_start().strip_prefix('+').unwrap_or(&input);
|
let input = input.strip_prefix('+').unwrap_or(input);
|
||||||
|
|
||||||
// Integral digits for any hex number is ill-defined (0 is fine as an output)
|
// Integral digits for any hex number is ill-defined (0 is fine as an output)
|
||||||
// Fractional digits for an floating hex number is ill-defined, return None
|
// Fractional digits for an floating hex number is ill-defined, return None
|
||||||
|
|
|
@ -869,6 +869,8 @@ fn test_parse_valid_hexadecimal_float_two_args() {
|
||||||
(["0xA.A9p-1", "6"], "5.33008\n"),
|
(["0xA.A9p-1", "6"], "5.33008\n"),
|
||||||
(["0xa.a9p-1", "6"], "5.33008\n"),
|
(["0xa.a9p-1", "6"], "5.33008\n"),
|
||||||
(["0xffffffffffp-30", "1024"], "1024\n"), // spell-checker:disable-line
|
(["0xffffffffffp-30", "1024"], "1024\n"), // spell-checker:disable-line
|
||||||
|
([" 0XA.A9P-1", "6"], "5.33008\n"),
|
||||||
|
([" 0xee.", " 0xef."], "238\n239\n"),
|
||||||
];
|
];
|
||||||
|
|
||||||
for (input_arguments, expected_output) in &test_cases {
|
for (input_arguments, expected_output) in &test_cases {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue