changeset 21281:3763e516cf1e

(read_process_output): Count multibyte characters. If received data is stored in p->decoding_buf, copy it to a temporary buffer and call insert_before_makers instead of insert_from_string_before_markers.
author Kenichi Handa <handa@m17n.org>
date Wed, 25 Mar 1998 10:45:59 +0000
parents 82fbf42bb989
children 58268912c0b5
files src/process.c
diffstat 1 files changed, 14 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/process.c	Wed Mar 25 10:45:59 1998 +0000
+++ b/src/process.c	Wed Mar 25 10:45:59 1998 +0000
@@ -2839,7 +2839,9 @@
 	return 0;
       chars = (char *) XSTRING (p->decoding_buf)->data;
       nbytes = coding->produced;
-      nchars = coding->produced_char;
+      nchars = (coding->fake_multibyte
+		? multibyte_chars_in_text (chars, nbytes)
+		: coding->produced_char);
       chars_in_decoding_buf = 1;
     }
 #ifdef VMS
@@ -2848,11 +2850,12 @@
       /* Although we don't have to decode the received data, we must
          move it to an area which we don't have to free.  */
       if (! STRINGP (p->decoding_buf)
-	  || XSTRING (p->decoding_buf)->size < nbytes)
+	  || STRING_BYTES (XSTRING (p->decoding_buf)) < nbytes)
 	p->decoding_buf = make_uninit_string (nbytes);
       bcopy (chars, XSTRING (p->decoding_buf)->data, nbytes);
       free (chars);
       chars = XSTRING (p->decoding_buf)->data;
+      nchars = multibyte_chars_in_text (chars, nbytes);
       chars_in_decoding_buf = 1;
       carryover = 0;
     }
@@ -2976,8 +2979,15 @@
       /* Insert before markers in case we are inserting where
 	 the buffer's mark is, and the user's next command is Meta-y.  */
       if (chars_in_decoding_buf)
-	insert_from_string_before_markers (p->decoding_buf, 0, 0,
-					   nchars, nbytes, 0);
+	{
+	  /* Since multibyteness of p->docoding_buf is corrupted, we
+             can't use insert_from_string_before_markers.  */
+	  char *temp_buf;
+
+	  temp_buf = (char *) alloca (nbytes);
+	  bcopy (XSTRING (p->decoding_buf)->data, temp_buf, nbytes);
+	  insert_before_markers (temp_buf, nbytes);
+	}
       else
 	insert_1_both (chars, nchars, nbytes, 0, 1, 1);
       set_marker_both (p->mark, p->buffer, PT, PT_BYTE);