From: Ondřej Surý Date: Tue, 4 Sep 2018 19:10:02 +0000 (+0200) Subject: Replace platform ISC_PLATFORM_NEEDSTRLCPY and ISC_PLATFORM_NEEDSTRLCAT with AC_CHECK_... X-Git-Tag: v9.13.4~157^2~29 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=47f18c7d50f4993a1fe36945fbeaaf57fd63ebc7;p=thirdparty%2Fbind9.git Replace platform ISC_PLATFORM_NEEDSTRLCPY and ISC_PLATFORM_NEEDSTRLCAT with AC_CHECK_FUNCS call --- diff --git a/config.h.in b/config.h.in index 83a1e8a99e4..5ccb35efc5b 100644 --- a/config.h.in +++ b/config.h.in @@ -404,6 +404,12 @@ /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H +/* 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 header file. */ #undef HAVE_SYS_CAPABILITY_H diff --git a/configure b/configure index 8d44145be12..2ac9d6efb4d 100755 --- a/configure +++ b/configure @@ -716,8 +716,6 @@ DST_EXTRA_SRCS DST_EXTRA_OBJS USE_ISC_SPNEGO READLINE_LIB -ISC_PLATFORM_NEEDSTRLCAT -ISC_PLATFORM_NEEDSTRLCPY ISC_PLATFORM_HAVETFO BIND9_CO_RULE LIBTOOL_MODE_UNINSTALL @@ -17608,22 +17606,17 @@ esac # # Check for some other useful functions that are not ever-present. # -ac_fn_c_check_func "$LINENO" "strlcpy" "ac_cv_func_strlcpy" -if test "x$ac_cv_func_strlcpy" = xyes; then : - ISC_PLATFORM_NEEDSTRLCPY="#undef ISC_PLATFORM_NEEDSTRLCPY" -else - ISC_PLATFORM_NEEDSTRLCPY="#define ISC_PLATFORM_NEEDSTRLCPY 1" -fi - - +for ac_func in strlcpy strlcat +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF -ac_fn_c_check_func "$LINENO" "strlcat" "ac_cv_func_strlcat" -if test "x$ac_cv_func_strlcat" = xyes; then : - ISC_PLATFORM_NEEDSTRLCAT="#undef ISC_PLATFORM_NEEDSTRLCAT" -else - ISC_PLATFORM_NEEDSTRLCAT="#define ISC_PLATFORM_NEEDSTRLCAT 1" fi - +done diff --git a/configure.in b/configure.in index 5de4a1e3004..1b80783f467 100644 --- a/configure.in +++ b/configure.in @@ -1895,15 +1895,7 @@ AC_SUBST(ISC_PLATFORM_HAVETFO) # # Check for some other useful functions that are not ever-present. # -AC_CHECK_FUNC(strlcpy, - [ISC_PLATFORM_NEEDSTRLCPY="#undef ISC_PLATFORM_NEEDSTRLCPY"], - [ISC_PLATFORM_NEEDSTRLCPY="#define ISC_PLATFORM_NEEDSTRLCPY 1"]) -AC_SUBST(ISC_PLATFORM_NEEDSTRLCPY) - -AC_CHECK_FUNC(strlcat, - [ISC_PLATFORM_NEEDSTRLCAT="#undef ISC_PLATFORM_NEEDSTRLCAT"], - [ISC_PLATFORM_NEEDSTRLCAT="#define ISC_PLATFORM_NEEDSTRLCAT 1"]) -AC_SUBST(ISC_PLATFORM_NEEDSTRLCAT) +AC_CHECK_FUNCS([strlcpy strlcat]) AC_SUBST(READLINE_LIB) AC_ARG_WITH(readline, diff --git a/lib/isc/include/isc/platform.h.in b/lib/isc/include/isc/platform.h.in index ee6b87adb6d..ee1845bd25b 100644 --- a/lib/isc/include/isc/platform.h.in +++ b/lib/isc/include/isc/platform.h.in @@ -62,15 +62,6 @@ */ @ISC_PLATFORM_HAVEDEVPOLL@ -/* - *** Printing. - ***/ - -/* - * If the system needs strlcat(), ISC_PLATFORM_NEEDSTRLCAT will be defined. - */ -@ISC_PLATFORM_NEEDSTRLCAT@ - /*** *** Miscellaneous. ***/ diff --git a/lib/isc/include/isc/string.h b/lib/isc/include/isc/string.h index 52c959e340f..309b1277a6c 100644 --- a/lib/isc/include/isc/string.h +++ b/lib/isc/include/isc/string.h @@ -20,18 +20,14 @@ ISC_LANG_BEGINDECLS +#if !defined(HAVE_STRLCPY) size_t -isc_string_strlcpy(char *dst, const char *src, size_t size); - -#ifdef ISC_PLATFORM_NEEDSTRLCPY -#define strlcpy isc_string_strlcpy -#endif +strlcpy(char *dst, const char *src, size_t size); +#endif /* !defined(HAVE_STRLCPY) */ +#if !defined(HAVE_STRLCAT) size_t -isc_string_strlcat(char *dst, const char *src, size_t size); - -#ifdef ISC_PLATFORM_NEEDSTRLCAT -#define strlcat isc_string_strlcat +strlcat(char *dst, const char *src, size_t size); #endif int diff --git a/lib/isc/string.c b/lib/isc/string.c index 46e5303166d..096793da772 100644 --- a/lib/isc/string.c +++ b/lib/isc/string.c @@ -49,8 +49,9 @@ #include "isc/string.h" // IWYU pragma: keep +#if !defined(HAVE_STRLCPY) size_t -isc_string_strlcpy(char *dst, const char *src, size_t size) +strlcpy(char *dst, const char *src, size_t size) { char *d = dst; const char *s = src; @@ -76,9 +77,11 @@ isc_string_strlcpy(char *dst, const char *src, size_t size) return(s - src - 1); /* count does not include NUL */ } +#endif /* !defined(HAVE_STRLCPY) */ +#if !defined(HAVE_STRLCAT) size_t -isc_string_strlcat(char *dst, const char *src, size_t size) +strlcat(char *dst, const char *src, size_t size) { char *d = dst; const char *s = src; @@ -106,6 +109,7 @@ isc_string_strlcat(char *dst, const char *src, size_t size) return(dlen + (s - src)); /* count does not include NUL */ } +#endif /* !defined(HAVE_STRLCAT) */ int isc_string_strerror_r(int errnum, char *buf, size_t buflen) { diff --git a/lib/isc/win32/include/isc/platform.h.in b/lib/isc/win32/include/isc/platform.h.in index c01aad27649..1e0a0354dc0 100644 --- a/lib/isc/win32/include/isc/platform.h.in +++ b/lib/isc/win32/include/isc/platform.h.in @@ -46,9 +46,6 @@ #undef MSG_TRUNC -#define ISC_PLATFORM_NEEDSTRLCPY -#define ISC_PLATFORM_NEEDSTRLCAT - /* * Used to control how extern data is linked; needed for Win32 platforms. */