From: Phil Pennock <zsh-workers+phil.pennock@spodhuis.org>
To: Peter Stephenson <Peter.Stephenson@csr.com>
Cc: zsh-workers@zsh.org
Subject: Re: PATCH: PCRE support for embedded NUL characters
Date: Mon, 17 Sep 2012 15:04:23 -0400 [thread overview]
Message-ID: <20120917190422.GA41017@redoubt.spodhuis.org> (raw)
In-Reply-To: <20120917095727.23896b8b@pwslap01u.europe.root.pri>
On 2012-09-17 at 09:57 +0100, Peter Stephenson wrote:
> You can just do a pre-scan of the whole string for backslashes. If
> there's a backslash followed by a non-NULL, skip checking that next
> character (which may itself be a backslash that's escaped); if there's a
> backslash followed by a NULL the backslash can go. It's such an unusual
> case it hardly seems worth it, though.
I'm inclined to document it as a limitation, rather than add complexity,
wherein will lurk bugs.
> They are characters. If the string is unmetafied you can skip the
> MB_METACHARLEN() stuff and use the mbrtowc()/WCWIDTH() library calls
> directly (WCWIDTH() is only defined in order to be able to replace an
> unusable wcwidth()), but a null probably needs to be a special case
> since I think the libraries assume it's a terminator. It looks like the
> existing pattern code uses metafied strings.
Yeah, but correlating offsets in unmetafied strings to the metafied
strings for then counting is non-trivial (or so it seems to me).
And wcwidth() tells how many display cells are needed for a given
character, assuming a monospace layout. For this, instead, mblen() is
needed, on a character-by-character basis. Given that mblen() is C99, I
opted to avoid it, and implement this just for UTF-8 with bit-pattern
examination to quickly count past characters. We only initialise PCRE
for wide characters with UTF-8. I've no idea how much effort we want to
put into supporting non-UTF-8 wide-character PCRE across multiple OSes.
Thoughts?
(Code not finished yesterday, will be a little bit before I get back to
it).
-Phil
next prev parent reply other threads:[~2012-09-17 19:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-16 12:50 Phil Pennock
2012-09-17 5:59 ` Phil Pennock
2012-09-19 18:24 ` Peter Stephenson
2012-09-19 18:49 ` Phil Pennock
2012-09-17 8:57 ` Peter Stephenson
2012-09-17 19:04 ` Phil Pennock [this message]
2012-09-18 8:51 ` Peter Stephenson
2012-09-18 10:40 ` 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=20120917190422.GA41017@redoubt.spodhuis.org \
--to=zsh-workers+phil.pennock@spodhuis.org \
--cc=Peter.Stephenson@csr.com \
--cc=zsh-workers@zsh.org \
/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).