summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-21 07:03:06 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-21 07:03:06 +0000
commit99cb8dc38a8624cb248dfc0afcd33ba896080324 (patch)
treebd8143e507b0da4a3be857aa436b71835fe55f2e
parent0fcc2067fcb9fb62f54c2f86c2b2f42561afe669 (diff)
downloadruby-99cb8dc38a8624cb248dfc0afcd33ba896080324.tar.gz
ruby-99cb8dc38a8624cb248dfc0afcd33ba896080324.tar.xz
ruby-99cb8dc38a8624cb248dfc0afcd33ba896080324.zip
* 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. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@25880 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--io.c2
-rw-r--r--test/ruby/test_io_m17n.rb6
3 files changed, 13 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 6da478814..2d411873e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Sat Nov 21 15:58:43 2009 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * 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@ruby-lang.org>
* file.c (file_path_convert): delay getting UTF8-MAC encoding
diff --git a/io.c b/io.c
index 7b0afa44c..7acd28571 100644
--- a/io.c
+++ b/io.c
@@ -1742,7 +1742,7 @@ read_all(rb_io_t *fptr, long siz, VALUE str)
}
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);
diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb
index 976aae8c2..4d1a62381 100644
--- a/test/ruby/test_io_m17n.rb
+++ b/test/ruby/test_io_m17n.rb
@@ -558,6 +558,12 @@ EOT
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)