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

ruby-changes:14067

From: naruse <ko1@a...>
Date: Sat, 21 Nov 2009 16:05:23 +0900 (JST)
Subject: [ruby-changes:14067] Ruby:r25880 (trunk): * io.c (read_all): fix: false negative invalid byte seequence

naruse	2009-11-21 16:03:06 +0900 (Sat, 21 Nov 2009)

  New Revision: 25880

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

  Log:
    * io.c (read_all): fix: false negative invalid byte seequence
      on reading from pipes. [ruby-dev:39743]
      fix: assigin the variable 'pos' as relative value from recent pos.

  Modified files:
    trunk/ChangeLog
    trunk/io.c
    trunk/test/ruby/test_io_m17n.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 25879)
+++ ChangeLog	(revision 25880)
@@ -1,3 +1,9 @@
+Sat Nov 21 15:58:43 2009  NARUSE, Yui  <naruse@r...>
+
+	* io.c (read_all): fix: false negative invalid byte seequence
+	  on reading from pipes. [ruby-dev:39743]
+	  fix: assigin the variable 'pos' as relative value from recent pos.
+
 Sat Nov 21 14:44:16 2009  NARUSE, Yui  <naruse@r...>
 
 	* file.c (file_path_convert): delay getting UTF8-MAC encoding
Index: io.c
===================================================================
--- io.c	(revision 25879)
+++ io.c	(revision 25880)
@@ -1742,7 +1742,7 @@
 	}
 	bytes += n;
 	if (cr != ENC_CODERANGE_BROKEN)
-	    pos = rb_str_coderange_scan_restartable(RSTRING_PTR(str) + pos, RSTRING_PTR(str) + bytes, enc, &cr);
+	    pos += rb_str_coderange_scan_restartable(RSTRING_PTR(str) + pos, RSTRING_PTR(str) + bytes, enc, &cr);
 	if (bytes < siz) break;
 	siz += BUFSIZ;
 	rb_str_resize(str, siz);
Index: test/ruby/test_io_m17n.rb
===================================================================
--- test/ruby/test_io_m17n.rb	(revision 25879)
+++ test/ruby/test_io_m17n.rb	(revision 25880)
@@ -558,6 +558,12 @@
       assert_equal(eucjp, r.read)
     }
 
+    with_pipe("UTF-8") {|r,w|
+      w << "a" * 1023 + "\u3042" + "a" * 1022
+      w.close
+      assert_equal(true, r.read.valid_encoding?)
+    }
+
     with_pipe("UTF-8:EUC-JP") {|r,w|
       assert_equal(Encoding::UTF_8, r.external_encoding)
       assert_equal(Encoding::EUC_JP, r.internal_encoding)

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

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