mkstemp: Fix C++ test error on mingw.
authorBruno Haible <bruno@clisp.org>
Sat, 3 Apr 2010 11:44:41 +0000 (13:44 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 3 Apr 2010 11:44:41 +0000 (13:44 +0200)
ChangeLog
lib/stdlib.in.h
m4/mkstemp.m4
m4/stdlib_h.m4
modules/stdlib

index ed4e221..88fffb8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,12 +1,21 @@
 2010-04-03  Bruno Haible  <bruno@clisp.org>
 
+       mkstemp: Fix C++ test error on mingw.
+       * lib/stdlib.in.h (mkstemp): Use modern idiom.
+       * m4/mkstemp.m4 (gl_FUNC_MKSTEMP): Distinguish the case that the
+       function is missing and that it needs to be replaced.
+       * m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Initialize HAVE_MKSTEMP.
+       * modules/stdlib (Makefile.am): Substitute HAVE_MKSTEMP.
+
+2010-04-03  Bruno Haible  <bruno@clisp.org>
+
        stpncpy: Fix C++ test error on mingw.
        * lib/string.in.h (stpncpy): Use modern idiom.
        * m4/stpncpy.m4 (gl_FUNC_STPNCPY): Distinguish the case that the
        function is missing and that it needs to be replaced.
        * m4/string_h.m4 (gl_HEADER_STRING_H_DEFAULTS): Initialize
        REPLACE_STPNCPY.
-       * modules/string (Makefile.am): Replace REPLACE_STPNCPY.
+       * modules/string (Makefile.am): Substitute REPLACE_STPNCPY.
 
 2010-04-03  Bruno Haible  <bruno@clisp.org>
 
index 5c7c3f0..d74c251 100644 (file)
@@ -329,6 +329,9 @@ _GL_WARN_ON_USE (mkostemps, "mkostemps is unportable - "
 _GL_FUNCDECL_RPL (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
 _GL_CXXALIAS_RPL (mkstemp, int, (char * /*template*/));
 # else
+#  if ! @HAVE_MKSTEMP@
+_GL_FUNCDECL_SYS (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
+#  endif
 _GL_CXXALIAS_SYS (mkstemp, int, (char * /*template*/));
 # endif
 _GL_CXXALIASWARN (mkstemp);
index e4fee76..d6430a9 100644 (file)
@@ -1,4 +1,4 @@
-#serial 17
+#serial 18
 
 # Copyright (C) 2001, 2003-2007, 2009-2010 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
@@ -16,35 +16,41 @@ AC_DEFUN([gl_FUNC_MKSTEMP],
   AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
   AC_REQUIRE([AC_SYS_LARGEFILE])
 
-  AC_CACHE_CHECK([for working mkstemp],
-    [gl_cv_func_working_mkstemp],
-    [
-      mkdir conftest.mkstemp
-      AC_RUN_IFELSE(
-        [AC_LANG_PROGRAM(
-          [AC_INCLUDES_DEFAULT],
-          [[int i;
-            off_t large = (off_t) 4294967295u;
-            if (large < 0)
-              large = 2147483647;
-            for (i = 0; i < 70; i++)
-              {
-                char templ[] = "conftest.mkstemp/coXXXXXX";
-                int (*mkstemp_function) (char *) = mkstemp;
-                int fd = mkstemp_function (templ);
-                if (fd < 0 || lseek (fd, large, SEEK_SET) != large)
-                  return 1;
-                close (fd);
-              }
-            return 0;]])],
-        [gl_cv_func_working_mkstemp=yes],
-        [gl_cv_func_working_mkstemp=no],
-        [gl_cv_func_working_mkstemp=no])
-      rm -rf conftest.mkstemp
-    ])
-
-  if test $gl_cv_func_working_mkstemp != yes; then
-    REPLACE_MKSTEMP=1
+  AC_CHECK_FUNCS_ONCE([mkstemp])
+  if test $ac_cv_func_mkstemp = yes; then
+    AC_CACHE_CHECK([for working mkstemp],
+      [gl_cv_func_working_mkstemp],
+      [
+        mkdir conftest.mkstemp
+        AC_RUN_IFELSE(
+          [AC_LANG_PROGRAM(
+            [AC_INCLUDES_DEFAULT],
+            [[int i;
+              off_t large = (off_t) 4294967295u;
+              if (large < 0)
+                large = 2147483647;
+              for (i = 0; i < 70; i++)
+                {
+                  char templ[] = "conftest.mkstemp/coXXXXXX";
+                  int (*mkstemp_function) (char *) = mkstemp;
+                  int fd = mkstemp_function (templ);
+                  if (fd < 0 || lseek (fd, large, SEEK_SET) != large)
+                    return 1;
+                  close (fd);
+                }
+              return 0;]])],
+          [gl_cv_func_working_mkstemp=yes],
+          [gl_cv_func_working_mkstemp=no],
+          [gl_cv_func_working_mkstemp=no])
+        rm -rf conftest.mkstemp
+      ])
+    if test $gl_cv_func_working_mkstemp != yes; then
+      REPLACE_MKSTEMP=1
+      AC_LIBOBJ([mkstemp])
+      gl_PREREQ_MKSTEMP
+    fi
+  else
+    HAVE_MKSTEMP=0
     AC_LIBOBJ([mkstemp])
     gl_PREREQ_MKSTEMP
   fi
index 4c5cca8..dd84796 100644 (file)
@@ -1,4 +1,4 @@
-# stdlib_h.m4 serial 27
+# stdlib_h.m4 serial 28
 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -85,6 +85,7 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
   HAVE_MKDTEMP=1;            AC_SUBST([HAVE_MKDTEMP])
   HAVE_MKOSTEMP=1;           AC_SUBST([HAVE_MKOSTEMP])
   HAVE_MKOSTEMPS=1;          AC_SUBST([HAVE_MKOSTEMPS])
+  HAVE_MKSTEMP=1;            AC_SUBST([HAVE_MKSTEMP])
   HAVE_MKSTEMPS=1;           AC_SUBST([HAVE_MKSTEMPS])
   HAVE_PTSNAME=1;            AC_SUBST([HAVE_PTSNAME])
   HAVE_RANDOM_R=1;           AC_SUBST([HAVE_RANDOM_R])
index 26ea709..32a4e64 100644 (file)
@@ -62,6 +62,7 @@ stdlib.h: stdlib.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
              -e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \
              -e 's|@''HAVE_MKOSTEMP''@|$(HAVE_MKOSTEMP)|g' \
              -e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \
+             -e 's|@''HAVE_MKSTEMP''@|$(HAVE_MKSTEMP)|g' \
              -e 's|@''HAVE_MKSTEMPS''@|$(HAVE_MKSTEMPS)|g' \
              -e 's|@''HAVE_PTSNAME''@|$(HAVE_PTSNAME)|g' \
              -e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \