Sortix 1.1dev ports manual
This manual documents Sortix 1.1dev ports. You can instead view this document in the latest official manual.
PCRECALLOUT(3) | Library Functions Manual | PCRECALLOUT(3) |
NAME
PCRE - Perl-compatible regular expressionsSYNOPSIS
#include <pcre.h> int (*pcre_callout)(pcre_callout_block *); int (*pcre16_callout)(pcre16_callout_block *); int (*pcre32_callout)(pcre32_callout_block *);DESCRIPTION
PCRE provides a feature called "callout", which is a means of temporarily passing control to the caller of PCRE in the middle of pattern matching. The caller of PCRE provides an external function by putting its entry point in the global variable pcre_callout (pcre16_callout for the 16-bit library, pcre32_callout for the 32-bit library). By default, this variable contains NULL, which disables all calling out. Within a regular expression, (?C) indicates the points at which the external function is to be called. Different callout points can be identified by putting a number less than 256 after the letter C. The default value is zero. For example, this pattern has two callout points:(?C1)abc(?C2)def
A(\d{2}|--)
(?(?C9)(?=a)ab|de)
MISSING CALLOUTS
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
--->aaaa
+0 ^ ^
+1 ^ a+
+3 ^ ^ [bc]
+3 ^ ^ [bc]
+3 ^ ^ [bc]
+3 ^^ [bc]
No match
ab(?C4)cd
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:int version;
int callout_number;
int * offset_vector;
const char * subject; (8-bit version)
PCRE_SPTR16 subject; (16-bit version)
PCRE_SPTR32 subject; (32-bit version)
int subject_length;
int start_match;
int current_position;
int capture_top;
int capture_last;
void * callout_data;
int pattern_position;
int next_item_length;
const unsigned char * mark; (8-bit version)
const PCRE_UCHAR16 * mark; (16-bit version)
const PCRE_UCHAR32 * mark; (32-bit version)
RETURN VALUES
The external callout function returns an integer to PCRE. If the value is zero, matching proceeds as normal. If the value is greater than zero, matching fails at the current point, but the testing of other matching possibilities goes ahead, just as if a lookahead assertion had failed. If the value is less than zero, the match is abandoned, the matching function returns the negative value. Negative values should normally be chosen from the set of PCRE_ERROR_xxx values. In particular, PCRE_ERROR_NOMATCH forces a standard "no match" failure. The error number PCRE_ERROR_CALLOUT is reserved for use by callout functions; it will never be used by PCRE itself.AUTHOR
Philip Hazel University Computing Service Cambridge CB2 3QH, England.
REVISION
Last updated: 12 November 2013 Copyright (c) 1997-2013 University of Cambridge.
12 November 2013 | PCRE 8.34 |