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

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

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

revision 111 by ph10, Thu Mar 8 16:53:09 2007 UTC revision 461 by ph10, Mon Oct 5 10:59:35 2009 UTC
# Line 37  function is to be called. Different call Line 37  function is to be called. Different call
37  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.
38  For example, this pattern has two callout points:  For example, this pattern has two callout points:
39  <pre>  <pre>
40    (?C1)\deabc(?C2)def    (?C1)abc(?C2)def
41  </pre>  </pre>
42  If the PCRE_AUTO_CALLOUT option bit is set when <b>pcre_compile()</b> is called,  If the PCRE_AUTO_CALLOUT option bit is set when <b>pcre_compile()</b> or
43  PCRE automatically inserts callouts, all with number 255, before each item in  <b>pcre_compile2()</b> is called, PCRE automatically inserts callouts, all with
44  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
45    is used with the pattern
46  <pre>  <pre>
47    A(\d{2}|--)    A(\d{2}|--)
48  </pre>  </pre>
# Line 62  trying to optimize the performance of a Line 63  trying to optimize the performance of a
63  <br><a name="SEC2" href="#TOC1">MISSING CALLOUTS</a><br>  <br><a name="SEC2" href="#TOC1">MISSING CALLOUTS</a><br>
64  <P>  <P>
65  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
66  patterns, callouts sometimes do not happen. For example, if the pattern is  patterns by default, callouts sometimes do not happen. For example, if the
67    pattern is
68  <pre>  <pre>
69    ab(?C4)cd    ab(?C4)cd
70  </pre>  </pre>
# Line 71  string is "abyz", the lack of "d" means Line 73  string is "abyz", the lack of "d" means
73  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
74  no match, the callout is obeyed.  no match, the callout is obeyed.
75  </P>  </P>
76    <P>
77    If the pattern is studied, PCRE knows the minimum length of a matching string,
78    and will immediately give a "no match" return without actually running a match
79    if the subject is not long enough, or, for unanchored patterns, if it has
80    been scanned far enough.
81    </P>
82    <P>
83    You can disable these optimizations by passing the PCRE_NO_START_OPTIMIZE
84    option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>. This slows down the
85    matching process, but does ensure that callouts such as the example above are
86    obeyed.
87    </P>
88  <br><a name="SEC3" href="#TOC1">THE CALLOUT INTERFACE</a><br>  <br><a name="SEC3" href="#TOC1">THE CALLOUT INTERFACE</a><br>
89  <P>  <P>
90  During matching, when PCRE reaches a callout point, the external function  During matching, when PCRE reaches a callout point, the external function
# Line 115  The <i>subject</i> and <i>subject_length Line 129  The <i>subject</i> and <i>subject_length
129  that were passed to <b>pcre_exec()</b>.  that were passed to <b>pcre_exec()</b>.
130  </P>  </P>
131  <P>  <P>
132  The <i>start_match</i> field contains the offset within the subject at which the  The <i>start_match</i> field normally contains the offset within the subject at
133  current match attempt started. If the pattern is not anchored, the callout  which the current match attempt started. However, if the escape sequence \K
134  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
135  different starting points in the subject.  point. If the pattern is not anchored, the callout function may be called
136    several times from the same point in the pattern for different starting points
137    in the subject.
138  </P>  </P>
139  <P>  <P>
140  The <i>current_position</i> field contains the offset within the subject of the  The <i>current_position</i> field contains the offset within the subject of the
# Line 170  The external callout function returns an Line 186  The external callout function returns an
186  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
187  at the current point, but the testing of other matching possibilities goes  at the current point, but the testing of other matching possibilities goes
188  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
189  zero, the match is abandoned, and <b>pcre_exec()</b> (or <b>pcre_dfa_exec()</b>)  zero, the match is abandoned, and <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
190  returns the negative value.  returns the negative value.
191  </P>  </P>
192  <P>  <P>
# Line 190  Cambridge CB2 3QH, England. Line 206  Cambridge CB2 3QH, England.
206  </P>  </P>
207  <br><a name="SEC6" href="#TOC1">REVISION</a><br>  <br><a name="SEC6" href="#TOC1">REVISION</a><br>
208  <P>  <P>
209  Last updated: 06 March 2007  Last updated: 29 September 2009
210  <br>  <br>
211  Copyright &copy; 1997-2007 University of Cambridge.  Copyright &copy; 1997-2009 University of Cambridge.
212  <br>  <br>
213  <p>  <p>
214  Return to the <a href="index.html">PCRE index page</a>.  Return to the <a href="index.html">PCRE index page</a>.

Legend:
Removed from v.111  
changed lines
  Added in v.461

  ViewVC Help
Powered by ViewVC 1.1.5