New module 'stdlib'.
authorBruno Haible <bruno@clisp.org>
Sun, 18 Feb 2007 15:39:54 +0000 (15:39 +0000)
committerBruno Haible <bruno@clisp.org>
Sun, 18 Feb 2007 15:39:54 +0000 (15:39 +0000)
ChangeLog
MODULES.html.sh
lib/exit.h [deleted file]
lib/mkdtemp.h [deleted file]
lib/mkstemp.h [deleted file]
lib/stdlib_.h [new file with mode: 0644]
m4/stdlib_h.m4 [new file with mode: 0644]
modules/stdlib [new file with mode: 0644]

index da1255e..b03f044 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -31,6 +31,7 @@
        * lib/mkdtemp.h: Remove file.
        * lib/mkstemp.h: Remove file.
        * m4/stdlib_h.m4: New file.
+       * MODULES.html.sh (Support for systems lacking ANSI C 89): Add stdlib.
 
 2007-02-18  Bruno Haible  <bruno@clisp.org>
 
index 30d9606..c0b7b97 100755 (executable)
@@ -1490,6 +1490,7 @@ func_all_modules ()
   func_echo "$element"
 
   func_begin_table
+  func_module stdlib
   func_module exit
   func_module atexit
   func_module strtod
diff --git a/lib/exit.h b/lib/exit.h
deleted file mode 100644 (file)
index e8f7738..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/* exit() function.
-   Copyright (C) 1995, 2001 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.  */
-
-#ifndef _EXIT_H
-#define _EXIT_H
-
-/* Get exit() declaration.  */
-#include <stdlib.h>
-
-/* Some systems do not define EXIT_*, despite otherwise supporting C89.  */
-#ifndef EXIT_SUCCESS
-# define EXIT_SUCCESS 0
-#endif
-#ifndef EXIT_FAILURE
-# define EXIT_FAILURE 1
-#endif
-
-#endif /* _EXIT_H */
diff --git a/lib/mkdtemp.h b/lib/mkdtemp.h
deleted file mode 100644 (file)
index 6176048..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Creating a private temporary directory.
-   Copyright (C) 2001-2002 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.  */
-
-#if HAVE_MKDTEMP
-
-/* Get mkdtemp() declaration.  */
-#include <stdlib.h>
-
-#else
-
-/* Create a unique temporary directory from TEMPLATE.
-   The last six characters of TEMPLATE must be "XXXXXX";
-   they are replaced with a string that makes the directory name unique.
-   Returns TEMPLATE, or a null pointer if it cannot get a unique name.
-   The directory is created mode 700.  */
-extern char * mkdtemp (char *template);
-
-#endif
diff --git a/lib/mkstemp.h b/lib/mkstemp.h
deleted file mode 100644 (file)
index 9ed7411..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/* 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>
-#include <unistd.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
diff --git a/lib/stdlib_.h b/lib/stdlib_.h
new file mode 100644 (file)
index 0000000..d2616a1
--- /dev/null
@@ -0,0 +1,86 @@
+/* A GNU-like <stdlib.h>.
+
+   Copyright (C) 1995, 2001-2002, 2006-2007 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.  */
+
+#ifndef _GL_STDLIB_H
+#define _GL_STDLIB_H
+
+#include @ABSOLUTE_STDLIB_H@
+
+
+/* The definition of GL_LINK_WARNING is copied here.  */
+
+
+/* Some systems do not define EXIT_*, despite otherwise supporting C89.  */
+#ifndef EXIT_SUCCESS
+# define EXIT_SUCCESS 0
+#endif
+#ifndef EXIT_FAILURE
+# define EXIT_FAILURE 1
+#endif
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#if @GNULIB_MKDTEMP@
+# if !@HAVE_MKDTEMP@
+/* Create a unique temporary directory from TEMPLATE.
+   The last six characters of TEMPLATE must be "XXXXXX";
+   they are replaced with a string that makes the directory name unique.
+   Returns TEMPLATE, or a null pointer if it cannot get a unique name.
+   The directory is created mode 700.  */
+extern char * mkdtemp (char *template);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef mkdtemp
+# define mkdtemp(t) \
+    (GL_LINK_WARNING ("mkdtemp is unportable - "\
+                      "use gnulib module mkdtemp for portability"), \
+     mkdtemp (t))
+#endif
+
+#if @GNULIB_MKSTEMP@
+# if @REPLACE_MKSTEMP@
+/* Create a unique temporary file from TEMPLATE.
+   The last six characters of TEMPLATE must be "XXXXXX";
+   they are replaced with a string that makes the file name unique.
+   The file is then created, ensuring it didn't exist before.
+   The file is created read-write (mask at least 0600 & ~umask), but it may be
+   world-readable and world-writable (mask 0666 & ~umask), depending on the
+   implementation.
+   Returns the open file descriptor if successful, otherwise -1 and errno
+   set.  */
+#  define mkstemp rpl_mkstemp
+extern int mkstemp (char *template);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef mkstemp
+# define mkstemp(t) \
+    (GL_LINK_WARNING ("mkstemp is unportable - "\
+                      "use gnulib module mkstemp for portability"), \
+     mkstemp (t))
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/m4/stdlib_h.m4 b/m4/stdlib_h.m4
new file mode 100644 (file)
index 0000000..6874441
--- /dev/null
@@ -0,0 +1,29 @@
+# stdlib_h.m4 serial 1
+dnl Copyright (C) 2007 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_STDLIB_H],
+[
+  AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
+  gl_ABSOLUTE_HEADER([stdlib.h])
+  ABSOLUTE_STDLIB_H=\"$gl_cv_absolute_stdlib_h\"
+  AC_SUBST([ABSOLUTE_STDLIB_H])
+])
+
+AC_DEFUN([gl_STDLIB_MODULE_INDICATOR],
+[
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+  AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
+  GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
+])
+
+AC_DEFUN([gl_STDLIB_H_DEFAULTS],
+[
+  GNULIB_MKDTEMP=0;  AC_SUBST([GNULIB_MKDTEMP])
+  GNULIB_MKSTEMP=0;  AC_SUBST([GNULIB_MKSTEMP])
+  dnl Assume proper GNU behavior unless another module says otherwise.
+  HAVE_MKDTEMP=1;    AC_SUBST([HAVE_MKDTEMP])
+  REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP])
+])
diff --git a/modules/stdlib b/modules/stdlib
new file mode 100644 (file)
index 0000000..d23fdc7
--- /dev/null
@@ -0,0 +1,41 @@
+Description:
+A GNU-like <stdlib.h>.
+
+Files:
+lib/stdlib_.h
+m4/stdlib_h.m4
+
+Depends-on:
+absolute-header
+link-warning
+
+configure.ac:
+gl_STDLIB_H
+
+Makefile.am:
+BUILT_SOURCES += stdlib.h
+
+# We need the following in order to create <stdlib.h> when the system
+# doesn't have one that works with the given compiler.
+stdlib.h: stdlib_.h
+       rm -f $@-t $@
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+         sed -e 's|@''ABSOLUTE_STDLIB_H''@|$(ABSOLUTE_STDLIB_H)|g' \
+             -e 's|@''GNULIB_MKDTEMP''@|$(GNULIB_MKDTEMP)|g' \
+             -e 's|@''GNULIB_MKSTEMP''@|$(GNULIB_MKSTEMP)|g' \
+             -e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \
+             -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \
+             -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+             < $(srcdir)/stdlib_.h; \
+       } > $@-t
+       mv $@-t $@
+MOSTLYCLEANFILES += stdlib.h stdlib.h-t
+
+Include:
+#include <stdlib.h>
+
+License:
+LGPL
+
+Maintainer:
+all