Man, you've got to love edge cases
brong at fastmail.fm
Sat Jan 31 19:44:26 EST 2009
On Sun, Feb 01, 2009 at 01:47:37AM +1100, Bron Gondwana wrote:
> /* regexec() requires a NUL-terminated string */
> char *buf = (char *) xstrndup(text, tlen);
> int r = !regexec((regex_t *) pat, buf, 0, NULL, 0);
> return r;
It occurs to me that this can be a pretty large lump of memory
use if the message being delivered is big. What a pain.
int pcre_exec(const pcre *code, const pcre_extra *extra,
const char *subject, int length, int startoffset,
int options, int *ovector, int ovecsize);
Now - at FastMail we use PCRE, but we use the PCRE posix compatibility
layer, which doesn't provide a length-based interface.
int regexec(const regex_t *restrict preg, const char *restrict string,
size_t nmatch, regmatch_t pmatch[restrict], int eflags);
I think probably the best bet is to use conditional compilation here,
so people using PCRE don't pay the price of duplicating the entire
Does anybody know if the "rx" library has a length based interface?
Bron ( looks like rx is using a compatibility layer too )
More information about the Cyrus-devel