Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH Re: infinite loop in prompt expansion
- X-seq: zsh-workers 17747
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxx>
- To: Laurent Wacrenier <lwa@xxxxxxxxx>, zsh-workers@xxxxxxxxxx
- Subject: PATCH Re: infinite loop in prompt expansion
- Date: Mon, 30 Sep 2002 18:32:30 +0000
- In-reply-to: <20020930145117.GA35025@xxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20020930145117.GA35025@xxxxxxxxxxxxxxxx>
On Sep 30, 4:51pm, Laurent Wacrenier wrote:
} Subject: infinite loop in prompt expansion
}
} Prompt truncation may enter in infinite loop within litteral escape
} sequence :
}
} % print -P '%{%8<..<%/%}'
} (don't give the hand back and spend all CPU time)
It shouldn't infinte loop, but I'd like to point out that it also is not
intended to do anything useful.
%{ ... %} means that the string inside the braces is treated as zero width
for purposes of computing the size of the prompt. Truncating a zero width
string is a no-op.
Hence the fix (which is probably not going to make you happy) is this:
Index: prompt.c
===================================================================
RCS file: /extra/cvsroot/zsh/zsh-4.0/Src/prompt.c,v
retrieving revision 1.6
diff -c -r1.6 prompt.c
--- prompt.c 1 Sep 2002 16:47:38 -0000 1.6
+++ prompt.c 30 Sep 2002 18:31:15 -0000
@@ -856,6 +856,10 @@
addbufspc(1);
*bp++ = *fm++;
}
+ if (dontcount) {
+ bp = buf + w;
+ return 1;
+ }
if (!*fm)
return 0;
if (bp - buf == w && truncchar == ']') {
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
Messages sorted by:
Reverse Date,
Date,
Thread,
Author