[前][次][番号順一覧][スレッド一覧]

ruby-changes:40666

From: shugo <ko1@a...>
Date: Wed, 25 Nov 2015 10:58:20 +0900 (JST)
Subject: [ruby-changes:40666] shugo:r52745 (trunk): * io.c (argf_getpartial): should not resize str if the second

shugo	2015-11-25 10:57:48 +0900 (Wed, 25 Nov 2015)

  New Revision: 52745

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52745

  Log:
    * io.c (argf_getpartial): should not resize str if the second
      argument is not given.
      [ruby-core:71668] [Bug #11738]

  Modified files:
    trunk/ChangeLog
    trunk/io.c
    trunk/test/ruby/test_argf.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 52744)
+++ ChangeLog	(revision 52745)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Nov 25 10:55:21 2015  Shugo Maeda  <shugo@r...>
+
+	* io.c (argf_getpartial): should not resize str if the second
+	  argument is not given.
+	  [ruby-core:71668] [Bug #11738]
+
 Tue Nov 24 23:56:25 2015  Naohisa Goto  <ngotogenome@g...>
 
 	* configure.in: On Solaris, it is safe to define _LARGEFILE_SOURCE
Index: io.c
===================================================================
--- io.c	(revision 52744)
+++ io.c	(revision 52745)
@@ -11247,7 +11247,9 @@ argf_getpartial(int argc, VALUE *argv, V https://github.com/ruby/ruby/blob/trunk/io.c#L11247
     }
 
     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()) {
Index: test/ruby/test_argf.rb
===================================================================
--- test/ruby/test_argf.rb	(revision 52744)
+++ test/ruby/test_argf.rb	(revision 52745)
@@ -510,6 +510,17 @@ class TestArgf < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_argf.rb#L510
     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 = ""

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]