[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: Fix both parsers to do the same tree with empty m
From: |
Patrice Dumas |
Subject: |
branch master updated: Fix both parsers to do the same tree with empty menu entry nodes |
Date: |
Wed, 20 Apr 2022 17:25:43 -0400 |
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 b1d3e9211d Fix both parsers to do the same tree with empty menu entry
nodes
b1d3e9211d is described below
commit b1d3e9211d9c0aebeb0f70fb268ba4a98a753968
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Wed Apr 20 23:25:30 2022 +0200
Fix both parsers to do the same tree with empty menu entry nodes
* tp/Texinfo/XS/parsetexi/menus.c
(register_extra_menu_entry_information): to determine that there
is no node content returned by parse_node_manual(), check that
manual_content and node_content fields are both null, as
parsed_entry_node is never null. parsed_entry_node cannot be null
because the return of parse_node_manual() can be used in nodes_manuals
which is null delimited.
* tp/Texinfo/Common.pm (parse_node_manual), tp/Texinfo/ParserNonXS.pm
(_isolate_last_space, _parse_node_manual, _end_line, _parse_texi):
do not set contents for type 'menu_entry_name' and 'menu_entry_node'
if empty.
* tp/Texinfo/ParserNonXS.pm (_register_extra_menu_entry_information):
do not call Texinfo::Convert::NodeNameNormalization::normalize_node
to check if node is empty, simply check that it has contents as is
done in the XS Parser.
---
ChangeLog | 22 +++++++++++++++
tp/Texinfo/Common.pm | 8 ++++--
tp/Texinfo/ParserNonXS.pm | 32 ++++++++++------------
tp/Texinfo/XS/parsetexi/end_line.c | 9 +++---
tp/Texinfo/XS/parsetexi/menus.c | 3 +-
.../sectioning/in_menu_only_special_spaces_node.pl | 24 +++++++++++++---
6 files changed, 69 insertions(+), 29 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b4d9ae5830..6751973c5d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2022-04-20 Patrice Dumas <pertusus@free.fr>
+
+ Fix both parsers to do the same tree with empty menu entry nodes
+
+ * tp/Texinfo/XS/parsetexi/menus.c
+ (register_extra_menu_entry_information): to determine that there
+ is no node content returned by parse_node_manual(), check that
+ manual_content and node_content fields are both null, as
+ parsed_entry_node is never null. parsed_entry_node cannot be null
+ because the return of parse_node_manual() can be used in nodes_manuals
+ which is null delimited.
+
+ * tp/Texinfo/Common.pm (parse_node_manual), tp/Texinfo/ParserNonXS.pm
+ (_isolate_last_space, _parse_node_manual, _end_line, _parse_texi):
+ do not set contents for type 'menu_entry_name' and 'menu_entry_node'
+ if empty.
+
+ * tp/Texinfo/ParserNonXS.pm (_register_extra_menu_entry_information):
+ do not call Texinfo::Convert::NodeNameNormalization::normalize_node
+ to check if node is empty, simply check that it has contents as is
+ done in the XS Parser.
+
2022-04-19 Gavin Smith <gavinsmith0123@gmail.com>
vertical tab
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index 4ac6bd848b..3c865edb1b 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -1453,13 +1453,15 @@ sub parse_node_manual($)
{
my $label_contents_container = shift;
- my @contents = @{$label_contents_container->{'contents'}};
-
my $manual;
my $result;
my ($end_paren, $spaces_after);
- if ($contents[0] and $contents[0]->{'text'} and $contents[0]->{'text'} =~
/^\(/) {
+ return undef, undef if (not $label_contents_container->{'contents'});
+ my @contents = @{$label_contents_container->{'contents'}};
+
+ if (scalar(@contents) and $contents[0]
+ and $contents[0]->{'text'} and $contents[0]->{'text'} =~ /^\(/) {
my $braces_count = 1;
if ($contents[0]->{'text'} !~ /^\($/) {
my $brace = shift @contents;
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 490a079ce9..4b18b10dd9 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -2347,19 +2347,19 @@ sub _isolate_last_space
{
my ($self, $current) = @_;
- return if (!$current->{'contents'} or !@{$current->{'contents'}});
+ return if (!$current->{'contents'} or !scalar(@{$current->{'contents'}}));
# Store a final comment command in the 'extra' hash.
- if (scalar(@{$current->{'contents'}}) >= 1
- and $current->{'contents'}->[-1]->{'cmdname'}
+ if ($current->{'contents'}->[-1]->{'cmdname'}
and ($current->{'contents'}->[-1]->{'cmdname'} eq 'c'
or $current->{'contents'}->[-1]->{'cmdname'} eq 'comment')) {
- $current->{'extra'}->{'comment_at_end'} = pop @{$current->{'contents'}};
- # TODO: @c should probably not be allowed inside most brace commands
- # as this would be difficult to implement properly in TeX.
+ $current->{'extra'}->{'comment_at_end'} = pop @{$current->{'contents'}};
+ # TODO: @c should probably not be allowed inside most brace commands
+ # as this would be difficult to implement properly in TeX.
}
- return if !@{$current->{'contents'}}
+ return if !$current->{'contents'}
+ or !scalar(@{$current->{'contents'}})
or !defined($current->{'contents'}->[-1]->{'text'})
or ($current->{'contents'}->[-1]->{'type'}
and (!$current->{'type'}
@@ -2401,7 +2401,8 @@ sub _parse_node_manual($)
my $label_contents_container = shift;
my ($parsed_node_manual, $modified_node_content)
= Texinfo::Common::parse_node_manual($label_contents_container);
- $label_contents_container->{'contents'} = $modified_node_content;
+ $label_contents_container->{'contents'} = $modified_node_content
+ if (defined($modified_node_content));
return $parsed_node_manual;
}
@@ -2833,13 +2834,13 @@ sub _end_line($$$)
my $empty_menu_entry_node = 0;
my $end_comment;
if ($current->{'type'} eq 'menu_entry_node') {
- if (@{$current->{'contents'}}
+ if ($current->{'contents'} and scalar(@{$current->{'contents'}})
and $current->{'contents'}->[-1]->{'cmdname'}
and ($current->{'contents'}->[-1]->{'cmdname'} eq 'c'
or $current->{'contents'}->[-1]->{'cmdname'} eq 'comment')) {
$end_comment = pop @{$current->{'contents'}};
}
- if (!@{$current->{'contents'}}
+ if (not $current->{'contents'} or not scalar(@{$current->{'contents'}})
# empty if only the end of line or spaces, including non ascii
spaces
or (@{$current->{'contents'}} == 1
and defined($current->{'contents'}->[-1]->{'text'})
@@ -2883,7 +2884,7 @@ sub _end_line($$$)
}
if ($description_or_menu_comment) {
$current = $description_or_menu_comment;
- if ($current->{'contents'}->[-1]
+ if ($current->{'contents'} and $current->{'contents'}->[-1]
and $current->{'contents'}->[-1]->{'type'}
and $current->{'contents'}->[-1]->{'type'} eq 'preformatted') {
$current = $current->{'contents'}->[-1];
@@ -3663,11 +3664,10 @@ sub _register_extra_menu_entry_information($$;$)
foreach my $arg (@{$current->{'args'}}) {
if ($arg->{'type'} eq 'menu_entry_name') {
$current->{'extra'}->{'menu_entry_name'} = $arg;
- my $normalized_menu_entry_name
- = Texinfo::Convert::NodeNameNormalization::normalize_node($arg);
- if ($normalized_menu_entry_name !~ /[^-]/) {
+ if (not $arg->{'contents'} or scalar(@{$arg->{'contents'}}) == 0) {
$self->_line_warn(sprintf(__("empty menu entry name in `%s'"),
- Texinfo::Convert::Texinfo::convert_to_texinfo($current)),
$source_info);
+ Texinfo::Convert::Texinfo::convert_to_texinfo($current)),
+ $source_info);
}
} elsif ($arg->{'type'} eq 'menu_entry_node') {
_isolate_last_space($self, $arg);
@@ -4303,7 +4303,6 @@ sub _parse_texi($$$)
'text' => $leading_text,
'parent' => $current },
{ 'type' => 'menu_entry_name',
- 'contents' => [],
'parent' => $current } ];
$current = $current->{'args'}->[-1];
}
@@ -4338,7 +4337,6 @@ sub _parse_texi($$$)
} elsif ($separator =~ /^:/) {
print STDERR "MENU ENTRY $separator\n" if ($self->{'DEBUG'});
push @{$current->{'args'}}, { 'type' => 'menu_entry_node',
- 'contents' => [],
'parent' => $current };
$current = $current->{'args'}->[-1];
# anything else is the end of the menu node following a menu_entry_name
diff --git a/tp/Texinfo/XS/parsetexi/end_line.c
b/tp/Texinfo/XS/parsetexi/end_line.c
index cbc6e1ae12..55f749e6ed 100644
--- a/tp/Texinfo/XS/parsetexi/end_line.c
+++ b/tp/Texinfo/XS/parsetexi/end_line.c
@@ -802,20 +802,21 @@ kdbinputstyle_invalid:
}
/* NODE->contents is the Texinfo for the specification of a node. This
- function sets three fields on the returned object:
+ function sets two fields on the returned object:
manual_content - Texinfo tree for a manual name extracted from the
node specification.
node_content - Texinfo tree for the node name on its own
- normalized - a string with the node name after HTML node name
- normalization is applied
Objects returned from this function are used as an 'extra' key in a
few places: the elements of a 'nodes_manuals' array (itself an extra key),
the 'menu_entry_node' key on a 'menu_entry' element (not to be confused
with an ET_menu_entry_node element, which occurs in the args of a
'menu_entry' element), and in the 'node_argument' key of a cross-reference
- command (like @xref). */
+ command (like @xref).
+
+ This function does not return 0 if there is no content for the node, as
+ the 'nodes_manuals' is delimited by a 0. */
NODE_SPEC_EXTRA *
parse_node_manual (ELEMENT *node)
{
diff --git a/tp/Texinfo/XS/parsetexi/menus.c b/tp/Texinfo/XS/parsetexi/menus.c
index 3999277a0c..976cad250c 100644
--- a/tp/Texinfo/XS/parsetexi/menus.c
+++ b/tp/Texinfo/XS/parsetexi/menus.c
@@ -51,7 +51,8 @@ register_extra_menu_entry_information (ELEMENT *current)
isolate_last_space (arg);
parsed_entry_node = parse_node_manual (arg);
- if (!parsed_entry_node)
+ if (!parsed_entry_node->manual_content
+ && !parsed_entry_node->node_content)
{
if (conf.show_menu)
line_error ("empty node name in menu entry");
diff --git a/tp/t/results/sectioning/in_menu_only_special_spaces_node.pl
b/tp/t/results/sectioning/in_menu_only_special_spaces_node.pl
index c346a105a7..72c533863f 100644
--- a/tp/t/results/sectioning/in_menu_only_special_spaces_node.pl
+++ b/tp/t/results/sectioning/in_menu_only_special_spaces_node.pl
@@ -193,8 +193,7 @@ $result_trees{'in_menu_only_special_spaces_node'} = {
}
],
"extra" => {
- "menu_entry_description" => {},
- "menu_entry_node" => undef
+ "menu_entry_description" => {}
},
"parent" => {},
"source_info" => {
@@ -238,8 +237,7 @@ $result_trees{'in_menu_only_special_spaces_node'} = {
}
],
"extra" => {
- "menu_entry_description" => {},
- "menu_entry_node" => undef
+ "menu_entry_description" => {}
},
"parent" => {},
"source_info" => {
@@ -1351,6 +1349,24 @@ $result_menus{'in_menu_only_special_spaces_node'} = {
$result_menus{'in_menu_only_special_spaces_node'}{'structure'}{'menu_child'}{'structure'}{'menu_up'}
= $result_menus{'in_menu_only_special_spaces_node'};
$result_errors{'in_menu_only_special_spaces_node'} = [
+ {
+ 'error_line' => 'empty node name in menu entry
+',
+ 'file_name' => 'in_menu_only_special_spaces_node.texi',
+ 'line_nr' => 7,
+ 'macro' => '',
+ 'text' => 'empty node name in menu entry',
+ 'type' => 'error'
+ },
+ {
+ 'error_line' => 'empty node name in menu entry
+',
+ 'file_name' => 'in_menu_only_special_spaces_node.texi',
+ 'line_nr' => 8,
+ 'macro' => '',
+ 'text' => 'empty node name in menu entry',
+ 'type' => 'error'
+ },
{
'error_line' => "empty node name after expansion `\x{2000}\x{2001}\x{2002}'
",
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: Fix both parsers to do the same tree with empty menu entry nodes,
Patrice Dumas <=