From 88783116e06ff7cd5e43041b2c598fe76cfe98db Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 23 Apr 2016 00:03:37 +0000 Subject: [PATCH] ruby.c: fix command line encoding on cygwin * ruby.c: cygwin does not use w32_cmdvector, command line can be other than UTF-8. [ruby-dev:49519] [Bug #12184] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54720 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ ruby.c | 2 ++ test/ruby/test_rubyoptions.rb | 13 ++++++++++--- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0dea6ec3ee..b606513792 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Apr 23 09:03:35 2016 Nobuyoshi Nakada + + * ruby.c: cygwin does not use w32_cmdvector, command line can be + other than UTF-8. [ruby-dev:49519] [Bug #12184] + Sat Apr 23 01:00:03 2016 Rei Odaira * configure.in: don't use the system-provided round(3) on AIX. diff --git a/ruby.c b/ruby.c index 7d06800c7c..128de434d2 100644 --- a/ruby.c +++ b/ruby.c @@ -396,7 +396,9 @@ translit_char_bin(char *p, int from, int to) p++; } } +#endif +#ifdef _WIN32 # define UTF8_PATH 1 #endif diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb index 10cdcd8802..6db6126e28 100644 --- a/test/ruby/test_rubyoptions.rb +++ b/test/ruby/test_rubyoptions.rb @@ -720,7 +720,8 @@ class TestRubyOptions < Test::Unit::TestCase end end - if /mswin|mingw/ =~ RUBY_PLATFORM + case RUBY_PLATFORM + when /mswin|mingw/ def test_command_line_glob_nonascii bug10555 = '[ruby-dev:48752] [Bug #10555]' name = "\u{3042}.txt" @@ -757,9 +758,7 @@ class TestRubyOptions < Test::Unit::TestCase assert_in_out_err(["-e", "", "test/*"], "", [], [], bug10941) end end - end - if /mswin|mingw/ =~ RUBY_PLATFORM Ougai = %W[\u{68ee}O\u{5916}.txt \u{68ee 9d0e 5916}.txt \u{68ee 9dd7 5916}.txt] def test_command_line_glob_noncodepage with_tmpchdir do |dir| @@ -769,6 +768,14 @@ class TestRubyOptions < Test::Unit::TestCase assert_in_out_err(["-e", "puts ARGV", "*.txt"], "", ougai) end end + when /cygwin/ + def test_command_line_non_ascii + assert_separately([{"LC_ALL"=>"ja_JP.SJIS"}, "-", "\u{3042}".encode("SJIS")], <<-"end;") + bug12184 = '[ruby-dev:49519] [Bug #12184]' + a = ARGV[0] + assert_equal([Encoding::SJIS, 130, 160], [a.encoding, *a.bytes], bug12184) + end; + end end def test_script_is_directory