summaryrefslogtreecommitdiff
path: root/universal.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-10-13 16:16:11 +0100
committerNicholas Clark <nick@ccl4.org>2010-10-13 16:16:11 +0100
commitfdae947323b49384fccc4ae1603c2e5fca04f0f1 (patch)
treed0cd4c68cf2c8feb67db32e389eddcf124971834 /universal.c
parentcb525dbe8838a8e289f2e8f893dd8df441c740c4 (diff)
downloadperl-fdae947323b49384fccc4ae1603c2e5fca04f0f1.tar.gz
Consistent stack handling for XS_re_regnames_*
This may also fix bugs for the (untested) cases where the called routine returns NULL, and the calling routine attempted XSRETURN_UNDEF.
Diffstat (limited to 'universal.c')
-rw-r--r--universal.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/universal.c b/universal.c
index 8b4ed21b0c..52d701c702 100644
--- a/universal.c
+++ b/universal.c
@@ -1038,8 +1038,6 @@ XS(XS_re_is_regexp)
if (items != 1)
croak_xs_usage(cv, "sv");
- SP -= items;
-
if (SvRXOK(ST(0))) {
XSRETURN_YES;
} else {
@@ -1058,6 +1056,7 @@ XS(XS_re_regnames_count)
croak_xs_usage(cv, "");
SP -= items;
+ PUTBACK;
if (!rx)
XSRETURN_UNDEF;
@@ -1065,14 +1064,8 @@ XS(XS_re_regnames_count)
ret = CALLREG_NAMED_BUFF_COUNT(rx);
SPAGAIN;
-
- if (ret) {
- mXPUSHs(ret);
- PUTBACK;
- return;
- } else {
- XSRETURN_UNDEF;
- }
+ PUSHs(ret ? sv_2mortal(ret) : &PL_sv_undef);
+ XSRETURN(1);
}
XS(XS_re_regname)
@@ -1087,6 +1080,7 @@ XS(XS_re_regname)
croak_xs_usage(cv, "name[, all ]");
SP -= items;
+ PUTBACK;
rx = PL_curpm ? PM_GETRE(PL_curpm) : NULL;
@@ -1100,11 +1094,9 @@ XS(XS_re_regname)
}
ret = CALLREG_NAMED_BUFF_FETCH(rx, ST(0), (flags | RXapif_REGNAME));
- if (ret) {
- mXPUSHs(ret);
- XSRETURN(1);
- }
- XSRETURN_UNDEF;
+ SPAGAIN;
+ PUSHs(ret ? sv_2mortal(ret) : &PL_sv_undef);
+ XSRETURN(1);
}
@@ -1135,13 +1127,12 @@ XS(XS_re_regnames)
}
SP -= items;
+ PUTBACK;
ret = CALLREG_NAMED_BUFF_ALL(rx, (flags | RXapif_REGNAMES));
SPAGAIN;
- SP -= items;
-
if (!ret)
XSRETURN_UNDEF;