diff --git a/ChangeLog b/ChangeLog index 54c6e27..6915276 100644 --- a/ChangeLog +++ b/ChangeLog @@ -118,6 +118,9 @@ that it expects trusted data. 29. Fix typo in pcre2_jit_test.c +30. Due to an oversight, pcre2grep was not making use of JIT when available. +This is now fixed. + Version 10.21 12-January-2016 ----------------------------- diff --git a/src/pcre2grep.c b/src/pcre2grep.c index 47d2a4e..60b6812 100644 --- a/src/pcre2grep.c +++ b/src/pcre2grep.c @@ -2788,9 +2788,24 @@ if ((popts & PO_FIXED_STRINGS) != 0) sprintf((char *)buffer, "%s%.*s%s", prefix[popts], patlen, ps, suffix[popts]); p->compiled = pcre2_compile(buffer, -1, options, &errcode, &erroffset, compile_context); -if (p->compiled != NULL) return TRUE; + +/* Handle successful compile */ + +if (p->compiled != NULL) + { +#ifdef SUPPORT_PCRE2GREP_JIT + if (use_jit) + { + errcode = pcre2_jit_compile(p->compiled, PCRE2_JIT_COMPLETE); + if (errcode == 0) return TRUE; + erroffset = PCRE2_SIZE_MAX; /* Will get reduced to patlen below */ + } + else +#endif + return TRUE; + } -/* Handle compile errors */ +/* Handle compile and JIT compile errors */ erroffset -= (int)strlen(prefix[popts]); if (erroffset > patlen) erroffset = patlen;