[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[8411] change meaning of 1 in %brace_commands
From: |
gavinsmith0123 |
Subject: |
[8411] change meaning of 1 in %brace_commands |
Date: |
Thu, 25 Oct 2018 19:22:33 -0400 (EDT) |
Revision: 8411
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=8411
Author: gavin
Date: 2018-10-25 19:22:33 -0400 (Thu, 25 Oct 2018)
Log Message:
-----------
change meaning of 1 in %brace_commands
Modified Paths:
--------------
trunk/ChangeLog
trunk/tp/Texinfo/Common.pm
trunk/tp/Texinfo/Convert/Plaintext.pm
trunk/tp/Texinfo/Parser.pm
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2018-10-25 20:46:53 UTC (rev 8410)
+++ trunk/ChangeLog 2018-10-25 23:22:33 UTC (rev 8411)
@@ -1,5 +1,35 @@
2018-10-25 Gavin Smith <address@hidden>
+ * tp/Texinfo/Common.pm (%brace_commands): Change meaning of 1
+ as a value. Now only commands that were in
+ %simple_text_commands in Parser.pm have 1. Use words as well as
+ numbers, as is done for %line_commands. Accent commands get
+ 'accent'. Style commands get 'style'. Context brace commands
+ get 'context'. Various other brace commands get 'other'.
+ (_parse_line_command_args): Commands defined by @definfoenclose
+ get 'style'.
+
+ * tp/Texinfo/Parser.pm
+ (%simple_text_commands): Change initialising code to use
+ %brace_commands for some brace commands. This shortens a
+ seemingly arbitrary list.
+
+ (%full_text_commands): Update initialising code for new meaning
+ of %brace_commands.
+
+ (_parse_texi): Change two conditions to compare values of
+ %brace_commands hash, without needing to look at
+ %simple_text_commands. Remove an unnecessary conditional.
+
+ * tp/Texinfo/Parser.pm (_parse_texi),
+ * tp/Texinfo/Convert/Plaintext.pm (%brace_no_arg_commands):
+ Use "eq '0'" instead of "== 0" for %brace_commands values.
+
+ No functional changes intended. This brings the implementation
+ closer to the C version under tp/Texinfo/XS/parsetexi.
+
+2018-10-25 Gavin Smith <address@hidden>
+
* tp/Texinfo/Parser.pm (%simple_text_commands): Add 'sortas'.
(%full_text_commands): No special case for 'sortas'.
(_parse_texi) <@copying in @insertcopying>: Undefine a variable.
Modified: trunk/tp/Texinfo/Common.pm
===================================================================
--- trunk/tp/Texinfo/Common.pm 2018-10-25 20:46:53 UTC (rev 8410)
+++ trunk/tp/Texinfo/Common.pm 2018-10-25 23:22:33 UTC (rev 8411)
@@ -579,7 +579,7 @@
'ringaccent','H','dotaccent','u','ubaraccent',
'udotaccent','v','ogonek','tieaccent', 'dotless') {
$accent_commands{$accent_command} = 1;
- $brace_commands{$accent_command} = 1;
+ $brace_commands{$accent_command} = 'accent';
}
our %style_commands;
@@ -588,7 +588,7 @@
'sc', 't', 'var',
'headitemfont', 'code', 'command', 'env', 'file', 'kbd',
'option', 'samp', 'strong', 'sub', 'sup') {
- $brace_commands{$style_command} = 1;
+ $brace_commands{$style_command} = 'style';
$style_commands{$style_command} = 1;
}
@@ -595,29 +595,38 @@
our %regular_font_style_commands;
foreach my $command ('r', 'i', 'b', 'sansserif', 'slanted') {
$regular_font_style_commands{$command} = 1;
- $brace_commands{$command} = 1;
+ $brace_commands{$command} = 'style';
$style_commands{$command} = 1;
}
-foreach my $one_arg_command ('U', 'dmn', 'w', 'key',
- 'titlefont', 'hyphenation', 'anchor', 'errormsg', 'sortas') {
+foreach my $one_arg_command ('U', 'dmn', 'key',
+ 'titlefont', 'anchor', 'errormsg', 'sortas') {
$brace_commands{$one_arg_command} = 1;
}
+# FIXME: 'key', 'verb', 't'?
+foreach my $other_arg_command ('w', 'hyphenation') {
+ $brace_commands{$other_arg_command} = 'other';
+}
+
our %code_style_commands;
foreach my $command ('code', 'command', 'env', 'file', 'kbd', 'key', 'option',
- 'samp', 'indicateurl', 'verb', 't') {
+ 'samp', 'verb', 't') {
$code_style_commands{$command} = 1;
- $brace_commands{$command} = 1;
+ $brace_commands{$command} = 'style';
}
+# FIXME: a special case?
+$code_style_commands{'indicateurl'} = 1;
+$brace_commands{'indicateurl'} = 1;
+
# Commands that enclose full texts, that can contain multiple paragraphs.
our %context_brace_commands;
foreach my $context_brace_command ('footnote', 'caption',
'shortcaption', 'math') {
$context_brace_commands{$context_brace_command} = $context_brace_command;
- $brace_commands{$context_brace_command} = 1;
+ $brace_commands{$context_brace_command} = 'context';
}
our %explained_commands;
@@ -626,6 +635,7 @@
$brace_commands{$explained_command} = 2;
}
+
our %inline_format_commands;
our %inline_commands;
foreach my $inline_format_command ('inlineraw', 'inlinefmt',
@@ -644,9 +654,6 @@
$inline_commands{$inline_conditional_command} = 1;
}
-# 'inlineset', 'inlineclear'
-#$brace_commands{'inlineclear'} = 1;
-
foreach my $two_arg_command('email') {
$brace_commands{$two_arg_command} = 2;
}
Modified: trunk/tp/Texinfo/Convert/Plaintext.pm
===================================================================
--- trunk/tp/Texinfo/Convert/Plaintext.pm 2018-10-25 20:46:53 UTC (rev
8410)
+++ trunk/tp/Texinfo/Convert/Plaintext.pm 2018-10-25 23:22:33 UTC (rev
8411)
@@ -82,7 +82,7 @@
my %brace_no_arg_commands;
foreach my $command (keys (%Texinfo::Common::brace_commands)) {
$brace_no_arg_commands{$command} = 1
- if ($Texinfo::Common::brace_commands{$command} == 0);
+ if ($Texinfo::Common::brace_commands{$command} eq '0');
}
my %accent_commands = %Texinfo::Common::accent_commands;
my %misc_commands = %Texinfo::Common::misc_commands;
Modified: trunk/tp/Texinfo/Parser.pm
===================================================================
--- trunk/tp/Texinfo/Parser.pm 2018-10-25 20:46:53 UTC (rev 8410)
+++ trunk/tp/Texinfo/Parser.pm 2018-10-25 23:22:33 UTC (rev 8411)
@@ -429,10 +429,16 @@
delete $simple_text_commands{'center'};
delete $simple_text_commands{'exdent'};
-foreach my $command ('titlefont', 'anchor', 'xref','ref', 'pxref',
+
+foreach my $command (keys (%brace_commands)) {
+ if ($brace_commands{$command} eq '1') {
+ $simple_text_commands{$command} = 1;
+ }
+}
+
+foreach my $command ('xref','ref', 'pxref',
'inforef', 'shortcaption', 'math', 'indicateurl',
- 'email', 'uref', 'url', 'image', 'abbr', 'acronym',
- 'dmn', 'errormsg', 'U', 'sortas') {
+ 'email', 'uref', 'url', 'image', 'abbr', 'acronym') {
$simple_text_commands{$command} = 1;
}
@@ -445,10 +451,7 @@
# commands that accept full text, but no block or top-level commands
my %full_text_commands;
foreach my $brace_command (keys (%brace_commands)) {
- if ($brace_commands{$brace_command} == 1
- and !$simple_text_commands{$brace_command}
- and !$context_brace_commands{$brace_command}
- and !$accent_commands{$brace_command}) {
+ if ($brace_commands{$brace_command} eq 'style') {
$full_text_commands{$brace_command} = 1;
}
}
@@ -4745,8 +4748,13 @@
my $command = $current->{'cmdname'};
$current->{'args'} = [ { 'parent' => $current,
'contents' => [] } ];
- $current->{'remaining_args'} = $brace_commands{$command} -1
- if ($brace_commands{$command} and $brace_commands{$command}
-1);
+
+ if ($brace_commands{$command}
+ and $brace_commands{$command} =~ /^\d$/
+ and $brace_commands{$command} > 1) {
+ $current->{'remaining_args'} = $brace_commands{$command} - 1;
+ }
+
$current = $current->{'args'}->[-1];
if ($context_brace_commands{$command}) {
if ($command eq 'caption' or $command eq 'shortcaption') {
@@ -4793,8 +4801,8 @@
} else {
$current->{'type'} = 'brace_command_arg';
if ($brace_commands{$command}
- and ($brace_commands{$command} > 1
- or $simple_text_commands{$command})) {
+ and $brace_commands{$command} =~ /^\d$/
+ and $brace_commands{$command} > 0) {
push @{$current->{'contents'}},
{'type' => 'empty_spaces_before_argument',
'text' => '',
@@ -4802,10 +4810,8 @@
'extra' => {'command' => $current}
};
}
- if ($inline_commands{$command}) {
- push @{$self->{'context_stack'}}, $command
- if ($command eq 'inlineraw');
- }
+ push @{$self->{'context_stack'}}, $command
+ if ($command eq 'inlineraw');
}
print STDERR "OPENED address@hidden>{'parent'}->{'cmdname'},
remaining: "
.(defined($current->{'parent'}->{'remaining_args'}) ?
"remaining: $current->{'parent'}->{'remaining_args'}, " : '')
@@ -4872,8 +4878,8 @@
# first is the arg.
if ($brace_commands{$current->{'parent'}->{'cmdname'}}
- and ($brace_commands{$current->{'parent'}->{'cmdname'}} > 1
- or $simple_text_commands{$current->{'parent'}->{'cmdname'}})
+ and $brace_commands{$current->{'parent'}{'cmdname'}} =~ /^\d$/
+ and $brace_commands{$current->{'parent'}->{'cmdname'}} > 0
and $current->{'parent'}->{'cmdname'} ne 'math') {
# @inline* always have end spaces considered as normal text
_isolate_last_space($self, $current)
@@ -4884,7 +4890,7 @@
if ($self->{'DEBUG'});
delete $current->{'parent'}->{'remaining_args'};
if (defined($brace_commands{$closed_command})
- and $brace_commands{$closed_command} == 0
+ and $brace_commands{$closed_command} eq '0'
and @{$current->{'contents'}}) {
$self->line_warn(sprintf(__(
"command address@hidden does not accept
arguments"),
@@ -5444,7 +5450,7 @@
$self->{'definfoenclose'}->{$1} = [ $2, $3 ];
print STDERR "DEFINFOENCLOSE address@hidden: $2, $3\n" if
($self->{'DEBUG'});
- $brace_commands{$1} = 1;
+ $brace_commands{$1} = 'style';
# Warning: there is a risk of mixing of data between a built-in
# command and a user command defined with @definfoenclose.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [8411] change meaning of 1 in %brace_commands,
gavinsmith0123 <=