Accept numbers like "123." where the period (dot) is present yet the
fractional part is empty. Adding a period but no additional digits is a
popular method of turning an otherwise integer literal into a float.
Compilers and strtod() routines accept this notation, too, so we have to
expect seeing such input.
errno = 0;
if (*endptr == '.') {
+ bool is_exp, is_eos;
const char *start = endptr + 1;
fractional = g_ascii_strtoll(start, &endptr, 10);
+ is_exp = *endptr == 'E' || *endptr == 'e';
+ is_eos = *endptr == '\0';
+ if (endptr == start && (is_exp || is_eos)) {
+ fractional = 0;
+ errno = 0;
+ }
if (errno)
return SR_ERR;
fractional_len = endptr - start;