fixed parsef, exponent can now follow integer part

master
Tibor Bizjak 2023-07-17 12:44:19 +02:00
parent bcff42f74d
commit e6de3d1193
1 changed files with 18 additions and 20 deletions

View File

@ -188,27 +188,25 @@ char * parsef(char s[], double *x)
int sign = SIGN(s); int sign = SIGN(s);
ATOI(s, *x); ATOI(s, *x);
#define X(sep) *s != sep &&
if (DEC_SEP 1) {
*x *= sign;
return s;
}
#undef X
s++;
/* fractional part */
int exp = 0; int exp = 0;
ATOI(s, *x, exp--); /* fractional part */
*x *= sign * pow(10, exp); #define X(sep) *s == sep ||
if (DEC_SEP 0) {
#define X(sep) *s != sep && s++;
if (EXP_SEP 1) ATOI(s, *x, exp--);
return s; *x *= pow(10, exp);
#undef X }
*x *= sign;
#undef X
/* exponent part */
#define X(sep) *s == sep ||
if (EXP_SEP 0) {
s++; s++;
/* exponent */
sign = SIGN(s); sign = SIGN(s);
exp = 0; exp = 0;
ATOI(s, exp); ATOI(s, exp);
*x *= pow(10, sign * exp); *x *= pow(10, sign * exp);
}
#undef X
return s; return s;
} }