[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Wed, 24 Jan 2024 17:51:16 -0500 (EST) |
branch: master
commit 86832f51c206dae4adaeccd2426446d90a94983d
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Wed Jan 24 23:50:30 2024 +0100
* tp/Texinfo/XSLoader.pm (init): if fallback module is not set, return
undef instead of calling die. For many XS modules there is no perl
module fallback, instead, if the perl methods are used instead of the
XS methods the output should be fine. For the other cases, the return
value of init should be checked.
* tp/Texinfo/Convert/ConvertXS.pm ($XS_package, BEGIN),
tp/Texinfo/Convert/Converter.pm (get_conf),
tp/Texinfo/Convert/PlainTexinfo.pm (convert_tree),
tp/Texinfo/Convert/Text.pm (convert_to_text, output),
tp/Texinfo/StructTransfXS.pm ($XS_package, BEGIN),
tp/Texinfo/Transformations.pm (_new_node): set $XS_package with
Texinfo::XSLoader::init return value for ConvertXS and StructTransfXS,
and check the value in codes that need to know if the module was
loaded, for instance if th eperl functions that are not overriden
should not be called.
* tp/Texinfo/Document.pm (%XS_overrides): remove
remove_document_descriptor override, it is not defined in perl.
---
ChangeLog | 22 ++++++++++++++++++++++
tp/Texinfo/Common.pm | 7 ++++---
tp/Texinfo/Convert/ConvertXS.pm | 4 +++-
tp/Texinfo/Convert/Converter.pm | 4 +++-
tp/Texinfo/Convert/PlainTexinfo.pm | 3 ++-
tp/Texinfo/Convert/Text.pm | 6 ++++--
tp/Texinfo/Document.pm | 2 --
tp/Texinfo/StructTransfXS.pm | 4 +++-
tp/Texinfo/Transformations.pm | 2 +-
tp/Texinfo/XSLoader.pm | 13 ++++++++++---
10 files changed, 52 insertions(+), 15 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3fbed52d56..54f74cc105 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -42,6 +42,28 @@
Set 'encoding_disabled' on the nested count context and pass
result to _stream_output instead of _stream_output_encoded.
+2024-01-23 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XSLoader.pm (init): if fallback module is not set, return
+ undef instead of calling die. For many XS modules there is no perl
+ module fallback, instead, if the perl methods are used instead of the
+ XS methods the output should be fine. For the other cases, the return
+ value of init should be checked.
+
+ * tp/Texinfo/Convert/ConvertXS.pm ($XS_package, BEGIN),
+ tp/Texinfo/Convert/Converter.pm (get_conf),
+ tp/Texinfo/Convert/PlainTexinfo.pm (convert_tree),
+ tp/Texinfo/Convert/Text.pm (convert_to_text, output),
+ tp/Texinfo/StructTransfXS.pm ($XS_package, BEGIN),
+ tp/Texinfo/Transformations.pm (_new_node): set $XS_package with
+ Texinfo::XSLoader::init return value for ConvertXS and StructTransfXS,
+ and check the value in codes that need to know if the module was
+ loaded, for instance if th eperl functions that are not overriden
+ should not be called.
+
+ * tp/Texinfo/Document.pm (%XS_overrides): remove
+ remove_document_descriptor override, it is not defined in perl.
+
2024-01-23 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/Convert/ConvertXS.pm (BEGIN),
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index d4d5e74c2c..8c2c7ddb21 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -2507,9 +2507,10 @@ sub get_label_element($)
return undef;
}
-# 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
+# non-XS does nothing and should not be called in most cases as the
+# caller verifies that there is a document descriptor; XS version
+# registers options in XS document.
+# NOTE It would have been more logical for this function to be in
# Texinfo::Config, but we do not want to load any XS in Texinfo::Config.
sub set_document_options($$)
{
diff --git a/tp/Texinfo/Convert/ConvertXS.pm b/tp/Texinfo/Convert/ConvertXS.pm
index 7eaa8db671..ace45d7a77 100644
--- a/tp/Texinfo/Convert/ConvertXS.pm
+++ b/tp/Texinfo/Convert/ConvertXS.pm
@@ -26,6 +26,8 @@ our $VERSION = '7.1dev';
use Texinfo::XSLoader;
+our $XS_package;
+
BEGIN {
# XS parser and not explicitely unset
my $XS_structuring = ((not defined($ENV{TEXINFO_XS})
@@ -41,7 +43,7 @@ BEGIN {
and $ENV{TEXINFO_XS_CONVERT} eq '1');
if ($XS_convert) {
- Texinfo::XSLoader::init (
+ $XS_package = Texinfo::XSLoader::init (
"Texinfo::Convert::ConvertXS",
undef,
"ConvertXS",
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index 3c2a73dca7..5648706a77 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -712,7 +712,9 @@ sub get_conf($$)
#return undef;
}
- if ($self->{'converter_descriptor'} and $XS_convert) {
+ # Check that the package was loaded as we should only use perl if not.
+ if ($self->{'converter_descriptor'} and $XS_convert
+ and $Texinfo::Convert::ConvertXS::XS_package) {
my $result = _XS_get_conf($self, $conf);
return $result;
}
diff --git a/tp/Texinfo/Convert/PlainTexinfo.pm
b/tp/Texinfo/Convert/PlainTexinfo.pm
index c53a6dceb4..5f9d349296 100644
--- a/tp/Texinfo/Convert/PlainTexinfo.pm
+++ b/tp/Texinfo/Convert/PlainTexinfo.pm
@@ -89,7 +89,8 @@ sub convert_tree($$)
my $self = shift;
my $root = shift;
- if ($XS_convert and defined($root->{'tree_document_descriptor'})) {
+ if ($XS_convert and defined($root->{'tree_document_descriptor'})
+ and $Texinfo::Convert::ConvertXS::XS_package) {
return _convert_tree_with_XS($root);
}
diff --git a/tp/Texinfo/Convert/Text.pm b/tp/Texinfo/Convert/Text.pm
index 8d4271b701..748854a3b4 100644
--- a/tp/Texinfo/Convert/Text.pm
+++ b/tp/Texinfo/Convert/Text.pm
@@ -848,7 +848,8 @@ sub convert_to_text($;$)
bless $options, "Texinfo::Convert::Text";
# Interface with XS converter.
- if ($XS_convert and defined($root->{'tree_document_descriptor'})) {
+ if ($XS_convert and defined($root->{'tree_document_descriptor'})
+ and $Texinfo::Convert::ConvertXS::XS_package) {
return _convert_tree_with_XS($options, $root);
}
@@ -1032,7 +1033,8 @@ sub output($$)
my $result;
# Interface with XS converter.
- if ($XS_convert and defined($root->{'tree_document_descriptor'})) {
+ if ($XS_convert and defined($root->{'tree_document_descriptor'})
+ and $Texinfo::Convert::ConvertXS::XS_package) {
$result = _convert_tree_with_XS($self, $root);
} else {
$result = _convert($self, $root);
diff --git a/tp/Texinfo/Document.pm b/tp/Texinfo/Document.pm
index 69088d6896..d8c65805b9 100644
--- a/tp/Texinfo/Document.pm
+++ b/tp/Texinfo/Document.pm
@@ -50,8 +50,6 @@ our %XS_overrides = (
=> "Texinfo::DocumentXS::remove_document",
"Texinfo::Document::clear_document_errors"
=> "Texinfo::DocumentXS::clear_document_errors",
- "Texinfo::Document::remove_document_descriptor"
- => "Texinfo::DocumentXS::remove_document_descriptor",
"Texinfo::Document::_XS_set_document_global_info",
=> "Texinfo::DocumentXS::set_document_global_info",
);
diff --git a/tp/Texinfo/StructTransfXS.pm b/tp/Texinfo/StructTransfXS.pm
index 62ed90b28f..230d03b241 100644
--- a/tp/Texinfo/StructTransfXS.pm
+++ b/tp/Texinfo/StructTransfXS.pm
@@ -23,13 +23,15 @@ our $VERSION = '7.1dev';
use Texinfo::XSLoader;
+our $XS_package;
+
BEGIN {
my $XS_structuring = ((not defined($ENV{TEXINFO_XS_PARSER})
or $ENV{TEXINFO_XS_PARSER} eq '1')
and (not defined($ENV{TEXINFO_XS_STRUCTURE})
or $ENV{TEXINFO_XS_STRUCTURE} ne '0'));
if ($XS_structuring) {
- Texinfo::XSLoader::init (
+ $XS_package = Texinfo::XSLoader::init (
"Texinfo::StructTransfXS",
undef,
"StructuringTransfoXS",
diff --git a/tp/Texinfo/Transformations.pm b/tp/Texinfo/Transformations.pm
index d53694285f..451eb167ac 100644
--- a/tp/Texinfo/Transformations.pm
+++ b/tp/Texinfo/Transformations.pm
@@ -291,7 +291,7 @@ sub _new_node($$;$$)
my $registrar = shift;
my $customization_information = shift;
- if ($XS_structuring) {
+ if ($XS_structuring and $Texinfo::StructTransfXS::XS_package) {
# If there were XS overrides for all the transformations, they would
# necessarily fail, so treat as a bug even though it does not matter
# with missing overrides, as seen just below.
diff --git a/tp/Texinfo/XSLoader.pm b/tp/Texinfo/XSLoader.pm
index dbe5b94364..ad613c02d9 100644
--- a/tp/Texinfo/XSLoader.pm
+++ b/tp/Texinfo/XSLoader.pm
@@ -233,10 +233,17 @@ sub init {
warn "falling back to pure Perl module $fallback_module\n";
}
}
+ # if there is no fallback and the perl methods that have not been overriden
+ # should not be called, the return value should be made available such
+ # that code that could have called the corresponding perl methods can
+ # chenck if the return value is not set.
if (!defined $fallback_module) {
- warn "no fallback module for $module\n";
- die "set/unset the TEXINFO_XS, TEXINFO_XS_PARSER and TEXINFO_XS_CONVERT "
- ."environment variables to use the pure Perl modules\n";
+ if ($TEXINFO_XS eq 'warn' or $TEXINFO_XS eq 'debug') {
+ warn "no fallback module for $module\n";
+ }
+ return undef;
+ #die "set/unset the TEXINFO_XS, TEXINFO_XS_PARSER and TEXINFO_XS_CONVERT "
+ # ."environment variables to use the pure Perl modules\n";
}
# Fall back to using the Perl code.