Blame SOURCES/Storable-2.51-Upgrade-to-2.53.patch

a40ef2
From fd2e79041c553c1220c6eca796293873246c5682 Mon Sep 17 00:00:00 2001
a40ef2
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
a40ef2
Date: Wed, 6 May 2015 09:39:53 +0200
a40ef2
Subject: [PATCH] Upgrade to 2.53
a40ef2
MIME-Version: 1.0
a40ef2
Content-Type: text/plain; charset=UTF-8
a40ef2
Content-Transfer-Encoding: 8bit
a40ef2
a40ef2
Signed-off-by: Petr Písař <ppisar@redhat.com>
a40ef2
---
a40ef2
 ChangeLog         |  2 +-
a40ef2
 MANIFEST          |  3 +++
a40ef2
 Storable.pm       |  6 +++---
a40ef2
 t/attach.t        | 42 ++++++++++++++++++++++++++++++++++++
a40ef2
 t/attach_errors.t |  2 +-
a40ef2
 t/canonical.t     |  2 +-
a40ef2
 t/code.t          |  2 +-
a40ef2
 t/leaks.t         | 34 +++++++++++++++++++++++++++++
a40ef2
 t/tied_store.t    | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
a40ef2
 t/utf8.t          |  6 ++++--
a40ef2
 10 files changed, 154 insertions(+), 9 deletions(-)
a40ef2
 create mode 100644 t/attach.t
a40ef2
 create mode 100644 t/leaks.t
a40ef2
 create mode 100644 t/tied_store.t
a40ef2
a40ef2
diff --git a/ChangeLog b/ChangeLog
a40ef2
index 4df921e..cbfdbab 100644
a40ef2
--- a/ChangeLog
a40ef2
+++ b/ChangeLog
a40ef2
@@ -209,7 +209,7 @@ Fri Jun  7 23:55:41 BST 2002   Nicholas Clark
a40ef2
 	The bug was introduced as development perl change 16442 (on
a40ef2
 	2002/05/07), so has been present since 2.00.
a40ef2
 	Patches to introduce more regression tests to reduce the chance of
a40ef2
-	a reoccurence of this sort of goof are always welcome.
a40ef2
+	a reoccurrence of this sort of goof are always welcome.
a40ef2
 	
a40ef2
 Thu May 30 20:31:08 BST 2002   Nicholas Clark <nick@ccl4.org>
a40ef2
 
a40ef2
diff --git a/MANIFEST b/MANIFEST
a40ef2
index 84b72f1..2f5b725 100644
a40ef2
--- a/MANIFEST
a40ef2
+++ b/MANIFEST
a40ef2
@@ -9,6 +9,7 @@ ppport.h
a40ef2
 README
a40ef2
 Storable.pm
a40ef2
 Storable.xs
a40ef2
+t/attach.t
a40ef2
 t/attach_errors.t
a40ef2
 t/attach_singleton.t
a40ef2
 t/blessed.t
a40ef2
@@ -33,6 +34,7 @@ t/HAS_OVERLOAD.pm
a40ef2
 t/integer.t
a40ef2
 t/interwork56.t
a40ef2
 t/just_plain_nasty.t
a40ef2
+t/leaks.t
a40ef2
 t/lock.t
a40ef2
 t/make_56_interwork.pl
a40ef2
 t/make_downgrade.pl
a40ef2
@@ -51,6 +53,7 @@ t/threads.t
a40ef2
 t/tied.t
a40ef2
 t/tied_hook.t
a40ef2
 t/tied_items.t
a40ef2
+t/tied_store.t
a40ef2
 t/utf8.t
a40ef2
 t/utf8hash.t
a40ef2
 t/weak.t
a40ef2
diff --git a/Storable.pm b/Storable.pm
a40ef2
index 839c1d1..9d8b621 100644
a40ef2
--- a/Storable.pm
a40ef2
+++ b/Storable.pm
a40ef2
@@ -22,7 +22,7 @@ package Storable; @ISA = qw(Exporter);
a40ef2
 
a40ef2
 use vars qw($canonical $forgive_me $VERSION);
a40ef2
 
a40ef2
-$VERSION = '2.51';
a40ef2
+$VERSION = '2.53';
a40ef2
 
a40ef2
 BEGIN {
a40ef2
     if (eval { local $SIG{__DIE__}; require Log::Agent; 1 }) {
a40ef2
@@ -1088,8 +1088,8 @@ deal with them.
a40ef2
 
a40ef2
 The store functions will C<croak> if they run into such references
a40ef2
 unless you set C<$Storable::forgive_me> to some C<TRUE> value. In that
a40ef2
-case, the fatal message is turned in a warning and some
a40ef2
-meaningless string is stored instead.
a40ef2
+case, the fatal message is converted to a warning and some meaningless
a40ef2
+string is stored instead.
a40ef2
 
a40ef2
 Setting C<$Storable::canonical> may not yield frozen strings that
a40ef2
 compare equal due to possible stringification of numbers. When the
a40ef2
diff --git a/t/attach.t b/t/attach.t
a40ef2
new file mode 100644
a40ef2
index 0000000..5ffdae5
a40ef2
--- /dev/null
a40ef2
+++ b/t/attach.t
a40ef2
@@ -0,0 +1,42 @@
a40ef2
+#!./perl -w
a40ef2
+#
a40ef2
+# This file tests that Storable correctly uses STORABLE_attach hooks
a40ef2
+
a40ef2
+sub BEGIN {
a40ef2
+	unshift @INC, 't';
a40ef2
+	unshift @INC, 't/compat' if $] < 5.006002;
a40ef2
+	require Config; import Config;
a40ef2
+	if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bStorable\b/) {
a40ef2
+		print "1..0 # Skip: Storable was not built\n";
a40ef2
+		exit 0;
a40ef2
+	}
a40ef2
+}
a40ef2
+
a40ef2
+use Test::More tests => 3;
a40ef2
+use Storable ();
a40ef2
+
a40ef2
+{
a40ef2
+	my $destruct_cnt = 0;
a40ef2
+	my $obj = bless {data => 'ok'}, 'My::WithDestructor';
a40ef2
+	my $target = Storable::thaw( Storable::freeze( $obj ) );
a40ef2
+	is( $target->{data}, 'ok', 'We got correct object after freeze/thaw' );
a40ef2
+	is( $destruct_cnt, 0, 'No tmp objects created by Storable' );
a40ef2
+	undef $obj;
a40ef2
+	undef $target;
a40ef2
+	is( $destruct_cnt, 2, 'Only right objects destroyed at the end' );
a40ef2
+
a40ef2
+	package My::WithDestructor;
a40ef2
+
a40ef2
+	sub STORABLE_freeze {
a40ef2
+		my ($self, $clone) = @_;
a40ef2
+		return $self->{data};
a40ef2
+	}
a40ef2
+
a40ef2
+	sub STORABLE_attach {
a40ef2
+		my ($class, $clone, $string) = @_;
a40ef2
+		return bless {data => $string}, 'My::WithDestructor';
a40ef2
+	}
a40ef2
+
a40ef2
+	sub DESTROY { $destruct_cnt++; }
a40ef2
+}
a40ef2
+
a40ef2
diff --git a/t/attach_errors.t b/t/attach_errors.t
a40ef2
index c163ca0..6cebd97 100644
a40ef2
--- a/t/attach_errors.t
a40ef2
+++ b/t/attach_errors.t
a40ef2
@@ -234,7 +234,7 @@ use Storable ();
a40ef2
 	isa_ok( $thawed->[1], 'My::GoodAttach::MultipleReferences' );
a40ef2
 
a40ef2
 	is($thawed->[0], $thawed->[1], 'References to the same object are attached properly');
a40ef2
-	is($thawed->[1]{id}, $obj->{id}, 'Object with multiple references attchached properly');
a40ef2
+	is($thawed->[1]{id}, $obj->{id}, 'Object with multiple references attached properly');
a40ef2
 
a40ef2
     package My::GoodAttach::MultipleReferences;
a40ef2
 
a40ef2
diff --git a/t/canonical.t b/t/canonical.t
a40ef2
index 23e012f..35046de 100644
a40ef2
--- a/t/canonical.t
a40ef2
+++ b/t/canonical.t
a40ef2
@@ -34,7 +34,7 @@ $maxarraysize = 100;
a40ef2
 
a40ef2
 eval { require Digest::MD5; };
a40ef2
 $gotmd5 = !$@;
a40ef2
-diag "Will use Digest::MD5" if $gotmd5;
a40ef2
+note "Will use Digest::MD5" if $gotmd5;
a40ef2
 
a40ef2
 # Use Data::Dumper if debugging and it is available to create an ASCII dump
a40ef2
 
a40ef2
diff --git a/t/code.t b/t/code.t
a40ef2
index c383142..7fc40ba 100644
a40ef2
--- a/t/code.t
a40ef2
+++ b/t/code.t
a40ef2
@@ -102,7 +102,7 @@ is($thawed->{"b"}->(), "JAPH");
a40ef2
 $freezed = freeze $obj[2];
a40ef2
 $thawed  = thaw $freezed;
a40ef2
 
a40ef2
-is($thawed->(), 42);
a40ef2
+is($thawed->(), (ord "A") == 193 ? -118 : 42);
a40ef2
 
a40ef2
 ######################################################################
a40ef2
 
a40ef2
diff --git a/t/leaks.t b/t/leaks.t
a40ef2
new file mode 100644
a40ef2
index 0000000..06360d6
a40ef2
--- /dev/null
a40ef2
+++ b/t/leaks.t
a40ef2
@@ -0,0 +1,34 @@
a40ef2
+#!./perl
a40ef2
+
a40ef2
+use Test::More;
a40ef2
+use Storable ();
a40ef2
+BEGIN {
a40ef2
+eval "use Test::LeakTrace";
a40ef2
+plan 'skip_all' => 'Test::LeakTrace required for this tests' if $@;
a40ef2
+}
a40ef2
+plan 'tests' => 1;
a40ef2
+
a40ef2
+{
a40ef2
+    my $c = My::Simple->new;
a40ef2
+    my $d;
a40ef2
+    my $freezed = Storable::freeze($c);
a40ef2
+    no_leaks_ok
a40ef2
+    {
a40ef2
+        $d = Storable::thaw($freezed);
a40ef2
+        undef $d;
a40ef2
+    };
a40ef2
+
a40ef2
+    package My::Simple;
a40ef2
+    sub new {
a40ef2
+        my ($class, $arg) = @_;
a40ef2
+        bless {t=>$arg}, $class;
a40ef2
+    }
a40ef2
+    sub STORABLE_freeze {
a40ef2
+        return "abcderfgh";
a40ef2
+    }
a40ef2
+    sub STORABLE_attach {
a40ef2
+        my ($class, $c, $serialized) = @_;
a40ef2
+        return $class->new($serialized);
a40ef2
+    }
a40ef2
+}
a40ef2
+
a40ef2
diff --git a/t/tied_store.t b/t/tied_store.t
a40ef2
new file mode 100644
a40ef2
index 0000000..c657f95
a40ef2
--- /dev/null
a40ef2
+++ b/t/tied_store.t
a40ef2
@@ -0,0 +1,64 @@
a40ef2
+#!./perl
a40ef2
+
a40ef2
+sub BEGIN {
a40ef2
+    unshift @INC, 't';
a40ef2
+    unshift @INC, 't/compat' if $] < 5.006002;
a40ef2
+    require Config; import Config;
a40ef2
+    if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bStorable\b/) {
a40ef2
+        print "1..0 # Skip: Storable was not built\n";
a40ef2
+        exit 0;
a40ef2
+    }
a40ef2
+}
a40ef2
+
a40ef2
+use Storable ();
a40ef2
+use Test::More tests => 3;
a40ef2
+
a40ef2
+our $f;
a40ef2
+
a40ef2
+package TIED_HASH;
a40ef2
+
a40ef2
+sub TIEHASH { bless({}, $_[0]) }
a40ef2
+
a40ef2
+sub STORE {
a40ef2
+	$f = Storable::freeze(\$_[2]);
a40ef2
+	1;
a40ef2
+}
a40ef2
+
a40ef2
+package TIED_ARRAY;
a40ef2
+
a40ef2
+sub TIEARRAY { bless({}, $_[0]) }
a40ef2
+
a40ef2
+sub STORE {
a40ef2
+	$f = Storable::freeze(\$_[2]);
a40ef2
+	1;
a40ef2
+}
a40ef2
+
a40ef2
+package TIED_SCALAR;
a40ef2
+
a40ef2
+sub TIESCALAR { bless({}, $_[0]) }
a40ef2
+
a40ef2
+sub STORE {
a40ef2
+	$f = Storable::freeze(\$_[1]);
a40ef2
+	1;
a40ef2
+}
a40ef2
+
a40ef2
+package main;
a40ef2
+
a40ef2
+my($s, @a, %h);
a40ef2
+tie $s, "TIED_SCALAR";
a40ef2
+tie @a, "TIED_ARRAY";
a40ef2
+tie %h, "TIED_HASH";
a40ef2
+
a40ef2
+$f = undef;
a40ef2
+$s = 111;
a40ef2
+is $f, Storable::freeze(\111);
a40ef2
+
a40ef2
+$f = undef;
a40ef2
+$a[3] = 222;
a40ef2
+is $f, Storable::freeze(\222);
a40ef2
+
a40ef2
+$f = undef;
a40ef2
+$h{foo} = 333;
a40ef2
+is $f, Storable::freeze(\333);
a40ef2
+
a40ef2
+1;
a40ef2
diff --git a/t/utf8.t b/t/utf8.t
a40ef2
index fd20ef6..a8dd6cd 100644
a40ef2
--- a/t/utf8.t
a40ef2
+++ b/t/utf8.t
a40ef2
@@ -32,8 +32,10 @@ is($x, ${thaw freeze \$x});
a40ef2
 $x = join '', map {chr $_} (0..1023);
a40ef2
 is($x, ${thaw freeze \$x});
a40ef2
 
a40ef2
-# Char in the range 127-255 (probably) in utf8
a40ef2
-$x = chr (175) . chr (256);
a40ef2
+# Char in the range 127-255 (probably) in utf8.  This just won't work for
a40ef2
+# EBCDIC for early Perls.
a40ef2
+$x = ($] lt 5.007_003) ? chr(175) : chr(utf8::unicode_to_native(175))
a40ef2
+   . chr (256);
a40ef2
 chop $x;
a40ef2
 is($x, ${thaw freeze \$x});
a40ef2
 
a40ef2
-- 
a40ef2
2.1.0
a40ef2