[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Gavin D. Smith |
Date: |
Sat, 4 Mar 2023 17:48:23 -0500 (EST) |
branch: master
commit ebe2c167db5905b6ccb7ebf665d5af47c09ad923
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Sat Mar 4 22:48:14 2023 +0000
Multiple @defline in @defblock in texi2any
* tp/Texinfo/XS/parsetexi/handle_commands.c
(handle_line_command) <def command>: Allow for @defline
occurring part way through a @defblock.
* tp/Texinfo/XS/parsetexi/def.c (gather_def_item)
Check for empty contents in block, and for items before a
@defline, gather an element of type 'def_item' rather than
'inter_def_item'.
---
ChangeLog | 12 ++++++++++++
tp/Texinfo/XS/parsetexi/def.c | 8 +++++---
tp/Texinfo/XS/parsetexi/handle_commands.c | 26 ++++++++++++++++++--------
3 files changed, 35 insertions(+), 11 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d412e4940d..401400c3b7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2023-03-04 Gavin Smith <gavinsmith0123@gmail.com>
+
+ Multiple @defline in @defblock in texi2any
+
+ * tp/Texinfo/XS/parsetexi/handle_commands.c
+ (handle_line_command) <def command>: Allow for @defline
+ occurring part way through a @defblock.
+ * tp/Texinfo/XS/parsetexi/def.c (gather_def_item)
+ Check for empty contents in block, and for items before a
+ @defline, gather an element of type 'def_item' rather than
+ 'inter_def_item'.
+
2023-03-04 Gavin Smith <gavinsmith0123@gmail.com>
Multiple @defline in @defblock in texi2any
diff --git a/tp/Texinfo/XS/parsetexi/def.c b/tp/Texinfo/XS/parsetexi/def.c
index e122af8b7b..19134a38c9 100644
--- a/tp/Texinfo/XS/parsetexi/def.c
+++ b/tp/Texinfo/XS/parsetexi/def.c
@@ -30,7 +30,7 @@ gather_def_item (ELEMENT *current, enum command_id
next_command)
ELEMENT *def_item;
int contents_count, i;
- if (next_command)
+ if (next_command && next_command != CM_defline)
type = ET_inter_def_item; /* Between @def*x and @def*. */
else
type = ET_def_item;
@@ -45,11 +45,13 @@ gather_def_item (ELEMENT *current, enum command_id
next_command)
if (command_data(current->cmd).flags & CF_line)
return;
- def_item = new_element (type);
+ contents_count = current->contents.number;
+ if (contents_count == 0)
+ return;
/* Starting from the end, collect everything that is not a ET_def_line and
put it into the ET_def_item. */
- contents_count = current->contents.number;
+ def_item = new_element (type);
for (i = 0; i < contents_count; i++)
{
ELEMENT *last_child, *item_content;
diff --git a/tp/Texinfo/XS/parsetexi/handle_commands.c
b/tp/Texinfo/XS/parsetexi/handle_commands.c
index d8805d5f0d..c2cbcd6362 100644
--- a/tp/Texinfo/XS/parsetexi/handle_commands.c
+++ b/tp/Texinfo/XS/parsetexi/handle_commands.c
@@ -292,12 +292,12 @@ handle_other_command (ELEMENT *current, char **line_inout,
/* STATUS is set to GET_A_NEW_LINE if we should get a new line after this,
to FINISHED_TOTALLY if we should stop processing completely. */
-/* data_cmd (used for the information on the command) and cmd (for the command
name)
- is different for the only multicategory command, @item */
+/* data_cmd (used for the information on the command) and cmd (for the
+ command name) is different for the only multicategory command, @item */
ELEMENT *
handle_line_command (ELEMENT *current, char **line_inout,
- enum command_id cmd, enum command_id data_cmd, int
*status,
- ELEMENT **command_element)
+ enum command_id cmd, enum command_id data_cmd,
+ int *status, ELEMENT **command_element)
{
ELEMENT *command_e = 0;
char *line = *line_inout;
@@ -587,6 +587,8 @@ handle_line_command (ELEMENT *current, char **line_inout,
{
enum command_id base_command;
int after_paragraph;
+ int appropriate_command;
+ enum command_id cmdname;
char *val;
if (cmd == CM_defline)
@@ -619,7 +621,11 @@ handle_line_command (ELEMENT *current, char **line_inout,
add_extra_string (command_e, "def_command", base_name);
}
- after_paragraph = check_no_text (current);
+ cmdname = current->cmd;
+ if (cmdname != CM_defblock)
+ after_paragraph = check_no_text (current);
+ else
+ after_paragraph = 0;
push_context (ct_def, cmd);
command_e->type = ET_def_line;
@@ -628,7 +634,12 @@ handle_line_command (ELEMENT *current, char **line_inout,
if (val)
add_extra_integer (command_e, "omit_def_name_space", 1);
- if (current->cmd == base_command)
+ if (cmdname == base_command || cmdname == CM_defblock)
+ appropriate_command = 1;
+ else
+ appropriate_command = 0;
+
+ if (appropriate_command)
{
ELEMENT *e = pop_element_from_contents (current);
/* e should be the same as command_e */
@@ -636,8 +647,7 @@ handle_line_command (ELEMENT *current, char **line_inout,
gather_def_item (current, cmd);
add_to_element_contents (current, e);
}
- if (current->cmd != base_command && current->cmd != CM_defblock
- || after_paragraph)
+ if (!appropriate_command || after_paragraph)
{
/* error - deffnx not after deffn */
line_error ("must be after `@%s' to use `@%s'",