Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: mangling of non-ascii char in prompt



On Thu, Jan 12, 2006 at 06:23:47PM -0800, Wayne Davison wrote:
> The problem appears to be that the UTF-8 string coming from %D{%a} is
> not being metafied

Attached are some fixes I just checked in.  They fix this problem in the
prompt, and some similar problems in the zsh/datetime and zsh/stat
modules, both of which needed to metafy values when they were put into
variables.

..wayne..
--- prompt.c	12 Jan 2006 00:51:41 -0000	1.32
+++ prompt.c	13 Jan 2006 09:43:46 -0000	1.34
@@ -543,6 +543,9 @@ putpromptchar(int doprint, int endchar)
 			if (ztrftime(bp, t0, tmfmt, tm) >= 0)
 			    break;
 		    }
+		    /* There is enough room for this because addbufspc(t0)
+		     * allocates room for t0 * 2 bytes. */
+		    metafy(bp, -1, META_NOALLOC);
 		    bp += strlen(bp);
 		    free(tmbuf);
 		    tmbuf = NULL;
--- Modules/datetime.c	7 Dec 2004 16:55:10 -0000	1.11
+++ Modules/datetime.c	13 Jan 2006 09:02:43 -0000	1.12
@@ -67,7 +67,7 @@ bin_strftime(char *nam, char **argv, Opt
     }
 
     if (scalar) {
-	setsparam(scalar, ztrdup(buffer));
+	setsparam(scalar, metafy(buffer, -1, META_DUP));
     } else {
 	printf("%s\n", buffer);
     }
--- Modules/stat.c	19 Dec 2005 11:35:44 -0000	1.10
+++ Modules/stat.c	13 Jan 2006 09:15:59 -0000	1.11
@@ -570,11 +570,11 @@ bin_stat(char *name, char **args, Option
 	if (iwhich > -1) {
 	    statprint(&statbuf, outbuf, *args, iwhich, flags);
 	    if (arrnam)
-		*arrptr++ = ztrdup(outbuf);
+		*arrptr++ = metafy(outbuf, -1, META_DUP);
 	    else if (hashnam) {
 		/* STF_NAME explicitly turned off for ops.ind['H'] above */
 	    	*hashptr++ = ztrdup(statelts[iwhich]);
-		*hashptr++ = ztrdup(outbuf);
+		*hashptr++ = metafy(outbuf, -1, META_DUP);
 	    } else
 		printf("%s\n", outbuf);
 	} else {
@@ -582,11 +582,11 @@ bin_stat(char *name, char **args, Option
 	    for (i = 0; i < ST_COUNT; i++) {
 		statprint(&statbuf, outbuf, *args, i, flags);
 		if (arrnam)
-		    *arrptr++= ztrdup(outbuf);
+		    *arrptr++= metafy(outbuf, -1, META_DUP);
 		else if (hashnam) {
 		    /* STF_NAME explicitly turned off for ops.ind['H'] above */
 		    *hashptr++ = ztrdup(statelts[i]);
-		    *hashptr++ = ztrdup(outbuf);
+		    *hashptr++ = metafy(outbuf, -1, META_DUP);
 		} else
 		    printf("%s\n", outbuf);
 	    }


Messages sorted by: Reverse Date, Date, Thread, Author