[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Fri, 4 Oct 2024 18:40:17 -0400 (EDT) |
branch: master
commit 842112a0c86d80c73ec5fc112a093135946fb303
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Wed Aug 14 21:40:33 2024 +0200
* tp/Texinfo/XS/convert/convert_html.c
(html_clear_direction_string_type)
(html_reset_translated_special_unit_info_tree): prepend
clear_direction_string_type and
reset_translated_special_unit_info_tree with html_ and put in header
file.
* tp/Texinfo/XS/Makefile.am (libtexinfo_convert_la_SOURCES),
tp/Texinfo/XS/convert/html_converter_finish.c
(reset_special_unit_info_list, free_special_unit_info_list)
(reset_html_targets_list, reset_html_targets, clear_type_explanations)
(html_reset_files_source_info, html_free_files_source_info)
(html_destroy_files_source_info, html_reset_converter)
(free_html_no_arg_command_conversion, html_free_converter),
tp/Texinfo/XS/convert/convert_html.c: move reset and free converter
functions to a new file convert/html_converter_finish.c, which has
already a header file, but was previously implemented in
convert_html.c.
---
ChangeLog | 21 +
tp/Texinfo/XS/Makefile.am | 40 ++
tp/Texinfo/XS/convert/convert_html.c | 591 +------------------------
tp/Texinfo/XS/convert/convert_html.h | 7 +-
tp/Texinfo/XS/convert/html_converter_finish.c | 612 ++++++++++++++++++++++++++
5 files changed, 684 insertions(+), 587 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 124a465081..f500175650 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,27 @@
* tp/Texinfo/XS/convert/convert_html.c (html_command_description):
call html_get_target instead of find_element_target.
+2024-08-14 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/convert/convert_html.c
+ (html_clear_direction_string_type)
+ (html_reset_translated_special_unit_info_tree): prepend
+ clear_direction_string_type and
+ reset_translated_special_unit_info_tree with html_ and put in header
+ file.
+
+ * tp/Texinfo/XS/Makefile.am (libtexinfo_convert_la_SOURCES),
+ tp/Texinfo/XS/convert/html_converter_finish.c
+ (reset_special_unit_info_list, free_special_unit_info_list)
+ (reset_html_targets_list, reset_html_targets, clear_type_explanations)
+ (html_reset_files_source_info, html_free_files_source_info)
+ (html_destroy_files_source_info, html_reset_converter)
+ (free_html_no_arg_command_conversion, html_free_converter),
+ tp/Texinfo/XS/convert/convert_html.c: move reset and free converter
+ functions to a new file convert/html_converter_finish.c, which has
+ already a header file, but was previously implemented in
+ convert_html.c.
+
2024-08-14 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/convert/convert_html.c (html_free_converter): remove
diff --git a/tp/Texinfo/XS/Makefile.am b/tp/Texinfo/XS/Makefile.am
index 19a99f4aa5..8a24f79fce 100644
--- a/tp/Texinfo/XS/Makefile.am
+++ b/tp/Texinfo/XS/Makefile.am
@@ -341,6 +341,45 @@ $(srcdir)/main/conversion_data.c
$(srcdir)/main/conversion_data.h: main/command_
MAINTAINERCLEANFILES += main/conversion_data.c main/conversion_data.h
+<<<<<<< HEAD
+=======
+########################## shared C library for conversion
+# conversion to raw text and to Texinfo code is in the libtexinfo library.
+# Note that having a library and not reusing source files is important to
+# share converter data among the XS objects used for conversion.
+
+if HAVE_ICONV
+xs_LTLIBRARIES += libtexinfo-convert.la
+endif
+
+libtexinfo_convert_la_SOURCES= \
+ convert/converter.c \
+ convert/converter.h \
+ convert/cmd_converter.c \
+ convert/converters_defaults.c \
+ convert/converters_defaults.h \
+ convert/create_buttons.c \
+ convert/create_buttons.h \
+ convert/html_converter_types.h \
+ convert/html_converter_init_options.c \
+ convert/html_converter_init_options.h \
+ convert/html_converter_finish.c \
+ convert/html_converter_finish.h \
+ convert/html_conversion_state.c \
+ convert/html_conversion_state.h \
+ convert/html_prepare_converter.c \
+ convert/html_prepare_converter.h \
+ convert/convert_html.h \
+ convert/convert_html.c \
+ convert/texinfo.c \
+ convert/texinfo.h
+
+# locate include files under out-of-source builds.
+# parsetexi is only needed for texinfo.c
+libtexinfo_convert_la_CPPFLAGS = -I$(srcdir)/main
-I$(srcdir)/structuring_transfo -I$(srcdir)/parsetexi $(AM_CPPFLAGS)
$(GNULIB_CPPFLAGS)
+libtexinfo_convert_la_LIBADD = libtexinfo.la
$(top_builddir)/gnulib/lib/libgnu.la
+libtexinfo_convert_la_LDFLAGS = -version-info 0:0:0 $(LTLIBINTL) $(LTLIBICONV)
$(LTLIBUNISTRING)
+>>>>>>> d36edb77bf (* tp/Texinfo/XS/convert/convert_html.c)
########################## shared perl XS library for texinfo XS codes
# it is separate from libtexinfo because of different dependencies; it
@@ -391,6 +430,7 @@ C_libtexinfo_convert_sources = \
convert/html_converter_types.h \
convert/html_converter_init_options.c \
convert/html_converter_init_options.h \
+ convert/html_converter_finish.c \
convert/html_converter_finish.h \
convert/html_conversion_state.c \
convert/html_conversion_state.h \
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index 61ecad81cb..1805a03474 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -1352,7 +1352,8 @@ convert_tree_new_formatting_context (CONVERTER *self,
const ELEMENT *tree,
}
void
-clear_direction_string_type (const CONVERTER *self, char
***type_directions_strings)
+html_clear_direction_string_type (const CONVERTER *self,
+ char ***type_directions_strings)
{
int i;
int nr_string_directions = NON_SPECIAL_DIRECTIONS_NR - FIRSTINFILE_NR
@@ -13395,7 +13396,7 @@ html_prepare_converted_output_info (CONVERTER *self,
const char *output_file,
}
void
-reset_translated_special_unit_info_tree (CONVERTER *self)
+html_reset_translated_special_unit_info_tree (CONVERTER *self)
{
STRING_LIST *special_unit_varieties = &self->special_unit_varieties;
int j;
@@ -13420,74 +13421,6 @@ reset_translated_special_unit_info_tree (CONVERTER
*self)
}
-/* these constructors/initialization allow to use malloc from this
- file and not from a file including Perl headers */
-
-void
-reset_special_unit_info_list (SPECIAL_UNIT_INFO_LIST *special_unit_info_list)
-{
- size_t i;
- for (i = 0; i < special_unit_info_list->number; i++)
- {
- SPECIAL_UNIT_INFO *special_unit_info = &special_unit_info_list->list[i];
- free (special_unit_info->value);
- }
- special_unit_info_list->number = 0;
-}
-
-void
-free_special_unit_info_list (SPECIAL_UNIT_INFO_LIST *special_unit_info_list)
-{
- reset_special_unit_info_list (special_unit_info_list);
- free (special_unit_info_list->list);
-}
-
-void
-reset_html_targets_list (CONVERTER *self, HTML_TARGET_LIST *targets)
-{
- if (targets->number)
- {
- size_t i;
- for (i = 0; i < targets->number; i++)
- {
- int j;
- HTML_TARGET *html_target = &targets->list[i];
- /* setup before conversion */
- free (html_target->target);
- free (html_target->special_unit_filename);
- free (html_target->node_filename);
- free (html_target->section_filename);
- free (html_target->contents_target);
- free (html_target->shortcontents_target);
-
- for (j = 0; j < HTT_string_nonumber+1; j++)
- free (html_target->command_text[j]);
-
- for (j = 0; j < HTT_string_nonumber+1; j++)
- free (html_target->command_description[j]);
-
- free_tree_added_elements (self, &html_target->tree);
- free_tree_added_elements (self, &html_target->tree_nonumber);
- }
- memset (targets->list, 0,
- sizeof (HTML_TARGET) * targets->number);
- targets->number = 0;
- }
-}
-
-void
-reset_html_targets (CONVERTER *self, HTML_TARGET_LIST *targets)
-{
- size_t i;
- for (i = 0; i < self->html_target_cmds.top; i++)
- {
- enum command_id cmd = self->html_target_cmds.stack[i];
- reset_html_targets_list (self, &targets[cmd]);
- free (targets[cmd].list);
- targets[cmd].space = 0;
- }
-}
-
static void
reset_unset_no_arg_commands_formatting_context (CONVERTER *self,
enum command_id cmd, enum conversion_context reset_context,
@@ -13690,202 +13623,6 @@ html_conversion_finalization (CONVERTER *self)
}
}
-static void
-clear_type_explanations (EXPLAINED_COMMAND_TYPE_LIST *type_explanations)
-{
- if (type_explanations->number > 0)
- {
- size_t i;
- for (i = 0; i < type_explanations->number; i++)
- {
- EXPLAINED_COMMAND_TYPE *type_explanation
- = &type_explanations->list[i];
- free (type_explanation->type);
- free (type_explanation->explanation);
- }
- type_explanations->number = 0;
- }
-}
-
-void
-html_reset_files_source_info (FILE_SOURCE_INFO_LIST *files_source_info)
-{
- size_t i;
- for (i = 0; i < files_source_info->number; i++)
- {
- free (files_source_info->list[i].filename);
- free (files_source_info->list[i].path);
- }
- files_source_info->number = 0;
-}
-
-void
-html_free_files_source_info (FILE_SOURCE_INFO_LIST *files_source_info)
-{
- html_reset_files_source_info (files_source_info);
- free (files_source_info->list);
- files_source_info->list = 0;
- files_source_info->space = 0;
-}
-
-void
-html_destroy_files_source_info (FILE_SOURCE_INFO_LIST *files_source_info)
-{
- html_free_files_source_info (files_source_info);
- free (files_source_info);
-}
-
-void
-html_reset_converter (CONVERTER *self)
-{
- size_t i;
- EXPLAINED_COMMAND_TYPE_LIST *type_explanations
- = &self->shared_conversion_state.explained_commands;
-
- reset_translated_special_unit_info_tree (self);
- /* targets */
- reset_html_targets (self, self->html_targets);
-
- if (self->ids_data_type == IDT_perl_hashmap)
- clear_registered_ids_hv (self);
- else
- clear_strings_list (self->registered_ids);
-
- for (i = 0; i < ST_footnote_location+1; i++)
- {
- reset_html_targets_list (self, &self->html_special_targets[i]);
- free (self->html_special_targets[i].list);
- self->html_special_targets[i].space = 0;
- }
- self->html_target_cmds.top = 0;
-
- reset_special_unit_info_list (&self->customized_special_unit_info);
-
- free (self->shared_conversion_state.footnote_id_numbers);
-
- free (self->shared_conversion_state.formatted_listoffloats_nr);
- self->shared_conversion_state.formatted_listoffloats_nr = 0;
-
- /* formatted_index_entries may not be initialized if there was an error
- early and prepare_conversion_units_targets was never called */
- if (self->document->indices_info.number
- && self->shared_conversion_state.formatted_index_entries)
- {
- for (i = 0; i < self->sorted_index_names.number; i++)
- {
- free (self->shared_conversion_state.formatted_index_entries[i]);
- }
- free (self->shared_conversion_state.formatted_index_entries);
- }
-
- free (self->sorted_index_names.list);
- memset (&self->sorted_index_names, 0, sizeof (INDEX_LIST));
-
- free (self->global_units_direction_name.list);
- self->global_units_direction_name.list = 0;
- self->global_units_direction_name.number = 0;
-
- free (self->special_units_direction_name);
- self->special_units_direction_name = 0;
- free (self->output_unit_file_indices);
- self->output_unit_file_indices = 0;
- free (self->special_unit_file_indices);
- self->special_unit_file_indices = 0;
- free (self->title_titlepage);
- self->title_titlepage = 0;
- free (self->title_string);
- self->title_string = 0;
- free (self->documentdescription_string);
- self->documentdescription_string = 0;
- free (self->copying_comment);
- self->copying_comment = 0;
- free (self->date_in_header);
- self->date_in_header = 0;
- free (self->destination_directory);
- self->destination_directory = 0;
- free (self->document_name);
- self->document_name = 0;
-
- if (self->added_title_tree)
- {
- destroy_element_and_children (self->title_tree);
-
- self->added_title_tree = 0;
- }
-
- html_reset_files_source_info (&self->files_source_info);
-
- if (self->jslicenses.number)
- {
- size_t i;
- for (i = 0; i < self->jslicenses.number; i++)
- {
- JSLICENSE_FILE_INFO_LIST *jslicences_files_info
- = &self->jslicenses.list[i];
- free (jslicences_files_info->category);
- if (jslicences_files_info->number)
- {
- size_t j;
- for (j = 0; j < jslicences_files_info->number; j++)
- {
- JSLICENSE_FILE_INFO *jslicense_file_info
- = &jslicences_files_info->list[j];
- free (jslicense_file_info->filename);
- free (jslicense_file_info->license);
- free (jslicense_file_info->url);
- free (jslicense_file_info->source);
- }
- }
- free (jslicences_files_info->list);
- }
- free (self->jslicenses.list);
- }
-
- clear_output_files_information (&self->output_files_information);
- clear_output_unit_files (&self->output_unit_files);
-
- clear_strings_list (&self->check_htmlxref_already_warned);
-
- free (self->page_name_number.list);
- memset (&self->page_name_number, 0, sizeof (PAGE_NAME_NUMBER_LIST));
-
- for (i = 0; i < self->page_css.number; i++)
- {
- size_t j;
- CSS_LIST *page_css_list = &self->page_css.list[i];
-
- for (j = 0; j < page_css_list->number; j++)
- free (page_css_list->list[j]);
- free (page_css_list->list);
- free (page_css_list->page_name);
- }
- free (self->page_css.list);
-
- /* could change to 0 in releases? */
- if (1)
- {
- if (self->tree_to_build.number > 0)
- {
- fprintf (stderr, "BUG: tree_to_build: %zu\n",
- self->tree_to_build.number);
- if (self->conf->DEBUG.o.integer > 0)
- {
- for (i = 0; i < self->tree_to_build.number; i++)
- {
- ELEMENT *element = self->tree_to_build.list[i];
- /* in most cases, the trees have been destroyed, so this
- will often segfault */
- fprintf (stderr, " %zu: '%s'\n", i,
- convert_to_texinfo (element));
- }
- }
- }
- }
- free (self->tree_to_build.list);
-
- clear_type_explanations (type_explanations);
-}
-
void
html_check_transfer_state_finalization (CONVERTER *self)
{
@@ -13904,324 +13641,6 @@ html_check_transfer_state_finalization (CONVERTER
*self)
}
}
-void free_html_no_arg_command_conversion (
- HTML_NO_ARG_COMMAND_CONVERSION *format_spec,
- enum conversion_context cctx)
-{
- if (cctx == HCC_type_normal && format_spec->translated_tree)
- destroy_element_and_children (format_spec->translated_tree);
- free (format_spec->element);
- free (format_spec->text);
- free (format_spec->translated_converted);
- free (format_spec->translated_to_convert);
-}
-
-void
-html_free_converter (CONVERTER *self)
-{
- int i;
- size_t j;
- int nr_string_directions = NON_SPECIAL_DIRECTIONS_NR - FIRSTINFILE_NR
- + self->special_unit_varieties.number;
- int nr_dir_str_contexts = TDS_context_string + 1;
- EXPLAINED_COMMAND_TYPE_LIST *type_explanations
- = &self->shared_conversion_state.explained_commands;
-
- free_special_unit_info_list (&self->customized_special_unit_info);
-
- free_strings_list (&self->customized_special_unit_varieties);
-
- free (self->direction_unit_direction_name);
-
- free (self->special_unit_body);
- free (self->special_unit_body_formatting);
-
- free (self->global_units_directions);
-
- free (self->html_target_cmds.stack);
-
- if (self->ids_data_type == IDT_perl_hashmap)
- free_registered_ids_hv (self);
- else
- {
- destroy_strings_list (self->registered_ids);
- self->registered_ids = 0;
- }
-
- if (self->pl_info_hv)
- {
- unregister_perl_data (self->pl_info_hv);
- self->pl_info_hv = 0;
- }
-
- html_free_files_source_info (&self->files_source_info);
-
- free_strings_list (&self->check_htmlxref_already_warned);
-
- for (i = 0; i < SUIT_type_heading+1; i++)
- {/* we assume that reset_translated_special_unit_info_tree
- has already been called */
- free (self->special_unit_info_tree[i]);
- }
-
- for (i = 1; i < TXI_TREE_TYPES_NUMBER; i++)
- {
- free (self->pre_class_types[i]);
- }
-
- for (i = 0; i < HSHT_type_finish +1; i++)
- {
- HTML_STAGE_HANDLER_INFO_LIST *stage_handler_list
- = &self->html_stage_handlers[i];
-
- if (stage_handler_list->number > 0)
- {
- size_t k;
- for (k = 0; k < stage_handler_list->number; k++)
- {
- HTML_STAGE_HANDLER_INFO *handler_info
- = &stage_handler_list->list[k];
- free (handler_info->priority);
- }
- free (stage_handler_list->list);
- }
- }
-
- for (j = 0; j < self->css_element_class_styles.number; j++)
- {
- CSS_SELECTOR_STYLE *selector_style
- = &self->css_element_class_styles.list[j];
- free (selector_style->selector);
- free (selector_style->style);
- }
- free (self->css_element_class_styles.list);
-
- free_strings_list (&self->css_element_class_list);
- free_strings_list (&self->css_rule_lines);
- free_strings_list (&self->css_import_lines);
-
- for (j = 0; j < no_arg_formatted_cmd.number; j++)
- {
- enum command_id cmd = no_arg_formatted_cmd.list[j];
- enum conversion_context cctx;
- for (cctx = 0; cctx < NO_ARG_COMMAND_CONTEXT_NR; cctx++)
- {
- HTML_NO_ARG_COMMAND_CONVERSION *format_spec
- = &self->html_no_arg_command_conversion[cmd][cctx];
- free_html_no_arg_command_conversion (format_spec, cctx);
- }
- }
-
- for (j = 0; j < no_arg_formatted_cmd.number; j++)
- {
- enum command_id cmd = no_arg_formatted_cmd.list[j];
- enum conversion_context cctx;
- for (cctx = 0; cctx < NO_ARG_COMMAND_CONTEXT_NR; cctx++)
- {
- HTML_NO_ARG_COMMAND_CONVERSION *format_spec
- = self->customized_no_arg_commands_formatting[cmd][cctx];
- if (format_spec)
- {
- free_html_no_arg_command_conversion (format_spec, cctx);
- free (format_spec);
- }
- }
- }
-
- for (j = 0; j < accent_cmd.number; j++)
- {
- enum command_id cmd = accent_cmd.list[j];
- ACCENT_ENTITY_INFO *accent_info
- = &self->accent_entities[cmd];
- free (accent_info->entity);
- free (accent_info->characters);
- }
-
- for (j = 0; j < style_formatted_cmd.number; j++)
- {
- enum command_id cmd = style_formatted_cmd.list[j];
- enum conversion_context cctx;
- for (cctx = 0; cctx < STYLE_COMMAND_CONTEXT_NR; cctx++)
- {
- HTML_STYLE_COMMAND_CONVERSION *format_spec
- = &self->html_style_command_conversion[cmd][cctx];
- free (format_spec->element);
- }
- }
-
- for (i = 0; i < TDS_TYPE_MAX_NR; i++)
- {
- int j;
- char ***type_dir_strings = self->directions_strings[i];
- clear_direction_string_type (self, type_dir_strings);
- for (j = 0; j < nr_string_directions; j++)
- {
- free (type_dir_strings[j]);
- }
- free (type_dir_strings);
- }
-
- for (i = 0; i < (TDS_TYPE_MAX_NR) - (TDS_TRANSLATED_MAX_NR); i++)
- {
- int j;
- char ***customized_type_dir_strings
- = self->customized_directions_strings[i];
- if (customized_type_dir_strings)
- {
- clear_direction_string_type (self, customized_type_dir_strings);
- for (j = 0; j < nr_string_directions; j++)
- {
- free (customized_type_dir_strings[j]);
- }
- free (customized_type_dir_strings);
- }
- }
-
- for (i = 0; i < TDS_TRANSLATED_MAX_NR; i++)
- {
- int j;
- if (self->customized_translated_direction_strings[i])
- {
- HTML_DIRECTION_STRING_TRANSLATED **customized_translated
- = self->customized_translated_direction_strings[i];
- for (j = 0; j < nr_string_directions; j++)
- {
- if (customized_translated[j])
- {
- int k;
- free (customized_translated[j]->to_convert);
- for (k = 0; k < nr_dir_str_contexts; k++)
- {
- free (customized_translated[j]->converted[k]);
- }
- }
- free (customized_translated[j]);
- }
- free (customized_translated);
- }
- }
-
- for (i = 0; i < TDS_TRANSLATED_MAX_NR; i++)
- {
- int j;
- HTML_DIRECTION_STRING_TRANSLATED *translated
- = self->translated_direction_strings[i];
- for (j = 0; j < nr_string_directions; j++)
- {
- int k;
- free (translated[j].to_convert);
- for (k = 0; k < nr_dir_str_contexts; k++)
- {
- free (translated[j].converted[k]);
- }
- }
- free (translated);
- }
-
- for (j = 0; j < self->htmlxref.number; j++)
- {
- int k;
- HTMLXREF_MANUAL *htmlxref_manual = &self->htmlxref.list[j];
- free (htmlxref_manual->manual);
- for (k = 0; k < htmlxref_split_type_chapter +1; k++)
- {
- free (htmlxref_manual->urlprefix[k]);
- }
- }
- free (self->htmlxref.list);
-
- for (i = 0; i < SUI_type_heading+1; i++)
- {
- size_t k;
- for (k = 0; k < self->special_unit_varieties.number; k++)
- {
- free (self->special_unit_info[i][k]);
- }
- free (self->special_unit_info[i]);
- }
-
- free (self->html_customized_upper_case_commands);
- self->html_customized_upper_case_commands = 0;
-
- free (self->html_customized_code_types);
- self->html_customized_code_types = 0;
-
- if (self->html_customized_pre_class_types)
- {
- for (i = 0; self->html_customized_pre_class_types[i].type; i++)
- free (self->html_customized_pre_class_types[i].pre_class);
- free (self->html_customized_pre_class_types);
- self->html_customized_pre_class_types = 0;
- }
-
- if (self->html_customized_accent_entity_info)
- {
- for (i = 0; self->html_customized_accent_entity_info[i].cmd; i++)
- {
- ACCENT_ENTITY_INFO *accent_info
- = &self->html_customized_accent_entity_info[i].accent_entity_info;
- free (accent_info->entity);
- free (accent_info->characters);
- }
- free (self->html_customized_accent_entity_info);
- self->html_customized_accent_entity_info = 0;
- }
-
- if (self->html_customized_style_commands)
- {
- for (i = 0; self->html_customized_style_commands[i].cmd; i++)
- {
- int cctx;
- for (cctx = 0; cctx < STYLE_COMMAND_CONTEXT_NR; cctx++)
- {
- if (self->html_customized_style_commands[i].conversion[cctx])
- {
- HTML_STYLE_COMMAND_CONVERSION *format_spec
- = self->html_customized_style_commands[i].conversion[cctx];
- free (format_spec->element);
- free (format_spec);
- }
- }
- }
- free (self->html_customized_style_commands);
- self->html_customized_style_commands = 0;
- }
-
- /* should be freed on exit.
- free (no_arg_formatted_cmd.list);
-
- free (accent_cmd.list);
-
- free (preformatted_cmd_list.stack);
- free (def_cmd_list.stack);
-
- free (style_formatted_cmd.list);
- */
-
- for (i = 0; i < self->pending_closes.number; i++)
- {
- STRING_STACK *file_pending_closes = &self->pending_closes.list[i];
- free (file_pending_closes->stack);
- }
- free (self->pending_closes.list);
-
- free (self->pending_inline_content.stack);
-
- free (self->associated_inline_content.list);
-
- free (self->no_arg_formatted_cmd_translated.list);
-
- free (self->referred_command_stack.stack);
-
- free (self->multiple_pass.stack);
-
- free (self->html_document_context.stack);
-
- free (type_explanations->list);
-
- free_strings_list (&self->special_unit_varieties);
-}
-
void
html_translate_names (CONVERTER *self)
{
@@ -14239,12 +13658,12 @@ html_translate_names (CONVERTER *self)
/* reset strings such that they are translated when needed. */
for (j = 0; j < TDS_TRANSLATED_MAX_NR; j++)
{
- clear_direction_string_type (self, self->directions_strings[j]);
+ html_clear_direction_string_type (self, self->directions_strings[j]);
}
/* reset trees such that they are created based on Texinfo code string
translation on-demand */
- reset_translated_special_unit_info_tree (self);
+ html_reset_translated_special_unit_info_tree (self);
/* delete the tree and formatted results for special elements
such that they are redone with the new tree when needed. */
diff --git a/tp/Texinfo/XS/convert/convert_html.h
b/tp/Texinfo/XS/convert/convert_html.h
index c4356e2164..bb45a89b30 100644
--- a/tp/Texinfo/XS/convert/convert_html.h
+++ b/tp/Texinfo/XS/convert/convert_html.h
@@ -90,6 +90,10 @@ int html_run_stage_handlers (CONVERTER *self,
void html_default_format_protect_text (const char *text, TEXT *result);
+void html_clear_direction_string_type (const CONVERTER *self,
+ char ***type_directions_strings);
+
+
int html_special_unit_variety_direction_index (const CONVERTER *self,
const char *special_unit_variety);
@@ -330,7 +334,8 @@ int html_finish_output (CONVERTER *self, const char
*output_file,
const char *destination_directory);
void html_check_transfer_state_finalization (CONVERTER *self);
-void html_destroy_files_source_info (FILE_SOURCE_INFO_LIST *files_source_info);
+
+void html_reset_translated_special_unit_info_tree (CONVERTER *self);
void html_complete_no_arg_commands_formatting (CONVERTER *self,
enum command_id cmd,
diff --git a/tp/Texinfo/XS/convert/html_converter_finish.c
b/tp/Texinfo/XS/convert/html_converter_finish.c
new file mode 100644
index 0000000000..a38af553ee
--- /dev/null
+++ b/tp/Texinfo/XS/convert/html_converter_finish.c
@@ -0,0 +1,612 @@
+/* Copyright 2010-2024 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "converter_types.h"
+#include "document_types.h"
+#include "html_converter_types.h"
+#include "tree.h"
+#include "convert_to_texinfo.h"
+#include "convert_utils.h"
+#include "converter.h"
+#include "api_to_perl.h"
+#include "call_html_perl_function.h"
+/* html_reset_translated_special_unit_info_tree
+ html_clear_direction_string_type */
+#include "convert_html.h"
+#include "html_converter_finish.h"
+
+
+static void
+reset_special_unit_info_list (SPECIAL_UNIT_INFO_LIST *special_unit_info_list)
+{
+ size_t i;
+ for (i = 0; i < special_unit_info_list->number; i++)
+ {
+ SPECIAL_UNIT_INFO *special_unit_info = &special_unit_info_list->list[i];
+ free (special_unit_info->value);
+ }
+ special_unit_info_list->number = 0;
+}
+
+static void
+free_special_unit_info_list (SPECIAL_UNIT_INFO_LIST *special_unit_info_list)
+{
+ reset_special_unit_info_list (special_unit_info_list);
+ free (special_unit_info_list->list);
+}
+
+static void
+reset_html_targets_list (CONVERTER *self, HTML_TARGET_LIST *targets)
+{
+ if (targets->number)
+ {
+ size_t i;
+ for (i = 0; i < targets->number; i++)
+ {
+ int j;
+ HTML_TARGET *html_target = &targets->list[i];
+ /* setup before conversion */
+ free (html_target->target);
+ free (html_target->special_unit_filename);
+ free (html_target->node_filename);
+ free (html_target->section_filename);
+ free (html_target->contents_target);
+ free (html_target->shortcontents_target);
+
+ for (j = 0; j < HTT_string_nonumber+1; j++)
+ free (html_target->command_text[j]);
+
+ free_tree_added_elements (self, &html_target->tree);
+ free_tree_added_elements (self, &html_target->tree_nonumber);
+ }
+ memset (targets->list, 0,
+ sizeof (HTML_TARGET) * targets->number);
+ targets->number = 0;
+ }
+}
+
+static void
+reset_html_targets (CONVERTER *self, HTML_TARGET_LIST *targets)
+{
+ size_t i;
+ for (i = 0; i < self->html_target_cmds.top; i++)
+ {
+ enum command_id cmd = self->html_target_cmds.stack[i];
+ reset_html_targets_list (self, &targets[cmd]);
+ free (targets[cmd].list);
+ targets[cmd].space = 0;
+ }
+}
+
+static void
+clear_type_explanations (EXPLAINED_COMMAND_TYPE_LIST *type_explanations)
+{
+ if (type_explanations->number > 0)
+ {
+ size_t i;
+ for (i = 0; i < type_explanations->number; i++)
+ {
+ EXPLAINED_COMMAND_TYPE *type_explanation
+ = &type_explanations->list[i];
+ free (type_explanation->type);
+ free (type_explanation->explanation);
+ }
+ type_explanations->number = 0;
+ }
+}
+
+static void
+html_reset_files_source_info (FILE_SOURCE_INFO_LIST *files_source_info)
+{
+ size_t i;
+ for (i = 0; i < files_source_info->number; i++)
+ {
+ free (files_source_info->list[i].filename);
+ free (files_source_info->list[i].path);
+ }
+ files_source_info->number = 0;
+}
+
+static void
+html_free_files_source_info (FILE_SOURCE_INFO_LIST *files_source_info)
+{
+ html_reset_files_source_info (files_source_info);
+ free (files_source_info->list);
+ files_source_info->list = 0;
+ files_source_info->space = 0;
+}
+
+/* unused */
+void
+html_destroy_files_source_info (FILE_SOURCE_INFO_LIST *files_source_info)
+{
+ html_free_files_source_info (files_source_info);
+ free (files_source_info);
+}
+
+void
+html_reset_converter (CONVERTER *self)
+{
+ size_t i;
+ EXPLAINED_COMMAND_TYPE_LIST *type_explanations
+ = &self->shared_conversion_state.explained_commands;
+
+ html_reset_translated_special_unit_info_tree (self);
+ /* targets */
+ reset_html_targets (self, self->html_targets);
+
+ if (self->ids_data_type == IDT_perl_hashmap)
+ clear_registered_ids_hv (self);
+ else
+ clear_strings_list (self->registered_ids);
+
+ for (i = 0; i < ST_footnote_location+1; i++)
+ {
+ reset_html_targets_list (self, &self->html_special_targets[i]);
+ free (self->html_special_targets[i].list);
+ self->html_special_targets[i].space = 0;
+ }
+ self->html_target_cmds.top = 0;
+
+ reset_special_unit_info_list (&self->customized_special_unit_info);
+
+ free (self->shared_conversion_state.footnote_id_numbers);
+
+ free (self->shared_conversion_state.formatted_listoffloats_nr);
+ self->shared_conversion_state.formatted_listoffloats_nr = 0;
+
+ /* formatted_index_entries may not be initialized if there was an error
+ early and prepare_conversion_units_targets was never called */
+ if (self->document->indices_info.number
+ && self->shared_conversion_state.formatted_index_entries)
+ {
+ for (i = 0; i < self->sorted_index_names.number; i++)
+ {
+ free (self->shared_conversion_state.formatted_index_entries[i]);
+ }
+ free (self->shared_conversion_state.formatted_index_entries);
+ }
+
+ free (self->sorted_index_names.list);
+ memset (&self->sorted_index_names, 0, sizeof (INDEX_LIST));
+
+ free (self->global_units_direction_name.list);
+ self->global_units_direction_name.list = 0;
+ self->global_units_direction_name.number = 0;
+
+ free (self->special_units_direction_name);
+ self->special_units_direction_name = 0;
+ free (self->output_unit_file_indices);
+ self->output_unit_file_indices = 0;
+ free (self->special_unit_file_indices);
+ self->special_unit_file_indices = 0;
+ free (self->title_titlepage);
+ self->title_titlepage = 0;
+ free (self->title_string);
+ self->title_string = 0;
+ free (self->documentdescription_string);
+ self->documentdescription_string = 0;
+ free (self->copying_comment);
+ self->copying_comment = 0;
+ free (self->date_in_header);
+ self->date_in_header = 0;
+ free (self->destination_directory);
+ self->destination_directory = 0;
+ free (self->document_name);
+ self->document_name = 0;
+
+ if (self->added_title_tree)
+ {
+ destroy_element_and_children (self->title_tree);
+
+ self->added_title_tree = 0;
+ }
+
+ html_reset_files_source_info (&self->files_source_info);
+
+ if (self->jslicenses.number)
+ {
+ size_t i;
+ for (i = 0; i < self->jslicenses.number; i++)
+ {
+ JSLICENSE_FILE_INFO_LIST *jslicences_files_info
+ = &self->jslicenses.list[i];
+ free (jslicences_files_info->category);
+ if (jslicences_files_info->number)
+ {
+ size_t j;
+ for (j = 0; j < jslicences_files_info->number; j++)
+ {
+ JSLICENSE_FILE_INFO *jslicense_file_info
+ = &jslicences_files_info->list[j];
+ free (jslicense_file_info->filename);
+ free (jslicense_file_info->license);
+ free (jslicense_file_info->url);
+ free (jslicense_file_info->source);
+ }
+ }
+ free (jslicences_files_info->list);
+ }
+ free (self->jslicenses.list);
+ }
+
+ clear_output_files_information (&self->output_files_information);
+ clear_output_unit_files (&self->output_unit_files);
+
+ clear_strings_list (&self->check_htmlxref_already_warned);
+
+ free (self->page_name_number.list);
+ memset (&self->page_name_number, 0, sizeof (PAGE_NAME_NUMBER_LIST));
+
+ for (i = 0; i < self->page_css.number; i++)
+ {
+ size_t j;
+ CSS_LIST *page_css_list = &self->page_css.list[i];
+
+ for (j = 0; j < page_css_list->number; j++)
+ free (page_css_list->list[j]);
+ free (page_css_list->list);
+ free (page_css_list->page_name);
+ }
+ free (self->page_css.list);
+
+ /* could change to 0 in releases? */
+ if (1)
+ {
+ if (self->tree_to_build.number > 0)
+ {
+ fprintf (stderr, "BUG: tree_to_build: %zu\n",
+ self->tree_to_build.number);
+ if (self->conf->DEBUG.o.integer > 0)
+ {
+ for (i = 0; i < self->tree_to_build.number; i++)
+ {
+ ELEMENT *element = self->tree_to_build.list[i];
+ /* in most cases, the trees have been destroyed, so this
+ will often segfault */
+ fprintf (stderr, " %zu: '%s'\n", i,
+ convert_to_texinfo (element));
+ }
+ }
+ }
+ }
+ free (self->tree_to_build.list);
+
+ clear_type_explanations (type_explanations);
+}
+
+static void free_html_no_arg_command_conversion (
+ HTML_NO_ARG_COMMAND_CONVERSION *format_spec,
+ enum conversion_context cctx)
+{
+ if (cctx == HCC_type_normal && format_spec->translated_tree)
+ destroy_element_and_children (format_spec->translated_tree);
+ free (format_spec->element);
+ free (format_spec->text);
+ free (format_spec->translated_converted);
+ free (format_spec->translated_to_convert);
+}
+
+void
+html_free_converter (CONVERTER *self)
+{
+ int i;
+ size_t j;
+ int nr_string_directions = NON_SPECIAL_DIRECTIONS_NR - FIRSTINFILE_NR
+ + self->special_unit_varieties.number;
+ int nr_dir_str_contexts = TDS_context_string + 1;
+ EXPLAINED_COMMAND_TYPE_LIST *type_explanations
+ = &self->shared_conversion_state.explained_commands;
+
+ free_special_unit_info_list (&self->customized_special_unit_info);
+
+ free_strings_list (&self->customized_special_unit_varieties);
+
+ free (self->direction_unit_direction_name);
+
+ free (self->special_unit_body);
+ free (self->special_unit_body_formatting);
+
+ free (self->global_units_directions);
+
+ free (self->html_target_cmds.stack);
+
+ if (self->ids_data_type == IDT_perl_hashmap)
+ free_registered_ids_hv (self);
+ else
+ {
+ destroy_strings_list (self->registered_ids);
+ self->registered_ids = 0;
+ }
+
+ if (self->pl_info_hv)
+ {
+ unregister_perl_data (self->pl_info_hv);
+ self->pl_info_hv = 0;
+ }
+
+ html_free_files_source_info (&self->files_source_info);
+
+ free_strings_list (&self->check_htmlxref_already_warned);
+
+ for (i = 0; i < SUIT_type_heading+1; i++)
+ {/* we assume that reset_translated_special_unit_info_tree
+ has already been called */
+ free (self->special_unit_info_tree[i]);
+ }
+
+ for (i = 1; i < TXI_TREE_TYPES_NUMBER; i++)
+ {
+ free (self->pre_class_types[i]);
+ }
+
+ for (i = 0; i < HSHT_type_finish +1; i++)
+ {
+ HTML_STAGE_HANDLER_INFO_LIST *stage_handler_list
+ = &self->html_stage_handlers[i];
+
+ if (stage_handler_list->number > 0)
+ {
+ size_t k;
+ for (k = 0; k < stage_handler_list->number; k++)
+ {
+ HTML_STAGE_HANDLER_INFO *handler_info
+ = &stage_handler_list->list[k];
+ free (handler_info->priority);
+ }
+ free (stage_handler_list->list);
+ }
+ }
+
+ for (j = 0; j < self->css_element_class_styles.number; j++)
+ {
+ CSS_SELECTOR_STYLE *selector_style
+ = &self->css_element_class_styles.list[j];
+ free (selector_style->selector);
+ free (selector_style->style);
+ }
+ free (self->css_element_class_styles.list);
+
+ free_strings_list (&self->css_element_class_list);
+ free_strings_list (&self->css_rule_lines);
+ free_strings_list (&self->css_import_lines);
+
+ for (j = 0; j < no_arg_formatted_cmd.number; j++)
+ {
+ enum command_id cmd = no_arg_formatted_cmd.list[j];
+ enum conversion_context cctx;
+ for (cctx = 0; cctx < NO_ARG_COMMAND_CONTEXT_NR; cctx++)
+ {
+ HTML_NO_ARG_COMMAND_CONVERSION *format_spec
+ = &self->html_no_arg_command_conversion[cmd][cctx];
+ free_html_no_arg_command_conversion (format_spec, cctx);
+ }
+ }
+
+ for (j = 0; j < no_arg_formatted_cmd.number; j++)
+ {
+ enum command_id cmd = no_arg_formatted_cmd.list[j];
+ enum conversion_context cctx;
+ for (cctx = 0; cctx < NO_ARG_COMMAND_CONTEXT_NR; cctx++)
+ {
+ HTML_NO_ARG_COMMAND_CONVERSION *format_spec
+ = self->customized_no_arg_commands_formatting[cmd][cctx];
+ if (format_spec)
+ {
+ free_html_no_arg_command_conversion (format_spec, cctx);
+ free (format_spec);
+ }
+ }
+ }
+
+ for (j = 0; j < accent_cmd.number; j++)
+ {
+ enum command_id cmd = accent_cmd.list[j];
+ ACCENT_ENTITY_INFO *accent_info
+ = &self->accent_entities[cmd];
+ free (accent_info->entity);
+ free (accent_info->characters);
+ }
+
+ for (j = 0; j < style_formatted_cmd.number; j++)
+ {
+ enum command_id cmd = style_formatted_cmd.list[j];
+ enum conversion_context cctx;
+ for (cctx = 0; cctx < STYLE_COMMAND_CONTEXT_NR; cctx++)
+ {
+ HTML_STYLE_COMMAND_CONVERSION *format_spec
+ = &self->html_style_command_conversion[cmd][cctx];
+ free (format_spec->element);
+ }
+ }
+
+ for (i = 0; i < TDS_TYPE_MAX_NR; i++)
+ {
+ int j;
+ char ***type_dir_strings = self->directions_strings[i];
+ html_clear_direction_string_type (self, type_dir_strings);
+ for (j = 0; j < nr_string_directions; j++)
+ {
+ free (type_dir_strings[j]);
+ }
+ free (type_dir_strings);
+ }
+
+ for (i = 0; i < (TDS_TYPE_MAX_NR) - (TDS_TRANSLATED_MAX_NR); i++)
+ {
+ int j;
+ char ***customized_type_dir_strings
+ = self->customized_directions_strings[i];
+ if (customized_type_dir_strings)
+ {
+ html_clear_direction_string_type (self, customized_type_dir_strings);
+ for (j = 0; j < nr_string_directions; j++)
+ {
+ free (customized_type_dir_strings[j]);
+ }
+ free (customized_type_dir_strings);
+ }
+ }
+
+ for (i = 0; i < TDS_TRANSLATED_MAX_NR; i++)
+ {
+ int j;
+ if (self->customized_translated_direction_strings[i])
+ {
+ HTML_DIRECTION_STRING_TRANSLATED **customized_translated
+ = self->customized_translated_direction_strings[i];
+ for (j = 0; j < nr_string_directions; j++)
+ {
+ if (customized_translated[j])
+ {
+ int k;
+ free (customized_translated[j]->to_convert);
+ for (k = 0; k < nr_dir_str_contexts; k++)
+ {
+ free (customized_translated[j]->converted[k]);
+ }
+ }
+ free (customized_translated[j]);
+ }
+ free (customized_translated);
+ }
+ }
+
+ for (i = 0; i < TDS_TRANSLATED_MAX_NR; i++)
+ {
+ int j;
+ HTML_DIRECTION_STRING_TRANSLATED *translated
+ = self->translated_direction_strings[i];
+ for (j = 0; j < nr_string_directions; j++)
+ {
+ int k;
+ free (translated[j].to_convert);
+ for (k = 0; k < nr_dir_str_contexts; k++)
+ {
+ free (translated[j].converted[k]);
+ }
+ }
+ free (translated);
+ }
+
+ for (j = 0; j < self->htmlxref.number; j++)
+ {
+ int k;
+ HTMLXREF_MANUAL *htmlxref_manual = &self->htmlxref.list[j];
+ free (htmlxref_manual->manual);
+ for (k = 0; k < htmlxref_split_type_chapter +1; k++)
+ {
+ free (htmlxref_manual->urlprefix[k]);
+ }
+ }
+ free (self->htmlxref.list);
+
+ for (i = 0; i < SUI_type_heading+1; i++)
+ {
+ size_t k;
+ for (k = 0; k < self->special_unit_varieties.number; k++)
+ {
+ free (self->special_unit_info[i][k]);
+ }
+ free (self->special_unit_info[i]);
+ }
+
+ free (self->html_customized_upper_case_commands);
+ self->html_customized_upper_case_commands = 0;
+
+ free (self->html_customized_code_types);
+ self->html_customized_code_types = 0;
+
+ if (self->html_customized_pre_class_types)
+ {
+ for (i = 0; self->html_customized_pre_class_types[i].type; i++)
+ free (self->html_customized_pre_class_types[i].pre_class);
+ free (self->html_customized_pre_class_types);
+ self->html_customized_pre_class_types = 0;
+ }
+
+ if (self->html_customized_accent_entity_info)
+ {
+ for (i = 0; self->html_customized_accent_entity_info[i].cmd; i++)
+ {
+ ACCENT_ENTITY_INFO *accent_info
+ = &self->html_customized_accent_entity_info[i].accent_entity_info;
+ free (accent_info->entity);
+ free (accent_info->characters);
+ }
+ free (self->html_customized_accent_entity_info);
+ self->html_customized_accent_entity_info = 0;
+ }
+
+ if (self->html_customized_style_commands)
+ {
+ for (i = 0; self->html_customized_style_commands[i].cmd; i++)
+ {
+ int cctx;
+ for (cctx = 0; cctx < STYLE_COMMAND_CONTEXT_NR; cctx++)
+ {
+ if (self->html_customized_style_commands[i].conversion[cctx])
+ {
+ HTML_STYLE_COMMAND_CONVERSION *format_spec
+ = self->html_customized_style_commands[i].conversion[cctx];
+ free (format_spec->element);
+ free (format_spec);
+ }
+ }
+ }
+ free (self->html_customized_style_commands);
+ self->html_customized_style_commands = 0;
+ }
+
+ /* should be freed on exit.
+ free (no_arg_formatted_cmd.list);
+
+ free (accent_cmd.list);
+
+ free (preformatted_cmd_list.stack);
+ free (def_cmd_list.stack);
+
+ free (style_formatted_cmd.list);
+ */
+
+ for (i = 0; i < self->pending_closes.number; i++)
+ {
+ STRING_STACK *file_pending_closes = &self->pending_closes.list[i];
+ free (file_pending_closes->stack);
+ }
+ free (self->pending_closes.list);
+
+ free (self->pending_inline_content.stack);
+
+ free (self->associated_inline_content.list);
+
+ free (self->no_arg_formatted_cmd_translated.list);
+
+ free (self->referred_command_stack.stack);
+
+ free (self->multiple_pass.stack);
+
+ free (self->html_document_context.stack);
+
+ free (type_explanations->list);
+
+ free_strings_list (&self->special_unit_varieties);
+}
+