5 * "A fair jaw-cracker dwarf-language must be." --Samwise Gamgee
8 /* NOTE: this is derived from Henry Spencer's regexp code, and should not
9 * confused with the original package (see point 3 below). Thanks, Henry!
12 /* Additional note: this code is very heavily munged from Henry's version
13 * in places. In some spots I've traded clarity for efficiency, so don't
14 * blame Henry for some of the lack of readability.
19 * regcomp and regexec -- regsub and regerror are not used in perl
21 * Copyright (c) 1986 by University of Toronto.
22 * Written by Henry Spencer. Not derived from licensed software.
24 * Permission is granted to anyone to use this software for any
25 * purpose on any computer system, and to redistribute it freely,
26 * subject to the following restrictions:
28 * 1. The author is not responsible for the consequences of use of
29 * this software, no matter how awful, even if they arise
32 * 2. The origin of this software must not be misrepresented, either
33 * by explicit claim or by omission.
35 * 3. Altered versions must be plainly marked as such, and must not
36 * be misrepresented as being the original software.
39 **** Alterations to Henry's code are...
41 **** Copyright (c) 1991-1994, Larry Wall
43 **** You may distribute under the terms of either the GNU General Public
44 **** License or the Artistic License, as specified in the README file.
47 * Beware that some of this code is subtly aware of the way operator
48 * precedence is structured in regular expressions. Serious changes in
49 * regular-expression syntax might require a total rethink.
57 # if defined(BUGGY_MSC6)
58 /* MSC 6.00A breaks on op/regexp.t test 85 unless we turn this off */
59 # pragma optimize("a",off)
60 /* But MSC 6.00A is happy with 'w', for aliases only across function calls*/
61 # pragma optimize("w",on )
62 # endif /* BUGGY_MSC6 */
69 #define ISMULT1(c) ((c) == '*' || (c) == '+' || (c) == '?')
70 #define ISMULT2(s) ((*s) == '*' || (*s) == '+' || (*s) == '?' || \
71 ((*s) == '{' && regcurly(s)))
73 #define PERL_META "^$.[()|?+*\\"
75 #define META "^$.[()|?+*\\"
79 #undef SPSTART /* dratted cpp namespace... */
82 * Flags to be passed up and down.
84 #define WORST 0 /* Worst case. */
85 #define HASWIDTH 0x1 /* Known never to match null string. */
86 #define SIMPLE 0x2 /* Simple enough to be STAR/PLUS operand. */
87 #define SPSTART 0x4 /* Starts with * or +. */
88 #define TRYAGAIN 0x8 /* Weeded out a declaration. */
91 * Forward declarations for regcomp()'s friends.
94 static char *reg _((I32, I32 *));
95 static char *reganode _((char, unsigned short));
96 static char *regatom _((I32 *));
97 static char *regbranch _((I32 *));
98 static void regc _((char));
99 static char *regclass _((void));
100 STATIC I32 regcurly _((char *));
101 static char *regnode _((char));
102 static char *regpiece _((I32 *));
103 static void reginsert _((char, char *));
104 static void regoptail _((char *, char *));
105 static void regset _((char *, I32, I32));
106 static void regtail _((char *, char *));
107 static char* nextchar _((void));
110 - regcomp - compile a regular expression into internal code
112 * We can't allocate space until we know how big the compiled form will be,
113 * but we can't compile it (and thus know how big it is) until we've got a
114 * place to put the code. So we cheat: we compile it twice, once with code
115 * generation turned off and size counting turned on, and once "for real".
116 * This also means that we don't allocate space until we are sure that the
117 * thing really will compile successfully, and we never have to move the
118 * code and thus invalidate pointers into it. (Note that it has to be in
119 * one piece because free() must be able to free it all.) [NB: not true in perl]
121 * Beware that the optimization-preparation code in here knows about some
122 * of the structure of the compiled regexp. [I'll say.]
130 I32 fold = pm->op_pmflags & PMf_FOLD;
133 register SV *longish;
136 register char *first;
146 croak("NULL regexp argument");
148 /* First pass: determine size, legality. */
149 regflags = pm->op_pmflags;
152 regprecomp = savepvn(exp,xend-exp);
159 if (reg(0, &flags) == NULL) {
160 Safefree(regprecomp);
165 /* Small enough for pointer-storage convention? */
166 if (regsize >= 32767L) /* Probably could be 65535L. */
167 FAIL("regexp too big");
169 /* Allocate space. */
170 Newc(1001, r, sizeof(regexp) + (unsigned)regsize, char, regexp);
172 FAIL("regexp out of space");
174 /* Second pass: emit code. */
175 r->prelen = xend-exp;
176 r->precomp = regprecomp;
177 r->subbeg = r->subbase = NULL;
181 regcode = r->program;
183 if (reg(0, &flags) == NULL)
186 /* Dig out information for optimizations. */
187 pm->op_pmflags = regflags;
188 fold = pm->op_pmflags & PMf_FOLD;
189 r->regstart = Nullsv; /* Worst-case defaults. */
193 r->regstclass = Nullch;
194 r->naughty = regnaughty >= 10; /* Probably an expensive pattern. */
195 scan = r->program+1; /* First BRANCH. */
196 if (OP(regnext(scan)) == END) {/* Only one top-level choice. */
197 scan = NEXTOPER(scan);
200 while ((OP(first) == OPEN && (sawopen = 1)) ||
201 (OP(first) == BRANCH && OP(regnext(first)) != BRANCH) ||
202 (OP(first) == PLUS) ||
203 (OP(first) == MINMOD) ||
204 (regkind[(U8)OP(first)] == CURLY && ARG1(first) > 0) ) {
205 if (OP(first) == PLUS)
208 first += regarglen[(U8)OP(first)];
209 first = NEXTOPER(first);
212 /* Starting-point info. */
214 if (OP(first) == EXACTLY) {
215 r->regstart = newSVpv(OPERAND(first)+1,*OPERAND(first));
216 if (SvCUR(r->regstart) > !(sawstudy|fold))
217 fbm_compile(r->regstart,fold);
219 sv_upgrade(r->regstart, SVt_PVBM);
221 else if (strchr(simple+2,OP(first)))
222 r->regstclass = first;
223 else if (OP(first) == BOUND || OP(first) == NBOUND)
224 r->regstclass = first;
225 else if (regkind[(U8)OP(first)] == BOL) {
226 r->reganch = ROPT_ANCH;
227 first = NEXTOPER(first);
230 else if ((OP(first) == STAR &&
231 regkind[(U8)OP(NEXTOPER(first))] == ANY) &&
232 !(r->reganch & ROPT_ANCH) )
234 /* turn .* into ^.* with an implied $*=1 */
235 r->reganch = ROPT_ANCH | ROPT_IMPLICIT;
236 first = NEXTOPER(first);
239 if (sawplus && (!sawopen || !regsawback))
240 r->reganch |= ROPT_SKIP; /* x+ must match 1st of run */
242 DEBUG_r(fprintf(stderr,"first %d next %d offset %d\n",
243 OP(first), OP(NEXTOPER(first)), first - scan));
245 * If there's something expensive in the r.e., find the
246 * longest literal string that must appear and make it the
247 * regmust. Resolve ties in favor of later strings, since
248 * the regstart check works with the beginning of the r.e.
249 * and avoiding duplication strengthens checking. Not a
250 * strong reason, but sufficient in the absence of others.
251 * [Now we resolve ties in favor of the earlier string if
252 * it happens that curback has been invalidated, since the
253 * earlier string may buy us something the later one won't.]
255 longish = newSVpv("",0);
256 longest = newSVpv("",0);
262 while (OP(scan) != END) {
263 if (OP(scan) == BRANCH) {
264 if (OP(regnext(scan)) == BRANCH) {
266 while (OP(scan) == BRANCH)
267 scan = regnext(scan);
269 else /* single branch is ok */
270 scan = NEXTOPER(scan);
272 if (OP(scan) == UNLESSM) {
274 scan = regnext(scan);
276 if (OP(scan) == EXACTLY) {
280 while (OP(t = regnext(scan)) == CLOSE)
282 minlen += *OPERAND(first);
283 if (curback - backish == len) {
284 sv_catpvn(longish, OPERAND(first)+1,
286 len += *OPERAND(first);
287 curback += *OPERAND(first);
288 first = regnext(scan);
290 else if (*OPERAND(first) >= len + (curback >= 0)) {
291 len = *OPERAND(first);
292 sv_setpvn(longish, OPERAND(first)+1,len);
295 first = regnext(scan);
298 curback += *OPERAND(first);
300 else if (strchr(varies,OP(scan))) {
303 if (SvCUR(longish) > SvCUR(longest)) {
304 sv_setsv(longest,longish);
307 sv_setpvn(longish,"",0);
308 if (OP(scan) == PLUS && strchr(simple,OP(NEXTOPER(scan))))
310 else if (regkind[(U8)OP(scan)] == CURLY &&
311 strchr(simple,OP(NEXTOPER(scan)+4)))
312 minlen += ARG1(scan);
314 else if (strchr(simple,OP(scan))) {
318 if (SvCUR(longish) > SvCUR(longest)) {
319 sv_setsv(longest,longish);
322 sv_setpvn(longish,"",0);
324 scan = regnext(scan);
327 /* Prefer earlier on tie, unless we can tail match latter */
329 if (SvCUR(longish) + (regkind[(U8)OP(first)] == EOL) >
332 sv_setsv(longest,longish);
336 sv_setpvn(longish,"",0);
341 !fbm_instr((unsigned char*) SvPVX(r->regstart),
342 (unsigned char *) SvPVX(r->regstart)
343 + SvCUR(r->regstart),
348 r->regmust = longest;
351 r->regback = backest;
352 if (SvCUR(longest) > !(sawstudy || fold ||
353 regkind[(U8)OP(first)]==EOL))
354 fbm_compile(r->regmust,fold);
355 (void)SvUPGRADE(r->regmust, SVt_PVBM);
356 BmUSEFUL(r->regmust) = 100;
357 if (regkind[(U8)OP(first)] == EOL && SvCUR(longish))
358 SvTAIL_on(r->regmust);
361 SvREFCNT_dec(longest);
364 SvREFCNT_dec(longish);
367 r->do_folding = fold;
368 r->nparens = regnpar - 1;
370 Newz(1002, r->startp, regnpar, char*);
371 Newz(1002, r->endp, regnpar, char*);
377 - reg - regular expression, i.e. main body or parenthesized thing
379 * Caller must absorb opening parenthesis.
381 * Combining parenthesis handling with the base level of regular expression
382 * is a trifle forced, but the need to tie the tails of the branches to what
383 * follows makes it hard to avoid.
387 I32 paren; /* Parenthesized? */
392 register char *ender = 0;
393 register I32 parno = 0;
396 *flagp = HASWIDTH; /* Tentatively. */
398 /* Make an OPEN node, if parenthesized. */
400 if (*regparse == '?') {
411 croak("Sequence (?%c...) not implemented", paren);
414 while (*regparse && *regparse != ')')
416 if (*regparse != ')')
417 croak("Sequence (?#... not terminated", *regparse);
423 while (*regparse && strchr("iogmsx", *regparse))
424 pmflag(®flags, *regparse++);
425 if (*regparse != ')')
426 croak("Sequence (?%c...) not recognized", *regparse);
435 ret = reganode(OPEN, parno);
440 /* Pick up the branches, linking them together. */
441 br = regbranch(&flags);
445 regtail(ret, br); /* OPEN -> first. */
448 if (!(flags&HASWIDTH))
450 *flagp |= flags&SPSTART;
451 while (*regparse == '|') {
453 br = regbranch(&flags);
456 regtail(ret, br); /* BRANCH -> BRANCH. */
457 if (!(flags&HASWIDTH))
459 *flagp |= flags&SPSTART;
462 /* Make a closing node, and hook it on the end. */
465 ender = regnode(NOTHING);
468 ender = reganode(CLOSE, parno);
472 ender = regnode(SUCCEED);
476 ender = regnode(END);
481 /* Hook the tails of the branches to the closing node. */
482 for (br = ret; br != NULL; br = regnext(br))
483 regoptail(br, ender);
486 reginsert(IFMATCH,ret);
487 regtail(ret, regnode(NOTHING));
489 else if (paren == '!') {
490 reginsert(UNLESSM,ret);
491 regtail(ret, regnode(NOTHING));
494 /* Check for proper termination. */
495 if (paren && *nextchar() != ')') {
496 FAIL("unmatched () in regexp");
497 } else if (!paren && regparse < regxend) {
498 if (*regparse == ')') {
499 FAIL("unmatched () in regexp");
501 FAIL("junk on end of regexp"); /* "Can't happen". */
509 - regbranch - one alternative of an | operator
511 * Implements the concatenation operator.
518 register char *chain;
519 register char *latest;
522 *flagp = WORST; /* Tentatively. */
524 ret = regnode(BRANCH);
528 while (regparse < regxend && *regparse != '|' && *regparse != ')') {
530 latest = regpiece(&flags);
531 if (latest == NULL) {
532 if (flags & TRYAGAIN)
536 *flagp |= flags&HASWIDTH;
537 if (chain == NULL) /* First piece. */
538 *flagp |= flags&SPSTART;
541 regtail(chain, latest);
545 if (chain == NULL) /* Loop ran zero times. */
546 (void) regnode(NOTHING);
552 - regpiece - something followed by possible [*+?]
554 * Note that the branching code sequences used for ? and the general cases
555 * of * and + are somewhat optimized: they use the same NOTHING node as
556 * both the endmarker for their branch list and the body of the last branch.
557 * It might seem that this node could be dispensed with entirely, but the
558 * endmarker role is not redundant.
568 char *origparse = regparse;
573 ret = regatom(&flags);
575 if (flags & TRYAGAIN)
581 if (op == '(' && regparse[1] == '?' && regparse[2] == '#') {
582 while (op && op != ')')
590 if (op == '{' && regcurly(regparse)) {
593 while (isDIGIT(*next) || *next == ',') {
602 if (*next == '}') { /* got one */
606 min = atoi(regparse);
612 if (!max && *maxpos != '0')
613 max = 32767; /* meaning "infinity" */
618 if ((flags&SIMPLE)) {
619 regnaughty += 2 + regnaughty / 2;
620 reginsert(CURLY, ret);
623 regnaughty += 4 + regnaughty; /* compound interest */
624 regtail(ret, regnode(WHILEM));
625 reginsert(CURLYX,ret);
626 regtail(ret, regnode(NOTHING));
630 *flagp = (WORST|HASWIDTH);
631 if (max && max < min)
632 croak("Can't do {n,m} with n > m");
633 if (regcode != ®dummy) {
635 *(unsigned short *)(ret+3) = min;
636 *(unsigned short *)(ret+5) = max;
638 ret[3] = min >> 8; ret[4] = min & 0377;
639 ret[5] = max >> 8; ret[6] = max & 0377;
653 *flagp = (op != '+') ? (WORST|SPSTART) : (WORST|HASWIDTH);
655 if (op == '*' && (flags&SIMPLE)) {
656 reginsert(STAR, ret);
659 else if (op == '*') {
662 } else if (op == '+' && (flags&SIMPLE)) {
663 reginsert(PLUS, ret);
666 else if (op == '+') {
669 } else if (op == '?') {
674 if (dowarn && regcode != ®dummy && !(flags&HASWIDTH) && max > 10000) {
675 warn("%.*s matches null string many times",
676 regparse - origparse, origparse);
679 if (*regparse == '?') {
681 reginsert(MINMOD, ret);
683 regtail(ret, ret + 4);
685 regtail(ret, ret + 3);
688 if (ISMULT2(regparse))
689 FAIL("nested *?+ in regexp");
695 - regatom - the lowest level
697 * Optimization: gobbles an entire sequence of ordinary characters so that
698 * it can turn them into a single node, which is smaller to store and
699 * faster to run. Backslashed characters are exceptions, each becoming a
700 * separate node; the code is simpler that way and it's not worth fixing.
702 * [Yes, it is worth fixing, some scripts can run twice the speed.]
708 register char *ret = 0;
711 *flagp = WORST; /* Tentatively. */
717 if (regflags & PMf_MULTILINE)
719 else if (regflags & PMf_SINGLELINE)
726 if (regflags & PMf_MULTILINE)
728 else if (regflags & PMf_SINGLELINE)
735 if (regflags & PMf_SINGLELINE)
740 *flagp |= HASWIDTH|SIMPLE;
745 *flagp |= HASWIDTH|SIMPLE;
749 ret = reg(1, &flags);
751 if (flags & TRYAGAIN)
755 *flagp |= flags&(HASWIDTH|SPSTART);
759 if (flags & TRYAGAIN) {
763 croak("internal urp in regexp at /%s/", regparse);
764 /* Supposed to be caught earlier. */
769 FAIL("?+* follows nothing in regexp");
772 switch (*++regparse) {
789 ret = regnode(ALNUM);
790 *flagp |= HASWIDTH|SIMPLE;
794 ret = regnode(NALNUM);
795 *flagp |= HASWIDTH|SIMPLE;
799 ret = regnode(BOUND);
804 ret = regnode(NBOUND);
809 ret = regnode(SPACE);
810 *flagp |= HASWIDTH|SIMPLE;
814 ret = regnode(NSPACE);
815 *flagp |= HASWIDTH|SIMPLE;
819 ret = regnode(DIGIT);
820 *flagp |= HASWIDTH|SIMPLE;
824 ret = regnode(NDIGIT);
825 *flagp |= HASWIDTH|SIMPLE;
838 case '1': case '2': case '3': case '4':
839 case '5': case '6': case '7': case '8': case '9':
841 I32 num = atoi(regparse);
843 if (num > 9 && num >= regnpar)
847 ret = reganode(REF, num);
849 while (isDIGIT(*regparse))
857 if (regparse >= regxend)
858 FAIL("trailing \\ in regexp");
874 ret = regnode(EXACTLY);
875 regc(0); /* save spot for len */
876 for (len = 0, p = regparse - 1;
877 len < 127 && p < regxend;
930 ender = scan_hex(++p, 2, &numlen);
937 ender = toUPPER(ender);
940 case '0': case '1': case '2': case '3':case '4':
941 case '5': case '6': case '7': case '8':case '9':
943 (isDIGIT(p[1]) && atoi(p) >= regnpar) ) {
944 ender = scan_oct(p, 3, &numlen);
954 FAIL("trailing \\ in regexp");
961 case ' ': case '\t': case '\n': case '\r': case '\f': case '\v':
962 if (regflags & PMf_EXTENDED) {
972 if (regflags & PMf_FOLD && isUPPER(ender))
973 ender = toLOWER(ender);
974 if (ISMULT2(p)) { /* Back off on ?+*. */
989 FAIL("internal disaster in regexp");
994 if (regcode != ®dummy)
1010 if (regcode == ®dummy)
1014 bits[c >> 3] &= ~(1 << (c & 7));
1016 bits[c >> 3] |= (1 << (c & 7));
1022 register char *bits;
1024 register I32 lastclass = 1234;
1025 register I32 range = 0;
1030 ret = regnode(ANYOF);
1031 if (*regparse == '^') { /* Complement of range. */
1039 for (class = 0; class < 32; class++)
1041 if (*regparse == ']' || *regparse == '-')
1042 goto skipcond; /* allow 1st char to be ] or - */
1043 while (regparse < regxend && *regparse != ']') {
1045 class = UCHARAT(regparse++);
1046 if (class == '\\') {
1047 class = UCHARAT(regparse++);
1050 for (class = 0; class < 256; class++)
1052 regset(bits,def,class);
1056 for (class = 0; class < 256; class++)
1057 if (!isALNUM(class))
1058 regset(bits,def,class);
1062 for (class = 0; class < 256; class++)
1064 regset(bits,def,class);
1068 for (class = 0; class < 256; class++)
1069 if (!isSPACE(class))
1070 regset(bits,def,class);
1074 for (class = '0'; class <= '9'; class++)
1075 regset(bits,def,class);
1079 for (class = 0; class < '0'; class++)
1080 regset(bits,def,class);
1081 for (class = '9' + 1; class < 256; class++)
1082 regset(bits,def,class);
1107 class = scan_hex(regparse, 2, &numlen);
1111 class = *regparse++;
1113 class = toUPPER(class);
1116 case '0': case '1': case '2': case '3': case '4':
1117 case '5': case '6': case '7': case '8': case '9':
1118 class = scan_oct(--regparse, 3, &numlen);
1124 if (lastclass > class)
1125 FAIL("invalid [] range in regexp");
1130 if (*regparse == '-' && regparse+1 < regxend &&
1131 regparse[1] != ']') {
1134 continue; /* do it next time */
1137 for ( ; lastclass <= class; lastclass++) {
1138 regset(bits,def,lastclass);
1139 if (regflags & PMf_FOLD && isUPPER(lastclass))
1140 regset(bits,def,toLOWER(lastclass));
1144 if (*regparse != ']')
1145 FAIL("unmatched [] in regexp");
1153 char* retval = regparse++;
1155 if (regflags & PMf_EXTENDED) {
1156 while (isSPACE(*regparse))
1163 - regnode - emit a node
1165 #ifdef CAN_PROTOTYPE
1166 static char * /* Location. */
1169 static char * /* Location. */
1178 if (ret == ®dummy) {
1189 if (!((long)ret & 1))
1195 *ptr++ = '\0'; /* Null "next" pointer. */
1203 - reganode - emit a node with an argument
1205 #ifdef CAN_PROTOTYPE
1206 static char * /* Location. */
1207 reganode(char op, unsigned short arg)
1209 static char * /* Location. */
1219 if (ret == ®dummy) {
1230 if (!((long)ret & 1))
1236 *ptr++ = '\0'; /* Null "next" pointer. */
1239 *(unsigned short *)(ret+3) = arg;
1241 ret[3] = arg >> 8; ret[4] = arg & 0377;
1250 - regc - emit (if appropriate) a byte of code
1252 #ifdef CAN_PROTOTYPE
1261 if (regcode != ®dummy)
1268 - reginsert - insert an operator in front of already-emitted operand
1270 * Means relocating the operand.
1272 #ifdef CAN_PROTOTYPE
1274 reginsert(char op, char *opnd)
1284 register char *place;
1285 register int offset = (regkind[(U8)op] == CURLY ? 4 : 0);
1287 if (regcode == ®dummy) {
1289 regsize += 4 + offset;
1291 regsize += 3 + offset;
1298 regcode += 4 + offset;
1300 regcode += 3 + offset;
1306 place = opnd; /* Op node, where operand used to be. */
1310 while (offset-- > 0)
1318 - regtail - set the next-pointer at the end of a node chain
1325 register char *scan;
1326 register char *temp;
1327 register I32 offset;
1332 /* Find last node. */
1335 temp = regnext(scan);
1342 offset = val - scan;
1344 *(short*)(scan+1) = offset;
1349 if (OP(scan) == BACK)
1350 offset = scan - val;
1352 offset = val - scan;
1353 *(scan+1) = (offset>>8)&0377;
1354 *(scan+2) = offset&0377;
1359 - regoptail - regtail on operand of first argument; nop if operandless
1366 /* "Operandless" and "op != BRANCH" are synonymous in practice. */
1367 if (p == NULL || p == ®dummy || regkind[(U8)OP(p)] != BRANCH)
1369 regtail(NEXTOPER(p), val);
1373 - regcurly - a little FSA that accepts {\d+,?\d*}
1397 - regdump - dump a regexp onto stderr in vaguely comprehensible form
1404 register char op = EXACTLY; /* Arbitrary non-END op. */
1405 register char *next;
1409 while (op != END) { /* While that wasn't END last time... */
1415 fprintf(stderr,"%2d%s", s-r->program, regprop(s)); /* Where, what. */
1417 s += regarglen[(U8)op];
1418 if (next == NULL) /* Next ptr. */
1419 fprintf(stderr,"(0)");
1421 fprintf(stderr,"(%d)", (s-r->program)+(next-s));
1426 if (op == EXACTLY) {
1427 /* Literal string, where present. */
1429 (void)putc(' ', stderr);
1430 (void)putc('<', stderr);
1431 while (*s != '\0') {
1432 (void)putc(*s, stderr);
1435 (void)putc('>', stderr);
1438 (void)putc('\n', stderr);
1441 /* Header fields of interest. */
1443 fprintf(stderr,"start `%s' ", SvPVX(r->regstart));
1445 fprintf(stderr,"stclass `%s' ", regprop(r->regstclass));
1446 if (r->reganch & ROPT_ANCH)
1447 fprintf(stderr,"anchored ");
1448 if (r->reganch & ROPT_SKIP)
1449 fprintf(stderr,"plus ");
1450 if (r->reganch & ROPT_IMPLICIT)
1451 fprintf(stderr,"implicit ");
1452 if (r->regmust != NULL)
1453 fprintf(stderr,"must have \"%s\" back %ld ", SvPVX(r->regmust),
1455 fprintf(stderr, "minlen %ld ", (long) r->minlen);
1456 fprintf(stderr,"\n");
1460 - regprop - printable representation of opcode
1466 register char *p = 0;
1468 (void) strcpy(buf, ":");
1538 (void)sprintf(buf+strlen(buf), "CURLY {%d,%d}", ARG1(op),ARG2(op));
1542 (void)sprintf(buf+strlen(buf), "CURLYX {%d,%d}", ARG1(op),ARG2(op));
1546 (void)sprintf(buf+strlen(buf), "REF%d", ARG1(op));
1550 (void)sprintf(buf+strlen(buf), "OPEN%d", ARG1(op));
1554 (void)sprintf(buf+strlen(buf), "CLOSE%d", ARG1(op));
1582 FAIL("corrupted regexp opcode");
1585 (void) strcat(buf, p);
1588 #endif /* DEBUGGING */
1597 Safefree(r->precomp);
1598 r->precomp = Nullch;
1601 Safefree(r->subbase);
1602 r->subbase = Nullch;
1605 SvREFCNT_dec(r->regmust);
1606 r->regmust = Nullsv;
1609 SvREFCNT_dec(r->regstart);
1610 r->regstart = Nullsv;
1612 Safefree(r->startp);