1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* io.c (argf_next_argv): go advance when the next file cannot be

read.  [ruby-core:34446]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30536 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2011-01-13 22:30:50 +00:00
parent 6ac9fea36f
commit 7909af18ed
3 changed files with 21 additions and 1 deletions

View file

@ -1,3 +1,8 @@
Fri Jan 14 07:30:47 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* io.c (argf_next_argv): go advance when the next file cannot be
read. [ruby-core:34446]
Thu Jan 13 20:49:19 2011 Tanaka Akira <akr@fsij.org>
* vm_insnhelper.c: parenthesize macro arguments.

2
io.c
View file

@ -6829,7 +6829,6 @@ argf_next_argv(VALUE argf)
}
if (ARGF.next_p == 1) {
ARGF.next_p = 0;
retry:
if (RARRAY_LEN(ARGF.argv) > 0) {
ARGF.filename = rb_ary_shift(ARGF.argv);
@ -6933,6 +6932,7 @@ argf_next_argv(VALUE argf)
fptr->encs = ARGF.encs;
clear_codeconv(fptr);
}
ARGF.next_p = 0;
}
else {
ARGF.next_p = 1;

View file

@ -720,6 +720,21 @@ class TestArgf < Test::Unit::TestCase
ensure
argf.close
end
end
def test_unreadable
bug4274 = '[ruby-core:34446]'
paths = (1..2).map do
t = Tempfile.new("bug4274-")
path = t.path
t.close!
path
end
argf = ARGF.class.new(*paths)
paths.each do |path|
e = assert_raise(Errno::ENOENT) {argf.gets}
assert_match(/- #{Regexp.quote(path)}\z/, e.message)
end
assert_nil(argf.gets, bug4274)
end
end