]> git.sur5r.net Git - openldap/blob - contrib/tweb/regular.h
Update man page date.
[openldap] / contrib / tweb / regular.h
1 /*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
2 *                                                                          *
3 * regular.h..                                                              *
4 *                                                                          *
5 * Function:..Routine for TWEB                                              *
6 *                                                                          *
7 *                                                                          *
8 *                                                                          *
9 * Authors:...Dr. Kurt Spanier & Bernhard Winkler,                          *
10 *            Zentrum fuer Datenverarbeitung, Bereich Entwicklung           *
11 *            neuer Dienste, Universitaet Tuebingen, GERMANY                *
12 *                                                                          *
13 *                                       ZZZZZ  DDD    V   V                *
14 *            Creation date:                Z   D  D   V   V                *
15 *            January 20 1998              Z    D   D   V V                 *
16 *            Last modification:          Z     D  D    V V                 *
17 *            December 31 1998           ZZZZZ  DDD      V                  *
18 *                                                                          *
19 _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
20 /*
21  * $Id: regular.h,v 1.6 1999/09/10 15:01:19 zrnsk01 Exp $
22  *
23  */
24
25 #ifndef _REGULAR_
26 #define _REGULAR_
27
28
29 /* definition   number  opnd?   meaning */
30 #define END     0       /* no   End of program. */
31 #define BOL     1       /* no   Match "" at beginning of line. */
32 #define EOL     2       /* no   Match "" at end of line. */
33 #define ANY     3       /* no   Match any one character. */
34 #define ANYOF   4       /* str  Match any character in this string. */
35 #define ANYBUT  5       /* str  Match any character not in this string. */
36 #define BRANCH  6       /* node Match this alternative, or the next... */
37 #define BACK    7       /* no   Match "", "next" ptr points backward. */
38 #define EXACTLY 8       /* str  Match this string. */
39 #define NOTHING 9       /* no   Match empty string. */
40 #define STAR    10      /* node Match this (simple) thing 0 or more times. */
41 #define PLUS    11      /* node Match this (simple) thing 1 or more times. */
42 #define OPEN    20      /* no   Mark this point in input as start of #n. */
43                         /*      OPEN+1 is number 1, etc. */
44 #define CLOSE   ((OPEN)+(NSUBEXP)+1)    /* no   Analogous to OPEN. */
45
46 /*
47  * Opcode notes:
48  *
49  * BRANCH       The set of branches constituting a single choice are hooked
50  *              together with their "next" pointers, since precedence prevents
51  *              anything being concatenated to any individual branch.  The
52  *              "next" pointer of the last BRANCH in a choice points to the
53  *              thing following the whole choice.  This is also where the
54  *              final "next" pointer of each individual branch points; each
55  *              branch starts with the operand node of a BRANCH node.
56  *
57  * BACK         Normal "next" pointers all implicitly point forward; BACK
58  *              exists to make loop structures possible.
59  *
60  * STAR,PLUS    '?', and complex '*' and '+', are implemented as circular
61  *              BRANCH structures using BACK.  Simple cases (one character
62  *              per match) are implemented with STAR and PLUS for speed
63  *              and to minimize recursive plunges.
64  *
65  * OPEN,CLOSE   ...are numbered at compile time.
66  */
67
68 /*
69  * A node is one char of opcode followed by two chars of "next" pointer.
70  * "Next" pointers are stored as two 8-bit pieces, high order first.  The
71  * value is a positive offset from the opcode of the node containing it.
72  * An operand, if any, simply follows the node.  (Note that much of the
73  * code generation knows about this implicit relationship.)
74  *
75  * Using two bytes for the "next" pointer is vast overkill for most things,
76  * but allows patterns to get big without disasters.
77  */
78 #define OP(p)   (*(p))
79 #define NEXT(p) (((*((p)+1)&0377)<<8) + (*((p)+2)&0377))
80 #define OPERAND(p)      ((p) + 3)
81
82 /*
83  * See regmagic.h for one further detail of program structure.
84  */
85
86
87 /*
88  * Utility definitions.
89  */
90 #ifndef CHARBITS
91 #define UCHARAT(p)      ((int)*(unsigned char *)(p))
92 #else
93 #define UCHARAT(p)      ((int)*(p)&CHARBITS)
94 #endif
95
96 #define FAIL(m) { tweb_regerror(m); return(NULL); }
97 #define ISMULT(c)       ((c) == '*' || (c) == '+' || (c) == '?')
98 #define META    "^$.[()|?+*\\"
99
100 /*
101  * Flags to be passed up and down.
102  */
103 #define HASWIDTH        01      /* Known never to match null string. */
104 #define SIMPLE          02      /* Simple enough to be STAR/PLUS operand. */
105 #define SPSTART         04      /* Starts with * or +. */
106 #define WORST           0       /* Worst case. */
107
108 /*
109  * Global work variables for regcomp().
110  */
111 PRIVATE char *regparse;         /* Input-scan pointer. */
112 PRIVATE int regnpar;            /* () count. */
113 PRIVATE char regdummy;
114 PRIVATE char *regcode;          /* Code-emit pointer; &regdummy = don't. */
115 PRIVATE long regsize;           /* Code size. */
116
117 /*
118  * Forward declarations for regcomp()'s friends.
119  */
120 #ifndef STATIC
121 #define STATIC  static
122 #endif
123 PRIVATE char *tweb_reg();
124 PRIVATE char *tweb_regbranch();
125 PRIVATE char *tweb_regpiece();
126 PRIVATE char *tweb_regatom();
127 PRIVATE char *tweb_regnode();
128 PRIVATE char *tweb_regnext();
129 PRIVATE void tweb_regc();
130 PRIVATE void tweb_reginsert();
131 PRIVATE void tweb_regtail();
132 PRIVATE void tweb_regoptail();
133 #ifdef STRCSPN
134 STATIC int tweb_strcspn();
135 #endif
136
137 #endif /* _REGULAR_ */