[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
texinfo/tp Texinfo/Parser.pm Texinfo/Structurin...
From: |
Patrice Dumas |
Subject: |
texinfo/tp Texinfo/Parser.pm Texinfo/Structurin... |
Date: |
Sun, 15 Apr 2012 22:34:32 +0000 |
CVSROOT: /sources/texinfo
Module name: texinfo
Changes by: Patrice Dumas <pertusus> 12/04/15 22:34:32
Modified files:
tp/Texinfo : Parser.pm Structuring.pm
tp/t : automatic_nodes.t
Log message:
HAndle correctly erroneous nodes when adding nodes.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Parser.pm?cvsroot=texinfo&r1=1.374&r2=1.375
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Structuring.pm?cvsroot=texinfo&r1=1.127&r2=1.128
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/automatic_nodes.t?cvsroot=texinfo&r1=1.9&r2=1.10
Patches:
Index: Texinfo/Parser.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Parser.pm,v
retrieving revision 1.374
retrieving revision 1.375
diff -u -b -r1.374 -r1.375
--- Texinfo/Parser.pm 14 Apr 2012 16:10:17 -0000 1.374
+++ Texinfo/Parser.pm 15 Apr 2012 22:34:31 -0000 1.375
@@ -410,7 +410,7 @@
# commands that may happen in simple text arguments
my %in_simple_text_commands = %in_sectioning_command_line_commands;
-foreach my $not_in_simple_text_command('xref','ref','pxref', 'inforef') {
+foreach my $not_in_simple_text_command('xref', 'ref', 'pxref', 'inforef') {
delete $in_simple_text_commands{$not_in_simple_text_command};
}
Index: Texinfo/Structuring.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Structuring.pm,v
retrieving revision 1.127
retrieving revision 1.128
diff -u -b -r1.127 -r1.128
--- Texinfo/Structuring.pm 7 Mar 2012 00:44:16 -0000 1.127
+++ Texinfo/Structuring.pm 15 Apr 2012 22:34:31 -0000 1.128
@@ -1125,6 +1125,8 @@
} elsif ($sectioning_commands{$command->{'cmdname'}}) {
$tree = $command->{'extra'}->{'misc_content'};
}
+ } else {
+ return "Not a root command";
}
return '@'.$command->{'cmdname'}. ' '
.Texinfo::Convert::Texinfo::convert ({'contents' => $tree})
@@ -1354,7 +1356,9 @@
}
push @{$node->{'extra'}->{'nodes_manuals'}}, $parsed_node;
- Texinfo::Parser::_register_label($self, $node, $parsed_node, undef);
+ if (!Texinfo::Parser::_register_label($self, $node, $parsed_node, undef)) {
+ print STDERR "BUG: node unique, register failed:
$parsed_node->{'normalized'}\n";
+ }
push @{$self->{'nodes'}}, $node;
return $node;
}
@@ -1366,8 +1370,7 @@
my $type = shift;
my $current = shift;
my $nodes = shift;
- my $new_node = $nodes->[0];
- my $previous_node = $nodes->[1];
+ my ($new_node, $previous_node) = @{$nodes};
if ($current->{'cmdname'} and $current->{'cmdname'} eq 'menu') {
if ($previous_node) {
@@ -1395,7 +1398,16 @@
if ($previous_node
and (!$current->{'extra'}->{'index_entry'}->{'node'}
or $current->{'extra'}->{'index_entry'}->{'node'} ne
$previous_node)) {
- print STDERR "Bug: index entry $current not in previous node
$previous_node\n";
+ print STDERR "Bug: index entry $current (".
+ Texinfo::Convert::Texinfo::convert ({'contents' =>
$current->{'extra'}->{'index_entry'}->{'content'}})
+ .") not in previous node $previous_node\n";
+ print STDERR " previous node:
"._print_root_command_texi($previous_node)."\n";
+ if ($current->{'extra'}->{'index_entry'}->{'node'}) {
+ print STDERR " current node: ".
+
_print_root_command_texi($current->{'extra'}->{'index_entry'}->{'node'})."\n";
+ } else {
+ print STDERR " current node not set\n";
+ }
}
$current->{'extra'}->{'index_entry'}->{'node'} = $new_node;
}
@@ -1436,8 +1448,11 @@
[$new_node, $previous_node]);
}
}
+ # check normalized to avoid erroneous nodes, such as duplicates
$previous_node = $content
- if ($content->{'cmdname'} and $content->{'cmdname'} eq 'node');
+ if ($content->{'cmdname'}
+ and $content->{'cmdname'} eq 'node'
+ and $content->{'extra'}->{'normalized'});
push @contents, $content;
}
return address@hidden;
Index: t/automatic_nodes.t
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/automatic_nodes.t,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- t/automatic_nodes.t 7 Mar 2012 00:44:16 -0000 1.9
+++ t/automatic_nodes.t 15 Apr 2012 22:34:32 -0000 1.10
@@ -1,7 +1,7 @@
use strict;
use Test::More;
-BEGIN { plan tests => 24 };
+BEGIN { plan tests => 25 };
use lib 'maintain/lib/Unicode-EastAsianWidth/lib/';
use lib 'maintain/lib/libintl-perl/lib/';
@@ -69,7 +69,6 @@
', Texinfo::Convert::Texinfo::convert($node), 'duplicate node added');
#print STDERR Texinfo::Convert::Texinfo::convert($node);
-
my $sections_text =
'@top top section
@@ -173,4 +172,22 @@
'index entry reassociated');
#print STDERR Texinfo::Convert::Texinfo::convert($tree);
+$parser = Texinfo::Parser::parser();
+my $text_duplicate_nodes =
+'@node NAME
address@hidden DESCRIPTION
+
address@hidden NAME
address@hidden SEE ALSO
+
address@hidden entry
+';
+$tree = $parser->parse_texi_text ($text_duplicate_nodes);
+# In fact, here we also check that there is no debugging message...
+$new_content
+ = Texinfo::Structuring::insert_nodes_for_sectioning_commands($parser,
$tree);
+($index_names, $merged_indices, $index_entries) =
$parser->indices_information();
+$labels = $parser->labels_information();
+is ($labels->{'SEE-ALSO'}, $index_entries->{'cp'}->[0]->{'node'},
+ 'index entry reassociated duplicate node ignored');
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- texinfo/tp Texinfo/Parser.pm Texinfo/Structurin...,
Patrice Dumas <=