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

ruby-changes:31424

From: nobu <ko1@a...>
Date: Fri, 1 Nov 2013 20:54:07 +0900 (JST)
Subject: [ruby-changes:31424] nobu:r43503 (trunk): string.c: fix typo

nobu	2013-11-01 20:53:59 +0900 (Fri, 01 Nov 2013)

  New Revision: 43503

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

  Log:
    string.c: fix typo
    
    * string.c (rb_str_scrub): fix typo, should yield invalid byte
      sequence to be scrubbed.  reported by znz at IRC.

  Modified files:
    trunk/ChangeLog
    trunk/string.c
    trunk/test/ruby/test_m17n.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 43502)
+++ ChangeLog	(revision 43503)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Nov  1 20:53:56 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* string.c (rb_str_scrub): fix typo, should yield invalid byte
+	  sequence to be scrubbed.  reported by znz at IRC.
+
 Fri Nov  1 17:25:30 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* gc.c (is_live_object): finalizer may not run because of lazy-sweep.
Index: string.c
===================================================================
--- string.c	(revision 43502)
+++ string.c	(revision 43503)
@@ -8069,7 +8069,7 @@ rb_str_scrub(VALUE str, VALUE repl) https://github.com/ruby/ruby/blob/trunk/string.c#L8069
 		    if (!rep7bit_p) cr = ENC_CODERANGE_VALID;
 		}
 		else {
-		    repl = rb_yield(rb_enc_str_new(p1, clen, enc));
+		    repl = rb_yield(rb_enc_str_new(p, clen, enc));
 		    repl = str_compat_and_valid(repl, enc);
 		    rb_str_buf_cat(buf, RSTRING_PTR(repl), RSTRING_LEN(repl));
 		    if (ENC_CODERANGE(repl) == ENC_CODERANGE_VALID)
Index: test/ruby/test_m17n.rb
===================================================================
--- test/ruby/test_m17n.rb	(revision 43502)
+++ test/ruby/test_m17n.rb	(revision 43503)
@@ -1524,6 +1524,9 @@ class TestM17N < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_m17n.rb#L1524
     assert_raise(ArgumentError){ u("\xE3\x81\x82\xE3\x81\x82\xE3\x81").scrub{u("\x81")} }
     assert_equal(e("\xA4\xA2\xA2\xAE"), e("\xA4\xA2\xA4").scrub{e("\xA2\xAE")})
 
+    assert_equal("\x81", u("a\x81").scrub {|c| break c})
+    assert_raise(ArgumentError) {u("a\x81").scrub {|c| c}}
+
     assert_equal("\uFFFD\u3042".encode("UTF-16BE"),
                  "\xD8\x00\x30\x42".force_encoding(Encoding::UTF_16BE).
                  scrub)

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

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