[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/XS/structuring_transfo/transformatio
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/XS/structuring_transfo/transformations.c (reassociate_to_node): select elements with "element_node" before accessing it. |
Date: |
Sun, 29 Sep 2024 04:43:28 -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 bc0bfc5c8b * tp/Texinfo/XS/structuring_transfo/transformations.c
(reassociate_to_node): select elements with "element_node" before accessing it.
bc0bfc5c8b is described below
commit bc0bfc5c8bbac37683e7b217eafb846985abd857
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Jun 9 16:03:15 2024 +0200
* tp/Texinfo/XS/structuring_transfo/transformations.c
(reassociate_to_node): select elements with "element_node" before
accessing it.
* tp/Texinfo/XS/main/tree_types.h (CONTAINER, ELEMENT): move
ASSOCIATED_INFO extra_info to CONTAINER now that it is never used by
text elements. Update code accessing this field.
---
ChangeLog | 10 ++++++++
tp/Texinfo/ManipulateTree.pm | 5 ----
tp/Texinfo/XS/main/build_perl_info.c | 2 +-
tp/Texinfo/XS/main/debug.c | 4 ++--
tp/Texinfo/XS/main/extra.c | 28 +++++++++++-----------
tp/Texinfo/XS/main/manipulate_tree.c | 4 ++--
tp/Texinfo/XS/main/tree.c | 4 ++--
tp/Texinfo/XS/main/tree_types.h | 4 ++--
.../XS/structuring_transfo/transformations.c | 9 ++++++-
9 files changed, 41 insertions(+), 29 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 6d3ffd56e1..3405d4ed6e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2024-06-09 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/structuring_transfo/transformations.c
+ (reassociate_to_node): select elements with "element_node" before
+ accessing it.
+
+ * tp/Texinfo/XS/main/tree_types.h (CONTAINER, ELEMENT): move
+ ASSOCIATED_INFO extra_info to CONTAINER now that it is never used by
+ text elements. Update code accessing this field.
+
2024-06-09 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/ManipulateTree.pm (_copy_tree)
diff --git a/tp/Texinfo/ManipulateTree.pm b/tp/Texinfo/ManipulateTree.pm
index 35f52cd405..8d4302c78b 100644
--- a/tp/Texinfo/ManipulateTree.pm
+++ b/tp/Texinfo/ManipulateTree.pm
@@ -141,11 +141,6 @@ sub _copy_tree($)
$current->{'_copy'} = $new;
if (exists($current->{'text'})) {
- #foreach my $key ('info', 'extra') {
- # inserted in info
- # print STDERR "TEXT $key: ".join('|',
sort(keys(%{$current->{$key}})))."\n"
- # if ($current->{$key})
- #}
if ($current->{'info'} and defined($current->{'info'}->{'inserted'})) {
$new->{'info'} = {'inserted' => $current->{'info'}->{'inserted'}};
}
diff --git a/tp/Texinfo/XS/main/build_perl_info.c
b/tp/Texinfo/XS/main/build_perl_info.c
index 0fb6e332c8..ccf5606225 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -803,7 +803,7 @@ element_to_perl_hash (ELEMENT *e, int avoid_recursion)
}
}
- store_additional_info (e, &e->extra_info, "extra", &nr_extra,
+ store_additional_info (e, &e->e.c->extra_info, "extra", &nr_extra,
avoid_recursion);
if (e->e.c->associated_unit)
diff --git a/tp/Texinfo/XS/main/debug.c b/tp/Texinfo/XS/main/debug.c
index fde6e228b1..43930cde99 100644
--- a/tp/Texinfo/XS/main/debug.c
+++ b/tp/Texinfo/XS/main/debug.c
@@ -223,11 +223,11 @@ print_element_debug_details (const ELEMENT *e, int
print_parent)
text_append (&text, string);
text_append (&text, "\n");
- if (e->extra_info.info_number > 0)
+ if (e->e.c->extra_info.info_number > 0)
{
char *associated_info_str;
text_append (&text, " EXTRA\n");
- associated_info_str = print_associate_info_debug (&e->extra_info);
+ associated_info_str = print_associate_info_debug (&e->e.c->extra_info);
text_append (&text, associated_info_str);
free (associated_info_str);
}
diff --git a/tp/Texinfo/XS/main/extra.c b/tp/Texinfo/XS/main/extra.c
index 828fbd66a1..6d119ff1ee 100644
--- a/tp/Texinfo/XS/main/extra.c
+++ b/tp/Texinfo/XS/main/extra.c
@@ -61,7 +61,7 @@ get_associated_info_key (ASSOCIATED_INFO *a, const char *key,
void
add_extra_element (ELEMENT *e, const char *key, ELEMENT *value)
{
- KEY_PAIR *k = get_associated_info_key (&e->extra_info, key,
+ KEY_PAIR *k = get_associated_info_key (&e->e.c->extra_info, key,
extra_element);
k->k.element = value;
}
@@ -73,7 +73,7 @@ add_extra_element (ELEMENT *e, const char *key, ELEMENT
*value)
void
add_extra_element_oot (ELEMENT *e, char *key, ELEMENT *value)
{
- KEY_PAIR *k = get_associated_info_key (&e->extra_info, key,
+ KEY_PAIR *k = get_associated_info_key (&e->e.c->extra_info, key,
extra_element_oot);
k->k.element = value;
}
@@ -87,7 +87,7 @@ add_extra_element_oot (ELEMENT *e, char *key, ELEMENT *value)
void
add_extra_container (ELEMENT *e, char *key, ELEMENT *value)
{
- KEY_PAIR *k = get_associated_info_key (&e->extra_info, key,
+ KEY_PAIR *k = get_associated_info_key (&e->e.c->extra_info, key,
extra_container);
k->k.element = value;
}
@@ -110,7 +110,7 @@ add_extra_contents (ELEMENT *e, const char *key, int
no_lookup)
}
n_list = new_list ();
- KEY_PAIR *k = get_associated_info_key (&e->extra_info, key,
+ KEY_PAIR *k = get_associated_info_key (&e->e.c->extra_info, key,
extra_contents);
k->k.list = n_list;
return n_list;
@@ -132,7 +132,7 @@ add_extra_directions (ELEMENT *e, const char *key)
{
ELEMENT_LIST *n_list = new_list ();
list_set_empty_contents (n_list, directions_length);
- KEY_PAIR *k = get_associated_info_key (&e->extra_info, key,
+ KEY_PAIR *k = get_associated_info_key (&e->e.c->extra_info, key,
extra_directions);
k->k.list = n_list;
return n_list;
@@ -143,7 +143,7 @@ void
add_extra_misc_args (ELEMENT *e, char *key, ELEMENT_LIST *value)
{
if (!value) return;
- KEY_PAIR *k = get_associated_info_key (&e->extra_info, key,
+ KEY_PAIR *k = get_associated_info_key (&e->e.c->extra_info, key,
extra_misc_args);
k->k.list = value;
}
@@ -151,14 +151,14 @@ add_extra_misc_args (ELEMENT *e, char *key, ELEMENT_LIST
*value)
void
add_extra_string (ELEMENT *e, const char *key, char *value)
{
- KEY_PAIR *k = get_associated_info_key (&e->extra_info, key, extra_string);
+ KEY_PAIR *k = get_associated_info_key (&e->e.c->extra_info, key,
extra_string);
k->k.string = value;
}
void
add_extra_string_dup (ELEMENT *e, const char *key, const char *value)
{
- KEY_PAIR *k = get_associated_info_key (&e->extra_info, key, extra_string);
+ KEY_PAIR *k = get_associated_info_key (&e->e.c->extra_info, key,
extra_string);
k->k.string = strdup (value);
}
@@ -180,7 +180,7 @@ add_associated_info_string_dup (ASSOCIATED_INFO *a, const
char *key,
void
add_extra_integer (ELEMENT *e, char *key, long value)
{
- KEY_PAIR *k = get_associated_info_key (&e->extra_info, key, extra_integer);
+ KEY_PAIR *k = get_associated_info_key (&e->e.c->extra_info, key,
extra_integer);
k->k.integer = value;
}
@@ -203,7 +203,7 @@ ELEMENT *
lookup_extra_element (const ELEMENT *e, const char *key)
{
const KEY_PAIR *k;
- k = lookup_associated_info (&e->extra_info, key);
+ k = lookup_associated_info (&e->e.c->extra_info, key);
if (!k)
return 0;
else if (k->type == extra_string || k->type == extra_integer
@@ -222,7 +222,7 @@ char *
lookup_extra_string (const ELEMENT *e, const char *key)
{
const KEY_PAIR *k;
- k = lookup_associated_info (&e->extra_info, key);
+ k = lookup_associated_info (&e->e.c->extra_info, key);
if (!k)
return 0;
else
@@ -244,7 +244,7 @@ lookup_extra_string (const ELEMENT *e, const char *key)
KEY_PAIR *
lookup_extra (const ELEMENT *e, const char *key)
{
- return lookup_associated_info (&e->extra_info, key);
+ return lookup_associated_info (&e->e.c->extra_info, key);
}
/* *ret is negative if not found or not an integer */
@@ -273,7 +273,7 @@ int
lookup_extra_integer (const ELEMENT *e, const char *key, int *ret)
{
const KEY_PAIR *k;
- k = lookup_associated_info (&e->extra_info, key);
+ k = lookup_associated_info (&e->e.c->extra_info, key);
return lookup_key_pair_integer (k, key, ret);
}
@@ -348,5 +348,5 @@ lookup_associated_info_by_index (const ASSOCIATED_INFO *a,
KEY_PAIR *
lookup_extra_by_index (const ELEMENT *e, const char *key, int index)
{
- return lookup_associated_info_by_index (&e->extra_info, key, index);
+ return lookup_associated_info_by_index (&e->e.c->extra_info, key, index);
}
diff --git a/tp/Texinfo/XS/main/manipulate_tree.c
b/tp/Texinfo/XS/main/manipulate_tree.c
index 6a4eec8d0d..7f7756705b 100644
--- a/tp/Texinfo/XS/main/manipulate_tree.c
+++ b/tp/Texinfo/XS/main/manipulate_tree.c
@@ -234,7 +234,7 @@ copy_tree_internal (ELEMENT* current)
new->e.c->string_info[i] = strdup (current->e.c->string_info[i]);
}
- copy_associated_info (¤t->extra_info, &new->extra_info);
+ copy_associated_info (¤t->e.c->extra_info, &new->e.c->extra_info);
return new;
}
@@ -340,7 +340,7 @@ remove_element_copy_info (ELEMENT *current)
}
}
}
- remove_associated_copy_info (¤t->extra_info);
+ remove_associated_copy_info (¤t->e.c->extra_info);
}
}
diff --git a/tp/Texinfo/XS/main/tree.c b/tp/Texinfo/XS/main/tree.c
index 1edc1a9e07..5cac560bf6 100644
--- a/tp/Texinfo/XS/main/tree.c
+++ b/tp/Texinfo/XS/main/tree.c
@@ -223,8 +223,6 @@ destroy_element (ELEMENT *e)
destroy_source_mark_list (&e->source_mark_list);
- destroy_associated_info (&e->extra_info);
-
if (type_data[e->type].flags & TF_text)
{
free (e->e.text->text);
@@ -238,6 +236,8 @@ destroy_element (ELEMENT *e)
free (e->e.c->contents.list);
free (e->e.c->args.list);
+ destroy_associated_info (&e->e.c->extra_info);
+
for (i = 0; i < type_data[e->type].elt_info_number; i++)
if (e->elt_info[i])
destroy_element_and_children (e->elt_info[i]);
diff --git a/tp/Texinfo/XS/main/tree_types.h b/tp/Texinfo/XS/main/tree_types.h
index dd25079902..1867fa518a 100644
--- a/tp/Texinfo/XS/main/tree_types.h
+++ b/tp/Texinfo/XS/main/tree_types.h
@@ -213,6 +213,7 @@ typedef struct CONTAINER {
ELEMENT_LIST contents;
SOURCE_INFO source_info;
+ ASSOCIATED_INFO extra_info;
OUTPUT_UNIT *associated_unit;
/* depends on the element */
char **string_info;
@@ -249,8 +250,7 @@ typedef struct ELEMENT {
struct ELEMENT **elt_info;
SOURCE_MARK_LIST source_mark_list;
- int counter; /* used temporarily for copy or other use and reset to 0 */
- ASSOCIATED_INFO extra_info;
+ int counter; /* to be used temporarily and reset to 0 */
enum command_id cmd;
diff --git a/tp/Texinfo/XS/structuring_transfo/transformations.c
b/tp/Texinfo/XS/structuring_transfo/transformations.c
index c5d04e4e1a..121dfeab75 100644
--- a/tp/Texinfo/XS/structuring_transfo/transformations.c
+++ b/tp/Texinfo/XS/structuring_transfo/transformations.c
@@ -727,7 +727,14 @@ reassociate_to_node (const char *type, ELEMENT *current,
void *argument)
added_node_menus = add_extra_contents (added_node, "menus", 0);
add_to_element_list (added_node_menus, current);
}
- else
+ /* what is really important is to avoid commands without extra information,
+ such as text, though it is even better to be precise */
+ else if (current->cmd == CM_nodedescription
+ || current->cmd == CM_nodedescriptionblock
+ /* following for index entries */
+ || current->cmd == CM_item || current->cmd == CM_itemx
+ || current->type == ET_index_entry_command
+ || (current->parent && current->parent->type == ET_def_line))
{
ELEMENT *element_node = lookup_extra_element (current, "element_node");
if (element_node)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/XS/structuring_transfo/transformations.c (reassociate_to_node): select elements with "element_node" before accessing it.,
Patrice Dumas <=