tin  2.4.5
About: TIN is a threaded NNTP and spool based UseNet newsreader.
  Fossies Dox: tin-2.4.5.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

pcre_compile.c File Reference
#include "pcre_internal.h"
Include dependency graph for pcre_compile.c:

Go to the source code of this file.

Macros

#define NLBLOCK   cd /* Block containing newline information */
 
#define PSSTART   start_pattern /* Field containing processed string start */
 
#define PSEND   end_pattern /* Field containing processed string end */
 
#define COMPILE_WORK_SIZE   (4096)
 
#define STRING(a)   # a
 
#define XSTRING(s)   STRING(s)
 

Functions

static BOOL compile_regex (int, int, uschar **, const uschar **, int *, BOOL, int, int *, int *, branch_chain *, compile_data *, int *)
 
static int check_escape (const uschar **ptrptr, int *errorcodeptr, int bracount, int options, BOOL isclass)
 
static BOOL is_counted_repeat (const uschar *p)
 
static const uscharread_repeat_counts (const uschar *p, int *minp, int *maxp, int *errorcodeptr)
 
static int find_parens (const uschar *ptr, int count, const uschar *name, int lorn, BOOL xmode)
 
static const uscharfirst_significant_code (const uschar *code, int *options, int optbit, BOOL skipassert)
 
static int find_fixedlength (uschar *code, int options)
 
static const uscharfind_bracket (const uschar *code, BOOL utf8, int number)
 
static const uscharfind_recurse (const uschar *code, BOOL utf8)
 
static BOOL could_be_empty_branch (const uschar *code, const uschar *endcode, BOOL utf8)
 
static BOOL could_be_empty (const uschar *code, const uschar *endcode, branch_chain *bcptr, BOOL utf8)
 
static BOOL check_posix_syntax (const uschar *ptr, const uschar **endptr, compile_data *cd)
 
static int check_posix_name (const uschar *ptr, int len)
 
static void adjust_recurse (uschar *group, int adjust, BOOL utf8, compile_data *cd, uschar *save_hwm)
 
static uscharauto_callout (uschar *code, const uschar *ptr, compile_data *cd)
 
static void complete_callout (uschar *previous_callout, const uschar *ptr, compile_data *cd)
 
static BOOL check_auto_possessive (int op_code, int item, BOOL utf8, uschar *utf8_char, const uschar *ptr, int options, compile_data *cd)
 
static BOOL compile_branch (int *optionsptr, uschar **codeptr, const uschar **ptrptr, int *errorcodeptr, int *firstbyteptr, int *reqbyteptr, branch_chain *bcptr, compile_data *cd, int *lengthptr)
 
static BOOL is_anchored (register const uschar *code, int *options, unsigned int bracket_map, unsigned int backref_map)
 
static BOOL is_startline (const uschar *code, unsigned int bracket_map, unsigned int backref_map)
 
static int find_firstassertedchar (const uschar *code, int *options, BOOL inassert)
 
pcrepcre_compile (const char *pattern, int options, const char **errorptr, int *erroroffset, const unsigned char *tables)
 
pcrepcre_compile2 (const char *pattern, int options, int *errorcodeptr, const char **errorptr, int *erroroffset, const unsigned char *tables)
 

Variables

static const short int escapes []
 
static const char *const posix_names []
 
static const uschar posix_name_lengths []
 
static const int posix_class_maps []
 
static const char * error_texts []
 
static const unsigned char digitab []
 

Macro Definition Documentation

◆ COMPILE_WORK_SIZE

#define COMPILE_WORK_SIZE   (4096)

Code parameters and static tables *

Definition at line 77 of file pcre_compile.c.

◆ NLBLOCK

#define NLBLOCK   cd /* Block containing newline information */

Perl-Compatible Regular Expressions *

Definition at line 45 of file pcre_compile.c.

◆ PSEND

#define PSEND   end_pattern /* Field containing processed string end */

Definition at line 47 of file pcre_compile.c.

◆ PSSTART

#define PSSTART   start_pattern /* Field containing processed string start */

Definition at line 46 of file pcre_compile.c.

◆ STRING

#define STRING (   a)    # a

Definition at line 168 of file pcre_compile.c.

◆ XSTRING

#define XSTRING (   s)    STRING(s)

Definition at line 169 of file pcre_compile.c.

Function Documentation

◆ adjust_recurse()

static void adjust_recurse ( uschar group,
int  adjust,
BOOL  utf8,
compile_data cd,
uschar save_hwm 
)
static

Adjust OP_RECURSE items in repeated group *

Definition at line 1622 of file pcre_compile.c.

References find_recurse(), compile_data::hwm, offset, compile_data::start_code, and utf8.

Referenced by compile_branch().

◆ auto_callout()

static uschar* auto_callout ( uschar code,
const uschar ptr,
compile_data cd 
)
static

Insert an automatic callout point *

Definition at line 1675 of file pcre_compile.c.

References code, OP_CALLOUT, and compile_data::start_pattern.

Referenced by compile_branch().

◆ check_auto_possessive()

static BOOL check_auto_possessive ( int  op_code,
int  item,
BOOL  utf8,
uschar utf8_char,
const uschar ptr,
int  options,
compile_data cd 
)
static

◆ check_escape()

static int check_escape ( const uschar **  ptrptr,
int *  errorcodeptr,
int  bracount,
int  options,
BOOL  isclass 
)
static

Handle escapes *

Definition at line 406 of file pcre_compile.c.

References ctype_digit, ctype_xdigit, digitab, ERR1, ERR15, ERR2, ERR3, ERR34, ERR37, ERR51, ERR57, ESC_REF, escapes, FALSE, GETCHARINCTEST, PCRE_EXTRA, PCRE_UTF8, TRUE, and utf8.

Referenced by check_auto_possessive(), and compile_branch().

◆ check_posix_name()

static int check_posix_name ( const uschar ptr,
int  len 
)
static

Check POSIX class name *

Definition at line 1578 of file pcre_compile.c.

References posix_name_lengths, and posix_names.

Referenced by compile_branch().

◆ check_posix_syntax()

static BOOL check_posix_syntax ( const uschar ptr,
const uschar **  endptr,
compile_data cd 
)
static

Check for POSIX class syntax *

Definition at line 1546 of file pcre_compile.c.

References ctype_letter, compile_data::ctypes, FALSE, and TRUE.

Referenced by compile_branch().

◆ compile_branch()

static BOOL compile_branch ( int *  optionsptr,
uschar **  codeptr,
const uschar **  ptrptr,
int *  errorcodeptr,
int *  firstbyteptr,
int *  reqbyteptr,
branch_chain bcptr,
compile_data cd,
int *  lengthptr 
)
static

Compile one branch *

Definition at line 2016 of file pcre_compile.c.

References _pcre_OP_lengths, _pcre_ord2utf8(), _pcre_ucp_othercase(), adjust_recurse(), auto_callout(), compile_data::backref_map, compile_data::bracount, cbit_digit, cbit_space, cbit_word, compile_data::cbits, check_auto_possessive(), check_escape(), check_posix_name(), check_posix_syntax(), code, compile_regex(), COMPILE_WORK_SIZE, complete_callout(), could_be_empty(), could_be_empty_branch(), ctype_digit, ctype_space, ctype_word, compile_data::ctypes, digitab, DPRINTF, ERR11, ERR12, ERR13, ERR14, ERR15, ERR18, ERR24, ERR26, ERR27, ERR28, ERR29, ERR30, ERR31, ERR35, ERR38, ERR39, ERR40, ERR41, ERR42, ERR43, ERR45, ERR48, ERR49, ERR50, ERR52, ERR54, ERR55, ERR6, ERR7, ERR8, ERR9, ESC_b, ESC_d, ESC_D, ESC_E, ESC_k, ESC_p, ESC_P, ESC_Q, ESC_R, ESC_REF, ESC_s, ESC_S, ESC_W, ESC_w, ESC_X, ESC_Z, compile_data::external_options, FALSE, compile_data::fcc, find_bracket(), find_parens(), GET2, GETCHARLEN, compile_data::hwm, is_counted_repeat(), IS_NEWLINE, MAX_DUPLENGTH, MAX_NAME_COUNT, MAX_NAME_SIZE, memmove, name, compile_data::name_entry_size, compile_data::name_table, compile_data::names_found, compile_data::nllen, compile_data::nopartial, NOTACHAR, offset, OP_ALT, OP_ANY, OP_ASSERT, OP_ASSERT_NOT, OP_ASSERTBACK, OP_ASSERTBACK_NOT, OP_BRA, OP_BRAZERO, OP_CALLOUT, OP_CBRA, OP_CHAR, OP_CHARNC, OP_CIRC, OP_CLASS, OP_COND, OP_CREF, OP_CRPLUS, OP_CRQUERY, OP_CRRANGE, OP_CRSTAR, OP_DEF, OP_DOLL, OP_END, OP_EODN, OP_EXACT, OP_KET, OP_KETRMAX, OP_NCLASS, OP_NOT, OP_NOTEXACT, OP_NOTPLUS, OP_NOTPOSPLUS, OP_NOTPOSQUERY, OP_NOTPOSSTAR, OP_NOTPOSUPTO, OP_NOTPROP, OP_NOTQUERY, OP_NOTSTAR, OP_NOTUPTO, OP_ONCE, OP_OPT, OP_PLUS, OP_POSPLUS, OP_POSQUERY, OP_POSSTAR, OP_POSUPTO, OP_PROP, OP_QUERY, OP_RECURSE, OP_REF, OP_RREF, OP_SBRA, OP_STAR, OP_TYPEEXACT, OP_TYPEPLUS, OP_TYPEPOSPLUS, OP_TYPEPOSQUERY, OP_TYPEPOSSTAR, OP_TYPEPOSUPTO, OP_TYPEQUERY, OP_TYPESTAR, OP_TYPEUPTO, OP_UPTO, OP_XCLASS, PCRE_AUTO_CALLOUT, PCRE_CASELESS, PCRE_DOTALL, PCRE_DUPNAMES, PCRE_EXTENDED, PCRE_EXTRA, PCRE_IMS, PCRE_JCHANGED, PCRE_MULTILINE, PCRE_NO_AUTO_CAPTURE, PCRE_UNGREEDY, PCRE_UTF8, posix_class_maps, PUT2, PUT2INC, PUTINC, read_repeat_counts(), REQ_CASELESS, REQ_NONE, REQ_UNSET, REQ_VARY, compile_data::req_varyopt, RREF_ANY, compile_data::start_code, compile_data::start_pattern, compile_data::start_workspace, compile_data::top_backref, TRUE, utf8, XCL_END, XCL_MAP, XCL_NOT, XCL_NOTPROP, XCL_PROP, XCL_RANGE, and XCL_SINGLE.

Referenced by compile_regex().

◆ compile_regex()

static BOOL compile_regex ( int  options,
int  oldims,
uschar **  codeptr,
const uschar **  ptrptr,
int *  errorcodeptr,
BOOL  lookbehind,
int  skipbytes,
int *  firstbyteptr,
int *  reqbyteptr,
branch_chain bcptr,
compile_data cd,
int *  lengthptr 
)
static

◆ complete_callout()

static void complete_callout ( uschar previous_callout,
const uschar ptr,
compile_data cd 
)
static

Complete a callout item *

Definition at line 1703 of file pcre_compile.c.

References compile_data::start_pattern.

Referenced by compile_branch().

◆ could_be_empty()

static BOOL could_be_empty ( const uschar code,
const uschar endcode,
branch_chain bcptr,
BOOL  utf8 
)
static

Scan compiled regex for non-emptiness *

Definition at line 1515 of file pcre_compile.c.

References code, could_be_empty_branch(), branch_chain::current, FALSE, branch_chain::outer, TRUE, and utf8.

Referenced by compile_branch().

◆ could_be_empty_branch()

◆ find_bracket()

static const uschar* find_bracket ( const uschar code,
BOOL  utf8,
int  number 
)
static

◆ find_firstassertedchar()

static int find_firstassertedchar ( const uschar code,
int *  options,
BOOL  inassert 
)
static

Check for asserted fixed first char *

Definition at line 4970 of file pcre_compile.c.

References code, first_significant_code(), OP_ALT, OP_ASSERT, OP_BRA, OP_CBRA, OP_CHAR, OP_CHARNC, OP_COND, OP_EXACT, OP_MINPLUS, OP_ONCE, OP_PLUS, OP_POSPLUS, PCRE_CASELESS, REQ_CASELESS, and TRUE.

Referenced by pcre_compile2().

◆ find_fixedlength()

◆ find_parens()

static int find_parens ( const uschar ptr,
int  count,
const uschar name,
int  lorn,
BOOL  xmode 
)
static

Find forward referenced subpattern *

Definition at line 861 of file pcre_compile.c.

References name.

Referenced by compile_branch().

◆ find_recurse()

static const uschar* find_recurse ( const uschar code,
BOOL  utf8 
)
static

◆ first_significant_code()

static const uschar* first_significant_code ( const uschar code,
int *  options,
int  optbit,
BOOL  skipassert 
)
static

◆ is_anchored()

static BOOL is_anchored ( register const uschar code,
int *  options,
unsigned int  bracket_map,
unsigned int  backref_map 
)
static

◆ is_counted_repeat()

static BOOL is_counted_repeat ( const uschar p)
static

Check for counted repeat *

Definition at line 755 of file pcre_compile.c.

References ctype_digit, digitab, FALSE, and TRUE.

Referenced by compile_branch().

◆ is_startline()

static BOOL is_startline ( const uschar code,
unsigned int  bracket_map,
unsigned int  backref_map 
)
static

Check for starting with ^ or .* *

Definition at line 4898 of file pcre_compile.c.

References _pcre_OP_lengths, code, FALSE, first_significant_code(), GET2, OP_ALT, OP_ANY, OP_ASSERT, OP_BRA, OP_CBRA, OP_CIRC, OP_COND, OP_ONCE, OP_TYPEMINSTAR, OP_TYPEPOSSTAR, OP_TYPESTAR, and TRUE.

Referenced by pcre_compile2().

◆ pcre_compile()

pcre* pcre_compile ( const char *  pattern,
int  options,
const char **  errorptr,
int *  erroroffset,
const unsigned char *  tables 
)

Compile a Regular Expression *

Definition at line 5043 of file pcre_compile.c.

References pcre_compile2().

Referenced by compile_regex(), compile_single_pattern(), and main().

◆ pcre_compile2()

pcre* pcre_compile2 ( const char *  pattern,
int  options,
int *  errorcodeptr,
const char **  errorptr,
int *  erroroffset,
const unsigned char *  tables 
)

Definition at line 5051 of file pcre_compile.c.

References _pcre_default_tables, _pcre_valid_utf8(), compile_data::backref_map, compile_data::bracount, compile_data::cbits, cbits_offset, code, compile_regex(), COMPILE_WORK_SIZE, compile_data::ctypes, ctypes_offset, DPRINTF, real_pcre::dummy1, compile_data::end_pattern, ERR0, ERR15, ERR16, ERR17, ERR20, ERR21, ERR22, ERR23, ERR32, ERR44, ERR53, ERR56, error_texts, compile_data::external_options, FALSE, compile_data::fcc, fcc_offset, find_bracket(), find_firstassertedchar(), real_pcre::first_byte, compile_data::hwm, is_anchored(), is_startline(), compile_data::lcc, lcc_offset, MAGIC_NUMBER, real_pcre::magic_number, real_pcre::name_count, real_pcre::name_entry_size, compile_data::name_entry_size, compile_data::name_table, real_pcre::name_table_offset, compile_data::names_found, newline, compile_data::nl, compile_data::nllen, compile_data::nltype, NLTYPE_ANY, NLTYPE_FIXED, compile_data::nopartial, real_pcre::nullpad, offset, OP_BRA, OP_END, real_pcre::options, PCRE_ANCHORED, PCRE_FIRSTSET, pcre_free, PCRE_IMS, pcre_malloc, PCRE_NEWLINE_ANY, PCRE_NEWLINE_CR, PCRE_NEWLINE_CRLF, PCRE_NEWLINE_LF, PCRE_NO_UTF8_CHECK, PCRE_NOPARTIAL, PCRE_STARTLINE, PCRE_UTF8, PUBLIC_OPTIONS, real_pcre::ref_count, real_pcre::req_byte, REQ_CASELESS, compile_data::req_varyopt, real_pcre::size, compile_data::start_code, compile_data::start_pattern, compile_data::start_workspace, real_pcre::tables, real_pcre::top_backref, compile_data::top_backref, real_pcre::top_bracket, and utf8.

Referenced by pcre_compile(), and regcomp().

◆ read_repeat_counts()

static const uschar* read_repeat_counts ( const uschar p,
int *  minp,
int *  maxp,
int *  errorcodeptr 
)
static

Read repeat counts *

Definition at line 792 of file pcre_compile.c.

References ctype_digit, digitab, ERR4, and ERR5.

Referenced by compile_branch().

Variable Documentation

◆ digitab

const unsigned char digitab[]
static

◆ error_texts

const char* error_texts[]
static

Definition at line 176 of file pcre_compile.c.

Referenced by pcre_compile2().

◆ escapes

const short int escapes[]
static
Initial value:
= {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, ':', ';', '<', '=', '>', '?',
'@', -ESC_A, -ESC_B, -ESC_C, -ESC_D, -ESC_E, 0, -ESC_G,
0, 0, 0, 0, 0, 0, 0, 0,
-ESC_P, -ESC_Q, -ESC_R, -ESC_S, 0, 0, 0, -ESC_W,
-ESC_X, 0, -ESC_Z, '[', '\\', ']', '^', '_',
'`', 7, -ESC_b, 0, -ESC_d, 27 , '\f' , 0,
0, 0, 0, -ESC_k, 0, 0, '\n' , 0,
-ESC_p, 0, '\r' , -ESC_s, '\t' , 0, 0, -ESC_w,
0, 0, -ESC_z
}
@ ESC_Z
@ ESC_k
@ ESC_b
@ ESC_A
@ ESC_D
@ ESC_Q
@ ESC_P
@ ESC_R
@ ESC_d
@ ESC_s
@ ESC_S
@ ESC_C
@ ESC_B
@ ESC_W
@ ESC_G
@ ESC_X
@ ESC_w
@ ESC_E
@ ESC_p
@ ESC_z

Definition at line 86 of file pcre_compile.c.

Referenced by check_escape().

◆ posix_class_maps

const int posix_class_maps[]
static
Initial value:
= {
160 , 64 , -2,
128 , -1, 0,
96 , -1, 0,
160 , -1, 2,
224 , 288 , 0,
0 , -1, 1,
288 , -1, 0,
64 , -1, 0,
192 , -1, 0,
224 , -1, 0,
256 , -1, 0,
0 , -1, 0,
160 , -1, 0,
32 ,-1, 0
}

Definition at line 150 of file pcre_compile.c.

Referenced by compile_branch().

◆ posix_name_lengths

const uschar posix_name_lengths[]
static
Initial value:
= {
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 6, 0 }

Definition at line 137 of file pcre_compile.c.

Referenced by check_posix_name().

◆ posix_names

const char* const posix_names[]
static
Initial value:
= {
"alpha", "lower", "upper",
"alnum", "ascii", "blank", "cntrl", "digit", "graph",
"print", "punct", "space", "word", "xdigit" }

Definition at line 132 of file pcre_compile.c.

Referenced by check_posix_name().