summaryrefslogtreecommitdiff
path: root/doc/html/pcreapi.html
diff options
context:
space:
mode:
authorph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2012-01-14 11:16:23 +0000
committerph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2012-01-14 11:16:23 +0000
commit57607b5518c705150a68606724fb875c7ba2686f (patch)
tree50d07ccc0c6d9e7698ea7ddef24bc333d7f58d11 /doc/html/pcreapi.html
parent36aa4021b0390d7727d5e1b11aac2fc87765792a (diff)
downloadpcre-57607b5518c705150a68606724fb875c7ba2686f.tar.gz
Bring HTML docs up to date.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@869 2f5784b3-3f2a-0410-8824-cb99058d5e15
Diffstat (limited to 'doc/html/pcreapi.html')
-rw-r--r--doc/html/pcreapi.html461
1 files changed, 258 insertions, 203 deletions
diff --git a/doc/html/pcreapi.html b/doc/html/pcreapi.html
index 3cbb6be..e4566a3 100644
--- a/doc/html/pcreapi.html
+++ b/doc/html/pcreapi.html
@@ -14,34 +14,35 @@ man page, in case the conversion went wrong.
<br>
<ul>
<li><a name="TOC1" href="#SEC1">PCRE NATIVE API BASIC FUNCTIONS</a>
-<li><a name="TOC2" href="#SEC2">PCRE NATIVE API AUXILIARY FUNCTIONS</a>
-<li><a name="TOC3" href="#SEC3">PCRE NATIVE API INDIRECTED FUNCTIONS</a>
-<li><a name="TOC4" href="#SEC4">PCRE API OVERVIEW</a>
-<li><a name="TOC5" href="#SEC5">NEWLINES</a>
-<li><a name="TOC6" href="#SEC6">MULTITHREADING</a>
-<li><a name="TOC7" href="#SEC7">SAVING PRECOMPILED PATTERNS FOR LATER USE</a>
-<li><a name="TOC8" href="#SEC8">CHECKING BUILD-TIME OPTIONS</a>
-<li><a name="TOC9" href="#SEC9">COMPILING A PATTERN</a>
-<li><a name="TOC10" href="#SEC10">COMPILATION ERROR CODES</a>
-<li><a name="TOC11" href="#SEC11">STUDYING A PATTERN</a>
-<li><a name="TOC12" href="#SEC12">LOCALE SUPPORT</a>
-<li><a name="TOC13" href="#SEC13">INFORMATION ABOUT A PATTERN</a>
-<li><a name="TOC14" href="#SEC14">OBSOLETE INFO FUNCTION</a>
-<li><a name="TOC15" href="#SEC15">REFERENCE COUNTS</a>
-<li><a name="TOC16" href="#SEC16">MATCHING A PATTERN: THE TRADITIONAL FUNCTION</a>
-<li><a name="TOC17" href="#SEC17">EXTRACTING CAPTURED SUBSTRINGS BY NUMBER</a>
-<li><a name="TOC18" href="#SEC18">EXTRACTING CAPTURED SUBSTRINGS BY NAME</a>
-<li><a name="TOC19" href="#SEC19">DUPLICATE SUBPATTERN NAMES</a>
-<li><a name="TOC20" href="#SEC20">FINDING ALL POSSIBLE MATCHES</a>
-<li><a name="TOC21" href="#SEC21">MATCHING A PATTERN: THE ALTERNATIVE FUNCTION</a>
-<li><a name="TOC22" href="#SEC22">SEE ALSO</a>
-<li><a name="TOC23" href="#SEC23">AUTHOR</a>
-<li><a name="TOC24" href="#SEC24">REVISION</a>
+<li><a name="TOC2" href="#SEC2">PCRE NATIVE API STRING EXTRACTION FUNCTIONS</a>
+<li><a name="TOC3" href="#SEC3">PCRE NATIVE API AUXILIARY FUNCTIONS</a>
+<li><a name="TOC4" href="#SEC4">PCRE NATIVE API INDIRECTED FUNCTIONS</a>
+<li><a name="TOC5" href="#SEC5">PCRE 8-BIT AND 16-BIT LIBRARIES</a>
+<li><a name="TOC6" href="#SEC6">PCRE API OVERVIEW</a>
+<li><a name="TOC7" href="#SEC7">NEWLINES</a>
+<li><a name="TOC8" href="#SEC8">MULTITHREADING</a>
+<li><a name="TOC9" href="#SEC9">SAVING PRECOMPILED PATTERNS FOR LATER USE</a>
+<li><a name="TOC10" href="#SEC10">CHECKING BUILD-TIME OPTIONS</a>
+<li><a name="TOC11" href="#SEC11">COMPILING A PATTERN</a>
+<li><a name="TOC12" href="#SEC12">COMPILATION ERROR CODES</a>
+<li><a name="TOC13" href="#SEC13">STUDYING A PATTERN</a>
+<li><a name="TOC14" href="#SEC14">LOCALE SUPPORT</a>
+<li><a name="TOC15" href="#SEC15">INFORMATION ABOUT A PATTERN</a>
+<li><a name="TOC16" href="#SEC16">REFERENCE COUNTS</a>
+<li><a name="TOC17" href="#SEC17">MATCHING A PATTERN: THE TRADITIONAL FUNCTION</a>
+<li><a name="TOC18" href="#SEC18">EXTRACTING CAPTURED SUBSTRINGS BY NUMBER</a>
+<li><a name="TOC19" href="#SEC19">EXTRACTING CAPTURED SUBSTRINGS BY NAME</a>
+<li><a name="TOC20" href="#SEC20">DUPLICATE SUBPATTERN NAMES</a>
+<li><a name="TOC21" href="#SEC21">FINDING ALL POSSIBLE MATCHES</a>
+<li><a name="TOC22" href="#SEC22">MATCHING A PATTERN: THE ALTERNATIVE FUNCTION</a>
+<li><a name="TOC23" href="#SEC23">SEE ALSO</a>
+<li><a name="TOC24" href="#SEC24">AUTHOR</a>
+<li><a name="TOC25" href="#SEC25">REVISION</a>
</ul>
-<br><a name="SEC1" href="#TOC1">PCRE NATIVE API BASIC FUNCTIONS</a><br>
<P>
<b>#include &#60;pcre.h&#62;</b>
</P>
+<br><a name="SEC1" href="#TOC1">PCRE NATIVE API BASIC FUNCTIONS</a><br>
<P>
<b>pcre *pcre_compile(const char *<i>pattern</i>, int <i>options</i>,</b>
<b>const char **<i>errptr</i>, int *<i>erroffset</i>,</b>
@@ -65,23 +66,13 @@ man page, in case the conversion went wrong.
<b>const char *<i>subject</i>, int <i>length</i>, int <i>startoffset</i>,</b>
<b>int <i>options</i>, int *<i>ovector</i>, int <i>ovecsize</i>);</b>
</P>
-<br><a name="SEC2" href="#TOC1">PCRE NATIVE API AUXILIARY FUNCTIONS</a><br>
-<P>
-<b>pcre_jit_stack *pcre_jit_stack_alloc(int <i>startsize</i>, int <i>maxsize</i>);</b>
-</P>
-<P>
-<b>void pcre_jit_stack_free(pcre_jit_stack *<i>stack</i>);</b>
-</P>
-<P>
-<b>void pcre_assign_jit_stack(pcre_extra *<i>extra</i>,</b>
-<b>pcre_jit_callback <i>callback</i>, void *<i>data</i>);</b>
-</P>
<P>
<b>int pcre_dfa_exec(const pcre *<i>code</i>, const pcre_extra *<i>extra</i>,</b>
<b>const char *<i>subject</i>, int <i>length</i>, int <i>startoffset</i>,</b>
<b>int <i>options</i>, int *<i>ovector</i>, int <i>ovecsize</i>,</b>
<b>int *<i>workspace</i>, int <i>wscount</i>);</b>
</P>
+<br><a name="SEC2" href="#TOC1">PCRE NATIVE API STRING EXTRACTION FUNCTIONS</a><br>
<P>
<b>int pcre_copy_named_substring(const pcre *<i>code</i>,</b>
<b>const char *<i>subject</i>, int *<i>ovector</i>,</b>
@@ -122,6 +113,17 @@ man page, in case the conversion went wrong.
<P>
<b>void pcre_free_substring_list(const char **<i>stringptr</i>);</b>
</P>
+<br><a name="SEC3" href="#TOC1">PCRE NATIVE API AUXILIARY FUNCTIONS</a><br>
+<P>
+<b>pcre_jit_stack *pcre_jit_stack_alloc(int <i>startsize</i>, int <i>maxsize</i>);</b>
+</P>
+<P>
+<b>void pcre_jit_stack_free(pcre_jit_stack *<i>stack</i>);</b>
+</P>
+<P>
+<b>void pcre_assign_jit_stack(pcre_extra *<i>extra</i>,</b>
+<b>pcre_jit_callback <i>callback</i>, void *<i>data</i>);</b>
+</P>
<P>
<b>const unsigned char *pcre_maketables(void);</b>
</P>
@@ -130,19 +132,19 @@ man page, in case the conversion went wrong.
<b>int <i>what</i>, void *<i>where</i>);</b>
</P>
<P>
-<b>int pcre_info(const pcre *<i>code</i>, int *<i>optptr</i>, int</b>
-<b>*<i>firstcharptr</i>);</b>
-</P>
-<P>
<b>int pcre_refcount(pcre *<i>code</i>, int <i>adjust</i>);</b>
</P>
<P>
<b>int pcre_config(int <i>what</i>, void *<i>where</i>);</b>
</P>
<P>
-<b>char *pcre_version(void);</b>
+<b>const char *pcre_version(void);</b>
+</P>
+<P>
+<b>int pcre_pattern_to_host_byte_order(pcre *<i>code</i>,</b>
+<b>pcre_extra *<i>extra</i>, const unsigned char *<i>tables</i>);</b>
</P>
-<br><a name="SEC3" href="#TOC1">PCRE NATIVE API INDIRECTED FUNCTIONS</a><br>
+<br><a name="SEC4" href="#TOC1">PCRE NATIVE API INDIRECTED FUNCTIONS</a><br>
<P>
<b>void *(*pcre_malloc)(size_t);</b>
</P>
@@ -158,25 +160,51 @@ man page, in case the conversion went wrong.
<P>
<b>int (*pcre_callout)(pcre_callout_block *);</b>
</P>
-<br><a name="SEC4" href="#TOC1">PCRE API OVERVIEW</a><br>
+<br><a name="SEC5" href="#TOC1">PCRE 8-BIT AND 16-BIT LIBRARIES</a><br>
+<P>
+From release 8.30, PCRE can be compiled as a library for handling 16-bit
+character strings as well as, or instead of, the original library that handles
+8-bit character strings. To avoid too much complication, this document
+describes the 8-bit versions of the functions, with only occasional references
+to the 16-bit library.
+</P>
+<P>
+The 16-bit functions operate in the same way as their 8-bit counterparts; they
+just use different data types for their arguments and results, and their names
+start with <b>pcre16_</b> instead of <b>pcre_</b>. For every option that has UTF8
+in its name (for example, PCRE_UTF8), there is a corresponding 16-bit name with
+UTF8 replaced by UTF16. This facility is in fact just cosmetic; the 16-bit
+option names define the same bit values.
+</P>
+<P>
+References to bytes and UTF-8 in this document should be read as references to
+16-bit data quantities and UTF-16 when using the 16-bit library, unless
+specified otherwise. More details of the specific differences for the 16-bit
+library are given in the
+<a href="pcre16.html"><b>pcre16</b></a>
+page.
+</P>
+<br><a name="SEC6" href="#TOC1">PCRE API OVERVIEW</a><br>
<P>
PCRE has its own native API, which is described in this document. There are
-also some wrapper functions that correspond to the POSIX regular expression
-API, but they do not give access to all the functionality. They are described
-in the
+also some wrapper functions (for the 8-bit library only) that correspond to the
+POSIX regular expression API, but they do not give access to all the
+functionality. They are described in the
<a href="pcreposix.html"><b>pcreposix</b></a>
documentation. Both of these APIs define a set of C function calls. A C++
-wrapper is also distributed with PCRE. It is documented in the
+wrapper (again for the 8-bit library only) is also distributed with PCRE. It is
+documented in the
<a href="pcrecpp.html"><b>pcrecpp</b></a>
page.
</P>
<P>
The native API C function prototypes are defined in the header file
-<b>pcre.h</b>, and on Unix systems the library itself is called <b>libpcre</b>.
-It can normally be accessed by adding <b>-lpcre</b> to the command for linking
-an application that uses PCRE. The header file defines the macros PCRE_MAJOR
-and PCRE_MINOR to contain the major and minor release numbers for the library.
-Applications can use these to include support for different releases of PCRE.
+<b>pcre.h</b>, and on Unix-like systems the (8-bit) library itself is called
+<b>libpcre</b>. It can normally be accessed by adding <b>-lpcre</b> to the
+command for linking an application that uses PCRE. The header file defines the
+macros PCRE_MAJOR and PCRE_MINOR to contain the major and minor release numbers
+for the library. Applications can use these to include support for different
+releases of PCRE.
</P>
<P>
In a Windows environment, if you want to statically link an application program
@@ -244,10 +272,8 @@ internal tables that are generated when PCRE is built are used.
</P>
<P>
The function <b>pcre_fullinfo()</b> is used to find out information about a
-compiled pattern; <b>pcre_info()</b> is an obsolete version that returns only
-some of the available information, but is retained for backwards compatibility.
-The function <b>pcre_version()</b> returns a pointer to a string containing the
-version of PCRE and its date of release.
+compiled pattern. The function <b>pcre_version()</b> returns a pointer to a
+string containing the version of PCRE and its date of release.
</P>
<P>
The function <b>pcre_refcount()</b> maintains a reference count in a data block
@@ -284,7 +310,7 @@ points during a matching operation. Details are given in the
<a href="pcrecallout.html"><b>pcrecallout</b></a>
documentation.
<a name="newlines"></a></P>
-<br><a name="SEC5" href="#TOC1">NEWLINES</a><br>
+<br><a name="SEC7" href="#TOC1">NEWLINES</a><br>
<P>
PCRE supports five different conventions for indicating line breaks in
strings: a single CR (carriage return) character, a single LF (linefeed)
@@ -323,7 +349,7 @@ The choice of newline convention does not affect the interpretation of
the \n or \r escape sequences, nor does it affect what \R matches, which is
controlled in a similar way, but by separate options.
</P>
-<br><a name="SEC6" href="#TOC1">MULTITHREADING</a><br>
+<br><a name="SEC8" href="#TOC1">MULTITHREADING</a><br>
<P>
The PCRE functions can be used in multi-threading applications, with the
proviso that the memory management functions pointed to by <b>pcre_malloc</b>,
@@ -340,17 +366,18 @@ memory stack areas for each thread. See the
<a href="pcrejit.html"><b>pcrejit</b></a>
documentation for more details.
</P>
-<br><a name="SEC7" href="#TOC1">SAVING PRECOMPILED PATTERNS FOR LATER USE</a><br>
+<br><a name="SEC9" href="#TOC1">SAVING PRECOMPILED PATTERNS FOR LATER USE</a><br>
<P>
The compiled form of a regular expression can be saved and re-used at a later
time, possibly by a different program, and even on a host other than the one on
which it was compiled. Details are given in the
<a href="pcreprecompile.html"><b>pcreprecompile</b></a>
-documentation. However, compiling a regular expression with one version of PCRE
-for use with a different version is not guaranteed to work and may cause
-crashes.
+documentation, which includes a description of the
+<b>pcre_pattern_to_host_byte_order()</b> function. However, compiling a regular
+expression with one version of PCRE for use with a different version is not
+guaranteed to work and may cause crashes.
</P>
-<br><a name="SEC8" href="#TOC1">CHECKING BUILD-TIME OPTIONS</a><br>
+<br><a name="SEC10" href="#TOC1">CHECKING BUILD-TIME OPTIONS</a><br>
<P>
<b>int pcre_config(int <i>what</i>, void *<i>where</i>);</b>
</P>
@@ -363,12 +390,22 @@ documentation has more details about these optional features.
<P>
The first argument for <b>pcre_config()</b> is an integer, specifying which
information is required; the second argument is a pointer to a variable into
-which the information is placed. The following information is available:
+which the information is placed. The returned value is zero on success, or the
+negative error code PCRE_ERROR_BADOPTION if the value in the first argument is
+not recognized. The following information is available:
<pre>
PCRE_CONFIG_UTF8
</pre>
The output is an integer that is set to one if UTF-8 support is available;
-otherwise it is set to zero.
+otherwise it is set to zero. If this option is given to the 16-bit version of
+this function, <b>pcre16_config()</b>, the result is PCRE_ERROR_BADOPTION.
+<pre>
+ PCRE_CONFIG_UTF16
+</pre>
+The output is an integer that is set to one if UTF-16 support is available;
+otherwise it is set to zero. This value should normally be given to the 16-bit
+version of this function, <b>pcre16_config()</b>. If it is given to the 8-bit
+version of this function, the result is PCRE_ERROR_BADOPTION.
<pre>
PCRE_CONFIG_UNICODE_PROPERTIES
</pre>
@@ -399,10 +436,12 @@ or CRLF. The default can be overridden when a pattern is compiled or matched.
PCRE_CONFIG_LINK_SIZE
</pre>
The output is an integer that contains the number of bytes used for internal
-linkage in compiled regular expressions. The value is 2, 3, or 4. Larger values
-allow larger regular expressions to be compiled, at the expense of slower
-matching. The default value of 2 is sufficient for all but the most massive
-patterns, since it allows the compiled pattern to be up to 64K in size.
+linkage in compiled regular expressions. For the 8-bit library, the value can
+be 2, 3, or 4. For the 16-bit library, the value is either 2 or 4 and is still
+a number of bytes. The default value of 2 is sufficient for all but the most
+massive patterns, since it allows the compiled pattern to be up to 64K in size.
+Larger values allow larger regular expressions to be compiled, at the expense
+of slower matching.
<pre>
PCRE_CONFIG_POSIX_MALLOC_THRESHOLD
</pre>
@@ -434,7 +473,7 @@ of recursive function calls. In this case, <b>pcre_stack_malloc</b> and
<b>pcre_stack_free</b> are called to manage memory blocks on the heap, thus
avoiding the use of the stack.
</P>
-<br><a name="SEC9" href="#TOC1">COMPILING A PATTERN</a><br>
+<br><a name="SEC11" href="#TOC1">COMPILING A PATTERN</a><br>
<P>
<b>pcre *pcre_compile(const char *<i>pattern</i>, int <i>options</i>,</b>
<b>const char **<i>errptr</i>, int *<i>erroffset</i>,</b>
@@ -489,13 +528,13 @@ not try to free it. Normally, the offset from the start of the pattern to the
byte that was being processed when the error was discovered is placed in the
variable pointed to by <i>erroffset</i>, which must not be NULL (if it is, an
immediate error is given). However, for an invalid UTF-8 string, the offset is
-that of the first byte of the failing character. Also, some errors are not
-detected until checks are carried out when the whole pattern has been scanned;
-in these cases the offset passed back is the length of the pattern.
+that of the first byte of the failing character.
</P>
<P>
-Note that the offset is in bytes, not characters, even in UTF-8 mode. It may
-sometimes point into the middle of a UTF-8 character.
+Some errors are not detected until the whole pattern has been scanned; in these
+cases, the offset passed back is the length of the pattern. Note that the
+offset is in bytes, not characters, even in UTF-8 mode. It may sometimes point
+into the middle of a UTF-8 character.
</P>
<P>
If <b>pcre_compile2()</b> is used instead of <b>pcre_compile()</b>, and the
@@ -699,8 +738,8 @@ preceding sequences should be recognized. Setting PCRE_NEWLINE_ANY specifies
that any Unicode newline sequence should be recognized. The Unicode newline
sequences are the three just mentioned, plus the single characters VT (vertical
tab, U+000B), FF (formfeed, U+000C), NEL (next line, U+0085), LS (line
-separator, U+2028), and PS (paragraph separator, U+2029). The last two are
-recognized only in UTF-8 mode.
+separator, U+2028), and PS (paragraph separator, U+2029). For the 8-bit
+library, the last two are recognized only in UTF-8 mode.
</P>
<P>
The newline setting in the options word uses three bits that are treated
@@ -760,34 +799,35 @@ with Perl. It can also be set by a (?U) option setting within the pattern.
PCRE_UTF8
</pre>
This option causes PCRE to regard both the pattern and the subject as strings
-of UTF-8 characters instead of single-byte character strings. However, it is
-available only when PCRE is built to include UTF-8 support. If not, the use
-of this option provokes an error. Details of how this option changes the
-behaviour of PCRE are given in the
+of UTF-8 characters instead of single-byte strings. However, it is available
+only when PCRE is built to include UTF support. If not, the use of this option
+provokes an error. Details of how this option changes the behaviour of PCRE are
+given in the
<a href="pcreunicode.html"><b>pcreunicode</b></a>
page.
<pre>
PCRE_NO_UTF8_CHECK
</pre>
-When PCRE_UTF8 is set, the validity of the pattern as a UTF-8 string is
-automatically checked. There is a discussion about the
-<a href="pcre.html#utf8strings">validity of UTF-8 strings</a>
-in the main
-<a href="pcre.html"><b>pcre</b></a>
-page. If an invalid UTF-8 sequence of bytes is found, <b>pcre_compile()</b>
-returns an error. If you already know that your pattern is valid, and you want
-to skip this check for performance reasons, you can set the PCRE_NO_UTF8_CHECK
-option. When it is set, the effect of passing an invalid UTF-8 string as a
-pattern is undefined. It may cause your program to crash. Note that this option
-can also be passed to <b>pcre_exec()</b> and <b>pcre_dfa_exec()</b>, to suppress
-the UTF-8 validity checking of subject strings.
-</P>
-<br><a name="SEC10" href="#TOC1">COMPILATION ERROR CODES</a><br>
+When PCRE_UTF8 is set, the validity of the pattern as a UTF-8
+string is automatically checked. There is a discussion about the
+<a href="pcreunicode.html#utf8strings">validity of UTF-8 strings</a>
+in the
+<a href="pcreunicode.html"><b>pcreunicode</b></a>
+page. If an invalid UTF-8 sequence is found, <b>pcre_compile()</b> returns an
+error. If you already know that your pattern is valid, and you want to skip
+this check for performance reasons, you can set the PCRE_NO_UTF8_CHECK option.
+When it is set, the effect of passing an invalid UTF-8 string as a pattern is
+undefined. It may cause your program to crash. Note that this option can also
+be passed to <b>pcre_exec()</b> and <b>pcre_dfa_exec()</b>, to suppress the
+validity checking of subject strings.
+</P>
+<br><a name="SEC12" href="#TOC1">COMPILATION ERROR CODES</a><br>
<P>
The following table lists the error codes than may be returned by
<b>pcre_compile2()</b>, along with the error messages that may be returned by
-both compiling functions. As PCRE has developed, some error codes have fallen
-out of use. To avoid confusion, they have not been re-used.
+both compiling functions. Note that error messages are always 8-bit ASCII
+strings, even in 16-bit mode. As PCRE has developed, some error codes have
+fallen out of use. To avoid confusion, they have not been re-used.
<pre>
0 no error
1 \ at end of pattern
@@ -821,7 +861,7 @@ out of use. To avoid confusion, they have not been re-used.
29 (?R or (?[+-]digits must be followed by )
30 unknown POSIX class name
31 POSIX collating elements are not supported
- 32 this version of PCRE is not compiled with PCRE_UTF8 support
+ 32 this version of PCRE is compiled without UTF support
33 [this code is not in use]
34 character value in \x{...} sequence is too large
35 invalid condition (?(0)
@@ -833,14 +873,14 @@ out of use. To avoid confusion, they have not been re-used.
41 unrecognized character after (?P
42 syntax error in subpattern name (missing terminator)
43 two named subpatterns have the same name
- 44 invalid UTF-8 string
+ 44 invalid UTF-8 string (specifically UTF-8)
45 support for \P, \p, and \X has not been compiled
46 malformed \P or \p sequence
47 unknown property name after \P or \p
48 subpattern name is too long (maximum 32 characters)
49 too many named subpatterns (maximum 10000)
50 [this code is not in use]
- 51 octal value is greater than \377 (not in UTF-8 mode)
+ 51 octal value is greater than \377 in 8-bit non-UTF-8 mode
52 internal error: overran compiling workspace
53 internal error: previously-checked referenced subpattern
not found
@@ -859,14 +899,20 @@ out of use. To avoid confusion, they have not been re-used.
65 different names for subpatterns of the same number are
not allowed
66 (*MARK) must have an argument
- 67 this version of PCRE is not compiled with PCRE_UCP support
+ 67 this version of PCRE is not compiled with Unicode property
+ support
68 \c must be followed by an ASCII character
69 \k is not followed by a braced, angle-bracketed, or quoted name
+ 70 internal error: unknown opcode in find_fixedlength()
+ 71 \N is not supported in a class
+ 72 too many forward references
+ 73 disallowed Unicode code point (&#62;= 0xd800 && &#60;= 0xdfff)
+ 74 invalid UTF-16 string (specifically UTF-16)
</pre>
The numbers 32 and 10000 in errors 48 and 49 are defaults; different values may
be used if the limits were changed when PCRE was built.
<a name="studyingapattern"></a></P>
-<br><a name="SEC11" href="#TOC1">STUDYING A PATTERN</a><br>
+<br><a name="SEC13" href="#TOC1">STUDYING A PATTERN</a><br>
<P>
<b>pcre_extra *pcre_study(const pcre *<i>code</i>, int <i>options</i></b>
<b>const char **<i>errptr</i>);</b>
@@ -958,7 +1004,7 @@ in a calling program via the <b>pcre_fullinfo()</b> function.
Studying a pattern is also useful for non-anchored patterns that do not have a
single fixed starting character. A bitmap of possible starting bytes is
created. This speeds up finding a position in the subject at which to start
-matching.
+matching. (In 16-bit mode, the bitmap is used for 16-bit values less than 256.)
</P>
<P>
These two optimizations apply to both <b>pcre_exec()</b> and
@@ -972,18 +1018,19 @@ to make use of these facilities in cases where matching fails. See the
discussion of PCRE_NO_START_OPTIMIZE
<a href="#execoptions">below.</a>
<a name="localesupport"></a></P>
-<br><a name="SEC12" href="#TOC1">LOCALE SUPPORT</a><br>
+<br><a name="SEC14" href="#TOC1">LOCALE SUPPORT</a><br>
<P>
PCRE handles caseless matching, and determines whether characters are letters,
digits, or whatever, by reference to a set of tables, indexed by character
-value. When running in UTF-8 mode, this applies only to characters with codes
-less than 128. By default, higher-valued codes never match escapes such as \w
-or \d, but they can be tested with \p if PCRE is built with Unicode character
-property support. Alternatively, the PCRE_UCP option can be set at compile
-time; this causes \w and friends to use Unicode property support instead of
-built-in tables. The use of locales with Unicode is discouraged. If you are
-handling characters with codes greater than 128, you should either use UTF-8
-and Unicode, or use locales, but not try to mix the two.
+value. When running in UTF-8 mode, this applies only to characters
+with codes less than 128. By default, higher-valued codes never match escapes
+such as \w or \d, but they can be tested with \p if PCRE is built with
+Unicode character property support. Alternatively, the PCRE_UCP option can be
+set at compile time; this causes \w and friends to use Unicode property
+support instead of built-in tables. The use of locales with Unicode is
+discouraged. If you are handling characters with codes greater than 128, you
+should either use UTF-8 and Unicode, or use locales, but not try to mix the
+two.
</P>
<P>
PCRE contains an internal set of tables that are used when the final argument
@@ -1033,15 +1080,15 @@ this facility could be used to match a pattern in a different locale from the
one in which it was compiled. Passing table pointers at run time is discussed
below in the section on matching a pattern.
<a name="infoaboutpattern"></a></P>
-<br><a name="SEC13" href="#TOC1">INFORMATION ABOUT A PATTERN</a><br>
+<br><a name="SEC15" href="#TOC1">INFORMATION ABOUT A PATTERN</a><br>
<P>
<b>int pcre_fullinfo(const pcre *<i>code</i>, const pcre_extra *<i>extra</i>,</b>
<b>int <i>what</i>, void *<i>where</i>);</b>
</P>
<P>
The <b>pcre_fullinfo()</b> function returns information about a compiled
-pattern. It replaces the obsolete <b>pcre_info()</b> function, which is
-nevertheless retained for backwards compability (and is documented below).
+pattern. It replaces the <b>pcre_info()</b> function, which was removed from the
+library at version 8.30, after more than 10 years of obsolescence.
</P>
<P>
The first argument for <b>pcre_fullinfo()</b> is a pointer to the compiled
@@ -1051,14 +1098,18 @@ information is required, and the fourth argument is a pointer to a variable
to receive the data. The yield of the function is zero for success, or one of
the following negative numbers:
<pre>
- PCRE_ERROR_NULL the argument <i>code</i> was NULL
- the argument <i>where</i> was NULL
- PCRE_ERROR_BADMAGIC the "magic number" was not found
- PCRE_ERROR_BADOPTION the value of <i>what</i> was invalid
+ PCRE_ERROR_NULL the argument <i>code</i> was NULL
+ the argument <i>where</i> was NULL
+ PCRE_ERROR_BADMAGIC the "magic number" was not found
+ PCRE_ERROR_BADENDIANNESS the pattern was compiled with different
+ endianness
+ PCRE_ERROR_BADOPTION the value of <i>what</i> was invalid
</pre>
The "magic number" is placed at the start of each compiled pattern as an simple
-check against passing an arbitrary memory pointer. Here is a typical call of
-<b>pcre_fullinfo()</b>, to obtain the length of the compiled pattern:
+check against passing an arbitrary memory pointer. The endianness error can
+occur if a compiled pattern is saved and reloaded on a different host. Here is
+a typical call of <b>pcre_fullinfo()</b>, to obtain the length of the compiled
+pattern:
<pre>
int rc;
size_t length;
@@ -1092,14 +1143,19 @@ a NULL table pointer.
<pre>
PCRE_INFO_FIRSTBYTE
</pre>
-Return information about the first byte of any matched string, for a
-non-anchored pattern. The fourth argument should point to an <b>int</b>
-variable. (This option used to be called PCRE_INFO_FIRSTCHAR; the old name is
-still recognized for backwards compatibility.)
+Return information about the first data unit of any matched string, for a
+non-anchored pattern. (The name of this option refers to the 8-bit library,
+where data units are bytes.) The fourth argument should point to an <b>int</b>
+variable.
+</P>
+<P>
+If there is a fixed first value, for example, the letter "c" from a pattern
+such as (cat|cow|coyote), its value is returned. In the 8-bit library, the
+value is always less than 256; in the 16-bit library the value can be up to
+0xffff.
</P>
<P>
-If there is a fixed first byte, for example, from a pattern such as
-(cat|cow|coyote), its value is returned. Otherwise, if either
+If there is no fixed first value, and if either
<br>
<br>
(a) the pattern was compiled with the PCRE_MULTILINE option, and every branch
@@ -1117,7 +1173,7 @@ returned. For anchored patterns, -2 is returned.
PCRE_INFO_FIRSTTABLE
</pre>
If the pattern was studied, and this resulted in the construction of a 256-bit
-table indicating a fixed set of bytes for the first byte in any matching
+table indicating a fixed set of values for the first data unit in any matching
string, a pointer to the table is returned. Otherwise NULL is returned. The
fourth argument should point to an <b>unsigned char *</b> variable.
<pre>
@@ -1152,11 +1208,11 @@ argument should point to a <b>size_t</b> variable.
<pre>
PCRE_INFO_LASTLITERAL
</pre>
-Return the value of the rightmost literal byte that must exist in any matched
-string, other than at its start, if such a byte has been recorded. The fourth
-argument should point to an <b>int</b> variable. If there is no such byte, -1 is
-returned. For anchored patterns, a last literal byte is recorded only if it
-follows something of variable length. For example, for the pattern
+Return the value of the rightmost literal data unit that must exist in any
+matched string, other than at its start, if such a value has been recorded. The
+fourth argument should point to an <b>int</b> variable. If there is no such
+value, -1 is returned. For anchored patterns, a last literal value is recorded
+only if it follows something of variable length. For example, for the pattern
/^a\d+z\d+/ the returned value is "z", but for /^a\dz\d/ the returned value
is -1.
<pre>
@@ -1164,8 +1220,8 @@ is -1.
</pre>
If the pattern was studied and a minimum length for matching subject strings
was computed, its value is returned. Otherwise the returned value is -1. The
-value is a number of characters, not bytes (this may be relevant in UTF-8
-mode). The fourth argument should point to an <b>int</b> variable. A
+value is a number of characters, which in UTF-8 mode may be different from the
+number of bytes. The fourth argument should point to an <b>int</b> variable. A
non-negative value is a lower bound to the length of any matching string. There
may not be any strings of that length that do actually match, but every string
that does match is at least that long.
@@ -1189,9 +1245,11 @@ The map consists of a number of fixed-size entries. PCRE_INFO_NAMECOUNT gives
the number of entries, and PCRE_INFO_NAMEENTRYSIZE gives the size of each
entry; both of these return an <b>int</b> value. The entry size depends on the
length of the longest name. PCRE_INFO_NAMETABLE returns a pointer to the first
-entry of the table (a pointer to <b>char</b>). The first two bytes of each entry
-are the number of the capturing parenthesis, most significant byte first. The
-rest of the entry is the corresponding name, zero terminated.
+entry of the table. This is a pointer to <b>char</b> in the 8-bit library, where
+the first two bytes of each entry are the number of the capturing parenthesis,
+most significant byte first. In the 16-bit library, the pointer points to
+16-bit data units, the first of which contains the parenthesis number. The rest
+of the entry is the corresponding name, zero terminated.
</P>
<P>
The names are in alphabetical order. Duplicate names may appear if (?| is used
@@ -1207,8 +1265,8 @@ necessarily the case because later subpatterns may have lower numbers.
</P>
<P>
As a simple example of the name/number table, consider the following pattern
-(assume PCRE_EXTENDED is set, so white space - including newlines - is
-ignored):
+after compilation by the 8-bit library (assume PCRE_EXTENDED is set, so white
+space - including newlines - is ignored):
<pre>
(?&#60;date&#62; (?&#60;year&#62;(\d\d)?\d\d) - (?&#60;month&#62;\d\d) - (?&#60;day&#62;\d\d) )
</pre>
@@ -1258,52 +1316,29 @@ For such patterns, the PCRE_ANCHORED bit is set in the options returned by
<pre>
PCRE_INFO_SIZE
</pre>
-Return the size of the compiled pattern. The fourth argument should point to a
-<b>size_t</b> variable. This value does not include the size of the <b>pcre</b>
-structure that is returned by <b>pcre_compile()</b>. The value that is passed as
-the argument to <b>pcre_malloc()</b> when <b>pcre_compile()</b> is getting memory
-in which to place the compiled data is the value returned by this option plus
-the size of the <b>pcre</b> structure. Studying a compiled pattern, with or
-without JIT, does not alter the value returned by this option.
+Return the size of the compiled pattern in bytes (for both libraries). The
+fourth argument should point to a <b>size_t</b> variable. This value does not
+include the size of the <b>pcre</b> structure that is returned by
+<b>pcre_compile()</b>. The value that is passed as the argument to
+<b>pcre_malloc()</b> when <b>pcre_compile()</b> is getting memory in which to
+place the compiled data is the value returned by this option plus the size of
+the <b>pcre</b> structure. Studying a compiled pattern, with or without JIT,
+does not alter the value returned by this option.
<pre>
PCRE_INFO_STUDYSIZE
</pre>
-Return the size of the data block pointed to by the <i>study_data</i> field in a
-<b>pcre_extra</b> block. If <b>pcre_extra</b> is NULL, or there is no study data,
-zero is returned. The fourth argument should point to a <b>size_t</b> variable.
-The <i>study_data</i> field is set by <b>pcre_study()</b> to record information
-that will speed up matching (see the section entitled
+Return the size in bytes of the data block pointed to by the <i>study_data</i>
+field in a <b>pcre_extra</b> block. If <b>pcre_extra</b> is NULL, or there is no
+study data, zero is returned. The fourth argument should point to a
+<b>size_t</b> variable. The <i>study_data</i> field is set by <b>pcre_study()</b>
+to record information that will speed up matching (see the section entitled
<a href="#studyingapattern">"Studying a pattern"</a>
above). The format of the <i>study_data</i> block is private, but its length
is made available via this option so that it can be saved and restored (see the
<a href="pcreprecompile.html"><b>pcreprecompile</b></a>
documentation for details).
</P>
-<br><a name="SEC14" href="#TOC1">OBSOLETE INFO FUNCTION</a><br>
-<P>
-<b>int pcre_info(const pcre *<i>code</i>, int *<i>optptr</i>, int</b>
-<b>*<i>firstcharptr</i>);</b>
-</P>
-<P>
-The <b>pcre_info()</b> function is now obsolete because its interface is too
-restrictive to return all the available data about a compiled pattern. New
-programs should use <b>pcre_fullinfo()</b> instead. The yield of
-<b>pcre_info()</b> is the number of capturing subpatterns, or one of the
-following negative numbers:
-<pre>
- PCRE_ERROR_NULL the argument <i>code</i> was NULL
- PCRE_ERROR_BADMAGIC the "magic number" was not found
-</pre>
-If the <i>optptr</i> argument is not NULL, a copy of the options with which the
-pattern was compiled is placed in the integer it points to (see
-PCRE_INFO_OPTIONS above).
-</P>
-<P>
-If the pattern is not anchored and the <i>firstcharptr</i> argument is not NULL,
-it is used to pass back information about the first character of any matched
-string (see PCRE_INFO_FIRSTBYTE above).
-</P>
-<br><a name="SEC15" href="#TOC1">REFERENCE COUNTS</a><br>
+<br><a name="SEC16" href="#TOC1">REFERENCE COUNTS</a><br>
<P>
<b>int pcre_refcount(pcre *<i>code</i>, int <i>adjust</i>);</b>
</P>
@@ -1327,7 +1362,7 @@ Except when it is zero, the reference count is not correctly preserved if a
pattern is compiled on one host and then transferred to a host whose byte-order
is different. (This seems a highly unlikely scenario.)
</P>
-<br><a name="SEC16" href="#TOC1">MATCHING A PATTERN: THE TRADITIONAL FUNCTION</a><br>
+<br><a name="SEC17" href="#TOC1">MATCHING A PATTERN: THE TRADITIONAL FUNCTION</a><br>
<P>
<b>int pcre_exec(const pcre *<i>code</i>, const pcre_extra *<i>extra</i>,</b>
<b>const char *<i>subject</i>, int <i>length</i>, int <i>startoffset</i>,</b>
@@ -1392,6 +1427,10 @@ fields (not necessarily in this order):
const unsigned char *<i>tables</i>;
unsigned char **<i>mark</i>;
</pre>
+In the 16-bit version of this structure, the <i>mark</i> field has type
+"PCRE_UCHAR16 **".
+</P>
+<P>
The <i>flags</i> field is a bitmap that specifies which of the other fields
are set. The flag bits are:
<pre>
@@ -1482,13 +1521,13 @@ documentation for a discussion of saving compiled patterns for later use.
</P>
<P>
If PCRE_EXTRA_MARK is set in the <i>flags</i> field, the <i>mark</i> field must
-be set to point to a <b>char *</b> variable. If the pattern contains any
+be set to point to a suitable variable. If the pattern contains any
backtracking control verbs such as (*MARK:NAME), and the execution ends up with
a name to pass back, a pointer to the name string (zero terminated) is placed
in the variable pointed to by the <i>mark</i> field. The names are within the
compiled pattern; if you wish to retain such a name you must copy it before
freeing the memory of a compiled pattern. If there is no name to pass back, the
-variable pointed to by the <i>mark</i> field set to NULL. For details of the
+variable pointed to by the <i>mark</i> field is set to NULL. For details of the
backtracking control verbs, see the section entitled
<a href="pcrepattern#backtrackcontrol">"Backtracking control"</a>
in the
@@ -1671,15 +1710,13 @@ string is automatically checked when <b>pcre_exec()</b> is subsequently called.
The value of <i>startoffset</i> is also checked to ensure that it points to the
start of a UTF-8 character. There is a discussion about the validity of UTF-8
strings in the
-<a href="pcre.html#utf8strings">section on UTF-8 support</a>
-in the main
-<a href="pcre.html"><b>pcre</b></a>
-page. If an invalid UTF-8 sequence of bytes is found, <b>pcre_exec()</b> returns
-the error PCRE_ERROR_BADUTF8 or, if PCRE_PARTIAL_HARD is set and the problem is
-a truncated UTF-8 character at the end of the subject, PCRE_ERROR_SHORTUTF8. In
-both cases, information about the precise nature of the error may also be
-returned (see the descriptions of these errors in the section entitled \fIError
-return values from\fP <b>pcre_exec()</b>
+<a href="pcreunicode.html"><b>pcreunicode</b></a>
+page. If an invalid sequence of bytes is found, <b>pcre_exec()</b> returns the
+error PCRE_ERROR_BADUTF8 or, if PCRE_PARTIAL_HARD is set and the problem is a
+truncated character at the end of the subject, PCRE_ERROR_SHORTUTF8. In both
+cases, information about the precise nature of the error may also be returned
+(see the descriptions of these errors in the section entitled \fIError return
+values from\fP <b>pcre_exec()</b>
<a href="#errorlist">below).</a>
If <i>startoffset</i> contains a value that does not point to the start of a
UTF-8 character (or to the end of the subject), PCRE_ERROR_BADUTF8_OFFSET is
@@ -1691,9 +1728,9 @@ checks for performance reasons, you can set the PCRE_NO_UTF8_CHECK option when
calling <b>pcre_exec()</b>. You might want to do this for the second and
subsequent calls to <b>pcre_exec()</b> if you are making repeated calls to find
all the matches in a single subject string. However, you should be sure that
-the value of <i>startoffset</i> points to the start of a UTF-8 character (or the
-end of the subject). When PCRE_NO_UTF8_CHECK is set, the effect of passing an
-invalid UTF-8 string as a subject or an invalid value of <i>startoffset</i> is
+the value of <i>startoffset</i> points to the start of a character (or the end
+of the subject). When PCRE_NO_UTF8_CHECK is set, the effect of passing an
+invalid string as a subject or an invalid value of <i>startoffset</i> is
undefined. Your program may crash.
<pre>
PCRE_PARTIAL_HARD
@@ -1728,7 +1765,7 @@ The string to be matched by <b>pcre_exec()</b>
</b><br>
<P>
The subject string is passed to <b>pcre_exec()</b> as a pointer in
-<i>subject</i>, a length (in bytes) in <i>length</i>, and a starting byte offset
+<i>subject</i>, a length in bytes in <i>length</i>, and a starting byte offset
in <i>startoffset</i>. If this is negative or greater than the length of the
subject, <b>pcre_exec()</b> returns PCRE_ERROR_BADOFFSET. When the starting
offset is zero, the search for a match starts at the beginning of the subject,
@@ -2027,6 +2064,18 @@ PCRE_STUDY_JIT_COMPILE option is being matched, but the memory available for
the just-in-time processing stack is not large enough. See the
<a href="pcrejit.html"><b>pcrejit</b></a>
documentation for more details.
+<pre>
+ PCRE_ERROR_BADMODE (-28)
+</pre>
+This error is given if a pattern that was compiled by the 8-bit library is
+passed to a 16-bit library function, or vice versa.
+<pre>
+ PCRE_ERROR_BADENDIANNESS (-29)
+</pre>
+This error is given if a pattern that was compiled and saved is reloaded on a
+host with different endianness. The utility function
+<b>pcre_pattern_to_host_byte_order()</b> can be used to convert such a pattern
+so that it runs on the new host.
</P>
<P>
Error numbers -16 to -20 and -22 are not used by <b>pcre_exec()</b>.
@@ -2035,6 +2084,12 @@ Error numbers -16 to -20 and -22 are not used by <b>pcre_exec()</b>.
Reason codes for invalid UTF-8 strings
</b><br>
<P>
+This section applies only to the 8-bit library. The corresponding information
+for the 16-bit library is given in the
+<a href="pcre16.html"><b>pcre16</b></a>
+page.
+</P>
+<P>
When <b>pcre_exec()</b> returns either PCRE_ERROR_BADUTF8 or
PCRE_ERROR_SHORTUTF8, and the size of the output vector (<i>ovecsize</i>) is at
least 2, the offset of the start of the invalid UTF-8 character is placed in
@@ -2104,7 +2159,7 @@ character.
The first byte of a character has the value 0xfe or 0xff. These values can
never occur in a valid UTF-8 string.
</P>
-<br><a name="SEC17" href="#TOC1">EXTRACTING CAPTURED SUBSTRINGS BY NUMBER</a><br>
+<br><a name="SEC18" href="#TOC1">EXTRACTING CAPTURED SUBSTRINGS BY NUMBER</a><br>
<P>
<b>int pcre_copy_substring(const char *<i>subject</i>, int *<i>ovector</i>,</b>
<b>int <i>stringcount</i>, int <i>stringnumber</i>, char *<i>buffer</i>,</b>
@@ -2199,7 +2254,7 @@ linked via a special interface to another programming language that cannot use
<b>pcre_free</b> directly; it is for these cases that the functions are
provided.
</P>
-<br><a name="SEC18" href="#TOC1">EXTRACTING CAPTURED SUBSTRINGS BY NAME</a><br>
+<br><a name="SEC19" href="#TOC1">EXTRACTING CAPTURED SUBSTRINGS BY NAME</a><br>
<P>
<b>int pcre_get_stringnumber(const pcre *<i>code</i>,</b>
<b>const char *<i>name</i>);</b>
@@ -2263,7 +2318,7 @@ names are not included in the compiled code. The matching process uses only
numbers. For this reason, the use of different names for subpatterns of the
same number causes an error at compile time.
</P>
-<br><a name="SEC19" href="#TOC1">DUPLICATE SUBPATTERN NAMES</a><br>
+<br><a name="SEC20" href="#TOC1">DUPLICATE SUBPATTERN NAMES</a><br>
<P>
<b>int pcre_get_stringtable_entries(const pcre *<i>code</i>,</b>
<b>const char *<i>name</i>, char **<i>first</i>, char **<i>last</i>);</b>
@@ -2301,7 +2356,7 @@ described above in the section entitled <i>Information about a pattern</i>
Given all the relevant entries for the name, you can extract each of their
numbers, and hence the captured data, if any.
</P>
-<br><a name="SEC20" href="#TOC1">FINDING ALL POSSIBLE MATCHES</a><br>
+<br><a name="SEC21" href="#TOC1">FINDING ALL POSSIBLE MATCHES</a><br>
<P>
The traditional matching function uses a similar algorithm to Perl, which stops
when it finds the first match, starting at a given point in the subject. If you
@@ -2320,7 +2375,7 @@ substring. Then return 1, which forces <b>pcre_exec()</b> to backtrack and try
other alternatives. Ultimately, when it runs out of matches, <b>pcre_exec()</b>
will yield PCRE_ERROR_NOMATCH.
<a name="dfamatch"></a></P>
-<br><a name="SEC21" href="#TOC1">MATCHING A PATTERN: THE ALTERNATIVE FUNCTION</a><br>
+<br><a name="SEC22" href="#TOC1">MATCHING A PATTERN: THE ALTERNATIVE FUNCTION</a><br>
<P>
<b>int pcre_dfa_exec(const pcre *<i>code</i>, const pcre_extra *<i>extra</i>,</b>
<b>const char *<i>subject</i>, int <i>length</i>, int <i>startoffset</i>,</b>
@@ -2495,13 +2550,13 @@ recursively, using private vectors for <i>ovector</i> and <i>workspace</i>. This
error is given if the output vector is not large enough. This should be
extremely rare, as a vector of size 1000 is used.
</P>
-<br><a name="SEC22" href="#TOC1">SEE ALSO</a><br>
+<br><a name="SEC23" href="#TOC1">SEE ALSO</a><br>
<P>
-<b>pcrebuild</b>(3), <b>pcrecallout</b>(3), <b>pcrecpp(3)</b>(3),
+<b>pcre16</b>(3), <b>pcrebuild</b>(3), <b>pcrecallout</b>(3), <b>pcrecpp(3)</b>(3),
<b>pcrematching</b>(3), <b>pcrepartial</b>(3), <b>pcreposix</b>(3),
<b>pcreprecompile</b>(3), <b>pcresample</b>(3), <b>pcrestack</b>(3).
</P>
-<br><a name="SEC23" href="#TOC1">AUTHOR</a><br>
+<br><a name="SEC24" href="#TOC1">AUTHOR</a><br>
<P>
Philip Hazel
<br>
@@ -2510,11 +2565,11 @@ University Computing Service
Cambridge CB2 3QH, England.
<br>
</P>
-<br><a name="SEC24" href="#TOC1">REVISION</a><br>
+<br><a name="SEC25" href="#TOC1">REVISION</a><br>
<P>
-Last updated: 02 December 2011
+Last updated: 07 January 2012
<br>
-Copyright &copy; 1997-2011 University of Cambridge.
+Copyright &copy; 1997-2012 University of Cambridge.
<br>
<p>
Return to the <a href="index.html">PCRE index page</a>.