summaryrefslogtreecommitdiff
path: root/object.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-05-02 13:37:18 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-05-02 13:37:18 +0000
commit853707123ecdc338ad27258aec3e473c86e76aaf (patch)
tree60eb8efb154cde513d19cbd0ba76701364b4ae53 /object.c
parent2af97e03b97c92ebe16b1e36fbcab728e76bf7d5 (diff)
object.c: fix exponent with underscore
* object.c (rb_cstr_to_dbl_raise): do not ignore exponent part when the input string longer than internal buffer contains underscore(s). [ruby-core:86836] [Bug #14731] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'object.c')
-rw-r--r--object.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/object.c b/object.c
index 4a5b5d359a..a4594a2982 100644
--- a/object.c
+++ b/object.c
@@ -3270,7 +3270,8 @@ rb_cstr_to_dbl_raise(const char *p, int badcheck, int raise, int *error)
if (*end) {
char buf[DBL_DIG * 4 + 10];
char *n = buf;
- char *e = buf + sizeof(buf) - 1;
+ char *const init_e = buf + DBL_DIG * 4;
+ char *e = init_e;
char prev = 0;
while (p < end && n < e) prev = *n++ = *p++;
@@ -3283,6 +3284,9 @@ rb_cstr_to_dbl_raise(const char *p, int badcheck, int raise, int *error)
}
}
prev = *p++;
+ if (e == init_e && (*p == 'e' || *p == 'E')) {
+ e = buf + sizeof(buf) - 1;
+ }
if (n < e) *n++ = prev;
}
*n = '\0';