From: Gerhard Sittig Date: Thu, 19 Jul 2018 19:10:15 +0000 (+0200) Subject: strutil: accept leading whitespace in parse rational X-Git-Url: https://sigrok.org/gitweb/?a=commitdiff_plain;h=7f5bfd613058ce09b267294004717eed2fc2582c;p=libsigrok.git 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. --- 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);