Changed jit_stack_alloc to jit_stack_create.

This commit is contained in:
Philip.Hazel 2014-11-03 17:13:00 +00:00
parent dea68c01fb
commit 08e3107cbe
37 changed files with 753 additions and 665 deletions

View File

@ -42,8 +42,8 @@ dist_html_DATA = \
doc/html/pcre2_jit_compile.html \
doc/html/pcre2_jit_free_unused_memory.html \
doc/html/pcre2_jit_match.html \
doc/html/pcre2_jit_stack_alloc.html \
doc/html/pcre2_jit_stack_assign.html \
doc/html/pcre2_jit_stack_create.html \
doc/html/pcre2_jit_stack_free.html \
doc/html/pcre2_maketables.html \
doc/html/pcre2_match.html \
@ -113,8 +113,8 @@ dist_man_MANS = \
doc/pcre2_jit_compile.3 \
doc/pcre2_jit_free_unused_memory.3 \
doc/pcre2_jit_match.3 \
doc/pcre2_jit_stack_alloc.3 \
doc/pcre2_jit_stack_assign.3 \
doc/pcre2_jit_stack_create.3 \
doc/pcre2_jit_stack_free.3 \
doc/pcre2_maketables.3 \
doc/pcre2_match.3 \

View File

@ -574,7 +574,7 @@ a list of tests.
The first two tests can always be run, as they expect only plain text strings
(not UTF) and make no use of Unicode properties. The first test file can be fed
directly into the perltest.pl script to check that Perl gives the same results.
directly into the perltest.sh script to check that Perl gives the same results.
The only difference you should see is in the first few lines, where the Perl
version is given instead of the PCRE2 version. The second set of tests check
auxiliary functions, error detection, and run-time flags that are specific to
@ -609,7 +609,7 @@ of the French locale have been encountered. The test passes if its output
matches any one of them.
The fourth and fifth tests check UTF and Unicode property support, the fourth
being compatible with the perltest.pl script, and the fifth checking
being compatible with the perltest.sh script, and the fifth checking
PCRE2-specific things.
The sixth and seventh tests check the pcre2_dfa_match() alternative matching
@ -781,7 +781,6 @@ The distribution should contain the files listed below.
doc/html/* HTML documentation
doc/pcre2.txt plain text version of the man pages
doc/pcre2test.txt plain text documentation of test program
doc/perltest.txt plain text documentation of Perl test program
install-sh a shell script for installing files
libpcre2-8.pc.in template for libpcre2-8.pc for pkg-config
libpcre2-16.pc.in template for libpcre2-16.pc for pkg-config
@ -791,7 +790,7 @@ The distribution should contain the files listed below.
missing ) common stub for a few missing GNU programs while
) installing, generated by automake
mkinstalldirs script for making install directories
perltest.pl Perl test program
perltest.sh Script for running a Perl test program
pcre2-config.in source of script which retains PCRE2 information
pcre2_jit_test.c test program for the JIT compiler
testdata/testinput* test data for main library tests
@ -829,4 +828,4 @@ The distribution should contain the files listed below.
Philip Hazel
Email local part: ph10
Email domain: cam.ac.uk
Last updated: 27 October 2014
Last updated: 25 October 2014

View File

@ -140,12 +140,12 @@ in the library.
<tr><td><a href="pcre2_jit_match.html">pcre2_jit_match</a></td>
<td>&nbsp;&nbsp;Fast path interface to JIT matching</td></tr>
<tr><td><a href="pcre2_jit_stack_alloc.html">pcre2_jit_stack_alloc</a></td>
<td>&nbsp;&nbsp;Create a stack for JIT matching</td></tr>
<tr><td><a href="pcre2_jit_stack_assign.html">pcre2_jit_stack_assign</a></td>
<td>&nbsp;&nbsp;Assign stack for JIT matching</td></tr>
<tr><td><a href="pcre2_jit_stack_create.html">pcre2_jit_stack_create</a></td>
<td>&nbsp;&nbsp;Create a stack for JIT matching</td></tr>
<tr><td><a href="pcre2_jit_stack_free.html">pcre2_jit_stack_free</a></td>
<td>&nbsp;&nbsp;Free a JIT matching stack</td></tr>
@ -162,7 +162,7 @@ in the library.
<tr><td><a href="pcre2_match_context_create.html">pcre2_match_context_create</a></td>
<td>&nbsp;&nbsp;Create a match context</td></tr>
<tr><td><a href="pcre2_match_context_free.html">pcre2_match_contest_free</a></td>
<tr><td><a href="pcre2_match_context_free.html">pcre2_match_context_free</a></td>
<td>&nbsp;&nbsp;Free a match context</td></tr>
<tr><td><a href="pcre2_match_data_create.html">pcre2_match_data_create</a></td>

View File

@ -27,9 +27,11 @@ DESCRIPTION
<P>
After a successful call of <b>pcre2_match()</b> that was passed the match block
that is this function's argument, this function returns the code unit offset of
the character at which the successful match started. This can be different to
the value of <i>ovector[0]</i> if the pattern contains the \K escape sequence.
Note, however, that \K has no effect for a partial match.
the character at which the successful match started. For a non-partial match,
this can be different to the value of <i>ovector[0]</i> if the pattern contains
the \K escape sequence. After a partial match, however, this value is always
the same as <i>ovector[0]</i> because \K does not affect the result of a
partial match.
</P>
<P>
There is a complete description of the PCRE2 native API in the

View File

@ -27,7 +27,10 @@ DESCRIPTION
<P>
This function frees unused JIT executable memory. The argument is a general
context, for custom memory management, or NULL for standard memory management.
FIXME: more detail needed.
JIT memory allocation retains some memory in order to improve future JIT
compilation speed. In low memory conditions,
\fBpcre2_jit_free_unused_memory()\fB can be used to cause this memory to be
freed.
</P>
<P>
There is a complete description of the PCRE2 native API in the

View File

@ -36,7 +36,7 @@ Its arguments are exactly the same as for
<a href="pcre2_match.html"><b>pcre2_match()</b></a>
plus one additional argument that must either point to a JIT stack or be NULL.
In the latter case, if a callback function has been set up by
<b>pcre2_jit_stack_alloc()</b>, it is called. Otherwise the system stack is
<b>pcre2_jit_stack_create()</b>, it is called. Otherwise the system stack is
used.
</P>
<P>

View File

@ -42,13 +42,13 @@ block on the machine stack is used.
<P>
If <i>callback</i> is NULL and <i>callback_data</i> is not NULL,
<i>callback_data</i> must be a valid JIT stack, the result of calling
<b>pcre2_jit_stack_alloc()</b>.
<b>pcre2_jit_stack_create()</b>.
</P>
<P>
If <i>callback</i> not NULL, it is called with <i>callback_data</i> as an
argument at the start of matching, in order to set up a JIT stack. If the
result is NULL, the internal 32K stack is used; otherwise the return value must
be a valid JIT stack, the result of calling <b>pcre2_jit_stack_alloc()</b>.
be a valid JIT stack, the result of calling <b>pcre2_jit_stack_create()</b>.
</P>
<P>
You may safely assign the same JIT stack to multiple patterns, as long as they

View File

@ -1,9 +1,9 @@
<html>
<head>
<title>pcre2_jit_stack_alloc specification</title>
<title>pcre2_jit_stack_create specification</title>
</head>
<body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
<h1>pcre2_jit_stack_alloc man page</h1>
<h1>pcre2_jit_stack_create man page</h1>
<p>
Return to the <a href="index.html">PCRE2 index page</a>.
</p>
@ -19,7 +19,7 @@ SYNOPSIS
<b>#include &#60;pcre2.h&#62;</b>
</P>
<P>
<b>pcre2_jit_stack *pcre2_jit_stack_alloc(pcre2_general_context *<i>gcontext</i>,</b>
<b>pcre2_jit_stack *pcre2_jit_stack_create(pcre2_general_context *<i>gcontext</i>,</b>
<b> PCRE2_SIZE <i>startsize</i>, PCRE2_SIZE <i>maxsize</i>);</b>
</P>
<br><b>

View File

@ -26,7 +26,7 @@ DESCRIPTION
</b><br>
<P>
This function is used to free a JIT stack that was created by
<b>pcre2_jit_stack_alloc()</b> when it is no longer needed. For more details,
<b>pcre2_jit_stack_create()</b> when it is no longer needed. For more details,
see the
<a href="pcre2jit.html"><b>pcre2jit</b></a>
page.

View File

@ -27,16 +27,17 @@ DESCRIPTION
</b><br>
<P>
This convenience function finds the number of a named substring capturing
parenthesis in a compiled pattern. Its arguments are:
parenthesis in a compiled pattern, provided that it is a unique name. The
function arguments are:
<pre>
<i>code</i> Compiled regular expression
<i>name</i> Name whose number is required
</pre>
The yield of the function is the number of the parenthesis if the name is
found, or PCRE2_ERROR_NOSUBSTRING otherwise. When duplicate names are allowed
(PCRE2_DUPNAMES is set), it is not defined which of the numbers is returned.
You can obtain the complete list by calling
<b>pcre2_substring_nametable_scan()</b>.
found, or PCRE2_ERROR_NOSUBSTRING if it is not found. When duplicate names are
allowed (PCRE2_DUPNAMES is set), if the name is not unique,
PCRE2_ERROR_NOUNIQUESUBSTRING is returned. You can obtain the list of numbers
with the same name by calling <b>pcre2_substring_nametable_scan()</b>.
</P>
<P>
There is a complete description of the PCRE2 native API in the

View File

@ -236,7 +236,7 @@ document for an overview of all the PCRE2 documentation.
<b>void pcre2_jit_free_unused_memory(pcre2_general_context *<i>gcontext</i>);</b>
<br>
<br>
<b>pcre2_jit_stack *pcre2_jit_stack_alloc(pcre2_general_context *<i>gcontext</i>,</b>
<b>pcre2_jit_stack *pcre2_jit_stack_create(pcre2_general_context *<i>gcontext</i>,</b>
<b> PCRE2_SIZE <i>startsize</i>, PCRE2_SIZE <i>maxsize</i>);</b>
<br>
<br>
@ -363,7 +363,7 @@ support is not available.
</P>
<P>
More complicated programs might need to make use of the specialist functions
<b>pcre2_jit_stack_alloc()</b>, <b>pcre2_jit_stack_free()</b>, and
<b>pcre2_jit_stack_create()</b>, <b>pcre2_jit_stack_free()</b>, and
<b>pcre2_jit_stack_assign()</b> in order to control the JIT code's memory usage.
</P>
<P>
@ -1272,7 +1272,7 @@ textual error message from any error code.
<b>void pcre2_jit_free_unused_memory(pcre2_general_context *<i>gcontext</i>);</b>
<br>
<br>
<b>pcre2_jit_stack *pcre2_jit_stack_alloc(pcre2_general_context *<i>gcontext</i>,</b>
<b>pcre2_jit_stack *pcre2_jit_stack_create(pcre2_general_context *<i>gcontext</i>,</b>
<b> PCRE2_SIZE <i>startsize</i>, PCRE2_SIZE <i>maxsize</i>);</b>
<br>
<br>
@ -2050,10 +2050,11 @@ Otherwise NULL is returned. A (*MARK) name may be available after a failed
match or a partial match, as well as after a successful one.
</P>
<P>
The offset of the character at which the successful match started is
returned by <b>pcre2_get_startchar()</b>. This can be different to the value of
<i>ovector[0]</i> if the pattern contains the \K escape sequence. Note,
however, that \K has no effect for a partial match.
The code unit offset of the character at which a successful match started is
returned by <b>pcre2_get_startchar()</b>. For a non-partial match, this can be
different to the value of <i>ovector[0]</i> if the pattern contains the \K
escape sequence. After a partial match, however, this value is always the same
as <i>ovector[0]</i> because \K does not affect the result of a partial match.
<a name="errorlist"></a></P>
<br><b>
Error return values from <b>pcre2_match()</b>
@ -2302,8 +2303,9 @@ the number of the subpattern called "xxx" is 2. If the name is known to be
unique (PCRE2_DUPNAMES was not set), you can find the number from the name by
calling <b>pcre2_substring_number_from_name()</b>. The first argument is the
compiled pattern, and the second is the name. The yield of the function is the
subpattern number, or PCRE2_ERROR_NOSUBSTRING if there is no subpattern of that
name.
subpattern number, PCRE2_ERROR_NOSUBSTRING if there is no subpattern of that
name, or PCRE2_ERROR_NOUNIQUESUBSTRING if there is more than one subpattern of
that name.
</P>
<P>
Given the number, you can extract the substring directly, or use one of the
@ -2577,7 +2579,7 @@ Cambridge CB2 3QH, England.
</P>
<br><a name="SEC32" href="#TOC1">REVISION</a><br>
<P>
Last updated: 16 October 2014
Last updated: 03 November 2014
<br>
Copyright &copy; 1997-2014 University of Cambridge.
<br>

View File

@ -20,17 +20,15 @@ please consult the man page, in case the conversion went wrong.
<li><a name="TOC5" href="#SEC5">RETURN VALUES FROM JIT MATCHING</a>
<li><a name="TOC6" href="#SEC6">CONTROLLING THE JIT STACK</a>
<li><a name="TOC7" href="#SEC7">JIT STACK FAQ</a>
<li><a name="TOC8" href="#SEC8">EXAMPLE CODE</a>
<li><a name="TOC9" href="#SEC9">JIT FAST PATH API</a>
<li><a name="TOC10" href="#SEC10">SEE ALSO</a>
<li><a name="TOC11" href="#SEC11">AUTHOR</a>
<li><a name="TOC12" href="#SEC12">REVISION</a>
<li><a name="TOC8" href="#SEC8">FREEING JIT SPECULATIVE MEMORY</a>
<li><a name="TOC9" href="#SEC9">EXAMPLE CODE</a>
<li><a name="TOC10" href="#SEC10">JIT FAST PATH API</a>
<li><a name="TOC11" href="#SEC11">SEE ALSO</a>
<li><a name="TOC12" href="#SEC12">AUTHOR</a>
<li><a name="TOC13" href="#SEC13">REVISION</a>
</ul>
<br><a name="SEC1" href="#TOC1">PCRE2 JUST-IN-TIME COMPILER SUPPORT</a><br>
<P>
FIXME: This needs checking over once JIT support is implemented.
</P>
<P>
Just-in-time compiling is a heavyweight optimization that can greatly speed up
pattern matching. However, it comes at the cost of extra processing before the
match is performed. Therefore, it is of most benefit when the same pattern is
@ -79,9 +77,12 @@ second is a set of option bits, which must include at least one of
PCRE2_JIT_COMPLETE, PCRE2_JIT_PARTIAL_HARD, or PCRE2_JIT_PARTIAL_SOFT.
</P>
<P>
The returned value from <b>pcre2_jit_compile()</b> is zero on success, or a
negative error code. In particular, PCRE2_ERROR_JIT_BADOPTION is returned if
JIT is not supported or if an unknown options bit is set.
If JIT support is not available, a call to <b>pcre2_jit_comple()</b> does
nothing and returns PCRE2_ERROR_JIT_BADOPTION. Otherwise, the compiled pattern
is passed to the JIT compiler, which turns it into machine code that executes
much faster than the normal interpretive code, but yields exactly the same
results. The returned value from <b>pcre2_jit_compile()</b> is zero on success,
or a negative error code.
</P>
<P>
PCRE2_JIT_COMPLETE requests the JIT compiler to generate code for complete
@ -100,12 +101,6 @@ described in the section entitled
below.
</P>
<P>
If JIT support is not available, a call to <b>pcre2_jit_comple()</b> does
nothing and returns FIXME. Otherwise, the compiled pattern is passed to the JIT
compiler, which turns it into machine code that executes much faster than the
normal interpretive code, but yields exactly the same results.
</P>
<P>
There are some <b>pcre2_match()</b> options that are not supported by JIT, and
there are also some pattern items that JIT cannot handle. Details are given
below. In both cases, matching automatically falls back to the interpretive
@ -166,7 +161,7 @@ about the use of JIT stacks in the section entitled
below.
</P>
<P>
The <b>pcre2_jit_stack_alloc()</b> function creates a JIT stack. Its arguments
The <b>pcre2_jit_stack_create()</b> function creates a JIT stack. Its arguments
are a general context (for memory allocation functions, or NULL for standard
memory allocation), a starting size and a maximum size, and it returns a
pointer to an opaque structure of type <b>pcre2_jit_stack</b>, or NULL if there
@ -195,14 +190,14 @@ the other two options:
on the machine stack is used.
(2) If <i>callback</i> is NULL and <i>data</i> is not NULL, <i>data</i> must be
a valid JIT stack, the result of calling <b>pcre2_jit_stack_alloc()</b>.
a valid JIT stack, the result of calling <b>pcre2_jit_stack_create()</b>.
(3) If <i>callback</i> is not NULL, it must point to a function that is
called with <i>data</i> as an argument at the start of matching, in
order to set up a JIT stack. If the return from the callback
function is NULL, the internal 32K stack is used; otherwise the
return value must be a valid JIT stack, the result of calling
<b>pcre2_jit_stack_alloc()</b>.
<b>pcre2_jit_stack_create()</b>.
</pre>
A callback function is obeyed whenever JIT code is about to be run; it is not
obeyed when <b>pcre2_match()</b> is called with options that are incompatible
@ -231,7 +226,7 @@ This is a suggestion for how a multithreaded program that needs to set up
non-default JIT stacks might operate:
<pre>
During thread initalization
thread_local_var = pcre2_jit_stack_alloc(...)
thread_local_var = pcre2_jit_stack_create(...)
During thread exit
pcre2_jit_stack_free(thread_local_var)
@ -323,7 +318,19 @@ stack handling?
No, thanks to Windows. If POSIX threads were used everywhere, we could throw
out this complicated API.
</P>
<br><a name="SEC8" href="#TOC1">EXAMPLE CODE</a><br>
<br><a name="SEC8" href="#TOC1">FREEING JIT SPECULATIVE MEMORY</a><br>
<P>
<b>void pcre2_jit_free_unused_memory(pcre2_general_context *<i>gcontext</i>);</b>
</P>
<P>
The JIT executable allocator does not free all memory when it is possible.
It expects new allocations, and keeps some free memory around to improve
allocation speed. However, in low memory conditions, it might be better to free
all possible memory. You can cause this to happen by calling
pcre2_jit_free_unused_memory(). Its argument is a general context, for custom
memory management, or NULL for standard memory management.
</P>
<br><a name="SEC9" href="#TOC1">EXAMPLE CODE</a><br>
<P>
This is a single-threaded example that specifies a JIT stack without using a
callback.
@ -338,7 +345,7 @@ callback.
/* Check for errors */
rc = pcre2_jit_compile(re, PCRE2_JIT_COMPLETE);
/* Check for errors */
jit_stack = pcre2_jit_stack_alloc(NULL, 32*1024, 512*1024);
jit_stack = pcre2_jit_stack_create(NULL, 32*1024, 512*1024);
/* Check for error (NULL) */
pcre2_jit_stack_assign(re, NULL, jit_stack);
match_data = pcre2_match_data_create(re, 10);
@ -349,7 +356,7 @@ callback.
</PRE>
</P>
<br><a name="SEC9" href="#TOC1">JIT FAST PATH API</a><br>
<br><a name="SEC10" href="#TOC1">JIT FAST PATH API</a><br>
<P>
Because the API described above falls back to interpreted matching when JIT is
not available, it is convenient for programs that are written for general use
@ -364,11 +371,11 @@ processed by <b>pcre2_jit_compile()</b>).
The fast path function is called <b>pcre2_jit_match()</b>, and it takes exactly
the same arguments as <b>pcre2_match()</b>, plus one additional argument that
must either point to a JIT stack or be NULL. In the latter case, if a callback
function has been set up by <b>pcre2_jit_stack_alloc()</b>, it is called.
function has been set up by <b>pcre2_jit_stack_assign()</b>, it is called.
Otherwise the system stack is used. The return values are the same as for
<b>pcre2_match()</b>, plus PCRE2_ERROR_JIT_BADOPTION if a matching mode (partial
or complete) is requested that was not compiled. Unsupported option bits are
ignored.
or complete) is requested that was not compiled. Unsupported option bits (for
example, PCRE2_ANCHORED) are ignored.
</P>
<P>
When you call <b>pcre2_match()</b>, as well as testing for invalid options, a
@ -382,11 +389,11 @@ invalid data is passed, the result is undefined.
Bypassing the sanity checks and the <b>pcre2_match()</b> wrapping can give
speedups of more than 10%.
</P>
<br><a name="SEC10" href="#TOC1">SEE ALSO</a><br>
<br><a name="SEC11" href="#TOC1">SEE ALSO</a><br>
<P>
<b>pcre2api</b>(3)
</P>
<br><a name="SEC11" href="#TOC1">AUTHOR</a><br>
<br><a name="SEC12" href="#TOC1">AUTHOR</a><br>
<P>
Philip Hazel (FAQ by Zoltan Herczeg)
<br>
@ -395,9 +402,9 @@ University Computing Service
Cambridge CB2 3QH, England.
<br>
</P>
<br><a name="SEC12" href="#TOC1">REVISION</a><br>
<br><a name="SEC13" href="#TOC1">REVISION</a><br>
<P>
Last updated: 21 October 2014
Last updated: 03 November 2014
<br>
Copyright &copy; 1997-2014 University of Cambridge.
<br>

View File

@ -223,10 +223,12 @@ Output the PCRE2 version number and then exit.
<br><a name="SEC5" href="#TOC1">DESCRIPTION</a><br>
<P>
If <b>pcre2test</b> is given two filename arguments, it reads from the first and
writes to the second. If it is given only one filename argument, it reads from
writes to the second. If the first name is "-", input is taken from the
standard input. If <b>pcre2test</b> is given only one argument, it reads from
that file and writes to stdout. Otherwise, it reads from stdin and writes to
stdout, and prompts for each line of input, using "re&#62;" to prompt for regular
expression patterns, and "data&#62;" to prompt for subject lines.
stdout. When the input is a terminal, it prompts for each line of input, using
"re&#62;" to prompt for regular expression patterns, and "data&#62;" to prompt for
subject lines.
</P>
<P>
When <b>pcre2test</b> is built, a configuration option can specify that it
@ -476,6 +478,7 @@ about the pattern:
/I info show info about compiled pattern
hex pattern is coded in hexadecimal
jit[=&#60;number&#62;] use JIT
jitfast use JIT fast path
jitverify verify JIT use
locale=&#60;name&#62; use this locale
memory show memory used
@ -573,6 +576,13 @@ documentation. See also the <b>jitstack</b> modifier below for a way of
setting the size of the JIT stack.
</P>
<P>
If the <b>jitfast</b> modifier is specified, matching is done using the JIT
"fast path" interface (\fBpcre2_jit_match()), which skips some of the sanity
checks that are done by <b>pcre2_match()</b>, and of course does not work when
JIT is not supported. If <b>jitfast</b> is specified without <b>jit</b>, jit=7 is
assumed.
</P>
<P>
If the <b>jitverify</b> modifier is specified, information about the compiled
pattern shows whether JIT compilation was or was not successful. If
<b>jitverify</b> is specified without <b>jit</b>, jit=7 is assumed. If JIT
@ -612,6 +622,9 @@ Limiting nested parentheses
<P>
The <b>parens_nest_limit</b> modifier sets a limit on the depth of nested
parentheses in a pattern. Breaching the limit causes a compilation error.
The default for the library is set when PCRE2 is built, but <b>pcre2test</b>
sets its own default of 220, which is required for running the standard test
suite.
</P>
<br><b>
Using the POSIX wrapper API
@ -681,6 +694,7 @@ not affect the compilation process.
allusedtext show all consulted text
/g global global matching
mark show mark values
startchar show starting character when relevant
</pre>
These modifiers may not appear in a <b>#pattern</b> command. If you want them as
defaults, set them in a <b>#subject</b> command.
@ -751,6 +765,7 @@ pattern.
offset=&#60;n&#62; set starting offset
ovector=&#60;n&#62; set size of output vector
recursion_limit=&#60;n&#62; set a recursion limit
startchar show startchar when relevant
</pre>
The effects of these modifiers are described in the following sections.
FIXME: Give more examples.
@ -777,14 +792,30 @@ there is a lookbehind at the start of a match, or a lookahead at the end, or if
of the actual match are indicated in the output by '&#60;' or '&#62;' characters
underneath them. Here is an example:
<pre>
/(?&#60;=pqr)abc(?=xyz)/
123pqrabcxyz456\=allusedtext
re&#62; /(?&#60;=pqr)abc(?=xyz)/
data&#62; 123pqrabcxyz456\=allusedtext
0: pqrabcxyz
&#60;&#60;&#60; &#62;&#62;&#62;
</pre>
This shows that the matched string is "abc", with the preceding and following
strings "pqr" and "xyz" also consulted during the match.
</P>
<P>
The <b>startchar</b> modifier requests that the starting character for the match
be indicated, if it is different to the start of the matched string. The only
time when this occurs is when \K has been processed as part of the match. In
this situation, the output for the matched string is displayed from the
starting character instead of from the match point, with circumflex characters
under the earlier characters. For example:
<pre>
re&#62; /abc\Kxyz/
data&#62; abcxyz\=startchar
0: abcxyz
^^^
</pre>
Unlike <b>allusedtext</b>, the <b>startchar</b> modifier can be used with JIT.
However, these two modifiers are mutually exclusive.
</P>
<br><b>
Showing the value of all capture groups
</b><br>
@ -870,8 +901,9 @@ Setting the JIT stack size
<P>
The <b>jitstack</b> modifier provides a way of setting the maximum stack size
that is used by the just-in-time optimization code. It is ignored if JIT
optimization is not being used. Providing a stack that is larger than the
default 32K is necessary only for very complicated patterns.
optimization is not being used. The value is a number of kilobytes. Providing a
stack that is larger than the default 32K is necessary only for very
complicated patterns.
</P>
<br><b>
Setting match and recursion limits
@ -939,11 +971,13 @@ appears, though of course it can also be used to set a default in a
available for storing matching information. The default is 15.
</P>
<P>
At least one pair of offsets is always created by
<b>pcre2_match_data_create()</b>, for matching with PCRE2's native API, so a
value of 0 is the same as 1. However a value of 0 is useful when testing the
POSIX API because it causes <b>regexec()</b> to be called with a NULL capture
vector.
A value of zero is useful when testing the POSIX API because it causes
<b>regexec()</b> to be called with a NULL capture vector. When not testing the
POSIX API, a value of zero is used to cause
<b>pcre2_match_data_create_from_pattern</b> to be called, in order to create a
match block of exactly the right size for the pattern. (It is not possible to
create a match block with a zero-length ovector; there is always one pair of
offsets.)
</P>
<br><a name="SEC12" href="#TOC1">THE ALTERNATIVE MATCHING FUNCTION</a><br>
<P>
@ -1175,10 +1209,9 @@ characters.
</P>
<br><a name="SEC18" href="#TOC1">SEE ALSO</a><br>
<P>
<b>pcre2</b>(3), <b>pcre16</b>(3), <b>pcre32</b>(3), <b>pcre2api</b>(3),
<b>pcre2callout</b>(3),
<b>pcre2</b>(3), <b>pcre2api</b>(3), <b>pcre2callout</b>(3),
<b>pcre2jit</b>, <b>pcre2matching</b>(3), <b>pcre2partial</b>(d),
<b>pcre2pattern</b>(3), <b>pcre2precompile</b>(3).
<b>pcre2pattern</b>(3).
</P>
<br><a name="SEC19" href="#TOC1">AUTHOR</a><br>
<P>
@ -1191,7 +1224,7 @@ Cambridge CB2 3QH, England.
</P>
<br><a name="SEC20" href="#TOC1">REVISION</a><br>
<P>
Last updated: 11 October 2014
Last updated: 02 November 2014
<br>
Copyright &copy; 1997-2014 University of Cambridge.
<br>

View File

@ -140,12 +140,12 @@ in the library.
<tr><td><a href="pcre2_jit_match.html">pcre2_jit_match</a></td>
<td>&nbsp;&nbsp;Fast path interface to JIT matching</td></tr>
<tr><td><a href="pcre2_jit_stack_alloc.html">pcre2_jit_stack_alloc</a></td>
<td>&nbsp;&nbsp;Create a stack for JIT matching</td></tr>
<tr><td><a href="pcre2_jit_stack_assign.html">pcre2_jit_stack_assign</a></td>
<td>&nbsp;&nbsp;Assign stack for JIT matching</td></tr>
<tr><td><a href="pcre2_jit_stack_create.html">pcre2_jit_stack_create</a></td>
<td>&nbsp;&nbsp;Create a stack for JIT matching</td></tr>
<tr><td><a href="pcre2_jit_stack_free.html">pcre2_jit_stack_free</a></td>
<td>&nbsp;&nbsp;Free a JIT matching stack</td></tr>

View File

@ -324,7 +324,7 @@ PCRE2 NATIVE API JIT FUNCTIONS
void pcre2_jit_free_unused_memory(pcre2_general_context *gcontext);
pcre2_jit_stack *pcre2_jit_stack_alloc(pcre2_general_context *gcontext,
pcre2_jit_stack *pcre2_jit_stack_create(pcre2_general_context *gcontext,
PCRE2_SIZE startsize, PCRE2_SIZE maxsize);
void pcre2_jit_stack_assign(const pcre2_code *code,
@ -437,7 +437,7 @@ PCRE2 API OVERVIEW
support is not available.
More complicated programs might need to make use of the specialist
functions pcre2_jit_stack_alloc(), pcre2_jit_stack_free(), and
functions pcre2_jit_stack_create(), pcre2_jit_stack_free(), and
pcre2_jit_stack_assign() in order to control the JIT code's memory
usage.
@ -1303,7 +1303,7 @@ JUST-IN-TIME (JIT) COMPILATION
void pcre2_jit_free_unused_memory(pcre2_general_context *gcontext);
pcre2_jit_stack *pcre2_jit_stack_alloc(pcre2_general_context *gcontext,
pcre2_jit_stack *pcre2_jit_stack_create(pcre2_general_context *gcontext,
PCRE2_SIZE startsize, PCRE2_SIZE maxsize);
void pcre2_jit_stack_assign(const pcre2_code *code,
@ -2034,10 +2034,12 @@ HOW PCRE2_MATCH() RETURNS A STRING AND CAPTURED SUBSTRINGS
after a failed match or a partial match, as well as after a successful
one.
The offset of the character at which the successful match started is
returned by pcre2_get_startchar(). This can be different to the value
of ovector[0] if the pattern contains the \K escape sequence. Note,
however, that \K has no effect for a partial match.
The code unit offset of the character at which a successful match
started is returned by pcre2_get_startchar(). For a non-partial match,
this can be different to the value of ovector[0] if the pattern con-
tains the \K escape sequence. After a partial match, however, this
value is always the same as ovector[0] because \K does not affect the
result of a partial match.
Error return values from pcre2_match()
@ -2266,8 +2268,9 @@ EXTRACTING CAPTURED SUBSTRINGS BY NAME
be unique (PCRE2_DUPNAMES was not set), you can find the number from
the name by calling pcre2_substring_number_from_name(). The first argu-
ment is the compiled pattern, and the second is the name. The yield of
the function is the subpattern number, or PCRE2_ERROR_NOSUBSTRING if
there is no subpattern of that name.
the function is the subpattern number, PCRE2_ERROR_NOSUBSTRING if there
is no subpattern of that name, or PCRE2_ERROR_NOUNIQUESUBSTRING if
there is more than one subpattern of that name.
Given the number, you can extract the substring directly, or use one of
the functions described in the previous section. For convenience, there
@ -2523,7 +2526,7 @@ AUTHOR
REVISION
Last updated: 16 October 2014
Last updated: 03 November 2014
Copyright (c) 1997-2014 University of Cambridge.
------------------------------------------------------------------------------
@ -3411,8 +3414,6 @@ NAME
PCRE2 JUST-IN-TIME COMPILER SUPPORT
FIXME: This needs checking over once JIT support is implemented.
Just-in-time compiling is a heavyweight optimization that can greatly
speed up pattern matching. However, it comes at the cost of extra pro-
cessing before the match is performed. Therefore, it is of most benefit
@ -3462,9 +3463,12 @@ SIMPLE USE OF JIT
second is a set of option bits, which must include at least one of
PCRE2_JIT_COMPLETE, PCRE2_JIT_PARTIAL_HARD, or PCRE2_JIT_PARTIAL_SOFT.
The returned value from pcre2_jit_compile() is zero on success, or a
negative error code. In particular, PCRE2_ERROR_JIT_BADOPTION is
returned if JIT is not supported or if an unknown options bit is set.
If JIT support is not available, a call to pcre2_jit_comple() does
nothing and returns PCRE2_ERROR_JIT_BADOPTION. Otherwise, the compiled
pattern is passed to the JIT compiler, which turns it into machine code
that executes much faster than the normal interpretive code, but yields
exactly the same results. The returned value from pcre2_jit_compile()
is zero on success, or a negative error code.
PCRE2_JIT_COMPLETE requests the JIT compiler to generate code for com-
plete matches. If you want to run partial matches using the PCRE2_PAR-
@ -3479,12 +3483,6 @@ SIMPLE USE OF JIT
are described in the section entitled "Controlling the JIT stack"
below.
If JIT support is not available, a call to pcre2_jit_comple() does
nothing and returns FIXME. Otherwise, the compiled pattern is passed to
the JIT compiler, which turns it into machine code that executes much
faster than the normal interpretive code, but yields exactly the same
results.
There are some pcre2_match() options that are not supported by JIT, and
there are also some pattern items that JIT cannot handle. Details are
given below. In both cases, matching automatically falls back to the
@ -3542,14 +3540,14 @@ CONTROLLING THE JIT STACK
JIT stacks. There is further discussion about the use of JIT stacks in
the section entitled "JIT stack FAQ" below.
The pcre2_jit_stack_alloc() function creates a JIT stack. Its arguments
are a general context (for memory allocation functions, or NULL for
standard memory allocation), a starting size and a maximum size, and it
returns a pointer to an opaque structure of type pcre2_jit_stack, or
NULL if there is an error. The pcre2_jit_stack_free() function is used
to free a stack that is no longer needed. (For the technically minded:
the address space is allocated by mmap or VirtualAlloc.) FIXME Is this
right?
The pcre2_jit_stack_create() function creates a JIT stack. Its argu-
ments are a general context (for memory allocation functions, or NULL
for standard memory allocation), a starting size and a maximum size,
and it returns a pointer to an opaque structure of type
pcre2_jit_stack, or NULL if there is an error. The
pcre2_jit_stack_free() function is used to free a stack that is no
longer needed. (For the technically minded: the address space is allo-
cated by mmap or VirtualAlloc.) FIXME Is this right?
JIT uses far less memory for recursion than the interpretive code, and
a maximum stack size of 512K to 1M should be more than enough for any
@ -3570,14 +3568,15 @@ CONTROLLING THE JIT STACK
on the machine stack is used.
(2) If callback is NULL and data is not NULL, data must be
a valid JIT stack, the result of calling pcre2_jit_stack_alloc().
a valid JIT stack, the result of calling pcre2_jit_stack_cre-
ate().
(3) If callback is not NULL, it must point to a function that is
called with data as an argument at the start of matching, in
order to set up a JIT stack. If the return from the callback
function is NULL, the internal 32K stack is used; otherwise the
return value must be a valid JIT stack, the result of calling
pcre2_jit_stack_alloc().
pcre2_jit_stack_create().
A callback function is obeyed whenever JIT code is about to be run; it
is not obeyed when pcre2_match() is called with options that are incom-
@ -3605,7 +3604,7 @@ CONTROLLING THE JIT STACK
up non-default JIT stacks might operate:
During thread initalization
thread_local_var = pcre2_jit_stack_alloc(...)
thread_local_var = pcre2_jit_stack_create(...)
During thread exit
pcre2_jit_stack_free(thread_local_var)
@ -3687,6 +3686,19 @@ JIT STACK FAQ
throw out this complicated API.
FREEING JIT SPECULATIVE MEMORY
void pcre2_jit_free_unused_memory(pcre2_general_context *gcontext);
The JIT executable allocator does not free all memory when it is possi-
ble. It expects new allocations, and keeps some free memory around to
improve allocation speed. However, in low memory conditions, it might
be better to free all possible memory. You can cause this to happen by
calling pcre2_jit_free_unused_memory(). Its argument is a general con-
text, for custom memory management, or NULL for standard memory manage-
ment.
EXAMPLE CODE
This is a single-threaded example that specifies a JIT stack without
@ -3702,7 +3714,7 @@ EXAMPLE CODE
/* Check for errors */
rc = pcre2_jit_compile(re, PCRE2_JIT_COMPLETE);
/* Check for errors */
jit_stack = pcre2_jit_stack_alloc(NULL, 32*1024, 512*1024);
jit_stack = pcre2_jit_stack_create(NULL, 32*1024, 512*1024);
/* Check for error (NULL) */
pcre2_jit_stack_assign(re, NULL, jit_stack);
match_data = pcre2_match_data_create(re, 10);
@ -3727,10 +3739,11 @@ JIT FAST PATH API
exactly the same arguments as pcre2_match(), plus one additional argu-
ment that must either point to a JIT stack or be NULL. In the latter
case, if a callback function has been set up by
pcre2_jit_stack_alloc(), it is called. Otherwise the system stack is
pcre2_jit_stack_assign(), it is called. Otherwise the system stack is
used. The return values are the same as for pcre2_match(), plus
PCRE2_ERROR_JIT_BADOPTION if a matching mode (partial or complete) is
requested that was not compiled. Unsupported option bits are ignored.
requested that was not compiled. Unsupported option bits (for example,
PCRE2_ANCHORED) are ignored.
When you call pcre2_match(), as well as testing for invalid options, a
number of other sanity checks are performed on the arguments. For exam-
@ -3757,7 +3770,7 @@ AUTHOR
REVISION
Last updated: 21 October 2014
Last updated: 03 November 2014
Copyright (c) 1997-2014 University of Cambridge.
------------------------------------------------------------------------------

View File

@ -1,4 +1,4 @@
.TH PCRE2_JIT_MATCH 3 "21 October 2014" "PCRE2 10.0"
.TH PCRE2_JIT_MATCH 3 "03 November 2014" "PCRE2 10.0"
.SH NAME
PCRE2 - Perl-compatible regular expressions (revised API)
.SH SYNOPSIS
@ -26,7 +26,7 @@ Its arguments are exactly the same as for
.\"
plus one additional argument that must either point to a JIT stack or be NULL.
In the latter case, if a callback function has been set up by
\fBpcre2_jit_stack_alloc()\fP, it is called. Otherwise the system stack is
\fBpcre2_jit_stack_create()\fP, it is called. Otherwise the system stack is
used.
.P
The supported options are PCRE2_NOTBOL, PCRE2_NOTEOL, PCRE2_NOTEMPTY,

View File

@ -1,4 +1,4 @@
.TH PCRE2_JIT_STACK_ASSIGN 3 "21 October 2014" "PCRE2 10.0"
.TH PCRE2_JIT_STACK_ASSIGN 3 "03 November 2014" "PCRE2 10.0"
.SH NAME
PCRE2 - Perl-compatible regular expressions (revised API)
.SH SYNOPSIS
@ -27,12 +27,12 @@ block on the machine stack is used.
.P
If \fIcallback\fP is NULL and \fIcallback_data\fP is not NULL,
\fIcallback_data\fP must be a valid JIT stack, the result of calling
\fBpcre2_jit_stack_alloc()\fP.
\fBpcre2_jit_stack_create()\fP.
.P
If \fIcallback\fP not NULL, it is called with \fIcallback_data\fP as an
argument at the start of matching, in order to set up a JIT stack. If the
result is NULL, the internal 32K stack is used; otherwise the return value must
be a valid JIT stack, the result of calling \fBpcre2_jit_stack_alloc()\fP.
be a valid JIT stack, the result of calling \fBpcre2_jit_stack_create()\fP.
.P
You may safely assign the same JIT stack to multiple patterns, as long as they
are all matched in the same thread. In a multithread application, each thread

View File

@ -1,4 +1,4 @@
.TH PCRE2_JIT_STACK_ALLOC 3 "21 October 2014" "PCRE2 10.00"
.TH PCRE2_JIT_STACK_CREATE 3 "03 November 2014" "PCRE2 10.00"
.SH NAME
PCRE2 - Perl-compatible regular expressions (revised API)
.SH SYNOPSIS
@ -7,7 +7,7 @@ PCRE2 - Perl-compatible regular expressions (revised API)
.B #include <pcre2.h>
.PP
.nf
.B pcre2_jit_stack *pcre2_jit_stack_alloc(pcre2_general_context *\fIgcontext\fP,
.B pcre2_jit_stack *pcre2_jit_stack_create(pcre2_general_context *\fIgcontext\fP,
.B " PCRE2_SIZE \fIstartsize\fP, PCRE2_SIZE \fImaxsize\fP);"
.fi
.

View File

@ -13,7 +13,7 @@ PCRE2 - Perl-compatible regular expressions (revised API)
.rs
.sp
This function is used to free a JIT stack that was created by
\fBpcre2_jit_stack_alloc()\fP when it is no longer needed. For more details,
\fBpcre2_jit_stack_create()\fP when it is no longer needed. For more details,
see the
.\" HREF
\fBpcre2jit\fP

View File

@ -1,4 +1,4 @@
.TH PCRE2API 3 "29 October 2014" "PCRE2 10.00"
.TH PCRE2API 3 "03 November 2014" "PCRE2 10.00"
.SH NAME
PCRE2 - Perl-compatible regular expressions (revised API)
.sp
@ -182,7 +182,7 @@ document for an overview of all the PCRE2 documentation.
.sp
.B void pcre2_jit_free_unused_memory(pcre2_general_context *\fIgcontext\fP);
.sp
.B pcre2_jit_stack *pcre2_jit_stack_alloc(pcre2_general_context *\fIgcontext\fP,
.B pcre2_jit_stack *pcre2_jit_stack_create(pcre2_general_context *\fIgcontext\fP,
.B " PCRE2_SIZE \fIstartsize\fP, PCRE2_SIZE \fImaxsize\fP);"
.sp
.B void pcre2_jit_stack_assign(const pcre2_code *\fIcode\fP,
@ -308,7 +308,7 @@ successfully compiled by \fBpcre2_compile()\fP. This does nothing if JIT
support is not available.
.P
More complicated programs might need to make use of the specialist functions
\fBpcre2_jit_stack_alloc()\fP, \fBpcre2_jit_stack_free()\fP, and
\fBpcre2_jit_stack_create()\fP, \fBpcre2_jit_stack_free()\fP, and
\fBpcre2_jit_stack_assign()\fP in order to control the JIT code's memory usage.
.P
JIT matching is automatically used by \fBpcre2_match()\fP if it is available.
@ -1265,7 +1265,7 @@ textual error message from any error code.
.sp
.B void pcre2_jit_free_unused_memory(pcre2_general_context *\fIgcontext\fP);
.sp
.B pcre2_jit_stack *pcre2_jit_stack_alloc(pcre2_general_context *\fIgcontext\fP,
.B pcre2_jit_stack *pcre2_jit_stack_create(pcre2_general_context *\fIgcontext\fP,
.B " PCRE2_SIZE \fIstartsize\fP, PCRE2_SIZE \fImaxsize\fP);"
.sp
.B void pcre2_jit_stack_assign(const pcre2_code *\fIcode\fP,
@ -2631,6 +2631,6 @@ Cambridge CB2 3QH, England.
.rs
.sp
.nf
Last updated: 29 October 2014
Last updated: 03 November 2014
Copyright (c) 1997-2014 University of Cambridge.
.fi

View File

@ -1,4 +1,4 @@
.TH PCRE2JIT 3 "02 November 2014" "PCRE2 10.00"
.TH PCRE2JIT 3 "03 November 2014" "PCRE2 10.00"
.SH NAME
PCRE2 - Perl-compatible regular expressions (revised API)
.SH "PCRE2 JUST-IN-TIME COMPILER SUPPORT"
@ -149,7 +149,7 @@ about the use of JIT stacks in the section entitled
.\"
below.
.P
The \fBpcre2_jit_stack_alloc()\fP function creates a JIT stack. Its arguments
The \fBpcre2_jit_stack_create()\fP function creates a JIT stack. Its arguments
are a general context (for memory allocation functions, or NULL for standard
memory allocation), a starting size and a maximum size, and it returns a
pointer to an opaque structure of type \fBpcre2_jit_stack\fP, or NULL if there
@ -176,14 +176,14 @@ the other two options:
on the machine stack is used.
.sp
(2) If \fIcallback\fP is NULL and \fIdata\fP is not NULL, \fIdata\fP must be
a valid JIT stack, the result of calling \fBpcre2_jit_stack_alloc()\fP.
a valid JIT stack, the result of calling \fBpcre2_jit_stack_create()\fP.
.sp
(3) If \fIcallback\fP is not NULL, it must point to a function that is
called with \fIdata\fP as an argument at the start of matching, in
order to set up a JIT stack. If the return from the callback
function is NULL, the internal 32K stack is used; otherwise the
return value must be a valid JIT stack, the result of calling
\fBpcre2_jit_stack_alloc()\fP.
\fBpcre2_jit_stack_create()\fP.
.sp
A callback function is obeyed whenever JIT code is about to be run; it is not
obeyed when \fBpcre2_match()\fP is called with options that are incompatible
@ -209,7 +209,7 @@ This is a suggestion for how a multithreaded program that needs to set up
non-default JIT stacks might operate:
.sp
During thread initalization
thread_local_var = pcre2_jit_stack_alloc(...)
thread_local_var = pcre2_jit_stack_create(...)
.sp
During thread exit
pcre2_jit_stack_free(thread_local_var)
@ -323,7 +323,7 @@ callback.
/* Check for errors */
rc = pcre2_jit_compile(re, PCRE2_JIT_COMPLETE);
/* Check for errors */
jit_stack = pcre2_jit_stack_alloc(NULL, 32*1024, 512*1024);
jit_stack = pcre2_jit_stack_create(NULL, 32*1024, 512*1024);
/* Check for error (NULL) */
pcre2_jit_stack_assign(re, NULL, jit_stack);
match_data = pcre2_match_data_create(re, 10);
@ -386,6 +386,6 @@ Cambridge CB2 3QH, England.
.rs
.sp
.nf
Last updated: 02 November 2014
Last updated: 03 November 2014
Copyright (c) 1997-2014 University of Cambridge.
.fi

View File

@ -169,11 +169,12 @@ COMMAND LINE OPTIONS
DESCRIPTION
If pcre2test is given two filename arguments, it reads from the first
and writes to the second. If it is given only one filename argument, it
reads from that file and writes to stdout. Otherwise, it reads from
stdin and writes to stdout, and prompts for each line of input, using
"re>" to prompt for regular expression patterns, and "data>" to prompt
for subject lines.
and writes to the second. If the first name is "-", input is taken from
the standard input. If pcre2test is given only one argument, it reads
from that file and writes to stdout. Otherwise, it reads from stdin and
writes to stdout. When the input is a terminal, it prompts for each
line of input, using "re>" to prompt for regular expression patterns,
and "data>" to prompt for subject lines.
When pcre2test is built, a configuration option can specify that it
should be linked with the libreadline or libedit library. When this is
@ -424,6 +425,7 @@ PATTERN MODIFIERS
/I info show info about compiled pattern
hex pattern is coded in hexadecimal
jit[=<number>] use JIT
jitfast use JIT fast path
jitverify verify JIT use
locale=<name> use this locale
memory show memory used
@ -506,6 +508,12 @@ PATTERN MODIFIERS
tation. See also the jitstack modifier below for a way of setting the
size of the JIT stack.
If the jitfast modifier is specified, matching is done using the JIT
"fast path" interface (pcre2_jit_match()), which skips some of the san-
ity checks that are done by pcre2_match(), and of course does not work
when JIT is not supported. If jitfast is specified without jit, jit=7
is assumed.
If the jitverify modifier is specified, information about the compiled
pattern shows whether JIT compilation was or was not successful. If
jitverify is specified without jit, jit=7 is assumed. If JIT compila-
@ -539,7 +547,9 @@ PATTERN MODIFIERS
The parens_nest_limit modifier sets a limit on the depth of nested
parentheses in a pattern. Breaching the limit causes a compilation
error.
error. The default for the library is set when PCRE2 is built, but
pcre2test sets its own default of 220, which is required for running
the standard test suite.
Using the POSIX wrapper API
@ -600,6 +610,7 @@ PATTERN MODIFIERS
allusedtext show all consulted text
/g global global matching
mark show mark values
startchar show starting character when relevant
These modifiers may not appear in a #pattern command. If you want them
as defaults, set them in a #subject command.
@ -664,6 +675,7 @@ SUBJECT MODIFIERS
offset=<n> set starting offset
ovector=<n> set size of output vector
recursion_limit=<n> set a recursion limit
startchar show startchar when relevant
The effects of these modifiers are described in the following sections.
FIXME: Give more examples.
@ -689,14 +701,30 @@ SUBJECT MODIFIERS
cated in the output by '<' or '>' characters underneath them. Here is
an example:
/(?<=pqr)abc(?=xyz)/
123pqrabcxyz456\=allusedtext
re> /(?<=pqr)abc(?=xyz)/
data> 123pqrabcxyz456\=allusedtext
0: pqrabcxyz
<<< >>>
This shows that the matched string is "abc", with the preceding and
following strings "pqr" and "xyz" also consulted during the match.
The startchar modifier requests that the starting character for the
match be indicated, if it is different to the start of the matched
string. The only time when this occurs is when \K has been processed as
part of the match. In this situation, the output for the matched string
is displayed from the starting character instead of from the match
point, with circumflex characters under the earlier characters. For
example:
re> /abc\Kxyz/
data> abcxyz\=startchar
0: abcxyz
^^^
Unlike allusedtext, the startchar modifier can be used with JIT. How-
ever, these two modifiers are mutually exclusive.
Showing the value of all capture groups
The allcaptures modifier requests that the values of all potential cap-
@ -768,8 +796,9 @@ SUBJECT MODIFIERS
The jitstack modifier provides a way of setting the maximum stack size
that is used by the just-in-time optimization code. It is ignored if
JIT optimization is not being used. Providing a stack that is larger
than the default 32K is necessary only for very complicated patterns.
JIT optimization is not being used. The value is a number of kilobytes.
Providing a stack that is larger than the default 32K is necessary only
for very complicated patterns.
Setting match and recursion limits
@ -824,10 +853,13 @@ SUBJECT MODIFIERS
#subject command. It specifies the number of pairs of offsets that are
available for storing matching information. The default is 15.
At least one pair of offsets is always created by pcre2_match_data_cre-
ate(), for matching with PCRE2's native API, so a value of 0 is the
same as 1. However a value of 0 is useful when testing the POSIX API
because it causes regexec() to be called with a NULL capture vector.
A value of zero is useful when testing the POSIX API because it causes
regexec() to be called with a NULL capture vector. When not testing the
POSIX API, a value of zero is used to cause pcre2_match_data_cre-
ate_from_pattern to be called, in order to create a match block of
exactly the right size for the pattern. (It is not possible to create a
match block with a zero-length ovector; there is always one pair of
offsets.)
THE ALTERNATIVE MATCHING FUNCTION
@ -1058,8 +1090,8 @@ NON-PRINTING CHARACTERS
SEE ALSO
pcre2(3), pcre16(3), pcre32(3), pcre2api(3), pcre2callout(3), pcre2jit,
pcre2matching(3), pcre2partial(d), pcre2pattern(3), pcre2precompile(3).
pcre2(3), pcre2api(3), pcre2callout(3), pcre2jit, pcre2matching(3),
pcre2partial(d), pcre2pattern(3).
AUTHOR
@ -1071,5 +1103,5 @@ AUTHOR
REVISION
Last updated: 11 October 2014
Last updated: 02 November 2014
Copyright (c) 1997-2014 University of Cambridge.

View File

@ -86,8 +86,7 @@ passed. Put these bits at the most significant end of the options word so
others can be added next to them */
#define PCRE2_ANCHORED 0x80000000u
#define PCRE2_NO_START_OPTIMIZE 0x40000000u
#define PCRE2_NO_UTF_CHECK 0x20000000u
#define PCRE2_NO_UTF_CHECK 0x40000000u
/* Other options that can be passed to pcre2_compile(). They may affect
compilation, JIT compilation, and/or interpretive execution. The following tags
@ -95,7 +94,7 @@ indicate which:
C alters what is compiled
J alters what JIT compiles
E is inspected during pcre2_match() execution
M is inspected during pcre2_match() execution
D is inspected during pcre2_dfa_match() execution
*/
@ -103,24 +102,25 @@ D is inspected during pcre2_dfa_match() execution
#define PCRE2_ALT_BSUX 0x00000002u /* C */
#define PCRE2_AUTO_CALLOUT 0x00000004u /* C */
#define PCRE2_CASELESS 0x00000008u /* C */
#define PCRE2_DOLLAR_ENDONLY 0x00000010u /* J E D */
#define PCRE2_DOLLAR_ENDONLY 0x00000010u /* J M D */
#define PCRE2_DOTALL 0x00000020u /* C */
#define PCRE2_DUPNAMES 0x00000040u /* C */
#define PCRE2_EXTENDED 0x00000080u /* C */
#define PCRE2_FIRSTLINE 0x00000100u /* J E D */
#define PCRE2_MATCH_UNSET_BACKREF 0x00000200u /* C J E */
#define PCRE2_FIRSTLINE 0x00000100u /* J M D */
#define PCRE2_MATCH_UNSET_BACKREF 0x00000200u /* C J M */
#define PCRE2_MULTILINE 0x00000400u /* C */
#define PCRE2_NEVER_UCP 0x00000800u /* C */
#define PCRE2_NEVER_UTF 0x00001000u /* C */
#define PCRE2_NO_AUTO_CAPTURE 0x00002000u /* C */
#define PCRE2_NO_AUTO_POSSESS 0x00004000u /* C */
#define PCRE2_UCP 0x00008000u /* C J E D */
#define PCRE2_UNGREEDY 0x00010000u /* C */
#define PCRE2_UTF 0x00020000u /* C J E D */
#define PCRE2_NO_START_OPTIMIZE 0x00008000u /* J M D */
#define PCRE2_UCP 0x00010000u /* C J M D */
#define PCRE2_UNGREEDY 0x00020000u /* C */
#define PCRE2_UTF 0x00040000u /* C J M D */
/* These are for pcre2_jit_compile(). */
#define PCRE2_JIT 0x00000001u /* For full matching */
#define PCRE2_JIT_COMPLETE 0x00000001u /* For full matching */
#define PCRE2_JIT_PARTIAL_SOFT 0x00000002u
#define PCRE2_JIT_PARTIAL_HARD 0x00000004u
@ -130,8 +130,8 @@ functions, so take care not to define synonyms by mistake. */
#define PCRE2_NOTBOL 0x00000001u
#define PCRE2_NOTEOL 0x00000002u
#define PCRE2_NOTEMPTY 0x00000004u
#define PCRE2_NOTEMPTY_ATSTART 0x00000008u
#define PCRE2_NOTEMPTY 0x00000004u /* ) These two must be kept */
#define PCRE2_NOTEMPTY_ATSTART 0x00000008u /* ) adjacent to each other. */
#define PCRE2_PARTIAL_SOFT 0x00000010u
#define PCRE2_PARTIAL_HARD 0x00000020u
@ -140,9 +140,9 @@ functions, so take care not to define synonyms by mistake. */
#define PCRE2_DFA_RESTART 0x00000040u
#define PCRE2_DFA_SHORTEST 0x00000080u
/* Newline and \R settings, for use in the compile and match contexts. The
newline values must be kept in step with values set in config.h and both sets
must all be greater than zero. */
/* Newline and \R settings, for use in compile contexts. The newline values
must be kept in step with values set in config.h and both sets must all be
greater than zero. */
#define PCRE2_NEWLINE_CR 1
#define PCRE2_NEWLINE_LF 2
@ -193,32 +193,33 @@ must all be greater than zero. */
#define PCRE2_ERROR_UTF32_ERR1 (-27)
#define PCRE2_ERROR_UTF32_ERR2 (-28)
/* Error codes for pcre2[_dfa]_match() */
/* Error codes for pcre2[_dfa]_match(), substring extraction functions, and
context functions. */
#define PCRE2_ERROR_BADCOUNT (-29)
#define PCRE2_ERROR_BADENDIANNESS (-30)
#define PCRE2_ERROR_BADLENGTH (-31)
#define PCRE2_ERROR_BADMAGIC (-32)
#define PCRE2_ERROR_BADMODE (-33)
#define PCRE2_ERROR_BADOFFSET (-34)
#define PCRE2_ERROR_BADOPTION (-35)
#define PCRE2_ERROR_BADUTFOFFSET (-36)
#define PCRE2_ERROR_CALLOUT (-37) /* Never used by PCRE2 itself */
#define PCRE2_ERROR_DFA_BADRESTART (-38)
#define PCRE2_ERROR_DFA_RECURSE (-39)
#define PCRE2_ERROR_DFA_UCOND (-40)
#define PCRE2_ERROR_DFA_UITEM (-41)
#define PCRE2_ERROR_DFA_UMLIMIT (-42)
#define PCRE2_ERROR_DFA_WSSIZE (-43)
#define PCRE2_ERROR_INTERNAL (-44)
#define PCRE2_ERROR_JIT_BADOPTION (-45)
#define PCRE2_ERROR_JIT_STACKLIMIT (-46)
#define PCRE2_ERROR_MATCHLIMIT (-47)
#define PCRE2_ERROR_NOMEMORY (-48)
#define PCRE2_ERROR_NOSUBSTRING (-49)
#define PCRE2_ERROR_NULL (-50)
#define PCRE2_ERROR_RECURSELOOP (-51)
#define PCRE2_ERROR_RECURSIONLIMIT (-52)
#define PCRE2_ERROR_BADDATA (-29)
#define PCRE2_ERROR_BADLENGTH (-30)
#define PCRE2_ERROR_BADMAGIC (-31)
#define PCRE2_ERROR_BADMODE (-32)
#define PCRE2_ERROR_BADOFFSET (-33)
#define PCRE2_ERROR_BADOPTION (-34)
#define PCRE2_ERROR_BADUTFOFFSET (-35)
#define PCRE2_ERROR_CALLOUT (-36) /* Never used by PCRE2 itself */
#define PCRE2_ERROR_DFA_BADRESTART (-37)
#define PCRE2_ERROR_DFA_RECURSE (-38)
#define PCRE2_ERROR_DFA_UCOND (-39)
#define PCRE2_ERROR_DFA_UITEM (-40)
#define PCRE2_ERROR_DFA_WSSIZE (-41)
#define PCRE2_ERROR_INTERNAL (-42)
#define PCRE2_ERROR_JIT_BADOPTION (-43)
#define PCRE2_ERROR_JIT_STACKLIMIT (-44)
#define PCRE2_ERROR_MATCHLIMIT (-45)
#define PCRE2_ERROR_NOMEMORY (-46)
#define PCRE2_ERROR_NOSUBSTRING (-47)
#define PCRE2_ERROR_NOUNIQUESUBSTRING (-48)
#define PCRE2_ERROR_NULL (-49)
#define PCRE2_ERROR_RECURSELOOP (-50)
#define PCRE2_ERROR_RECURSIONLIMIT (-51)
#define PCRE2_ERROR_UNSET (-52)
/* Request types for pcre2_pattern_info() */
@ -257,8 +258,8 @@ must all be greater than zero. */
#define PCRE2_CONFIG_PARENSLIMIT 7
#define PCRE2_CONFIG_RECURSIONLIMIT 5
#define PCRE2_CONFIG_STACKRECURSE 8
#define PCRE2_CONFIG_UNICODE_VERSION 9
#define PCRE2_CONFIG_UTF 10
#define PCRE2_CONFIG_UNICODE 9
#define PCRE2_CONFIG_UNICODE_VERSION 10
#define PCRE2_CONFIG_VERSION 11
/* Types for code units in patterns and subject strings. */
@ -271,12 +272,14 @@ typedef const PCRE2_UCHAR8 *PCRE2_SPTR8;
typedef const PCRE2_UCHAR16 *PCRE2_SPTR16;
typedef const PCRE2_UCHAR32 *PCRE2_SPTR32;
/* Offsets in the pattern (for errors) and in the subject (after a match) are
unsigned 32-bit numbers. We also define a value to indicate "unset" in the
offset vector (ovector). */
/* The PCRE2_SIZE type is used for all string lengths and offsets in PCRE2,
including pattern offsets for errors and subject offsets after a match. We
define special values to indicate zero-terminated strings and unset offsets in
the offset vector (ovector). */
#define PCRE2_OFFSET PCRE2_UCHAR32
#define PCRE2_UNSET (~(PCRE2_OFFSET)0)
#define PCRE2_SIZE size_t
#define PCRE2_ZERO_TERMINATED (~(PCRE2_SIZE)0)
#define PCRE2_UNSET (~(PCRE2_SIZE)0)
/* Generic types for opaque structures and JIT callback functions. These
declarations are defined in a macro that is expanded for each width later. */
@ -311,22 +314,20 @@ versions are generated from this macro below. */
#define PCRE2_STRUCTURE_LIST \
typedef struct pcre2_callout_block { \
int version; /* Identifies version of block */ \
uint32_t version; /* Identifies version of block */ \
/* ------------------------ Version 0 ------------------------------- */ \
uint32_t callout_number; /* Number compiled into pattern */ \
PCRE2_OFFSET *offset_vector; /* The offset vector */ \
PCRE2_SPTR subject; /* The subject being matched */ \
size_t subject_length; /* The length of the subject */ \
PCRE2_OFFSET start_match; /* Offset to start of this match attempt */ \
PCRE2_OFFSET current_position; /* Where we currently are in the subject */ \
uint32_t capture_top; /* Max current capture */ \
uint32_t capture_last; /* Most recently closed capture */ \
void *callout_data; /* Data passed in with the call */ \
/* ------------------- Added for Version 1 -------------------------- */ \
PCRE2_OFFSET pattern_position; /* Offset to next item in the pattern */ \
PCRE2_OFFSET next_item_length; /* Length of next item in the pattern */ \
/* ------------------- Added for Version 2 -------------------------- */ \
PCRE2_SIZE *offset_vector; /* The offset vector */ \
PCRE2_SPTR mark; /* Pointer to current mark or NULL */ \
PCRE2_SPTR subject; /* The subject being matched */ \
PCRE2_SIZE subject_length; /* The length of the subject */ \
PCRE2_SIZE start_match; /* Offset to start of this match attempt */ \
PCRE2_SIZE current_position; /* Where we currently are in the subject */ \
PCRE2_SIZE pattern_position; /* Offset to next item in the pattern */ \
PCRE2_SIZE next_item_length; /* Length of next item in the pattern */ \
/* ------------------------------------------------------------------ */ \
} pcre2_callout_block;
@ -336,7 +337,7 @@ expanded for each width below. Start with functions that give general
information. */
#define PCRE2_GENERAL_INFO_FUNCTIONS \
PCRE2_EXP_DECL int pcre2_config(int, void *, size_t);
PCRE2_EXP_DECL int pcre2_config(uint32_t, void *);
/* Functions for manipulating contexts. */
@ -346,7 +347,7 @@ PCRE2_EXP_DECL \
pcre2_general_context *pcre2_general_context_copy(pcre2_general_context *); \
PCRE2_EXP_DECL \
pcre2_general_context *pcre2_general_context_create( \
void *(*)(size_t, void *), \
void *(*)(PCRE2_SIZE, void *), \
void (*)(void *, void *), void *); \
PCRE2_EXP_DECL void pcre2_general_context_free(pcre2_general_context *);
@ -356,12 +357,10 @@ PCRE2_EXP_DECL \
PCRE2_EXP_DECL \
pcre2_compile_context *pcre2_compile_context_create(pcre2_general_context *);\
PCRE2_EXP_DECL void pcre2_compile_context_free(pcre2_compile_context *); \
PCRE2_EXP_DECL int pcre2_set_bsr_compile(pcre2_compile_context *, \
uint32_t); \
PCRE2_EXP_DECL int pcre2_set_bsr(pcre2_compile_context *, uint32_t); \
PCRE2_EXP_DECL int pcre2_set_character_tables(pcre2_compile_context *, \
const unsigned char *); \
PCRE2_EXP_DECL int pcre2_set_newline_compile(pcre2_compile_context *, \
uint32_t); \
PCRE2_EXP_DECL int pcre2_set_newline(pcre2_compile_context *, uint32_t); \
PCRE2_EXP_DECL int pcre2_set_parens_nest_limit(pcre2_compile_context *, \
uint32_t); \
PCRE2_EXP_DECL int pcre2_set_compile_recursion_guard(\
@ -373,18 +372,14 @@ PCRE2_EXP_DECL \
PCRE2_EXP_DECL \
pcre2_match_context *pcre2_match_context_create(pcre2_general_context *); \
PCRE2_EXP_DECL void pcre2_match_context_free(pcre2_match_context *); \
PCRE2_EXP_DECL int pcre2_set_bsr_match(pcre2_match_context *, \
uint32_t); \
PCRE2_EXP_DECL int pcre2_set_callout(pcre2_match_context *, \
int (*)(pcre2_callout_block *), void *); \
PCRE2_EXP_DECL int pcre2_set_match_limit(pcre2_match_context *, \
uint32_t); \
PCRE2_EXP_DECL int pcre2_set_newline_match(pcre2_match_context *, \
uint32_t); \
PCRE2_EXP_DECL int pcre2_set_recursion_limit(pcre2_match_context *, \
uint32_t); \
PCRE2_EXP_DECL int pcre2_set_recursion_memory_management( \
pcre2_match_context *, void *(*)(size_t, void *), \
pcre2_match_context *, void *(*)(PCRE2_SIZE, void *), \
void (*)(void *, void *), void *);
@ -392,8 +387,8 @@ PCRE2_EXP_DECL int pcre2_set_recursion_memory_management( \
#define PCRE2_COMPILE_FUNCTIONS \
PCRE2_EXP_DECL \
pcre2_code *pcre2_compile(PCRE2_SPTR, int, uint32_t, \
int *, PCRE2_OFFSET *, pcre2_compile_context *); \
pcre2_code *pcre2_compile(PCRE2_SPTR, PCRE2_SIZE, uint32_t, \
int *, PCRE2_SIZE *, pcre2_compile_context *); \
PCRE2_EXP_DECL void pcre2_code_free(pcre2_code *);
@ -413,60 +408,57 @@ PCRE2_EXP_DECL \
PCRE2_EXP_DECL \
pcre2_match_data *pcre2_match_data_create_from_pattern(pcre2_code *, \
pcre2_general_context *); \
PCRE2_EXP_DECL int pcre2_dfa_match(const pcre2_code *, \
PCRE2_SPTR, int, PCRE2_OFFSET, uint32_t, \
PCRE2_EXP_DECL int pcre2_dfa_match(const pcre2_code *, PCRE2_SPTR, \
PCRE2_SIZE, PCRE2_SIZE, uint32_t, \
pcre2_match_data *, pcre2_match_context *, int *, \
size_t); \
PCRE2_SIZE); \
PCRE2_EXP_DECL int pcre2_match(const pcre2_code *, \
PCRE2_SPTR, int, PCRE2_OFFSET, uint32_t, \
PCRE2_SPTR, PCRE2_SIZE, PCRE2_SIZE, uint32_t, \
pcre2_match_data *, pcre2_match_context *); \
PCRE2_EXP_DECL void pcre2_match_data_free(pcre2_match_data *); \
PCRE2_EXP_DECL PCRE2_OFFSET pcre2_get_leftchar(pcre2_match_data *); \
PCRE2_EXP_DECL PCRE2_SPTR pcre2_get_mark(pcre2_match_data *); \
PCRE2_EXP_DECL uint32_t pcre2_get_ovector_count(pcre2_match_data *); \
PCRE2_EXP_DECL PCRE2_OFFSET *pcre2_get_ovector_pointer(pcre2_match_data *); \
PCRE2_EXP_DECL PCRE2_OFFSET pcre2_get_rightchar(pcre2_match_data *); \
PCRE2_EXP_DECL PCRE2_OFFSET pcre2_get_startchar(pcre2_match_data *);
PCRE2_EXP_DECL PCRE2_SIZE *pcre2_get_ovector_pointer(pcre2_match_data *); \
PCRE2_EXP_DECL PCRE2_SIZE pcre2_get_startchar(pcre2_match_data *);
/* Convenience functions for handling matched substrings. */
#define PCRE2_SUBSTRING_FUNCTIONS \
PCRE2_EXP_DECL int pcre2_substring_copy_byname(pcre2_match_data *, \
PCRE2_SPTR, PCRE2_UCHAR *, size_t); \
PCRE2_SPTR, PCRE2_UCHAR *, PCRE2_SIZE *); \
PCRE2_EXP_DECL int pcre2_substring_copy_bynumber(pcre2_match_data *, \
int, PCRE2_UCHAR *, size_t); \
unsigned int, PCRE2_UCHAR *, PCRE2_SIZE *); \
PCRE2_EXP_DECL void pcre2_substring_free(PCRE2_UCHAR *); \
PCRE2_EXP_DECL int pcre2_substring_get_byname(pcre2_match_data *, \
PCRE2_SPTR, PCRE2_UCHAR **); \
PCRE2_SPTR, PCRE2_UCHAR **, PCRE2_SIZE *); \
PCRE2_EXP_DECL int pcre2_substring_get_bynumber(pcre2_match_data *, \
int, PCRE2_UCHAR **); \
unsigned int, PCRE2_UCHAR **, PCRE2_SIZE *); \
PCRE2_EXP_DECL int pcre2_substring_length_byname(pcre2_match_data *, \
PCRE2_SPTR); \
PCRE2_SPTR, PCRE2_SIZE *); \
PCRE2_EXP_DECL int pcre2_substring_length_bynumber(pcre2_match_data *, \
int); \
unsigned int, PCRE2_SIZE *); \
PCRE2_EXP_DECL int pcre2_substring_nametable_scan(const pcre2_code *, \
PCRE2_SPTR, PCRE2_SPTR *, PCRE2_SPTR *); \
PCRE2_EXP_DECL int pcre2_substring_number_from_name(\
const pcre2_code *, PCRE2_SPTR); \
PCRE2_EXP_DECL void pcre2_substring_list_free(PCRE2_SPTR *); \
PCRE2_EXP_DECL int pcre2_substring_list_get(pcre2_match_data *, \
PCRE2_UCHAR ***, size_t **);
PCRE2_UCHAR ***, PCRE2_SIZE **);
/* Functions for JIT processing */
#define PCRE2_JIT_FUNCTIONS \
PCRE2_EXP_DECL int pcre2_jit_compile(pcre2_code *, uint32_t, \
pcre2_match_context *); \
PCRE2_EXP_DECL int pcre2_jit_compile(pcre2_code *, uint32_t); \
PCRE2_EXP_DECL int pcre2_jit_match(const pcre2_code *, \
PCRE2_SPTR, int, PCRE2_OFFSET, uint32_t, \
PCRE2_SPTR, PCRE2_SIZE, PCRE2_SIZE, uint32_t, \
pcre2_match_data *, pcre2_match_context *, \
pcre2_jit_stack *); \
PCRE2_EXP_DECL void pcre2_jit_free_unused_memory(pcre2_general_context *);\
PCRE2_EXP_DECL \
pcre2_jit_stack *pcre2_jit_stack_alloc(pcre2_general_context *, \
size_t, size_t); \
pcre2_jit_stack *pcre2_jit_stack_create(pcre2_general_context *, \
PCRE2_SIZE, PCRE2_SIZE); \
PCRE2_EXP_DECL void pcre2_jit_stack_assign(const pcre2_code *, \
pcre2_jit_callback, void *); \
PCRE2_EXP_DECL void pcre2_jit_stack_free(pcre2_jit_stack *);
@ -475,7 +467,7 @@ PCRE2_EXP_DECL void pcre2_jit_stack_free(pcre2_jit_stack *);
/* Other miscellaneous functions. */
#define PCRE2_OTHER_FUNCTIONS \
PCRE2_EXP_DECL int pcre2_get_error_message(int, PCRE2_UCHAR *, size_t); \
PCRE2_EXP_DECL int pcre2_get_error_message(int, PCRE2_UCHAR *, PCRE2_SIZE); \
PCRE2_EXP_DECL \
const uint8_t *pcre2_maketables(pcre2_general_context *); \
@ -532,17 +524,15 @@ pcre2_compile are called by application code. */
#define pcre2_general_context_create PCRE2_SUFFIX(pcre2_general_context_create_)
#define pcre2_general_context_free PCRE2_SUFFIX(pcre2_general_context_free_)
#define pcre2_get_error_message PCRE2_SUFFIX(pcre2_get_error_message_)
#define pcre2_get_leftchar PCRE2_SUFFIX(pcre2_get_leftchar_)
#define pcre2_get_mark PCRE2_SUFFIX(pcre2_get_mark_)
#define pcre2_get_ovector_pointer PCRE2_SUFFIX(pcre2_get_ovector_pointer_)
#define pcre2_get_ovector_count PCRE2_SUFFIX(pcre2_get_ovector_count_)
#define pcre2_get_rightchar PCRE2_SUFFIX(pcre2_get_rightchar_)
#define pcre2_get_startchar PCRE2_SUFFIX(pcre2_get_startchar_)
#define pcre2_jit_compile PCRE2_SUFFIX(pcre2_jit_compile_)
#define pcre2_jit_match PCRE2_SUFFIX(pcre2_jit_match_)
#define pcre2_jit_free_unused_memory PCRE2_SUFFIX(pcre2_jit_free_unused_memory_)
#define pcre2_jit_stack_alloc PCRE2_SUFFIX(pcre2_jit_stack_alloc_)
#define pcre2_jit_stack_assign PCRE2_SUFFIX(pcre2_jit_stack_assign_)
#define pcre2_jit_stack_create PCRE2_SUFFIX(pcre2_jit_stack_create_)
#define pcre2_jit_stack_free PCRE2_SUFFIX(pcre2_jit_stack_free_)
#define pcre2_maketables PCRE2_SUFFIX(pcre2_maketables_)
#define pcre2_match_context_copy PCRE2_SUFFIX(pcre2_match_context_copy_)
@ -552,14 +542,12 @@ pcre2_compile are called by application code. */
#define pcre2_match_data_create_from_pattern PCRE2_SUFFIX(pcre2_match_data_create_from_pattern_)
#define pcre2_match_data_free PCRE2_SUFFIX(pcre2_match_data_free_)
#define pcre2_pattern_info PCRE2_SUFFIX(pcre2_pattern_info_)
#define pcre2_set_bsr_compile PCRE2_SUFFIX(pcre2_set_bsr_compile_)
#define pcre2_set_bsr_match PCRE2_SUFFIX(pcre2_set_bsr_match_)
#define pcre2_set_bsr PCRE2_SUFFIX(pcre2_set_bsr_)
#define pcre2_set_callout PCRE2_SUFFIX(pcre2_set_callout_)
#define pcre2_set_character_tables PCRE2_SUFFIX(pcre2_set_character_tables_)
#define pcre2_set_compile_recursion_guard PCRE2_SUFFIX(pcre2_set_compile_recursion_guard_)
#define pcre2_set_match_limit PCRE2_SUFFIX(pcre2_set_match_limit_)
#define pcre2_set_newline_compile PCRE2_SUFFIX(pcre2_set_newline_compile_)
#define pcre2_set_newline_match PCRE2_SUFFIX(pcre2_set_newline_match_)
#define pcre2_set_newline PCRE2_SUFFIX(pcre2_set_newline_)
#define pcre2_set_parens_nest_limit PCRE2_SUFFIX(pcre2_set_parens_nest_limit_)
#define pcre2_set_recursion_limit PCRE2_SUFFIX(pcre2_set_recursion_limit_)
#define pcre2_set_recursion_memory_management PCRE2_SUFFIX(pcre2_set_recursion_memory_management_)
@ -621,24 +609,27 @@ PCRE2_TYPES_STRUCTURES_AND_FUNCTIONS
#undef PCRE2_OTHER_FUNCTIONS
#undef PCRE2_TYPES_STRUCTURES_AND_FUNCTIONS
/* Re-define PCRE2_SUFFIX to use the external width value, if defined.
Otherwise, undefine the other macros and make PCRE2_SUFFIX a no-op, to reduce
confusion. */
/* PCRE2_CODE_UNIT_WIDTH must be defined. If it is 8, 16, or 32, redefine
PCRE2_SUFFIX to use it. If it is 0, undefine the other macros and make
PCRE2_SUFFIX a no-op. Otherwise, generate an error. */
#undef PCRE2_SUFFIX
#ifdef PCRE2_CODE_UNIT_WIDTH
#if PCRE2_CODE_UNIT_WIDTH != 8 && \
PCRE2_CODE_UNIT_WIDTH != 16 && \
PCRE2_CODE_UNIT_WIDTH != 32
#error PCRE2_CODE_UNIT_WIDTH must be 8, 16, or 32
#endif
#ifndef PCRE2_CODE_UNIT_WIDTH
#error PCRE2_CODE_UNIT_WIDTH must be defined before including pcre2.h.
#error Use 8, 16, or 32; or 0 for a multi-width application.
#else /* PCRE2_CODE_UNIT_WIDTH is defined */
#if PCRE2_CODE_UNIT_WIDTH == 8 || \
PCRE2_CODE_UNIT_WIDTH == 16 || \
PCRE2_CODE_UNIT_WIDTH == 32
#define PCRE2_SUFFIX(a) PCRE2_GLUE(a, PCRE2_CODE_UNIT_WIDTH)
#else
#elif PCRE2_CODE_UNIT_WIDTH == 0
#undef PCRE2_JOIN
#undef PCRE2_GLUE
#define PCRE2_SUFFIX(a) a
#else
#error PCRE2_CODE_UNIT_WIDTH must be 0, 8, 16, or 32.
#endif
#endif /* PCRE2_CODE_UNIT_WIDTH is defined */
#ifdef __cplusplus
} /* extern "C" */

View File

@ -457,7 +457,7 @@ PCRE2_EXP_DECL int pcre2_jit_match(const pcre2_code *, \
pcre2_jit_stack *); \
PCRE2_EXP_DECL void pcre2_jit_free_unused_memory(pcre2_general_context *);\
PCRE2_EXP_DECL \
pcre2_jit_stack *pcre2_jit_stack_alloc(pcre2_general_context *, \
pcre2_jit_stack *pcre2_jit_stack_create(pcre2_general_context *, \
PCRE2_SIZE, PCRE2_SIZE); \
PCRE2_EXP_DECL void pcre2_jit_stack_assign(const pcre2_code *, \
pcre2_jit_callback, void *); \
@ -531,8 +531,8 @@ pcre2_compile are called by application code. */
#define pcre2_jit_compile PCRE2_SUFFIX(pcre2_jit_compile_)
#define pcre2_jit_match PCRE2_SUFFIX(pcre2_jit_match_)
#define pcre2_jit_free_unused_memory PCRE2_SUFFIX(pcre2_jit_free_unused_memory_)
#define pcre2_jit_stack_alloc PCRE2_SUFFIX(pcre2_jit_stack_alloc_)
#define pcre2_jit_stack_assign PCRE2_SUFFIX(pcre2_jit_stack_assign_)
#define pcre2_jit_stack_create PCRE2_SUFFIX(pcre2_jit_stack_create_)
#define pcre2_jit_stack_free PCRE2_SUFFIX(pcre2_jit_stack_free_)
#define pcre2_maketables PCRE2_SUFFIX(pcre2_maketables_)
#define pcre2_match_context_copy PCRE2_SUFFIX(pcre2_match_context_copy_)

View File

@ -97,7 +97,7 @@ sljit_free_unused_memory_exec();
*************************************************/
PCRE2_EXP_DEFN pcre2_jit_stack * PCRE2_CALL_CONVENTION
pcre2_jit_stack_alloc(pcre2_general_context *gcontext, size_t startsize,
pcre2_jit_stack_create(pcre2_general_context *gcontext, size_t startsize,
size_t maxsize)
{
#ifndef SUPPORT_JIT

View File

@ -854,7 +854,7 @@ static pcre2_jit_stack_8 *stack8;
static pcre2_jit_stack_8 *getstack8(void)
{
if (!stack8)
stack8 = pcre2_jit_stack_alloc_8(NULL, 1, 1024 * 1024);
stack8 = pcre2_jit_stack_create_8(NULL, 1, 1024 * 1024);
return stack8;
}
@ -877,7 +877,7 @@ static pcre2_jit_stack_16 *stack16;
static pcre2_jit_stack_16 *getstack16(void)
{
if (!stack16)
stack16 = pcre2_jit_stack_alloc_16(NULL, 1, 1024 * 1024);
stack16 = pcre2_jit_stack_create_16(NULL, 1, 1024 * 1024);
return stack16;
}
@ -900,7 +900,7 @@ static pcre2_jit_stack_32 *stack32;
static pcre2_jit_stack_32 *getstack32(void)
{
if (!stack32)
stack32 = pcre2_jit_stack_alloc_32(NULL, 1, 1024 * 1024);
stack32 = pcre2_jit_stack_create_32(NULL, 1, 1024 * 1024);
return stack32;
}

View File

@ -3115,7 +3115,7 @@ for (fn = pattern_files; fn != NULL; fn = fn->next)
#ifdef SUPPORT_PCRE2GREP_JIT
if (use_jit)
jit_stack = pcre2_jit_stack_alloc(NULL, 32*1024, 1024*1024);
jit_stack = pcre2_jit_stack_create(NULL, 32*1024, 1024*1024);
#endif
for (j = 1, cp = patterns; cp != NULL; j++, cp = cp->next)

View File

@ -822,13 +822,13 @@ are supported. */
a = pcre2_jit_match_32(G(b,32),(PCRE2_SPTR32)c,d,e,f,G(g,32),G(h,32), \
(pcre2_jit_stack_32 *)i)
#define PCRE2_JIT_STACK_ALLOC(a,b,c,d) \
#define PCRE2_JIT_STACK_CREATE(a,b,c,d) \
if (test_mode == PCRE8_MODE) \
a = (PCRE2_JIT_STACK *)pcre2_jit_stack_alloc_8(b,c,d); \
a = (PCRE2_JIT_STACK *)pcre2_jit_stack_create_8(b,c,d); \
else if (test_mode == PCRE16_MODE) \
a = (PCRE2_JIT_STACK *)pcre2_jit_stack_alloc_16(b,c,d); \
a = (PCRE2_JIT_STACK *)pcre2_jit_stack_create_16(b,c,d); \
else \
a = (PCRE2_JIT_STACK *)pcre2_jit_stack_alloc_32(b,c,d);
a = (PCRE2_JIT_STACK *)pcre2_jit_stack_create_32(b,c,d);
#define PCRE2_JIT_STACK_ASSIGN(a,b,c) \
if (test_mode == PCRE8_MODE) \
@ -1200,11 +1200,11 @@ the three different cases. */
a = G(pcre2_jit_match_,BITTWO)(G(b,BITTWO),(G(PCRE2_SPTR,BITTWO))c,d,e,f, \
G(g,BITTWO),G(h,BITTWO),(G(pcre2_jit_stack_,BITTWO) *)i)
#define PCRE2_JIT_STACK_ALLOC(a,b,c,d) \
#define PCRE2_JIT_STACK_CREATE(a,b,c,d) \
if (test_mode == G(G(PCRE,BITONE),_MODE)) \
a = (PCRE2_JIT_STACK *)G(pcre2_jit_stack_alloc_,BITONE)(b,c,d); \
a = (PCRE2_JIT_STACK *)G(pcre2_jit_stack_create_,BITONE)(b,c,d); \
else \
a = (PCRE2_JIT_STACK *)G(pcre2_jit_stack_alloc_,BITTWO)(b,c,d); \
a = (PCRE2_JIT_STACK *)G(pcre2_jit_stack_create_,BITTWO)(b,c,d); \
#define PCRE2_JIT_STACK_ASSIGN(a,b,c) \
if (test_mode == G(G(PCRE,BITONE),_MODE)) \
@ -1447,8 +1447,8 @@ the three different cases. */
#define PCRE2_JIT_MATCH(a,b,c,d,e,f,g,h,(pcre2_jit_stack_8 *)i) \
a = pcre2_jit_match_8(G(b,8),(PCRE2_SPTR8)c,d,e,f,G(g,8),G(h,8), \
(pcre2_jit_stack_8 *)i)
#define PCRE2_JIT_STACK_ALLOC(a,b,c,d) \
a = (PCRE2_JIT_STACK *)pcre2_jit_stack_alloc_8(b,c,d);
#define PCRE2_JIT_STACK_CREATE(a,b,c,d) \
a = (PCRE2_JIT_STACK *)pcre2_jit_stack_create_8(b,c,d);
#define PCRE2_JIT_STACK_ASSIGN(a,b,c) \
pcre2_jit_stack_assign_8(G(a,8),(pcre2_jit_callback_8)b,c);
#define PCRE2_JIT_STACK_FREE(a) pcre2_jit_stack_free_8((pcre2_jit_stack_8 *)a);
@ -1526,8 +1526,8 @@ the three different cases. */
#define PCRE2_JIT_MATCH(a,b,c,d,e,f,g,h,i) \
a = pcre2_jit_match_16(G(b,16),(PCRE2_SPTR16)c,d,e,f,G(g,16),G(h,16), \
(pcre2_jit_stack_16 *)i)
#define PCRE2_JIT_STACK_ALLOC(a,b,c,d) \
a = (PCRE2_JIT_STACK *)pcre2_jit_stack_alloc_16(b,c,d);
#define PCRE2_JIT_STACK_CREATE(a,b,c,d) \
a = (PCRE2_JIT_STACK *)pcre2_jit_stack_create_16(b,c,d);
#define PCRE2_JIT_STACK_ASSIGN(a,b,c) \
pcre2_jit_stack_assign_16(G(a,16),(pcre2_jit_callback_16)b,c);
#define PCRE2_JIT_STACK_FREE(a) pcre2_jit_stack_free_16((pcre2_jit_stack_16 *)a);
@ -1605,8 +1605,8 @@ the three different cases. */
#define PCRE2_JIT_MATCH(a,b,c,d,e,f,g,h,i) \
a = pcre2_jit_match_32(G(b,32),(PCRE2_SPTR32)c,d,e,f,G(g,32),G(h,32), \
(pcre2_jit_stack_32 *)i)
#define PCRE2_JIT_STACK_ALLOC(a,b,c,d) \
a = (PCRE2_JIT_STACK *)pcre2_jit_stack_alloc_32(b,c,d);
#define PCRE2_JIT_STACK_CREATE(a,b,c,d) \
a = (PCRE2_JIT_STACK *)pcre2_jit_stack_create_32(b,c,d);
#define PCRE2_JIT_STACK_ASSIGN(a,b,c) \
pcre2_jit_stack_assign_32(G(a,32),(pcre2_jit_callback_32)b,c);
#define PCRE2_JIT_STACK_FREE(a) pcre2_jit_stack_free_32((pcre2_jit_stack_32 *)a);
@ -4637,7 +4637,7 @@ if (dat_datctl.jitstack != 0)
if (dat_datctl.jitstack != jit_stack_size)
{
PCRE2_JIT_STACK_FREE(jit_stack);
PCRE2_JIT_STACK_ALLOC(jit_stack, NULL, 1, dat_datctl.jitstack * 1024);
PCRE2_JIT_STACK_CREATE(jit_stack, NULL, 1, dat_datctl.jitstack * 1024);
jit_stack_size = dat_datctl.jitstack;
}
PCRE2_JIT_STACK_ASSIGN(compiled_code, jit_callback, jit_stack);

View File

@ -245,6 +245,11 @@ Minimum match limit = 6
0: aabbccddee (JIT)
1: aa
2: cc
3: ee
aabbccddee\=jitstack=1
0: aabbccddee (JIT)
1: aa
2: cc
3: ee
/(a+)*zz/