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

ruby-changes:28290

From: naruse <ko1@a...>
Date: Thu, 18 Apr 2013 14:03:37 +0900 (JST)
Subject: [ruby-changes:28290] naruse:r40342 (trunk): * pack.c (pack_unpack): output characters even if the input doesn't

naruse	2013-04-18 14:03:00 +0900 (Thu, 18 Apr 2013)

  New Revision: 40342

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

  Log:
    * pack.c (pack_unpack): output characters even if the input doesn't
      have paddings. [Bug #8286]

  Modified files:
    trunk/ChangeLog
    trunk/pack.c
    trunk/test/ruby/test_pack.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40341)
+++ ChangeLog	(revision 40342)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Apr 18 13:35:54 2013  NARUSE, Yui  <naruse@r...>
+
+	* pack.c (pack_unpack): output characters even if the input doesn't
+	  have paddings. [Bug #8286]
+
 Thu Apr 18 08:20:48 2013  NARUSE, Yui  <naruse@r...>
 
 	* common.mk (clean-ext): remove timestamps.
Index: pack.c
===================================================================
--- pack.c	(revision 40341)
+++ pack.c	(revision 40342)
@@ -2006,9 +2006,9 @@ pack_unpack(VALUE str, VALUE fmt) https://github.com/ruby/ruby/blob/trunk/pack.c#L2006
 			*ptr++ = castchar(c << 6 | d);
 		    }
 		    if (a != -1 && b != -1) {
-			if (c == -1 && *s == '=')
+			if (c == -1)
 			    *ptr++ = castchar(a << 2 | b >> 4);
-			else if (c != -1 && *s == '=') {
+			else {
 			    *ptr++ = castchar(a << 2 | b >> 4);
 			    *ptr++ = castchar(b << 4 | c >> 2);
 			}
Index: test/ruby/test_pack.rb
===================================================================
--- test/ruby/test_pack.rb	(revision 40341)
+++ test/ruby/test_pack.rb	(revision 40342)
@@ -545,6 +545,10 @@ EXPECTED https://github.com/ruby/ruby/blob/trunk/test/ruby/test_pack.rb#L545
     assert_equal(["\377"], "/w==\n".unpack("m"))
     assert_equal(["\377\377"], "//8=\n".unpack("m"))
     assert_equal(["\377\377\377"], "////\n".unpack("m"))
+    assert_equal([""], "A\n".unpack("m"))
+    assert_equal(["\0"], "AA\n".unpack("m"))
+    assert_equal(["\0"], "AA=\n".unpack("m"))
+    assert_equal(["\0\0"], "AAA\n".unpack("m"))
   end
 
   def test_pack_unpack_m0

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

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