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

ruby-changes:18513

From: nobu <ko1@a...>
Date: Fri, 14 Jan 2011 07:31:02 +0900 (JST)
Subject: [ruby-changes:18513] Ruby:r30536 (trunk): * io.c (argf_next_argv): go advance when the next file cannot be

nobu	2011-01-14 07:30:50 +0900 (Fri, 14 Jan 2011)

  New Revision: 30536

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

  Log:
    * io.c (argf_next_argv): go advance when the next file cannot be
      read.  [ruby-core:34446]

  Modified files:
    trunk/ChangeLog
    trunk/io.c
    trunk/test/ruby/test_argf.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 30535)
+++ ChangeLog	(revision 30536)
@@ -1,3 +1,8 @@
+Fri Jan 14 07:30:47 2011  Nobuyoshi Nakada  <nobu@r...>
+
+	* io.c (argf_next_argv): go advance when the next file cannot be
+	  read.  [ruby-core:34446]
+
 Thu Jan 13 20:49:19 2011  Tanaka Akira  <akr@f...>
 
 	* vm_insnhelper.c: parenthesize macro arguments.
Index: io.c
===================================================================
--- io.c	(revision 30535)
+++ io.c	(revision 30536)
@@ -6829,7 +6829,6 @@
     }
 
     if (ARGF.next_p == 1) {
-	ARGF.next_p = 0;
       retry:
 	if (RARRAY_LEN(ARGF.argv) > 0) {
 	    ARGF.filename = rb_ary_shift(ARGF.argv);
@@ -6933,6 +6932,7 @@
 		fptr->encs = ARGF.encs;
                 clear_codeconv(fptr);
 	    }
+	    ARGF.next_p = 0;
 	}
 	else {
 	    ARGF.next_p = 1;
Index: test/ruby/test_argf.rb
===================================================================
--- test/ruby/test_argf.rb	(revision 30535)
+++ test/ruby/test_argf.rb	(revision 30536)
@@ -720,6 +720,21 @@
     ensure
       argf.close
     end
+  end
 
+  def test_unreadable
+    bug4274 = '[ruby-core:34446]'
+    paths = (1..2).map do
+      t = Tempfile.new("bug4274-")
+      path = t.path
+      t.close!
+      path
+    end
+    argf = ARGF.class.new(*paths)
+    paths.each do |path|
+      e = assert_raise(Errno::ENOENT) {argf.gets}
+      assert_match(/- #{Regexp.quote(path)}\z/, e.message)
+    end
+    assert_nil(argf.gets, bug4274)
   end
 end

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

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