* bignum.c (big2str_table): base cannot be 0 or 1.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2007-08-02 15:00:22 +00:00
parent 230aa7715a
commit 51732bc6d2
2 changed files with 11 additions and 5 deletions

View File

@ -1,3 +1,7 @@
Fri Aug 3 00:00:20 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* bignum.c (big2str_table): base cannot be 0 or 1.
Thu Aug 2 23:42:57 2007 Nobuyoshi Nakada <nobu@ruby-lang.org> Thu Aug 2 23:42:57 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y (reg_compile_gen): set error if failed to compile regexp * parse.y (reg_compile_gen): set error if failed to compile regexp

View File

@ -595,6 +595,7 @@ rb_str2inum(VALUE str, int base)
} }
const char ruby_digitmap[] = "0123456789abcdefghijklmnopqrstuvwxyz"; const char ruby_digitmap[] = "0123456789abcdefghijklmnopqrstuvwxyz";
static inline int static inline int
big2str_normal(VALUE x, long j, int base, int hbase, char *s, int trim) big2str_normal(VALUE x, long j, int base, int hbase, char *s, int trim)
{ {
@ -624,7 +625,8 @@ big2str_normal(VALUE x, long j, int base, int hbase, char *s, int trim)
#define KARATSUBA_DIGITS 128 #define KARATSUBA_DIGITS 128
#define MAX_BIG2STR_TABLE_ENTRIES 64 #define MAX_BIG2STR_TABLE_ENTRIES 64
static VALUE big2str_table[37][MAX_BIG2STR_TABLE_ENTRIES]; static VALUE big2str_table_0[37-2][MAX_BIG2STR_TABLE_ENTRIES];
#define big2str_table (big2str_table_0-2)
static VALUE bigsqr(VALUE x); static VALUE bigsqr(VALUE x);
static void bigdivmod(VALUE x, VALUE y, VALUE *divp, VALUE *modp); static void bigdivmod(VALUE x, VALUE y, VALUE *divp, VALUE *modp);
@ -763,7 +765,7 @@ init_big2str_table(void)
int i, j; int i, j;
VALUE v; VALUE v;
for (i=0; i<37; i++) { for (i=2; i<37; i++) {
v = rb_big_pow(rb_int2big(i), INT2FIX(KARATSUBA_DIGITS)); v = rb_big_pow(rb_int2big(i), INT2FIX(KARATSUBA_DIGITS));
big2str_table[i][0] = v; big2str_table[i][0] = v;
rb_global_variable(&big2str_table[i][0]); rb_global_variable(&big2str_table[i][0]);