summaryrefslogtreecommitdiff
path: root/universal.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-10-14 10:08:08 +0100
committerNicholas Clark <nick@ccl4.org>2010-10-14 14:34:27 +0100
commit606c5d14753b06846c2cc98166e8bc2dc8cb27fd (patch)
tree4969304767e631a370779cdda9c048d5c682075d /universal.c
parent0bbbe6948c4d46b5eafef01c918d2aea8e16681a (diff)
downloadperl-606c5d14753b06846c2cc98166e8bc2dc8cb27fd.tar.gz
Merge XS_Tie_Hash_NamedCapture_{FETCH,EXISTS} into S_named_capture_common.
Diffstat (limited to 'universal.c')
-rw-r--r--universal.c34
1 files changed, 9 insertions, 25 deletions
diff --git a/universal.c b/universal.c
index cd8f9f9039..cbdca0d780 100644
--- a/universal.c
+++ b/universal.c
@@ -1254,7 +1254,8 @@ XS(XS_re_regexp_pattern)
/* NOT-REACHED */
}
-XS(XS_Tie_Hash_NamedCapture_FETCH)
+static void
+S_named_capture_common(pTHX_ CV *const cv, const U32 action)
{
dVAR;
dXSARGS;
@@ -1274,13 +1275,18 @@ XS(XS_Tie_Hash_NamedCapture_FETCH)
PUTBACK;
flags = (U32)SvUV(SvRV(MUTABLE_SV(ST(0))));
- ret = RX_ENGINE(rx)->named_buff(aTHX_ (rx), ST(1), NULL, flags | RXapif_FETCH);
+ ret = RX_ENGINE(rx)->named_buff(aTHX_ (rx), ST(1), NULL, flags | action);
SPAGAIN;
PUSHs(ret ? sv_2mortal(ret) : &PL_sv_undef);
XSRETURN(1);
}
+XS(XS_Tie_Hash_NamedCapture_FETCH)
+{
+ S_named_capture_common(aTHX_ cv, RXapif_FETCH);
+}
+
XS(XS_Tie_Hash_NamedCapture_STORE)
{
dVAR;
@@ -1370,29 +1376,7 @@ XS(XS_Tie_Hash_NamedCapture_CLEAR)
XS(XS_Tie_Hash_NamedCapture_EXISTS)
{
- dVAR;
- dXSARGS;
- REGEXP * rx;
- U32 flags;
- SV * ret;
-
- if (items != 2)
- croak_xs_usage(cv, "$key");
-
- rx = PL_curpm ? PM_GETRE(PL_curpm) : NULL;
-
- if (!rx || !SvROK(ST(0)))
- XSRETURN_UNDEF;
-
- SP -= items;
- PUTBACK;
-
- flags = (U32)SvUV(SvRV(MUTABLE_SV(ST(0))));
- ret = RX_ENGINE(rx)->named_buff(aTHX_ (rx), ST(1), NULL, flags | RXapif_EXISTS);
-
- SPAGAIN;
- PUSHs(ret ? sv_2mortal(ret) : &PL_sv_undef);
- XSRETURN(1);
+ S_named_capture_common(aTHX_ cv, RXapif_EXISTS);
}
XS(XS_Tie_Hash_NamedCapture_FIRSTK)