From: Perl 5 Porters Date: Mon, 7 Apr 1997 00:00:00 +0000 (+0000) Subject: [inseparable changes from match from perl-5.003_97b to perl-5.003_97c] X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8cc95fdbe3687330bd987cea170494b4cd263d90;p=p5sagit%2Fp5-mst-13.2.git [inseparable changes from match from perl-5.003_97b to perl-5.003_97c] BUILD PROCESS Subject: Fix syntax error in Configure comment(!) From: Chip Salzenberg Files: Configure Subject: For Solaris, if -DDEBUGGING, default to '-KPIC', not '-Kpic' From: Chip Salzenberg Files: Configure Subject: Fix usage of dXSUB_SYS, esp. in ExtUtils::Miniperl From: Chip Salzenberg Files: dosish.h minimod.pl os2/os2ish.h plan9/plan9ish.h vms/vmsish.h CORE LANGUAGE CHANGES Subject: Refine setgroups() behavior of C<$)> From: Chip Salzenberg Files: mg.c pod/perldelta.pod pod/perlvar.pod Subject: Forbid -[Mm] on #! line From: Chip Salzenberg Files: pod/perldelta.pod pod/perldiag.pod toke.c CORE PORTABILITY Subject: Special mkdir() for VMS Date: Tue, 08 Apr 1997 12:33:56 -0400 (EDT) From: Charles Bailey Files: dosish.h lib/ExtUtils/MM_Unix.pm lib/File/Path.pm os2/os2ish.h plan9/plan9ish.h pp_sys.c unixish.h vms/vms.c vms/vmsish.h Msg-ID: 01IHGOXN6MZM0004K3@hmivax.humgen.upenn.edu (applied based on p5p patch as commit ebec1d4b2ca9c08d24035a369c7aa782aa058e66) DOCUMENTATION Subject: IO::Socket doc fix Date: Tue, 08 Apr 1997 15:30:43 -0400 From: Roderick Schertler Files: ext/IO/lib/IO/Socket.pm Msg-ID: 28383.860527843@eeyore.ibcinc.com (applied based on p5p patch as commit 4a51304ce091cb6d1ccc9f25e11753bd7d985b32) LIBRARY AND EXTENSIONS Subject: Replace Class::Template with improved Class::Struct From: Jim Miner Files: MANIFEST lib/Class/Struct.pm lib/Class/Template.pm lib/File/stat.pm lib/Net/hostent.pm lib/Net/netent.pm lib/Net/protoent.pm lib/Net/servent.pm lib/Time/gmtime.pm lib/Time/localtime.pm lib/Time/tm.pm lib/User/grent.pm lib/User/pwent.pm pod/perldelta.pod pod/perlfaq7.pod pod/perlmod.pod pod/perltoot.pod Subject: MakeMaker pathname patch Date: Wed, 9 Apr 1997 20:08:23 +0100 From: Nick Ing-Simmons Files: lib/ExtUtils/MM_Unix.pm lib/ExtUtils/MakeMaker.pm Msg-ID: 199704091908.UAA00877@ni-s.u-net.com (applied based on p5p patch as commit 9cbbd68ff8edc7de96e3471de49538d0b2b98173) Subject: Fix configuration of new socket From: Chip Salzenberg Files: ext/IO/lib/IO/Socket.pm --- diff --git a/Changes b/Changes index fc9c9c7..3b3a6e5 100644 --- a/Changes +++ b/Changes @@ -46,6 +46,113 @@ And the Keepers of the Patch Pumpkin: ------------------- + Version 5.003_97c +------------------- + +That second public beta will be Real Soon Now... + + CORE LANGUAGE CHANGES + + Title: "Refine setgroups() behavior of C<$)>" + From: Chip Salzenberg + Files: mg.c pod/perldelta.pod pod/perlvar.pod + + Title: "Forbid -[Mm] on #! line" + From: Chip Salzenberg + Files: pod/perldelta.pod pod/perldiag.pod toke.c + + CORE PORTABILITY + + Title: "Fix dynamic loading (and argv[0]) under AmigaOS" + From: Norbert Pueschel + Msg-ID: <77724842@Armageddon.meb.uni-bonn.de> + Date: Tue, 08 Apr 1997 22:01:45 +0200 + Files: hints/amigaos.sh + + Title: "Special mkdir() for VMS" + From: Charles Bailey + Msg-ID: <01IHGOXN6MZM0004K3@hmivax.humgen.upenn.edu> + Date: Tue, 08 Apr 1997 12:33:56 -0400 (EDT) + Files: dosish.h lib/ExtUtils/MM_Unix.pm lib/File/Path.pm os2/os2ish.h + plan9/plan9ish.h pp_sys.c unixish.h vms/vms.c vms/vmsish.h + + OTHER CORE CHANGES + + Title: "Fix assignment from magic SV that becomes a glob" + From: Chip Salzenberg + Files: sv.c + + BUILD PROCESS + + Title: "Fix syntax error in Configure comment(!)" + From: Chip Salzenberg + Files: Configure + + Title: "For Solaris, if -DDEBUGGING, default to '-KPIC', not '-Kpic'" + From: Chip Salzenberg + Files: Configure + + Title: "Fix usage of dXSUB_SYS, esp. in ExtUtils::Miniperl" + From: Chip Salzenberg + Files: dosish.h minimod.pl os2/os2ish.h plan9/plan9ish.h vms/vmsish.h + + LIBRARY AND EXTENSIONS + + Title: "Replace Class::Template with improved Class::Struct" + From: Jim Miner + Files: MANIFEST lib/Class/Struct.pm lib/Class/Template.pm + lib/File/stat.pm lib/Net/hostent.pm lib/Net/netent.pm + lib/Net/protoent.pm lib/Net/servent.pm lib/Time/gmtime.pm + lib/Time/localtime.pm lib/Time/tm.pm lib/User/grent.pm + lib/User/pwent.pm pod/perldelta.pod pod/perlfaq7.pod + pod/perlmod.pod pod/perltoot.pod + + Title: "MakeMaker pathname patch" + From: Nick Ing-Simmons + Msg-ID: <199704091908.UAA00877@ni-s.u-net.com> + Date: Wed, 9 Apr 1997 20:08:23 +0100 + Files: lib/ExtUtils/MM_Unix.pm lib/ExtUtils/MakeMaker.pm + + Title: "Fix configuration of new socket" + From: Chip Salzenberg + Files: ext/IO/lib/IO/Socket.pm + + Title: "Improve IO::Handle docs; don't export _open_mode_string" + From: Chip Salzenberg + Files: ext/IO/lib/IO/File.pm ext/IO/lib/IO/Handle.pm + + Title: "Complex.pm: 0**0 sanity" + From: Jarkko Hietaniemi + Msg-ID: <199704091804.VAA13930@alpha.hut.fi> + Date: Wed, 9 Apr 1997 21:04:23 +0300 (EET DST) + Files: lib/Math/Complex.pm + + Title: "Fix typos in Math::Trig" + From: Jarkko Hietaniemi + Files: lib/Math/Trig.pm + + TESTS + + Title: "Accommodate CodeBuilder variant of Machten 4.0.3" + From: Dominic Dunlop + Msg-ID: + Date: Tue, 8 Apr 1997 22:15:15 +0200 + Files: t/io/fs.t t/op/stat.t + + UTILITIES + + (no changes) + + DOCUMENTATION + + Title: "IO::Socket doc fix" + From: Roderick Schertler + Msg-ID: <28383.860527843@eeyore.ibcinc.com> + Date: Tue, 08 Apr 1997 15:30:43 -0400 + Files: ext/IO/lib/IO/Socket.pm + + +------------------- Version 5.003_97b ------------------- diff --git a/Configure b/Configure index 88ba08d..0253fdb 100755 --- a/Configure +++ b/Configure @@ -4413,8 +4413,12 @@ EOM '') case "$osname" in hpux) dflt='+z' ;; next) dflt='none' ;; - solaris|svr4*|esix*) dflt='-Kpic' ;; - irix*) dflt='-KPIC' ;; + svr4*|esix*) dflt='-Kpic' ;; + irix*) dflt='-KPIC' ;; + solaris) case "$ccflags" in + *-DDEBUGGING*) dflt='-KPIC' ;; + *) dflt='-Kpic' ;; + esac ;; sunos) dflt='-pic' ;; *) dflt='none' ;; esac ;; @@ -8495,7 +8499,7 @@ eval $inlibc set setgroups d_setgrps eval $inlibc -: Find type of 2nd arg to getgroups (and setgroups) +: Find type of 2nd arg to 'getgroups()' and 'setgroups()' echo " " case "$d_getgrps$d_setgrps" in *define*) diff --git a/MANIFEST b/MANIFEST index 22c7eab..0515ac3 100644 --- a/MANIFEST +++ b/MANIFEST @@ -319,7 +319,7 @@ lib/CPAN.pm Interface to Comprehensive Perl Archive Network lib/CPAN/FirstTime.pm Utility for creating CPAN config files lib/CPAN/Nox.pm Runs CPAN while avoiding compiled extensions lib/Carp.pm Error message base class -lib/Class/Template.pm Structure/member template builder; makes nested types +lib/Class/Struct.pm Declare struct-like datatypes as Perl classes lib/Cwd.pm Various cwd routines (getcwd, fastcwd, chdir) lib/Devel/SelfStubber.pm Generate stubs for SelfLoader.pm lib/DirHandle.pm like FileHandle only for directories @@ -391,7 +391,7 @@ lib/Tie/SubstrHash.pm Compact hash for known key, value and table size lib/Time/Local.pm Reverse translation of localtime, gmtime lib/Time/gmtime.pm By-name interface to Perl's built-in gmtime lib/Time/localtime.pm By-name interface to Perl's built-in localtime -lib/Time/tm.pm Internal oject for Time::{gm,local}time +lib/Time/tm.pm Internal object for Time::{gm,local}time lib/UNIVERSAL.pm Base class for ALL classes lib/User/grent.pm By-name interface to Perl's built-in getgr* lib/User/pwent.pm By-name interface to Perl's built-in getpw* diff --git a/dosish.h b/dosish.h index 7bdea44..574fbfc 100644 --- a/dosish.h +++ b/dosish.h @@ -18,7 +18,7 @@ void Perl_DJGPP_init(); #endif /* DJGPP */ #define PERL_SYS_TERM() -#define dXSUB_SYS int dummy +#define dXSUB_SYS #define TMPPATH "plXXXXXX" #ifdef WIN32 @@ -86,6 +86,7 @@ void Perl_DJGPP_init(); #define Fstat(fd,bufptr) fstat((fd),(bufptr)) #define Fflush(fp) fflush(fp) +#define Mkdir(path,mode) mkdir((path),(mode)) #ifndef WIN32 # define Stat(fname,bufptr) stat((fname),(bufptr)) diff --git a/ext/IO/lib/IO/Socket.pm b/ext/IO/lib/IO/Socket.pm index 9ef897b..171042c 100644 --- a/ext/IO/lib/IO/Socket.pm +++ b/ext/IO/lib/IO/Socket.pm @@ -118,7 +118,7 @@ use Exporter; @ISA = qw(IO::Handle); -$VERSION = "1.16"; +$VERSION = "1.1602"; sub import { my $pkg = shift; @@ -157,7 +157,7 @@ sub configure { unless ref($fh) eq "IO::Socket"; bless($fh, $domain2pkg[$domain]); - $fh->configure; + $fh->configure($arg); } sub socket { @@ -417,7 +417,7 @@ the service name. Examples: $sock = IO::Socket::INET->new(PeerAddr => 'www.perl.org', - PeerPort => http(80), + PeerPort => 'http(80)', Proto => 'tcp'); $sock = IO::Socket::INET->new(PeerAddr => 'localhost:smtp(25)'); diff --git a/lib/Class/Struct.pm b/lib/Class/Struct.pm new file mode 100644 index 0000000..9c56779 --- /dev/null +++ b/lib/Class/Struct.pm @@ -0,0 +1,482 @@ +package Class::Struct; + +## See POD after __END__ + +require 5.002; + +use strict; +use vars qw(@ISA @EXPORT); + +use Carp; + +require Exporter; +@ISA = qw(Exporter); +@EXPORT = qw(struct); + +## Tested on 5.002 and 5.003 without class membership tests: +my $CHECK_CLASS_MEMBERSHIP = ($] >= 5.003_95); + +my $print = 0; +sub printem { + if (@_) { $print = shift } + else { $print++ } +} + +{ + package Class::Struct::Tie_ISA; + + sub TIEARRAY { + my $class = shift; + return bless [], $class; + } + + sub STORE { + my ($self, $index, $value) = @_; + Class::Struct::_subclass_error(); + } + + sub FETCH { + my ($self, $index) = @_; + $self->[$index]; + } + + sub DESTROY { } +} + +sub struct { + + # Determine parameter list structure, one of: + # struct( class => [ element-list ]) + # struct( class => { element-list }) + # struct( element-list ) + # Latter form assumes current package name as struct name. + + my ($class, @decls); + my $base_type = ref $_[1]; + if ( $base_type eq 'HASH' ) { + $class = shift; + @decls = %{shift()}; + _usage_error() if @_; + } + elsif ( $base_type eq 'ARRAY' ) { + $class = shift; + @decls = @{shift()}; + _usage_error() if @_; + } + else { + $base_type = 'ARRAY'; + $class = (caller())[0]; + @decls = @_; + } + _usage_error() if @decls % 2 == 1; + + # Ensure we are not, and will not be, a subclass. + + my $isa = do { + no strict 'refs'; + \@{$class . '::ISA'}; + }; + _subclass_error() if @$isa; + tie @$isa, 'Class::Struct::Tie_ISA'; + + # Create constructor. + + croak "function 'new' already defined in package $class" + if do { no strict 'refs'; defined &{$class . "::new"} }; + + my @methods = (); + my %refs = (); + my %arrays = (); + my %hashes = (); + my %classes = (); + my $got_class = 0; + my $out = ''; + + $out = "{\n package $class;\n use Carp;\n sub new {\n"; + + my $cnt = 0; + my $idx = 0; + my( $cmt, $name, $type, $elem ); + + if( $base_type eq 'HASH' ){ + $out .= " my(\$r) = {};\n"; + $cmt = ''; + } + elsif( $base_type eq 'ARRAY' ){ + $out .= " my(\$r) = [];\n"; + } + while( $idx < @decls ){ + $name = $decls[$idx]; + $type = $decls[$idx+1]; + push( @methods, $name ); + if( $base_type eq 'HASH' ){ + $elem = "{'$name'}"; + } + elsif( $base_type eq 'ARRAY' ){ + $elem = "[$cnt]"; + ++$cnt; + $cmt = " # $name"; + } + if( $type =~ /^\*(.)/ ){ + $refs{$name}++; + $type = $1; + } + if( $type eq '@' ){ + $out .= " \$r->$elem = [];$cmt\n"; + $arrays{$name}++; + } + elsif( $type eq '%' ){ + $out .= " \$r->$elem = {};$cmt\n"; + $hashes{$name}++; + } + elsif ( $type eq '$') { + $out .= " \$r->$elem = undef;$cmt\n"; + } + elsif( $type =~ /^\w+(?:::\w+)*$/ ){ + $out .= " \$r->$elem = '${type}'->new();$cmt\n"; + $classes{$name} = $type; + $got_class = 1; + } + else{ + croak "'$type' is not a valid struct element type"; + } + $idx += 2; + } + $out .= " bless \$r;\n }\n"; + + # Create accessor methods. + + if ( $got_class && $CHECK_CLASS_MEMBERSHIP ) { + $out .= " use UNIVERSAL;\n"; + } + my( $pre, $pst, $sel ); + $cnt = 0; + foreach $name (@methods){ + if ( do { no strict 'refs'; defined &{$class . "::$name"} } ) { + carp "function '$name' already defined, overrides struct accessor method" + if $^W; + } + else { + $pre = $pst = $cmt = $sel = ''; + if( defined $refs{$name} ){ + $pre = "\\("; + $pst = ")"; + $cmt = " # returns ref"; + } + $out .= " sub $name {$cmt\n my \$r = shift;\n"; + if( $base_type eq 'ARRAY' ){ + $elem = "[$cnt]"; + ++$cnt; + } + elsif( $base_type eq 'HASH' ){ + $elem = "{'$name'}"; + } + if( defined $arrays{$name} ){ + $out .= " my \$i;\n"; + $out .= " \@_ ? (\$i = shift) : return $pre\$r->$elem$pst;\n"; + $sel = "->[\$i]"; + } + elsif( defined $hashes{$name} ){ + $out .= " my \$i;\n"; + $out .= " \@_ ? (\$i = shift) : return $pre\$r->$elem$pst;\n"; + $sel = "->{\$i}"; + } + elsif( defined $classes{$name} ){ + if ( $CHECK_CLASS_MEMBERSHIP ) { + $out .= " croak '$name argument is wrong class' if \@_ && ! UNIVERSAL::isa(\$_[0], '$type');\n"; + } + } + $out .= " croak 'Too many args to $name' if \@_ > 1;\n"; + $out .= " \@_ ? ($pre\$r->$elem$sel = shift$pst) : $pre\$r->$elem$sel$pst;\n"; + $out .= " }\n"; + } + } + $out .= "}\n1;\n"; + + print $out if $print; + my $result = eval $out; + carp $@ if $@; +} + +sub _usage_error { + confess "struct usage error"; +} + +sub _subclass_error { + croak 'struct class cannot be a subclass (@ISA not allowed)'; +} + +1; # for require + + +__END__ + +=head1 NAME + +Class::Struct - declare struct-like datatypes as Perl classes + +=head1 SYNOPSIS + + use Class::Struct; + # declare struct, based on array: + struct( CLASS_NAME => [ ELEMENT_NAME => ELEMENT_TYPE, ... ]); + # declare struct, based on hash: + struct( CLASS_NAME => { ELEMENT_NAME => ELEMENT_TYPE, ... }); + + package CLASS_NAME; + use Class::Struct; + # declare struct, based on array, implicit class name: + struct( ELEMENT_NAME => ELEMENT_TYPE, ... ); + + + package Myobj; + use Class::Struct; + # declare struct with four types of elements: + struct( s => '$', a => '@', h => '%', c => 'My_Other_Class' ); + + $obj = new Myobj; # constructor + + # scalar type accessor: + $element_value = $obj->s; # element value + $obj->s('new value'); # assign to element + + # array type accessor: + $ary_ref = $obj->a; # reference to whole array + $ary_element_value = $obj->a(2); # array element value + $obj->a(2, 'new value'); # assign to array element + + # hash type accessor: + $hash_ref = $obj->h; # reference to whole hash + $hash_element_value = $obj->h('x'); # hash element value + $obj->h('x', 'new value'); # assign to hash element + + # class type accessor: + $element_value = $obj->c; # object reference + $obj->c->method(...); # call method of object + $obj->c(new My_Other_Class); # assign a new object + + +=head1 DESCRIPTION + +C exports a single function, C. +Given a list of element names and types, and optionally +a class name, C creates a Perl 5 class that implements +a "struct-like" data structure. + +The new class is given a constructor method, C, for creating +struct objects. + +Each element in the struct data has an accessor method, which is +used to assign to the element and to fetch its value. The +default accessor can be overridden by declaring a C of the +same name in the package. (See Example 2.) + +Each element's type can be scalar, array, hash, or class. + + +=head2 The C function + +The C function has three forms of parameter-list. + + struct( CLASS_NAME => [ ELEMENT_LIST ]); + struct( CLASS_NAME => { ELEMENT_LIST }); + struct( ELEMENT_LIST ); + +The first and second forms explicitly identify the name of the +class being created. The third form assumes the current package +name as the class name. + +An object of a class created by the first and third forms is +based on an array, whereas an object of a class created by the +second form is based on a hash. The array-based forms will be +somewhat faster and smaller; the hash-based forms are more +flexible. + +The class created by C must not be a subclass of another +class other than C. + +A function named C must not be explicitly defined in a class +created by C. + +The I has the form + + NAME => TYPE, ... + +Each name-type pair declares one element of the struct. Each +element name will be defined as an accessor method unless a +method by that name is explicitly defined; in the latter case, a +warning is issued if the warning flag (-w) is set. + + +=head2 Element Types and Accessor Methods + +The four element types -- scalar, array, hash, and class -- are +represented by strings -- C<'$'>, C<'@'>, C<'%'>, and a class name -- +optionally preceded by a C<'*'>. + +The accessor method provided by C for an element depends +on the declared type of the element. + +=over + +=item Scalar (C<'$'> or C<'*$'>) + +The element is a scalar, and is initialized to C. + +The accessor's argument, if any, is assigned to the element. + +If the element type is C<'$'>, the value of the element (after +assignment) is returned. If the element type is C<'*$'>, a reference +to the element is returned. + +=item Array (C<'@'> or C<'*@'>) + +The element is an array, initialized to C<()>. + +With no argument, the accessor returns a reference to the +element's whole array. + +With one or two arguments, the first argument is an index +specifying one element of the array; the second argument, if +present, is assigned to the array element. If the element type +is C<'@'>, the accessor returns the array element value. If the +element type is C<'*@'>, a reference to the array element is +returned. + +=item Hash (C<'%'> or C<'*%'>) + +The element is a hash, initialized to C<()>. + +With no argument, the accessor returns a reference to the +element's whole hash. + +With one or two arguments, the first argument is a key specifying +one element of the hash; the second argument, if present, is +assigned to the hash element. If the element type is C<'%'>, the +accessor returns the hash element value. If the element type is +C<'*%'>, a reference to the hash element is returned. + +=item Class (C<'Class_Name'> or C<'*Class_Name'>) + +The element's value must be a reference blessed to the named +class or to one of its subclasses. The element is initialized to +the result of calling the C constructor of the named class. + +The accessor's argument, if any, is assigned to the element. The +accessor will C if this is not an appropriate object +reference. + +If the element type does not start with a C<'*'>, the accessor +returns the element value (after assignment). If the element type +starts with a C<'*'>, a reference to the element itself is returned. + +=back + +=head1 EXAMPLES + +=over + +=item Example 1 + +Giving a struct element a class type that is also a struct is how +structs are nested. Here, C represents a time (seconds and +microseconds), and C has two elements, each of which is of +type C. + + use Class::Struct; + + struct( rusage => { + ru_utime => timeval, # seconds + ru_stime => timeval, # microseconds + }); + + struct( timeval => [ + tv_secs => '$', + tv_usecs => '$', + ]); + + # create an object: + my $t = new rusage; + # $t->ru_utime and $t->ru_stime are objects of type timeval. + + # set $t->ru_utime to 100.0 sec and $t->ru_stime to 5.0 sec. + $t->ru_utime->tv_secs(100); + $t->ru_utime->tv_usecs(0); + $t->ru_stime->tv_secs(5); + $t->ru_stime->tv_usecs(0); + + +=item Example 2 + +An accessor function can be redefined in order to provide +additional checking of values, etc. Here, we want the C +element always to be nonnegative, so we redefine the C +accessor accordingly. + + package MyObj; + use Class::Struct; + + # declare the struct + struct ( 'MyObj', { count => '$', stuff => '%' } ); + + # override the default accessor method for 'count' + sub count { + my $self = shift; + if ( @_ ) { + die 'count must be nonnegative' if $_[0] < 0; + $self->{'count'} = shift; + warn "Too many args to count" if @_; + } + return $self->{'count'}; + } + + package main; + $x = new MyObj; + print "\$x->count(5) = ", $x->count(5), "\n"; + # prints '$x->count(5) = 5' + + print "\$x->count = ", $x->count, "\n"; + # prints '$x->count = 5' + + print "\$x->count(-5) = ", $x->count(-5), "\n"; + # dies due to negative argument! + + +=head1 Author and Modification History + + +Renamed to C and modified by Jim Miner, 1997-04-02. + + members() function removed. + Documentation corrected and extended. + Use of struct() in a subclass prohibited. + User definition of accessor allowed. + Treatment of '*' in element types corrected. + Treatment of classes as element types corrected. + Class name to struct() made optional. + Diagnostic checks added. + + +Originally C by Dean Roehrich. + + # Template.pm --- struct/member template builder + # 12mar95 + # Dean Roehrich + # + # changes/bugs fixed since 28nov94 version: + # - podified + # changes/bugs fixed since 21nov94 version: + # - Fixed examples. + # changes/bugs fixed since 02sep94 version: + # - Moved to Class::Template. + # changes/bugs fixed since 20feb94 version: + # - Updated to be a more proper module. + # - Added "use strict". + # - Bug in build_methods, was using @var when @$var needed. + # - Now using my() rather than local(). + # + # Uses perl5 classes to create nested data types. + # This is offered as one implementation of Tom Christiansen's "structs.pl" + # idea. + +=cut diff --git a/lib/ExtUtils/MM_Unix.pm b/lib/ExtUtils/MM_Unix.pm index f4ee44f..928e4ce 100644 --- a/lib/ExtUtils/MM_Unix.pm +++ b/lib/ExtUtils/MM_Unix.pm @@ -662,11 +662,17 @@ sub dir_target { # too often :) my($self,@dirs) = @_; - my(@m,$dir); + my(@m,$dir,$targdir); foreach $dir (@dirs) { my($src) = $self->catfile($self->{PERL_INC},'perl.h'); my($targ) = $self->catfile($dir,'.exists'); - my($targdir) = dirname($targ); # Necessary because catfile may have adapted syntax of $dir to target OS + # catfile may have adapted syntax of $dir to target OS, so... + if ($Is_VMS) { # Just remove file name; dirspec is often in macro + ($targdir = $targ) =~ s:/?\.exists$::; + } + else { # while elsewhere we expect to see the dir separator in $targ + $targdir = dirname($targ); + } next if $self->{DIR_TARGET}{$self}{$targdir}++; push @m, qq{ $targ :: $src @@ -1350,7 +1356,7 @@ sub init_dirscan { # --- File and Directory Lists (.xs .pm .pod etc) Initializes NAME, FULLEXT, BASEEXT, PARENT_NAME, DLBASE, PERL_SRC, PERL_LIB, PERL_ARCHLIB, PERL_INC, INSTALLDIRS, INST_*, INSTALL*, -PREFIX, CONFIG, AR, AR_STATIC_ARGS, LD, OBJ_EXT, LIB_EXT, MAP_TARGET, +PREFIX, CONFIG, AR, AR_STATIC_ARGS, LD, OBJ_EXT, LIB_EXT, EXE_EXT, MAP_TARGET, LIBPERL_A, VERSION_FROM, VERSION, DISTNAME, VERSION_SYM. =cut @@ -1539,7 +1545,7 @@ usually solves this kind of problem. # all the installation path variables to literally $(PREFIX), so # the user can still say make PREFIX=foo my($configure_prefix) = $Config{'prefix'}; - $prefix = VMS::Filespec::unixify($prefix) if $Is_VMS; + $configure_prefix = VMS::Filespec::unixify($configure_prefix) if $Is_VMS; $self->{PREFIX} ||= $configure_prefix; diff --git a/lib/ExtUtils/MakeMaker.pm b/lib/ExtUtils/MakeMaker.pm index 0898b75..273ebe7 100644 --- a/lib/ExtUtils/MakeMaker.pm +++ b/lib/ExtUtils/MakeMaker.pm @@ -307,7 +307,7 @@ sub full_setup { @Get_from_Config = qw( ar cc cccdlflags ccdlflags dlext dlsrc ld lddlflags ldflags libc - lib_ext obj_ext ranlib sitelibexp sitearchexp so + lib_ext obj_ext ranlib sitelibexp sitearchexp so exe_ext ); my $item; diff --git a/lib/File/Path.pm b/lib/File/Path.pm index 137e7bb..edec55d 100644 --- a/lib/File/Path.pm +++ b/lib/File/Path.pm @@ -113,6 +113,8 @@ sub mkpath { my(@created); foreach $path (@$paths) { next if -d $path; + # Logic wants Unix paths, so go with the flow. + $path = VMS::Filespec::unixify($path) if $Is_VMS; my $parent = dirname($path); push(@created,mkpath($parent, $verbose, $mode)) unless (-d $parent); print "mkdir $path\n" if $verbose; diff --git a/lib/File/stat.pm b/lib/File/stat.pm index 82cb3f6..f5d17f7 100644 --- a/lib/File/stat.pm +++ b/lib/File/stat.pm @@ -3,8 +3,7 @@ use strict; BEGIN { use Exporter (); - use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); - @ISA = qw(Exporter); + use vars qw(@EXPORT @EXPORT_OK %EXPORT_TAGS); @EXPORT = qw(stat lstat); @EXPORT_OK = qw( $st_dev $st_ino $st_mode $st_nlink $st_uid $st_gid @@ -16,7 +15,10 @@ BEGIN { } use vars @EXPORT_OK; -use Class::Template qw(struct); +# Class::Struct forbids use of @ISA +sub import { goto &Exporter::import } + +use Class::Struct qw(struct); struct 'File::stat' => [ map { $_ => '$' } qw{ dev ino mode nlink uid gid rdev size @@ -103,7 +105,7 @@ via the C pseudo-package. =head1 NOTE -While this class is currently implemented using the Class::Template +While this class is currently implemented using the Class::Struct module to build a struct-like class, you shouldn't rely upon this. =head1 AUTHOR diff --git a/lib/Net/hostent.pm b/lib/Net/hostent.pm index 1eeaae3..dfca789 100644 --- a/lib/Net/hostent.pm +++ b/lib/Net/hostent.pm @@ -3,8 +3,7 @@ use strict; BEGIN { use Exporter (); - use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); - @ISA = qw(Exporter); + use vars qw(@EXPORT @EXPORT_OK %EXPORT_TAGS); @EXPORT = qw(gethostbyname gethostbyaddr gethost); @EXPORT_OK = qw( $h_name @h_aliases @@ -15,7 +14,10 @@ BEGIN { } use vars @EXPORT_OK; -use Class::Template qw(struct); +# Class::Struct forbids use of @ISA +sub import { goto &Exporter::import } + +use Class::Struct qw(struct); struct 'Net::hostent' => [ name => '$', aliases => '@', @@ -139,7 +141,7 @@ via the C pseudo-package. =head1 NOTE -While this class is currently implemented using the Class::Template +While this class is currently implemented using the Class::Struct module to build a struct-like class, you shouldn't rely upon this. =head1 AUTHOR diff --git a/lib/Net/netent.pm b/lib/Net/netent.pm index c21096d..b82447c 100644 --- a/lib/Net/netent.pm +++ b/lib/Net/netent.pm @@ -3,8 +3,7 @@ use strict; BEGIN { use Exporter (); - use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); - @ISA = qw(Exporter); + use vars qw(@EXPORT @EXPORT_OK %EXPORT_TAGS); @EXPORT = qw(getnetbyname getnetbyaddr getnet); @EXPORT_OK = qw( $n_name @n_aliases @@ -14,7 +13,10 @@ BEGIN { } use vars @EXPORT_OK; -use Class::Template qw(struct); +# Class::Struct forbids use of @ISA +sub import { goto &Exporter::import } + +use Class::Struct qw(struct); struct 'Net::netent' => [ name => '$', aliases => '@', @@ -157,7 +159,7 @@ This seems a bug, but here's how to deal with it: =head1 NOTE -While this class is currently implemented using the Class::Template +While this class is currently implemented using the Class::Struct module to build a struct-like class, you shouldn't rely upon this. =head1 AUTHOR diff --git a/lib/Net/protoent.pm b/lib/Net/protoent.pm index ffd6acd..737ff5a 100644 --- a/lib/Net/protoent.pm +++ b/lib/Net/protoent.pm @@ -3,15 +3,17 @@ use strict; BEGIN { use Exporter (); - use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); - @ISA = qw(Exporter); + use vars qw(@EXPORT @EXPORT_OK %EXPORT_TAGS); @EXPORT = qw(getprotobyname getprotobynumber getprotoent); @EXPORT_OK = qw( $p_name @p_aliases $p_proto ); %EXPORT_TAGS = ( FIELDS => [ @EXPORT_OK, @EXPORT ] ); } use vars @EXPORT_OK; -use Class::Template qw(struct); +# Class::Struct forbids use of @ISA +sub import { goto &Exporter::import } + +use Class::Struct qw(struct); struct 'Net::protoent' => [ name => '$', aliases => '@', @@ -84,7 +86,7 @@ via the C pseudo-package. =head1 NOTE -While this class is currently implemented using the Class::Template +While this class is currently implemented using the Class::Struct module to build a struct-like class, you shouldn't rely upon this. =head1 AUTHOR diff --git a/lib/Net/servent.pm b/lib/Net/servent.pm index 8c0fc13..fb85dd0 100644 --- a/lib/Net/servent.pm +++ b/lib/Net/servent.pm @@ -3,15 +3,17 @@ use strict; BEGIN { use Exporter (); - use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); - @ISA = qw(Exporter); + use vars qw(@EXPORT @EXPORT_OK %EXPORT_TAGS); @EXPORT = qw(getservbyname getservbyport getservent getserv); @EXPORT_OK = qw( $s_name @s_aliases $s_port $s_proto ); %EXPORT_TAGS = ( FIELDS => [ @EXPORT_OK, @EXPORT ] ); } use vars @EXPORT_OK; -use Class::Template qw(struct); +# Class::Struct forbids use of @ISA +sub import { goto &Exporter::import } + +use Class::Struct qw(struct); struct 'Net::servent' => [ name => '$', aliases => '@', @@ -101,7 +103,7 @@ via the C pseudo-package. =head1 NOTE -While this class is currently implemented using the Class::Template +While this class is currently implemented using the Class::Struct module to build a struct-like class, you shouldn't rely upon this. =head1 AUTHOR diff --git a/lib/Time/gmtime.pm b/lib/Time/gmtime.pm index 353ade4..7ca12bb 100644 --- a/lib/Time/gmtime.pm +++ b/lib/Time/gmtime.pm @@ -79,7 +79,7 @@ via the C pseudo-package. =head1 NOTE -While this class is currently implemented using the Class::Template +While this class is currently implemented using the Class::Struct module to build a struct-like class, you shouldn't rely upon this. =head1 AUTHOR diff --git a/lib/Time/localtime.pm b/lib/Time/localtime.pm index 8f7695b..8d72da1 100644 --- a/lib/Time/localtime.pm +++ b/lib/Time/localtime.pm @@ -75,7 +75,7 @@ via the C pseudo-package. =head1 NOTE -While this class is currently implemented using the Class::Template +While this class is currently implemented using the Class::Struct module to build a struct-like class, you shouldn't rely upon this. =head1 AUTHOR diff --git a/lib/Time/tm.pm b/lib/Time/tm.pm index 7041432..fd47ad1 100644 --- a/lib/Time/tm.pm +++ b/lib/Time/tm.pm @@ -1,7 +1,7 @@ package Time::tm; use strict; -use Class::Template qw(struct); +use Class::Struct qw(struct); struct('Time::tm' => [ map { $_ => '$' } qw{ sec min hour mday mon year wday yday isdst } ]); diff --git a/lib/User/grent.pm b/lib/User/grent.pm index 3c4635b..deb0a8d 100644 --- a/lib/User/grent.pm +++ b/lib/User/grent.pm @@ -3,15 +3,17 @@ use strict; BEGIN { use Exporter (); - use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); - @ISA = qw(Exporter); + use vars qw(@EXPORT @EXPORT_OK %EXPORT_TAGS); @EXPORT = qw(getgrent getgrgid getgrnam getgr); @EXPORT_OK = qw($gr_name $gr_gid $gr_passwd $gr_mem @gr_members); %EXPORT_TAGS = ( FIELDS => [ @EXPORT_OK, @EXPORT ] ); } use vars @EXPORT_OK; -use Class::Template qw(struct); +# Class::Struct forbids use of @ISA +sub import { goto &Exporter::import } + +use Class::Struct qw(struct); struct 'User::grent' => [ name => '$', passwd => '$', @@ -83,7 +85,7 @@ via the C pseudo-package. =head1 NOTE -While this class is currently implemented using the Class::Template +While this class is currently implemented using the Class::Struct module to build a struct-like class, you shouldn't rely upon this. =head1 AUTHOR diff --git a/lib/User/pwent.pm b/lib/User/pwent.pm index a027fe6..183a641 100644 --- a/lib/User/pwent.pm +++ b/lib/User/pwent.pm @@ -3,8 +3,7 @@ use strict; BEGIN { use Exporter (); - use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); - @ISA = qw(Exporter); + use vars qw(@EXPORT @EXPORT_OK %EXPORT_TAGS); @EXPORT = qw(getpwent getpwuid getpwnam getpw); @EXPORT_OK = qw( $pw_name $pw_passwd $pw_uid @@ -15,7 +14,10 @@ BEGIN { } use vars @EXPORT_OK; -use Class::Template qw(struct); +# Class::Struct forbids use of @ISA +sub import { goto &Exporter::import } + +use Class::Struct qw(struct); struct 'User::pwent' => [ name => '$', passwd => '$', @@ -93,7 +95,7 @@ via the C pseudo-package. =head1 NOTE -While this class is currently implemented using the Class::Template +While this class is currently implemented using the Class::Struct module to build a struct-like class, you shouldn't rely upon this. =head1 AUTHOR diff --git a/mg.c b/mg.c index 54ca044..1355740 100644 --- a/mg.c +++ b/mg.c @@ -1536,7 +1536,8 @@ MAGIC* mg; break; gary[i] = I_V(atof(p)); } - (void)setgroups(i, gary); + if (i) + (void)setgroups(i, gary); } #else /* HAS_SETGROUPS */ egid = SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv); diff --git a/minimod.pl b/minimod.pl index b9b7071..82760ee 100755 --- a/minimod.pl +++ b/minimod.pl @@ -40,7 +40,7 @@ $tail=<<'EOF!TAIL'; END while () { - print; + print unless /dXSUB_SYS/; } close MINI; @@ -65,7 +65,9 @@ sub writemain{ my ($tail1,$tail2) = ( $tail =~ /\A(.*\n)(\s*\}.*)\Z/s ); print $tail1; - print " char *file = __FILE__;\n"; + print "\tchar *file = __FILE__;\n"; + print "\tdXSUB_SYS;\n" if $] > 5.002; + foreach $_ (@exts){ my($pname) = canon('/', $_); my($mname, $cname, $ccode); diff --git a/os2/os2ish.h b/os2/os2ish.h index 06a92a3..a1b6db9 100644 --- a/os2/os2ish.h +++ b/os2/os2ish.h @@ -78,7 +78,7 @@ void Perl_OS2_init(char **); /* #define PERL_SYS_TERM() STMT_START { \ if (Perl_HAB_set) WinTerminate(Perl_hab); } STMT_END */ -#define dXSUB_SYS int fake = OS2_XS_init() +#define dXSUB_SYS OS2_XS_init() #ifdef PERL_IS_AOUT /* # define HAS_FORK */ @@ -156,6 +156,7 @@ void *emx_realloc (void *, size_t); #define Stat(fname,bufptr) os2_stat((fname),(bufptr)) #define Fstat(fd,bufptr) fstat((fd),(bufptr)) #define Fflush(fp) fflush(fp) +#define Mkdir(path,mode) mkdir((path),(mode)) #undef S_IFBLK #undef S_ISBLK @@ -167,6 +168,7 @@ void *emx_realloc (void *, size_t); #define Stat(fname,bufptr) stat((fname),(bufptr)) #define Fstat(fd,bufptr) fstat((fd),(bufptr)) #define Fflush(fp) fflush(fp) +#define Mkdir(path,mode) mkdir((path),(mode)) #endif diff --git a/patchlevel.h b/patchlevel.h index e768691..32c4800 100644 --- a/patchlevel.h +++ b/patchlevel.h @@ -40,6 +40,7 @@ static char *local_patches[] = { NULL ,"Dev97A - First development patch to 5.003_97" ,"Dev97B - Second development patch to 5.003_97" + ,"Dev97C - Third development patch to 5.003_97" ,NULL }; diff --git a/plan9/plan9ish.h b/plan9/plan9ish.h index c225d28..3a5ad5e 100644 --- a/plan9/plan9ish.h +++ b/plan9/plan9ish.h @@ -99,7 +99,7 @@ #define BIT_BUCKET "/dev/null" #define PERL_SYS_INIT(c,v) -#define dXSUB_SYS int dummy +#define dXSUB_SYS #define PERL_SYS_TERM() /* @@ -113,6 +113,7 @@ #define Stat(fname,bufptr) stat((fname),(bufptr)) #define Fstat(fd,bufptr) fstat((fd),(bufptr)) #define Fflush(fp) fflush(fp) +#define Mkdir(path,mode) mkdir((path),(mode)) /* getenv related stuff */ #define my_getenv(var) getenv(var) diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 1447fd4..4aa05ed 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -35,6 +35,29 @@ variable as if its contents had appeared on a "#!perl" line at the beginning of your script, except that hyphens are optional. PERL5OPT may only be used to set the following switches: B<-[DIMUdmw]>. +=head2 Limitations on B<-M>, and C<-m>, and B<-T> options + +The C<-M> and C<-m> options are no longer allowed on the C<#!> line of +a script. If a script needs a module, it should invoke it with the +C pragma. + +The B<-T> option is also forbidden on the C<#!> line of a script, +unless it was present on the Perl command line. Due to the way C<#!> +works, this usually means that B<-T> must be in the first argument. +Thus: + + #!/usr/bin/perl -T -w + +will probably work for an executable script invoked as C, +while: + + #!/usr/bin/perl -w -T + +will probably fail under the same conditions. (Non-Unix systems will +probably not follow this rule.) But C is guaranteed +to fail, since then there is no chance of B<-T> being found on the +command line before it is found on the C<#!> line. + =head2 More precise warnings If you removed the B<-w> option from your Perl 5.003 scripts because it @@ -84,18 +107,18 @@ After this code executes in Perl 5.004, $a{b} exists but $a[2] does not. In Perl 5.002 and 5.003, both $a{b} and $a[2] would have existed (but $a[2]'s value would have been undefined). -=head2 C<$)> is writable +=head2 Group vector changeable with C<$)> The C<$)> special variable has always (well, in Perl 5, at least) -reflected not only the current effective group, but also the group -list as returned by the C C function (if there is one). -However, due to an oversight, assigning to C<$)> has not called -C, only C. +reflected not only the current effective group, but also the group list +as returned by the C C function (if there is one). +However, until this release, there has not been a way to call the +C C function from Perl. -In Perl 5.004, assigning to C<$)> is exactly symmetrical with -examining it: The first number in its string value is used as the -effective gid, and all the others are passed to the C C -function (if there is one). +In Perl 5.004, assigning to C<$)> is exactly symmetrical with examining +it: The first number in its string value is used as the effective gid; +if there are any numbers after the first one, they are passed to the +C C function (if there is one). =head2 Fixed parsing of $$, &$, etc. @@ -127,9 +150,9 @@ calculation of a return value if it isn't going to be used. =head2 Changes to tainting checks A bug in previous versions may have failed to detect some insecure -conditions when taint checks are turned on. (Taint checks are used +conditions when taint checks are turned on. (Taint checks are used in setuid or setgid scripts, or when explicitly turned on with the -C<-T> invocation option.) Although it's unlikely, this may cause a +C<-T> invocation option.) Although it's unlikely, this may cause a previously-working script to now fail -- which should be construed as a blessing, since that indicates a potentially-serious security hole was just plugged. @@ -662,17 +685,17 @@ alphabetically: FindBin.pm Find path of currently executing program - Class/Template.pm Structure/member template builder - File/stat.pm Object-oriented wrapper around CORE::stat - Net/hostent.pm Object-oriented wrapper around CORE::gethost* - Net/netent.pm Object-oriented wrapper around CORE::getnet* - Net/protoent.pm Object-oriented wrapper around CORE::getproto* - Net/servent.pm Object-oriented wrapper around CORE::getserv* - Time/gmtime.pm Object-oriented wrapper around CORE::gmtime - Time/localtime.pm Object-oriented wrapper around CORE::localtime - Time/tm.pm Perl implementation of "struct tm" for {gm,local}time - User/grent.pm Object-oriented wrapper around CORE::getgr* - User/pwent.pm Object-oriented wrapper around CORE::getpw* + Class/Struct.pm Declare struct-like datatypes as Perl classes + File/stat.pm By-name interface to Perl's built-in stat + Net/hostent.pm By-name interface to Perl's built-in gethost* + Net/netent.pm By-name interface to Perl's built-in getnet* + Net/protoent.pm By-name interface to Perl's built-in getproto* + Net/servent.pm By-name interface to Perl's built-in getserv* + Time/gmtime.pm By-name interface to Perl's built-in gmtime + Time/localtime.pm By-name interface to Perl's built-in localtime + Time/tm.pm Internal object for Time::{gm,local}time + User/grent.pm By-name interface to Perl's built-in getgr* + User/pwent.pm By-name interface to Perl's built-in getpw* Tie/RefHash.pm Base class for tied hashes with references as keys diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 0543595..cdc7c59 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -2263,10 +2263,10 @@ system call to call, silly dilly. =item Too late for "B<-T>" option (X) The #! line (or local equivalent) in a Perl script contains the -B<-T> option, but Perl was not invoked with B<-T> in its argument -list. This is an error because, by the time Perl discovers a B<-T> in -a script, it's too late to properly taint everything from the -environment. So Perl gives up. +B<-T> option, but Perl was not invoked with B<-T> in its command line. +This is an error because, by the time Perl discovers a B<-T> in a +script, it's too late to properly taint everything from the environment. +So Perl gives up. If the Perl script is being executed as a command using the #! mechanism (or its local equivalent), this error can usually be fixed @@ -2276,6 +2276,12 @@ first argument: e.g. change C to C. If the Perl script is being executed as C, then the B<-T> option must appear on the command line: C. +=item Too late for "-%s" option + +(X) The #! line (or local equivalent) in a Perl script contains the +B<-M> or B<-m> option. This is an error because B<-M> and B<-m> options +are not intended for use inside scripts. Use the C pragma instead. + =item Too many ('s =item Too many )'s diff --git a/pod/perlfaq7.pod b/pod/perlfaq7.pod index c272c91..1047b28 100644 --- a/pod/perlfaq7.pod +++ b/pod/perlfaq7.pod @@ -539,7 +539,7 @@ Why do you want to do that? :-) If you want to override a predefined function, such as open(), then you'll have to import the new definition from a different module. See L. There's -also an example in L. +also an example in L. If you want to overload a Perl operator, such as C<+> or C<**>, then you'll want to use the C pragma, documented diff --git a/pod/perlmod.pod b/pod/perlmod.pod index 0b384ab..cfdcdda 100644 --- a/pod/perlmod.pod +++ b/pod/perlmod.pod @@ -502,9 +502,9 @@ run CPAN while avoiding compiled extensions warn of errors (from perspective of caller) -=item Class::Template +=item Class::Struct -struct/member template builder +declare struct-like datatypes =item Config diff --git a/pod/perltoc.pod b/pod/perltoc.pod index ce590dc..ae5f768 100644 --- a/pod/perltoc.pod +++ b/pod/perltoc.pod @@ -827,13 +827,15 @@ file on another machine? =item $PERL5OPT environment variable +=item Limitations on B<-M>, and C<-m>, and B<-T> options + =item More precise warnings =item Deprecated: Inherited C for non-methods =item Subroutine arguments created only when they're modified -=item C<$)> is writable +=item Group vector changeable with C<$)> =item Fixed parsing of $$, &$, etc. @@ -1322,7 +1324,7 @@ strict, subs, vmsish, vars =item Standard Modules AnyDBM_File, AutoLoader, AutoSplit, Benchmark, CPAN, CPAN::FirstTime, -CPAN::Nox, Carp, Class::Template, Config, Cwd, DB_File, Devel::SelfStubber, +CPAN::Nox, Carp, Class::Struct, Config, Cwd, DB_File, Devel::SelfStubber, DirHandle, DynaLoader, English, Env, Exporter, ExtUtils::Embed, ExtUtils::Install, ExtUtils::Liblist, ExtUtils::MM_OS2, ExtUtils::MM_Unix, ExtUtils::MM_VMS, ExtUtils::MakeMaker, ExtUtils::Manifest, @@ -1696,7 +1698,7 @@ more elaborate constructs =over -=item Class::Template +=item Class::Struct =item Data Members as Variables @@ -3112,17 +3114,28 @@ module =item DESCRIPTION -=head2 Class::Template - struct/member template builder +=head2 Class::Struct - declare struct-like datatypes as Perl classes =item SYNOPSIS =item DESCRIPTION +=over + +=item The C function + +=item Element Types and Accessor Methods + +Scalar (C<'$'> or C<'*$'>), Array (C<'@'> or C<'*@'>), Hash (C<'%'> or +C<'*%'>), Class (C<'Class_Name'> or C<'*Class_Name'>) + +=back + =item EXAMPLES Example 1, Example 2 -=item NOTES +=item Author and Modification History =head2 Config - access Perl configuration information @@ -3801,8 +3814,9 @@ new (), new_from_fd ( FD, MODE ) =item METHODS -$fh->getline, $fh->getlines, $fh->fdopen ( FD, MODE ), $fh->write ( BUF, -LEN [, OFFSET }\] ), $fh->opened, $fh->untaint +$fh->fdopen ( FD, MODE ), $fh->opened, $fh->getline, $fh->getlines, +$fh->ungetc ( ORD ), $fh->write ( BUF, LEN [, OFFSET }\] ), $fh->flush, +$fh->error, $fh->clearerr, $fh->untaint =item NOTE @@ -3935,8 +3949,9 @@ new (), new_from_fd ( FD, MODE ) =item METHODS -$fh->getline, $fh->getlines, $fh->fdopen ( FD, MODE ), $fh->write ( BUF, -LEN [, OFFSET }\] ), $fh->opened, $fh->untaint +$fh->fdopen ( FD, MODE ), $fh->opened, $fh->getline, $fh->getlines, +$fh->ungetc ( ORD ), $fh->write ( BUF, LEN [, OFFSET }\] ), $fh->flush, +$fh->error, $fh->clearerr, $fh->untaint =item NOTE diff --git a/pod/perltoot.pod b/pod/perltoot.pod index c235912..0c5b418 100644 --- a/pod/perltoot.pod +++ b/pod/perltoot.pod @@ -1467,12 +1467,12 @@ as detailed above. Perl programmers have responded to this by creating several different class construction classes. These metaclasses are classes that create other classes. A couple worth looking at are -Class::Template and Alias. These and other related metaclasses can be +Class::Struct and Alias. These and other related metaclasses can be found in the modules directory on CPAN. -=head2 Class::Template +=head2 Class::Struct -One of the older ones is Class::Template. In fact, its syntax and +One of the older ones is Class::Struct. In fact, its syntax and interface were sketched out long before perl5 even solidified into a real thing. What it does is provide you a way to "declare" a class as having objects whose fields are of a specific type. The function @@ -1481,11 +1481,11 @@ structures or records are not base types in Perl, each time you want to create a class to provide a record-like data object, you yourself have to define a new() method, plus separate data-access methods for each of that record's fields. You'll quickly become bored with this process. -The Class::Template::struct() function alleviates this tedium. +The Class::Struct::struct() function alleviates this tedium. Here's a simple example of using it: - use Class::Template qw(struct); + use Class::Struct qw(struct); use Jobbie; # user-defined; see below struct 'Fred' => { @@ -1520,7 +1520,7 @@ act like structs in the C sense. printf "perl.com's real name is %s, address %s\n", $h->name, inet_ntoa($h->addr); -Here's how to do this using the Class::Template module. +Here's how to do this using the Class::Struct module. The crux is going to be this call: struct 'Net::hostent' => [ # note bracket @@ -1544,7 +1544,7 @@ We could also have implemented our object this way: addr_list => '@', }; -and then Class::Template would have used an anonymous hash as the object +and then Class::Struct would have used an anonymous hash as the object type, instead of an anonymous array. The array is faster and smaller, but the hash works out better if you eventually want to do inheritance. Since for this struct-like object we aren't planning on inheritance, @@ -1557,8 +1557,7 @@ Here's the whole implementation: BEGIN { use Exporter (); - use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); - @ISA = qw(Exporter); + use vars qw(@EXPORT @EXPORT_OK %EXPORT_TAGS); @EXPORT = qw(gethostbyname gethostbyaddr gethost); @EXPORT_OK = qw( $h_name @h_aliases @@ -1569,7 +1568,10 @@ Here's the whole implementation: } use vars @EXPORT_OK; - use Class::Template qw(struct); + # Class::Struct forbids use of @ISA + sub import { goto &Exporter::import } + + use Class::Struct qw(struct); struct 'Net::hostent' => [ name => '$', aliases => '@', @@ -1582,7 +1584,7 @@ Here's the whole implementation: sub populate (@) { return unless @_; - my $hob = new(); # Class::Template made this! + my $hob = new(); # Class::Struct made this! $h_name = $hob->[0] = $_[0]; @h_aliases = @{ $hob->[1] } = split ' ', $_[1]; $h_addrtype = $hob->[2] = $_[2]; @@ -1615,9 +1617,10 @@ Here's the whole implementation: We've snuck in quite a fair bit of other concepts besides just dynamic class creation, like overriding core functions, import/export bits, -function prototyping, and short-cut function call via C<&whatever>. -These all mostly make sense from the perspective of a traditional module, -but as you can see, we can also use them in an object module. +function prototyping, short-cut function call via C<&whatever>, and +function replacement with C. These all mostly make +sense from the perspective of a traditional module, but as you can see, +we can also use them in an object module. You can look at other object-based, struct-like overrides of core functions in the 5.004 release of Perl in File::stat, Net::hostent, @@ -1695,7 +1698,7 @@ they're still considered global variables with temporary values, just as with any other local(). It would be nice to combine Alias with -something like Class::Template or Class::MethodMaker. +something like Class::Struct or Class::MethodMaker. =head2 NOTES diff --git a/pod/perlvar.pod b/pod/perlvar.pod index 00b97ba..198e5c1 100644 --- a/pod/perlvar.pod +++ b/pod/perlvar.pod @@ -490,8 +490,9 @@ The effective uid of this process. Example: $< = $>; # set real to effective uid ($<,$>) = ($>,$<); # swap real and effective uid -(Mnemonic: it's the uid you went I, if you're running setuid.) Note: -"C<$E>" and "C<$E>" can be swapped on only machines supporting setreuid(). +(Mnemonic: it's the uid you went I, if you're running setuid.) +Note: "C<$E>" and "C<$E>" can be swapped only on machines +supporting setreuid(). =item $REAL_GROUP_ID @@ -503,8 +504,14 @@ The real gid of this process. If you are on a machine that supports membership in multiple groups simultaneously, gives a space separated list of groups you are in. The first number is the one returned by getgid(), and the subsequent ones by getgroups(), one of which may be -the same as the first number. (Mnemonic: parentheses are used to I -things. The real gid is the group you I, if you're running setgid.) +the same as the first number. + +However, a value assigned to "C<$(>" must be a single number used to +set the real gid. So the value given by "C<$(>" should I be assigned +back to "C<$(>" without being forced numeric, such as by adding zero. + +(Mnemonic: parentheses are used to I things. The real gid is the +group you I, if you're running setgid.) =item $EFFECTIVE_GROUP_ID @@ -516,15 +523,21 @@ The effective gid of this process. If you are on a machine that supports membership in multiple groups simultaneously, gives a space separated list of groups you are in. The first number is the one returned by getegid(), and the subsequent ones by getgroups(), one of -which may be the same as the first number. (Mnemonic: parentheses are -used to I things. The effective gid is the group that's I for -you, if you're running setgid.) +which may be the same as the first number. + +Similarly, a value assigned to "C<$)>" must also be a space-separated +list of numbers. The first number is used to set the effective gid, and +the rest (if any) are passed to setgroups(). To get the effect of an +empty list for setgroups(), just repeat the new effective gid; that is, +to force an effective gid of 5 and an effectively empty setgroups() +list, say C< $) = "5 5" >. + +(Mnemonic: parentheses are used to I things. The effective gid +is the group that's I for you, if you're running setgid.) Note: "C<$E>", "C<$E>", "C<$(>" and "C<$)>" can be set only on machines that support the corresponding I routine. "C<$(>" -and "C<$)>" can be swapped on only machines supporting setregid(). Because -Perl doesn't currently use initgroups(), you can't set your group vector to -multiple groups. +and "C<$)>" can be swapped only on machines supporting setregid(). =item $PROGRAM_NAME diff --git a/pp_sys.c b/pp_sys.c index fe11f85..bc22763 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -2728,7 +2728,7 @@ PP(pp_mkdir) TAINT_PROPER("mkdir"); #ifdef HAS_MKDIR - SETi( mkdir(tmps, mode) >= 0 ); + SETi( Mkdir(tmps, mode) >= 0 ); #else SETi( dooneliner("mkdir", tmps) ); oldumask = umask(0); diff --git a/toke.c b/toke.c index c40955a..6a306ec 100644 --- a/toke.c +++ b/toke.c @@ -1696,7 +1696,15 @@ yylex() while (*d == ' ' || *d == '\t') d++; if (*d++ == '-') { - while (d = moreswitches(d)) ; + do { + if (*d == 'M' || *d == 'm') { + char *m = d; + while (*d && !isSPACE(*d)) d++; + croak("Too late for \"-%.*s\" option", + (int)(d - m), m); + } + d = moreswitches(d); + } while (d); if (perldb && !oldpdb || ( minus_n || minus_p ) && !(oldn || oldp) ) /* if we have already added "LINE: while (<>) {", diff --git a/unixish.h b/unixish.h index 3e39e7d..4968a38 100644 --- a/unixish.h +++ b/unixish.h @@ -104,6 +104,7 @@ #define Stat(fname,bufptr) stat((fname),(bufptr)) #define Fstat(fd,bufptr) fstat((fd),(bufptr)) #define Fflush(fp) fflush(fp) +#define Mkdir(path,mode) mkdir((path),(mode)) #ifdef PERL_SCO5 # define PERL_SYS_INIT(c,v) fpsetmask(0) diff --git a/vms/vms.c b/vms/vms.c index 969cbe0..20710f7 100644 --- a/vms/vms.c +++ b/vms/vms.c @@ -455,6 +455,28 @@ kill_file(char *name) } /* end of kill_file() */ /*}}}*/ + +/*{{{int my_mkdir(char *,mode_t)*/ +int +my_mkdir(char *dir, mode_t mode) +{ + STRLEN dirlen = strlen(dir); + + /* CRTL mkdir() doesn't tolerate trailing /, since that implies + * null file name/type. However, it's commonplace under Unix, + * so we'll allow it for a gain in portability. + */ + if (dir[dirlen-1] == '/') { + char *newdir = savepvn(dir,dirlen-1); + int ret = mkdir(newdir,mode); + Safefree(newdir); + return ret; + } + else return mkdir(dir,mode); +} /* end of my_mkdir */ +/*}}}*/ + + static void create_mbx(unsigned short int *chan, struct dsc$descriptor_s *namdsc) { diff --git a/vms/vmsish.h b/vms/vmsish.h index fd4434e..9917232 100644 --- a/vms/vmsish.h +++ b/vms/vmsish.h @@ -88,6 +88,7 @@ # define my_gconvert Perl_my_gconvert # define do_rmdir Perl_do_rmdir # define kill_file Perl_kill_file +# define my_mkdir Perl_my_mkdir # define my_utime Perl_my_utime # define rmsexpand Perl_rmsexpand # define rmsexpand_ts Perl_rmsexpand_ts @@ -226,7 +227,7 @@ #define BIT_BUCKET "_NLA0:" #define PERL_SYS_INIT(c,v) getredirection((c),(v)) #define PERL_SYS_TERM() -#define dXSUB_SYS int dummy +#define dXSUB_SYS #define HAS_KILL #define HAS_WAIT @@ -349,6 +350,9 @@ struct utimbuf { /* Ditto for sys$hash_passwrod() . . . */ #define crypt my_crypt +/* Tweak arg to mkdir first, so we can tolerate trailing /. */ +#define Mkdir(dir,mode) my_mkdir((dir),(mode)) + /* Use our own stat() clones, which handle Unix-style directory names */ #define Stat(name,bufptr) flex_stat(name,bufptr) #define Fstat(fd,bufptr) flex_fstat(fd,bufptr) @@ -506,6 +510,7 @@ Pid_t my_waitpid _((Pid_t, int *, int)); char * my_gconvert _((double, int, int, char *)); int do_rmdir _((char *)); int kill_file _((char *)); +int my_mkdir _((char *, mode_t)); int my_utime _((char *, struct utimbuf *)); char * rmsexpand _((char *, char *, char *, unsigned)); char * rmsexpand_ts _((char *, char *, char *, unsigned));