[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Tue, 24 Dec 2024 03:44:25 -0500 (EST) |
branch: master
commit b54816f76aff95e0d202169a7a6f52028749947f
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Dec 23 19:52:07 2024 +0100
* tp/Texinfo/XS/convert/converter.c (free_converter_paths_information)
(setup_converter_paths_information), tp/Texinfo/XS/convert/converter.h
(INSTALLED_PATHS, UNINSTALLED_PATHS): add
free_converter_paths_information. Free previous conversion_paths_info
before setting them in setup_converter_paths_information.
* tp/Texinfo/XS/convert/converter.c (converter_setup): the function
can be called twice if called both from C and from a Perl converter
modules initialization called from C. Add a variable to avoid running
twice the code except for setting paths.
---
ChangeLog | 13 +++++++++++
tp/Texinfo/XS/convert/converter.c | 45 +++++++++++++++++++++++++++++++++------
tp/Texinfo/XS/convert/converter.h | 6 +++---
3 files changed, 54 insertions(+), 10 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index a13c04e989..9d09a27049 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2024-12-23 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/convert/converter.c (free_converter_paths_information)
+ (setup_converter_paths_information), tp/Texinfo/XS/convert/converter.h
+ (INSTALLED_PATHS, UNINSTALLED_PATHS): add
+ free_converter_paths_information. Free previous conversion_paths_info
+ before setting them in setup_converter_paths_information.
+
+ * tp/Texinfo/XS/convert/converter.c (converter_setup): the function
+ can be called twice if called both from C and from a Perl converter
+ modules initialization called from C. Add a variable to avoid running
+ twice the code except for setting paths.
+
2024-12-23 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/teximakehtml.c (locate_and_load_init_file)
diff --git a/tp/Texinfo/XS/convert/converter.c
b/tp/Texinfo/XS/convert/converter.c
index 4e0d4c5604..333d93d04c 100644
--- a/tp/Texinfo/XS/convert/converter.c
+++ b/tp/Texinfo/XS/convert/converter.c
@@ -117,32 +117,58 @@ PATHS_INFORMATION conversion_paths_info;
const char *xml_text_entity_no_arg_commands_formatting[BUILTIN_CMD_NUMBER];
+static void
+free_converter_paths_information (PATHS_INFORMATION *paths_info)
+{
+ if (paths_info->texinfo_uninstalled)
+ {
+ free (paths_info->p.uninstalled.tp_builddir);
+ free (paths_info->p.uninstalled.top_srcdir);
+ }
+ else
+ free (paths_info->p.installed.converterdatadir);
+}
+
static void
setup_converter_paths_information (int texinfo_uninstalled,
const char *converterdatadir,
const char *tp_builddir,
const char *top_srcdir)
{
+ free_converter_paths_information (&conversion_paths_info);
memset (&conversion_paths_info, 0, sizeof (PATHS_INFORMATION));
conversion_paths_info.texinfo_uninstalled = texinfo_uninstalled;
if (texinfo_uninstalled)
{
if (tp_builddir)
- conversion_paths_info.p.uninstalled.tp_builddir
- = strdup (tp_builddir);
+ {
+ conversion_paths_info.p.uninstalled.tp_builddir
+ = strdup (tp_builddir);
+ }
if (top_srcdir)
- conversion_paths_info.p.uninstalled.top_srcdir
- = strdup (top_srcdir);
+ {
+ conversion_paths_info.p.uninstalled.top_srcdir
+ = strdup (top_srcdir);
+ }
}
else
{
if (converterdatadir)
- conversion_paths_info.p.installed.converterdatadir
- = strdup (converterdatadir);
+ {
+ conversion_paths_info.p.installed.converterdatadir
+ = strdup (converterdatadir);
+ }
}
}
-/* called only once */
+static int converter_setup_called;
+
+/* should be called only once. Except that it may be called both
+ from C and from an embedded Perl module initialization, so
+ use a variable to guard resetting anything else than paths */
+/* TODO do not call XS Modules init from XSLoader.pm if
+ $embedded_xs is set, under the assumption that the corresponding
+ code would already be called in C code? */
void
converter_setup (int texinfo_uninstalled, const char *converterdatadir,
const char *tp_builddir, const char *top_srcdir)
@@ -154,6 +180,11 @@ converter_setup (int texinfo_uninstalled, const char
*converterdatadir,
setup_converter_paths_information (texinfo_uninstalled,
converterdatadir, tp_builddir, top_srcdir);
+ if (converter_setup_called)
+ return;
+
+ converter_setup_called = 1;
+
set_element_type_name_info ();
txi_initialise_base_options ();
diff --git a/tp/Texinfo/XS/convert/converter.h
b/tp/Texinfo/XS/convert/converter.h
index 4cd21c0fbb..63a20f9cfc 100644
--- a/tp/Texinfo/XS/convert/converter.h
+++ b/tp/Texinfo/XS/convert/converter.h
@@ -74,12 +74,12 @@ typedef struct FLOAT_CAPTION_PREPENDED_ELEMENT {
} FLOAT_CAPTION_PREPENDED_ELEMENT;
typedef struct INSTALLED_PATHS {
- const char *converterdatadir;
+ char *converterdatadir;
} INSTALLED_PATHS;
typedef struct UNINSTALLED_PATHS {
- const char *tp_builddir;
- const char *top_srcdir;
+ char *tp_builddir;
+ char *top_srcdir;
} UNINSTALLED_PATHS;
typedef struct PATHS_INFORMATION {