[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: Avoid using C specific types in code
From: |
Patrice Dumas |
Subject: |
branch master updated: Avoid using C specific types in code |
Date: |
Wed, 23 Oct 2024 18:04:21 -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 81d0dafca1 Avoid using C specific types in code
81d0dafca1 is described below
commit 81d0dafca1f4f3c8de762edb712aee64589f322e
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Thu Oct 24 00:04:15 2024 +0200
Avoid using C specific types in code
* tp/Texinfo/XS/main/convert_to_text.c (convert_to_text_internal): use
CF_block instead of ET_block_command and CF_line instead of
ET_line_command and ET_lineraw_command.
* tp/Texinfo/XS/main/convert_utils.c (find_innermost_accent_contents),
tp/Texinfo/XS/parsetexi/close.c (close_command_cleanup),
tp/Texinfo/XS/parsetexi/end_line.c (end_line_starting_block),
tp/Texinfo/XS/parsetexi/menus.c (end_line_menu_entry),
tp/Texinfo/XS/parsetexi/multitable.c (gather_previous_item),
tp/Texinfo/XS/parsetexi/parser.c (isolate_last_space): use TF_text to
determine if the cmd element can be accessed instead of C only types.
---
ChangeLog | 16 ++++++++++++++++
tp/Texinfo/XS/main/convert_to_text.c | 10 ++++------
tp/Texinfo/XS/main/convert_utils.c | 2 +-
tp/Texinfo/XS/main/element_types.txt | 4 +++-
tp/Texinfo/XS/parsetexi/close.c | 2 +-
tp/Texinfo/XS/parsetexi/end_line.c | 2 +-
tp/Texinfo/XS/parsetexi/menus.c | 5 +++--
tp/Texinfo/XS/parsetexi/multitable.c | 5 +++--
tp/Texinfo/XS/parsetexi/parser.c | 2 +-
9 files changed, 33 insertions(+), 15 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e3c02b31c6..a8026cc01e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2024-10-23 Patrice Dumas <pertusus@free.fr>
+
+ Avoid using C specific types in code
+
+ * tp/Texinfo/XS/main/convert_to_text.c (convert_to_text_internal): use
+ CF_block instead of ET_block_command and CF_line instead of
+ ET_line_command and ET_lineraw_command.
+
+ * tp/Texinfo/XS/main/convert_utils.c (find_innermost_accent_contents),
+ tp/Texinfo/XS/parsetexi/close.c (close_command_cleanup),
+ tp/Texinfo/XS/parsetexi/end_line.c (end_line_starting_block),
+ tp/Texinfo/XS/parsetexi/menus.c (end_line_menu_entry),
+ tp/Texinfo/XS/parsetexi/multitable.c (gather_previous_item),
+ tp/Texinfo/XS/parsetexi/parser.c (isolate_last_space): use TF_text to
+ determine if the cmd element can be accessed instead of C only types.
+
2024-10-23 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/main/element_types.txt,
diff --git a/tp/Texinfo/XS/main/convert_to_text.c
b/tp/Texinfo/XS/main/convert_to_text.c
index b8af425baa..c041399ccd 100644
--- a/tp/Texinfo/XS/main/convert_to_text.c
+++ b/tp/Texinfo/XS/main/convert_to_text.c
@@ -601,21 +601,19 @@ convert_to_text_internal (const ELEMENT *element,
TEXT_OPTIONS *text_options,
/* hyphenation anchor errormsg sortas caption shortcaption */
if (builtin_command_data[data_cmd].other_flags & CF_non_formatted_brace
- || (element->type == ET_block_command
+ || (builtin_command_data[data_cmd].flags & CF_block
&& (/* ignored_block_commands */
/* titlepage copying documentdescription */
builtin_command_data[data_cmd].data == BLOCK_region
- /* ignore nodedescriptionblock (would also have ignored @*macro
- if their type was ET_block_command */
+ /* ignore nodedescriptionblock, @*macro */
|| builtin_command_data[data_cmd].other_flags
& CF_non_formatted_block
|| (/* html tex xml docbook latex */
builtin_command_data[data_cmd].data == BLOCK_format_raw
&& !format_expanded_p (text_options->expanded_formats,
builtin_command_name (data_cmd)))))
- /* here ignore most of the line commands, and also @*macro */
- || ((element->type == ET_line_command
- || element->type == ET_lineraw_command
+ /* here ignore most of the line commands */
+ || ((builtin_command_data[data_cmd].flags & CF_line
|| element->type == ET_index_entry_command)
&& !(builtin_command_data[data_cmd].other_flags
& CF_formatted_line)
diff --git a/tp/Texinfo/XS/main/convert_utils.c
b/tp/Texinfo/XS/main/convert_utils.c
index d344fa4212..ca21707cdb 100644
--- a/tp/Texinfo/XS/main/convert_utils.c
+++ b/tp/Texinfo/XS/main/convert_utils.c
@@ -133,7 +133,7 @@ find_innermost_accent_contents (const ELEMENT *element)
enum command_id data_cmd;
unsigned long flags;
- if (current->type != ET_brace_command)
+ if (type_data[current->type].flags & TF_text)
return accent_stack;
data_cmd = element_builtin_data_cmd (current);
diff --git a/tp/Texinfo/XS/main/element_types.txt
b/tp/Texinfo/XS/main/element_types.txt
index f103a6e56c..e584557db2 100644
--- a/tp/Texinfo/XS/main/element_types.txt
+++ b/tp/Texinfo/XS/main/element_types.txt
@@ -47,7 +47,9 @@
index_entry_command spaces_before
definfoenclose_command braces
-# only in C
+# only in C. These types should not be used in code except to set the
+# type at the element creation, except maybe to help with the handling
+# of C specific data (case of ET_lineraw_command to check/select string_info)
nobrace_command c_only
brace_noarg_command braces,c_only
# @item, @tab
diff --git a/tp/Texinfo/XS/parsetexi/close.c b/tp/Texinfo/XS/parsetexi/close.c
index 238bb3f5c7..e1407148e7 100644
--- a/tp/Texinfo/XS/parsetexi/close.c
+++ b/tp/Texinfo/XS/parsetexi/close.c
@@ -328,7 +328,7 @@ close_command_cleanup (ELEMENT *current)
{
ELEMENT *content = before_item->e.c->contents.list[i];
/* content can be spaces text element such as empty_line */
- if (!(content->type == ET_lineraw_command
+ if (!(!(type_data[content->type].flags & TF_text)
&& (content->e.c->cmd == CM_c
|| content->e.c->cmd == CM_comment)))
{
diff --git a/tp/Texinfo/XS/parsetexi/end_line.c
b/tp/Texinfo/XS/parsetexi/end_line.c
index 7135981ef7..ea9c4fcf28 100644
--- a/tp/Texinfo/XS/parsetexi/end_line.c
+++ b/tp/Texinfo/XS/parsetexi/end_line.c
@@ -997,7 +997,7 @@ end_line_starting_block (ELEMENT *current)
+ strspn (f->e.text->text, whitespace_chars)))
not_command_as_arg = 1;
}
- else if (!(f->type == ET_lineraw_command
+ else if (!(!(type_data[f->type].flags & TF_text)
&& (f->e.c->cmd == CM_c
|| f->e.c->cmd == CM_comment)))
not_command_as_arg = 1;
diff --git a/tp/Texinfo/XS/parsetexi/menus.c b/tp/Texinfo/XS/parsetexi/menus.c
index 3573803a09..22c1579a67 100644
--- a/tp/Texinfo/XS/parsetexi/menus.c
+++ b/tp/Texinfo/XS/parsetexi/menus.c
@@ -20,6 +20,7 @@
#include "element_types.h"
#include "tree_types.h"
#include "text.h"
+#include "types_data.h"
#include "tree.h"
#include "extra.h"
/* for whitespace_chars */
@@ -304,8 +305,8 @@ end_line_menu_entry (ELEMENT *current)
ELEMENT *last = last_contents_child (current);
if (last
- /* last can be a text element */
- && last->type == ET_lineraw_command
+ /* last could be a text element */
+ && !(type_data[last->type].flags & TF_text)
&& (last->e.c->cmd == CM_c || last->e.c->cmd == CM_comment))
{
end_comment = pop_element_from_contents (current);
diff --git a/tp/Texinfo/XS/parsetexi/multitable.c
b/tp/Texinfo/XS/parsetexi/multitable.c
index 8587b975b4..9506c51192 100644
--- a/tp/Texinfo/XS/parsetexi/multitable.c
+++ b/tp/Texinfo/XS/parsetexi/multitable.c
@@ -19,6 +19,7 @@
#include "command_ids.h"
#include "element_types.h"
#include "tree_types.h"
+#include "types_data.h"
#include "tree.h"
#include "errors_parser.h"
#include "commands.h"
@@ -85,7 +86,7 @@ gather_previous_item (ELEMENT *current, enum command_id
next_command)
{
e = contents_child_by_index (current, position -1);
/* e can be a text element with spaces, mainly empty_line */
- if (e->type == ET_line_command
+ if (!(type_data[e->type].flags & TF_text)
&& (e->e.c->cmd == CM_item || e->e.c->cmd == CM_itemx))
{
begin_idx = position;
@@ -172,7 +173,7 @@ gather_previous_item (ELEMENT *current, enum command_id
next_command)
ELEMENT* last_elt = last_contents_child (before_item);
/* last_elt can be a spaces text element, such as empty_line */
if (last_elt->type == ET_index_entry_command
- || (last_elt->type == ET_lineraw_command
+ || (!(type_data[last_elt->type].flags & TF_text)
&& (last_elt->e.c->cmd == CM_c
|| last_elt->e.c->cmd == CM_comment)))
{
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index f065fda646..a999381d37 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -1038,7 +1038,7 @@ isolate_last_space (ELEMENT *current)
&& current->type != ET_brace_arg)
{
last_elt = last_contents_child (current);
- if (last_elt->type == ET_lineraw_command
+ if (!(type_data[last_elt->type].flags & TF_text)
&& (last_elt->e.c->cmd == CM_c
|| last_elt->e.c->cmd == CM_comment))
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: Avoid using C specific types in code,
Patrice Dumas <=