1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
matz 2006-06-27 16:15:22 +00:00
parent 471e41ec70
commit 30492d9d53
3 changed files with 10 additions and 13 deletions

View file

@ -1,3 +1,10 @@
Wed Jun 28 01:05:37 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* 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 <matz@ruby-lang.org> Tue Jun 27 23:03:49 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c: RDoc update for =~ method. a patch from Alex Young * string.c: RDoc update for =~ method. a patch from Alex Young

View file

@ -313,12 +313,7 @@ rb_cstr_to_inum(const char *str, int base, int badcheck)
if (badcheck) goto bad; if (badcheck) goto bad;
return INT2FIX(0); return INT2FIX(0);
} }
if (badcheck) {
while (ISSPACE(*str)) str++; while (ISSPACE(*str)) str++;
}
else {
while (ISSPACE(*str) || *str == '_') str++;
}
if (str[0] == '+') { if (str[0] == '+') {
str++; str++;
@ -408,7 +403,7 @@ rb_cstr_to_inum(const char *str, int base, int badcheck)
if (len <= (sizeof(VALUE)*CHAR_BIT)) { if (len <= (sizeof(VALUE)*CHAR_BIT)) {
unsigned long val = strtoul(str, &end, base); unsigned long val = strtoul(str, &end, base);
if (*end == '_') goto bigparse; if (str < end && *end == '_') goto bigparse;
if (badcheck) { if (badcheck) {
if (end == str) goto bad; /* no number */ if (end == str) goto bad; /* no number */
while (*end && ISSPACE(*end)) end++; while (*end && ISSPACE(*end)) end++;

View file

@ -2066,12 +2066,7 @@ rb_cstr_to_dbl(const char *p, int badcheck)
if (!p) return 0.0; if (!p) return 0.0;
q = p; q = p;
if (badcheck) {
while (ISSPACE(*p)) p++; while (ISSPACE(*p)) p++;
}
else {
while (ISSPACE(*p) || *p == '_') p++;
}
d = strtod(p, &end); d = strtod(p, &end);
if (errno == ERANGE) { if (errno == ERANGE) {
rb_warn("Float %*s out of range", end-p, p); rb_warn("Float %*s out of range", end-p, p);