diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-01-16 02:20:25 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-01-16 02:20:25 +0000 |
commit | ce71ad15c71e4ec0fdc8d6249c6b3b0e6729e232 (patch) | |
tree | f8d9ccb1d20bb73826691439585a29f3bb939ca6 /object.c | |
parent | a7d98b7bc323f5915bab6a1984989e60f5686584 (diff) |
* object.c (rb_Float): remove underscores between digits.
* bignum.c (rb_cstr2inum): reject prefix followed by spaces only.
* class.c (rb_class_inherited): should use Object when no super
class.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@1993 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'object.c')
-rw-r--r-- | object.c | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -940,7 +940,6 @@ rb_Float(val) q = p = STR2CSTR(val); while (*p && ISSPACE(*p)) p++; - again: d = strtod(p, &end); if (p == end) { bad: @@ -949,13 +948,20 @@ rb_Float(val) if (*end) { if (*end == '_') { char *buf = ALLOCA_N(char, strlen(p)); - char *n = buf, *last; + char *n = buf, *last = p; + while (p < end) *n++ = *p++; while (*p) { - if (*p == '_') { + if (*p == '_' && (n > buf && ISDIGIT(n[-1]))) { + /* remove underscores between digits */ last = ++p; + while (*p == '_') ++p; + if (!ISDIGIT(*p)) { + while (last < p) *n++ = *last++; continue; } + last = p; + } *n++ = *p++; } while (*last && (*last == '_' || ISSPACE(*last))) @@ -963,7 +969,8 @@ rb_Float(val) if (!*last) goto bad; *n = '\0'; p = buf; - goto again; + d = strtod(p, &end); + if (p == end) goto bad; } while (*end && ISSPACE(*end)) end++; if (*end) goto bad; |