[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: Warning for block commands without argument with
From: |
Patrice Dumas |
Subject: |
branch master updated: Warning for block commands without argument with an argument |
Date: |
Sat, 24 Dec 2022 16:10:19 -0500 |
This is an automated email from the git hooks/post-receive script.
pertusus pushed a commit to branch master
in repository texinfo.
The following commit(s) were added to refs/heads/master by this push:
new 6898ab9279 Warning for block commands without argument with an argument
6898ab9279 is described below
commit 6898ab9279d69974fdfd9890d210b494fa088ffd
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Dec 24 22:10:07 2022 +0100
Warning for block commands without argument with an argument
* tp/Texinfo/ParserNonXS.pm (_end_line_starting_block),
tp/Texinfo/XS/parsetexi/end_line.c (end_line_starting_block):
warn if a block command with 0 argument, and not a variadic command
has arguments on the line.
---
ChangeLog | 9 +++++++
tp/TODO | 10 +++-----
tp/Texinfo/ParserNonXS.pm | 19 +++++++++++---
tp/Texinfo/XS/parsetexi/end_line.c | 18 +++++++++++--
.../coverage/group_beginning_and_end_on_line.pl | 9 +++++++
.../preformatted/text_on_display_command_line.pl | 18 +++++++++++++
tp/t/results/raw/beginning_and_end_on_line.pl | 27 +++++++++++++++++++
tp/t/results/raw/misc_raw.pl | 9 +++++++
tp/t/results/raw/misc_raw_comments.pl | 9 +++++++
tp/t/results/raw/spurious_arg_on_line.pl | 30 +++++++++++++++++++++-
tp/t/results/xml_tests/spaces_info_lost.pl | 12 ++++++++-
tp/tests/many_input_files/tex_l2h_res/tex_l2h.2 | 2 ++
tp/tests/many_input_files/tex_t4ht_res/tex_t4ht.2 | 2 ++
tp/tests/tex_html/res_parser/tex/tex.2 | 2 ++
tp/tests/tex_html/res_parser/tex_l2h_latex/tex.2 | 2 ++
.../tex_html/res_parser/tex_l2h_tex_latex/tex.2 | 2 ++
tp/tests/tex_html/res_parser/tex_mathjax/tex.2 | 2 ++
tp/tests/tex_html/res_parser/tex_notex/tex.2 | 2 ++
18 files changed, 169 insertions(+), 15 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index a2afc49c78..edd1d25171 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2022-12-24 Patrice Dumas <pertusus@free.fr>
+
+ Warning for block commands without argument with an argument
+
+ * tp/Texinfo/ParserNonXS.pm (_end_line_starting_block),
+ tp/Texinfo/XS/parsetexi/end_line.c (end_line_starting_block):
+ warn if a block command with 0 argument, and not a variadic command
+ has arguments on the line.
+
2022-12-24 Patrice Dumas <pertusus@free.fr>
* doc/Makefile.am (TEXINFO_TEX): use in-source texinfo.tex.
diff --git a/tp/TODO b/tp/TODO
index d68ff237f2..0695bdbe13 100644
--- a/tp/TODO
+++ b/tp/TODO
@@ -57,8 +57,6 @@ expanded. For example
truc @value{closebrace}
machin
-In Plaintext, @quotation text should have the right margin narrowed.
-
Text after @bye should be kept as is when redoing Texinfo.
Sorting of index entries should be language dependent and sort properly
@@ -125,11 +123,6 @@ In fact @image is completly formatted outside of usual
formatting containers.
Not sure what should be the right way?
test in info_test/image_and_punctuation
-There could be a warning for block commands without argument
-that have an argument on their line, like:
-@blockcmd text
-...
-
Image on sectioning command line haven't their length ignored correctly.
Not sure it is a big deal. An example in sectioning/at_commands_in_refs.
@@ -246,6 +239,9 @@ For plaintext, implement an effect of NO_TOP_NODE_OUTPUT
* if false, current output is ok
Default is false.
+In Plaintext, @quotation text could have the right margin narrowed to be more
+in line with other output formats.
+
DocBook
-------
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index d5b0ea85c2..078d0e464d 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -3426,11 +3426,10 @@ sub _end_line_starting_block($$$)
_register_label($self->{'targets'}, $current, $float_label);
$current->{'extra'}->{'float_section'} = $self->{'current_section'}
if (defined($self->{'current_section'}));
- }
- # all the commands with @item
- if ($current->{'cmdname'}
- and $blockitem_commands{$current->{'cmdname'}}) {
+ # all the commands with @item
+ } elsif ($current->{'cmdname'}
+ and $blockitem_commands{$current->{'cmdname'}}) {
if ($current->{'cmdname'} eq 'enumerate') {
my $spec = '1';
if ($current->{'args'} and $current->{'args'}->[0]
@@ -3560,6 +3559,18 @@ sub _end_line_starting_block($$$)
push @{$current->{'contents'}}, { 'type' => 'before_item',
'parent', $current };
$current = $current->{'contents'}->[-1];
+ } elsif (not $commands_args_number{$current->{'cmdname'}}
+ and not exists($variadic_commands{$current->{'cmdname'}})
+ and $current->{'args'}
+ and scalar(@{$current->{'args'}})
+ and $current->{'args'}->[0]->{'contents'}
+ and scalar(@{$current->{'args'}->[0]->{'contents'}})) {
+ # expand the contents to avoid surrounding spaces
+ my $texi_arg = Texinfo::Convert::Texinfo::convert_to_texinfo(
+ {'contents' => $current->{'args'}->[0]->{'contents'}});
+ $self->_command_warn($current, $source_info,
+ __("unexpected argument on \@%s line: %s"),
+ $current->{'cmdname'}, $texi_arg);
}
if ($current->{'cmdname'}
and $block_commands{$current->{'cmdname'}} eq 'menu') {
diff --git a/tp/Texinfo/XS/parsetexi/end_line.c
b/tp/Texinfo/XS/parsetexi/end_line.c
index 98d0b882f1..b99ff1a836 100644
--- a/tp/Texinfo/XS/parsetexi/end_line.c
+++ b/tp/Texinfo/XS/parsetexi/end_line.c
@@ -1126,8 +1126,7 @@ end_line_starting_block (ELEMENT *current)
if (current_section)
add_extra_element (current, "float_section", current_section);
}
-
- if (command_flags(current) & CF_blockitem)
+ else if (command_flags(current) & CF_blockitem)
{
if (current->cmd == CM_enumerate)
{
@@ -1299,6 +1298,21 @@ end_line_starting_block (ELEMENT *current)
current = bi;
}
} /* CF_blockitem */
+ else if (command_data (current->cmd).args_number == 0
+ && ! command_data (current->cmd).flags & CF_variadic
+ && current->args.number > 0
+ && current->args.list[0]->contents.number > 0)
+ {
+ ELEMENT tmp;
+ char *texi_arg;
+
+ /* expand the contents to avoid surrounding spaces */
+ memset (&tmp, 0, sizeof (ELEMENT));
+ tmp.contents = current->args.list[0]->contents;
+ texi_arg = convert_to_texinfo (&tmp);
+ command_warn (current, "unexpected argument on @%s line: %s",
+ command_name(current->cmd), texi_arg);
+ }
if (command_data(current->cmd).data == BLOCK_menu)
{
diff --git a/tp/t/results/coverage/group_beginning_and_end_on_line.pl
b/tp/t/results/coverage/group_beginning_and_end_on_line.pl
index 608acf3792..1e70f3f1e3 100644
--- a/tp/t/results/coverage/group_beginning_and_end_on_line.pl
+++ b/tp/t/results/coverage/group_beginning_and_end_on_line.pl
@@ -85,6 +85,15 @@ $result_errors{'group_beginning_and_end_on_line'} = [
'macro' => '',
'text' => '@end should only appear at the beginning of a line',
'type' => 'warning'
+ },
+ {
+ 'error_line' => 'warning: unexpected argument on @group line: within
+',
+ 'file_name' => '',
+ 'line_nr' => 1,
+ 'macro' => '',
+ 'text' => 'unexpected argument on @group line: within',
+ 'type' => 'warning'
}
];
diff --git a/tp/t/results/preformatted/text_on_display_command_line.pl
b/tp/t/results/preformatted/text_on_display_command_line.pl
index c9d3a5dbff..78bd013919 100644
--- a/tp/t/results/preformatted/text_on_display_command_line.pl
+++ b/tp/t/results/preformatted/text_on_display_command_line.pl
@@ -326,6 +326,24 @@ in display
';
$result_errors{'text_on_display_command_line'} = [
+ {
+ 'error_line' => 'warning: unexpected argument on @display line: text on
line
+',
+ 'file_name' => '',
+ 'line_nr' => 1,
+ 'macro' => '',
+ 'text' => 'unexpected argument on @display line: text on line',
+ 'type' => 'warning'
+ },
+ {
+ 'error_line' => 'warning: unexpected argument on @display line: text on
line followed by text
+',
+ 'file_name' => '',
+ 'line_nr' => 4,
+ 'macro' => '',
+ 'text' => 'unexpected argument on @display line: text on line followed by
text',
+ 'type' => 'warning'
+ },
{
'error_line' => 'bad argument to @end: display text after end
',
diff --git a/tp/t/results/raw/beginning_and_end_on_line.pl
b/tp/t/results/raw/beginning_and_end_on_line.pl
index c9fea17de4..5c2c2172ff 100644
--- a/tp/t/results/raw/beginning_and_end_on_line.pl
+++ b/tp/t/results/raw/beginning_and_end_on_line.pl
@@ -220,6 +220,15 @@ $result_errors{'beginning_and_end_on_line'} = [
'text' => '@end should only appear at the beginning of a line',
'type' => 'warning'
},
+ {
+ 'error_line' => 'warning: unexpected argument on @tex line: in tex
+',
+ 'file_name' => '',
+ 'line_nr' => 2,
+ 'macro' => '',
+ 'text' => 'unexpected argument on @tex line: in tex',
+ 'type' => 'warning'
+ },
{
'error_line' => 'warning: @end should only appear at the beginning of a
line
',
@@ -229,6 +238,15 @@ $result_errors{'beginning_and_end_on_line'} = [
'text' => '@end should only appear at the beginning of a line',
'type' => 'warning'
},
+ {
+ 'error_line' => 'warning: unexpected argument on @verbatim line: in
verbatim
+',
+ 'file_name' => '',
+ 'line_nr' => 4,
+ 'macro' => '',
+ 'text' => 'unexpected argument on @verbatim line: in verbatim',
+ 'type' => 'warning'
+ },
{
'error_line' => 'warning: @end should only appear at the beginning of a
line
',
@@ -237,6 +255,15 @@ $result_errors{'beginning_and_end_on_line'} = [
'macro' => '',
'text' => '@end should only appear at the beginning of a line',
'type' => 'warning'
+ },
+ {
+ 'error_line' => 'warning: unexpected argument on @html line: in html
+',
+ 'file_name' => '',
+ 'line_nr' => 6,
+ 'macro' => '',
+ 'text' => 'unexpected argument on @html line: in html',
+ 'type' => 'warning'
}
];
diff --git a/tp/t/results/raw/misc_raw.pl b/tp/t/results/raw/misc_raw.pl
index 2e329362fd..6047ac08ae 100644
--- a/tp/t/results/raw/misc_raw.pl
+++ b/tp/t/results/raw/misc_raw.pl
@@ -228,6 +228,15 @@ $result_errors{'misc_raw'} = [
'macro' => '',
'text' => '@end should only appear at the beginning of a line',
'type' => 'warning'
+ },
+ {
+ 'error_line' => 'warning: unexpected argument on @tex line: in tex
+',
+ 'file_name' => '',
+ 'line_nr' => 5,
+ 'macro' => '',
+ 'text' => 'unexpected argument on @tex line: in tex',
+ 'type' => 'warning'
}
];
diff --git a/tp/t/results/raw/misc_raw_comments.pl
b/tp/t/results/raw/misc_raw_comments.pl
index 9c2229439d..1fc141bd31 100644
--- a/tp/t/results/raw/misc_raw_comments.pl
+++ b/tp/t/results/raw/misc_raw_comments.pl
@@ -274,6 +274,15 @@ $result_errors{'misc_raw_comments'} = [
'macro' => '',
'text' => '@end should only appear at the beginning of a line',
'type' => 'warning'
+ },
+ {
+ 'error_line' => 'warning: unexpected argument on @tex line: in tex
+',
+ 'file_name' => '',
+ 'line_nr' => 5,
+ 'macro' => '',
+ 'text' => 'unexpected argument on @tex line: in tex',
+ 'type' => 'warning'
}
];
diff --git a/tp/t/results/raw/spurious_arg_on_line.pl
b/tp/t/results/raw/spurious_arg_on_line.pl
index 294b1d3738..060830ec4e 100644
--- a/tp/t/results/raw/spurious_arg_on_line.pl
+++ b/tp/t/results/raw/spurious_arg_on_line.pl
@@ -233,7 +233,35 @@ in verbatim
';
-$result_errors{'spurious_arg_on_line'} = [];
+$result_errors{'spurious_arg_on_line'} = [
+ {
+ 'error_line' => 'warning: unexpected argument on @tex line: argt
+',
+ 'file_name' => '',
+ 'line_nr' => 2,
+ 'macro' => '',
+ 'text' => 'unexpected argument on @tex line: argt',
+ 'type' => 'warning'
+ },
+ {
+ 'error_line' => 'warning: unexpected argument on @verbatim line:
argverbatim
+',
+ 'file_name' => '',
+ 'line_nr' => 6,
+ 'macro' => '',
+ 'text' => 'unexpected argument on @verbatim line: argverbatim',
+ 'type' => 'warning'
+ },
+ {
+ 'error_line' => 'warning: unexpected argument on @html line: argh
+',
+ 'file_name' => '',
+ 'line_nr' => 10,
+ 'macro' => '',
+ 'text' => 'unexpected argument on @html line: argh',
+ 'type' => 'warning'
+ }
+];
$result_floats{'spurious_arg_on_line'} = {};
diff --git a/tp/t/results/xml_tests/spaces_info_lost.pl
b/tp/t/results/xml_tests/spaces_info_lost.pl
index f69fa32f9d..aa65100986 100644
--- a/tp/t/results/xml_tests/spaces_info_lost.pl
+++ b/tp/t/results/xml_tests/spaces_info_lost.pl
@@ -152,7 +152,17 @@ $result_texts{'spaces_info_lost'} = 'in bad display
in verbatim @g
';
-$result_errors{'spaces_info_lost'} = [];
+$result_errors{'spaces_info_lost'} = [
+ {
+ 'error_line' => 'warning: unexpected argument on @display line: text on
display line
+',
+ 'file_name' => '',
+ 'line_nr' => 1,
+ 'macro' => '',
+ 'text' => 'unexpected argument on @display line: text on display line',
+ 'type' => 'warning'
+ }
+];
$result_floats{'spaces_info_lost'} = {};
diff --git a/tp/tests/many_input_files/tex_l2h_res/tex_l2h.2
b/tp/tests/many_input_files/tex_l2h_res/tex_l2h.2
index b8937a9ad1..a8ea018d76 100644
--- a/tp/tests/many_input_files/tex_l2h_res/tex_l2h.2
+++ b/tp/tests/many_input_files/tex_l2h_res/tex_l2h.2
@@ -1,5 +1,7 @@
texexpand
tex.texi:7: warning: @tex should only appear at the beginning of a line
+tex.texi:7: warning: unexpected argument on @tex line: some
tex.texi:14: bad argument to @end: tex bidule
+tex.texi:27: warning: unexpected argument on @tex line: some
tex.texi:54: warning: @\ should only appear in math context
texexpand
diff --git a/tp/tests/many_input_files/tex_t4ht_res/tex_t4ht.2
b/tp/tests/many_input_files/tex_t4ht_res/tex_t4ht.2
index 65837b3198..d96b7bda50 100644
--- a/tp/tests/many_input_files/tex_t4ht_res/tex_t4ht.2
+++ b/tp/tests/many_input_files/tex_t4ht_res/tex_t4ht.2
@@ -1,3 +1,5 @@
tex.texi:7: warning: @tex should only appear at the beginning of a line
+tex.texi:7: warning: unexpected argument on @tex line: some
tex.texi:14: bad argument to @end: tex bidule
+tex.texi:27: warning: unexpected argument on @tex line: some
tex.texi:54: warning: @\ should only appear in math context
diff --git a/tp/tests/tex_html/res_parser/tex/tex.2
b/tp/tests/tex_html/res_parser/tex/tex.2
index 0aaa627853..a0c2679059 100644
--- a/tp/tests/tex_html/res_parser/tex/tex.2
+++ b/tp/tests/tex_html/res_parser/tex/tex.2
@@ -1,4 +1,6 @@
tex.texi:7: warning: @tex should only appear at the beginning of a line
+tex.texi:7: warning: unexpected argument on @tex line: some
tex.texi:14: bad argument to @end: tex bidule
+tex.texi:27: warning: unexpected argument on @tex line: some
tex.texi:54: warning: @\ should only appear in math context
texexpand
diff --git a/tp/tests/tex_html/res_parser/tex_l2h_latex/tex.2
b/tp/tests/tex_html/res_parser/tex_l2h_latex/tex.2
index 0aaa627853..a0c2679059 100644
--- a/tp/tests/tex_html/res_parser/tex_l2h_latex/tex.2
+++ b/tp/tests/tex_html/res_parser/tex_l2h_latex/tex.2
@@ -1,4 +1,6 @@
tex.texi:7: warning: @tex should only appear at the beginning of a line
+tex.texi:7: warning: unexpected argument on @tex line: some
tex.texi:14: bad argument to @end: tex bidule
+tex.texi:27: warning: unexpected argument on @tex line: some
tex.texi:54: warning: @\ should only appear in math context
texexpand
diff --git a/tp/tests/tex_html/res_parser/tex_l2h_tex_latex/tex.2
b/tp/tests/tex_html/res_parser/tex_l2h_tex_latex/tex.2
index 0aaa627853..a0c2679059 100644
--- a/tp/tests/tex_html/res_parser/tex_l2h_tex_latex/tex.2
+++ b/tp/tests/tex_html/res_parser/tex_l2h_tex_latex/tex.2
@@ -1,4 +1,6 @@
tex.texi:7: warning: @tex should only appear at the beginning of a line
+tex.texi:7: warning: unexpected argument on @tex line: some
tex.texi:14: bad argument to @end: tex bidule
+tex.texi:27: warning: unexpected argument on @tex line: some
tex.texi:54: warning: @\ should only appear in math context
texexpand
diff --git a/tp/tests/tex_html/res_parser/tex_mathjax/tex.2
b/tp/tests/tex_html/res_parser/tex_mathjax/tex.2
index 7c806c8bb9..66b53aed18 100644
--- a/tp/tests/tex_html/res_parser/tex_mathjax/tex.2
+++ b/tp/tests/tex_html/res_parser/tex_mathjax/tex.2
@@ -1,5 +1,7 @@
tex.texi:7: warning: @tex should only appear at the beginning of a line
+tex.texi:7: warning: unexpected argument on @tex line: some
tex.texi:14: bad argument to @end: tex bidule
+tex.texi:27: warning: unexpected argument on @tex line: some
tex.texi:54: warning: @\ should only appear in math context
tex.texi:7: warning: raw format tex is not converted
tex.texi:27: warning: raw format tex is not converted
diff --git a/tp/tests/tex_html/res_parser/tex_notex/tex.2
b/tp/tests/tex_html/res_parser/tex_notex/tex.2
index 65837b3198..d96b7bda50 100644
--- a/tp/tests/tex_html/res_parser/tex_notex/tex.2
+++ b/tp/tests/tex_html/res_parser/tex_notex/tex.2
@@ -1,3 +1,5 @@
tex.texi:7: warning: @tex should only appear at the beginning of a line
+tex.texi:7: warning: unexpected argument on @tex line: some
tex.texi:14: bad argument to @end: tex bidule
+tex.texi:27: warning: unexpected argument on @tex line: some
tex.texi:54: warning: @\ should only appear in math context
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: Warning for block commands without argument with an argument,
Patrice Dumas <=