ruby-changes:48040
From: nobu <ko1@a...>
Date: Tue, 10 Oct 2017 19:42:58 +0900 (JST)
Subject: [ruby-changes:48040] nobu:r60154 (trunk): io.c: path name conversion at ARGF
nobu 2017-10-10 19:42:52 +0900 (Tue, 10 Oct 2017) New Revision: 60154 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60154 Log: io.c: path name conversion at ARGF * io.c (argf_next_argv): the standard conversion to path name should take place. Modified files: trunk/io.c trunk/test/ruby/test_argf.rb Index: test/ruby/test_argf.rb =================================================================== --- test/ruby/test_argf.rb (revision 60153) +++ test/ruby/test_argf.rb (revision 60154) @@ -316,6 +316,34 @@ class TestArgf < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_argf.rb#L316 } end + def test_inplace_to_path + base = "argf-test" + name = "#{@tmpdir}/#{base}" + File.write(name, "foo") + stdout = $stdout + argf = ARGF.class.new(Struct.new(:to_path).new(name)) + begin + result = argf.gets + ensure + $stdout = stdout + argf.close + end + assert_equal("foo", result) + end + + def test_inplace_ascii_incompatible_path + base = "argf-\u{30c6 30b9 30c8}" + name = "#{@tmpdir}/#{base}" + File.write(name, "foo") + stdout = $stdout + argf = ARGF.class.new(name.encode(Encoding::UTF_16LE)) + assert_raise(Encoding::CompatibilityError) do + argf.gets + end + ensure + $stdout = stdout + end + def test_encoding ruby('-e', "#{<<~"{#"}\n#{<<~'};'}", @t1.path, @t2.path, @t3.path) do |f| {# Index: io.c =================================================================== --- io.c (revision 60153) +++ io.c (revision 60154) @@ -136,6 +136,8 @@ off_t __syscall(quad_t number, ...); https://github.com/ruby/ruby/blob/trunk/io.c#L136 #ifdef _WIN32 #undef open #define open rb_w32_uopen +#undef rename +#define rename(f, t) rb_w32_urename((f), (t)) #endif VALUE rb_cIO; @@ -8249,8 +8251,8 @@ argf_next_argv(VALUE argf) https://github.com/ruby/ruby/blob/trunk/io.c#L8251 retry: if (RARRAY_LEN(ARGF.argv) > 0) { VALUE filename = rb_ary_shift(ARGF.argv); - StringValueCStr(filename); - ARGF.filename = rb_str_encode_ospath(filename); + FilePathValue(filename); + ARGF.filename = filename; fn = StringValueCStr(filename); if (RSTRING_LEN(filename) == 1 && fn[0] == '-') { ARGF.current_file = rb_stdin; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/