--- embedaddon/pcre/doc/html/pcreapi.html 2013/07/22 08:25:57 1.1.1.4 +++ embedaddon/pcre/doc/html/pcreapi.html 2014/06/15 19:46:05 1.1.1.5 @@ -46,125 +46,125 @@ man page, in case the conversion went wrong.
PCRE NATIVE API BASIC FUNCTIONS

pcre *pcre_compile(const char *pattern, int options, -const char **errptr, int *erroffset, -const unsigned char *tableptr); -

-

+ const char **errptr, int *erroffset, + const unsigned char *tableptr); +
+
pcre *pcre_compile2(const char *pattern, int options, -int *errorcodeptr, -const char **errptr, int *erroffset, -const unsigned char *tableptr); -

-

+ int *errorcodeptr, + const char **errptr, int *erroffset, + const unsigned char *tableptr); +
+
pcre_extra *pcre_study(const pcre *code, int options, -const char **errptr); -

-

+ const char **errptr); +
+
void pcre_free_study(pcre_extra *extra); -

-

+
+
int pcre_exec(const pcre *code, const pcre_extra *extra, -const char *subject, int length, int startoffset, -int options, int *ovector, int ovecsize); -

-

+ const char *subject, int length, int startoffset, + int options, int *ovector, int ovecsize); +
+
int pcre_dfa_exec(const pcre *code, const pcre_extra *extra, -const char *subject, int length, int startoffset, -int options, int *ovector, int ovecsize, -int *workspace, int wscount); + const char *subject, int length, int startoffset, + int options, int *ovector, int ovecsize, + int *workspace, int wscount);


PCRE NATIVE API STRING EXTRACTION FUNCTIONS

int pcre_copy_named_substring(const pcre *code, -const char *subject, int *ovector, -int stringcount, const char *stringname, -char *buffer, int buffersize); -

-

+ const char *subject, int *ovector, + int stringcount, const char *stringname, + char *buffer, int buffersize); +
+
int pcre_copy_substring(const char *subject, int *ovector, -int stringcount, int stringnumber, char *buffer, -int buffersize); -

-

+ int stringcount, int stringnumber, char *buffer, + int buffersize); +
+
int pcre_get_named_substring(const pcre *code, -const char *subject, int *ovector, -int stringcount, const char *stringname, -const char **stringptr); -

-

+ const char *subject, int *ovector, + int stringcount, const char *stringname, + const char **stringptr); +
+
int pcre_get_stringnumber(const pcre *code, -const char *name); -

-

+ const char *name); +
+
int pcre_get_stringtable_entries(const pcre *code, -const char *name, char **first, char **last); -

-

+ const char *name, char **first, char **last); +
+
int pcre_get_substring(const char *subject, int *ovector, -int stringcount, int stringnumber, -const char **stringptr); -

-

+ int stringcount, int stringnumber, + const char **stringptr); +
+
int pcre_get_substring_list(const char *subject, -int *ovector, int stringcount, const char ***listptr); -

-

+ int *ovector, int stringcount, const char ***listptr); +
+
void pcre_free_substring(const char *stringptr); -

-

+
+
void pcre_free_substring_list(const char **stringptr);


PCRE NATIVE API AUXILIARY FUNCTIONS

int pcre_jit_exec(const pcre *code, const pcre_extra *extra, -const char *subject, int length, int startoffset, -int options, int *ovector, int ovecsize, -pcre_jit_stack *jstack); -

-

+ const char *subject, int length, int startoffset, + int options, int *ovector, int ovecsize, + pcre_jit_stack *jstack); +
+
pcre_jit_stack *pcre_jit_stack_alloc(int startsize, int maxsize); -

-

+
+
void pcre_jit_stack_free(pcre_jit_stack *stack); -

-

+
+
void pcre_assign_jit_stack(pcre_extra *extra, -pcre_jit_callback callback, void *data); -

-

+ pcre_jit_callback callback, void *data); +
+
const unsigned char *pcre_maketables(void); -

-

+
+
int pcre_fullinfo(const pcre *code, const pcre_extra *extra, -int what, void *where); -

-

+ int what, void *where); +
+
int pcre_refcount(pcre *code, int adjust); -

-

+
+
int pcre_config(int what, void *where); -

-

+
+
const char *pcre_version(void); -

-

+
+
int pcre_pattern_to_host_byte_order(pcre *code, -pcre_extra *extra, const unsigned char *tables); + pcre_extra *extra, const unsigned char *tables);


PCRE NATIVE API INDIRECTED FUNCTIONS

void *(*pcre_malloc)(size_t); -

-

+
+
void (*pcre_free)(void *); -

-

+
+
void *(*pcre_stack_malloc)(size_t); -

-

+
+
void (*pcre_stack_free)(void *); -

-

+
+
int (*pcre_callout)(pcre_callout_block *);


PCRE 8-BIT, 16-BIT, AND 32-BIT LIBRARIES
@@ -484,6 +484,13 @@ the pcreposix documentation.
+  PCRE_CONFIG_PARENS_LIMIT
+
+The output is a long integer that gives the maximum depth of nesting of +parentheses (of any kind) in a pattern. This limit is imposed to cap the amount +of system stack used when a pattern is compiled. It is specified when PCRE is +built; the default is 250. +
   PCRE_CONFIG_MATCH_LIMIT
 
The output is a long integer that gives the default limit for the number of @@ -509,12 +516,14 @@ avoiding the use of the stack.
COMPILING A PATTERN

pcre *pcre_compile(const char *pattern, int options, -const char **errptr, int *erroffset, -const unsigned char *tableptr); + const char **errptr, int *erroffset, + const unsigned char *tableptr); +
+
pcre *pcre_compile2(const char *pattern, int options, -int *errorcodeptr, -const char **errptr, int *erroffset, -const unsigned char *tableptr); + int *errorcodeptr, + const char **errptr, int *erroffset, + const unsigned char *tableptr);

Either of the functions pcre_compile() or pcre_compile2() can be @@ -580,8 +589,9 @@ If the final argument, tableptr, is NULL, PCRE character tables that are built when PCRE is compiled, using the default C locale. Otherwise, tableptr must be an address that is the result of a call to pcre_maketables(). This value is stored with the compiled -pattern, and used again by pcre_exec(), unless another table pointer is -passed to it. For more discussion, see the section on locale support below. +pattern, and used again by pcre_exec() and pcre_dfa_exec() when the +pattern is matched. For more discussion, see the section on locale support +below.

This code fragment shows a typical straightforward call to pcre_compile(): @@ -666,14 +676,26 @@ documentation.

   PCRE_EXTENDED
 
-If this bit is set, white space data characters in the pattern are totally -ignored except when escaped or inside a character class. White space does not -include the VT character (code 11). In addition, characters between an -unescaped # outside a character class and the next newline, inclusive, are also -ignored. This is equivalent to Perl's /x option, and it can be changed within a -pattern by a (?x) option setting. +If this bit is set, most white space characters in the pattern are totally +ignored except when escaped or inside a character class. However, white space +is not allowed within sequences such as (?> that introduce various +parenthesized subpatterns, nor within a numerical quantifier such as {1,3}. +However, ignorable white space is permitted between an item and a following +quantifier and between a quantifier and a following + that indicates +possessiveness.

+White space did not used to include the VT character (code 11), because Perl +did not treat this character as white space. However, Perl changed at release +5.18, so PCRE followed at release 8.34, and VT is now treated as white space. +

+

+PCRE_EXTENDED also causes characters between an unescaped # outside a character +class and the next newline, inclusive, to be ignored. PCRE_EXTENDED is +equivalent to Perl's /x option, and it can be changed within a pattern by a +(?x) option setting. +

+

Which characters are interpreted as newlines is controlled by the options passed to pcre_compile() or by a special sequence at the start of the pattern, as described in the section entitled @@ -825,6 +847,15 @@ were followed by ?: but named parentheses can still be they acquire numbers in the usual way). There is no equivalent of this option in Perl.

+  PCRE_NO_AUTO_POSSESS
+
+If this option is set, it disables "auto-possessification". This is an +optimization that, for example, turns a+b into a++b in order to avoid +backtracks into a+ that can never be successful. However, if callouts are in +use, auto-possessification means that some of them are never taken. You can set +this option if you want the matching functions to do a full unoptimized search +and run all the callouts, but it is mainly provided for testing purposes. +
   PCRE_NO_START_OPTIMIZE
 
This is an option that acts at matching time; that is, it is really an option @@ -875,10 +906,10 @@ page. If an invalid UTF-8 sequence is found, pcre_c 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 pcre_exec() and pcre_dfa_exec(), to suppress the -validity checking of subject strings only. If the same string is being matched -many times, the option can be safely set for the second and subsequent +undefined. It may cause your program to crash or loop. Note that this option +can also be passed to pcre_exec() and pcre_dfa_exec(), to suppress +the validity checking of subject strings only. If the same string is being +matched many times, the option can be safely set for the second and subsequent matchings to improve performance.


COMPILATION ERROR CODES
@@ -923,7 +954,7 @@ have fallen out of use. To avoid confusion, they have 31 POSIX collating elements are not supported 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 + 34 character value in \x{} or \o{} is too large 35 invalid condition (?(0) 36 \C not allowed in lookbehind assertion 37 PCRE does not support \L, \l, \N{name}, \U, or \u @@ -971,14 +1002,20 @@ have fallen out of use. To avoid confusion, they have 75 name is too long in (*MARK), (*PRUNE), (*SKIP), or (*THEN) 76 character value in \u.... sequence is too large 77 invalid UTF-32 string (specifically UTF-32) + 78 setting UTF is disabled by the application + 79 non-hex character in \x{} (closing brace missing?) + 80 non-octal character in \o{} (closing brace missing?) + 81 missing opening brace after \o + 82 parentheses are too deeply nested + 83 invalid range in character class 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.


STUDYING A PATTERN

-pcre_extra *pcre_study(const pcre *code, int options -const char **errptr); +pcre_extra *pcre_study(const pcre *code, int options, + const char **errptr);

If a compiled pattern is going to be used several times, it is worth spending @@ -1101,17 +1138,20 @@ There is a longer discussion of PCRE_NO_START_OPTIMIZE

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. +code point. When running in UTF-8 mode, or in the 16- or 32-bit libraries, this +applies only to characters with code points less than 256. By default, +higher-valued code points never match escapes such as \w or \d. However, if +PCRE is built with Unicode property support, all characters can be tested with +\p and \P, or, alternatively, the PCRE_UCP option can be set when a pattern +is compiled; this causes \w and friends to use Unicode property support +instead of the built-in tables.

+The use of locales with Unicode is discouraged. If you are handling characters +with code points greater than 128, you should either use Unicode support, or +use locales, but not try to mix the two. +

+

PCRE contains an internal set of tables that are used when the final argument of pcre_compile() is NULL. These are sufficient for many applications. Normally, the internal tables recognize only ASCII characters. However, when @@ -1127,10 +1167,10 @@ for this locale support is expected to die away.

External tables are built by calling the pcre_maketables() function, which has no arguments, in the relevant locale. The result can then be passed -to pcre_compile() or pcre_exec() as often as necessary. For -example, to build and use tables that are appropriate for the French locale -(where accented characters with values greater than 128 are treated as letters), -the following code could be used: +to pcre_compile() as often as necessary. For example, to build and use +tables that are appropriate for the French locale (where accented characters +with values greater than 128 are treated as letters), the following code could +be used:

   setlocale(LC_CTYPE, "fr_FR");
   tables = pcre_maketables();
@@ -1148,21 +1188,25 @@ needed.
 

The pointer that is passed to pcre_compile() is saved with the compiled pattern, and the same tables are used via this pointer by pcre_study() -and normally also by pcre_exec(). Thus, by default, for any single +and also by pcre_exec() and pcre_dfa_exec(). Thus, for any single pattern, compilation, studying and matching all happen in the same locale, but -different patterns can be compiled in different locales. +different patterns can be processed in different locales.

It is possible to pass a table pointer or NULL (indicating the use of the -internal tables) to pcre_exec(). Although not intended for this purpose, -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. +internal tables) to pcre_exec() or pcre_dfa_exec() (see the +discussion below in the section on matching a pattern). This facility is +provided for use with pre-compiled patterns that have been saved and reloaded. +Character tables are not saved with patterns, so if a non-standard table was +used at compile time, it must be provided again when the reloaded pattern is +matched. Attempting to use this facility to match a pattern in a different +locale from the one in which it was compiled is likely to lead to anomalous +(usually incorrect) results.


INFORMATION ABOUT A PATTERN

int pcre_fullinfo(const pcre *code, const pcre_extra *extra, -int what, void *where); + int what, void *where);

The pcre_fullinfo() function returns information about a compiled @@ -1303,10 +1347,15 @@ is -1.

Since for the 32-bit library using the non-UTF-32 mode, this function is unable -to return the full 32-bit range of the character, this value is deprecated; +to return the full 32-bit range of characters, this value is deprecated; instead the PCRE_INFO_REQUIREDCHARFLAGS and PCRE_INFO_REQUIREDCHAR values should be used.

+  PCRE_INFO_MATCH_EMPTY
+
+Return 1 if the pattern can match an empty string, otherwise 0. The fourth +argument should point to an int variable. +
   PCRE_INFO_MATCHLIMIT
 
If the pattern set a match limit by including an item of the form @@ -1364,16 +1413,18 @@ contains the parenthesis number. The rest of the entry name, zero terminated.

-The names are in alphabetical order. Duplicate names may appear if (?| is used -to create multiple groups with the same number, as described in the +The names are in alphabetical order. If (?| is used to create multiple groups +with the same number, as described in the section on duplicate subpattern numbers in the pcrepattern -page. Duplicate names for subpatterns with different numbers are permitted only -if PCRE_DUPNAMES is set. In all cases of duplicate names, they appear in the -table in the order in which they were found in the pattern. In the absence of -(?| this is the order of increasing number; when (?| is used this is not -necessarily the case because later subpatterns may have lower numbers. +page, the groups may be given the same name, but there is only one entry in the +table. Different names for groups of the same number are not permitted. +Duplicate names for subpatterns with different numbers are permitted, +but only if PCRE_DUPNAMES is set. They appear in the table in the order in +which they were found in the pattern. In the absence of (?| this is the order +of increasing number; when (?| is used this is not necessarily the case because +later subpatterns may have lower numbers.

As a simple example of the name/number table, consider the following pattern @@ -1487,30 +1538,14 @@ returned. For anchored patterns, 0 is returned.

   PCRE_INFO_FIRSTCHARACTER
 
-Return the fixed first character value, if PCRE_INFO_FIRSTCHARACTERFLAGS -returned 1; otherwise returns 0. The fourth argument should point to an -uint_t variable. +Return the fixed first character value in the situation where +PCRE_INFO_FIRSTCHARACTERFLAGS returns 1; otherwise return 0. The fourth +argument should point to an uint_t variable.

In the 8-bit library, the value is always less than 256. In the 16-bit library the value can be up to 0xffff. In the 32-bit library in UTF-32 mode the value can be up to 0x10ffff, and up to 0xffffffff when not using UTF-32 mode. -

-

-If there is no fixed first value, and if either -
-
-(a) the pattern was compiled with the PCRE_MULTILINE option, and every branch -starts with "^", or -
-
-(b) every branch of the pattern starts with ".*" and PCRE_DOTALL is not set -(if it were set, the pattern would be anchored), -
-
--1 is returned, indicating that the pattern matches only at the start of a -subject string or after any newline within the string. Otherwise -2 is -returned. For anchored patterns, -2 is returned.

   PCRE_INFO_REQUIREDCHARFLAGS
 
@@ -1559,8 +1594,8 @@ is different. (This seems a highly unlikely scenario.)
MATCHING A PATTERN: THE TRADITIONAL FUNCTION

int pcre_exec(const pcre *code, const pcre_extra *extra, -const char *subject, int length, int startoffset, -int options, int *ovector, int ovecsize); + const char *subject, int length, int startoffset, + int options, int *ovector, int ovecsize);

The function pcre_exec() is called to match a subject string against a @@ -1723,19 +1758,24 @@ and is described in the documentation.

-The tables field is used to pass a character tables pointer to -pcre_exec(); this overrides the value that is stored with the compiled -pattern. A non-NULL value is stored with the compiled pattern only if custom -tables were supplied to pcre_compile() via its tableptr argument. -If NULL is passed to pcre_exec() using this mechanism, it forces PCRE's -internal tables to be used. This facility is helpful when re-using patterns -that have been saved after compiling with an external set of tables, because -the external tables might be at a different address when pcre_exec() is -called. See the +The tables field is provided for use with patterns that have been +pre-compiled using custom character tables, saved to disc or elsewhere, and +then reloaded, because the tables that were used to compile a pattern are not +saved with it. See the pcreprecompile -documentation for a discussion of saving compiled patterns for later use. +documentation for a discussion of saving compiled patterns for later use. If +NULL is passed using this mechanism, it forces PCRE's internal tables to be +used.

+Warning: The tables that pcre_exec() uses must be the same as those +that were used when the pattern was compiled. If this is not the case, the +behaviour of pcre_exec() is undefined. Therefore, when a pattern is +compiled and matched in the same process, this field should never be set. In +this (the most common) case, the correct table pointer is automatically passed +with the compiled pattern from pcre_compile() to pcre_exec(). +

+

If PCRE_EXTRA_MARK is set in the flags field, the mark field must 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 @@ -1951,7 +1991,7 @@ all the matches in a single subject string. However, y the value of startoffset 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 startoffset is -undefined. Your program may crash. +undefined. Your program may crash or loop.

   PCRE_PARTIAL_HARD
   PCRE_PARTIAL_SOFT
@@ -2413,17 +2453,17 @@ no longer in use and is never returned.
 
EXTRACTING CAPTURED SUBSTRINGS BY NUMBER

int pcre_copy_substring(const char *subject, int *ovector, -int stringcount, int stringnumber, char *buffer, -int buffersize); -

-

+ int stringcount, int stringnumber, char *buffer, + int buffersize); +
+
int pcre_get_substring(const char *subject, int *ovector, -int stringcount, int stringnumber, -const char **stringptr); -

-

+ int stringcount, int stringnumber, + const char **stringptr); +
+
int pcre_get_substring_list(const char *subject, -int *ovector, int stringcount, const char ***listptr); + int *ovector, int stringcount, const char ***listptr);

Captured substrings can be accessed directly by using the offsets returned by @@ -2508,19 +2548,19 @@ provided.
EXTRACTING CAPTURED SUBSTRINGS BY NAME

int pcre_get_stringnumber(const pcre *code, -const char *name); -

-

+ const char *name); +
+
int pcre_copy_named_substring(const pcre *code, -const char *subject, int *ovector, -int stringcount, const char *stringname, -char *buffer, int buffersize); -

-

+ const char *subject, int *ovector, + int stringcount, const char *stringname, + char *buffer, int buffersize); +
+
int pcre_get_named_substring(const pcre *code, -const char *subject, int *ovector, -int stringcount, const char *stringname, -const char **stringptr); + const char *subject, int *ovector, + int stringcount, const char *stringname, + const char **stringptr);

To extract a substring by name, you first have to find associated number. @@ -2572,7 +2612,7 @@ same number causes an error at compile time.
DUPLICATE SUBPATTERN NAMES

int pcre_get_stringtable_entries(const pcre *code, -const char *name, char **first, char **last); + const char *name, char **first, char **last);

When a pattern is compiled with the PCRE_DUPNAMES option, names for subpatterns @@ -2653,9 +2693,9 @@ the value returned is the size of each block that is o
MATCHING A PATTERN: THE ALTERNATIVE FUNCTION

int pcre_dfa_exec(const pcre *code, const pcre_extra *extra, -const char *subject, int length, int startoffset, -int options, int *ovector, int ovecsize, -int *workspace, int wscount); + const char *subject, int length, int startoffset, + int options, int *ovector, int ovecsize, + int *workspace, int wscount);

The function pcre_dfa_exec() is called to match a subject string against @@ -2784,6 +2824,15 @@ matching string is given first. If there were too many the longest matches. Unlike pcre_exec(), pcre_dfa_exec() can use the entire ovector for returning matched strings.

+

+NOTE: PCRE's "auto-possessification" optimization usually applies to character +repeats at the end of a pattern (as well as internally). For example, the +pattern "a\d+" is compiled as if it were "a\d++" because there is no point +even considering the possibility of backtracking into the repeated digits. For +DFA matching, this means that only one possible match is found. If you really +do want multiple matches in such cases, either use an ungreedy repeat +("a\d+?") or set the PCRE_NO_AUTO_POSSESS option when compiling. +


Error returns from pcre_dfa_exec()
@@ -2850,7 +2899,7 @@ Cambridge CB2 3QH, England.


REVISION

-Last updated: 12 May 2013 +Last updated: 12 November 2013
Copyright © 1997-2013 University of Cambridge.