Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: characters with meta in parameters with prompt subst
- X-seq: zsh-workers 26705
- From: Peter Stephenson <pws@xxxxxxx>
- To: "Zsh Hackers' List" <zsh-workers@xxxxxxxxxx>
- Subject: PATCH: characters with meta in parameters with prompt subst
- Date: Tue, 10 Mar 2009 11:08:55 +0000
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- Organization: CSR
This is Sourceforge tracker bug 2182755.
The report didn't give enough information to show it up immediately, but
not surprisingly it involves characters which include a byte that's the
same as the Meta byte, which is the most difficult case.
I haven't looked at how the code got so strangely garbled, but as it's
probably my fault it's hardly worth investigating specially.
There was in fact already a quite similar test for this (just above in
D07multibyte.ztst); so similar I don't quite understand why it passed and
the new one would previously have failed (which I confirmed).
Index: Src/subst.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/subst.c,v
retrieving revision 1.94
diff -u -r1.94 subst.c
--- Src/subst.c 11 Feb 2009 20:42:16 -0000 1.94
+++ Src/subst.c 10 Mar 2009 10:59:59 -0000
@@ -2734,7 +2734,7 @@
*/
if (presc) {
int ops = opts[PROMPTSUBST], opb = opts[PROMPTBANG];
- int opp = opts[PROMPTPERCENT], len;
+ int opp = opts[PROMPTPERCENT];
if (presc < 2) {
opts[PROMPTPERCENT] = 1;
@@ -2756,10 +2756,8 @@
ap = aval;
for (; *ap; ap++) {
char *tmps;
- unmetafy(*ap, &len);
untokenize(*ap);
- tmps = promptexpand(metafy(*ap, len, META_NOALLOC),
- 0, NULL, NULL, NULL);
+ tmps = promptexpand(*ap, 0, NULL, NULL, NULL);
*ap = dupstring(tmps);
free(tmps);
}
@@ -2767,10 +2765,8 @@
char *tmps;
if (!copied)
val = dupstring(val), copied = 1;
- unmetafy(val, &len);
untokenize(val);
- tmps = promptexpand(metafy(val, len, META_NOALLOC),
- 0, NULL, NULL, NULL);
+ tmps = promptexpand(val, 0, NULL, NULL, NULL);
val = dupstring(tmps);
free(tmps);
}
Index: Test/D07multibyte.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/D07multibyte.ztst,v
retrieving revision 1.28
diff -u -r1.28 D07multibyte.ztst
--- Test/D07multibyte.ztst 30 Oct 2008 15:34:18 -0000 1.28
+++ Test/D07multibyte.ztst 10 Mar 2009 10:59:59 -0000
@@ -410,3 +410,20 @@
0:Metafied characters in prompt expansion
>ææçè
>ÐÑÑÑ ÐÐÑÐÑ ÐÐÐÐÐÐÑÐÐÐ
+
+ (
+ setopt nonomatch
+ tmp1=Ä
+ tmpA=(Ä 'ÐÑÑÑ ÐÐÑÐÑ ÐÐÐÐÐÐÑÐÐÐ' ææçè)
+ print ${tmp1} ${(%)tmp1} ${(%%)tmp1}
+ print ${#tmp1} ${#${(%)tmp1}} ${#${(%%)tmp1}}
+ print ${tmpA}
+ print ${(%)tmpA}
+ print ${(%%)tmpA}
+ )
+0:More metafied characters in prompt expansion
+>Ä Ä Ä
+>1 1 1
+>Ä ÐÑÑÑ ÐÐÑÐÑ ÐÐÐÐÐÐÑÐÐÐ ææçè
+>Ä ÐÑÑÑ ÐÐÑÐÑ ÐÐÐÐÐÐÑÐÐÐ ææçè
+>Ä ÐÑÑÑ ÐÐÑÐÑ ÐÐÐÐÐÐÑÐÐÐ ææçè
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
Messages sorted by:
Reverse Date,
Date,
Thread,
Author