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

ruby-changes:22479

From: naruse <ko1@a...>
Date: Fri, 10 Feb 2012 05:12:17 +0900 (JST)
Subject: [ruby-changes:22479] naruse:r34528 (ruby_1_9_3): merge revision(s) 34409,34412,34417:

naruse	2012-02-10 05:12:02 +0900 (Fri, 10 Feb 2012)

  New Revision: 34528

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

  Log:
    merge revision(s) 34409,34412,34417:
    
    * io.c (argf_close): skip stdin, which should be readable again.
      [ruby-dev:45160] [Bug #5952]
    
    * io.c (argf_readlines): reinitialize after all read to be
      readable again.
    
    * io.c (argf_next_argv): reset ARGF.next_p on ARGV.replace.
      r34409 breaks replacing ARGV.
      [ruby-dev:45160] [Bug #5952]

  Modified files:
    branches/ruby_1_9_3/ChangeLog
    branches/ruby_1_9_3/io.c
    branches/ruby_1_9_3/test/ruby/test_argf.rb
    branches/ruby_1_9_3/version.h

Index: ruby_1_9_3/ChangeLog
===================================================================
--- ruby_1_9_3/ChangeLog	(revision 34527)
+++ ruby_1_9_3/ChangeLog	(revision 34528)
@@ -1,3 +1,17 @@
+Fri Feb 10 05:11:43 2012  NARUSE, Yui  <naruse@r...>
+
+	* io.c (argf_next_argv): reset ARGF.next_p on ARGV.replace.
+	  r34409 breaks replacing ARGV.
+	  [ruby-dev:45160] [Bug #5952]
+
+Fri Feb 10 05:11:43 2012  Nobuyoshi Nakada  <nobu@r...>
+
+	* io.c (argf_close): skip stdin, which should be readable again.
+	  [ruby-dev:45160] [Bug #5952]
+
+	* io.c (argf_readlines): reinitialize after all read to be
+	  readable again.
+
 Fri Feb  9 01:36:19 2012  Martin Bosslet  <Martin.Bosslet@g...>
 
 	* backport r34482 from trunk
Index: ruby_1_9_3/io.c
===================================================================
--- ruby_1_9_3/io.c	(revision 34527)
+++ ruby_1_9_3/io.c	(revision 34528)
@@ -6852,6 +6852,7 @@
 static void
 argf_close(VALUE file)
 {
+    if (file == rb_stdin) return;
     if (RB_TYPE_P(file, T_FILE)) {
 	rb_io_set_write_io(file, Qnil);
     }
@@ -6881,6 +6882,14 @@
 	}
 	ARGF.init_p = 1;
     }
+    else {
+	if (NIL_P(ARGF.argv)) {
+	    ARGF.next_p = -1;
+	}
+	else if (ARGF.next_p == -1 && RARRAY_LEN(ARGF.argv) > 0) {
+	    ARGF.next_p = 1;
+	}
+    }
 
     if (ARGF.next_p == 1) {
       retry:
@@ -7262,6 +7271,7 @@
 	ARGF.lineno = lineno + RARRAY_LEN(ary);
 	ARGF.last_lineno = ARGF.lineno;
     }
+    ARGF.init_p = 0;
     return ary;
 }
 
Index: ruby_1_9_3/version.h
===================================================================
--- ruby_1_9_3/version.h	(revision 34527)
+++ ruby_1_9_3/version.h	(revision 34528)
@@ -1,5 +1,5 @@
 #define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 76
+#define RUBY_PATCHLEVEL 77
 
 #define RUBY_RELEASE_DATE "2012-02-10"
 #define RUBY_RELEASE_YEAR 2012
Index: ruby_1_9_3/test/ruby/test_argf.rb
===================================================================
--- ruby_1_9_3/test/ruby/test_argf.rb	(revision 34527)
+++ ruby_1_9_3/test/ruby/test_argf.rb	(revision 34528)
@@ -685,6 +685,16 @@
     end
   end
 
+  def test_close_replace
+    ruby('-e', <<-SRC) do |f|
+      ARGF.close
+      ARGV.replace ['#{@t1.path}', '#{@t2.path}', '#{@t3.path}']
+      puts ARGF.read
+    SRC
+      assert_equal("1\n2\n3\n4\n5\n6\n", f.read)
+    end
+  end
+
   def test_closed
     ruby('-e', <<-SRC, @t1.path, @t2.path, @t3.path) do |f|
       3.times do
@@ -748,4 +758,9 @@
     end
     assert_nil(argf.gets, bug4274)
   end
+
+  def test_readlines_twice
+    bug5952 = '[ruby-dev:45160]'
+    assert_ruby_status(["-e", "2.times {STDIN.tty?; readlines}"], "", bug5952)
+  end
 end

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

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