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

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

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

revision 79 by nigel, Sat Feb 24 21:40:52 2007 UTC revision 577 by ph10, Sun Nov 21 18:51:22 2010 UTC
# Line 17  function is to be called. Different call Line 17  function is to be called. Different call
17  a number less than 256 after the letter C. The default value is zero.  a number less than 256 after the letter C. The default value is zero.
18  For example, this pattern has two callout points:  For example, this pattern has two callout points:
19  .sp  .sp
20    (?C1)\deabc(?C2)def    (?C1)abc(?C2)def
21  .sp  .sp
22  If the PCRE_AUTO_CALLOUT option bit is set when \fBpcre_compile()\fP is called,  If the PCRE_AUTO_CALLOUT option bit is set when \fBpcre_compile()\fP or
23  PCRE automatically inserts callouts, all with number 255, before each item in  \fBpcre_compile2()\fP is called, PCRE automatically inserts callouts, all with
24  the pattern. For example, if PCRE_AUTO_CALLOUT is used with the pattern  number 255, before each item in the pattern. For example, if PCRE_AUTO_CALLOUT
25    is used with the pattern
26  .sp  .sp
27    A(\ed{2}|--)    A(\ed{2}|--)
28  .sp  .sp
# Line 44  trying to optimize the performance of a Line 45  trying to optimize the performance of a
45  .rs  .rs
46  .sp  .sp
47  You should be aware that, because of optimizations in the way PCRE matches  You should be aware that, because of optimizations in the way PCRE matches
48  patterns, callouts sometimes do not happen. For example, if the pattern is  patterns by default, callouts sometimes do not happen. For example, if the
49    pattern is
50  .sp  .sp
51    ab(?C4)cd    ab(?C4)cd
52  .sp  .sp
# Line 52  PCRE knows that any matching string must Line 54  PCRE knows that any matching string must
54  string is "abyz", the lack of "d" means that matching doesn't ever start, and  string is "abyz", the lack of "d" means that matching doesn't ever start, and
55  the callout is never reached. However, with "abyd", though the result is still  the callout is never reached. However, with "abyd", though the result is still
56  no match, the callout is obeyed.  no match, the callout is obeyed.
57    .P
58    If the pattern is studied, PCRE knows the minimum length of a matching string,
59    and will immediately give a "no match" return without actually running a match
60    if the subject is not long enough, or, for unanchored patterns, if it has
61    been scanned far enough.
62    .P
63    You can disable these optimizations by passing the PCRE_NO_START_OPTIMIZE
64    option to \fBpcre_compile()\fP, \fBpcre_exec()\fP, or \fBpcre_dfa_exec()\fP,
65    or by starting the pattern with (*NO_START_OPT). This slows down the matching
66    process, but does ensure that callouts such as the example above are obeyed.
67  .  .
68  .  .
69  .SH "THE CALLOUT INTERFACE"  .SH "THE CALLOUT INTERFACE"
# Line 95  not useful. Line 107  not useful.
107  The \fIsubject\fP and \fIsubject_length\fP fields contain copies of the values  The \fIsubject\fP and \fIsubject_length\fP fields contain copies of the values
108  that were passed to \fBpcre_exec()\fP.  that were passed to \fBpcre_exec()\fP.
109  .P  .P
110  The \fIstart_match\fP field contains the offset within the subject at which the  The \fIstart_match\fP field normally contains the offset within the subject at
111  current match attempt started. If the pattern is not anchored, the callout  which the current match attempt started. However, if the escape sequence \eK
112  function may be called several times from the same point in the pattern for  has been encountered, this value is changed to reflect the modified starting
113  different starting points in the subject.  point. If the pattern is not anchored, the callout function may be called
114    several times from the same point in the pattern for different starting points
115    in the subject.
116  .P  .P
117  The \fIcurrent_position\fP field contains the offset within the subject of the  The \fIcurrent_position\fP field contains the offset within the subject of the
118  current match pointer.  current match pointer.
# Line 147  The external callout function returns an Line 161  The external callout function returns an
161  matching proceeds as normal. If the value is greater than zero, matching fails  matching proceeds as normal. If the value is greater than zero, matching fails
162  at the current point, but the testing of other matching possibilities goes  at the current point, but the testing of other matching possibilities goes
163  ahead, just as if a lookahead assertion had failed. If the value is less than  ahead, just as if a lookahead assertion had failed. If the value is less than
164  zero, the match is abandoned, and \fBpcre_exec()\fP (or \fBpcre_dfa_exec()\fP)  zero, the match is abandoned, and \fBpcre_exec()\fP or \fBpcre_dfa_exec()\fP
165  returns the negative value.  returns the negative value.
166  .P  .P
167  Negative values should normally be chosen from the set of PCRE_ERROR_xxx  Negative values should normally be chosen from the set of PCRE_ERROR_xxx
168  values. In particular, PCRE_ERROR_NOMATCH forces a standard "no match" failure.  values. In particular, PCRE_ERROR_NOMATCH forces a standard "no match" failure.
169  The error number PCRE_ERROR_CALLOUT is reserved for use by callout functions;  The error number PCRE_ERROR_CALLOUT is reserved for use by callout functions;
170  it will never be used by PCRE itself.  it will never be used by PCRE itself.
171  .P  .
172  .in 0  .
173  Last updated: 28 February 2005  .SH AUTHOR
174  .br  .rs
175  Copyright (c) 1997-2005 University of Cambridge.  .sp
176    .nf
177    Philip Hazel
178    University Computing Service
179    Cambridge CB2 3QH, England.
180    .fi
181    .
182    .
183    .SH REVISION
184    .rs
185    .sp
186    .nf
187    Last updated: 21 November 2010
188    Copyright (c) 1997-2010 University of Cambridge.
189    .fi

Legend:
Removed from v.79  
changed lines
  Added in v.577

  ViewVC Help
Powered by ViewVC 1.1.5