diff options
author | Nicholas Clark <nick@ccl4.org> | 2001-06-17 01:16:05 +0100 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2001-06-16 22:27:48 +0000 |
commit | 72f7b9a1041f8cd00a817b387850fef64f11d90e (patch) | |
tree | 2894b3b2dcc54e2f1486b6e0345a07670115c771 /ext/File | |
parent | 9038e305e40aa7aacfc52a55cb7265c4f175011b (diff) | |
download | perl-72f7b9a1041f8cd00a817b387850fef64f11d90e.tar.gz |
Re: [PATCH] Re: perl@10611
Message-ID: <20010617001605.V98663@plum.flirble.org>
p4raw-id: //depot/perl@10648
Diffstat (limited to 'ext/File')
-rw-r--r-- | ext/File/Glob/Glob.pm | 21 | ||||
-rw-r--r-- | ext/File/Glob/Glob.xs | 160 | ||||
-rw-r--r-- | ext/File/Glob/Makefile.PL | 11 |
3 files changed, 20 insertions, 172 deletions
diff --git a/ext/File/Glob/Glob.pm b/ext/File/Glob/Glob.pm index 78a8fb417a..cad8131f28 100644 --- a/ext/File/Glob/Glob.pm +++ b/ext/File/Glob/Glob.pm @@ -6,7 +6,7 @@ our($VERSION, @ISA, @EXPORT_OK, @EXPORT_FAIL, %EXPORT_TAGS, use XSLoader (); -@ISA = qw(Exporter AutoLoader); +@ISA = qw(Exporter); # NOTE: The glob() export is only here for compatibility with 5.6.0. # csh_glob() should not be used directly, unless you know what you're doing. @@ -56,7 +56,7 @@ use XSLoader (); ) ], ); -$VERSION = '1.0'; +$VERSION = '1.01'; sub import { require Exporter; @@ -84,17 +84,10 @@ sub AUTOLOAD { my $constname; ($constname = $AUTOLOAD) =~ s/.*:://; - my $val = constant($constname, @_ ? $_[0] : 0); - if ($! != 0) { - if ($! =~ /Invalid/ || $!{EINVAL}) { - require AutoLoader; - $AutoLoader::AUTOLOAD = $AUTOLOAD; - goto &AutoLoader::AUTOLOAD; - } - else { - require Carp; - Carp::croak("Your vendor has not defined File::Glob macro $constname"); - } + my ($error, $val) = constant($constname); + if ($error) { + require Carp; + Carp::croak($error); } eval "sub $AUTOLOAD { $val }"; goto &$AUTOLOAD; @@ -105,7 +98,7 @@ XSLoader::load 'File::Glob', $VERSION; # Preloaded methods go here. sub GLOB_ERROR { - return constant('GLOB_ERROR', 0); + return (constant('GLOB_ERROR'))[1]; } sub GLOB_CSH () { diff --git a/ext/File/Glob/Glob.xs b/ext/File/Glob/Glob.xs index ce03ef85d3..85ddf02e6d 100644 --- a/ext/File/Glob/Glob.xs +++ b/ext/File/Glob/Glob.xs @@ -7,159 +7,7 @@ /* XXX: need some thread awareness */ static int GLOB_ERROR = 0; -static double -constant(char *name, int arg) -{ - errno = 0; - if (strlen(name) <= 5) - goto not_there; - switch (*(name+5)) { - case 'A': - if (strEQ(name, "GLOB_ABEND")) -#ifdef GLOB_ABEND - return GLOB_ABEND; -#else - goto not_there; -#endif - if (strEQ(name, "GLOB_ALPHASORT")) -#ifdef GLOB_ALPHASORT - return GLOB_ALPHASORT; -#else - goto not_there; -#endif - if (strEQ(name, "GLOB_ALTDIRFUNC")) -#ifdef GLOB_ALTDIRFUNC - return GLOB_ALTDIRFUNC; -#else - goto not_there; -#endif - break; - case 'B': - if (strEQ(name, "GLOB_BRACE")) -#ifdef GLOB_BRACE - return GLOB_BRACE; -#else - goto not_there; -#endif - break; - case 'C': - break; - case 'D': - break; - case 'E': - if (strEQ(name, "GLOB_ERR")) -#ifdef GLOB_ERR - return GLOB_ERR; -#else - goto not_there; -#endif - if (strEQ(name, "GLOB_ERROR")) - return GLOB_ERROR; - break; - case 'F': - break; - case 'G': - break; - case 'H': - break; - case 'I': - break; - case 'J': - break; - case 'K': - break; - case 'L': - if (strEQ(name, "GLOB_LIMIT")) -#ifdef GLOB_LIMIT - return GLOB_LIMIT; -#else - goto not_there; -#endif - break; - case 'M': - if (strEQ(name, "GLOB_MARK")) -#ifdef GLOB_MARK - return GLOB_MARK; -#else - goto not_there; -#endif - break; - case 'N': - if (strEQ(name, "GLOB_NOCASE")) -#ifdef GLOB_NOCASE - return GLOB_NOCASE; -#else - goto not_there; -#endif - if (strEQ(name, "GLOB_NOCHECK")) -#ifdef GLOB_NOCHECK - return GLOB_NOCHECK; -#else - goto not_there; -#endif - if (strEQ(name, "GLOB_NOMAGIC")) -#ifdef GLOB_NOMAGIC - return GLOB_NOMAGIC; -#else - goto not_there; -#endif - if (strEQ(name, "GLOB_NOSORT")) -#ifdef GLOB_NOSORT - return GLOB_NOSORT; -#else - goto not_there; -#endif - if (strEQ(name, "GLOB_NOSPACE")) -#ifdef GLOB_NOSPACE - return GLOB_NOSPACE; -#else - goto not_there; -#endif - break; - case 'O': - break; - case 'P': - break; - case 'Q': - if (strEQ(name, "GLOB_QUOTE")) -#ifdef GLOB_QUOTE - return GLOB_QUOTE; -#else - goto not_there; -#endif - break; - case 'R': - break; - case 'S': - break; - case 'T': - if (strEQ(name, "GLOB_TILDE")) -#ifdef GLOB_TILDE - return GLOB_TILDE; -#else - goto not_there; -#endif - break; - case 'U': - break; - case 'V': - break; - case 'W': - break; - case 'X': - break; - case 'Y': - break; - case 'Z': - break; - } - errno = EINVAL; - return 0; - -not_there: - errno = ENOENT; - return 0; -} +#include "constants.c" #ifdef WIN32 #define errfunc NULL @@ -207,8 +55,4 @@ PPCODE: bsd_globfree(&pglob); } -double -constant(name,arg) - char *name - int arg -PROTOTYPE: $$ +INCLUDE: constants.xs diff --git a/ext/File/Glob/Makefile.PL b/ext/File/Glob/Makefile.PL index 98781c98e7..b73a0c483e 100644 --- a/ext/File/Glob/Makefile.PL +++ b/ext/File/Glob/Makefile.PL @@ -1,9 +1,11 @@ use ExtUtils::MakeMaker; +use ExtUtils::Constant 0.08 'WriteConstants'; WriteMakefile( NAME => 'File::Glob', VERSION_FROM => 'Glob.pm', MAN3PODS => {}, # Pods will be built by installman. OBJECT => 'bsd_glob$(OBJ_EXT) Glob$(OBJ_EXT)', + realclean => {FILES=> 'constants.c constants.xs'}, ## uncomment for glob debugging (will cause make test to fail) # DEFINE => '-DGLOB_DEBUG', @@ -19,3 +21,12 @@ sub MY::cflags { } $inherited; } + +WriteConstants( + 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 + GLOB_NOSORT GLOB_NOSPACE GLOB_QUOTE GLOB_TILDE), + {name=>"GLOB_ERROR", macro=>1}], + BREAKOUT_AT => 8, +); |