changeset 34856:a79d5c8fdfaf

(echo_prompt): Always set current_kboard->echoptr to the end of the prompt. Set echo_after_prompt to the offset of echoptr in echobuf.
author Gerd Moellmann <gerd@gnu.org>
date Sat, 23 Dec 2000 23:08:42 +0000
parents dbcb6bfb3ddb
children 6c2e68c36cdd
files src/keyboard.c
diffstat 1 files changed, 20 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/src/keyboard.c	Sat Dec 23 20:54:14 2000 +0000
+++ b/src/keyboard.c	Sat Dec 23 23:08:42 2000 +0000
@@ -692,36 +692,37 @@
 echo_prompt (str)
      Lisp_Object str;
 {
-  int len = STRING_BYTES (XSTRING (str));
+  int nbytes = STRING_BYTES (XSTRING (str));
   int multibyte_p = STRING_MULTIBYTE (str);
 
-  if (len > ECHOBUFSIZE - 4)
+  if (nbytes > ECHOBUFSIZE - 4)
     {
       if (multibyte_p)
 	{
-	  unsigned char *p = XSTRING (str)->data, *lastp = p;
+	  /* Have to find the last character that fit's into the 
+	     echo buffer.  */
+	  unsigned char *p = XSTRING (str)->data;
 	  unsigned char *pend = p + ECHOBUFSIZE - 4;
-
-	  while (p < pend)
+	  int char_len;
+
+	  do 
 	    {
-	      int this_len;
-
-	      lastp = p;
-	      PARSE_MULTIBYTE_SEQ (p, pend - p, this_len);
-	      p += this_len;
+	      PARSE_MULTIBYTE_SEQ (p, pend - p, char_len);
+	      p += char_len;
 	    }
-	  len = lastp - XSTRING (str)->data;
+	  while (p < pend);
+
+	  nbytes = p - XSTRING (str)->data - char_len;
 	}
       else
-	len = ECHOBUFSIZE - 4;
-    }
-
-  current_kboard->echoptr
-    += copy_text (XSTRING (str)->data, current_kboard->echobuf, len,
-		  STRING_MULTIBYTE (str), 1);
+	nbytes = ECHOBUFSIZE - 4;
+    }
+
+  nbytes = copy_text (XSTRING (str)->data, current_kboard->echobuf, nbytes,
+		      STRING_MULTIBYTE (str), 1);
+  current_kboard->echoptr = current_kboard->echobuf + nbytes;
   *current_kboard->echoptr = '\0';
-
-  current_kboard->echo_after_prompt = len;
+  current_kboard->echo_after_prompt = nbytes;
 
   echo_now ();
 }