* 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
This commit is contained in:
parent
36e891304c
commit
d0c78c8567
@ -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>
|
Tue Dec 25 02:37:49 2001 Tanaka Akira <akr@m17n.org>
|
||||||
|
|
||||||
* lib/pp.rb, lib/prettyprint.rb: new files.
|
* lib/pp.rb, lib/prettyprint.rb: new files.
|
||||||
|
25
bignum.c
25
bignum.c
@ -230,10 +230,7 @@ rb_cstr2inum(str, base)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (base == 8) {
|
if (base == 8) {
|
||||||
while (*str == '0') str++;
|
len = 3;
|
||||||
if (!*str) return INT2FIX(0);
|
|
||||||
while (*str == '_') str++;
|
|
||||||
len = 3*strlen(str)*sizeof(char);
|
|
||||||
}
|
}
|
||||||
else { /* base == 10, 2 or 16 */
|
else { /* base == 10, 2 or 16 */
|
||||||
if (base == 16 && str[0] == '0' && (str[1] == 'x'||str[1] == 'X')) {
|
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')) {
|
else if (base == 2 && str[0] == '0' && (str[1] == 'b'||str[1] == 'B')) {
|
||||||
str += 2;
|
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 (ISSPACE(*str)) {
|
||||||
if (badcheck) goto bad;
|
if (badcheck) {
|
||||||
|
while (ISSPACE(*str)) str++;
|
||||||
|
if (*str) goto bad;
|
||||||
|
}
|
||||||
return INT2FIX(0);
|
return INT2FIX(0);
|
||||||
}
|
}
|
||||||
if (!*str) str--;
|
|
||||||
len = 4*strlen(str)*sizeof(char);
|
|
||||||
}
|
}
|
||||||
|
len *= strlen(str)*sizeof(char);
|
||||||
|
|
||||||
if (len <= (sizeof(VALUE)*CHAR_BIT)) {
|
if (len <= (sizeof(VALUE)*CHAR_BIT)) {
|
||||||
unsigned long val = strtoul((char*)str, &end, base);
|
unsigned long val = strtoul((char*)str, &end, base);
|
||||||
@ -330,9 +335,7 @@ rb_cstr2inum(str, base)
|
|||||||
if (badcheck) {
|
if (badcheck) {
|
||||||
str--;
|
str--;
|
||||||
if (s+1 < str && str[-1] == '_') goto bad;
|
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;
|
if (*str) goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#define RUBY_VERSION "1.7.2"
|
#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_VERSION_CODE 172
|
||||||
#define RUBY_RELEASE_CODE 20011221
|
#define RUBY_RELEASE_CODE 20011226
|
||||||
|
Loading…
x
Reference in New Issue
Block a user