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 (_process_remaining_o


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line), tp/Texinfo/XS/parsetexi/menus.c (handle_menu): transfer source marks from popped menu star element to menu leading text.
Date: Wed, 01 Feb 2023 15:29:35 -0500

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 7146c4703a * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line), 
tp/Texinfo/XS/parsetexi/menus.c (handle_menu): transfer source marks from 
popped menu star element to menu leading text.
7146c4703a is described below

commit 7146c4703abaf94f0b3bbcd837ea1b4eecf76c9b
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Wed Feb 1 21:29:20 2023 +0100

    * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line),
    tp/Texinfo/XS/parsetexi/menus.c (handle_menu): transfer source marks
    from popped menu star element to menu leading text.
---
 ChangeLog                           |  6 ++++
 tp/TODO                             | 15 ++-------
 tp/Texinfo/ParserNonXS.pm           | 11 ++++---
 tp/Texinfo/XS/parsetexi/menus.c     | 12 +++++--
 tp/t/results/macro/macro_in_menu.pl | 62 ++++++++++++++++++++-----------------
 5 files changed, 58 insertions(+), 48 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d2bbe14432..fdb465cefd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-02-01  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line),
+       tp/Texinfo/XS/parsetexi/menus.c (handle_menu): transfer source marks
+       from popped menu star element to menu leading text.
+
 2023-02-01  Patrice Dumas  <pertusus@free.fr>
 
        * tp/DebugTexinfo/DebugTree.pm (_print_tree),
diff --git a/tp/TODO b/tp/TODO
index 36cb6c9034..a539d7a27b 100644
--- a/tp/TODO
+++ b/tp/TODO
@@ -30,18 +30,9 @@ Also check that the situation of the following fixme is 
tested:
 Same for
 # FIXME transfer source marks
 
-Source marks of element popped from accents are associated to the accent
-command parent otherwise an empty element will be readded for the source
-mark leading to an infinite loop
-1) it is not clear that it leads to the correct location of source marks
-2) such a situation could probably happen in more cases and should maybe
-  be handled in _pop_element_from_contents
-
-Add code + test for the case of
-      # FIXME this should lead to readding an empty element for
-      # source marks and source marks not to be well placed.
-      # Instead source marks should be transferred directly to
-      # menu_entry_leading_text
+Source marks of element popped can lead to empty element readded for the source
+mark leading to an infinite loop. Such a situation should maybe be handled in
+_pop_element_from_contents
 
 Test for the case of
           # FIXME not sure that it is possible to have source marks, nor
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index d0a55d2032..31ceb45302 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -4895,11 +4895,7 @@ sub _process_remaining_on_line($$$$)
     } else {
       print STDERR "MENU ENTRY (certainly)\n" if ($self->{'DEBUG'});
       # this is the menu star collected previously
-      # FIXME this should lead to readding an empty element for
-      # source marks and source marks not to be well placed.
-      # Instead source marks should be transferred directly to
-      # menu_entry_leading_text
-      _pop_element_from_contents($self, $current, 1);
+      my $menu_star_element = _pop_element_from_contents($self, $current);
       $line =~ s/^(\s+)//;
       my $leading_text = '*' . $1;
       # FIXME remove empty description too?  In that case there won't be
@@ -4942,6 +4938,11 @@ sub _process_remaining_on_line($$$$)
                                'parent' => $current },
                              { 'type' => 'menu_entry_name',
                                'parent' => $current } ];
+      # transfer source marks from removed menu star to leading text
+      if ($menu_star_element->{'source_marks'}) {
+        _add_source_marks($menu_star_element->{'source_marks'},
+                          $current->{'args'}->[0]);
+      }
       $current = $current->{'args'}->[-1];
     }
   # after a separator in menu
diff --git a/tp/Texinfo/XS/parsetexi/menus.c b/tp/Texinfo/XS/parsetexi/menus.c
index 28803988e5..040ed75cce 100644
--- a/tp/Texinfo/XS/parsetexi/menus.c
+++ b/tp/Texinfo/XS/parsetexi/menus.c
@@ -22,6 +22,7 @@
 #include "text.h"
 #include "convert.h"
 #include "labels.h"
+#include "source_marks.h"
 
 /* Save 'menu_entry_name' 'menu_entry_node', and 'menu_entry_description'
    extra keys on the top-level @menu element. */
@@ -123,12 +124,15 @@ handle_menu (ELEMENT **current_inout, char **line_inout)
            && last_contents_child(current)->type == ET_internal_menu_star)
     {
       ELEMENT *menu_entry, *leading_text, *entry_name;
+      ELEMENT *menu_star_element;
       int leading_spaces;
 
       debug ("MENU ENTRY (certainly)");
-      leading_spaces = strspn (line, whitespace_chars);
 
-      destroy_element (pop_element_from_contents (current, 1));
+      /* this is the menu star collected previously */
+      menu_star_element = pop_element_from_contents (current, 0);
+
+      leading_spaces = strspn (line, whitespace_chars);
 
       if (current->type == ET_preformatted
           && current->parent->type == ET_menu_comment)
@@ -160,6 +164,10 @@ handle_menu (ELEMENT **current_inout, char **line_inout)
 
       menu_entry = new_element (ET_menu_entry);
       leading_text = new_element (ET_menu_entry_leading_text);
+      /* transfer source marks from removed menu star to leading text */
+      add_source_marks (&menu_star_element->source_mark_list, leading_text);
+      menu_star_element->source_mark_list.number = 0;
+      destroy_element (menu_star_element);
       entry_name = new_element (ET_menu_entry_name);
       add_to_element_contents (current, menu_entry);
       add_to_element_args (menu_entry, leading_text);
diff --git a/tp/t/results/macro/macro_in_menu.pl 
b/tp/t/results/macro/macro_in_menu.pl
index 74715916f5..96a6ce8109 100644
--- a/tp/t/results/macro/macro_in_menu.pl
+++ b/tp/t/results/macro/macro_in_menu.pl
@@ -519,12 +519,6 @@ $result_trees{'macro_in_menu'} = {
                       },
                       'sourcemark_type' => 'macro_expansion',
                       'status' => 'start'
-                    },
-                    {
-                      'counter' => 4,
-                      'position' => 1,
-                      'sourcemark_type' => 'macro_expansion',
-                      'status' => 'end'
                     }
                   ],
                   'type' => 'preformatted'
@@ -535,6 +529,14 @@ $result_trees{'macro_in_menu'} = {
             {
               'args' => [
                 {
+                  'source_marks' => [
+                    {
+                      'counter' => 4,
+                      'position' => 1,
+                      'sourcemark_type' => 'macro_expansion',
+                      'status' => 'end'
+                    }
+                  ],
                   'text' => '* ',
                   'type' => 'menu_entry_leading_text'
                 },
@@ -575,29 +577,6 @@ $result_trees{'macro_in_menu'} = {
                           },
                           'sourcemark_type' => 'macro_expansion',
                           'status' => 'start'
-                        },
-                        {
-                          'counter' => 5,
-                          'position' => 1,
-                          'sourcemark_type' => 'macro_expansion',
-                          'status' => 'end'
-                        },
-                        {
-                          'counter' => 6,
-                          'element' => {
-                            'args' => [
-                              {
-                                'text' => ''
-                              }
-                            ],
-                            'extra' => {
-                              'name' => 'aspace'
-                            },
-                            'type' => 'macro_call'
-                          },
-                          'position' => 1,
-                          'sourcemark_type' => 'macro_expansion',
-                          'status' => 'start'
                         }
                       ],
                       'type' => 'preformatted'
@@ -625,6 +604,31 @@ $result_trees{'macro_in_menu'} = {
             {
               'args' => [
                 {
+                  'source_marks' => [
+                    {
+                      'counter' => 5,
+                      'position' => 1,
+                      'sourcemark_type' => 'macro_expansion',
+                      'status' => 'end'
+                    },
+                    {
+                      'counter' => 6,
+                      'element' => {
+                        'args' => [
+                          {
+                            'text' => ''
+                          }
+                        ],
+                        'extra' => {
+                          'name' => 'aspace'
+                        },
+                        'type' => 'macro_call'
+                      },
+                      'position' => 1,
+                      'sourcemark_type' => 'macro_expansion',
+                      'status' => 'start'
+                    }
+                  ],
                   'text' => '* ',
                   'type' => 'menu_entry_leading_text'
                 },



reply via email to

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