[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Fri, 26 Apr 2024 18:11:21 -0400 (EDT) |
branch: master
commit 1fdf0183654700f2d72f706ab96b0b8456cf58fc
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Apr 27 00:10:56 2024 +0200
* tp/Texinfo/ParserNonXS.pm (_handle_other_command),
tp/Texinfo/XS/parsetexi/handle_commands.c (handle_other_command):
check that an in_heading_spec command is in an heading_spec command by
using the basic_inline_stack_on_line nesting_context.
* tp/Makefile.tres, tp/t/57invalid_nestings.t
(heading_commands_in_center, heading_commands_in_documentlanguage):
move two tests from tp/t/02coverage.t.
* tp/Makefile.tres, tp/t/57invalid_nestings.t
(heading_separator_in_accent_command)
thischapter_in_footnote_in_evenfooting)
(thischapter_in_math_in_evenfooting): new tests of invalid nestings
for in heading commands.
---
ChangeLog | 17 +++
tp/Makefile.tres | 7 +-
tp/Texinfo/ParserNonXS.pm | 29 ++--
tp/Texinfo/XS/parsetexi/handle_commands.c | 3 -
tp/Texinfo/command_data.txt | 4 +-
tp/t/02coverage.t | 6 -
tp/t/57invalid_nestings.t | 20 ++-
.../heading_commands_in_center.pl | 0
.../heading_commands_in_documentlanguage.pl | 0
.../heading_separator_in_accent_command.pl} | 115 ++++++++-------
.../thischapter_in_footnote_in_evenfooting.pl | 155 +++++++++++++++++++++
.../thischapter_in_math_in_evenfooting.pl | 81 +++++++++++
12 files changed, 352 insertions(+), 85 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 2cf869cb96..6869861e96 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2024-04-27 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/ParserNonXS.pm (_handle_other_command),
+ tp/Texinfo/XS/parsetexi/handle_commands.c (handle_other_command):
+ check that an in_heading_spec command is in an heading_spec command by
+ using the basic_inline_stack_on_line nesting_context.
+
+ * tp/Makefile.tres, tp/t/57invalid_nestings.t
+ (heading_commands_in_center, heading_commands_in_documentlanguage):
+ move two tests from tp/t/02coverage.t.
+
+ * tp/Makefile.tres, tp/t/57invalid_nestings.t
+ (heading_separator_in_accent_command)
+ thischapter_in_footnote_in_evenfooting)
+ (thischapter_in_math_in_evenfooting): new tests of invalid nestings
+ for in heading commands.
+
2024-04-22 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/command_data.txt (nodedescription): add
diff --git a/tp/Makefile.tres b/tp/Makefile.tres
index fd3338dc3d..d9669f37bd 100644
--- a/tp/Makefile.tres
+++ b/tp/Makefile.tres
@@ -330,8 +330,6 @@ test_files_generated_list =
$(test_tap_files_generated_list) \
t/results/coverage/formats_titles.pl \
t/results/coverage/group_beginning_and_end_on_line.pl \
t/results/coverage/group_not_closed.pl \
- t/results/coverage/heading_commands_in_center.pl \
- t/results/coverage/heading_commands_in_documentlanguage.pl \
t/results/coverage/hyphenation.pl \
t/results/coverage/indentedblock.pl \
t/results/coverage/indicateurl_end_lines.pl \
@@ -1074,6 +1072,9 @@ test_files_generated_list =
$(test_tap_files_generated_list) \
t/results/invalid_nestings/flushright_in_style_command.pl \
t/results/invalid_nestings/footnote_in_ref.pl \
t/results/invalid_nestings/formats_not_closed_in_example.pl \
+ t/results/invalid_nestings/heading_commands_in_center.pl \
+ t/results/invalid_nestings/heading_commands_in_documentlanguage.pl \
+ t/results/invalid_nestings/heading_separator_in_accent_command.pl \
t/results/invalid_nestings/ignore_in_xref.pl \
t/results/invalid_nestings/ignored_text.pl \
t/results/invalid_nestings/in_errormsg.pl \
@@ -1125,6 +1126,8 @@ test_files_generated_list =
$(test_tap_files_generated_list) \
t/results/invalid_nestings/table_not_closed_in_menu_comment.pl \
t/results/invalid_nestings/table_not_closed_in_menu_description.pl \
t/results/invalid_nestings/table_on_item_line.pl \
+ t/results/invalid_nestings/thischapter_in_footnote_in_evenfooting.pl \
+ t/results/invalid_nestings/thischapter_in_math_in_evenfooting.pl \
t/results/invalid_nestings/unclosed_verb_end_of_line_on_misc_line.pl \
t/results/invalid_nestings/unclosed_verb_on_misc_line.pl \
t/results/invalid_nestings/unclosed_verb_on_section_line.pl \
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index a2ddda08c2..269428968a 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -5343,19 +5343,22 @@ sub _handle_other_command($$$$$)
push @{$current->{'contents'}}, $command_e;
if ($in_heading_spec_commands{$command}) {
- # TODO use a more generic system for check of @-command nesting
- # in command on context stack?
- my $top_context_command = $self->_top_context_command();
- if (not defined($top_context_command)
- or not $heading_spec_commands{$top_context_command}) {
- #my $line_context;
- #if (defined($self->{'nesting_context'}->{'basic_inline_stack_on_line'})
- # and @{$self->{'nesting_context'}->{'basic_inline_stack_on_line'}} >
0) {
- # $line_context
- # = $self->{'nesting_context'}->{'basic_inline_stack_on_line'}->[-1];
- #}
- #if (!defined($line_context)
- # or !$heading_spec_commands{$line_context}) {
+ # We check that in_heading_spec_commands are in heading_spec_commands by
+ # using basic_inline_stack_on_line since heading_spec_commands are
+ # contain_basic_inline commands. We do not check that
+ # in_heading_spec_commands are not in context nor special brace commands,
+ # so there won't be a warning for @thischapter in @footnote for example.
+ # However, heading_spec_commands being contain_basic_inline commands,
+ # there should be a warning if they contain most context/special brace
+ # commands such as @footnote.
+ my $line_context;
+ if (defined($self->{'nesting_context'}->{'basic_inline_stack_on_line'})
+ and @{$self->{'nesting_context'}->{'basic_inline_stack_on_line'}} >
0) {
+ $line_context
+ = $self->{'nesting_context'}->{'basic_inline_stack_on_line'}->[-1];
+ }
+ if (!defined($line_context)
+ or !$heading_spec_commands{$line_context}) {
$self->_line_error(
sprintf(__("\@%s should only appear in heading or footing"),
$command), $source_info);
diff --git a/tp/Texinfo/XS/parsetexi/handle_commands.c
b/tp/Texinfo/XS/parsetexi/handle_commands.c
index 20a98e7252..fbaf45741a 100644
--- a/tp/Texinfo/XS/parsetexi/handle_commands.c
+++ b/tp/Texinfo/XS/parsetexi/handle_commands.c
@@ -348,14 +348,11 @@ handle_other_command (ELEMENT *current, char **line_inout,
command_e->cmd = cmd;
add_to_element_contents (current, command_e);
if (command_data(cmd).flags & CF_in_heading_spec
- /*
&& (nesting_context.basic_inline_stack_on_line.top <= 0
|| !(command_data(
top_command(&nesting_context.basic_inline_stack_on_line)).flags
& CF_heading_spec)))
- */
- && !(command_data(current_context_command()).flags &
CF_heading_spec))
{
line_error ("@%s should only appear in heading or footing",
command_name(cmd));
diff --git a/tp/Texinfo/command_data.txt b/tp/Texinfo/command_data.txt
index 674cb5afb9..ab961e297d 100644
--- a/tp/Texinfo/command_data.txt
+++ b/tp/Texinfo/command_data.txt
@@ -21,13 +21,13 @@
# Most flags (second column) should be documented (with _commands
# postpended) in Texinfo/Commands.pod.
-# Some documentation of the flags is in commands.h.
+# Some documentation of the flags is in Texinfo/XS/main/builtin_commands.h.
##############################################################
# Internal commands
# invalid if not accept_internalvalue set in configuration
txiinternalvalue internal,brace INTERNAL_brace
-# used in parsers for easy access to flags
+# used in converters for easy access to flags
definfoenclose_command internal,brace INTERNAL_brace
index_entry_command
internal,line,index_entry_command,contain_basic_inline,no_paragraph
INTERNAL_line
diff --git a/tp/t/02coverage.t b/tp/t/02coverage.t
index 41a19b7e35..ea5cfc48e1 100644
--- a/tp/t/02coverage.t
+++ b/tp/t/02coverage.t
@@ -1013,12 +1013,6 @@ undef, {'test_file' =>
'delcomment_followed_by_cpp_line.texi'}
['delcomment_on_comment', undef,
{'test_file' => 'delcomment_on_comment.texi'},
],
-['heading_commands_in_center',
-'@center @code{aaa @thischapter} @| a @thissection @| b
-'],
-['heading_commands_in_documentlanguage',
-'@documentlanguage @code{aaa @thischapter} @| @thissection @| b
-'],
);
my %docbooc_doc_tests = (
diff --git a/tp/t/57invalid_nestings.t b/tp/t/57invalid_nestings.t
index d1f94f5816..81d7b48e8a 100644
--- a/tp/t/57invalid_nestings.t
+++ b/tp/t/57invalid_nestings.t
@@ -499,7 +499,25 @@ Text. @errormsg{@anchor{in anchor} @ref{in ref}}
@item item
@end table
}'],
-);
+['heading_commands_in_center',
+'@center @code{aaa @thischapter} @| a @thissection @| b
+'],
+['heading_commands_in_documentlanguage',
+'@documentlanguage @code{aaa @thischapter} @| @thissection @| b
+'],
+['thischapter_in_math_in_evenfooting',
+'
+@evenfooting @math{aa @thischapter}
+'],
+['thischapter_in_footnote_in_evenfooting',
+'
+@evenfooting aa @strong{GG@footnote{bb @thischapter}} @| @footnote{cc
@thissection}
+'],
+['heading_separator_in_accent_command',
+'@,{@|}
+
+@oddfooting a @| @^{@|} @| b
+']);
my @formatted_cases = (
['on_node_line',
diff --git a/tp/t/results/coverage/heading_commands_in_center.pl
b/tp/t/results/invalid_nestings/heading_commands_in_center.pl
similarity index 100%
copy from tp/t/results/coverage/heading_commands_in_center.pl
copy to tp/t/results/invalid_nestings/heading_commands_in_center.pl
diff --git a/tp/t/results/coverage/heading_commands_in_documentlanguage.pl
b/tp/t/results/invalid_nestings/heading_commands_in_documentlanguage.pl
similarity index 100%
rename from tp/t/results/coverage/heading_commands_in_documentlanguage.pl
rename to tp/t/results/invalid_nestings/heading_commands_in_documentlanguage.pl
diff --git a/tp/t/results/coverage/heading_commands_in_center.pl
b/tp/t/results/invalid_nestings/heading_separator_in_accent_command.pl
similarity index 53%
rename from tp/t/results/coverage/heading_commands_in_center.pl
rename to tp/t/results/invalid_nestings/heading_separator_in_accent_command.pl
index b0ebb568db..b60b78a86e 100644
--- a/tp/t/results/coverage/heading_commands_in_center.pl
+++ b/tp/t/results/invalid_nestings/heading_separator_in_accent_command.pl
@@ -5,31 +5,67 @@ use vars qw(%result_texis %result_texts %result_trees
%result_errors
use utf8;
-$result_trees{'heading_commands_in_center'} = {
+$result_trees{'heading_separator_in_accent_command'} = {
'contents' => [
{
'contents' => [
+ {
+ 'contents' => [
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'cmdname' => '|'
+ }
+ ],
+ 'type' => 'brace_command_arg'
+ }
+ ],
+ 'cmdname' => ',',
+ 'source_info' => {
+ 'line_nr' => 1
+ }
+ },
+ {
+ 'text' => '
+'
+ }
+ ],
+ 'type' => 'paragraph'
+ },
+ {
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ },
{
'args' => [
{
'contents' => [
+ {
+ 'text' => 'a '
+ },
+ {
+ 'cmdname' => '|'
+ },
+ {
+ 'text' => ' '
+ },
{
'args' => [
{
'contents' => [
{
- 'text' => 'aaa '
- },
- {
- 'cmdname' => 'thischapter'
+ 'cmdname' => '|'
}
],
'type' => 'brace_command_arg'
}
],
- 'cmdname' => 'code',
+ 'cmdname' => '^',
'source_info' => {
- 'line_nr' => 1
+ 'line_nr' => 3
}
},
{
@@ -38,18 +74,6 @@ $result_trees{'heading_commands_in_center'} = {
{
'cmdname' => '|'
},
- {
- 'text' => ' a '
- },
- {
- 'cmdname' => 'thissection'
- },
- {
- 'text' => ' '
- },
- {
- 'cmdname' => '|'
- },
{
'text' => ' b'
}
@@ -63,14 +87,14 @@ $result_trees{'heading_commands_in_center'} = {
'type' => 'line_arg'
}
],
- 'cmdname' => 'center',
+ 'cmdname' => 'oddfooting',
'info' => {
'spaces_before_argument' => {
'text' => ' '
}
},
'source_info' => {
- 'line_nr' => 1
+ 'line_nr' => 3
}
}
],
@@ -80,26 +104,22 @@ $result_trees{'heading_commands_in_center'} = {
'type' => 'document_root'
};
-$result_texis{'heading_commands_in_center'} = '@center @code{aaa @thischapter}
@| a @thissection @| b
+$result_texis{'heading_separator_in_accent_command'} = '@,{@|}
+
+@oddfooting a @| @^{@|} @| b
';
-$result_texts{'heading_commands_in_center'} = 'aaa a b
+$result_texts{'heading_separator_in_accent_command'} = ',
+
';
-$result_errors{'heading_commands_in_center'} = [
+$result_errors{'heading_separator_in_accent_command'} = [
{
- 'error_line' => '@thischapter should only appear in heading or footing
+ 'error_line' => 'warning: @| should not appear in @,
',
'line_nr' => 1,
- 'text' => '@thischapter should only appear in heading or footing',
- 'type' => 'error'
- },
- {
- 'error_line' => 'warning: @| should not appear in @center
-',
- 'line_nr' => 1,
- 'text' => '@| should not appear in @center',
+ 'text' => '@| should not appear in @,',
'type' => 'warning'
},
{
@@ -110,37 +130,16 @@ $result_errors{'heading_commands_in_center'} = [
'type' => 'error'
},
{
- 'error_line' => 'warning: @thissection should not appear in @center
+ 'error_line' => 'warning: @| should not appear in @^
',
- 'line_nr' => 1,
- 'text' => '@thissection should not appear in @center',
+ 'line_nr' => 3,
+ 'text' => '@| should not appear in @^',
'type' => 'warning'
- },
- {
- 'error_line' => '@thissection should only appear in heading or footing
-',
- 'line_nr' => 1,
- 'text' => '@thissection should only appear in heading or footing',
- 'type' => 'error'
- },
- {
- 'error_line' => 'warning: @| should not appear in @center
-',
- 'line_nr' => 1,
- 'text' => '@| should not appear in @center',
- 'type' => 'warning'
- },
- {
- 'error_line' => '@| should only appear in heading or footing
-',
- 'line_nr' => 1,
- 'text' => '@| should only appear in heading or footing',
- 'type' => 'error'
}
];
-$result_floats{'heading_commands_in_center'} = {};
+$result_floats{'heading_separator_in_accent_command'} = {};
1;
diff --git
a/tp/t/results/invalid_nestings/thischapter_in_footnote_in_evenfooting.pl
b/tp/t/results/invalid_nestings/thischapter_in_footnote_in_evenfooting.pl
new file mode 100644
index 0000000000..a5767f0ea6
--- /dev/null
+++ b/tp/t/results/invalid_nestings/thischapter_in_footnote_in_evenfooting.pl
@@ -0,0 +1,155 @@
+use vars qw(%result_texis %result_texts %result_trees %result_errors
+ %result_indices %result_sectioning %result_nodes %result_menus
+ %result_floats %result_converted %result_converted_errors
+ %result_elements %result_directions_text %result_indices_sort_strings);
+
+use utf8;
+
+$result_trees{'thischapter_in_footnote_in_evenfooting'} = {
+ 'contents' => [
+ {
+ 'contents' => [
+ {
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'aa '
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'GG'
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'bb '
+ },
+ {
+ 'cmdname' => 'thischapter'
+ }
+ ],
+ 'type' => 'paragraph'
+ }
+ ],
+ 'type' => 'brace_command_context'
+ }
+ ],
+ 'cmdname' => 'footnote',
+ 'extra' => {},
+ 'source_info' => {
+ 'line_nr' => 2
+ }
+ }
+ ],
+ 'type' => 'brace_command_arg'
+ }
+ ],
+ 'cmdname' => 'strong',
+ 'source_info' => {
+ 'line_nr' => 2
+ }
+ },
+ {
+ 'text' => ' '
+ },
+ {
+ 'cmdname' => '|'
+ },
+ {
+ 'text' => ' '
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'cc '
+ },
+ {
+ 'cmdname' => 'thissection'
+ }
+ ],
+ 'type' => 'paragraph'
+ }
+ ],
+ 'type' => 'brace_command_context'
+ }
+ ],
+ 'cmdname' => 'footnote',
+ 'extra' => {},
+ 'source_info' => {
+ 'line_nr' => 2
+ }
+ }
+ ],
+ 'info' => {
+ 'spaces_after_argument' => {
+ 'text' => '
+'
+ }
+ },
+ 'type' => 'line_arg'
+ }
+ ],
+ 'cmdname' => 'evenfooting',
+ 'info' => {
+ 'spaces_before_argument' => {
+ 'text' => ' '
+ }
+ },
+ 'source_info' => {
+ 'line_nr' => 2
+ }
+ }
+ ],
+ 'type' => 'before_node_section'
+ }
+ ],
+ 'type' => 'document_root'
+};
+
+$result_texis{'thischapter_in_footnote_in_evenfooting'} = '
+@evenfooting aa @strong{GG@footnote{bb @thischapter}} @| @footnote{cc
@thissection}
+';
+
+
+$result_texts{'thischapter_in_footnote_in_evenfooting'} = '
+';
+
+$result_errors{'thischapter_in_footnote_in_evenfooting'} = [
+ {
+ 'error_line' => 'warning: @footnote should not appear on @evenfooting line
+',
+ 'line_nr' => 2,
+ 'text' => '@footnote should not appear on @evenfooting line',
+ 'type' => 'warning'
+ },
+ {
+ 'error_line' => 'warning: @footnote should not appear on @evenfooting line
+',
+ 'line_nr' => 2,
+ 'text' => '@footnote should not appear on @evenfooting line',
+ 'type' => 'warning'
+ }
+];
+
+
+$result_floats{'thischapter_in_footnote_in_evenfooting'} = {};
+
+
+1;
diff --git
a/tp/t/results/invalid_nestings/thischapter_in_math_in_evenfooting.pl
b/tp/t/results/invalid_nestings/thischapter_in_math_in_evenfooting.pl
new file mode 100644
index 0000000000..f39e7aeef3
--- /dev/null
+++ b/tp/t/results/invalid_nestings/thischapter_in_math_in_evenfooting.pl
@@ -0,0 +1,81 @@
+use vars qw(%result_texis %result_texts %result_trees %result_errors
+ %result_indices %result_sectioning %result_nodes %result_menus
+ %result_floats %result_converted %result_converted_errors
+ %result_elements %result_directions_text %result_indices_sort_strings);
+
+use utf8;
+
+$result_trees{'thischapter_in_math_in_evenfooting'} = {
+ 'contents' => [
+ {
+ 'contents' => [
+ {
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ },
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'args' => [
+ {
+ 'contents' => [
+ {
+ 'text' => 'aa '
+ },
+ {
+ 'cmdname' => 'thischapter'
+ }
+ ],
+ 'type' => 'brace_command_context'
+ }
+ ],
+ 'cmdname' => 'math',
+ 'source_info' => {
+ 'line_nr' => 2
+ }
+ }
+ ],
+ 'info' => {
+ 'spaces_after_argument' => {
+ 'text' => '
+'
+ }
+ },
+ 'type' => 'line_arg'
+ }
+ ],
+ 'cmdname' => 'evenfooting',
+ 'info' => {
+ 'spaces_before_argument' => {
+ 'text' => ' '
+ }
+ },
+ 'source_info' => {
+ 'line_nr' => 2
+ }
+ }
+ ],
+ 'type' => 'before_node_section'
+ }
+ ],
+ 'type' => 'document_root'
+};
+
+$result_texis{'thischapter_in_math_in_evenfooting'} = '
+@evenfooting @math{aa @thischapter}
+';
+
+
+$result_texts{'thischapter_in_math_in_evenfooting'} = '
+';
+
+$result_errors{'thischapter_in_math_in_evenfooting'} = [];
+
+
+$result_floats{'thischapter_in_math_in_evenfooting'} = {};
+
+
+1;