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

ruby-changes:24618

From: naruse <ko1@a...>
Date: Thu, 9 Aug 2012 22:49:47 +0900 (JST)
Subject: [ruby-changes:24618] naruse:r36669 (ruby_1_9_3): merge revision(s) 34972:

naruse	2012-08-09 22:49:27 +0900 (Thu, 09 Aug 2012)

  New Revision: 36669

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

  Log:
    merge revision(s) 34972:
    
    * pack.c (pack_unpack): when unpack('M') occurs an illegal byte
      sequence, output the "=" character and the following character in
      the decoded data without any transformation.
      [ruby-dev:44875] [Bug #5635]

  Modified files:
    branches/ruby_1_9_3/ChangeLog
    branches/ruby_1_9_3/pack.c
    branches/ruby_1_9_3/test/ruby/test_pack.rb
    branches/ruby_1_9_3/version.h

Index: ruby_1_9_3/ChangeLog
===================================================================
--- ruby_1_9_3/ChangeLog	(revision 36668)
+++ ruby_1_9_3/ChangeLog	(revision 36669)
@@ -1,3 +1,10 @@
+Thu Aug  9 22:48:58 2012  NARUSE, Yui  <naruse@r...>
+
+	* pack.c (pack_unpack): when unpack('M') occurs an illegal byte
+	  sequence, output the "=" character and the following character in
+	  the decoded data without any transformation.
+	  [ruby-dev:44875] [Bug #5635]
+
 Tue Jul 31 10:36:12 2012  Aaron Patterson <aaron@t...>
 
 	* ext/psych/lib/psych.rb: updated to released version.
Index: ruby_1_9_3/pack.c
===================================================================
--- ruby_1_9_3/pack.c	(revision 36668)
+++ ruby_1_9_3/pack.c	(revision 36669)
@@ -2003,7 +2003,7 @@
 	  case 'M':
 	    {
 		VALUE buf = infected_str_new(0, send - s, str);
-		char *ptr = RSTRING_PTR(buf);
+		char *ptr = RSTRING_PTR(buf), *ss = s;
 		int c1, c2;
 
 		while (s < send) {
@@ -2022,8 +2022,10 @@
 			*ptr++ = *s;
 		    }
 		    s++;
+		    ss = s;
 		}
 		rb_str_set_len(buf, ptr - RSTRING_PTR(buf));
+		rb_str_buf_cat(buf, ss, send-ss);
 		ENCODING_CODERANGE_SET(buf, rb_ascii8bit_encindex(), ENC_CODERANGE_VALID);
 		UNPACK_PUSH(buf);
 	    }
Index: ruby_1_9_3/version.h
===================================================================
--- ruby_1_9_3/version.h	(revision 36668)
+++ ruby_1_9_3/version.h	(revision 36669)
@@ -1,10 +1,10 @@
 #define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 259
+#define RUBY_PATCHLEVEL 260
 
-#define RUBY_RELEASE_DATE "2012-08-08"
+#define RUBY_RELEASE_DATE "2012-08-09"
 #define RUBY_RELEASE_YEAR 2012
 #define RUBY_RELEASE_MONTH 8
-#define RUBY_RELEASE_DAY 8
+#define RUBY_RELEASE_DAY 9
 
 #include "ruby/version.h"
 
Index: ruby_1_9_3/test/ruby/test_pack.rb
===================================================================
--- ruby_1_9_3/test/ruby/test_pack.rb	(revision 36668)
+++ ruby_1_9_3/test/ruby/test_pack.rb	(revision 36669)
@@ -612,6 +612,18 @@
     assert_equal([0x100000000], "\220\200\200\200\000".unpack("w"), [0x100000000])
   end
 
+
+  def test_pack_unpack_M
+    assert_equal(["pre123after"], "pre=31=32=33after".unpack("M"))
+    assert_equal(["preafter"], "pre=\nafter".unpack("M"))
+    assert_equal(["preafter"], "pre=\r\nafter".unpack("M"))
+    assert_equal(["pre="], "pre=".unpack("M"))
+    assert_equal(["pre=\r"], "pre=\r".unpack("M"))
+    assert_equal(["pre=hoge"], "pre=hoge".unpack("M"))
+    assert_equal(["pre==31after"], "pre==31after".unpack("M"))
+    assert_equal(["pre===31after"], "pre===31after".unpack("M"))
+  end
+
   def test_modify_under_safe4
     s = "foo"
     assert_raise(SecurityError) do

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

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