[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Texinfo command nesting and syntax checking: nested @ref
From: |
Gavin Smith |
Subject: |
Re: Texinfo command nesting and syntax checking: nested @ref |
Date: |
Tue, 24 Jan 2023 20:21:20 +0000 |
On Mon, Jan 23, 2023 at 08:04:48PM +0000, Gavin Smith wrote:
> In a recent commit I reduced the number of places from three to two. It
> means that spaces are ignored after @caption as caption was inside
> %command_ignore_space_after although this was not being used in the
> removed block of code.
This further change reduces the number of places from two to one. It
means that close_brace_command is always called, not just for erroneous
input.
I will be happy to make the corresponding changes in the Perl code, although
I may not have time to do it before a couple of days.
diff --git a/ChangeLog b/ChangeLog
index 8153b2e3b8..e6b5e8b233 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2023-01-24 Gavin Smith <gavinsmith0123@gmail.com>
+
+ * tp/Texinfo/XS/parsetexi/close.c (close_brace_command): Add
+ argument to control printing of error messages and make non-static
+ function. Pop context stack for BRACE_context commands and
+ decrement nesting context counters.
+ (close_all_style_commands): Remove FIXME about nesting context.
+ (close_current): Do not update context stack or context counters
+ as it is done in close_brace_command.
+
+ * tp/Texinfo/XS/parsetexi/separator.c (handle_close_brace):
+ Always call close_brace_command, so it is no longer just called for
+ erroneous input.
+
2023-01-23 Gavin Smith <gavinsmith0123@gmail.com>
* tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line) <close brace>,
diff --git a/tp/Texinfo/XS/parsetexi/close.c b/tp/Texinfo/XS/parsetexi/close.c
index f640eb24e0..346127a57b 100644
--- a/tp/Texinfo/XS/parsetexi/close.c
+++ b/tp/Texinfo/XS/parsetexi/close.c
@@ -1,4 +1,4 @@
-/* Copyright 2010-2019 Free Software Foundation, Inc.
+/* Copyright 2010-2023 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -20,15 +20,32 @@
#include "parser.h"
-/* Possibly print an error message, and return CURRENT->parent. */
-static ELEMENT *
+/* Return CURRENT->parent. The other arguments are used if an error message
+ should be printed. */
+ELEMENT *
close_brace_command (ELEMENT *current,
enum command_id closed_block_command,
- enum command_id interrupting_command)
+ enum command_id interrupting_command,
+ int missing_brace)
{
KEY_PAIR *k;
+ if (command_data(current->cmd).data == BRACE_context)
+ {
+ if (current->cmd == CM_math)
+ {
+ if (pop_context () != ct_math)
+ fatal ("math context expected");
+ }
+ else if (pop_context () != ct_brace_command)
+ fatal ("context brace command context expected");
+ if (current->cmd == CM_footnote)
+ nesting_context.footnote--;
+ if (current->cmd == CM_caption || current->cmd == CM_shortcaption)
+ nesting_context.caption--;
+ }
+
if (current->cmd != CM_verb)
goto yes;
k = lookup_info (current, "delimiter");
@@ -47,12 +64,12 @@ close_brace_command (ELEMENT *current,
"@%s seen before @%s closing brace",
command_name(interrupting_command),
command_name(current->cmd));
- else
- command_error (current,
+ else if (missing_brace)
+ command_error (current,
"@%s missing closing brace",
command_name(current->cmd));
}
- else
+ else if (missing_brace)
{
command_error (current,
"@%s missing closing delimiter sequence: %s}",
@@ -74,10 +91,8 @@ close_all_style_commands (ELEMENT *current,
&& (command_flags(current->parent) & CF_brace)
&& !(command_data(current->parent->cmd).data == BRACE_context))
current = close_brace_command (current->parent,
- closed_block_command, interrupting_command);
+ closed_block_command, interrupting_command, 1);
- /* FIXME: we don't touch nesting_context here which may lead to erroneous
- warnings. */
return current;
}
@@ -273,23 +288,8 @@ close_current (ELEMENT *current,
debug ("CLOSING (close_current) %s", command_name(current->cmd));
if (command_flags(current) & CF_brace)
{
- if (command_data(current->cmd).data == BRACE_context)
- {
- if (current->cmd == CM_math)
- {
- if (pop_context () != ct_math)
- fatal ("math context expected");
- }
- else if (pop_context () != ct_brace_command)
- fatal ("context brace command context expected");
- if (current->cmd == CM_footnote)
- nesting_context.footnote--;
- if (current->cmd == CM_caption || current->cmd ==
CM_shortcaption)
- nesting_context.caption--;
- }
-
current = close_brace_command (current, closed_block_command,
- interrupting_command);
+ interrupting_command, 1);
}
else if (command_flags(current) & CF_block)
{
diff --git a/tp/Texinfo/XS/parsetexi/parser.h b/tp/Texinfo/XS/parsetexi/parser.h
index f4a128536f..ad191587c9 100644
--- a/tp/Texinfo/XS/parsetexi/parser.h
+++ b/tp/Texinfo/XS/parsetexi/parser.h
@@ -116,6 +116,10 @@ ELEMENT *close_all_style_commands (ELEMENT *current,
ELEMENT *close_current (ELEMENT *current,
enum command_id closed_block_command,
enum command_id interrupting_command);
+ELEMENT *close_brace_command (ELEMENT *current,
+ enum command_id closed_block_command,
+ enum command_id interrupting_command,
+ int missing_brace);
/* In end_line.c */
NODE_SPEC_EXTRA *parse_node_manual (ELEMENT *node);
diff --git a/tp/Texinfo/XS/parsetexi/separator.c
b/tp/Texinfo/XS/parsetexi/separator.c
index 2918f4993b..30d2a64f32 100644
--- a/tp/Texinfo/XS/parsetexi/separator.c
+++ b/tp/Texinfo/XS/parsetexi/separator.c
@@ -253,27 +253,10 @@ handle_close_brace (ELEMENT *current, char **line_inout)
else if (command_flags(current->parent) & CF_brace)
{
enum command_id closed_command;
- if (command_data(current->parent->cmd).data == BRACE_context)
- {
- debug ("CLOSING(context command)");
- if (current->parent->cmd == CM_math)
- {
- if (pop_context () != ct_math)
- fatal ("math context expected");
- }
- else if (pop_context () != ct_brace_command)
- fatal ("context brace command context expected");
- if (current->parent->cmd == CM_footnote)
- nesting_context.footnote--;
- else if (current->parent->cmd == CM_caption
- || current->parent->cmd == CM_shortcaption)
- nesting_context.caption--;
- }
+
/* determine if trailing spaces are ignored */
- else if (command_data(current->parent->cmd).data == BRACE_arguments)
- {
- isolate_last_space (current);
- }
+ if (command_data(current->parent->cmd).data == BRACE_arguments)
+ isolate_last_space (current);
closed_command = current->parent->cmd;
debug ("CLOSING(brace) %s", command_data(closed_command).cmdname);
@@ -520,7 +503,8 @@ handle_close_brace (ELEMENT *current, char **line_inout)
add_to_element_contents (current->parent->parent, e);
}
- current = current->parent->parent;
+ current = close_brace_command (current->parent, 0, 0, 0);
+
if (close_preformatted_command(closed_command))
current = begin_preformatted (current);
} /* CF_brace */
- Re: Texinfo command nesting and syntax checking: nested @ref, (continued)
- Re: Texinfo command nesting and syntax checking: nested @ref, Gavin Smith, 2023/01/18
- Re: Texinfo command nesting and syntax checking: nested @ref, Gavin Smith, 2023/01/18
- Re: Texinfo command nesting and syntax checking: nested @ref, Patrice Dumas, 2023/01/18
- Re: Texinfo command nesting and syntax checking: nested @ref, Gavin Smith, 2023/01/21
- Re: Texinfo command nesting and syntax checking: nested @ref, Patrice Dumas, 2023/01/21
- Re: Texinfo command nesting and syntax checking: nested @ref, Gavin Smith, 2023/01/22
- Re: Texinfo command nesting and syntax checking: nested @ref, Patrice Dumas, 2023/01/24
- Re: Texinfo command nesting and syntax checking: nested @ref, Gavin Smith, 2023/01/29
- Re: Texinfo command nesting and syntax checking: nested @ref, Gavin Smith, 2023/01/23
- Re: Texinfo command nesting and syntax checking: nested @ref,
Gavin Smith <=
- Re: Texinfo command nesting and syntax checking: nested @ref, Gavin Smith, 2023/01/25
Name of "simple text", Gavin Smith, 2023/01/25