[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/Common.pm, tp/Texinfo/Config.pm (reg
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/Common.pm, tp/Texinfo/Config.pm (register_XS_document_main_configuration), tp/Texinfo/Convert/Converter.pm (encode_converter_document), tp/Texinfo/Convert/HTML.pm (_translate_names), tp/Texinfo/Convert/Text.pm (encode_text_options), tp/maintain/regenerate_C_options_info.pl: encode customization options strings in C and not in perl. The corresponding code is generated by regenerate_C_options_info.pl, using SvPVbyte for byte strings and SvPVutf8 to get UT-8 encoded strings for [...] |
Date: |
Sun, 05 Nov 2023 13:39:42 -0500 |
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 01c4879b77 * tp/Texinfo/Common.pm, tp/Texinfo/Config.pm
(register_XS_document_main_configuration), tp/Texinfo/Convert/Converter.pm
(encode_converter_document), tp/Texinfo/Convert/HTML.pm (_translate_names),
tp/Texinfo/Convert/Text.pm (encode_text_options),
tp/maintain/regenerate_C_options_info.pl: encode customization options strings
in C and not in perl. The corresponding code is generated by
regenerate_C_options_info.pl, using SvPVbyte for byte strings and SvPVutf8 to
get UT-8 [...]
01c4879b77 is described below
commit 01c4879b77cdd3638b310dc589fd8596780a4e1e
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Nov 5 19:39:31 2023 +0100
* tp/Texinfo/Common.pm, tp/Texinfo/Config.pm
(register_XS_document_main_configuration),
tp/Texinfo/Convert/Converter.pm (encode_converter_document),
tp/Texinfo/Convert/HTML.pm (_translate_names),
tp/Texinfo/Convert/Text.pm (encode_text_options),
tp/maintain/regenerate_C_options_info.pl: encode customization options
strings in C and not in perl. The corresponding code is generated by
regenerate_C_options_info.pl, using SvPVbyte for byte strings and
SvPVutf8 to get UT-8 encoded strings for character strings.
* tp/Texinfo/XS/main/TranslationsXS.xs (gettree): more compact code.
---
ChangeLog | 14 +++++++
tp/Texinfo/Common.pm | 18 ---------
tp/Texinfo/Config.pm | 3 +-
tp/Texinfo/Convert/Converter.pm | 16 ++------
tp/Texinfo/Convert/HTML.pm | 7 ++--
tp/Texinfo/Convert/Text.pm | 9 ++---
tp/Texinfo/Translations.pm | 4 +-
tp/Texinfo/XS/main/TranslationsXS.xs | 64 +++++++++++++++-----------------
tp/maintain/regenerate_C_options_info.pl | 14 ++++++-
9 files changed, 68 insertions(+), 81 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 442d3ba3ec..58fb5724f9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2023-11-05 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Common.pm, tp/Texinfo/Config.pm
+ (register_XS_document_main_configuration),
+ tp/Texinfo/Convert/Converter.pm (encode_converter_document),
+ tp/Texinfo/Convert/HTML.pm (_translate_names),
+ tp/Texinfo/Convert/Text.pm (encode_text_options),
+ tp/maintain/regenerate_C_options_info.pl: encode customization options
+ strings in C and not in perl. The corresponding code is generated by
+ regenerate_C_options_info.pl, using SvPVbyte for byte strings and
+ SvPVutf8 to get UT-8 encoded strings for character strings.
+
+ * tp/Texinfo/XS/main/TranslationsXS.xs (gettree): more compact code.
+
2023-11-05 Gavin Smith <gavinsmith0123@gmail.com>
* contrib/tex3patch: Remove. The message in texinfo.tex that
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index 27bb272996..799dfb7476 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -2547,24 +2547,6 @@ sub get_label_element($)
return undef;
}
-sub encode_options($)
-{
- my $options = shift;
- my $encoded_options = {};
- foreach my $option (keys(%$options)) {
- next unless ($valid_customization_options{$option});
- if (defined($options->{$option})
- and ref($options->{$option}) eq ''
- and not $non_decoded_customization_variables{$option}) {
- $encoded_options->{$option}
- = Encode::encode("UTF-8", $options->{$option});
- } else {
- $encoded_options->{$option} = $options->{$option};
- }
- }
- return $encoded_options;
-}
-
# non-XS does nothing and should not even be called as the caller verifies
# that there is a document descriptor; XS version registers options in XS
# document. It would have been more logical for this function to be in
diff --git a/tp/Texinfo/Config.pm b/tp/Texinfo/Config.pm
index 18e96eb2bb..31b2679885 100644
--- a/tp/Texinfo/Config.pm
+++ b/tp/Texinfo/Config.pm
@@ -896,8 +896,7 @@ sub register_XS_document_main_configuration($$)
#print STDERR "MAIN: ".join('|', sort(keys(%options)))."\n";
$options = \%options;
}
- my $encoded_options = Texinfo::Common::encode_options($options);
- Texinfo::Common::set_document_options($encoded_options, $document);
+ Texinfo::Common::set_document_options($options, $document);
}
1;
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index b916f5fa0f..808afa7d31 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -468,18 +468,13 @@ sub encode_converter_document($)
foreach my $variable ('expanded_formats', 'style_commands_formatting',
'formatting_function',
'types_open', 'types_conversion', 'commands_open', 'commands_conversion',
- 'output_units_conversion', 'code_types', 'pre_class_types') {
+ 'output_units_conversion', 'code_types', 'pre_class_types',
+ 'converter_init_conf') {
if ($self->{$variable}) {
$result->{$variable} = $self->{$variable};
}
}
- if (defined($self->{'converter_init_conf'})) {
- my $encoded_converter_init_conf
- = Texinfo::Common::encode_options($self->{'converter_init_conf'});
- $result->{'converter_init_conf'} = $encoded_converter_init_conf;
- }
-
if ($self->{'translated_commands'}) {
my $encoded_translated_commands = {};
foreach my $cmdname (keys(%{$self->{'translated_commands'}})) {
@@ -558,16 +553,13 @@ sub encode_converter_document($)
sub encode_converter_for_output($)
{
my $self = shift;
- my $encoded_conf = Texinfo::Common::encode_options($self->{'conf'});
my $result = {'converter_descriptor' => $self->{'converter_descriptor'},
- 'conf' => $encoded_conf,
+ 'conf' => $self->{'conf'},
};
if (defined($self->{'output_init_conf'})) {
- my $encoded_init_conf
- = Texinfo::Common::encode_options($self->{'output_init_conf'});
- $result->{'output_init_conf'} = $encoded_init_conf;
+ $result->{'output_init_conf'} = $self->{'output_init_conf'};
}
return $result;
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 66f9b52029..d2645869bf 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -2356,12 +2356,11 @@ sub _translate_names($)
my $self = shift;
if ($self->{'converter_descriptor'} and $XS_convert) {
- my $encoded_conf = Texinfo::Common::encode_options($self->{'conf'});
- my $encoded_converter
+ my $selected_info
= {'converter_descriptor' => $self->{'converter_descriptor'},
- 'conf' => $encoded_conf,
+ 'conf' => $self->{'conf'},
};
- _XS_translate_names($encoded_converter);
+ _XS_translate_names($selected_info);
return;
}
diff --git a/tp/Texinfo/Convert/Text.pm b/tp/Texinfo/Convert/Text.pm
index 1c687bc2fd..f00e418d0c 100644
--- a/tp/Texinfo/Convert/Text.pm
+++ b/tp/Texinfo/Convert/Text.pm
@@ -449,14 +449,11 @@ sub encode_text_options($)
# called through convert_to_text with a converter in text options
if ($options->{'converter'}
and $options->{'converter'}->{'conf'}) {
- my $encoded_converter_options
- = Texinfo::Common::encode_options($options->{'converter'}->{'conf'});
- $encoded_options->{'other_converter_options'} = $encoded_converter_options;
+ $encoded_options->{'other_converter_options'}
+ = $options->{'converter'}->{'conf'};
}
- my $encoded_converter_options
- = Texinfo::Common::encode_options($options);
- $encoded_options->{'self_converter_options'} = $encoded_converter_options;
+ $encoded_options->{'self_converter_options'} = $options;
return $encoded_options;
}
diff --git a/tp/Texinfo/Translations.pm b/tp/Texinfo/Translations.pm
index f976f7dacb..0071934e01 100644
--- a/tp/Texinfo/Translations.pm
+++ b/tp/Texinfo/Translations.pm
@@ -478,10 +478,8 @@ sub _XS_gdt($$;$$$)
my $encoded_lang;
$encoded_lang = Encode::encode('utf-8', $lang)
if (defined($lang));
- my $encoded_customization_information
- = Texinfo::Common::encode_options ($customization_information);
- my $tree = _XS_gettree ($encoded_string, $encoded_customization_information,
+ my $tree = _XS_gettree ($encoded_string, $customization_information,
$replaced_substrings,
$encoded_translation_context, $encoded_lang);
diff --git a/tp/Texinfo/XS/main/TranslationsXS.xs
b/tp/Texinfo/XS/main/TranslationsXS.xs
index bc6a3d5fa5..286e9c2374 100644
--- a/tp/Texinfo/XS/main/TranslationsXS.xs
+++ b/tp/Texinfo/XS/main/TranslationsXS.xs
@@ -63,45 +63,39 @@ gettree (char *string, ...)
int gdt_document_descriptor;
DOCUMENT *gdt_document;
CODE:
- if ( items > 4 )
- if (SvOK(ST(4)))
- in_lang = (char *)SvPVbyte_nolen(ST(4));
- if ( items > 3 )
- if (SvOK(ST(3)))
- translation_context = (char *)SvPVbyte_nolen(ST(3));
- if ( items > 2 )
+ if (items > 4 && SvOK(ST(4)))
+ in_lang = (char *)SvPVbyte_nolen(ST(4));
+ if (items > 3 && SvOK(ST(3)))
+ translation_context = (char *)SvPVbyte_nolen(ST(3));
+ if (items > 2 && SvOK(ST(2)))
{
/* TODO put in get_perl_info.h */
- if (SvOK(ST(2)))
- {
- I32 hv_number;
- I32 i;
- hv_replaced_substrings = (HV *)SvRV (ST(1));
- hv_number = hv_iterinit (hv_replaced_substrings);
- if (hv_number > 0)
- replaced_substrings = new_named_string_element_list ();
- for (i = 0; i < hv_number; i++)
- {
- char *key;
- I32 retlen;
- SV *value = hv_iternextsv(hv_replaced_substrings,
- &key, &retlen);
- DOCUMENT *document = get_sv_tree_document (value, 0);
- /* TODO should warn/error if not found or return
- a list of missing string identifiers? Or check
- in caller? In any case, it cannot be good to
- ignore a replaced substring */
- if (document && document->tree)
- add_element_to_named_string_element_list (
- replaced_substrings, key, document->tree);
- }
+ I32 hv_number;
+ I32 i;
+ hv_replaced_substrings = (HV *)SvRV (ST(1));
+ hv_number = hv_iterinit (hv_replaced_substrings);
+ if (hv_number > 0)
+ replaced_substrings = new_named_string_element_list ();
+ for (i = 0; i < hv_number; i++)
+ {
+ char *key;
+ I32 retlen;
+ SV *value = hv_iternextsv(hv_replaced_substrings,
+ &key, &retlen);
+ DOCUMENT *document = get_sv_tree_document (value, 0);
+ /* TODO should warn/error if not found or return
+ a list of missing string identifiers? Or check
+ in caller? In any case, it cannot be good to
+ ignore a replaced substring */
+ if (document && document->tree)
+ add_element_to_named_string_element_list (
+ replaced_substrings, key, document->tree);
}
}
- if ( items > 1 )
- if (SvOK(ST(1)))
- {
- options = copy_sv_options (ST(1));
- }
+ if (items > 1 && SvOK(ST(1)))
+ {
+ options = copy_sv_options (ST(1));
+ }
gdt_document_descriptor
= gdt (string, options, replaced_substrings,
diff --git a/tp/maintain/regenerate_C_options_info.pl
b/tp/maintain/regenerate_C_options_info.pl
index 6bb03cf8dd..36552eeec6 100755
--- a/tp/maintain/regenerate_C_options_info.pl
+++ b/tp/maintain/regenerate_C_options_info.pl
@@ -261,6 +261,14 @@ get_sv_option (OPTIONS *options, const char *key, SV
*value)
if (0) {}
';
+#my %non_decoded_customization_variables
+# = %Texinfo::Common::non_decoded_customization_variables;
+
+# duplicated from Texinfo::Common to avoid depending on Texinfo::Common
+my %non_decoded_customization_variables;
+foreach my $variable_name ('MACRO_EXPAND', 'INTERNAL_LINKS') {
+ $non_decoded_customization_variables{$variable_name} = 1;
+}
foreach my $category (sort(keys(%option_categories))) {
print GET "\n/* ${category} */\n\n";
@@ -268,9 +276,13 @@ foreach my $category (sort(keys(%option_categories))) {
my ($option, $value, $type) = @$option_info;
print GET " else if (!strcmp (key, \"$option\"))\n";
if ($type eq 'char *') {
+ my $SV_function_type = 'utf8';
+ if ($non_decoded_customization_variables{$option}) {
+ $SV_function_type = 'byte';
+ }
print GET " {
free (options->$option);
- options->$option = strdup (SvPVbyte_nolen (value));
+ options->$option = strdup (SvPV${SV_function_type}_nolen (value));
}\n";
} elsif ($type eq 'int') {
print GET " options->$option = SvIV (value);\n";
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/Common.pm, tp/Texinfo/Config.pm (register_XS_document_main_configuration), tp/Texinfo/Convert/Converter.pm (encode_converter_document), tp/Texinfo/Convert/HTML.pm (_translate_names), tp/Texinfo/Convert/Text.pm (encode_text_options), tp/maintain/regenerate_C_options_info.pl: encode customization options strings in C and not in perl. The corresponding code is generated by regenerate_C_options_info.pl, using SvPVbyte for byte strings and SvPVutf8 to get UT-8 encoded strings for [...],
Patrice Dumas <=