1 /* regcomp and regexec -- regsub and regerror are elsewhere
3 * Copyright (c) 1986 by University of Toronto.
4 * Written by Henry Spencer. Not derived from licensed software.
6 * Permission is granted to anyone to use this software for any
7 * purpose on any computer system, and to redistribute it freely,
8 * subject to the following restrictions:
10 * 1. The author is not responsible for the consequences of use of
11 * this software, no matter how awful, even if they arise
14 * 2. The origin of this software must not be misrepresented, either
15 * by explicit claim or by omission.
17 * 3. Altered versions must be plainly marked as such, and must not
18 * be misrepresented as being the original software.
20 * Beware that some of this code is subtly aware of the way operator
21 * precedence is structured in regular expressions. Serious changes in
22 * regular-expression syntax might require a total rethink.
24 * The third parameter to regexec was added by Martin C. Atkins.
25 * Andy Tanenbaum also made some changes.
31 #define const /* avoid "const poisoning" */
35 /* The first byte of the regexp internal "program" is actually this magic
36 * number; the start node begins in the second byte.
40 /* The "internal use only" fields in regexp.h are present to pass info from
41 * compile to execute that permits the execute phase to run lots faster on
42 * simple cases. They are:
44 * regstart char that must begin a match; '\0' if none obvious
45 * reganch is the match anchored (at beginning-of-line only)?
46 * regmust string (pointer into program) that match must include, or NULL
47 * regmlen length of regmust string
49 * Regstart and reganch permit very fast decisions on suitable starting points
50 * for a match, cutting down the work a lot. Regmust permits fast rejection
51 * of lines that cannot possibly match. The regmust tests are costly enough
52 * that regcomp() supplies a regmust only if the r.e. contains something
53 * potentially expensive (at present, the only such thing detected is * or +
54 * at the start of the r.e., which can involve a lot of backup). Regmlen is
55 * supplied because the test in regexec() needs it and regcomp() is computing
59 /* Structure for regexp "program". This is essentially a linear encoding
60 * of a nondeterministic finite-state machine (aka syntax charts or
61 * "railroad normal form" in parsing technology). Each node is an opcode
62 * plus a "next" pointer, possibly plus an operand. "Next" pointers of
63 * all nodes except BRANCH implement concatenation; a "next" pointer with
64 * a BRANCH on both ends of it is connecting two alternatives. (Here we
65 * have one of the subtle syntax dependencies: an individual BRANCH (as
66 * opposed to a collection of them) is never concatenated with anything
67 * because of operator precedence.) The operand of some types of node is
68 * a literal string; for others, it is a node leading into a sub-FSM. In
69 * particular, the operand of a BRANCH node is the first node of the branch.
70 * (NB this is *not* a tree structure: the tail of the branch connects
71 * to the thing following the set of BRANCHes.) The opcodes are:
74 /* Definition number opnd? meaning */
75 #define END 0 /* no End of program. */
76 #define BOL 1 /* no Match "" at beginning of line. */
77 #define EOL 2 /* no Match "" at end of line. */
78 #define ANY 3 /* no Match any one character. */
79 #define ANYOF 4 /* str Match any character in this string. */
80 #define ANYBUT 5 /* str Match any character not in this
82 #define BRANCH 6 /* node Match this alternative, or the
84 #define BACK 7 /* no Match "", "next" ptr points backward. */
85 #define EXACTLY 8 /* str Match this string. */
86 #define NOTHING 9 /* no Match empty string. */
87 #define STAR 10 /* node Match this (simple) thing 0 or more
89 #define PLUS 11 /* node Match this (simple) thing 1 or more
91 #define OPEN 20 /* no Mark this point in input as start of
93 /* OPEN+1 is number 1, etc. */
94 #define CLOSE 30 /* no Analogous to OPEN. */
98 * BRANCH The set of branches constituting a single choice are hooked
99 * together with their "next" pointers, since precedence prevents
100 * anything being concatenated to any individual branch. The
101 * "next" pointer of the last BRANCH in a choice points to the
102 * thing following the whole choice. This is also where the
103 * final "next" pointer of each individual branch points; each
104 * branch starts with the operand node of a BRANCH node.
106 * BACK Normal "next" pointers all implicitly point forward; BACK
107 * exists to make loop structures possible.
109 * STAR,PLUS '?', and complex '*' and '+', are implemented as circular
110 * BRANCH structures using BACK. Simple cases (one character
111 * per match) are implemented with STAR and PLUS for speed
112 * and to minimize recursive plunges.
114 * OPEN,CLOSE ...are numbered at compile time.
117 /* A node is one char of opcode followed by two chars of "next" pointer.
118 * "Next" pointers are stored as two 8-bit pieces, high order first. The
119 * value is a positive offset from the opcode of the node containing it.
120 * An operand, if any, simply follows the node. (Note that much of the
121 * code generation knows about this implicit relationship.)
123 * Using two bytes for the "next" pointer is vast overkill for most things,
124 * but allows patterns to get big without disasters.
127 #define NEXT(p) (((*((p)+1)&0377)<<8) + (*((p)+2)&0377))
128 #define OPERAND(p) ((p) + 3)
130 /* Utility definitions.
133 #define UCHARAT(p) ((int)*(unsigned char *)(p))
135 #define UCHARAT(p) ((int)*(p)&CHARBITS)
138 #define CFAIL(m) { regerror(m); return((char *)NULL); }
139 #define RFAIL(m) { regerror(m); return((regexp *)NULL); }
140 #define ISMULT(c) ((c) == '*' || (c) == '+' || (c) == '?')
141 #define META "^$.[()|?+*\\"
143 /* Flags to be passed up and down.
145 #define HASWIDTH 01 /* Known never to match null string. */
146 #define SIMPLE 02 /* Simple enough to be STAR/PLUS operand. */
147 #define SPSTART 04 /* Starts with * or +. */
148 #define WORST 0 /* Worst case. */
150 /* Global work variables for regcomp().
152 static char *regparse
; /* Input-scan pointer. */
153 static int regnpar
; /* () count. */
154 static char regdummy
;
155 static char *regcode
; /* Code-emit pointer; ®dummy = don't. */
156 static long regsize
; /* Code size. */
158 /* Forward declarations for regcomp()'s friends.
160 static char *reg(int paren
, int *flagp
);
161 static char *regbranch(int *flagp
);
162 static char *regpiece(int *flagp
);
163 static char *regatom(int *flagp
);
164 static char *regnode(int op
);
165 static char *regnext(char *p
);
166 static void regc(int b
);
167 static void reginsert(int op
, char *opnd
);
168 static void regtail(char *p
, char *val
);
169 static void regoptail(char *p
, char *val
);
172 - regcomp - compile a regular expression into internal code
174 * We can't allocate space until we know how big the compiled form will be,
175 * but we can't compile it (and thus know how big it is) until we've got a
176 * place to put the code. So we cheat: we compile it twice, once with code
177 * generation turned off and size counting turned on, and once "for real".
178 * This also means that we don't allocate space until we are sure that the
179 * thing really will compile successfully, and we never have to move the
180 * code and thus invalidate pointers into it. (Note that it has to be in
181 * one piece because free() must be able to free it all.)
183 * Beware that the optimization-preparation code in here knows about some
184 * of the structure of the compiled regexp.
191 register char *longest
;
195 if (exp
== (char *)NULL
) RFAIL("NULL argument");
197 /* First pass: determine size, legality. */
203 if (reg(0, &flags
) == (char *)NULL
) return((regexp
*)NULL
);
205 /* Small enough for pointer-storage convention? */
206 if (regsize
>= 32767L) /* Probably could be 65535L. */
207 RFAIL("regexp too big");
209 /* Allocate space. */
210 r
= (regexp
*) malloc(sizeof(regexp
) + (unsigned) regsize
);
211 if (r
== (regexp
*)NULL
) RFAIL("out of space");
213 /* Second pass: emit code. */
216 regcode
= r
->program
;
218 if (reg(0, &flags
) == (char *)NULL
) return((regexp
*)NULL
);
220 /* Dig out information for optimizations. */
221 r
->regstart
= '\0'; /* Worst-case defaults. */
223 r
->regmust
= (char *)NULL
;
225 scan
= r
->program
+ 1; /* First BRANCH. */
226 if (OP(regnext(scan
)) == END
) { /* Only one top-level choice. */
227 scan
= OPERAND(scan
);
229 /* Starting-point info. */
230 if (OP(scan
) == EXACTLY
)
231 r
->regstart
= *OPERAND(scan
);
232 else if (OP(scan
) == BOL
)
235 /* If there's something expensive in the r.e., find the
236 * longest literal string that must appear and make it the
237 * regmust. Resolve ties in favor of later strings, since
238 * the regstart check works with the beginning of the r.e.
239 * and avoiding duplication strengthens checking. Not a
240 * strong reason, but sufficient in the absence of others. */
241 if (flags
& SPSTART
) {
242 longest
= (char *)NULL
;
244 for (; scan
!= (char *)NULL
; scan
= regnext(scan
))
245 if (OP(scan
) == EXACTLY
&& strlen(OPERAND(scan
)) >= len
) {
246 longest
= OPERAND(scan
);
247 len
= strlen(OPERAND(scan
));
249 r
->regmust
= longest
;
257 - reg - regular expression, i.e. main body or parenthesized thing
259 * Caller must absorb opening parenthesis.
261 * Combining parenthesis handling with the base level of regular expression
262 * is a trifle forced, but the need to tie the tails of the branches to what
263 * follows makes it hard to avoid.
265 static char *reg(paren
, flagp
)
266 int paren
; /* Parenthesized? */
271 register char *ender
;
275 *flagp
= HASWIDTH
; /* Tentatively. */
277 /* Make an OPEN node, if parenthesized. */
279 if (regnpar
>= NSUBEXP
) CFAIL("too many ()");
282 ret
= regnode(OPEN
+ parno
);
284 parno
= 0; /* not actually used, keep compiler quiet */
288 /* Pick up the branches, linking them together. */
289 br
= regbranch(&flags
);
290 if (br
== (char *)NULL
) return((char *)NULL
);
291 if (ret
!= (char *)NULL
)
292 regtail(ret
, br
); /* OPEN -> first. */
295 if (!(flags
& HASWIDTH
)) *flagp
&= ~HASWIDTH
;
296 *flagp
|= flags
& SPSTART
;
297 while (*regparse
== '|') {
299 br
= regbranch(&flags
);
300 if (br
== (char *)NULL
) return((char *)NULL
);
301 regtail(ret
, br
); /* BRANCH -> BRANCH. */
302 if (!(flags
& HASWIDTH
)) *flagp
&= ~HASWIDTH
;
303 *flagp
|= flags
& SPSTART
;
306 /* Make a closing node, and hook it on the end. */
307 ender
= regnode((paren
) ? CLOSE
+ parno
: END
);
310 /* Hook the tails of the branches to the closing node. */
311 for (br
= ret
; br
!= (char *)NULL
; br
= regnext(br
)) regoptail(br
, ender
);
313 /* Check for proper termination. */
314 if (paren
&& *regparse
++ != ')') {
315 CFAIL("unmatched ()");
316 } else if (!paren
&& *regparse
!= '\0') {
317 if (*regparse
== ')') {
318 CFAIL("unmatched ()");
320 CFAIL("junk on end"); /* "Can't happen". */
327 - regbranch - one alternative of an | operator
329 * Implements the concatenation operator.
331 static char *regbranch(flagp
)
335 register char *chain
;
336 register char *latest
;
339 *flagp
= WORST
; /* Tentatively. */
341 ret
= regnode(BRANCH
);
342 chain
= (char *)NULL
;
343 while (*regparse
!= '\0' && *regparse
!= '|' && *regparse
!= ')') {
344 latest
= regpiece(&flags
);
345 if (latest
== (char *)NULL
) return((char *)NULL
);
346 *flagp
|= flags
& HASWIDTH
;
347 if (chain
== (char *)NULL
) /* First piece. */
348 *flagp
|= flags
& SPSTART
;
350 regtail(chain
, latest
);
353 if (chain
== (char *)NULL
) /* Loop ran zero times. */
360 - regpiece - something followed by possible [*+?]
362 * Note that the branching code sequences used for ? and the general cases
363 * of * and + are somewhat optimized: they use the same NOTHING node as
364 * both the endmarker for their branch list and the body of the last branch.
365 * It might seem that this node could be dispensed with entirely, but the
366 * endmarker role is not redundant.
368 static char *regpiece(flagp
)
376 ret
= regatom(&flags
);
377 if (ret
== (char *)NULL
) return((char *)NULL
);
384 if (!(flags
& HASWIDTH
) && op
!= '?') CFAIL("*+ operand could be empty");
385 *flagp
= (op
!= '+') ? (WORST
| SPSTART
) : (WORST
| HASWIDTH
);
387 if (op
== '*' && (flags
& SIMPLE
))
388 reginsert(STAR
, ret
);
389 else if (op
== '*') {
390 /* Emit x* as (x&|), where & means "self". */
391 reginsert(BRANCH
, ret
); /* Either x */
392 regoptail(ret
, regnode(BACK
)); /* and loop */
393 regoptail(ret
, ret
); /* back */
394 regtail(ret
, regnode(BRANCH
)); /* or */
395 regtail(ret
, regnode(NOTHING
)); /* null. */
396 } else if (op
== '+' && (flags
& SIMPLE
))
397 reginsert(PLUS
, ret
);
398 else if (op
== '+') {
399 /* Emit x+ as x(&|), where & means "self". */
400 next
= regnode(BRANCH
); /* Either */
402 regtail(regnode(BACK
), ret
); /* loop back */
403 regtail(next
, regnode(BRANCH
)); /* or */
404 regtail(ret
, regnode(NOTHING
)); /* null. */
405 } else if (op
== '?') {
406 /* Emit x? as (x|) */
407 reginsert(BRANCH
, ret
); /* Either x */
408 regtail(ret
, regnode(BRANCH
)); /* or */
409 next
= regnode(NOTHING
);/* null. */
411 regoptail(ret
, next
);
414 if (ISMULT(*regparse
)) CFAIL("nested *?+");
420 - regatom - the lowest level
422 * Optimization: gobbles an entire sequence of ordinary characters so that
423 * it can turn them into a single node, which is smaller to store and
424 * faster to run. Backslashed characters are exceptions, each becoming a
425 * separate node; the code is simpler that way and it's not worth fixing.
427 static char *regatom(flagp
)
433 *flagp
= WORST
; /* Tentatively. */
435 switch (*regparse
++) {
436 case '^': ret
= regnode(BOL
); break;
437 case '$': ret
= regnode(EOL
); break;
440 *flagp
|= HASWIDTH
| SIMPLE
;
444 register int classend
;
446 if (*regparse
== '^') { /* Complement of range. */
447 ret
= regnode(ANYBUT
);
450 ret
= regnode(ANYOF
);
451 if (*regparse
== ']' || *regparse
== '-') regc(*regparse
++);
452 while (*regparse
!= '\0' && *regparse
!= ']') {
453 if (*regparse
== '-') {
455 if (*regparse
== ']' || *regparse
== '\0')
458 class = UCHARAT(regparse
- 2) + 1;
459 classend
= UCHARAT(regparse
);
460 if (class > classend
+ 1)
461 CFAIL("invalid [] range");
462 for (; class <= classend
; class++)
470 if (*regparse
!= ']') CFAIL("unmatched []");
472 *flagp
|= HASWIDTH
| SIMPLE
;
476 ret
= reg(1, &flags
);
477 if (ret
== (char *)NULL
) return((char *)NULL
);
478 *flagp
|= flags
& (HASWIDTH
| SPSTART
);
483 CFAIL("internal urp"); /* Supposed to be caught earlier. */
487 case '*': CFAIL("?+* follows nothing"); break;
489 if (*regparse
== '\0') CFAIL("trailing \\");
490 ret
= regnode(EXACTLY
);
493 *flagp
|= HASWIDTH
| SIMPLE
;
500 len
= strcspn(regparse
, META
);
501 if (len
<= 0) CFAIL("internal disaster");
502 ender
= *(regparse
+ len
);
503 if (len
> 1 && ISMULT(ender
))
504 len
--; /* Back off clear of ?+* operand. */
506 if (len
== 1) *flagp
|= SIMPLE
;
507 ret
= regnode(EXACTLY
);
521 - regnode - emit a node
523 static char *regnode(op
)
530 if (ret
== ®dummy
) {
536 *ptr
++ = '\0'; /* Null "next" pointer. */
544 - regc - emit (if appropriate) a byte of code
549 if (regcode
!= ®dummy
)
556 - reginsert - insert an operator in front of already-emitted operand
558 * Means relocating the operand.
560 static void reginsert(op
, opnd
)
566 register char *place
;
568 if (regcode
== ®dummy
) {
575 while (src
> opnd
) *--dst
= *--src
;
577 place
= opnd
; /* Op node, where operand used to be. */
584 - regtail - set the next-pointer at the end of a node chain
586 static void regtail(p
, val
)
594 if (p
== ®dummy
) return;
596 /* Find last node. */
599 temp
= (char *)regnext(scan
);
600 if (temp
== (char *)NULL
) break;
604 if (OP(scan
) == BACK
)
608 *(scan
+ 1) = (offset
>> 8) & 0377;
609 *(scan
+ 2) = offset
& 0377;
613 - regoptail - regtail on operand of first argument; nop if operandless
615 static void regoptail(p
, val
)
619 /* "Operandless" and "op != BRANCH" are synonymous in practice. */
620 if (p
== (char *)NULL
|| p
== ®dummy
|| OP(p
) != BRANCH
) return;
621 regtail(OPERAND(p
), val
);
624 /* regexec and friends
627 /* Global work variables for regexec().
629 static char *reginput
; /* String-input pointer. */
630 static char *regbol
; /* Beginning of input, for ^ check. */
631 static char **regstartp
; /* Pointer to startp array. */
632 static char **regendp
; /* Ditto for endp. */
636 static int regtry(regexp
*prog
, char *string
);
637 static int regmatch(char *prog
);
638 static int regrepeat(char *p
);
643 static char *regprop(char *op
);
647 - regexec - match a regexp against a string
649 int regexec(prog
, string
, bolflag
)
650 register regexp
*prog
;
651 register char *string
;
657 if (prog
== (regexp
*)NULL
|| string
== (char *)NULL
) {
658 regerror("NULL parameter");
662 /* Check validity of program. */
663 if (UCHARAT(prog
->program
) != MAGIC
) {
664 regerror("corrupted program");
668 /* If there is a "must appear" string, look for it. */
669 if (prog
->regmust
!= (char *)NULL
) {
671 while ((s
= strchr(s
, prog
->regmust
[0])) != (char *)NULL
) {
672 if (strncmp(s
, prog
->regmust
, prog
->regmlen
) == 0)
673 break; /* Found it. */
676 if (s
== (char *)NULL
) /* Not present. */
680 /* Mark beginning of line for ^ . */
684 regbol
= (char *)NULL
;
686 /* Simplest case: anchored match need be tried only once. */
687 if (prog
->reganch
) return(regtry(prog
, string
));
689 /* Messy cases: unanchored match. */
691 if (prog
->regstart
!= '\0') /* We know what char it must start with. */
692 while ((s
= strchr(s
, prog
->regstart
)) != (char *)NULL
) {
693 if (regtry(prog
, s
)) return(1);
697 /* We don't -- general case. */
699 if (regtry(prog
, s
)) return(1);
700 } while (*s
++ != '\0');
707 - regtry - try match at specific point
709 static int regtry(prog
, string
) /* 0 failure, 1 success */
718 regstartp
= prog
->startp
;
719 regendp
= prog
->endp
;
723 for (i
= NSUBEXP
; i
> 0; i
--) {
724 *sp
++ = (char *)NULL
;
725 *ep
++ = (char *)NULL
;
727 if (regmatch(prog
->program
+ 1)) {
728 prog
->startp
[0] = string
;
729 prog
->endp
[0] = reginput
;
736 - regmatch - main matching routine
738 * Conceptually the strategy is simple: check to see whether the current
739 * node matches, call self recursively to see whether the rest matches,
740 * and then act accordingly. In practice we make some effort to avoid
741 * recursion, in particular by going through "ordinary" nodes (that don't
742 * need to know whether the rest of the match failed) by a loop instead of
745 static int regmatch(prog
) /* 0 failure, 1 success */
748 register char *scan
; /* Current node. */
749 char *next
; /* Next node. */
753 if (scan
!= (char *)NULL
&& regnarrate
) fprintf(stderr
, "%s(\n", regprop(scan
));
755 while (scan
!= (char *)NULL
) {
757 if (regnarrate
) fprintf(stderr
, "%s...\n", regprop(scan
));
759 next
= regnext(scan
);
763 if (reginput
!= regbol
) return(0);
766 if (*reginput
!= '\0') return(0);
769 if (*reginput
== '\0') return(0);
776 opnd
= OPERAND(scan
);
777 /* Inline the first character, for speed. */
778 if (*opnd
!= *reginput
) return(0);
780 if (len
> 1 && strncmp(opnd
, reginput
, len
) != 0)
786 if (*reginput
== '\0' || strchr(OPERAND(scan
), *reginput
) == (char *)NULL
)
791 if (*reginput
== '\0' || strchr(OPERAND(scan
), *reginput
) != (char *)NULL
)
811 no
= OP(scan
) - OPEN
;
814 if (regmatch(next
)) {
815 /* Don't set startp if some later
816 * invocation of the same parentheses
818 if (regstartp
[no
] == (char *)NULL
)
819 regstartp
[no
] = save
;
837 no
= OP(scan
) - CLOSE
;
840 if (regmatch(next
)) {
841 /* Don't set endp if some later
842 * invocation of the same parentheses
844 if (regendp
[no
] == (char *)NULL
) regendp
[no
] = save
;
853 if (OP(next
) != BRANCH
) /* No choice. */
854 next
= OPERAND(scan
); /* Avoid recursion. */
858 if (regmatch(OPERAND(scan
)))
861 scan
= regnext(scan
);
862 } while (scan
!= (char *)NULL
&& OP(scan
) == BRANCH
);
870 register char nextch
;
875 /* Lookahead to avoid useless match attempts
876 * when we know what character comes next. */
878 if (OP(next
) == EXACTLY
) nextch
= *OPERAND(next
);
879 min
= (OP(scan
) == STAR
) ? 0 : 1;
881 no
= regrepeat(OPERAND(scan
));
883 /* If it could work, try it. */
884 if (nextch
== '\0' || *reginput
== nextch
)
885 if (regmatch(next
)) return(1);
886 /* Couldn't or didn't -- back up. */
888 reginput
= save
+ no
;
894 return(1); /* Success! */
897 regerror("memory corruption");
905 /* We get here only if there's trouble -- normally "case END" is the
906 * terminating point. */
907 regerror("corrupted pointers");
912 - regrepeat - repeatedly match something simple, report how many
914 static int regrepeat(p
)
917 register int count
= 0;
925 count
= strlen(scan
);
929 while (*opnd
== *scan
) {
935 while (*scan
!= '\0' && strchr(opnd
, *scan
) != (char *)NULL
) {
941 while (*scan
!= '\0' && strchr(opnd
, *scan
) == (char *)NULL
) {
946 default: /* Oh dear. Called inappropriately. */
947 regerror("internal foulup");
948 count
= 0; /* Best compromise. */
957 - regnext - dig the "next" pointer out of a node
959 static char *regnext(p
)
964 if (p
== ®dummy
) return((char *)NULL
);
967 if (offset
== 0) return((char *)NULL
);
977 static char *regprop();
980 - regdump - dump a regexp onto stdout in vaguely comprehensible form
986 register char op
= EXACTLY
; /* Arbitrary non-END op. */
990 while (op
!= END
) { /* While that wasn't END last time... */
992 printf("%2d%s", (int) (s
- r
->program
), regprop(s
)); /* Where, what. */
994 if (next
== (char *)NULL
) /* Next ptr. */
997 printf("(%d)", (int) (s
- r
->program
) + (int) (next
- s
));
999 if (op
== ANYOF
|| op
== ANYBUT
|| op
== EXACTLY
) {
1000 /* Literal string, where present. */
1001 while (*s
!= '\0') {
1010 /* Header fields of interest. */
1011 if (r
->regstart
!= '\0') printf("start `%c' ", r
->regstart
);
1012 if (r
->reganch
) printf("anchored ");
1013 if (r
->regmust
!= (char *)NULL
) printf("must have \"%s\"", r
->regmust
);
1018 - regprop - printable representation of opcode
1020 static char *regprop(op
)
1024 static char buf
[50];
1026 (void) strcpy(buf
, ":");
1029 case BOL
: p
= "BOL"; break;
1030 case EOL
: p
= "EOL"; break;
1031 case ANY
: p
= "ANY"; break;
1032 case ANYOF
: p
= "ANYOF"; break;
1033 case ANYBUT
: p
= "ANYBUT"; break;
1034 case BRANCH
: p
= "BRANCH"; break;
1035 case EXACTLY
: p
= "EXACTLY"; break;
1036 case NOTHING
: p
= "NOTHING"; break;
1037 case BACK
: p
= "BACK"; break;
1038 case END
: p
= "END"; break;
1048 sprintf(buf
+ strlen(buf
), "OPEN%d", OP(op
) - OPEN
);
1060 sprintf(buf
+ strlen(buf
), "CLOSE%d", OP(op
) - CLOSE
);
1063 case STAR
: p
= "STAR"; break;
1064 case PLUS
: p
= "PLUS"; break;
1065 default: regerror("corrupted opcode"); p
= (char *) NULL
; break;
1067 if (p
!= (char *)NULL
) (void) strcat(buf
, p
);
1074 * $PchId: regexp.c,v 1.4 1996/02/22 09:03:07 philip Exp $