[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Tue, 26 Dec 2023 12:53:13 -0500 (EST) |
branch: master
commit f1671ea0de5188555fcb70ae0be0e60234d1a625
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Tue Dec 26 17:36:07 2023 +0100
* tp/Texinfo/XS/convert/get_html_perl_info.c,
tp/Texinfo/XS/main/build_perl_info.c (build_expanded_formats): rename
get_expanded_formats as build_expanded_formats and move to
build_perl_info.c.
* tp/Texinfo/Convert/Converter.pm (converter): do not inherit
Texinfo::Report.
* tp/t/test_utils.pl (convert_to_*), tp/texi2any.pl: use separate
registrar from converters to store and get the errors.
* tp/Texinfo/XS/main/build_perl_info.c (pass_converter_errors):
rename converter_hv as report_hv and verify that the errors_warnings
key is set to clarify and make sure that the function is applied to a
report object.
* tp/Texinfo/XS/convert/ConvertXS.xs (html_prepare_conversion_units):
do not call pass_converter_errors, the converter is not a
Texinfo::Report object anymore and all the messages are stored in the
C converter.
---
ChangeLog | 25 +++++++++++++-
tp/Texinfo/Convert/Converter.pm | 6 ++--
tp/Texinfo/XS/convert/ConvertXS.xs | 2 --
tp/Texinfo/XS/convert/build_html_perl_state.h | 3 --
tp/Texinfo/XS/convert/get_html_perl_info.c | 23 ++-----------
tp/Texinfo/XS/main/build_perl_info.c | 49 ++++++++++++++++++++++-----
tp/Texinfo/XS/main/build_perl_info.h | 3 --
tp/t/test_utils.pl | 31 ++++++++++-------
tp/texi2any.pl | 8 ++---
9 files changed, 93 insertions(+), 57 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e801a4a200..566f855924 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,7 +10,30 @@
2023-12-26 Patrice Dumas <pertusus@free.fr>
- * * doc/texi2any_api.texi: do not use Perl tree as it could also be a
+ * tp/Texinfo/XS/convert/get_html_perl_info.c,
+ tp/Texinfo/XS/main/build_perl_info.c (build_expanded_formats): rename
+ get_expanded_formats as build_expanded_formats and move to
+ build_perl_info.c.
+
+ * tp/Texinfo/Convert/Converter.pm (converter): do not inherit
+ Texinfo::Report.
+
+ * tp/t/test_utils.pl (convert_to_*), tp/texi2any.pl: use separate
+ registrar from converters to store and get the errors.
+
+ * tp/Texinfo/XS/main/build_perl_info.c (pass_converter_errors):
+ rename converter_hv as report_hv and verify that the errors_warnings
+ key is set to clarify and make sure that the function is applied to a
+ report object.
+
+ * tp/Texinfo/XS/convert/ConvertXS.xs (html_prepare_conversion_units):
+ do not call pass_converter_errors, the converter is not a
+ Texinfo::Report object anymore and all the messages are stored in the
+ C converter.
+
+2023-12-26 Patrice Dumas <pertusus@free.fr>
+
+ * doc/texi2any_api.texi: do not use Perl tree as it could also be a
tree in C. Other misc changes.
2023-12-26 Patrice Dumas <pertusus@free.fr>
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index a726a87274..966ae2685b 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -56,7 +56,7 @@ use Texinfo::Translations;
require Exporter;
use vars qw($VERSION @ISA @EXPORT_OK %EXPORT_TAGS);
-@ISA = qw(Exporter Texinfo::Report Texinfo::Translations);
+@ISA = qw(Exporter Texinfo::Translations);
%EXPORT_TAGS = ( 'all' => [ qw(
xml_protect_text
@@ -310,7 +310,6 @@ sub converter($;$)
# and not closed files. Accessed through output_files_information()
$converter->{'output_files'} = Texinfo::Common::output_files_initialize();
- $converter->Texinfo::Report::new();
$converter->{'error_warning_messages'} = [];
# XS converter initialization
@@ -2068,8 +2067,7 @@ in HTML converter, either through
$converter-E<gt>get_info() or label_command())
The C<converter> function returns a converter object (a blessed hash
reference) after checking the options and performing some initializations,
-especially when a document is given among the options. The converter is
-also initialized as a L<Texinfo::Report>.
+especially when a document is given among the options.
=back
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs
b/tp/Texinfo/XS/convert/ConvertXS.xs
index d506ccc866..454b4a345b 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -1632,8 +1632,6 @@ html_prepare_conversion_units (SV *converter_in, ...)
output_units_descriptor, special_units_descriptor,
associated_special_units_descriptor);
- pass_converter_errors (&self->error_messages, self->hv);
-
EXTEND(SP, 3);
PUSHs(sv_2mortal(output_units_sv));
PUSHs(sv_2mortal(special_units_sv));
diff --git a/tp/Texinfo/XS/convert/build_html_perl_state.h
b/tp/Texinfo/XS/convert/build_html_perl_state.h
index 0ffe66e65c..1a3dbba239 100644
--- a/tp/Texinfo/XS/convert/build_html_perl_state.h
+++ b/tp/Texinfo/XS/convert/build_html_perl_state.h
@@ -15,9 +15,6 @@
HV *build_html_target (HTML_TARGET *html_target);
void build_html_translated_names (HV *hv, CONVERTER *converter);
-void pass_converter_errors (ERROR_MESSAGE_LIST *error_messages,
- HV *converter_hv);
-
SV *build_html_files_source_info (FILE_SOURCE_INFO_LIST *files_source_info);
void pass_html_global_units_directions (SV *converter_sv,
const OUTPUT_UNIT **global_units_directions,
diff --git a/tp/Texinfo/XS/convert/get_html_perl_info.c
b/tp/Texinfo/XS/convert/get_html_perl_info.c
index f1486905be..223a59f875 100644
--- a/tp/Texinfo/XS/convert/get_html_perl_info.c
+++ b/tp/Texinfo/XS/convert/get_html_perl_info.c
@@ -1508,7 +1508,9 @@ find_node_target_info_nodedescription_sv (CONVERTER
*converter,
return 0;
}
-
+/* This function could be in a build* file as it builds perl data.
+ However, since it has a lot of code and logic in common with the
+ associated get function below, it is kept here. */
void
html_set_shared_conversion_state (CONVERTER *converter, SV *converter_in,
const char *cmdname, const char *state_name,
@@ -1636,22 +1638,3 @@ html_get_shared_conversion_state (CONVERTER *converter,
SV *converter_in,
return newSViv(converter->shared_conversion_state.in_skipped_node_top);
return newSV (0);
}
-
-SV *
-get_expanded_formats (EXPANDED_FORMAT *expanded_formats)
-{
- dTHX;
-
- int i;
- HV *expanded_hv = newHV ();
- for (i = 0; i < expanded_formats_number (); i++)
- {
- if (expanded_formats[i].expandedp)
- {
- char *format = expanded_formats[i].format;
- hv_store (expanded_hv, format, strlen (format),
- newSViv (1), 0);
- }
- }
- return newRV_noinc ((SV *)expanded_hv);
-}
diff --git a/tp/Texinfo/XS/main/build_perl_info.c
b/tp/Texinfo/XS/main/build_perl_info.c
index 01cdf7e61d..78e43f7400 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -1054,6 +1054,8 @@ build_source_info_hash (SOURCE_INFO source_info, HV *hv)
}
}
+/* build perl already 'formatted' message, same as the output of
+ Texinfo::Report::format*message */
static SV *
convert_error (ERROR_MESSAGE e)
{
@@ -1484,10 +1486,14 @@ build_output_units_list (size_t output_units_descriptor)
return newRV_noinc ((SV *) av_output_units);
}
-/* implements Texinfo::Report::add_formatted_message */
+/* add C messages to a Texinfo::Report object, like
+ Texinfo::Report::add_formatted_message does.
+ TODO it could replace the calls to add_formatted_message
+ in perl code, if it is found relevant.
+ */
void
pass_converter_errors (ERROR_MESSAGE_LIST *error_messages,
- HV *converter_hv)
+ HV *report_hv)
{
int i;
SV **errors_warnings_sv;
@@ -1501,16 +1507,16 @@ pass_converter_errors (ERROR_MESSAGE_LIST
*error_messages,
return;
}
- if (!converter_hv)
+ if (!report_hv)
{
- fprintf (stderr, "pass_converter_errors: BUG: no perl converter\n");
+ fprintf (stderr, "pass_converter_errors: BUG: no perl report\n");
return;
}
- errors_warnings_sv = hv_fetch (converter_hv, "errors_warnings",
- strlen ("errors_warnings"), 0);
+ errors_warnings_sv = hv_fetch (report_hv, "errors_warnings",
+ strlen ("errors_warnings"), 0);
- error_nrs_sv = hv_fetch (converter_hv, "error_nrs",
+ error_nrs_sv = hv_fetch (report_hv, "error_nrs",
strlen ("error_nrs"), 0);
if (errors_warnings_sv && SvOK(*errors_warnings_sv))
@@ -1530,9 +1536,15 @@ pass_converter_errors (ERROR_MESSAGE_LIST
*error_messages,
av_push (av, sv);
}
if (error_nrs)
- hv_store (converter_hv, "error_nrs",
+ hv_store (report_hv, "error_nrs",
strlen ("error_nrs"), newSViv (error_nrs), 0);
}
+ else
+ {
+ /* warn if it does not looks like a Texinfo::Report object, as
+ it is likely that the error messages are going to disappear */
+ fprintf (stderr, "BUG? no 'errors_warnings'. Not a Perl
Texinfo::Report?\n");
+ }
clear_error_message_list (error_messages);
}
@@ -1832,3 +1844,24 @@ build_output_files_information (SV *converter_sv,
output_files_information);
}
+/* not used for now */
+SV *
+build_expanded_formats (EXPANDED_FORMAT *expanded_formats)
+{
+ int i;
+ HV *expanded_hv;
+
+ dTHX;
+
+ expanded_hv = newHV ();
+ for (i = 0; i < expanded_formats_number (); i++)
+ {
+ if (expanded_formats[i].expandedp)
+ {
+ char *format = expanded_formats[i].format;
+ hv_store (expanded_hv, format, strlen (format),
+ newSViv (1), 0);
+ }
+ }
+ return newRV_noinc ((SV *)expanded_hv);
+}
diff --git a/tp/Texinfo/XS/main/build_perl_info.h
b/tp/Texinfo/XS/main/build_perl_info.h
index f9d438075e..50f0da3293 100644
--- a/tp/Texinfo/XS/main/build_perl_info.h
+++ b/tp/Texinfo/XS/main/build_perl_info.h
@@ -44,9 +44,6 @@ AV *build_integer_stack (INTEGER_STACK *integer_stack);
void pass_output_unit_files (SV *converter_sv,
FILE_NAME_PATH_COUNTER_LIST *output_unit_files);
-void pass_converter_errors (ERROR_MESSAGE_LIST *error_messages,
- HV *converter_hv);
-
void build_output_files_information (SV *converter_sv,
OUTPUT_FILES_INFORMATION *output_files_information);
diff --git a/tp/t/test_utils.pl b/tp/t/test_utils.pl
index 05ae514508..0d2aa9bdc3 100644
--- a/tp/t/test_utils.pl
+++ b/tp/t/test_utils.pl
@@ -63,6 +63,7 @@ use Texinfo::Options;
use Texinfo::Common;
use Texinfo::Convert::Texinfo;
use Texinfo::Config;
+use Texinfo::Report;
use Texinfo::Parser;
use Texinfo::Convert::Text;
use Texinfo::Document;
@@ -544,11 +545,12 @@ sub convert_to_plaintext($$$$$$;$)
}
my $converter_errors = $converter->get_converter_errors();
+ my $registrar = Texinfo::Report::new();
foreach my $error (@$converter_errors) {
- $converter->add_formatted_message($error);
+ $registrar->add_formatted_message($error);
}
- my ($errors, $error_nrs) = $converter->errors();
+ my ($errors, $error_nrs) = $registrar->errors();
return ($errors, $result, $converter);
}
@@ -575,11 +577,12 @@ sub convert_to_info($$$$$;$)
die if (!defined($converter_options->{'SUBDIR'}) and !defined($result));
my $converter_errors = $converter->get_converter_errors();
+ my $registrar = Texinfo::Report::new();
foreach my $error (@$converter_errors) {
- $converter->add_formatted_message($error);
+ $registrar->add_formatted_message($error);
}
- my ($errors, $error_nrs) = $converter->errors();
+ my ($errors, $error_nrs) = $registrar->errors();
return ($errors, $result, $converter);
}
@@ -612,12 +615,13 @@ sub convert_to_html($$$$$$;$)
}
my $converter_errors = $converter->get_converter_errors();
+ my $registrar = Texinfo::Report::new();
foreach my $error (@$converter_errors) {
- $converter->add_formatted_message($error);
+ $registrar->add_formatted_message($error);
}
die if (!defined($converter_options->{'SUBDIR'}) and !defined($result));
- my ($errors, $error_nrs) = $converter->errors();
+ my ($errors, $error_nrs) = $registrar->errors();
return ($errors, $result, $converter);
}
@@ -650,11 +654,12 @@ sub convert_to_xml($$$$$$;$)
}
my $converter_errors = $converter->get_converter_errors();
+ my $registrar = Texinfo::Report::new();
foreach my $error (@$converter_errors) {
- $converter->add_formatted_message($error);
+ $registrar->add_formatted_message($error);
}
- my ($errors, $error_nrs) = $converter->errors();
+ my ($errors, $error_nrs) = $registrar->errors();
return ($errors, $result, $converter);
}
@@ -706,11 +711,12 @@ sub convert_to_docbook($$$$$$;$)
}
my $converter_errors = $converter->get_converter_errors();
+ my $registrar = Texinfo::Report::new();
foreach my $error (@$converter_errors) {
- $converter->add_formatted_message($error);
+ $registrar->add_formatted_message($error);
}
- my ($errors, $error_nrs) = $converter->errors();
+ my ($errors, $error_nrs) = $registrar->errors();
return ($errors, $result, $converter);
}
@@ -741,11 +747,12 @@ sub convert_to_latex($$$$$$;$)
}
my $converter_errors = $converter->get_converter_errors();
+ my $registrar = Texinfo::Report::new();
foreach my $error (@$converter_errors) {
- $converter->add_formatted_message($error);
+ $registrar->add_formatted_message($error);
}
- my ($errors, $error_nrs) = $converter->errors();
+ my ($errors, $error_nrs) = $registrar->errors();
return ($errors, $result, $converter);
}
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index 7b8e61debe..e15a239240 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -128,6 +128,7 @@ use Locale::Messages;
use Texinfo::Options;
use Texinfo::Common;
use Texinfo::Config;
+use Texinfo::Report;
# determine the path separators
my $path_separator = $Config{'path_sep'};
@@ -1692,18 +1693,17 @@ while(@input_files) {
->{'converter'}}($converter_options);
$converter->output($document);
- # If XS is used, store XS converter errors in perl Texinfo::Report
- # object associated to the perl converter.
+ my $converter_registrar = Texinfo::Report::new();
my $converter_errors = $converter->get_converter_errors();
if (defined($converter_errors)) {
foreach my $error (@$converter_errors) {
- $converter->add_formatted_message($error);
+ $converter_registrar->add_formatted_message($error);
}
}
push @opened_files, Texinfo::Common::output_files_opened_files(
$converter->output_files_information());
- handle_errors($converter, $error_count, \@opened_files);
+ handle_errors($converter_registrar, $error_count, \@opened_files);
my $converter_unclosed_files
= Texinfo::Common::output_files_unclosed_files(
$converter->output_files_information());