[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/XS/main/xs_utils.c (non_perl_*), tp
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/XS/main/xs_utils.c (non_perl_*), tp/Texinfo/XS/main/utils.c: move non_perl_* functions out of utils.c to xs_utils.c. |
Date: |
Thu, 14 Nov 2024 09:18:28 -0500 |
This is an automated email from the git hooks/post-receive script.
pertusus pushed a commit to branch master
in repository texinfo.
The following commit(s) were added to refs/heads/master by this push:
new 8197d2014e * tp/Texinfo/XS/main/xs_utils.c (non_perl_*),
tp/Texinfo/XS/main/utils.c: move non_perl_* functions out of utils.c to
xs_utils.c.
8197d2014e is described below
commit 8197d2014e0b6ad2b52263fc3584b1913e98c5fc
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Thu Nov 14 15:18:20 2024 +0100
* tp/Texinfo/XS/main/xs_utils.c (non_perl_*),
tp/Texinfo/XS/main/utils.c: move non_perl_* functions out of utils.c
to xs_utils.c.
* tp/Texinfo/XS/Makefile.am (noinst_LTLIBRARIES)
(libxsutils_la_SOURCES, libxs_in_libtexinfo_la_SOURCES)
(libxs_in_libtexinfo_la_CPPFLAGS, libtexinfo_la_CPPFLAGS)
(libtexinfoxs_la_LIBADD), tp/Texinfo/XS/main/call_perl_function.c,
tp/Texinfo/XS/main/api_to_perl.c: add libxsutils and
ibxs_in_libtexinfo convenience libraries to be able to use different
CPPFLAGS for compiltation. libxsutils contains only xs_utils and does
not require any CPPFLAGS. This allows to avoid including config.h
directly or indirectly in call_perl_function.c and api_to_perl.c and
be fully independent of gnulib and autoconf.
---
ChangeLog | 17 +++++++
tp/Texinfo/XS/Makefile.am | 46 ++++++++++++-----
tp/Texinfo/XS/convert/ConvertXS.xs | 4 +-
tp/Texinfo/XS/convert/call_html_perl_function.c | 2 +
tp/Texinfo/XS/convert/get_converter_perl_info.c | 2 +
tp/Texinfo/XS/convert/get_html_perl_info.c | 2 +
tp/Texinfo/XS/main/DocumentXS.xs | 5 +-
tp/Texinfo/XS/main/IndicesXS.xs | 3 +-
tp/Texinfo/XS/main/api_to_perl.c | 4 +-
tp/Texinfo/XS/main/build_perl_info.c | 2 +
tp/Texinfo/XS/main/call_perl_function.c | 8 +--
tp/Texinfo/XS/main/get_perl_info.c | 2 +
tp/Texinfo/XS/main/utils.c | 48 -----------------
tp/Texinfo/XS/main/utils.h | 7 ---
tp/Texinfo/XS/main/xs_utils.c | 68 +++++++++++++++++++++++++
tp/Texinfo/XS/main/xs_utils.h | 29 +++++++++++
16 files changed, 168 insertions(+), 81 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index cdb39bc3cf..000edb4a66 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2024-11-14 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/main/xs_utils.c (non_perl_*),
+ tp/Texinfo/XS/main/utils.c: move non_perl_* functions out of utils.c
+ to xs_utils.c.
+
+ * tp/Texinfo/XS/Makefile.am (noinst_LTLIBRARIES)
+ (libxsutils_la_SOURCES, libxs_in_libtexinfo_la_SOURCES)
+ (libxs_in_libtexinfo_la_CPPFLAGS, libtexinfo_la_CPPFLAGS)
+ (libtexinfoxs_la_LIBADD), tp/Texinfo/XS/main/call_perl_function.c,
+ tp/Texinfo/XS/main/api_to_perl.c: add libxsutils and
+ ibxs_in_libtexinfo convenience libraries to be able to use different
+ CPPFLAGS for compiltation. libxsutils contains only xs_utils and does
+ not require any CPPFLAGS. This allows to avoid including config.h
+ directly or indirectly in call_perl_function.c and api_to_perl.c and
+ be fully independent of gnulib and autoconf.
+
2024-11-14 Patrice Dumas <pertusus@free.fr>
* README-hacking: add suggestion and instructions to run tests after
diff --git a/tp/Texinfo/XS/Makefile.am b/tp/Texinfo/XS/Makefile.am
index 38d04a4505..7bb04b9041 100644
--- a/tp/Texinfo/XS/Makefile.am
+++ b/tp/Texinfo/XS/Makefile.am
@@ -102,6 +102,16 @@ XSParagraph_la_LDFLAGS = $(XSLIBS_LDFLAGS) $(LTLIBINTL)
$(LTLIBICONV) $(LTLIBUNI
EXTRA_DIST += XSParagraph.xs MiscXS.xs
+############ Convenience library used in XS code, separate to use different
+# flags to be sure that Perl headers and Perl replacement functions
+# are not used and libc functions are used.
+
+noinst_LTLIBRARIES =
+noinst_LTLIBRARIES += libxsutils.la
+
+libxsutils_la_SOURCES = \
+ main/xs_utils.c \
+ main/xs_utils.h
########################## shared common library and parser library
@@ -217,14 +227,6 @@ C_libtexinfo_sources = \
structuring_transfo/transformations.c \
structuring_transfo/transformations.h
-# api_to_perl.c and call_perl_function.c functions are called in other
-# parts of the code and need to be linked against Perl
-XS_libtexinfo_sources = \
- main/api_to_perl.c \
- main/api_to_perl.h \
- main/call_perl_function.c \
- main/call_perl_function.h
-
EXTRA_DIST += main/accent_tables_8bit_codepoints.c
EXTRA_DIST += main/command_data.c
EXTRA_DIST += main/cmd_normalization.c
@@ -234,13 +236,29 @@ EXTRA_DIST += main/global_multi_commands_case.c
EXTRA_DIST += main/global_unique_commands_case.c
libtexinfo_la_SOURCES = \
- $(C_libtexinfo_sources) \
- $(XS_libtexinfo_sources)
+ $(C_libtexinfo_sources)
+
+# convenience library separate from but only used in libtexinfo to have
+# different CPPFLAGS to make sure that gnulib header files are not used
+# in compilation.
+noinst_LTLIBRARIES += libxs_in_libtexinfo.la
+
+# api_to_perl.c and call_perl_function.c functions are called in other
+# parts of the code and need to be linked against Perl
+libxs_in_libtexinfo_la_SOURCES = \
+ main/api_to_perl.c \
+ main/api_to_perl.h \
+ main/call_perl_function.c \
+ main/call_perl_function.h
+
+libxs_in_libtexinfo_la_CPPFLAGS = -I$(srcdir)/main $(XSLIBS_CPPFLAGS)
+libxs_in_libtexinfo_la_CFLAGS = $(XSLIBS_CFLAGS)
+libxs_in_libtexinfo_la_LIBADD = libxsutils.la $(platform_PERL_LIBADD)
+libxs_in_libtexinfo_la_LDFLAGS = $(perl_conf_LDFLAGS)
# locate include files under out-of-source builds.
-libtexinfo_la_CPPFLAGS = -I$(srcdir)/main -I$(srcdir)/parsetexi $(AM_CPPFLAGS)
$(GNULIB_CPPFLAGS) $(XSLIBS_CPPFLAGS)
-libtexinfo_la_CFLAGS = $(XSLIBS_CFLAGS)
-libtexinfo_la_LIBADD = $(top_builddir)/gnulib/lib/libgnu.la
$(platform_PERL_LIBADD)
+libtexinfo_la_CPPFLAGS = -I$(srcdir)/main -I$(srcdir)/parsetexi $(AM_CPPFLAGS)
$(GNULIB_CPPFLAGS)
+libtexinfo_la_LIBADD = $(top_builddir)/gnulib/lib/libgnu.la
libxs_in_libtexinfo.la $(platform_PERL_LIBADD)
libtexinfo_la_LDFLAGS = -version-info 0:0:0 $(perl_conf_LDFLAGS) $(LTLIBINTL)
$(LTLIBICONV) $(LTLIBUNISTRING)
#libtexinfo_la_LDFLAGS = -version-info 0:0:0 -Wl,--no-undefined
$(perl_conf_LDFLAGS) $(PERL_LIBS) $(LTLIBINTL) $(LTLIBICONV) $(LTLIBUNISTRING)
@@ -374,7 +392,7 @@ libtexinfoxs_la_SOURCES= \
# locate include files under out-of-source builds.
libtexinfoxs_la_CPPFLAGS = -I$(srcdir)/main -I$(srcdir)/convert $(AM_CPPFLAGS)
$(XSLIBS_CPPFLAGS)
libtexinfoxs_la_CFLAGS = $(XSLIBS_CFLAGS)
-libtexinfoxs_la_LIBADD = libtexinfo.la $(platform_PERL_LIBADD)
+libtexinfoxs_la_LIBADD = libtexinfo.la libxsutils.la $(platform_PERL_LIBADD)
# example to trigger errors associated with no undefined
#libtexinfoxs_la_LDFLAGS = -version-info 0:0:0 -Wl,--no-undefined
$(perl_conf_LDFLAGS) $(PERL_LIBS) $(LTLIBINTL)
libtexinfoxs_la_LDFLAGS = -version-info 0:0:0 $(perl_conf_LDFLAGS) $(LTLIBINTL)
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs
b/tp/Texinfo/XS/convert/ConvertXS.xs
index 3f153b7859..03ea046cf2 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -40,12 +40,14 @@
#include "option_types.h"
#include "options_data.h"
#include "converter_types.h"
+/* non_perl_free */
+#include "xs_utils.h"
#include "builtin_commands.h"
#include "errors.h"
#include "convert_to_text.h"
#include "convert_to_texinfo.h"
#include "manipulate_indices.h"
-/* for command_location_names non_perl_free new_string_list ... */
+/* for command_location_names new_string_list ... */
#include "utils.h"
#include "command_stack.h"
#include "customization_options.h"
diff --git a/tp/Texinfo/XS/convert/call_html_perl_function.c
b/tp/Texinfo/XS/convert/call_html_perl_function.c
index 577f48fd9b..563458658c 100644
--- a/tp/Texinfo/XS/convert/call_html_perl_function.c
+++ b/tp/Texinfo/XS/convert/call_html_perl_function.c
@@ -36,6 +36,8 @@
#include "option_types.h"
#include "converter_types.h"
#include "types_data.h"
+/* non_perl_* */
+#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
diff --git a/tp/Texinfo/XS/convert/get_converter_perl_info.c
b/tp/Texinfo/XS/convert/get_converter_perl_info.c
index e361c7acac..883517cab5 100644
--- a/tp/Texinfo/XS/convert/get_converter_perl_info.c
+++ b/tp/Texinfo/XS/convert/get_converter_perl_info.c
@@ -34,6 +34,8 @@
#include "option_types.h"
#include "options_data.h"
#include "converter_types.h"
+/* non_perl_* */
+#include "xs_utils.h"
#include "builtin_commands.h"
#include "utils.h"
#include "customization_options.h"
diff --git a/tp/Texinfo/XS/convert/get_html_perl_info.c
b/tp/Texinfo/XS/convert/get_html_perl_info.c
index ad757b0ef6..79e4e520db 100644
--- a/tp/Texinfo/XS/convert/get_html_perl_info.c
+++ b/tp/Texinfo/XS/convert/get_html_perl_info.c
@@ -35,6 +35,8 @@
#include "command_ids.h"
#include "converter_types.h"
#include "types_data.h"
+/* non_perl_* */
+#include "xs_utils.h"
/* also for direction_string_type_names direction_string_context_names
html_conversion_context_type_names html_stage_handler_stage_type_names
*/
diff --git a/tp/Texinfo/XS/main/DocumentXS.xs b/tp/Texinfo/XS/main/DocumentXS.xs
index e8251685fc..71a7773167 100644
--- a/tp/Texinfo/XS/main/DocumentXS.xs
+++ b/tp/Texinfo/XS/main/DocumentXS.xs
@@ -30,9 +30,12 @@
#include "options_data.h"
#include "tree_types.h"
#include "document_types.h"
+/* non_perl_* */
+#include "xs_utils.h"
#include "extra.h"
-/* for non_perl_* */
+/* needed?
#include "utils.h"
+ */
#include "customization_options.h"
/* for clear_error_message_list */
#include "errors.h"
diff --git a/tp/Texinfo/XS/main/IndicesXS.xs b/tp/Texinfo/XS/main/IndicesXS.xs
index b07556733e..26a295890a 100644
--- a/tp/Texinfo/XS/main/IndicesXS.xs
+++ b/tp/Texinfo/XS/main/IndicesXS.xs
@@ -28,8 +28,9 @@
#include "tree_types.h"
#include "document_types.h"
/* non_perl_* */
-#include "utils.h"
+#include "xs_utils.h"
/*
+#include "utils.h"
#include "tree.h"
*/
#include "document.h"
diff --git a/tp/Texinfo/XS/main/api_to_perl.c b/tp/Texinfo/XS/main/api_to_perl.c
index 6e7650a5cd..8f29c8bdb7 100644
--- a/tp/Texinfo/XS/main/api_to_perl.c
+++ b/tp/Texinfo/XS/main/api_to_perl.c
@@ -13,8 +13,6 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#include <config.h>
-
/* Avoid namespace conflicts. */
#define context perl_context
@@ -35,7 +33,7 @@
#include "converter_types.h"
#include "document_types.h"
/* non_perl_* */
-#include "utils.h"
+#include "xs_utils.h"
/* See the NOTE in build_perl_info.c on use of functions related to
memory allocation */
diff --git a/tp/Texinfo/XS/main/build_perl_info.c
b/tp/Texinfo/XS/main/build_perl_info.c
index 676c861443..9dc1f10dab 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -61,6 +61,8 @@
#include "document_types.h"
/* CONVERTER sv_string_type */
#include "converter_types.h"
+/* non_perl_* */
+#include "xs_utils.h"
/* for new_element */
#include "tree.h"
#include "extra.h"
diff --git a/tp/Texinfo/XS/main/call_perl_function.c
b/tp/Texinfo/XS/main/call_perl_function.c
index 115f621faf..baed57d725 100644
--- a/tp/Texinfo/XS/main/call_perl_function.c
+++ b/tp/Texinfo/XS/main/call_perl_function.c
@@ -13,8 +13,6 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#include <config.h>
-
/* Avoid namespace conflicts. */
#define context perl_context
@@ -25,13 +23,11 @@
#undef context
-#include <string.h>
-
#include "tree_types.h"
#include "converter_types.h"
#include "document_types.h"
-/* for non_perl_strndup and similar */
-#include "utils.h"
+/* non_perl_* */
+#include "xs_utils.h"
#include "call_perl_function.h"
/* See the NOTE in build_perl_info.c on use of functions related to
diff --git a/tp/Texinfo/XS/main/get_perl_info.c
b/tp/Texinfo/XS/main/get_perl_info.c
index 2864284284..e18c7f301e 100644
--- a/tp/Texinfo/XS/main/get_perl_info.c
+++ b/tp/Texinfo/XS/main/get_perl_info.c
@@ -35,6 +35,8 @@
#include "options_data.h"
#include "document_types.h"
#include "converter_types.h"
+/* non_perl_* */
+#include "xs_utils.h"
#include "extra.h"
#include "builtin_commands.h"
#include "debug.h"
diff --git a/tp/Texinfo/XS/main/utils.c b/tp/Texinfo/XS/main/utils.c
index 5240d57179..a4a2c5d44a 100644
--- a/tp/Texinfo/XS/main/utils.c
+++ b/tp/Texinfo/XS/main/utils.c
@@ -184,54 +184,6 @@ char *html_command_text_type_name[] = {
"href", "node", "section",
};
-/* wrappers to be sure to use non-Perl defined functions */
-void
-non_perl_free (void *ptr)
-{
- free (ptr);
-}
-
-void *
-non_perl_malloc (size_t size)
-{
- return malloc (size);
-}
-
-char *
-non_perl_strdup (const char *s)
-{
- return strdup (s);
-}
-
-char *
-non_perl_strndup (const char *s, size_t n)
-{
- return strndup (s, n);
-}
-
-/* wrapper for vasprintf */
-int
-non_perl_xvasprintf (char **ptr, const char *template, va_list ap)
-{
- int ret;
- ret = vasprintf (ptr, template, ap);
- if (ret < 0)
- abort (); /* out of memory */
- return ret;
-}
-
-/* wrapper for asprintf */
-int
-non_perl_xasprintf (char **ptr, const char *template, ...)
-{
- int ret;
- va_list v;
- va_start (v, template);
- ret = non_perl_xvasprintf (ptr, template, v);
- va_end (v);
- return ret;
-}
-
/* wrapper for asprintf */
int
xasprintf (char **ptr, const char *template, ...)
diff --git a/tp/Texinfo/XS/main/utils.h b/tp/Texinfo/XS/main/utils.h
index 5ad606185f..2f8e696c95 100644
--- a/tp/Texinfo/XS/main/utils.h
+++ b/tp/Texinfo/XS/main/utils.h
@@ -108,13 +108,6 @@ typedef struct ACCENTS_STACK {
ELEMENT *argument;
} ACCENTS_STACK;
-void non_perl_free (void *ptr);
-void *non_perl_malloc (size_t size);
-char *non_perl_strdup (const char *s);
-char *non_perl_strndup (const char *s, size_t n);
-int non_perl_xvasprintf (char **ptr, const char *template, va_list ap);
-int non_perl_xasprintf (char **ptr, const char *template, ...);
-
int xasprintf (char **ptr, const char *template, ...);
void fatal (char *);
diff --git a/tp/Texinfo/XS/main/xs_utils.c b/tp/Texinfo/XS/main/xs_utils.c
new file mode 100644
index 0000000000..1c57402fbd
--- /dev/null
+++ b/tp/Texinfo/XS/main/xs_utils.c
@@ -0,0 +1,68 @@
+/* Copyright 2010-2024 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+/* wrappers to be sure to use non-Perl defined functions */
+void
+non_perl_free (void *ptr)
+{
+ free (ptr);
+}
+
+void *
+non_perl_malloc (size_t size)
+{
+ return malloc (size);
+}
+
+char *
+non_perl_strdup (const char *s)
+{
+ return strdup (s);
+}
+
+char *
+non_perl_strndup (const char *s, size_t n)
+{
+ return strndup (s, n);
+}
+
+/* wrapper for vasprintf */
+int
+non_perl_xvasprintf (char **ptr, const char *template, va_list ap)
+{
+ int ret;
+ ret = vasprintf (ptr, template, ap);
+ if (ret < 0)
+ abort (); /* out of memory */
+ return ret;
+}
+
+/* wrapper for asprintf */
+int
+non_perl_xasprintf (char **ptr, const char *template, ...)
+{
+ int ret;
+ va_list v;
+ va_start (v, template);
+ ret = non_perl_xvasprintf (ptr, template, v);
+ va_end (v);
+ return ret;
+}
+
diff --git a/tp/Texinfo/XS/main/xs_utils.h b/tp/Texinfo/XS/main/xs_utils.h
new file mode 100644
index 0000000000..2b581153d8
--- /dev/null
+++ b/tp/Texinfo/XS/main/xs_utils.h
@@ -0,0 +1,29 @@
+/* xs_utils.h - declarations for xs_utils.c */
+#ifndef XS_UTILS_H
+#define XS_UTILS_H
+
+/* Copyright 2010-2024 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <stdarg.h>
+
+void non_perl_free (void *ptr);
+void *non_perl_malloc (size_t size);
+char *non_perl_strdup (const char *s);
+char *non_perl_strndup (const char *s, size_t n);
+int non_perl_xvasprintf (char **ptr, const char *template, va_list ap);
+int non_perl_xasprintf (char **ptr, const char *template, ...);
+
+#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/XS/main/xs_utils.c (non_perl_*), tp/Texinfo/XS/main/utils.c: move non_perl_* functions out of utils.c to xs_utils.c.,
Patrice Dumas <=