[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Thu, 14 Dec 2023 16:39:30 -0500 (EST) |
branch: master
commit c9210497da87cd1b960daeaacbc2aab66fc274ac
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Thu Dec 14 22:39:18 2023 +0100
* tp/Texinfo/Convert/Converter.pm (%XS_overrides, reset_converter),
tp/Texinfo/XS/convert/ConvertXS.xs (reset_converter)
(html_finalize_output_state), tp/texi2any.pl, tp/t/test_utils.pl
(test): split reset_converter out of html_finalize_output_state, and
call reset_converter later than html_finalize_output_state, when the
converter data is not needed anymore. In html_finalize_output_state
the finalization of the converting state is kept.
* tp/Texinfo/Convert/HTML.pm (output): call count_elements_in_filename
instead of accessing directly 'elements_in_file_count'.
* tp/Texinfo/XS/convert/convert_html.c (find_page_name_number): return
0 if the file is not found.
* tp/Texinfo/Convert/HTML.pm (%XS_conversion_overrides),
tp/Texinfo/XS/convert/ConvertXS.xs (html_count_elements_in_filename),
tp/Texinfo/XS/convert/convert_html.c (count_elements_in_filename_type)
(html_count_elements_in_filename, count_elements_in_file_number),
tp/Texinfo/XS/convert/convert_html.h
(enum count_elements_in_filename_type):
rename count_elements_in_filename as count_elements_in_file_number.
Update callers. Add html_count_elements_in_filename. Add an XS
interface for count_elements_in_filename.
* tp/Texinfo/XS/convert/build_html_perl_state.c
(build_html_formatting_state), tp/Texinfo/XS/convert/convert_html.c
(html_new_document_context, document_global_context)
(html_set_pages_files, html_finalize_output_state),
tp/Texinfo/XS/main/converter_types.h (FILE_NAME_PATH_COUNTER)
(CONVERTER): remove document_global_context, and file_counters
information passed to perl it is not needed with overrides. Remove
corresponding structures in C, file_changed_counter in converter, and
counter_changed in FILE_NAME_PATH_COUNTER.
---
ChangeLog | 36 ++++
tp/Texinfo/Convert/Converter.pm | 7 +
tp/Texinfo/Convert/HTML.pm | 4 +-
tp/Texinfo/XS/convert/ConvertXS.xs | 49 ++++-
tp/Texinfo/XS/convert/build_html_perl_state.c | 47 -----
tp/Texinfo/XS/convert/convert_html.c | 271 ++++++++++++++------------
tp/Texinfo/XS/convert/convert_html.h | 13 ++
tp/Texinfo/XS/main/converter_types.h | 4 -
tp/Texinfo/XS/main/utils.h | 2 +-
tp/t/test_utils.pl | 1 +
tp/texi2any.pl | 8 +
11 files changed, 260 insertions(+), 182 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 5bf46149ce..b93e0f4fe0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,39 @@
+2023-12-14 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Convert/Converter.pm (%XS_overrides, reset_converter),
+ tp/Texinfo/XS/convert/ConvertXS.xs (reset_converter)
+ (html_finalize_output_state), tp/texi2any.pl, tp/t/test_utils.pl
+ (test): split reset_converter out of html_finalize_output_state, and
+ call reset_converter later than html_finalize_output_state, when the
+ converter data is not needed anymore. In html_finalize_output_state
+ the finalization of the converting state is kept.
+
+ * tp/Texinfo/Convert/HTML.pm (output): call count_elements_in_filename
+ instead of accessing directly 'elements_in_file_count'.
+
+ * tp/Texinfo/XS/convert/convert_html.c (find_page_name_number): return
+ 0 if the file is not found.
+
+ * tp/Texinfo/Convert/HTML.pm (%XS_conversion_overrides),
+ tp/Texinfo/XS/convert/ConvertXS.xs (html_count_elements_in_filename),
+ tp/Texinfo/XS/convert/convert_html.c (count_elements_in_filename_type)
+ (html_count_elements_in_filename, count_elements_in_file_number),
+ tp/Texinfo/XS/convert/convert_html.h
+ (enum count_elements_in_filename_type):
+ rename count_elements_in_filename as count_elements_in_file_number.
+ Update callers. Add html_count_elements_in_filename. Add an XS
+ interface for count_elements_in_filename.
+
+ * tp/Texinfo/XS/convert/build_html_perl_state.c
+ (build_html_formatting_state), tp/Texinfo/XS/convert/convert_html.c
+ (html_new_document_context, document_global_context)
+ (html_set_pages_files, html_finalize_output_state),
+ tp/Texinfo/XS/main/converter_types.h (FILE_NAME_PATH_COUNTER)
+ (CONVERTER): remove document_global_context, and file_counters
+ information passed to perl it is not needed with overrides. Remove
+ corresponding structures in C, file_changed_counter in converter, and
+ counter_changed in FILE_NAME_PATH_COUNTER.
+
2023-12-14 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/Convert/HTML.pm (_initialize_output_state)
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index f5d0ba4588..a726a87274 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -103,6 +103,8 @@ my %XS_overrides = (
"Texinfo::Convert::Converter::converter_document_warn"
=> "Texinfo::Convert::ConvertXS::converter_document_warn",
+ "Texinfo::Convert::Converter::reset_converter"
+ => "Texinfo::Convert::ConvertXS::reset_converter",
"Texinfo::Convert::Converter::destroy"
=> "Texinfo::Convert::ConvertXS::destroy",
);
@@ -498,6 +500,11 @@ sub output($$)
return undef;
}
+# Nothing to do in perl. XS function resets converter
+sub reset_converter($)
+{
+}
+
# Nothing to do in perl. XS function frees memory
sub destroy($)
{
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index ee86b6b2fb..8b7e4c025f 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -187,6 +187,8 @@ my %XS_conversion_overrides = (
"Texinfo::Convert::HTML::in_align"
=> "Texinfo::Convert::ConvertXS::html_in_align",
+ "Texinfo::Convert::HTML::count_elements_in_filename"
+ => "Texinfo::Convert::ConvertXS::html_count_elements_in_filename",
"Texinfo::Convert::HTML::register_file_information"
=> "Texinfo::Convert::ConvertXS::html_register_file_information",
"Texinfo::Convert::HTML::get_file_information",
@@ -12174,7 +12176,7 @@ sub output($$)
my $redirection_filename
= $self->register_normalize_case_filename($node_filename);
# first condition finds conflict with tree elements
- if ($self->{'elements_in_file_count'}->{$redirection_filename}
+ if ($self->count_elements_in_filename('total', $redirection_filename)
or $redirection_filenames{$redirection_filename}) {
$self->converter_line_warn(
sprintf(__("\@%s `%s' file %s for redirection exists"),
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs
b/tp/Texinfo/XS/convert/ConvertXS.xs
index 75adb951dd..d7b9aa8a88 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -134,7 +134,7 @@ converter_document_error (SV *converter_in, text, ...)
if (self)
{
message_list_document_formatted_message (&self->error_messages,
- self->conf, MSG_document_error, continuation, strdup (text));
+ self->conf, MSG_document_error, continuation, strdup (text));
}
void
@@ -221,6 +221,21 @@ get_converter_errors (SV *converter_in)
OUTPUT:
RETVAL
+void
+reset_converter (SV *converter_in)
+ PREINIT:
+ CONVERTER *self = 0;
+ HV *stash;
+ char *name;
+ CODE:
+ stash = SvSTASH (SvRV (converter_in));
+ name = HvNAME (stash);
+ if (!strcmp (name, "Texinfo::Convert::HTML"))
+ {
+ self = get_sv_converter (converter_in, "reset html converter");
+ html_reset_converter (self);
+ }
+
void
destroy (SV *converter_in)
PREINIT:
@@ -695,6 +710,38 @@ html_in_align (SV *converter_in)
OUTPUT:
RETVAL
+SV *
+html_count_elements_in_filename (SV *converter_in, char *spec, filename)
+ char *filename = (char *)SvPVutf8_nolen($arg);
+ PREINIT:
+ IV count = -1;
+ CONVERTER *self;
+ CODE:
+ self = get_sv_converter (converter_in,
+ "html_count_elements_in_filename");
+ if (self)
+ {
+ int i;
+ for (i = 0; count_elements_in_filename_type_names[i]; i++)
+ if (!strcmp (spec, count_elements_in_filename_type_names[i]))
+ break;
+ if (!count_elements_in_filename_type_names[i])
+ {
+ fprintf (stderr, "ERROR: unknown count type: %s\n", spec);
+ }
+ else
+ {
+ count = (IV) html_count_elements_in_filename (self, i,
+ filename);
+ }
+ }
+ if (count >= 0)
+ RETVAL = newSViv (count);
+ else
+ RETVAL = newSV (0);
+ OUTPUT:
+ RETVAL
+
void
html_register_file_information (SV *converter_in, key, int value)
char *key = (char *)SvPVutf8_nolen($arg);
diff --git a/tp/Texinfo/XS/convert/build_html_perl_state.c
b/tp/Texinfo/XS/convert/build_html_perl_state.c
index 9a3433c733..12af08aa19 100644
--- a/tp/Texinfo/XS/convert/build_html_perl_state.c
+++ b/tp/Texinfo/XS/convert/build_html_perl_state.c
@@ -683,9 +683,6 @@ build_html_formatting_state (CONVERTER *converter, unsigned
long flags)
if (flags & HMSF_converter_state)
{
- STORE("document_global_context",
- newSViv (converter->document_global_context));
-
STORE("ignore_notice",
newSViv (converter->ignore_notice));
}
@@ -785,34 +782,6 @@ build_html_formatting_state (CONVERTER *converter,
unsigned long flags)
}
}
- if (converter->file_changed_counter.number)
- {
- SV **file_counters_sv;
- HV *file_counters_hv;
-
- FETCH(file_counters);
- file_counters_hv = (HV *) SvRV (*file_counters_sv);
-
- int j;
- for (j = 0; j < converter->file_changed_counter.number; j++)
- {
- size_t file_idx = converter->file_changed_counter.list[j];
- FILE_NAME_PATH_COUNTER *output_unit_file
- = &converter->output_unit_files.list[file_idx];
- char *filename = output_unit_file->filename;
-
- SV *filename_sv = newSVpv_utf8 (filename, 0);
-
- hv_store_ent (file_counters_hv, filename_sv,
- newSViv (output_unit_file->counter), 0);
-
- output_unit_file->counter_changed = 0;
- }
- memset (converter->file_changed_counter.list, 0,
- converter->file_changed_counter.number * sizeof (size_t));
- converter->file_changed_counter.number = 0;
- }
-
if (converter->added_targets.number)
{
SV **targets_sv;
@@ -873,22 +842,6 @@ build_html_formatting_state (CONVERTER *converter,
unsigned long flags)
clear_strings_list (&converter->shared_conversion_state_integer);
}
- /*
- files_information_sv = hv_fetch (hv, "files_information",
- strlen ("files_information"), 0);
-
- if (!files_information_sv)
- {
- files_information_hv = newHV ();
- STORE("files_information", newRV_noinc ((SV *) files_information_hv));
- }
- else
- {
- files_information_hv = (HV *) SvRV (*files_information_sv);
- hv_clear (files_information_av);
- }
- */
-
#undef STORE
if (flags & HMSF_translations)
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index 55b41aee52..3348b3dc0d 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -53,11 +53,8 @@
#include "structuring.h"
#include "convert_html.h"
-enum count_elements_in_filename_type {
- CEFT_total,
- CEFT_remaining,
- CEFT_current,
-};
+char *count_elements_in_filename_type_names[] = {
+ "total", "remaining", "current"};
typedef struct ROOT_AND_UNIT {
const OUTPUT_UNIT *output_unit;
@@ -748,8 +745,42 @@ html_in_multi_expanded (CONVERTER *self)
return 0;
}
+static int
+compare_page_name_number (const void *a, const void *b)
+{
+ const PAGE_NAME_NUMBER *pnn_a = (const PAGE_NAME_NUMBER *) a;
+ const PAGE_NAME_NUMBER *pnn_b = (const PAGE_NAME_NUMBER *) b;
+
+ return strcmp (pnn_a->page_name, pnn_b->page_name);
+}
+
+size_t
+find_page_name_number
+ (const PAGE_NAME_NUMBER_LIST *page_name_number,
+ const char *page_name)
+{
+ PAGE_NAME_NUMBER *result = 0;
+ static PAGE_NAME_NUMBER searched_page_name;
+ searched_page_name.page_name = page_name;
+ if (page_name_number->number == 0)
+ {
+ char *msg;
+ xasprintf (&msg, "no pages, searching for '%s'\n", page_name);
+ fatal (msg);
+ free (msg);
+ }
+
+ result = (PAGE_NAME_NUMBER *) bsearch (&searched_page_name,
+ page_name_number->list,
+ page_name_number->number, sizeof(PAGE_NAME_NUMBER),
+ compare_page_name_number);
+ if (!result)
+ return 0;
+ return result->number;
+}
+
size_t
-count_elements_in_filename (CONVERTER *self,
+count_elements_in_file_number (CONVERTER *self,
enum count_elements_in_filename_type type,
size_t file_number)
{
@@ -765,6 +796,21 @@ count_elements_in_filename (CONVERTER *self,
return file_counter->elements_in_file_count - file_counter->counter +1;
}
+/* called from perl */
+size_t
+html_count_elements_in_filename (CONVERTER *self,
+ enum count_elements_in_filename_type type,
+ const char *filename)
+{
+ size_t page_number = find_page_name_number (&self->page_name_number,
+ filename);
+
+ if (!page_number)
+ return 0;
+
+ return count_elements_in_file_number (self, type, page_number);
+}
+
ELEMENT *
special_unit_info_tree (CONVERTER *self, const enum special_unit_info_tree
type,
const char *special_unit_variety)
@@ -1082,31 +1128,6 @@ html_get_associated_formatted_inline_content (CONVERTER
*self,
return strdup ("");
}
-static int
-compare_page_name_number (const void *a, const void *b)
-{
- const PAGE_NAME_NUMBER *pnn_a = (const PAGE_NAME_NUMBER *) a;
- const PAGE_NAME_NUMBER *pnn_b = (const PAGE_NAME_NUMBER *) b;
-
- return strcmp (pnn_a->page_name, pnn_b->page_name);
-}
-
-size_t
-find_page_name_number
- (const PAGE_NAME_NUMBER_LIST *page_name_number,
- const char *page_name)
-{
- PAGE_NAME_NUMBER *result = 0;
- static PAGE_NAME_NUMBER searched_page_name;
- searched_page_name.page_name = page_name;
-
- result = (PAGE_NAME_NUMBER *) bsearch (&searched_page_name,
- page_name_number->list,
- page_name_number->number, sizeof(PAGE_NAME_NUMBER),
- compare_page_name_number);
- return result->number;
-}
-
/* API to register an information to a file and get it. To be able to
set an information during conversion and get it back during headers
and footers conversion */
@@ -2536,7 +2557,6 @@ html_new_document_context (CONVERTER *self,
if (document_global_context)
{
self->document_global_context++;
- self->modified_state |= HMSF_converter_state;
}
push_html_formatting_context (&doc_context->formatting_context,
@@ -2570,7 +2590,6 @@ html_pop_document_context (CONVERTER *self)
if (document_ctx->document_global_context)
{
self->document_global_context--;
- self->modified_state |= HMSF_converter_state;
}
stack->top--;
@@ -3203,7 +3222,7 @@ char *html_command_href (CONVERTER *self, const ELEMENT
*command,
if (target_filename->file_number > 0)
{
size_t count_in_file
- = count_elements_in_filename (self, CEFT_total,
+ = count_elements_in_file_number (self, CEFT_total,
target_filename->file_number);
if (count_in_file == 1)
target = "";
@@ -3601,6 +3620,8 @@ html_command_text (CONVERTER *self, const ELEMENT
*command,
tree_root = tree_root_string;
/* TODO tree_root_string/tree_root probably remains in tree_to_build
as it is not removed nor set to string_tree->tree */
+ fprintf (stderr, "TODO: manual_content check tree_to_build '%s'\n",
+ convert_to_texinfo (tree_root));
add_to_element_list (&self->tree_to_build, tree_root);
}
else
@@ -3672,6 +3693,8 @@ html_command_text (CONVERTER *self, const ELEMENT
*command,
tree_root = tree_root_string;
/* TODO tree_root_string/tree_root probably remains in tree_to_build
as it is not removed nor set to string_tree->tree */
+ fprintf (stderr, "TODO: command_text check tree_to_build '%s'\n",
+ convert_to_texinfo (tree_root));
add_to_element_list (&self->tree_to_build, tree_root);
}
else
@@ -4897,12 +4920,6 @@ html_set_pages_files (CONVERTER *self, OUTPUT_UNIT_LIST
*output_units,
}
}
- /* initialize data that requires output_unit_files number */
- self->file_changed_counter.list = (size_t *)
- malloc (self->output_unit_files.number * sizeof (size_t));
- memset (self->file_changed_counter.list, 0,
- self->output_unit_files.number * sizeof (size_t));
-
/* 0 is for document_global_context_css, the remaining indices
for the output unit files */
self->page_css.number = self->output_unit_files.number +1;
@@ -5962,7 +5979,8 @@ html_default_format_element_header (CONVERTER *self,
{
file_index = self->output_unit_file_indices[output_unit->index];
count_in_file
- = count_elements_in_filename (self, CEFT_current, file_index +1);
+ = count_elements_in_file_number (self, CEFT_current,
+ file_index +1);
if (count_in_file == 1)
first_in_page = 1;
}
@@ -8060,7 +8078,7 @@ convert_special_unit_type (CONVERTER *self,
{
size_t file_index = self->special_unit_file_indices[output_unit->index];
count_in_file
- = count_elements_in_filename (self, CEFT_current, file_index +1);
+ = count_elements_in_file_number (self, CEFT_current, file_index +1);
}
if (self->conf->HEADERS > 0
@@ -8877,6 +8895,89 @@ html_initialize_output_state (CONVERTER *self, char
*context)
void
html_finalize_output_state (CONVERTER *self)
+{
+ int i;
+ for (i = 0; i < self->html_files_information.number; i++)
+ {
+ destroy_associated_info (&self->html_files_information.list[i]);
+ }
+ free (self->html_files_information.list);
+
+ /* should not be possible with default code, as
+ close_registered_sections_level(0)
+ is called at the end of processing or at the end of each file.
+ However, it could happen if the conversion functions are user
+ defined.
+ */
+ if (self->pending_closes.top > 0)
+ {
+ message_list_document_warn (&self->error_messages, self->conf,
+ "%zu registered opened sections not closed",
+ self->pending_closes.top);
+ clear_string_stack (&self->pending_closes);
+ }
+
+ if (self->pending_inline_content.top > 0)
+ {
+ char *inline_content = html_get_pending_formatted_inline_content (self);
+ message_list_document_warn (&self->error_messages, self->conf,
+ "%zu registered inline contents: %s",
+ self->pending_inline_content.top, inline_content);
+ free (inline_content);
+ }
+
+ for (i = 0; i < self->associated_inline_content.number; i++)
+ {
+ HTML_ASSOCIATED_INLINE_CONTENT *associated_content
+ = &self->associated_inline_content.list[i];
+ if (associated_content->inline_content.space > 0)
+ {
+ char *inline_content = associated_content->inline_content.text;
+ if (associated_content->element)
+ {
+ char *element_str
+ = print_element_debug (associated_content->element, 0);
+ message_list_document_warn (&self->error_messages, self->conf,
+ "left inline content associated to %s: '%s'", element_str,
+ inline_content);
+ free (element_str);
+ }
+ else if (associated_content->hv)
+ {
+ message_list_document_warn (&self->error_messages, self->conf,
+ "left inline content of %p: '%s'", associated_content->hv,
+ inline_content);
+ }
+ else
+ message_list_document_warn (&self->error_messages, self->conf,
+ "left inline content associated: '%s'", inline_content);
+ free (associated_content->inline_content.text);
+ }
+ }
+ self->associated_inline_content.number = 0;
+
+ self->shared_conversion_state.integers.info_number = 0;
+
+ html_pop_document_context (self);
+
+ /* could change to 0 in releases? */
+ if (1)
+ {
+ if (self->html_document_context.top > 0)
+ fprintf (stderr, "BUG: document context top > 0: %zu\n",
+ self->html_document_context.top);
+ if (self->document_global_context)
+ fprintf (stderr, "BUG: document_global_context: %d\n",
+ self->document_global_context);
+ if (self->ignore_notice)
+ fprintf (stderr, "BUG: ignore_notice: %d\n",
+ self->ignore_notice);
+ }
+
+}
+
+void
+html_reset_converter (CONVERTER *self)
{
int i;
reset_translated_special_unit_info_tree (self);
@@ -8966,69 +9067,6 @@ html_finalize_output_state (CONVERTER *self)
}
free (self->page_css.list);
- for (i = 0; i < self->html_files_information.number; i++)
- {
- destroy_associated_info (&self->html_files_information.list[i]);
- }
- free (self->html_files_information.list);
-
- /* should not be possible with default code, as
- close_registered_sections_level(0)
- is called at the end of processing or at the end of each file.
- However, it could happen if the conversion functions are user
- defined.
- */
- if (self->pending_closes.top > 0)
- {
- message_list_document_warn (&self->error_messages, self->conf,
- "%zu registered opened sections not closed",
- self->pending_closes.top);
- clear_string_stack (&self->pending_closes);
- }
-
- if (self->pending_inline_content.top > 0)
- {
- char *inline_content = html_get_pending_formatted_inline_content (self);
- message_list_document_warn (&self->error_messages, self->conf,
- "%zu registered inline contents: %s",
- self->pending_inline_content.top, inline_content);
- free (inline_content);
- }
-
- for (i = 0; i < self->associated_inline_content.number; i++)
- {
- HTML_ASSOCIATED_INLINE_CONTENT *associated_content
- = &self->associated_inline_content.list[i];
- if (associated_content->inline_content.space > 0)
- {
- char *inline_content = associated_content->inline_content.text;
- if (associated_content->element)
- {
- char *element_str
- = print_element_debug (associated_content->element, 0);
- message_list_document_warn (&self->error_messages, self->conf,
- "left inline content associated to %s: '%s'", element_str,
- inline_content);
- free (element_str);
- }
- else if (associated_content->hv)
- {
- message_list_document_warn (&self->error_messages, self->conf,
- "left inline content of %p: '%s'", associated_content->hv,
- inline_content);
- }
- else
- message_list_document_warn (&self->error_messages, self->conf,
- "left inline content associated: '%s'", inline_content);
- free (associated_content->inline_content.text);
- }
- }
- self->associated_inline_content.number = 0;
-
- self->shared_conversion_state.integers.info_number = 0;
-
- html_pop_document_context (self);
-
/* could change to 0 in releases? */
if (1)
{
@@ -9048,19 +9086,8 @@ html_finalize_output_state (CONVERTER *self)
}
}
}
- if (self->html_document_context.top > 0)
- fprintf (stderr, "BUG: document context top > 0: %zu\n",
- self->html_document_context.top);
- if (self->document_global_context)
- fprintf (stderr, "BUG: document_global_context: %d\n",
- self->document_global_context);
- if (self->ignore_notice)
- fprintf (stderr, "BUG: ignore_notice: %d\n",
- self->ignore_notice);
}
-
free (self->tree_to_build.list);
-
}
void
@@ -9081,9 +9108,6 @@ html_check_transfer_state_finalization (CONVERTER *self)
if (self->reset_target_commands.number)
fprintf (stderr, "BUG: reset_target_commands: %zu\n",
self->reset_target_commands.number);
- if (self->file_changed_counter.number)
- fprintf (stderr, "BUG: file_changed_counter: %zu\n",
- self->file_changed_counter.number);
}
}
@@ -9190,7 +9214,6 @@ html_free_converter (CONVERTER *self)
free (self->no_arg_formatted_cmd_translated.list);
free (self->reset_target_commands.list);
- free (self->file_changed_counter.list);
free (self->referred_command_stack.stack);
@@ -10513,14 +10536,6 @@ convert_output_output_unit_internal (CONVERTER *self,
}
unit_file->counter--;
- if (!unit_file->counter_changed)
- {
- self->file_changed_counter.list[self->file_changed_counter.number]
- = file_index;
- self->file_changed_counter.number++;
- unit_file->counter_changed = 1;
- self->modified_state |= HMSF_file_counter;
- }
/* register the output but do not print anything. Printing
only when file_counters reach 0, to be sure that all the
diff --git a/tp/Texinfo/XS/convert/convert_html.h
b/tp/Texinfo/XS/convert/convert_html.h
index a8e17a353f..fe027b65a2 100644
--- a/tp/Texinfo/XS/convert/convert_html.h
+++ b/tp/Texinfo/XS/convert/convert_html.h
@@ -8,6 +8,12 @@
/* for FILE_SOURCE_INFO_LIST */
#include "utils.h"
+enum count_elements_in_filename_type {
+ CEFT_total,
+ CEFT_remaining,
+ CEFT_current,
+};
+
extern char *html_conversion_context_type_names[];
extern char *html_global_unit_direction_names[];
@@ -17,6 +23,8 @@ extern TRANSLATED_SUI_ASSOCIATION
translated_special_unit_info[];
extern const char *special_unit_info_type_names[SUI_type_heading + 1];
extern const char *htmlxref_split_type_names[htmlxref_split_type_chapter + 1];
+extern char *count_elements_in_filename_type_names[];
+
void html_format_init (void);
void html_converter_initialize (CONVERTER *self);
@@ -62,6 +70,10 @@ enum command_id html_in_align (CONVERTER *self);
char *debug_print_html_contexts (CONVERTER *self);
+size_t html_count_elements_in_filename (CONVERTER *self,
+ enum count_elements_in_filename_type type,
+ const char *filename);
+
void html_register_file_information (CONVERTER *self, const char *key,
int value);
int html_get_file_information (CONVERTER *self, const char *key,
@@ -142,6 +154,7 @@ char *html_convert_output (CONVERTER *self, const ELEMENT
*root,
void html_check_transfer_state_finalization (CONVERTER *self);
void html_free_converter (CONVERTER *self);
+void html_reset_converter (CONVERTER *self);
void html_destroy_files_source_info (FILE_SOURCE_INFO_LIST *files_source_info);
#endif
diff --git a/tp/Texinfo/XS/main/converter_types.h
b/tp/Texinfo/XS/main/converter_types.h
index 7bf37d97f1..f062c01cd6 100644
--- a/tp/Texinfo/XS/main/converter_types.h
+++ b/tp/Texinfo/XS/main/converter_types.h
@@ -350,8 +350,6 @@ typedef struct FILE_NAME_PATH_COUNTER {
'elements_in_file_count' */
TEXT body; /* file body output, used for HTML */
const OUTPUT_UNIT *first_unit;
- int counter_changed; /* indicator to determine if the file has already
- been setup for change in counter passed to perl */
} FILE_NAME_PATH_COUNTER;
typedef struct FILE_NAME_PATH_COUNTER_LIST {
@@ -718,8 +716,6 @@ typedef struct CONVERTER {
ELEMENT_LIST reset_target_commands; /* element targets that should have
their texts reset after language
change */
- ARRAY_INDEX_LIST file_changed_counter; /* index of files in
- output_unit_files with changed counter */
HTML_ADDED_TARGET_LIST added_targets; /* targets added */
STRING_LIST shared_conversion_state_integer; /* modified */
/* next 4 allow to switch from normal HTML formatting to css strings
diff --git a/tp/Texinfo/XS/main/utils.h b/tp/Texinfo/XS/main/utils.h
index dfbc6205c0..bf5bb57b19 100644
--- a/tp/Texinfo/XS/main/utils.h
+++ b/tp/Texinfo/XS/main/utils.h
@@ -135,7 +135,7 @@ enum command_location {
#define HMSF_converter_state 0x1000
#define HMSF_multiple_pass 0x2000
#define HMSF_translations 0x4000
-#define HMSF_file_counter 0x8000
+#define HMSF_ 0x8000
#define HMSF_added_target 0x00010000
#define HMSF_referred_command_stack 0x00020000
diff --git a/tp/t/test_utils.pl b/tp/t/test_utils.pl
index 7e567807a6..16da3da835 100644
--- a/tp/t/test_utils.pl
+++ b/tp/t/test_utils.pl
@@ -1323,6 +1323,7 @@ sub test($$)
}
}
}
+ $converter->reset_converter();
$converter->destroy();
}
}
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index 8692c3c866..7b8e61debe 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -1768,6 +1768,12 @@ while(@input_files) {
}
}
+ # Texinfo::Converter::Text does not define it. Alternatively could be
+ # a mandated part of the converter API
+ if ($converter->can('reset_converter')) {
+ $converter->reset_converter();
+ }
+
if (defined(get_conf('SORT_ELEMENT_COUNT')) and $file_number == 0) {
require Texinfo::Convert::TextContent;
my $sort_element_converter_options = { %$main_program_default_options,
@@ -1827,6 +1833,8 @@ while(@input_files) {
push @opened_files, Texinfo::Common::output_files_opened_files(
$sort_elem_files_information);
+
+ $converter_element_count->destroy();
# we do not need to go through unclosed files of
# $sort_elem_files_information as we know that the file is
# already closed if needed.