summaryrefslogtreecommitdiff
path: root/universal.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-10-14 10:44:15 +0100
committerNicholas Clark <nick@ccl4.org>2010-10-14 14:34:27 +0100
commit1ee8edd0f0d0f301e1084aca5f8a9a83c483d072 (patch)
tree8ab3ad1ebe4973581051d3824961dc19b8eb14ab /universal.c
parent015db559459b868f19c1cf27c13a231443eab9b7 (diff)
downloadperl-1ee8edd0f0d0f301e1084aca5f8a9a83c483d072.tar.gz
Merge XS_Tie_Hash_NamedCapture_DELETE into S_named_capture_common.
Diffstat (limited to 'universal.c')
-rw-r--r--universal.c39
1 files changed, 12 insertions, 27 deletions
diff --git a/universal.c b/universal.c
index f543a85e3c..168a5cb13d 100644
--- a/universal.c
+++ b/universal.c
@@ -1255,7 +1255,8 @@ XS(XS_re_regexp_pattern)
}
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;
@@ -1268,8 +1269,12 @@ S_named_capture_common(pTHX_ CV *const cv, const int expect, const U32 action)
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;
@@ -1285,7 +1290,7 @@ S_named_capture_common(pTHX_ CV *const cv, const int expect, const U32 action)
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)
@@ -1322,27 +1327,7 @@ 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)
@@ -1377,7 +1362,7 @@ 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)
@@ -1436,7 +1421,7 @@ XS(XS_Tie_Hash_NamedCapture_NEXTK)
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)