[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/XS/convert/convert_html.c (determine
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/XS/convert/convert_html.c (determine_non_default_special_unit_directions) (html_initialize_output_state): add a function that returns an array indicating special units directions different from default spacial units directions names. Indeed, if the customized special unit direction name is not the same as the defaults, the default direction info should not be used as they are not for the customized special unit direction. Code taken from html_initialize_output_state for spec [...] |
Date: |
Wed, 02 Oct 2024 06:06:34 -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 62f99b2537 * tp/Texinfo/XS/convert/convert_html.c
(determine_non_default_special_unit_directions) (html_initialize_output_state):
add a function that returns an array indicating special units directions
different from default spacial units directions names. Indeed, if the
customized special unit direction name is not the same as the defaults, the
default direction info should not be used as they are not for the customized
special unit direction. Code taken from html_initialize_ [...]
62f99b2537 is described below
commit 62f99b2537f8657269f6d579ee018fb9374a6d92
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Tue Jul 30 23:53:51 2024 +0200
* tp/Texinfo/XS/convert/convert_html.c
(determine_non_default_special_unit_directions)
(html_initialize_output_state): add a function that returns an array
indicating special units directions different from default spacial
units directions names. Indeed, if the customized special unit
direction name is not the same as the defaults, the default direction
info should not be used as they are not for the customized special
unit direction. Code taken from html_initialize_output_state for
special units direction strings.
* tp/Texinfo/XS/convert/convert_html.c (html_converter_initialize)
(html_free_converter), tp/Texinfo/XS/convert/get_html_perl_info.c
(html_converter_initialize_sv), tp/Texinfo/XS/main/converter_types.h
(CONVERTER): add customized_translated_direction_strings field in
converter and get the customized translated_direction_strings in
html_converter_initialize_sv in the same code where customized
untranslated direction_strings are determined. Set converter
translated_direction_strings in html_converter_initialize based on
defaults from main/conversion_data.c and
customized_translated_direction_strings. Do not set
translated_direction_strings from Perl data in
html_converter_initialize_sv.
---
ChangeLog | 25 ++++
tp/Texinfo/XS/convert/convert_html.c | 141 ++++++++++++++++++----
tp/Texinfo/XS/convert/get_html_perl_info.c | 186 +++++++++++------------------
tp/Texinfo/XS/main/converter_types.h | 1 +
4 files changed, 216 insertions(+), 137 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d59868e0a3..c60e8cf960 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,31 @@
(converter_initialize): readd converter_initialize that was mistakenly
removed.
+2024-07-30 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/convert/convert_html.c
+ (determine_non_default_special_unit_directions)
+ (html_initialize_output_state): add a function that returns an array
+ indicating special units directions different from default spacial
+ units directions names. Indeed, if the customized special unit
+ direction name is not the same as the defaults, the default direction
+ info should not be used as they are not for the customized special
+ unit direction. Code taken from html_initialize_output_state for
+ special units direction strings.
+
+ * tp/Texinfo/XS/convert/convert_html.c (html_converter_initialize)
+ (html_free_converter), tp/Texinfo/XS/convert/get_html_perl_info.c
+ (html_converter_initialize_sv), tp/Texinfo/XS/main/converter_types.h
+ (CONVERTER): add customized_translated_direction_strings field in
+ converter and get the customized translated_direction_strings in
+ html_converter_initialize_sv in the same code where customized
+ untranslated direction_strings are determined. Set converter
+ translated_direction_strings in html_converter_initialize based on
+ defaults from main/conversion_data.c and
+ customized_translated_direction_strings. Do not set
+ translated_direction_strings from Perl data in
+ html_converter_initialize_sv.
+
2024-07-30 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/convert/get_html_perl_info.c
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index 4b3e4a76fb..de53b43161 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -17372,6 +17372,33 @@ html_converter_init_special_unit (CONVERTER *self)
}
}
+static int *
+determine_non_default_special_unit_directions (const CONVERTER *self)
+{
+ int i;
+ int nr_special_units = self->special_unit_varieties.number;
+ int *non_default_special_unit_directions = 0;
+ /* determine the special units directions that are not the same as
+ the default units directions. If not the same as the defaults,
+ the default direction info should not be used as they are not for
+ the customized special unit direction */
+ if (nr_special_units > 0)
+ {
+ non_default_special_unit_directions = (int *)
+ malloc (nr_special_units * sizeof (int));
+ memset (non_default_special_unit_directions, 0,
+ nr_special_units * sizeof (int));
+
+ for (i = 0; i < nr_special_units; i++)
+ {
+ if (strcmp (self->special_unit_info[SUI_type_direction][i],
+ default_special_unit_info[SUI_type_direction][i]))
+ non_default_special_unit_directions[i] = 1;
+ }
+ }
+ return non_default_special_unit_directions;
+}
+
/* most of the initialization is done by html_converter_initialize_sv
in get_perl_info, the initialization that do not require information
directly from perl data is done here. This is called after information
@@ -17380,7 +17407,15 @@ void
html_converter_initialize (CONVERTER *self)
{
int i;
- int nr_special_units;
+ enum direction_string_type DS_type;
+ int nr_special_units = self->special_unit_varieties.number;
+ /* The corresponding direction without FirstInFile are used instead
+ of FirstInFile*, so the directions_strings are not set */
+ int nr_string_directions = NON_SPECIAL_DIRECTIONS_NR - FIRSTINFILE_NR
+ + nr_special_units;
+ int nr_dir_str_contexts = TDS_context_string +1;
+ int *non_default_special_unit_directions =
+ determine_non_default_special_unit_directions (self);
/* counters of external formatting functions */
int external_special_unit_body_formatting_function = 0;
@@ -17413,8 +17448,6 @@ html_converter_initialize (CONVERTER *self)
}
}
- nr_special_units = self->special_unit_varieties.number;
-
self->direction_unit_direction_name = (const char **) malloc
((nr_special_units + NON_SPECIAL_DIRECTIONS_NR +1) * sizeof (char *));
memcpy (self->direction_unit_direction_name, html_button_direction_names,
@@ -17430,6 +17463,62 @@ html_converter_initialize (CONVERTER *self)
self->direction_unit_direction_name[i]);
*/
+
+
+ /* setup translated_direction_strings */
+ for (DS_type = 0; DS_type < TDS_TRANSLATED_MAX_NR; DS_type++)
+ {
+ self->translated_direction_strings[DS_type]
+ = new_directions_strings_translated_type (nr_string_directions);
+ for (i = 0; i < nr_string_directions; i++)
+ {
+ HTML_DIRECTION_STRING_TRANSLATED *dir_string_translated
+ = &self->translated_direction_strings[DS_type][i];
+ if (self->customized_translated_direction_strings[DS_type]
+ && self->customized_translated_direction_strings[DS_type][i])
+ {
+ HTML_DIRECTION_STRING_TRANSLATED *custom_dir_translated
+ = self->customized_translated_direction_strings[DS_type][i];
+ if (custom_dir_translated->to_convert)
+ dir_string_translated->to_convert
+ = strdup (custom_dir_translated->to_convert);
+ else
+ {
+ int j;
+
+ for (j = 0; j < nr_dir_str_contexts; j++)
+ if (custom_dir_translated->converted[j])
+ dir_string_translated->converted[j]
+ = strdup (custom_dir_translated->converted[j]);
+ }
+ }
+ else if (i < NON_SPECIAL_DIRECTIONS_NR - FIRSTINFILE_NR
+ || !non_default_special_unit_directions[
+ i - (NON_SPECIAL_DIRECTIONS_NR - FIRSTINFILE_NR)])
+ {
+ const HTML_DEFAULT_DIRECTION_STRING_TRANSLATED
*default_dir_translated
+ = &default_translated_directions_strings[DS_type][i];
+ if (default_dir_translated->to_convert)
+ dir_string_translated->to_convert
+ = strdup (default_dir_translated->to_convert);
+ else
+ {
+ if (default_dir_translated->converted)
+ {
+ int j;
+
+ for (j = 0; j < nr_dir_str_contexts; j++)
+ dir_string_translated->converted[j]
+ = strdup (default_dir_translated->converted);
+ }
+ }
+ }
+ }
+ }
+
+ free (non_default_special_unit_directions);
+
+
/* allocate space for translated tree types, they will be created
on-demand during the conversion */
for (i = 0; i < SUIT_type_heading+1; i++)
@@ -18097,7 +18186,8 @@ html_initialize_output_state (CONVERTER *self, const
char *context)
enum direction_string_type DS_type;
const char *line_break_element;
int css_style_idx = 0;
- int *non_default_special_unit_directions = 0;
+ int *non_default_special_unit_directions =
+ determine_non_default_special_unit_directions (self);
if (!self->document && self->conf->DEBUG.o.integer > 0)
{
@@ -18297,25 +18387,6 @@ html_initialize_output_state (CONVERTER *self, const
char *context)
}
}
- /* determine the special units directions that are not the same as
- the default units directions. If not the same as the defaults,
- the default direction info should not be used as they are not for
- the customized special unit direction */
- if (nr_special_units > 0)
- {
- non_default_special_unit_directions = (int *)
- malloc (nr_special_units * sizeof (int));
- memset (non_default_special_unit_directions, 0,
- nr_special_units * sizeof (int));
-
- for (i = 0; i < nr_special_units; i++)
- {
- if (strcmp (self->special_unit_info[SUI_type_direction][i],
- default_special_unit_info[SUI_type_direction][i]))
- non_default_special_unit_directions[i] = 1;
- }
- }
-
for (DS_type = 0; DS_type < TDS_TYPE_MAX_NR; DS_type++)
{
int i;
@@ -19532,6 +19603,30 @@ html_free_converter (CONVERTER *self)
free (customized_type_dir_strings);
}
+ for (i = 0; i < TDS_TRANSLATED_MAX_NR; i++)
+ {
+ int j;
+ if (self->customized_translated_direction_strings[i])
+ {
+ HTML_DIRECTION_STRING_TRANSLATED **customized_translated
+ = self->customized_translated_direction_strings[i];
+ for (j = 0; j < nr_string_directions; j++)
+ {
+ if (customized_translated[j])
+ {
+ int k;
+ free (customized_translated[j]->to_convert);
+ for (k = 0; k < nr_dir_str_contexts; k++)
+ {
+ free (customized_translated[j]->converted[k]);
+ }
+ }
+ free (customized_translated[j]);
+ }
+ free (customized_translated);
+ }
+ }
+
for (i = 0; i < TDS_TRANSLATED_MAX_NR; i++)
{
int j;
diff --git a/tp/Texinfo/XS/convert/get_html_perl_info.c
b/tp/Texinfo/XS/convert/get_html_perl_info.c
index e7966532fb..97577cdf05 100644
--- a/tp/Texinfo/XS/convert/get_html_perl_info.c
+++ b/tp/Texinfo/XS/convert/get_html_perl_info.c
@@ -255,14 +255,12 @@ html_converter_initialize_sv (SV *converter_sv,
SV **file_id_setting_sv;
SV **code_types_sv;
SV **pre_class_types_sv;
- SV **translated_direction_strings_sv;
HV *formatting_function_hv;
HV *commands_open_hv;
HV *commands_conversion_hv;
HV *types_open_hv;
HV *types_conversion_hv;
HV *output_units_conversion_hv;
- HV *translated_direction_strings_hv;
CONVERTER *converter;
int nr_accent_cmd = 0;
int nr_string_directions;
@@ -874,98 +872,6 @@ html_converter_initialize_sv (SV *converter_sv,
}
}
- FETCH(translated_direction_strings)
-
- if (translated_direction_strings_sv)
- translated_direction_strings_hv
- = (HV *) SvRV (*translated_direction_strings_sv);
-
- /* The corresponding direction without FirstInFile are used instead
- of FirstInFile*, so the directions_strings are not set */
- nr_string_directions = NON_SPECIAL_DIRECTIONS_NR - FIRSTINFILE_NR
- + special_unit_varieties->number;
-
- for (DS_type = 0; DS_type < TDS_TRANSLATED_MAX_NR; DS_type++)
- {
- converter->translated_direction_strings[DS_type]
- = new_directions_strings_translated_type (nr_string_directions);
-
- if (translated_direction_strings_sv)
- {
- const char *type_name = direction_string_type_names[DS_type];
- SV **direction_sv = hv_fetch (translated_direction_strings_hv,
- type_name, strlen (type_name), 0);
-
- if (direction_sv)
- {
- int i;
- HV *direction_hv = (HV *) SvRV (*direction_sv);
-
- for (i = 0; i < nr_string_directions; i++)
- {
- const char *direction_name;
- SV **spec_sv;
-
- if (i < FIRSTINFILE_MIN_IDX)
- direction_name = html_button_direction_names[i];
- else
- direction_name
- = converter->special_unit_info[SUI_type_direction]
- [i - FIRSTINFILE_MIN_IDX];
-
- spec_sv = hv_fetch (direction_hv, direction_name,
- strlen (direction_name), 0);
-
- if (spec_sv && SvOK (*spec_sv))
- {
- HV *spec_hv = (HV *) SvRV (*spec_sv);
-
- SV **to_convert_sv = hv_fetch (spec_hv, "to_convert",
- strlen ("to_convert"), 0);
- /* can be undef if set through Config */
- if (to_convert_sv && SvOK (*to_convert_sv))
- {
- const char *to_convert
- = (char *) SvPVutf8_nolen (*to_convert_sv);
- converter
-
->translated_direction_strings[DS_type][i].to_convert
- = non_perl_strdup (to_convert);
- }
- else
- {
- SV **context_sv = hv_fetch (spec_hv, "converted",
- strlen ("converted"), 0);
- if (context_sv)
- {
- HV *context_hv = (HV *) SvRV (*context_sv);
- int j;
-
- for (j = 0; j < nr_dir_str_contexts; j++)
- {
- const char *context_name
- = direction_string_context_names[j];
-
- SV **value_sv
- = hv_fetch (context_hv, context_name,
- strlen (context_name), 0);
-
- if (value_sv)
- {
- const char *value
- = (char *) SvPVutf8_nolen (*value_sv);
- converter
- ->translated_direction_strings[DS_type][i].converted[j]
- = non_perl_strdup (value);
- }
- }
- }
- }
- }
- }
- }
- }
- }
-
FETCH(customized_no_arg_commands_formatting)
if (customized_no_arg_commands_formatting_sv)
{
@@ -1081,18 +987,24 @@ html_converter_initialize_sv (SV *converter_sv,
}
}
+ /* The corresponding direction without FirstInFile are used instead
+ of FirstInFile*, so the directions_strings are not set */
+ nr_string_directions = NON_SPECIAL_DIRECTIONS_NR - FIRSTINFILE_NR
+ + special_unit_varieties->number;
+
if (customized_direction_strings && SvOK (customized_direction_strings))
{
HV *customized_direction_strings_hv
= (HV *) SvRV (customized_direction_strings);
- for (DS_type = TDS_TRANSLATED_MAX_NR;
- DS_type < TDS_TYPE_MAX_NR; DS_type++)
+ for (DS_type = 0; DS_type < TDS_TYPE_MAX_NR; DS_type++)
{
int i;
const char *type_name;
HV *direction_hv = 0;
SV **direction_sv;
+ size_t customized_type = DS_type;
+ int translated = 0;
type_name = direction_string_type_names[DS_type];
@@ -1101,15 +1013,29 @@ html_converter_initialize_sv (SV *converter_sv,
if (direction_sv && SvOK (*direction_sv))
direction_hv = (HV *) SvRV (*direction_sv);
- size_t customized_type = DS_type - (TDS_TRANSLATED_MAX_NR);
+ if (DS_type < TDS_TRANSLATED_MAX_NR)
+ {
+ translated = 1;
+ converter->customized_translated_direction_strings[DS_type]
+ = (HTML_DIRECTION_STRING_TRANSLATED **) malloc
+ (nr_string_directions
+ * sizeof (HTML_DIRECTION_STRING_TRANSLATED *));
+ memset (converter
+ ->customized_translated_direction_strings[DS_type], 0,
+ nr_string_directions
+ * sizeof (HTML_DIRECTION_STRING_TRANSLATED *));
+ }
+ else
+ {
+ customized_type = DS_type - (TDS_TRANSLATED_MAX_NR);
/* do not use new_directions_strings_type as a 0 for a direction
array
is allowed here, it means that there is a customized value undef
*/
- converter->customized_directions_strings[customized_type]
- = (char ***) malloc (nr_string_directions * sizeof (char **));
- memset (converter->customized_directions_strings[customized_type], 0,
- nr_string_directions * sizeof (char **));
-
+ converter->customized_directions_strings[customized_type]
+ = (char ***) malloc (nr_string_directions * sizeof (char **));
+ memset
(converter->customized_directions_strings[customized_type],
+ 0, nr_string_directions * sizeof (char **));
+ }
for (i = 0; i < nr_string_directions; i++)
{
@@ -1130,17 +1056,45 @@ html_converter_initialize_sv (SV *converter_sv,
if (spec_sv && SvOK (*spec_sv))
{
HV *spec_hv = (HV *) SvRV (*spec_sv);
- SV **context_sv = hv_fetch (spec_hv, "converted",
- strlen ("converted"), 0);
+ HTML_DIRECTION_STRING_TRANSLATED
+ *dir_string_translated = 0;
+ if (translated)
+ {
+ SV **to_convert_sv = hv_fetch (spec_hv, "to_convert",
+ strlen ("to_convert"), 0);
- converter->
- customized_directions_strings[customized_type][i]
- = (char **)
+ dir_string_translated
+ = (HTML_DIRECTION_STRING_TRANSLATED *) malloc
+ (sizeof (HTML_DIRECTION_STRING_TRANSLATED));
+ memset (dir_string_translated, 0,
+ sizeof (HTML_DIRECTION_STRING_TRANSLATED));
+ converter
+
->customized_translated_direction_strings[DS_type][i]
+ = dir_string_translated;
+
+ /* can be undef if set through Config */
+ if (to_convert_sv && SvOK (*to_convert_sv))
+ {
+ const char *to_convert
+ = (char *) SvPVutf8_nolen (*to_convert_sv);
+ dir_string_translated->to_convert
+ = non_perl_strdup (to_convert);
+ continue;
+ }
+ }
+ else
+ {
+ converter->
+ customized_directions_strings[customized_type][i]
+ = (char **)
malloc (nr_dir_str_contexts * sizeof (char *));
- memset (converter->
- customized_directions_strings[customized_type][i],
- 0, nr_dir_str_contexts * sizeof (char *));
+ memset (converter->
+ customized_directions_strings[customized_type][i],
+ 0, nr_dir_str_contexts * sizeof (char *));
+ }
+ SV **context_sv = hv_fetch (spec_hv, "converted",
+ strlen ("converted"), 0);
if (context_sv && SvOK (*context_sv))
{
int j;
@@ -1158,9 +1112,13 @@ html_converter_initialize_sv (SV *converter_sv,
{
const char *value
= (char *) SvPVutf8_nolen (*value_sv);
- converter->customized_directions_strings
- [customized_type][i][j]
- = strdup (value);
+ if (translated)
+ dir_string_translated->converted[j]
+ = non_perl_strdup (value);
+ else
+ converter->customized_directions_strings
+ [customized_type][i][j]
+ = non_perl_strdup (value);
}
/* in general no string value, it is completed later on
in C code
@@ -1176,7 +1134,7 @@ html_converter_initialize_sv (SV *converter_sv,
}
continue;
}
- /* for debug, case of directions not customized
+ /* for debug, case of direction not customized
else
{
fprintf (stderr,
diff --git a/tp/Texinfo/XS/main/converter_types.h
b/tp/Texinfo/XS/main/converter_types.h
index 10043aa304..cef28b91f9 100644
--- a/tp/Texinfo/XS/main/converter_types.h
+++ b/tp/Texinfo/XS/main/converter_types.h
@@ -805,6 +805,7 @@ typedef struct CONVERTER {
OUTPUT_UNIT_CONVERSION_FUNCTION
output_unit_conversion_function[OU_special_unit+1];
SPECIAL_UNIT_BODY_FORMATTING *special_unit_body_formatting;
HTML_DIRECTION_STRING_TRANSLATED
*translated_direction_strings[TDS_TRANSLATED_MAX_NR];
+ HTML_DIRECTION_STRING_TRANSLATED
**customized_translated_direction_strings[TDS_TRANSLATED_MAX_NR];
HTML_STAGE_HANDLER_INFO_LIST html_stage_handlers[HSHT_type_finish +1];
HTML_COMMAND_CONVERSION
*customized_no_arg_commands_formatting[BUILTIN_CMD_NUMBER][HCC_type_css_string+1];
/* set for a converter, modified in a document */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/XS/convert/convert_html.c (determine_non_default_special_unit_directions) (html_initialize_output_state): add a function that returns an array indicating special units directions different from default spacial units directions names. Indeed, if the customized special unit direction name is not the same as the defaults, the default direction info should not be used as they are not for the customized special unit direction. Code taken from html_initialize_output_state for spec [...],
Patrice Dumas <=