[前][次][番号順一覧][スレッド一覧]

ruby-changes:29182

From: akr <ko1@a...>
Date: Tue, 11 Jun 2013 23:40:27 +0900 (JST)
Subject: [ruby-changes:29182] akr:r41234 (trunk): * bignum.c (validate_integer_pack_format): Don't require a word order

akr	2013-06-11 23:40:16 +0900 (Tue, 11 Jun 2013)

  New Revision: 41234

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41234

  Log:
    * 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.

  Modified files:
    trunk/ChangeLog
    trunk/bignum.c
    trunk/hash.c
    trunk/test/-ext-/bignum/test_pack.rb
    trunk/time.c

Index: time.c
===================================================================
--- time.c	(revision 41233)
+++ time.c	(revision 41234)
@@ -302,8 +302,8 @@ v2w_bignum(VALUE v) https://github.com/ruby/ruby/blob/trunk/time.c#L302
     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) {
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41233)
+++ ChangeLog	(revision 41234)
@@ -1,3 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Jun 11 23:37:19 2013  Tanaka Akira  <akr@f...>
+
+	* 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@f...>
 
 	* bignum.c (validate_integer_pack_format): Refine error messages.
Index: hash.c
===================================================================
--- hash.c	(revision 41233)
+++ hash.c	(revision 41234)
@@ -93,7 +93,7 @@ rb_hash(VALUE obj) https://github.com/ruby/ruby/blob/trunk/hash.c#L93
             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);
Index: bignum.c
===================================================================
--- bignum.c	(revision 41233)
+++ bignum.c	(revision 41234)
@@ -611,7 +611,7 @@ absint_numwords_generic(size_t numbytes, https://github.com/ruby/ruby/blob/trunk/bignum.c#L611
         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 numw https://github.com/ruby/ruby/blob/trunk/bignum.c#L740
     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)
Index: test/-ext-/bignum/test_pack.rb
===================================================================
--- test/-ext-/bignum/test_pack.rb	(revision 41233)
+++ test/-ext-/bignum/test_pack.rb	(revision 41234)
@@ -19,7 +19,7 @@ class TestBignum < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/-ext-/bignum/test_pack.rb#L19
     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 https://github.com/ruby/ruby/blob/trunk/test/-ext-/bignum/test_pack.rb#L121
     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) }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]