diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-12-26 17:01:20 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-12-26 17:01:20 +0000 |
commit | d0c78c8567a009626191ea1383599624e169966a (patch) | |
tree | 6b0066ce29a9d9d3661f74719f507c56303e8221 | |
parent | 36e891304c0f1619808ff2d3afaf0920e23470c8 (diff) | |
download | ruby-d0c78c8567a009626191ea1383599624e169966a.tar.gz |
* bignum.c (rb_cstr2inum): allow "0\n" and so on.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1942 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | bignum.c | 25 | ||||
-rw-r--r-- | version.h | 4 |
3 files changed, 20 insertions, 13 deletions
@@ -1,3 +1,7 @@ +Thu Dec 27 01:54:02 2001 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp> + + * bignum.c (rb_cstr2inum): allow "0\n" and so on. + Tue Dec 25 02:37:49 2001 Tanaka Akira <akr@m17n.org> * lib/pp.rb, lib/prettyprint.rb: new files. @@ -230,10 +230,7 @@ rb_cstr2inum(str, base) } } if (base == 8) { - while (*str == '0') str++; - if (!*str) return INT2FIX(0); - while (*str == '_') str++; - len = 3*strlen(str)*sizeof(char); + len = 3; } else { /* base == 10, 2 or 16 */ if (base == 16 && str[0] == '0' && (str[1] == 'x'||str[1] == 'X')) { @@ -242,14 +239,22 @@ rb_cstr2inum(str, base) else if (base == 2 && str[0] == '0' && (str[1] == 'b'||str[1] == 'B')) { str += 2; } - while (*str && *str == '0') str++; + len = 4; + } + if (*str == '0') { + do str++; while (*str == '0'); + if (!*str) return INT2FIX(0); + while (*str == '_') str++; + if (!*str) str--; if (ISSPACE(*str)) { - if (badcheck) goto bad; + if (badcheck) { + while (ISSPACE(*str)) str++; + if (*str) goto bad; + } return INT2FIX(0); } - if (!*str) str--; - len = 4*strlen(str)*sizeof(char); } + len *= strlen(str)*sizeof(char); if (len <= (sizeof(VALUE)*CHAR_BIT)) { unsigned long val = strtoul((char*)str, &end, base); @@ -330,9 +335,7 @@ rb_cstr2inum(str, base) if (badcheck) { str--; if (s+1 < str && str[-1] == '_') goto bad; - if (ISSPACE(c)) { - while (*str && ISSPACE(*str)) str++; - } + while (*str && ISSPACE(*str)) str++; if (*str) goto bad; } @@ -1,4 +1,4 @@ #define RUBY_VERSION "1.7.2" -#define RUBY_RELEASE_DATE "2001-12-21" +#define RUBY_RELEASE_DATE "2001-12-26" #define RUBY_VERSION_CODE 172 -#define RUBY_RELEASE_CODE 20011221 +#define RUBY_RELEASE_CODE 20011226 |