don't declare strptime() ourselves if the system already does it, we might have a slightly different declaration and this causes problems

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35699 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2005-09-25 22:34:03 +00:00
parent 20ceebaa87
commit f536f00539
3 changed files with 111 additions and 5 deletions

83
configure vendored
View File

@ -38965,6 +38965,89 @@ _ACEOF
fi
done
if test "$ac_cv_func_strptime" = "yes"; then
echo "$as_me:$LINENO: checking for strptime declaration" >&5
echo $ECHO_N "checking for strptime declaration... $ECHO_C" >&6
if test "${wx_cv_func_strptime_decl+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_ext=cc
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <time.h>
int
main ()
{
struct tm t;
strptime("foo", "bar", &t);
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest.$ac_objext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
wx_cv_func_strptime_decl=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
wx_cv_func_strptime_decl=no
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
fi
echo "$as_me:$LINENO: result: $wx_cv_func_strptime_decl" >&5
echo "${ECHO_T}$wx_cv_func_strptime_decl" >&6
fi
if test "$wx_cv_func_strptime_decl" = "yes"; then
cat >>confdefs.h <<\_ACEOF
#define HAVE_STRPTIME_DECL 1
_ACEOF
fi
echo "$as_me:$LINENO: checking for timezone variable in <time.h>" >&5
echo $ECHO_N "checking for timezone variable in <time.h>... $ECHO_C" >&6

View File

@ -5436,11 +5436,34 @@ fi
dnl ---------------------------------------------------------------------------
dnl time/date functions
dnl ------------------------------------------------------------------------
dnl ---------------------------------------------------------------------------
if test "$wxUSE_DATETIME" = "yes"; then
dnl check for strptime
dnl check for strptime and for its declaration as some systems lack it
AC_CHECK_FUNCS(strptime)
if test "$ac_cv_func_strptime" = "yes"; then
AC_CACHE_CHECK([for strptime declaration], wx_cv_func_strptime_decl,
[
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_TRY_COMPILE(
[
#include <time.h>
],
[
struct tm t;
strptime("foo", "bar", &t);
],
wx_cv_func_strptime_decl=yes,
wx_cv_func_strptime_decl=no
)
AC_LANG_RESTORE
]
)
fi
if test "$wx_cv_func_strptime_decl" = "yes"; then
AC_DEFINE(HAVE_STRPTIME_DECL)
fi
dnl check for timezone variable
dnl doesn't exist under Darwin / Mac OS X which uses tm_gmtoff instead

View File

@ -392,9 +392,9 @@ static wxString CallStrftime(const wxChar *format, const tm* tm)
#ifdef HAVE_STRPTIME
// glibc2 doesn't define this in the headers unless _XOPEN_SOURCE is defined
// which, unfortunately, wreaks havoc elsewhere
#if defined(__GLIBC__) && (__GLIBC__ == 2)
#if wxUSE_UNIX && !defined(HAVE_STRPTIME_DECL)
// configure detected that we had strptime() but not its declaration,
// provide it ourselves
extern "C" char *strptime(const char *, const char *, struct tm *);
#endif