Subject: | is_arg_ok modifies the global $_, which causes action at a distance errors |
The is_arg_ok function has the following code:
eval{$_ = fileno($_[0]);};
which modifies the global $_, resulting in strange and mysterious errors elsewhere.
Attached is a patch which fixes this, and also reduces the number of times that fileno is called.
eval{$_ = fileno($_[0]);};
which modifies the global $_, resulting in strange and mysterious errors elsewhere.
Attached is a patch which fixes this, and also reduces the number of times that fileno is called.
Subject: | FileHandle-Fmode-0.11.patch |
# This is a patch for FileHandle-Fmode-0.11.orig to update it to FileHandle-Fmode-0.11
#
# To apply this patch:
# STEP 1: Chdir to the source directory.
# STEP 2: Run the 'applypatch' program with this patch file as input.
#
# If you do not have 'applypatch', it is part of the 'makepatch' package
# that you can fetch from the Comprehensive Perl Archive Network:
# http://www.perl.com/CPAN/authors/Johan_Vromans/makepatch-x.y.tar.gz
# In the above URL, 'x' should be 2 or higher.
#
# To apply this patch without the use of 'applypatch':
# STEP 1: Chdir to the source directory.
# STEP 2: Run the 'patch' program with this file as input.
#
#### End of Preamble ####
#### Patch data follows ####
diff -c 'FileHandle-Fmode-0.11.orig/Fmode.pm' 'FileHandle-Fmode-0.11/Fmode.pm'
Index: ./Fmode.pm
*** ./Fmode.pm Fri Sep 26 08:43:20 2008
--- ./Fmode.pm Wed Oct 3 12:03:04 2012
***************
*** 21,30 ****
my $is_win32 = $^O =~ /mswin32/i ? 1 : 0;
sub is_arg_ok {
! eval{$_ = fileno($_[0]);};
if($@) {return 0}
! if(defined(fileno($_[0]))) {
! if(fileno($_[0]) == -1) {
if($] < 5.007) {return 0}
return 1;
}
--- 21,30 ----
my $is_win32 = $^O =~ /mswin32/i ? 1 : 0;
sub is_arg_ok {
! my $fileno = eval{fileno($_[0])};
if($@) {return 0}
! if(defined($fileno)) {
! if( $fileno == -1) {
if($] < 5.007) {return 0}
return 1;
}
***************
*** 34,41 ****
}
sub is_RO {
! if(!defined(fileno($_[0]))) {die "Not an open filehandle"}
! if(fileno($_[0]) == -1) {
if($] < 5.007) {die "Illegal fileno() return"}
if(perliol_readable($_[0]) && !perliol_writable($_[0])) {return 1}
return 0;
--- 34,42 ----
}
sub is_RO {
! my $fileno = fileno($_[0]);
! if(!defined( $fileno)) {die "Not an open filehandle"}
! if( $fileno == -1) {
if($] < 5.007) {die "Illegal fileno() return"}
if(perliol_readable($_[0]) && !perliol_writable($_[0])) {return 1}
return 0;
***************
*** 50,57 ****
}
sub is_WO {
! if(!defined(fileno($_[0]))) {die "Not an open filehandle"}
! if(fileno($_[0]) == -1) {
if($] < 5.007) {die "Illegal fileno() return"}
if(!perliol_readable($_[0]) && perliol_writable($_[0])) {return 1}
return 0;
--- 51,59 ----
}
sub is_WO {
! my $fileno = fileno($_[0]);
! if(!defined( $fileno)) {die "Not an open filehandle"}
! if( $fileno == -1) {
if($] < 5.007) {die "Illegal fileno() return"}
if(!perliol_readable($_[0]) && perliol_writable($_[0])) {return 1}
return 0;
***************
*** 76,83 ****
}
sub is_RW {
! if(!defined(fileno($_[0]))) {die "Not an open filehandle"}
! if(fileno($_[0]) == -1) {
if($] < 5.007) {die "Illegal fileno() return"}
if(perliol_readable($_[0]) && perliol_writable($_[0])) {return 1}
return 0;
--- 78,86 ----
}
sub is_RW {
! my $fileno = fileno($_[0]);
! if(!defined($fileno)) {die "Not an open filehandle"}
! if($fileno == -1) {
if($] < 5.007) {die "Illegal fileno() return"}
if(perliol_readable($_[0]) && perliol_writable($_[0])) {return 1}
return 0;
***************
*** 92,99 ****
}
sub is_A {
! if(!defined(fileno($_[0]))) {die "Not an open filehandle"}
! if(fileno($_[0]) == -1) {
if($] < 5.007) {die "Illegal fileno() return"}
return is_appendable($_[0]);
}
--- 95,103 ----
}
sub is_A {
! my $fileno = fileno($_[0]);
! if(!defined($fileno)) {die "Not an open filehandle"}
! if($fileno == -1) {
if($] < 5.007) {die "Illegal fileno() return"}
return is_appendable($_[0]);
}
#### End of Patch data ####
#### ApplyPatch data follows ####
# Data version : 1.0
# Date generated : Wed Oct 3 12:03:42 2012
# Generated by : makepatch 2.04
# Recurse directories : Yes
# Excluded files : (\A|/).*\~\Z
# (\A|/).*\.a\Z
# (\A|/).*\.bak\Z
# (\A|/).*\.BAK\Z
# (\A|/).*\.elc\Z
# (\A|/).*\.exe\Z
# (\A|/).*\.gz\Z
# (\A|/).*\.ln\Z
# (\A|/).*\.o\Z
# (\A|/).*\.obj\Z
# (\A|/).*\.olb\Z
# (\A|/).*\.old\Z
# (\A|/).*\.orig\Z
# (\A|/).*\.rej\Z
# (\A|/).*\.so\Z
# (\A|/).*\.Z\Z
# (\A|/)\.del\-.*\Z
# (\A|/)\.make\.state\Z
# (\A|/)\.nse_depinfo\Z
# (\A|/)core\Z
# (\A|/)tags\Z
# (\A|/)TAGS\Z
# p 'Fmode.pm' 6294 1349280184 0100644
#### End of ApplyPatch data ####
#### End of Patch kit [created: Wed Oct 3 12:03:42 2012] ####
#### Patch checksum: 141 4372 17867 ####
#### Checksum: 159 5081 11101 ####