From 870df461dd3008dd56c0147ddc2fd84688cdd9cb Mon Sep 17 00:00:00 2001 From: shyouhei Date: Sun, 15 Jun 2008 10:57:55 +0000 Subject: merge revision(s) 15575: * bignum.c (BIGZEROP): fix for longer Bignum zeros. [ruby-Bugs-17454] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_6@17202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- bignum.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'bignum.c') diff --git a/bignum.c b/bignum.c index 70a88e64d9..e3d531ceaf 100644 --- a/bignum.c +++ b/bignum.c @@ -36,7 +36,21 @@ VALUE rb_cBignum; #define BIGLO(x) ((BDIGIT)((x) & (BIGRAD-1))) #define BDIGMAX ((BDIGIT)-1) -#define BIGZEROP(x) (RBIGNUM(x)->len == 0 || (RBIGNUM(x)->len == 1 && BDIGITS(x)[0] == 0)) +#define BIGZEROP(x) (RBIGNUM(x)->len == 0 || \ + (BDIGITS(x)[0] == 0 && \ + (RBIGNUM(x)->len == 1 || bigzero_p(x)))) + +static int bigzero_p(VALUE); +static int +bigzero_p(x) + VALUE x; +{ + long i; + for (i = 0; i < RBIGNUM(x)->len; ++i) { + if (BDIGITS(x)[i]) return 0; + } + return 1; +} static VALUE bignew_1(klass, len, sign) -- cgit v1.2.3