Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: bug in delete-to-char in 4.3.9



On Sun, 7 Dec 2008 02:18:11 -0500
Greg Klanderman <gak@xxxxxxxxxxxxxx> wrote:
> Hi, there appears to be a small bug in delete-to-char in zsh 4.3.9.
> I'm upgrading from 4.2.5 so don't know how long ago it was introduced.
> The bug causes either incorrect behavior, or the crash:
> 
> | zsh: fatal error: out of memory
> 
> zap-to-char works so long as you don't give it a prefix (count)
> argument.

Yes, it's got a bit knocked about.

Index: Src/Zle/deltochar.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/deltochar.c,v
retrieving revision 1.9
diff -u -r1.9 deltochar.c
--- Src/Zle/deltochar.c	13 Apr 2008 16:58:42 -0000	1.9
+++ Src/Zle/deltochar.c	7 Dec 2008 18:42:27 -0000
@@ -44,11 +44,10 @@
     if (n > 0) {
 	while (n-- && dest != zlell) {
 	    while (dest != zlell && (ZLE_INT_T)zleline[dest] != c)
-		dest++;
+		INCPOS(dest);
 	    if (dest != zlell) {
-		/* HERE adjust dest for trailing combining chars */
 		if (!zap || n > 0)
-		    INCCS();
+		    INCPOS(dest);
 		if (!n) {
 		    forekill(dest - zlecs, CUT_RAW);
 		    ok++;
@@ -58,10 +57,10 @@
     } else {
 	/* ignore character cursor is on when scanning backwards */
 	if (dest)
-	    dest--;
+	    DECPOS(dest);
 	while (n++ && dest != 0) {
 	    while (dest != 0 && (ZLE_INT_T)zleline[dest] != c)
-		dest--;
+		DECPOS(dest);
 	    if ((ZLE_INT_T)zleline[dest] == c) {
 		if (!n) {
 		    /* HERE adjust zap for trailing combining chars */
@@ -69,7 +68,7 @@
 		    ok++;
 		}
 		if (dest)
-		    dest--;
+		    DECPOS(dest);
 	    }
 	}
     }


-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/



Messages sorted by: Reverse Date, Date, Thread, Author