GnuRegex.c File Reference
#include "squid.h"
#include <strings.h>
#include "compat/GnuRegex.h"
#include <ctype.h>
Include dependency graph for GnuRegex.c:

Go to the source code of this file.

Classes

struct  compile_stack_elt_t
 
struct  compile_stack_type
 
struct  fail_stack_type
 
union  register_info_type
 

Macros

#define _GNU_SOURCE   1
 
#define REGEX_MALLOC   1
 
#define Sword   1
 
#define CHAR_SET_SIZE   256
 
#define isascii(c)   1
 
#define ISBLANK(c)   ((c) == ' ' || (c) == '\t')
 
#define ISGRAPH(c)   (isascii ((unsigned char)c) && isprint ((unsigned char)c) && !isspace ((unsigned char)c))
 
#define ISPRINT(c)   (isascii ((unsigned char)c) && isprint ((unsigned char)c))
 
#define ISDIGIT(c)   (isascii ((unsigned char)c) && isdigit ((unsigned char)c))
 
#define ISALNUM(c)   (isascii ((unsigned char)c) && isalnum ((unsigned char)c))
 
#define ISALPHA(c)   (isascii ((unsigned char)c) && isalpha ((unsigned char)c))
 
#define ISCNTRL(c)   (isascii ((unsigned char)c) && iscntrl ((unsigned char)c))
 
#define ISLOWER(c)   (isascii ((unsigned char)c) && islower ((unsigned char)c))
 
#define ISPUNCT(c)   (isascii ((unsigned char)c) && ispunct ((unsigned char)c))
 
#define ISSPACE(c)   (isascii ((unsigned char)c) && isspace ((unsigned char)c))
 
#define ISUPPER(c)   (isascii ((unsigned char)c) && isupper ((unsigned char)c))
 
#define ISXDIGIT(c)   (isascii ((unsigned char)c) && isxdigit ((unsigned char)c))
 
#define SIGN_EXTEND_CHAR(c)   ((((unsigned char) (c)) ^ 128) - 128)
 
#define REGEX_ALLOCATE   malloc
 
#define REGEX_REALLOCATE(source, osize, nsize)   realloc (source, nsize)
 
#define FIRST_STRING_P(ptr)   (size1 && string1 <= (ptr) && (ptr) <= string1 + size1)
 
#define TALLOC(n, t)   ((t *) malloc ((n) * sizeof (t)))
 
#define RETALLOC(addr, n, t)   ((addr) = (t *) realloc (addr, (n) * sizeof (t)))
 
#define REGEX_TALLOC(n, t)   ((t *) REGEX_ALLOCATE ((n) * sizeof (t)))
 
#define BYTEWIDTH   8 /* In bits. */
 
#define STREQ(s1, s2)   ((strcmp (s1, s2) == 0))
 
#define false   0
 
#define true   1
 
#define STORE_NUMBER(destination, number)
 
#define STORE_NUMBER_AND_INCR(destination, number)
 
#define EXTRACT_NUMBER(destination, source)
 
#define EXTRACT_NUMBER_AND_INCR(destination, source)
 
#define assert(e)
 
#define DEBUG_STATEMENT(e)
 
#define DEBUG_PRINT1(x)
 
#define DEBUG_PRINT2(x1, x2)
 
#define DEBUG_PRINT3(x1, x2, x3)
 
#define DEBUG_PRINT4(x1, x2, x3, x4)
 
#define DEBUG_PRINT_COMPILED_PATTERN(p, s, e)
 
#define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2)
 
#define PATFETCH(c)
 
#define PATFETCH_RAW(c)
 
#define PATUNFETCH   p--
 
#define TRANSLATE(d)   (translate ? translate[(unsigned char) (d)] : (d))
 
#define INIT_BUF_SIZE   32
 
#define GET_BUFFER_SPACE(n)
 
#define BUF_PUSH(c)
 
#define BUF_PUSH_2(c1, c2)
 
#define BUF_PUSH_3(c1, c2, c3)
 
#define STORE_JUMP(op, loc, to)   store_op1 (op, loc, (to) - (loc) - 3)
 
#define STORE_JUMP2(op, loc, to, arg)   store_op2 (op, loc, (to) - (loc) - 3, arg)
 
#define INSERT_JUMP(op, loc, to)   insert_op1 (op, loc, (to) - (loc) - 3, b)
 
#define INSERT_JUMP2(op, loc, to, arg)   insert_op2 (op, loc, (to) - (loc) - 3, arg, b)
 
#define MAX_BUF_SIZE   (1L << 16)
 
#define EXTEND_BUFFER()
 
#define MAX_REGNUM   255
 
#define INIT_COMPILE_STACK_SIZE   32
 
#define COMPILE_STACK_TOP   (compile_stack.stack[compile_stack.avail])
 
#define SET_LIST_BIT(c)
 
#define GET_UNSIGNED_NUMBER(num)
 
#define CHAR_CLASS_MAX_LENGTH   6 /* Namely, `xdigit'. */
 
#define IS_CHAR_CLASS(string)
 
#define INIT_FAILURE_ALLOC   5
 
#define FAIL_STACK_EMPTY()   (fail_stack.avail == 0)
 
#define FAIL_STACK_PTR_EMPTY()   (fail_stack_ptr->avail == 0)
 
#define FAIL_STACK_FULL()   (fail_stack.avail == fail_stack.size)
 
#define FAIL_STACK_TOP()   (fail_stack.stack[fail_stack.avail])
 
#define INIT_FAIL_STACK()
 
#define DOUBLE_FAIL_STACK(fail_stack)
 
#define PUSH_PATTERN_OP(pattern_op, fail_stack)
 
#define PUSH_FAILURE_ITEM(item)   fail_stack.stack[fail_stack.avail++] = (fail_stack_elt_t) item
 
#define POP_FAILURE_ITEM()   fail_stack.stack[--fail_stack.avail]
 
#define DEBUG_PUSH(item)
 
#define DEBUG_POP(item_addr)
 
#define PUSH_FAILURE_POINT(pattern_place, string_place, failure_code)
 
#define NUM_REG_ITEMS   3
 
#define NUM_NONREG_ITEMS   4
 
#define MAX_FAILURE_ITEMS   ((num_regs - 1) * NUM_REG_ITEMS + NUM_NONREG_ITEMS)
 
#define NUM_FAILURE_ITEMS
 
#define REMAINING_AVAIL_SLOTS   ((fail_stack).size - (fail_stack).avail)
 
#define POP_FAILURE_POINT(str, pat, low_reg, high_reg, regstart, regend, reg_info)
 
#define MATCH_NULL_UNSET_VALUE   3
 
#define REG_MATCH_NULL_STRING_P(R)   ((R).bits.match_null_string_p)
 
#define IS_ACTIVE(R)   ((R).bits.is_active)
 
#define MATCHED_SOMETHING(R)   ((R).bits.matched_something)
 
#define EVER_MATCHED_SOMETHING(R)   ((R).bits.ever_matched_something)
 
#define SET_REGS_MATCHED()
 
#define POINTER_TO_OFFSET(ptr)   (FIRST_STRING_P (ptr) ? (ptr) - string1 : (ptr) - string2 + size1)
 
#define REG_UNSET_VALUE   ((char *) -1)
 
#define REG_UNSET(e)   ((e) == REG_UNSET_VALUE)
 
#define MATCHING_IN_FIRST_STRING   (dend == end_match_1)
 
#define PREFETCH()
 
#define AT_STRINGS_BEG(d)   ((d) == (size1 ? string1 : string2) || !size2)
 
#define WORDCHAR_P(d)
 
#define AT_WORD_BOUNDARY(d)
 
#define FREE_VAR(var)   if (var) free (var); var = NULL
 
#define FREE_VARIABLES()
 
#define NO_HIGHEST_ACTIVE_REG   (1 << BYTEWIDTH)
 
#define NO_LOWEST_ACTIVE_REG   (NO_HIGHEST_ACTIVE_REG + 1)
 

Typedefs

typedef char boolean
 
typedef unsigned regnum_t
 
typedef int pattern_offset_t
 
typedef const unsigned char * fail_stack_elt_t
 

Enumerations

enum  re_opcode_t {
  no_op = 0,
  exactn = 1,
  anychar,
  charset,
  charset_not,
  start_memory,
  stop_memory,
  duplicate,
  begline,
  endline,
  begbuf,
  endbuf,
  jump,
  jump_past_alt,
  on_failure_jump,
  on_failure_keep_string_jump,
  pop_failure_jump,
  maybe_pop_jump,
  dummy_failure_jump,
  push_dummy_failure,
  succeed_n,
  jump_n,
  set_number_at,
  wordchar,
  notwordchar,
  wordbeg,
  wordend,
  wordbound,
  notwordbound
}
 

Functions

static void init_syntax_once (void)
 
static int re_compile_fastmap (struct re_pattern_buffer *buffer)
 
static int re_search (struct re_pattern_buffer *buffer, const char *string, int length, int start, int range, struct re_registers *regs)
 
static int re_search_2 (struct re_pattern_buffer *buffer, const char *string1, int length1, const char *string2, int length2, int start, int range, struct re_registers *regs, int stop)
 
static int re_match_2 (struct re_pattern_buffer *buffer, const char *string1, int length1, const char *string2, int length2, int start, struct re_registers *regs, int stop)
 
static void store_op1 (re_opcode_t op, unsigned char *loc, int arg)
 
static void store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2)
 
static void insert_op1 (re_opcode_t op, unsigned char *loc, int arg, unsigned char *end)
 
static void insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, unsigned char *end)
 
static boolean at_begline_loc_p (const char *pattern, const char *p, reg_syntax_t syntax)
 
static boolean at_endline_loc_p (const char *p, const char *pend, int syntax)
 
static boolean group_in_compile_stack (compile_stack_type compile_stack, regnum_t regnum)
 
static reg_errcode_t compile_range (const char **p_ptr, const char *pend, char *translate, reg_syntax_t syntax, unsigned char *b)
 
static reg_errcode_t regex_compile (const char *pattern, int size, reg_syntax_t syntax, struct re_pattern_buffer *bufp)
 
static boolean alt_match_null_string_p (unsigned char *p, unsigned char *end, register_info_type *reg_info)
 
static boolean common_op_match_null_string_p (unsigned char **p, unsigned char *end, register_info_type *reg_info)
 
static int bcmp_translate (unsigned char const *s1, unsigned char const *s2, register int len, char *translate)
 
static boolean group_match_null_string_p (unsigned char **p, unsigned char *end, register_info_type *reg_info)
 
static int at_strings_end (const char *d, const char *end2)
 
static int wordchar_p (const char *d, const char *end1, const char *string2)
 
int regcomp (regex_t *preg, const char *pattern, int cflags)
 
int regexec (regex_t *preg, const char *string, size_t nmatch, pmatch, int eflags) const
 
size_t regerror (int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size)
 
void regfree (regex_t *preg)
 

Variables

static char re_syntax_table [CHAR_SET_SIZE]
 
static const char * re_error_msg []
 
int re_max_failures = 2000
 

Macro Definition Documentation

#define _GNU_SOURCE   1

Definition at line 36 of file GnuRegex.c.

#define assert (   e)
#define AT_STRINGS_BEG (   d)    ((d) == (size1 ? string1 : string2) || !size2)

Definition at line 2742 of file GnuRegex.c.

Referenced by re_match_2().

#define AT_WORD_BOUNDARY (   d)
Value:
(AT_STRINGS_BEG (d) || at_strings_end(d,end2) \
|| WORDCHAR_P (d - 1) != WORDCHAR_P (d))
static int at_strings_end(const char *d, const char *end2)
Definition: GnuRegex.c:2743
#define WORDCHAR_P(d)
Definition: GnuRegex.c:2752
#define AT_STRINGS_BEG(d)
Definition: GnuRegex.c:2742

Definition at line 2766 of file GnuRegex.c.

Referenced by re_match_2().

#define BUF_PUSH (   c)
Value:
do { \
*b++ = (unsigned char) (c); \
} while (0)
#define GET_BUFFER_SPACE(n)
Definition: GnuRegex.c:779

Definition at line 784 of file GnuRegex.c.

Referenced by regex_compile().

#define BUF_PUSH_2 (   c1,
  c2 
)
Value:
do { \
*b++ = (unsigned char) (c1); \
*b++ = (unsigned char) (c2); \
} while (0)
#define GET_BUFFER_SPACE(n)
Definition: GnuRegex.c:779

Definition at line 791 of file GnuRegex.c.

Referenced by regex_compile().

#define BUF_PUSH_3 (   c1,
  c2,
  c3 
)
Value:
do { \
*b++ = (unsigned char) (c1); \
*b++ = (unsigned char) (c2); \
*b++ = (unsigned char) (c3); \
} while (0)
#define GET_BUFFER_SPACE(n)
Definition: GnuRegex.c:779

Definition at line 799 of file GnuRegex.c.

Referenced by regex_compile().

#define BYTEWIDTH   8 /* In bits. */

Definition at line 226 of file GnuRegex.c.

Referenced by re_compile_fastmap(), re_match_2(), and regex_compile().

#define CHAR_CLASS_MAX_LENGTH   6 /* Namely, `xdigit'. */

Definition at line 923 of file GnuRegex.c.

Referenced by regex_compile().

#define CHAR_SET_SIZE   256

Definition at line 70 of file GnuRegex.c.

Referenced by regcomp().

#define COMPILE_STACK_TOP   (compile_stack.stack[compile_stack.avail])

Definition at line 899 of file GnuRegex.c.

Referenced by regex_compile().

#define DEBUG_POP (   item_addr)

Definition at line 2104 of file GnuRegex.c.

#define DEBUG_PRINT1 (   x)

Definition at line 714 of file GnuRegex.c.

Referenced by re_match_2(), and regex_compile().

#define DEBUG_PRINT2 (   x1,
  x2 
)

Definition at line 715 of file GnuRegex.c.

Referenced by re_match_2().

#define DEBUG_PRINT3 (   x1,
  x2,
  x3 
)

Definition at line 716 of file GnuRegex.c.

Referenced by re_match_2().

#define DEBUG_PRINT4 (   x1,
  x2,
  x3,
  x4 
)

Definition at line 717 of file GnuRegex.c.

Referenced by re_match_2().

#define DEBUG_PRINT_COMPILED_PATTERN (   p,
  s,
 
)

Definition at line 718 of file GnuRegex.c.

Referenced by re_match_2().

#define DEBUG_PRINT_DOUBLE_STRING (   w,
  s1,
  sz1,
  s2,
  sz2 
)

Definition at line 719 of file GnuRegex.c.

Referenced by re_match_2().

#define DEBUG_PUSH (   item)

Definition at line 2103 of file GnuRegex.c.

#define DEBUG_STATEMENT (   e)

Definition at line 713 of file GnuRegex.c.

#define DOUBLE_FAIL_STACK (   fail_stack)
Value:
? 0 \
: ((fail_stack).stack = (fail_stack_elt_t *) \
REGEX_REALLOCATE ((fail_stack).stack, \
(fail_stack).size * sizeof (fail_stack_elt_t), \
((fail_stack).size << 1) * sizeof (fail_stack_elt_t)), \
\
(fail_stack).stack == NULL \
? 0 \
: ((fail_stack).size <<= 1, \
1)))
#define MAX_FAILURE_ITEMS
Definition: GnuRegex.c:2202
int re_max_failures
Definition: GnuRegex.c:2029
#define REGEX_REALLOCATE(source, osize, nsize)
Definition: GnuRegex.c:183
const unsigned char * fail_stack_elt_t
Definition: GnuRegex.c:2031
#define NULL
Definition: types.h:166
int size
Definition: ModDevPoll.cc:77

Definition at line 2065 of file GnuRegex.c.

#define EVER_MATCHED_SOMETHING (   R)    ((R).bits.ever_matched_something)

Definition at line 2696 of file GnuRegex.c.

Referenced by re_match_2().

#define EXTEND_BUFFER ( )
Value:
do { \
unsigned char *old_buffer = bufp->buffer; \
if (bufp->allocated == MAX_BUF_SIZE) \
return REG_ESIZE; \
bufp->allocated <<= 1; \
if (bufp->allocated > MAX_BUF_SIZE) \
bufp->allocated = MAX_BUF_SIZE; \
bufp->buffer = (unsigned char *) realloc (bufp->buffer, bufp->allocated);\
if (bufp->buffer == NULL) \
return REG_ESPACE; \
/* If the buffer moved, move all the pointers into it. */ \
if (old_buffer != bufp->buffer) \
{ \
b = (b - old_buffer) + bufp->buffer; \
begalt = (begalt - old_buffer) + bufp->buffer; \
if (fixup_alt_jump) \
fixup_alt_jump = (fixup_alt_jump - old_buffer) + bufp->buffer;\
if (laststart) \
laststart = (laststart - old_buffer) + bufp->buffer; \
if (pending_exact) \
pending_exact = (pending_exact - old_buffer) + bufp->buffer; \
} \
} while (0)
#define MAX_BUF_SIZE
Definition: GnuRegex.c:827
#define NULL
Definition: types.h:166

Definition at line 833 of file GnuRegex.c.

#define EXTRACT_NUMBER (   destination,
  source 
)
Value:
do { \
(destination) = *(source) & 0377; \
(destination) += SIGN_EXTEND_CHAR (*((source) + 1)) << 8; \
} while (0)
#define SIGN_EXTEND_CHAR(c)
Definition: GnuRegex.c:167

Definition at line 385 of file GnuRegex.c.

Referenced by group_match_null_string_p(), and re_match_2().

#define EXTRACT_NUMBER_AND_INCR (   destination,
  source 
)
Value:
do { \
EXTRACT_NUMBER (destination, source); \
(source) += 2; \
} while (0)
#define EXTRACT_NUMBER(destination, source)
Definition: GnuRegex.c:385

Definition at line 412 of file GnuRegex.c.

Referenced by alt_match_null_string_p(), common_op_match_null_string_p(), group_match_null_string_p(), re_compile_fastmap(), and re_match_2().

#define FAIL_STACK_EMPTY ( )    (fail_stack.avail == 0)

Definition at line 2039 of file GnuRegex.c.

Referenced by re_compile_fastmap(), and re_match_2().

#define FAIL_STACK_FULL ( )    (fail_stack.avail == fail_stack.size)

Definition at line 2041 of file GnuRegex.c.

#define FAIL_STACK_PTR_EMPTY ( )    (fail_stack_ptr->avail == 0)

Definition at line 2040 of file GnuRegex.c.

#define FAIL_STACK_TOP ( )    (fail_stack.stack[fail_stack.avail])

Definition at line 2042 of file GnuRegex.c.

#define false   0

Definition at line 233 of file GnuRegex.c.

#define FIRST_STRING_P (   ptr)    (size1 && string1 <= (ptr) && (ptr) <= string1 + size1)

Definition at line 218 of file GnuRegex.c.

Referenced by re_match_2().

#define FREE_VAR (   var)    if (var) free (var); var = NULL

Definition at line 2772 of file GnuRegex.c.

#define FREE_VARIABLES ( )
Value:
do { \
FREE_VAR (fail_stack.stack); \
FREE_VAR (regstart); \
FREE_VAR (regend); \
FREE_VAR (old_regstart); \
FREE_VAR (old_regend); \
FREE_VAR (best_regstart); \
FREE_VAR (best_regend); \
FREE_VAR (reg_info); \
FREE_VAR (reg_dummy); \
FREE_VAR (reg_info_dummy); \
} while (0)
#define FREE_VAR(var)
Definition: GnuRegex.c:2772

Definition at line 2773 of file GnuRegex.c.

Referenced by re_match_2().

#define GET_BUFFER_SPACE (   n)
Value:
while (b - bufp->buffer + (n) > bufp->allocated) \
#define EXTEND_BUFFER()
Definition: GnuRegex.c:833

Definition at line 779 of file GnuRegex.c.

Referenced by regex_compile().

#define GET_UNSIGNED_NUMBER (   num)
Value:
{ if (p != pend) \
{ \
PATFETCH (c); \
while (ISDIGIT (c)) \
{ \
if (num < 0) \
num = 0; \
num = num * 10 + c - '0'; \
if (p == pend) \
break; \
PATFETCH (c); \
} \
} \
}
char * p
Definition: membanger.c:43
#define ISDIGIT(c)
Definition: GnuRegex.c:148
#define PATFETCH(c)
Definition: GnuRegex.c:751

Definition at line 907 of file GnuRegex.c.

Referenced by regex_compile().

#define INIT_BUF_SIZE   32

Definition at line 776 of file GnuRegex.c.

Referenced by regex_compile().

#define INIT_COMPILE_STACK_SIZE   32

Definition at line 896 of file GnuRegex.c.

Referenced by regex_compile().

#define INIT_FAIL_STACK ( )
Value:
do { \
fail_stack.stack = (fail_stack_elt_t *) \
\
if (fail_stack.stack == NULL) \
return -2; \
\
fail_stack.size = INIT_FAILURE_ALLOC; \
fail_stack.avail = 0; \
} while (0)
const unsigned char * fail_stack_elt_t
Definition: GnuRegex.c:2031
#define REGEX_ALLOCATE
Definition: GnuRegex.c:182
#define NULL
Definition: types.h:166
#define INIT_FAILURE_ALLOC
Definition: GnuRegex.c:2022

Definition at line 2046 of file GnuRegex.c.

Referenced by re_compile_fastmap(), and re_match_2().

#define INIT_FAILURE_ALLOC   5

Definition at line 2022 of file GnuRegex.c.

#define INSERT_JUMP (   op,
  loc,
  to 
)    insert_op1 (op, loc, (to) - (loc) - 3, b)

Definition at line 817 of file GnuRegex.c.

Referenced by regex_compile().

#define INSERT_JUMP2 (   op,
  loc,
  to,
  arg 
)    insert_op2 (op, loc, (to) - (loc) - 3, arg, b)

Definition at line 821 of file GnuRegex.c.

Referenced by regex_compile().

#define IS_ACTIVE (   R)    ((R).bits.is_active)

Definition at line 2694 of file GnuRegex.c.

Referenced by re_match_2().

#define IS_CHAR_CLASS (   string)
Value:
(STREQ (string, "alpha") || STREQ (string, "upper") \
|| STREQ (string, "lower") || STREQ (string, "digit") \
|| STREQ (string, "alnum") || STREQ (string, "xdigit") \
|| STREQ (string, "space") || STREQ (string, "print") \
|| STREQ (string, "punct") || STREQ (string, "graph") \
|| STREQ (string, "cntrl") || STREQ (string, "blank"))
#define STREQ(s1, s2)
Definition: GnuRegex.c:228

Definition at line 925 of file GnuRegex.c.

Referenced by regex_compile().

#define ISALNUM (   c)    (isascii ((unsigned char)c) && isalnum ((unsigned char)c))

Definition at line 149 of file GnuRegex.c.

Referenced by regex_compile().

#define ISALPHA (   c)    (isascii ((unsigned char)c) && isalpha ((unsigned char)c))

Definition at line 150 of file GnuRegex.c.

Referenced by regex_compile().

#define isascii (   c)    1

Definition at line 133 of file GnuRegex.c.

#define ISBLANK (   c)    ((c) == ' ' || (c) == '\t')

Definition at line 139 of file GnuRegex.c.

Referenced by regex_compile().

#define ISCNTRL (   c)    (isascii ((unsigned char)c) && iscntrl ((unsigned char)c))

Definition at line 151 of file GnuRegex.c.

Referenced by regex_compile().

#define ISDIGIT (   c)    (isascii ((unsigned char)c) && isdigit ((unsigned char)c))

Definition at line 148 of file GnuRegex.c.

Referenced by regex_compile().

#define ISGRAPH (   c)    (isascii ((unsigned char)c) && isprint ((unsigned char)c) && !isspace ((unsigned char)c))

Definition at line 144 of file GnuRegex.c.

Referenced by regex_compile().

#define ISLOWER (   c)    (isascii ((unsigned char)c) && islower ((unsigned char)c))

Definition at line 152 of file GnuRegex.c.

Referenced by regex_compile().

#define ISPRINT (   c)    (isascii ((unsigned char)c) && isprint ((unsigned char)c))

Definition at line 147 of file GnuRegex.c.

Referenced by regex_compile().

#define ISPUNCT (   c)    (isascii ((unsigned char)c) && ispunct ((unsigned char)c))

Definition at line 153 of file GnuRegex.c.

Referenced by regex_compile().

#define ISSPACE (   c)    (isascii ((unsigned char)c) && isspace ((unsigned char)c))

Definition at line 154 of file GnuRegex.c.

Referenced by regex_compile().

#define ISUPPER (   c)    (isascii ((unsigned char)c) && isupper ((unsigned char)c))

Definition at line 155 of file GnuRegex.c.

Referenced by regcomp(), and regex_compile().

#define ISXDIGIT (   c)    (isascii ((unsigned char)c) && isxdigit ((unsigned char)c))

Definition at line 156 of file GnuRegex.c.

Referenced by regex_compile().

#define MATCH_NULL_UNSET_VALUE   3

Definition at line 2681 of file GnuRegex.c.

Referenced by common_op_match_null_string_p(), and re_match_2().

#define MATCHED_SOMETHING (   R)    ((R).bits.matched_something)

Definition at line 2695 of file GnuRegex.c.

Referenced by re_match_2().

#define MATCHING_IN_FIRST_STRING   (dend == end_match_1)

Definition at line 2725 of file GnuRegex.c.

Referenced by re_match_2().

#define MAX_BUF_SIZE   (1L << 16)

Definition at line 827 of file GnuRegex.c.

#define MAX_FAILURE_ITEMS   ((num_regs - 1) * NUM_REG_ITEMS + NUM_NONREG_ITEMS)

Definition at line 2202 of file GnuRegex.c.

#define MAX_REGNUM   255

Definition at line 861 of file GnuRegex.c.

Referenced by common_op_match_null_string_p(), and regex_compile().

#define NO_HIGHEST_ACTIVE_REG   (1 << BYTEWIDTH)

Definition at line 2798 of file GnuRegex.c.

Referenced by re_match_2().

#define NO_LOWEST_ACTIVE_REG   (NO_HIGHEST_ACTIVE_REG + 1)

Definition at line 2799 of file GnuRegex.c.

Referenced by re_match_2().

#define NUM_FAILURE_ITEMS
Value:
((highest_active_reg - lowest_active_reg + 1) * NUM_REG_ITEMS \
#define NUM_REG_ITEMS
Definition: GnuRegex.c:2192
#define NUM_NONREG_ITEMS
Definition: GnuRegex.c:2198

Definition at line 2205 of file GnuRegex.c.

#define NUM_NONREG_ITEMS   4

Definition at line 2198 of file GnuRegex.c.

#define NUM_REG_ITEMS   3

Definition at line 2192 of file GnuRegex.c.

#define PATFETCH (   c)
Value:
do {if (p == pend) return REG_EEND; \
c = (unsigned char) *p++; \
if (translate) c = translate[c]; \
} while (0)
char * p
Definition: membanger.c:43

Definition at line 751 of file GnuRegex.c.

Referenced by regex_compile().

#define PATFETCH_RAW (   c)
Value:
do {if (p == pend) return REG_EEND; \
c = (unsigned char) *p++; \
} while (0)
char * p
Definition: membanger.c:43

Definition at line 759 of file GnuRegex.c.

Referenced by regex_compile().

#define PATUNFETCH   p--

Definition at line 765 of file GnuRegex.c.

Referenced by regex_compile().

#define POINTER_TO_OFFSET (   ptr)    (FIRST_STRING_P (ptr) ? (ptr) - string1 : (ptr) - string2 + size1)

Definition at line 2716 of file GnuRegex.c.

Referenced by re_match_2().

#define POP_FAILURE_ITEM ( )    fail_stack.stack[--fail_stack.avail]

Definition at line 2096 of file GnuRegex.c.

#define POP_FAILURE_POINT (   str,
  pat,
  low_reg,
  high_reg,
  regstart,
  regend,
  reg_info 
)

Definition at line 2224 of file GnuRegex.c.

Referenced by re_match_2().

#define PREFETCH ( )
Value:
while (d == dend) \
{ \
/* End of string2 => fail. */ \
if (dend == end_match_2) \
goto fail; \
/* End of string1 => advance to string2. */ \
d = string2; \
dend = end_match_2; \
}

Definition at line 2729 of file GnuRegex.c.

Referenced by re_match_2().

#define PUSH_FAILURE_ITEM (   item)    fail_stack.stack[fail_stack.avail++] = (fail_stack_elt_t) item

Definition at line 2092 of file GnuRegex.c.

#define PUSH_FAILURE_POINT (   pattern_place,
  string_place,
  failure_code 
)

Definition at line 2116 of file GnuRegex.c.

Referenced by re_match_2().

#define PUSH_PATTERN_OP (   pattern_op,
  fail_stack 
)
Value:
&& !DOUBLE_FAIL_STACK (fail_stack)) \
? 0 \
: ((fail_stack).stack[(fail_stack).avail++] = pattern_op, \
1))
#define FAIL_STACK_FULL()
Definition: GnuRegex.c:2041
#define DOUBLE_FAIL_STACK(fail_stack)
Definition: GnuRegex.c:2065

Definition at line 2082 of file GnuRegex.c.

Referenced by re_compile_fastmap().

#define REG_MATCH_NULL_STRING_P (   R)    ((R).bits.match_null_string_p)

Definition at line 2693 of file GnuRegex.c.

Referenced by common_op_match_null_string_p(), and re_match_2().

#define REG_UNSET (   e)    ((e) == REG_UNSET_VALUE)

Definition at line 2721 of file GnuRegex.c.

Referenced by re_match_2().

#define REG_UNSET_VALUE   ((char *) -1)

Definition at line 2720 of file GnuRegex.c.

Referenced by re_match_2().

#define REGEX_ALLOCATE   malloc

Definition at line 182 of file GnuRegex.c.

#define REGEX_MALLOC   1

Definition at line 44 of file GnuRegex.c.

#define REGEX_REALLOCATE (   source,
  osize,
  nsize 
)    realloc (source, nsize)

Definition at line 183 of file GnuRegex.c.

#define REGEX_TALLOC (   n,
 
)    ((t *) REGEX_ALLOCATE ((n) * sizeof (t)))

Definition at line 224 of file GnuRegex.c.

Referenced by re_match_2().

#define REMAINING_AVAIL_SLOTS   ((fail_stack).size - (fail_stack).avail)

Definition at line 2210 of file GnuRegex.c.

#define RETALLOC (   addr,
  n,
 
)    ((addr) = (t *) realloc (addr, (n) * sizeof (t)))

Definition at line 223 of file GnuRegex.c.

Referenced by re_match_2(), and regex_compile().

#define SET_LIST_BIT (   c)
Value:
(b[((unsigned char) (c)) / BYTEWIDTH] \
|= 1 << (((unsigned char) c) % BYTEWIDTH))
#define BYTEWIDTH
Definition: GnuRegex.c:226

Definition at line 902 of file GnuRegex.c.

Referenced by compile_range(), and regex_compile().

#define SET_REGS_MATCHED ( )
Value:
do \
{ \
unsigned r; \
for (r = lowest_active_reg; r <= highest_active_reg; r++) \
{ \
MATCHED_SOMETHING (reg_info[r]) \
= EVER_MATCHED_SOMETHING (reg_info[r]) \
= 1; \
} \
} \
while (0)
#define EVER_MATCHED_SOMETHING(R)
Definition: GnuRegex.c:2696
#define MATCHED_SOMETHING(R)
Definition: GnuRegex.c:2695

Definition at line 2701 of file GnuRegex.c.

Referenced by re_match_2().

#define SIGN_EXTEND_CHAR (   c)    ((((unsigned char) (c)) ^ 128) - 128)

Definition at line 167 of file GnuRegex.c.

#define STORE_JUMP (   op,
  loc,
  to 
)    store_op1 (op, loc, (to) - (loc) - 3)

Definition at line 809 of file GnuRegex.c.

Referenced by regex_compile().

#define STORE_JUMP2 (   op,
  loc,
  to,
  arg 
)    store_op2 (op, loc, (to) - (loc) - 3, arg)

Definition at line 813 of file GnuRegex.c.

Referenced by regex_compile().

#define STORE_NUMBER (   destination,
  number 
)
Value:
do { \
(destination)[0] = (number) & 0377; \
(destination)[1] = (number) >> 8; \
} while (0)
number
Definition: testStatHist.cc:16

Definition at line 366 of file GnuRegex.c.

Referenced by re_match_2(), store_op1(), and store_op2().

#define STORE_NUMBER_AND_INCR (   destination,
  number 
)
Value:
do { \
STORE_NUMBER (destination, number); \
(destination) += 2; \
} while (0)
number
Definition: testStatHist.cc:16
#define STORE_NUMBER(destination, number)
Definition: GnuRegex.c:366

Definition at line 376 of file GnuRegex.c.

Referenced by re_match_2().

#define STREQ (   s1,
  s2 
)    ((strcmp (s1, s2) == 0))

Definition at line 228 of file GnuRegex.c.

Referenced by regex_compile().

#define Sword   1

Definition at line 60 of file GnuRegex.c.

Referenced by init_syntax_once(), re_compile_fastmap(), and wordchar_p().

#define TALLOC (   n,
 
)    ((t *) malloc ((n) * sizeof (t)))

Definition at line 222 of file GnuRegex.c.

Referenced by re_match_2(), regex_compile(), and regexec().

#define TRANSLATE (   d)    (translate ? translate[(unsigned char) (d)] : (d))

Definition at line 771 of file GnuRegex.c.

Referenced by compile_range(), re_match_2(), re_search_2(), and regex_compile().

#define true   1

Definition at line 234 of file GnuRegex.c.

#define WORDCHAR_P (   d)
Value:
(re_syntax_table[(d) == end1 ? *string2 \
: (d) == string2 - 1 ? *(end1 - 1) : *(d)] \
== Sword)
#define Sword
Definition: GnuRegex.c:60
static char re_syntax_table[CHAR_SET_SIZE]
Definition: GnuRegex.c:72

Definition at line 2752 of file GnuRegex.c.

Referenced by re_match_2().

Typedef Documentation

typedef char boolean

Definition at line 231 of file GnuRegex.c.

typedef const unsigned char* fail_stack_elt_t

Definition at line 2031 of file GnuRegex.c.

Definition at line 871 of file GnuRegex.c.

typedef unsigned regnum_t

Definition at line 865 of file GnuRegex.c.

Enumeration Type Documentation

Enumerator
no_op 
exactn 
anychar 
charset 
charset_not 
start_memory 
stop_memory 
duplicate 
begline 
endline 
begbuf 
endbuf 
jump 
jump_past_alt 
on_failure_jump 
on_failure_keep_string_jump 
pop_failure_jump 
maybe_pop_jump 
dummy_failure_jump 
push_dummy_failure 
succeed_n 
jump_n 
set_number_at 
wordchar 
notwordchar 
wordbeg 
wordend 
wordbound 
notwordbound 

Definition at line 245 of file GnuRegex.c.

Function Documentation

boolean alt_match_null_string_p ( unsigned char *  p,
unsigned char *  end,
register_info_type reg_info 
)
static
boolean at_begline_loc_p ( const char *  pattern,
const char *  p,
reg_syntax_t  syntax 
)
static

Definition at line 1915 of file GnuRegex.c.

References RE_NO_BK_PARENS, and RE_NO_BK_VBAR.

Referenced by regex_compile().

boolean at_endline_loc_p ( const char *  p,
const char *  pend,
int  syntax 
)
static

Definition at line 1931 of file GnuRegex.c.

References NULL, p, RE_NO_BK_PARENS, and RE_NO_BK_VBAR.

Referenced by regex_compile().

static int at_strings_end ( const char *  d,
const char *  end2 
)
static

Definition at line 2743 of file GnuRegex.c.

Referenced by re_match_2().

int bcmp_translate ( unsigned char const *  s1,
unsigned char const *  s2,
register int  len,
char *  translate 
)
static

Definition at line 4070 of file GnuRegex.c.

References s1.

Referenced by re_match_2().

boolean common_op_match_null_string_p ( unsigned char **  p,
unsigned char *  end,
register_info_type reg_info 
)
static
reg_errcode_t compile_range ( const char **  p_ptr,
const char *  pend,
char *  translate,
reg_syntax_t  syntax,
unsigned char *  b 
)
static

Definition at line 1975 of file GnuRegex.c.

References RE_NO_EMPTY_RANGES, REG_ERANGE, REG_NOERROR, SET_LIST_BIT, and TRANSLATE.

Referenced by regex_compile().

boolean group_in_compile_stack ( compile_stack_type  compile_stack,
regnum_t  regnum 
)
static
boolean group_match_null_string_p ( unsigned char **  p,
unsigned char *  end,
register_info_type reg_info 
)
static
static void init_syntax_once ( void  )
static

Definition at line 75 of file GnuRegex.c.

References re_syntax_table, and Sword.

Referenced by regex_compile().

void insert_op1 ( re_opcode_t  op,
unsigned char *  loc,
int  arg,
unsigned char *  end 
)
static

Definition at line 1885 of file GnuRegex.c.

References store_op1().

void insert_op2 ( re_opcode_t  op,
unsigned char *  loc,
int  arg1,
int  arg2,
unsigned char *  end 
)
static

Definition at line 1899 of file GnuRegex.c.

References store_op2().

Referenced by regex_compile().

int re_match_2 ( struct re_pattern_buffer buffer,
const char *  string1,
int  length1,
const char *  string2,
int  length2,
int  start,
struct re_registers regs,
int  stop 
)
static
static int re_search ( struct re_pattern_buffer buffer,
const char *  string,
int  length,
int  start,
int  range,
struct re_registers regs 
)
static

Definition at line 2527 of file GnuRegex.c.

References NULL, and re_search_2().

Referenced by regexec().

static int re_search_2 ( struct re_pattern_buffer buffer,
const char *  string1,
int  length1,
const char *  string2,
int  length2,
int  start,
int  range,
struct re_registers regs,
int  stop 
)
static

Definition at line 2559 of file GnuRegex.c.

References begbuf, re_compile_fastmap(), re_match_2(), and TRANSLATE.

Referenced by re_search().

size_t regerror ( int  errcode,
const regex_t preg,
char *  errbuf,
size_t  errbuf_size 
)
static reg_errcode_t regex_compile ( const char *  pattern,
int  size,
reg_syntax_t  syntax,
struct re_pattern_buffer bufp 
)
static

Definition at line 952 of file GnuRegex.c.

References re_pattern_buffer::allocated, anychar, assert, at_begline_loc_p(), at_endline_loc_p(), compile_stack_type::avail, begbuf, begline, BUF_PUSH, BUF_PUSH_2, BUF_PUSH_3, re_pattern_buffer::buffer, BYTEWIDTH, CHAR_CLASS_MAX_LENGTH, charset, charset_not, compile_range(), COMPILE_STACK_TOP, debug, DEBUG_PRINT1, dummy_failure_jump, duplicate, endbuf, endline, exactn, re_pattern_buffer::fastmap_accurate, free, GET_BUFFER_SPACE, GET_UNSIGNED_NUMBER, group_in_compile_stack(), INIT_BUF_SIZE, INIT_COMPILE_STACK_SIZE, init_syntax_once(), INSERT_JUMP, INSERT_JUMP2, insert_op2(), IS_CHAR_CLASS, ISALNUM, ISALPHA, ISBLANK, ISCNTRL, ISDIGIT, ISGRAPH, ISLOWER, ISPRINT, ISPUNCT, ISSPACE, ISUPPER, ISXDIGIT, jump, jump_n, jump_past_alt, MAX_REGNUM, maybe_pop_jump, re_pattern_buffer::not_bol, re_pattern_buffer::not_eol, notwordbound, notwordchar, NULL, on_failure_jump, on_failure_keep_string_jump, p, PATFETCH, PATFETCH_RAW, PATUNFETCH, push_dummy_failure, RE_BACKSLASH_ESCAPE_IN_LISTS, RE_BK_PLUS_QM, RE_CHAR_CLASSES, RE_CONTEXT_INDEP_ANCHORS, RE_CONTEXT_INDEP_OPS, RE_CONTEXT_INVALID_OPS, RE_DOT_NEWLINE, RE_DUP_MAX, RE_HAT_LISTS_NOT_NEWLINE, RE_INTERVALS, RE_LIMITED_OPS, RE_NEWLINE_ALT, RE_NO_BK_BRACES, RE_NO_BK_PARENS, RE_NO_BK_REFS, RE_NO_BK_VBAR, re_pattern_buffer::re_nsub, RE_UNMATCHED_RIGHT_PAREN_ORD, REG_BADBR, REG_BADRPT, REG_EBRACE, REG_EBRACK, REG_ECTYPE, REG_EESCAPE, REG_EPAREN, REG_ERANGE, REG_ERPAREN, REG_ESPACE, REG_ESUBREG, REG_NOERROR, RETALLOC, SET_LIST_BIT, set_number_at, size, compile_stack_type::size, compile_stack_type::stack, start_memory, stop_memory, STORE_JUMP, STORE_JUMP2, STREQ, succeed_n, re_pattern_buffer::syntax, TALLOC, re_pattern_buffer::translate, TRANSLATE, re_pattern_buffer::used, wordbeg, wordbound, wordchar, and wordend.

Referenced by regcomp().

void regfree ( regex_t preg)
void store_op1 ( re_opcode_t  op,
unsigned char *  loc,
int  arg 
)
static

Definition at line 1865 of file GnuRegex.c.

References STORE_NUMBER.

Referenced by insert_op1().

void store_op2 ( re_opcode_t  op,
unsigned char *  loc,
int  arg1,
int  arg2 
)
static

Definition at line 1874 of file GnuRegex.c.

References STORE_NUMBER.

Referenced by insert_op2().

static int wordchar_p ( const char *  d,
const char *  end1,
const char *  string2 
)
static

Definition at line 2757 of file GnuRegex.c.

References re_syntax_table, and Sword.

Referenced by re_match_2().

Variable Documentation

const char* re_error_msg[]
static
Initial value:
= {NULL,
"No match",
"Invalid regular expression",
"Invalid collation character",
"Invalid character class name",
"Trailing backslash",
"Invalid back reference",
"Unmatched [ or [^",
"Unmatched ( or \\(",
"Unmatched \\{",
"Invalid content of \\{\\}",
"Invalid range end",
"Memory exhausted",
"Invalid preceding regular expression",
"Premature end of regular expression",
"Regular expression too big",
"Unmatched ) or \\)",
}
#define NULL
Definition: types.h:166

Definition at line 726 of file GnuRegex.c.

int re_max_failures = 2000

Definition at line 2029 of file GnuRegex.c.

char re_syntax_table[CHAR_SET_SIZE]
static

Definition at line 72 of file GnuRegex.c.

Referenced by init_syntax_once(), re_compile_fastmap(), and wordchar_p().

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors