[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Sun, 29 Sep 2024 08:51:34 -0400 (EDT) |
branch: master
commit 1a6ae8b462208fbb125c9ef4f0a38665c67f045d
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Wed Jun 26 23:53:21 2024 +0200
* tp/Texinfo/OutputUnits.pm (output_unit_texi),
tp/Texinfo/XS/main/output_unit.c (output_unit_texi): prepend
'_EXT_NODE: ' to external node output unit debug string output.
* tp/Texinfo/XS/main/output_unit.c (units_directions): use a
ELEMENT_STACK for up list instead of an ELEMENT_LIST and reuse is for
all the elements.
* tp/Texinfo/XS/main/tree_types.h (OUTPUT_UNIT),
tp/Texinfo/XS/convert/convert_html.c (from_element_direction)
(html_default_format_begin_file), tp/Texinfo/XS/main/build_perl_info.c
(output_unit_to_perl_hash), tp/Texinfo/XS/main/output_unit.c
(output_unit_texi, label_target_unit_element, split_by_node)
(split_by_section): distinguish unit_command for an output unit
unit_command found in the tree and special_unit_command for a special
output unit unit_command, which is added. Update uses of
unit_command.
---
ChangeLog | 20 +++++
tp/Texinfo/OutputUnits.pm | 2 +-
tp/Texinfo/XS/convert/convert_html.c | 93 +++++++++++++---------
tp/Texinfo/XS/convert/get_html_perl_info.c | 2 +-
tp/Texinfo/XS/main/build_perl_info.c | 30 ++++---
tp/Texinfo/XS/main/convert_to_texinfo.c | 2 +-
tp/Texinfo/XS/main/manipulate_indices.c | 5 +-
tp/Texinfo/XS/main/manipulate_tree.c | 4 +-
tp/Texinfo/XS/main/manipulate_tree.h | 2 +-
tp/Texinfo/XS/main/output_unit.c | 93 ++++++++++++----------
tp/Texinfo/XS/main/tree_types.h | 6 +-
tp/Texinfo/XS/parsetexi/handle_commands.c | 6 +-
tp/Texinfo/XS/structuring_transfo/structuring.c | 4 +-
.../XS/structuring_transfo/transformations.c | 3 +-
tp/t/results/moresectioning/complex.pl | 2 +-
.../moresectioning/complex_split_at_node.pl | 2 +-
.../non_automatic_top_node_up_url.pl | 6 +-
tp/t/results/sectioning/node_up_external_node.pl | 8 +-
.../nodes_no_node_top_explicit_directions.pl | 2 +-
tp/t/results/sectioning/top_without_node_nodes.pl | 2 +-
.../sectioning/top_without_node_sections.pl | 2 +-
.../unnumbered_top_without_node_nodes.pl | 4 +-
.../unnumbered_top_without_node_sections.pl | 4 +-
23 files changed, 184 insertions(+), 120 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index af580f72f1..1c42b9148e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2024-06-26 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/OutputUnits.pm (output_unit_texi),
+ tp/Texinfo/XS/main/output_unit.c (output_unit_texi): prepend
+ '_EXT_NODE: ' to external node output unit debug string output.
+
+ * tp/Texinfo/XS/main/output_unit.c (units_directions): use a
+ ELEMENT_STACK for up list instead of an ELEMENT_LIST and reuse is for
+ all the elements.
+
+ * tp/Texinfo/XS/main/tree_types.h (OUTPUT_UNIT),
+ tp/Texinfo/XS/convert/convert_html.c (from_element_direction)
+ (html_default_format_begin_file), tp/Texinfo/XS/main/build_perl_info.c
+ (output_unit_to_perl_hash), tp/Texinfo/XS/main/output_unit.c
+ (output_unit_texi, label_target_unit_element, split_by_node)
+ (split_by_section): distinguish unit_command for an output unit
+ unit_command found in the tree and special_unit_command for a special
+ output unit unit_command, which is added. Update uses of
+ unit_command.
+
2024-06-26 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/convert/convert_html.c (html_default_format_contents),
diff --git a/tp/Texinfo/OutputUnits.pm b/tp/Texinfo/OutputUnits.pm
index 07ba5f4cc6..4189e16652 100644
--- a/tp/Texinfo/OutputUnits.pm
+++ b/tp/Texinfo/OutputUnits.pm
@@ -638,7 +638,7 @@ sub output_unit_texi($)
my $unit_command = $output_unit->{'unit_command'};
if ($output_unit->{'unit_type'} eq 'external_node_unit') {
- return Texinfo::Convert::Texinfo::convert_to_texinfo(
+ return "_EXT_NODE: ".Texinfo::Convert::Texinfo::convert_to_texinfo(
{'contents' => $unit_command->{'contents'}});
} elsif ($output_unit->{'unit_type'} eq 'special_unit') {
return "_SPECIAL_UNIT: $output_unit->{'special_unit_variety'}";
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index 3af62e3642..0215ae907b 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -409,7 +409,7 @@ html_get_tree_root_element (CONVERTER *self, const ELEMENT
*command,
{
ROOT_AND_UNIT *result = malloc (sizeof (ROOT_AND_UNIT));
result->output_unit = output_units->list[0];
- result->root = output_units->list[0]->unit_command;
+ result->root = output_units->list[0]->uc.unit_command;
return result;
}
if (output_unit || root_command)
@@ -1509,7 +1509,7 @@ register_special_unit (CONVERTER *self, char
*special_unit_variety)
special_unit->special_unit_variety = special_unit_variety;
unit_command->e.c->associated_unit = special_unit;
- special_unit->unit_command = unit_command;
+ special_unit->uc.special_unit_command = unit_command;
return special_unit;
}
@@ -1901,7 +1901,8 @@ set_special_units_targets_files (CONVERTER *self, const
char *document_name)
}
HTML_TARGET *element_target
- = add_element_target (self, special_unit->unit_command, target);
+ = add_element_target (self, special_unit->uc.special_unit_command,
+ target);
element_target->special_unit_filename = filename;
html_register_id (self, target);
@@ -1964,7 +1965,8 @@ prepare_associated_special_units_targets (CONVERTER *self)
str_target, str_filename);
}
element_target
- = add_element_target (self, special_unit->unit_command, target);
+ = add_element_target (self, special_unit->uc.special_unit_command,
+ target);
if (target)
html_register_id (self, target);
if (filename)
@@ -3162,9 +3164,9 @@ external_node_href (CONVERTER *self, const ELEMENT
*external_node,
const char *extension = 0;
int target_split = 0;
char *normalized = lookup_extra_string (external_node, AI_key_normalized);
- ELEMENT *node_contents = lookup_extra_element (external_node,
+ const ELEMENT *node_contents = lookup_extra_element (external_node,
AI_key_node_content);
- ELEMENT *manual_content = lookup_extra_element (external_node,
+ const ELEMENT *manual_content = lookup_extra_element (external_node,
AI_key_manual_content);
TARGET_FILENAME *target_filename =
@@ -3500,7 +3502,7 @@ html_command_root_element_command (CONVERTER *self, const
ELEMENT *command)
&& root_unit->output_unit->unit_type == OU_unit)
{
target_info->root_element_command
- = root_unit->output_unit->unit_command;
+ = root_unit->output_unit->uc.unit_command;
}
else
target_info->root_element_command = 0;
@@ -3766,7 +3768,7 @@ html_command_contents_href (CONVERTER *self, const
ELEMENT *command,
if (special_unit)
{
target_filename = html_command_filename (self,
- special_unit->unit_command);
+ special_unit->uc.special_unit_command);
}
text_init (&href);
@@ -4315,7 +4317,7 @@ from_element_direction (CONVERTER *self, int direction,
{
const char *filename_from;
const OUTPUT_UNIT *target_unit = 0;
- ELEMENT *command = 0;
+ const ELEMENT *command = 0;
if (!source_unit)
source_unit = self->current_output_unit;
@@ -4325,12 +4327,20 @@ from_element_direction (CONVERTER *self, int direction,
else
filename_from = self->current_filename.filename;
+ /* To debug:
+ fprintf (stderr, "%s %s\n", html_command_text_type_name[type],
+ self->direction_unit_direction_name[direction]);
+ */
+
if (direction < D_direction_Space)
target_unit = self->global_units_directions[direction];
else if (direction > NON_SPECIAL_DIRECTIONS_NR - 1)
- target_unit
+ {
+ /* special units (global) directions */
+ target_unit
= self->global_units_directions
[D_direction_Last + direction - NON_SPECIAL_DIRECTIONS_NR +1];
+ }
else if ((!source_unit || unit_is_top_output_unit (self, source_unit))
&& self->conf->TOP_NODE_UP_URL.o.string
&& (direction == D_direction_Up || direction == D_direction_NodeUp))
@@ -4363,7 +4373,8 @@ from_element_direction (CONVERTER *self, int direction,
{
if (target_unit->unit_type == OU_external_node_unit)
{
- ELEMENT *external_node_element = target_unit->unit_command;
+ const ELEMENT *external_node_element
+ = target_unit->uc.unit_command;
if (type == HTT_href)
return external_node_href (self, external_node_element,
source_command);
@@ -4375,14 +4386,15 @@ from_element_direction (CONVERTER *self, int direction,
}
else if (type == HTT_node)
{
- if (target_unit->unit_command)
+ if (target_unit->unit_type == OU_unit &&
target_unit->uc.unit_command)
{
- if (target_unit->unit_command->e.c->cmd == CM_node)
- command = target_unit->unit_command;
+ const ELEMENT *target_command = target_unit->uc.unit_command;
+ if (target_command->e.c->cmd == CM_node)
+ command = target_command;
else
{
- ELEMENT *associated_node
- = lookup_extra_element (target_unit->unit_command,
+ const ELEMENT *associated_node
+ = lookup_extra_element (target_command,
AI_key_associated_node);
if (associated_node)
command = associated_node;
@@ -4392,14 +4404,15 @@ from_element_direction (CONVERTER *self, int direction,
}
else if (type == HTT_section)
{
- if (target_unit->unit_command)
+ if (target_unit->unit_type == OU_unit &&
target_unit->uc.unit_command)
{
- if (target_unit->unit_command->e.c->cmd != CM_node)
- command = target_unit->unit_command;
+ const ELEMENT *target_command = target_unit->uc.unit_command;
+ if (target_command->e.c->cmd != CM_node)
+ command = target_command;
else
{
- ELEMENT *associated_section
- = lookup_extra_element (target_unit->unit_command,
+ const ELEMENT *associated_section
+ = lookup_extra_element (target_command,
AI_key_associated_section);
if (associated_section)
command = associated_section;
@@ -4409,7 +4422,10 @@ from_element_direction (CONVERTER *self, int direction,
}
else
{
- command = target_unit->unit_command;
+ if (target_unit->unit_type == OU_special_unit)
+ command = target_unit->uc.special_unit_command;
+ else
+ command = target_unit->uc.unit_command;
if (type == HTT_href)
{
if (command)
@@ -5663,7 +5679,7 @@ html_set_pages_files (CONVERTER *self, const
OUTPUT_UNIT_LIST *output_units,
if (!node_filename)
{
/* use section to do the file name if there is no node */
- const ELEMENT *command = file_output_unit->unit_command;
+ const ELEMENT *command = file_output_unit->uc.unit_command;
if (command)
{
if (command->e.c->cmd == CM_top && !node_top
@@ -5882,7 +5898,7 @@ html_set_pages_files (CONVERTER *self, const
OUTPUT_UNIT_LIST *output_units,
size_t special_unit_file_idx = 0;
const FILE_NAME_PATH_COUNTER *special_unit_file;
OUTPUT_UNIT *special_unit = special_units->list[i];
- const ELEMENT *unit_command = special_unit->unit_command;
+ const ELEMENT *unit_command = special_unit->uc.special_unit_command;
const HTML_TARGET *special_unit_target
= find_element_target (self->html_targets, unit_command);
const char *filename = special_unit_target->special_unit_filename;
@@ -5944,7 +5960,7 @@ html_set_pages_files (CONVERTER *self, const
OUTPUT_UNIT_LIST *output_units,
OUTPUT_UNIT *special_unit = associated_special_units->list[i];
const OUTPUT_UNIT *associated_output_unit
= special_unit->associated_document_unit;
- const ELEMENT *unit_command = special_unit->unit_command;
+ const ELEMENT *unit_command = special_unit->uc.special_unit_command;
HTML_TARGET *element_target
= find_element_target (self->html_targets, unit_command);
@@ -7262,7 +7278,7 @@ file_header_information (CONVERTER *self, const ELEMENT
*command,
if (self->conf->SECTION_NAME_IN_TITLE.o.integer > 0)
{
- ELEMENT *associated_section
+ const ELEMENT *associated_section
= lookup_extra_element (command, AI_key_associated_section);
if (associated_section && associated_section->e.c->args.number >
0)
{
@@ -7523,7 +7539,10 @@ html_default_format_begin_file (CONVERTER *self, const
char *filename,
if (output_unit)
{
- element_command = output_unit->unit_command;
+ if (output_unit->unit_type == OU_special_unit)
+ element_command = output_unit->uc.special_unit_command;
+ else
+ element_command = output_unit->uc.unit_command;
if (element_command && element_command->e.c->cmd != CM_node)
{
node_command = lookup_extra_element (element_command,
@@ -10191,7 +10210,8 @@ contents_inline_element (CONVERTER *self, const enum
command_id cmd,
special_unit_variety);
const OUTPUT_UNIT *special_unit
= self->global_units_directions[special_unit_direction_index];
- const ELEMENT *unit_command = special_unit->unit_command;
+ const ELEMENT *unit_command
+ = special_unit->uc.special_unit_command;
text_init (&result);
@@ -10530,8 +10550,8 @@ convert_heading_command (CONVERTER *self, const enum
command_id cmd,
= lookup_extra_element (element, AI_key_associated_section);
const char *normalized = lookup_extra_string (element,
AI_key_normalized);
/* NOTE: if USE_NODES = 0 and there are no sectioning commands,
- output_unit->unit_command is NUL (and not equal to elemen). */
- if (output_unit->unit_command == element
+ output_unit->uc.unit_command is NUL (and not equal to elemen). */
+ if (output_unit->uc.unit_command == element
&& !associated_section
&& normalized)
{
@@ -12991,9 +13011,10 @@ convert_printindex_command (CONVERTER *self, const
enum command_id cmd,
if (!index_sorted || !index_sorted->letter_number)
return;
- if (self->current_output_unit && self->current_output_unit->unit_command)
+ if (self->current_output_unit
+ && self->current_output_unit->uc.unit_command)
index_element_id
- = html_command_id (self, self->current_output_unit->unit_command);
+ = html_command_id (self, self->current_output_unit->uc.unit_command);
if (!index_element_id)
{
@@ -13614,7 +13635,7 @@ convert_printindex_command (CONVERTER *self, const enum
command_id cmd,
if (!associated_command)
{
associated_command
- =
self->global_units_directions[D_Top]->unit_command;
+ = self->global_units_directions[D_Top]->uc.unit_command;
/* NOTE the warning here catches the most relevant cases of
index entry that is not associated to the right command, which
@@ -15723,7 +15744,7 @@ convert_unit_type (CONVERTER *self, const enum
output_unit_type unit_type,
if (content)
text_append (result, content);
- unit_command = output_unit->unit_command;
+ unit_command = output_unit->uc.unit_command;
format_element_footer (self, unit_type, output_unit, content, unit_command,
result);
@@ -15788,7 +15809,7 @@ convert_special_unit_type (CONVERTER *self,
classes = new_string_list ();
- unit_command = output_unit->unit_command;
+ unit_command = output_unit->uc.special_unit_command;
id = html_command_id (self, unit_command);
class_base = special_unit_info (self, SUI_type_class,
special_unit_variety);
@@ -18045,7 +18066,7 @@ html_translate_names (CONVERTER *self)
= self->global_units_directions[special_unit_direction_index];
if (special_unit)
{
- const ELEMENT *command = special_unit->unit_command;
+ const ELEMENT *command = special_unit->uc.special_unit_command;
if (command)
{
HTML_TARGET *target_info
diff --git a/tp/Texinfo/XS/convert/get_html_perl_info.c
b/tp/Texinfo/XS/convert/get_html_perl_info.c
index c7a416aeb6..0ff7fe8997 100644
--- a/tp/Texinfo/XS/convert/get_html_perl_info.c
+++ b/tp/Texinfo/XS/convert/get_html_perl_info.c
@@ -1299,7 +1299,7 @@ html_find_element_from_sv (CONVERTER *converter, const SV
*element_sv,
const OUTPUT_UNIT *special_unit
= converter->global_units_directions[special_unit_direction_index];
if (special_unit)
- return special_unit->unit_command;
+ return special_unit->uc.special_unit_command;
}
}
}
diff --git a/tp/Texinfo/XS/main/build_perl_info.c
b/tp/Texinfo/XS/main/build_perl_info.c
index 2d06722479..8dd61b9280 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -2039,30 +2039,36 @@ output_unit_to_perl_hash (OUTPUT_UNIT *output_unit)
}
}
- if (output_unit->unit_command)
+ if (output_unit->unit_type == OU_special_unit)
{
- const ELEMENT *command;
- if (!output_unit->unit_command->hv
- && output_unit->unit_command->type == ET_special_unit_element)
+ ELEMENT *command = output_unit->uc.special_unit_command;
+ if (!command->hv)
{
SV *unit_sv;
/* a virtual out of tree element, add it to perl */
- element_to_perl_hash (output_unit->unit_command, 0);
+ element_to_perl_hash (command, 0);
unit_sv = newRV_inc ((SV *) output_unit->hv);
- hv_store (output_unit->unit_command->hv, "associated_unit",
+ hv_store (command->hv, "associated_unit",
strlen ("associated_unit"), unit_sv, 0);
}
-
- command = output_unit->unit_command;
-
- if (!command->hv)
- fatal ("Missing output unit unit_command hv");
-
sv = newRV_inc ((SV *) command->hv);
STORE("unit_command");
}
+ else
+ {
+ const ELEMENT *command = output_unit->uc.unit_command;
+
+ if (command)
+ {
+ if (!command->hv)
+ fatal ("Missing output unit unit_command hv");
+
+ sv = newRV_inc ((SV *) command->hv);
+ STORE("unit_command");
+ }
+ }
if (output_unit->associated_document_unit)
{
diff --git a/tp/Texinfo/XS/main/convert_to_texinfo.c
b/tp/Texinfo/XS/main/convert_to_texinfo.c
index 1f9a421480..02cc510f1e 100644
--- a/tp/Texinfo/XS/main/convert_to_texinfo.c
+++ b/tp/Texinfo/XS/main/convert_to_texinfo.c
@@ -237,7 +237,7 @@ char *
link_element_to_texi (const ELEMENT *element)
{
TEXT result;
- ELEMENT *element_link;
+ const ELEMENT *element_link;
text_init (&result);
text_append (&result, "");
diff --git a/tp/Texinfo/XS/main/manipulate_indices.c
b/tp/Texinfo/XS/main/manipulate_indices.c
index d41ac2246a..f251402989 100644
--- a/tp/Texinfo/XS/main/manipulate_indices.c
+++ b/tp/Texinfo/XS/main/manipulate_indices.c
@@ -424,7 +424,7 @@ setup_index_entries_sort_strings (ERROR_MESSAGE_LIST
*error_messages,
INDEX_ENTRY_SORT_STRING entry_sort_string;
ELEMENT *main_entry_element = index_entry->entry_element;
- ELEMENT *subentry = main_entry_element;
+ const ELEMENT *subentry = main_entry_element;
INDEX *entry_index
= indices_info_index_by_name (indices_information,
@@ -472,7 +472,8 @@ setup_index_entries_sort_strings (ERROR_MESSAGE_LIST
*error_messages,
while (1)
{
- ELEMENT *next_subentry = lookup_extra_element (subentry,
+ const ELEMENT *next_subentry
+ = lookup_extra_element (subentry,
AI_key_subentry);
if (!next_subentry)
break;
diff --git a/tp/Texinfo/XS/main/manipulate_tree.c
b/tp/Texinfo/XS/main/manipulate_tree.c
index f4798c507e..2d61ade264 100644
--- a/tp/Texinfo/XS/main/manipulate_tree.c
+++ b/tp/Texinfo/XS/main/manipulate_tree.c
@@ -1047,7 +1047,7 @@ normalized_entry_associated_internal_node (const ELEMENT
*entry,
}
ELEMENT *
-first_menu_node (ELEMENT *node, LABEL_LIST *identifiers_target)
+first_menu_node (const ELEMENT *node, LABEL_LIST *identifiers_target)
{
const ELEMENT_LIST *menus = lookup_extra_contents (node, AI_key_menus);
if (menus)
@@ -1075,7 +1075,7 @@ first_menu_node (ELEMENT *node, LABEL_LIST
*identifiers_target)
ELEMENT *content = menu_content->e.c->contents.list[k];
if (content->type == ET_menu_entry_node)
{
- ELEMENT *manual_content
+ const ELEMENT *manual_content
= lookup_extra_element (content,
AI_key_manual_content);
/* a reference to an external manual */
diff --git a/tp/Texinfo/XS/main/manipulate_tree.h
b/tp/Texinfo/XS/main/manipulate_tree.h
index 59b9ed345b..368bf6bfe9 100644
--- a/tp/Texinfo/XS/main/manipulate_tree.h
+++ b/tp/Texinfo/XS/main/manipulate_tree.h
@@ -52,5 +52,5 @@ ELEMENT *protect_node_after_label_in_tree (ELEMENT *tree);
const char *normalized_menu_entry_internal_node (const ELEMENT *entry);
ELEMENT *normalized_entry_associated_internal_node (const ELEMENT *entry,
const LABEL_LIST
*identifiers_target);
-ELEMENT *first_menu_node (ELEMENT *node, LABEL_LIST *identifiers_target);
+ELEMENT *first_menu_node (const ELEMENT *node, LABEL_LIST *identifiers_target);
#endif
diff --git a/tp/Texinfo/XS/main/output_unit.c b/tp/Texinfo/XS/main/output_unit.c
index 2ac1c3eb52..e0d1a6d368 100644
--- a/tp/Texinfo/XS/main/output_unit.c
+++ b/tp/Texinfo/XS/main/output_unit.c
@@ -29,6 +29,7 @@
#include "tree.h"
#include "builtin_commands.h"
#include "extra.h"
+#include "command_stack.h"
/* for xasprintf fatal */
#include "utils.h"
#include "debug.h"
@@ -166,13 +167,13 @@ split_by_node (DOCUMENT *document)
}
if (data_cmd == CM_node)
{
- if (!current->unit_command)
- current->unit_command = content;
+ if (!current->uc.unit_command)
+ current->uc.unit_command = content;
else
{
OUTPUT_UNIT *last = output_units->list[output_units->number -1];
current = new_output_unit (OU_unit);
- current->unit_command = content;
+ current->uc.unit_command = content;
current->tree_unit_directions[D_prev] = last;
last->tree_unit_directions[D_next] = current;
add_to_output_unit_list (output_units, current);
@@ -232,17 +233,17 @@ split_by_section (DOCUMENT *document)
enum command_id data_cmd = element_builtin_data_cmd (content);
unsigned long flags = builtin_command_data[data_cmd].flags;
- ELEMENT *new_section = 0;
+ const ELEMENT *new_section = 0;
if (data_cmd == CM_node)
{
- ELEMENT *associated_section
+ const ELEMENT *associated_section
= lookup_extra_element (content, AI_key_associated_section);
if (associated_section)
new_section = associated_section;
}
else if (data_cmd == CM_part)
{
- ELEMENT *part_associated_section
+ const ELEMENT *part_associated_section
= lookup_extra_element (content, AI_key_part_associated_section);
if (part_associated_section)
new_section = part_associated_section;
@@ -253,15 +254,15 @@ split_by_section (DOCUMENT *document)
}
if (new_section)
{
- if (!current->unit_command)
+ if (!current->uc.unit_command)
{
- current->unit_command = new_section;
+ current->uc.unit_command = new_section;
}
- else if (new_section != current->unit_command)
+ else if (new_section != current->uc.unit_command)
{
OUTPUT_UNIT *last = output_units->list[output_units->number -1];
current = new_output_unit (OU_unit);
- current->unit_command = new_section;
+ current->uc.unit_command = new_section;
current->tree_unit_directions[D_prev] = last;
last->tree_unit_directions[D_next] = current;
add_to_output_unit_list (output_units, current);
@@ -306,7 +307,7 @@ destroy_output_unit (OUTPUT_UNIT *output_unit)
/* need to destroy elements associated with special output units
as they are not in the document Texinfo tree */
if (output_unit->special_unit_variety)
- destroy_element (output_unit->unit_command);
+ destroy_element (output_unit->uc.special_unit_command);
free (output_unit->unit_contents.list);
/* no need to free output_unit->unit_filename as it is a
reference on output_unit_files list FILE_NAME_PATH_COUNTER
@@ -342,18 +343,18 @@ free_output_units_lists (OUTPUT_UNIT_LISTS
*output_units_lists)
}
-static ELEMENT *
+static const ELEMENT *
output_unit_section (OUTPUT_UNIT *output_unit)
{
- ELEMENT *element;
+ const ELEMENT *element;
- if (!output_unit->unit_command)
+ if (!output_unit->uc.unit_command)
return 0;
- element = output_unit->unit_command;
+ element = output_unit->uc.unit_command;
if (element->e.c->cmd == CM_node)
{
- ELEMENT *associated_section
+ const ELEMENT *associated_section
= lookup_extra_element (element, AI_key_associated_section);
if (associated_section)
return associated_section;
@@ -364,21 +365,21 @@ output_unit_section (OUTPUT_UNIT *output_unit)
return element;
}
-static ELEMENT *
+static const ELEMENT *
output_unit_node (OUTPUT_UNIT *output_unit)
{
- ELEMENT *element;
+ const ELEMENT *element;
- if (!output_unit->unit_command)
+ if (!output_unit->uc.unit_command)
return 0;
- element = output_unit->unit_command;
+ element = output_unit->uc.unit_command;
if (element->e.c->cmd == CM_node)
return element;
else
{
- ELEMENT *associated_node
+ const ELEMENT *associated_node
= lookup_extra_element (element, AI_key_associated_node);
if (associated_node)
return associated_node;
@@ -440,7 +441,7 @@ split_pages (OUTPUT_UNIT_LIST *output_units, const char
*split)
for (i = 0; i < output_units->number; i++)
{
OUTPUT_UNIT *output_unit = output_units->list[i];
- ELEMENT *section = output_unit_section (output_unit);
+ const ELEMENT *section = output_unit_section (output_unit);
int level = -3;
if (section)
{
@@ -461,15 +462,20 @@ split_pages (OUTPUT_UNIT_LIST *output_units, const char
*split)
char *
output_unit_texi (const OUTPUT_UNIT *output_unit)
{
- ELEMENT *unit_command;
+ const ELEMENT *unit_command;
if (!output_unit)
return strdup ("UNDEF OUTPUT UNIT");
- unit_command = output_unit->unit_command;
-
if (output_unit->unit_type == OU_external_node_unit)
- return convert_contents_to_texinfo (unit_command);
+ {
+ char *result;
+ char *reference_texi
+ = convert_contents_to_texinfo (output_unit->uc.unit_command);
+ xasprintf (&result, "_EXT_NODE: %s", reference_texi);
+ free (reference_texi);
+ return result;
+ }
else if (output_unit->unit_type == OU_special_unit)
{
char *result;
@@ -478,6 +484,7 @@ output_unit_texi (const OUTPUT_UNIT *output_unit)
return result;
}
+ unit_command = output_unit->uc.unit_command;
if (!unit_command)
{
/* happens when there are only nodes and sections are used as elements */
@@ -491,16 +498,17 @@ output_unit_texi (const OUTPUT_UNIT *output_unit)
}
static OUTPUT_UNIT *
-label_target_unit_element (ELEMENT *label,
+label_target_unit_element (const ELEMENT *label,
OUTPUT_UNIT_LIST *external_node_target_units)
{
- ELEMENT *manual_content = lookup_extra_element (label,
AI_key_manual_content);
+ const ELEMENT *manual_content
+ = lookup_extra_element (label, AI_key_manual_content);
if (manual_content)
{
/* setup an output_unit for consistency with regular output units */
OUTPUT_UNIT *external_node_unit
= new_output_unit (OU_external_node_unit);
- external_node_unit->unit_command = label;
+ external_node_unit->uc.unit_command = label;
add_to_output_unit_list (external_node_target_units,
external_node_unit);
return external_node_unit;
@@ -566,21 +574,24 @@ units_directions (LABEL_LIST *identifiers_target,
OUTPUT_UNIT_LIST *external_node_target_units,
int print_debug)
{
- ELEMENT *node_top;
int i;
+ ELEMENT_STACK up_list;
+ ELEMENT *node_top;
if (!output_units || !output_units->number)
return;
+ memset (&up_list, 0, sizeof (ELEMENT_STACK));
+
node_top = find_identifier_target (identifiers_target, "Top");
for (i = 0; i < output_units->number; i++)
{
OUTPUT_UNIT *output_unit = output_units->list[i];
OUTPUT_UNIT **directions = output_unit->directions;
- ELEMENT *node = output_unit_node (output_unit);
+ const ELEMENT *node = output_unit_node (output_unit);
const ELEMENT_LIST *node_directions;
- ELEMENT *section = output_unit_section (output_unit);
+ const ELEMENT *section = output_unit_section (output_unit);
directions[RUD_type_This] = output_unit;
if (output_unit->tree_unit_directions[D_next]
@@ -594,7 +605,8 @@ units_directions (LABEL_LIST *identifiers_target,
if (node)
{
- ELEMENT *menu_child = first_menu_node (node, identifiers_target);
+ const ELEMENT *menu_child
+ = first_menu_node (node, identifiers_target);
enum directions d;
node_directions = lookup_extra_directions (node,
AI_key_node_directions);
@@ -602,7 +614,7 @@ units_directions (LABEL_LIST *identifiers_target,
{
for (d = 0; d < directions_length; d++)
{
- ELEMENT *node_direction = node_directions->list[d];
+ const ELEMENT *node_direction = node_directions->list[d];
if (node_direction)
directions[node_unit_directions[d]]
= label_target_unit_element (node_direction,
@@ -640,16 +652,14 @@ units_directions (LABEL_LIST *identifiers_target,
else if (node_directions && node_directions->list[D_up])
{
ELEMENT *up = node_directions->list[D_up];
- ELEMENT_LIST up_list;
- memset (&up_list, 0, sizeof (ELEMENT_LIST));
- add_to_element_list (&up_list, node);
+ push_stack_element (&up_list, node);
while (1)
{
const ELEMENT_LIST *up_node_directions;
int i;
int in_up = 0;
- for (i = 0; i < up_list.number; i++)
- if (up == up_list.list[i])
+ for (i = 0; i < up_list.top; i++)
+ if (up == up_list.stack[i])
{
in_up = 1;
break;
@@ -668,14 +678,14 @@ units_directions (LABEL_LIST *identifiers_target,
external_node_target_units);
break;
}
- add_to_element_list (&up_list, up);
+ push_stack_element (&up_list, up);
if (up_node_directions
&& up_node_directions->list[D_up])
up = up_node_directions->list[D_up];
else
break;
}
- free (up_list.list);
+ up_list.top = 0;
}
}
if (directions[RUD_type_NodeForward]
@@ -819,6 +829,7 @@ units_directions (LABEL_LIST *identifiers_target,
}
}
}
+ free (up_list.stack);
if (print_debug > 0)
{
int i;
diff --git a/tp/Texinfo/XS/main/tree_types.h b/tp/Texinfo/XS/main/tree_types.h
index b1a65b57b9..70b5f2a7c1 100644
--- a/tp/Texinfo/XS/main/tree_types.h
+++ b/tp/Texinfo/XS/main/tree_types.h
@@ -291,7 +291,11 @@ typedef struct OUTPUT_UNIT {
enum output_unit_type unit_type;
size_t index;
- struct ELEMENT *unit_command;
+ struct {
+ const struct ELEMENT *unit_command;
+ /* for special units, not in the tree */
+ struct ELEMENT *special_unit_command;
+ } uc;
char *unit_filename;
ELEMENT_LIST unit_contents;
struct OUTPUT_UNIT *tree_unit_directions[2];
diff --git a/tp/Texinfo/XS/parsetexi/handle_commands.c
b/tp/Texinfo/XS/parsetexi/handle_commands.c
index 0a1781f562..ee8711a649 100644
--- a/tp/Texinfo/XS/parsetexi/handle_commands.c
+++ b/tp/Texinfo/XS/parsetexi/handle_commands.c
@@ -771,7 +771,7 @@ handle_line_command (ELEMENT *current, const char
**line_inout,
{
if (current_node)
{
- ELEMENT *e_description
+ const ELEMENT *e_description
= lookup_extra_element (current_node,
AI_key_node_description);
if (e_description)
@@ -1106,14 +1106,14 @@ handle_block_command (ELEMENT *current, const char
**line_inout,
{
if (current_node)
{
- ELEMENT *node_long_description
+ const ELEMENT *node_long_description
= lookup_extra_element (current_node,
AI_key_node_long_description);
if (node_long_description)
line_warn ("multiple node @nodedescriptionblock");
else
{
- ELEMENT *node_description
+ const ELEMENT *node_description
= lookup_extra_element (current_node, AI_key_node_description);
if (!node_description)
diff --git a/tp/Texinfo/XS/structuring_transfo/structuring.c
b/tp/Texinfo/XS/structuring_transfo/structuring.c
index ccaf00de7d..c62ad3bd29 100644
--- a/tp/Texinfo/XS/structuring_transfo/structuring.c
+++ b/tp/Texinfo/XS/structuring_transfo/structuring.c
@@ -372,7 +372,7 @@ sectioning_structure (DOCUMENT *document)
}
else if (content->e.c->cmd == CM_part)
{
- ELEMENT *part_associated_section
+ const ELEMENT *part_associated_section
= lookup_extra_element (content, AI_key_part_associated_section);
if (!part_associated_section)
{
@@ -433,7 +433,7 @@ check_menu_entry (DOCUMENT *document, enum command_id cmd,
}
else
{
- ELEMENT *node_content = lookup_extra_element (menu_entry_node,
+ const ELEMENT *node_content = lookup_extra_element (menu_entry_node,
AI_key_node_content);
if (!check_node_same_texinfo_code (menu_node, node_content))
{
diff --git a/tp/Texinfo/XS/structuring_transfo/transformations.c
b/tp/Texinfo/XS/structuring_transfo/transformations.c
index b0e48e87e9..580e6d1671 100644
--- a/tp/Texinfo/XS/structuring_transfo/transformations.c
+++ b/tp/Texinfo/XS/structuring_transfo/transformations.c
@@ -744,7 +744,8 @@ reassociate_to_node (const char *type, ELEMENT *current,
void *argument)
|| current->type == ET_index_entry_command
|| (current->parent && current->parent->flags & EF_def_line)))
{
- ELEMENT *element_node = lookup_extra_element (current,
AI_key_element_node);
+ const ELEMENT *element_node
+ = lookup_extra_element (current, AI_key_element_node);
if (element_node)
{
if (previous_node && element_node != previous_node)
diff --git a/tp/t/results/moresectioning/complex.pl
b/tp/t/results/moresectioning/complex.pl
index 086a6f0898..57fd4d60a0 100644
--- a/tp/t/results/moresectioning/complex.pl
+++ b/tp/t/results/moresectioning/complex.pl
@@ -5107,7 +5107,7 @@ $result_directions_text{'complex'} = 'output unit: @top
Forward: @chapter first node chapter
FastForward: @chapter first node chapter
NodeNext: @chapter first node chapter
- NodePrev: (dir)
+ NodePrev: _EXT_NODE: (dir)
NodeForward: @chapter first node chapter
output unit: @chapter first node chapter
This: @chapter first node chapter
diff --git a/tp/t/results/moresectioning/complex_split_at_node.pl
b/tp/t/results/moresectioning/complex_split_at_node.pl
index 7632a0ab07..c5e3da86ca 100644
--- a/tp/t/results/moresectioning/complex_split_at_node.pl
+++ b/tp/t/results/moresectioning/complex_split_at_node.pl
@@ -5388,7 +5388,7 @@ $result_directions_text{'complex_split_at_node'} =
'output unit: @node Top
Forward: @node First node
FastForward: @node First node
NodeNext: @node First node
- NodePrev: (dir)
+ NodePrev: _EXT_NODE: (dir)
NodeForward: @node First node
output unit: @node First node
This: @node First node
diff --git a/tp/t/results/moresectioning/non_automatic_top_node_up_url.pl
b/tp/t/results/moresectioning/non_automatic_top_node_up_url.pl
index b141d0ee43..a8d198c937 100644
--- a/tp/t/results/moresectioning/non_automatic_top_node_up_url.pl
+++ b/tp/t/results/moresectioning/non_automatic_top_node_up_url.pl
@@ -735,15 +735,15 @@ $result_directions_text{'non_automatic_top_node_up_url'}
= 'output unit: @node T
This: @node Top
Forward: @node chap
NodeNext: @node chap
- NodePrev: (dir)
- NodeUp: (dir)
+ NodePrev: _EXT_NODE: (dir)
+ NodeUp: _EXT_NODE: (dir)
NodeForward: @node chap
output unit: @node chap
This: @node chap
Back: @node Top
FastBack: @node Top
NodePrev: @node Top
- NodeUp: (dir)
+ NodeUp: _EXT_NODE: (dir)
NodeBack: @node Top
';
diff --git a/tp/t/results/sectioning/node_up_external_node.pl
b/tp/t/results/sectioning/node_up_external_node.pl
index 513089f84d..0ae92f79c8 100644
--- a/tp/t/results/sectioning/node_up_external_node.pl
+++ b/tp/t/results/sectioning/node_up_external_node.pl
@@ -575,10 +575,10 @@ $result_directions_text{'node_up_external_node'} =
'output unit: @node Top
output unit: @node chap first
This: @node chap first
Back: @node Top
- NodeNext: (manual1)
- NodePrev: (manual2)
- NodeUp: (manual3)
- NodeForward: (manual1)
+ NodeNext: _EXT_NODE: (manual1)
+ NodePrev: _EXT_NODE: (manual2)
+ NodeUp: _EXT_NODE: (manual3)
+ NodeForward: _EXT_NODE: (manual1)
NodeBack: @node Top
';
diff --git a/tp/t/results/sectioning/nodes_no_node_top_explicit_directions.pl
b/tp/t/results/sectioning/nodes_no_node_top_explicit_directions.pl
index 643e1c4387..0fb37e9a8b 100644
--- a/tp/t/results/sectioning/nodes_no_node_top_explicit_directions.pl
+++ b/tp/t/results/sectioning/nodes_no_node_top_explicit_directions.pl
@@ -507,7 +507,7 @@
$result_elements{'nodes_no_node_top_explicit_directions'}[1] = $result_elements{
$result_directions_text{'nodes_no_node_top_explicit_directions'} = 'output
unit: @node first
This: @node first
Forward: @node second node
- NodeUp: (dir)
+ NodeUp: _EXT_NODE: (dir)
NodeForward: @node second node
output unit: @node second node
This: @node second node
diff --git a/tp/t/results/sectioning/top_without_node_nodes.pl
b/tp/t/results/sectioning/top_without_node_nodes.pl
index 263dc040b6..8f849cc049 100644
--- a/tp/t/results/sectioning/top_without_node_nodes.pl
+++ b/tp/t/results/sectioning/top_without_node_nodes.pl
@@ -351,7 +351,7 @@
$result_elements{'top_without_node_nodes'}[0]{'unit_command'}{'associated_unit'}
$result_directions_text{'top_without_node_nodes'} = 'output unit: @node second
This: @node second
- NodeUp: (dir)
+ NodeUp: _EXT_NODE: (dir)
';
diff --git a/tp/t/results/sectioning/top_without_node_sections.pl
b/tp/t/results/sectioning/top_without_node_sections.pl
index 905b58690a..153fbd38e2 100644
--- a/tp/t/results/sectioning/top_without_node_sections.pl
+++ b/tp/t/results/sectioning/top_without_node_sections.pl
@@ -472,7 +472,7 @@ output unit: @chapter Chapter
Back: @top top section
FastBack: @top top section
Up: @top top section
- NodeUp: (dir)
+ NodeUp: _EXT_NODE: (dir)
';
diff --git a/tp/t/results/sectioning/unnumbered_top_without_node_nodes.pl
b/tp/t/results/sectioning/unnumbered_top_without_node_nodes.pl
index 5f862220b2..872fba9efe 100644
--- a/tp/t/results/sectioning/unnumbered_top_without_node_nodes.pl
+++ b/tp/t/results/sectioning/unnumbered_top_without_node_nodes.pl
@@ -673,12 +673,12 @@
$result_directions_text{'unnumbered_top_without_node_nodes'} = 'output unit: @no
Forward: @node second
FastForward: @node a node
FastBack: @node a node
- NodeUp: (dir)
+ NodeUp: _EXT_NODE: (dir)
output unit: @node second
This: @node second
Back: @node a node
Prev: @node a node
- NodeUp: (dir)
+ NodeUp: _EXT_NODE: (dir)
';
diff --git a/tp/t/results/sectioning/unnumbered_top_without_node_sections.pl
b/tp/t/results/sectioning/unnumbered_top_without_node_sections.pl
index 994ef3a3a2..57948970e5 100644
--- a/tp/t/results/sectioning/unnumbered_top_without_node_sections.pl
+++ b/tp/t/results/sectioning/unnumbered_top_without_node_sections.pl
@@ -804,7 +804,7 @@
$result_directions_text{'unnumbered_top_without_node_sections'} = 'output unit:
Forward: @top top section
FastForward: @top top section
Next: @top top section
- NodeUp: (dir)
+ NodeUp: _EXT_NODE: (dir)
output unit: @top top section
This: @top top section
Forward: @chapter Chapter
@@ -818,7 +818,7 @@ output unit: @chapter Chapter
Back: @top top section
FastBack: @top top section
Prev: @top top section
- NodeUp: (dir)
+ NodeUp: _EXT_NODE: (dir)
';