From 735631af6fd7ee0a0db0185decce87cabe3eb134 Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Tue, 19 Oct 2010 20:37:06 +0200 Subject: [PATCH] Convert Fcntl, File::Glob, I18N::Langinfo, POSIX and Socket to croak_on_error. This is possible because all 5 use ExtUtils::Constant::ProxySubs, so the constant() routine is only used for error conditions. --- ext/Fcntl/Fcntl.pm | 9 +-------- ext/Fcntl/Makefile.PL | 4 ++-- ext/File-Glob/Glob.pm | 10 ++-------- ext/File-Glob/Makefile.PL | 4 ++-- ext/I18N-Langinfo/Langinfo.pm | 16 ++-------------- ext/I18N-Langinfo/Makefile.PL | 4 ++-- ext/POSIX/Makefile.PL | 4 ++-- ext/POSIX/lib/POSIX.pm | 10 ++-------- ext/Socket/Makefile.PL | 4 ++-- ext/Socket/Socket.pm | 9 ++------- 10 files changed, 19 insertions(+), 55 deletions(-) diff --git a/ext/Fcntl/Fcntl.pm b/ext/Fcntl/Fcntl.pm index 970735c..6e1c1af 100644 --- a/ext/Fcntl/Fcntl.pm +++ b/ext/Fcntl/Fcntl.pm @@ -186,14 +186,7 @@ XSLoader::load(); sub AUTOLOAD { (my $constname = $AUTOLOAD) =~ s/.*:://; die "&Fcntl::constant not defined" if $constname eq 'constant'; - my ($error, $val) = constant($constname); - if ($error) { - my (undef,$file,$line) = caller; - die "$error at $file line $line\n"; - } - no strict 'refs'; - *$AUTOLOAD = sub { $val }; - goto &$AUTOLOAD; + constant($constname); } 1; diff --git a/ext/Fcntl/Makefile.PL b/ext/Fcntl/Makefile.PL index 2bed754..470291f 100644 --- a/ext/Fcntl/Makefile.PL +++ b/ext/Fcntl/Makefile.PL @@ -1,5 +1,5 @@ use ExtUtils::MakeMaker; -use ExtUtils::Constant 0.11 'WriteConstants'; +use ExtUtils::Constant 0.23 'WriteConstants'; WriteMakefile( NAME => 'Fcntl', XSPROTOARG => '-noprototypes', # XXX remove later? @@ -39,7 +39,7 @@ my @names = (qw( {name=>"SEEK_END", default=>["IV", "2"]}, {name=>"_S_IFMT", macro=>"S_IFMT", value=>"S_IFMT"}); WriteConstants( - PROXYSUBS => 1, + PROXYSUBS => {croak_on_error => 1}, NAME => 'Fcntl', NAMES => \@names, ); diff --git a/ext/File-Glob/Glob.pm b/ext/File-Glob/Glob.pm index 4219c7e..acb53d6 100644 --- a/ext/File-Glob/Glob.pm +++ b/ext/File-Glob/Glob.pm @@ -37,7 +37,7 @@ use feature 'switch'; @EXPORT_OK = (@{$EXPORT_TAGS{'glob'}}, 'csh_glob'); -$VERSION = '1.09'; +$VERSION = '1.10'; sub import { require Exporter; @@ -63,13 +63,7 @@ sub AUTOLOAD { my $constname; ($constname = $AUTOLOAD) =~ s/.*:://; - my ($error, $val) = constant($constname); - if ($error) { - require Carp; - Carp::croak($error); - } - eval "sub $AUTOLOAD { $val }"; - goto &$AUTOLOAD; + constant($constname); } XSLoader::load(); diff --git a/ext/File-Glob/Makefile.PL b/ext/File-Glob/Makefile.PL index 790613b..5f2b4f3 100644 --- a/ext/File-Glob/Makefile.PL +++ b/ext/File-Glob/Makefile.PL @@ -1,5 +1,5 @@ use ExtUtils::MakeMaker; -use ExtUtils::Constant 0.11 'WriteConstants'; +use ExtUtils::Constant 0.23 'WriteConstants'; WriteMakefile( NAME => 'File::Glob', VERSION_FROM => 'Glob.pm', @@ -22,7 +22,7 @@ sub MY::cflags { } WriteConstants( - PROXYSUBS => 1, + PROXYSUBS => {croak_on_error => 1}, NAME => 'File::Glob', NAMES => [qw(GLOB_ABEND GLOB_ALPHASORT GLOB_ALTDIRFUNC GLOB_BRACE GLOB_ERR GLOB_LIMIT GLOB_MARK GLOB_NOCASE GLOB_NOCHECK GLOB_NOMAGIC diff --git a/ext/I18N-Langinfo/Langinfo.pm b/ext/I18N-Langinfo/Langinfo.pm index 51d0d4d..48e44ce 100644 --- a/ext/I18N-Langinfo/Langinfo.pm +++ b/ext/I18N-Langinfo/Langinfo.pm @@ -72,7 +72,7 @@ our @EXPORT_OK = qw( YESSTR ); -our $VERSION = '0.06'; +our $VERSION = '0.07'; sub AUTOLOAD { # This AUTOLOAD is used to 'autoload' constants from the constant() @@ -82,19 +82,7 @@ sub AUTOLOAD { our $AUTOLOAD; ($constname = $AUTOLOAD) =~ s/.*:://; croak "&I18N::Langinfo::constant not defined" if $constname eq 'constant'; - my ($error, $val) = constant($constname); - if ($error) { croak $error; } - { - no strict 'refs'; - # Fixed between 5.005_53 and 5.005_61 -#XXX if ($] >= 5.00561) { -#XXX *$AUTOLOAD = sub () { $val }; -#XXX } -#XXX else { - *$AUTOLOAD = sub { $val }; -#XXX } - } - goto &$AUTOLOAD; + constant($constname); } XSLoader::load(); diff --git a/ext/I18N-Langinfo/Makefile.PL b/ext/I18N-Langinfo/Makefile.PL index 56c3aee..2cc590a 100644 --- a/ext/I18N-Langinfo/Makefile.PL +++ b/ext/I18N-Langinfo/Makefile.PL @@ -1,5 +1,5 @@ use ExtUtils::MakeMaker; -use ExtUtils::Constant; +use ExtUtils::Constant 0.23; WriteMakefile( 'NAME' => 'I18N::Langinfo', @@ -30,7 +30,7 @@ push @names, # This lot are only enums for __SVR4_I386_ABI_L1__: foreach qw (CRNCYSTR THOUSEP RADIXCHAR); ExtUtils::Constant::WriteConstants( - PROXYSUBS => 1, + PROXYSUBS => {croak_on_error => 1}, NAME => 'I18N::Langinfo', NAMES => \@names, ); diff --git a/ext/POSIX/Makefile.PL b/ext/POSIX/Makefile.PL index 4a2c08a..0e994a6 100644 --- a/ext/POSIX/Makefile.PL +++ b/ext/POSIX/Makefile.PL @@ -1,6 +1,6 @@ # Expect this line to be read by t/posix.t, don't change it use ExtUtils::MakeMaker; -use ExtUtils::Constant 0.11 'WriteConstants'; +use ExtUtils::Constant 0.23 'WriteConstants'; use Config; my $rt_signals; if ($Config{sig_name} =~ /\bRTMIN\b/ && $Config{sig_name} =~ /\bRTMAX\b/) { @@ -119,7 +119,7 @@ if ($rt_signals) { } WriteConstants( - PROXYSUBS => 1, + PROXYSUBS => {croak_on_error => 1}, NAME => 'POSIX', NAMES => \@names, ); diff --git a/ext/POSIX/lib/POSIX.pm b/ext/POSIX/lib/POSIX.pm index fbbbcd1..1071b3b 100644 --- a/ext/POSIX/lib/POSIX.pm +++ b/ext/POSIX/lib/POSIX.pm @@ -4,7 +4,7 @@ use warnings; our(@ISA, %EXPORT_TAGS, @EXPORT_OK, @EXPORT, $AUTOLOAD, %SIGRT) = (); -our $VERSION = "1.21"; +our $VERSION = "1.22"; use AutoLoader; @@ -36,21 +36,15 @@ sub usage; XSLoader::load(); sub AUTOLOAD { - no strict; no warnings 'uninitialized'; if ($AUTOLOAD =~ /::(_?[a-z])/) { # require AutoLoader; $AutoLoader::AUTOLOAD = $AUTOLOAD; goto &AutoLoader::AUTOLOAD } - local $! = 0; my $constname = $AUTOLOAD; $constname =~ s/.*:://; - my ($error, $val) = constant($constname); - croak $error if $error; - *$AUTOLOAD = sub { $val }; - - goto &$AUTOLOAD; + constant($constname); } package POSIX::SigAction; diff --git a/ext/Socket/Makefile.PL b/ext/Socket/Makefile.PL index 043f482..d81a5c3 100644 --- a/ext/Socket/Makefile.PL +++ b/ext/Socket/Makefile.PL @@ -1,5 +1,5 @@ use ExtUtils::MakeMaker; -use ExtUtils::Constant 0.11 'WriteConstants'; +use ExtUtils::Constant 0.23 'WriteConstants'; use Config; WriteMakefile( NAME => 'Socket', @@ -72,7 +72,7 @@ push @names, foreach qw(INADDR_ANY INADDR_LOOPBACK INADDR_NONE INADDR_BROADCAST); WriteConstants( - PROXYSUBS => 1, + PROXYSUBS => {croak_on_error => 1}, NAME => 'Socket', NAMES => \@names, ); diff --git a/ext/Socket/Socket.pm b/ext/Socket/Socket.pm index 1cffe6b..a46d2fe 100644 --- a/ext/Socket/Socket.pm +++ b/ext/Socket/Socket.pm @@ -1,7 +1,7 @@ package Socket; our($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); -$VERSION = "1.90"; +$VERSION = "1.91"; =head1 NAME @@ -435,12 +435,7 @@ sub AUTOLOAD { my($constname); ($constname = $AUTOLOAD) =~ s/.*:://; croak "&Socket::constant not defined" if $constname eq 'constant'; - my ($error, $val) = constant($constname); - if ($error) { - croak $error; - } - *$AUTOLOAD = sub { $val }; - goto &$AUTOLOAD; + constant($constname); } XSLoader::load(); -- 2.7.4