strutil: accept leading whitespace in parse rational
Programmatic output of floating point numbers might choose to print spaces instead of an explicit '+' sign, to align the output with the result of formatting negative numbers yet achieve a screen appearance similar to what humans would have written. Skip leading whitespace before insisting in seeing either signs or digits or decimals.
This commit is contained in:
parent
42408643f9
commit
7f5bfd6130
|
@ -616,6 +616,9 @@ SR_API int sr_parse_rational(const char *str, struct sr_rational *ret)
|
|||
int32_t exponent = 0;
|
||||
bool is_negative = false;
|
||||
|
||||
while (isspace(*str))
|
||||
str++;
|
||||
|
||||
errno = 0;
|
||||
integral = g_ascii_strtoll(str, &endptr, 10);
|
||||
|
||||
|
|
Loading…
Reference in New Issue