texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Tue, 24 Dec 2024 03:25:03 -0500 (EST)

branch: master
commit 02959c293901f354f295d099cce45cfe8e9e710b
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Dec 22 22:24:07 2024 +0100

    force using XS when Perl interpreter is embedded
    
    * tp/Texinfo/XSLoader.pm ($embedded_xs, set_XS_embedded)
    (XS_parser_enabled, XS_structuring_enabled, XS_convert_enabled),
    tp/load_txi_modules.pl: add set_XS_embedded to notify that the Perl
    parser is embedded and set $embedded_xs.  Call it from
    load_txi_modules.pl.
    
    * tp/Texinfo/Convert/HTML.pm (import): do not call _XS_format_setup if
    Perl is embedded, as it has already been called by the C code.
---
 ChangeLog                  | 13 +++++++++++++
 tp/Texinfo/Convert/HTML.pm |  5 ++++-
 tp/Texinfo/XSLoader.pm     | 27 +++++++++++++++++++--------
 tp/load_txi_modules.pl     |  6 +++---
 4 files changed, 39 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index be382afc5a..971463d2ce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2024-12-22  Patrice Dumas  <pertusus@free.fr>
+
+       force using XS when Perl interpreter is embedded
+
+       * tp/Texinfo/XSLoader.pm ($embedded_xs, set_XS_embedded)
+       (XS_parser_enabled, XS_structuring_enabled, XS_convert_enabled),
+       tp/load_txi_modules.pl: add set_XS_embedded to notify that the Perl
+       parser is embedded and set $embedded_xs.  Call it from
+       load_txi_modules.pl.
+
+       * tp/Texinfo/Convert/HTML.pm (import): do not call _XS_format_setup if
+       Perl is embedded, as it has already been called by the C code.
+
 2024-12-22  Patrice Dumas  <pertusus@free.fr>
 
        load initialization files in teximakehtml.c
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 1644e71b04..86734b6984 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -336,7 +336,10 @@ sub import {
       foreach my $sub (keys %XS_conversion_overrides) {
         Texinfo::XSLoader::override ($sub, $XS_conversion_overrides{$sub});
       }
-      _XS_format_setup();
+      # No need to do it again if called from C
+      if (!$Texinfo::XSLoader::embedded_xs) {
+        _XS_format_setup();
+      }
     }
     $module_loaded = 1;
   }
diff --git a/tp/Texinfo/XSLoader.pm b/tp/Texinfo/XSLoader.pm
index fe053416ed..01afbddd53 100644
--- a/tp/Texinfo/XSLoader.pm
+++ b/tp/Texinfo/XSLoader.pm
@@ -43,23 +43,34 @@ my $xs_version = $VERSION;
 $xs_version =~ s/-/./g;
 #my $xs_version = version->declare($VERSION)->numify;
 
+# Set from code to notify that Perl is embedded in C, and that XS needs to
+# be used.
+our $embedded_xs;
+
+sub set_XS_embedded {
+  $embedded_xs = 1;
+}
+
 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'));
+  return ($embedded_xs or
+          ((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()
+  return ($embedded_xs or
+          (XS_parser_enabled()
            and (not defined($ENV{TEXINFO_XS_STRUCTURE})
-                or $ENV{TEXINFO_XS_STRUCTURE} ne '0'));
+                or $ENV{TEXINFO_XS_STRUCTURE} ne '0')));
 }
 
 sub XS_convert_enabled {
-  return (XS_structuring_enabled()
+  return ($embedded_xs or
+          (XS_structuring_enabled()
             and defined $ENV{TEXINFO_XS_CONVERT}
-            and $ENV{TEXINFO_XS_CONVERT} eq '1');
+            and $ENV{TEXINFO_XS_CONVERT} eq '1'));
 }
 
 
diff --git a/tp/load_txi_modules.pl b/tp/load_txi_modules.pl
index cf86cb43a8..effac14e3b 100755
--- a/tp/load_txi_modules.pl
+++ b/tp/load_txi_modules.pl
@@ -112,9 +112,7 @@ BEGIN
 BEGIN {
   my $enable_xs = '@enable_xs@';
   if ($enable_xs eq 'no') {
-    package Texinfo::XSLoader;
-    our $disable_XS;
-    $disable_XS = 1;
+    die ("Cannot have XS disabled and embedding Perl\n");
   }
 }
 
@@ -125,6 +123,8 @@ use Texinfo::Common;
 use Texinfo::Config;
 use Texinfo::Report;
 
+Texinfo::XSLoader::set_XS_embedded();
+
 # Paths and file names
 #my $curdir = File::Spec->curdir();
 #my $updir = File::Spec->updir();



reply via email to

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