ruby-changes:17496
From: naruse <ko1@a...>
Date: Fri, 15 Oct 2010 16:42:27 +0900 (JST)
Subject: [ruby-changes:17496] Ruby:r29501 (trunk): * pack.c (pack_pack): fix more than one modifiers appear in the
naruse 2010-10-15 16:42:21 +0900 (Fri, 15 Oct 2010) New Revision: 29501 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=29501 Log: * pack.c (pack_pack): fix more than one modifiers appear in the format string. [ruby-core:32793] * pack.c (pack_unpack): ditto. Modified files: trunk/ChangeLog trunk/pack.c trunk/test/ruby/test_pack.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 29500) +++ ChangeLog (revision 29501) @@ -1,3 +1,10 @@ +Fri Oct 15 16:40:37 2010 NARUSE, Yui <naruse@r...> + + * pack.c (pack_pack): fix more than one modifiers appear in the + format string. [ruby-core:32793] + + * pack.c (pack_unpack): ditto. + Thu Oct 14 23:20:42 2010 Masaki Suketa <masaki.suketa@n...> * test/win32ole/test_folderitem2_invokeverb.rb: refactoring. Index: pack.c =================================================================== --- pack.c (revision 29500) +++ pack.c (revision 29501) @@ -428,7 +428,6 @@ int natint; /* native integer */ #endif int signed_p, integer_size, bigendian_p; - int explicit_endian = 0; StringValue(fmt); p = RSTRING_PTR(fmt); @@ -443,6 +442,7 @@ #define NEXTFROM (items-- > 0 ? RARRAY_PTR(ary)[idx++] : TOO_FEW) while (p < pend) { + int explicit_endian = 0; if (RSTRING_PTR(fmt) + RSTRING_LEN(fmt) != pend) { rb_raise(rb_eRuntimeError, "format string modified"); } @@ -1366,7 +1366,6 @@ #endif int block_p = rb_block_given_p(); int signed_p, integer_size, bigendian_p; - int explicit_endian = 0; #define UNPACK_PUSH(item) do {\ VALUE item_val = (item);\ if (block_p) {\ @@ -1386,6 +1385,7 @@ ary = block_p ? Qnil : rb_ary_new(); while (p < pend) { + int explicit_endian = 0; type = *p++; #ifdef NATINT_PACK natint = 0; Index: test/ruby/test_pack.rb =================================================================== --- test/ruby/test_pack.rb (revision 29500) +++ test/ruby/test_pack.rb (revision 29501) @@ -145,6 +145,8 @@ else _integer_little_endian() end + assert_equal("\x01\x02\x02\x01", [0x0102,0x0102].pack("s>s<")) + assert_equal([0x0102,0x0102], "\x01\x02\x02\x01".unpack("s>s<")) end def test_integer_endian_explicit -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/