summaryrefslogtreecommitdiff
path: root/object.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-01-16 02:20:25 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-01-16 02:20:25 +0000
commit5fe2879fd5b2b5db264f4bdbbc1181482b70e339 (patch)
treed487751d1461586d18ae2078f6b712ddf79d7228 /object.c
parenta2fc17bb81a7ade35dc775516867c82e00e39074 (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/trunk@1993 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'object.c')
-rw-r--r--object.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/object.c b/object.c
index fc2bd23fef..68a0b824ea 100644
--- a/object.c
+++ b/object.c
@@ -966,7 +966,6 @@ rb_Float(val)
q = p = StringValuePtr(val);
while (*p && ISSPACE(*p)) p++;
- again:
d = strtod(p, &end);
if (p == end) {
bad:
@@ -975,12 +974,19 @@ 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;
- continue;
+ while (*p == '_') ++p;
+ if (!ISDIGIT(*p)) {
+ while (last < p) *n++ = *last++;
+ continue;
+ }
+ last = p;
}
*n++ = *p++;
}
@@ -989,7 +995,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;