zsh-workers
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: Peter Stephenson <pws@csr.com>
Cc: Zsh hackers list <zsh-workers@sunsite.dk>
Subject: Re: PATCH: prompt truncation with multibyte characters
Date: Wed, 19 Oct 2005 22:15:40 +0200	[thread overview]
Message-ID: <237967ef0510191315i6eab176apdb8bb6c2cf050551@mail.gmail.com> (raw)
In-Reply-To: <200510190833.j9J8XuPX015440@news01.csr.com>

On 10/19/05, Peter Stephenson <pws@csr.com> 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

  reply	other threads:[~2005-10-19 20:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-19  8:33 Peter Stephenson
2005-10-19 20:15 ` Mikael Magnusson [this message]
2005-10-19 21:47   ` Mikael Magnusson
2005-10-19 21:53   ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=237967ef0510191315i6eab176apdb8bb6c2cf050551@mail.gmail.com \
    --to=mikachu@gmail.com \
    --cc=pws@csr.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).