[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Gavin D. Smith |
Date: |
Sat, 7 May 2022 17:45:10 -0400 (EDT) |
branch: master
commit add50f7cd8255906540a9b4bf636642a7b9a79a7
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Sat May 7 22:44:59 2022 +0100
Reinstate empty contents
Reverse the following change, from 2022-04-20.
* 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.
With this reversion, I have run the test suite to pass both under
TEXINFO_XS=omit and TEXINFO_XS_PARSER=0.
There were various test failures with TEXINFO_XS=omit and
TEXINFO_XS_PARSER=0 due to inconsistent results.
Where an element can have contents, it will be simplest if
it always has the contents element, as in the C code there
is no distinction between an empty contents array and no
contents at all.
---
ChangeLog | 22 +++++++++++++++++++
tp/Texinfo/Common.pm | 10 ++++-----
tp/Texinfo/ParserNonXS.pm | 25 +++++++++++-----------
.../sectioning/in_menu_only_special_spaces_node.pl | 2 ++
4 files changed, 41 insertions(+), 18 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 09057610c2..b55bd48fdb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2022-05-07 Gavin Smith <gavinsmith0123@gmail.com>
+
+ Reinstate empty contents
+
+ Reverse the following change, from 2022-04-20.
+
+ * 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.
+
+ With this reversion, I have run the test suite to pass both under
+ TEXINFO_XS=omit and TEXINFO_XS_PARSER=0.
+
+ There were various test failures with TEXINFO_XS=omit and
+ TEXINFO_XS_PARSER=0 due to inconsistent results.
+
+ Where an element can have contents, it will be simplest if
+ it always has the contents element, as in the C code there
+ is no distinction between an empty contents array and no
+ contents at all.
+
2022-05-07 Gavin Smith <gavinsmith0123@gmail.com>
Fix segfault for empty contents
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index 4ee6e2a34f..4ac6bd848b 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -1,6 +1,6 @@
# Common.pm: definition of commands. Common code of other Texinfo modules.
#
-# Copyright 2010-2022 Free Software Foundation, Inc.
+# Copyright 2010-2020 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -1453,15 +1453,13 @@ sub parse_node_manual($)
{
my $label_contents_container = shift;
+ my @contents = @{$label_contents_container->{'contents'}};
+
my $manual;
my $result;
my ($end_paren, $spaces_after);
- 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'} =~ /^\(/) {
+ if ($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 4b18b10dd9..4ab5ee2ae0 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 !scalar(@{$current->{'contents'}}));
+ return if (!$current->{'contents'} or !@{$current->{'contents'}});
# Store a final comment command in the 'extra' hash.
- if ($current->{'contents'}->[-1]->{'cmdname'}
+ if (scalar(@{$current->{'contents'}}) >= 1
+ and $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'}
- or !scalar(@{$current->{'contents'}})
+ return if !@{$current->{'contents'}}
or !defined($current->{'contents'}->[-1]->{'text'})
or ($current->{'contents'}->[-1]->{'type'}
and (!$current->{'type'}
@@ -2401,8 +2401,7 @@ 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
- if (defined($modified_node_content));
+ $label_contents_container->{'contents'} = $modified_node_content;
return $parsed_node_manual;
}
@@ -2834,13 +2833,13 @@ sub _end_line($$$)
my $empty_menu_entry_node = 0;
my $end_comment;
if ($current->{'type'} eq 'menu_entry_node') {
- if ($current->{'contents'} and scalar(@{$current->{'contents'}})
+ if (@{$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 (not $current->{'contents'} or not scalar(@{$current->{'contents'}})
+ if (!@{$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'})
@@ -2884,7 +2883,7 @@ sub _end_line($$$)
}
if ($description_or_menu_comment) {
$current = $description_or_menu_comment;
- if ($current->{'contents'} and $current->{'contents'}->[-1]
+ if ($current->{'contents'}->[-1]
and $current->{'contents'}->[-1]->{'type'}
and $current->{'contents'}->[-1]->{'type'} eq 'preformatted') {
$current = $current->{'contents'}->[-1];
@@ -4303,6 +4302,7 @@ sub _parse_texi($$$)
'text' => $leading_text,
'parent' => $current },
{ 'type' => 'menu_entry_name',
+ 'contents' => [],
'parent' => $current } ];
$current = $current->{'args'}->[-1];
}
@@ -4337,6 +4337,7 @@ 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/t/results/sectioning/in_menu_only_special_spaces_node.pl
b/tp/t/results/sectioning/in_menu_only_special_spaces_node.pl
index 72c533863f..badb1646a2 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
@@ -167,6 +167,7 @@ $result_trees{'in_menu_only_special_spaces_node'} = {
"type" => "menu_entry_leading_text"
},
{
+ "contents" => [],
"parent" => {},
"type" => "menu_entry_node"
},
@@ -211,6 +212,7 @@ $result_trees{'in_menu_only_special_spaces_node'} = {
"type" => "menu_entry_leading_text"
},
{
+ "contents" => [],
"parent" => {},
"type" => "menu_entry_node"
},