mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* io.c (rb_io_each_codepoint): read directly when readconv is
needed but internal encoding is not set. [ruby-core:28650] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26926 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ad130d3670
commit
32ed00ab18
3 changed files with 23 additions and 3 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Mon Mar 15 04:41:25 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* io.c (rb_io_each_codepoint): read directly when readconv is
|
||||||
|
needed but internal encoding is not set. [ruby-core:28650]
|
||||||
|
|
||||||
Mon Mar 15 04:18:31 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Mon Mar 15 04:18:31 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* tool/file2lastrev.rb (VCS::{SVN,GIT}#get_revisions):
|
* tool/file2lastrev.rb (VCS::{SVN,GIT}#get_revisions):
|
||||||
|
|
11
io.c
11
io.c
|
@ -2895,9 +2895,14 @@ rb_io_each_codepoint(VALUE io)
|
||||||
rb_enc_name(fptr->encs.enc));
|
rb_enc_name(fptr->encs.enc));
|
||||||
}
|
}
|
||||||
n = MBCLEN_CHARFOUND_LEN(r);
|
n = MBCLEN_CHARFOUND_LEN(r);
|
||||||
c = rb_enc_codepoint(fptr->cbuf+fptr->cbuf_off,
|
if (fptr->encs.enc) {
|
||||||
fptr->cbuf+fptr->cbuf_off+fptr->cbuf_len,
|
c = rb_enc_codepoint(fptr->cbuf+fptr->cbuf_off,
|
||||||
fptr->encs.enc);
|
fptr->cbuf+fptr->cbuf_off+fptr->cbuf_len,
|
||||||
|
fptr->encs.enc);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
c = (unsigned char)fptr->cbuf[fptr->cbuf_off];
|
||||||
|
}
|
||||||
fptr->cbuf_off += n;
|
fptr->cbuf_off += n;
|
||||||
fptr->cbuf_len -= n;
|
fptr->cbuf_len -= n;
|
||||||
rb_yield(UINT2NUM(c));
|
rb_yield(UINT2NUM(c));
|
||||||
|
|
|
@ -150,6 +150,16 @@ class TestIO < Test::Unit::TestCase
|
||||||
r.close
|
r.close
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_each_codepoint
|
||||||
|
t = make_tempfile
|
||||||
|
bug2959 = '[ruby-core:28650]'
|
||||||
|
a = ""
|
||||||
|
File.open(t, 'rt') {|f|
|
||||||
|
f.each_codepoint {|c| a << c}
|
||||||
|
}
|
||||||
|
assert_equal("foo\nbar\nbaz\n", a, bug2959)
|
||||||
|
end
|
||||||
|
|
||||||
def test_rubydev33072
|
def test_rubydev33072
|
||||||
assert_raise(Errno::ENOENT, "[ruby-dev:33072]") do
|
assert_raise(Errno::ENOENT, "[ruby-dev:33072]") do
|
||||||
File.read("empty", nil, nil, {})
|
File.read("empty", nil, nil, {})
|
||||||
|
|
Loading…
Reference in a new issue