Change 30273 by [EMAIL PROTECTED] on 2007/02/13 23:40:57

        Integrate:
        [ 26459]
        De-duplicate the items in @EXPORT. (@EXPORT is built from all the tags,
        and some constants are mentioned in multiple tags).
        Should this logic be in Exporter::Heavy?
        
        [ 26709]
        Tweak the code that generates unique entries in @POSIX::EXPORT so that
        the array ends up with shared hash key scalars, for a memory saving.
        
        [ 29571]
        POSIX::SigAction::new can be moved into the AUTOLOAD section.
        
        [ 29586]
        Given that POSIX already has AutoLoader loaded, move as much as
        possible of POSIX::SigRt out to AutoLoadLand, so that it won't be
        loaded unless someone starts using the realtime signals interface.
        
        [ 29587]
        Ensure that POSIX.pm is strict and warnings compliant throughout if
        the __END__ is temporarily removed.
        
        [ 29591]
        Disable strictures in POSIX AUTOLOAD
        
        [ 29592]
        Add a regression test to verify that POSIX::AUTOLOAD works,
        and silence a potential warning from it.

Affected files ...

... //depot/maint-5.8/perl/ext/POSIX/POSIX.pm#13 integrate
... //depot/maint-5.8/perl/ext/POSIX/t/posix.t#9 integrate

Differences ...

==== //depot/maint-5.8/perl/ext/POSIX/POSIX.pm#13 (text) ====
Index: perl/ext/POSIX/POSIX.pm
--- perl/ext/POSIX/POSIX.pm#12~30038~   2007-01-27 10:13:24.000000000 -0800
+++ perl/ext/POSIX/POSIX.pm     2007-02-13 15:40:57.000000000 -0800
@@ -1,8 +1,10 @@
 package POSIX;
+use strict;
+use warnings;
 
-our(@ISA, %EXPORT_TAGS, @EXPORT_OK, $AUTOLOAD, %SIGRT) = ();
+our(@ISA, %EXPORT_TAGS, @EXPORT_OK, @EXPORT, $AUTOLOAD, %SIGRT) = ();
 
-our $VERSION = "1.09";
+our $VERSION = "1.12";
 
 use AutoLoader;
 
@@ -30,6 +32,8 @@
                      WIFEXITED WIFSIGNALED WIFSTOPPED WSTOPSIG WTERMSIG));
 
 sub AUTOLOAD {
+    no strict;
+    no warnings 'uninitialized';
     if ($AUTOLOAD =~ /::(_?[a-z])/) {
        # require AutoLoader;
        $AutoLoader::AUTOLOAD = $AUTOLOAD;
@@ -54,75 +58,22 @@
 package POSIX::SigAction;
 
 use AutoLoader 'AUTOLOAD';
-sub new { bless {HANDLER => $_[1], MASK => $_[2], FLAGS => $_[3] || 0, SAFE => 
0}, $_[0] }
 
 package POSIX::SigRt;
 
-use strict;
+use AutoLoader 'AUTOLOAD';
 
 use Tie::Hash;
-use base qw(Tie::StdHash);
 
-use vars qw($SIGACTION_FLAGS);
+use vars qw($SIGACTION_FLAGS $_SIGRTMIN $_SIGRTMAX $_sigrtn @ISA);
[EMAIL PROTECTED]::SigRt::ISA = qw(Tie::StdHash);
 
 $SIGACTION_FLAGS = 0;
 
-my ($SIGRTMIN, $SIGRTMAX, $sigrtn);
-
-sub _init {
-    $SIGRTMIN = &POSIX::SIGRTMIN;
-    $SIGRTMAX = &POSIX::SIGRTMAX;
-    $sigrtn   = $SIGRTMAX - $SIGRTMIN;
-}
-
-sub _croak {
-    &_init unless defined $sigrtn;
-    die "POSIX::SigRt not available" unless defined $sigrtn && $sigrtn > 0;
-}
-
-sub _getsig {
-    &_croak;
-    my $rtsig = $_[0];
-    # Allow (SIGRT)?MIN( + n)?, a common idiom when doing these things in C.
-    $rtsig = $SIGRTMIN + ($1 || 0)
-       if $rtsig =~ /^(?:(?:SIG)?RT)?MIN(\s*\+\s*(\d+))?$/;
-    return $rtsig;
-}
-
-sub _exist {
-    my $rtsig = _getsig($_[1]);
-    my $ok    = $rtsig >= $SIGRTMIN && $rtsig <= $SIGRTMAX;
-    ($rtsig, $ok);
-}
-
-sub _check {
-    my ($rtsig, $ok) = &_exist;
-    die "No POSIX::SigRt signal $_[1] (valid range SIGRTMIN..SIGRTMAX, or 
$SIGRTMIN..$SIGRTMAX)"
-       unless $ok;
-    return $rtsig;
-}
-
-sub new {
-    my ($rtsig, $handler, $flags) = @_;
-    my $sigset = POSIX::SigSet->new($rtsig);
-    my $sigact = POSIX::SigAction->new($handler,
-                                      $sigset,
-                                      $flags);
-    POSIX::sigaction($rtsig, $sigact);
-}
-
-sub EXISTS { &_exist }
-sub FETCH  { my $rtsig = &_check;
-            my $oa = POSIX::SigAction->new();
-            POSIX::sigaction($rtsig, undef, $oa);
-            return $oa->{HANDLER} }
-sub STORE  { my $rtsig = &_check; new($rtsig, $_[2], $SIGACTION_FLAGS) }
-sub DELETE { delete $SIG{ &_check } }
-sub CLEAR  { &_exist; delete @SIG{ &POSIX::SIGRTMIN .. &POSIX::SIGRTMAX } }
-sub SCALAR { &_croak; $sigrtn + 1 }
-
 tie %POSIX::SIGRT, 'POSIX::SigRt';
 
+sub DESTROY {};
+
 package POSIX;
 
 1;
@@ -958,8 +909,13 @@
 );
 
 # Exporter::export_tags();
-for (values %EXPORT_TAGS) {
-  push @EXPORT, @$_;
+{
+  # De-duplicate the export list: 
+  my %export;
+  @export{map [EMAIL PROTECTED] values %EXPORT_TAGS} = ();
+  # Doing the de-dup with a temporary hash has the advantage that the SVs in
+  # @EXPORT are actually shared hash key sacalars, which will save some memory.
+  push @EXPORT, keys %export;
 }
 
 @EXPORT_OK = qw(
@@ -1026,8 +982,63 @@
 
 package POSIX::SigAction;
 
+sub new { bless {HANDLER => $_[1], MASK => $_[2], FLAGS => $_[3] || 0, SAFE => 
0}, $_[0] }
 sub handler { $_[0]->{HANDLER} = $_[1] if @_ > 1; $_[0]->{HANDLER} };
 sub mask    { $_[0]->{MASK}    = $_[1] if @_ > 1; $_[0]->{MASK} };
 sub flags   { $_[0]->{FLAGS}   = $_[1] if @_ > 1; $_[0]->{FLAGS} };
 sub safe    { $_[0]->{SAFE}    = $_[1] if @_ > 1; $_[0]->{SAFE} };
 
+package POSIX::SigRt;
+
+
+sub _init {
+    $_SIGRTMIN = &POSIX::SIGRTMIN;
+    $_SIGRTMAX = &POSIX::SIGRTMAX;
+    $_sigrtn   = $_SIGRTMAX - $_SIGRTMIN;
+}
+
+sub _croak {
+    &_init unless defined $_sigrtn;
+    die "POSIX::SigRt not available" unless defined $_sigrtn && $_sigrtn > 0;
+}
+
+sub _getsig {
+    &_croak;
+    my $rtsig = $_[0];
+    # Allow (SIGRT)?MIN( + n)?, a common idiom when doing these things in C.
+    $rtsig = $_SIGRTMIN + ($1 || 0)
+       if $rtsig =~ /^(?:(?:SIG)?RT)?MIN(\s*\+\s*(\d+))?$/;
+    return $rtsig;
+}
+
+sub _exist {
+    my $rtsig = _getsig($_[1]);
+    my $ok    = $rtsig >= $_SIGRTMIN && $rtsig <= $_SIGRTMAX;
+    ($rtsig, $ok);
+}
+
+sub _check {
+    my ($rtsig, $ok) = &_exist;
+    die "No POSIX::SigRt signal $_[1] (valid range SIGRTMIN..SIGRTMAX, or 
$_SIGRTMIN..$_SIGRTMAX)"
+       unless $ok;
+    return $rtsig;
+}
+
+sub new {
+    my ($rtsig, $handler, $flags) = @_;
+    my $sigset = POSIX::SigSet->new($rtsig);
+    my $sigact = POSIX::SigAction->new($handler,
+                                      $sigset,
+                                      $flags);
+    POSIX::sigaction($rtsig, $sigact);
+}
+
+sub EXISTS { &_exist }
+sub FETCH  { my $rtsig = &_check;
+            my $oa = POSIX::SigAction->new();
+            POSIX::sigaction($rtsig, undef, $oa);
+            return $oa->{HANDLER} }
+sub STORE  { my $rtsig = &_check; new($rtsig, $_[2], $SIGACTION_FLAGS) }
+sub DELETE { delete $SIG{ &_check } }
+sub CLEAR  { &_exist; delete @SIG{ &POSIX::SIGRTMIN .. &POSIX::SIGRTMAX } }
+sub SCALAR { &_croak; $_sigrtn + 1 }

==== //depot/maint-5.8/perl/ext/POSIX/t/posix.t#9 (text) ====
Index: perl/ext/POSIX/t/posix.t
--- perl/ext/POSIX/t/posix.t#8~21824~   2003-11-30 11:00:33.000000000 -0800
+++ perl/ext/POSIX/t/posix.t    2007-02-13 15:40:57.000000000 -0800
@@ -11,7 +11,7 @@
 }
 
 require "./test.pl";
-plan(tests => 65);
+plan(tests => 66);
 
 use POSIX qw(fcntl_h signal_h limits_h _exit getcwd open read strftime write
             errno);
@@ -266,6 +266,9 @@
 # those functions should stringify their arguments
 ok(!POSIX::isalpha([]),   'isalpha []' );
 ok( POSIX::isprint([]),   'isprint []' );
+
+eval { use strict; POSIX->import("S_ISBLK"); my $x = S_ISBLK };
+unlike( $@, qr/Can't use string .* as a symbol ref/, "Can import autoloaded 
constants" );
  
 # Check that output is not flushed by _exit. This test should be last
 # in the file, and is not counted in the total number of tests.
End of Patch.

Reply via email to