mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-12-01 23:24:21 +08:00
builtin_test.cpp: check for ERANGE and special fish_wcstoll errno
We were not parsing an in-range number when we claimed we were, and were thus failing to error with invalid numbers and returned a wrong test result. Fixed #5414 Also, provide the detail we can for the other error cases.
This commit is contained in:
parent
c1be3284c1
commit
4aa069a8ff
|
@ -657,7 +657,7 @@ static bool parse_number(const wcstring &arg, number_t *number, wcstring_list_t
|
|||
// invalid (e.g. not a representable integer).
|
||||
*number = number_t{integral, 0.0};
|
||||
return true;
|
||||
} else if (got_float) {
|
||||
} else if (got_float && errno != ERANGE) {
|
||||
// Here we parsed an (in range) floating point value that could not be parsed as an integer.
|
||||
// Break the floating point value into base and delta. Ensure that base is <= the floating
|
||||
// point value.
|
||||
|
@ -667,7 +667,11 @@ static bool parse_number(const wcstring &arg, number_t *number, wcstring_list_t
|
|||
return true;
|
||||
} else {
|
||||
// We could not parse a float or an int.
|
||||
errors.push_back(format_string(_(L"invalid number '%ls'"), arg.c_str()));
|
||||
// Check for special fish_wcsto* value or show standard EINVAL/ERANGE error.
|
||||
if (errno == -1)
|
||||
errors.push_back(format_string(_(L"Integer %lld in '%ls' followed by non-digit"), integral, argcs));
|
||||
else
|
||||
errors.push_back(format_string(L"%s: '%ls'", strerror(errno), argcs));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user