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

Re: regex matching regression in 5.0.0 vs. 4.3.17



On 2012-09-15 at 20:42 +0100, Peter Stephenson wrote:
> So unless anyone can think of a smart solution, I think the only answer
> is to remove NULL characters from the body of the regular expression and
> document that this happens.

The situation sucks, clearly.

So: is it better to change the NUL to something else, to strip it out
(shortening the pattern) or to just document that NULs are bad?

For the POSIX system library regex module, a NUL will always be bad.

For PCRE, pcre_exec() takes a length parameter for the haystack string,
so one option might be to change the NUL in the _pattern_ to be \x00
instead?

It seems that for PCRE, supplying a length-receiving parameter to
unmetafy() and comparing that to strlen() should be right, and then
switching the result if so.

If I do this, then zsh/pcre should be able to handle NULs fine in both
needle/pattern and haystack.

For regex .. generally, I'm not in favour of hidden mutations of strings
which might change whether they match or not.  I can just document it as
a limitation of non-PCRE?

-Phil



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