]> git.eshelyaron.com Git - emacs.git/commitdiff
(read_process_output): Fix previous change, i.e, if
authorKenichi Handa <handa@m17n.org>
Tue, 9 Dec 1997 04:12:03 +0000 (04:12 +0000)
committerKenichi Handa <handa@m17n.org>
Tue, 9 Dec 1997 04:12:03 +0000 (04:12 +0000)
proc_encode_coding_system[p->outfd] is NULL, instead of allocating
`struct coding_system' for encoding, just skip setting up coding
system for encoding.  Set Vlast_coding_system_used after some text
is read.
(send_process): Set Vlast_coding_system_used after deciding a
coding system to be used for encoding.

src/process.c

index d05071824de26f73dcb73d1b3d7aa16dfd793c1f..ef0cd07d883fb7315f5c03bb3d23b0e478eb108a 100644 (file)
@@ -2807,15 +2807,17 @@ read_process_output (proc, channel)
              proc_decode_coding_system[channel] here.  It is done in
              detect_coding called via decode_coding above.  */
 
-         /* If coding-system for encoding is not yet decided, we set it
-            as the same as coding-system for decoding.  */
-         if (NILP (p->encode_coding_system))
+         /* If coding-system for encoding is not yet decided, we set
+            it as the same as coding-system for decoding.
+
+            But, before doing that we must check if
+            proc_encode_coding_system[p->outfd] surely points to a
+            valid memory because p->outfd will be changed once EOF is
+            sent to the process.  */
+         if (NILP (p->encode_coding_system)
+             && proc_encode_coding_system[p->outfd])
            {
              p->encode_coding_system = coding->symbol;
-             if (!proc_encode_coding_system[p->outfd])
-               proc_encode_coding_system[p->outfd]
-                 = ((struct coding_system *)
-                    xmalloc (sizeof (struct coding_system)));
              setup_coding_system (coding->symbol,
                                   proc_encode_coding_system[p->outfd]);
            }
@@ -2846,6 +2848,8 @@ read_process_output (proc, channel)
     }
 #endif
 
+  Vlast_coding_system_used = coding->symbol;
+
   outstream = p->filter;
   if (!NILP (outstream))
     {
@@ -3047,6 +3051,8 @@ send_process (proc, buf, len, object)
     error ("Output file descriptor of %s is closed", procname);
 
   coding = proc_encode_coding_system[XINT (XPROCESS (proc)->outfd)];
+  Vlast_coding_system_used = coding->symbol;
+
   if (CODING_REQUIRE_ENCODING (coding))
     {
       int require = encoding_buffer_size (coding, len);