/[pcre]/code/trunk/doc/pcre32.3
ViewVC logotype

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1339 - (show annotations)
Fri Jun 14 09:09:28 2013 UTC (6 years, 2 months ago) by ph10
File size: 13184 byte(s)
Update man pages to avoid the use of .ti (which causes difficulties for some 
translation software).
1 .TH PCRE 3 "12 May 2013" "PCRE 8.33"
2 .SH NAME
3 PCRE - Perl-compatible regular expressions
4 .sp
5 .B #include <pcre.h>
6 .
7 .
8 .SH "PCRE 32-BIT API BASIC FUNCTIONS"
9 .rs
10 .sp
11 .nf
12 .B pcre32 *pcre32_compile(PCRE_SPTR32 \fIpattern\fP, int \fIoptions\fP,
13 .B " const char **\fIerrptr\fP, int *\fIerroffset\fP,"
14 .B " const unsigned char *\fItableptr\fP);"
15 .sp
16 .B pcre32 *pcre32_compile2(PCRE_SPTR32 \fIpattern\fP, int \fIoptions\fP,
17 .B " int *\fIerrorcodeptr\fP,"
18 .B " const unsigned char *\fItableptr\fP);"
19 .sp
20 .B pcre32_extra *pcre32_study(const pcre32 *\fIcode\fP, int \fIoptions\fP,
21 .B " const char **\fIerrptr\fP);"
22 .sp
23 .B void pcre32_free_study(pcre32_extra *\fIextra\fP);
24 .sp
25 .B int pcre32_exec(const pcre32 *\fIcode\fP, "const pcre32_extra *\fIextra\fP,"
26 .B " PCRE_SPTR32 \fIsubject\fP, int \fIlength\fP, int \fIstartoffset\fP,"
27 .B " int \fIoptions\fP, int *\fIovector\fP, int \fIovecsize\fP);"
28 .sp
29 .B int pcre32_dfa_exec(const pcre32 *\fIcode\fP, "const pcre32_extra *\fIextra\fP,"
30 .B " PCRE_SPTR32 \fIsubject\fP, int \fIlength\fP, int \fIstartoffset\fP,"
31 .B " int \fIoptions\fP, int *\fIovector\fP, int \fIovecsize\fP,"
32 .B " int *\fIworkspace\fP, int \fIwscount\fP);"
33 .fi
34 .
35 .
36 .SH "PCRE 32-BIT API STRING EXTRACTION FUNCTIONS"
37 .rs
38 .sp
39 .nf
40 .B int pcre32_copy_named_substring(const pcre32 *\fIcode\fP,
41 .B " PCRE_SPTR32 \fIsubject\fP, int *\fIovector\fP,"
42 .B " int \fIstringcount\fP, PCRE_SPTR32 \fIstringname\fP,"
43 .B " PCRE_UCHAR32 *\fIbuffer\fP, int \fIbuffersize\fP);"
44 .sp
45 .B int pcre32_copy_substring(PCRE_SPTR32 \fIsubject\fP, int *\fIovector\fP,
46 .B " int \fIstringcount\fP, int \fIstringnumber\fP, PCRE_UCHAR32 *\fIbuffer\fP,"
47 .B " int \fIbuffersize\fP);"
48 .sp
49 .B int pcre32_get_named_substring(const pcre32 *\fIcode\fP,
50 .B " PCRE_SPTR32 \fIsubject\fP, int *\fIovector\fP,"
51 .B " int \fIstringcount\fP, PCRE_SPTR32 \fIstringname\fP,"
52 .B " PCRE_SPTR32 *\fIstringptr\fP);"
53 .sp
54 .B int pcre32_get_stringnumber(const pcre32 *\fIcode\fP,
55 .B " PCRE_SPTR32 \fIname\fP);"
56 .sp
57 .B int pcre32_get_stringtable_entries(const pcre32 *\fIcode\fP,
58 .B " PCRE_SPTR32 \fIname\fP, PCRE_UCHAR32 **\fIfirst\fP, PCRE_UCHAR32 **\fIlast\fP);"
59 .sp
60 .B int pcre32_get_substring(PCRE_SPTR32 \fIsubject\fP, int *\fIovector\fP,
61 .B " int \fIstringcount\fP, int \fIstringnumber\fP,"
62 .B " PCRE_SPTR32 *\fIstringptr\fP);"
63 .sp
64 .B int pcre32_get_substring_list(PCRE_SPTR32 \fIsubject\fP,
65 .B " int *\fIovector\fP, int \fIstringcount\fP, PCRE_SPTR32 **\fIlistptr\fP);"
66 .sp
67 .B void pcre32_free_substring(PCRE_SPTR32 \fIstringptr\fP);
68 .sp
69 .B void pcre32_free_substring_list(PCRE_SPTR32 *\fIstringptr\fP);
70 .fi
71 .
72 .
73 .SH "PCRE 32-BIT API AUXILIARY FUNCTIONS"
74 .rs
75 .sp
76 .nf
77 .B pcre32_jit_stack *pcre32_jit_stack_alloc(int \fIstartsize\fP, int \fImaxsize\fP);
78 .sp
79 .B void pcre32_jit_stack_free(pcre32_jit_stack *\fIstack\fP);
80 .sp
81 .B void pcre32_assign_jit_stack(pcre32_extra *\fIextra\fP,
82 .B " pcre32_jit_callback \fIcallback\fP, void *\fIdata\fP);"
83 .sp
84 .B const unsigned char *pcre32_maketables(void);
85 .sp
86 .B int pcre32_fullinfo(const pcre32 *\fIcode\fP, "const pcre32_extra *\fIextra\fP,"
87 .B " int \fIwhat\fP, void *\fIwhere\fP);"
88 .sp
89 .B int pcre32_refcount(pcre32 *\fIcode\fP, int \fIadjust\fP);
90 .sp
91 .B int pcre32_config(int \fIwhat\fP, void *\fIwhere\fP);
92 .sp
93 .B const char *pcre32_version(void);
94 .sp
95 .B int pcre32_pattern_to_host_byte_order(pcre32 *\fIcode\fP,
96 .B " pcre32_extra *\fIextra\fP, const unsigned char *\fItables\fP);"
97 .fi
98 .
99 .
100 .SH "PCRE 32-BIT API INDIRECTED FUNCTIONS"
101 .rs
102 .sp
103 .nf
104 .B void *(*pcre32_malloc)(size_t);
105 .sp
106 .B void (*pcre32_free)(void *);
107 .sp
108 .B void *(*pcre32_stack_malloc)(size_t);
109 .sp
110 .B void (*pcre32_stack_free)(void *);
111 .sp
112 .B int (*pcre32_callout)(pcre32_callout_block *);
113 .fi
114 .
115 .
116 .SH "PCRE 32-BIT API 32-BIT-ONLY FUNCTION"
117 .rs
118 .sp
119 .nf
120 .B int pcre32_utf32_to_host_byte_order(PCRE_UCHAR32 *\fIoutput\fP,
121 .B " PCRE_SPTR32 \fIinput\fP, int \fIlength\fP, int *\fIbyte_order\fP,"
122 .B " int \fIkeep_boms\fP);"
123 .fi
124 .
125 .
126 .SH "THE PCRE 32-BIT LIBRARY"
127 .rs
128 .sp
129 Starting with release 8.32, it is possible to compile a PCRE library that
130 supports 32-bit character strings, including UTF-32 strings, as well as or
131 instead of the original 8-bit library. This work was done by Christian Persch,
132 based on the work done by Zoltan Herczeg for the 16-bit library. All three
133 libraries contain identical sets of functions, used in exactly the same way.
134 Only the names of the functions and the data types of their arguments and
135 results are different. To avoid over-complication and reduce the documentation
136 maintenance load, most of the PCRE documentation describes the 8-bit library,
137 with only occasional references to the 16-bit and 32-bit libraries. This page
138 describes what is different when you use the 32-bit library.
139 .P
140 WARNING: A single application can be linked with all or any of the three
141 libraries, but you must take care when processing any particular pattern
142 to use functions from just one library. For example, if you want to study
143 a pattern that was compiled with \fBpcre32_compile()\fP, you must do so
144 with \fBpcre32_study()\fP, not \fBpcre_study()\fP, and you must free the
145 study data with \fBpcre32_free_study()\fP.
146 .
147 .
148 .SH "THE HEADER FILE"
149 .rs
150 .sp
151 There is only one header file, \fBpcre.h\fP. It contains prototypes for all the
152 functions in all libraries, as well as definitions of flags, structures, error
153 codes, etc.
154 .
155 .
156 .SH "THE LIBRARY NAME"
157 .rs
158 .sp
159 In Unix-like systems, the 32-bit library is called \fBlibpcre32\fP, and can
160 normally be accesss by adding \fB-lpcre32\fP to the command for linking an
161 application that uses PCRE.
162 .
163 .
164 .SH "STRING TYPES"
165 .rs
166 .sp
167 In the 8-bit library, strings are passed to PCRE library functions as vectors
168 of bytes with the C type "char *". In the 32-bit library, strings are passed as
169 vectors of unsigned 32-bit quantities. The macro PCRE_UCHAR32 specifies an
170 appropriate data type, and PCRE_SPTR32 is defined as "const PCRE_UCHAR32 *". In
171 very many environments, "unsigned int" is a 32-bit data type. When PCRE is
172 built, it defines PCRE_UCHAR32 as "unsigned int", but checks that it really is
173 a 32-bit data type. If it is not, the build fails with an error message telling
174 the maintainer to modify the definition appropriately.
175 .
176 .
177 .SH "STRUCTURE TYPES"
178 .rs
179 .sp
180 The types of the opaque structures that are used for compiled 32-bit patterns
181 and JIT stacks are \fBpcre32\fP and \fBpcre32_jit_stack\fP respectively. The
182 type of the user-accessible structure that is returned by \fBpcre32_study()\fP
183 is \fBpcre32_extra\fP, and the type of the structure that is used for passing
184 data to a callout function is \fBpcre32_callout_block\fP. These structures
185 contain the same fields, with the same names, as their 8-bit counterparts. The
186 only difference is that pointers to character strings are 32-bit instead of
187 8-bit types.
188 .
189 .
190 .SH "32-BIT FUNCTIONS"
191 .rs
192 .sp
193 For every function in the 8-bit library there is a corresponding function in
194 the 32-bit library with a name that starts with \fBpcre32_\fP instead of
195 \fBpcre_\fP. The prototypes are listed above. In addition, there is one extra
196 function, \fBpcre32_utf32_to_host_byte_order()\fP. This is a utility function
197 that converts a UTF-32 character string to host byte order if necessary. The
198 other 32-bit functions expect the strings they are passed to be in host byte
199 order.
200 .P
201 The \fIinput\fP and \fIoutput\fP arguments of
202 \fBpcre32_utf32_to_host_byte_order()\fP may point to the same address, that is,
203 conversion in place is supported. The output buffer must be at least as long as
204 the input.
205 .P
206 The \fIlength\fP argument specifies the number of 32-bit data units in the
207 input string; a negative value specifies a zero-terminated string.
208 .P
209 If \fIbyte_order\fP is NULL, it is assumed that the string starts off in host
210 byte order. This may be changed by byte-order marks (BOMs) anywhere in the
211 string (commonly as the first character).
212 .P
213 If \fIbyte_order\fP is not NULL, a non-zero value of the integer to which it
214 points means that the input starts off in host byte order, otherwise the
215 opposite order is assumed. Again, BOMs in the string can change this. The final
216 byte order is passed back at the end of processing.
217 .P
218 If \fIkeep_boms\fP is not zero, byte-order mark characters (0xfeff) are copied
219 into the output string. Otherwise they are discarded.
220 .P
221 The result of the function is the number of 32-bit units placed into the output
222 buffer, including the zero terminator if the string was zero-terminated.
223 .
224 .
225 .SH "SUBJECT STRING OFFSETS"
226 .rs
227 .sp
228 The lengths and starting offsets of subject strings must be specified in 32-bit
229 data units, and the offsets within subject strings that are returned by the
230 matching functions are in also 32-bit units rather than bytes.
231 .
232 .
233 .SH "NAMED SUBPATTERNS"
234 .rs
235 .sp
236 The name-to-number translation table that is maintained for named subpatterns
237 uses 32-bit characters. The \fBpcre32_get_stringtable_entries()\fP function
238 returns the length of each entry in the table as the number of 32-bit data
239 units.
240 .
241 .
242 .SH "OPTION NAMES"
243 .rs
244 .sp
245 There are two new general option names, PCRE_UTF32 and PCRE_NO_UTF32_CHECK,
246 which correspond to PCRE_UTF8 and PCRE_NO_UTF8_CHECK in the 8-bit library. In
247 fact, these new options define the same bits in the options word. There is a
248 discussion about the
249 .\" HTML <a href="pcreunicode.html#utf32strings">
250 .\" </a>
251 validity of UTF-32 strings
252 .\"
253 in the
254 .\" HREF
255 \fBpcreunicode\fP
256 .\"
257 page.
258 .P
259 For the \fBpcre32_config()\fP function there is an option PCRE_CONFIG_UTF32
260 that returns 1 if UTF-32 support is configured, otherwise 0. If this option is
261 given to \fBpcre_config()\fP or \fBpcre16_config()\fP, or if the
262 PCRE_CONFIG_UTF8 or PCRE_CONFIG_UTF16 option is given to \fBpcre32_config()\fP,
263 the result is the PCRE_ERROR_BADOPTION error.
264 .
265 .
266 .SH "CHARACTER CODES"
267 .rs
268 .sp
269 In 32-bit mode, when PCRE_UTF32 is not set, character values are treated in the
270 same way as in 8-bit, non UTF-8 mode, except, of course, that they can range
271 from 0 to 0x7fffffff instead of 0 to 0xff. Character types for characters less
272 than 0xff can therefore be influenced by the locale in the same way as before.
273 Characters greater than 0xff have only one case, and no "type" (such as letter
274 or digit).
275 .P
276 In UTF-32 mode, the character code is Unicode, in the range 0 to 0x10ffff, with
277 the exception of values in the range 0xd800 to 0xdfff because those are
278 "surrogate" values that are ill-formed in UTF-32.
279 .P
280 A UTF-32 string can indicate its endianness by special code knows as a
281 byte-order mark (BOM). The PCRE functions do not handle this, expecting strings
282 to be in host byte order. A utility function called
283 \fBpcre32_utf32_to_host_byte_order()\fP is provided to help with this (see
284 above).
285 .
286 .
287 .SH "ERROR NAMES"
288 .rs
289 .sp
290 The error PCRE_ERROR_BADUTF32 corresponds to its 8-bit counterpart.
291 The error PCRE_ERROR_BADMODE is given when a compiled
292 pattern is passed to a function that processes patterns in the other
293 mode, for example, if a pattern compiled with \fBpcre_compile()\fP is passed to
294 \fBpcre32_exec()\fP.
295 .P
296 There are new error codes whose names begin with PCRE_UTF32_ERR for invalid
297 UTF-32 strings, corresponding to the PCRE_UTF8_ERR codes for UTF-8 strings that
298 are described in the section entitled
299 .\" HTML <a href="pcreapi.html#badutf8reasons">
300 .\" </a>
301 "Reason codes for invalid UTF-8 strings"
302 .\"
303 in the main
304 .\" HREF
305 \fBpcreapi\fP
306 .\"
307 page. The UTF-32 errors are:
308 .sp
309 PCRE_UTF32_ERR1 Surrogate character (range from 0xd800 to 0xdfff)
310 PCRE_UTF32_ERR2 Non-character
311 PCRE_UTF32_ERR3 Character > 0x10ffff
312 .
313 .
314 .SH "ERROR TEXTS"
315 .rs
316 .sp
317 If there is an error while compiling a pattern, the error text that is passed
318 back by \fBpcre32_compile()\fP or \fBpcre32_compile2()\fP is still an 8-bit
319 character string, zero-terminated.
320 .
321 .
322 .SH "CALLOUTS"
323 .rs
324 .sp
325 The \fIsubject\fP and \fImark\fP fields in the callout block that is passed to
326 a callout function point to 32-bit vectors.
327 .
328 .
329 .SH "TESTING"
330 .rs
331 .sp
332 The \fBpcretest\fP program continues to operate with 8-bit input and output
333 files, but it can be used for testing the 32-bit library. If it is run with the
334 command line option \fB-32\fP, patterns and subject strings are converted from
335 8-bit to 32-bit before being passed to PCRE, and the 32-bit library functions
336 are used instead of the 8-bit ones. Returned 32-bit strings are converted to
337 8-bit for output. If both the 8-bit and the 16-bit libraries were not compiled,
338 \fBpcretest\fP defaults to 32-bit and the \fB-32\fP option is ignored.
339 .P
340 When PCRE is being built, the \fBRunTest\fP script that is called by "make
341 check" uses the \fBpcretest\fP \fB-C\fP option to discover which of the 8-bit,
342 16-bit and 32-bit libraries has been built, and runs the tests appropriately.
343 .
344 .
345 .SH "NOT SUPPORTED IN 32-BIT MODE"
346 .rs
347 .sp
348 Not all the features of the 8-bit library are available with the 32-bit
349 library. The C++ and POSIX wrapper functions support only the 8-bit library,
350 and the \fBpcregrep\fP program is at present 8-bit only.
351 .
352 .
353 .SH AUTHOR
354 .rs
355 .sp
356 .nf
357 Philip Hazel
358 University Computing Service
359 Cambridge CB2 3QH, England.
360 .fi
361 .
362 .
363 .SH REVISION
364 .rs
365 .sp
366 .nf
367 Last updated: 12 May 2013
368 Copyright (c) 1997-2013 University of Cambridge.
369 .fi

  ViewVC Help
Powered by ViewVC 1.1.5