texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: * tp/Texinfo/XSLoader.pm (XS_parser_enabled, XS_s


From: Gavin D. Smith
Subject: branch master updated: * tp/Texinfo/XSLoader.pm (XS_parser_enabled, XS_structuring_enabled) (XS_convert_enabled): New functions, in order to avoid repeating similar blocks of code checking environment variables.
Date: Sat, 06 Apr 2024 08:27:37 -0400

This is an automated email from the git hooks/post-receive script.

gavin pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new ffea4ebb1e * tp/Texinfo/XSLoader.pm (XS_parser_enabled, 
XS_structuring_enabled) (XS_convert_enabled): New functions, in order to avoid 
repeating similar blocks of code checking environment variables.
ffea4ebb1e is described below

commit ffea4ebb1eac460afa9938365ae77c320f8e6dc4
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Sat Apr 6 13:25:29 2024 +0100

    * tp/Texinfo/XSLoader.pm (XS_parser_enabled, XS_structuring_enabled)
    (XS_convert_enabled): New functions, in order to avoid repeating
    similar blocks of code checking environment variables.
    
    * tp/Texinfo/Common.pm, tp/Texinfo/Convert/ConvertXS.pm,
    tp/Texinfo/Convert/Converter.pm, tp/Texinfo/Convert/HTML.pm,
    tp/Texinfo/Convert/PlainTexinfo.pm, tp/Texinfo/Convert/Texinfo.pm,
    tp/Texinfo/Convert/Text.pm, tp/Texinfo/Document.pm,
    tp/Texinfo/Indices.pm, tp/Texinfo/IndicesXS.pm, tp/Texinfo/Parser.pm,
    tp/Texinfo/StructTransfXS.pm, tp/Texinfo/Structuring.pm,
    tp/Texinfo/Transformations.pm, tp/t/automatic_nodes.t,
    tp/t/html_tests.t, tp/t/protect_character_in_texinfo.t,
    tp/t/test_utils.pl, tp/texi2any.pl: Use the new functions.
---
 ChangeLog                           | 16 ++++++++++++++++
 tp/Texinfo/Common.pm                |  8 +-------
 tp/Texinfo/Convert/ConvertXS.pm     | 15 +--------------
 tp/Texinfo/Convert/Converter.pm     | 14 +-------------
 tp/Texinfo/Convert/HTML.pm          | 14 +-------------
 tp/Texinfo/Convert/PlainTexinfo.pm  | 14 +-------------
 tp/Texinfo/Convert/Texinfo.pm       | 14 ++------------
 tp/Texinfo/Convert/Text.pm          | 14 +-------------
 tp/Texinfo/Document.pm              |  5 +----
 tp/Texinfo/Indices.pm               | 13 +------------
 tp/Texinfo/IndicesXS.pm             | 14 +-------------
 tp/Texinfo/Parser.pm                |  3 +--
 tp/Texinfo/StructTransfXS.pm        |  6 +-----
 tp/Texinfo/Structuring.pm           | 23 ++++++-----------------
 tp/Texinfo/Transformations.pm       |  8 +-------
 tp/Texinfo/XSLoader.pm              | 20 ++++++++++++++++++++
 tp/t/automatic_nodes.t              |  9 +++------
 tp/t/html_tests.t                   |  4 +---
 tp/t/protect_character_in_texinfo.t |  9 ++-------
 tp/t/test_utils.pl                  | 10 +++-------
 tp/texi2any.pl                      |  9 +++------
 21 files changed, 68 insertions(+), 174 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7575203169..4be3b8a9ee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2024-04-06  Gavin Smith <gavinsmith0123@gmail.com>
+
+       * tp/Texinfo/XSLoader.pm (XS_parser_enabled, XS_structuring_enabled)
+       (XS_convert_enabled): New functions, in order to avoid repeating
+       similar blocks of code checking environment variables.
+
+       * tp/Texinfo/Common.pm, tp/Texinfo/Convert/ConvertXS.pm,
+       tp/Texinfo/Convert/Converter.pm, tp/Texinfo/Convert/HTML.pm,
+       tp/Texinfo/Convert/PlainTexinfo.pm, tp/Texinfo/Convert/Texinfo.pm,
+       tp/Texinfo/Convert/Text.pm, tp/Texinfo/Document.pm,
+       tp/Texinfo/Indices.pm, tp/Texinfo/IndicesXS.pm, tp/Texinfo/Parser.pm,
+       tp/Texinfo/StructTransfXS.pm, tp/Texinfo/Structuring.pm,
+       tp/Texinfo/Transformations.pm, tp/t/automatic_nodes.t,
+       tp/t/html_tests.t, tp/t/protect_character_in_texinfo.t,
+       tp/t/test_utils.pl, tp/texi2any.pl: Use the new functions.
+
 2024-04-06  Patrice Dumas  <pertusus@free.fr>
 
        * doc/refcard/txivarcheck (read_refman), util/txicustomvars: get
diff --git a/tp/Texinfo/Common.pm b/tp/Texinfo/Common.pm
index 9cf589d937..ac61374f3f 100644
--- a/tp/Texinfo/Common.pm
+++ b/tp/Texinfo/Common.pm
@@ -81,13 +81,7 @@ __ __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'));
+my $XS_structuring = Texinfo::XSLoader::XS_structuring_enabled();
 
 our %XS_overrides = (
   "Texinfo::Common::set_document_options"
diff --git a/tp/Texinfo/Convert/ConvertXS.pm b/tp/Texinfo/Convert/ConvertXS.pm
index b5be8290d5..0a0faaf02b 100644
--- a/tp/Texinfo/Convert/ConvertXS.pm
+++ b/tp/Texinfo/Convert/ConvertXS.pm
@@ -29,20 +29,7 @@ use Texinfo::XSLoader;
 our $XS_package;
 
 BEGIN {
-  # 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 $XS_convert = 0;
-  $XS_convert = 1 if ($XS_structuring
-                      and defined $ENV{TEXINFO_XS_CONVERT}
-                      and $ENV{TEXINFO_XS_CONVERT} eq '1');
-
-  if ($XS_convert) {
+  if (Texinfo::XSLoader::XS_convert_enabled()) {
     $XS_package = Texinfo::XSLoader::init (
       "Texinfo::Convert::ConvertXS",
       undef,
diff --git a/tp/Texinfo/Convert/Converter.pm b/tp/Texinfo/Convert/Converter.pm
index dfa882c1eb..0b4bc05e4c 100644
--- a/tp/Texinfo/Convert/Converter.pm
+++ b/tp/Texinfo/Convert/Converter.pm
@@ -37,7 +37,6 @@ use Storable;
 use Carp qw(cluck confess);
 
 use Texinfo::Convert::ConvertXS;
-
 use Texinfo::XSLoader;
 
 use Texinfo::Options;
@@ -69,18 +68,7 @@ xml_accents
 
 $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'));
-
-my $XS_convert = 0;
-$XS_convert = 1 if ($XS_structuring
-                    and defined $ENV{TEXINFO_XS_CONVERT}
-                    and $ENV{TEXINFO_XS_CONVERT} eq '1');
+my $XS_convert = Texinfo::XSLoader::XS_convert_enabled();
 
 our $module_loaded = 0;
 
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 47f4e9f579..1cf6ddcd05 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -61,7 +61,6 @@ use Encode qw(find_encoding decode encode);
 use charnames ();
 
 use Texinfo::Convert::ConvertXS;
-
 use Texinfo::XSLoader;
 
 use Texinfo::Commands;
@@ -90,18 +89,7 @@ use vars qw($VERSION @ISA);
 
 $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'));
-
-my $XS_convert = 0;
-$XS_convert = 1 if ($XS_structuring
-                    and defined $ENV{TEXINFO_XS_CONVERT}
-                    and $ENV{TEXINFO_XS_CONVERT} eq '1');
+my $XS_convert = Texinfo::XSLoader::XS_convert_enabled();
 
 my %XS_overrides = (
   "Texinfo::Convert::HTML::_default_format_protect_text"
diff --git a/tp/Texinfo/Convert/PlainTexinfo.pm 
b/tp/Texinfo/Convert/PlainTexinfo.pm
index 46b349df69..b64a97cb80 100644
--- a/tp/Texinfo/Convert/PlainTexinfo.pm
+++ b/tp/Texinfo/Convert/PlainTexinfo.pm
@@ -26,7 +26,6 @@ use 5.00405;
 use strict;
 
 use Texinfo::Convert::ConvertXS;
-
 use Texinfo::XSLoader;
 
 use Texinfo::Convert::Texinfo qw(convert_to_texinfo);
@@ -37,18 +36,7 @@ use vars qw($VERSION @ISA);
 
 $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'));
-
-my $XS_convert = 0;
-$XS_convert = 1 if ($XS_structuring
-                    and defined $ENV{TEXINFO_XS_CONVERT}
-                    and $ENV{TEXINFO_XS_CONVERT} eq '1');
+my $XS_convert = Texinfo::XSLoader::XS_convert_enabled();
 
 our $module_loaded = 0;
 sub import {
diff --git a/tp/Texinfo/Convert/Texinfo.pm b/tp/Texinfo/Convert/Texinfo.pm
index 3613fbe5e6..bf9d58f99f 100644
--- a/tp/Texinfo/Convert/Texinfo.pm
+++ b/tp/Texinfo/Convert/Texinfo.pm
@@ -33,6 +33,7 @@ use if $] >= 5.014, re => '/a';
 use Carp qw(cluck confess);
 
 use Texinfo::Convert::ConvertXS;
+use Texinfo::XSLoader;
 
 # commands definitions
 use Texinfo::Commands;
@@ -53,18 +54,7 @@ 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'));
-
-my $XS_convert = 0;
-$XS_convert = 1 if ($XS_structuring
-                    and defined $ENV{TEXINFO_XS_CONVERT}
-                    and $ENV{TEXINFO_XS_CONVERT} eq '1');
+my $XS_convert = Texinfo::XSLoader::XS_convert_enabled();
 
 our $module_loaded = 0;
 sub import {
diff --git a/tp/Texinfo/Convert/Text.pm b/tp/Texinfo/Convert/Text.pm
index 060771b877..a882e067d0 100644
--- a/tp/Texinfo/Convert/Text.pm
+++ b/tp/Texinfo/Convert/Text.pm
@@ -32,7 +32,6 @@ use Carp qw(cluck carp confess);
 use Encode qw(decode);
 
 use Texinfo::Convert::ConvertXS;
-
 use Texinfo::XSLoader;
 
 use Texinfo::Commands;
@@ -58,18 +57,7 @@ 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'));
-
-my $XS_convert = 0;
-$XS_convert = 1 if ($XS_structuring
-                    and defined $ENV{TEXINFO_XS_CONVERT}
-                    and $ENV{TEXINFO_XS_CONVERT} eq '1');
+my $XS_convert = Texinfo::XSLoader::XS_convert_enabled();
 
 our $module_loaded = 0;
 sub import {
diff --git a/tp/Texinfo/Document.pm b/tp/Texinfo/Document.pm
index b5335dcfb6..85e67fbb56 100644
--- a/tp/Texinfo/Document.pm
+++ b/tp/Texinfo/Document.pm
@@ -36,10 +36,7 @@ use Texinfo::Report;
 
 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'));
+my $XS_parser = Texinfo::XSLoader::XS_parser_enabled();
 
 our %XS_overrides = (
   "Texinfo::Document::remove_document"
diff --git a/tp/Texinfo/Indices.pm b/tp/Texinfo/Indices.pm
index dc3004fd81..0f824d79c1 100644
--- a/tp/Texinfo/Indices.pm
+++ b/tp/Texinfo/Indices.pm
@@ -60,18 +60,7 @@ 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'));
-
-my $XS_convert = 0;
-$XS_convert = 1 if ($XS_structuring
-                    and defined $ENV{TEXINFO_XS_CONVERT}
-                    and $ENV{TEXINFO_XS_CONVERT} eq '1');
+my $XS_convert = Texinfo::XSLoader::XS_convert_enabled();
 
 # used in conversion only, and should only be loaded with XS converters
 my %XS_convert_overrides = (
diff --git a/tp/Texinfo/IndicesXS.pm b/tp/Texinfo/IndicesXS.pm
index 9dc21fe7c9..12f21b8149 100644
--- a/tp/Texinfo/IndicesXS.pm
+++ b/tp/Texinfo/IndicesXS.pm
@@ -24,19 +24,7 @@ our $VERSION = '7.1dev';
 use Texinfo::XSLoader;
 
 BEGIN {
-  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 $XS_convert = 0;
-  $XS_convert = 1 if ($XS_structuring
-                    and defined $ENV{TEXINFO_XS_CONVERT}
-                    and $ENV{TEXINFO_XS_CONVERT} eq '1');
-
-  if ($XS_convert) {
+  if (Texinfo::XSLoader::XS_convert_enabled()) {
     Texinfo::XSLoader::init (
       "Texinfo::IndicesXS",
       undef,
diff --git a/tp/Texinfo/Parser.pm b/tp/Texinfo/Parser.pm
index 7d60a147ed..57b9ca1f6f 100644
--- a/tp/Texinfo/Parser.pm
+++ b/tp/Texinfo/Parser.pm
@@ -26,8 +26,7 @@ use Texinfo::XSLoader;
 
 BEGIN {
   my $shared_library_name = "Parsetexi";
-  if (defined $ENV{TEXINFO_XS_PARSER}
-      and $ENV{TEXINFO_XS_PARSER} eq '0') {
+  if (!Texinfo::XSLoader::XS_parser_enabled()) {
     undef $shared_library_name;
   }
 
diff --git a/tp/Texinfo/StructTransfXS.pm b/tp/Texinfo/StructTransfXS.pm
index 1c0ad09617..ae81433e90 100644
--- a/tp/Texinfo/StructTransfXS.pm
+++ b/tp/Texinfo/StructTransfXS.pm
@@ -26,11 +26,7 @@ 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) {
+  if (Texinfo::XSLoader::XS_structuring_enabled()) {
     $XS_package = Texinfo::XSLoader::init (
       "Texinfo::StructTransfXS",
       undef,
diff --git a/tp/Texinfo/Structuring.pm b/tp/Texinfo/Structuring.pm
index efc4095057..1242c1c4cd 100644
--- a/tp/Texinfo/Structuring.pm
+++ b/tp/Texinfo/Structuring.pm
@@ -76,18 +76,7 @@ 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'));
-
-my $XS_convert = 0;
-$XS_convert = 1 if ($XS_structuring
-                    and defined $ENV{TEXINFO_XS_CONVERT}
-                    and $ENV{TEXINFO_XS_CONVERT} eq '1');
+my $XS_structuring = Texinfo::XSLoader::XS_structuring_enabled();
 
 my %XS_overrides = (
   "Texinfo::Structuring::associate_internal_references"
@@ -133,11 +122,11 @@ sub import {
         Texinfo::XSLoader::override ($sub, $XS_overrides{$sub});
       }
     }
-    if ($XS_convert) {
-      for my $sub (keys %XS_convert_overrides) {
-        Texinfo::XSLoader::override ($sub, $XS_convert_overrides{$sub});
-      }
-    }
+    #if ($XS_convert) {
+    #  for my $sub (keys %XS_convert_overrides) {
+    #    Texinfo::XSLoader::override ($sub, $XS_convert_overrides{$sub});
+    #  }
+    #}
     $module_loaded = 1;
   }
   # The usual import method
diff --git a/tp/Texinfo/Transformations.pm b/tp/Texinfo/Transformations.pm
index 5de81aa056..047a9ed13a 100644
--- a/tp/Texinfo/Transformations.pm
+++ b/tp/Texinfo/Transformations.pm
@@ -53,13 +53,7 @@ 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'));
+my $XS_structuring = Texinfo::XSLoader::XS_structuring_enabled();
 
 our %XS_overrides = (
   "Texinfo::Transformations::fill_gaps_in_sectioning"
diff --git a/tp/Texinfo/XSLoader.pm b/tp/Texinfo/XSLoader.pm
index 2d8cf6e5de..1967bb32ee 100644
--- a/tp/Texinfo/XSLoader.pm
+++ b/tp/Texinfo/XSLoader.pm
@@ -35,6 +35,26 @@ our $TEXINFO_XS;
 
 our $VERSION = '7.1dev';
 
+sub XS_parser_enabled {
+  return ((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'));
+}
+
+sub XS_structuring_enabled {
+  return (XS_parser_enabled()
+           and (not defined($ENV{TEXINFO_XS_STRUCTURE})
+                or $ENV{TEXINFO_XS_STRUCTURE} ne '0'));
+}
+
+sub XS_convert_enabled {
+  return (XS_structuring_enabled()
+            and defined $ENV{TEXINFO_XS_CONVERT}
+            and $ENV{TEXINFO_XS_CONVERT} eq '1');
+}
+
+
 our $disable_XS;
 
 # For verbose information about what's being done
diff --git a/tp/t/automatic_nodes.t b/tp/t/automatic_nodes.t
index 389bf32e5c..d89e14974b 100644
--- a/tp/t/automatic_nodes.t
+++ b/tp/t/automatic_nodes.t
@@ -12,17 +12,14 @@ use Texinfo::Transformations;
 use Texinfo::Convert::Texinfo;
 use Texinfo::Document;
 use Texinfo::Structuring;
+use Texinfo::XSLoader;
 
 use Data::Dumper;
 
 ok(1);
 
-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 $XS_structuring = Texinfo::XSLoader::XS_structuring_enabled();
 
 # _new_node cannot be called with XS used for structuring.
 # See comment in the beginning of _new_node.
diff --git a/tp/t/html_tests.t b/tp/t/html_tests.t
index ad3e04cb97..4e27d2868e 100644
--- a/tp/t/html_tests.t
+++ b/tp/t/html_tests.t
@@ -5,9 +5,7 @@ use Texinfo::ModulePath (undef, undef, undef, 'updirs' => 2);
 
 require 't/test_utils.pl';
 
-my $XS_convert = 0;
-$XS_convert = 1 if (defined $ENV{TEXINFO_XS_CONVERT}
-                    and $ENV{TEXINFO_XS_CONVERT} eq '1');
+my $XS_convert = Texinfo::XSLoader::XS_convert_enabled();
 
 my $itemize_arguments_text = '
 @itemize ---
diff --git a/tp/t/protect_character_in_texinfo.t 
b/tp/t/protect_character_in_texinfo.t
index 90c2a4a771..75128975c6 100644
--- a/tp/t/protect_character_in_texinfo.t
+++ b/tp/t/protect_character_in_texinfo.t
@@ -12,14 +12,9 @@ use Texinfo::Common qw(protect_comma_in_tree 
protect_colon_in_tree
       protect_node_after_label_in_tree);
 use Texinfo::Convert::Texinfo;
 use Texinfo::Document;
+use Texinfo::XSLoader;
 
-# XS parser and not explicitly 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 $XS_structuring = Texinfo::XSLoader::XS_structuring_enabled();
 
 ok(1);
 
diff --git a/tp/t/test_utils.pl b/tp/t/test_utils.pl
index 21592df39b..d224aaf147 100644
--- a/tp/t/test_utils.pl
+++ b/tp/t/test_utils.pl
@@ -28,6 +28,8 @@ BEGIN {
 require Texinfo::ModulePath;
 Texinfo::ModulePath::init(undef, undef, undef, 'updirs' => 2);
 
+use Texinfo::XSLoader;
+
 # NOTE in general file names and directory names are not encoded,
 # there will be problems if there are non ascii characters in those
 # strings.
@@ -112,13 +114,7 @@ Texinfo::Translations::configure($localesdir);
 
 Locale::Messages::bindtextdomain('texinfo', $localesdir);
 
-# XS parser and not explicitly 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 $XS_structuring = Texinfo::XSLoader::XS_structuring_enabled();
 
 my $generated_texis_dir = 't_texis';
 
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index e74f25b080..19001e0b85 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -124,6 +124,8 @@ BEGIN {
   }
 }
 
+use Texinfo::XSLoader;
+
 use Locale::Messages;
 use Texinfo::Options;
 use Texinfo::Common;
@@ -1423,12 +1425,7 @@ die _encode_message(
      unless (scalar(@input_files) >= 1);
 
 # XS parser and not explicitly 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 $XS_structuring = Texinfo::XSLoader::XS_structuring_enabled();
 
 if (defined($ENV{TEXINFO_XS_EXTERNAL_CONVERSION})
     and $ENV{TEXINFO_XS_EXTERNAL_CONVERSION}) {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]