--- embedaddon/pcre/doc/html/pcrecallout.html 2013/07/22 08:25:57 1.1.1.3 +++ embedaddon/pcre/doc/html/pcrecallout.html 2014/06/15 19:46:05 1.1.1.4 @@ -77,16 +77,51 @@ independent groups). Automatic callouts can be used for tracking the progress of pattern matching. The pcretest -command has an option that sets automatic callouts; when it is used, the output -indicates how the pattern is matched. This is useful information when you are -trying to optimize the performance of a particular pattern. +program has a pattern qualifier (/C) that sets automatic callouts; when it is +used, the output indicates how the pattern is being matched. This is useful +information when you are trying to optimize the performance of a particular +pattern.


MISSING CALLOUTS

-You should be aware that, because of optimizations in the way PCRE matches -patterns by default, callouts sometimes do not happen. For example, if the -pattern is +You should be aware that, because of optimizations in the way PCRE compiles and +matches patterns, callouts sometimes do not happen exactly as you might expect. +

+

+At compile time, PCRE "auto-possessifies" repeated items when it knows that +what follows cannot be part of the repeat. For example, a+[bc] is compiled as +if it were a++[bc]. The pcretest output when this pattern is anchored and +then applied with automatic callouts to the string "aaaa" is:

+  --->aaaa
+   +0 ^        ^
+   +1 ^        a+
+   +3 ^   ^    [bc]
+  No match
+
+This indicates that when matching [bc] fails, there is no backtracking into a+ +and therefore the callouts that would be taken for the backtracks do not occur. +You can disable the auto-possessify feature by passing PCRE_NO_AUTO_POSSESS +to pcre_compile(), or starting the pattern with (*NO_AUTO_POSSESS). If +this is done in pcretest (using the /O qualifier), the output changes to +this: +
+  --->aaaa
+   +0 ^        ^
+   +1 ^        a+
+   +3 ^   ^    [bc]
+   +3 ^  ^     [bc]
+   +3 ^ ^      [bc]
+   +3 ^^       [bc]
+  No match
+
+This time, when matching [bc] fails, the matcher backtracks into a+ and tries +again, repeatedly, until a+ itself fails. +

+

+Other optimizations that provide fast "no match" results also affect callouts. +For example, if the pattern is +

   ab(?C4)cd
 
PCRE knows that any matching string must contain the letter "d". If the subject @@ -109,11 +144,11 @@ callouts such as the example above are obeyed.
THE CALLOUT INTERFACE

During matching, when PCRE reaches a callout point, the external function -defined by pcre_callout or pcre[16|32]_callout is called -(if it is set). This applies to both normal and DFA matching. The only -argument to the callout function is a pointer to a pcre_callout -or pcre[16|32]_callout block. -These structures contains the following fields: +defined by pcre_callout or pcre[16|32]_callout is called (if it is +set). This applies to both normal and DFA matching. The only argument to the +callout function is a pointer to a pcre_callout or +pcre[16|32]_callout block. These structures contains the following +fields:

   int           version;
   int           callout_number;
@@ -242,7 +277,7 @@ Cambridge CB2 3QH, England.
 


REVISION

-Last updated: 03 March 2013 +Last updated: 12 November 2013
Copyright © 1997-2013 University of Cambridge.