texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: Warning for \, in macro arg


From: Gavin D. Smith
Subject: branch master updated: Warning for \, in macro arg
Date: Sun, 05 Mar 2023 09:27:13 -0500

This is an automated email from the git hooks/post-receive script.

gavin pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new 98060b5758 Warning for \, in macro arg
98060b5758 is described below

commit 98060b57587d575d90ac550899560e05eaa84817
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Sun Mar 5 14:27:05 2023 +0000

    Warning for \, in macro arg
    
    * tp/Texinfo/ParserNonXS.pm (_expand_macro_arguments),
    * tp/Texinfo/XS/parsetexi/macro.c (expand_macro_arguments):
    Issue a warning if \, is used in a macro argument, recommending
    @comma{} instead.
    
    \, doesn't work with texinfo.tex so it is better to warn about it.
---
 ChangeLog                              | 11 +++++++++++
 tp/Texinfo/ParserNonXS.pm              |  5 +++++
 tp/Texinfo/XS/parsetexi/macro.c        |  5 ++++-
 tp/t/results/macro/complex_argument.pl |  9 +++++++++
 tp/t/results/macro/glossary.pl         |  9 +++++++++
 tp/t/results/macro/macro_expansion.pl  |  9 +++++++++
 6 files changed, 47 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 246113a0e1..b296f60563 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2023-03-05  Gavin Smith <gavinsmith0123@gmail.com>
+
+       Warning for \, in macro arg
+
+       * tp/Texinfo/ParserNonXS.pm (_expand_macro_arguments),
+       * tp/Texinfo/XS/parsetexi/macro.c (expand_macro_arguments):
+       Issue a warning if \, is used in a macro argument, recommending
+       @comma{} instead.
+
+       \, doesn't work with texinfo.tex so it is better to warn about it.
+
 2023-03-05  Gavin Smith <gavinsmith0123@gmail.com>
 
        * tp/Texinfo/ParserNonXS.pm (_handle_line_command) <def commands>
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index d8a7011d9d..fd67f3b748 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -2513,6 +2513,11 @@ sub _expand_macro_arguments($$$$$)
             $argument_content->{'text'} .= '\\';
           }
           $argument_content->{'text'} .= $protected_char;
+          if ($protected_char eq ',') {
+            $self->_line_warn(sprintf(
+                __("use %s instead of %s in macro arg"), '@comma{}', '\\,'),
+              $source_info);
+          }
           print STDERR "MACRO ARG: $separator: $protected_char\n"
             if ($self->{'DEBUG'});
         } else {
diff --git a/tp/Texinfo/XS/parsetexi/macro.c b/tp/Texinfo/XS/parsetexi/macro.c
index 438406ede5..17067237d9 100644
--- a/tp/Texinfo/XS/parsetexi/macro.c
+++ b/tp/Texinfo/XS/parsetexi/macro.c
@@ -1,4 +1,4 @@
-/* Copyright 2010-2022 Free Software Foundation, Inc.
+/* Copyright 2010-2023 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -335,6 +335,9 @@ expand_macro_arguments (ELEMENT *macro, char **line_inout, 
enum command_id cmd,
             {
               text_append_n (arg, &sep[1], 1);
               pline = sep + 2;
+              if (sep[1] == ',')
+                line_warn ("use %s instead of %s in macro arg",
+                           "@comma{}", "\\,");
             }
           else
             pline = sep + 1;
diff --git a/tp/t/results/macro/complex_argument.pl 
b/tp/t/results/macro/complex_argument.pl
index d7bb1bb9f4..9c968f13fc 100644
--- a/tp/t/results/macro/complex_argument.pl
+++ b/tp/t/results/macro/complex_argument.pl
@@ -979,6 +979,15 @@ aaa
 ';
 
 $result_errors{'complex_argument'} = [
+  {
+    'error_line' => 'warning: use @comma{} instead of \\, in macro arg
+',
+    'file_name' => '',
+    'line_nr' => 35,
+    'macro' => '',
+    'text' => 'use @comma{} instead of \\, in macro arg',
+    'type' => 'warning'
+  },
   {
     'error_line' => 'bad argument to @headings: doubleafter 1 (possibly 
involving @macrofour)
 ',
diff --git a/tp/t/results/macro/glossary.pl b/tp/t/results/macro/glossary.pl
index 5296557528..e68b319f02 100644
--- a/tp/t/results/macro/glossary.pl
+++ b/tp/t/results/macro/glossary.pl
@@ -1820,6 +1820,15 @@ $result_menus{'glossary'} = {
 $result_menus{'glossary'}{'structure'}{'menu_child'}{'structure'}{'menu_up'} = 
$result_menus{'glossary'};
 
 $result_errors{'glossary'} = [
+  {
+    'error_line' => 'warning: use @comma{} instead of \\, in macro arg
+',
+    'file_name' => 'glossary.texi',
+    'line_nr' => 42,
+    'macro' => '',
+    'text' => 'use @comma{} instead of \\, in macro arg',
+    'type' => 'warning'
+  },
   {
     'error_line' => 'warning: @ifhtml should only appear at the beginning of a 
line (possibly involving @gentry)
 ',
diff --git a/tp/t/results/macro/macro_expansion.pl 
b/tp/t/results/macro/macro_expansion.pl
index c74ad00d2b..1e5d1e488b 100644
--- a/tp/t/results/macro/macro_expansion.pl
+++ b/tp/t/results/macro/macro_expansion.pl
@@ -924,6 +924,15 @@ $result_errors{'macro_expansion'} = [
     'text' => 'bad argument to @end: verbatim.',
     'type' => 'error'
   },
+  {
+    'error_line' => 'warning: use @comma{} instead of \\, in macro arg
+',
+    'file_name' => '',
+    'line_nr' => 17,
+    'macro' => '',
+    'text' => 'use @comma{} instead of \\, in macro arg',
+    'type' => 'warning'
+  },
   {
     'error_line' => 'bad argument to @end: verbatim. (possibly involving 
@macroone)
 ',



reply via email to

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