diff --git a/CMakeLists.txt b/CMakeLists.txt index 85747f6262..74dd99ae05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -250,9 +250,7 @@ if(NOT MSVC) set(ZMQ_HAVE_LIBBSD 1) endif() endif() - if(NOT WITH_LIBBSD OR NOT LIBBSD_FOUND) - check_cxx_symbol_exists(strlcpy string.h ZMQ_HAVE_STRLCPY) - endif() + check_cxx_symbol_exists(strlcpy string.h ZMQ_HAVE_STRLCPY) endif() # Select curve encryption library, defaults to tweetnacl To use libsodium instead, use --with-libsodium(must be diff --git a/configure.ac b/configure.ac index 58a78e75ef..a7a1609af2 100644 --- a/configure.ac +++ b/configure.ac @@ -812,20 +812,18 @@ if test "x$enable_libbsd" != "xno"; then fi ]) fi -if test "x$found_libbsd" != "xyes"; then - AC_MSG_CHECKING([whether strlcpy is available]) - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[#include ]], - [[char buf [100]; size_t bar = strlcpy (buf, "foo", 100); (void)bar; return 0;]]) - ],[ - AC_MSG_RESULT([yes]) - AC_DEFINE(ZMQ_HAVE_STRLCPY, [1], - [strlcpy is available]) - ],[ - AC_MSG_RESULT([no]) - ]) -fi +AC_MSG_CHECKING([whether strlcpy is available]) +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include ]], + [[char buf [100]; size_t bar = strlcpy (buf, "foo", 100); (void)bar; return 0;]]) + ],[ + AC_MSG_RESULT([yes]) + AC_DEFINE(ZMQ_HAVE_STRLCPY, [1], + [strlcpy is available]) + ],[ + AC_MSG_RESULT([no]) +]) # pthread_setname is non-posix, and there are at least 4 different implementations AC_MSG_CHECKING([whether signature of pthread_setname_np() has 1 argument]) diff --git a/src/compat.hpp b/src/compat.hpp index 7c7a89275f..47744b98e2 100644 --- a/src/compat.hpp +++ b/src/compat.hpp @@ -37,9 +37,10 @@ #define strcasecmp _stricmp #define strtok_r strtok_s #else +#ifndef ZMQ_HAVE_STRLCPY #ifdef ZMQ_HAVE_LIBBSD #include -#elif !defined(ZMQ_HAVE_STRLCPY) +#else static inline size_t strlcpy (char *dest_, const char *src_, const size_t dest_size_) { @@ -50,6 +51,7 @@ strlcpy (char *dest_, const char *src_, const size_t dest_size_) return dest_size_ - remain; } #endif +#endif template static inline int strcpy_s (char (&dest_)[size], const char *const src_) {