Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: PCRE support for embedded NUL characters
- X-seq: zsh-workers 30673
- From: Phil Pennock <zsh-workers+phil.pennock@xxxxxxxxxxxx>
- To: Peter Stephenson <Peter.Stephenson@xxxxxxx>
- Subject: Re: PATCH: PCRE support for embedded NUL characters
- Date: Mon, 17 Sep 2012 15:04:23 -0400
- Cc: zsh-workers@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=spodhuis.org; s=d201107; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=Is15KULo0ZdyvtvpXm9/m6lSXdFoVBfvi9CiXjnZJZU=; b=CJIBOgepw56FIMtmrVp+nxJLpzUsQvZJwKMqf7IKUSQKSbK92kuaE92zDAQd7xkkdnHpwMN4beP9twHqOj3PQl2X9rvubkIJ9TCWVqreiw9xK2LcSpbtLuPWwnG+dgl8tG07fVh30iGjhF110Z7kzgqt3vnpKqwPWYv6JNedZc0=;
- In-reply-to: <20120917095727.23896b8b@pwslap01u.europe.root.pri>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mail-followup-to: Peter Stephenson <Peter.Stephenson@xxxxxxx>, zsh-workers@xxxxxxx
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20120916125015.GA87764@redoubt.spodhuis.org> <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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author