summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2008-01-05 22:33:12 +0000
committerNicholas Clark <nick@ccl4.org>2008-01-05 22:33:12 +0000
commitd2f13c598f9812cd520097e22d819d1b9f7b0cb6 (patch)
tree51c2739d4fe37c20fc90e087816461a35cf48e5a
parent62a1a1efb41483ae8589f3158be0ce9a1c21e8e2 (diff)
downloadperl-d2f13c598f9812cd520097e22d819d1b9f7b0cb6.tar.gz
Make REGEXP a type distinct from SV. (Much like AV, CV, GV, HV).
p4raw-id: //depot/perl@32861
-rw-r--r--perl.h2
-rw-r--r--pp_ctl.c8
-rw-r--r--pp_hot.c2
-rw-r--r--regcomp.c6
-rw-r--r--regexec.c10
-rw-r--r--sv.c8
-rw-r--r--sv.h5
-rw-r--r--util.c2
8 files changed, 24 insertions, 19 deletions
diff --git a/perl.h b/perl.h
index 0f6557250c..66cdf3e764 100644
--- a/perl.h
+++ b/perl.h
@@ -2353,7 +2353,7 @@ typedef struct av AV;
typedef struct hv HV;
typedef struct cv CV;
typedef struct regexp ORANGE; /* This is the body structure. */
-typedef SV REGEXP;
+typedef struct p5rx REGEXP;
typedef struct gp GP;
typedef struct gv GV;
typedef struct io IO;
diff --git a/pp_ctl.c b/pp_ctl.c
index 74c99cc6ae..11bbdc561a 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -117,7 +117,7 @@ PP(pp_regcomp)
if (SvROK(tmpstr)) {
SV * const sv = SvRV(tmpstr);
if (SvTYPE(sv) == SVt_REGEXP)
- re = sv;
+ re = (REGEXP*) sv;
}
if (re) {
re = reg_temp_copy(re);
@@ -3914,11 +3914,11 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other)
# define SM_REGEX ( \
(SvROK(d) && (SvTYPE(This = SvRV(d)) == SVt_REGEXP) \
- && (this_regex = This) \
+ && (this_regex = (REGEXP*) This) \
&& (Other = e)) \
|| \
(SvROK(e) && (SvTYPE(This = SvRV(e)) == SVt_REGEXP) \
- && (this_regex = This) \
+ && (this_regex = (REGEXP*) This) \
&& (Other = d)) )
@@ -3927,7 +3927,7 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other)
# define SM_OTHER_REGEX (SvROK(Other) \
&& (SvTYPE(SvRV(Other)) == SVt_REGEXP) \
- && (other_regex = SvRV(Other)))
+ && (other_regex = (REGEXP*) SvRV(Other)))
# define SM_SEEN_THIS(sv) hv_exists_ent(seen_this, \
diff --git a/pp_hot.c b/pp_hot.c
index 940c4a500a..f5433724f5 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -1199,7 +1199,7 @@ PP(pp_qr)
/* This RV is about to own a reference to the regexp. (In addition to the
reference already owned by the PMOP. */
ReREFCNT_inc(rx);
- SvRV_set(rv, rx);
+ SvRV_set(rv, (SV*) rx);
SvROK_on(rv);
if (pkg) {
diff --git a/regcomp.c b/regcomp.c
index 48a6944fcc..6e9c19abf4 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -4264,7 +4264,7 @@ redo_first_pass:
/* Allocate space and zero-initialize. Note, the two step process
of zeroing when in debug mode, thus anything assigned has to
happen after that */
- rx = newSV_type(SVt_REGEXP);
+ rx = (REGEXP*) newSV_type(SVt_REGEXP);
r = (struct regexp*)SvANY(rx);
Newxc(ri, sizeof(regexp_internal) + (unsigned)RExC_size * sizeof(regnode),
char, regexp_internal);
@@ -4294,7 +4294,7 @@ redo_first_pass:
+ (sizeof(STD_PAT_MODS) - 1)
+ (sizeof("(?:)") - 1);
- p = sv_grow(rx, wraplen + 1);
+ p = sv_grow((SV *)rx, wraplen + 1);
SvCUR_set(rx, wraplen);
SvPOK_on(rx);
SvFLAGS(rx) |= SvUTF8(pattern);
@@ -9201,7 +9201,7 @@ Perl_pregfree2(pTHX_ REGEXP *rx)
REGEXP *
Perl_reg_temp_copy (pTHX_ REGEXP *rx) {
- REGEXP *ret_x = newSV_type(SVt_REGEXP);
+ REGEXP *ret_x = (REGEXP*) newSV_type(SVt_REGEXP);
struct regexp *ret = (struct regexp *)SvANY(ret_x);
struct regexp *const r = (struct regexp *)SvANY(rx);
register const I32 npar = r->nparens+1;
diff --git a/regexec.c b/regexec.c
index 64966941c7..0f1c9e11bd 100644
--- a/regexec.c
+++ b/regexec.c
@@ -3633,7 +3633,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, regnode *prog)
#define ST st->u.eval
{
SV *ret;
- SV *re_sv;
+ REGEXP *re_sv;
regexp *re;
regexp_internal *rei;
regnode *startpoint;
@@ -3720,13 +3720,13 @@ S_regmatch(pTHX_ regmatch_info *reginfo, regnode *prog)
SV *const sv = SvRV(ret);
if (SvTYPE(sv) == SVt_REGEXP) {
- rx = sv;
+ rx = (REGEXP*) sv;
} else if (SvSMAGICAL(sv)) {
mg = mg_find(sv, PERL_MAGIC_qr);
assert(mg);
}
} else if (SvTYPE(ret) == SVt_REGEXP) {
- rx = ret;
+ rx = (REGEXP*) ret;
} else if (SvSMAGICAL(ret)) {
if (SvGMAGICAL(ret)) {
/* I don't believe that there is ever qr magic
@@ -3745,7 +3745,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, regnode *prog)
}
if (mg) {
- rx = mg->mg_obj; /*XXX:dmq*/
+ rx = (REGEXP *) mg->mg_obj; /*XXX:dmq*/
assert(rx);
}
if (rx) {
@@ -3774,7 +3774,7 @@ S_regmatch(pTHX_ regmatch_info *reginfo, regnode *prog)
/* This isn't a first class regexp. Instead, it's
caching a regexp onto an existing, Perl visible
scalar. */
- sv_magic(ret, rx, PERL_MAGIC_qr, 0, 0);
+ sv_magic(ret, (SV*) rx, PERL_MAGIC_qr, 0, 0);
}
PL_regsize = osize;
}
diff --git a/sv.c b/sv.c
index dc0ec589b7..b5ee77e9db 100644
--- a/sv.c
+++ b/sv.c
@@ -5240,7 +5240,7 @@ Perl_sv_clear(pTHX_ register SV *sv)
goto freescalar;
case SVt_REGEXP:
/* FIXME for plugins */
- pregfree2(sv);
+ pregfree2((REGEXP*) sv);
goto freescalar;
case SVt_PVCV:
case SVt_PVFM:
@@ -10251,7 +10251,7 @@ Perl_sv_dup(pTHX_ const SV *sstr, CLONE_PARAMS* param)
break;
case SVt_REGEXP:
/* FIXME for plugins */
- re_dup_guts(sstr, dstr, param);
+ re_dup_guts((REGEXP*) sstr, (REGEXP*) dstr, param);
break;
case SVt_PVLV:
/* XXX LvTARGOFF sometimes holds PMOP* when DEBUGGING */
@@ -11247,9 +11247,9 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags,
pointer inside an IV hack? */
SV * const sv =
SvREPADTMP(regex)
- ? sv_dup_inc(regex, param)
+ ? sv_dup_inc((SV*) regex, param)
: SvREFCNT_inc(
- newSViv(PTR2IV(sv_dup_inc(INT2PTR(REGEXP *, SvIVX(regex)), param))))
+ newSViv(PTR2IV(sv_dup_inc(INT2PTR(SV *, SvIVX(regex)), param))))
;
if (SvFLAGS(regex) & SVf_BREAK)
SvFLAGS(sv) |= SVf_BREAK; /* unrefcnted PL_curpm */
diff --git a/sv.h b/sv.h
index ea5e0aecc8..ed253839fd 100644
--- a/sv.h
+++ b/sv.h
@@ -150,6 +150,11 @@ struct io {
_SV_HEAD_UNION;
};
+struct p5rx {
+ _SV_HEAD(struct regexp*); /* pointer to regexp body */
+ _SV_HEAD_UNION;
+};
+
#undef _SV_HEAD
#undef _SV_HEAD_UNION /* ensure no pollution */
diff --git a/util.c b/util.c
index 980db3c406..556abb715d 100644
--- a/util.c
+++ b/util.c
@@ -5921,7 +5921,7 @@ Perl_get_re_arg(pTHX_ SV *sv) {
(tmpsv = (SV*)SvRV(sv)) && /* assign deliberate */
SvTYPE(tmpsv) == SVt_REGEXP)
{
- return tmpsv;
+ return (REGEXP*) tmpsv;
}
}