ruby-changes:7207
From: akr <ko1@a...>
Date: Wed, 20 Aug 2008 20:34:05 +0900 (JST)
Subject: [ruby-changes:7207] Ruby:r18726 (trunk): * io.c (rb_io_open_with_args): use rb_open_file instead of rb_io_open.
akr 2008-08-20 20:33:36 +0900 (Wed, 20 Aug 2008) New Revision: 18726 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=18726 Log: * io.c (rb_io_open_with_args): use rb_open_file instead of rb_io_open. Modified files: trunk/ChangeLog trunk/io.c trunk/test/ruby/test_io.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 18725) +++ ChangeLog (revision 18726) @@ -1,3 +1,7 @@ +Wed Aug 20 20:32:49 2008 Tanaka Akira <akr@f...> + + * io.c (rb_io_open_with_args): use rb_open_file instead of rb_io_open. + Wed Aug 20 20:16:17 2008 Tanaka Akira <akr@f...> * io.c (rb_scan_open_args): extracted from rb_open_file. Index: io.c =================================================================== --- io.c (revision 18725) +++ io.c (revision 18726) @@ -4807,19 +4807,11 @@ static VALUE rb_io_open_with_args(int argc, VALUE *argv) { - const char *mode; - VALUE pname, pmode; + VALUE io; - if (rb_scan_args(argc, argv, "11", &pname, &pmode) == 1) { - mode = "r"; - } - else if (FIXNUM_P(pmode)) { - mode = rb_io_modenum_mode(FIX2INT(pmode)); - } - else { - mode = StringValueCStr(pmode); - } - return rb_io_open(StringValueCStr(pname), mode); + io = io_alloc(rb_cFile); + rb_open_file(argc, argv, io); + return io; } static VALUE Index: test/ruby/test_io.rb =================================================================== --- test/ruby/test_io.rb (revision 18725) +++ test/ruby/test_io.rb (revision 18726) @@ -1225,4 +1225,22 @@ def test_uninitialized assert_raise(IOError) { IO.allocate.print "" } end + + def test_nofollow + return unless defined? File::NOFOLLOW + mkcdtmpdir { + open("file", "w") {|f| f << "content" } + begin + File.symlink("file", "slnk") + rescue NotImplementedError + return + end + assert_raise(Errno::ELOOP) { + open("slnk", File::RDONLY|File::NOFOLLOW) {} + } + assert_raise(Errno::ELOOP) { + File.foreach("slnk", :open_args=>[File::RDONLY|File::NOFOLLOW]) {} + } + } + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/