aboutsummaryrefslogtreecommitdiffstats
path: root/object.c
diff options
context:
space:
mode:
Diffstat (limited to 'object.c')
-rw-r--r--object.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/object.c b/object.c
index 971c0a73bf..88b4c56cb5 100644
--- a/object.c
+++ b/object.c
@@ -2870,15 +2870,10 @@ rb_cstr_to_dbl(const char *p, int badcheck)
while (p < end && n < e) prev = *n++ = *p++;
while (*p) {
if (*p == '_') {
- /* remove underscores between digits */
- if (badcheck) {
- if (n == buf || !ISDIGIT(prev)) goto bad;
- ++p;
- if (!ISDIGIT(*p)) goto bad;
- }
- else {
- while (*++p == '_');
- continue;
+ /* remove an underscore between digits */
+ if (n == buf || !ISDIGIT(prev) || (++p, !ISDIGIT(*p))) {
+ if (badcheck) goto bad;
+ break;
}
}
prev = *p++;