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

ruby-changes:46040

From: usa <ko1@a...>
Date: Sun, 26 Mar 2017 02:35:57 +0900 (JST)
Subject: [ruby-changes:46040] usa:r58111 (ruby_2_2): merge revision(s) 54785: [Backport #11900]

usa	2017-03-26 02:35:52 +0900 (Sun, 26 Mar 2017)

  New Revision: 58111

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58111

  Log:
    merge revision(s) 54785: [Backport #11900]
    
    * ruby.c (process_options): convert -e script to the encoding
      given by a command line option on Windows.  assume it is the
      expected encoding.  [ruby-dev:49461] [Bug #11900]

  Modified directories:
    branches/ruby_2_2/
  Modified files:
    branches/ruby_2_2/ChangeLog
    branches/ruby_2_2/ruby.c
    branches/ruby_2_2/test/ruby/test_rubyoptions.rb
    branches/ruby_2_2/version.h
Index: ruby_2_2/version.h
===================================================================
--- ruby_2_2/version.h	(revision 58110)
+++ ruby_2_2/version.h	(revision 58111)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1
 #define RUBY_VERSION "2.2.7"
 #define RUBY_RELEASE_DATE "2017-03-26"
-#define RUBY_PATCHLEVEL 443
+#define RUBY_PATCHLEVEL 444
 
 #define RUBY_RELEASE_YEAR 2017
 #define RUBY_RELEASE_MONTH 3
Index: ruby_2_2/test/ruby/test_rubyoptions.rb
===================================================================
--- ruby_2_2/test/ruby/test_rubyoptions.rb	(revision 58110)
+++ ruby_2_2/test/ruby/test_rubyoptions.rb	(revision 58111)
@@ -739,6 +739,34 @@ class TestRubyOptions < Test::Unit::Test https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_rubyoptions.rb#L739
         assert_in_out_err(["-e", "puts ARGV", "*.txt"], "", ougai)
       end
     end
+
+    def assert_e_script_encoding(str, args = [])
+      cmds = [
+        EnvUtil::LANG_ENVS.inject({}) {|h, k| h[k] = ENV[k]; h},
+        *args,
+        '-e', "s = '#{str}'",
+        '-e', 'puts s.encoding.name',
+        '-e', 'puts s.dump',
+      ]
+      assert_in_out_err(cmds, "", [str.encoding.name, str.dump], [],
+                        "#{str.encoding}:#{str.dump} #{args.inspect}")
+    end
+
+    # tested codepages: 437 850 852 855 932 65001
+    # Since the codepage is shared all processes per conhost.exe, do
+    # not chcp, or parallel test may break.
+    def test_locale_codepage
+      locale = Encoding.find("locale")
+      list = %W"\u{c7} \u{452} \u{3066 3059 3068}"
+      list.each do |s|
+        assert_e_script_encoding(s, %w[-U])
+      end
+      list.each do |s|
+        s = s.encode(locale) rescue next
+        assert_e_script_encoding(s)
+        assert_e_script_encoding(s, %W[-E#{locale.name}])
+      end
+    end
   when /cygwin/
     def test_command_line_non_ascii
       assert_separately([{"LC_ALL"=>"ja_JP.SJIS"}, "-", "\u{3042}".encode("SJIS")], <<-"end;")
Index: ruby_2_2/ChangeLog
===================================================================
--- ruby_2_2/ChangeLog	(revision 58110)
+++ ruby_2_2/ChangeLog	(revision 58111)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1
+Sun Mar 26 02:35:17 2017  Nobuyoshi Nakada  <nobu@r...>
+
+	* ruby.c (process_options): convert -e script to the encoding
+	  given by a command line option on Windows.  assume it is the
+	  expected encoding.  [ruby-dev:49461] [Bug #11900]
+
 Sun Mar 26 02:32:12 2017  NAKAMURA Usaku  <usa@r...>
 
 	* win32/win32.c (poll_child_status): rb_w32_wait_events_blocking() sets
Index: ruby_2_2/ruby.c
===================================================================
--- ruby_2_2/ruby.c	(revision 58110)
+++ ruby_2_2/ruby.c	(revision 58111)
@@ -1285,6 +1285,9 @@ process_options(int argc, char **argv, s https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ruby.c#L1285
     VALUE parser;
     VALUE iseq;
     rb_encoding *enc, *lenc;
+#if UTF8_PATH
+    rb_encoding *uenc, *ienc = 0;
+#endif
     const char *s;
     char fbuf[MAXPATHLEN];
     int i = (int)proc_options(argc, argv, opt, 0);
@@ -1395,6 +1398,9 @@ process_options(int argc, char **argv, s https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ruby.c#L1398
 	enc = rb_enc_from_index(opt->intern.enc.index);
 	rb_enc_set_default_internal(rb_enc_from_encoding(enc));
 	opt->intern.enc.index = -1;
+#if UTF8_PATH
+	ienc = enc;
+#endif
     }
     rb_enc_associate(opt->script_name, lenc);
     rb_obj_freeze(opt->script_name);
@@ -1413,8 +1419,11 @@ process_options(int argc, char **argv, s https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ruby.c#L1419
     }
     ruby_init_prelude();
 #if UTF8_PATH
-    opt->script_name = str_conv_enc(opt->script_name, rb_utf8_encoding(), lenc);
-    opt->script = RSTRING_PTR(opt->script_name);
+    uenc = rb_utf8_encoding();
+    if (uenc != lenc) {
+	opt->script_name = str_conv_enc(opt->script_name, uenc, lenc);
+	opt->script = RSTRING_PTR(opt->script_name);
+    }
 #endif
     ruby_set_argv(argc, argv);
     process_sflag(&opt->sflag);
@@ -1438,7 +1447,15 @@ process_options(int argc, char **argv, s https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ruby.c#L1447
 	}
 	else {
 	    eenc = lenc;
+#if UTF8_PATH
+	    if (ienc) eenc = ienc;
+#endif
 	}
+#if UTF8_PATH
+	if (eenc != uenc) {
+	    opt->e_script = str_conv_enc(opt->e_script, uenc, eenc);
+	}
+#endif
 	rb_enc_associate(opt->e_script, eenc);
 	if (!(opt->dump & ~DUMP_BIT(version_v))) {
 	    ruby_set_script_name(opt->script_name);

Property changes on: ruby_2_2
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r54785


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

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