summaryrefslogtreecommitdiff
path: root/dump.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2017-07-03 17:07:28 +0100
committerDavid Mitchell <davem@iabyn.com>2017-07-27 11:30:21 +0100
commit5a6c28370397ad3d5c138df5778833dc4b11c3be (patch)
tree220b9b186bb82e9ed21290c3f93130b906e3ba27 /dump.c
parent0283ad960acb937e9387b3323f1f7852c2adb0fa (diff)
downloadperl-5a6c28370397ad3d5c138df5778833dc4b11c3be.tar.gz
add PL_sv_zero
it's like PL_sv_no, except that its string value is "0" rather than "". It can be used for example where pp function wants to push a zero return value on the stack. The next commit will start to use it. Also update the SvIMMORTAL() to be more efficient: it now checks whether the SV's address is in a range rather than individually checking against &PL_sv_undef, &PL_sv_no etc.
Diffstat (limited to 'dump.c')
-rw-r--r--dump.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/dump.c b/dump.c
index c4bb3ce09c..fa5f0baf91 100644
--- a/dump.c
+++ b/dump.c
@@ -369,7 +369,9 @@ Perl_sv_peek(pTHX_ SV *sv)
sv_catpv(t, "WILD");
goto finish;
}
- else if (sv == &PL_sv_undef || sv == &PL_sv_no || sv == &PL_sv_yes || sv == &PL_sv_placeholder) {
+ else if ( sv == &PL_sv_undef || sv == &PL_sv_no || sv == &PL_sv_yes
+ || sv == &PL_sv_zero || sv == &PL_sv_placeholder)
+ {
if (sv == &PL_sv_undef) {
sv_catpv(t, "SV_UNDEF");
if (!(SvFLAGS(sv) & (SVf_OK|SVf_OOK|SVs_OBJECT|
@@ -398,6 +400,17 @@ Perl_sv_peek(pTHX_ SV *sv)
SvNVX(sv) == 1.0)
goto finish;
}
+ else if (sv == &PL_sv_zero) {
+ sv_catpv(t, "SV_ZERO");
+ if (!(SvFLAGS(sv) & (SVf_ROK|SVf_OOK|SVs_OBJECT|
+ SVs_GMG|SVs_SMG|SVs_RMG)) &&
+ !(~SvFLAGS(sv) & (SVf_POK|SVf_NOK|SVf_READONLY|
+ SVp_POK|SVp_NOK)) &&
+ SvCUR(sv) == 1 &&
+ SvPVX_const(sv) && *SvPVX_const(sv) == '0' &&
+ SvNVX(sv) == 0.0)
+ goto finish;
+ }
else {
sv_catpv(t, "SV_PLACEHOLDER");
if (!(SvFLAGS(sv) & (SVf_OK|SVf_OOK|SVs_OBJECT|