zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: characters with meta in parameters with prompt subst
@ 2009-03-10 11:08 Peter Stephenson
  0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 2009-03-10 11:08 UTC (permalink / raw)
  To: Zsh Hackers' List

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@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-03-10 11:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-10 11:08 PATCH: characters with meta in parameters with prompt subst Peter Stephenson

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).