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

branch: master
commit b5f703ae4247eaa7fb290e80595f00fd3ba920bc
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Dec 23 17:23:14 2024 +0100

    * tp/Texinfo/XS/convert/call_conversion_perl.c (call_init_perl),
    tp/Texinfo/XS/teximakehtml.c (main): call perl_run to have
    load_txi_modules.pl executed.  Report and check statuses.
    
    * tp/Texinfo/XS/teximakehtml.c (main): put init files in a list when
    they appear on the command line and load them only after the embedded
    interpreter has been loaded.
---
 ChangeLog                                    | 10 ++++++
 tp/Texinfo/XS/convert/call_conversion_perl.c | 20 ++++++++---
 tp/Texinfo/XS/convert/call_conversion_perl.h |  4 +--
 tp/Texinfo/XS/teximakehtml.c                 | 54 ++++++++++++++++++----------
 4 files changed, 64 insertions(+), 24 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1dd3bcd754..a8a0e4ecc8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2024-12-23  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/convert/call_conversion_perl.c (call_init_perl),
+       tp/Texinfo/XS/teximakehtml.c (main): call perl_run to have
+       load_txi_modules.pl executed.  Report and check statuses.
+
+       * tp/Texinfo/XS/teximakehtml.c (main): put init files in a list when
+       they appear on the command line and load them only after the embedded
+       interpreter has been loaded.
+
 2024-12-23  Patrice Dumas  <pertusus@free.fr>
 
        * tp/load_txi_modules.pl (BEGIN): load Texinfo::XSLoader in BEGIN
diff --git a/tp/Texinfo/XS/convert/call_conversion_perl.c 
b/tp/Texinfo/XS/convert/call_conversion_perl.c
index 8e242b0aa8..0c8d57c326 100644
--- a/tp/Texinfo/XS/convert/call_conversion_perl.c
+++ b/tp/Texinfo/XS/convert/call_conversion_perl.c
@@ -205,11 +205,12 @@ xs_init(pTHX)
 }
 
 /* load a Perl intperpreter and load Texinfo modules.  To be called once */
-void
+int
 call_init_perl (int *argc_ref, char ***argv_ref, char ***env_ref,
                 char *load_txi_modules_path)
 {
-  char *embedding[] = { "", load_txi_modules_path };
+  int parse_status, run_status;
+  char *embedding[] = { "", load_txi_modules_path, NULL };
   /* 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:
@@ -221,8 +222,19 @@ call_init_perl (int *argc_ref, char ***argv_ref, char 
***env_ref,
   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); */
+  parse_status = perl_parse(my_perl, xs_init, 2, embedding, (char **)NULL);
+  if (parse_status)
+    return parse_status;
+  /*
+  fprintf (stderr, "call_init_perl parse_status: %d\n", parse_status);
+   */
+  run_status = perl_run(my_perl);
+  /*
+  fprintf (stderr, "call_init_perl run_status: %d\n", run_status);
+   */
+  if (run_status)
+    return run_status;
+  return 0;
 }
 
 void
diff --git a/tp/Texinfo/XS/convert/call_conversion_perl.h 
b/tp/Texinfo/XS/convert/call_conversion_perl.h
index 11984689f5..0545773402 100644
--- a/tp/Texinfo/XS/convert/call_conversion_perl.h
+++ b/tp/Texinfo/XS/convert/call_conversion_perl.h
@@ -13,7 +13,7 @@ char *call_converter_output (const char *module_name, 
CONVERTER *self,
 
 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);
+int 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 2b8192cf5c..6c88c5e8d2 100644
--- a/tp/Texinfo/XS/teximakehtml.c
+++ b/tp/Texinfo/XS/teximakehtml.c
@@ -994,6 +994,8 @@ main (int argc, char *argv[], char *env[])
   STRING_LIST converter_init_dirs;
   STRING_LIST *converter_config_dirs_array_ref;
   STRING_LIST internal_extension_dirs;
+  STRING_LIST init_files;
+  STRING_LIST init_file_dirs;
   char *extensions_dir;
   char *texinfo_output_format_env;
   OPTION *output_format_option;
@@ -1146,6 +1148,7 @@ main (int argc, char *argv[], char *env[])
 
 
   memset (&ignored_formats, 0, sizeof (STRING_LIST));
+  memset (&init_files, 0, sizeof (STRING_LIST));
 
   initialize_options_list (&init_files_options);
 
@@ -1325,23 +1328,7 @@ main (int argc, char *argv[], char *env[])
           print_help_p = 1;
           break;
         case INIT_FILE_OPT:
-          {
-            OPTION *test_option
-              = get_conf (program_options.options->TEST.number);
-            if (test_option && test_option->o.integer > 0)
-              locate_and_load_init_file (optarg, &conf_dirs, 0);
-            else
-              {
-                static STRING_LIST init_file_dirs;
-                copy_strings (&init_file_dirs, &conf_dirs);
-                copy_strings (&init_file_dirs, &converter_init_dirs);
-                locate_and_load_init_file (optarg, &init_file_dirs,
-                                           &deprecated_directories);
-
-                clear_strings_list (&init_file_dirs);
-              }
-
-          }
+          add_string (optarg, &init_files);
           break;
         case 'D':
           {
@@ -1780,6 +1767,7 @@ main (int argc, char *argv[], char *env[])
     {/* 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,
@@ -1788,11 +1776,40 @@ main (int argc, char *argv[], char *env[])
         xasprintf (&load_modules_path, "%s/%s",
                   conversion_paths_info.p.installed.converterdatadir,
                    load_txi_modules_basename);
-      call_init_perl (&argc, &argv, &env, load_modules_path);
+      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
 
+  /* TODO different from Perl, to be discussed on the list which
+     one is better, load within the command line loop, or after */
+  memset (&init_file_dirs, 0, sizeof (STRING_LIST));
+
+  test_option = get_conf (program_options.options->TEST.number);
+  if (test_option && test_option->o.integer > 0)
+    test_mode_set = 1;
+
+  if (!test_mode_set)
+    {
+      copy_strings (&init_file_dirs, &conf_dirs);
+      copy_strings (&init_file_dirs, &converter_init_dirs);
+    }
+
+  for (i = 0; i < init_files.number; i++)
+    {
+      char *init_file = init_files.list[i];
+      if (test_mode_set)
+        locate_and_load_init_file (init_file, &conf_dirs, 0);
+      else
+        locate_and_load_init_file (init_file, &init_file_dirs,
+                                   &deprecated_directories);
+    }
+
+  free_strings_list (&init_file_dirs);
+  free_strings_list (&init_files);
+
   html_math_option = get_conf (program_options.options->HTML_MATH.number);
   if (html_math_option && html_math_option->o.string
       && !strcmp (html_math_option->o.string, "l2h"))
@@ -1809,6 +1826,7 @@ main (int argc, char *argv[], char *env[])
     locate_and_load_extension_file ("highlight_syntax.pm",
                                     &internal_extension_dirs);
 
+  /* re-set in case it was set in init files */
   test_option = get_conf (program_options.options->TEST.number);
   if (test_option && test_option->o.integer > 0)
     test_mode_set = 1;



reply via email to

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