Skip to content

Commit 63bc35f

Browse files
committed
merge revision(s) 41250: [Backport ruby#8516]
* io.c (io_getc): fix 7bit coderange condition, check if ascii read data instead of read length. [ruby-core:55444] [Bug ruby#8516] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@41260 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent fdae108 commit 63bc35f

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Wed Jun 12 23:05:41 2013 Nobuyoshi Nakada <[email protected]>
2+
3+
* io.c (io_getc): fix 7bit coderange condition, check if ascii read
4+
data instead of read length. [ruby-core:55444] [Bug #8516]
5+
16
Sun Jun 9 02:27:07 2013 Nobuyoshi Nakada <[email protected]>
27

38
* lib/mkmf.rb (install_dirs, with_destdir): prefix with DESTDIR

io.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3385,7 +3385,11 @@ io_getc(rb_io_t *fptr, rb_encoding *enc)
33853385
}
33863386
else {
33873387
io_shift_cbuf(fptr, MBCLEN_CHARFOUND_LEN(r), &str);
3388-
cr = ISASCII(r) ? ENC_CODERANGE_7BIT : ENC_CODERANGE_VALID;
3388+
cr = ENC_CODERANGE_VALID;
3389+
if (MBCLEN_CHARFOUND_LEN(r) == 1 && rb_enc_asciicompat(read_enc) &&
3390+
ISASCII(RSTRING_PTR(str)[0])) {
3391+
cr = ENC_CODERANGE_7BIT;
3392+
}
33893393
}
33903394
str = io_enc_str(str, fptr);
33913395
ENC_CODERANGE_SET(str, cr);

test/ruby/test_io_m17n.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2159,7 +2159,17 @@ def test_getc_ascii_only
21592159
open("a", "wb") {|f| f.puts "a"}
21602160
open("a", "rt") {|f| f.getc}
21612161
}
2162-
assert(c.ascii_only?, "should be ascii_only #{bug4557}")
2162+
assert_predicate(c, :ascii_only?, bug4557)
2163+
end
2164+
2165+
def test_getc_conversion
2166+
bug8516 = '[ruby-core:55444] [Bug #8516]'
2167+
c = with_tmpdir {
2168+
open("a", "wb") {|f| f.putc "\xe1"}
2169+
open("a", "r:iso-8859-1:utf-8") {|f| f.getc}
2170+
}
2171+
assert_not_predicate(c, :ascii_only?, bug8516)
2172+
assert_equal(1, c.size, bug8516)
21632173
end
21642174

21652175
def test_default_mode_on_dosish

version.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#define RUBY_VERSION "2.0.0"
2-
#define RUBY_RELEASE_DATE "2013-06-09"
3-
#define RUBY_PATCHLEVEL 214
2+
#define RUBY_RELEASE_DATE "2013-06-12"
3+
#define RUBY_PATCHLEVEL 215
44

55
#define RUBY_RELEASE_YEAR 2013
66
#define RUBY_RELEASE_MONTH 6
7-
#define RUBY_RELEASE_DAY 9
7+
#define RUBY_RELEASE_DAY 12
88

99
#include "ruby/version.h"
1010

0 commit comments

Comments
 (0)