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

Re: PATCH: prompt truncation with multibyte characters



On 10/19/05, Peter Stephenson <pws@xxxxxxx> wrote:
> Here's a go at extending prompt truncation to work with multibyte
> characters in the prompt string.  It doesn't look very much like the
> existing code in the other branch because I didn't really understand
> that (possibly I wrote bits of it).  It seems to do roughly the right
> thing; if anyone finds any more obscure uses, they can be added to the
> tests.
>
> It's hard to write tests that depend on a given locale, however.  If
> anyone wants to try doing this in a fail-safe manner, maybe printing a
> message if the locale isn't available, please do.
>
> I didn't alter the documentation since it already seems intuitively
> obvious that truncation should work on displayed characters, not bytes.

I get both freezes and crashes with this code, I have a backtrace for
a crash at the end of the mail. for some reason,
/tmp/a/ちちちちちちちちちちちちちちちちちちちちちちちちちちちちち works fine while
/tmp/a/ちちちちちちちちちちちちちちちちちちちちちちちちちちちちちち crashes. The difference being
the one that crashes is one character longer. It also seems any name
shorter than that works fine, and the ones longer crash, but i can't
guarantee that. And yes, the short ones are still long enough to be
truncated and seem to be so correctly.
my PS1 is
PS1=$'%{\e[0m%}%{\e[1;32m%}{%{\e[0;32m%}%*%{\e[0;39m%}:%{\e[0;31m%}%40<...<%{\e[1;31m%}%~%<<%{\e[1;32m%}}%{\e[1;34m%}'$TTY:t$'%#
%(1j.%{\e[1;33m%}%j jobs .)%(?.%{\e[0m%}.%{\e[1;31;40m%}%?%{\e[0m%} )'



{22:08:55:/tmp/a}3% cd ちちちちちちちちちちちちちちちちちちちちちちちちちちちちちちちちちち
(gdb) bt full
#0  0x47586cd2 in free () from /lib/tls/libc.so.6
No symbol table info available.
#1  0x47588a3f in malloc () from /lib/tls/libc.so.6
No symbol table info available.
#2  0x0809f8b7 in zalloc (size=1197795360) at mem.c:568
	ptr = (void *) 0x4764cff4
#3  0xa7bb93b1 in zleread (lp=0x2ee5, rp=0x0, flags=1197795416,
context=1197795416)
    at zle_main.c:970
	s = (unsigned char *) 0x8101078 "å."
	old_errno = 2
	tmout = 0
	initthingy = 0x8101078
#4  0x0808a474 in inputline () at input.c:278
	flags = 1197795416
	ingetcline = 0x8101960 ""
	ingetcpmptl = (char **) 0x8101960
	ingetcpmptr = (char **) 0x4764e820
	context = 0
#5  0x0808aaba in ingetc () at input.c:214
	lastc = 0
#6  0x08080fe7 in ihgetc () at hist.c:240
	c = 0
#7  0x08096546 in gettok () at lex.c:628
	c = 1
	d = 1197795360
	peekfd = -1
	peek = 1197795416
#8  0x08098206 in yylex () at lex.c:344
No locals.
---Type <return> to continue, or q <return> to quit---
#9  0x080ba2ea in parse_event () at parse.c:451
No locals.
#10 0x0808730a in loop (toplevel=1, justonce=0) at init.c:128
	hstop = 0
	prog = 0x0
#11 0x0808a024 in zsh_main (argc=1, argv=0xaf8db524) at init.c:1312
	t = (char **) 0x64
	t0 = 1197795416
#12 0x08052aae in main (argc=1197795416, argv=0x4764e858) at main.c:93
No locals.

--
Mikael Magnusson


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