[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Sat, 18 May 2024 15:28:28 -0400 (EDT) |
branch: master
commit 28e01bd56a9684b043488bc212ed20a64e9dae9b
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat May 18 21:28:28 2024 +0200
* tp/Texinfo/XS/main/document.c (new_document)
(destroy_document_information_except_tree),
tp/Texinfo/XS/main/document_types.h (DOCUMENT),
tp/Texinfo/XS/convert/ConvertXS.xs,
tp/Texinfo/XS/convert/convert_html.c,
tp/Texinfo/XS/convert/converter.c,
tp/Texinfo/XS/main/build_perl_info.c,
tp/Texinfo/XS/main/get_perl_info.c,
tp/Texinfo/XS/parsetexi/handle_commands.c,
tp/Texinfo/XS/parsetexi/parser.c,
tp/Texinfo/XS/structuring_transfo/structuring.c,
tp/Texinfo/XS/structuring_transfo/transformations.c: put
global_commands directly in DOCUMENT, not as a pointer.
---
ChangeLog | 16 +++++++
tp/Texinfo/XS/convert/ConvertXS.xs | 2 +-
tp/Texinfo/XS/convert/convert_html.c | 56 +++++++++++-----------
tp/Texinfo/XS/convert/converter.c | 6 +--
tp/Texinfo/XS/main/build_perl_info.c | 11 +++--
tp/Texinfo/XS/main/document.c | 5 +-
tp/Texinfo/XS/main/document_types.h | 2 +-
tp/Texinfo/XS/main/get_perl_info.c | 2 +-
tp/Texinfo/XS/parsetexi/handle_commands.c | 4 +-
tp/Texinfo/XS/parsetexi/parser.c | 6 +--
tp/Texinfo/XS/structuring_transfo/structuring.c | 8 ++--
.../XS/structuring_transfo/transformations.c | 4 +-
12 files changed, 68 insertions(+), 54 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index a466839024..9603c7c067 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2024-05-18 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/main/document.c (new_document)
+ (destroy_document_information_except_tree),
+ tp/Texinfo/XS/main/document_types.h (DOCUMENT),
+ tp/Texinfo/XS/convert/ConvertXS.xs,
+ tp/Texinfo/XS/convert/convert_html.c,
+ tp/Texinfo/XS/convert/converter.c,
+ tp/Texinfo/XS/main/build_perl_info.c,
+ tp/Texinfo/XS/main/get_perl_info.c,
+ tp/Texinfo/XS/parsetexi/handle_commands.c,
+ tp/Texinfo/XS/parsetexi/parser.c,
+ tp/Texinfo/XS/structuring_transfo/structuring.c,
+ tp/Texinfo/XS/structuring_transfo/transformations.c: put
+ global_commands directly in DOCUMENT, not as a pointer.
+
2024-05-18 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/main/document.c (new_document),
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs
b/tp/Texinfo/XS/convert/ConvertXS.xs
index 1a6cccb849..730a803c1f 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -1677,7 +1677,7 @@ html_register_footnote (SV *converter_in, SV *command,
footid, docid, int number
which command we are searching for */
/* find footnote in XS using index in global commands */
ELEMENT_LIST *footnotes
- = &self->document->global_commands->footnotes;
+ = &self->document->global_commands.footnotes;
HV *command_hv = (HV *) SvRV (command);
SV **extra_sv
= hv_fetch (command_hv, "extra", strlen ("extra"), 0);
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index ae75ab0233..ea21fe33d6 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -288,7 +288,7 @@ get_top_unit (DOCUMENT *document, const OUTPUT_UNIT_LIST
*output_units)
{
const ELEMENT *node_top = find_identifier_target
(&document->identifiers_target, "Top");
- const ELEMENT *section_top = document->global_commands->top;
+ const ELEMENT *section_top = document->global_commands.top;
if (section_top)
return section_top->associated_unit;
@@ -356,10 +356,10 @@ html_get_tree_root_element (CONVERTER *self, const
ELEMENT *command,
const OUTPUT_UNIT_LIST *output_units
= retrieve_output_units (self->output_units_descriptors[OUDT_units]);
if (data_cmd == CM_copying
- && self->document->global_commands->insertcopying.number > 0)
+ && self->document->global_commands.insertcopying.number > 0)
{
const ELEMENT_LIST global_insertcopying
- = self->document->global_commands->insertcopying;
+ = self->document->global_commands.insertcopying;
int i;
for (i = 0; i < global_insertcopying.number; i++)
{
@@ -1497,10 +1497,10 @@ prepare_special_units (CONVERTER *self, int
output_units_descriptor)
else if (contents_location
&& !strcmp (contents_location, "after_top"))
{
- if (self->document->global_commands->top)
+ if (self->document->global_commands.top)
{/* note that top is a uniq command */
const ELEMENT *section_top
- = self->document->global_commands->top;
+ = self->document->global_commands.top;
if (section_top->associated_unit)
associated_output_unit
@@ -1514,7 +1514,7 @@ prepare_special_units (CONVERTER *self, int
output_units_descriptor)
{
const ELEMENT_LIST *global_command
= get_cmd_global_multi_command (
- self->document->global_commands, cmd);
+ &self->document->global_commands, cmd);
if (global_command->number > 0)
{
int i;
@@ -1547,7 +1547,7 @@ prepare_special_units (CONVERTER *self, int
output_units_descriptor)
}
}
- if (self->document->global_commands->footnotes.number > 0
+ if (self->document->global_commands.footnotes.number > 0
&& self->conf->footnotestyle.string
&& !strcmp (self->conf->footnotestyle.string, "separate")
&& output_units->number > 1)
@@ -4800,7 +4800,7 @@ FOOTNOTE_ID_NUMBER *
find_footnote_id_number (const CONVERTER *self, const char *footnote_id)
{
const ELEMENT_LIST *global_footnotes
- = &self->document->global_commands->footnotes;
+ = &self->document->global_commands.footnotes;
FOOTNOTE_ID_NUMBER *result = 0;
static FOOTNOTE_ID_NUMBER searched_footnote_id;
@@ -4827,7 +4827,7 @@ static void
prepare_footnotes_targets (CONVERTER *self)
{
const ELEMENT_LIST *global_footnotes
- = &self->document->global_commands->footnotes;
+ = &self->document->global_commands.footnotes;
if (global_footnotes->number > 0)
{
int i;
@@ -4903,7 +4903,7 @@ set_heading_commands_targets (CONVERTER *self)
{
enum command_id cmd = heading_commands_list[i];
const ELEMENT_LIST *global_command
- = get_cmd_global_multi_command (self->document->global_commands, cmd);
+ = get_cmd_global_multi_command (&self->document->global_commands, cmd);
if (global_command->number > 0)
{
@@ -5046,10 +5046,10 @@ html_prepare_output_units_global_targets (CONVERTER
*self)
/* It is always the first printindex, even if it is not output (for example
it is in @copying and @titlepage, which are certainly wrong constructs).
*/
- if (self->document->global_commands->printindex.number > 0)
+ if (self->document->global_commands.printindex.number > 0)
{
const ELEMENT *printindex
- = self->document->global_commands->printindex.list[0];
+ = self->document->global_commands.printindex.list[0];
ROOT_AND_UNIT *root_unit
= html_get_tree_root_element (self, printindex, 0);
if (root_unit->output_unit)
@@ -6151,8 +6151,8 @@ html_default_format_contents (CONVERTER *self, const enum
command_id cmd,
&& (!self->conf->CONTENTS_OUTPUT_LOCATION.string
|| strcmp (self->conf->CONTENTS_OUTPUT_LOCATION.string,
"inline")
- || self->document->global_commands->contents.number > 0
- || self->document->global_commands->shortcontents.number > 0));
+ || self->document->global_commands.contents.number > 0
+ || self->document->global_commands.shortcontents.number > 0));
for (i = 0; i < root_children->number; i++)
{
@@ -10981,10 +10981,10 @@ convert_insertcopying_command (CONVERTER *self, const
enum command_id cmd,
const HTML_ARGS_FORMATTED *args_formatted,
const char *content, TEXT *result)
{
- if (self->document->global_commands->copying)
+ if (self->document->global_commands.copying)
{
ELEMENT *tmp = new_element (ET_NONE);
- tmp->contents = self->document->global_commands->copying->contents;
+ tmp->contents = self->document->global_commands.copying->contents;
convert_to_html_internal (self, tmp, result, "convert insertcopying");
tmp->contents.list = 0;
destroy_element (tmp);
@@ -15489,10 +15489,10 @@ html_default_format_titlepage (CONVERTER *self)
TEXT result;
text_init (&result);
text_append (&result, "");
- if (self->document->global_commands->titlepage)
+ if (self->document->global_commands.titlepage)
{
ELEMENT *tmp = new_element (ET_NONE);
- tmp->contents = self->document->global_commands->titlepage->contents;
+ tmp->contents = self->document->global_commands.titlepage->contents;
convert_to_html_internal (self, tmp, &result, "convert titlepage");
tmp->contents.list = 0;
destroy_element (tmp);
@@ -15875,7 +15875,7 @@ html_prepare_simpletitle (CONVERTER *self)
{
enum command_id cmd = simpletitle_cmds[i];
const ELEMENT *command
- = get_cmd_global_uniq_command (self->document->global_commands, cmd);
+ = get_cmd_global_uniq_command (&self->document->global_commands, cmd);
if (command && command->args.number > 0
&& command->args.list[0]->contents.number > 0)
{
@@ -15908,7 +15908,7 @@ html_prepare_converted_output_info (CONVERTER *self)
{
enum command_id cmd = fulltitle_cmds[i];
const ELEMENT *command
- = get_cmd_global_uniq_command (self->document->global_commands, cmd);
+ = get_cmd_global_uniq_command (&self->document->global_commands, cmd);
if (command && command->args.number > 0
&& command->args.list[0]->contents.number > 0)
{
@@ -15918,12 +15918,12 @@ html_prepare_converted_output_info (CONVERTER *self)
}
if (!fulltitle_tree
- && self->document->global_commands->titlefont.number > 0
- && self->document->global_commands->titlefont.list[0]->args.number > 0
- && self->document->global_commands->titlefont.list[0]->args.list[0]
+ && self->document->global_commands.titlefont.number > 0
+ && self->document->global_commands.titlefont.list[0]->args.number > 0
+ && self->document->global_commands.titlefont.list[0]->args.list[0]
->contents.number > 0)
{
- fulltitle_tree = self->document->global_commands->titlefont.list[0];
+ fulltitle_tree = self->document->global_commands.titlefont.list[0];
}
if (fulltitle_tree)
@@ -15976,12 +15976,12 @@ html_prepare_converted_output_info (CONVERTER *self)
/* copying comment */
- if (self->document->global_commands->copying)
+ if (self->document->global_commands.copying)
{
char *copying_comment;
ELEMENT *tmp = new_element (ET_NONE);
- tmp->contents = self->document->global_commands->copying->contents;
+ tmp->contents = self->document->global_commands.copying->contents;
copying_comment = convert_to_text (tmp, self->convert_text_options);
@@ -15999,14 +15999,14 @@ html_prepare_converted_output_info (CONVERTER *self)
if (self->conf->documentdescription.string)
self->documentdescription_string
= strdup (self->conf->documentdescription.string);
- else if (self->document->global_commands->documentdescription)
+ else if (self->document->global_commands.documentdescription)
{
ELEMENT *tmp = new_element (ET_NONE);
char *documentdescription_string;
size_t documentdescription_string_len;
tmp->contents
- = self->document->global_commands->documentdescription->contents;
+ = self->document->global_commands.documentdescription->contents;
documentdescription_string
= convert_string_tree_new_formatting_context (self,
diff --git a/tp/Texinfo/XS/convert/converter.c
b/tp/Texinfo/XS/convert/converter.c
index 2c5ce7b135..eeb1da11ee 100644
--- a/tp/Texinfo/XS/convert/converter.c
+++ b/tp/Texinfo/XS/convert/converter.c
@@ -230,9 +230,9 @@ set_global_document_commands (CONVERTER *converter,
builtin_command_data[cmd].cmdname);
}
element
- = set_global_document_command
(converter->document->global_commands,
- converter->conf,
- cmd, location);
+ = set_global_document_command (&converter->document->global_commands,
+ converter->conf,
+ cmd, location);
if (!element)
{
OPTION *option_value = command_init (cmd,
diff --git a/tp/Texinfo/XS/main/build_perl_info.c
b/tp/Texinfo/XS/main/build_perl_info.c
index fff850da78..485224330d 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -1391,7 +1391,7 @@ get_document (size_t document_descriptor)
hv_tree = newHV ();
hv_info = build_global_info (&document->global_info,
- document->global_commands);
+ &document->global_commands);
#define STORE(key, value) hv_store (hv, key, strlen (key), newRV_inc ((SV *)
value), 0)
STORE("tree", hv_tree);
@@ -1436,9 +1436,9 @@ fill_document_hv (HV *hv, size_t document_descriptor, int
no_store)
hv_tree = build_texinfo_tree (document->tree, 0);
hv_info = build_global_info (&document->global_info,
- document->global_commands);
+ &document->global_commands);
- hv_commands_info = build_global_commands (document->global_commands);
+ hv_commands_info = build_global_commands (&document->global_commands);
hv_index_names = build_index_data (&document->indices_info);
@@ -1640,7 +1640,6 @@ funcname (SV *document_in) \
BUILD_PERL_DOCUMENT_ITEM(funcname,fieldname,keyname,flagname,buildname,HVAV)
*/
-BUILD_PERL_DOCUMENT_ITEM(document_global_commands_information,global_commands,"commands_info",F_DOCM_global_commands,build_global_commands,HV)
BUILD_PERL_DOCUMENT_ITEM(document_nodes_list,nodes_list,"nodes_list",F_DOCM_nodes_list,build_elements_list,AV)
@@ -1705,6 +1704,8 @@
BUILD_PERL_DOCUMENT_LIST(document_indices_information,indices_info,"indices",F_D
BUILD_PERL_DOCUMENT_LIST(document_labels_information,identifiers_target,"identifiers_target",F_DOCM_identifiers_target,build_identifiers_target,HV)
+BUILD_PERL_DOCUMENT_LIST(document_global_commands_information,global_commands,"commands_info",F_DOCM_global_commands,build_global_commands,HV)
+
#undef BUILD_PERL_DOCUMENT_LIST
SV *
@@ -1725,7 +1726,7 @@ document_global_information (SV *document_in)
if (document->modified_information & F_DOCM_global_info)
{
HV *result_hv = build_global_info (&document->global_info,
- document->global_commands);
+ &document->global_commands);
result_sv = newRV_inc ((SV *) result_hv);
hv_store (document_hv, key, strlen (key), result_sv, 0);
document->modified_information &= ~F_DOCM_global_info;
diff --git a/tp/Texinfo/XS/main/document.c b/tp/Texinfo/XS/main/document.c
index a174e77523..8045c42b3d 100644
--- a/tp/Texinfo/XS/main/document.c
+++ b/tp/Texinfo/XS/main/document.c
@@ -81,8 +81,6 @@ new_document (void)
memset (document, 0, sizeof (DOCUMENT));
document->descriptor = document_index +1;
- document->global_commands = malloc (sizeof (GLOBAL_COMMANDS));
- memset (document->global_commands, 0, sizeof (GLOBAL_COMMANDS));
/* For filenames and macro names, it is possible that they won't be
referenced
in the line number of any element. It would be too much work to keep track,
so just keep them all here, and free them all together at the end. */
@@ -397,8 +395,7 @@ destroy_document_information_except_tree (DOCUMENT
*document)
if (document->tree)
{
delete_global_info (&document->global_info);
- delete_global_commands (document->global_commands);
- free (document->global_commands);
+ delete_global_commands (&document->global_commands);
free (document->internal_references.list);
free (document->floats.list);
free_listoffloats_list (&document->listoffloats);
diff --git a/tp/Texinfo/XS/main/document_types.h
b/tp/Texinfo/XS/main/document_types.h
index aa5e3dd0b6..43a617098c 100644
--- a/tp/Texinfo/XS/main/document_types.h
+++ b/tp/Texinfo/XS/main/document_types.h
@@ -189,7 +189,7 @@ typedef struct DOCUMENT {
/* Information that is not local to where it is set in the Texinfo input,
for example document language and encoding. */
GLOBAL_INFO global_info;
- GLOBAL_COMMANDS *global_commands;
+ GLOBAL_COMMANDS global_commands;
STRING_LIST *small_strings;
ELEMENT_LIST *nodes_list;
ELEMENT_LIST *sections_list;
diff --git a/tp/Texinfo/XS/main/get_perl_info.c
b/tp/Texinfo/XS/main/get_perl_info.c
index e9bd846ad4..3cac46c132 100644
--- a/tp/Texinfo/XS/main/get_perl_info.c
+++ b/tp/Texinfo/XS/main/get_perl_info.c
@@ -1562,7 +1562,7 @@ find_element_from_sv (const CONVERTER *converter, const
DOCUMENT *document_in,
int global_command_number = SvIV (*global_command_number_sv);
const ELEMENT_LIST *global_cmd_list
= get_cmd_global_multi_command (
- document->global_commands, cmd);
+ &document->global_commands, cmd);
if (global_command_number > 0
&& global_command_number - 1 < global_cmd_list->number)
diff --git a/tp/Texinfo/XS/parsetexi/handle_commands.c
b/tp/Texinfo/XS/parsetexi/handle_commands.c
index b0869fd155..efe67acf8c 100644
--- a/tp/Texinfo/XS/parsetexi/handle_commands.c
+++ b/tp/Texinfo/XS/parsetexi/handle_commands.c
@@ -972,7 +972,7 @@ handle_line_command (ELEMENT *current, char **line_inout,
register_global_command (command_e);
if (cmd == CM_dircategory)
add_to_element_list (&parsed_document->global_commands
- ->dircategory_direntry,
+ .dircategory_direntry,
command_e);
funexit:
@@ -1109,7 +1109,7 @@ handle_block_command (ELEMENT *current, char **line_inout,
if (cmd == CM_direntry)
add_to_element_list (&parsed_document->global_commands
- ->dircategory_direntry,
+ .dircategory_direntry,
block);
if (current_node)
diff --git a/tp/Texinfo/XS/parsetexi/parser.c b/tp/Texinfo/XS/parsetexi/parser.c
index ea7299de19..3ecf7f7b40 100644
--- a/tp/Texinfo/XS/parsetexi/parser.c
+++ b/tp/Texinfo/XS/parsetexi/parser.c
@@ -351,7 +351,7 @@ set_accept_internalvalue (int value)
int
register_global_command (ELEMENT *current)
{
- GLOBAL_COMMANDS *global_commands = parsed_document->global_commands;
+ GLOBAL_COMMANDS *global_commands = &parsed_document->global_commands;
enum command_id cmd = current->cmd;
if (cmd == CM_summarycontents)
cmd = CM_shortcontents;
@@ -468,8 +468,8 @@ rearrange_tree_beginning (ELEMENT *before_node_section, int
document_descriptor)
/* Put everything before @setfilename in a special type. This allows to
ignore everything before @setfilename. */
- if (document->global_commands->setfilename
- && document->global_commands->setfilename->parent
+ if (document->global_commands.setfilename
+ && document->global_commands.setfilename->parent
== before_node_section)
{
ELEMENT *before_setfilename
diff --git a/tp/Texinfo/XS/structuring_transfo/structuring.c
b/tp/Texinfo/XS/structuring_transfo/structuring.c
index b38f897180..3d3d0b9981 100644
--- a/tp/Texinfo/XS/structuring_transfo/structuring.c
+++ b/tp/Texinfo/XS/structuring_transfo/structuring.c
@@ -395,7 +395,7 @@ sectioning_structure (DOCUMENT *document)
void
warn_non_empty_parts (DOCUMENT *document)
{
- GLOBAL_COMMANDS *global_commands = document->global_commands;
+ const GLOBAL_COMMANDS *global_commands = &document->global_commands;
ERROR_MESSAGE_LIST *error_messages = document->error_messages;
OPTIONS *options = document->options;
@@ -403,7 +403,7 @@ warn_non_empty_parts (DOCUMENT *document)
for (i = 0; i < global_commands->part.number; i++)
{
- ELEMENT *part = global_commands->part.list[i];
+ const ELEMENT *part = global_commands->part.list[i];
if (!is_content_empty (part, 0))
message_list_command_warn (error_messages, options, part, 0,
"@%s not empty", builtin_command_name (part->cmd));
@@ -802,7 +802,7 @@ check_nodes_are_referenced (DOCUMENT *document)
void
set_menus_node_directions (DOCUMENT *document)
{
- GLOBAL_COMMANDS *global_commands = document->global_commands;
+ GLOBAL_COMMANDS *global_commands = &document->global_commands;
ELEMENT_LIST *nodes_list = document->nodes_list;
LABEL_LIST *identifiers_target = &document->identifiers_target;
ERROR_MESSAGE_LIST *error_messages = document->error_messages;
@@ -935,7 +935,7 @@ set_menus_node_directions (DOCUMENT *document)
int i;
for (i = 0; i < global_commands->detailmenu.number; i++)
{
- ELEMENT *detailmenu = global_commands->detailmenu.list[i];
+ const ELEMENT *detailmenu = global_commands->detailmenu.list[i];
int k;
for (k = 0; k < detailmenu->contents.number; k++)
{
diff --git a/tp/Texinfo/XS/structuring_transfo/transformations.c
b/tp/Texinfo/XS/structuring_transfo/transformations.c
index 72735ed7d9..f51d67f266 100644
--- a/tp/Texinfo/XS/structuring_transfo/transformations.c
+++ b/tp/Texinfo/XS/structuring_transfo/transformations.c
@@ -1174,7 +1174,7 @@ regenerate_master_menu (DOCUMENT *document, int
use_sections)
{
size_t j;
ELEMENT *removed = remove_from_contents (menu, detailmenu_index);
- replace_element_in_list (&document->global_commands->detailmenu,
+ replace_element_in_list (&document->global_commands.detailmenu,
removed, new_detailmenu_e);
/* remove internal refs of removed entries */
for (j = 0; j < removed->contents.number; j++)
@@ -1259,7 +1259,7 @@ regenerate_master_menu (DOCUMENT *document, int
use_sections)
}
/* insert master menu */
insert_into_contents (last_menu, new_detailmenu_e, index);
- add_to_element_list (&document->global_commands->detailmenu,
+ add_to_element_list (&document->global_commands.detailmenu,
new_detailmenu_e);
return 1;
}