diff --git a/acconfig.h b/acconfig.h index bea917394..6c852f057 100644 --- a/acconfig.h +++ b/acconfig.h @@ -100,6 +100,12 @@ /* Define this if fnmatch is prototyped in fnmatch.h */ #undef HAVE_FNMATCH_PROTO +/* Define this if strnlen is prototyped in string.h */ +#undef HAVE_STRNLEN_PROTO + +/* Define this if fnmatch is prototyped in string.h */ +#undef HAVE_STRCASESTR_PROTO + /* Define this to something appropriate for declaring 0 length arrays */ #undef ZERO_LENGTH_ARRAY diff --git a/configure.ac b/configure.ac index dc5af4fbc..1813fb3b5 100644 --- a/configure.ac +++ b/configure.ac @@ -223,6 +223,24 @@ AC_TRY_COMPILE( AC_MSG_RESULT(no) ) +AC_MSG_CHECKING(for strnlen in string.h) +AC_TRY_COMPILE( + [#include "string.h"], + [int (*foo)() = strnlen;], + AC_DEFINE(HAVE_STRNLEN_PROTO) + AC_MSG_RESULT(yes), + AC_MSG_RESULT(no) +) + +AC_MSG_CHECKING(for strcasestr in string.h) +AC_TRY_COMPILE( + [#include "string.h"], + [int (*foo)() = strnlen;], + AC_DEFINE(HAVE_STRCASESTR_PROTO) + AC_MSG_RESULT(yes), + AC_MSG_RESULT(no) +) + AC_MSG_CHECKING(for type of fpos_t) AC_TRY_COMPILE( [#include ], @@ -307,8 +325,8 @@ AC_FUNC_VPRINTF AC_CHECK_FUNCS( access _access \ gethostname gethostbyname connect gettimeofday getwd mkdir _mkdir \ - ftime _ftime fcntl stat putenv select socket strerror strstr \ - snprintf _snprintf vsnprintf _vsnprintf strsep dlopen getaddrinfo \ + ftime _ftime fcntl stat putenv select socket strerror strcasestr strnlen \ + strstr snprintf _snprintf vsnprintf _vsnprintf strsep dlopen getaddrinfo \ getnameinfo mprotect ) diff --git a/include/compat.h b/include/compat.h index 1024a5ccb..cf5551b6a 100644 --- a/include/compat.h +++ b/include/compat.h @@ -91,13 +91,19 @@ extern int vsnprintf(char *s, size_t maxlen, const char *format, va_list arg); #if !defined(strncaseequal) # define strncaseequal(a,b,c) (strncasecmp (a, b, c) == 0) #endif -// FIXME: glibc has strcasestr, but only declares it if __USE_GNU is defined -#if !defined(strcasestr) +#ifdef HAVE_STRCASESTR +# ifndef HAVE_STRCASESTR_PROTO +extern char *strcasestr (const char *__haystack, const char *__needle); +# endif +#else # define strcasestr Q_strcasestr # define need_qstring_h #endif -// FIXME: same as above -#if !defined(strnlen) +#ifdef HAVE_STRNLEN +# ifndef HAVE_STRNLEN_PROTO +size_t strnlen (const char *str, size_t len); +# endif +#else # define strnlen Q_strnlen # define need_qstring_h #endif