diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-11-29 09:10:20 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-11-29 09:10:20 +0000 |
commit | 5925c930a8120ac5033f513a22a891b0329b29b8 (patch) | |
tree | 8ccacb31c9736c1a35bf138f4b3e539c9a5588cc | |
parent | 979ba5fc702823b954f5f3aa12702821d7a6481e (diff) |
merge revision(s) 52745: [Backport #11738]
* io.c (argf_getpartial): should not resize str if the second
argument is not given.
[ruby-core:71668] [Bug #11738]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@52788 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | io.c | 4 | ||||
-rw-r--r-- | test/ruby/test_argf.rb | 11 | ||||
-rw-r--r-- | version.h | 2 |
4 files changed, 21 insertions, 2 deletions
@@ -1,3 +1,9 @@ +Sun Nov 29 18:02:44 2015 Shugo Maeda <shugo@ruby-lang.org> + + * io.c (argf_getpartial): should not resize str if the second + argument is not given. + [ruby-core:71668] [Bug #11738] + Sun Nov 29 17:48:39 2015 Nobuyoshi Nakada <nobu@ruby-lang.org> * vm_eval.c (local_var_list_add): skip internal local variable @@ -11180,7 +11180,9 @@ argf_getpartial(int argc, VALUE *argv, VALUE argf, int nonblock) } if (!next_argv()) { - rb_str_resize(str, 0); + if (!NIL_P(str)) { + rb_str_resize(str, 0); + } rb_eof_error(); } if (ARGF_GENERIC_INPUT_P()) { diff --git a/test/ruby/test_argf.rb b/test/ruby/test_argf.rb index 10da4abeba..19c56146dd 100644 --- a/test/ruby/test_argf.rb +++ b/test/ruby/test_argf.rb @@ -510,6 +510,17 @@ class TestArgf < Test::Unit::TestCase end end + def test_readpartial_eof_twice + ruby('-W1', '-e', <<-SRC, @t1.path) do |f| + $stderr = $stdout + print ARGF.readpartial(256) + ARGF.readpartial(256) rescue p($!.class) + ARGF.readpartial(256) rescue p($!.class) + SRC + assert_equal("1\n2\nEOFError\nEOFError\n", f.read) + end + end + def test_getc ruby('-e', <<-SRC, @t1.path, @t2.path, @t3.path) do |f| s = "" @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.2.4" #define RUBY_RELEASE_DATE "2015-11-29" -#define RUBY_PATCHLEVEL 213 +#define RUBY_PATCHLEVEL 214 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 11 |