autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] [committed] autom4te: Don’t crash if Data::Dumper::Sortkeys is u


From: Zack Weinberg
Subject: [PATCH] [committed] autom4te: Don’t crash if Data::Dumper::Sortkeys is unavailable.
Date: Mon, 11 Dec 2023 13:19:57 -0500

Commit c2ab755698db245898a4cc89149eb5df256e4bd0 added an unconditional
use of Data::Dumper’s Sortkeys method, which was added in version
2.12_01 of that module.  In terms of Perl versions, it is available in
5.8.x and later, and in 5.6.2, but not in 5.6.1 or earlier. At the
time, our minimum Perl version was 5.10, but we lowered it to 5.6.0
again in 05e295b60cfdf378b7ed8c1f8563a5644d5d4689.  It seems that
commit was not actually tested with 5.6.1 or earlier.

As we are only using Sortkeys to facilitate manual comparison of
autom4te.cache/requests files, we can just ignore the method lookup
failure with 5.6.[01] and everything will work fine without it.

Tested on x86_64-unknown-netbsd9.3 with perl 5.6.1.
Resolves https://savannah.gnu.org/support/?110561.

* lib/Autom4te/C4che.pm (marshall): Ignore method lookup failure for
  Data::Dumper::Sortkeys with very old perl.
* lib/Autom4te/Request.pm (marshall): Likewise.
---
 lib/Autom4te/C4che.pm   | 11 +++++++----
 lib/Autom4te/Request.pm | 11 +++++++----
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/lib/Autom4te/C4che.pm b/lib/Autom4te/C4che.pm
index 523f15bf..029138d1 100644
--- a/lib/Autom4te/C4che.pm
+++ b/lib/Autom4te/C4che.pm
@@ -155,13 +155,16 @@ Serialize all the current requests.
 sub marshall ($)
 {
   my ($caller) = @_;
-  my $res = '';
 
   my $marshall = Data::Dumper->new ([\@request], [qw (*request)]);
-  $marshall->Indent(2)->Terse(0)->Sortkeys(1);
-  $res = $marshall->Dump . "\n";
+  $marshall->Indent(2)->Terse(0);
 
-  return $res;
+  # The Sortkeys method was added in Data::Dumper 2.12_01, so it is
+  # available in 5.8.x and 5.6.2 but not in 5.6.1 or earlier.
+  # Ignore failure of method lookup.
+  eval { $marshall->Sortkeys(1); };
+
+  return $marshall->Dump . "\n";
 }
 
 
diff --git a/lib/Autom4te/Request.pm b/lib/Autom4te/Request.pm
index 53f9ad7a..f4ede8df 100644
--- a/lib/Autom4te/Request.pm
+++ b/lib/Autom4te/Request.pm
@@ -59,14 +59,17 @@ struct
 sub marshall($)
 {
   my ($caller) = @_;
-  my $res = '';
 
   # CALLER is an object: instance method.
   my $marshall = Data::Dumper->new ([$caller]);
-  $marshall->Indent(2)->Terse(0)->Sortkeys(1);
-  $res = $marshall->Dump . "\n";
+  $marshall->Indent(2)->Terse(0);
 
-  return $res;
+  # The Sortkeys method was added in Data::Dumper 2.12_01, so it is
+  # available in 5.8.x and 5.6.2 but not in 5.6.1 or earlier.
+  # Ignore failure of method lookup.
+  eval { $marshall->Sortkeys(1); };
+
+  return $marshall->Dump . "\n";
 }
 
 
-- 
2.41.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]