diff options
author | sorah <sorah@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-04-09 14:28:06 +0000 |
---|---|---|
committer | sorah <sorah@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-04-09 14:28:06 +0000 |
commit | 4e817b39b42fb1089ed0d4eb5f8c4d3e0e695960 (patch) | |
tree | eb03ce997a98639257308ecf23237fd70db666ad /ext | |
parent | 0a69f2e39de67d3d9887673b5030adcc5f2d0b81 (diff) | |
download | ruby-4e817b39b42fb1089ed0d4eb5f8c4d3e0e695960.tar.gz |
* ext/stringio/stringio.c (strio_each):
Fix exception message and don't raise immediately if block is not given.
Fixes [ruby-dev:43394].
* test/stringio/test_stringio.rb (test_each_line_limit_0):
Fix test for above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31253 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/stringio/stringio.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c index 609355a51b..1bb5e0f573 100644 --- a/ext/stringio/stringio.c +++ b/ext/stringio/stringio.c @@ -1067,13 +1067,13 @@ strio_each(int argc, VALUE *argv, VALUE self) struct StringIO *ptr = StringIO(self); VALUE line; + RETURN_ENUMERATOR(self, argc, argv); + if(argc > 0 && TYPE(argv[argc-1]) == T_FIXNUM && FIX2INT(argv[argc-1]) == 0) { - rb_raise(rb_eArgError, "invalid limit: 0 for readlines"); + rb_raise(rb_eArgError, "invalid limit: 0 for each_line"); } - RETURN_ENUMERATOR(self, argc, argv); - while (!NIL_P(line = strio_getline(argc, argv, readable(ptr)))) { rb_yield(line); } |