texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/XS/Makefile.am (libcallperl_libtexin


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/Makefile.am (libcallperl_libtexinfo_convert_la_SOURCES) (libtexinfo_convertxs_la_SOURCES), tp/Texinfo/XS/convert/call_conversion_perl.c (get_sv_converter), tp/Texinfo/XS/convert/get_converter_perl_info.c: move libcallperl_libtexinfo_convert.c to libcallperl_libtexinfo_convert, and move get_sv_converter to libcallperl_libtexinfo_convert.c as it is used in that file.
Date: Tue, 24 Dec 2024 03:40:29 -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 5ad78a7d91 * tp/Texinfo/XS/Makefile.am 
(libcallperl_libtexinfo_convert_la_SOURCES) (libtexinfo_convertxs_la_SOURCES), 
tp/Texinfo/XS/convert/call_conversion_perl.c (get_sv_converter), 
tp/Texinfo/XS/convert/get_converter_perl_info.c: move 
libcallperl_libtexinfo_convert.c to libcallperl_libtexinfo_convert, and move 
get_sv_converter to libcallperl_libtexinfo_convert.c as it is used in that file.
5ad78a7d91 is described below

commit 5ad78a7d9195880fa9e1a488b987bb3a3e0ef9de
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Dec 23 18:45:31 2024 +0100

    * tp/Texinfo/XS/Makefile.am
    (libcallperl_libtexinfo_convert_la_SOURCES)
    (libtexinfo_convertxs_la_SOURCES),
    tp/Texinfo/XS/convert/call_conversion_perl.c (get_sv_converter),
    tp/Texinfo/XS/convert/get_converter_perl_info.c: move
    libcallperl_libtexinfo_convert.c to libcallperl_libtexinfo_convert,
    and move get_sv_converter to libcallperl_libtexinfo_convert.c as it is
    used in that file.
    
    * tp/Texinfo/XS/convert/call_conversion_perl.c
    (call_config_GNUT_load_init_file), tp/Texinfo/XS/Makefile.am
    (teximakehtml_SOURCES),
    tp/Texinfo/XS/convert/replace_call_conversion_perl.c: add replacements
    for call_conversion_perl.c functions to be used when not linked
    against libtexinfo_convertxs.
    
    * tp/Texinfo/XS/convert/texinfo.c (txi_customization_loading_setup)
    (txi_load_init_file, txi_customization_loading_finish)
    (txi_converter_setup, txi_converter_output),
    tp/Texinfo/XS/teximakehtml.c (locate_and_load_init_file)
    (locate_and_load_extension_file, main): move code calling
    call_conversion_perl.c functions out of texi2makehtml.c to texinfo.c.
---
 ChangeLog                                          |  25 +++++
 tp/Texinfo/XS/Makefile.am                          |  13 ++-
 tp/Texinfo/XS/convert/call_conversion_perl.c       |  36 +++++++-
 tp/Texinfo/XS/convert/call_conversion_perl.h       |   2 +-
 tp/Texinfo/XS/convert/get_converter_perl_info.c    |  31 -------
 tp/Texinfo/XS/convert/get_converter_perl_info.h    |   4 +
 .../XS/convert/replace_call_conversion_perl.c      |  39 ++++++++
 .../XS/convert/replace_perl_call_html_function.c   |   3 -
 tp/Texinfo/XS/convert/texinfo.c                    |  77 ++++++++++++++--
 tp/Texinfo/XS/convert/texinfo.h                    |  13 ++-
 tp/Texinfo/XS/teximakehtml.c                       | 102 +++++++--------------
 11 files changed, 224 insertions(+), 121 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a8a0e4ecc8..30ceed9e0d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2024-12-23  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/Makefile.am
+       (libcallperl_libtexinfo_convert_la_SOURCES)
+       (libtexinfo_convertxs_la_SOURCES),
+       tp/Texinfo/XS/convert/call_conversion_perl.c (get_sv_converter),
+       tp/Texinfo/XS/convert/get_converter_perl_info.c: move
+       libcallperl_libtexinfo_convert.c to libcallperl_libtexinfo_convert,
+       and move get_sv_converter to libcallperl_libtexinfo_convert.c as it is
+       used in that file.
+
+       * tp/Texinfo/XS/convert/call_conversion_perl.c
+       (call_config_GNUT_load_init_file), tp/Texinfo/XS/Makefile.am
+       (teximakehtml_SOURCES),
+       tp/Texinfo/XS/convert/replace_call_conversion_perl.c: add replacements
+       for call_conversion_perl.c functions to be used when not linked
+       against libtexinfo_convertxs.
+
+       * tp/Texinfo/XS/convert/texinfo.c (txi_customization_loading_setup)
+       (txi_load_init_file, txi_customization_loading_finish)
+       (txi_converter_setup, txi_converter_output),
+       tp/Texinfo/XS/teximakehtml.c (locate_and_load_init_file)
+       (locate_and_load_extension_file, main): move code calling
+       call_conversion_perl.c functions out of texi2makehtml.c to texinfo.c.
+
 2024-12-23  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/convert/call_conversion_perl.c (call_init_perl),
diff --git a/tp/Texinfo/XS/Makefile.am b/tp/Texinfo/XS/Makefile.am
index 30e1a8015e..187d022add 100644
--- a/tp/Texinfo/XS/Makefile.am
+++ b/tp/Texinfo/XS/Makefile.am
@@ -518,7 +518,9 @@ libcallperl_libtexinfo_convert_la_SOURCES = \
                        convert/build_html_perl_state.h \
                        convert/build_html_perl_state.c \
                        convert/call_html_perl_function.h \
-                       convert/call_html_perl_function.c
+                       convert/call_html_perl_function.c \
+                       convert/call_conversion_perl.c \
+                       convert/call_conversion_perl.h
 
 libcallperl_libtexinfo_convert_la_CPPFLAGS = -I$(srcdir)/main 
-I$(srcdir)/convert $(XSLIBS_CPPFLAGS)
 libcallperl_libtexinfo_convert_la_CFLAGS = $(XSLIBS_CFLAGS)
@@ -543,15 +545,11 @@ if HAVE_ICONV
 xs_LTLIBRARIES += libtexinfo-convertxs.la
 endif
 
-# call_conversion_perl.c code is not actually called by XS interfaces
-# but from C code embedding a Perl interpreter.
 libtexinfo_convertxs_la_SOURCES = \
                        convert/build_html_perl_info.h \
                        convert/build_html_perl_info.c \
                        convert/get_converter_perl_info.c \
-                       convert/get_converter_perl_info.h \
-                       convert/call_conversion_perl.c \
-                       convert/call_conversion_perl.h
+                       convert/get_converter_perl_info.h
 
 # locate include files under out-of-source builds.
 libtexinfo_convertxs_la_CPPFLAGS = -I$(srcdir)/main -I$(srcdir)/convert 
$(AM_CPPFLAGS) $(XSLIBS_CPPFLAGS)
@@ -620,7 +618,8 @@ teximakehtml_SOURCES = \
                        $(C_libtexinfo_convert_sources) \
                        teximakehtml.c \
                        main/replace_perl_api_call.c \
-                       convert/replace_perl_call_html_function.c
+                       convert/replace_perl_call_html_function.c \
+                       convert/replace_call_conversion_perl.c
 
 teximakehtml_LDADD = $(top_builddir)/gnulib/lib/libgnu.la
 teximakehtml_LDFLAGS = $(EUIDACCESS_LIBGEN) $(LTLIBINTL) $(LTLIBICONV) 
$(LTLIBUNISTRING)
diff --git a/tp/Texinfo/XS/convert/call_conversion_perl.c 
b/tp/Texinfo/XS/convert/call_conversion_perl.c
index 0c8d57c326..6b098134bc 100644
--- a/tp/Texinfo/XS/convert/call_conversion_perl.c
+++ b/tp/Texinfo/XS/convert/call_conversion_perl.c
@@ -29,6 +29,7 @@
 #include "build_perl_info.h"
 #include "get_converter_perl_info.h"
 #include "xs_utils.h"
+#include "converter.h"
 #include "call_conversion_perl.h"
 
  /* See the NOTE in build_perl_info.c on use of functions related to
@@ -37,7 +38,7 @@
 
 static int texinfo_convert_html_module_loaded;
 
-void
+int
 call_config_GNUT_load_init_file (const char *file_path)
 {
   int count;
@@ -74,6 +75,39 @@ call_config_GNUT_load_init_file (const char *file_path)
 
   FREETMPS;
   LEAVE;
+
+  return 1;
+}
+
+CONVERTER *
+get_sv_converter (SV *sv_in, const char *warn_string)
+{
+  size_t converter_descriptor = 0;
+  CONVERTER *converter = 0;
+  SV** converter_descriptor_sv;
+  HV *hv_in;
+  char *key = "converter_descriptor";
+
+  dTHX;
+
+  hv_in = (HV *)SvRV (sv_in);
+  converter_descriptor_sv = hv_fetch (hv_in, key, strlen (key), 0);
+  if (converter_descriptor_sv)
+    {
+      converter_descriptor = (size_t) SvIV (*converter_descriptor_sv);
+      converter = retrieve_converter (converter_descriptor);
+    }
+  else if (warn_string)
+    {
+      fprintf (stderr, "ERROR: %s: no %s\n", warn_string, key);
+      return 0;
+    }
+  if (! converter && warn_string)
+    {
+      fprintf (stderr, "ERROR: %s: no converter %zu\n", warn_string,
+                                                      converter_descriptor);
+    }
+  return converter;
 }
 
 CONVERTER *
diff --git a/tp/Texinfo/XS/convert/call_conversion_perl.h 
b/tp/Texinfo/XS/convert/call_conversion_perl.h
index 0545773402..b91a9fdb73 100644
--- a/tp/Texinfo/XS/convert/call_conversion_perl.h
+++ b/tp/Texinfo/XS/convert/call_conversion_perl.h
@@ -11,7 +11,7 @@ CONVERTER *call_convert_converter (const char *module_name,
 char *call_converter_output (const char *module_name, CONVERTER *self,
                              DOCUMENT *document);
 
-void call_config_GNUT_load_init_file (const char *file_path);
+int call_config_GNUT_load_init_file (const char *file_path);
 
 int call_init_perl (int *argc_ref, char ***argv_ref, char ***env_ref,
                     char *load_txi_modules_path);
diff --git a/tp/Texinfo/XS/convert/get_converter_perl_info.c 
b/tp/Texinfo/XS/convert/get_converter_perl_info.c
index cb406125c2..53a1aa0529 100644
--- a/tp/Texinfo/XS/convert/get_converter_perl_info.c
+++ b/tp/Texinfo/XS/convert/get_converter_perl_info.c
@@ -43,37 +43,6 @@
 #include "get_converter_perl_info.h"
 
 
-CONVERTER *
-get_sv_converter (SV *sv_in, const char *warn_string)
-{
-  size_t converter_descriptor = 0;
-  CONVERTER *converter = 0;
-  SV** converter_descriptor_sv;
-  HV *hv_in;
-  char *key = "converter_descriptor";
-
-  dTHX;
-
-  hv_in = (HV *)SvRV (sv_in);
-  converter_descriptor_sv = hv_fetch (hv_in, key, strlen (key), 0);
-  if (converter_descriptor_sv)
-    {
-      converter_descriptor = (size_t) SvIV (*converter_descriptor_sv);
-      converter = retrieve_converter (converter_descriptor);
-    }
-  else if (warn_string)
-    {
-      fprintf (stderr, "ERROR: %s: no %s\n", warn_string, key);
-      return 0;
-    }
-  if (! converter && warn_string)
-    {
-      fprintf (stderr, "ERROR: %s: no converter %zu\n", warn_string,
-                                                      converter_descriptor);
-    }
-  return converter;
-}
-
 CONVERTER *
 get_or_create_sv_converter (SV *converter_in, const char *input_class)
 {
diff --git a/tp/Texinfo/XS/convert/get_converter_perl_info.h 
b/tp/Texinfo/XS/convert/get_converter_perl_info.h
index 2642f839f0..870506016a 100644
--- a/tp/Texinfo/XS/convert/get_converter_perl_info.h
+++ b/tp/Texinfo/XS/convert/get_converter_perl_info.h
@@ -10,7 +10,11 @@
 #include "converter_types.h"
 #include "convert_to_text.h"
 
+/* Implemented in call_conversion_perl.h, but we do not want Perl
+   SV in call_conversion_perl.h since it is included from pure C */
 CONVERTER *get_sv_converter (SV *sv_in, const char *warn_string);
+
+
 CONVERTER *get_or_create_sv_converter (SV *converter_in,
                                        const char *input_class);
 CONVERTER_INITIALIZATION_INFO * get_converter_info_from_sv (SV *conf_sv,
diff --git a/tp/Texinfo/XS/convert/replace_call_conversion_perl.c 
b/tp/Texinfo/XS/convert/replace_call_conversion_perl.c
new file mode 100644
index 0000000000..f2f301ab6e
--- /dev/null
+++ b/tp/Texinfo/XS/convert/replace_call_conversion_perl.c
@@ -0,0 +1,39 @@
+/* replacements for Perl functions calling.  Most could be called. */
+
+#include <config.h>
+
+#include "converter_types.h"
+#include "document_types.h"
+#include "call_conversion_perl.h"
+
+int
+call_config_GNUT_load_init_file (const char *file_path)
+{
+  return 0; 
+}
+
+CONVERTER *
+call_convert_converter (const char *module_name,
+                        const CONVERTER_INITIALIZATION_INFO *conf)
+{
+  return 0;
+}
+
+char *
+call_converter_output (const char *module_name, CONVERTER *self,
+                       DOCUMENT *document)
+{
+  return 0;
+}
+
+int
+call_init_perl (int *argc_ref, char ***argv_ref, char ***env_ref,
+                char *load_txi_modules_path)
+{
+  return -1;
+}
+
+void
+call_finish_perl (void)
+{
+}
diff --git a/tp/Texinfo/XS/convert/replace_perl_call_html_function.c 
b/tp/Texinfo/XS/convert/replace_perl_call_html_function.c
index d80c836dd0..eb7028f1e8 100644
--- a/tp/Texinfo/XS/convert/replace_perl_call_html_function.c
+++ b/tp/Texinfo/XS/convert/replace_perl_call_html_function.c
@@ -7,9 +7,6 @@
 /* *BUTTON* */
 #include "option_types.h"
 #include "converter_types.h"
-/* new_string_list find_string *string 
- */
-#include "utils.h"
 #include "call_html_perl_function.h"
 
 TARGET_FILENAME *
diff --git a/tp/Texinfo/XS/convert/texinfo.c b/tp/Texinfo/XS/convert/texinfo.c
index 312f327c38..549491b1c8 100644
--- a/tp/Texinfo/XS/convert/texinfo.c
+++ b/tp/Texinfo/XS/convert/texinfo.c
@@ -43,6 +43,7 @@
 #include "transformations.h"
 #include "converter.h"
 #include "html_converter_api.h"
+#include "call_conversion_perl.h"
 #include "texinfo.h"
 
 /* initialization of the library for parsing and conversion (generic),
@@ -133,6 +134,50 @@ txi_set_base_default_options (OPTIONS_LIST 
*main_program_set_options,
   add_program_customization_options_defaults (main_program_set_options);
 }
 
+/* to be called before loading init file to get the opportunity to
+   start an embedded interpreter */
+void
+txi_customization_loading_setup (int embedded_interpreter,
+                   int *argc_ref, char ***argv_ref, char ***env_ref)
+{
+  const char *load_txi_modules_basename = "load_txi_modules";
+  if (embedded_interpreter)
+    {/* setup paths here to avoid memory management as much as possible
+        in Perl C */
+      char *load_modules_path;
+      int status;
+      if (conversion_paths_info.texinfo_uninstalled)
+        xasprintf (&load_modules_path, "%s/tp/%s.pl",
+                      conversion_paths_info.p.uninstalled.top_srcdir,
+                                       load_txi_modules_basename);
+      else
+        xasprintf (&load_modules_path, "%s/%s",
+                  conversion_paths_info.p.installed.converterdatadir,
+                   load_txi_modules_basename);
+      status = call_init_perl (argc_ref, argv_ref, env_ref, load_modules_path);
+      /* status < 0 means no functioning call_init_perl */
+      if (status > 0)
+        fprintf (stderr, "ERROR: call_init_perl status: %d\n", status);
+      else if (status < 0)
+        fprintf (stderr, "WARNING: no embedded interpreter available\n");
+      free (load_modules_path);
+    }
+}
+
+int
+txi_load_init_file (const char *file)
+{
+  int status = call_config_GNUT_load_init_file (file);
+  return status;
+}
+
+void
+txi_customization_loading_finish (int embedded_interpreter)
+{
+  if (embedded_interpreter)
+    call_finish_perl ();
+}
+
 /* initialization of the library for a specific output format, to be
    called once */
 void
@@ -392,13 +437,26 @@ txi_converter_initialization_setup 
(CONVERTER_INITIALIZATION_INFO *conf,
 /* converter setup. Similar to an initialization of converter
    in texi2any */
 CONVERTER *
-txi_converter_setup (const char *converted_format,
-                     const CONVERTER_INITIALIZATION_INFO *conf)
+txi_converter_setup (const char *external_module,
+                     const char *converted_format,
+                     const CONVERTER_INITIALIZATION_INFO *converter_init_info)
 {
-  enum converter_format converter_format
-    = find_format_name_converter_format (converted_format);
+  enum converter_format converter_format;
+  CONVERTER *self;
+
+  if (external_module)
+    {
+      self = call_convert_converter (external_module, converter_init_info);
+      if (!self)
+        fprintf (stderr,
+                 "ERROR: no interpreter or NULL return for module: %s\n",
+                 external_module);
+      else
+        return self;
+    }
 
-  CONVERTER *self = converter_converter (converter_format, conf);
+  converter_format = find_format_name_converter_format (converted_format);
+  self = converter_converter (converter_format, converter_init_info);
 
   return self;
 }
@@ -414,8 +472,15 @@ txi_parse_texi_file (const char *input_file_path, int 
*status)
 
 /* similar to Texinfo::Convert::XXX->output */
 char *
-txi_converter_output (CONVERTER *converter, DOCUMENT *document)
+txi_converter_output (const char *external_module,
+                      CONVERTER *converter, DOCUMENT *document)
 {
+  if (external_module)
+    {
+      char *result = call_converter_output (external_module,
+                                            converter, document);
+      return result;
+    }
   return converter_output (converter, document);
 }
 
diff --git a/tp/Texinfo/XS/convert/texinfo.h b/tp/Texinfo/XS/convert/texinfo.h
index 628b2e9dbf..ef35237231 100644
--- a/tp/Texinfo/XS/convert/texinfo.h
+++ b/tp/Texinfo/XS/convert/texinfo.h
@@ -39,6 +39,9 @@ void txi_set_base_default_options (OPTIONS_LIST *options,
                                    const char *locale_encoding,
                                    const char *program_file);
 
+void txi_customization_loading_setup (int embedded_interpreter,
+                   int *argc_ref, char ***argv_ref, char ***env_ref);
+
 void txi_converter_output_format_setup (const char *format_str);
 
 CONVERTER_INITIALIZATION_INFO *txi_converter_format_defaults (
@@ -56,11 +59,15 @@ 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);
+void txi_customization_loading_finish (int embedded_interpreter);
 
-CONVERTER *txi_converter_setup (const char *converted_format,
-                                const CONVERTER_INITIALIZATION_INFO *conf);
+CONVERTER *txi_converter_setup (const char *external_module,
+                     const char *converted_format,
+                     const CONVERTER_INITIALIZATION_INFO *converter_init_info);
 
-char *txi_converter_output (CONVERTER *converter, DOCUMENT *document);
+char *txi_converter_output (const char *external_module,
+                            CONVERTER *converter, DOCUMENT *document);
 char *txi_converter_convert (CONVERTER *converter, DOCUMENT *document);
 
 size_t txi_handle_parser_error_messages (DOCUMENT *document, int no_warn,
diff --git a/tp/Texinfo/XS/teximakehtml.c b/tp/Texinfo/XS/teximakehtml.c
index 6c88c5e8d2..6d93aab588 100644
--- a/tp/Texinfo/XS/teximakehtml.c
+++ b/tp/Texinfo/XS/teximakehtml.c
@@ -65,10 +65,6 @@
 #include "converter.h"
 #include "texinfo.h"
 
-#ifdef EMBED_PERL
-#include "call_conversion_perl.h"
-#endif
-
 #define LOCALEDIR DATADIR "/locale"
 
 #define _(String) gettext (String)
@@ -767,18 +763,19 @@ locate_and_load_init_file (const char *filename, 
STRING_LIST *directories,
 
   if (file)
     {
-#ifdef EMBED_PERL
-      if (embedded_interpreter)
-        {
-          call_config_GNUT_load_init_file (file);
-          loaded_init_files_nr++;
-        }
+      int status = txi_load_init_file (file);
+
+      if (status)
+        loaded_init_files_nr++;
       else
-#endif
         {
           char *decoded_filename = decode_input ((char *) filename);
-          fprintf (stderr, "No interpreter, cannot load: %s\n",
-                   filename);
+          if (!embedded_interpreter)
+            fprintf (stderr, "WARNING: no interpreter, cannot load: %s\n",
+                     filename);
+          else
+            fprintf (stderr, "ERROR: could not load: %s\n",
+                     filename);
           free (decoded_filename);
         }
     }
@@ -801,18 +798,19 @@ locate_and_load_extension_file (const char *filename, 
STRING_LIST *directories)
 
   if (file)
     {
-#ifdef EMBED_PERL
-      if (embedded_interpreter)
-        {
-          call_config_GNUT_load_init_file (file);
-          loaded_init_files_nr++;
-        }
+      int status = txi_load_init_file (file);
+
+      if (status)
+        loaded_init_files_nr++;
       else
-#endif
         {
           char *decoded_filename = decode_input ((char *) filename);
-          fprintf (stderr, "No interpreter, cannot load: %s\n",
-                   filename);
+          if (!embedded_interpreter)
+            fprintf (stderr, "WARNING: no interpreter, cannot load: %s\n",
+                     filename);
+          else
+            fprintf (stderr, "ERROR: could not load: %s\n",
+                     filename);
           free (decoded_filename);
         }
     }
@@ -1010,10 +1008,7 @@ main (int argc, char *argv[], char *env[])
   const char *converterdatadir = DATADIR "/" CONVERTER_CONFIG;
   const char *curdir = ".";
   CONVERTER_INITIALIZATION_INFO *converter_init_info;
-  /* to avoid a warning on unused variable keep in ifdef */
-#ifdef EMBED_PERL
-  const char *load_txi_modules_basename = "load_txi_modules";
-#endif
+  const char *external_module = 0;
 
   parse_file_path (argv[0], program_file_name_and_directory);
   program_file = program_file_name_and_directory[0];
@@ -1762,26 +1757,7 @@ main (int argc, char *argv[], char *env[])
     add_option_value (&program_options, "XS_STRXFRM_COLLATION_LOCALE", 0,
                       "en_US");
 
-#ifdef EMBED_PERL
-  if (embedded_interpreter)
-    {/* setup paths here to avoid memory management as much as possible
-        in Perl C */
-      char *load_modules_path;
-      int status;
-      if (conversion_paths_info.texinfo_uninstalled)
-        xasprintf (&load_modules_path, "%s/tp/%s.pl",
-                      conversion_paths_info.p.uninstalled.top_srcdir,
-                                       load_txi_modules_basename);
-      else
-        xasprintf (&load_modules_path, "%s/%s",
-                  conversion_paths_info.p.installed.converterdatadir,
-                   load_txi_modules_basename);
-      status = call_init_perl (&argc, &argv, &env, load_modules_path);
-      if (status)
-        fprintf (stderr, "ERROR: call_init_perl status: %d\n", status);
-      free (load_modules_path);
-    }
-#endif
+  txi_customization_loading_setup (embedded_interpreter, &argc, &argv, &env);
 
   /* TODO different from Perl, to be discussed on the list which
      one is better, load within the command line loop, or after */
@@ -2018,6 +1994,11 @@ main (int argc, char *argv[], char *env[])
                         configured_name_version);
     }
 
+  if (format_specification->module && embedded_interpreter
+      && (!strcmp (converted_format, "html")
+          && loaded_init_files_nr > 0))
+    external_module = format_specification->module;
+
   if (optind < argc)
     {
       int j;
@@ -2339,29 +2320,15 @@ main (int argc, char *argv[], char *env[])
                                           &deprecated_directories,
                                           &convert_options);
 
-#ifdef EMBED_PERL
-      if (format_specification->module
-          && embedded_interpreter
-          && (!strcmp (converted_format, "html")
-              && loaded_init_files_nr > 0))
-        {
-          converter = call_convert_converter (format_specification->module,
-                                              converter_init_info);
-
-          result = call_converter_output (format_specification->module,
-                                          converter, document);
-        }
-      else
-#endif
-        {
-          converter = txi_converter_setup (converted_format,
-                                           converter_init_info);
+      converter = txi_converter_setup (external_module,
+                                       converted_format,
+                                       converter_init_info);
 
       /* conversion */
       /* return value can be NULL in case of errors or an empty string, but
          not anything else as parse_file is used with a file */
-          result = txi_converter_output (converter, document);
-        }
+      result = txi_converter_output (external_module, converter, document);
+
       free (result);
       clear_converter_initialization_info (converter_init_info);
 
@@ -2422,10 +2389,7 @@ main (int argc, char *argv[], char *env[])
   free_strings_list (&internal_extension_dirs);
   free (extensions_dir);
 
-#ifdef EMBED_PERL
-  if (embedded_interpreter)
-    call_finish_perl ();
-#endif
+  txi_customization_loading_finish (embedded_interpreter);
 
   if (errors_count > 0)
     exit (EXIT_FAILURE);



reply via email to

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