X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=regcomp.c;h=f9e253926b4482a2611b9357de3e3f1dfdb4a321;hb=baed7233d4dfe516b6be04fb05fade5080a282e0;hp=adda2aa8f9bfb7914ddf3bd6b9d5dad30c117947;hpb=161b471ac314d8d6343f9f351e5fb9ef816168a8;p=p5sagit%2Fp5-mst-13.2.git diff --git a/regcomp.c b/regcomp.c index adda2aa..f9e2539 100644 --- a/regcomp.c +++ b/regcomp.c @@ -19,6 +19,16 @@ * with the POSIX routines of the same names. */ +#ifdef IN_XSUB_RE +/* We *really* need to overwrite these symbols: */ +# define Perl_pregcomp my_regcomp +# define Perl_regdump my_regdump +# define Perl_regprop my_regprop +/* *These* symbols are masked to allow static link. */ +# define Perl_pregfree my_regfree +# define Perl_regnext my_regnext +#endif + /*SUPPRESS 112*/ /* * pregcomp and pregexec -- regsub and regerror are not used in perl @@ -55,28 +65,17 @@ */ #include "EXTERN.h" #include "perl.h" -#include "INTERN.h" + +#ifndef IN_XSUB_RE +# include "INTERN.h" +#endif #define REG_COMP_C #include "regcomp.h" -#ifdef USE_THREADS +#ifdef op #undef op -#endif /* USE_THREADS */ - -static regnode regdummy; -static char * regparse; /* Input-scan pointer. */ -static char * regxend; /* End of input for compile */ -static regnode * regcode; /* Code-emit pointer; ®dummy = don't. */ -static I32 regnaughty; /* How bad is this pattern? */ -static I32 regsawback; /* Did we see \1, ...? */ - -/* This guys appear both in regcomp.c and regexec.c, but there is no - other reason to have them global. */ -static char * regprecomp; /* uncompiled string. */ -static I32 regnpar; /* () count. */ -static I32 regsize; /* Code size. */ -static U16 regflags; /* are we folding, multilining? */ +#endif /* op */ #ifdef MSDOS # if defined(BUGGY_MSC6) @@ -107,7 +106,7 @@ static U16 regflags; /* are we folding, multilining? */ * Flags to be passed up and down. */ #define WORST 0 /* Worst case. */ -#define HASWIDTH 0x1 /* Known never to match null string. */ +#define HASWIDTH 0x1 /* Known to match non-null strings. */ #define SIMPLE 0x2 /* Simple enough to be STAR/PLUS operand. */ #define SPSTART 0x4 /* Starts with * or +. */ #define TRYAGAIN 0x8 /* Weeded out a declaration. */ @@ -116,6 +115,7 @@ static U16 regflags; /* are we folding, multilining? */ * Forward declarations for pregcomp()'s friends. */ +#ifndef PERL_OBJECT static regnode *reg _((I32, I32 *)); static regnode *reganode _((U8, U32)); static regnode *regatom _((I32 *)); @@ -127,23 +127,15 @@ static regnode *reg_node _((U8)); static regnode *regpiece _((I32 *)); static void reginsert _((U8, regnode *)); static void regoptail _((regnode *, regnode *)); -static void regset _((char *, I32)); static void regtail _((regnode *, regnode *)); static char* regwhite _((char *, char *)); static char* nextchar _((void)); - -static U32 regseen; -static I32 seen_zerolen; -static regexp *rx; -static I32 extralen; - -#ifdef DEBUGGING -static int colorset; -char *colors[4]; -#endif +static void re_croak2 _((const char* pat1,const char* pat2,...)) __attribute__((noreturn)); +#endif /* Length of a variant. */ +#ifndef PERL_OBJECT typedef struct { I32 len_min; I32 len_delta; @@ -161,6 +153,7 @@ typedef struct { I32 offset_float_max; I32 flags; } scan_data_t; +#endif static scan_data_t zero_scan_data = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; @@ -170,8 +163,13 @@ static scan_data_t zero_scan_data = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; #define SF_FIX_BEFORE_EOL (SF_FIX_BEFORE_SEOL|SF_FIX_BEFORE_MEOL) #define SF_FL_BEFORE_EOL (SF_FL_BEFORE_SEOL|SF_FL_BEFORE_MEOL) -#define SF_FIX_SHIFT_EOL (+2) -#define SF_FL_SHIFT_EOL (+4) +#ifdef NO_UNARY_PLUS +# define SF_FIX_SHIFT_EOL (0+2) +# define SF_FL_SHIFT_EOL (0+4) +#else +# define SF_FIX_SHIFT_EOL (+2) +# define SF_FL_SHIFT_EOL (+4) +#endif #define SF_FIX_BEFORE_SEOL (SF_BEFORE_SEOL << SF_FIX_SHIFT_EOL) #define SF_FIX_BEFORE_MEOL (SF_BEFORE_MEOL << SF_FIX_SHIFT_EOL) @@ -182,8 +180,9 @@ static scan_data_t zero_scan_data = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; #define SF_HAS_PAR 0x80 #define SF_IN_PAR 0x100 #define SF_HAS_EVAL 0x200 +#define SCF_DO_SUBSTR 0x400 -static void +STATIC void scan_commit(scan_data_t *data) { STRLEN l = SvCUR(data->last_found); @@ -215,12 +214,10 @@ scan_commit(scan_data_t *data) data->flags &= ~SF_BEFORE_EOL; } -#define SCF_DO_SUBSTR 1 - /* Stops at toplevel WHILEM as well as at `last'. At end *scanp is set to the position after last scanned or to NULL. */ -static I32 +STATIC I32 study_chunk(regnode **scanp, I32 *deltap, regnode *last, scan_data_t *data, U32 flags) /* scanp: Start here (read-write). */ /* deltap: Write maxlen-minlen here. */ @@ -283,6 +280,10 @@ study_chunk(regnode **scanp, I32 *deltap, regnode *last, scan_data_t *data, U32 /* Allow dumping */ n = scan + (*OPERAND(scan) + 2 - 1)/sizeof(regnode) + 2; while (n <= stop) { + /* Purify reports a benign UMR here sometimes, because we + * don't initialize the OP() slot of a node when that node + * is occupied by just the trailing null of the string in + * an EXACT node */ if (regkind[(U8)OP(n)] != NOTHING || OP(n) == NOTHING) { OP(n) = OPTIMIZED; NEXT_OFF(n) = 0; @@ -340,7 +341,7 @@ study_chunk(regnode **scanp, I32 *deltap, regnode *last, scan_data_t *data, U32 scan = next; if (data_fake.flags & (SF_HAS_PAR|SF_IN_PAR)) pars++; - if (data_fake.flags & SF_HAS_EVAL) + if (data && (data_fake.flags & SF_HAS_EVAL)) data->flags |= SF_HAS_EVAL; if (code == SUSPEND) break; @@ -437,7 +438,8 @@ study_chunk(regnode **scanp, I32 *deltap, regnode *last, scan_data_t *data, U32 if (!scan) /* It was not CURLYX, but CURLY. */ scan = next; if (dowarn && (minnext + deltanext == 0) - && !(data->flags & (SF_HAS_PAR|SF_IN_PAR))) + && !(data->flags & (SF_HAS_PAR|SF_IN_PAR)) + && maxcount <= 10000) /* Complement check for big count */ warn("Strange *+?{} on zero-length expression"); min += minnext * mincount; is_inf |= (maxcount == REG_INFTY && (minnext + deltanext) > 0 @@ -445,7 +447,6 @@ study_chunk(regnode **scanp, I32 *deltap, regnode *last, scan_data_t *data, U32 delta += (minnext + deltanext) * maxcount - minnext * mincount; /* Try powerful optimization CURLYX => CURLYN. */ -#ifdef REGALIGN_STRUCT if ( OP(oscan) == CURLYX && data && data->flags & SF_IN_PAR && !(data->flags & SF_HAS_EVAL) @@ -477,16 +478,11 @@ study_chunk(regnode **scanp, I32 *deltap, regnode *last, scan_data_t *data, U32 NEXT_OFF(nxt+ 1) = 0; /* just for consistancy. */ #endif } -#endif nogo: /* Try optimization CURLYX => CURLYM. */ if ( OP(oscan) == CURLYX && data -#ifdef REGALIGN_STRUCT && !(data->flags & SF_HAS_PAR) -#else - && !(data->flags & (SF_HAS_PAR|SF_IN_PAR)) -#endif && !(data->flags & SF_HAS_EVAL) && !deltanext ) { /* XXXX How to optimize if data == 0? */ @@ -499,7 +495,6 @@ study_chunk(regnode **scanp, I32 *deltap, regnode *last, scan_data_t *data, U32 && (OP(nxt2) != WHILEM)) nxt = nxt2; OP(nxt2) = SUCCEED; /* Whas WHILEM */ -#ifdef REGALIGN_STRUCT /* Need to optimize away parenths. */ if (data->flags & SF_IN_PAR) { /* Set the parenth number. */ @@ -535,7 +530,6 @@ study_chunk(regnode **scanp, I32 *deltap, regnode *last, scan_data_t *data, U32 study_chunk(&nxt1, &deltanext, nxt, NULL, 0); } else oscan->flags = 0; -#endif } if (data && fl & (SF_HAS_PAR|SF_IN_PAR)) pars++; @@ -586,16 +580,14 @@ study_chunk(regnode **scanp, I32 *deltap, regnode *last, scan_data_t *data, U32 data->longest = &(data->longest_float); } } - if (fl & SF_HAS_EVAL) + if (data && (fl & SF_HAS_EVAL)) data->flags |= SF_HAS_EVAL; optimize_curly_tail: -#ifdef REGALIGN if (OP(oscan) != CURLYX) { while (regkind[(U8)OP(next = regnext(oscan))] == NOTHING && NEXT_OFF(next)) NEXT_OFF(oscan) += NEXT_OFF(next); } -#endif continue; default: /* REF only? */ if (flags & SCF_DO_SUBSTR) { @@ -635,16 +627,14 @@ study_chunk(regnode **scanp, I32 *deltap, regnode *last, scan_data_t *data, U32 } if (data && data_fake.flags & (SF_HAS_PAR|SF_IN_PAR)) pars++; - if (data_fake.flags & SF_HAS_EVAL) + if (data && (data_fake.flags & SF_HAS_EVAL)) data->flags |= SF_HAS_EVAL; } else if (OP(scan) == OPEN) { pars++; } else if (OP(scan) == CLOSE && ARG(scan) == is_par) { -#ifdef REGALIGN_STRUCT next = regnext(scan); if ( next && (OP(next) != WHILEM) && next < last) -#endif is_par = 0; /* Disable optimization */ } else if (OP(scan) == EVAL) { if (data) @@ -671,23 +661,23 @@ study_chunk(regnode **scanp, I32 *deltap, regnode *last, scan_data_t *data, U32 return min; } -static I32 +STATIC I32 add_data(I32 n, char *s) { - if (rx->data) { - Renewc(rx->data, - sizeof(*rx->data) + sizeof(void*) * (rx->data->count + n - 1), + if (regcomp_rx->data) { + Renewc(regcomp_rx->data, + sizeof(*regcomp_rx->data) + sizeof(void*) * (regcomp_rx->data->count + n - 1), char, struct reg_data); - Renew(rx->data->what, rx->data->count + n, U8); - rx->data->count += n; + Renew(regcomp_rx->data->what, regcomp_rx->data->count + n, U8); + regcomp_rx->data->count += n; } else { - Newc(1207, rx->data, sizeof(*rx->data) + sizeof(void*) * (n - 1), + Newc(1207, regcomp_rx->data, sizeof(*regcomp_rx->data) + sizeof(void*) * (n - 1), char, struct reg_data); - New(1208, rx->data->what, n, U8); - rx->data->count = n; + New(1208, regcomp_rx->data->what, n, U8); + regcomp_rx->data->count = n; } - Copy(s, rx->data->what + rx->data->count - n, n, U8); - return rx->data->count - n; + Copy(s, regcomp_rx->data->what + regcomp_rx->data->count - n, n, U8); + return regcomp_rx->data->count - n; } /* @@ -733,7 +723,7 @@ pregcomp(char *exp, char *xend, PMOP *pm) extralen = 0; /* First pass: determine size, legality. */ - regparse = exp; + regcomp_parse = exp; regxend = xend; regnaughty = 0; regnpar = 1; @@ -750,7 +740,7 @@ pregcomp(char *exp, char *xend, PMOP *pm) DEBUG_r( if (!colorset) { int i = 0; - char *s = getenv("TERMCAP_COLORS"); + char *s = PerlEnv_getenv("TERMCAP_COLORS"); colorset = 1; if (s) { @@ -774,15 +764,10 @@ pregcomp(char *exp, char *xend, PMOP *pm) /* Small enough for pointer-storage convention? If extralen==0, this means that we will not need long jumps. */ -#ifndef REGALIGN_STRUCT - if (regsize >= 0x10000L && extralen) - FAIL("regexp too big"); -#else if (regsize >= 0x10000L && extralen) regsize += extralen; else extralen = 0; -#endif /* Allocate space and initialize. */ Newc(1001, r, sizeof(regexp) + (unsigned)regsize * sizeof(regnode), @@ -793,10 +778,11 @@ pregcomp(char *exp, char *xend, PMOP *pm) r->prelen = xend - exp; r->precomp = regprecomp; r->subbeg = r->subbase = NULL; - rx = r; + r->nparens = regnpar - 1; /* set early to validate backrefs */ + regcomp_rx = r; /* Second pass: emit code. */ - regparse = exp; + regcomp_parse = exp; regxend = xend; regnaughty = 0; regnpar = 1; @@ -812,6 +798,11 @@ pregcomp(char *exp, char *xend, PMOP *pm) r->regstclass = NULL; r->naughty = regnaughty >= 10; /* Probably an expensive pattern. */ scan = r->program + 1; /* First BRANCH. */ + + /* XXXX To minimize changes to RE engine we always allocate + 3-units-long substrs field. */ + Newz(1004, r->substrs, 1, struct reg_substr_data); + if (OP(scan) != BRANCH) { /* Only one top-level choice. */ scan_data_t data; I32 fake; @@ -906,7 +897,7 @@ pregcomp(char *exp, char *xend, PMOP *pm) r->float_substr = data.longest_float; r->float_min_offset = data.offset_float_min; r->float_max_offset = data.offset_float_max; - fbm_compile(r->float_substr); + fbm_compile(r->float_substr, 0); BmUSEFUL(r->float_substr) = 100; if (data.flags & SF_FL_BEFORE_EOL /* Cannot have SEOL and MULTI */ && (!(data.flags & SF_FL_BEFORE_MEOL) @@ -926,7 +917,7 @@ pregcomp(char *exp, char *xend, PMOP *pm) || (regflags & PMf_MULTILINE)))) { r->anchored_substr = data.longest_fixed; r->anchored_offset = data.offset_fixed; - fbm_compile(r->anchored_substr); + fbm_compile(r->anchored_substr, 0); BmUSEFUL(r->anchored_substr) = 100; if (data.flags & SF_FIX_BEFORE_EOL /* Cannot have SEOL and MULTI */ && (!(data.flags & SF_FIX_BEFORE_MEOL) @@ -959,12 +950,13 @@ pregcomp(char *exp, char *xend, PMOP *pm) r->check_substr = r->anchored_substr = r->float_substr = Nullsv; } - r->nparens = regnpar - 1; r->minlen = minlen; if (regseen & REG_SEEN_GPOS) r->reganch |= ROPT_GPOS_SEEN; if (regseen & REG_SEEN_LOOKBEHIND) r->reganch |= ROPT_LOOKBEHIND_SEEN; + if (regseen & REG_SEEN_EVAL) + r->reganch |= ROPT_EVAL_SEEN; Newz(1002, r->startp, regnpar, char*); Newz(1002, r->endp, regnpar, char*); DEBUG_r(regdump(r)); @@ -980,7 +972,7 @@ pregcomp(char *exp, char *xend, PMOP *pm) * is a trifle forced, but the need to tie the tails of the branches to what * follows makes it hard to avoid. */ -static regnode * +STATIC regnode * reg(I32 paren, I32 *flagp) /* paren: Parenthesized? 0=top, 1=(, inside: changed to letter. */ { @@ -992,25 +984,25 @@ reg(I32 paren, I32 *flagp) I32 flags, oregflags = regflags, have_branch = 0, open = 0; char c; - *flagp = HASWIDTH; /* Tentatively. */ + *flagp = 0; /* Tentatively. */ /* Make an OPEN node, if parenthesized. */ if (paren) { - if (*regparse == '?') { - regparse++; - paren = *regparse++; + if (*regcomp_parse == '?') { + U16 posflags = 0, negflags = 0; + U16 *flagsp = &posflags; + + regcomp_parse++; + paren = *regcomp_parse++; ret = NULL; /* For look-ahead/behind. */ switch (paren) { case '<': -#ifndef REGALIGN_STRUCT - FAIL("lookbehind non-implemented without REGALIGN_STRUCT"); -#endif regseen |= REG_SEEN_LOOKBEHIND; - if (*regparse == '!') + if (*regcomp_parse == '!') paren = ','; - if (*regparse != '=' && *regparse != '!') + if (*regcomp_parse != '=' && *regcomp_parse != '!') goto unknown; - regparse++; + regcomp_parse++; case '=': case '!': seen_zerolen++; @@ -1022,9 +1014,9 @@ reg(I32 paren, I32 *flagp) FAIL2("Sequence (?%c...) not implemented", (int)paren); break; case '#': - while (*regparse && *regparse != ')') - regparse++; - if (*regparse != ')') + while (*regcomp_parse && *regcomp_parse != ')') + regcomp_parse++; + if (*regcomp_parse != ')') FAIL("Sequence (?#... not terminated"); nextchar(); *flagp = TRYAGAIN; @@ -1034,61 +1026,70 @@ reg(I32 paren, I32 *flagp) dTHR; I32 count = 1, n = 0; char c; - char *s = regparse; + char *s = regcomp_parse; SV *sv; OP_4tree *sop, *rop; seen_zerolen++; - while (count && (c = *regparse)) { - if (c == '\\' && regparse[1]) - regparse++; + regseen |= REG_SEEN_EVAL; + while (count && (c = *regcomp_parse)) { + if (c == '\\' && regcomp_parse[1]) + regcomp_parse++; else if (c == '{') count++; else if (c == '}') count--; - regparse++; + regcomp_parse++; } - if (*regparse != ')') + if (*regcomp_parse != ')') FAIL("Sequence (?{...}) not terminated or not {}-balanced"); if (!SIZE_ONLY) { AV *av; - if (regparse - 1 - s) - sv = newSVpv(s, regparse - 1 - s); + if (regcomp_parse - 1 - s) + sv = newSVpv(s, regcomp_parse - 1 - s); else sv = newSVpv("", 0); rop = sv_compile_2op(sv, &sop, "re", &av); n = add_data(3, "nso"); - rx->data->data[n] = (void*)rop; - rx->data->data[n+1] = (void*)av; - rx->data->data[n+2] = (void*)sop; + regcomp_rx->data->data[n] = (void*)rop; + regcomp_rx->data->data[n+1] = (void*)av; + regcomp_rx->data->data[n+2] = (void*)sop; SvREFCNT_dec(sv); + } else { /* First pass */ + if (curcop == &compiling) { + if (!(hints & HINT_RE_EVAL)) + FAIL("Eval-group not allowed, use re 'eval'"); + } + else { + FAIL("Eval-group not allowed at run time"); + } + if (tainted) + FAIL("Eval-group in insecure regular expression"); } nextchar(); - if (tainted) - FAIL("Eval-group in insecure regular expression"); return reganode(EVAL, n); } case '(': { - if (regparse[0] == '?') { - if (regparse[1] == '=' || regparse[1] == '!' - || regparse[1] == '<' - || regparse[1] == '{') { /* Lookahead or eval. */ + if (regcomp_parse[0] == '?') { + if (regcomp_parse[1] == '=' || regcomp_parse[1] == '!' + || regcomp_parse[1] == '<' + || regcomp_parse[1] == '{') { /* Lookahead or eval. */ I32 flag; ret = reg_node(LOGICAL); regtail(ret, reg(1, &flag)); goto insert_if; } - } else if (regparse[0] >= '1' && regparse[0] <= '9' ) { - parno = atoi(regparse++); + } else if (regcomp_parse[0] >= '1' && regcomp_parse[0] <= '9' ) { + parno = atoi(regcomp_parse++); - while (isDIGIT(*regparse)) - regparse++; + while (isDIGIT(*regcomp_parse)) + regcomp_parse++; ret = reganode(GROUPP, parno); if ((c = *nextchar()) != ')') FAIL2("Switch (?(number%c not recognized", c); @@ -1118,19 +1119,35 @@ reg(I32 paren, I32 *flagp) regtail(ret, ender); return ret; } else { - FAIL2("Unknown condition for (?(%.2s", regparse); + FAIL2("Unknown condition for (?(%.2s", regcomp_parse); } } case 0: FAIL("Sequence (? incomplete"); break; default: - --regparse; - while (*regparse && strchr("iogcmsx", *regparse)) - pmflag(®flags, *regparse++); + --regcomp_parse; + parse_flags: + while (*regcomp_parse && strchr("iogcmsx", *regcomp_parse)) { + if (*regcomp_parse != 'o') + pmflag(flagsp, *regcomp_parse); + ++regcomp_parse; + } + if (*regcomp_parse == '-') { + flagsp = &negflags; + ++regcomp_parse; + goto parse_flags; + } + regflags |= posflags; + regflags &= ~negflags; + if (*regcomp_parse == ':') { + regcomp_parse++; + paren = ':'; + break; + } unknown: - if (*regparse != ')') - FAIL2("Sequence (?%c...) not recognized", *regparse); + if (*regcomp_parse != ')') + FAIL2("Sequence (?%c...) not recognized", *regcomp_parse); nextchar(); *flagp = TRYAGAIN; return NULL; @@ -1149,7 +1166,7 @@ reg(I32 paren, I32 *flagp) br = regbranch(&flags, 1); if (br == NULL) return(NULL); - if (*regparse == '|') { + if (*regcomp_parse == '|') { if (!SIZE_ONLY && extralen) { reginsert(BRANCHJ, br); } else @@ -1164,11 +1181,11 @@ reg(I32 paren, I32 *flagp) regtail(ret, br); /* OPEN -> first. */ } else if (paren != '?') /* Not Conditional */ ret = br; - if (!(flags&HASWIDTH)) - *flagp &= ~HASWIDTH; + if (flags&HASWIDTH) + *flagp |= HASWIDTH; *flagp |= flags&SPSTART; lastbr = br; - while (*regparse == '|') { + while (*regcomp_parse == '|') { if (!SIZE_ONLY && extralen) { ender = reganode(LONGJMP,0); regtail(NEXTOPER(NEXTOPER(lastbr)), ender); /* Append to the previous. */ @@ -1181,8 +1198,8 @@ reg(I32 paren, I32 *flagp) return(NULL); regtail(lastbr, br); /* BRANCH -> BRANCH. */ lastbr = br; - if (!(flags&HASWIDTH)) - *flagp &= ~HASWIDTH; + if (flags&HASWIDTH) + *flagp |= HASWIDTH; *flagp |= flags&SPSTART; } @@ -1196,12 +1213,13 @@ reg(I32 paren, I32 *flagp) ender = reganode(CLOSE, parno); break; case '<': - case '>': case ',': case '=': case '!': - ender = reg_node(SUCCEED); *flagp &= ~HASWIDTH; + /* FALL THROUGH */ + case '>': + ender = reg_node(SUCCEED); break; case 0: ender = reg_node(END); @@ -1228,18 +1246,16 @@ reg(I32 paren, I32 *flagp) if (paren == '>') node = SUSPEND, flag = 0; reginsert(node,ret); -#ifdef REGALIGN_STRUCT ret->flags = flag; -#endif regtail(ret, reg_node(TAIL)); } } /* Check for proper termination. */ - if (paren && (regparse >= regxend || *nextchar() != ')')) { + if (paren && (regcomp_parse >= regxend || *nextchar() != ')')) { FAIL("unmatched () in regexp"); - } else if (!paren && regparse < regxend) { - if (*regparse == ')') { + } else if (!paren && regcomp_parse < regxend) { + if (*regcomp_parse == ')') { FAIL("unmatched () in regexp"); } else FAIL("junk on end of regexp"); /* "Can't happen". */ @@ -1257,7 +1273,7 @@ reg(I32 paren, I32 *flagp) * * Implements the concatenation operator. */ -static regnode * +STATIC regnode * regbranch(I32 *flagp, I32 first) { register regnode *ret; @@ -1279,9 +1295,9 @@ regbranch(I32 *flagp, I32 first) *flagp = WORST; /* Tentatively. */ - regparse--; + regcomp_parse--; nextchar(); - while (regparse < regxend && *regparse != '|' && *regparse != ')') { + while (regcomp_parse < regxend && *regcomp_parse != '|' && *regcomp_parse != ')') { flags &= ~TRYAGAIN; latest = regpiece(&flags); if (latest == NULL) { @@ -1321,14 +1337,14 @@ regbranch(I32 *flagp, I32 first) * It might seem that this node could be dispensed with entirely, but the * endmarker role is not redundant. */ -static regnode * +STATIC regnode * regpiece(I32 *flagp) { register regnode *ret; register char op; register char *next; I32 flags; - char *origparse = regparse; + char *origparse = regcomp_parse; char *maxpos; I32 min; I32 max = REG_INFTY; @@ -1340,10 +1356,10 @@ regpiece(I32 *flagp) return(NULL); } - op = *regparse; + op = *regcomp_parse; - if (op == '{' && regcurly(regparse)) { - next = regparse + 1; + if (op == '{' && regcurly(regcomp_parse)) { + next = regcomp_parse + 1; maxpos = Nullch; while (isDIGIT(*next) || *next == ',') { if (*next == ',') { @@ -1357,18 +1373,18 @@ regpiece(I32 *flagp) if (*next == '}') { /* got one */ if (!maxpos) maxpos = next; - regparse++; - min = atoi(regparse); + regcomp_parse++; + min = atoi(regcomp_parse); if (*maxpos == ',') maxpos++; else - maxpos = regparse; + maxpos = regcomp_parse; max = atoi(maxpos); if (!max && *maxpos != '0') max = REG_INFTY; /* meaning "infinity" */ else if (max >= REG_INFTY) FAIL2("Quantifier in {,} bigger than %d", REG_INFTY - 1); - regparse = next; + regcomp_parse = next; nextchar(); do_curly: @@ -1391,12 +1407,12 @@ regpiece(I32 *flagp) if (SIZE_ONLY) extralen += 3; } -#ifdef REGALIGN_STRUCT ret->flags = 0; -#endif if (min > 0) - *flagp = (WORST|HASWIDTH); + *flagp = WORST; + if (max > 0) + *flagp |= HASWIDTH; if (max && max < min) FAIL("Can't do {n,m} with n > m"); if (!SIZE_ONLY) { @@ -1420,13 +1436,11 @@ regpiece(I32 *flagp) nextchar(); - *flagp = (op != '+') ? (WORST|SPSTART) : (WORST|HASWIDTH); + *flagp = (op != '+') ? (WORST|SPSTART|HASWIDTH) : (WORST|HASWIDTH); if (op == '*' && (flags&SIMPLE)) { reginsert(STAR, ret); -#ifdef REGALIGN_STRUCT ret->flags = 0; -#endif regnaughty += 4; } else if (op == '*') { @@ -1434,9 +1448,7 @@ regpiece(I32 *flagp) goto do_curly; } else if (op == '+' && (flags&SIMPLE)) { reginsert(PLUS, ret); -#ifdef REGALIGN_STRUCT ret->flags = 0; -#endif regnaughty += 3; } else if (op == '+') { @@ -1449,19 +1461,15 @@ regpiece(I32 *flagp) nest_check: if (dowarn && !SIZE_ONLY && !(flags&HASWIDTH) && max > 10000) { warn("%.*s matches null string many times", - regparse - origparse, origparse); + regcomp_parse - origparse, origparse); } - if (*regparse == '?') { + if (*regcomp_parse == '?') { nextchar(); reginsert(MINMOD, ret); -#ifdef REGALIGN regtail(ret, ret + NODE_STEP_REGNODE); -#else - regtail(ret, ret + 3); -#endif } - if (ISMULT2(regparse)) + if (ISMULT2(regcomp_parse)) FAIL("nested *?+ in regexp"); return(ret); @@ -1477,7 +1485,7 @@ regpiece(I32 *flagp) * * [Yes, it is worth fixing, some scripts can run twice the speed.] */ -static regnode * +STATIC regnode * regatom(I32 *flagp) { register regnode *ret = 0; @@ -1486,7 +1494,7 @@ regatom(I32 *flagp) *flagp = WORST; /* Tentatively. */ tryagain: - switch (*regparse) { + switch (*regcomp_parse) { case '^': seen_zerolen++; nextchar(); @@ -1498,7 +1506,7 @@ tryagain: ret = reg_node(BOL); break; case '$': - if (regparse[1]) + if (regcomp_parse[1]) seen_zerolen++; nextchar(); if (regflags & PMf_MULTILINE) @@ -1518,7 +1526,7 @@ tryagain: *flagp |= HASWIDTH|SIMPLE; break; case '[': - regparse++; + regcomp_parse++; ret = regclass(); *flagp |= HASWIDTH|SIMPLE; break; @@ -1538,12 +1546,12 @@ tryagain: *flagp |= TRYAGAIN; return NULL; } - FAIL2("internal urp in regexp at /%s/", regparse); + FAIL2("internal urp in regexp at /%s/", regcomp_parse); /* Supposed to be caught earlier. */ break; case '{': - if (!regcurly(regparse)) { - regparse++; + if (!regcurly(regcomp_parse)) { + regcomp_parse++; goto defchar; } /* FALL THROUGH */ @@ -1553,7 +1561,7 @@ tryagain: FAIL("?+*{} follows nothing in regexp"); break; case '\\': - switch (*++regparse) { + switch (*++regcomp_parse) { case 'A': seen_zerolen++; ret = reg_node(SBOL); @@ -1571,6 +1579,12 @@ tryagain: *flagp |= SIMPLE; nextchar(); break; + case 'z': + ret = reg_node(EOS); + *flagp |= SIMPLE; + seen_zerolen++; /* Do not optimize RE away */ + nextchar(); + break; case 'w': ret = reg_node((regflags & PMf_LOCALE) ? ALNUML : ALNUM); *flagp |= HASWIDTH|SIMPLE; @@ -1626,25 +1640,27 @@ tryagain: case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { - I32 num = atoi(regparse); + I32 num = atoi(regcomp_parse); if (num > 9 && num >= regnpar) goto defchar; else { + if (!SIZE_ONLY && num > regcomp_rx->nparens) + FAIL("reference to nonexistent group"); regsawback = 1; ret = reganode((regflags & PMf_FOLD) ? ((regflags & PMf_LOCALE) ? REFFL : REFF) : REF, num); *flagp |= HASWIDTH; - while (isDIGIT(*regparse)) - regparse++; - regparse--; + while (isDIGIT(*regcomp_parse)) + regcomp_parse++; + regcomp_parse--; nextchar(); } } break; case '\0': - if (regparse >= regxend) + if (regcomp_parse >= regxend) FAIL("trailing \\ in regexp"); /* FALL THROUGH */ default: @@ -1654,8 +1670,8 @@ tryagain: case '#': if (regflags & PMf_EXTENDED) { - while (regparse < regxend && *regparse != '\n') regparse++; - if (regparse < regxend) + while (regcomp_parse < regxend && *regcomp_parse != '\n') regcomp_parse++; + if (regcomp_parse < regxend) goto tryagain; } /* FALL THROUGH */ @@ -1667,7 +1683,7 @@ tryagain: char *oldp, *s; I32 numlen; - regparse++; + regcomp_parse++; defchar: ret = reg_node((regflags & PMf_FOLD) @@ -1675,7 +1691,7 @@ tryagain: : EXACT); s = (char *) OPERAND(ret); regc(0, s++); /* save spot for len */ - for (len = 0, p = regparse - 1; + for (len = 0, p = regcomp_parse - 1; len < 127 && p < regxend; len++) { @@ -1697,6 +1713,7 @@ tryagain: case 'A': case 'G': case 'Z': + case 'z': case 'w': case 'W': case 'b': @@ -1779,7 +1796,7 @@ tryagain: regc(ender, s++); } loopdone: - regparse = p - 1; + regcomp_parse = p - 1; nextchar(); if (len < 0) FAIL("internal disaster in regexp"); @@ -1791,9 +1808,7 @@ tryagain: *OPERAND(ret) = len; regc('\0', s++); if (SIZE_ONLY) { -#ifdef REGALIGN_STRUCT regsize += (len + 2 + sizeof(regnode) - 1) / sizeof(regnode); -#endif } else { regcode += (len + 2 + sizeof(regnode) - 1) / sizeof(regnode); } @@ -1804,7 +1819,7 @@ tryagain: return(ret); } -static char * +STATIC char * regwhite(char *p, char *e) { while (p < e) { @@ -1821,16 +1836,7 @@ regwhite(char *p, char *e) return p; } -static void -regset(char *opnd, register I32 c) -{ - if (SIZE_ONLY) - return; - c &= 0xFF; - opnd[1 + (c >> 3)] |= (1 << (c & 7)); -} - -static regnode * +STATIC regnode * regclass(void) { register char *opnd, *s; @@ -1845,9 +1851,9 @@ regclass(void) ret = reg_node(ANYOF); for (Class = 0; Class < 33; Class++) regc(0, s++); - if (*regparse == '^') { /* Complement of range. */ + if (*regcomp_parse == '^') { /* Complement of range. */ regnaughty++; - regparse++; + regcomp_parse++; if (!SIZE_ONLY) *opnd |= ANYOF_INVERT; } @@ -1860,72 +1866,100 @@ regclass(void) } else { regsize += ANY_SKIP; } - if (*regparse == ']' || *regparse == '-') + if (*regcomp_parse == ']' || *regcomp_parse == '-') goto skipcond; /* allow 1st char to be ] or - */ - while (regparse < regxend && *regparse != ']') { + while (regcomp_parse < regxend && *regcomp_parse != ']') { skipcond: - Class = UCHARAT(regparse++); + Class = UCHARAT(regcomp_parse++); + if (Class == '[' && regcomp_parse + 1 < regxend && + /* I smell either [: or [= or [. -- POSIX has been here, right? */ + (*regcomp_parse == ':' || *regcomp_parse == '=' || *regcomp_parse == '.')) { + char posixccc = *regcomp_parse; + char* posixccs = regcomp_parse++; + + while (regcomp_parse < regxend && *regcomp_parse != posixccc) + regcomp_parse++; + if (regcomp_parse == regxend) + /* Grandfather lone [:, [=, [. */ + regcomp_parse = posixccs; + else { + regcomp_parse++; /* skip over the posixccc */ + if (*regcomp_parse == ']') { + /* Not Implemented Yet. + * (POSIX Extended Character Classes, that is) + * The text between e.g. [: and :] would start + * at posixccs + 1 and stop at regcomp_parse - 2. */ + if (dowarn && !SIZE_ONLY) + warn("Character class syntax [%c %c] is reserved for future extensions", posixccc, posixccc); + regcomp_parse++; /* skip over the ending ] */ + } + } + } if (Class == '\\') { - Class = UCHARAT(regparse++); + Class = UCHARAT(regcomp_parse++); switch (Class) { case 'w': - if (regflags & PMf_LOCALE) { - if (!SIZE_ONLY) + if (!SIZE_ONLY) { + if (regflags & PMf_LOCALE) *opnd |= ANYOF_ALNUML; - } - else { - for (Class = 0; Class < 256; Class++) - if (isALNUM(Class)) - regset(opnd, Class); + else { + for (Class = 0; Class < 256; Class++) + if (isALNUM(Class)) + ANYOF_SET(opnd, Class); + } } lastclass = 1234; continue; case 'W': - if (regflags & PMf_LOCALE) { - if (!SIZE_ONLY) + if (!SIZE_ONLY) { + if (regflags & PMf_LOCALE) *opnd |= ANYOF_NALNUML; - } - else { - for (Class = 0; Class < 256; Class++) - if (!isALNUM(Class)) - regset(opnd, Class); + else { + for (Class = 0; Class < 256; Class++) + if (!isALNUM(Class)) + ANYOF_SET(opnd, Class); + } } lastclass = 1234; continue; case 's': - if (regflags & PMf_LOCALE) { - if (!SIZE_ONLY) + if (!SIZE_ONLY) { + if (regflags & PMf_LOCALE) *opnd |= ANYOF_SPACEL; - } - else { - for (Class = 0; Class < 256; Class++) - if (isSPACE(Class)) - regset(opnd, Class); + else { + for (Class = 0; Class < 256; Class++) + if (isSPACE(Class)) + ANYOF_SET(opnd, Class); + } } lastclass = 1234; continue; case 'S': - if (regflags & PMf_LOCALE) { - if (!SIZE_ONLY) + if (!SIZE_ONLY) { + if (regflags & PMf_LOCALE) *opnd |= ANYOF_NSPACEL; - } - else { - for (Class = 0; Class < 256; Class++) - if (!isSPACE(Class)) - regset(opnd, Class); + else { + for (Class = 0; Class < 256; Class++) + if (!isSPACE(Class)) + ANYOF_SET(opnd, Class); + } } lastclass = 1234; continue; case 'd': - for (Class = '0'; Class <= '9'; Class++) - regset(opnd, Class); + if (!SIZE_ONLY) { + for (Class = '0'; Class <= '9'; Class++) + ANYOF_SET(opnd, Class); + } lastclass = 1234; continue; case 'D': - for (Class = 0; Class < '0'; Class++) - regset(opnd, Class); - for (Class = '9' + 1; Class < 256; Class++) - regset(opnd, Class); + if (!SIZE_ONLY) { + for (Class = 0; Class < '0'; Class++) + ANYOF_SET(opnd, Class); + for (Class = '9' + 1; Class < 256; Class++) + ANYOF_SET(opnd, Class); + } lastclass = 1234; continue; case 'n': @@ -1950,17 +1984,17 @@ regclass(void) Class = '\007'; break; case 'x': - Class = scan_hex(regparse, 2, &numlen); - regparse += numlen; + Class = scan_hex(regcomp_parse, 2, &numlen); + regcomp_parse += numlen; break; case 'c': - Class = UCHARAT(regparse++); + Class = UCHARAT(regcomp_parse++); Class = toCTRL(Class); break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': - Class = scan_oct(--regparse, 3, &numlen); - regparse += numlen; + Class = scan_oct(--regcomp_parse, 3, &numlen); + regcomp_parse += numlen; break; } } @@ -1971,45 +2005,63 @@ regclass(void) } else { lastclass = Class; - if (*regparse == '-' && regparse+1 < regxend && - regparse[1] != ']') { - regparse++; + if (*regcomp_parse == '-' && regcomp_parse+1 < regxend && + regcomp_parse[1] != ']') { + regcomp_parse++; range = 1; continue; /* do it next time */ } } - for ( ; lastclass <= Class; lastclass++) - regset(opnd, lastclass); + if (!SIZE_ONLY) { + for ( ; lastclass <= Class; lastclass++) + ANYOF_SET(opnd, lastclass); + } lastclass = Class; } - if (*regparse != ']') + if (*regcomp_parse != ']') FAIL("unmatched [] in regexp"); nextchar(); + /* optimize case-insensitive simple patterns (e.g. /[a-z]/i) */ + if (!SIZE_ONLY && (*opnd & (0xFF ^ ANYOF_INVERT)) == ANYOF_FOLD) { + for (Class = 0; Class < 256; ++Class) { + if (ANYOF_TEST(opnd, Class)) { + I32 cf = fold[Class]; + ANYOF_SET(opnd, cf); + } + } + *opnd &= ~ANYOF_FOLD; + } + /* optimize inverted simple patterns (e.g. [^a-z]) */ + if (!SIZE_ONLY && (*opnd & 0xFF) == ANYOF_INVERT) { + for (Class = 0; Class < 32; ++Class) + opnd[1 + Class] ^= 0xFF; + *opnd = 0; + } return ret; } -static char* +STATIC char* nextchar(void) { - char* retval = regparse++; + char* retval = regcomp_parse++; for (;;) { - if (*regparse == '(' && regparse[1] == '?' && - regparse[2] == '#') { - while (*regparse && *regparse != ')') - regparse++; - regparse++; + if (*regcomp_parse == '(' && regcomp_parse[1] == '?' && + regcomp_parse[2] == '#') { + while (*regcomp_parse && *regcomp_parse != ')') + regcomp_parse++; + regcomp_parse++; continue; } if (regflags & PMf_EXTENDED) { - if (isSPACE(*regparse)) { - regparse++; + if (isSPACE(*regcomp_parse)) { + regcomp_parse++; continue; } - else if (*regparse == '#') { - while (*regparse && *regparse != '\n') - regparse++; - regparse++; + else if (*regcomp_parse == '#') { + while (*regcomp_parse && *regcomp_parse != '\n') + regcomp_parse++; + regcomp_parse++; continue; } } @@ -2020,13 +2072,8 @@ nextchar(void) /* - reg_node - emit a node */ -static regnode * /* Location. */ -#ifdef CAN_PROTOTYPE +STATIC regnode * /* Location. */ reg_node(U8 op) -#else -reg_node(op) -U8 op; -#endif { register regnode *ret; register regnode *ptr; @@ -2034,11 +2081,7 @@ U8 op; ret = regcode; if (SIZE_ONLY) { SIZE_ALIGN(regsize); -#ifdef REGALIGN_STRUCT regsize += 1; -#else - regsize += 3; -#endif return(ret); } @@ -2053,14 +2096,8 @@ U8 op; /* - reganode - emit a node with an argument */ -static regnode * /* Location. */ -#ifdef CAN_PROTOTYPE +STATIC regnode * /* Location. */ reganode(U8 op, U32 arg) -#else -reganode(op, arg) -U8 op; -U32 arg; -#endif { register regnode *ret; register regnode *ptr; @@ -2068,11 +2105,7 @@ U32 arg; ret = regcode; if (SIZE_ONLY) { SIZE_ALIGN(regsize); -#ifdef REGALIGN regsize += 2; -#else - regsize += 5; -#endif return(ret); } @@ -2087,15 +2120,8 @@ U32 arg; /* - regc - emit (if appropriate) a byte of code */ -#ifdef CAN_PROTOTYPE -static void +STATIC void regc(U8 b, char* s) -#else -static void -regc(b, s) -U8 b; -char *s; -#endif { if (!SIZE_ONLY) *s = b; @@ -2106,15 +2132,8 @@ char *s; * * Means relocating the operand. */ -#ifdef CAN_PROTOTYPE -static void +STATIC void reginsert(U8 op, regnode *opnd) -#else -static void -reginsert(op, opnd) -U8 op; -regnode *opnd; -#endif { register regnode *src; register regnode *dst; @@ -2138,15 +2157,12 @@ regnode *opnd; src = NEXTOPER(place); FILL_ADVANCE_NODE(place, op); Zero(src, offset, regnode); -#if defined(REGALIGN) && !defined(REGALIGN_STRUCT) - src[offset + 1] = '\177'; -#endif } /* - regtail - set the next-pointer at the end of a node chain of p to val. */ -static void +STATIC void regtail(regnode *p, regnode *val) { register regnode *scan; @@ -2165,33 +2181,17 @@ regtail(regnode *p, regnode *val) scan = temp; } -#ifdef REGALIGN -# ifdef REGALIGN_STRUCT if (reg_off_by_arg[OP(scan)]) { ARG_SET(scan, val - scan); } else { NEXT_OFF(scan) = val - scan; } -# else - offset = val - scan; -# ifndef lint - *(short*)(scan+1) = offset; -# endif -#endif -#else - if (OP(scan) == BACK) - offset = scan - val; - else - offset = val - scan; - *(scan+1) = (offset>>8)&0377; - *(scan+2) = offset&0377; -#endif } /* - regoptail - regtail on operand of first argument; nop if operandless */ -static void +STATIC void regoptail(regnode *p, regnode *val) { /* "Operandless" and "op != BRANCH" are synonymous in practice. */ @@ -2226,11 +2226,11 @@ regcurly(register char *s) return TRUE; } -#ifdef DEBUGGING -static regnode * +STATIC regnode * dumpuntil(regnode *start, regnode *node, regnode *last, SV* sv, I32 l) { +#ifdef DEBUGGING register char op = EXACT; /* Arbitrary non-END op. */ register regnode *next, *onode; @@ -2287,6 +2287,7 @@ dumpuntil(regnode *start, regnode *node, regnode *last, SV* sv, I32 l) else if (op == WHILEM) l--; } +#endif /* DEBUGGING */ return node; } @@ -2296,6 +2297,7 @@ dumpuntil(regnode *start, regnode *node, regnode *last, SV* sv, I32 l) void regdump(regexp *r) { +#ifdef DEBUGGING SV *sv = sv_newmortal(); (void)dumpuntil(r->program, r->program + 1, NULL, sv, 0); @@ -2347,7 +2349,10 @@ regdump(regexp *r) if (r->reganch & ROPT_IMPLICIT) PerlIO_printf(Perl_debug_log, "implicit "); PerlIO_printf(Perl_debug_log, "minlen %ld ", (long) r->minlen); + if (r->reganch & ROPT_EVAL_SEEN) + PerlIO_printf(Perl_debug_log, "with eval "); PerlIO_printf(Perl_debug_log, "\n"); +#endif /* DEBUGGING */ } /* @@ -2356,6 +2361,7 @@ regdump(regexp *r) void regprop(SV *sv, regnode *o) { +#ifdef DEBUGGING register char *p = 0; sv_setpv(sv, ":"); @@ -2372,6 +2378,9 @@ regprop(SV *sv, regnode *o) case EOL: p = "EOL"; break; + case EOS: + p = "EOS"; + break; case MEOL: p = "MEOL"; break; @@ -2427,18 +2436,10 @@ regprop(SV *sv, regnode *o) sv_catpvf(sv, "CURLY {%d,%d}", ARG1(o), ARG2(o)); break; case CURLYM: -#ifdef REGALIGN_STRUCT sv_catpvf(sv, "CURLYM[%d] {%d,%d}", o->flags, ARG1(o), ARG2(o)); -#else - sv_catpvf(sv, "CURLYM {%d,%d}", ARG1(o), ARG2(o)); -#endif break; case CURLYN: -#ifdef REGALIGN_STRUCT sv_catpvf(sv, "CURLYN[%d] {%d,%d}", o->flags, ARG1(o), ARG2(o)); -#else - sv_catpvf(sv, "CURLYN {%d,%d}", ARG1(o), ARG2(o)); -#endif break; case CURLYX: sv_catpvf(sv, "CURLYX {%d,%d}", ARG1(o), ARG2(o)); @@ -2472,18 +2473,10 @@ regprop(SV *sv, regnode *o) p = "GPOS"; break; case UNLESSM: -#ifdef REGALIGN_STRUCT sv_catpvf(sv, "UNLESSM[-%d]", o->flags); -#else - p = "UNLESSM"; -#endif break; case IFMATCH: -#ifdef REGALIGN_STRUCT sv_catpvf(sv, "IFMATCH[-%d]", o->flags); -#else - p = "IFMATCH"; -#endif break; case SUCCEED: p = "SUCCEED"; @@ -2553,8 +2546,8 @@ regprop(SV *sv, regnode *o) } if (p) sv_catpv(sv, p); +#endif /* DEBUGGING */ } -#endif /* DEBUGGING */ void pregfree(struct regexp *r) @@ -2565,10 +2558,13 @@ pregfree(struct regexp *r) Safefree(r->precomp); if (r->subbase) Safefree(r->subbase); - if (r->anchored_substr) - SvREFCNT_dec(r->anchored_substr); - if (r->float_substr) - SvREFCNT_dec(r->float_substr); + if (r->substrs) { + if (r->anchored_substr) + SvREFCNT_dec(r->anchored_substr); + if (r->float_substr) + SvREFCNT_dec(r->float_substr); + Safefree(r->substrs); + } if (r->data) { int n = r->data->count; while (--n >= 0) { @@ -2611,27 +2607,11 @@ regnext(register regnode *p) if (offset == 0) return(NULL); -#ifdef REGALIGN return(p+offset); -#else - if (OP(p) == BACK) - return(p-offset); - else - return(p+offset); -#endif } -#ifdef I_STDARG -void +STATIC void re_croak2(const char* pat1,const char* pat2,...) -#else -/*VARARGS0*/ -void -re_croak2(const char* pat1,const char* pat2, va_alist) - const char* pat1; - const char* pat2; - va_dcl -#endif { va_list args; STRLEN l1 = strlen(pat1); @@ -2645,13 +2625,9 @@ re_croak2(const char* pat1,const char* pat2, va_alist) l2 = 510 - l1; Copy(pat1, buf, l1 , char); Copy(pat2, buf + l1, l2 , char); - buf[l1 + l2 + 1] = '\n'; - buf[l1 + l2 + 2] = '\0'; -#ifdef I_STDARG + buf[l1 + l2] = '\n'; + buf[l1 + l2 + 1] = '\0'; va_start(args, pat2); -#else - va_start(args); -#endif message = mess(buf, &args); va_end(args); l1 = strlen(message); @@ -2661,5 +2637,3 @@ re_croak2(const char* pat1,const char* pat2, va_alist) buf[l1] = '\0'; /* Overwrite \n */ croak("%s", buf); } - -