From 00b51d5c25abd0d91c7f6b25aeb3bdc8102e436b Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Sat, 2 Aug 2014 21:43:56 -0500 Subject: conditionally build strnlen if needed. it is only used by strndup prodded by Sortie@ --- configure.ac.tpl | 5 +++++ crypto/Makefile.am.tpl | 2 ++ include/string.h | 2 ++ 3 files changed, 9 insertions(+) diff --git a/configure.ac.tpl b/configure.ac.tpl index b557687..87a571d 100644 --- a/configure.ac.tpl +++ b/configure.ac.tpl @@ -72,6 +72,11 @@ AC_CHECK_FUNC(strndup, AC_DEFINE(NO_STRNDUP) AM_CONDITIONAL(NO_STRNDUP, true)) +AC_CHECK_FUNC(strnlen, + AM_CONDITIONAL(NO_STRNLEN, false), + AC_DEFINE(NO_STRNLEN) + AM_CONDITIONAL(NO_STRNLEN, true)) + AC_CHECK_FUNC(asprintf, AM_CONDITIONAL(NO_ASPRINTF, false), AC_DEFINE(NO_ASPRINTF) diff --git a/crypto/Makefile.am.tpl b/crypto/Makefile.am.tpl index d203b7b..04ff7f7 100644 --- a/crypto/Makefile.am.tpl +++ b/crypto/Makefile.am.tpl @@ -35,8 +35,10 @@ endif if NO_STRNDUP libcompat_la_SOURCES += compat/strndup.c +if NO_STRNLEN libcompat_la_SOURCES += compat/strnlen.c endif +endif if NO_ASPRINTF libcompat_la_SOURCES += compat/bsd-asprintf.c diff --git a/include/string.h b/include/string.h index c4bf1e4..ab232a8 100644 --- a/include/string.h +++ b/include/string.h @@ -22,8 +22,10 @@ size_t strlcat(char *dst, const char *src, size_t siz); #ifdef NO_STRNDUP char * strndup(const char *str, size_t maxlen); +#ifdef NO_STRNLEN size_t strnlen(const char *str, size_t maxlen); #endif +#endif #ifdef NO_EXPLICIT_BZERO void explicit_bzero(void *, size_t); -- cgit v1.2.3-55-g6feb