From 8fb02d1cf73ecf992d2e1fbfdd28fa97ac08781b Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 18 Feb 2007 15:39:54 +0000 Subject: [PATCH] New module 'stdlib'. --- ChangeLog | 1 + MODULES.html.sh | 1 + lib/exit.h | 32 --------------------- lib/mkdtemp.h | 32 --------------------- lib/mkstemp.h | 31 --------------------- lib/stdlib_.h | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ m4/stdlib_h.m4 | 29 +++++++++++++++++++ modules/stdlib | 41 +++++++++++++++++++++++++++ 8 files changed, 158 insertions(+), 95 deletions(-) delete mode 100644 lib/exit.h delete mode 100644 lib/mkdtemp.h delete mode 100644 lib/mkstemp.h create mode 100644 lib/stdlib_.h create mode 100644 m4/stdlib_h.m4 create mode 100644 modules/stdlib diff --git a/ChangeLog b/ChangeLog index da1255e48..b03f0441c 100644 --- 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 diff --git a/MODULES.html.sh b/MODULES.html.sh index 30d96067c..c0b7b97b5 100755 --- a/MODULES.html.sh +++ b/MODULES.html.sh @@ -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 index e8f773883..000000000 --- a/lib/exit.h +++ /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 - -/* 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 index 617604801..000000000 --- a/lib/mkdtemp.h +++ /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 - -#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 index 9ed74116d..000000000 --- a/lib/mkstemp.h +++ /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 -#include - -#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 index 000000000..d2616a135 --- /dev/null +++ b/lib/stdlib_.h @@ -0,0 +1,86 @@ +/* A GNU-like . + + 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 index 000000000..6874441fc --- /dev/null +++ b/m4/stdlib_h.m4 @@ -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 index 000000000..d23fdc785 --- /dev/null +++ b/modules/stdlib @@ -0,0 +1,41 @@ +Description: +A GNU-like . + +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 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 + +License: +LGPL + +Maintainer: +all -- 2.11.0