mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 16:44:01 +02:00
[Bug #20705] Update strtod
implementation
The absence of either the integer or fractional part should be allowed.
This commit is contained in:
parent
f37e6d7f7b
commit
d17edf3a17
Notes:
git
2024-10-05 14:59:02 +00:00
3 changed files with 20 additions and 26 deletions
|
@ -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++;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue