texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: Warn if @-commands other than accent, glyphs and


From: Patrice Dumas
Subject: branch master updated: Warn if @-commands other than accent, glyphs and symbols appear in @w
Date: Sun, 02 Oct 2022 08:44:32 -0400

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

pertusus pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new 3982dafb8f Warn if @-commands other than accent, glyphs and symbols 
appear in @w
3982dafb8f is described below

commit 3982dafb8f1410e73bda916f59aa0b2c993b74aa
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Oct 2 14:44:10 2022 +0200

    Warn if @-commands other than accent, glyphs and symbols appear in @w
    
    * tp/Texinfo/Common.pm (%contain_plain_text_commands),
    tp/Texinfo/XS/parsetexi/command_data.txt, NEWS: add w to contain_plain_text.
    
    * tp/Texinfo/Common.pm (%variadic_commands),
    tp/Texinfo/ParserNonXS.pm: use the %variadic_commands hash for
    variadic commands instead of setting %commands_args_number to
    variadic.
---
 ChangeLog                                          |  12 +++
 NEWS                                               |   1 +
 tp/Texinfo/Common.pm                               |  43 +++++----
 tp/Texinfo/ParserNonXS.pm                          |  15 ++-
 tp/Texinfo/XS/parsetexi/command_data.txt           |   2 +-
 tp/t/results/coverage_braces/test_w.pl             |  12 ++-
 .../formats_encodings/at_commands_in_refs.pl       |  36 ++++++++
 .../at_commands_in_refs_latin1.pl                  |  36 ++++++++
 .../formats_encodings/at_commands_in_refs_utf8.pl  |  36 ++++++++
 tp/t/results/indices/w_lines_count.pl              |  12 ++-
 tp/t/results/misc_commands/test_allowcodebreaks.pl | 102 ++++++++++++++++++++-
 11 files changed, 277 insertions(+), 30 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 00832a93da..fd4bc727e8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2022-10-02  Patrice Dumas  <pertusus@free.fr>
+
+       Warn if @-commands other than accent, glyphs and symbols appear in @w
+
+       * tp/Texinfo/Common.pm (%contain_plain_text_commands),
+       tp/Texinfo/XS/parsetexi/command_data.txt, NEWS: add w to 
contain_plain_text.
+
+       * tp/Texinfo/Common.pm (%variadic_commands),
+       tp/Texinfo/ParserNonXS.pm: use the %variadic_commands hash for
+       variadic commands instead of setting %commands_args_number to
+       variadic.
+
 2022-10-02  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/Common.pm (%contain_plain_text_commands),
diff --git a/NEWS b/NEWS
index 464505d8d1..8f61ad116a 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,7 @@ See the manual for detailed information.
 * texi2any
  . LaTeX added as an output format, selected with --latex
  . EPUB 3 added as an output format, selected with --epub3
+ . Warn if @-commands other than accent, glyphs and symbols appear in @w
  . reform throughout the code in general
  . thorough review of character encoding issues
  . new customization variables involved with character encoding:
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index 115ea72d49..181465332f 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -746,24 +746,17 @@ foreach my $command ('code', 'command', 'env', 'file', 
'indicateurl', 'kbd',
   $brace_commands{$command} = 'style_code';
 }
 
-# FIXME Some commands can contain @-commands, but not all, for example no @ref,
-# no @footnote: 'anchor', 'indicateurl', 'errormsg', 'seeentry', 'seealso'.
-# 'titlefont' may be less constrained.
-
 # in this category, the leading and trailing spaces are put in specific
-# text with type, but commas do not delimitate arguments
+# text with type, but commas do not delimitate arguments.
+# As other arguments brace_commands, they can only contain simple text,
+# ie not ref, footnote, titlefont, anchor, verb.
+# Parsers have specific checks for U content.
 foreach my $one_arg_command ('U', 'hyphenation',
     'anchor', 'errormsg', 'sortas', 'seeentry', 'seealso') {
   $brace_commands{$one_arg_command} = 'arguments';
   $commands_args_number{$one_arg_command} = 1;
 }
 
-# only accept plain text, ie only accent, symbol and glyph commands
-our %contain_plain_text_commands;
-foreach my $command ('dmn', 'key', 'hyphenation', 'sortas') {
-  $contain_plain_text_commands{$command} = 1;
-}
-
 # Leading and trailing spaces kept in main text.
 # verb is treated especially, it should not matter much in which category it 
is.
 # value also is treated especially.
@@ -771,11 +764,17 @@ foreach my $special_arg_command ('w', 'verb', 'value') {
   $brace_commands{$special_arg_command} = 'special';
 }
 
-# Leading and trailing spaces kept in main text, nothing special.
+# Leading and trailing spaces kept in main text.
 foreach my $other_arg_command ('titlefont', 'dmn') {
   $brace_commands{$other_arg_command} = 'other';
 }
 
+# only accept plain text, ie only accent, symbol and glyph commands
+our %contain_plain_text_commands;
+foreach my $command ('dmn', 'hyphenation', 'key', 'sortas', 'w') {
+  $contain_plain_text_commands{$command} = 1;
+}
+
 # brace style command that are not style commands
 $brace_code_commands{'verb'} = 1;
 
@@ -952,7 +951,11 @@ foreach my $preformatted_command(
   $preformatted_commands{$preformatted_command} = 1;
   $preformatted_code_commands{$preformatted_command} = 1;
 }
-$commands_args_number{'example'} = 'variadic'; # unlimited arguments
+
+# unlimited arguments
+our %variadic_commands = (
+  'example' => 1,
+);
 
 foreach my $preformatted_command(
     'display', 'smalldisplay', 'format', 'smallformat') {
@@ -1035,7 +1038,6 @@ foreach my $close_paragraph_command (keys(%def_commands)) 
{
   $close_paragraph_commands{$close_paragraph_command} = 1;
 }
 
-
 our %deprecated_commands = (
   'definfoenclose' => '',
   'refill' => '',
@@ -3042,10 +3044,10 @@ Other values for other block line commands.
 X<C<%commands_args_number>>
 
 Set to the number of arguments separated by commas that may appear in braces or
-on the @-command line, or to I<variadic> if there is an unlimited number of
-arguments.  That means 0 or unset in most block command cases, 1 for
-C<@quotation>, 2 for C<@float> and C<variadic> for C<@example>, 1 for most
-brace commands, 2 for C<@email> or C<@abbr>, 5 for C<@image> of C<@ref>.
+on the @-command line.  That means 0 or unset in most block command cases,
+including C<@example> which has an unlimited (variadic) number of arguments, 1
+for C<@quotation>, 2 for C<@float>, 1 for most brace commands, 2 for C<@email>
+or C<@abbr>, 5 for C<@image> of C<@ref>.
 
 Values are not necessarily set for all the commands, as commands are
 also classified by type of command, some type of commands implying a
@@ -3193,6 +3195,11 @@ X<C<%small_block_associated_command>>
 Associate small command like C<smallexample> to the regular command
 C<example>.
 
+=item %variadic_commands
+X<C<%variadic_commands>>
+
+Commands with unlimited arguments, like C<@example>.
+
 =back
 
 =head1 METHODS
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 683dccec28..28689e056a 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -288,6 +288,7 @@ my %in_heading_spec_commands  = 
%Texinfo::Common::in_heading_spec_commands;
 my %in_index_commands         = %Texinfo::Common::in_index_commands;
 my %explained_commands        = %Texinfo::Common::explained_commands;
 my %inline_format_commands    = %Texinfo::Common::inline_format_commands;
+my %variadic_commands         = %Texinfo::Common::variadic_commands;
 my %all_commands              = %Texinfo::Common::all_commands;
 
 # equivalence between a @set flag and an @@-command
@@ -5012,7 +5013,7 @@ sub _process_remaining_on_line($$$$)
           if ($line =~ 
/^\s+([[:alnum:]][[:alnum:]\-]*)\s*(\@(c|comment)((\@|\s+).*)?)?$/) {
             my $name = $1;
             my $command_is_defined = (
-              exists($Texinfo::Common::all_commands{$name})
+              exists($all_commands{$name})
               or $self->{'macros'}->{$name}
               or $self->{'definfoenclose'}->{$name}
               or $self->{'aliases'}->{$name}
@@ -5160,14 +5161,12 @@ sub _process_remaining_on_line($$$$)
            'parent' => $current } ];
 
         if ($commands_args_number{$command}) {
-          if ($commands_args_number{$command} =~ /^\d+$/) {
-            if ($commands_args_number{$command} - 1 > 0) {
-              $current->{'remaining_args'}
-                = $commands_args_number{$command} - 1;
-            }
-          } elsif ($commands_args_number{$command} eq 'variadic') {
-            $current->{'remaining_args'} = -1; # unlimited args
+          if ($commands_args_number{$command} - 1 > 0) {
+            $current->{'remaining_args'}
+              = $commands_args_number{$command} - 1;
           }
+        } elsif ($variadic_commands{$command}) {
+          $current->{'remaining_args'} = -1; # unlimited args
         }
         $current = $current->{'args'}->[-1];
         $self->_push_context('ct_line', $command)
diff --git a/tp/Texinfo/XS/parsetexi/command_data.txt 
b/tp/Texinfo/XS/parsetexi/command_data.txt
index de3a673677..207528af96 100644
--- a/tp/Texinfo/XS/parsetexi/command_data.txt
+++ b/tp/Texinfo/XS/parsetexi/command_data.txt
@@ -312,7 +312,7 @@ seealso                 brace                           
BRACE_arguments     1
 
 value                   brace                           BRACE_special
 verb                    brace                           BRACE_special
-w                       brace                           BRACE_special
+w                       brace,contain_plain_text        BRACE_special
 
 # other brace commands, leading and trailing spaces not ignored
 dmn                     brace,contain_plain_text        BRACE_other         1
diff --git a/tp/t/results/coverage_braces/test_w.pl 
b/tp/t/results/coverage_braces/test_w.pl
index 452b3ced60..2d3fa80321 100644
--- a/tp/t/results/coverage_braces/test_w.pl
+++ b/tp/t/results/coverage_braces/test_w.pl
@@ -903,7 +903,17 @@ convention should be followed in Texinfo files.  TeX 
converts
 two single quotes to left- and right-hand doubled.
 ';
 
-$result_errors{'test_w'} = [];
+$result_errors{'test_w'} = [
+  {
+    'error_line' => 'warning: @t should not appear in @w
+',
+    'file_name' => '',
+    'line_nr' => 34,
+    'macro' => '',
+    'text' => '@t should not appear in @w',
+    'type' => 'warning'
+  }
+];
 
 
 $result_floats{'test_w'} = {};
diff --git a/tp/t/results/formats_encodings/at_commands_in_refs.pl 
b/tp/t/results/formats_encodings/at_commands_in_refs.pl
index 2302944278..8aa43d4809 100644
--- a/tp/t/results/formats_encodings/at_commands_in_refs.pl
+++ b/tp/t/results/formats_encodings/at_commands_in_refs.pl
@@ -21817,6 +21817,15 @@ 
$result_menus{'at_commands_in_refs'}{'structure'}{'menu_child'}{'structure'}{'me
 
$result_menus{'at_commands_in_refs'}{'structure'}{'menu_child'}{'structure'}{'menu_up'}
 = $result_menus{'at_commands_in_refs'};
 
 $result_errors{'at_commands_in_refs'} = [
+  {
+    'error_line' => 'warning: @b should not appear in @w
+',
+    'file_name' => '',
+    'line_nr' => 25,
+    'macro' => '',
+    'text' => '@b should not appear in @w',
+    'type' => 'warning'
+  },
   {
     'error_line' => 'warning: @verb should not appear in @node
 ',
@@ -21835,6 +21844,24 @@ $result_errors{'at_commands_in_refs'} = [
     'text' => '@verb should not appear in @chapter',
     'type' => 'warning'
   },
+  {
+    'error_line' => 'warning: @b should not appear in @w
+',
+    'file_name' => '',
+    'line_nr' => 100,
+    'macro' => '',
+    'text' => '@b should not appear in @w',
+    'type' => 'warning'
+  },
+  {
+    'error_line' => 'warning: @b should not appear in @w
+',
+    'file_name' => '',
+    'line_nr' => 101,
+    'macro' => '',
+    'text' => '@b should not appear in @w',
+    'type' => 'warning'
+  },
   {
     'error_line' => 'warning: @verb should not appear in @ref
 ',
@@ -21843,6 +21870,15 @@ $result_errors{'at_commands_in_refs'} = [
     'macro' => '',
     'text' => '@verb should not appear in @ref',
     'type' => 'warning'
+  },
+  {
+    'error_line' => 'warning: @b should not appear in @w
+',
+    'file_name' => '',
+    'line_nr' => 165,
+    'macro' => '',
+    'text' => '@b should not appear in @w',
+    'type' => 'warning'
   }
 ];
 
diff --git a/tp/t/results/formats_encodings/at_commands_in_refs_latin1.pl 
b/tp/t/results/formats_encodings/at_commands_in_refs_latin1.pl
index 7db93e661d..0bea63b210 100644
--- a/tp/t/results/formats_encodings/at_commands_in_refs_latin1.pl
+++ b/tp/t/results/formats_encodings/at_commands_in_refs_latin1.pl
@@ -21895,6 +21895,15 @@ 
$result_menus{'at_commands_in_refs_latin1'}{'structure'}{'menu_child'}{'structur
 
$result_menus{'at_commands_in_refs_latin1'}{'structure'}{'menu_child'}{'structure'}{'menu_up'}
 = $result_menus{'at_commands_in_refs_latin1'};
 
 $result_errors{'at_commands_in_refs_latin1'} = [
+  {
+    'error_line' => 'warning: @b should not appear in @w
+',
+    'file_name' => '',
+    'line_nr' => 28,
+    'macro' => '',
+    'text' => '@b should not appear in @w',
+    'type' => 'warning'
+  },
   {
     'error_line' => 'warning: @verb should not appear in @node
 ',
@@ -21913,6 +21922,24 @@ $result_errors{'at_commands_in_refs_latin1'} = [
     'text' => '@verb should not appear in @chapter',
     'type' => 'warning'
   },
+  {
+    'error_line' => 'warning: @b should not appear in @w
+',
+    'file_name' => '',
+    'line_nr' => 103,
+    'macro' => '',
+    'text' => '@b should not appear in @w',
+    'type' => 'warning'
+  },
+  {
+    'error_line' => 'warning: @b should not appear in @w
+',
+    'file_name' => '',
+    'line_nr' => 104,
+    'macro' => '',
+    'text' => '@b should not appear in @w',
+    'type' => 'warning'
+  },
   {
     'error_line' => 'warning: @verb should not appear in @ref
 ',
@@ -21921,6 +21948,15 @@ $result_errors{'at_commands_in_refs_latin1'} = [
     'macro' => '',
     'text' => '@verb should not appear in @ref',
     'type' => 'warning'
+  },
+  {
+    'error_line' => 'warning: @b should not appear in @w
+',
+    'file_name' => '',
+    'line_nr' => 168,
+    'macro' => '',
+    'text' => '@b should not appear in @w',
+    'type' => 'warning'
   }
 ];
 
diff --git a/tp/t/results/formats_encodings/at_commands_in_refs_utf8.pl 
b/tp/t/results/formats_encodings/at_commands_in_refs_utf8.pl
index e035977d8c..a87358033d 100644
--- a/tp/t/results/formats_encodings/at_commands_in_refs_utf8.pl
+++ b/tp/t/results/formats_encodings/at_commands_in_refs_utf8.pl
@@ -21895,6 +21895,15 @@ 
$result_menus{'at_commands_in_refs_utf8'}{'structure'}{'menu_child'}{'structure'
 
$result_menus{'at_commands_in_refs_utf8'}{'structure'}{'menu_child'}{'structure'}{'menu_up'}
 = $result_menus{'at_commands_in_refs_utf8'};
 
 $result_errors{'at_commands_in_refs_utf8'} = [
+  {
+    'error_line' => 'warning: @b should not appear in @w
+',
+    'file_name' => '',
+    'line_nr' => 28,
+    'macro' => '',
+    'text' => '@b should not appear in @w',
+    'type' => 'warning'
+  },
   {
     'error_line' => 'warning: @verb should not appear in @node
 ',
@@ -21913,6 +21922,24 @@ $result_errors{'at_commands_in_refs_utf8'} = [
     'text' => '@verb should not appear in @chapter',
     'type' => 'warning'
   },
+  {
+    'error_line' => 'warning: @b should not appear in @w
+',
+    'file_name' => '',
+    'line_nr' => 103,
+    'macro' => '',
+    'text' => '@b should not appear in @w',
+    'type' => 'warning'
+  },
+  {
+    'error_line' => 'warning: @b should not appear in @w
+',
+    'file_name' => '',
+    'line_nr' => 104,
+    'macro' => '',
+    'text' => '@b should not appear in @w',
+    'type' => 'warning'
+  },
   {
     'error_line' => 'warning: @verb should not appear in @ref
 ',
@@ -21921,6 +21948,15 @@ $result_errors{'at_commands_in_refs_utf8'} = [
     'macro' => '',
     'text' => '@verb should not appear in @ref',
     'type' => 'warning'
+  },
+  {
+    'error_line' => 'warning: @b should not appear in @w
+',
+    'file_name' => '',
+    'line_nr' => 168,
+    'macro' => '',
+    'text' => '@b should not appear in @w',
+    'type' => 'warning'
   }
 ];
 
diff --git a/tp/t/results/indices/w_lines_count.pl 
b/tp/t/results/indices/w_lines_count.pl
index facdad5fe7..d5982dcea7 100644
--- a/tp/t/results/indices/w_lines_count.pl
+++ b/tp/t/results/indices/w_lines_count.pl
@@ -392,7 +392,17 @@ $result_menus{'w_lines_count'} = {
   }
 };
 
-$result_errors{'w_lines_count'} = [];
+$result_errors{'w_lines_count'} = [
+  {
+    'error_line' => 'warning: @code should not appear in @w
+',
+    'file_name' => '',
+    'line_nr' => 5,
+    'macro' => '',
+    'text' => '@code should not appear in @w',
+    'type' => 'warning'
+  }
+];
 
 
 $result_floats{'w_lines_count'} = {};
diff --git a/tp/t/results/misc_commands/test_allowcodebreaks.pl 
b/tp/t/results/misc_commands/test_allowcodebreaks.pl
index e3767bc9af..b0b3d892ee 100644
--- a/tp/t/results/misc_commands/test_allowcodebreaks.pl
+++ b/tp/t/results/misc_commands/test_allowcodebreaks.pl
@@ -2659,7 +2659,107 @@ $result_menus{'test_allowcodebreaks'} = {
   }
 };
 
-$result_errors{'test_allowcodebreaks'} = [];
+$result_errors{'test_allowcodebreaks'} = [
+  {
+    'error_line' => 'warning: @code should not appear in @w (possibly 
involving @testallowcodebreakspara)
+',
+    'file_name' => '',
+    'line_nr' => 29,
+    'macro' => 'testallowcodebreakspara',
+    'text' => '@code should not appear in @w',
+    'type' => 'warning'
+  },
+  {
+    'error_line' => 'warning: @code should not appear in @w (possibly 
involving @testallowcodebreakspara)
+',
+    'file_name' => '',
+    'line_nr' => 29,
+    'macro' => 'testallowcodebreakspara',
+    'text' => '@code should not appear in @w',
+    'type' => 'warning'
+  },
+  {
+    'error_line' => 'warning: @code should not appear in @w (possibly 
involving @testallowcodebreakspara)
+',
+    'file_name' => '',
+    'line_nr' => 29,
+    'macro' => 'testallowcodebreakspara',
+    'text' => '@code should not appear in @w',
+    'type' => 'warning'
+  },
+  {
+    'error_line' => 'warning: @code should not appear in @w (possibly 
involving @testallowcodebreakspara)
+',
+    'file_name' => '',
+    'line_nr' => 29,
+    'macro' => 'testallowcodebreakspara',
+    'text' => '@code should not appear in @w',
+    'type' => 'warning'
+  },
+  {
+    'error_line' => 'warning: @code should not appear in @w (possibly 
involving @testallowcodebreakspara)
+',
+    'file_name' => '',
+    'line_nr' => 29,
+    'macro' => 'testallowcodebreakspara',
+    'text' => '@code should not appear in @w',
+    'type' => 'warning'
+  },
+  {
+    'error_line' => 'warning: @code should not appear in @w (possibly 
involving @testallowcodebreakspara)
+',
+    'file_name' => '',
+    'line_nr' => 29,
+    'macro' => 'testallowcodebreakspara',
+    'text' => '@code should not appear in @w',
+    'type' => 'warning'
+  },
+  {
+    'error_line' => 'warning: @code should not appear in @w (possibly 
involving @testallowcodebreakspara)
+',
+    'file_name' => '',
+    'line_nr' => 29,
+    'macro' => 'testallowcodebreakspara',
+    'text' => '@code should not appear in @w',
+    'type' => 'warning'
+  },
+  {
+    'error_line' => 'warning: @code should not appear in @w (possibly 
involving @testallowcodebreakspara)
+',
+    'file_name' => '',
+    'line_nr' => 29,
+    'macro' => 'testallowcodebreakspara',
+    'text' => '@code should not appear in @w',
+    'type' => 'warning'
+  },
+  {
+    'error_line' => 'warning: @code should not appear in @w (possibly 
involving @testallowcodebreakspara)
+',
+    'file_name' => '',
+    'line_nr' => 29,
+    'macro' => 'testallowcodebreakspara',
+    'text' => '@code should not appear in @w',
+    'type' => 'warning'
+  },
+  {
+    'error_line' => 'warning: @samp should not appear in @w (possibly 
involving @testallowcodebreakspara)
+',
+    'file_name' => '',
+    'line_nr' => 29,
+    'macro' => 'testallowcodebreakspara',
+    'text' => '@samp should not appear in @w',
+    'type' => 'warning'
+  },
+  {
+    'error_line' => 'warning: @code should not appear in @w
+',
+    'file_name' => '',
+    'line_nr' => 33,
+    'macro' => '',
+    'text' => '@code should not appear in @w',
+    'type' => 'warning'
+  }
+];
 
 
 $result_floats{'test_allowcodebreaks'} = {};



reply via email to

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