[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: Hanle brace @-command before opening brace with a
From: |
Patrice Dumas |
Subject: |
branch master updated: Hanle brace @-command before opening brace with another command |
Date: |
Mon, 29 Aug 2022 12:59:14 -0400 |
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 d06b7b92c1 Hanle brace @-command before opening brace with another
command
d06b7b92c1 is described below
commit d06b7b92c18eb0b48589592ecbc7d9b184a4d614
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Aug 29 18:56:37 2022 +0200
Hanle brace @-command before opening brace with another command
* tp/Texinfo/ParserNonXS.pm (_parse_texi),
tp/Texinfo/XS/parsetexi/parser.c (process_remaining_on_line):
close brace @-command if after the command name but before the
brace, and anther @-command is seen before handling unknown
@-command.
---
ChangeLog | 10 ++
tp/Texinfo/ParserNonXS.pm | 40 +++---
tp/Texinfo/XS/parsetexi/parser.c | 39 ++++--
tp/t/02coverage.t | 6 +
.../spaces_unknown_command_after_braced_command.pl | 144 +++++++++++++++++++++
5 files changed, 209 insertions(+), 30 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ed705a581f..fe4f3d84ed 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2022-08-29 Patrice Dumas <pertusus@free.fr>
+
+ Hanle brace @-command before opening brace with another command
+
+ * tp/Texinfo/ParserNonXS.pm (_parse_texi),
+ tp/Texinfo/XS/parsetexi/parser.c (process_remaining_on_line):
+ close brace @-command if after the command name but before the
+ brace, and anther @-command is seen before handling unknown
+ @-command.
+
2022-08-29 Gavin Smith <gavinsmith0123@gmail.com>
* doc/texinfo.tex (\outerhsize, \outervsize, \topandbottommargin):
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 38df6a910e..1acead1102 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -4227,6 +4227,23 @@ sub _parse_texi($$$)
$current = $current->{'parent'};
}
+ # command but before an opening brace, otherwise $current
+ # would be an argument type and not the command, and a new
+ # @-command was found. This means that the $current->{'cmdname'}
+ # argument (an opening brace, or a character after spaces for
+ # accent commands) was not found and there is already a new command.
+ #
+ # It would have been nice to allow for comments, but there is no
+ # container in the tree to put them when after command and before brace
+ # or argument for accent commands.
+ if ($command
+ and $current->{'cmdname'}
+ and defined($brace_commands{$current->{'cmdname'}})) {
+ $self->_line_error(sprintf(__("\@%s expected braces"),
+ $current->{'cmdname'}), $source_info);
+ $current = $current->{'parent'};
+ }
+
# handle unknown @-command
if ($command and !$all_commands{$command}
and !$self->{'definfoenclose'}->{$command}
@@ -4244,25 +4261,6 @@ sub _parse_texi($$$)
}
# this situation arises when after the $current->{'cmdname'}
- # command but before an opening brace, otherwise $current
- # would be an argument type and not the command, and a new
- # @-command was found. This means that the $current->{'cmdname'}
- # argument (an opening brace, or a character after spaces for
- # accent commands) was not found and there is already a new command.
- #
- # It would have been nice to allow for comments, but there is no
- # container in the tree to put them when after command and before brace
- # or argument for accent commands.
- # FIXME this is sort of a duplicate of what is happening later
- # with the condition of !$open_brace. It could allow for more
- # precise error messages.
- if ($command
- and $current->{'cmdname'}
- and defined($brace_commands{$current->{'cmdname'}})) {
- $self->_line_error(sprintf(__("\@%s expected braces"),
- $current->{'cmdname'}), $source_info);
- $current = $current->{'parent'};
-
# Brace commands not followed immediately by a brace
# opening. In particular cases that may lead to "command closing"
# or following character association with an @-command, for accent
@@ -4271,8 +4269,7 @@ sub _parse_texi($$$)
# This condition can only happen immediately after the command opening,
# otherwise the current element is in the 'args' and not right in the
# command container.
- } elsif ($current->{'cmdname'}
- #if ($current->{'cmdname'}
+ if ($current->{'cmdname'}
and defined($brace_commands{$current->{'cmdname'}})
and !$open_brace) {
print STDERR "BRACE CMD: no brace after \@$current->{'cmdname'}: $line"
@@ -4448,6 +4445,7 @@ sub _parse_texi($$$)
print STDERR "COMMAND $command\n" if ($self->{'DEBUG'});
+ # @value not expanded (expansion is done above), and @txiinternalvalue
if ($command eq 'value' or $command eq 'txiinternalvalue') {
$line =~ s/^\s*//
if ($self->{'IGNORE_SPACE_AFTER_BRACED_COMMAND_NAME'});
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index 8c7eb4add0..99aa7adc5d 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -1041,9 +1041,10 @@ process_remaining_on_line (ELEMENT **current_inout, char
**line_inout)
int retval = STILL_MORE_TO_PROCESS;
enum command_id end_cmd;
char *p;
- int unknown_command = 0;
enum command_id cmd = CM_NONE;
+ /* remains set only if command is unknown, otherwise cmd is used */
+ char *command;
/********* BLOCK_raw or (ignored) BLOCK_conditional ******************/
/* If in raw block, or ignored conditional block. */
@@ -1364,19 +1365,18 @@ superfluous_arg:
}
else
{
- char *command = read_command_name (&line_after_command);
+ command = read_command_name (&line_after_command);
cmd = 0;
if (command)
{
cmd = lookup_command (command);
- if (!cmd)
+ /* known command */
+ if (cmd)
{
- line_error ("unknown command `%s'", command);
- debug ("COMMAND (UNKNOWN) %s", command);
- unknown_command = 1;
+ free (command);
}
- free (command);
+ /* command holds the unknown command name if !cmd && command */
}
else
{
@@ -1464,10 +1464,31 @@ superfluous_arg:
current = current->parent;
}
- if (unknown_command)
+ /* command but before an opening brace, otherwise current
+ would be an argument type and not the command, and a new
+ @-command was found. This means that the current->cmd
+ argument (an opening brace, or a character after spaces for
+ accent commands) was not found and there is already a new command.
+
+ It would have been nice to allow for comments, but there is no
+ container in the tree to put them when after command and before brace
+ or argument for accent commands. */
+
+ if (command_flags(current) & CF_brace && (cmd || command))
+ {
+ line_error ("@%s expected braces",
+ command_name(current->cmd));
+ current = current->parent;
+ }
+
+ /* Handle unknown command. */
+ if (!cmd && command)
{
ELEMENT *paragraph;
+ line_error ("unknown command `%s'", command);
+ debug ("COMMAND (UNKNOWN) %s", command);
+ free (command);
abort_empty_line (¤t, 0);
paragraph = begin_paragraph (current);
if (paragraph)
@@ -1582,7 +1603,7 @@ superfluous_arg:
line = line_after_command;
debug ("COMMAND %s", command_name(cmd));
- /* @value and @txiinternalvalue */
+ /* @value not expanded (expansion is done above), and @txiinternalvalue
*/
if ((cmd == CM_value) || (cmd == CM_txiinternalvalue))
{
char *arg_start;
diff --git a/tp/t/02coverage.t b/tp/t/02coverage.t
index 85acd90803..d6c23f79fa 100644
--- a/tp/t/02coverage.t
+++ b/tp/t/02coverage.t
@@ -705,6 +705,12 @@ cut by blank line}
['spaces_no_brace_after_braced_command',
'@code b
'],
+['spaces_unknown_command_after_braced_command',
+'@code @unknown
+
+@~ @notexisting
+ e
+'],
['flushright_not_closed',
'@flushright
diff --git
a/tp/t/results/coverage/spaces_unknown_command_after_braced_command.pl
b/tp/t/results/coverage/spaces_unknown_command_after_braced_command.pl
new file mode 100644
index 0000000000..d8ccf64ab3
--- /dev/null
+++ b/tp/t/results/coverage/spaces_unknown_command_after_braced_command.pl
@@ -0,0 +1,144 @@
+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{'spaces_unknown_command_after_braced_command'} = {
+ 'contents' => [
+ {
+ 'contents' => [
+ {
+ 'contents' => [
+ {
+ 'cmdname' => 'code',
+ 'contents' => [],
+ 'extra' => {
+ 'spaces' => ' '
+ },
+ 'parent' => {},
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 1,
+ 'macro' => ''
+ }
+ },
+ {
+ 'parent' => {},
+ 'text' => '
+'
+ }
+ ],
+ 'parent' => {},
+ 'type' => 'paragraph'
+ },
+ {
+ 'parent' => {},
+ 'text' => '
+',
+ 'type' => 'empty_line'
+ },
+ {
+ 'contents' => [
+ {
+ 'cmdname' => '~',
+ 'contents' => [],
+ 'extra' => {
+ 'spaces' => ' '
+ },
+ 'parent' => {},
+ 'source_info' => {
+ 'file_name' => '',
+ 'line_nr' => 3,
+ 'macro' => ''
+ }
+ },
+ {
+ 'parent' => {},
+ 'text' => '
+'
+ },
+ {
+ 'parent' => {},
+ 'text' => ' e
+'
+ }
+ ],
+ 'parent' => {},
+ 'type' => 'paragraph'
+ }
+ ],
+ 'parent' => {},
+ 'type' => 'before_node_section'
+ }
+ ],
+ 'type' => 'document_root'
+};
+$result_trees{'spaces_unknown_command_after_braced_command'}{'contents'}[0]{'contents'}[0]{'contents'}[0]{'parent'}
=
$result_trees{'spaces_unknown_command_after_braced_command'}{'contents'}[0]{'contents'}[0];
+$result_trees{'spaces_unknown_command_after_braced_command'}{'contents'}[0]{'contents'}[0]{'contents'}[1]{'parent'}
=
$result_trees{'spaces_unknown_command_after_braced_command'}{'contents'}[0]{'contents'}[0];
+$result_trees{'spaces_unknown_command_after_braced_command'}{'contents'}[0]{'contents'}[0]{'parent'}
= $result_trees{'spaces_unknown_command_after_braced_command'}{'contents'}[0];
+$result_trees{'spaces_unknown_command_after_braced_command'}{'contents'}[0]{'contents'}[1]{'parent'}
= $result_trees{'spaces_unknown_command_after_braced_command'}{'contents'}[0];
+$result_trees{'spaces_unknown_command_after_braced_command'}{'contents'}[0]{'contents'}[2]{'contents'}[0]{'parent'}
=
$result_trees{'spaces_unknown_command_after_braced_command'}{'contents'}[0]{'contents'}[2];
+$result_trees{'spaces_unknown_command_after_braced_command'}{'contents'}[0]{'contents'}[2]{'contents'}[1]{'parent'}
=
$result_trees{'spaces_unknown_command_after_braced_command'}{'contents'}[0]{'contents'}[2];
+$result_trees{'spaces_unknown_command_after_braced_command'}{'contents'}[0]{'contents'}[2]{'contents'}[2]{'parent'}
=
$result_trees{'spaces_unknown_command_after_braced_command'}{'contents'}[0]{'contents'}[2];
+$result_trees{'spaces_unknown_command_after_braced_command'}{'contents'}[0]{'contents'}[2]{'parent'}
= $result_trees{'spaces_unknown_command_after_braced_command'}{'contents'}[0];
+$result_trees{'spaces_unknown_command_after_braced_command'}{'contents'}[0]{'parent'}
= $result_trees{'spaces_unknown_command_after_braced_command'};
+
+$result_texis{'spaces_unknown_command_after_braced_command'} = '@code
+
+@~
+ e
+';
+
+
+$result_texts{'spaces_unknown_command_after_braced_command'} = '
+
+~
+ e
+';
+
+$result_errors{'spaces_unknown_command_after_braced_command'} = [
+ {
+ 'error_line' => '@code expected braces
+',
+ 'file_name' => '',
+ 'line_nr' => 1,
+ 'macro' => '',
+ 'text' => '@code expected braces',
+ 'type' => 'error'
+ },
+ {
+ 'error_line' => 'unknown command `unknown\'
+',
+ 'file_name' => '',
+ 'line_nr' => 1,
+ 'macro' => '',
+ 'text' => 'unknown command `unknown\'',
+ 'type' => 'error'
+ },
+ {
+ 'error_line' => '@~ expected braces
+',
+ 'file_name' => '',
+ 'line_nr' => 3,
+ 'macro' => '',
+ 'text' => '@~ expected braces',
+ 'type' => 'error'
+ },
+ {
+ 'error_line' => 'unknown command `notexisting\'
+',
+ 'file_name' => '',
+ 'line_nr' => 3,
+ 'macro' => '',
+ 'text' => 'unknown command `notexisting\'',
+ 'type' => 'error'
+ }
+];
+
+
+$result_floats{'spaces_unknown_command_after_braced_command'} = {};
+
+
+1;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: Hanle brace @-command before opening brace with another command,
Patrice Dumas <=