From: oracle@pcr8.pcr.com Date: Mon, 19 Jul 1999 18:39:13 +0000 (-0400) Subject: Use Errno more extensively so that error X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=98a6f11e5caa62333286d697f0f5df32e778e17a;p=p5sagit%2Fp5-mst-13.2.git Use Errno more extensively so that error messages are more portable (another way would be to muck around with LC_MESSAGES). Problem reported in To: perl5-porters@perl.org Subject: [ID 19990719.003] LC_MESSAGES breaks h2xs autoloaded constants on AIX 4.1.4 Message-Id: <9907192239.AA44990@pcr8.pcr.com> p4raw-id: //depot/cfgperl@3716 --- diff --git a/ext/DB_File/DB_File.pm b/ext/DB_File/DB_File.pm index 7dd1d26..90a82b8 100644 --- a/ext/DB_File/DB_File.pm +++ b/ext/DB_File/DB_File.pm @@ -15,6 +15,7 @@ require 5.003 ; use strict; use Carp; +use Errno; require Tie::Hash; @DB_File::HASHINFO::ISA = qw(Tie::Hash); @@ -196,7 +197,7 @@ sub AUTOLOAD { ($constname = $AUTOLOAD) =~ s/.*:://; my $val = constant($constname, @_ ? $_[0] : 0); if ($! != 0) { - if ($! =~ /Invalid/) { + if ($!{EINVAL} || $! =~ /Invalid/) { $AutoLoader::AUTOLOAD = $AUTOLOAD; goto &AutoLoader::AUTOLOAD; } diff --git a/ext/Fcntl/Fcntl.pm b/ext/Fcntl/Fcntl.pm index 00f834d..664c2cb 100644 --- a/ext/Fcntl/Fcntl.pm +++ b/ext/Fcntl/Fcntl.pm @@ -44,6 +44,7 @@ what constants are implemented in your system. use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $AUTOLOAD); +use Errno; require Exporter; require DynaLoader; @ISA = qw(Exporter DynaLoader); @@ -122,7 +123,7 @@ sub AUTOLOAD { (my $constname = $AUTOLOAD) =~ s/.*:://; my $val = constant($constname, 0); if ($! != 0) { - if ($! =~ /Invalid/) { + if ($!{EINVAL} || $! =~ /Invalid/) { $AutoLoader::AUTOLOAD = $AUTOLOAD; goto &AutoLoader::AUTOLOAD; } diff --git a/ext/GDBM_File/GDBM_File.pm b/ext/GDBM_File/GDBM_File.pm index aff0152..1d90a34 100644 --- a/ext/GDBM_File/GDBM_File.pm +++ b/ext/GDBM_File/GDBM_File.pm @@ -43,6 +43,7 @@ use strict; use vars qw($VERSION @ISA @EXPORT $AUTOLOAD); require Carp; +use Errno; require Tie::Hash; require Exporter; use AutoLoader; @@ -66,7 +67,7 @@ sub AUTOLOAD { ($constname = $AUTOLOAD) =~ s/.*:://; my $val = constant($constname, @_ ? $_[0] : 0); if ($! != 0) { - if ($! =~ /Invalid/) { + if ($!{EINVAL} || $! =~ /Invalid/) { $AutoLoader::AUTOLOAD = $AUTOLOAD; goto &AutoLoader::AUTOLOAD; } diff --git a/jpl/JNI/JNI.pm b/jpl/JNI/JNI.pm index 7797ad6..455a130 100644 --- a/jpl/JNI/JNI.pm +++ b/jpl/JNI/JNI.pm @@ -2,6 +2,7 @@ package JNI; use strict; use Carp; +use Errno; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $AUTOLOAD $JVM @JVM_ARGS $JAVALIB); require Exporter; @@ -198,7 +199,7 @@ sub AUTOLOAD { ($constname = $AUTOLOAD) =~ s/.*:://; my $val = constant($constname, @_ ? $_[0] : 0); if ($! != 0) { - if ($! =~ /Invalid/) { + if ($!{EINVAL} || $! =~ /Invalid/) { $AutoLoader::AUTOLOAD = $AUTOLOAD; goto &AutoLoader::AUTOLOAD; } diff --git a/lib/AutoLoader.pm b/lib/AutoLoader.pm index 488030a..1ca3b14 100644 --- a/lib/AutoLoader.pm +++ b/lib/AutoLoader.pm @@ -219,13 +219,14 @@ lines: use AutoLoader; use Carp; + use Errno; sub AUTOLOAD { my $sub = $AUTOLOAD; (my $constname = $sub) =~ s/.*:://; my $val = constant($constname, @_ ? $_[0] : 0); if ($! != 0) { - if ($! =~ /Invalid/) { + if ($!{EINVAL} || $! =~ /Invalid/) { $AutoLoader::AUTOLOAD = $sub; goto &AutoLoader::AUTOLOAD; } diff --git a/lib/CPAN.pm b/lib/CPAN.pm index 3f3b980..401660e 100644 --- a/lib/CPAN.pm +++ b/lib/CPAN.pm @@ -19,6 +19,7 @@ use Config (); use Cwd (); use DirHandle; use Exporter (); +use Errno (); use ExtUtils::MakeMaker (); # $SelfLoader::DEBUG=1; use File::Basename (); use File::Copy (); @@ -575,7 +576,7 @@ Please make sure the directory exists and is writable. } my $fh; unless ($fh = FileHandle->new(">$lockfile")) { - if ($! =~ /Permission/) { + if ($!{EACCES} || $! =~ /Permission/) { my $incc = $INC{'CPAN/Config.pm'}; my $myincc = MM->catfile($ENV{HOME},'.cpan','CPAN','MyConfig.pm'); $CPAN::Frontend->myprint(qq{ diff --git a/pod/perllocale.pod b/pod/perllocale.pod index 08b50e0..0447b26 100644 --- a/pod/perllocale.pod +++ b/pod/perllocale.pod @@ -608,8 +608,12 @@ obeys the current C locale. The remaining locale category, C (possibly supplemented by others in particular implementations) is not currently used by -Perl--except possibly to affect the behavior of library functions called -by extensions outside the standard Perl distribution. +Perl--except possibly to affect the behavior of library functions +called by extensions outside the standard Perl distribution and by the +operating system and its utilities. Note especially that the string +value of C<$!> and the error messages given by external utilities may +be changed by C. If you want to have portable error +codes, use the Errno extension. =head1 SECURITY diff --git a/utils/h2xs.PL b/utils/h2xs.PL index 3650512..710242a 100644 --- a/utils/h2xs.PL +++ b/utils/h2xs.PL @@ -117,7 +117,7 @@ Specifies a name to be used for the extension, e.g., S<-n RPC::DCE> Specify a prefix which should be removed from the Perl function names, e.g., S<-p sec_rgy_> This sets up the XS B keyword and removes the prefix from functions that are -autoloaded via the C mechansim. +autoloaded via the C mechanism. =item B<-s> I @@ -419,6 +419,7 @@ else{ # will want Carp. print PM <<'END'; use Carp; +use Errno; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $AUTOLOAD); END } @@ -471,7 +472,7 @@ sub AUTOLOAD { croak "&$module::constant not defined" if \$constname eq 'constant'; my \$val = constant(\$constname, \@_ ? \$_[0] : 0); if (\$! != 0) { - if (\$! =~ /Invalid/) { + if (\$!{EINVAL} || \$! =~ /Invalid/) { \$AutoLoader::AUTOLOAD = \$AUTOLOAD; goto &AutoLoader::AUTOLOAD; }