[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Thu, 9 Nov 2023 15:59:26 -0500 (EST) |
branch: master
commit bd7b8f424b8ed583bd4c065c077599b95d102018
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Thu Nov 9 21:50:27 2023 +0100
* tp/Texinfo/XS/convert/ConvertXS.xs (html_prepare_conversion_units),
(tp/Texinfo/XS/convert/build_html_perl_state.c
(build_html_special_targets, pass_html_special_targets),
tp/Texinfo/XS/convert/convert_html.c (add_element_target)
(add_special_target, set_special_units_targets_files)
(prepare_associated_special_units_targets, unique_target)
(new_sectioning_command_target, prepare_index_entries_targets)
(prepare_footnotes_targets, html_set_pages_files)
(html_initialize_output_state, html_translate_names),
tp/Texinfo/XS/main/converter_types.h (CONVERTER): put
html_special_targets, html_targets and seen_ids directly in CONVERTER,
not as pointers.
* tp/Texinfo/XS/convert/convert_html.c (html_converter_initialize)
(html_initialize_output_state): initialize converter
global_units_directions in html_initialize_output_state.
---
ChangeLog | 19 +++++++++
tp/Texinfo/XS/convert/ConvertXS.xs | 6 ++-
tp/Texinfo/XS/convert/build_html_perl_state.c | 6 +--
tp/Texinfo/XS/convert/build_html_perl_state.h | 2 +-
tp/Texinfo/XS/convert/convert_html.c | 60 ++++++++++++++-------------
tp/Texinfo/XS/main/converter_types.h | 33 ++++++++-------
6 files changed, 78 insertions(+), 48 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 0dde1d3cc7..2b22db2409 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2023-11-09 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/convert/ConvertXS.xs (html_prepare_conversion_units),
+ (tp/Texinfo/XS/convert/build_html_perl_state.c
+ (build_html_special_targets, pass_html_special_targets),
+ tp/Texinfo/XS/convert/convert_html.c (add_element_target)
+ (add_special_target, set_special_units_targets_files)
+ (prepare_associated_special_units_targets, unique_target)
+ (new_sectioning_command_target, prepare_index_entries_targets)
+ (prepare_footnotes_targets, html_set_pages_files)
+ (html_initialize_output_state, html_translate_names),
+ tp/Texinfo/XS/main/converter_types.h (CONVERTER): put
+ html_special_targets, html_targets and seen_ids directly in CONVERTER,
+ not as pointers.
+
+ * tp/Texinfo/XS/convert/convert_html.c (html_converter_initialize)
+ (html_initialize_output_state): initialize converter
+ global_units_directions in html_initialize_output_state.
+
2023-11-09 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/convert/get_html_perl_info.c
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs
b/tp/Texinfo/XS/convert/ConvertXS.xs
index b23d56808c..0b2460aa5e 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -152,6 +152,8 @@ text_convert_tree (SV *text_options_in, SV *tree_in,
unused=0)
OUTPUT:
RETVAL
+# HTML
+
int
html_converter_initialize_sv (SV *converter_in, SV
*default_formatting_references, SV *default_css_string_formatting_references,
SV *default_commands_open, SV *default_commands_conversion, SV
*default_css_string_commands_conversion, SV *default_types_open, SV
*default_types_conversion, SV *default_css_string_types_conversion, SV
*default_output_units_conversion)
@@ -301,9 +303,9 @@ html_prepare_conversion_units (SV *converter_in, ...)
output_units_descriptor, special_units_descriptor,
associated_special_units_descriptor);
- pass_html_element_targets (converter_in, self->html_targets);
+ pass_html_element_targets (converter_in, &self->html_targets);
pass_html_special_targets (converter_in, self->html_special_targets);
- pass_html_seen_ids (converter_in, self->seen_ids);
+ pass_html_seen_ids (converter_in, &self->seen_ids);
pass_converter_errors (self->error_messages, self->hv);
diff --git a/tp/Texinfo/XS/convert/build_html_perl_state.c
b/tp/Texinfo/XS/convert/build_html_perl_state.c
index 6be33603b6..ea4702c37f 100644
--- a/tp/Texinfo/XS/convert/build_html_perl_state.c
+++ b/tp/Texinfo/XS/convert/build_html_perl_state.c
@@ -134,7 +134,7 @@ pass_html_element_targets (SV *converter_sv,
HTML_TARGET_LIST *html_targets)
}
HV *
-build_html_special_targets (HTML_TARGET_LIST **html_special_targets)
+build_html_special_targets (HTML_TARGET_LIST *html_special_targets)
{
HV *hv;
HV *html_special_target_hv;
@@ -145,7 +145,7 @@ build_html_special_targets (HTML_TARGET_LIST
**html_special_targets)
/* could be generalized if needed */
- HTML_TARGET_LIST *html_special_target =
html_special_targets[ST_footnote_location];
+ HTML_TARGET_LIST *html_special_target =
&html_special_targets[ST_footnote_location];
html_special_target_hv = build_html_element_targets (html_special_target);
hv_store (hv, "footnote_location", strlen ("footnote_location"),
@@ -156,7 +156,7 @@ build_html_special_targets (HTML_TARGET_LIST
**html_special_targets)
void
pass_html_special_targets (SV *converter_sv,
- HTML_TARGET_LIST **html_special_targets)
+ HTML_TARGET_LIST *html_special_targets)
{
HV *special_targets_hv;
HV *hv;
diff --git a/tp/Texinfo/XS/convert/build_html_perl_state.h
b/tp/Texinfo/XS/convert/build_html_perl_state.h
index fe320107d2..e5337a1dc0 100644
--- a/tp/Texinfo/XS/convert/build_html_perl_state.h
+++ b/tp/Texinfo/XS/convert/build_html_perl_state.h
@@ -15,7 +15,7 @@
void pass_html_element_targets (SV *converter_sv,
HTML_TARGET_LIST *html_targets);
void pass_html_special_targets (SV *converter_sv,
- HTML_TARGET_LIST **html_special_targets);
+ HTML_TARGET_LIST *html_special_targets);
void pass_html_seen_ids (SV *converter_sv, STRING_LIST *seen_ids);
void pass_converter_errors (ERROR_MESSAGE_LIST *error_messages,
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index 42c34ac18c..fe70704f23 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -737,7 +737,7 @@ add_element_target_to_list (HTML_TARGET_LIST *targets,
static HTML_TARGET *
add_element_target (CONVERTER *self, ELEMENT *element, char *target)
{
- HTML_TARGET_LIST *targets = self->html_targets;
+ HTML_TARGET_LIST *targets = &self->html_targets;
return add_element_target_to_list (targets, element, target);
}
@@ -745,7 +745,7 @@ static HTML_TARGET *
add_special_target (CONVERTER *self, enum special_target_type type,
ELEMENT *element, char *target)
{
- HTML_TARGET_LIST *targets = self->html_special_targets[type];
+ HTML_TARGET_LIST *targets = &self->html_special_targets[type];
return add_element_target_to_list (targets, element, target);
}
@@ -874,7 +874,7 @@ set_special_units_targets_files (CONVERTER *self, int
special_units_descriptor,
HTML_TARGET *element_target
= add_element_target (self, special_unit->unit_command, target);
element_target->special_unit_filename = filename;
- add_string (target, self->seen_ids);
+ add_string (target, &self->seen_ids);
if (target_filename)
{
@@ -937,7 +937,7 @@ prepare_associated_special_units_targets (CONVERTER *self,
element_target
= add_element_target (self, special_unit->unit_command, target);
if (target)
- add_string (target, self->seen_ids);
+ add_string (target, &self->seen_ids);
if (filename)
element_target->special_unit_filename = filename;
@@ -1014,7 +1014,7 @@ unique_target (CONVERTER *self, char *target_base)
char *target = strdup (target_base);
while (1)
{
- if (find_string (self->seen_ids, target))
+ if (find_string (&self->seen_ids, target))
{
free (target);
xasprintf (&target, "%s-%d", target_base, nr);
@@ -1104,7 +1104,7 @@ new_sectioning_command_target (CONVERTER *self, ELEMENT
*command)
HTML_TARGET *element_target
= add_element_target (self, command, target);
element_target->section_filename = filename;
- add_string (target, self->seen_ids);
+ add_string (target, &self->seen_ids);
free (target);
@@ -1205,7 +1205,7 @@ set_root_commands_targets_node_files (CONVERTER *self)
HTML_TARGET *element_target
= add_element_target (self, target_element, target);
element_target->node_filename = node_filename;
- add_string (target, self->seen_ids);
+ add_string (target, &self->seen_ids);
free (target);
}
@@ -1339,7 +1339,7 @@ prepare_index_entries_targets (CONVERTER *self)
target_element = main_entry_element;
add_element_target (self, target_element, target);
- add_string (target, self->seen_ids);
+ add_string (target, &self->seen_ids);
free (target);
}
@@ -1375,10 +1375,10 @@ prepare_footnotes_targets (CONVERTER *self)
{
int j;
int non_unique = 0;
- for (j = 0; j < self->seen_ids->number; j++)
+ for (j = 0; j < self->seen_ids.number; j++)
{
- if (!strcmp (footid.text, self->seen_ids->list[j])
- || !strcmp (docid.text, self->seen_ids->list[j]))
+ if (!strcmp (footid.text, self->seen_ids.list[j])
+ || !strcmp (docid.text, self->seen_ids.list[j]))
{
non_unique = 1;
break;
@@ -1398,8 +1398,8 @@ prepare_footnotes_targets (CONVERTER *self)
else
break;
}
- add_string (footid.text, self->seen_ids);
- add_string (docid.text, self->seen_ids);
+ add_string (footid.text, &self->seen_ids);
+ add_string (docid.text, &self->seen_ids);
add_element_target (self, footnote, footid.text);
add_special_target (self, ST_footnote_location, footnote,
docid.text);
@@ -1781,7 +1781,7 @@ html_set_pages_files (CONVERTER *self, OUTPUT_UNIT_LIST
*output_units,
'identifiers_target', and thus in targets. It is a bug otherwise.
*/
FILE_SOURCE_INFO *file_source_info = 0;
HTML_TARGET *node_target
- = find_element_target (self->html_targets,
+ = find_element_target (&self->html_targets,
root_command);
node_filename = node_target->node_filename;
@@ -1845,7 +1845,7 @@ html_set_pages_files (CONVERTER *self, OUTPUT_UNIT_LIST
*output_units,
else
{
HTML_TARGET *section_target
- = find_element_target (self->html_targets,
+ = find_element_target (&self->html_targets,
command);
char *section_filename
= section_target->section_filename;
@@ -2010,7 +2010,7 @@ html_set_pages_files (CONVERTER *self, OUTPUT_UNIT_LIST
*output_units,
OUTPUT_UNIT *special_unit = special_units->list[i];
ELEMENT *unit_command = special_unit->unit_command;
HTML_TARGET *special_unit_target
- = find_element_target (self->html_targets, unit_command);
+ = find_element_target (&self->html_targets, unit_command);
char *filename = special_unit_target->special_unit_filename;
/* Associate the special elements that have no page with the main page.
@@ -2073,7 +2073,7 @@ html_set_pages_files (CONVERTER *self, OUTPUT_UNIT_LIST
*output_units,
= special_unit->associated_document_unit;
ELEMENT *unit_command = special_unit->unit_command;
HTML_TARGET *element_target
- = find_element_target (self->html_targets, unit_command);
+ = find_element_target (&self->html_targets, unit_command);
if (element_target->special_unit_filename)
filename = element_target->special_unit_filename;
@@ -2427,8 +2427,6 @@ html_converter_initialize (CONVERTER *self)
self->global_units_directions
= (OUTPUT_UNIT **) malloc ((D_Last + nr_special_units+1)
* sizeof (OUTPUT_UNIT));
- memset (self->global_units_directions, 0,
- (D_Last + nr_special_units+1) * sizeof (OUTPUT_UNIT));
/* prepare mapping of variety names to index in global_units_directions */
self->varieties_direction_index = (VARIETY_DIRECTION_INDEX **)
@@ -2461,6 +2459,7 @@ html_converter_initialize (CONVERTER *self)
memset (self->no_arg_formatted_cmd_translated.list, 0,
self->no_arg_formatted_cmd.number * sizeof (enum command_id));
}
+
for (i = 0; command_special_unit_variety[i].cmd; i++)
{
char *special_unit_variety = command_special_unit_variety[i].variety;
@@ -2472,6 +2471,8 @@ html_converter_initialize (CONVERTER *self)
self->command_special_variety_name_index[i].cmd = cmd;
self->command_special_variety_name_index[i].index = number - 1;
}
+
+
}
void
@@ -2482,15 +2483,14 @@ html_initialize_output_state (CONVERTER *self, char
*context)
/* used for diverse elements: tree units, indices, footnotes, special
elements, contents elements... */
- self->html_targets = (HTML_TARGET_LIST *) malloc (sizeof (HTML_TARGET_LIST));
- self->seen_ids = (STRING_LIST *) malloc (sizeof (STRING_LIST));
- memset (self->html_targets, 0, sizeof (HTML_TARGET_LIST));
- memset (self->seen_ids, 0, sizeof (STRING_LIST));
+ memset (&self->html_targets, 0, sizeof (HTML_TARGET_LIST));
+ memset (&self->seen_ids, 0, sizeof (STRING_LIST));
+ memset (self->global_units_directions, 0,
+ (D_Last + self->special_unit_varieties.number+1) * sizeof (OUTPUT_UNIT));
+
for (i = 0; i < ST_footnote_location+1; i++)
{
- self->html_special_targets[i]
- = (HTML_TARGET_LIST *) malloc (sizeof (HTML_TARGET_LIST));
- memset (self->html_special_targets[i], 0, sizeof (HTML_TARGET_LIST));
+ memset (&self->html_special_targets[i], 0, sizeof (HTML_TARGET_LIST));
}
self->current_formatting_references = &self->formatting_references[0];
@@ -2790,7 +2790,7 @@ html_translate_names (CONVERTER *self)
if (command)
{
HTML_TARGET *target
- = find_element_target (self->html_targets, command);
+ = find_element_target (&self->html_targets, command);
if (target)
{
target->tree = 0;
@@ -2812,9 +2812,13 @@ html_translate_names (CONVERTER *self)
{
int translated_nr = 0;
COMMAND_ID_LIST *translated_cmds =
&self->no_arg_formatted_cmd_translated;
+ /* in general this is done in build_html_translated_names. Still need
+ to do it here if build_html_translated_names is never called */
if (translated_cmds->number)
- memset (translated_cmds->list, 0, translated_cmds->number
+ {
+ memset (translated_cmds->list, 0, translated_cmds->number
* sizeof (enum command_id));
+ }
for (j = 0; j < self->no_arg_formatted_cmd.number; j++)
{
diff --git a/tp/Texinfo/XS/main/converter_types.h
b/tp/Texinfo/XS/main/converter_types.h
index 05e4fb2975..f47b3765a6 100644
--- a/tp/Texinfo/XS/main/converter_types.h
+++ b/tp/Texinfo/XS/main/converter_types.h
@@ -385,17 +385,7 @@ typedef struct CONVERTER {
char *title_titlepage;
/* HTML specific */
- OUTPUT_UNIT **global_units_directions;
- SPECIAL_UNIT_DIRECTION **special_units_direction_name;
- char **special_unit_info[SUI_type_heading+1];
- ELEMENT **special_unit_info_tree[SUIT_type_heading+1];
- STRING_LIST special_unit_varieties;
- VARIETY_DIRECTION_INDEX **varieties_direction_index;
- STRING_LIST *seen_ids;
- HTML_TARGET_LIST *html_targets;
- HTML_TARGET_LIST *html_special_targets[ST_footnote_location+1];
- char **directions_strings[TDS_type_rel+1];
- HTML_COMMAND_CONVERSION **html_command_conversion[BUILTIN_CMD_NUMBER];
+ /* set for a converter */
COMMAND_ID_LIST no_arg_formatted_cmd;
int code_types[ET_special_unit_element+1];
char *pre_class_types[ET_special_unit_element+1];
@@ -410,9 +400,27 @@ typedef struct CONVERTER {
FORMATTING_REFERENCE types_conversion[ET_special_unit_element+1];
FORMATTING_REFERENCE
css_string_types_conversion[ET_special_unit_element+1];
FORMATTING_REFERENCE output_units_conversion[OU_special_unit+1];
+ char **special_unit_info[SUI_type_heading+1];
+
+ /* set for a converter, modified in a document */
+ HTML_COMMAND_CONVERSION **html_command_conversion[BUILTIN_CMD_NUMBER];
+
+ /* set for a document */
+ OUTPUT_UNIT **global_units_directions;
+ SPECIAL_UNIT_DIRECTION **special_units_direction_name;
+ ELEMENT **special_unit_info_tree[SUIT_type_heading+1];
+ STRING_LIST special_unit_varieties;
+ VARIETY_DIRECTION_INDEX **varieties_direction_index;
+ STRING_LIST seen_ids;
+ HTML_TARGET_LIST html_targets;
+ HTML_TARGET_LIST html_special_targets[ST_footnote_location+1];
+ char **directions_strings[TDS_type_rel+1];
/* associate cmd and index in special_unit_varieties STRING_LIST */
/* number in sync with command_special_unit_variety, +1 for trailing 0 */
COMMAND_ID_INDEX command_special_variety_name_index[4+1];
+ size_t *output_unit_file_indices; /* array of indices in
output_unit_files
+ each position corresponding to an output unit. */
+ size_t *special_unit_file_indices; /* same for special output units */
/* state only in C converter */
unsigned long modified_state; /* specifies which perl state to rebuild */
@@ -429,9 +437,6 @@ typedef struct CONVERTER {
to be brought to perl */
int document_contexts_to_pop; /* number of contexts to pop in perl before
readding the new contexts */
- size_t *output_unit_file_indices; /* array of indices in
output_unit_files
- each position corresponding to an output unit. */
- size_t *special_unit_file_indices; /* same for special output units */
/* next three allow to switch from normal HTML formatting to css strings
formatting */
FORMATTING_REFERENCE *current_formatting_references;