[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[7240] remove _ignore_global_commands
From: |
gavinsmith0123 |
Subject: |
[7240] remove _ignore_global_commands |
Date: |
Sun, 26 Jun 2016 13:36:30 +0000 (UTC) |
Revision: 7240
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7240
Author: gavin
Date: 2016-06-26 13:36:28 +0000 (Sun, 26 Jun 2016)
Log Message:
-----------
remove _ignore_global_commands
Modified Paths:
--------------
trunk/ChangeLog
trunk/tp/Texinfo/Parser.pm
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2016-06-26 12:49:50 UTC (rev 7239)
+++ trunk/ChangeLog 2016-06-26 13:36:28 UTC (rev 7240)
@@ -1,5 +1,16 @@
2016-06-26 Gavin Smith <address@hidden>
+ * tp/Texinfo/Parser.pm (_parse_texi, _register_global_command)
+ (_register_label, _enter_index_entry, _end_line)
+ (_parse_line_command_args, _parse_special_misc_commands): Remove
+ uses of _ignore_global_commands. Remove some commented-out
+ lines of code.
+ (parser, simple_parser): Remove reference to
+ $self->{'expanded_formats_stack'}.
+ (_ignore_global_commands): Removed.
+
+2016-06-26 Gavin Smith <address@hidden>
+
* tp/Texinfo/Parser.pm (_parse_texi): For raw block commands
(like @tex) and raw inline commands (@inlinefmt), skip over the
part of the conditional that isn't expanded, instead of parsing
Modified: trunk/tp/Texinfo/Parser.pm
===================================================================
--- trunk/tp/Texinfo/Parser.pm 2016-06-26 12:49:50 UTC (rev 7239)
+++ trunk/tp/Texinfo/Parser.pm 2016-06-26 13:36:28 UTC (rev 7240)
@@ -552,14 +552,6 @@
return $struct;
}
-# return true if effect of global commands should be ignored.
-sub _ignore_global_commands($)
-{
- my $self = shift;
- return 0;
- return !$self->{'expanded_formats_stack'}->[-1];
-}
-
sub _setup_conf($$$)
{
my $parser = shift;
@@ -701,7 +693,6 @@
$parser->{'regions_stack'} = [];
$parser->{'macro_stack'} = [];
$parser->{'conditionals_stack'} = [];
- $parser->{'expanded_formats_stack'} = [1];
# turn the array to a hash for speed. Not sure it really matters for such
# a small array.
@@ -756,7 +747,6 @@
$parser->{'regions_stack'} = [];
$parser->{'macro_stack'} = [];
$parser->{'conditionals_stack'} = [];
- $parser->{'expanded_formats_stack'} = [1];
# turn the array to a hash for speed. Not sure it really matters for such
# a small array.
@@ -1128,8 +1118,7 @@
$command = 'shortcontents';
}
if ($self->{'global_commands'}->{$command} and $command ne 'author') {
- push @{$self->{'extra'}->{$command}}, $current
- unless (_ignore_global_commands($self));
+ push @{$self->{'extra'}->{$command}}, $current;
$current->{'line_nr'} = $line_nr if (!$current->{'line_nr'});
return 1;
} elsif ($global_unique_commands{$command}) {
@@ -1141,8 +1130,7 @@
$self->line_warn(sprintf($self->__('multiple @%s'),
$current->{'cmdname'}), $line_nr);
} else {
- $self->{'extra'}->{$current->{'cmdname'}} = $current
- unless (_ignore_global_commands($self));
+ $self->{'extra'}->{$current->{'cmdname'}} = $current;
}
return 1;
}
@@ -1739,8 +1727,6 @@
or $menu_commands{$current->{'cmdname'}}
or $format_raw_commands{$current->{'cmdname'}}) {
my $context = pop @{$self->{'context_stack'}};
- #pop @{$self->{'expanded_formats_stack'}}
- # if ($format_raw_commands{$current->{'cmdname'}});
}
pop @{$self->{'regions_stack'}}
if ($region_commands{$current->{'cmdname'}});
@@ -1835,7 +1821,6 @@
$self->_bug_message("context $context instead of rawpreformatted for
$closed_command",
$line_nr, $current);
}
- #pop @{$self->{'expanded_formats_stack'}};
} elsif ($menu_commands{$current->{'cmdname'}}) {
my $context = pop @{$self->{'context_stack'}};
# may be in menu, but context is preformatted if in a preformatted too.
@@ -2516,11 +2501,8 @@
my $label = shift;
my $line_nr = shift;
my $normalized = $label->{'normalized'};
- if (_ignore_global_commands($self)) {
- $current->{'extra'}->{'normalized'} = $normalized;
- $current->{'extra'}->{'node_content'} = $label->{'node_content'};
- return 0;
- } elsif ($self->{'labels'}->{$normalized}) {
+
+ if ($self->{'labels'}->{$normalized}) {
$self->line_error(sprintf($self->__("address@hidden `%s' previously
defined"),
$current->{'cmdname'},
Texinfo::Convert::Texinfo::convert({'contents' =>
@@ -2572,12 +2554,9 @@
my $index_name = $self->{'command_index'}->{$command_container};
my $index = $self->{'index_names'}->{$index_name};
- my $number;
- unless (_ignore_global_commands($self)) {
- $number = (defined($index->{'index_entries'})
- ? (scalar(@{$index->{'index_entries'}}) + 1)
- : 1);
- }
+ my $number = (defined($index->{'index_entries'})
+ ? (scalar(@{$index->{'index_entries'}}) + 1)
+ : 1);
my $index_entry = { 'index_name' => $index_name,
'index_at_command' => $command,
'index_type_command' => $command_container,
@@ -2594,10 +2573,7 @@
$self->line_warn(sprintf($self->__("entry for index `%s' outside of any
node"),
$index_name), $line_nr);
}
- #print STDERR "INDEX ENTRY address@hidden $index_name($number)\n";
- unless (_ignore_global_commands($self)) {
- push @{$index->{'index_entries'}}, $index_entry;
- }
+ push @{$index->{'index_entries'}}, $index_entry;
$current->{'extra'}->{'index_entry'} = $index_entry;
}
@@ -2957,8 +2933,7 @@
_parse_float_type($float);
$type = $float->{'extra'}->{'type'}->{'normalized'};
}
- push @{$self->{'floats'}->{$type}}, $float
- unless (_ignore_global_commands($self));
+ push @{$self->{'floats'}->{$type}}, $float;
$float->{'extra'}->{'float_section'} = $self->{'current_section'}
if (defined($self->{'current_section'}));
}
@@ -3224,30 +3199,28 @@
$self->__("encoding `%s' is not a canonical texinfo
encoding"),
$text)
if (!$texinfo_encoding or $texinfo_encoding ne lc($text));
- if (! _ignore_global_commands($self)) {
+ if ($input_encoding) {
+ $current->{'extra'}->{'input_encoding_name'} = $input_encoding;
+ }
+ if (!$perl_encoding) {
+ $self->_command_warn($current, $line_nr,
+ $self->__("unrecognized encoding name `%s'"), $text);
+ } else {
+ $current->{'extra'}->{'input_perl_encoding'} = $perl_encoding;
+
if ($input_encoding) {
- $current->{'extra'}->{'input_encoding_name'} = $input_encoding;
+ if (!$self->{'set'}->{'INPUT_ENCODING_NAME'}) {
+ $self->{'INPUT_ENCODING_NAME'} = $input_encoding;
+ $self->{'info'}->{'input_encoding_name'} = $input_encoding;
+ }
}
- if (!$perl_encoding) {
- $self->_command_warn($current, $line_nr,
- $self->__("unrecognized encoding name `%s'"), $text);
- } else {
- $current->{'extra'}->{'input_perl_encoding'} = $perl_encoding;
- if ($input_encoding) {
- if (!$self->{'set'}->{'INPUT_ENCODING_NAME'}) {
- $self->{'INPUT_ENCODING_NAME'} = $input_encoding;
- $self->{'info'}->{'input_encoding_name'} = $input_encoding;
- }
+ if (!$self->{'set'}->{'INPUT_PERL_ENCODING'}) {
+ $self->{'INPUT_PERL_ENCODING'} = $perl_encoding;
+ $self->{'info'}->{'input_perl_encoding'} = $perl_encoding;
+ foreach my $input (@{$self->{'input'}}) {
+ binmode($input->{'fh'}, ":encoding($perl_encoding)") if
($input->{'fh'});
}
-
- if (!$self->{'set'}->{'INPUT_PERL_ENCODING'}) {
- $self->{'INPUT_PERL_ENCODING'} = $perl_encoding;
- $self->{'info'}->{'input_perl_encoding'} = $perl_encoding;
- foreach my $input (@{$self->{'input'}}) {
- binmode($input->{'fh'}, ":encoding($perl_encoding)") if
($input->{'fh'});
- }
- }
}
}
} elsif ($command eq 'documentlanguage') {
@@ -3256,8 +3229,7 @@
foreach my $message(@messages) {
$self->_command_warn($current, $line_nr, $message);
}
- if (!$self->{'set'}->{'documentlanguage'}
- and !_ignore_global_commands($self)) {
+ if (!$self->{'set'}->{'documentlanguage'}) {
$self->{'documentlanguage'} = $text;
}
}
@@ -3420,8 +3392,6 @@
delete $current->{'remaining_args'};
$current->{'contents'} = [];
- # we never should be in a raw format bock, so we don't check for
- # _ignore_global_commands($self)
# associate the section (not part) with the current node.
if ($command ne 'node' and $command ne 'part') {
if ($self->{'current_node'}
@@ -3828,8 +3798,7 @@
$self->_strip_macrobody_leading_space(
Texinfo::Convert::Texinfo::convert({ 'contents'
=> $current->{'contents'} }));
- if ($current->{'args'} and $current->{'args'}->[0]
- and !_ignore_global_commands($self)) {
+ if ($current->{'args'} and $current->{'args'}->[0]) {
my $name = $current->{'args'}->[0]->{'text'};
if (exists($self->{'macros'}->{$name})) {
$self->line_warn(sprintf($self->__("macro `%s' previously
defined"),
@@ -4466,14 +4435,12 @@
$misc->{'extra'}->{'misc_args'} = $args
if (scalar(@$args) and $arg_spec ne 'skipline');
}
- if (! _ignore_global_commands($self)) {
- if ($command eq 'raisesections') {
- $self->{'sections_level'}++;
- } elsif ($command eq 'lowersections') {
- $self->{'sections_level'}--;
- } elsif ($command eq 'novalidate') {
- $self->{'info'}->{'novalidate'} = 1;
- }
+ if ($command eq 'raisesections') {
+ $self->{'sections_level'}++;
+ } elsif ($command eq 'lowersections') {
+ $self->{'sections_level'}--;
+ } elsif ($command eq 'novalidate') {
+ $self->{'info'}->{'novalidate'} = 1;
}
_mark_and_warn_invalid($self, $command, $invalid_parent,
$line_nr, $misc);
@@ -4706,8 +4673,7 @@
$line_nr, $misc);
_register_global_command($self, $command, $misc, $line_nr);
- if ($command eq 'dircategory'
- and ! _ignore_global_commands($self)) {
+ if ($command eq 'dircategory') {
push @{$self->{'info'}->{'dircategory_direntry'}}, $misc;
}
# @-command with matching @end opening
@@ -4869,7 +4835,6 @@
'text' => '',
'parent' => $current };
next;
- #push @{$self->{'expanded_formats_stack'}}, 0;
}
}
if ($region_commands{$command}) {
@@ -4887,30 +4852,28 @@
} else {
push @{$self->{'context_stack'}}, 'menu';
}
- if (! _ignore_global_commands($self)) {
- push @{$self->{'info'}->{'dircategory_direntry'}}, $block
- if ($command eq 'direntry');
- if ($self->{'current_node'}) {
- if ($command eq 'direntry') {
- if ($self->{'SHOW_MENU'}) {
- $self->line_warn($self->__("address@hidden after first
node"),
- $line_nr);
- }
- } elsif ($command eq 'menu') {
- push @{$self->{'current_node'}->{'menus'}}, $current;
- }
- } elsif ($command ne 'direntry') {
+ push @{$self->{'info'}->{'dircategory_direntry'}}, $block
+ if ($command eq 'direntry');
+ if ($self->{'current_node'}) {
+ if ($command eq 'direntry') {
if ($self->{'SHOW_MENU'}) {
- $self->line_error(sprintf($self->__("address@hidden seen
before first address@hidden"),
- $command), $line_nr);
- $self->line_error($self->__(
- "perhaps your address@hidden node should be wrapped in address@hidden
rather than address@hidden"),
- $line_nr, 1);
+ $self->line_warn($self->__("address@hidden after first
node"),
+ $line_nr);
}
- if ($command eq 'menu') {
- push @{$self->{'info'}->{'unassociated_menus'}},
$current;
- }
+ } elsif ($command eq 'menu') {
+ push @{$self->{'current_node'}->{'menus'}}, $current;
}
+ } elsif ($command ne 'direntry') {
+ if ($self->{'SHOW_MENU'}) {
+ $self->line_error(sprintf($self->__("address@hidden seen
before first address@hidden"),
+ $command), $line_nr);
+ $self->line_error($self->__(
+ "perhaps your address@hidden node should be wrapped in address@hidden
rather than address@hidden"),
+ $line_nr, 1);
+ }
+ if ($command eq 'menu') {
+ push @{$self->{'info'}->{'unassociated_menus'}}, $current;
+ }
}
}
$current->{'args'} = [ {
@@ -5055,8 +5018,6 @@
= $current->{'contents'}->[-1];
}
if ($inline_commands{$command}) {
- # this is changed when the first argument is known.
- #push @{$self->{'expanded_formats_stack'}}, 0;
push @{$self->{'context_stack'}}, $command
if ($command eq 'inlineraw');
}
@@ -5095,8 +5056,7 @@
# code
} elsif ($self->{'context_stack'}->[-1] eq 'math'
or $self->{'context_stack'}->[-1] eq 'rawpreformatted'
- or $self->{'context_stack'}->[-1] eq 'inlineraw'
- or $self->_ignore_global_commands()) {
+ or $self->{'context_stack'}->[-1] eq 'inlineraw') {
push @{$current->{'contents'}},
{ 'type' => 'bracketed', 'contents' => [],
'parent' => $current, 'line_nr' => $line_nr };
@@ -5179,8 +5139,7 @@
if (defined($parsed_ref_node));
if ($closed_command ne 'inforef'
and !defined($args[3]) and !defined($args[4])
- and !$parsed_ref_node->{'manual_content'}
- and ! _ignore_global_commands($self)) {
+ and !$parsed_ref_node->{'manual_content'}) {
push @{$self->{'internal_references'}}, $ref;
}
}
@@ -5240,7 +5199,6 @@
die;
}
}
- #pop @{$self->{'expanded_formats_stack'}};
}
if (address@hidden>{'args'}}
or address@hidden>{'extra'}->{'brace_command_contents'}}
@@ -5250,13 +5208,10 @@
$current_command->{'cmdname'}), $line_nr);
}
} elsif ($current->{'parent'}->{'cmdname'} eq 'errormsg') {
- if (! _ignore_global_commands($self)) {
- my $error_message_text
- = Texinfo::Convert::Text::convert($current,
- {Texinfo::Common::_convert_text_options($self)});
- $self->line_error($error_message_text, $line_nr);
- }
-
+ my $error_message_text
+ = Texinfo::Convert::Text::convert($current,
+ {Texinfo::Common::_convert_text_options($self)});
+ $self->line_error($error_message_text, $line_nr);
} elsif ($current->{'parent'}->{'cmdname'} eq 'U') {
my $arg
= Texinfo::Convert::Text::convert($current,
@@ -5547,12 +5502,6 @@
}
@{$self->{'context_stack'}} = ($self->{'context'});
}
- if (@{$self->{'expanded_formats_stack'}} != 1) {
- if ($self->{'DEBUG'}) {
- print STDERR "EXPANDED_FORMATS_STACK no empty end _parse_texi:
".join('|', @{$self->{'expanded_formats_stack'}})."\n";
- }
- @{$self->{'expanded_formats_stack'}} =
($self->{'expanded_formats_stack'}->[0]);
- }
return $root;
}
@@ -5594,7 +5543,6 @@
my $remaining;
if ($command eq 'set') {
# REVALUE
- #if ($line =~ s/^\s+([\w\-]+)(\s+(.*?))\s*$//) {
if ($line =~
/^\s+([\w\-][^\s{\\}~`\^+"<>|@]*)(\@(c|comment)((\@|\s+).*)?|[^\S\f]+(.*?))?[^\S\f]*$/)
{
if ($line =~ s/\@(c|comment)((\@|\s+).*)?$//) {
$has_comment = 1;
@@ -5604,8 +5552,7 @@
my $arg = $3;
$arg = '' if (!defined($arg));
$args = [$name, $arg];
- $self->{'values'}->{$name} = $arg
- unless(_ignore_global_commands($self));
+ $self->{'values'}->{$name} = $arg;
} elsif ($line !~ /\S/) {
$self->line_error(sprintf($self->
__("%c%s requires a name"), ord('@'), $command), $line_nr);
@@ -5617,11 +5564,8 @@
# REVALUE
if ($line =~
/^\s+([\w\-][^\s{\\}~`\^+"<>|@]*)\s*(\@(c|comment)((\@|\s+).*)?)?$/) {
$args = [$1];
- delete $self->{'values'}->{$1}
- unless(_ignore_global_commands($self));
+ delete $self->{'values'}->{$1};
$has_comment = 1 if (defined($3));
- #$remaining = $line;
- #$remaining =~ s/^\s+([\w\-]+)\s*(\@(c|comment)((\@|\s+).*)?)?//;
} elsif ($line !~ /\S/) {
$self->line_error(sprintf($self->
__("%c%s requires a name"), ord('@'), $command), $line_nr);
@@ -5633,8 +5577,7 @@
# REMACRO
if ($line =~
/^\s+([[:alnum:]][[:alnum:]\-]*)\s*(\@(c|comment)((\@|\s+).*)?)?$/) {
$args = [$1];
- delete $self->{'macros'}->{$1}
- unless(_ignore_global_commands($self));
+ delete $self->{'macros'}->{$1};
$has_comment = 1 if (defined($3));
print STDERR "UNMACRO $1\n" if ($self->{'DEBUG'});
} elsif ($line !~ /\S/) {
@@ -5648,8 +5591,7 @@
# REMACRO
if ($line =~ /^\s+@([[:alnum:]][[:alnum:]\-]*)({})?\s*/) {
$args = ['@'.$1];
- $self->{'clickstyle'} = $1
- unless(_ignore_global_commands($self));
+ $self->{'clickstyle'} = $1;
$remaining = $line;
$remaining =~
s/^\s+@([[:alnum:]][[:alnum:]\-]*)({})?\s*(\@(c|comment)((\@|\s+).*)?)?//;
$has_comment = 1 if (defined($4));
@@ -5734,8 +5676,7 @@
my $new_command = $1;
my $existing_command = $3;
$args = [$1, $3];
- $self->{'aliases'}->{$new_command} = $existing_command
- unless (_ignore_global_commands($self));
+ $self->{'aliases'}->{$new_command} = $existing_command;
if (exists($block_commands{$existing_command})) {
$self->line_warn(sprintf($self->
__("environment command %s as argument to
address@hidden"),
@@ -5750,8 +5691,7 @@
# REMACRO
if ($line =~
s/^([[:alnum:]][[:alnum:]\-]*)\s*,\s*([^\s,]*)\s*,\s*([^\s,]*)$//) {
$args = [$1, $2, $3 ];
- $self->{'definfoenclose'}->{$1} = [ $2, $3 ]
- unless (_ignore_global_commands($self));
+ $self->{'definfoenclose'}->{$1} = [ $2, $3 ];
print STDERR "DEFINFOENCLOSE address@hidden: $2, $3\n" if
($self->{'DEBUG'});
} else {
$self->line_error(sprintf($self->
@@ -5791,19 +5731,17 @@
my $in_code = 0;
$in_code = 1 if ($command eq 'defcodeindex');
$args = [$name];
- if (! _ignore_global_commands($self)) {
- $self->{'index_names'}->{$name} = {'in_code' => $in_code};
- if (!exists($self->{'index_names'}->{$name}->{'name'})) {
- $self->{'index_names'}->{$name}->{'name'} = $name;
- }
- if (!exists($self->{'index_names'}->{$name}->{'contained_indices'}))
{
- $self->{'index_names'}->{$name}->{'contained_indices'}->{$name} =
1;
- }
- $self->{'misc_commands'}->{$name.'index'} = 'line';
- $self->{'no_paragraph_commands'}->{$name.'index'} = 1;
- $self->{'valid_nestings'}->{$name.'index'} =
\%in_simple_text_commands;
- $self->{'command_index'}->{$name.'index'} = $name;
+ $self->{'index_names'}->{$name} = {'in_code' => $in_code};
+ if (!exists($self->{'index_names'}->{$name}->{'name'})) {
+ $self->{'index_names'}->{$name}->{'name'} = $name;
}
+ if (!exists($self->{'index_names'}->{$name}->{'contained_indices'})) {
+ $self->{'index_names'}->{$name}->{'contained_indices'}->{$name} = 1;
+ }
+ $self->{'misc_commands'}->{$name.'index'} = 'line';
+ $self->{'no_paragraph_commands'}->{$name.'index'} = 1;
+ $self->{'valid_nestings'}->{$name.'index'} = \%in_simple_text_commands;
+ $self->{'command_index'}->{$name.'index'} = $name;
}
} else {
$self->line_error(sprintf($self->
@@ -5834,16 +5772,14 @@
my $in_code = 0;
$in_code = 1 if ($command eq 'syncodeindex');
- if (! _ignore_global_commands($self)) {
- $self->{'merged_indices'}->{$index_from} = $current_to;
- $index_from_info->{'in_code'} = $in_code;
- foreach my $contained_index (keys
%{$index_from_info->{'contained_indices'}}) {
- $index_to_info->{'contained_indices'}->{$contained_index} = 1;
- $self->{'index_names'}->{$contained_index}->{'merged_in'} =
$current_to;
- }
- $index_from_info->{'merged_in'} = $current_to;
- $index_to_info->{'contained_indices'}->{$index_from} = 1;
+ $self->{'merged_indices'}->{$index_from} = $current_to;
+ $index_from_info->{'in_code'} = $in_code;
+ foreach my $contained_index (keys
%{$index_from_info->{'contained_indices'}}) {
+ $index_to_info->{'contained_indices'}->{$contained_index} = 1;
+ $self->{'index_names'}->{$contained_index}->{'merged_in'} =
$current_to;
}
+ $index_from_info->{'merged_in'} = $current_to;
+ $index_to_info->{'contained_indices'}->{$index_from} = 1;
$args = [$index_from, $index_to];
} else {
$self->line_warn(sprintf($self->__(
@@ -5972,8 +5908,7 @@
}
} elsif ($command eq 'kbdinputstyle') {
if ($line eq 'code' or $line eq 'example' or $line eq 'distinct') {
- $self->{'kbdinputstyle'} = $line
- unless (_ignore_global_commands($self));
+ $self->{'kbdinputstyle'} = $line;
$args = [$line];
} else {
$self->line_error(sprintf($self->__(
@@ -6077,9 +6012,6 @@
An array reference of the output formats for which C<@ifI<FORMAT>>
conditional blocks should be expanded. Default is empty.
-The raw block formats (within C<@html> blocks, for example) are
-always kept.
-
=item gettext
If set, the function reference is used to translate error and warning
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [7240] remove _ignore_global_commands,
gavinsmith0123 <=