diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-06-07 16:33:01 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-06-07 16:33:01 +0000 |
commit | db128e1b31f3c31e955a9063d027a97dcb938873 (patch) | |
tree | 8fae5a1140049d13043e01a4bd2c7358d2807a5d /bignum.c | |
parent | 3ec9537664b3555609bccd0bdf54fa25040a2aeb (diff) | |
download | ruby-db128e1b31f3c31e955a9063d027a97dcb938873.tar.gz |
* bignum.c (bignorm): fixed a bug in normalizing negative numbers
reported from Honda Hiroki <hhonda@ipflex.com>. normalizing
should not trim preceding zeros from negative numbers.
* ext/socket/socket.c (ruby_getaddrinfo__aix): merged a patch from
KUBO Takehiro <kubo@jiubao.org> to support AIX. [ruby-list:40832]
* lib/yaml/rubytypes.rb (Array::to_yaml): merged a patch from
Tilman Sauerbeck <tilman@code-monkey.de>. [ruby-core:05055]
* lib/yaml/rubytypes.rb (Hash::to_yaml): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8589 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r-- | bignum.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -105,9 +105,15 @@ bignorm(x) BDIGIT *ds = BDIGITS(x); while (len-- && !ds[len]) ; - RBIGNUM(x)->len = ++len; + len++; + if (RBIGNUM(x)->sign) { + RBIGNUM(x)->len = len; + } + else if (len == 0) { + return x; + } - if (len*SIZEOF_BDIGITS <= sizeof(VALUE)) { + if (RBIGNUM(x)->len*SIZEOF_BDIGITS <= sizeof(VALUE)) { long num = 0; while (len--) { num = BIGUP(num) + ds[len]; |