zsh-workers
 help / color / mirror / code / Atom feed
* mangling of non-ascii char in prompt
@ 2006-01-12  2:29 Clint Adams
  2006-01-12  4:01 ` Andrey Borzenkov
  2006-01-13  2:23 ` Wayne Davison
  0 siblings, 2 replies; 5+ messages in thread
From: Clint Adams @ 2006-01-12  2:29 UTC (permalink / raw)
  To: zsh-workers

I haven't debugged this any further yet.

% LANG=hr_HR.UTF-8
% PS1="%D{%a}%# "
Sri% print -P '%D{%a}'
Sri
Sri% export TZ=UTC
�t% print -P '%D{%a}'
Čet
�t% 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: mangling of non-ascii char in prompt
  2006-01-12  2:29 mangling of non-ascii char in prompt Clint Adams
@ 2006-01-12  4:01 ` Andrey Borzenkov
  2006-01-13  0:45   ` Clint Adams
  2006-01-13  2:23 ` Wayne Davison
  1 sibling, 1 reply; 5+ messages in thread
From: Andrey Borzenkov @ 2006-01-12  4:01 UTC (permalink / raw)
  To: zsh-workers

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thursday 12 January 2006 05:29, Clint Adams wrote:
> I haven't debugged this any further yet.
>
> % LANG=hr_HR.UTF-8
> % PS1="%D{%a}%# "
> Sri% print -P '%D{%a}'
> Sri
> Sri% export TZ=UTC
> �t% print -P '%D{%a}'
> Čet
> �t%

I can't reproduce it in current CVS;

{pts/1}% PS1="%D{%a}%# "
Чтв% print -P '%D{%a}'
Чтв
Чтв% export TZ=UTC
Чтв% print -P '%D{%a}'
Чтв
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFDxdSjR6LMutpd94wRAmB9AJ0Zr8NWP88VYH213POPgW3NjIgt/ACbBRYg
cIovQUd3v4a3VaKbgoHvDCw=
=pAoj
-----END PGP SIGNATURE-----


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: mangling of non-ascii char in prompt
  2006-01-12  4:01 ` Andrey Borzenkov
@ 2006-01-13  0:45   ` Clint Adams
  0 siblings, 0 replies; 5+ messages in thread
From: Clint Adams @ 2006-01-13  0:45 UTC (permalink / raw)
  To: Andrey Borzenkov; +Cc: zsh-workers

> {pts/1}% PS1="%D{%a}%# "
> Чтв% print -P '%D{%a}'
> Чтв
> Чтв% export TZ=UTC
> Чтв% print -P '%D{%a}'
> Чтв

I get the above for ru_RU.UTF-8, but hr_HR.UTF-8 is still broken.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: mangling of non-ascii char in prompt
  2006-01-12  2:29 mangling of non-ascii char in prompt Clint Adams
  2006-01-12  4:01 ` Andrey Borzenkov
@ 2006-01-13  2:23 ` Wayne Davison
  2006-01-13  9:47   ` Wayne Davison
  1 sibling, 1 reply; 5+ messages in thread
From: Wayne Davison @ 2006-01-13  2:23 UTC (permalink / raw)
  To: zsh-workers

On Wed, Jan 11, 2006 at 09:29:50PM -0500, Clint Adams wrote:
> % LANG=hr_HR.UTF-8
> % PS1="%D{%a}%# "

The problem appears to be that the UTF-8 string coming from %D{%a} is
not being metafied, so zputs() is outputting the string wrong.  The
above PS1 setting on a Thursday results in this 4-char string being
assigned to lpromptbuf:

    \304\254et

The second character does not pass the itok() test, so it is skipped,
mangling the output.

If I assign the above 4-character string directly to PS1 via a variable,
the second character is properly metafied:

    \304\203\254et

And the string outputs correctly.

..wayne..


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: mangling of non-ascii char in prompt
  2006-01-13  2:23 ` Wayne Davison
@ 2006-01-13  9:47   ` Wayne Davison
  0 siblings, 0 replies; 5+ messages in thread
From: Wayne Davison @ 2006-01-13  9:47 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 390 bytes --]

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

[-- Attachment #2: meta.patch --]
[-- Type: text/plain, Size: 1873 bytes --]

--- 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);
 	    }

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-01-13  9:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-12  2:29 mangling of non-ascii char in prompt Clint Adams
2006-01-12  4:01 ` Andrey Borzenkov
2006-01-13  0:45   ` Clint Adams
2006-01-13  2:23 ` Wayne Davison
2006-01-13  9:47   ` Wayne Davison

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