diff options
author | Simon Josefsson <simon@josefsson.org> | 2010-12-06 16:20:45 +0100 |
---|---|---|
committer | Simon Josefsson <simon@josefsson.org> | 2010-12-06 16:20:45 +0100 |
commit | 705bd41bc85effe81660de90acf10f65bb23977c (patch) | |
tree | 9f41b7bbe9b1f9416f94a46cfd995eb0db5c8774 /gl | |
parent | 3ec531a07ddfaddacdef08af6d49abc0eb8d8edd (diff) | |
download | gnutls-705bd41bc85effe81660de90acf10f65bb23977c.tar.gz |
Update gnulib files.
Diffstat (limited to 'gl')
41 files changed, 339 insertions, 155 deletions
diff --git a/gl/Makefile.am b/gl/Makefile.am index e1b67d75da..a4c50aad10 100644 --- a/gl/Makefile.am +++ b/gl/Makefile.am @@ -131,6 +131,7 @@ arpa/inet.h: arpa_inet.in.h $(WARN_ON_USE_H) $(ARG_NONNULL_H) sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ + -e 's|@''HAVE_FEATURES_H''@|$(HAVE_FEATURES_H)|g' \ -e 's|@''NEXT_ARPA_INET_H''@|$(NEXT_ARPA_INET_H)|g' \ -e 's|@''HAVE_ARPA_INET_H''@|$(HAVE_ARPA_INET_H)|g' \ -e 's|@''GNULIB_INET_NTOP''@|$(GNULIB_INET_NTOP)|g' \ @@ -1003,6 +1004,7 @@ string.h: string.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -e 's|@''GNULIB_STRCASESTR''@|$(GNULIB_STRCASESTR)|g' \ -e 's|@''GNULIB_STRTOK_R''@|$(GNULIB_STRTOK_R)|g' \ -e 's|@''GNULIB_STRERROR''@|$(GNULIB_STRERROR)|g' \ + -e 's|@''GNULIB_STRERROR_R''@|$(GNULIB_STRERROR_R)|g' \ -e 's|@''GNULIB_STRSIGNAL''@|$(GNULIB_STRSIGNAL)|g' \ -e 's|@''GNULIB_STRVERSCMP''@|$(GNULIB_STRVERSCMP)|g' \ < $(srcdir)/string.in.h | \ @@ -1022,6 +1024,7 @@ 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_R''@|$(HAVE_DECL_STRERROR_R)|g' \ -e 's|@''HAVE_DECL_STRSIGNAL''@|$(HAVE_DECL_STRSIGNAL)|g' \ -e 's|@''HAVE_STRVERSCMP''@|$(HAVE_STRVERSCMP)|g' \ -e 's|@''REPLACE_STPNCPY''@|$(REPLACE_STPNCPY)|g' \ @@ -1031,6 +1034,7 @@ string.h: string.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \ -e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \ -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \ + -e 's|@''REPLACE_STRERROR_R''@|$(REPLACE_STRERROR_R)|g' \ -e 's|@''REPLACE_STRNCAT''@|$(REPLACE_STRNCAT)|g' \ -e 's|@''REPLACE_STRNDUP''@|$(REPLACE_STRNDUP)|g' \ -e 's|@''REPLACE_STRNLEN''@|$(REPLACE_STRNLEN)|g' \ @@ -1113,6 +1117,7 @@ sys/socket.h: sys_socket.in.h $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H) -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \ -e 's|@''HAVE_WS2TCPIP_H''@|$(HAVE_WS2TCPIP_H)|g' \ -e 's|@''HAVE_STRUCT_SOCKADDR_STORAGE''@|$(HAVE_STRUCT_SOCKADDR_STORAGE)|g' \ + -e 's|@''HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY''@|$(HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY)|g' \ -e 's|@''HAVE_SA_FAMILY_T''@|$(HAVE_SA_FAMILY_T)|g' \ -e 's|@''HAVE_ACCEPT4''@|$(HAVE_ACCEPT4)|g' \ -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ @@ -1330,7 +1335,6 @@ unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -e 's|@''HAVE_FCHOWNAT''@|$(HAVE_FCHOWNAT)|g' \ -e 's|@''HAVE_FSYNC''@|$(HAVE_FSYNC)|g' \ -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \ - -e 's|@''HAVE_GETDOMAINNAME''@|$(HAVE_GETDOMAINNAME)|g' \ -e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \ -e 's|@''HAVE_GETGROUPS''@|$(HAVE_GETGROUPS)|g' \ -e 's|@''HAVE_GETHOSTNAME''@|$(HAVE_GETHOSTNAME)|g' \ @@ -1351,6 +1355,7 @@ unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -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_GETDOMAINNAME''@|$(HAVE_DECL_GETDOMAINNAME)|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' \ @@ -1362,6 +1367,7 @@ unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \ -e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \ -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \ + -e 's|@''REPLACE_GETDOMAINNAME''@|$(REPLACE_GETDOMAINNAME)|g' \ -e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \ -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \ -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \ @@ -1422,6 +1428,12 @@ EXTRA_DIST += $(top_srcdir)/build-aux/vc-list-files ## end gnulib module vc-list-files +## begin gnulib module verify + +libgnu_la_SOURCES += verify.h + +## end gnulib module verify + ## begin gnulib module version-etc libgnu_la_SOURCES += version-etc.h version-etc.c @@ -1465,6 +1477,7 @@ wchar.h: wchar.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ + -e 's|@''HAVE_FEATURES_H''@|$(HAVE_FEATURES_H)|g' \ -e 's|@''NEXT_WCHAR_H''@|$(NEXT_WCHAR_H)|g' \ -e 's|@''HAVE_WCHAR_H''@|$(HAVE_WCHAR_H)|g' \ -e 's|@''GNULIB_BTOWC''@|$(GNULIB_BTOWC)|g' \ diff --git a/gl/arpa_inet.in.h b/gl/arpa_inet.in.h index 84a4006789..f17d642b84 100644 --- a/gl/arpa_inet.in.h +++ b/gl/arpa_inet.in.h @@ -23,6 +23,10 @@ #endif @PRAGMA_COLUMNS@ +#if @HAVE_FEATURES_H@ +# include <features.h> /* for __GLIBC__ */ +#endif + /* Gnulib's sys/socket.h is responsible for pulling in winsock2.h etc under MinGW. But avoid namespace pollution on glibc systems. */ diff --git a/gl/float+.h b/gl/float+.h index b55e5e6def..bf6714ae10 100644 --- a/gl/float+.h +++ b/gl/float+.h @@ -141,8 +141,8 @@ #define SIZEOF_LDBL ((LDBL_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT) /* Verify that SIZEOF_FLT <= sizeof (float) etc. */ -typedef int verify_sizeof_flt[2 * (SIZEOF_FLT <= sizeof (float)) - 1]; -typedef int verify_sizeof_dbl[2 * (SIZEOF_DBL <= sizeof (double)) - 1]; -typedef int verify_sizeof_ldbl[2 * (SIZEOF_LDBL <= sizeof (long double)) - 1]; +typedef int verify_sizeof_flt[SIZEOF_FLT <= sizeof (float) ? 1 : -1]; +typedef int verify_sizeof_dbl[SIZEOF_DBL <= sizeof (double) ? 1 : - 1]; +typedef int verify_sizeof_ldbl[SIZEOF_LDBL <= sizeof (long double) ? 1 : - 1]; #endif /* _FLOATPLUS_H */ diff --git a/gl/gettext.h b/gl/gettext.h index b1145d51a5..f08759e186 100644 --- a/gl/gettext.h +++ b/gl/gettext.h @@ -54,7 +54,7 @@ it now, to make later inclusions of <libintl.h> a NOP. */ #if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3) # include <cstdlib> -# if (__GLIBC__ >= 2) || _GLIBCXX_HAVE_LIBINTL_H +# if (__GLIBC__ >= 2 && !defined __UCLIBC__) || _GLIBCXX_HAVE_LIBINTL_H # include <libintl.h> # endif #endif diff --git a/gl/inet_ntop.c b/gl/inet_ntop.c index baaa23f856..8746114bbe 100644 --- a/gl/inet_ntop.c +++ b/gl/inet_ntop.c @@ -49,7 +49,7 @@ * WARNING: Don't even consider trying to compile this on a system where * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. */ -typedef int verify_int_size[2 * sizeof (int) - 7]; +typedef int verify_int_size[4 <= sizeof (int) ? 1 : -1]; static const char *inet_ntop4 (const unsigned char *src, char *dst, socklen_t size); #if HAVE_IPV6 diff --git a/gl/intprops.h b/gl/intprops.h index 46f4d47d70..0c2787582f 100644 --- a/gl/intprops.h +++ b/gl/intprops.h @@ -68,13 +68,17 @@ # define signed_type_or_expr__(t) 1 # endif +/* Bound on length of the string representing an unsigned integer + value representable in B bits. log10 (2.0) < 146/485. The + smallest value of B where this bound is not tight is 2621. */ +# define INT_BITS_STRLEN_BOUND(b) (((b) * 146 + 484) / 485) + /* Bound on length of the string representing an integer type or expression T. - Subtract 1 for the sign bit if T is signed; log10 (2.0) < 146/485; - add 1 for integer division truncation; add 1 more for a minus sign - if needed. */ + Subtract 1 for the sign bit if T is signed, and then add 1 more for + a minus sign if needed. */ # define INT_STRLEN_BOUND(t) \ - ((sizeof (t) * CHAR_BIT - signed_type_or_expr__ (t)) * 146 / 485 \ - + signed_type_or_expr__ (t) + 1) + (INT_BITS_STRLEN_BOUND (sizeof (t) * CHAR_BIT - signed_type_or_expr__ (t)) \ + + signed_type_or_expr__ (t)) /* Bound on buffer size needed to represent an integer type or expression T, including the terminating null. */ diff --git a/gl/m4/alloca.m4 b/gl/m4/alloca.m4 index f3ee34380c..80d67aad77 100644 --- a/gl/m4/alloca.m4 +++ b/gl/m4/alloca.m4 @@ -1,4 +1,4 @@ -# alloca.m4 serial 9 +# alloca.m4 serial 10 dnl Copyright (C) 2002-2004, 2006-2007, 2009-2010 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation @@ -7,10 +7,6 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_ALLOCA], [ - dnl Work around a bug of AC_EGREP_CPP in autoconf-2.57. - AC_REQUIRE([AC_PROG_CPP]) - AC_REQUIRE([AC_PROG_EGREP]) - AC_REQUIRE([AC_FUNC_ALLOCA]) if test $ac_cv_func_alloca_works = no; then gl_PREREQ_ALLOCA diff --git a/gl/m4/arpa_inet_h.m4 b/gl/m4/arpa_inet_h.m4 index 15a30e2bca..80fdb406b6 100644 --- a/gl/m4/arpa_inet_h.m4 +++ b/gl/m4/arpa_inet_h.m4 @@ -1,5 +1,5 @@ -# arpa_inet_h.m4 serial 8 -dnl Copyright (C) 2006, 2008, 2009, 2010 Free Software Foundation, Inc. +# arpa_inet_h.m4 serial 10 +dnl Copyright (C) 2006, 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. @@ -22,11 +22,13 @@ AC_DEFUN([gl_HEADER_ARPA_INET], dnl <arpa/inet.h> is always overridden, because of GNULIB_POSIXCHECK. gl_CHECK_NEXT_HEADERS([arpa/inet.h]) + AC_REQUIRE([gl_FEATURES_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([[ /* On some systems, this header is not self-consistent. */ -#ifndef __GLIBC__ +#if !(defined __GLIBC__ || defined __UCLIBC__) # include <sys/socket.h> #endif #include <arpa/inet.h> diff --git a/gl/m4/getdelim.m4 b/gl/m4/getdelim.m4 index 4beb1501c2..2bbd5cff6e 100644 --- a/gl/m4/getdelim.m4 +++ b/gl/m4/getdelim.m4 @@ -1,4 +1,4 @@ -# getdelim.m4 serial 6 +# getdelim.m4 serial 7 dnl Copyright (C) 2005-2007, 2009-2010 Free Software Foundation, Inc. dnl @@ -57,7 +57,7 @@ AC_DEFUN([gl_FUNC_GETDELIM], [ #include <features.h> #ifdef __GNU_LIBRARY__ - #if (__GLIBC__ >= 2) + #if (__GLIBC__ >= 2) && !defined __UCLIBC__ Lucky GNU user #endif #endif diff --git a/gl/m4/getline.m4 b/gl/m4/getline.m4 index 83005600d6..0f8e3134d9 100644 --- a/gl/m4/getline.m4 +++ b/gl/m4/getline.m4 @@ -1,4 +1,4 @@ -# getline.m4 serial 21 +# getline.m4 serial 22 dnl Copyright (C) 1998-2003, 2005-2007, 2009-2010 Free Software Foundation, dnl Inc. @@ -65,7 +65,7 @@ AC_DEFUN([gl_FUNC_GETLINE], [ #include <features.h> #ifdef __GNU_LIBRARY__ - #if (__GLIBC__ >= 2) + #if (__GLIBC__ >= 2) && !defined __UCLIBC__ Lucky GNU user #endif #endif diff --git a/gl/m4/getpass.m4 b/gl/m4/getpass.m4 index cb80a65c52..8072e46442 100644 --- a/gl/m4/getpass.m4 +++ b/gl/m4/getpass.m4 @@ -1,4 +1,4 @@ -# getpass.m4 serial 11 +# getpass.m4 serial 12 dnl Copyright (C) 2002-2003, 2005-2006, 2009-2010 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation @@ -8,6 +8,9 @@ dnl with or without modifications, as long as this notice is preserved. # Provide a getpass() function if the system doesn't have it. AC_DEFUN([gl_FUNC_GETPASS], [ + dnl Persuade Solaris <unistd.h> and <stdlib.h> to declare getpass(). + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_REPLACE_FUNCS([getpass]) AC_CHECK_DECLS_ONCE([getpass]) if test $ac_cv_func_getpass = no; then @@ -19,6 +22,9 @@ AC_DEFUN([gl_FUNC_GETPASS], # arbitrary length (not just 8 bytes as on HP-UX). AC_DEFUN([gl_FUNC_GETPASS_GNU], [ + dnl Persuade Solaris <unistd.h> and <stdlib.h> to declare getpass(). + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_CHECK_DECLS_ONCE([getpass]) dnl TODO: Detect when GNU getpass() is already found in glibc. AC_LIBOBJ([getpass]) diff --git a/gl/m4/gnulib-common.m4 b/gl/m4/gnulib-common.m4 index 4c7ac30d0f..d0c8b66287 100644 --- a/gl/m4/gnulib-common.m4 +++ b/gl/m4/gnulib-common.m4 @@ -1,4 +1,4 @@ -# gnulib-common.m4 serial 20 +# gnulib-common.m4 serial 21 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, @@ -102,6 +102,19 @@ AC_DEFUN([gl_MODULE_INDICATOR_FOR_TESTS], [Define to 1 when the gnulib module $1 should be tested.]) ]) +# Test whether <features.h> exists. +# Set HAVE_FEATURES_H. +AC_DEFUN([gl_FEATURES_H], +[ + AC_CHECK_HEADERS_ONCE([features.h]) + if test $ac_cv_header_features_h = yes; then + HAVE_FEATURES_H=1 + else + HAVE_FEATURES_H=0 + fi + AC_SUBST([HAVE_FEATURES_H]) +]) + # m4_foreach_w # is a backport of autoconf-2.59c's m4_foreach_w. # Remove this macro when we can assume autoconf >= 2.60. diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4 index 201ec0f99a..56f86b804a 100644 --- a/gl/m4/gnulib-comp.m4 +++ b/gl/m4/gnulib-comp.m4 @@ -437,6 +437,7 @@ AC_SUBST([LTALLOCA]) # Code from module vasnprintf: gl_FUNC_VASNPRINTF # Code from module vc-list-files: + # Code from module verify: # Code from module version-etc: gl_VERSION_ETC # Code from module version-etc-fsf: @@ -705,6 +706,7 @@ AC_DEFUN([gl_FILE_LIST], [ lib/unistd.in.h lib/vasnprintf.c lib/vasnprintf.h + lib/verify.h lib/version-etc-fsf.c lib/version-etc.c lib/version-etc.h @@ -861,7 +863,6 @@ AC_DEFUN([gl_FILE_LIST], [ tests=lib/getpagesize.c tests=lib/ioctl.c tests=lib/sys_ioctl.in.h - tests=lib/verify.h tests=lib/w32sock.h top/GNUmakefile top/maint.mk diff --git a/gl/m4/mmap-anon.m4 b/gl/m4/mmap-anon.m4 index a6b7b9ac3b..e20fc3c670 100644 --- a/gl/m4/mmap-anon.m4 +++ b/gl/m4/mmap-anon.m4 @@ -1,4 +1,4 @@ -# mmap-anon.m4 serial 8 +# mmap-anon.m4 serial 9 dnl Copyright (C) 2005, 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, @@ -15,10 +15,6 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_MMAP_ANON], [ - dnl Work around a bug of AC_EGREP_CPP in autoconf-2.57. - AC_REQUIRE([AC_PROG_CPP]) - AC_REQUIRE([AC_PROG_EGREP]) - dnl Persuade glibc <sys/mman.h> to define MAP_ANONYMOUS. AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) diff --git a/gl/m4/printf.m4 b/gl/m4/printf.m4 index e850862c01..b1ac37833e 100644 --- a/gl/m4/printf.m4 +++ b/gl/m4/printf.m4 @@ -1,4 +1,4 @@ -# printf.m4 serial 35 +# printf.m4 serial 39 dnl Copyright (C) 2003, 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, @@ -439,16 +439,9 @@ changequote(,)dnl # Guess yes on FreeBSD >= 6. freebsd[1-5]*) gl_cv_func_printf_infinite_long_double="guessing no";; freebsd* | kfreebsd*) gl_cv_func_printf_infinite_long_double="guessing yes";; - # Guess yes on MacOS X >= 10.3. - darwin[1-6].*) gl_cv_func_printf_infinite_long_double="guessing no";; - darwin*) gl_cv_func_printf_infinite_long_double="guessing yes";; # Guess yes on HP-UX >= 11. hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite_long_double="guessing no";; hpux*) gl_cv_func_printf_infinite_long_double="guessing yes";; - # Guess yes on NetBSD >= 3. - netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) - gl_cv_func_printf_infinite_long_double="guessing no";; - netbsd*) gl_cv_func_printf_infinite_long_double="guessing yes";; # If we don't know, assume the worst. *) gl_cv_func_printf_infinite_long_double="guessing no";; esac @@ -533,7 +526,7 @@ int main () AC_EGREP_CPP([BZ2908], [ #include <features.h> #ifdef __GNU_LIBRARY__ - #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 5) || (__GLIBC__ > 2) + #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 5) || (__GLIBC__ > 2)) && !defined __UCLIBC__ BZ2908 #endif #endif @@ -889,8 +882,9 @@ changequote([,])dnl dnl Test whether the *printf family of functions supports large precisions. dnl On mingw, precisions larger than 512 are treated like 512, in integer, -dnl floating-point or pointer output. On BeOS, precisions larger than 1044 -dnl crash the program. +dnl floating-point or pointer output. On Solaris 10/x86, precisions larger +dnl than 510 in floating-point output crash the program. On BeOS, precisions +dnl larger than 1044 crash the program. dnl Result is gl_cv_func_printf_precision. AC_DEFUN([gl_PRINTF_PRECISION], @@ -913,6 +907,8 @@ int main () #endif if (sprintf (buf, "%.4000d %d", 1, 33, 44) < 4000 + 3) return 1; + if (sprintf (buf, "%.4000f %d", 1.0, 33, 44) < 4000 + 5) + return 2; return 0; }]])], [gl_cv_func_printf_precision=yes], @@ -920,7 +916,8 @@ int main () [ changequote(,)dnl case "$host_os" in - # Guess no only on native Win32 and BeOS systems. + # Guess no only on Solaris, native Win32, and BeOS systems. + solaris*) gl_cv_func_printf_precision="guessing no" ;; mingw* | pw*) gl_cv_func_printf_precision="guessing no" ;; beos*) gl_cv_func_printf_precision="guessing no" ;; *) gl_cv_func_printf_precision="guessing yes" ;; @@ -1439,12 +1436,14 @@ dnl 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 dnl glibc 2.5 . . . . . . . . . . . . . . . . . . . . dnl glibc 2.3.6 . . . . # . . . . . . . . . . . . . . . dnl FreeBSD 5.4, 6.1 . . . . # . . . . . . # . # . . . . . . +dnl MacOS X 10.5.8 . . . # # . . . . . . # . . . . . . . . dnl MacOS X 10.3.9 . . . . # . . . . . . # . # . . . . . . dnl OpenBSD 3.9, 4.0 . . # # # # . # . # . # . # . . . . . . dnl Cygwin 1.7.0 (2009) . . . # . . . ? . . . . . ? . . . . . . dnl Cygwin 1.5.25 (2008) . . . # # . . # . . . . . # . . . . . . dnl Cygwin 1.5.19 (2006) # . . # # # . # . # . # # # . . . . . . -dnl Solaris 10 . . # # # . . # . . . # . . . . . . . . +dnl Solaris 11 2010-11 . . # # # . . # . . . # . . . . . . . . +dnl Solaris 10 . . # # # . . # . . . # # . . . . . . . dnl Solaris 2.6 ... 9 # . # # # # . # . . . # . . . . . . . . dnl Solaris 2.5.1 # . # # # # . # . . . # . . # # # # # # dnl AIX 5.2, 7.1 . . # # # . . . . . . # . . . . . . . . @@ -1455,6 +1454,7 @@ dnl HP-UX 10.20 # . # . # # . ? . . # # . . . dnl IRIX 6.5 # . # # # # . # . . . # . . . . # . . . dnl OSF/1 5.1 # . # # # # . . . . . # . . . . # . . # dnl OSF/1 4.0d # . # # # # . . . . . # . . # # # # # # +dnl NetBSD 5.0 . . . # # . . . . . . # . # . . . . . . dnl NetBSD 4.0 . ? ? ? ? ? . ? . ? ? ? ? ? . . . ? ? ? dnl NetBSD 3.0 . . . . # # . ? # # ? # . # . . . . . . dnl Haiku . . . # # # . # . . . . . ? . . . . . . diff --git a/gl/m4/readline.m4 b/gl/m4/readline.m4 index 27f81629a5..7a97ecba91 100644 --- a/gl/m4/readline.m4 +++ b/gl/m4/readline.m4 @@ -1,4 +1,4 @@ -# readline.m4 serial 7 +# readline.m4 serial 8 dnl Copyright (C) 2005, 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, @@ -40,7 +40,12 @@ AC_DEFUN([gl_FUNC_READLINE], AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h> #include <readline/readline.h>]], [[readline((char*)0);]])], - [gl_cv_lib_readline=" -l$extra_lib"]) + [if test -n "$extra_lib"; then + gl_cv_lib_readline="yes, requires -l$extra_lib" + else + gl_cv_lib_readline="yes" + fi + ]) if test "$gl_cv_lib_readline" != no; then break fi @@ -50,9 +55,10 @@ AC_DEFUN([gl_FUNC_READLINE], if test "$gl_cv_lib_readline" != no; then AC_DEFINE([HAVE_READLINE], [1], [Define if you have the readline library.]) - if test "$gl_cv_lib_readline" != " -l"; then - LIBREADLINE="$LIBREADLINE$gl_cv_lib_readline" - LTLIBREADLINE="$LTLIBREADLINE$gl_cv_lib_readline" + extra_lib=`echo "$gl_cv_lib_readline" | sed -n -e 's/yes, requires //p'` + if test -n "$extra_lib"; then + LIBREADLINE="$LIBREADLINE $extra_lib" + LTLIBREADLINE="$LTLIBREADLINE $extra_lib" fi AC_MSG_CHECKING([how to link with libreadline]) AC_MSG_RESULT([$LIBREADLINE]) @@ -68,7 +74,7 @@ AC_DEFUN([gl_FUNC_READLINE], AC_CHECK_HEADERS([readline/readline.h]) - if test $gl_cv_lib_readline = no; then + if test "$gl_cv_lib_readline" = no; then AC_LIBOBJ([readline]) gl_PREREQ_READLINE fi diff --git a/gl/m4/string_h.m4 b/gl/m4/string_h.m4 index 1977aecf91..5844b2d660 100644 --- a/gl/m4/string_h.m4 +++ b/gl/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 17 +# serial 18 # Written by Paul Eggert. @@ -28,8 +28,8 @@ AC_DEFUN([gl_HEADER_STRING_H_BODY], gl_WARN_ON_USE_PREPARE([[#include <string.h> ]], [memmem mempcpy memrchr rawmemchr stpcpy stpncpy strchrnul strdup - strncat strndup strnlen strpbrk strsep strcasestr strtok_r strsignal - strverscmp]) + strncat strndup strnlen strpbrk strsep strcasestr strtok_r strerror_r + strsignal strverscmp]) ]) AC_DEFUN([gl_STRING_MODULE_INDICATOR], @@ -75,6 +75,7 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS], GNULIB_MBSSEP=0; AC_SUBST([GNULIB_MBSSEP]) GNULIB_MBSTOK_R=0; AC_SUBST([GNULIB_MBSTOK_R]) GNULIB_STRERROR=0; AC_SUBST([GNULIB_STRERROR]) + GNULIB_STRERROR_R=0; AC_SUBST([GNULIB_STRERROR_R]) GNULIB_STRSIGNAL=0; AC_SUBST([GNULIB_STRSIGNAL]) GNULIB_STRVERSCMP=0; AC_SUBST([GNULIB_STRVERSCMP]) HAVE_MBSLEN=0; AC_SUBST([HAVE_MBSLEN]) @@ -94,6 +95,7 @@ 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_R=1; AC_SUBST([HAVE_DECL_STRERROR_R]) HAVE_DECL_STRSIGNAL=1; AC_SUBST([HAVE_DECL_STRSIGNAL]) HAVE_STRVERSCMP=1; AC_SUBST([HAVE_STRVERSCMP]) REPLACE_MEMCHR=0; AC_SUBST([REPLACE_MEMCHR]) @@ -103,6 +105,7 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS], REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR]) REPLACE_STRCASESTR=0; AC_SUBST([REPLACE_STRCASESTR]) REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR]) + REPLACE_STRERROR_R=0; AC_SUBST([REPLACE_STRERROR_R]) REPLACE_STRNCAT=0; AC_SUBST([REPLACE_STRNCAT]) REPLACE_STRNDUP=0; AC_SUBST([REPLACE_STRNDUP]) REPLACE_STRNLEN=0; AC_SUBST([REPLACE_STRNLEN]) diff --git a/gl/m4/sys_ioctl_h.m4 b/gl/m4/sys_ioctl_h.m4 index f6face2574..5c342a5b1d 100644 --- a/gl/m4/sys_ioctl_h.m4 +++ b/gl/m4/sys_ioctl_h.m4 @@ -1,4 +1,4 @@ -# sys_ioctl_h.m4 serial 8 +# sys_ioctl_h.m4 serial 9 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, @@ -38,7 +38,7 @@ AC_DEFUN([gl_SYS_IOCTL_H], dnl corresponding gnulib module is not in use. gl_WARN_ON_USE_PREPARE([[#include <sys/ioctl.h> /* Some platforms declare ioctl in the wrong header. */ -#ifndef __GLIBC__ +#if !(defined __GLIBC__ && !defined __UCLIBC__) # include <unistd.h> #endif ]], [ioctl]) diff --git a/gl/m4/sys_select_h.m4 b/gl/m4/sys_select_h.m4 index 95e7818fd8..0e8063ea97 100644 --- a/gl/m4/sys_select_h.m4 +++ b/gl/m4/sys_select_h.m4 @@ -1,4 +1,4 @@ -# sys_select_h.m4 serial 14 +# sys_select_h.m4 serial 15 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, @@ -61,7 +61,7 @@ AC_DEFUN([gl_HEADER_SYS_SELECT], gl_WARN_ON_USE_PREPARE([[ /* Some systems require prerequisite headers. */ #include <sys/types.h> -#if !defined __GLIBC__ && HAVE_SYS_TIME_H +#if !(defined __GLIBC__ && !defined __UCLIBC__) && HAVE_SYS_TIME_H # include <sys/time.h> #endif #include <sys/select.h> diff --git a/gl/m4/sys_socket_h.m4 b/gl/m4/sys_socket_h.m4 index 9f4db56230..c7627cb94e 100644 --- a/gl/m4/sys_socket_h.m4 +++ b/gl/m4/sys_socket_h.m4 @@ -1,4 +1,4 @@ -# sys_socket_h.m4 serial 17 +# sys_socket_h.m4 serial 20 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, @@ -57,6 +57,23 @@ AC_DEFUN([gl_HEADER_SYS_SOCKET], if test $ac_cv_type_sa_family_t = no; then HAVE_SA_FAMILY_T=0 fi + if test $ac_cv_type_struct_sockaddr_storage != no; then + AC_CHECK_MEMBERS([struct sockaddr_storage.ss_family], + [], + [HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY=0], + [#include <sys/types.h> + #ifdef HAVE_SYS_SOCKET_H + #include <sys/socket.h> + #endif + #ifdef HAVE_WS2TCPIP_H + #include <ws2tcpip.h> + #endif + ]) + fi + if test $HAVE_STRUCT_SOCKADDR_STORAGE = 0 || test $HAVE_SA_FAMILY_T = 0 \ + || test $HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY = 0; then + SYS_SOCKET_H='sys/socket.h' + fi gl_PREREQ_SYS_H_WINSOCK2 dnl Check for declarations of anything we want to poison if the @@ -64,10 +81,7 @@ AC_DEFUN([gl_HEADER_SYS_SOCKET], gl_WARN_ON_USE_PREPARE([[ /* Some systems require prerequisite headers. */ #include <sys/types.h> -#if !defined __GLIBC__ && HAVE_SYS_TIME_H -# include <sys/time.h> -#endif -#include <sys/select.h> +#include <sys/socket.h> ]], [socket connect accept bind getpeername getsockname getsockopt listen recv send recvfrom sendto setsockopt shutdown accept4]) ]) @@ -148,6 +162,8 @@ AC_DEFUN([gl_SYS_SOCKET_H_DEFAULTS], GNULIB_SHUTDOWN=0; AC_SUBST([GNULIB_SHUTDOWN]) GNULIB_ACCEPT4=0; AC_SUBST([GNULIB_ACCEPT4]) HAVE_STRUCT_SOCKADDR_STORAGE=1; AC_SUBST([HAVE_STRUCT_SOCKADDR_STORAGE]) + HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY=1; + AC_SUBST([HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY]) HAVE_SA_FAMILY_T=1; AC_SUBST([HAVE_SA_FAMILY_T]) HAVE_ACCEPT4=1; AC_SUBST([HAVE_ACCEPT4]) ]) diff --git a/gl/m4/unistd_h.m4 b/gl/m4/unistd_h.m4 index 48d06c7426..e2f7f2bf45 100644 --- a/gl/m4/unistd_h.m4 +++ b/gl/m4/unistd_h.m4 @@ -1,4 +1,4 @@ -# unistd_h.m4 serial 46 +# unistd_h.m4 serial 48 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, @@ -27,7 +27,7 @@ AC_DEFUN([gl_UNISTD_H], dnl corresponding gnulib module is not in use. gl_WARN_ON_USE_PREPARE([[#include <unistd.h> /* Some systems declare various items in the wrong headers. */ -#ifndef __GLIBC__ +#if !(defined __GLIBC__ && !defined __UCLIBC__) # include <fcntl.h> # include <stdio.h> # include <stdlib.h> @@ -104,7 +104,6 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS], HAVE_FCHOWNAT=1; AC_SUBST([HAVE_FCHOWNAT]) HAVE_FSYNC=1; AC_SUBST([HAVE_FSYNC]) HAVE_FTRUNCATE=1; AC_SUBST([HAVE_FTRUNCATE]) - HAVE_GETDOMAINNAME=1; AC_SUBST([HAVE_GETDOMAINNAME]) HAVE_GETDTABLESIZE=1; AC_SUBST([HAVE_GETDTABLESIZE]) HAVE_GETGROUPS=1; AC_SUBST([HAVE_GETGROUPS]) HAVE_GETHOSTNAME=1; AC_SUBST([HAVE_GETHOSTNAME]) @@ -125,6 +124,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS], 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_GETDOMAINNAME=1; AC_SUBST([HAVE_DECL_GETDOMAINNAME]) 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]) @@ -136,6 +136,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS], REPLACE_DUP2=0; AC_SUBST([REPLACE_DUP2]) REPLACE_FCHOWNAT=0; AC_SUBST([REPLACE_FCHOWNAT]) REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD]) + REPLACE_GETDOMAINNAME=0; AC_SUBST([REPLACE_GETDOMAINNAME]) REPLACE_GETGROUPS=0; AC_SUBST([REPLACE_GETGROUPS]) REPLACE_GETPAGESIZE=0; AC_SUBST([REPLACE_GETPAGESIZE]) REPLACE_LCHOWN=0; AC_SUBST([REPLACE_LCHOWN]) diff --git a/gl/m4/vasnprintf.m4 b/gl/m4/vasnprintf.m4 index ebe3c52cde..9c04520242 100644 --- a/gl/m4/vasnprintf.m4 +++ b/gl/m4/vasnprintf.m4 @@ -1,4 +1,4 @@ -# vasnprintf.m4 serial 31 +# vasnprintf.m4 serial 32 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, @@ -40,6 +40,7 @@ AC_DEFUN([gl_PREREQ_PRINTF_ARGS], # Prequisites of lib/printf-parse.h, lib/printf-parse.c. AC_DEFUN([gl_PREREQ_PRINTF_PARSE], [ + AC_REQUIRE([gl_FEATURES_H]) AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) AC_REQUIRE([gt_TYPE_WCHAR_T]) AC_REQUIRE([gt_TYPE_WINT_T]) diff --git a/gl/m4/wchar_h.m4 b/gl/m4/wchar_h.m4 index 8cae82dd0b..8c8fad96df 100644 --- a/gl/m4/wchar_h.m4 +++ b/gl/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 33 +# wchar_h.m4 serial 35 AC_DEFUN([gl_WCHAR_H], [ @@ -26,6 +26,8 @@ AC_DEFUN([gl_WCHAR_H], fi AC_SUBST([HAVE_WCHAR_H]) + AC_REQUIRE([gl_FEATURES_H]) + AC_REQUIRE([gt_TYPE_WINT_T]) if test $gt_cv_c_wint_t = yes; then HAVE_WINT_T=1 @@ -38,7 +40,7 @@ AC_DEFUN([gl_WCHAR_H], dnl corresponding gnulib module is not in use. gl_WARN_ON_USE_PREPARE([[ /* Some systems require additional headers. */ -#ifndef __GLIBC__ +#if !(defined __GLIBC__ && !defined __UCLIBC__) # include <stddef.h> # include <stdio.h> # include <time.h> diff --git a/gl/printf-parse.c b/gl/printf-parse.c index f612beb5b7..58cd889089 100644 --- a/gl/printf-parse.c +++ b/gl/printf-parse.c @@ -206,6 +206,13 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a) dp->flags |= FLAG_ZERO; cp++; } +#if __GLIBC__ >= 2 && !defined __UCLIBC__ + else if (*cp == 'I') + { + dp->flags |= FLAG_LOCALIZED; + cp++; + } +#endif else break; } diff --git a/gl/printf-parse.h b/gl/printf-parse.h index 0f2b708209..1b27040b7e 100644 --- a/gl/printf-parse.h +++ b/gl/printf-parse.h @@ -23,6 +23,10 @@ ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions. STATIC Set to 'static' to declare the function static. */ +#if HAVE_FEATURES_H +# include <features.h> /* for __GLIBC__, __UCLIBC__ */ +#endif + #include "printf-args.h" @@ -33,6 +37,9 @@ #define FLAG_SPACE 8 /* space flag */ #define FLAG_ALT 16 /* # flag */ #define FLAG_ZERO 32 +#if __GLIBC__ >= 2 && !defined __UCLIBC__ +# define FLAG_LOCALIZED 64 /* I flag, uses localized digits */ +#endif /* arg_index value indicating that no argument is consumed. */ #define ARG_NONE (~(size_t)0) diff --git a/gl/stdint.in.h b/gl/stdint.in.h index 9e81110ae3..9909f57e4b 100644 --- a/gl/stdint.in.h +++ b/gl/stdint.in.h @@ -134,40 +134,53 @@ typedef unsigned int gl_uint32_t; #define int32_t gl_int32_t #define uint32_t gl_uint32_t +/* If the system defines INT64_MAX, assume int64_t works. That way, + if the underlying platform defines int64_t to be a 64-bit long long + int, the code below won't mistakenly define it to be a 64-bit long + int, which would mess up C++ name mangling. */ + +#if INT64_MAX +# define GL_INT64_T +#else /* Do not undefine int64_t if gnulib is not being used with 64-bit types, since otherwise it breaks platforms like Tandem/NSK. */ -#if LONG_MAX >> 31 >> 31 == 1 -# undef int64_t +# if LONG_MAX >> 31 >> 31 == 1 +# undef int64_t typedef long int gl_int64_t; -# define int64_t gl_int64_t -# define GL_INT64_T -#elif defined _MSC_VER -# undef int64_t +# define int64_t gl_int64_t +# define GL_INT64_T +# elif defined _MSC_VER +# undef int64_t typedef __int64 gl_int64_t; -# define int64_t gl_int64_t -# define GL_INT64_T -#elif @HAVE_LONG_LONG_INT@ -# undef int64_t +# define int64_t gl_int64_t +# define GL_INT64_T +# elif @HAVE_LONG_LONG_INT@ +# undef int64_t typedef long long int gl_int64_t; -# define int64_t gl_int64_t -# define GL_INT64_T +# define int64_t gl_int64_t +# define GL_INT64_T +# endif #endif -#if ULONG_MAX >> 31 >> 31 >> 1 == 1 -# undef uint64_t -typedef unsigned long int gl_uint64_t; -# define uint64_t gl_uint64_t +#if UINT64_MAX # define GL_UINT64_T -#elif defined _MSC_VER -# undef uint64_t +#else +# if ULONG_MAX >> 31 >> 31 >> 1 == 1 +# undef uint64_t +typedef unsigned long int gl_uint64_t; +# define uint64_t gl_uint64_t +# define GL_UINT64_T +# elif defined _MSC_VER +# undef uint64_t typedef unsigned __int64 gl_uint64_t; -# define uint64_t gl_uint64_t -# define GL_UINT64_T -#elif @HAVE_UNSIGNED_LONG_LONG_INT@ -# undef uint64_t +# define uint64_t gl_uint64_t +# define GL_UINT64_T +# elif @HAVE_UNSIGNED_LONG_LONG_INT@ +# undef uint64_t typedef unsigned long long int gl_uint64_t; -# define uint64_t gl_uint64_t -# define GL_UINT64_T +# define uint64_t gl_uint64_t +# define GL_UINT64_T +# endif #endif /* Avoid collision with Solaris 2.5.1 <pthread.h> etc. */ @@ -279,7 +292,8 @@ typedef unsigned long int gl_uintmax_t; /* Verify that intmax_t and uintmax_t have the same size. Too much code breaks if this is not the case. If this check fails, the reason is likely to be found in the autoconf macros. */ -typedef int _verify_intmax_size[2 * (sizeof (intmax_t) == sizeof (uintmax_t)) - 1]; +typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t) + ? 1 : -1]; /* 7.18.2. Limits of specified-width integer types */ @@ -311,17 +325,14 @@ typedef int _verify_intmax_size[2 * (sizeof (intmax_t) == sizeof (uintmax_t)) - #define INT32_MAX 2147483647 #define UINT32_MAX 4294967295U -#undef INT64_MIN -#undef INT64_MAX -#ifdef GL_INT64_T +#if defined GL_INT64_T && ! defined INT64_MAX /* Prefer (- INTMAX_C (1) << 63) over (~ INT64_MAX) because SunPRO C 5.0 evaluates the latter incorrectly in preprocessor expressions. */ # define INT64_MIN (- INTMAX_C (1) << 63) # define INT64_MAX INTMAX_C (9223372036854775807) #endif -#undef UINT64_MAX -#ifdef GL_UINT64_T +#if defined GL_UINT64_T && ! defined UINT64_MAX # define UINT64_MAX UINTMAX_C (18446744073709551615) #endif diff --git a/gl/stdio.in.h b/gl/stdio.in.h index fedcdfcc25..45eaa1c22b 100644 --- a/gl/stdio.in.h +++ b/gl/stdio.in.h @@ -57,6 +57,13 @@ # endif #endif +/* Solaris 10 declares renameat in <unistd.h>, not in <stdio.h>. */ +/* But in any case avoid namespace pollution on glibc systems. */ +#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && defined __sun \ + && ! defined __GLIBC__ +# include <unistd.h> +#endif + /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ diff --git a/gl/stdlib.in.h b/gl/stdlib.in.h index 6fe75d330f..e6dcdbc841 100644 --- a/gl/stdlib.in.h +++ b/gl/stdlib.in.h @@ -61,6 +61,9 @@ #endif #if !@HAVE_STRUCT_RANDOM_DATA@ +/* Define 'struct random_data'. + But allow multiple gnulib generated <stdlib.h> replacements to coexist. */ +# if !GNULIB_defined_struct_random_data struct random_data { int32_t *fptr; /* Front pointer. */ @@ -71,6 +74,8 @@ struct random_data int rand_sep; /* Distance between front and rear. */ int32_t *end_ptr; /* Pointer behind state table. */ }; +# define GNULIB_defined_struct_random_data 1 +# endif #endif #if (@GNULIB_MKSTEMP@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) diff --git a/gl/string.in.h b/gl/string.in.h index 3d3af3349a..b0c2ba1e1c 100644 --- a/gl/string.in.h +++ b/gl/string.in.h @@ -51,8 +51,8 @@ #endif /* NetBSD 5.0 declares strsignal in <unistd.h>, not in <string.h>. */ -/* But avoid namespace pollution on glibc systems. */ -#if (@GNULIB_STRSIGNAL@ || defined GNULIB_POSIXCHECK) \ +/* But in any case avoid namespace pollution on glibc systems. */ +#if (@GNULIB_STRSIGNAL@ || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \ && ! defined __GLIBC__ # include <unistd.h> #endif @@ -87,7 +87,7 @@ _GL_CXXALIAS_SYS_CAST2 (memchr, void *, (void const *__s, int __c, size_t __n), void const *, (void const *__s, int __c, size_t __n)); # endif -# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ +# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) _GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n)); _GL_CXXALIASWARN1 (memchr, void const *, @@ -172,7 +172,7 @@ _GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t) _GL_CXXALIAS_SYS_CAST2 (memrchr, void *, (void const *, int, size_t), void const *, (void const *, int, size_t)); -# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ +# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) _GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t)); _GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t)); @@ -202,7 +202,7 @@ _GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in) _GL_CXXALIAS_SYS_CAST2 (rawmemchr, void *, (void const *__s, int __c_in), void const *, (void const *__s, int __c_in)); -# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ +# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) _GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in)); _GL_CXXALIASWARN1 (rawmemchr, void const *, (void const *__s, int __c_in)); @@ -293,7 +293,7 @@ _GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in) _GL_CXXALIAS_SYS_CAST2 (strchrnul, char *, (char const *__s, int __c_in), char const *, (char const *__s, int __c_in)); -# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ +# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) _GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in)); _GL_CXXALIASWARN1 (strchrnul, char const *, (char const *__s, int __c_in)); @@ -439,7 +439,7 @@ _GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept) _GL_CXXALIAS_SYS_CAST2 (strpbrk, char *, (char const *__s, char const *__accept), const char *, (char const *__s, char const *__accept)); -# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ +# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) _GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept)); _GL_CXXALIASWARN1 (strpbrk, char const *, @@ -541,7 +541,7 @@ _GL_CXXALIAS_SYS_CAST2 (strstr, char *, (const char *haystack, const char *needle), const char *, (const char *haystack, const char *needle)); # endif -# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ +# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) _GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle)); _GL_CXXALIASWARN1 (strstr, const char *, @@ -590,7 +590,7 @@ _GL_CXXALIAS_SYS_CAST2 (strcasestr, char *, (const char *haystack, const char *needle), const char *, (const char *haystack, const char *needle)); # endif -# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ +# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) _GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle)); _GL_CXXALIASWARN1 (strcasestr, const char *, @@ -902,6 +902,35 @@ _GL_WARN_ON_USE (strerror, "strerror is unportable - " "use gnulib module strerror to guarantee non-NULL result"); #endif +/* Map any int, typically from errno, into an error message. Multithread-safe. + Uses the POSIX declaration, not the glibc declaration. */ +#if @GNULIB_STRERROR_R@ +# if @REPLACE_STRERROR_R@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef strerror_r +# define strerror_r rpl_strerror_r +# endif +_GL_FUNCDECL_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen) + _GL_ARG_NONNULL ((2))); +_GL_CXXALIAS_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen)); +# else +# if !@HAVE_DECL_STRERROR_R@ +_GL_FUNCDECL_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen) + _GL_ARG_NONNULL ((2))); +# endif +_GL_CXXALIAS_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen)); +# endif +# if @HAVE_DECL_STRERROR_R@ +_GL_CXXALIASWARN (strerror_r); +# endif +#elif defined GNULIB_POSIXCHECK +# undef strerror_r +# if HAVE_RAW_DECL_STRERROR_R +_GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - " + "use gnulib module strerror_r-posix for portability"); +# endif +#endif + #if @GNULIB_STRSIGNAL@ # if @REPLACE_STRSIGNAL@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) diff --git a/gl/sys_select.in.h b/gl/sys_select.in.h index 4ce48e2f8d..49347b63f8 100644 --- a/gl/sys_select.in.h +++ b/gl/sys_select.in.h @@ -51,8 +51,9 @@ /* On Solaris 10, <sys/select.h> provides an FD_ZERO implementation that relies on memset(), but without including <string.h>. - But avoid namespace pollution on glibc systems. */ -# ifndef __GLIBC__ + But in any case avoid namespace pollution on glibc systems. */ +# if (defined __OpenBSD__ || defined __sun || defined __osf__ || defined __BEOS__) \ + && ! defined __GLIBC__ # include <string.h> # endif diff --git a/gl/sys_socket.in.h b/gl/sys_socket.in.h index 8fded705cf..339cabb958 100644 --- a/gl/sys_socket.in.h +++ b/gl/sys_socket.in.h @@ -70,7 +70,14 @@ typedef unsigned short sa_family_t; #endif -#if !@HAVE_STRUCT_SOCKADDR_STORAGE@ +#if @HAVE_STRUCT_SOCKADDR_STORAGE@ +/* Make the 'struct sockaddr_storage' field 'ss_family' visible on AIX 7.1. */ +# if !@HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY@ +# ifndef ss_family +# define ss_family __ss_family +# endif +# endif +#else # include <alignof.h> /* Code taken from glibc sysdeps/unix/sysv/linux/bits/socket.h on 2009-05-08, licensed under LGPLv2.1+, plus portability fixes. */ diff --git a/gl/tests/Makefile.am b/gl/tests/Makefile.am index 9aaf714ca7..acfc33e34c 100644 --- a/gl/tests/Makefile.am +++ b/gl/tests/Makefile.am @@ -298,7 +298,7 @@ check_PROGRAMS += test-select test-select-fd test-select-stdin test_select_LDADD = $(LDADD) @LIBSOCKET@ $(INET_PTON_LIB) test_select_fd_LDADD = $(LDADD) @LIBSOCKET@ test_select_stdin_LDADD = $(LDADD) @LIBSOCKET@ -EXTRA_DIST += signature.h test-select.c test-select-fd.c test-select-in.sh test-select-out.sh test-select-stdin.c +EXTRA_DIST += macros.h signature.h test-select.c test-select-fd.c test-select-in.sh test-select-out.sh test-select-stdin.c ## end gnulib module select-tests @@ -489,12 +489,6 @@ EXTRA_DIST += test-vc-list-files-git.sh test-vc-list-files-cvs.sh init.sh ## end gnulib module vc-list-files-tests -## begin gnulib module verify - -libtests_a_SOURCES += verify.h - -## end gnulib module verify - ## begin gnulib module verify-tests TESTS_ENVIRONMENT += MAKE='$(MAKE)' diff --git a/gl/tests/init.sh b/gl/tests/init.sh index a57de77a2f..14f3b198d4 100644 --- a/gl/tests/init.sh +++ b/gl/tests/init.sh @@ -330,6 +330,12 @@ setup_() || fail_ "failed to create temporary directory in $initial_cwd_" cd "$test_dir_" + # As autoconf-generated configure scripts do, ensure that IFS + # is defined initially, so that saving and restoring $IFS works. + gl_init_sh_nl_=' +' + IFS=" "" $gl_init_sh_nl_" + # This trap statement, along with a trap on 0 below, ensure that the # temporary directory, $test_dir_, is removed upon exit as well as # upon receipt of any of the listed signals. diff --git a/gl/tests/test-select-stdin.c b/gl/tests/test-select-stdin.c index e9cee96f1f..c88698cd3f 100644 --- a/gl/tests/test-select-stdin.c +++ b/gl/tests/test-select-stdin.c @@ -24,6 +24,8 @@ #include <sys/time.h> #include <unistd.h> +#include "macros.h" + int main (void) { @@ -67,14 +69,15 @@ main (void) exit (1); } /* Timeout */ - printf ("."); fflush (stdout); + printf ("."); + ASSERT (fflush (stdout) == 0); } else { char c; printf ("Input available! Trying to read 1 byte...\n"); - read (0, &c, 1); + ASSERT (read (0, &c, 1) == 1); } } } diff --git a/gl/tests/test-select.c b/gl/tests/test-select.c index 884e823394..9c895c3b21 100644 --- a/gl/tests/test-select.c +++ b/gl/tests/test-select.c @@ -48,6 +48,8 @@ SIGNATURE_CHECK (FD_ZERO, void, (fd_set *)); #include <sys/ioctl.h> #include <errno.h> +#include "macros.h" + enum { SEL_IN = 1, SEL_OUT = 2, SEL_EXC = 4 }; #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ @@ -263,9 +265,9 @@ test_connect_first (void) addrlen = sizeof (ia); c2 = accept (s, (struct sockaddr *) &ia, &addrlen); - close (s); - close (c1); - close (c2); + ASSERT (close (s) == 0); + ASSERT (close (c1) == 0); + ASSERT (close (c2) == 0); } @@ -289,26 +291,26 @@ test_accept_first (void) { addrlen = sizeof (ia); c = accept (s, (struct sockaddr *) &ia, &addrlen); - close (s); - write (c, "foo", 3); - read (c, buf, 3); + ASSERT (close (s) == 0); + ASSERT (write (c, "foo", 3) == 3); + ASSERT (read (c, buf, 3) == 3); shutdown (c, SHUT_RD); - close (c); + ASSERT (close (c) == 0); exit (0); } else { - close (s); + ASSERT (close (s) == 0); c = connect_to_socket (true); if (do_select_nowait (c, SEL_OUT) != SEL_OUT) failed ("cannot write after blocking connect"); - write (c, "foo", 3); + ASSERT (write (c, "foo", 3) == 3); wait (&pid); if (do_select_wait (c, SEL_IN) != SEL_IN) failed ("cannot read data left in the socket by closed process"); - read (c, buf, 3); - write (c, "foo", 3); - close (c); + ASSERT (read (c, buf, 3) == 3); + ASSERT (write (c, "foo", 3) == 3); + ASSERT (close (c) == 0); } #endif } @@ -325,13 +327,13 @@ test_pair (int rd, int wd) if (do_select_nowait (wd, SEL_IN | SEL_OUT | SEL_EXC) != SEL_OUT) failed ("expecting writability before writing"); - write (wd, "foo", 3); + ASSERT (write (wd, "foo", 3) == 3); if (do_select_wait (rd, SEL_IN) != SEL_IN) failed ("expecting readability after writing"); if (do_select_nowait (rd, SEL_IN) != SEL_IN) failed ("expecting readability after writing"); - read (rd, buf, 3); + ASSERT (read (rd, buf, 3) == 3); } @@ -347,12 +349,12 @@ test_socket_pair (void) int c1 = connect_to_socket (false); int c2 = accept (s, (struct sockaddr *) &ia, &addrlen); - close (s); + ASSERT (close (s) == 0); test_pair (c1, c2); - close (c1); - write (c2, "foo", 3); - close (c2); + ASSERT (close (c1) == 0); + ASSERT (write (c2, "foo", 3) == 3); + ASSERT (close (c2) == 0); } @@ -363,10 +365,10 @@ test_pipe (void) { int fd[2]; - pipe (fd); + ASSERT (pipe (fd) == 0); test_pair (fd[0], fd[1]); - close (fd[0]); - close (fd[1]); + ASSERT (close (fd[0]) == 0); + ASSERT (close (fd[1]) == 0); } diff --git a/gl/tests/test-update-copyright.sh b/gl/tests/test-update-copyright.sh index fbf4f23bb4..ea700c902b 100755 --- a/gl/tests/test-update-copyright.sh +++ b/gl/tests/test-update-copyright.sh @@ -25,6 +25,7 @@ fi # Ensure the update-copyright program gets found. PATH=$abs_aux_dir:$PATH +export PATH TMP_BASE=update-copyright.test trap 'rm -f $TMP_BASE*' 0 1 2 3 15 diff --git a/gl/time.in.h b/gl/time.in.h index 1d34416f56..0f6adac43f 100644 --- a/gl/time.in.h +++ b/gl/time.in.h @@ -84,6 +84,15 @@ struct timespec # endif # endif +/* Per http://austingroupbugs.net/view.php?id=327, POSIX requires + time_t to be an integer type, even though C99 permits floating + point. We don't know of any implementation that uses floating + point, and it is much easier to write code that doesn't have to + worry about that corner case, so we force the issue. */ +struct __time_t_must_be_integral { + unsigned int __floating_time_t_unsupported : (time_t) 1; +}; + /* Sleep for at least RQTP seconds unless interrupted, If interrupted, return -1 and store the remaining time into RMTP. See <http://www.opengroup.org/susv3xsh/nanosleep.html>. */ diff --git a/gl/unistd.in.h b/gl/unistd.in.h index fb44e48158..fcf7c43904 100644 --- a/gl/unistd.in.h +++ b/gl/unistd.in.h @@ -61,14 +61,16 @@ /* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */ /* But avoid namespace pollution on glibc systems. */ #if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \ - || (@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK)) \ + || ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \ + && defined __CYGWIN__)) \ && ! defined __GLIBC__ # include <stdio.h> #endif /* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>. */ /* But avoid namespace pollution on glibc systems. */ -#if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ +#if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && defined __CYGWIN__ \ + && ! defined __GLIBC__ # include <fcntl.h> #endif @@ -86,6 +88,13 @@ # include <io.h> #endif +/* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>. */ +/* But avoid namespace pollution on glibc systems. */ +#if @GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__) \ + && !defined __GLIBC__ +# include <netdb.h> +#endif + #if (@GNULIB_WRITE@ || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \ || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK) /* Get ssize_t. */ @@ -549,13 +558,21 @@ _GL_WARN_ON_USE (getcwd, "getcwd is unportable - " Null terminate it if the name is shorter than LEN. If the NIS domain name is longer than LEN, set errno = EINVAL and return -1. Return 0 if successful, otherwise set errno and return -1. */ -# if !@HAVE_GETDOMAINNAME@ +# if @REPLACE_GETDOMAINNAME@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef getdomainname +# define getdomainname rpl_getdomainname +# endif +_GL_FUNCDECL_RPL (getdomainname, int, (char *name, size_t len) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (getdomainname, int, (char *name, size_t len)); +# else +# if !@HAVE_DECL_GETDOMAINNAME@ _GL_FUNCDECL_SYS (getdomainname, int, (char *name, size_t len) _GL_ARG_NONNULL ((1))); +# endif +_GL_CXXALIAS_SYS (getdomainname, int, (char *name, size_t len)); # endif -/* Need to cast, because on MacOS X 10.5 systems, the second parameter is - int len. */ -_GL_CXXALIAS_SYS_CAST (getdomainname, int, (char *name, size_t len)); _GL_CXXALIASWARN (getdomainname); #elif defined GNULIB_POSIXCHECK # undef getdomainname diff --git a/gl/vasnprintf.c b/gl/vasnprintf.c index e618901ba2..1e9cd431e6 100644 --- a/gl/vasnprintf.c +++ b/gl/vasnprintf.c @@ -88,6 +88,8 @@ /* Checked size_t computations. */ #include "xsize.h" +#include "verify.h" + #if (NEED_PRINTF_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL # include <math.h> # include "float+.h" @@ -277,7 +279,7 @@ decimal_point_char (void) multithread-safe on glibc systems and MacOS X systems, but is not required to be multithread-safe by POSIX. sprintf(), however, is multithread-safe. localeconv() is rarely multithread-safe. */ -# if HAVE_NL_LANGINFO && (__GLIBC__ || (defined __APPLE__ && defined __MACH__)) +# if HAVE_NL_LANGINFO && (__GLIBC__ || defined __UCLIBC__ || (defined __APPLE__ && defined __MACH__)) point = nl_langinfo (RADIXCHAR); # elif 1 char pointbuf[5]; @@ -322,11 +324,11 @@ is_infinite_or_zerol (long double x) typedef unsigned int mp_limb_t; # define GMP_LIMB_BITS 32 -typedef int mp_limb_verify[2 * (sizeof (mp_limb_t) * CHAR_BIT == GMP_LIMB_BITS) - 1]; +verify (sizeof (mp_limb_t) * CHAR_BIT == GMP_LIMB_BITS); typedef unsigned long long mp_twolimb_t; # define GMP_TWOLIMB_BITS 64 -typedef int mp_twolimb_verify[2 * (sizeof (mp_twolimb_t) * CHAR_BIT == GMP_TWOLIMB_BITS) - 1]; +verify (sizeof (mp_twolimb_t) * CHAR_BIT == GMP_TWOLIMB_BITS); /* Representation of a bignum >= 0. */ typedef struct @@ -2621,7 +2623,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, size_t characters; # if !DCHAR_IS_TCHAR /* This code assumes that TCHAR_T is 'char'. */ - typedef int TCHAR_T_verify[2 * (sizeof (TCHAR_T) == 1) - 1]; + verify (sizeof (TCHAR_T) == 1); TCHAR_T *tmpsrc; DCHAR_T *tmpdst; size_t tmpdst_len; @@ -4597,6 +4599,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, TCHAR_T *fbp; unsigned int prefix_count; int prefixes[2] IF_LINT (= { 0 }); + int orig_errno; #if !USE_SNPRINTF size_t tmp_length; TCHAR_T tmpbuf[700]; @@ -4751,6 +4754,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, *fbp++ = ' '; if (flags & FLAG_ALT) *fbp++ = '#'; +#if __GLIBC__ >= 2 && !defined __UCLIBC__ + if (flags & FLAG_LOCALIZED) + *fbp++ = 'I'; +#endif if (!pad_ourselves) { if (flags & FLAG_ZERO) @@ -4834,14 +4841,15 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, #endif *fbp = dp->conversion; #if USE_SNPRINTF -# if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)) +# if !(((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined __UCLIBC__) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)) fbp[1] = '%'; fbp[2] = 'n'; fbp[3] = '\0'; # else /* On glibc2 systems from glibc >= 2.3 - probably also older - ones - we know that snprintf's returns value conforms to - ISO C 99: the gl_SNPRINTF_DIRECTIVE_N test passes. + ones - we know that snprintf's return value conforms to + ISO C 99: the tests gl_SNPRINTF_RETVAL_C99 and + gl_SNPRINTF_TRUNCATION_C99 pass. Therefore we can avoid using %n in this situation. On glibc2 systems from 2004-10-18 or newer, the use of %n in format strings in writable memory may crash the program @@ -4900,6 +4908,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, *(TCHAR_T *) (result + length) = '\0'; #endif + orig_errno = errno; + for (;;) { int count = -1; @@ -5284,8 +5294,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, DCHAR_T *tmpdst; size_t tmpdst_len; /* This code assumes that TCHAR_T is 'char'. */ - typedef int TCHAR_T_verify - [2 * (sizeof (TCHAR_T) == 1) - 1]; + verify (sizeof (TCHAR_T) == 1); # if USE_SNPRINTF tmpsrc = (TCHAR_T *) (result + length); # else @@ -5498,6 +5507,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, length += count; break; } + errno = orig_errno; #undef pad_ourselves #undef prec_ourselves } diff --git a/gl/tests/verify.h b/gl/verify.h index 4ad780c8fa..4ad780c8fa 100644 --- a/gl/tests/verify.h +++ b/gl/verify.h diff --git a/gl/wchar.in.h b/gl/wchar.in.h index c0ff224478..c22dc06a0b 100644 --- a/gl/wchar.in.h +++ b/gl/wchar.in.h @@ -53,6 +53,10 @@ #define _GL_ALREADY_INCLUDING_WCHAR_H +#if @HAVE_FEATURES_H@ +# include <features.h> /* for __GLIBC__ */ +#endif + /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before <wchar.h>. BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be |