From accb2e46c9c68b82bee7294ac100d7c3a29585a4 Mon Sep 17 00:00:00 2001 From: psychon Date: Thu, 22 Jan 2009 11:19:42 +0000 Subject: [PATCH] Check if lstat() is available and use stat() instead if it isn't git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1339 726aef4b-f618-498e-8847-2d620e286838 --- FileUtils.cpp | 4 ++++ configure | 48 ++++++++++++++++-------------------------------- configure.in | 2 +- 3 files changed, 21 insertions(+), 33 deletions(-) diff --git a/FileUtils.cpp b/FileUtils.cpp index d0498048..772a1883 100644 --- a/FileUtils.cpp +++ b/FileUtils.cpp @@ -12,6 +12,10 @@ #include #include +#ifndef HAVE_LSTAT +# define lstat(a, b) stat(a, b) +#endif + CFile::CFile() { m_iFD = -1; m_bClose = false; diff --git a/configure b/configure index b31dfcdb..34696a6b 100755 --- a/configure +++ b/configure @@ -2605,16 +2605,9 @@ _ACEOF fi - - - - -for ac_func in stat lstat chmod open -do -as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ echo "$as_me:$LINENO: checking for $ac_func" >&5 -echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } -if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then +{ echo "$as_me:$LINENO: checking for lstat" >&5 +echo $ECHO_N "checking for lstat... $ECHO_C" >&6; } +if test "${ac_cv_func_lstat+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -2623,12 +2616,12 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. +/* Define lstat to an innocuous variant, in case declares lstat. For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func +#define lstat innocuous_lstat /* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. + which can conflict with char lstat (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ @@ -2638,7 +2631,7 @@ cat >>conftest.$ac_ext <<_ACEOF # include #endif -#undef $ac_func +#undef lstat /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC @@ -2646,18 +2639,18 @@ cat >>conftest.$ac_ext <<_ACEOF #ifdef __cplusplus extern "C" #endif -char $ac_func (); +char lstat (); /* 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_$ac_func || defined __stub___$ac_func +#if defined __stub_lstat || defined __stub___lstat choke me #endif int main () { -return $ac_func (); +return lstat (); ; return 0; } @@ -2680,31 +2673,22 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then - eval "$as_ac_var=yes" + ac_cv_func_lstat=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - eval "$as_ac_var=no" + ac_cv_func_lstat=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi -ac_res=`eval echo '${'$as_ac_var'}'` - { echo "$as_me:$LINENO: result: $ac_res" >&5 -echo "${ECHO_T}$ac_res" >&6; } -if test `eval echo '${'$as_ac_var'}'` = yes; then - cat >>confdefs.h <<_ACEOF -#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -else - { { echo "$as_me:$LINENO: error: missing required libc feature" >&5 -echo "$as_me: error: missing required libc feature" >&2;} - { (exit 1); exit 1; }; } +{ echo "$as_me:$LINENO: result: $ac_cv_func_lstat" >&5 +echo "${ECHO_T}$ac_cv_func_lstat" >&6; } +if test $ac_cv_func_lstat = yes; then + appendCXX -DHAVE_LSTAT fi -done if test -z "$NOSSL"; then diff --git a/configure.in b/configure.in index c8760d19..9b19b988 100644 --- a/configure.in +++ b/configure.in @@ -110,7 +110,7 @@ if test "x$GXX" = "xyes"; then fi AC_CHECK_LIB( gnugetopt, getopt_long,) -AC_CHECK_FUNCS( stat lstat chmod open, , AC_MSG_ERROR([missing required libc feature])) +AC_CHECK_FUNC([lstat], [appendCXX -DHAVE_LSTAT]) if test -z "$NOSSL"; then if test -n "$OPENSSL"; then