diff options
author | Paul Marquess <pmarquess@bfsec.bt.co.uk> | 1997-01-08 16:55:02 +0000 |
---|---|---|
committer | Chip Salzenberg <chip@atlantic.net> | 1997-01-16 07:24:00 +1200 |
commit | ac1ad7f00e63b0423f397847dd05653ab9cea16c (patch) | |
tree | 82498d4107a06f574c21dadef227a2ce8d8f609f | |
parent | 3f73d1e9321c4a88755d416e8a3bef027db02853 (diff) | |
download | perl-ac1ad7f00e63b0423f397847dd05653ab9cea16c.tar.gz |
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>
-rw-r--r-- | lib/Cwd.pm | 55 | ||||
-rwxr-xr-x | t/comp/redef.t | 3 | ||||
-rwxr-xr-x | t/lib/db-btree.t | 28 |
3 files changed, 41 insertions, 45 deletions
diff --git a/lib/Cwd.pm b/lib/Cwd.pm index d7a4875574..e93cf1a0a9 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('',<DATA>) || die $@; # quick test diff --git a/t/comp/redef.t b/t/comp/redef.t index 6a73ae1c2e..ad28bfd5e2 100755 --- a/t/comp/redef.t +++ b/t/comp/redef.t @@ -1,9 +1,8 @@ -#!./perl +#!./perl -w # # Contributed by Graham Barr <Graham.Barr@tiuk.ti.com> BEGIN { - $^W = 1; $warn = ""; $SIG{__WARN__} = sub { $warn .= join("",@_) } } diff --git a/t/lib/db-btree.t b/t/lib/db-btree.t index 7dea2ed5ea..0e2a7c34eb 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 ; } |