summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/perl/perl-5.20.0/debian/fixes/memoize_storable_nstore.diff
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/perl/perl-5.20.0/debian/fixes/memoize_storable_nstore.diff')
-rw-r--r--meta/recipes-devtools/perl/perl-5.20.0/debian/fixes/memoize_storable_nstore.diff110
1 files changed, 110 insertions, 0 deletions
diff --git a/meta/recipes-devtools/perl/perl-5.20.0/debian/fixes/memoize_storable_nstore.diff b/meta/recipes-devtools/perl/perl-5.20.0/debian/fixes/memoize_storable_nstore.diff
new file mode 100644
index 0000000000..b9d61c713e
--- /dev/null
+++ b/meta/recipes-devtools/perl/perl-5.20.0/debian/fixes/memoize_storable_nstore.diff
@@ -0,0 +1,110 @@
1From 8b7b31d6b2368717514a05dc0e968c1357511733 Mon Sep 17 00:00:00 2001
2From: Jonathan Nieder <jrnieder@gmail.com>
3Date: Fri, 27 Jul 2012 10:35:07 -0500
4Subject: Memoize::Storable: respect 'nstore' option not respected
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9Memoize(3perl) says:
10
11 tie my %cache => 'Memoize::Storable', $filename, 'nstore';
12 memoize 'function', SCALAR_CACHE => [HASH => \%cache];
13
14 Include the ‘nstore’ option to have the "Storable" database
15 written in ‘network order’. (See Storable for more details
16 about this.)
17
18In fact the "nstore" option does no such thing. Option parsing looks
19like this:
20
21 @options{@_} = ();
22
23$self->{OPTIONS}{'nstore'} is accordingly set to undef. Later
24Memoize::Storable checks if the option is true, and since undef is
25not true, the "else" branch is always taken.
26
27 if ($self->{OPTIONS}{'nstore'}) {
28 Storable::nstore($self->{H}, $self->{FILENAME});
29 } else {
30 Storable::store($self->{H}, $self->{FILENAME});
31 }
32
33Correcting the condition to (exists $self->{OPTIONS}{'nstore'}) fixes
34it.
35
36Noticed because git-svn, which uses the 'nstore' option for its
37on-disk caches, was producing
38
39 Byte order is not compatible at ../../lib/Storable.pm
40
41when run using a perl with a different integer size (and hence
42byteorder).
43
44Reported by Tim Retout (RT#77790)
45
46Bug-Debian: http://bugs.debian.org/587650
47Bug: https://rt.cpan.org/Public/Bug/Display.html?id=77790
48Forwarded: https://rt.cpan.org/Public/Bug/Display.html?id=77790
49Patch-Name: fixes/memoize_storable_nstore.diff
50---
51 cpan/Memoize/Memoize/Storable.pm | 2 +-
52 cpan/Memoize/t/tie_storable.t | 24 ++++++++++++++++++++----
53 2 files changed, 21 insertions(+), 5 deletions(-)
54
55diff --git a/cpan/Memoize/Memoize/Storable.pm b/cpan/Memoize/Memoize/Storable.pm
56index 1314797..87876f2 100644
57--- a/cpan/Memoize/Memoize/Storable.pm
58+++ b/cpan/Memoize/Memoize/Storable.pm
59@@ -55,7 +55,7 @@ sub DESTROY {
60 require Carp if $Verbose;
61 my $self= shift;
62 print STDERR "Memoize::Storable::DESTROY(@_)\n" if $Verbose;
63- if ($self->{OPTIONS}{'nstore'}) {
64+ if (exists $self->{OPTIONS}{'nstore'}) {
65 Storable::nstore($self->{H}, $self->{FILENAME});
66 } else {
67 Storable::store($self->{H}, $self->{FILENAME});
68diff --git a/cpan/Memoize/t/tie_storable.t b/cpan/Memoize/t/tie_storable.t
69index de3b8dc..a624238 100644
70--- a/cpan/Memoize/t/tie_storable.t
71+++ b/cpan/Memoize/t/tie_storable.t
72@@ -31,18 +31,34 @@ if ($@) {
73 exit 0;
74 }
75
76-print "1..4\n";
77+print "1..9\n";
78
79 $file = "storable$$";
80 1 while unlink $file;
81 tryout('Memoize::Storable', $file, 1); # Test 1..4
82 1 while unlink $file;
83+tryout('Memoize::Storable', $file, 5, 'nstore'); # Test 5..8
84+assert_netorder($file, 9); # Test 9
85+1 while unlink $file;
86+
87+
88+sub assert_netorder {
89+ my ($file, $testno) = @_;
90+
91+ my $netorder = Storable::file_magic($file)->{'netorder'};
92+ print ($netorder ? "ok $testno\n" : "not ok $testno\n");
93+}
94
95 sub tryout {
96- my ($tiepack, $file, $testno) = @_;
97+ my ($tiepack, $file, $testno, $option) = @_;
98
99- tie my %cache => $tiepack, $file
100- or die $!;
101+ if (defined $option) {
102+ tie my %cache => $tiepack, $file, $option
103+ or die $!;
104+ } else {
105+ tie my %cache => $tiepack, $file
106+ or die $!;
107+ }
108
109 memoize 'c5',
110 SCALAR_CACHE => [HASH => \%cache],