[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): remove empty menu entry node description by using close_container to close. |
Date: |
Wed, 22 Feb 2023 18:43:19 -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 2c4c989132 * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line),
tp/Texinfo/XS/parsetexi/menus.c (handle_menu): remove empty menu entry node
description by using close_container to close.
2c4c989132 is described below
commit 2c4c9891328d0a15248639dc913324b2ca852f02
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Thu Feb 23 00:43:10 2023 +0100
* tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line),
tp/Texinfo/XS/parsetexi/menus.c (handle_menu): remove empty menu entry
node description by using close_container to close.
* tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line): clarify
the comments explaining the situation after closing when encountering
a root command or @bye. Restate a FIXME as a TODO and be more
explicit.
---
ChangeLog | 11 +++++++
tp/Texinfo/ParserNonXS.pm | 38 ++++++++++++++++------
tp/Texinfo/XS/parsetexi/menus.c | 7 ++--
.../info_tests/invalid_node_name_no_warning.pl | 8 -----
.../info_tests/invalid_node_name_warning.pl | 8 -----
tp/t/results/menu/formats_in_menu.pl | 5 +--
tp/t/results/menu/menu_entry_name.pl | 10 +-----
7 files changed, 46 insertions(+), 41 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 84f04697de..a685ecefcd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2023-02-22 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line),
+ tp/Texinfo/XS/parsetexi/menus.c (handle_menu): remove empty menu entry
+ node description by using close_container to close.
+
+ * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line): clarify
+ the comments explaining the situation after closing when encountering
+ a root command or @bye. Restate a FIXME as a TODO and be more
+ explicit.
+
2023-02-22 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line),
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index f19d86e17e..d53afd1e68 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -2103,8 +2103,9 @@ sub _close_commands($$$;$$)
and !($current->{'cmdname'}
and ($root_commands{$current->{'cmdname'}}
or ($closed_block_command and
$current->{'parent'}->{'cmdname'}
- and
(exists($brace_commands{$current->{'parent'}->{'cmdname'}})
- and $brace_commands{$current->{'parent'}->{'cmdname'}} eq
'context'))))) {
+ and
exists($brace_commands{$current->{'parent'}->{'cmdname'}})
+ and $brace_commands{
+ $current->{'parent'}->{'cmdname'}} eq
'context')))) {
_close_command_cleanup($self, $current);
$current = _close_current($self, $current, $source_info,
$closed_block_command,
@@ -5329,7 +5330,6 @@ sub _process_remaining_on_line($$$$)
my $menu_star_element = _pop_element_from_contents($self, $current);
$line =~ s/^(\s+)//;
my $leading_text = '*' . $1;
- # FIXME remove empty description too?
if ($current->{'type'} eq 'preformatted'
and $current->{'parent'}->{'type'}
and $current->{'parent'}->{'type'} eq 'menu_comment') {
@@ -5338,7 +5338,8 @@ sub _process_remaining_on_line($$$$)
# close menu_comment
$current = _close_container($self, $current);
} else {
- # first parent preformatted, third is menu_entry
+ # if in the preceding menu entry description, first parent is
preformatted,
+ # second is the description, third is the menu_entry
if ($current->{'type'} ne 'preformatted'
or $current->{'parent'}->{'type'} ne 'menu_entry_description'
or $current->{'parent'}->{'parent'}->{'type'} ne 'menu_entry'
@@ -5347,7 +5348,12 @@ sub _process_remaining_on_line($$$$)
$self->_bug_message("Not in menu comment nor description",
$source_info, $current);
}
- $current = $current->{'parent'}->{'parent'}->{'parent'};
+ # close preformatted
+ $current = _close_container($self, $current);
+ # close menu_description
+ $current = _close_container($self, $current);
+ # close menu_entry (which cannot actually be empty).
+ $current = _close_container($self, $current);
}
push @{$current->{'contents'}}, { 'type' => 'menu_entry',
'parent' => $current,
@@ -5640,17 +5646,29 @@ sub _process_remaining_on_line($$$$)
if ($root_commands{$command} or $command eq 'bye') {
$current = _close_commands($self, $current, $source_info, undef,
$command);
+ # if the root command happens in a Texinfo fragment going through
+ # parse_texi_line we are directly in the root_line document
+ # root container (in this case _close_commands returned immediately),
+ # and there is no parent for $current.
+ # In any other situation, _close_command stops at the preceding
+ # root command or in before_node_section, both being in the document
+ # root container, so that there is a parent for $current, the document
+ # root container.
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", $source_info, $current);
die;
+ } else {
+ # TODO do we want to error out if there is a root command in
+ # Texinfo fragment processed with parse_texi_text (and therefore
+ # here in root_line)?
+ # $self->_line_error(sprintf(__(
+ # "\@%s should not appear in Texinfo parsed as a short fragment"),
+ # $command), $source_info);
}
} else {
+ # in a root command or before_node_section, get to the document root
+ # container.
$current = $current->{'parent'};
}
}
diff --git a/tp/Texinfo/XS/parsetexi/menus.c b/tp/Texinfo/XS/parsetexi/menus.c
index 52c7f3eb1b..de07f9d7f2 100644
--- a/tp/Texinfo/XS/parsetexi/menus.c
+++ b/tp/Texinfo/XS/parsetexi/menus.c
@@ -143,8 +143,11 @@ handle_menu (ELEMENT **current_inout, char **line_inout)
/* current should be ET_preformatted,
1st parent ET_menu_entry_description,
2nd parent ET_menu_entry,
- 3rd parent @menu. */
- current = current->parent->parent->parent;
+ 3rd parent @menu.
+ Close current, 1st and 2nd parent (which cannot be empty) */
+ current = close_container (current);
+ current = close_container (current);
+ current = close_container (current);
}
menu_entry = new_element (ET_menu_entry);
diff --git a/tp/t/results/info_tests/invalid_node_name_no_warning.pl
b/tp/t/results/info_tests/invalid_node_name_no_warning.pl
index 37186492ab..1e60d20240 100644
--- a/tp/t/results/info_tests/invalid_node_name_no_warning.pl
+++ b/tp/t/results/info_tests/invalid_node_name_no_warning.pl
@@ -115,14 +115,6 @@ $result_trees{'invalid_node_name_no_warning'} = {
}
],
'type' => 'menu_entry_node'
- },
- {
- 'contents' => [
- {
- 'type' => 'preformatted'
- }
- ],
- 'type' => 'menu_entry_description'
}
],
'extra' => {
diff --git a/tp/t/results/info_tests/invalid_node_name_warning.pl
b/tp/t/results/info_tests/invalid_node_name_warning.pl
index c6c6e1a1d3..78b4910237 100644
--- a/tp/t/results/info_tests/invalid_node_name_warning.pl
+++ b/tp/t/results/info_tests/invalid_node_name_warning.pl
@@ -115,14 +115,6 @@ $result_trees{'invalid_node_name_warning'} = {
}
],
'type' => 'menu_entry_node'
- },
- {
- 'contents' => [
- {
- 'type' => 'preformatted'
- }
- ],
- 'type' => 'menu_entry_description'
}
],
'extra' => {
diff --git a/tp/t/results/menu/formats_in_menu.pl
b/tp/t/results/menu/formats_in_menu.pl
index 81614d6019..f436a0bd42 100644
--- a/tp/t/results/menu/formats_in_menu.pl
+++ b/tp/t/results/menu/formats_in_menu.pl
@@ -338,9 +338,6 @@ $result_trees{'formats_in_menu'} = {
'line_nr' => 11,
'macro' => ''
}
- },
- {
- 'type' => 'preformatted'
}
],
'type' => 'menu_entry_description'
@@ -944,7 +941,7 @@ $result_converted{'xml'}->{'formats_in_menu'} = '<node
name="first" spaces=" "><
some @ verb{x atim
* texinfo:: in @ verbatim
</verbatim>
-<pre
xml:space="preserve"></pre></menudescription></menuentry><menuentry><menuleadingtext>*
</menuleadingtext><menunode>(manual2)</menunode><menuseparator>::
</menuseparator><menudescription><pre xml:space="preserve">%
+</menudescription></menuentry><menuentry><menuleadingtext>*
</menuleadingtext><menunode>(manual2)</menunode><menuseparator>::
</menuseparator><menudescription><pre xml:space="preserve">%
<html endspaces=" ">
<i></i>
diff --git a/tp/t/results/menu/menu_entry_name.pl
b/tp/t/results/menu/menu_entry_name.pl
index 1629232fdd..7df4c7c194 100644
--- a/tp/t/results/menu/menu_entry_name.pl
+++ b/tp/t/results/menu/menu_entry_name.pl
@@ -62,14 +62,6 @@ $result_trees{'menu_entry_name'} = {
}
],
'type' => 'menu_entry_node'
- },
- {
- 'contents' => [
- {
- 'type' => 'preformatted'
- }
- ],
- 'type' => 'menu_entry_description'
}
],
'extra' => {
@@ -923,7 +915,7 @@ $result_converted_errors{'html'}->{'menu_entry_name'} = [
$result_converted{'xml'}->{'menu_entry_name'} = '<menu endspaces=" ">
<menuentry><menuleadingtext>*
</menuleadingtext><menutitle>a</menutitle><menuseparator>:
</menuseparator><menunode>(f)b
-</menunode><menudescription><pre
xml:space="preserve"></pre></menudescription></menuentry><menuentry><menuleadingtext>*
</menuleadingtext><menutitle>a</menutitle><menuseparator>:
</menuseparator><menunode>(f)b1.c</menunode><menuseparator>,</menuseparator><menudescription><pre
xml:space="preserve">
+</menunode></menuentry><menuentry><menuleadingtext>*
</menuleadingtext><menutitle>a</menutitle><menuseparator>:
</menuseparator><menunode>(f)b1.c</menunode><menuseparator>,</menuseparator><menudescription><pre
xml:space="preserve">
</pre></menudescription></menuentry><menuentry><menuleadingtext>*
</menuleadingtext><menutitle>a</menutitle><menuseparator>:
</menuseparator><menunode>(f)b2.c</menunode><menuseparator>,
</menuseparator><menudescription><pre xml:space="preserve">
</pre></menudescription></menuentry><menuentry><menuleadingtext>*
</menuleadingtext><menutitle>a</menutitle><menuseparator>:
</menuseparator><menunode>(f)b3.c</menunode><menuseparator>,
</menuseparator><menudescription><pre xml:space="preserve">d
</pre></menudescription></menuentry><menuentry><menuleadingtext>*
</menuleadingtext><menutitle>a</menutitle><menuseparator>:
</menuseparator><menunode>(f)b1.</menunode><menuseparator>.
</menuseparator><menudescription><pre xml:space="preserve">
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line), tp/Texinfo/XS/parsetexi/menus.c (handle_menu): remove empty menu entry node description by using close_container to close.,
Patrice Dumas <=