From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12477 invoked by alias); 27 Sep 2014 04:40:04 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 33256 Received: (qmail 7847 invoked from network); 27 Sep 2014 04:39:51 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 From: Bart Schaefer Message-id: <140926213949.ZM6043@torch.brasslantern.com> Date: Fri, 26 Sep 2014 21:39:49 -0700 In-reply-to: Comments: In reply to Joel Elkins "bug with %<< prompt expansion" (Sep 26, 6:27pm) References: X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Re: bug with %<< prompt expansion MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Sep 26, 6:27pm, Joel Elkins wrote: } } % print -P "%4>.>12345" } 123. } % print -P "%4>.>1%{%}2345" } 12. } } In my opinion, these two commands should have the same output. Right you are. I'm not entirely sure why this doesn't seem to affect %<< but it looks like it has the same logic error, so I patched that branch as well. diff --git a/Src/prompt.c b/Src/prompt.c index 9ed6c54..0cc9ef9 100644 --- a/Src/prompt.c +++ b/Src/prompt.c @@ -1316,12 +1316,11 @@ prompttrunc(int arg, int truncchar, int doprint, int endchar, */ for (;;) { *ptr++ = *fulltextptr; - if (*fulltextptr == Outpar || - *fulltextptr == '\0') + if (*fulltextptr == '\0' || + *fulltextptr++ == Outpar) break; - if (*fulltextptr == Nularg) + if (fulltextptr[-1] == Nularg) remw--; - fulltextptr++; } } else { #ifdef MULTIBYTE_SUPPORT @@ -1397,12 +1396,11 @@ prompttrunc(int arg, int truncchar, int doprint, int endchar, if (*skiptext == Inpar) { /* see comment on left truncation above */ for (;;) { - if (*skiptext == Outpar || - *skiptext == '\0') + if (*skiptext == '\0' || + *skiptext++ == Outpar) break; - if (*skiptext == Nularg) + if (skiptext[-1] == Nularg) maxwidth--; - skiptext++; } } else { #ifdef MULTIBYTE_SUPPORT