Re: [pcre-dev] Using JIT stacks for multiple patterns

Top Page
Delete this message
Author: Zoltán Herczeg
Date:  
To: Christoph Becker
CC: pcre-dev
Subject: Re: [pcre-dev] Using JIT stacks for multiple patterns
Hi Christoph,

>I'm having a single threaded application. How could it happen that
>patterns are not matched sequentially? AIUI, nested calls to
>pcre_exec() or pcre_jit_exec() would have to be made, which could only
>happen if this is done from a callback, such as the pcre_jit_callback
>passed to pcre_assign_jit_stack().


The JIT callback runs before the match starts, so you can even execute a pcre_exec() in the JIT callback without issues. I mean executing a pcre_exec with a given stack, and returning with it from the callback is ok.

However, PCRE has a callout feature, which allows suspending the matching process and calling an application provided C function:

http://linux.die.net/man/3/pcrecallout

This feature needs application support, otherwise it has the same effect as the /(?:)/ pattern. Script languages can even execute scripts here (callout with string argument is designed for that). This greatly extends the regular expression capabilities, but also allows nested (non-sequential) matching because the embedded script can start another match.

>Are there any other potential nested calls, or can I safely assume that
>*sequential* calls to pcre_(jit_)exec() are safe to use the same JIT stack?


Yes, you can safely use the same JIT stack as long as your application does not support callouts or does not allow nested matches from callouts.

I will extend the documentation with callouts to explain the "non-sequential" use.

Regards,
Zoltan