[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/Transformations.pm (complete_node_me
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/Transformations.pm (complete_node_menu): handle empty nodes. |
Date: |
Sun, 18 Sep 2022 17:57:24 -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 dd19c0bbfc * tp/Texinfo/Transformations.pm (complete_node_menu):
handle empty nodes.
dd19c0bbfc is described below
commit dd19c0bbfc0f1abc3ff262322c070ed4d966745d
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Sep 18 23:57:13 2022 +0200
* tp/Texinfo/Transformations.pm (complete_node_menu): handle empty
nodes.
* tp/Texinfo/Structuring.pm (new_node_menu_entry): call confess if
there are undef contents in node contents.
* tp/Texinfo/ParserNonXS.pm (_parse_node_manual): remove useless
condition.
---
ChangeLog | 11 +++++++++++
tp/Texinfo/ParserNonXS.pm | 2 +-
tp/Texinfo/Structuring.pm | 7 +++++--
tp/Texinfo/Transformations.pm | 8 ++++++--
tp/t/automatic_menus.t | 25 +++++++++++++++++++++++++
5 files changed, 48 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e9d37dcf52..2e33398e47 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2022-09-18 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Transformations.pm (complete_node_menu): handle empty
+ nodes.
+
+ * tp/Texinfo/Structuring.pm (new_node_menu_entry): call confess if
+ there are undef contents in node contents.
+
+ * tp/Texinfo/ParserNonXS.pm (_parse_node_manual): remove useless
+ condition.
+
2022-09-18 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/Common.pm (parse_node_manual): return directly undef
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 8e83716b7c..9985d57836 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -2411,7 +2411,7 @@ sub _parse_node_manual($)
my ($parsed_node_manual, $modified_node_content)
= Texinfo::Common::parse_node_manual($label_contents_container);
$label_contents_container->{'contents'} = $modified_node_content
- if ($modified_node_content and scalar(@$modified_node_content) > 0);
+ if ($modified_node_content);
return $parsed_node_manual;
}
diff --git a/tp/Texinfo/Structuring.pm b/tp/Texinfo/Structuring.pm
index 849fed53ff..5e1141979a 100644
--- a/tp/Texinfo/Structuring.pm
+++ b/tp/Texinfo/Structuring.pm
@@ -26,7 +26,7 @@ use 5.00405;
# See comment at start of HTML.pm
use if $] >= 5.012, feature => 'unicode_strings';
-use Carp qw(cluck);
+use Carp qw(cluck confess);
use strict;
@@ -1423,7 +1423,8 @@ sub new_node_menu_entry
{
my ($node, $use_sections) = @_;
- my $node_contents = $node->{'extra'}->{'node_content'};
+ my $node_contents;
+ $node_contents = $node->{'extra'}->{'node_content'} if ($node->{'extra'});
# can happen with node without argument or with empty argument
return undef if (not defined($node_contents));
@@ -1517,6 +1518,8 @@ sub new_block_command($$$)
'extra' => { 'spaces_after_argument' => "\n",}}];
foreach my $content (@$block_contents) {
+ confess("new_block_command: undef \$block_contents content")
+ if (!defined($content));
$content->{'parent'} = $new_block;
}
diff --git a/tp/Texinfo/Transformations.pm b/tp/Texinfo/Transformations.pm
index b17cef0b46..427868f8ee 100644
--- a/tp/Texinfo/Transformations.pm
+++ b/tp/Texinfo/Transformations.pm
@@ -431,7 +431,9 @@ sub complete_node_menu($;$)
my @pending;
my $current_menu;
foreach my $node_entry (@node_childs) {
- if ($existing_entries{$node_entry->{'extra'}->{'normalized'}}) {
+ if ($node_entry->{'extra'}
+ and defined($node_entry->{'extra'}->{'normalized'})
+ and $existing_entries{$node_entry->{'extra'}->{'normalized'}}) {
my $entry;
($current_menu, $entry)
= @{$existing_entries{$node_entry->{'extra'}->{'normalized'}}};
@@ -450,7 +452,9 @@ sub complete_node_menu($;$)
} else {
my $entry = Texinfo::Structuring::new_node_menu_entry($node_entry,
$use_sections);
- push @pending, $entry;
+ # not defined $entry should mean an empty node. We do not warn as
+ # we try, in general, to be silent in the transformations.
+ push @pending, $entry if (defined($entry));
}
}
if (scalar(@pending)) {
diff --git a/tp/t/automatic_menus.t b/tp/t/automatic_menus.t
index 7ebf020919..c3cb50c9f0 100644
--- a/tp/t/automatic_menus.t
+++ b/tp/t/automatic_menus.t
@@ -123,6 +123,31 @@ test('@node Top
@chapter chap2
', 'menu completed before');
+test('@node Top
+@top top
+
+@node @
+@chapter @
+
+@node
+@chapter
+
+@node @code{ }
+@chapter @code{ }
+',
+'@node Top
+@top top
+
+@node @
+@chapter @
+
+@node
+@chapter
+
+@node @code{ }
+@chapter @code{ }
+', 'empty nodes ');
+
my $colon_in_menu_entry_text = '@node Top
@top top
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/Transformations.pm (complete_node_menu): handle empty nodes.,
Patrice Dumas <=