summaryrefslogtreecommitdiff
path: root/proto.h
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-06-05 20:09:32 -0700
committerFather Chrysostomos <sprout@cpan.org>2012-06-07 08:18:54 -0700
commit01f91bf275559c4ad5a42efe7848a0db00ceb317 (patch)
treed1210a4901f728e53a84cc155c635ddb4bdefc0f /proto.h
parentef5fe392ebd662891a80860e9ba74cc961823c81 (diff)
downloadperl-01f91bf275559c4ad5a42efe7848a0db00ceb317.tar.gz
[perl #109542] Make num ops treat $1 as "$1"
Numeric ops were not taking magical variables into account. So $1 (a magical variable) would be treated differently from "$1" (a non-magi- cal variable0. In determining whether to use an integer operation, they would call SvIV_please_nomg, and then check whether the sv was SvIOK as a result. SvIV_please_nomg would call SvIV_nomg if the sv were SvPOK or SvNOK. The problem here is that gmagical variables are never SvIOK, but only SvIOKp. In fact, the private flags are used differently for gmagical and non- magical variables. For non-gmagical variables, the private flag indi- cates that there is a cached value. If the public flag is not set, then the cached value is imprecise. For gmagical variables, imprecise values are never cached; only the private flags are used, and they are equivalent to the public flags on non-gmagical variables. This commit changes SvIV_please_nomg to take gmagical variables into account, using the newly-added sv_gmagical_2iv_please (see the docs for it in the diff). SvIV_please_nomg now returns true or false, not void, since a subsequent SvIOK is not reliable. So ‘SvIV_please_nomg(sv); if(SvIOK)’ becomes ‘if(SvIV_please_nomg(sv))’.
Diffstat (limited to 'proto.h')
-rw-r--r--proto.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/proto.h b/proto.h
index b6dbd5c3b6..02bc3ccbc7 100644
--- a/proto.h
+++ b/proto.h
@@ -3959,6 +3959,11 @@ PERL_CALLCONV char* Perl_sv_gets(pTHX_ SV *const sv, PerlIO *const fp, I32 appen
#define PERL_ARGS_ASSERT_SV_GETS \
assert(sv); assert(fp)
+PERL_CALLCONV bool Perl_sv_gmagical_2iv_please(pTHX_ SV *sv)
+ __attribute__nonnull__(pTHX_1);
+#define PERL_ARGS_ASSERT_SV_GMAGICAL_2IV_PLEASE \
+ assert(sv)
+
PERL_CALLCONV char* Perl_sv_grow(pTHX_ SV *const sv, STRLEN newlen)
__attribute__nonnull__(pTHX_1);
#define PERL_ARGS_ASSERT_SV_GROW \