texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Mon, 30 Sep 2024 16:51:57 -0400 (EDT)

branch: master
commit 5907aaf7da6a1cf7e6bd23eddcda38ab40890a56
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Tue Jul 23 10:18:35 2024 +0200

    * tp/Texinfo/XS/convert/ConvertXS.xs (init),
    tp/Texinfo/XS/convert/converter.c (setup_converter_paths_information),
    tp/Texinfo/XS/convert/converter.h (INSTALLED_PATHS, UNINSTALLED_PATHS)
    (PATHS_INFORMATION), tp/Texinfo/XS/main/build_perl_info.c (init),
    tp/Texinfo/XS/parsetexi/Parsetexi.xs (init), tp/Texinfo/XSLoader.pm
    (init): exchange second and third paths argument of init called from
    XSLoader.pm and setup_converter_paths_information for more logical
    groupings.  Consider paths in XS init functions as SV * as some are
    necessarily undef.  In ConvertXS.xs init, convert only some SV * path
    to char based on texinfo_uninstalled, other remain NULL.  Modify
    PATHS_INFORMATION struct to ba a union of INSTALLED_PATHS and
    UNINSTALLED_PATHS.  Setup conversion_paths_information accordingly in
    setup_converter_paths_information.
---
 ChangeLog                            | 20 ++++++++++++++++++--
 tp/Texinfo/XS/convert/ConvertXS.xs   | 22 ++++++++++++++++------
 tp/Texinfo/XS/convert/converter.c    | 16 +++++++++++++---
 tp/Texinfo/XS/convert/converter.h    | 16 +++++++++++++---
 tp/Texinfo/XS/main/build_perl_info.c |  4 ++--
 tp/Texinfo/XS/main/build_perl_info.h |  4 ++--
 tp/Texinfo/XS/parsetexi/Parsetexi.xs |  7 ++-----
 tp/Texinfo/XSLoader.pm               |  2 +-
 8 files changed, 67 insertions(+), 24 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 5e7e3ba316..99f27219f5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,18 @@
 2024-07-23  Patrice Dumas  <pertusus@free.fr>
 
-       * tp/Texinfo/XS/TestXS.xs (PREFIX, xstest_init): use xstest_ as
-       prefix.  Update xstest_init call.
+       * tp/Texinfo/XS/convert/ConvertXS.xs (init),
+       tp/Texinfo/XS/convert/converter.c (setup_converter_paths_information),
+       tp/Texinfo/XS/convert/converter.h (INSTALLED_PATHS, UNINSTALLED_PATHS)
+       (PATHS_INFORMATION), tp/Texinfo/XS/main/build_perl_info.c (init),
+       tp/Texinfo/XS/parsetexi/Parsetexi.xs (init), tp/Texinfo/XSLoader.pm
+       (init): exchange second and third paths argument of init called from
+       XSLoader.pm and setup_converter_paths_information for more logical
+       groupings.  Consider paths in XS init functions as SV * as some are
+       necessarily undef.  In ConvertXS.xs init, convert only some SV * path
+       to char based on texinfo_uninstalled, other remain NULL.  Modify
+       PATHS_INFORMATION struct to ba a union of INSTALLED_PATHS and
+       UNINSTALLED_PATHS.  Setup conversion_paths_information accordingly in
+       setup_converter_paths_information.
 
 2024-07-22  Patrice Dumas  <pertusus@free.fr>
 
@@ -12,6 +23,11 @@
        variable conversion_paths_information.  Fill the paths with
        setup_converter_paths_information called from ConvertXS.xs init.
 
+2024-07-23  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/TestXS.xs (PREFIX, xstest_init): use xstest_ as
+       prefix.  Update xstest_init call.
+
 2024-07-22  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/convert/ConvertXS.xs (init),
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs 
b/tp/Texinfo/XS/convert/ConvertXS.xs
index 0a92b381f9..ba056d19d9 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -65,15 +65,25 @@ MODULE = Texinfo::Convert::ConvertXS        PACKAGE = 
Texinfo::Convert::ConvertXS
 PROTOTYPES: ENABLE
 
 # Called from Texinfo::XSLoader.pm.
-# File paths can be in any encoding
+# File paths are byte strings and can be in any encoding.
 int
-init (int texinfo_uninstalled, tp_builddir, pkgdatadir, top_srcdir)
-     const char *tp_builddir = (const char *)SvPVbyte_nolen ($arg);
-     const char *pkgdatadir = (const char *)SvPVbyte_nolen ($arg);
-     const char *top_srcdir = (const char *)SvPVbyte_nolen ($arg);
+init (int texinfo_uninstalled, SV *pkgdatadir_sv, SV *tp_builddir_sv, SV 
*top_srcdir_sv)
+      PREINIT:
+        const char *tp_builddir = 0;
+        const char *top_srcdir = 0;
+        const char *pkgdatadir = 0;
       CODE:
+        if (texinfo_uninstalled)
+          {
+            if (SvOK (tp_builddir_sv))
+              tp_builddir = SvPVbyte_nolen (tp_builddir_sv);
+            if (SvOK (top_srcdir_sv))
+              top_srcdir = SvPVbyte_nolen (top_srcdir_sv);
+          }
+        else
+          pkgdatadir = SvPVbyte_nolen (pkgdatadir_sv);
         setup_converter_paths_information (texinfo_uninstalled,
-                             tp_builddir, pkgdatadir, top_srcdir);
+                             pkgdatadir, tp_builddir, top_srcdir);
         set_element_type_name_info ();
         converter_setup ();
         RETVAL = 1;
diff --git a/tp/Texinfo/XS/convert/converter.c 
b/tp/Texinfo/XS/convert/converter.c
index 280a0041a9..19871bccde 100644
--- a/tp/Texinfo/XS/convert/converter.c
+++ b/tp/Texinfo/XS/convert/converter.c
@@ -100,10 +100,20 @@ setup_converter_paths_information (int 
texinfo_uninstalled,
                                    const char *tp_builddir,
                              const char *pkgdatadir, const char *top_srcdir)
 {
+  memset (&conversion_paths_information, 0, sizeof (PATHS_INFORMATION));
   conversion_paths_information.texinfo_uninstalled = texinfo_uninstalled;
-  conversion_paths_information.tp_builddir = strdup (tp_builddir);
-  conversion_paths_information.pkgdatadir = strdup (pkgdatadir);
-  conversion_paths_information.top_srcdir = strdup (top_srcdir);
+  if (texinfo_uninstalled)
+    {
+      if (tp_builddir)
+        conversion_paths_information.paths.uninstalled.tp_builddir
+          = strdup (tp_builddir);
+      if (top_srcdir)
+        conversion_paths_information.paths.uninstalled.top_srcdir
+          = strdup (top_srcdir);
+    }
+  else
+    conversion_paths_information.paths.installed.pkgdatadir
+      = strdup (pkgdatadir);
 }
 
 CONVERTER *
diff --git a/tp/Texinfo/XS/convert/converter.h 
b/tp/Texinfo/XS/convert/converter.h
index 4af4203cae..78e0201968 100644
--- a/tp/Texinfo/XS/convert/converter.h
+++ b/tp/Texinfo/XS/convert/converter.h
@@ -71,11 +71,21 @@ typedef struct FLOAT_CAPTION_PREPENDED_ELEMENT {
     ELEMENT *prepended;
 } FLOAT_CAPTION_PREPENDED_ELEMENT;
 
-typedef struct PATHS_INFORMATION {
-    int texinfo_uninstalled;
-    const char *tp_builddir;
+typedef struct INSTALLED_PATHS {
     const char *pkgdatadir;
+} INSTALLED_PATHS;
+
+typedef struct UNINSTALLED_PATHS {
+    const char *tp_builddir;
     const char *top_srcdir;
+} UNINSTALLED_PATHS;
+
+typedef struct PATHS_INFORMATION {
+    int texinfo_uninstalled;
+    union paths {
+      INSTALLED_PATHS installed;
+      UNINSTALLED_PATHS uninstalled;
+    } paths;
 } PATHS_INFORMATION;
 
 extern enum command_id no_brace_command_accent_upper_case[][2];
diff --git a/tp/Texinfo/XS/main/build_perl_info.c 
b/tp/Texinfo/XS/main/build_perl_info.c
index c609a628a5..b52f358fca 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -131,8 +131,8 @@ perl_only_strndup (const char *s, size_t n)
 }
 
 int
-init (int texinfo_uninstalled, const char *builddir,
-      const char *pkgdatadir, const char *top_srcdir)
+init (int texinfo_uninstalled, SV *pkgdatadir_sv, SV *builddir_sv,
+      SV *top_srcdir_sv)
 {
 #ifdef ENABLE_NLS
 
diff --git a/tp/Texinfo/XS/main/build_perl_info.h 
b/tp/Texinfo/XS/main/build_perl_info.h
index 0524ae04d2..2ab285f712 100644
--- a/tp/Texinfo/XS/main/build_perl_info.h
+++ b/tp/Texinfo/XS/main/build_perl_info.h
@@ -20,8 +20,8 @@ void *perl_only_malloc (size_t size);
 char *perl_only_strdup (const char *s);
 char *perl_only_strndup (const char *s, size_t n);
 
-int init (int texinfo_uninstalled, const char *tp_builddir,
-          const char *pkgdatadir, const char *top_srcdir);
+int init (int texinfo_uninstalled, SV *pkgdatadir_sv, SV *builddir_sv,
+          SV *top_srcdir_sv);
 
 /* in options_get_perl.c */
 SV *build_sv_option (const OPTIONS *options, const char *key,
diff --git a/tp/Texinfo/XS/parsetexi/Parsetexi.xs 
b/tp/Texinfo/XS/parsetexi/Parsetexi.xs
index dc24b4e960..e24f90592b 100644
--- a/tp/Texinfo/XS/parsetexi/Parsetexi.xs
+++ b/tp/Texinfo/XS/parsetexi/Parsetexi.xs
@@ -55,12 +55,9 @@ PROTOTYPES: ENABLE
 # and passed as byte strings.
 
 # Called from Texinfo::XSLoader.pm.  The arguments are not actually used.
-# file path, can be in any encoding
+# File paths are byte strings and can be in any encoding.
 int
-init (int texinfo_uninstalled, tp_builddir, pkgdatadir, top_srcdir)
-     const char *tp_builddir = (const char *)SvPVbyte_nolen ($arg);
-     const char *pkgdatadir = (const char *)SvPVbyte_nolen ($arg);
-     const char *top_srcdir = (const char *)SvPVbyte_nolen ($arg);
+init (int texinfo_uninstalled, SV *pkgdatadir, SV *tp_builddir, SV *top_srcdir)
 
 void
 reset_parser (int debug_output)
diff --git a/tp/Texinfo/XSLoader.pm b/tp/Texinfo/XSLoader.pm
index f88c18bdb6..221a48d334 100644
--- a/tp/Texinfo/XSLoader.pm
+++ b/tp/Texinfo/XSLoader.pm
@@ -215,8 +215,8 @@ sub init {
 
   if (defined &{"${module}::init"}
       and !&{"${module}::init"} ($Texinfo::ModulePath::texinfo_uninstalled,
-                                 $Texinfo::ModulePath::tp_builddir,
                                  $Texinfo::ModulePath::pkgdatadir,
+                                 $Texinfo::ModulePath::tp_builddir,
                                  $Texinfo::ModulePath::top_srcdir)) {
     _fatal "$module_name: error initializing";
     goto FALLBACK;



reply via email to

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