summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-29 07:51:43 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-29 07:51:43 +0000
commit824cb6905896131031c4f712e6cb55f76fc9ad1f (patch)
treecbcf54ad82ad4bf9b278243baf5a5a3b5b180d17 /io.c
parent8d7c52dbe21f1bbd423860c7bab21a9f8ce487c2 (diff)
io.c: get rid of IOError when skipped while iteration
* io.c (argf_next_argv): set init flag if succeeded to forward, after skipping. * io.c (argf_block_call_i, argf_block_call): no more forwarding if forwarded after skipping. [ruby-list:49185] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39997 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/io.c b/io.c
index c2a89fdb1f..a98bec8093 100644
--- a/io.c
+++ b/io.c
@@ -7614,7 +7614,6 @@ argf_next_argv(VALUE argf)
else if (ARGF.next_p == -1 && RARRAY_LEN(ARGF.argv) > 0) {
ARGF.next_p = 1;
}
- ARGF.init_p = 1;
}
if (ARGF.next_p == 1) {
@@ -7747,6 +7746,7 @@ argf_next_argv(VALUE argf)
rb_stdout = orig_stdout;
}
}
+ if (ARGF.init_p == -1) ARGF.init_p = 1;
return TRUE;
}
@@ -10927,7 +10927,7 @@ argf_readbyte(VALUE argf)
return c;
}
-#define FOREACH_ARGF() for (; next_argv(); ARGF.next_p = 1)
+#define FOREACH_ARGF() while (next_argv())
static VALUE
argf_block_call_i(VALUE i, VALUE argf, int argc, VALUE *argv)
@@ -10935,7 +10935,7 @@ argf_block_call_i(VALUE i, VALUE argf, int argc, VALUE *argv)
const VALUE current = ARGF.current_file;
rb_yield_values2(argc, argv);
if (ARGF.init_p == -1 || current != ARGF.current_file) {
- rb_iter_break();
+ rb_iter_break_value(Qundef);
}
return Qnil;
}
@@ -10943,7 +10943,8 @@ argf_block_call_i(VALUE i, VALUE argf, int argc, VALUE *argv)
static void
argf_block_call(ID mid, int argc, VALUE *argv, VALUE argf)
{
- rb_block_call(ARGF.current_file, mid, argc, argv, argf_block_call_i, argf);
+ VALUE ret = rb_block_call(ARGF.current_file, mid, argc, argv, argf_block_call_i, argf);
+ if (ret != Qundef) ARGF.next_p = 1;
}
/*