zsh-workers
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@brasslantern.com>
To: Laurent Wacrenier <lwa@teaser.fr>, zsh-workers@sunsite.dk
Subject: PATCH Re: infinite loop in prompt expansion
Date: Mon, 30 Sep 2002 18:32:30 +0000	[thread overview]
Message-ID: <1020930183230.ZM12902@candle.brasslantern.com> (raw)
In-Reply-To: <20020930145117.GA35025@victor.teaser.fr>

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   


  reply	other threads:[~2002-09-30 18:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-30 14:51 Laurent Wacrenier
2002-09-30 18:32 ` Bart Schaefer [this message]
2002-10-01  9:35   ` PATCH " Laurent Wacrenier
2002-10-02  7:18     ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1020930183230.ZM12902@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=lwa@teaser.fr \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).