From 1190e8018e461fc3f44533d4bab44200ec0f19bb Mon Sep 17 00:00:00 2001 From: Gerhard Rieger Date: Mon, 28 Dec 2020 00:41:41 +0100 Subject: [PATCH] Substitute strndup() when it is missing --- CHANGES | 5 ++++- compat.h | 4 ++++ config.h.in | 3 +++ configure.ac | 1 + 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 5efbf45..15fc1d5 100644 --- a/CHANGES +++ b/CHANGES @@ -17,7 +17,7 @@ Corrections: Unsetenv() was conditional in sysutils.c but not in xio-openssl.c thus building failed on Solaris 9. Thanks to Greg Earle for reporting this issue and providing a patch. - + Porting: In gcc version 10 the default changed from -fcommon to -fno-common. Consequently, linking filan and procan failed with error @@ -26,6 +26,9 @@ Porting: Debian issue 957823 Thanks to László Böszörményi and others for reporting this issue. + Solaris 9 does not provide strndup(); added substitute code. + Thanks to Greg Earle for providing a patch. + Testing: test.sh now produces a list of tests that could not be performed for any reason. This helps to analyse these cases. diff --git a/compat.h b/compat.h index d40ccc5..d68adf7 100644 --- a/compat.h +++ b/compat.h @@ -704,4 +704,8 @@ typedef int sig_atomic_t; extern const char *hstrerror(int); #endif +#if !HAVE_PROTOTYPE_LIB_strndup +extern char *strndup (const char *s, size_t n); +#endif + #endif /* !defined(__compat_h_included) */ diff --git a/config.h.in b/config.h.in index 17a6549..7a99c7c 100644 --- a/config.h.in +++ b/config.h.in @@ -114,6 +114,9 @@ /* Define if you have the inet_aton function. */ #undef HAVE_INET_ATON +/* Define if you have the strndup function. */ +#undef HAVE_PROTOTYPE_LIB_strndup + /* Define if you have the memrchr function. */ #undef HAVE_PROTOTYPE_LIB_memrchr diff --git a/configure.ac b/configure.ac index d788dc1..4b0bc09 100644 --- a/configure.ac +++ b/configure.ac @@ -777,6 +777,7 @@ AC_CHECK_PROTOTYPE_LIB(strdup) AC_CHECK_PROTOTYPE_LIB(strerror) AC_CHECK_PROTOTYPE_LIB(strstr) AC_CHECK_PROTOTYPE_LIB(getipnodebyname) +AC_CHECK_PROTOTYPE_LIB(strndup) AC_CHECK_PROTOTYPE_LIB(memrchr) AC_CHECK_PROTOTYPE_LIB(if_indextoname) AC_CHECK_PROTOTYPE_LIB(ptsname)