From unknown Sat Jun 21 03:01:06 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#67841 <67841@debbugs.gnu.org> To: bug#67841 <67841@debbugs.gnu.org> Subject: Status: [PATCH] Clarify error messages for misuse of m4_warn and --help for -W. Reply-To: bug#67841 <67841@debbugs.gnu.org> Date: Sat, 21 Jun 2025 10:01:06 +0000 retitle 67841 [PATCH] Clarify error messages for misuse of m4_warn and --he= lp for -W. reassign 67841 automake-patches submitter 67841 Zack Weinberg severity 67841 normal tag 67841 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 15 15:44:54 2023 Received: (at submit) by debbugs.gnu.org; 15 Dec 2023 20:44:54 +0000 Received: from localhost ([127.0.0.1]:53612 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rEF3F-00068y-2w for submit@debbugs.gnu.org; Fri, 15 Dec 2023 15:44:53 -0500 Received: from lists.gnu.org ([2001:470:142::17]:54108) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rEF3C-00068k-DY for submit@debbugs.gnu.org; Fri, 15 Dec 2023 15:44:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rEF36-0006K5-Gy; Fri, 15 Dec 2023 15:44:44 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rEF33-0008Ud-Ld; Fri, 15 Dec 2023 15:44:44 -0500 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id AF14532009F3; Fri, 15 Dec 2023 15:44:37 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Fri, 15 Dec 2023 15:44:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=owlfolio.org; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:message-id:mime-version:reply-to:subject :subject:to:to; s=fm1; t=1702673077; x=1702759477; bh=NZB7LslVfv B5oq70+Mii3e8t/VUvY2hJH8QZvRl1KhA=; b=LtsEE6gGkd17OjhTTZEuUxW1nn GViz/w+PfFGW23Bbnhhq5LAMfyONEK8+bjoD9AnJl2GhJ5cP/I0YmvJDCT/HV1kW tTz4CKVDw5mjIhc+VswtugwlYI1iJT5jFIyfWr2SngRAS3TJB8cOwv/YbN9Kry64 MNNH7+HlIMrrBCicCOzl7RCjCPBDtalCjGKfjQZcrsxDhxQT+MWp58FmdxuaUb1H W7jH8A8VZZy1044eQsKY2dODDkQz5Hodj7MsBN4pt7lwG0Kse39PYL5eHo0SiuJ+ tZf0oy6eunf7qXdsEjkkxjYmqIDFjcHZ4Wpu8JULLgTqd2K8MMFAd0QrSCRw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:message-id:mime-version:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1702673077; x=1702759477; bh=NZB7LslVfvB5oq70+Mii3e8t/VUv Y2hJH8QZvRl1KhA=; b=HQX9Zs/0BHguQV111mhKUZU0Gm7SdS+mjZk0fV5sOL6q ClqJV9PVncPm6Vg2ZDwUdn9z+WQKfw4CftxdAo+X6Glt95KvWr8m9UM55Vr+ncXy UmXzcpLj8SqohfaHjio0ys23EyZYJVJLmI7vRd/3/FduonwnQZ2N++0TPyMW2Uja qlFYWMOSwR1FxqbfT0HQ3ycNEgRjaqLMyYHvdgHHZP9ahOmXGW0AcKugBFBJMSmD LtVBR8llFkzIo6PNTxGE43uyabRETTMIChGMx2p3raw8AEkmWUOQSB4Ge4HfJjNX G2DfmIMFW84yF33k34gvMFaDpo47Imi9e33h36FNSA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvddtvddgudegtdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffogggtgfesthekre dtredtjeenucfhrhhomhepkggrtghkucghvghinhgsvghrghcuoeiirggtkhesohiflhhf ohhlihhordhorhhgqeenucggtffrrghtthgvrhhnpedviedtudekheeffedugeetteduve eukedtheeugeeuleduleefvdduhfeufefgkeenucffohhmrghinhepghhnuhdrohhrghen ucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpeiirggtkh esohiflhhfohhlihhordhorhhg X-ME-Proxy: Feedback-ID: i876146a2:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 15 Dec 2023 15:44:35 -0500 (EST) Received: by moxana.owlfolio.org (sSMTP sendmail emulation); Fri, 15 Dec 2023 15:44:35 -0500 From: Zack Weinberg To: autoconf-patches@gnu.org, automake-patches@gnu.org Subject: [PATCH] Clarify error messages for misuse of m4_warn and --help for -W. Date: Fri, 15 Dec 2023 15:44:35 -0500 Message-ID: <20231215204435.1888127-1-zack@owlfolio.org> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=64.147.123.25; envelope-from=zack@owlfolio.org; helo=wout2-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.6 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.4 (/) In autoconf 2.69, the manual said that you could use “all” and the empty string as the first argument to m4_warn. As far as I can tell this was never actually true, and the manual was corrected in 2.70, but we still got a bug report from someone who tried it and got a confusing internal error from the guts of autom4te. This patch makes us issue a nice helpful user error, instead of a confusing internal error, when Autom4te::Channels::msg is called with a bogus channel argument. If the bogus channel is “all” or the empty string, that error is demoted to a -Wobsolete warning. If it is one of the other special tokens recognized by -W, we customize the error message, since someone might’ve thought that “none” being acceptable to -W meant it was also acceptable to m4_warn. The --help output for autoconf, autoheader, autom4te, and autoreconf is also adjusted to clarify that not all of the tokens recognized by -W count as warning categories. (Oddly enough, m4_warn([error], […]) actually issues an error, because the argument to m4_warn is passed straight through as the channel argument to Autom4te::Channels::msg. Since neither m4_errprintn(…) nor m4_fatal(…) does quite the same thing as m4_warn([error], […]), I propose to leave that alone for now and promote it to a proper, documented feature (probably spelled m4_error(…)) post-2.72.) Since this touches code shared between Autoconf and Automake, I’m not checking it in yet and I’m requesting comments from both sides of the fence. Also, there’s a perl 2.14ism in one place (s///a) which I need to figure out how to make 2.6-compatible before it can land. Addresses . * lib/Autom4te/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/Autom4te/ChannelDefs.pm (usage): Clarify that the list of warning categories is exhaustive, and that “all”, “none”, “no-CATEGORY”, and “error” are not warning categories. * bin/autoconf.in, bin/autoheader.in, bin/autom4te.in, bin/autoreconf.in: Tweak --help text. * tests/m4sugar.at (m4@&t@_warn (bad categories)): New test. --- bin/autoconf.in | 1 + bin/autoheader.in | 1 + bin/autom4te.in | 1 + bin/autoreconf.in | 10 +++--- lib/Autom4te/ChannelDefs.pm | 10 +++--- lib/Autom4te/Channels.pm | 48 +++++++++++++++++++++++++++- tests/m4sugar.at | 63 +++++++++++++++++++++++++++++++++++++ 7 files changed, 123 insertions(+), 11 deletions(-) diff --git a/bin/autoconf.in b/bin/autoconf.in index 060a9a04..5f4a2e5c 100644 --- a/bin/autoconf.in +++ b/bin/autoconf.in @@ -64,6 +64,7 @@ Operation modes: -f, --force consider all files obsolete -o, --output=FILE save output in FILE (stdout is the default) -W, --warnings=CATEGORY report the warnings falling in CATEGORY + (comma-separated list accepted) " . Autom4te::ChannelDefs::usage . " diff --git a/bin/autoheader.in b/bin/autoheader.in index 4afa5f13..f5af0df2 100644 --- a/bin/autoheader.in +++ b/bin/autoheader.in @@ -74,6 +74,7 @@ or else 'configure.in'. -d, --debug don\'t remove temporary files -f, --force consider all files obsolete -W, --warnings=CATEGORY report the warnings falling in CATEGORY + (comma-separated list accepted) " . Autom4te::ChannelDefs::usage . " diff --git a/bin/autom4te.in b/bin/autom4te.in index 8957a6c9..2e4e7d52 100644 --- a/bin/autom4te.in +++ b/bin/autom4te.in @@ -160,6 +160,7 @@ Operation modes: -o, --output=FILE save output in FILE (defaults to '-', stdout) -f, --force don't rely on cached values -W, --warnings=CATEGORY report the warnings falling in CATEGORY + (comma-separated list accepted) -l, --language=LANG specify the set of M4 macros to use -C, --cache=DIRECTORY preserve results for future runs in DIRECTORY --no-cache disable the cache diff --git a/bin/autoreconf.in b/bin/autoreconf.in index c6077efe..285d0f49 100644 --- a/bin/autoreconf.in +++ b/bin/autoreconf.in @@ -84,20 +84,18 @@ Operation modes: --no-recursive don't rebuild sub-packages -s, --symlink with -i, install symbolic links instead of copies -m, --make when applicable, re-run ./configure && make - -W, --warnings=CATEGORY report the warnings falling in CATEGORY [syntax] + -W, --warnings=CATEGORY report the warnings falling in CATEGORY + (comma-separated list accepted) " . Autom4te::ChannelDefs::usage . " -The environment variable 'WARNINGS' is honored. Some subtools might -support other warning types, using 'all' is encouraged. - Library directories: -B, --prepend-include=DIR prepend directory DIR to search path -I, --include=DIR append directory DIR to search path The environment variables AUTOCONF, ACLOCAL, AUTOHEADER, AUTOM4TE, -AUTOMAKE, AUTOPOINT, GTKDOCIZE, INTLTOOLIZE, LIBTOOLIZE, M4, and MAKE -are honored. +AUTOMAKE, AUTOPOINT, GTKDOCIZE, INTLTOOLIZE, LIBTOOLIZE, M4, MAKE, +and WARNINGS are honored. Report bugs to . GNU Autoconf home page: . diff --git a/lib/Autom4te/ChannelDefs.pm b/lib/Autom4te/ChannelDefs.pm index 85ea6f82..9682e8db 100644 --- a/lib/Autom4te/ChannelDefs.pm +++ b/lib/Autom4te/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 diff --git a/lib/Autom4te/Channels.pm b/lib/Autom4te/Channels.pm index a2ed0a0b..634a61a6 100644 --- a/lib/Autom4te/Channels.pm +++ b/lib/Autom4te/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,46 @@ 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])/"\\x".sprintf("%02x", ord($1))/aeg; + $q_channel =~ s/(?=[\"\$\'\@\`])/\\/g; + $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 autom4te --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 diff --git a/tests/m4sugar.at b/tests/m4sugar.at index 2f1dbe37..9a6be0d2 100644 --- a/tests/m4sugar.at +++ b/tests/m4sugar.at @@ -244,6 +244,7 @@ AT_CLEANUP ## --------- ## AT_SETUP([m4@&t@_warn]) +AT_KEYWORDS([m4@&t@_warn]) AT_DATA_M4SUGAR([script.4s], [[m4_init @@ -297,6 +298,68 @@ script.4s:8: the top level AT_CLEANUP +## ----------------------------------------------- ## +## Bad m4_warn categories (Autoconf bug #110872). ## +## ----------------------------------------------- ## + +AT_SETUP([m4@&t@_warn (bad categories)]) +AT_KEYWORDS([m4@&t@_warn]) + +AT_DATA_M4SUGAR([script.4s], +[[m4_init +m4_warn([], [empty category])dnl +m4_warn([bogus], [invalid category])dnl +m4_warn([!"%^&*], [line noise category])dnl " unconfuse editor +m4_warn([all], ['all' used as a category])dnl +m4_warn([none], ['none' used as a category])dnl +m4_warn([no-syntax], ['no-syntax' used as a category])dnl +m4_warn([no-bogus], ['no-bogus' used as a category])dnl +m4_warn([error], [oddly enough, this works])dnl +]]) + +AT_CHECK_M4SUGAR([-o- -Wnone], 1, [], +[script.4s:3: error: unknown diagnostic category "bogus" +script.4s:4: error: unknown diagnostic category "!\"%^&*" +script.4s:6: error: -W accepts "none", but it is not a diagnostic category +script.4s:7: error: -W accepts "no-syntax", but it is not a diagnostic category +script.4s:8: error: unknown diagnostic category "no-bogus" +script.4s:9: error: oddly enough, this works +]) + +AT_CHECK_M4SUGAR([-o- -Wnone,obsolete], 1, [], +[script.4s:2: warning: use of "" as a diagnostic category is obsolete +script.4s:2: (see autom4te --help for a list of valid categories) +script.4s:3: error: unknown diagnostic category "bogus" +script.4s:4: error: unknown diagnostic category "!\"%^&*" +script.4s:5: warning: use of "all" as a diagnostic category is obsolete +script.4s:5: (see autom4te --help for a list of valid categories) +script.4s:6: error: -W accepts "none", but it is not a diagnostic category +script.4s:7: error: -W accepts "no-syntax", but it is not a diagnostic category +script.4s:8: error: unknown diagnostic category "no-bogus" +script.4s:9: error: oddly enough, this works +]) + +AT_CHECK_M4SUGAR([-o- -Wnone,obsolete,syntax], 1, [], +[script.4s:2: warning: use of "" as a diagnostic category is obsolete +script.4s:2: (see autom4te --help for a list of valid categories) +script.4s:2: warning: empty category +script.4s:3: error: unknown diagnostic category "bogus" +script.4s:3: warning: invalid category +script.4s:4: error: unknown diagnostic category "!\"%^&*" +script.4s:4: warning: line noise category +script.4s:5: warning: use of "all" as a diagnostic category is obsolete +script.4s:5: (see autom4te --help for a list of valid categories) +script.4s:5: warning: 'all' used as a category +script.4s:6: error: -W accepts "none", but it is not a diagnostic category +script.4s:6: warning: 'none' used as a category +script.4s:7: error: -W accepts "no-syntax", but it is not a diagnostic category +script.4s:7: warning: 'no-syntax' used as a category +script.4s:8: error: unknown diagnostic category "no-bogus" +script.4s:8: warning: 'no-bogus' used as a category +script.4s:9: error: oddly enough, this works +]) + +AT_CLEANUP ## ----------------- ## ## m4_divert_stack. ## -- 2.41.0 From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 15 18:52:44 2023 Received: (at 67841) by debbugs.gnu.org; 15 Dec 2023 23:52:44 +0000 Received: from localhost ([127.0.0.1]:53749 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rEHz2-0002Zo-52 for submit@debbugs.gnu.org; Fri, 15 Dec 2023 18:52:44 -0500 Received: from frenzy.freefriends.org ([198.99.81.75]:43322 helo=freefriends.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rEHz0-0002Ze-7c for 67841@debbugs.gnu.org; Fri, 15 Dec 2023 18:52:42 -0500 X-Envelope-From: karl@freefriends.org Received: from freefriends.org (localhost [127.0.0.1]) by freefriends.org (8.14.7/8.14.7) with ESMTP id 3BFNqetF008777 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 15 Dec 2023 16:52:40 -0700 Received: (from apache@localhost) by freefriends.org (8.14.7/8.14.7/Submit) id 3BFNqeSu008776; Fri, 15 Dec 2023 16:52:40 -0700 Date: Fri, 15 Dec 2023 16:52:40 -0700 Message-Id: <202312152352.3BFNqeSu008776@freefriends.org> From: Karl Berry To: zack@owlfolio.org Subject: Re: [bug#67841] [PATCH] Clarify error messages for misuse of m4_warn and --help for -W. In-Reply-To: <20231215204435.1888127-1-zack@owlfolio.org> X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 67841 Cc: autoconf-patches@gnu.org, 67841@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi Zack, Since this touches code shared between Autoconf and Automake, I'm not checking it in yet and I'm requesting comments from both sides of the fence. Well, it seems good to me in principle, FWIW. I don't think this directly affects automake? I admit I did not try to extract the parts for automake and run the am tests ... --thanks, karl. From debbugs-submit-bounces@debbugs.gnu.org Fri Dec 15 19:08:09 2023 Received: (at 67841) by debbugs.gnu.org; 16 Dec 2023 00:08:09 +0000 Received: from localhost ([127.0.0.1]:53771 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rEIDx-0005Yc-DV for submit@debbugs.gnu.org; Fri, 15 Dec 2023 19:08:09 -0500 Received: from mail-ot1-x32b.google.com ([2607:f8b0:4864:20::32b]:53526) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rEIDw-0005YF-4i for 67841@debbugs.gnu.org; Fri, 15 Dec 2023 19:08:08 -0500 Received: by mail-ot1-x32b.google.com with SMTP id 46e09a7af769-6da579e6858so400235a34.3 for <67841@debbugs.gnu.org>; Fri, 15 Dec 2023 16:08:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702685282; x=1703290082; darn=debbugs.gnu.org; h=content-transfer-encoding:in-reply-to:references:subject:cc:to :mime-version:user-agent:reply-to:from:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=XaU9yzzw9HwToOIgxl+w2Vhsw2bkLddaAaDNLlTF2lI=; b=Po4ZbuYoENDwaoV4PtMfpBO2MC3sWZxVWS9i+C5mFTvuxq8ej9eLWPqKJ/e06Ccd5r /e0XgALdIkxXpAdWdlseHTVmeckCp7+oS4c4UoreHx1FQCXrGjEDPcGLYouZYiDTFSQm wc9rRF5XEUAYPgxQOT5wEIDq8IWfUPsJUjZLHtrCGfXK7JcRYnaPBKs66kFka7OiQvwd v7Yn/7S7OM72hETW69NnhvHdTRob3amcAhbeJe1VXJbtn+ijsPZ5D614UvjYCIx3RNGV EUcam1SmFxU5ENIvQg0g7iSkY83yItcUgB5h/PGAFrF+raMSXyNJaEc+3ueDs14469Be Kg/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702685282; x=1703290082; h=content-transfer-encoding:in-reply-to:references:subject:cc:to :mime-version:user-agent:reply-to:from:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=XaU9yzzw9HwToOIgxl+w2Vhsw2bkLddaAaDNLlTF2lI=; b=P8i66VUDPkPLaONJqhRJhvz2RkIA1J/sJJ6CCrJ2NbwvDYK/bY9K4QPutOsMbW0022 d/vSlci2qTGh1WKlwVPD/Z51VkvuAydckrKgjWKHI+8s3ROOfXSMJdltfDerOyHTe5Wk JFktz7sJ2LCAwDgXuVfCyLge/rrGRhsyG8/wnO8IclKzk+5RMQ4FaYM7iBQO5lhJQIiW BJA8UVzHGEXU9qBVL2Fe3ss3dWmdZh05O8u1tyaFZHOxuqK+9hQBKrngmz8k9+/xmiwG Y9N6JEctY33DrQtZsJ+VlmT8nubbN94BJsHaVSyHVso02MFKJRNC7oHFd7fd0SCYUI/2 lO5A== X-Gm-Message-State: AOJu0YzvHhf0A1xqwwv4NBYt+Iiq1q1o/qtTrU3ObnRUFfpTN9Cb9V6c pEz69njzT8kQQZ3/v9ZyfKY= X-Google-Smtp-Source: AGHT+IEDUZNbfQrmOfavd1JSs9Gab5+0UvKYLrUu7cx53LNF3qS8+hfbU/fLDkxdNMIqV1xa4tRfvA== X-Received: by 2002:a9d:6185:0:b0:6d9:e28c:28ef with SMTP id g5-20020a9d6185000000b006d9e28c28efmr11642405otk.55.1702685282199; Fri, 15 Dec 2023 16:08:02 -0800 (PST) Received: from [127.0.0.1] ([70.133.144.43]) by smtp.gmail.com with ESMTPSA id eq9-20020a056830490900b006da0e88aa4bsm2850258otb.64.2023.12.15.16.08.00 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Dec 2023 16:08:01 -0800 (PST) Message-ID: <657CEA60.5040605@gmail.com> Date: Fri, 15 Dec 2023 18:08:00 -0600 From: Jacob Bachmeyer User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.22) Gecko/20090807 MultiZilla/1.8.3.4e SeaMonkey/1.1.17 Mnenhy/0.7.6.0 MIME-Version: 1.0 To: Zack Weinberg Subject: Re: [bug#67841] [PATCH] Clarify error messages for misuse of m4_warn and --help for -W. References: <20231215204435.1888127-1-zack@owlfolio.org> In-Reply-To: <20231215204435.1888127-1-zack@owlfolio.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Score: -0.2 (/) X-Debbugs-Envelope-To: 67841 Cc: autoconf-patches@gnu.org, 67841@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: jcb62281@gmail.com Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.2 (-) Zack Weinberg wrote: > [...] > > Since this touches code shared between Autoconf and Automake, I’m not > checking it in yet and I’m requesting comments from both sides of the > fence. Also, there’s a perl 2.14ism in one place (s///a) which I need > to figure out how to make 2.6-compatible before it can land. > > [...] > > +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])/"\\x".sprintf("%02x", ord($1))/aeg; > + $q_channel =~ s/(?=[\"\$\'\@\`])/\\/g; > + $q_channel = '"' . $q_channel . '"'; > > [...] > If I am reading perlre correctly, you should be able to simply drop the /a modifier because it has no effect on the pattern you have written, since you are using an explicit character class and are *not* using the /i modifier. (The documentation says that /a only affects the \d, \s, \w Perl character classes and the POSIX character classes.) Further, Perl's sprintf is indeed sprintf, so you should be able to rewrite that substitution as: s/([^\x20-\x7e])/sprintf('\\x%02x', ord $1)/eg This slightly simplifies the program (eliminating one concatenation), which is probably of trivial consequence, since this code is on an error path and not an inner loop. More importantly, including the "\\x" in the sprintf format string makes the intended output more clear. The single quotes are both a (very slight) performance optimization and serve to document that no direct interpolation is intended because this is a format string. Perl's handling of backslash in single quotes is fun: backslash escapes itself but will also be taken literally if it does not form an escape that is allowed in q[]. -- Jacob From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 18 13:58:59 2023 Received: (at 67841) by debbugs.gnu.org; 18 Dec 2023 18:58:59 +0000 Received: from localhost ([127.0.0.1]:33612 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rFIpO-0002xg-S0 for submit@debbugs.gnu.org; Mon, 18 Dec 2023 13:58:59 -0500 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:48191) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rFIpN-0002xH-1i for 67841@debbugs.gnu.org; Mon, 18 Dec 2023 13:58:57 -0500 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id E820B5C029A; Mon, 18 Dec 2023 13:58:48 -0500 (EST) Received: from imap45 ([10.202.2.95]) by compute5.internal (MEProxy); Mon, 18 Dec 2023 13:58:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=owlfolio.org; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1702925928; x=1703012328; bh=EaNpwUqvPYLaroiQSmkuTn4rsSxvz2JM/mMoLjmlYaE=; b= maa6s2Vj+UAuENJz/EX8ZhozL6CMMf9Wtw1tIS5JmEhQ47UN9g9K3t/xsxCNNMCE HfmNfr4/ix6fcA7hMfT1JYgtKPjjcZcBAxA/WQGCsZvuCh8D9pgVfd/A2v+3XLO8 /3Ui0OxkJy4/NTS7XEk1mdxAn2NNAO2+46aQmPJB+0X4/xuvVEYFsXGh6O4Gj9lN UoaoeREDt8CCwuJPP/iJV7YofcccxJgzXSf8W4hOfYTJligwucOHMtCekB2AruXR 10cIU9BsBSTezqYZwuFrON4LpK64AnqefRnQKr1TEJCLOXTeRNvn+LH1rZHR6qq6 L/GQqE/nOU5DXOEaES1pzQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1702925928; x= 1703012328; bh=EaNpwUqvPYLaroiQSmkuTn4rsSxvz2JM/mMoLjmlYaE=; b=v KLHCUpV210teTW7oHMp1LssBnnZM4euYgaVwgyK7krp4YE0CtRxAplBMHctgf/RT ad2yH6bYymGOvQ1orsIKZ64mrSBH3D2sfD3VU3aRx/A1f0YxOkAUmQffY1DwDTbz GoCNYdIKvUZDh3srswRByK0sqh22yc8yVISDWYlc9lGq17aYDTmmq/Swq0ZrOjd0 nNczLb19Eadk47TztqZ/t/xu1rIZsTbFE38PJp/8Ft+uTOQP/ClW9E95+OTVAmvf 3t6UBM3QWPCbAC10DkSua4XaIr6tfj4r6NXfSHENWx4H4JL4+WhBzR40Xxo9iEW3 RubB4wlxZ+OwXJILCdvwA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvddtkedguddukecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvvefutgfgsehtqhertderreejnecuhfhrohhmpedf kggrtghkucghvghinhgsvghrghdfuceoiigrtghksehofihlfhholhhiohdrohhrgheqne cuggftrfgrthhtvghrnhepudeuieegheffkeeihfdtheeivdeuffetveethfdugfeutdeu iedttefgteeiieeinecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepiigrtghksehofihlfhholhhiohdrohhrgh X-ME-Proxy: Feedback-ID: i876146a2:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 50762272007C; Mon, 18 Dec 2023 13:58:48 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-1283-g327e3ec917-fm-20231207.002-g327e3ec9 MIME-Version: 1.0 Message-Id: <8e57bf48-15b5-4ca7-963d-657c98ad3272@app.fastmail.com> In-Reply-To: <657CEA60.5040605@gmail.com> References: <20231215204435.1888127-1-zack@owlfolio.org> <657CEA60.5040605@gmail.com> Date: Mon, 18 Dec 2023 13:58:27 -0500 From: "Zack Weinberg" To: "Jacob Bachmeyer" Subject: Re: [bug#67841] [PATCH] Clarify error messages for misuse of m4_warn and --help for -W. Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 67841 Cc: Autoconf Patches , 67841@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) On Fri, Dec 15, 2023, at 7:08 PM, Jacob Bachmeyer wrote: > Zack Weinberg wrote: >> [...] >> Also, there=E2=80=99s a perl 2.14ism in one place (s///a) which I need >> to figure out how to make 2.6-compatible before it can land. ... >> + $q_channel =3D~ s/([^\x20-\x7e])/"\\x".sprintf("%02x", ord($1))/ae= g; ... > If I am reading perlre correctly, you should be able to simply drop th= e=20 > /a modifier because it has no effect on the pattern you have written,=20 > since you are using an explicit character class and are *not* using th= e=20 > /i modifier. Thanks, you've made me realize that /a wasn't even what I wanted in the first place. What I thought /a would do is force s/// to act byte by byte -- or, in the terms of perlunitut, force the target string to be treated as a binary string. That might be clearer with a concrete examp= le: $ perl -e '$_ =3D "\xE2\x88\x85"; s/([^\x20-\x7e])/sprintf("\\x%02x", or= d($1))/eg; print "$_\n";' \xe2\x88\x85 $ perl -e '$_ =3D "\N{EMPTY SET}"; s/([^\x20-\x7e])/sprintf("\\x%02x", o= rd($1))/eg; print "$_\n";' \x2205 What change do I need to make to the second one-liner to make it also print \xe2\x88\x85? How do I express that in a way that is backward compatible all the way to 5.6.0? And finally, how do I ensure that there is absolutely nothing I can put in the initial assignment to $_ that will cause the rest of the one-liner to crash? For example over in the Python universe it's very easy to get Unicode conversion to crash: $ python3 -c 'print("\uDC00".encode("utf-8"))' Traceback (most recent call last): File "", line 1, in UnicodeEncodeError: 'utf-8' codec can't encode character '\udc00' in pos= ition 0: surrogates not allowed Given that having non-ASCII here in the first place is pretty unlikely, I am going to go ahead and land the patch with your suggested changes, but I'd still appreciate any further advice you have. zw From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 18 14:02:50 2023 Received: (at 67841) by debbugs.gnu.org; 18 Dec 2023 19:02:50 +0000 Received: from localhost ([127.0.0.1]:33618 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rFIt8-0005l4-HY for submit@debbugs.gnu.org; Mon, 18 Dec 2023 14:02:50 -0500 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:45547) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rFIt6-0005kT-HA for 67841@debbugs.gnu.org; Mon, 18 Dec 2023 14:02:49 -0500 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id D48A75C01D3; Mon, 18 Dec 2023 14:02:40 -0500 (EST) Received: from imap45 ([10.202.2.95]) by compute5.internal (MEProxy); Mon, 18 Dec 2023 14:02:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=owlfolio.org; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1702926160; x=1703012560; bh=P+jVwR4Yo3 FskjpAIoVtXccqPYBccAMkzi+2GGmrtCE=; b=G2rgC6o9Btgw2PJqkODxCKHgQK VTjlYefPLxrulIrE32v+/KuJKpDm0oa3I4bwd0Lqv4VxLYP4LS0cHUk1kj1+HcgF IwVop8Z+swCWpHJOjgFA7iFaeo8/5+xmY6jpili2917rBqKHzucMq38EaKYqk+e8 Mmfx7uzvCDqVbyw6eQ2ZHFW8z6k4AsF+xAtp/7TYxcIlGXW0QNwHaDBm0svGoOsN SVfLpZWnCIBeuIgjmAfD9qbwibyXSf53L8JEQVyN44sa8DjK33tRcPGCjJDckpsu EesbqhOL0mqKYYhP4mVPjeU99IwcnhNlfFIr/w6zwBYUYqIjLrtojxoypURQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1702926160; x=1703012560; bh=P+jVwR4Yo3FskjpAIoVtXccqPYBc cAMkzi+2GGmrtCE=; b=srhC5x8P+giXuzJbUosMsr3dXg1KyvNmB77+VzlrkKjr H/+bom+55O030V3U7aOK/3PYzUKuMCLstud8jSY1En6LADthqNGt2K1H/EBsVJlj hWKc8O16rnsvPewhLoGWaPhtHmB91OPSsnKAf5MVcelYkZxo8esqZ+llJCG/iyvP pTqYlvzu3uYp4cLnXztdkHiHfO8G5EI5JqMg1DfW9GFvuEPLysMVoOTil3arG0oz VUqkTAJ+xnOH7fti89jtMy2nsQSmN6yAZSzzZRoMVyYzj0LcRVSImWhffNi2ctek m8CScbKPw75rdNz6MjFmoisQTNMRjcdHPvY8ZR8Kog== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvddtkedguddukecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvvefutgesthdtredtreertdenucfhrhhomhepfdgk rggtkhcuhggvihhnsggvrhhgfdcuoeiirggtkhesohiflhhfohhlihhordhorhhgqeenuc ggtffrrghtthgvrhhnpefhleefheduhfelgeehgeejveehueeihedvgfeuueetteelieei teehfefhleduieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpeiirggtkhesohiflhhfohhlihhordhorhhg X-ME-Proxy: Feedback-ID: i876146a2:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id B3DC3272007C; Mon, 18 Dec 2023 14:02:39 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-1283-g327e3ec917-fm-20231207.002-g327e3ec9 MIME-Version: 1.0 Message-Id: <49e34850-4608-43e2-a9cb-8a5cc474e926@app.fastmail.com> In-Reply-To: <202312152352.3BFNqeSu008776@freefriends.org> References: <202312152352.3BFNqeSu008776@freefriends.org> Date: Mon, 18 Dec 2023 14:02:18 -0500 From: "Zack Weinberg" To: "Karl Berry" Subject: Re: [bug#67841] [PATCH] Clarify error messages for misuse of m4_warn and --help for -W. Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 67841 Cc: Autoconf Patches , 67841@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) On Fri, Dec 15, 2023, at 6:52 PM, Karl Berry wrote: > Hi Zack, > > Since this touches code shared between Autoconf and Automake, I'm not > checking it in yet and I'm requesting comments from both sides of the > fence. > > Well, it seems good to me in principle, FWIW. I don't think this > directly affects automake? I doubt it, unless there's something you can put in a Makefile.am that will cause Automake::Channels::msg to be called with a user-controlled $channel argument. (On the autoconf side of the fence, m4_warn([channel], [message]) does exactly that, hence the patch.) zw From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 18 14:27:16 2023 Received: (at 67841) by debbugs.gnu.org; 18 Dec 2023 19:27:16 +0000 Received: from localhost ([127.0.0.1]:33641 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rFJGl-000193-1P for submit@debbugs.gnu.org; Mon, 18 Dec 2023 14:27:16 -0500 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:52231) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rFJGi-00018X-Kk for 67841@debbugs.gnu.org; Mon, 18 Dec 2023 14:27:13 -0500 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 630D25C01E5; Mon, 18 Dec 2023 14:27:04 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Mon, 18 Dec 2023 14:27:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=owlfolio.org; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1702927624; x=1703014024; bh=wAB3a0nJkibjK5z1hteFXptOy4gpLDnvwYj+z4EFPo4=; b= AHsQwSClcyPY3f4Blqblw1Adj4fKgV4CmYsUNI04OS3X03emaUJsC9V/4CBWWAZA OIBSTc0lIzo8TAnlDdL7evbu7nfGuFhrbeb/wrstPRSu7TnxVVDM1DQz4GCRGgr4 E3pnh37m6TN2VCK1+teaHE8ubSYn2JHAtnmJ9yuG9pC6WRKP6dCiqOJ8uzPPmbVp +nqBjXzzmk0j8m8nOfg4D5ZByn4BhvhXHy6w3AyDoN+tjj6E741qPt0cgFGv65EU JURCkAlK2dqIK5Eq4/QnhotAosH32XDfQF+vSeEZVfLyugW4qukZ1qdJOl5zqnGj OVeFPUnRTqZozuTYbLddbw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1702927624; x= 1703014024; bh=wAB3a0nJkibjK5z1hteFXptOy4gpLDnvwYj+z4EFPo4=; b=M isoQbODQpeLnuj+v5AJDzfGWYKPAEl+IEY1Qg2OhtZg+D/mRYQKbjBO+cW+45ZGM RFDh5FIkQ4drbYu+mCYlpsJY7r5V1TeUdx6LLET3HrkNhWqu3hw22jQCDI6+XFDC rijuN5c8CCntslyW1Xp9yA97M3VMYuqGLYJ6Gv6O4LMAByz7r+n5M9UtgSUllm9W ordngUEwSaAOz98jnPVbk0GOKBoEjXgcJDEL7BHWV7m/+EQczQRU5Bse87NqPnVn 5sbx3gMo5fPHreIoJNu9uAjBf8+Nht/fYYRClgiCUh4oxIJ9YaoyEMQEdIx144ob MbiV3QHA3Y+Jmz5ajHcEw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvddtkedguddvvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfgggtgfesth ekredtredtjeenucfhrhhomhepkggrtghkucghvghinhgsvghrghcuoeiirggtkhesohif lhhfohhlihhordhorhhgqeenucggtffrrghtthgvrhhnpeehkedtudffjedtffefhffhue fgfefhgffhgfeltddujeekueetgfekgeevfffhleenucffohhmrghinhepghhnuhdrohhr ghenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpeiirg gtkhesohiflhhfohhlihhordhorhhg X-ME-Proxy: Feedback-ID: i876146a2:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 18 Dec 2023 14:27:03 -0500 (EST) Received: by moxana.owlfolio.org (sSMTP sendmail emulation); Mon, 18 Dec 2023 14:27:02 -0500 From: Zack Weinberg To: autoconf-patches@gnu.org, 67841@debbugs.gnu.org Subject: [PATCH v2, committed] Clarify error messages for misuse of m4_warn and --help for -W. Date: Mon, 18 Dec 2023 14:27:02 -0500 Message-ID: <20231218192702.640074-1-zack@owlfolio.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <8e57bf48-15b5-4ca7-963d-657c98ad3272@app.fastmail.com> References: <8e57bf48-15b5-4ca7-963d-657c98ad3272@app.fastmail.com> <657CEA60.5040605@gmail.com> <20231215204435.1888127-1-zack@owlfolio.org> <657CEA60.5040605@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 67841 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) m4_warn([category], [message]) passes its arguments directly to Autom4te::Channels::msg. If the category argument is not a recognized “channel”, that function will crash and emit a *Perl* stack trace, which makes it look like there’s something wrong with autoconf or autom4te, rather than something wrong with the script. Making matters worse, in autoconf 2.69, the manual said you could use “all” and the empty string as the first argument to m4_warn. As far as I can tell, neither of those was ever a valid message channel, and the manual was corrected in 2.70, but we still got a bug report from someone who tried it. This patch makes us issue a nice helpful user error, instead of a confusing internal error, when Autom4te::Channels::msg is called with a bogus channel argument. If the bogus channel is “all” or the empty string, that error is demoted to a -Wobsolete warning. If it is one of the other special tokens recognized by -W, we customize the error message, since someone might’ve thought that “none” being acceptable to -W meant it was also acceptable to m4_warn. The --help output for autoconf, autoheader, autom4te, and autoreconf is also adjusted to clarify that not all of the tokens recognized by -W count as warning categories. (Oddly enough, the lack of filtration at the autom4te level means m4_warn([error], […]) actually does issue an error. There’s no other way to get exactly that effect — m4_errprintn(…) and m4_fatal(…) both do something a little different — so I I propose to leave that alone for now and promote it to a proper, documented feature, probably spelled m4_error(…), post-2.72.) Channels.pm and ChannelDefs.pm are shared with Automake. I believe there is nothing you can write in a Makefile.am that will cause Automake::Channels::msg to be called with an arbitrary user-supplied channel argument, so these changes should have no visible effect on that side of the fence. Addresses . * lib/Autom4te/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/Autom4te/ChannelDefs.pm (usage): Clarify that the list of warning categories is exhaustive, and that “all”, “none”, “no-CATEGORY”, and “error” are not warning categories. * bin/autoconf.in, bin/autoheader.in, bin/autom4te.in, bin/autoreconf.in: Tweak --help text. * tests/m4sugar.at (m4@&t@_warn (bad categories)): New test. --- bin/autoconf.in | 1 + bin/autoheader.in | 1 + bin/autom4te.in | 1 + bin/autoreconf.in | 10 +++--- lib/Autom4te/ChannelDefs.pm | 10 +++--- lib/Autom4te/Channels.pm | 47 ++++++++++++++++++++++++++- tests/m4sugar.at | 63 +++++++++++++++++++++++++++++++++++++ 7 files changed, 122 insertions(+), 11 deletions(-) diff --git a/bin/autoconf.in b/bin/autoconf.in index 060a9a04..5f4a2e5c 100644 --- a/bin/autoconf.in +++ b/bin/autoconf.in @@ -64,6 +64,7 @@ Operation modes: -f, --force consider all files obsolete -o, --output=FILE save output in FILE (stdout is the default) -W, --warnings=CATEGORY report the warnings falling in CATEGORY + (comma-separated list accepted) " . Autom4te::ChannelDefs::usage . " diff --git a/bin/autoheader.in b/bin/autoheader.in index 4afa5f13..f5af0df2 100644 --- a/bin/autoheader.in +++ b/bin/autoheader.in @@ -74,6 +74,7 @@ or else 'configure.in'. -d, --debug don\'t remove temporary files -f, --force consider all files obsolete -W, --warnings=CATEGORY report the warnings falling in CATEGORY + (comma-separated list accepted) " . Autom4te::ChannelDefs::usage . " diff --git a/bin/autom4te.in b/bin/autom4te.in index 8957a6c9..2e4e7d52 100644 --- a/bin/autom4te.in +++ b/bin/autom4te.in @@ -160,6 +160,7 @@ Operation modes: -o, --output=FILE save output in FILE (defaults to '-', stdout) -f, --force don't rely on cached values -W, --warnings=CATEGORY report the warnings falling in CATEGORY + (comma-separated list accepted) -l, --language=LANG specify the set of M4 macros to use -C, --cache=DIRECTORY preserve results for future runs in DIRECTORY --no-cache disable the cache diff --git a/bin/autoreconf.in b/bin/autoreconf.in index c6077efe..285d0f49 100644 --- a/bin/autoreconf.in +++ b/bin/autoreconf.in @@ -84,20 +84,18 @@ Operation modes: --no-recursive don't rebuild sub-packages -s, --symlink with -i, install symbolic links instead of copies -m, --make when applicable, re-run ./configure && make - -W, --warnings=CATEGORY report the warnings falling in CATEGORY [syntax] + -W, --warnings=CATEGORY report the warnings falling in CATEGORY + (comma-separated list accepted) " . Autom4te::ChannelDefs::usage . " -The environment variable 'WARNINGS' is honored. Some subtools might -support other warning types, using 'all' is encouraged. - Library directories: -B, --prepend-include=DIR prepend directory DIR to search path -I, --include=DIR append directory DIR to search path The environment variables AUTOCONF, ACLOCAL, AUTOHEADER, AUTOM4TE, -AUTOMAKE, AUTOPOINT, GTKDOCIZE, INTLTOOLIZE, LIBTOOLIZE, M4, and MAKE -are honored. +AUTOMAKE, AUTOPOINT, GTKDOCIZE, INTLTOOLIZE, LIBTOOLIZE, M4, MAKE, +and WARNINGS are honored. Report bugs to . GNU Autoconf home page: . diff --git a/lib/Autom4te/ChannelDefs.pm b/lib/Autom4te/ChannelDefs.pm index 85ea6f82..9682e8db 100644 --- a/lib/Autom4te/ChannelDefs.pm +++ b/lib/Autom4te/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 diff --git a/lib/Autom4te/Channels.pm b/lib/Autom4te/Channels.pm index a2ed0a0b..cd77be95 100644 --- a/lib/Autom4te/Channels.pm +++ b/lib/Autom4te/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 autom4te --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 diff --git a/tests/m4sugar.at b/tests/m4sugar.at index 2f1dbe37..c7e87228 100644 --- a/tests/m4sugar.at +++ b/tests/m4sugar.at @@ -244,6 +244,7 @@ AT_CLEANUP ## --------- ## AT_SETUP([m4@&t@_warn]) +AT_KEYWORDS([m4@&t@_warn]) AT_DATA_M4SUGAR([script.4s], [[m4_init @@ -297,6 +298,68 @@ script.4s:8: the top level AT_CLEANUP +## ----------------------------------------------- ## +## Bad m4_warn categories (Autoconf bug #110872). ## +## ----------------------------------------------- ## + +AT_SETUP([m4@&t@_warn (bad categories)]) +AT_KEYWORDS([m4@&t@_warn]) + +AT_DATA_M4SUGAR([script.4s], +[[m4_init +m4_warn([], [empty category])dnl +m4_warn([bogus], [invalid category])dnl +m4_warn([!"\ %^&*], [line noise category])dnl " unconfuse editor +m4_warn([all], ['all' used as a category])dnl +m4_warn([none], ['none' used as a category])dnl +m4_warn([no-syntax], ['no-syntax' used as a category])dnl +m4_warn([no-bogus], ['no-bogus' used as a category])dnl +m4_warn([error], [oddly enough, this works])dnl +]]) + +AT_CHECK_M4SUGAR([-o- -Wnone], 1, [], +[script.4s:3: error: unknown diagnostic category "bogus" +script.4s:4: error: unknown diagnostic category "!\"\\\x09%^&*" +script.4s:6: error: -W accepts "none", but it is not a diagnostic category +script.4s:7: error: -W accepts "no-syntax", but it is not a diagnostic category +script.4s:8: error: unknown diagnostic category "no-bogus" +script.4s:9: error: oddly enough, this works +]) + +AT_CHECK_M4SUGAR([-o- -Wnone,obsolete], 1, [], +[script.4s:2: warning: use of "" as a diagnostic category is obsolete +script.4s:2: (see autom4te --help for a list of valid categories) +script.4s:3: error: unknown diagnostic category "bogus" +script.4s:4: error: unknown diagnostic category "!\"\\\x09%^&*" +script.4s:5: warning: use of "all" as a diagnostic category is obsolete +script.4s:5: (see autom4te --help for a list of valid categories) +script.4s:6: error: -W accepts "none", but it is not a diagnostic category +script.4s:7: error: -W accepts "no-syntax", but it is not a diagnostic category +script.4s:8: error: unknown diagnostic category "no-bogus" +script.4s:9: error: oddly enough, this works +]) + +AT_CHECK_M4SUGAR([-o- -Wnone,obsolete,syntax], 1, [], +[script.4s:2: warning: use of "" as a diagnostic category is obsolete +script.4s:2: (see autom4te --help for a list of valid categories) +script.4s:2: warning: empty category +script.4s:3: error: unknown diagnostic category "bogus" +script.4s:3: warning: invalid category +script.4s:4: error: unknown diagnostic category "!\"\\\x09%^&*" +script.4s:4: warning: line noise category +script.4s:5: warning: use of "all" as a diagnostic category is obsolete +script.4s:5: (see autom4te --help for a list of valid categories) +script.4s:5: warning: 'all' used as a category +script.4s:6: error: -W accepts "none", but it is not a diagnostic category +script.4s:6: warning: 'none' used as a category +script.4s:7: error: -W accepts "no-syntax", but it is not a diagnostic category +script.4s:7: warning: 'no-syntax' used as a category +script.4s:8: error: unknown diagnostic category "no-bogus" +script.4s:8: warning: 'no-bogus' used as a category +script.4s:9: error: oddly enough, this works +]) + +AT_CLEANUP ## ----------------- ## ## m4_divert_stack. ## -- 2.41.0 From debbugs-submit-bounces@debbugs.gnu.org Tue Dec 19 00:44:59 2023 Received: (at 67841) by debbugs.gnu.org; 19 Dec 2023 05:44:59 +0000 Received: from localhost ([127.0.0.1]:33963 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rFSuZ-0007Ql-7U for submit@debbugs.gnu.org; Tue, 19 Dec 2023 00:44:59 -0500 Received: from mail-oi1-x231.google.com ([2607:f8b0:4864:20::231]:54443) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rFSuX-0007QW-S4 for 67841@debbugs.gnu.org; Tue, 19 Dec 2023 00:44:58 -0500 Received: by mail-oi1-x231.google.com with SMTP id 5614622812f47-3bb60d0b9b8so43171b6e.0 for <67841@debbugs.gnu.org>; Mon, 18 Dec 2023 21:44:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702964690; x=1703569490; darn=debbugs.gnu.org; h=content-transfer-encoding:in-reply-to:references:subject:cc:to :mime-version:user-agent:reply-to:from:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=BRf2mDbUPWP0OCPDEZ2q+ynUspe7fejEdsea2wQ84zE=; b=GpTp4afSPqd+RnIhdApwuRd0xMgle4BL6VgcUZvIakBjxmI6lYUwjNTDryNZXanI94 WuvGLTr9eiF/MgBSn8YtpMAr1kbYS0X9JaH/VL2MpK+cG4oytP6hD5I0ZgCNIwT+rSCU j9NtqsujT0buWFh3ovfF6t7cxUPLneQL5aIcc2JfauXm2+57OzaaUlhqtMpbfzhLVdvf RJj413tO6CgMmix2lvlBoZojitZd4JXR7CLWDHNYVwV00anWKjnvyhCZyMt8rpLn8OUD vjEbGlNHMzVIkyiJWee/M5GaQETekwsTCZqTn3+1N0Z3QV+9fdcQsc5ME/eF7RtApURN iwOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702964690; x=1703569490; h=content-transfer-encoding:in-reply-to:references:subject:cc:to :mime-version:user-agent:reply-to:from:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=BRf2mDbUPWP0OCPDEZ2q+ynUspe7fejEdsea2wQ84zE=; b=SKF9CTi7UBW7/GzgE2/4GEFHB+vNUQFRcsIO6Z+QrF3QO0QZWiRo7dJeUK63vG6wyu brUE65EPyMmSeJAyYH+HQfMPN/rFAnK1cbr+caxaUuI0+2RZqkgJhIy3EKbk67X+iz76 ku0fgFXHBCLTktOZz4ScQXdxS8bFIHvASzCRwH2u3LLO69xLSvEk8RtP5c5rHrWbjJKk VZZrTGHNNaTFV1eDgXbj3+eXIqZSFZA0uJB6CCWwMI9hm4NPc27GHOBDOPh5FYkR31vw 3vGkwElw0q/n6+Y9031+HbWdGwHF/9hfIiDAgRKX9rpaizSUzE8SKFky2ekZ8LmLeMDb JH3A== X-Gm-Message-State: AOJu0YwWb2uyhkdOEn4nNzxcEMrS9JFu8V4iklrhThNfI82zJ9kVJnVB Z85EamDD7B/XCn3dslKV2BQ= X-Google-Smtp-Source: AGHT+IGY8asDJ66v7mV3MIHqmRWicJ8I2s/NDvmPd/LY+6KQiNhb/XuE/UooXfUAw5FGcRb3+EOv4g== X-Received: by 2002:a05:6808:3206:b0:3ba:3f4b:d2c4 with SMTP id cb6-20020a056808320600b003ba3f4bd2c4mr3646886oib.116.1702964689689; Mon, 18 Dec 2023 21:44:49 -0800 (PST) Received: from [127.0.0.1] ([70.133.144.43]) by smtp.gmail.com with ESMTPSA id u18-20020a056808151200b003b2e4754cc2sm5059222oiw.26.2023.12.18.21.44.48 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Dec 2023 21:44:49 -0800 (PST) Message-ID: <65812DCF.208@gmail.com> Date: Mon, 18 Dec 2023 23:44:47 -0600 From: Jacob Bachmeyer User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.22) Gecko/20090807 MultiZilla/1.8.3.4e SeaMonkey/1.1.17 Mnenhy/0.7.6.0 MIME-Version: 1.0 To: Zack Weinberg Subject: Re: [bug#67841] [PATCH] Clarify error messages for misuse of m4_warn and --help for -W. References: <20231215204435.1888127-1-zack@owlfolio.org> <657CEA60.5040605@gmail.com> <8e57bf48-15b5-4ca7-963d-657c98ad3272@app.fastmail.com> In-Reply-To: <8e57bf48-15b5-4ca7-963d-657c98ad3272@app.fastmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Score: -0.2 (/) X-Debbugs-Envelope-To: 67841 Cc: Autoconf Patches , 67841@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: jcb62281@gmail.com Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.2 (-) Zack Weinberg wrote: > On Fri, Dec 15, 2023, at 7:08 PM, Jacob Bachmeyer wrote: > >> Zack Weinberg wrote: >> >>> [...] >>> Also, there’s a perl 2.14ism in one place (s///a) which I need >>> to figure out how to make 2.6-compatible before it can land. >>> > ... > >>> + $q_channel =~ s/([^\x20-\x7e])/"\\x".sprintf("%02x", ord($1))/aeg; >>> > ... > >> If I am reading perlre correctly, you should be able to simply drop the >> /a modifier because it has no effect on the pattern you have written, >> since you are using an explicit character class and are *not* using the >> /i modifier. >> > > Thanks, you've made me realize that /a wasn't even what I wanted in the > first place. What I thought /a would do is force s/// to act byte by > byte -- or, in the terms of perlunitut, force the target string to be > treated as a binary string. That might be clearer with a concrete example: > > $ perl -e '$_ = "\xE2\x88\x85"; s/([^\x20-\x7e])/sprintf("\\x%02x", ord($1))/eg; print "$_\n";' > \xe2\x88\x85 > $ perl -e '$_ = "\N{EMPTY SET}"; s/([^\x20-\x7e])/sprintf("\\x%02x", ord($1))/eg; print "$_\n";' > \x2205 > > What change do I need to make to the second one-liner to make it also > print \xe2\x88\x85? Add -MEncode to the one-liner and insert "$_ = encode_utf8($_);" before the substitution to declare that you want the string as UTF-8 bytes. The Encode documentation states: "All possible characters have a UTF-8 representation so this function [encode_utf8] cannot fail." In the actual patch, try "my $q_channel = encode_utf8($channel);" when initially copying the channel name. > How do I express that in a way that is backward > compatible all the way to 5.6.0? Now the fun part... Perl 5.6 had serious deficiencies in Unicode support; Encode was introduced with 5.8. You will need to make the Encode import conditional and generate a stub for encode_utf8 if the import fails. This should not be a problem since non-ASCII here in the first place is unlikely, and I think Perl 5.6 would treat non-ASCII as exactly the octet string you want anyway. Something like: (untested) BEGIN { my $have_Encode = 0; eval { require Encode; $have_Encode = 1; }; if ($have_Encode) { Encode->import('encode_utf8'); } else { # for Perl 5.6, which did not really have Unicode support anyway eval 'sub encode_utf8 { return pop }'; } } Note that the stub is defined using eval STRING rather than eval BLOCK because "sub" has compile-time effects in Perl and we only want it if Encode could not be loaded. > And finally, how do I ensure that there is absolutely nothing I can put in the initial assignment to $_ that will cause the rest of the one-liner to crash? For example > over in the Python universe it's very easy to get Unicode conversion > to crash: > > $ python3 -c 'print("\uDC00".encode("utf-8"))' > Traceback (most recent call last): > File "", line 1, in > UnicodeEncodeError: 'utf-8' codec can't encode character '\udc00' in position 0: surrogates not allowed > Not a problem in Perl: $ perl -MEncode -e '$_ = "\x{dc00}"; $_ = encode_utf8($_); s/([^\x20-\x7e])/sprintf("\\x%02x", ord($1))/eg; print "$_\n";' \xed\xb0\x80 :-) -- Jacob From debbugs-submit-bounces@debbugs.gnu.org Tue Dec 19 17:49:55 2023 Received: (at 67841) by debbugs.gnu.org; 19 Dec 2023 22:49:55 +0000 Received: from localhost ([127.0.0.1]:37803 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rFiuQ-0000bh-Os for submit@debbugs.gnu.org; Tue, 19 Dec 2023 17:49:54 -0500 Received: from frenzy.freefriends.org ([198.99.81.75]:53566 helo=freefriends.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rFiuP-0000bY-K3 for 67841@debbugs.gnu.org; Tue, 19 Dec 2023 17:49:53 -0500 X-Envelope-From: karl@freefriends.org Received: from freefriends.org (localhost [127.0.0.1]) by freefriends.org (8.14.7/8.14.7) with ESMTP id 3BJMnmBN024700 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 19 Dec 2023 15:49:48 -0700 Received: (from apache@localhost) by freefriends.org (8.14.7/8.14.7/Submit) id 3BJMnmV8024699; Tue, 19 Dec 2023 15:49:48 -0700 Date: Tue, 19 Dec 2023 15:49:48 -0700 Message-Id: <202312192249.3BJMnmV8024699@freefriends.org> From: Karl Berry To: jcb62281@gmail.com Subject: Re: [bug#67841] [PATCH] Clarify error messages for misuse of m4_warn and --help for -W. In-Reply-To: <65812DCF.208@gmail.com> X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 67841 Cc: zack@owlfolio.org, 67841@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) "All possible characters have a UTF-8 representation so this function [encode_utf8] cannot fail." What about non-characters, i.e., byte sequences that are invalid UTF-8? What I found was that using \N{...} implies a Unicode string. From the charnames(3) man page (stranged not named "perlcharnames"): Otherwise, any string that includes a "\N{charname}" or "\N{U+code point}" will automatically have Unicode rules (see "Byte and Character Semantics" in perlunicode). Maybe pack("C") somehow can get to the bytes from a Unicode string? Sorry I don't have time to experiment more. Must go look at the first bug reports from the pretest ... --thanks, karl. From debbugs-submit-bounces@debbugs.gnu.org Tue Dec 19 22:06:00 2023 Received: (at 67841) by debbugs.gnu.org; 20 Dec 2023 03:06:01 +0000 Received: from localhost ([127.0.0.1]:38055 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rFmuG-00011j-I4 for submit@debbugs.gnu.org; Tue, 19 Dec 2023 22:06:00 -0500 Received: from mail-oi1-x22e.google.com ([2607:f8b0:4864:20::22e]:45128) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rFmuE-00011V-5k for 67841@debbugs.gnu.org; Tue, 19 Dec 2023 22:05:58 -0500 Received: by mail-oi1-x22e.google.com with SMTP id 5614622812f47-3ba2dc0f6b7so4192197b6e.2 for <67841@debbugs.gnu.org>; Tue, 19 Dec 2023 19:05:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703041549; x=1703646349; darn=debbugs.gnu.org; h=content-transfer-encoding:in-reply-to:references:subject:cc:to :mime-version:user-agent:reply-to:from:date:message-id:from:to:cc :subject:date:message-id:reply-to; bh=+YzUVeuILhwruQ+/Y43DXqjDtbKBjASN0H8UHA10Ve4=; b=G8tAFePoRzuymajpqAJMUsu/Ihi/qmTH9+w9VedIFFl/pp4Kin1dirKTlIeJKRcJxz +1YCd69capkmqBZuwPJtKA90LpMRfku0moLrK3PyEsggR6DZvL+RL/+aEXgkcQlEo3Nn BT268HOgGzNhioaII9kz6SkeM6A7lNlNjQzpHBPJztmnpk28IL6GZx4JAZCOKa+4mAls 11SMU0EatfMfYZpU5VrbtbAteomZt9tKPdF4aPSc/AGlpqjlzn8KF7KNmo1GVFUarivY 0Bd0pSsmj7e2XuKX65Ai2REySvAE0VBp42i9KO2NxkIRdb0Pse1e/ctpjmWGwdTd3F9F dWtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703041549; x=1703646349; h=content-transfer-encoding:in-reply-to:references:subject:cc:to :mime-version:user-agent:reply-to:from:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+YzUVeuILhwruQ+/Y43DXqjDtbKBjASN0H8UHA10Ve4=; b=oIiU7JIdmfs2d/7qaFOd39q4hzfFOQQxXHAMNg4j3yQymISW0VvSamlSTUBPd7VHE/ M+LFJQUCaryJrFVO9W7kwArsnrCBl7LrIrRkA+Pf3EVgg/I/XXg0GWy7sVgwhLF65dEy nEl/I7gMD7JOdKklXkQKLAXwTO6FAEi7Xuejd7GGdgeD07tqyxhIzGoB4vWKkedcoCNt +kyLlZ53jo7L7QyuKVw0tpohmRCdg+UEsaVYyPJoWER0+1wUhABII0IBeFBahpRg35jl 7n49Amk15+oTKBm1IT/NICohP5foFXugsrp4RBh5p+rBIxE0BlUpAeIA5KkDM6dfIyO4 dHag== X-Gm-Message-State: AOJu0YyH52E0kNNmIkFcSQ6mA6qQweCnsu2PA0fMJraJNW/J2jqeObL8 SD0znG4+UWMhSzmx58zADN8= X-Google-Smtp-Source: AGHT+IHv15jz1SOxjsA5044rxuplUacIiYe2jE18lo4yCuqbriEanJxdbJFjlO56BkDwHqRotNhFXA== X-Received: by 2002:a05:6808:1810:b0:3b9:d75e:8f56 with SMTP id bh16-20020a056808181000b003b9d75e8f56mr24052673oib.4.1703041549212; Tue, 19 Dec 2023 19:05:49 -0800 (PST) Received: from [127.0.0.1] ([70.133.144.43]) by smtp.gmail.com with ESMTPSA id ca21-20020a056808331500b003b6caf2accfsm59231oib.22.2023.12.19.19.05.48 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 19 Dec 2023 19:05:48 -0800 (PST) Message-ID: <65825A0A.8050904@gmail.com> Date: Tue, 19 Dec 2023 21:05:46 -0600 From: Jacob Bachmeyer User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.22) Gecko/20090807 MultiZilla/1.8.3.4e SeaMonkey/1.1.17 Mnenhy/0.7.6.0 MIME-Version: 1.0 To: Karl Berry Subject: Re: [bug#67841] [PATCH] Clarify error messages for misuse of m4_warn and --help for -W. References: <202312192249.3BJMnmV8024699@freefriends.org> In-Reply-To: <202312192249.3BJMnmV8024699@freefriends.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -0.2 (/) X-Debbugs-Envelope-To: 67841 Cc: zack@owlfolio.org, 67841@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: jcb62281@gmail.com Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.2 (-) Karl Berry wrote: > "All possible characters have a UTF-8 representation so this function > [encode_utf8] cannot fail." > > What about non-characters, i.e., byte sequences that are invalid UTF-8? > Each individual byte gets encoded as UTF-8. 0x00..0x7F are an identity map, while 0x80..0xFF are translated to 2-octet sequences. /Decoding/ UTF-8 can blow up or produce bogus results (I think Perl might just drop in the "substitute" character and emit a warning) but /encoding/ UTF-8 always works, even on UTF-8. Remember that Perl could handle arbitrary binary data long before it had Unicode support. > What I found was that using \N{...} implies a Unicode string. From the > charnames(3) man page (stranged not named "perlcharnames"): > > Otherwise, any string that includes a "\N{charname}" or "\N{U+code > point}" will automatically have Unicode rules (see "Byte and > Character Semantics" in perlunicode). > That page is named "charnames" because it documents the "charnames" pragmatic module. The man page version was translated from the perldoc system when perl was built/installed/packaged. The "perlunicode" page documents general Unicode support in Perl. > Maybe pack("C") somehow can get to the bytes from a Unicode string? > All strings in Perl are Unicode now, internally stored as UTF-8 or, as an optimization if no codepoints exceed 255, raw octets. (A string of raw octets is considered to be a sequence of characters in the range [0,255].) The "utf8 flag" on a string indicates which of those forms is in use on any particular string. Using encode_utf8 simply gives you the internal encoding, converting an octet string to UTF-8 if needed, marked as an octet string. If the string is already UTF-8, encode_utf8 simply clears the utf8 flag so you get access to the raw bytes. (Brain twisted yet? Mine was when I first looked at this...) Perl's Unicode handling is fun because Perl could always handle binary data, and Unicode support was more-or-less retrofitted on top of that support for binary data. In other words, if your program does not handle Unicode properly (or if you are running on Perl 5.6 and your program does not do the Perl 5.6 magic Unicode dances), Perl will treat "Unicode" data as its underlying octet sequence; thus my earlier advice to conditionally import Encode and shim encode_utf8 with an identity function if Encode is not available. -- Jacob From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 23 13:54:43 2023 Received: (at 67841) by debbugs.gnu.org; 23 Dec 2023 18:54:44 +0000 Received: from localhost ([127.0.0.1]:51228 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rH791-0005e9-Ku for submit@debbugs.gnu.org; Sat, 23 Dec 2023 13:54:43 -0500 Received: from frenzy.freefriends.org ([198.99.81.75]:46950 helo=freefriends.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rH78z-0005dv-L1; Sat, 23 Dec 2023 13:54:42 -0500 X-Envelope-From: karl@freefriends.org Received: from freefriends.org (localhost [127.0.0.1]) by freefriends.org (8.14.7/8.14.7) with ESMTP id 3BNIsZ7T004100 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 23 Dec 2023 11:54:35 -0700 Received: (from apache@localhost) by freefriends.org (8.14.7/8.14.7/Submit) id 3BNIsZPn004099; Sat, 23 Dec 2023 11:54:35 -0700 Date: Sat, 23 Dec 2023 11:54:35 -0700 Message-Id: <202312231854.3BNIsZPn004099@freefriends.org> From: Karl Berry To: 67841@debbugs.gnu.org Subject: Re: [PATCH] Clarify error messages for misuse of m4_warn and --help for -W. X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 67841 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) This was changed in https://debbugs.gnu.org/cgi/bugreport.cgi?bug=67971 and autoconf-2.72 has been released, so closing. Without Jacob's suggested use of encode(), I see (Jacob, thanks for the explanations), but Zack, I'm not sure you intended this bug to track that. Feel free to reopen if so. Thanks, Karl From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 23 14:25:36 2023 Received: (at 67841) by debbugs.gnu.org; 23 Dec 2023 19:25:36 +0000 Received: from localhost ([127.0.0.1]:51242 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rH7ct-0003B7-Nv for submit@debbugs.gnu.org; Sat, 23 Dec 2023 14:25:35 -0500 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:41595) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rH7cr-0003At-GT for 67841@debbugs.gnu.org; Sat, 23 Dec 2023 14:25:34 -0500 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 731495C00C8; Sat, 23 Dec 2023 14:25:22 -0500 (EST) Received: from imap45 ([10.202.2.95]) by compute5.internal (MEProxy); Sat, 23 Dec 2023 14:25:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=owlfolio.org; h= cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1703359522; x=1703445922; bh=HndNI5kIlT 36ewG4CZ77tsSnz7PoTwXq/WuOMyGcgOw=; b=Hg0f5Qqx/1sqLl3h0PMb4dyRi/ +cL1xvQg6TdhwhdSeYHIGMk1r31fVB+C7CsZIz8kcloWMIXF80XZ83HPMRIgpPQu Qj/ZQLptilKvaMIZ1kbUjAuQEmZjrEfe7dpiPyol4uC8x2Z8dUT/szBvvQJW0yMe 8oN2gRMEjiXL8lBVAn0X80Xuif0ncmXikK2u9dmr9pNDBn4wPK+b1f/Bl9KUI+2N VLE7j3lnSqqLYEt8F/jVYMZQsrSFII6ZdwrxpGS8GOyBngN+PWD36Smzsa3vgcrt BAmSAIWomLfpb7pcrpXSPjxDo54nWsM1sXONZ3qjUk7ZWmcAvcFsTJ7V5xOg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1703359522; x=1703445922; bh=HndNI5kIlT36ewG4CZ77tsSnz7Po TwXq/WuOMyGcgOw=; b=DZpPmZxmm5uTtf20tBnBjCOH65pObHnYrEvhV5/U9Nq0 gdAOoQGt7UNgf6n2/4whdMSpDaw1cwIyNCak5C2egl12ptX9TsuwIB0izZ8efw22 mNCddd9GH1PlNVzc/5oDdZ9OkjuXSECAy7I5GKOLxudkSlx47dPg+bvwtTvk4hzz O0GKj537U2OcBhm/2e5bta/cnXk7HYjY71Il7igmR76X9+/yifpJm/rjDGxszYxV 3oa5CIxkWAlgS9KvUuxrlvD4wicZUECWm+OIPwAXgsR/8rl0MgshRJNe6d8WFknJ JKPkWEw34u9HyYOb1wJHj8NAkHDDovDsIrItsplDeg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdduledguddviecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfkggr tghkucghvghinhgsvghrghdfuceoiigrtghksehofihlfhholhhiohdrohhrgheqnecugg ftrfgrthhtvghrnhephfeuhfevueffteffgfejtefgkeekheeftdeflefgheffffevheek leefgfehffdunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homhepiigrtghksehofihlfhholhhiohdrohhrgh X-ME-Proxy: Feedback-ID: i876146a2:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id F03AD272007C; Sat, 23 Dec 2023 14:25:21 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-1364-ga51d5fd3b7-fm-20231219.001-ga51d5fd3 MIME-Version: 1.0 Message-Id: <851ad418-3fe7-4ce6-9366-1a09e5ca1010@app.fastmail.com> In-Reply-To: <202312231854.3BNIsZPn004099@freefriends.org> References: <20231215204435.1888127-1-zack@owlfolio.org> <202312231854.3BNIsZPn004099@freefriends.org> Date: Sat, 23 Dec 2023 14:25:01 -0500 From: "Zack Weinberg" To: "Karl Berry" , 67841@debbugs.gnu.org Subject: Re: [bug#67841] [PATCH] Clarify error messages for misuse of m4_warn and --help for -W. Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 67841 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) On Sat, Dec 23, 2023, at 1:54 PM, > Without Jacob's suggested use of encode(), I see (Jacob, thanks for the > explanations), but Zack, I'm not sure you intended this bug to track > that. Feel free to reopen if so. I decided I didn't want to write that code and verify it in a hurry. I'll come back to it next year. This bug was just to make sure automake and autoconf were back in sync on all the shared files. From unknown Sat Jun 21 03:01:06 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 21 Jan 2024 12:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator