[Bug #20705] Update strtod implementation

The absence of either the integer or fractional part should be
allowed.
This commit is contained in:
Nobuyoshi Nakada 2024-09-05 22:08:41 +09:00
parent f37e6d7f7b
commit d17edf3a17
No known key found for this signature in database
GPG key ID: 3582D74E1FEE4465
Notes: git 2024-10-05 14:59:02 +00:00
3 changed files with 20 additions and 26 deletions

View file

@ -1552,7 +1552,7 @@ break2:
aadj = 1.0;
nd0 = -4;
if (!*++s || !(s1 = strchr(hexdigit, *s))) goto ret0;
if (!*++s || (!(s1 = strchr(hexdigit, *s)) && *s != '.')) goto ret0;
if (*s == '0') {
while (*++s == '0');
if (!*s) goto ret;
@ -1566,9 +1566,7 @@ break2:
} while (*++s && (s1 = strchr(hexdigit, *s)));
}
if (*s == '.') {
dsign = 1;
if (!*++s || !(s1 = strchr(hexdigit, *s))) goto ret0;
if ((*s == '.') && *++s && (s1 = strchr(hexdigit, *s))) {
if (nd0 < 0) {
while (*s == '0') {
s++;
@ -1583,9 +1581,6 @@ break2:
}
}
}
else {
dsign = 0;
}
if (*s == 'P' || *s == 'p') {
dsign = 0x2C - *++s; /* +: 2B, -: 2D */
@ -1608,9 +1603,6 @@ break2:
} while ('0' <= c && c <= '9');
nd0 += nd * dsign;
}
else {
if (dsign) goto ret0;
}
dval(rv) = ldexp(adj, nd0);
goto ret;
}
@ -1647,9 +1639,9 @@ break2:
}
#endif
if (c == '.') {
if (!ISDIGIT(s[1]))
goto dig_done;
c = *++s;
if (!ISDIGIT(c))
goto dig_done;
if (!nd) {
for (; c == '0'; c = *++s)
nz++;