[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/XS/main/tree.c (elt_info_names): add
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/XS/main/tree.c (elt_info_names): add. |
Date: |
Wed, 23 Oct 2024 06:27:24 -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 b851d8022e * tp/Texinfo/XS/main/tree.c (elt_info_names): add.
b851d8022e is described below
commit b851d8022e76829a5b00e0a13c31789c13281b2b
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Wed Oct 23 12:27:17 2024 +0200
* tp/Texinfo/XS/main/tree.c (elt_info_names): add.
* tp/Texinfo/XS/main/build_perl_info.c (element_to_perl_hash): process
elt_info simply by going through the array.
---
ChangeLog | 7 +++
tp/Texinfo/XS/main/build_perl_info.c | 89 ++++--------------------------------
tp/Texinfo/XS/main/tree.c | 9 ++++
tp/Texinfo/XS/main/tree.h | 3 ++
4 files changed, 29 insertions(+), 79 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index cbe17134af..c3f9c392c6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-10-23 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/main/tree.c (elt_info_names): add.
+
+ * tp/Texinfo/XS/main/build_perl_info.c (element_to_perl_hash): process
+ elt_info simply by going through the array.
+
2024-10-23 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/main/tree_types.h (CONTAINER),
diff --git a/tp/Texinfo/XS/main/build_perl_info.c
b/tp/Texinfo/XS/main/build_perl_info.c
index f1b6b9d9b0..14deab5898 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -803,6 +803,11 @@ element_to_perl_hash (ELEMENT *e, int avoid_recursion)
if (e->e.c->cmd)
{
+ /* Note we could optimize the call to newSVpv here and
+ elsewhere by passing an appropriate second argument. */
+ sv = newSVpv (element_command_name (e), 0);
+ hv_store (e->hv, "cmdname", strlen ("cmdname"), sv, HSH_cmdname);
+
if (e->e.c->string_info[sit_alias_of])
store_info_string (e, e->e.c->string_info[sit_alias_of],
"alias_of", &info_hv);
@@ -845,88 +850,14 @@ element_to_perl_hash (ELEMENT *e, int avoid_recursion)
"command_name", &info_hv);
}
- /* process elt_info array */
-
- if (e->e.c->cmd)
- {
- enum command_id data_cmd;
- unsigned long flags;
-
- /* Note we could optimize the call to newSVpv here and
- elsewhere by passing an appropriate second argument. */
- sv = newSVpv (element_command_name (e), 0);
- hv_store (e->hv, "cmdname", strlen ("cmdname"), sv, HSH_cmdname);
-
- data_cmd = element_builtin_data_cmd (e);
- flags = builtin_command_data[data_cmd].flags;
-
- if (flags & CF_line)
- {
- if (e->type != ET_lineraw_command)
- {
- store_info_element (e, e->elt_info[eit_spaces_before_argument],
- "spaces_before_argument",
- avoid_recursion, &info_hv);
- }
- }
- else if (flags & CF_block)
- {
- if (e->type != ET_lineraw_command)
- {
- store_info_element (e, e->elt_info[eit_spaces_before_argument],
- "spaces_before_argument",
- avoid_recursion, &info_hv);
- }
- }
- else if (e->type != ET_nobrace_command
- && e->type != ET_container_command)
- { /* brace commands */
- store_info_element (e, e->elt_info[eit_spaces_after_cmd_before_arg],
- "spaces_after_cmd_before_arg",
- avoid_recursion, &info_hv);
- if (e->type == ET_context_brace_command)
- {
- store_info_element (e,
- e->elt_info[eit_spaces_before_argument],
- "spaces_before_argument",
- avoid_recursion, &info_hv);
- }
- }
- }
- else /* types / containers */
+ if (type_data[e->type].elt_info_number > 0)
{
- if (type_data[e->type].flags & TF_spaces_before)
- {
- store_info_element (e, e->elt_info[eit_spaces_before_argument],
- "spaces_before_argument",
- avoid_recursion, &info_hv);
- }
-
- if (type_data[e->type].flags & TF_spaces_after)
- {
- store_info_element (e, e->elt_info[eit_spaces_after_argument],
- "spaces_after_argument",
- avoid_recursion, &info_hv);
- if (e->type == ET_block_line_arg || e->type == ET_line_arg)
- {
- store_info_element (e, e->elt_info[eit_comment_at_end],
- "comment_at_end",
- avoid_recursion, &info_hv);
- }
- }
- else if (type_data[e->type].flags & TF_macro_call)
- {
- if (type_data[e->type].flags & TF_braces)
- {
- store_info_element (e,
- e->elt_info[eit_spaces_after_cmd_before_arg],
- "spaces_after_cmd_before_arg",
- avoid_recursion, &info_hv);
- }
- }
+ size_t i;
+ for (i = 0; i < type_data[e->type].elt_info_number; i++)
+ store_info_element (e, e->elt_info[i], elt_info_names[i],
+ avoid_recursion, &info_hv);
}
-
if (e->e.c->contents.number > 0)
{
AV *av;
diff --git a/tp/Texinfo/XS/main/tree.c b/tp/Texinfo/XS/main/tree.c
index 660639e900..4fad701d2f 100644
--- a/tp/Texinfo/XS/main/tree.c
+++ b/tp/Texinfo/XS/main/tree.c
@@ -51,6 +51,15 @@ static int *obs_element_first = 0;
#include "api_to_perl.h"
#include "tree.h"
+/* to be kept in sync with enum elt_info_type */
+const char *elt_info_names[] = {
+ "spaces_before_argument",
+ "spaces_after_cmd_before_arg",
+ "spaces_after_argument",
+ "comment_at_end",
+};
+
+
const char *ai_key_names[] = {
0,
#define ai_key(name) #name,
diff --git a/tp/Texinfo/XS/main/tree.h b/tp/Texinfo/XS/main/tree.h
index 438946a67a..b12f8112dc 100644
--- a/tp/Texinfo/XS/main/tree.h
+++ b/tp/Texinfo/XS/main/tree.h
@@ -7,6 +7,9 @@
/* Array of "associated info" key names. */
extern const char *ai_key_names[];
+/* Array of elt_info key names. */
+extern const char *elt_info_names[];
+
void reset_obstacks (void);
ASSOCIATED_INFO *new_associated_info (void);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/XS/main/tree.c (elt_info_names): add.,
Patrice Dumas <=
- Prev by Date:
branch master updated: * tp/Texinfo/XS/main/tree_types.h (CONTAINER), tp/Texinfo/XS/main/element_types.awk, tp/Texinfo/XS/main/build_perl_info.c (element_to_perl_hash), tp/Texinfo/XS/main/convert_to_texinfo.c (expand_cmd_args_to_texi), tp/Texinfo/XS/parsetexi/parser.c (move_last_space_to_element): remove eit_brace_content_spaces_before_argument from enum elt_info_type, use eit_spaces_before_argument instead. Do not overload enum elt_info_type indices, instead allow an unused slot for some elements in elt_info.
- Next by Date:
branch master updated: * tp/Texinfo/XS/main/build_perl_info.c (element_to_perl_hash): inline store_info_element in element_to_perl_hash.
- Previous by thread:
branch master updated: * tp/Texinfo/XS/main/tree_types.h (CONTAINER), tp/Texinfo/XS/main/element_types.awk, tp/Texinfo/XS/main/build_perl_info.c (element_to_perl_hash), tp/Texinfo/XS/main/convert_to_texinfo.c (expand_cmd_args_to_texi), tp/Texinfo/XS/parsetexi/parser.c (move_last_space_to_element): remove eit_brace_content_spaces_before_argument from enum elt_info_type, use eit_spaces_before_argument instead. Do not overload enum elt_info_type indices, instead allow an unused slot for some elements in elt_info.
- Next by thread:
branch master updated: * tp/Texinfo/XS/main/build_perl_info.c (element_to_perl_hash): inline store_info_element in element_to_perl_hash.
- Index(es):