[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Wed, 2 Oct 2024 06:05:15 -0400 (EDT) |
branch: master
commit 7323011ca30d95dc70aaa41f3282363a957f6ed9
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Tue Jul 30 21:26:25 2024 +0200
* tp/Texinfo/Convert/HTML.pm (converter_initialize): avoid spurious
autovivification for translated_direction_strings.
* tp/Texinfo/XS/convert/get_html_perl_info.c
(html_converter_initialize_sv): handle undef spec hv in
translated_direction_strings.
* tp/maintain/generate_code_convert_data.pl: declare
default_converted_directions_strings and
default_translated_directions_strings.
* tp/Texinfo/XS/convert/convert_html.c (html_initialize_output_state):
use default_converted_directions_strings from main/conversion_data.c
instead of the information coming from Perl. 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.
---
ChangeLog | 21 +++++++++++++++++
tp/Texinfo/Convert/HTML.pm | 3 ++-
tp/Texinfo/XS/convert/convert_html.c | 36 +++++++++++++++++++++++++-----
tp/Texinfo/XS/convert/get_html_perl_info.c | 14 +++++++++---
tp/Texinfo/XS/main/conversion_data.h | 4 ++++
tp/maintain/generate_code_convert_data.pl | 7 ++++++
6 files changed, 76 insertions(+), 9 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ff05525574..770c0cab3c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,27 @@
(converter_initialize): readd converter_initialize that was mistakenly
removed.
+2024-07-30 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Convert/HTML.pm (converter_initialize): avoid spurious
+ autovivification for translated_direction_strings.
+
+ * tp/Texinfo/XS/convert/get_html_perl_info.c
+ (html_converter_initialize_sv): handle undef spec hv in
+ translated_direction_strings.
+
+ * tp/maintain/generate_code_convert_data.pl: declare
+ default_converted_directions_strings and
+ default_translated_directions_strings.
+
+ * tp/Texinfo/XS/convert/convert_html.c (html_initialize_output_state):
+ use default_converted_directions_strings from main/conversion_data.c
+ instead of the information coming from Perl. 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.
+
2024-07-30 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/Convert/HTML.pm (converter_initialize): remove the code
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 28f5f80eaa..282da44321 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -9038,7 +9038,8 @@ sub converter_initialize($)
= $customized_direction_strings->{$string_type}->{$direction};
} else {
if ($default_translated_directions_strings{$string_type}->{$direction}
- ->{'converted'})
{
+ and $default_translated_directions_strings{$string_type}
+ ->{$direction}->{'converted'}) {
$self->{'translated_direction_strings'}->{$string_type}
->{$direction} = {'converted' => {}};
foreach my $context ('normal', 'string') {
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index 9c02cdec9b..86fd6fbead 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -18088,14 +18088,16 @@ html_initialize_output_state (CONVERTER *self, const
char *context)
{
int i;
const char *output_encoding;
+ 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
- + self->special_unit_varieties.number;
+ + nr_special_units;
int nr_dir_str_contexts = TDS_context_string + 1;
enum direction_string_type DS_type;
const char *line_break_element;
int css_style_idx = 0;
+ int *non_default_special_unit_directions = 0;
if (!self->document && self->conf->DEBUG.o.integer > 0)
{
@@ -18295,10 +18297,29 @@ 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;
- char **default_converted_dir_str;
+ const char * const*default_converted_dir_str;
char ***customized_type_dir_strings;
self->directions_strings[DS_type]
@@ -18310,7 +18331,7 @@ html_initialize_output_state (CONVERTER *self, const
char *context)
continue;
default_converted_dir_str =
- self->default_converted_directions_strings[
+ default_converted_directions_strings[
DS_type - (TDS_TRANSLATED_MAX_NR)];
customized_type_dir_strings = self->customized_directions_strings[
DS_type - (TDS_TRANSLATED_MAX_NR)];
@@ -18329,8 +18350,11 @@ html_initialize_output_state (CONVERTER *self, const
char *context)
}
else if (default_converted_dir_str[i])
{
- self->directions_strings[DS_type][i][TDS_context_normal]
- = substitute_html_non_breaking_space (self,
+ if (i < NON_SPECIAL_DIRECTIONS_NR - FIRSTINFILE_NR
+ || !non_default_special_unit_directions[
+ i - (NON_SPECIAL_DIRECTIONS_NR - FIRSTINFILE_NR)])
+ self->directions_strings[DS_type][i][TDS_context_normal]
+ = substitute_html_non_breaking_space (self,
default_converted_dir_str[i]);
}
@@ -18344,6 +18368,8 @@ html_initialize_output_state (CONVERTER *self, const
char *context)
}
}
+ free (non_default_special_unit_directions);
+
sort_css_element_class_styles (&self->css_element_class_styles);
/* set the htmlxref type split of the document */
diff --git a/tp/Texinfo/XS/convert/get_html_perl_info.c
b/tp/Texinfo/XS/convert/get_html_perl_info.c
index af6ade4b12..94b01d4d50 100644
--- a/tp/Texinfo/XS/convert/get_html_perl_info.c
+++ b/tp/Texinfo/XS/convert/get_html_perl_info.c
@@ -978,7 +978,7 @@ html_converter_initialize_sv (SV *converter_sv,
spec_sv = hv_fetch (direction_hv, direction_name,
strlen (direction_name), 0);
- if (spec_sv)
+ if (spec_sv && SvOK (*spec_sv))
{
HV *spec_hv = (HV *) SvRV (*spec_sv);
@@ -1200,8 +1200,8 @@ html_converter_initialize_sv (SV *converter_sv,
= (char **)
malloc (nr_dir_str_contexts * sizeof (char *));
memset (converter->
-
customized_directions_strings[customized_type][i], 0,
- nr_dir_str_contexts * sizeof (char *));
+ customized_directions_strings[customized_type][i],
+ 0, nr_dir_str_contexts * sizeof (char *));
if (context_sv && SvOK (*context_sv))
{
@@ -1247,6 +1247,14 @@ html_converter_initialize_sv (SV *converter_sv,
*/
continue;
}
+ /* not clear that it can happen
+ else
+ {
+ fprintf (stderr,
+ "customized_direction_strings: %s: %s: spec undef\n",
+ type_name, direction_name);
+ }
+ */
}
/* for debug, case of directions not customized
else
diff --git a/tp/Texinfo/XS/main/conversion_data.h
b/tp/Texinfo/XS/main/conversion_data.h
index 9e44f84072..6379d7dc88 100644
--- a/tp/Texinfo/XS/main/conversion_data.h
+++ b/tp/Texinfo/XS/main/conversion_data.h
@@ -83,6 +83,10 @@ extern const char *direction_type_translation_context[];
#define FIRSTINFILE_MIN_IDX D_direction_FirstInFileThis
#define FIRSTINFILE_MAX_IDX D_direction_FirstInFileNodeBack
+extern const char * const default_converted_directions_strings[][24];
+
+extern const HTML_DEFAULT_DIRECTION_STRING_TRANSLATED
default_translated_directions_strings[][24];
+
extern const char *html_style_commands_element[];
#endif
diff --git a/tp/maintain/generate_code_convert_data.pl
b/tp/maintain/generate_code_convert_data.pl
index 418112195c..c3caa6fb6b 100755
--- a/tp/maintain/generate_code_convert_data.pl
+++ b/tp/maintain/generate_code_convert_data.pl
@@ -578,6 +578,10 @@ if ($perl_format) {
.$direction_orders{'relative'}[-1]."\n\n";
my $nr_string_directions = scalar(@ordered_directions);
+
+ print HDR "extern const char * const default_converted_directions_strings[]["
+ ."$nr_string_directions];\n\n";
+
print OUT "const char * const default_converted_directions_strings[]["
."$nr_string_directions] = {\n";
foreach my $type (@d_ordered_untranslated_hashes) {
@@ -595,6 +599,9 @@ if ($perl_format) {
}
print OUT "};\n\n";
+ print HDR "extern const HTML_DEFAULT_DIRECTION_STRING_TRANSLATED "
+ ."default_translated_directions_strings[][$nr_string_directions];\n\n";
+
print OUT "const HTML_DEFAULT_DIRECTION_STRING_TRANSLATED "
."default_translated_directions_strings[][$nr_string_directions] = {\n";
foreach my $type (@d_ordered_translated_hashes) {