summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--io.c6
-rw-r--r--test/ruby/test_io_m17n.rb12
-rw-r--r--version.h2
4 files changed, 22 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index e718720666..3ff95b5d40 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Wed Jun 26 16:13:25 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * io.c (io_getc): fix 7bit coderange condition, check if ascii read
+ data instead of read length. [ruby-core:55444] [Bug #8516]
+
Wed Jun 26 16:10:01 2013 Eric Hodel <drbrain@segment7.net>
* ext/socket/extconf.rb: Enable RFC 3542 IPV6 socket options for OS X
diff --git a/io.c b/io.c
index 57164d1042..e88918f575 100644
--- a/io.c
+++ b/io.c
@@ -3151,7 +3151,11 @@ io_getc(rb_io_t *fptr, rb_encoding *enc)
}
else {
io_shift_cbuf(fptr, MBCLEN_CHARFOUND_LEN(r), &str);
- cr = ISASCII(r) ? ENC_CODERANGE_7BIT : ENC_CODERANGE_VALID;
+ cr = ENC_CODERANGE_VALID;
+ if (MBCLEN_CHARFOUND_LEN(r) == 1 && rb_enc_asciicompat(read_enc) &&
+ ISASCII(RSTRING_PTR(str)[0])) {
+ cr = ENC_CODERANGE_7BIT;
+ }
}
str = io_enc_str(str, fptr);
ENC_CODERANGE_SET(str, cr);
diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb
index 98c9e2b41c..7ee90dd265 100644
--- a/test/ruby/test_io_m17n.rb
+++ b/test/ruby/test_io_m17n.rb
@@ -2067,7 +2067,17 @@ EOT
open("a", "wb") {|f| f.puts "a"}
open("a", "rt") {|f| f.getc}
}
- assert(c.ascii_only?, "should be ascii_only #{bug4557}")
+ assert_predicate(c, :ascii_only?, bug4557)
+ end
+
+ def test_getc_conversion
+ bug8516 = '[ruby-core:55444] [Bug #8516]'
+ c = with_tmpdir {
+ open("a", "wb") {|f| f.putc "\xe1"}
+ open("a", "r:iso-8859-1:utf-8") {|f| f.getc}
+ }
+ assert_not_predicate(c, :ascii_only?, bug8516)
+ assert_equal(1, c.size, bug8516)
end
def test_default_mode_on_dosish
diff --git a/version.h b/version.h
index 66cde47e6b..9bb30bb770 100644
--- a/version.h
+++ b/version.h
@@ -1,5 +1,5 @@
#define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 436
+#define RUBY_PATCHLEVEL 437
#define RUBY_RELEASE_DATE "2013-06-26"
#define RUBY_RELEASE_YEAR 2013