summaryrefslogtreecommitdiff
path: root/universal.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-10-14 11:17:35 +0100
committerNicholas Clark <nick@ccl4.org>2010-10-14 14:34:27 +0100
commit451eed4a967ae47c4702ea000f3a547dc3d7267b (patch)
tree944b2b37936ccd26ed77d60650f66f3e67120a9a /universal.c
parent7f35162bf94f4c6c0cf4778e9f03e480f68a9da2 (diff)
downloadperl-451eed4a967ae47c4702ea000f3a547dc3d7267b.tar.gz
Merge XS_Tie_Hash_NamedCapture_STORE into S_named_capture_common.
Diffstat (limited to 'universal.c')
-rw-r--r--universal.c34
1 files changed, 4 insertions, 30 deletions
diff --git a/universal.c b/universal.c
index cbced9deba..5b0e5e5f61 100644
--- a/universal.c
+++ b/universal.c
@@ -1265,7 +1265,8 @@ S_named_capture_common(pTHX_ CV *const cv, const bool fatal, const int expect,
SV * ret;
if (items != expect)
- croak_xs_usage(cv, expect == 2 ? "$key" : "");
+ croak_xs_usage(cv, expect == 2 ? "$key"
+ : (expect == 3 ? "$key, $value" : ""));
rx = PL_curpm ? PM_GETRE(PL_curpm) : NULL;
@@ -1281,7 +1282,7 @@ S_named_capture_common(pTHX_ CV *const cv, const bool fatal, const int expect,
flags = (U32)SvUV(SvRV(MUTABLE_SV(ST(0))));
ret = RX_ENGINE(rx)->named_buff(aTHX_ (rx), expect >= 2 ? ST(1) : NULL,
- NULL, flags | action);
+ expect >= 3 ? ST(2) : NULL, flags | action);
if (discard) {
/* Called with G_DISCARD, so our return stack state is thrown away.
@@ -1302,34 +1303,7 @@ XS(XS_Tie_Hash_NamedCapture_FETCH)
XS(XS_Tie_Hash_NamedCapture_STORE)
{
- dVAR;
- dXSARGS;
- REGEXP * rx;
- U32 flags;
- SV *ret;
-
- if (items != 3)
- croak_xs_usage(cv, "$key, $value");
-
- rx = PL_curpm ? PM_GETRE(PL_curpm) : NULL;
-
- 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), ST(2), flags | RXapif_STORE);
-
-
- /* Perl_magic_setpack calls us with G_DISCARD, so our return stack state
- is thrown away. */
-
- /* If we were returned anything, free it immediately. */
- SvREFCNT_dec(ret);
- XSRETURN_EMPTY;
+ S_named_capture_common(aTHX_ cv, TRUE, 3, TRUE, RXapif_STORE);
}
XS(XS_Tie_Hash_NamedCapture_DELETE)