[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[SCM] GNU libidn branch, master, updated. libidn-1-15-20-ga24f6d4
From: |
Simon Josefsson |
Subject: |
[SCM] GNU libidn branch, master, updated. libidn-1-15-20-ga24f6d4 |
Date: |
Thu, 08 Oct 2009 12:54:24 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU libidn".
http://git.savannah.gnu.org/cgit/libidn.git/commit/?id=a24f6d4f7c442dde0601d932d5dfb98695287719
The branch, master has been updated
via a24f6d4f7c442dde0601d932d5dfb98695287719 (commit)
from b8f98f068a027d9e0bf892db92bf124fa09588ab (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit a24f6d4f7c442dde0601d932d5dfb98695287719
Author: Simon Josefsson <address@hidden>
Date: Thu Oct 8 14:52:57 2009 +0200
Update gnulib files.
-----------------------------------------------------------------------
Summary of changes:
gl/Makefile.am | 14 +-
gl/getopt.in.h | 36 +++-
gl/getopt_int.h | 4 +-
gl/m4/alloca.m4 | 46 ++++
gl/m4/eealloc.m4 | 32 +++
gl/m4/getopt.m4 | 11 +-
gl/m4/gnulib-comp.m4 | 15 ++
gl/m4/malloca.m4 | 14 +
gl/m4/unistd_h.m4 | 9 +-
gl/progname.c | 15 +-
gl/unistd.in.h | 226 +++++++++++-------
gltests/Makefile.am | 61 +++++
gltests/alloca.in.h | 56 +++++
gltests/malloca.c | 137 +++++++++++
gltests/malloca.h | 134 +++++++++++
gltests/malloca.valgrind | 7 +
gltests/setenv.c | 330 ++++++++++++++++++++++++++
gltests/{test-stdlib.c => test-alloca-opt.c} | 45 +++-
gltests/test-getopt.c | 3 +
gltests/test-getopt_long.h | 21 ++
gltests/test-malloca.c | 59 +++++
lib/gltests/Makefile.am | 8 +
maint.mk | 10 +-
23 files changed, 1170 insertions(+), 123 deletions(-)
create mode 100644 gl/m4/alloca.m4
create mode 100644 gl/m4/eealloc.m4
create mode 100644 gl/m4/malloca.m4
create mode 100644 gltests/alloca.in.h
create mode 100644 gltests/malloca.c
create mode 100644 gltests/malloca.h
create mode 100644 gltests/malloca.valgrind
create mode 100644 gltests/setenv.c
copy gltests/{test-stdlib.c => test-alloca-opt.c} (51%)
create mode 100644 gltests/test-malloca.c
diff --git a/gl/Makefile.am b/gl/Makefile.am
index b822564..8605b81 100644
--- a/gl/Makefile.am
+++ b/gl/Makefile.am
@@ -97,7 +97,12 @@ BUILT_SOURCES += $(GETOPT_H)
getopt.h: getopt.in.h
$(AM_V_GEN)rm -f address@hidden $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
- cat $(srcdir)/getopt.in.h; \
+ sed -e 's|@''HAVE_GETOPT_H''@|$(HAVE_GETOPT_H)|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''NEXT_GETOPT_H''@|$(NEXT_GETOPT_H)|g' \
+ -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+ < $(srcdir)/getopt.in.h; \
} > address@hidden && \
mv -f address@hidden $@
MOSTLYCLEANFILES += getopt.h getopt.h-t
@@ -333,12 +338,14 @@ unistd.h: unistd.in.h
-e 's|@''GNULIB_GETUSERSHELL''@|$(GNULIB_GETUSERSHELL)|g' \
-e 's|@''GNULIB_LCHOWN''@|$(GNULIB_LCHOWN)|g' \
-e 's|@''GNULIB_LINK''@|$(GNULIB_LINK)|g' \
+ -e 's|@''GNULIB_LINKAT''@|$(GNULIB_LINKAT)|g' \
-e 's|@''GNULIB_LSEEK''@|$(GNULIB_LSEEK)|g' \
-e 's|@''GNULIB_PIPE2''@|$(GNULIB_PIPE2)|g' \
-e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \
-e 's|@''GNULIB_READLINKAT''@|$(GNULIB_READLINKAT)|g' \
-e 's|@''GNULIB_RMDIR''@|$(GNULIB_RMDIR)|g' \
-e 's|@''GNULIB_SLEEP''@|$(GNULIB_SLEEP)|g' \
+ -e 's|@''GNULIB_SYMLINK''@|$(GNULIB_SYMLINK)|g' \
-e 's|@''GNULIB_SYMLINKAT''@|$(GNULIB_SYMLINKAT)|g' \
-e 's|@''GNULIB_UNISTD_H_GETOPT''@|$(GNULIB_UNISTD_H_GETOPT)|g' \
-e 's|@''GNULIB_UNISTD_H_SIGPIPE''@|$(GNULIB_UNISTD_H_SIGPIPE)|g'
\
@@ -358,10 +365,12 @@ unistd.h: unistd.in.h
-e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \
-e 's|@''HAVE_GETUSERSHELL''@|$(HAVE_GETUSERSHELL)|g' \
-e 's|@''HAVE_LINK''@|$(HAVE_LINK)|g' \
+ -e 's|@''HAVE_LINKAT''@|$(HAVE_LINKAT)|g' \
-e 's|@''HAVE_PIPE2''@|$(HAVE_PIPE2)|g' \
-e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \
-e 's|@''HAVE_READLINKAT''@|$(HAVE_READLINKAT)|g' \
-e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \
+ -e 's|@''HAVE_SYMLINK''@|$(HAVE_SYMLINK)|g' \
-e 's|@''HAVE_SYMLINKAT''@|$(HAVE_SYMLINKAT)|g' \
-e 's|@''HAVE_UNLINKAT''@|$(HAVE_UNLINKAT)|g' \
-e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \
@@ -378,8 +387,11 @@ unistd.h: unistd.in.h
-e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \
-e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \
-e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \
+ -e 's|@''REPLACE_LINKAT''@|$(REPLACE_LINKAT)|g' \
-e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \
+ -e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \
-e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \
+ -e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \
-e 's|@''REPLACE_UNLINK''@|$(REPLACE_UNLINK)|g' \
-e 's|@''REPLACE_UNLINKAT''@|$(REPLACE_UNLINKAT)|g' \
-e 's|@''REPLACE_WRITE''@|$(REPLACE_WRITE)|g' \
diff --git a/gl/getopt.in.h b/gl/getopt.in.h
index d2d3e6e..7377f3c 100644
--- a/gl/getopt.in.h
+++ b/gl/getopt.in.h
@@ -1,5 +1,5 @@
/* Declarations for getopt.
- Copyright (C) 1989-1994,1996-1999,2001,2003,2004,2005,2006,2007
+ Copyright (C) 1989-1994,1996-1999,2001,2003,2004,2005,2006,2007,2009
Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -16,24 +16,42 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#ifndef _GETOPT_H
+#ifndef _GL_GETOPT_H
+
+#if __GNUC__ >= 3
address@hidden@
+#endif
+
+/* The include_next requires a split double-inclusion guard. We must
+ also inform the replacement unistd.h to not recursively use
+ <getopt.h>; our definitions will be present soon enough. */
+#if @HAVE_GETOPT_H@
+# define _GL_SYSTEM_GETOPT
+# @INCLUDE_NEXT@ @NEXT_GETOPT_H@
+# undef _GL_SYSTEM_GETOPT
+#endif
+
+#ifndef _GL_GETOPT_H
#ifndef __need_getopt
-# define _GETOPT_H 1
+# define _GL_GETOPT_H 1
#endif
/* Standalone applications should #define __GETOPT_PREFIX to an
identifier that prefixes the external functions and variables
defined in this header. When this happens, include the
headers that might declare getopt so that they will not cause
- confusion if included after this file. Then systematically rename
+ confusion if included after this file (if the system had <getopt.h>,
+ we have already included it). Then systematically rename
identifiers so that they do not collide with the system functions
and variables. Renaming avoids problems with some compilers and
linkers. */
#if defined __GETOPT_PREFIX && !defined __need_getopt
-# include <stdlib.h>
-# include <stdio.h>
-# include <unistd.h>
+# if address@hidden@
+# include <stdlib.h>
+# include <stdio.h>
+# include <unistd.h>
+# endif
# undef __need_getopt
# undef getopt
# undef getopt_long
@@ -42,6 +60,7 @@
# undef opterr
# undef optind
# undef optopt
+# undef option
# define __GETOPT_CONCAT(x, y) x ## y
# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y)
# define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y)
@@ -52,6 +71,8 @@
# define opterr __GETOPT_ID (opterr)
# define optind __GETOPT_ID (optind)
# define optopt __GETOPT_ID (optopt)
+# define option __GETOPT_ID (option)
+# define _getopt_internal __GETOPT_ID (getopt_internal)
#endif
/* Standalone applications get correct prototypes for getopt_long and
@@ -223,3 +244,4 @@ extern int getopt_long_only (int ___argc, char
*__getopt_argv_const *___argv,
#undef __need_getopt
#endif /* getopt.h */
+#endif /* getopt.h */
diff --git a/gl/getopt_int.h b/gl/getopt_int.h
index 3c6628b..69cdf0d 100644
--- a/gl/getopt_int.h
+++ b/gl/getopt_int.h
@@ -1,5 +1,5 @@
/* Internal declarations for getopt.
- Copyright (C) 1989-1994,1996-1999,2001,2003,2004
+ Copyright (C) 1989-1994,1996-1999,2001,2003,2004,2009
Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -19,6 +19,8 @@
#ifndef _GETOPT_INT_H
#define _GETOPT_INT_H 1
+#include <getopt.h>
+
extern int _getopt_internal (int ___argc, char **___argv,
const char *__shortopts,
const struct option *__longopts, int *__longind,
diff --git a/gl/m4/alloca.m4 b/gl/m4/alloca.m4
new file mode 100644
index 0000000..4b978e1
--- /dev/null
+++ b/gl/m4/alloca.m4
@@ -0,0 +1,46 @@
+# alloca.m4 serial 9
+dnl Copyright (C) 2002-2004, 2006, 2007, 2009 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_FUNC_ALLOCA],
+[
+ dnl Work around a bug of AC_EGREP_CPP in autoconf-2.57.
+ AC_REQUIRE([AC_PROG_CPP])
+ AC_REQUIRE([AC_PROG_EGREP])
+
+ AC_REQUIRE([AC_FUNC_ALLOCA])
+ if test $ac_cv_func_alloca_works = no; then
+ gl_PREREQ_ALLOCA
+ fi
+
+ # Define an additional variable used in the Makefile substitution.
+ if test $ac_cv_working_alloca_h = yes; then
+ AC_CACHE_CHECK([for alloca as a compiler built-in], [gl_cv_rpl_alloca], [
+ AC_EGREP_CPP([Need own alloca], [
+#if defined __GNUC__ || defined _AIX || defined _MSC_VER
+ Need own alloca
+#endif
+ ], [gl_cv_rpl_alloca=yes], [gl_cv_rpl_alloca=no])
+ ])
+ if test $gl_cv_rpl_alloca = yes; then
+ dnl OK, alloca can be implemented through a compiler built-in.
+ AC_DEFINE([HAVE_ALLOCA], [1],
+ [Define to 1 if you have 'alloca' after including <alloca.h>,
+ a header that may be supplied by this distribution.])
+ ALLOCA_H=alloca.h
+ else
+ dnl alloca exists as a library function, i.e. it is slow and probably
+ dnl a memory leak. Don't define HAVE_ALLOCA in this case.
+ ALLOCA_H=
+ fi
+ else
+ ALLOCA_H=alloca.h
+ fi
+ AC_SUBST([ALLOCA_H])
+])
+
+# Prerequisites of lib/alloca.c.
+# STACK_DIRECTION is already handled by AC_FUNC_ALLOCA.
+AC_DEFUN([gl_PREREQ_ALLOCA], [:])
diff --git a/gl/m4/eealloc.m4 b/gl/m4/eealloc.m4
new file mode 100644
index 0000000..3c9c0b5
--- /dev/null
+++ b/gl/m4/eealloc.m4
@@ -0,0 +1,32 @@
+# eealloc.m4 serial 2
+dnl Copyright (C) 2003, 2009 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_EEALLOC],
+[
+ AC_REQUIRE([gl_EEMALLOC])
+ AC_REQUIRE([gl_EEREALLOC])
+ AC_REQUIRE([AC_C_INLINE])
+])
+
+AC_DEFUN([gl_EEMALLOC],
+[
+ _AC_FUNC_MALLOC_IF(
+ [gl_cv_func_malloc_0_nonnull=1],
+ [gl_cv_func_malloc_0_nonnull=0])
+ AC_DEFINE_UNQUOTED([MALLOC_0_IS_NONNULL], [$gl_cv_func_malloc_0_nonnull],
+ [If malloc(0) is != NULL, define this to 1. Otherwise define this
+ to 0.])
+])
+
+AC_DEFUN([gl_EEREALLOC],
+[
+ _AC_FUNC_REALLOC_IF(
+ [gl_cv_func_realloc_0_nonnull=1],
+ [gl_cv_func_realloc_0_nonnull=0])
+ AC_DEFINE_UNQUOTED([REALLOC_0_IS_NONNULL], [$gl_cv_func_realloc_0_nonnull],
+ [If realloc(NULL,0) is != NULL, define this to 1. Otherwise define this
+ to 0.])
+])
diff --git a/gl/m4/getopt.m4 b/gl/m4/getopt.m4
index 7443dfe..8f0c36c 100644
--- a/gl/m4/getopt.m4
+++ b/gl/m4/getopt.m4
@@ -1,4 +1,4 @@
-# getopt.m4 serial 22
+# getopt.m4 serial 23
dnl Copyright (C) 2002-2006, 2008-2009 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -54,6 +54,15 @@ AC_DEFUN([gl_GETOPT_CHECK_HEADERS],
dnl Persuade Solaris <unistd.h> to declare optarg, optind, opterr, optopt.
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+ gl_CHECK_NEXT_HEADERS([getopt.h])
+ AC_CHECK_HEADERS_ONCE([getopt.h])
+ if test $ac_cv_header_getopt_h = yes; then
+ HAVE_GETOPT_H=1
+ else
+ HAVE_GETOPT_H=0
+ fi
+ AC_SUBST([HAVE_GETOPT_H])
+
gl_replace_getopt=
dnl Test whether <getopt.h> is available.
diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4
index 24df69d..c3a876f 100644
--- a/gl/m4/gnulib-comp.m4
+++ b/gl/m4/gnulib-comp.m4
@@ -71,6 +71,7 @@ AC_DEFUN([gl_INIT],
[GNUmakefile=$GNUmakefile])])
gl_PMCCABE2HTML
AC_CHECK_DECLS([program_invocation_name], [], [], [#include <errno.h>])
+ AC_CHECK_DECLS([program_invocation_short_name], [], [], [#include <errno.h>])
gl_STDARG_H
gl_STDDEF_H
gl_FUNC_STRERROR
@@ -118,9 +119,13 @@ AC_DEFUN([gl_INIT],
m4_pushdef([gltests_LIBSOURCES_DIR], [])
gl_COMMON
gl_source_base='gltests'
+ gl_FUNC_ALLOCA
gl_ENVIRON
gl_UNISTD_MODULE_INDICATOR([environ])
+ gl_MALLOCA
gl_MULTIARCH
+ gl_FUNC_SETENV
+ gl_STDLIB_MODULE_INDICATOR([setenv])
gl_STDINT_H
gt_TYPE_WCHAR_T
gt_TYPE_WINT_T
@@ -255,9 +260,11 @@ AC_DEFUN([gl_FILE_LIST], [
lib/version-etc.c
lib/version-etc.h
m4/00gnulib.m4
+ m4/alloca.m4
m4/autobuild.m4
m4/csharp.m4
m4/csharpcomp.m4
+ m4/eealloc.m4
m4/environ.m4
m4/errno_h.m4
m4/error.m4
@@ -266,6 +273,7 @@ AC_DEFUN([gl_FILE_LIST], [
m4/gnulib-common.m4
m4/include_next.m4
m4/longlong.m4
+ m4/malloca.m4
m4/manywarnings.m4
m4/multiarch.m4
m4/pmccabe2html.m4
@@ -282,11 +290,13 @@ AC_DEFUN([gl_FILE_LIST], [
m4/wchar.m4
m4/wchar_t.m4
m4/wint_t.m4
+ tests/test-alloca-opt.c
tests/test-environ.c
tests/test-errno.c
tests/test-getopt.c
tests/test-getopt.h
tests/test-getopt_long.h
+ tests/test-malloca.c
tests/test-stddef.c
tests/test-stdint.c
tests/test-stdlib.c
@@ -299,6 +309,11 @@ AC_DEFUN([gl_FILE_LIST], [
tests/test-version-etc.c
tests/test-version-etc.sh
tests/test-wchar.c
+ tests=lib/alloca.in.h
+ tests=lib/malloca.c
+ tests=lib/malloca.h
+ tests=lib/malloca.valgrind
+ tests=lib/setenv.c
tests=lib/stdint.in.h
tests=lib/stdlib.in.h
tests=lib/unsetenv.c
diff --git a/gl/m4/malloca.m4 b/gl/m4/malloca.m4
new file mode 100644
index 0000000..2841ae8
--- /dev/null
+++ b/gl/m4/malloca.m4
@@ -0,0 +1,14 @@
+# malloca.m4 serial 1
+dnl Copyright (C) 2003-2004, 2006-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_MALLOCA],
+[
+ dnl Use the autoconf tests for alloca(), but not the AC_SUBSTed variables
+ dnl @ALLOCA@ and @address@hidden
+ dnl gl_FUNC_ALLOCA dnl Already brought in by the module dependencies.
+ AC_REQUIRE([gl_EEMALLOC])
+ AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
+])
diff --git a/gl/m4/unistd_h.m4 b/gl/m4/unistd_h.m4
index 648fd86..5aa39ae 100644
--- a/gl/m4/unistd_h.m4
+++ b/gl/m4/unistd_h.m4
@@ -1,4 +1,4 @@
-# unistd_h.m4 serial 29
+# unistd_h.m4 serial 31
dnl Copyright (C) 2006-2009 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -52,12 +52,14 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
GNULIB_GETUSERSHELL=0; AC_SUBST([GNULIB_GETUSERSHELL])
GNULIB_LCHOWN=0; AC_SUBST([GNULIB_LCHOWN])
GNULIB_LINK=0; AC_SUBST([GNULIB_LINK])
+ GNULIB_LINKAT=0; AC_SUBST([GNULIB_LINKAT])
GNULIB_LSEEK=0; AC_SUBST([GNULIB_LSEEK])
GNULIB_PIPE2=0; AC_SUBST([GNULIB_PIPE2])
GNULIB_READLINK=0; AC_SUBST([GNULIB_READLINK])
GNULIB_READLINKAT=0; AC_SUBST([GNULIB_READLINKAT])
GNULIB_RMDIR=0; AC_SUBST([GNULIB_RMDIR])
GNULIB_SLEEP=0; AC_SUBST([GNULIB_SLEEP])
+ GNULIB_SYMLINK=0; AC_SUBST([GNULIB_SYMLINK])
GNULIB_SYMLINKAT=0; AC_SUBST([GNULIB_SYMLINKAT])
GNULIB_UNISTD_H_GETOPT=0; AC_SUBST([GNULIB_UNISTD_H_GETOPT])
GNULIB_UNISTD_H_SIGPIPE=0; AC_SUBST([GNULIB_UNISTD_H_SIGPIPE])
@@ -78,10 +80,12 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
HAVE_GETPAGESIZE=1; AC_SUBST([HAVE_GETPAGESIZE])
HAVE_GETUSERSHELL=1; AC_SUBST([HAVE_GETUSERSHELL])
HAVE_LINK=1; AC_SUBST([HAVE_LINK])
+ HAVE_LINKAT=1; AC_SUBST([HAVE_LINKAT])
HAVE_PIPE2=1; AC_SUBST([HAVE_PIPE2])
HAVE_READLINK=1; AC_SUBST([HAVE_READLINK])
HAVE_READLINKAT=1; AC_SUBST([HAVE_READLINKAT])
HAVE_SLEEP=1; AC_SUBST([HAVE_SLEEP])
+ HAVE_SYMLINK=1; AC_SUBST([HAVE_SYMLINK])
HAVE_SYMLINKAT=1; AC_SUBST([HAVE_SYMLINKAT])
HAVE_DECL_ENVIRON=1; AC_SUBST([HAVE_DECL_ENVIRON])
HAVE_DECL_GETLOGIN_R=1; AC_SUBST([HAVE_DECL_GETLOGIN_R])
@@ -98,8 +102,11 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
REPLACE_GETPAGESIZE=0; AC_SUBST([REPLACE_GETPAGESIZE])
REPLACE_LCHOWN=0; AC_SUBST([REPLACE_LCHOWN])
REPLACE_LINK=0; AC_SUBST([REPLACE_LINK])
+ REPLACE_LINKAT=0; AC_SUBST([REPLACE_LINKAT])
REPLACE_LSEEK=0; AC_SUBST([REPLACE_LSEEK])
+ REPLACE_READLINK=0; AC_SUBST([REPLACE_READLINK])
REPLACE_RMDIR=0; AC_SUBST([REPLACE_RMDIR])
+ REPLACE_SYMLINK=0; AC_SUBST([REPLACE_SYMLINK])
REPLACE_UNLINK=0; AC_SUBST([REPLACE_UNLINK])
REPLACE_UNLINKAT=0; AC_SUBST([REPLACE_UNLINKAT])
REPLACE_WRITE=0; AC_SUBST([REPLACE_WRITE])
diff --git a/gl/progname.c b/gl/progname.c
index 19df10a..bfa374a 100644
--- a/gl/progname.c
+++ b/gl/progname.c
@@ -48,7 +48,14 @@ set_program_name (const char *argv0)
{
argv0 = base;
if (strncmp (base, "lt-", 3) == 0)
- argv0 = base + 3;
+ {
+ argv0 = base + 3;
+ /* On glibc systems, remove the "lt-" prefix from the variable
+ program_invocation_short_name. */
+#if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
+ program_invocation_short_name = (char *) argv0;
+#endif
+ }
}
/* But don't strip off a leading <dirname>/ in general, because when the user
@@ -62,9 +69,9 @@ set_program_name (const char *argv0)
program_name = argv0;
- /* On glibc systems, when the gnulib module 'error' is not used, the error()
- function comes from libc and uses the variable program_invocation_name,
- not program_name. So set this variable as well. */
+ /* On glibc systems, the error() function comes from libc and uses the
+ variable program_invocation_name, not program_name. So set this variable
+ as well. */
#if HAVE_DECL_PROGRAM_INVOCATION_NAME
program_invocation_name = (char *) argv0;
#endif
diff --git a/gl/unistd.in.h b/gl/unistd.in.h
index 6936ad4..0e31883 100644
--- a/gl/unistd.in.h
+++ b/gl/unistd.in.h
@@ -41,13 +41,15 @@
/* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>. */
#include <stdlib.h>
-#if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
+#if ((@GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@) \
+ || (@GNULIB_READLINK@ && (address@hidden@ || @REPLACE_READLINK@)) \
+ || (@GNULIB_READLINKAT@ && address@hidden@))
/* Get ssize_t. */
# include <sys/types.h>
#endif
/* Get getopt(), optarg, optind, opterr, optopt. */
-#if @GNULIB_UNISTD_H_GETOPT@
+#if @GNULIB_UNISTD_H_GETOPT@ && !defined _GL_SYSTEM_GETOPT
# include <getopt.h>
#endif
@@ -106,7 +108,7 @@
# define STDERR_FILENO 2
#endif
-/* Ensure *_OK functions exist. */
+/* Ensure *_OK macros exist. */
#ifndef F_OK
# define F_OK 0
# define X_OK 1
@@ -147,91 +149,6 @@ extern int chown (const char *file, uid_t uid, gid_t gid);
#endif
-#if @GNULIB_FCHOWNAT@
-# if @REPLACE_FCHOWNAT@
-# undef fchownat
-# define fchownat rpl_fchownat
-# endif
-# if address@hidden@ || @REPLACE_FCHOWNAT@
-extern int fchownat (int fd, char const *file, uid_t owner, gid_t group, int
flag);
-# endif
-#elif defined GNULIB_POSIXCHECK
-# undef fchownat
-# define fchownat(d,n,o,g,f) \
- (GL_LINK_WARNING ("fchownat is not portable - " \
- "use gnulib module openat for portability"), \
- fchownat (d, n, o, g, f))
-#endif
-
-
-#if @GNULIB_UNLINK@
-# if @REPLACE_UNLINK@
-# undef unlink
-# define unlink rpl_unlink
-extern int unlink (char const *file);
-# endif
-#elif defined GNULIB_POSIXCHECK
-# undef unlink
-# define unlink(n) \
- (GL_LINK_WARNING ("unlink is not portable - " \
- "use gnulib module unlink for portability"), \
- unlink (n))
-#endif
-
-
-#if @GNULIB_UNLINKAT@
-# if @REPLACE_UNLINKAT@
-# undef unlinkat
-# define unlinkat rpl_unlinkat
-# endif
-# if address@hidden@ || @REPLACE_UNLINKAT@
-extern int unlinkat (int fd, char const *file, int flag);
-# endif
-#elif defined GNULIB_POSIXCHECK
-# undef unlinkat
-# define unlinkat(d,n,f) \
- (GL_LINK_WARNING ("unlinkat is not portable - " \
- "use gnulib module openat for portability"), \
- unlinkat (d, n, f))
-#endif
-
-
-#if @GNULIB_FACCESSAT@
-# if address@hidden@
-int faccessat (int fd, char const *file, int mode, int flag);
-# endif
-#elif defined GNULIB_POSIXCHECK
-# undef faccessat
-# define faccessat(d,n,m,f) \
- (GL_LINK_WARNING ("faccessat is not portable - " \
- "use gnulib module faccessat for portability"), \
- faccessat (d, n, m, f))
-#endif
-
-#if @GNULIB_SYMLINKAT@
-# if address@hidden@
-int symlinkat (char const *contents, int fd, char const *file);
-# endif
-#elif defined GNULIB_POSIXCHECK
-# undef symlinkat
-# define symlinkat(c,d,n) \
- (GL_LINK_WARNING ("symlinkat is not portable - " \
- "use gnulib module symlinkat for portability"), \
- symlinkat (c, d, n))
-#endif
-
-#if @GNULIB_READLINKAT@
-# if address@hidden@
-ssize_t readlinkat (int fd, char const *file, char *buf, size_t len);
-# endif
-#elif defined GNULIB_POSIXCHECK
-# undef readlinkat
-# define readlinkat(d,n,b,l) \
- (GL_LINK_WARNING ("readlinkat is not portable - " \
- "use gnulib module symlinkat for portability"), \
- readlinkat (d, n, b, l))
-#endif
-
#if @GNULIB_CLOSE@
# if @REPLACE_CLOSE@
/* Automatically included by modules that need a replacement for close. */
@@ -250,11 +167,13 @@ extern int close (int);
close (f))
#endif
+
#if @REPLACE_DUP@
# define dup rpl_dup
extern int dup (int);
#endif
+
#if @GNULIB_DUP2@
# if @REPLACE_DUP2@
# define dup2 rpl_dup2
@@ -333,6 +252,19 @@ extern int euidaccess (const char *filename, int mode);
#endif
+#if @GNULIB_FACCESSAT@
+# if address@hidden@
+int faccessat (int fd, char const *file, int mode, int flag);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef faccessat
+# define faccessat(d,n,m,f) \
+ (GL_LINK_WARNING ("faccessat is not portable - " \
+ "use gnulib module faccessat for portability"), \
+ faccessat (d, n, m, f))
+#endif
+
+
#if @GNULIB_FCHDIR@
# if @REPLACE_FCHDIR@
/* Change the process' current working directory to the directory on which
@@ -358,6 +290,23 @@ extern const char *_gl_directory_name (int fd);
#endif
+#if @GNULIB_FCHOWNAT@
+# if @REPLACE_FCHOWNAT@
+# undef fchownat
+# define fchownat rpl_fchownat
+# endif
+# if address@hidden@ || @REPLACE_FCHOWNAT@
+extern int fchownat (int fd, char const *file, uid_t owner, gid_t group, int
flag);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef fchownat
+# define fchownat(d,n,o,g,f) \
+ (GL_LINK_WARNING ("fchownat is not portable - " \
+ "use gnulib module openat for portability"), \
+ fchownat (d, n, o, g, f))
+#endif
+
+
#if @GNULIB_FSYNC@
/* Synchronize changes to a file.
Return 0 if successful, otherwise -1 and errno set.
@@ -632,6 +581,25 @@ extern int link (const char *path1, const char *path2);
link (path1, path2))
#endif
+#if @GNULIB_LINKAT@
+# if @REPLACE_LINKAT@
+# undef linkat
+# define linkat rpl_linkat
+# endif
+/* Create a new hard link for an existing file, relative to two
+ directories. FLAG controls whether symlinks are followed.
+ Return 0 if successful, otherwise -1 and errno set. */
+# if address@hidden@ || @REPLACE_LINKAT@
+extern int linkat (int fd1, const char *path1, int fd2, const char *path2,
+ int flag);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef linkat
+# define link(f1,path1,f2,path2,f) \
+ (GL_LINK_WARNING ("linkat is unportable - " \
+ "use gnulib module linkat for portability"), \
+ linkat (f1, path1, f2, path2,f))
+#endif
#if @GNULIB_LSEEK@
# if @REPLACE_LSEEK@
@@ -674,13 +642,16 @@ extern int pipe2 (int fd[2], int flags);
#if @GNULIB_READLINK@
+# if @REPLACE_READLINK@
+# define readlink rpl_readlink
+# endif
/* Read the contents of the symbolic link FILE and place the first BUFSIZE
bytes of it into BUF. Return the number of bytes placed into BUF if
successful, otherwise -1 and errno set.
See the POSIX:2001 specification
<http://www.opengroup.org/susv3xsh/readlink.html>. */
-# if address@hidden@
-extern int readlink (const char *file, char *buf, size_t bufsize);
+# if address@hidden@ || @REPLACE_READLINK@
+extern ssize_t readlink (const char *file, char *buf, size_t bufsize);
# endif
#elif defined GNULIB_POSIXCHECK
# undef readlink
@@ -691,6 +662,19 @@ extern int readlink (const char *file, char *buf, size_t
bufsize);
#endif
+#if @GNULIB_READLINKAT@
+# if address@hidden@
+ssize_t readlinkat (int fd, char const *file, char *buf, size_t len);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef readlinkat
+# define readlinkat(d,n,b,l) \
+ (GL_LINK_WARNING ("readlinkat is not portable - " \
+ "use gnulib module symlinkat for portability"), \
+ readlinkat (d, n, b, l))
+#endif
+
+
#if @GNULIB_RMDIR@
# if @REPLACE_RMDIR@
# define rmdir rpl_rmdir
@@ -723,6 +707,68 @@ extern unsigned int sleep (unsigned int n);
#endif
+#if @GNULIB_SYMLINK@
+# if @REPLACE_SYMLINK@
+# undef symlink
+# define symlink rpl_symlink
+# endif
+# if address@hidden@ || @REPLACE_SYMLINK@
+int symlink (char const *contents, char const *file);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef symlink
+# define symlink(c,n) \
+ (GL_LINK_WARNING ("symlink is not portable - " \
+ "use gnulib module symlink for portability"), \
+ symlink (c, n))
+#endif
+
+
+#if @GNULIB_SYMLINKAT@
+# if address@hidden@
+int symlinkat (char const *contents, int fd, char const *file);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef symlinkat
+# define symlinkat(c,d,n) \
+ (GL_LINK_WARNING ("symlinkat is not portable - " \
+ "use gnulib module symlinkat for portability"), \
+ symlinkat (c, d, n))
+#endif
+
+
+#if @GNULIB_UNLINK@
+# if @REPLACE_UNLINK@
+# undef unlink
+# define unlink rpl_unlink
+extern int unlink (char const *file);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef unlink
+# define unlink(n) \
+ (GL_LINK_WARNING ("unlink is not portable - " \
+ "use gnulib module unlink for portability"), \
+ unlink (n))
+#endif
+
+
+#if @GNULIB_UNLINKAT@
+# if @REPLACE_UNLINKAT@
+# undef unlinkat
+# define unlinkat rpl_unlinkat
+# endif
+# if address@hidden@ || @REPLACE_UNLINKAT@
+extern int unlinkat (int fd, char const *file, int flag);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef unlinkat
+# define unlinkat(d,n,f) \
+ (GL_LINK_WARNING ("unlinkat is not portable - " \
+ "use gnulib module openat for portability"), \
+ unlinkat (d, n, f))
+#endif
+
+
#if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
/* Write up to COUNT bytes starting at BUF to file descriptor FD.
See the POSIX:2001 specification
diff --git a/gltests/Makefile.am b/gltests/Makefile.am
index 61593cd..f525397 100644
--- a/gltests/Makefile.am
+++ b/gltests/Makefile.am
@@ -42,6 +42,33 @@ libtests_a_DEPENDENCIES = $(gltests_LIBOBJS)
EXTRA_libtests_a_SOURCES =
AM_LIBTOOLFLAGS = --preserve-dup-deps
+## begin gnulib module alloca-opt
+
+BUILT_SOURCES += $(ALLOCA_H)
+
+# We need the following in order to create <alloca.h> when the system
+# doesn't have one that works with the given compiler.
+alloca.h: alloca.in.h
+ $(AM_V_GEN)rm -f address@hidden $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ cat $(srcdir)/alloca.in.h; \
+ } > address@hidden && \
+ mv -f address@hidden $@
+MOSTLYCLEANFILES += alloca.h alloca.h-t
+
+EXTRA_DIST += alloca.in.h
+
+## end gnulib module alloca-opt
+
+## begin gnulib module alloca-opt-tests
+
+TESTS += test-alloca-opt
+check_PROGRAMS += test-alloca-opt
+
+EXTRA_DIST += test-alloca-opt.c
+
+## end gnulib module alloca-opt-tests
+
## begin gnulib module environ-tests
TESTS += test-environ
@@ -69,6 +96,40 @@ EXTRA_DIST += test-getopt.c test-getopt.h test-getopt_long.h
## end gnulib module getopt-posix-tests
+## begin gnulib module link-warning
+
+LINK_WARNING_H=$(top_srcdir)/build-aux/link-warning.h
+
+EXTRA_DIST += $(top_srcdir)/build-aux/link-warning.h
+
+## end gnulib module link-warning
+
+## begin gnulib module malloca
+
+libtests_a_SOURCES += malloca.c
+
+EXTRA_DIST += malloca.h malloca.valgrind
+
+## end gnulib module malloca
+
+## begin gnulib module malloca-tests
+
+TESTS += test-malloca
+check_PROGRAMS += test-malloca
+
+EXTRA_DIST += test-malloca.c
+
+## end gnulib module malloca-tests
+
+## begin gnulib module setenv
+
+
+EXTRA_DIST += setenv.c
+
+EXTRA_libtests_a_SOURCES += setenv.c
+
+## end gnulib module setenv
+
## begin gnulib module stddef-tests
TESTS += test-stddef
diff --git a/gltests/alloca.in.h b/gltests/alloca.in.h
new file mode 100644
index 0000000..6269607
--- /dev/null
+++ b/gltests/alloca.in.h
@@ -0,0 +1,56 @@
+/* Memory allocation on the stack.
+
+ Copyright (C) 1995, 1999, 2001-2004, 2006-2008 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 3, 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. */
+
+/* Avoid using the symbol _ALLOCA_H here, as Bison assumes _ALLOCA_H
+ means there is a real alloca function. */
+#ifndef _GL_ALLOCA_H
+#define _GL_ALLOCA_H
+
+/* alloca (N) returns a pointer to N bytes of memory
+ allocated on the stack, which will last until the function returns.
+ Use of alloca should be avoided:
+ - inside arguments of function calls - undefined behaviour,
+ - in inline functions - the allocation may actually last until the
+ calling function returns,
+ - for huge N (say, N >= 65536) - you never know how large (or small)
+ the stack is, and when the stack cannot fulfill the memory allocation
+ request, the program just crashes.
+ */
+
+#ifndef alloca
+# ifdef __GNUC__
+# define alloca __builtin_alloca
+# elif defined _AIX
+# define alloca __alloca
+# elif defined _MSC_VER
+# include <malloc.h>
+# define alloca _alloca
+# elif defined __DECC && defined __VMS
+# define alloca __ALLOCA
+# else
+# include <stddef.h>
+# ifdef __cplusplus
+extern "C"
+# endif
+void *alloca (size_t);
+# endif
+#endif
+
+#endif /* _GL_ALLOCA_H */
diff --git a/gltests/malloca.c b/gltests/malloca.c
new file mode 100644
index 0000000..1f41078
--- /dev/null
+++ b/gltests/malloca.c
@@ -0,0 +1,137 @@
+/* Safe automatic memory allocation.
+ Copyright (C) 2003, 2006-2007 Free Software Foundation, Inc.
+ Written by Bruno Haible <address@hidden>, 2003.
+
+ 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 3, 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. */
+
+#include <config.h>
+
+/* Specification. */
+#include "malloca.h"
+
+/* The speed critical point in this file is freea() applied to an alloca()
+ result: it must be fast, to match the speed of alloca(). The speed of
+ mmalloca() and freea() in the other case are not critical, because they
+ are only invoked for big memory sizes. */
+
+#if HAVE_ALLOCA
+
+/* Store the mmalloca() results in a hash table. This is needed to reliably
+ distinguish a mmalloca() result and an alloca() result.
+
+ Although it is possible that the same pointer is returned by alloca() and
+ by mmalloca() at different times in the same application, it does not lead
+ to a bug in freea(), because:
+ - Before a pointer returned by alloca() can point into malloc()ed memory,
+ the function must return, and once this has happened the programmer must
+ not call freea() on it anyway.
+ - Before a pointer returned by mmalloca() can point into the stack, it
+ must be freed. The only function that can free it is freea(), and
+ when freea() frees it, it also removes it from the hash table. */
+
+#define MAGIC_NUMBER 0x1415fb4a
+#define MAGIC_SIZE sizeof (int)
+/* This is how the header info would look like without any alignment
+ considerations. */
+struct preliminary_header { void *next; char room[MAGIC_SIZE]; };
+/* But the header's size must be a multiple of sa_alignment_max. */
+#define HEADER_SIZE \
+ (((sizeof (struct preliminary_header) + sa_alignment_max - 1) /
sa_alignment_max) * sa_alignment_max)
+struct header { void *next; char room[HEADER_SIZE - sizeof (struct
preliminary_header) + MAGIC_SIZE]; };
+/* Verify that HEADER_SIZE == sizeof (struct header). */
+typedef int verify1[2 * (HEADER_SIZE == sizeof (struct header)) - 1];
+/* We make the hash table quite big, so that during lookups the probability
+ of empty hash buckets is quite high. There is no need to make the hash
+ table resizable, because when the hash table gets filled so much that the
+ lookup becomes slow, it means that the application has memory leaks. */
+#define HASH_TABLE_SIZE 257
+static void * mmalloca_results[HASH_TABLE_SIZE];
+
+#endif
+
+void *
+mmalloca (size_t n)
+{
+#if HAVE_ALLOCA
+ /* Allocate one more word, that serves as an indicator for malloc()ed
+ memory, so that freea() of an alloca() result is fast. */
+ size_t nplus = n + HEADER_SIZE;
+
+ if (nplus >= n)
+ {
+ char *p = (char *) malloc (nplus);
+
+ if (p != NULL)
+ {
+ size_t slot;
+
+ p += HEADER_SIZE;
+
+ /* Put a magic number into the indicator word. */
+ ((int *) p)[-1] = MAGIC_NUMBER;
+
+ /* Enter p into the hash table. */
+ slot = (unsigned long) p % HASH_TABLE_SIZE;
+ ((struct header *) (p - HEADER_SIZE))->next = mmalloca_results[slot];
+ mmalloca_results[slot] = p;
+
+ return p;
+ }
+ }
+ /* Out of memory. */
+ return NULL;
+#else
+# if !MALLOC_0_IS_NONNULL
+ if (n == 0)
+ n = 1;
+# endif
+ return malloc (n);
+#endif
+}
+
+#if HAVE_ALLOCA
+void
+freea (void *p)
+{
+ /* mmalloca() may have returned NULL. */
+ if (p != NULL)
+ {
+ /* Attempt to quickly distinguish the mmalloca() result - which has
+ a magic indicator word - and the alloca() result - which has an
+ uninitialized indicator word. It is for this test that sa_increment
+ additional bytes are allocated in the alloca() case. */
+ if (((int *) p)[-1] == MAGIC_NUMBER)
+ {
+ /* Looks like a mmalloca() result. To see whether it really is one,
+ perform a lookup in the hash table. */
+ size_t slot = (unsigned long) p % HASH_TABLE_SIZE;
+ void **chain = &mmalloca_results[slot];
+ for (; *chain != NULL;)
+ {
+ if (*chain == p)
+ {
+ /* Found it. Remove it from the hash table and free it. */
+ char *p_begin = (char *) p - HEADER_SIZE;
+ *chain = ((struct header *) p_begin)->next;
+ free (p_begin);
+ return;
+ }
+ chain = &((struct header *) ((char *) *chain -
HEADER_SIZE))->next;
+ }
+ }
+ /* At this point, we know it was not a mmalloca() result. */
+ }
+}
+#endif
diff --git a/gltests/malloca.h b/gltests/malloca.h
new file mode 100644
index 0000000..3be0a38
--- /dev/null
+++ b/gltests/malloca.h
@@ -0,0 +1,134 @@
+/* Safe automatic memory allocation.
+ Copyright (C) 2003-2007 Free Software Foundation, Inc.
+ Written by Bruno Haible <address@hidden>, 2003.
+
+ 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 3, 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 _MALLOCA_H
+#define _MALLOCA_H
+
+#include <alloca.h>
+#include <stddef.h>
+#include <stdlib.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* safe_alloca(N) is equivalent to alloca(N) when it is safe to call
+ alloca(N); otherwise it returns NULL. It either returns N bytes of
+ memory allocated on the stack, that lasts until the function returns,
+ or NULL.
+ Use of safe_alloca should be avoided:
+ - inside arguments of function calls - undefined behaviour,
+ - in inline functions - the allocation may actually last until the
+ calling function returns.
+*/
+#if HAVE_ALLOCA
+/* The OS usually guarantees only one guard page at the bottom of the stack,
+ and a page size can be as small as 4096 bytes. So we cannot safely
+ allocate anything larger than 4096 bytes. Also care for the possibility
+ of a few compiler-allocated temporary stack slots.
+ This must be a macro, not an inline function. */
+# define safe_alloca(N) ((N) < 4032 ? alloca (N) : NULL)
+#else
+# define safe_alloca(N) ((void) (N), NULL)
+#endif
+
+/* malloca(N) is a safe variant of alloca(N). It allocates N bytes of
+ memory allocated on the stack, that must be freed using freea() before
+ the function returns. Upon failure, it returns NULL. */
+#if HAVE_ALLOCA
+# define malloca(N) \
+ ((N) < 4032 - sa_increment \
+ ? (void *) ((char *) alloca ((N) + sa_increment) + sa_increment) \
+ : mmalloca (N))
+#else
+# define malloca(N) \
+ mmalloca (N)
+#endif
+extern void * mmalloca (size_t n);
+
+/* Free a block of memory allocated through malloca(). */
+#if HAVE_ALLOCA
+extern void freea (void *p);
+#else
+# define freea free
+#endif
+
+/* nmalloca(N,S) is an overflow-safe variant of malloca (N * S).
+ It allocates an array of N objects, each with S bytes of memory,
+ on the stack. S must be positive and N must be nonnegative.
+ The array must be freed using freea() before the function returns. */
+#if 1
+/* Cf. the definition of xalloc_oversized. */
+# define nmalloca(n, s) \
+ ((n) > (size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) \
+ ? NULL \
+ : malloca ((n) * (s)))
+#else
+extern void * nmalloca (size_t n, size_t s);
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+/* ------------------- Auxiliary, non-public definitions ------------------- */
+
+/* Determine the alignment of a type at compile time. */
+#if defined __GNUC__
+# define sa_alignof __alignof__
+#elif defined __cplusplus
+ template <class type> struct sa_alignof_helper { char __slot1; type __slot2;
};
+# define sa_alignof(type) offsetof (sa_alignof_helper<type>, __slot2)
+#elif defined __hpux
+ /* Work around a HP-UX 10.20 cc bug with enums constants defined as offsetof
+ values. */
+# define sa_alignof(type) (sizeof (type) <= 4 ? 4 : 8)
+#elif defined _AIX
+ /* Work around an AIX 3.2.5 xlc bug with enums constants defined as offsetof
+ values. */
+# define sa_alignof(type) (sizeof (type) <= 4 ? 4 : 8)
+#else
+# define sa_alignof(type) offsetof (struct { char __slot1; type __slot2; },
__slot2)
+#endif
+
+enum
+{
+/* The desired alignment of memory allocations is the maximum alignment
+ among all elementary types. */
+ sa_alignment_long = sa_alignof (long),
+ sa_alignment_double = sa_alignof (double),
+#if HAVE_LONG_LONG_INT
+ sa_alignment_longlong = sa_alignof (long long),
+#endif
+ sa_alignment_longdouble = sa_alignof (long double),
+ sa_alignment_max = ((sa_alignment_long - 1) | (sa_alignment_double - 1)
+#if HAVE_LONG_LONG_INT
+ | (sa_alignment_longlong - 1)
+#endif
+ | (sa_alignment_longdouble - 1)
+ ) + 1,
+/* The increment that guarantees room for a magic word must be >= sizeof (int)
+ and a multiple of sa_alignment_max. */
+ sa_increment = ((sizeof (int) + sa_alignment_max - 1) / sa_alignment_max) *
sa_alignment_max
+};
+
+#endif /* _MALLOCA_H */
diff --git a/gltests/malloca.valgrind b/gltests/malloca.valgrind
new file mode 100644
index 0000000..52f0a50
--- /dev/null
+++ b/gltests/malloca.valgrind
@@ -0,0 +1,7 @@
+# Suppress a valgrind message about use of uninitialized memory in freea().
+# This use is OK because it provides only a speedup.
+{
+ freea
+ Memcheck:Cond
+ fun:freea
+}
diff --git a/gltests/setenv.c b/gltests/setenv.c
new file mode 100644
index 0000000..83b52b8
--- /dev/null
+++ b/gltests/setenv.c
@@ -0,0 +1,330 @@
+/* Copyright (C) 1992,1995-1999,2000-2003,2005-2008 Free Software Foundation,
Inc.
+ This file is part of the GNU C Library.
+
+ 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 3 of the License, 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, see <http://www.gnu.org/licenses/>. */
+
+#if !_LIBC
+# include <config.h>
+#endif
+#include <alloca.h>
+
+/* Specification. */
+#include <stdlib.h>
+
+#include <errno.h>
+#ifndef __set_errno
+# define __set_errno(ev) ((errno) = (ev))
+#endif
+
+#include <string.h>
+#if _LIBC || HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#if _LIBC || !HAVE_SETENV
+
+#if !_LIBC
+# include "malloca.h"
+#endif
+
+#if !_LIBC
+# define __environ environ
+#endif
+
+#if _LIBC
+/* This lock protects against simultaneous modifications of `environ'. */
+# include <bits/libc-lock.h>
+__libc_lock_define_initialized (static, envlock)
+# define LOCK __libc_lock_lock (envlock)
+# define UNLOCK __libc_lock_unlock (envlock)
+#else
+# define LOCK
+# define UNLOCK
+#endif
+
+/* In the GNU C library we must keep the namespace clean. */
+#ifdef _LIBC
+# define setenv __setenv
+# define clearenv __clearenv
+# define tfind __tfind
+# define tsearch __tsearch
+#endif
+
+/* In the GNU C library implementation we try to be more clever and
+ allow arbitrarily many changes of the environment given that the used
+ values are from a small set. Outside glibc this will eat up all
+ memory after a while. */
+#if defined _LIBC || (defined HAVE_SEARCH_H && defined HAVE_TSEARCH \
+ && defined __GNUC__)
+# define USE_TSEARCH 1
+# include <search.h>
+typedef int (*compar_fn_t) (const void *, const void *);
+
+/* This is a pointer to the root of the search tree with the known
+ values. */
+static void *known_values;
+
+# define KNOWN_VALUE(Str) \
+ ({ \
+ void *value = tfind (Str, &known_values, (compar_fn_t) strcmp); \
+ value != NULL ? *(char **) value : NULL; \
+ })
+# define STORE_VALUE(Str) \
+ tsearch (Str, &known_values, (compar_fn_t) strcmp)
+
+#else
+# undef USE_TSEARCH
+
+# define KNOWN_VALUE(Str) NULL
+# define STORE_VALUE(Str) do { } while (0)
+
+#endif
+
+
+/* If this variable is not a null pointer we allocated the current
+ environment. */
+static char **last_environ;
+
+
+/* This function is used by `setenv' and `putenv'. The difference between
+ the two functions is that for the former must create a new string which
+ is then placed in the environment, while the argument of `putenv'
+ must be used directly. This is all complicated by the fact that we try
+ to reuse values once generated for a `setenv' call since we can never
+ free the strings. */
+int
+__add_to_environ (const char *name, const char *value, const char *combined,
+ int replace)
+{
+ register char **ep;
+ register size_t size;
+ const size_t namelen = strlen (name);
+ const size_t vallen = value != NULL ? strlen (value) + 1 : 0;
+
+ LOCK;
+
+ /* We have to get the pointer now that we have the lock and not earlier
+ since another thread might have created a new environment. */
+ ep = __environ;
+
+ size = 0;
+ if (ep != NULL)
+ {
+ for (; *ep != NULL; ++ep)
+ if (!strncmp (*ep, name, namelen) && (*ep)[namelen] == '=')
+ break;
+ else
+ ++size;
+ }
+
+ if (ep == NULL || *ep == NULL)
+ {
+ char **new_environ;
+#ifdef USE_TSEARCH
+ char *new_value;
+#endif
+
+ /* We allocated this space; we can extend it. */
+ new_environ =
+ (char **) (last_environ == NULL
+ ? malloc ((size + 2) * sizeof (char *))
+ : realloc (last_environ, (size + 2) * sizeof (char *)));
+ if (new_environ == NULL)
+ {
+ UNLOCK;
+ return -1;
+ }
+
+ /* If the whole entry is given add it. */
+ if (combined != NULL)
+ /* We must not add the string to the search tree since it belongs
+ to the user. */
+ new_environ[size] = (char *) combined;
+ else
+ {
+ /* See whether the value is already known. */
+#ifdef USE_TSEARCH
+# ifdef _LIBC
+ new_value = (char *) alloca (namelen + 1 + vallen);
+ __mempcpy (__mempcpy (__mempcpy (new_value, name, namelen), "=", 1),
+ value, vallen);
+# else
+ new_value = (char *) malloca (namelen + 1 + vallen);
+ if (new_value == NULL)
+ {
+ __set_errno (ENOMEM);
+ UNLOCK;
+ return -1;
+ }
+ memcpy (new_value, name, namelen);
+ new_value[namelen] = '=';
+ memcpy (&new_value[namelen + 1], value, vallen);
+# endif
+
+ new_environ[size] = KNOWN_VALUE (new_value);
+ if (new_environ[size] == NULL)
+#endif
+ {
+ new_environ[size] = (char *) malloc (namelen + 1 + vallen);
+ if (new_environ[size] == NULL)
+ {
+#if defined USE_TSEARCH && !defined _LIBC
+ freea (new_value);
+#endif
+ __set_errno (ENOMEM);
+ UNLOCK;
+ return -1;
+ }
+
+#ifdef USE_TSEARCH
+ memcpy (new_environ[size], new_value, namelen + 1 + vallen);
+#else
+ memcpy (new_environ[size], name, namelen);
+ new_environ[size][namelen] = '=';
+ memcpy (&new_environ[size][namelen + 1], value, vallen);
+#endif
+ /* And save the value now. We cannot do this when we remove
+ the string since then we cannot decide whether it is a
+ user string or not. */
+ STORE_VALUE (new_environ[size]);
+ }
+#if defined USE_TSEARCH && !defined _LIBC
+ freea (new_value);
+#endif
+ }
+
+ if (__environ != last_environ)
+ memcpy ((char *) new_environ, (char *) __environ,
+ size * sizeof (char *));
+
+ new_environ[size + 1] = NULL;
+
+ last_environ = __environ = new_environ;
+ }
+ else if (replace)
+ {
+ char *np;
+
+ /* Use the user string if given. */
+ if (combined != NULL)
+ np = (char *) combined;
+ else
+ {
+#ifdef USE_TSEARCH
+ char *new_value;
+# ifdef _LIBC
+ new_value = alloca (namelen + 1 + vallen);
+ __mempcpy (__mempcpy (__mempcpy (new_value, name, namelen), "=", 1),
+ value, vallen);
+# else
+ new_value = malloca (namelen + 1 + vallen);
+ if (new_value == NULL)
+ {
+ __set_errno (ENOMEM);
+ UNLOCK;
+ return -1;
+ }
+ memcpy (new_value, name, namelen);
+ new_value[namelen] = '=';
+ memcpy (&new_value[namelen + 1], value, vallen);
+# endif
+
+ np = KNOWN_VALUE (new_value);
+ if (np == NULL)
+#endif
+ {
+ np = malloc (namelen + 1 + vallen);
+ if (np == NULL)
+ {
+#if defined USE_TSEARCH && !defined _LIBC
+ freea (new_value);
+#endif
+ __set_errno (ENOMEM);
+ UNLOCK;
+ return -1;
+ }
+
+#ifdef USE_TSEARCH
+ memcpy (np, new_value, namelen + 1 + vallen);
+#else
+ memcpy (np, name, namelen);
+ np[namelen] = '=';
+ memcpy (&np[namelen + 1], value, vallen);
+#endif
+ /* And remember the value. */
+ STORE_VALUE (np);
+ }
+#if defined USE_TSEARCH && !defined _LIBC
+ freea (new_value);
+#endif
+ }
+
+ *ep = np;
+ }
+
+ UNLOCK;
+
+ return 0;
+}
+
+int
+setenv (const char *name, const char *value, int replace)
+{
+ return __add_to_environ (name, value, NULL, replace);
+}
+
+/* The `clearenv' was planned to be added to POSIX.1 but probably
+ never made it. Nevertheless the POSIX.9 standard (POSIX bindings
+ for Fortran 77) requires this function. */
+int
+clearenv (void)
+{
+ LOCK;
+
+ if (__environ == last_environ && __environ != NULL)
+ {
+ /* We allocated this environment so we can free it. */
+ free (__environ);
+ last_environ = NULL;
+ }
+
+ /* Clear the environment pointer removes the whole environment. */
+ __environ = NULL;
+
+ UNLOCK;
+
+ return 0;
+}
+
+#ifdef _LIBC
+static void
+free_mem (void)
+{
+ /* Remove all traces. */
+ clearenv ();
+
+ /* Now remove the search tree. */
+ __tdestroy (known_values, free);
+ known_values = NULL;
+}
+text_set_element (__libc_subfreeres, free_mem);
+
+
+# undef setenv
+# undef clearenv
+weak_alias (__setenv, setenv)
+weak_alias (__clearenv, clearenv)
+#endif
+
+#endif /* _LIBC || !HAVE_SETENV */
diff --git a/gltests/test-stdlib.c b/gltests/test-alloca-opt.c
similarity index 51%
copy from gltests/test-stdlib.c
copy to gltests/test-alloca-opt.c
index ae46ba1..68d906d 100644
--- a/gltests/test-stdlib.c
+++ b/gltests/test-alloca-opt.c
@@ -1,5 +1,5 @@
-/* Test of <stdlib.h> substitute.
- Copyright (C) 2007, 2009 Free Software Foundation, Inc.
+/* Test of optional automatic memory allocation.
+ Copyright (C) 2005, 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
@@ -18,26 +18,45 @@
#include <config.h>
-#include <stdlib.h>
+#include <alloca.h>
-#include "verify.h"
+#if HAVE_ALLOCA
-int exitcode;
+static void
+do_allocation (int n)
+{
+ void *ptr = alloca (n);
+ (void) ptr;
+}
-/* Check that NULL can be passed through varargs as a pointer type,
- per POSIX 2008. */
-verify (sizeof NULL == sizeof (void *));
+void (*func) (int) = do_allocation;
+
+#endif
int
main ()
{
- /* Check that some macros are defined and different integer constants. */
- switch (exitcode)
+#if HAVE_ALLOCA
+ int i;
+
+ /* Repeat a lot of times, to make sure there's no memory leak. */
+ for (i = 0; i < 100000; i++)
{
- case EXIT_SUCCESS:
- case EXIT_FAILURE:
- break;
+ /* Try various values.
+ n = 0 gave a crash on Alpha with gcc-2.5.8.
+ Some versions of MacOS X have a stack size limit of 512 KB. */
+ func (34);
+ func (134);
+ func (399);
+ func (510823);
+ func (129321);
+ func (0);
+ func (4070);
+ func (4095);
+ func (1);
+ func (16582);
}
+#endif
return 0;
}
diff --git a/gltests/test-getopt.c b/gltests/test-getopt.c
index b3dd60b..12d8d92 100644
--- a/gltests/test-getopt.c
+++ b/gltests/test-getopt.c
@@ -60,6 +60,9 @@ main ()
test_getopt ();
#if GNULIB_GETOPT_GNU
test_getopt_long ();
+
+ setenv ("POSIXLY_CORRECT", "1", 0);
+ test_getopt_long_posix ();
#endif
return 0;
diff --git a/gltests/test-getopt_long.h b/gltests/test-getopt_long.h
index 0017f19..fb505b2 100644
--- a/gltests/test-getopt_long.h
+++ b/gltests/test-getopt_long.h
@@ -935,3 +935,24 @@ test_getopt_long (void)
ASSERT (optind == 4);
}
}
+
+/* Test behavior of getopt_long when POSIXLY_CORRECT is set in the
+ environment. Options with optional arguments should not change
+ behavior just because of an environment variable.
+ http://lists.gnu.org/archive/html/bug-m4/2006-09/msg00028.html */
+static void
+test_getopt_long_posix (void)
+{
+ int c = 3;
+ char *v[4] = {"test", "-r", "foo", NULL};
+ struct option l[] = {{NULL}};
+ int start;
+ int result;
+ for (start = OPTIND_MIN; start <= 1; start++)
+ {
+ optind = start;
+ result = getopt_long (c, v, "r::", l, NULL);
+ }
+ ASSERT (result == 'r');
+ ASSERT (optarg == NULL);
+}
diff --git a/gltests/test-malloca.c b/gltests/test-malloca.c
new file mode 100644
index 0000000..7de6c68
--- /dev/null
+++ b/gltests/test-malloca.c
@@ -0,0 +1,59 @@
+/* Test of safe automatic memory allocation.
+ Copyright (C) 2005, 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 3 of the License, 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, see <http://www.gnu.org/licenses/>. */
+
+/* Written by Bruno Haible <address@hidden>, 2005. */
+
+#include <config.h>
+
+#include "malloca.h"
+
+#include <stdlib.h>
+
+static void
+do_allocation (int n)
+{
+ void *ptr = malloca (n);
+ freea (ptr);
+ ptr = safe_alloca (n);
+}
+
+void (*func) (int) = do_allocation;
+
+int
+main ()
+{
+ int i;
+
+ /* Repeat a lot of times, to make sure there's no memory leak. */
+ for (i = 0; i < 50000; i++)
+ {
+ /* Try various values.
+ n = 0 gave a crash on Alpha with gcc-2.5.8.
+ Some versions of MacOS X have a stack size limit of 512 KB. */
+ func (34);
+ func (134);
+ func (399);
+ func (510823);
+ func (129321);
+ func (0);
+ func (4070);
+ func (4095);
+ func (1);
+ func (16582);
+ }
+
+ return 0;
+}
diff --git a/lib/gltests/Makefile.am b/lib/gltests/Makefile.am
index d5e93de..e72ecd5 100644
--- a/lib/gltests/Makefile.am
+++ b/lib/gltests/Makefile.am
@@ -77,6 +77,14 @@ EXTRA_DIST += intprops.h
## end gnulib module intprops
+## begin gnulib module link-warning
+
+LINK_WARNING_H=$(top_srcdir)/build-aux/link-warning.h
+
+EXTRA_DIST += $(top_srcdir)/build-aux/link-warning.h
+
+## end gnulib module link-warning
+
## begin gnulib module stdbool-tests
TESTS += test-stdbool
diff --git a/maint.mk b/maint.mk
index fe6b3ff..68bd8f9 100644
--- a/maint.mk
+++ b/maint.mk
@@ -696,11 +696,11 @@ no-submodule-changes:
: ; \
fi
-.PHONY: alpha beta major
-ALL_RECURSIVE_TARGETS += alpha beta major
-alpha beta major: $(local-check) writable-files no-submodule-changes
- test $@ = major \
- && { echo $(VERSION) | grep -E '^[0-9]+(\.[0-9]+)+$$' \
+.PHONY: alpha beta stable
+ALL_RECURSIVE_TARGETS += alpha beta stable
+alpha beta stable: $(local-check) writable-files no-submodule-changes
+ test $@ = stable \
+ && { echo $(VERSION) | grep -E '^[0-9]+(\.[0-9]+)+$$' \
|| { echo "invalid version string: $(VERSION)" 1>&2; exit 1;};}\
|| :
$(MAKE) vc-diff-check
hooks/post-receive
--
GNU libidn
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [SCM] GNU libidn branch, master, updated. libidn-1-15-20-ga24f6d4,
Simon Josefsson <=