changeset 20225:ca258a32a122

(create_process): Encode arguments for the process. (read_process_output): Use new macros defined in coding.h. (send_process): Likewise.
author Kenichi Handa <handa@m17n.org>
date Sat, 08 Nov 1997 03:05:44 +0000
parents fb98ec190b6a
children 549826cf2952
files src/process.c
diffstat 1 files changed, 32 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/process.c	Sat Nov 08 03:05:44 1997 +0000
+++ b/src/process.c	Sat Nov 08 03:05:44 1997 +0000
@@ -1399,6 +1399,35 @@
   setup_coding_system (XPROCESS (process)->encode_coding_system,
 		       proc_encode_coding_system[outchannel]);
 
+  if (CODING_REQUIRE_ENCODING (proc_encode_coding_system[outchannel]))
+    {
+      /* Here we encode arguments by the coding system used for
+	 sending data to the process.  We don't support using
+	 different coding systems for encoding arguments and for
+	 encoding data sent to the process.  */
+      struct gcpro gcpro1;
+      int i = 1;
+      struct coding_system *coding = proc_encode_coding_system[outchannel];
+
+      coding->last_block = 1;
+      GCPRO1 (process);
+      while (new_argv[i] != 0)
+	{
+	  int len = strlen (new_argv[i]);
+	  int size = encoding_buffer_size (coding, len);
+	  unsigned char *buf = (unsigned char *) alloca (size);
+	  int produced, dmy;
+
+	  produced = encode_coding (coding, new_argv[i], buf, len, size, &dmy);
+	  buf[produced] = 0;
+	  /* We don't have to free new_argv[i] because it points to a
+             Lisp string given as an argument to `start-process'.  */
+	  new_argv[i++] = buf;
+	}
+      UNGCPRO;
+      coding->last_block = 0;
+    }
+
   /* Delay interrupts until we have a chance to store
      the new fork's pid in its process structure */
 #ifdef POSIX_SIGNALS
@@ -2754,7 +2783,8 @@
   /* Now set NCHARS how many bytes we must decode.  */
   nchars += coding->carryover_size;
 
-  if (! CODING_REQUIRE_NO_CONVERSION (coding))
+  if (CODING_REQUIRE_DECODING (coding)
+      || CODING_REQUIRE_DETECTION (coding))
     {
       int require = decoding_buffer_size (coding, nchars);
       int consumed, produced;
@@ -3010,7 +3040,7 @@
     error ("Output file descriptor of %s is closed", procname);
 
   coding = proc_encode_coding_system[XINT (XPROCESS (proc)->outfd)];
-  if (! CODING_MAY_REQUIRE_NO_CONVERSION (coding))
+  if (CODING_REQUIRE_ENCODING (coding))
     {
       int require = encoding_buffer_size (coding, len);
       int offset, dummy;