From 30492d9d53f1d79c1713f3ed4e7c623cd1490884 Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 27 Jun 2006 16:15:22 +0000 Subject: * object.c (rb_cstr_to_dbl): should not skip '_' at the beginning of a string. [ruby-dev:28830] * bignum.c (rb_cstr_to_inum): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10414 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ bignum.c | 9 ++------- object.c | 7 +------ 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index f4fbf1a6ab..c2059e9680 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Wed Jun 28 01:05:37 2006 Yukihiro Matsumoto + + * object.c (rb_cstr_to_dbl): should not skip '_' at the beginning + of a string. [ruby-dev:28830] + + * bignum.c (rb_cstr_to_inum): ditto. + Tue Jun 27 23:03:49 2006 Yukihiro Matsumoto * string.c: RDoc update for =~ method. a patch from Alex Young diff --git a/bignum.c b/bignum.c index 2bd44c2bf9..f06444d8dd 100644 --- a/bignum.c +++ b/bignum.c @@ -313,12 +313,7 @@ rb_cstr_to_inum(const char *str, int base, int badcheck) if (badcheck) goto bad; return INT2FIX(0); } - if (badcheck) { - while (ISSPACE(*str)) str++; - } - else { - while (ISSPACE(*str) || *str == '_') str++; - } + while (ISSPACE(*str)) str++; if (str[0] == '+') { str++; @@ -408,7 +403,7 @@ rb_cstr_to_inum(const char *str, int base, int badcheck) if (len <= (sizeof(VALUE)*CHAR_BIT)) { unsigned long val = strtoul(str, &end, base); - if (*end == '_') goto bigparse; + if (str < end && *end == '_') goto bigparse; if (badcheck) { if (end == str) goto bad; /* no number */ while (*end && ISSPACE(*end)) end++; diff --git a/object.c b/object.c index 49957c7bcb..afbcd61e28 100644 --- a/object.c +++ b/object.c @@ -2066,12 +2066,7 @@ rb_cstr_to_dbl(const char *p, int badcheck) if (!p) return 0.0; q = p; - if (badcheck) { - while (ISSPACE(*p)) p++; - } - else { - while (ISSPACE(*p) || *p == '_') p++; - } + while (ISSPACE(*p)) p++; d = strtod(p, &end); if (errno == ERANGE) { rb_warn("Float %*s out of range", end-p, p); -- cgit v1.2.3