From: Benjamin Sugars Date: Tue, 3 Apr 2001 17:03:48 +0000 (-0400) Subject: Re: [PATCH] Lighten up glob X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7d3fb23018f73b213481a8b6b108e1dc03cefcff;p=p5sagit%2Fp5-mst-13.2.git Re: [PATCH] Lighten up glob Message-ID: p4raw-id: //depot/perl@9541 --- diff --git a/embed.pl b/embed.pl index 3682192..e1ddd67 100755 --- a/embed.pl +++ b/embed.pl @@ -1675,7 +1675,7 @@ p |void |lex_start |SV* line p |OP* |linklist |OP* o p |OP* |list |OP* o p |OP* |listkids |OP* o -Ap |void |load_module|U32 flags|SV* name|SV* ver|... +Apd |void |load_module|U32 flags|SV* name|SV* ver|... Ap |void |vload_module|U32 flags|SV* name|SV* ver|va_list* args p |OP* |localize |OP* arg|I32 lexical Apd |I32 |looks_like_number|SV* sv diff --git a/ext/File/Glob/Glob.pm b/ext/File/Glob/Glob.pm index 561f331..da331b1 100644 --- a/ext/File/Glob/Glob.pm +++ b/ext/File/Glob/Glob.pm @@ -1,13 +1,10 @@ package File::Glob; use strict; -use Carp; our($VERSION, @ISA, @EXPORT_OK, @EXPORT_FAIL, %EXPORT_TAGS, $AUTOLOAD, $DEFAULT_FLAGS); -require Exporter; use XSLoader (); -require AutoLoader; @ISA = qw(Exporter AutoLoader); @@ -60,6 +57,7 @@ require AutoLoader; $VERSION = '0.991'; sub import { + require Exporter; my $i = 1; while ($i < @_) { if ($_[$i] =~ /^:(case|nocase|globally)$/) { @@ -67,7 +65,7 @@ sub import { $DEFAULT_FLAGS &= ~GLOB_NOCASE() if $1 eq 'case'; $DEFAULT_FLAGS |= GLOB_NOCASE() if $1 eq 'nocase'; if ($1 eq 'globally') { - no warnings; + local $^W; *CORE::GLOBAL::glob = \&File::Glob::csh_glob; } next; @@ -87,11 +85,13 @@ sub AUTOLOAD { my $val = constant($constname, @_ ? $_[0] : 0); if ($! != 0) { if ($! =~ /Invalid/) { + require AutoLoader; $AutoLoader::AUTOLOAD = $AUTOLOAD; goto &AutoLoader::AUTOLOAD; } else { - croak "Your vendor has not defined File::Glob macro $constname"; + require Carp; + Carp::croak("Your vendor has not defined File::Glob macro $constname"); } } eval "sub $AUTOLOAD { $val }"; diff --git a/op.c b/op.c index f6ec916..59cbfa3 100644 --- a/op.c +++ b/op.c @@ -3306,6 +3306,20 @@ Perl_utilize(pTHX_ int aver, I32 floor, OP *version, OP *id, OP *arg) PL_expect = XSTATE; } +/* +=for apidoc load_module + +Loads the module whose name is pointed to by the string part of name. +Note that the actual module name, not its filename, should be given. +Eg, "Foo::Bar" instead of "Foo/Bar.pm". flags can be any of +PERL_LOADMOD_DENY, PERL_LOADMOD_NOIMPORT, or PERL_LOADMOD_IMPORT_OPS +(or 0 for no flags). ver, if specified, provides version semantics +similar to C. The optional trailing SV* +arguments can be used to specify arguments to the module's import() +method, similar to C. + +=cut */ + void Perl_load_module(pTHX_ U32 flags, SV *name, SV *ver, ...) { @@ -5848,11 +5862,14 @@ Perl_ck_glob(pTHX_ OP *o) #if !defined(PERL_EXTERNAL_GLOB) /* XXX this can be tightened up and made more failsafe. */ if (!gv) { + GV *glob_gv; ENTER; - Perl_load_module(aTHX_ 0, newSVpvn("File::Glob", 10), Nullsv, - /* null-terminated import list */ - newSVpvn(":globally", 9), Nullsv); + Perl_load_module(aTHX_ PERL_LOADMOD_NOIMPORT, newSVpvn("File::Glob", 10), Nullsv, + Nullsv, Nullsv); gv = gv_fetchpv("CORE::GLOBAL::glob", FALSE, SVt_PVCV); + glob_gv = gv_fetchpv("File::Glob::csh_glob", FALSE, SVt_PVCV); + GvCV(gv) = GvCV(glob_gv); + GvIMPORTED_CV_on(gv); LEAVE; } #endif /* PERL_EXTERNAL_GLOB */ diff --git a/perl.c b/perl.c index 41ffdaa..834dc46 100644 --- a/perl.c +++ b/perl.c @@ -1985,10 +1985,11 @@ Perl_eval_pv(pTHX_ const char *p, I32 croak_on_error) /* =for apidoc p||require_pv -Tells Perl to C a module. +Tells Perl to C the file named by the string argument. It is +analogous to the Perl code C. It's even +implemented that way; consider using Perl_load_module instead. -=cut -*/ +=cut */ void Perl_require_pv(pTHX_ const char *pv) diff --git a/pod/perlapi.pod b/pod/perlapi.pod index 711db4d..3f7c2f9 100644 --- a/pod/perlapi.pod +++ b/pod/perlapi.pod @@ -1086,6 +1086,22 @@ Closing bracket on a callback. See C and L. =for hackers Found in file scope.h +=item load_module + +Loads the module whose name is pointed to by the string part of name. +Note that the actual module name, not its filename, should be given. +Eg, "Foo::Bar" instead of "Foo/Bar.pm". flags can be any of +PERL_LOADMOD_DENY, PERL_LOADMOD_NOIMPORT, or PERL_LOADMOD_IMPORT_OPS +(or 0 for no flags). ver, if specified, provides version semantics +similar to C. The optional trailing SV* +arguments can be used to specify arguments to the module's import() +method, similar to C. + + void load_module(U32 flags, SV* name, SV* ver, ...) + +=for hackers +Found in file op.c + =item looks_like_number Test if an the content of an SV looks like a number (or is a @@ -1697,7 +1713,9 @@ Found in file handy.h =item require_pv -Tells Perl to C a module. +Tells Perl to C the file named by the string argument. It is +analogous to the Perl code C. It's even +implemented that way; consider using Perl_load_module instead. NOTE: the perl_ form of this function is deprecated. @@ -2390,19 +2408,19 @@ false, defined or undefined. Does not handle 'get' magic. =for hackers Found in file sv.h -=item svtype +=item SvTYPE -An enum of flags for Perl types. These are found in the file B -in the C enum. Test these flags with the C macro. +Returns the type of the SV. See C. + + svtype SvTYPE(SV* sv) =for hackers Found in file sv.h -=item SvTYPE - -Returns the type of the SV. See C. +=item svtype - svtype SvTYPE(SV* sv) +An enum of flags for Perl types. These are found in the file B +in the C enum. Test these flags with the C macro. =for hackers Found in file sv.h