[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: Remove some perl_only_* wrappers
From: |
Gavin D. Smith |
Subject: |
branch master updated: Remove some perl_only_* wrappers |
Date: |
Sun, 03 Mar 2024 12:18:57 -0500 |
This is an automated email from the git hooks/post-receive script.
gavin pushed a commit to branch master
in repository texinfo.
The following commit(s) were added to refs/heads/master by this push:
new a41c348f41 Remove some perl_only_* wrappers
a41c348f41 is described below
commit a41c348f41f5999f48eea95ef8604d23f1b50954
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Sun Mar 3 17:18:49 2024 +0000
Remove some perl_only_* wrappers
* tp/Texinfo/XS/main/build_perl_info.c
(perl_only_xasprintf, perl_only_xvasprintf): Remove as wrappers,
as it is likely that Perl does not define its own versions
of these. It's not worth implementing them ourselves as this is
not trivial to do, and they are not currently needed.
* tp/Texinfo/XS/main/utils.c
(non_perl_xasprintf, non_perl_xvasprintf): Add.
* tp/Texinfo/XS/main/get_perl_info.c
(get_sv_index_entries_sorted_by_letter): Replace calls to
perl_only_xasprintf and perl_only_free with calls to non_perl_xasprintf
and non_perl_free.
* tp/Texinfo/XS/convert/build_html_perl_state.c
(build_html_translated_names): Replace call to perl_only_xasprintf
with calls to perl_only_malloc and sprintf.
---
ChangeLog | 22 ++++++++++++++++++++++
tp/Texinfo/XS/convert/build_html_perl_state.c | 3 ++-
tp/Texinfo/XS/main/build_perl_info.c | 26 +++-----------------------
tp/Texinfo/XS/main/build_perl_info.h | 2 --
tp/Texinfo/XS/main/get_perl_info.c | 4 ++--
tp/Texinfo/XS/main/utils.c | 20 ++++++++++++++++++++
tp/Texinfo/XS/main/utils.h | 2 ++
7 files changed, 51 insertions(+), 28 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3b1238d27e..0e579d9588 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2024-03-03 Gavin Smith <gavinsmith0123@gmail.com>
+
+ Remove some perl_only_* wrappers
+
+ * tp/Texinfo/XS/main/build_perl_info.c
+ (perl_only_xasprintf, perl_only_xvasprintf): Remove as wrappers,
+ as it is likely that Perl does not define its own versions
+ of these. It's not worth implementing them ourselves as this is
+ not trivial to do, and they are not currently needed.
+
+ * tp/Texinfo/XS/main/utils.c
+ (non_perl_xasprintf, non_perl_xvasprintf): Add.
+
+ * tp/Texinfo/XS/main/get_perl_info.c
+ (get_sv_index_entries_sorted_by_letter): Replace calls to
+ perl_only_xasprintf and perl_only_free with calls to non_perl_xasprintf
+ and non_perl_free.
+
+ * tp/Texinfo/XS/convert/build_html_perl_state.c
+ (build_html_translated_names): Replace call to perl_only_xasprintf
+ with calls to perl_only_malloc and sprintf.
+
2024-03-03 Gavin Smith <gavinsmith0123@gmail.com>
Reimplement perl_only_* wrappers
diff --git a/tp/Texinfo/XS/convert/build_html_perl_state.c
b/tp/Texinfo/XS/convert/build_html_perl_state.c
index fcc898b3db..7c4ecfd189 100644
--- a/tp/Texinfo/XS/convert/build_html_perl_state.c
+++ b/tp/Texinfo/XS/convert/build_html_perl_state.c
@@ -279,7 +279,8 @@ build_html_translated_names (HV *hv, CONVERTER *converter)
const char *type_name = special_unit_info_type_names[string_type];
char *key;
HV *special_unit_hv = newHV ();
- perl_only_xasprintf (&key, "%s_tree", type_name);
+ key = perl_only_malloc (strlen (type_name) + strlen ("_tree") + 1);
+ sprintf (key, "%s_tree", type_name);
hv_store (special_unit_info_hv, key, strlen (key),
newRV_noinc ((SV *) special_unit_hv), 0);
perl_only_free (key);
diff --git a/tp/Texinfo/XS/main/build_perl_info.c
b/tp/Texinfo/XS/main/build_perl_info.c
index 1eb3856eba..7e2c7f3444 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -70,12 +70,12 @@
To be sure to use Perl defined functions, wrappers
can be used, from build_perl_info.h:
- perl_only_free, perl_only_strdup, perl_only_strndup, perl_only_malloc,
- perl_only_xvasprintf, perl_only_xasprintf.
+ perl_only_free, perl_only_strdup, perl_only_strndup, perl_only_malloc.
To be sure to use non Perl defined functions, constructors and wrappers
can be used, from utils.h:
- non_perl_free, non_perl_strdup, non_perl_strndup.
+ non_perl_free, non_perl_strdup, non_perl_strndup,
+ non_perl_xvasprintf, non_perl_xasprintf.
*/
/* wrappers to be sure to use Perl defined functions */
@@ -119,26 +119,6 @@ perl_only_strndup (const char *s, size_t n)
return ret;
}
-/* wrapper for vasprintf */
-int
-perl_only_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
-perl_only_xasprintf (char **ptr, const char *template, ...)
-{
- va_list v;
- va_start (v, template);
- return perl_only_xvasprintf (ptr, template, v);
-}
-
int
init (int texinfo_uninstalled, char *builddir)
{
diff --git a/tp/Texinfo/XS/main/build_perl_info.h
b/tp/Texinfo/XS/main/build_perl_info.h
index 72d3a9f961..3901ef7bd1 100644
--- a/tp/Texinfo/XS/main/build_perl_info.h
+++ b/tp/Texinfo/XS/main/build_perl_info.h
@@ -18,8 +18,6 @@ void perl_only_free (void *ptr);
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 perl_only_xvasprintf (char **ptr, const char *template, va_list ap);
-int perl_only_xasprintf (char **ptr, const char *template, ...);
int init (int texinfo_uninstalled, char *srcdir_in);
diff --git a/tp/Texinfo/XS/main/get_perl_info.c
b/tp/Texinfo/XS/main/get_perl_info.c
index 193a0e4a41..585c56b4ea 100644
--- a/tp/Texinfo/XS/main/get_perl_info.c
+++ b/tp/Texinfo/XS/main/get_perl_info.c
@@ -861,13 +861,13 @@ get_sv_index_entries_sorted_by_letter (INDEX
**index_names,
idx_name, i, letter_entries->letter, k);
fatal (msg);
}
- perl_only_xasprintf (&warn_string,
+ non_perl_xasprintf (&warn_string,
"get_sv_index_entries_sorted_by_letter: %s: %d: %s:
%d",
idx_name, i, letter_entries->letter, k);
index_entry = find_index_entry_sv (*index_entry_sv,
index_names,
warn_string, &entry_idx,
&entry_number);
- perl_only_free (warn_string);
+ non_perl_free (warn_string);
letter_entries->entries[k] = index_entry;
diff --git a/tp/Texinfo/XS/main/utils.c b/tp/Texinfo/XS/main/utils.c
index 03e181caff..1a7aa133c1 100644
--- a/tp/Texinfo/XS/main/utils.c
+++ b/tp/Texinfo/XS/main/utils.c
@@ -156,6 +156,26 @@ 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, ...)
+{
+ va_list v;
+ va_start (v, template);
+ return non_perl_xvasprintf (ptr, template, v);
+}
+
/* 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 cba2de61cf..110ad28465 100644
--- a/tp/Texinfo/XS/main/utils.h
+++ b/tp/Texinfo/XS/main/utils.h
@@ -169,6 +169,8 @@ typedef struct TARGET_DIRECTORY_FILENAME {
void non_perl_free (void *ptr);
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, ...);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: Remove some perl_only_* wrappers,
Gavin D. Smith <=