[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Sun, 19 Nov 2023 06:02:17 -0500 (EST) |
branch: master
commit c07df0d6c2d04be3e938bb54721cee45acca1f85
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Nov 19 11:30:45 2023 +0100
* tp/Texinfo/Document.pm ($XS_parser, $XS_structuring, %XS_overrides)
(%XS_structure_overrides, import): use hashes for XS overrides. Do
not load rebuild_document and rebuild_tree if XS is not used for
structure.
---
ChangeLog | 7 ++++++
tp/Texinfo/Document.pm | 61 ++++++++++++++++++++++++++++++++------------------
2 files changed, 46 insertions(+), 22 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 79590dcd69..96a115d12f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,13 @@
* tp/texi2any.supp: Add variant suppression specification
for setenv error.
+2023-11-19 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Document.pm ($XS_parser, $XS_structuring, %XS_overrides)
+ (%XS_structure_overrides, import): use hashes for XS overrides. Do
+ not load rebuild_document and rebuild_tree if XS is not used for
+ structure.
+
2023-11-19 Patrice Dumas <pertusus@free.fr>
Explicit void for argument of C functions. Gavin report.
diff --git a/tp/Texinfo/Document.pm b/tp/Texinfo/Document.pm
index ae9d9b8cc9..58d156b5d3 100644
--- a/tp/Texinfo/Document.pm
+++ b/tp/Texinfo/Document.pm
@@ -32,29 +32,48 @@ use Texinfo::XSLoader;
use Texinfo::Common;
+our $VERSION = '7.1dev';
+
+my $XS_parser = ((not defined($ENV{TEXINFO_XS})
+ or $ENV{TEXINFO_XS} ne 'omit')
+ and (not defined($ENV{TEXINFO_XS_PARSER})
+ or $ENV{TEXINFO_XS_PARSER} eq '1'));
+
+# XS parser and not explicitely unset
+my $XS_structuring = ($XS_parser
+ and (not defined($ENV{TEXINFO_XS_STRUCTURE})
+ or $ENV{TEXINFO_XS_STRUCTURE} ne '0'));
+
+# needed by parser
+our %XS_overrides = (
+ "Texinfo::Document::remove_document"
+ => "Texinfo::DocumentXS::remove_document",
+ "Texinfo::Document::clear_document_errors"
+ => "Texinfo::DocumentXS::clear_document_errors",
+ "Texinfo::Document::remove_document_descriptor"
+ => "Texinfo::DocumentXS::remove_document_descriptor",
+);
+
+# needed by structure code
+our %XS_structure_overrides = (
+ "Texinfo::Document::rebuild_document"
+ => "Texinfo::DocumentXS::rebuild_document",
+ "Texinfo::Document::rebuild_tree"
+ => "Texinfo::DocumentXS::rebuild_tree",
+);
+
our $module_loaded = 0;
sub import {
if (!$module_loaded) {
- if (!defined $ENV{TEXINFO_XS_PARSER}
- or $ENV{TEXINFO_XS_PARSER} eq '1') {
- Texinfo::XSLoader::override(
- "Texinfo::Document::remove_document",
- "Texinfo::DocumentXS::remove_document");
- Texinfo::XSLoader::override(
- "Texinfo::Document::rebuild_document",
- "Texinfo::DocumentXS::rebuild_document");
- Texinfo::XSLoader::override(
- "Texinfo::Document::rebuild_tree",
- "Texinfo::DocumentXS::rebuild_tree");
- Texinfo::XSLoader::override(
- "Texinfo::Document::remove_document_descriptor",
- "Texinfo::DocumentXS::remove_document_descriptor");
- Texinfo::XSLoader::override(
- "Texinfo::Document::clear_document_errors",
- "Texinfo::DocumentXS::clear_document_errors");
- Texinfo::XSLoader::override(
- "Texinfo::Document::set_document_options",
- "Texinfo::DocumentXS::set_document_options");
+ if ($XS_parser) {
+ for my $sub (keys %XS_overrides) {
+ Texinfo::XSLoader::override ($sub, $XS_overrides{$sub});
+ }
+ if ($XS_structuring) {
+ for my $sub (keys %XS_structure_overrides) {
+ Texinfo::XSLoader::override ($sub, $XS_structure_overrides{$sub});
+ }
+ }
}
$module_loaded = 1;
}
@@ -62,8 +81,6 @@ sub import {
goto &Exporter::import;
}
-our $VERSION = '7.1dev';
-
sub register
{
my $tree = shift;