From ce71ad15c71e4ec0fdc8d6249c6b3b0e6729e232 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 16 Jan 2002 02:20:25 +0000 Subject: [PATCH] * 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 --- ChangeLog | 9 +++++++++ bignum.c | 2 +- class.c | 1 + object.c | 15 +++++++++++---- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8ef7af2698..3eb01cb7df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Wed Jan 16 11:12:30 2002 Nobuyoshi Nakada + + * 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. + Tue Jan 15 12:43:34 2002 Minero Aoki * lib/net/protocol.rb: Protocol#start returns the return value of diff --git a/bignum.c b/bignum.c index ee119f2d1d..2c70b4b8f0 100644 --- a/bignum.c +++ b/bignum.c @@ -252,8 +252,8 @@ rb_cstr2inum(str, base) if (*end == '_') goto bigparse; if (badcheck) { - while (*end && ISSPACE(*end)) end++; if (end == str) goto bad; /* no number */ + while (*end && ISSPACE(*end)) end++; if (*end) { /* trailing garbage */ bad: rb_raise(rb_eArgError, "invalid value for Integer: \"%s\"", s); diff --git a/class.c b/class.c index 9e96d692c8..d0263bfd96 100644 --- a/class.c +++ b/class.c @@ -149,6 +149,7 @@ VALUE rb_class_inherited(super, klass) VALUE super, klass; { + if (!super) super = rb_cObject; return rb_funcall(super, rb_intern("inherited"), 1, klass); } diff --git a/object.c b/object.c index d6ea3c785b..e0ccc11697 100644 --- a/object.c +++ b/object.c @@ -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,12 +948,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; + while (*p == '_') ++p; + if (!ISDIGIT(*p)) { + while (last < p) *n++ = *last++; continue; + } + last = p; } *n++ = *p++; } @@ -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;