changeset 32864:21acd0c60f5d

(send_process): If OBJECT is t, it means that the data is from C string, but we should encode it. Before calling setup_raw_text_coding_system, be sure to flush out data by the previous coding system.
author Kenichi Handa <handa@m17n.org>
date Wed, 25 Oct 2000 11:06:51 +0000
parents 0a4d038159dd
children 34e286ed22a5
files src/process.c
diffstat 1 files changed, 21 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/process.c	Wed Oct 25 11:06:35 2000 +0000
+++ b/src/process.c	Wed Oct 25 11:06:51 2000 +0000
@@ -3185,13 +3185,11 @@
 
 /* Send some data to process PROC.
    BUF is the beginning of the data; LEN is the number of characters.
-   OBJECT is the Lisp object that the data comes from.
-
-   The data is encoded by PROC's coding-system for encoding before it
-   is sent.  But if the data ends at the middle of multi-byte
-   representation, that incomplete sequence of bytes are sent without
-   being encoded.  Should we store them in a buffer to prepend them to
-   the data send later? 
+   OBJECT is the Lisp object that the data comes from.  If OBJECT is
+   nil or t, it means that the data comes from C string.
+
+   If OBJECT is not nil, the data is encoded by PROC's coding-system
+   for encoding before it is sent.
 
    This function can evaluate Lisp code and can garbage collect.  */
 
@@ -3228,7 +3226,8 @@
 
   if ((STRINGP (object) && STRING_MULTIBYTE (object))
       || (BUFFERP (object)
-	  && !NILP (XBUFFER (object)->enable_multibyte_characters)))
+	  && !NILP (XBUFFER (object)->enable_multibyte_characters))
+      || EQ (object, Qt))
     {
       coding->src_multibyte = 1;
       if (!EQ (coding->symbol, XPROCESS (proc)->encode_coding_system))
@@ -3242,11 +3241,20 @@
     }
   else
     {
-      coding->src_multibyte = 0;
-        /* For sending a unibyte text, character code conversion
-	 should not take place but EOL conversion should.  So, setup
-	 raw-text or one of the subsidiary.  */
-      setup_raw_text_coding_system (coding);
+      /* For sending a unibyte text, character code conversion should
+	 not take place but EOL conversion should.  So, setup raw-text
+	 or one of the subsidiary if we have not yet done it.  */
+      if (coding->type != coding_type_raw_text)
+	{
+	  if (CODING_REQUIRE_FLUSHING (coding))
+	    {
+	      /* But, before changing the coding, we must flush out data.  */
+	      coding->mode |= CODING_MODE_LAST_BLOCK;
+	      send_process (proc, "", 0, Qt);
+	    }
+	  coding->src_multibyte = 0;
+	  setup_raw_text_coding_system (coding);
+	}
     }
   coding->dst_multibyte = 0;