[hackers] [sbase] [PATCH] libutil: Rename functions in reserved namespace to prevent potential conflict

From: Michael Forney <mforney_AT_mforney.org>
Date: Mon, 20 May 2019 23:36:33 -0700

libc may define functions with the same names, but differing in prototype.
---
Anyone have any comments on this patch before I push it?
The motivating conflict is with strsep, which glibc declares as
	char *strsep(char **restrict, const char *restrict);
which is not compatible with the libutil declaration.
	char *strsep(char **, const char *);
 util.h | 6 ++++++
 1 file changed, 6 insertions(+)
diff --git a/util.h b/util.h
index 6c0aba9..8d5004b 100644
--- a/util.h
+++ b/util.h
_AT_@ -47,16 +47,20 @@ void weprintf(const char *, ...);
 double estrtod(const char *);
 
 #undef strcasestr
+#define strcasestr xstrcasestr
 char *strcasestr(const char *, const char *);
 
 #undef strlcat
+#define strlcat xstrlcat
 size_t strlcat(char *, const char *, size_t);
 size_t estrlcat(char *, const char *, size_t);
 #undef strlcpy
+#define strlcpy xstrlcpy
 size_t strlcpy(char *, const char *, size_t);
 size_t estrlcpy(char *, const char *, size_t);
 
 #undef strsep
+#define strsep xstrsep
 char *strsep(char **, const char *);
 
 /* regex */
_AT_@ -76,10 +80,12 @@ mode_t parsemode(const char *, mode_t, mode_t);
 off_t parseoffset(const char *);
 void putword(FILE *, const char *);
 #undef strtonum
+#define strtonum xstrtonum
 long long strtonum(const char *, long long, long long, const char **);
 long long enstrtonum(int, const char *, long long, long long);
 long long estrtonum(const char *, long long, long long);
 size_t unescape(char *);
 int mkdirp(const char *, mode_t, mode_t);
 #undef memmem
+#define memmem xmemmem
 void *memmem(const void *, size_t, const void *, size_t);
-- 
2.20.1
Received on Tue May 21 2019 - 08:36:33 CEST

This archive was generated by hypermail 2.3.0 : Tue May 21 2019 - 19:12:23 CEST