GNU bug report logs - #67971
[PATCH] Sync shared files from Autoconf

Previous Next

Package: automake-patches;

Reported by: Zack Weinberg <zack <at> owlfolio.org>

Date: Fri, 22 Dec 2023 18:11:02 UTC

Severity: normal

Tags: patch

Done: Karl Berry <karl <at> freefriends.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 67971 in the body.
You can then email your comments to 67971 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to automake-patches <at> gnu.org:
bug#67971; Package automake-patches. (Fri, 22 Dec 2023 18:11:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Zack Weinberg <zack <at> owlfolio.org>:
New bug report received and forwarded. Copy sent to automake-patches <at> gnu.org. (Fri, 22 Dec 2023 18:11:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Zack Weinberg <zack <at> owlfolio.org>
To: automake-patches <at> gnu.org
Subject: [PATCH] Sync shared files from Autoconf
Date: Fri, 22 Dec 2023 13:10:12 -0500
lib/Automake/ChannelDefs.pm and lib/Automake/Channels.pm were updated
in Autoconf to address <https://savannah.gnu.org/support/?110872>.
Bring over the changes.

It *should* be impossible to reach report_bad_channel from code in Automake.

* lib/Automake/Channels.pm (msg): If the channel argument is invalid,
  don’t crash; report the mistake and use the ‘syntax’ channel.
  (report_bad_channel): New function for reporting invalid channels.

* lib/Automake/ChannelDefs.pm (usage): Clarify that the list of
  warning categories is exhaustive, and that “all”, “none”,
  “no-CATEGORY”, and “error” are not warning categories.
---
 lib/Automake/ChannelDefs.pm | 10 ++++----
 lib/Automake/Channels.pm    | 47 ++++++++++++++++++++++++++++++++++++-
 2 files changed, 52 insertions(+), 5 deletions(-)

diff --git a/lib/Automake/ChannelDefs.pm b/lib/Automake/ChannelDefs.pm
index 1c436645e..8b334ee93 100644
--- a/lib/Automake/ChannelDefs.pm
+++ b/lib/Automake/ChannelDefs.pm
@@ -197,7 +197,7 @@ Return the warning category descriptions.
 
 sub usage ()
 {
-  return "Warning categories include:
+  return "Warning categories are:
   cross                  cross compilation issues
   gnu                    GNU coding standards (default in gnu and gnits modes)
   obsolete               obsolete features or constructions (default)
@@ -207,10 +207,12 @@ sub usage ()
   extra-portability      extra portability issues related to obscure tools
   syntax                 dubious syntactic constructs (default)
   unsupported            unsupported or incomplete features (default)
-  all                    all the warnings
-  no-CATEGORY            turn off warnings in CATEGORY
+
+-W also understands:
+  all                    turn on all the warnings
   none                   turn off all the warnings
-  error                  treat warnings as errors";
+  no-CATEGORY            turn off warnings in CATEGORY
+  error                  treat all enabled warnings as errors";
 }
 
 =item C<prog_error ($MESSAGE, [%OPTIONS])>
diff --git a/lib/Automake/Channels.pm b/lib/Automake/Channels.pm
index b4563d36e..84e93d106 100644
--- a/lib/Automake/Channels.pm
+++ b/lib/Automake/Channels.pm
@@ -628,7 +628,13 @@ sub msg ($$;$%)
       $location = '';
     }
 
-  confess "unknown channel $channel" unless exists $channels{$channel};
+  if (!exists $channels{$channel})
+    {
+      # This can happen as a result of e.g. m4_warn([nonsense], [message])
+      # so it should not crash.
+      report_bad_channel($channel, $location);
+      $channel = 'syntax';
+    }
 
   my %opts = %{$channels{$channel}};
   _merge_options (%opts, %options);
@@ -662,6 +668,45 @@ sub msg ($$;$%)
     }
 }
 
+sub report_bad_channel ($$)
+{
+  my ($channel, $location) = @_;
+  my $message;
+  my $report_as = 'error';
+
+  # quotemeta is both too aggressive (e.g. it escapes '-') and
+  # too generous (it turns control characters into \ + themselves,
+  # not into symbolic escapes).
+  my $q_channel = $channel;
+  $q_channel =~ s/(?=[\"\$\'\@\`\\])/\\/g;
+  $q_channel =~ s/([^\x20-\x7e])/sprintf('\\x%02X', ord $1)/eg;
+  $q_channel = '"' . $q_channel . '"';
+
+  if ($channel eq '' || $channel eq 'all')
+    {
+      # Prior to version 2.70, the Autoconf manual said it was valid to use
+      # "all" and the empty string as the category argument to m4_warn, so
+      # don't treat those cases as errors.
+      $report_as = 'obsolete';
+      $message = "use of $q_channel as a diagnostic category is obsolete\n";
+      $message .= "(see automake --help for a list of valid categories)";
+    }
+  elsif ($channel eq 'none'
+         || ($channel =~ /^no-/ && exists $channels{substr($channel, 3)}))
+    {
+      # Also recognize "none" and "no-[category]", as someone might have
+      # thought anything acceptable to -W is also acceptable to m4_warn.
+      # Note: m4_warn([error], [...]) does actually issue an error.
+      $message = "-W accepts $q_channel, but it is not a diagnostic category";
+    }
+  else
+    {
+      $message = "unknown diagnostic category " . $q_channel;
+    }
+
+  msg $report_as, $location, $message;
+}
+
 
 =item C<setup_channel ($channel, %options)>
 
-- 
2.41.0





Information forwarded to automake-patches <at> gnu.org:
bug#67971; Package automake-patches. (Sat, 23 Dec 2023 01:47:01 GMT) Full text and rfc822 format available.

Message #8 received at 67971 <at> debbugs.gnu.org (full text, mbox):

From: Karl Berry <karl <at> freefriends.org>
To: zack <at> owlfolio.org
Cc: 67971 <at> debbugs.gnu.org
Subject: Re: [bug#67971] [PATCH] Sync shared files from Autoconf
Date: Fri, 22 Dec 2023 18:46:26 -0700
    lib/Automake/ChannelDefs.pm and lib/Automake/Channels.pm were updated
    in Autoconf to address <https://savannah.gnu.org/support/?110872>.

Thanks Zack. Installed.

BTW, the automake THANKS file has your panix.com address. Is that still
ok, or should I update it to owlfolio? (Not that it really matters.) -k




Reply sent to Karl Berry <karl <at> freefriends.org>:
You have taken responsibility. (Sat, 23 Dec 2023 01:47:02 GMT) Full text and rfc822 format available.

Notification sent to Zack Weinberg <zack <at> owlfolio.org>:
bug acknowledged by developer. (Sat, 23 Dec 2023 01:47:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 20 Jan 2024 12:24:20 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 151 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.