{ sizeof(XPVMG), copy_length(XPVMG, xmg_stash), 0, SVt_PVMG, FALSE, HADNV,
HASARENA, FIT_ARENA(0, sizeof(XPVMG)) },
- /* There are plans for this */
- { 0, 0, 0, SVt_ORANGE, FALSE, NONV, NOARENA, 0 },
+ /* 32 */
+ { sizeof(struct xregexp), copy_length(struct xregexp, xrx_regexp), 0,
+ SVt_REGEXP, FALSE, HADNV, HASARENA, FIT_ARENA(0, sizeof(struct xregexp))
+ },
/* 48 */
{ sizeof(XPVGV), sizeof(XPVGV), 0, SVt_PVGV, TRUE, HADNV,
#endif
+static const struct body_details fake_rv =
+ { 0, 0, 0, SVt_IV, FALSE, NONV, NOARENA, 0 };
+
/*
=for apidoc sv_upgrade
void* new_body;
const svtype old_type = SvTYPE(sv);
const struct body_details *new_type_details;
- const struct body_details *const old_type_details
+ const struct body_details *old_type_details
= bodies_by_type + old_type;
SV *referant = NULL;
case SVt_IV:
if (SvROK(sv)) {
referant = SvRV(sv);
- if (new_type < SVt_PVIV) {
- new_type = SVt_PVIV;
- /* FIXME to check SvROK(sv) ? SVt_PV : and fake up
- old_body_details */
- }
+ old_type_details = &fake_rv;
+ if (new_type == SVt_NV)
+ new_type = SVt_PVNV;
} else {
if (new_type < SVt_PVIV) {
new_type = (new_type == SVt_NV)
case SVt_PVGV:
case SVt_PVCV:
case SVt_PVLV:
+ case SVt_REGEXP:
case SVt_PVMG:
case SVt_PVNV:
case SVt_PV:
STRLEN len;
char *retval;
char *buffer;
- MAGIC *mg;
const SV *const referent = (SV*)SvRV(sv);
if (!referent) {
len = 7;
retval = buffer = savepvn("NULLREF", len);
- } else if (SvTYPE(referent) == SVt_PVMG
- && ((SvFLAGS(referent) &
- (SVs_OBJECT|SVf_OK|SVs_GMG|SVs_SMG|SVs_RMG))
- == (SVs_OBJECT|SVs_SMG))
- && (mg = mg_find(referent, PERL_MAGIC_qr)))
- {
+ } else if (SvTYPE(referent) == SVt_REGEXP) {
char *str = NULL;
I32 haseval = 0;
U32 flags = 0;
- (str) = CALLREG_AS_STR(mg,lp,&flags,&haseval);
+ struct magic temp;
+ temp.mg_obj
+ = (SV*)((struct xregexp *)SvANY(referent))->xrx_regexp;
+ assert(temp.mg_obj);
+ (str) = CALLREG_AS_STR(&temp,lp,&flags,&haseval);
if (flags & 1)
SvUTF8_on(sv);
else
Safefree(IoFMT_NAME(sv));
Safefree(IoBOTTOM_NAME(sv));
goto freescalar;
+ case SVt_REGEXP:
+ ReREFCNT_dec(((struct xregexp *)SvANY(sv))->xrx_regexp);
+ goto freescalar;
case SVt_PVCV:
case SVt_PVFM:
cv_undef((CV*)sv);
else
Perl_croak(aTHX_ "Can't coerce readonly %s to string", ref);
}
- if (SvTYPE(sv) > SVt_PVLV && SvTYPE(sv) != SVt_PVFM)
+ if ((SvTYPE(sv) > SVt_PVLV && SvTYPE(sv) != SVt_PVFM)
+ || isGV_with_GP(sv))
Perl_croak(aTHX_ "Can't coerce %s to string in %s", sv_reftype(sv,0),
OP_NAME(PL_op));
s = sv_2pv_flags(sv, &len, flags);
case SVt_PVFM: return "FORMAT";
case SVt_PVIO: return "IO";
case SVt_BIND: return "BIND";
+ case SVt_REGEXP: return "Regexp"; /* FIXME? to "REGEXP" */
default: return "UNKNOWN";
}
}
case SVt_PVAV:
case SVt_PVCV:
case SVt_PVLV:
+ case SVt_REGEXP:
case SVt_PVMG:
case SVt_PVNV:
case SVt_PVIV:
break;
case SVt_PVMG:
break;
+ case SVt_REGEXP:
+ ((struct xregexp *)SvANY(dstr))->xrx_regexp
+ = CALLREGDUPE(((struct xregexp *)SvANY(dstr))->xrx_regexp,
+ param);
+ break;
case SVt_PVLV:
/* XXX LvTARGOFF sometimes holds PMOP* when DEBUGGING */
if (LvTYPE(dstr) == 't') /* for tie: unrefcnted fake (SV**) */