summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.x-sc_prohibit_empty_lines_at_EOF4
-rw-r--r--GNUmakefile6
-rw-r--r--build-aux/c++defs.h18
-rw-r--r--build-aux/warn-on-use.h9
-rw-r--r--doc/certtool.cfg1
-rwxr-xr-xdoc/credentials/gnutls-http-serv1
-rw-r--r--doc/credentials/params.pem2
-rw-r--r--doc/credentials/x509/Makefile.am1
-rw-r--r--doc/credentials/x509/cert.pem1
-rw-r--r--doc/credentials/x509/clicert-dsa.pem1
-rw-r--r--gl/Makefile.am19
-rw-r--r--gl/fseeko.c5
-rw-r--r--gl/m4/fseeko.m431
-rw-r--r--gl/m4/gnulib-common.m44
-rw-r--r--gl/m4/gnulib-comp.m41
-rw-r--r--gl/m4/lib-link.m414
-rw-r--r--gl/m4/memchr.m417
-rw-r--r--gl/m4/stdio_h.m48
-rw-r--r--gl/m4/stdlib_h.m43
-rw-r--r--gl/m4/string_h.m414
-rw-r--r--gl/m4/time_h.m48
-rw-r--r--gl/m4/unistd_h.m45
-rw-r--r--gl/m4/vasnprintf.m414
-rw-r--r--gl/stdio-impl.h11
-rw-r--r--gl/stdio.in.h105
-rw-r--r--gl/stdlib.in.h7
-rw-r--r--gl/string.in.h50
-rw-r--r--gl/sys_socket.in.h27
-rw-r--r--gl/sys_stat.in.h11
-rw-r--r--gl/sys_time.in.h4
-rw-r--r--gl/tests/Makefile.am2
-rw-r--r--gl/tests/ioctl.c2
-rw-r--r--gl/tests/sys_ioctl.in.h4
-rw-r--r--gl/tests/test-vasnprintf.c61
-rw-r--r--gl/time.in.h32
-rw-r--r--gl/unistd.in.h19
-rw-r--r--gl/vasnprintf.c590
-rw-r--r--gl/wchar.in.h6
-rw-r--r--guile/modules/gnutls/extra.scm1
-rw-r--r--guile/tests/x509-auth.scm1
-rw-r--r--guile/tests/x509-certificate.pem1
-rw-r--r--lib/build-aux/c++defs.h18
-rw-r--r--lib/build-aux/warn-on-use.h9
-rw-r--r--lib/ext_cert_type.h1
-rw-r--r--lib/gl/Makefile.am19
-rw-r--r--lib/gl/fseeko.c5
-rw-r--r--lib/gl/m4/fseeko.m431
-rw-r--r--lib/gl/m4/gnulib-common.m44
-rw-r--r--lib/gl/m4/gnulib-comp.m41
-rw-r--r--lib/gl/m4/lib-link.m414
-rw-r--r--lib/gl/m4/memchr.m417
-rw-r--r--lib/gl/m4/stdio_h.m48
-rw-r--r--lib/gl/m4/stdlib_h.m43
-rw-r--r--lib/gl/m4/string_h.m414
-rw-r--r--lib/gl/m4/threadlib.m441
-rw-r--r--lib/gl/m4/time_h.m48
-rw-r--r--lib/gl/m4/time_r.m450
-rw-r--r--lib/gl/m4/unistd_h.m45
-rw-r--r--lib/gl/m4/vasnprintf.m414
-rw-r--r--lib/gl/stdio-impl.h11
-rw-r--r--lib/gl/stdio.in.h105
-rw-r--r--lib/gl/stdlib.in.h7
-rw-r--r--lib/gl/string.in.h50
-rw-r--r--lib/gl/sys_socket.in.h27
-rw-r--r--lib/gl/sys_stat.in.h11
-rw-r--r--lib/gl/tests/Makefile.am2
-rw-r--r--lib/gl/tests/test-vasnprintf.c61
-rw-r--r--lib/gl/time.in.h32
-rw-r--r--lib/gl/time_r.c4
-rw-r--r--lib/gl/unistd.in.h19
-rw-r--r--lib/gl/vasnprintf.c590
-rw-r--r--lib/gl/wchar.in.h6
-rw-r--r--lib/minitasn1/Makefile.am2
-rw-r--r--lib/minitasn1/README3
-rw-r--r--lib/opencdk/keydb.h1
-rw-r--r--lib/opencdk/packet.h1
-rw-r--r--libextra/gl/m4/gnulib-common.m44
-rw-r--r--libextra/gl/m4/gnulib-comp.m41
-rw-r--r--libextra/gl/m4/lib-link.m414
-rw-r--r--maint.mk445
-rw-r--r--src/certtool.gaa1
-rw-r--r--src/cfg/Makefile.am1
-rw-r--r--src/crypt.gaa1
-rw-r--r--src/tls_test.gaa1
-rw-r--r--tests/key-id/ca-gnutls-keyid.pem3
-rw-r--r--tests/key-id/ca-no-keyid.pem3
-rw-r--r--tests/key-id/ca-weird-keyid.pem3
-rw-r--r--tests/pkcs1-padding/pkcs1-pad-broken.pem3
-rw-r--r--tests/pkcs1-padding/pkcs1-pad-broken2.pem3
-rw-r--r--tests/pkcs1-padding/pkcs1-pad-broken3.pem3
-rw-r--r--tests/pkcs1-padding/pkcs1-pad-ok.pem3
-rw-r--r--tests/pkcs1-padding/pkcs1-pad-ok2.pem3
-rw-r--r--tests/safe-renegotiation/Makefile.am1
-rw-r--r--tests/test25.pem1
94 files changed, 1760 insertions, 1049 deletions
diff --git a/.x-sc_prohibit_empty_lines_at_EOF b/.x-sc_prohibit_empty_lines_at_EOF
new file mode 100644
index 0000000000..a01c26af45
--- /dev/null
+++ b/.x-sc_prohibit_empty_lines_at_EOF
@@ -0,0 +1,4 @@
+^doc/fdl-1.3.texi
+^doc/protocol/
+^lib/COPYING
+^src/cfg/
diff --git a/GNUmakefile b/GNUmakefile
index 40ccc061d0..daba47ae2d 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -49,7 +49,7 @@ include $(srcdir)/maint.mk
# Allow cfg.mk to override these.
_build-aux ?= build-aux
-_autoreconf ?= autoreconf
+_autoreconf ?= autoreconf -v
# Ensure that $(VERSION) is up to date for dist-related targets, but not
# for others: rerunning autoreconf and recompiling everything isn't cheap.
@@ -78,7 +78,8 @@ ifeq ($(_have-git-version-gen)0,yes$(MAKELEVEL))
$(info run '$(MAKE) _version' to fix it)
else
$(info INFO: running autoreconf for new version string: $(_curr-ver))
- _dummy := $(shell $(MAKE) $(AM_MAKEFLAGS) _version)
+GNUmakefile: _version
+ touch GNUmakefile
endif
endif
endif
@@ -88,6 +89,7 @@ endif
.PHONY: _version
_version:
cd $(srcdir) && rm -rf autom4te.cache .version && $(_autoreconf)
+ $(MAKE) $(AM_MAKEFLAGS) Makefile
else
diff --git a/build-aux/c++defs.h b/build-aux/c++defs.h
index 31b29c2261..7d710898ec 100644
--- a/build-aux/c++defs.h
+++ b/build-aux/c++defs.h
@@ -126,6 +126,24 @@
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
+/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
+ is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
+ except that the C function rpl_func may have a slightly different
+ declaration. A cast is used to silence the "invalid conversion" error
+ that would otherwise occur. */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
+ namespace GNULIB_NAMESPACE \
+ { \
+ rettype (*const func) parameters = \
+ reinterpret_cast<rettype(*)parameters>(::rpl_func); \
+ } \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#else
+# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
/* _GL_CXXALIAS_SYS (func, rettype, parameters);
declares a C++ alias called GNULIB_NAMESPACE::func
that redirects to the system provided function func, if GNULIB_NAMESPACE
diff --git a/build-aux/warn-on-use.h b/build-aux/warn-on-use.h
index 1cd5062d0a..171e599163 100644
--- a/build-aux/warn-on-use.h
+++ b/build-aux/warn-on-use.h
@@ -67,7 +67,10 @@
/* A compiler attribute is available in gcc versions 4.3.0 and later. */
# define _GL_WARN_ON_USE(function, message) \
extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
-
+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
+/* Verify the existence of the function. */
+# define _GL_WARN_ON_USE(function, message) \
+extern __typeof__ (function) function
# else /* Unsupported. */
# define _GL_WARN_ON_USE(function, message) \
_GL_WARN_EXTERN_C int _gl_warn_on_use
@@ -85,6 +88,10 @@ _GL_WARN_EXTERN_C int _gl_warn_on_use
# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
extern rettype function parameters_and_attributes \
__attribute__ ((__warning__ (msg)))
+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
+/* Verify the existence of the function. */
+# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
+extern rettype function parameters_and_attributes
# else /* Unsupported. */
# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
_GL_WARN_EXTERN_C int _gl_warn_on_use
diff --git a/doc/certtool.cfg b/doc/certtool.cfg
index 7b86833dc5..72597600ff 100644
--- a/doc/certtool.cfg
+++ b/doc/certtool.cfg
@@ -112,4 +112,3 @@ signing_key
# A name for a PKCS #12 key
#pkcs12_key_name = "Anonymous key"
-
diff --git a/doc/credentials/gnutls-http-serv b/doc/credentials/gnutls-http-serv
index 5f5fcee3d4..90c9717547 100755
--- a/doc/credentials/gnutls-http-serv
+++ b/doc/credentials/gnutls-http-serv
@@ -5,4 +5,3 @@
--srppasswd srp/tpasswd --srppasswdconf srp/tpasswd.conf \
--pgpkeyfile openpgp/sec.asc --pgpcertfile openpgp/pub.asc --pskpasswd psk/passwd.psk \
--dhparams params.pem $*
-
diff --git a/doc/credentials/params.pem b/doc/credentials/params.pem
index 2539090162..43f0282d03 100644
--- a/doc/credentials/params.pem
+++ b/doc/credentials/params.pem
@@ -1,7 +1,5 @@
-
-----BEGIN DH PARAMETERS-----
MIGGAoGA7q8Kua2zjdacM/gK+o/F6GByYYd1/zwLnqIxTJwlZXbWdN90luqB0zg7
SBPWksbg4NXY4lC5i+SOSVwdYIna0V3H17RhVNa2zo70rWmxXUmCVZspe88YhcUp
9WZmDlfsaO28PAVybMAv1Mv0l26qmv1ROP6DdkNbn8YdL8DrBuMCAQI=
-----END DH PARAMETERS-----
-
diff --git a/doc/credentials/x509/Makefile.am b/doc/credentials/x509/Makefile.am
index 5bf4c23fa1..1c18486db3 100644
--- a/doc/credentials/x509/Makefile.am
+++ b/doc/credentials/x509/Makefile.am
@@ -1,3 +1,2 @@
EXTRA_DIST = ca.pem cert.pem key.pem clikey.pem clicert.pem clicert-dsa.pem \
clikey-dsa.pem cert-dsa.pem key-dsa.pem
-
diff --git a/doc/credentials/x509/cert.pem b/doc/credentials/x509/cert.pem
index 8891072581..f6f4bed1a4 100644
--- a/doc/credentials/x509/cert.pem
+++ b/doc/credentials/x509/cert.pem
@@ -30,4 +30,3 @@ CSqGSIb3DQEBBQOBgQCi/SI37DrGCeZhtGhU2AyZFaqskRoFt4zAb9UYaGZaYEh5
0VUZsA/Ol8jiiQTtiCokZswhSsn+2McZmcspKigsY2aEBrry+TGFWMnYu5j5kcwP
1nVuHxLRwLt2rIsjgkeSNdHr8XHKi9/Roz/Gj86OnBAHwPt8WHfHK+63cMX1WA==
-----END CERTIFICATE-----
-
diff --git a/doc/credentials/x509/clicert-dsa.pem b/doc/credentials/x509/clicert-dsa.pem
index 0586abc126..880ea160b1 100644
--- a/doc/credentials/x509/clicert-dsa.pem
+++ b/doc/credentials/x509/clicert-dsa.pem
@@ -37,4 +37,3 @@ CSqGSIb3DQEBBQOBgQCi/SI37DrGCeZhtGhU2AyZFaqskRoFt4zAb9UYaGZaYEh5
0VUZsA/Ol8jiiQTtiCokZswhSsn+2McZmcspKigsY2aEBrry+TGFWMnYu5j5kcwP
1nVuHxLRwLt2rIsjgkeSNdHr8XHKi9/Roz/Gj86OnBAHwPt8WHfHK+63cMX1WA==
-----END CERTIFICATE-----
-
diff --git a/gl/Makefile.am b/gl/Makefile.am
index 190158cb9e..327ac12e60 100644
--- a/gl/Makefile.am
+++ b/gl/Makefile.am
@@ -760,6 +760,7 @@ stdio.h: stdio.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
-e 's|@''GNULIB_SNPRINTF''@|$(GNULIB_SNPRINTF)|g' \
-e 's|@''GNULIB_SPRINTF_POSIX''@|$(GNULIB_SPRINTF_POSIX)|g' \
-e 's|@''GNULIB_STDIO_H_SIGPIPE''@|$(GNULIB_STDIO_H_SIGPIPE)|g' \
+ -e 's|@''GNULIB_TMPFILE''@|$(GNULIB_TMPFILE)|g' \
-e 's|@''GNULIB_VASPRINTF''@|$(GNULIB_VASPRINTF)|g' \
-e 's|@''GNULIB_VDPRINTF''@|$(GNULIB_VDPRINTF)|g' \
-e 's|@''GNULIB_VFPRINTF''@|$(GNULIB_VFPRINTF)|g' \
@@ -776,6 +777,8 @@ stdio.h: stdio.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
-e 's|@''HAVE_DECL_SNPRINTF''@|$(HAVE_DECL_SNPRINTF)|g' \
-e 's|@''HAVE_DECL_VSNPRINTF''@|$(HAVE_DECL_VSNPRINTF)|g' \
-e 's|@''HAVE_DPRINTF''@|$(HAVE_DPRINTF)|g' \
+ -e 's|@''HAVE_FSEEKO''@|$(HAVE_FSEEKO)|g' \
+ -e 's|@''HAVE_FTELLO''@|$(HAVE_FTELLO)|g' \
-e 's|@''HAVE_RENAMEAT''@|$(HAVE_RENAMEAT)|g' \
-e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \
-e 's|@''HAVE_VDPRINTF''@|$(HAVE_VDPRINTF)|g' \
@@ -802,6 +805,7 @@ stdio.h: stdio.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
-e 's|@''REPLACE_SNPRINTF''@|$(REPLACE_SNPRINTF)|g' \
-e 's|@''REPLACE_SPRINTF''@|$(REPLACE_SPRINTF)|g' \
-e 's|@''REPLACE_STDIO_WRITE_FUNCS''@|$(REPLACE_STDIO_WRITE_FUNCS)|g' \
+ -e 's|@''REPLACE_TMPFILE''@|$(REPLACE_TMPFILE)|g' \
-e 's|@''REPLACE_VASPRINTF''@|$(REPLACE_VASPRINTF)|g' \
-e 's|@''REPLACE_VDPRINTF''@|$(REPLACE_VDPRINTF)|g' \
-e 's|@''REPLACE_VFPRINTF''@|$(REPLACE_VFPRINTF)|g' \
@@ -867,6 +871,7 @@ stdlib.h: stdlib.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
-e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \
-e 's|@''HAVE_MKOSTEMP''@|$(HAVE_MKOSTEMP)|g' \
-e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \
+ -e 's|@''HAVE_MKSTEMP''@|$(HAVE_MKSTEMP)|g' \
-e 's|@''HAVE_MKSTEMPS''@|$(HAVE_MKSTEMPS)|g' \
-e 's|@''HAVE_PTSNAME''@|$(HAVE_PTSNAME)|g' \
-e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \
@@ -945,6 +950,7 @@ string.h: string.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
-e 's|@''GNULIB_STPNCPY''@|$(GNULIB_STPNCPY)|g' \
-e 's|@''GNULIB_STRCHRNUL''@|$(GNULIB_STRCHRNUL)|g' \
-e 's|@''GNULIB_STRDUP''@|$(GNULIB_STRDUP)|g' \
+ -e 's|@''GNULIB_STRNCAT''@|$(GNULIB_STRNCAT)|g' \
-e 's|@''GNULIB_STRNDUP''@|$(GNULIB_STRNDUP)|g' \
-e 's|@''GNULIB_STRNLEN''@|$(GNULIB_STRNLEN)|g' \
-e 's|@''GNULIB_STRPBRK''@|$(GNULIB_STRPBRK)|g' \
@@ -957,6 +963,7 @@ string.h: string.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
-e 's|@''GNULIB_STRVERSCMP''@|$(GNULIB_STRVERSCMP)|g' \
< $(srcdir)/string.in.h | \
sed -e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \
+ -e 's|@''HAVE_MEMCHR''@|$(HAVE_MEMCHR)|g' \
-e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \
-e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \
-e 's|@''HAVE_DECL_MEMRCHR''@|$(HAVE_DECL_MEMRCHR)|g' \
@@ -971,16 +978,18 @@ string.h: string.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
-e 's|@''HAVE_STRSEP''@|$(HAVE_STRSEP)|g' \
-e 's|@''HAVE_STRCASESTR''@|$(HAVE_STRCASESTR)|g' \
-e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \
- -e 's|@''HAVE_DECL_STRERROR''@|$(HAVE_DECL_STRERROR)|g' \
-e 's|@''HAVE_DECL_STRSIGNAL''@|$(HAVE_DECL_STRSIGNAL)|g' \
-e 's|@''HAVE_STRVERSCMP''@|$(HAVE_STRVERSCMP)|g' \
+ -e 's|@''REPLACE_STPNCPY''@|$(REPLACE_STPNCPY)|g' \
-e 's|@''REPLACE_MEMCHR''@|$(REPLACE_MEMCHR)|g' \
-e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \
-e 's|@''REPLACE_STRCASESTR''@|$(REPLACE_STRCASESTR)|g' \
-e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \
-e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \
-e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \
+ -e 's|@''REPLACE_STRNCAT''@|$(REPLACE_STRNCAT)|g' \
-e 's|@''REPLACE_STRNDUP''@|$(REPLACE_STRNDUP)|g' \
+ -e 's|@''REPLACE_STRNLEN''@|$(REPLACE_STRNLEN)|g' \
-e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \
-e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \
-e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \
@@ -1178,10 +1187,13 @@ time.h: time.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
-e 's|@''GNULIB_STRPTIME''@|$(GNULIB_STRPTIME)|g' \
-e 's|@''GNULIB_TIMEGM''@|$(GNULIB_TIMEGM)|g' \
-e 's|@''GNULIB_TIME_R''@|$(GNULIB_TIME_R)|g' \
+ -e 's|@''HAVE_LOCALTIME_R''@|$(HAVE_LOCALTIME_R)|g' \
+ -e 's|@''HAVE_NANOSLEEP''@|$(HAVE_NANOSLEEP)|g' \
+ -e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \
+ -e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \
-e 's|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \
-e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \
-e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \
- -e 's|@''REPLACE_STRPTIME''@|$(REPLACE_STRPTIME)|g' \
-e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \
-e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
-e 's|@''TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
@@ -1262,6 +1274,7 @@ unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
-e 's|@''HAVE_DUP3''@|$(HAVE_DUP3)|g' \
-e 's|@''HAVE_EUIDACCESS''@|$(HAVE_EUIDACCESS)|g' \
-e 's|@''HAVE_FACCESSAT''@|$(HAVE_FACCESSAT)|g' \
+ -e 's|@''HAVE_FCHDIR''@|$(HAVE_FCHDIR)|g' \
-e 's|@''HAVE_FCHOWNAT''@|$(HAVE_FCHOWNAT)|g' \
-e 's|@''HAVE_FSYNC''@|$(HAVE_FSYNC)|g' \
-e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \
@@ -1286,6 +1299,7 @@ unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
-e 's|@''HAVE_USLEEP''@|$(HAVE_USLEEP)|g' \
-e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \
-e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \
+ -e 's|@''HAVE_DECL_GETPAGESIZE''@|$(HAVE_DECL_GETPAGESIZE)|g' \
-e 's|@''HAVE_DECL_GETUSERSHELL''@|$(HAVE_DECL_GETUSERSHELL)|g' \
-e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \
-e 's|@''HAVE_SYS_PARAM_H''@|$(HAVE_SYS_PARAM_H)|g' \
@@ -1293,7 +1307,6 @@ unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
-e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \
-e 's|@''REPLACE_DUP''@|$(REPLACE_DUP)|g' \
-e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \
- -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \
-e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \
-e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \
-e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \
diff --git a/gl/fseeko.c b/gl/fseeko.c
index 1a41b16f51..05a7384c07 100644
--- a/gl/fseeko.c
+++ b/gl/fseeko.c
@@ -25,14 +25,13 @@
#include "stdio-impl.h"
+int
+fseeko (FILE *fp, off_t offset, int whence)
#undef fseeko
#if !HAVE_FSEEKO
# undef fseek
# define fseeko fseek
#endif
-
-int
-rpl_fseeko (FILE *fp, off_t offset, int whence)
{
#if LSEEK_PIPE_BROKEN
/* mingw gives bogus answers rather than failure on non-seekable files. */
diff --git a/gl/m4/fseeko.m4 b/gl/m4/fseeko.m4
index 5f7f97729c..b97df53377 100644
--- a/gl/m4/fseeko.m4
+++ b/gl/m4/fseeko.m4
@@ -1,4 +1,4 @@
-# fseeko.m4 serial 7
+# fseeko.m4 serial 9
dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -7,9 +7,25 @@ dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_FUNC_FSEEKO],
[
AC_REQUIRE([gl_STDIO_H_DEFAULTS])
- AC_REQUIRE([AC_PROG_CC])
+ AC_REQUIRE([gl_HAVE_FSEEKO])
AC_REQUIRE([gl_STDIN_LARGE_OFFSET])
+ if test $gl_cv_func_fseeko = no; then
+ HAVE_FSEEKO=0
+ gl_REPLACE_FSEEKO
+ else
+ if test $gl_cv_var_stdin_large_offset = no; then
+ gl_REPLACE_FSEEKO
+ fi
+ fi
+])
+
+dnl Tests whether fseeko is available.
+dnl Result is gl_cv_func_fseeko.
+AC_DEFUN([gl_HAVE_FSEEKO],
+[
+ AC_REQUIRE([AC_PROG_CC])
+
dnl Persuade glibc <stdio.h> to declare fseeko().
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
@@ -19,17 +35,16 @@ AC_DEFUN([gl_FUNC_FSEEKO],
]], [fseeko (stdin, 0, 0);])],
[gl_cv_func_fseeko=yes], [gl_cv_func_fseeko=no])
])
- if test $gl_cv_func_fseeko = no \
- || test $gl_cv_var_stdin_large_offset = no; then
- gl_REPLACE_FSEEKO
- fi
])
AC_DEFUN([gl_REPLACE_FSEEKO],
[
- AC_LIBOBJ([fseeko])
AC_REQUIRE([gl_STDIO_H_DEFAULTS])
- REPLACE_FSEEKO=1
+ AC_REQUIRE([gl_HAVE_FSEEKO])
+ if test $gl_cv_func_fseeko = yes; then
+ REPLACE_FSEEKO=1
+ fi
+ AC_LIBOBJ([fseeko])
dnl If we are also using the fseek module, then fseek needs replacing, too.
m4_ifdef([gl_REPLACE_FSEEK], [gl_REPLACE_FSEEK])
])
diff --git a/gl/m4/gnulib-common.m4 b/gl/m4/gnulib-common.m4
index 9cc519e765..54b251737c 100644
--- a/gl/m4/gnulib-common.m4
+++ b/gl/m4/gnulib-common.m4
@@ -1,4 +1,4 @@
-# gnulib-common.m4 serial 18
+# gnulib-common.m4 serial 19
dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -132,6 +132,7 @@ m4_ifdef([AC_PROG_MKDIR_P], [
# so that mixed use of GNU C and GNU C++ and mixed use of Sun C and Sun C++
# works.
# This definition can be removed once autoconf >= 2.62 can be assumed.
+m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.62]),[-1],[
AC_DEFUN([AC_C_RESTRICT],
[AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict],
[ac_cv_c_restrict=no
@@ -169,6 +170,7 @@ AC_DEFUN([AC_C_RESTRICT],
*) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;;
esac
])
+])
# gl_BIGENDIAN
# is like AC_C_BIGENDIAN, except that it can be AC_REQUIREd.
diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4
index 8830de9c41..65fb6c6d4f 100644
--- a/gl/m4/gnulib-comp.m4
+++ b/gl/m4/gnulib-comp.m4
@@ -174,6 +174,7 @@ AC_DEFUN([gl_INIT],
[
AM_CONDITIONAL([GL_COND_LIBTOOL], [true])
gl_cond_libtool=true
+ gl_m4_base='gl/m4'
m4_pushdef([AC_LIBOBJ], m4_defn([gl_LIBOBJ]))
m4_pushdef([AC_REPLACE_FUNCS], m4_defn([gl_REPLACE_FUNCS]))
m4_pushdef([AC_LIBSOURCES], m4_defn([gl_LIBSOURCES]))
diff --git a/gl/m4/lib-link.m4 b/gl/m4/lib-link.m4
index 90e1ac9170..c73bd8e3a4 100644
--- a/gl/m4/lib-link.m4
+++ b/gl/m4/lib-link.m4
@@ -1,4 +1,4 @@
-# lib-link.m4 serial 20 (gettext-0.18)
+# lib-link.m4 serial 21 (gettext-0.18)
dnl Copyright (C) 2001-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -74,7 +74,17 @@ AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
ac_save_LIBS="$LIBS"
- LIBS="$LIBS $LIB[]NAME"
+ dnl If $LIB[]NAME contains some -l options, add it to the end of LIBS,
+ dnl because these -l options might require -L options that are present in
+ dnl LIBS. -l options benefit only from the -L options listed before it.
+ dnl Otherwise, add it to the front of LIBS, because it may be a static
+ dnl library that depends on another static library that is present in LIBS.
+ dnl Static libraries benefit only from the static libraries listed after
+ dnl it.
+ case " $LIB[]NAME" in
+ *" -l"*) LIBS="$LIBS $LIB[]NAME" ;;
+ *) LIBS="$LIB[]NAME $LIBS" ;;
+ esac
AC_TRY_LINK([$3], [$4],
[ac_cv_lib[]Name=yes],
[ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])'])
diff --git a/gl/m4/memchr.m4 b/gl/m4/memchr.m4
index 94596ef959..ab773b8129 100644
--- a/gl/m4/memchr.m4
+++ b/gl/m4/memchr.m4
@@ -1,4 +1,4 @@
-# memchr.m4 serial 7
+# memchr.m4 serial 8
dnl Copyright (C) 2002-2004, 2009-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -13,12 +13,7 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
dnl These days, we assume memchr is present. But just in case...
AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
- AC_REPLACE_FUNCS([memchr])
- if test $ac_cv_func_memchr = no; then
- gl_PREREQ_MEMCHR
- REPLACE_MEMCHR=1
- fi
-
+ AC_CHECK_FUNCS_ONCE([memchr])
if test $ac_cv_func_memchr = yes; then
# Detect platform-specific bugs in some versions of glibc:
# memchr should not dereference anything with length 0
@@ -73,10 +68,14 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
[dnl Be pessimistic for now.
gl_cv_func_memchr_works="guessing no"])])
if test "$gl_cv_func_memchr_works" != yes; then
- gl_PREREQ_MEMCHR
REPLACE_MEMCHR=1
- AC_LIBOBJ([memchr])
fi
+ else
+ HAVE_MEMCHR=0
+ fi
+ if test $HAVE_MEMCHR = 0 || test $REPLACE_MEMCHR = 1; then
+ AC_LIBOBJ([memchr])
+ gl_PREREQ_MEMCHR
fi
])
diff --git a/gl/m4/stdio_h.m4 b/gl/m4/stdio_h.m4
index af56b1f9da..1d1d95e568 100644
--- a/gl/m4/stdio_h.m4
+++ b/gl/m4/stdio_h.m4
@@ -1,4 +1,4 @@
-# stdio_h.m4 serial 27
+# stdio_h.m4 serial 30
dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -37,7 +37,7 @@ AC_DEFUN([gl_STDIO_H],
dnl guaranteed by C89.
gl_WARN_ON_USE_PREPARE([[#include <stdio.h>
]], [dprintf fpurge fseeko ftello getdelim getline popen renameat
- snprintf vdprintf vsnprintf])
+ snprintf tmpfile vdprintf vsnprintf])
])
AC_DEFUN([gl_STDIO_MODULE_INDICATOR],
@@ -83,6 +83,7 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS],
GNULIB_SNPRINTF=0; AC_SUBST([GNULIB_SNPRINTF])
GNULIB_SPRINTF_POSIX=0; AC_SUBST([GNULIB_SPRINTF_POSIX])
GNULIB_STDIO_H_SIGPIPE=0; AC_SUBST([GNULIB_STDIO_H_SIGPIPE])
+ GNULIB_TMPFILE=0; AC_SUBST([GNULIB_TMPFILE])
GNULIB_VASPRINTF=0; AC_SUBST([GNULIB_VASPRINTF])
GNULIB_VDPRINTF=0; AC_SUBST([GNULIB_VDPRINTF])
GNULIB_VFPRINTF=0; AC_SUBST([GNULIB_VFPRINTF])
@@ -99,6 +100,8 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS],
HAVE_DECL_SNPRINTF=1; AC_SUBST([HAVE_DECL_SNPRINTF])
HAVE_DECL_VSNPRINTF=1; AC_SUBST([HAVE_DECL_VSNPRINTF])
HAVE_DPRINTF=1; AC_SUBST([HAVE_DPRINTF])
+ HAVE_FSEEKO=1; AC_SUBST([HAVE_FSEEKO])
+ HAVE_FTELLO=1; AC_SUBST([HAVE_FTELLO])
HAVE_RENAMEAT=1; AC_SUBST([HAVE_RENAMEAT])
HAVE_VASPRINTF=1; AC_SUBST([HAVE_VASPRINTF])
HAVE_VDPRINTF=1; AC_SUBST([HAVE_VDPRINTF])
@@ -125,6 +128,7 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS],
REPLACE_SNPRINTF=0; AC_SUBST([REPLACE_SNPRINTF])
REPLACE_SPRINTF=0; AC_SUBST([REPLACE_SPRINTF])
REPLACE_STDIO_WRITE_FUNCS=0; AC_SUBST([REPLACE_STDIO_WRITE_FUNCS])
+ REPLACE_TMPFILE=0; AC_SUBST([REPLACE_TMPFILE])
REPLACE_VASPRINTF=0; AC_SUBST([REPLACE_VASPRINTF])
REPLACE_VDPRINTF=0; AC_SUBST([REPLACE_VDPRINTF])
REPLACE_VFPRINTF=0; AC_SUBST([REPLACE_VFPRINTF])
diff --git a/gl/m4/stdlib_h.m4 b/gl/m4/stdlib_h.m4
index 4c5cca89ab..dd84796d2c 100644
--- a/gl/m4/stdlib_h.m4
+++ b/gl/m4/stdlib_h.m4
@@ -1,4 +1,4 @@
-# stdlib_h.m4 serial 27
+# stdlib_h.m4 serial 28
dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -85,6 +85,7 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
HAVE_MKDTEMP=1; AC_SUBST([HAVE_MKDTEMP])
HAVE_MKOSTEMP=1; AC_SUBST([HAVE_MKOSTEMP])
HAVE_MKOSTEMPS=1; AC_SUBST([HAVE_MKOSTEMPS])
+ HAVE_MKSTEMP=1; AC_SUBST([HAVE_MKSTEMP])
HAVE_MKSTEMPS=1; AC_SUBST([HAVE_MKSTEMPS])
HAVE_PTSNAME=1; AC_SUBST([HAVE_PTSNAME])
HAVE_RANDOM_R=1; AC_SUBST([HAVE_RANDOM_R])
diff --git a/gl/m4/string_h.m4 b/gl/m4/string_h.m4
index 9ceeea986a..1977aecf91 100644
--- a/gl/m4/string_h.m4
+++ b/gl/m4/string_h.m4
@@ -5,7 +5,7 @@
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
-# serial 13
+# serial 17
# Written by Paul Eggert.
@@ -26,8 +26,10 @@ AC_DEFUN([gl_HEADER_STRING_H_BODY],
dnl corresponding gnulib module is not in use, and which is not
dnl guaranteed by C89.
gl_WARN_ON_USE_PREPARE([[#include <string.h>
- ]], [memmem mempcpy memrchr rawmemchr stpcpy stpncpy strchrnul strdup
- strndup strnlen strpbrk strsep strcasestr strtok_r strsignal strverscmp])
+ ]],
+ [memmem mempcpy memrchr rawmemchr stpcpy stpncpy strchrnul strdup
+ strncat strndup strnlen strpbrk strsep strcasestr strtok_r strsignal
+ strverscmp])
])
AC_DEFUN([gl_STRING_MODULE_INDICATOR],
@@ -50,6 +52,7 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
GNULIB_STPNCPY=0; AC_SUBST([GNULIB_STPNCPY])
GNULIB_STRCHRNUL=0; AC_SUBST([GNULIB_STRCHRNUL])
GNULIB_STRDUP=0; AC_SUBST([GNULIB_STRDUP])
+ GNULIB_STRNCAT=0; AC_SUBST([GNULIB_STRNCAT])
GNULIB_STRNDUP=0; AC_SUBST([GNULIB_STRNDUP])
GNULIB_STRNLEN=0; AC_SUBST([GNULIB_STRNLEN])
GNULIB_STRPBRK=0; AC_SUBST([GNULIB_STRPBRK])
@@ -76,6 +79,7 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
GNULIB_STRVERSCMP=0; AC_SUBST([GNULIB_STRVERSCMP])
HAVE_MBSLEN=0; AC_SUBST([HAVE_MBSLEN])
dnl Assume proper GNU behavior unless another module says otherwise.
+ HAVE_MEMCHR=1; AC_SUBST([HAVE_MEMCHR])
HAVE_DECL_MEMMEM=1; AC_SUBST([HAVE_DECL_MEMMEM])
HAVE_MEMPCPY=1; AC_SUBST([HAVE_MEMPCPY])
HAVE_DECL_MEMRCHR=1; AC_SUBST([HAVE_DECL_MEMRCHR])
@@ -90,16 +94,18 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
HAVE_STRSEP=1; AC_SUBST([HAVE_STRSEP])
HAVE_STRCASESTR=1; AC_SUBST([HAVE_STRCASESTR])
HAVE_DECL_STRTOK_R=1; AC_SUBST([HAVE_DECL_STRTOK_R])
- HAVE_DECL_STRERROR=1; AC_SUBST([HAVE_DECL_STRERROR])
HAVE_DECL_STRSIGNAL=1; AC_SUBST([HAVE_DECL_STRSIGNAL])
HAVE_STRVERSCMP=1; AC_SUBST([HAVE_STRVERSCMP])
REPLACE_MEMCHR=0; AC_SUBST([REPLACE_MEMCHR])
REPLACE_MEMMEM=0; AC_SUBST([REPLACE_MEMMEM])
+ REPLACE_STPNCPY=0; AC_SUBST([REPLACE_STPNCPY])
REPLACE_STRDUP=0; AC_SUBST([REPLACE_STRDUP])
REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR])
REPLACE_STRCASESTR=0; AC_SUBST([REPLACE_STRCASESTR])
REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR])
+ REPLACE_STRNCAT=0; AC_SUBST([REPLACE_STRNCAT])
REPLACE_STRNDUP=0; AC_SUBST([REPLACE_STRNDUP])
+ REPLACE_STRNLEN=0; AC_SUBST([REPLACE_STRNLEN])
REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL])
REPLACE_STRTOK_R=0; AC_SUBST([REPLACE_STRTOK_R])
UNDEFINE_STRTOK_R=0; AC_SUBST([UNDEFINE_STRTOK_R])
diff --git a/gl/m4/time_h.m4 b/gl/m4/time_h.m4
index f2e54f2a94..b88ba94da1 100644
--- a/gl/m4/time_h.m4
+++ b/gl/m4/time_h.m4
@@ -64,7 +64,7 @@ AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
AC_DEFUN([gl_TIME_MODULE_INDICATOR],
[
dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
- AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
+ AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
gl_MODULE_INDICATOR_SET_VARIABLE([$1])
dnl Define it also as a C macro, for the benefit of the unit tests.
gl_MODULE_INDICATOR_FOR_TESTS([$1])
@@ -77,12 +77,16 @@ AC_DEFUN([gl_HEADER_TIME_H_DEFAULTS],
GNULIB_STRPTIME=0; AC_SUBST([GNULIB_STRPTIME])
GNULIB_TIMEGM=0; AC_SUBST([GNULIB_TIMEGM])
GNULIB_TIME_R=0; AC_SUBST([GNULIB_TIME_R])
+ dnl Assume proper GNU behavior unless another module says otherwise.
+ HAVE_LOCALTIME_R=1; AC_SUBST([HAVE_LOCALTIME_R])
+ HAVE_NANOSLEEP=1; AC_SUBST([HAVE_NANOSLEEP])
+ HAVE_STRPTIME=1; AC_SUBST([HAVE_STRPTIME])
+ HAVE_TIMEGM=1; AC_SUBST([HAVE_TIMEGM])
dnl If another module says to replace or to not replace, do that.
dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK;
dnl this lets maintainers check for portability.
REPLACE_LOCALTIME_R=GNULIB_PORTCHECK; AC_SUBST([REPLACE_LOCALTIME_R])
REPLACE_MKTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_MKTIME])
REPLACE_NANOSLEEP=GNULIB_PORTCHECK; AC_SUBST([REPLACE_NANOSLEEP])
- REPLACE_STRPTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_STRPTIME])
REPLACE_TIMEGM=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TIMEGM])
])
diff --git a/gl/m4/unistd_h.m4 b/gl/m4/unistd_h.m4
index 789739dffa..8c2eec64a6 100644
--- a/gl/m4/unistd_h.m4
+++ b/gl/m4/unistd_h.m4
@@ -1,4 +1,4 @@
-# unistd_h.m4 serial 43
+# unistd_h.m4 serial 45
dnl Copyright (C) 2006-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -98,6 +98,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
HAVE_DUP3=1; AC_SUBST([HAVE_DUP3])
HAVE_EUIDACCESS=1; AC_SUBST([HAVE_EUIDACCESS])
HAVE_FACCESSAT=1; AC_SUBST([HAVE_FACCESSAT])
+ HAVE_FCHDIR=1; AC_SUBST([HAVE_FCHDIR])
HAVE_FCHOWNAT=1; AC_SUBST([HAVE_FCHOWNAT])
HAVE_FSYNC=1; AC_SUBST([HAVE_FSYNC])
HAVE_FTRUNCATE=1; AC_SUBST([HAVE_FTRUNCATE])
@@ -122,6 +123,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
HAVE_USLEEP=1; AC_SUBST([HAVE_USLEEP])
HAVE_DECL_ENVIRON=1; AC_SUBST([HAVE_DECL_ENVIRON])
HAVE_DECL_GETLOGIN_R=1; AC_SUBST([HAVE_DECL_GETLOGIN_R])
+ HAVE_DECL_GETPAGESIZE=1; AC_SUBST([HAVE_DECL_GETPAGESIZE])
HAVE_DECL_GETUSERSHELL=1; AC_SUBST([HAVE_DECL_GETUSERSHELL])
HAVE_OS_H=0; AC_SUBST([HAVE_OS_H])
HAVE_SYS_PARAM_H=0; AC_SUBST([HAVE_SYS_PARAM_H])
@@ -129,7 +131,6 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
REPLACE_CLOSE=0; AC_SUBST([REPLACE_CLOSE])
REPLACE_DUP=0; AC_SUBST([REPLACE_DUP])
REPLACE_DUP2=0; AC_SUBST([REPLACE_DUP2])
- REPLACE_FCHDIR=0; AC_SUBST([REPLACE_FCHDIR])
REPLACE_FCHOWNAT=0; AC_SUBST([REPLACE_FCHOWNAT])
REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD])
REPLACE_GETGROUPS=0; AC_SUBST([REPLACE_GETGROUPS])
diff --git a/gl/m4/vasnprintf.m4 b/gl/m4/vasnprintf.m4
index 50a20cca23..ebe3c52cde 100644
--- a/gl/m4/vasnprintf.m4
+++ b/gl/m4/vasnprintf.m4
@@ -1,4 +1,4 @@
-# vasnprintf.m4 serial 29
+# vasnprintf.m4 serial 31
dnl Copyright (C) 2002-2004, 2006-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -54,6 +54,7 @@ AC_DEFUN([gl_PREREQ_PRINTF_PARSE],
# Prerequisites of lib/vasnprintf.c.
AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF],
[
+ AC_REQUIRE([AC_C_INLINE])
AC_REQUIRE([AC_FUNC_ALLOCA])
AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
AC_REQUIRE([gt_TYPE_WCHAR_T])
@@ -62,6 +63,17 @@ AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF],
dnl Use the _snprintf function only if it is declared (because on NetBSD it
dnl is defined as a weak alias of snprintf; we prefer to use the latter).
AC_CHECK_DECLS([_snprintf], , , [#include <stdio.h>])
+ dnl We can avoid a lot of code by assuming that snprintf's return value
+ dnl conforms to ISO C99. So check that.
+ AC_REQUIRE([gl_SNPRINTF_RETVAL_C99])
+ case "$gl_cv_func_snprintf_retval_c99" in
+ *yes)
+ AC_DEFINE([HAVE_SNPRINTF_RETVAL_C99], [1],
+ [Define if the return value of the snprintf function is the number of
+ of bytes (excluding the terminating NUL) that would have been produced
+ if the buffer had been large enough.])
+ ;;
+ esac
])
# Extra prerequisites of lib/vasnprintf.c for supporting 'long double'
diff --git a/gl/stdio-impl.h b/gl/stdio-impl.h
index 7d719efe1b..0e67f66ef6 100644
--- a/gl/stdio-impl.h
+++ b/gl/stdio-impl.h
@@ -1,5 +1,5 @@
/* Implementation details of FILE streams.
- Copyright (C) 2007-2010 Free Software Foundation, Inc.
+ Copyright (C) 2007-2008, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -21,6 +21,11 @@
/* BSD stdio derived implementations. */
+#if defined __NetBSD__ /* NetBSD */
+/* Get __NetBSD_Version__. */
+# include <sys/param.h>
+#endif
+
#if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */
# if defined __DragonFly__ /* DragonFly */
@@ -50,7 +55,7 @@
# define fp_ fp
# endif
-# if defined __NetBSD__ || defined __OpenBSD__ /* NetBSD, OpenBSD */
+# if (defined __NetBSD__ && __NetBSD_Version__ >= 105270000) || defined __OpenBSD__ /* NetBSD >= 1.5ZA, OpenBSD */
/* See <http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup>
and <http://www.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup> */
struct __sfileext
@@ -59,7 +64,7 @@
/* More fields, not relevant here. */
};
# define fp_ub ((struct __sfileext *) fp->_ext._base)->_ub
-# else /* FreeBSD, DragonFly, MacOS X, Cygwin */
+# else /* FreeBSD, NetBSD <= 1.5Z, DragonFly, MacOS X, Cygwin */
# define fp_ub fp_->_ub
# endif
diff --git a/gl/stdio.in.h b/gl/stdio.in.h
index b1dbe67c39..dcb8ee573b 100644
--- a/gl/stdio.in.h
+++ b/gl/stdio.in.h
@@ -322,30 +322,39 @@ _GL_CXXALIASWARN (fseek);
# undef fseek
# endif
# if @REPLACE_FSEEKO@
-/* Provide fseek, fseeko functions that are aware of a preceding
- fflush(), and which detect pipes. */
+/* Provide an fseeko function that is aware of a preceding fflush(), and which
+ detects pipes. */
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef fseeko
# define fseeko rpl_fseeko
# endif
_GL_FUNCDECL_RPL (fseeko, int, (FILE *fp, off_t offset, int whence)
_GL_ARG_NONNULL ((1)));
-# if !@GNULIB_FSEEK@
- /* In order to avoid that fseek gets defined as a macro here, the
- developer can request the 'fseek' module. */
-# undef fseek
-# define fseek rpl_fseek
+_GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence));
+# else
+# if ! @HAVE_FSEEKO@
+_GL_FUNCDECL_SYS (fseeko, int, (FILE *fp, off_t offset, int whence)
+ _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence));
+# endif
+_GL_CXXALIASWARN (fseeko);
+# if (@REPLACE_FSEEKO@ || !@HAVE_FSEEKO@) && !@GNULIB_FSEEK@
+ /* Provide an fseek function that is consistent with fseeko. */
+ /* In order to avoid that fseek gets defined as a macro here, the
+ developer can request the 'fseek' module. */
+# undef fseek
+# define fseek rpl_fseek
static inline int _GL_ARG_NONNULL ((1))
rpl_fseek (FILE *fp, long offset, int whence)
{
+# if @REPLACE_FSEEKO@
+ return rpl_fseeko (fp, offset, whence);
+# else
return fseeko (fp, offset, whence);
-}
# endif
-_GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence));
-# else
-_GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence));
+}
# endif
-_GL_CXXALIASWARN (fseeko);
#elif defined GNULIB_POSIXCHECK
# define _GL_FSEEK_WARN /* Category 1, above. */
# undef fseek
@@ -397,22 +406,30 @@ _GL_CXXALIASWARN (ftell);
# define ftello rpl_ftello
# endif
_GL_FUNCDECL_RPL (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1)));
-# if !@GNULIB_FTELL@
- /* In order to avoid that ftell gets defined as a macro here, the
- developer can request the 'ftell' module. */
-# undef ftell
-# define ftell rpl_ftell
+_GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp));
+# else
+# if ! @HAVE_FTELLO@
+_GL_FUNCDECL_SYS (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp));
+# endif
+_GL_CXXALIASWARN (ftello);
+# if (@REPLACE_FTELLO@ || !@HAVE_FTELLO@) && !@GNULIB_FTELL@
+ /* Provide an ftell function that is consistent with ftello. */
+ /* In order to avoid that ftell gets defined as a macro here, the
+ developer can request the 'ftell' module. */
+# undef ftell
+# define ftell rpl_ftell
static inline long _GL_ARG_NONNULL ((1))
rpl_ftell (FILE *f)
{
+# if @REPLACE_FTELLO@
+ return rpl_ftello (f);
+# else
return ftello (f);
-}
# endif
-_GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp));
-# else
-_GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp));
+}
# endif
-_GL_CXXALIASWARN (ftello);
#elif defined GNULIB_POSIXCHECK
# define _GL_FTELL_WARN /* Category 1, above. */
# undef ftell
@@ -516,7 +533,9 @@ _GL_FUNCDECL_SYS (getline, ssize_t,
_GL_CXXALIAS_SYS (getline, ssize_t,
(char **lineptr, size_t *linesize, FILE *stream));
# endif
+# if @HAVE_DECL_GETLINE@
_GL_CXXALIASWARN (getline);
+# endif
#elif defined GNULIB_POSIXCHECK
# undef getline
# if HAVE_RAW_DECL_GETLINE
@@ -819,6 +838,25 @@ _GL_WARN_ON_USE (sprintf, "sprintf is not always POSIX compliant - "
"POSIX compliance");
#endif
+#if @GNULIB_TMPFILE@
+# if @REPLACE_TMPFILE@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define tmpfile rpl_tmpfile
+# endif
+_GL_FUNCDECL_RPL (tmpfile, FILE *, (void));
+_GL_CXXALIAS_RPL (tmpfile, FILE *, (void));
+# else
+_GL_CXXALIAS_SYS (tmpfile, FILE *, (void));
+# endif
+_GL_CXXALIASWARN (tmpfile);
+#elif defined GNULIB_POSIXCHECK
+# undef tmpfile
+# if HAVE_RAW_DECL_TMPFILE
+_GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - "
+ "use gnulib module tmpfile for portability");
+# endif
+#endif
+
#if @GNULIB_VASPRINTF@
/* Write formatted output to a string dynamically allocated with malloc().
If the memory allocation succeeds, store the address of the string in
@@ -883,7 +921,10 @@ _GL_FUNCDECL_SYS (vdprintf, int, (int fd, const char *format, va_list args)
__attribute__ ((__format__ (__printf__, 2, 0)))
_GL_ARG_NONNULL ((2)));
# endif
-_GL_CXXALIAS_SYS (vdprintf, int, (int fd, const char *format, va_list args));
+/* Need to cast, because on Solaris, the third parameter will likely be
+ __va_list args. */
+_GL_CXXALIAS_SYS_CAST (vdprintf, int,
+ (int fd, const char *format, va_list args));
# endif
_GL_CXXALIASWARN (vdprintf);
#elif defined GNULIB_POSIXCHECK
@@ -906,7 +947,11 @@ _GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args)
_GL_ARG_NONNULL ((1, 2)));
_GL_CXXALIAS_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args));
# else
-_GL_CXXALIAS_SYS (vfprintf, int, (FILE *fp, const char *format, va_list args));
+/* Need to cast, because on Solaris, the third parameter is
+ __va_list args
+ and GCC's fixincludes did not change this to __gnuc_va_list. */
+_GL_CXXALIAS_SYS_CAST (vfprintf, int,
+ (FILE *fp, const char *format, va_list args));
# endif
_GL_CXXALIASWARN (vfprintf);
#endif
@@ -932,7 +977,10 @@ _GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args)
_GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (vprintf, int, (const char *format, va_list args));
# else
-_GL_CXXALIAS_SYS (vprintf, int, (const char *format, va_list args));
+/* Need to cast, because on Solaris, the second parameter is
+ __va_list args
+ and GCC's fixincludes did not change this to __gnuc_va_list. */
+_GL_CXXALIAS_SYS_CAST (vprintf, int, (const char *format, va_list args));
# endif
_GL_CXXALIASWARN (vprintf);
#endif
@@ -988,8 +1036,11 @@ _GL_FUNCDECL_RPL (vsprintf, int,
_GL_CXXALIAS_RPL (vsprintf, int,
(char *str, const char *format, va_list args));
# else
-_GL_CXXALIAS_SYS (vsprintf, int,
- (char *str, const char *format, va_list args));
+/* Need to cast, because on Solaris, the third parameter is
+ __va_list args
+ and GCC's fixincludes did not change this to __gnuc_va_list. */
+_GL_CXXALIAS_SYS_CAST (vsprintf, int,
+ (char *str, const char *format, va_list args));
# endif
_GL_CXXALIASWARN (vsprintf);
#elif defined GNULIB_POSIXCHECK
diff --git a/gl/stdlib.in.h b/gl/stdlib.in.h
index 3a87245eb4..d74c2518ba 100644
--- a/gl/stdlib.in.h
+++ b/gl/stdlib.in.h
@@ -67,10 +67,10 @@ struct random_data
};
#endif
-#if (@GNULIB_MKSTEMP@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__
+#if (@GNULIB_MKSTEMP@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
/* On MacOS X 10.3, only <unistd.h> declares mkstemp. */
/* On Cygwin 1.7.1, only <unistd.h> declares getsubopt. */
-/* But avoid namespace pollution on glibc systems. */
+/* But avoid namespace pollution on glibc systems and native Windows. */
# include <unistd.h>
#endif
@@ -329,6 +329,9 @@ _GL_WARN_ON_USE (mkostemps, "mkostemps is unportable - "
_GL_FUNCDECL_RPL (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (mkstemp, int, (char * /*template*/));
# else
+# if ! @HAVE_MKSTEMP@
+_GL_FUNCDECL_SYS (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
+# endif
_GL_CXXALIAS_SYS (mkstemp, int, (char * /*template*/));
# endif
_GL_CXXALIASWARN (mkstemp);
diff --git a/gl/string.in.h b/gl/string.in.h
index de4e6d3596..13c0f09520 100644
--- a/gl/string.in.h
+++ b/gl/string.in.h
@@ -66,6 +66,11 @@ _GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n)
_GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n));
# else
+# if ! @HAVE_MEMCHR@
+_GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n)
+ __attribute__ ((__pure__))
+ _GL_ARG_NONNULL ((1)));
+# endif
/* On some systems, this function is defined as an overloaded function:
extern "C" { const void * std::memchr (const void *, int, size_t); }
extern "C++" { void * std::memchr (void *, int, size_t); } */
@@ -222,7 +227,7 @@ _GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - "
/* Copy no more than N bytes of SRC to DST, returning a pointer past the
last non-NUL byte written into DST. */
#if @GNULIB_STPNCPY@
-# if ! @HAVE_STPNCPY@
+# if @REPLACE_STPNCPY@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define stpncpy rpl_stpncpy
# endif
@@ -234,6 +239,12 @@ _GL_CXXALIAS_RPL (stpncpy, char *,
(char *restrict __dst, char const *restrict __src,
size_t __n));
# else
+# if ! @HAVE_STPNCPY@
+_GL_FUNCDECL_SYS (stpncpy, char *,
+ (char *restrict __dst, char const *restrict __src,
+ size_t __n)
+ _GL_ARG_NONNULL ((1, 2)));
+# endif
_GL_CXXALIAS_SYS (stpncpy, char *,
(char *restrict __dst, char const *restrict __src,
size_t __n));
@@ -309,6 +320,28 @@ _GL_WARN_ON_USE (strdup, "strdup is unportable - "
# endif
#endif
+/* Append no more than N characters from SRC onto DEST. */
+#if @GNULIB_STRNCAT@
+# if @REPLACE_STRNCAT@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef strncat
+# define strncat rpl_strncat
+# endif
+_GL_FUNCDECL_RPL (strncat, char *, (char *dest, const char *src, size_t n)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (strncat, char *, (char *dest, const char *src, size_t n));
+# else
+_GL_CXXALIAS_SYS (strncat, char *, (char *dest, const char *src, size_t n));
+# endif
+_GL_CXXALIASWARN (strncat);
+#elif defined GNULIB_POSIXCHECK
+# undef strncat
+# if HAVE_RAW_DECL_STRNCAT
+_GL_WARN_ON_USE (strncat, "strncat is unportable - "
+ "use gnulib module strncat for portability");
+# endif
+#endif
+
/* Return a newly allocated copy of at most N bytes of STRING. */
#if @GNULIB_STRNDUP@
# if @REPLACE_STRNDUP@
@@ -339,12 +372,23 @@ _GL_WARN_ON_USE (strndup, "strndup is unportable - "
MAXLEN bytes. If no '\0' terminator is found in that many bytes,
return MAXLEN. */
#if @GNULIB_STRNLEN@
-# if ! @HAVE_DECL_STRNLEN@
+# if @REPLACE_STRNLEN@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef strnlen
+# define strnlen rpl_strnlen
+# endif
+_GL_FUNCDECL_RPL (strnlen, size_t, (char const *__string, size_t __maxlen)
+ __attribute__ ((__pure__))
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (strnlen, size_t, (char const *__string, size_t __maxlen));
+# else
+# if ! @HAVE_DECL_STRNLEN@
_GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)
__attribute__ ((__pure__))
_GL_ARG_NONNULL ((1)));
-# endif
+# endif
_GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen));
+# endif
_GL_CXXALIASWARN (strnlen);
#elif defined GNULIB_POSIXCHECK
# undef strnlen
diff --git a/gl/sys_socket.in.h b/gl/sys_socket.in.h
index 644abcc601..fc105e63da 100644
--- a/gl/sys_socket.in.h
+++ b/gl/sys_socket.in.h
@@ -183,13 +183,23 @@ rpl_fd_isset (SOCKET fd, fd_set * set)
/* Wrap everything else to use libc file descriptors for sockets. */
#if @HAVE_WINSOCK2_H@ && !defined _GL_UNISTD_H
-# undef close
-# define close close_used_without_including_unistd_h
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef close
+# define close close_used_without_including_unistd_h
+# else
+ _GL_WARN_ON_USE (close,
+ "close() used without including <unistd.h>");
+# endif
#endif
#if @HAVE_WINSOCK2_H@ && !defined _GL_UNISTD_H
-# undef gethostname
-# define gethostname gethostname_used_without_including_unistd_h
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef gethostname
+# define gethostname gethostname_used_without_including_unistd_h
+# else
+ _GL_WARN_ON_USE (gethostname,
+ "gethostname() used without including <unistd.h>");
+# endif
#endif
#if @GNULIB_SOCKET@
@@ -571,8 +581,13 @@ _GL_WARN_ON_USE (shutdown, "shutdown is not always POSIX compliant - "
#endif
#if @HAVE_WINSOCK2_H@
-# undef select
-# define select select_used_without_including_sys_select_h
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef select
+# define select select_used_without_including_sys_select_h
+# else
+ _GL_WARN_ON_USE (select,
+ "select() used without including <sys/select.h>");
+# endif
#endif
#if @GNULIB_ACCEPT4@
diff --git a/gl/sys_stat.in.h b/gl/sys_stat.in.h
index 568358aefb..dc7ef51171 100644
--- a/gl/sys_stat.in.h
+++ b/gl/sys_stat.in.h
@@ -56,7 +56,8 @@
/* Before doing "#define mkdir rpl_mkdir" below, we need to include all
headers that may declare mkdir(). */
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-# include <io.h>
+# include <io.h> /* mingw32, mingw64 */
+# include <direct.h> /* mingw64 */
#endif
#ifndef S_IFMT
@@ -390,7 +391,10 @@ _GL_WARN_ON_USE (futimens, "futimens is not portable - "
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define lchmod chmod
# endif
-_GL_CXXALIAS_RPL_1 (lchmod, chmod, int, (const char *filename, mode_t mode));
+/* Need to cast, because on mingw, the second parameter of chmod is
+ int mode. */
+_GL_CXXALIAS_RPL_CAST_1 (lchmod, chmod, int,
+ (const char *filename, mode_t mode));
# else
# if 0 /* assume already declared */
_GL_FUNCDECL_SYS (lchmod, int, (const char *filename, mode_t mode)
@@ -452,7 +456,8 @@ _GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
#else
/* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
Additionally, it declares _mkdir (and depending on compile flags, an
- alias mkdir), only in the nonstandard <io.h>, which is included above. */
+ alias mkdir), only in the nonstandard includes <direct.h> and <io.h>,
+ which are included above. */
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
static inline int
diff --git a/gl/sys_time.in.h b/gl/sys_time.in.h
index 0df8b0dc0d..c4c2eb5e87 100644
--- a/gl/sys_time.in.h
+++ b/gl/sys_time.in.h
@@ -18,12 +18,12 @@
/* Written by Paul Eggert. */
-#if defined _GL_SYS_TIME_H
-
#if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
#endif
+#if defined _GL_SYS_TIME_H
+
/* Simply delegate to the system's header, without adding anything. */
# if @HAVE_SYS_TIME_H@
# @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@
diff --git a/gl/tests/Makefile.am b/gl/tests/Makefile.am
index ae662e8066..7101e82ee9 100644
--- a/gl/tests/Makefile.am
+++ b/gl/tests/Makefile.am
@@ -12,7 +12,7 @@
AUTOMAKE_OPTIONS = 1.5 foreign
-SUBDIRS =
+SUBDIRS = .
TESTS =
XFAIL_TESTS =
TESTS_ENVIRONMENT =
diff --git a/gl/tests/ioctl.c b/gl/tests/ioctl.c
index 1d409c6712..91eb3be1b9 100644
--- a/gl/tests/ioctl.c
+++ b/gl/tests/ioctl.c
@@ -50,7 +50,7 @@ rpl_ioctl (int fd, int request, ... /* {void *,char *} arg */)
# include "w32sock.h"
int
-rpl_ioctl (int fd, int req, ...)
+ioctl (int fd, int req, ...)
{
void *buf;
va_list args;
diff --git a/gl/tests/sys_ioctl.in.h b/gl/tests/sys_ioctl.in.h
index 32dacd4b84..7ff04391be 100644
--- a/gl/tests/sys_ioctl.in.h
+++ b/gl/tests/sys_ioctl.in.h
@@ -44,7 +44,7 @@
/* Declare overridden functions. */
#if @GNULIB_IOCTL@
-# if @SYS_IOCTL_H_HAVE_WINSOCK2_H@ || @REPLACE_IOCTL@
+# if @REPLACE_IOCTL@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef ioctl
# define ioctl rpl_ioctl
@@ -54,8 +54,10 @@ _GL_FUNCDECL_RPL (ioctl, int,
_GL_CXXALIAS_RPL (ioctl, int,
(int fd, int request, ... /* {void *,char *} arg */));
# else
+# if @SYS_IOCTL_H_HAVE_WINSOCK2_H@ || 1
_GL_FUNCDECL_SYS (ioctl, int,
(int fd, int request, ... /* {void *,char *} arg */));
+# endif
_GL_CXXALIAS_SYS (ioctl, int,
(int fd, int request, ... /* {void *,char *} arg */));
# endif
diff --git a/gl/tests/test-vasnprintf.c b/gl/tests/test-vasnprintf.c
index e2831420b4..15401eb4ca 100644
--- a/gl/tests/test-vasnprintf.c
+++ b/gl/tests/test-vasnprintf.c
@@ -26,20 +26,8 @@
#include "macros.h"
-static char *
-my_asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...)
-{
- va_list args;
- char *ret;
-
- va_start (args, format);
- ret = vasnprintf (resultbuf, lengthp, format, args);
- va_end (args);
- return ret;
-}
-
static void
-test_vasnprintf ()
+test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
{
char buf[8];
int size;
@@ -73,39 +61,28 @@ test_vasnprintf ()
}
}
-static void
-test_asnprintf ()
+static char *
+my_asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...)
{
- char buf[8];
- int size;
+ va_list args;
+ char *ret;
- for (size = 0; size <= 8; size++)
- {
- size_t length = size;
- char *result = asnprintf (NULL, &length, "%d", 12345);
- ASSERT (result != NULL);
- ASSERT (strcmp (result, "12345") == 0);
- ASSERT (length == 5);
- free (result);
- }
+ va_start (args, format);
+ ret = vasnprintf (resultbuf, lengthp, format, args);
+ va_end (args);
+ return ret;
+}
- for (size = 0; size <= 8; size++)
- {
- size_t length;
- char *result;
+static void
+test_vasnprintf ()
+{
+ test_function (my_asnprintf);
+}
- memcpy (buf, "DEADBEEF", 8);
- length = size;
- result = asnprintf (buf, &length, "%d", 12345);
- ASSERT (result != NULL);
- ASSERT (strcmp (result, "12345") == 0);
- ASSERT (length == 5);
- if (size < 6)
- ASSERT (result != buf);
- ASSERT (memcmp (buf + size, "DEADBEEF" + size, 8 - size) == 0);
- if (result != buf)
- free (result);
- }
+static void
+test_asnprintf ()
+{
+ test_function (asnprintf);
}
int
diff --git a/gl/time.in.h b/gl/time.in.h
index bdae1492ae..8e364feb82 100644
--- a/gl/time.in.h
+++ b/gl/time.in.h
@@ -87,6 +87,11 @@ _GL_FUNCDECL_RPL (nanosleep, int,
_GL_CXXALIAS_RPL (nanosleep, int,
(struct timespec const *__rqtp, struct timespec *__rmtp));
# else
+# if ! @HAVE_NANOSLEEP@
+_GL_FUNCDECL_SYS (nanosleep, int,
+ (struct timespec const *__rqtp, struct timespec *__rmtp)
+ _GL_ARG_NONNULL ((1)));
+# endif
_GL_CXXALIAS_SYS (nanosleep, int,
(struct timespec const *__rqtp, struct timespec *__rmtp));
# endif
@@ -122,6 +127,11 @@ _GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
_GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
struct tm *restrict __result));
# else
+# if ! @HAVE_LOCALTIME_R@
+_GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
+ struct tm *restrict __result)
+ _GL_ARG_NONNULL ((1, 2)));
+# endif
_GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
struct tm *restrict __result));
# endif
@@ -137,6 +147,11 @@ _GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
_GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
struct tm *restrict __result));
# else
+# if ! @HAVE_LOCALTIME_R@
+_GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
+ struct tm *restrict __result)
+ _GL_ARG_NONNULL ((1, 2)));
+# endif
_GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
struct tm *restrict __result));
# endif
@@ -147,23 +162,15 @@ _GL_CXXALIASWARN (gmtime_r);
the resulting broken-down time into TM. See
<http://www.opengroup.org/susv3xsh/strptime.html>. */
# if @GNULIB_STRPTIME@
-# if @REPLACE_STRPTIME@
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# undef strptime
-# define strptime rpl_strptime
-# endif
-_GL_FUNCDECL_RPL (strptime, char *, (char const *restrict __buf,
+# if ! @HAVE_STRPTIME@
+_GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf,
char const *restrict __format,
struct tm *restrict __tm)
_GL_ARG_NONNULL ((1, 2, 3)));
-_GL_CXXALIAS_RPL (strptime, char *, (char const *restrict __buf,
- char const *restrict __format,
- struct tm *restrict __tm));
-# else
+# endif
_GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
char const *restrict __format,
struct tm *restrict __tm));
-# endif
_GL_CXXALIASWARN (strptime);
# endif
@@ -177,6 +184,9 @@ _GL_CXXALIASWARN (strptime);
_GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm));
# else
+# if ! @HAVE_TIMEGM@
+_GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
+# endif
_GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm));
# endif
_GL_CXXALIASWARN (timegm);
diff --git a/gl/unistd.in.h b/gl/unistd.in.h
index 0c5c61687b..04d3a68fed 100644
--- a/gl/unistd.in.h
+++ b/gl/unistd.in.h
@@ -415,9 +415,8 @@ _GL_WARN_ON_USE (faccessat, "faccessat is not portable - "
Return 0 if successful, otherwise -1 and errno set.
See the POSIX:2001 specification
<http://www.opengroup.org/susv3xsh/fchdir.html>. */
-# if @REPLACE_FCHDIR@
-_GL_FUNCDECL_RPL (fchdir, int, (int /*fd*/));
-_GL_CXXALIAS_RPL (fchdir, int, (int /*fd*/));
+# if ! @HAVE_FCHDIR@
+_GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
/* Gnulib internal hooks needed to maintain the fchdir metadata. */
_GL_EXTERN_C int _gl_register_fd (int fd, const char *filename)
@@ -426,9 +425,8 @@ _GL_EXTERN_C void _gl_unregister_fd (int fd);
_GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd);
_GL_EXTERN_C const char *_gl_directory_name (int fd);
-# else
-_GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/));
# endif
+_GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/));
_GL_CXXALIASWARN (fchdir);
#elif defined GNULIB_POSIXCHECK
# undef fchdir
@@ -525,7 +523,9 @@ _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
_GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size));
_GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size));
# else
-_GL_CXXALIAS_SYS (getcwd, char *, (char *buf, size_t size));
+/* Need to cast, because on mingw, the second parameter is
+ int size. */
+_GL_CXXALIAS_SYS_CAST (getcwd, char *, (char *buf, size_t size));
# endif
_GL_CXXALIASWARN (getcwd);
#elif defined GNULIB_POSIXCHECK
@@ -773,7 +773,9 @@ getpagesize ()
/* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */
_GL_CXXALIAS_SYS_CAST (getpagesize, int, (void));
# endif
+# if @HAVE_DECL_GETPAGESIZE@
_GL_CXXALIASWARN (getpagesize);
+# endif
#elif defined GNULIB_POSIXCHECK
# undef getpagesize
# if HAVE_RAW_DECL_GETPAGESIZE
@@ -1266,7 +1268,10 @@ _GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count)
_GL_ARG_NONNULL ((2)));
_GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count));
# else
-_GL_CXXALIAS_SYS (write, ssize_t, (int fd, const void *buf, size_t count));
+/* Need to cast, because on mingw, the third parameter is
+ unsigned int count
+ and the return type is 'int'. */
+_GL_CXXALIAS_SYS_CAST (write, ssize_t, (int fd, const void *buf, size_t count));
# endif
_GL_CXXALIASWARN (write);
#endif
diff --git a/gl/vasnprintf.c b/gl/vasnprintf.c
index 99d921e9c7..1ca8d534a0 100644
--- a/gl/vasnprintf.c
+++ b/gl/vasnprintf.c
@@ -148,8 +148,14 @@
# define USE_SNPRINTF 1
# if HAVE_DECL__SNWPRINTF
/* On Windows, the function swprintf() has a different signature than
- on Unix; we use the _snwprintf() function instead. */
-# define SNPRINTF _snwprintf
+ on Unix; we use the function _snwprintf() or - on mingw - snwprintf()
+ instead. The mingw function snwprintf() has fewer bugs than the
+ MSVCRT function _snwprintf(), so prefer that. */
+# if defined __MINGW32__
+# define SNPRINTF snwprintf
+# else
+# define SNPRINTF _snwprintf
+# endif
# else
/* Unix. */
# define SNPRINTF swprintf
@@ -167,8 +173,15 @@
# define USE_SNPRINTF 0
# endif
# if HAVE_DECL__SNPRINTF
- /* Windows. */
-# define SNPRINTF _snprintf
+ /* Windows. The mingw function snprintf() has fewer bugs than the MSVCRT
+ function _snprintf(), so prefer that. */
+# if defined __MINGW32__
+# define SNPRINTF snprintf
+ /* Here we need to call the native snprintf, not rpl_snprintf. */
+# undef snprintf
+# else
+# define SNPRINTF _snprintf
+# endif
# else
/* Unix. */
# define SNPRINTF snprintf
@@ -194,7 +207,7 @@
#undef remainder
#define remainder rem
-#if !USE_SNPRINTF && !WIDE_CHAR_VERSION
+#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99) && !WIDE_CHAR_VERSION
# if (HAVE_STRNLEN && !defined _AIX)
# define local_strnlen strnlen
# else
@@ -210,7 +223,7 @@ local_strnlen (const char *string, size_t maxlen)
# endif
#endif
-#if (!USE_SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && HAVE_WCHAR_T && (WIDE_CHAR_VERSION || DCHAR_IS_TCHAR)
+#if (((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99) && WIDE_CHAR_VERSION) || ((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && !WIDE_CHAR_VERSION && DCHAR_IS_TCHAR)) && HAVE_WCHAR_T
# if HAVE_WCSLEN
# define local_wcslen wcslen
# else
@@ -233,7 +246,7 @@ local_wcslen (const wchar_t *s)
# endif
#endif
-#if !USE_SNPRINTF && HAVE_WCHAR_T && WIDE_CHAR_VERSION
+#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99) && HAVE_WCHAR_T && WIDE_CHAR_VERSION
# if HAVE_WCSNLEN
# define local_wcsnlen wcsnlen
# else
@@ -1474,6 +1487,258 @@ is_borderline (const char *digits, size_t precision)
#endif
+#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99
+
+/* Use a different function name, to make it possible that the 'wchar_t'
+ parametrization and the 'char' parametrization get compiled in the same
+ translation unit. */
+# if WIDE_CHAR_VERSION
+# define MAX_ROOM_NEEDED wmax_room_needed
+# else
+# define MAX_ROOM_NEEDED max_room_needed
+# endif
+
+/* Returns the number of TCHAR_T units needed as temporary space for the result
+ of sprintf or SNPRINTF of a single conversion directive. */
+static inline size_t
+MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion,
+ arg_type type, int flags, size_t width, int has_precision,
+ size_t precision, int pad_ourselves)
+{
+ size_t tmp_length;
+
+ switch (conversion)
+ {
+ case 'd': case 'i': case 'u':
+# if HAVE_LONG_LONG_INT
+ if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
+ tmp_length =
+ (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
+ * 0.30103 /* binary -> decimal */
+ )
+ + 1; /* turn floor into ceil */
+ else
+# endif
+ if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
+ tmp_length =
+ (unsigned int) (sizeof (unsigned long) * CHAR_BIT
+ * 0.30103 /* binary -> decimal */
+ )
+ + 1; /* turn floor into ceil */
+ else
+ tmp_length =
+ (unsigned int) (sizeof (unsigned int) * CHAR_BIT
+ * 0.30103 /* binary -> decimal */
+ )
+ + 1; /* turn floor into ceil */
+ if (tmp_length < precision)
+ tmp_length = precision;
+ /* Multiply by 2, as an estimate for FLAG_GROUP. */
+ tmp_length = xsum (tmp_length, tmp_length);
+ /* Add 1, to account for a leading sign. */
+ tmp_length = xsum (tmp_length, 1);
+ break;
+
+ case 'o':
+# if HAVE_LONG_LONG_INT
+ if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
+ tmp_length =
+ (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
+ * 0.333334 /* binary -> octal */
+ )
+ + 1; /* turn floor into ceil */
+ else
+# endif
+ if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
+ tmp_length =
+ (unsigned int) (sizeof (unsigned long) * CHAR_BIT
+ * 0.333334 /* binary -> octal */
+ )
+ + 1; /* turn floor into ceil */
+ else
+ tmp_length =
+ (unsigned int) (sizeof (unsigned int) * CHAR_BIT
+ * 0.333334 /* binary -> octal */
+ )
+ + 1; /* turn floor into ceil */
+ if (tmp_length < precision)
+ tmp_length = precision;
+ /* Add 1, to account for a leading sign. */
+ tmp_length = xsum (tmp_length, 1);
+ break;
+
+ case 'x': case 'X':
+# if HAVE_LONG_LONG_INT
+ if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
+ tmp_length =
+ (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
+ * 0.25 /* binary -> hexadecimal */
+ )
+ + 1; /* turn floor into ceil */
+ else
+# endif
+ if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
+ tmp_length =
+ (unsigned int) (sizeof (unsigned long) * CHAR_BIT
+ * 0.25 /* binary -> hexadecimal */
+ )
+ + 1; /* turn floor into ceil */
+ else
+ tmp_length =
+ (unsigned int) (sizeof (unsigned int) * CHAR_BIT
+ * 0.25 /* binary -> hexadecimal */
+ )
+ + 1; /* turn floor into ceil */
+ if (tmp_length < precision)
+ tmp_length = precision;
+ /* Add 2, to account for a leading sign or alternate form. */
+ tmp_length = xsum (tmp_length, 2);
+ break;
+
+ case 'f': case 'F':
+ if (type == TYPE_LONGDOUBLE)
+ tmp_length =
+ (unsigned int) (LDBL_MAX_EXP
+ * 0.30103 /* binary -> decimal */
+ * 2 /* estimate for FLAG_GROUP */
+ )
+ + 1 /* turn floor into ceil */
+ + 10; /* sign, decimal point etc. */
+ else
+ tmp_length =
+ (unsigned int) (DBL_MAX_EXP
+ * 0.30103 /* binary -> decimal */
+ * 2 /* estimate for FLAG_GROUP */
+ )
+ + 1 /* turn floor into ceil */
+ + 10; /* sign, decimal point etc. */
+ tmp_length = xsum (tmp_length, precision);
+ break;
+
+ case 'e': case 'E': case 'g': case 'G':
+ tmp_length =
+ 12; /* sign, decimal point, exponent etc. */
+ tmp_length = xsum (tmp_length, precision);
+ break;
+
+ case 'a': case 'A':
+ if (type == TYPE_LONGDOUBLE)
+ tmp_length =
+ (unsigned int) (LDBL_DIG
+ * 0.831 /* decimal -> hexadecimal */
+ )
+ + 1; /* turn floor into ceil */
+ else
+ tmp_length =
+ (unsigned int) (DBL_DIG
+ * 0.831 /* decimal -> hexadecimal */
+ )
+ + 1; /* turn floor into ceil */
+ if (tmp_length < precision)
+ tmp_length = precision;
+ /* Account for sign, decimal point etc. */
+ tmp_length = xsum (tmp_length, 12);
+ break;
+
+ case 'c':
+# if HAVE_WINT_T && !WIDE_CHAR_VERSION
+ if (type == TYPE_WIDE_CHAR)
+ tmp_length = MB_CUR_MAX;
+ else
+# endif
+ tmp_length = 1;
+ break;
+
+ case 's':
+# if HAVE_WCHAR_T
+ if (type == TYPE_WIDE_STRING)
+ {
+# if WIDE_CHAR_VERSION
+ /* ISO C says about %ls in fwprintf:
+ "If the precision is not specified or is greater than the size
+ of the array, the array shall contain a null wide character."
+ So if there is a precision, we must not use wcslen. */
+ const wchar_t *arg = ap->arg[arg_index].a.a_wide_string;
+
+ if (has_precision)
+ tmp_length = local_wcsnlen (arg, precision);
+ else
+ tmp_length = local_wcslen (arg);
+# else
+ /* ISO C says about %ls in fprintf:
+ "If a precision is specified, no more than that many bytes are
+ written (including shift sequences, if any), and the array
+ shall contain a null wide character if, to equal the multibyte
+ character sequence length given by the precision, the function
+ would need to access a wide character one past the end of the
+ array."
+ So if there is a precision, we must not use wcslen. */
+ /* This case has already been handled separately in VASNPRINTF. */
+ abort ();
+# endif
+ }
+ else
+# endif
+ {
+# if WIDE_CHAR_VERSION
+ /* ISO C says about %s in fwprintf:
+ "If the precision is not specified or is greater than the size
+ of the converted array, the converted array shall contain a
+ null wide character."
+ So if there is a precision, we must not use strlen. */
+ /* This case has already been handled separately in VASNPRINTF. */
+ abort ();
+# else
+ /* ISO C says about %s in fprintf:
+ "If the precision is not specified or greater than the size of
+ the array, the array shall contain a null character."
+ So if there is a precision, we must not use strlen. */
+ const char *arg = ap->arg[arg_index].a.a_string;
+
+ if (has_precision)
+ tmp_length = local_strnlen (arg, precision);
+ else
+ tmp_length = strlen (arg);
+# endif
+ }
+ break;
+
+ case 'p':
+ tmp_length =
+ (unsigned int) (sizeof (void *) * CHAR_BIT
+ * 0.25 /* binary -> hexadecimal */
+ )
+ + 1 /* turn floor into ceil */
+ + 2; /* account for leading 0x */
+ break;
+
+ default:
+ abort ();
+ }
+
+ if (!pad_ourselves)
+ {
+# if ENABLE_UNISTDIO
+ /* Padding considers the number of characters, therefore the number of
+ elements after padding may be
+ > max (tmp_length, width)
+ but is certainly
+ <= tmp_length + width. */
+ tmp_length = xsum (tmp_length, width);
+# else
+ /* Padding considers the number of elements, says POSIX. */
+ if (tmp_length < width)
+ tmp_length = width;
+# endif
+ }
+
+ tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */
+
+ return tmp_length;
+}
+
+#endif
+
DCHAR_T *
VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
const FCHAR_T *format, va_list args)
@@ -2103,7 +2368,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
}
}
#endif
-#if (!USE_SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && HAVE_WCHAR_T
+#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && HAVE_WCHAR_T
else if (dp->conversion == 's'
# if WIDE_CHAR_VERSION
&& a.arg[dp->arg_index].type != TYPE_WIDE_STRING
@@ -2592,8 +2857,16 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
count = wctomb (cbuf, *arg);
# endif
if (count <= 0)
- /* Inconsistency. */
- abort ();
+ {
+ /* Cannot convert. */
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ if (buf_malloced != NULL)
+ free (buf_malloced);
+ CLEANUP ();
+ errno = EILSEQ;
+ return NULL;
+ }
ENSURE_ALLOCATION (xsum (length, count));
memcpy (result + length, cbuf, count);
length += count;
@@ -4301,11 +4574,11 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
{
arg_type type = a.arg[dp->arg_index].type;
int flags = dp->flags;
-#if !USE_SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
+#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
int has_width;
size_t width;
#endif
-#if !USE_SNPRINTF || NEED_PRINTF_UNBOUNDED_PRECISION
+#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || NEED_PRINTF_UNBOUNDED_PRECISION
int has_precision;
size_t precision;
#endif
@@ -4330,7 +4603,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
TCHAR_T *tmp;
#endif
-#if !USE_SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
+#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
has_width = 0;
width = 0;
if (dp->width_start != dp->width_end)
@@ -4364,7 +4637,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
}
#endif
-#if !USE_SNPRINTF || NEED_PRINTF_UNBOUNDED_PRECISION
+#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || NEED_PRINTF_UNBOUNDED_PRECISION
has_precision = 0;
precision = 6;
if (dp->precision_start != dp->precision_end)
@@ -4437,246 +4710,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
#if !USE_SNPRINTF
/* Allocate a temporary buffer of sufficient size for calling
sprintf. */
- {
- switch (dp->conversion)
- {
-
- case 'd': case 'i': case 'u':
-# if HAVE_LONG_LONG_INT
- if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
- tmp_length =
- (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
- * 0.30103 /* binary -> decimal */
- )
- + 1; /* turn floor into ceil */
- else
-# endif
- if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
- tmp_length =
- (unsigned int) (sizeof (unsigned long) * CHAR_BIT
- * 0.30103 /* binary -> decimal */
- )
- + 1; /* turn floor into ceil */
- else
- tmp_length =
- (unsigned int) (sizeof (unsigned int) * CHAR_BIT
- * 0.30103 /* binary -> decimal */
- )
- + 1; /* turn floor into ceil */
- if (tmp_length < precision)
- tmp_length = precision;
- /* Multiply by 2, as an estimate for FLAG_GROUP. */
- tmp_length = xsum (tmp_length, tmp_length);
- /* Add 1, to account for a leading sign. */
- tmp_length = xsum (tmp_length, 1);
- break;
-
- case 'o':
-# if HAVE_LONG_LONG_INT
- if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
- tmp_length =
- (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
- * 0.333334 /* binary -> octal */
- )
- + 1; /* turn floor into ceil */
- else
-# endif
- if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
- tmp_length =
- (unsigned int) (sizeof (unsigned long) * CHAR_BIT
- * 0.333334 /* binary -> octal */
- )
- + 1; /* turn floor into ceil */
- else
- tmp_length =
- (unsigned int) (sizeof (unsigned int) * CHAR_BIT
- * 0.333334 /* binary -> octal */
- )
- + 1; /* turn floor into ceil */
- if (tmp_length < precision)
- tmp_length = precision;
- /* Add 1, to account for a leading sign. */
- tmp_length = xsum (tmp_length, 1);
- break;
-
- case 'x': case 'X':
-# if HAVE_LONG_LONG_INT
- if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
- tmp_length =
- (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
- * 0.25 /* binary -> hexadecimal */
- )
- + 1; /* turn floor into ceil */
- else
-# endif
- if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
- tmp_length =
- (unsigned int) (sizeof (unsigned long) * CHAR_BIT
- * 0.25 /* binary -> hexadecimal */
- )
- + 1; /* turn floor into ceil */
- else
- tmp_length =
- (unsigned int) (sizeof (unsigned int) * CHAR_BIT
- * 0.25 /* binary -> hexadecimal */
- )
- + 1; /* turn floor into ceil */
- if (tmp_length < precision)
- tmp_length = precision;
- /* Add 2, to account for a leading sign or alternate form. */
- tmp_length = xsum (tmp_length, 2);
- break;
-
- case 'f': case 'F':
- if (type == TYPE_LONGDOUBLE)
- tmp_length =
- (unsigned int) (LDBL_MAX_EXP
- * 0.30103 /* binary -> decimal */
- * 2 /* estimate for FLAG_GROUP */
- )
- + 1 /* turn floor into ceil */
- + 10; /* sign, decimal point etc. */
- else
- tmp_length =
- (unsigned int) (DBL_MAX_EXP
- * 0.30103 /* binary -> decimal */
- * 2 /* estimate for FLAG_GROUP */
- )
- + 1 /* turn floor into ceil */
- + 10; /* sign, decimal point etc. */
- tmp_length = xsum (tmp_length, precision);
- break;
-
- case 'e': case 'E': case 'g': case 'G':
- tmp_length =
- 12; /* sign, decimal point, exponent etc. */
- tmp_length = xsum (tmp_length, precision);
- break;
-
- case 'a': case 'A':
- if (type == TYPE_LONGDOUBLE)
- tmp_length =
- (unsigned int) (LDBL_DIG
- * 0.831 /* decimal -> hexadecimal */
- )
- + 1; /* turn floor into ceil */
- else
- tmp_length =
- (unsigned int) (DBL_DIG
- * 0.831 /* decimal -> hexadecimal */
- )
- + 1; /* turn floor into ceil */
- if (tmp_length < precision)
- tmp_length = precision;
- /* Account for sign, decimal point etc. */
- tmp_length = xsum (tmp_length, 12);
- break;
-
- case 'c':
-# if HAVE_WINT_T && !WIDE_CHAR_VERSION
- if (type == TYPE_WIDE_CHAR)
- tmp_length = MB_CUR_MAX;
- else
-# endif
- tmp_length = 1;
- break;
-
- case 's':
-# if HAVE_WCHAR_T
- if (type == TYPE_WIDE_STRING)
- {
-# if WIDE_CHAR_VERSION
- /* ISO C says about %ls in fwprintf:
- "If the precision is not specified or is greater
- than the size of the array, the array shall
- contain a null wide character."
- So if there is a precision, we must not use
- wcslen. */
- const wchar_t *arg =
- a.arg[dp->arg_index].a.a_wide_string;
-
- if (has_precision)
- tmp_length = local_wcsnlen (arg, precision);
- else
- tmp_length = local_wcslen (arg);
-# else
- /* ISO C says about %ls in fprintf:
- "If a precision is specified, no more than that
- many bytes are written (including shift
- sequences, if any), and the array shall contain
- a null wide character if, to equal the
- multibyte character sequence length given by
- the precision, the function would need to
- access a wide character one past the end of the
- array."
- So if there is a precision, we must not use
- wcslen. */
- /* This case has already been handled above. */
- abort ();
-# endif
- }
- else
-# endif
- {
-# if WIDE_CHAR_VERSION
- /* ISO C says about %s in fwprintf:
- "If the precision is not specified or is greater
- than the size of the converted array, the
- converted array shall contain a null wide
- character."
- So if there is a precision, we must not use
- strlen. */
- /* This case has already been handled above. */
- abort ();
-# else
- /* ISO C says about %s in fprintf:
- "If the precision is not specified or greater
- than the size of the array, the array shall
- contain a null character."
- So if there is a precision, we must not use
- strlen. */
- const char *arg = a.arg[dp->arg_index].a.a_string;
-
- if (has_precision)
- tmp_length = local_strnlen (arg, precision);
- else
- tmp_length = strlen (arg);
-# endif
- }
- break;
-
- case 'p':
- tmp_length =
- (unsigned int) (sizeof (void *) * CHAR_BIT
- * 0.25 /* binary -> hexadecimal */
- )
- + 1 /* turn floor into ceil */
- + 2; /* account for leading 0x */
- break;
-
- default:
- abort ();
- }
-
- if (!pad_ourselves)
- {
-# if ENABLE_UNISTDIO
- /* Padding considers the number of characters, therefore
- the number of elements after padding may be
- > max (tmp_length, width)
- but is certainly
- <= tmp_length + width. */
- tmp_length = xsum (tmp_length, width);
-# else
- /* Padding considers the number of elements,
- says POSIX. */
- if (tmp_length < width)
- tmp_length = width;
-# endif
- }
-
- tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */
- }
+ tmp_length =
+ MAX_ROOM_NEEDED (&a, dp->arg_index, dp->conversion, type,
+ flags, width, has_precision, precision,
+ pad_ourselves);
if (tmp_length <= sizeof (tmpbuf) / sizeof (TCHAR_T))
tmp = tmpbuf;
@@ -5062,15 +5099,44 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
/* Look at the snprintf() return value. */
if (retcount < 0)
{
+# if !HAVE_SNPRINTF_RETVAL_C99
/* HP-UX 10.20 snprintf() is doubly deficient:
It doesn't understand the '%n' directive,
*and* it returns -1 (rather than the length
that would have been required) when the
- buffer is too small. */
- size_t bigger_need =
- xsum (xtimes (allocated, 2), 12);
- ENSURE_ALLOCATION (bigger_need);
- continue;
+ buffer is too small.
+ But a failure at this point can also come
+ from other reasons than a too small buffer,
+ such as an invalid wide string argument to
+ the %ls directive, or possibly an invalid
+ floating-point argument. */
+ size_t tmp_length =
+ MAX_ROOM_NEEDED (&a, dp->arg_index,
+ dp->conversion, type, flags,
+ width, has_precision,
+ precision, pad_ourselves);
+
+ if (maxlen < tmp_length)
+ {
+ /* Make more room. But try to do through
+ this reallocation only once. */
+ size_t bigger_need =
+ xsum (length,
+ xsum (tmp_length,
+ TCHARS_PER_DCHAR - 1)
+ / TCHARS_PER_DCHAR);
+ /* And always grow proportionally.
+ (There may be several arguments, each
+ needing a little more room than the
+ previous one.) */
+ size_t bigger_need2 =
+ xsum (xtimes (allocated, 2), 12);
+ if (bigger_need < bigger_need2)
+ bigger_need = bigger_need2;
+ ENSURE_ALLOCATION (bigger_need);
+ continue;
+ }
+# endif
}
else
count = retcount;
@@ -5086,7 +5152,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
if (buf_malloced != NULL)
free (buf_malloced);
CLEANUP ();
- errno = EINVAL;
+ errno =
+ (dp->conversion == 'c' || dp->conversion == 's'
+ ? EILSEQ
+ : EINVAL);
return NULL;
}
@@ -5473,6 +5542,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
}
}
+#undef MAX_ROOM_NEEDED
#undef TCHARS_PER_DCHAR
#undef SNPRINTF
#undef USE_SNPRINTF
diff --git a/gl/wchar.in.h b/gl/wchar.in.h
index 287204f6f7..dd41d35392 100644
--- a/gl/wchar.in.h
+++ b/gl/wchar.in.h
@@ -82,12 +82,16 @@
/* The definition of _GL_WARN_ON_USE is copied here. */
-/* Define wint_t. (Also done in wctype.in.h.) */
+/* Define wint_t and WEOF. (Also done in wctype.in.h.) */
#if !@HAVE_WINT_T@ && !defined wint_t
# define wint_t int
# ifndef WEOF
# define WEOF -1
# endif
+#else
+# ifndef WEOF
+# define WEOF ((wint_t) -1)
+# endif
#endif
diff --git a/guile/modules/gnutls/extra.scm b/guile/modules/gnutls/extra.scm
index 6f7c892bfc..35db12bab1 100644
--- a/guile/modules/gnutls/extra.scm
+++ b/guile/modules/gnutls/extra.scm
@@ -78,4 +78,3 @@
;;; mode: scheme
;;; coding: latin-1
;;; End:
-
diff --git a/guile/tests/x509-auth.scm b/guile/tests/x509-auth.scm
index 147ff666b5..8582fc1e4a 100644
--- a/guile/tests/x509-auth.scm
+++ b/guile/tests/x509-auth.scm
@@ -132,4 +132,3 @@
(exit 1)))
;;; arch-tag: 1f88f835-a5c8-4fd6-94b6-5a13571ba03d
-
diff --git a/guile/tests/x509-certificate.pem b/guile/tests/x509-certificate.pem
index 8891072581..f6f4bed1a4 100644
--- a/guile/tests/x509-certificate.pem
+++ b/guile/tests/x509-certificate.pem
@@ -30,4 +30,3 @@ CSqGSIb3DQEBBQOBgQCi/SI37DrGCeZhtGhU2AyZFaqskRoFt4zAb9UYaGZaYEh5
0VUZsA/Ol8jiiQTtiCokZswhSsn+2McZmcspKigsY2aEBrry+TGFWMnYu5j5kcwP
1nVuHxLRwLt2rIsjgkeSNdHr8XHKi9/Roz/Gj86OnBAHwPt8WHfHK+63cMX1WA==
-----END CERTIFICATE-----
-
diff --git a/lib/build-aux/c++defs.h b/lib/build-aux/c++defs.h
index 31b29c2261..7d710898ec 100644
--- a/lib/build-aux/c++defs.h
+++ b/lib/build-aux/c++defs.h
@@ -126,6 +126,24 @@
_GL_EXTERN_C int _gl_cxxalias_dummy
#endif
+/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
+ is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
+ except that the C function rpl_func may have a slightly different
+ declaration. A cast is used to silence the "invalid conversion" error
+ that would otherwise occur. */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
+ namespace GNULIB_NAMESPACE \
+ { \
+ rettype (*const func) parameters = \
+ reinterpret_cast<rettype(*)parameters>(::rpl_func); \
+ } \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#else
+# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
+ _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
/* _GL_CXXALIAS_SYS (func, rettype, parameters);
declares a C++ alias called GNULIB_NAMESPACE::func
that redirects to the system provided function func, if GNULIB_NAMESPACE
diff --git a/lib/build-aux/warn-on-use.h b/lib/build-aux/warn-on-use.h
index 1cd5062d0a..171e599163 100644
--- a/lib/build-aux/warn-on-use.h
+++ b/lib/build-aux/warn-on-use.h
@@ -67,7 +67,10 @@
/* A compiler attribute is available in gcc versions 4.3.0 and later. */
# define _GL_WARN_ON_USE(function, message) \
extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
-
+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
+/* Verify the existence of the function. */
+# define _GL_WARN_ON_USE(function, message) \
+extern __typeof__ (function) function
# else /* Unsupported. */
# define _GL_WARN_ON_USE(function, message) \
_GL_WARN_EXTERN_C int _gl_warn_on_use
@@ -85,6 +88,10 @@ _GL_WARN_EXTERN_C int _gl_warn_on_use
# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
extern rettype function parameters_and_attributes \
__attribute__ ((__warning__ (msg)))
+# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
+/* Verify the existence of the function. */
+# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
+extern rettype function parameters_and_attributes
# else /* Unsupported. */
# define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
_GL_WARN_EXTERN_C int _gl_warn_on_use
diff --git a/lib/ext_cert_type.h b/lib/ext_cert_type.h
index e515fdd593..f33cd27289 100644
--- a/lib/ext_cert_type.h
+++ b/lib/ext_cert_type.h
@@ -30,4 +30,3 @@ int _gnutls_cert_type_recv_params (gnutls_session_t session,
const opaque * data, size_t data_size);
int _gnutls_cert_type_send_params (gnutls_session_t session, opaque * data,
size_t);
-
diff --git a/lib/gl/Makefile.am b/lib/gl/Makefile.am
index 9e3b18d0b8..3944512c37 100644
--- a/lib/gl/Makefile.am
+++ b/lib/gl/Makefile.am
@@ -460,6 +460,7 @@ stdio.h: stdio.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
-e 's|@''GNULIB_SNPRINTF''@|$(GNULIB_SNPRINTF)|g' \
-e 's|@''GNULIB_SPRINTF_POSIX''@|$(GNULIB_SPRINTF_POSIX)|g' \
-e 's|@''GNULIB_STDIO_H_SIGPIPE''@|$(GNULIB_STDIO_H_SIGPIPE)|g' \
+ -e 's|@''GNULIB_TMPFILE''@|$(GNULIB_TMPFILE)|g' \
-e 's|@''GNULIB_VASPRINTF''@|$(GNULIB_VASPRINTF)|g' \
-e 's|@''GNULIB_VDPRINTF''@|$(GNULIB_VDPRINTF)|g' \
-e 's|@''GNULIB_VFPRINTF''@|$(GNULIB_VFPRINTF)|g' \
@@ -476,6 +477,8 @@ stdio.h: stdio.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
-e 's|@''HAVE_DECL_SNPRINTF''@|$(HAVE_DECL_SNPRINTF)|g' \
-e 's|@''HAVE_DECL_VSNPRINTF''@|$(HAVE_DECL_VSNPRINTF)|g' \
-e 's|@''HAVE_DPRINTF''@|$(HAVE_DPRINTF)|g' \
+ -e 's|@''HAVE_FSEEKO''@|$(HAVE_FSEEKO)|g' \
+ -e 's|@''HAVE_FTELLO''@|$(HAVE_FTELLO)|g' \
-e 's|@''HAVE_RENAMEAT''@|$(HAVE_RENAMEAT)|g' \
-e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \
-e 's|@''HAVE_VDPRINTF''@|$(HAVE_VDPRINTF)|g' \
@@ -502,6 +505,7 @@ stdio.h: stdio.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
-e 's|@''REPLACE_SNPRINTF''@|$(REPLACE_SNPRINTF)|g' \
-e 's|@''REPLACE_SPRINTF''@|$(REPLACE_SPRINTF)|g' \
-e 's|@''REPLACE_STDIO_WRITE_FUNCS''@|$(REPLACE_STDIO_WRITE_FUNCS)|g' \
+ -e 's|@''REPLACE_TMPFILE''@|$(REPLACE_TMPFILE)|g' \
-e 's|@''REPLACE_VASPRINTF''@|$(REPLACE_VASPRINTF)|g' \
-e 's|@''REPLACE_VDPRINTF''@|$(REPLACE_VDPRINTF)|g' \
-e 's|@''REPLACE_VFPRINTF''@|$(REPLACE_VFPRINTF)|g' \
@@ -567,6 +571,7 @@ stdlib.h: stdlib.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
-e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \
-e 's|@''HAVE_MKOSTEMP''@|$(HAVE_MKOSTEMP)|g' \
-e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \
+ -e 's|@''HAVE_MKSTEMP''@|$(HAVE_MKSTEMP)|g' \
-e 's|@''HAVE_MKSTEMPS''@|$(HAVE_MKSTEMPS)|g' \
-e 's|@''HAVE_PTSNAME''@|$(HAVE_PTSNAME)|g' \
-e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \
@@ -645,6 +650,7 @@ string.h: string.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
-e 's|@''GNULIB_STPNCPY''@|$(GNULIB_STPNCPY)|g' \
-e 's|@''GNULIB_STRCHRNUL''@|$(GNULIB_STRCHRNUL)|g' \
-e 's|@''GNULIB_STRDUP''@|$(GNULIB_STRDUP)|g' \
+ -e 's|@''GNULIB_STRNCAT''@|$(GNULIB_STRNCAT)|g' \
-e 's|@''GNULIB_STRNDUP''@|$(GNULIB_STRNDUP)|g' \
-e 's|@''GNULIB_STRNLEN''@|$(GNULIB_STRNLEN)|g' \
-e 's|@''GNULIB_STRPBRK''@|$(GNULIB_STRPBRK)|g' \
@@ -657,6 +663,7 @@ string.h: string.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
-e 's|@''GNULIB_STRVERSCMP''@|$(GNULIB_STRVERSCMP)|g' \
< $(srcdir)/string.in.h | \
sed -e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \
+ -e 's|@''HAVE_MEMCHR''@|$(HAVE_MEMCHR)|g' \
-e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \
-e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \
-e 's|@''HAVE_DECL_MEMRCHR''@|$(HAVE_DECL_MEMRCHR)|g' \
@@ -671,16 +678,18 @@ string.h: string.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
-e 's|@''HAVE_STRSEP''@|$(HAVE_STRSEP)|g' \
-e 's|@''HAVE_STRCASESTR''@|$(HAVE_STRCASESTR)|g' \
-e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \
- -e 's|@''HAVE_DECL_STRERROR''@|$(HAVE_DECL_STRERROR)|g' \
-e 's|@''HAVE_DECL_STRSIGNAL''@|$(HAVE_DECL_STRSIGNAL)|g' \
-e 's|@''HAVE_STRVERSCMP''@|$(HAVE_STRVERSCMP)|g' \
+ -e 's|@''REPLACE_STPNCPY''@|$(REPLACE_STPNCPY)|g' \
-e 's|@''REPLACE_MEMCHR''@|$(REPLACE_MEMCHR)|g' \
-e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \
-e 's|@''REPLACE_STRCASESTR''@|$(REPLACE_STRCASESTR)|g' \
-e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \
-e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \
-e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \
+ -e 's|@''REPLACE_STRNCAT''@|$(REPLACE_STRNCAT)|g' \
-e 's|@''REPLACE_STRNDUP''@|$(REPLACE_STRNDUP)|g' \
+ -e 's|@''REPLACE_STRNLEN''@|$(REPLACE_STRNLEN)|g' \
-e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \
-e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \
-e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \
@@ -853,10 +862,13 @@ time.h: time.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
-e 's|@''GNULIB_STRPTIME''@|$(GNULIB_STRPTIME)|g' \
-e 's|@''GNULIB_TIMEGM''@|$(GNULIB_TIMEGM)|g' \
-e 's|@''GNULIB_TIME_R''@|$(GNULIB_TIME_R)|g' \
+ -e 's|@''HAVE_LOCALTIME_R''@|$(HAVE_LOCALTIME_R)|g' \
+ -e 's|@''HAVE_NANOSLEEP''@|$(HAVE_NANOSLEEP)|g' \
+ -e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \
+ -e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \
-e 's|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \
-e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \
-e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \
- -e 's|@''REPLACE_STRPTIME''@|$(REPLACE_STRPTIME)|g' \
-e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \
-e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
-e 's|@''TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
@@ -939,6 +951,7 @@ unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
-e 's|@''HAVE_DUP3''@|$(HAVE_DUP3)|g' \
-e 's|@''HAVE_EUIDACCESS''@|$(HAVE_EUIDACCESS)|g' \
-e 's|@''HAVE_FACCESSAT''@|$(HAVE_FACCESSAT)|g' \
+ -e 's|@''HAVE_FCHDIR''@|$(HAVE_FCHDIR)|g' \
-e 's|@''HAVE_FCHOWNAT''@|$(HAVE_FCHOWNAT)|g' \
-e 's|@''HAVE_FSYNC''@|$(HAVE_FSYNC)|g' \
-e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \
@@ -963,6 +976,7 @@ unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
-e 's|@''HAVE_USLEEP''@|$(HAVE_USLEEP)|g' \
-e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \
-e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \
+ -e 's|@''HAVE_DECL_GETPAGESIZE''@|$(HAVE_DECL_GETPAGESIZE)|g' \
-e 's|@''HAVE_DECL_GETUSERSHELL''@|$(HAVE_DECL_GETUSERSHELL)|g' \
-e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \
-e 's|@''HAVE_SYS_PARAM_H''@|$(HAVE_SYS_PARAM_H)|g' \
@@ -970,7 +984,6 @@ unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
-e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \
-e 's|@''REPLACE_DUP''@|$(REPLACE_DUP)|g' \
-e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \
- -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \
-e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \
-e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \
-e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \
diff --git a/lib/gl/fseeko.c b/lib/gl/fseeko.c
index cca32a56d9..8e492c54be 100644
--- a/lib/gl/fseeko.c
+++ b/lib/gl/fseeko.c
@@ -25,14 +25,13 @@
#include "stdio-impl.h"
+int
+fseeko (FILE *fp, off_t offset, int whence)
#undef fseeko
#if !HAVE_FSEEKO
# undef fseek
# define fseeko fseek
#endif
-
-int
-rpl_fseeko (FILE *fp, off_t offset, int whence)
{
#if LSEEK_PIPE_BROKEN
/* mingw gives bogus answers rather than failure on non-seekable files. */
diff --git a/lib/gl/m4/fseeko.m4 b/lib/gl/m4/fseeko.m4
index 5f7f97729c..b97df53377 100644
--- a/lib/gl/m4/fseeko.m4
+++ b/lib/gl/m4/fseeko.m4
@@ -1,4 +1,4 @@
-# fseeko.m4 serial 7
+# fseeko.m4 serial 9
dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -7,9 +7,25 @@ dnl with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_FUNC_FSEEKO],
[
AC_REQUIRE([gl_STDIO_H_DEFAULTS])
- AC_REQUIRE([AC_PROG_CC])
+ AC_REQUIRE([gl_HAVE_FSEEKO])
AC_REQUIRE([gl_STDIN_LARGE_OFFSET])
+ if test $gl_cv_func_fseeko = no; then
+ HAVE_FSEEKO=0
+ gl_REPLACE_FSEEKO
+ else
+ if test $gl_cv_var_stdin_large_offset = no; then
+ gl_REPLACE_FSEEKO
+ fi
+ fi
+])
+
+dnl Tests whether fseeko is available.
+dnl Result is gl_cv_func_fseeko.
+AC_DEFUN([gl_HAVE_FSEEKO],
+[
+ AC_REQUIRE([AC_PROG_CC])
+
dnl Persuade glibc <stdio.h> to declare fseeko().
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
@@ -19,17 +35,16 @@ AC_DEFUN([gl_FUNC_FSEEKO],
]], [fseeko (stdin, 0, 0);])],
[gl_cv_func_fseeko=yes], [gl_cv_func_fseeko=no])
])
- if test $gl_cv_func_fseeko = no \
- || test $gl_cv_var_stdin_large_offset = no; then
- gl_REPLACE_FSEEKO
- fi
])
AC_DEFUN([gl_REPLACE_FSEEKO],
[
- AC_LIBOBJ([fseeko])
AC_REQUIRE([gl_STDIO_H_DEFAULTS])
- REPLACE_FSEEKO=1
+ AC_REQUIRE([gl_HAVE_FSEEKO])
+ if test $gl_cv_func_fseeko = yes; then
+ REPLACE_FSEEKO=1
+ fi
+ AC_LIBOBJ([fseeko])
dnl If we are also using the fseek module, then fseek needs replacing, too.
m4_ifdef([gl_REPLACE_FSEEK], [gl_REPLACE_FSEEK])
])
diff --git a/lib/gl/m4/gnulib-common.m4 b/lib/gl/m4/gnulib-common.m4
index 9cc519e765..54b251737c 100644
--- a/lib/gl/m4/gnulib-common.m4
+++ b/lib/gl/m4/gnulib-common.m4
@@ -1,4 +1,4 @@
-# gnulib-common.m4 serial 18
+# gnulib-common.m4 serial 19
dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -132,6 +132,7 @@ m4_ifdef([AC_PROG_MKDIR_P], [
# so that mixed use of GNU C and GNU C++ and mixed use of Sun C and Sun C++
# works.
# This definition can be removed once autoconf >= 2.62 can be assumed.
+m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.62]),[-1],[
AC_DEFUN([AC_C_RESTRICT],
[AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict],
[ac_cv_c_restrict=no
@@ -169,6 +170,7 @@ AC_DEFUN([AC_C_RESTRICT],
*) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;;
esac
])
+])
# gl_BIGENDIAN
# is like AC_C_BIGENDIAN, except that it can be AC_REQUIREd.
diff --git a/lib/gl/m4/gnulib-comp.m4 b/lib/gl/m4/gnulib-comp.m4
index 0e4423631a..d10ad29d13 100644
--- a/lib/gl/m4/gnulib-comp.m4
+++ b/lib/gl/m4/gnulib-comp.m4
@@ -114,6 +114,7 @@ AC_DEFUN([lgl_INIT],
[
AM_CONDITIONAL([GL_COND_LIBTOOL], [true])
gl_cond_libtool=true
+ gl_m4_base='gl/m4'
m4_pushdef([AC_LIBOBJ], m4_defn([lgl_LIBOBJ]))
m4_pushdef([AC_REPLACE_FUNCS], m4_defn([lgl_REPLACE_FUNCS]))
m4_pushdef([AC_LIBSOURCES], m4_defn([lgl_LIBSOURCES]))
diff --git a/lib/gl/m4/lib-link.m4 b/lib/gl/m4/lib-link.m4
index 90e1ac9170..c73bd8e3a4 100644
--- a/lib/gl/m4/lib-link.m4
+++ b/lib/gl/m4/lib-link.m4
@@ -1,4 +1,4 @@
-# lib-link.m4 serial 20 (gettext-0.18)
+# lib-link.m4 serial 21 (gettext-0.18)
dnl Copyright (C) 2001-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -74,7 +74,17 @@ AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
ac_save_LIBS="$LIBS"
- LIBS="$LIBS $LIB[]NAME"
+ dnl If $LIB[]NAME contains some -l options, add it to the end of LIBS,
+ dnl because these -l options might require -L options that are present in
+ dnl LIBS. -l options benefit only from the -L options listed before it.
+ dnl Otherwise, add it to the front of LIBS, because it may be a static
+ dnl library that depends on another static library that is present in LIBS.
+ dnl Static libraries benefit only from the static libraries listed after
+ dnl it.
+ case " $LIB[]NAME" in
+ *" -l"*) LIBS="$LIBS $LIB[]NAME" ;;
+ *) LIBS="$LIB[]NAME $LIBS" ;;
+ esac
AC_TRY_LINK([$3], [$4],
[ac_cv_lib[]Name=yes],
[ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])'])
diff --git a/lib/gl/m4/memchr.m4 b/lib/gl/m4/memchr.m4
index 94596ef959..ab773b8129 100644
--- a/lib/gl/m4/memchr.m4
+++ b/lib/gl/m4/memchr.m4
@@ -1,4 +1,4 @@
-# memchr.m4 serial 7
+# memchr.m4 serial 8
dnl Copyright (C) 2002-2004, 2009-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -13,12 +13,7 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
dnl These days, we assume memchr is present. But just in case...
AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
- AC_REPLACE_FUNCS([memchr])
- if test $ac_cv_func_memchr = no; then
- gl_PREREQ_MEMCHR
- REPLACE_MEMCHR=1
- fi
-
+ AC_CHECK_FUNCS_ONCE([memchr])
if test $ac_cv_func_memchr = yes; then
# Detect platform-specific bugs in some versions of glibc:
# memchr should not dereference anything with length 0
@@ -73,10 +68,14 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
[dnl Be pessimistic for now.
gl_cv_func_memchr_works="guessing no"])])
if test "$gl_cv_func_memchr_works" != yes; then
- gl_PREREQ_MEMCHR
REPLACE_MEMCHR=1
- AC_LIBOBJ([memchr])
fi
+ else
+ HAVE_MEMCHR=0
+ fi
+ if test $HAVE_MEMCHR = 0 || test $REPLACE_MEMCHR = 1; then
+ AC_LIBOBJ([memchr])
+ gl_PREREQ_MEMCHR
fi
])
diff --git a/lib/gl/m4/stdio_h.m4 b/lib/gl/m4/stdio_h.m4
index af56b1f9da..1d1d95e568 100644
--- a/lib/gl/m4/stdio_h.m4
+++ b/lib/gl/m4/stdio_h.m4
@@ -1,4 +1,4 @@
-# stdio_h.m4 serial 27
+# stdio_h.m4 serial 30
dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -37,7 +37,7 @@ AC_DEFUN([gl_STDIO_H],
dnl guaranteed by C89.
gl_WARN_ON_USE_PREPARE([[#include <stdio.h>
]], [dprintf fpurge fseeko ftello getdelim getline popen renameat
- snprintf vdprintf vsnprintf])
+ snprintf tmpfile vdprintf vsnprintf])
])
AC_DEFUN([gl_STDIO_MODULE_INDICATOR],
@@ -83,6 +83,7 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS],
GNULIB_SNPRINTF=0; AC_SUBST([GNULIB_SNPRINTF])
GNULIB_SPRINTF_POSIX=0; AC_SUBST([GNULIB_SPRINTF_POSIX])
GNULIB_STDIO_H_SIGPIPE=0; AC_SUBST([GNULIB_STDIO_H_SIGPIPE])
+ GNULIB_TMPFILE=0; AC_SUBST([GNULIB_TMPFILE])
GNULIB_VASPRINTF=0; AC_SUBST([GNULIB_VASPRINTF])
GNULIB_VDPRINTF=0; AC_SUBST([GNULIB_VDPRINTF])
GNULIB_VFPRINTF=0; AC_SUBST([GNULIB_VFPRINTF])
@@ -99,6 +100,8 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS],
HAVE_DECL_SNPRINTF=1; AC_SUBST([HAVE_DECL_SNPRINTF])
HAVE_DECL_VSNPRINTF=1; AC_SUBST([HAVE_DECL_VSNPRINTF])
HAVE_DPRINTF=1; AC_SUBST([HAVE_DPRINTF])
+ HAVE_FSEEKO=1; AC_SUBST([HAVE_FSEEKO])
+ HAVE_FTELLO=1; AC_SUBST([HAVE_FTELLO])
HAVE_RENAMEAT=1; AC_SUBST([HAVE_RENAMEAT])
HAVE_VASPRINTF=1; AC_SUBST([HAVE_VASPRINTF])
HAVE_VDPRINTF=1; AC_SUBST([HAVE_VDPRINTF])
@@ -125,6 +128,7 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS],
REPLACE_SNPRINTF=0; AC_SUBST([REPLACE_SNPRINTF])
REPLACE_SPRINTF=0; AC_SUBST([REPLACE_SPRINTF])
REPLACE_STDIO_WRITE_FUNCS=0; AC_SUBST([REPLACE_STDIO_WRITE_FUNCS])
+ REPLACE_TMPFILE=0; AC_SUBST([REPLACE_TMPFILE])
REPLACE_VASPRINTF=0; AC_SUBST([REPLACE_VASPRINTF])
REPLACE_VDPRINTF=0; AC_SUBST([REPLACE_VDPRINTF])
REPLACE_VFPRINTF=0; AC_SUBST([REPLACE_VFPRINTF])
diff --git a/lib/gl/m4/stdlib_h.m4 b/lib/gl/m4/stdlib_h.m4
index 4c5cca89ab..dd84796d2c 100644
--- a/lib/gl/m4/stdlib_h.m4
+++ b/lib/gl/m4/stdlib_h.m4
@@ -1,4 +1,4 @@
-# stdlib_h.m4 serial 27
+# stdlib_h.m4 serial 28
dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -85,6 +85,7 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
HAVE_MKDTEMP=1; AC_SUBST([HAVE_MKDTEMP])
HAVE_MKOSTEMP=1; AC_SUBST([HAVE_MKOSTEMP])
HAVE_MKOSTEMPS=1; AC_SUBST([HAVE_MKOSTEMPS])
+ HAVE_MKSTEMP=1; AC_SUBST([HAVE_MKSTEMP])
HAVE_MKSTEMPS=1; AC_SUBST([HAVE_MKSTEMPS])
HAVE_PTSNAME=1; AC_SUBST([HAVE_PTSNAME])
HAVE_RANDOM_R=1; AC_SUBST([HAVE_RANDOM_R])
diff --git a/lib/gl/m4/string_h.m4 b/lib/gl/m4/string_h.m4
index 9ceeea986a..1977aecf91 100644
--- a/lib/gl/m4/string_h.m4
+++ b/lib/gl/m4/string_h.m4
@@ -5,7 +5,7 @@
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
-# serial 13
+# serial 17
# Written by Paul Eggert.
@@ -26,8 +26,10 @@ AC_DEFUN([gl_HEADER_STRING_H_BODY],
dnl corresponding gnulib module is not in use, and which is not
dnl guaranteed by C89.
gl_WARN_ON_USE_PREPARE([[#include <string.h>
- ]], [memmem mempcpy memrchr rawmemchr stpcpy stpncpy strchrnul strdup
- strndup strnlen strpbrk strsep strcasestr strtok_r strsignal strverscmp])
+ ]],
+ [memmem mempcpy memrchr rawmemchr stpcpy stpncpy strchrnul strdup
+ strncat strndup strnlen strpbrk strsep strcasestr strtok_r strsignal
+ strverscmp])
])
AC_DEFUN([gl_STRING_MODULE_INDICATOR],
@@ -50,6 +52,7 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
GNULIB_STPNCPY=0; AC_SUBST([GNULIB_STPNCPY])
GNULIB_STRCHRNUL=0; AC_SUBST([GNULIB_STRCHRNUL])
GNULIB_STRDUP=0; AC_SUBST([GNULIB_STRDUP])
+ GNULIB_STRNCAT=0; AC_SUBST([GNULIB_STRNCAT])
GNULIB_STRNDUP=0; AC_SUBST([GNULIB_STRNDUP])
GNULIB_STRNLEN=0; AC_SUBST([GNULIB_STRNLEN])
GNULIB_STRPBRK=0; AC_SUBST([GNULIB_STRPBRK])
@@ -76,6 +79,7 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
GNULIB_STRVERSCMP=0; AC_SUBST([GNULIB_STRVERSCMP])
HAVE_MBSLEN=0; AC_SUBST([HAVE_MBSLEN])
dnl Assume proper GNU behavior unless another module says otherwise.
+ HAVE_MEMCHR=1; AC_SUBST([HAVE_MEMCHR])
HAVE_DECL_MEMMEM=1; AC_SUBST([HAVE_DECL_MEMMEM])
HAVE_MEMPCPY=1; AC_SUBST([HAVE_MEMPCPY])
HAVE_DECL_MEMRCHR=1; AC_SUBST([HAVE_DECL_MEMRCHR])
@@ -90,16 +94,18 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
HAVE_STRSEP=1; AC_SUBST([HAVE_STRSEP])
HAVE_STRCASESTR=1; AC_SUBST([HAVE_STRCASESTR])
HAVE_DECL_STRTOK_R=1; AC_SUBST([HAVE_DECL_STRTOK_R])
- HAVE_DECL_STRERROR=1; AC_SUBST([HAVE_DECL_STRERROR])
HAVE_DECL_STRSIGNAL=1; AC_SUBST([HAVE_DECL_STRSIGNAL])
HAVE_STRVERSCMP=1; AC_SUBST([HAVE_STRVERSCMP])
REPLACE_MEMCHR=0; AC_SUBST([REPLACE_MEMCHR])
REPLACE_MEMMEM=0; AC_SUBST([REPLACE_MEMMEM])
+ REPLACE_STPNCPY=0; AC_SUBST([REPLACE_STPNCPY])
REPLACE_STRDUP=0; AC_SUBST([REPLACE_STRDUP])
REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR])
REPLACE_STRCASESTR=0; AC_SUBST([REPLACE_STRCASESTR])
REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR])
+ REPLACE_STRNCAT=0; AC_SUBST([REPLACE_STRNCAT])
REPLACE_STRNDUP=0; AC_SUBST([REPLACE_STRNDUP])
+ REPLACE_STRNLEN=0; AC_SUBST([REPLACE_STRNLEN])
REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL])
REPLACE_STRTOK_R=0; AC_SUBST([REPLACE_STRTOK_R])
UNDEFINE_STRTOK_R=0; AC_SUBST([UNDEFINE_STRTOK_R])
diff --git a/lib/gl/m4/threadlib.m4 b/lib/gl/m4/threadlib.m4
index bba460e4bc..05cc4ffab9 100644
--- a/lib/gl/m4/threadlib.m4
+++ b/lib/gl/m4/threadlib.m4
@@ -1,4 +1,4 @@
-# threadlib.m4 serial 4 (gettext-0.18)
+# threadlib.m4 serial 5 (gettext-0.18)
dnl Copyright (C) 2005-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -107,11 +107,34 @@ AC_DEFUN([gl_THREADLIB_BODY],
LTLIBMULTITHREAD=
if test "$gl_use_threads" != no; then
dnl Check whether the compiler and linker support weak declarations.
- AC_MSG_CHECKING([whether imported symbols can be declared weak])
- gl_have_weak=no
- AC_TRY_LINK([extern void xyzzy ();
-#pragma weak xyzzy], [xyzzy();], [gl_have_weak=yes])
- AC_MSG_RESULT([$gl_have_weak])
+ AC_CACHE_CHECK([whether imported symbols can be declared weak],
+ [gl_cv_have_weak],
+ [gl_cv_have_weak=no
+ dnl First, test whether the compiler accepts it syntactically.
+ AC_TRY_LINK([extern void xyzzy ();
+#pragma weak xyzzy], [xyzzy();], [gl_cv_have_weak=maybe])
+ if test $gl_cv_have_weak = maybe; then
+ dnl Second, test whether it actually works. On Cygwin 1.7.2, with
+ dnl gcc 4.3, symbols declared weak always evaluate to the address 0.
+ AC_TRY_RUN([
+#include <stdio.h>
+#pragma weak fputs
+int main ()
+{
+ return (fputs == NULL);
+}], [gl_cv_have_weak=yes], [gl_cv_have_weak=no],
+ [dnl When cross-compiling, assume that only ELF platforms support
+ dnl weak symbols.
+ AC_EGREP_CPP([Extensible Linking Format],
+ [#ifdef __ELF__
+ Extensible Linking Format
+ #endif
+ ],
+ [gl_cv_have_weak="guessing yes"],
+ [gl_cv_have_weak="guessing no"])
+ ])
+ fi
+ ])
if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then
# On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that
# it groks <pthread.h>. It's added above, in gl_THREADLIB_EARLY_BODY.
@@ -165,7 +188,7 @@ AC_DEFUN([gl_THREADLIB_BODY],
AC_DEFINE([USE_POSIX_THREADS], [1],
[Define if the POSIX multithreading library can be used.])
if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then
- if test $gl_have_weak = yes; then
+ if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then
AC_DEFINE([USE_POSIX_THREADS_WEAK], [1],
[Define if references to the POSIX multithreading library should be made weak.])
LIBTHREAD=
@@ -193,7 +216,7 @@ AC_DEFUN([gl_THREADLIB_BODY],
LTLIBMULTITHREAD="$LTLIBTHREAD"
AC_DEFINE([USE_SOLARIS_THREADS], [1],
[Define if the old Solaris multithreading library can be used.])
- if test $gl_have_weak = yes; then
+ if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then
AC_DEFINE([USE_SOLARIS_THREADS_WEAK], [1],
[Define if references to the old Solaris multithreading library should be made weak.])
LIBTHREAD=
@@ -219,7 +242,7 @@ AC_DEFUN([gl_THREADLIB_BODY],
AC_DEFINE([USE_PTH_THREADS], [1],
[Define if the GNU Pth multithreading library can be used.])
if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then
- if test $gl_have_weak = yes; then
+ if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then
AC_DEFINE([USE_PTH_THREADS_WEAK], [1],
[Define if references to the GNU Pth multithreading library should be made weak.])
LIBTHREAD=
diff --git a/lib/gl/m4/time_h.m4 b/lib/gl/m4/time_h.m4
index f2e54f2a94..b88ba94da1 100644
--- a/lib/gl/m4/time_h.m4
+++ b/lib/gl/m4/time_h.m4
@@ -64,7 +64,7 @@ AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
AC_DEFUN([gl_TIME_MODULE_INDICATOR],
[
dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
- AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
+ AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
gl_MODULE_INDICATOR_SET_VARIABLE([$1])
dnl Define it also as a C macro, for the benefit of the unit tests.
gl_MODULE_INDICATOR_FOR_TESTS([$1])
@@ -77,12 +77,16 @@ AC_DEFUN([gl_HEADER_TIME_H_DEFAULTS],
GNULIB_STRPTIME=0; AC_SUBST([GNULIB_STRPTIME])
GNULIB_TIMEGM=0; AC_SUBST([GNULIB_TIMEGM])
GNULIB_TIME_R=0; AC_SUBST([GNULIB_TIME_R])
+ dnl Assume proper GNU behavior unless another module says otherwise.
+ HAVE_LOCALTIME_R=1; AC_SUBST([HAVE_LOCALTIME_R])
+ HAVE_NANOSLEEP=1; AC_SUBST([HAVE_NANOSLEEP])
+ HAVE_STRPTIME=1; AC_SUBST([HAVE_STRPTIME])
+ HAVE_TIMEGM=1; AC_SUBST([HAVE_TIMEGM])
dnl If another module says to replace or to not replace, do that.
dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK;
dnl this lets maintainers check for portability.
REPLACE_LOCALTIME_R=GNULIB_PORTCHECK; AC_SUBST([REPLACE_LOCALTIME_R])
REPLACE_MKTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_MKTIME])
REPLACE_NANOSLEEP=GNULIB_PORTCHECK; AC_SUBST([REPLACE_NANOSLEEP])
- REPLACE_STRPTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_STRPTIME])
REPLACE_TIMEGM=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TIMEGM])
])
diff --git a/lib/gl/m4/time_r.m4 b/lib/gl/m4/time_r.m4
index b5938e7963..9e82d39ffb 100644
--- a/lib/gl/m4/time_r.m4
+++ b/lib/gl/m4/time_r.m4
@@ -1,7 +1,6 @@
-dnl Reentrant time functions like localtime_r.
+dnl Reentrant time functions: localtime_r, gmtime_r.
-dnl Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010 Free Software Foundation,
-dnl Inc.
+dnl Copyright (C) 2003, 2006-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -10,29 +9,40 @@ dnl Written by Paul Eggert.
AC_DEFUN([gl_TIME_R],
[
- dnl Persuade glibc and Solaris <time.h> to declare localtime_r.
+ dnl Persuade glibc and Solaris <time.h> to declare localtime_r.
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
AC_REQUIRE([AC_C_RESTRICT])
- AC_CACHE_CHECK([whether localtime_r is compatible with its POSIX signature],
- [gl_cv_time_r_posix],
- [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
- [[#include <time.h>]],
- [[/* We don't need to append 'restrict's to the argument types,
- even though the POSIX signature has the 'restrict's,
- since C99 says they can't affect type compatibility. */
- struct tm * (*ptr) (time_t const *, struct tm *) = localtime_r;
- if (ptr) return 0;
- /* Check the return type is a pointer. On HP-UX 10 it is 'int'. */
- *localtime_r (0, 0);]])],
- [gl_cv_time_r_posix=yes],
- [gl_cv_time_r_posix=no])])
- if test $gl_cv_time_r_posix = yes; then
- REPLACE_LOCALTIME_R=0
+ AC_CHECK_FUNCS_ONCE([localtime_r])
+ if test $ac_cv_func_localtime_r = yes; then
+ AC_CACHE_CHECK([whether localtime_r is compatible with its POSIX signature],
+ [gl_cv_time_r_posix],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <time.h>]],
+ [[/* We don't need to append 'restrict's to the argument types,
+ even though the POSIX signature has the 'restrict's,
+ since C99 says they can't affect type compatibility. */
+ struct tm * (*ptr) (time_t const *, struct tm *) = localtime_r;
+ if (ptr) return 0;
+ /* Check the return type is a pointer.
+ On HP-UX 10 it is 'int'. */
+ *localtime_r (0, 0);]])
+ ],
+ [gl_cv_time_r_posix=yes],
+ [gl_cv_time_r_posix=no])
+ ])
+ if test $gl_cv_time_r_posix = yes; then
+ REPLACE_LOCALTIME_R=0
+ else
+ REPLACE_LOCALTIME_R=1
+ fi
else
- REPLACE_LOCALTIME_R=1
+ HAVE_LOCALTIME_R=0
+ fi
+ if test $HAVE_LOCALTIME_R = 0 || test $REPLACE_LOCALTIME_R = 1; then
AC_LIBOBJ([time_r])
gl_PREREQ_TIME_R
fi
diff --git a/lib/gl/m4/unistd_h.m4 b/lib/gl/m4/unistd_h.m4
index 789739dffa..8c2eec64a6 100644
--- a/lib/gl/m4/unistd_h.m4
+++ b/lib/gl/m4/unistd_h.m4
@@ -1,4 +1,4 @@
-# unistd_h.m4 serial 43
+# unistd_h.m4 serial 45
dnl Copyright (C) 2006-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -98,6 +98,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
HAVE_DUP3=1; AC_SUBST([HAVE_DUP3])
HAVE_EUIDACCESS=1; AC_SUBST([HAVE_EUIDACCESS])
HAVE_FACCESSAT=1; AC_SUBST([HAVE_FACCESSAT])
+ HAVE_FCHDIR=1; AC_SUBST([HAVE_FCHDIR])
HAVE_FCHOWNAT=1; AC_SUBST([HAVE_FCHOWNAT])
HAVE_FSYNC=1; AC_SUBST([HAVE_FSYNC])
HAVE_FTRUNCATE=1; AC_SUBST([HAVE_FTRUNCATE])
@@ -122,6 +123,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
HAVE_USLEEP=1; AC_SUBST([HAVE_USLEEP])
HAVE_DECL_ENVIRON=1; AC_SUBST([HAVE_DECL_ENVIRON])
HAVE_DECL_GETLOGIN_R=1; AC_SUBST([HAVE_DECL_GETLOGIN_R])
+ HAVE_DECL_GETPAGESIZE=1; AC_SUBST([HAVE_DECL_GETPAGESIZE])
HAVE_DECL_GETUSERSHELL=1; AC_SUBST([HAVE_DECL_GETUSERSHELL])
HAVE_OS_H=0; AC_SUBST([HAVE_OS_H])
HAVE_SYS_PARAM_H=0; AC_SUBST([HAVE_SYS_PARAM_H])
@@ -129,7 +131,6 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
REPLACE_CLOSE=0; AC_SUBST([REPLACE_CLOSE])
REPLACE_DUP=0; AC_SUBST([REPLACE_DUP])
REPLACE_DUP2=0; AC_SUBST([REPLACE_DUP2])
- REPLACE_FCHDIR=0; AC_SUBST([REPLACE_FCHDIR])
REPLACE_FCHOWNAT=0; AC_SUBST([REPLACE_FCHOWNAT])
REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD])
REPLACE_GETGROUPS=0; AC_SUBST([REPLACE_GETGROUPS])
diff --git a/lib/gl/m4/vasnprintf.m4 b/lib/gl/m4/vasnprintf.m4
index 50a20cca23..ebe3c52cde 100644
--- a/lib/gl/m4/vasnprintf.m4
+++ b/lib/gl/m4/vasnprintf.m4
@@ -1,4 +1,4 @@
-# vasnprintf.m4 serial 29
+# vasnprintf.m4 serial 31
dnl Copyright (C) 2002-2004, 2006-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -54,6 +54,7 @@ AC_DEFUN([gl_PREREQ_PRINTF_PARSE],
# Prerequisites of lib/vasnprintf.c.
AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF],
[
+ AC_REQUIRE([AC_C_INLINE])
AC_REQUIRE([AC_FUNC_ALLOCA])
AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
AC_REQUIRE([gt_TYPE_WCHAR_T])
@@ -62,6 +63,17 @@ AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF],
dnl Use the _snprintf function only if it is declared (because on NetBSD it
dnl is defined as a weak alias of snprintf; we prefer to use the latter).
AC_CHECK_DECLS([_snprintf], , , [#include <stdio.h>])
+ dnl We can avoid a lot of code by assuming that snprintf's return value
+ dnl conforms to ISO C99. So check that.
+ AC_REQUIRE([gl_SNPRINTF_RETVAL_C99])
+ case "$gl_cv_func_snprintf_retval_c99" in
+ *yes)
+ AC_DEFINE([HAVE_SNPRINTF_RETVAL_C99], [1],
+ [Define if the return value of the snprintf function is the number of
+ of bytes (excluding the terminating NUL) that would have been produced
+ if the buffer had been large enough.])
+ ;;
+ esac
])
# Extra prerequisites of lib/vasnprintf.c for supporting 'long double'
diff --git a/lib/gl/stdio-impl.h b/lib/gl/stdio-impl.h
index 63687797f1..7a64fa839c 100644
--- a/lib/gl/stdio-impl.h
+++ b/lib/gl/stdio-impl.h
@@ -1,5 +1,5 @@
/* Implementation details of FILE streams.
- Copyright (C) 2007-2010 Free Software Foundation, Inc.
+ Copyright (C) 2007-2008, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@@ -21,6 +21,11 @@
/* BSD stdio derived implementations. */
+#if defined __NetBSD__ /* NetBSD */
+/* Get __NetBSD_Version__. */
+# include <sys/param.h>
+#endif
+
#if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */
# if defined __DragonFly__ /* DragonFly */
@@ -50,7 +55,7 @@
# define fp_ fp
# endif
-# if defined __NetBSD__ || defined __OpenBSD__ /* NetBSD, OpenBSD */
+# if (defined __NetBSD__ && __NetBSD_Version__ >= 105270000) || defined __OpenBSD__ /* NetBSD >= 1.5ZA, OpenBSD */
/* See <http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup>
and <http://www.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdio/fileext.h?rev=HEAD&content-type=text/x-cvsweb-markup> */
struct __sfileext
@@ -59,7 +64,7 @@
/* More fields, not relevant here. */
};
# define fp_ub ((struct __sfileext *) fp->_ext._base)->_ub
-# else /* FreeBSD, DragonFly, MacOS X, Cygwin */
+# else /* FreeBSD, NetBSD <= 1.5Z, DragonFly, MacOS X, Cygwin */
# define fp_ub fp_->_ub
# endif
diff --git a/lib/gl/stdio.in.h b/lib/gl/stdio.in.h
index 0f6fdd5482..9cef601e07 100644
--- a/lib/gl/stdio.in.h
+++ b/lib/gl/stdio.in.h
@@ -322,30 +322,39 @@ _GL_CXXALIASWARN (fseek);
# undef fseek
# endif
# if @REPLACE_FSEEKO@
-/* Provide fseek, fseeko functions that are aware of a preceding
- fflush(), and which detect pipes. */
+/* Provide an fseeko function that is aware of a preceding fflush(), and which
+ detects pipes. */
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef fseeko
# define fseeko rpl_fseeko
# endif
_GL_FUNCDECL_RPL (fseeko, int, (FILE *fp, off_t offset, int whence)
_GL_ARG_NONNULL ((1)));
-# if !@GNULIB_FSEEK@
- /* In order to avoid that fseek gets defined as a macro here, the
- developer can request the 'fseek' module. */
-# undef fseek
-# define fseek rpl_fseek
+_GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence));
+# else
+# if ! @HAVE_FSEEKO@
+_GL_FUNCDECL_SYS (fseeko, int, (FILE *fp, off_t offset, int whence)
+ _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence));
+# endif
+_GL_CXXALIASWARN (fseeko);
+# if (@REPLACE_FSEEKO@ || !@HAVE_FSEEKO@) && !@GNULIB_FSEEK@
+ /* Provide an fseek function that is consistent with fseeko. */
+ /* In order to avoid that fseek gets defined as a macro here, the
+ developer can request the 'fseek' module. */
+# undef fseek
+# define fseek rpl_fseek
static inline int _GL_ARG_NONNULL ((1))
rpl_fseek (FILE *fp, long offset, int whence)
{
+# if @REPLACE_FSEEKO@
+ return rpl_fseeko (fp, offset, whence);
+# else
return fseeko (fp, offset, whence);
-}
# endif
-_GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence));
-# else
-_GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence));
+}
# endif
-_GL_CXXALIASWARN (fseeko);
#elif defined GNULIB_POSIXCHECK
# define _GL_FSEEK_WARN /* Category 1, above. */
# undef fseek
@@ -397,22 +406,30 @@ _GL_CXXALIASWARN (ftell);
# define ftello rpl_ftello
# endif
_GL_FUNCDECL_RPL (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1)));
-# if !@GNULIB_FTELL@
- /* In order to avoid that ftell gets defined as a macro here, the
- developer can request the 'ftell' module. */
-# undef ftell
-# define ftell rpl_ftell
+_GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp));
+# else
+# if ! @HAVE_FTELLO@
+_GL_FUNCDECL_SYS (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp));
+# endif
+_GL_CXXALIASWARN (ftello);
+# if (@REPLACE_FTELLO@ || !@HAVE_FTELLO@) && !@GNULIB_FTELL@
+ /* Provide an ftell function that is consistent with ftello. */
+ /* In order to avoid that ftell gets defined as a macro here, the
+ developer can request the 'ftell' module. */
+# undef ftell
+# define ftell rpl_ftell
static inline long _GL_ARG_NONNULL ((1))
rpl_ftell (FILE *f)
{
+# if @REPLACE_FTELLO@
+ return rpl_ftello (f);
+# else
return ftello (f);
-}
# endif
-_GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp));
-# else
-_GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp));
+}
# endif
-_GL_CXXALIASWARN (ftello);
#elif defined GNULIB_POSIXCHECK
# define _GL_FTELL_WARN /* Category 1, above. */
# undef ftell
@@ -516,7 +533,9 @@ _GL_FUNCDECL_SYS (getline, ssize_t,
_GL_CXXALIAS_SYS (getline, ssize_t,
(char **lineptr, size_t *linesize, FILE *stream));
# endif
+# if @HAVE_DECL_GETLINE@
_GL_CXXALIASWARN (getline);
+# endif
#elif defined GNULIB_POSIXCHECK
# undef getline
# if HAVE_RAW_DECL_GETLINE
@@ -819,6 +838,25 @@ _GL_WARN_ON_USE (sprintf, "sprintf is not always POSIX compliant - "
"POSIX compliance");
#endif
+#if @GNULIB_TMPFILE@
+# if @REPLACE_TMPFILE@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# define tmpfile rpl_tmpfile
+# endif
+_GL_FUNCDECL_RPL (tmpfile, FILE *, (void));
+_GL_CXXALIAS_RPL (tmpfile, FILE *, (void));
+# else
+_GL_CXXALIAS_SYS (tmpfile, FILE *, (void));
+# endif
+_GL_CXXALIASWARN (tmpfile);
+#elif defined GNULIB_POSIXCHECK
+# undef tmpfile
+# if HAVE_RAW_DECL_TMPFILE
+_GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - "
+ "use gnulib module tmpfile for portability");
+# endif
+#endif
+
#if @GNULIB_VASPRINTF@
/* Write formatted output to a string dynamically allocated with malloc().
If the memory allocation succeeds, store the address of the string in
@@ -883,7 +921,10 @@ _GL_FUNCDECL_SYS (vdprintf, int, (int fd, const char *format, va_list args)
__attribute__ ((__format__ (__printf__, 2, 0)))
_GL_ARG_NONNULL ((2)));
# endif
-_GL_CXXALIAS_SYS (vdprintf, int, (int fd, const char *format, va_list args));
+/* Need to cast, because on Solaris, the third parameter will likely be
+ __va_list args. */
+_GL_CXXALIAS_SYS_CAST (vdprintf, int,
+ (int fd, const char *format, va_list args));
# endif
_GL_CXXALIASWARN (vdprintf);
#elif defined GNULIB_POSIXCHECK
@@ -906,7 +947,11 @@ _GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args)
_GL_ARG_NONNULL ((1, 2)));
_GL_CXXALIAS_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args));
# else
-_GL_CXXALIAS_SYS (vfprintf, int, (FILE *fp, const char *format, va_list args));
+/* Need to cast, because on Solaris, the third parameter is
+ __va_list args
+ and GCC's fixincludes did not change this to __gnuc_va_list. */
+_GL_CXXALIAS_SYS_CAST (vfprintf, int,
+ (FILE *fp, const char *format, va_list args));
# endif
_GL_CXXALIASWARN (vfprintf);
#endif
@@ -932,7 +977,10 @@ _GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args)
_GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (vprintf, int, (const char *format, va_list args));
# else
-_GL_CXXALIAS_SYS (vprintf, int, (const char *format, va_list args));
+/* Need to cast, because on Solaris, the second parameter is
+ __va_list args
+ and GCC's fixincludes did not change this to __gnuc_va_list. */
+_GL_CXXALIAS_SYS_CAST (vprintf, int, (const char *format, va_list args));
# endif
_GL_CXXALIASWARN (vprintf);
#endif
@@ -988,8 +1036,11 @@ _GL_FUNCDECL_RPL (vsprintf, int,
_GL_CXXALIAS_RPL (vsprintf, int,
(char *str, const char *format, va_list args));
# else
-_GL_CXXALIAS_SYS (vsprintf, int,
- (char *str, const char *format, va_list args));
+/* Need to cast, because on Solaris, the third parameter is
+ __va_list args
+ and GCC's fixincludes did not change this to __gnuc_va_list. */
+_GL_CXXALIAS_SYS_CAST (vsprintf, int,
+ (char *str, const char *format, va_list args));
# endif
_GL_CXXALIASWARN (vsprintf);
#elif defined GNULIB_POSIXCHECK
diff --git a/lib/gl/stdlib.in.h b/lib/gl/stdlib.in.h
index d4365fc244..89af73265b 100644
--- a/lib/gl/stdlib.in.h
+++ b/lib/gl/stdlib.in.h
@@ -67,10 +67,10 @@ struct random_data
};
#endif
-#if (@GNULIB_MKSTEMP@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__
+#if (@GNULIB_MKSTEMP@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
/* On MacOS X 10.3, only <unistd.h> declares mkstemp. */
/* On Cygwin 1.7.1, only <unistd.h> declares getsubopt. */
-/* But avoid namespace pollution on glibc systems. */
+/* But avoid namespace pollution on glibc systems and native Windows. */
# include <unistd.h>
#endif
@@ -329,6 +329,9 @@ _GL_WARN_ON_USE (mkostemps, "mkostemps is unportable - "
_GL_FUNCDECL_RPL (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (mkstemp, int, (char * /*template*/));
# else
+# if ! @HAVE_MKSTEMP@
+_GL_FUNCDECL_SYS (mkstemp, int, (char * /*template*/) _GL_ARG_NONNULL ((1)));
+# endif
_GL_CXXALIAS_SYS (mkstemp, int, (char * /*template*/));
# endif
_GL_CXXALIASWARN (mkstemp);
diff --git a/lib/gl/string.in.h b/lib/gl/string.in.h
index 46d609d601..2ebe17f590 100644
--- a/lib/gl/string.in.h
+++ b/lib/gl/string.in.h
@@ -66,6 +66,11 @@ _GL_FUNCDECL_RPL (memchr, void *, (void const *__s, int __c, size_t __n)
_GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (memchr, void *, (void const *__s, int __c, size_t __n));
# else
+# if ! @HAVE_MEMCHR@
+_GL_FUNCDECL_SYS (memchr, void *, (void const *__s, int __c, size_t __n)
+ __attribute__ ((__pure__))
+ _GL_ARG_NONNULL ((1)));
+# endif
/* On some systems, this function is defined as an overloaded function:
extern "C" { const void * std::memchr (const void *, int, size_t); }
extern "C++" { void * std::memchr (void *, int, size_t); } */
@@ -222,7 +227,7 @@ _GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - "
/* Copy no more than N bytes of SRC to DST, returning a pointer past the
last non-NUL byte written into DST. */
#if @GNULIB_STPNCPY@
-# if ! @HAVE_STPNCPY@
+# if @REPLACE_STPNCPY@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define stpncpy rpl_stpncpy
# endif
@@ -234,6 +239,12 @@ _GL_CXXALIAS_RPL (stpncpy, char *,
(char *restrict __dst, char const *restrict __src,
size_t __n));
# else
+# if ! @HAVE_STPNCPY@
+_GL_FUNCDECL_SYS (stpncpy, char *,
+ (char *restrict __dst, char const *restrict __src,
+ size_t __n)
+ _GL_ARG_NONNULL ((1, 2)));
+# endif
_GL_CXXALIAS_SYS (stpncpy, char *,
(char *restrict __dst, char const *restrict __src,
size_t __n));
@@ -309,6 +320,28 @@ _GL_WARN_ON_USE (strdup, "strdup is unportable - "
# endif
#endif
+/* Append no more than N characters from SRC onto DEST. */
+#if @GNULIB_STRNCAT@
+# if @REPLACE_STRNCAT@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef strncat
+# define strncat rpl_strncat
+# endif
+_GL_FUNCDECL_RPL (strncat, char *, (char *dest, const char *src, size_t n)
+ _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (strncat, char *, (char *dest, const char *src, size_t n));
+# else
+_GL_CXXALIAS_SYS (strncat, char *, (char *dest, const char *src, size_t n));
+# endif
+_GL_CXXALIASWARN (strncat);
+#elif defined GNULIB_POSIXCHECK
+# undef strncat
+# if HAVE_RAW_DECL_STRNCAT
+_GL_WARN_ON_USE (strncat, "strncat is unportable - "
+ "use gnulib module strncat for portability");
+# endif
+#endif
+
/* Return a newly allocated copy of at most N bytes of STRING. */
#if @GNULIB_STRNDUP@
# if @REPLACE_STRNDUP@
@@ -339,12 +372,23 @@ _GL_WARN_ON_USE (strndup, "strndup is unportable - "
MAXLEN bytes. If no '\0' terminator is found in that many bytes,
return MAXLEN. */
#if @GNULIB_STRNLEN@
-# if ! @HAVE_DECL_STRNLEN@
+# if @REPLACE_STRNLEN@
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef strnlen
+# define strnlen rpl_strnlen
+# endif
+_GL_FUNCDECL_RPL (strnlen, size_t, (char const *__string, size_t __maxlen)
+ __attribute__ ((__pure__))
+ _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (strnlen, size_t, (char const *__string, size_t __maxlen));
+# else
+# if ! @HAVE_DECL_STRNLEN@
_GL_FUNCDECL_SYS (strnlen, size_t, (char const *__string, size_t __maxlen)
__attribute__ ((__pure__))
_GL_ARG_NONNULL ((1)));
-# endif
+# endif
_GL_CXXALIAS_SYS (strnlen, size_t, (char const *__string, size_t __maxlen));
+# endif
_GL_CXXALIASWARN (strnlen);
#elif defined GNULIB_POSIXCHECK
# undef strnlen
diff --git a/lib/gl/sys_socket.in.h b/lib/gl/sys_socket.in.h
index 3037dbdba8..b63b0c4f22 100644
--- a/lib/gl/sys_socket.in.h
+++ b/lib/gl/sys_socket.in.h
@@ -183,13 +183,23 @@ rpl_fd_isset (SOCKET fd, fd_set * set)
/* Wrap everything else to use libc file descriptors for sockets. */
#if @HAVE_WINSOCK2_H@ && !defined _GL_UNISTD_H
-# undef close
-# define close close_used_without_including_unistd_h
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef close
+# define close close_used_without_including_unistd_h
+# else
+ _GL_WARN_ON_USE (close,
+ "close() used without including <unistd.h>");
+# endif
#endif
#if @HAVE_WINSOCK2_H@ && !defined _GL_UNISTD_H
-# undef gethostname
-# define gethostname gethostname_used_without_including_unistd_h
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef gethostname
+# define gethostname gethostname_used_without_including_unistd_h
+# else
+ _GL_WARN_ON_USE (gethostname,
+ "gethostname() used without including <unistd.h>");
+# endif
#endif
#if @GNULIB_SOCKET@
@@ -571,8 +581,13 @@ _GL_WARN_ON_USE (shutdown, "shutdown is not always POSIX compliant - "
#endif
#if @HAVE_WINSOCK2_H@
-# undef select
-# define select select_used_without_including_sys_select_h
+# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+# undef select
+# define select select_used_without_including_sys_select_h
+# else
+ _GL_WARN_ON_USE (select,
+ "select() used without including <sys/select.h>");
+# endif
#endif
#if @GNULIB_ACCEPT4@
diff --git a/lib/gl/sys_stat.in.h b/lib/gl/sys_stat.in.h
index ebfd4e592b..80b9c47ddf 100644
--- a/lib/gl/sys_stat.in.h
+++ b/lib/gl/sys_stat.in.h
@@ -56,7 +56,8 @@
/* Before doing "#define mkdir rpl_mkdir" below, we need to include all
headers that may declare mkdir(). */
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-# include <io.h>
+# include <io.h> /* mingw32, mingw64 */
+# include <direct.h> /* mingw64 */
#endif
#ifndef S_IFMT
@@ -390,7 +391,10 @@ _GL_WARN_ON_USE (futimens, "futimens is not portable - "
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# define lchmod chmod
# endif
-_GL_CXXALIAS_RPL_1 (lchmod, chmod, int, (const char *filename, mode_t mode));
+/* Need to cast, because on mingw, the second parameter of chmod is
+ int mode. */
+_GL_CXXALIAS_RPL_CAST_1 (lchmod, chmod, int,
+ (const char *filename, mode_t mode));
# else
# if 0 /* assume already declared */
_GL_FUNCDECL_SYS (lchmod, int, (const char *filename, mode_t mode)
@@ -452,7 +456,8 @@ _GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
#else
/* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
Additionally, it declares _mkdir (and depending on compile flags, an
- alias mkdir), only in the nonstandard <io.h>, which is included above. */
+ alias mkdir), only in the nonstandard includes <direct.h> and <io.h>,
+ which are included above. */
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
static inline int
diff --git a/lib/gl/tests/Makefile.am b/lib/gl/tests/Makefile.am
index a2d36fff91..1f010616dd 100644
--- a/lib/gl/tests/Makefile.am
+++ b/lib/gl/tests/Makefile.am
@@ -12,7 +12,7 @@
AUTOMAKE_OPTIONS = 1.5 foreign
-SUBDIRS =
+SUBDIRS = .
TESTS =
XFAIL_TESTS =
TESTS_ENVIRONMENT =
diff --git a/lib/gl/tests/test-vasnprintf.c b/lib/gl/tests/test-vasnprintf.c
index e2831420b4..15401eb4ca 100644
--- a/lib/gl/tests/test-vasnprintf.c
+++ b/lib/gl/tests/test-vasnprintf.c
@@ -26,20 +26,8 @@
#include "macros.h"
-static char *
-my_asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...)
-{
- va_list args;
- char *ret;
-
- va_start (args, format);
- ret = vasnprintf (resultbuf, lengthp, format, args);
- va_end (args);
- return ret;
-}
-
static void
-test_vasnprintf ()
+test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
{
char buf[8];
int size;
@@ -73,39 +61,28 @@ test_vasnprintf ()
}
}
-static void
-test_asnprintf ()
+static char *
+my_asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...)
{
- char buf[8];
- int size;
+ va_list args;
+ char *ret;
- for (size = 0; size <= 8; size++)
- {
- size_t length = size;
- char *result = asnprintf (NULL, &length, "%d", 12345);
- ASSERT (result != NULL);
- ASSERT (strcmp (result, "12345") == 0);
- ASSERT (length == 5);
- free (result);
- }
+ va_start (args, format);
+ ret = vasnprintf (resultbuf, lengthp, format, args);
+ va_end (args);
+ return ret;
+}
- for (size = 0; size <= 8; size++)
- {
- size_t length;
- char *result;
+static void
+test_vasnprintf ()
+{
+ test_function (my_asnprintf);
+}
- memcpy (buf, "DEADBEEF", 8);
- length = size;
- result = asnprintf (buf, &length, "%d", 12345);
- ASSERT (result != NULL);
- ASSERT (strcmp (result, "12345") == 0);
- ASSERT (length == 5);
- if (size < 6)
- ASSERT (result != buf);
- ASSERT (memcmp (buf + size, "DEADBEEF" + size, 8 - size) == 0);
- if (result != buf)
- free (result);
- }
+static void
+test_asnprintf ()
+{
+ test_function (asnprintf);
}
int
diff --git a/lib/gl/time.in.h b/lib/gl/time.in.h
index 457459f4b1..7e86161299 100644
--- a/lib/gl/time.in.h
+++ b/lib/gl/time.in.h
@@ -87,6 +87,11 @@ _GL_FUNCDECL_RPL (nanosleep, int,
_GL_CXXALIAS_RPL (nanosleep, int,
(struct timespec const *__rqtp, struct timespec *__rmtp));
# else
+# if ! @HAVE_NANOSLEEP@
+_GL_FUNCDECL_SYS (nanosleep, int,
+ (struct timespec const *__rqtp, struct timespec *__rmtp)
+ _GL_ARG_NONNULL ((1)));
+# endif
_GL_CXXALIAS_SYS (nanosleep, int,
(struct timespec const *__rqtp, struct timespec *__rmtp));
# endif
@@ -122,6 +127,11 @@ _GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
_GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
struct tm *restrict __result));
# else
+# if ! @HAVE_LOCALTIME_R@
+_GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
+ struct tm *restrict __result)
+ _GL_ARG_NONNULL ((1, 2)));
+# endif
_GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
struct tm *restrict __result));
# endif
@@ -137,6 +147,11 @@ _GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
_GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
struct tm *restrict __result));
# else
+# if ! @HAVE_LOCALTIME_R@
+_GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
+ struct tm *restrict __result)
+ _GL_ARG_NONNULL ((1, 2)));
+# endif
_GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
struct tm *restrict __result));
# endif
@@ -147,23 +162,15 @@ _GL_CXXALIASWARN (gmtime_r);
the resulting broken-down time into TM. See
<http://www.opengroup.org/susv3xsh/strptime.html>. */
# if @GNULIB_STRPTIME@
-# if @REPLACE_STRPTIME@
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# undef strptime
-# define strptime rpl_strptime
-# endif
-_GL_FUNCDECL_RPL (strptime, char *, (char const *restrict __buf,
+# if ! @HAVE_STRPTIME@
+_GL_FUNCDECL_SYS (strptime, char *, (char const *restrict __buf,
char const *restrict __format,
struct tm *restrict __tm)
_GL_ARG_NONNULL ((1, 2, 3)));
-_GL_CXXALIAS_RPL (strptime, char *, (char const *restrict __buf,
- char const *restrict __format,
- struct tm *restrict __tm));
-# else
+# endif
_GL_CXXALIAS_SYS (strptime, char *, (char const *restrict __buf,
char const *restrict __format,
struct tm *restrict __tm));
-# endif
_GL_CXXALIASWARN (strptime);
# endif
@@ -177,6 +184,9 @@ _GL_CXXALIASWARN (strptime);
_GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm));
# else
+# if ! @HAVE_TIMEGM@
+_GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
+# endif
_GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm));
# endif
_GL_CXXALIASWARN (timegm);
diff --git a/lib/gl/time_r.c b/lib/gl/time_r.c
index e5f57a917a..591bc02b23 100644
--- a/lib/gl/time_r.c
+++ b/lib/gl/time_r.c
@@ -1,6 +1,6 @@
/* Reentrant time functions like localtime_r.
- Copyright (C) 2003, 2006, 2007, 2009, 2010 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2006-2007, 2010 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@@ -22,8 +22,6 @@
#include <time.h>
-#include <string.h>
-
static struct tm *
copy_tm_result (struct tm *dest, struct tm const *src)
{
diff --git a/lib/gl/unistd.in.h b/lib/gl/unistd.in.h
index bb3c989376..e8997df577 100644
--- a/lib/gl/unistd.in.h
+++ b/lib/gl/unistd.in.h
@@ -415,9 +415,8 @@ _GL_WARN_ON_USE (faccessat, "faccessat is not portable - "
Return 0 if successful, otherwise -1 and errno set.
See the POSIX:2001 specification
<http://www.opengroup.org/susv3xsh/fchdir.html>. */
-# if @REPLACE_FCHDIR@
-_GL_FUNCDECL_RPL (fchdir, int, (int /*fd*/));
-_GL_CXXALIAS_RPL (fchdir, int, (int /*fd*/));
+# if ! @HAVE_FCHDIR@
+_GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
/* Gnulib internal hooks needed to maintain the fchdir metadata. */
_GL_EXTERN_C int _gl_register_fd (int fd, const char *filename)
@@ -426,9 +425,8 @@ _GL_EXTERN_C void _gl_unregister_fd (int fd);
_GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd);
_GL_EXTERN_C const char *_gl_directory_name (int fd);
-# else
-_GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/));
# endif
+_GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/));
_GL_CXXALIASWARN (fchdir);
#elif defined GNULIB_POSIXCHECK
# undef fchdir
@@ -525,7 +523,9 @@ _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
_GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size));
_GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size));
# else
-_GL_CXXALIAS_SYS (getcwd, char *, (char *buf, size_t size));
+/* Need to cast, because on mingw, the second parameter is
+ int size. */
+_GL_CXXALIAS_SYS_CAST (getcwd, char *, (char *buf, size_t size));
# endif
_GL_CXXALIASWARN (getcwd);
#elif defined GNULIB_POSIXCHECK
@@ -773,7 +773,9 @@ getpagesize ()
/* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */
_GL_CXXALIAS_SYS_CAST (getpagesize, int, (void));
# endif
+# if @HAVE_DECL_GETPAGESIZE@
_GL_CXXALIASWARN (getpagesize);
+# endif
#elif defined GNULIB_POSIXCHECK
# undef getpagesize
# if HAVE_RAW_DECL_GETPAGESIZE
@@ -1266,7 +1268,10 @@ _GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count)
_GL_ARG_NONNULL ((2)));
_GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count));
# else
-_GL_CXXALIAS_SYS (write, ssize_t, (int fd, const void *buf, size_t count));
+/* Need to cast, because on mingw, the third parameter is
+ unsigned int count
+ and the return type is 'int'. */
+_GL_CXXALIAS_SYS_CAST (write, ssize_t, (int fd, const void *buf, size_t count));
# endif
_GL_CXXALIASWARN (write);
#endif
diff --git a/lib/gl/vasnprintf.c b/lib/gl/vasnprintf.c
index ae238a87a6..056e0cdff7 100644
--- a/lib/gl/vasnprintf.c
+++ b/lib/gl/vasnprintf.c
@@ -148,8 +148,14 @@
# define USE_SNPRINTF 1
# if HAVE_DECL__SNWPRINTF
/* On Windows, the function swprintf() has a different signature than
- on Unix; we use the _snwprintf() function instead. */
-# define SNPRINTF _snwprintf
+ on Unix; we use the function _snwprintf() or - on mingw - snwprintf()
+ instead. The mingw function snwprintf() has fewer bugs than the
+ MSVCRT function _snwprintf(), so prefer that. */
+# if defined __MINGW32__
+# define SNPRINTF snwprintf
+# else
+# define SNPRINTF _snwprintf
+# endif
# else
/* Unix. */
# define SNPRINTF swprintf
@@ -167,8 +173,15 @@
# define USE_SNPRINTF 0
# endif
# if HAVE_DECL__SNPRINTF
- /* Windows. */
-# define SNPRINTF _snprintf
+ /* Windows. The mingw function snprintf() has fewer bugs than the MSVCRT
+ function _snprintf(), so prefer that. */
+# if defined __MINGW32__
+# define SNPRINTF snprintf
+ /* Here we need to call the native snprintf, not rpl_snprintf. */
+# undef snprintf
+# else
+# define SNPRINTF _snprintf
+# endif
# else
/* Unix. */
# define SNPRINTF snprintf
@@ -194,7 +207,7 @@
#undef remainder
#define remainder rem
-#if !USE_SNPRINTF && !WIDE_CHAR_VERSION
+#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99) && !WIDE_CHAR_VERSION
# if (HAVE_STRNLEN && !defined _AIX)
# define local_strnlen strnlen
# else
@@ -210,7 +223,7 @@ local_strnlen (const char *string, size_t maxlen)
# endif
#endif
-#if (!USE_SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && HAVE_WCHAR_T && (WIDE_CHAR_VERSION || DCHAR_IS_TCHAR)
+#if (((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99) && WIDE_CHAR_VERSION) || ((!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && !WIDE_CHAR_VERSION && DCHAR_IS_TCHAR)) && HAVE_WCHAR_T
# if HAVE_WCSLEN
# define local_wcslen wcslen
# else
@@ -233,7 +246,7 @@ local_wcslen (const wchar_t *s)
# endif
#endif
-#if !USE_SNPRINTF && HAVE_WCHAR_T && WIDE_CHAR_VERSION
+#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99) && HAVE_WCHAR_T && WIDE_CHAR_VERSION
# if HAVE_WCSNLEN
# define local_wcsnlen wcsnlen
# else
@@ -1474,6 +1487,258 @@ is_borderline (const char *digits, size_t precision)
#endif
+#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99
+
+/* Use a different function name, to make it possible that the 'wchar_t'
+ parametrization and the 'char' parametrization get compiled in the same
+ translation unit. */
+# if WIDE_CHAR_VERSION
+# define MAX_ROOM_NEEDED wmax_room_needed
+# else
+# define MAX_ROOM_NEEDED max_room_needed
+# endif
+
+/* Returns the number of TCHAR_T units needed as temporary space for the result
+ of sprintf or SNPRINTF of a single conversion directive. */
+static inline size_t
+MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion,
+ arg_type type, int flags, size_t width, int has_precision,
+ size_t precision, int pad_ourselves)
+{
+ size_t tmp_length;
+
+ switch (conversion)
+ {
+ case 'd': case 'i': case 'u':
+# if HAVE_LONG_LONG_INT
+ if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
+ tmp_length =
+ (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
+ * 0.30103 /* binary -> decimal */
+ )
+ + 1; /* turn floor into ceil */
+ else
+# endif
+ if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
+ tmp_length =
+ (unsigned int) (sizeof (unsigned long) * CHAR_BIT
+ * 0.30103 /* binary -> decimal */
+ )
+ + 1; /* turn floor into ceil */
+ else
+ tmp_length =
+ (unsigned int) (sizeof (unsigned int) * CHAR_BIT
+ * 0.30103 /* binary -> decimal */
+ )
+ + 1; /* turn floor into ceil */
+ if (tmp_length < precision)
+ tmp_length = precision;
+ /* Multiply by 2, as an estimate for FLAG_GROUP. */
+ tmp_length = xsum (tmp_length, tmp_length);
+ /* Add 1, to account for a leading sign. */
+ tmp_length = xsum (tmp_length, 1);
+ break;
+
+ case 'o':
+# if HAVE_LONG_LONG_INT
+ if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
+ tmp_length =
+ (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
+ * 0.333334 /* binary -> octal */
+ )
+ + 1; /* turn floor into ceil */
+ else
+# endif
+ if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
+ tmp_length =
+ (unsigned int) (sizeof (unsigned long) * CHAR_BIT
+ * 0.333334 /* binary -> octal */
+ )
+ + 1; /* turn floor into ceil */
+ else
+ tmp_length =
+ (unsigned int) (sizeof (unsigned int) * CHAR_BIT
+ * 0.333334 /* binary -> octal */
+ )
+ + 1; /* turn floor into ceil */
+ if (tmp_length < precision)
+ tmp_length = precision;
+ /* Add 1, to account for a leading sign. */
+ tmp_length = xsum (tmp_length, 1);
+ break;
+
+ case 'x': case 'X':
+# if HAVE_LONG_LONG_INT
+ if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
+ tmp_length =
+ (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
+ * 0.25 /* binary -> hexadecimal */
+ )
+ + 1; /* turn floor into ceil */
+ else
+# endif
+ if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
+ tmp_length =
+ (unsigned int) (sizeof (unsigned long) * CHAR_BIT
+ * 0.25 /* binary -> hexadecimal */
+ )
+ + 1; /* turn floor into ceil */
+ else
+ tmp_length =
+ (unsigned int) (sizeof (unsigned int) * CHAR_BIT
+ * 0.25 /* binary -> hexadecimal */
+ )
+ + 1; /* turn floor into ceil */
+ if (tmp_length < precision)
+ tmp_length = precision;
+ /* Add 2, to account for a leading sign or alternate form. */
+ tmp_length = xsum (tmp_length, 2);
+ break;
+
+ case 'f': case 'F':
+ if (type == TYPE_LONGDOUBLE)
+ tmp_length =
+ (unsigned int) (LDBL_MAX_EXP
+ * 0.30103 /* binary -> decimal */
+ * 2 /* estimate for FLAG_GROUP */
+ )
+ + 1 /* turn floor into ceil */
+ + 10; /* sign, decimal point etc. */
+ else
+ tmp_length =
+ (unsigned int) (DBL_MAX_EXP
+ * 0.30103 /* binary -> decimal */
+ * 2 /* estimate for FLAG_GROUP */
+ )
+ + 1 /* turn floor into ceil */
+ + 10; /* sign, decimal point etc. */
+ tmp_length = xsum (tmp_length, precision);
+ break;
+
+ case 'e': case 'E': case 'g': case 'G':
+ tmp_length =
+ 12; /* sign, decimal point, exponent etc. */
+ tmp_length = xsum (tmp_length, precision);
+ break;
+
+ case 'a': case 'A':
+ if (type == TYPE_LONGDOUBLE)
+ tmp_length =
+ (unsigned int) (LDBL_DIG
+ * 0.831 /* decimal -> hexadecimal */
+ )
+ + 1; /* turn floor into ceil */
+ else
+ tmp_length =
+ (unsigned int) (DBL_DIG
+ * 0.831 /* decimal -> hexadecimal */
+ )
+ + 1; /* turn floor into ceil */
+ if (tmp_length < precision)
+ tmp_length = precision;
+ /* Account for sign, decimal point etc. */
+ tmp_length = xsum (tmp_length, 12);
+ break;
+
+ case 'c':
+# if HAVE_WINT_T && !WIDE_CHAR_VERSION
+ if (type == TYPE_WIDE_CHAR)
+ tmp_length = MB_CUR_MAX;
+ else
+# endif
+ tmp_length = 1;
+ break;
+
+ case 's':
+# if HAVE_WCHAR_T
+ if (type == TYPE_WIDE_STRING)
+ {
+# if WIDE_CHAR_VERSION
+ /* ISO C says about %ls in fwprintf:
+ "If the precision is not specified or is greater than the size
+ of the array, the array shall contain a null wide character."
+ So if there is a precision, we must not use wcslen. */
+ const wchar_t *arg = ap->arg[arg_index].a.a_wide_string;
+
+ if (has_precision)
+ tmp_length = local_wcsnlen (arg, precision);
+ else
+ tmp_length = local_wcslen (arg);
+# else
+ /* ISO C says about %ls in fprintf:
+ "If a precision is specified, no more than that many bytes are
+ written (including shift sequences, if any), and the array
+ shall contain a null wide character if, to equal the multibyte
+ character sequence length given by the precision, the function
+ would need to access a wide character one past the end of the
+ array."
+ So if there is a precision, we must not use wcslen. */
+ /* This case has already been handled separately in VASNPRINTF. */
+ abort ();
+# endif
+ }
+ else
+# endif
+ {
+# if WIDE_CHAR_VERSION
+ /* ISO C says about %s in fwprintf:
+ "If the precision is not specified or is greater than the size
+ of the converted array, the converted array shall contain a
+ null wide character."
+ So if there is a precision, we must not use strlen. */
+ /* This case has already been handled separately in VASNPRINTF. */
+ abort ();
+# else
+ /* ISO C says about %s in fprintf:
+ "If the precision is not specified or greater than the size of
+ the array, the array shall contain a null character."
+ So if there is a precision, we must not use strlen. */
+ const char *arg = ap->arg[arg_index].a.a_string;
+
+ if (has_precision)
+ tmp_length = local_strnlen (arg, precision);
+ else
+ tmp_length = strlen (arg);
+# endif
+ }
+ break;
+
+ case 'p':
+ tmp_length =
+ (unsigned int) (sizeof (void *) * CHAR_BIT
+ * 0.25 /* binary -> hexadecimal */
+ )
+ + 1 /* turn floor into ceil */
+ + 2; /* account for leading 0x */
+ break;
+
+ default:
+ abort ();
+ }
+
+ if (!pad_ourselves)
+ {
+# if ENABLE_UNISTDIO
+ /* Padding considers the number of characters, therefore the number of
+ elements after padding may be
+ > max (tmp_length, width)
+ but is certainly
+ <= tmp_length + width. */
+ tmp_length = xsum (tmp_length, width);
+# else
+ /* Padding considers the number of elements, says POSIX. */
+ if (tmp_length < width)
+ tmp_length = width;
+# endif
+ }
+
+ tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */
+
+ return tmp_length;
+}
+
+#endif
+
DCHAR_T *
VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
const FCHAR_T *format, va_list args)
@@ -2103,7 +2368,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
}
}
#endif
-#if (!USE_SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && HAVE_WCHAR_T
+#if (!USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && HAVE_WCHAR_T
else if (dp->conversion == 's'
# if WIDE_CHAR_VERSION
&& a.arg[dp->arg_index].type != TYPE_WIDE_STRING
@@ -2592,8 +2857,16 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
count = wctomb (cbuf, *arg);
# endif
if (count <= 0)
- /* Inconsistency. */
- abort ();
+ {
+ /* Cannot convert. */
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ if (buf_malloced != NULL)
+ free (buf_malloced);
+ CLEANUP ();
+ errno = EILSEQ;
+ return NULL;
+ }
ENSURE_ALLOCATION (xsum (length, count));
memcpy (result + length, cbuf, count);
length += count;
@@ -4301,11 +4574,11 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
{
arg_type type = a.arg[dp->arg_index].type;
int flags = dp->flags;
-#if !USE_SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
+#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
int has_width;
size_t width;
#endif
-#if !USE_SNPRINTF || NEED_PRINTF_UNBOUNDED_PRECISION
+#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || NEED_PRINTF_UNBOUNDED_PRECISION
int has_precision;
size_t precision;
#endif
@@ -4330,7 +4603,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
TCHAR_T *tmp;
#endif
-#if !USE_SNPRINTF || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
+#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || !DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_LEFTADJUST || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION
has_width = 0;
width = 0;
if (dp->width_start != dp->width_end)
@@ -4364,7 +4637,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
}
#endif
-#if !USE_SNPRINTF || NEED_PRINTF_UNBOUNDED_PRECISION
+#if !USE_SNPRINTF || !HAVE_SNPRINTF_RETVAL_C99 || NEED_PRINTF_UNBOUNDED_PRECISION
has_precision = 0;
precision = 6;
if (dp->precision_start != dp->precision_end)
@@ -4437,246 +4710,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
#if !USE_SNPRINTF
/* Allocate a temporary buffer of sufficient size for calling
sprintf. */
- {
- switch (dp->conversion)
- {
-
- case 'd': case 'i': case 'u':
-# if HAVE_LONG_LONG_INT
- if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
- tmp_length =
- (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
- * 0.30103 /* binary -> decimal */
- )
- + 1; /* turn floor into ceil */
- else
-# endif
- if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
- tmp_length =
- (unsigned int) (sizeof (unsigned long) * CHAR_BIT
- * 0.30103 /* binary -> decimal */
- )
- + 1; /* turn floor into ceil */
- else
- tmp_length =
- (unsigned int) (sizeof (unsigned int) * CHAR_BIT
- * 0.30103 /* binary -> decimal */
- )
- + 1; /* turn floor into ceil */
- if (tmp_length < precision)
- tmp_length = precision;
- /* Multiply by 2, as an estimate for FLAG_GROUP. */
- tmp_length = xsum (tmp_length, tmp_length);
- /* Add 1, to account for a leading sign. */
- tmp_length = xsum (tmp_length, 1);
- break;
-
- case 'o':
-# if HAVE_LONG_LONG_INT
- if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
- tmp_length =
- (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
- * 0.333334 /* binary -> octal */
- )
- + 1; /* turn floor into ceil */
- else
-# endif
- if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
- tmp_length =
- (unsigned int) (sizeof (unsigned long) * CHAR_BIT
- * 0.333334 /* binary -> octal */
- )
- + 1; /* turn floor into ceil */
- else
- tmp_length =
- (unsigned int) (sizeof (unsigned int) * CHAR_BIT
- * 0.333334 /* binary -> octal */
- )
- + 1; /* turn floor into ceil */
- if (tmp_length < precision)
- tmp_length = precision;
- /* Add 1, to account for a leading sign. */
- tmp_length = xsum (tmp_length, 1);
- break;
-
- case 'x': case 'X':
-# if HAVE_LONG_LONG_INT
- if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
- tmp_length =
- (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
- * 0.25 /* binary -> hexadecimal */
- )
- + 1; /* turn floor into ceil */
- else
-# endif
- if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
- tmp_length =
- (unsigned int) (sizeof (unsigned long) * CHAR_BIT
- * 0.25 /* binary -> hexadecimal */
- )
- + 1; /* turn floor into ceil */
- else
- tmp_length =
- (unsigned int) (sizeof (unsigned int) * CHAR_BIT
- * 0.25 /* binary -> hexadecimal */
- )
- + 1; /* turn floor into ceil */
- if (tmp_length < precision)
- tmp_length = precision;
- /* Add 2, to account for a leading sign or alternate form. */
- tmp_length = xsum (tmp_length, 2);
- break;
-
- case 'f': case 'F':
- if (type == TYPE_LONGDOUBLE)
- tmp_length =
- (unsigned int) (LDBL_MAX_EXP
- * 0.30103 /* binary -> decimal */
- * 2 /* estimate for FLAG_GROUP */
- )
- + 1 /* turn floor into ceil */
- + 10; /* sign, decimal point etc. */
- else
- tmp_length =
- (unsigned int) (DBL_MAX_EXP
- * 0.30103 /* binary -> decimal */
- * 2 /* estimate for FLAG_GROUP */
- )
- + 1 /* turn floor into ceil */
- + 10; /* sign, decimal point etc. */
- tmp_length = xsum (tmp_length, precision);
- break;
-
- case 'e': case 'E': case 'g': case 'G':
- tmp_length =
- 12; /* sign, decimal point, exponent etc. */
- tmp_length = xsum (tmp_length, precision);
- break;
-
- case 'a': case 'A':
- if (type == TYPE_LONGDOUBLE)
- tmp_length =
- (unsigned int) (LDBL_DIG
- * 0.831 /* decimal -> hexadecimal */
- )
- + 1; /* turn floor into ceil */
- else
- tmp_length =
- (unsigned int) (DBL_DIG
- * 0.831 /* decimal -> hexadecimal */
- )
- + 1; /* turn floor into ceil */
- if (tmp_length < precision)
- tmp_length = precision;
- /* Account for sign, decimal point etc. */
- tmp_length = xsum (tmp_length, 12);
- break;
-
- case 'c':
-# if HAVE_WINT_T && !WIDE_CHAR_VERSION
- if (type == TYPE_WIDE_CHAR)
- tmp_length = MB_CUR_MAX;
- else
-# endif
- tmp_length = 1;
- break;
-
- case 's':
-# if HAVE_WCHAR_T
- if (type == TYPE_WIDE_STRING)
- {
-# if WIDE_CHAR_VERSION
- /* ISO C says about %ls in fwprintf:
- "If the precision is not specified or is greater
- than the size of the array, the array shall
- contain a null wide character."
- So if there is a precision, we must not use
- wcslen. */
- const wchar_t *arg =
- a.arg[dp->arg_index].a.a_wide_string;
-
- if (has_precision)
- tmp_length = local_wcsnlen (arg, precision);
- else
- tmp_length = local_wcslen (arg);
-# else
- /* ISO C says about %ls in fprintf:
- "If a precision is specified, no more than that
- many bytes are written (including shift
- sequences, if any), and the array shall contain
- a null wide character if, to equal the
- multibyte character sequence length given by
- the precision, the function would need to
- access a wide character one past the end of the
- array."
- So if there is a precision, we must not use
- wcslen. */
- /* This case has already been handled above. */
- abort ();
-# endif
- }
- else
-# endif
- {
-# if WIDE_CHAR_VERSION
- /* ISO C says about %s in fwprintf:
- "If the precision is not specified or is greater
- than the size of the converted array, the
- converted array shall contain a null wide
- character."
- So if there is a precision, we must not use
- strlen. */
- /* This case has already been handled above. */
- abort ();
-# else
- /* ISO C says about %s in fprintf:
- "If the precision is not specified or greater
- than the size of the array, the array shall
- contain a null character."
- So if there is a precision, we must not use
- strlen. */
- const char *arg = a.arg[dp->arg_index].a.a_string;
-
- if (has_precision)
- tmp_length = local_strnlen (arg, precision);
- else
- tmp_length = strlen (arg);
-# endif
- }
- break;
-
- case 'p':
- tmp_length =
- (unsigned int) (sizeof (void *) * CHAR_BIT
- * 0.25 /* binary -> hexadecimal */
- )
- + 1 /* turn floor into ceil */
- + 2; /* account for leading 0x */
- break;
-
- default:
- abort ();
- }
-
- if (!pad_ourselves)
- {
-# if ENABLE_UNISTDIO
- /* Padding considers the number of characters, therefore
- the number of elements after padding may be
- > max (tmp_length, width)
- but is certainly
- <= tmp_length + width. */
- tmp_length = xsum (tmp_length, width);
-# else
- /* Padding considers the number of elements,
- says POSIX. */
- if (tmp_length < width)
- tmp_length = width;
-# endif
- }
-
- tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */
- }
+ tmp_length =
+ MAX_ROOM_NEEDED (&a, dp->arg_index, dp->conversion, type,
+ flags, width, has_precision, precision,
+ pad_ourselves);
if (tmp_length <= sizeof (tmpbuf) / sizeof (TCHAR_T))
tmp = tmpbuf;
@@ -5062,15 +5099,44 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
/* Look at the snprintf() return value. */
if (retcount < 0)
{
+# if !HAVE_SNPRINTF_RETVAL_C99
/* HP-UX 10.20 snprintf() is doubly deficient:
It doesn't understand the '%n' directive,
*and* it returns -1 (rather than the length
that would have been required) when the
- buffer is too small. */
- size_t bigger_need =
- xsum (xtimes (allocated, 2), 12);
- ENSURE_ALLOCATION (bigger_need);
- continue;
+ buffer is too small.
+ But a failure at this point can also come
+ from other reasons than a too small buffer,
+ such as an invalid wide string argument to
+ the %ls directive, or possibly an invalid
+ floating-point argument. */
+ size_t tmp_length =
+ MAX_ROOM_NEEDED (&a, dp->arg_index,
+ dp->conversion, type, flags,
+ width, has_precision,
+ precision, pad_ourselves);
+
+ if (maxlen < tmp_length)
+ {
+ /* Make more room. But try to do through
+ this reallocation only once. */
+ size_t bigger_need =
+ xsum (length,
+ xsum (tmp_length,
+ TCHARS_PER_DCHAR - 1)
+ / TCHARS_PER_DCHAR);
+ /* And always grow proportionally.
+ (There may be several arguments, each
+ needing a little more room than the
+ previous one.) */
+ size_t bigger_need2 =
+ xsum (xtimes (allocated, 2), 12);
+ if (bigger_need < bigger_need2)
+ bigger_need = bigger_need2;
+ ENSURE_ALLOCATION (bigger_need);
+ continue;
+ }
+# endif
}
else
count = retcount;
@@ -5086,7 +5152,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
if (buf_malloced != NULL)
free (buf_malloced);
CLEANUP ();
- errno = EINVAL;
+ errno =
+ (dp->conversion == 'c' || dp->conversion == 's'
+ ? EILSEQ
+ : EINVAL);
return NULL;
}
@@ -5473,6 +5542,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
}
}
+#undef MAX_ROOM_NEEDED
#undef TCHARS_PER_DCHAR
#undef SNPRINTF
#undef USE_SNPRINTF
diff --git a/lib/gl/wchar.in.h b/lib/gl/wchar.in.h
index 3eeafd1a90..3369efa4a9 100644
--- a/lib/gl/wchar.in.h
+++ b/lib/gl/wchar.in.h
@@ -82,12 +82,16 @@
/* The definition of _GL_WARN_ON_USE is copied here. */
-/* Define wint_t. (Also done in wctype.in.h.) */
+/* Define wint_t and WEOF. (Also done in wctype.in.h.) */
#if !@HAVE_WINT_T@ && !defined wint_t
# define wint_t int
# ifndef WEOF
# define WEOF -1
# endif
+#else
+# ifndef WEOF
+# define WEOF ((wint_t) -1)
+# endif
#endif
diff --git a/lib/minitasn1/Makefile.am b/lib/minitasn1/Makefile.am
index e32783e5ac..9490d82235 100644
--- a/lib/minitasn1/Makefile.am
+++ b/lib/minitasn1/Makefile.am
@@ -31,5 +31,3 @@ noinst_LTLIBRARIES = libminitasn1.la
libminitasn1_la_SOURCES = libtasn1.h gstr.h int.h parser_aux.h \
structure.h element.h decoding.c gstr.c errors.c parser_aux.c \
structure.c element.c coding.c
-
-EXTRA_DIST = README
diff --git a/lib/minitasn1/README b/lib/minitasn1/README
deleted file mode 100644
index 9d484dfccc..0000000000
--- a/lib/minitasn1/README
+++ /dev/null
@@ -1,3 +0,0 @@
-This is just a mirror of the files in the libtasn1's
-lib/ directory.
-
diff --git a/lib/opencdk/keydb.h b/lib/opencdk/keydb.h
index 054d2c4a55..da043880dd 100644
--- a/lib/opencdk/keydb.h
+++ b/lib/opencdk/keydb.h
@@ -49,4 +49,3 @@ struct cdk_keydb_hd_s
size_t new_keys; /* amount of new keys that were imported. */
} stats;
};
-
diff --git a/lib/opencdk/packet.h b/lib/opencdk/packet.h
index ea3b147d9e..9120b22a62 100644
--- a/lib/opencdk/packet.h
+++ b/lib/opencdk/packet.h
@@ -46,4 +46,3 @@ cdk_error_t _cdk_copy_signature( cdk_pkt_signature_t* dst, cdk_pkt_signature_t s
cdk_error_t _cdk_pubkey_compare( cdk_pkt_pubkey_t a, cdk_pkt_pubkey_t b );
#endif /* CDK_PACKET_H */
-
diff --git a/libextra/gl/m4/gnulib-common.m4 b/libextra/gl/m4/gnulib-common.m4
index 9cc519e765..54b251737c 100644
--- a/libextra/gl/m4/gnulib-common.m4
+++ b/libextra/gl/m4/gnulib-common.m4
@@ -1,4 +1,4 @@
-# gnulib-common.m4 serial 18
+# gnulib-common.m4 serial 19
dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -132,6 +132,7 @@ m4_ifdef([AC_PROG_MKDIR_P], [
# so that mixed use of GNU C and GNU C++ and mixed use of Sun C and Sun C++
# works.
# This definition can be removed once autoconf >= 2.62 can be assumed.
+m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.62]),[-1],[
AC_DEFUN([AC_C_RESTRICT],
[AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict],
[ac_cv_c_restrict=no
@@ -169,6 +170,7 @@ AC_DEFUN([AC_C_RESTRICT],
*) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;;
esac
])
+])
# gl_BIGENDIAN
# is like AC_C_BIGENDIAN, except that it can be AC_REQUIREd.
diff --git a/libextra/gl/m4/gnulib-comp.m4 b/libextra/gl/m4/gnulib-comp.m4
index ad60507a17..b497cc3bd7 100644
--- a/libextra/gl/m4/gnulib-comp.m4
+++ b/libextra/gl/m4/gnulib-comp.m4
@@ -41,6 +41,7 @@ AC_DEFUN([xgl_INIT],
[
AM_CONDITIONAL([GL_COND_LIBTOOL], [true])
gl_cond_libtool=true
+ gl_m4_base='gl/m4'
m4_pushdef([AC_LIBOBJ], m4_defn([xgl_LIBOBJ]))
m4_pushdef([AC_REPLACE_FUNCS], m4_defn([xgl_REPLACE_FUNCS]))
m4_pushdef([AC_LIBSOURCES], m4_defn([xgl_LIBSOURCES]))
diff --git a/libextra/gl/m4/lib-link.m4 b/libextra/gl/m4/lib-link.m4
index 90e1ac9170..c73bd8e3a4 100644
--- a/libextra/gl/m4/lib-link.m4
+++ b/libextra/gl/m4/lib-link.m4
@@ -1,4 +1,4 @@
-# lib-link.m4 serial 20 (gettext-0.18)
+# lib-link.m4 serial 21 (gettext-0.18)
dnl Copyright (C) 2001-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -74,7 +74,17 @@ AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
ac_save_LIBS="$LIBS"
- LIBS="$LIBS $LIB[]NAME"
+ dnl If $LIB[]NAME contains some -l options, add it to the end of LIBS,
+ dnl because these -l options might require -L options that are present in
+ dnl LIBS. -l options benefit only from the -L options listed before it.
+ dnl Otherwise, add it to the front of LIBS, because it may be a static
+ dnl library that depends on another static library that is present in LIBS.
+ dnl Static libraries benefit only from the static libraries listed after
+ dnl it.
+ case " $LIB[]NAME" in
+ *" -l"*) LIBS="$LIBS $LIB[]NAME" ;;
+ *) LIBS="$LIB[]NAME $LIBS" ;;
+ esac
AC_TRY_LINK([$3], [$4],
[ac_cv_lib[]Name=yes],
[ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])'])
diff --git a/maint.mk b/maint.mk
index e121eb847b..6942730b76 100644
--- a/maint.mk
+++ b/maint.mk
@@ -129,8 +129,23 @@ sc_m_rules_ = $(patsubst %, %.m, $(syntax-check-rules))
.PHONY: $(sc_m_rules_)
$(sc_m_rules_):
@echo $(patsubst sc_%.m, %, $@)
-
-local-check := $(filter-out $(local-checks-to-skip), $(local-checks-available))
+ @date +%s.%N > .sc-start-$(basename $@)
+
+# Compute and print the elapsed time for each syntax-check rule.
+sc_z_rules_ = $(patsubst %, %.z, $(syntax-check-rules))
+.PHONY: $(sc_z_rules_)
+$(sc_z_rules_): %.z: %
+ @end=$$(date +%s.%N); \
+ start=$$(cat .sc-start-$*); \
+ rm -f .sc-start-$*; \
+ awk -v s=$$start -v e=$$end \
+ 'END {printf "%.2f $(patsubst sc_%,%,$*)\n", e - s}' < /dev/null
+
+# The patsubst here is to replace each sc_% rule with its sc_%.z wrapper
+# that computes and prints elapsed time.
+local-check := \
+ $(patsubst sc_%, sc_%.z, \
+ $(filter-out $(local-checks-to-skip), $(local-checks-available)))
syntax-check: $(local-check)
# @grep -nE '# *include <(limits|std(def|arg|bool))\.h>' \
@@ -144,19 +159,104 @@ syntax-check: $(local-check)
# exit 1; } || :
# FIXME: don't allow `#include .strings\.h' anywhere
-# By default, _prohibit_regexp does not ignore case.
+# _sc_search_regexp
+#
+# This macro searches for a given construct in the selected files and
+# then takes some action.
+#
+# Parameters (shell variables):
+#
+# prohibit | require
+#
+# Regular expression (ERE) denoting either a forbidden construct
+# or a required construct. Those arguments are exclusive.
+#
+# in_vc_files | in_files
+#
+# grep-E-style regexp denoting the files to check. If no files
+# are specified the default are all the files that are under
+# version control.
+#
+# containing | non_containing
+#
+# Select the files (non) containing strings matching this regexp.
+# If both arguments are specified then CONTAINING takes
+# precedence.
+#
+# with_grep_options
+#
+# Extra options for grep.
+#
+# ignore_case
+#
+# Ignore case.
+#
+# halt
+#
+# Message to display before to halting execution.
+
+# By default, _sc_search_regexp does not ignore case.
export ignore_case =
_ignore_case = $$(test -n "$$ignore_case" && echo -i || :)
-# There are many rules below that prohibit constructs in this package.
-# If the offending construct can be matched with a grep-E-style regexp,
-# use this macro. The shell variables "re" and "msg" must be defined.
-define _prohibit_regexp
- dummy=; : so we do not need a semicolon before each use; \
- test "x$$re" != x || { echo '$(ME): re not defined' 1>&2; exit 1; }; \
- test "x$$msg" != x || { echo '$(ME): msg not defined' 1>&2; exit 1; };\
- grep $(_ignore_case) -nE "$$re" $$($(VC_LIST_EXCEPT)) && \
- { echo '$(ME): '"$$msg" 1>&2; exit 1; } || :
+define _sc_say_and_exit
+ dummy=; : so we do not need a semicolon before each use; \
+ { echo -e "$(ME): $$msg" 1>&2; exit 1; };
+endef
+
+# _sc_search_regexp used to be named _prohibit_regexp. However,
+# upgrading to the new definition and leaving the old name undefined
+# would usually convert each custom rule using $(_prohibit_regexp)
+# (usually defined in cfg.mk) into a no-op. This definition ensures
+# that people know right away if they're still using the old name.
+# FIXME: remove in 2012.
+_prohibit_regexp = \
+ $(error '*** you need to s/_prohibit_regexp/_sc_search_regexp/, and adapt')
+
+define _sc_search_regexp
+ dummy=; : so we do not need a semicolon before each use; \
+ \
+ : Check arguments; \
+ test -n "$$prohibit" && test -n "$$require" \
+ && { msg='Cannot specify both prohibit and require' \
+ $(_sc_say_and_exit) } || :; \
+ test -z "$$prohibit" && test -z "$$require" \
+ && { msg='Should specify either prohibit or require' \
+ $(_sc_say_and_exit) } || :; \
+ test -n "$$in_vc_files" && test -n "$$in_files" \
+ && { msg='Cannot specify both in_vc_files and in_files' \
+ $(_sc_say_and_exit) } || :; \
+ test "x$$halt" != x \
+ || { msg='halt not defined' $(_sc_say_and_exit) }; \
+ \
+ : Filter by file name; \
+ if test -n "$$in_files"; then \
+ files=$$(find $(srcdir) | grep -E "$$in_files"); \
+ else \
+ files=$$($(VC_LIST_EXCEPT)); \
+ if test -n "$$in_vc_files"; then \
+ files=$$(echo "$$files" | grep -E "$$in_vc_files"); \
+ fi; \
+ fi; \
+ \
+ : Filter by content; \
+ test -n "$$files" && test -n "$$containing" \
+ && { files=$$(grep -l "$$containing" $$files); } || :; \
+ test -n "$$files" && test -n "$$non_containing" \
+ && { files=$$(grep -vl "$$non_containing" $$files); } || :; \
+ \
+ : Check for the construct; \
+ if test -n "$$files"; then \
+ if test -n "$$prohibit"; then \
+ grep $$with_grep_options $(_ignore_case) -nE "$$prohibit" $$files \
+ && { msg="$$halt" $(_sc_say_and_exit) } || :; \
+ else \
+ grep $$with_grep_options $(_ignore_case) -LE "$$require" $$files \
+ | grep . \
+ && { msg="$$halt" $(_sc_say_and_exit) } || :; \
+ fi \
+ else :; \
+ fi || :;
endef
sc_avoid_if_before_free:
@@ -167,29 +267,31 @@ sc_avoid_if_before_free:
exit 1; } || :
sc_cast_of_argument_to_free:
- @re='\<free *\( *\(' msg='don'\''t cast free argument' \
- $(_prohibit_regexp)
+ @prohibit='\<free *\( *\(' halt='don'\''t cast free argument' \
+ $(_sc_search_regexp)
sc_cast_of_x_alloc_return_value:
- @re='\*\) *x(m|c|re)alloc\>' \
- msg='don'\''t cast x*alloc return value' \
- $(_prohibit_regexp)
+ @prohibit='\*\) *x(m|c|re)alloc\>' \
+ halt='don'\''t cast x*alloc return value' \
+ $(_sc_search_regexp)
sc_cast_of_alloca_return_value:
- @re='\*\) *alloca\>' msg='don'\''t cast alloca return value' \
- $(_prohibit_regexp)
+ @prohibit='\*\) *alloca\>' \
+ halt='don'\''t cast alloca return value' \
+ $(_sc_search_regexp)
sc_space_tab:
- @re='[ ] ' msg='found SPACE-TAB sequence; remove the SPACE' \
- $(_prohibit_regexp)
+ @prohibit='[ ] ' \
+ halt='found SPACE-TAB sequence; remove the SPACE' \
+ $(_sc_search_regexp)
# Don't use *scanf or the old ato* functions in `real' code.
# They provide no error checking mechanism.
# Instead, use strto* functions.
sc_prohibit_atoi_atof:
- @re='\<([fs]?scanf|ato([filq]|ll)) *\(' \
- msg='do not use *scan''f, ato''f, ato''i, ato''l, ato''ll or ato''q' \
- $(_prohibit_regexp)
+ @prohibit='\<([fs]?scanf|ato([filq]|ll)) *\(' \
+ halt='do not use *scan''f, ato''f, ato''i, ato''l, ato''ll or ato''q' \
+ $(_sc_search_regexp)
# Use STREQ rather than comparing strcmp == 0, or != 0.
sc_prohibit_strcmp:
@@ -210,28 +312,29 @@ sc_prohibit_strcmp:
# | xargs --no-run-if-empty \
# perl -pi -e 's/(^|[^.])\b(exit ?)\(0\)/$1$2(EXIT_SUCCESS)/'
sc_prohibit_magic_number_exit:
- @re='(^|[^.])\<(usage|exit) ?\([0-9]|\<error ?\([1-9][0-9]*,' \
- msg='use EXIT_* values rather than magic number' \
- $(_prohibit_regexp)
+ @prohibit='(^|[^.])\<(usage|exit) ?\([0-9]|\<error ?\([1-9][0-9]*,' \
+ halt='use EXIT_* values rather than magic number' \
+ $(_sc_search_regexp)
# Using EXIT_SUCCESS as the first argument to error is misleading,
# since when that parameter is 0, error does not exit. Use `0' instead.
sc_error_exit_success:
- @grep -nE 'error \(EXIT_SUCCESS,' \
- $$($(VC_LIST_EXCEPT) | grep -E '\.[chly]$$') && \
- { echo '$(ME): found error (EXIT_SUCCESS' 1>&2; exit 1; } || :
+ @prohibit='error *\(EXIT_SUCCESS,' \
+ in_vc_files='\.[chly]$$' \
+ halt='found error (EXIT_SUCCESS' \
+ $(_sc_search_regexp)
# `FATAL:' should be fully upper-cased in error messages
# `WARNING:' should be fully upper-cased, or fully lower-cased
sc_error_message_warn_fatal:
- @grep -nEA2 '[^rp]error \(' $$($(VC_LIST_EXCEPT)) \
+ @grep -nEA2 '[^rp]error *\(' $$($(VC_LIST_EXCEPT)) \
| grep -E '"Warning|"Fatal|"fatal' && \
{ echo '$(ME): use FATAL, WARNING or warning' 1>&2; \
exit 1; } || :
# Error messages should not start with a capital letter
sc_error_message_uppercase:
- @grep -nEA2 '[^rp]error \(' $$($(VC_LIST_EXCEPT)) \
+ @grep -nEA2 '[^rp]error *\(' $$($(VC_LIST_EXCEPT)) \
| grep -E '"[A-Z]' \
| grep -vE '"FATAL|"WARNING|"Java|"C#|PRIuMAX' && \
{ echo '$(ME): found capitalized error message' 1>&2; \
@@ -239,35 +342,32 @@ sc_error_message_uppercase:
# Error messages should not end with a period
sc_error_message_period:
- @grep -nEA2 '[^rp]error \(' $$($(VC_LIST_EXCEPT)) \
+ @grep -nEA2 '[^rp]error *\(' $$($(VC_LIST_EXCEPT)) \
| grep -E '[^."]\."' && \
{ echo '$(ME): found error message ending in period' 1>&2; \
exit 1; } || :
sc_file_system:
- @re=file''system ignore_case=1 \
- msg='found use of "file''system"; spell it "file system"' \
- $(_prohibit_regexp)
+ @prohibit=file''system \
+ ignore_case=1 \
+ halt='found use of "file''system"; spell it "file system"' \
+ $(_sc_search_regexp)
# Don't use cpp tests of this symbol. All code assumes config.h is included.
sc_prohibit_have_config_h:
- @grep -n '^# *if.*HAVE''_CONFIG_H' $$($(VC_LIST_EXCEPT)) && \
- { echo '$(ME): found use of HAVE''_CONFIG_H; remove' \
- 1>&2; exit 1; } || :
+ @prohibit='^# *if.*HAVE''_CONFIG_H' \
+ halt='found use of HAVE''_CONFIG_H; remove' \
+ $(_sc_search_regexp)
# Nearly all .c files must include <config.h>. However, we also permit this
# via inclusion of a package-specific header, if cfg.mk specified one.
# config_h_header must be suitable for grep -E.
config_h_header ?= <config\.h>
sc_require_config_h:
- @if $(VC_LIST_EXCEPT) | grep -l '\.c$$' > /dev/null; then \
- grep -EL '^# *include $(config_h_header)' \
- $$($(VC_LIST_EXCEPT) | grep '\.c$$') \
- | grep . && \
- { echo '$(ME): the above files do not include <config.h>' \
- 1>&2; exit 1; } || :; \
- else :; \
- fi
+ @require='^# *include $(config_h_header)' \
+ in_vc_files='\.c$$' \
+ halt='the above files do not include <config.h>' \
+ $(_sc_search_regexp)
# You must include <config.h> before including any other header file.
# This can possibly be via a package-specific header, if given by cfg.mk.
@@ -286,8 +386,9 @@ sc_require_config_h_first:
fi
sc_prohibit_HAVE_MBRTOWC:
- @re='\bHAVE_MBRTOWC\b' msg="do not use $$re; it is always defined" \
- $(_prohibit_regexp)
+ @prohibit='\bHAVE_MBRTOWC\b' \
+ halt="do not use $$prohibit; it is always defined" \
+ $(_sc_search_regexp)
# To use this "command" macro, you must first define two shell variables:
# h: the header, enclosed in <> or ""
@@ -349,7 +450,7 @@ sc_prohibit_error_without_use:
# Don't include xalloc.h unless you use one of its functions.
# Consider these symbols:
# perl -lne '/^# *define (\w+)\(/ and print $1' lib/xalloc.h|grep -v '^__';
-# perl -lne '/^(?:extern )?(?:void|char) \*?(\w+) \(/ and print $1' lib/xalloc.h
+# perl -lne '/^(?:extern )?(?:void|char) \*?(\w+) *\(/ and print $1' lib/xalloc.h
# Divide into two sets on case, and filter each through this:
# | sort | perl -MRegexp::Assemble -le \
# 'print Regexp::Assemble->new(file => "/dev/stdin")->as_string'|sed 's/\?://g'
@@ -370,7 +471,7 @@ sc_prohibit_xalloc_without_use:
$(_sc_header_without_use)
# Extract function names:
-# perl -lne '/^(?:extern )?(?:void|char) \*?(\w+) \(/ and print $1' lib/hash.h
+# perl -lne '/^(?:extern )?(?:void|char) \*?(\w+) *\(/ and print $1' lib/hash.h
_hash_re = \
clear|delete|free|get_(first|next)|insert|lookup|print_statistics|reset_tuning
_hash_fn = \<($(_hash_re)) *\(
@@ -467,32 +568,27 @@ sc_prohibit_intprops_without_use:
$(_sc_header_without_use)
sc_obsolete_symbols:
- @re='\<(HAVE''_FCNTL_H|O''_NDELAY)\>' \
- msg='do not use HAVE''_FCNTL_H or O'_NDELAY \
- $(_prohibit_regexp)
+ @prohibit='\<(HAVE''_FCNTL_H|O''_NDELAY)\>' \
+ halt='do not use HAVE''_FCNTL_H or O'_NDELAY \
+ $(_sc_search_regexp)
# FIXME: warn about definitions of EXIT_FAILURE, EXIT_SUCCESS, STREQ
# Each nonempty ChangeLog line must start with a year number, or a TAB.
sc_changelog:
- @if $(VC_LIST_EXCEPT) | grep -l '^ChangeLog$$' >/dev/null; then \
- grep -n '^[^12 ]' \
- $$($(VC_LIST_EXCEPT) | grep '^ChangeLog$$') && \
- { echo '$(ME): found unexpected prefix in a ChangeLog' 1>&2; \
- exit 1; } || :; \
- fi
+ @prohibit='^[^12 ]' \
+ in_vc_files='^ChangeLog$$' \
+ halt='found unexpected prefix in a ChangeLog' \
+ $(_sc_search_regexp)
# Ensure that each .c file containing a "main" function also
# calls set_program_name.
sc_program_name:
- @if $(VC_LIST_EXCEPT) | grep -l '\.c$$' > /dev/null; then \
- files=$$(grep -l '^main *(' $$($(VC_LIST_EXCEPT) | grep '\.c$$')); \
- grep -LE 'set_program_name *\(m?argv\[0\]\);' $$files \
- | grep . && \
- { echo '$(ME): the above files do not call set_program_name' \
- 1>&2; exit 1; } || :; \
- else :; \
- fi
+ @require='set_program_name *\(m?argv\[0\]\);' \
+ in_vc_files='\.c$$' \
+ containing='^main *(' \
+ halt='the above files do not call set_program_name' \
+ $(_sc_search_regexp)
# Require that the final line of each test-lib.sh-using test be this one:
# Exit $fail
@@ -514,31 +610,30 @@ sc_require_test_exit_idiom:
fi
sc_the_the:
- @re='\<the ''the\>' \
- ignore_case=1 msg='found use of "the ''the";' \
- $(_prohibit_regexp)
+ @prohibit='\<the ''the\>' \
+ ignore_case=1 \
+ halt='found use of "the ''the";' \
+ $(_sc_search_regexp)
sc_trailing_blank:
- @re='[ ]$$' \
- msg='found trailing blank(s)' \
- $(_prohibit_regexp)
+ @prohibit='[ ]$$' \
+ halt='found trailing blank(s)' \
+ $(_sc_search_regexp)
# Match lines like the following, but where there is only one space
# between the options and the description:
# -D, --all-repeated[=delimit-method] print all duplicate lines\n
longopt_re = --[a-z][0-9A-Za-z-]*(\[?=[0-9A-Za-z-]*\]?)?
sc_two_space_separator_in_usage:
- @grep -nE '^ *(-[A-Za-z],)? $(longopt_re) [^ ].*\\$$' \
- $$($(VC_LIST_EXCEPT)) && \
- { echo "$(ME): help2man requires at least two spaces between"; \
- echo "$(ME): an option and its description"; \
- 1>&2; exit 1; } || :
+ @prohibit='^ *(-[A-Za-z],)? $(longopt_re) [^ ].*\\$$' \
+ halt='help2man requires at least two spaces between an option and its description'\
+ $(_sc_search_regexp)
# Look for diagnostics that aren't marked for translation.
# This won't find any for which error's format string is on a separate line.
sc_unmarked_diagnostics:
@grep -nE \
- '\<error \([^"]*"[^"]*[a-z]{3}' $$($(VC_LIST_EXCEPT)) \
+ '\<error *\([^"]*"[^"]*[a-z]{3}' $$($(VC_LIST_EXCEPT)) \
| grep -v '_''(' && \
{ echo '$(ME): found unmarked diagnostic(s)' 1>&2; \
exit 1; } || :
@@ -546,61 +641,96 @@ sc_unmarked_diagnostics:
# Avoid useless parentheses like those in this example:
# #if defined (SYMBOL) || defined (SYM2)
sc_useless_cpp_parens:
- @grep -n '^# *if .*defined *(' $$($(VC_LIST_EXCEPT)) && \
- { echo '$(ME): found useless parentheses in cpp directive' \
- 1>&2; exit 1; } || :
+ @prohibit='^# *if .*defined *\(' \
+ halt='found useless parentheses in cpp directive' \
+ $(_sc_search_regexp)
# Require the latest GPL.
sc_GPL_version:
- @re='either ''version [^3]' msg='GPL vN, N!=3' \
- $(_prohibit_regexp)
+ @prohibit='either ''version [^3]' \
+ halt='GPL vN, N!=3' \
+ $(_sc_search_regexp)
# Require the latest GFDL. Two regexp, since some .texi files end up
# line wrapping between 'Free Documentation License,' and 'Version'.
_GFDL_regexp = (Free ''Documentation.*Version 1\.[^3]|Version 1\.[^3] or any)
sc_GFDL_version:
- @re='$(_GFDL_regexp)' msg='GFDL vN, N!=3' \
- $(_prohibit_regexp)
+ @prohibit='$(_GFDL_regexp)' \
+ halt='GFDL vN, N!=3' \
+ $(_sc_search_regexp)
# Don't use Texinfo @acronym{} as it is not a good idea.
sc_texinfo_acronym:
- @if $(VC_LIST_EXCEPT) | grep -lE '\.texi$$' >/dev/null; then \
- grep -nE '@acronym{' \
- $$($(VC_LIST_EXCEPT) | grep -E '\.texi$$') && \
- { echo '$(ME): found use of Texinfo @acronym{}' 1>&2; \
- exit 1; } || :; \
- else :; \
- fi
+ @prohibit='@acronym{' \
+ in_vc_files='\.texi$$' \
+ halt='found use of Texinfo @acronym{}' \
+ $(_sc_search_regexp)
cvs_keywords = \
Author|Date|Header|Id|Name|Locker|Log|RCSfile|Revision|Source|State
sc_prohibit_cvs_keyword:
- @re='\$$($(cvs_keywords))\$$' \
- msg='do not use CVS keyword expansion' \
- $(_prohibit_regexp)
+ @prohibit='\$$($(cvs_keywords))\$$' \
+ halt='do not use CVS keyword expansion' \
+ $(_sc_search_regexp)
+
+# This Perl code is slightly obfuscated. Not only is each "$" doubled
+# because it's in a Makefile, but the $$c's are comments; we cannot
+# use "#" due to the way the script ends up concatenated onto one line.
+# It would be much more concise, and would produce better output (including
+# counts) if written as:
+# perl -ln -0777 -e '/\n(\n+)$/ and print "$ARGV: ".length $1' ...
+# but that would be far less efficient, reading the entire contents
+# of each file, rather than just the last two bytes of each.
+#
+# This is a perl script that is expected to be the single-quoted argument
+# to a command-line "-le". The remaining arguments are file names.
+# Print the name of each file that ends in two or more newline bytes.
+# Exit nonzero if at least one such file is found, otherwise, exit 0.
+# Warn about, but otherwise ignore open failure. Ignore seek/read failure.
+#
+# Use this if you want to remove trailing empty lines from selected files:
+# perl -pi -0777 -e 's/\n\n+$/\n/' files...
+#
+detect_empty_lines_at_EOF_ = \
+ foreach my $$f (@ARGV) { \
+ open F, "<", $$f or (warn "failed to open $$f: $$!\n"), next; \
+ my $$p = sysseek (F, -2, 2); \
+ my $$c = "seek failure probably means file has < 2 bytes; ignore"; \
+ my $$two; \
+ defined $$p and $$p = sysread F, $$two, 2; \
+ close F; \
+ $$c = "ignore read failure"; \
+ $$p && $$two eq "\n\n" and (print $$f), $$fail=1; \
+ } END { exit defined $$fail }
+sc_prohibit_empty_lines_at_EOF:
+ @perl -le '$(detect_empty_lines_at_EOF_)' $$($(VC_LIST_EXCEPT)) \
+ || { echo '$(ME): the above files end with empty line(s)' \
+ 1>&2; exit 1; } || :; \
# Make sure we don't use st_blocks. Use ST_NBLOCKS instead.
# This is a bit of a kludge, since it prevents use of the string
# even in comments, but for now it does the job with no false positives.
sc_prohibit_stat_st_blocks:
- @re='[.>]st_blocks' msg='do not use st_blocks; use ST_NBLOCKS' \
- $(_prohibit_regexp)
+ @prohibit='[.>]st_blocks' \
+ halt='do not use st_blocks; use ST_NBLOCKS' \
+ $(_sc_search_regexp)
# Make sure we don't define any S_IS* macros in src/*.c files.
# They're already defined via gnulib's sys/stat.h replacement.
sc_prohibit_S_IS_definition:
- @re='^ *# *define *S_IS' \
- msg='do not define S_IS* macros; include <sys/stat.h>' \
- $(_prohibit_regexp)
+ @prohibit='^ *# *define *S_IS' \
+ halt='do not define S_IS* macros; include <sys/stat.h>' \
+ $(_sc_search_regexp)
_ptm1 = use "test C1 && test C2", not "test C1 -''a C2"
_ptm2 = use "test C1 || test C2", not "test C1 -''o C2"
# Using test's -a and -o operators is not portable.
+# We prefer test over [, since the latter is spelled [[ in configure.ac.
sc_prohibit_test_minus_ao:
- @re='\<test .+ -[ao] ' \
- msg='$(_ptm1); $(_ptm2)' \
- $(_prohibit_regexp)
+ @prohibit='(\<test| \[+) .+ -[ao] ' \
+ halt='$(_ptm1); $(_ptm2)' \
+ $(_sc_search_regexp)
# Each program that uses proper_name_utf8 must link with one of the
# ICONV libraries. Otherwise, some ICONV library must appear in LDADD.
@@ -628,9 +758,9 @@ sc_proper_name_utf8_requires_ICONV:
# Warn about "c0nst struct Foo const foo[]",
# but not about "char const *const foo" or "#define const const".
sc_redundant_const:
- @re='\bconst\b[[:space:][:alnum:]]{2,}\bconst\b' \
- msg='redundant "const" in declarations' \
- $(_prohibit_regexp)
+ @prohibit='\bconst\b[[:space:][:alnum:]]{2,}\bconst\b' \
+ halt='redundant "const" in declarations' \
+ $(_sc_search_regexp)
sc_const_long_option:
@grep '^ *static.*struct option ' $$($(VC_LIST_EXCEPT)) \
@@ -684,16 +814,16 @@ news-check: NEWS
fi
sc_makefile_TAB_only_indentation:
- @grep -nE '^ [ ]{8}' \
- $$($(VC_LIST_EXCEPT) | grep -E 'akefile|\.mk$$') \
- && { echo '$(ME): found TAB-8-space indentation' 1>&2; \
- exit 1; } || :
+ @prohibit='^ [ ]{8}' \
+ in_vc_files='akefile|\.mk$$' \
+ halt='found TAB-8-space indentation' \
+ $(_sc_search_regexp)
sc_m4_quote_check:
- @grep -nE '(AC_DEFINE(_UNQUOTED)?|AC_DEFUN)\([^[]' \
- $$($(VC_LIST_EXCEPT) | grep -E '(^configure\.ac|\.m4)$$') \
- && { echo '$(ME): quote the first arg to AC_DEF*' 1>&2; \
- exit 1; } || :
+ @prohibit='(AC_DEFINE(_UNQUOTED)?|AC_DEFUN)\([^[]' \
+ in_vc_files='(^configure\.ac|\.m4)$$' \
+ halt='quote the first arg to AC_DEF*' \
+ $(_sc_search_regexp)
fix_po_file_diag = \
'you have changed the set of files with translatable diagnostics;\n\
@@ -732,9 +862,10 @@ sc_po_check:
# path separator of `:', but rather the automake-provided `$(PATH_SEPARATOR)'.
msg = '$(ME): Do not use `:'\'' above; use $$(PATH_SEPARATOR) instead'
sc_makefile_path_separator_check:
- @grep -nE 'PATH[=].*:' \
- $$($(VC_LIST_EXCEPT) | grep -E 'akefile|\.mk$$') \
- && { echo $(msg) 1>&2; exit 1; } || :
+ @prohibit='PATH[=].*:' \
+ in_vc_files='akefile|\.mk$$' \
+ halt=$(msg) \
+ $(_sc_search_regexp)
# Check that `make alpha' will not fail at the end of the process.
writable-files:
@@ -754,23 +885,41 @@ texi = doc/$(PACKAGE).texi
# Make sure that the copyright date in $(v_etc_file) is up to date.
# Do the same for the $(sample-test) and the main doc/.texi file.
sc_copyright_check:
- @if test -f $(v_etc_file); then \
- grep 'enum { COPYRIGHT_YEAR = '$$(date +%Y)' };' $(v_etc_file) \
- >/dev/null \
- || { echo 'out of date copyright in $(v_etc_file); update it' 1>&2; \
- exit 1; }; \
- fi
- @if test -f $(sample-test); then \
- grep '# Copyright (C) '$$(date +%Y)' Free' $(sample-test) \
- >/dev/null \
- || { echo 'out of date copyright in $(sample-test); update it' 1>&2; \
- exit 1; }; \
- fi
- @if test -f $(texi); then \
- grep 'Copyright @copyright{} .*'$$(date +%Y)' Free' $(texi) \
- >/dev/null \
- || { echo 'out of date copyright in $(texi); update it' 1>&2; \
- exit 1; }; \
+ @require='enum { COPYRIGHT_YEAR = '$$(date +%Y)' };' \
+ in_files=$(v_etc_file) \
+ halt='out of date copyright in $(v_etc_file); update it' \
+ $(_sc_search_regexp)
+ @require='# Copyright \(C\) '$$(date +%Y)' Free' \
+ in_vc_files=$(sample-test) \
+ halt='out of date copyright in $(sample-test); update it' \
+ $(_sc_search_regexp)
+ @require='Copyright @copyright\{\} .*'$$(date +%Y)' Free' \
+ in_vc_files=$(texi) \
+ halt='out of date copyright in $(texi); update it' \
+ $(_sc_search_regexp)
+
+# If tests/help-version exists and seems to be new enough, assume that its
+# use of init.sh and path_prepend_ is correct, and ensure that every other
+# use of init.sh is identical.
+# This is useful because help-version cross-checks prog --version
+# with $(VERSION), which verifies that its path_prepend_ invocation
+# sets PATH correctly. This is an inexpensive way to ensure that
+# the other init.sh-using tests also get it right.
+_hv_file ?= $(srcdir)/tests/help-version
+_hv_regex ?= ^ *\. [^ ]*/init\.sh
+sc_cross_check_PATH_usage_in_tests:
+ @if test -f $(_hv_file); then \
+ if grep -l 'VERSION mismatch' $(_hv_file) >/dev/null \
+ && grep -lE '$(_hv_regex)' $(_hv_file) >/dev/null; then \
+ good=$$(grep -E '$(_hv_regex)' < $(_hv_file)); \
+ grep -LFx "$$good" \
+ $$(grep -lE '$(_hv_regex)' $$($(VC_LIST_EXCEPT))) \
+ | grep . && \
+ { echo "$(ME): the above files use path_prepend_ inconsistently" \
+ 1>&2; exit 1; } || :; \
+ fi; \
+ else \
+ echo "$@: skipped: no such file: $(_hv_file)"; \
fi
# #if HAVE_... will evaluate to false for any non numeric string.
@@ -778,22 +927,18 @@ sc_copyright_check:
# tests many undefined macros, and so we can't enable that option.
# So at least preclude common boolean strings as macro values.
sc_Wundef_boolean:
- @test -e '$(CONFIG_INCLUDE)' && \
- grep -Ei '^#define.*(yes|no|true|false)$$' '$(CONFIG_INCLUDE)' && \
- { echo 'Use 0 or 1 for macro values' 1>&2; exit 1; } || :
+ @prohibit='^#define.*(yes|no|true|false)$$' \
+ in_files='$(CONFIG_INCLUDE)' \
+ halt='Use 0 or 1 for macro values' \
+ $(_sc_search_regexp)
sc_vulnerable_makefile_CVE-2009-4029:
- @files=$$(find $(srcdir) -name Makefile.in); \
- if test -n "$$files"; then \
- grep -E \
- 'perm -777 -exec chmod a\+rwx|chmod 777 \$$\(distdir\)' \
- $$files && \
- { echo '$(ME): the above files are vulnerable; beware of' \
- 'running "make dist*" rules, and upgrade to fixed automake' \
- 'see http://bugzilla.redhat.com/542609 for details' \
- 1>&2; exit 1; } || :; \
- else :; \
- fi
+ @prohibit='perm -777 -exec chmod a\+rwx|chmod 777 \$$\(distdir\)' \
+ in_files=$$(find $(srcdir) -name Makefile.in) \
+ halt='the above files are vulnerable; beware of running\n'\
+'"make dist*" rules, and upgrade to fixed automake\n'\
+'see http://bugzilla.redhat.com/542609 for details' \
+ $(_sc_search_regexp)
vc-diff-check:
(unset CDPATH; cd $(srcdir) && $(VC) diff) > vc-diffs || :
diff --git a/src/certtool.gaa b/src/certtool.gaa
index 0215245c04..096f119613 100644
--- a/src/certtool.gaa
+++ b/src/certtool.gaa
@@ -140,4 +140,3 @@ init { $bits = 2048; $pkcs8 = 0; $privkey = NULL; $ca=NULL; $ca_privkey = NULL;
$incert_format = 0; $outcert_format = 0; $action=-1; $pass = NULL; $v1_cert = 0;
$export = 0; $template = NULL; $hash=NULL; $fix_key = 0; $quick_random=1;
$privkey_op = 0; $pkcs_cipher = "3des"; $crq_extensions=1; }
-
diff --git a/src/cfg/Makefile.am b/src/cfg/Makefile.am
index 5ba55faa16..9d47df07ad 100644
--- a/src/cfg/Makefile.am
+++ b/src/cfg/Makefile.am
@@ -2,4 +2,3 @@ EXTRA_DIST = cfg+.h cfgfile.h cmdline.h shared.h \
cfg+.c cfgfile.c cmdline.c parse.c props.c shared.c
SUBDIRS = platon
-
diff --git a/src/crypt.gaa b/src/crypt.gaa
index 3771502c6a..516b257f25 100644
--- a/src/crypt.gaa
+++ b/src/crypt.gaa
@@ -40,4 +40,3 @@ option (h, help) { gaa_help(); exit(0); } "shows this help text"
init { $username=NULL; $passwd=NULL; $salt=0;
$create_conf=NULL; $passwd_conf=NULL; $verify = 0;
$index = 1; }
-
diff --git a/src/tls_test.gaa b/src/tls_test.gaa
index a4080c0670..f28d99d136 100644
--- a/src/tls_test.gaa
+++ b/src/tls_test.gaa
@@ -30,4 +30,3 @@ option (h, help) { gaa_help(); exit(0); } "prints this help"
rest STR "hostname" { $rest_args = $1; }
init { $rest_args=NULL; $pp = 443; $more_info = 0; }
-
diff --git a/tests/key-id/ca-gnutls-keyid.pem b/tests/key-id/ca-gnutls-keyid.pem
index ad4ae9a847..fdb7520a48 100644
--- a/tests/key-id/ca-gnutls-keyid.pem
+++ b/tests/key-id/ca-gnutls-keyid.pem
@@ -1,5 +1,3 @@
-
-
X.509 certificate info:
Version: 3
@@ -43,4 +41,3 @@ BAUwAwEB/zAdBgNVHQ4EFgQUuuRvY1GQbDgb39qJtZKH0ynn10EwCwYJKoZIhvcN
AQEFA0EAMIM/ZIai49eKHg/Hb/LoKPtY8bLIf+oRw+0ifZghudZPokwIukVRoRw3
rvJSTitBJGH9uyNWn8bbackkkg4otA==
-----END CERTIFICATE-----
-
diff --git a/tests/key-id/ca-no-keyid.pem b/tests/key-id/ca-no-keyid.pem
index b058706f98..50675e420b 100644
--- a/tests/key-id/ca-no-keyid.pem
+++ b/tests/key-id/ca-no-keyid.pem
@@ -1,5 +1,3 @@
-
-
X.509 certificate info:
Version: 3
@@ -40,4 +38,3 @@ AAcbuwIDAQABoxMwETAPBgNVHRMBAf8EBTADAQH/MAsGCSqGSIb3DQEBBQNBAI6O
9GReGvX7vMcZxjMOua6mIOViqOPeMzJRNEFqUAo4aHy/ad17nHZhy3WsWm2GkrTk
AiKsBcgbwyu2d/Fg6js=
-----END CERTIFICATE-----
-
diff --git a/tests/key-id/ca-weird-keyid.pem b/tests/key-id/ca-weird-keyid.pem
index 6d0579a8a6..6ecfef4231 100644
--- a/tests/key-id/ca-weird-keyid.pem
+++ b/tests/key-id/ca-weird-keyid.pem
@@ -1,5 +1,3 @@
-
-
X.509 certificate info:
Version: 3
@@ -49,4 +47,3 @@ cm5ldCBXaWRnaXRzIFB0eSBMdGSCCQDSCBqCpCeFKzAMBgNVHRMEBTADAQH/MA0G
CSqGSIb3DQEBBQUAA0EAv5CpU4DykkfMcy1BLbsowb/7YritEudYemW3cOMg6q92
tc8eEDBjIYcVccHJMM27fTKt7AIDUiHUysFFxclcww==
-----END CERTIFICATE-----
-
diff --git a/tests/pkcs1-padding/pkcs1-pad-broken.pem b/tests/pkcs1-padding/pkcs1-pad-broken.pem
index 17036de8a3..62cb076757 100644
--- a/tests/pkcs1-padding/pkcs1-pad-broken.pem
+++ b/tests/pkcs1-padding/pkcs1-pad-broken.pem
@@ -1,5 +1,3 @@
-
-
X.509 certificate info:
Version: 3
@@ -118,4 +116,3 @@ aJ/c/3cGHssi8IvVRci/aavqj607y7l22nKDtG1p4KAjnfNhBMOhRhFv00nJnokK
y0uc4DIegAW1bxQjqcMNNEmGbzAeixH/cRCot8C1LobEQmxNWCY2DJLWoI3wwqr8
uUSnI1CDZ5402etkCiNXsDy/eYDrF+2KonkIWRrr
-----END CERTIFICATE-----
-
diff --git a/tests/pkcs1-padding/pkcs1-pad-broken2.pem b/tests/pkcs1-padding/pkcs1-pad-broken2.pem
index 22b32d2876..b13cdf508c 100644
--- a/tests/pkcs1-padding/pkcs1-pad-broken2.pem
+++ b/tests/pkcs1-padding/pkcs1-pad-broken2.pem
@@ -1,5 +1,3 @@
-
-
X.509 certificate info:
Version: 1
@@ -39,4 +37,3 @@ hCeV/xIxUg8V70YRxK2A5jZbD92A12GN4PxyRQk0/lVmRUNMaJdq/qigpd9feP/u
DF6P14yRKUtX8akOP2TwStaSiVf/akYqfLFm3UGka5XbPj4rifrZ0/sOoZEEBvHQ
e20sRA==
-----END CERTIFICATE-----
-
diff --git a/tests/pkcs1-padding/pkcs1-pad-broken3.pem b/tests/pkcs1-padding/pkcs1-pad-broken3.pem
index 04618b6c45..9c1d39d329 100644
--- a/tests/pkcs1-padding/pkcs1-pad-broken3.pem
+++ b/tests/pkcs1-padding/pkcs1-pad-broken3.pem
@@ -1,5 +1,3 @@
-
-
X.509 certificate info:
Version: 3
@@ -126,4 +124,3 @@ xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynp
VSJYACPq4xJDKVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEY
WQPJIrSPnNVeKtelttQKbfi3QBFGmh95DmK/D5fs4C8fF5Q=
-----END CERTIFICATE-----
-
diff --git a/tests/pkcs1-padding/pkcs1-pad-ok.pem b/tests/pkcs1-padding/pkcs1-pad-ok.pem
index fd0e5a1ccb..ff19cb456e 100644
--- a/tests/pkcs1-padding/pkcs1-pad-ok.pem
+++ b/tests/pkcs1-padding/pkcs1-pad-ok.pem
@@ -1,5 +1,3 @@
-
-
X.509 certificate info:
Version: 3
@@ -118,4 +116,3 @@ aJ/c/3cGHssi8IvVRci/aavqj607y7l22nKDtG1p4KAjnfNhBMOhRhFv00nJnokK
y0uc4DIegAW1bxQjqcMNNEmGbzAeixH/cRCot8C1LobEQmxNWCY2DJLWoI3wwqr8
uUSnI1CDZ5402etkCiNXsDy/eYDrF+2KonkIWRrr
-----END CERTIFICATE-----
-
diff --git a/tests/pkcs1-padding/pkcs1-pad-ok2.pem b/tests/pkcs1-padding/pkcs1-pad-ok2.pem
index f728f31e9f..36548fa48f 100644
--- a/tests/pkcs1-padding/pkcs1-pad-ok2.pem
+++ b/tests/pkcs1-padding/pkcs1-pad-ok2.pem
@@ -1,5 +1,3 @@
-
-
X.509 certificate info:
Version: 1
@@ -39,4 +37,3 @@ hCeV/xIxUg8V70YRxK2A5jZbD92A12GN4PxyRQk0/lVmRUNMaJdq/qigpd9feP/u
4itiMOU4SN6JFTFDCTU/Gb5aR/Fiu7HJkuE5yGEnTdnwcId/T9sTW251yzCc1e2z
rHX/kw==
-----END CERTIFICATE-----
-
diff --git a/tests/safe-renegotiation/Makefile.am b/tests/safe-renegotiation/Makefile.am
index 4a85cfeb01..74ad564350 100644
--- a/tests/safe-renegotiation/Makefile.am
+++ b/tests/safe-renegotiation/Makefile.am
@@ -21,4 +21,3 @@ EXTRA_DIST = params.dh
dist_check_SCRIPTS = testsrn
TESTS = testsrn
-
diff --git a/tests/test25.pem b/tests/test25.pem
index 72220a4f26..057cbe0b5c 100644
--- a/tests/test25.pem
+++ b/tests/test25.pem
@@ -179,4 +179,3 @@ CSqGSIb3DQEBBQUAA4GBABZWD2Gsh4tP62QSG8OFWUpo4TulIcFZLpGsaP4T/2Nt
7lXUoIJMN7wWjqkmYf5/Rvo4HxNcimq3EkeYcrm1VoDueJUYGvRjcCY5mxkghI27
Yl/fLKE9/BvQOrvYzBs2EqKrrT7m4VK0dRMR7CeVpmPP08z0Tti6uK2tzBplp1pF
-----END CERTIFICATE-----
-