Add -DMULTIARCH (see change #3006).
[p5sagit/p5-mst-13.2.git] / regcomp.c
index 2d5f813..5d4c0f0 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -147,6 +147,7 @@ static char* regwhite _((char *, char *));
 static char* nextchar _((void));
 static void re_croak2 _((const char* pat1,const char* pat2,...)) __attribute__((noreturn));
 static char* regpposixcc _((I32 value));
+static void clear_re _((void *r));
 #endif
 
 /* Length of a variant. */
@@ -207,6 +208,12 @@ static scan_data_t zero_scan_data = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
 #define CHR_DIST(a,b) (UTF ? utf8_distance(a,b) : a - b)
 
 STATIC void
+clear_re(void *r)
+{
+    ReREFCNT_dec((regexp *)r);
+}
+
+STATIC void
 scan_commit(scan_data_t *data)
 {
     dTHR;
@@ -868,7 +875,12 @@ pregcomp(char *exp, char *xend, PMOP *pm)
     r->prelen = xend - exp;
     r->precomp = PL_regprecomp;
     r->subbeg = r->subbase = NULL;
-    r->nparens = PL_regnpar - 1;               /* set early to validate backrefs */
+    r->nparens = PL_regnpar - 1;       /* set early to validate backrefs */
+
+    r->substrs = 0;                    /* Useful during FAIL. */
+    r->startp = 0;                     /* Useful during FAIL. */
+    r->endp = 0;                       /* Useful during FAIL. */
+
     PL_regcomp_rx = r;
 
     /* Second pass: emit code. */
@@ -1378,8 +1390,11 @@ reg(I32 paren, I32 *flagp)
     }
 
     /* Check for proper termination. */
-    if (paren && (PL_regcomp_parse >= PL_regxend || *nextchar() != ')')) {
-       FAIL("unmatched () in regexp");
+    if (paren) {
+       PL_regflags = oregflags;
+       if (PL_regcomp_parse >= PL_regxend || *nextchar() != ')') {
+           FAIL("unmatched () in regexp");
+       }
     }
     else if (!paren && PL_regcomp_parse < PL_regxend) {
        if (*PL_regcomp_parse == ')') {
@@ -1389,9 +1404,6 @@ reg(I32 paren, I32 *flagp)
            FAIL("junk on end of regexp");      /* "Can't happen". */
        /* NOTREACHED */
     }
-    if (paren != 0) {
-       PL_regflags = oregflags;
-    }
 
     return(ret);
 }