texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/ParserNonXS.pm (gather_previous_item


From: Gavin D. Smith
Subject: branch master updated: * tp/Texinfo/ParserNonXS.pm (gather_previous_item), * tp/Texinfo/XS/parsetexi/multitable.c (gather_previous_item): Leave trailing index entries if no command follows. * tp/t/22xtable.t (index_command_before_end_table): New test.
Date: Sat, 26 Nov 2022 10:51:53 -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 ab4aa927ce * tp/Texinfo/ParserNonXS.pm (gather_previous_item), * 
tp/Texinfo/XS/parsetexi/multitable.c (gather_previous_item): Leave trailing 
index entries if no command follows. * tp/t/22xtable.t 
(index_command_before_end_table): New test.
ab4aa927ce is described below

commit ab4aa927ce64ce1defd38e3ec2f203ba2ecca807
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Sat Nov 26 15:51:45 2022 +0000

    * tp/Texinfo/ParserNonXS.pm (gather_previous_item),
    * tp/Texinfo/XS/parsetexi/multitable.c (gather_previous_item):
    Leave trailing index entries if no command follows.
    * tp/t/22xtable.t (index_command_before_end_table): New test.
---
 ChangeLog                                          |   7 +
 tp/Makefile.tres                                   |   4 +
 tp/Texinfo/ParserNonXS.pm                          |  18 +-
 tp/Texinfo/XS/parsetexi/multitable.c               |  18 +-
 tp/t/22xtable.t                                    |  10 +
 .../xtable/index_command_before_end_table.pl       | 281 +++++++++++++++++++++
 6 files changed, 322 insertions(+), 16 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e555037ac1..7130fe1c57 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2022-11-26  Gavin Smith  <gavinsmith0123@gmail.com>
+
+       * tp/Texinfo/ParserNonXS.pm (gather_previous_item),
+       * tp/Texinfo/XS/parsetexi/multitable.c (gather_previous_item):
+       Leave trailing index entries if no command follows.
+       * tp/t/22xtable.t (index_command_before_end_table): New test.
+
 2022-11-26  Gavin Smith  <gavinsmith0123@gmail.com>
 
        * tp/t/22xtable.t (inter_item_commands_in_table): Move test
diff --git a/tp/Makefile.tres b/tp/Makefile.tres
index 5bdc4400d0..b816cf6ff1 100644
--- a/tp/Makefile.tres
+++ b/tp/Makefile.tres
@@ -1702,6 +1702,8 @@ test_files_generated_list = 
$(test_tap_files_generated_list) \
   t/results/sectioning/contents_with_only_top_node.pl \
   t/results/sectioning/double_node_anchor_float.pl \
   t/results/sectioning/double_part.pl \
+  t/results/sectioning/double_recursive_self_section_node_reference.pl \
+  t/results/sectioning/double_recursive_self_section_reference.pl \
   t/results/sectioning/double_top.pl \
   t/results/sectioning/double_top_in_menu.pl \
   t/results/sectioning/double_top_section.pl \
@@ -1788,6 +1790,7 @@ test_files_generated_list = 
$(test_tap_files_generated_list) \
   t/results/sectioning/protected_node_parentheses.pl \
   t/results/sectioning/raiselowersections.pl \
   t/results/sectioning/rec_nodes.pl \
+  t/results/sectioning/recursive_self_section_reference.pl \
   t/results/sectioning/ref_to_top.pl \
   t/results/sectioning/ref_to_unknown_node.pl \
   t/results/sectioning/reference_to_only_special_spaces_node.pl \
@@ -1909,6 +1912,7 @@ test_files_generated_list = 
$(test_tap_files_generated_list) \
   t/results/xtable/definfoenclose_on_table_line.pl \
   t/results/xtable/empty_item_itemx.pl \
   t/results/xtable/headitem_in_table.pl \
+  t/results/xtable/index_command_before_end_table.pl \
   t/results/xtable/inter_item_commands_in_table.pl \
   
t/results/xtable/inter_item_commands_in_table/res_latex/inter_item_commands_in_table.tex
 \
   t/results/xtable/inter_item_commands_in_table_in_example.pl \
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 91b254c221..881a8fdca5 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -1579,14 +1579,16 @@ sub _gather_previous_item($$;$$)
   $splice_idx = 0 if !defined($splice_idx);
 
   my $splice_idx2;
-  # don't absorb trailing index entries as they are included with following
-  # @item.
-  # fixme - what to do with index entries immediately before '@end table'
-  for (my $i = $contents_count - 1; $i >= $splice_idx; $i--) {
-    if (!$current->{'contents'}->[$i]->{'type'}
-          or $current->{'contents'}->[$i]->{'type'} ne 'index_entry_command') {
-      $splice_idx2 = $i + 1;
-      last;
+
+  if (defined($next_command)) {
+    # Don't absorb trailing index entries as they are included with a
+    # following @item.
+    for (my $i = $contents_count - 1; $i >= $splice_idx; $i--) {
+      if (!$current->{'contents'}->[$i]->{'type'}
+        or $current->{'contents'}->[$i]->{'type'} ne 'index_entry_command') {
+        $splice_idx2 = $i + 1;
+        last;
+      }
     }
   }
   $splice_idx2 = $contents_count if !defined($splice_idx2);
diff --git a/tp/Texinfo/XS/parsetexi/multitable.c 
b/tp/Texinfo/XS/parsetexi/multitable.c
index badd914df9..6575af83fc 100644
--- a/tp/Texinfo/XS/parsetexi/multitable.c
+++ b/tp/Texinfo/XS/parsetexi/multitable.c
@@ -92,16 +92,18 @@ gather_previous_item (ELEMENT *current, enum command_id 
next_command)
   if (splice_idx == -1)
     splice_idx = 0;
 
-  /* don't absorb trailing index entries as they are included with following
-     @item. */
-  /* fixme - what to do with index entries immediately before '@end table' */
-  for (i = contents_count - 1; i >= splice_idx; i--)
+  if (next_command)
     {
-      e = contents_child_by_index (current, i);
-      if (e->type != ET_index_entry_command)
+      /* Don't absorb trailing index entries as they are included with a
+         following @item. */
+      for (i = contents_count - 1; i >= splice_idx; i--)
         {
-          splice_idx2 = i + 1;
-          break;
+          e = contents_child_by_index (current, i);
+          if (e->type != ET_index_entry_command)
+            {
+              splice_idx2 = i + 1;
+              break;
+            }
         }
     }
   if (splice_idx2 == -1)
diff --git a/tp/t/22xtable.t b/tp/t/22xtable.t
index 5574be2dfe..441043bf03 100644
--- a/tp/t/22xtable.t
+++ b/tp/t/22xtable.t
@@ -160,6 +160,16 @@ l--ine
 @end table
 @end example
 '],
+['index_command_before_end_table',
+'
+@table @code
+@item in item
+@itemx in itemx
+aaaaa
+
+@vindex var
+@end table
+'],
 ['block_commands_in_table',
 '@node Top
 @top Element
diff --git a/tp/t/results/xtable/index_command_before_end_table.pl 
b/tp/t/results/xtable/index_command_before_end_table.pl
new file mode 100644
index 0000000000..64531657ce
--- /dev/null
+++ b/tp/t/results/xtable/index_command_before_end_table.pl
@@ -0,0 +1,281 @@
+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{'index_command_before_end_table'} = {
+  'contents' => [
+    {
+      'contents' => [
+        {
+          'text' => '
+',
+          'type' => 'empty_line'
+        },
+        {
+          'args' => [
+            {
+              'contents' => [
+                {
+                  'cmdname' => 'code',
+                  'source_info' => {
+                    'file_name' => '',
+                    'line_nr' => 2,
+                    'macro' => ''
+                  },
+                  'type' => 'command_as_argument'
+                }
+              ],
+              'info' => {
+                'spaces_after_argument' => '
+'
+              },
+              'type' => 'block_line_arg'
+            }
+          ],
+          'cmdname' => 'table',
+          'contents' => [
+            {
+              'contents' => [
+                {
+                  'contents' => [
+                    {
+                      'args' => [
+                        {
+                          'contents' => [
+                            {
+                              'text' => 'in item'
+                            }
+                          ],
+                          'info' => {
+                            'spaces_after_argument' => '
+'
+                          },
+                          'type' => 'line_arg'
+                        }
+                      ],
+                      'cmdname' => 'item',
+                      'info' => {
+                        'spaces_before_argument' => ' '
+                      },
+                      'source_info' => {
+                        'file_name' => '',
+                        'line_nr' => 3,
+                        'macro' => ''
+                      }
+                    },
+                    {
+                      'args' => [
+                        {
+                          'contents' => [
+                            {
+                              'text' => 'in itemx'
+                            }
+                          ],
+                          'info' => {
+                            'spaces_after_argument' => '
+'
+                          },
+                          'type' => 'line_arg'
+                        }
+                      ],
+                      'cmdname' => 'itemx',
+                      'info' => {
+                        'spaces_before_argument' => ' '
+                      },
+                      'source_info' => {
+                        'file_name' => '',
+                        'line_nr' => 4,
+                        'macro' => ''
+                      }
+                    }
+                  ],
+                  'type' => 'table_term'
+                },
+                {
+                  'contents' => [
+                    {
+                      'contents' => [
+                        {
+                          'text' => 'aaaaa
+'
+                        }
+                      ],
+                      'type' => 'paragraph'
+                    },
+                    {
+                      'text' => '
+',
+                      'type' => 'empty_line'
+                    },
+                    {
+                      'args' => [
+                        {
+                          'contents' => [
+                            {
+                              'text' => 'var'
+                            }
+                          ],
+                          'info' => {
+                            'spaces_after_argument' => '
+'
+                          },
+                          'type' => 'line_arg'
+                        }
+                      ],
+                      'cmdname' => 'vindex',
+                      'extra' => {
+                        'index_entry' => {
+                          'content_normalized' => [],
+                          'entry_content' => [],
+                          'entry_element' => {},
+                          'entry_number' => 1,
+                          'in_code' => 1,
+                          'index_at_command' => 'vindex',
+                          'index_ignore_chars' => {},
+                          'index_name' => 'vr',
+                          'index_type_command' => 'vindex'
+                        }
+                      },
+                      'info' => {
+                        'spaces_before_argument' => ' '
+                      },
+                      'source_info' => {
+                        'file_name' => '',
+                        'line_nr' => 7,
+                        'macro' => ''
+                      },
+                      'type' => 'index_entry_command'
+                    }
+                  ],
+                  'type' => 'table_definition'
+                }
+              ],
+              'type' => 'table_entry'
+            },
+            {
+              'args' => [
+                {
+                  'contents' => [
+                    {
+                      'text' => 'table'
+                    }
+                  ],
+                  'info' => {
+                    'spaces_after_argument' => '
+'
+                  },
+                  'type' => 'line_arg'
+                }
+              ],
+              'cmdname' => 'end',
+              'extra' => {
+                'text_arg' => 'table'
+              },
+              'info' => {
+                'spaces_before_argument' => ' '
+              },
+              'source_info' => {
+                'file_name' => '',
+                'line_nr' => 8,
+                'macro' => ''
+              }
+            }
+          ],
+          'extra' => {
+            'command_as_argument' => {}
+          },
+          'info' => {
+            'spaces_before_argument' => ' '
+          },
+          'source_info' => {
+            'file_name' => '',
+            'line_nr' => 2,
+            'macro' => ''
+          }
+        }
+      ],
+      'type' => 'before_node_section'
+    }
+  ],
+  'type' => 'document_root'
+};
+$result_trees{'index_command_before_end_table'}{'contents'}[0]{'contents'}[1]{'contents'}[0]{'contents'}[1]{'contents'}[2]{'extra'}{'index_entry'}{'content_normalized'}
 = 
$result_trees{'index_command_before_end_table'}{'contents'}[0]{'contents'}[1]{'contents'}[0]{'contents'}[1]{'contents'}[2]{'args'}[0]{'contents'};
+$result_trees{'index_command_before_end_table'}{'contents'}[0]{'contents'}[1]{'contents'}[0]{'contents'}[1]{'contents'}[2]{'extra'}{'index_entry'}{'entry_content'}
 = 
$result_trees{'index_command_before_end_table'}{'contents'}[0]{'contents'}[1]{'contents'}[0]{'contents'}[1]{'contents'}[2]{'args'}[0]{'contents'};
+$result_trees{'index_command_before_end_table'}{'contents'}[0]{'contents'}[1]{'contents'}[0]{'contents'}[1]{'contents'}[2]{'extra'}{'index_entry'}{'entry_element'}
 = 
$result_trees{'index_command_before_end_table'}{'contents'}[0]{'contents'}[1]{'contents'}[0]{'contents'}[1]{'contents'}[2];
+$result_trees{'index_command_before_end_table'}{'contents'}[0]{'contents'}[1]{'extra'}{'command_as_argument'}
 = 
$result_trees{'index_command_before_end_table'}{'contents'}[0]{'contents'}[1]{'args'}[0]{'contents'}[0];
+
+$result_texis{'index_command_before_end_table'} = '
+@table @code
+@item in item
+@itemx in itemx
+aaaaa
+
+@vindex var
+@end table
+';
+
+
+$result_texts{'index_command_before_end_table'} = '
+in item
+in itemx
+aaaaa
+
+';
+
+$result_errors{'index_command_before_end_table'} = [
+  {
+    'error_line' => 'warning: entry for index `vr\' outside of any node
+',
+    'file_name' => '',
+    'line_nr' => 7,
+    'macro' => '',
+    'text' => 'entry for index `vr\' outside of any node',
+    'type' => 'warning'
+  }
+];
+
+
+$result_floats{'index_command_before_end_table'} = {};
+
+
+$result_indices_sort_strings{'index_command_before_end_table'} = {
+  'vr' => [
+    'var'
+  ]
+};
+
+
+
+$result_converted{'plaintext'}->{'index_command_before_end_table'} = '‘in item’
+‘in itemx’
+     aaaaa
+
+';
+
+
+$result_converted{'html_text'}->{'index_command_before_end_table'} = '
+<dl class="table">
+<dt><code class="code">in item</code></dt>
+<dt><code class="code">in itemx</code></dt>
+<dd><p>aaaaa
+</p>
+<a class="index-entry-id" id="index-var"></a>
+</dd>
+</dl>
+';
+
+
+$result_converted{'xml'}->{'index_command_before_end_table'} = '
+<table commandarg="code" spaces=" " endspaces=" ">
+<tableentry><tableterm><item spaces=" "><itemformat command="code">in 
item</itemformat></item>
+<itemx spaces=" "><itemformat command="code">in itemx</itemformat></itemx>
+</tableterm><tableitem><para>aaaaa
+</para>
+<vindex index="vr" spaces=" "><indexterm index="vr" 
number="1">var</indexterm></vindex>
+</tableitem></tableentry></table>
+';
+
+1;



reply via email to

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