From: Vincent Pit Date: Fri, 25 Jun 2010 20:30:18 +0000 (+0200) Subject: 5.13.2 calls get magic on globs X-Git-Tag: v0.43~3 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FVariable-Magic.git;a=commitdiff_plain;h=d40ee99380faf573a5d2983fbd730600266244e7 5.13.2 calls get magic on globs Add the new compatibility macro VMG_COMPAT_GLOB_GET to reflect this change. --- diff --git a/Magic.xs b/Magic.xs index fab2340..0d6359e 100644 --- a/Magic.xs +++ b/Magic.xs @@ -196,6 +196,12 @@ STATIC SV *vmg_clone(pTHX_ SV *sv, tTHX owner) { # define VMG_COMPAT_SCALAR_LENGTH_NOLEN 0 #endif +#if VMG_HAS_PERL(5, 13, 2) +# define VMG_COMPAT_GLOB_GET 1 +#else +# define VMG_COMPAT_GLOB_GET 0 +#endif + /* ... Bug-free mg_magical ................................................. */ /* See the discussion at http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2008-01/msg00036.html. This version is specialized to our needs. */ @@ -1357,6 +1363,7 @@ BOOT: newSVuv(VMG_COMPAT_ARRAY_UNDEF_CLEAR)); newCONSTSUB(stash, "VMG_COMPAT_SCALAR_LENGTH_NOLEN", newSVuv(VMG_COMPAT_SCALAR_LENGTH_NOLEN)); + newCONSTSUB(stash, "VMG_COMPAT_GLOB_GET", newSVuv(VMG_COMPAT_GLOB_GET)); newCONSTSUB(stash, "VMG_PERL_PATCHLEVEL", newSVuv(VMG_PERL_PATCHLEVEL)); newCONSTSUB(stash, "VMG_THREADSAFE", newSVuv(VMG_THREADSAFE)); newCONSTSUB(stash, "VMG_FORKSAFE", newSVuv(VMG_FORKSAFE)); diff --git a/lib/Variable/Magic.pm b/lib/Variable/Magic.pm index d792a8a..05fdde1 100644 --- a/lib/Variable/Magic.pm +++ b/lib/Variable/Magic.pm @@ -392,6 +392,10 @@ True for perls that call 'clear' magic when undefining magical arrays. True for perls that don't call 'len' magic when taking the C of a magical scalar. +=head2 C + +True for perls that call 'get' magic for operations on globs. + =head2 C The perl patchlevel this module was built with, or C<0> for non-debugging perls. @@ -569,6 +573,7 @@ our %EXPORT_TAGS = ( qw/VMG_COMPAT_ARRAY_UNSHIFT_NOLEN_VOID/, qw/VMG_COMPAT_ARRAY_UNDEF_CLEAR/, qw/VMG_COMPAT_SCALAR_LENGTH_NOLEN/, + qw/VMG_COMPAT_GLOB_GET/, qw/VMG_PERL_PATCHLEVEL/, qw/VMG_THREADSAFE VMG_FORKSAFE/, qw/VMG_OP_INFO_NAME VMG_OP_INFO_OBJECT/ diff --git a/t/01-import.t b/t/01-import.t index 19d165f..8fdd778 100644 --- a/t/01-import.t +++ b/t/01-import.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 2 * 18; +use Test::More tests => 2 * 19; require Variable::Magic; @@ -18,6 +18,7 @@ my %syms = ( VMG_COMPAT_ARRAY_UNSHIFT_NOLEN_VOID VMG_COMPAT_ARRAY_UNDEF_CLEAR VMG_COMPAT_SCALAR_LENGTH_NOLEN + VMG_COMPAT_GLOB_GET VMG_PERL_PATCHLEVEL VMG_THREADSAFE VMG_FORKSAFE VMG_OP_INFO_NAME VMG_OP_INFO_OBJECT diff --git a/t/34-glob.t b/t/34-glob.t index 664152d..de5c64c 100644 --- a/t/34-glob.t +++ b/t/34-glob.t @@ -13,7 +13,9 @@ if ($@) { diag "Using Symbol $Symbol::VERSION" if defined $Symbol::VERSION; } -use Variable::Magic qw/cast dispell/; +use Variable::Magic qw/cast dispell VMG_COMPAT_GLOB_GET/; + +my %get = VMG_COMPAT_GLOB_GET ? (get => 1) : (); use lib 't/lib'; use Variable::Magic::TestWatcher; @@ -24,17 +26,17 @@ my $wiz = init_watcher local *a = gensym(); -watch { cast *a, $wiz } { }, 'cast'; +watch { cast *a, $wiz } +{ }, 'cast'; -watch { local *b = *a } { }, 'assign to'; +watch { local *b = *a } +{ %get }, 'assign to'; -watch { *a = gensym() } { set => 1 }, 'assign'; +watch { *a = gensym() } +{ %get, set => 1 }, 'assign'; watch { local *b = gensym(); - watch { cast *b, $wiz } { }, 'cast 2'; -} { }, 'scope end'; + watch { cast *b, $wiz } +{ }, 'cast 2'; +} +{ }, 'scope end'; -watch { undef *a } { }, 'undef'; +watch { undef *a } +{ %get }, 'undef'; -watch { dispell *a, $wiz } { }, 'dispell'; +watch { dispell *a, $wiz } +{ %get }, 'dispell';