In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/5f425cbef56bf693b214e78fe4ac4fbc3cba54d9?hp=3231d2579ce5888f1afc6ca0c6c50ca2d7826e54>
- Log ----------------------------------------------------------------- commit 5f425cbef56bf693b214e78fe4ac4fbc3cba54d9 Author: Father Chrysostomos <[email protected]> Date: Sat Jun 8 23:10:18 2013 -0700 Increase some File::Spec versions to 3.41 M dist/Cwd/lib/File/Spec/Cygwin.pm M dist/Cwd/lib/File/Spec/Epoc.pm M dist/Cwd/lib/File/Spec/Mac.pm M dist/Cwd/lib/File/Spec/OS2.pm M dist/Cwd/lib/File/Spec/Unix.pm M dist/Cwd/lib/File/Spec/Win32.pm commit 1d0806cfaae4b389343892feefebb77287497b9c Author: Father Chrysostomos <[email protected]> Date: Sat Jun 8 23:03:56 2013 -0700 Correct File::Spec POD about tainting and tmpdir Since version 3.39_01, the taint check has applied before 5.8.0, too. M dist/Cwd/lib/File/Spec/Cygwin.pm M dist/Cwd/lib/File/Spec/VMS.pm M dist/Cwd/lib/File/Spec/Win32.pm commit 82730d4c29900a581a5c4f6cd8c0cdef16c6e687 Author: Father Chrysostomos <[email protected]> Date: Sat Jun 8 23:01:07 2013 -0700 [perl #89940] File::Spec->tmpdir and env changes If the environment changes, File::Spec->tmpdir should respect that and recalculate the temp directory. The only objection raised in the ticket was that File::Spec is already accused of being too slow, so removing the cache would not be a good idea. So I put in a check to see whether the relevant environment variables have changed since the last call to tmpdir. M dist/Cwd/lib/File/Spec/Cygwin.pm M dist/Cwd/lib/File/Spec/Mac.pm M dist/Cwd/lib/File/Spec/OS2.pm M dist/Cwd/lib/File/Spec/Unix.pm M dist/Cwd/lib/File/Spec/VMS.pm M dist/Cwd/lib/File/Spec/Win32.pm M dist/Cwd/t/tmpdir.t commit 483ad8291bb83bb55f59f0ff324af70346c4945a Author: Father Chrysostomos <[email protected]> Date: Sat Jun 8 22:33:24 2013 -0700 File::Spec::Epoc: Small pod clean-up M dist/Cwd/lib/File/Spec/Epoc.pm commit 210fdecd4386556fdb4aa40a112c04b9f37be553 Author: Father Chrysostomos <[email protected]> Date: Sat Jun 8 14:38:02 2013 -0700 Flush PL_stashcache on glob-to-glob assignment Commit dc93d7fb33f6b2093 says this: Flush PL_stashcache when assigning a file handle to a typeglob. File handles take priority over stashes for method dispatch. Assigning a file handle to a typeglob potentially creates a file handle where one did not exist before. As PL_stashcache only con- tains entries for names which unambiguously resolve to stashes, such a change may mean that PL_stashcache now contains an invalid entry. As itâs hard to work out exactly which entries might be affected, simply flush the entire cache and let it rebuild itself. But it only applied to io-to-glob assignment. This commit extends it to glob-to-glob assignment. M sv.c M t/op/method.t commit 1f3ffe4c6058f20e1f7d746ababdd669651e8d2b Author: Father Chrysostomos <[email protected]> Date: Sat Jun 8 14:13:21 2013 -0700 pp_hot.c: Correct comment At this point, ob holds the object the reference points to, not the reference itself. M pp_hot.c commit c549afe0d456f55513209483c7ddf6040ddeb9d7 Author: Father Chrysostomos <[email protected]> Date: Sat Jun 8 14:07:38 2013 -0700 podcheck.t: Output fixed problems as passing to-do tests M t/porting/podcheck.t ----------------------------------------------------------------------- Summary of changes: dist/Cwd/lib/File/Spec/Cygwin.pm | 15 ++++++++++----- dist/Cwd/lib/File/Spec/Epoc.pm | 8 ++++---- dist/Cwd/lib/File/Spec/Mac.pm | 8 ++++---- dist/Cwd/lib/File/Spec/OS2.pm | 10 ++++++---- dist/Cwd/lib/File/Spec/Unix.pm | 24 +++++++++++++++++++----- dist/Cwd/lib/File/Spec/VMS.pm | 11 ++++++----- dist/Cwd/lib/File/Spec/Win32.pm | 7 ++++--- dist/Cwd/t/tmpdir.t | 19 ++++++++++++++++++- pp_hot.c | 2 +- sv.c | 9 +++++++++ t/op/method.t | 9 +++++++-- t/porting/podcheck.t | 10 +++++++++- 12 files changed, 97 insertions(+), 35 deletions(-) diff --git a/dist/Cwd/lib/File/Spec/Cygwin.pm b/dist/Cwd/lib/File/Spec/Cygwin.pm index b27f7b1..4c89071 100644 --- a/dist/Cwd/lib/File/Spec/Cygwin.pm +++ b/dist/Cwd/lib/File/Spec/Cygwin.pm @@ -4,7 +4,7 @@ use strict; use vars qw(@ISA $VERSION); require File::Spec::Unix; -$VERSION = '3.40'; +$VERSION = '3.41'; $VERSION =~ tr/_//; @ISA = qw(File::Spec::Unix); @@ -92,15 +92,20 @@ from the following list: $ENV{'TEMP'} C:/temp -Since Perl 5.8.0, if running under taint mode, and if the environment +If running under taint mode, and if the environment variables are tainted, they are not used. =cut -my $tmpdir; sub tmpdir { - return $tmpdir if defined $tmpdir; - $tmpdir = $_[0]->_tmpdir( $ENV{TMPDIR}, "/tmp", $ENV{'TMP'}, $ENV{'TEMP'}, 'C:/temp' ); + my $cached = $_[0]->_cached_tmpdir(qw 'TMPDIR TMP TEMP'); + return $cached if defined $cached; + $_[0]->_cache_tmpdir( + $_[0]->_tmpdir( + $ENV{TMPDIR}, "/tmp", $ENV{'TMP'}, $ENV{'TEMP'}, 'C:/temp' + ), + qw 'TMPDIR TMP TEMP' + ); } =item case_tolerant diff --git a/dist/Cwd/lib/File/Spec/Epoc.pm b/dist/Cwd/lib/File/Spec/Epoc.pm index e7faa16..7c0354f 100644 --- a/dist/Cwd/lib/File/Spec/Epoc.pm +++ b/dist/Cwd/lib/File/Spec/Epoc.pm @@ -3,7 +3,7 @@ package File::Spec::Epoc; use strict; use vars qw($VERSION @ISA); -$VERSION = '3.40'; +$VERSION = '3.41'; $VERSION =~ tr/_//; require File::Spec::Unix; @@ -20,10 +20,10 @@ File::Spec::Epoc - methods for Epoc file specs =head1 DESCRIPTION See File::Spec::Unix for a documentation of the methods provided -there. This package overrides the implementation of these methods, not +there. This package overrides the implementation of these methods, not the semantics. -This package is still work in progress ;-) +This package is still a work in progress. ;-) =cut @@ -38,7 +38,7 @@ sub case_tolerant { =item canonpath() No physical check on the filesystem, but a logical cleanup of a -path. On UNIX eliminated successive slashes and successive "/.". +path. On UNIX eliminated successive slashes and successive "/.". =back diff --git a/dist/Cwd/lib/File/Spec/Mac.pm b/dist/Cwd/lib/File/Spec/Mac.pm index 7f42171..1a8cd0f 100644 --- a/dist/Cwd/lib/File/Spec/Mac.pm +++ b/dist/Cwd/lib/File/Spec/Mac.pm @@ -4,7 +4,7 @@ use strict; use vars qw(@ISA $VERSION); require File::Spec::Unix; -$VERSION = '3.40'; +$VERSION = '3.41'; $VERSION =~ tr/_//; @ISA = qw(File::Spec::Unix); @@ -374,10 +374,10 @@ directory on your startup volume. =cut -my $tmpdir; sub tmpdir { - return $tmpdir if defined $tmpdir; - $tmpdir = $_[0]->_tmpdir( $ENV{TMPDIR} ); + my $cached = $_[0]->_cached_tmpdir('TMPDIR'); + return $cached if defined $cached; + $_[0]->_cache_tmpdir($_[0]->_tmpdir( $ENV{TMPDIR} ), 'TMPDIR'); } =item updir diff --git a/dist/Cwd/lib/File/Spec/OS2.pm b/dist/Cwd/lib/File/Spec/OS2.pm index 7f60d68..70f4d13 100644 --- a/dist/Cwd/lib/File/Spec/OS2.pm +++ b/dist/Cwd/lib/File/Spec/OS2.pm @@ -4,7 +4,7 @@ use strict; use vars qw(@ISA $VERSION); require File::Spec::Unix; -$VERSION = '3.40'; +$VERSION = '3.41'; $VERSION =~ tr/_//; @ISA = qw(File::Spec::Unix); @@ -35,11 +35,13 @@ sub _cwd { return Cwd::sys_cwd(); } -my $tmpdir; sub tmpdir { - return $tmpdir if defined $tmpdir; + my $cached = $_[0]->_cached_tmpdir(qw 'TMPDIR TEMP TMP'); + return $cached if defined $cached; my @d = @ENV{qw(TMPDIR TEMP TMP)}; # function call could autovivivy - $tmpdir = $_[0]->_tmpdir( @d, '/tmp', '/' ); + $_[0]->_cache_tmpdir( + $_[0]->_tmpdir( @d, '/tmp', '/' ), qw 'TMPDIR TEMP TMP' + ); } sub catdir { diff --git a/dist/Cwd/lib/File/Spec/Unix.pm b/dist/Cwd/lib/File/Spec/Unix.pm index a1a91b4..98b7f1b 100644 --- a/dist/Cwd/lib/File/Spec/Unix.pm +++ b/dist/Cwd/lib/File/Spec/Unix.pm @@ -3,7 +3,7 @@ package File::Spec::Unix; use strict; use vars qw($VERSION); -$VERSION = '3.40'; +$VERSION = '3.41'; $VERSION =~ tr/_//; =head1 NAME @@ -140,9 +140,22 @@ is tainted, it is not used. =cut -my $tmpdir; +my ($tmpdir, %tmpenv); +# Cache and return the calculated tmpdir, recording which env vars +# determined it. +sub _cache_tmpdir { + @tmpenv{@_[2..$#_]} = @ENV{@_[2..$#_]}; + return $tmpdir = $_[1]; +} +# Retrieve the cached tmpdir, checking first whether relevant env vars have +# changed and invalidated the cache. +sub _cached_tmpdir { + shift; + local $^W; + return if grep $ENV{$_} ne $tmpenv{$_}, @_; + return $tmpdir; +} sub _tmpdir { - return $tmpdir if defined $tmpdir; my $self = shift; my @dirlist = @_; { @@ -166,8 +179,9 @@ sub _tmpdir { } sub tmpdir { - return $tmpdir if defined $tmpdir; - $tmpdir = $_[0]->_tmpdir( $ENV{TMPDIR}, "/tmp" ); + my $cached = $_[0]->_cached_tmpdir('TMPDIR'); + return $cached if defined $cached; + $_[0]->_cache_tmpdir($_[0]->_tmpdir( $ENV{TMPDIR}, "/tmp" ), 'TMPDIR'); } =item updir diff --git a/dist/Cwd/lib/File/Spec/VMS.pm b/dist/Cwd/lib/File/Spec/VMS.pm index ce0dab7..92f85a6 100644 --- a/dist/Cwd/lib/File/Spec/VMS.pm +++ b/dist/Cwd/lib/File/Spec/VMS.pm @@ -271,21 +271,22 @@ from the following list or '' if none are writable: sys$scratch: $ENV{TMPDIR} -Since perl 5.8.0, if running under taint mode, and if $ENV{TMPDIR} +If running under taint mode, and if $ENV{TMPDIR} is tainted, it is not used. =cut -my $tmpdir; sub tmpdir { my $self = shift @_; + my $tmpdir = $self->_cached_tmpdir('TMPDIR'); return $tmpdir if defined $tmpdir; if ($self->_unix_rpt) { $tmpdir = $self->_tmpdir('/tmp', '/sys$scratch', $ENV{TMPDIR}); - return $tmpdir; } - - $tmpdir = $self->_tmpdir( 'sys$scratch:', $ENV{TMPDIR} ); + else { + $tmpdir = $self->_tmpdir( 'sys$scratch:', $ENV{TMPDIR} ); + } + $self->_cache_tmpdir($tmpdir, 'TMPDIR'); } =item updir (override) diff --git a/dist/Cwd/lib/File/Spec/Win32.pm b/dist/Cwd/lib/File/Spec/Win32.pm index ae74a26..763d09f 100644 --- a/dist/Cwd/lib/File/Spec/Win32.pm +++ b/dist/Cwd/lib/File/Spec/Win32.pm @@ -5,7 +5,7 @@ use strict; use vars qw(@ISA $VERSION); require File::Spec::Unix; -$VERSION = '3.40'; +$VERSION = '3.41'; $VERSION =~ tr/_//; @ISA = qw(File::Spec::Unix); @@ -62,13 +62,13 @@ from the following list: The SYS:/temp is preferred in Novell NetWare and the C:\system\temp for Symbian (the File::Spec::Win32 is used also for those platforms). -Since Perl 5.8.0, if running under taint mode, and if the environment +If running under taint mode, and if the environment variables are tainted, they are not used. =cut -my $tmpdir; sub tmpdir { + my $tmpdir = $_[0]->_cached_tmpdir(qw(TMPDIR TEMP TMP)); return $tmpdir if defined $tmpdir; $tmpdir = $_[0]->_tmpdir( map( $ENV{$_}, qw(TMPDIR TEMP TMP) ), 'SYS:/temp', @@ -76,6 +76,7 @@ sub tmpdir { 'C:/temp', '/tmp', '/' ); + $_[0]->_cache_tmpdir($tmpdir, qw(TMPDIR TEMP TMP)); } =item case_tolerant diff --git a/dist/Cwd/t/tmpdir.t b/dist/Cwd/t/tmpdir.t index 6f7f318..7c13da1 100644 --- a/dist/Cwd/t/tmpdir.t +++ b/dist/Cwd/t/tmpdir.t @@ -1,5 +1,5 @@ use strict; -use Test::More tests => 5; +use Test::More tests => 7; # Grab all of the plain routines from File::Spec use File::Spec; @@ -29,3 +29,20 @@ SKIP: { File::Spec::Win32->tmpdir; is(scalar keys %ENV, $num_keys, "Win32->tmpdir() shouldn't change the contents of %ENV"); + +# Changing tmpdir dynamically +for ('File::Spec', "File::Spec::Win32") { + SKIP: { + skip('sys$scratch: takes precedence over env on vms', 1) + if $^O eq 'VMS'; + local $ENV{TMPDIR} = $_->catfile($_->curdir, 'lib'); + -d $ENV{TMPDIR} && -w _ + or skip "Can't create usable TMPDIR env var", 1; + my $tmpdir1 = $_->tmpdir; + $ENV{TMPDIR} = $_->catfile($_->curdir, 't'); + -d $ENV{TMPDIR} && -w _ + or skip "Can't create usable TMPDIR env var", 1; + my $tmpdir2 = $_->tmpdir; + isn't $tmpdir2, $tmpdir1, "$_->tmpdir works with changing env"; + } +} diff --git a/pp_hot.c b/pp_hot.c index 96c93a8..e19776b 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -3116,7 +3116,7 @@ S_method_common(pTHX_ SV* meth, U32* hashp) *(PL_stack_base + TOPMARK + 1) = sv_2mortal(newRV(MUTABLE_SV(iogv))); } - /* if we got here, ob should be a reference or a glob */ + /* if we got here, ob should be an object or a glob */ if (!ob || !(SvOBJECT(ob) || (SvTYPE(ob) == SVt_PVGV && isGV_with_GP(ob) diff --git a/sv.c b/sv.c index 8d1c015..962e392 100644 --- a/sv.c +++ b/sv.c @@ -3746,6 +3746,15 @@ S_glob_assign_glob(pTHX_ SV *const dstr, SV *const sstr, const int dtype) ); } else if(mro_changes) mro_method_changed_in(GvSTASH(dstr)); + if (GvIO(dstr) && dtype == SVt_PVGV) { + DEBUG_o(Perl_deb(aTHX_ + "glob_assign_glob clearing PL_stashcache\n")); + /* It's a cache. It will rebuild itself quite happily. + It's a lot of effort to work out exactly which key (or keys) + might be invalidated by the creation of the this file handle. + */ + hv_clear(PL_stashcache); + } return; } diff --git a/t/op/method.t b/t/op/method.t index 5ed8f76..27354ce 100644 --- a/t/op/method.t +++ b/t/op/method.t @@ -13,7 +13,7 @@ BEGIN { use strict; no warnings 'once'; -plan(tests => 141); +plan(tests => 142); @A::ISA = 'B'; @B::ISA = 'C'; @@ -582,7 +582,7 @@ SKIP: { is(Colour::H1->getline(), <DATA>, 'read from a file'); is(Color::H1->getline(), <DATA>, - 'file handles take priority after typeglob assignment'); + 'file handles take priority after io-to-typeglob assignment'); *Color::H1 = *CLOSED{IO}; { @@ -595,6 +595,11 @@ SKIP: { is(Color::H1->getline(), 'method in Color::H1', 'undefining the typeglob does change object resolution'); + *Color::H1 = *Colour::H1; + + is(Color::H1->getline(), <DATA>, + 'file handles take priority after typeglob-to-typeglob assignment'); + seek Colour::H1, $fh_start, Fcntl::SEEK_SET() or die $!; seek DATA, $data_start, Fcntl::SEEK_SET() or die $!; diff --git a/t/porting/podcheck.t b/t/porting/podcheck.t index a22672b..4b4c893 100644 --- a/t/porting/podcheck.t +++ b/t/porting/podcheck.t @@ -1704,6 +1704,7 @@ foreach my $filename (@files) { skip($skip, 1) if $skip; my @diagnostics; + my @thankful_diagnostics; my $indent = ' '; my $total_known = 0; @@ -1736,6 +1737,7 @@ foreach my $filename (@files) { $files_with_unknown_issues{$filename} = 1; } elsif ($problem_count < $known_problems{$canonical}{$message}) { $diagnostic = output_thanks($filename, $known_problems{$canonical}{$message}, $problem_count, $message); + push @thankful_diagnostics, $diagnostic; } push @diagnostics, $diagnostic if $diagnostic; } @@ -1749,12 +1751,18 @@ foreach my $filename (@files) { next if $known_problems{$canonical}{$message} < 0; # Preserve negs my $diagnostic = output_thanks($filename, $known_problems{$canonical}{$message}, 0, $message); push @diagnostics, $diagnostic if $diagnostic; + push @thankful_diagnostics, $diagnostic if $diagnostic; } my $output = "POD of $filename"; $output .= ", excluding $total_known not shown known potential problems" if $total_known; - ok(@diagnostics == 0, $output); + if (@diagnostics && @diagnostics == @thankful_diagnostics) { + # Output fixed issues as passing to-do tests, so they do not + # cause failures, but t/harness still flags them. + $output .= " # TODO" + } + ok(@diagnostics == @thankful_diagnostics, $output); if (@diagnostics) { note(join "", @diagnostics, "See end of this test output for your options on silencing this"); -- Perl5 Master Repository
