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

branch: master
commit bb3623ddb79dfab16183e410bac1fbcc3a97ffd9
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Dec 22 18:40:30 2024 +0100

    * tp/Makefile.am (converterdata_SCRIPTS, load_txi_modules): install
    load_txi_modules.
    
    * tp/Texinfo/XS/main/call_perl_function.c (call_init_perl),
    tp/Texinfo/XS/teximakehtml.c (main): get file to load from
    call_init_perl caller.
    
    * tp/load_txi_modules.pl: add/remove loaded modules.
---
 ChangeLog                               | 11 +++++++++++
 tp/Makefile.am                          |  8 ++++++++
 tp/Texinfo/XS/main/call_perl_function.c | 14 ++++++--------
 tp/Texinfo/XS/main/call_perl_function.h |  3 ++-
 tp/Texinfo/XS/teximakehtml.c            | 29 +++++++++++++++++++++++++----
 tp/load_txi_modules.pl                  | 14 +++++++++-----
 6 files changed, 61 insertions(+), 18 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 27e1ff1ef2..5cecd13293 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2024-12-22  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Makefile.am (converterdata_SCRIPTS, load_txi_modules): install
+       load_txi_modules.
+
+       * tp/Texinfo/XS/main/call_perl_function.c (call_init_perl),
+       tp/Texinfo/XS/teximakehtml.c (main): get file to load from
+       call_init_perl caller.
+
+       * tp/load_txi_modules.pl: add/remove loaded modules.
+
 2024-12-22  Patrice Dumas  <pertusus@free.fr>
 
        ctexi2any C program for conversion to HTML with Perl embedding
diff --git a/tp/Makefile.am b/tp/Makefile.am
index 2854fa4d1b..9e1bbfe786 100644
--- a/tp/Makefile.am
+++ b/tp/Makefile.am
@@ -42,6 +42,8 @@ converterdatadir = $(datadir)/$(CONVERTER)
 
 bin_SCRIPTS = texi2any
 
+converterdata_SCRIPTS = load_txi_modules
+
 do_subst = sed \
   -e 's,[@]PACKAGE_VERSION[@],$(PACKAGE_VERSION),g' \
   -e 's,[@]PACKAGE_NAME[@],$(PACKAGE_NAME),g' \
@@ -64,6 +66,12 @@ texi2any: texi2any.pl $(top_builddir)/config.status
        $(do_subst) $(srcdir)/texi2any.pl >$@
        chmod a+x $@
 
+# the chmod may not be needed, but since the file is called by Perl, let's
+# be prudent
+load_txi_modules: load_txi_modules.pl $(top_builddir)/config.status
+       $(do_subst) $(srcdir)/load_txi_modules.pl >$@
+       chmod a+x $@
+
 makeinfo: texi2any
        rm -f $@
        -$(LN_S) texi2any $@
diff --git a/tp/Texinfo/XS/main/call_perl_function.c 
b/tp/Texinfo/XS/main/call_perl_function.c
index c1395a97d0..181ad55ead 100644
--- a/tp/Texinfo/XS/main/call_perl_function.c
+++ b/tp/Texinfo/XS/main/call_perl_function.c
@@ -281,16 +281,14 @@ xs_init(pTHX)
 }
 
 /* load a Perl intperpreter and load Texinfo modules.  To be called once */
-/* TODO "hide" load_txi_modules.pl in datadir/texi2any and pass the
-   path as call_init_perl argument, with a different name for in-source and
-   installed cases */
 void
-/* call_init_perl (int argc, char **argv, char **env) */
-call_init_perl (int *argc_ref, char ***argv_ref, char ***env_ref)
+call_init_perl (int *argc_ref, char ***argv_ref, char ***env_ref,
+                char *load_txi_modules_path)
 {
-  char *embedding[] = { "", "load_txi_modules.pl" };
-  /* The arguments of PERL_SYS_INIT3 are not explained clearly anywhere.
-     The only hint is in perlembed:
+  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); */
diff --git a/tp/Texinfo/XS/main/call_perl_function.h 
b/tp/Texinfo/XS/main/call_perl_function.h
index 140eb332e8..c57111e3da 100644
--- a/tp/Texinfo/XS/main/call_perl_function.h
+++ b/tp/Texinfo/XS/main/call_perl_function.h
@@ -20,6 +20,7 @@ const void *call_setup_collator (int use_unicode_collation,
 BYTES_STRING *call_collator_getSortKey (const void *collator_sv,
                                         const char *string);
 
-void call_init_perl (int *argc_ref, char ***argv_ref, char ***env_ref);
+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 93a8a381ab..9bcae6dc65 100644
--- a/tp/Texinfo/XS/teximakehtml.c
+++ b/tp/Texinfo/XS/teximakehtml.c
@@ -884,6 +884,12 @@ main (int argc, char *argv[], char *env[])
   int do_menu = 0;
   size_t format_menu_option_nr;
   char *conversion_format_menu_default = 0;
+  int texinfo_uninstalled = 1;
+  const char *converterdatadir = DATADIR "/" CONVERTER_CONFIG;
+  /* to avoid a warning on unused variable keep in ifdef */
+#ifdef EMBED_PERL
+  const char *load_txi_modules_basename = "load_txi_modules";
+#endif
   /* used to have different parameterization with embedded interpreter and
      without */
   int use_external_translate_string = -1;
@@ -914,12 +920,26 @@ main (int argc, char *argv[], char *env[])
   free (top_builddir);
 
 #ifdef EMBED_PERL
-  call_init_perl (&argc, &argv, &env);
   embedded_interpreter = 1;
-  use_external_translate_string = 0;
+  if (embedded_interpreter)
+    {/* setup paths here to avoid memory management as much as possible
+        in Perl C */
+      char *load_modules_path;
+      if (texinfo_uninstalled)
+        xasprintf (&load_modules_path, "%s/tp/%s.pl", top_srcdir,
+                                       load_txi_modules_basename);
+      else
+        xasprintf (&load_modules_path, "%s/%s",
+                   converterdatadir, load_txi_modules_basename);
+      call_init_perl (&argc, &argv, &env, load_modules_path);
+      free (load_modules_path);
+
+      use_external_translate_string = 0;
+    }
 #endif
 
-  txi_general_setup (1, 0, tp_builddir, top_srcdir,
+  txi_general_setup (texinfo_uninstalled, converterdatadir,
+                     tp_builddir, top_srcdir,
                      use_external_translate_string);
 
   free (tp_builddir);
@@ -2128,7 +2148,8 @@ main (int argc, char *argv[], char *env[])
   wipe_values (&values);
 
 #ifdef EMBED_PERL
-  call_finish_perl ();
+  if (embedded_interpreter)
+    call_finish_perl ();
 #endif
 
   if (errors_count > 0)
diff --git a/tp/load_txi_modules.pl b/tp/load_txi_modules.pl
index 67bbd24a42..cf86cb43a8 100755
--- a/tp/load_txi_modules.pl
+++ b/tp/load_txi_modules.pl
@@ -18,7 +18,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 # Trimmed down texi2any.pl that is used to load the modules when
-# Perl code is only called from C and no Perl script is run.
+# Perl code is directly called from C and no Perl script is run.
 
 use 5.006;
 
@@ -121,7 +121,6 @@ BEGIN {
 use Texinfo::XSLoader;
 
 use Locale::Messages;
-use Texinfo::Options;
 use Texinfo::Common;
 use Texinfo::Config;
 use Texinfo::Report;
@@ -274,9 +273,10 @@ foreach my $configured_variable 
(keys(%$configured_information)) {
                        $configured_information->{$configured_variable});
 }
 
+# next three modules are basic and used in call_perl_function.c
 use Texinfo::Translations;
-use Texinfo::Document;
-use Texinfo::Convert::Utils;
+use Texinfo::Convert::NodeNameNormalization;
+use Texinfo::Indices;
 
 if ($Texinfo::ModulePath::texinfo_uninstalled) {
   my $locales_dir = File::Spec->catdir($Texinfo::ModulePath::tp_builddir,
@@ -291,6 +291,10 @@ if ($Texinfo::ModulePath::texinfo_uninstalled) {
                               $strings_textdomain);
 }
 
-#use Texinfo::Convert::HTML;
+# useful modules the user can always assume to have.
+use Texinfo::ManipulateTree;
+use Texinfo::Document;
+use Texinfo::Convert::Texinfo;
+use Texinfo::Convert::Utils;
 
 1;



reply via email to

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