summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2009-03-25 09:51:43 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2009-03-25 09:51:43 +0000
commitaa3942d2d121ae3cab753d892a81eae53e03b870 (patch)
tree5beb6d6ff8964dea6c0022b9296d2e02098475fc
parent89d979e1bc39feaff8062ff0fa2242ad277b4080 (diff)
downloadzsh-aa3942d2d121ae3cab753d892a81eae53e03b870.tar.gz
zsh-aa3942d2d121ae3cab753d892a81eae53e03b870.zip
Michael Hwang: 26776: improved column alignment with print -c -P
-rw-r--r--ChangeLog7
-rw-r--r--Src/builtin.c17
2 files changed, 23 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 020716bc6..52e2d6dd7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-03-25 Peter Stephenson <pws@csr.com>
+
+ * Michael Hwang: 26776: Src/builtin.c: improved column alignment
+ with print -c -P.
+
2009-03-24 Peter Stephenson <pws@csr.com>
* 26774: Src/utils.c: cd to $HOME on failure in preference to /.
@@ -11482,5 +11487,5 @@
*****************************************************
* This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.4635 $
+* $Revision: 1.4636 $
*****************************************************
diff --git a/Src/builtin.c b/Src/builtin.c
index 95aca06fd..b715e9782 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -3741,6 +3741,23 @@ bin_print(char *name, char **args, Options ops, int func)
memset(&mbs, 0, sizeof(mbstate_t));
while (l > 0) {
+ /*
+ * Prevent misaligned columns due to escape sequences by
+ * skipping over them. Octals \033 and \233 are the
+ * possible escape characters recognized by ANSI.
+ *
+ * It ought to be possible to do this in the case
+ * of prompt expansion by propagating the information
+ * about escape sequences (currently we strip this
+ * out).
+ */
+ if (*aptr == '\033' || *aptr == '\233') {
+ for (aptr++, l--; l && !isalpha(*aptr); aptr++, l--);
+ aptr++;
+ l--;
+ continue;
+ }
+
wchar_t wc;
size_t cnt = mbrtowc(&wc, aptr, l, &mbs);
int wcw;