From a1f6db3a0ca86606d4a32e46d2db266d2290b7e4 Mon Sep 17 00:00:00 2001
From: "Todd C. Miller" <Todd.Miller@courtesan.com>
Date: Tue, 3 May 2011 13:45:56 -0400
Subject: [PATCH] Resolve namespace collisions on HP-UX ia64 and possibly
 others by adding a rpl_ prefix to our fnmatch and glob replacements and
 #defining rpl_foo to foo in the header files.

---
 compat/fnmatch.c | 2 +-
 compat/fnmatch.h | 2 ++
 compat/glob.c    | 4 ++--
 compat/glob.h    | 3 +++
 4 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/compat/fnmatch.c b/compat/fnmatch.c
index 3bc92d3be..91ef81476 100644
--- a/compat/fnmatch.c
+++ b/compat/fnmatch.c
@@ -68,7 +68,7 @@ static int rangematch(const char *, int, int, char **);
 static int classmatch(const char *, int, int, const char **);
 
 int
-fnmatch(const char *pattern, const char *string, int flags)
+rpl_fnmatch(const char *pattern, const char *string, int flags)
 {
 	const char *stringstart;
 	char *newp;
diff --git a/compat/fnmatch.h b/compat/fnmatch.h
index 5b6029394..2c310796d 100644
--- a/compat/fnmatch.h
+++ b/compat/fnmatch.h
@@ -41,6 +41,8 @@
 #define	FNM_LEADING_DIR	0x08	/* Ignore /<tail> after Imatch. */
 #define	FNM_CASEFOLD	0x10	/* Case insensitive search. */
 
+#define fnmatch(_a, _b, _c)	rpl_fnmatch((_a), (_b), (_c))
+
 int	 fnmatch(const char *, const char *, int);
 
 #endif /* !_FNMATCH_H_ */
diff --git a/compat/glob.c b/compat/glob.c
index a46ae9d7e..cf9a4e2bf 100644
--- a/compat/glob.c
+++ b/compat/glob.c
@@ -174,7 +174,7 @@ static void	 qprintf(const char *, Char *);
 #endif
 
 int
-glob(const char *pattern, int flags, int (*errfunc)(const char *, int),
+rpl_glob(const char *pattern, int flags, int (*errfunc)(const char *, int),
 	glob_t *pglob)
 {
 	const unsigned char *patnext;
@@ -810,7 +810,7 @@ match(Char *name, Char *pat, Char *patend)
 
 /* Free allocated data belonging to a glob_t structure. */
 void
-globfree(glob_t *pglob)
+rpl_globfree(glob_t *pglob)
 {
 	int i;
 	char **pp;
diff --git a/compat/glob.h b/compat/glob.h
index 4b59b4e3c..8279b796c 100644
--- a/compat/glob.h
+++ b/compat/glob.h
@@ -69,6 +69,9 @@ typedef struct {
 #define	GLOB_NOSYS	(-4)	/* Function not supported. */
 #define GLOB_ABEND	GLOB_ABORTED
 
+#define glob(_a, _b, _c, _d) rpl_glob((_a), (_b), (_c), (_d))
+#define globfree(_a) rpl_globfree((_a))
+
 int	glob(const char *, int, int (*)(const char *, int), glob_t *);
 void	globfree(glob_t *);
 
-- 
2.40.0