regexp.c File Reference

#include <stdio.h>
#include <ctype.h>
#include "regexp.h"

Include dependency graph for regexp.c:

Go to the source code of this file.

Defines

#define regerror(a)   error("regular expression error: %s", a)
#define MAGIC   0234
#define END   0
#define BOL   1
#define EOL   2
#define ANY   3
#define ANYOF   4
#define ANYBUT   5
#define BRANCH   6
#define BACK   7
#define EXACTLY   8
#define NOTHING   9
#define STAR   10
#define PLUS   11
#define OPEN   20
#define CLOSE   30
#define OP(p)   (*(p))
#define NEXT(p)   (((*((p)+1)&0377)<<8) + *((p)+2)&0377)
#define OPERAND(p)   ((p) + 3)
#define UCHARAT(p)   ((int)*(p)&CHARBITS)
#define FAIL(m)   { regerror(m); return(NULL); }
#define ISMULT(c)   ((c) == '*' || (c) == '+' || (c) == '?')
#define META   "^$.[()|?+*\\"
#define HASWIDTH   01
#define SIMPLE   02
#define SPSTART   04
#define WORST   0
#define STATIC   static

Functions

STATIC ushort * reg ()
STATIC ushort * regbranch ()
STATIC ushort * regpiece ()
STATIC ushort * regatom ()
STATIC ushort * regnode ()
STATIC ushort * regnext ()
STATIC void regc ()
STATIC void reginsert ()
STATIC void regtail ()
STATIC void regoptail ()
STATIC int Strcspn ()
regexpregcomp (ushort *exp)
static ushort * reg (int paren, int *flagp)
static ushort * regbranch (int *flagp)
static ushort * regpiece (int *flagp)
static ushort * regatom (int *flagp)
 IsDigid (ushort c)
static ushort * regnode (ushort op)
static void regc (ushort b)
static void reginsert (ushort op, ushort *opnd)
static void regtail (ushort *p, ushort *val)
static void regoptail (ushort *p, ushort *val)
STATIC int regtry ()
STATIC int regmatch ()
STATIC int regrepeat ()
int regexec (regexp *prog, ushort *string, int bolflag)
static int regtry (regexp *prog, ushort *string)
static int regmatch (ushort *prog)
static int regrepeat (ushort *p)
static ushort * regnext (ushort *p)
static int Strcspn (ushort *s1, unsigned char *s2)
 isthere (ushort *s, ushort c)
ushort * Strchr (ushort *s, ushort c)
 Strncmp (ushort *s, ushort *t, n)
 Strlen (ushort *s)
char * mkpat (char *s)
 match (regexp *p, char *s)
 sjtok (ushort *s, unsigned char *t)
 ktosj (unsigned char *s, ushort *t)
 regsub (ushort *dst, regexp *exp, ushort *src, ushort *pat, pos)
 Sub (char *u, char *exp, str, char *s, char *t, pos)

Variables

int r_start
int r_length
static ushort * regparse
static int regnpar
static ushort regdummy
static ushort * regcode
static long regsize
static ushort * reginput
static ushort * regbol
static ushort ** regstartp
static ushort ** regendp
ushort kbuf [BUFSIZ]
static ushort kbuf1 [BUFSIZ]
static ushort kbuf2 [BUFSIZ]


Define Documentation

#define ANY   3
 

Definition at line 85 of file regexp.c.

Referenced by clock_task(), deadlock(), do_init(), driver_task(), f_intr_wait(), f_reset(), get_work(), main(), makepat(), mini_notify(), mini_receive(), mini_send(), omatch(), osdep_eth_init(), proc_name(), prrecv(), regatom(), regmatch(), regrepeat(), seek(), sr_rec(), start_motor(), sys_call(), sys_task(), and w_intr_wait().

#define ANYBUT   5
 

Definition at line 87 of file regexp.c.

Referenced by regatom(), regmatch(), and regrepeat().

#define ANYOF   4
 

Definition at line 86 of file regexp.c.

Referenced by regatom(), regmatch(), and regrepeat().

#define BACK   7
 

Definition at line 89 of file regexp.c.

#define BOL   1
 

Definition at line 83 of file regexp.c.

Referenced by fast(), makepat(), matchs(), omatch(), regatom(), regcomp(), regmatch(), slow(), and step().

#define BRANCH   6
 

Definition at line 88 of file regexp.c.

Referenced by regbranch(), regmatch(), regoptail(), and regpiece().

#define CLOSE   30
 

Definition at line 96 of file regexp.c.

#define END   0
 

Definition at line 82 of file regexp.c.

#define EOL   2
 

Definition at line 84 of file regexp.c.

#define EXACTLY   8
 

Definition at line 90 of file regexp.c.

Referenced by regatom(), regcomp(), regmatch(), and regrepeat().

#define FAIL m   )     { regerror(m); return(NULL); }
 

Definition at line 145 of file regexp.c.

Referenced by access_standards(), comp_array(), gettoken(), open_alot(), read_standards(), reg(), regatom(), regcomp(), regpiece(), servxcheck(), system(), test03(), test04(), test05(), test06(), test07(), test08(), test09(), test10(), test11(), tmpstart(), try_open(), and write_standards().

#define HASWIDTH   01
 

Definition at line 152 of file regexp.c.

Referenced by reg(), regatom(), regbranch(), and regpiece().

#define ISMULT c   )     ((c) == '*' || (c) == '+' || (c) == '?')
 

Definition at line 146 of file regexp.c.

Referenced by regatom(), and regpiece().

#define MAGIC   0234
 

Definition at line 43 of file regexp.c.

Referenced by _catch(), _cls(), _cre(), _efl(), _ini(), _opn(), _rf(), _wdw(), _wf(), bcpio_id(), bcpio_wr(), buff(), cache2file(), cpio_wr(), diag(), file2cache(), free(), initfl(), malloc(), nobuff(), pcreat(), popen(), regcomp(), regexec(), regsub(), and swapon().

#define META   "^$.[()|?+*\\"
 

Definition at line 147 of file regexp.c.

Referenced by regatom().

#define NEXT p   )     (((*((p)+1)&0377)<<8) + *((p)+2)&0377)
 

Definition at line 131 of file regexp.c.

#define NOTHING   9
 

Definition at line 91 of file regexp.c.

#define OP p   )     (*(p))
 

Definition at line 130 of file regexp.c.

Referenced by backref(), dissect(), dofwd(), findmust(), p_simp_re(), pluscount(), regcomp(), regmatch(), regnext(), regoptail(), regrepeat(), and step().

#define OPEN   20
 

Definition at line 94 of file regexp.c.

#define OPERAND p   )     ((p) + 3)
 

Definition at line 132 of file regexp.c.

Referenced by regcomp(), regmatch(), regoptail(), and regrepeat().

#define PLUS   11
 

Definition at line 93 of file regexp.c.

Referenced by _do_compare(), bc_divide(), bc_multiply(), bc_sub(), evaluate(), expr_operator(), get_list(), get_string(), modify(), new_num(), num2long(), prin1(), regmatch(), and regpiece().

#define regerror a   )     error("regular expression error: %s", a)
 

Definition at line 35 of file regexp.c.

Referenced by regexec(), regmatch(), regrepeat(), regsub(), and rep_add().

#define SIMPLE   02
 

Definition at line 153 of file regexp.c.

Referenced by lookup(), regatom(), and regpiece().

#define SPSTART   04
 

Definition at line 154 of file regexp.c.

Referenced by reg(), regatom(), regbranch(), regcomp(), and regpiece().

#define STAR   10
 

Definition at line 92 of file regexp.c.

Referenced by check_string(), evaluate(), get_list(), get_string(), prin1(), regmatch(), and regpiece().

#define STATIC   static
 

Definition at line 170 of file regexp.c.

#define UCHARAT p   )     ((int)*(p)&CHARBITS)
 

Definition at line 142 of file regexp.c.

Referenced by regatom(), regexec(), and regsub().

#define WORST   0
 

Definition at line 155 of file regexp.c.

Referenced by regatom(), regbranch(), and regpiece().


Function Documentation

IsDigid ushort  c  ) 
 

Definition at line 599 of file regexp.c.

Referenced by regatom().

isthere ushort *  s,
ushort  c
 

Definition at line 1281 of file regexp.c.

Referenced by regmatch(), and regrepeat().

ktosj unsigned char *  s,
ushort *  t
 

Definition at line 1357 of file regexp.c.

Referenced by Sub().

match regexp p,
char *  s
 

Definition at line 1331 of file regexp.c.

References i, r_length, r_start, regexec, and sjtok().

char* mkpat char *  s  ) 
 

Definition at line 1325 of file regexp.c.

References regcomp, and sjtok().

Referenced by expr10(), getpat(), r_mkfld(), and Split().

static ushort* reg int  paren,
int *  flagp
[static]
 

Definition at line 286 of file regexp.c.

References CLOSE, END, FAIL, flags, HASWIDTH, NSUBEXP, NULL, OPEN, regbranch(), regnext(), regnode(), regnpar, regoptail(), regparse, regtail(), SPSTART, and ushort.

STATIC ushort* reg  ) 
 

static ushort* regatom int *  flagp  )  [static]
 

Definition at line 461 of file regexp.c.

References ANY, ANYBUT, ANYOF, BOL, c, d, EOL, EXACTLY, FAIL, flags, HASWIDTH, IsDigid(), ISMULT, META, NULL, reg, regc(), regnode(), regparse, SIMPLE, SPSTART, Strcspn(), UCHARAT, ushort, and WORST.

STATIC ushort* regatom  ) 
 

Referenced by regpiece().

static ushort* regbranch int *  flagp  )  [static]
 

Definition at line 358 of file regexp.c.

References BRANCH, flags, HASWIDTH, NOTHING, NULL, regnode(), regparse, regpiece(), regtail(), SPSTART, ushort, and WORST.

STATIC ushort* regbranch  ) 
 

Referenced by reg().

static void regc ushort  b  )  [static]
 

Definition at line 633 of file regexp.c.

References regcode, regdummy, and regsize.

STATIC void regc  ) 
 

Referenced by regatom(), and regcomp().

regexp* regcomp ushort *  exp  ) 
 

Definition at line 200 of file regexp.c.

References BOL, emalloc(), END, EXACTLY, FAIL, flags, L, MAGIC, NULL, OP, OPERAND, r, reg, regc(), regcode, regdummy, regnext(), regnpar, regparse, regsize, SPSTART, Strlen(), and ushort.

int regexec regexp prog,
ushort *  string,
int  bolflag
 

Definition at line 748 of file regexp.c.

References MAGIC, NULL, regerror, regtry(), s, Strchr(), Strncmp(), and ushort.

static void reginsert ushort  op,
ushort *  opnd
[static]
 

Definition at line 648 of file regexp.c.

References place(), regcode, regdummy, regsize, and ushort.

STATIC void reginsert  ) 
 

Referenced by regpiece().

static int regmatch ushort *  prog  )  [static]
 

Definition at line 852 of file regexp.c.

References ANY, ANYBUT, ANYOF, BACK, BOL, BRANCH, CLOSE, END, EOL, EXACTLY, fprintf(), isthere(), min, next, nextch(), NOTHING, NULL, OP, OPEN, OPERAND, PLUS, regerror, regmatch(), regnext(), regrepeat(), STAR, stderr, Strchr(), Strlen(), Strncmp(), and ushort.

STATIC int regmatch  ) 
 

Referenced by regmatch().

static ushort* regnext ushort *  p  )  [static]
 

Definition at line 1086 of file regexp.c.

References BACK, NEXT, NULL, offset, OP, and regdummy.

STATIC ushort* regnext  ) 
 

Referenced by reg(), regcomp(), regmatch(), and regtail().

static ushort* regnode ushort  op  )  [static]
 

Definition at line 608 of file regexp.c.

References ptr, regcode, regdummy, regsize, and ushort.

STATIC ushort* regnode  ) 
 

Referenced by reg(), regatom(), regbranch(), and regpiece().

static void regoptail ushort *  p,
ushort *  val
[static]
 

Definition at line 709 of file regexp.c.

References BRANCH, NULL, OP, OPERAND, regdummy, and regtail().

STATIC void regoptail  ) 
 

Referenced by reg(), and regpiece().

static ushort* regpiece int *  flagp  )  [static]
 

Definition at line 397 of file regexp.c.

References BACK, BRANCH, FAIL, flags, HASWIDTH, ISMULT, next, NOTHING, NULL, PLUS, regatom(), reginsert(), regnode(), regoptail(), regparse, regtail(), SIMPLE, SPSTART, STAR, ushort, and WORST.

STATIC ushort* regpiece  ) 
 

Referenced by regbranch().

static int regrepeat ushort *  p  )  [static]
 

Definition at line 1040 of file regexp.c.

References ANY, ANYBUT, ANYOF, count, EXACTLY, isthere(), OP, OPERAND, regerror, Strlen(), and ushort.

STATIC int regrepeat  ) 
 

Referenced by regmatch().

regsub ushort *  dst,
regexp exp,
ushort *  src,
ushort *  pat,
pos 
 

Definition at line 1369 of file regexp.c.

References exp, i, loc1, loc2, MAGIC, n, NULL, pos, regerror, regexec, t, and ushort.

static void regtail ushort *  p,
ushort *  val
[static]
 

Definition at line 677 of file regexp.c.

References NULL, offset, regdummy, regnext(), and ushort.

STATIC void regtail  ) 
 

Referenced by reg(), regbranch(), regoptail(), and regpiece().

static int regtry regexp prog,
ushort *  string
[static]
 

Definition at line 815 of file regexp.c.

References ep, i, NSUBEXP, NULL, sp, and ushort.

STATIC int regtry  ) 
 

Referenced by regexec().

sjtok ushort *  s,
unsigned char *  t
 

Definition at line 1345 of file regexp.c.

References isKanji().

Referenced by match(), mkpat(), and Sub().

ushort* Strchr ushort *  s,
ushort  c
 

Definition at line 1298 of file regexp.c.

References NULL.

Referenced by regexec(), and regmatch().

static int Strcspn ushort *  s1,
unsigned char *  s2
[static]
 

Definition at line 1263 of file regexp.c.

References count, and ushort.

STATIC int Strcspn  ) 
 

Referenced by regatom().

Strlen ushort *  s  ) 
 

Definition at line 1313 of file regexp.c.

References i.

Referenced by regcomp(), regmatch(), and regrepeat().

Strncmp ushort *  s,
ushort *  t,
n 
 

Definition at line 1306 of file regexp.c.

References n.

Referenced by regexec(), and regmatch().

Sub char *  u,
char *  exp,
str  ,
char *  s,
char *  t,
pos 
 

Definition at line 1421 of file regexp.c.

References i, kbuf, ktosj(), pos, r, regcomp, regsub, sfree(), and sjtok().

Referenced by Subst().


Variable Documentation

ushort kbuf[BUFSIZ]
 

Definition at line 1322 of file regexp.c.

Referenced by exrefresh(), initscr(), resume_curses(), starttcap(), Sub(), wqrefresh(), and wrefresh().

ushort kbuf1[BUFSIZ] [static]
 

Definition at line 1419 of file regexp.c.

ushort kbuf2[BUFSIZ] [static]
 

Definition at line 1419 of file regexp.c.

int r_length
 

Definition at line 37 of file regexp.c.

Referenced by match(), r_mkfld(), Split(), and Strfun().

int r_start
 

Definition at line 37 of file regexp.c.

Referenced by match(), r_mkfld(), Split(), and Strfun().

ushort* regbol [static]
 

Definition at line 727 of file regexp.c.

ushort* regcode [static]
 

Definition at line 163 of file regexp.c.

Referenced by regc(), regcomp(), reginsert(), and regnode().

ushort regdummy [static]
 

Definition at line 162 of file regexp.c.

Referenced by regc(), regcomp(), reginsert(), regnext(), regnode(), regoptail(), and regtail().

ushort** regendp [static]
 

Definition at line 729 of file regexp.c.

ushort* reginput [static]
 

Definition at line 726 of file regexp.c.

int regnpar [static]
 

Definition at line 161 of file regexp.c.

Referenced by reg(), and regcomp().

ushort* regparse [static]
 

Definition at line 160 of file regexp.c.

Referenced by reg(), regatom(), regbranch(), regcomp(), and regpiece().

long regsize [static]
 

Definition at line 164 of file regexp.c.

Referenced by regc(), regcomp(), reginsert(), and regnode().

ushort** regstartp [static]
 

Definition at line 728 of file regexp.c.


Generated on Fri Apr 14 22:58:27 2006 for minix by  doxygen 1.4.6