ViewVC logotype

Contents of /code/trunk/doc/pcrebuild.3

Parent Directory Parent Directory | Revision Log Revision Log

Revision 1031 - (show annotations)
Sat Sep 8 15:59:01 2012 UTC (7 years, 5 months ago) by ph10
File size: 16353 byte(s)
More documentation updates/tidies for EBCDIC environments.
1 .TH PCREBUILD 3 "08 September 2012" "PCRE 8.32"
3 PCRE - Perl-compatible regular expressions
4 .
5 .
7 .rs
8 .sp
9 This document describes the optional features of PCRE that can be selected when
10 the library is compiled. It assumes use of the \fBconfigure\fP script, where
11 the optional features are selected or deselected by providing options to
12 \fBconfigure\fP before running the \fBmake\fP command. However, the same
13 options can be selected in both Unix-like and non-Unix-like environments using
14 the GUI facility of \fBcmake-gui\fP if you are using \fBCMake\fP instead of
15 \fBconfigure\fP to build PCRE.
16 .P
17 There is a lot more information about building PCRE without using
18 \fBconfigure\fP (including information about using \fBCMake\fP or building "by
19 hand") in the file called \fINON-AUTOTOOLS-BUILD\fP, which is part of the PCRE
20 distribution. You should consult this file as well as the \fIREADME\fP file if
21 you are building in a non-Unix-like environment.
22 .P
23 The complete list of options for \fBconfigure\fP (which includes the standard
24 ones such as the selection of the installation directory) can be obtained by
25 running
26 .sp
27 ./configure --help
28 .sp
29 The following sections include descriptions of options whose names begin with
30 --enable or --disable. These settings specify changes to the defaults for the
31 \fBconfigure\fP command. Because of the way that \fBconfigure\fP works,
32 --enable and --disable always come in pairs, so the complementary option always
33 exists as well, but as it specifies the default, it is not described.
34 .
35 .
37 .rs
38 .sp
39 By default, a library called \fBlibpcre\fP is built, containing functions that
40 take string arguments contained in vectors of bytes, either as single-byte
41 characters, or interpreted as UTF-8 strings. You can also build a separate
42 library, called \fBlibpcre16\fP, in which strings are contained in vectors of
43 16-bit data units and interpreted either as single-unit characters or UTF-16
44 strings, by adding
45 .sp
46 --enable-pcre16
47 .sp
48 to the \fBconfigure\fP command. If you do not want the 8-bit library, add
49 .sp
50 --disable-pcre8
51 .sp
52 as well. At least one of the two libraries must be built. Note that the C++ and
53 POSIX wrappers are for the 8-bit library only, and that \fBpcregrep\fP is an
54 8-bit program. None of these are built if you select only the 16-bit library.
55 .
56 .
58 .rs
59 .sp
60 The PCRE building process uses \fBlibtool\fP to build both shared and static
61 Unix libraries by default. You can suppress one of these by adding one of
62 .sp
63 --disable-shared
64 --disable-static
65 .sp
66 to the \fBconfigure\fP command, as required.
67 .
68 .
69 .SH "C++ SUPPORT"
70 .rs
71 .sp
72 By default, if the 8-bit library is being built, the \fBconfigure\fP script
73 will search for a C++ compiler and C++ header files. If it finds them, it
74 automatically builds the C++ wrapper library (which supports only 8-bit
75 strings). You can disable this by adding
76 .sp
77 --disable-cpp
78 .sp
79 to the \fBconfigure\fP command.
80 .
81 .
82 .SH "UTF-8 and UTF-16 SUPPORT"
83 .rs
84 .sp
85 To build PCRE with support for UTF Unicode character strings, add
86 .sp
87 --enable-utf
88 .sp
89 to the \fBconfigure\fP command. This setting applies to both libraries, adding
90 support for UTF-8 to the 8-bit library and support for UTF-16 to the 16-bit
91 library. There are no separate options for enabling UTF-8 and UTF-16
92 independently because that would allow ridiculous settings such as requesting
93 UTF-16 support while building only the 8-bit library. It is not possible to
94 build one library with UTF support and the other without in the same
95 configuration. (For backwards compatibility, --enable-utf8 is a synonym of
96 --enable-utf.)
97 .P
98 Of itself, this setting does not make PCRE treat strings as UTF-8 or UTF-16. As
99 well as compiling PCRE with this option, you also have have to set the
100 PCRE_UTF8 or PCRE_UTF16 option when you call one of the pattern compiling
101 functions.
102 .P
103 If you set --enable-utf when compiling in an EBCDIC environment, PCRE expects
104 its input to be either ASCII or UTF-8 (depending on the run-time option). It is
105 not possible to support both EBCDIC and UTF-8 codes in the same version of the
106 library. Consequently, --enable-utf and --enable-ebcdic are mutually
107 exclusive.
108 .
109 .
111 .rs
112 .sp
113 UTF support allows the libraries to process character codepoints up to 0x10ffff
114 in the strings that they handle. On its own, however, it does not provide any
115 facilities for accessing the properties of such characters. If you want to be
116 able to use the pattern escapes \eP, \ep, and \eX, which refer to Unicode
117 character properties, you must add
118 .sp
119 --enable-unicode-properties
120 .sp
121 to the \fBconfigure\fP command. This implies UTF support, even if you have
122 not explicitly requested it.
123 .P
124 Including Unicode property support adds around 30K of tables to the PCRE
125 library. Only the general category properties such as \fILu\fP and \fINd\fP are
126 supported. Details are given in the
127 .\" HREF
128 \fBpcrepattern\fP
129 .\"
130 documentation.
131 .
132 .
134 .rs
135 .sp
136 Just-in-time compiler support is included in the build by specifying
137 .sp
138 --enable-jit
139 .sp
140 This support is available only for certain hardware architectures. If this
141 option is set for an unsupported architecture, a compile time error occurs.
142 See the
143 .\" HREF
144 \fBpcrejit\fP
145 .\"
146 documentation for a discussion of JIT usage. When JIT support is enabled,
147 pcregrep automatically makes use of it, unless you add
148 .sp
149 --disable-pcregrep-jit
150 .sp
151 to the "configure" command.
152 .
153 .
155 .rs
156 .sp
157 By default, PCRE interprets the linefeed (LF) character as indicating the end
158 of a line. This is the normal newline character on Unix-like systems. You can
159 compile PCRE to use carriage return (CR) instead, by adding
160 .sp
161 --enable-newline-is-cr
162 .sp
163 to the \fBconfigure\fP command. There is also a --enable-newline-is-lf option,
164 which explicitly specifies linefeed as the newline character.
165 .sp
166 Alternatively, you can specify that line endings are to be indicated by the two
167 character sequence CRLF. If you want this, add
168 .sp
169 --enable-newline-is-crlf
170 .sp
171 to the \fBconfigure\fP command. There is a fourth option, specified by
172 .sp
173 --enable-newline-is-anycrlf
174 .sp
175 which causes PCRE to recognize any of the three sequences CR, LF, or CRLF as
176 indicating a line ending. Finally, a fifth option, specified by
177 .sp
178 --enable-newline-is-any
179 .sp
180 causes PCRE to recognize any Unicode newline sequence.
181 .P
182 Whatever line ending convention is selected when PCRE is built can be
183 overridden when the library functions are called. At build time it is
184 conventional to use the standard for your operating system.
185 .
186 .
188 .rs
189 .sp
190 By default, the sequence \eR in a pattern matches any Unicode newline sequence,
191 whatever has been selected as the line ending sequence. If you specify
192 .sp
193 --enable-bsr-anycrlf
194 .sp
195 the default is changed so that \eR matches only CR, LF, or CRLF. Whatever is
196 selected when PCRE is built can be overridden when the library functions are
197 called.
198 .
199 .
201 .rs
202 .sp
203 When the 8-bit library is called through the POSIX interface (see the
204 .\" HREF
205 \fBpcreposix\fP
206 .\"
207 documentation), additional working storage is required for holding the pointers
208 to capturing substrings, because PCRE requires three integers per substring,
209 whereas the POSIX interface provides only two. If the number of expected
210 substrings is small, the wrapper function uses space on the stack, because this
211 is faster than using \fBmalloc()\fP for each call. The default threshold above
212 which the stack is no longer used is 10; it can be changed by adding a setting
213 such as
214 .sp
215 --with-posix-malloc-threshold=20
216 .sp
217 to the \fBconfigure\fP command.
218 .
219 .
221 .rs
222 .sp
223 Within a compiled pattern, offset values are used to point from one part to
224 another (for example, from an opening parenthesis to an alternation
225 metacharacter). By default, two-byte values are used for these offsets, leading
226 to a maximum size for a compiled pattern of around 64K. This is sufficient to
227 handle all but the most gigantic patterns. Nevertheless, some people do want to
228 process truly enormous patterns, so it is possible to compile PCRE to use
229 three-byte or four-byte offsets by adding a setting such as
230 .sp
231 --with-link-size=3
232 .sp
233 to the \fBconfigure\fP command. The value given must be 2, 3, or 4. For the
234 16-bit library, a value of 3 is rounded up to 4. Using longer offsets slows
235 down the operation of PCRE because it has to load additional data when handling
236 them.
237 .
238 .
240 .rs
241 .sp
242 When matching with the \fBpcre_exec()\fP function, PCRE implements backtracking
243 by making recursive calls to an internal function called \fBmatch()\fP. In
244 environments where the size of the stack is limited, this can severely limit
245 PCRE's operation. (The Unix environment does not usually suffer from this
246 problem, but it may sometimes be necessary to increase the maximum stack size.
247 There is a discussion in the
248 .\" HREF
249 \fBpcrestack\fP
250 .\"
251 documentation.) An alternative approach to recursion that uses memory from the
252 heap to remember data, instead of using recursive function calls, has been
253 implemented to work round the problem of limited stack size. If you want to
254 build a version of PCRE that works this way, add
255 .sp
256 --disable-stack-for-recursion
257 .sp
258 to the \fBconfigure\fP command. With this configuration, PCRE will use the
259 \fBpcre_stack_malloc\fP and \fBpcre_stack_free\fP variables to call memory
260 management functions. By default these point to \fBmalloc()\fP and
261 \fBfree()\fP, but you can replace the pointers so that your own functions are
262 used instead.
263 .P
264 Separate functions are provided rather than using \fBpcre_malloc\fP and
265 \fBpcre_free\fP because the usage is very predictable: the block sizes
266 requested are always the same, and the blocks are always freed in reverse
267 order. A calling program might be able to implement optimized functions that
268 perform better than \fBmalloc()\fP and \fBfree()\fP. PCRE runs noticeably more
269 slowly when built in this way. This option affects only the \fBpcre_exec()\fP
270 function; it is not relevant for \fBpcre_dfa_exec()\fP.
271 .
272 .
274 .rs
275 .sp
276 Internally, PCRE has a function called \fBmatch()\fP, which it calls repeatedly
277 (sometimes recursively) when matching a pattern with the \fBpcre_exec()\fP
278 function. By controlling the maximum number of times this function may be
279 called during a single matching operation, a limit can be placed on the
280 resources used by a single call to \fBpcre_exec()\fP. The limit can be changed
281 at run time, as described in the
282 .\" HREF
283 \fBpcreapi\fP
284 .\"
285 documentation. The default is 10 million, but this can be changed by adding a
286 setting such as
287 .sp
288 --with-match-limit=500000
289 .sp
290 to the \fBconfigure\fP command. This setting has no effect on the
291 \fBpcre_dfa_exec()\fP matching function.
292 .P
293 In some environments it is desirable to limit the depth of recursive calls of
294 \fBmatch()\fP more strictly than the total number of calls, in order to
295 restrict the maximum amount of stack (or heap, if --disable-stack-for-recursion
296 is specified) that is used. A second limit controls this; it defaults to the
297 value that is set for --with-match-limit, which imposes no additional
298 constraints. However, you can set a lower limit by adding, for example,
299 .sp
300 --with-match-limit-recursion=10000
301 .sp
302 to the \fBconfigure\fP command. This value can also be overridden at run time.
303 .
304 .
306 .rs
307 .sp
308 PCRE uses fixed tables for processing characters whose code values are less
309 than 256. By default, PCRE is built with a set of tables that are distributed
310 in the file \fIpcre_chartables.c.dist\fP. These tables are for ASCII codes
311 only. If you add
312 .sp
313 --enable-rebuild-chartables
314 .sp
315 to the \fBconfigure\fP command, the distributed tables are no longer used.
316 Instead, a program called \fBdftables\fP is compiled and run. This outputs the
317 source for new set of tables, created in the default locale of your C run-time
318 system. (This method of replacing the tables does not work if you are cross
319 compiling, because \fBdftables\fP is run on the local host. If you need to
320 create alternative tables when cross compiling, you will have to do so "by
321 hand".)
322 .
323 .
325 .rs
326 .sp
327 PCRE assumes by default that it will run in an environment where the character
328 code is ASCII (or Unicode, which is a superset of ASCII). This is the case for
329 most computer operating systems. PCRE can, however, be compiled to run in an
330 EBCDIC environment by adding
331 .sp
332 --enable-ebcdic
333 .sp
334 to the \fBconfigure\fP command. This setting implies
335 --enable-rebuild-chartables. You should only use it if you know that you are in
336 an EBCDIC environment (for example, an IBM mainframe operating system). The
337 --enable-ebcdic option is incompatible with --enable-utf.
338 .P
339 The EBCDIC character that corresponds to an ASCII LF is assumed to have the
340 value 0x15 by default. However, in some EBCDIC environments, 0x25 is used. In
341 such an environment you should use
342 .sp
343 --enable-ebcdic-nl25
344 .sp
345 as well as, or instead of, --enable-ebcdic. The EBCDIC character for CR has the
346 same value as in ASCII, namely, 0x0d. Whichever of 0x15 and 0x25 is \fInot\fP
347 chosen as LF is made to correspond to the Unicode NEL character (which, in
348 Unicode, is 0x85).
349 .P
350 The options that select newline behaviour, such as --enable-newline-is-cr,
351 and equivalent run-time options, refer to these character values in an EBCDIC
352 environment.
353 .
354 .
356 .rs
357 .sp
358 By default, \fBpcregrep\fP reads all files as plain text. You can build it so
359 that it recognizes files whose names end in \fB.gz\fP or \fB.bz2\fP, and reads
360 them with \fBlibz\fP or \fBlibbz2\fP, respectively, by adding one or both of
361 .sp
362 --enable-pcregrep-libz
363 --enable-pcregrep-libbz2
364 .sp
365 to the \fBconfigure\fP command. These options naturally require that the
366 relevant libraries are installed on your system. Configuration will fail if
367 they are not.
368 .
369 .
371 .rs
372 .sp
373 \fBpcregrep\fP uses an internal buffer to hold a "window" on the file it is
374 scanning, in order to be able to output "before" and "after" lines when it
375 finds a match. The size of the buffer is controlled by a parameter whose
376 default value is 20K. The buffer itself is three times this size, but because
377 of the way it is used for holding "before" lines, the longest line that is
378 guaranteed to be processable is the parameter size. You can change the default
379 parameter value by adding, for example,
380 .sp
381 --with-pcregrep-bufsize=50K
382 .sp
383 to the \fBconfigure\fP command. The caller of \fPpcregrep\fP can, however,
384 override this value by specifying a run-time option.
385 .
386 .
388 .rs
389 .sp
390 If you add
391 .sp
392 --enable-pcretest-libreadline
393 .sp
394 to the \fBconfigure\fP command, \fBpcretest\fP is linked with the
395 \fBlibreadline\fP library, and when its input is from a terminal, it reads it
396 using the \fBreadline()\fP function. This provides line-editing and history
397 facilities. Note that \fBlibreadline\fP is GPL-licensed, so if you distribute a
398 binary of \fBpcretest\fP linked in this way, there may be licensing issues.
399 .P
400 Setting this option causes the \fB-lreadline\fP option to be added to the
401 \fBpcretest\fP build. In many operating environments with a sytem-installed
402 \fBlibreadline\fP this is sufficient. However, in some environments (e.g.
403 if an unmodified distribution version of readline is in use), some extra
404 configuration may be necessary. The INSTALL file for \fBlibreadline\fP says
405 this:
406 .sp
407 "Readline uses the termcap functions, but does not link with the
408 termcap or curses library itself, allowing applications which link
409 with readline the to choose an appropriate library."
410 .sp
411 If your environment has not been set up so that an appropriate library is
412 automatically included, you may need to add something like
413 .sp
414 LIBS="-ncurses"
415 .sp
416 immediately before the \fBconfigure\fP command.
417 .
418 .
419 .SH "SEE ALSO"
420 .rs
421 .sp
422 \fBpcreapi\fP(3), \fBpcre16\fP, \fBpcre_config\fP(3).
423 .
424 .
426 .rs
427 .sp
428 .nf
429 Philip Hazel
430 University Computing Service
431 Cambridge CB2 3QH, England.
432 .fi
433 .
434 .
436 .rs
437 .sp
438 .nf
439 Last updated: 08 September 2012
440 Copyright (c) 1997-2012 University of Cambridge.
441 .fi


Name Value
svn:eol-style native
svn:keywords "Author Date Id Revision Url"

  ViewVC Help
Powered by ViewVC 1.1.5