texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Fri, 26 Apr 2024 18:11:19 -0400 (EDT)

branch: master
commit 3fe5a8953e8dd01a13419bd48a5795e067dde0a4
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Apr 21 22:58:04 2024 +0200

    * tp/Texinfo/ParserNonXS.pm (%in_plain_text_commands),
    tp/Texinfo/XS/parsetexi/parser.c (check_valid_nesting): remove @| from
    commands valid in plain text, by adding a check on
    %in_heading_spec_commands.
    
    * tp/Texinfo/ParserNonXS.pm (%in_full_text_commands)
    (%in_basic_inline_commands): do not put in_heading_spec_commands in
    %in_full_text_commands, only in %in_basic_inline_commands such that
    they can only appear in selecter @-commands (style brace @-commands).
    
    * tp/Texinfo/XS/parsetexi/parser.c (check_valid_nesting): remove an
    impossible check of outer_flags & CF_heading_spec for a brace command.
    
    * tp/Makefile.tres, tp/t/02coverage.t (heading_commands_in_center)
    (heading_commands_in_documentlanguage): add tests of heading commands
    in non heading nor footing line command and in contain_plain_text
    command.
---
 ChangeLog                                          |  20 +++
 tp/Makefile.tres                                   |   2 +
 tp/Texinfo/ParserNonXS.pm                          |  10 +-
 tp/Texinfo/XS/parsetexi/parser.c                   |  12 +-
 tp/t/02coverage.t                                  |   6 +
 .../results/coverage/heading_commands_in_center.pl | 146 +++++++++++++++++++
 .../heading_commands_in_documentlanguage.pl        | 162 +++++++++++++++++++++
 7 files changed, 349 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 9a2fd07526..19fc889553 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2024-04-21  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/ParserNonXS.pm (%in_plain_text_commands),
+       tp/Texinfo/XS/parsetexi/parser.c (check_valid_nesting): remove @| from
+       commands valid in plain text, by adding a check on
+       %in_heading_spec_commands.
+
+       * tp/Texinfo/ParserNonXS.pm (%in_full_text_commands)
+       (%in_basic_inline_commands): do not put in_heading_spec_commands in
+       %in_full_text_commands, only in %in_basic_inline_commands such that
+       they can only appear in selecter @-commands (style brace @-commands).
+
+       * tp/Texinfo/XS/parsetexi/parser.c (check_valid_nesting): remove an
+       impossible check of outer_flags & CF_heading_spec for a brace command.
+
+       * tp/Makefile.tres, tp/t/02coverage.t (heading_commands_in_center)
+       (heading_commands_in_documentlanguage): add tests of heading commands
+       in non heading nor footing line command and in contain_plain_text
+       command.
+
 2024-04-20  Patrice Dumas  <pertusus@free.fr>
 
        * Pod-Simple-Texinfo/README: explain how test_scripts/*.sh can be
diff --git a/tp/Makefile.tres b/tp/Makefile.tres
index 755b4ed4cf..fd3338dc3d 100644
--- a/tp/Makefile.tres
+++ b/tp/Makefile.tres
@@ -330,6 +330,8 @@ test_files_generated_list = 
$(test_tap_files_generated_list) \
   t/results/coverage/formats_titles.pl \
   t/results/coverage/group_beginning_and_end_on_line.pl \
   t/results/coverage/group_not_closed.pl \
+  t/results/coverage/heading_commands_in_center.pl \
+  t/results/coverage/heading_commands_in_documentlanguage.pl \
   t/results/coverage/hyphenation.pl \
   t/results/coverage/indentedblock.pl \
   t/results/coverage/indicateurl_end_lines.pl \
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 67e7fee0d1..b8bf781009 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -420,7 +420,8 @@ foreach my $brace_command(keys(%brace_commands)) {
 }
 my %symbol_nobrace_commands;
 foreach my $no_brace_command (keys(%nobrace_commands)) {
-  if ($nobrace_commands{$no_brace_command} eq 'symbol') {
+  if ($nobrace_commands{$no_brace_command} eq 'symbol'
+      and !$in_heading_spec_commands{$no_brace_command}) {
     $symbol_nobrace_commands{$no_brace_command} = 1;
     $in_plain_text_commands{$no_brace_command} = 1;
   }
@@ -437,8 +438,7 @@ foreach my $command (keys(%brace_commands), 
keys(%symbol_nobrace_commands)) {
 }
 # selected line commands
 foreach my $in_full_text_command ('c', 'comment', 'refill', 'subentry',
-                         'columnfractions', 'set', 'clear', 'end',
-                         keys(%in_heading_spec_commands)) {
+                         'columnfractions', 'set', 'clear', 'end') {
   $in_full_text_commands{$in_full_text_command} = 1;
 }
 # selected block commands
@@ -514,6 +514,10 @@ foreach my $not_in_basic_inline_commands
   delete $in_basic_inline_commands{$not_in_basic_inline_commands};
 }
 
+foreach my $in_heading_spec (keys(%in_heading_spec_commands)) {
+  $in_basic_inline_commands{$in_heading_spec} = 1;
+}
+
 my %contain_basic_inline_with_refs_commands = (%sectioning_heading_commands,
                                       %def_commands);
 my %ok_in_basic_inline_with_refs_commands;
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index dd49f8f27e..62c4b9cb93 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -1192,7 +1192,8 @@ check_valid_nesting (ELEMENT *current, enum command_id 
cmd)
     {
       if ((cmd_flags & CF_accent)
           || (cmd_flags & CF_nobrace
-              && command_data(cmd).data == NOBRACE_symbol))
+              && command_data(cmd).data == NOBRACE_symbol
+              && (!cmd_flags & CF_in_heading_spec)))
         ok = 1;
       else if (cmd_flags & CF_brace
                && command_data(cmd).data == BRACE_noarg)
@@ -1243,11 +1244,10 @@ check_valid_nesting (ELEMENT *current, enum command_id 
cmd)
         { /* in heading commands can only appear in headings and style
              brace commands */
           ok = 0;
-          if (outer_flags & CF_heading_spec
-              || (outer_flags & CF_brace
-                  && (command_data(outer).data == BRACE_style_other
-                      || command_data(outer).data == BRACE_style_code
-                      || command_data(outer).data == BRACE_style_no_code)))
+          if (outer_flags & CF_brace
+              && (command_data(outer).data == BRACE_style_other
+                  || command_data(outer).data == BRACE_style_code
+                  || command_data(outer).data == BRACE_style_no_code))
               ok = 1;
         }
     }
diff --git a/tp/t/02coverage.t b/tp/t/02coverage.t
index ea5cfc48e1..41a19b7e35 100644
--- a/tp/t/02coverage.t
+++ b/tp/t/02coverage.t
@@ -1013,6 +1013,12 @@ undef, {'test_file' => 
'delcomment_followed_by_cpp_line.texi'}
 ['delcomment_on_comment', undef,
 {'test_file' => 'delcomment_on_comment.texi'},
 ],
+['heading_commands_in_center',
+'@center @code{aaa @thischapter} @| a @thissection @| b
+'],
+['heading_commands_in_documentlanguage',
+'@documentlanguage @code{aaa @thischapter} @| @thissection @| b
+'],
 );
 
 my %docbooc_doc_tests = (
diff --git a/tp/t/results/coverage/heading_commands_in_center.pl 
b/tp/t/results/coverage/heading_commands_in_center.pl
new file mode 100644
index 0000000000..b0ebb568db
--- /dev/null
+++ b/tp/t/results/coverage/heading_commands_in_center.pl
@@ -0,0 +1,146 @@
+use vars qw(%result_texis %result_texts %result_trees %result_errors 
+   %result_indices %result_sectioning %result_nodes %result_menus
+   %result_floats %result_converted %result_converted_errors 
+   %result_elements %result_directions_text %result_indices_sort_strings);
+
+use utf8;
+
+$result_trees{'heading_commands_in_center'} = {
+  'contents' => [
+    {
+      'contents' => [
+        {
+          'args' => [
+            {
+              'contents' => [
+                {
+                  'args' => [
+                    {
+                      'contents' => [
+                        {
+                          'text' => 'aaa '
+                        },
+                        {
+                          'cmdname' => 'thischapter'
+                        }
+                      ],
+                      'type' => 'brace_command_arg'
+                    }
+                  ],
+                  'cmdname' => 'code',
+                  'source_info' => {
+                    'line_nr' => 1
+                  }
+                },
+                {
+                  'text' => ' '
+                },
+                {
+                  'cmdname' => '|'
+                },
+                {
+                  'text' => ' a '
+                },
+                {
+                  'cmdname' => 'thissection'
+                },
+                {
+                  'text' => ' '
+                },
+                {
+                  'cmdname' => '|'
+                },
+                {
+                  'text' => ' b'
+                }
+              ],
+              'info' => {
+                'spaces_after_argument' => {
+                  'text' => '
+'
+                }
+              },
+              'type' => 'line_arg'
+            }
+          ],
+          'cmdname' => 'center',
+          'info' => {
+            'spaces_before_argument' => {
+              'text' => ' '
+            }
+          },
+          'source_info' => {
+            'line_nr' => 1
+          }
+        }
+      ],
+      'type' => 'before_node_section'
+    }
+  ],
+  'type' => 'document_root'
+};
+
+$result_texis{'heading_commands_in_center'} = '@center @code{aaa @thischapter} 
@| a @thissection @| b
+';
+
+
+$result_texts{'heading_commands_in_center'} = 'aaa   a   b
+';
+
+$result_errors{'heading_commands_in_center'} = [
+  {
+    'error_line' => '@thischapter should only appear in heading or footing
+',
+    'line_nr' => 1,
+    'text' => '@thischapter should only appear in heading or footing',
+    'type' => 'error'
+  },
+  {
+    'error_line' => 'warning: @| should not appear in @center
+',
+    'line_nr' => 1,
+    'text' => '@| should not appear in @center',
+    'type' => 'warning'
+  },
+  {
+    'error_line' => '@| should only appear in heading or footing
+',
+    'line_nr' => 1,
+    'text' => '@| should only appear in heading or footing',
+    'type' => 'error'
+  },
+  {
+    'error_line' => 'warning: @thissection should not appear in @center
+',
+    'line_nr' => 1,
+    'text' => '@thissection should not appear in @center',
+    'type' => 'warning'
+  },
+  {
+    'error_line' => '@thissection should only appear in heading or footing
+',
+    'line_nr' => 1,
+    'text' => '@thissection should only appear in heading or footing',
+    'type' => 'error'
+  },
+  {
+    'error_line' => 'warning: @| should not appear in @center
+',
+    'line_nr' => 1,
+    'text' => '@| should not appear in @center',
+    'type' => 'warning'
+  },
+  {
+    'error_line' => '@| should only appear in heading or footing
+',
+    'line_nr' => 1,
+    'text' => '@| should only appear in heading or footing',
+    'type' => 'error'
+  }
+];
+
+
+$result_floats{'heading_commands_in_center'} = {};
+
+
+1;
diff --git a/tp/t/results/coverage/heading_commands_in_documentlanguage.pl 
b/tp/t/results/coverage/heading_commands_in_documentlanguage.pl
new file mode 100644
index 0000000000..2d335a0919
--- /dev/null
+++ b/tp/t/results/coverage/heading_commands_in_documentlanguage.pl
@@ -0,0 +1,162 @@
+use vars qw(%result_texis %result_texts %result_trees %result_errors 
+   %result_indices %result_sectioning %result_nodes %result_menus
+   %result_floats %result_converted %result_converted_errors 
+   %result_elements %result_directions_text %result_indices_sort_strings);
+
+use utf8;
+
+$result_trees{'heading_commands_in_documentlanguage'} = {
+  'contents' => [
+    {
+      'contents' => [
+        {
+          'args' => [
+            {
+              'contents' => [
+                {
+                  'args' => [
+                    {
+                      'contents' => [
+                        {
+                          'text' => 'aaa '
+                        },
+                        {
+                          'cmdname' => 'thischapter'
+                        }
+                      ],
+                      'type' => 'brace_command_arg'
+                    }
+                  ],
+                  'cmdname' => 'code',
+                  'source_info' => {
+                    'line_nr' => 1
+                  }
+                },
+                {
+                  'text' => ' '
+                },
+                {
+                  'cmdname' => '|'
+                },
+                {
+                  'text' => ' '
+                },
+                {
+                  'cmdname' => 'thissection'
+                },
+                {
+                  'text' => ' '
+                },
+                {
+                  'cmdname' => '|'
+                },
+                {
+                  'text' => ' b'
+                }
+              ],
+              'info' => {
+                'spaces_after_argument' => {
+                  'text' => '
+'
+                }
+              },
+              'type' => 'line_arg'
+            }
+          ],
+          'cmdname' => 'documentlanguage',
+          'extra' => {
+            'text_arg' => '    b'
+          },
+          'info' => {
+            'spaces_before_argument' => {
+              'text' => ' '
+            }
+          },
+          'source_info' => {
+            'line_nr' => 1
+          }
+        }
+      ],
+      'type' => 'before_node_section'
+    }
+  ],
+  'type' => 'document_root'
+};
+
+$result_texis{'heading_commands_in_documentlanguage'} = '@documentlanguage 
@code{aaa @thischapter} @| @thissection @| b
+';
+
+
+$result_texts{'heading_commands_in_documentlanguage'} = '';
+
+$result_errors{'heading_commands_in_documentlanguage'} = [
+  {
+    'error_line' => 'warning: @code should not appear in @documentlanguage
+',
+    'line_nr' => 1,
+    'text' => '@code should not appear in @documentlanguage',
+    'type' => 'warning'
+  },
+  {
+    'error_line' => '@thischapter should only appear in heading or footing
+',
+    'line_nr' => 1,
+    'text' => '@thischapter should only appear in heading or footing',
+    'type' => 'error'
+  },
+  {
+    'error_line' => 'warning: @| should not appear in @documentlanguage
+',
+    'line_nr' => 1,
+    'text' => '@| should not appear in @documentlanguage',
+    'type' => 'warning'
+  },
+  {
+    'error_line' => '@| should only appear in heading or footing
+',
+    'line_nr' => 1,
+    'text' => '@| should only appear in heading or footing',
+    'type' => 'error'
+  },
+  {
+    'error_line' => 'warning: @thissection should not appear in 
@documentlanguage
+',
+    'line_nr' => 1,
+    'text' => '@thissection should not appear in @documentlanguage',
+    'type' => 'warning'
+  },
+  {
+    'error_line' => '@thissection should only appear in heading or footing
+',
+    'line_nr' => 1,
+    'text' => '@thissection should only appear in heading or footing',
+    'type' => 'error'
+  },
+  {
+    'error_line' => 'warning: @| should not appear in @documentlanguage
+',
+    'line_nr' => 1,
+    'text' => '@| should not appear in @documentlanguage',
+    'type' => 'warning'
+  },
+  {
+    'error_line' => '@| should only appear in heading or footing
+',
+    'line_nr' => 1,
+    'text' => '@| should only appear in heading or footing',
+    'type' => 'error'
+  },
+  {
+    'error_line' => 'bad argument to @documentlanguage: @code{aaa 
@thischapter} @| @thissection @| b
+',
+    'line_nr' => 1,
+    'text' => 'bad argument to @documentlanguage: @code{aaa @thischapter} @| 
@thissection @| b',
+    'type' => 'error'
+  }
+];
+
+
+$result_floats{'heading_commands_in_documentlanguage'} = {};
+
+
+1;



reply via email to

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