diff -Naur perl-5.28.0.orig/MANIFEST perl-5.28.0/MANIFEST --- perl-5.28.0.orig/MANIFEST 2018-05-23 15:29:56.000000000 +0200 +++ perl-5.28.0/MANIFEST 2018-09-16 18:29:15.492576340 +0200 @@ -4747,7 +4747,8 @@ lib/Tie/Array/splice.t Test for Tie::Array::SPLICE lib/Tie/Array/std.t Test for Tie::StdArray lib/Tie/Array/stdpush.t Test for Tie::StdArray -lib/Tie/ExtraHash.t Test for Tie::ExtraHash (in Tie/Hash.pm) +lib/Tie/ExtraHash.pm Tie::ExtraHash +lib/Tie/ExtraHash.t Test for Tie::ExtraHash lib/Tie/Handle.pm Base class for tied handles lib/Tie/Handle/stdhandle.t Test for Tie::StdHandle lib/Tie/Handle/stdhandle_from_handle.t Test for Tie::StdHandle/Handle backwards compat @@ -4755,7 +4756,10 @@ lib/Tie/Hash.t See if Tie::Hash works lib/Tie/Scalar.pm Base class for tied scalars lib/Tie/Scalar.t See if Tie::Scalar works +lib/Tie/StdArray.pm Tie::StdArray lib/Tie/StdHandle.pm Tie::StdHandle +lib/Tie/StdHash.pm Tie::StdHash +lib/Tie/StdScalar.pm Tie::StdScalar lib/Tie/SubstrHash.pm Compact hash for known key, value and table size lib/Tie/SubstrHash.t Test for Tie::SubstrHash lib/Time/gmtime.pm By-name interface to Perl's builtin gmtime diff -Naur perl-5.28.0.orig/Porting/Maintainers.pl perl-5.28.0/Porting/Maintainers.pl --- perl-5.28.0.orig/Porting/Maintainers.pl 2018-06-19 23:15:34.000000000 +0200 +++ perl-5.28.0/Porting/Maintainers.pl 2018-09-16 19:08:13.327438271 +0200 @@ -1406,12 +1406,15 @@ lib/Thread.{pm,t} lib/Tie/Array.pm lib/Tie/Array/ - lib/Tie/ExtraHash.t + lib/Tie/ExtraHash.{pm,t} lib/Tie/Handle.pm lib/Tie/Handle/ lib/Tie/Hash.{pm,t} lib/Tie/Scalar.{pm,t} + lib/Tie/StdArray.pm lib/Tie/StdHandle.pm + lib/Tie/StdHash.pm + lib/Tie/StdScalar.pm lib/Tie/SubstrHash.{pm,t} lib/Time/gmtime.{pm,t} lib/Time/localtime.{pm,t} diff -Naur perl-5.28.0.orig/lib/Tie/Array.pm perl-5.28.0/lib/Tie/Array.pm --- perl-5.28.0.orig/lib/Tie/Array.pm 2018-05-21 14:29:23.000000000 +0200 +++ perl-5.28.0/lib/Tie/Array.pm 2018-09-16 19:08:59.525376168 +0200 @@ -2,12 +2,13 @@ use 5.006_001; use strict; -use Carp; -our $VERSION = '1.07'; +use warnings; +use Tie::StdArray (); # for backwards compatibility + +our $VERSION = '1.08'; # Pod documentation after __END__ below. -sub DESTROY { } sub EXTEND { } sub UNSHIFT { scalar shift->SPLICE(0,0,@_) } sub SHIFT { shift->SPLICE(0,1) } @@ -72,42 +73,6 @@ return wantarray ? @result : pop @result; } -sub EXISTS { - my $pkg = ref $_[0]; - croak "$pkg doesn't define an EXISTS method"; -} - -sub DELETE { - my $pkg = ref $_[0]; - croak "$pkg doesn't define a DELETE method"; -} - -package Tie::StdArray; -our @ISA = 'Tie::Array'; - -sub TIEARRAY { bless [], $_[0] } -sub FETCHSIZE { scalar @{$_[0]} } -sub STORESIZE { $#{$_[0]} = $_[1]-1 } -sub STORE { $_[0]->[$_[1]] = $_[2] } -sub FETCH { $_[0]->[$_[1]] } -sub CLEAR { @{$_[0]} = () } -sub POP { pop(@{$_[0]}) } -sub PUSH { my $o = shift; push(@$o,@_) } -sub SHIFT { shift(@{$_[0]}) } -sub UNSHIFT { my $o = shift; unshift(@$o,@_) } -sub EXISTS { exists $_[0]->[$_[1]] } -sub DELETE { delete $_[0]->[$_[1]] } - -sub SPLICE -{ - my $ob = shift; - my $sz = $ob->FETCHSIZE; - my $off = @_ ? shift : 0; - $off += $sz if $off < 0; - my $len = @_ ? shift : $sz-$off; - return splice(@$ob,$off,$len,@_); -} - 1; __END__ @@ -119,8 +84,7 @@ =head1 SYNOPSIS package Tie::NewArray; - use Tie::Array; - @ISA = ('Tie::Array'); + use parent 'Tie::Array'; # mandatory methods sub TIEARRAY { ... } @@ -142,37 +106,21 @@ sub EXTEND { ... } sub DESTROY { ... } - package Tie::NewStdArray; - use Tie::Array; - - @ISA = ('Tie::StdArray'); - - # all methods provided by default - package main; $object = tie @somearray,'Tie::NewArray'; - $object = tie @somearray,'Tie::StdArray'; - $object = tie @somearray,'Tie::NewStdArray'; - =head1 DESCRIPTION This module provides methods for array-tying classes. See L for a list of the functions required in order to tie an array -to a package. The basic B package provides stub C, -and C methods that do nothing, stub C and C -methods that croak() if the delete() or exists() builtins are ever called -on the tied array, and implementations of C, C, C, +to a package. The basic B package provides a stub +C method that does nothing, +and implementations of C, C, C, C, C and C in terms of basic C, C, C, C. -The B package provides efficient methods required for tied arrays -which are implemented as blessed references to an "inner" perl array. -It inherits from B, and should cause tied arrays to behave exactly -like standard arrays, allowing for selective overloading of methods. - For developers wishing to write their own tied arrays, the required methods are briefly defined below. See the L section for more detailed descriptive, as well as example code: @@ -270,6 +218,18 @@ =back +=head1 CHANGES + +C up to version 1.07 had an unnecessarily complex setup +of C and C. To inherit from C, just add +a C constructor to your class. If your code used C, just +rename it to C. C is gone, and so are C and +C. + +C was included in C up to version 1.07. Now, +it is a properly separated classes. C still loads it to avoid +breaking code. + =head1 CAVEATS There is no support at present for tied @ISA. There is a potential conflict diff -Naur perl-5.28.0.orig/lib/Tie/ExtraHash.pm perl-5.28.0/lib/Tie/ExtraHash.pm --- perl-5.28.0.orig/lib/Tie/ExtraHash.pm 1970-01-01 01:00:00.000000000 +0100 +++ perl-5.28.0/lib/Tie/ExtraHash.pm 2018-09-16 18:01:49.062782093 +0200 @@ -0,0 +1,100 @@ +package Tie::ExtraHash; + +use strict; +use warnings; +use parent 'Tie::Hash'; # allow for new methods in future versions of perl + +our $VERSION = '1.06'; + +=head1 NAME + +Tie::ExtraHash - base class definition for tied hashes + +=head1 SYNOPSIS + + package NewExtraHash; + + use parent 'Tie::ExtraHash'; + + # All methods provided by default, define + # only those needing overrides + # Accessors access the storage in %{$_[0][0]}; + # TIEHASH should return an array reference with the first element + # being the reference to the actual storage + sub DELETE { + $_[0][1]->('del', $_[0][0], $_[1]); # Call the report writer + delete $_[0][0]->{$_[1]}; # $_[0]->SUPER::DELETE($_[1]) + } + + + package main; + + tie %new_extra_hash, 'NewExtraHash', + sub {warn "Doing \U$_[1]\E of $_[2].\n"}; + +=head1 DESCRIPTION + + +This module provides some skeletal methods for hash-tying classes, +behaving exactly like standard hashes +and allows for selective overwriting of methods. +See L for a list of the functions required in order to tie a hash +to a package. + +For developers wishing to write their own tied hashes, the required methods +are briefly defined in L. See the L section for more detailed +descriptive, as well as example code. + +=head1 Inheriting from B + +The accessor methods assume that the actual storage for the data in the tied +hash is in the hash referenced by C<(tied(%tiedhash))-E[0]>. Thus overwritten +C method should return an array reference with the first +element being a hash reference, and the remaining methods should operate on the +hash C<< %{ $_[0]->[0] } >>: + + package ReportHash; + use parent 'Tie::ExtraHash'; + + sub TIEHASH { + my $class = shift; + my $self = bless [{}, @_], $class; + warn "New ReportHash created, stored in $sself.\n"; + $self; + } + sub STORE { + warn "Storing data with key $_[1] at $_[0].\n"; + $_[0][0]{$_[1]} = $_[2] + } + +The default C method stores "extra" arguments to tie() starting +from offset 1 in the array referenced by C; this is the +same storage algorithm as in TIEHASH subroutine above. Hence, a typical +package inheriting from B does not need to overwrite this +method. + +=head1 CHANGES + +C prior to version 1.06 was hidden in C, and so you +had to manually load C and manipulate C<@ISA> like this: + + use Tie::Hash; + our @ISA=('Tie::ExtraHash'); + +And while this still works, new code should do this instead: + + use parent 'Tie::ExtraHash'; + +=cut + +sub TIEHASH { my $p = shift; bless [{}, @_], $p } +sub STORE { $_[0][0]{$_[1]} = $_[2] } +sub FETCH { $_[0][0]{$_[1]} } +sub FIRSTKEY { my $a = scalar keys %{$_[0][0]}; each %{$_[0][0]} } +sub NEXTKEY { each %{$_[0][0]} } +sub EXISTS { exists $_[0][0]->{$_[1]} } +sub DELETE { delete $_[0][0]->{$_[1]} } +sub CLEAR { %{$_[0][0]} = () } +sub SCALAR { scalar %{$_[0][0]} } + +1; diff -Naur perl-5.28.0.orig/lib/Tie/Hash.pm perl-5.28.0/lib/Tie/Hash.pm --- perl-5.28.0.orig/lib/Tie/Hash.pm 2018-03-20 21:06:36.000000000 +0100 +++ perl-5.28.0/lib/Tie/Hash.pm 2018-09-16 18:23:34.233034429 +0200 @@ -1,68 +1,38 @@ package Tie::Hash; -our $VERSION = '1.05'; +use strict; +use warnings; +use Tie::StdHash (); # for backwards compatibility +use Tie::ExtraHash (); # for backwards compatibility + +our $VERSION = '1.06'; =head1 NAME -Tie::Hash, Tie::StdHash, Tie::ExtraHash - base class definitions for tied hashes +Tie::Hash - base class for tied hashes =head1 SYNOPSIS package NewHash; - require Tie::Hash; - - @ISA = qw(Tie::Hash); + use parent 'Tie::Hash'; sub DELETE { ... } # Provides needed method sub CLEAR { ... } # Overrides inherited method - package NewStdHash; - require Tie::Hash; - - @ISA = qw(Tie::StdHash); - - # All methods provided by default, define - # only those needing overrides - # Accessors access the storage in %{$_[0]}; - # TIEHASH should return a reference to the actual storage - sub DELETE { ... } - - package NewExtraHash; - require Tie::Hash; - - @ISA = qw(Tie::ExtraHash); - - # All methods provided by default, define - # only those needing overrides - # Accessors access the storage in %{$_[0][0]}; - # TIEHASH should return an array reference with the first element - # being the reference to the actual storage - sub DELETE { - $_[0][1]->('del', $_[0][0], $_[1]); # Call the report writer - delete $_[0][0]->{$_[1]}; # $_[0]->SUPER::DELETE($_[1]) - } - - package main; tie %new_hash, 'NewHash'; - tie %new_std_hash, 'NewStdHash'; - tie %new_extra_hash, 'NewExtraHash', - sub {warn "Doing \U$_[1]\E of $_[2].\n"}; =head1 DESCRIPTION -This module provides some skeletal methods for hash-tying classes. See +This module provides skeletal methods for hash-tying classes. See L for a list of the functions required in order to tie a hash -to a package. The basic B package provides a C method, as well -as methods C, C and C. The B and -B packages -provide most methods for hashes described in L (the exceptions -are C and C). They cause tied hashes to behave exactly like standard hashes, -and allow for selective overwriting of methods. B grandfathers the -C method: it is used if C is not defined -in the case a class forgets to include a C method. +to a package. The basic B package provides +the method C. + +L implements a class that behaves exactly like standard hashes, +and allows for selective overwriting of methods. For developers wishing to write their own tied hashes, the required methods are briefly defined below. See the L section for more detailed @@ -116,55 +86,6 @@ =back -=head1 Inheriting from B - -The accessor methods assume that the actual storage for the data in the tied -hash is in the hash referenced by C. Thus overwritten -C method should return a hash reference, and the remaining methods -should operate on the hash referenced by the first argument: - - package ReportHash; - our @ISA = 'Tie::StdHash'; - - sub TIEHASH { - my $storage = bless {}, shift; - warn "New ReportHash created, stored in $storage.\n"; - $storage - } - sub STORE { - warn "Storing data with key $_[1] at $_[0].\n"; - $_[0]{$_[1]} = $_[2] - } - - -=head1 Inheriting from B - -The accessor methods assume that the actual storage for the data in the tied -hash is in the hash referenced by C<(tied(%tiedhash))-E[0]>. Thus overwritten -C method should return an array reference with the first -element being a hash reference, and the remaining methods should operate on the -hash C<< %{ $_[0]->[0] } >>: - - package ReportHash; - our @ISA = 'Tie::ExtraHash'; - - sub TIEHASH { - my $class = shift; - my $storage = bless [{}, @_], $class; - warn "New ReportHash created, stored in $storage.\n"; - $storage; - } - sub STORE { - warn "Storing data with key $_[1] at $_[0].\n"; - $_[0][0]{$_[1]} = $_[2] - } - -The default C method stores "extra" arguments to tie() starting -from offset 1 in the array referenced by C; this is the -same storage algorithm as in TIEHASH subroutine above. Hence, a typical -package inheriting from B does not need to overwrite this -method. - =head1 C, C and C The methods C and C are not defined in B, @@ -178,6 +99,18 @@ B, B, or B. See L to find out what happens when C does not exist. +=head1 CHANGES + +C up to version 1.05 had an unnecessarily complex setup +of C and C. To inherit from C, just add +a C constructor to your class. If your code used C, just +rename it to C. C is gone, and so are C and +C. + +C and C were included in C up to +version 1.05. Now, they are properly separated classes. C still +loads them to avoid breaking code. + =head1 MORE INFORMATION The packages relating to various DBM-related implementations (F, @@ -187,43 +120,6 @@ =cut -use Carp; -use warnings::register; - -sub new { - my $pkg = shift; - $pkg->TIEHASH(@_); -} - -# Grandfather "new" - -sub TIEHASH { - my $pkg = shift; - my $pkg_new = $pkg -> can ('new'); - - if ($pkg_new and $pkg ne __PACKAGE__) { - my $my_new = __PACKAGE__ -> can ('new'); - if ($pkg_new == $my_new) { - # - # Prevent recursion - # - croak "$pkg must define either a TIEHASH() or a new() method"; - } - - warnings::warnif ("WARNING: calling ${pkg}->new since " . - "${pkg}->TIEHASH is missing"); - $pkg -> new (@_); - } - else { - croak "$pkg doesn't define a TIEHASH method"; - } -} - -sub EXISTS { - my $pkg = ref $_[0]; - croak "$pkg doesn't define an EXISTS method"; -} - sub CLEAR { my $self = shift; my $key = $self->FIRSTKEY(@_); @@ -238,33 +134,4 @@ } } -# The Tie::StdHash package implements standard perl hash behaviour. -# It exists to act as a base class for classes which only wish to -# alter some parts of their behaviour. - -package Tie::StdHash; -# @ISA = qw(Tie::Hash); # would inherit new() only - -sub TIEHASH { bless {}, $_[0] } -sub STORE { $_[0]->{$_[1]} = $_[2] } -sub FETCH { $_[0]->{$_[1]} } -sub FIRSTKEY { my $a = scalar keys %{$_[0]}; each %{$_[0]} } -sub NEXTKEY { each %{$_[0]} } -sub EXISTS { exists $_[0]->{$_[1]} } -sub DELETE { delete $_[0]->{$_[1]} } -sub CLEAR { %{$_[0]} = () } -sub SCALAR { scalar %{$_[0]} } - -package Tie::ExtraHash; - -sub TIEHASH { my $p = shift; bless [{}, @_], $p } -sub STORE { $_[0][0]{$_[1]} = $_[2] } -sub FETCH { $_[0][0]{$_[1]} } -sub FIRSTKEY { my $a = scalar keys %{$_[0][0]}; each %{$_[0][0]} } -sub NEXTKEY { each %{$_[0][0]} } -sub EXISTS { exists $_[0][0]->{$_[1]} } -sub DELETE { delete $_[0][0]->{$_[1]} } -sub CLEAR { %{$_[0][0]} = () } -sub SCALAR { scalar %{$_[0][0]} } - 1; diff -Naur perl-5.28.0.orig/lib/Tie/Hash.t perl-5.28.0/lib/Tie/Hash.t --- perl-5.28.0.orig/lib/Tie/Hash.t 2018-03-20 21:06:36.000000000 +0100 +++ perl-5.28.0/lib/Tie/Hash.t 2018-09-16 19:03:33.032814985 +0200 @@ -9,5 +9,5 @@ # these are "abstract virtual" parent methods for my $method (qw( TIEHASH EXISTS )) { eval { Tie::Hash->$method() }; - like( $@, qr/doesn't define an? $method/, "croaks on inherited $method()" ); + like( $@, qr/Can't locate object method "$method"/, "dies on inherited $method()" ); } diff -Naur perl-5.28.0.orig/lib/Tie/Scalar.pm perl-5.28.0/lib/Tie/Scalar.pm --- perl-5.28.0.orig/lib/Tie/Scalar.pm 2018-05-21 10:41:35.000000000 +0200 +++ perl-5.28.0/lib/Tie/Scalar.pm 2018-09-16 19:05:18.345673461 +0200 @@ -1,48 +1,38 @@ package Tie::Scalar; -our $VERSION = '1.04'; +use strict; +use warnings; +use Tie::StdScalar (); # for backwards compatibility -=head1 NAME - -Tie::Scalar, Tie::StdScalar - base class definitions for tied scalars - -=head1 SYNOPSIS +our $VERSION = '1.05'; - package NewScalar; - require Tie::Scalar; +1; - @ISA = qw(Tie::Scalar); +__END__ - sub FETCH { ... } # Provide a needed method - sub TIESCALAR { ... } # Overrides inherited method +=head1 NAME +Tie::Scalar - base class for tied scalars - package NewStdScalar; - require Tie::Scalar; +=head1 SYNOPSIS - @ISA = qw(Tie::StdScalar); + package NewScalar; + use parent 'Tie::Scalar'; - # All methods provided by default, so define - # only what needs be overridden sub FETCH { ... } + sub TIESCALAR { ... } package main; tie $new_scalar, 'NewScalar'; - tie $new_std_scalar, 'NewStdScalar'; =head1 DESCRIPTION -This module provides some skeletal methods for scalar-tying classes. See +This class provides some skeletal methods for scalar-tying classes. See L for a list of the functions required in tying a scalar to a -package. The basic B package provides a C method, as well -as methods C, C and C. The B -package provides all the methods specified in L. It inherits from -B and causes scalars tied to it to behave exactly like the -built-in scalars, allowing for selective overloading of methods. The C -method is provided as a means of grandfathering, for classes that forget to -provide their own C method. +package. The basic B package currently provides no methods, +but may do so in future versions. For developers wishing to write their own tied-scalar classes, the methods are summarized below. The L section not only documents these, but @@ -76,16 +66,22 @@ =head2 Tie::Scalar vs Tie::StdScalar -C<< Tie::Scalar >> provides all the necessary methods, but one should realize -they do not do anything useful. Calling C<< Tie::Scalar::FETCH >> or -C<< Tie::Scalar::STORE >> results in a (trappable) croak. And if you inherit -from C<< Tie::Scalar >>, you I provide either a C<< new >> or a -C<< TIESCALAR >> method. - If you are looking for a class that does everything for you you don't define yourself, use the C<< Tie::StdScalar >> class, not the C<< Tie::Scalar >> one. +=head1 CHANGES + +C up to version 1.04 had an unnecessarily complex setup +of C and C. To inherit from C, just add +a C constructor to your class. If your code used C, just +rename it to C. C is gone, and so are C and +C. + +C was included in C up to version 1.04. Now, +it is a properly separated classes. C still loads it to avoid +breaking code. + =head1 MORE INFORMATION The L section uses a good example of tying scalars by associating @@ -93,72 +89,3 @@ =cut -use Carp; -use warnings::register; - -sub new { - my $pkg = shift; - $pkg->TIESCALAR(@_); -} - -# "Grandfather" the new, a la Tie::Hash - -sub TIESCALAR { - my $pkg = shift; - my $pkg_new = $pkg -> can ('new'); - - if ($pkg_new and $pkg ne __PACKAGE__) { - my $my_new = __PACKAGE__ -> can ('new'); - if ($pkg_new == $my_new) { - # - # Prevent recursion - # - croak "$pkg must define either a TIESCALAR() or a new() method"; - } - - warnings::warnif ("WARNING: calling ${pkg}->new since " . - "${pkg}->TIESCALAR is missing"); - $pkg -> new (@_); - } - else { - croak "$pkg doesn't define a TIESCALAR method"; - } -} - -sub FETCH { - my $pkg = ref $_[0]; - croak "$pkg doesn't define a FETCH method"; -} - -sub STORE { - my $pkg = ref $_[0]; - croak "$pkg doesn't define a STORE method"; -} - -# -# The Tie::StdScalar package provides scalars that behave exactly like -# Perl's built-in scalars. Good base to inherit from, if you're only going to -# tweak a small bit. -# -package Tie::StdScalar; -@ISA = qw(Tie::Scalar); - -sub TIESCALAR { - my $class = shift; - my $instance = @_ ? shift : undef; - return bless \$instance => $class; -} - -sub FETCH { - return ${$_[0]}; -} - -sub STORE { - ${$_[0]} = $_[1]; -} - -sub DESTROY { - undef ${$_[0]}; -} - -1; diff -Naur perl-5.28.0.orig/lib/Tie/Scalar.t perl-5.28.0/lib/Tie/Scalar.t --- perl-5.28.0.orig/lib/Tie/Scalar.t 2018-05-21 14:29:23.000000000 +0200 +++ perl-5.28.0/lib/Tie/Scalar.t 2018-09-16 20:04:04.464035128 +0200 @@ -5,35 +5,21 @@ @INC = '../lib'; } -# this must come before main, or tests will fail -package TieTest; - -use Tie::Scalar; -our @ISA = qw( Tie::Scalar ); - -sub new { 'Fooled you.' } - -package main; - our $flag; -use Test::More tests => 16; +use Test::More tests => 11; use_ok( 'Tie::Scalar' ); # these are "abstract virtual" parent methods for my $method (qw( TIESCALAR FETCH STORE )) { eval { Tie::Scalar->$method() }; - like( $@, qr/doesn't define a $method/, "croaks on inherited $method()" ); + like( $@, qr/Can't locate object method "$method"/, "dies on inherited $method()" ); } # the default value is undef my $scalar = Tie::StdScalar->TIESCALAR(); is( $$scalar, undef, 'used TIESCALAR, default value is still undef' ); -# Tie::StdScalar redirects to TIESCALAR -$scalar = Tie::StdScalar->new(); -is( $$scalar, undef, 'used new(), default value is still undef' ); - # this approach should work as well tie $scalar, 'Tie::StdScalar'; is( $$scalar, undef, 'tied a scalar, default value is undef' ); @@ -60,10 +46,6 @@ $warn = $_[0]; }; -# Tie::Scalar::TIEHANDLE should find and call TieTest::new and complain -is( tie( my $foo, 'TieTest'), 'Fooled you.', 'delegated to new()' ); -like( $warn, qr/WARNING: calling TieTest->new/, 'caught warning fine' ); - package DestroyAction; sub new { @@ -95,26 +77,7 @@ eval {tie my $foo => "NoMethods";}; like $@ => - qr /\QNoMethods must define either a TIESCALAR() or a new() method/, - "croaks if both new() and TIESCALAR() are missing"; + qr /Can't locate object method "TIESCALAR"/, + "croaks if TIESCALAR() is missing"; }; -# -# Don't croak on missing new/TIESCALAR if you're inheriting one. -# -my $called1 = 0; -my $called2 = 0; - -sub HasMethod1::new {$called1 ++} - @HasMethod1::ISA = qw [Tie::Scalar]; - @InheritHasMethod1::ISA = qw [HasMethod1]; - -sub HasMethod2::TIESCALAR {$called2 ++} - @HasMethod2::ISA = qw [Tie::Scalar]; - @InheritHasMethod2::ISA = qw [HasMethod2]; - -my $r1 = eval {tie my $foo => "InheritHasMethod1"; 1}; -my $r2 = eval {tie my $foo => "InheritHasMethod2"; 1}; - -ok $r1 && $called1, "inheriting new() does not croak"; -ok $r2 && $called2, "inheriting TIESCALAR() does not croak"; diff -Naur perl-5.28.0.orig/lib/Tie/StdArray.pm perl-5.28.0/lib/Tie/StdArray.pm --- perl-5.28.0.orig/lib/Tie/StdArray.pm 1970-01-01 01:00:00.000000000 +0100 +++ perl-5.28.0/lib/Tie/StdArray.pm 2018-09-16 18:02:03.173763240 +0200 @@ -0,0 +1,88 @@ +package Tie::StdArray; + +use 5.006_001; +use strict; +use warnings; +use parent 'Tie::Array'; # inherit EXTEND() and future methods + +our $VERSION = '1.08'; + +sub TIEARRAY { bless [], $_[0] } +sub FETCHSIZE { scalar @{$_[0]} } +sub STORESIZE { $#{$_[0]} = $_[1]-1 } +sub STORE { $_[0]->[$_[1]] = $_[2] } +sub FETCH { $_[0]->[$_[1]] } +sub CLEAR { @{$_[0]} = () } +sub POP { pop(@{$_[0]}) } +sub PUSH { my $o = shift; push(@$o,@_) } +sub SHIFT { shift(@{$_[0]}) } +sub UNSHIFT { my $o = shift; unshift(@$o,@_) } +sub EXISTS { exists $_[0]->[$_[1]] } +sub DELETE { delete $_[0]->[$_[1]] } + +sub SPLICE +{ + my $ob = shift; + my $sz = $ob->FETCHSIZE; + my $off = @_ ? shift : 0; + $off += $sz if $off < 0; + my $len = @_ ? shift : $sz-$off; + return splice(@$ob,$off,$len,@_); +} + +1; + +__END__ + +=head1 NAME + +Tie::StdArray - base class for tied arrays + +=head1 SYNOPSIS + + package Tie::NewStdArray; + use parent 'Tie::StdArray'; + + # all methods provided by default + + package main; + + $object = tie @somearray,'Tie::StdArray'; + $object = tie @somearray,'Tie::NewStdArray'; + + + +=head1 DESCRIPTION + +The B package provides efficient methods required for tied arrays +which are implemented as blessed references to an "inner" perl array. +It inherits from L, and should cause tied arrays to behave exactly +like standard arrays, allowing for selective overloading of methods. + +For developers wishing to write their own tied arrays, the required methods +are briefly defined in C. See the L section for more detailed +descriptive, as well as example code. + +=head1 CHANGES + +C prior to version 1.08 was hidden in C, and so you +had to manually load C and manipulate C<@ISA> like this: + + use Tie::Array; + our @ISA=('Tie::StdArray'); + +And while this still works, new code should do this instead: + + use parent 'Tie::StdArray'; + +=head1 CAVEATS + +There is no support at present for tied @ISA. There is a potential conflict +between magic entries needed to notice setting of @ISA, and those needed to +implement 'tie'. + +=head1 AUTHOR + +Nick Ing-Simmons Enik@tiuk.ti.comE + +=cut diff -Naur perl-5.28.0.orig/lib/Tie/StdHandle.pm perl-5.28.0/lib/Tie/StdHandle.pm --- perl-5.28.0.orig/lib/Tie/StdHandle.pm 2018-05-21 14:29:23.000000000 +0200 +++ perl-5.28.0/lib/Tie/StdHandle.pm 2018-09-16 18:17:30.411522328 +0200 @@ -1,10 +1,10 @@ package Tie::StdHandle; use strict; +use warnings; +use parent 'Tie::Handle'; -use Tie::Handle; -our @ISA = 'Tie::Handle'; -our $VERSION = '4.5'; +our $VERSION = '4.6'; =head1 NAME @@ -13,9 +13,7 @@ =head1 SYNOPSIS package NewHandle; - require Tie::Handle; - - @ISA = qw(Tie::Handle); + use parent 'Tie::StdHandle'; sub READ { ... } # Provide a needed method sub TIEHANDLE { ... } # Overrides inherited method diff -Naur perl-5.28.0.orig/lib/Tie/StdHash.pm perl-5.28.0/lib/Tie/StdHash.pm --- perl-5.28.0.orig/lib/Tie/StdHash.pm 1970-01-01 01:00:00.000000000 +0100 +++ perl-5.28.0/lib/Tie/StdHash.pm 2018-09-16 18:01:50.442780249 +0200 @@ -0,0 +1,85 @@ +package Tie::StdHash; + +use strict; +use warnings; +use parent 'Tie::Hash'; # allow for new methods in future versions of perl + +our $VERSION = '1.06'; + +=head1 NAME + +Tie::StdHash - base class for tied hashes + +=head1 SYNOPSIS + + package NewStdHash; + + use paremt 'Tie::StdHash'; + + # All methods provided by default, define + # only those needing overrides + # Accessors access the storage in %{$_[0]}; + # TIEHASH should return a reference to the actual storage + sub DELETE { ... } + + package main; + + tie %new_std_hash, 'NewStdHash'; + +=head1 DESCRIPTION + +This module provides some skeletal methods for hash-tying classes, +behaving exactly like standard hashes +and allows for selective overwriting of methods. +See L for a list of the functions required in order to tie a hash +to a package. + +For developers wishing to write their own tied hashes, the required methods +are briefly defined in L. See the L section for more detailed +descriptive, as well as example code. + +=head1 Inheriting from B + +The accessor methods assume that the actual storage for the data in the tied +hash is in the hash referenced by C. Thus overwritten +C method should return a hash reference, and the remaining methods +should operate on the hash referenced by the first argument: + + package ReportHash; + use parent 'Tie::StdHash'; + + sub TIEHASH { + my $sself = bless {}, shift; + warn "New ReportHash created, stored in $sself.\n"; + $self + } + sub STORE { + warn "Storing data with key $_[1] at $_[0].\n"; + $_[0]{$_[1]} = $_[2] + } + +=head1 CHANGES + +C prior to version 1.06 was hidden in C, and so you +had to manually load C and manipulate C<@ISA> like this: + + use Tie::Hash; + our @ISA=('Tie::StdHash'); + +And while this still works, new code should do this instead: + + use parent 'Tie::StdHash'; + +=cut + +sub TIEHASH { bless {}, $_[0] } +sub STORE { $_[0]->{$_[1]} = $_[2] } +sub FETCH { $_[0]->{$_[1]} } +sub FIRSTKEY { my $a = scalar keys %{$_[0]}; each %{$_[0]} } +sub NEXTKEY { each %{$_[0]} } +sub EXISTS { exists $_[0]->{$_[1]} } +sub DELETE { delete $_[0]->{$_[1]} } +sub CLEAR { %{$_[0]} = () } +sub SCALAR { scalar %{$_[0]} } + +1; diff -Naur perl-5.28.0.orig/lib/Tie/StdScalar.pm perl-5.28.0/lib/Tie/StdScalar.pm --- perl-5.28.0.orig/lib/Tie/StdScalar.pm 1970-01-01 01:00:00.000000000 +0100 +++ perl-5.28.0/lib/Tie/StdScalar.pm 2018-09-16 19:05:06.887688859 +0200 @@ -0,0 +1,134 @@ +package Tie::StdScalar; + +use strict; +use warnings; +use parent 'Tie::Scalar'; + +our $VERSION = '1.05'; + +sub TIESCALAR { + my $class = shift; + my $instance = @_ ? shift : undef; + return bless \$instance => $class; +} + +sub FETCH { + return ${$_[0]}; +} + +sub STORE { + ${$_[0]} = $_[1]; +} + +sub DESTROY { + undef ${$_[0]}; +} + +1; + +__END__ + +=head1 NAME + +Tie::StdScalar - base class for tied scalars + +=head1 SYNOPSIS + + package NewScalar; + require Tie::Scalar; + + @ISA = qw(Tie::Scalar); + + sub FETCH { ... } # Provide a needed method + sub TIESCALAR { ... } # Overrides inherited method + + + package NewStdScalar; + require Tie::Scalar; + + @ISA = qw(Tie::StdScalar); + + # All methods provided by default, so define + # only what needs be overridden + sub FETCH { ... } + + + package main; + + tie $new_scalar, 'NewScalar'; + tie $new_std_scalar, 'NewStdScalar'; + +=head1 DESCRIPTION + +This module provides some skeletal methods for scalar-tying classes. See +L for a list of the functions required in tying a scalar to a +package. The basic B package provides a C method, as well +as methods C, C and C. The B +package provides all the methods specified in L. It inherits from +B and causes scalars tied to it to behave exactly like the +built-in scalars, allowing for selective overloading of methods. The C +method is provided as a means of grandfathering, for classes that forget to +provide their own C method. + +For developers wishing to write their own tied-scalar classes, the methods +are summarized below. The L section not only documents these, but +has sample code as well: + +=over 4 + +=item TIESCALAR classname, LIST + +The method invoked by the command C. Associates a new +scalar instance with the specified class. C would represent additional +arguments (along the lines of L and compatriots) needed to +complete the association. + +=item FETCH this + +Retrieve the value of the tied scalar referenced by I. + +=item STORE this, value + +Store data I in the tied scalar referenced by I. + +=item DESTROY this + +Free the storage associated with the tied scalar referenced by I. +This is rarely needed, as Perl manages its memory quite well. But the +option exists, should a class wish to perform specific actions upon the +destruction of an instance. + +=back + +=head2 Tie::Scalar vs Tie::StdScalar + +C<< Tie::Scalar >> provides all the necessary methods, but one should realize +they do not do anything useful. Calling C<< Tie::Scalar::FETCH >> or +C<< Tie::Scalar::STORE >> results in a (trappable) croak. And if you inherit +from C<< Tie::Scalar >>, you I provide either a C<< new >> or a +C<< TIESCALAR >> method. + +If you are looking for a class that does everything for you you don't +define yourself, use the C<< Tie::StdScalar >> class, not the +C<< Tie::Scalar >> one. + +=head1 CHANGES + +C prior to version 1.05 was hidden in C, and so you +had to manually load C and manipulate C<@ISA> like this: + + use Tie::Scalar; + our @ISA=('Tie::StdScalar'); + +And while this still works, new code should do this instead: + + use parent 'Tie::StdScalar'; + +=head1 MORE INFORMATION + +The L section uses a good example of tying scalars by associating +process IDs with priority. + +=cut + +