Change 13996 by ams@lustre on 2002/01/01 04:44:28

        Subject: [PATCH @13746] Leaner exporter
        From: Ilya Zakharevich <[EMAIL PROTECTED]>
        Date: Mon, 31 Dec 2001 18:16:08 -0500
        Message-Id: <[EMAIL PROTECTED]>

Affected files ...

.... //depot/perl/ext/B/t/stash.t#5 edit
.... //depot/perl/lib/Exporter.pm#25 edit
.... //depot/perl/lib/Exporter/Heavy.pm#17 edit

Differences ...

==== //depot/perl/ext/B/t/stash.t#5 (xtext) ====
Index: perl/ext/B/t/stash.t
--- perl/ext/B/t/stash.t.~1~    Mon Dec 31 22:00:05 2001
+++ perl/ext/B/t/stash.t        Mon Dec 31 22:00:05 2001
@@ -38,7 +38,7 @@
 $a =~ s/-u(Cwd|File|File::Copy|OS2),//g if $^O eq 'os2';
 $a =~ s/-uCwd,// if $^O eq 'cygwin';
   $b = '-uCarp,-uCarp::Heavy,-uDB,-uExporter,-uExporter::Heavy,-uaccess,-uattributes,'
-     . '-umain,-ustrict,-uutf8,-uwarnings';
+     . '-umain,-uutf8,-uwarnings';
 if ($Is_VMS) {
     $a =~ s/-uFile,-uFile::Copy,//;
     $a =~ s/-uVMS,-uVMS::Filespec,//;

==== //depot/perl/lib/Exporter.pm#25 (text) ====
Index: perl/lib/Exporter.pm
--- perl/lib/Exporter.pm.~1~    Mon Dec 31 22:00:05 2001
+++ perl/lib/Exporter.pm        Mon Dec 31 22:00:05 2001
@@ -2,33 +2,27 @@
 
 require 5.006;
 
-use strict;
-no strict 'refs';
+# Be lean.
+#use strict;
+#no strict 'refs';
 
 our $Debug = 0;
 our $ExportLevel = 0;
 our $Verbose ||= 0;
-our $VERSION = '5.565';
+our $VERSION = '5.566';
 $Carp::Internal{Exporter} = 1;
 
-sub export_to_level {
+sub as_heavy {
   require Exporter::Heavy;
-  goto &Exporter::Heavy::heavy_export_to_level;
+  # Unfortunately, this does not work if the caller is aliased as *name = \&foo
+  # Thus the need to create a lot of identical subroutines
+  my $c = (caller(1))[3];
+  $c =~ s/.*:://;
+  \&{"Exporter::Heavy::heavy_$c"};
 }
 
 sub export {
-  require Exporter::Heavy;
-  goto &Exporter::Heavy::heavy_export;
-}
-
-sub export_tags {
-  require Exporter::Heavy;
-  Exporter::Heavy::_push_tags((caller)[0], "EXPORT",    \@_);
-}
-
-sub export_ok_tags {
-  require Exporter::Heavy;
-  Exporter::Heavy::_push_tags((caller)[0], "EXPORT_OK", \@_);
+  goto &{as_heavy()};
 }
 
 sub import {
@@ -65,7 +59,6 @@
   *{"$callpkg\::$_"} = \&{"$pkg\::$_"} foreach @_;
 }
 
-
 # Default methods
 
 sub export_fail {
@@ -73,13 +66,26 @@
     @_;
 }
 
+# Unfortunately, caller(1)[3] "does not work" if the caller is aliased as
+# *name = \&foo.  Thus the need to create a lot of identical subroutines
+# Otherwise we could have aliased them to export().
+
+sub export_to_level {
+  goto &{as_heavy()};
+}
+
+sub export_tags {
+  goto &{as_heavy()};
+}
+
+sub export_ok_tags {
+  goto &{as_heavy()};
+}
 
 sub require_version {
-    require Exporter::Heavy;
-    goto &Exporter::Heavy::require_version;
+  goto &{as_heavy()};
 }
 
-
 1;
 __END__
 

==== //depot/perl/lib/Exporter/Heavy.pm#17 (text) ====
Index: perl/lib/Exporter/Heavy.pm
--- perl/lib/Exporter/Heavy.pm.~1~      Mon Dec 31 22:00:05 2001
+++ perl/lib/Exporter/Heavy.pm  Mon Dec 31 22:00:05 2001
@@ -215,11 +215,18 @@
     }
 }
 
-
-sub require_version {
+sub heavy_require_version {
     my($self, $wanted) = @_;
     my $pkg = ref $self || $self;
     return ${pkg}->VERSION($wanted);
 }
 
+sub heavy_export_tags {
+  _push_tags((caller)[0], "EXPORT",    \@_);
+}
+
+sub heavy_export_ok_tags {
+  _push_tags((caller)[0], "EXPORT_OK", \@_);
+}
+
 1;
End of Patch.

Reply via email to