Re: Which Perl versions Autoconf needs [PATCH included]
Jacob Bachmeyer <[email protected]>
| Newsgroups | gmane.comp.sysutils.autoconf.general |
|---|---|
| Message-ID | <[email protected]> |
Paul Eggert wrote:
> On 2023-03-29 16:32, Jacob Bachmeyer wrote:
>
>> Is there anything more needed from me to get similar fixes into
>> Autoconf?
>
> I started to do that, by installing this:
>
> https://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=e2220ed33e69d8bc6504e3f6279894afe33a99a5
>
>
> into Autoconf master on Savannah and then drafting the attached patch.
> However, the attached patch is not right, because some other Perl 5.10
> code is now in autoconf/build-aux/help-extract.pl (and perhaps a few
> other places; I haven't checked). So I did not install this draft patch.
>
> If it's easy to backport help-extract.pl (and etc.?) to older Perl
> then feel free to come up with an additional patch set. If not, I
> wouldn't worry too much. As Warren mentioned, these old Perls are
> getting rare on platforms that users are likely to be running Autoconf
> on.
>
> I ran into this issue when testing the latest Autoconf release
> candidate on Solaris 10, which ships with Perl 5.8.4. Although Solaris
> 10 is obsolescent Oracle says they will support it through January 2024.
I have since looked into this a bit further. The standard advice for
these features in Perl is to use POD, which already has a well-developed
system for extracting manpages instead of needing help2man, and the
Pod::Usage module (first included in Perl core in Perl 5.6) for
extracting a help message from embedded POD text. The problem with
using POD here would be the usage block from Autom4te::ChannelDefs.
Further examination led to a simple solution, although I am not entirely
certain what the regexps in the two versions of eval_qq_no_interpolation
are supposed to do exactly:
[patch against current master, commit
e2220ed33e69d8bc6504e3f6279894afe33a99a5 as of this writing]
8<-------
diff --git a/build-aux/help-extract.pl b/build-aux/help-extract.pl
index 83f79da..51cab65 100644
--- a/build-aux/help-extract.pl
+++ b/build-aux/help-extract.pl
@@ -16,10 +16,12 @@
# Written by Zack Weinberg.
-use 5.010;
use strict;
use warnings;
-use File::Spec::Functions qw(catfile);
+
+# File::Spec itself was added in 5.005.
+# File::Spec::Functions was added in 5.6.1 which is just barely too new.
+use File::Spec;
# This script is not intended to be used directly. It's run by
# help2man via wrappers in man/, e.g. man/autoconf.w, as if it were
@@ -48,17 +50,13 @@ sub eval_qq_no_interpolation ($)
# The argument is expected to be a "double quoted string" including the
# leading and trailing delimiters. Returns the text of this string after
# processing backslash escapes but NOT interpolation.
- my $s = $_[0];
-
- # Escape $ and @ inside the string, if they are not already escaped.
- # The regex matches the empty string, but only if it is preceded by an
- # even number of backslashes (including zero) and followed by either a
- # literal $ or a literal @. Then we insert a backslash at the position
- # of the match.
- $s =~ s/ (?:\A|[^\\]) (?:\\\\)* \K (?=[\$\@]) /\\/xg;
-
- # It is now safe to feed the string to 'eval'.
- return eval $s;
+ # / (?<!\\) (?>\\\\)* blah /x means match blah preceded by an
+ # *even* number of backslashes. It would be nice if we could use \K
+ # to exclude the backslashes from the matched text, but that was only
+ # added in Perl 5.10 and we still support back to 5.006.
+ my $text;
+ ($text = $_[0]) =~ s/ (?<!\\) (?>\\\\)* [\$\@] /\\$&/xg;
+ return eval $text;
}
sub extract_channeldefs_usage ($)
@@ -203,8 +201,8 @@ The script-source argument should also be relative to top_sr
my $cmd_name = $source;
$cmd_name =~ s{^.*/([^./]+)\.in$}{$1};
- $source = catfile($top_srcdir, $source);
- $channeldefs_pm = catfile($top_srcdir, $channeldefs_pm);
+ $source = File::Spec->catfile($top_srcdir, $source);
+ $channeldefs_pm = File::Spec->catfile($top_srcdir, $channeldefs_pm);
my $text = extract_assignment ($source, $channeldefs_pm, $what);
$text =~ s/\$0\b/$cmd_name/g;
8<-------
As before, please use my gnu.org address, (<[email protected]>) for public
attribution for the patch.
-- Jacob