[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/XS/main/manipulate_indices.c (get_so
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/XS/main/manipulate_indices.c (get_sort_key): initialize the string passed to strxfrm_l. |
Date: |
Thu, 03 Oct 2024 16:47:37 -0400 |
This is an automated email from the git hooks/post-receive script.
pertusus pushed a commit to branch master
in repository texinfo.
The following commit(s) were added to refs/heads/master by this push:
new 02fdffe52b * tp/Texinfo/XS/main/manipulate_indices.c (get_sort_key):
initialize the string passed to strxfrm_l.
02fdffe52b is described below
commit 02fdffe52bdfd24c95a6c614cfe61d868fc3e025
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Thu Aug 8 12:31:52 2024 +0200
* tp/Texinfo/XS/main/manipulate_indices.c (get_sort_key): initialize
the string passed to strxfrm_l.
* tp/Texinfo/XS/convert/convert_html.c (html_free_converter): do not
free customized_type_dir_strings if not set.
* tp/Texinfo/XS/convert/convert_html.c (format_raw_cmd)
(html_format_setup, html_converter_customize): setup a list of format
raw commands in html_format_setup. In html_converter_customize, set
the conversion of format raw commands to ignore if the command is not
expanded and the status is FRS_status_internal.
* tp/Texinfo/XS/convert/convert_html.c (clear_type_explanations)
(html_reset_converter, html_free_converter): add
clear_type_explanations separated from html_reset_converter code.
Call in html_free_converter too, in case html_reset_converter is never
called.
* tp/Texinfo/XS/convert/convert_html.c (html_free_converter): call
reset_translated_special_unit_info_tree in case html_reset_converter
is never called.
* tp/Texinfo/XS/teximakehtml.c (main): print converter errors. Call
html_free_converter. Reorder code.
---
ChangeLog | 27 +++++++++++++
tp/Texinfo/XS/convert/convert_html.c | 71 +++++++++++++++++++++++++--------
tp/Texinfo/XS/main/manipulate_indices.c | 7 +++-
tp/Texinfo/XS/teximakehtml.c | 23 +++++++----
4 files changed, 102 insertions(+), 26 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index af023a64e5..598268fc78 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,30 @@
+2024-08-08 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/main/manipulate_indices.c (get_sort_key): initialize
+ the string passed to strxfrm_l.
+
+ * tp/Texinfo/XS/convert/convert_html.c (html_free_converter): do not
+ free customized_type_dir_strings if not set.
+
+ * tp/Texinfo/XS/convert/convert_html.c (format_raw_cmd)
+ (html_format_setup, html_converter_customize): setup a list of format
+ raw commands in html_format_setup. In html_converter_customize, set
+ the conversion of format raw commands to ignore if the command is not
+ expanded and the status is FRS_status_internal.
+
+ * tp/Texinfo/XS/convert/convert_html.c (clear_type_explanations)
+ (html_reset_converter, html_free_converter): add
+ clear_type_explanations separated from html_reset_converter code.
+ Call in html_free_converter too, in case html_reset_converter is never
+ called.
+
+ * tp/Texinfo/XS/convert/convert_html.c (html_free_converter): call
+ reset_translated_special_unit_info_tree in case html_reset_converter
+ is never called.
+
+ * tp/Texinfo/XS/teximakehtml.c (main): print converter errors. Call
+ html_free_converter. Reorder code.
+
2024-10-03 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/Makefile.am (C_libtexinfo_sources)
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index d8fcd43a3e..6675068dc9 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -16865,6 +16865,7 @@ static COMMAND_STACK def_cmd_list;
COMMAND_ID_LIST no_arg_formatted_cmd;
COMMAND_ID_LIST style_formatted_cmd;
COMMAND_ID_LIST accent_cmd;
+COMMAND_ID_LIST format_raw_cmd;
static char *unicode_entities[BUILTIN_CMD_NUMBER];
@@ -16903,6 +16904,7 @@ html_format_setup (void)
int no_arg_formatted_cmd_nr = 0;
int accent_cmd_nr = 0;
int style_formatted_cmd_nr = 0;
+ int format_raw_cmd_nr = 0;
int no_arg_formatted_cmd_idx;
int default_commands_args_nr
= sizeof (default_commands_args) / sizeof (default_commands_args[0]);
@@ -16983,7 +16985,7 @@ html_format_setup (void)
/* set flags */
/* also count the number of no_arg_formatted_cmd, style_formatted_cmd and
- accent_cmd commands */
+ accent_cmd commands and other types of commands */
for (i = 1; i < BUILTIN_CMD_NUMBER; i++)
{
if (xml_text_entity_no_arg_commands_formatting[i])
@@ -17016,7 +17018,10 @@ html_format_setup (void)
if (builtin_command_data[i].data == BLOCK_menu)
html_commands_data[i].flags |= HF_composition_context;
else if (builtin_command_data[i].data == BLOCK_format_raw)
- html_commands_data[i].flags |= HF_format_raw;
+ {
+ html_commands_data[i].flags |= HF_format_raw;
+ format_raw_cmd_nr++;
+ }
}
if (builtin_command_data[i].flags & CF_preformatted)
@@ -17050,6 +17055,7 @@ html_format_setup (void)
no_arg_formatted_cmd_nr);
initialize_cmd_list (&accent_cmd, accent_cmd_nr, 0);
initialize_cmd_list (&style_formatted_cmd, style_formatted_cmd_nr, 0);
+ initialize_cmd_list (&format_raw_cmd, format_raw_cmd_nr, 0);
for (i = 0; quoted_style_commands[i]; i++)
{
@@ -17069,6 +17075,11 @@ html_format_setup (void)
accent_cmd.list[accent_cmd.number] = i;
accent_cmd.number++;
}
+ else if (html_commands_data[i].flags & HF_format_raw)
+ {
+ format_raw_cmd.list[format_raw_cmd.number] = i;
+ format_raw_cmd.number++;
+ }
if (html_commands_data[i].flags & HF_style_command)
{
@@ -17991,6 +18002,18 @@ html_converter_customize (CONVERTER *self)
command_conversion->status = FRS_status_ignored;
}
}
+ for (i = 0; i < format_raw_cmd.number; i++)
+ {
+ enum command_id cmd = format_raw_cmd.list[i];
+ COMMAND_CONVERSION_FUNCTION *command_conversion
+ = &self->command_conversion_function[cmd];
+ if (command_conversion->status == FRS_status_internal)
+ {
+ const char *format = builtin_command_name (cmd);
+ if (!format_expanded_p (self->expanded_formats, format))
+ command_conversion->status = FRS_status_ignored;
+ }
+ }
/* all the no arg formatted commands are implemented in C */
for (i = 0; i < no_arg_formatted_cmd.number; i++)
@@ -19564,6 +19587,23 @@ html_setup_convert (CONVERTER *self)
init_conversion_after_setup_handler (self);
}
+static void
+clear_type_explanations (EXPLAINED_COMMAND_TYPE_LIST *type_explanations)
+{
+ if (type_explanations->number > 0)
+ {
+ int 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_converter (CONVERTER *self)
{
@@ -19711,17 +19751,7 @@ html_reset_converter (CONVERTER *self)
}
free (self->tree_to_build.list);
- if (type_explanations->number > 0)
- {
- 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;
- }
+ clear_type_explanations (type_explanations);
}
void
@@ -19764,6 +19794,8 @@ html_free_converter (CONVERTER *self)
EXPLAINED_COMMAND_TYPE_LIST *type_explanations
= &self->shared_conversion_state.explained_commands;
+ /* useful only if html_reset_converter was not called previously */
+ reset_translated_special_unit_info_tree (self);
if (self->error_messages.number)
{
@@ -19916,12 +19948,15 @@ html_free_converter (CONVERTER *self)
int j;
char ***customized_type_dir_strings
= self->customized_directions_strings[i];
- clear_direction_string_type (self, customized_type_dir_strings);
- for (j = 0; j < nr_string_directions; j++)
+ if (customized_type_dir_strings)
{
- free (customized_type_dir_strings[j]);
+ 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);
}
- free (customized_type_dir_strings);
}
for (i = 0; i < TDS_TRANSLATED_MAX_NR; i++)
@@ -20064,6 +20099,8 @@ html_free_converter (CONVERTER *self)
free (self->html_document_context.stack);
+ /* already cleared if html_clear_converter was called */
+ clear_type_explanations (type_explanations);
free (type_explanations->list);
free_strings_list (&self->special_unit_varieties);
diff --git a/tp/Texinfo/XS/main/manipulate_indices.c
b/tp/Texinfo/XS/main/manipulate_indices.c
index f251402989..12ad29805b 100644
--- a/tp/Texinfo/XS/main/manipulate_indices.c
+++ b/tp/Texinfo/XS/main/manipulate_indices.c
@@ -310,15 +310,18 @@ get_sort_key (const INDEX_COLLATOR *collator, const char
*sort_string)
sort_key = (BYTES_STRING *) malloc (sizeof (BYTES_STRING));
sort_key->len = strxfrm_l (0, sort_string, 0, collator->coll.locale);
char_sort_key = (char *) malloc (sizeof (char) * sort_key->len);
+ /* there is uninitialized memory without the next line. Somewhat
+ unclear why it is needed, strxfrm_l could have done it. */
+ memset (char_sort_key, 0, sizeof (char) * sort_key->len);
check_len = strxfrm_l (char_sort_key, sort_string, sort_key->len,
collator->coll.locale);
+ if (check_len != sort_key->len)
+ fatal ("strxfrm_l returns a different length");
sort_key->bytes = (unsigned char *)
malloc (sizeof (unsigned char) * sort_key->len);
memcpy (sort_key->bytes, (unsigned char *) char_sort_key,
sort_key->len);
free (char_sort_key);
- if (check_len != sort_key->len)
- fatal ("strxfrm_l returns a different length");
}
break;
#endif
diff --git a/tp/Texinfo/XS/teximakehtml.c b/tp/Texinfo/XS/teximakehtml.c
index dd053af6e5..6a5f97e86d 100644
--- a/tp/Texinfo/XS/teximakehtml.c
+++ b/tp/Texinfo/XS/teximakehtml.c
@@ -256,11 +256,13 @@ main (int argc, char *argv[])
}
*/
- /* converter initialization */
+ /* set converter */
+ /* create converter and generic converter initializations */
converter_descriptor = new_converter ();
converter = retrieve_converter (converter_descriptor);
+ /* prepare specific information for the converter */
format_defaults = new_converter_initialization_info ();
format_defaults->converted_format = strdup ("html");
format_defaults->output_format = strdup ("html");
@@ -291,26 +293,27 @@ main (int argc, char *argv[])
add_option_value (&conf->conf, converter->sorted_options,
"DEBUG", 1, 0);
*/
+ free (program_file);
+
+ /* pass information to the converter and format specific initialization */
set_converter_init_information (converter, converter_format,
format_defaults, conf);
- destroy_converter_initialization_info (format_defaults);
- destroy_converter_initialization_info (conf);
-
/* next 3 functions are HTML specific */
html_converter_init_special_unit (converter);
html_converter_customize (converter);
html_fill_options_directions (converter->conf, converter);
+ destroy_converter_initialization_info (format_defaults);
+ destroy_converter_initialization_info (conf);
+
/* prepare conversion to HTML */
converter_set_document (converter, document);
- free (program_file);
-
html_initialize_output_state (converter, "_output");
status = html_setup_output (converter, paths);
@@ -364,6 +367,12 @@ main (int argc, char *argv[])
{
free (paths[i]);
}
- /* html_conversion_finalization */
+
html_conversion_finalization (converter);
+
+ print_errors (&converter->error_messages);
+ clear_error_message_list (&converter->error_messages);
+
+ /* destroy converter */
+ html_free_converter (converter);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/XS/main/manipulate_indices.c (get_sort_key): initialize the string passed to strxfrm_l.,
Patrice Dumas <=