[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
texinfo/tp/Texinfo Parser.pm
From: |
Patrice Dumas |
Subject: |
texinfo/tp/Texinfo Parser.pm |
Date: |
Sun, 24 Oct 2010 18:22:26 +0000 |
CVSROOT: /sources/texinfo
Module name: texinfo
Changes by: Patrice Dumas <pertusus> 10/10/24 18:22:26
Modified files:
tp/Texinfo : Parser.pm
Log message:
Keep the information on merged indices.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Parser.pm?cvsroot=texinfo&r1=1.105&r2=1.106
Patches:
Index: Parser.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Parser.pm,v
retrieving revision 1.105
retrieving revision 1.106
diff -u -b -r1.105 -r1.106
--- Parser.pm 24 Oct 2010 17:51:45 -0000 1.105
+++ Parser.pm 24 Oct 2010 18:22:26 -0000 1.106
@@ -412,7 +412,6 @@
);
my %forbidden_index_name = ();
-my @default_index_prefixes;
my %index_names = (
'cp' => {'cp' => 0,'c' => 0},
@@ -426,7 +425,6 @@
foreach my $name(keys(%index_names)) {
foreach my $prefix (keys %{$index_names{$name}}) {
$forbidden_index_name{$prefix} = 1;
- push @default_index_prefixes, $prefix;
}
}
@@ -631,6 +629,17 @@
return $struct;
}
+sub _enter_index_commands ($$)
+{
+ my $self = shift;
+ my $index_name = shift;
+ foreach my $prefix (keys (%{$self->{'index_names'}->{$index_name}})) {
+ $self->{'misc_commands'}->{$prefix.'index'} = 'line';
+ $self->{'no_paragraph_commands'}->{$prefix.'index'} = 1;
+ $self->{'simple_text_commands'}->{$prefix.'index'} = 1;
+ }
+}
+
# initialize a parser
sub parser(;$$)
{
@@ -680,10 +689,17 @@
$parser->{'misc_commands'} = _deep_copy (\%misc_commands);
$parser->{'simple_text_commands'} = _deep_copy (\%simple_text_commands);
$parser->{'no_paragraph_commands'} = { %default_no_paragraph_commands };
- foreach my $name (@{$parser->{'indices'}}, @default_index_prefixes) {
- $parser->{'misc_commands'}->{$name.'index'} = 'line';
- $parser->{'no_paragraph_commands'}->{$name.'index'} = 1;
- $parser->{'simple_text_commands'}->{$name.'index'} = 1;
+ $parser->{'index_names'} = _deep_copy (\%index_names);
+ if (ref($parser->{'indices'}) eq 'HASH') {
+ %{$parser->{'index_names'}} = (%{$parser->{'index_names'}},
+ %{$parser->{'indices'}});
+ } else {
+ foreach my $name (@{$parser->{'indices'}}) {
+ $parser->{'index_names'}->{$name} = {$name => 0};
+ }
+ }
+ foreach my $index (keys (%{$parser->{'index_names'}})) {
+ $parser->_enter_index_commands($index);
}
$parser->{'errors_warnings'} = [];
$parser->{'errors_nrs'} = 0;
@@ -3052,10 +3068,11 @@
_line_error($self, sprintf($self->
__("Reserved index name %s"),$name), $line_nr);
} else {
+ my $in_code = 0;
+ $in_code = 1 if ($command eq 'defcodeindex');
$args = [$name];
- $self->{'misc_commands'}->{$name.'index'} = 'line';
- $self->{'no_paragraph_commands'}->{$name.'index'} = 1;
- $self->{'simple_text_commands'}->{$name.'index'} = 1;
+ $self->{'index_names'}->{$name} = {$name => $in_code};
+ $self->_enter_index_commands($name);
}
} else {
_line_error ($self, sprintf($self->
@@ -3067,12 +3084,26 @@
my $index_from = $1;
my $index_to = $2;
_line_error ($self, sprintf($self->__("Unknown from index `%s' in
address@hidden"), $index_from, $command), $line_nr)
- unless $self->{'misc_commands'}->{$index_from.'index'};
+ unless $self->{'index_names'}->{$index_from};
_line_error ($self, sprintf($self->__("Unknown to index name `%s' in
address@hidden"), $index_to, $command), $line_nr)
- unless $self->{'misc_commands'}->{$index_to.'index'};
- if ($self->{'misc_commands'}->{$index_from.'index'}
- and $self->{'misc_commands'}->{$index_to.'index'}) {
+ unless $self->{'index_names'}->{$index_to};
+ if ($self->{'index_names'}->{$index_from}
+ and $self->{'index_names'}->{$index_to}) {
$args = [$index_from, $index_to];
+ my $current_to = $index_to;
+ # find the merged indices recursively avoiding loops
+ while ($current_to ne $index_from
+ and $self->{'merged_indices'}->{$current_to}) {
+ $current_to = $self->{'merged_indices'}->{$current_to};
+ }
+ if ($current_to ne $index_from) {
+ my $in_code = 0;
+ $in_code = 1 if ($command eq 'syncodeindex');
+ $self->{'merged_indices'}->{$index_from} = $current_to;
+ foreach my $prefix (keys(%{$self->{'index_names'}->{$index_from}})) {
+ $self->{'index_names'}->{$current_to}->{$prefix} = $in_code;
+ }
+ }
}
} else {
_line_error ($self, sprintf($self->__("Bad argument to address@hidden:
%s"), $command, $line), $line_nr);
- texinfo/tp/Texinfo Parser.pm, Patrice Dumas, 2010/10/04
- texinfo/tp/Texinfo Parser.pm, Patrice Dumas, 2010/10/04
- texinfo/tp/Texinfo Parser.pm, Patrice Dumas, 2010/10/09
- texinfo/tp/Texinfo Parser.pm, Patrice Dumas, 2010/10/14
- texinfo/tp/Texinfo Parser.pm, Patrice Dumas, 2010/10/14
- texinfo/tp/Texinfo Parser.pm, Patrice Dumas, 2010/10/16
- texinfo/tp/Texinfo Parser.pm, Patrice Dumas, 2010/10/18
- texinfo/tp/Texinfo Parser.pm, Patrice Dumas, 2010/10/19
- texinfo/tp/Texinfo Parser.pm, Patrice Dumas, 2010/10/19
- texinfo/tp/Texinfo Parser.pm, Patrice Dumas, 2010/10/24
- texinfo/tp/Texinfo Parser.pm,
Patrice Dumas <=