From ade35f11fe3931202fb44a08c7fcdd56751ff20d Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Sat, 1 Dec 2001 17:18:11 +0000
Subject: [PATCH] 1. added wxFileName::CreateTempFileName() and implemented it
 properly (using    mkstemp() when available) 2. wxTempFile::Open() and
 wxGetTempFileName() now use CreateTempFileName()    avoiding code duplication
 3. updated the docs

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12805 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 configure                   | 368 +++++++++++++++++++++---------------
 configure.in                |   3 +
 docs/latex/wx/filename.tex  |  31 ++-
 docs/latex/wx/function.tex  |  22 ++-
 include/wx/filefn.h         |   6 +-
 include/wx/filename.h       |   5 +-
 samples/console/console.cpp |  34 +++-
 setup.h.in                  |   6 +
 src/common/file.cpp         |  97 +++-------
 src/common/filefn.cpp       |  58 ++----
 src/common/filename.cpp     | 165 +++++++++++++++-
 11 files changed, 493 insertions(+), 302 deletions(-)

diff --git a/configure b/configure
index 34e46821ad..7dff8ce3ae 100755
--- a/configure
+++ b/configure
@@ -14464,13 +14464,69 @@ fi
 done
 
 
+for ac_func in mkstemp mktemp
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:14471: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 14476 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $ac_func(); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char $ac_func();
+
+int main() {
+
+/* 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)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:14499: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_func_$ac_func=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+    ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+  cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+ break
+else
+  echo "$ac_t""no" 1>&6
+fi
+done
+
+
 echo $ac_n "checking for statfs""... $ac_c" 1>&6
-echo "configure:14469: checking for statfs" >&5
+echo "configure:14525: checking for statfs" >&5
 if eval "test \"`echo '$''{'wx_cv_func_statfs'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 14474 "configure"
+#line 14530 "configure"
 #include "confdefs.h"
 
              #if defined(__BSD__)
@@ -14491,7 +14547,7 @@ int main() {
         
 ; return 0; }
 EOF
-if { (eval echo configure:14495: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:14551: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
              wx_cv_func_statfs=yes
@@ -14518,12 +14574,12 @@ EOF
 
 else
     echo $ac_n "checking for statvfs""... $ac_c" 1>&6
-echo "configure:14522: checking for statvfs" >&5
+echo "configure:14578: checking for statvfs" >&5
 if eval "test \"`echo '$''{'wx_cv_func_statvfs'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 14527 "configure"
+#line 14583 "configure"
 #include "confdefs.h"
 
                  #include <sys/statvfs.h>
@@ -14539,7 +14595,7 @@ int main() {
             
 ; return 0; }
 EOF
-if { (eval echo configure:14543: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:14599: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
                  wx_cv_func_statvfs=yes
@@ -14573,12 +14629,12 @@ if test "$wxUSE_SNGLINST_CHECKER" = "yes"; then
     for ac_func in fcntl flock
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:14577: checking for $ac_func" >&5
+echo "configure:14633: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 14582 "configure"
+#line 14638 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -14601,7 +14657,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:14605: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14661: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -14635,12 +14691,12 @@ fi
 for ac_func in timegm
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:14639: checking for $ac_func" >&5
+echo "configure:14695: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 14644 "configure"
+#line 14700 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -14663,7 +14719,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:14667: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14723: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -14691,12 +14747,12 @@ done
 for ac_func in putenv setenv
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:14695: checking for $ac_func" >&5
+echo "configure:14751: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 14700 "configure"
+#line 14756 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -14719,7 +14775,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:14723: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14779: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -14766,12 +14822,12 @@ if test "$HAVE_SOME_SLEEP_FUNC" != 1; then
     for ac_func in nanosleep
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:14770: checking for $ac_func" >&5
+echo "configure:14826: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 14775 "configure"
+#line 14831 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -14794,7 +14850,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:14798: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14854: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -14819,7 +14875,7 @@ EOF
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for nanosleep in -lposix4""... $ac_c" 1>&6
-echo "configure:14823: checking for nanosleep in -lposix4" >&5
+echo "configure:14879: checking for nanosleep in -lposix4" >&5
 ac_lib_var=`echo posix4'_'nanosleep | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -14827,7 +14883,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lposix4  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 14831 "configure"
+#line 14887 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -14838,7 +14894,7 @@ int main() {
 nanosleep()
 ; return 0; }
 EOF
-if { (eval echo configure:14842: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14898: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -14866,12 +14922,12 @@ else
                     for ac_func in usleep
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:14870: checking for $ac_func" >&5
+echo "configure:14926: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 14875 "configure"
+#line 14931 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -14894,7 +14950,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:14898: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:14954: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -14937,12 +14993,12 @@ fi
 for ac_func in uname gethostname
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:14941: checking for $ac_func" >&5
+echo "configure:14997: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 14946 "configure"
+#line 15002 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -14965,7 +15021,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:14969: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:15025: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -15002,12 +15058,12 @@ cross_compiling=$ac_cv_prog_cxx_cross
 for ac_func in strtok_r
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:15006: checking for $ac_func" >&5
+echo "configure:15062: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 15011 "configure"
+#line 15067 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -15033,7 +15089,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:15037: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:15093: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -15070,12 +15126,12 @@ INET_LINK=
 for ac_func in inet_addr
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:15074: checking for $ac_func" >&5
+echo "configure:15130: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 15079 "configure"
+#line 15135 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -15098,7 +15154,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:15102: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:15158: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -15123,7 +15179,7 @@ EOF
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for inet_addr in -lnsl""... $ac_c" 1>&6
-echo "configure:15127: checking for inet_addr in -lnsl" >&5
+echo "configure:15183: checking for inet_addr in -lnsl" >&5
 ac_lib_var=`echo nsl'_'inet_addr | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -15131,7 +15187,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lnsl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 15135 "configure"
+#line 15191 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -15142,7 +15198,7 @@ int main() {
 inet_addr()
 ; return 0; }
 EOF
-if { (eval echo configure:15146: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:15202: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -15161,7 +15217,7 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for inet_addr in -lresolv""... $ac_c" 1>&6
-echo "configure:15165: checking for inet_addr in -lresolv" >&5
+echo "configure:15221: checking for inet_addr in -lresolv" >&5
 ac_lib_var=`echo resolv'_'inet_addr | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -15169,7 +15225,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lresolv  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 15173 "configure"
+#line 15229 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -15180,7 +15236,7 @@ int main() {
 inet_addr()
 ; return 0; }
 EOF
-if { (eval echo configure:15184: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:15240: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -15213,12 +15269,12 @@ done
 for ac_func in inet_aton
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:15217: checking for $ac_func" >&5
+echo "configure:15273: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 15222 "configure"
+#line 15278 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -15241,7 +15297,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:15245: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:15301: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -15266,7 +15322,7 @@ EOF
 else
   echo "$ac_t""no" 1>&6
             echo $ac_n "checking for inet_aton in -l$INET_LINK""... $ac_c" 1>&6
-echo "configure:15270: checking for inet_aton in -l$INET_LINK" >&5
+echo "configure:15326: checking for inet_aton in -l$INET_LINK" >&5
 ac_lib_var=`echo $INET_LINK'_'inet_aton | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -15274,7 +15330,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$INET_LINK  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 15278 "configure"
+#line 15334 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -15285,7 +15341,7 @@ int main() {
 inet_aton()
 ; return 0; }
 EOF
-if { (eval echo configure:15289: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:15345: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -15400,7 +15456,7 @@ if test "$TOOLKIT" != "MSW"; then
         fi
 
                                 echo $ac_n "checking for pthread_create in -l$THREADS_LIB""... $ac_c" 1>&6
-echo "configure:15404: checking for pthread_create in -l$THREADS_LIB" >&5
+echo "configure:15460: checking for pthread_create in -l$THREADS_LIB" >&5
 ac_lib_var=`echo $THREADS_LIB'_'pthread_create | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -15408,7 +15464,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$THREADS_LIB  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 15412 "configure"
+#line 15468 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -15419,7 +15475,7 @@ int main() {
 pthread_create()
 ; return 0; }
 EOF
-if { (eval echo configure:15423: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:15479: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -15442,7 +15498,7 @@ else
   echo "$ac_t""no" 1>&6
 
                                 echo $ac_n "checking for pthread_create in -lc_r""... $ac_c" 1>&6
-echo "configure:15446: checking for pthread_create in -lc_r" >&5
+echo "configure:15502: checking for pthread_create in -lc_r" >&5
 ac_lib_var=`echo c_r'_'pthread_create | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -15450,7 +15506,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lc_r  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 15454 "configure"
+#line 15510 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -15461,7 +15517,7 @@ int main() {
 pthread_create()
 ; return 0; }
 EOF
-if { (eval echo configure:15465: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:15521: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -15485,17 +15541,17 @@ else
 
                                         ac_safe=`echo "sys/prctl.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for sys/prctl.h""... $ac_c" 1>&6
-echo "configure:15489: checking for sys/prctl.h" >&5
+echo "configure:15545: checking for sys/prctl.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 15494 "configure"
+#line 15550 "configure"
 #include "confdefs.h"
 #include <sys/prctl.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:15499: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:15555: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -15535,12 +15591,12 @@ fi
       for ac_func in thr_setconcurrency
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:15539: checking for $ac_func" >&5
+echo "configure:15595: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 15544 "configure"
+#line 15600 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -15563,7 +15619,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:15567: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:15623: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -15593,17 +15649,17 @@ done
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:15597: checking for $ac_hdr" >&5
+echo "configure:15653: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 15602 "configure"
+#line 15658 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:15607: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:15663: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -15631,7 +15687,7 @@ done
 
 
       echo $ac_n "checking for sched_yield in -l$THREADS_LINK""... $ac_c" 1>&6
-echo "configure:15635: checking for sched_yield in -l$THREADS_LINK" >&5
+echo "configure:15691: checking for sched_yield in -l$THREADS_LINK" >&5
 ac_lib_var=`echo $THREADS_LINK'_'sched_yield | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -15639,7 +15695,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$THREADS_LINK  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 15643 "configure"
+#line 15699 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -15650,7 +15706,7 @@ int main() {
 sched_yield()
 ; return 0; }
 EOF
-if { (eval echo configure:15654: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:15710: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -15672,7 +15728,7 @@ EOF
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for sched_yield in -lposix4""... $ac_c" 1>&6
-echo "configure:15676: checking for sched_yield in -lposix4" >&5
+echo "configure:15732: checking for sched_yield in -lposix4" >&5
 ac_lib_var=`echo posix4'_'sched_yield | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -15680,7 +15736,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lposix4  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 15684 "configure"
+#line 15740 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -15691,7 +15747,7 @@ int main() {
 sched_yield()
 ; return 0; }
 EOF
-if { (eval echo configure:15695: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:15751: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -15722,7 +15778,7 @@ fi
 
                                           HAVE_PRIOR_FUNCS=0
       echo $ac_n "checking for pthread_attr_getschedpolicy in -l$THREADS_LINK""... $ac_c" 1>&6
-echo "configure:15726: checking for pthread_attr_getschedpolicy in -l$THREADS_LINK" >&5
+echo "configure:15782: checking for pthread_attr_getschedpolicy in -l$THREADS_LINK" >&5
 ac_lib_var=`echo $THREADS_LINK'_'pthread_attr_getschedpolicy | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -15730,7 +15786,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$THREADS_LINK  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 15734 "configure"
+#line 15790 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -15741,7 +15797,7 @@ int main() {
 pthread_attr_getschedpolicy()
 ; return 0; }
 EOF
-if { (eval echo configure:15745: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:15801: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -15757,7 +15813,7 @@ fi
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
   echo $ac_n "checking for pthread_attr_setschedparam in -l$THREADS_LINK""... $ac_c" 1>&6
-echo "configure:15761: checking for pthread_attr_setschedparam in -l$THREADS_LINK" >&5
+echo "configure:15817: checking for pthread_attr_setschedparam in -l$THREADS_LINK" >&5
 ac_lib_var=`echo $THREADS_LINK'_'pthread_attr_setschedparam | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -15765,7 +15821,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$THREADS_LINK  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 15769 "configure"
+#line 15825 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -15776,7 +15832,7 @@ int main() {
 pthread_attr_setschedparam()
 ; return 0; }
 EOF
-if { (eval echo configure:15780: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:15836: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -15792,7 +15848,7 @@ fi
 if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
   echo "$ac_t""yes" 1>&6
   echo $ac_n "checking for sched_get_priority_max in -l$THREADS_LINK""... $ac_c" 1>&6
-echo "configure:15796: checking for sched_get_priority_max in -l$THREADS_LINK" >&5
+echo "configure:15852: checking for sched_get_priority_max in -l$THREADS_LINK" >&5
 ac_lib_var=`echo $THREADS_LINK'_'sched_get_priority_max | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -15800,7 +15856,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$THREADS_LINK  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 15804 "configure"
+#line 15860 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -15811,7 +15867,7 @@ int main() {
 sched_get_priority_max()
 ; return 0; }
 EOF
-if { (eval echo configure:15815: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:15871: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -15830,7 +15886,7 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for sched_get_priority_max in -lposix4""... $ac_c" 1>&6
-echo "configure:15834: checking for sched_get_priority_max in -lposix4" >&5
+echo "configure:15890: checking for sched_get_priority_max in -lposix4" >&5
 ac_lib_var=`echo posix4'_'sched_get_priority_max | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -15838,7 +15894,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lposix4  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 15842 "configure"
+#line 15898 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -15849,7 +15905,7 @@ int main() {
 sched_get_priority_max()
 ; return 0; }
 EOF
-if { (eval echo configure:15853: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:15909: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -15896,7 +15952,7 @@ EOF
       fi
 
       echo $ac_n "checking for pthread_cancel in -l$THREADS_LINK""... $ac_c" 1>&6
-echo "configure:15900: checking for pthread_cancel in -l$THREADS_LINK" >&5
+echo "configure:15956: checking for pthread_cancel in -l$THREADS_LINK" >&5
 ac_lib_var=`echo $THREADS_LINK'_'pthread_cancel | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -15904,7 +15960,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-l$THREADS_LINK  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 15908 "configure"
+#line 15964 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -15915,7 +15971,7 @@ int main() {
 pthread_cancel()
 ; return 0; }
 EOF
-if { (eval echo configure:15919: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:15975: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -15941,13 +15997,13 @@ fi
 
 
       echo $ac_n "checking for pthread_cleanup_push/pop""... $ac_c" 1>&6
-echo "configure:15945: checking for pthread_cleanup_push/pop" >&5
+echo "configure:16001: checking for pthread_cleanup_push/pop" >&5
 if eval "test \"`echo '$''{'wx_cv_func_pthread_cleanup_push'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
         cat > conftest.$ac_ext <<EOF
-#line 15951 "configure"
+#line 16007 "configure"
 #include "confdefs.h"
 #include <pthread.h>
 int main() {
@@ -15957,7 +16013,7 @@ int main() {
                      
 ; return 0; }
 EOF
-if { (eval echo configure:15961: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:16017: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
                         wx_cv_func_pthread_cleanup_push=yes
@@ -15989,13 +16045,13 @@ EOF
       fi
 
       echo $ac_n "checking for pthread_mutexattr_t""... $ac_c" 1>&6
-echo "configure:15993: checking for pthread_mutexattr_t" >&5
+echo "configure:16049: checking for pthread_mutexattr_t" >&5
 if eval "test \"`echo '$''{'wx_cv_type_pthread_mutexattr_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
         cat > conftest.$ac_ext <<EOF
-#line 15999 "configure"
+#line 16055 "configure"
 #include "confdefs.h"
 #include <pthread.h>
 int main() {
@@ -16005,7 +16061,7 @@ int main() {
             
 ; return 0; }
 EOF
-if { (eval echo configure:16009: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:16065: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
                wx_cv_type_pthread_mutexattr_t=yes
@@ -16032,13 +16088,13 @@ EOF
 
       else
                 echo $ac_n "checking for PTHREAD_RECURSIVE_MUTEX_INITIALIZER""... $ac_c" 1>&6
-echo "configure:16036: checking for PTHREAD_RECURSIVE_MUTEX_INITIALIZER" >&5
+echo "configure:16092: checking for PTHREAD_RECURSIVE_MUTEX_INITIALIZER" >&5
 if eval "test \"`echo '$''{'wx_cv_type_pthread_rec_mutex_init'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
             cat > conftest.$ac_ext <<EOF
-#line 16042 "configure"
+#line 16098 "configure"
 #include "confdefs.h"
 #include <pthread.h>
 int main() {
@@ -16047,7 +16103,7 @@ int main() {
                 
 ; return 0; }
 EOF
-if { (eval echo configure:16051: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:16107: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
                     wx_cv_type_pthread_rec_mutex_init=yes
@@ -16101,7 +16157,7 @@ EOF
 else
       if test "$ac_cv_func_strtok_r" = "yes"; then
     echo $ac_n "checking if -D_REENTRANT is needed""... $ac_c" 1>&6
-echo "configure:16105: checking if -D_REENTRANT is needed" >&5
+echo "configure:16161: checking if -D_REENTRANT is needed" >&5
     if test "$NEEDS_D_REENTRANT_FOR_R_FUNCS" = 1; then
         TOOLCHAIN_DEFS="${TOOLCHAIN_DEFS} -D_REENTRANT"
         echo "$ac_t""yes" 1>&6
@@ -16481,12 +16537,12 @@ if test "$wxUSE_DATETIME" = "yes"; then
         for ac_func in strptime
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:16485: checking for $ac_func" >&5
+echo "configure:16541: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 16490 "configure"
+#line 16546 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -16509,7 +16565,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:16513: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:16569: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -16535,13 +16591,13 @@ done
 
 
         echo $ac_n "checking for timezone variable in <time.h>""... $ac_c" 1>&6
-echo "configure:16539: checking for timezone variable in <time.h>" >&5
+echo "configure:16595: checking for timezone variable in <time.h>" >&5
 if eval "test \"`echo '$''{'wx_cv_var_timezone'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
                         cat > conftest.$ac_ext <<EOF
-#line 16545 "configure"
+#line 16601 "configure"
 #include "confdefs.h"
 
                                 #include <time.h>
@@ -16553,7 +16609,7 @@ int main() {
                             
 ; return 0; }
 EOF
-if { (eval echo configure:16557: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:16613: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
                                 wx_cv_var_timezone=timezone
@@ -16564,7 +16620,7 @@ else
   rm -rf conftest*
   
                                 cat > conftest.$ac_ext <<EOF
-#line 16568 "configure"
+#line 16624 "configure"
 #include "confdefs.h"
 
                                         #include <time.h>
@@ -16576,7 +16632,7 @@ int main() {
                                     
 ; return 0; }
 EOF
-if { (eval echo configure:16580: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:16636: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
                                         wx_cv_var_timezone=_timezone
@@ -16587,7 +16643,7 @@ else
   rm -rf conftest*
   
                                         cat > conftest.$ac_ext <<EOF
-#line 16591 "configure"
+#line 16647 "configure"
 #include "confdefs.h"
 
                                                 #include <time.h>
@@ -16599,7 +16655,7 @@ int main() {
                                             
 ; return 0; }
 EOF
-if { (eval echo configure:16603: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:16659: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
                                                 wx_cv_var_timezone=__timezone
@@ -16634,12 +16690,12 @@ EOF
         for ac_func in localtime
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:16638: checking for $ac_func" >&5
+echo "configure:16694: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 16643 "configure"
+#line 16699 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -16662,7 +16718,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:16666: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:16722: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -16689,13 +16745,13 @@ done
 
     if test "$ac_cv_func_localtime" = "yes"; then
         echo $ac_n "checking for tm_gmtoff in struct tm""... $ac_c" 1>&6
-echo "configure:16693: checking for tm_gmtoff in struct tm" >&5
+echo "configure:16749: checking for tm_gmtoff in struct tm" >&5
 if eval "test \"`echo '$''{'wx_cv_struct_tm_has_gmtoff'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   
             cat > conftest.$ac_ext <<EOF
-#line 16699 "configure"
+#line 16755 "configure"
 #include "confdefs.h"
 
                     #include <time.h>
@@ -16707,7 +16763,7 @@ int main() {
                 
 ; return 0; }
 EOF
-if { (eval echo configure:16711: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:16767: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   
                     wx_cv_struct_tm_has_gmtoff=yes
@@ -16736,12 +16792,12 @@ EOF
             for ac_func in gettimeofday ftime
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:16740: checking for $ac_func" >&5
+echo "configure:16796: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 16745 "configure"
+#line 16801 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -16764,7 +16820,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:16768: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:16824: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -16791,7 +16847,7 @@ done
 
     if test "$ac_cv_func_gettimeofday" = "yes"; then
         echo $ac_n "checking whether gettimeofday takes two arguments""... $ac_c" 1>&6
-echo "configure:16795: checking whether gettimeofday takes two arguments" >&5
+echo "configure:16851: checking whether gettimeofday takes two arguments" >&5
 if eval "test \"`echo '$''{'wx_cv_func_gettimeofday_has_2_args'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -16806,7 +16862,7 @@ cross_compiling=$ac_cv_prog_cxx_cross
 
 
             cat > conftest.$ac_ext <<EOF
-#line 16810 "configure"
+#line 16866 "configure"
 #include "confdefs.h"
 
                     #include <sys/time.h>
@@ -16819,7 +16875,7 @@ int main() {
                 
 ; return 0; }
 EOF
-if { (eval echo configure:16823: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:16879: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   wx_cv_func_gettimeofday_has_2_args=yes
 else
@@ -16827,7 +16883,7 @@ else
   cat conftest.$ac_ext >&5
   rm -rf conftest*
   cat > conftest.$ac_ext <<EOF
-#line 16831 "configure"
+#line 16887 "configure"
 #include "confdefs.h"
 
                         #include <sys/time.h>
@@ -16840,7 +16896,7 @@ int main() {
                     
 ; return 0; }
 EOF
-if { (eval echo configure:16844: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:16900: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   wx_cv_func_gettimeofday_has_2_args=no
 else
@@ -16889,12 +16945,12 @@ if test "$TOOLKIT" != "MSW"; then
 
     if test "$wxUSE_SOCKETS" = "yes"; then
                 echo $ac_n "checking for socket""... $ac_c" 1>&6
-echo "configure:16893: checking for socket" >&5
+echo "configure:16949: checking for socket" >&5
 if eval "test \"`echo '$''{'ac_cv_func_socket'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 16898 "configure"
+#line 16954 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char socket(); below.  */
@@ -16917,7 +16973,7 @@ socket();
 
 ; return 0; }
 EOF
-if { (eval echo configure:16921: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:16977: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_socket=yes"
 else
@@ -16935,7 +16991,7 @@ if eval "test \"`echo '$ac_cv_func_'socket`\" = yes"; then
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6
-echo "configure:16939: checking for socket in -lsocket" >&5
+echo "configure:16995: checking for socket in -lsocket" >&5
 ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -16943,7 +16999,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lsocket  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 16947 "configure"
+#line 17003 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -16954,7 +17010,7 @@ int main() {
 socket()
 ; return 0; }
 EOF
-if { (eval echo configure:16958: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:17014: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -16987,7 +17043,7 @@ fi
             
     if test "$wxUSE_SOCKETS" = "yes" ; then
                 echo $ac_n "checking what is the type of the third argument of getsockname""... $ac_c" 1>&6
-echo "configure:16991: checking what is the type of the third argument of getsockname" >&5
+echo "configure:17047: checking what is the type of the third argument of getsockname" >&5
 if eval "test \"`echo '$''{'wx_cv_type_getsockname3'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -17002,7 +17058,7 @@ cross_compiling=$ac_cv_prog_cxx_cross
 
 
                 cat > conftest.$ac_ext <<EOF
-#line 17006 "configure"
+#line 17062 "configure"
 #include "confdefs.h"
 
                         #include <sys/types.h>
@@ -17015,7 +17071,7 @@ int main() {
                     
 ; return 0; }
 EOF
-if { (eval echo configure:17019: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:17075: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   wx_cv_type_getsockname3=socklen_t
 else
@@ -17023,7 +17079,7 @@ else
   cat conftest.$ac_ext >&5
   rm -rf conftest*
   cat > conftest.$ac_ext <<EOF
-#line 17027 "configure"
+#line 17083 "configure"
 #include "confdefs.h"
 
                             #include <sys/types.h>
@@ -17036,7 +17092,7 @@ int main() {
                         
 ; return 0; }
 EOF
-if { (eval echo configure:17040: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:17096: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   wx_cv_type_getsockname3=size_t
 else
@@ -17044,7 +17100,7 @@ else
   cat conftest.$ac_ext >&5
   rm -rf conftest*
   cat > conftest.$ac_ext <<EOF
-#line 17048 "configure"
+#line 17104 "configure"
 #include "confdefs.h"
 
                                 #include <sys/types.h>
@@ -17057,7 +17113,7 @@ int main() {
                             
 ; return 0; }
 EOF
-if { (eval echo configure:17061: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:17117: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   wx_cv_type_getsockname3=int
 else
@@ -17125,17 +17181,17 @@ if test "$wxUSE_GUI" = "yes"; then
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:17129: checking for $ac_hdr" >&5
+echo "configure:17185: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 17134 "configure"
+#line 17190 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:17139: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:17195: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -17189,12 +17245,12 @@ if test "$TOOLKIT" != "MSW"; then
                                                 for ac_func in dlopen
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:17193: checking for $ac_func" >&5
+echo "configure:17249: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 17198 "configure"
+#line 17254 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -17217,7 +17273,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:17221: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:17277: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -17245,7 +17301,7 @@ EOF
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:17249: checking for dlopen in -ldl" >&5
+echo "configure:17305: checking for dlopen in -ldl" >&5
 ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -17253,7 +17309,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 17257 "configure"
+#line 17313 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -17264,7 +17320,7 @@ int main() {
 dlopen()
 ; return 0; }
 EOF
-if { (eval echo configure:17268: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:17324: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -17293,12 +17349,12 @@ else
                                 for ac_func in shl_load
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:17297: checking for $ac_func" >&5
+echo "configure:17353: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 17302 "configure"
+#line 17358 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -17321,7 +17377,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:17325: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:17381: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -17349,7 +17405,7 @@ EOF
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for dld in -lshl_load""... $ac_c" 1>&6
-echo "configure:17353: checking for dld in -lshl_load" >&5
+echo "configure:17409: checking for dld in -lshl_load" >&5
 ac_lib_var=`echo shl_load'_'dld | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -17357,7 +17413,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lshl_load  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 17361 "configure"
+#line 17417 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -17368,7 +17424,7 @@ int main() {
 dld()
 ; return 0; }
 EOF
-if { (eval echo configure:17372: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:17428: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -17407,12 +17463,12 @@ done
             for ac_func in dlerror
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:17411: checking for $ac_func" >&5
+echo "configure:17467: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 17416 "configure"
+#line 17472 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -17435,7 +17491,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:17439: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:17495: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -17460,7 +17516,7 @@ EOF
 else
   echo "$ac_t""no" 1>&6
 echo $ac_n "checking for dlerror in -ldl""... $ac_c" 1>&6
-echo "configure:17464: checking for dlerror in -ldl" >&5
+echo "configure:17520: checking for dlerror in -ldl" >&5
 ac_lib_var=`echo dl'_'dlerror | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -17468,7 +17524,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-ldl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 17472 "configure"
+#line 17528 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -17479,7 +17535,7 @@ int main() {
 dlerror()
 ; return 0; }
 EOF
-if { (eval echo configure:17483: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:17539: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -17636,17 +17692,17 @@ EOF
       if test "$wxUSE_MS_HTML_HELP" = "yes"; then
         ac_safe=`echo "htmlhelp.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for htmlhelp.h""... $ac_c" 1>&6
-echo "configure:17640: checking for htmlhelp.h" >&5
+echo "configure:17696: checking for htmlhelp.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 17645 "configure"
+#line 17701 "configure"
 #include "confdefs.h"
 #include <htmlhelp.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:17650: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:17706: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -17734,17 +17790,17 @@ if test "$wxUSE_MSW" = 1 -a \( "$wxUSE_DATAOBJ"       = "yes" \
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:17738: checking for $ac_hdr" >&5
+echo "configure:17794: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 17743 "configure"
+#line 17799 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:17748: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:17804: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -18645,7 +18701,7 @@ SAMPLES_SUBDIRS="`echo $SAMPLES_SUBDIRS | tr -s ' ' | tr ' ' '\n' | sort | uniq
 
 
 echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
-echo "configure:18649: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "configure:18705: checking whether ${MAKE-make} sets \${MAKE}" >&5
 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
diff --git a/configure.in b/configure.in
index eedc8ed2ab..2908fd07b7 100644
--- a/configure.in
+++ b/configure.in
@@ -3055,6 +3055,9 @@ fi
 dnl check for vfork() (even if it's the same as fork() in modern Unices)
 AC_CHECK_FUNCS(vfork)
 
+dnl check for the function for temp files creation
+AC_CHECK_FUNCS(mkstemp mktemp, break)
+
 dnl get the library function to use for wxGetDiskSpace(): it is statfs() under
 dnl Linux and *BSD and statvfs() under Solaris
 AC_CACHE_CHECK(for statfs, wx_cv_func_statfs,
diff --git a/docs/latex/wx/filename.tex b/docs/latex/wx/filename.tex
index 8f5ed74491..f20099f3ca 100644
--- a/docs/latex/wx/filename.tex
+++ b/docs/latex/wx/filename.tex
@@ -234,15 +234,33 @@ get the value of user home (Unix only mainly)
 
 \func{void}{AssignTempFileName}{\param{const wxString\& }{prefix}}
 
-get a temp file name starting with thespecified prefix
-
+The function calls \helpref{CreateTempFileName}{wxfilenamecreatetempfilename} to
+create a temporary file and sets this object to the name of the file. If a
+temporary file couldn't be created, the object is put into the\rtfsp
+\helpref{invalid}{wxfilenameisok} state.
 
 \membersection{wxFileName::Clear}\label{wxfilenameclear}
 
 \func{void}{Clear}{\void}
 
-reset all components to default, uninitialized state
+Reset all components to default, uninitialized state.
+
+\membersection{wxFileName::CreateTempFileName}{wxfilenamecreatetempfilename}
+
+\func{static wxString}{CreateTempFileName}{\param{const wxString\& }{prefix}}
+
+Returns a temporary file name starting with the given {\it prefix}. If
+the {\it prefix} is an absolute path, the temporary file is created in this
+directory, otherwise it is created in the default system directory for the
+temporary files or in the current directory.
 
+If the function succeeds, the temporary file is actually created (but not
+opened) as well. Under Unix, it will have read and write permissions for the
+owner only.
+
+\wxheading{Return value}
+
+The full temporary file name or an empty string on error.
 
 \membersection{wxFileName::DirExists}\label{wxfilenamedirexists}
 
@@ -443,9 +461,10 @@ are the file names of this type cases sensitive?
 
 \constfunc{bool}{IsOk}{\void}
 
-file tests
-is the filename valid at all?
-
+Returns {\tt TRUE} if the filename is valid, {\tt FALSE} if it is not
+initialized yet. The assignment functions and
+\helpref{Clear}{wxfilenameclear} may reset the object to the uninitialized,
+invalid state (the former only do it on failure).
 
 \membersection{wxFileName::IsPathSeparator}\label{wxfilenameispathseparator}
 
diff --git a/docs/latex/wx/function.tex b/docs/latex/wx/function.tex
index 49affc0f53..ee3b947473 100644
--- a/docs/latex/wx/function.tex
+++ b/docs/latex/wx/function.tex
@@ -265,15 +265,19 @@ if the buffer is NULL.
 
 \func{bool}{wxGetTempFileName}{\param{const wxString\& }{prefix}, \param{wxString\& }{buf}}
 
-Makes a temporary filename based on {\it prefix}, opens and closes the file,
-and places the name in {\it buf}. If {\it buf} is NULL, new store
-is allocated for the temporary filename using {\it new}.
-
-Under Windows, the filename will include the drive and name of the
-directory allocated for temporary files (usually the contents of the
-TEMP variable). Under Unix, the {\tt /tmp} directory is used.
-
-It is the application's responsibility to create and delete the file.
+%% Makes a temporary filename based on {\it prefix}, opens and closes the file,
+%% and places the name in {\it buf}. If {\it buf} is NULL, new store
+%% is allocated for the temporary filename using {\it new}.
+%%
+%% Under Windows, the filename will include the drive and name of the
+%% directory allocated for temporary files (usually the contents of the
+%% TEMP variable). Under Unix, the {\tt /tmp} directory is used.
+%%
+%% It is the application's responsibility to create and delete the file.
+
+These functions are obsolete, please use\rtfsp
+\helpref{wxFileName::CreateTempFileName}{wxfilenamecreatetempfilename}\rtfsp
+instead.
 
 \membersection{::wxIsWild}\label{wxiswild}
 
diff --git a/include/wx/filefn.h b/include/wx/filefn.h
index 3e66d0a536..e076faacfc 100644
--- a/include/wx/filefn.h
+++ b/include/wx/filefn.h
@@ -185,7 +185,7 @@ WXDLLEXPORT wxString wxUnix2MacFilename( const char *s);
 WXDLLEXPORT void wxStripExtension(wxChar *buffer);
 WXDLLEXPORT void wxStripExtension(wxString& buffer);
 
-// Get a temporary filename, opening and closing the file.
+// Get a temporary filename
 WXDLLEXPORT wxChar* wxGetTempFileName(const wxString& prefix, wxChar *buf = (wxChar *) NULL);
 WXDLLEXPORT bool wxGetTempFileName(const wxString& prefix, wxString& buf);
 
@@ -197,8 +197,8 @@ WXDLLEXPORT bool wxExpandPath(wxString& dest, const wxChar *path);
 // and make (if under the home tree) relative to home
 // [caller must copy-- volatile]
 WXDLLEXPORT wxChar* wxContractPath(const wxString& filename,
-				   const wxString& envname = wxEmptyString,
-				   const wxString& user = wxEmptyString);
+                                   const wxString& envname = wxEmptyString,
+                                   const wxString& user = wxEmptyString);
 
 // Destructive removal of /./ and /../ stuff
 WXDLLEXPORT wxChar* wxRealPath(wxChar *path);
diff --git a/include/wx/filename.h b/include/wx/filename.h
index 95666dc2b9..0b8bec879f 100644
--- a/include/wx/filename.h
+++ b/include/wx/filename.h
@@ -200,8 +200,9 @@ public:
     void AssignHomeDir();
     static wxString GetHomeDir();
 
-        // get a temp file name starting with thespecified prefix
-    void AssignTempFileName( const wxString &prefix );
+        // get a temp file name starting with the specified prefix
+    void AssignTempFileName(const wxString& prefix);
+    static wxString CreateTempFileName(const wxString& prefix);
 
     // directory creation and removal.
     // if full is TRUE, will try to make each directory in the path.
diff --git a/samples/console/console.cpp b/samples/console/console.cpp
index 91d9b70f85..051b4e253d 100644
--- a/samples/console/console.cpp
+++ b/samples/console/console.cpp
@@ -844,6 +844,35 @@ static void TestFileNameSplit()
     }
 }
 
+static void TestFileNameTemp()
+{
+    puts("*** testing wxFileName temp file creation ***");
+
+    static const char *tmpprefixes[] =
+    {
+        "foo",
+        "/tmp/foo",
+        "..",
+        "../bar",
+        "/tmp/foo/bar", // this one must be an error
+    };
+
+    for ( size_t n = 0; n < WXSIZEOF(tmpprefixes); n++ )
+    {
+        wxString path = wxFileName::CreateTempFileName(tmpprefixes[n]);
+        if ( !path.empty() )
+        {
+            printf("Prefix '%s'\t-> temp file '%s'\n",
+                   tmpprefixes[n], path.c_str());
+
+            if ( !wxRemoveFile(path) )
+            {
+                wxLogWarning("Failed to remove temp file '%s'", path.c_str());
+            }
+        }
+    }
+}
+
 static void TestFileNameComparison()
 {
     // TODO!
@@ -5187,10 +5216,11 @@ int main(int argc, char **argv)
 #endif // TEST_FILE
 
 #ifdef TEST_FILENAME
-    TestFileNameConstruction();
-    TestFileNameSplit();
+    TestFileNameTemp();
     if ( 0 )
     {
+    TestFileNameConstruction();
+    TestFileNameSplit();
         TestFileNameCwd();
         TestFileNameComparison();
         TestFileNameOperations();
diff --git a/setup.h.in b/setup.h.in
index 72b61840a2..a193068a07 100644
--- a/setup.h.in
+++ b/setup.h.in
@@ -964,6 +964,12 @@
 /* Define if you have the inet_aton function.  */
 #undef HAVE_INET_ATON
 
+/* Define if you have the mktemp function.  */
+#undef HAVE_MKTEMP
+
+/* Define if you have the mkstemp function.  */
+#undef HAVE_MKSTEMP
+
 /* Define if you have the nanosleep function.  */
 #undef HAVE_NANOSLEEP
 
diff --git a/src/common/file.cpp b/src/common/file.cpp
index 6f29068b42..cc53e66a0a 100644
--- a/src/common/file.cpp
+++ b/src/common/file.cpp
@@ -54,7 +54,6 @@
     #define   NOMCX
 #endif
 
-    #include  <windows.h>     // for GetTempFileName
 #elif (defined(__UNIX__) || defined(__GNUWIN32__))
     #include  <unistd.h>
     #ifdef __GNUWIN32__
@@ -121,10 +120,14 @@
 #endif // Salford C
 
 // wxWindows
-#include  "wx/string.h"
-#include  "wx/intl.h"
-#include  "wx/file.h"
-#include  "wx/log.h"
+#ifndef WX_PRECOMP
+    #include  "wx/string.h"
+    #include  "wx/intl.h"
+    #include  "wx/file.h"
+    #include  "wx/log.h"
+#endif // !WX_PRECOMP
+
+#include  "wx/filename.h"
 
 // ============================================================================
 // implementation of wxFile
@@ -465,87 +468,39 @@ bool wxTempFile::Open(const wxString& strName)
 {
     m_strName = strName;
 
-    // we want to create the file in the same directory as strName because
-    // otherwise rename() in Commit() might not work (if the files are on
-    // different partitions for example). Unfortunately, the only standard
-    // (POSIX) temp file creation function tmpnam() can't do it.
-#if defined(__UNIX__) || defined(__WXSTUBS__)|| defined( __WXMAC__ )
-    static const wxChar *szMktempSuffix = wxT("XXXXXX");
-    m_strTemp << strName << szMktempSuffix;
-    // can use the cast because length doesn't change
-    mktemp(wxMBSTRINGCAST m_strTemp.mb_str());
-#elif  defined(__WXPM__)
-    // for now just create a file
-    // future enhancements can be to set some extended attributes for file systems
-    // OS/2 supports that have them (HPFS, FAT32) and security (HPFS386)
-    static const wxChar *szMktempSuffix = wxT("XXX");
-    m_strTemp << strName << szMktempSuffix;
-    // Temporarily remove - MN
-    #ifndef __WATCOMC__
-    ::DosCreateDir(m_strTemp.GetWriteBuf(MAX_PATH), NULL);
-    #endif
-#else // Windows
-    wxString strPath;
-    wxSplitPath(strName, &strPath, NULL, NULL);
-    if ( strPath.IsEmpty() )
-        strPath = wxT('.');  // GetTempFileName will fail if we give it empty string
-#ifdef __WIN32__
-    if ( !GetTempFileName(strPath, wxT("wx_"),0, m_strTemp.GetWriteBuf(MAX_PATH)) )
-#else
-        // Not sure why MSVC++ 1.5 header defines first param as BYTE - bug?
-        if ( !GetTempFileName((BYTE) (DWORD)(const wxChar*) strPath, wxT("wx_"),0, m_strTemp.GetWriteBuf(MAX_PATH)) )
-#endif
-            wxLogLastError(wxT("GetTempFileName"));
-    m_strTemp.UngetWriteBuf();
-#endif  // Windows/Unix
+    m_strTemp = wxFileName::CreateTempFileName(strName);
+
+    if ( m_strTemp.empty() )
+    {
+        // CreateTempFileName() failed
+        return FALSE;
+    }
 
-    int access = wxS_DEFAULT;
 #ifdef __UNIX__
-    // create the file with the same mode as the original one under Unix
-    mode_t umaskOld = 0; // just to suppress compiler warning
-    bool changedUmask;
+    // the temp file should have the same permissions as the original one
+    mode_t mode;
 
     wxStructStat st;
     if ( stat(strName.fn_str(), &st) == 0 )
     {
-        // this assumes that only lower bits of st_mode contain the access
-        // rights, but it's true for at least all Unices which have S_IXXXX()
-        // macros, so should not be less portable than using (not POSIX)
-        // S_IFREG &c
-        access = st.st_mode & 0777;
-
-        // we want to create the file with exactly the same access rights as
-        // the original one, so disable the user's umask for the moment
-        umaskOld = umask(0);
-        changedUmask = TRUE;
+        mode = st.st_mode;
     }
     else
     {
-        // file probably didn't exist, just create with default mode _using_
+        // file probably didn't exist, just give it the default mode _using_
         // user's umask (new files creation should respect umask)
-        changedUmask = FALSE;
+        mode_t mask = umask(0777);
+        mode = 0666 & ~mask;
+        umask(mask);
     }
-#endif // Unix
-
-    // Open this file securely, since it surely should not exist unless
-    // nefarious activities (or other random bad things) are at play.
-
-    bool ok = m_file.Open(m_strTemp, wxFile::write_excl, access);
-
-    // FIXME: If !ok here should we loop and try again with another file
-    //        name?  That is the standard recourse if open(O_EXCL) fails,
-    //        though of course it should be protected against possible
-    //        infinite looping too.
 
-#ifdef __UNIX__
-    if ( changedUmask )
+    if ( chmod(m_strTemp.mb_str(), mode) == -1 )
     {
-        // restore umask now that the file is created
-        (void)umask(umaskOld);
+        wxLogSysError(_("Failed to set temporary file permissions"));
     }
 #endif // Unix
 
-    return ok;
+    return TRUE;
 }
 
 // ----------------------------------------------------------------------------
@@ -582,5 +537,5 @@ void wxTempFile::Discard()
         wxLogSysError(_("can't remove temporary file '%s'"), m_strTemp.c_str());
 }
 
-#endif
+#endif // wxUSE_FILE
 
diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp
index 4bdaf88176..8346e0eae8 100644
--- a/src/common/filefn.cpp
+++ b/src/common/filefn.cpp
@@ -1262,59 +1262,23 @@ bool wxPathExists(const wxChar *pszPathName)
 // Get a temporary filename, opening and closing the file.
 wxChar *wxGetTempFileName(const wxString& prefix, wxChar *buf)
 {
-#if defined(__WINDOWS__) && !defined(__WXMICROWIN__)
-
-#ifndef        __WIN32__
-  wxChar tmp[144];
-  ::GetTempFileName(0, WXSTRINGCAST prefix, 0, tmp);
-#else
-  wxChar tmp[MAX_PATH];
-  wxChar tmpPath[MAX_PATH];
-  ::GetTempPath(MAX_PATH, tmpPath);
-  ::GetTempFileName(tmpPath, WXSTRINGCAST prefix, 0, tmp);
-#endif
-  if (buf) wxStrcpy(buf, tmp);
-  else buf = copystring(tmp);
-  return buf;
+    wxString filename = wxFileName::CreateTempFileName(prefix);
+    if ( filename.empty() )
+        return NULL;
 
-#else
-  static short last_temp = 0;        // cache last to speed things a bit
-  // At most 1000 temp files to a process! We use a ring count.
-  wxChar tmp[100]; // FIXME static buffer
+    if ( buf )
+        wxStrcpy(buf, filename);
+    else
+        buf = copystring(filename);
 
-  for (short suffix = last_temp + 1; suffix != last_temp; ++suffix %= 1000)
-    {
-      wxSprintf (tmp, wxT("/tmp/%s%d.%03x"), WXSTRINGCAST prefix, (int) getpid (), (int) suffix);
-      if (!wxFileExists( tmp ))
-        {
-          // Touch the file to create it (reserve name)
-          FILE *fd = fopen (wxFNCONV(tmp), "w");
-          if (fd)
-            fclose (fd);
-          last_temp = suffix;
-          if (buf)
-            wxStrcpy( buf, tmp);
-          else
-            buf = copystring( tmp );
-          return buf;
-        }
-    }
-  wxLogError( _("wxWindows: error finding temporary file name.\n") );
-  if (buf) buf[0] = 0;
-  return (wxChar *) NULL;
-#endif
+    return buf;
 }
 
 bool wxGetTempFileName(const wxString& prefix, wxString& buf)
 {
-    wxChar buf2[512];
-    if (wxGetTempFileName(prefix, buf2) != (wxChar*) NULL)
-    {
-        buf = buf2;
-        return TRUE;
-    }
-    else
-        return FALSE;
+    buf = wxFileName::CreateTempFileName(prefix);
+
+    return !buf.empty();
 }
 
 // Get first file name matching given wild card.
diff --git a/src/common/filename.cpp b/src/common/filename.cpp
index 25dc0eecd9..221ebb8176 100644
--- a/src/common/filename.cpp
+++ b/src/common/filename.cpp
@@ -360,17 +360,170 @@ wxString wxFileName::GetHomeDir()
     return ::wxGetHomeDir();
 }
 
-void wxFileName::AssignTempFileName( const wxString &prefix )
+void wxFileName::AssignTempFileName( const wxString& prefix )
 {
-    wxString fullname;
-    if ( wxGetTempFileName(prefix, fullname) )
+    wxString tempname = CreateTempFileName(prefix);
+    if ( tempname.empty() )
     {
-        Assign(fullname);
+        // error, failed to get temp file name
+        Clear();
     }
-    else // error
+    else // ok
     {
-        Clear();
+        Assign(tempname);
+    }
+}
+
+/* static */
+wxString wxFileName::CreateTempFileName(const wxString& prefix)
+{
+    wxString path, dir, name;
+
+    // use the directory specified by the prefix
+    SplitPath(prefix, &dir, &name, NULL /* extension */);
+
+#if defined(__WINDOWS__) && !defined(__WXMICROWIN__)
+
+#ifdef __WIN32__
+    if ( dir.empty() )
+    {
+        if ( !::GetTempPath(MAX_PATH, wxStringBuffer(dir, MAX_PATH + 1)) )
+        {
+            wxLogLastError(_T("GetTempPath"));
+        }
+
+        if ( dir.empty() )
+        {
+            // GetTempFileName() fails if we pass it an empty string
+            dir = _T('.');
+        }
     }
+
+    if ( !::GetTempFileName(dir, name, 0, wxStringBuffer(path, MAX_PATH + 1)) )
+    {
+        wxLogLastError(_T("GetTempFileName"));
+
+        path.clear();
+    }
+#else // Win16
+    if ( !::GetTempFileName(NULL, prefix, 0, wxStringBuffer(path, 1025)) )
+    {
+        path.clear();
+    }
+#endif // Win32/16
+
+#elif defined(__WXPM__)
+    // for now just create a file
+    //
+    // future enhancements can be to set some extended attributes for file
+    // systems OS/2 supports that have them (HPFS, FAT32) and security
+    // (HPFS386)
+    static const wxChar *szMktempSuffix = wxT("XXX");
+    path << dir << _T('/') << name << szMktempSuffix;
+
+    // Temporarily remove - MN
+    #ifndef __WATCOMC__
+        ::DosCreateDir(wxStringBuffer(MAX_PATH), NULL);
+    #endif
+
+#else // !Windows, !OS/2
+    if ( dir.empty() )
+    {
+        dir = wxGetenv(_T("TMP"));
+        if ( path.empty() )
+        {
+            dir = wxGetenv(_T("TEMP"));
+        }
+
+        if ( dir.empty() )
+        {
+            // default
+            dir = _T("/tmp");
+        }
+    }
+
+    path = dir;
+
+    if ( !wxEndsWithPathSeparator(dir) &&
+            (name.empty() || !wxIsPathSeparator(name[0u])) )
+    {
+        path += _T('/');
+    }
+
+    path += name;
+
+#ifdef HAVE_MKSTEMP
+    // scratch space for mkstemp()
+    path += _T("XXXXXX");
+
+    // can use the cast here because the length doesn't change and the string
+    // is not shared
+    if ( mkstemp((char *)path.mb_str()) == -1 )
+    {
+        // this might be not necessary as mkstemp() on most systems should have
+        // already done it but it doesn't hurt neither...
+        path.clear();
+    }
+    //else: file already created
+#else // !HAVE_MKSTEMP
+
+#ifdef HAVE_MKTEMP
+    // same as above
+    path += _T("XXXXXX");
+
+    if ( !mktemp((char *)path.mb_str()) )
+    {
+        path.clear();
+    }
+#else // !HAVE_MKTEMP
+    // generate the unique file name ourselves
+    path << (unsigned int)getpid();
+
+    wxString pathTry;
+
+    static const size_t numTries = 1000;
+    for ( size_t n = 0; n < numTries; n++ )
+    {
+        // 3 hex digits is enough for numTries == 1000 < 4096
+        pathTry = path + wxString::Format(_T("%.03x"), n);
+        if ( !wxFile::Exists(pathTry) )
+        {
+            break;
+        }
+
+        pathTry.clear();
+    }
+
+    path = pathTry;
+#endif // HAVE_MKTEMP/!HAVE_MKTEMP
+
+    if ( !path.empty() )
+    {
+        // create the file - of course, there is a race condition here, this is
+        // why we always prefer using mkstemp()...
+        wxFile file;
+        if ( !file.Open(path, wxFile::write_excl, wxS_IRUSR | wxS_IWUSR) )
+        {
+            // FIXME: If !ok here should we loop and try again with another
+            //        file name?  That is the standard recourse if open(O_EXCL)
+            //        fails, though of course it should be protected against
+            //        possible infinite looping too.
+
+            wxLogError(_("Failed to open temporary file."));
+
+            path.clear();
+        }
+    }
+#endif // HAVE_MKSTEMP/!HAVE_MKSTEMP
+
+#endif // Windows/!Windows
+
+    if ( path.empty() )
+    {
+        wxLogSysError(_("Failed to create a temporary file name"));
+    }
+
+    return path;
 }
 
 // ----------------------------------------------------------------------------
-- 
2.50.0

