[Message Prev][Message Next][Thread Prev][Thread Next][Message Index][Thread Index]

Re: How to specify coding-system of process parmeters?



Keisuke Mori <ksk@xxxxxxxx> writes:
> horiguti@xxxxxxxxxxxxx (Kyotaro HORIGUCHI) writes:
> >    start-process でプロセスの起動パラメータの漢字コードを指定する
> >   にはどうしたらいいのでしょうか.  process-coding-system-alist で
> >   は call-process のパラメータの文字コードは変わりますが,
> >   start-process のは変わっていないようです.
> 
> とりあえず今のソースを見る限り、start-process の方では引数の
> encode はしていないようなので、「とりあえずは無理」と思います。

「とりあえず無理矢理」patch を作ってみました。callproc.c からほ
とんどコピーしただけですけど。

-- 
	Keisuke Mori / NTT Software Corp. California Branch
	E-Mail: ksk@xxxxxxxx
--- process.c.org	Mon Oct 20 06:55:19 1997
+++ process.c	Wed Apr 08 11:24:39 1998
@@ -1134,6 +1134,8 @@
       new_argv[0] = XSTRING (program)->data;
     }
 
+#if 0 /* KSK Apr/08/1998 */
+  /* set new_argv later with encoding arguments */
   for (i = 3; i < nargs; i++)
     {
       tem = args[i];
@@ -1141,6 +1143,7 @@
       new_argv[i - 2] = XSTRING (tem)->data;
     }
   new_argv[i - 2] = 0;
+#endif /* KSK */
 #endif /* not VMS */
 
   proc = make_process (name);
@@ -1226,6 +1229,36 @@
   XPROCESS (proc)->decoding_buf = make_uninit_string (0);
   XPROCESS (proc)->encoding_buf = make_uninit_string (0);
 
+#ifndef VMS
+  { /* encode arguments into new_argv here :KSK Apr/08/1998*/
+    /* this code is copied from call-process definition in callproc.c */
+    struct coding_system argument_coding;
+    tem = XPROCESS (proc)->encode_coding_system; /* just for short writing */
+    setup_coding_system (Fcheck_coding_system (tem), &argument_coding);
+    for (i = 3; i < nargs; i++)
+      {
+	tem = args[i];
+	CHECK_STRING (tem, i);
+	if (argument_coding.type == coding_type_no_conversion)
+	  new_argv[i - 2] = XSTRING (tem)->data;
+	else
+	  {
+	    int size = encoding_buffer_size (&argument_coding,
+					     XSTRING (tem)->size);	     
+	    int produced, dummy;
+	    unsigned char *dummy1 = (unsigned char *) alloca (size);
+	    /* The Irix 4.0 compiler barfs if we eliminate dummy.  */
+	    new_argv[i - 2] = dummy1;
+	    produced = encode_coding (&argument_coding,
+				      XSTRING (tem)->data, new_argv[i - 2],
+				      XSTRING (tem)->data, size, &dummy);
+	    new_argv[i - 2][produced] = 0;
+	  }
+      }
+    new_argv[i - 2] = 0;
+  }
+#endif /* VMS */
+  
   create_process (proc, new_argv, current_dir);
 
   return unbind_to (count, proc);