From: Paul Marquess Date: Wed, 8 Jan 1997 16:55:02 +0000 (+0000) Subject: low priority patches X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ac1ad7f00e63b0423f397847dd05653ab9cea16c;p=p5sagit%2Fp5-mst-13.2.git low priority patches this set of patches isn't super critical, but it does tidy a few things up in anticipation of lexical warnings. p5p-msgid: <9701081655.AA27349@claudius.bfsec.bt.co.uk> --- diff --git a/lib/Cwd.pm b/lib/Cwd.pm index d7a4875..e93cf1a 100644 --- a/lib/Cwd.pm +++ b/lib/Cwd.pm @@ -244,36 +244,35 @@ sub _msdos_cwd { return $ENV{'PWD'}; } -my($oldw) = $^W; -$^W = 0; # assignments trigger 'subroutine redefined' warning -if ($^O eq 'VMS') { - - *cwd = \&_vms_cwd; - *getcwd = \&_vms_cwd; - *fastcwd = \&_vms_cwd; - *fastgetcwd = \&_vms_cwd; -} -elsif ($^O eq 'NT' or $^O eq 'MSWin32') { +{ + local $^W = 0; # assignments trigger 'subroutine redefined' warning - # We assume that &_NT_cwd is defined as an XSUB or in the core. - *getcwd = \&_NT_cwd; - *fastcwd = \&_NT_cwd; - *fastgetcwd = \&_NT_cwd; -} -elsif ($^O eq 'os2') { - # sys_cwd may keep the builtin command - *cwd = defined &sys_cwd ? \&sys_cwd : \&_os2_cwd; - *getcwd = defined &sys_cwd ? \&sys_cwd : \&_os2_cwd; - *fastgetcwd = defined &sys_cwd ? \&sys_cwd : \&_os2_cwd; - *fastcwd = defined &sys_cwd ? \&sys_cwd : \&_os2_cwd; -} -elsif ($^O eq 'msdos') { - *cwd = \&_msdos_cwd; - *getcwd = \&_msdos_cwd; - *fastgetcwd = \&_msdos_cwd; - *fastcwd = \&_msdos_cwd; + if ($^O eq 'VMS') { + *cwd = \&_vms_cwd; + *getcwd = \&_vms_cwd; + *fastcwd = \&_vms_cwd; + *fastgetcwd = \&_vms_cwd; + } + elsif ($^O eq 'NT' or $^O eq 'MSWin32') { + # We assume that &_NT_cwd is defined as an XSUB or in the core. + *getcwd = \&_NT_cwd; + *fastcwd = \&_NT_cwd; + *fastgetcwd = \&_NT_cwd; + } + elsif ($^O eq 'os2') { + # sys_cwd may keep the builtin command + *cwd = defined &sys_cwd ? \&sys_cwd : \&_os2_cwd; + *getcwd = defined &sys_cwd ? \&sys_cwd : \&_os2_cwd; + *fastgetcwd = defined &sys_cwd ? \&sys_cwd : \&_os2_cwd; + *fastcwd = defined &sys_cwd ? \&sys_cwd : \&_os2_cwd; + } + elsif ($^O eq 'msdos') { + *cwd = \&_msdos_cwd; + *getcwd = \&_msdos_cwd; + *fastgetcwd = \&_msdos_cwd; + *fastcwd = \&_msdos_cwd; + } } -$^W = $oldw; # package main; eval join('',) || die $@; # quick test diff --git a/t/comp/redef.t b/t/comp/redef.t index 6a73ae1..ad28bfd 100755 --- a/t/comp/redef.t +++ b/t/comp/redef.t @@ -1,9 +1,8 @@ -#!./perl +#!./perl -w # # Contributed by Graham Barr BEGIN { - $^W = 1; $warn = ""; $SIG{__WARN__} = sub { $warn .= join("",@_) } } diff --git a/t/lib/db-btree.t b/t/lib/db-btree.t index 7dea2ed..0e2a7c3 100755 --- a/t/lib/db-btree.t +++ b/t/lib/db-btree.t @@ -52,10 +52,11 @@ ok(3, $dbh->{psize} == 0) ; ok(4, $dbh->{lorder} == 0) ; ok(5, $dbh->{minkeypage} == 0) ; ok(6, $dbh->{maxkeypage} == 0) ; -$^W = 0 ; -ok(7, $dbh->{compare} == undef) ; -ok(8, $dbh->{prefix} == undef) ; -$^W = 1 ; +{ + local $^W = 0 ; + ok(7, $dbh->{compare} == undef) ; + ok(8, $dbh->{prefix} == undef) ; +} $dbh->{flags} = 3000 ; ok(9, $dbh->{flags} == 3000) ; @@ -240,10 +241,8 @@ $status = $X->del('') ; ok(42, $status == 0 ); # Make sure that the key deleted, cannot be retrieved -$^W = 0 ; -ok(43, $h{'q'} eq undef) ; -ok(44, $h{''} eq undef) ; -$^W = 1 ; +ok(43, ! defined $h{'q'}) ; +ok(44, ! defined $h{''}) ; undef $X ; untie %h ; @@ -430,7 +429,8 @@ $Dfile2 = "btree2" ; $Dfile3 = "btree3" ; $dbh1 = new DB_File::BTREEINFO ; -$dbh1->{compare} = sub { $_[0] <=> $_[1] } ; +{ local $^W = 0 ; + $dbh1->{compare} = sub { $_[0] <=> $_[1] } ; } $dbh2 = new DB_File::BTREEINFO ; $dbh2->{compare} = sub { $_[0] cmp $_[1] } ; @@ -444,16 +444,14 @@ tie(%g, 'DB_File',$Dfile2, O_RDWR|O_CREAT, 0640, $dbh2 ) ; tie(%k, 'DB_File',$Dfile3, O_RDWR|O_CREAT, 0640, $dbh3 ) ; @Keys = qw( 0123 12 -1234 9 987654321 def ) ; -$^W = 0 ; -@srt_1 = sort { $a <=> $b } @Keys ; -$^W = 1 ; +{ local $^W = 0 ; + @srt_1 = sort { $a <=> $b } @Keys ; } @srt_2 = sort { $a cmp $b } @Keys ; @srt_3 = sort { length $a <=> length $b } @Keys ; foreach (@Keys) { - $^W = 0 ; - $h{$_} = 1 ; - $^W = 1 ; + { local $^W = 0 ; + $h{$_} = 1 ; } $g{$_} = 1 ; $k{$_} = 1 ; }