зеркало из https://github.com/github/ruby.git
io.c: fix 7bit coderange condition
* io.c (io_getc): fix 7bit coderange condition, check if ascii read data instead of read length. [ruby-core:55444] [Bug #8516] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41250 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
ff6104ba62
Коммит
ab64f23771
|
@ -1,3 +1,8 @@
|
||||||
|
Wed Jun 12 12:44:45 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 12 12:35:13 2013 Tanaka Akira <akr@fsij.org>
|
Wed Jun 12 12:35:13 2013 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* pack.c (pack_pack): Use rb_integer_pack_2comp.
|
* pack.c (pack_pack): Use rb_integer_pack_2comp.
|
||||||
|
|
6
io.c
6
io.c
|
@ -3411,7 +3411,11 @@ io_getc(rb_io_t *fptr, rb_encoding *enc)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
io_shift_cbuf(fptr, MBCLEN_CHARFOUND_LEN(r), &str);
|
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);
|
str = io_enc_str(str, fptr);
|
||||||
ENC_CODERANGE_SET(str, cr);
|
ENC_CODERANGE_SET(str, cr);
|
||||||
|
|
|
@ -2196,7 +2196,17 @@ EOT
|
||||||
open("a", "wb") {|f| f.puts "a"}
|
open("a", "wb") {|f| f.puts "a"}
|
||||||
open("a", "rt") {|f| f.getc}
|
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
|
end
|
||||||
|
|
||||||
def test_default_mode_on_dosish
|
def test_default_mode_on_dosish
|
||||||
|
|
Загрузка…
Ссылка в новой задаче