ruby-changes:21162
From: kosaki <ko1@a...>
Date: Wed, 7 Sep 2011 23:43:27 +0900 (JST)
Subject: [ruby-changes:21162] kosaki:r33211 (ruby_1_9_3): merge revision(s) 33171:
kosaki 2011-09-07 23:43:10 +0900 (Wed, 07 Sep 2011) New Revision: 33211 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=33211 Log: merge revision(s) 33171: * io.c (argf_next_argv): open in default text mode. [ruby-core:39234] [Bug #5268] 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 33210) +++ ruby_1_9_3/ChangeLog (revision 33211) @@ -1,3 +1,8 @@ +Wed Sep 7 23:42:45 2011 Nobuyoshi Nakada <nobu@r...> + + * io.c (argf_next_argv): open in default text mode. + [ruby-core:39234] [Bug #5268] + Mon Sep 5 15:06:55 2011 NARUSE, Yui <naruse@r...> * test/rubygems/test_gem_security.rb Index: ruby_1_9_3/io.c =================================================================== --- ruby_1_9_3/io.c (revision 33210) +++ ruby_1_9_3/io.c (revision 33211) @@ -6840,6 +6840,7 @@ char *fn; rb_io_t *fptr; int stdout_binmode = 0; + int fmode; if (TYPE(rb_stdout) == T_FILE) { GetOpenFile(rb_stdout, fptr); @@ -6948,19 +6949,25 @@ rb_stdout = write_io; if (stdout_binmode) rb_io_binmode(rb_stdout); } - ARGF.current_file = prep_io(fr, FMODE_READABLE, rb_cFile, fn); + fmode = FMODE_READABLE; + if (!ARGF.binmode) fmode |= DEFAULT_TEXTMODE; + ARGF.current_file = prep_io(fr, fmode, rb_cFile, fn); if (!NIL_P(write_io)) { rb_io_set_write_io(ARGF.current_file, write_io); } } if (ARGF.binmode) rb_io_ascii8bit_binmode(ARGF.current_file); + GetOpenFile(ARGF.current_file, fptr); if (ARGF.encs.enc) { - rb_io_t *fptr; - - GetOpenFile(ARGF.current_file, fptr); fptr->encs = ARGF.encs; clear_codeconv(fptr); } + else { + fptr->encs.ecflags &= ~ECONV_NEWLINE_DECORATOR_MASK; + if (!ARGF.binmode) { + fptr->encs.ecflags |= ECONV_DEFAULT_NEWLINE_DECORATOR; + } + } ARGF.next_p = 0; } else { Index: ruby_1_9_3/version.h =================================================================== --- ruby_1_9_3/version.h (revision 33210) +++ ruby_1_9_3/version.h (revision 33211) @@ -1,10 +1,10 @@ #define RUBY_VERSION "1.9.3" #define RUBY_PATCHLEVEL -1 -#define RUBY_RELEASE_DATE "2011-09-05" +#define RUBY_RELEASE_DATE "2011-09-07" #define RUBY_RELEASE_YEAR 2011 #define RUBY_RELEASE_MONTH 9 -#define RUBY_RELEASE_DAY 5 +#define RUBY_RELEASE_DAY 7 #include "ruby/version.h" Index: ruby_1_9_3/test/ruby/test_argf.rb =================================================================== --- ruby_1_9_3/test/ruby/test_argf.rb (revision 33210) +++ ruby_1_9_3/test/ruby/test_argf.rb (revision 33211) @@ -648,12 +648,23 @@ end def test_binmode + bug5268 = '[ruby-core:39234]' + open(@t3.path, "wb") {|f| f.write "5\r\n6\r\n"} ruby('-e', "ARGF.binmode; STDOUT.binmode; puts ARGF.read", @t1.path, @t2.path, @t3.path) do |f| f.binmode - assert_equal("1\n2\n3\n4\n5\n6\n", f.read) + assert_equal("1\n2\n3\n4\n5\r\n6\r\n", f.read, bug5268) end end + def test_textmode + bug5268 = '[ruby-core:39234]' + open(@t3.path, "wb") {|f| f.write "5\r\n6\r\n"} + ruby('-e', "STDOUT.binmode; puts ARGF.read", @t1.path, @t2.path, @t3.path) do |f| + f.binmode + assert_equal("1\n2\n3\n4\n5\n6\n", f.read, bug5268) + end + end unless IO::BINARY.zero? + def test_skip ruby('-e', <<-SRC, @t1.path, @t2.path, @t3.path) do |f| ARGF.skip -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/