diff options
author | Simon Josefsson <simon@josefsson.org> | 2009-08-06 16:30:15 +0200 |
---|---|---|
committer | Simon Josefsson <simon@josefsson.org> | 2009-08-06 16:30:15 +0200 |
commit | 92a5cd11f9b33f427c495dca22d9aac1cf7b1f3d (patch) | |
tree | b3bb68a392114cd82b5f174061b0d6ab77cfa1f2 /gl | |
parent | a532faf3bd6d95bf41ba75733a72b504090667af (diff) | |
download | gnutls-92a5cd11f9b33f427c495dca22d9aac1cf7b1f3d.tar.gz |
Update gnulib files.
Diffstat (limited to 'gl')
-rw-r--r-- | gl/Makefile.am | 4 | ||||
-rw-r--r-- | gl/error.c | 16 | ||||
-rw-r--r-- | gl/fseeko.c | 2 | ||||
-rw-r--r-- | gl/m4/gnulib-comp.m4 | 2 | ||||
-rw-r--r-- | gl/m4/lib-link.m4 | 7 | ||||
-rw-r--r-- | gl/m4/stdio_h.m4 | 5 | ||||
-rw-r--r-- | gl/m4/unistd_h.m4 | 3 | ||||
-rw-r--r-- | gl/socket.c | 10 | ||||
-rw-r--r-- | gl/sockets.c | 26 | ||||
-rw-r--r-- | gl/stdio.in.h | 20 | ||||
-rw-r--r-- | gl/tests/Makefile.am | 10 | ||||
-rw-r--r-- | gl/tests/test-select.c | 5 | ||||
-rw-r--r-- | gl/tests/test-stdio.c | 8 | ||||
-rw-r--r-- | gl/tests/test-stdlib.c | 8 | ||||
-rw-r--r-- | gl/tests/test-string.c | 8 | ||||
-rw-r--r-- | gl/tests/test-unistd.c | 6 | ||||
-rw-r--r-- | gl/tests/test-version-etc.c | 33 | ||||
-rwxr-xr-x | gl/tests/test-version-etc.sh | 40 | ||||
-rw-r--r-- | gl/unistd.in.h | 13 | ||||
-rw-r--r-- | gl/version-etc.c | 119 | ||||
-rw-r--r-- | gl/version-etc.h | 42 |
21 files changed, 324 insertions, 63 deletions
diff --git a/gl/Makefile.am b/gl/Makefile.am index b40d7bad8d..28f1560f39 100644 --- a/gl/Makefile.am +++ b/gl/Makefile.am @@ -677,6 +677,7 @@ stdio.h: stdio.in.h -e 's|@''GNULIB_FTELL''@|$(GNULIB_FTELL)|g' \ -e 's|@''GNULIB_FTELLO''@|$(GNULIB_FTELLO)|g' \ -e 's|@''GNULIB_FFLUSH''@|$(GNULIB_FFLUSH)|g' \ + -e 's|@''GNULIB_FPURGE''@|$(GNULIB_FPURGE)|g' \ -e 's|@''GNULIB_FCLOSE''@|$(GNULIB_FCLOSE)|g' \ -e 's|@''GNULIB_FPUTC''@|$(GNULIB_FPUTC)|g' \ -e 's|@''GNULIB_PUTC''@|$(GNULIB_PUTC)|g' \ @@ -714,6 +715,8 @@ stdio.h: stdio.in.h -e 's|@''REPLACE_FTELLO''@|$(REPLACE_FTELLO)|g' \ -e 's|@''REPLACE_FTELL''@|$(REPLACE_FTELL)|g' \ -e 's|@''REPLACE_FFLUSH''@|$(REPLACE_FFLUSH)|g' \ + -e 's|@''REPLACE_FPURGE''@|$(REPLACE_FPURGE)|g' \ + -e 's|@''HAVE_DECL_FPURGE''@|$(HAVE_DECL_FPURGE)|g' \ -e 's|@''REPLACE_FCLOSE''@|$(REPLACE_FCLOSE)|g' \ -e 's|@''HAVE_DECL_GETDELIM''@|$(HAVE_DECL_GETDELIM)|g' \ -e 's|@''HAVE_DECL_GETLINE''@|$(HAVE_DECL_GETLINE)|g' \ @@ -1058,6 +1061,7 @@ unistd.h: unistd.in.h -e 's|@''HAVE_SYS_PARAM_H''@|$(HAVE_SYS_PARAM_H)|g' \ -e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \ -e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \ + -e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \ -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \ -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \ -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \ diff --git a/gl/error.c b/gl/error.c index 3177bd5d2c..af2287b271 100644 --- a/gl/error.c +++ b/gl/error.c @@ -1,5 +1,5 @@ /* Error handler for noninteractive utilities - Copyright (C) 1990-1998, 2000-2007 Free Software Foundation, Inc. + Copyright (C) 1990-1998, 2000-2007, 2009 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 @@ -85,6 +85,8 @@ extern void __error_at_line (int status, int errnum, const char *file_name, #else /* not _LIBC */ +# include <fcntl.h> + # if !HAVE_DECL_STRERROR_R && STRERROR_R_CHAR_P # ifndef HAVE_DECL_STRERROR_R "this configure-time declaration test was not run" @@ -236,6 +238,12 @@ error (int status, int errnum, const char *message, ...) 0); #endif +#if !_LIBC && defined F_GETFL + /* POSIX states that fflush (stdout) after fclose is unspecified; it + is safe in glibc, but not on all other platforms. fflush (NULL) + is always defined, but too draconian. */ + if (0 <= fcntl (1, F_GETFL)) +#endif fflush (stdout); #ifdef _LIBC _IO_flockfile (stderr); @@ -295,6 +303,12 @@ error_at_line (int status, int errnum, const char *file_name, 0); #endif +#if !_LIBC && defined F_GETFL + /* POSIX states that fflush (stdout) after fclose is unspecified; it + is safe in glibc, but not on all other platforms. fflush (NULL) + is always defined, but too draconian. */ + if (0 <= fcntl (1, F_GETFL)) +#endif fflush (stdout); #ifdef _LIBC _IO_flockfile (stderr); diff --git a/gl/fseeko.c b/gl/fseeko.c index cf7c42fbfd..a7ac9fc4dc 100644 --- a/gl/fseeko.c +++ b/gl/fseeko.c @@ -79,7 +79,7 @@ rpl_fseeko (FILE *fp, off_t offset, int whence) && ((fp->__modeflags & (__FLAG_READONLY | __FLAG_READING)) == 0 || fp->__bufpos == fp->__bufread)) #elif defined __QNX__ /* QNX */ - if ((fp->_Mode & _MWRITE ? fp->_Next == fp->_Buf : fp->_Next == fp->_Rend) + if ((fp->_Mode & 0x2000 /* _MWRITE */ ? fp->_Next == fp->_Buf : fp->_Next == fp->_Rend) && fp->_Rback == fp->_Back + sizeof (fp->_Back) && fp->_Rsave == NULL) #elif defined __MINT__ /* Atari FreeMiNT */ diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4 index 56d0e4a036..cf3336d3cc 100644 --- a/gl/m4/gnulib-comp.m4 +++ b/gl/m4/gnulib-comp.m4 @@ -538,6 +538,8 @@ AC_DEFUN([gl_FILE_LIST], [ tests/test-vasnprintf.c tests/test-vc-list-files-cvs.sh tests/test-vc-list-files-git.sh + tests/test-version-etc.c + tests/test-version-etc.sh tests/test-wchar.c tests/zerosize-ptr.h tests=lib/dummy.c diff --git a/gl/m4/lib-link.m4 b/gl/m4/lib-link.m4 index 21442033c8..2f8b7ff38f 100644 --- a/gl/m4/lib-link.m4 +++ b/gl/m4/lib-link.m4 @@ -1,4 +1,4 @@ -# lib-link.m4 serial 19 (gettext-0.18) +# lib-link.m4 serial 20 (gettext-0.18) dnl Copyright (C) 2001-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, @@ -82,7 +82,7 @@ AC_DEFUN([AC_LIB_HAVE_LINKFLAGS], ]) if test "$ac_cv_lib[]Name" = yes; then HAVE_LIB[]NAME=yes - AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the lib[]$1 library.]) + AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the lib][$1 library.]) AC_MSG_CHECKING([how to link with lib[]$1]) AC_MSG_RESULT([$LIB[]NAME]) else @@ -210,6 +210,9 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY], LTLIB[]NAME= INC[]NAME= LIB[]NAME[]_PREFIX= + dnl HAVE_LIB${NAME} is an indicator that LIB${NAME}, LTLIB${NAME} have been + dnl computed. So it has to be reset here. + HAVE_LIB[]NAME= rpathdirs= ltrpathdirs= names_already_handled= diff --git a/gl/m4/stdio_h.m4 b/gl/m4/stdio_h.m4 index 846b65d302..fcbe68f6ba 100644 --- a/gl/m4/stdio_h.m4 +++ b/gl/m4/stdio_h.m4 @@ -1,4 +1,4 @@ -# stdio_h.m4 serial 15 +# stdio_h.m4 serial 16 dnl Copyright (C) 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, @@ -65,6 +65,7 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS], GNULIB_FTELL=0; AC_SUBST([GNULIB_FTELL]) GNULIB_FTELLO=0; AC_SUBST([GNULIB_FTELLO]) GNULIB_FFLUSH=0; AC_SUBST([GNULIB_FFLUSH]) + GNULIB_FPURGE=0; AC_SUBST([GNULIB_FPURGE]) GNULIB_FCLOSE=0; AC_SUBST([GNULIB_FCLOSE]) GNULIB_FPUTC=0; AC_SUBST([GNULIB_FPUTC]) GNULIB_PUTC=0; AC_SUBST([GNULIB_PUTC]) @@ -105,6 +106,8 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS], REPLACE_FTELLO=0; AC_SUBST([REPLACE_FTELLO]) REPLACE_FTELL=0; AC_SUBST([REPLACE_FTELL]) REPLACE_FFLUSH=0; AC_SUBST([REPLACE_FFLUSH]) + REPLACE_FPURGE=0; AC_SUBST([REPLACE_FPURGE]) + HAVE_DECL_FPURGE=1; AC_SUBST([HAVE_DECL_FPURGE]) REPLACE_FCLOSE=0; AC_SUBST([REPLACE_FCLOSE]) HAVE_DECL_GETDELIM=1; AC_SUBST([HAVE_DECL_GETDELIM]) HAVE_DECL_GETLINE=1; AC_SUBST([HAVE_DECL_GETLINE]) diff --git a/gl/m4/unistd_h.m4 b/gl/m4/unistd_h.m4 index ff9a4ea0a5..96fddba7fe 100644 --- a/gl/m4/unistd_h.m4 +++ b/gl/m4/unistd_h.m4 @@ -1,4 +1,4 @@ -# unistd_h.m4 serial 17 +# unistd_h.m4 serial 18 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, @@ -73,6 +73,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS], HAVE_SYS_PARAM_H=0; AC_SUBST([HAVE_SYS_PARAM_H]) REPLACE_CHOWN=0; AC_SUBST([REPLACE_CHOWN]) REPLACE_CLOSE=0; AC_SUBST([REPLACE_CLOSE]) + REPLACE_DUP2=0; AC_SUBST([REPLACE_DUP2]) REPLACE_FCHDIR=0; AC_SUBST([REPLACE_FCHDIR]) REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD]) REPLACE_GETPAGESIZE=0; AC_SUBST([REPLACE_GETPAGESIZE]) diff --git a/gl/socket.c b/gl/socket.c index 1fa6928747..8ce4bae8db 100644 --- a/gl/socket.c +++ b/gl/socket.c @@ -1,6 +1,6 @@ /* socket.c --- wrappers for Windows socket function - Copyright (C) 2008 Free Software Foundation, Inc. + Copyright (C) 2008-2009 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 @@ -26,12 +26,18 @@ /* Get set_winsock_errno, FD_TO_SOCKET etc. */ #include "w32sock.h" +#include "sockets.h" + int rpl_socket (int domain, int type, int protocol) { + SOCKET fh; + + gl_sockets_startup (SOCKETS_1_1); + /* We have to use WSASocket() to create non-overlapped IO sockets. Overlapped IO sockets cannot be used with read/write. */ - SOCKET fh = WSASocket (domain, type, protocol, NULL, 0, 0); + fh = WSASocket (domain, type, protocol, NULL, 0, 0); if (fh == INVALID_SOCKET) { diff --git a/gl/sockets.c b/gl/sockets.c index 9d5c547928..7cb9981d12 100644 --- a/gl/sockets.c +++ b/gl/sockets.c @@ -69,23 +69,31 @@ close_fd_maybe_socket (int fd, const struct close_hook *remaining_list) static struct close_hook close_sockets_hook; +static int initialized_sockets_version /* = 0 */; + #endif int gl_sockets_startup (int version) { #if WINDOWS_SOCKETS - WSADATA data; - int err; + if (version > initialized_sockets_version) + { + WSADATA data; + int err; - err = WSAStartup (version, &data); - if (err != 0) - return 1; + err = WSAStartup (version, &data); + if (err != 0) + return 1; + + if (data.wVersion < version) + return 2; - if (data.wVersion < version) - return 2; + if (initialized_sockets_version == 0) + register_close_hook (close_fd_maybe_socket, &close_sockets_hook); - register_close_hook (close_fd_maybe_socket, &close_sockets_hook); + initialized_sockets_version = version; + } #endif return 0; @@ -97,6 +105,8 @@ gl_sockets_cleanup (void) #if WINDOWS_SOCKETS int err; + initialized_sockets_version = 0; + unregister_close_hook (&close_sockets_hook); err = WSACleanup (); diff --git a/gl/stdio.in.h b/gl/stdio.in.h index cb273d7642..0445c6f107 100644 --- a/gl/stdio.in.h +++ b/gl/stdio.in.h @@ -1,6 +1,6 @@ /* A GNU-like <stdio.h>. - Copyright (C) 2004, 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2004, 2007-2009 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 @@ -407,6 +407,24 @@ extern long rpl_ftell (FILE *fp); fflush (f)) #endif +#if @GNULIB_FPURGE@ +# if @REPLACE_FPURGE@ +# define fpurge rpl_fpurge +# endif +# if @REPLACE_FPURGE@ || !@HAVE_DECL_FPURGE@ + /* Discard all pending buffered I/O data on STREAM. + STREAM must not be wide-character oriented. + Return 0 if successful. Upon error, return -1 and set errno. */ + extern int fpurge (FILE *gl_stream); +# endif +#elif defined GNULIB_POSIXCHECK +# undef fpurge +# define fpurge(f) \ + (GL_LINK_WARNING ("fpurge is not always present - " \ + "use gnulib module fpurge for portability"), \ + fpurge (f)) +#endif + #if @GNULIB_FCLOSE@ # if @REPLACE_FCLOSE@ # define fclose rpl_fclose diff --git a/gl/tests/Makefile.am b/gl/tests/Makefile.am index ecb33b656e..0b753ae949 100644 --- a/gl/tests/Makefile.am +++ b/gl/tests/Makefile.am @@ -384,6 +384,16 @@ libtests_a_SOURCES += verify.h ## end gnulib module verify +## begin gnulib module version-etc-tests + +TESTS += test-version-etc.sh +TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' +check_PROGRAMS += test-version-etc +test_version_etc_LDADD = $(LDADD) @LIBINTL@ +EXTRA_DIST += test-version-etc.c test-version-etc.sh + +## end gnulib module version-etc-tests + ## begin gnulib module wchar-tests TESTS += test-wchar diff --git a/gl/tests/test-select.c b/gl/tests/test-select.c index 4c9cdc02dc..ec82250149 100644 --- a/gl/tests/test-select.c +++ b/gl/tests/test-select.c @@ -1,5 +1,5 @@ /* Test of select() substitute. - Copyright (C) 2008 Free Software Foundation, Inc. + Copyright (C) 2008-2009 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 @@ -29,7 +29,6 @@ #include <stdbool.h> #include <sys/ioctl.h> #include <errno.h> -#include "sockets.h" enum { SEL_IN = 1, SEL_OUT = 2, SEL_EXC = 4 }; @@ -360,8 +359,6 @@ main () { int result; - gl_sockets_startup (SOCKETS_1_1); - #ifdef INTERACTIVE printf ("Please press Enter\n"); test (test_tty, "TTY"); diff --git a/gl/tests/test-stdio.c b/gl/tests/test-stdio.c index a5efa320ba..dcfe38dd51 100644 --- a/gl/tests/test-stdio.c +++ b/gl/tests/test-stdio.c @@ -1,5 +1,5 @@ /* Test of <stdio.h> substitute. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 2009 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 @@ -20,9 +20,15 @@ #include <stdio.h> +#include "verify.h" + /* Check that the various SEEK_* macros are defined. */ int sk[] = { SEEK_CUR, SEEK_END, SEEK_SET }; +/* Check that NULL can be passed through varargs as a pointer type, + per POSIX 2008. */ +verify (sizeof NULL == sizeof (void *)); + int main () { diff --git a/gl/tests/test-stdlib.c b/gl/tests/test-stdlib.c index e103d46b20..ae46ba1662 100644 --- a/gl/tests/test-stdlib.c +++ b/gl/tests/test-stdlib.c @@ -1,5 +1,5 @@ /* Test of <stdlib.h> substitute. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 2009 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 @@ -20,8 +20,14 @@ #include <stdlib.h> +#include "verify.h" + int exitcode; +/* Check that NULL can be passed through varargs as a pointer type, + per POSIX 2008. */ +verify (sizeof NULL == sizeof (void *)); + int main () { diff --git a/gl/tests/test-string.c b/gl/tests/test-string.c index 68014f54c8..fe53cd9b15 100644 --- a/gl/tests/test-string.c +++ b/gl/tests/test-string.c @@ -1,5 +1,5 @@ /* Test of <string.h> substitute. - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 2009 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 @@ -20,6 +20,12 @@ #include <string.h> +#include "verify.h" + +/* Check that NULL can be passed through varargs as a pointer type, + per POSIX 2008. */ +verify (sizeof NULL == sizeof (void *)); + int main () { diff --git a/gl/tests/test-unistd.c b/gl/tests/test-unistd.c index 5fed15cf9f..129367b4d7 100644 --- a/gl/tests/test-unistd.c +++ b/gl/tests/test-unistd.c @@ -20,6 +20,12 @@ #include <unistd.h> +#include "verify.h" + +/* Check that NULL can be passed through varargs as a pointer type, + per POSIX 2008. */ +verify (sizeof NULL == sizeof (void *)); + /* Check that the various SEEK_* macros are defined. */ int sk[] = { SEEK_CUR, SEEK_END, SEEK_SET }; diff --git a/gl/tests/test-version-etc.c b/gl/tests/test-version-etc.c new file mode 100644 index 0000000000..71cbc8bac4 --- /dev/null +++ b/gl/tests/test-version-etc.c @@ -0,0 +1,33 @@ +/* Test suite for version-etc. + Copyright (C) 2009 Free Software Foundation, Inc. + This file is part of the GNUlib 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/>. */ + +#include <config.h> + +#include "version-etc.h" + +#include "progname.h" + +#define AUTHORS "Sergey Poznyakoff", "Eric Blake" + +int +main (int argc, char **argv) +{ + set_program_name (argv[0]); + version_etc (stdout, "test-version-etc", "dummy", "0", AUTHORS, + (const char *) NULL); + return 0; +} diff --git a/gl/tests/test-version-etc.sh b/gl/tests/test-version-etc.sh new file mode 100755 index 0000000000..3b2fc4db80 --- /dev/null +++ b/gl/tests/test-version-etc.sh @@ -0,0 +1,40 @@ +#! /bin/sh +# Test suite for version-etc. +# Copyright (C) 2009 Free Software Foundation, Inc. +# This file is part of the GNUlib 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/>. + +TMP=ve-expected.tmp +LC_ALL=C +export LC_ALL +ERR=0 + +cat > $TMP <<EOT +test-version-etc (dummy) 0 +COPYRIGHT Free Software Foundation, Inc. +License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. +This is free software: you are free to change and redistribute it. +There is NO WARRANTY, to the extent permitted by law. + +Written by Sergey Poznyakoff and Eric Blake. +EOT + +./test-version-etc --version | + sed '2s/Copyright (C) [0-9]\{4,4\}/COPYRIGHT/' | + diff -c $TMP - || ERR=1 + +rm $TMP + +exit $ERR diff --git a/gl/unistd.in.h b/gl/unistd.in.h index fa8d84a3d9..09e90392df 100644 --- a/gl/unistd.in.h +++ b/gl/unistd.in.h @@ -150,10 +150,13 @@ extern int close (int); #if @GNULIB_DUP2@ -# if !@HAVE_DUP2@ +# if @REPLACE_DUP2@ +# define dup2 rpl_dup2 +# endif +# if !@HAVE_DUP2@ || @REPLACE_DUP2@ /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if NEWFD = OLDFD, otherwise close NEWFD first if it is open. - Return 0 if successful, otherwise -1 and errno set. + Return newfd if successful, otherwise -1 and errno set. See the POSIX:2001 specification <http://www.opengroup.org/susv3xsh/dup2.html>. */ extern int dup2 (int oldfd, int newfd); @@ -214,7 +217,11 @@ extern int fchdir (int /*fd*/); # define dup rpl_dup extern int dup (int); -# define dup2 rpl_dup2 + +# if @REPLACE_DUP2@ +# undef dup2 +# endif +# define dup2 rpl_dup2_fchdir extern int dup2 (int, int); # endif diff --git a/gl/version-etc.c b/gl/version-etc.c index c3b028926b..a580140c45 100644 --- a/gl/version-etc.c +++ b/gl/version-etc.c @@ -34,26 +34,30 @@ enum { COPYRIGHT_YEAR = 2009 }; -/* Like version_etc, below, but with the NULL-terminated author list - provided via a variable of type va_list. */ -void -version_etc_va (FILE *stream, - const char *command_name, const char *package, - const char *version, va_list authors) -{ - size_t n_authors; +/* The three functions below display the --version information the + standard way. + + If COMMAND_NAME is NULL, the PACKAGE is assumed to be the name of + the program. The formats are therefore: + + PACKAGE VERSION - /* Count the number of authors. */ - { - va_list tmp_authors; + or - va_copy (tmp_authors, authors); + COMMAND_NAME (PACKAGE) VERSION. - n_authors = 0; - while (va_arg (tmp_authors, const char *) != NULL) - ++n_authors; - } + The functions differ in the way they are passed author names. */ + +/* Display the --version information the standard way. + Author names are given in the array AUTHORS. N_AUTHORS is the + number of elements in the array. */ +void +version_etc_arn (FILE *stream, + const char *command_name, const char *package, + const char *version, + const char * const * authors, size_t n_authors) +{ if (command_name) fprintf (stream, "%s (%s) %s\n", command_name, package, version); else @@ -89,57 +93,64 @@ There is NO WARRANTY, to the extent permitted by law.\n\ abort (); case 1: /* TRANSLATORS: %s denotes an author name. */ - vfprintf (stream, _("Written by %s.\n"), authors); + fprintf (stream, _("Written by %s.\n"), authors[0]); break; case 2: /* TRANSLATORS: Each %s denotes an author name. */ - vfprintf (stream, _("Written by %s and %s.\n"), authors); + fprintf (stream, _("Written by %s and %s.\n"), authors[0], authors[1]); break; case 3: /* TRANSLATORS: Each %s denotes an author name. */ - vfprintf (stream, _("Written by %s, %s, and %s.\n"), authors); + fprintf (stream, _("Written by %s, %s, and %s.\n"), + authors[0], authors[1], authors[2]); break; case 4: /* TRANSLATORS: Each %s denotes an author name. You can use line breaks, estimating that each author name occupies ca. 16 screen columns and that a screen line has ca. 80 columns. */ - vfprintf (stream, _("Written by %s, %s, %s,\nand %s.\n"), authors); + fprintf (stream, _("Written by %s, %s, %s,\nand %s.\n"), + authors[0], authors[1], authors[2], authors[3]); break; case 5: /* TRANSLATORS: Each %s denotes an author name. You can use line breaks, estimating that each author name occupies ca. 16 screen columns and that a screen line has ca. 80 columns. */ - vfprintf (stream, _("Written by %s, %s, %s,\n%s, and %s.\n"), authors); + fprintf (stream, _("Written by %s, %s, %s,\n%s, and %s.\n"), + authors[0], authors[1], authors[2], authors[3], authors[4]); break; case 6: /* TRANSLATORS: Each %s denotes an author name. You can use line breaks, estimating that each author name occupies ca. 16 screen columns and that a screen line has ca. 80 columns. */ - vfprintf (stream, _("Written by %s, %s, %s,\n%s, %s, and %s.\n"), - authors); + fprintf (stream, _("Written by %s, %s, %s,\n%s, %s, and %s.\n"), + authors[0], authors[1], authors[2], authors[3], authors[4], + authors[5]); break; case 7: /* TRANSLATORS: Each %s denotes an author name. You can use line breaks, estimating that each author name occupies ca. 16 screen columns and that a screen line has ca. 80 columns. */ - vfprintf (stream, _("Written by %s, %s, %s,\n%s, %s, %s, and %s.\n"), - authors); + fprintf (stream, _("Written by %s, %s, %s,\n%s, %s, %s, and %s.\n"), + authors[0], authors[1], authors[2], authors[3], authors[4], + authors[5], authors[6]); break; case 8: /* TRANSLATORS: Each %s denotes an author name. You can use line breaks, estimating that each author name occupies ca. 16 screen columns and that a screen line has ca. 80 columns. */ - vfprintf (stream, _("\ + fprintf (stream, _("\ Written by %s, %s, %s,\n%s, %s, %s, %s,\nand %s.\n"), - authors); + authors[0], authors[1], authors[2], authors[3], authors[4], + authors[5], authors[6], authors[7]); break; case 9: /* TRANSLATORS: Each %s denotes an author name. You can use line breaks, estimating that each author name occupies ca. 16 screen columns and that a screen line has ca. 80 columns. */ - vfprintf (stream, _("\ + fprintf (stream, _("\ Written by %s, %s, %s,\n%s, %s, %s, %s,\n%s, and %s.\n"), - authors); + authors[0], authors[1], authors[2], authors[3], authors[4], + authors[5], authors[6], authors[7], authors[8]); break; default: /* 10 or more authors. Use an abbreviation, since the human reader @@ -147,18 +158,55 @@ Written by %s, %s, %s,\n%s, %s, %s, %s,\n%s, and %s.\n"), /* TRANSLATORS: Each %s denotes an author name. You can use line breaks, estimating that each author name occupies ca. 16 screen columns and that a screen line has ca. 80 columns. */ - vfprintf (stream, _("\ + fprintf (stream, _("\ Written by %s, %s, %s,\n%s, %s, %s, %s,\n%s, %s, and others.\n"), - authors); + authors[0], authors[1], authors[2], authors[3], authors[4], + authors[5], authors[6], authors[7], authors[8]); break; } - va_end (authors); +} + +/* Display the --version information the standard way. See the initial + comment to this module, for more information. + + Author names are given in the NULL-terminated array AUTHORS. */ +void +version_etc_ar (FILE *stream, + const char *command_name, const char *package, + const char *version, const char * const * authors) +{ + size_t n_authors; + + for (n_authors = 0; authors[n_authors]; n_authors++) + ; + version_etc_arn (stream, command_name, package, version, authors, n_authors); +} + +/* Display the --version information the standard way. See the initial + comment to this module, for more information. + + Author names are given in the NULL-terminated va_list AUTHORS. */ +void +version_etc_va (FILE *stream, + const char *command_name, const char *package, + const char *version, va_list authors) +{ + size_t n_authors; + const char *authtab[10]; + + for (n_authors = 0; + n_authors < 10 + && (authtab[n_authors] = va_arg (authors, const char *)) != NULL; + n_authors++) + ; + version_etc_arn (stream, command_name, package, version, + authtab, n_authors); } /* Display the --version information the standard way. - If COMMAND_NAME is NULL, the PACKAGE is asumed to be the name of + If COMMAND_NAME is NULL, the PACKAGE is assumed to be the name of the program. The formats are therefore: PACKAGE VERSION @@ -167,7 +215,7 @@ Written by %s, %s, %s,\n%s, %s, %s, %s,\n%s, %s, and others.\n"), COMMAND_NAME (PACKAGE) VERSION. - The author names are passed as separate arguments, with an additional + The authors names are passed as separate arguments, with an additional NULL argument at the end. */ void version_etc (FILE *stream, @@ -178,6 +226,7 @@ version_etc (FILE *stream, va_start (authors, version); version_etc_va (stream, command_name, package, version, authors); + va_end (authors); } void @@ -195,5 +244,5 @@ emit_bug_reporting_address (void) printf (_("%s home page: <http://www.gnu.org/software/%s/>.\n"), PACKAGE_NAME, PACKAGE); fputs (_("General help using GNU software: <http://www.gnu.org/gethelp/>.\n"), - stdout); + stdout); } diff --git a/gl/version-etc.h b/gl/version-etc.h index 33a8e7f143..8ce02fecb8 100644 --- a/gl/version-etc.h +++ b/gl/version-etc.h @@ -22,17 +22,57 @@ # include <stdarg.h> # include <stdio.h> +/* The `sentinel' attribute was added in gcc 4.0. */ +#ifndef ATTRIBUTE_SENTINEL +# if 4 <= __GNUC__ +# define ATTRIBUTE_SENTINEL __attribute__ ((__sentinel__)) +# else +# define ATTRIBUTE_SENTINEL /* empty */ +# endif +#endif + extern const char version_etc_copyright[]; +/* The three functions below display the --version information in the + standard way: command and package names, package version, followed + by a short GPLv3+ notice and a list of up to 10 author names. + + If COMMAND_NAME is NULL, the PACKAGE is asumed to be the name of + the program. The formats are therefore: + + PACKAGE VERSION + + or + + COMMAND_NAME (PACKAGE) VERSION. + + The functions differ in the way they are passed author names: */ + +/* N_AUTHORS names are supplied in array AUTHORS. */ +extern void version_etc_arn (FILE *stream, + const char *command_name, const char *package, + const char *version, + const char * const * authors, size_t n_authors); + +/* Names are passed in the NULL-terminated array AUTHORS. */ +extern void version_etc_ar (FILE *stream, + const char *command_name, const char *package, + const char *version, const char * const * authors); + +/* Names are passed in the NULL-terminated va_list. */ extern void version_etc_va (FILE *stream, const char *command_name, const char *package, const char *version, va_list authors); +/* Names are passed as separate arguments, with an additional + NULL argument at the end. */ extern void version_etc (FILE *stream, const char *command_name, const char *package, const char *version, - /* const char *author1, ...*/ ...); + /* const char *author1, ..., NULL */ ...) + ATTRIBUTE_SENTINEL; +/* Display the usual `Report bugs to' stanza */ extern void emit_bug_reporting_address (void); #endif /* VERSION_ETC_H */ |