Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: Column alignment with print -c -P
- X-seq: zsh-workers 26776
- From: Michael Hwang <nomex45@xxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: PATCH: Column alignment with print -c -P
- Date: Tue, 24 Mar 2009 16:11:12 -0700 (PDT)
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1237936272; bh=YhfHn/V4plPevK3hP1geKLf8DFG0QxOJJTurybCZkMI=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type; b=pSvXDF6xVZGl3ICN0DkOl1+zmCMlMy7wQZVtebDtZBdKG9NPgHP20VzQfdh4ANywUKuQA4mGR8VheotZLDGZo0liEAWlXPRGKV9zEfPEpJY5LJLaNtvLGNmQrBZKBiN2nfdvxDZ/e+UJ7KUpNCES+DNHn6Lzy0v6O+qTWl1fleM=
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type; b=jnsocl101KJKUT61umtIisbP2mt/Y0L1qVPXK8unyQzbGwHLpE4Uz4IGz3kys7z3h+vm6EAyLpJSvMWStJ2BfABjFDeqSHTYOOojTHfl96DurW8l/DTuvQQYF8zZeWiGDNwgJXlqrDEr82iJti55surb7gU9qAYDaMxUTS8yJDE=;
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
This fixes misaligned columns when using %B, %U, %S, %F, or %K prompt expansions with the -c/-C option of the print builtin. This fix only affects those who have multibyte enabled.
diff --git a/Src/builtin.c b/Src/builtin.c
index 95aca06..250aa3e 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -3741,6 +3741,16 @@ 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. */
+ 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;
Messages sorted by:
Reverse Date,
Date,
Thread,
Author