diff options
author | Father Chrysostomos <sprout@cpan.org> | 2011-07-12 12:24:29 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-07-12 13:00:02 -0700 |
commit | fa819c1ce3252e7ae97e9cdd4d3d0dd1edb06fa1 (patch) | |
tree | 9de6862f1c09e08526ecb4c315aec824c6f82b8e | |
parent | 21690b721fd5cd765bcc0330aa94f9172c24582d (diff) | |
download | perl-fa819c1ce3252e7ae97e9cdd4d3d0dd1edb06fa1.tar.gz |
Make SvIsCOW honest about globs
SvIsCOW was ignoring the fact that it might be passed a
typeglob, which made its behaviour contradict its docs.
This fixes that and, in doing so, simplifies the
upcoming Internals::SvREADONLY fix.
-rw-r--r-- | MANIFEST | 1 | ||||
-rw-r--r-- | ext/XS-APItest/APItest.xs | 7 | ||||
-rw-r--r-- | ext/XS-APItest/t/sviscow.t | 13 | ||||
-rw-r--r-- | sv.h | 4 |
4 files changed, 23 insertions, 2 deletions
@@ -3715,6 +3715,7 @@ ext/XS-APItest/t/stmtasexpr.t test recursive descent statement parsing ext/XS-APItest/t/stmtsasexpr.t test recursive descent statement-sequence parsing ext/XS-APItest/t/stuff_modify_bug.t test for eval side-effecting source string ext/XS-APItest/t/stuff_svcur_bug.t test for a bug in lex_stuff_pvn +ext/XS-APItest/t/sviscow.t Test SvIsCOW ext/XS-APItest/t/svpeek.t XS::APItest extension ext/XS-APItest/t/svpv_magic.t Test behaviour of SvPVbyte and get magic ext/XS-APItest/t/svsetsv.t Test behaviour of sv_setsv with/without PERL_CORE diff --git a/ext/XS-APItest/APItest.xs b/ext/XS-APItest/APItest.xs index acd1b5e42f..68533da58b 100644 --- a/ext/XS-APItest/APItest.xs +++ b/ext/XS-APItest/APItest.xs @@ -2858,6 +2858,13 @@ CODE: HeVAL(entry) = NULL; } +bool +SvIsCOW(SV *sv) +CODE: + RETVAL = SvIsCOW(sv); +OUTPUT: + RETVAL + MODULE = XS::APItest PACKAGE = XS::APItest::Magic PROTOTYPES: DISABLE diff --git a/ext/XS-APItest/t/sviscow.t b/ext/XS-APItest/t/sviscow.t new file mode 100644 index 0000000000..bcc9da8ebd --- /dev/null +++ b/ext/XS-APItest/t/sviscow.t @@ -0,0 +1,13 @@ +use strict; +use warnings; no warnings 'once'; + +use Test::More tests => 1; + +use XS::APItest; +use Hash::Util 'lock_value'; + +my %h; +$h{g} = *foo; +lock_value %h, 'g'; + +ok(!SvIsCOW($h{g}), 'SvIsCOW is honest when it comes to globs'); @@ -1738,8 +1738,8 @@ Like sv_utf8_upgrade, but doesn't do magic on C<sv> # define SvTRUEx(sv) ((PL_Sv = (sv)), SvTRUE(PL_Sv)) #endif /* __GNU__ */ -#define SvIsCOW(sv) ((SvFLAGS(sv) & (SVf_FAKE | SVf_READONLY)) == \ - (SVf_FAKE | SVf_READONLY)) +#define SvIsCOW(sv) ((SvFLAGS(sv) & (SVf_FAKE | SVf_READONLY)) == \ + (SVf_FAKE | SVf_READONLY) && !isGV_with_GP(sv)) #define SvIsCOW_shared_hash(sv) (SvIsCOW(sv) && SvLEN(sv) == 0) #define SvSHARED_HEK_FROM_PV(pvx) \ |