[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/Common.pm, tp/Texinfo/Convert/HTML.p
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/Common.pm, tp/Texinfo/Convert/HTML.pm, tp/Texinfo/Convert/PlainTexinfo.pm, tp/Texinfo/Convert/Text.pm, tp/Texinfo/Structuring.pm, tp/Texinfo/Transformations.pm: always use main XS file first, and add use Texinfo::XSLoader if used in the module. |
Date: |
Sun, 05 Nov 2023 05:53:02 -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 403894ff57 * tp/Texinfo/Common.pm, tp/Texinfo/Convert/HTML.pm,
tp/Texinfo/Convert/PlainTexinfo.pm, tp/Texinfo/Convert/Text.pm,
tp/Texinfo/Structuring.pm, tp/Texinfo/Transformations.pm: always use main XS
file first, and add use Texinfo::XSLoader if used in the module.
403894ff57 is described below
commit 403894ff57d87dd86411f15105404197f3183d34
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Nov 5 11:52:51 2023 +0100
* tp/Texinfo/Common.pm, tp/Texinfo/Convert/HTML.pm,
tp/Texinfo/Convert/PlainTexinfo.pm, tp/Texinfo/Convert/Text.pm,
tp/Texinfo/Structuring.pm, tp/Texinfo/Transformations.pm: always use
main XS file first, and add use Texinfo::XSLoader if used in the
module.
* tp/Texinfo/Convert/ConvertXS.pm: only load if TEXINFO_XS_CONVERT is
set. From Gavin.
* tp/Texinfo/StructTransf.pm: only load if TEXINFO_XS_PARSER is not
unset and TEXINFO_XS_STRUCTURE is not set to 0. From Gavin.
* tp/Texinfo/Common.pm ($XS_structuring, import),
tp/Texinfo/Structuring.pm ($XS_structuring, import),
tp/Texinfo/Transformations.pm ($XS_structuring, import): load modules
only if TEXINFO_XS_PARSER is not unset and TEXINFO_XS_STRUCTURE is not
set to 0. From Gavin.
* tp/t/test_utils.pl ($XS_structuring, test), tp/texi2any.pl: set
no_build argument to parse_texi_* and consider that error messages are
done in XS if TEXINFO_XS_PARSER is not unset and TEXINFO_XS_STRUCTURE
is not set to 0. Based on Gavin idea.
* tp/Texinfo/Convert/Text.pm ($XS_convert, _convert_tree_with_XS)
(convert_to_text, output): call perl code preparing for XS call and
calling XS functions only if TEXINFO_XS_CONVERT is set.
---
ChangeLog | 29 +++++++++++++++++++++++++++++
tp/Texinfo/Common.pm | 22 ++++++++++++++++------
tp/Texinfo/Convert/ConvertXS.pm | 24 +++++++++++++++---------
tp/Texinfo/Convert/HTML.pm | 2 ++
tp/Texinfo/Convert/PlainTexinfo.pm | 18 +++++++++---------
tp/Texinfo/Convert/Text.pm | 18 +++++++++---------
tp/Texinfo/StructTransf.pm | 24 +++++++++++++++---------
tp/Texinfo/Structuring.pm | 17 +++++++++++++----
tp/Texinfo/Transformations.pm | 16 +++++++++++++---
tp/t/test_utils.pl | 24 ++++++++++++++----------
tp/texi2any.pl | 15 +++++++++------
11 files changed, 144 insertions(+), 65 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 1c7d076cc1..803281b6db 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,32 @@
+2023-11-05 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Common.pm, tp/Texinfo/Convert/HTML.pm,
+ tp/Texinfo/Convert/PlainTexinfo.pm, tp/Texinfo/Convert/Text.pm,
+ tp/Texinfo/Structuring.pm, tp/Texinfo/Transformations.pm: always use
+ main XS file first, and add use Texinfo::XSLoader if used in the
+ module.
+
+ * tp/Texinfo/Convert/ConvertXS.pm: only load if TEXINFO_XS_CONVERT is
+ set. From Gavin.
+
+ * tp/Texinfo/StructTransf.pm: only load if TEXINFO_XS_PARSER is not
+ unset and TEXINFO_XS_STRUCTURE is not set to 0. From Gavin.
+
+ * tp/Texinfo/Common.pm ($XS_structuring, import),
+ tp/Texinfo/Structuring.pm ($XS_structuring, import),
+ tp/Texinfo/Transformations.pm ($XS_structuring, import): load modules
+ only if TEXINFO_XS_PARSER is not unset and TEXINFO_XS_STRUCTURE is not
+ set to 0. From Gavin.
+
+ * tp/t/test_utils.pl ($XS_structuring, test), tp/texi2any.pl: set
+ no_build argument to parse_texi_* and consider that error messages are
+ done in XS if TEXINFO_XS_PARSER is not unset and TEXINFO_XS_STRUCTURE
+ is not set to 0. Based on Gavin idea.
+
+ * tp/Texinfo/Convert/Text.pm ($XS_convert, _convert_tree_with_XS)
+ (convert_to_text, output): call perl code preparing for XS call and
+ calling XS functions only if TEXINFO_XS_CONVERT is set.
+
2023-11-04 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/main/utils.c, tp/Texinfo/XS/main/converter_types.h:
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index 80cb1874ef..27bb272996 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -43,14 +43,16 @@ use Carp qw(cluck confess);
use Locale::Messages;
-use Texinfo::Documentlanguages;
-use Texinfo::Commands;
-use Texinfo::Options;
-
# FIXME do we really want XS in that file? Move to
# Structuring.pm?
use Texinfo::StructTransf;
+use Texinfo::XSLoader;
+
+use Texinfo::Documentlanguages;
+use Texinfo::Commands;
+use Texinfo::Options;
+
require Exporter;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
@ISA = qw(Exporter);
@@ -78,6 +80,14 @@ __ __p
$VERSION = '7.1dev';
+# XS parser and not explicitely unset
+my $XS_structuring = ((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')
+ and (not defined($ENV{TEXINFO_XS_STRUCTURE})
+ or $ENV{TEXINFO_XS_STRUCTURE} ne '0'));
+
our %XS_overrides = (
"Texinfo::Common::set_document_options"
=> "Texinfo::StructTransf::set_document_options",
@@ -92,13 +102,13 @@ our %XS_overrides = (
"Texinfo::Common::protect_comma_in_tree"
=> "Texinfo::StructTransf::protect_comma_in_tree",
"Texinfo::Common::protect_node_after_label_in_tree"
- => "Texinfo::StructTransf::protect_node_after_label_in_tree"
+ => "Texinfo::StructTransf::protect_node_after_label_in_tree",
);
our $module_loaded = 0;
sub import {
if (!$module_loaded) {
- if (!defined $ENV{TEXINFO_XS_PARSER} or $ENV{TEXINFO_XS_PARSER} eq '1') {
+ if ($XS_structuring) {
for my $sub (keys %XS_overrides) {
Texinfo::XSLoader::override ($sub, $XS_overrides{$sub});
}
diff --git a/tp/Texinfo/Convert/ConvertXS.pm b/tp/Texinfo/Convert/ConvertXS.pm
index 6ed1492359..9a875ad511 100644
--- a/tp/Texinfo/Convert/ConvertXS.pm
+++ b/tp/Texinfo/Convert/ConvertXS.pm
@@ -27,15 +27,21 @@ our $VERSION = '7.1dev';
use Texinfo::XSLoader;
BEGIN {
- Texinfo::XSLoader::init (
- "Texinfo::Convert::ConvertXS",
- "Texinfo::Convert::ConvertXS",
- "ConvertXS",
- undef,
- 0,
- undef,
- undef,
- );
+ my $XS_convert = 0;
+ $XS_convert = 1 if (defined $ENV{TEXINFO_XS_CONVERT}
+ and $ENV{TEXINFO_XS_CONVERT} eq '1');
+
+ if ($XS_convert) {
+ Texinfo::XSLoader::init (
+ "Texinfo::Convert::ConvertXS",
+ "Texinfo::Convert::ConvertXS",
+ "ConvertXS",
+ undef,
+ 0,
+ undef,
+ undef,
+ );
+ }
}
# NB Don't add more functions down here, because this can cause an error
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 68859caf6f..aa382b1b2f 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -61,6 +61,8 @@ use charnames ();
use Texinfo::Convert::ConvertXS;
+use Texinfo::XSLoader;
+
use Texinfo::Commands;
use Texinfo::Common;
use Texinfo::Config;
diff --git a/tp/Texinfo/Convert/PlainTexinfo.pm
b/tp/Texinfo/Convert/PlainTexinfo.pm
index a03c219ccc..cfca126e8b 100644
--- a/tp/Texinfo/Convert/PlainTexinfo.pm
+++ b/tp/Texinfo/Convert/PlainTexinfo.pm
@@ -27,6 +27,8 @@ use strict;
use Texinfo::Convert::ConvertXS;
+use Texinfo::XSLoader;
+
use Texinfo::Convert::Texinfo qw(convert_to_texinfo);
use Texinfo::Convert::Converter;
@@ -35,11 +37,14 @@ use vars qw($VERSION @ISA);
$VERSION = '7.1dev';
+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 (defined $ENV{TEXINFO_XS_CONVERT}
- and $ENV{TEXINFO_XS_CONVERT} eq '1') {
+ if ($XS_convert) {
# We do not simply override, we must check at runtime
# that the document tree was stored by the XS parser.
Texinfo::XSLoader::override(
@@ -66,13 +71,8 @@ sub converter_defaults($$)
return %defaults;
}
-# This is used if the document is available for XS, but XS is not
-# used (most likely $TEXINFO_XS_CONVERT is 0).
sub _convert_tree_with_XS($)
{
- my $root = shift;
-
- return convert_to_texinfo($root);
}
sub convert_tree($$)
@@ -80,7 +80,7 @@ sub convert_tree($$)
my $self = shift;
my $root = shift;
- if (defined($root->{'tree_document_descriptor'})) {
+ if ($XS_convert and defined($root->{'tree_document_descriptor'})) {
return _convert_tree_with_XS($root);
}
@@ -102,7 +102,7 @@ sub convert($$)
my $root = $document->tree();
- if (defined($document->document_descriptor())) {
+ if ($XS_convert and defined($document->document_descriptor())) {
return _convert_tree_with_XS($root);
}
diff --git a/tp/Texinfo/Convert/Text.pm b/tp/Texinfo/Convert/Text.pm
index 526641dcc3..1c687bc2fd 100644
--- a/tp/Texinfo/Convert/Text.pm
+++ b/tp/Texinfo/Convert/Text.pm
@@ -33,6 +33,8 @@ use Encode qw(decode);
use Texinfo::Convert::ConvertXS;
+use Texinfo::XSLoader;
+
use Texinfo::Commands;
use Texinfo::Common;
use Texinfo::Convert::Unicode;
@@ -55,11 +57,14 @@ use vars qw($VERSION @ISA @EXPORT_OK %EXPORT_TAGS);
$VERSION = '7.1dev';
+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 (defined $ENV{TEXINFO_XS_CONVERT}
- and $ENV{TEXINFO_XS_CONVERT} eq '1') {
+ if ($XS_convert) {
# We do not simply override, we must check at runtime
# that the document tree was stored by the XS parser.
Texinfo::XSLoader::override(
@@ -460,11 +465,6 @@ sub encode_text_options($)
# used (most likely $TEXINFO_XS_CONVERT is 0).
sub _convert_tree_with_XS($$;$)
{
- my $encoded_options = shift;
- my $root = shift;
- my $options = shift;
-
- return _convert($root, $options);
}
sub convert_to_text($;$)
@@ -492,7 +492,7 @@ sub convert_to_text($;$)
}
# Interface with XS converter.
- if (defined($root->{'tree_document_descriptor'})) {
+ if ($XS_convert and defined($root->{'tree_document_descriptor'})) {
my $encoded_options = encode_text_options($options);
my $XS_result = _convert_tree_with_XS($encoded_options, $root, $options);
if (defined ($XS_result)) {
@@ -1001,7 +1001,7 @@ sub output($$)
my $result;
# Interface with XS converter.
- if (defined($root->{'tree_document_descriptor'})) {
+ if ($XS_convert and defined($root->{'tree_document_descriptor'})) {
my $encoded_options = encode_text_options($self);
my $XS_result = _convert_tree_with_XS($encoded_options, $root, $self);
if (defined ($XS_result)) {
diff --git a/tp/Texinfo/StructTransf.pm b/tp/Texinfo/StructTransf.pm
index 24e8ded854..193aae65e7 100644
--- a/tp/Texinfo/StructTransf.pm
+++ b/tp/Texinfo/StructTransf.pm
@@ -27,15 +27,21 @@ our $VERSION = '7.1dev';
use Texinfo::XSLoader;
BEGIN {
- Texinfo::XSLoader::init (
- "Texinfo::StructTransf",
- "Texinfo::StructTransf",
- "StructuringTransfo",
- undef,
- 0,
- undef,
- undef,
- );
+ 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 (
+ "Texinfo::StructTransf",
+ "Texinfo::StructTransf",
+ "StructuringTransfo",
+ undef,
+ 0,
+ undef,
+ undef,
+ );
+ }
}
# NB Don't add more functions down here, because this can cause an error
diff --git a/tp/Texinfo/Structuring.pm b/tp/Texinfo/Structuring.pm
index d21c4b67de..39ba71b75b 100644
--- a/tp/Texinfo/Structuring.pm
+++ b/tp/Texinfo/Structuring.pm
@@ -39,6 +39,10 @@ use Carp qw(cluck confess);
use Unicode::Normalize;
+use Texinfo::StructTransf;
+
+use Texinfo::XSLoader;
+
# for %root_commands
use Texinfo::Commands;
use Texinfo::Common;
@@ -53,8 +57,6 @@ use Texinfo::Convert::NodeNameNormalization;
# for new_master_menu translations
use Texinfo::Translations;
-use Texinfo::StructTransf;
-
require Exporter;
use vars qw($VERSION @ISA @EXPORT_OK %EXPORT_TAGS);
@ISA = qw(Exporter);
@@ -82,6 +84,14 @@ use vars qw($VERSION @ISA @EXPORT_OK %EXPORT_TAGS);
$VERSION = '7.1dev';
+# XS parser and not explicitely unset
+my $XS_structuring = ((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')
+ and (not defined($ENV{TEXINFO_XS_STRUCTURE})
+ or $ENV{TEXINFO_XS_STRUCTURE} ne '0'));
+
our %XS_overrides = (
"Texinfo::Structuring::rebuild_document"
=> "Texinfo::StructTransf::rebuild_document",
@@ -124,8 +134,7 @@ our %XS_overrides = (
our $module_loaded = 0;
sub import {
if (!$module_loaded) {
- if (!defined $ENV{TEXINFO_XS_PARSER}
- or $ENV{TEXINFO_XS_PARSER} ne '0') {
+ if ($XS_structuring) {
for my $sub (keys %XS_overrides) {
Texinfo::XSLoader::override ($sub, $XS_overrides{$sub});
}
diff --git a/tp/Texinfo/Transformations.pm b/tp/Texinfo/Transformations.pm
index 8bf237d2c8..b3677b54bb 100644
--- a/tp/Texinfo/Transformations.pm
+++ b/tp/Texinfo/Transformations.pm
@@ -30,14 +30,16 @@ use strict;
use Carp qw(cluck);
+use Texinfo::StructTransf;
+
+use Texinfo::XSLoader;
+
use Texinfo::Commands;
use Texinfo::Common;
use Texinfo::Translations;
use Texinfo::Structuring;
use Texinfo::Document;
-use Texinfo::StructTransf;
-
require Exporter;
use vars qw($VERSION @ISA @EXPORT_OK %EXPORT_TAGS);
@ISA = qw(Exporter);
@@ -51,6 +53,14 @@ reference_to_arg_in_tree
$VERSION = '7.1dev';
+# XS parser and not explicitely unset
+my $XS_structuring = ((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')
+ and (not defined($ENV{TEXINFO_XS_STRUCTURE})
+ or $ENV{TEXINFO_XS_STRUCTURE} ne '0'));
+
our %XS_overrides = (
"Texinfo::Transformations::fill_gaps_in_sectioning"
=> "Texinfo::StructTransf::fill_gaps_in_sectioning",
@@ -73,7 +83,7 @@ our %XS_overrides = (
our $module_loaded = 0;
sub import {
if (!$module_loaded) {
- if (!defined $ENV{TEXINFO_XS_PARSER} or $ENV{TEXINFO_XS_PARSER} eq '1') {
+ if ($XS_structuring) {
for my $sub (keys %XS_overrides) {
Texinfo::XSLoader::override ($sub, $XS_overrides{$sub});
}
diff --git a/tp/t/test_utils.pl b/tp/t/test_utils.pl
index f1fd7f9112..5ff668c424 100644
--- a/tp/t/test_utils.pl
+++ b/tp/t/test_utils.pl
@@ -109,6 +109,14 @@ Texinfo::Translations::configure($localesdir);
Locale::Messages::bindtextdomain('texinfo', $localesdir);
+# XS parser and not explicitely unset
+my $XS_structuring = ((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')
+ and (not defined($ENV{TEXINFO_XS_STRUCTURE})
+ or $ENV{TEXINFO_XS_STRUCTURE} ne '0'));
+
my $generated_texis_dir = 't_texis';
my $input_files_dir = $srcdir."t/input_files/";
@@ -745,11 +753,6 @@ sub output_preamble_postamble_latex($$)
}
}
-my $with_XS = ((not defined($ENV{TEXINFO_XS})
- or $ENV{TEXINFO_XS} ne 'omit')
- and (!defined $ENV{TEXINFO_XS_PARSER}
- or $ENV{TEXINFO_XS_PARSER} eq '1'));
-
my %tested_transformations;
# Run a single test case. Each test case is an array
@@ -958,10 +961,10 @@ sub test($$)
if (!$test_file) {
if ($full_document) {
print STDERR " TEST FULL $test_name\n" if ($self->{'DEBUG'});
- $document = $parser->parse_texi_text($test_text, undef, $with_XS);
+ $document = $parser->parse_texi_text($test_text, undef, $XS_structuring);
} else {
print STDERR " TEST $test_name\n" if ($self->{'DEBUG'});
- $document = $parser->parse_texi_piece($test_text, undef, $with_XS);
+ $document = $parser->parse_texi_piece($test_text, undef,
$XS_structuring);
if (defined($test_input_file_name)) {
warn "ERROR: $self->{'name'}: $test_name: piece of texi with a file
name\n";
}
@@ -975,7 +978,7 @@ sub test($$)
}
} else {
print STDERR " TEST $test_name ($test_file)\n" if ($self->{'DEBUG'});
- $document = $parser->parse_texi_file($test_file, $with_XS);
+ $document = $parser->parse_texi_file($test_file, $XS_structuring);
}
my $tree = $document->tree();
my $registrar = $parser->registered_errors();
@@ -1080,12 +1083,13 @@ sub test($$)
}
}
}
-
+ # could be in a if !$XS_structuring, but the function should not be
+ # overriden already in that case
$document = Texinfo::Structuring::rebuild_document($document);
# should not actually be useful, as the same element should be reused.
$tree = $document->tree();
- if ($with_XS) {
+ if ($XS_structuring) {
foreach my $error (@{$document->{'errors'}}) {
$registrar->add_formatted_message($error);
}
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index de51d7b96a..c12e78a01d 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -1393,10 +1393,13 @@ die _encode_message(
.sprintf(__("Try `%s --help' for more information.\n"), $real_command_name))
unless (scalar(@input_files) >= 1);
-my $with_XS = ((not defined($ENV{TEXINFO_XS})
- or $ENV{TEXINFO_XS} ne 'omit')
- and (!defined $ENV{TEXINFO_XS_PARSER}
- or $ENV{TEXINFO_XS_PARSER} eq '1'));
+# XS parser and not explicitely unset
+my $XS_structuring = ((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')
+ and (not defined($ENV{TEXINFO_XS_STRUCTURE})
+ or $ENV{TEXINFO_XS_STRUCTURE} ne '0'));
my $file_number = -1;
my @opened_files = ();
@@ -1449,7 +1452,7 @@ while(@input_files) {
@prepended_include_directories;
my $parser = Texinfo::Parser::parser($parser_file_options);
- my $document = $parser->parse_texi_file($input_file_name, $with_XS);
+ my $document = $parser->parse_texi_file($input_file_name, $XS_structuring);
my $tree;
if (defined($document)) {
$tree = $document->tree();
@@ -1638,7 +1641,7 @@ while(@input_files) {
$document = Texinfo::Structuring::rebuild_document($document);
- if ($with_XS) {
+ if ($XS_structuring) {
foreach my $error (@{$document->{'errors'}}) {
$registrar->add_formatted_message($error);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/Common.pm, tp/Texinfo/Convert/HTML.pm, tp/Texinfo/Convert/PlainTexinfo.pm, tp/Texinfo/Convert/Text.pm, tp/Texinfo/Structuring.pm, tp/Texinfo/Transformations.pm: always use main XS file first, and add use Texinfo::XSLoader if used in the module.,
Patrice Dumas <=