From a927b6c1d885162c8c3068a74c07840c5bb52162 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ludovic=20Court=C3=A8s?= Date: Sat, 29 May 2010 23:58:12 +0200 Subject: [PATCH] Update Gnulib to v0.0-3955-g8ab5996. --- GNUmakefile | 12 +- build-aux/announce-gen | 15 +- build-aux/c++defs.h | 54 ++- build-aux/gendocs.sh | 12 +- build-aux/gnu-web-doc-update | 4 +- build-aux/gnupload | 13 +- build-aux/vc-list-files | 4 +- build-aux/warn-on-use.h | 23 +- doc/gendocs_template | 2 +- lib/Makefile.am | 93 ++++- lib/arpa_inet.in.h | 8 +- lib/canonicalize-lgpl.c | 2 +- lib/config.charset | 42 +- lib/getaddrinfo.c | 9 +- lib/gettext.h | 2 +- lib/libunistring.valgrind | 9 + lib/localcharset.c | 7 +- lib/locale.in.h | 2 + lib/netdb.in.h | 46 ++- lib/netinet_in.in.h | 8 +- lib/stdbool.in.h | 3 + lib/stdint.in.h | 7 +- lib/stdio-write.c | 2 - lib/stdio.in.h | 127 +++++-- lib/stdlib.in.h | 55 ++- lib/string.in.h | 50 ++- lib/sys_file.in.h | 11 +- lib/sys_socket.in.h | 35 +- lib/sys_stat.in.h | 15 +- lib/time.in.h | 70 ++-- lib/time_r.c | 4 +- lib/unistd.in.h | 231 ++++++++--- lib/{unistr.h => unistr.in.h} | 0 lib/{unitypes.h => unitypes.in.h} | 0 lib/vasnprintf.c | 601 ++++++++++++++++------------- lib/verify.h | 41 +- lib/wchar.in.h | 8 +- m4/absolute-header.m4 | 77 ++++ m4/arpa_inet_h.m4 | 4 +- m4/asm-underscore.m4 | 48 +++ m4/fcntl-o.m4 | 2 +- m4/getaddrinfo.m4 | 4 +- m4/gnulib-common.m4 | 67 +++- m4/gnulib-comp.m4 | 27 +- m4/iconv.m4 | 7 +- m4/iconv_h.m4 | 4 +- m4/inet_ntop.m4 | 4 +- m4/inet_pton.m4 | 4 +- m4/lib-link.m4 | 14 +- m4/libunistring-base.m4 | 143 +++++++ m4/libunistring.m4 | 121 +++++- m4/locale_h.m4 | 8 +- m4/mbrtowc.m4 | 61 +-- m4/mbsinit.m4 | 12 +- m4/memchr.m4 | 17 +- m4/netdb_h.m4 | 19 +- m4/stddef_h.m4 | 4 +- m4/stdio_h.m4 | 13 +- m4/stdlib_h.m4 | 20 +- m4/string_h.m4 | 18 +- m4/strings_h.m4 | 6 +- m4/sys_file_h.m4 | 4 +- m4/sys_socket_h.m4 | 6 +- m4/sys_stat_h.m4 | 6 +- m4/time_h.m4 | 12 +- m4/time_r.m4 | 98 ++--- m4/unistd_h.m4 | 26 +- m4/vasnprintf.m4 | 14 +- m4/visibility.m4 | 28 +- m4/wchar_h.m4 | 6 +- maint.mk | 610 +++++++++++++++++++++--------- 71 files changed, 2280 insertions(+), 861 deletions(-) create mode 100644 lib/libunistring.valgrind rename lib/{unistr.h => unistr.in.h} (100%) rename lib/{unitypes.h => unitypes.in.h} (100%) create mode 100644 m4/absolute-header.m4 create mode 100644 m4/asm-underscore.m4 create mode 100644 m4/libunistring-base.m4 rewrite m4/time_r.m4 (66%) diff --git a/GNUmakefile b/GNUmakefile index 40ccc061d..97fea3653 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -49,7 +49,7 @@ include $(srcdir)/maint.mk # Allow cfg.mk to override these. _build-aux ?= build-aux -_autoreconf ?= autoreconf +_autoreconf ?= autoreconf -v # Ensure that $(VERSION) is up to date for dist-related targets, but not # for others: rerunning autoreconf and recompiling everything isn't cheap. @@ -60,8 +60,10 @@ ifeq ($(_have-git-version-gen)0,yes$(MAKELEVEL)) $(filter maintainer-% dist% alpha beta major,$(MAKECMDGOALS))) _is-install-target ?= $(filter-out %check, $(filter install%,$(MAKECMDGOALS))) ifneq (,$(_is-dist-target)$(_is-install-target)) - _curr-ver := $(shell cd $(srcdir) \ - && $(_build-aux)/git-version-gen .tarball-version) + _curr-ver := $(shell cd $(srcdir) \ + && $(_build-aux)/git-version-gen \ + .tarball-version \ + $(git-version-gen-tag-sed-script)) ifneq ($(_curr-ver),$(VERSION)) ifeq ($(_curr-ver),UNKNOWN) $(info WARNING: unable to verify if $(VERSION) is the correct version) @@ -78,7 +80,8 @@ ifeq ($(_have-git-version-gen)0,yes$(MAKELEVEL)) $(info run '$(MAKE) _version' to fix it) else $(info INFO: running autoreconf for new version string: $(_curr-ver)) - _dummy := $(shell $(MAKE) $(AM_MAKEFLAGS) _version) +GNUmakefile: _version + touch GNUmakefile endif endif endif @@ -88,6 +91,7 @@ endif .PHONY: _version _version: cd $(srcdir) && rm -rf autom4te.cache .version && $(_autoreconf) + $(MAKE) $(AM_MAKEFLAGS) Makefile else diff --git a/build-aux/announce-gen b/build-aux/announce-gen index 7d70fd4b5..7f9ec86dc 100755 --- a/build-aux/announce-gen +++ b/build-aux/announce-gen @@ -3,7 +3,7 @@ eval '(exit $?0)' && eval 'exec perl -wS "$0" ${1+"$@"}' if 0; # Generate a release announcement message. -my $VERSION = '2009-11-20 13:36'; # UTC +my $VERSION = '2010-05-03 20:17'; # UTC # The definition above must lie within the first 8 lines in order # for the Emacs time-stamp write hook (at end) to update it. # If you change this file with Emacs, please let the write hook @@ -75,6 +75,8 @@ The following are optional: required if gnulib is in TOOL_LIST. --no-print-checksums do not emit MD5 or SHA1 checksums --archive-suffix=SUF add SUF to the list of archive suffixes + --mail-headers=HEADERS a space-separated list of mail headers, e.g., + To: x\@example.com Cc: y-announce\@example.com,... --help display this help and exit --version output version information and exit @@ -346,6 +348,7 @@ sub get_tool_versions ($$) # issue "1,2" instead of "1.2", what confuses our regexps. $ENV{LC_ALL} = "C"; + my $mail_headers; my $release_type; my $package_name; my $prev_version; @@ -359,6 +362,7 @@ sub get_tool_versions ($$) GetOptions ( + 'mail-headers=s' => \$mail_headers, 'release-type=s' => \$release_type, 'package-name=s' => \$package_name, 'previous-version=s' => \$prev_version, @@ -422,11 +426,18 @@ sub get_tool_versions ($$) %size or exit 1; + my $headers = ''; + if (defined $mail_headers) + { + ($headers = $mail_headers) =~ s/\s+(\S+:)/\n$1/g; + $headers .= "\n"; + } + # The markup is escaped as <\# so that when this script is sent by # mail (or part of a diff), Gnus is not triggered. print < diff --git a/build-aux/c++defs.h b/build-aux/c++defs.h index 31b29c226..0c2fad7a2 100644 --- a/build-aux/c++defs.h +++ b/build-aux/c++defs.h @@ -126,6 +126,24 @@ _GL_EXTERN_C int _gl_cxxalias_dummy #endif +/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters); + is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters); + except that the C function rpl_func may have a slightly different + declaration. A cast is used to silence the "invalid conversion" error + that would otherwise occur. */ +#if defined __cplusplus && defined GNULIB_NAMESPACE +# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ + namespace GNULIB_NAMESPACE \ + { \ + rettype (*const func) parameters = \ + reinterpret_cast(::rpl_func); \ + } \ + _GL_EXTERN_C int _gl_cxxalias_dummy +#else +# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ + _GL_EXTERN_C int _gl_cxxalias_dummy +#endif + /* _GL_CXXALIAS_SYS (func, rettype, parameters); declares a C++ alias called GNULIB_NAMESPACE::func that redirects to the system provided function func, if GNULIB_NAMESPACE @@ -203,10 +221,20 @@ _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) # define _GL_CXXALIASWARN_1(func,namespace) \ _GL_CXXALIASWARN_2 (func, namespace) -# define _GL_CXXALIASWARN_2(func,namespace) \ - _GL_WARN_ON_USE (func, \ - "The symbol ::" #func " refers to the system function. " \ - "Use " #namespace "::" #func " instead.") +/* To work around GCC bug , + we enable the warning only when not optimizing. */ +# if !__OPTIMIZE__ +# define _GL_CXXALIASWARN_2(func,namespace) \ + _GL_WARN_ON_USE (func, \ + "The symbol ::" #func " refers to the system function. " \ + "Use " #namespace "::" #func " instead.") +# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING +# define _GL_CXXALIASWARN_2(func,namespace) \ + extern __typeof__ (func) func +# else +# define _GL_CXXALIASWARN_2(func,namespace) \ + _GL_EXTERN_C int _gl_cxxalias_dummy +# endif #else # define _GL_CXXALIASWARN(func) \ _GL_EXTERN_C int _gl_cxxalias_dummy @@ -221,10 +249,20 @@ GNULIB_NAMESPACE) # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \ _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace) -# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ - _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \ - "The symbol ::" #func " refers to the system function. " \ - "Use " #namespace "::" #func " instead.") +/* To work around GCC bug , + we enable the warning only when not optimizing. */ +# if !__OPTIMIZE__ +# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ + _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \ + "The symbol ::" #func " refers to the system function. " \ + "Use " #namespace "::" #func " instead.") +# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING +# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ + extern __typeof__ (func) func +# else +# define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ + _GL_EXTERN_C int _gl_cxxalias_dummy +# endif #else # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ _GL_EXTERN_C int _gl_cxxalias_dummy diff --git a/build-aux/gendocs.sh b/build-aux/gendocs.sh index 67d5b52ca..8cab8f6cd 100755 --- a/build-aux/gendocs.sh +++ b/build-aux/gendocs.sh @@ -2,7 +2,7 @@ # gendocs.sh -- generate a GNU manual in many formats. This script is # mentioned in maintain.texi. See the help message below for usage details. -scriptversion=2010-02-13.20 +scriptversion=2010-05-04.09 # Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 # Free Software Foundation, Inc. @@ -149,8 +149,16 @@ while test $# -gt 0; do shift done +# For most of the following, the base name is just $PACKAGE +base=$PACKAGE + if test -n "$srcfile"; then - : + # but here, we use the basename of $srcfile + base=`basename "$srcfile"` + case $base in + *.txi|*.texi|*.texinfo) base=`echo "$base"|sed 's/\.[texinfo]*$//'`;; + esac + PACKAGE=$base elif test -s "$srcdir/$PACKAGE.texinfo"; then srcfile=$srcdir/$PACKAGE.texinfo elif test -s "$srcdir/$PACKAGE.texi"; then diff --git a/build-aux/gnu-web-doc-update b/build-aux/gnu-web-doc-update index 2c1a0cc6e..e834dcf46 100755 --- a/build-aux/gnu-web-doc-update +++ b/build-aux/gnu-web-doc-update @@ -90,7 +90,9 @@ trap 'exit $?' 1 2 13 15 # just-released version number, not some string like 7.6.18-20761. # That version string propagates into all documentation. git checkout -b $tmp_branch v$version -./bootstrap && ./configure && make && make web-manual +ok=0 +./bootstrap && ./configure && make && make web-manual && ok=1 +test $ok = 1 || exit 1 tmp=$(mktemp -d --tmpdir=. web-doc-update.XXXXXX) || exit 1 ( cd $tmp \ diff --git a/build-aux/gnupload b/build-aux/gnupload index c28a5cc13..68215caf6 100755 --- a/build-aux/gnupload +++ b/build-aux/gnupload @@ -1,7 +1,7 @@ #!/bin/sh # Sign files and upload them. -scriptversion=2010-02-08.07; # UTC +scriptversion=2010-05-23.15; # UTC # Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software # Foundation, Inc. @@ -32,6 +32,8 @@ delete_files= delete_symlinks= collect_var= dbg= +nl=' +' usage="Usage: $0 [OPTION]... [CMD] FILE... [[CMD] FILE...] @@ -109,7 +111,8 @@ Send patches to ." # Read local configuration file if test -r "$conffile"; then echo "$0: Reading configuration file $conffile" - eval set x "`sed 's/#.*$//;/^$/d' \"$conffile\" | tr '\012\015' ' '` \"\$@\"" + conf=`sed 's/#.*$//;/^$/d' "$conffile" | tr "\015$nl" ' '` + eval set x "$conf \"\$@\"" shift fi @@ -185,7 +188,7 @@ done dprint() { - echo "Running $*..." + echo "Running $* ..." } if $dry_run; then @@ -249,7 +252,7 @@ echo if test $# -ne 0; then for file do - echo "Signing $file..." + echo "Signing $file ..." rm -f $file.sig echo "$passphrase" | $dbg $GPG --passphrase-fd 0 -ba -o $file.sig $file done @@ -388,7 +391,7 @@ for dest in $to do for file do - echo "Uploading $file to $dest..." + echo "Uploading $file to $dest ..." stmt= files="$file $file.sig" destdir=`echo $dest | sed 's/[^:]*://'` diff --git a/build-aux/vc-list-files b/build-aux/vc-list-files index b9f2fbd8f..48a33ee7f 100755 --- a/build-aux/vc-list-files +++ b/build-aux/vc-list-files @@ -2,7 +2,7 @@ # List version-controlled file names. # Print a version string. -scriptversion=2010-02-21.13; # UTC +scriptversion=2010-04-23.22; # UTC # Copyright (C) 2006-2010 Free Software Foundation, Inc. @@ -102,6 +102,8 @@ elif test -d CVS; then }}'\'' \ `find "$dir" -name Entries -print` /dev/null' $postprocess fi +elif test -d .svn; then + eval exec svn list -R '"$dir"' $postprocess else echo "$0: Failed to determine type of version control used in `pwd`" 1>&2 exit 1 diff --git a/build-aux/warn-on-use.h b/build-aux/warn-on-use.h index 03ae87190..171e59916 100644 --- a/build-aux/warn-on-use.h +++ b/build-aux/warn-on-use.h @@ -67,10 +67,13 @@ /* A compiler attribute is available in gcc versions 4.3.0 and later. */ # define _GL_WARN_ON_USE(function, message) \ extern __typeof__ (function) function __attribute__ ((__warning__ (message))) - +# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING +/* Verify the existence of the function. */ +# define _GL_WARN_ON_USE(function, message) \ +extern __typeof__ (function) function # else /* Unsupported. */ # define _GL_WARN_ON_USE(function, message) \ -extern int _gl_warn_on_use +_GL_WARN_EXTERN_C int _gl_warn_on_use # endif #endif @@ -85,8 +88,22 @@ extern int _gl_warn_on_use # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ extern rettype function parameters_and_attributes \ __attribute__ ((__warning__ (msg))) +# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING +/* Verify the existence of the function. */ +# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ +extern rettype function parameters_and_attributes # else /* Unsupported. */ # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ -extern int _gl_warn_on_use +_GL_WARN_EXTERN_C int _gl_warn_on_use +# endif +#endif + +/* _GL_WARN_EXTERN_C declaration; + performs the declaration with C linkage. */ +#ifndef _GL_WARN_EXTERN_C +# if defined __cplusplus +# define _GL_WARN_EXTERN_C extern "C" +# else +# define _GL_WARN_EXTERN_C extern # endif #endif diff --git a/doc/gendocs_template b/doc/gendocs_template index ee6a5c566..ccce0be2a 100644 --- a/doc/gendocs_template +++ b/doc/gendocs_template @@ -85,7 +85,7 @@ Please send broken links and other corrections or suggestions to <%%EMAIL%%>.

-

Copyright © 2009 Free Software Foundation, Inc.

+

Copyright © 2010 Free Software Foundation, Inc.

Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.

diff --git a/lib/Makefile.am b/lib/Makefile.am index 149586edd..5f5172793 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -491,6 +491,13 @@ AM_CFLAGS += $(CFLAG_VISIBILITY) ## end gnulib module lib-symbol-visibility +## begin gnulib module libunistring + + +EXTRA_DIST += libunistring.valgrind + +## end gnulib module libunistring + ## begin gnulib module localcharset libgnu_la_SOURCES += localcharset.h localcharset.c @@ -663,11 +670,11 @@ EXTRA_libgnu_la_SOURCES += memchr.c ## begin gnulib module netdb -BUILT_SOURCES += $(NETDB_H) +BUILT_SOURCES += netdb.h # We need the following in order to create when the system # doesn't have one that works with the given compiler. -netdb.h: netdb.in.h $(ARG_NONNULL_H) +netdb.h: netdb.in.h $(ARG_NONNULL_H) $(WARN_ON_USE_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ @@ -681,6 +688,7 @@ netdb.h: netdb.in.h $(ARG_NONNULL_H) -e 's|@''HAVE_DECL_GETADDRINFO''@|$(HAVE_DECL_GETADDRINFO)|g' \ -e 's|@''HAVE_DECL_GETNAMEINFO''@|$(HAVE_DECL_GETNAMEINFO)|g' \ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ + -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ < $(srcdir)/netdb.in.h; \ } > $@-t && \ mv $@-t $@ @@ -929,6 +937,7 @@ stdio.h: stdio.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -e 's|@''GNULIB_SNPRINTF''@|$(GNULIB_SNPRINTF)|g' \ -e 's|@''GNULIB_SPRINTF_POSIX''@|$(GNULIB_SPRINTF_POSIX)|g' \ -e 's|@''GNULIB_STDIO_H_SIGPIPE''@|$(GNULIB_STDIO_H_SIGPIPE)|g' \ + -e 's|@''GNULIB_TMPFILE''@|$(GNULIB_TMPFILE)|g' \ -e 's|@''GNULIB_VASPRINTF''@|$(GNULIB_VASPRINTF)|g' \ -e 's|@''GNULIB_VDPRINTF''@|$(GNULIB_VDPRINTF)|g' \ -e 's|@''GNULIB_VFPRINTF''@|$(GNULIB_VFPRINTF)|g' \ @@ -945,6 +954,8 @@ stdio.h: stdio.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -e 's|@''HAVE_DECL_SNPRINTF''@|$(HAVE_DECL_SNPRINTF)|g' \ -e 's|@''HAVE_DECL_VSNPRINTF''@|$(HAVE_DECL_VSNPRINTF)|g' \ -e 's|@''HAVE_DPRINTF''@|$(HAVE_DPRINTF)|g' \ + -e 's|@''HAVE_FSEEKO''@|$(HAVE_FSEEKO)|g' \ + -e 's|@''HAVE_FTELLO''@|$(HAVE_FTELLO)|g' \ -e 's|@''HAVE_RENAMEAT''@|$(HAVE_RENAMEAT)|g' \ -e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \ -e 's|@''HAVE_VDPRINTF''@|$(HAVE_VDPRINTF)|g' \ @@ -971,12 +982,14 @@ stdio.h: stdio.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -e 's|@''REPLACE_SNPRINTF''@|$(REPLACE_SNPRINTF)|g' \ -e 's|@''REPLACE_SPRINTF''@|$(REPLACE_SPRINTF)|g' \ -e 's|@''REPLACE_STDIO_WRITE_FUNCS''@|$(REPLACE_STDIO_WRITE_FUNCS)|g' \ + -e 's|@''REPLACE_TMPFILE''@|$(REPLACE_TMPFILE)|g' \ -e 's|@''REPLACE_VASPRINTF''@|$(REPLACE_VASPRINTF)|g' \ -e 's|@''REPLACE_VDPRINTF''@|$(REPLACE_VDPRINTF)|g' \ -e 's|@''REPLACE_VFPRINTF''@|$(REPLACE_VFPRINTF)|g' \ -e 's|@''REPLACE_VPRINTF''@|$(REPLACE_VPRINTF)|g' \ -e 's|@''REPLACE_VSNPRINTF''@|$(REPLACE_VSNPRINTF)|g' \ -e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \ + -e 's|@''ASM_SYMBOL_PREFIX''@|$(ASM_SYMBOL_PREFIX)|g' \ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \ @@ -1007,12 +1020,14 @@ stdlib.h: stdlib.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -e 's|@''GNULIB_CANONICALIZE_FILE_NAME''@|$(GNULIB_CANONICALIZE_FILE_NAME)|g' \ -e 's|@''GNULIB_GETLOADAVG''@|$(GNULIB_GETLOADAVG)|g' \ -e 's|@''GNULIB_GETSUBOPT''@|$(GNULIB_GETSUBOPT)|g' \ + -e 's|@''GNULIB_GRANTPT''@|$(GNULIB_GRANTPT)|g' \ -e 's|@''GNULIB_MALLOC_POSIX''@|$(GNULIB_MALLOC_POSIX)|g' \ -e 's|@''GNULIB_MKDTEMP''@|$(GNULIB_MKDTEMP)|g' \ -e 's|@''GNULIB_MKOSTEMP''@|$(GNULIB_MKOSTEMP)|g' \ -e 's|@''GNULIB_MKOSTEMPS''@|$(GNULIB_MKOSTEMPS)|g' \ -e 's|@''GNULIB_MKSTEMP''@|$(GNULIB_MKSTEMP)|g' \ -e 's|@''GNULIB_MKSTEMPS''@|$(GNULIB_MKSTEMPS)|g' \ + -e 's|@''GNULIB_PTSNAME''@|$(GNULIB_PTSNAME)|g' \ -e 's|@''GNULIB_PUTENV''@|$(GNULIB_PUTENV)|g' \ -e 's|@''GNULIB_RANDOM_R''@|$(GNULIB_RANDOM_R)|g' \ -e 's|@''GNULIB_REALLOC_POSIX''@|$(GNULIB_REALLOC_POSIX)|g' \ @@ -1022,17 +1037,21 @@ stdlib.h: stdlib.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -e 's|@''GNULIB_STRTOD''@|$(GNULIB_STRTOD)|g' \ -e 's|@''GNULIB_STRTOLL''@|$(GNULIB_STRTOLL)|g' \ -e 's|@''GNULIB_STRTOULL''@|$(GNULIB_STRTOULL)|g' \ + -e 's|@''GNULIB_UNLOCKPT''@|$(GNULIB_UNLOCKPT)|g' \ -e 's|@''GNULIB_UNSETENV''@|$(GNULIB_UNSETENV)|g' \ -e 's|@''HAVE_ATOLL''@|$(HAVE_ATOLL)|g' \ -e 's|@''HAVE_CALLOC_POSIX''@|$(HAVE_CALLOC_POSIX)|g' \ -e 's|@''HAVE_CANONICALIZE_FILE_NAME''@|$(HAVE_CANONICALIZE_FILE_NAME)|g' \ -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \ -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \ + -e 's|@''HAVE_GRANTPT''@|$(HAVE_GRANTPT)|g' \ -e 's|@''HAVE_MALLOC_POSIX''@|$(HAVE_MALLOC_POSIX)|g' \ -e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \ -e 's|@''HAVE_MKOSTEMP''@|$(HAVE_MKOSTEMP)|g' \ -e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \ + -e 's|@''HAVE_MKSTEMP''@|$(HAVE_MKSTEMP)|g' \ -e 's|@''HAVE_MKSTEMPS''@|$(HAVE_MKSTEMPS)|g' \ + -e 's|@''HAVE_PTSNAME''@|$(HAVE_PTSNAME)|g' \ -e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \ -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \ -e 's|@''HAVE_REALLOC_POSIX''@|$(HAVE_REALLOC_POSIX)|g' \ @@ -1044,6 +1063,7 @@ stdlib.h: stdlib.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -e 's|@''HAVE_STRTOULL''@|$(HAVE_STRTOULL)|g' \ -e 's|@''HAVE_STRUCT_RANDOM_DATA''@|$(HAVE_STRUCT_RANDOM_DATA)|g' \ -e 's|@''HAVE_SYS_LOADAVG_H''@|$(HAVE_SYS_LOADAVG_H)|g' \ + -e 's|@''HAVE_UNLOCKPT''@|$(HAVE_UNLOCKPT)|g' \ -e 's|@''HAVE_UNSETENV''@|$(HAVE_UNSETENV)|g' \ -e 's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \ -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \ @@ -1135,6 +1155,7 @@ string.h: string.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -e 's|@''GNULIB_STPNCPY''@|$(GNULIB_STPNCPY)|g' \ -e 's|@''GNULIB_STRCHRNUL''@|$(GNULIB_STRCHRNUL)|g' \ -e 's|@''GNULIB_STRDUP''@|$(GNULIB_STRDUP)|g' \ + -e 's|@''GNULIB_STRNCAT''@|$(GNULIB_STRNCAT)|g' \ -e 's|@''GNULIB_STRNDUP''@|$(GNULIB_STRNDUP)|g' \ -e 's|@''GNULIB_STRNLEN''@|$(GNULIB_STRNLEN)|g' \ -e 's|@''GNULIB_STRPBRK''@|$(GNULIB_STRPBRK)|g' \ @@ -1147,6 +1168,7 @@ string.h: string.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -e 's|@''GNULIB_STRVERSCMP''@|$(GNULIB_STRVERSCMP)|g' \ < $(srcdir)/string.in.h | \ sed -e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \ + -e 's|@''HAVE_MEMCHR''@|$(HAVE_MEMCHR)|g' \ -e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \ -e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \ -e 's|@''HAVE_DECL_MEMRCHR''@|$(HAVE_DECL_MEMRCHR)|g' \ @@ -1161,16 +1183,18 @@ string.h: string.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -e 's|@''HAVE_STRSEP''@|$(HAVE_STRSEP)|g' \ -e 's|@''HAVE_STRCASESTR''@|$(HAVE_STRCASESTR)|g' \ -e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \ - -e 's|@''HAVE_DECL_STRERROR''@|$(HAVE_DECL_STRERROR)|g' \ -e 's|@''HAVE_DECL_STRSIGNAL''@|$(HAVE_DECL_STRSIGNAL)|g' \ -e 's|@''HAVE_STRVERSCMP''@|$(HAVE_STRVERSCMP)|g' \ + -e 's|@''REPLACE_STPNCPY''@|$(REPLACE_STPNCPY)|g' \ -e 's|@''REPLACE_MEMCHR''@|$(REPLACE_MEMCHR)|g' \ -e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \ -e 's|@''REPLACE_STRCASESTR''@|$(REPLACE_STRCASESTR)|g' \ -e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \ -e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \ -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \ + -e 's|@''REPLACE_STRNCAT''@|$(REPLACE_STRNCAT)|g' \ -e 's|@''REPLACE_STRNDUP''@|$(REPLACE_STRNDUP)|g' \ + -e 's|@''REPLACE_STRNLEN''@|$(REPLACE_STRNLEN)|g' \ -e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \ -e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \ -e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \ @@ -1361,10 +1385,13 @@ time.h: time.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -e 's|@''GNULIB_STRPTIME''@|$(GNULIB_STRPTIME)|g' \ -e 's|@''GNULIB_TIMEGM''@|$(GNULIB_TIMEGM)|g' \ -e 's|@''GNULIB_TIME_R''@|$(GNULIB_TIME_R)|g' \ + -e 's|@''HAVE_LOCALTIME_R''@|$(HAVE_LOCALTIME_R)|g' \ + -e 's|@''HAVE_NANOSLEEP''@|$(HAVE_NANOSLEEP)|g' \ + -e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \ + -e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \ -e 's|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \ -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \ -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \ - -e 's|@''REPLACE_STRPTIME''@|$(REPLACE_STRPTIME)|g' \ -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \ -e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ -e 's|@''TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ @@ -1428,12 +1455,14 @@ unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -e 's|@''GNULIB_LSEEK''@|$(GNULIB_LSEEK)|g' \ -e 's|@''GNULIB_PIPE2''@|$(GNULIB_PIPE2)|g' \ -e 's|@''GNULIB_PREAD''@|$(GNULIB_PREAD)|g' \ + -e 's|@''GNULIB_PWRITE''@|$(GNULIB_PWRITE)|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_TTYNAME_R''@|$(GNULIB_TTYNAME_R)|g' \ -e 's|@''GNULIB_UNISTD_H_GETOPT''@|$(GNULIB_UNISTD_H_GETOPT)|g' \ -e 's|@''GNULIB_UNISTD_H_SIGPIPE''@|$(GNULIB_UNISTD_H_SIGPIPE)|g' \ -e 's|@''GNULIB_UNLINK''@|$(GNULIB_UNLINK)|g' \ @@ -1446,6 +1475,7 @@ unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -e 's|@''HAVE_DUP3''@|$(HAVE_DUP3)|g' \ -e 's|@''HAVE_EUIDACCESS''@|$(HAVE_EUIDACCESS)|g' \ -e 's|@''HAVE_FACCESSAT''@|$(HAVE_FACCESSAT)|g' \ + -e 's|@''HAVE_FCHDIR''@|$(HAVE_FCHDIR)|g' \ -e 's|@''HAVE_FCHOWNAT''@|$(HAVE_FCHOWNAT)|g' \ -e 's|@''HAVE_FSYNC''@|$(HAVE_FSYNC)|g' \ -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \ @@ -1455,28 +1485,30 @@ unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -e 's|@''HAVE_GETHOSTNAME''@|$(HAVE_GETHOSTNAME)|g' \ -e 's|@''HAVE_GETLOGIN''@|$(HAVE_GETLOGIN)|g' \ -e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \ - -e 's|@''HAVE_GETUSERSHELL''@|$(HAVE_GETUSERSHELL)|g' \ -e 's|@''HAVE_LCHOWN''@|$(HAVE_LCHOWN)|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_PREAD''@|$(HAVE_PREAD)|g' \ + -e 's|@''HAVE_PWRITE''@|$(HAVE_PWRITE)|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_TTYNAME_R''@|$(HAVE_TTYNAME_R)|g' \ -e 's|@''HAVE_UNLINKAT''@|$(HAVE_UNLINKAT)|g' \ -e 's|@''HAVE_USLEEP''@|$(HAVE_USLEEP)|g' \ -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \ -e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \ + -e 's|@''HAVE_DECL_GETPAGESIZE''@|$(HAVE_DECL_GETPAGESIZE)|g' \ + -e 's|@''HAVE_DECL_GETUSERSHELL''@|$(HAVE_DECL_GETUSERSHELL)|g' \ -e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \ -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_DUP''@|$(REPLACE_DUP)|g' \ -e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \ - -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \ -e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \ -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \ -e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \ @@ -1486,10 +1518,12 @@ unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -e 's|@''REPLACE_LINKAT''@|$(REPLACE_LINKAT)|g' \ -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \ -e 's|@''REPLACE_PREAD''@|$(REPLACE_PREAD)|g' \ + -e 's|@''REPLACE_PWRITE''@|$(REPLACE_PWRITE)|g' \ -e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \ -e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \ -e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \ -e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \ + -e 's|@''REPLACE_TTYNAME_R''@|$(REPLACE_TTYNAME_R)|g' \ -e 's|@''REPLACE_UNLINK''@|$(REPLACE_UNLINK)|g' \ -e 's|@''REPLACE_UNLINKAT''@|$(REPLACE_UNLINKAT)|g' \ -e 's|@''REPLACE_USLEEP''@|$(REPLACE_USLEEP)|g' \ @@ -1509,45 +1543,78 @@ EXTRA_DIST += unistd.in.h ## begin gnulib module unistr/base +BUILT_SOURCES += $(LIBUNISTRING_UNISTR_H) -EXTRA_DIST += unistr.h +unistr.h: unistr.in.h + $(AM_V_GEN)rm -f $@-t $@ && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + cat $(srcdir)/unistr.in.h; \ + } > $@-t && \ + mv -f $@-t $@ +MOSTLYCLEANFILES += unistr.h unistr.h-t + +EXTRA_DIST += unistr.in.h ## end gnulib module unistr/base ## begin gnulib module unistr/u8-mbtouc -libgnu_la_SOURCES += unistr/u8-mbtouc.c unistr/u8-mbtouc-aux.c + +EXTRA_DIST += unistr/u8-mbtouc-aux.c unistr/u8-mbtouc.c + +EXTRA_libgnu_la_SOURCES += unistr/u8-mbtouc-aux.c unistr/u8-mbtouc.c ## end gnulib module unistr/u8-mbtouc ## begin gnulib module unistr/u8-mbtouc-unsafe -libgnu_la_SOURCES += unistr/u8-mbtouc-unsafe.c unistr/u8-mbtouc-unsafe-aux.c + +EXTRA_DIST += unistr/u8-mbtouc-unsafe-aux.c unistr/u8-mbtouc-unsafe.c + +EXTRA_libgnu_la_SOURCES += unistr/u8-mbtouc-unsafe-aux.c unistr/u8-mbtouc-unsafe.c ## end gnulib module unistr/u8-mbtouc-unsafe ## begin gnulib module unistr/u8-mbtoucr -libgnu_la_SOURCES += unistr/u8-mbtoucr.c + +EXTRA_DIST += unistr/u8-mbtoucr.c + +EXTRA_libgnu_la_SOURCES += unistr/u8-mbtoucr.c ## end gnulib module unistr/u8-mbtoucr ## begin gnulib module unistr/u8-prev -libgnu_la_SOURCES += unistr/u8-prev.c + +EXTRA_DIST += unistr/u8-prev.c + +EXTRA_libgnu_la_SOURCES += unistr/u8-prev.c ## end gnulib module unistr/u8-prev ## begin gnulib module unistr/u8-uctomb -libgnu_la_SOURCES += unistr/u8-uctomb.c unistr/u8-uctomb-aux.c + +EXTRA_DIST += unistr/u8-uctomb-aux.c unistr/u8-uctomb.c + +EXTRA_libgnu_la_SOURCES += unistr/u8-uctomb-aux.c unistr/u8-uctomb.c ## end gnulib module unistr/u8-uctomb ## begin gnulib module unitypes +BUILT_SOURCES += $(LIBUNISTRING_UNITYPES_H) + +unitypes.h: unitypes.in.h + $(AM_V_GEN)rm -f $@-t $@ && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + cat $(srcdir)/unitypes.in.h; \ + } > $@-t && \ + mv -f $@-t $@ +MOSTLYCLEANFILES += unitypes.h unitypes.h-t -EXTRA_DIST += unitypes.h +EXTRA_DIST += unitypes.in.h ## end gnulib module unitypes diff --git a/lib/arpa_inet.in.h b/lib/arpa_inet.in.h index 8e6c6c5e2..2dedcd7ce 100644 --- a/lib/arpa_inet.in.h +++ b/lib/arpa_inet.in.h @@ -18,6 +18,10 @@ #ifndef _GL_ARPA_INET_H +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif + /* Gnulib's sys/socket.h is responsible for pulling in winsock2.h etc under MinGW. But avoid namespace pollution on glibc systems. */ @@ -27,10 +31,6 @@ #if @HAVE_ARPA_INET_H@ -# if __GNUC__ >= 3 -@PRAGMA_SYSTEM_HEADER@ -# endif - /* The include_next requires a split double-inclusion guard. */ # @INCLUDE_NEXT@ @NEXT_ARPA_INET_H@ diff --git a/lib/canonicalize-lgpl.c b/lib/canonicalize-lgpl.c index 0f36add66..9979eda2c 100644 --- a/lib/canonicalize-lgpl.c +++ b/lib/canonicalize-lgpl.c @@ -43,7 +43,7 @@ # include #else # define SHLIB_COMPAT(lib, introduced, obsoleted) 0 -# define versioned_symbol(lib, local, symbol, version) +# define versioned_symbol(lib, local, symbol, version) extern int dummy # define compat_symbol(lib, local, symbol, version) # define weak_alias(local, symbol) # define __canonicalize_file_name canonicalize_file_name diff --git a/lib/config.charset b/lib/config.charset index ae2efc4d8..7435711c6 100644 --- a/lib/config.charset +++ b/lib/config.charset @@ -30,21 +30,21 @@ # The current list of GNU canonical charset names is as follows. # # name MIME? used by which systems -# ASCII, ANSI_X3.4-1968 glibc solaris freebsd netbsd darwin -# ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin -# ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin -# ISO-8859-3 Y glibc solaris +# ASCII, ANSI_X3.4-1968 glibc solaris freebsd netbsd darwin cygwin +# ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin +# ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin +# ISO-8859-3 Y glibc solaris cygwin # ISO-8859-4 Y osf solaris freebsd netbsd openbsd darwin -# ISO-8859-5 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin -# ISO-8859-6 Y glibc aix hpux solaris -# ISO-8859-7 Y glibc aix hpux irix osf solaris netbsd openbsd darwin -# ISO-8859-8 Y glibc aix hpux osf solaris -# ISO-8859-9 Y glibc aix hpux irix osf solaris darwin -# ISO-8859-13 glibc netbsd openbsd darwin -# ISO-8859-14 glibc -# ISO-8859-15 glibc aix osf solaris freebsd netbsd openbsd darwin +# ISO-8859-5 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin +# ISO-8859-6 Y glibc aix hpux solaris cygwin +# ISO-8859-7 Y glibc aix hpux irix osf solaris netbsd openbsd darwin cygwin +# ISO-8859-8 Y glibc aix hpux osf solaris cygwin +# ISO-8859-9 Y glibc aix hpux irix osf solaris darwin cygwin +# ISO-8859-13 glibc netbsd openbsd darwin cygwin +# ISO-8859-14 glibc cygwin +# ISO-8859-15 glibc aix osf solaris freebsd netbsd openbsd darwin cygwin # KOI8-R Y glibc solaris freebsd netbsd openbsd darwin -# KOI8-U Y glibc freebsd netbsd openbsd darwin +# KOI8-U Y glibc freebsd netbsd openbsd darwin cygwin # KOI8-T glibc # CP437 dos # CP775 dos @@ -61,7 +61,7 @@ # CP869 dos # CP874 woe32 dos # CP922 aix -# CP932 aix woe32 dos +# CP932 aix cygwin woe32 dos # CP943 aix # CP949 osf darwin woe32 dos # CP950 woe32 dos @@ -71,7 +71,7 @@ # CP1129 aix # CP1131 darwin # CP1250 woe32 -# CP1251 glibc solaris netbsd openbsd darwin woe32 +# CP1251 glibc solaris netbsd openbsd darwin cygwin woe32 # CP1252 aix woe32 # CP1253 woe32 # CP1254 woe32 @@ -80,19 +80,19 @@ # CP1257 woe32 # GB2312 Y glibc aix hpux irix solaris freebsd netbsd darwin # EUC-JP Y glibc aix hpux irix osf solaris freebsd netbsd darwin -# EUC-KR Y glibc aix hpux irix osf solaris freebsd netbsd darwin +# EUC-KR Y glibc aix hpux irix osf solaris freebsd netbsd darwin cygwin # EUC-TW glibc aix hpux irix osf solaris netbsd -# BIG5 Y glibc aix hpux osf solaris freebsd netbsd darwin +# BIG5 Y glibc aix hpux osf solaris freebsd netbsd darwin cygwin # BIG5-HKSCS glibc solaris darwin -# GBK glibc aix osf solaris darwin woe32 dos +# GBK glibc aix osf solaris darwin cygwin woe32 dos # GB18030 glibc solaris netbsd darwin # SHIFT_JIS Y hpux osf solaris freebsd netbsd darwin # JOHAB glibc solaris woe32 -# TIS-620 glibc aix hpux osf solaris +# TIS-620 glibc aix hpux osf solaris cygwin # VISCII Y glibc # TCVN5712-1 glibc # ARMSCII-8 glibc darwin -# GEORGIAN-PS glibc +# GEORGIAN-PS glibc cygwin # PT154 glibc # HP-ROMAN8 hpux # HP-ARABIC8 hpux @@ -102,7 +102,7 @@ # HP-KANA8 hpux # DEC-KANJI osf # DEC-HANYU osf -# UTF-8 Y glibc aix hpux osf solaris netbsd darwin +# UTF-8 Y glibc aix hpux osf solaris netbsd darwin cygwin # # Note: Names which are not marked as being a MIME name should not be used in # Internet protocols for information interchange (mail, news, etc.). diff --git a/lib/getaddrinfo.c b/lib/getaddrinfo.c index 475eaa0f3..2e7090300 100644 --- a/lib/getaddrinfo.c +++ b/lib/getaddrinfo.c @@ -351,10 +351,11 @@ freeaddrinfo (struct addrinfo *ai) } } -int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen, - char *restrict node, socklen_t nodelen, - char *restrict service, socklen_t servicelen, - int flags) +int +getnameinfo (const struct sockaddr *restrict sa, socklen_t salen, + char *restrict node, socklen_t nodelen, + char *restrict service, socklen_t servicelen, + int flags) { #ifdef WIN32_NATIVE if (use_win32_p ()) diff --git a/lib/gettext.h b/lib/gettext.h index 987009ff2..6eed64d68 100644 --- a/lib/gettext.h +++ b/lib/gettext.h @@ -81,7 +81,7 @@ ((void) (Domainname), ngettext (Msgid1, Msgid2, N)) # undef dcngettext # define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \ - ((void) (Category), dngettext(Domainname, Msgid1, Msgid2, N)) + ((void) (Category), dngettext (Domainname, Msgid1, Msgid2, N)) # undef textdomain # define textdomain(Domainname) ((const char *) (Domainname)) # undef bindtextdomain diff --git a/lib/libunistring.valgrind b/lib/libunistring.valgrind new file mode 100644 index 000000000..aba265aec --- /dev/null +++ b/lib/libunistring.valgrind @@ -0,0 +1,9 @@ +# Suppress valgrind messages in an installed libunistring. + +# Suppress a valgrind message about use of uninitialized memory in freea(). +# This use is OK because it provides only a speedup. +{ + libunistring_freea + Memcheck:Cond + fun:libunistring_freea +} diff --git a/lib/localcharset.c b/lib/localcharset.c index 29de23d67..6c233d1c0 100644 --- a/lib/localcharset.c +++ b/lib/localcharset.c @@ -369,10 +369,9 @@ locale_charset (void) codeset = nl_langinfo (CODESET); # ifdef __CYGWIN__ - /* Cygwin 1.5.x does not have locales. nl_langinfo (CODESET) always - returns "US-ASCII". As long as this is not fixed, return the suffix - of the locale name from the environment variables (if present) or - the codepage as a number. */ + /* Cygwin < 1.7 does not have locales. nl_langinfo (CODESET) always + returns "US-ASCII". Return the suffix of the locale name from the + environment variables (if present) or the codepage as a number. */ if (codeset != NULL && strcmp (codeset, "US-ASCII") == 0) { const char *locale; diff --git a/lib/locale.in.h b/lib/locale.in.h index 0d3ca80b8..64212d879 100644 --- a/lib/locale.in.h +++ b/lib/locale.in.h @@ -59,7 +59,9 @@ _GL_CXXALIAS_RPL (duplocale, locale_t, (locale_t locale)); _GL_CXXALIAS_SYS (duplocale, locale_t, (locale_t locale)); # endif # endif +# if @HAVE_DUPLOCALE@ _GL_CXXALIASWARN (duplocale); +# endif #elif defined GNULIB_POSIXCHECK # undef duplocale # if HAVE_RAW_DECL_DUPLOCALE diff --git a/lib/netdb.in.h b/lib/netdb.in.h index 8fa6164fe..d67a96cd6 100644 --- a/lib/netdb.in.h +++ b/lib/netdb.in.h @@ -22,11 +22,11 @@ #ifndef _GL_NETDB_H -#if @HAVE_NETDB_H@ - -# if __GNUC__ >= 3 +#if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ -# endif +#endif + +#if @HAVE_NETDB_H@ /* The include_next requires a split double-inclusion guard. */ # @INCLUDE_NEXT@ @NEXT_NETDB_H@ @@ -41,6 +41,8 @@ /* The definition of _GL_ARG_NONNULL is copied here. */ +/* The definition of _GL_WARN_ON_USE is copied here. */ + /* Declarations for a platform that lacks , or where it is incomplete. */ @@ -171,10 +173,10 @@ extern const char *gai_strerror (int ecode); /* Convert socket address to printable node and service names. For more details, see the POSIX:2001 specification . */ -extern int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen, - char *restrict node, socklen_t nodelen, - char *restrict service, socklen_t servicelen, - int flags) +extern int getnameinfo (const struct sockaddr *restrict sa, socklen_t salen, + char *restrict node, socklen_t nodelen, + char *restrict service, socklen_t servicelen, + int flags) _GL_ARG_NONNULL ((1)); # endif @@ -186,7 +188,33 @@ extern int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen, # define NI_NUMERICSERV 2 # endif -#endif /* @GNULIB_GETADDRINFO@ */ +#elif defined GNULIB_POSIXCHECK + +# undef getaddrinfo +# if HAVE_RAW_DECL_GETADDRINFO +_GL_WARN_ON_USE (getaddrinfo, "getaddrinfo is unportable - " + "use gnulib module getaddrinfo for portability"); +# endif + +# undef freeaddrinfo +# if HAVE_RAW_DECL_FREEADDRINFO +_GL_WARN_ON_USE (freeaddrinfo, "freeaddrinfo is unportable - " + "use gnulib module getaddrinfo for portability"); +# endif + +# undef gai_strerror +# if HAVE_RAW_DECL_GAI_STRERROR +_GL_WARN_ON_USE (gai_strerror, "gai_strerror is unportable - " + "use gnulib module getaddrinfo for portability"); +# endif + +# undef getnameinfo +# if HAVE_RAW_DECL_GETNAMEINFO +_GL_WARN_ON_USE (getnameinfo, "getnameinfo is unportable - " + "use gnulib module getaddrinfo for portability"); +# endif + +#endif #endif /* _GL_NETDB_H */ #endif /* _GL_NETDB_H */ diff --git a/lib/netinet_in.in.h b/lib/netinet_in.in.h index 8a86bcae3..bd0b6d98b 100644 --- a/lib/netinet_in.in.h +++ b/lib/netinet_in.in.h @@ -17,11 +17,11 @@ #ifndef _GL_NETINET_IN_H -#if @HAVE_NETINET_IN_H@ - -# if __GNUC__ >= 3 +#if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ -# endif +#endif + +#if @HAVE_NETINET_IN_H@ /* On many platforms, assumes prior inclusion of . */ diff --git a/lib/stdbool.in.h b/lib/stdbool.in.h index 7b681f688..f2510a9e0 100644 --- a/lib/stdbool.in.h +++ b/lib/stdbool.in.h @@ -50,6 +50,9 @@ with this substitute. With this substitute, only the values 0 and 1 give the expected result when converted to _Bool' or 'bool'. + - C99 allows the use of (_Bool)0.0 in constant expressions, but + this substitute cannot always provide this property. + Also, it is suggested that programs use 'bool' rather than '_Bool'; this isn't required, but 'bool' is more common. */ diff --git a/lib/stdint.in.h b/lib/stdint.in.h index a1162d40c..997e40634 100644 --- a/lib/stdint.in.h +++ b/lib/stdint.in.h @@ -23,6 +23,10 @@ #ifndef _GL_STDINT_H +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif + /* When including a system file that in turn includes , use the system , not our substitute. This avoids problems with (for example) VMS, whose includes @@ -49,9 +53,6 @@ in would reinclude us, skipping our contents because _GL_STDINT_H is defined. The include_next requires a split double-inclusion guard. */ -# if __GNUC__ >= 3 -@PRAGMA_SYSTEM_HEADER@ -# endif # @INCLUDE_NEXT@ @NEXT_STDINT_H@ #endif diff --git a/lib/stdio-write.c b/lib/stdio-write.c index 61bba9229..21d07b996 100644 --- a/lib/stdio-write.c +++ b/lib/stdio-write.c @@ -63,7 +63,6 @@ } # if !REPLACE_PRINTF_POSIX /* avoid collision with printf.c */ -# if !DEPENDS_ON_LIBINTL /* avoid collision with intl/printf.c */ int printf (const char *format, ...) { @@ -76,7 +75,6 @@ printf (const char *format, ...) return retval; } -# endif # endif # if !REPLACE_FPRINTF_POSIX /* avoid collision with fprintf.c */ diff --git a/lib/stdio.in.h b/lib/stdio.in.h index 27c554b64..ca61fd684 100644 --- a/lib/stdio.in.h +++ b/lib/stdio.in.h @@ -63,6 +63,10 @@ /* The definition of _GL_WARN_ON_USE is copied here. */ +/* Macros for stringification. */ +#define _GL_STDIO_STRINGIZE(token) #token +#define _GL_STDIO_MACROEXPAND_AND_STRINGIZE(token) _GL_STDIO_STRINGIZE(token) + #if @GNULIB_DPRINTF@ # if @REPLACE_DPRINTF@ @@ -322,30 +326,39 @@ _GL_CXXALIASWARN (fseek); # undef fseek # endif # if @REPLACE_FSEEKO@ -/* Provide fseek, fseeko functions that are aware of a preceding - fflush(), and which detect pipes. */ +/* Provide an fseeko function that is aware of a preceding fflush(), and which + detects pipes. */ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # undef fseeko # define fseeko rpl_fseeko # endif _GL_FUNCDECL_RPL (fseeko, int, (FILE *fp, off_t offset, int whence) _GL_ARG_NONNULL ((1))); -# if !@GNULIB_FSEEK@ - /* In order to avoid that fseek gets defined as a macro here, the - developer can request the 'fseek' module. */ -# undef fseek -# define fseek rpl_fseek +_GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence)); +# else +# if ! @HAVE_FSEEKO@ +_GL_FUNCDECL_SYS (fseeko, int, (FILE *fp, off_t offset, int whence) + _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence)); +# endif +_GL_CXXALIASWARN (fseeko); +# if (@REPLACE_FSEEKO@ || !@HAVE_FSEEKO@) && !@GNULIB_FSEEK@ + /* Provide an fseek function that is consistent with fseeko. */ + /* In order to avoid that fseek gets defined as a macro here, the + developer can request the 'fseek' module. */ +# undef fseek +# define fseek rpl_fseek static inline int _GL_ARG_NONNULL ((1)) rpl_fseek (FILE *fp, long offset, int whence) { +# if @REPLACE_FSEEKO@ + return rpl_fseeko (fp, offset, whence); +# else return fseeko (fp, offset, whence); -} # endif -_GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence)); -# else -_GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence)); +} # endif -_GL_CXXALIASWARN (fseeko); #elif defined GNULIB_POSIXCHECK # define _GL_FSEEK_WARN /* Category 1, above. */ # undef fseek @@ -397,22 +410,30 @@ _GL_CXXALIASWARN (ftell); # define ftello rpl_ftello # endif _GL_FUNCDECL_RPL (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1))); -# if !@GNULIB_FTELL@ - /* In order to avoid that ftell gets defined as a macro here, the - developer can request the 'ftell' module. */ -# undef ftell -# define ftell rpl_ftell +_GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp)); +# else +# if ! @HAVE_FTELLO@ +_GL_FUNCDECL_SYS (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp)); +# endif +_GL_CXXALIASWARN (ftello); +# if (@REPLACE_FTELLO@ || !@HAVE_FTELLO@) && !@GNULIB_FTELL@ + /* Provide an ftell function that is consistent with ftello. */ + /* In order to avoid that ftell gets defined as a macro here, the + developer can request the 'ftell' module. */ +# undef ftell +# define ftell rpl_ftell static inline long _GL_ARG_NONNULL ((1)) rpl_ftell (FILE *f) { +# if @REPLACE_FTELLO@ + return rpl_ftello (f); +# else return ftello (f); -} # endif -_GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp)); -# else -_GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp)); +} # endif -_GL_CXXALIASWARN (ftello); #elif defined GNULIB_POSIXCHECK # define _GL_FTELL_WARN /* Category 1, above. */ # undef ftell @@ -516,7 +537,9 @@ _GL_FUNCDECL_SYS (getline, ssize_t, _GL_CXXALIAS_SYS (getline, ssize_t, (char **lineptr, size_t *linesize, FILE *stream)); # endif +# if @HAVE_DECL_GETLINE@ _GL_CXXALIASWARN (getline); +# endif #elif defined GNULIB_POSIXCHECK # undef getline # if HAVE_RAW_DECL_GETLINE @@ -621,16 +644,26 @@ _GL_WARN_ON_USE (popen, "popen is buggy on some platforms - " #if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@ # if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \ || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@) -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# if defined __GNUC__ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) /* Don't break __attribute__((format(printf,M,N))). */ -# define printf __printf__ -# endif -# define GNULIB_overrides_printf 1 +# define printf __printf__ +# endif _GL_FUNCDECL_RPL_1 (__printf__, int, (const char *format, ...) + __asm__ (@ASM_SYMBOL_PREFIX@ + _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)) __attribute__ ((__format__ (__printf__, 1, 2))) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...)); +# else +_GL_FUNCDECL_RPL (printf, int, + (const char *format, ...) + __attribute__ ((__format__ (__printf__, 1, 2))) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (printf, printf, int, (const char *format, ...)); +# endif +# define GNULIB_overrides_printf 1 # else _GL_CXXALIAS_SYS (printf, int, (const char *format, ...)); # endif @@ -819,6 +852,25 @@ _GL_WARN_ON_USE (sprintf, "sprintf is not always POSIX compliant - " "POSIX compliance"); #endif +#if @GNULIB_TMPFILE@ +# if @REPLACE_TMPFILE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define tmpfile rpl_tmpfile +# endif +_GL_FUNCDECL_RPL (tmpfile, FILE *, (void)); +_GL_CXXALIAS_RPL (tmpfile, FILE *, (void)); +# else +_GL_CXXALIAS_SYS (tmpfile, FILE *, (void)); +# endif +_GL_CXXALIASWARN (tmpfile); +#elif defined GNULIB_POSIXCHECK +# undef tmpfile +# if HAVE_RAW_DECL_TMPFILE +_GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - " + "use gnulib module tmpfile for portability"); +# endif +#endif + #if @GNULIB_VASPRINTF@ /* Write formatted output to a string dynamically allocated with malloc(). If the memory allocation succeeds, store the address of the string in @@ -883,7 +935,10 @@ _GL_FUNCDECL_SYS (vdprintf, int, (int fd, const char *format, va_list args) __attribute__ ((__format__ (__printf__, 2, 0))) _GL_ARG_NONNULL ((2))); # endif -_GL_CXXALIAS_SYS (vdprintf, int, (int fd, const char *format, va_list args)); +/* Need to cast, because on Solaris, the third parameter will likely be + __va_list args. */ +_GL_CXXALIAS_SYS_CAST (vdprintf, int, + (int fd, const char *format, va_list args)); # endif _GL_CXXALIASWARN (vdprintf); #elif defined GNULIB_POSIXCHECK @@ -906,7 +961,11 @@ _GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args) _GL_ARG_NONNULL ((1, 2))); _GL_CXXALIAS_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args)); # else -_GL_CXXALIAS_SYS (vfprintf, int, (FILE *fp, const char *format, va_list args)); +/* Need to cast, because on Solaris, the third parameter is + __va_list args + and GCC's fixincludes did not change this to __gnuc_va_list. */ +_GL_CXXALIAS_SYS_CAST (vfprintf, int, + (FILE *fp, const char *format, va_list args)); # endif _GL_CXXALIASWARN (vfprintf); #endif @@ -932,7 +991,10 @@ _GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (vprintf, int, (const char *format, va_list args)); # else -_GL_CXXALIAS_SYS (vprintf, int, (const char *format, va_list args)); +/* Need to cast, because on Solaris, the second parameter is + __va_list args + and GCC's fixincludes did not change this to __gnuc_va_list. */ +_GL_CXXALIAS_SYS_CAST (vprintf, int, (const char *format, va_list args)); # endif _GL_CXXALIASWARN (vprintf); #endif @@ -988,8 +1050,11 @@ _GL_FUNCDECL_RPL (vsprintf, int, _GL_CXXALIAS_RPL (vsprintf, int, (char *str, const char *format, va_list args)); # else -_GL_CXXALIAS_SYS (vsprintf, int, - (char *str, const char *format, va_list args)); +/* Need to cast, because on Solaris, the third parameter is + __va_list args + and GCC's fixincludes did not change this to __gnuc_va_list. */ +_GL_CXXALIAS_SYS_CAST (vsprintf, int, + (char *str, const char *format, va_list args)); # endif _GL_CXXALIASWARN (vsprintf); #elif defined GNULIB_POSIXCHECK diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h index 00415e0b9..3839ff341 100644 --- a/lib/stdlib.in.h +++ b/lib/stdlib.in.h @@ -67,10 +67,10 @@ struct random_data }; #endif -#if (@GNULIB_MKSTEMP@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ +#if (@GNULIB_MKSTEMP@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) /* On MacOS X 10.3, only declares mkstemp. */ /* On Cygwin 1.7.1, only declares getsubopt. */ -/* But avoid namespace pollution on glibc systems. */ +/* But avoid namespace pollution on glibc systems and native Windows. */ # include #endif @@ -201,6 +201,22 @@ _GL_WARN_ON_USE (getsubopt, "getsubopt is unportable - " # endif #endif +#if @GNULIB_GRANTPT@ +/* Change the ownership and access permission of the slave side of the + pseudo-terminal whose master side is specified by FD. */ +# if !@HAVE_GRANTPT@ +_GL_FUNCDECL_SYS (grantpt, int, (int fd)); +# endif +_GL_CXXALIAS_SYS (grantpt, int, (int fd)); +_GL_CXXALIASWARN (grantpt); +#elif defined GNULIB_POSIXCHECK +# undef grantpt +# if HAVE_RAW_DECL_GRANTPT +_GL_WARN_ON_USE (ptsname, "grantpt is not portable - " + "use gnulib module grantpt for portability"); +# endif +#endif + #if @GNULIB_MALLOC_POSIX@ # if !@HAVE_MALLOC_POSIX@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) @@ -313,6 +329,9 @@ _GL_WARN_ON_USE (mkostemps, "mkostemps is unportable - " _GL_FUNCDECL_RPL (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (mkstemp, int, (char * /*template*/)); # else +# if ! @HAVE_MKSTEMP@ +_GL_FUNCDECL_SYS (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1))); +# endif _GL_CXXALIAS_SYS (mkstemp, int, (char * /*template*/)); # endif _GL_CXXALIASWARN (mkstemp); @@ -349,6 +368,22 @@ _GL_WARN_ON_USE (mkstemps, "mkstemps is unportable - " # endif #endif +#if @GNULIB_PTSNAME@ +/* Return the pathname of the pseudo-terminal slave associated with + the master FD is open on, or NULL on errors. */ +# if !@HAVE_PTSNAME@ +_GL_FUNCDECL_SYS (ptsname, char *, (int fd)); +# endif +_GL_CXXALIAS_SYS (ptsname, char *, (int fd)); +_GL_CXXALIASWARN (ptsname); +#elif defined GNULIB_POSIXCHECK +# undef ptsname +# if HAVE_RAW_DECL_PTSNAME +_GL_WARN_ON_USE (ptsname, "ptsname is not portable - " + "use gnulib module ptsname for portability"); +# endif +#endif + #if @GNULIB_PUTENV@ # if @REPLACE_PUTENV@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) @@ -606,6 +641,22 @@ _GL_WARN_ON_USE (strtoull, "strtoull is unportable - " # endif #endif +#if @GNULIB_UNLOCKPT@ +/* Unlock the slave side of the pseudo-terminal whose master side is specified + by FD, so that it can be opened. */ +# if !@HAVE_UNLOCKPT@ +_GL_FUNCDECL_SYS (unlockpt, int, (int fd)); +# endif +_GL_CXXALIAS_SYS (unlockpt, int, (int fd)); +_GL_CXXALIASWARN (unlockpt); +#elif defined GNULIB_POSIXCHECK +# undef unlockpt +# if HAVE_RAW_DECL_UNLOCKPT +_GL_WARN_ON_USE (ptsname, "unlockpt is not portable - " + "use gnulib module unlockpt for portability"); +# endif +#endif + #if @GNULIB_UNSETENV@ /* Remove the variable NAME from the environment. */ # if @REPLACE_UNSETENV@ diff --git a/lib/string.in.h b/lib/string.in.h index ee1a03d89..75deca015 100644 --- a/lib/string.in.h +++ b/lib/string.in.h @@ -66,6 +66,11 @@ _GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n)); # else +# if ! @HAVE_MEMCHR@ +_GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n) + __attribute__ ((__pure__)) + _GL_ARG_NONNULL ((1))); +# endif /* On some systems, this function is defined as an overloaded function: extern "C" { const void * std::memchr (const void *, int, size_t); } extern "C++" { void * std::memchr (void *, int, size_t); } */ @@ -222,7 +227,7 @@ _GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - " /* Copy no more than N bytes of SRC to DST, returning a pointer past the last non-NUL byte written into DST. */ #if @GNULIB_STPNCPY@ -# if ! @HAVE_STPNCPY@ +# if @REPLACE_STPNCPY@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define stpncpy rpl_stpncpy # endif @@ -234,6 +239,12 @@ _GL_CXXALIAS_RPL (stpncpy, char *, (char *restrict __dst, char const *restrict __src, size_t __n)); # else +# if ! @HAVE_STPNCPY@ +_GL_FUNCDECL_SYS (stpncpy, char *, + (char *restrict __dst, char const *restrict __src, + size_t __n) + _GL_ARG_NONNULL ((1, 2))); +# endif _GL_CXXALIAS_SYS (stpncpy, char *, (char *restrict __dst, char const *restrict __src, size_t __n)); @@ -309,6 +320,28 @@ _GL_WARN_ON_USE (strdup, "strdup is unportable - " # endif #endif +/* Append no more than N characters from SRC onto DEST. */ +#if @GNULIB_STRNCAT@ +# if @REPLACE_STRNCAT@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef strncat +# define strncat rpl_strncat +# endif +_GL_FUNCDECL_RPL (strncat, char *, (char *dest, const char *src, size_t n) + _GL_ARG_NONNULL ((1, 2))); +_GL_CXXALIAS_RPL (strncat, char *, (char *dest, const char *src, size_t n)); +# else +_GL_CXXALIAS_SYS (strncat, char *, (char *dest, const char *src, size_t n)); +# endif +_GL_CXXALIASWARN (strncat); +#elif defined GNULIB_POSIXCHECK +# undef strncat +# if HAVE_RAW_DECL_STRNCAT +_GL_WARN_ON_USE (strncat, "strncat is unportable - " + "use gnulib module strncat for portability"); +# endif +#endif + /* Return a newly allocated copy of at most N bytes of STRING. */ #if @GNULIB_STRNDUP@ # if @REPLACE_STRNDUP@ @@ -339,12 +372,23 @@ _GL_WARN_ON_USE (strndup, "strndup is unportable - " MAXLEN bytes. If no '\0' terminator is found in that many bytes, return MAXLEN. */ #if @GNULIB_STRNLEN@ -# if ! @HAVE_DECL_STRNLEN@ +# if @REPLACE_STRNLEN@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef strnlen +# define strnlen rpl_strnlen +# endif +_GL_FUNCDECL_RPL (strnlen, size_t, (char const *__string, size_t __maxlen) + __attribute__ ((__pure__)) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (strnlen, size_t, (char const *__string, size_t __maxlen)); +# else +# if ! @HAVE_DECL_STRNLEN@ _GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen) __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1))); -# endif +# endif _GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)); +# endif _GL_CXXALIASWARN (strnlen); #elif defined GNULIB_POSIXCHECK # undef strnlen diff --git a/lib/sys_file.in.h b/lib/sys_file.in.h index bdf664d5c..986885003 100644 --- a/lib/sys_file.in.h +++ b/lib/sys_file.in.h @@ -17,16 +17,17 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* Written by Richard W.M. Jones. */ + #ifndef _GL_SYS_FILE_H -# if __GNUC__ >= 3 +#if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ -# endif +#endif /* The include_next requires a split double-inclusion guard. */ -# if @HAVE_SYS_FILE_H@ -# @INCLUDE_NEXT@ @NEXT_SYS_FILE_H@ -# endif +#if @HAVE_SYS_FILE_H@ +# @INCLUDE_NEXT@ @NEXT_SYS_FILE_H@ +#endif #ifndef _GL_SYS_FILE_H #define _GL_SYS_FILE_H diff --git a/lib/sys_socket.in.h b/lib/sys_socket.in.h index f54d757c3..e62a8d061 100644 --- a/lib/sys_socket.in.h +++ b/lib/sys_socket.in.h @@ -23,6 +23,10 @@ It is intended to provide definitions and prototypes needed by an application. */ +#if __GNUC__ >= 3 +@PRAGMA_SYSTEM_HEADER@ +#endif + #if defined _GL_ALREADY_INCLUDING_SYS_SOCKET_H /* Special invocation convention: - On Cygwin 1.5.x we have a sequence of nested includes @@ -41,10 +45,6 @@ # define _GL_ALREADY_INCLUDING_SYS_SOCKET_H -# if __GNUC__ >= 3 -@PRAGMA_SYSTEM_HEADER@ -# endif - /* On many platforms, assumes prior inclusion of . */ # include @@ -183,13 +183,23 @@ rpl_fd_isset (SOCKET fd, fd_set * set) /* Wrap everything else to use libc file descriptors for sockets. */ #if @HAVE_WINSOCK2_H@ && !defined _GL_UNISTD_H -# undef close -# define close close_used_without_including_unistd_h +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef close +# define close close_used_without_including_unistd_h +# else + _GL_WARN_ON_USE (close, + "close() used without including "); +# endif #endif #if @HAVE_WINSOCK2_H@ && !defined _GL_UNISTD_H -# undef gethostname -# define gethostname gethostname_used_without_including_unistd_h +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef gethostname +# define gethostname gethostname_used_without_including_unistd_h +# else + _GL_WARN_ON_USE (gethostname, + "gethostname() used without including "); +# endif #endif #if @GNULIB_SOCKET@ @@ -571,8 +581,13 @@ _GL_WARN_ON_USE (shutdown, "shutdown is not always POSIX compliant - " #endif #if @HAVE_WINSOCK2_H@ -# undef select -# define select select_used_without_including_sys_select_h +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef select +# define select select_used_without_including_sys_select_h +# else + _GL_WARN_ON_USE (select, + "select() used without including "); +# endif #endif #if @GNULIB_ACCEPT4@ diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h index 571cfe4f5..69a307ddb 100644 --- a/lib/sys_stat.in.h +++ b/lib/sys_stat.in.h @@ -56,7 +56,8 @@ /* Before doing "#define mkdir rpl_mkdir" below, we need to include all headers that may declare mkdir(). */ #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ -# include +# include /* mingw32, mingw64 */ +# include /* mingw64 */ #endif #ifndef S_IFMT @@ -390,7 +391,10 @@ _GL_WARN_ON_USE (futimens, "futimens is not portable - " # if !(defined __cplusplus && defined GNULIB_NAMESPACE) # define lchmod chmod # endif -_GL_CXXALIAS_RPL_1 (lchmod, chmod, int, (const char *filename, mode_t mode)); +/* Need to cast, because on mingw, the second parameter of chmod is + int mode. */ +_GL_CXXALIAS_RPL_CAST_1 (lchmod, chmod, int, + (const char *filename, mode_t mode)); # else # if 0 /* assume already declared */ _GL_FUNCDECL_SYS (lchmod, int, (const char *filename, mode_t mode) @@ -398,7 +402,9 @@ _GL_FUNCDECL_SYS (lchmod, int, (const char *filename, mode_t mode) # endif _GL_CXXALIAS_SYS (lchmod, int, (const char *filename, mode_t mode)); # endif +# if @HAVE_LCHMOD@ _GL_CXXALIASWARN (lchmod); +# endif #elif defined GNULIB_POSIXCHECK # undef lchmod # if HAVE_RAW_DECL_LCHMOD @@ -427,7 +433,9 @@ _GL_CXXALIAS_RPL (lstat, int, (const char *name, struct stat *buf)); # else _GL_CXXALIAS_SYS (lstat, int, (const char *name, struct stat *buf)); # endif +# if @HAVE_LSTAT@ _GL_CXXALIASWARN (lstat); +# endif #elif defined GNULIB_POSIXCHECK # undef lstat # if HAVE_RAW_DECL_LSTAT @@ -448,7 +456,8 @@ _GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode)); #else /* mingw's _mkdir() function has 1 argument, but we pass 2 arguments. Additionally, it declares _mkdir (and depending on compile flags, an - alias mkdir), only in the nonstandard , which is included above. */ + alias mkdir), only in the nonstandard includes and , + which are included above. */ # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ static inline int diff --git a/lib/time.in.h b/lib/time.in.h index 958de82cf..eff1bf63d 100644 --- a/lib/time.in.h +++ b/lib/time.in.h @@ -38,7 +38,7 @@ # @INCLUDE_NEXT@ @NEXT_TIME_H@ /* NetBSD 5.0 mis-defines NULL. */ -#include +# include /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ @@ -46,10 +46,6 @@ /* The definition of _GL_WARN_ON_USE is copied here. */ -# ifdef __cplusplus -extern "C" { -# endif - /* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3). Or they define it with the wrong member names or define it in (e.g., FreeBSD circa 1997). */ @@ -57,6 +53,11 @@ extern "C" { # if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@ # include # else + +# ifdef __cplusplus +extern "C" { +# endif + # undef timespec # define timespec rpl_timespec struct timespec @@ -64,11 +65,12 @@ struct timespec time_t tv_sec; long int tv_nsec; }; -# endif -# endif -# ifdef __cplusplus +# ifdef __cplusplus } +# endif + +# endif # endif /* Sleep for at least RQTP seconds unless interrupted, If interrupted, @@ -85,6 +87,11 @@ _GL_FUNCDECL_RPL (nanosleep, int, _GL_CXXALIAS_RPL (nanosleep, int, (struct timespec const *__rqtp, struct timespec *__rmtp)); # else +# if ! @HAVE_NANOSLEEP@ +_GL_FUNCDECL_SYS (nanosleep, int, + (struct timespec const *__rqtp, struct timespec *__rmtp) + _GL_ARG_NONNULL ((1))); +# endif _GL_CXXALIAS_SYS (nanosleep, int, (struct timespec const *__rqtp, struct timespec *__rmtp)); # endif @@ -120,6 +127,11 @@ _GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer, _GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer, struct tm *restrict __result)); # else +# if ! @HAVE_LOCALTIME_R@ +_GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer, + struct tm *restrict __result) + _GL_ARG_NONNULL ((1, 2))); +# endif _GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer, struct tm *restrict __result)); # endif @@ -135,6 +147,11 @@ _GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer, _GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer, struct tm *restrict __result)); # else +# if ! @HAVE_LOCALTIME_R@ +_GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer, + struct tm *restrict __result) + _GL_ARG_NONNULL ((1, 2))); +# endif _GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer, struct tm *restrict __result)); # endif @@ -145,23 +162,15 @@ _GL_CXXALIASWARN (gmtime_r); the resulting broken-down time into TM. See . */ # if @GNULIB_STRPTIME@ -# if @REPLACE_STRPTIME@ -# if !(defined __cplusplus && defined GNULIB_NAMESPACE) -# undef strptime -# define strptime rpl_strptime -# endif -_GL_FUNCDECL_RPL (strptime, char *, (char const *restrict __buf, +# if ! @HAVE_STRPTIME@ +_GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf, char const *restrict __format, struct tm *restrict __tm) _GL_ARG_NONNULL ((1, 2, 3))); -_GL_CXXALIAS_RPL (strptime, char *, (char const *restrict __buf, - char const *restrict __format, - struct tm *restrict __tm)); -# else +# endif _GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf, char const *restrict __format, struct tm *restrict __tm)); -# endif _GL_CXXALIASWARN (strptime); # endif @@ -175,6 +184,9 @@ _GL_CXXALIASWARN (strptime); _GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm)); # else +# if ! @HAVE_TIMEGM@ +_GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1))); +# endif _GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm)); # endif _GL_CXXALIASWARN (timegm); @@ -183,15 +195,25 @@ _GL_CXXALIASWARN (timegm); /* Encourage applications to avoid unsafe functions that can overrun buffers when given outlandish struct tm values. Portable applications should use strftime (or even sprintf) instead. */ -# if GNULIB_PORTCHECK +# if defined GNULIB_POSIXCHECK # undef asctime -# define asctime eschew_asctime +_GL_WARN_ON_USE (asctime, "asctime can overrun buffers in some cases - " + "better use strftime (or even sprintf) instead"); +# endif +# if defined GNULIB_POSIXCHECK # undef asctime_r -# define asctime_r eschew_asctime_r +_GL_WARN_ON_USE (asctime, "asctime_r can overrun buffers in some cases - " + "better use strftime (or even sprintf) instead"); +# endif +# if defined GNULIB_POSIXCHECK # undef ctime -# define ctime eschew_ctime +_GL_WARN_ON_USE (asctime, "ctime can overrun buffers in some cases - " + "better use strftime (or even sprintf) instead"); +# endif +# if defined GNULIB_POSIXCHECK # undef ctime_r -# define ctime_r eschew_ctime_r +_GL_WARN_ON_USE (asctime, "ctime_r can overrun buffers in some cases - " + "better use strftime (or even sprintf) instead"); # endif #endif diff --git a/lib/time_r.c b/lib/time_r.c index a4f2b4d21..a3c29c676 100644 --- a/lib/time_r.c +++ b/lib/time_r.c @@ -1,6 +1,6 @@ /* Reentrant time functions like localtime_r. - Copyright (C) 2003, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2003, 2006-2007, 2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -22,8 +22,6 @@ #include -#include - static struct tm * copy_tm_result (struct tm *dest, struct tm const *src) { diff --git a/lib/unistd.in.h b/lib/unistd.in.h index 7609d5897..89d01539e 100644 --- a/lib/unistd.in.h +++ b/lib/unistd.in.h @@ -15,18 +15,42 @@ 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_UNISTD_H - #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ #endif +/* Special invocation convention: + - On mingw, several headers, including , include , + but we need to ensure that both the system and + are completely included before we replace gethostname. */ +#if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \ + && !defined _GL_WINSOCK2_H_WITNESS && defined _WINSOCK2_H +/* is being indirectly included for the first time from + ; avoid declaring any overrides. */ +# if @HAVE_UNISTD_H@ +# @INCLUDE_NEXT@ @NEXT_UNISTD_H@ +# else +# error unexpected; report this to bug-gnulib@gnu.org +# endif +# define _GL_WINSOCK2_H_WITNESS + +/* Normal invocation. */ +#elif !defined _GL_UNISTD_H + /* The include_next requires a split double-inclusion guard. */ #if @HAVE_UNISTD_H@ # @INCLUDE_NEXT@ @NEXT_UNISTD_H@ #endif -#ifndef _GL_UNISTD_H +/* Get all possible declarations of gethostname(). */ +#if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \ + && !defined _GL_INCLUDING_WINSOCK2_H +# define _GL_INCLUDING_WINSOCK2_H +# include +# undef _GL_INCLUDING_WINSOCK2_H +#endif + +#if !defined _GL_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H #define _GL_UNISTD_H /* NetBSD 5.0 mis-defines NULL. Also get size_t. */ @@ -62,7 +86,7 @@ #endif #if (@GNULIB_WRITE@ || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \ - || @GNULIB_PREAD@ || defined GNULIB_POSIXCHECK) + || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK) /* Get ssize_t. */ # include #endif @@ -73,53 +97,89 @@ # include #endif +/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ + +/* The definition of _GL_ARG_NONNULL is copied here. */ + +/* The definition of _GL_WARN_ON_USE is copied here. */ + + #if @GNULIB_GETHOSTNAME@ /* Get all possible declarations of gethostname(). */ # if @UNISTD_H_HAVE_WINSOCK2_H@ -# include # if !defined _GL_SYS_SOCKET_H -# undef socket -# define socket socket_used_without_including_sys_socket_h -# undef connect -# define connect connect_used_without_including_sys_socket_h -# undef accept -# define accept accept_used_without_including_sys_socket_h -# undef bind -# define bind bind_used_without_including_sys_socket_h -# undef getpeername -# define getpeername getpeername_used_without_including_sys_socket_h -# undef getsockname -# define getsockname getsockname_used_without_including_sys_socket_h -# undef getsockopt -# define getsockopt getsockopt_used_without_including_sys_socket_h -# undef listen -# define listen listen_used_without_including_sys_socket_h -# undef recv -# define recv recv_used_without_including_sys_socket_h -# undef send -# define send send_used_without_including_sys_socket_h -# undef recvfrom -# define recvfrom recvfrom_used_without_including_sys_socket_h -# undef sendto -# define sendto sendto_used_without_including_sys_socket_h -# undef setsockopt -# define setsockopt setsockopt_used_without_including_sys_socket_h -# undef shutdown -# define shutdown shutdown_used_without_including_sys_socket_h +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef socket +# define socket socket_used_without_including_sys_socket_h +# undef connect +# define connect connect_used_without_including_sys_socket_h +# undef accept +# define accept accept_used_without_including_sys_socket_h +# undef bind +# define bind bind_used_without_including_sys_socket_h +# undef getpeername +# define getpeername getpeername_used_without_including_sys_socket_h +# undef getsockname +# define getsockname getsockname_used_without_including_sys_socket_h +# undef getsockopt +# define getsockopt getsockopt_used_without_including_sys_socket_h +# undef listen +# define listen listen_used_without_including_sys_socket_h +# undef recv +# define recv recv_used_without_including_sys_socket_h +# undef send +# define send send_used_without_including_sys_socket_h +# undef recvfrom +# define recvfrom recvfrom_used_without_including_sys_socket_h +# undef sendto +# define sendto sendto_used_without_including_sys_socket_h +# undef setsockopt +# define setsockopt setsockopt_used_without_including_sys_socket_h +# undef shutdown +# define shutdown shutdown_used_without_including_sys_socket_h +# else + _GL_WARN_ON_USE (socket, + "socket() used without including "); + _GL_WARN_ON_USE (connect, + "connect() used without including "); + _GL_WARN_ON_USE (accept, + "accept() used without including "); + _GL_WARN_ON_USE (bind, + "bind() used without including "); + _GL_WARN_ON_USE (getpeername, + "getpeername() used without including "); + _GL_WARN_ON_USE (getsockname, + "getsockname() used without including "); + _GL_WARN_ON_USE (getsockopt, + "getsockopt() used without including "); + _GL_WARN_ON_USE (listen, + "listen() used without including "); + _GL_WARN_ON_USE (recv, + "recv() used without including "); + _GL_WARN_ON_USE (send, + "send() used without including "); + _GL_WARN_ON_USE (recvfrom, + "recvfrom() used without including "); + _GL_WARN_ON_USE (sendto, + "sendto() used without including "); + _GL_WARN_ON_USE (setsockopt, + "setsockopt() used without including "); + _GL_WARN_ON_USE (shutdown, + "shutdown() used without including "); +# endif # endif # if !defined _GL_SYS_SELECT_H -# undef select -# define select select_used_without_including_sys_select_h +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef select +# define select select_used_without_including_sys_select_h +# else + _GL_WARN_ON_USE (select, + "select() used without including "); +# endif # endif # endif #endif -/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ - -/* The definition of _GL_ARG_NONNULL is copied here. */ - -/* The definition of _GL_WARN_ON_USE is copied here. */ - /* OS/2 EMX lacks these macros. */ #ifndef STDIN_FILENO @@ -355,9 +415,8 @@ _GL_WARN_ON_USE (faccessat, "faccessat is not portable - " Return 0 if successful, otherwise -1 and errno set. See the POSIX:2001 specification . */ -# if @REPLACE_FCHDIR@ -_GL_FUNCDECL_RPL (fchdir, int, (int /*fd*/)); -_GL_CXXALIAS_RPL (fchdir, int, (int /*fd*/)); +# if ! @HAVE_FCHDIR@ +_GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/)); /* Gnulib internal hooks needed to maintain the fchdir metadata. */ _GL_EXTERN_C int _gl_register_fd (int fd, const char *filename) @@ -366,9 +425,8 @@ _GL_EXTERN_C void _gl_unregister_fd (int fd); _GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd); _GL_EXTERN_C const char *_gl_directory_name (int fd); -# else -_GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/)); # endif +_GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/)); _GL_CXXALIASWARN (fchdir); #elif defined GNULIB_POSIXCHECK # undef fchdir @@ -465,7 +523,9 @@ _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - " _GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size)); _GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size)); # else -_GL_CXXALIAS_SYS (getcwd, char *, (char *buf, size_t size)); +/* Need to cast, because on mingw, the second parameter is + int size. */ +_GL_CXXALIAS_SYS_CAST (getcwd, char *, (char *buf, size_t size)); # endif _GL_CXXALIASWARN (getcwd); #elif defined GNULIB_POSIXCHECK @@ -713,7 +773,9 @@ getpagesize () /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */ _GL_CXXALIAS_SYS_CAST (getpagesize, int, (void)); # endif +# if @HAVE_DECL_GETPAGESIZE@ _GL_CXXALIASWARN (getpagesize); +# endif #elif defined GNULIB_POSIXCHECK # undef getpagesize # if HAVE_RAW_DECL_GETPAGESIZE @@ -726,7 +788,7 @@ _GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - " #if @GNULIB_GETUSERSHELL@ /* Return the next valid login shell on the system, or NULL when the end of the list has been reached. */ -# if !@HAVE_GETUSERSHELL@ +# if !@HAVE_DECL_GETUSERSHELL@ _GL_FUNCDECL_SYS (getusershell, char *, (void)); # endif _GL_CXXALIAS_SYS (getusershell, char *, (void)); @@ -741,7 +803,7 @@ _GL_WARN_ON_USE (getusershell, "getusershell is unportable - " #if @GNULIB_GETUSERSHELL@ /* Rewind to pointer that is advanced at each getusershell() call. */ -# if !@HAVE_GETUSERSHELL@ +# if !@HAVE_DECL_GETUSERSHELL@ _GL_FUNCDECL_SYS (setusershell, void, (void)); # endif _GL_CXXALIAS_SYS (setusershell, void, (void)); @@ -757,7 +819,7 @@ _GL_WARN_ON_USE (setusershell, "setusershell is unportable - " #if @GNULIB_GETUSERSHELL@ /* Free the pointer that is advanced at each getusershell() call and associated resources. */ -# if !@HAVE_GETUSERSHELL@ +# if !@HAVE_DECL_GETUSERSHELL@ _GL_FUNCDECL_SYS (endusershell, void, (void)); # endif _GL_CXXALIAS_SYS (endusershell, void, (void)); @@ -954,6 +1016,40 @@ _GL_WARN_ON_USE (pread, "pread is unportable - " #endif +#if @GNULIB_PWRITE@ +/* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET. + Return the number of bytes written if successful, otherwise + set errno and return -1. 0 indicates nothing written. See the + POSIX:2001 specification + . */ +# if @REPLACE_PWRITE@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# define pwrite rpl_pwrite +# endif +_GL_FUNCDECL_RPL (pwrite, ssize_t, + (int fd, const void *buf, size_t bufsize, off_t offset) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (pwrite, ssize_t, + (int fd, const void *buf, size_t bufsize, off_t offset)); +# else +# if !@HAVE_PWRITE@ +_GL_FUNCDECL_SYS (pwrite, ssize_t, + (int fd, const void *buf, size_t bufsize, off_t offset) + _GL_ARG_NONNULL ((2))); +# endif +_GL_CXXALIAS_SYS (pwrite, ssize_t, + (int fd, const void *buf, size_t bufsize, off_t offset)); +# endif +_GL_CXXALIASWARN (pwrite); +#elif defined GNULIB_POSIXCHECK +# undef pwrite +# if HAVE_RAW_DECL_PWRITE +_GL_WARN_ON_USE (pwrite, "pwrite is unportable - " + "use gnulib module pwrite for portability"); +# endif +#endif + + #if @GNULIB_READLINK@ /* 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 @@ -1099,6 +1195,36 @@ _GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - " #endif +#if @GNULIB_TTYNAME_R@ +/* Store at most BUFLEN characters of the pathname of the terminal FD is + open on in BUF. Return 0 on success, otherwise an error number. */ +# if @REPLACE_TTYNAME_R@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef ttyname_r +# define ttyname_r rpl_ttyname_r +# endif +_GL_FUNCDECL_RPL (ttyname_r, int, + (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (ttyname_r, int, + (int fd, char *buf, size_t buflen)); +# else +# if !@HAVE_TTYNAME_R@ +_GL_FUNCDECL_SYS (ttyname_r, int, + (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2))); +# endif +_GL_CXXALIAS_SYS (ttyname_r, int, + (int fd, char *buf, size_t buflen)); +# endif +_GL_CXXALIASWARN (ttyname_r); +#elif defined GNULIB_POSIXCHECK +# undef ttyname_r +# if HAVE_RAW_DECL_TTYNAME_R +_GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - " + "use gnulib module ttyname_r for portability"); +# endif +#endif + + #if @GNULIB_UNLINK@ # if @REPLACE_UNLINK@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) @@ -1187,7 +1313,10 @@ _GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count) _GL_ARG_NONNULL ((2))); _GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count)); # else -_GL_CXXALIAS_SYS (write, ssize_t, (int fd, const void *buf, size_t count)); +/* Need to cast, because on mingw, the third parameter is + unsigned int count + and the return type is 'int'. */ +_GL_CXXALIAS_SYS_CAST (write, ssize_t, (int fd, const void *buf, size_t count)); # endif _GL_CXXALIASWARN (write); #endif diff --git a/lib/unistr.h b/lib/unistr.in.h similarity index 100% rename from lib/unistr.h rename to lib/unistr.in.h diff --git a/lib/unitypes.h b/lib/unitypes.in.h similarity index 100% rename from lib/unitypes.h rename to lib/unitypes.in.h diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c index 3d7955b38..d45cbdd1e 100644 --- a/lib/vasnprintf.c +++ b/lib/vasnprintf.c @@ -148,8 +148,14 @@ # define USE_SNPRINTF 1 # if HAVE_DECL__SNWPRINTF /* On Windows, the function swprintf() has a different signature than - on Unix; we use the _snwprintf() function instead. */ -# define SNPRINTF _snwprintf + on Unix; we use the function _snwprintf() or - on mingw - snwprintf() + instead. The mingw function snwprintf() has fewer bugs than the + MSVCRT function _snwprintf(), so prefer that. */ +# if defined __MINGW32__ +# define SNPRINTF snwprintf +# else +# define SNPRINTF _snwprintf +# endif # else /* Unix. */ # define SNPRINTF swprintf @@ -167,8 +173,15 @@ # define USE_SNPRINTF 0 # endif # if HAVE_DECL__SNPRINTF - /* Windows. */ -# define SNPRINTF _snprintf + /* Windows. The mingw function snprintf() has fewer bugs than the MSVCRT + function _snprintf(), so prefer that. */ +# if defined __MINGW32__ +# define SNPRINTF snprintf + /* Here we need to call the native snprintf, not rpl_snprintf. */ +# undef snprintf +# else +# define SNPRINTF _snprintf +# endif # else /* Unix. */ # define SNPRINTF snprintf @@ -194,7 +207,7 @@ #undef remainder #define remainder rem -#if !USE_SNPRINTF && !WIDE_CHAR_VERSION +#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99) && !WIDE_CHAR_VERSION # if (HAVE_STRNLEN && !defined _AIX) # define local_strnlen strnlen # else @@ -210,7 +223,7 @@ local_strnlen (const char *string, size_t maxlen) # endif #endif -#if (!USE_SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && HAVE_WCHAR_T && (WIDE_CHAR_VERSION || DCHAR_IS_TCHAR) +#if (((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99) && WIDE_CHAR_VERSION) || ((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && !WIDE_CHAR_VERSION && DCHAR_IS_TCHAR)) && HAVE_WCHAR_T # if HAVE_WCSLEN # define local_wcslen wcslen # else @@ -233,7 +246,7 @@ local_wcslen (const wchar_t *s) # endif #endif -#if !USE_SNPRINTF && HAVE_WCHAR_T && WIDE_CHAR_VERSION +#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99) && HAVE_WCHAR_T && WIDE_CHAR_VERSION # if HAVE_WCSNLEN # define local_wcsnlen wcsnlen # else @@ -1474,6 +1487,258 @@ is_borderline (const char *digits, size_t precision) #endif +#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 + +/* Use a different function name, to make it possible that the 'wchar_t' + parametrization and the 'char' parametrization get compiled in the same + translation unit. */ +# if WIDE_CHAR_VERSION +# define MAX_ROOM_NEEDED wmax_room_needed +# else +# define MAX_ROOM_NEEDED max_room_needed +# endif + +/* Returns the number of TCHAR_T units needed as temporary space for the result + of sprintf or SNPRINTF of a single conversion directive. */ +static inline size_t +MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion, + arg_type type, int flags, size_t width, int has_precision, + size_t precision, int pad_ourselves) +{ + size_t tmp_length; + + switch (conversion) + { + case 'd': case 'i': case 'u': +# if HAVE_LONG_LONG_INT + if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) + tmp_length = + (unsigned int) (sizeof (unsigned long long) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + else +# endif + if (type == TYPE_LONGINT || type == TYPE_ULONGINT) + tmp_length = + (unsigned int) (sizeof (unsigned long) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + else + tmp_length = + (unsigned int) (sizeof (unsigned int) * CHAR_BIT + * 0.30103 /* binary -> decimal */ + ) + + 1; /* turn floor into ceil */ + if (tmp_length < precision) + tmp_length = precision; + /* Multiply by 2, as an estimate for FLAG_GROUP. */ + tmp_length = xsum (tmp_length, tmp_length); + /* Add 1, to account for a leading sign. */ + tmp_length = xsum (tmp_length, 1); + break; + + case 'o': +# if HAVE_LONG_LONG_INT + if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) + tmp_length = + (unsigned int) (sizeof (unsigned long long) * CHAR_BIT + * 0.333334 /* binary -> octal */ + ) + + 1; /* turn floor into ceil */ + else +# endif + if (type == TYPE_LONGINT || type == TYPE_ULONGINT) + tmp_length = + (unsigned int) (sizeof (unsigned long) * CHAR_BIT + * 0.333334 /* binary -> octal */ + ) + + 1; /* turn floor into ceil */ + else + tmp_length = + (unsigned int) (sizeof (unsigned int) * CHAR_BIT + * 0.333334 /* binary -> octal */ + ) + + 1; /* turn floor into ceil */ + if (tmp_length < precision) + tmp_length = precision; + /* Add 1, to account for a leading sign. */ + tmp_length = xsum (tmp_length, 1); + break; + + case 'x': case 'X': +# if HAVE_LONG_LONG_INT + if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) + tmp_length = + (unsigned int) (sizeof (unsigned long long) * CHAR_BIT + * 0.25 /* binary -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + else +# endif + if (type == TYPE_LONGINT || type == TYPE_ULONGINT) + tmp_length = + (unsigned int) (sizeof (unsigned long) * CHAR_BIT + * 0.25 /* binary -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + else + tmp_length = + (unsigned int) (sizeof (unsigned int) * CHAR_BIT + * 0.25 /* binary -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + if (tmp_length < precision) + tmp_length = precision; + /* Add 2, to account for a leading sign or alternate form. */ + tmp_length = xsum (tmp_length, 2); + break; + + case 'f': case 'F': + if (type == TYPE_LONGDOUBLE) + tmp_length = + (unsigned int) (LDBL_MAX_EXP + * 0.30103 /* binary -> decimal */ + * 2 /* estimate for FLAG_GROUP */ + ) + + 1 /* turn floor into ceil */ + + 10; /* sign, decimal point etc. */ + else + tmp_length = + (unsigned int) (DBL_MAX_EXP + * 0.30103 /* binary -> decimal */ + * 2 /* estimate for FLAG_GROUP */ + ) + + 1 /* turn floor into ceil */ + + 10; /* sign, decimal point etc. */ + tmp_length = xsum (tmp_length, precision); + break; + + case 'e': case 'E': case 'g': case 'G': + tmp_length = + 12; /* sign, decimal point, exponent etc. */ + tmp_length = xsum (tmp_length, precision); + break; + + case 'a': case 'A': + if (type == TYPE_LONGDOUBLE) + tmp_length = + (unsigned int) (LDBL_DIG + * 0.831 /* decimal -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + else + tmp_length = + (unsigned int) (DBL_DIG + * 0.831 /* decimal -> hexadecimal */ + ) + + 1; /* turn floor into ceil */ + if (tmp_length < precision) + tmp_length = precision; + /* Account for sign, decimal point etc. */ + tmp_length = xsum (tmp_length, 12); + break; + + case 'c': +# if HAVE_WINT_T && !WIDE_CHAR_VERSION + if (type == TYPE_WIDE_CHAR) + tmp_length = MB_CUR_MAX; + else +# endif + tmp_length = 1; + break; + + case 's': +# if HAVE_WCHAR_T + if (type == TYPE_WIDE_STRING) + { +# if WIDE_CHAR_VERSION + /* ISO C says about %ls in fwprintf: + "If the precision is not specified or is greater than the size + of the array, the array shall contain a null wide character." + So if there is a precision, we must not use wcslen. */ + const wchar_t *arg = ap->arg[arg_index].a.a_wide_string; + + if (has_precision) + tmp_length = local_wcsnlen (arg, precision); + else + tmp_length = local_wcslen (arg); +# else + /* ISO C says about %ls in fprintf: + "If a precision is specified, no more than that many bytes are + written (including shift sequences, if any), and the array + shall contain a null wide character if, to equal the multibyte + character sequence length given by the precision, the function + would need to access a wide character one past the end of the + array." + So if there is a precision, we must not use wcslen. */ + /* This case has already been handled separately in VASNPRINTF. */ + abort (); +# endif + } + else +# endif + { +# if WIDE_CHAR_VERSION + /* ISO C says about %s in fwprintf: + "If the precision is not specified or is greater than the size + of the converted array, the converted array shall contain a + null wide character." + So if there is a precision, we must not use strlen. */ + /* This case has already been handled separately in VASNPRINTF. */ + abort (); +# else + /* ISO C says about %s in fprintf: + "If the precision is not specified or greater than the size of + the array, the array shall contain a null character." + So if there is a precision, we must not use strlen. */ + const char *arg = ap->arg[arg_index].a.a_string; + + if (has_precision) + tmp_length = local_strnlen (arg, precision); + else + tmp_length = strlen (arg); +# endif + } + break; + + case 'p': + tmp_length = + (unsigned int) (sizeof (void *) * CHAR_BIT + * 0.25 /* binary -> hexadecimal */ + ) + + 1 /* turn floor into ceil */ + + 2; /* account for leading 0x */ + break; + + default: + abort (); + } + + if (!pad_ourselves) + { +# if ENABLE_UNISTDIO + /* Padding considers the number of characters, therefore the number of + elements after padding may be + > max (tmp_length, width) + but is certainly + <= tmp_length + width. */ + tmp_length = xsum (tmp_length, width); +# else + /* Padding considers the number of elements, says POSIX. */ + if (tmp_length < width) + tmp_length = width; +# endif + } + + tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */ + + return tmp_length; +} + +#endif + DCHAR_T * VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, const FCHAR_T *format, va_list args) @@ -2103,7 +2368,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, } } #endif -#if (!USE_SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && HAVE_WCHAR_T +#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && HAVE_WCHAR_T else if (dp->conversion == 's' # if WIDE_CHAR_VERSION && a.arg[dp->arg_index].type != TYPE_WIDE_STRING @@ -2592,8 +2857,16 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, count = wctomb (cbuf, *arg); # endif if (count <= 0) - /* Inconsistency. */ - abort (); + { + /* Cannot convert. */ + if (!(result == resultbuf || result == NULL)) + free (result); + if (buf_malloced != NULL) + free (buf_malloced); + CLEANUP (); + errno = EILSEQ; + return NULL; + } ENSURE_ALLOCATION (xsum (length, count)); memcpy (result + length, cbuf, count); length += count; @@ -2616,8 +2889,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, length += n; } } - } # endif + } #endif #if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL else if ((dp->conversion == 'a' || dp->conversion == 'A') @@ -4301,11 +4574,11 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, { arg_type type = a.arg[dp->arg_index].type; int flags = dp->flags; -#if !USE_SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION +#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION int has_width; size_t width; #endif -#if !USE_SNPRINTF || NEED_PRINTF_UNBOUNDED_PRECISION +#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || NEED_PRINTF_UNBOUNDED_PRECISION int has_precision; size_t precision; #endif @@ -4330,7 +4603,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, TCHAR_T *tmp; #endif -#if !USE_SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION +#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION has_width = 0; width = 0; if (dp->width_start != dp->width_end) @@ -4364,7 +4637,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, } #endif -#if !USE_SNPRINTF || NEED_PRINTF_UNBOUNDED_PRECISION +#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || NEED_PRINTF_UNBOUNDED_PRECISION has_precision = 0; precision = 6; if (dp->precision_start != dp->precision_end) @@ -4437,246 +4710,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, #if !USE_SNPRINTF /* Allocate a temporary buffer of sufficient size for calling sprintf. */ - { - switch (dp->conversion) - { - - case 'd': case 'i': case 'u': -# if HAVE_LONG_LONG_INT - if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) - tmp_length = - (unsigned int) (sizeof (unsigned long long) * CHAR_BIT - * 0.30103 /* binary -> decimal */ - ) - + 1; /* turn floor into ceil */ - else -# endif - if (type == TYPE_LONGINT || type == TYPE_ULONGINT) - tmp_length = - (unsigned int) (sizeof (unsigned long) * CHAR_BIT - * 0.30103 /* binary -> decimal */ - ) - + 1; /* turn floor into ceil */ - else - tmp_length = - (unsigned int) (sizeof (unsigned int) * CHAR_BIT - * 0.30103 /* binary -> decimal */ - ) - + 1; /* turn floor into ceil */ - if (tmp_length < precision) - tmp_length = precision; - /* Multiply by 2, as an estimate for FLAG_GROUP. */ - tmp_length = xsum (tmp_length, tmp_length); - /* Add 1, to account for a leading sign. */ - tmp_length = xsum (tmp_length, 1); - break; - - case 'o': -# if HAVE_LONG_LONG_INT - if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) - tmp_length = - (unsigned int) (sizeof (unsigned long long) * CHAR_BIT - * 0.333334 /* binary -> octal */ - ) - + 1; /* turn floor into ceil */ - else -# endif - if (type == TYPE_LONGINT || type == TYPE_ULONGINT) - tmp_length = - (unsigned int) (sizeof (unsigned long) * CHAR_BIT - * 0.333334 /* binary -> octal */ - ) - + 1; /* turn floor into ceil */ - else - tmp_length = - (unsigned int) (sizeof (unsigned int) * CHAR_BIT - * 0.333334 /* binary -> octal */ - ) - + 1; /* turn floor into ceil */ - if (tmp_length < precision) - tmp_length = precision; - /* Add 1, to account for a leading sign. */ - tmp_length = xsum (tmp_length, 1); - break; - - case 'x': case 'X': -# if HAVE_LONG_LONG_INT - if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) - tmp_length = - (unsigned int) (sizeof (unsigned long long) * CHAR_BIT - * 0.25 /* binary -> hexadecimal */ - ) - + 1; /* turn floor into ceil */ - else -# endif - if (type == TYPE_LONGINT || type == TYPE_ULONGINT) - tmp_length = - (unsigned int) (sizeof (unsigned long) * CHAR_BIT - * 0.25 /* binary -> hexadecimal */ - ) - + 1; /* turn floor into ceil */ - else - tmp_length = - (unsigned int) (sizeof (unsigned int) * CHAR_BIT - * 0.25 /* binary -> hexadecimal */ - ) - + 1; /* turn floor into ceil */ - if (tmp_length < precision) - tmp_length = precision; - /* Add 2, to account for a leading sign or alternate form. */ - tmp_length = xsum (tmp_length, 2); - break; - - case 'f': case 'F': - if (type == TYPE_LONGDOUBLE) - tmp_length = - (unsigned int) (LDBL_MAX_EXP - * 0.30103 /* binary -> decimal */ - * 2 /* estimate for FLAG_GROUP */ - ) - + 1 /* turn floor into ceil */ - + 10; /* sign, decimal point etc. */ - else - tmp_length = - (unsigned int) (DBL_MAX_EXP - * 0.30103 /* binary -> decimal */ - * 2 /* estimate for FLAG_GROUP */ - ) - + 1 /* turn floor into ceil */ - + 10; /* sign, decimal point etc. */ - tmp_length = xsum (tmp_length, precision); - break; - - case 'e': case 'E': case 'g': case 'G': - tmp_length = - 12; /* sign, decimal point, exponent etc. */ - tmp_length = xsum (tmp_length, precision); - break; - - case 'a': case 'A': - if (type == TYPE_LONGDOUBLE) - tmp_length = - (unsigned int) (LDBL_DIG - * 0.831 /* decimal -> hexadecimal */ - ) - + 1; /* turn floor into ceil */ - else - tmp_length = - (unsigned int) (DBL_DIG - * 0.831 /* decimal -> hexadecimal */ - ) - + 1; /* turn floor into ceil */ - if (tmp_length < precision) - tmp_length = precision; - /* Account for sign, decimal point etc. */ - tmp_length = xsum (tmp_length, 12); - break; - - case 'c': -# if HAVE_WINT_T && !WIDE_CHAR_VERSION - if (type == TYPE_WIDE_CHAR) - tmp_length = MB_CUR_MAX; - else -# endif - tmp_length = 1; - break; - - case 's': -# if HAVE_WCHAR_T - if (type == TYPE_WIDE_STRING) - { -# if WIDE_CHAR_VERSION - /* ISO C says about %ls in fwprintf: - "If the precision is not specified or is greater - than the size of the array, the array shall - contain a null wide character." - So if there is a precision, we must not use - wcslen. */ - const wchar_t *arg = - a.arg[dp->arg_index].a.a_wide_string; - - if (has_precision) - tmp_length = local_wcsnlen (arg, precision); - else - tmp_length = local_wcslen (arg); -# else - /* ISO C says about %ls in fprintf: - "If a precision is specified, no more than that - many bytes are written (including shift - sequences, if any), and the array shall contain - a null wide character if, to equal the - multibyte character sequence length given by - the precision, the function would need to - access a wide character one past the end of the - array." - So if there is a precision, we must not use - wcslen. */ - /* This case has already been handled above. */ - abort (); -# endif - } - else -# endif - { -# if WIDE_CHAR_VERSION - /* ISO C says about %s in fwprintf: - "If the precision is not specified or is greater - than the size of the converted array, the - converted array shall contain a null wide - character." - So if there is a precision, we must not use - strlen. */ - /* This case has already been handled above. */ - abort (); -# else - /* ISO C says about %s in fprintf: - "If the precision is not specified or greater - than the size of the array, the array shall - contain a null character." - So if there is a precision, we must not use - strlen. */ - const char *arg = a.arg[dp->arg_index].a.a_string; - - if (has_precision) - tmp_length = local_strnlen (arg, precision); - else - tmp_length = strlen (arg); -# endif - } - break; - - case 'p': - tmp_length = - (unsigned int) (sizeof (void *) * CHAR_BIT - * 0.25 /* binary -> hexadecimal */ - ) - + 1 /* turn floor into ceil */ - + 2; /* account for leading 0x */ - break; - - default: - abort (); - } - - if (!pad_ourselves) - { -# if ENABLE_UNISTDIO - /* Padding considers the number of characters, therefore - the number of elements after padding may be - > max (tmp_length, width) - but is certainly - <= tmp_length + width. */ - tmp_length = xsum (tmp_length, width); -# else - /* Padding considers the number of elements, - says POSIX. */ - if (tmp_length < width) - tmp_length = width; -# endif - } - - tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */ - } + tmp_length = + MAX_ROOM_NEEDED (&a, dp->arg_index, dp->conversion, type, + flags, width, has_precision, precision, + pad_ourselves); if (tmp_length <= sizeof (tmpbuf) / sizeof (TCHAR_T)) tmp = tmpbuf; @@ -4916,6 +4953,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, } #endif + errno = 0; switch (type) { case TYPE_SCHAR: @@ -5062,15 +5100,44 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, /* Look at the snprintf() return value. */ if (retcount < 0) { +# if !HAVE_SNPRINTF_RETVAL_C99 /* HP-UX 10.20 snprintf() is doubly deficient: It doesn't understand the '%n' directive, *and* it returns -1 (rather than the length that would have been required) when the - buffer is too small. */ - size_t bigger_need = - xsum (xtimes (allocated, 2), 12); - ENSURE_ALLOCATION (bigger_need); - continue; + buffer is too small. + But a failure at this point can also come + from other reasons than a too small buffer, + such as an invalid wide string argument to + the %ls directive, or possibly an invalid + floating-point argument. */ + size_t tmp_length = + MAX_ROOM_NEEDED (&a, dp->arg_index, + dp->conversion, type, flags, + width, has_precision, + precision, pad_ourselves); + + if (maxlen < tmp_length) + { + /* Make more room. But try to do through + this reallocation only once. */ + size_t bigger_need = + xsum (length, + xsum (tmp_length, + TCHARS_PER_DCHAR - 1) + / TCHARS_PER_DCHAR); + /* And always grow proportionally. + (There may be several arguments, each + needing a little more room than the + previous one.) */ + size_t bigger_need2 = + xsum (xtimes (allocated, 2), 12); + if (bigger_need < bigger_need2) + bigger_need = bigger_need2; + ENSURE_ALLOCATION (bigger_need); + continue; + } +# endif } else count = retcount; @@ -5081,12 +5148,21 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, /* Attempt to handle failure. */ if (count < 0) { + /* SNPRINTF or sprintf failed. Save and use the errno + that it has set, if any. */ + int saved_errno = errno; + if (!(result == resultbuf || result == NULL)) free (result); if (buf_malloced != NULL) free (buf_malloced); CLEANUP (); - errno = EINVAL; + errno = + (saved_errno != 0 + ? saved_errno + : (dp->conversion == 'c' || dp->conversion == 's' + ? EILSEQ + : EINVAL)); return NULL; } @@ -5422,6 +5498,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, length += count; break; } +#undef pad_ourselves +#undef prec_ourselves } } } @@ -5473,6 +5551,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, } } +#undef MAX_ROOM_NEEDED #undef TCHARS_PER_DCHAR #undef SNPRINTF #undef USE_SNPRINTF diff --git a/lib/verify.h b/lib/verify.h index 7773c7943..9bd9cb812 100644 --- a/lib/verify.h +++ b/lib/verify.h @@ -69,13 +69,14 @@ if the entity names are not disambiguated. A workaround is to attach the current line number to the entity name: - #define GL_CONCAT0(x, y) x##y - #define GL_CONCAT(x, y) GL_CONCAT0 (x, y) - extern struct {...} * GL_CONCAT(dummy,__LINE__); + #define _GL_CONCAT0(x, y) x##y + #define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y) + extern struct {...} * _GL_CONCAT (dummy, __LINE__); But this has the problem that two invocations of verify from within the same macro would collide, since the __LINE__ value - would be the same for both invocations. + would be the same for both invocations. (The GCC __COUNTER__ + macro solves this problem, but is not portable.) A solution is to use the sizeof operator. It yields a number, getting rid of the identity of the type. Declarations like @@ -103,20 +104,41 @@ extern int (*dummy (void)) [sizeof (struct {...})]; + * GCC warns about duplicate declarations of the dummy function if + -Wredundant_decls is used. GCC 4.3 and later have a builtin + __COUNTER__ macro that can let us generate unique identifiers for + each dummy function, to suppress this warning. + * This implementation exploits the fact that GCC does not warn about the last declaration mentioned above. If a future version of GCC introduces a warning for this, the problem could be worked around - by using code specialized to GCC, e.g.,: + by using code specialized to GCC, just as __COUNTER__ is already + being used if available. #if 4 <= __GNUC__ - # define verify(R) \ - extern int (* verify_function__ (void)) \ - [__builtin_constant_p (R) && (R) ? 1 : -1] + # define verify(R) [another version to keep GCC happy] #endif * In C++, any struct definition inside sizeof is invalid. Use a template type to work around the problem. */ +/* Concatenate two preprocessor tokens. */ +# define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y) +# define _GL_CONCAT0(x, y) x##y + +/* _GL_COUNTER is an integer, preferably one that changes each time we + use it. Use __COUNTER__ if it works, falling back on __LINE__ + otherwise. __LINE__ isn't perfect, but it's better than a + constant. */ +# if defined __COUNTER__ && __COUNTER__ != __COUNTER__ +# define _GL_COUNTER __COUNTER__ +# else +# define _GL_COUNTER __LINE__ +# endif + +/* Generate a symbol with the given prefix, making it unique if + possible. */ +# define _GL_GENSYM(prefix) _GL_CONCAT (prefix, _GL_COUNTER) /* Verify requirement R at compile-time, as an integer constant expression. Return 1. */ @@ -135,6 +157,7 @@ template /* Verify requirement R at compile-time, as a declaration without a trailing ';'. */ -# define verify(R) extern int (* verify_function__ (void)) [verify_true (R)] +# define verify(R) \ + extern int (* _GL_GENSYM (verify_function) (void)) [verify_true (R)] #endif diff --git a/lib/wchar.in.h b/lib/wchar.in.h index 28bfa0670..3e3a0c39c 100644 --- a/lib/wchar.in.h +++ b/lib/wchar.in.h @@ -82,12 +82,16 @@ /* The definition of _GL_WARN_ON_USE is copied here. */ -/* Define wint_t. (Also done in wctype.in.h.) */ +/* Define wint_t and WEOF. (Also done in wctype.in.h.) */ #if !@HAVE_WINT_T@ && !defined wint_t # define wint_t int # ifndef WEOF # define WEOF -1 # endif +#else +# ifndef WEOF +# define WEOF ((wint_t) -1) +# endif #endif @@ -403,7 +407,7 @@ _GL_WARN_ON_USE (wcsnrtombs, "wcsnrtombs is unportable - " _GL_FUNCDECL_RPL (wcwidth, int, (wchar_t)); _GL_CXXALIAS_RPL (wcwidth, int, (wchar_t)); # else -# if !defined wcwidth && !@HAVE_DECL_WCWIDTH@ +# if !@HAVE_DECL_WCWIDTH@ /* wcwidth exists but is not declared. */ _GL_FUNCDECL_SYS (wcwidth, int, (wchar_t)); # endif diff --git a/m4/absolute-header.m4 b/m4/absolute-header.m4 new file mode 100644 index 000000000..f576d3427 --- /dev/null +++ b/m4/absolute-header.m4 @@ -0,0 +1,77 @@ +# absolute-header.m4 serial 12 +dnl Copyright (C) 2006-2010 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. + +dnl From Derek Price. + +# gl_ABSOLUTE_HEADER(HEADER1 HEADER2 ...) +# --------------------------------------- +# Find the absolute name of a header file, testing first if the header exists. +# If the header were sys/inttypes.h, this macro would define +# ABSOLUTE_SYS_INTTYPES_H to the `""' quoted absolute name of sys/inttypes.h +# in config.h +# (e.g. `#define ABSOLUTE_SYS_INTTYPES_H "///usr/include/sys/inttypes.h"'). +# The three "///" are to pacify Sun C 5.8, which otherwise would say +# "warning: #include of /usr/include/... may be non-portable". +# Use `""', not `<>', so that the /// cannot be confused with a C99 comment. +# Note: This macro assumes that the header file is not empty after +# preprocessing, i.e. it does not only define preprocessor macros but also +# provides some type/enum definitions or function/variable declarations. +AC_DEFUN([gl_ABSOLUTE_HEADER], +[AC_REQUIRE([AC_CANONICAL_HOST]) +AC_LANG_PREPROC_REQUIRE()dnl +m4_foreach_w([gl_HEADER_NAME], [$1], + [AS_VAR_PUSHDEF([gl_absolute_header], + [gl_cv_absolute_]m4_defn([gl_HEADER_NAME]))dnl + AC_CACHE_CHECK([absolute name of <]m4_defn([gl_HEADER_NAME])[>], + m4_defn([gl_absolute_header]), + [AS_VAR_PUSHDEF([ac_header_exists], + [ac_cv_header_]m4_defn([gl_HEADER_NAME]))dnl + AC_CHECK_HEADERS_ONCE(m4_defn([gl_HEADER_NAME]))dnl + if test AS_VAR_GET(ac_header_exists) = yes; then + gl_ABSOLUTE_HEADER_ONE(m4_defn([gl_HEADER_NAME])) + fi + AS_VAR_POPDEF([ac_header_exists])dnl + ])dnl + AC_DEFINE_UNQUOTED(AS_TR_CPP([ABSOLUTE_]m4_defn([gl_HEADER_NAME])), + ["AS_VAR_GET(gl_absolute_header)"], + [Define this to an absolute name of <]m4_defn([gl_HEADER_NAME])[>.]) + AS_VAR_POPDEF([gl_absolute_header])dnl +])dnl +])# gl_ABSOLUTE_HEADER + +# gl_ABSOLUTE_HEADER_ONE(HEADER) +# ------------------------------ +# Like gl_ABSOLUTE_HEADER, except that: +# - it assumes that the header exists, +# - it uses the current CPPFLAGS, +# - it does not cache the result, +# - it is silent. +AC_DEFUN([gl_ABSOLUTE_HEADER_ONE], +[ + AC_LANG_CONFTEST([AC_LANG_SOURCE([[#include <]]m4_dquote([$1])[[>]])]) + dnl AIX "xlc -E" and "cc -E" omit #line directives for header files + dnl that contain only a #include of other header files and no + dnl non-comment tokens of their own. This leads to a failure to + dnl detect the absolute name of , , + dnl and others. The workaround is to force preservation of comments + dnl through option -C. This ensures all necessary #line directives + dnl are present. GCC supports option -C as well. + case "$host_os" in + aix*) gl_absname_cpp="$ac_cpp -C" ;; + *) gl_absname_cpp="$ac_cpp" ;; + esac + dnl eval is necessary to expand gl_absname_cpp. + dnl Ultrix and Pyramid sh refuse to redirect output of eval, + dnl so use subshell. + AS_VAR_SET([gl_cv_absolute_]AS_TR_SH([[$1]]), +[`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD | +sed -n '\#/$1#{ + s#.*"\(.*/$1\)".*#\1# + s#^/[^/]#//&# + p + q +}'`]) +]) diff --git a/m4/arpa_inet_h.m4 b/m4/arpa_inet_h.m4 index 4360dd810..15a30e2bc 100644 --- a/m4/arpa_inet_h.m4 +++ b/m4/arpa_inet_h.m4 @@ -1,4 +1,4 @@ -# arpa_inet_h.m4 serial 7 +# arpa_inet_h.m4 serial 8 dnl Copyright (C) 2006, 2008, 2009, 2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -44,7 +44,7 @@ AC_DEFUN([gl_ARPA_INET_MODULE_INDICATOR], [ dnl Use AC_REQUIRE here, so that the default settings are expanded once only. AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS]) - GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1 + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) ]) AC_DEFUN([gl_ARPA_INET_H_DEFAULTS], diff --git a/m4/asm-underscore.m4 b/m4/asm-underscore.m4 new file mode 100644 index 000000000..1736cc432 --- /dev/null +++ b/m4/asm-underscore.m4 @@ -0,0 +1,48 @@ +# asm-underscore.m4 serial 1 +dnl Copyright (C) 2010 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. + +dnl From Bruno Haible. Based on as-underscore.m4 in GNU clisp. + +# gl_ASM_SYMBOL_PREFIX +# Tests for the prefix of C symbols at the assembly language level and the +# linker level. This prefix is either an underscore or empty. Defines the +# C macro USER_LABEL_PREFIX to this prefix, and sets ASM_SYMBOL_PREFIX to +# a stringified variant of this prefix. + +AC_DEFUN([gl_ASM_SYMBOL_PREFIX], +[ + dnl We don't use GCC's __USER_LABEL_PREFIX__ here, because + dnl 1. It works only for GCC. + dnl 2. It is incorrectly defined on some platforms, in some GCC versions. + AC_CACHE_CHECK( + [whether C symbols are prefixed with underscore at the linker level], + [gl_cv_prog_as_underscore], + [cat > conftest.c </dev/null 2>&1 + if grep _foo conftest.s >/dev/null ; then + gl_cv_prog_as_underscore=yes + else + gl_cv_prog_as_underscore=no + fi + rm -f conftest* + ]) + if test $gl_cv_prog_as_underscore = yes; then + USER_LABEL_PREFIX=_ + else + USER_LABEL_PREFIX= + fi + AC_DEFINE_UNQUOTED([USER_LABEL_PREFIX], [$USER_LABEL_PREFIX], + [Define to the prefix of C symbols at the assembler and linker level, + either an underscore or empty.]) + ASM_SYMBOL_PREFIX='"'${USER_LABEL_PREFIX}'"' + AC_SUBST([ASM_SYMBOL_PREFIX]) +]) diff --git a/m4/fcntl-o.m4 b/m4/fcntl-o.m4 index 67167cbda..d416a61c8 100644 --- a/m4/fcntl-o.m4 +++ b/m4/fcntl-o.m4 @@ -1,5 +1,5 @@ # fcntl-o.m4 serial 1 -dnl Copyright (C) 2006, 2009, 2010 Free Software Foundation, Inc. +dnl Copyright (C) 2006, 2009-2010 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. diff --git a/m4/getaddrinfo.m4 b/m4/getaddrinfo.m4 index 05fd2b6c4..bc3066db1 100644 --- a/m4/getaddrinfo.m4 +++ b/m4/getaddrinfo.m4 @@ -1,4 +1,4 @@ -# getaddrinfo.m4 serial 22 +# getaddrinfo.m4 serial 23 dnl Copyright (C) 2004-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -96,7 +96,7 @@ AC_DEFUN([gl_PREREQ_GETADDRINFO], [ AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H AC_REQUIRE([gl_HOSTENT]) dnl for HOSTENT_LIB AC_REQUIRE([gl_SERVENT]) dnl for SERVENT_LIB - AC_REQUIRE([gl_INET_NTOP]) dnl for INET_NTOP_LIB + AC_REQUIRE([gl_FUNC_INET_NTOP]) dnl for INET_NTOP_LIB AC_REQUIRE([AC_C_RESTRICT]) AC_REQUIRE([gl_SOCKET_FAMILIES]) AC_REQUIRE([gl_HEADER_SYS_SOCKET]) diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4 index 80ba26332..4c7ac30d0 100644 --- a/m4/gnulib-common.m4 +++ b/m4/gnulib-common.m4 @@ -1,4 +1,4 @@ -# gnulib-common.m4 serial 13 +# gnulib-common.m4 serial 20 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -35,14 +35,71 @@ AC_DEFUN([gl_COMMON_BODY], [ is a misnomer outside of parameter lists. */ #define _UNUSED_PARAMETER_ _GL_UNUSED ]) + dnl Preparation for running test programs: + dnl Tell glibc to write diagnostics from -D_FORTIFY_SOURCE=2 to stderr, not + dnl to /dev/tty, so they can be redirected to log files. Such diagnostics + dnl arise e.g., in the macros gl_PRINTF_DIRECTIVE_N, gl_SNPRINTF_DIRECTIVE_N. + LIBC_FATAL_STDERR_=1 + export LIBC_FATAL_STDERR_ +]) + +# gl_MODULE_INDICATOR_CONDITION +# expands to a C preprocessor expression that evaluates to 1 or 0, depending +# whether a gnulib module that has been requested shall be considered present +# or not. +AC_DEFUN([gl_MODULE_INDICATOR_CONDITION], [1]) + +# gl_MODULE_INDICATOR_SET_VARIABLE([modulename]) +# sets the shell variable that indicates the presence of the given module to +# a C preprocessor expression that will evaluate to 1. +AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE], +[ + GNULIB_[]m4_translit([[$1]], + [abcdefghijklmnopqrstuvwxyz./-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=gl_MODULE_INDICATOR_CONDITION ]) # gl_MODULE_INDICATOR([modulename]) -# defines a C macro indicating the presence of the given module. +# defines a C macro indicating the presence of the given module +# in a location where it can be used. +# | Value | Value | +# | in lib/ | in tests/ | +# --------------------------------------------+---------+-----------+ +# Module present among main modules: | 1 | 1 | +# --------------------------------------------+---------+-----------+ +# Module present among tests-related modules: | 0 | 1 | +# --------------------------------------------+---------+-----------+ +# Module not present at all: | 0 | 0 | +# --------------------------------------------+---------+-----------+ AC_DEFUN([gl_MODULE_INDICATOR], [ - AC_DEFINE([GNULIB_]translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___]), [1], - [Define to 1 when using the gnulib module ]$1[.]) + AC_DEFINE_UNQUOTED([GNULIB_]m4_translit([[$1]], + [abcdefghijklmnopqrstuvwxyz./-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ___]), + [gl_MODULE_INDICATOR_CONDITION], + [Define to a C preprocessor expression that evaluates to 1 or 0, + depending whether the gnulib module $1 shall be considered present.]) +]) + +# gl_MODULE_INDICATOR_FOR_TESTS([modulename]) +# defines a C macro indicating the presence of the given module +# in lib or tests. This is useful to determine whether the module +# should be tested. +# | Value | Value | +# | in lib/ | in tests/ | +# --------------------------------------------+---------+-----------+ +# Module present among main modules: | 1 | 1 | +# --------------------------------------------+---------+-----------+ +# Module present among tests-related modules: | 1 | 1 | +# --------------------------------------------+---------+-----------+ +# Module not present at all: | 0 | 0 | +# --------------------------------------------+---------+-----------+ +AC_DEFUN([gl_MODULE_INDICATOR_FOR_TESTS], +[ + AC_DEFINE([GNULIB_TEST_]m4_translit([[$1]], + [abcdefghijklmnopqrstuvwxyz./-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ___]), [1], + [Define to 1 when the gnulib module $1 should be tested.]) ]) # m4_foreach_w @@ -81,6 +138,7 @@ m4_ifdef([AC_PROG_MKDIR_P], [ # so that mixed use of GNU C and GNU C++ and mixed use of Sun C and Sun C++ # works. # This definition can be removed once autoconf >= 2.62 can be assumed. +m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.62]),[-1],[ AC_DEFUN([AC_C_RESTRICT], [AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict], [ac_cv_c_restrict=no @@ -118,6 +176,7 @@ AC_DEFUN([AC_C_RESTRICT], *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;; esac ]) +]) # gl_BIGENDIAN # is like AC_C_BIGENDIAN, except that it can be AC_REQUIREd. diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 index 16d6ca6f3..f7538ff56 100644 --- a/m4/gnulib-comp.m4 +++ b/m4/gnulib-comp.m4 @@ -148,6 +148,7 @@ AC_DEFUN([gl_INIT], [ AM_CONDITIONAL([GL_COND_LIBTOOL], [true]) gl_cond_libtool=true + gl_m4_base='m4' m4_pushdef([AC_LIBOBJ], m4_defn([gl_LIBOBJ])) m4_pushdef([AC_REPLACE_FUNCS], m4_defn([gl_REPLACE_FUNCS])) m4_pushdef([AC_LIBSOURCES], m4_defn([gl_LIBSOURCES])) @@ -230,10 +231,10 @@ AC_DEFUN([gl_INIT], gl_FUNC_ICONV_OPEN_UTF # Code from module include_next: # Code from module inet_ntop: - gl_INET_NTOP + gl_FUNC_INET_NTOP gl_ARPA_INET_MODULE_INDICATOR([inet_ntop]) # Code from module inet_pton: - gl_INET_PTON + gl_FUNC_INET_PTON gl_ARPA_INET_MODULE_INDICATOR([inet_pton]) # Code from module inline: gl_INLINE @@ -348,16 +349,23 @@ AC_DEFUN([gl_INIT], # Code from module unistd: gl_UNISTD_H # Code from module unistr/base: + gl_LIBUNISTRING_LIBHEADER([0.9.2], [unistr.h]) # Code from module unistr/u8-mbtouc: gl_MODULE_INDICATOR([unistr/u8-mbtouc]) + gl_LIBUNISTRING_LIBSOURCE([0.9], [unistr/u8-mbtouc.c unistr/u8-mbtouc-aux.c]) # Code from module unistr/u8-mbtouc-unsafe: gl_MODULE_INDICATOR([unistr/u8-mbtouc-unsafe]) + gl_LIBUNISTRING_LIBSOURCE([0.9], [unistr/u8-mbtouc-unsafe.c unistr/u8-mbtouc-unsafe-aux.c]) # Code from module unistr/u8-mbtoucr: gl_MODULE_INDICATOR([unistr/u8-mbtoucr]) + gl_LIBUNISTRING_LIBSOURCE([0.9], [unistr/u8-mbtoucr.c]) # Code from module unistr/u8-prev: + gl_LIBUNISTRING_LIBSOURCE([0.9], [unistr/u8-prev.c]) # Code from module unistr/u8-uctomb: gl_MODULE_INDICATOR([unistr/u8-uctomb]) + gl_LIBUNISTRING_LIBSOURCE([0.9], [unistr/u8-uctomb.c unistr/u8-uctomb-aux.c]) # Code from module unitypes: + gl_LIBUNISTRING_LIBHEADER([0.9], [unitypes.h]) # Code from module unused-parameter: # Code from module useless-if-before-free: # Code from module vasnprintf: @@ -420,6 +428,13 @@ AC_DEFUN([gl_INIT], m4_pushdef([gltests_LIBSOURCES_DIR], []) gl_COMMON gl_source_base='tests' +changequote(,)dnl + gltests_WITNESS=IN_`echo "${PACKAGE-$PACKAGE_TARNAME}" | LC_ALL=C tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ | LC_ALL=C sed -e 's/[^A-Z0-9_]/_/g'`_GNULIB_TESTS +changequote([, ])dnl + AC_SUBST([gltests_WITNESS]) + gl_module_indicator_condition=$gltests_WITNESS + m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$gl_module_indicator_condition]) + m4_popdef([gl_MODULE_INDICATOR_CONDITION]) m4_ifval(gltests_LIBSOURCES_LIST, [ m4_syscmd([test ! -d ]m4_defn([gltests_LIBSOURCES_DIR])[ || for gl_file in ]gltests_LIBSOURCES_LIST[ ; do @@ -559,6 +574,7 @@ AC_DEFUN([gl_FILE_LIST], [ lib/iconveh.h lib/inet_ntop.c lib/inet_pton.c + lib/libunistring.valgrind lib/localcharset.c lib/localcharset.h lib/locale.in.h @@ -612,7 +628,7 @@ AC_DEFUN([gl_FILE_LIST], [ lib/time.in.h lib/time_r.c lib/unistd.in.h - lib/unistr.h + lib/unistr.in.h lib/unistr/u8-mbtouc-aux.c lib/unistr/u8-mbtouc-unsafe-aux.c lib/unistr/u8-mbtouc-unsafe.c @@ -621,7 +637,7 @@ AC_DEFUN([gl_FILE_LIST], [ lib/unistr/u8-prev.c lib/unistr/u8-uctomb-aux.c lib/unistr/u8-uctomb.c - lib/unitypes.h + lib/unitypes.in.h lib/vasnprintf.c lib/vasnprintf.h lib/verify.h @@ -633,8 +649,10 @@ AC_DEFUN([gl_FILE_LIST], [ lib/write.c lib/xsize.h m4/00gnulib.m4 + m4/absolute-header.m4 m4/alloca.m4 m4/arpa_inet_h.m4 + m4/asm-underscore.m4 m4/autobuild.m4 m4/byteswap.m4 m4/canonicalize.m4 @@ -668,6 +686,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/lib-ld.m4 m4/lib-link.m4 m4/lib-prefix.m4 + m4/libunistring-base.m4 m4/libunistring.m4 m4/localcharset.m4 m4/locale-fr.m4 diff --git a/m4/iconv.m4 b/m4/iconv.m4 index f46ff1421..4c6847213 100644 --- a/m4/iconv.m4 +++ b/m4/iconv.m4 @@ -1,4 +1,4 @@ -# iconv.m4 serial 9 (gettext-0.18) +# iconv.m4 serial 10 (gettext-0.18.1) dnl Copyright (C) 2000-2002, 2007-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -170,7 +170,10 @@ int main () AC_SUBST([LTLIBICONV]) ]) -AC_DEFUN([AM_ICONV], +dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to +dnl avoid warnings like +dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required". +m4_version_prereq([2.64],[AC_DEFUN_ONCE],[AC_DEFUN])([AM_ICONV], [ AM_ICONV_LINK if test "$am_cv_func_iconv" = yes; then diff --git a/m4/iconv_h.m4 b/m4/iconv_h.m4 index 8881473ac..7366cb98e 100644 --- a/m4/iconv_h.m4 +++ b/m4/iconv_h.m4 @@ -1,4 +1,4 @@ -# iconv_h.m4 serial 5 +# iconv_h.m4 serial 6 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -24,7 +24,7 @@ AC_DEFUN([gl_ICONV_MODULE_INDICATOR], [ dnl Use AC_REQUIRE here, so that the default settings are expanded once only. AC_REQUIRE([gl_ICONV_H_DEFAULTS]) - GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1 + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) ]) AC_DEFUN([gl_ICONV_H_DEFAULTS], diff --git a/m4/inet_ntop.m4 b/m4/inet_ntop.m4 index 20e8d7c52..a6d219c20 100644 --- a/m4/inet_ntop.m4 +++ b/m4/inet_ntop.m4 @@ -1,10 +1,10 @@ -# inet_ntop.m4 serial 11 +# inet_ntop.m4 serial 12 dnl Copyright (C) 2005, 2006, 2008, 2009, 2010 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_INET_NTOP], +AC_DEFUN([gl_FUNC_INET_NTOP], [ dnl Persuade Solaris to declare inet_ntop. AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) diff --git a/m4/inet_pton.m4 b/m4/inet_pton.m4 index e0b794242..193f17d0a 100644 --- a/m4/inet_pton.m4 +++ b/m4/inet_pton.m4 @@ -1,10 +1,10 @@ -# inet_pton.m4 serial 9 +# inet_pton.m4 serial 10 dnl Copyright (C) 2006, 2008, 2009, 2010 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_INET_PTON], +AC_DEFUN([gl_FUNC_INET_PTON], [ dnl Persuade Solaris to declare inet_pton. AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) diff --git a/m4/lib-link.m4 b/m4/lib-link.m4 index 90e1ac917..c73bd8e3a 100644 --- a/m4/lib-link.m4 +++ b/m4/lib-link.m4 @@ -1,4 +1,4 @@ -# lib-link.m4 serial 20 (gettext-0.18) +# lib-link.m4 serial 21 (gettext-0.18) dnl Copyright (C) 2001-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -74,7 +74,17 @@ AC_DEFUN([AC_LIB_HAVE_LINKFLAGS], AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [ ac_save_LIBS="$LIBS" - LIBS="$LIBS $LIB[]NAME" + dnl If $LIB[]NAME contains some -l options, add it to the end of LIBS, + dnl because these -l options might require -L options that are present in + dnl LIBS. -l options benefit only from the -L options listed before it. + dnl Otherwise, add it to the front of LIBS, because it may be a static + dnl library that depends on another static library that is present in LIBS. + dnl Static libraries benefit only from the static libraries listed after + dnl it. + case " $LIB[]NAME" in + *" -l"*) LIBS="$LIBS $LIB[]NAME" ;; + *) LIBS="$LIB[]NAME $LIBS" ;; + esac AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])']) diff --git a/m4/libunistring-base.m4 b/m4/libunistring-base.m4 new file mode 100644 index 000000000..54aa521c7 --- /dev/null +++ b/m4/libunistring-base.m4 @@ -0,0 +1,143 @@ +# libunistring-base.m4 serial 2 +dnl Copyright (C) 2010 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. + +dnl From Paolo Bonzini and Bruno Haible. + +dnl gl_LIBUNISTRING_LIBSOURCE([VERSION], [SourceFile]) +dnl Declares that SourceFile should be compiled, unless we are linking +dnl with libunistring and its version is >= the given VERSION. +dnl SourceFile should be relative to the lib directory and end in '.c'. +dnl This macro is to be used for public libunistring API, not for +dnl undocumented API. +dnl +dnl You have to bump the VERSION argument to the next projected version +dnl number each time you make a change that affects the behaviour of the +dnl functions defined in SourceFile (even if SourceFile itself does not +dnl change). + +AC_DEFUN([gl_LIBUNISTRING_LIBSOURCE], +[ + AC_REQUIRE([gl_LIBUNISTRING_LIB_PREPARE]) + dnl Use the variables HAVE_LIBUNISTRING, LIBUNISTRING_VERSION from + dnl gl_LIBUNISTRING_CORE if that macro has been run. + if gl_LIBUNISTRING_VERSION_CMP([$1]) + then + m4_foreach_w([gl_source_file], [$2], + [AC_LIBOBJ(m4_bpatsubst(m4_defn([gl_source_file]), [\.c$], [])) + ]) + fi +]) + +dnl gl_LIBUNISTRING_LIBHEADER([VERSION], [HeaderFile]) +dnl Declares that HeaderFile should be created, unless we are linking +dnl with libunistring and its version is >= the given VERSION. +dnl HeaderFile should be relative to the lib directory and end in '.h'. +dnl Prepares for substituting LIBUNISTRING_HEADERFILE (to HeaderFile or empty). +dnl +dnl When we are linking with the already installed libunistring and its version +dnl is < VERSION, we create HeaderFile here, because we may compile functions +dnl (via gl_LIBUNISTRING_LIBSOURCE above) that are not contained in the +dnl installed version. +dnl When we are linking with the already installed libunistring and its version +dnl is > VERSION, we don't create HeaderFile here: it could cause compilation +dnl errors in other libunistring header files if some types are missing. +dnl +dnl You have to bump the VERSION argument to the next projected version +dnl number each time you make a non-comment change to the HeaderFile. + +AC_DEFUN([gl_LIBUNISTRING_LIBHEADER], +[ + AC_REQUIRE([gl_LIBUNISTRING_LIB_PREPARE]) + dnl Use the variables HAVE_LIBUNISTRING, LIBUNISTRING_VERSION from + dnl gl_LIBUNISTRING_CORE if that macro has been run. + if gl_LIBUNISTRING_VERSION_CMP([$1]) + then + LIBUNISTRING_[]AS_TR_CPP([$2])='$2' + else + LIBUNISTRING_[]AS_TR_CPP([$2])= + fi + AC_SUBST([LIBUNISTRING_]AS_TR_CPP([$2])) +]) + +dnl Miscellaneous preparations/initializations. + +AC_DEFUN([gl_LIBUNISTRING_LIB_PREPARE], +[ + AC_REQUIRE([AC_PROG_AWK]) + +dnl Sed expressions to extract the parts of a version number. +changequote(,) +gl_libunistring_sed_extract_major='/^[0-9]/{s/^\([0-9]*\).*/\1/p;q;} +i\ +0 +q +' +gl_libunistring_sed_extract_minor='/^[0-9][0-9]*[.][0-9]/{s/^[0-9]*[.]\([0-9]*\).*/\1/p;q;} +i\ +0 +q +' +gl_libunistring_sed_extract_subminor='/^[0-9][0-9]*[.][0-9][0-9]*[.][0-9]/{s/^[0-9]*[.][0-9]*[.]\([0-9]*\).*/\1/p;q;} +i\ +0 +q +' +changequote([,]) + + if test "$HAVE_LIBUNISTRING" = yes; then + LIBUNISTRING_VERSION_MAJOR=`echo "$LIBUNISTRING_VERSION" | sed -n -e "$gl_libunistring_sed_extract_major"` + LIBUNISTRING_VERSION_MINOR=`echo "$LIBUNISTRING_VERSION" | sed -n -e "$gl_libunistring_sed_extract_minor"` + LIBUNISTRING_VERSION_SUBMINOR=`echo "$LIBUNISTRING_VERSION" | sed -n -e "$gl_libunistring_sed_extract_subminor"` + fi +]) + +dnl gl_LIBUNISTRING_VERSION_CMP([VERSION]) +dnl Expands to a shell statement that evaluates to true if LIBUNISTRING_VERSION +dnl is less than the VERSION argument. +AC_DEFUN([gl_LIBUNISTRING_VERSION_CMP], +[ { test "$HAVE_LIBUNISTRING" != yes \ + || { + dnl AS_LITERAL_IF exists and works fine since autoconf-2.59 at least. + AS_LITERAL_IF([$1], + [dnl This is the optimized variant, that assumes the argument is a literal: + m4_pushdef([requested_version_major], + [gl_LIBUNISTRING_ARG_OR_ZERO(m4_bpatsubst([$1], [^\([0-9]*\).*], [\1]), [])]) + m4_pushdef([requested_version_minor], + [gl_LIBUNISTRING_ARG_OR_ZERO(m4_bpatsubst([$1], [^[0-9]*[.]\([0-9]*\).*], [\1]), [$1])]) + m4_pushdef([requested_version_subminor], + [gl_LIBUNISTRING_ARG_OR_ZERO(m4_bpatsubst([$1], [^[0-9]*[.][0-9]*[.]\([0-9]*\).*], [\1]), [$1])]) + test $LIBUNISTRING_VERSION_MAJOR -lt requested_version_major \ + || { test $LIBUNISTRING_VERSION_MAJOR -eq requested_version_major \ + && { test $LIBUNISTRING_VERSION_MINOR -lt requested_version_minor \ + || { test $LIBUNISTRING_VERSION_MINOR -eq requested_version_minor \ + && test $LIBUNISTRING_VERSION_SUBMINOR -lt requested_version_subminor + } + } + } + m4_popdef([requested_version_subminor]) + m4_popdef([requested_version_minor]) + m4_popdef([requested_version_major]) + ], + [dnl This is the unoptimized variant: + requested_version_major=`echo '$1' | sed -n -e "$gl_libunistring_sed_extract_major"` + requested_version_minor=`echo '$1' | sed -n -e "$gl_libunistring_sed_extract_minor"` + requested_version_subminor=`echo '$1' | sed -n -e "$gl_libunistring_sed_extract_subminor"` + test $LIBUNISTRING_VERSION_MAJOR -lt $requested_version_major \ + || { test $LIBUNISTRING_VERSION_MAJOR -eq $requested_version_major \ + && { test $LIBUNISTRING_VERSION_MINOR -lt $requested_version_minor \ + || { test $LIBUNISTRING_VERSION_MINOR -eq $requested_version_minor \ + && test $LIBUNISTRING_VERSION_SUBMINOR -lt $requested_version_subminor + } + } + } + ]) + } + } +]) + +dnl gl_LIBUNISTRING_ARG_OR_ZERO([ARG], [ORIG]) expands to ARG if it is not the +dnl same as ORIG, otherwise to 0. +m4_define([gl_LIBUNISTRING_ARG_OR_ZERO], [m4_if([$1], [$2], [0], [$1])]) diff --git a/m4/libunistring.m4 b/m4/libunistring.m4 index 8f9f07b0e..7a10efec7 100644 --- a/m4/libunistring.m4 +++ b/m4/libunistring.m4 @@ -1,5 +1,5 @@ -# libunistring.m4 serial 1 -dnl Copyright (C) 2009, 2010 Free Software Foundation, Inc. +# libunistring.m4 serial 6 +dnl Copyright (C) 2009-2010 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. @@ -7,22 +7,61 @@ dnl with or without modifications, as long as this notice is preserved. dnl gl_LIBUNISTRING dnl Searches for an installed libunistring. dnl If found, it sets and AC_SUBSTs HAVE_LIBUNISTRING=yes and the LIBUNISTRING -dnl and LTLIBUNISTRING variables and augments the CPPFLAGS variable, and -dnl #defines HAVE_LIBUNISTRING to 1. Otherwise, it sets and AC_SUBSTs -dnl HAVE_LIBUNISTRING=no and LIBUNINSTRING and LTLIBUNISTRING to empty. +dnl and LTLIBUNISTRING variables, sets the LIBUNISTRING_VERSION variable, and +dnl augments the CPPFLAGS variable, and #defines HAVE_LIBUNISTRING to 1. +dnl Otherwise, it sets and AC_SUBSTs HAVE_LIBUNISTRING=no and LIBUNISTRING and +dnl LTLIBUNISTRING to empty. AC_DEFUN([gl_LIBUNISTRING], [ - dnl First, try to link without -liconv. libunistring often depends on - dnl libiconv, but we don't know (and often don't need to know) where - dnl libiconv is installed. - AC_LIB_HAVE_LINKFLAGS([unistring], [], - [#include ], [u8_strconv_from_locale((char*)0);], - [no, consider installing GNU libunistring]) - if test "$ac_cv_libunistring" != yes; then - dnl Second try, with -liconv. - AC_REQUIRE([AM_ICONV]) - if test -n "$LIBICONV"; then + AC_BEFORE([$0], [gl_LIBUNISTRING_LIBSOURCE]) + AC_BEFORE([$0], [gl_LIBUNISTRING_LIBHEADER]) + AC_BEFORE([$0], [gl_LIBUNISTRING_LIB_PREPARE]) + + m4_ifdef([gl_LIBUNISTRING_OPTIONAL], + [ + AC_MSG_CHECKING([whether included libunistring is requested]) + AC_ARG_WITH([included-libunistring], + [ --with-included-libunistring use the libunistring parts included here], + [gl_libunistring_force_included=$withval], + [gl_libunistring_force_included=no]) + AC_MSG_RESULT([$gl_libunistring_force_included]) + gl_libunistring_use_included="$gl_libunistring_force_included" + if test "$gl_libunistring_use_included" = yes; then + dnl Assume that libunistring is not installed until some other macro + dnl explicitly invokes gl_LIBUNISTRING_CORE. + if test -z "$HAVE_LIBUNISTRING"; then + HAVE_LIBUNISTRING=no + fi + LIBUNISTRING= + LTLIBUNISTRING= + else + gl_LIBUNISTRING_CORE + if test $HAVE_LIBUNISTRING = no; then + gl_libunistring_use_included=yes + LIBUNISTRING= + LTLIBUNISTRING= + fi + fi + ], + [gl_LIBUNISTRING_CORE]) +]) + +AC_DEFUN([gl_LIBUNISTRING_CORE], +[ + AC_REQUIRE([AM_ICONV]) + if test -n "$LIBICONV"; then + dnl First, try to link without -liconv. libunistring often depends on + dnl libiconv, but we don't know (and often don't need to know) where + dnl libiconv is installed. + AC_LIB_HAVE_LINKFLAGS([unistring], [], + [#include ], [u8_strconv_from_locale((char*)0);], + [no, trying again together with libiconv]) + if test "$ac_cv_libunistring" != yes; then + dnl Second try, with -liconv. + dnl We have to erase the cached result of the first AC_LIB_HAVE_LINKFLAGS + dnl invocation, otherwise the second one will not be run. + unset ac_cv_libunistring glus_save_LIBS="$LIBS" LIBS="$LIBS $LIBICONV" AC_LIB_HAVE_LINKFLAGS([unistring], [], @@ -30,8 +69,60 @@ AC_DEFUN([gl_LIBUNISTRING], [no, consider installing GNU libunistring]) if test -n "$LIBUNISTRING"; then LIBUNISTRING="$LIBUNISTRING $LIBICONV" + LTLIBUNISTRING="$LTLIBUNISTRING $LTLIBICONV" fi LIBS="$glus_save_LIBS" fi + else + AC_LIB_HAVE_LINKFLAGS([unistring], [], + [#include ], [u8_strconv_from_locale((char*)0);], + [no, consider installing GNU libunistring]) + fi + if test $HAVE_LIBUNISTRING = yes; then + dnl Determine the installed version. + AC_CACHE_CHECK([for libunistring version], [gl_cv_libunistring_version], + [AC_COMPUTE_INT([gl_libunistring_hexversion], + [_LIBUNISTRING_VERSION], + [#include ]) + dnl Versions <= 0.9.3 had a hexversion of 0x0009. + dnl Use other tests to distinguish them. + if test $gl_libunistring_hexversion = 9; then + dnl Version 0.9.2 introduced the header . + AC_TRY_COMPILE([#include ], , + [gl_cv_libunistring_version092=true], + [gl_cv_libunistring_version092=false]); + if $gl_cv_libunistring_version092; then + dnl Version 0.9.3 changed a comment in . + gl_ABSOLUTE_HEADER_ONE([unistr.h]) + if test -n "$gl_cv_absolute_unistr_h" \ + && grep 'Copy no more than N units of SRC to DEST. Return a pointer' $gl_cv_absolute_unistr_h > /dev/null; then + dnl Detected version 0.9.3. + gl_libunistring_hexversion=2307 + else + dnl Detected version 0.9.2. + gl_libunistring_hexversion=2306 + fi + else + dnl Version 0.9.1 introduced the type casing_suffix_context_t. + AC_TRY_COMPILE([#include + casing_suffix_context_t ct;], , + [gl_cv_libunistring_version091=true], + [gl_cv_libunistring_version091=false]) + if $gl_cv_libunistring_version091; then + dnl Detected version 0.9.1. + gl_libunistring_hexversion=2305 + else + dnl Detected version 0.9. + gl_libunistring_hexversion=2304 + fi + fi + fi + dnl Transform into the usual major.minor.subminor notation. + gl_libunistring_major=`expr $gl_libunistring_hexversion / 65536` + gl_libunistring_minor=`expr $gl_libunistring_hexversion / 256 % 256` + gl_libunistring_subminor=`expr $gl_libunistring_hexversion % 256` + gl_cv_libunistring_version="$gl_libunistring_major.$gl_libunistring_minor.$gl_libunistring_subminor" + ]) + LIBUNISTRING_VERSION="$gl_cv_libunistring_version" fi ]) diff --git a/m4/locale_h.m4 b/m4/locale_h.m4 index 743e6a849..18a119b8e 100644 --- a/m4/locale_h.m4 +++ b/m4/locale_h.m4 @@ -1,5 +1,5 @@ -# locale_h.m4 serial 9 -dnl Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. +# locale_h.m4 serial 10 +dnl Copyright (C) 2007, 2009-2010 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. @@ -78,9 +78,9 @@ AC_DEFUN([gl_LOCALE_MODULE_INDICATOR], [ dnl Use AC_REQUIRE here, so that the default settings are expanded once only. AC_REQUIRE([gl_LOCALE_H_DEFAULTS]) - GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1 + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) dnl Define it also as a C macro, for the benefit of the unit tests. - gl_MODULE_INDICATOR([$1]) + gl_MODULE_INDICATOR_FOR_TESTS([$1]) ]) AC_DEFUN([gl_LOCALE_H_DEFAULTS], diff --git a/m4/mbrtowc.m4 b/m4/mbrtowc.m4 index 9ec93f561..606de5c9f 100644 --- a/m4/mbrtowc.m4 +++ b/m4/mbrtowc.m4 @@ -1,4 +1,4 @@ -# mbrtowc.m4 serial 16 +# mbrtowc.m4 serial 17 dnl Copyright (C) 2001-2002, 2004-2005, 2008-2010 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation @@ -11,38 +11,39 @@ AC_DEFUN([gl_FUNC_MBRTOWC], AC_REQUIRE([AC_TYPE_MBSTATE_T]) gl_MBSTATE_T_BROKEN - if test $REPLACE_MBSTATE_T = 1; then - REPLACE_MBRTOWC=1 - fi + AC_CHECK_FUNCS_ONCE([mbrtowc]) if test $ac_cv_func_mbrtowc = no; then HAVE_MBRTOWC=0 - fi - if test $HAVE_MBRTOWC != 0 && test $REPLACE_MBRTOWC != 1; then - gl_MBRTOWC_NULL_ARG - gl_MBRTOWC_RETVAL - gl_MBRTOWC_NUL_RETVAL - case "$gl_cv_func_mbrtowc_null_arg" in - *yes) ;; - *) AC_DEFINE([MBRTOWC_NULL_ARG_BUG], [1], - [Define if the mbrtowc function has the NULL string argument bug.]) - REPLACE_MBRTOWC=1 - ;; - esac - case "$gl_cv_func_mbrtowc_retval" in - *yes) ;; - *) AC_DEFINE([MBRTOWC_RETVAL_BUG], [1], - [Define if the mbrtowc function returns a wrong return value.]) - REPLACE_MBRTOWC=1 - ;; - esac - case "$gl_cv_func_mbrtowc_nul_retval" in - *yes) ;; - *) AC_DEFINE([MBRTOWC_NUL_RETVAL_BUG], [1], - [Define if the mbrtowc function does not return 0 for a NUL character.]) - REPLACE_MBRTOWC=1 - ;; - esac + else + if test $REPLACE_MBSTATE_T = 1; then + REPLACE_MBRTOWC=1 + else + gl_MBRTOWC_NULL_ARG + gl_MBRTOWC_RETVAL + gl_MBRTOWC_NUL_RETVAL + case "$gl_cv_func_mbrtowc_null_arg" in + *yes) ;; + *) AC_DEFINE([MBRTOWC_NULL_ARG_BUG], [1], + [Define if the mbrtowc function has the NULL string argument bug.]) + REPLACE_MBRTOWC=1 + ;; + esac + case "$gl_cv_func_mbrtowc_retval" in + *yes) ;; + *) AC_DEFINE([MBRTOWC_RETVAL_BUG], [1], + [Define if the mbrtowc function returns a wrong return value.]) + REPLACE_MBRTOWC=1 + ;; + esac + case "$gl_cv_func_mbrtowc_nul_retval" in + *yes) ;; + *) AC_DEFINE([MBRTOWC_NUL_RETVAL_BUG], [1], + [Define if the mbrtowc function does not return 0 for a NUL character.]) + REPLACE_MBRTOWC=1 + ;; + esac + fi fi if test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1; then gl_REPLACE_WCHAR_H diff --git a/m4/mbsinit.m4 b/m4/mbsinit.m4 index 13907a516..46c106fc4 100644 --- a/m4/mbsinit.m4 +++ b/m4/mbsinit.m4 @@ -1,5 +1,5 @@ -# mbsinit.m4 serial 3 -dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. +# mbsinit.m4 serial 4 +dnl Copyright (C) 2008, 2010 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. @@ -10,12 +10,14 @@ AC_DEFUN([gl_FUNC_MBSINIT], AC_REQUIRE([AC_TYPE_MBSTATE_T]) gl_MBSTATE_T_BROKEN - if test $REPLACE_MBSTATE_T = 1; then - REPLACE_MBSINIT=1 - fi + AC_CHECK_FUNCS_ONCE([mbsinit]) if test $ac_cv_func_mbsinit = no; then HAVE_MBSINIT=0 + else + if test $REPLACE_MBSTATE_T = 1; then + REPLACE_MBSINIT=1 + fi fi if test $HAVE_MBSINIT = 0 || test $REPLACE_MBSINIT = 1; then gl_REPLACE_WCHAR_H diff --git a/m4/memchr.m4 b/m4/memchr.m4 index 94596ef95..ab773b812 100644 --- a/m4/memchr.m4 +++ b/m4/memchr.m4 @@ -1,4 +1,4 @@ -# memchr.m4 serial 7 +# memchr.m4 serial 8 dnl Copyright (C) 2002-2004, 2009-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -13,12 +13,7 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR], dnl These days, we assume memchr is present. But just in case... AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) - AC_REPLACE_FUNCS([memchr]) - if test $ac_cv_func_memchr = no; then - gl_PREREQ_MEMCHR - REPLACE_MEMCHR=1 - fi - + AC_CHECK_FUNCS_ONCE([memchr]) if test $ac_cv_func_memchr = yes; then # Detect platform-specific bugs in some versions of glibc: # memchr should not dereference anything with length 0 @@ -73,10 +68,14 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR], [dnl Be pessimistic for now. gl_cv_func_memchr_works="guessing no"])]) if test "$gl_cv_func_memchr_works" != yes; then - gl_PREREQ_MEMCHR REPLACE_MEMCHR=1 - AC_LIBOBJ([memchr]) fi + else + HAVE_MEMCHR=0 + fi + if test $HAVE_MEMCHR = 0 || test $REPLACE_MEMCHR = 1; then + AC_LIBOBJ([memchr]) + gl_PREREQ_MEMCHR fi ]) diff --git a/m4/netdb_h.m4 b/m4/netdb_h.m4 index 84afce6e5..c870fb61b 100644 --- a/m4/netdb_h.m4 +++ b/m4/netdb_h.m4 @@ -1,4 +1,4 @@ -# netdb_h.m4 serial 6 +# netdb_h.m4 serial 9 dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -10,28 +10,23 @@ AC_DEFUN([gl_HEADER_NETDB], AC_CHECK_HEADERS_ONCE([netdb.h]) gl_CHECK_NEXT_HEADERS([netdb.h]) if test $ac_cv_header_netdb_h = yes; then - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([[ - #include - struct addrinfo a; - int b = EAI_OVERFLOW; - int c = AI_NUMERICSERV; - ]])], - [NETDB_H=''], [NETDB_H='netdb.h']) HAVE_NETDB_H=1 else - NETDB_H='netdb.h' HAVE_NETDB_H=0 fi AC_SUBST([HAVE_NETDB_H]) - AC_SUBST([NETDB_H]) + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use. + gl_WARN_ON_USE_PREPARE([[#include ]], + [getaddrinfo freeaddrinfo gai_strerror getnameinfo]) ]) AC_DEFUN([gl_NETDB_MODULE_INDICATOR], [ dnl Use AC_REQUIRE here, so that the default settings are expanded once only. AC_REQUIRE([gl_NETDB_H_DEFAULTS]) - GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1 + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) ]) AC_DEFUN([gl_NETDB_H_DEFAULTS], diff --git a/m4/stddef_h.m4 b/m4/stddef_h.m4 index c8572de94..c3ae56943 100644 --- a/m4/stddef_h.m4 +++ b/m4/stddef_h.m4 @@ -1,5 +1,5 @@ dnl A placeholder for POSIX 2008 , for platforms that have issues. -# stddef_h.m4 serial 1 +# stddef_h.m4 serial 2 dnl Copyright (C) 2009, 2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -33,7 +33,7 @@ AC_DEFUN([gl_STDDEF_MODULE_INDICATOR], [ dnl Use AC_REQUIRE here, so that the default settings are expanded once only. AC_REQUIRE([gl_STDDEF_H_DEFAULTS]) - GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1 + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) ]) AC_DEFUN([gl_STDDEF_H_DEFAULTS], diff --git a/m4/stdio_h.m4 b/m4/stdio_h.m4 index 681fd8b85..f5650cdea 100644 --- a/m4/stdio_h.m4 +++ b/m4/stdio_h.m4 @@ -1,4 +1,4 @@ -# stdio_h.m4 serial 26 +# stdio_h.m4 serial 31 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -8,6 +8,7 @@ AC_DEFUN([gl_STDIO_H], [ AC_REQUIRE([gl_STDIO_H_DEFAULTS]) AC_REQUIRE([AC_C_INLINE]) + AC_REQUIRE([gl_ASM_SYMBOL_PREFIX]) gl_CHECK_NEXT_HEADERS([stdio.h]) dnl No need to create extra modules for these functions. Everyone who uses dnl likely needs them. @@ -37,16 +38,16 @@ AC_DEFUN([gl_STDIO_H], dnl guaranteed by C89. gl_WARN_ON_USE_PREPARE([[#include ]], [dprintf fpurge fseeko ftello getdelim getline popen renameat - snprintf vdprintf vsnprintf]) + snprintf tmpfile vdprintf vsnprintf]) ]) AC_DEFUN([gl_STDIO_MODULE_INDICATOR], [ dnl Use AC_REQUIRE here, so that the default settings are expanded once only. AC_REQUIRE([gl_STDIO_H_DEFAULTS]) - GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1 + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) dnl Define it also as a C macro, for the benefit of the unit tests. - gl_MODULE_INDICATOR([$1]) + gl_MODULE_INDICATOR_FOR_TESTS([$1]) ]) AC_DEFUN([gl_STDIO_H_DEFAULTS], @@ -83,6 +84,7 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS], GNULIB_SNPRINTF=0; AC_SUBST([GNULIB_SNPRINTF]) GNULIB_SPRINTF_POSIX=0; AC_SUBST([GNULIB_SPRINTF_POSIX]) GNULIB_STDIO_H_SIGPIPE=0; AC_SUBST([GNULIB_STDIO_H_SIGPIPE]) + GNULIB_TMPFILE=0; AC_SUBST([GNULIB_TMPFILE]) GNULIB_VASPRINTF=0; AC_SUBST([GNULIB_VASPRINTF]) GNULIB_VDPRINTF=0; AC_SUBST([GNULIB_VDPRINTF]) GNULIB_VFPRINTF=0; AC_SUBST([GNULIB_VFPRINTF]) @@ -99,6 +101,8 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS], HAVE_DECL_SNPRINTF=1; AC_SUBST([HAVE_DECL_SNPRINTF]) HAVE_DECL_VSNPRINTF=1; AC_SUBST([HAVE_DECL_VSNPRINTF]) HAVE_DPRINTF=1; AC_SUBST([HAVE_DPRINTF]) + HAVE_FSEEKO=1; AC_SUBST([HAVE_FSEEKO]) + HAVE_FTELLO=1; AC_SUBST([HAVE_FTELLO]) HAVE_RENAMEAT=1; AC_SUBST([HAVE_RENAMEAT]) HAVE_VASPRINTF=1; AC_SUBST([HAVE_VASPRINTF]) HAVE_VDPRINTF=1; AC_SUBST([HAVE_VDPRINTF]) @@ -125,6 +129,7 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS], REPLACE_SNPRINTF=0; AC_SUBST([REPLACE_SNPRINTF]) REPLACE_SPRINTF=0; AC_SUBST([REPLACE_SPRINTF]) REPLACE_STDIO_WRITE_FUNCS=0; AC_SUBST([REPLACE_STDIO_WRITE_FUNCS]) + REPLACE_TMPFILE=0; AC_SUBST([REPLACE_TMPFILE]) REPLACE_VASPRINTF=0; AC_SUBST([REPLACE_VASPRINTF]) REPLACE_VDPRINTF=0; AC_SUBST([REPLACE_VDPRINTF]) REPLACE_VFPRINTF=0; AC_SUBST([REPLACE_VFPRINTF]) diff --git a/m4/stdlib_h.m4 b/m4/stdlib_h.m4 index 77344bda8..dd84796d2 100644 --- a/m4/stdlib_h.m4 +++ b/m4/stdlib_h.m4 @@ -1,4 +1,4 @@ -# stdlib_h.m4 serial 23 +# stdlib_h.m4 serial 28 dnl Copyright (C) 2007-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -33,18 +33,19 @@ AC_DEFUN([gl_STDLIB_H], #if HAVE_RANDOM_H # include #endif - ]], [atoll canonicalize_file_name getloadavg getsubopt mkdtemp - mkostemp mkostemps mkstemp mkstemps random_r initstat_r srandom_r - setstate_r realpath rpmatch setenv strtod strtoll strtoull unsetenv]) + ]], [atoll canonicalize_file_name getloadavg getsubopt grantpt mkdtemp + mkostemp mkostemps mkstemp mkstemps ptsname random_r initstat_r srandom_r + setstate_r realpath rpmatch setenv strtod strtoll strtoull unlockpt + unsetenv]) ]) 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 + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) dnl Define it also as a C macro, for the benefit of the unit tests. - gl_MODULE_INDICATOR([$1]) + gl_MODULE_INDICATOR_FOR_TESTS([$1]) ]) AC_DEFUN([gl_STDLIB_H_DEFAULTS], @@ -54,12 +55,14 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS], GNULIB_CANONICALIZE_FILE_NAME=0; AC_SUBST([GNULIB_CANONICALIZE_FILE_NAME]) GNULIB_GETLOADAVG=0; AC_SUBST([GNULIB_GETLOADAVG]) GNULIB_GETSUBOPT=0; AC_SUBST([GNULIB_GETSUBOPT]) + GNULIB_GRANTPT=0; AC_SUBST([GNULIB_GRANTPT]) GNULIB_MALLOC_POSIX=0; AC_SUBST([GNULIB_MALLOC_POSIX]) GNULIB_MKDTEMP=0; AC_SUBST([GNULIB_MKDTEMP]) GNULIB_MKOSTEMP=0; AC_SUBST([GNULIB_MKOSTEMP]) GNULIB_MKOSTEMPS=0; AC_SUBST([GNULIB_MKOSTEMPS]) GNULIB_MKSTEMP=0; AC_SUBST([GNULIB_MKSTEMP]) GNULIB_MKSTEMPS=0; AC_SUBST([GNULIB_MKSTEMPS]) + GNULIB_PTSNAME=0; AC_SUBST([GNULIB_PTSNAME]) GNULIB_PUTENV=0; AC_SUBST([GNULIB_PUTENV]) GNULIB_RANDOM_R=0; AC_SUBST([GNULIB_RANDOM_R]) GNULIB_REALLOC_POSIX=0; AC_SUBST([GNULIB_REALLOC_POSIX]) @@ -69,6 +72,7 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS], GNULIB_STRTOD=0; AC_SUBST([GNULIB_STRTOD]) GNULIB_STRTOLL=0; AC_SUBST([GNULIB_STRTOLL]) GNULIB_STRTOULL=0; AC_SUBST([GNULIB_STRTOULL]) + GNULIB_UNLOCKPT=0; AC_SUBST([GNULIB_UNLOCKPT]) GNULIB_UNSETENV=0; AC_SUBST([GNULIB_UNSETENV]) dnl Assume proper GNU behavior unless another module says otherwise. HAVE_ATOLL=1; AC_SUBST([HAVE_ATOLL]) @@ -76,11 +80,14 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS], HAVE_CANONICALIZE_FILE_NAME=1; AC_SUBST([HAVE_CANONICALIZE_FILE_NAME]) HAVE_DECL_GETLOADAVG=1; AC_SUBST([HAVE_DECL_GETLOADAVG]) HAVE_GETSUBOPT=1; AC_SUBST([HAVE_GETSUBOPT]) + HAVE_GRANTPT=1; AC_SUBST([HAVE_GRANTPT]) HAVE_MALLOC_POSIX=1; AC_SUBST([HAVE_MALLOC_POSIX]) HAVE_MKDTEMP=1; AC_SUBST([HAVE_MKDTEMP]) HAVE_MKOSTEMP=1; AC_SUBST([HAVE_MKOSTEMP]) HAVE_MKOSTEMPS=1; AC_SUBST([HAVE_MKOSTEMPS]) + HAVE_MKSTEMP=1; AC_SUBST([HAVE_MKSTEMP]) HAVE_MKSTEMPS=1; AC_SUBST([HAVE_MKSTEMPS]) + HAVE_PTSNAME=1; AC_SUBST([HAVE_PTSNAME]) HAVE_RANDOM_R=1; AC_SUBST([HAVE_RANDOM_R]) HAVE_REALLOC_POSIX=1; AC_SUBST([HAVE_REALLOC_POSIX]) HAVE_REALPATH=1; AC_SUBST([HAVE_REALPATH]) @@ -91,6 +98,7 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS], HAVE_STRTOULL=1; AC_SUBST([HAVE_STRTOULL]) HAVE_STRUCT_RANDOM_DATA=1; AC_SUBST([HAVE_STRUCT_RANDOM_DATA]) HAVE_SYS_LOADAVG_H=0; AC_SUBST([HAVE_SYS_LOADAVG_H]) + HAVE_UNLOCKPT=1; AC_SUBST([HAVE_UNLOCKPT]) HAVE_UNSETENV=1; AC_SUBST([HAVE_UNSETENV]) REPLACE_CANONICALIZE_FILE_NAME=0; AC_SUBST([REPLACE_CANONICALIZE_FILE_NAME]) REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP]) diff --git a/m4/string_h.m4 b/m4/string_h.m4 index a8a366c70..1977aecf9 100644 --- a/m4/string_h.m4 +++ b/m4/string_h.m4 @@ -5,7 +5,7 @@ # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 12 +# serial 17 # Written by Paul Eggert. @@ -26,17 +26,19 @@ AC_DEFUN([gl_HEADER_STRING_H_BODY], dnl corresponding gnulib module is not in use, and which is not dnl guaranteed by C89. gl_WARN_ON_USE_PREPARE([[#include - ]], [memmem mempcpy memrchr rawmemchr stpcpy stpncpy strchrnul strdup - strndup strnlen strpbrk strsep strcasestr strtok_r strsignal strverscmp]) + ]], + [memmem mempcpy memrchr rawmemchr stpcpy stpncpy strchrnul strdup + strncat strndup strnlen strpbrk strsep strcasestr strtok_r strsignal + strverscmp]) ]) AC_DEFUN([gl_STRING_MODULE_INDICATOR], [ dnl Use AC_REQUIRE here, so that the default settings are expanded once only. AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) - GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1 + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) dnl Define it also as a C macro, for the benefit of the unit tests. - gl_MODULE_INDICATOR([$1]) + gl_MODULE_INDICATOR_FOR_TESTS([$1]) ]) AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS], @@ -50,6 +52,7 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS], GNULIB_STPNCPY=0; AC_SUBST([GNULIB_STPNCPY]) GNULIB_STRCHRNUL=0; AC_SUBST([GNULIB_STRCHRNUL]) GNULIB_STRDUP=0; AC_SUBST([GNULIB_STRDUP]) + GNULIB_STRNCAT=0; AC_SUBST([GNULIB_STRNCAT]) GNULIB_STRNDUP=0; AC_SUBST([GNULIB_STRNDUP]) GNULIB_STRNLEN=0; AC_SUBST([GNULIB_STRNLEN]) GNULIB_STRPBRK=0; AC_SUBST([GNULIB_STRPBRK]) @@ -76,6 +79,7 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS], GNULIB_STRVERSCMP=0; AC_SUBST([GNULIB_STRVERSCMP]) HAVE_MBSLEN=0; AC_SUBST([HAVE_MBSLEN]) dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_MEMCHR=1; AC_SUBST([HAVE_MEMCHR]) HAVE_DECL_MEMMEM=1; AC_SUBST([HAVE_DECL_MEMMEM]) HAVE_MEMPCPY=1; AC_SUBST([HAVE_MEMPCPY]) HAVE_DECL_MEMRCHR=1; AC_SUBST([HAVE_DECL_MEMRCHR]) @@ -90,16 +94,18 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS], HAVE_STRSEP=1; AC_SUBST([HAVE_STRSEP]) HAVE_STRCASESTR=1; AC_SUBST([HAVE_STRCASESTR]) HAVE_DECL_STRTOK_R=1; AC_SUBST([HAVE_DECL_STRTOK_R]) - HAVE_DECL_STRERROR=1; AC_SUBST([HAVE_DECL_STRERROR]) HAVE_DECL_STRSIGNAL=1; AC_SUBST([HAVE_DECL_STRSIGNAL]) HAVE_STRVERSCMP=1; AC_SUBST([HAVE_STRVERSCMP]) REPLACE_MEMCHR=0; AC_SUBST([REPLACE_MEMCHR]) REPLACE_MEMMEM=0; AC_SUBST([REPLACE_MEMMEM]) + REPLACE_STPNCPY=0; AC_SUBST([REPLACE_STPNCPY]) REPLACE_STRDUP=0; AC_SUBST([REPLACE_STRDUP]) REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR]) REPLACE_STRCASESTR=0; AC_SUBST([REPLACE_STRCASESTR]) REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR]) + REPLACE_STRNCAT=0; AC_SUBST([REPLACE_STRNCAT]) REPLACE_STRNDUP=0; AC_SUBST([REPLACE_STRNDUP]) + REPLACE_STRNLEN=0; AC_SUBST([REPLACE_STRNLEN]) REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL]) REPLACE_STRTOK_R=0; AC_SUBST([REPLACE_STRTOK_R]) UNDEFINE_STRTOK_R=0; AC_SUBST([UNDEFINE_STRTOK_R]) diff --git a/m4/strings_h.m4 b/m4/strings_h.m4 index 26aa1f782..4374c7cbe 100644 --- a/m4/strings_h.m4 +++ b/m4/strings_h.m4 @@ -1,7 +1,7 @@ # Configure a replacement for . -# serial 2 +# serial 3 -# Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. +# Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -28,7 +28,7 @@ AC_DEFUN([gl_STRINGS_MODULE_INDICATOR], [ dnl Use AC_REQUIRE here, so that the default settings are expanded once only. AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS]) - GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1 + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) ]) AC_DEFUN([gl_HEADER_STRINGS_H_DEFAULTS], diff --git a/m4/sys_file_h.m4 b/m4/sys_file_h.m4 index fac106a09..d33e15a37 100644 --- a/m4/sys_file_h.m4 +++ b/m4/sys_file_h.m4 @@ -1,5 +1,5 @@ # Configure a replacement for . -# serial 4 +# serial 5 # Copyright (C) 2008-2010 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation @@ -32,7 +32,7 @@ AC_DEFUN([gl_HEADER_SYS_FILE_H], AC_DEFUN([gl_HEADER_SYS_FILE_MODULE_INDICATOR], [ AC_REQUIRE([gl_HEADER_SYS_FILE_H_DEFAULTS]) - GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1 + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) ]) AC_DEFUN([gl_HEADER_SYS_FILE_H_DEFAULTS], diff --git a/m4/sys_socket_h.m4 b/m4/sys_socket_h.m4 index 993514c25..9f4db5623 100644 --- a/m4/sys_socket_h.m4 +++ b/m4/sys_socket_h.m4 @@ -1,4 +1,4 @@ -# sys_socket_h.m4 serial 16 +# sys_socket_h.m4 serial 17 dnl Copyright (C) 2005-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -125,9 +125,9 @@ AC_DEFUN([gl_SYS_SOCKET_MODULE_INDICATOR], [ dnl Use AC_REQUIRE here, so that the default settings are expanded once only. AC_REQUIRE([gl_SYS_SOCKET_H_DEFAULTS]) - GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1 + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) dnl Define it also as a C macro, for the benefit of the unit tests. - gl_MODULE_INDICATOR([$1]) + gl_MODULE_INDICATOR_FOR_TESTS([$1]) ]) AC_DEFUN([gl_SYS_SOCKET_H_DEFAULTS], diff --git a/m4/sys_stat_h.m4 b/m4/sys_stat_h.m4 index 54d74caa9..7181c253b 100644 --- a/m4/sys_stat_h.m4 +++ b/m4/sys_stat_h.m4 @@ -1,4 +1,4 @@ -# sys_stat_h.m4 serial 23 -*- Autoconf -*- +# sys_stat_h.m4 serial 24 -*- Autoconf -*- dnl Copyright (C) 2006-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -38,9 +38,9 @@ AC_DEFUN([gl_SYS_STAT_MODULE_INDICATOR], [ dnl Use AC_REQUIRE here, so that the default settings are expanded once only. AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) - GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1 + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) dnl Define it also as a C macro, for the benefit of the unit tests. - gl_MODULE_INDICATOR([$1]) + gl_MODULE_INDICATOR_FOR_TESTS([$1]) ]) AC_DEFUN([gl_SYS_STAT_H_DEFAULTS], diff --git a/m4/time_h.m4 b/m4/time_h.m4 index f572b8594..b88ba94da 100644 --- a/m4/time_h.m4 +++ b/m4/time_h.m4 @@ -64,10 +64,10 @@ AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC], AC_DEFUN([gl_TIME_MODULE_INDICATOR], [ dnl Use AC_REQUIRE here, so that the default settings are expanded once only. - AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) - GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1 + AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) dnl Define it also as a C macro, for the benefit of the unit tests. - gl_MODULE_INDICATOR([$1]) + gl_MODULE_INDICATOR_FOR_TESTS([$1]) ]) AC_DEFUN([gl_HEADER_TIME_H_DEFAULTS], @@ -77,12 +77,16 @@ AC_DEFUN([gl_HEADER_TIME_H_DEFAULTS], GNULIB_STRPTIME=0; AC_SUBST([GNULIB_STRPTIME]) GNULIB_TIMEGM=0; AC_SUBST([GNULIB_TIMEGM]) GNULIB_TIME_R=0; AC_SUBST([GNULIB_TIME_R]) + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_LOCALTIME_R=1; AC_SUBST([HAVE_LOCALTIME_R]) + HAVE_NANOSLEEP=1; AC_SUBST([HAVE_NANOSLEEP]) + HAVE_STRPTIME=1; AC_SUBST([HAVE_STRPTIME]) + HAVE_TIMEGM=1; AC_SUBST([HAVE_TIMEGM]) dnl If another module says to replace or to not replace, do that. dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK; dnl this lets maintainers check for portability. REPLACE_LOCALTIME_R=GNULIB_PORTCHECK; AC_SUBST([REPLACE_LOCALTIME_R]) REPLACE_MKTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_MKTIME]) REPLACE_NANOSLEEP=GNULIB_PORTCHECK; AC_SUBST([REPLACE_NANOSLEEP]) - REPLACE_STRPTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_STRPTIME]) REPLACE_TIMEGM=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TIMEGM]) ]) diff --git a/m4/time_r.m4 b/m4/time_r.m4 dissimilarity index 66% index b5938e796..9e82d39ff 100644 --- a/m4/time_r.m4 +++ b/m4/time_r.m4 @@ -1,44 +1,54 @@ -dnl Reentrant time functions like localtime_r. - -dnl Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, -dnl 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. - -dnl Written by Paul Eggert. - -AC_DEFUN([gl_TIME_R], -[ - dnl Persuade glibc and Solaris to declare localtime_r. - AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) - - AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) - AC_REQUIRE([AC_C_RESTRICT]) - - AC_CACHE_CHECK([whether localtime_r is compatible with its POSIX signature], - [gl_cv_time_r_posix], - [AC_COMPILE_IFELSE([AC_LANG_PROGRAM( - [[#include ]], - [[/* We don't need to append 'restrict's to the argument types, - even though the POSIX signature has the 'restrict's, - since C99 says they can't affect type compatibility. */ - struct tm * (*ptr) (time_t const *, struct tm *) = localtime_r; - if (ptr) return 0; - /* Check the return type is a pointer. On HP-UX 10 it is 'int'. */ - *localtime_r (0, 0);]])], - [gl_cv_time_r_posix=yes], - [gl_cv_time_r_posix=no])]) - if test $gl_cv_time_r_posix = yes; then - REPLACE_LOCALTIME_R=0 - else - REPLACE_LOCALTIME_R=1 - AC_LIBOBJ([time_r]) - gl_PREREQ_TIME_R - fi -]) - -# Prerequisites of lib/time_r.c. -AC_DEFUN([gl_PREREQ_TIME_R], [ - : -]) +dnl Reentrant time functions: localtime_r, gmtime_r. + +dnl Copyright (C) 2003, 2006-2010 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. + +dnl Written by Paul Eggert. + +AC_DEFUN([gl_TIME_R], +[ + dnl Persuade glibc and Solaris to declare localtime_r. + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + + AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) + AC_REQUIRE([AC_C_RESTRICT]) + + AC_CHECK_FUNCS_ONCE([localtime_r]) + if test $ac_cv_func_localtime_r = yes; then + AC_CACHE_CHECK([whether localtime_r is compatible with its POSIX signature], + [gl_cv_time_r_posix], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[#include ]], + [[/* We don't need to append 'restrict's to the argument types, + even though the POSIX signature has the 'restrict's, + since C99 says they can't affect type compatibility. */ + struct tm * (*ptr) (time_t const *, struct tm *) = localtime_r; + if (ptr) return 0; + /* Check the return type is a pointer. + On HP-UX 10 it is 'int'. */ + *localtime_r (0, 0);]]) + ], + [gl_cv_time_r_posix=yes], + [gl_cv_time_r_posix=no]) + ]) + if test $gl_cv_time_r_posix = yes; then + REPLACE_LOCALTIME_R=0 + else + REPLACE_LOCALTIME_R=1 + fi + else + HAVE_LOCALTIME_R=0 + fi + if test $HAVE_LOCALTIME_R = 0 || test $REPLACE_LOCALTIME_R = 1; then + AC_LIBOBJ([time_r]) + gl_PREREQ_TIME_R + fi +]) + +# Prerequisites of lib/time_r.c. +AC_DEFUN([gl_PREREQ_TIME_R], [ + : +]) diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4 index f6c35d2a7..48d06c742 100644 --- a/m4/unistd_h.m4 +++ b/m4/unistd_h.m4 @@ -1,4 +1,4 @@ -# unistd_h.m4 serial 40 +# unistd_h.m4 serial 46 dnl Copyright (C) 2006-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -38,17 +38,18 @@ AC_DEFUN([gl_UNISTD_H], ]], [chown dup2 dup3 environ euidaccess faccessat fchdir fchownat fsync ftruncate getcwd getdomainname getdtablesize getgroups gethostname getlogin getlogin_r getpagesize getusershell setusershell - endusershell lchown link linkat lseek pipe2 pread readlink readlinkat - rmdir sleep symlink symlinkat unlink unlinkat usleep]) + endusershell lchown link linkat lseek pipe2 pread pwrite readlink + readlinkat rmdir sleep symlink symlinkat ttyname_r unlink unlinkat + usleep]) ]) AC_DEFUN([gl_UNISTD_MODULE_INDICATOR], [ dnl Use AC_REQUIRE here, so that the default settings are expanded once only. AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) - GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1 + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) dnl Define it also as a C macro, for the benefit of the unit tests. - gl_MODULE_INDICATOR([$1]) + gl_MODULE_INDICATOR_FOR_TESTS([$1]) ]) AC_DEFUN([gl_UNISTD_H_DEFAULTS], @@ -79,12 +80,14 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS], GNULIB_LSEEK=0; AC_SUBST([GNULIB_LSEEK]) GNULIB_PIPE2=0; AC_SUBST([GNULIB_PIPE2]) GNULIB_PREAD=0; AC_SUBST([GNULIB_PREAD]) + GNULIB_PWRITE=0; AC_SUBST([GNULIB_PWRITE]) 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_TTYNAME_R=0; AC_SUBST([GNULIB_TTYNAME_R]) GNULIB_UNISTD_H_GETOPT=0; AC_SUBST([GNULIB_UNISTD_H_GETOPT]) GNULIB_UNISTD_H_SIGPIPE=0; AC_SUBST([GNULIB_UNISTD_H_SIGPIPE]) GNULIB_UNLINK=0; AC_SUBST([GNULIB_UNLINK]) @@ -97,6 +100,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS], HAVE_DUP3=1; AC_SUBST([HAVE_DUP3]) HAVE_EUIDACCESS=1; AC_SUBST([HAVE_EUIDACCESS]) HAVE_FACCESSAT=1; AC_SUBST([HAVE_FACCESSAT]) + HAVE_FCHDIR=1; AC_SUBST([HAVE_FCHDIR]) HAVE_FCHOWNAT=1; AC_SUBST([HAVE_FCHOWNAT]) HAVE_FSYNC=1; AC_SUBST([HAVE_FSYNC]) HAVE_FTRUNCATE=1; AC_SUBST([HAVE_FTRUNCATE]) @@ -106,28 +110,30 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS], HAVE_GETHOSTNAME=1; AC_SUBST([HAVE_GETHOSTNAME]) HAVE_GETLOGIN=1; AC_SUBST([HAVE_GETLOGIN]) HAVE_GETPAGESIZE=1; AC_SUBST([HAVE_GETPAGESIZE]) - HAVE_GETUSERSHELL=1; AC_SUBST([HAVE_GETUSERSHELL]) HAVE_LCHOWN=1; AC_SUBST([HAVE_LCHOWN]) HAVE_LINK=1; AC_SUBST([HAVE_LINK]) HAVE_LINKAT=1; AC_SUBST([HAVE_LINKAT]) HAVE_PIPE2=1; AC_SUBST([HAVE_PIPE2]) HAVE_PREAD=1; AC_SUBST([HAVE_PREAD]) + HAVE_PWRITE=1; AC_SUBST([HAVE_PWRITE]) 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_TTYNAME_R=1; AC_SUBST([HAVE_TTYNAME_R]) + HAVE_UNLINKAT=1; AC_SUBST([HAVE_UNLINKAT]) + HAVE_USLEEP=1; AC_SUBST([HAVE_USLEEP]) HAVE_DECL_ENVIRON=1; AC_SUBST([HAVE_DECL_ENVIRON]) HAVE_DECL_GETLOGIN_R=1; AC_SUBST([HAVE_DECL_GETLOGIN_R]) + HAVE_DECL_GETPAGESIZE=1; AC_SUBST([HAVE_DECL_GETPAGESIZE]) + HAVE_DECL_GETUSERSHELL=1; AC_SUBST([HAVE_DECL_GETUSERSHELL]) HAVE_OS_H=0; AC_SUBST([HAVE_OS_H]) HAVE_SYS_PARAM_H=0; AC_SUBST([HAVE_SYS_PARAM_H]) - HAVE_UNLINKAT=1; AC_SUBST([HAVE_UNLINKAT]) - HAVE_USLEEP=1; AC_SUBST([HAVE_USLEEP]) REPLACE_CHOWN=0; AC_SUBST([REPLACE_CHOWN]) REPLACE_CLOSE=0; AC_SUBST([REPLACE_CLOSE]) REPLACE_DUP=0; AC_SUBST([REPLACE_DUP]) REPLACE_DUP2=0; AC_SUBST([REPLACE_DUP2]) - REPLACE_FCHDIR=0; AC_SUBST([REPLACE_FCHDIR]) REPLACE_FCHOWNAT=0; AC_SUBST([REPLACE_FCHOWNAT]) REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD]) REPLACE_GETGROUPS=0; AC_SUBST([REPLACE_GETGROUPS]) @@ -137,10 +143,12 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS], REPLACE_LINKAT=0; AC_SUBST([REPLACE_LINKAT]) REPLACE_LSEEK=0; AC_SUBST([REPLACE_LSEEK]) REPLACE_PREAD=0; AC_SUBST([REPLACE_PREAD]) + REPLACE_PWRITE=0; AC_SUBST([REPLACE_PWRITE]) REPLACE_READLINK=0; AC_SUBST([REPLACE_READLINK]) REPLACE_RMDIR=0; AC_SUBST([REPLACE_RMDIR]) REPLACE_SLEEP=0; AC_SUBST([REPLACE_SLEEP]) REPLACE_SYMLINK=0; AC_SUBST([REPLACE_SYMLINK]) + REPLACE_TTYNAME_R=0; AC_SUBST([REPLACE_TTYNAME_R]) REPLACE_UNLINK=0; AC_SUBST([REPLACE_UNLINK]) REPLACE_UNLINKAT=0; AC_SUBST([REPLACE_UNLINKAT]) REPLACE_USLEEP=0; AC_SUBST([REPLACE_USLEEP]) diff --git a/m4/vasnprintf.m4 b/m4/vasnprintf.m4 index 50a20cca2..ebe3c52cd 100644 --- a/m4/vasnprintf.m4 +++ b/m4/vasnprintf.m4 @@ -1,4 +1,4 @@ -# vasnprintf.m4 serial 29 +# vasnprintf.m4 serial 31 dnl Copyright (C) 2002-2004, 2006-2010 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,7 @@ AC_DEFUN([gl_PREREQ_PRINTF_PARSE], # Prerequisites of lib/vasnprintf.c. AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF], [ + AC_REQUIRE([AC_C_INLINE]) AC_REQUIRE([AC_FUNC_ALLOCA]) AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) AC_REQUIRE([gt_TYPE_WCHAR_T]) @@ -62,6 +63,17 @@ AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF], dnl Use the _snprintf function only if it is declared (because on NetBSD it dnl is defined as a weak alias of snprintf; we prefer to use the latter). AC_CHECK_DECLS([_snprintf], , , [#include ]) + dnl We can avoid a lot of code by assuming that snprintf's return value + dnl conforms to ISO C99. So check that. + AC_REQUIRE([gl_SNPRINTF_RETVAL_C99]) + case "$gl_cv_func_snprintf_retval_c99" in + *yes) + AC_DEFINE([HAVE_SNPRINTF_RETVAL_C99], [1], + [Define if the return value of the snprintf function is the number of + of bytes (excluding the terminating NUL) that would have been produced + if the buffer had been large enough.]) + ;; + esac ]) # Extra prerequisites of lib/vasnprintf.c for supporting 'long double' diff --git a/m4/visibility.m4 b/m4/visibility.m4 index 35a6dc0e7..077c4765e 100644 --- a/m4/visibility.m4 +++ b/m4/visibility.m4 @@ -1,5 +1,5 @@ -# visibility.m4 serial 2 (gettext-0.18) -dnl Copyright (C) 2005, 2008, 2009, 2010 Free Software Foundation, Inc. +# visibility.m4 serial 3 (gettext-0.18) +dnl Copyright (C) 2005, 2008-2010 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. @@ -26,15 +26,37 @@ AC_DEFUN([gl_VISIBILITY], CFLAG_VISIBILITY= HAVE_VISIBILITY=0 if test -n "$GCC"; then + dnl First, check whether -Werror can be added to the command line, or + dnl whether it leads to an error because of some other option that the + dnl user has put into $CC $CFLAGS $CPPFLAGS. + AC_MSG_CHECKING([whether the -Werror option is usable]) + AC_CACHE_VAL([gl_cv_cc_vis_werror], [ + gl_save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -Werror" + AC_TRY_COMPILE([], [], + [gl_cv_cc_vis_werror=yes], + [gl_cv_cc_vis_werror=no]) + CFLAGS="$gl_save_CFLAGS"]) + AC_MSG_RESULT([$gl_cv_cc_vis_werror]) + dnl Now check whether visibility declarations are supported. AC_MSG_CHECKING([for simple visibility declarations]) AC_CACHE_VAL([gl_cv_cc_visibility], [ gl_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -fvisibility=hidden" + dnl We use the option -Werror and a function dummyfunc, because on some + dnl platforms (Cygwin 1.7) the use of -fvisibility triggers a warning + dnl "visibility attribute not supported in this configuration; ignored" + dnl at the first function definition in every compilation unit, and we + dnl don't want to use the option in this case. + if test $gl_cv_cc_vis_werror = yes; then + CFLAGS="$CFLAGS -Werror" + fi AC_TRY_COMPILE( [extern __attribute__((__visibility__("hidden"))) int hiddenvar; extern __attribute__((__visibility__("default"))) int exportedvar; extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void); - extern __attribute__((__visibility__("default"))) int exportedfunc (void);], + extern __attribute__((__visibility__("default"))) int exportedfunc (void); + void dummyfunc (void) {}], [], [gl_cv_cc_visibility=yes], [gl_cv_cc_visibility=no]) diff --git a/m4/wchar_h.m4 b/m4/wchar_h.m4 index 0bce51c6b..8cae82dd0 100644 --- a/m4/wchar_h.m4 +++ b/m4/wchar_h.m4 @@ -7,7 +7,7 @@ dnl with or without modifications, as long as this notice is preserved. dnl Written by Eric Blake. -# wchar_h.m4 serial 32 +# wchar_h.m4 serial 33 AC_DEFUN([gl_WCHAR_H], [ @@ -107,9 +107,9 @@ AC_DEFUN([gl_WCHAR_MODULE_INDICATOR], [ dnl Use AC_REQUIRE here, so that the default settings are expanded once only. AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) - GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1 + gl_MODULE_INDICATOR_SET_VARIABLE([$1]) dnl Define it also as a C macro, for the benefit of the unit tests. - gl_MODULE_INDICATOR([$1]) + gl_MODULE_INDICATOR_FOR_TESTS([$1]) ]) AC_DEFUN([gl_WCHAR_H_DEFAULTS], diff --git a/maint.mk b/maint.mk index 7d84b6c3b..644fbb648 100644 --- a/maint.mk +++ b/maint.mk @@ -27,7 +27,8 @@ build_aux ?= $(srcdir)/build-aux # Do not save the original name or timestamp in the .tar.gz file. # Use --rsyncable if available. gzip_rsyncable := \ - $(shell gzip --help 2>/dev/null|grep rsyncable >/dev/null && echo --rsyncable) + $(shell gzip --help 2>/dev/null|grep rsyncable >/dev/null \ + && printf %s --rsyncable) GZIP_ENV = '--no-name --best $(gzip_rsyncable)' GIT = git @@ -129,34 +130,124 @@ sc_m_rules_ = $(patsubst %, %.m, $(syntax-check-rules)) .PHONY: $(sc_m_rules_) $(sc_m_rules_): @echo $(patsubst sc_%.m, %, $@) - -local-check := $(filter-out $(local-checks-to-skip), $(local-checks-available)) + @date +%s.%N > .sc-start-$(basename $@) + +# Compute and print the elapsed time for each syntax-check rule. +sc_z_rules_ = $(patsubst %, %.z, $(syntax-check-rules)) +.PHONY: $(sc_z_rules_) +$(sc_z_rules_): %.z: % + @end=$$(date +%s.%N); \ + start=$$(cat .sc-start-$*); \ + rm -f .sc-start-$*; \ + awk -v s=$$start -v e=$$end \ + 'END {printf "%.2f $(patsubst sc_%,%,$*)\n", e - s}' < /dev/null + +# The patsubst here is to replace each sc_% rule with its sc_%.z wrapper +# that computes and prints elapsed time. +local-check := \ + $(patsubst sc_%, sc_%.z, \ + $(filter-out $(local-checks-to-skip), $(local-checks-available))) syntax-check: $(local-check) -# @grep -nE '# *include <(limits|std(def|arg|bool))\.h>' \ -# $$(find -type f -name '*.[chly]') && \ -# { echo '$(ME): found conditional include' 1>&2; \ -# exit 1; } || : - -# grep -nE '^# *include <(string|stdlib)\.h>' \ -# $(srcdir)/{lib,src}/*.[chy] && \ -# { echo '$(ME): FIXME' 1>&2; \ -# exit 1; } || : -# FIXME: don't allow `#include .strings\.h' anywhere - -# By default, _prohibit_regexp does not ignore case. + +# _sc_search_regexp +# +# This macro searches for a given construct in the selected files and +# then takes some action. +# +# Parameters (shell variables): +# +# prohibit | require +# +# Regular expression (ERE) denoting either a forbidden construct +# or a required construct. Those arguments are exclusive. +# +# in_vc_files | in_files +# +# grep-E-style regexp denoting the files to check. If no files +# are specified the default are all the files that are under +# version control. +# +# containing | non_containing +# +# Select the files (non) containing strings matching this regexp. +# If both arguments are specified then CONTAINING takes +# precedence. +# +# with_grep_options +# +# Extra options for grep. +# +# ignore_case +# +# Ignore case. +# +# halt +# +# Message to display before to halting execution. + +# By default, _sc_search_regexp does not ignore case. export ignore_case = -_ignore_case = $$(test -n "$$ignore_case" && echo -i || :) +_ignore_case = $$(test -n "$$ignore_case" && printf %s -i || :) -# There are many rules below that prohibit constructs in this package. -# If the offending construct can be matched with a grep-E-style regexp, -# use this macro. The shell variables "re" and "msg" must be defined. -define _prohibit_regexp - dummy=; : so we do not need a semicolon before each use; \ - test "x$$re" != x || { echo '$(ME): re not defined' 1>&2; exit 1; }; \ - test "x$$msg" != x || { echo '$(ME): msg not defined' 1>&2; exit 1; };\ - grep $(_ignore_case) -nE "$$re" $$($(VC_LIST_EXCEPT)) && \ - { echo '$(ME): '"$$msg" 1>&2; exit 1; } || : +define _sc_say_and_exit + dummy=; : so we do not need a semicolon before each use; \ + { printf '%s\n' "$(ME): $$msg" 1>&2; exit 1; }; +endef + +# _sc_search_regexp used to be named _prohibit_regexp. However, +# upgrading to the new definition and leaving the old name undefined +# would usually convert each custom rule using $(_prohibit_regexp) +# (usually defined in cfg.mk) into a no-op. This definition ensures +# that people know right away if they're still using the old name. +# FIXME: remove in 2012. +_prohibit_regexp = \ + $(error '*** you need to s/_prohibit_regexp/_sc_search_regexp/, and adapt') + +define _sc_search_regexp + dummy=; : so we do not need a semicolon before each use; \ + \ + : Check arguments; \ + test -n "$$prohibit" && test -n "$$require" \ + && { msg='Cannot specify both prohibit and require' \ + $(_sc_say_and_exit) } || :; \ + test -z "$$prohibit" && test -z "$$require" \ + && { msg='Should specify either prohibit or require' \ + $(_sc_say_and_exit) } || :; \ + test -n "$$in_vc_files" && test -n "$$in_files" \ + && { msg='Cannot specify both in_vc_files and in_files' \ + $(_sc_say_and_exit) } || :; \ + test "x$$halt" != x \ + || { msg='halt not defined' $(_sc_say_and_exit) }; \ + \ + : Filter by file name; \ + if test -n "$$in_files"; then \ + files=$$(find $(srcdir) | grep -E "$$in_files"); \ + else \ + files=$$($(VC_LIST_EXCEPT)); \ + if test -n "$$in_vc_files"; then \ + files=$$(echo "$$files" | grep -E "$$in_vc_files"); \ + fi; \ + fi; \ + \ + : Filter by content; \ + test -n "$$files" && test -n "$$containing" \ + && { files=$$(grep -l "$$containing" $$files); } || :; \ + test -n "$$files" && test -n "$$non_containing" \ + && { files=$$(grep -vl "$$non_containing" $$files); } || :; \ + \ + : Check for the construct; \ + if test -n "$$files"; then \ + if test -n "$$prohibit"; then \ + grep $$with_grep_options $(_ignore_case) -nE "$$prohibit" $$files \ + && { msg="$$halt" $(_sc_say_and_exit) } || :; \ + else \ + grep $$with_grep_options $(_ignore_case) -LE "$$require" $$files \ + | grep . \ + && { msg="$$halt" $(_sc_say_and_exit) } || :; \ + fi \ + else :; \ + fi || :; endef sc_avoid_if_before_free: @@ -167,29 +258,31 @@ sc_avoid_if_before_free: exit 1; } || : sc_cast_of_argument_to_free: - @re='\&2; exit 1; } || : + @prohibit='error *\(EXIT_SUCCESS,' \ + in_vc_files='\.[chly]$$' \ + halt='found error (EXIT_SUCCESS' \ + $(_sc_search_regexp) # `FATAL:' should be fully upper-cased in error messages # `WARNING:' should be fully upper-cased, or fully lower-cased sc_error_message_warn_fatal: - @grep -nEA2 '[^rp]error \(' $$($(VC_LIST_EXCEPT)) \ + @grep -nEA2 '[^rp]error *\(' $$($(VC_LIST_EXCEPT)) \ | grep -E '"Warning|"Fatal|"fatal' && \ { echo '$(ME): use FATAL, WARNING or warning' 1>&2; \ exit 1; } || : # Error messages should not start with a capital letter sc_error_message_uppercase: - @grep -nEA2 '[^rp]error \(' $$($(VC_LIST_EXCEPT)) \ + @grep -nEA2 '[^rp]error *\(' $$($(VC_LIST_EXCEPT)) \ | grep -E '"[A-Z]' \ | grep -vE '"FATAL|"WARNING|"Java|"C#|PRIuMAX' && \ { echo '$(ME): found capitalized error message' 1>&2; \ @@ -239,35 +333,32 @@ sc_error_message_uppercase: # Error messages should not end with a period sc_error_message_period: - @grep -nEA2 '[^rp]error \(' $$($(VC_LIST_EXCEPT)) \ + @grep -nEA2 '[^rp]error *\(' $$($(VC_LIST_EXCEPT)) \ | grep -E '[^."]\."' && \ { echo '$(ME): found error message ending in period' 1>&2; \ exit 1; } || : sc_file_system: - @re=file''system ignore_case=1 \ - msg='found use of "file''system"; spell it "file system"' \ - $(_prohibit_regexp) + @prohibit=file''system \ + ignore_case=1 \ + halt='found use of "file''system"; spell it "file system"' \ + $(_sc_search_regexp) # Don't use cpp tests of this symbol. All code assumes config.h is included. sc_prohibit_have_config_h: - @grep -n '^# *if.*HAVE''_CONFIG_H' $$($(VC_LIST_EXCEPT)) && \ - { echo '$(ME): found use of HAVE''_CONFIG_H; remove' \ - 1>&2; exit 1; } || : + @prohibit='^# *if.*HAVE''_CONFIG_H' \ + halt='found use of HAVE''_CONFIG_H; remove' \ + $(_sc_search_regexp) # Nearly all .c files must include . However, we also permit this # via inclusion of a package-specific header, if cfg.mk specified one. # config_h_header must be suitable for grep -E. config_h_header ?= sc_require_config_h: - @if $(VC_LIST_EXCEPT) | grep -l '\.c$$' > /dev/null; then \ - grep -EL '^# *include $(config_h_header)' \ - $$($(VC_LIST_EXCEPT) | grep '\.c$$') \ - | grep . && \ - { echo '$(ME): the above files do not include ' \ - 1>&2; exit 1; } || :; \ - else :; \ - fi + @require='^# *include $(config_h_header)' \ + in_vc_files='\.c$$' \ + halt='the above files do not include ' \ + $(_sc_search_regexp) # You must include before including any other header file. # This can possibly be via a package-specific header, if given by cfg.mk. @@ -286,13 +377,14 @@ sc_require_config_h_first: fi sc_prohibit_HAVE_MBRTOWC: - @re='\bHAVE_MBRTOWC\b' msg="do not use $$re; it is always defined" \ - $(_prohibit_regexp) + @prohibit='\bHAVE_MBRTOWC\b' \ + halt="do not use $$prohibit; it is always defined" \ + $(_sc_search_regexp) # To use this "command" macro, you must first define two shell variables: # h: the header, enclosed in <> or "" # re: a regular expression that matches IFF something provided by $h is used. -define _header_without_use +define _sc_header_without_use dummy=; : so we do not need a semicolon before each use; \ h_esc=`echo "$$h"|sed 's/\./\\\\./g'`; \ if $(VC_LIST_EXCEPT) | grep -l '\.c$$' > /dev/null; then \ @@ -307,49 +399,49 @@ endef # Prohibit the inclusion of assert.h without an actual use of assert. sc_prohibit_assert_without_use: - @h='' re='\new(file => "/dev/stdin")->as_string'|sed 's/\?://g' @@ -367,10 +459,10 @@ _xa2 = X([CZ]|N?M)ALLOC sc_prohibit_xalloc_without_use: @h='"xalloc.h"' \ re='\<($(_xa1)|$(_xa2)) *\('\ - $(_header_without_use) + $(_sc_header_without_use) # Extract function names: -# perl -lne '/^(?:extern )?(?:void|char) \*?(\w+) \(/ and print $1' lib/hash.h +# perl -lne '/^(?:extern )?(?:void|char) \*?(\w+) *\(/ and print $1' lib/hash.h _hash_re = \ clear|delete|free|get_(first|next)|insert|lookup|print_statistics|reset_tuning _hash_fn = \<($(_hash_re)) *\( @@ -378,42 +470,43 @@ _hash_struct = (struct )?\<[Hh]ash_(table|tuning)\> sc_prohibit_hash_without_use: @h='"hash.h"' \ re='$(_hash_fn)|$(_hash_struct)'\ - $(_header_without_use) + $(_sc_header_without_use) sc_prohibit_hash_pjw_without_use: @h='"hash-pjw.h"' \ re='\' \ - msg='do not use HAVE''_FCNTL_H or O'_NDELAY \ - $(_prohibit_regexp) + @prohibit='\<(HAVE''_FCNTL_H|O''_NDELAY)\>' \ + halt='do not use HAVE''_FCNTL_H or O'_NDELAY \ + $(_sc_search_regexp) # FIXME: warn about definitions of EXIT_FAILURE, EXIT_SUCCESS, STREQ # Each nonempty ChangeLog line must start with a year number, or a TAB. sc_changelog: - @if $(VC_LIST_EXCEPT) | grep -l '^ChangeLog$$' >/dev/null; then \ - grep -n '^[^12 ]' \ - $$($(VC_LIST_EXCEPT) | grep '^ChangeLog$$') && \ - { echo '$(ME): found unexpected prefix in a ChangeLog' 1>&2; \ - exit 1; } || :; \ - fi + @prohibit='^[^12 ]' \ + in_vc_files='^ChangeLog$$' \ + halt='found unexpected prefix in a ChangeLog' \ + $(_sc_search_regexp) # Ensure that each .c file containing a "main" function also # calls set_program_name. sc_program_name: - @if $(VC_LIST_EXCEPT) | grep -l '\.c$$' > /dev/null; then \ - files=$$(grep -l '^main *(' $$($(VC_LIST_EXCEPT) | grep '\.c$$')); \ - grep -LE 'set_program_name *\(m?argv\[0\]\);' $$files \ - | grep . && \ - { echo '$(ME): the above files do not call set_program_name' \ - 1>&2; exit 1; } || :; \ - else :; \ - fi + @require='set_program_name *\(m?argv\[0\]\);' \ + in_vc_files='\.c$$' \ + containing='^main *(' \ + halt='the above files do not call set_program_name' \ + $(_sc_search_regexp) # Require that the final line of each test-lib.sh-using test be this one: # Exit $fail @@ -500,31 +608,30 @@ sc_require_test_exit_idiom: fi sc_the_the: - @re='\' \ - ignore_case=1 msg='found use of "the ''the";' \ - $(_prohibit_regexp) + @prohibit='\' \ + ignore_case=1 \ + halt='found use of "the ''the";' \ + $(_sc_search_regexp) sc_trailing_blank: - @re='[ ]$$' \ - msg='found trailing blank(s)' \ - $(_prohibit_regexp) + @prohibit='[ ]$$' \ + halt='found trailing blank(s)' \ + $(_sc_search_regexp) # Match lines like the following, but where there is only one space # between the options and the description: # -D, --all-repeated[=delimit-method] print all duplicate lines\n longopt_re = --[a-z][0-9A-Za-z-]*(\[?=[0-9A-Za-z-]*\]?)? sc_two_space_separator_in_usage: - @grep -nE '^ *(-[A-Za-z],)? $(longopt_re) [^ ].*\\$$' \ - $$($(VC_LIST_EXCEPT)) && \ - { echo "$(ME): help2man requires at least two spaces between"; \ - echo "$(ME): an option and its description"; \ - 1>&2; exit 1; } || : + @prohibit='^ *(-[A-Za-z],)? $(longopt_re) [^ ].*\\$$' \ + halt='help2man requires at least two spaces between an option and its description'\ + $(_sc_search_regexp) # Look for diagnostics that aren't marked for translation. # This won't find any for which error's format string is on a separate line. sc_unmarked_diagnostics: @grep -nE \ - '\&2; \ exit 1; } || : @@ -532,43 +639,167 @@ sc_unmarked_diagnostics: # Avoid useless parentheses like those in this example: # #if defined (SYMBOL) || defined (SYM2) sc_useless_cpp_parens: - @grep -n '^# *if .*defined *(' $$($(VC_LIST_EXCEPT)) && \ - { echo '$(ME): found useless parentheses in cpp directive' \ - 1>&2; exit 1; } || : + @prohibit='^# *if .*defined *\(' \ + halt='found useless parentheses in cpp directive' \ + $(_sc_search_regexp) + +# List headers for which HAVE_HEADER_H is always true, assuming you are +# using the appropriate gnulib module. CAUTION: for each "unnecessary" +# #if HAVE_HEADER_H that you remove, be sure that your project explicitly +# requires the gnulib module that guarantees the usability of that header. +gl_assured_headers_ = \ + cd $(gnulib_dir)/lib && echo *.in.h|sed 's/\.in\.h//g' + +# Convert the list of names to upper case, and replace each space with "|". +az_ = abcdefghijklmnopqrstuvwxyz +AZ_ = ABCDEFGHIJKLMNOPQRSTUVWXYZ +gl_header_upper_case_or_ = \ + $$($(gl_assured_headers_) \ + | tr $(az_)/.- $(AZ_)___ \ + | tr -s ' ' '|' \ + ) +sc_prohibit_always_true_header_tests: + @or=$(gl_header_upper_case_or_); \ + re="HAVE_($$or)_H"; \ + prohibit='\<'"$$re"'\>' \ + halt='do not test the above HAVE_
_H symbol(s);\n'\ +' with the corresponding gnulib module, they are always true' \ + $(_sc_search_regexp) + +# ================================================================== +gl_other_headers_ ?= \ + intprops.h \ + openat.h \ + stat-macros.h + +# Perl -lne code to extract "significant" cpp-defined symbols from a +# gnulib header file, eliminating a few common false-positives. +gl_extract_significant_defines_ = \ + /^\# *define ([^_ (][^ (]*)(\s*\(|\s+\w+)/\ + && $$2 !~ /(?:rpl_|_used_without_)/\ + && $$1 !~ /^(?:NSIG|ATTRIBUTE_NORETURN)$$/\ + and print $$1 + +# Create a list of regular expressions matching the names +# of macros that are guaranteed to be defined by parts of gnulib. +define def_sym_regex + gen_h=$(gl_generated_headers_); \ + (cd $(gnulib_dir)/lib; \ + for f in *.in.h $(gl_other_headers_); do \ + perl -lne '$(gl_extract_significant_defines_)' $$f; \ + done; \ + ) | sort -u \ + | grep -Ev '^ATTRIBUTE_NORETURN' \ + | sed 's/^/^ *# *(define|undef) */;s/$$/\\>/' +endef + +# Don't define macros that we already get from gnulib header files. +sc_prohibit_always-defined_macros: + @if test -d $(gnulib_dir); then \ + case $$(echo all: | grep -l -f - Makefile) in Makefile);; *) \ + echo '$(ME): skipping $@: you lack GNU grep' 1>&2; exit 0;; \ + esac; \ + $(def_sym_regex) | grep -E -f - $$($(VC_LIST_EXCEPT)) \ + && { echo '$(ME): define the above via some gnulib .h file' \ + 1>&2; exit 1; } || :; \ + fi +# ================================================================== + +# Prohibit checked in backup files. +sc_prohibit_backup_files: + @$(VC_LIST) | grep '~$$' && \ + { echo '$(ME): found version controlled backup file' 1>&2; \ + exit 1; } || : # Require the latest GPL. sc_GPL_version: - @re='either ''version [^3]' msg='GPL vN, N!=3' \ - $(_prohibit_regexp) + @prohibit='either ''version [^3]' \ + halt='GPL vN, N!=3' \ + $(_sc_search_regexp) # Require the latest GFDL. Two regexp, since some .texi files end up # line wrapping between 'Free Documentation License,' and 'Version'. _GFDL_regexp = (Free ''Documentation.*Version 1\.[^3]|Version 1\.[^3] or any) sc_GFDL_version: - @re='$(_GFDL_regexp)' msg='GFDL vN, N!=3' \ - $(_prohibit_regexp) + @prohibit='$(_GFDL_regexp)' \ + halt='GFDL vN, N!=3' \ + $(_sc_search_regexp) + +# Don't use Texinfo @acronym{} as it is not a good idea. +texinfo_suffix_re_ ?= \.(txi|texi(nfo)?)$$ +sc_texinfo_acronym: + @prohibit='@acronym\{' \ + in_vc_files='$(texinfo_suffix_re_)' \ + halt='found use of Texinfo @acronym{}' \ + $(_sc_search_regexp) cvs_keywords = \ Author|Date|Header|Id|Name|Locker|Log|RCSfile|Revision|Source|State sc_prohibit_cvs_keyword: - @re='\$$($(cvs_keywords))\$$' \ - msg='do not use CVS keyword expansion' \ - $(_prohibit_regexp) + @prohibit='\$$($(cvs_keywords))\$$' \ + halt='do not use CVS keyword expansion' \ + $(_sc_search_regexp) + +# This Perl code is slightly obfuscated. Not only is each "$" doubled +# because it's in a Makefile, but the $$c's are comments; we cannot +# use "#" due to the way the script ends up concatenated onto one line. +# It would be much more concise, and would produce better output (including +# counts) if written as: +# perl -ln -0777 -e '/\n(\n+)$/ and print "$ARGV: ".length $1' ... +# but that would be far less efficient, reading the entire contents +# of each file, rather than just the last two bytes of each. +# +# This is a perl script that is expected to be the single-quoted argument +# to a command-line "-le". The remaining arguments are file names. +# Print the name of each file that ends in two or more newline bytes. +# Exit nonzero if at least one such file is found, otherwise, exit 0. +# Warn about, but otherwise ignore open failure. Ignore seek/read failure. +# +# Use this if you want to remove trailing empty lines from selected files: +# perl -pi -0777 -e 's/\n\n+$/\n/' files... +# +detect_empty_lines_at_EOF_ = \ + foreach my $$f (@ARGV) \ + { \ + open F, "<", $$f or (warn "failed to open $$f: $$!\n"), next; \ + my $$p = sysseek (F, -2, 2); \ + my $$c = "seek failure probably means file has < 2 bytes; ignore"; \ + my $$last_two_bytes; \ + defined $$p and $$p = sysread F, $$last_two_bytes, 2; \ + close F; \ + $$c = "ignore read failure"; \ + $$p && $$last_two_bytes eq "\n\n" and (print $$f), $$fail=1; \ + } \ + END { exit defined $$fail } +sc_prohibit_empty_lines_at_EOF: + @perl -le '$(detect_empty_lines_at_EOF_)' $$($(VC_LIST_EXCEPT)) \ + || { echo '$(ME): the above files end with empty line(s)' \ + 1>&2; exit 1; } || :; \ # Make sure we don't use st_blocks. Use ST_NBLOCKS instead. # This is a bit of a kludge, since it prevents use of the string # even in comments, but for now it does the job with no false positives. sc_prohibit_stat_st_blocks: - @re='[.>]st_blocks' msg='do not use st_blocks; use ST_NBLOCKS' \ - $(_prohibit_regexp) + @prohibit='[.>]st_blocks' \ + halt='do not use st_blocks; use ST_NBLOCKS' \ + $(_sc_search_regexp) # Make sure we don't define any S_IS* macros in src/*.c files. # They're already defined via gnulib's sys/stat.h replacement. sc_prohibit_S_IS_definition: - @re='^ *# *define *S_IS' \ - msg='do not define S_IS* macros; include ' \ - $(_prohibit_regexp) + @prohibit='^ *# *define *S_IS' \ + halt='do not define S_IS* macros; include ' \ + $(_sc_search_regexp) + +_ptm1 = use "test C1 && test C2", not "test C1 -''a C2" +_ptm2 = use "test C1 || test C2", not "test C1 -''o C2" +# Using test's -a and -o operators is not portable. +# We prefer test over [, since the latter is spelled [[ in configure.ac. +sc_prohibit_test_minus_ao: + @prohibit='(\&2; \ - exit 1; } || : + @prohibit='^ [ ]{8}' \ + in_vc_files='akefile|\.mk$$' \ + halt='found TAB-8-space indentation' \ + $(_sc_search_regexp) sc_m4_quote_check: - @grep -nE '(AC_DEFINE(_UNQUOTED)?|AC_DEFUN)\([^[]' \ - $$($(VC_LIST_EXCEPT) | grep -E '(^configure\.ac|\.m4)$$') \ - && { echo '$(ME): quote the first arg to AC_DEF*' 1>&2; \ - exit 1; } || : + @prohibit='(AC_DEFINE(_UNQUOTED)?|AC_DEFUN)\([^[]' \ + in_vc_files='(^configure\.ac|\.m4)$$' \ + halt='quote the first arg to AC_DEF*' \ + $(_sc_search_regexp) fix_po_file_diag = \ 'you have changed the set of files with translatable diagnostics;\n\ @@ -700,9 +931,10 @@ sc_po_check: # path separator of `:', but rather the automake-provided `$(PATH_SEPARATOR)'. msg = '$(ME): Do not use `:'\'' above; use $$(PATH_SEPARATOR) instead' sc_makefile_path_separator_check: - @grep -nE 'PATH[=].*:' \ - $$($(VC_LIST_EXCEPT) | grep -E 'akefile|\.mk$$') \ - && { echo $(msg) 1>&2; exit 1; } || : + @prohibit='PATH[=].*:' \ + in_vc_files='akefile|\.mk$$' \ + halt=$(msg) \ + $(_sc_search_regexp) # Check that `make alpha' will not fail at the end of the process. writable-files: @@ -722,23 +954,43 @@ texi = doc/$(PACKAGE).texi # Make sure that the copyright date in $(v_etc_file) is up to date. # Do the same for the $(sample-test) and the main doc/.texi file. sc_copyright_check: - @if test -f $(v_etc_file); then \ - grep 'enum { COPYRIGHT_YEAR = '$$(date +%Y)' };' $(v_etc_file) \ - >/dev/null \ - || { echo 'out of date copyright in $(v_etc_file); update it' 1>&2; \ - exit 1; }; \ - fi - @if test -f $(sample-test); then \ - grep '# Copyright (C) '$$(date +%Y)' Free' $(sample-test) \ - >/dev/null \ - || { echo 'out of date copyright in $(sample-test); update it' 1>&2; \ - exit 1; }; \ - fi - @if test -f $(texi); then \ - grep 'Copyright @copyright{} .*'$$(date +%Y)' Free' $(texi) \ - >/dev/null \ - || { echo 'out of date copyright in $(texi); update it' 1>&2; \ - exit 1; }; \ + @require='enum { COPYRIGHT_YEAR = '$$(date +%Y)' };' \ + in_files=$(v_etc_file) \ + halt='out of date copyright in $(v_etc_file); update it' \ + $(_sc_search_regexp) + @require='# Copyright \(C\) '$$(date +%Y)' Free' \ + in_vc_files=$(sample-test) \ + halt='out of date copyright in $(sample-test); update it' \ + $(_sc_search_regexp) + @require='Copyright @copyright\{\} .*'$$(date +%Y)' Free' \ + in_vc_files=$(texi) \ + halt='out of date copyright in $(texi); update it' \ + $(_sc_search_regexp) + +# If tests/help-version exists and seems to be new enough, assume that its +# use of init.sh and path_prepend_ is correct, and ensure that every other +# use of init.sh is identical. +# This is useful because help-version cross-checks prog --version +# with $(VERSION), which verifies that its path_prepend_ invocation +# sets PATH correctly. This is an inexpensive way to ensure that +# the other init.sh-using tests also get it right. +_hv_file ?= $(srcdir)/tests/help-version +_hv_regex_weak ?= ^ *\. .*/init\.sh" +_hv_regex_strong ?= ^ *\. "\$${srcdir=\.}/init\.sh" +sc_cross_check_PATH_usage_in_tests: + @if test -f $(_hv_file); then \ + grep -l 'VERSION mismatch' $(_hv_file) >/dev/null \ + || { echo "$@: skipped: no such file: $(_hv_file)" 1>&2; \ + exit 0; }; \ + grep -lE '$(_hv_regex_strong)' $(_hv_file) >/dev/null \ + || { echo "$@: $(_hv_file) lacks conforming use of init.sh" 1>&2; \ + exit 1; }; \ + good=$$(grep -E '$(_hv_regex_strong)' $(_hv_file)); \ + grep -LFx "$$good" \ + $$(grep -lE '$(_hv_regex_weak)' $$($(VC_LIST_EXCEPT))) \ + | grep . && \ + { echo "$(ME): the above files use path_prepend_ inconsistently" \ + 1>&2; exit 1; } || :; \ fi # #if HAVE_... will evaluate to false for any non numeric string. @@ -746,21 +998,18 @@ sc_copyright_check: # tests many undefined macros, and so we can't enable that option. # So at least preclude common boolean strings as macro values. sc_Wundef_boolean: - @grep -Ei '^#define.*(yes|no|true|false)$$' '$(CONFIG_INCLUDE)' && \ - { echo 'Use 0 or 1 for macro values' 1>&2; exit 1; } || : + @prohibit='^#define.*(yes|no|true|false)$$' \ + in_files='$(CONFIG_INCLUDE)' \ + halt='Use 0 or 1 for macro values' \ + $(_sc_search_regexp) sc_vulnerable_makefile_CVE-2009-4029: - @files=$$(find $(srcdir) -name Makefile.in); \ - if test -n "$$files"; then \ - grep -E \ - 'perm -777 -exec chmod a\+rwx|chmod 777 \$$\(distdir\)' \ - $$files && \ - { echo '$(ME): the above files are vulnerable; beware of' \ - 'running "make dist*" rules, and upgrade to fixed automake' \ - 'see http://bugzilla.redhat.com/542609 for details' \ - 1>&2; exit 1; } || :; \ - else :; \ - fi + @prohibit='perm -777 -exec chmod a\+rwx|chmod 777 \$$\(distdir\)' \ + in_files=$$(find $(srcdir) -name Makefile.in) \ + halt='the above files are vulnerable; beware of running\n'\ +'"make dist*" rules, and upgrade to fixed automake\n'\ +'see http://bugzilla.redhat.com/542609 for details' \ + $(_sc_search_regexp) vc-diff-check: (unset CDPATH; cd $(srcdir) && $(VC) diff) > vc-diffs || : @@ -785,8 +1034,16 @@ gpg_key_ID ?= \ && gpgv .ann-sig - < /dev/null 2>&1 \ | sed -n '/.*key ID \([0-9A-F]*\)/s//\1/p'; rm -f .ann-sig) +translation_project_ ?= coordinator@translationproject.org +announcement_Cc_ ?= $(translation_project_), $(PACKAGE_BUGREPORT) +announcement_mail_headers_ ?= \ +To: info-gnu@gnu.org \ +Cc: $(announcement_Cc_) \ +Mail-Followup-To: $(PACKAGE_BUGREPORT) + announcement: NEWS ChangeLog $(rel-files) @$(build_aux)/announce-gen \ + --mail-headers='$(announcement_mail_headers_)' \ --release-type=$(RELEASE_TYPE) \ --package=$(PACKAGE) \ --prev=$(PREV_VERSION) \ @@ -870,12 +1127,17 @@ release-prep: $(VC) commit -F .ci-msg -a rm .ci-msg +# Override this with e.g., -s $(srcdir)/some_other_name.texi +# if the default $(PACKAGE)-derived name doesn't apply. +gendocs_options_ ?= + .PHONY: web-manual web-manual: @test -z "$(manual_title)" \ && { echo define manual_title in cfg.mk 1>&2; exit 1; } || : @cd '$(srcdir)/doc'; \ - $(SHELL) ../build-aux/gendocs.sh -o '$(abs_builddir)/doc/manual' \ + $(SHELL) ../build-aux/gendocs.sh $(gendocs_options_) \ + -o '$(abs_builddir)/doc/manual' \ --email $(PACKAGE_BUGREPORT) $(PACKAGE) \ "$(PACKAGE_NAME) - $(manual_title)" @echo " *** Upload the doc/manual directory to web-cvs." @@ -917,10 +1179,12 @@ refresh-po: echo 'en@quot' >> $(PODIR)/LINGUAS && \ ls $(PODIR)/*.po | sed 's/\.po//' | sed 's,$(PODIR)/,,' | sort >> $(PODIR)/LINGUAS + # Running indent once is not idempotent, but running it twice is. INDENT_SOURCES ?= $(C_SOURCES) .PHONY: indent indent: indent $(INDENT_SOURCES) + indent $(INDENT_SOURCES) # If you want to set UPDATE_COPYRIGHT_* environment variables, # put the assignments in this variable. -- 2.20.1