[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Sat, 13 Jan 2024 14:34:23 -0500 (EST) |
branch: master
commit fd324bf6fdd1180ed684fbd94b2474644d33a4cd
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Fri Jan 12 15:08:13 2024 +0100
* tp/Texinfo/XS/main/document.c
(register_document_convert_index_text_options),
tp/Texinfo/XS/structuring_transfo/StructuringTransfoXS.xs
(setup_index_entry_keys_formatting): free previously set
convert_index_text_options before replacing.
* tp/Texinfo/XS/convert/convert_html.c (add_to_unit_file_name_paths):
simplify.
* tp/Texinfo/XS/convert/convert_html.c (html_set_pages_files): use
unit_file_name_paths entry directly as filename.
* tp/Texinfo/XS/convert/convert_html.c (html_convert_output): call
text_reset only if needed.
* tp/Texinfo/XS/convert/convert_html.c (html_convert_output): setup
conversion to output encoding only if it is not utf-8.
---
ChangeLog | 20 +++++++++++++++++++
tp/Texinfo/Translations.pm | 2 +-
tp/Texinfo/XS/convert/convert_html.c | 23 ++++++++--------------
tp/Texinfo/XS/main/document.c | 7 ++++---
tp/Texinfo/XS/main/unicode.c | 4 ++--
.../XS/structuring_transfo/StructuringTransfoXS.xs | 3 +++
tp/t/test_sort.t | 1 +
7 files changed, 39 insertions(+), 21 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 8b7c644862..f42defafde 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2024-01-12 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/main/document.c
+ (register_document_convert_index_text_options),
+ tp/Texinfo/XS/structuring_transfo/StructuringTransfoXS.xs
+ (setup_index_entry_keys_formatting): free previously set
+ convert_index_text_options before replacing.
+
+ * tp/Texinfo/XS/convert/convert_html.c (add_to_unit_file_name_paths):
+ simplify.
+
+ * tp/Texinfo/XS/convert/convert_html.c (html_set_pages_files): use
+ unit_file_name_paths entry directly as filename.
+
+ * tp/Texinfo/XS/convert/convert_html.c (html_convert_output): call
+ text_reset only if needed.
+
+ * tp/Texinfo/XS/convert/convert_html.c (html_convert_output): setup
+ conversion to output encoding only if it is not utf-8.
+
2024-01-12 Patrice Dumas <pertusus@free.fr>
* NEWS: add the converters in C and use of TEXINFO_XS_CONVERT
diff --git a/tp/Texinfo/Translations.pm b/tp/Texinfo/Translations.pm
index 8e3d9ed679..fbf0441d5d 100644
--- a/tp/Texinfo/Translations.pm
+++ b/tp/Texinfo/Translations.pm
@@ -147,7 +147,7 @@ sub _switch_messages_locale
# general not set, except if set from the command line.
# When called from the parser, however, it should only be for @def* object
# oriented def* index name translation and $LANG is likely to be set from
the
-# tree is there was a @documentlanguage.
+# tree if there was a @documentlanguage.
# * If called from a converter, documentlanguage will in general be set from
# the document when it is encountered. Before the first @documentlanguage,
# it depends on the converter. Some do not set @documentlanguage before it
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index 1ea789534a..88d177bc98 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -651,7 +651,6 @@ html_gdt_string (const char *string, CONVERTER *self,
NAMED_STRING_ELEMENT_LIST *replaced_substrings,
const char *translation_context, const char *in_lang)
{
- /* FIXME */
char *translated_string = html_translate_string (self, string,
translation_context, in_lang);
@@ -1612,7 +1611,6 @@ static enum command_id HTML_align_cmd[] = {
CM_raggedright, CM_flushleft, CM_flushright, CM_center, 0
};
-/* TODO free? It should be freed at exit? */
void
register_format_context_command (enum command_id cmd)
{
@@ -5192,12 +5190,9 @@ static char *
add_to_unit_file_name_paths (char **unit_file_name_paths,
char *filename, OUTPUT_UNIT *output_unit)
{
- /* FIXME simplify */
- char **new_output_unit_file_name
- = &unit_file_name_paths[output_unit->index];
- *new_output_unit_file_name = strdup (filename);
+ unit_file_name_paths[output_unit->index] = strdup (filename);
- return *new_output_unit_file_name;
+ return unit_file_name_paths[output_unit->index];
}
static FILE_SOURCE_INFO_LIST *
@@ -5497,15 +5492,14 @@ html_set_pages_files (CONVERTER *self, OUTPUT_UNIT_LIST
*output_units,
size_t output_unit_file_idx = 0;
FILE_NAME_PATH_COUNTER *output_unit_file;
OUTPUT_UNIT *output_unit = output_units->list[i];
- char *output_unit_file_name = unit_file_name_paths[i];
- char *filename = strdup (output_unit_file_name);
+ char *filename = unit_file_name_paths[i];
FILE_SOURCE_INFO *file_source_info
- = find_file_source_info (files_source_info, output_unit_file_name);
+ = find_file_source_info (files_source_info, filename);
char *filepath = file_source_info->path;
FILE_NAME_PATH *file_name_path
= call_file_id_setting_unit_file_name (self, output_unit,
- output_unit_file_name, filepath);
+ filename, filepath);
if (file_name_path)
{
if (file_name_path->filename)
@@ -5548,7 +5542,6 @@ html_set_pages_files (CONVERTER *self, OUTPUT_UNIT_LIST
*output_units,
output_unit_texi (output_unit),
output_unit->unit_filename, output_unit_file->counter);
free (filename);
- free (output_unit_file_name);
}
free (unit_file_name_paths);
@@ -18384,10 +18377,9 @@ html_convert_output (CONVERTER *self, const ELEMENT
*root,
close_html_lone_element (self, &text);
text_append_n (&text, "\n", 1);
self->date_in_header = strdup (text.text);
+ text_reset (&text);
}
- text_reset (&text);
-
text_append (&result, "");
@@ -18462,7 +18454,8 @@ html_convert_output (CONVERTER *self, const ELEMENT
*root,
int i;
ENCODING_CONVERSION *conversion = 0;
- if (self->conf->OUTPUT_ENCODING_NAME.string)
+ if (self->conf->OUTPUT_ENCODING_NAME.string
+ && strcmp (self->conf->OUTPUT_ENCODING_NAME.string, "utf-8"))
{
conversion
= get_encoding_conversion
(self->conf->OUTPUT_ENCODING_NAME.string,
diff --git a/tp/Texinfo/XS/main/document.c b/tp/Texinfo/XS/main/document.c
index 2568fd1eed..026a939e66 100644
--- a/tp/Texinfo/XS/main/document.c
+++ b/tp/Texinfo/XS/main/document.c
@@ -137,6 +137,9 @@ void
register_document_convert_index_text_options (DOCUMENT *document,
TEXT_OPTIONS *text_options)
{
+ /* this can happen if indices are sorted more than once for a document */
+ if (document->convert_index_text_options)
+ destroy_text_options (document->convert_index_text_options);
document->convert_index_text_options = text_options;
}
@@ -171,9 +174,7 @@ destroy_document_information_except_tree (DOCUMENT
*document)
free (document->options);
}
if (document->convert_index_text_options)
- {
- destroy_text_options (document->convert_index_text_options);
- }
+ destroy_text_options (document->convert_index_text_options);
}
}
diff --git a/tp/Texinfo/XS/main/unicode.c b/tp/Texinfo/XS/main/unicode.c
index 8c809e4d30..4b669e7820 100644
--- a/tp/Texinfo/XS/main/unicode.c
+++ b/tp/Texinfo/XS/main/unicode.c
@@ -43,7 +43,7 @@ normalize_NFC (const char *text)
size_t lengthp;
char *result = 0;
- /* FIXME error checking? */
+ /* TODO error checking? Or cast (uint8_t *) instead of conversion? */
uint8_t *encoded_u8 = u8_strconv_from_encoding (text, "UTF-8",
iconveh_question_mark);
/* +1 to have the terminating NUL included in the string */
@@ -62,7 +62,7 @@ normalize_NFKD (const char *text)
size_t lengthp;
char *result = 0;
- /* FIXME error checking? */
+ /* TODO error checking? Or cast (uint8_t *) instead of conversion? */
uint8_t *encoded_u8 = u8_strconv_from_encoding (text, "UTF-8",
iconveh_question_mark);
/* +1 to have the terminating NUL included in the string */
diff --git a/tp/Texinfo/XS/structuring_transfo/StructuringTransfoXS.xs
b/tp/Texinfo/XS/structuring_transfo/StructuringTransfoXS.xs
index 899fd77531..8bf9ec41a1 100644
--- a/tp/Texinfo/XS/structuring_transfo/StructuringTransfoXS.xs
+++ b/tp/Texinfo/XS/structuring_transfo/StructuringTransfoXS.xs
@@ -458,6 +458,9 @@ setup_index_entry_keys_formatting (SV
*customization_info_sv)
{
TEXT_OPTIONS *text_options
= setup_converter_index_entry_keys_formatting (self);
+ /* this can happen if indices are sorted more than once */
+ if (self->convert_index_text_options)
+ destroy_text_options (self->convert_index_text_options);
self->convert_index_text_options = text_options;
}
else
diff --git a/tp/t/test_sort.t b/tp/t/test_sort.t
index 872120b0b0..da84786afa 100644
--- a/tp/t/test_sort.t
+++ b/tp/t/test_sort.t
@@ -8,6 +8,7 @@ BEGIN { plan tests => 7; };
use Texinfo::Convert::Text;
use Texinfo::Parser;
+use Texinfo::Document;
use Texinfo::Structuring;
use Test::Deep;
# package Texinfo::MainConfig is in Texinfo::Config