+2006-09-20 Paul Eggert <eggert@cs.ucla.edu>
+
+ * modules/mkstemp (Depends-on): Add extensions, so that
+ mkstemp is visible on some platforms.
+ (Makefile.am): Add mkstemp.h to EXTRA_DIST.
+
2006-09-19 Eric Blake <ebb9@byu.net>
* gnulib-tool: Avoid space-tab.
2006-09-20 Paul Eggert <eggert@cs.ucla.edu>
+ * mkstemp.h: New file, since some standard headers
+ #define mkstemp.
+ * mkstemp.c: Revamp to put the !_LIBC code together.
+ Include "mkstemp.h".
+ Make the _LIBC code resemble glibc original more,
+ e.g., use K&R style.
+ * stdlib--.h: Include mkstemp.h.
+
Import this patch from libc:
2006-04-07 Ulrich Drepper <drepper@redhat.com>
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
-#include <config.h>
-
-/* Disable the definition of mkstemp to rpl_mkstemp (from config.h) in this
- file. Otherwise, we'd get conflicting prototypes for rpl_mkstemp on
- most systems. */
-#undef mkstemp
+#if !_LIBC
+# include <config.h>
+# include "mkstemp.h"
+int __gen_tempname ();
+#endif
#include <stdio.h>
#include <stdlib.h>
# define __GT_FILE 0
#endif
-int __gen_tempname ();
-
/* Generate a unique temporary file name from TEMPLATE.
The last six characters of TEMPLATE must be "XXXXXX";
they are replaced with a string that makes the file name unique.
Then open the file and return a fd. */
int
-rpl_mkstemp (char *template)
+mkstemp (template)
+ char *template;
{
return __gen_tempname (template, __GT_FILE);
}
--- /dev/null
+/* Create a unique temporary file.
+
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+
+/* written by Jim Meyering */
+
+#include <stdlib.h>
+
+#ifdef __MKSTEMP_PREFIX
+# define _GL_CONCAT(x, y) x ## y
+# define _GL_XCONCAT(x, y) _GL_CONCAT (x, y)
+# define __MKSTEMP_ID(y) _GL_XCONCAT (__MKSTEMP_PREFIX, y)
+# undef mkstemp
+# define mkstemp __MKSTEMP_ID (mkstemp)
+int mkstemp (char *);
+#endif
/* Like stdlib.h, but redefine some names to avoid glitches.
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include <stdlib.h>
#include "stdlib-safer.h"
+#include "mkstemp.h"
#undef mkstemp
#define mkstemp mkstemp_safer
+2006-09-20 Paul Eggert <eggert@cs.ucla.edu>
+
+ * mkstemp.m4 (gl_FUNC_MKSTEMP): Require AC_SYS_LARGEFILE.
+ Check that large offsets work. Modernize Autoconf usages.
+ Prefer "yes" to mean a good thing rather than a bad.
+ Don't put "#define mkstemp" in config.h, as this might interfere
+ with standard system headers that "#define mkstemp mkstemp64".
+
2006-09-18 Bruno Haible <bruno@clisp.org>
* inttypes-h.m4 (gl_HEADER_INTTYPES_H): Remove macro.
-#serial 13
+#serial 14
# Copyright (C) 2001, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# only 32 files per process.
# On systems like the above, arrange to use the replacement function.
AC_DEFUN([gl_FUNC_MKSTEMP],
-[dnl
- AC_REPLACE_FUNCS(mkstemp)
- if test $ac_cv_func_mkstemp = no; then
- gl_cv_func_mkstemp_limitations=yes
- else
- AC_CACHE_CHECK([for mkstemp limitations],
- gl_cv_func_mkstemp_limitations,
- [
- mkdir conftest.mkstemp
- AC_TRY_RUN([
-# include <stdlib.h>
-# include <unistd.h>
- int main ()
- {
- int i;
- for (i = 0; i < 70; i++)
- {
- char template[] = "conftest.mkstemp/coXXXXXX";
- int fd = mkstemp (template);
- if (fd == -1)
- exit (1);
- close (fd);
- }
- exit (0);
- }
- ],
- gl_cv_func_mkstemp_limitations=no,
- gl_cv_func_mkstemp_limitations=yes,
- gl_cv_func_mkstemp_limitations=yes
- )
- rm -rf conftest.mkstemp
- ]
- )
- fi
+[
+ 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 template[] = "conftest.mkstemp/coXXXXXX";
+ int (*mkstemp_function) (char *) = mkstemp;
+ int fd = mkstemp_function (template);
+ 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_mkstemp_limitations = yes; then
+ if test $gl_cv_func_working_mkstemp != yes; then
+ AC_DEFINE([__MKSTEMP_PREFIX], [[rpl_]],
+ [Define to rpl_ if the mkstemp replacement function should be used.])
AC_LIBOBJ(mkstemp)
AC_LIBOBJ(tempname)
- AC_DEFINE(mkstemp, rpl_mkstemp,
- [Define to rpl_mkstemp if the replacement function should be used.])
gl_PREREQ_MKSTEMP
gl_PREREQ_TEMPNAME
fi
m4/mkstemp.m4
Depends-on:
+extensions
stat-macros
stdint
sys_stat
gl_FUNC_MKSTEMP
Makefile.am:
+EXTRA_DIST += mkstemp.h
Include:
<stdlib.h>