#define ck_subr CPerlObj::Perl_ck_subr
#define ck_svconst CPerlObj::Perl_ck_svconst
#define ck_trunc CPerlObj::Perl_ck_trunc
+#define clear_re CPerlObj::Perl_clear_re
#define condpair_magic CPerlObj::Perl_condpair_magic
#define convert CPerlObj::Perl_convert
#define croak CPerlObj::Perl_croak
add_data
re_croak2
regpposixcc
+ clear_re
regmatch
regrepeat
regrepeat_hard
#define ck_svconst pPerl->Perl_ck_svconst
#undef ck_trunc
#define ck_trunc pPerl->Perl_ck_trunc
+#undef clear_re
+#define clear_re pPerl->Perl_clear_re
#undef condpair_magic
#define condpair_magic pPerl->Perl_condpair_magic
#undef convert
I32 add_data _((I32 n, char *s));
void re_croak2 _((const char* pat1,const char* pat2,...)) __attribute__((noreturn));
char* regpposixcc _((I32 value));
+void clear_re _((void *r));
I32 regmatch _((regnode *prog));
I32 regrepeat _((regnode *p, I32 max));
I32 regrepeat_hard _((regnode *p, I32 max, I32 *lp));
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. */
#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;
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. */
#define FAIL(m) \
STMT_START { \
- /*if (!SIZE_ONLY) \
- ReREFCNT_dec(PL_regcomp_rx);*/ \
+ if (!SIZE_ONLY) \
+ SAVEDESTRUCTOR(clear_re,(void*)PL_regcomp_rx); \
croak ("/%.127s/: %s", PL_regprecomp,m); \
} STMT_END
#define FAIL2(pat,m) \
STMT_START { \
- /*if (!SIZE_ONLY) \
- ReREFCNT_dec(PL_regcomp_rx);*/ \
+ if (!SIZE_ONLY) \
+ SAVEDESTRUCTOR(clear_re,(void*)PL_regcomp_rx); \
re_croak2("/%.127s/: ",pat,PL_regprecomp,m); \
} STMT_END
/* Check validity of program. */
if (UCHARAT(prog->program) != REG_MAGIC) {
- FAIL("corrupted regexp program");
+ croak("corrupted regexp program");
}
PL_reg_flags = 0;
default:
PerlIO_printf(PerlIO_stderr(), "%lx %d\n",
(unsigned long)scan, OP(scan));
- FAIL("regexp memory corruption");
+ croak("regexp memory corruption");
}
scan = next;
}
* We get here only if there's trouble -- normally "case END" is
* the terminating point.
*/
- FAIL("corrupted regexp pointers");
+ croak("corrupted regexp pointers");
/*NOTREACHED*/
sayNO;