zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk
Subject: Re: mb_metacharlenconv vs. tokens
Date: Tue, 26 Sep 2006 10:20:04 +0100	[thread overview]
Message-ID: <200609260920.k8Q9K4wb026573@news01.csr.com> (raw)
In-Reply-To: <200609252146.00249.arvidjaar@newmail.ru>

Andrey Borzenkov wrote:
> Apparently mb_metacharlenconv gets passed tokenized string (how is it called
> properly in zsh lingua?) It means that the fact length(any-token-char) == 1
> is actually side effect of mbrtowc failing miserably and mb_metacharlenconv
> returning fallback 1 (at least using UTF-8).
> 
> Should not it untokenize character first? If yes, I will provide a fix as
>  part of larger patch; if no, I fail to see how it works then.

It's a bug if it's getting a tokenized character.  It should have been
untokenized at some point in the sequence leading to the call, since
mb_metacharlenconv() should already be dealing with a printable
string---by implication, we're looking at its width or length in
characters because we're about to do something to it which is
appropriate to a printable string.  However, this being zsh, the exact
point at which untokenization should be done is not necessarily obvious.
This is particularly true if we're using the string as a pattern.

I had a case like this in substitution recently:

2006-09-12  Peter Stephenson  <pws@csr.com>

	* 22689: Src/subst.c, Test/D04parameter.ztst: untokenize
	strings for substitution in cases like
	${${~:-*}//(#m)*/$MATCH=$MATCH}.  The pattern code tried
	to metafy the tokens, which caused chaos.

We're a victim of the fact that metafied strings are used both to
protect tokens and to protect embedded NULs; it tends to hide the logic
indicating that tokens are still around when they shouldn't be.

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


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php


  reply	other threads:[~2006-09-26 10:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-25 17:45 Andrey Borzenkov
2006-09-26  9:20 ` Peter Stephenson [this message]
2006-09-26 18:03   ` Andrey Borzenkov
2006-09-26 18:10     ` Peter Stephenson
2006-09-27 16:31       ` Andrey Borzenkov
2006-09-27 16:51         ` 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=200609260920.k8Q9K4wb026573@news01.csr.com \
    --to=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).