--- embedaddon/pcre/doc/html/pcreapi.html 2012/02/21 23:05:52 1.1.1.1 +++ embedaddon/pcre/doc/html/pcreapi.html 2012/02/21 23:50:25 1.1.1.2 @@ -14,34 +14,36 @@ man page, in case the conversion went wrong.
-
PCRE NATIVE API BASIC FUNCTIONS

#include <pcre.h>

+
PCRE NATIVE API BASIC FUNCTIONS

pcre *pcre_compile(const char *pattern, int options, const char **errptr, int *erroffset, @@ -65,23 +67,13 @@ man page, in case the conversion went wrong. const char *subject, int length, int startoffset, int options, int *ovector, int ovecsize);

-
PCRE NATIVE API AUXILIARY FUNCTIONS

-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); -

-

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);

+
PCRE NATIVE API STRING EXTRACTION FUNCTIONS

int pcre_copy_named_substring(const pcre *code, const char *subject, int *ovector, @@ -122,7 +114,18 @@ man page, in case the conversion went wrong.

void pcre_free_substring_list(const char **stringptr);

+
PCRE NATIVE API AUXILIARY FUNCTIONS

+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); +

+

const unsigned char *pcre_maketables(void);

@@ -130,20 +133,20 @@ man page, in case the conversion went wrong. int what, void *where);

-int pcre_info(const pcre *code, int *optptr, int -*firstcharptr); -

-

int pcre_refcount(pcre *code, int adjust);

int pcre_config(int what, void *where);

-char *pcre_version(void); +const char *pcre_version(void);

-
PCRE NATIVE API INDIRECTED FUNCTIONS

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

+
PCRE NATIVE API INDIRECTED FUNCTIONS
+

void *(*pcre_malloc)(size_t);

@@ -158,25 +161,51 @@ man page, in case the conversion went wrong.

int (*pcre_callout)(pcre_callout_block *);

-
PCRE API OVERVIEW
+
PCRE 8-BIT AND 16-BIT LIBRARIES

+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. +

+

+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 pcre16_ instead of pcre_. 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. +

+

+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 +pcre16 +page. +

+
PCRE API OVERVIEW
+

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 pcreposix 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 pcrecpp page.

The native API C function prototypes are defined in the header file -pcre.h, and on Unix systems the library itself is called libpcre. -It can normally be accessed by adding -lpcre 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. +pcre.h, and on Unix-like systems the (8-bit) library itself is called +libpcre. It can normally be accessed by adding -lpcre 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.

In a Windows environment, if you want to statically link an application program @@ -244,10 +273,8 @@ internal tables that are generated when PCRE is built

The function pcre_fullinfo() is used to find out information about a -compiled pattern; pcre_info() is an obsolete version that returns only -some of the available information, but is retained for backwards compatibility. -The function pcre_version() returns a pointer to a string containing the -version of PCRE and its date of release. +compiled pattern. The function pcre_version() returns a pointer to a +string containing the version of PCRE and its date of release.

The function pcre_refcount() maintains a reference count in a data block @@ -284,7 +311,7 @@ points during a matching operation. Details are given pcrecallout documentation.

-
NEWLINES
+
NEWLINES

PCRE supports five different conventions for indicating line breaks in strings: a single CR (carriage return) character, a single LF (linefeed) @@ -323,7 +350,7 @@ The choice of newline convention does not affect the i the \n or \r escape sequences, nor does it affect what \R matches, which is controlled in a similar way, but by separate options.

-
MULTITHREADING
+
MULTITHREADING

The PCRE functions can be used in multi-threading applications, with the proviso that the memory management functions pointed to by pcre_malloc, @@ -340,17 +367,18 @@ memory stack areas for each thread. See the pcrejit documentation for more details.

-
SAVING PRECOMPILED PATTERNS FOR LATER USE
+
SAVING PRECOMPILED PATTERNS FOR LATER USE

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 pcreprecompile -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 +pcre_pattern_to_host_byte_order() 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.

-
CHECKING BUILD-TIME OPTIONS
+
CHECKING BUILD-TIME OPTIONS

int pcre_config(int what, void *where);

@@ -363,13 +391,23 @@ documentation has more details about these optional fe

The first argument for pcre_config() 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:

   PCRE_CONFIG_UTF8
 
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, pcre16_config(), the result is PCRE_ERROR_BADOPTION.
+  PCRE_CONFIG_UTF16
+
+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, pcre16_config(). If it is given to the 8-bit +version of this function, the result is PCRE_ERROR_BADOPTION. +
   PCRE_CONFIG_UNICODE_PROPERTIES
 
The output is an integer that is set to one if support for Unicode character @@ -380,6 +418,13 @@ properties is available; otherwise it is set to zero. The output is an integer that is set to one if support for just-in-time compiling is available; otherwise it is set to zero.
+  PCRE_CONFIG_JITTARGET
+
+The output is a pointer to a zero-terminated "const char *" string. If JIT +support is available, the string contains the name of the architecture for +which the JIT compiler is configured, for example "x86 32bit (little endian + +unaligned)". If JIT support is not available, the result is NULL. +
   PCRE_CONFIG_NEWLINE
 
The output is an integer whose value specifies the default character sequence @@ -399,10 +444,12 @@ or CRLF. The default can be overridden when a pattern PCRE_CONFIG_LINK_SIZE 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.
   PCRE_CONFIG_POSIX_MALLOC_THRESHOLD
 
@@ -434,7 +481,7 @@ of recursive function calls. In this case, pcre_sta pcre_stack_free are called to manage memory blocks on the heap, thus avoiding the use of the stack.

-
COMPILING A PATTERN
+
COMPILING A PATTERN

pcre *pcre_compile(const char *pattern, int options, const char **errptr, int *erroffset, @@ -489,13 +536,13 @@ not try to free it. Normally, the offset from the star byte that was being processed when the error was discovered is placed in the variable pointed to by erroffset, 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.

-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.

If pcre_compile2() is used instead of pcre_compile(), and the @@ -699,8 +746,8 @@ preceding sequences should be recognized. Setting PCRE 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.

The newline setting in the options word uses three bits that are treated @@ -760,34 +807,35 @@ with Perl. It can also be set by a (?U) option setting PCRE_UTF8 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 pcreunicode page.

   PCRE_NO_UTF8_CHECK
 
-When PCRE_UTF8 is set, the validity of the pattern as a UTF-8 string is -automatically checked. There is a discussion about the -validity of UTF-8 strings -in the main -pcre -page. If an invalid UTF-8 sequence of bytes is found, pcre_compile() -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 pcre_exec() and pcre_dfa_exec(), to suppress -the UTF-8 validity checking of subject strings. +When PCRE_UTF8 is set, the validity of the pattern as a UTF-8 +string is automatically checked. There is a discussion about the +validity of UTF-8 strings +in the +pcreunicode +page. If an invalid UTF-8 sequence is found, pcre_compile() 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 pcre_exec() and pcre_dfa_exec(), to suppress the +validity checking of subject strings.

-
COMPILATION ERROR CODES
+
COMPILATION ERROR CODES

The following table lists the error codes than may be returned by pcre_compile2(), 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.

    0  no error
    1  \ at end of pattern
@@ -821,7 +869,7 @@ out of use. To avoid confusion, they have not been re-
   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 +881,14 @@ out of use. To avoid confusion, they have not been re-
   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 +907,20 @@ out of use. To avoid confusion, they have not been re-
   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 (>= 0xd800 && <= 0xdfff)
+  74  invalid UTF-16 string (specifically UTF-16)
 
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
+
STUDYING A PATTERN

pcre_extra *pcre_study(const pcre *code, int options const char **errptr); @@ -958,7 +1012,7 @@ in a calling program via the pcre_fullinfo() fu 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.)

These two optimizations apply to both pcre_exec() and @@ -972,18 +1026,19 @@ to make use of these facilities in cases where matchin discussion of PCRE_NO_START_OPTIMIZE below.

-
LOCALE SUPPORT
+
LOCALE SUPPORT

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.

PCRE contains an internal set of tables that are used when the final argument @@ -1033,15 +1088,15 @@ this facility could be used to match a pattern in a di one in which it was compiled. Passing table pointers at run time is discussed below in the section on matching a pattern.

-
INFORMATION ABOUT A PATTERN
+
INFORMATION ABOUT A PATTERN

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

The pcre_fullinfo() function returns information about a compiled -pattern. It replaces the obsolete pcre_info() function, which is -nevertheless retained for backwards compability (and is documented below). +pattern. It replaces the pcre_info() function, which was removed from the +library at version 8.30, after more than 10 years of obsolescence.

The first argument for pcre_fullinfo() is a pointer to the compiled @@ -1051,14 +1106,18 @@ information is required, and the fourth argument is a to receive the data. The yield of the function is zero for success, or one of the following negative numbers:

-  PCRE_ERROR_NULL       the argument code was NULL
-                        the argument where was NULL
-  PCRE_ERROR_BADMAGIC   the "magic number" was not found
-  PCRE_ERROR_BADOPTION  the value of what was invalid
+  PCRE_ERROR_NULL           the argument code was NULL
+                            the argument where 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 what was invalid
 
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 -pcre_fullinfo(), 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 pcre_fullinfo(), to obtain the length of the compiled +pattern:
   int rc;
   size_t length;
@@ -1092,14 +1151,19 @@ a NULL table pointer.
 
   PCRE_INFO_FIRSTBYTE
 
-Return information about the first byte of any matched string, for a -non-anchored pattern. The fourth argument should point to an int -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 int +variable.

-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 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. +

+

+If there is no fixed first value, and if either

(a) the pattern was compiled with the PCRE_MULTILINE option, and every branch @@ -1117,7 +1181,7 @@ returned. For anchored patterns, -2 is returned. PCRE_INFO_FIRSTTABLE

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 unsigned char * variable.
@@ -1152,11 +1216,11 @@ argument should point to a size_t variable.
 
   PCRE_INFO_LASTLITERAL
 
-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 int 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 int 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.
@@ -1164,8 +1228,8 @@ is -1.
 
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 int 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 int 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 +1253,11 @@ The map consists of a number of fixed-size entries. PC the number of entries, and PCRE_INFO_NAMEENTRYSIZE gives the size of each entry; both of these return an int 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 char). 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 char 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.

The names are in alphabetical order. Duplicate names may appear if (?| is used @@ -1207,8 +1273,8 @@ necessarily the case because later subpatterns may hav

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):

   (?<date> (?<year>(\d\d)?\d\d) - (?<month>\d\d) - (?<day>\d\d) )
 
@@ -1258,53 +1324,30 @@ For such patterns, the PCRE_ANCHORED bit is set in the
   PCRE_INFO_SIZE
 
-Return the size of the compiled pattern. The fourth argument should point to a -size_t variable. This value does not include the size of the pcre -structure that is returned by pcre_compile(). The value that is passed as -the argument to pcre_malloc() when pcre_compile() is getting memory -in which to place the compiled data is the value returned by this option plus -the size of the pcre 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 size_t variable. This value does not +include the size of the pcre structure that is returned by +pcre_compile(). The value that is passed as the argument to +pcre_malloc() when pcre_compile() is getting memory in which to +place the compiled data is the value returned by this option plus the size of +the pcre structure. Studying a compiled pattern, with or without JIT, +does not alter the value returned by this option.
   PCRE_INFO_STUDYSIZE
 
-Return the size of the data block pointed to by the study_data field in a -pcre_extra block. If pcre_extra is NULL, or there is no study data, -zero is returned. The fourth argument should point to a size_t variable. -The study_data field is set by pcre_study() 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 study_data +field in a pcre_extra block. If pcre_extra is NULL, or there is no +study data, zero is returned. The fourth argument should point to a +size_t variable. The study_data field is set by pcre_study() +to record information that will speed up matching (see the section entitled "Studying a pattern" above). The format of the study_data block is private, but its length is made available via this option so that it can be saved and restored (see the pcreprecompile documentation for details).

-
OBSOLETE INFO FUNCTION
+
REFERENCE COUNTS

-int pcre_info(const pcre *code, int *optptr, int -*firstcharptr); -

-

-The pcre_info() function is now obsolete because its interface is too -restrictive to return all the available data about a compiled pattern. New -programs should use pcre_fullinfo() instead. The yield of -pcre_info() is the number of capturing subpatterns, or one of the -following negative numbers: -

-  PCRE_ERROR_NULL       the argument code was NULL
-  PCRE_ERROR_BADMAGIC   the "magic number" was not found
-
-If the optptr 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). -

-

-If the pattern is not anchored and the firstcharptr argument is not NULL, -it is used to pass back information about the first character of any matched -string (see PCRE_INFO_FIRSTBYTE above). -

-
REFERENCE COUNTS
-

int pcre_refcount(pcre *code, int adjust);

@@ -1327,7 +1370,7 @@ Except when it is zero, the reference count is not cor pattern is compiled on one host and then transferred to a host whose byte-order is different. (This seems a highly unlikely scenario.)

-
MATCHING A PATTERN: THE TRADITIONAL FUNCTION
+
MATCHING A PATTERN: THE TRADITIONAL FUNCTION

int pcre_exec(const pcre *code, const pcre_extra *extra, const char *subject, int length, int startoffset, @@ -1392,6 +1435,10 @@ fields (not necessarily in this order): const unsigned char *tables; unsigned char **mark;

+In the 16-bit version of this structure, the mark field has type +"PCRE_UCHAR16 **". +

+

The flags field is a bitmap that specifies which of the other fields are set. The flag bits are:

@@ -1482,13 +1529,13 @@ documentation for a discussion of saving compiled patt
 

If PCRE_EXTRA_MARK is set in the flags field, the mark field must -be set to point to a char * 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 mark 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 mark field set to NULL. For details of the +variable pointed to by the mark field is set to NULL. For details of the backtracking control verbs, see the section entitled "Backtracking control" in the @@ -1671,15 +1718,13 @@ string is automatically checked when pcre_exec()startoffset 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 -section on UTF-8 support -in the main -pcre -page. If an invalid UTF-8 sequence of bytes is found, pcre_exec() 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 pcre_exec() +pcreunicode +page. If an invalid sequence of bytes is found, pcre_exec() 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 pcre_exec() below). If startoffset 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 +1736,9 @@ checks for performance reasons, you can set the PCRE_N calling pcre_exec(). You might want to do this for the second and subsequent calls to pcre_exec() 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 startoffset 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 startoffset is +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.

   PCRE_PARTIAL_HARD
@@ -1728,7 +1773,7 @@ The string to be matched by pcre_exec()
 

The subject string is passed to pcre_exec() as a pointer in -subject, a length (in bytes) in length, and a starting byte offset +subject, a length in bytes in length, and a starting byte offset in startoffset. If this is negative or greater than the length of the subject, pcre_exec() returns PCRE_ERROR_BADOFFSET. When the starting offset is zero, the search for a match starts at the beginning of the subject, @@ -2027,6 +2072,18 @@ PCRE_STUDY_JIT_COMPILE option is being matched, but th the just-in-time processing stack is not large enough. See the pcrejit documentation for more details. +

+  PCRE_ERROR_BADMODE (-28)
+
+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. +
+  PCRE_ERROR_BADENDIANNESS (-29)
+
+This error is given if a pattern that was compiled and saved is reloaded on a +host with different endianness. The utility function +pcre_pattern_to_host_byte_order() can be used to convert such a pattern +so that it runs on the new host.

Error numbers -16 to -20 and -22 are not used by pcre_exec(). @@ -2035,6 +2092,12 @@ Error numbers -16 to -20 and -22 are not used by pc Reason codes for invalid UTF-8 strings

+This section applies only to the 8-bit library. The corresponding information +for the 16-bit library is given in the +pcre16 +page. +

+

When pcre_exec() returns either PCRE_ERROR_BADUTF8 or PCRE_ERROR_SHORTUTF8, and the size of the output vector (ovecsize) is at least 2, the offset of the start of the invalid UTF-8 character is placed in @@ -2104,7 +2167,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.

-
EXTRACTING CAPTURED SUBSTRINGS BY NUMBER
+
EXTRACTING CAPTURED SUBSTRINGS BY NUMBER

int pcre_copy_substring(const char *subject, int *ovector, int stringcount, int stringnumber, char *buffer, @@ -2199,7 +2262,7 @@ linked via a special interface to another programming pcre_free directly; it is for these cases that the functions are provided.

-
EXTRACTING CAPTURED SUBSTRINGS BY NAME
+
EXTRACTING CAPTURED SUBSTRINGS BY NAME

int pcre_get_stringnumber(const pcre *code, const char *name); @@ -2263,7 +2326,7 @@ names are not included in the compiled code. The match numbers. For this reason, the use of different names for subpatterns of the same number causes an error at compile time.

-
DUPLICATE SUBPATTERN NAMES
+
DUPLICATE SUBPATTERN NAMES

int pcre_get_stringtable_entries(const pcre *code, const char *name, char **first, char **last); @@ -2301,7 +2364,7 @@ described above in the section entitled Information Given all the relevant entries for the name, you can extract each of their numbers, and hence the captured data, if any.

-
FINDING ALL POSSIBLE MATCHES
+
FINDING ALL POSSIBLE MATCHES

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 @@ -2319,8 +2382,32 @@ When your callout function is called, extract and save substring. Then return 1, which forces pcre_exec() to backtrack and try other alternatives. Ultimately, when it runs out of matches, pcre_exec() will yield PCRE_ERROR_NOMATCH. +

+
OBTAINING AN ESTIMATE OF STACK USAGE
+

+Matching certain patterns using pcre_exec() can use a lot of process +stack, which in certain environments can be rather limited in size. Some users +find it helpful to have an estimate of the amount of stack that is used by +pcre_exec(), to help them set recursion limits, as described in the +pcrestack +documentation. The estimate that is output by pcretest when called with +the -m and -C options is obtained by calling pcre_exec with +the values NULL, NULL, NULL, -999, and -999 for its first five arguments. +

+

+Normally, if its first argument is NULL, pcre_exec() immediately returns +the negative error code PCRE_ERROR_NULL, but with this special combination of +arguments, it returns instead a negative number whose absolute value is the +approximate stack frame size in bytes. (A negative number is used so that it is +clear that no match has happened.) The value is approximate because in some +cases, recursive calls to pcre_exec() occur when there are one or two +additional variables on the stack. +

+

+If PCRE has been compiled to use the heap instead of the stack for recursion, +the value returned is the size of each block that is obtained from the heap.

-
MATCHING A PATTERN: THE ALTERNATIVE FUNCTION
+
MATCHING A PATTERN: THE ALTERNATIVE FUNCTION

int pcre_dfa_exec(const pcre *code, const pcre_extra *extra, const char *subject, int length, int startoffset, @@ -2495,13 +2582,13 @@ recursively, using private vectors for ovector error is given if the output vector is not large enough. This should be extremely rare, as a vector of size 1000 is used.

-
SEE ALSO
+
SEE ALSO

-pcrebuild(3), pcrecallout(3), pcrecpp(3)(3), +pcre16(3), pcrebuild(3), pcrecallout(3), pcrecpp(3)(3), pcrematching(3), pcrepartial(3), pcreposix(3), pcreprecompile(3), pcresample(3), pcrestack(3).

-
AUTHOR
+
AUTHOR

Philip Hazel
@@ -2510,11 +2597,11 @@ University Computing Service Cambridge CB2 3QH, England.

-
REVISION
+
REVISION

-Last updated: 02 December 2011 +Last updated: 21 January 2012
-Copyright © 1997-2011 University of Cambridge. +Copyright © 1997-2012 University of Cambridge.

Return to the PCRE index page.