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 (_parse_texi), tp/Tex


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/ParserNonXS.pm (_parse_texi), tp/Texinfo/XS/parsetexi/handle_commands.c (handle_line_command): check if the element type is root_line when closing a root command, and die if there is no parent only if not in root_line. A root command in parse_texi_line could be considered incorrect, in that case an error message should be output.
Date: Sat, 08 Jan 2022 20:08:48 -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 5f54d2265f * tp/Texinfo/ParserNonXS.pm (_parse_texi), 
tp/Texinfo/XS/parsetexi/handle_commands.c (handle_line_command): check if the 
element type is root_line when closing a root command, and die if there is no 
parent only if not in root_line.  A root command in parse_texi_line could be 
considered incorrect, in that case an error message should be output.
5f54d2265f is described below

commit 5f54d2265f8a5951d58cde98b3faa6e1243b4f23
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Jan 9 02:08:37 2022 +0100

    * tp/Texinfo/ParserNonXS.pm (_parse_texi),
    tp/Texinfo/XS/parsetexi/handle_commands.c (handle_line_command):
    check if the element type is root_line when closing a root command,
    and die if there is no parent only if not in root_line.  A root
    command in parse_texi_line could be considered incorrect, in that
    case an error message should be output.
---
 ChangeLog                                 |  9 +++++++++
 tp/Texinfo/ParserNonXS.pm                 | 15 +++++++++++++--
 tp/Texinfo/XS/parsetexi/handle_commands.c | 12 +++++++++---
 3 files changed, 31 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 807499b4fb..fcc3528ca0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2022-01-09  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/ParserNonXS.pm (_parse_texi),
+       tp/Texinfo/XS/parsetexi/handle_commands.c (handle_line_command):
+       check if the element type is root_line when closing a root command,
+       and die if there is no parent only if not in root_line.  A root
+       command in parse_texi_line could be considered incorrect, in that
+       case an error message should be output.
+
 2022-01-08  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/Convert/Converter.pm (_in_preamble)
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 067326777f..af077a35b8 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -4474,8 +4474,19 @@ sub _parse_texi($$$)
           if ($root_commands{$command} or $command eq 'bye') {
             $current = _close_commands($self, $current, $line_nr, undef, 
                                        $command);
-            die if (!defined($current->{'parent'}));
-            $current = $current->{'parent'};
+            if (!defined($current->{'parent'})) {
+              # if parse_texi_line is called on a line with a node/section then
+              # it will directly be in the root_line, otherwise it is not 
directly
+              # in the root, but in another container
+              #
+              # FIXME warn/error with a root command in parse_texi_line?
+              if ($current->{'type'} ne 'root_line') {
+                $self->_bug_message("no parent element", $line_nr, $current);
+                die;
+              }
+            } else {
+              $current = $current->{'parent'};
+            }
           }
 
           # skipline text line lineraw /^\d$/
diff --git a/tp/Texinfo/XS/parsetexi/handle_commands.c 
b/tp/Texinfo/XS/parsetexi/handle_commands.c
index b79b93bf53..24a7f33a34 100644
--- a/tp/Texinfo/XS/parsetexi/handle_commands.c
+++ b/tp/Texinfo/XS/parsetexi/handle_commands.c
@@ -320,9 +320,15 @@ handle_line_command (ELEMENT *current, char **line_inout,
     {
       ELEMENT *closed_elt; /* Not used */
       current = close_commands (current, 0, &closed_elt, cmd);
-      current = current->parent;
-      if (!current)
-        fatal ("no parent element");
+      /* if parse_texi_line is called on a line with a node/section then
+         it will directly be in the root_line, otherwise it is not directly
+         in the root, but in another container */
+      if (current->type != ET_root_line)
+        {
+          current = current->parent;
+          if (!current)
+            fatal ("no parent element");
+        }
     }
 
   /* Look up information about this command ( skipline text 



reply via email to

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