-for ac_func in vsnprintf
+
+for ac_func in snprintf vsnprintf
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
fi
fi
+if test "$ac_cv_func_snprintf" = "yes"; then
+ echo "$as_me:$LINENO: checking for snprintf declaration" >&5
+echo $ECHO_N "checking for snprintf declaration... $ECHO_C" >&6
+if test "${wx_cv_func_snprintf_decl+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+ #include <stdio.h>
+ #include <stdarg.h>
+ #ifdef __MSL__
+ #if __MSL__ >= 0x6000
+ namespace std {}
+ using namespace std;
+ #endif
+ #endif
+
+int
+main ()
+{
+
+ char *buf;
+ const char *fmt = "%s";
+ snprintf(buf, 10u, fmt, "wx");
+
+ ;
+ 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_snprintf_decl=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+wx_cv_func_snprintf_decl=no
+
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+fi
+echo "$as_me:$LINENO: result: $wx_cv_func_snprintf_decl" >&5
+echo "${ECHO_T}$wx_cv_func_snprintf_decl" >&6
+
+ if test "$wx_cv_func_snprintf_decl" = "yes"; then
+ cat >>confdefs.h <<\_ACEOF
+#define HAVE_SNPRINTF_DECL 1
+_ACEOF
+
+ fi
+fi
+
if test "$wxUSE_UNICODE" = yes; then
dnl succeeds, even with C++ compiler, but the compilation of wxWidgets fails
dnl
dnl so we first check if the function is in the library
-AC_CHECK_FUNCS(vsnprintf)
+AC_CHECK_FUNCS(snprintf vsnprintf)
if test "$ac_cv_func_vsnprintf" = "yes"; then
dnl yes it is -- now check if it is in the headers
fi
fi
+dnl the same as above but for snprintf() now: it's not present in at least AIX
+dnl 4.2 headers
+if test "$ac_cv_func_snprintf" = "yes"; then
+ AC_CACHE_CHECK([for snprintf declaration], wx_cv_func_snprintf_decl,
+ [
+ AC_TRY_COMPILE(
+ [
+ #include <stdio.h>
+ #include <stdarg.h>
+ #ifdef __MSL__
+ #if __MSL__ >= 0x6000
+ namespace std {}
+ using namespace std;
+ #endif
+ #endif
+ ],
+ [
+ char *buf;
+ const char *fmt = "%s";
+ snprintf(buf, 10u, fmt, "wx");
+ ],
+ wx_cv_func_snprintf_decl=yes,
+ wx_cv_func_snprintf_decl=no
+ )
+ ]
+ )
+
+ if test "$wx_cv_func_snprintf_decl" = "yes"; then
+ AC_DEFINE(HAVE_SNPRINTF_DECL)
+ fi
+fi
+
if test "$wxUSE_UNICODE" = yes; then
dnl also look if we have wide char IO functions
AC_CHECK_FUNCS(wputc wputchar putws fputws wprintf vswprintf)
/* printf() family saga */
/*
- For some systems vsnprintf() exists in the system libraries but not in the
+ For some systems [v]snprintf() exists in the system libraries but not in the
headers, so we need to declare it ourselves to be able to use it.
*/
#if defined(HAVE_VSNPRINTF) && !defined(HAVE_VSNPRINTF_DECL)
int vsnprintf(char *str, size_t size, const char *format, va_list ap);
#endif /* !HAVE_VSNPRINTF_DECL */
+#if defined(HAVE_SNPRINTF) && !defined(HAVE_SNPRINTF_DECL)
+#ifdef __cplusplus
+ extern "C"
+#else
+ extern
+#endif
+ int snprintf(char *str, size_t size, const char *format, ...);
+#endif /* !HAVE_SNPRINTF_DECL */
+
/*
First of all, we always want to define safe snprintf() function to be used
instead of sprintf(). Some compilers already have it (or rather vsnprintf()
#endif
#else /* ASCII */
/* all versions of CodeWarrior supported by wxWidgets apparently have */
- /* vsnprintf() */
+ /* both snprintf() and vsnprintf() */
+ #ifdef HAVE_SNPRINTF || defined(__MWERKS__) || defined(__WATCOMC__)
+ #define wxSnprintf_ snprintf
+ #endif
#if defined(HAVE_VSNPRINTF) || defined(__MWERKS__) || defined(__WATCOMC__)
- /* assume we have snprintf() too if we have vsnprintf() */
#define wxVsnprintf_ vsnprintf
- #define wxSnprintf_ snprintf
#endif
#endif
#endif /* wxVsnprintf_ not defined yet */
/* Define if you have shl_load() */
#undef HAVE_SHL_LOAD
+/* Define if you have snprintf() */
+#undef HAVE_SNPRINTF
+
+/* Define if you have snprintf() declaration in the header */
+#undef HAVE_SNPRINTF_DECL
+
/* define if you have statfs function */
#undef HAVE_STATFS
/* Define if you have shl_load() */
#undef HAVE_SHL_LOAD
+/* Define if you have snprintf() */
+#undef HAVE_SNPRINTF
+
+/* Define if you have snprintf() declaration in the header */
+#undef HAVE_SNPRINTF_DECL
+
/* define if you have statfs function */
#undef HAVE_STATFS