diff src/getchar.c @ 620:9e359e5759f6 v7.0177

updated for version 7.0177
author vimboss
date Wed, 28 Dec 2005 22:39:57 +0000
parents 66080ac5dab7
children 6a944e0bd5d2
line wrap: on
line diff
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -529,16 +529,18 @@ AppendToRedobuff(s)
  * K_SPECIAL and CSI are escaped as well.
  */
     void
-AppendToRedobuffLit(s)
-    char_u	*s;
+AppendToRedobuffLit(str, len)
+    char_u	*str;
+    int		len;	    /* length of "str" or -1 for up to the NUL */
 {
+    char_u	*s = str;
     int		c;
     char_u	*start;
 
     if (block_redo)
 	return;
 
-    while (*s != NUL)
+    while (len < 0 ? *s != NUL : s - str < len)
     {
 	/* Put a string of normal characters in the redo buffer (that's
 	 * faster). */
@@ -547,7 +549,7 @@ AppendToRedobuffLit(s)
 #ifndef EBCDIC
 		&& *s < DEL	/* EBCDIC: all chars above space are normal */
 #endif
-		)
+		&& (len < 0 || s - str < len))
 	    ++s;
 
 	/* Don't put '0' or '^' as last character, just in case a CTRL-D is
@@ -557,29 +559,29 @@ AppendToRedobuffLit(s)
 	if (s > start)
 	    add_buff(&redobuff, start, (long)(s - start));
 
-	if (*s != NUL)
-	{
-	    /* Handle a special or multibyte character. */
+	if (*s == NUL || (len >= 0 && s - str >= len))
+	    break;
+
+	/* Handle a special or multibyte character. */
 #ifdef FEAT_MBYTE
-	    if (has_mbyte)
-		/* Handle composing chars separately. */
-		c = mb_cptr2char_adv(&s);
-	    else
+	if (has_mbyte)
+	    /* Handle composing chars separately. */
+	    c = mb_cptr2char_adv(&s);
+	else
 #endif
-		c = *s++;
-	    if (c < ' ' || c == DEL || (*s == NUL && (c == '0' || c == '^')))
-		add_char_buff(&redobuff, Ctrl_V);
-
-	    /* CTRL-V '0' must be inserted as CTRL-V 048 (EBCDIC: xf0) */
-	    if (*s == NUL && c == '0')
+	    c = *s++;
+	if (c < ' ' || c == DEL || (*s == NUL && (c == '0' || c == '^')))
+	    add_char_buff(&redobuff, Ctrl_V);
+
+	/* CTRL-V '0' must be inserted as CTRL-V 048 (EBCDIC: xf0) */
+	if (*s == NUL && c == '0')
 #ifdef EBCDIC
-		add_buff(&redobuff, (char_u *)"xf0", 3L);
+	    add_buff(&redobuff, (char_u *)"xf0", 3L);
 #else
-		add_buff(&redobuff, (char_u *)"048", 3L);
+	    add_buff(&redobuff, (char_u *)"048", 3L);
 #endif
-	    else
-		add_char_buff(&redobuff, c);
-	}
+	else
+	    add_char_buff(&redobuff, c);
     }
 }