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

Diff of /code/trunk/doc/pcreapi.3

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 191 by ph10, Mon Jul 30 11:13:54 2007 UTC revision 226 by ph10, Tue Aug 21 11:46:08 2007 UTC
# Line 240  pair of characters that indicate a line Line 240  pair of characters that indicate a line
240  convention affects the handling of the dot, circumflex, and dollar  convention affects the handling of the dot, circumflex, and dollar
241  metacharacters, the handling of #-comments in /x mode, and, when CRLF is a  metacharacters, the handling of #-comments in /x mode, and, when CRLF is a
242  recognized line ending sequence, the match position advancement for a  recognized line ending sequence, the match position advancement for a
243  non-anchored pattern. The choice of newline convention does not affect the  non-anchored pattern. There is more detail about this in the
244  interpretation of the \en or \er escape sequences.  .\" HTML <a href="#execoptions">
245    .\" </a>
246    section on \fBpcre_exec()\fP options
247    .\"
248    below. The choice of newline convention does not affect the interpretation of
249    the \en or \er escape sequences.
250  .  .
251  .  .
252  .SH MULTITHREADING  .SH MULTITHREADING
# Line 601  page. Line 606  page.
606    PCRE_NO_UTF8_CHECK    PCRE_NO_UTF8_CHECK
607  .sp  .sp
608  When PCRE_UTF8 is set, the validity of the pattern as a UTF-8 string is  When PCRE_UTF8 is set, the validity of the pattern as a UTF-8 string is
609  automatically checked. If an invalid UTF-8 sequence of bytes is found,  automatically checked. There is a discussion about the
610  \fBpcre_compile()\fP returns an error. If you already know that your pattern is  .\" HTML <a href="pcre.html#utf8strings">
611  valid, and you want to skip this check for performance reasons, you can set the  .\" </a>
612  PCRE_NO_UTF8_CHECK option. When it is set, the effect of passing an invalid  validity of UTF-8 strings
613  UTF-8 string as a pattern is undefined. It may cause your program to crash.  .\"
614  Note that this option can also be passed to \fBpcre_exec()\fP and  in the main
615  \fBpcre_dfa_exec()\fP, to suppress the UTF-8 validity checking of subject  .\" HREF
616  strings.  \fBpcre\fP
617    .\"
618    page. If an invalid UTF-8 sequence of bytes is found, \fBpcre_compile()\fP
619    returns an error. If you already know that your pattern is valid, and you want
620    to skip this check for performance reasons, you can set the PCRE_NO_UTF8_CHECK
621    option. When it is set, the effect of passing an invalid UTF-8 string as a
622    pattern is undefined. It may cause your program to crash. Note that this option
623    can also be passed to \fBpcre_exec()\fP and \fBpcre_dfa_exec()\fP, to suppress
624    the UTF-8 validity checking of subject strings.
625  .  .
626  .  .
627  .SH "COMPILATION ERROR CODES"  .SH "COMPILATION ERROR CODES"
# Line 669  out of use. To avoid confusion, they hav Line 682  out of use. To avoid confusion, they hav
682    47  unknown property name after \eP or \ep    47  unknown property name after \eP or \ep
683    48  subpattern name is too long (maximum 32 characters)    48  subpattern name is too long (maximum 32 characters)
684    49  too many named subpatterns (maximum 10,000)    49  too many named subpatterns (maximum 10,000)
685    50  repeated subpattern is too long    50  [this code is not in use]
686    51  octal value is greater than \e377 (not in UTF-8 mode)    51  octal value is greater than \e377 (not in UTF-8 mode)
687    52  internal error: overran compiling workspace    52  internal error: overran compiling workspace
688    53  internal error: previously-checked referenced subpattern not found    53  internal error: previously-checked referenced subpattern not found
# Line 874  table indicating a fixed set of bytes fo Line 887  table indicating a fixed set of bytes fo
887  string, a pointer to the table is returned. Otherwise NULL is returned. The  string, a pointer to the table is returned. Otherwise NULL is returned. The
888  fourth argument should point to an \fBunsigned char *\fP variable.  fourth argument should point to an \fBunsigned char *\fP variable.
889  .sp  .sp
890      PCRE_INFO_HASCRORLF
891    .sp
892    Return 1 if the pattern contains any explicit matches for CR or LF characters,
893    otherwise 0. The fourth argument should point to an \fBint\fP variable.
894    .sp
895    PCRE_INFO_JCHANGED    PCRE_INFO_JCHANGED
896  .sp  .sp
897  Return 1 if the (?J) option setting is used in the pattern, otherwise 0. The  Return 1 if the (?J) option setting is used in the pattern, otherwise 0. The
# Line 947  matching is used. Line 965  matching is used.
965  Return a copy of the options with which the pattern was compiled. The fourth  Return a copy of the options with which the pattern was compiled. The fourth
966  argument should point to an \fBunsigned long int\fP variable. These option bits  argument should point to an \fBunsigned long int\fP variable. These option bits
967  are those specified in the call to \fBpcre_compile()\fP, modified by any  are those specified in the call to \fBpcre_compile()\fP, modified by any
968  top-level option settings within the pattern itself.  top-level option settings at the start of the pattern itself. In other words,
969    they are the options that will be in force when matching starts. For example,
970    if the pattern /(?im)abc(?-i)d/ is compiled with the PCRE_EXTENDED option, the
971    result is PCRE_CASELESS, PCRE_MULTILINE, and PCRE_EXTENDED.
972  .P  .P
973  A pattern is automatically anchored by PCRE if all of its top-level  A pattern is automatically anchored by PCRE if all of its top-level
974  alternatives begin with one of the following:  alternatives begin with one of the following:
# Line 1158  called. See the Line 1179  called. See the
1179  .\"  .\"
1180  documentation for a discussion of saving compiled patterns for later use.  documentation for a discussion of saving compiled patterns for later use.
1181  .  .
1182    .\" HTML <a name="execoptions"></a>
1183  .SS "Option bits for \fBpcre_exec()\fP"  .SS "Option bits for \fBpcre_exec()\fP"
1184  .rs  .rs
1185  .sp  .sp
# Line 1183  the pattern was compiled. For details, s Line 1205  the pattern was compiled. For details, s
1205  \fBpcre_compile()\fP above. During matching, the newline choice affects the  \fBpcre_compile()\fP above. During matching, the newline choice affects the
1206  behaviour of the dot, circumflex, and dollar metacharacters. It may also alter  behaviour of the dot, circumflex, and dollar metacharacters. It may also alter
1207  the way the match position is advanced after a match failure for an unanchored  the way the match position is advanced after a match failure for an unanchored
1208  pattern. When PCRE_NEWLINE_CRLF, PCRE_NEWLINE_ANYCRLF, or PCRE_NEWLINE_ANY is  pattern.
1209  set, and a match attempt fails when the current position is at a CRLF sequence,  .P
1210  the match position is advanced by two characters instead of one, in other  When PCRE_NEWLINE_CRLF, PCRE_NEWLINE_ANYCRLF, or PCRE_NEWLINE_ANY is set, and a
1211  words, to after the CRLF.  match attempt for an unanchored pattern fails when the current position is at a
1212    CRLF sequence, and the pattern contains no explicit matches for CR or NL
1213    characters, the match position is advanced by two characters instead of one, in
1214    other words, to after the CRLF.
1215    .P
1216    The above rule is a compromise that makes the most common cases work as
1217    expected. For example, if the pattern is .+A (and the PCRE_DOTALL option is not
1218    set), it does not match the string "\er\enA" because, after failing at the
1219    start, it skips both the CR and the LF before retrying. However, the pattern
1220    [\er\en]A does match that string, because it contains an explicit CR or LF
1221    reference, and so advances only by one character after the first failure.
1222    Note than an explicit CR or LF reference occurs for negated character classes
1223    such as [^X] because they can match CR or LF characters.
1224    .P
1225    Notwithstanding the above, anomalous effects may still occur when CRLF is a
1226    valid newline sequence and explicit \er or \en escapes appear in the pattern.
1227  .sp  .sp
1228    PCRE_NOTBOL    PCRE_NOTBOL
1229  .sp  .sp
# Line 1229  code that demonstrates how to do this in Line 1266  code that demonstrates how to do this in
1266  When PCRE_UTF8 is set at compile time, the validity of the subject as a UTF-8  When PCRE_UTF8 is set at compile time, the validity of the subject as a UTF-8
1267  string is automatically checked when \fBpcre_exec()\fP is subsequently called.  string is automatically checked when \fBpcre_exec()\fP is subsequently called.
1268  The value of \fIstartoffset\fP is also checked to ensure that it points to the  The value of \fIstartoffset\fP is also checked to ensure that it points to the
1269  start of a UTF-8 character. If an invalid UTF-8 sequence of bytes is found,  start of a UTF-8 character. There is a discussion about the validity of UTF-8
1270  \fBpcre_exec()\fP returns the error PCRE_ERROR_BADUTF8. If \fIstartoffset\fP  strings in the
1271  contains an invalid value, PCRE_ERROR_BADUTF8_OFFSET is returned.  .\" HTML <a href="pcre.html#utf8strings">
1272    .\" </a>
1273    section on UTF-8 support
1274    .\"
1275    in the main
1276    .\" HREF
1277    \fBpcre\fP
1278    .\"
1279    page. If an invalid UTF-8 sequence of bytes is found, \fBpcre_exec()\fP returns
1280    the error PCRE_ERROR_BADUTF8. If \fIstartoffset\fP contains an invalid value,
1281    PCRE_ERROR_BADUTF8_OFFSET is returned.
1282  .P  .P
1283  If you already know that your subject is valid, and you want to skip these  If you already know that your subject is valid, and you want to skip these
1284  checks for performance reasons, you can set the PCRE_NO_UTF8_CHECK option when  checks for performance reasons, you can set the PCRE_NO_UTF8_CHECK option when
# Line 1463  The internal recursion limit, as specifi Line 1510  The internal recursion limit, as specifi
1510  field in a \fBpcre_extra\fP structure (or defaulted) was reached. See the  field in a \fBpcre_extra\fP structure (or defaulted) was reached. See the
1511  description above.  description above.
1512  .sp  .sp
   PCRE_ERROR_NULLWSLIMIT    (-22)  
 .sp  
 When a parenthesized subpattern that can match an empty substring is repeated  
 with an unbounded upper limit, the subject position at the start of the group  
 must be remembered, so that a test for an empty string can be made when the end  
 of the group is reached. The repetition loop is automatically terminated when  
 an empty string is matched.  
 .P  
 Some workspace is required for remembering the starting position. For most  
 capturing subpatterns, an internal recursive call of the match() function is  
 used, and in this case, the workspace is taken from the runtime stack. However,  
 for non-capturing subpatterns, this is not available. Instead, some fixed  
 workspace (taken from the top-level stack) is used. If it runs out, the  
 PCRE_ERROR_NULLWSLIMIT error is given. The size of the fixed workspace allows  
 for up to 1000 repetitions of a non-capturing subpattern that might match an  
 empty string. If this limit is a problem for you, you can sometimes get round  
 it by changing a non-capturing subpattern into a capturing one, but that will  
 increase the amount of runtime stack that is used.  
 .sp  
1513    PCRE_ERROR_BADNEWLINE     (-23)    PCRE_ERROR_BADNEWLINE     (-23)
1514  .sp  .sp
1515  An invalid combination of PCRE_NEWLINE_\fIxxx\fP options was given.  An invalid combination of PCRE_NEWLINE_\fIxxx\fP options was given.
1516  .P  .P
1517  Error numbers -16 to -20 are not used by \fBpcre_exec()\fP.  Error numbers -16 to -20 and -22 are not used by \fBpcre_exec()\fP.
1518  .  .
1519  .  .
1520  .SH "EXTRACTING CAPTURED SUBSTRINGS BY NUMBER"  .SH "EXTRACTING CAPTURED SUBSTRINGS BY NUMBER"
# Line 1651  example is shown in the Line 1679  example is shown in the
1679  .\" HREF  .\" HREF
1680  \fBpcrepattern\fP  \fBpcrepattern\fP
1681  .\"  .\"
1682  documentation. When duplicates are present, \fBpcre_copy_named_substring()\fP  documentation.
1683  and \fBpcre_get_named_substring()\fP return the first substring corresponding  .P
1684  to the given name that is set. If none are set, an empty string is returned.  When duplicates are present, \fBpcre_copy_named_substring()\fP and
1685  The \fBpcre_get_stringnumber()\fP function returns one of the numbers that are  \fBpcre_get_named_substring()\fP return the first substring corresponding to
1686  associated with the name, but it is not defined which it is.  the given name that is set. If none are set, PCRE_ERROR_NOSUBSTRING (-7) is
1687  .sp  returned; no data is returned. The \fBpcre_get_stringnumber()\fP function
1688    returns one of the numbers that are associated with the name, but it is not
1689    defined which it is.
1690    .P
1691  If you want to get full details of all captured substrings for a given name,  If you want to get full details of all captured substrings for a given name,
1692  you must use the \fBpcre_get_stringtable_entries()\fP function. The first  you must use the \fBpcre_get_stringtable_entries()\fP function. The first
1693  argument is the compiled pattern, and the second is the name. The third and  argument is the compiled pattern, and the second is the name. The third and
# Line 1881  Cambridge CB2 3QH, England. Line 1912  Cambridge CB2 3QH, England.
1912  .rs  .rs
1913  .sp  .sp
1914  .nf  .nf
1915  Last updated: 30 July 2007  Last updated: 21 August 2007
1916  Copyright (c) 1997-2007 University of Cambridge.  Copyright (c) 1997-2007 University of Cambridge.
1917  .fi  .fi

Legend:
Removed from v.191  
changed lines
  Added in v.226

  ViewVC Help
Powered by ViewVC 1.1.5