/home/aaron/olsrd-current/olsrd/src/android/regex/regcomp.c File Reference

#include <sys/types.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>
#include <stdlib.h>
#include <regex.h>
#include "utils.h"
#include <assert.h>
Include dependency graph for regcomp.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  parse

Defines

#define NPAREN   10
#define PEEK()   (*p->next)
#define PEEK2()   (*(p->next+1))
#define MORE()   (p->next < p->end)
#define MORE2()   (p->next+1 < p->end)
#define SEE(c)   (MORE() && PEEK() == (c))
#define SEETWO(a, b)   (MORE() && MORE2() && PEEK() == (a) && PEEK2() == (b))
#define EAT(c)   ((SEE(c)) ? (NEXT(), 1) : 0)
#define EATTWO(a, b)   ((SEETWO(a, b)) ? (NEXT2(), 1) : 0)
#define NEXT()   (p->next++)
#define NEXT2()   (p->next += 2)
#define NEXTn(n)   (p->next += (n))
#define GETNEXT()   (*p->next++)
#define SETERROR(e)   seterr(p, (e))
#define REQUIRE(co, e)   ((co) || SETERROR(e))
#define MUSTSEE(c, e)   (REQUIRE(MORE() && PEEK() == (c), e))
#define MUSTEAT(c, e)   (REQUIRE(MORE() && GETNEXT() == (c), e))
#define MUSTNOTSEE(c, e)   (REQUIRE(!MORE() || PEEK() != (c), e))
#define EMIT(op, sopnd)   doemit(p, (sop)(op), (size_t)(sopnd))
#define INSERT(op, pos)   doinsert(p, (sop)(op), HERE()-(pos)+1, pos)
#define AHEAD(pos)   dofwd(p, pos, HERE()-(pos))
#define ASTERN(sop, pos)   EMIT(sop, HERE()-pos)
#define HERE()   (p->slen)
#define THERE()   (p->slen - 1)
#define THERETHERE()   (p->slen - 2)
#define DROP(n)   (p->slen -= (n))
#define GOODFLAGS(f)   ((f)&~REG_DUMP)
#define BACKSL   (1<<CHAR_BIT)
#define N   2
#define INF   3
#define REP(f, t)   ((f)*8 + (t))
#define MAP(n)   (((n) <= 1) ? (n) : ((n) == INFINITY) ? INF : N)

Functions

static void p_ere (struct parse *, int)
static void p_ere_exp (struct parse *)
static void p_str (struct parse *)
static void p_bre (struct parse *, int, int)
static int p_simp_re (struct parse *, int)
static int p_count (struct parse *)
static void p_bracket (struct parse *)
static void p_b_term (struct parse *, cset *)
static void p_b_cclass (struct parse *, cset *)
static void p_b_eclass (struct parse *, cset *)
static char p_b_symbol (struct parse *)
static char p_b_coll_elem (struct parse *, int)
static char othercase (int)
static void bothcases (struct parse *, int)
static void ordinary (struct parse *, int)
static void nonnewline (struct parse *)
static void repeat (struct parse *, sopno, int, int)
static int seterr (struct parse *, int)
static csetallocset (struct parse *)
static void freeset (struct parse *, cset *)
static int freezeset (struct parse *, cset *)
static int firstch (struct parse *, cset *)
static int nch (struct parse *, cset *)
static void mcadd (struct parse *, cset *, char *)
static void mcinvert (struct parse *, cset *)
static void mccase (struct parse *, cset *)
static int isinsets (struct re_guts *, int)
static int samesets (struct re_guts *, int, int)
static void categorize (struct parse *, struct re_guts *)
static sopno dupl (struct parse *, sopno, sopno)
static void doemit (struct parse *, sop, size_t)
static void doinsert (struct parse *, sop, size_t, sopno)
static void dofwd (struct parse *, sopno, sop)
static void enlarge (struct parse *, sopno)
static void stripsnug (struct parse *, struct re_guts *)
static void findmust (struct parse *, struct re_guts *)
static sopno pluscount (struct parse *, struct re_guts *)
int regcomp (regex_t *preg, const char *pattern, int cflags)

Variables

static char nuls [10]
static int never = 0

Define Documentation

#define AHEAD ( pos   )     dofwd(p, pos, HERE()-(pos))

Definition at line 132 of file regcomp.c.

Referenced by p_ere(), p_ere_exp(), and repeat().

#define ASTERN ( sop,
pos   )     EMIT(sop, HERE()-pos)

Definition at line 133 of file regcomp.c.

Referenced by p_ere(), p_ere_exp(), p_simp_re(), and repeat().

#define BACKSL   (1<<CHAR_BIT)

Referenced by p_simp_re().

#define DROP (  )     (p->slen -= (n))

Definition at line 137 of file regcomp.c.

Referenced by p_bre(), and repeat().

#define EAT (  )     ((SEE(c)) ? (NEXT(), 1) : 0)

Definition at line 119 of file regcomp.c.

Referenced by p_b_term(), p_bracket(), p_bre(), p_ere(), p_ere_exp(), and p_simp_re().

#define EATTWO ( a,
 )     ((SEETWO(a, b)) ? (NEXT2(), 1) : 0)

Definition at line 120 of file regcomp.c.

Referenced by p_b_symbol(), p_b_term(), and p_simp_re().

#define EMIT ( op,
sopnd   )     doemit(p, (sop)(op), (size_t)(sopnd))

Definition at line 130 of file regcomp.c.

Referenced by doinsert(), ordinary(), p_bracket(), p_bre(), p_ere(), p_ere_exp(), p_simp_re(), regcomp(), and repeat().

 
#define GETNEXT (  )     (*p->next++)

Definition at line 124 of file regcomp.c.

Referenced by p_b_symbol(), p_count(), p_ere_exp(), p_simp_re(), and p_str().

#define GOODFLAGS (  )     ((f)&~REG_DUMP)

Referenced by regcomp(), and regexec().

 
#define HERE (  )     (p->slen)

Definition at line 134 of file regcomp.c.

Referenced by doinsert(), dupl(), p_bre(), p_ere(), p_ere_exp(), p_simp_re(), and repeat().

#define INF   3

Referenced by repeat().

#define INSERT ( op,
pos   )     doinsert(p, (sop)(op), HERE()-(pos)+1, pos)

Definition at line 131 of file regcomp.c.

Referenced by p_ere(), p_ere_exp(), p_simp_re(), and repeat().

#define MAP (  )     (((n) <= 1) ? (n) : ((n) == INFINITY) ? INF : N)

Referenced by repeat().

 
#define MORE (  )     (p->next < p->end)
 
#define MORE2 (  )     (p->next+1 < p->end)

Definition at line 116 of file regcomp.c.

Referenced by p_b_term(), and p_ere_exp().

#define MUSTEAT ( c,
 )     (REQUIRE(MORE() && GETNEXT() == (c), e))

Definition at line 128 of file regcomp.c.

Referenced by p_bracket(), and p_ere_exp().

#define MUSTNOTSEE ( c,
 )     (REQUIRE(!MORE() || PEEK() != (c), e))

Definition at line 129 of file regcomp.c.

#define MUSTSEE ( c,
 )     (REQUIRE(MORE() && PEEK() == (c), e))

Definition at line 127 of file regcomp.c.

#define N   2

Referenced by repeat().

 
#define NEXT (  )     (p->next++)

Definition at line 121 of file regcomp.c.

Referenced by p_b_cclass(), p_b_coll_elem(), p_b_term(), p_ere_exp(), and p_simp_re().

 
#define NEXT2 (  )     (p->next += 2)

Definition at line 122 of file regcomp.c.

Referenced by p_b_term().

#define NEXTn (  )     (p->next += (n))

Definition at line 123 of file regcomp.c.

Referenced by p_bracket().

#define NPAREN   10

Definition at line 59 of file regcomp.c.

Referenced by doinsert(), p_ere_exp(), p_simp_re(), and regcomp().

 
#define PEEK (  )     (*p->next)

Definition at line 113 of file regcomp.c.

Referenced by p_b_cclass(), p_b_term(), p_bracket(), p_count(), p_ere(), p_ere_exp(), and p_simp_re().

 
#define PEEK2 (  )     (*(p->next+1))

Definition at line 114 of file regcomp.c.

Referenced by p_b_term(), and p_ere_exp().

#define REP ( f,
 )     ((f)*8 + (t))

Referenced by repeat().

#define REQUIRE ( co,
 )     ((co) || SETERROR(e))

Definition at line 126 of file regcomp.c.

Referenced by p_b_symbol(), p_b_term(), p_bre(), p_count(), p_ere(), p_ere_exp(), p_simp_re(), and p_str().

#define SEE (  )     (MORE() && PEEK() == (c))

Definition at line 117 of file regcomp.c.

Referenced by p_b_term(), p_ere(), and p_ere_exp().

#define SEETWO ( a,
 )     (MORE() && MORE2() && PEEK() == (a) && PEEK2() == (b))

Definition at line 118 of file regcomp.c.

Referenced by p_b_coll_elem(), p_bracket(), p_bre(), and p_simp_re().

#define SETERROR (  )     seterr(p, (e))
 
#define THERE (  )     (p->slen - 1)

Definition at line 135 of file regcomp.c.

Referenced by p_ere(), p_ere_exp(), regcomp(), and repeat().

 
#define THERETHERE (  )     (p->slen - 2)

Definition at line 136 of file regcomp.c.

Referenced by p_ere_exp(), and repeat().


Function Documentation

static cset * allocset ( struct parse p  )  [static]
static void bothcases ( struct parse p,
int  ch 
) [static]

Definition at line 875 of file regcomp.c.

References parse::end, parse::next, othercase(), and p_bracket().

Referenced by ordinary().

Here is the call graph for this function:

static void categorize ( struct parse p,
struct re_guts g 
) [static]

Definition at line 1250 of file regcomp.c.

References re_guts::categories, parse::error, isinsets(), re_guts::ncategories, and samesets().

Referenced by regcomp().

Here is the call graph for this function:

static void doemit ( struct parse p,
sop  op,
size_t  opnd 
) [static]

Definition at line 1301 of file regcomp.c.

References enlarge(), parse::error, OPSHIFT, parse::slen, SOP, parse::ssize, and parse::strip.

Here is the call graph for this function:

static void dofwd ( struct parse p,
sopno  pos,
sop  value 
) [static]

Definition at line 1358 of file regcomp.c.

References parse::error, OP, OPSHIFT, and parse::strip.

static void doinsert ( struct parse p,
sop  op,
size_t  opnd,
sopno  pos 
) [static]

Definition at line 1323 of file regcomp.c.

References EMIT, parse::error, HERE, NPAREN, parse::pbegin, parse::pend, and parse::strip.

static sopno dupl ( struct parse p,
sopno  start,
sopno  finish 
) [static]

Definition at line 1275 of file regcomp.c.

References enlarge(), HERE, parse::slen, parse::ssize, and parse::strip.

Referenced by p_simp_re(), and repeat().

Here is the call graph for this function:

static void enlarge ( struct parse p,
sopno  size 
) [static]

Definition at line 1372 of file regcomp.c.

References REG_ESPACE, SETERROR, parse::ssize, and parse::strip.

Referenced by doemit(), and dupl().

static void findmust ( struct parse p,
struct re_guts g 
) [static]
static int firstch ( struct parse p,
cset cs 
) [static]

Definition at line 1134 of file regcomp.c.

References CHIN, re_guts::csetsize, parse::g, and never.

Referenced by p_bracket().

static void freeset ( struct parse p,
cset cs 
) [static]

Definition at line 1081 of file regcomp.c.

References CHsub, re_guts::csetsize, parse::g, re_guts::ncsets, and re_guts::sets.

Referenced by freezeset(), and p_bracket().

static int freezeset ( struct parse p,
cset cs 
) [static]

Definition at line 1103 of file regcomp.c.

References CHIN, re_guts::csetsize, freeset(), parse::g, cset::hash, re_guts::ncsets, and re_guts::sets.

Referenced by p_bracket().

Here is the call graph for this function:

static int isinsets ( struct re_guts g,
int  c 
) [static]

Definition at line 1215 of file regcomp.c.

References re_guts::ncsets, and re_guts::setbits.

Referenced by categorize().

static void mcadd ( struct parse p,
cset cs,
char *  cp 
) [static]

Definition at line 1166 of file regcomp.c.

References cset::multis, REG_ESPACE, SETERROR, and cset::smultis.

static void mccase ( struct parse p,
cset cs 
) [static]

Definition at line 1206 of file regcomp.c.

References cset::multis.

Referenced by p_bracket().

static void mcinvert ( struct parse p,
cset cs 
) [static]

Definition at line 1193 of file regcomp.c.

References cset::multis.

Referenced by p_bracket().

static int nch ( struct parse p,
cset cs 
) [static]

Definition at line 1150 of file regcomp.c.

References CHIN, re_guts::csetsize, and parse::g.

Referenced by p_bracket().

static void nonnewline ( struct parse p  )  [static]

Definition at line 917 of file regcomp.c.

References parse::end, parse::next, and p_bracket().

Referenced by p_ere_exp(), and p_simp_re().

Here is the call graph for this function:

static void ordinary ( struct parse p,
int  ch 
) [static]

Definition at line 898 of file regcomp.c.

References bothcases(), re_guts::categories, re_guts::cflags, EMIT, parse::g, re_guts::ncategories, OCHAR, othercase(), and REG_ICASE.

Referenced by p_bracket(), p_ere_exp(), p_simp_re(), and p_str().

Here is the call graph for this function:

static char othercase ( int  ch  )  [static]

Definition at line 857 of file regcomp.c.

Referenced by bothcases(), ordinary(), and p_bracket().

static void p_b_cclass ( struct parse p,
cset cs 
) [static]

Definition at line 767 of file regcomp.c.

References cclasses, CHadd, cclass::chars, MCadd, MORE, cclass::multis, cclass::name, NEXT, parse::next, PEEK, REG_ECTYPE, and SETERROR.

Referenced by p_b_term().

static char p_b_coll_elem ( struct parse p,
int  endc 
) [static]

Definition at line 830 of file regcomp.c.

References cnames, cname::code, MORE, cname::name, NEXT, parse::next, REG_EBRACK, REG_ECOLLATE, SEETWO, and SETERROR.

Referenced by p_b_eclass(), and p_b_symbol().

static void p_b_eclass ( struct parse p,
cset cs 
) [static]

Definition at line 800 of file regcomp.c.

References CHadd, and p_b_coll_elem().

Referenced by p_b_term().

Here is the call graph for this function:

static char p_b_symbol ( struct parse p  )  [static]

Definition at line 812 of file regcomp.c.

References EATTWO, GETNEXT, MORE, p_b_coll_elem(), REG_EBRACK, REG_ECOLLATE, and REQUIRE.

Referenced by p_b_term().

Here is the call graph for this function:

static void p_b_term ( struct parse p,
cset cs 
) [static]

Definition at line 704 of file regcomp.c.

References CHadd, EAT, EATTWO, MORE, MORE2, NEXT, NEXT2, p_b_cclass(), p_b_eclass(), p_b_symbol(), PEEK, PEEK2, REG_EBRACK, REG_ECOLLATE, REG_ECTYPE, REG_ERANGE, REQUIRE, SEE, and SETERROR.

Referenced by p_bracket().

Here is the call graph for this function:

static void p_bracket ( struct parse p  )  [static]
static void p_bre ( struct parse p,
int  end1,
int  end2 
) [static]

Definition at line 457 of file regcomp.c.

References DROP, EAT, EMIT, parse::g, HERE, re_guts::iflags, MORE, re_guts::nbol, re_guts::neol, OBOL, OEOL, p_simp_re(), REG_EMPTY, REQUIRE, SEETWO, USEBOL, and USEEOL.

Referenced by p_simp_re(), and regcomp().

Here is the call graph for this function:

static int p_count ( struct parse p  )  [static]

Definition at line 604 of file regcomp.c.

References DUPMAX, GETNEXT, MORE, PEEK, REG_BADBR, and REQUIRE.

Referenced by p_ere_exp(), and p_simp_re().

static void p_ere ( struct parse p,
int  stop 
) [static]

Definition at line 249 of file regcomp.c.

References AHEAD, ASTERN, EAT, EMIT, HERE, INSERT, MORE, O_CH, OCH_, OOR1, OOR2, p_ere_exp(), PEEK, REG_EMPTY, REQUIRE, SEE, and THERE.

Referenced by p_ere_exp(), and regcomp().

Here is the call graph for this function:

static void p_ere_exp ( struct parse p  )  [static]
static int p_simp_re ( struct parse p,
int  starordinary 
) [static]
static void p_str ( struct parse p  )  [static]

Definition at line 439 of file regcomp.c.

References GETNEXT, MORE, ordinary(), REG_EMPTY, and REQUIRE.

Referenced by regcomp().

Here is the call graph for this function:

static sopno pluscount ( struct parse p,
struct re_guts g 
) [static]

Definition at line 1490 of file regcomp.c.

References BAD, parse::error, re_guts::iflags, O_PLUS, OEND, OP, OPLUS_, and re_guts::strip.

Referenced by regcomp().

int regcomp ( regex_t preg,
const char *  pattern,
int  cflags 
)
static void repeat ( struct parse p,
sopno  start,
int  from,
int  to 
) [static]

Definition at line 939 of file regcomp.c.

References AHEAD, ASTERN, DROP, dupl(), EMIT, parse::error, HERE, INF, INSERT, MAP, N, O_CH, O_PLUS, OCH_, OOR1, OOR2, OPLUS_, REG_ASSERT, REP, SETERROR, THERE, and THERETHERE.

Referenced by p_ere_exp(), and p_simp_re().

Here is the call graph for this function:

static int samesets ( struct re_guts g,
int  c1,
int  c2 
) [static]

Definition at line 1232 of file regcomp.c.

References re_guts::ncsets, and re_guts::setbits.

Referenced by categorize().

static int seterr ( struct parse p,
int  e 
) [static]

Definition at line 1009 of file regcomp.c.

References parse::end, parse::error, parse::next, and nuls.

static void stripsnug ( struct parse p,
struct re_guts g 
) [static]

Definition at line 1392 of file regcomp.c.

References re_guts::nstates, REG_ESPACE, SETERROR, parse::slen, parse::strip, and re_guts::strip.

Referenced by regcomp().


Variable Documentation

int never = 0 [static]

Definition at line 140 of file regcomp.c.

Referenced by firstch().

char nuls[10] [static]

Definition at line 107 of file regcomp.c.

Referenced by seterr().

Generated on Thu May 23 06:00:05 2013 for olsrd by  doxygen 1.6.3