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

branch: master
commit e7483f3490faf0a027629e6a1bcf128b330f1d8a
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Dec 23 10:37:15 2024 +0100

    * tp/Texinfo/XS/convert/converter.c (free_generic_converter),
    tp/Texinfo/XS/convert/ConvertXS.xs (generic_converter_init): hold a
    reference to the converter in C.  It is required if the converter is
    not lexicaly associated to a Perl module, for instance when the
    converter is created by a call to Perl method from C.
    
    * tp/Texinfo/XS/Makefile.am (libtexinfo_convertxs_la_SOURCES),
    tp/Texinfo/XS/convert/call_conversion_perl.c
    (call_config_GNUT_load_init_file, call_init_perl, call_finish_perl),
    tp/Texinfo/XS/main/call_perl_function.c: move code calle dfrom
    embedded Perl to the new convert/call_conversion_perl.c file.
    
    * tp/Texinfo/XS/convert/call_conversion_perl.c
    (call_convert_converter, call_converter_output),
    tp/Texinfo/XS/teximakehtml.c (formats_table, FORMAT_SPECIFICATION)
    (main): add Perl module in FORMAT_SPECIFICATION, and add calls
    tp converter converter and output Perl methods.  Use it for HTML if
    init files were loaded.
---
 ChangeLog                                          |  21 ++
 tp/Texinfo/XS/Makefile.am                          |   6 +-
 tp/Texinfo/XS/convert/ConvertXS.xs                 |   5 +
 .../call_conversion_perl.c}                        | 256 +++++----------------
 tp/Texinfo/XS/convert/call_conversion_perl.h       |  20 ++
 tp/Texinfo/XS/convert/call_html_perl_function.c    |   4 +-
 tp/Texinfo/XS/convert/converter.c                  |   4 +
 tp/Texinfo/XS/main/call_perl_function.c            |  94 --------
 tp/Texinfo/XS/main/call_perl_function.h            |   5 -
 tp/Texinfo/XS/teximakehtml.c                       |  40 +++-
 10 files changed, 151 insertions(+), 304 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 971463d2ce..a279c85bc2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2024-12-23  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/convert/converter.c (free_generic_converter),
+       tp/Texinfo/XS/convert/ConvertXS.xs (generic_converter_init): hold a
+       reference to the converter in C.  It is required if the converter is
+       not lexicaly associated to a Perl module, for instance when the
+       converter is created by a call to Perl method from C.
+
+       * tp/Texinfo/XS/Makefile.am (libtexinfo_convertxs_la_SOURCES),
+       tp/Texinfo/XS/convert/call_conversion_perl.c
+       (call_config_GNUT_load_init_file, call_init_perl, call_finish_perl),
+       tp/Texinfo/XS/main/call_perl_function.c: move code calle dfrom
+       embedded Perl to the new convert/call_conversion_perl.c file.
+
+       * tp/Texinfo/XS/convert/call_conversion_perl.c
+       (call_convert_converter, call_converter_output),
+       tp/Texinfo/XS/teximakehtml.c (formats_table, FORMAT_SPECIFICATION)
+       (main): add Perl module in FORMAT_SPECIFICATION, and add calls
+       tp converter converter and output Perl methods.  Use it for HTML if
+       init files were loaded.
+
 2024-12-22  Patrice Dumas  <pertusus@free.fr>
 
        force using XS when Perl interpreter is embedded
diff --git a/tp/Texinfo/XS/Makefile.am b/tp/Texinfo/XS/Makefile.am
index 4c888a7bfd..30e1a8015e 100644
--- a/tp/Texinfo/XS/Makefile.am
+++ b/tp/Texinfo/XS/Makefile.am
@@ -543,11 +543,15 @@ 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/get_converter_perl_info.h \
+                       convert/call_conversion_perl.c \
+                       convert/call_conversion_perl.h
 
 # locate include files under out-of-source builds.
 libtexinfo_convertxs_la_CPPFLAGS = -I$(srcdir)/main -I$(srcdir)/convert 
$(AM_CPPFLAGS) $(XSLIBS_CPPFLAGS)
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs 
b/tp/Texinfo/XS/convert/ConvertXS.xs
index eca8e635da..10953f96fa 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -185,6 +185,11 @@ generic_converter_init (SV *converter_in, SV 
*format_defaults_sv, SV *conf_sv=0)
         self = get_or_create_sv_converter (converter_in, class_name);
         converter_hv = (HV *)SvRV (converter_in);
         self->hv = converter_hv;
+        /* hold a reference to the converter as long as we could access
+           it, in case there is nothing else holding a reference, for
+           instance when the converter is created by a call to Perl
+           method from C */
+        SvREFCNT_inc ((SV *) self->hv);
 
         format_defaults = get_converter_info_from_sv (format_defaults_sv,
                                                       class_name, self);
diff --git a/tp/Texinfo/XS/main/call_perl_function.c 
b/tp/Texinfo/XS/convert/call_conversion_perl.c
similarity index 53%
copy from tp/Texinfo/XS/main/call_perl_function.c
copy to tp/Texinfo/XS/convert/call_conversion_perl.c
index 2f16c0e856..a74fada11d 100644
--- a/tp/Texinfo/XS/main/call_perl_function.c
+++ b/tp/Texinfo/XS/convert/call_conversion_perl.c
@@ -26,77 +26,29 @@
 #include "tree_types.h"
 #include "converter_types.h"
 #include "document_types.h"
-/* non_perl_* */
+#include "build_perl_info.h"
+#include "get_converter_perl_info.h"
 #include "xs_utils.h"
-#include "call_perl_function.h"
+#include "call_conversion_perl.h"
 
  /* See the NOTE in build_perl_info.c on use of functions related to
     memory allocation */
 
-/* Used to create a "Perl-internal" string that represents a sequence
-   of Unicode codepoints with no specific encoding. */
-SV *
-newSVpv_utf8 (const char *str, STRLEN len)
-{
-  SV *sv;
-  dTHX;
-
-  sv = newSVpv (str, len);
-  SvUTF8_on (sv);
-  return sv;
-}
-
-/* Used to create a string considered as bytes by perl */
-SV *
-newSVpv_byte (const char *str, STRLEN len)
-{
-  SV *sv;
-  dTHX;
 
-  sv = newSVpv (str, len);
-  SvUTF8_off (sv);
-  return sv;
-}
+static int texinfo_convert_html_module_loaded;
 
 void
-call_common_set_output_perl_encoding (const CONVERTER *self)
+call_config_GNUT_load_init_file (const char *file_path)
 {
   int count;
 
   dTHX;
 
-  dSP;
-
-  ENTER;
-  SAVETMPS;
-
-  PUSHMARK(SP);
-  EXTEND(SP, 1);
-
-  PUSHs(sv_2mortal (newRV_inc (self->hv)));
-  PUTBACK;
-
-  count = call_pv (
-    "Texinfo::Common::set_output_perl_encoding",
-    G_DISCARD);
-
-  if (count != 0)
-    croak ("set_output_perl_encoding should return 0 item\n");
-
-  FREETMPS;
-  LEAVE;
-}
-
-char *
-call_nodenamenormalization_unicode_to_transliterate (const char *text)
-{
-  int count;
-  char *result;
-  char *result_ret;
-  STRLEN len;
-  SV *result_sv;
-
-  dTHX;
+  if (!texinfo_convert_html_module_loaded)
+    {
+      eval_pv ("use Texinfo::Convert::HTML;", TRUE);
+      texinfo_convert_html_module_loaded = 1;
+    }
 
   dSP;
 
@@ -106,112 +58,63 @@ call_nodenamenormalization_unicode_to_transliterate 
(const char *text)
   PUSHMARK(SP);
   EXTEND(SP, 1);
 
-  PUSHs(sv_2mortal (newSVpv_utf8 (text, 0)));
-  PUTBACK;
-
-  count = call_pv (
-    "Texinfo::Convert::NodeNameNormalization::_unicode_to_transliterate",
-    G_SCALAR);
-
-  SPAGAIN;
-
-  if (count != 1)
-    croak ("_unicode_to_transliterate should return 1 item\n");
-
-  result_sv = POPs;
-  result_ret = SvPVutf8 (result_sv, len);
-  result = non_perl_strndup (result_ret, len);
-
-  PUTBACK;
-
-  FREETMPS;
-  LEAVE;
-
-  return result;
-}
-
-char *
-call_translations_translate_string (const char *string, const char *in_lang,
-                                    const char *translation_context)
-{
-  int count;
-  char *result;
-  char *result_ret;
-  STRLEN len;
-  SV *result_sv;
-
-  dTHX;
-
-  dSP;
-
-  ENTER;
-  SAVETMPS;
-
-  PUSHMARK(SP);
-  EXTEND(SP, 3);
+  PUSHs(sv_2mortal (newSVpv_byte (file_path, 0)));
 
-  PUSHs(sv_2mortal (newSVpv_utf8 (string, 0)));
-  PUSHs(sv_2mortal (newSVpv_utf8 (in_lang, 0)));
-  PUSHs(sv_2mortal (newSVpv_utf8 (translation_context, 0)));
   PUTBACK;
 
-  count = call_pv (
-    "Texinfo::Translations::translate_string",
-    G_SCALAR);
+  count = call_pv ("Texinfo::Config::GNUT_load_init_file",
+                   G_VOID);
 
   SPAGAIN;
 
-  if (count != 1)
-    croak ("translate_string should return 1 item\n");
-
-  result_sv = POPs;
-  result_ret = SvPVutf8 (result_sv, len);
-  result = non_perl_strndup (result_ret, len);
+  if (count != 0)
+    croak ("Texinfo::Config::GNUT_load_init_file should not return 
anything\n");
 
   PUTBACK;
 
   FREETMPS;
   LEAVE;
-
-  return result;
 }
 
-const void *
-call_setup_collator (int use_unicode_collation, const char *locale_lang)
+CONVERTER *
+call_convert_converter (const char *module_name,
+                        const DEPRECATED_DIRS_LIST *deprecated_directories,
+                        const OPTIONS_LIST *converter_options)
 {
+  SV *options_list_sv;
   int count;
-  const void *result = 0;
-  SV *collator_sv = 0;
-
+  CONVERTER *result;
+  SV *result_sv;
+  
   dTHX;
+  
+  options_list_sv
+    = build_sv_options_from_options_list (converter_options, 0);
 
   dSP;
 
-  ENTER;
+  ENTER; 
   SAVETMPS;
 
   PUSHMARK(SP);
   EXTEND(SP, 2);
 
-  PUSHs(sv_2mortal (newSViv (use_unicode_collation)));
-  PUSHs(sv_2mortal (newSVpv (locale_lang, 0)));
+  SvREFCNT_inc (options_list_sv);
 
+  PUSHs(sv_2mortal (newSVpv (module_name, 0)));
+  PUSHs(sv_2mortal (options_list_sv));
   PUTBACK;
 
-  count = call_pv ("Texinfo::Indices::_setup_collator",
-                   G_SCALAR);
+  count = call_method ("converter",
+                       G_SCALAR);
 
   SPAGAIN;
 
   if (count != 1)
-    croak ("_setup_collator should return 1 item\n");
+    croak ("call_convert_converter should return 1 item\n");
 
-  collator_sv = POPs;
-  if (SvOK (collator_sv))
-    {
-      SvREFCNT_inc (collator_sv);
-      result = (const void *) collator_sv;
-    }
+  result_sv = POPs;
+  result = get_sv_converter (result_sv, "call_convert_converter");
 
   PUTBACK;
 
@@ -221,45 +124,55 @@ call_setup_collator (int use_unicode_collation, const 
char *locale_lang)
   return result;
 }
 
-BYTES_STRING *
-call_collator_getSortKey (const void *collator_sv, const char *string)
+/* FIXME it would probably be better to be able to keep the converter
+   SV to keep the blessing information instead of needing the module name */
+char *
+call_converter_output (const char *module_name, CONVERTER *self,
+                       DOCUMENT *document)
 {
-  BYTES_STRING *result;
-  unsigned char *result_ret;
+  SV *document_sv;
+  SV *converter_sv;
+  int count;
+  char *result;
+  const char *result_ret;
   STRLEN len;
   SV *result_sv;
-  int count;
-
+  HV *hv_stash;
+  
   dTHX;
+  
+  document_sv = get_document (document->descriptor);
+  SvREFCNT_inc (document_sv);
+
+  converter_sv = newRV_inc (self->hv);
+  SvREFCNT_inc (converter_sv);
+
+  hv_stash = gv_stashpv (module_name, 0);
+  sv_bless (converter_sv, hv_stash);
 
-  result = (BYTES_STRING *) non_perl_malloc (sizeof (BYTES_STRING));
   dSP;
 
-  ENTER;
+  ENTER; 
   SAVETMPS;
 
   PUSHMARK(SP);
   EXTEND(SP, 2);
 
-  PUSHs((SV *) collator_sv);
-  PUSHs(sv_2mortal (newSVpv_utf8 (string, 0)));
-
+  PUSHs(sv_2mortal (converter_sv));
+  PUSHs(sv_2mortal (document_sv));
   PUTBACK;
 
-  count = call_method ("getSortKey",
+  count = call_method ("output",
                        G_SCALAR);
 
   SPAGAIN;
 
   if (count != 1)
-    croak ("getSortKey should return 1 item\n");
+    croak ("call_output should return 1 item\n");
 
   result_sv = POPs;
-  result_ret = (unsigned char *)SvPVbyte (result_sv, len);
-  result->len = (size_t) len;
-  result->bytes = (unsigned char *)
-    non_perl_malloc (sizeof (unsigned char) * len);
-  memcpy (result->bytes, result_ret, result->len);
+  result_ret = SvPVutf8 (result_sv, len);
+  result = non_perl_strndup (result_ret, len);
 
   PUTBACK;
 
@@ -269,49 +182,6 @@ call_collator_getSortKey (const void *collator_sv, const 
char *string)
   return result;
 }
 
-static int texinfo_convert_html_module_loaded;
-
-void
-call_config_GNUT_load_init_file (const char *file_path)
-{
-  int count;
-
-  dTHX;
-
-  if (!texinfo_convert_html_module_loaded)
-    {
-      eval_pv ("use Texinfo::Convert::HTML;", TRUE);
-      texinfo_convert_html_module_loaded = 1;
-    }
-
-  dSP;
-
-  ENTER;
-  SAVETMPS;
-
-  PUSHMARK(SP);
-  EXTEND(SP, 1);
-
-  PUSHs(sv_2mortal (newSVpv_byte (file_path, 0)));
-
-  PUTBACK;
-
-  count = call_pv ("Texinfo::Config::GNUT_load_init_file",
-                   G_VOID);
-
-  SPAGAIN;
-
-  if (count != 0)
-    croak ("Texinfo::Config::GNUT_load_init_file should not return 
anything\n");
-
-  PUTBACK;
-
-  FREETMPS;
-  LEAVE;
-}
-
-
-
 /* following is used to embed a Perl interpreter */
 static PerlInterpreter *my_perl;
 
diff --git a/tp/Texinfo/XS/convert/call_conversion_perl.h 
b/tp/Texinfo/XS/convert/call_conversion_perl.h
new file mode 100644
index 0000000000..5528e4df90
--- /dev/null
+++ b/tp/Texinfo/XS/convert/call_conversion_perl.h
@@ -0,0 +1,20 @@
+/* call_conversion_perl.h - API to interact with embedded perl from C code */
+#ifndef CALL_CONVERSION_PERL_H
+#define CALL_CONVERSION_PERL_H
+
+#include "tree_types.h"
+#include "document_types.h"
+#include "converter_types.h"
+
+CONVERTER *call_convert_converter (const char *module_name,
+                      const DEPRECATED_DIRS_LIST *deprecated_directories,
+                      const OPTIONS_LIST *converter_options);
+char *call_converter_output (const char *module_name, CONVERTER *self,
+                             DOCUMENT *document);
+
+void call_config_GNUT_load_init_file (const char *file_path);
+
+void call_init_perl (int *argc_ref, char ***argv_ref, char ***env_ref,
+                     char *load_txi_modules_path);
+void call_finish_perl (void);
+#endif
diff --git a/tp/Texinfo/XS/convert/call_html_perl_function.c 
b/tp/Texinfo/XS/convert/call_html_perl_function.c
index 8a000005d4..89a5feaf1e 100644
--- a/tp/Texinfo/XS/convert/call_html_perl_function.c
+++ b/tp/Texinfo/XS/convert/call_html_perl_function.c
@@ -36,8 +36,8 @@
 #include "xs_utils.h"
 /* for element_command_name (or could be builtin_command_data) */
 #include "builtin_commands.h"
-/* new_target_filename non_perl_strndup new_target_contents_filename
-   new_file_name_path new_target_directory_filename non_perl_free
+/* new_target_filename new_target_contents_filename
+   new_file_name_path new_target_directory_filename
    new_formatted_button_info output_unit_type_names enum output_unit_type
  */
 #include "utils.h"
diff --git a/tp/Texinfo/XS/convert/converter.c 
b/tp/Texinfo/XS/convert/converter.c
index 55b39fab22..6b5c72e4a7 100644
--- a/tp/Texinfo/XS/convert/converter.c
+++ b/tp/Texinfo/XS/convert/converter.c
@@ -61,6 +61,7 @@
 #include "manipulate_indices.h"
 #include "document.h"
 #include "html_converter_api.h"
+#include "api_to_perl.h"
 #include "converter.h"
 
 /* table used to dispatch format specific functions.
@@ -1827,6 +1828,9 @@ free_generic_converter (CONVERTER *self)
   wipe_error_message_list (&self->error_messages);
 
   free_strings_list (&self->small_strings);
+
+  if (self->hv)
+    register_perl_data (self->hv);
 }
 
 void
diff --git a/tp/Texinfo/XS/main/call_perl_function.c 
b/tp/Texinfo/XS/main/call_perl_function.c
index 2f16c0e856..cb44c0d917 100644
--- a/tp/Texinfo/XS/main/call_perl_function.c
+++ b/tp/Texinfo/XS/main/call_perl_function.c
@@ -268,97 +268,3 @@ call_collator_getSortKey (const void *collator_sv, const 
char *string)
 
   return result;
 }
-
-static int texinfo_convert_html_module_loaded;
-
-void
-call_config_GNUT_load_init_file (const char *file_path)
-{
-  int count;
-
-  dTHX;
-
-  if (!texinfo_convert_html_module_loaded)
-    {
-      eval_pv ("use Texinfo::Convert::HTML;", TRUE);
-      texinfo_convert_html_module_loaded = 1;
-    }
-
-  dSP;
-
-  ENTER;
-  SAVETMPS;
-
-  PUSHMARK(SP);
-  EXTEND(SP, 1);
-
-  PUSHs(sv_2mortal (newSVpv_byte (file_path, 0)));
-
-  PUTBACK;
-
-  count = call_pv ("Texinfo::Config::GNUT_load_init_file",
-                   G_VOID);
-
-  SPAGAIN;
-
-  if (count != 0)
-    croak ("Texinfo::Config::GNUT_load_init_file should not return 
anything\n");
-
-  PUTBACK;
-
-  FREETMPS;
-  LEAVE;
-}
-
-
-
-/* following is used to embed a Perl interpreter */
-static PerlInterpreter *my_perl;
-
-/* this is somewhat magic, but it works; obtained according to perlembed with
-  perl -MExtUtils::Embed -e xsinit -- -o perlxsi.c
- */
-
-EXTERN_C void xs_init (pTHX);
-
-EXTERN_C void boot_DynaLoader (pTHX_ CV* cv);
-
-EXTERN_C void
-xs_init(pTHX)
-{
-    static const char file[] = __FILE__;
-    dXSUB_SYS;
-    PERL_UNUSED_CONTEXT;
-
-    /* DynaLoader is a special case */
-    newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
-}
-
-/* load a Perl intperpreter and load Texinfo modules.  To be called once */
-void
-call_init_perl (int *argc_ref, char ***argv_ref, char ***env_ref,
-                char *load_txi_modules_path)
-{
-  char *embedding[] = { "", load_txi_modules_path };
-  /* The need and use of arguments of PERL_SYS_INIT3 are not explained
-     clearly anywhere.  In perlembed they seem to be mandatory, but
-     there is nothing very explicit.  We follow perlembed:
-   PERL_SYS_INIT3() must be invoked on the C main() argc, argv and env and 
only once.
-   */
-  /* PERL_SYS_INIT3(&argc,&argv,&env); */
-  PERL_SYS_INIT3 (argc_ref, argv_ref, env_ref);
-  /* PERL_SYS_INIT3((int *)NULL,(char ***)NULL,(char ***)NULL); */
-  my_perl = perl_alloc();
-  perl_construct(my_perl);
-  PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
-  perl_parse(my_perl, xs_init, 2, embedding, (char **)NULL);
-  /* perl_run(my_perl); */
-}
-
-void
-call_finish_perl (void)
-{
-  perl_destruct(my_perl);
-  perl_free(my_perl);
-  PERL_SYS_TERM();
-}
diff --git a/tp/Texinfo/XS/main/call_perl_function.h 
b/tp/Texinfo/XS/main/call_perl_function.h
index 6a856d2846..845aaf0f70 100644
--- a/tp/Texinfo/XS/main/call_perl_function.h
+++ b/tp/Texinfo/XS/main/call_perl_function.h
@@ -20,9 +20,4 @@ const void *call_setup_collator (int use_unicode_collation,
 BYTES_STRING *call_collator_getSortKey (const void *collator_sv,
                                         const char *string);
 
-void call_config_GNUT_load_init_file (const char *file_path);
-
-void call_init_perl (int *argc_ref, char ***argv_ref, char ***env_ref,
-                     char *load_txi_modules_path);
-void call_finish_perl (void);
 #endif
diff --git a/tp/Texinfo/XS/teximakehtml.c b/tp/Texinfo/XS/teximakehtml.c
index 86f0c27c07..21550d2a87 100644
--- a/tp/Texinfo/XS/teximakehtml.c
+++ b/tp/Texinfo/XS/teximakehtml.c
@@ -66,7 +66,7 @@
 #include "texinfo.h"
 
 #ifdef EMBED_PERL
-#include "call_perl_function.h"
+#include "call_conversion_perl.h"
 #endif
 
 #define LOCALEDIR DATADIR "/locale"
@@ -99,6 +99,8 @@ typedef struct FORMAT_SPECIFICATION {
     const char *name;
     unsigned long flags;
     const char *converted_format;
+    /* Perl module name */
+    const char *module;
 } FORMAT_SPECIFICATION;
 
 static FORMAT_SPECIFICATION formats_table[] = {
@@ -106,10 +108,11 @@ static FORMAT_SPECIFICATION formats_table[] = {
            | STTF_move_index_entries_after_items
            | STTF_no_warn_non_empty_parts
            | STTF_nodes_tree | STTF_floats | STTF_split
-           | STTF_setup_index_entries_sort_strings, NULL},
-  {"parse", 0, NULL},
-  {"structure", STTF_nodes_tree | STTF_floats | STTF_split, NULL},
-  {NULL, 0, NULL}
+           | STTF_setup_index_entries_sort_strings,
+   NULL, "Texinfo::Convert::HTML"},
+  {"parse", 0, NULL, NULL},
+  {"structure", STTF_nodes_tree | STTF_floats | STTF_split, NULL, NULL},
+  {NULL, 0, NULL, NULL}
 };
 
 static VALUE_LIST values;
@@ -750,6 +753,8 @@ warn_deprecated_dirs (DEPRECATED_DIRS_LIST 
*deprecated_dirs_used)
   deprecated_dirs_used->number = 0;
 }
 
+int loaded_init_files_nr = 0;
+
 static void
 locate_and_load_init_file (const char *filename, STRING_LIST *directories,
                            DEPRECATED_DIRS_LIST *deprecated_dirs)
@@ -765,6 +770,7 @@ locate_and_load_init_file (const char *filename, 
STRING_LIST *directories,
       if (embedded_interpreter)
         {
           call_config_GNUT_load_init_file (file);
+          loaded_init_files_nr++;
         }
       else
 #endif
@@ -2233,15 +2239,31 @@ main (int argc, char *argv[], char *env[])
       copy_strings (converter_texinfo_language_config_dirs,
                     texinfo_language_config_dirs);
 
-      converter = txi_converter_setup (converted_format, output_format,
-                                   &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,
+                                              &deprecated_directories,
+                                              &convert_options);
 
+          result = call_converter_output (format_specification->module,
+                                          converter, document);
+        }
+      else
+#endif
+        {
+          converter = txi_converter_setup (converted_format, output_format,
+                                           &deprecated_directories,
+                                           &convert_options);
 
       /* 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 (converter, document);
+        }
       free (result);
 
       errors_count



reply via email to

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