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

ruby-changes:44352

From: nobu <ko1@a...>
Date: Sat, 15 Oct 2016 00:54:09 +0900 (JST)
Subject: [ruby-changes:44352] nobu:r56424 (trunk): process.c: use uaspawn

nobu	2016-10-15 00:54:03 +0900 (Sat, 15 Oct 2016)

  New Revision: 56424

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

  Log:
    process.c: use uaspawn
    
    * process.c (proc_exec_cmd): use UTF-8 version aspawn.
      [ruby-dev:49838] [Bug #12841]

  Modified files:
    trunk/ChangeLog
    trunk/process.c
    trunk/test/ruby/test_process.rb
Index: process.c
===================================================================
--- process.c	(revision 56423)
+++ process.c	(revision 56424)
@@ -1247,7 +1247,9 @@ proc_exec_cmd(const char *prog, VALUE ar https://github.com/ruby/ruby/blob/trunk/process.c#L1247
     UNREACHABLE;
 #else
     char **argv;
+#ifndef _WIN32
     char **envp;
+#endif
 
     argv = ARGVSTR2ARGV(argv_str);
 
@@ -1256,12 +1258,16 @@ proc_exec_cmd(const char *prog, VALUE ar https://github.com/ruby/ruby/blob/trunk/process.c#L1258
 	return -1;
     }
 
+#ifdef _WIN32
+    rb_w32_uaspawn(P_OVERLAY, prog, argv);
+#else
     envp = envp_str ? (char **)RSTRING_PTR(envp_str) : NULL;
     if (envp_str)
         execve(prog, argv, envp); /* async-signal-safe */
     else
         execv(prog, argv); /* async-signal-safe (since SUSv4) */
     preserving_errno(try_with_sh(prog, argv, envp)); /* try_with_sh() is async-signal-safe. */
+#endif
     return -1;
 #endif
 }
Index: test/ruby/test_process.rb
===================================================================
--- test/ruby/test_process.rb	(revision 56423)
+++ test/ruby/test_process.rb	(revision 56424)
@@ -1910,6 +1910,27 @@ EOS https://github.com/ruby/ruby/blob/trunk/test/ruby/test_process.rb#L1910
     end
   end if windows?
 
+  def test_exec_nonascii
+    bug12841 = '[ruby-dev:49838] [Bug #12841]'
+
+    [
+      "\u{7d05 7389}",
+      "zuf\u{00E4}llige_\u{017E}lu\u{0165}ou\u{010D}k\u{00FD}_\u{10D2 10D0 10DB 10D4 10DD 10E0 10D4 10D1}_\u{0440 0430 0437 043B 043E 0433 0430}_\u{548C 65B0 52A0 5761 4EE5 53CA 4E1C}",
+      "c\u{1EE7}a",
+    ].each do |arg|
+      begin
+        arg = arg.encode(Encoding.find("locale"))
+      rescue
+      else
+        assert_in_out_err([], "#{<<-"begin;"}\n#{<<-"end;"}", [arg], [], bug12841)
+        begin;
+          arg = "#{arg.b}".force_encoding("#{arg.encoding.name}")
+          exec(ENV["COMSPEC"]||"cmd.exe", "/c", "echo", arg)
+        end;
+      end
+    end
+  end if windows?
+
   def test_clock_gettime
     t1 = Process.clock_gettime(Process::CLOCK_REALTIME, :nanosecond)
     t2 = Time.now; t2 = t2.tv_sec * 1000000000 + t2.tv_nsec
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 56423)
+++ ChangeLog	(revision 56424)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Oct 15 00:54:01 2016  Nobuyoshi Nakada  <nobu@r...>
+
+	* process.c (proc_exec_cmd): use UTF-8 version aspawn.
+	  [ruby-dev:49838] [Bug #12841]
+
 Fri Oct 14 22:26:10 2016  Nobuyoshi Nakada  <nobu@r...>
 
 	* lib/optparse/kwargs.rb (OptionParser#define_by_keywords):

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

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