[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: Basic inline stack for index commands
From: |
Gavin D. Smith |
Subject: |
branch master updated: Basic inline stack for index commands |
Date: |
Sat, 04 Feb 2023 17:04:22 -0500 |
This is an automated email from the git hooks/post-receive script.
gavin pushed a commit to branch master
in repository texinfo.
The following commit(s) were added to refs/heads/master by this push:
new c9d31d3ef5 Basic inline stack for index commands
c9d31d3ef5 is described below
commit c9d31d3ef59551e22c74f37fc212bcecd024694a
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Sat Feb 4 22:03:56 2023 +0000
Basic inline stack for index commands
* tp/Texinfo/ParserNonXS.pm (%default_basic_inline_commands):
Initialise from %contain_basic_inline_commands and add index commands.
(parser): Initialise $parser->{'basic_inline_commands'} therefrom.
This hash is already mentioned in comment at top of file.
(_close_brace_command, _end_line_misc_line)
(_process_remaining_on_line): Use 'basic_inline_commands' hash.
(_parse_line_command_args) <new index command>: Add to hash.
* tp/Texinfo/XS/parsetexi/indices.c (add_index_command):
Set CF_contain_basic_inline flag.
* tp/Texinfo/XS/parsetexi/parser.c (check_valid_nesting):
Eliminate check for CF_index_entry_command.
(check_valid_nesting_context): Reorder a couple of conditionals.
---
ChangeLog | 18 ++++++++++++++++++
tp/Texinfo/ParserNonXS.pm | 16 ++++++++--------
tp/Texinfo/XS/parsetexi/indices.c | 2 +-
tp/Texinfo/XS/parsetexi/parser.c | 12 +++++-------
.../coverage_braces/contain_plain_text_nestings.pl | 9 +++++++++
.../invalid_nestings/multitable_item_in_index.pl | 4 ++--
.../invalid_nestings/node_on_index_entry_line.pl | 4 ++--
tp/t/results/invalid_nestings/on_index_entry_line.pl | 20 ++++++++++----------
.../invalid_nestings/section_on_index_entry_line.pl | 4 ++--
tp/t/results/invalid_nestings/tab_in_index.pl | 4 ++--
10 files changed, 59 insertions(+), 34 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e6bc4c61c2..fb7b18139a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2023-02-04 Gavin Smith <gavinsmith0123@gmail.com>
+
+ Basic inline stack for index commands
+
+ * tp/Texinfo/ParserNonXS.pm (%default_basic_inline_commands):
+ Initialise from %contain_basic_inline_commands and add index commands.
+ (parser): Initialise $parser->{'basic_inline_commands'} therefrom.
+ This hash is already mentioned in comment at top of file.
+ (_close_brace_command, _end_line_misc_line)
+ (_process_remaining_on_line): Use 'basic_inline_commands' hash.
+ (_parse_line_command_args) <new index command>: Add to hash.
+
+ * tp/Texinfo/XS/parsetexi/indices.c (add_index_command):
+ Set CF_contain_basic_inline flag.
+ * tp/Texinfo/XS/parsetexi/parser.c (check_valid_nesting):
+ Eliminate check for CF_index_entry_command.
+ (check_valid_nesting_context): Reorder a couple of conditionals.
+
2023-02-04 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/ParserNonXS.pm (import): never load the abort_empty_line
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 32c9310804..6c26325ac6 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -552,11 +552,12 @@ foreach my $name (keys(%index_names)) {
}
}
+my %default_basic_inline_commands = %contain_basic_inline_commands;
foreach my $index (keys(%index_names)) {
my $one_letter_prefix = substr($index, 0, 1);
foreach my $prefix ($index, $one_letter_prefix) {
$default_no_paragraph_commands{$prefix.'index'} = 1;
- $default_valid_nestings{$prefix.'index'} = \%in_basic_inline_commands;
+ $default_basic_inline_commands{$prefix.'index'} = 1;
}
}
@@ -664,6 +665,7 @@ sub parser(;$$)
$parser->{'nesting_context'} = {%nesting_context_init};
$parser->{'nesting_context'}->{'basic_inline_stack'} = [];
$parser->{'nesting_context'}->{'basic_inline_stack_on_line'} = [];
+ $parser->{'basic_inline_commands'} = {%default_basic_inline_commands};
# handle user provided state.
@@ -695,8 +697,6 @@ sub parser(;$$)
foreach my $prefix ($index, substr($index, 0, 1)) {
$parser->{'line_commands'}->{$prefix.'index'} = 'line';
$parser->{'no_paragraph_commands'}->{$prefix.'index'} = 1;
- $parser->{'valid_nestings'}->{$prefix.'index'}
- = \%in_basic_inline_commands;
$parser->{'command_index'}->{$prefix.'index'} = $index;
}
}
@@ -1520,7 +1520,7 @@ sub _close_brace_command($$$;$$$)
}
pop @{$self->{'nesting_context'}->{'basic_inline_stack'}}
- if ($contain_basic_inline_commands{$current->{'cmdname'}});
+ if ($self->{'basic_inline_commands'}->{$current->{'cmdname'}});
if ($current->{'cmdname'} ne 'verb'
or $current->{'info'}->{'delimiter'} eq '') {
@@ -3240,7 +3240,7 @@ sub _end_line_misc_line($$$)
print STDERR "MISC END \@$command: $self->{'line_commands'}->{$command}\n"
if ($self->{'DEBUG'});
- if ($contain_basic_inline_commands{$command}) {
+ if ($self->{'basic_inline_commands'}->{$command}) {
pop @{$self->{'nesting_context'}->{'basic_inline_stack_on_line'}};
}
@@ -5526,7 +5526,7 @@ sub _process_remaining_on_line($$$$)
$current = $current->{'contents'}->[-1];
$current->{'args'} = [{ 'type' => 'line_arg',
'parent' => $current }];
- if ($contain_basic_inline_commands{$command}) {
+ if ($self->{'basic_inline_commands'}->{$command}) {
push @{$self->{'nesting_context'}->{'basic_inline_stack_on_line'}},
$command;
}
@@ -5840,7 +5840,7 @@ sub _process_remaining_on_line($$$$)
$current = $current->{'args'}->[-1];
push @{$self->{'nesting_context'}->{'basic_inline_stack'}}, $command
- if ($contain_basic_inline_commands{$command});
+ if ($self->{'basic_inline_commands'}->{$command});
if ($self->{'brace_commands'}->{$command} eq 'context') {
if ($command eq 'caption' or $command eq 'shortcaption') {
my $float;
@@ -6715,7 +6715,7 @@ sub _parse_line_command_args($$$)
}
$self->{'line_commands'}->{$name.'index'} = 'line';
$self->{'no_paragraph_commands'}->{$name.'index'} = 1;
- $self->{'valid_nestings'}->{$name.'index'} =
\%in_basic_inline_commands;
+ $self->{'basic_inline_commands'}->{$name.'index'} = 1;
$self->{'command_index'}->{$name.'index'} = $name;
}
} else {
diff --git a/tp/Texinfo/XS/parsetexi/indices.c
b/tp/Texinfo/XS/parsetexi/indices.c
index 537bb833b8..132de7733c 100644
--- a/tp/Texinfo/XS/parsetexi/indices.c
+++ b/tp/Texinfo/XS/parsetexi/indices.c
@@ -71,7 +71,7 @@ add_index_command (char *cmdname, INDEX *idx)
{
enum command_id new = add_texinfo_command (cmdname);
user_defined_command_data[new & ~USER_COMMAND_BIT].flags
- = CF_line | CF_index_entry_command;
+ = CF_line | CF_index_entry_command | CF_contain_basic_inline;
user_defined_command_data[new & ~USER_COMMAND_BIT].data = LINE_line;
associate_command_to_index (new, idx);
}
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index 5d8565747d..1117e754a0 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -1019,10 +1019,7 @@ check_valid_nesting (ELEMENT *current, enum command_id
cmd)
// much TODO here.
if (outer_flags & CF_contain_basic_inline
- && !(outer_flags & (CF_brace | CF_line))
- /* not in CF_contain_basic_inline since index entry flags are not set
- in command_data.txt, and also index commands are dynamically added */
- || outer_flags & CF_index_entry_command)
+ && !(outer_flags & (CF_brace | CF_line)))
{
basic_inline_command = 1;
}
@@ -1167,12 +1164,13 @@ void
check_valid_nesting_context (enum command_id cmd)
{
enum command_id invalid_context = 0;
- if (cmd == CM_footnote && nesting_context.footnote > 0)
+ if (nesting_context.footnote > 0
+ && cmd == CM_footnote)
{
invalid_context = CM_footnote;
}
- else if ((cmd == CM_caption || cmd == CM_shortcaption)
- && nesting_context.caption > 0)
+ else if (nesting_context.caption > 0
+ && (cmd == CM_caption || cmd == CM_shortcaption))
{
line_warn ("@%s should not appear anywhere inside caption",
command_name(cmd));
diff --git a/tp/t/results/coverage_braces/contain_plain_text_nestings.pl
b/tp/t/results/coverage_braces/contain_plain_text_nestings.pl
index f7e10aa15e..36a4c091b9 100644
--- a/tp/t/results/coverage_braces/contain_plain_text_nestings.pl
+++ b/tp/t/results/coverage_braces/contain_plain_text_nestings.pl
@@ -972,6 +972,15 @@ $result_errors{'contain_plain_text_nestings'} = [
'macro' => '',
'text' => '@ref should not appear in @sortas',
'type' => 'warning'
+ },
+ {
+ 'error_line' => 'warning: @ref should not appear anywhere inside @cindex
+',
+ 'file_name' => '',
+ 'line_nr' => 16,
+ 'macro' => '',
+ 'text' => '@ref should not appear anywhere inside @cindex',
+ 'type' => 'warning'
}
];
diff --git a/tp/t/results/invalid_nestings/multitable_item_in_index.pl
b/tp/t/results/invalid_nestings/multitable_item_in_index.pl
index 43c953a709..4d8a5ba581 100644
--- a/tp/t/results/invalid_nestings/multitable_item_in_index.pl
+++ b/tp/t/results/invalid_nestings/multitable_item_in_index.pl
@@ -179,12 +179,12 @@ $result_texts{'multitable_item_in_index'} = '';
$result_errors{'multitable_item_in_index'} = [
{
- 'error_line' => 'warning: @item should not appear in @vindex
+ 'error_line' => 'warning: @item should not appear anywhere inside @vindex
',
'file_name' => '',
'line_nr' => 2,
'macro' => '',
- 'text' => '@item should not appear in @vindex',
+ 'text' => '@item should not appear anywhere inside @vindex',
'type' => 'warning'
},
{
diff --git a/tp/t/results/invalid_nestings/node_on_index_entry_line.pl
b/tp/t/results/invalid_nestings/node_on_index_entry_line.pl
index 7b6cd60580..9cff113b71 100644
--- a/tp/t/results/invalid_nestings/node_on_index_entry_line.pl
+++ b/tp/t/results/invalid_nestings/node_on_index_entry_line.pl
@@ -296,12 +296,12 @@ $result_errors{'node_on_index_entry_line'} = [
'type' => 'warning'
},
{
- 'error_line' => 'warning: @node should not appear in @cindex
+ 'error_line' => 'warning: @node should not appear anywhere inside @cindex
',
'file_name' => '',
'line_nr' => 2,
'macro' => '',
- 'text' => '@node should not appear in @cindex',
+ 'text' => '@node should not appear anywhere inside @cindex',
'type' => 'warning'
},
{
diff --git a/tp/t/results/invalid_nestings/on_index_entry_line.pl
b/tp/t/results/invalid_nestings/on_index_entry_line.pl
index b9f8033fcc..f3cdc09b7e 100644
--- a/tp/t/results/invalid_nestings/on_index_entry_line.pl
+++ b/tp/t/results/invalid_nestings/on_index_entry_line.pl
@@ -174,39 +174,39 @@ $result_texts{'on_index_entry_line'} = '';
$result_errors{'on_index_entry_line'} = [
{
- 'error_line' => 'warning: @indent should not appear in @cindex
+ 'error_line' => 'warning: @indent should not appear anywhere inside @cindex
',
'file_name' => '',
'line_nr' => 1,
'macro' => '',
- 'text' => '@indent should not appear in @cindex',
+ 'text' => '@indent should not appear anywhere inside @cindex',
'type' => 'warning'
},
{
- 'error_line' => 'warning: @titlefont should not appear in @cindex
+ 'error_line' => 'warning: @titlefont should not appear anywhere inside
@cindex
',
'file_name' => '',
'line_nr' => 1,
'macro' => '',
- 'text' => '@titlefont should not appear in @cindex',
+ 'text' => '@titlefont should not appear anywhere inside @cindex',
'type' => 'warning'
},
{
- 'error_line' => 'warning: @anchor should not appear in @cindex
+ 'error_line' => 'warning: @anchor should not appear anywhere inside @cindex
',
'file_name' => '',
'line_nr' => 1,
'macro' => '',
- 'text' => '@anchor should not appear in @cindex',
+ 'text' => '@anchor should not appear anywhere inside @cindex',
'type' => 'warning'
},
{
- 'error_line' => 'warning: @footnote should not appear in @cindex
+ 'error_line' => 'warning: @footnote should not appear anywhere inside
@cindex
',
'file_name' => '',
'line_nr' => 1,
'macro' => '',
- 'text' => '@footnote should not appear in @cindex',
+ 'text' => '@footnote should not appear anywhere inside @cindex',
'type' => 'warning'
},
{
@@ -219,12 +219,12 @@ $result_errors{'on_index_entry_line'} = [
'type' => 'warning'
},
{
- 'error_line' => 'warning: @exdent should not appear in @cindex
+ 'error_line' => 'warning: @exdent should not appear anywhere inside @cindex
',
'file_name' => '',
'line_nr' => 1,
'macro' => '',
- 'text' => '@exdent should not appear in @cindex',
+ 'text' => '@exdent should not appear anywhere inside @cindex',
'type' => 'warning'
},
{
diff --git a/tp/t/results/invalid_nestings/section_on_index_entry_line.pl
b/tp/t/results/invalid_nestings/section_on_index_entry_line.pl
index d6333f2d21..73c5710b5e 100644
--- a/tp/t/results/invalid_nestings/section_on_index_entry_line.pl
+++ b/tp/t/results/invalid_nestings/section_on_index_entry_line.pl
@@ -147,12 +147,12 @@ $result_errors{'section_on_index_entry_line'} = [
'type' => 'warning'
},
{
- 'error_line' => 'warning: @section should not appear in @cindex
+ 'error_line' => 'warning: @section should not appear anywhere inside
@cindex
',
'file_name' => '',
'line_nr' => 1,
'macro' => '',
- 'text' => '@section should not appear in @cindex',
+ 'text' => '@section should not appear anywhere inside @cindex',
'type' => 'warning'
},
{
diff --git a/tp/t/results/invalid_nestings/tab_in_index.pl
b/tp/t/results/invalid_nestings/tab_in_index.pl
index 0cfafb5f50..005b72175e 100644
--- a/tp/t/results/invalid_nestings/tab_in_index.pl
+++ b/tp/t/results/invalid_nestings/tab_in_index.pl
@@ -243,12 +243,12 @@ $result_texts{'tab_in_index'} = 'one nonlettered
character aaa
$result_errors{'tab_in_index'} = [
{
- 'error_line' => 'warning: @tab should not appear in @vindex
+ 'error_line' => 'warning: @tab should not appear anywhere inside @vindex
',
'file_name' => '',
'line_nr' => 3,
'macro' => '',
- 'text' => '@tab should not appear in @vindex',
+ 'text' => '@tab should not appear anywhere inside @vindex',
'type' => 'warning'
},
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: Basic inline stack for index commands,
Gavin D. Smith <=