summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTon Voon <ton.voon@opsera.com>2010-06-21 12:50:34 (GMT)
committerTon Voon <ton.voon@opsera.com>2010-06-21 12:50:34 (GMT)
commitaab4e991d4e4213249058dd073543551c9c88c35 (patch)
treeefc8cfb750476203fed0c3fc2d04fb1b274e8a81
parent29cf8ff2fea1a8f0e1f56b9f8a07fd7ee68c1770 (diff)
downloadmonitoring-plugins-aab4e991d4e4213249058dd073543551c9c88c35.tar.gz
Sync with the latest Gnulib code (86ba51d)
Signed-off-by: Ton Voon <ton.voon@opsera.com>
-rw-r--r--gl/Makefile.am23
-rw-r--r--gl/config.charset42
-rw-r--r--gl/error.c32
-rw-r--r--gl/getopt.c39
-rw-r--r--gl/getopt_int.h69
-rw-r--r--gl/localcharset.c7
-rw-r--r--gl/m4/asm-underscore.m448
-rw-r--r--gl/m4/getopt.m441
-rw-r--r--gl/m4/gettext.m46
-rw-r--r--gl/m4/gnulib-common.m410
-rw-r--r--gl/m4/gnulib-comp.m46
-rw-r--r--gl/m4/iconv.m419
-rw-r--r--gl/m4/intl.m493
-rw-r--r--gl/m4/lib-link.m446
-rw-r--r--gl/m4/netdb_h.m417
-rw-r--r--gl/m4/onceonly.m410
-rw-r--r--gl/m4/po.m42
-rw-r--r--gl/m4/printf.m44
-rw-r--r--gl/m4/sockpfaf.m43
-rw-r--r--gl/m4/stdint.m414
-rw-r--r--gl/m4/stdio_h.m43
-rw-r--r--gl/m4/string_h.m43
-rw-r--r--gl/m4/strnlen.m422
-rw-r--r--gl/m4/time_h.m419
-rw-r--r--gl/m4/unistd_h.m411
-rw-r--r--gl/m4/vasnprintf.m414
-rw-r--r--gl/m4/visibility.m426
-rw-r--r--gl/netdb.in.h30
-rw-r--r--gl/regex_internal.c4
-rw-r--r--gl/regex_internal.h2
-rw-r--r--gl/stdbool.in.h3
-rw-r--r--gl/stdio-write.c2
-rw-r--r--gl/stdio.in.h22
-rw-r--r--gl/strerror.c3
-rw-r--r--gl/string.in.h15
-rw-r--r--gl/sys_stat.in.h6
-rw-r--r--gl/time.in.h12
-rw-r--r--gl/unistd.in.h56
-rw-r--r--gl/vasnprintf.c601
-rw-r--r--gl/verify.h41
-rw-r--r--gl/wchar.in.h2
41 files changed, 932 insertions, 496 deletions
diff --git a/gl/Makefile.am b/gl/Makefile.am
index e2dc38b..7edf495 100644
--- a/gl/Makefile.am
+++ b/gl/Makefile.am
@@ -44,17 +44,6 @@ EXTRA_DIST += alignof.h
44 44
45## end gnulib module alignof 45## end gnulib module alignof
46 46
47## begin gnulib module alloca
48
49
50EXTRA_DIST += alloca.c
51
52EXTRA_libgnu_a_SOURCES += alloca.c
53
54libgnu_a_LIBADD += @ALLOCA@
55libgnu_a_DEPENDENCIES += @ALLOCA@
56## end gnulib module alloca
57
58## begin gnulib module alloca-opt 47## begin gnulib module alloca-opt
59 48
60BUILT_SOURCES += $(ALLOCA_H) 49BUILT_SOURCES += $(ALLOCA_H)
@@ -833,11 +822,11 @@ EXTRA_libgnu_a_SOURCES += mountlist.c
833 822
834## begin gnulib module netdb 823## begin gnulib module netdb
835 824
836BUILT_SOURCES += $(NETDB_H) 825BUILT_SOURCES += netdb.h
837 826
838# We need the following in order to create <netdb.h> when the system 827# We need the following in order to create <netdb.h> when the system
839# doesn't have one that works with the given compiler. 828# doesn't have one that works with the given compiler.
840netdb.h: netdb.in.h $(ARG_NONNULL_H) 829netdb.h: netdb.in.h $(ARG_NONNULL_H) $(WARN_ON_USE_H)
841 $(AM_V_GEN)rm -f $@-t $@ && \ 830 $(AM_V_GEN)rm -f $@-t $@ && \
842 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 831 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
843 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 832 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -851,6 +840,7 @@ netdb.h: netdb.in.h $(ARG_NONNULL_H)
851 -e 's|@''HAVE_DECL_GETADDRINFO''@|$(HAVE_DECL_GETADDRINFO)|g' \ 840 -e 's|@''HAVE_DECL_GETADDRINFO''@|$(HAVE_DECL_GETADDRINFO)|g' \
852 -e 's|@''HAVE_DECL_GETNAMEINFO''@|$(HAVE_DECL_GETNAMEINFO)|g' \ 841 -e 's|@''HAVE_DECL_GETNAMEINFO''@|$(HAVE_DECL_GETNAMEINFO)|g' \
853 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 842 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
843 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
854 < $(srcdir)/netdb.in.h; \ 844 < $(srcdir)/netdb.in.h; \
855 } > $@-t && \ 845 } > $@-t && \
856 mv $@-t $@ 846 mv $@-t $@
@@ -1140,6 +1130,7 @@ stdio.h: stdio.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
1140 -e 's|@''REPLACE_VPRINTF''@|$(REPLACE_VPRINTF)|g' \ 1130 -e 's|@''REPLACE_VPRINTF''@|$(REPLACE_VPRINTF)|g' \
1141 -e 's|@''REPLACE_VSNPRINTF''@|$(REPLACE_VSNPRINTF)|g' \ 1131 -e 's|@''REPLACE_VSNPRINTF''@|$(REPLACE_VSNPRINTF)|g' \
1142 -e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \ 1132 -e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \
1133 -e 's|@''ASM_SYMBOL_PREFIX''@|$(ASM_SYMBOL_PREFIX)|g' \
1143 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 1134 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
1144 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 1135 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
1145 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \ 1136 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
@@ -1333,6 +1324,7 @@ string.h: string.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
1333 -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \ 1324 -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \
1334 -e 's|@''REPLACE_STRNCAT''@|$(REPLACE_STRNCAT)|g' \ 1325 -e 's|@''REPLACE_STRNCAT''@|$(REPLACE_STRNCAT)|g' \
1335 -e 's|@''REPLACE_STRNDUP''@|$(REPLACE_STRNDUP)|g' \ 1326 -e 's|@''REPLACE_STRNDUP''@|$(REPLACE_STRNDUP)|g' \
1327 -e 's|@''REPLACE_STRNLEN''@|$(REPLACE_STRNLEN)|g' \
1336 -e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \ 1328 -e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \
1337 -e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \ 1329 -e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \
1338 -e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \ 1330 -e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \
@@ -1506,6 +1498,7 @@ time.h: time.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
1506 -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \ 1498 -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \
1507 -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \ 1499 -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \
1508 -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \ 1500 -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \
1501 -e 's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|$(PTHREAD_H_DEFINES_STRUCT_TIMESPEC)|g' \
1509 -e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ 1502 -e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
1510 -e 's|@''TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \ 1503 -e 's|@''TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
1511 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 1504 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
@@ -1577,6 +1570,7 @@ unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
1577 -e 's|@''GNULIB_LSEEK''@|$(GNULIB_LSEEK)|g' \ 1570 -e 's|@''GNULIB_LSEEK''@|$(GNULIB_LSEEK)|g' \
1578 -e 's|@''GNULIB_PIPE2''@|$(GNULIB_PIPE2)|g' \ 1571 -e 's|@''GNULIB_PIPE2''@|$(GNULIB_PIPE2)|g' \
1579 -e 's|@''GNULIB_PREAD''@|$(GNULIB_PREAD)|g' \ 1572 -e 's|@''GNULIB_PREAD''@|$(GNULIB_PREAD)|g' \
1573 -e 's|@''GNULIB_PWRITE''@|$(GNULIB_PWRITE)|g' \
1580 -e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \ 1574 -e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \
1581 -e 's|@''GNULIB_READLINKAT''@|$(GNULIB_READLINKAT)|g' \ 1575 -e 's|@''GNULIB_READLINKAT''@|$(GNULIB_READLINKAT)|g' \
1582 -e 's|@''GNULIB_RMDIR''@|$(GNULIB_RMDIR)|g' \ 1576 -e 's|@''GNULIB_RMDIR''@|$(GNULIB_RMDIR)|g' \
@@ -1611,6 +1605,7 @@ unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
1611 -e 's|@''HAVE_LINKAT''@|$(HAVE_LINKAT)|g' \ 1605 -e 's|@''HAVE_LINKAT''@|$(HAVE_LINKAT)|g' \
1612 -e 's|@''HAVE_PIPE2''@|$(HAVE_PIPE2)|g' \ 1606 -e 's|@''HAVE_PIPE2''@|$(HAVE_PIPE2)|g' \
1613 -e 's|@''HAVE_PREAD''@|$(HAVE_PREAD)|g' \ 1607 -e 's|@''HAVE_PREAD''@|$(HAVE_PREAD)|g' \
1608 -e 's|@''HAVE_PWRITE''@|$(HAVE_PWRITE)|g' \
1614 -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \ 1609 -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \
1615 -e 's|@''HAVE_READLINKAT''@|$(HAVE_READLINKAT)|g' \ 1610 -e 's|@''HAVE_READLINKAT''@|$(HAVE_READLINKAT)|g' \
1616 -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \ 1611 -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \
@@ -1638,10 +1633,12 @@ unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
1638 -e 's|@''REPLACE_LINKAT''@|$(REPLACE_LINKAT)|g' \ 1633 -e 's|@''REPLACE_LINKAT''@|$(REPLACE_LINKAT)|g' \
1639 -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \ 1634 -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \
1640 -e 's|@''REPLACE_PREAD''@|$(REPLACE_PREAD)|g' \ 1635 -e 's|@''REPLACE_PREAD''@|$(REPLACE_PREAD)|g' \
1636 -e 's|@''REPLACE_PWRITE''@|$(REPLACE_PWRITE)|g' \
1641 -e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \ 1637 -e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \
1642 -e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \ 1638 -e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \
1643 -e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \ 1639 -e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \
1644 -e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \ 1640 -e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \
1641 -e 's|@''REPLACE_TTYNAME_R''@|$(REPLACE_TTYNAME_R)|g' \
1645 -e 's|@''REPLACE_UNLINK''@|$(REPLACE_UNLINK)|g' \ 1642 -e 's|@''REPLACE_UNLINK''@|$(REPLACE_UNLINK)|g' \
1646 -e 's|@''REPLACE_UNLINKAT''@|$(REPLACE_UNLINKAT)|g' \ 1643 -e 's|@''REPLACE_UNLINKAT''@|$(REPLACE_UNLINKAT)|g' \
1647 -e 's|@''REPLACE_USLEEP''@|$(REPLACE_USLEEP)|g' \ 1644 -e 's|@''REPLACE_USLEEP''@|$(REPLACE_USLEEP)|g' \
diff --git a/gl/config.charset b/gl/config.charset
index 2959df8..aa7d00d 100644
--- a/gl/config.charset
+++ b/gl/config.charset
@@ -30,21 +30,21 @@
30# The current list of GNU canonical charset names is as follows. 30# The current list of GNU canonical charset names is as follows.
31# 31#
32# name MIME? used by which systems 32# name MIME? used by which systems
33# ASCII, ANSI_X3.4-1968 glibc solaris freebsd netbsd darwin 33# ASCII, ANSI_X3.4-1968 glibc solaris freebsd netbsd darwin cygwin
34# ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin 34# ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
35# ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin 35# ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
36# ISO-8859-3 Y glibc solaris 36# ISO-8859-3 Y glibc solaris cygwin
37# ISO-8859-4 Y osf solaris freebsd netbsd openbsd darwin 37# ISO-8859-4 Y osf solaris freebsd netbsd openbsd darwin
38# ISO-8859-5 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin 38# ISO-8859-5 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
39# ISO-8859-6 Y glibc aix hpux solaris 39# ISO-8859-6 Y glibc aix hpux solaris cygwin
40# ISO-8859-7 Y glibc aix hpux irix osf solaris netbsd openbsd darwin 40# ISO-8859-7 Y glibc aix hpux irix osf solaris netbsd openbsd darwin cygwin
41# ISO-8859-8 Y glibc aix hpux osf solaris 41# ISO-8859-8 Y glibc aix hpux osf solaris cygwin
42# ISO-8859-9 Y glibc aix hpux irix osf solaris darwin 42# ISO-8859-9 Y glibc aix hpux irix osf solaris darwin cygwin
43# ISO-8859-13 glibc netbsd openbsd darwin 43# ISO-8859-13 glibc netbsd openbsd darwin cygwin
44# ISO-8859-14 glibc 44# ISO-8859-14 glibc cygwin
45# ISO-8859-15 glibc aix osf solaris freebsd netbsd openbsd darwin 45# ISO-8859-15 glibc aix osf solaris freebsd netbsd openbsd darwin cygwin
46# KOI8-R Y glibc solaris freebsd netbsd openbsd darwin 46# KOI8-R Y glibc solaris freebsd netbsd openbsd darwin
47# KOI8-U Y glibc freebsd netbsd openbsd darwin 47# KOI8-U Y glibc freebsd netbsd openbsd darwin cygwin
48# KOI8-T glibc 48# KOI8-T glibc
49# CP437 dos 49# CP437 dos
50# CP775 dos 50# CP775 dos
@@ -61,7 +61,7 @@
61# CP869 dos 61# CP869 dos
62# CP874 woe32 dos 62# CP874 woe32 dos
63# CP922 aix 63# CP922 aix
64# CP932 aix woe32 dos 64# CP932 aix cygwin woe32 dos
65# CP943 aix 65# CP943 aix
66# CP949 osf darwin woe32 dos 66# CP949 osf darwin woe32 dos
67# CP950 woe32 dos 67# CP950 woe32 dos
@@ -71,7 +71,7 @@
71# CP1129 aix 71# CP1129 aix
72# CP1131 darwin 72# CP1131 darwin
73# CP1250 woe32 73# CP1250 woe32
74# CP1251 glibc solaris netbsd openbsd darwin woe32 74# CP1251 glibc solaris netbsd openbsd darwin cygwin woe32
75# CP1252 aix woe32 75# CP1252 aix woe32
76# CP1253 woe32 76# CP1253 woe32
77# CP1254 woe32 77# CP1254 woe32
@@ -80,19 +80,19 @@
80# CP1257 woe32 80# CP1257 woe32
81# GB2312 Y glibc aix hpux irix solaris freebsd netbsd darwin 81# GB2312 Y glibc aix hpux irix solaris freebsd netbsd darwin
82# EUC-JP Y glibc aix hpux irix osf solaris freebsd netbsd darwin 82# EUC-JP Y glibc aix hpux irix osf solaris freebsd netbsd darwin
83# EUC-KR Y glibc aix hpux irix osf solaris freebsd netbsd darwin 83# EUC-KR Y glibc aix hpux irix osf solaris freebsd netbsd darwin cygwin
84# EUC-TW glibc aix hpux irix osf solaris netbsd 84# EUC-TW glibc aix hpux irix osf solaris netbsd
85# BIG5 Y glibc aix hpux osf solaris freebsd netbsd darwin 85# BIG5 Y glibc aix hpux osf solaris freebsd netbsd darwin cygwin
86# BIG5-HKSCS glibc solaris darwin 86# BIG5-HKSCS glibc solaris darwin
87# GBK glibc aix osf solaris darwin woe32 dos 87# GBK glibc aix osf solaris darwin cygwin woe32 dos
88# GB18030 glibc solaris netbsd darwin 88# GB18030 glibc solaris netbsd darwin
89# SHIFT_JIS Y hpux osf solaris freebsd netbsd darwin 89# SHIFT_JIS Y hpux osf solaris freebsd netbsd darwin
90# JOHAB glibc solaris woe32 90# JOHAB glibc solaris woe32
91# TIS-620 glibc aix hpux osf solaris 91# TIS-620 glibc aix hpux osf solaris cygwin
92# VISCII Y glibc 92# VISCII Y glibc
93# TCVN5712-1 glibc 93# TCVN5712-1 glibc
94# ARMSCII-8 glibc darwin 94# ARMSCII-8 glibc darwin
95# GEORGIAN-PS glibc 95# GEORGIAN-PS glibc cygwin
96# PT154 glibc 96# PT154 glibc
97# HP-ROMAN8 hpux 97# HP-ROMAN8 hpux
98# HP-ARABIC8 hpux 98# HP-ARABIC8 hpux
@@ -102,7 +102,7 @@
102# HP-KANA8 hpux 102# HP-KANA8 hpux
103# DEC-KANJI osf 103# DEC-KANJI osf
104# DEC-HANYU osf 104# DEC-HANYU osf
105# UTF-8 Y glibc aix hpux osf solaris netbsd darwin 105# UTF-8 Y glibc aix hpux osf solaris netbsd darwin cygwin
106# 106#
107# Note: Names which are not marked as being a MIME name should not be used in 107# Note: Names which are not marked as being a MIME name should not be used in
108# Internet protocols for information interchange (mail, news, etc.). 108# Internet protocols for information interchange (mail, news, etc.).
diff --git a/gl/error.c b/gl/error.c
index c79e8d4..ed9dba0 100644
--- a/gl/error.c
+++ b/gl/error.c
@@ -88,6 +88,15 @@ extern void __error_at_line (int status, int errnum, const char *file_name,
88# include <fcntl.h> 88# include <fcntl.h>
89# include <unistd.h> 89# include <unistd.h>
90 90
91# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
92/* Get declarations of the Win32 API functions. */
93# define WIN32_LEAN_AND_MEAN
94# include <windows.h>
95# endif
96
97/* The gnulib override of fcntl is not needed in this file. */
98# undef fcntl
99
91# if !HAVE_DECL_STRERROR_R && STRERROR_R_CHAR_P 100# if !HAVE_DECL_STRERROR_R && STRERROR_R_CHAR_P
92# ifndef HAVE_DECL_STRERROR_R 101# ifndef HAVE_DECL_STRERROR_R
93"this configure-time declaration test was not run" 102"this configure-time declaration test was not run"
@@ -104,10 +113,29 @@ extern char *program_name;
104# endif /* HAVE_STRERROR_R || defined strerror_r */ 113# endif /* HAVE_STRERROR_R || defined strerror_r */
105#endif /* not _LIBC */ 114#endif /* not _LIBC */
106 115
116#if !_LIBC
117/* Return non-zero if FD is open. */
118static inline int
119is_open (int fd)
120{
121# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
122 /* On Win32: The initial state of unassigned standard file descriptors is
123 that they are open but point to an INVALID_HANDLE_VALUE. There is no
124 fcntl, and the gnulib replacement fcntl does not support F_GETFL. */
125 return (HANDLE) _get_osfhandle (fd) != INVALID_HANDLE_VALUE;
126# else
127# ifndef F_GETFL
128# error Please port fcntl to your platform
129# endif
130 return 0 <= fcntl (fd, F_GETFL);
131# endif
132}
133#endif
134
107static inline void 135static inline void
108flush_stdout (void) 136flush_stdout (void)
109{ 137{
110#if !_LIBC && defined F_GETFL 138#if !_LIBC
111 int stdout_fd; 139 int stdout_fd;
112 140
113# if GNULIB_FREOPEN_SAFER 141# if GNULIB_FREOPEN_SAFER
@@ -124,7 +152,7 @@ flush_stdout (void)
124 /* POSIX states that fflush (stdout) after fclose is unspecified; it 152 /* POSIX states that fflush (stdout) after fclose is unspecified; it
125 is safe in glibc, but not on all other platforms. fflush (NULL) 153 is safe in glibc, but not on all other platforms. fflush (NULL)
126 is always defined, but too draconian. */ 154 is always defined, but too draconian. */
127 if (0 <= stdout_fd && 0 <= fcntl (stdout_fd, F_GETFL)) 155 if (0 <= stdout_fd && is_open (stdout_fd))
128#endif 156#endif
129 fflush (stdout); 157 fflush (stdout);
130} 158}
diff --git a/gl/getopt.c b/gl/getopt.c
index aaabc8d..3791f12 100644
--- a/gl/getopt.c
+++ b/gl/getopt.c
@@ -348,8 +348,6 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
348 int long_only, struct _getopt_data *d, int posixly_correct) 348 int long_only, struct _getopt_data *d, int posixly_correct)
349{ 349{
350 int print_errors = d->opterr; 350 int print_errors = d->opterr;
351 if (optstring[0] == ':')
352 print_errors = 0;
353 351
354 if (argc < 1) 352 if (argc < 1)
355 return -1; 353 return -1;
@@ -364,6 +362,10 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
364 posixly_correct); 362 posixly_correct);
365 d->__initialized = 1; 363 d->__initialized = 1;
366 } 364 }
365 else if (optstring[0] == '-' || optstring[0] == '+')
366 optstring++;
367 if (optstring[0] == ':')
368 print_errors = 0;
367 369
368 /* Test whether ARGV[optind] points to a non-option argument. 370 /* Test whether ARGV[optind] points to a non-option argument.
369 Either it does not have option syntax, or there is an environment flag 371 Either it does not have option syntax, or there is an environment flag
@@ -633,8 +635,8 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
633 char *buf; 635 char *buf;
634 636
635 if (__asprintf (&buf, _("\ 637 if (__asprintf (&buf, _("\
636%s: option '%s' requires an argument\n"), 638%s: option '--%s' requires an argument\n"),
637 argv[0], argv[d->optind - 1]) >= 0) 639 argv[0], pfound->name) >= 0)
638 { 640 {
639 _IO_flockfile (stderr); 641 _IO_flockfile (stderr);
640 642
@@ -651,8 +653,8 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
651 } 653 }
652#else 654#else
653 fprintf (stderr, 655 fprintf (stderr,
654 _("%s: option '%s' requires an argument\n"), 656 _("%s: option '--%s' requires an argument\n"),
655 argv[0], argv[d->optind - 1]); 657 argv[0], pfound->name);
656#endif 658#endif
657 } 659 }
658 d->__nextchar += strlen (d->__nextchar); 660 d->__nextchar += strlen (d->__nextchar);
@@ -736,13 +738,13 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
736 738
737 { 739 {
738 char c = *d->__nextchar++; 740 char c = *d->__nextchar++;
739 char *temp = strchr (optstring, c); 741 const char *temp = strchr (optstring, c);
740 742
741 /* Increment `optind' when we start to process its last character. */ 743 /* Increment `optind' when we start to process its last character. */
742 if (*d->__nextchar == '\0') 744 if (*d->__nextchar == '\0')
743 ++d->optind; 745 ++d->optind;
744 746
745 if (temp == NULL || c == ':') 747 if (temp == NULL || c == ':' || c == ';')
746 { 748 {
747 if (print_errors) 749 if (print_errors)
748 { 750 {
@@ -864,7 +866,10 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
864 pfound = p; 866 pfound = p;
865 indfound = option_index; 867 indfound = option_index;
866 } 868 }
867 else 869 else if (long_only
870 || pfound->has_arg != p->has_arg
871 || pfound->flag != p->flag
872 || pfound->val != p->val)
868 /* Second or later nonexact match found. */ 873 /* Second or later nonexact match found. */
869 ambig = 1; 874 ambig = 1;
870 } 875 }
@@ -876,7 +881,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
876 char *buf; 881 char *buf;
877 882
878 if (__asprintf (&buf, _("%s: option '-W %s' is ambiguous\n"), 883 if (__asprintf (&buf, _("%s: option '-W %s' is ambiguous\n"),
879 argv[0], argv[d->optind]) >= 0) 884 argv[0], d->optarg) >= 0)
880 { 885 {
881 _IO_flockfile (stderr); 886 _IO_flockfile (stderr);
882 887
@@ -892,7 +897,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
892 } 897 }
893#else 898#else
894 fprintf (stderr, _("%s: option '-W %s' is ambiguous\n"), 899 fprintf (stderr, _("%s: option '-W %s' is ambiguous\n"),
895 argv[0], argv[d->optind]); 900 argv[0], d->optarg);
896#endif 901#endif
897 } 902 }
898 d->__nextchar += strlen (d->__nextchar); 903 d->__nextchar += strlen (d->__nextchar);
@@ -955,8 +960,8 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
955 char *buf; 960 char *buf;
956 961
957 if (__asprintf (&buf, _("\ 962 if (__asprintf (&buf, _("\
958%s: option '%s' requires an argument\n"), 963%s: option '-W %s' requires an argument\n"),
959 argv[0], argv[d->optind - 1]) >= 0) 964 argv[0], pfound->name) >= 0)
960 { 965 {
961 _IO_flockfile (stderr); 966 _IO_flockfile (stderr);
962 967
@@ -972,15 +977,17 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
972 free (buf); 977 free (buf);
973 } 978 }
974#else 979#else
975 fprintf (stderr, 980 fprintf (stderr, _("\
976 _("%s: option '%s' requires an argument\n"), 981%s: option '-W %s' requires an argument\n"),
977 argv[0], argv[d->optind - 1]); 982 argv[0], pfound->name);
978#endif 983#endif
979 } 984 }
980 d->__nextchar += strlen (d->__nextchar); 985 d->__nextchar += strlen (d->__nextchar);
981 return optstring[0] == ':' ? ':' : '?'; 986 return optstring[0] == ':' ? ':' : '?';
982 } 987 }
983 } 988 }
989 else
990 d->optarg = NULL;
984 d->__nextchar += strlen (d->__nextchar); 991 d->__nextchar += strlen (d->__nextchar);
985 if (longind != NULL) 992 if (longind != NULL)
986 *longind = option_index; 993 *longind = option_index;
diff --git a/gl/getopt_int.h b/gl/getopt_int.h
index 169def5..980b750 100644
--- a/gl/getopt_int.h
+++ b/gl/getopt_int.h
@@ -30,6 +30,40 @@ extern int _getopt_internal (int ___argc, char **___argv,
30/* Reentrant versions which can handle parsing multiple argument 30/* Reentrant versions which can handle parsing multiple argument
31 vectors at the same time. */ 31 vectors at the same time. */
32 32
33/* Describe how to deal with options that follow non-option ARGV-elements.
34
35 If the caller did not specify anything,
36 the default is REQUIRE_ORDER if the environment variable
37 POSIXLY_CORRECT is defined, PERMUTE otherwise.
38
39 REQUIRE_ORDER means don't recognize them as options;
40 stop option processing when the first non-option is seen.
41 This is what Unix does.
42 This mode of operation is selected by either setting the environment
43 variable POSIXLY_CORRECT, or using `+' as the first character
44 of the list of option characters, or by calling getopt.
45
46 PERMUTE is the default. We permute the contents of ARGV as we
47 scan, so that eventually all the non-options are at the end.
48 This allows options to be given in any order, even with programs
49 that were not written to expect this.
50
51 RETURN_IN_ORDER is an option available to programs that were
52 written to expect options and other ARGV-elements in any order
53 and that care about the ordering of the two. We describe each
54 non-option ARGV-element as if it were the argument of an option
55 with character code 1. Using `-' as the first character of the
56 list of option characters selects this mode of operation.
57
58 The special argument `--' forces an end of option-scanning regardless
59 of the value of `ordering'. In the case of RETURN_IN_ORDER, only
60 `--' can cause `getopt' to return -1 with `optind' != ARGC. */
61
62enum __ord
63 {
64 REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
65 };
66
33/* Data type for reentrant functions. */ 67/* Data type for reentrant functions. */
34struct _getopt_data 68struct _getopt_data
35{ 69{
@@ -54,39 +88,8 @@ struct _getopt_data
54 by advancing to the next ARGV-element. */ 88 by advancing to the next ARGV-element. */
55 char *__nextchar; 89 char *__nextchar;
56 90
57 /* Describe how to deal with options that follow non-option ARGV-elements. 91 /* See __ord above. */
58 92 enum __ord __ordering;
59 If the caller did not specify anything,
60 the default is REQUIRE_ORDER if the environment variable
61 POSIXLY_CORRECT is defined, PERMUTE otherwise.
62
63 REQUIRE_ORDER means don't recognize them as options;
64 stop option processing when the first non-option is seen.
65 This is what Unix does.
66 This mode of operation is selected by either setting the environment
67 variable POSIXLY_CORRECT, or using `+' as the first character
68 of the list of option characters, or by calling getopt.
69
70 PERMUTE is the default. We permute the contents of ARGV as we
71 scan, so that eventually all the non-options are at the end.
72 This allows options to be given in any order, even with programs
73 that were not written to expect this.
74
75 RETURN_IN_ORDER is an option available to programs that were
76 written to expect options and other ARGV-elements in any order
77 and that care about the ordering of the two. We describe each
78 non-option ARGV-element as if it were the argument of an option
79 with character code 1. Using `-' as the first character of the
80 list of option characters selects this mode of operation.
81
82 The special argument `--' forces an end of option-scanning regardless
83 of the value of `ordering'. In the case of RETURN_IN_ORDER, only
84 `--' can cause `getopt' to return -1 with `optind' != ARGC. */
85
86 enum
87 {
88 REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
89 } __ordering;
90 93
91 /* If the POSIXLY_CORRECT environment variable is set 94 /* If the POSIXLY_CORRECT environment variable is set
92 or getopt was called. */ 95 or getopt was called. */
diff --git a/gl/localcharset.c b/gl/localcharset.c
index a04dc44..fa2207f 100644
--- a/gl/localcharset.c
+++ b/gl/localcharset.c
@@ -369,10 +369,9 @@ locale_charset (void)
369 codeset = nl_langinfo (CODESET); 369 codeset = nl_langinfo (CODESET);
370 370
371# ifdef __CYGWIN__ 371# ifdef __CYGWIN__
372 /* Cygwin 1.5.x does not have locales. nl_langinfo (CODESET) always 372 /* Cygwin < 1.7 does not have locales. nl_langinfo (CODESET) always
373 returns "US-ASCII". As long as this is not fixed, return the suffix 373 returns "US-ASCII". Return the suffix of the locale name from the
374 of the locale name from the environment variables (if present) or 374 environment variables (if present) or the codepage as a number. */
375 the codepage as a number. */
376 if (codeset != NULL && strcmp (codeset, "US-ASCII") == 0) 375 if (codeset != NULL && strcmp (codeset, "US-ASCII") == 0)
377 { 376 {
378 const char *locale; 377 const char *locale;
diff --git a/gl/m4/asm-underscore.m4 b/gl/m4/asm-underscore.m4
new file mode 100644
index 0000000..1736cc4
--- /dev/null
+++ b/gl/m4/asm-underscore.m4
@@ -0,0 +1,48 @@
1# asm-underscore.m4 serial 1
2dnl Copyright (C) 2010 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible. Based on as-underscore.m4 in GNU clisp.
8
9# gl_ASM_SYMBOL_PREFIX
10# Tests for the prefix of C symbols at the assembly language level and the
11# linker level. This prefix is either an underscore or empty. Defines the
12# C macro USER_LABEL_PREFIX to this prefix, and sets ASM_SYMBOL_PREFIX to
13# a stringified variant of this prefix.
14
15AC_DEFUN([gl_ASM_SYMBOL_PREFIX],
16[
17 dnl We don't use GCC's __USER_LABEL_PREFIX__ here, because
18 dnl 1. It works only for GCC.
19 dnl 2. It is incorrectly defined on some platforms, in some GCC versions.
20 AC_CACHE_CHECK(
21 [whether C symbols are prefixed with underscore at the linker level],
22 [gl_cv_prog_as_underscore],
23 [cat > conftest.c <<EOF
24#ifdef __cplusplus
25extern "C" int foo (void);
26#endif
27int foo(void) { return 0; }
28EOF
29 # Look for the assembly language name in the .s file.
30 AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS -S conftest.c) >/dev/null 2>&1
31 if grep _foo conftest.s >/dev/null ; then
32 gl_cv_prog_as_underscore=yes
33 else
34 gl_cv_prog_as_underscore=no
35 fi
36 rm -f conftest*
37 ])
38 if test $gl_cv_prog_as_underscore = yes; then
39 USER_LABEL_PREFIX=_
40 else
41 USER_LABEL_PREFIX=
42 fi
43 AC_DEFINE_UNQUOTED([USER_LABEL_PREFIX], [$USER_LABEL_PREFIX],
44 [Define to the prefix of C symbols at the assembler and linker level,
45 either an underscore or empty.])
46 ASM_SYMBOL_PREFIX='"'${USER_LABEL_PREFIX}'"'
47 AC_SUBST([ASM_SYMBOL_PREFIX])
48])
diff --git a/gl/m4/getopt.m4 b/gl/m4/getopt.m4
index a19805e..5b211e5 100644
--- a/gl/m4/getopt.m4
+++ b/gl/m4/getopt.m4
@@ -1,4 +1,4 @@
1# getopt.m4 serial 24 1# getopt.m4 serial 28
2dnl Copyright (C) 2002-2006, 2008-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2006, 2008-2010 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
@@ -79,8 +79,13 @@ AC_DEFUN([gl_GETOPT_CHECK_HEADERS],
79 dnl Existence of the variable, in and of itself, is not a reason to replace 79 dnl Existence of the variable, in and of itself, is not a reason to replace
80 dnl getopt, but knowledge of the variable is needed to determine how to 80 dnl getopt, but knowledge of the variable is needed to determine how to
81 dnl reset and whether a reset reparses the environment. 81 dnl reset and whether a reset reparses the environment.
82 if test -z "$gl_replace_getopt" && test $gl_getopt_required = GNU; then 82 dnl Solaris supports neither optreset nor optind=0, but keeps no state that
83 AC_CHECK_DECLS([optreset], [], [], 83 dnl needs a reset beyond setting optind=1; detect Solaris by getopt_clip.
84 if test -z "$gl_replace_getopt"; then
85 AC_CHECK_DECLS([optreset], [],
86 [AC_CHECK_DECLS([getopt_clip], [], [],
87 [[#include <getopt.h>]])
88 ],
84 [[#include <getopt.h>]]) 89 [[#include <getopt.h>]])
85 fi 90 fi
86 91
@@ -89,6 +94,10 @@ AC_DEFUN([gl_GETOPT_CHECK_HEADERS],
89 dnl is left over from earlier calls, and neither setting optind = 0 nor 94 dnl is left over from earlier calls, and neither setting optind = 0 nor
90 dnl setting optreset = 1 get rid of this internal state. 95 dnl setting optreset = 1 get rid of this internal state.
91 dnl POSIX is silent on optind vs. optreset, so we allow either behavior. 96 dnl POSIX is silent on optind vs. optreset, so we allow either behavior.
97 dnl POSIX 2008 does not specify leading '+' behavior, but see
98 dnl http://austingroupbugs.net/view.php?id=191 for a recommendation on
99 dnl the next version of POSIX. For now, we only guarantee leading '+'
100 dnl behavior with getopt-gnu.
92 if test -z "$gl_replace_getopt"; then 101 if test -z "$gl_replace_getopt"; then
93 AC_CACHE_CHECK([whether getopt is POSIX compatible], 102 AC_CACHE_CHECK([whether getopt is POSIX compatible],
94 [gl_cv_func_getopt_posix], 103 [gl_cv_func_getopt_posix],
@@ -99,7 +108,7 @@ AC_DEFUN([gl_GETOPT_CHECK_HEADERS],
99#include <stdlib.h> 108#include <stdlib.h>
100#include <string.h> 109#include <string.h>
101 110
102#if !HAVE_DECL_OPTRESET 111#if !HAVE_DECL_OPTRESET && !HAVE_DECL_GETOPT_CLIP
103# define OPTIND_MIN 0 112# define OPTIND_MIN 0
104#else 113#else
105# define OPTIND_MIN 1 114# define OPTIND_MIN 1
@@ -167,6 +176,20 @@ main ()
167 if (!(optind == 1)) 176 if (!(optind == 1))
168 return 12; 177 return 12;
169 } 178 }
179 /* Detect MacOS 10.5 bug. */
180 {
181 char *argv[3] = { "program", "-ab", NULL };
182 optind = OPTIND_MIN;
183 opterr = 0;
184 if (getopt (2, argv, "ab:") != 'a')
185 return 13;
186 if (getopt (2, argv, "ab:") != '?')
187 return 14;
188 if (optopt != 'b')
189 return 15;
190 if (optind != 2)
191 return 16;
192 }
170 193
171 return 0; 194 return 0;
172} 195}
@@ -174,6 +197,7 @@ main ()
174 [gl_cv_func_getopt_posix=yes], [gl_cv_func_getopt_posix=no], 197 [gl_cv_func_getopt_posix=yes], [gl_cv_func_getopt_posix=no],
175 [case "$host_os" in 198 [case "$host_os" in
176 mingw*) gl_cv_func_getopt_posix="guessing no";; 199 mingw*) gl_cv_func_getopt_posix="guessing no";;
200 darwin*) gl_cv_func_getopt_posix="guessing no";;
177 *) gl_cv_func_getopt_posix="guessing yes";; 201 *) gl_cv_func_getopt_posix="guessing yes";;
178 esac 202 esac
179 ]) 203 ])
@@ -234,6 +258,15 @@ main ()
234 if (getopt (3, argv, "-p") != 'p') 258 if (getopt (3, argv, "-p") != 'p')
235 return 7; 259 return 7;
236 } 260 }
261 /* This code fails on glibc 2.11. */
262 {
263 char *argv[] = { "program", "-b", "-a", NULL };
264 optind = opterr = 0;
265 if (getopt (3, argv, "+:a:b") != 'b')
266 return 8;
267 if (getopt (3, argv, "+:a:b") != ':')
268 return 9;
269 }
237 return 0; 270 return 0;
238 ]])], 271 ]])],
239 [gl_cv_func_getopt_gnu=yes], 272 [gl_cv_func_getopt_gnu=yes],
diff --git a/gl/m4/gettext.m4 b/gl/m4/gettext.m4
index d6dc3fe..f84e6a5 100644
--- a/gl/m4/gettext.m4
+++ b/gl/m4/gettext.m4
@@ -1,4 +1,4 @@
1# gettext.m4 serial 62 (gettext-0.18) 1# gettext.m4 serial 63 (gettext-0.18)
2dnl Copyright (C) 1995-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 1995-2010 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
@@ -15,7 +15,7 @@ dnl They are *not* in the public domain.
15 15
16dnl Authors: 16dnl Authors:
17dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000. 17dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
18dnl Bruno Haible <haible@clisp.cons.org>, 2000-2006. 18dnl Bruno Haible <haible@clisp.cons.org>, 2000-2006, 2008-2010.
19 19
20dnl Macro to add for using GNU gettext. 20dnl Macro to add for using GNU gettext.
21 21
@@ -60,6 +60,8 @@ AC_DEFUN([AM_GNU_GETTEXT],
60 ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], , 60 ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], ,
61 [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT 61 [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT
62])])])])]) 62])])])])])
63 ifelse(ifelse([$1], [], [old])[]ifelse([$1], [no-libtool], [old]), [old],
64 [AC_DIAGNOSE([obsolete], [Use of AM_GNU_GETTEXT without [external] argument is deprecated.])])
63 ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], , 65 ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], ,
64 [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT 66 [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT
65])])])]) 67])])])])
diff --git a/gl/m4/gnulib-common.m4 b/gl/m4/gnulib-common.m4
index 9cc519e..4c7ac30 100644
--- a/gl/m4/gnulib-common.m4
+++ b/gl/m4/gnulib-common.m4
@@ -1,4 +1,4 @@
1# gnulib-common.m4 serial 18 1# gnulib-common.m4 serial 20
2dnl Copyright (C) 2007-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
@@ -35,6 +35,12 @@ AC_DEFUN([gl_COMMON_BODY], [
35 is a misnomer outside of parameter lists. */ 35 is a misnomer outside of parameter lists. */
36#define _UNUSED_PARAMETER_ _GL_UNUSED 36#define _UNUSED_PARAMETER_ _GL_UNUSED
37]) 37])
38 dnl Preparation for running test programs:
39 dnl Tell glibc to write diagnostics from -D_FORTIFY_SOURCE=2 to stderr, not
40 dnl to /dev/tty, so they can be redirected to log files. Such diagnostics
41 dnl arise e.g., in the macros gl_PRINTF_DIRECTIVE_N, gl_SNPRINTF_DIRECTIVE_N.
42 LIBC_FATAL_STDERR_=1
43 export LIBC_FATAL_STDERR_
38]) 44])
39 45
40# gl_MODULE_INDICATOR_CONDITION 46# gl_MODULE_INDICATOR_CONDITION
@@ -132,6 +138,7 @@ m4_ifdef([AC_PROG_MKDIR_P], [
132# so that mixed use of GNU C and GNU C++ and mixed use of Sun C and Sun C++ 138# so that mixed use of GNU C and GNU C++ and mixed use of Sun C and Sun C++
133# works. 139# works.
134# This definition can be removed once autoconf >= 2.62 can be assumed. 140# This definition can be removed once autoconf >= 2.62 can be assumed.
141m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.62]),[-1],[
135AC_DEFUN([AC_C_RESTRICT], 142AC_DEFUN([AC_C_RESTRICT],
136[AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict], 143[AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict],
137 [ac_cv_c_restrict=no 144 [ac_cv_c_restrict=no
@@ -169,6 +176,7 @@ AC_DEFUN([AC_C_RESTRICT],
169 *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;; 176 *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;;
170 esac 177 esac
171]) 178])
179])
172 180
173# gl_BIGENDIAN 181# gl_BIGENDIAN
174# is like AC_C_BIGENDIAN, except that it can be AC_REQUIREd. 182# is like AC_C_BIGENDIAN, except that it can be AC_REQUIREd.
diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4
index 4a956e4..e776ae7 100644
--- a/gl/m4/gnulib-comp.m4
+++ b/gl/m4/gnulib-comp.m4
@@ -26,7 +26,6 @@ AC_DEFUN([gl_EARLY],
26 m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable 26 m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable
27 AC_REQUIRE([AC_PROG_RANLIB]) 27 AC_REQUIRE([AC_PROG_RANLIB])
28 # Code from module alignof: 28 # Code from module alignof:
29 # Code from module alloca:
30 # Code from module alloca-opt: 29 # Code from module alloca-opt:
31 # Code from module arg-nonnull: 30 # Code from module arg-nonnull:
32 # Code from module arpa_inet: 31 # Code from module arpa_inet:
@@ -146,7 +145,6 @@ AC_DEFUN([gl_INIT],
146 gl_COMMON 145 gl_COMMON
147 gl_source_base='gl' 146 gl_source_base='gl'
148 # Code from module alignof: 147 # Code from module alignof:
149 # Code from module alloca:
150 # Code from module alloca-opt: 148 # Code from module alloca-opt:
151 gl_FUNC_ALLOCA 149 gl_FUNC_ALLOCA
152 # Code from module arg-nonnull: 150 # Code from module arg-nonnull:
@@ -222,7 +220,7 @@ AC_DEFUN([gl_INIT],
222 gl_FUNC_GETOPT_POSIX 220 gl_FUNC_GETOPT_POSIX
223 # Code from module gettext: 221 # Code from module gettext:
224 dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac. 222 dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac.
225 AM_GNU_GETTEXT_VERSION([0.17]) 223 AM_GNU_GETTEXT_VERSION([0.18.1])
226 # Code from module gettext-h: 224 # Code from module gettext-h:
227 AC_SUBST([LIBINTL]) 225 AC_SUBST([LIBINTL])
228 AC_SUBST([LTLIBINTL]) 226 AC_SUBST([LTLIBINTL])
@@ -522,7 +520,6 @@ AC_DEFUN([gl_FILE_LIST], [
522 build-aux/config.rpath 520 build-aux/config.rpath
523 build-aux/warn-on-use.h 521 build-aux/warn-on-use.h
524 lib/alignof.h 522 lib/alignof.h
525 lib/alloca.c
526 lib/alloca.in.h 523 lib/alloca.in.h
527 lib/arpa_inet.in.h 524 lib/arpa_inet.in.h
528 lib/asnprintf.c 525 lib/asnprintf.c
@@ -660,6 +657,7 @@ AC_DEFUN([gl_FILE_LIST], [
660 m4/00gnulib.m4 657 m4/00gnulib.m4
661 m4/alloca.m4 658 m4/alloca.m4
662 m4/arpa_inet_h.m4 659 m4/arpa_inet_h.m4
660 m4/asm-underscore.m4
663 m4/base64.m4 661 m4/base64.m4
664 m4/btowc.m4 662 m4/btowc.m4
665 m4/c-strtod.m4 663 m4/c-strtod.m4
diff --git a/gl/m4/iconv.m4 b/gl/m4/iconv.m4
index f46ff14..e2041b9 100644
--- a/gl/m4/iconv.m4
+++ b/gl/m4/iconv.m4
@@ -1,4 +1,4 @@
1# iconv.m4 serial 9 (gettext-0.18) 1# iconv.m4 serial 11 (gettext-0.18.1)
2dnl Copyright (C) 2000-2002, 2007-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2000-2002, 2007-2010 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
@@ -170,7 +170,22 @@ int main ()
170 AC_SUBST([LTLIBICONV]) 170 AC_SUBST([LTLIBICONV])
171]) 171])
172 172
173AC_DEFUN([AM_ICONV], 173dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to
174dnl avoid warnings like
175dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required".
176dnl This is tricky because of the way 'aclocal' is implemented:
177dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN.
178dnl Otherwise aclocal's initial scan pass would miss the macro definition.
179dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions.
180dnl Otherwise aclocal would emit many "Use of uninitialized value $1"
181dnl warnings.
182m4_define([gl_iconv_AC_DEFUN],
183 m4_version_prereq([2.64],
184 [[AC_DEFUN_ONCE(
185 [$1], [$2])]],
186 [[AC_DEFUN(
187 [$1], [$2])]]))
188gl_iconv_AC_DEFUN([AM_ICONV],
174[ 189[
175 AM_ICONV_LINK 190 AM_ICONV_LINK
176 if test "$am_cv_func_iconv" = yes; then 191 if test "$am_cv_func_iconv" = yes; then
diff --git a/gl/m4/intl.m4 b/gl/m4/intl.m4
index 5e17fea..335b23c 100644
--- a/gl/m4/intl.m4
+++ b/gl/m4/intl.m4
@@ -1,5 +1,5 @@
1# intl.m4 serial 8 (gettext-0.17) 1# intl.m4 serial 17 (gettext-0.18)
2dnl Copyright (C) 1995-2007, 2009-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 1995-2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -15,9 +15,9 @@ dnl They are *not* in the public domain.
15 15
16dnl Authors: 16dnl Authors:
17dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000. 17dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
18dnl Bruno Haible <haible@clisp.cons.org>, 2000-2006. 18dnl Bruno Haible <haible@clisp.cons.org>, 2000-2009.
19 19
20AC_PREREQ(2.52) 20AC_PREREQ([2.52])
21 21
22dnl Checks for all prerequisites of the intl subdirectory, 22dnl Checks for all prerequisites of the intl subdirectory,
23dnl except for INTL_LIBTOOL_SUFFIX_PREFIX (and possibly LIBTOOL), INTLOBJS, 23dnl except for INTL_LIBTOOL_SUFFIX_PREFIX (and possibly LIBTOOL), INTLOBJS,
@@ -40,14 +40,24 @@ AC_DEFUN([AM_INTL_SUBDIR],
40 AC_REQUIRE([gt_PRINTF_POSIX]) 40 AC_REQUIRE([gt_PRINTF_POSIX])
41 AC_REQUIRE([gl_GLIBC21])dnl 41 AC_REQUIRE([gl_GLIBC21])dnl
42 AC_REQUIRE([gl_XSIZE])dnl 42 AC_REQUIRE([gl_XSIZE])dnl
43 AC_REQUIRE([gl_FCNTL_O_FLAGS])dnl
43 AC_REQUIRE([gt_INTL_MACOSX])dnl 44 AC_REQUIRE([gt_INTL_MACOSX])dnl
44 45
46 dnl Support for automake's --enable-silent-rules.
47 case "$enable_silent_rules" in
48 yes) INTL_DEFAULT_VERBOSITY=0;;
49 no) INTL_DEFAULT_VERBOSITY=1;;
50 *) INTL_DEFAULT_VERBOSITY=1;;
51 esac
52 AC_SUBST([INTL_DEFAULT_VERBOSITY])
53
45 AC_CHECK_TYPE([ptrdiff_t], , 54 AC_CHECK_TYPE([ptrdiff_t], ,
46 [AC_DEFINE([ptrdiff_t], [long], 55 [AC_DEFINE([ptrdiff_t], [long],
47 [Define as the type of the result of subtracting two pointers, if the system doesn't define it.]) 56 [Define as the type of the result of subtracting two pointers, if the system doesn't define it.])
48 ]) 57 ])
49 AC_CHECK_HEADERS([stddef.h stdlib.h string.h]) 58 AC_CHECK_HEADERS([stddef.h stdlib.h string.h])
50 AC_CHECK_FUNCS([asprintf fwprintf putenv setenv setlocale snprintf wcslen]) 59 AC_CHECK_FUNCS([asprintf fwprintf newlocale putenv setenv setlocale \
60 snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb])
51 61
52 dnl Use the _snprintf function only if it is declared (because on NetBSD it 62 dnl Use the _snprintf function only if it is declared (because on NetBSD it
53 dnl is defined as a weak alias of snprintf; we prefer to use the latter). 63 dnl is defined as a weak alias of snprintf; we prefer to use the latter).
@@ -78,6 +88,12 @@ AC_DEFUN([AM_INTL_SUBDIR],
78 HAVE_SNPRINTF=0 88 HAVE_SNPRINTF=0
79 fi 89 fi
80 AC_SUBST([HAVE_SNPRINTF]) 90 AC_SUBST([HAVE_SNPRINTF])
91 if test "$ac_cv_func_newlocale" = yes; then
92 HAVE_NEWLOCALE=1
93 else
94 HAVE_NEWLOCALE=0
95 fi
96 AC_SUBST([HAVE_NEWLOCALE])
81 if test "$ac_cv_func_wprintf" = yes; then 97 if test "$ac_cv_func_wprintf" = yes; then
82 HAVE_WPRINTF=1 98 HAVE_WPRINTF=1
83 else 99 else
@@ -146,22 +162,31 @@ AC_DEFUN([AM_INTL_SUBDIR],
146#define __libc_lock_lock_recursive gl_recursive_lock_lock 162#define __libc_lock_lock_recursive gl_recursive_lock_lock
147#define __libc_lock_unlock_recursive gl_recursive_lock_unlock 163#define __libc_lock_unlock_recursive gl_recursive_lock_unlock
148#define glthread_in_use libintl_thread_in_use 164#define glthread_in_use libintl_thread_in_use
149#define glthread_lock_init libintl_lock_init 165#define glthread_lock_init_func libintl_lock_init_func
150#define glthread_lock_lock libintl_lock_lock 166#define glthread_lock_lock_func libintl_lock_lock_func
151#define glthread_lock_unlock libintl_lock_unlock 167#define glthread_lock_unlock_func libintl_lock_unlock_func
152#define glthread_lock_destroy libintl_lock_destroy 168#define glthread_lock_destroy_func libintl_lock_destroy_func
153#define glthread_rwlock_init libintl_rwlock_init 169#define glthread_rwlock_init_multithreaded libintl_rwlock_init_multithreaded
154#define glthread_rwlock_rdlock libintl_rwlock_rdlock 170#define glthread_rwlock_init_func libintl_rwlock_init_func
155#define glthread_rwlock_wrlock libintl_rwlock_wrlock 171#define glthread_rwlock_rdlock_multithreaded libintl_rwlock_rdlock_multithreaded
156#define glthread_rwlock_unlock libintl_rwlock_unlock 172#define glthread_rwlock_rdlock_func libintl_rwlock_rdlock_func
157#define glthread_rwlock_destroy libintl_rwlock_destroy 173#define glthread_rwlock_wrlock_multithreaded libintl_rwlock_wrlock_multithreaded
158#define glthread_recursive_lock_init libintl_recursive_lock_init 174#define glthread_rwlock_wrlock_func libintl_rwlock_wrlock_func
159#define glthread_recursive_lock_lock libintl_recursive_lock_lock 175#define glthread_rwlock_unlock_multithreaded libintl_rwlock_unlock_multithreaded
160#define glthread_recursive_lock_unlock libintl_recursive_lock_unlock 176#define glthread_rwlock_unlock_func libintl_rwlock_unlock_func
161#define glthread_recursive_lock_destroy libintl_recursive_lock_destroy 177#define glthread_rwlock_destroy_multithreaded libintl_rwlock_destroy_multithreaded
162#define glthread_once libintl_once 178#define glthread_rwlock_destroy_func libintl_rwlock_destroy_func
163#define glthread_once_call libintl_once_call 179#define glthread_recursive_lock_init_multithreaded libintl_recursive_lock_init_multithreaded
180#define glthread_recursive_lock_init_func libintl_recursive_lock_init_func
181#define glthread_recursive_lock_lock_multithreaded libintl_recursive_lock_lock_multithreaded
182#define glthread_recursive_lock_lock_func libintl_recursive_lock_lock_func
183#define glthread_recursive_lock_unlock_multithreaded libintl_recursive_lock_unlock_multithreaded
184#define glthread_recursive_lock_unlock_func libintl_recursive_lock_unlock_func
185#define glthread_recursive_lock_destroy_multithreaded libintl_recursive_lock_destroy_multithreaded
186#define glthread_recursive_lock_destroy_func libintl_recursive_lock_destroy_func
187#define glthread_once_func libintl_once_func
164#define glthread_once_singlethreaded libintl_once_singlethreaded 188#define glthread_once_singlethreaded libintl_once_singlethreaded
189#define glthread_once_multithreaded libintl_once_multithreaded
165]) 190])
166]) 191])
167 192
@@ -198,40 +223,24 @@ AC_DEFUN([gt_INTL_SUBDIR_CORE],
198 AC_TRY_LINK( 223 AC_TRY_LINK(
199 [int foo (int a) { a = __builtin_expect (a, 10); return a == 10 ? 0 : 1; }], 224 [int foo (int a) { a = __builtin_expect (a, 10); return a == 10 ? 0 : 1; }],
200 [], 225 [],
201 [AC_DEFINE([HAVE_BUILTIN_EXPECT], 1, 226 [AC_DEFINE([HAVE_BUILTIN_EXPECT], [1],
202 [Define to 1 if the compiler understands __builtin_expect.])]) 227 [Define to 1 if the compiler understands __builtin_expect.])])
203 228
204 AC_CHECK_HEADERS([argz.h inttypes.h limits.h unistd.h sys/param.h]) 229 AC_CHECK_HEADERS([argz.h inttypes.h limits.h unistd.h sys/param.h])
205 AC_CHECK_FUNCS([getcwd getegid geteuid getgid getuid mempcpy munmap \ 230 AC_CHECK_FUNCS([getcwd getegid geteuid getgid getuid mempcpy munmap \
206 stpcpy strcasecmp strdup strtoul tsearch argz_count argz_stringify \ 231 stpcpy strcasecmp strdup strtoul tsearch uselocale argz_count \
207 argz_next __fsetlocking]) 232 argz_stringify argz_next __fsetlocking])
208 233
209 dnl Use the *_unlocked functions only if they are declared. 234 dnl Use the *_unlocked functions only if they are declared.
210 dnl (because some of them were defined without being declared in Solaris 235 dnl (because some of them were defined without being declared in Solaris
211 dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built 236 dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built
212 dnl on Solaris 2.5.1 to run on Solaris 2.6). 237 dnl on Solaris 2.5.1 to run on Solaris 2.6).
213 dnl Don't use AC_CHECK_DECLS because it isn't supported in autoconf-2.13. 238 dnl Don't use AC_CHECK_DECLS because it isn't supported in autoconf-2.13.
214 gt_CHECK_DECL(feof_unlocked, [#include <stdio.h>]) 239 gt_CHECK_DECL([feof_unlocked], [#include <stdio.h>])
215 gt_CHECK_DECL(fgets_unlocked, [#include <stdio.h>]) 240 gt_CHECK_DECL([fgets_unlocked], [#include <stdio.h>])
216 241
217 AM_ICONV 242 AM_ICONV
218 243
219 dnl glibc >= 2.4 has a NL_LOCALE_NAME macro when _GNU_SOURCE is defined,
220 dnl and a _NL_LOCALE_NAME macro always.
221 AC_CACHE_CHECK([for NL_LOCALE_NAME macro], gt_cv_nl_locale_name,
222 [AC_TRY_LINK([#include <langinfo.h>
223#include <locale.h>],
224 [char* cs = nl_langinfo(_NL_LOCALE_NAME(LC_MESSAGES));
225 return !cs;
226 ],
227 gt_cv_nl_locale_name=yes,
228 gt_cv_nl_locale_name=no)
229 ])
230 if test $gt_cv_nl_locale_name = yes; then
231 AC_DEFINE(HAVE_NL_LOCALE_NAME, 1,
232 [Define if you have <langinfo.h> and it defines the NL_LOCALE_NAME macro if _GNU_SOURCE is defined.])
233 fi
234
235 dnl intl/plural.c is generated from intl/plural.y. It requires bison, 244 dnl intl/plural.c is generated from intl/plural.y. It requires bison,
236 dnl because plural.y uses bison specific features. It requires at least 245 dnl because plural.y uses bison specific features. It requires at least
237 dnl bison-1.26 because earlier versions generate a plural.c that doesn't 246 dnl bison-1.26 because earlier versions generate a plural.c that doesn't
@@ -269,7 +278,7 @@ dnl gt_CHECK_DECL(FUNC, INCLUDES)
269dnl Check whether a function is declared. 278dnl Check whether a function is declared.
270AC_DEFUN([gt_CHECK_DECL], 279AC_DEFUN([gt_CHECK_DECL],
271[ 280[
272 AC_CACHE_CHECK([whether $1 is declared], ac_cv_have_decl_$1, 281 AC_CACHE_CHECK([whether $1 is declared], [ac_cv_have_decl_$1],
273 [AC_TRY_COMPILE([$2], [ 282 [AC_TRY_COMPILE([$2], [
274#ifndef $1 283#ifndef $1
275 char *p = (char *) $1; 284 char *p = (char *) $1;
diff --git a/gl/m4/lib-link.m4 b/gl/m4/lib-link.m4
index 90e1ac9..59b367d 100644
--- a/gl/m4/lib-link.m4
+++ b/gl/m4/lib-link.m4
@@ -1,4 +1,4 @@
1# lib-link.m4 serial 20 (gettext-0.18) 1# lib-link.m4 serial 23 (gettext-0.18.2)
2dnl Copyright (C) 2001-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2001-2010 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
@@ -18,9 +18,9 @@ AC_DEFUN([AC_LIB_LINKFLAGS],
18[ 18[
19 AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) 19 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
20 AC_REQUIRE([AC_LIB_RPATH]) 20 AC_REQUIRE([AC_LIB_RPATH])
21 pushdef([Name],[translit([$1],[./-], [___])]) 21 pushdef([Name],[m4_translit([$1],[./+-], [____])])
22 pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], 22 pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
23 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) 23 [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
24 AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [ 24 AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
25 AC_LIB_LINKFLAGS_BODY([$1], [$2]) 25 AC_LIB_LINKFLAGS_BODY([$1], [$2])
26 ac_cv_lib[]Name[]_libs="$LIB[]NAME" 26 ac_cv_lib[]Name[]_libs="$LIB[]NAME"
@@ -58,9 +58,9 @@ AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
58[ 58[
59 AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) 59 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
60 AC_REQUIRE([AC_LIB_RPATH]) 60 AC_REQUIRE([AC_LIB_RPATH])
61 pushdef([Name],[translit([$1],[./-], [___])]) 61 pushdef([Name],[m4_translit([$1],[./+-], [____])])
62 pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], 62 pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
63 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) 63 [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
64 64
65 dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME 65 dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
66 dnl accordingly. 66 dnl accordingly.
@@ -74,7 +74,17 @@ AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
74 74
75 AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [ 75 AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
76 ac_save_LIBS="$LIBS" 76 ac_save_LIBS="$LIBS"
77 LIBS="$LIBS $LIB[]NAME" 77 dnl If $LIB[]NAME contains some -l options, add it to the end of LIBS,
78 dnl because these -l options might require -L options that are present in
79 dnl LIBS. -l options benefit only from the -L options listed before it.
80 dnl Otherwise, add it to the front of LIBS, because it may be a static
81 dnl library that depends on another static library that is present in LIBS.
82 dnl Static libraries benefit only from the static libraries listed after
83 dnl it.
84 case " $LIB[]NAME" in
85 *" -l"*) LIBS="$LIBS $LIB[]NAME" ;;
86 *) LIBS="$LIB[]NAME $LIBS" ;;
87 esac
78 AC_TRY_LINK([$3], [$4], 88 AC_TRY_LINK([$3], [$4],
79 [ac_cv_lib[]Name=yes], 89 [ac_cv_lib[]Name=yes],
80 [ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])']) 90 [ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])'])
@@ -147,13 +157,13 @@ dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar
147dnl macro call that searches for libname. 157dnl macro call that searches for libname.
148AC_DEFUN([AC_LIB_FROMPACKAGE], 158AC_DEFUN([AC_LIB_FROMPACKAGE],
149[ 159[
150 pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], 160 pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
151 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) 161 [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
152 define([acl_frompackage_]NAME, [$2]) 162 define([acl_frompackage_]NAME, [$2])
153 popdef([NAME]) 163 popdef([NAME])
154 pushdef([PACK],[$2]) 164 pushdef([PACK],[$2])
155 pushdef([PACKUP],[translit(PACK,[abcdefghijklmnopqrstuvwxyz./-], 165 pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-],
156 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) 166 [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
157 define([acl_libsinpackage_]PACKUP, 167 define([acl_libsinpackage_]PACKUP,
158 m4_ifdef([acl_libsinpackage_]PACKUP, [acl_libsinpackage_]PACKUP[[, ]],)[lib$1]) 168 m4_ifdef([acl_libsinpackage_]PACKUP, [acl_libsinpackage_]PACKUP[[, ]],)[lib$1])
159 popdef([PACKUP]) 169 popdef([PACKUP])
@@ -168,14 +178,14 @@ dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
168AC_DEFUN([AC_LIB_LINKFLAGS_BODY], 178AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
169[ 179[
170 AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) 180 AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
171 pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], 181 pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
172 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) 182 [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
173 pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])]) 183 pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])])
174 pushdef([PACKUP],[translit(PACK,[abcdefghijklmnopqrstuvwxyz./-], 184 pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-],
175 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) 185 [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
176 pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])]) 186 pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])])
177 dnl Autoconf >= 2.61 supports dots in --with options. 187 dnl Autoconf >= 2.61 supports dots in --with options.
178 pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[translit(PACK,[.],[_])],PACK)]) 188 pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[m4_translit(PACK,[.],[_])],PACK)])
179 dnl By default, look in $includedir and $libdir. 189 dnl By default, look in $includedir and $libdir.
180 use_additional=yes 190 use_additional=yes
181 AC_LIB_WITH_FINAL_PREFIX([ 191 AC_LIB_WITH_FINAL_PREFIX([
@@ -232,7 +242,7 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
232 names_already_handled="$names_already_handled $name" 242 names_already_handled="$names_already_handled $name"
233 dnl See if it was already located by an earlier AC_LIB_LINKFLAGS 243 dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
234 dnl or AC_LIB_HAVE_LINKFLAGS call. 244 dnl or AC_LIB_HAVE_LINKFLAGS call.
235 uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'` 245 uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'`
236 eval value=\"\$HAVE_LIB$uppername\" 246 eval value=\"\$HAVE_LIB$uppername\"
237 if test -n "$value"; then 247 if test -n "$value"; then
238 if test "$value" = yes; then 248 if test "$value" = yes; then
diff --git a/gl/m4/netdb_h.m4 b/gl/m4/netdb_h.m4
index 40ba8f6..c870fb6 100644
--- a/gl/m4/netdb_h.m4
+++ b/gl/m4/netdb_h.m4
@@ -1,4 +1,4 @@
1# netdb_h.m4 serial 7 1# netdb_h.m4 serial 9
2dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
@@ -10,21 +10,16 @@ AC_DEFUN([gl_HEADER_NETDB],
10 AC_CHECK_HEADERS_ONCE([netdb.h]) 10 AC_CHECK_HEADERS_ONCE([netdb.h])
11 gl_CHECK_NEXT_HEADERS([netdb.h]) 11 gl_CHECK_NEXT_HEADERS([netdb.h])
12 if test $ac_cv_header_netdb_h = yes; then 12 if test $ac_cv_header_netdb_h = yes; then
13 AC_COMPILE_IFELSE(
14 [AC_LANG_PROGRAM([[
15 #include <netdb.h>
16 struct addrinfo a;
17 int b = EAI_OVERFLOW;
18 int c = AI_NUMERICSERV;
19 ]])],
20 [NETDB_H=''], [NETDB_H='netdb.h'])
21 HAVE_NETDB_H=1 13 HAVE_NETDB_H=1
22 else 14 else
23 NETDB_H='netdb.h'
24 HAVE_NETDB_H=0 15 HAVE_NETDB_H=0
25 fi 16 fi
26 AC_SUBST([HAVE_NETDB_H]) 17 AC_SUBST([HAVE_NETDB_H])
27 AC_SUBST([NETDB_H]) 18
19 dnl Check for declarations of anything we want to poison if the
20 dnl corresponding gnulib module is not in use.
21 gl_WARN_ON_USE_PREPARE([[#include <netdb.h>]],
22 [getaddrinfo freeaddrinfo gai_strerror getnameinfo])
28]) 23])
29 24
30AC_DEFUN([gl_NETDB_MODULE_INDICATOR], 25AC_DEFUN([gl_NETDB_MODULE_INDICATOR],
diff --git a/gl/m4/onceonly.m4 b/gl/m4/onceonly.m4
index 4a3cd84..6a9c87b 100644
--- a/gl/m4/onceonly.m4
+++ b/gl/m4/onceonly.m4
@@ -1,4 +1,4 @@
1# onceonly.m4 serial 6 1# onceonly.m4 serial 7
2dnl Copyright (C) 2002-2003, 2005-2006, 2008-2010 Free Software Foundation, 2dnl Copyright (C) 2002-2003, 2005-2006, 2008-2010 Free Software Foundation,
3dnl Inc. 3dnl Inc.
4dnl This file is free software, distributed under the terms of the GNU 4dnl This file is free software, distributed under the terms of the GNU
@@ -39,16 +39,16 @@ AC_PREREQ([2.59])
39AC_DEFUN([AC_CHECK_HEADERS_ONCE], [ 39AC_DEFUN([AC_CHECK_HEADERS_ONCE], [
40 : 40 :
41 m4_foreach_w([gl_HEADER_NAME], [$1], [ 41 m4_foreach_w([gl_HEADER_NAME], [$1], [
42 AC_DEFUN([gl_CHECK_HEADER_]m4_quote(translit(gl_HEADER_NAME, 42 AC_DEFUN([gl_CHECK_HEADER_]m4_quote(m4_translit(gl_HEADER_NAME,
43 [./-], [___])), [ 43 [./-], [___])), [
44 m4_divert_text([INIT_PREPARE], 44 m4_divert_text([INIT_PREPARE],
45 [gl_header_list="$gl_header_list gl_HEADER_NAME"]) 45 [gl_header_list="$gl_header_list gl_HEADER_NAME"])
46 gl_HEADERS_EXPANSION 46 gl_HEADERS_EXPANSION
47 AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([gl_HEADER_NAME])), 47 AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([gl_HEADER_NAME])),
48 [Define to 1 if you have the <]m4_defn([gl_HEADER_NAME])[> header file.]) 48 [Define to 1 if you have the <]m4_defn([gl_HEADER_NAME])[> header file.])
49 ]) 49 ])
50 AC_REQUIRE([gl_CHECK_HEADER_]m4_quote(translit(gl_HEADER_NAME, 50 AC_REQUIRE([gl_CHECK_HEADER_]m4_quote(m4_translit(gl_HEADER_NAME,
51 [./-], [___]))) 51 [./-], [___])))
52 ]) 52 ])
53]) 53])
54m4_define([gl_HEADERS_EXPANSION], [ 54m4_define([gl_HEADERS_EXPANSION], [
diff --git a/gl/m4/po.m4 b/gl/m4/po.m4
index 960efe1..47f36a4 100644
--- a/gl/m4/po.m4
+++ b/gl/m4/po.m4
@@ -29,7 +29,7 @@ AC_DEFUN([AM_PO_SUBDIRS],
29 29
30 dnl Release version of the gettext macros. This is used to ensure that 30 dnl Release version of the gettext macros. This is used to ensure that
31 dnl the gettext macros and po/Makefile.in.in are in sync. 31 dnl the gettext macros and po/Makefile.in.in are in sync.
32 AC_SUBST([GETTEXT_MACRO_VERSION], [0.17]) 32 AC_SUBST([GETTEXT_MACRO_VERSION], [0.18])
33 33
34 dnl Perform the following tests also if --disable-nls has been given, 34 dnl Perform the following tests also if --disable-nls has been given,
35 dnl because they are needed for "make dist" to work. 35 dnl because they are needed for "make dist" to work.
diff --git a/gl/m4/printf.m4 b/gl/m4/printf.m4
index ebca536..b31efe3 100644
--- a/gl/m4/printf.m4
+++ b/gl/m4/printf.m4
@@ -1,4 +1,4 @@
1# printf.m4 serial 33 1# printf.m4 serial 34
2dnl Copyright (C) 2003, 2007-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2003, 2007-2010 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
@@ -1101,7 +1101,7 @@ dnl }
1101dnl --------------------------------------------------------------------- 1101dnl ---------------------------------------------------------------------
1102dnl Result is gl_cv_func_snprintf_retval_c99. 1102dnl Result is gl_cv_func_snprintf_retval_c99.
1103 1103
1104AC_DEFUN([gl_SNPRINTF_RETVAL_C99], 1104AC_DEFUN_ONCE([gl_SNPRINTF_RETVAL_C99],
1105[ 1105[
1106 AC_REQUIRE([AC_PROG_CC]) 1106 AC_REQUIRE([AC_PROG_CC])
1107 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 1107 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
diff --git a/gl/m4/sockpfaf.m4 b/gl/m4/sockpfaf.m4
index 8a0c236..8806705 100644
--- a/gl/m4/sockpfaf.m4
+++ b/gl/m4/sockpfaf.m4
@@ -47,6 +47,9 @@ AC_DEFUN([gl_SOCKET_FAMILIES],
47#endif 47#endif
48#ifdef HAVE_WINSOCK2_H 48#ifdef HAVE_WINSOCK2_H
49#include <winsock2.h> 49#include <winsock2.h>
50#endif
51#ifdef HAVE_WS2TCPIP_H
52#include <ws2tcpip.h>
50#endif]], 53#endif]],
51[[int x = AF_INET6; struct in6_addr y; struct sockaddr_in6 z; 54[[int x = AF_INET6; struct in6_addr y; struct sockaddr_in6 z;
52 if (&x && &y && &z) return 0;]])], 55 if (&x && &y && &z) return 0;]])],
diff --git a/gl/m4/stdint.m4 b/gl/m4/stdint.m4
index 1cc57e6..c5e813a 100644
--- a/gl/m4/stdint.m4
+++ b/gl/m4/stdint.m4
@@ -1,4 +1,4 @@
1# stdint.m4 serial 34 1# stdint.m4 serial 35
2dnl Copyright (C) 2001-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2001-2010 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
@@ -309,7 +309,7 @@ AC_DEFUN([gl_STDINT_BITSIZEOF],
309 dnl config.h.in, 309 dnl config.h.in,
310 dnl - extra AC_SUBST calls, so that the right substitutions are made. 310 dnl - extra AC_SUBST calls, so that the right substitutions are made.
311 m4_foreach_w([gltype], [$1], 311 m4_foreach_w([gltype], [$1],
312 [AH_TEMPLATE([BITSIZEOF_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]), 312 [AH_TEMPLATE([BITSIZEOF_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]),
313 [Define to the number of bits in type ']gltype['.])]) 313 [Define to the number of bits in type ']gltype['.])])
314 for gltype in $1 ; do 314 for gltype in $1 ; do
315 AC_CACHE_CHECK([for bit size of $gltype], [gl_cv_bitsizeof_${gltype}], 315 AC_CACHE_CHECK([for bit size of $gltype], [gl_cv_bitsizeof_${gltype}],
@@ -334,7 +334,7 @@ AC_DEFUN([gl_STDINT_BITSIZEOF],
334 eval BITSIZEOF_${GLTYPE}=\$result 334 eval BITSIZEOF_${GLTYPE}=\$result
335 done 335 done
336 m4_foreach_w([gltype], [$1], 336 m4_foreach_w([gltype], [$1],
337 [AC_SUBST([BITSIZEOF_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))]) 337 [AC_SUBST([BITSIZEOF_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))])
338]) 338])
339 339
340dnl gl_CHECK_TYPES_SIGNED(TYPES, INCLUDES) 340dnl gl_CHECK_TYPES_SIGNED(TYPES, INCLUDES)
@@ -347,7 +347,7 @@ AC_DEFUN([gl_CHECK_TYPES_SIGNED],
347 dnl config.h.in, 347 dnl config.h.in,
348 dnl - extra AC_SUBST calls, so that the right substitutions are made. 348 dnl - extra AC_SUBST calls, so that the right substitutions are made.
349 m4_foreach_w([gltype], [$1], 349 m4_foreach_w([gltype], [$1],
350 [AH_TEMPLATE([HAVE_SIGNED_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]), 350 [AH_TEMPLATE([HAVE_SIGNED_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]),
351 [Define to 1 if ']gltype[' is a signed integer type.])]) 351 [Define to 1 if ']gltype[' is a signed integer type.])])
352 for gltype in $1 ; do 352 for gltype in $1 ; do
353 AC_CACHE_CHECK([whether $gltype is signed], [gl_cv_type_${gltype}_signed], 353 AC_CACHE_CHECK([whether $gltype is signed], [gl_cv_type_${gltype}_signed],
@@ -367,7 +367,7 @@ AC_DEFUN([gl_CHECK_TYPES_SIGNED],
367 fi 367 fi
368 done 368 done
369 m4_foreach_w([gltype], [$1], 369 m4_foreach_w([gltype], [$1],
370 [AC_SUBST([HAVE_SIGNED_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))]) 370 [AC_SUBST([HAVE_SIGNED_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))])
371]) 371])
372 372
373dnl gl_INTEGER_TYPE_SUFFIX(TYPES, INCLUDES) 373dnl gl_INTEGER_TYPE_SUFFIX(TYPES, INCLUDES)
@@ -380,7 +380,7 @@ AC_DEFUN([gl_INTEGER_TYPE_SUFFIX],
380 dnl config.h.in, 380 dnl config.h.in,
381 dnl - extra AC_SUBST calls, so that the right substitutions are made. 381 dnl - extra AC_SUBST calls, so that the right substitutions are made.
382 m4_foreach_w([gltype], [$1], 382 m4_foreach_w([gltype], [$1],
383 [AH_TEMPLATE(translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX], 383 [AH_TEMPLATE(m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX],
384 [Define to l, ll, u, ul, ull, etc., as suitable for 384 [Define to l, ll, u, ul, ull, etc., as suitable for
385 constants of type ']gltype['.])]) 385 constants of type ']gltype['.])])
386 for gltype in $1 ; do 386 for gltype in $1 ; do
@@ -419,7 +419,7 @@ AC_DEFUN([gl_INTEGER_TYPE_SUFFIX],
419 AC_DEFINE_UNQUOTED([${GLTYPE}_SUFFIX], [$result]) 419 AC_DEFINE_UNQUOTED([${GLTYPE}_SUFFIX], [$result])
420 done 420 done
421 m4_foreach_w([gltype], [$1], 421 m4_foreach_w([gltype], [$1],
422 [AC_SUBST(translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX])]) 422 [AC_SUBST(m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX])])
423]) 423])
424 424
425dnl gl_STDINT_INCLUDES 425dnl gl_STDINT_INCLUDES
diff --git a/gl/m4/stdio_h.m4 b/gl/m4/stdio_h.m4
index 1d1d95e..f5650cd 100644
--- a/gl/m4/stdio_h.m4
+++ b/gl/m4/stdio_h.m4
@@ -1,4 +1,4 @@
1# stdio_h.m4 serial 30 1# stdio_h.m4 serial 31
2dnl Copyright (C) 2007-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
@@ -8,6 +8,7 @@ AC_DEFUN([gl_STDIO_H],
8[ 8[
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS]) 9 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
10 AC_REQUIRE([AC_C_INLINE]) 10 AC_REQUIRE([AC_C_INLINE])
11 AC_REQUIRE([gl_ASM_SYMBOL_PREFIX])
11 gl_CHECK_NEXT_HEADERS([stdio.h]) 12 gl_CHECK_NEXT_HEADERS([stdio.h])
12 dnl No need to create extra modules for these functions. Everyone who uses 13 dnl No need to create extra modules for these functions. Everyone who uses
13 dnl <stdio.h> likely needs them. 14 dnl <stdio.h> likely needs them.
diff --git a/gl/m4/string_h.m4 b/gl/m4/string_h.m4
index cf26123..1977aec 100644
--- a/gl/m4/string_h.m4
+++ b/gl/m4/string_h.m4
@@ -5,7 +5,7 @@
5# gives unlimited permission to copy and/or distribute it, 5# gives unlimited permission to copy and/or distribute it,
6# with or without modifications, as long as this notice is preserved. 6# with or without modifications, as long as this notice is preserved.
7 7
8# serial 16 8# serial 17
9 9
10# Written by Paul Eggert. 10# Written by Paul Eggert.
11 11
@@ -105,6 +105,7 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
105 REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR]) 105 REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR])
106 REPLACE_STRNCAT=0; AC_SUBST([REPLACE_STRNCAT]) 106 REPLACE_STRNCAT=0; AC_SUBST([REPLACE_STRNCAT])
107 REPLACE_STRNDUP=0; AC_SUBST([REPLACE_STRNDUP]) 107 REPLACE_STRNDUP=0; AC_SUBST([REPLACE_STRNDUP])
108 REPLACE_STRNLEN=0; AC_SUBST([REPLACE_STRNLEN])
108 REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL]) 109 REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL])
109 REPLACE_STRTOK_R=0; AC_SUBST([REPLACE_STRTOK_R]) 110 REPLACE_STRTOK_R=0; AC_SUBST([REPLACE_STRTOK_R])
110 UNDEFINE_STRTOK_R=0; AC_SUBST([UNDEFINE_STRTOK_R]) 111 UNDEFINE_STRTOK_R=0; AC_SUBST([UNDEFINE_STRTOK_R])
diff --git a/gl/m4/strnlen.m4 b/gl/m4/strnlen.m4
index cd48948..52bb838 100644
--- a/gl/m4/strnlen.m4
+++ b/gl/m4/strnlen.m4
@@ -1,4 +1,4 @@
1# strnlen.m4 serial 10 1# strnlen.m4 serial 12
2dnl Copyright (C) 2002-2003, 2005-2007, 2009-2010 Free Software Foundation, 2dnl Copyright (C) 2002-2003, 2005-2007, 2009-2010 Free Software Foundation,
3dnl Inc. 3dnl Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
@@ -7,23 +7,23 @@ dnl with or without modifications, as long as this notice is preserved.
7 7
8AC_DEFUN([gl_FUNC_STRNLEN], 8AC_DEFUN([gl_FUNC_STRNLEN],
9[ 9[
10 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
11
10 dnl Persuade glibc <string.h> to declare strnlen(). 12 dnl Persuade glibc <string.h> to declare strnlen().
11 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) 13 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
12 14
13 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
14 AC_CHECK_DECLS_ONCE([strnlen]) 15 AC_CHECK_DECLS_ONCE([strnlen])
15 if test $ac_cv_have_decl_strnlen = no; then 16 if test $ac_cv_have_decl_strnlen = no; then
16 HAVE_DECL_STRNLEN=0 17 HAVE_DECL_STRNLEN=0
18 else
19 AC_FUNC_STRNLEN
20 dnl Note: AC_FUNC_STRNLEN does AC_LIBOBJ([strnlen]).
21 if test $ac_cv_func_strnlen_working = no; then
22 REPLACE_STRNLEN=1
23 fi
17 fi 24 fi
18 25 if test $HAVE_DECL_STRNLEN = 0 || test $REPLACE_STRNLEN = 1; then
19 AC_FUNC_STRNLEN 26 AC_LIBOBJ([strnlen])
20 if test $ac_cv_func_strnlen_working = no; then
21 # This is necessary because automake-1.6.1 doesn't understand
22 # that the above use of AC_FUNC_STRNLEN means we may have to use
23 # lib/strnlen.c.
24 #AC_LIBOBJ([strnlen])
25 AC_DEFINE([strnlen], [rpl_strnlen],
26 [Define to rpl_strnlen if the replacement function should be used.])
27 gl_PREREQ_STRNLEN 27 gl_PREREQ_STRNLEN
28 fi 28 fi
29]) 29])
diff --git a/gl/m4/time_h.m4 b/gl/m4/time_h.m4
index b88ba94..a45a10a 100644
--- a/gl/m4/time_h.m4
+++ b/gl/m4/time_h.m4
@@ -2,6 +2,8 @@
2 2
3# Copyright (C) 2000-2001, 2003-2007, 2009-2010 Free Software Foundation, Inc. 3# Copyright (C) 2000-2001, 2003-2007, 2009-2010 Free Software Foundation, Inc.
4 4
5# serial 2
6
5# This file is free software; the Free Software Foundation 7# This file is free software; the Free Software Foundation
6# gives unlimited permission to copy and/or distribute it, 8# gives unlimited permission to copy and/or distribute it,
7# with or without modifications, as long as this notice is preserved. 9# with or without modifications, as long as this notice is preserved.
@@ -24,7 +26,7 @@ AC_DEFUN([gl_HEADER_TIME_H_BODY],
24]) 26])
25 27
26dnl Define HAVE_STRUCT_TIMESPEC if `struct timespec' is declared 28dnl Define HAVE_STRUCT_TIMESPEC if `struct timespec' is declared
27dnl in time.h or sys/time.h. 29dnl in time.h, sys/time.h, or pthread.h.
28 30
29AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC], 31AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
30[ 32[
@@ -41,6 +43,7 @@ AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
41 43
42 TIME_H_DEFINES_STRUCT_TIMESPEC=0 44 TIME_H_DEFINES_STRUCT_TIMESPEC=0
43 SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0 45 SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0
46 PTHREAD_H_DEFINES_STRUCT_TIMESPEC=0
44 if test $gl_cv_sys_struct_timespec_in_time_h = yes; then 47 if test $gl_cv_sys_struct_timespec_in_time_h = yes; then
45 TIME_H_DEFINES_STRUCT_TIMESPEC=1 48 TIME_H_DEFINES_STRUCT_TIMESPEC=1
46 else 49 else
@@ -55,10 +58,24 @@ AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
55 [gl_cv_sys_struct_timespec_in_sys_time_h=no])]) 58 [gl_cv_sys_struct_timespec_in_sys_time_h=no])])
56 if test $gl_cv_sys_struct_timespec_in_sys_time_h = yes; then 59 if test $gl_cv_sys_struct_timespec_in_sys_time_h = yes; then
57 SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=1 60 SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=1
61 else
62 AC_CACHE_CHECK([for struct timespec in <pthread.h>],
63 [gl_cv_sys_struct_timespec_in_pthread_h],
64 [AC_COMPILE_IFELSE(
65 [AC_LANG_PROGRAM(
66 [[#include <pthread.h>
67 ]],
68 [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
69 [gl_cv_sys_struct_timespec_in_pthread_h=yes],
70 [gl_cv_sys_struct_timespec_in_pthread_h=no])])
71 if test $gl_cv_sys_struct_timespec_in_pthread_h = yes; then
72 PTHREAD_H_DEFINES_STRUCT_TIMESPEC=1
73 fi
58 fi 74 fi
59 fi 75 fi
60 AC_SUBST([TIME_H_DEFINES_STRUCT_TIMESPEC]) 76 AC_SUBST([TIME_H_DEFINES_STRUCT_TIMESPEC])
61 AC_SUBST([SYS_TIME_H_DEFINES_STRUCT_TIMESPEC]) 77 AC_SUBST([SYS_TIME_H_DEFINES_STRUCT_TIMESPEC])
78 AC_SUBST([PTHREAD_H_DEFINES_STRUCT_TIMESPEC])
62]) 79])
63 80
64AC_DEFUN([gl_TIME_MODULE_INDICATOR], 81AC_DEFUN([gl_TIME_MODULE_INDICATOR],
diff --git a/gl/m4/unistd_h.m4 b/gl/m4/unistd_h.m4
index 8c2eec6..48d06c7 100644
--- a/gl/m4/unistd_h.m4
+++ b/gl/m4/unistd_h.m4
@@ -1,4 +1,4 @@
1# unistd_h.m4 serial 45 1# unistd_h.m4 serial 46
2dnl Copyright (C) 2006-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2006-2010 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
@@ -38,8 +38,9 @@ AC_DEFUN([gl_UNISTD_H],
38 ]], [chown dup2 dup3 environ euidaccess faccessat fchdir fchownat 38 ]], [chown dup2 dup3 environ euidaccess faccessat fchdir fchownat
39 fsync ftruncate getcwd getdomainname getdtablesize getgroups 39 fsync ftruncate getcwd getdomainname getdtablesize getgroups
40 gethostname getlogin getlogin_r getpagesize getusershell setusershell 40 gethostname getlogin getlogin_r getpagesize getusershell setusershell
41 endusershell lchown link linkat lseek pipe2 pread readlink readlinkat 41 endusershell lchown link linkat lseek pipe2 pread pwrite readlink
42 rmdir sleep symlink symlinkat ttyname_r unlink unlinkat usleep]) 42 readlinkat rmdir sleep symlink symlinkat ttyname_r unlink unlinkat
43 usleep])
43]) 44])
44 45
45AC_DEFUN([gl_UNISTD_MODULE_INDICATOR], 46AC_DEFUN([gl_UNISTD_MODULE_INDICATOR],
@@ -79,6 +80,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
79 GNULIB_LSEEK=0; AC_SUBST([GNULIB_LSEEK]) 80 GNULIB_LSEEK=0; AC_SUBST([GNULIB_LSEEK])
80 GNULIB_PIPE2=0; AC_SUBST([GNULIB_PIPE2]) 81 GNULIB_PIPE2=0; AC_SUBST([GNULIB_PIPE2])
81 GNULIB_PREAD=0; AC_SUBST([GNULIB_PREAD]) 82 GNULIB_PREAD=0; AC_SUBST([GNULIB_PREAD])
83 GNULIB_PWRITE=0; AC_SUBST([GNULIB_PWRITE])
82 GNULIB_READLINK=0; AC_SUBST([GNULIB_READLINK]) 84 GNULIB_READLINK=0; AC_SUBST([GNULIB_READLINK])
83 GNULIB_READLINKAT=0; AC_SUBST([GNULIB_READLINKAT]) 85 GNULIB_READLINKAT=0; AC_SUBST([GNULIB_READLINKAT])
84 GNULIB_RMDIR=0; AC_SUBST([GNULIB_RMDIR]) 86 GNULIB_RMDIR=0; AC_SUBST([GNULIB_RMDIR])
@@ -113,6 +115,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
113 HAVE_LINKAT=1; AC_SUBST([HAVE_LINKAT]) 115 HAVE_LINKAT=1; AC_SUBST([HAVE_LINKAT])
114 HAVE_PIPE2=1; AC_SUBST([HAVE_PIPE2]) 116 HAVE_PIPE2=1; AC_SUBST([HAVE_PIPE2])
115 HAVE_PREAD=1; AC_SUBST([HAVE_PREAD]) 117 HAVE_PREAD=1; AC_SUBST([HAVE_PREAD])
118 HAVE_PWRITE=1; AC_SUBST([HAVE_PWRITE])
116 HAVE_READLINK=1; AC_SUBST([HAVE_READLINK]) 119 HAVE_READLINK=1; AC_SUBST([HAVE_READLINK])
117 HAVE_READLINKAT=1; AC_SUBST([HAVE_READLINKAT]) 120 HAVE_READLINKAT=1; AC_SUBST([HAVE_READLINKAT])
118 HAVE_SLEEP=1; AC_SUBST([HAVE_SLEEP]) 121 HAVE_SLEEP=1; AC_SUBST([HAVE_SLEEP])
@@ -140,10 +143,12 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
140 REPLACE_LINKAT=0; AC_SUBST([REPLACE_LINKAT]) 143 REPLACE_LINKAT=0; AC_SUBST([REPLACE_LINKAT])
141 REPLACE_LSEEK=0; AC_SUBST([REPLACE_LSEEK]) 144 REPLACE_LSEEK=0; AC_SUBST([REPLACE_LSEEK])
142 REPLACE_PREAD=0; AC_SUBST([REPLACE_PREAD]) 145 REPLACE_PREAD=0; AC_SUBST([REPLACE_PREAD])
146 REPLACE_PWRITE=0; AC_SUBST([REPLACE_PWRITE])
143 REPLACE_READLINK=0; AC_SUBST([REPLACE_READLINK]) 147 REPLACE_READLINK=0; AC_SUBST([REPLACE_READLINK])
144 REPLACE_RMDIR=0; AC_SUBST([REPLACE_RMDIR]) 148 REPLACE_RMDIR=0; AC_SUBST([REPLACE_RMDIR])
145 REPLACE_SLEEP=0; AC_SUBST([REPLACE_SLEEP]) 149 REPLACE_SLEEP=0; AC_SUBST([REPLACE_SLEEP])
146 REPLACE_SYMLINK=0; AC_SUBST([REPLACE_SYMLINK]) 150 REPLACE_SYMLINK=0; AC_SUBST([REPLACE_SYMLINK])
151 REPLACE_TTYNAME_R=0; AC_SUBST([REPLACE_TTYNAME_R])
147 REPLACE_UNLINK=0; AC_SUBST([REPLACE_UNLINK]) 152 REPLACE_UNLINK=0; AC_SUBST([REPLACE_UNLINK])
148 REPLACE_UNLINKAT=0; AC_SUBST([REPLACE_UNLINKAT]) 153 REPLACE_UNLINKAT=0; AC_SUBST([REPLACE_UNLINKAT])
149 REPLACE_USLEEP=0; AC_SUBST([REPLACE_USLEEP]) 154 REPLACE_USLEEP=0; AC_SUBST([REPLACE_USLEEP])
diff --git a/gl/m4/vasnprintf.m4 b/gl/m4/vasnprintf.m4
index 50a20cc..ebe3c52 100644
--- a/gl/m4/vasnprintf.m4
+++ b/gl/m4/vasnprintf.m4
@@ -1,4 +1,4 @@
1# vasnprintf.m4 serial 29 1# vasnprintf.m4 serial 31
2dnl Copyright (C) 2002-2004, 2006-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2004, 2006-2010 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
@@ -54,6 +54,7 @@ AC_DEFUN([gl_PREREQ_PRINTF_PARSE],
54# Prerequisites of lib/vasnprintf.c. 54# Prerequisites of lib/vasnprintf.c.
55AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF], 55AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF],
56[ 56[
57 AC_REQUIRE([AC_C_INLINE])
57 AC_REQUIRE([AC_FUNC_ALLOCA]) 58 AC_REQUIRE([AC_FUNC_ALLOCA])
58 AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) 59 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
59 AC_REQUIRE([gt_TYPE_WCHAR_T]) 60 AC_REQUIRE([gt_TYPE_WCHAR_T])
@@ -62,6 +63,17 @@ AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF],
62 dnl Use the _snprintf function only if it is declared (because on NetBSD it 63 dnl Use the _snprintf function only if it is declared (because on NetBSD it
63 dnl is defined as a weak alias of snprintf; we prefer to use the latter). 64 dnl is defined as a weak alias of snprintf; we prefer to use the latter).
64 AC_CHECK_DECLS([_snprintf], , , [#include <stdio.h>]) 65 AC_CHECK_DECLS([_snprintf], , , [#include <stdio.h>])
66 dnl We can avoid a lot of code by assuming that snprintf's return value
67 dnl conforms to ISO C99. So check that.
68 AC_REQUIRE([gl_SNPRINTF_RETVAL_C99])
69 case "$gl_cv_func_snprintf_retval_c99" in
70 *yes)
71 AC_DEFINE([HAVE_SNPRINTF_RETVAL_C99], [1],
72 [Define if the return value of the snprintf function is the number of
73 of bytes (excluding the terminating NUL) that would have been produced
74 if the buffer had been large enough.])
75 ;;
76 esac
65]) 77])
66 78
67# Extra prerequisites of lib/vasnprintf.c for supporting 'long double' 79# Extra prerequisites of lib/vasnprintf.c for supporting 'long double'
diff --git a/gl/m4/visibility.m4 b/gl/m4/visibility.m4
index 6d3f9c9..077c476 100644
--- a/gl/m4/visibility.m4
+++ b/gl/m4/visibility.m4
@@ -1,4 +1,4 @@
1# visibility.m4 serial 2 (gettext-0.18) 1# visibility.m4 serial 3 (gettext-0.18)
2dnl Copyright (C) 2005, 2008-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2005, 2008-2010 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
@@ -26,15 +26,37 @@ AC_DEFUN([gl_VISIBILITY],
26 CFLAG_VISIBILITY= 26 CFLAG_VISIBILITY=
27 HAVE_VISIBILITY=0 27 HAVE_VISIBILITY=0
28 if test -n "$GCC"; then 28 if test -n "$GCC"; then
29 dnl First, check whether -Werror can be added to the command line, or
30 dnl whether it leads to an error because of some other option that the
31 dnl user has put into $CC $CFLAGS $CPPFLAGS.
32 AC_MSG_CHECKING([whether the -Werror option is usable])
33 AC_CACHE_VAL([gl_cv_cc_vis_werror], [
34 gl_save_CFLAGS="$CFLAGS"
35 CFLAGS="$CFLAGS -Werror"
36 AC_TRY_COMPILE([], [],
37 [gl_cv_cc_vis_werror=yes],
38 [gl_cv_cc_vis_werror=no])
39 CFLAGS="$gl_save_CFLAGS"])
40 AC_MSG_RESULT([$gl_cv_cc_vis_werror])
41 dnl Now check whether visibility declarations are supported.
29 AC_MSG_CHECKING([for simple visibility declarations]) 42 AC_MSG_CHECKING([for simple visibility declarations])
30 AC_CACHE_VAL([gl_cv_cc_visibility], [ 43 AC_CACHE_VAL([gl_cv_cc_visibility], [
31 gl_save_CFLAGS="$CFLAGS" 44 gl_save_CFLAGS="$CFLAGS"
32 CFLAGS="$CFLAGS -fvisibility=hidden" 45 CFLAGS="$CFLAGS -fvisibility=hidden"
46 dnl We use the option -Werror and a function dummyfunc, because on some
47 dnl platforms (Cygwin 1.7) the use of -fvisibility triggers a warning
48 dnl "visibility attribute not supported in this configuration; ignored"
49 dnl at the first function definition in every compilation unit, and we
50 dnl don't want to use the option in this case.
51 if test $gl_cv_cc_vis_werror = yes; then
52 CFLAGS="$CFLAGS -Werror"
53 fi
33 AC_TRY_COMPILE( 54 AC_TRY_COMPILE(
34 [extern __attribute__((__visibility__("hidden"))) int hiddenvar; 55 [extern __attribute__((__visibility__("hidden"))) int hiddenvar;
35 extern __attribute__((__visibility__("default"))) int exportedvar; 56 extern __attribute__((__visibility__("default"))) int exportedvar;
36 extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void); 57 extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void);
37 extern __attribute__((__visibility__("default"))) int exportedfunc (void);], 58 extern __attribute__((__visibility__("default"))) int exportedfunc (void);
59 void dummyfunc (void) {}],
38 [], 60 [],
39 [gl_cv_cc_visibility=yes], 61 [gl_cv_cc_visibility=yes],
40 [gl_cv_cc_visibility=no]) 62 [gl_cv_cc_visibility=no])
diff --git a/gl/netdb.in.h b/gl/netdb.in.h
index 73db46a..f800cac 100644
--- a/gl/netdb.in.h
+++ b/gl/netdb.in.h
@@ -41,6 +41,8 @@
41 41
42/* The definition of _GL_ARG_NONNULL is copied here. */ 42/* The definition of _GL_ARG_NONNULL is copied here. */
43 43
44/* The definition of _GL_WARN_ON_USE is copied here. */
45
44/* Declarations for a platform that lacks <netdb.h>, or where it is 46/* Declarations for a platform that lacks <netdb.h>, or where it is
45 incomplete. */ 47 incomplete. */
46 48
@@ -186,7 +188,33 @@ extern int getnameinfo (const struct sockaddr *restrict sa, socklen_t salen,
186# define NI_NUMERICSERV 2 188# define NI_NUMERICSERV 2
187# endif 189# endif
188 190
189#endif /* @GNULIB_GETADDRINFO@ */ 191#elif defined GNULIB_POSIXCHECK
192
193# undef getaddrinfo
194# if HAVE_RAW_DECL_GETADDRINFO
195_GL_WARN_ON_USE (getaddrinfo, "getaddrinfo is unportable - "
196 "use gnulib module getaddrinfo for portability");
197# endif
198
199# undef freeaddrinfo
200# if HAVE_RAW_DECL_FREEADDRINFO
201_GL_WARN_ON_USE (freeaddrinfo, "freeaddrinfo is unportable - "
202 "use gnulib module getaddrinfo for portability");
203# endif
204
205# undef gai_strerror
206# if HAVE_RAW_DECL_GAI_STRERROR
207_GL_WARN_ON_USE (gai_strerror, "gai_strerror is unportable - "
208 "use gnulib module getaddrinfo for portability");
209# endif
210
211# undef getnameinfo
212# if HAVE_RAW_DECL_GETNAMEINFO
213_GL_WARN_ON_USE (getnameinfo, "getnameinfo is unportable - "
214 "use gnulib module getaddrinfo for portability");
215# endif
216
217#endif
190 218
191#endif /* _GL_NETDB_H */ 219#endif /* _GL_NETDB_H */
192#endif /* _GL_NETDB_H */ 220#endif /* _GL_NETDB_H */
diff --git a/gl/regex_internal.c b/gl/regex_internal.c
index 17eafaa..98b8d5d 100644
--- a/gl/regex_internal.c
+++ b/gl/regex_internal.c
@@ -733,15 +733,17 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
733 mbstate_t cur_state; 733 mbstate_t cur_state;
734 wchar_t wc2; 734 wchar_t wc2;
735 Idx mlen = raw + pstr->len - p; 735 Idx mlen = raw + pstr->len - p;
736 unsigned char buf[6];
737 size_t mbclen; 736 size_t mbclen;
738 737
738#if 0 /* dead code: buf is set but never used */
739 unsigned char buf[6];
739 if (BE (pstr->trans != NULL, 0)) 740 if (BE (pstr->trans != NULL, 0))
740 { 741 {
741 int i = mlen < 6 ? mlen : 6; 742 int i = mlen < 6 ? mlen : 6;
742 while (--i >= 0) 743 while (--i >= 0)
743 buf[i] = pstr->trans[p[i]]; 744 buf[i] = pstr->trans[p[i]];
744 } 745 }
746#endif
745 /* XXX Don't use mbrtowc, we know which conversion 747 /* XXX Don't use mbrtowc, we know which conversion
746 to use (UTF-8 -> UCS4). */ 748 to use (UTF-8 -> UCS4). */
747 memset (&cur_state, 0, sizeof (cur_state)); 749 memset (&cur_state, 0, sizeof (cur_state));
diff --git a/gl/regex_internal.h b/gl/regex_internal.h
index 2cb8c4d..5aa5aa2 100644
--- a/gl/regex_internal.h
+++ b/gl/regex_internal.h
@@ -467,6 +467,8 @@ static unsigned int re_string_context_at (const re_string_t *input, Idx idx,
467# else 467# else
468/* alloca is implemented with malloc, so just use malloc. */ 468/* alloca is implemented with malloc, so just use malloc. */
469# define __libc_use_alloca(n) 0 469# define __libc_use_alloca(n) 0
470# undef alloca
471# define alloca(n) malloc (n)
470# endif 472# endif
471#endif 473#endif
472 474
diff --git a/gl/stdbool.in.h b/gl/stdbool.in.h
index e2312ec..574c281 100644
--- a/gl/stdbool.in.h
+++ b/gl/stdbool.in.h
@@ -50,6 +50,9 @@
50 with this substitute. With this substitute, only the values 0 and 1 50 with this substitute. With this substitute, only the values 0 and 1
51 give the expected result when converted to _Bool' or 'bool'. 51 give the expected result when converted to _Bool' or 'bool'.
52 52
53 - C99 allows the use of (_Bool)0.0 in constant expressions, but
54 this substitute cannot always provide this property.
55
53 Also, it is suggested that programs use 'bool' rather than '_Bool'; 56 Also, it is suggested that programs use 'bool' rather than '_Bool';
54 this isn't required, but 'bool' is more common. */ 57 this isn't required, but 'bool' is more common. */
55 58
diff --git a/gl/stdio-write.c b/gl/stdio-write.c
index f7da9e4..a6a0eb1 100644
--- a/gl/stdio-write.c
+++ b/gl/stdio-write.c
@@ -63,7 +63,6 @@
63 } 63 }
64 64
65# if !REPLACE_PRINTF_POSIX /* avoid collision with printf.c */ 65# if !REPLACE_PRINTF_POSIX /* avoid collision with printf.c */
66# if !DEPENDS_ON_LIBINTL /* avoid collision with intl/printf.c */
67int 66int
68printf (const char *format, ...) 67printf (const char *format, ...)
69{ 68{
@@ -76,7 +75,6 @@ printf (const char *format, ...)
76 75
77 return retval; 76 return retval;
78} 77}
79# endif
80# endif 78# endif
81 79
82# if !REPLACE_FPRINTF_POSIX /* avoid collision with fprintf.c */ 80# if !REPLACE_FPRINTF_POSIX /* avoid collision with fprintf.c */
diff --git a/gl/stdio.in.h b/gl/stdio.in.h
index dcb8ee5..80b9dbf 100644
--- a/gl/stdio.in.h
+++ b/gl/stdio.in.h
@@ -63,6 +63,10 @@
63 63
64/* The definition of _GL_WARN_ON_USE is copied here. */ 64/* The definition of _GL_WARN_ON_USE is copied here. */
65 65
66/* Macros for stringification. */
67#define _GL_STDIO_STRINGIZE(token) #token
68#define _GL_STDIO_MACROEXPAND_AND_STRINGIZE(token) _GL_STDIO_STRINGIZE(token)
69
66 70
67#if @GNULIB_DPRINTF@ 71#if @GNULIB_DPRINTF@
68# if @REPLACE_DPRINTF@ 72# if @REPLACE_DPRINTF@
@@ -640,16 +644,26 @@ _GL_WARN_ON_USE (popen, "popen is buggy on some platforms - "
640#if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@ 644#if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@
641# if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \ 645# if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \
642 || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@) 646 || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@)
643# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 647# if defined __GNUC__
648# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
644/* Don't break __attribute__((format(printf,M,N))). */ 649/* Don't break __attribute__((format(printf,M,N))). */
645# define printf __printf__ 650# define printf __printf__
646# endif 651# endif
647# define GNULIB_overrides_printf 1
648_GL_FUNCDECL_RPL_1 (__printf__, int, 652_GL_FUNCDECL_RPL_1 (__printf__, int,
649 (const char *format, ...) 653 (const char *format, ...)
654 __asm__ (@ASM_SYMBOL_PREFIX@
655 _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf))
650 __attribute__ ((__format__ (__printf__, 1, 2))) 656 __attribute__ ((__format__ (__printf__, 1, 2)))
651 _GL_ARG_NONNULL ((1))); 657 _GL_ARG_NONNULL ((1)));
652_GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...)); 658_GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...));
659# else
660_GL_FUNCDECL_RPL (printf, int,
661 (const char *format, ...)
662 __attribute__ ((__format__ (__printf__, 1, 2)))
663 _GL_ARG_NONNULL ((1)));
664_GL_CXXALIAS_RPL (printf, int, (const char *format, ...));
665# endif
666# define GNULIB_overrides_printf 1
653# else 667# else
654_GL_CXXALIAS_SYS (printf, int, (const char *format, ...)); 668_GL_CXXALIAS_SYS (printf, int, (const char *format, ...));
655# endif 669# endif
diff --git a/gl/strerror.c b/gl/strerror.c
index b0df778..46153ab 100644
--- a/gl/strerror.c
+++ b/gl/strerror.c
@@ -32,6 +32,9 @@
32 32
33# include "intprops.h" 33# include "intprops.h"
34 34
35/* Use the system functions, not the gnulib overrides in this file. */
36# undef sprintf
37
35# undef strerror 38# undef strerror
36# if ! HAVE_DECL_STRERROR 39# if ! HAVE_DECL_STRERROR
37# define strerror(n) NULL 40# define strerror(n) NULL
diff --git a/gl/string.in.h b/gl/string.in.h
index eb8d758..13c0f09 100644
--- a/gl/string.in.h
+++ b/gl/string.in.h
@@ -372,12 +372,23 @@ _GL_WARN_ON_USE (strndup, "strndup is unportable - "
372 MAXLEN bytes. If no '\0' terminator is found in that many bytes, 372 MAXLEN bytes. If no '\0' terminator is found in that many bytes,
373 return MAXLEN. */ 373 return MAXLEN. */
374#if @GNULIB_STRNLEN@ 374#if @GNULIB_STRNLEN@
375# if ! @HAVE_DECL_STRNLEN@ 375# if @REPLACE_STRNLEN@
376# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
377# undef strnlen
378# define strnlen rpl_strnlen
379# endif
380_GL_FUNCDECL_RPL (strnlen, size_t, (char const *__string, size_t __maxlen)
381 __attribute__ ((__pure__))
382 _GL_ARG_NONNULL ((1)));
383_GL_CXXALIAS_RPL (strnlen, size_t, (char const *__string, size_t __maxlen));
384# else
385# if ! @HAVE_DECL_STRNLEN@
376_GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen) 386_GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)
377 __attribute__ ((__pure__)) 387 __attribute__ ((__pure__))
378 _GL_ARG_NONNULL ((1))); 388 _GL_ARG_NONNULL ((1)));
379# endif 389# endif
380_GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)); 390_GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen));
391# endif
381_GL_CXXALIASWARN (strnlen); 392_GL_CXXALIASWARN (strnlen);
382#elif defined GNULIB_POSIXCHECK 393#elif defined GNULIB_POSIXCHECK
383# undef strnlen 394# undef strnlen
diff --git a/gl/sys_stat.in.h b/gl/sys_stat.in.h
index a64bf02..dc7ef51 100644
--- a/gl/sys_stat.in.h
+++ b/gl/sys_stat.in.h
@@ -56,7 +56,8 @@
56/* Before doing "#define mkdir rpl_mkdir" below, we need to include all 56/* Before doing "#define mkdir rpl_mkdir" below, we need to include all
57 headers that may declare mkdir(). */ 57 headers that may declare mkdir(). */
58#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 58#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
59# include <io.h> 59# include <io.h> /* mingw32, mingw64 */
60# include <direct.h> /* mingw64 */
60#endif 61#endif
61 62
62#ifndef S_IFMT 63#ifndef S_IFMT
@@ -455,7 +456,8 @@ _GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
455#else 456#else
456/* mingw's _mkdir() function has 1 argument, but we pass 2 arguments. 457/* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
457 Additionally, it declares _mkdir (and depending on compile flags, an 458 Additionally, it declares _mkdir (and depending on compile flags, an
458 alias mkdir), only in the nonstandard <io.h>, which is included above. */ 459 alias mkdir), only in the nonstandard includes <direct.h> and <io.h>,
460 which are included above. */
459# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 461# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
460 462
461static inline int 463static inline int
diff --git a/gl/time.in.h b/gl/time.in.h
index 8e364fe..6fb4fd7 100644
--- a/gl/time.in.h
+++ b/gl/time.in.h
@@ -48,10 +48,20 @@
48 48
49/* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3). 49/* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3).
50 Or they define it with the wrong member names or define it in <sys/time.h> 50 Or they define it with the wrong member names or define it in <sys/time.h>
51 (e.g., FreeBSD circa 1997). */ 51 (e.g., FreeBSD circa 1997). Stock Mingw does not define it, but the
52 pthreads-win32 library defines it in <pthread.h>. */
52# if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@ 53# if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@
53# if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@ 54# if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
54# include <sys/time.h> 55# include <sys/time.h>
56# elif @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
57# include <pthread.h>
58/* The pthreads-win32 <pthread.h> also defines a couple of broken macros. */
59# undef asctime_r
60# undef ctime_r
61# undef gmtime_r
62# undef localtime_r
63# undef rand_r
64# undef strtok_r
55# else 65# else
56 66
57# ifdef __cplusplus 67# ifdef __cplusplus
diff --git a/gl/unistd.in.h b/gl/unistd.in.h
index 45fc5dc..7914f22 100644
--- a/gl/unistd.in.h
+++ b/gl/unistd.in.h
@@ -86,7 +86,7 @@
86#endif 86#endif
87 87
88#if (@GNULIB_WRITE@ || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \ 88#if (@GNULIB_WRITE@ || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
89 || @GNULIB_PREAD@ || defined GNULIB_POSIXCHECK) 89 || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK)
90/* Get ssize_t. */ 90/* Get ssize_t. */
91# include <sys/types.h> 91# include <sys/types.h>
92#endif 92#endif
@@ -1016,6 +1016,40 @@ _GL_WARN_ON_USE (pread, "pread is unportable - "
1016#endif 1016#endif
1017 1017
1018 1018
1019#if @GNULIB_PWRITE@
1020/* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1021 Return the number of bytes written if successful, otherwise
1022 set errno and return -1. 0 indicates nothing written. See the
1023 POSIX:2001 specification
1024 <http://www.opengroup.org/susv3xsh/pwrite.html>. */
1025# if @REPLACE_PWRITE@
1026# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1027# define pwrite rpl_pwrite
1028# endif
1029_GL_FUNCDECL_RPL (pwrite, ssize_t,
1030 (int fd, const void *buf, size_t bufsize, off_t offset)
1031 _GL_ARG_NONNULL ((2)));
1032_GL_CXXALIAS_RPL (pwrite, ssize_t,
1033 (int fd, const void *buf, size_t bufsize, off_t offset));
1034# else
1035# if !@HAVE_PWRITE@
1036_GL_FUNCDECL_SYS (pwrite, ssize_t,
1037 (int fd, const void *buf, size_t bufsize, off_t offset)
1038 _GL_ARG_NONNULL ((2)));
1039# endif
1040_GL_CXXALIAS_SYS (pwrite, ssize_t,
1041 (int fd, const void *buf, size_t bufsize, off_t offset));
1042# endif
1043_GL_CXXALIASWARN (pwrite);
1044#elif defined GNULIB_POSIXCHECK
1045# undef pwrite
1046# if HAVE_RAW_DECL_PWRITE
1047_GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
1048 "use gnulib module pwrite for portability");
1049# endif
1050#endif
1051
1052
1019#if @GNULIB_READLINK@ 1053#if @GNULIB_READLINK@
1020/* Read the contents of the symbolic link FILE and place the first BUFSIZE 1054/* Read the contents of the symbolic link FILE and place the first BUFSIZE
1021 bytes of it into BUF. Return the number of bytes placed into BUF if 1055 bytes of it into BUF. Return the number of bytes placed into BUF if
@@ -1164,12 +1198,23 @@ _GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - "
1164#if @GNULIB_TTYNAME_R@ 1198#if @GNULIB_TTYNAME_R@
1165/* Store at most BUFLEN characters of the pathname of the terminal FD is 1199/* Store at most BUFLEN characters of the pathname of the terminal FD is
1166 open on in BUF. Return 0 on success, otherwise an error number. */ 1200 open on in BUF. Return 0 on success, otherwise an error number. */
1167# if !@HAVE_TTYNAME_R@ 1201# if @REPLACE_TTYNAME_R@
1202# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1203# undef ttyname_r
1204# define ttyname_r rpl_ttyname_r
1205# endif
1206_GL_FUNCDECL_RPL (ttyname_r, int,
1207 (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
1208_GL_CXXALIAS_RPL (ttyname_r, int,
1209 (int fd, char *buf, size_t buflen));
1210# else
1211# if !@HAVE_TTYNAME_R@
1168_GL_FUNCDECL_SYS (ttyname_r, int, 1212_GL_FUNCDECL_SYS (ttyname_r, int,
1169 (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2))); 1213 (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
1170# endif 1214# endif
1171_GL_CXXALIAS_SYS (ttyname_r, int, 1215_GL_CXXALIAS_SYS (ttyname_r, int,
1172 (int fd, char *buf, size_t buflen)); 1216 (int fd, char *buf, size_t buflen));
1217# endif
1173_GL_CXXALIASWARN (ttyname_r); 1218_GL_CXXALIASWARN (ttyname_r);
1174#elif defined GNULIB_POSIXCHECK 1219#elif defined GNULIB_POSIXCHECK
1175# undef ttyname_r 1220# undef ttyname_r
@@ -1268,7 +1313,10 @@ _GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count)
1268 _GL_ARG_NONNULL ((2))); 1313 _GL_ARG_NONNULL ((2)));
1269_GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count)); 1314_GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count));
1270# else 1315# else
1271_GL_CXXALIAS_SYS (write, ssize_t, (int fd, const void *buf, size_t count)); 1316/* Need to cast, because on mingw, the third parameter is
1317 unsigned int count
1318 and the return type is 'int'. */
1319_GL_CXXALIAS_SYS_CAST (write, ssize_t, (int fd, const void *buf, size_t count));
1272# endif 1320# endif
1273_GL_CXXALIASWARN (write); 1321_GL_CXXALIASWARN (write);
1274#endif 1322#endif
diff --git a/gl/vasnprintf.c b/gl/vasnprintf.c
index 99d921e..e618901 100644
--- a/gl/vasnprintf.c
+++ b/gl/vasnprintf.c
@@ -148,8 +148,14 @@
148# define USE_SNPRINTF 1 148# define USE_SNPRINTF 1
149# if HAVE_DECL__SNWPRINTF 149# if HAVE_DECL__SNWPRINTF
150 /* On Windows, the function swprintf() has a different signature than 150 /* On Windows, the function swprintf() has a different signature than
151 on Unix; we use the _snwprintf() function instead. */ 151 on Unix; we use the function _snwprintf() or - on mingw - snwprintf()
152# define SNPRINTF _snwprintf 152 instead. The mingw function snwprintf() has fewer bugs than the
153 MSVCRT function _snwprintf(), so prefer that. */
154# if defined __MINGW32__
155# define SNPRINTF snwprintf
156# else
157# define SNPRINTF _snwprintf
158# endif
153# else 159# else
154 /* Unix. */ 160 /* Unix. */
155# define SNPRINTF swprintf 161# define SNPRINTF swprintf
@@ -167,8 +173,15 @@
167# define USE_SNPRINTF 0 173# define USE_SNPRINTF 0
168# endif 174# endif
169# if HAVE_DECL__SNPRINTF 175# if HAVE_DECL__SNPRINTF
170 /* Windows. */ 176 /* Windows. The mingw function snprintf() has fewer bugs than the MSVCRT
171# define SNPRINTF _snprintf 177 function _snprintf(), so prefer that. */
178# if defined __MINGW32__
179# define SNPRINTF snprintf
180 /* Here we need to call the native snprintf, not rpl_snprintf. */
181# undef snprintf
182# else
183# define SNPRINTF _snprintf
184# endif
172# else 185# else
173 /* Unix. */ 186 /* Unix. */
174# define SNPRINTF snprintf 187# define SNPRINTF snprintf
@@ -194,7 +207,7 @@
194#undef remainder 207#undef remainder
195#define remainder rem 208#define remainder rem
196 209
197#if !USE_SNPRINTF && !WIDE_CHAR_VERSION 210#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99) && !WIDE_CHAR_VERSION
198# if (HAVE_STRNLEN && !defined _AIX) 211# if (HAVE_STRNLEN && !defined _AIX)
199# define local_strnlen strnlen 212# define local_strnlen strnlen
200# else 213# else
@@ -210,7 +223,7 @@ local_strnlen (const char *string, size_t maxlen)
210# endif 223# endif
211#endif 224#endif
212 225
213#if (!USE_SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && HAVE_WCHAR_T && (WIDE_CHAR_VERSION || DCHAR_IS_TCHAR) 226#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
214# if HAVE_WCSLEN 227# if HAVE_WCSLEN
215# define local_wcslen wcslen 228# define local_wcslen wcslen
216# else 229# else
@@ -233,7 +246,7 @@ local_wcslen (const wchar_t *s)
233# endif 246# endif
234#endif 247#endif
235 248
236#if !USE_SNPRINTF && HAVE_WCHAR_T && WIDE_CHAR_VERSION 249#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99) && HAVE_WCHAR_T && WIDE_CHAR_VERSION
237# if HAVE_WCSNLEN 250# if HAVE_WCSNLEN
238# define local_wcsnlen wcsnlen 251# define local_wcsnlen wcsnlen
239# else 252# else
@@ -1474,6 +1487,258 @@ is_borderline (const char *digits, size_t precision)
1474 1487
1475#endif 1488#endif
1476 1489
1490#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99
1491
1492/* Use a different function name, to make it possible that the 'wchar_t'
1493 parametrization and the 'char' parametrization get compiled in the same
1494 translation unit. */
1495# if WIDE_CHAR_VERSION
1496# define MAX_ROOM_NEEDED wmax_room_needed
1497# else
1498# define MAX_ROOM_NEEDED max_room_needed
1499# endif
1500
1501/* Returns the number of TCHAR_T units needed as temporary space for the result
1502 of sprintf or SNPRINTF of a single conversion directive. */
1503static inline size_t
1504MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion,
1505 arg_type type, int flags, size_t width, int has_precision,
1506 size_t precision, int pad_ourselves)
1507{
1508 size_t tmp_length;
1509
1510 switch (conversion)
1511 {
1512 case 'd': case 'i': case 'u':
1513# if HAVE_LONG_LONG_INT
1514 if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
1515 tmp_length =
1516 (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
1517 * 0.30103 /* binary -> decimal */
1518 )
1519 + 1; /* turn floor into ceil */
1520 else
1521# endif
1522 if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
1523 tmp_length =
1524 (unsigned int) (sizeof (unsigned long) * CHAR_BIT
1525 * 0.30103 /* binary -> decimal */
1526 )
1527 + 1; /* turn floor into ceil */
1528 else
1529 tmp_length =
1530 (unsigned int) (sizeof (unsigned int) * CHAR_BIT
1531 * 0.30103 /* binary -> decimal */
1532 )
1533 + 1; /* turn floor into ceil */
1534 if (tmp_length < precision)
1535 tmp_length = precision;
1536 /* Multiply by 2, as an estimate for FLAG_GROUP. */
1537 tmp_length = xsum (tmp_length, tmp_length);
1538 /* Add 1, to account for a leading sign. */
1539 tmp_length = xsum (tmp_length, 1);
1540 break;
1541
1542 case 'o':
1543# if HAVE_LONG_LONG_INT
1544 if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
1545 tmp_length =
1546 (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
1547 * 0.333334 /* binary -> octal */
1548 )
1549 + 1; /* turn floor into ceil */
1550 else
1551# endif
1552 if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
1553 tmp_length =
1554 (unsigned int) (sizeof (unsigned long) * CHAR_BIT
1555 * 0.333334 /* binary -> octal */
1556 )
1557 + 1; /* turn floor into ceil */
1558 else
1559 tmp_length =
1560 (unsigned int) (sizeof (unsigned int) * CHAR_BIT
1561 * 0.333334 /* binary -> octal */
1562 )
1563 + 1; /* turn floor into ceil */
1564 if (tmp_length < precision)
1565 tmp_length = precision;
1566 /* Add 1, to account for a leading sign. */
1567 tmp_length = xsum (tmp_length, 1);
1568 break;
1569
1570 case 'x': case 'X':
1571# if HAVE_LONG_LONG_INT
1572 if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
1573 tmp_length =
1574 (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
1575 * 0.25 /* binary -> hexadecimal */
1576 )
1577 + 1; /* turn floor into ceil */
1578 else
1579# endif
1580 if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
1581 tmp_length =
1582 (unsigned int) (sizeof (unsigned long) * CHAR_BIT
1583 * 0.25 /* binary -> hexadecimal */
1584 )
1585 + 1; /* turn floor into ceil */
1586 else
1587 tmp_length =
1588 (unsigned int) (sizeof (unsigned int) * CHAR_BIT
1589 * 0.25 /* binary -> hexadecimal */
1590 )
1591 + 1; /* turn floor into ceil */
1592 if (tmp_length < precision)
1593 tmp_length = precision;
1594 /* Add 2, to account for a leading sign or alternate form. */
1595 tmp_length = xsum (tmp_length, 2);
1596 break;
1597
1598 case 'f': case 'F':
1599 if (type == TYPE_LONGDOUBLE)
1600 tmp_length =
1601 (unsigned int) (LDBL_MAX_EXP
1602 * 0.30103 /* binary -> decimal */
1603 * 2 /* estimate for FLAG_GROUP */
1604 )
1605 + 1 /* turn floor into ceil */
1606 + 10; /* sign, decimal point etc. */
1607 else
1608 tmp_length =
1609 (unsigned int) (DBL_MAX_EXP
1610 * 0.30103 /* binary -> decimal */
1611 * 2 /* estimate for FLAG_GROUP */
1612 )
1613 + 1 /* turn floor into ceil */
1614 + 10; /* sign, decimal point etc. */
1615 tmp_length = xsum (tmp_length, precision);
1616 break;
1617
1618 case 'e': case 'E': case 'g': case 'G':
1619 tmp_length =
1620 12; /* sign, decimal point, exponent etc. */
1621 tmp_length = xsum (tmp_length, precision);
1622 break;
1623
1624 case 'a': case 'A':
1625 if (type == TYPE_LONGDOUBLE)
1626 tmp_length =
1627 (unsigned int) (LDBL_DIG
1628 * 0.831 /* decimal -> hexadecimal */
1629 )
1630 + 1; /* turn floor into ceil */
1631 else
1632 tmp_length =
1633 (unsigned int) (DBL_DIG
1634 * 0.831 /* decimal -> hexadecimal */
1635 )
1636 + 1; /* turn floor into ceil */
1637 if (tmp_length < precision)
1638 tmp_length = precision;
1639 /* Account for sign, decimal point etc. */
1640 tmp_length = xsum (tmp_length, 12);
1641 break;
1642
1643 case 'c':
1644# if HAVE_WINT_T && !WIDE_CHAR_VERSION
1645 if (type == TYPE_WIDE_CHAR)
1646 tmp_length = MB_CUR_MAX;
1647 else
1648# endif
1649 tmp_length = 1;
1650 break;
1651
1652 case 's':
1653# if HAVE_WCHAR_T
1654 if (type == TYPE_WIDE_STRING)
1655 {
1656# if WIDE_CHAR_VERSION
1657 /* ISO C says about %ls in fwprintf:
1658 "If the precision is not specified or is greater than the size
1659 of the array, the array shall contain a null wide character."
1660 So if there is a precision, we must not use wcslen. */
1661 const wchar_t *arg = ap->arg[arg_index].a.a_wide_string;
1662
1663 if (has_precision)
1664 tmp_length = local_wcsnlen (arg, precision);
1665 else
1666 tmp_length = local_wcslen (arg);
1667# else
1668 /* ISO C says about %ls in fprintf:
1669 "If a precision is specified, no more than that many bytes are
1670 written (including shift sequences, if any), and the array
1671 shall contain a null wide character if, to equal the multibyte
1672 character sequence length given by the precision, the function
1673 would need to access a wide character one past the end of the
1674 array."
1675 So if there is a precision, we must not use wcslen. */
1676 /* This case has already been handled separately in VASNPRINTF. */
1677 abort ();
1678# endif
1679 }
1680 else
1681# endif
1682 {
1683# if WIDE_CHAR_VERSION
1684 /* ISO C says about %s in fwprintf:
1685 "If the precision is not specified or is greater than the size
1686 of the converted array, the converted array shall contain a
1687 null wide character."
1688 So if there is a precision, we must not use strlen. */
1689 /* This case has already been handled separately in VASNPRINTF. */
1690 abort ();
1691# else
1692 /* ISO C says about %s in fprintf:
1693 "If the precision is not specified or greater than the size of
1694 the array, the array shall contain a null character."
1695 So if there is a precision, we must not use strlen. */
1696 const char *arg = ap->arg[arg_index].a.a_string;
1697
1698 if (has_precision)
1699 tmp_length = local_strnlen (arg, precision);
1700 else
1701 tmp_length = strlen (arg);
1702# endif
1703 }
1704 break;
1705
1706 case 'p':
1707 tmp_length =
1708 (unsigned int) (sizeof (void *) * CHAR_BIT
1709 * 0.25 /* binary -> hexadecimal */
1710 )
1711 + 1 /* turn floor into ceil */
1712 + 2; /* account for leading 0x */
1713 break;
1714
1715 default:
1716 abort ();
1717 }
1718
1719 if (!pad_ourselves)
1720 {
1721# if ENABLE_UNISTDIO
1722 /* Padding considers the number of characters, therefore the number of
1723 elements after padding may be
1724 > max (tmp_length, width)
1725 but is certainly
1726 <= tmp_length + width. */
1727 tmp_length = xsum (tmp_length, width);
1728# else
1729 /* Padding considers the number of elements, says POSIX. */
1730 if (tmp_length < width)
1731 tmp_length = width;
1732# endif
1733 }
1734
1735 tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */
1736
1737 return tmp_length;
1738}
1739
1740#endif
1741
1477DCHAR_T * 1742DCHAR_T *
1478VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, 1743VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
1479 const FCHAR_T *format, va_list args) 1744 const FCHAR_T *format, va_list args)
@@ -2103,7 +2368,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2103 } 2368 }
2104 } 2369 }
2105#endif 2370#endif
2106#if (!USE_SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && HAVE_WCHAR_T 2371#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && HAVE_WCHAR_T
2107 else if (dp->conversion == 's' 2372 else if (dp->conversion == 's'
2108# if WIDE_CHAR_VERSION 2373# if WIDE_CHAR_VERSION
2109 && a.arg[dp->arg_index].type != TYPE_WIDE_STRING 2374 && a.arg[dp->arg_index].type != TYPE_WIDE_STRING
@@ -2592,8 +2857,16 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2592 count = wctomb (cbuf, *arg); 2857 count = wctomb (cbuf, *arg);
2593# endif 2858# endif
2594 if (count <= 0) 2859 if (count <= 0)
2595 /* Inconsistency. */ 2860 {
2596 abort (); 2861 /* Cannot convert. */
2862 if (!(result == resultbuf || result == NULL))
2863 free (result);
2864 if (buf_malloced != NULL)
2865 free (buf_malloced);
2866 CLEANUP ();
2867 errno = EILSEQ;
2868 return NULL;
2869 }
2597 ENSURE_ALLOCATION (xsum (length, count)); 2870 ENSURE_ALLOCATION (xsum (length, count));
2598 memcpy (result + length, cbuf, count); 2871 memcpy (result + length, cbuf, count);
2599 length += count; 2872 length += count;
@@ -2616,8 +2889,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2616 length += n; 2889 length += n;
2617 } 2890 }
2618 } 2891 }
2619 }
2620# endif 2892# endif
2893 }
2621#endif 2894#endif
2622#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL 2895#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL
2623 else if ((dp->conversion == 'a' || dp->conversion == 'A') 2896 else if ((dp->conversion == 'a' || dp->conversion == 'A')
@@ -4301,11 +4574,11 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4301 { 4574 {
4302 arg_type type = a.arg[dp->arg_index].type; 4575 arg_type type = a.arg[dp->arg_index].type;
4303 int flags = dp->flags; 4576 int flags = dp->flags;
4304#if !USE_SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION 4577#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
4305 int has_width; 4578 int has_width;
4306 size_t width; 4579 size_t width;
4307#endif 4580#endif
4308#if !USE_SNPRINTF || NEED_PRINTF_UNBOUNDED_PRECISION 4581#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || NEED_PRINTF_UNBOUNDED_PRECISION
4309 int has_precision; 4582 int has_precision;
4310 size_t precision; 4583 size_t precision;
4311#endif 4584#endif
@@ -4330,7 +4603,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4330 TCHAR_T *tmp; 4603 TCHAR_T *tmp;
4331#endif 4604#endif
4332 4605
4333#if !USE_SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION 4606#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
4334 has_width = 0; 4607 has_width = 0;
4335 width = 0; 4608 width = 0;
4336 if (dp->width_start != dp->width_end) 4609 if (dp->width_start != dp->width_end)
@@ -4364,7 +4637,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4364 } 4637 }
4365#endif 4638#endif
4366 4639
4367#if !USE_SNPRINTF || NEED_PRINTF_UNBOUNDED_PRECISION 4640#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || NEED_PRINTF_UNBOUNDED_PRECISION
4368 has_precision = 0; 4641 has_precision = 0;
4369 precision = 6; 4642 precision = 6;
4370 if (dp->precision_start != dp->precision_end) 4643 if (dp->precision_start != dp->precision_end)
@@ -4437,246 +4710,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4437#if !USE_SNPRINTF 4710#if !USE_SNPRINTF
4438 /* Allocate a temporary buffer of sufficient size for calling 4711 /* Allocate a temporary buffer of sufficient size for calling
4439 sprintf. */ 4712 sprintf. */
4440 { 4713 tmp_length =
4441 switch (dp->conversion) 4714 MAX_ROOM_NEEDED (&a, dp->arg_index, dp->conversion, type,
4442 { 4715 flags, width, has_precision, precision,
4443 4716 pad_ourselves);
4444 case 'd': case 'i': case 'u':
4445# if HAVE_LONG_LONG_INT
4446 if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
4447 tmp_length =
4448 (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
4449 * 0.30103 /* binary -> decimal */
4450 )
4451 + 1; /* turn floor into ceil */
4452 else
4453# endif
4454 if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
4455 tmp_length =
4456 (unsigned int) (sizeof (unsigned long) * CHAR_BIT
4457 * 0.30103 /* binary -> decimal */
4458 )
4459 + 1; /* turn floor into ceil */
4460 else
4461 tmp_length =
4462 (unsigned int) (sizeof (unsigned int) * CHAR_BIT
4463 * 0.30103 /* binary -> decimal */
4464 )
4465 + 1; /* turn floor into ceil */
4466 if (tmp_length < precision)
4467 tmp_length = precision;
4468 /* Multiply by 2, as an estimate for FLAG_GROUP. */
4469 tmp_length = xsum (tmp_length, tmp_length);
4470 /* Add 1, to account for a leading sign. */
4471 tmp_length = xsum (tmp_length, 1);
4472 break;
4473
4474 case 'o':
4475# if HAVE_LONG_LONG_INT
4476 if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
4477 tmp_length =
4478 (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
4479 * 0.333334 /* binary -> octal */
4480 )
4481 + 1; /* turn floor into ceil */
4482 else
4483# endif
4484 if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
4485 tmp_length =
4486 (unsigned int) (sizeof (unsigned long) * CHAR_BIT
4487 * 0.333334 /* binary -> octal */
4488 )
4489 + 1; /* turn floor into ceil */
4490 else
4491 tmp_length =
4492 (unsigned int) (sizeof (unsigned int) * CHAR_BIT
4493 * 0.333334 /* binary -> octal */
4494 )
4495 + 1; /* turn floor into ceil */
4496 if (tmp_length < precision)
4497 tmp_length = precision;
4498 /* Add 1, to account for a leading sign. */
4499 tmp_length = xsum (tmp_length, 1);
4500 break;
4501
4502 case 'x': case 'X':
4503# if HAVE_LONG_LONG_INT
4504 if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
4505 tmp_length =
4506 (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
4507 * 0.25 /* binary -> hexadecimal */
4508 )
4509 + 1; /* turn floor into ceil */
4510 else
4511# endif
4512 if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
4513 tmp_length =
4514 (unsigned int) (sizeof (unsigned long) * CHAR_BIT
4515 * 0.25 /* binary -> hexadecimal */
4516 )
4517 + 1; /* turn floor into ceil */
4518 else
4519 tmp_length =
4520 (unsigned int) (sizeof (unsigned int) * CHAR_BIT
4521 * 0.25 /* binary -> hexadecimal */
4522 )
4523 + 1; /* turn floor into ceil */
4524 if (tmp_length < precision)
4525 tmp_length = precision;
4526 /* Add 2, to account for a leading sign or alternate form. */
4527 tmp_length = xsum (tmp_length, 2);
4528 break;
4529
4530 case 'f': case 'F':
4531 if (type == TYPE_LONGDOUBLE)
4532 tmp_length =
4533 (unsigned int) (LDBL_MAX_EXP
4534 * 0.30103 /* binary -> decimal */
4535 * 2 /* estimate for FLAG_GROUP */
4536 )
4537 + 1 /* turn floor into ceil */
4538 + 10; /* sign, decimal point etc. */
4539 else
4540 tmp_length =
4541 (unsigned int) (DBL_MAX_EXP
4542 * 0.30103 /* binary -> decimal */
4543 * 2 /* estimate for FLAG_GROUP */
4544 )
4545 + 1 /* turn floor into ceil */
4546 + 10; /* sign, decimal point etc. */
4547 tmp_length = xsum (tmp_length, precision);
4548 break;
4549
4550 case 'e': case 'E': case 'g': case 'G':
4551 tmp_length =
4552 12; /* sign, decimal point, exponent etc. */
4553 tmp_length = xsum (tmp_length, precision);
4554 break;
4555
4556 case 'a': case 'A':
4557 if (type == TYPE_LONGDOUBLE)
4558 tmp_length =
4559 (unsigned int) (LDBL_DIG
4560 * 0.831 /* decimal -> hexadecimal */
4561 )
4562 + 1; /* turn floor into ceil */
4563 else
4564 tmp_length =
4565 (unsigned int) (DBL_DIG
4566 * 0.831 /* decimal -> hexadecimal */
4567 )
4568 + 1; /* turn floor into ceil */
4569 if (tmp_length < precision)
4570 tmp_length = precision;
4571 /* Account for sign, decimal point etc. */
4572 tmp_length = xsum (tmp_length, 12);
4573 break;
4574
4575 case 'c':
4576# if HAVE_WINT_T && !WIDE_CHAR_VERSION
4577 if (type == TYPE_WIDE_CHAR)
4578 tmp_length = MB_CUR_MAX;
4579 else
4580# endif
4581 tmp_length = 1;
4582 break;
4583
4584 case 's':
4585# if HAVE_WCHAR_T
4586 if (type == TYPE_WIDE_STRING)
4587 {
4588# if WIDE_CHAR_VERSION
4589 /* ISO C says about %ls in fwprintf:
4590 "If the precision is not specified or is greater
4591 than the size of the array, the array shall
4592 contain a null wide character."
4593 So if there is a precision, we must not use
4594 wcslen. */
4595 const wchar_t *arg =
4596 a.arg[dp->arg_index].a.a_wide_string;
4597
4598 if (has_precision)
4599 tmp_length = local_wcsnlen (arg, precision);
4600 else
4601 tmp_length = local_wcslen (arg);
4602# else
4603 /* ISO C says about %ls in fprintf:
4604 "If a precision is specified, no more than that
4605 many bytes are written (including shift
4606 sequences, if any), and the array shall contain
4607 a null wide character if, to equal the
4608 multibyte character sequence length given by
4609 the precision, the function would need to
4610 access a wide character one past the end of the
4611 array."
4612 So if there is a precision, we must not use
4613 wcslen. */
4614 /* This case has already been handled above. */
4615 abort ();
4616# endif
4617 }
4618 else
4619# endif
4620 {
4621# if WIDE_CHAR_VERSION
4622 /* ISO C says about %s in fwprintf:
4623 "If the precision is not specified or is greater
4624 than the size of the converted array, the
4625 converted array shall contain a null wide
4626 character."
4627 So if there is a precision, we must not use
4628 strlen. */
4629 /* This case has already been handled above. */
4630 abort ();
4631# else
4632 /* ISO C says about %s in fprintf:
4633 "If the precision is not specified or greater
4634 than the size of the array, the array shall
4635 contain a null character."
4636 So if there is a precision, we must not use
4637 strlen. */
4638 const char *arg = a.arg[dp->arg_index].a.a_string;
4639
4640 if (has_precision)
4641 tmp_length = local_strnlen (arg, precision);
4642 else
4643 tmp_length = strlen (arg);
4644# endif
4645 }
4646 break;
4647
4648 case 'p':
4649 tmp_length =
4650 (unsigned int) (sizeof (void *) * CHAR_BIT
4651 * 0.25 /* binary -> hexadecimal */
4652 )
4653 + 1 /* turn floor into ceil */
4654 + 2; /* account for leading 0x */
4655 break;
4656
4657 default:
4658 abort ();
4659 }
4660
4661 if (!pad_ourselves)
4662 {
4663# if ENABLE_UNISTDIO
4664 /* Padding considers the number of characters, therefore
4665 the number of elements after padding may be
4666 > max (tmp_length, width)
4667 but is certainly
4668 <= tmp_length + width. */
4669 tmp_length = xsum (tmp_length, width);
4670# else
4671 /* Padding considers the number of elements,
4672 says POSIX. */
4673 if (tmp_length < width)
4674 tmp_length = width;
4675# endif
4676 }
4677
4678 tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */
4679 }
4680 4717
4681 if (tmp_length <= sizeof (tmpbuf) / sizeof (TCHAR_T)) 4718 if (tmp_length <= sizeof (tmpbuf) / sizeof (TCHAR_T))
4682 tmp = tmpbuf; 4719 tmp = tmpbuf;
@@ -4916,6 +4953,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4916 } 4953 }
4917#endif 4954#endif
4918 4955
4956 errno = 0;
4919 switch (type) 4957 switch (type)
4920 { 4958 {
4921 case TYPE_SCHAR: 4959 case TYPE_SCHAR:
@@ -5062,15 +5100,44 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5062 /* Look at the snprintf() return value. */ 5100 /* Look at the snprintf() return value. */
5063 if (retcount < 0) 5101 if (retcount < 0)
5064 { 5102 {
5103# if !HAVE_SNPRINTF_RETVAL_C99
5065 /* HP-UX 10.20 snprintf() is doubly deficient: 5104 /* HP-UX 10.20 snprintf() is doubly deficient:
5066 It doesn't understand the '%n' directive, 5105 It doesn't understand the '%n' directive,
5067 *and* it returns -1 (rather than the length 5106 *and* it returns -1 (rather than the length
5068 that would have been required) when the 5107 that would have been required) when the
5069 buffer is too small. */ 5108 buffer is too small.
5070 size_t bigger_need = 5109 But a failure at this point can also come
5071 xsum (xtimes (allocated, 2), 12); 5110 from other reasons than a too small buffer,
5072 ENSURE_ALLOCATION (bigger_need); 5111 such as an invalid wide string argument to
5073 continue; 5112 the %ls directive, or possibly an invalid
5113 floating-point argument. */
5114 size_t tmp_length =
5115 MAX_ROOM_NEEDED (&a, dp->arg_index,
5116 dp->conversion, type, flags,
5117 width, has_precision,
5118 precision, pad_ourselves);
5119
5120 if (maxlen < tmp_length)
5121 {
5122 /* Make more room. But try to do through
5123 this reallocation only once. */
5124 size_t bigger_need =
5125 xsum (length,
5126 xsum (tmp_length,
5127 TCHARS_PER_DCHAR - 1)
5128 / TCHARS_PER_DCHAR);
5129 /* And always grow proportionally.
5130 (There may be several arguments, each
5131 needing a little more room than the
5132 previous one.) */
5133 size_t bigger_need2 =
5134 xsum (xtimes (allocated, 2), 12);
5135 if (bigger_need < bigger_need2)
5136 bigger_need = bigger_need2;
5137 ENSURE_ALLOCATION (bigger_need);
5138 continue;
5139 }
5140# endif
5074 } 5141 }
5075 else 5142 else
5076 count = retcount; 5143 count = retcount;
@@ -5081,12 +5148,21 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5081 /* Attempt to handle failure. */ 5148 /* Attempt to handle failure. */
5082 if (count < 0) 5149 if (count < 0)
5083 { 5150 {
5151 /* SNPRINTF or sprintf failed. Save and use the errno
5152 that it has set, if any. */
5153 int saved_errno = errno;
5154
5084 if (!(result == resultbuf || result == NULL)) 5155 if (!(result == resultbuf || result == NULL))
5085 free (result); 5156 free (result);
5086 if (buf_malloced != NULL) 5157 if (buf_malloced != NULL)
5087 free (buf_malloced); 5158 free (buf_malloced);
5088 CLEANUP (); 5159 CLEANUP ();
5089 errno = EINVAL; 5160 errno =
5161 (saved_errno != 0
5162 ? saved_errno
5163 : (dp->conversion == 'c' || dp->conversion == 's'
5164 ? EILSEQ
5165 : EINVAL));
5090 return NULL; 5166 return NULL;
5091 } 5167 }
5092 5168
@@ -5422,6 +5498,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5422 length += count; 5498 length += count;
5423 break; 5499 break;
5424 } 5500 }
5501#undef pad_ourselves
5502#undef prec_ourselves
5425 } 5503 }
5426 } 5504 }
5427 } 5505 }
@@ -5473,6 +5551,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5473 } 5551 }
5474} 5552}
5475 5553
5554#undef MAX_ROOM_NEEDED
5476#undef TCHARS_PER_DCHAR 5555#undef TCHARS_PER_DCHAR
5477#undef SNPRINTF 5556#undef SNPRINTF
5478#undef USE_SNPRINTF 5557#undef USE_SNPRINTF
diff --git a/gl/verify.h b/gl/verify.h
index bcd3f5a..4ad780c 100644
--- a/gl/verify.h
+++ b/gl/verify.h
@@ -69,13 +69,14 @@
69 if the entity names are not disambiguated. A workaround is to 69 if the entity names are not disambiguated. A workaround is to
70 attach the current line number to the entity name: 70 attach the current line number to the entity name:
71 71
72 #define GL_CONCAT0(x, y) x##y 72 #define _GL_CONCAT0(x, y) x##y
73 #define GL_CONCAT(x, y) GL_CONCAT0 (x, y) 73 #define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y)
74 extern struct {...} * GL_CONCAT(dummy,__LINE__); 74 extern struct {...} * _GL_CONCAT (dummy, __LINE__);
75 75
76 But this has the problem that two invocations of verify from 76 But this has the problem that two invocations of verify from
77 within the same macro would collide, since the __LINE__ value 77 within the same macro would collide, since the __LINE__ value
78 would be the same for both invocations. 78 would be the same for both invocations. (The GCC __COUNTER__
79 macro solves this problem, but is not portable.)
79 80
80 A solution is to use the sizeof operator. It yields a number, 81 A solution is to use the sizeof operator. It yields a number,
81 getting rid of the identity of the type. Declarations like 82 getting rid of the identity of the type. Declarations like
@@ -103,20 +104,41 @@
103 104
104 extern int (*dummy (void)) [sizeof (struct {...})]; 105 extern int (*dummy (void)) [sizeof (struct {...})];
105 106
107 * GCC warns about duplicate declarations of the dummy function if
108 -Wredundant_decls is used. GCC 4.3 and later have a builtin
109 __COUNTER__ macro that can let us generate unique identifiers for
110 each dummy function, to suppress this warning.
111
106 * This implementation exploits the fact that GCC does not warn about 112 * This implementation exploits the fact that GCC does not warn about
107 the last declaration mentioned above. If a future version of GCC 113 the last declaration mentioned above. If a future version of GCC
108 introduces a warning for this, the problem could be worked around 114 introduces a warning for this, the problem could be worked around
109 by using code specialized to GCC, e.g.,: 115 by using code specialized to GCC, just as __COUNTER__ is already
116 being used if available.
110 117
111 #if 4 <= __GNUC__ 118 #if 4 <= __GNUC__
112 # define verify(R) \ 119 # define verify(R) [another version to keep GCC happy]
113 extern int (* verify_function__ (void)) \
114 [__builtin_constant_p (R) && (R) ? 1 : -1]
115 #endif 120 #endif
116 121
117 * In C++, any struct definition inside sizeof is invalid. 122 * In C++, any struct definition inside sizeof is invalid.
118 Use a template type to work around the problem. */ 123 Use a template type to work around the problem. */
119 124
125/* Concatenate two preprocessor tokens. */
126# define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y)
127# define _GL_CONCAT0(x, y) x##y
128
129/* _GL_COUNTER is an integer, preferably one that changes each time we
130 use it. Use __COUNTER__ if it works, falling back on __LINE__
131 otherwise. __LINE__ isn't perfect, but it's better than a
132 constant. */
133# if defined __COUNTER__ && __COUNTER__ != __COUNTER__
134# define _GL_COUNTER __COUNTER__
135# else
136# define _GL_COUNTER __LINE__
137# endif
138
139/* Generate a symbol with the given prefix, making it unique if
140 possible. */
141# define _GL_GENSYM(prefix) _GL_CONCAT (prefix, _GL_COUNTER)
120 142
121/* Verify requirement R at compile-time, as an integer constant expression. 143/* Verify requirement R at compile-time, as an integer constant expression.
122 Return 1. */ 144 Return 1. */
@@ -135,6 +157,7 @@ template <int w>
135/* Verify requirement R at compile-time, as a declaration without a 157/* Verify requirement R at compile-time, as a declaration without a
136 trailing ';'. */ 158 trailing ';'. */
137 159
138# define verify(R) extern int (* verify_function__ (void)) [verify_true (R)] 160# define verify(R) \
161 extern int (* _GL_GENSYM (verify_function) (void)) [verify_true (R)]
139 162
140#endif 163#endif
diff --git a/gl/wchar.in.h b/gl/wchar.in.h
index dd41d35..88d47db 100644
--- a/gl/wchar.in.h
+++ b/gl/wchar.in.h
@@ -407,7 +407,7 @@ _GL_WARN_ON_USE (wcsnrtombs, "wcsnrtombs is unportable - "
407_GL_FUNCDECL_RPL (wcwidth, int, (wchar_t)); 407_GL_FUNCDECL_RPL (wcwidth, int, (wchar_t));
408_GL_CXXALIAS_RPL (wcwidth, int, (wchar_t)); 408_GL_CXXALIAS_RPL (wcwidth, int, (wchar_t));
409# else 409# else
410# if !defined wcwidth && !@HAVE_DECL_WCWIDTH@ 410# if !@HAVE_DECL_WCWIDTH@
411/* wcwidth exists but is not declared. */ 411/* wcwidth exists but is not declared. */
412_GL_FUNCDECL_SYS (wcwidth, int, (wchar_t)); 412_GL_FUNCDECL_SYS (wcwidth, int, (wchar_t));
413# endif 413# endif