| 1 |
nigel |
63 |
.TH PCRE 3 |
| 2 |
|
|
.SH NAME |
| 3 |
|
|
PCRE - Perl-compatible regular expressions |
| 4 |
|
|
.SH PCRE BUILD-TIME OPTIONS |
| 5 |
|
|
.rs |
| 6 |
|
|
.sp |
| 7 |
|
|
This document describes the optional features of PCRE that can be selected when |
| 8 |
|
|
the library is compiled. They are all selected, or deselected, by providing |
| 9 |
|
|
options to the \fBconfigure\fR script which is run before the \fBmake\fR |
| 10 |
|
|
command. The complete list of options for \fBconfigure\fR (which includes the |
| 11 |
|
|
standard ones such as the selection of the installation directory) can be |
| 12 |
|
|
obtained by running |
| 13 |
|
|
|
| 14 |
|
|
./configure --help |
| 15 |
|
|
|
| 16 |
|
|
The following sections describe certain options whose names begin with --enable |
| 17 |
|
|
or --disable. These settings specify changes to the defaults for the |
| 18 |
|
|
\fBconfigure\fR command. Because of the way that \fBconfigure\fR works, |
| 19 |
|
|
--enable and --disable always come in pairs, so the complementary option always |
| 20 |
|
|
exists as well, but as it specifies the default, it is not described. |
| 21 |
|
|
|
| 22 |
|
|
.SH UTF-8 SUPPORT |
| 23 |
|
|
.rs |
| 24 |
|
|
.sp |
| 25 |
|
|
To build PCRE with support for UTF-8 character strings, add |
| 26 |
|
|
|
| 27 |
|
|
--enable-utf8 |
| 28 |
|
|
|
| 29 |
|
|
to the \fBconfigure\fR command. Of itself, this does not make PCRE treat |
| 30 |
|
|
strings as UTF-8. As well as compiling PCRE with this option, you also have |
| 31 |
|
|
have to set the PCRE_UTF8 option when you call the \fBpcre_compile()\fR |
| 32 |
|
|
function. |
| 33 |
|
|
|
| 34 |
|
|
.SH CODE VALUE OF NEWLINE |
| 35 |
|
|
.rs |
| 36 |
|
|
.sp |
| 37 |
|
|
By default, PCRE treats character 10 (linefeed) as the newline character. This |
| 38 |
|
|
is the normal newline character on Unix-like systems. You can compile PCRE to |
| 39 |
|
|
use character 13 (carriage return) instead by adding |
| 40 |
|
|
|
| 41 |
|
|
--enable-newline-is-cr |
| 42 |
|
|
|
| 43 |
|
|
to the \fBconfigure\fR command. For completeness there is also a |
| 44 |
|
|
--enable-newline-is-lf option, which explicitly specifies linefeed as the |
| 45 |
|
|
newline character. |
| 46 |
|
|
|
| 47 |
|
|
.SH BUILDING SHARED AND STATIC LIBRARIES |
| 48 |
|
|
.rs |
| 49 |
|
|
.sp |
| 50 |
|
|
The PCRE building process uses \fBlibtool\fR to build both shared and static |
| 51 |
|
|
Unix libraries by default. You can suppress one of these by adding one of |
| 52 |
|
|
|
| 53 |
|
|
--disable-shared |
| 54 |
|
|
--disable-static |
| 55 |
|
|
|
| 56 |
|
|
to the \fBconfigure\fR command, as required. |
| 57 |
|
|
|
| 58 |
|
|
.SH POSIX MALLOC USAGE |
| 59 |
|
|
.rs |
| 60 |
|
|
.sp |
| 61 |
|
|
When PCRE is called through the POSIX interface (see the \fBpcreposix\fR |
| 62 |
|
|
documentation), additional working storage is required for holding the pointers |
| 63 |
|
|
to capturing substrings because PCRE requires three integers per substring, |
| 64 |
|
|
whereas the POSIX interface provides only two. If the number of expected |
| 65 |
|
|
substrings is small, the wrapper function uses space on the stack, because this |
| 66 |
|
|
is faster than using \fBmalloc()\fR for each call. The default threshold above |
| 67 |
|
|
which the stack is no longer used is 10; it can be changed by adding a setting |
| 68 |
|
|
such as |
| 69 |
|
|
|
| 70 |
|
|
--with-posix-malloc-threshold=20 |
| 71 |
|
|
|
| 72 |
|
|
to the \fBconfigure\fR command. |
| 73 |
|
|
|
| 74 |
|
|
.SH LIMITING PCRE RESOURCE USAGE |
| 75 |
|
|
.rs |
| 76 |
|
|
.sp |
| 77 |
|
|
Internally, PCRE has a function called \fBmatch()\fR which it calls repeatedly |
| 78 |
|
|
(possibly recursively) when performing a matching operation. By limiting the |
| 79 |
|
|
number of times this function may be called, a limit can be placed on the |
| 80 |
|
|
resources used by a single call to \fBpcre_exec()\fR. The limit can be changed |
| 81 |
|
|
at run time, as described in the \fBpcreapi\fR documentation. The default is 10 |
| 82 |
|
|
million, but this can be changed by adding a setting such as |
| 83 |
|
|
|
| 84 |
|
|
--with-match-limit=500000 |
| 85 |
|
|
|
| 86 |
|
|
to the \fBconfigure\fR command. |
| 87 |
|
|
|
| 88 |
|
|
.SH HANDLING VERY LARGE PATTERNS |
| 89 |
|
|
.rs |
| 90 |
|
|
.sp |
| 91 |
|
|
Within a compiled pattern, offset values are used to point from one part to |
| 92 |
|
|
another (for example, from an opening parenthesis to an alternation |
| 93 |
|
|
metacharacter). By default two-byte values are used for these offsets, leading |
| 94 |
|
|
to a maximum size for a compiled pattern of around 64K. This is sufficient to |
| 95 |
|
|
handle all but the most gigantic patterns. Nevertheless, some people do want to |
| 96 |
|
|
process enormous patterns, so it is possible to compile PCRE to use three-byte |
| 97 |
|
|
or four-byte offsets by adding a setting such as |
| 98 |
|
|
|
| 99 |
|
|
--with-link-size=3 |
| 100 |
|
|
|
| 101 |
|
|
to the \fBconfigure\fR command. The value given must be 2, 3, or 4. Using |
| 102 |
|
|
longer offsets slows down the operation of PCRE because it has to load |
| 103 |
|
|
additional bytes when handling them. |
| 104 |
|
|
|
| 105 |
|
|
If you build PCRE with an increased link size, test 2 (and test 5 if you are |
| 106 |
|
|
using UTF-8) will fail. Part of the output of these tests is a representation |
| 107 |
|
|
of the compiled pattern, and this changes with the link size. |
| 108 |
|
|
|
| 109 |
nigel |
73 |
.SH AVOIDING EXCESSIVE STACK USAGE |
| 110 |
|
|
.rs |
| 111 |
|
|
.sp |
| 112 |
|
|
PCRE implements backtracking while matching by making recursive calls to an |
| 113 |
|
|
internal function called \fBmatch()\fR. In environments where the size of the |
| 114 |
|
|
stack is limited, this can severely limit PCRE's operation. (The Unix |
| 115 |
|
|
environment does not usually suffer from this problem.) An alternative approach |
| 116 |
|
|
that uses memory from the heap to remember data, instead of using recursive |
| 117 |
|
|
function calls, has been implemented to work round this problem. If you want to |
| 118 |
|
|
build a version of PCRE that works this way, add |
| 119 |
|
|
|
| 120 |
|
|
--disable-stack-for-recursion |
| 121 |
|
|
|
| 122 |
|
|
to the \fBconfigure\fR command. With this configuration, PCRE will use the |
| 123 |
|
|
\fBpcre_stack_malloc\fR and \fBpcre_stack_free\fR variables to call memory |
| 124 |
|
|
management functions. Separate functions are provided because the usage is very |
| 125 |
|
|
predictable: the block sizes requested are always the same, and the blocks are |
| 126 |
|
|
always freed in reverse order. A calling program might be able to implement |
| 127 |
|
|
optimized functions that perform better than the standard \fBmalloc()\fR and |
| 128 |
|
|
\fBfree()\fR functions. PCRE runs noticeably more slowly when built in this |
| 129 |
|
|
way. |
| 130 |
|
|
|
| 131 |
|
|
.SH USING EBCDIC CODE |
| 132 |
|
|
.rs |
| 133 |
|
|
.sp |
| 134 |
|
|
PCRE assumes by default that it will run in an environment where the character |
| 135 |
|
|
code is ASCII (or UTF-8, which is a superset of ASCII). PCRE can, however, be |
| 136 |
|
|
compiled to run in an EBCDIC environment by adding |
| 137 |
|
|
|
| 138 |
|
|
--enable-ebcdic |
| 139 |
|
|
|
| 140 |
|
|
to the \fBconfigure\fR command. |
| 141 |
|
|
|
| 142 |
nigel |
63 |
.in 0 |
| 143 |
nigel |
73 |
Last updated: 09 December 2003 |
| 144 |
nigel |
63 |
.br |
| 145 |
|
|
Copyright (c) 1997-2003 University of Cambridge. |