[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/XS/main/get_perl_info.c (add_svav_to
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/XS/main/get_perl_info.c (add_svav_to_string_list): use a SV * in argument, not a SV **. Update callers. |
Date: |
Thu, 02 Nov 2023 15:15:11 -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 8920b5cd40 * tp/Texinfo/XS/main/get_perl_info.c
(add_svav_to_string_list): use a SV * in argument, not a SV **. Update callers.
8920b5cd40 is described below
commit 8920b5cd40a0e5a5bb2af9641f31dbb1b8b3254d
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Thu Nov 2 20:14:56 2023 +0100
* tp/Texinfo/XS/main/get_perl_info.c (add_svav_to_string_list): use a
SV * in argument, not a SV **. Update callers.
* tp/Texinfo/XS/main/get_perl_info.c (get_sv_options),
tp/maintain/regenerate_C_options_info.pl: generate automatically
get_sv_option to get one option value from perl and set the C option.
Put get_sv_options in get_perl_info.c, that calls get_sv_option for
each option set in perl.
* tp/Texinfo/Convert/Converter.pm (import, _XS_set_conf, set_conf)
(force_conf), tp/Texinfo/XS/convert/ConvertXS.xs (set_conf),
tp/Texinfo/XS/main/get_perl_info.c (set_conf): XS interface to set
customization options in C converter options.
* tp/Texinfo/Convert/HTML.pm (_translate_names): always use XS
if with XS.
* tp/Texinfo/XS/convert/convert_html.c
(reset_unset_no_arg_commands_formatting_context),
tp/Texinfo/Convert/HTML.pm
(_reset_unset_no_arg_commands_formatting_context): add context name in
explanations of conversion.
---
ChangeLog | 25 +++++++++++
tp/Texinfo/Convert/Converter.pm | 41 +++++++++++++++++
tp/Texinfo/Convert/HTML.pm | 18 ++++----
tp/Texinfo/XS/convert/ConvertXS.xs | 10 +++++
tp/Texinfo/XS/convert/convert_html.c | 29 +++++++-----
tp/Texinfo/XS/main/get_perl_info.c | 77 +++++++++++++++++++++++---------
tp/Texinfo/XS/main/get_perl_info.h | 1 +
tp/maintain/regenerate_C_options_info.pl | 34 +++++---------
8 files changed, 172 insertions(+), 63 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index a7285c9872..11782cdeae 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2023-11-02 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/main/get_perl_info.c (add_svav_to_string_list): use a
+ SV * in argument, not a SV **. Update callers.
+
+ * tp/Texinfo/XS/main/get_perl_info.c (get_sv_options),
+ tp/maintain/regenerate_C_options_info.pl: generate automatically
+ get_sv_option to get one option value from perl and set the C option.
+ Put get_sv_options in get_perl_info.c, that calls get_sv_option for
+ each option set in perl.
+
+ * tp/Texinfo/Convert/Converter.pm (import, _XS_set_conf, set_conf)
+ (force_conf), tp/Texinfo/XS/convert/ConvertXS.xs (set_conf),
+ tp/Texinfo/XS/main/get_perl_info.c (set_conf): XS interface to set
+ customization options in C converter options.
+
+ * tp/Texinfo/Convert/HTML.pm (_translate_names): always use XS
+ if with XS.
+
+ * tp/Texinfo/XS/convert/convert_html.c
+ (reset_unset_no_arg_commands_formatting_context),
+ tp/Texinfo/Convert/HTML.pm
+ (_reset_unset_no_arg_commands_formatting_context): add context name in
+ explanations of conversion.
+
2023-11-02 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/convert/convert_html.c
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index 27049c3e2d..355c6c3f89 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -36,6 +36,8 @@ use Storable;
use Carp qw(cluck confess);
+use Texinfo::Convert::ConvertXS;
+
use Texinfo::Options;
use Texinfo::Common;
@@ -65,6 +67,25 @@ xml_accents
$VERSION = '7.1';
+my $XS_convert = 0;
+$XS_convert = 1 if (defined $ENV{TEXINFO_XS_CONVERT}
+ and $ENV{TEXINFO_XS_CONVERT} eq '1');
+
+our $module_loaded = 0;
+sub import {
+ if (!$module_loaded) {
+ if ($XS_convert) {
+ Texinfo::XSLoader::override(
+ "Texinfo::Convert::Converter::_XS_set_conf",
+ "Texinfo::Convert::ConvertXS::set_conf");
+ }
+
+ $module_loaded = 1;
+ }
+ # The usual import method
+ goto &Exporter::import;
+}
+
my %defaults = (
'documentlanguage' => undef,
);
@@ -565,6 +586,10 @@ sub get_conf($$)
return $self->{'conf'}->{$conf};
}
+sub _XS_set_conf($$$)
+{
+}
+
sub set_conf($$$)
{
my $self = shift;
@@ -577,6 +602,14 @@ sub set_conf($$$)
if ($self->{'set'}->{$conf}) {
return 0;
} else {
+ if ($self->{'converter_descriptor'} and $XS_convert) {
+ if (ref($value) eq ''
+ and not $Texinfo::Common::non_decoded_customization_variables{$conf}) {
+ _XS_set_conf($self, $conf, Encode::encode("UTF-8", $value));
+ } else {
+ _XS_set_conf($self, $conf, $value);
+ }
+ }
$self->{'conf'}->{$conf} = $value;
return 1;
}
@@ -591,6 +624,14 @@ sub force_conf($$$)
die "BUG: force_conf: unknown option $conf\n";
return undef;
}
+ if ($self->{'converter_descriptor'} and $XS_convert) {
+ if (ref($value) eq ''
+ and not $Texinfo::Common::non_decoded_customization_variables{$conf}) {
+ _XS_set_conf($self, $conf, Encode::encode("UTF-8", $value));
+ } else {
+ _XS_set_conf($self, $conf, $value);
+ }
+ }
$self->{'conf'}->{$conf} = $value;
return 1;
}
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 5fbf546eec..0f48006474 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -2329,12 +2329,11 @@ sub _XS_translate_names($)
{
}
-sub _translate_names($;$)
+sub _translate_names($)
{
my $self = shift;
- my $do_XS = shift;
- if ($do_XS and $self->{'converter_descriptor'} and $XS_convert) {
+ if ($self->{'converter_descriptor'} and $XS_convert) {
my $encoded_conf = Texinfo::Common::encode_options($self->{'conf'});
my $encoded_converter
= {'converter_descriptor' => $self->{'converter_descriptor'},
@@ -7655,25 +7654,28 @@ sub
_reset_unset_no_arg_commands_formatting_context($$$$;$)
my $translation_result;
if ($reset_context eq 'normal') {
$translation_result
- = $self->convert_tree($translated_tree, "no arg $cmdname translated");
+ = $self->convert_tree($translated_tree,
+ "no arg $cmdname translated for $reset_context");
} elsif ($reset_context eq 'preformatted') {
# there does not seems to be anything simpler...
my $preformatted_command_name = 'example';
- $self->_new_document_context("Translate $cmdname");
+ $self->_new_document_context("Translate $cmdname for $reset_context");
push @{$self->{'document_context'}->[-1]->{'composition_context'}},
$preformatted_command_name;
# should not be needed for at commands no brace translation strings
push @{$self->{'document_context'}->[-1]->{'preformatted_classes'}},
$pre_class_commands{$preformatted_command_name};
$translation_result
- = $self->convert_tree($translated_tree, "no arg $cmdname translated");
+ = $self->convert_tree($translated_tree,
+ "no arg $cmdname translated for $reset_context");
# only pop the main context
$self->_pop_document_context();
} elsif ($reset_context eq 'string') {
$translation_result
= $self->convert_tree_new_formatting_context({'type' => '_string',
'contents' => [$translated_tree]},
- 'translated_string', "string no arg $cmdname translated");
+ 'translated_string',
+ "string no arg $cmdname translated for $reset_context");
} elsif ($reset_context eq 'css_string') {
$translation_result = $self->html_convert_css_string($translated_tree);
}
@@ -11140,7 +11142,7 @@ sub convert($$)
}
# setup untranslated strings
- $self->_translate_names(1);
+ $self->_translate_names();
# FIXME duplicate of code in output()
foreach my $simpletitle_command ('settitle', 'shorttitlepage') {
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs
b/tp/Texinfo/XS/convert/ConvertXS.xs
index f0187f17d3..e1ca6a420e 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -94,6 +94,16 @@ text_convert_tree (text_options_in, tree_in, unused=0)
int
html_converter_initialize_sv (SV *converter_in, SV
*default_formatting_references, SV *default_css_string_formatting_references,
SV *default_commands_open, SV *default_commands_conversion, SV
*default_types_open, SV *default_types_conversion, SV*
default_output_units_conversion)
+void set_conf(SV *converter_in, conf, SV *value)
+ char *conf = (char *)SvPVbyte_nolen($arg);
+ PREINIT:
+ CONVERTER *self;
+ CODE:
+ /* warn? */
+ self = get_sv_converter (converter_in, 0);
+ if (self)
+ set_conf (self, conf, value);
+
void
html_initialize_output_state (SV *converter_in)
PREINIT:
diff --git a/tp/Texinfo/XS/convert/convert_html.c
b/tp/Texinfo/XS/convert/convert_html.c
index 976375623a..6dcbdc8371 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -2363,8 +2363,8 @@ convert_tree_new_formatting_context (CONVERTER *self,
ELEMENT *tree,
static void
reset_unset_no_arg_commands_formatting_context (CONVERTER *self,
- enum command_id cmd, int reset_context, int ref_context,
- int translate)
+ enum command_id cmd, enum conversion_context reset_context,
+ enum conversion_context ref_context, int translate)
{
HTML_COMMAND_CONVERSION *no_arg_command_context;
HTML_COMMAND_CONVERSION **conversion_contexts
@@ -2422,8 +2422,9 @@ reset_unset_no_arg_commands_formatting_context (CONVERTER
*self,
if (reset_context == HCC_type_normal)
{
char *explanation;
- xasprintf (&explanation, "no arg %s translated",
- builtin_command_data[cmd].cmdname);
+ xasprintf (&explanation, "no arg %s translated for",
+ builtin_command_data[cmd].cmdname,
+ html_conversion_context_type_names[reset_context]);
translation_result = html_convert_tree (self, translated_tree,
explanation);
free (explanation);
@@ -2434,8 +2435,9 @@ reset_unset_no_arg_commands_formatting_context (CONVERTER
*self,
enum command_id preformated_cmd = CM_example;
HTML_DOCUMENT_CONTEXT *top_document_ctx;
char *explanation;
- xasprintf (&context_name, "Translate %s",
- builtin_command_data[cmd].cmdname);
+ xasprintf (&context_name, "Translate %s for %s",
+ builtin_command_data[cmd].cmdname,
+ html_conversion_context_type_names[reset_context]);
html_new_document_context (self, context_name, 0, 0);
free (context_name);
@@ -2449,8 +2451,9 @@ reset_unset_no_arg_commands_formatting_context (CONVERTER
*self,
html_commands_data[preformated_cmd].pre_class);
self->modified_state |= HMSF_document_context;
- xasprintf (&explanation, "no arg %s translated",
- builtin_command_data[cmd].cmdname);
+ xasprintf (&explanation, "no arg %s translated for %s",
+ builtin_command_data[cmd].cmdname,
+ html_conversion_context_type_names[reset_context]);
translation_result = html_convert_tree (self, translated_tree,
explanation);
free (explanation);
@@ -2464,7 +2467,8 @@ reset_unset_no_arg_commands_formatting_context (CONVERTER
*self,
char *context_name;
HTML_DOCUMENT_CONTEXT *top_document_ctx;
- xasprintf (&context_name, "string no arg %s translated",
+ xasprintf (&context_name, "string no arg %s translated for %s",
+ html_conversion_context_type_names[reset_context],
builtin_command_data[cmd].cmdname);
html_new_document_context (self, context_name, 0, 0);
@@ -2481,6 +2485,7 @@ reset_unset_no_arg_commands_formatting_context (CONVERTER
*self,
else if (reset_context == HCC_type_css_string)
{
/*
+ fprintf (stderr, "TODO ccs_string %s\n",
builtin_command_data[cmd].cmdname);
translation_result = html_convert_css_string (self, translated_tree);
*/
}
@@ -2514,7 +2519,7 @@ html_translate_names (CONVERTER *self)
if (self->conf->DEBUG > 0)
{
- fprintf (stderr, "\nTRANSLATE_NAMES encoding_name: %s"
+ fprintf (stderr, "\nXS|TRANSLATE_NAMES encoding_name: %s"
" documentlanguage: %s\n",
self->conf->OUTPUT_ENCODING_NAME, self->conf->documentlanguage);
}
@@ -3229,7 +3234,9 @@ convert_to_html_internal (CONVERTER *self, ELEMENT
*element,
destroy_args_formatted (args_formatted);
if (cmd == CM_documentlanguage)
- html_translate_names (self);
+ {
+ html_translate_names (self);
+ }
free (content_formatted.text);
diff --git a/tp/Texinfo/XS/main/get_perl_info.c
b/tp/Texinfo/XS/main/get_perl_info.c
index 73b1e7e950..69113c4009 100644
--- a/tp/Texinfo/XS/main/get_perl_info.c
+++ b/tp/Texinfo/XS/main/get_perl_info.c
@@ -165,34 +165,56 @@ get_sv_output_units (SV *output_units_in, char
*warn_string)
}
void
-add_svav_to_string_list (SV **sv, STRING_LIST *string_list, int dir_strings)
+add_svav_to_string_list (SV *sv, STRING_LIST *string_list, int dir_strings)
{
+ int i;
+ SSize_t strings_nr;
+
dTHX;
- if (sv)
+ AV *av = (AV *)SvRV (sv);
+ strings_nr = av_top_index (av) +1;
+ for (i = 0; i < strings_nr; i++)
{
- int i;
- SSize_t strings_nr;
- AV *av = (AV *)SvRV (*sv);
- strings_nr = av_top_index (av) +1;
- for (i = 0; i < strings_nr; i++)
+ SV** string_sv = av_fetch (av, i, 0);
+ if (string_sv)
{
- SV** string_sv = av_fetch (av, i, 0);
- if (string_sv)
- {
- char *string = SvPVbyte_nolen (*string_sv);
- if (dir_strings)
- add_include_directory (string, string_list);
- else
- add_string (string, string_list);
- }
+ char *string = SvPVbyte_nolen (*string_sv);
+ if (dir_strings)
+ add_include_directory (string, string_list);
+ else
+ add_string (string, string_list);
}
}
}
-/* contains get_sv_options (), automatically generated from options_data.txt */
+/* contains get_sv_option (), automatically generated from options_data.txt */
#include "options_get_perl.c"
+void
+get_sv_options (SV *sv, OPTIONS *options)
+{
+ I32 hv_number;
+ I32 i;
+ HV *hv;
+
+ dTHX;
+
+ hv = (HV *)SvRV (sv);
+ hv_number = hv_iterinit (hv);
+ for (i = 0; i < hv_number; i++)
+ {
+ char *key;
+ I32 retlen;
+ SV *value = hv_iternextsv(hv, &key, &retlen);
+ if (value && SvOK (value))
+ {
+ get_sv_option (options, key, value);
+ }
+ }
+}
+
+
OPTIONS *
copy_sv_options (SV *sv_in)
{
@@ -268,8 +290,9 @@ copy_sv_options_for_convert_text (SV *sv_in)
include_directories_sv = hv_fetch (hv_in, "INCLUDE_DIRECTORIES",
strlen ("INCLUDE_DIRECTORIES"), 0);
- add_svav_to_string_list (include_directories_sv,
- &text_options->include_directories, 1);
+ if (include_directories_sv)
+ add_svav_to_string_list (*include_directories_sv,
+ &text_options->include_directories, 1);
get_expanded_formats (hv_in, &text_options->expanded_formats);
@@ -649,8 +672,9 @@ html_converter_initialize_sv (SV *sv_in, SV
*default_formatting_references,
STRING_LIST *special_unit_varieties
= (STRING_LIST *) malloc (sizeof (STRING_LIST));
memset (special_unit_varieties, 0, sizeof (STRING_LIST));
- add_svav_to_string_list (sorted_special_unit_varieties_sv,
- special_unit_varieties, 0);
+ if (sorted_special_unit_varieties_sv)
+ add_svav_to_string_list (*sorted_special_unit_varieties_sv,
+ special_unit_varieties, 0);
/* allocate space for translated tree types, but do not
get from perl, it will be created for the conversion */
@@ -1490,3 +1514,14 @@ get_sv_index_entries_sorted_by_letter (CONVERTER
*converter,
}
}
}
+
+void
+set_conf (CONVERTER *converter, const char *conf, SV *value)
+{
+ if (converter->conf)
+ get_sv_option (converter->conf, conf, value);
+ /* Too early to have aoptions set
+ else
+ fprintf (stderr, "HHH no converter conf %s\n", conf);
+ */
+}
diff --git a/tp/Texinfo/XS/main/get_perl_info.h
b/tp/Texinfo/XS/main/get_perl_info.h
index 409ceafd84..c88d5a6bed 100644
--- a/tp/Texinfo/XS/main/get_perl_info.h
+++ b/tp/Texinfo/XS/main/get_perl_info.h
@@ -16,6 +16,7 @@ OUTPUT_UNIT_LIST *get_sv_output_units (SV *output_units_in,
char *warn_string);
int get_sv_output_units_descriptor (SV *output_units_in, char *warn_string);
OPTIONS *copy_sv_options (SV *sv_in);
+void set_conf (CONVERTER *converter, const char *conf, SV *value);
TEXT_OPTIONS *copy_sv_options_for_convert_text (SV *sv_in);
int html_converter_initialize_sv (SV *sv_in, SV *default_formatting_references,
diff --git a/tp/maintain/regenerate_C_options_info.pl
b/tp/maintain/regenerate_C_options_info.pl
index 826454d5b8..6bb03cf8dd 100755
--- a/tp/maintain/regenerate_C_options_info.pl
+++ b/tp/maintain/regenerate_C_options_info.pl
@@ -254,24 +254,11 @@ open (GET, ">$get_file") or die "Open $get_file: $!\n";
print GET "/* Automatically generated from $0 */\n\n";
print GET 'void
-get_sv_options (SV *sv, OPTIONS *options)
+get_sv_option (OPTIONS *options, const char *key, SV *value)
{
- I32 hv_number;
- I32 i;
- HV *hv;
-
dTHX;
- hv = (HV *)SvRV (sv);
- hv_number = hv_iterinit (hv);
- for (i = 0; i < hv_number; i++)
- {
- char *key;
- I32 retlen;
- SV *value = hv_iternextsv(hv, &key, &retlen);
- if (value && SvOK (value))
- {
- if (0) {}
+ if (0) {}
';
@@ -279,25 +266,26 @@ foreach my $category (sort(keys(%option_categories))) {
print GET "\n/* ${category} */\n\n";
foreach my $option_info (@{$option_categories{$category}}) {
my ($option, $value, $type) = @$option_info;
- print GET " else if (!strcmp (key, \"$option\"))\n";
+ print GET " else if (!strcmp (key, \"$option\"))\n";
if ($type eq 'char *') {
- print GET " options->$option = strdup (SvPVbyte_nolen
(value));\n";
+ print GET " {
+ free (options->$option);
+ options->$option = strdup (SvPVbyte_nolen (value));
+ }\n";
} elsif ($type eq 'int') {
- print GET " options->$option = SvIV (value);\n";
+ print GET " options->$option = SvIV (value);\n";
} elsif ($type eq 'STRING_LIST') {
my $dir_string_arg = 0;
$dir_string_arg = 1
if ($option eq 'INCLUDE_DIRECTORIES');
- print GET " add_svav_to_string_list (&value,
&options->$option, $dir_string_arg);\n";
+ print GET " add_svav_to_string_list (value, &options->$option,
$dir_string_arg);\n";
} else {
- print GET " {}\n";
+ print GET " {}\n";
}
}
}
-print GET ' }
- }
-}
+print GET '}
';
close(GET);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/XS/main/get_perl_info.c (add_svav_to_string_list): use a SV * in argument, not a SV **. Update callers.,
Patrice Dumas <=