[PATCH 2/5] Move to autoconf standard function name checks & defines
Alan Coopersmith
alan.coopersmith at oracle.com
Fri Dec 2 10:48:13 PST 2011
Replace multiple methods of checking for funcs calls with AC_CHECK_FUNCS
Replace multiple methods of selecting fallback funcs with AC_REPLACE_FUNCS
Replace HAS_* and NEED_* #defines with autogenerated HAVE_*
Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
configure.ac | 38 +++++---------------------
hw/dmx/config/Makefile.am | 3 --
hw/vfb/InitOutput.c | 26 +++++++++---------
hw/xwin/win.h | 4 +-
include/dix-config.h.in | 65 +++++++++++++++++++++++---------------------
include/os.h | 8 +++---
include/xkb-config.h.in | 3 --
mi/mibitblt.c | 2 +-
os/Makefile.am | 16 +---------
os/access.c | 28 +++++++++---------
os/connection.c | 6 ++--
os/osdep.h | 6 ----
os/strcasecmp.c | 4 +-
os/strcasestr.c | 2 +-
os/strlcpy.c | 2 +
15 files changed, 85 insertions(+), 128 deletions(-)
diff --git a/configure.ac b/configure.ac
index 3005dc4..ff86d37 100644
--- a/configure.ac
+++ b/configure.ac
@@ -213,31 +213,14 @@ AC_CHECK_FUNC([dlopen], [],
AC_SUBST(DLOPEN_LIBS)
dnl Checks for library functions.
-AC_CHECK_FUNCS([vsnprintf walkcontext backtrace \
- getzoneid shmctl64 strcasestr ffs vasprintf])
-AC_CHECK_FUNCS([strndup], [HAVE_STRNDUP=yes], [HAVE_STRNDUP=no])
-AM_CONDITIONAL(NEED_STRNDUP, [test x$HAVE_STRNDUP = xno])
-dnl Old HAS_* names used in os/*.c.
-AC_CHECK_FUNC([getdtablesize],
- AC_DEFINE(HAS_GETDTABLESIZE, 1, [Have the 'getdtablesize' function.]))
-AC_CHECK_FUNC([getifaddrs],
- AC_DEFINE(HAS_GETIFADDRS, 1, [Have the 'getifaddrs' function.]))
-AC_CHECK_FUNC([getpeereid],
- AC_DEFINE(HAS_GETPEEREID, 1, [Have the 'getpeereid' function.]))
-AC_CHECK_FUNC([getpeerucred],
- AC_DEFINE(HAS_GETPEERUCRED, 1, [Have the 'getpeerucred' function.]))
-AC_CHECK_FUNC([strlcat], HAVE_STRLCAT=yes, HAVE_STRLCAT=no)
-AM_CONDITIONAL(NEED_STRLCAT, [test x$HAVE_STRLCAT = xno])
-AC_CHECK_FUNC([strlcpy], AC_DEFINE(HAS_STRLCPY, 1, [Have the 'strlcpy' function]))
-
-AM_CONDITIONAL(NEED_VSNPRINTF, [test x$HAVE_VSNPRINTF = xno])
-
-dnl Check for mmap support for Xvfb
-AC_CHECK_FUNC([mmap], AC_DEFINE(HAS_MMAP, 1, [Have the 'mmap' function.]))
-
-dnl Find the math libary
+AC_CHECK_FUNCS([backtrace ffs \
+ getdtablesize getifaddrs getpeereid getpeerucred getzoneid \
+ mmap shmctl64 strncasecmp vasprintf vsnprintf walkcontext])
+AC_REPLACE_FUNCS([strcasecmp strcasestr strlcat strlcpy strndup])
+
+dnl Find the math libary, then check for cbrt function in it.
AC_CHECK_LIB(m, sqrt)
-AC_CHECK_LIB(m, cbrt, AC_DEFINE(HAVE_CBRT, 1, [Have the 'cbrt' function]))
+AC_CHECK_FUNCS([cbrt])
AC_CHECK_HEADERS([ndbm.h dbm.h rpcsvc/dbm.h])
@@ -1238,13 +1221,6 @@ XKB_LIB='$(top_builddir)/xkb/libxkb.la'
XKB_STUB_LIB='$(top_builddir)/xkb/libxkbstubs.la'
REQUIRED_MODULES="$REQUIRED_MODULES xkbfile"
-AC_CHECK_FUNC(strcasecmp, [], AC_DEFINE([NEED_STRCASECMP], 1,
- [Do not have 'strcasecmp'.]))
-AC_CHECK_FUNC(strncasecmp, [], AC_DEFINE([NEED_STRNCASECMP], 1,
- [Do not have 'strncasecmp'.]))
-AC_CHECK_FUNC(strcasestr, [], AC_DEFINE([NEED_STRCASESTR], 1,
- [Do not have 'strcasestr'.]))
-
PKG_CHECK_MODULES([XDMCP], [xdmcp], [have_libxdmcp="yes"], [have_libxdmcp="no"])
if test "x$have_libxdmcp" = xyes; then
AC_CHECK_LIB(Xdmcp, XdmcpWrap, [have_xdmcpwrap="yes"], [have_xdmcpwrap="no"], [$XDMCP_LIBS])
diff --git a/hw/dmx/config/Makefile.am b/hw/dmx/config/Makefile.am
index 7518143..06588e7 100644
--- a/hw/dmx/config/Makefile.am
+++ b/hw/dmx/config/Makefile.am
@@ -21,10 +21,7 @@ BUILT_SOURCES = parser.c parser.h scanner.c
MAINTAINERCLEANFILES = $(BUILT_SOURCES)
libdmxconfig_a_SOURCES = $(LIBSRCS)
-
-if NEED_STRLCAT
libdmxconfig_a_SOURCES += $(top_srcdir)/os/strlcpy.c
-endif
if GLX
GLX_DEFS = @GL_CFLAGS@
diff --git a/hw/vfb/InitOutput.c b/hw/vfb/InitOutput.c
index 9a9905d..e1af5a4 100644
--- a/hw/vfb/InitOutput.c
+++ b/hw/vfb/InitOutput.c
@@ -48,12 +48,12 @@ from The Open Group.
#include "mipointer.h"
#include "micmap.h"
#include <sys/types.h>
-#ifdef HAS_MMAP
+#ifdef HAVE_MMAP
#include <sys/mman.h>
#ifndef MAP_FILE
#define MAP_FILE 0
#endif
-#endif /* HAS_MMAP */
+#endif /* HAVE_MMAP */
#include <sys/stat.h>
#include <errno.h>
#ifndef WIN32
@@ -93,7 +93,7 @@ typedef struct
unsigned int lineBias;
CloseScreenProcPtr closeScreen;
-#ifdef HAS_MMAP
+#ifdef HAVE_MMAP
int mmap_fd;
char mmap_file[MAXPATHLEN];
#endif
@@ -114,7 +114,7 @@ static vfbScreenInfo defaultScreenInfo = {
.lineBias = VFB_DEFAULT_LINEBIAS,
};
static Bool vfbPixmapDepths[33];
-#ifdef HAS_MMAP
+#ifdef HAVE_MMAP
static char *pfbdir = NULL;
#endif
typedef enum { NORMAL_MEMORY_FB, SHARED_MEMORY_FB, MMAPPED_FILE_FB } fbMemType;
@@ -158,7 +158,7 @@ ddxGiveUp(enum ExitCode error)
switch (fbmemtype)
{
-#ifdef HAS_MMAP
+#ifdef HAVE_MMAP
case MMAPPED_FILE_FB:
for (i = 0; i < vfbNumScreens; i++)
{
@@ -170,10 +170,10 @@ ddxGiveUp(enum ExitCode error)
}
}
break;
-#else /* HAS_MMAP */
+#else /* HAVE_MMAP */
case MMAPPED_FILE_FB:
break;
-#endif /* HAS_MMAP */
+#endif /* HAVE_MMAP */
#ifdef HAS_SHM
case SHARED_MEMORY_FB:
@@ -241,7 +241,7 @@ ddxUseMsg(void)
ErrorF("-blackpixel n pixel value for black\n");
ErrorF("-whitepixel n pixel value for white\n");
-#ifdef HAS_MMAP
+#ifdef HAVE_MMAP
ErrorF("-fbdir directory put framebuffers in mmap'ed files in directory\n");
#endif
@@ -370,7 +370,7 @@ ddxProcessArgument(int argc, char *argv[], int i)
return 2;
}
-#ifdef HAS_MMAP
+#ifdef HAVE_MMAP
if (strcmp (argv[i], "-fbdir") == 0) /* -fbdir directory */
{
CHECK_FOR_REQUIRED_ARGUMENTS(1);
@@ -378,7 +378,7 @@ ddxProcessArgument(int argc, char *argv[], int i)
fbmemtype = MMAPPED_FILE_FB;
return 2;
}
-#endif /* HAS_MMAP */
+#endif /* HAVE_MMAP */
#ifdef HAS_SHM
if (strcmp (argv[i], "-shmem") == 0) /* -shmem */
@@ -523,7 +523,7 @@ vfbSaveScreen(ScreenPtr pScreen, int on)
return TRUE;
}
-#ifdef HAS_MMAP
+#ifdef HAVE_MMAP
/* this flushes any changes to the screens out to the mmapped file */
static void
@@ -608,7 +608,7 @@ vfbAllocateMmappedFramebuffer(vfbScreenInfoPtr pvfb)
pvfb->pXWDHeader = NULL;
}
}
-#endif /* HAS_MMAP */
+#endif /* HAVE_MMAP */
#ifdef HAS_SHM
@@ -672,7 +672,7 @@ vfbAllocateFramebufferMemory(vfbScreenInfoPtr pvfb)
pvfb->pXWDHeader = NULL;
switch (fbmemtype)
{
-#ifdef HAS_MMAP
+#ifdef HAVE_MMAP
case MMAPPED_FILE_FB: vfbAllocateMmappedFramebuffer(pvfb); break;
#else
case MMAPPED_FILE_FB: break;
diff --git a/hw/xwin/win.h b/hw/xwin/win.h
index e2e946f..ac26d01 100644
--- a/hw/xwin/win.h
+++ b/hw/xwin/win.h
@@ -143,12 +143,12 @@
#undef HANDLE
#endif
-#ifdef HAS_MMAP
+#ifdef HAVE_MMAP
#include <sys/mman.h>
#ifndef MAP_FILE
#define MAP_FILE 0
#endif /* MAP_FILE */
-#endif /* HAS_MMAP */
+#endif /* HAVE_MMAP */
#include <X11/X.h>
#include <X11/Xproto.h>
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index d5129fe..3fb6413 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -51,27 +51,9 @@
/* Support XDM-AUTH*-1 */
#undef HASXDMAUTH
-/* Define to 1 if you have the `getdtablesize' function. */
-#undef HAS_GETDTABLESIZE
-
-/* Define to 1 if you have the `getifaddrs' function. */
-#undef HAS_GETIFADDRS
-
-/* Define to 1 if you have the `getpeereid' function. */
-#undef HAS_GETPEEREID
-
-/* Define to 1 if you have the `getpeerucred' function. */
-#undef HAS_GETPEERUCRED
-
-/* Define to 1 if you have the `mmap' function. */
-#undef HAS_MMAP
-
/* Support SHM */
#undef HAS_SHM
-/* Have the 'strlcpy' function */
-#undef HAS_STRLCPY
-
/* Define to 1 if you have the <asm/mtrr.h> header file. */
#undef HAVE_ASM_MTRR_H
@@ -81,7 +63,7 @@
/* Define to 1 if you have the <byteswap.h> header file. */
#undef HAVE_BYTESWAP_H
-/* Define to 1 if you have cbrt */
+/* Define to 1 if you have the `cbrt' function. */
#undef HAVE_CBRT
/* Define to 1 if you have the <dbm.h> header file. */
@@ -100,6 +82,21 @@
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
+/* Define to 1 if you have the `ffs' function. */
+#undef HAVE_FFS
+
+/* Define to 1 if you have the `getdtablesize' function. */
+#undef HAVE_GETDTABLESIZE
+
+/* Define to 1 if you have the `getifaddrs' function. */
+#undef HAVE_GETIFADDRS
+
+/* Define to 1 if you have the `getpeereid' function. */
+#undef HAVE_GETPEEREID
+
+/* Define to 1 if you have the `getpeerucred' function. */
+#undef HAVE_GETPEERUCRED
+
/* Define to 1 if you have the `getzoneid' function. */
#undef HAVE_GETZONEID
@@ -133,6 +130,9 @@
/* Define to 1 if you have the <linux/fb.h> header file. */
#undef HAVE_LINUX_FB_H
+/* Define to 1 if you have the `mmap' function. */
+#undef HAVE_MMAP
+
/* Define to 1 if you have the <ndbm.h> header file. */
#undef HAVE_NDBM_H
@@ -163,6 +163,21 @@
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
+/* Define to 1 if you have the `strcasecmp' function. */
+#undef HAVE_STRCASECMP
+
+/* Define to 1 if you have the `strcasestr' function. */
+#undef HAVE_STRCASESTR
+
+/* Define to 1 if you have the `strncasecmp' function. */
+#undef HAVE_STRNCASECMP
+
+/* Define to 1 if you have the `strlcat' function. */
+#undef HAVE_STRLCAT
+
+/* Define to 1 if you have the `strlcpy' function. */
+#undef HAVE_STRLCPY
+
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
@@ -402,18 +417,6 @@
/* Define to 64-bit byteswap macro */
#undef bswap_64
-/* Need the strcasecmp function. */
-#undef NEED_STRCASECMP
-
-/* Need the strncasecmp function. */
-#undef NEED_STRNCASECMP
-
-/* Need the strcasestr function. */
-#undef NEED_STRCASESTR
-
-/* Define to 1 if you have the `ffs' function. */
-#undef HAVE_FFS
-
/* The compiler supported TLS storage class, prefering initial-exec if tls_model is supported */
#undef TLS
diff --git a/include/os.h b/include/os.h
index 2298381..1fd5367 100644
--- a/include/os.h
+++ b/include/os.h
@@ -472,22 +472,22 @@ extern _X_EXPORT void ddxGiveUp(enum ExitCode error);
extern _X_EXPORT int TimeSinceLastInputEvent(void);
/* strcasecmp.c */
-#if NEED_STRCASECMP
+#ifndef HAVE_STRCASECMP
#define strcasecmp xstrcasecmp
extern _X_EXPORT int xstrcasecmp(const char *s1, const char *s2);
#endif
-#if NEED_STRNCASECMP
+#ifndef HAVE_STRNCASECMP
#define strncasecmp xstrncasecmp
extern _X_EXPORT int xstrncasecmp(const char *s1, const char *s2, size_t n);
#endif
-#if NEED_STRCASESTR
+#ifndef HAVE_STRCASESTR
#define strcasestr xstrcasestr
extern _X_EXPORT char *xstrcasestr(const char *s, const char *find);
#endif
-#ifndef HAS_STRLCPY
+#ifndef HAVE_STRLCPY
extern _X_EXPORT size_t strlcpy(char *dst, const char *src, size_t siz);
extern _X_EXPORT size_t strlcat(char *dst, const char *src, size_t siz);
#endif
diff --git a/include/xkb-config.h.in b/include/xkb-config.h.in
index d3cdd19..7b6a671 100644
--- a/include/xkb-config.h.in
+++ b/include/xkb-config.h.in
@@ -29,7 +29,4 @@
/* XKB output dir for compiled keymaps. */
#undef XKM_OUTPUT_DIR
-/* Do not have `strcasecmp'. */
-#undef NEED_STRCASECMP
-
#endif /* _XKB_CONFIG_H_ */
diff --git a/mi/mibitblt.c b/mi/mibitblt.c
index 49e17bd..2dfff14 100644
--- a/mi/mibitblt.c
+++ b/mi/mibitblt.c
@@ -63,7 +63,7 @@ SOFTWARE.
#include <X11/Xmd.h>
#include "servermd.h"
-#ifndef HAS_FFS
+#ifndef HAVE_FFS
extern int ffs(int);
#endif
diff --git a/os/Makefile.am b/os/Makefile.am
index 8dd8095..4990426 100644
--- a/os/Makefile.am
+++ b/os/Makefile.am
@@ -4,7 +4,6 @@ AM_CFLAGS = $(DIX_CFLAGS) $(SHA1_CFLAGS)
SECURERPC_SRCS = rpcauth.c
XDMCP_SRCS = xdmcp.c
-STRLCAT_SRCS = strlcat.c strlcpy.c
XORG_SRCS = log.c
libos_la_SOURCES = \
@@ -20,14 +19,12 @@ libos_la_SOURCES = \
osdep.h \
osinit.c \
utils.c \
- strcasecmp.c \
- strcasestr.c \
xdmauth.c \
xsha1.c \
xstrans.c \
xprintf.c \
$(XORG_SRCS)
-libos_la_LIBADD = @SHA1_LIBS@ $(DLOPEN_LIBS)
+libos_la_LIBADD = @SHA1_LIBS@ $(DLOPEN_LIBS) $(LIBOBJS)
if SECURE_RPC
libos_la_SOURCES += $(SECURERPC_SRCS)
@@ -37,16 +34,7 @@ if XDMCP
libos_la_SOURCES += $(XDMCP_SRCS)
endif
-if NEED_STRLCAT
-libos_la_SOURCES += $(STRLCAT_SRCS)
-endif
-
-if NEED_STRNDUP
-libos_la_SOURCES += $(STRNDUP_SRCS)
-endif
-
-EXTRA_DIST = $(SECURERPC_SRCS) $(INTERNALMALLOC_SRCS) \
- $(XDMCP_SRCS) $(STRLCAT_SRCS)
+EXTRA_DIST = $(SECURERPC_SRCS) $(XDMCP_SRCS)
if SPECIAL_DTRACE_OBJECTS
# Generate dtrace object code for probes in libos & libdix
diff --git a/os/access.c b/os/access.c
index 1598940..0800c7f 100644
--- a/os/access.c
+++ b/os/access.c
@@ -106,7 +106,7 @@ SOFTWARE.
#include <netinet/in.h>
#endif /* TCPCONN || STREAMSCONN */
-#ifdef HAS_GETPEERUCRED
+#ifdef HAVE_GETPEERUCRED
# include <ucred.h>
# ifdef sun
# include <zone.h>
@@ -146,7 +146,7 @@ SOFTWARE.
#endif
#endif
-#ifdef HAS_GETIFADDRS
+#ifdef HAVE_GETIFADDRS
#include <ifaddrs.h>
#endif
@@ -495,7 +495,7 @@ in6_fillscopeid(struct sockaddr_in6 *sin6)
void
DefineSelf (int fd)
{
-#ifndef HAS_GETIFADDRS
+#ifndef HAVE_GETIFADDRS
char *cp, *cplim;
# ifdef USE_SIOCGLIFCONF
struct sockaddr_storage buf[16];
@@ -510,7 +510,7 @@ DefineSelf (int fd)
register struct ifreq *ifr;
# endif
void * bufptr = buf;
-#else /* HAS_GETIFADDRS */
+#else /* HAVE_GETIFADDRS */
struct ifaddrs * ifap, *ifr;
#endif
int len;
@@ -518,7 +518,7 @@ DefineSelf (int fd)
int family;
register HOST *host;
-#ifndef HAS_GETIFADDRS
+#ifndef HAVE_GETIFADDRS
len = sizeof(buf);
@@ -689,7 +689,7 @@ DefineSelf (int fd)
}
if (bufptr != buf)
free(bufptr);
-#else /* HAS_GETIFADDRS */
+#else /* HAVE_GETIFADDRS */
if (getifaddrs(&ifap) < 0) {
ErrorF("Warning: getifaddrs returns %s\n", strerror(errno));
return;
@@ -777,7 +777,7 @@ DefineSelf (int fd)
} /* for */
freeifaddrs(ifap);
-#endif /* HAS_GETIFADDRS */
+#endif /* HAVE_GETIFADDRS */
/*
* add something of FamilyLocalHost
@@ -798,7 +798,7 @@ DefineSelf (int fd)
}
}
}
-#endif /* hpux && !HAS_IFREQ */
+#endif /* hpux && !HAVE_IFREQ */
#ifdef XDMCP
void
@@ -1091,14 +1091,14 @@ LocalClientCred(ClientPtr client, int *pUid, int *pGid)
int
GetLocalClientCreds(ClientPtr client, LocalClientCredRec **lccp)
{
-#if defined(HAS_GETPEEREID) || defined(HAS_GETPEERUCRED) || defined(SO_PEERCRED)
+#if defined(HAVE_GETPEEREID) || defined(HAVE_GETPEERUCRED) || defined(SO_PEERCRED)
int fd;
XtransConnInfo ci;
LocalClientCredRec *lcc;
-#ifdef HAS_GETPEEREID
+#ifdef HAVE_GETPEEREID
uid_t uid;
gid_t gid;
-#elif defined(HAS_GETPEERUCRED)
+#elif defined(HAVE_GETPEERUCRED)
ucred_t *peercred = NULL;
const gid_t *gids;
#elif defined(SO_PEERCRED)
@@ -1109,7 +1109,7 @@ GetLocalClientCreds(ClientPtr client, LocalClientCredRec **lccp)
if (client == NULL)
return -1;
ci = ((OsCommPtr)client->osPrivate)->trans_conn;
-#if !(defined(sun) && defined(HAS_GETPEERUCRED))
+#if !(defined(sun) && defined(HAVE_GETPEERUCRED))
/* Most implementations can only determine peer credentials for Unix
* domain sockets - Solaris getpeerucred can work with a bit more, so
* we just let it tell us if the connection type is supported or not
@@ -1125,7 +1125,7 @@ GetLocalClientCreds(ClientPtr client, LocalClientCredRec **lccp)
lcc = *lccp;
fd = _XSERVTransGetConnectionNumber(ci);
-#ifdef HAS_GETPEEREID
+#ifdef HAVE_GETPEEREID
if (getpeereid(fd, &uid, &gid) == -1) {
FreeLocalClientCreds(lcc);
return -1;
@@ -1134,7 +1134,7 @@ GetLocalClientCreds(ClientPtr client, LocalClientCredRec **lccp)
lcc->egid = gid;
lcc->fieldsSet = LCC_UID_SET | LCC_GID_SET;
return 0;
-#elif defined(HAS_GETPEERUCRED)
+#elif defined(HAVE_GETPEERUCRED)
if (getpeerucred(fd, &peercred) < 0) {
FreeLocalClientCreds(lcc);
return -1;
diff --git a/os/connection.c b/os/connection.c
index c5fc5a0..6f480de 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -114,7 +114,7 @@ SOFTWARE.
#define Pid_t pid_t
-#ifdef HAS_GETPEERUCRED
+#ifdef HAVE_GETPEERUCRED
# include <ucred.h>
# include <zone.h>
#endif
@@ -122,7 +122,7 @@ SOFTWARE.
#ifdef XSERVER_DTRACE
# include <sys/types.h>
typedef const char *string;
-# ifndef HAS_GETPEERUCRED
+# ifndef HAVE_GETPEERUCRED
# define zoneid_t int
# endif
# include "../dix/Xserver-dtrace.h"
@@ -282,7 +282,7 @@ InitConnectionLimits(void)
lastfdesc = sysconf(_SC_OPEN_MAX) - 1;
#endif
-#ifdef HAS_GETDTABLESIZE
+#ifdef HAVE_GETDTABLESIZE
if (lastfdesc < 0)
lastfdesc = getdtablesize() - 1;
#endif
diff --git a/os/osdep.h b/os/osdep.h
index 087e36d..72bd7d7 100644
--- a/os/osdep.h
+++ b/os/osdep.h
@@ -103,12 +103,6 @@ SOFTWARE.
/* MAXSELECT is the number of fds that select() can handle */
#define MAXSELECT (sizeof(fd_set) * NBBY)
-#ifndef HAS_GETDTABLESIZE
-#if !defined(SVR4) && !defined(SYSV)
-#define HAS_GETDTABLESIZE
-#endif
-#endif
-
#include <stddef.h>
#if defined(XDMCP) || defined(HASXDMAUTH)
diff --git a/os/strcasecmp.c b/os/strcasecmp.c
index ad6da6a..cf100ba 100644
--- a/os/strcasecmp.c
+++ b/os/strcasecmp.c
@@ -34,7 +34,7 @@
#include <ctype.h>
#include "dix.h"
-#ifdef NEED_STRCASECMP
+#ifndef HAVE_STRCASECMP
int
xstrcasecmp(const char *str1, const char *str2)
{
@@ -50,7 +50,7 @@ xstrcasecmp(const char *str1, const char *str2)
}
#endif
-#ifdef NEED_STRNCASECMP
+#ifndef HAVE_STRNCASECMP
int
xstrncasecmp(const char *s1, const char *s2, size_t n)
{
diff --git a/os/strcasestr.c b/os/strcasestr.c
index f89b2f2..a20a6cc 100644
--- a/os/strcasestr.c
+++ b/os/strcasestr.c
@@ -41,7 +41,7 @@
/*
* Find the first occurrence of find in s, ignore case.
*/
-#ifdef NEED_STRCASESTR
+#ifndef HAVE_STRCASESTR
char *
xstrcasestr(const char *s, const char *find)
{
diff --git a/os/strlcpy.c b/os/strlcpy.c
index 2e55b2e..7ffb64c 100644
--- a/os/strlcpy.c
+++ b/os/strlcpy.c
@@ -22,6 +22,7 @@
#include <string.h>
#include "os.h"
+#ifndef HAVE_STRLCPY
/*
* Copy src to string dst of size siz. At most siz-1 characters
* will be copied. Always NUL terminates (unless siz == 0).
@@ -52,3 +53,4 @@ strlcpy(char *dst, const char *src, size_t siz)
return s - src - 1; /* count does not include NUL */
}
+#endif
--
1.7.3.2
More information about the xorg-devel
mailing list