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

ruby-changes:15808

From: akr <ko1@a...>
Date: Tue, 11 May 2010 22:57:10 +0900 (JST)
Subject: [ruby-changes:15808] Ruby:r27739 (ruby_1_8): * pack.c (pack_pack): call rb_quad_pack to preserve RangeError.

akr	2010-05-11 22:56:34 +0900 (Tue, 11 May 2010)

  New Revision: 27739

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

  Log:
    * pack.c (pack_pack): call rb_quad_pack to preserve RangeError.

  Modified files:
    branches/ruby_1_8/ChangeLog
    branches/ruby_1_8/bignum.c
    branches/ruby_1_8/pack.c

Index: ruby_1_8/ChangeLog
===================================================================
--- ruby_1_8/ChangeLog	(revision 27738)
+++ ruby_1_8/ChangeLog	(revision 27739)
@@ -1,3 +1,7 @@
+Tue May 11 22:51:11 2010  Tanaka Akira  <akr@f...>
+
+	* pack.c (pack_pack): call rb_quad_pack to preserve RangeError.
+
 Tue May 11 05:37:19 2010  Tanaka Akira  <akr@f...>
 
 	* pack.c: backport integer pack/unpack from 1.9 for [ruby-core:21937].
Index: ruby_1_8/pack.c
===================================================================
--- ruby_1_8/pack.c	(revision 27738)
+++ ruby_1_8/pack.c	(revision 27739)
@@ -738,6 +738,9 @@
                     int i;
 
                     from = NEXTFROM;
+                    from = rb_to_int(from);
+                    if (integer_size == QUAD_SIZE)
+                        rb_quad_pack(v.a, from); /* RangeError compatibility for Ruby 1.8. */
                     rb_big_pack(from, v.i, num_longs);
                     if (bigendian_p) {
                         for (i = 0; i < num_longs/2; i++) {
Index: ruby_1_8/bignum.c
===================================================================
--- ruby_1_8/bignum.c	(revision 27738)
+++ ruby_1_8/bignum.c	(revision 27739)
@@ -426,7 +426,7 @@
     }
     len = RBIGNUM(val)->len * SIZEOF_BDIGITS;
     if (len > QUAD_SIZE) {
-        len = QUAD_SIZE;
+	rb_raise(rb_eRangeError, "bignum too big to convert into `quad int'");
     }
     memcpy(buf, (char*)BDIGITS(val), len);
     if (RBIGNUM_NEGATIVE_P(val)) {

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

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