Re: [pcre-dev] Recursion with possessive quantifiers

Kezdőlap
Üzenet törlése
Szerző: Herczeg Zoltán
Dátum:  
Címzett: pcre-dev
Tárgy: Re: [pcre-dev] Recursion with possessive quantifiers
Hey Naden,

PCRE just follows the PERL way (standard :P), but you should be a little more creative and easly avoid the problem:

rewrite (exp)*+ to ((((exp){0,10}+){0,10}+){0,10}+)*+ this way you can do thousands of matches with little stack usage.

Regards,
Zoltan

PS: Are you sure you can't change the stack size on Windows? There is a Visual C compiler option to change it as far as I remember.

ND <nadenj@???> írta:
>On Thu, 19 May 2011 20:25:27 +0400, Philip Hazel <ph10@???>>

wrote:>
>
> I continue to be amazed, in this day of gigabyte main memories, that>
> stack sizes are so restricted.>
>

I'm too. But it's a Windows way and I can't change it.>
>
> PCRE does support using the heap instead>
> of the stack if you compile with --disable-stack-for-recursion; this>
> feature was implemented specially for certain Windows users. However,>
> PCRE does run more slowly when it has, in effect, to manage its own>
> stack.>
>

Using the heap slows pcre_exec() by about 3-5 times. It is not an eligible>
choice.>
>

Anyway is true that problem is actual in both cases (with stack or heap>
usage):>
The memory really needed to match an expression with possessive quantifier >
is>
less than eats pcre_exec() in reality.>
Excessing memory amount is linearly proportional to number of>
consequent repetitions of this expression in subject string.>
There are subject strings when a repetitions number is huge.>
This deep recursion not only increases memory usage but decreases a >
potentional>
matching speed too.>
>
>
> When you process something like (?>(<EXPR>)*) ...>
>

Is there a possibility to not convert expression with possessive>
quantifiers to this form and write an effective handler?>
>

-- >
## List details at https://lists.exim.org/mailman/listinfo/pcre-dev >