# Checking for functions/libs
# ===========================================================================
+
+AC_DEFUN(AC_CHECK_FUNC_NOCACHE,
+[AC_MSG_CHECKING([for $1])
+AC_TRY_LINK(
+dnl Don't include <ctype.h> because on OSF/1 3.0 it includes <sys/types.h>
+dnl which includes <sys/select.h> which contains a prototype for
+dnl select. Similarly for bzero.
+[/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $1(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
+extern "C"
+#endif
+])dnl
+[/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $1();
+], [
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$1) || defined (__stub___$1)
+choke me
+#else
+$1();
+#endif
+], eval "ac_cv_func_$1=yes", eval "ac_cv_func_$1=no")
+if eval "test \"`echo '$ac_cv_func_'$1`\" = yes"; then
+ AC_MSG_RESULT(yes)
+ ifelse([$2], , :, [$2])
+else
+ AC_MSG_RESULT(no)
+ifelse([$3], , , [$3
+])dnl
+fi
+])
+
AC_CHECK_LIB(socket,socket)
AC_CHECK_LIB(nsl,xdr_short)
AC_CHECK_LIB(panel,panel_above,
AC_SUBST(CURSES_LIBS)
AC_FUNC_VPRINTF
-AC_CHECK_FUNCS(vsnprintf vasprintf)
+dnl Do not cache the result of the vasprintf test.
+dnl This is because vasprintf is defined in the C++ runtime
+dnl for egcs, but not in the C runtime. Thus, caching the result
+dnl of this test (which is done with C++) will cause later C
+dnl based tests to falsely conclude that vasprintf is available
+dnl to C programs.
+dnl It's a bloody stupid function anyway.
+AC_CHECK_FUNC_NOCACHE(vasprintf)
AC_CHECK_FUNCS(strlen strcpy strcat strstr strcmp strerror strtok strdup)
-AC_CHECK_FUNCS(strchr memcpy)
+AC_CHECK_FUNCS(vsnprintf strchr memcpy)
dnl AC_CHECK_FUNCS(getline)
dnl AC_CHECK_FUNCS(getdelim)
AC_CHECK_FUNCS(fgets)