[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Thu, 18 Jan 2024 14:31:11 -0500 (EST) |
branch: master
commit 7abd62842dc697e96d942ac7949b2ace0dd833d7
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Wed Jan 17 23:30:40 2024 +0100
* tp/Texinfo/Convert/HTML.pm (_load_htmlxref_files): use
$Texinfo::ModulePath::top_srcdir to setup search directory with TEST
to avoid using the document information before calling output or
convert.
* tp/Texinfo/Convert/HTML.pm (converter_initialize): use
converter_descriptor and not document_descriptor to verify if the
converter will be found in XS.
* tp/Texinfo/XS/convert/convert_html.c (html_converter_initialize)
(html_initialize_output_state): move code needing information in
document to html_initialize_output_state.
* tp/Texinfo/XS/convert/converter.c (free_generic_converter),
tp/Texinfo/XS/main/converter_types.h (CONVERTER),
tp/Texinfo/XS/main/get_perl_info.c (get_line_message): add
small_strings in converter to store small strings from
get_line_message.
* tp/Texinfo/Convert/Converter.pm (set_document, converter): call
set_document after converter_initialize. Set convert_text_options in
set_document.
---
ChangeLog | 25 ++++++++++++
tp/Texinfo/Convert/Converter.pm | 12 ++----
tp/Texinfo/Convert/HTML.pm | 11 ++---
tp/Texinfo/XS/convert/convert_html.c | 78 ++++++++++++++++++------------------
tp/Texinfo/XS/convert/converter.c | 2 +
tp/Texinfo/XS/main/converter_types.h | 2 +
tp/Texinfo/XS/main/get_perl_info.c | 4 +-
7 files changed, 79 insertions(+), 55 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 73364b1306..ddf644ee42 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -25,6 +25,31 @@
Report from Bugsy Abatantuono <bugsyabatantuono@proton.me>.
+2024-01-17 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Convert/HTML.pm (_load_htmlxref_files): use
+ $Texinfo::ModulePath::top_srcdir to setup search directory with TEST
+ to avoid using the document information before calling output or
+ convert.
+
+ * tp/Texinfo/Convert/HTML.pm (converter_initialize): use
+ converter_descriptor and not document_descriptor to verify if the
+ converter will be found in XS.
+
+ * tp/Texinfo/XS/convert/convert_html.c (html_converter_initialize)
+ (html_initialize_output_state): move code needing information in
+ document to html_initialize_output_state.
+
+ * tp/Texinfo/XS/convert/converter.c (free_generic_converter),
+ tp/Texinfo/XS/main/converter_types.h (CONVERTER),
+ tp/Texinfo/XS/main/get_perl_info.c (get_line_message): add
+ small_strings in converter to store small strings from
+ get_line_message.
+
+ * tp/Texinfo/Convert/Converter.pm (set_document, converter): call
+ set_document after converter_initialize. Set convert_text_options in
+ set_document.
+
2024-01-17 Patrice Dumas <pertusus@free.fr>
Add initialization and finalization of conversion, separate document
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index 0252a7b722..d9d0e458bc 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -282,11 +282,9 @@ sub set_document($$)
}
Texinfo::Common::set_output_encodings($converter,
$converter->{'document_info'});
- # TODO should be done here, but need to split converter_initialize
- # in document specifc and not document specific
- #$converter->{'convert_text_options'}
- # = Texinfo::Convert::Text::copy_options_for_convert_text($converter);
+ $converter->{'convert_text_options'}
+ = Texinfo::Convert::Text::copy_options_for_convert_text($converter);
}
# this function is designed so as to be used in specific Converters
@@ -363,14 +361,12 @@ sub converter($;$)
# information can be passed to C.
_XS_converter_initialize($converter);
+ $converter->converter_initialize();
+
if ($document) {
set_document($converter, $document);
}
- $converter->converter_initialize();
- $converter->{'convert_text_options'}
- = Texinfo::Convert::Text::copy_options_for_convert_text($converter);
-
return $converter;
}
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index f6063570c1..fc5c25b8df 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -8384,12 +8384,9 @@ sub _load_htmlxref_files {
# directories if TEST is set.
@htmlxref_dirs = File::Spec->catdir($curdir, '.texinfo');
- if (defined($self->{'document_info'})
- and defined($self->{'document_info'}->{'input_directory'})) {
- my $input_directory = $self->{'document_info'}->{'input_directory'};
- if ($input_directory ne '.' and $input_directory ne '') {
- unshift @htmlxref_dirs, $input_directory;
- }
+ if ($Texinfo::ModulePath::texinfo_uninstalled) {
+ unshift @htmlxref_dirs, File::Spec->catdir(
+ $Texinfo::ModulePath::top_srcdir, 'tp', 't', 'input_files');
}
} elsif ($self->{'language_config_dirs'}
and @{$self->{'language_config_dirs'}}) {
@@ -8795,7 +8792,7 @@ sub converter_initialize($)
}
# XS parser initialization
- if ($self->{'document_descriptor'} and $XS_convert) {
+ if ($self->{'converter_descriptor'} and $XS_convert) {
# reformat special_unit_info information passed to XS to simplify
# XS code
if ($self->{'special_unit_info'}) {
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index 3272f6a5c5..a3b1fa0301 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -15987,44 +15987,8 @@ html_converter_initialize (CONVERTER *self)
{
int i;
int nr_special_units;
- char *output_encoding;
- char *line_break_element;
/* initialization needing some information from perl */
- output_encoding = self->conf->OUTPUT_ENCODING_NAME.string;
-
- for (i = 0; i < SC_non_breaking_space+1; i++)
- {
- char *unicode_point = special_characters_formatting[i][2];
- char *entity = special_characters_formatting[i][0];
- char *encoded_string = special_characters_formatting[i][1];
- char *numeric_entity = special_characters_formatting[i][3];
- char *special_character_string;
-
- if (self->conf->OUTPUT_CHARACTERS.integer > 0
- && unicode_point_decoded_in_encoding (output_encoding,
- unicode_point))
- special_character_string = encoded_string;
- else if (self->conf->USE_NUMERIC_ENTITY.integer > 0)
- special_character_string = numeric_entity;
- else
- special_character_string = entity;
-
- self->special_character[i].string = special_character_string;
- self->special_character[i].len = strlen (special_character_string);
- }
-
- if (self->conf->USE_XML_SYNTAX.integer > 0)
- {
- /* here in perl something for rules but we already get that from perl */
- line_break_element = "<br/>";
- }
- else
- line_break_element = "<br>";
-
- self->line_break_element.string = line_break_element;
- self->line_break_element.len = strlen(line_break_element);
-
nr_special_units = self->special_unit_varieties.number;
self->direction_unit_direction_name = (const char **) malloc
@@ -16123,8 +16087,6 @@ html_converter_initialize (CONVERTER *self)
qsort (self->htmlxref.list, self->htmlxref.number,
sizeof (HTMLXREF_MANUAL), compare_htmlxref_manual);
- sort_css_element_class_styles (self);
-
/* set to customization such that it is not replaced by C functions */
if (self->conf->XS_EXTERNAL_FORMATTING.integer > 0)
{
@@ -16432,11 +16394,51 @@ reset_html_targets (CONVERTER *self, HTML_TARGET_LIST
*targets)
void
html_initialize_output_state (CONVERTER *self, char *context)
{
+ int i;
+ char *output_encoding;
+ char *line_break_element;
+
if (!self->document && self->conf->DEBUG.integer > 0)
{
fprintf (stderr, "REMARK: html_initialize_output_state: no document");
}
+ output_encoding = self->conf->OUTPUT_ENCODING_NAME.string;
+
+ for (i = 0; i < SC_non_breaking_space+1; i++)
+ {
+ char *unicode_point = special_characters_formatting[i][2];
+ char *entity = special_characters_formatting[i][0];
+ char *encoded_string = special_characters_formatting[i][1];
+ char *numeric_entity = special_characters_formatting[i][3];
+ char *special_character_string;
+
+ if (self->conf->OUTPUT_CHARACTERS.integer > 0
+ && unicode_point_decoded_in_encoding (output_encoding,
+ unicode_point))
+ special_character_string = encoded_string;
+ else if (self->conf->USE_NUMERIC_ENTITY.integer > 0)
+ special_character_string = numeric_entity;
+ else
+ special_character_string = entity;
+
+ self->special_character[i].string = special_character_string;
+ self->special_character[i].len = strlen (special_character_string);
+ }
+
+ if (self->conf->USE_XML_SYNTAX.integer > 0)
+ {
+ /* here in perl something for rules but we already get that from perl */
+ line_break_element = "<br/>";
+ }
+ else
+ line_break_element = "<br>";
+
+ self->line_break_element.string = line_break_element;
+ self->line_break_element.len = strlen(line_break_element);
+
+ sort_css_element_class_styles (self);
+
/* set the htmlxref type split of the document */
self->document_htmlxref_split_type = htmlxref_split_type_mono;
diff --git a/tp/Texinfo/XS/convert/converter.c
b/tp/Texinfo/XS/convert/converter.c
index 2660df5fa3..ba2fbbbdcf 100644
--- a/tp/Texinfo/XS/convert/converter.c
+++ b/tp/Texinfo/XS/convert/converter.c
@@ -890,6 +890,8 @@ free_generic_converter (CONVERTER *self)
destroy_text_options (self->convert_text_options);
wipe_error_message_list (&self->error_messages);
+
+ free_strings_list (&self->small_strings);
}
diff --git a/tp/Texinfo/XS/main/converter_types.h
b/tp/Texinfo/XS/main/converter_types.h
index 1242838f47..a3264fc5f0 100644
--- a/tp/Texinfo/XS/main/converter_types.h
+++ b/tp/Texinfo/XS/main/converter_types.h
@@ -687,6 +687,8 @@ typedef struct CONVERTER {
TRANSLATED_COMMAND *translated_commands;
ERROR_MESSAGE_LIST error_messages;
+ /* for error messages registered in the converter */
+ STRING_LIST small_strings;
DOCUMENT *document;
MERGED_INDEX *index_entries;
diff --git a/tp/Texinfo/XS/main/get_perl_info.c
b/tp/Texinfo/XS/main/get_perl_info.c
index c1c9c09568..9044b3b912 100644
--- a/tp/Texinfo/XS/main/get_perl_info.c
+++ b/tp/Texinfo/XS/main/get_perl_info.c
@@ -311,7 +311,7 @@ get_line_message (CONVERTER *self, enum error_type type,
int continuation,
if (source_info->file_name)
{
char *saved_string = add_string (source_info->file_name,
- self->document->small_strings);
+ &self->small_strings);
free (source_info->file_name);
source_info->file_name = saved_string;
}
@@ -319,7 +319,7 @@ get_line_message (CONVERTER *self, enum error_type type,
int continuation,
if (source_info->macro)
{
char *saved_string = add_string (source_info->macro,
- self->document->small_strings);
+ &self->small_strings);
free (source_info->macro);
source_info->macro = saved_string;
}