Don't check for strlcpy and strlcat in the configure script as simply #defining _XOPEN_SOURCE (what config.h does) is enough to prevent declarations of these functions from being included (thus the #inclusion of "frame.h" in strlfuncs.h should be enough (this should fix bug #11609)

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@4915 4a71c877-e1ca-e34f-864e-861f7616d084
master
Giel van Schijndel 2008-05-04 13:56:27 +00:00
parent 2c7d52d0c8
commit 45c2a0676c
2 changed files with 0 additions and 103 deletions

View File

@ -287,16 +287,6 @@ if test "x$host_os_mingw32" = "xyes" ; then
WIN32_LIBS="${WIN32_LIBS} ${BFD_LIBS} ${IBERTY_LIBS} -lstdc++"
fi
#
# Check for OS-supplied functions
#
# Check for strlcpy
AC_STRLCPY_CHECK
# Check for strlcat
AC_STRLCAT_CHECK
WZ_CPPFLAGS="${WZ_CPPFLAGS} -DDATADIR=\"\\\"\${datadir}/\${PACKAGE}\\\"\""
WZ_CPPFLAGS="${WZ_CPPFLAGS} -DLOCALEDIR=\"\\\"\${localedir}\\\"\""
WZ_CPPFLAGS="${WZ_CPPFLAGS} -I\$(top_srcdir)"

View File

@ -1,93 +0,0 @@
# strlfuncs.m4
dnl Copyright (C) 2008 Giel van Schijndel
dnl Copyright (C) 2008 Warzone Resurrection Project
dnl
dnl This file is free software; I (Giel van Schijndel) give unlimited permission
dnl to copy and/or distribute it, with or without modifications, as long as this
dnl notice is preserved.
# Define HAVE_STRLCPY when strlcpy(char* dst, const char* src, size_t size) is
# available and copies at the most (size - 1) into (dst) and always NUL
# terminates (dst) when (size) is at least one (1). The return value also _must_
# be strlen(src).
AC_DEFUN([AC_STRLCPY_CHECK],
[
AC_CACHE_CHECK([for OpenBSD or MacOSX strlcpy], ac_cv_have_strlcpy,[
AC_TRY_RUN([
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#define MIN(a, b) a > b ? b : a
int main()
{
static const char str[] = "teststring";
char b[10] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
size_t retval = strlcpy(b, str, sizeof(b));
/* Check for a proper return value */
if (retval != strlen(str))
{
fprintf(stderr, "Function strlcpy should return strlen(src) (%u) but returned %u.\n", (unsigned int)strlen(str), (unsigned int)retval);
return EXIT_FAILURE;
}
/* Check for proper NUL-termination */
else if (b[MIN(sizeof(b) - 1, strlen(str))] != '\0')
{
fprintf(stderr, "Function strlcpy didn't properly NUL-terminate it's target string.\n");
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
], ac_cv_have_strlcpy=yes, ac_cv_have_strlcpy=no, ac_cv_have_strlcpy=no)])
if test "$ac_cv_have_strlcpy" = "yes"; then
AC_DEFINE(HAVE_STRLCPY, 1, [Have function strlcpy])
fi
])
# Define HAVE_STRLCAT when strlcat(char* dst, const char* src, size_t size) is
# available and appends (src) to (dst) but copies at the most
# (size - strlen(dst) - 1) characters from (src) into (dst). It must also NUL
# terminate (dst) when (size) is at least one (1). The return value also _must_
# be strlen(src) + min(size, strlen((dst) before execution)).
AC_DEFUN([AC_STRLCAT_CHECK],
[
AC_CACHE_CHECK([for OpenBSD or MacOSX strlcat], ac_cv_have_strlcat,[
AC_TRY_RUN([
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
int main()
{
static const char catstr[] = "very long concatenation string that shouldn't get fully concatenated";
char str[20] = "teststring";
size_t retval = strlcat(str, catstr, 0);
size_t expretval;
/* Check for a proper return value */
if (retval != strlen(catstr))
{
fprintf(stderr, "strlcat(dst, str, 0) should return strlen(str) (%u) but it returned %u.\n", (unsigned int)strlen(str), (unsigned int)retval);
return EXIT_FAILURE;
}
/* Check for a proper return value in case of truncation */
expretval = strlen(str) + strlen(catstr);
retval = strlcat(str, catstr, sizeof(str));
if (retval != expretval)
{
fprintf(stderr, "strlcat(dst, str, sizeof(dst)) should return strlen(dst) + strlen(src) (%u) but it returned %u.\n", (unsigned int)expretval, (unsigned int)retval);
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
], ac_cv_have_strlcat=yes, ac_cv_have_strlcat=no, ac_cv_have_strlcat=no)])
if test "$ac_cv_have_strlcat" = "yes"; then
AC_DEFINE(HAVE_STRLCAT, 1, [Have function strlcat])
fi
])