}
static void
-S_named_capture_common(pTHX_ CV *const cv, const int expect, const U32 action)
+S_named_capture_common(pTHX_ CV *const cv, const bool fatal, const int expect,
+ const U32 action)
{
dVAR;
dXSARGS;
rx = PL_curpm ? PM_GETRE(PL_curpm) : NULL;
- if (!rx || !SvROK(ST(0)))
- XSRETURN_UNDEF;
+ if (!rx || !SvROK(ST(0))) {
+ if (fatal)
+ Perl_croak_no_modify(aTHX);
+ else
+ XSRETURN_UNDEF;
+ }
SP -= items;
PUTBACK;
XS(XS_Tie_Hash_NamedCapture_FETCH)
{
- S_named_capture_common(aTHX_ cv, 2, RXapif_FETCH);
+ S_named_capture_common(aTHX_ cv, FALSE, 2, RXapif_FETCH);
}
XS(XS_Tie_Hash_NamedCapture_STORE)
XS(XS_Tie_Hash_NamedCapture_DELETE)
{
- dVAR;
- dXSARGS;
- REGEXP * rx = PL_curpm ? PM_GETRE(PL_curpm) : NULL;
- U32 flags;
- SV *ret;
-
- if (items != 2)
- croak_xs_usage(cv, "$key");
-
- if (!rx || !SvROK(ST(0)))
- Perl_croak_no_modify(aTHX);
-
- SP -= items;
- PUTBACK;
-
- flags = (U32)SvUV(SvRV(MUTABLE_SV(ST(0))));
- ret = RX_ENGINE(rx)->named_buff(aTHX_ (rx), ST(1), NULL, flags | RXapif_DELETE);
-
- SPAGAIN;
- PUSHs(ret ? sv_2mortal(ret) : &PL_sv_undef);
- XSRETURN(1);
+ S_named_capture_common(aTHX_ cv, TRUE, 2, RXapif_DELETE);
}
XS(XS_Tie_Hash_NamedCapture_CLEAR)
XS(XS_Tie_Hash_NamedCapture_EXISTS)
{
- S_named_capture_common(aTHX_ cv, 2, RXapif_EXISTS);
+ S_named_capture_common(aTHX_ cv, FALSE, 2, RXapif_EXISTS);
}
XS(XS_Tie_Hash_NamedCapture_FIRSTK)
XS(XS_Tie_Hash_NamedCapture_SCALAR)
{
- S_named_capture_common(aTHX_ cv, 1, RXapif_SCALAR);
+ S_named_capture_common(aTHX_ cv, FALSE, 1, RXapif_SCALAR);
}
XS(XS_Tie_Hash_NamedCapture_flags)