summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-11 14:40:16 (GMT)
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-11 14:40:16 (GMT)
commitb23d9a8a637e5e63a93ea6a620b3dab3450f15e2 (patch)
tree0c644db703bcc461e7b3adce7500be52f06877db
parentc4b12333f770039fa4f189b3ac9ca015707836c3 (diff)
* bignum.c (validate_integer_pack_format): Don't require a word order
flag if numwords is 1 or less. (absint_numwords_generic): Don't specify a word order for rb_integer_pack. * hash.c (rb_hash): Ditto. * time.c (v2w_bignum): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog11
-rw-r--r--bignum.c5
-rw-r--r--hash.c2
-rw-r--r--test/-ext-/bignum/test_pack.rb4
-rw-r--r--time.c4
5 files changed, 19 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 7b3353a..935dff3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+Tue Jun 11 23:37:19 2013 Tanaka Akira <akr@fsij.org>
+
+ * bignum.c (validate_integer_pack_format): Don't require a word order
+ flag if numwords is 1 or less.
+ (absint_numwords_generic): Don't specify a word order for
+ rb_integer_pack.
+
+ * hash.c (rb_hash): Ditto.
+
+ * time.c (v2w_bignum): Ditto.
+
Tue Jun 11 23:01:57 2013 Tanaka Akira <akr@fsij.org>
* bignum.c (validate_integer_pack_format): Refine error messages.
diff --git a/bignum.c b/bignum.c
index 3eb086c..0315cd5 100644
--- a/bignum.c
+++ b/bignum.c
@@ -611,7 +611,7 @@ absint_numwords_generic(size_t numbytes, int nlz_bits_in_msbyte, size_t word_num
nlz_bits = word_numbits - NUM2SIZET(mod);
}
sign = rb_integer_pack(div, &numwords, 1, sizeof(numwords), 0,
- INTEGER_PACK_MSWORD_FIRST|INTEGER_PACK_NATIVE_BYTE_ORDER);
+ INTEGER_PACK_NATIVE_BYTE_ORDER);
if (sign == 2)
return (size_t)-1;
*nlz_bits_ret = nlz_bits;
@@ -740,7 +740,8 @@ validate_integer_pack_format(size_t numwords, size_t wordsize, size_t nails, int
int wordorder_bits = flags & INTEGER_PACK_WORDORDER_MASK;
int byteorder_bits = flags & INTEGER_PACK_BYTEORDER_MASK;
if (wordorder_bits == 0) {
- rb_raise(rb_eArgError, "word order not specified");
+ if (1 < numwords)
+ rb_raise(rb_eArgError, "word order not specified");
}
else if (wordorder_bits != INTEGER_PACK_MSWORD_FIRST &&
wordorder_bits != INTEGER_PACK_LSWORD_FIRST)
diff --git a/hash.c b/hash.c
index b5da3b7..a67335f 100644
--- a/hash.c
+++ b/hash.c
@@ -93,7 +93,7 @@ rb_hash(VALUE obj)
int sign;
unsigned long ul;
sign = rb_integer_pack(hval, &ul, 1, sizeof(ul), 0,
- INTEGER_PACK_LSWORD_FIRST|INTEGER_PACK_NATIVE_BYTE_ORDER);
+ INTEGER_PACK_NATIVE_BYTE_ORDER);
ul &= (1UL << (sizeof(long)*CHAR_BIT-1)) - 1;
if (sign < 0)
return LONG2FIX(-(long)ul);
diff --git a/test/-ext-/bignum/test_pack.rb b/test/-ext-/bignum/test_pack.rb
index 8c7cc12..21abf09 100644
--- a/test/-ext-/bignum/test_pack.rb
+++ b/test/-ext-/bignum/test_pack.rb
@@ -19,7 +19,7 @@ class TestBignum < Test::Unit::TestCase
end
def test_pack_argument_check
- assert_raise(ArgumentError) { 0.test_pack_raw("", 0, 1, 0, MSBYTE_FIRST) }
+ assert_raise(ArgumentError) { 0.test_pack_raw("", 2, 1, 0, MSBYTE_FIRST) }
assert_raise(ArgumentError) { 0.test_pack_raw("", 0, 1, 0, MSWORD_FIRST) }
assert_raise(ArgumentError) { 0.test_pack_raw("", 0, 0, 0, BIG_ENDIAN) }
assert_raise(ArgumentError) { 0.test_pack_raw("", 0, 1, 8, BIG_ENDIAN) }
@@ -121,7 +121,7 @@ class TestBignum < Test::Unit::TestCase
end
def test_unpack_argument_check
- assert_raise(ArgumentError) { Integer.test_unpack(1, "x", 1, 1, 0, MSBYTE_FIRST) }
+ assert_raise(ArgumentError) { Integer.test_unpack(1, "x", 2, 1, 0, MSBYTE_FIRST) }
assert_raise(ArgumentError) { Integer.test_unpack(1, "x", 1, 1, 0, MSWORD_FIRST) }
assert_raise(ArgumentError) { Integer.test_unpack(1, "x", 1, 0, 0, BIG_ENDIAN) }
assert_raise(ArgumentError) { Integer.test_unpack(1, "x", 1, 1, 8, BIG_ENDIAN) }
diff --git a/time.c b/time.c
index 1916e76..f20d29e 100644
--- a/time.c
+++ b/time.c
@@ -302,8 +302,8 @@ v2w_bignum(VALUE v)
int sign;
uwideint_t u;
wideint_t i;
- sign = rb_integer_pack(v, &u, 1, sizeof(i), 0,
- INTEGER_PACK_LSWORD_FIRST|INTEGER_PACK_NATIVE_BYTE_ORDER);
+ sign = rb_integer_pack(v, &u, 1, sizeof(u), 0,
+ INTEGER_PACK_NATIVE_BYTE_ORDER);
if (sign == 0)
return WINT2FIXWV(0);
else if (sign == -1) {