Re: [pcre-dev] Problem with a regexp

Page principale
Supprimer ce message
Auteur: Thomas Weber
Date:  
À: pcre-dev
Sujet: Re: [pcre-dev] Problem with a regexp
On Fri, Sep 19, 2008 at 06:38:59PM +0100, Philip Hazel wrote:
> On Thu, 18 Sep 2008, Thomas Weber wrote:
>
> > So, would a feasible solution look like the following:
> >
> > 1) Try with the default values on MATCH_LIMIT. 
> > 2) If that fails, check with (the equivalent of) \M and use that value
> >    for a second calculation?

>
> That would work, I suppose. But it would be slow (\M works by trying and
> retrying). Much better if you can write the regex more efficiently in
> the first place (using a possessive quantifier when needed). :-)


The regexp is user-supplied, so I don't have much choice here :)

Anyway, I've now followed the above path with a modification: instead of
using "\M", I increase the MATCH_LIMIT by a factor of 10 in a
while-loop; it's still quite fast.

One question, though:
In the 7.8 release, line 107 in pcre_config. reads:

*((unsigned int *)where) = MATCH_LIMIT;

Shouldn't this be
*((unsigned long int *)where) = MATCH_LIMIT;


Regards
    Thomas