Re: [pcre-dev] New API

Top Page
Delete this message
Author: Ralf Junker
Date:  
To: pcre-dev
Subject: Re: [pcre-dev] New API
On 13.01.2014 18:52, ph10@??? wrote:

> ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/Testing/PCRE2_proposal.pdf


Changes look good to me, just one though on this quote from above:

"Question: There have been requests for the pattern to be given as a
pointer and length, rather than a zero-terminated string. If that is
ever to be implemented, now is the time. A negative length could mean
zero-terminated. What do people think?"

Yes, I would appreciate to be able to specify the length!

SQLite uses a similar approach and extends it for optimization. Quoted
from http://www.sqlite.org/c3ref/prepare.html:

"If the nByte argument is less than zero, then zSql is read up to the
first zero terminator. If nByte is non-negative, then it is the
maximum number of bytes read from zSql. When nByte is non-negative,
the zSql string ends at either the first '\000' or '\u0000' character
or the nByte-th byte, whichever comes first. If the caller knows that
the supplied string is nul-terminated, then there is a small
performance advantage to be gained by passing an nByte parameter that
is equal to the number of bytes in the input string including the
nul-terminator bytes as this saves SQLite from having to make a copy
of the input string."

I am not sure if PCRE could benefit from this optimization, but if so,
it is worth considering.

Also, specifying the length, would potentially allow 0x00 values in
patterns. Not sure if you want to allow those, probably not.

Ralf