[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Fri, 10 Nov 2023 12:50:26 -0500 (EST) |
branch: master
commit 6748e3faeda4c589277d796a92096a14cf2977f6
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Thu Nov 9 23:17:07 2023 +0100
* tp/Texinfo/XS/convert/convert_html.c
(reset_translated_special_unit_info_tree)
(html_finalize_output_state, html_translate_names): add function
reset_translated_special_unit_info_tree based on code from
html_translate_names and use it in html_finalize_output_state too.
* tp/Texinfo/XS/main/converter_types.h (enum special_unit_info_type)
(enum special_unit_info_tree), tp/Texinfo/XS/convert/convert_html.c
(special_unit_info_tree, reset_translated_special_unit_info_tree),
tp/Texinfo/XS/main/utils.c (translated_special_unit_info),
tp/Texinfo/XS/main/utils.h (TRANSLATED_SUI_ASSOCIATION): add *_none
set to -1 for special_unit_info_type and special_unit_info_tree. Use
enum as types more.
---
ChangeLog | 16 ++++++++++++++++
tp/Texinfo/XS/convert/convert_html.c | 36 +++++++++++++++++++++++++++---------
tp/Texinfo/XS/main/converter_types.h | 3 +++
tp/Texinfo/XS/main/utils.c | 2 +-
tp/Texinfo/XS/main/utils.h | 4 ++--
5 files changed, 49 insertions(+), 12 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index a5a51cc1bf..4266c8ab33 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,22 @@
This gives inconsistent test results between XS and pure Perl.
Reverting until this can be investigated.
+2023-11-09 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/convert/convert_html.c
+ (reset_translated_special_unit_info_tree)
+ (html_finalize_output_state, html_translate_names): add function
+ reset_translated_special_unit_info_tree based on code from
+ html_translate_names and use it in html_finalize_output_state too.
+
+ * tp/Texinfo/XS/main/converter_types.h (enum special_unit_info_type)
+ (enum special_unit_info_tree), tp/Texinfo/XS/convert/convert_html.c
+ (special_unit_info_tree, reset_translated_special_unit_info_tree),
+ tp/Texinfo/XS/main/utils.c (translated_special_unit_info),
+ tp/Texinfo/XS/main/utils.h (TRANSLATED_SUI_ASSOCIATION): add *_none
+ set to -1 for special_unit_info_type and special_unit_info_tree. Use
+ enum as types more.
+
2023-11-09 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/convert/ConvertXS.xs (html_prepare_conversion_units),
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index fe70704f23..9a643393f0 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -430,11 +430,12 @@ special_unit_info_tree (CONVERTER *self, enum
special_unit_info_tree type,
if (self->special_unit_info_tree[type][i])
return self->special_unit_info_tree[type][i];
- for (j = 0; translated_special_unit_info[j].tree_type >= 0; j++)
+ for (j = 0; translated_special_unit_info[j].tree_type != SUIT_type_none; j++)
{
if (translated_special_unit_info[j].tree_type == type)
{
- int string_type = translated_special_unit_info[j].string_type;
+ enum special_unit_info_type string_type
+ = translated_special_unit_info[j].string_type;
char *special_unit_info_string
= self->special_unit_info[string_type][i];
char *translation_context;
@@ -2336,6 +2337,26 @@ html_pop_document_context (CONVERTER *self)
stack->top--;
}
+void
+reset_translated_special_unit_info_tree (CONVERTER *self)
+{
+ STRING_LIST *special_unit_varieties = &self->special_unit_varieties;
+ int j;
+ for (j = 0; translated_special_unit_info[j].tree_type != SUIT_type_none; j++)
+ {
+ int i;
+ enum special_unit_info_tree tree_type
+ = translated_special_unit_info[j].tree_type;
+ for (i = 0; i < special_unit_varieties->number; i++)
+ {
+ if (self->special_unit_info_tree[tree_type][i])
+ destroy_element_and_children (
+ self->special_unit_info_tree[tree_type][i]);
+ self->special_unit_info_tree[tree_type][i] = 0;
+ }
+ }
+}
+
/* most of the initialization is done by html_converter_initialize_sv
in get_perl_info, the initialization that do not require information
from perl is done here. This is called after information from perl
@@ -2506,6 +2527,7 @@ html_initialize_output_state (CONVERTER *self, char
*context)
void
html_finalize_output_state (CONVERTER *self)
{
+ reset_translated_special_unit_info_tree (self);
html_pop_document_context (self);
}
@@ -2764,13 +2786,9 @@ html_translate_names (CONVERTER *self)
TDS_TRANSLATED_TYPES_LIST
#undef tds_type
- for (j = 0; translated_special_unit_info[j].tree_type >= 0; j++)
- {
- int i;
- int tree_type = translated_special_unit_info[j].tree_type;
- for (i = 0; i < special_unit_varieties->number; i++)
- self->special_unit_info_tree[tree_type][i] = 0;
- }
+ /* reset trees such that they are created based on Texinfo code string
+ translation on-demand */
+ reset_translated_special_unit_info_tree (self);
/* delete the tree and formatted results for special elements
such that they are redone with the new tree when needed. */
diff --git a/tp/Texinfo/XS/main/converter_types.h
b/tp/Texinfo/XS/main/converter_types.h
index f47b3765a6..b9f51f685f 100644
--- a/tp/Texinfo/XS/main/converter_types.h
+++ b/tp/Texinfo/XS/main/converter_types.h
@@ -59,6 +59,7 @@ enum monospace_context {
sui_type(heading)
enum special_unit_info_type {
+ SUI_type_none = -1,
#define sui_type(name) SUI_type_ ## name,
SUI_TYPES_LIST
#undef sui_type
@@ -66,6 +67,8 @@ enum special_unit_info_type {
/* translated from corresponding SUI_type* */
enum special_unit_info_tree {
+ SUIT_type_none = -1,
+
SUIT_type_heading,
};
diff --git a/tp/Texinfo/XS/main/utils.c b/tp/Texinfo/XS/main/utils.c
index 3aec357159..e29cda4330 100644
--- a/tp/Texinfo/XS/main/utils.c
+++ b/tp/Texinfo/XS/main/utils.c
@@ -101,7 +101,7 @@ const char *special_unit_info_type_names[SUI_type_heading +
1] =
TRANSLATED_SUI_ASSOCIATION translated_special_unit_info[] = {
{SUIT_type_heading, SUI_type_heading},
- {-1, -1},
+ {SUIT_type_none, SUI_type_none},
};
ENCODING_CONVERSION_LIST output_conversions = {0, 0, 0, -1};
diff --git a/tp/Texinfo/XS/main/utils.h b/tp/Texinfo/XS/main/utils.h
index 9fae830ae4..d255f39a2b 100644
--- a/tp/Texinfo/XS/main/utils.h
+++ b/tp/Texinfo/XS/main/utils.h
@@ -167,8 +167,8 @@ enum conversion_context {
#define HMSF_translations 0x4000
typedef struct TRANSLATED_SUI_ASSOCIATION {
- int tree_type;
- int string_type;
+ enum special_unit_info_tree tree_type;
+ enum special_unit_info_type string_type;
} TRANSLATED_SUI_ASSOCIATION;
extern TRANSLATED_SUI_ASSOCIATION translated_special_unit_info[];