zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: bug with %<< prompt expansion
Date: Fri, 26 Sep 2014 21:39:49 -0700	[thread overview]
Message-ID: <140926213949.ZM6043@torch.brasslantern.com> (raw)
In-Reply-To: <CACPkN-ONVBHyFr8nB0j7+bkMBGP8qO25AASHh34gpXE=RwAuCA@mail.gmail.com>

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


  reply	other threads:[~2014-09-27  4:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-26 23:27 Joel Elkins
2014-09-27  4:39 ` Bart Schaefer [this message]
2014-09-28 13:40   ` Joel Elkins

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=140926213949.ZM6043@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /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).