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:44:25 -0500 (EST)

branch: master
commit 2ed355b271bcb3268df9f4b2bbbfef7d7e65497f
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Dec 23 19:13:35 2024 +0100

    * tp/Texinfo/XS/convert/texinfo.c (txi_load_init_file): add
    embedded_interpreter argument, to be able to skip the call if there is
    no embedded interpreter forced by the caller.  Update caller.
    
    * tp/Texinfo/XS/convert/texinfo.c (txi_customization_loading_setup),
    tp/Texinfo/XS/main/api_to_perl.c (get_perl_scalar_reference_value)
    (call_switch_to_global_locale, call_sync_locale),
    tp/Texinfo/XS/main/xs_utils.c (set_no_perl_interpreter)
    (get_no_perl_interpreter): add set_no_perl_interpreter and
    get_no_perl_interpreter to be able to communicate that there is no
    Perl interpreter even though the code is linked against Perl.  Set it
    in txi_customization_loading_setup.  Avoid calling Perl functions if
    set.
---
 ChangeLog                                  | 16 ++++++++++++++++
 tp/Texinfo/XS/convert/texinfo.c            | 10 ++++++++--
 tp/Texinfo/XS/convert/texinfo.h            |  2 +-
 tp/Texinfo/XS/main/api_to_perl.c           | 11 ++++++++++-
 tp/Texinfo/XS/main/replace_perl_api_call.c | 12 ++++++++++++
 tp/Texinfo/XS/main/xs_utils.c              | 17 +++++++++++++++++
 tp/Texinfo/XS/main/xs_utils.h              |  3 +++
 tp/Texinfo/XS/teximakehtml.c               |  4 ++--
 8 files changed, 69 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 30ceed9e0d..fabb57a1c7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2024-12-23  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/convert/texinfo.c (txi_load_init_file): add
+       embedded_interpreter argument, to be able to skip the call if there is
+       no embedded interpreter forced by the caller.  Update caller.
+
+       * tp/Texinfo/XS/convert/texinfo.c (txi_customization_loading_setup),
+       tp/Texinfo/XS/main/api_to_perl.c (get_perl_scalar_reference_value)
+       (call_switch_to_global_locale, call_sync_locale),
+       tp/Texinfo/XS/main/xs_utils.c (set_no_perl_interpreter)
+       (get_no_perl_interpreter): add set_no_perl_interpreter and
+       get_no_perl_interpreter to be able to communicate that there is no
+       Perl interpreter even though the code is linked against Perl.  Set it
+       in txi_customization_loading_setup.  Avoid calling Perl functions if
+       set.
+
 2024-12-23  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/Makefile.am
diff --git a/tp/Texinfo/XS/convert/texinfo.c b/tp/Texinfo/XS/convert/texinfo.c
index 549491b1c8..99659c18ce 100644
--- a/tp/Texinfo/XS/convert/texinfo.c
+++ b/tp/Texinfo/XS/convert/texinfo.c
@@ -44,6 +44,8 @@
 #include "converter.h"
 #include "html_converter_api.h"
 #include "call_conversion_perl.h"
+/* set_no_perl_interpreter */
+#include "xs_utils.h"
 #include "texinfo.h"
 
 /* initialization of the library for parsing and conversion (generic),
@@ -162,12 +164,16 @@ txi_customization_loading_setup (int embedded_interpreter,
         fprintf (stderr, "WARNING: no embedded interpreter available\n");
       free (load_modules_path);
     }
+  else
+    set_no_perl_interpreter (1);
 }
 
 int
-txi_load_init_file (const char *file)
+txi_load_init_file (const char *file, int embedded_interpreter)
 {
-  int status = call_config_GNUT_load_init_file (file);
+  int status = 0;
+  if (embedded_interpreter)
+    status = call_config_GNUT_load_init_file (file);
   return status;
 }
 
diff --git a/tp/Texinfo/XS/convert/texinfo.h b/tp/Texinfo/XS/convert/texinfo.h
index ef35237231..8271f2141d 100644
--- a/tp/Texinfo/XS/convert/texinfo.h
+++ b/tp/Texinfo/XS/convert/texinfo.h
@@ -59,7 +59,7 @@ void txi_complete_document (DOCUMENT *document, unsigned long 
flags,
 void txi_converter_initialization_setup (CONVERTER_INITIALIZATION_INFO *conf,
                                     const DEPRECATED_DIRS_LIST 
*deprecated_dirs,
                                     const OPTIONS_LIST *customizations);
-int txi_load_init_file (const char *file);
+int txi_load_init_file (const char *file, int embedded_interpreter);
 void txi_customization_loading_finish (int embedded_interpreter);
 
 CONVERTER *txi_converter_setup (const char *external_module,
diff --git a/tp/Texinfo/XS/main/api_to_perl.c b/tp/Texinfo/XS/main/api_to_perl.c
index 7149e06e82..ec8b23718c 100644
--- a/tp/Texinfo/XS/main/api_to_perl.c
+++ b/tp/Texinfo/XS/main/api_to_perl.c
@@ -32,7 +32,7 @@
 #include "option_types.h"
 #include "converter_types.h"
 #include "document_types.h"
-/* non_perl_* */
+/* non_perl_* get_no_perl_interpreter */
 #include "xs_utils.h"
 
  /* See the NOTE in build_perl_info.c on use of functions related to
@@ -70,6 +70,9 @@ get_perl_scalar_reference_value (const void *sv_string)
 
   dTHX;
 
+  if (get_no_perl_interpreter ())
+    return 0;
+
   string_ref_sv = (SV *) sv_string;
   if (SvOK (string_ref_sv) && SvROK (string_ref_sv))
     {
@@ -89,6 +92,9 @@ call_switch_to_global_locale (void)
 {
   dTHX;
 
+  if (get_no_perl_interpreter ())
+    return;
+
 #if PERL_VERSION > 27 || (PERL_VERSION == 27 && PERL_SUBVERSION > 8)
   /* needed due to thread-safe locale handling in newer perls */
   switch_to_global_locale ();
@@ -100,6 +106,9 @@ call_sync_locale (void)
 {
   dTHX;
 
+  if (get_no_perl_interpreter ())
+    return;
+
 #if PERL_VERSION > 27 || (PERL_VERSION == 27 && PERL_SUBVERSION > 8)
   /* needed due to thread-safe locale handling in newer perls */
   sync_locale ();
diff --git a/tp/Texinfo/XS/main/replace_perl_api_call.c 
b/tp/Texinfo/XS/main/replace_perl_api_call.c
index a7006afa2f..0119c8855b 100644
--- a/tp/Texinfo/XS/main/replace_perl_api_call.c
+++ b/tp/Texinfo/XS/main/replace_perl_api_call.c
@@ -26,6 +26,18 @@
 #include "api_to_perl.h"
 #include "call_perl_function.h"
 
+/* in xs_utils.h */
+void
+set_no_perl_interpreter (int value)
+{
+}
+
+int
+get_no_perl_interpreter (void)
+{
+  return 1;
+}
+
 void
 call_switch_to_global_locale (void)
 {
diff --git a/tp/Texinfo/XS/main/xs_utils.c b/tp/Texinfo/XS/main/xs_utils.c
index bf90b92f1a..e1e0db5b75 100644
--- a/tp/Texinfo/XS/main/xs_utils.c
+++ b/tp/Texinfo/XS/main/xs_utils.c
@@ -21,6 +21,23 @@
 #include <stdio.h>
 #include <stdarg.h>
 
+#include "xs_utils.h"
+
+/* to set if Perl code is compiled in, but there is no Perl interpreter */
+static int no_perl_interpreter = 0;
+
+void
+set_no_perl_interpreter (int value)
+{
+  no_perl_interpreter = value;
+}
+
+int
+get_no_perl_interpreter (void)
+{
+  return no_perl_interpreter;
+}
+
 /* wrappers to be sure to use non-Perl defined functions */
 void
 non_perl_free (void *ptr)
diff --git a/tp/Texinfo/XS/main/xs_utils.h b/tp/Texinfo/XS/main/xs_utils.h
index 2b581153d8..41dd726e08 100644
--- a/tp/Texinfo/XS/main/xs_utils.h
+++ b/tp/Texinfo/XS/main/xs_utils.h
@@ -26,4 +26,7 @@ char *non_perl_strndup (const char *s, size_t n);
 int non_perl_xvasprintf (char **ptr, const char *template, va_list ap);
 int non_perl_xasprintf (char **ptr, const char *template, ...);
 
+void set_no_perl_interpreter (int value);
+int get_no_perl_interpreter (void);
+
 #endif
diff --git a/tp/Texinfo/XS/teximakehtml.c b/tp/Texinfo/XS/teximakehtml.c
index 6d93aab588..06a979aa92 100644
--- a/tp/Texinfo/XS/teximakehtml.c
+++ b/tp/Texinfo/XS/teximakehtml.c
@@ -763,7 +763,7 @@ locate_and_load_init_file (const char *filename, 
STRING_LIST *directories,
 
   if (file)
     {
-      int status = txi_load_init_file (file);
+      int status = txi_load_init_file (file, embedded_interpreter);
 
       if (status)
         loaded_init_files_nr++;
@@ -798,7 +798,7 @@ locate_and_load_extension_file (const char *filename, 
STRING_LIST *directories)
 
   if (file)
     {
-      int status = txi_load_init_file (file);
+      int status = txi_load_init_file (file, embedded_interpreter);
 
       if (status)
         loaded_init_files_nr++;



reply via email to

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