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:
Gerhard Sittig 2018-07-19 21:10:15 +02:00 committed by Uwe Hermann
parent 42408643f9
commit 7f5bfd6130
1 changed files with 3 additions and 0 deletions

View File

@ -616,6 +616,9 @@ SR_API int sr_parse_rational(const char *str, struct sr_rational *ret)
int32_t exponent = 0; int32_t exponent = 0;
bool is_negative = false; bool is_negative = false;
while (isspace(*str))
str++;
errno = 0; errno = 0;
integral = g_ascii_strtoll(str, &endptr, 10); integral = g_ascii_strtoll(str, &endptr, 10);