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 (_close_current), tp


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/ParserNonXS.pm (_close_current), tp/Texinfo/XS/parsetexi/close.c (close_current): more precise comment on why it is needed to check that the potentially removed empty type needs to be cheked to be contents, to avoid args. Improve debug message.
Date: Sat, 04 Feb 2023 03:59:29 -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 856f88a758 * tp/Texinfo/ParserNonXS.pm (_close_current), 
tp/Texinfo/XS/parsetexi/close.c (close_current): more precise comment on why it 
is needed to check that the potentially removed empty type needs to be cheked 
to be contents, to avoid args.  Improve debug message.
856f88a758 is described below

commit 856f88a758f4b32755fc0f118efc9cc7f17fc848
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Feb 4 09:16:49 2023 +0100

    * tp/Texinfo/ParserNonXS.pm (_close_current),
    tp/Texinfo/XS/parsetexi/close.c (close_current): more precise comment
    on why it is needed to check that the potentially removed empty type
    needs to be cheked to be contents, to avoid args.  Improve debug
    message.
    
    * tp/Texinfo/XS/parsetexi/end_line.c (end_line): improve debug
    message.
---
 ChangeLog                          | 11 +++++++++++
 tp/TODO                            |  2 --
 tp/Texinfo/ParserNonXS.pm          | 20 ++++++++++++--------
 tp/Texinfo/XS/parsetexi/close.c    | 10 +++++++++-
 tp/Texinfo/XS/parsetexi/end_line.c |  3 ++-
 5 files changed, 34 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0f0ec52d77..7ae25c1375 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2023-02-04  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/ParserNonXS.pm (_close_current),
+       tp/Texinfo/XS/parsetexi/close.c (close_current): more precise comment
+       on why it is needed to check that the potentially removed empty type
+       needs to be cheked to be contents, to avoid args.  Improve debug
+       message.
+
+       * tp/Texinfo/XS/parsetexi/end_line.c (end_line): improve debug
+       message.
+
 2023-02-03  Gavin Smith <gavinsmith0123@gmail.com>
 
        Eliminate duplicate nesting warning messages
diff --git a/tp/TODO b/tp/TODO
index c6b04c8717..20ccb326b4 100644
--- a/tp/TODO
+++ b/tp/TODO
@@ -17,8 +17,6 @@ or value expansion. aliases.
 done: source_marks structures, with beginning and end of included file, @
 protecting end of line in @def*, @setfilename in included files.
 
-use contents for menu entry.
-
 Fix
 # FIXME this is wrong, the source mark ends up at a wrong location
 
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 12bd0be762..dd2bf9cb9d 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -2119,17 +2119,21 @@ sub _close_current($$$;$$)
         and (not $current->{'source_marks'}
              or not scalar(@{$current->{'source_marks'}}))) {
       $element_to_remove = $current;
+    }
+    $current = $current->{'parent'};
+
+    if ($element_to_remove
+        # this is to avoid removing empty containers in args,
+        # happens with brace commands not closed at the end of
+        # a manual
+        and $current->{'contents'}
+        and scalar(@{$current->{'contents'}})
+        and $current->{'contents'}->[-1] eq $element_to_remove) {
       print STDERR "REMOVE empty type "
-        .Texinfo::Common::debug_print_element_short($current)."\n"
+        .Texinfo::Common::debug_print_element_short($element_to_remove)."\n"
           if ($self->{'DEBUG'});
+      _pop_element_from_contents($self, $current);
     }
-    $current = $current->{'parent'};
-    _pop_element_from_contents($self, $current)
-      if ($element_to_remove
-          # this is to avoid args, not sure that it can happen
-          and $current->{'contents'}
-          and scalar(@{$current->{'contents'}})
-          and $current->{'contents'}->[-1] eq $element_to_remove);
   } else { # Should never go here.
     $current = $current->{'parent'} if ($current->{'parent'});
     $self->_bug_message("No type nor cmdname when closing",
diff --git a/tp/Texinfo/XS/parsetexi/close.c b/tp/Texinfo/XS/parsetexi/close.c
index 3d8b93c4e2..ef30aede3f 100644
--- a/tp/Texinfo/XS/parsetexi/close.c
+++ b/tp/Texinfo/XS/parsetexi/close.c
@@ -390,12 +390,20 @@ close_current (ELEMENT *current,
           && current->info_info->info_number == 0
           && current->source_mark_list.number == 0)
         element_to_remove = current;
+
       current = current->parent;
       if (element_to_remove)
         {
           ELEMENT *last_child = last_contents_child (current);
+          /* this is to avoid removing empty containers in args,
+             happens with brace commands not closed at the end of
+             a manual */
           if (last_child == element_to_remove)
-            destroy_element (pop_element_from_contents (current, 0));
+            {
+              debug_nonl ("REMOVE empty type ");
+              debug_print_element_short (last_child, 1); debug("");
+              destroy_element (pop_element_from_contents (current, 0));
+            }
         }
     }
   else
diff --git a/tp/Texinfo/XS/parsetexi/end_line.c 
b/tp/Texinfo/XS/parsetexi/end_line.c
index a7616cd042..6f71ae1ad8 100644
--- a/tp/Texinfo/XS/parsetexi/end_line.c
+++ b/tp/Texinfo/XS/parsetexi/end_line.c
@@ -2302,7 +2302,8 @@ end_line (ELEMENT *current)
      line commands are nested (always incorrectly?) */
   if (current_context () == ct_line || current_context () == ct_def)
     {
-      debug ("Still opened line command");
+      debug_nonl ("Still opened line command %d:", current_context ());
+      debug_print_element_short (current, 1); debug("");
       if (current_context () == ct_def)
         {
           while (current->parent



reply via email to

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