From 7f5bfd613058ce09b267294004717eed2fc2582c Mon Sep 17 00:00:00 2001 From: Gerhard Sittig Date: Thu, 19 Jul 2018 21:10:15 +0200 Subject: [PATCH] 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. --- src/strutil.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/strutil.c b/src/strutil.c index 28f202c9..07ed7b44 100644 --- a/src/strutil.c +++ b/src/strutil.c @@ -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);