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_exec.c File Reference
#include "pcre_internal.h"
Include dependency graph for pcre_exec.c:

Go to the source code of this file.

Macros

#define NLBLOCK   md /* Block containing newline information */
 
#define PSSTART   start_subject /* Field containing processed string start */
 
#define PSEND   end_subject /* Field containing processed string end */
 
#define EPTR_WORK_SIZE   (1000)
 
#define match_condassert   0x01 /* Called to check a condition assertion */
 
#define match_cbegroup   0x02 /* Could-be-empty unlimited repeat group */
 
#define match_tail_recursed   0x04 /* Tail recursive call */
 
#define MATCH_MATCH   1
 
#define MATCH_NOMATCH   0
 
#define REC_STACK_SAVE_MAX   30
 
#define REGISTER   register
 
#define RMATCH(rx, ra, rb, rc, rd, re, rf, rg)    rx = match(ra,rb,rc,rd,re,rf,rg,rdepth+1)
 
#define RRETURN(ra)   return ra
 
#define fi   i
 
#define fc   c
 

Functions

static BOOL match_ref (int offset, register const unsigned char *eptr, int length, match_data *md, unsigned long int ims)
 
static int match (register const unsigned char *eptr, register const uschar *ecode, int offset_top, match_data *md, unsigned long int ims, eptrblock *eptrb, int flags, unsigned int rdepth)
 
int pcre_exec (const pcre *argument_re, const pcre_extra *extra_data, const char *subject, int length, int start_offset, int options, int *offsets, int offsetcount)
 

Variables

static const char rep_min [] = { 0, 0, 1, 1, 0, 0 }
 
static const char rep_max [] = { 0, 0, 0, 0, 1, 1 }
 

Macro Definition Documentation

◆ EPTR_WORK_SIZE

#define EPTR_WORK_SIZE   (1000)

Definition at line 54 of file pcre_exec.c.

◆ fc

#define fc   c

◆ fi

#define fi   i

◆ match_cbegroup

#define match_cbegroup   0x02 /* Could-be-empty unlimited repeat group */

Definition at line 59 of file pcre_exec.c.

◆ match_condassert

#define match_condassert   0x01 /* Called to check a condition assertion */

Definition at line 58 of file pcre_exec.c.

◆ MATCH_MATCH

#define MATCH_MATCH   1

Definition at line 65 of file pcre_exec.c.

◆ MATCH_NOMATCH

#define MATCH_NOMATCH   0

Definition at line 66 of file pcre_exec.c.

◆ match_tail_recursed

#define match_tail_recursed   0x04 /* Tail recursive call */

Definition at line 60 of file pcre_exec.c.

◆ NLBLOCK

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

Perl-Compatible Regular Expressions *

Definition at line 45 of file pcre_exec.c.

◆ PSEND

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

Definition at line 47 of file pcre_exec.c.

◆ PSSTART

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

Definition at line 46 of file pcre_exec.c.

◆ REC_STACK_SAVE_MAX

#define REC_STACK_SAVE_MAX   30

Definition at line 72 of file pcre_exec.c.

◆ REGISTER

#define REGISTER   register
               RECURSION IN THE match() FUNCTION

The match() function is highly recursive, though not every recursive call increases the recursive depth. Nevertheless, some regular expressions can cause it to recurse to a great depth. I was writing for Unix, so I just let it call itself recursively. This uses the stack for saving everything that has to be saved for a recursive call. On Unix, the stack can be large, and this works fine.

It turns out that on some non-Unix-like systems there are problems with programs that use a lot of stack. (This despite the fact that every last chip has oodles of memory these days, and techniques for extending the stack have been known for decades.) So....

There is a fudge, triggered by defining NO_RECURSE, which avoids recursive calls by keeping local variables that need to be preserved in blocks of memory obtained from malloc() instead instead of on the stack. Macros are used to achieve this so that the actual code doesn't look very different to what it always used to.

Definition at line 194 of file pcre_exec.c.

◆ RMATCH

#define RMATCH (   rx,
  ra,
  rb,
  rc,
  rd,
  re,
  rf,
  rg 
)     rx = match(ra,rb,rc,rd,re,rf,rg,rdepth+1)

Definition at line 208 of file pcre_exec.c.

◆ RRETURN

#define RRETURN (   ra)    return ra

Definition at line 210 of file pcre_exec.c.

Function Documentation

◆ match()

static int match ( register const unsigned char *  eptr,
register const uschar ecode,
int  offset_top,
match_data md,
unsigned long int  ims,
eptrblock eptrb,
int  flags,
unsigned int  rdepth 
)
static

Match from current position *

Definition at line 369 of file pcre_exec.c.

References _pcre_OP_lengths, _pcre_ord2utf8(), _pcre_ucp_findprop(), _pcre_ucp_othercase(), _pcre_xclass(), recursion_info::after_call, BACKCHAR, pcre_callout_block::callout_data, match_data::callout_data, pcre_callout_block::callout_number, pcre_callout_block::capture_last, match_data::capture_last, pcre_callout_block::capture_top, ctype_digit, ctype_space, ctype_word, match_data::ctypes, pcre_callout_block::current_position, DPRINTF, match_data::end_match_ptr, match_data::end_offset_top, match_data::end_subject, match_data::endonly, eptrblock::epb_prev, eptrblock::epb_saved_eptr, EPTR_WORK_SIZE, match_data::eptrchain, match_data::eptrn, FALSE, fc, fi, GET2, GETCHAR, GETCHARINC, GETCHARINCTEST, GETCHARLEN, recursion_info::group_num, match_data::hitend, IS_NEWLINE, match_data::lcc, match_data::match_call_count, match_cbegroup, match_condassert, match_data::match_limit, match_data::match_limit_recursion, MATCH_MATCH, MATCH_NOMATCH, match_ref(), match_tail_recursed, memmove, pcre_callout_block::next_item_length, match_data::nllen, NOTACHAR, match_data::notbol, match_data::notempty, match_data::noteol, number, offset, match_data::offset_end, match_data::offset_max, match_data::offset_overflow, recursion_info::offset_save, pcre_callout_block::offset_vector, match_data::offset_vector, OP_ALT, OP_ANY, OP_ANYBYTE, OP_ANYNL, OP_ASSERT, OP_ASSERT_NOT, OP_ASSERTBACK, OP_ASSERTBACK_NOT, OP_BRA, OP_BRAMINZERO, OP_BRAZERO, OP_CALLOUT, OP_CBRA, OP_CHAR, OP_CHARNC, OP_CIRC, OP_CLASS, OP_COND, OP_CREF, OP_CRMINPLUS, OP_CRMINQUERY, OP_CRMINRANGE, OP_CRMINSTAR, OP_CRPLUS, OP_CRQUERY, OP_CRRANGE, OP_CRSTAR, OP_DEF, OP_DIGIT, OP_DOLL, OP_END, OP_EOD, OP_EODN, OP_EXACT, OP_EXTUNI, OP_KET, OP_KETRMAX, OP_KETRMIN, OP_MINPLUS, OP_MINQUERY, OP_MINSTAR, OP_MINUPTO, OP_NCLASS, OP_NOT, OP_NOT_DIGIT, OP_NOT_WHITESPACE, OP_NOT_WORD_BOUNDARY, OP_NOT_WORDCHAR, OP_NOTEXACT, OP_NOTMINPLUS, OP_NOTMINQUERY, OP_NOTMINSTAR, OP_NOTMINUPTO, 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_REVERSE, OP_RREF, OP_SBRA, OP_SCBRA, OP_SCOND, OP_SOD, OP_SOM, OP_STAR, OP_TYPEEXACT, OP_TYPEMINPLUS, OP_TYPEMINQUERY, OP_TYPEMINSTAR, OP_TYPEMINUPTO, OP_TYPEPLUS, OP_TYPEPOSPLUS, OP_TYPEPOSQUERY, OP_TYPEPOSSTAR, OP_TYPEPOSUPTO, OP_TYPEQUERY, OP_TYPESTAR, OP_TYPEUPTO, OP_UPTO, OP_WHITESPACE, OP_WORD_BOUNDARY, OP_WORDCHAR, OP_XCLASS, match_data::partial, pcre_callout_block::pattern_position, pchars(), pcre_callout, PCRE_CASELESS, PCRE_DOTALL, PCRE_ERROR_INTERNAL, PCRE_ERROR_MATCHLIMIT, PCRE_ERROR_NOMEMORY, PCRE_ERROR_NULLWSLIMIT, PCRE_ERROR_RECURSIONLIMIT, PCRE_ERROR_UNKNOWN_OPCODE, pcre_free, PCRE_IMS, pcre_malloc, PCRE_MULTILINE, PCRE_SPTR, pcre_stack_malloc, recursion_info::prevrec, PT_ANY, PT_GC, PT_LAMP, PT_PC, PT_SC, REC_STACK_SAVE_MAX, match_data::recursive, rep_max, rep_min, RMATCH, RREF_ANY, RRETURN, recursion_info::save_start, recursion_info::saved_max, match_data::start_code, pcre_callout_block::start_match, match_data::start_match, match_data::start_offset, match_data::start_subject, pcre_callout_block::subject, pcre_callout_block::subject_length, TRUE, ucp_Ll, ucp_Lt, ucp_Lu, ucp_M, USPTR, match_data::utf8, utf8, pcre_callout_block::version, and WAS_NEWLINE.

Referenced by pcre_exec().

◆ match_ref()

static BOOL match_ref ( int  offset,
register const unsigned char *  eptr,
int  length,
match_data md,
unsigned long int  ims 
)
static

Match a back-reference *

Definition at line 128 of file pcre_exec.c.

References match_data::end_subject, FALSE, match_data::lcc, offset, match_data::offset_vector, pchars(), PCRE_CASELESS, match_data::start_subject, TRUE, and USPTR.

Referenced by match().

◆ pcre_exec()

int pcre_exec ( const pcre argument_re,
const pcre_extra extra_data,
const char *  subject,
int  length,
int  start_offset,
int  options,
int *  offsets,
int  offsetcount 
)
               RECURSION IN THE match() FUNCTION

Undefine all the macros that were defined above to handle this. Execute a Regular Expression *

Definition at line 3690 of file pcre_exec.c.

References _pcre_default_tables, _pcre_try_flipped(), _pcre_valid_utf8(), pcre_extra::callout_data, match_data::callout_data, match_data::capture_last, match_data::ctypes, ctypes_offset, DPRINTF, match_data::end_match_ptr, match_data::end_offset_top, match_data::end_subject, match_data::endonly, EPTR_WORK_SIZE, match_data::eptrchain, match_data::eptrn, FALSE, fcc_offset, real_pcre::first_byte, pcre_extra::flags, match_data::hitend, IS_NEWLINE, match_data::lcc, lcc_offset, MAGIC_NUMBER, real_pcre::magic_number, match(), match_data::match_call_count, pcre_extra::match_limit, match_data::match_limit, pcre_extra::match_limit_recursion, match_data::match_limit_recursion, MATCH_MATCH, MATCH_NOMATCH, real_pcre::name_count, real_pcre::name_entry_size, real_pcre::name_table_offset, newline, match_data::nl, match_data::nllen, match_data::nltype, NLTYPE_ANY, NLTYPE_FIXED, match_data::notbol, match_data::notempty, match_data::noteol, match_data::offset_end, match_data::offset_max, match_data::offset_overflow, match_data::offset_vector, real_pcre::options, pcre_study_data::options, match_data::partial, pchars(), PCRE_ANCHORED, PCRE_CASELESS, PCRE_DOLLAR_ENDONLY, PCRE_DOTALL, PCRE_ERROR_BADCOUNT, PCRE_ERROR_BADMAGIC, PCRE_ERROR_BADNEWLINE, PCRE_ERROR_BADOPTION, PCRE_ERROR_BADPARTIAL, PCRE_ERROR_BADUTF8, PCRE_ERROR_BADUTF8_OFFSET, PCRE_ERROR_NOMATCH, PCRE_ERROR_NOMEMORY, PCRE_ERROR_NULL, PCRE_ERROR_PARTIAL, PCRE_EXTRA_CALLOUT_DATA, PCRE_EXTRA_MATCH_LIMIT, PCRE_EXTRA_MATCH_LIMIT_RECURSION, PCRE_EXTRA_STUDY_DATA, PCRE_EXTRA_TABLES, PCRE_FIRSTLINE, PCRE_FIRSTSET, pcre_free, pcre_malloc, PCRE_MULTILINE, PCRE_NEWLINE_ANY, PCRE_NEWLINE_BITS, PCRE_NEWLINE_CR, PCRE_NEWLINE_LF, PCRE_NO_UTF8_CHECK, PCRE_NOPARTIAL, PCRE_NOTBOL, PCRE_NOTEMPTY, PCRE_NOTEOL, PCRE_PARTIAL, PCRE_REQCHSET, PCRE_STARTLINE, PCRE_STUDY_MAPPED, PCRE_UTF8, PUBLIC_EXEC_OPTIONS, match_data::recursive, real_pcre::req_byte, REQ_BYTE_MAX, REQ_CASELESS, pcre_study_data::start_bits, match_data::start_code, match_data::start_match, match_data::start_offset, match_data::start_subject, pcre_extra::study_data, pcre_extra::tables, real_pcre::tables, real_pcre::top_backref, real_pcre::top_bracket, TRUE, USPTR, match_data::utf8, utf8, and WAS_NEWLINE.

Referenced by body_search(), build_url_list(), check_match_limit(), eat_re(), grep_or_recurse(), highlight_regexes(), main(), match_regex(), pcregrep(), post_process_sh(), process_text_body_part(), regexec(), search_article(), and test_regex().

Variable Documentation

◆ rep_max

const char rep_max[] = { 0, 0, 0, 0, 1, 1 }
static

Definition at line 77 of file pcre_exec.c.

Referenced by match().

◆ rep_min

const char rep_min[] = { 0, 0, 1, 1, 0, 0 }
static

Definition at line 76 of file pcre_exec.c.

Referenced by match().