summaryrefslogtreecommitdiffstats
path: root/gl
diff options
context:
space:
mode:
authorThomas Guyot-Sionnest <dermoth@aei.ca>2009-01-15 09:22:57 (GMT)
committerThomas Guyot-Sionnest <dermoth@aei.ca>2009-01-15 10:19:08 (GMT)
commit71cdb52799220f8d9052643baf1d3e9836a9c755 (patch)
tree27aee97a35d9ab51f0d8f64a46690bd41a5f8c1b /gl
parentf7afa46586645e50498d8b2d0c67884f014dc3a4 (diff)
downloadmonitoring-plugins-71cdb52799220f8d9052643baf1d3e9836a9c755.tar.gz
Sync with gnulib
Diffstat (limited to 'gl')
-rw-r--r--gl/Makefile.am343
-rw-r--r--gl/alloca.in.h4
-rw-r--r--gl/arpa_inet.in.h (renamed from gl/inet_ntop.h)54
-rw-r--r--gl/base64.c273
-rw-r--r--gl/base64.h24
-rw-r--r--gl/btowc.c38
-rwxr-xr-xgl/config.charset6
-rw-r--r--gl/errno.in.h155
-rw-r--r--gl/fcntl.in.h144
-rw-r--r--gl/float.in.h6
-rw-r--r--gl/gai_strerror.c7
-rw-r--r--gl/getaddrinfo.c27
-rw-r--r--gl/getaddrinfo.h155
-rw-r--r--gl/gethostname.c3
-rw-r--r--gl/getloadavg.c7
-rw-r--r--gl/getopt.c6
-rw-r--r--gl/inet_ntop.c4
-rw-r--r--gl/localcharset.c6
-rw-r--r--gl/m4/absolute-header.m449
-rw-r--r--gl/m4/alloca.m46
-rw-r--r--gl/m4/arpa_inet_h.m442
-rw-r--r--gl/m4/btowc.m468
-rw-r--r--gl/m4/c-strtod.m46
-rw-r--r--gl/m4/codeset.m412
-rw-r--r--gl/m4/double-slash-root.m410
-rw-r--r--gl/m4/eoverflow.m470
-rw-r--r--gl/m4/errno_h.m4119
-rw-r--r--gl/m4/extensions.m420
-rw-r--r--gl/m4/fcntl_h.m494
-rw-r--r--gl/m4/fsusage.m468
-rw-r--r--gl/m4/getaddrinfo.m496
-rw-r--r--gl/m4/gethostname.m411
-rw-r--r--gl/m4/getloadavg.m481
-rw-r--r--gl/m4/getopt.m46
-rw-r--r--gl/m4/gettext.m438
-rw-r--r--gl/m4/glibc2.m414
-rw-r--r--gl/m4/glibc21.m414
-rw-r--r--gl/m4/gnulib-cache.m420
-rw-r--r--gl/m4/gnulib-common.m442
-rw-r--r--gl/m4/gnulib-comp.m4127
-rw-r--r--gl/m4/gnulib-tool.m428
-rw-r--r--gl/m4/hostent.m445
-rw-r--r--gl/m4/iconv.m430
-rw-r--r--gl/m4/include_next.m4103
-rw-r--r--gl/m4/inet_ntop.m417
-rw-r--r--gl/m4/inline.m46
-rw-r--r--gl/m4/intdiv0.m48
-rw-r--r--gl/m4/intldir.m46
-rw-r--r--gl/m4/intlmacosx.m412
-rw-r--r--gl/m4/intmax.m412
-rw-r--r--gl/m4/intmax_t.m416
-rw-r--r--gl/m4/inttypes-pri.m412
-rw-r--r--gl/m4/inttypes_h.m412
-rw-r--r--gl/m4/lcmessage.m410
-rw-r--r--gl/m4/lib-ld.m414
-rw-r--r--gl/m4/lib-link.m4103
-rw-r--r--gl/m4/lib-prefix.m488
-rw-r--r--gl/m4/localcharset.m46
-rw-r--r--gl/m4/locale-fr.m4204
-rw-r--r--gl/m4/locale-ja.m4126
-rw-r--r--gl/m4/locale-zh.m4111
-rw-r--r--gl/m4/lock.m4313
-rw-r--r--gl/m4/longlong.m48
-rw-r--r--gl/m4/ls-mntd-fs.m491
-rw-r--r--gl/m4/malloc.m46
-rw-r--r--gl/m4/math_h.m441
-rw-r--r--gl/m4/mbrtowc.m4325
-rw-r--r--gl/m4/mbsinit.m430
-rw-r--r--gl/m4/mbstate_t.m422
-rw-r--r--gl/m4/mountlist.m48
-rw-r--r--gl/m4/multiarch.m474
-rw-r--r--gl/m4/netdb_h.m445
-rw-r--r--gl/m4/netinet_in_h.m46
-rw-r--r--gl/m4/nls.m412
-rw-r--r--gl/m4/onceonly.m4 (renamed from gl/m4/onceonly_2_57.m4)26
-rw-r--r--gl/m4/open.m466
-rw-r--r--gl/m4/po.m48
-rw-r--r--gl/m4/printf-posix.m413
-rw-r--r--gl/m4/printf.m41322
-rw-r--r--gl/m4/progtest.m414
-rw-r--r--gl/m4/regex.m416
-rw-r--r--gl/m4/servent.m447
-rw-r--r--gl/m4/size_max.m414
-rw-r--r--gl/m4/snprintf.m415
-rw-r--r--gl/m4/sockpfaf.m420
-rw-r--r--gl/m4/stdbool.m44
-rw-r--r--gl/m4/stdint.m441
-rw-r--r--gl/m4/stdint_h.m412
-rw-r--r--gl/m4/stdio_h.m4136
-rw-r--r--gl/m4/stdlib_h.m444
-rw-r--r--gl/m4/strdup.m422
-rw-r--r--gl/m4/strerror.m463
-rw-r--r--gl/m4/string_h.m413
-rw-r--r--gl/m4/strndup.m412
-rw-r--r--gl/m4/strnlen.m48
-rw-r--r--gl/m4/sys_socket_h.m490
-rw-r--r--gl/m4/threadlib.m4313
-rw-r--r--gl/m4/uintmax_t.m410
-rw-r--r--gl/m4/unistd_h.m446
-rw-r--r--gl/m4/vasnprintf.m437
-rw-r--r--gl/m4/visibility.m410
-rw-r--r--gl/m4/vsnprintf.m415
-rw-r--r--gl/m4/wchar.m457
-rw-r--r--gl/m4/wchar_t.m410
-rw-r--r--gl/m4/wcrtomb.m488
-rw-r--r--gl/m4/wctype.m434
-rw-r--r--gl/m4/wint_t.m410
-rw-r--r--gl/m4/write.m420
-rw-r--r--gl/m4/xsize.m46
-rw-r--r--gl/math.in.h157
-rw-r--r--gl/mbrtowc.c349
-rw-r--r--gl/mbsinit.c47
-rw-r--r--gl/netdb.in.h182
-rw-r--r--gl/netinet_in.in.h6
-rw-r--r--gl/open-safer.c9
-rw-r--r--gl/open.c140
-rw-r--r--gl/regcomp.c131
-rw-r--r--gl/regex_internal.c30
-rw-r--r--gl/regex_internal.h12
-rw-r--r--gl/regexec.c16
-rw-r--r--gl/snprintf.c7
-rw-r--r--gl/stdbool.in.h6
-rw-r--r--gl/stdint.in.h123
-rw-r--r--gl/stdio-write.c148
-rw-r--r--gl/stdio.in.h110
-rw-r--r--gl/stdlib.in.h171
-rw-r--r--gl/strdup.c55
-rw-r--r--gl/streq.h176
-rw-r--r--gl/strerror.c242
-rw-r--r--gl/string.in.h38
-rw-r--r--gl/sys_socket.in.h338
-rw-r--r--gl/unistd.in.h240
-rw-r--r--gl/vasnprintf.c361
-rw-r--r--gl/vasprintf.c7
-rw-r--r--gl/verify.h140
-rw-r--r--gl/vsnprintf.c7
-rw-r--r--gl/wchar.in.h219
-rw-r--r--gl/wcrtomb.c53
-rw-r--r--gl/wctype.in.h59
-rw-r--r--gl/write.c62
-rw-r--r--gl/xalloc.h24
-rw-r--r--gl/xmalloc.c2
-rw-r--r--gl/xsize.h4
143 files changed, 8806 insertions, 1752 deletions
diff --git a/gl/Makefile.am b/gl/Makefile.am
index 1eefee9..1a407c5 100644
--- a/gl/Makefile.am
+++ b/gl/Makefile.am
@@ -1,6 +1,6 @@
1## DO NOT EDIT! GENERATED AUTOMATICALLY! 1## DO NOT EDIT! GENERATED AUTOMATICALLY!
2## Process this file with automake to produce Makefile.in. 2## Process this file with automake to produce Makefile.in.
3# Copyright (C) 2004-2007 Free Software Foundation, Inc. 3# Copyright (C) 2002-2009 Free Software Foundation, Inc.
4# 4#
5# This file is free software, distributed under the terms of the GNU 5# This file is free software, distributed under the terms of the GNU
6# General Public License. As a special exception to the GNU General 6# General Public License. As a special exception to the GNU General
@@ -9,10 +9,11 @@
9# the same distribution terms as the rest of that program. 9# the same distribution terms as the rest of that program.
10# 10#
11# Generated by gnulib-tool. 11# Generated by gnulib-tool.
12# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --aux-dir=build-aux --no-libtool --macro-prefix=gl base64 dirname floorf fsusage getaddrinfo gethostname getloadavg getopt gettext mountlist regex vasprintf vsnprintf 12# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-libtool --macro-prefix=gl base64 dirname floorf fsusage getaddrinfo gethostname getloadavg getopt gettext mountlist regex vasprintf vsnprintf
13 13
14AUTOMAKE_OPTIONS = 1.5 gnits 14AUTOMAKE_OPTIONS = 1.5 gnits
15 15
16SUBDIRS =
16noinst_HEADERS = 17noinst_HEADERS =
17noinst_LIBRARIES = 18noinst_LIBRARIES =
18noinst_LTLIBRARIES = 19noinst_LTLIBRARIES =
@@ -24,6 +25,7 @@ MOSTLYCLEANDIRS =
24CLEANFILES = 25CLEANFILES =
25DISTCLEANFILES = 26DISTCLEANFILES =
26MAINTAINERCLEANFILES = 27MAINTAINERCLEANFILES =
28EXTRA_DIST += m4/gnulib-cache.m4
27 29
28AM_CPPFLAGS = 30AM_CPPFLAGS =
29 31
@@ -34,15 +36,6 @@ libgnu_a_LIBADD = $(gl_LIBOBJS)
34libgnu_a_DEPENDENCIES = $(gl_LIBOBJS) 36libgnu_a_DEPENDENCIES = $(gl_LIBOBJS)
35EXTRA_libgnu_a_SOURCES = 37EXTRA_libgnu_a_SOURCES =
36 38
37## begin gnulib module absolute-header
38
39# Use this preprocessor expression to decide whether #include_next works.
40# Do not rely on a 'configure'-time test for this, since the expression
41# might appear in an installed header, which is used by some other compiler.
42HAVE_INCLUDE_NEXT = (__GNUC__ || 60000000 <= __DECC_VER)
43
44## end gnulib module absolute-header
45
46## begin gnulib module alloca 39## begin gnulib module alloca
47 40
48 41
@@ -81,12 +74,23 @@ arpa/inet.h:
81 @MKDIR_P@ arpa 74 @MKDIR_P@ arpa
82 rm -f $@-t $@ 75 rm -f $@-t $@
83 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 76 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
84 echo '#include <sys/socket.h>'; \ 77 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
78 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
79 -e 's|@''NEXT_ARPA_INET_H''@|$(NEXT_ARPA_INET_H)|g' \
80 -e 's|@''HAVE_ARPA_INET_H''@|$(HAVE_ARPA_INET_H)|g' \
81 -e 's|@''GNULIB_INET_NTOP''@|$(GNULIB_INET_NTOP)|g' \
82 -e 's|@''GNULIB_INET_PTON''@|$(GNULIB_INET_PTON)|g' \
83 -e 's|@''HAVE_DECL_INET_NTOP''@|$(HAVE_DECL_INET_NTOP)|g' \
84 -e 's|@''HAVE_DECL_INET_PTON''@|$(HAVE_DECL_INET_PTON)|g' \
85 -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
86 < $(srcdir)/arpa_inet.in.h; \
85 } > $@-t 87 } > $@-t
86 mv $@-t $@ 88 mv $@-t $@
87MOSTLYCLEANFILES += arpa/inet.h arpa/inet.h-t 89MOSTLYCLEANFILES += arpa/inet.h arpa/inet.h-t
88MOSTLYCLEANDIRS += arpa 90MOSTLYCLEANDIRS += arpa
89 91
92EXTRA_DIST += arpa_inet.in.h
93
90## end gnulib module arpa_inet 94## end gnulib module arpa_inet
91 95
92## begin gnulib module base64 96## begin gnulib module base64
@@ -95,6 +99,15 @@ libgnu_a_SOURCES += base64.h base64.c
95 99
96## end gnulib module base64 100## end gnulib module base64
97 101
102## begin gnulib module btowc
103
104
105EXTRA_DIST += btowc.c
106
107EXTRA_libgnu_a_SOURCES += btowc.c
108
109## end gnulib module btowc
110
98## begin gnulib module c-strtod 111## begin gnulib module c-strtod
99 112
100 113
@@ -178,6 +191,33 @@ EXTRA_libgnu_a_SOURCES += basename.c dirname.c stripslash.c
178 191
179## end gnulib module dirname 192## end gnulib module dirname
180 193
194## begin gnulib module errno
195
196BUILT_SOURCES += $(ERRNO_H)
197
198# We need the following in order to create <errno.h> when the system
199# doesn't have one that is POSIX compliant.
200errno.h: errno.in.h
201 rm -f $@-t $@
202 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
203 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
204 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
205 -e 's|@''NEXT_ERRNO_H''@|$(NEXT_ERRNO_H)|g' \
206 -e 's|@''EMULTIHOP_HIDDEN''@|$(EMULTIHOP_HIDDEN)|g' \
207 -e 's|@''EMULTIHOP_VALUE''@|$(EMULTIHOP_VALUE)|g' \
208 -e 's|@''ENOLINK_HIDDEN''@|$(ENOLINK_HIDDEN)|g' \
209 -e 's|@''ENOLINK_VALUE''@|$(ENOLINK_VALUE)|g' \
210 -e 's|@''EOVERFLOW_HIDDEN''@|$(EOVERFLOW_HIDDEN)|g' \
211 -e 's|@''EOVERFLOW_VALUE''@|$(EOVERFLOW_VALUE)|g' \
212 < $(srcdir)/errno.in.h; \
213 } > $@-t
214 mv $@-t $@
215MOSTLYCLEANFILES += errno.h errno.h-t
216
217EXTRA_DIST += errno.in.h
218
219## end gnulib module errno
220
181## begin gnulib module error 221## begin gnulib module error
182 222
183 223
@@ -196,6 +236,29 @@ EXTRA_libgnu_a_SOURCES += exitfail.c
196 236
197## end gnulib module exitfail 237## end gnulib module exitfail
198 238
239## begin gnulib module fcntl
240
241BUILT_SOURCES += $(FCNTL_H)
242
243# We need the following in order to create <fcntl.h> when the system
244# doesn't have one that works with the given compiler.
245fcntl.h: fcntl.in.h
246 rm -f $@-t $@
247 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
248 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
249 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
250 -e 's|@''NEXT_FCNTL_H''@|$(NEXT_FCNTL_H)|g' \
251 -e 's|@''GNULIB_OPEN''@|$(GNULIB_OPEN)|g' \
252 -e 's|@''REPLACE_OPEN''@|$(REPLACE_OPEN)|g' \
253 < $(srcdir)/fcntl.in.h; \
254 } > $@-t
255 mv $@-t $@
256MOSTLYCLEANFILES += fcntl.h fcntl.h-t
257
258EXTRA_DIST += fcntl.in.h
259
260## end gnulib module fcntl
261
199## begin gnulib module fcntl-safer 262## begin gnulib module fcntl-safer
200 263
201 264
@@ -214,7 +277,8 @@ BUILT_SOURCES += $(FLOAT_H)
214float.h: float.in.h 277float.h: float.in.h
215 rm -f $@-t $@ 278 rm -f $@-t $@
216 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 279 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
217 sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \ 280 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
281 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
218 -e 's|@''NEXT_FLOAT_H''@|$(NEXT_FLOAT_H)|g' \ 282 -e 's|@''NEXT_FLOAT_H''@|$(NEXT_FLOAT_H)|g' \
219 < $(srcdir)/float.in.h; \ 283 < $(srcdir)/float.in.h; \
220 } > $@-t 284 } > $@-t
@@ -258,7 +322,7 @@ libgnu_a_SOURCES += full-write.h full-write.c
258## begin gnulib module getaddrinfo 322## begin gnulib module getaddrinfo
259 323
260 324
261EXTRA_DIST += gai_strerror.c getaddrinfo.c getaddrinfo.h 325EXTRA_DIST += gai_strerror.c getaddrinfo.c
262 326
263EXTRA_libgnu_a_SOURCES += gai_strerror.c getaddrinfo.c 327EXTRA_libgnu_a_SOURCES += gai_strerror.c getaddrinfo.c
264 328
@@ -333,7 +397,7 @@ EXTRA_DIST += $(top_srcdir)/build-aux/config.rpath
333## begin gnulib module inet_ntop 397## begin gnulib module inet_ntop
334 398
335 399
336EXTRA_DIST += inet_ntop.c inet_ntop.h 400EXTRA_DIST += inet_ntop.c
337 401
338EXTRA_libgnu_a_SOURCES += inet_ntop.c 402EXTRA_libgnu_a_SOURCES += inet_ntop.c
339 403
@@ -439,7 +503,8 @@ BUILT_SOURCES += math.h
439math.h: math.in.h 503math.h: math.in.h
440 rm -f $@-t $@ 504 rm -f $@-t $@
441 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 505 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
442 sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \ 506 sed -e 's|@''INCLUDE_NEXT_AS_FIRST_DIRECTIVE''@|$(INCLUDE_NEXT_AS_FIRST_DIRECTIVE)|g' \
507 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
443 -e 's|@''NEXT_MATH_H''@|$(NEXT_MATH_H)|g' \ 508 -e 's|@''NEXT_MATH_H''@|$(NEXT_MATH_H)|g' \
444 -e 's|@''GNULIB_CEILF''@|$(GNULIB_CEILF)|g' \ 509 -e 's|@''GNULIB_CEILF''@|$(GNULIB_CEILF)|g' \
445 -e 's|@''GNULIB_CEILL''@|$(GNULIB_CEILL)|g' \ 510 -e 's|@''GNULIB_CEILL''@|$(GNULIB_CEILL)|g' \
@@ -448,6 +513,11 @@ math.h: math.in.h
448 -e 's|@''GNULIB_FREXP''@|$(GNULIB_FREXP)|g' \ 513 -e 's|@''GNULIB_FREXP''@|$(GNULIB_FREXP)|g' \
449 -e 's|@''GNULIB_FREXPL''@|$(GNULIB_FREXPL)|g' \ 514 -e 's|@''GNULIB_FREXPL''@|$(GNULIB_FREXPL)|g' \
450 -e 's|@''GNULIB_ISFINITE''@|$(GNULIB_ISFINITE)|g' \ 515 -e 's|@''GNULIB_ISFINITE''@|$(GNULIB_ISFINITE)|g' \
516 -e 's|@''GNULIB_ISINF''@|$(GNULIB_ISINF)|g' \
517 -e 's|@''GNULIB_ISNAN''@|$(GNULIB_ISNAN)|g' \
518 -e 's|@''GNULIB_ISNANF''@|$(GNULIB_ISNANF)|g' \
519 -e 's|@''GNULIB_ISNAND''@|$(GNULIB_ISNAND)|g' \
520 -e 's|@''GNULIB_ISNANL''@|$(GNULIB_ISNANL)|g' \
451 -e 's|@''GNULIB_LDEXPL''@|$(GNULIB_LDEXPL)|g' \ 521 -e 's|@''GNULIB_LDEXPL''@|$(GNULIB_LDEXPL)|g' \
452 -e 's|@''GNULIB_MATHL''@|$(GNULIB_MATHL)|g' \ 522 -e 's|@''GNULIB_MATHL''@|$(GNULIB_MATHL)|g' \
453 -e 's|@''GNULIB_ROUND''@|$(GNULIB_ROUND)|g' \ 523 -e 's|@''GNULIB_ROUND''@|$(GNULIB_ROUND)|g' \
@@ -457,6 +527,9 @@ math.h: math.in.h
457 -e 's|@''GNULIB_TRUNC''@|$(GNULIB_TRUNC)|g' \ 527 -e 's|@''GNULIB_TRUNC''@|$(GNULIB_TRUNC)|g' \
458 -e 's|@''GNULIB_TRUNCF''@|$(GNULIB_TRUNCF)|g' \ 528 -e 's|@''GNULIB_TRUNCF''@|$(GNULIB_TRUNCF)|g' \
459 -e 's|@''GNULIB_TRUNCL''@|$(GNULIB_TRUNCL)|g' \ 529 -e 's|@''GNULIB_TRUNCL''@|$(GNULIB_TRUNCL)|g' \
530 -e 's|@''HAVE_ISNANF''@|$(HAVE_ISNANF)|g' \
531 -e 's|@''HAVE_ISNAND''@|$(HAVE_ISNAND)|g' \
532 -e 's|@''HAVE_ISNANL''@|$(HAVE_ISNANL)|g' \
460 -e 's|@''HAVE_DECL_ACOSL''@|$(HAVE_DECL_ACOSL)|g' \ 533 -e 's|@''HAVE_DECL_ACOSL''@|$(HAVE_DECL_ACOSL)|g' \
461 -e 's|@''HAVE_DECL_ASINL''@|$(HAVE_DECL_ASINL)|g' \ 534 -e 's|@''HAVE_DECL_ASINL''@|$(HAVE_DECL_ASINL)|g' \
462 -e 's|@''HAVE_DECL_ATANL''@|$(HAVE_DECL_ATANL)|g' \ 535 -e 's|@''HAVE_DECL_ATANL''@|$(HAVE_DECL_ATANL)|g' \
@@ -470,20 +543,24 @@ math.h: math.in.h
470 -e 's|@''HAVE_DECL_TANL''@|$(HAVE_DECL_TANL)|g' \ 543 -e 's|@''HAVE_DECL_TANL''@|$(HAVE_DECL_TANL)|g' \
471 -e 's|@''HAVE_DECL_TRUNC''@|$(HAVE_DECL_TRUNC)|g' \ 544 -e 's|@''HAVE_DECL_TRUNC''@|$(HAVE_DECL_TRUNC)|g' \
472 -e 's|@''HAVE_DECL_TRUNCF''@|$(HAVE_DECL_TRUNCF)|g' \ 545 -e 's|@''HAVE_DECL_TRUNCF''@|$(HAVE_DECL_TRUNCF)|g' \
473 -e 's|@''HAVE_DECL_TRUNCL''@|$(HAVE_DECL_TRUNCL)|g' \
474 -e 's|@''REPLACE_CEILF''@|$(REPLACE_CEILF)|g' \ 546 -e 's|@''REPLACE_CEILF''@|$(REPLACE_CEILF)|g' \
475 -e 's|@''REPLACE_CEILL''@|$(REPLACE_CEILL)|g' \ 547 -e 's|@''REPLACE_CEILL''@|$(REPLACE_CEILL)|g' \
476 -e 's|@''REPLACE_FLOORF''@|$(REPLACE_FLOORF)|g' \ 548 -e 's|@''REPLACE_FLOORF''@|$(REPLACE_FLOORF)|g' \
477 -e 's|@''REPLACE_FLOORL''@|$(REPLACE_FLOORL)|g' \ 549 -e 's|@''REPLACE_FLOORL''@|$(REPLACE_FLOORL)|g' \
478 -e 's|@''REPLACE_FREXP''@|$(REPLACE_FREXP)|g' \ 550 -e 's|@''REPLACE_FREXP''@|$(REPLACE_FREXP)|g' \
479 -e 's|@''REPLACE_FREXPL''@|$(REPLACE_FREXPL)|g' \ 551 -e 's|@''REPLACE_FREXPL''@|$(REPLACE_FREXPL)|g' \
552 -e 's|@''REPLACE_HUGE_VAL''@|$(REPLACE_HUGE_VAL)|g' \
480 -e 's|@''REPLACE_ISFINITE''@|$(REPLACE_ISFINITE)|g' \ 553 -e 's|@''REPLACE_ISFINITE''@|$(REPLACE_ISFINITE)|g' \
554 -e 's|@''REPLACE_ISINF''@|$(REPLACE_ISINF)|g' \
555 -e 's|@''REPLACE_ISNAN''@|$(REPLACE_ISNAN)|g' \
481 -e 's|@''REPLACE_LDEXPL''@|$(REPLACE_LDEXPL)|g' \ 556 -e 's|@''REPLACE_LDEXPL''@|$(REPLACE_LDEXPL)|g' \
557 -e 's|@''REPLACE_NAN''@|$(REPLACE_NAN)|g' \
482 -e 's|@''REPLACE_ROUND''@|$(REPLACE_ROUND)|g' \ 558 -e 's|@''REPLACE_ROUND''@|$(REPLACE_ROUND)|g' \
483 -e 's|@''REPLACE_ROUNDF''@|$(REPLACE_ROUNDF)|g' \ 559 -e 's|@''REPLACE_ROUNDF''@|$(REPLACE_ROUNDF)|g' \
484 -e 's|@''REPLACE_ROUNDL''@|$(REPLACE_ROUNDL)|g' \ 560 -e 's|@''REPLACE_ROUNDL''@|$(REPLACE_ROUNDL)|g' \
485 -e 's|@''REPLACE_SIGNBIT''@|$(REPLACE_SIGNBIT)|g' \ 561 -e 's|@''REPLACE_SIGNBIT''@|$(REPLACE_SIGNBIT)|g' \
486 -e 's|@''REPLACE_SIGNBIT_USING_GCC''@|$(REPLACE_SIGNBIT_USING_GCC)|g' \ 562 -e 's|@''REPLACE_SIGNBIT_USING_GCC''@|$(REPLACE_SIGNBIT_USING_GCC)|g' \
563 -e 's|@''REPLACE_TRUNCL''@|$(REPLACE_TRUNCL)|g' \
487 -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ 564 -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
488 < $(srcdir)/math.in.h; \ 565 < $(srcdir)/math.in.h; \
489 } > $@-t 566 } > $@-t
@@ -494,6 +571,24 @@ EXTRA_DIST += math.in.h
494 571
495## end gnulib module math 572## end gnulib module math
496 573
574## begin gnulib module mbrtowc
575
576
577EXTRA_DIST += mbrtowc.c
578
579EXTRA_libgnu_a_SOURCES += mbrtowc.c
580
581## end gnulib module mbrtowc
582
583## begin gnulib module mbsinit
584
585
586EXTRA_DIST += mbsinit.c
587
588EXTRA_libgnu_a_SOURCES += mbsinit.c
589
590## end gnulib module mbsinit
591
497## begin gnulib module mountlist 592## begin gnulib module mountlist
498 593
499 594
@@ -503,6 +598,34 @@ EXTRA_libgnu_a_SOURCES += mountlist.c
503 598
504## end gnulib module mountlist 599## end gnulib module mountlist
505 600
601## begin gnulib module netdb
602
603BUILT_SOURCES += $(NETDB_H)
604
605# We need the following in order to create <netdb.h> when the system
606# doesn't have one that works with the given compiler.
607netdb.h: netdb.in.h
608 rm -f $@-t $@
609 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
610 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
611 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
612 -e 's|@''NEXT_NETDB_H''@|$(NEXT_NETDB_H)|g' \
613 -e 's|@''HAVE_NETDB_H''@|$(HAVE_NETDB_H)|g' \
614 -e 's|@''GNULIB_GETADDRINFO''@|$(GNULIB_GETADDRINFO)|g' \
615 -e 's|@''HAVE_STRUCT_ADDRINFO''@|$(HAVE_STRUCT_ADDRINFO)|g' \
616 -e 's|@''HAVE_DECL_FREEADDRINFO''@|$(HAVE_DECL_FREEADDRINFO)|g' \
617 -e 's|@''HAVE_DECL_GAI_STRERROR''@|$(HAVE_DECL_GAI_STRERROR)|g' \
618 -e 's|@''HAVE_DECL_GETADDRINFO''@|$(HAVE_DECL_GETADDRINFO)|g' \
619 -e 's|@''HAVE_DECL_GETNAMEINFO''@|$(HAVE_DECL_GETNAMEINFO)|g' \
620 < $(srcdir)/netdb.in.h; \
621 } > $@-t
622 mv $@-t $@
623MOSTLYCLEANFILES += netdb.h netdb.h-t
624
625EXTRA_DIST += netdb.in.h
626
627## end gnulib module netdb
628
506## begin gnulib module netinet_in 629## begin gnulib module netinet_in
507 630
508BUILT_SOURCES += $(NETINET_IN_H) 631BUILT_SOURCES += $(NETINET_IN_H)
@@ -513,7 +636,8 @@ netinet/in.h: netinet_in.in.h
513 @MKDIR_P@ netinet 636 @MKDIR_P@ netinet
514 rm -f $@-t $@ 637 rm -f $@-t $@
515 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 638 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
516 sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \ 639 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
640 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
517 -e 's|@''NEXT_NETINET_IN_H''@|$(NEXT_NETINET_IN_H)|g' \ 641 -e 's|@''NEXT_NETINET_IN_H''@|$(NEXT_NETINET_IN_H)|g' \
518 -e 's|@''HAVE_NETINET_IN_H''@|$(HAVE_NETINET_IN_H)|g' \ 642 -e 's|@''HAVE_NETINET_IN_H''@|$(HAVE_NETINET_IN_H)|g' \
519 < $(srcdir)/netinet_in.in.h; \ 643 < $(srcdir)/netinet_in.in.h; \
@@ -526,6 +650,15 @@ EXTRA_DIST += netinet_in.in.h
526 650
527## end gnulib module netinet_in 651## end gnulib module netinet_in
528 652
653## begin gnulib module open
654
655
656EXTRA_DIST += open.c
657
658EXTRA_libgnu_a_SOURCES += open.c
659
660## end gnulib module open
661
529## begin gnulib module regex 662## begin gnulib module regex
530 663
531 664
@@ -596,7 +729,8 @@ stdint.h: stdint.in.h
596 rm -f $@-t $@ 729 rm -f $@-t $@
597 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 730 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
598 sed -e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \ 731 sed -e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \
599 -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \ 732 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
733 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
600 -e 's|@''NEXT_STDINT_H''@|$(NEXT_STDINT_H)|g' \ 734 -e 's|@''NEXT_STDINT_H''@|$(NEXT_STDINT_H)|g' \
601 -e 's/@''HAVE_SYS_TYPES_H''@/$(HAVE_SYS_TYPES_H)/g' \ 735 -e 's/@''HAVE_SYS_TYPES_H''@/$(HAVE_SYS_TYPES_H)/g' \
602 -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \ 736 -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \
@@ -604,6 +738,7 @@ stdint.h: stdint.in.h
604 -e 's/@''HAVE_SYS_BITYPES_H''@/$(HAVE_SYS_BITYPES_H)/g' \ 738 -e 's/@''HAVE_SYS_BITYPES_H''@/$(HAVE_SYS_BITYPES_H)/g' \
605 -e 's/@''HAVE_LONG_LONG_INT''@/$(HAVE_LONG_LONG_INT)/g' \ 739 -e 's/@''HAVE_LONG_LONG_INT''@/$(HAVE_LONG_LONG_INT)/g' \
606 -e 's/@''HAVE_UNSIGNED_LONG_LONG_INT''@/$(HAVE_UNSIGNED_LONG_LONG_INT)/g' \ 740 -e 's/@''HAVE_UNSIGNED_LONG_LONG_INT''@/$(HAVE_UNSIGNED_LONG_LONG_INT)/g' \
741 -e 's/@''APPLE_UNIVERSAL_BUILD''@/$(APPLE_UNIVERSAL_BUILD)/g' \
607 -e 's/@''BITSIZEOF_PTRDIFF_T''@/$(BITSIZEOF_PTRDIFF_T)/g' \ 742 -e 's/@''BITSIZEOF_PTRDIFF_T''@/$(BITSIZEOF_PTRDIFF_T)/g' \
608 -e 's/@''PTRDIFF_T_SUFFIX''@/$(PTRDIFF_T_SUFFIX)/g' \ 743 -e 's/@''PTRDIFF_T_SUFFIX''@/$(PTRDIFF_T_SUFFIX)/g' \
609 -e 's/@''BITSIZEOF_SIG_ATOMIC_T''@/$(BITSIZEOF_SIG_ATOMIC_T)/g' \ 744 -e 's/@''BITSIZEOF_SIG_ATOMIC_T''@/$(BITSIZEOF_SIG_ATOMIC_T)/g' \
@@ -635,17 +770,24 @@ BUILT_SOURCES += stdio.h
635stdio.h: stdio.in.h 770stdio.h: stdio.in.h
636 rm -f $@-t $@ 771 rm -f $@-t $@
637 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 772 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
638 sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \ 773 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
774 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
639 -e 's|@''NEXT_STDIO_H''@|$(NEXT_STDIO_H)|g' \ 775 -e 's|@''NEXT_STDIO_H''@|$(NEXT_STDIO_H)|g' \
776 -e 's|@''GNULIB_FPRINTF''@|$(GNULIB_FPRINTF)|g' \
640 -e 's|@''GNULIB_FPRINTF_POSIX''@|$(GNULIB_FPRINTF_POSIX)|g' \ 777 -e 's|@''GNULIB_FPRINTF_POSIX''@|$(GNULIB_FPRINTF_POSIX)|g' \
778 -e 's|@''GNULIB_PRINTF''@|$(GNULIB_PRINTF)|g' \
641 -e 's|@''GNULIB_PRINTF_POSIX''@|$(GNULIB_PRINTF_POSIX)|g' \ 779 -e 's|@''GNULIB_PRINTF_POSIX''@|$(GNULIB_PRINTF_POSIX)|g' \
642 -e 's|@''GNULIB_SNPRINTF''@|$(GNULIB_SNPRINTF)|g' \ 780 -e 's|@''GNULIB_SNPRINTF''@|$(GNULIB_SNPRINTF)|g' \
643 -e 's|@''GNULIB_SPRINTF_POSIX''@|$(GNULIB_SPRINTF_POSIX)|g' \ 781 -e 's|@''GNULIB_SPRINTF_POSIX''@|$(GNULIB_SPRINTF_POSIX)|g' \
782 -e 's|@''GNULIB_VFPRINTF''@|$(GNULIB_VFPRINTF)|g' \
644 -e 's|@''GNULIB_VFPRINTF_POSIX''@|$(GNULIB_VFPRINTF_POSIX)|g' \ 783 -e 's|@''GNULIB_VFPRINTF_POSIX''@|$(GNULIB_VFPRINTF_POSIX)|g' \
784 -e 's|@''GNULIB_VPRINTF''@|$(GNULIB_VPRINTF)|g' \
645 -e 's|@''GNULIB_VPRINTF_POSIX''@|$(GNULIB_VPRINTF_POSIX)|g' \ 785 -e 's|@''GNULIB_VPRINTF_POSIX''@|$(GNULIB_VPRINTF_POSIX)|g' \
646 -e 's|@''GNULIB_VSNPRINTF''@|$(GNULIB_VSNPRINTF)|g' \ 786 -e 's|@''GNULIB_VSNPRINTF''@|$(GNULIB_VSNPRINTF)|g' \
647 -e 's|@''GNULIB_VSPRINTF_POSIX''@|$(GNULIB_VSPRINTF_POSIX)|g' \ 787 -e 's|@''GNULIB_VSPRINTF_POSIX''@|$(GNULIB_VSPRINTF_POSIX)|g' \
648 -e 's|@''GNULIB_VASPRINTF''@|$(GNULIB_VASPRINTF)|g' \ 788 -e 's|@''GNULIB_VASPRINTF''@|$(GNULIB_VASPRINTF)|g' \
789 -e 's|@''GNULIB_OBSTACK_PRINTF''@|$(GNULIB_OBSTACK_PRINTF)|g' \
790 -e 's|@''GNULIB_OBSTACK_PRINTF_POSIX''@|$(GNULIB_OBSTACK_PRINTF_POSIX)|g' \
649 -e 's|@''GNULIB_FOPEN''@|$(GNULIB_FOPEN)|g' \ 791 -e 's|@''GNULIB_FOPEN''@|$(GNULIB_FOPEN)|g' \
650 -e 's|@''GNULIB_FREOPEN''@|$(GNULIB_FREOPEN)|g' \ 792 -e 's|@''GNULIB_FREOPEN''@|$(GNULIB_FREOPEN)|g' \
651 -e 's|@''GNULIB_FSEEK''@|$(GNULIB_FSEEK)|g' \ 793 -e 's|@''GNULIB_FSEEK''@|$(GNULIB_FSEEK)|g' \
@@ -653,8 +795,18 @@ stdio.h: stdio.in.h
653 -e 's|@''GNULIB_FTELL''@|$(GNULIB_FTELL)|g' \ 795 -e 's|@''GNULIB_FTELL''@|$(GNULIB_FTELL)|g' \
654 -e 's|@''GNULIB_FTELLO''@|$(GNULIB_FTELLO)|g' \ 796 -e 's|@''GNULIB_FTELLO''@|$(GNULIB_FTELLO)|g' \
655 -e 's|@''GNULIB_FFLUSH''@|$(GNULIB_FFLUSH)|g' \ 797 -e 's|@''GNULIB_FFLUSH''@|$(GNULIB_FFLUSH)|g' \
798 -e 's|@''GNULIB_FCLOSE''@|$(GNULIB_FCLOSE)|g' \
799 -e 's|@''GNULIB_FPUTC''@|$(GNULIB_FPUTC)|g' \
800 -e 's|@''GNULIB_PUTC''@|$(GNULIB_PUTC)|g' \
801 -e 's|@''GNULIB_PUTCHAR''@|$(GNULIB_PUTCHAR)|g' \
802 -e 's|@''GNULIB_FPUTS''@|$(GNULIB_FPUTS)|g' \
803 -e 's|@''GNULIB_PUTS''@|$(GNULIB_PUTS)|g' \
804 -e 's|@''GNULIB_FWRITE''@|$(GNULIB_FWRITE)|g' \
656 -e 's|@''GNULIB_GETDELIM''@|$(GNULIB_GETDELIM)|g' \ 805 -e 's|@''GNULIB_GETDELIM''@|$(GNULIB_GETDELIM)|g' \
657 -e 's|@''GNULIB_GETLINE''@|$(GNULIB_GETLINE)|g' \ 806 -e 's|@''GNULIB_GETLINE''@|$(GNULIB_GETLINE)|g' \
807 -e 's|@''GNULIB_PERROR''@|$(GNULIB_PERROR)|g' \
808 -e 's|@''GNULIB_STDIO_H_SIGPIPE''@|$(GNULIB_STDIO_H_SIGPIPE)|g' \
809 -e 's|@''REPLACE_STDIO_WRITE_FUNCS''@|$(REPLACE_STDIO_WRITE_FUNCS)|g' \
658 -e 's|@''REPLACE_FPRINTF''@|$(REPLACE_FPRINTF)|g' \ 810 -e 's|@''REPLACE_FPRINTF''@|$(REPLACE_FPRINTF)|g' \
659 -e 's|@''REPLACE_VFPRINTF''@|$(REPLACE_VFPRINTF)|g' \ 811 -e 's|@''REPLACE_VFPRINTF''@|$(REPLACE_VFPRINTF)|g' \
660 -e 's|@''REPLACE_PRINTF''@|$(REPLACE_PRINTF)|g' \ 812 -e 's|@''REPLACE_PRINTF''@|$(REPLACE_PRINTF)|g' \
@@ -667,6 +819,8 @@ stdio.h: stdio.in.h
667 -e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \ 819 -e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \
668 -e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \ 820 -e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \
669 -e 's|@''REPLACE_VASPRINTF''@|$(REPLACE_VASPRINTF)|g' \ 821 -e 's|@''REPLACE_VASPRINTF''@|$(REPLACE_VASPRINTF)|g' \
822 -e 's|@''HAVE_DECL_OBSTACK_PRINTF''@|$(HAVE_DECL_OBSTACK_PRINTF)|g' \
823 -e 's|@''REPLACE_OBSTACK_PRINTF''@|$(REPLACE_OBSTACK_PRINTF)|g' \
670 -e 's|@''REPLACE_FOPEN''@|$(REPLACE_FOPEN)|g' \ 824 -e 's|@''REPLACE_FOPEN''@|$(REPLACE_FOPEN)|g' \
671 -e 's|@''REPLACE_FREOPEN''@|$(REPLACE_FREOPEN)|g' \ 825 -e 's|@''REPLACE_FREOPEN''@|$(REPLACE_FREOPEN)|g' \
672 -e 's|@''REPLACE_FSEEKO''@|$(REPLACE_FSEEKO)|g' \ 826 -e 's|@''REPLACE_FSEEKO''@|$(REPLACE_FSEEKO)|g' \
@@ -674,16 +828,20 @@ stdio.h: stdio.in.h
674 -e 's|@''REPLACE_FTELLO''@|$(REPLACE_FTELLO)|g' \ 828 -e 's|@''REPLACE_FTELLO''@|$(REPLACE_FTELLO)|g' \
675 -e 's|@''REPLACE_FTELL''@|$(REPLACE_FTELL)|g' \ 829 -e 's|@''REPLACE_FTELL''@|$(REPLACE_FTELL)|g' \
676 -e 's|@''REPLACE_FFLUSH''@|$(REPLACE_FFLUSH)|g' \ 830 -e 's|@''REPLACE_FFLUSH''@|$(REPLACE_FFLUSH)|g' \
831 -e 's|@''REPLACE_FCLOSE''@|$(REPLACE_FCLOSE)|g' \
677 -e 's|@''HAVE_DECL_GETDELIM''@|$(HAVE_DECL_GETDELIM)|g' \ 832 -e 's|@''HAVE_DECL_GETDELIM''@|$(HAVE_DECL_GETDELIM)|g' \
678 -e 's|@''HAVE_DECL_GETLINE''@|$(HAVE_DECL_GETLINE)|g' \ 833 -e 's|@''HAVE_DECL_GETLINE''@|$(HAVE_DECL_GETLINE)|g' \
679 -e 's|@''REPLACE_GETLINE''@|$(REPLACE_GETLINE)|g' \ 834 -e 's|@''REPLACE_GETLINE''@|$(REPLACE_GETLINE)|g' \
835 -e 's|@''REPLACE_PERROR''@|$(REPLACE_PERROR)|g' \
680 -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ 836 -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
681 < $(srcdir)/stdio.in.h; \ 837 < $(srcdir)/stdio.in.h; \
682 } > $@-t 838 } > $@-t
683 mv $@-t $@ 839 mv $@-t $@
684MOSTLYCLEANFILES += stdio.h stdio.h-t 840MOSTLYCLEANFILES += stdio.h stdio.h-t
685 841
686EXTRA_DIST += stdio.in.h 842EXTRA_DIST += stdio-write.c stdio.in.h
843
844EXTRA_libgnu_a_SOURCES += stdio-write.c
687 845
688## end gnulib module stdio 846## end gnulib module stdio
689 847
@@ -696,26 +854,44 @@ BUILT_SOURCES += stdlib.h
696stdlib.h: stdlib.in.h 854stdlib.h: stdlib.in.h
697 rm -f $@-t $@ 855 rm -f $@-t $@
698 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 856 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
699 sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \ 857 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
858 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
700 -e 's|@''NEXT_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \ 859 -e 's|@''NEXT_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \
701 -e 's|@''GNULIB_MALLOC_POSIX''@|$(GNULIB_MALLOC_POSIX)|g' \ 860 -e 's|@''GNULIB_MALLOC_POSIX''@|$(GNULIB_MALLOC_POSIX)|g' \
702 -e 's|@''GNULIB_REALLOC_POSIX''@|$(GNULIB_REALLOC_POSIX)|g' \ 861 -e 's|@''GNULIB_REALLOC_POSIX''@|$(GNULIB_REALLOC_POSIX)|g' \
703 -e 's|@''GNULIB_CALLOC_POSIX''@|$(GNULIB_CALLOC_POSIX)|g' \ 862 -e 's|@''GNULIB_CALLOC_POSIX''@|$(GNULIB_CALLOC_POSIX)|g' \
863 -e 's|@''GNULIB_ATOLL''@|$(GNULIB_ATOLL)|g' \
864 -e 's|@''GNULIB_GETLOADAVG''@|$(GNULIB_GETLOADAVG)|g' \
704 -e 's|@''GNULIB_GETSUBOPT''@|$(GNULIB_GETSUBOPT)|g' \ 865 -e 's|@''GNULIB_GETSUBOPT''@|$(GNULIB_GETSUBOPT)|g' \
705 -e 's|@''GNULIB_MKDTEMP''@|$(GNULIB_MKDTEMP)|g' \ 866 -e 's|@''GNULIB_MKDTEMP''@|$(GNULIB_MKDTEMP)|g' \
706 -e 's|@''GNULIB_MKSTEMP''@|$(GNULIB_MKSTEMP)|g' \ 867 -e 's|@''GNULIB_MKSTEMP''@|$(GNULIB_MKSTEMP)|g' \
707 -e 's|@''GNULIB_PUTENV''@|$(GNULIB_PUTENV)|g' \ 868 -e 's|@''GNULIB_PUTENV''@|$(GNULIB_PUTENV)|g' \
869 -e 's|@''GNULIB_RANDOM_R''@|$(GNULIB_RANDOM_R)|g' \
870 -e 's|@''GNULIB_RPMATCH''@|$(GNULIB_RPMATCH)|g' \
708 -e 's|@''GNULIB_SETENV''@|$(GNULIB_SETENV)|g' \ 871 -e 's|@''GNULIB_SETENV''@|$(GNULIB_SETENV)|g' \
872 -e 's|@''GNULIB_STRTOD''@|$(GNULIB_STRTOD)|g' \
873 -e 's|@''GNULIB_STRTOLL''@|$(GNULIB_STRTOLL)|g' \
874 -e 's|@''GNULIB_STRTOULL''@|$(GNULIB_STRTOULL)|g' \
709 -e 's|@''GNULIB_UNSETENV''@|$(GNULIB_UNSETENV)|g' \ 875 -e 's|@''GNULIB_UNSETENV''@|$(GNULIB_UNSETENV)|g' \
876 -e 's|@''HAVE_ATOLL''@|$(HAVE_ATOLL)|g' \
710 -e 's|@''HAVE_CALLOC_POSIX''@|$(HAVE_CALLOC_POSIX)|g' \ 877 -e 's|@''HAVE_CALLOC_POSIX''@|$(HAVE_CALLOC_POSIX)|g' \
711 -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \ 878 -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \
712 -e 's|@''HAVE_MALLOC_POSIX''@|$(HAVE_MALLOC_POSIX)|g' \ 879 -e 's|@''HAVE_MALLOC_POSIX''@|$(HAVE_MALLOC_POSIX)|g' \
713 -e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \ 880 -e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \
714 -e 's|@''HAVE_REALLOC_POSIX''@|$(HAVE_REALLOC_POSIX)|g' \ 881 -e 's|@''HAVE_REALLOC_POSIX''@|$(HAVE_REALLOC_POSIX)|g' \
882 -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \
883 -e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \
715 -e 's|@''HAVE_SETENV''@|$(HAVE_SETENV)|g' \ 884 -e 's|@''HAVE_SETENV''@|$(HAVE_SETENV)|g' \
885 -e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \
886 -e 's|@''HAVE_STRTOLL''@|$(HAVE_STRTOLL)|g' \
887 -e 's|@''HAVE_STRTOULL''@|$(HAVE_STRTOULL)|g' \
888 -e 's|@''HAVE_STRUCT_RANDOM_DATA''@|$(HAVE_STRUCT_RANDOM_DATA)|g' \
889 -e 's|@''HAVE_SYS_LOADAVG_H''@|$(HAVE_SYS_LOADAVG_H)|g' \
716 -e 's|@''HAVE_UNSETENV''@|$(HAVE_UNSETENV)|g' \ 890 -e 's|@''HAVE_UNSETENV''@|$(HAVE_UNSETENV)|g' \
891 -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \
717 -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \ 892 -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \
718 -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \ 893 -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \
894 -e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \
719 -e 's|@''VOID_UNSETENV''@|$(VOID_UNSETENV)|g' \ 895 -e 's|@''VOID_UNSETENV''@|$(VOID_UNSETENV)|g' \
720 -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ 896 -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
721 < $(srcdir)/stdlib.in.h; \ 897 < $(srcdir)/stdlib.in.h; \
@@ -727,14 +903,12 @@ EXTRA_DIST += stdlib.in.h
727 903
728## end gnulib module stdlib 904## end gnulib module stdlib
729 905
730## begin gnulib module strdup 906## begin gnulib module streq
731
732 907
733EXTRA_DIST += strdup.c
734 908
735EXTRA_libgnu_a_SOURCES += strdup.c 909EXTRA_DIST += streq.h
736 910
737## end gnulib module strdup 911## end gnulib module streq
738 912
739## begin gnulib module strerror 913## begin gnulib module strerror
740 914
@@ -754,7 +928,8 @@ BUILT_SOURCES += string.h
754string.h: string.in.h 928string.h: string.in.h
755 rm -f $@-t $@ 929 rm -f $@-t $@
756 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 930 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
757 sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \ 931 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
932 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
758 -e 's|@''NEXT_STRING_H''@|$(NEXT_STRING_H)|g' \ 933 -e 's|@''NEXT_STRING_H''@|$(NEXT_STRING_H)|g' \
759 -e 's|@''GNULIB_MBSLEN''@|$(GNULIB_MBSLEN)|g' \ 934 -e 's|@''GNULIB_MBSLEN''@|$(GNULIB_MBSLEN)|g' \
760 -e 's|@''GNULIB_MBSNLEN''@|$(GNULIB_MBSNLEN)|g' \ 935 -e 's|@''GNULIB_MBSNLEN''@|$(GNULIB_MBSNLEN)|g' \
@@ -773,6 +948,7 @@ string.h: string.in.h
773 -e 's|@''GNULIB_MEMMEM''@|$(GNULIB_MEMMEM)|g' \ 948 -e 's|@''GNULIB_MEMMEM''@|$(GNULIB_MEMMEM)|g' \
774 -e 's|@''GNULIB_MEMPCPY''@|$(GNULIB_MEMPCPY)|g' \ 949 -e 's|@''GNULIB_MEMPCPY''@|$(GNULIB_MEMPCPY)|g' \
775 -e 's|@''GNULIB_MEMRCHR''@|$(GNULIB_MEMRCHR)|g' \ 950 -e 's|@''GNULIB_MEMRCHR''@|$(GNULIB_MEMRCHR)|g' \
951 -e 's|@''GNULIB_RAWMEMCHR''@|$(GNULIB_RAWMEMCHR)|g' \
776 -e 's|@''GNULIB_STPCPY''@|$(GNULIB_STPCPY)|g' \ 952 -e 's|@''GNULIB_STPCPY''@|$(GNULIB_STPCPY)|g' \
777 -e 's|@''GNULIB_STPNCPY''@|$(GNULIB_STPNCPY)|g' \ 953 -e 's|@''GNULIB_STPNCPY''@|$(GNULIB_STPNCPY)|g' \
778 -e 's|@''GNULIB_STRCHRNUL''@|$(GNULIB_STRCHRNUL)|g' \ 954 -e 's|@''GNULIB_STRCHRNUL''@|$(GNULIB_STRCHRNUL)|g' \
@@ -786,9 +962,11 @@ string.h: string.in.h
786 -e 's|@''GNULIB_STRTOK_R''@|$(GNULIB_STRTOK_R)|g' \ 962 -e 's|@''GNULIB_STRTOK_R''@|$(GNULIB_STRTOK_R)|g' \
787 -e 's|@''GNULIB_STRERROR''@|$(GNULIB_STRERROR)|g' \ 963 -e 's|@''GNULIB_STRERROR''@|$(GNULIB_STRERROR)|g' \
788 -e 's|@''GNULIB_STRSIGNAL''@|$(GNULIB_STRSIGNAL)|g' \ 964 -e 's|@''GNULIB_STRSIGNAL''@|$(GNULIB_STRSIGNAL)|g' \
965 -e 's|@''GNULIB_STRVERSCMP''@|$(GNULIB_STRVERSCMP)|g' \
789 -e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \ 966 -e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \
790 -e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \ 967 -e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \
791 -e 's|@''HAVE_DECL_MEMRCHR''@|$(HAVE_DECL_MEMRCHR)|g' \ 968 -e 's|@''HAVE_DECL_MEMRCHR''@|$(HAVE_DECL_MEMRCHR)|g' \
969 -e 's|@''HAVE_RAWMEMCHR''@|$(HAVE_RAWMEMCHR)|g' \
792 -e 's|@''HAVE_STPCPY''@|$(HAVE_STPCPY)|g' \ 970 -e 's|@''HAVE_STPCPY''@|$(HAVE_STPCPY)|g' \
793 -e 's|@''HAVE_STPNCPY''@|$(HAVE_STPNCPY)|g' \ 971 -e 's|@''HAVE_STPNCPY''@|$(HAVE_STPNCPY)|g' \
794 -e 's|@''HAVE_STRCHRNUL''@|$(HAVE_STRCHRNUL)|g' \ 972 -e 's|@''HAVE_STRCHRNUL''@|$(HAVE_STRCHRNUL)|g' \
@@ -802,8 +980,10 @@ string.h: string.in.h
802 -e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \ 980 -e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \
803 -e 's|@''HAVE_DECL_STRERROR''@|$(HAVE_DECL_STRERROR)|g' \ 981 -e 's|@''HAVE_DECL_STRERROR''@|$(HAVE_DECL_STRERROR)|g' \
804 -e 's|@''HAVE_DECL_STRSIGNAL''@|$(HAVE_DECL_STRSIGNAL)|g' \ 982 -e 's|@''HAVE_DECL_STRSIGNAL''@|$(HAVE_DECL_STRSIGNAL)|g' \
983 -e 's|@''HAVE_STRVERSCMP''@|$(HAVE_STRVERSCMP)|g' \
805 -e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \ 984 -e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \
806 -e 's|@''REPLACE_STRCASESTR''@|$(REPLACE_STRCASESTR)|g' \ 985 -e 's|@''REPLACE_STRCASESTR''@|$(REPLACE_STRCASESTR)|g' \
986 -e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \
807 -e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \ 987 -e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \
808 -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \ 988 -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \
809 -e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \ 989 -e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \
@@ -844,11 +1024,28 @@ BUILT_SOURCES += $(SYS_SOCKET_H)
844sys/socket.h: sys_socket.in.h 1024sys/socket.h: sys_socket.in.h
845 @MKDIR_P@ sys 1025 @MKDIR_P@ sys
846 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 1026 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
847 sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \ 1027 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1028 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
848 -e 's|@''NEXT_SYS_SOCKET_H''@|$(NEXT_SYS_SOCKET_H)|g' \ 1029 -e 's|@''NEXT_SYS_SOCKET_H''@|$(NEXT_SYS_SOCKET_H)|g' \
849 -e 's|@''HAVE_SYS_SOCKET_H''@|$(HAVE_SYS_SOCKET_H)|g' \ 1030 -e 's|@''HAVE_SYS_SOCKET_H''@|$(HAVE_SYS_SOCKET_H)|g' \
1031 -e 's|@''GNULIB_CLOSE''@|$(GNULIB_CLOSE)|g' \
1032 -e 's|@''GNULIB_SOCKET''@|$(GNULIB_SOCKET)|g' \
1033 -e 's|@''GNULIB_CONNECT''@|$(GNULIB_CONNECT)|g' \
1034 -e 's|@''GNULIB_ACCEPT''@|$(GNULIB_ACCEPT)|g' \
1035 -e 's|@''GNULIB_BIND''@|$(GNULIB_BIND)|g' \
1036 -e 's|@''GNULIB_GETPEERNAME''@|$(GNULIB_GETPEERNAME)|g' \
1037 -e 's|@''GNULIB_GETSOCKNAME''@|$(GNULIB_GETSOCKNAME)|g' \
1038 -e 's|@''GNULIB_GETSOCKOPT''@|$(GNULIB_GETSOCKOPT)|g' \
1039 -e 's|@''GNULIB_LISTEN''@|$(GNULIB_LISTEN)|g' \
1040 -e 's|@''GNULIB_RECV''@|$(GNULIB_RECV)|g' \
1041 -e 's|@''GNULIB_SEND''@|$(GNULIB_SEND)|g' \
1042 -e 's|@''GNULIB_RECVFROM''@|$(GNULIB_RECVFROM)|g' \
1043 -e 's|@''GNULIB_SENDTO''@|$(GNULIB_SENDTO)|g' \
1044 -e 's|@''GNULIB_SETSOCKOPT''@|$(GNULIB_SETSOCKOPT)|g' \
1045 -e 's|@''GNULIB_SHUTDOWN''@|$(GNULIB_SHUTDOWN)|g' \
850 -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \ 1046 -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \
851 -e 's|@''HAVE_WS2TCPIP_H''@|$(HAVE_WS2TCPIP_H)|g' \ 1047 -e 's|@''HAVE_WS2TCPIP_H''@|$(HAVE_WS2TCPIP_H)|g' \
1048 -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
852 < $(srcdir)/sys_socket.in.h; \ 1049 < $(srcdir)/sys_socket.in.h; \
853 } > $@-t 1050 } > $@-t
854 mv -f $@-t $@ 1051 mv -f $@-t $@
@@ -869,33 +1066,55 @@ unistd.h: unistd.in.h
869 rm -f $@-t $@ 1066 rm -f $@-t $@
870 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 1067 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
871 sed -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \ 1068 sed -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \
872 -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \ 1069 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1070 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
873 -e 's|@''NEXT_UNISTD_H''@|$(NEXT_UNISTD_H)|g' \ 1071 -e 's|@''NEXT_UNISTD_H''@|$(NEXT_UNISTD_H)|g' \
874 -e 's|@''GNULIB_CHOWN''@|$(GNULIB_CHOWN)|g' \ 1072 -e 's|@''GNULIB_CHOWN''@|$(GNULIB_CHOWN)|g' \
1073 -e 's|@''GNULIB_CLOSE''@|$(GNULIB_CLOSE)|g' \
875 -e 's|@''GNULIB_DUP2''@|$(GNULIB_DUP2)|g' \ 1074 -e 's|@''GNULIB_DUP2''@|$(GNULIB_DUP2)|g' \
1075 -e 's|@''GNULIB_ENVIRON''@|$(GNULIB_ENVIRON)|g' \
1076 -e 's|@''GNULIB_EUIDACCESS''@|$(GNULIB_EUIDACCESS)|g' \
876 -e 's|@''GNULIB_FCHDIR''@|$(GNULIB_FCHDIR)|g' \ 1077 -e 's|@''GNULIB_FCHDIR''@|$(GNULIB_FCHDIR)|g' \
1078 -e 's|@''GNULIB_FSYNC''@|$(GNULIB_FSYNC)|g' \
877 -e 's|@''GNULIB_FTRUNCATE''@|$(GNULIB_FTRUNCATE)|g' \ 1079 -e 's|@''GNULIB_FTRUNCATE''@|$(GNULIB_FTRUNCATE)|g' \
878 -e 's|@''GNULIB_GETCWD''@|$(GNULIB_GETCWD)|g' \ 1080 -e 's|@''GNULIB_GETCWD''@|$(GNULIB_GETCWD)|g' \
1081 -e 's|@''GNULIB_GETDOMAINNAME''@|$(GNULIB_GETDOMAINNAME)|g' \
1082 -e 's|@''GNULIB_GETDTABLESIZE''@|$(GNULIB_GETDTABLESIZE)|g' \
1083 -e 's|@''GNULIB_GETHOSTNAME''@|$(GNULIB_GETHOSTNAME)|g' \
879 -e 's|@''GNULIB_GETLOGIN_R''@|$(GNULIB_GETLOGIN_R)|g' \ 1084 -e 's|@''GNULIB_GETLOGIN_R''@|$(GNULIB_GETLOGIN_R)|g' \
880 -e 's|@''GNULIB_GETPAGESIZE''@|$(GNULIB_GETPAGESIZE)|g' \ 1085 -e 's|@''GNULIB_GETPAGESIZE''@|$(GNULIB_GETPAGESIZE)|g' \
1086 -e 's|@''GNULIB_GETUSERSHELL''@|$(GNULIB_GETUSERSHELL)|g' \
881 -e 's|@''GNULIB_LCHOWN''@|$(GNULIB_LCHOWN)|g' \ 1087 -e 's|@''GNULIB_LCHOWN''@|$(GNULIB_LCHOWN)|g' \
882 -e 's|@''GNULIB_LSEEK''@|$(GNULIB_LSEEK)|g' \ 1088 -e 's|@''GNULIB_LSEEK''@|$(GNULIB_LSEEK)|g' \
883 -e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \ 1089 -e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \
884 -e 's|@''GNULIB_SLEEP''@|$(GNULIB_SLEEP)|g' \ 1090 -e 's|@''GNULIB_SLEEP''@|$(GNULIB_SLEEP)|g' \
1091 -e 's|@''GNULIB_UNISTD_H_SIGPIPE''@|$(GNULIB_UNISTD_H_SIGPIPE)|g' \
1092 -e 's|@''GNULIB_WRITE''@|$(GNULIB_WRITE)|g' \
885 -e 's|@''HAVE_DUP2''@|$(HAVE_DUP2)|g' \ 1093 -e 's|@''HAVE_DUP2''@|$(HAVE_DUP2)|g' \
1094 -e 's|@''HAVE_EUIDACCESS''@|$(HAVE_EUIDACCESS)|g' \
1095 -e 's|@''HAVE_FSYNC''@|$(HAVE_FSYNC)|g' \
886 -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \ 1096 -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \
1097 -e 's|@''HAVE_GETDOMAINNAME''@|$(HAVE_GETDOMAINNAME)|g' \
1098 -e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \
1099 -e 's|@''HAVE_GETHOSTNAME''@|$(HAVE_GETHOSTNAME)|g' \
887 -e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \ 1100 -e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \
1101 -e 's|@''HAVE_GETUSERSHELL''@|$(HAVE_GETUSERSHELL)|g' \
888 -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \ 1102 -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \
889 -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \ 1103 -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \
1104 -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \
890 -e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \ 1105 -e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \
891 -e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \ 1106 -e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \
892 -e 's|@''HAVE_SYS_PARAM_H''@|$(HAVE_SYS_PARAM_H)|g' \ 1107 -e 's|@''HAVE_SYS_PARAM_H''@|$(HAVE_SYS_PARAM_H)|g' \
893 -e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \ 1108 -e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \
1109 -e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \
894 -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \ 1110 -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \
895 -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \ 1111 -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \
896 -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \ 1112 -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \
897 -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \ 1113 -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \
898 -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \ 1114 -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \
1115 -e 's|@''REPLACE_WRITE''@|$(REPLACE_WRITE)|g' \
1116 -e 's|@''UNISTD_H_HAVE_WINSOCK2_H''@|$(UNISTD_H_HAVE_WINSOCK2_H)|g' \
1117 -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
899 < $(srcdir)/unistd.in.h; \ 1118 < $(srcdir)/unistd.in.h; \
900 } > $@-t 1119 } > $@-t
901 mv $@-t $@ 1120 mv $@-t $@
@@ -932,6 +1151,12 @@ EXTRA_libgnu_a_SOURCES += asprintf.c vasprintf.c
932 1151
933## end gnulib module vasprintf 1152## end gnulib module vasprintf
934 1153
1154## begin gnulib module verify
1155
1156libgnu_a_SOURCES += verify.h
1157
1158## end gnulib module verify
1159
935## begin gnulib module vsnprintf 1160## begin gnulib module vsnprintf
936 1161
937 1162
@@ -950,11 +1175,43 @@ BUILT_SOURCES += $(WCHAR_H)
950wchar.h: wchar.in.h 1175wchar.h: wchar.in.h
951 rm -f $@-t $@ 1176 rm -f $@-t $@
952 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 1177 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
953 sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \ 1178 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1179 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
954 -e 's|@''NEXT_WCHAR_H''@|$(NEXT_WCHAR_H)|g' \ 1180 -e 's|@''NEXT_WCHAR_H''@|$(NEXT_WCHAR_H)|g' \
955 -e 's/@''HAVE_WCHAR_H''@/$(HAVE_WCHAR_H)/g' \ 1181 -e 's|@''HAVE_WCHAR_H''@|$(HAVE_WCHAR_H)|g' \
1182 -e 's|@''GNULIB_BTOWC''@|$(GNULIB_BTOWC)|g' \
1183 -e 's|@''GNULIB_WCTOB''@|$(GNULIB_WCTOB)|g' \
1184 -e 's|@''GNULIB_MBSINIT''@|$(GNULIB_MBSINIT)|g' \
1185 -e 's|@''GNULIB_MBRTOWC''@|$(GNULIB_MBRTOWC)|g' \
1186 -e 's|@''GNULIB_MBRLEN''@|$(GNULIB_MBRLEN)|g' \
1187 -e 's|@''GNULIB_MBSRTOWCS''@|$(GNULIB_MBSRTOWCS)|g' \
1188 -e 's|@''GNULIB_MBSNRTOWCS''@|$(GNULIB_MBSNRTOWCS)|g' \
1189 -e 's|@''GNULIB_WCRTOMB''@|$(GNULIB_WCRTOMB)|g' \
1190 -e 's|@''GNULIB_WCSRTOMBS''@|$(GNULIB_WCSRTOMBS)|g' \
1191 -e 's|@''GNULIB_WCSNRTOMBS''@|$(GNULIB_WCSNRTOMBS)|g' \
956 -e 's|@''GNULIB_WCWIDTH''@|$(GNULIB_WCWIDTH)|g' \ 1192 -e 's|@''GNULIB_WCWIDTH''@|$(GNULIB_WCWIDTH)|g' \
1193 -e 's|@''HAVE_WINT_T''@|$(HAVE_WINT_T)|g' \
1194 -e 's|@''HAVE_BTOWC''@|$(HAVE_BTOWC)|g' \
1195 -e 's|@''HAVE_MBSINIT''@|$(HAVE_MBSINIT)|g' \
1196 -e 's|@''HAVE_MBRTOWC''@|$(HAVE_MBRTOWC)|g' \
1197 -e 's|@''HAVE_MBRLEN''@|$(HAVE_MBRLEN)|g' \
1198 -e 's|@''HAVE_MBSRTOWCS''@|$(HAVE_MBSRTOWCS)|g' \
1199 -e 's|@''HAVE_MBSNRTOWCS''@|$(HAVE_MBSNRTOWCS)|g' \
1200 -e 's|@''HAVE_WCRTOMB''@|$(HAVE_WCRTOMB)|g' \
1201 -e 's|@''HAVE_WCSRTOMBS''@|$(HAVE_WCSRTOMBS)|g' \
1202 -e 's|@''HAVE_WCSNRTOMBS''@|$(HAVE_WCSNRTOMBS)|g' \
1203 -e 's|@''HAVE_DECL_WCTOB''@|$(HAVE_DECL_WCTOB)|g' \
957 -e 's|@''HAVE_DECL_WCWIDTH''@|$(HAVE_DECL_WCWIDTH)|g' \ 1204 -e 's|@''HAVE_DECL_WCWIDTH''@|$(HAVE_DECL_WCWIDTH)|g' \
1205 -e 's|@''REPLACE_MBSTATE_T''@|$(REPLACE_MBSTATE_T)|g' \
1206 -e 's|@''REPLACE_BTOWC''@|$(REPLACE_BTOWC)|g' \
1207 -e 's|@''REPLACE_WCTOB''@|$(REPLACE_WCTOB)|g' \
1208 -e 's|@''REPLACE_MBSINIT''@|$(REPLACE_MBSINIT)|g' \
1209 -e 's|@''REPLACE_MBRTOWC''@|$(REPLACE_MBRTOWC)|g' \
1210 -e 's|@''REPLACE_MBRLEN''@|$(REPLACE_MBRLEN)|g' \
1211 -e 's|@''REPLACE_MBSRTOWCS''@|$(REPLACE_MBSRTOWCS)|g' \
1212 -e 's|@''REPLACE_MBSNRTOWCS''@|$(REPLACE_MBSNRTOWCS)|g' \
1213 -e 's|@''REPLACE_WCRTOMB''@|$(REPLACE_WCRTOMB)|g' \
1214 -e 's|@''REPLACE_WCSRTOMBS''@|$(REPLACE_WCSRTOMBS)|g' \
958 -e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \ 1215 -e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \
959 -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ 1216 -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
960 < $(srcdir)/wchar.in.h; \ 1217 < $(srcdir)/wchar.in.h; \
@@ -966,6 +1223,15 @@ EXTRA_DIST += wchar.in.h
966 1223
967## end gnulib module wchar 1224## end gnulib module wchar
968 1225
1226## begin gnulib module wcrtomb
1227
1228
1229EXTRA_DIST += wcrtomb.c
1230
1231EXTRA_libgnu_a_SOURCES += wcrtomb.c
1232
1233## end gnulib module wcrtomb
1234
969## begin gnulib module wctype 1235## begin gnulib module wctype
970 1236
971BUILT_SOURCES += $(WCTYPE_H) 1237BUILT_SOURCES += $(WCTYPE_H)
@@ -976,10 +1242,12 @@ wctype.h: wctype.in.h
976 rm -f $@-t $@ 1242 rm -f $@-t $@
977 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 1243 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
978 sed -e 's/@''HAVE_WCTYPE_H''@/$(HAVE_WCTYPE_H)/g' \ 1244 sed -e 's/@''HAVE_WCTYPE_H''@/$(HAVE_WCTYPE_H)/g' \
979 -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \ 1245 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1246 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
980 -e 's|@''NEXT_WCTYPE_H''@|$(NEXT_WCTYPE_H)|g' \ 1247 -e 's|@''NEXT_WCTYPE_H''@|$(NEXT_WCTYPE_H)|g' \
981 -e 's/@''HAVE_ISWCNTRL''@/$(HAVE_ISWCNTRL)/g' \ 1248 -e 's/@''HAVE_ISWCNTRL''@/$(HAVE_ISWCNTRL)/g' \
982 -e 's/@''HAVE_WINT_T''@/$(HAVE_WINT_T)/g' \ 1249 -e 's/@''HAVE_WINT_T''@/$(HAVE_WINT_T)/g' \
1250 -e 's/@''REPLACE_ISWCNTRL''@/$(REPLACE_ISWCNTRL)/g' \
983 < $(srcdir)/wctype.in.h; \ 1251 < $(srcdir)/wctype.in.h; \
984 } > $@-t 1252 } > $@-t
985 mv $@-t $@ 1253 mv $@-t $@
@@ -989,6 +1257,15 @@ EXTRA_DIST += wctype.in.h
989 1257
990## end gnulib module wctype 1258## end gnulib module wctype
991 1259
1260## begin gnulib module write
1261
1262
1263EXTRA_DIST += write.c
1264
1265EXTRA_libgnu_a_SOURCES += write.c
1266
1267## end gnulib module write
1268
992## begin gnulib module xalloc 1269## begin gnulib module xalloc
993 1270
994 1271
diff --git a/gl/alloca.in.h b/gl/alloca.in.h
index 8278288..6269607 100644
--- a/gl/alloca.in.h
+++ b/gl/alloca.in.h
@@ -1,6 +1,6 @@
1/* Memory allocation on the stack. 1/* Memory allocation on the stack.
2 2
3 Copyright (C) 1995, 1999, 2001-2004, 2006-2007 Free Software 3 Copyright (C) 1995, 1999, 2001-2004, 2006-2008 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 5
6 This program is free software; you can redistribute it and/or modify it 6 This program is free software; you can redistribute it and/or modify it
@@ -42,6 +42,8 @@
42# elif defined _MSC_VER 42# elif defined _MSC_VER
43# include <malloc.h> 43# include <malloc.h>
44# define alloca _alloca 44# define alloca _alloca
45# elif defined __DECC && defined __VMS
46# define alloca __ALLOCA
45# else 47# else
46# include <stddef.h> 48# include <stddef.h>
47# ifdef __cplusplus 49# ifdef __cplusplus
diff --git a/gl/inet_ntop.h b/gl/arpa_inet.in.h
index 2897bb4..4b95b94 100644
--- a/gl/inet_ntop.h
+++ b/gl/arpa_inet.in.h
@@ -1,5 +1,6 @@
1/* Convert internet address from internal to printable, presentable format. 1/* A GNU-like <arpa/inet.h>.
2 Copyright (C) 2005, 2006 Free Software Foundation, Inc. 2
3 Copyright (C) 2005-2006, 2008 Free Software Foundation, Inc.
3 4
4 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
@@ -15,11 +16,30 @@
15 along with this program; if not, write to the Free Software Foundation, 16 along with this program; if not, write to the Free Software Foundation,
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ 17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
17 18
18#include <sys/types.h> 19#ifndef _GL_ARPA_INET_H
20
21/* Gnulib's sys/socket.h is responsible for pulling in winsock2.h etc
22 under MinGW. */
19#include <sys/socket.h> 23#include <sys/socket.h>
20#include <netinet/in.h>
21#include <arpa/inet.h>
22 24
25#if @HAVE_ARPA_INET_H@
26
27# if __GNUC__ >= 3
28@PRAGMA_SYSTEM_HEADER@
29# endif
30
31/* The include_next requires a split double-inclusion guard. */
32# @INCLUDE_NEXT@ @NEXT_ARPA_INET_H@
33
34#endif
35
36#ifndef _GL_ARPA_INET_H
37#define _GL_ARPA_INET_H
38
39/* The definition of GL_LINK_WARNING is copied here. */
40
41#if @GNULIB_INET_NTOP@
42# if !@HAVE_DECL_INET_NTOP@
23/* Converts an internet address from internal format to a printable, 43/* Converts an internet address from internal format to a printable,
24 presentable format. 44 presentable format.
25 AF is an internet address family, such as AF_INET or AF_INET6. 45 AF is an internet address family, such as AF_INET or AF_INET6.
@@ -35,8 +55,28 @@
35 55
36 For more details, see the POSIX:2001 specification 56 For more details, see the POSIX:2001 specification
37 <http://www.opengroup.org/susv3xsh/inet_ntop.html>. */ 57 <http://www.opengroup.org/susv3xsh/inet_ntop.html>. */
38
39#if !HAVE_DECL_INET_NTOP
40extern const char *inet_ntop (int af, const void *restrict src, 58extern const char *inet_ntop (int af, const void *restrict src,
41 char *restrict dst, socklen_t cnt); 59 char *restrict dst, socklen_t cnt);
60# endif
61#elif defined GNULIB_POSIXCHECK
62# undef inet_ntop
63# define inet_ntop(af,src,dst,cnt) \
64 (GL_LINK_WARNING ("inet_ntop is unportable - " \
65 "use gnulib module inet_ntop for portability"), \
66 inet_ntop (af, src, dst, cnt))
42#endif 67#endif
68
69#if @GNULIB_INET_PTON@
70# if !@HAVE_DECL_INET_PTON@
71extern int inet_pton (int af, const char *restrict src, void *restrict dst);
72# endif
73#elif defined GNULIB_POSIXCHECK
74# undef inet_pton
75# define inet_pton(af,src,dst) \
76 (GL_LINK_WARNING ("inet_pton is unportable - " \
77 "use gnulib module inet_pton for portability"), \
78 inet_pton (af, src, dst))
79#endif
80
81#endif /* _GL_ARPA_INET_H */
82#endif /* _GL_ARPA_INET_H */
diff --git a/gl/base64.c b/gl/base64.c
index e67075d..42ccc9c 100644
--- a/gl/base64.c
+++ b/gl/base64.c
@@ -52,6 +52,8 @@
52/* Get UCHAR_MAX. */ 52/* Get UCHAR_MAX. */
53#include <limits.h> 53#include <limits.h>
54 54
55#include <string.h>
56
55/* C89 compliant way to cast 'char' to 'unsigned char'. */ 57/* C89 compliant way to cast 'char' to 'unsigned char'. */
56static inline unsigned char 58static inline unsigned char
57to_uchar (char ch) 59to_uchar (char ch)
@@ -300,89 +302,237 @@ isbase64 (char ch)
300 return uchar_in_range (to_uchar (ch)) && 0 <= b64[to_uchar (ch)]; 302 return uchar_in_range (to_uchar (ch)) && 0 <= b64[to_uchar (ch)];
301} 303}
302 304
303/* Decode base64 encoded input array IN of length INLEN to output 305/* Initialize decode-context buffer, CTX. */
304 array OUT that can hold *OUTLEN bytes. Return true if decoding was 306void
305 successful, i.e. if the input was valid base64 data, false 307base64_decode_ctx_init (struct base64_decode_context *ctx)
306 otherwise. If *OUTLEN is too small, as many bytes as possible will
307 be written to OUT. On return, *OUTLEN holds the length of decoded
308 bytes in OUT. Note that as soon as any non-alphabet characters are
309 encountered, decoding is stopped and false is returned. This means
310 that, when applicable, you must remove any line terminators that is
311 part of the data stream before calling this function. */
312bool
313base64_decode (const char *restrict in, size_t inlen,
314 char *restrict out, size_t *outlen)
315{ 308{
316 size_t outleft = *outlen; 309 ctx->i = 0;
310}
317 311
318 while (inlen >= 2) 312/* If CTX->i is 0 or 4, there are four or more bytes in [*IN..IN_END), and
319 { 313 none of those four is a newline, then return *IN. Otherwise, copy up to
320 if (!isbase64 (in[0]) || !isbase64 (in[1])) 314 4 - CTX->i non-newline bytes from that range into CTX->buf, starting at
321 break; 315 index CTX->i and setting CTX->i to reflect the number of bytes copied,
316 and return CTX->buf. In either case, advance *IN to point to the byte
317 after the last one processed, and set *N_NON_NEWLINE to the number of
318 verified non-newline bytes accessible through the returned pointer. */
319static inline char *
320get_4 (struct base64_decode_context *ctx,
321 char const *restrict *in, char const *restrict in_end,
322 size_t *n_non_newline)
323{
324 if (ctx->i == 4)
325 ctx->i = 0;
322 326
323 if (outleft) 327 if (ctx->i == 0)
328 {
329 char const *t = *in;
330 if (4 <= in_end - *in && memchr (t, '\n', 4) == NULL)
324 { 331 {
325 *out++ = ((b64[to_uchar (in[0])] << 2) 332 /* This is the common case: no newline. */
326 | (b64[to_uchar (in[1])] >> 4)); 333 *in += 4;
327 outleft--; 334 *n_non_newline = 4;
335 return (char *) t;
328 } 336 }
337 }
329 338
330 if (inlen == 2) 339 {
331 break; 340 /* Copy non-newline bytes into BUF. */
341 char const *p = *in;
342 while (p < in_end)
343 {
344 char c = *p++;
345 if (c != '\n')
346 {
347 ctx->buf[ctx->i++] = c;
348 if (ctx->i == 4)
349 break;
350 }
351 }
352
353 *in = p;
354 *n_non_newline = ctx->i;
355 return ctx->buf;
356 }
357}
358
359#define return_false \
360 do \
361 { \
362 *outp = out; \
363 return false; \
364 } \
365 while (false)
366
367/* Decode up to four bytes of base64-encoded data, IN, of length INLEN
368 into the output buffer, *OUT, of size *OUTLEN bytes. Return true if
369 decoding is successful, false otherwise. If *OUTLEN is too small,
370 as many bytes as possible are written to *OUT. On return, advance
371 *OUT to point to the byte after the last one written, and decrement
372 *OUTLEN to reflect the number of bytes remaining in *OUT. */
373static inline bool
374decode_4 (char const *restrict in, size_t inlen,
375 char *restrict *outp, size_t *outleft)
376{
377 char *out = *outp;
378 if (inlen < 2)
379 return false;
380
381 if (!isbase64 (in[0]) || !isbase64 (in[1]))
382 return false;
383
384 if (*outleft)
385 {
386 *out++ = ((b64[to_uchar (in[0])] << 2)
387 | (b64[to_uchar (in[1])] >> 4));
388 --*outleft;
389 }
390
391 if (inlen == 2)
392 return_false;
393
394 if (in[2] == '=')
395 {
396 if (inlen != 4)
397 return_false;
398
399 if (in[3] != '=')
400 return_false;
401 }
402 else
403 {
404 if (!isbase64 (in[2]))
405 return_false;
332 406
333 if (in[2] == '=') 407 if (*outleft)
334 { 408 {
335 if (inlen != 4) 409 *out++ = (((b64[to_uchar (in[1])] << 4) & 0xf0)
336 break; 410 | (b64[to_uchar (in[2])] >> 2));
411 --*outleft;
412 }
337 413
338 if (in[3] != '=') 414 if (inlen == 3)
339 break; 415 return_false;
340 416
417 if (in[3] == '=')
418 {
419 if (inlen != 4)
420 return_false;
341 } 421 }
342 else 422 else
343 { 423 {
344 if (!isbase64 (in[2])) 424 if (!isbase64 (in[3]))
345 break; 425 return_false;
346 426
347 if (outleft) 427 if (*outleft)
348 { 428 {
349 *out++ = (((b64[to_uchar (in[1])] << 4) & 0xf0) 429 *out++ = (((b64[to_uchar (in[2])] << 6) & 0xc0)
350 | (b64[to_uchar (in[2])] >> 2)); 430 | b64[to_uchar (in[3])]);
351 outleft--; 431 --*outleft;
352 } 432 }
433 }
434 }
353 435
354 if (inlen == 3) 436 *outp = out;
355 break; 437 return true;
438}
356 439
357 if (in[3] == '=') 440/* Decode base64-encoded input array IN of length INLEN to output array
358 { 441 OUT that can hold *OUTLEN bytes. The input data may be interspersed
359 if (inlen != 4) 442 with newlines. Return true if decoding was successful, i.e. if the
360 break; 443 input was valid base64 data, false otherwise. If *OUTLEN is too
361 } 444 small, as many bytes as possible will be written to OUT. On return,
362 else 445 *OUTLEN holds the length of decoded bytes in OUT. Note that as soon
446 as any non-alphabet, non-newline character is encountered, decoding
447 is stopped and false is returned. If INLEN is zero, then process
448 only whatever data is stored in CTX.
449
450 Initially, CTX must have been initialized via base64_decode_ctx_init.
451 Subsequent calls to this function must reuse whatever state is recorded
452 in that buffer. It is necessary for when a quadruple of base64 input
453 bytes spans two input buffers.
454
455 If CTX is NULL then newlines are treated as garbage and the input
456 buffer is processed as a unit. */
457
458bool
459base64_decode_ctx (struct base64_decode_context *ctx,
460 const char *restrict in, size_t inlen,
461 char *restrict out, size_t *outlen)
462{
463 size_t outleft = *outlen;
464 bool ignore_newlines = ctx != NULL;
465 bool flush_ctx = false;
466 unsigned int ctx_i = 0;
467
468 if (ignore_newlines)
469 {
470 ctx_i = ctx->i;
471 flush_ctx = inlen == 0;
472 }
473
474
475 while (true)
476 {
477 size_t outleft_save = outleft;
478 if (ctx_i == 0 && !flush_ctx)
479 {
480 while (true)
363 { 481 {
364 if (!isbase64 (in[3])) 482 /* Save a copy of outleft, in case we need to re-parse this
483 block of four bytes. */
484 outleft_save = outleft;
485 if (!decode_4 (in, inlen, &out, &outleft))
365 break; 486 break;
366 487
367 if (outleft) 488 in += 4;
368 { 489 inlen -= 4;
369 *out++ = (((b64[to_uchar (in[2])] << 6) & 0xc0)
370 | b64[to_uchar (in[3])]);
371 outleft--;
372 }
373 } 490 }
374 } 491 }
375 492
376 in += 4; 493 if (inlen == 0 && !flush_ctx)
377 inlen -= 4; 494 break;
495
496 /* Handle the common case of 72-byte wrapped lines.
497 This also handles any other multiple-of-4-byte wrapping. */
498 if (inlen && *in == '\n' && ignore_newlines)
499 {
500 ++in;
501 --inlen;
502 continue;
503 }
504
505 /* Restore OUT and OUTLEFT. */
506 out -= outleft_save - outleft;
507 outleft = outleft_save;
508
509 {
510 char const *in_end = in + inlen;
511 char const *non_nl;
512
513 if (ignore_newlines)
514 non_nl = get_4 (ctx, &in, in_end, &inlen);
515 else
516 non_nl = in; /* Might have nl in this case. */
517
518 /* If the input is empty or consists solely of newlines (0 non-newlines),
519 then we're done. Likewise if there are fewer than 4 bytes when not
520 flushing context and not treating newlines as garbage. */
521 if (inlen == 0 || (inlen < 4 && !flush_ctx && ignore_newlines))
522 {
523 inlen = 0;
524 break;
525 }
526 if (!decode_4 (non_nl, inlen, &out, &outleft))
527 break;
528
529 inlen = in_end - in;
530 }
378 } 531 }
379 532
380 *outlen -= outleft; 533 *outlen -= outleft;
381 534
382 if (inlen != 0) 535 return inlen == 0;
383 return false;
384
385 return true;
386} 536}
387 537
388/* Allocate an output buffer in *OUT, and decode the base64 encoded 538/* Allocate an output buffer in *OUT, and decode the base64 encoded
@@ -397,12 +547,13 @@ base64_decode (const char *restrict in, size_t inlen,
397 input was invalid, in which case *OUT is NULL and *OUTLEN is 547 input was invalid, in which case *OUT is NULL and *OUTLEN is
398 undefined. */ 548 undefined. */
399bool 549bool
400base64_decode_alloc (const char *in, size_t inlen, char **out, 550base64_decode_alloc_ctx (struct base64_decode_context *ctx,
401 size_t *outlen) 551 const char *in, size_t inlen, char **out,
552 size_t *outlen)
402{ 553{
403 /* This may allocate a few bytes too much, depending on input, 554 /* This may allocate a few bytes too many, depending on input,
404 but it's not worth the extra CPU time to compute the exact amount. 555 but it's not worth the extra CPU time to compute the exact size.
405 The exact amount is 3 * inlen / 4, minus 1 if the input ends 556 The exact size is 3 * inlen / 4, minus 1 if the input ends
406 with "=" and minus another 1 if the input ends with "==". 557 with "=" and minus another 1 if the input ends with "==".
407 Dividing before multiplying avoids the possibility of overflow. */ 558 Dividing before multiplying avoids the possibility of overflow. */
408 size_t needlen = 3 * (inlen / 4) + 2; 559 size_t needlen = 3 * (inlen / 4) + 2;
@@ -411,7 +562,7 @@ base64_decode_alloc (const char *in, size_t inlen, char **out,
411 if (!*out) 562 if (!*out)
412 return true; 563 return true;
413 564
414 if (!base64_decode (in, inlen, *out, &needlen)) 565 if (!base64_decode_ctx (ctx, in, inlen, *out, &needlen))
415 { 566 {
416 free (*out); 567 free (*out);
417 *out = NULL; 568 *out = NULL;
diff --git a/gl/base64.h b/gl/base64.h
index 1f9b203..63b6abc 100644
--- a/gl/base64.h
+++ b/gl/base64.h
@@ -29,6 +29,12 @@
29 integer >= n/k, i.e., the ceiling of n/k. */ 29 integer >= n/k, i.e., the ceiling of n/k. */
30# define BASE64_LENGTH(inlen) ((((inlen) + 2) / 3) * 4) 30# define BASE64_LENGTH(inlen) ((((inlen) + 2) / 3) * 4)
31 31
32struct base64_decode_context
33{
34 unsigned int i;
35 char buf[4];
36};
37
32extern bool isbase64 (char ch); 38extern bool isbase64 (char ch);
33 39
34extern void base64_encode (const char *restrict in, size_t inlen, 40extern void base64_encode (const char *restrict in, size_t inlen,
@@ -36,10 +42,20 @@ extern void base64_encode (const char *restrict in, size_t inlen,
36 42
37extern size_t base64_encode_alloc (const char *in, size_t inlen, char **out); 43extern size_t base64_encode_alloc (const char *in, size_t inlen, char **out);
38 44
39extern bool base64_decode (const char *restrict in, size_t inlen, 45extern void base64_decode_ctx_init (struct base64_decode_context *ctx);
40 char *restrict out, size_t *outlen); 46
47extern bool base64_decode_ctx (struct base64_decode_context *ctx,
48 const char *restrict in, size_t inlen,
49 char *restrict out, size_t *outlen);
50
51extern bool base64_decode_alloc_ctx (struct base64_decode_context *ctx,
52 const char *in, size_t inlen,
53 char **out, size_t *outlen);
54
55#define base64_decode(in, inlen, out, outlen) \
56 base64_decode_ctx (NULL, in, inlen, out, outlen)
41 57
42extern bool base64_decode_alloc (const char *in, size_t inlen, 58#define base64_decode_alloc(in, inlen, out, outlen) \
43 char **out, size_t *outlen); 59 base64_decode_alloc_ctx (NULL, in, inlen, out, outlen)
44 60
45#endif /* BASE64_H */ 61#endif /* BASE64_H */
diff --git a/gl/btowc.c b/gl/btowc.c
new file mode 100644
index 0000000..7f3b966
--- /dev/null
+++ b/gl/btowc.c
@@ -0,0 +1,38 @@
1/* Convert unibyte character to wide character.
2 Copyright (C) 2008 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2008.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#include <wchar.h>
22
23#include <stdio.h>
24
25wint_t
26btowc (int c)
27{
28 if (c != EOF)
29 {
30 char buf[1];
31 wchar_t wc;
32
33 buf[0] = c;
34 if (mbtowc (&wc, buf, 1) >= 0)
35 return wc;
36 }
37 return WEOF;
38}
diff --git a/gl/config.charset b/gl/config.charset
index c233788..36ba683 100755
--- a/gl/config.charset
+++ b/gl/config.charset
@@ -1,7 +1,7 @@
1#! /bin/sh 1#! /bin/sh
2# Output a system dependent table of character encoding aliases. 2# Output a system dependent table of character encoding aliases.
3# 3#
4# Copyright (C) 2000-2004, 2006-2007 Free Software Foundation, Inc. 4# Copyright (C) 2000-2004, 2006-2008 Free Software Foundation, Inc.
5# 5#
6# This program is free software; you can redistribute it and/or modify 6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by 7# it under the terms of the GNU General Public License as published by
@@ -478,8 +478,8 @@ case "$os" in
478 # space nevertheless. 478 # space nevertheless.
479 echo "* UTF-8" 479 echo "* UTF-8"
480 ;; 480 ;;
481 beos*) 481 beos* | haiku*)
482 # BeOS has a single locale, and it has UTF-8 encoding. 482 # BeOS and Haiku have a single locale, and it has UTF-8 encoding.
483 echo "* UTF-8" 483 echo "* UTF-8"
484 ;; 484 ;;
485 msdosdjgpp*) 485 msdosdjgpp*)
diff --git a/gl/errno.in.h b/gl/errno.in.h
new file mode 100644
index 0000000..51ac662
--- /dev/null
+++ b/gl/errno.in.h
@@ -0,0 +1,155 @@
1/* A POSIX-like <errno.h>.
2
3 Copyright (C) 2008 Free Software Foundation, Inc.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3, or (at your option)
8 any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software Foundation,
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18
19#ifndef _GL_ERRNO_H
20
21#if __GNUC__ >= 3
22@PRAGMA_SYSTEM_HEADER@
23#endif
24
25/* The include_next requires a split double-inclusion guard. */
26#@INCLUDE_NEXT@ @NEXT_ERRNO_H@
27
28#ifndef _GL_ERRNO_H
29#define _GL_ERRNO_H
30
31
32/* On native Windows platforms, many macros are not defined. */
33# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
34
35/* POSIX says that EAGAIN and EWOULDBLOCK may have the same value. */
36# define EWOULDBLOCK EAGAIN
37
38/* Values >= 100 seem safe to use. */
39# define ETXTBSY 100
40# define GNULIB_defined_ETXTBSY 1
41
42/* These are intentionally the same values as the WSA* error numbers, defined
43 in <winsock2.h>. */
44# define EINPROGRESS 10036
45# define EALREADY 10037
46# define ENOTSOCK 10038
47# define EDESTADDRREQ 10039
48# define EMSGSIZE 10040
49# define EPROTOTYPE 10041
50# define ENOPROTOOPT 10042
51# define EPROTONOSUPPORT 10043
52# define ESOCKTNOSUPPORT 10044 /* not required by POSIX */
53# define EOPNOTSUPP 10045
54# define EPFNOSUPPORT 10046 /* not required by POSIX */
55# define EAFNOSUPPORT 10047
56# define EADDRINUSE 10048
57# define EADDRNOTAVAIL 10049
58# define ENETDOWN 10050
59# define ENETUNREACH 10051
60# define ENETRESET 10052
61# define ECONNABORTED 10053
62# define ECONNRESET 10054
63# define ENOBUFS 10055
64# define EISCONN 10056
65# define ENOTCONN 10057
66# define ESHUTDOWN 10058 /* not required by POSIX */
67# define ETOOMANYREFS 10059 /* not required by POSIX */
68# define ETIMEDOUT 10060
69# define ECONNREFUSED 10061
70# define ELOOP 10062
71# define EHOSTDOWN 10064 /* not required by POSIX */
72# define EHOSTUNREACH 10065
73# define EPROCLIM 10067 /* not required by POSIX */
74# define EUSERS 10068 /* not required by POSIX */
75# define EDQUOT 10069
76# define ESTALE 10070
77# define EREMOTE 10071 /* not required by POSIX */
78# define GNULIB_defined_ESOCK 1
79
80# endif
81
82
83/* On OSF/1 5.1, when _XOPEN_SOURCE_EXTENDED is not defined, the macros
84 EMULTIHOP, ENOLINK, EOVERFLOW are not defined. */
85# if @EMULTIHOP_HIDDEN@
86# define EMULTIHOP @EMULTIHOP_VALUE@
87# define GNULIB_defined_EMULTIHOP 1
88# endif
89# if @ENOLINK_HIDDEN@
90# define ENOLINK @ENOLINK_VALUE@
91# define GNULIB_defined_ENOLINK 1
92# endif
93# if @EOVERFLOW_HIDDEN@
94# define EOVERFLOW @EOVERFLOW_VALUE@
95# define GNULIB_defined_EOVERFLOW 1
96# endif
97
98
99/* On OpenBSD 4.0 and on native Windows, the macros ENOMSG, EIDRM, ENOLINK,
100 EPROTO, EMULTIHOP, EBADMSG, EOVERFLOW, ENOTSUP, ECANCELED are not defined.
101 Define them here. Values >= 2000 seem safe to use: Solaris ESTALE = 151,
102 HP-UX EWOULDBLOCK = 246, IRIX EDQUOT = 1133.
103
104 Note: When one of these systems defines some of these macros some day,
105 binaries will have to be recompiled so that they recognizes the new
106 errno values from the system. */
107
108# ifndef ENOMSG
109# define ENOMSG 2000
110# define GNULIB_defined_ENOMSG 1
111# endif
112
113# ifndef EIDRM
114# define EIDRM 2001
115# define GNULIB_defined_EIDRM 1
116# endif
117
118# ifndef ENOLINK
119# define ENOLINK 2002
120# define GNULIB_defined_ENOLINK 1
121# endif
122
123# ifndef EPROTO
124# define EPROTO 2003
125# define GNULIB_defined_EPROTO 1
126# endif
127
128# ifndef EMULTIHOP
129# define EMULTIHOP 2004
130# define GNULIB_defined_EMULTIHOP 1
131# endif
132
133# ifndef EBADMSG
134# define EBADMSG 2005
135# define GNULIB_defined_EBADMSG 1
136# endif
137
138# ifndef EOVERFLOW
139# define EOVERFLOW 2006
140# define GNULIB_defined_EOVERFLOW 1
141# endif
142
143# ifndef ENOTSUP
144# define ENOTSUP 2007
145# define GNULIB_defined_ENOTSUP 1
146# endif
147
148# ifndef ECANCELED
149# define ECANCELED 2008
150# define GNULIB_defined_ECANCELED 1
151# endif
152
153
154#endif /* _GL_ERRNO_H */
155#endif /* _GL_ERRNO_H */
diff --git a/gl/fcntl.in.h b/gl/fcntl.in.h
new file mode 100644
index 0000000..fd7520e
--- /dev/null
+++ b/gl/fcntl.in.h
@@ -0,0 +1,144 @@
1/* Like <fcntl.h>, but with non-working flags defined to 0.
2
3 Copyright (C) 2006-2008 Free Software Foundation, Inc.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18/* written by Paul Eggert */
19
20#if __GNUC__ >= 3
21@PRAGMA_SYSTEM_HEADER@
22#endif
23
24#if defined __need_system_fcntl_h
25/* Special invocation convention. */
26
27#include <sys/types.h>
28#include <sys/stat.h>
29#include <unistd.h>
30#@INCLUDE_NEXT@ @NEXT_FCNTL_H@
31
32#else
33/* Normal invocation convention. */
34
35#ifndef _GL_FCNTL_H
36
37#include <sys/types.h>
38#include <sys/stat.h>
39#include <unistd.h>
40/* The include_next requires a split double-inclusion guard. */
41#@INCLUDE_NEXT@ @NEXT_FCNTL_H@
42
43#ifndef _GL_FCNTL_H
44#define _GL_FCNTL_H
45
46
47/* Declare overridden functions. */
48
49#ifdef __cplusplus
50extern "C" {
51#endif
52
53#if @GNULIB_OPEN@
54# if @REPLACE_OPEN@
55# undef open
56# define open rpl_open
57extern int open (const char *filename, int flags, ...);
58# endif
59#endif
60
61#ifdef FCHDIR_REPLACEMENT
62/* gnulib internal function. */
63extern void _gl_register_fd (int fd, const char *filename);
64#endif
65
66#ifdef __cplusplus
67}
68#endif
69
70
71/* Fix up the O_* macros. */
72
73#if !defined O_DIRECT && defined O_DIRECTIO
74/* Tru64 spells it `O_DIRECTIO'. */
75# define O_DIRECT O_DIRECTIO
76#endif
77
78#ifndef O_DIRECT
79# define O_DIRECT 0
80#endif
81
82#ifndef O_DIRECTORY
83# define O_DIRECTORY 0
84#endif
85
86#ifndef O_DSYNC
87# define O_DSYNC 0
88#endif
89
90#ifndef O_NDELAY
91# define O_NDELAY 0
92#endif
93
94#ifndef O_NOATIME
95# define O_NOATIME 0
96#endif
97
98#ifndef O_NONBLOCK
99# define O_NONBLOCK O_NDELAY
100#endif
101
102#ifndef O_NOCTTY
103# define O_NOCTTY 0
104#endif
105
106#ifndef O_NOFOLLOW
107# define O_NOFOLLOW 0
108#endif
109
110#ifndef O_NOLINKS
111# define O_NOLINKS 0
112#endif
113
114#ifndef O_RSYNC
115# define O_RSYNC 0
116#endif
117
118#ifndef O_SYNC
119# define O_SYNC 0
120#endif
121
122/* For systems that distinguish between text and binary I/O.
123 O_BINARY is usually declared in fcntl.h */
124#if !defined O_BINARY && defined _O_BINARY
125 /* For MSC-compatible compilers. */
126# define O_BINARY _O_BINARY
127# define O_TEXT _O_TEXT
128#endif
129
130#if defined __BEOS__ || defined __HAIKU__
131 /* BeOS 5 and Haiku have O_BINARY and O_TEXT, but they have no effect. */
132# undef O_BINARY
133# undef O_TEXT
134#endif
135
136#ifndef O_BINARY
137# define O_BINARY 0
138# define O_TEXT 0
139#endif
140
141
142#endif /* _GL_FCNTL_H */
143#endif /* _GL_FCNTL_H */
144#endif
diff --git a/gl/float.in.h b/gl/float.in.h
index 2504032..9ba2bce 100644
--- a/gl/float.in.h
+++ b/gl/float.in.h
@@ -1,6 +1,6 @@
1/* A correct <float.h>. 1/* A correct <float.h>.
2 2
3 Copyright (C) 2007 Free Software Foundation, Inc. 3 Copyright (C) 2007-2008 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
@@ -17,6 +17,10 @@
17 17
18#ifndef _GL_FLOAT_H 18#ifndef _GL_FLOAT_H
19 19
20#if __GNUC__ >= 3
21@PRAGMA_SYSTEM_HEADER@
22#endif
23
20/* The include_next requires a split double-inclusion guard. */ 24/* The include_next requires a split double-inclusion guard. */
21#@INCLUDE_NEXT@ @NEXT_FLOAT_H@ 25#@INCLUDE_NEXT@ @NEXT_FLOAT_H@
22 26
diff --git a/gl/gai_strerror.c b/gl/gai_strerror.c
index 9e4abbe..78a8edf 100644
--- a/gl/gai_strerror.c
+++ b/gl/gai_strerror.c
@@ -1,4 +1,4 @@
1/* Copyright (C) 1997, 2001, 2002, 2004, 2005, 2006 Free Software Foundation, Inc. 1/* Copyright (C) 1997, 2001, 2002, 2004, 2005, 2006, 2008 Free Software Foundation, Inc.
2 This file is part of the GNU C Library. 2 This file is part of the GNU C Library.
3 Contributed by Philip Blundell <pjb27@cam.ac.uk>, 1997. 3 Contributed by Philip Blundell <pjb27@cam.ac.uk>, 1997.
4 4
@@ -18,13 +18,10 @@
18 18
19#ifndef _LIBC 19#ifndef _LIBC
20# include <config.h> 20# include <config.h>
21# include "getaddrinfo.h"
22#endif 21#endif
23 22
24#include <stdio.h> 23#include <stdio.h>
25#ifdef HAVE_NETDB_H 24#include <netdb.h>
26# include <netdb.h>
27#endif
28 25
29#ifdef _LIBC 26#ifdef _LIBC
30# include <libintl.h> 27# include <libintl.h>
diff --git a/gl/getaddrinfo.c b/gl/getaddrinfo.c
index 04f0ac2..f09cf9e 100644
--- a/gl/getaddrinfo.c
+++ b/gl/getaddrinfo.c
@@ -1,5 +1,5 @@
1/* Get address information (partial implementation). 1/* Get address information (partial implementation).
2 Copyright (C) 1997, 2001, 2002, 2004, 2005, 2006, 2007 Free Software 2 Copyright (C) 1997, 2001, 2002, 2004, 2005, 2006, 2007, 2008 Free Software
3 Foundation, Inc. 3 Foundation, Inc.
4 Contributed by Simon Josefsson <simon@josefsson.org>. 4 Contributed by Simon Josefsson <simon@josefsson.org>.
5 5
@@ -19,12 +19,15 @@
19 19
20#include <config.h> 20#include <config.h>
21 21
22#include "getaddrinfo.h" 22#include <netdb.h>
23 23
24#if HAVE_NETINET_IN_H 24#if HAVE_NETINET_IN_H
25# include <netinet/in.h> 25# include <netinet/in.h>
26#endif 26#endif
27 27
28/* Get inet_ntop. */
29#include <arpa/inet.h>
30
28/* Get calloc. */ 31/* Get calloc. */
29#include <stdlib.h> 32#include <stdlib.h>
30 33
@@ -40,8 +43,6 @@
40#define _(String) gettext (String) 43#define _(String) gettext (String)
41#define N_(String) String 44#define N_(String) String
42 45
43#include "inet_ntop.h"
44
45/* BeOS has AF_INET, but not PF_INET. */ 46/* BeOS has AF_INET, but not PF_INET. */
46#ifndef PF_INET 47#ifndef PF_INET
47# define PF_INET AF_INET 48# define PF_INET AF_INET
@@ -300,6 +301,22 @@ getaddrinfo (const char *restrict nodename,
300 tmp->ai_addr->sa_family = he->h_addrtype; 301 tmp->ai_addr->sa_family = he->h_addrtype;
301 tmp->ai_family = he->h_addrtype; 302 tmp->ai_family = he->h_addrtype;
302 303
304#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
305 switch (he->h_addrtype)
306 {
307#if HAVE_IPV4
308 case AF_INET:
309 tmp->ai_addr->sa_len = sizeof (struct sockaddr_in);
310 break;
311#endif
312#if HAVE_IPV6
313 case AF_INET6:
314 tmp->ai_addr->sa_len = sizeof (struct sockaddr_in6);
315 break;
316#endif
317 }
318#endif
319
303 /* FIXME: If more than one address, create linked list of addrinfo's. */ 320 /* FIXME: If more than one address, create linked list of addrinfo's. */
304 321
305 *res = tmp; 322 *res = tmp;
@@ -326,7 +343,7 @@ freeaddrinfo (struct addrinfo *ai)
326 cur = ai; 343 cur = ai;
327 ai = ai->ai_next; 344 ai = ai->ai_next;
328 345
329 if (cur->ai_canonname) free (cur->ai_canonname); 346 free (cur->ai_canonname);
330 free (cur); 347 free (cur);
331 } 348 }
332} 349}
diff --git a/gl/getaddrinfo.h b/gl/getaddrinfo.h
deleted file mode 100644
index 050b793..0000000
--- a/gl/getaddrinfo.h
+++ /dev/null
@@ -1,155 +0,0 @@
1/* Get address information.
2 Copyright (C) 1996-2002, 2003, 2004, 2005, 2006
3 Free Software Foundation, Inc.
4 Contributed by Simon Josefsson <simon@josefsson.org>.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
9 any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software Foundation,
18 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
19
20#ifndef GETADDRINFO_H
21#define GETADDRINFO_H
22
23/* sys/socket.h in i386-unknown-freebsd4.10 and
24 powerpc-apple-darwin5.5 require sys/types.h, so include it first.
25 Then we'll also get 'socklen_t' and 'struct sockaddr' which are
26 used below. */
27#include <sys/types.h>
28/* Get all getaddrinfo related declarations, if available. */
29#include <sys/socket.h>
30#ifdef HAVE_NETDB_H
31# include <netdb.h>
32#endif
33
34#ifndef HAVE_STRUCT_ADDRINFO
35
36/* Structure to contain information about address of a service provider. */
37struct addrinfo
38{
39 int ai_flags; /* Input flags. */
40 int ai_family; /* Protocol family for socket. */
41 int ai_socktype; /* Socket type. */
42 int ai_protocol; /* Protocol for socket. */
43 socklen_t ai_addrlen; /* Length of socket address. */
44 struct sockaddr *ai_addr; /* Socket address for socket. */
45 char *ai_canonname; /* Canonical name for service location. */
46 struct addrinfo *ai_next; /* Pointer to next in list. */
47};
48#endif
49
50/* Possible values for `ai_flags' field in `addrinfo' structure. */
51#ifndef AI_PASSIVE
52# define AI_PASSIVE 0x0001 /* Socket address is intended for `bind'. */
53#endif
54#ifndef AI_CANONNAME
55# define AI_CANONNAME 0x0002 /* Request for canonical name. */
56#endif
57#ifndef AI_NUMERICSERV
58# define AI_NUMERICSERV 0x0400 /* Don't use name resolution. */
59#endif
60
61#if 0
62/* The commented out definitions below are not yet implemented in the
63 GNULIB getaddrinfo() replacement, so are not yet needed and may, in fact,
64 cause conflicts on systems with a getaddrinfo() function which does not
65 define them.
66
67 If they are restored, be sure to protect the definitions with #ifndef. */
68#define AI_NUMERICHOST 0x0004 /* Don't use name resolution. */
69#define AI_V4MAPPED 0x0008 /* IPv4 mapped addresses are acceptable. */
70#define AI_ALL 0x0010 /* Return IPv4 mapped and IPv6 addresses. */
71#define AI_ADDRCONFIG 0x0020 /* Use configuration of this host to choose
72 returned address type.. */
73#endif /* 0 */
74
75/* Error values for `getaddrinfo' function. */
76#ifndef EAI_BADFLAGS
77# define EAI_BADFLAGS -1 /* Invalid value for `ai_flags' field. */
78# define EAI_NONAME -2 /* NAME or SERVICE is unknown. */
79# define EAI_AGAIN -3 /* Temporary failure in name resolution. */
80# define EAI_FAIL -4 /* Non-recoverable failure in name res. */
81# define EAI_NODATA -5 /* No address associated with NAME. */
82# define EAI_FAMILY -6 /* `ai_family' not supported. */
83# define EAI_SOCKTYPE -7 /* `ai_socktype' not supported. */
84# define EAI_SERVICE -8 /* SERVICE not supported for `ai_socktype'. */
85# define EAI_MEMORY -10 /* Memory allocation failure. */
86#endif
87#ifndef EAI_OVERFLOW
88/* Not defined on mingw32. */
89# define EAI_OVERFLOW -12 /* Argument buffer overflow. */
90#endif
91#ifndef EAI_ADDRFAMILY
92/* Not defined on mingw32. */
93# define EAI_ADDRFAMILY -9 /* Address family for NAME not supported. */
94#endif
95#ifndef EAI_SYSTEM
96/* Not defined on mingw32. */
97# define EAI_SYSTEM -11 /* System error returned in `errno'. */
98#endif
99
100#ifdef __USE_GNU
101# ifndef EAI_INPROGRESS
102# define EAI_INPROGRESS -100 /* Processing request in progress. */
103# define EAI_CANCELED -101 /* Request canceled. */
104# define EAI_NOTCANCELED -102 /* Request not canceled. */
105# define EAI_ALLDONE -103 /* All requests done. */
106# define EAI_INTR -104 /* Interrupted by a signal. */
107# define EAI_IDN_ENCODE -105 /* IDN encoding failed. */
108# endif
109#endif
110
111#if !HAVE_DECL_GETADDRINFO
112/* Translate name of a service location and/or a service name to set of
113 socket addresses.
114 For more details, see the POSIX:2001 specification
115 <http://www.opengroup.org/susv3xsh/getaddrinfo.html>. */
116extern int getaddrinfo (const char *restrict nodename,
117 const char *restrict servname,
118 const struct addrinfo *restrict hints,
119 struct addrinfo **restrict res);
120#endif
121
122#if !HAVE_DECL_FREEADDRINFO
123/* Free `addrinfo' structure AI including associated storage.
124 For more details, see the POSIX:2001 specification
125 <http://www.opengroup.org/susv3xsh/getaddrinfo.html>. */
126extern void freeaddrinfo (struct addrinfo *ai);
127#endif
128
129#if !HAVE_DECL_GAI_STRERROR
130/* Convert error return from getaddrinfo() to a string.
131 For more details, see the POSIX:2001 specification
132 <http://www.opengroup.org/susv3xsh/gai_strerror.html>. */
133extern const char *gai_strerror (int ecode);
134#endif
135
136#if !HAVE_DECL_GETNAMEINFO
137/* Convert socket address to printable node and service names.
138 For more details, see the POSIX:2001 specification
139 <http://www.opengroup.org/susv3xsh/getnameinfo.html>. */
140extern int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen,
141 char *restrict node, socklen_t nodelen,
142 char *restrict service, socklen_t servicelen,
143 int flags);
144
145#endif
146
147/* Possible flags for getnameinfo. */
148#ifndef NI_NUMERICHOST
149# define NI_NUMERICHOST 1
150#endif
151#ifndef NI_NUMERICSERV
152# define NI_NUMERICSERV 2
153#endif
154
155#endif /* GETADDRINFO_H */
diff --git a/gl/gethostname.c b/gl/gethostname.c
index 169dd4e..acff351 100644
--- a/gl/gethostname.c
+++ b/gl/gethostname.c
@@ -19,6 +19,9 @@
19 19
20#include <config.h> 20#include <config.h>
21 21
22/* Specification. */
23#include <unistd.h>
24
22#ifdef HAVE_UNAME 25#ifdef HAVE_UNAME
23# include <sys/utsname.h> 26# include <sys/utsname.h>
24#endif 27#endif
diff --git a/gl/getloadavg.c b/gl/getloadavg.c
index 5faa8fa..5c32f9f 100644
--- a/gl/getloadavg.c
+++ b/gl/getloadavg.c
@@ -1,7 +1,7 @@
1/* Get the system load averages. 1/* Get the system load averages.
2 2
3 Copyright (C) 1985, 1986, 1987, 1988, 1989, 1991, 1992, 1993, 1994, 3 Copyright (C) 1985, 1986, 1987, 1988, 1989, 1991, 1992, 1993, 1994,
4 1995, 1997, 1999, 2000, 2003, 2004, 2005, 2006, 2007 Free Software 4 1995, 1997, 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2008 Free Software
5 Foundation, Inc. 5 Foundation, Inc.
6 6
7 NOTE: The canonical source of this file is maintained with gnulib. 7 NOTE: The canonical source of this file is maintained with gnulib.
@@ -89,9 +89,11 @@
89# include <stdbool.h> 89# include <stdbool.h>
90#endif 90#endif
91 91
92/* Specification. */
93#include <stdlib.h>
94
92#include <errno.h> 95#include <errno.h>
93#include <stdio.h> 96#include <stdio.h>
94#include <stdlib.h>
95 97
96/* Exclude all the code except the test program at the end 98/* Exclude all the code except the test program at the end
97 if the system has its own `getloadavg' function. */ 99 if the system has its own `getloadavg' function. */
@@ -407,6 +409,7 @@
407# endif /* LOAD_AVE_TYPE */ 409# endif /* LOAD_AVE_TYPE */
408 410
409# if defined HAVE_LIBPERFSTAT 411# if defined HAVE_LIBPERFSTAT
412# include <sys/protosw.h>
410# include <libperfstat.h> 413# include <libperfstat.h>
411# include <sys/proc.h> 414# include <sys/proc.h>
412# ifndef SBITS 415# ifndef SBITS
diff --git a/gl/getopt.c b/gl/getopt.c
index 3c23601..f1e6d1f 100644
--- a/gl/getopt.c
+++ b/gl/getopt.c
@@ -2,7 +2,7 @@
2 NOTE: getopt is now part of the C library, so if you don't know what 2 NOTE: getopt is now part of the C library, so if you don't know what
3 "Keep this file name-space clean" means, talk to drepper@gnu.org 3 "Keep this file name-space clean" means, talk to drepper@gnu.org
4 before changing it! 4 before changing it!
5 Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001,2002,2003,2004,2006 5 Copyright (C) 1987,88,89,90,91,92,93,94,95,96,98,99,2000,2001,2002,2003,2004,2006,2008
6 Free Software Foundation, Inc. 6 Free Software Foundation, Inc.
7 This file is part of the GNU C Library. 7 This file is part of the GNU C Library.
8 8
@@ -30,10 +30,6 @@
30#include <string.h> 30#include <string.h>
31#include <unistd.h> 31#include <unistd.h>
32 32
33#ifdef __VMS
34# include <unixlib.h>
35#endif
36
37#ifdef _LIBC 33#ifdef _LIBC
38# include <libintl.h> 34# include <libintl.h>
39#else 35#else
diff --git a/gl/inet_ntop.c b/gl/inet_ntop.c
index 3e266a2..be091ff 100644
--- a/gl/inet_ntop.c
+++ b/gl/inet_ntop.c
@@ -1,6 +1,6 @@
1/* inet_ntop.c -- convert IPv4 and IPv6 addresses from binary to text form 1/* inet_ntop.c -- convert IPv4 and IPv6 addresses from binary to text form
2 2
3 Copyright (C) 2005, 2006 Free Software Foundation, Inc. 3 Copyright (C) 2005, 2006, 2008 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
@@ -36,7 +36,7 @@
36#include <config.h> 36#include <config.h>
37 37
38/* Specification. */ 38/* Specification. */
39#include "inet_ntop.h" 39#include <arpa/inet.h>
40 40
41#include <stdio.h> 41#include <stdio.h>
42#include <string.h> 42#include <string.h>
diff --git a/gl/localcharset.c b/gl/localcharset.c
index 4f31948..68679cf 100644
--- a/gl/localcharset.c
+++ b/gl/localcharset.c
@@ -1,6 +1,6 @@
1/* Determine a canonical name for the current locale's character encoding. 1/* Determine a canonical name for the current locale's character encoding.
2 2
3 Copyright (C) 2000-2006 Free Software Foundation, Inc. 3 Copyright (C) 2000-2006, 2008 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
@@ -34,7 +34,9 @@
34 34
35#if defined __EMX__ 35#if defined __EMX__
36/* Assume EMX program runs on OS/2, even if compiled under DOS. */ 36/* Assume EMX program runs on OS/2, even if compiled under DOS. */
37# define OS2 37# ifndef OS2
38# define OS2
39# endif
38#endif 40#endif
39 41
40#if !defined WIN32_NATIVE 42#if !defined WIN32_NATIVE
diff --git a/gl/m4/absolute-header.m4 b/gl/m4/absolute-header.m4
deleted file mode 100644
index 5b7a2fc..0000000
--- a/gl/m4/absolute-header.m4
+++ /dev/null
@@ -1,49 +0,0 @@
1# absolute-header.m4 serial 7
2dnl Copyright (C) 2006, 2007 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Derek Price.
8
9# gl_ABSOLUTE_HEADER(HEADER1 HEADER2 ...)
10# ---------------------------------------
11# Find the absolute name of a header file, assuming the header exists.
12# If the header were sys/inttypes.h, this macro would define
13# ABSOLUTE_SYS_INTTYPES_H to the `""' quoted absolute name of sys/inttypes.h
14# in config.h
15# (e.g. `#define ABSOLUTE_SYS_INTTYPES_H "///usr/include/sys/inttypes.h"').
16# The three "///" are to pacify Sun C 5.8, which otherwise would say
17# "warning: #include of /usr/include/... may be non-portable".
18# Use `""', not `<>', so that the /// cannot be confused with a C99 comment.
19AC_DEFUN([gl_ABSOLUTE_HEADER],
20[AC_LANG_PREPROC_REQUIRE()dnl
21AC_FOREACH([gl_HEADER_NAME], [$1],
22 [AS_VAR_PUSHDEF([gl_absolute_header],
23 [gl_cv_absolute_]m4_quote(m4_defn([gl_HEADER_NAME])))dnl
24 AC_CACHE_CHECK([absolute name of <]m4_quote(m4_defn([gl_HEADER_NAME]))[>],
25 m4_quote(m4_defn([gl_absolute_header])),
26 [AS_VAR_PUSHDEF([ac_header_exists],
27 [ac_cv_header_]m4_quote(m4_defn([gl_HEADER_NAME])))dnl
28 AC_CHECK_HEADERS_ONCE(m4_quote(m4_defn([gl_HEADER_NAME])))dnl
29 if test AS_VAR_GET(ac_header_exists) = yes; then
30 AC_LANG_CONFTEST([AC_LANG_SOURCE([[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]])])
31dnl eval is necessary to expand ac_cpp.
32dnl Ultrix and Pyramid sh refuse to redirect output of eval, so use subshell.
33 AS_VAR_SET(gl_absolute_header,
34[`(eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
35sed -n '\#/]m4_quote(m4_defn([gl_HEADER_NAME]))[#{
36 s#.*"\(.*/]m4_quote(m4_defn([gl_HEADER_NAME]))[\)".*#\1#
37 s#^/[^/]#//&#
38 p
39 q
40}'`])
41 fi
42 AS_VAR_POPDEF([ac_header_exists])dnl
43 ])dnl
44 AC_DEFINE_UNQUOTED(AS_TR_CPP([ABSOLUTE_]m4_quote(m4_defn([gl_HEADER_NAME]))),
45 ["AS_VAR_GET(gl_absolute_header)"],
46 [Define this to an absolute name of <]m4_quote(m4_defn([gl_HEADER_NAME]))[>.])
47 AS_VAR_POPDEF([gl_absolute_header])dnl
48])dnl
49])# gl_ABSOLUTE_HEADER
diff --git a/gl/m4/alloca.m4 b/gl/m4/alloca.m4
index 95f54a6..4b978e1 100644
--- a/gl/m4/alloca.m4
+++ b/gl/m4/alloca.m4
@@ -1,5 +1,5 @@
1# alloca.m4 serial 8 1# alloca.m4 serial 9
2dnl Copyright (C) 2002-2004, 2006, 2007 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2004, 2006, 2007, 2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -26,7 +26,7 @@ AC_DEFUN([gl_FUNC_ALLOCA],
26 ]) 26 ])
27 if test $gl_cv_rpl_alloca = yes; then 27 if test $gl_cv_rpl_alloca = yes; then
28 dnl OK, alloca can be implemented through a compiler built-in. 28 dnl OK, alloca can be implemented through a compiler built-in.
29 AC_DEFINE([HAVE_ALLOCA], 1, 29 AC_DEFINE([HAVE_ALLOCA], [1],
30 [Define to 1 if you have 'alloca' after including <alloca.h>, 30 [Define to 1 if you have 'alloca' after including <alloca.h>,
31 a header that may be supplied by this distribution.]) 31 a header that may be supplied by this distribution.])
32 ALLOCA_H=alloca.h 32 ALLOCA_H=alloca.h
diff --git a/gl/m4/arpa_inet_h.m4 b/gl/m4/arpa_inet_h.m4
index d01d098..a6e63df 100644
--- a/gl/m4/arpa_inet_h.m4
+++ b/gl/m4/arpa_inet_h.m4
@@ -1,18 +1,50 @@
1# arpa_inet_h.m4 serial 1 1# arpa_inet_h.m4 serial 5
2dnl Copyright (C) 2006 Free Software Foundation, Inc. 2dnl Copyright (C) 2006, 2008 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl Written by Simon Josefsson 7dnl Written by Simon Josefsson and Bruno Haible
8 8
9AC_DEFUN([gl_HEADER_ARPA_INET], 9AC_DEFUN([gl_HEADER_ARPA_INET],
10[ 10[
11 dnl Use AC_REQUIRE here, so that the default behavior below is expanded
12 dnl once only, before all statements that occur in other macros.
13 AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS])
14
11 AC_CHECK_HEADERS_ONCE([arpa/inet.h]) 15 AC_CHECK_HEADERS_ONCE([arpa/inet.h])
12 if test $ac_cv_header_arpa_inet_h = yes; then 16 if test $ac_cv_header_arpa_inet_h = yes; then
13 ARPA_INET_H='' 17 HAVE_ARPA_INET_H=1
14 else 18 else
15 ARPA_INET_H='arpa/inet.h' 19 ARPA_INET_H='arpa/inet.h'
20 HAVE_ARPA_INET_H=0
16 fi 21 fi
17 AC_SUBST(ARPA_INET_H) 22 AC_SUBST([HAVE_ARPA_INET_H])
23 dnl Execute this unconditionally, because ARPA_INET_H may be set by other
24 dnl modules, after this code is executed.
25 gl_CHECK_NEXT_HEADERS([arpa/inet.h])
26])
27
28dnl Unconditionally enables the replacement of <arpa/inet.h>.
29AC_DEFUN([gl_REPLACE_ARPA_INET_H],
30[
31 AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS])
32 ARPA_INET_H='arpa/inet.h'
33])
34
35AC_DEFUN([gl_ARPA_INET_MODULE_INDICATOR],
36[
37 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
38 AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS])
39 GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
40])
41
42AC_DEFUN([gl_ARPA_INET_H_DEFAULTS],
43[
44 GNULIB_INET_NTOP=0; AC_SUBST([GNULIB_INET_NTOP])
45 GNULIB_INET_PTON=0; AC_SUBST([GNULIB_INET_PTON])
46 dnl Assume proper GNU behavior unless another module says otherwise.
47 HAVE_DECL_INET_NTOP=1; AC_SUBST([HAVE_DECL_INET_NTOP])
48 HAVE_DECL_INET_PTON=1; AC_SUBST([HAVE_DECL_INET_PTON])
49 ARPA_INET_H=''; AC_SUBST([ARPA_INET_H])
18]) 50])
diff --git a/gl/m4/btowc.m4 b/gl/m4/btowc.m4
new file mode 100644
index 0000000..64ff829
--- /dev/null
+++ b/gl/m4/btowc.m4
@@ -0,0 +1,68 @@
1# btowc.m4 serial 3
2dnl Copyright (C) 2008 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_BTOWC],
8[
9 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
10
11 AC_CHECK_FUNCS_ONCE([btowc])
12 if test $ac_cv_func_btowc = no; then
13 HAVE_BTOWC=0
14 else
15
16 dnl IRIX 6.5 btowc(EOF) is 0xFF, not WEOF.
17 AC_REQUIRE([AC_PROG_CC])
18 AC_REQUIRE([gt_LOCALE_FR])
19 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
20 AC_CACHE_CHECK([whether btowc(EOF) is correct],
21 [gl_cv_func_btowc_eof],
22 [
23 dnl Initial guess, used when cross-compiling or when no suitable locale
24 dnl is present.
25changequote(,)dnl
26 case "$host_os" in
27 # Guess no on IRIX.
28 irix*) gl_cv_func_btowc_eof="guessing no" ;;
29 # Guess yes otherwise.
30 *) gl_cv_func_btowc_eof="guessing yes" ;;
31 esac
32changequote([,])dnl
33 if test $LOCALE_FR != none; then
34 AC_TRY_RUN([
35#include <locale.h>
36#include <stdio.h>
37#include <string.h>
38#include <wchar.h>
39int main ()
40{
41 if (setlocale (LC_ALL, "$LOCALE_FR") != NULL)
42 {
43 if (btowc (EOF) != WEOF)
44 return 1;
45 }
46 return 0;
47}],
48 [gl_cv_func_btowc_eof=yes],
49 [gl_cv_func_btowc_eof=no],
50 [])
51 fi
52 ])
53 case "$gl_cv_func_btowc_eof" in
54 *yes) ;;
55 *) REPLACE_BTOWC=1 ;;
56 esac
57 fi
58 if test $HAVE_BTOWC = 0 || test $REPLACE_BTOWC = 1; then
59 gl_REPLACE_WCHAR_H
60 AC_LIBOBJ([btowc])
61 gl_PREREQ_BTOWC
62 fi
63])
64
65# Prerequisites of lib/btowc.c.
66AC_DEFUN([gl_PREREQ_BTOWC], [
67 :
68])
diff --git a/gl/m4/c-strtod.m4 b/gl/m4/c-strtod.m4
index 7f206c7..0514f2d 100644
--- a/gl/m4/c-strtod.m4
+++ b/gl/m4/c-strtod.m4
@@ -1,6 +1,6 @@
1# c-strtod.m4 serial 9 1# c-strtod.m4 serial 10
2 2
3# Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc. 3# Copyright (C) 2004, 2005, 2006, 2009 Free Software Foundation, Inc.
4# This file is free software; the Free Software Foundation 4# This file is free software; the Free Software Foundation
5# gives unlimited permission to copy and/or distribute it, 5# gives unlimited permission to copy and/or distribute it,
6# with or without modifications, as long as this notice is preserved. 6# with or without modifications, as long as this notice is preserved.
@@ -29,7 +29,7 @@ AC_DEFUN([gl_C99_STRTOLD],
29 [gl_cv_func_c99_strtold=yes], 29 [gl_cv_func_c99_strtold=yes],
30 [gl_cv_func_c99_strtold=no])]) 30 [gl_cv_func_c99_strtold=no])])
31 if test $gl_cv_func_c99_strtold = yes; then 31 if test $gl_cv_func_c99_strtold = yes; then
32 AC_DEFINE([HAVE_C99_STRTOLD], 1, [Define to 1 if strtold conforms to C99.]) 32 AC_DEFINE([HAVE_C99_STRTOLD], [1], [Define to 1 if strtold conforms to C99.])
33 fi 33 fi
34]) 34])
35 35
diff --git a/gl/m4/codeset.m4 b/gl/m4/codeset.m4
index 223955b..413217b 100644
--- a/gl/m4/codeset.m4
+++ b/gl/m4/codeset.m4
@@ -1,5 +1,5 @@
1# codeset.m4 serial 2 (gettext-0.16) 1# codeset.m4 serial 4 (gettext-0.18)
2dnl Copyright (C) 2000-2002, 2006 Free Software Foundation, Inc. 2dnl Copyright (C) 2000-2002, 2006, 2008, 2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -8,14 +8,14 @@ dnl From Bruno Haible.
8 8
9AC_DEFUN([AM_LANGINFO_CODESET], 9AC_DEFUN([AM_LANGINFO_CODESET],
10[ 10[
11 AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset, 11 AC_CACHE_CHECK([for nl_langinfo and CODESET], [am_cv_langinfo_codeset],
12 [AC_TRY_LINK([#include <langinfo.h>], 12 [AC_TRY_LINK([#include <langinfo.h>],
13 [char* cs = nl_langinfo(CODESET); return !cs;], 13 [char* cs = nl_langinfo(CODESET); return !cs;],
14 am_cv_langinfo_codeset=yes, 14 [am_cv_langinfo_codeset=yes],
15 am_cv_langinfo_codeset=no) 15 [am_cv_langinfo_codeset=no])
16 ]) 16 ])
17 if test $am_cv_langinfo_codeset = yes; then 17 if test $am_cv_langinfo_codeset = yes; then
18 AC_DEFINE(HAVE_LANGINFO_CODESET, 1, 18 AC_DEFINE([HAVE_LANGINFO_CODESET], [1],
19 [Define if you have <langinfo.h> and nl_langinfo(CODESET).]) 19 [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
20 fi 20 fi
21]) 21])
diff --git a/gl/m4/double-slash-root.m4 b/gl/m4/double-slash-root.m4
index 69d60d0..8c6841b 100644
--- a/gl/m4/double-slash-root.m4
+++ b/gl/m4/double-slash-root.m4
@@ -1,5 +1,5 @@
1# double-slash-root.m4 serial 2 -*- Autoconf -*- 1# double-slash-root.m4 serial 4 -*- Autoconf -*-
2dnl Copyright (C) 2006 Free Software Foundation, Inc. 2dnl Copyright (C) 2006, 2008, 2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -24,15 +24,15 @@ AC_DEFUN([gl_DOUBLE_SLASH_ROOT],
24 gl_cv_double_slash_root='unknown, assuming no' ;; 24 gl_cv_double_slash_root='unknown, assuming no' ;;
25 esac 25 esac
26 else 26 else
27 set x `ls -di / //` 27 set x `ls -di / // 2>/dev/null`
28 if test $[2] = $[4] && wc //dev/null >/dev/null 2>&1; then 28 if test "$[2]" = "$[4]" && wc //dev/null >/dev/null 2>&1; then
29 gl_cv_double_slash_root=no 29 gl_cv_double_slash_root=no
30 else 30 else
31 gl_cv_double_slash_root=yes 31 gl_cv_double_slash_root=yes
32 fi 32 fi
33 fi]) 33 fi])
34 if test "$gl_cv_double_slash_root" = yes; then 34 if test "$gl_cv_double_slash_root" = yes; then
35 AC_DEFINE([DOUBLE_SLASH_IS_DISTINCT_ROOT], 1, 35 AC_DEFINE([DOUBLE_SLASH_IS_DISTINCT_ROOT], [1],
36 [Define to 1 if // is a file system root distinct from /.]) 36 [Define to 1 if // is a file system root distinct from /.])
37 fi 37 fi
38]) 38])
diff --git a/gl/m4/eoverflow.m4 b/gl/m4/eoverflow.m4
deleted file mode 100644
index 3bffd10..0000000
--- a/gl/m4/eoverflow.m4
+++ /dev/null
@@ -1,70 +0,0 @@
1# eoverflow.m4 serial 2
2dnl Copyright (C) 2004, 2006 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8
9# The EOVERFLOW errno value ought to be defined in <errno.h>, according to
10# POSIX. But some systems (like AIX 3) don't define it, and some systems
11# (like OSF/1) define it when _XOPEN_SOURCE_EXTENDED is defined.
12
13# Define EOVERFLOW as a C macro and as a substituted macro in such a way that
14# 1. on all systems, after inclusion of <errno.h>, EOVERFLOW is usable,
15# 2. on systems where EOVERFLOW is defined elsewhere, we use the same numeric
16# value.
17
18AC_DEFUN([gl_EOVERFLOW],
19[
20 AC_REQUIRE([AC_PROG_CC])dnl
21
22 AC_CACHE_CHECK([for EOVERFLOW], ac_cv_decl_EOVERFLOW, [
23 AC_EGREP_CPP(yes,[
24#include <errno.h>
25#ifdef EOVERFLOW
26yes
27#endif
28 ], have_eoverflow=1)
29 if test -n "$have_eoverflow"; then
30 dnl EOVERFLOW exists in <errno.h>. Don't need to define EOVERFLOW ourselves.
31 ac_cv_decl_EOVERFLOW=yes
32 else
33 AC_EGREP_CPP(yes,[
34#define _XOPEN_SOURCE_EXTENDED 1
35#include <errno.h>
36#ifdef EOVERFLOW
37yes
38#endif
39 ], have_eoverflow=1)
40 if test -n "$have_eoverflow"; then
41 dnl EOVERFLOW exists but is hidden.
42 dnl Define it to the same value.
43 AC_COMPUTE_INT([ac_cv_decl_EOVERFLOW], [EOVERFLOW], [
44#define _XOPEN_SOURCE_EXTENDED 1
45#include <errno.h>
46/* The following two lines are a workaround against an autoconf-2.52 bug. */
47#include <stdio.h>
48#include <stdlib.h>
49])
50 else
51 dnl EOVERFLOW isn't defined by the system. Define EOVERFLOW ourselves, but
52 dnl don't define it as EINVAL, because snprintf() callers want to
53 dnl distinguish EINVAL and EOVERFLOW.
54 ac_cv_decl_EOVERFLOW=E2BIG
55 fi
56 fi
57 ])
58 if test "$ac_cv_decl_EOVERFLOW" != yes; then
59 AC_DEFINE_UNQUOTED([EOVERFLOW], [$ac_cv_decl_EOVERFLOW],
60 [Define as good substitute value for EOVERFLOW.])
61 EOVERFLOW="$ac_cv_decl_EOVERFLOW"
62 AC_SUBST(EOVERFLOW)
63 fi
64])
65
66dnl Autoconf >= 2.61 has AC_COMPUTE_INT built-in.
67dnl Remove this when we can assume autoconf >= 2.61.
68m4_ifdef([AC_COMPUTE_INT], [], [
69 AC_DEFUN([AC_COMPUTE_INT], [_AC_COMPUTE_INT([$2],[$1],[$3],[$4])])
70])
diff --git a/gl/m4/errno_h.m4 b/gl/m4/errno_h.m4
new file mode 100644
index 0000000..0682d1a
--- /dev/null
+++ b/gl/m4/errno_h.m4
@@ -0,0 +1,119 @@
1# errno_h.m4 serial 3
2dnl Copyright (C) 2004, 2006, 2008, 2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_HEADER_ERRNO_H],
8[
9 dnl Use AC_REQUIRE here, so that the default behavior below is expanded
10 dnl once only, before all statements that occur in other macros.
11 AC_REQUIRE([gl_HEADER_ERRNO_H_BODY])
12])
13
14AC_DEFUN([gl_HEADER_ERRNO_H_BODY],
15[
16 AC_REQUIRE([AC_PROG_CC])
17 AC_CACHE_CHECK([for complete errno.h], [gl_cv_header_errno_h_complete], [
18 AC_EGREP_CPP([booboo],[
19#include <errno.h>
20#if !defined ENOMSG
21booboo
22#endif
23#if !defined EIDRM
24booboo
25#endif
26#if !defined ENOLINK
27booboo
28#endif
29#if !defined EPROTO
30booboo
31#endif
32#if !defined EMULTIHOP
33booboo
34#endif
35#if !defined EBADMSG
36booboo
37#endif
38#if !defined EOVERFLOW
39booboo
40#endif
41#if !defined ENOTSUP
42booboo
43#endif
44#if !defined ECANCELED
45booboo
46#endif
47 ],
48 [gl_cv_header_errno_h_complete=no],
49 [gl_cv_header_errno_h_complete=yes])
50 ])
51 if test $gl_cv_header_errno_h_complete = yes; then
52 ERRNO_H=''
53 else
54 gl_CHECK_NEXT_HEADERS([errno.h])
55 ERRNO_H='errno.h'
56 fi
57 AC_SUBST([ERRNO_H])
58 gl_REPLACE_ERRNO_VALUE([EMULTIHOP])
59 gl_REPLACE_ERRNO_VALUE([ENOLINK])
60 gl_REPLACE_ERRNO_VALUE([EOVERFLOW])
61])
62
63# Assuming $1 = EOVERFLOW.
64# The EOVERFLOW errno value ought to be defined in <errno.h>, according to
65# POSIX. But some systems (like OpenBSD 4.0 or AIX 3) don't define it, and
66# some systems (like OSF/1) define it when _XOPEN_SOURCE_EXTENDED is defined.
67# Check for the value of EOVERFLOW.
68# Set the variables EOVERFLOW_HIDDEN and EOVERFLOW_VALUE.
69AC_DEFUN([gl_REPLACE_ERRNO_VALUE],
70[
71 if test -n "$ERRNO_H"; then
72 AC_CACHE_CHECK([for ]$1[ value], [gl_cv_header_errno_h_]$1, [
73 AC_EGREP_CPP([yes],[
74#include <errno.h>
75#ifdef ]$1[
76yes
77#endif
78 ],
79 [gl_cv_header_errno_h_]$1[=yes],
80 [gl_cv_header_errno_h_]$1[=no])
81 if test $gl_cv_header_errno_h_]$1[ = no; then
82 AC_EGREP_CPP([yes],[
83#define _XOPEN_SOURCE_EXTENDED 1
84#include <errno.h>
85#ifdef ]$1[
86yes
87#endif
88 ], [gl_cv_header_errno_h_]$1[=hidden])
89 if test $gl_cv_header_errno_h_]$1[ = hidden; then
90 dnl The macro exists but is hidden.
91 dnl Define it to the same value.
92 AC_COMPUTE_INT([gl_cv_header_errno_h_]$1, $1, [
93#define _XOPEN_SOURCE_EXTENDED 1
94#include <errno.h>
95/* The following two lines are a workaround against an autoconf-2.52 bug. */
96#include <stdio.h>
97#include <stdlib.h>
98])
99 fi
100 fi
101 ])
102 case $gl_cv_header_errno_h_]$1[ in
103 yes | no)
104 ]$1[_HIDDEN=0; ]$1[_VALUE=
105 ;;
106 *)
107 ]$1[_HIDDEN=1; ]$1[_VALUE="$gl_cv_header_errno_h_]$1["
108 ;;
109 esac
110 AC_SUBST($1[_HIDDEN])
111 AC_SUBST($1[_VALUE])
112 fi
113])
114
115dnl Autoconf >= 2.61 has AC_COMPUTE_INT built-in.
116dnl Remove this when we can assume autoconf >= 2.61.
117m4_ifdef([AC_COMPUTE_INT], [], [
118 AC_DEFUN([AC_COMPUTE_INT], [_AC_COMPUTE_INT([$2],[$1],[$3],[$4])])
119])
diff --git a/gl/m4/extensions.m4 b/gl/m4/extensions.m4
index bcbb3ce..611fcfd 100644
--- a/gl/m4/extensions.m4
+++ b/gl/m4/extensions.m4
@@ -1,7 +1,7 @@
1# serial 5 -*- Autoconf -*- 1# serial 6 -*- Autoconf -*-
2# Enable extensions on systems that normally disable them. 2# Enable extensions on systems that normally disable them.
3 3
4# Copyright (C) 2003, 2006, 2007 Free Software Foundation, Inc. 4# Copyright (C) 2003, 2006-2008 Free Software Foundation, Inc.
5# This file is free software; the Free Software Foundation 5# This file is free software; the Free Software Foundation
6# gives unlimited permission to copy and/or distribute it, 6# gives unlimited permission to copy and/or distribute it,
7# with or without modifications, as long as this notice is preserved. 7# with or without modifications, as long as this notice is preserved.
@@ -24,6 +24,8 @@ AC_DEFUN([AC_USE_SYSTEM_EXTENSIONS],
24[AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl 24[AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
25AC_BEFORE([$0], [AC_RUN_IFELSE])dnl 25AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
26 26
27 AC_REQUIRE([AC_CANONICAL_HOST])
28
27 AC_CHECK_HEADER([minix/config.h], [MINIX=yes], [MINIX=]) 29 AC_CHECK_HEADER([minix/config.h], [MINIX=yes], [MINIX=])
28 if test "$MINIX" = yes; then 30 if test "$MINIX" = yes; then
29 AC_DEFINE([_POSIX_SOURCE], [1], 31 AC_DEFINE([_POSIX_SOURCE], [1],
@@ -36,6 +38,16 @@ AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
36 [Define to 1 if on MINIX.]) 38 [Define to 1 if on MINIX.])
37 fi 39 fi
38 40
41 dnl HP-UX 11.11 defines mbstate_t only if _XOPEN_SOURCE is defined to 500,
42 dnl regardless of whether the flags -Ae or _D_HPUX_SOURCE=1 are already
43 dnl provided.
44 case "$host_os" in
45 hpux*)
46 AC_DEFINE([_XOPEN_SOURCE], [500],
47 [Define to 500 only on HP-UX.])
48 ;;
49 esac
50
39 AH_VERBATIM([__EXTENSIONS__], 51 AH_VERBATIM([__EXTENSIONS__],
40[/* Enable extensions on AIX 3, Interix. */ 52[/* Enable extensions on AIX 3, Interix. */
41#ifndef _ALL_SOURCE 53#ifndef _ALL_SOURCE
@@ -61,9 +73,9 @@ AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
61 AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__], 73 AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__],
62 [ac_cv_safe_to_define___extensions__], 74 [ac_cv_safe_to_define___extensions__],
63 [AC_COMPILE_IFELSE( 75 [AC_COMPILE_IFELSE(
64 [AC_LANG_PROGRAM([ 76 [AC_LANG_PROGRAM([[
65# define __EXTENSIONS__ 1 77# define __EXTENSIONS__ 1
66 AC_INCLUDES_DEFAULT])], 78 ]AC_INCLUDES_DEFAULT])],
67 [ac_cv_safe_to_define___extensions__=yes], 79 [ac_cv_safe_to_define___extensions__=yes],
68 [ac_cv_safe_to_define___extensions__=no])]) 80 [ac_cv_safe_to_define___extensions__=no])])
69 test $ac_cv_safe_to_define___extensions__ = yes && 81 test $ac_cv_safe_to_define___extensions__ = yes &&
diff --git a/gl/m4/fcntl_h.m4 b/gl/m4/fcntl_h.m4
new file mode 100644
index 0000000..4a7fc42
--- /dev/null
+++ b/gl/m4/fcntl_h.m4
@@ -0,0 +1,94 @@
1# Configure fcntl.h.
2dnl Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl Written by Paul Eggert.
8
9AC_DEFUN([gl_FCNTL_H],
10[
11 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
12 AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h],
13 [AC_RUN_IFELSE(
14 [AC_LANG_PROGRAM(
15 [[#include <sys/types.h>
16 #include <sys/stat.h>
17 #include <unistd.h>
18 #include <fcntl.h>
19 #ifndef O_NOATIME
20 #define O_NOATIME 0
21 #endif
22 #ifndef O_NOFOLLOW
23 #define O_NOFOLLOW 0
24 #endif
25 static int const constants[] =
26 {
27 O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND,
28 O_NONBLOCK, O_SYNC, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY
29 };
30 ]],
31 [[
32 int status = !constants;
33 {
34 static char const sym[] = "conftest.sym";
35 if (symlink (".", sym) != 0
36 || close (open (sym, O_RDONLY | O_NOFOLLOW)) == 0)
37 status |= 32;
38 }
39 {
40 static char const file[] = "confdefs.h";
41 int fd = open (file, O_RDONLY | O_NOATIME);
42 char c;
43 struct stat st0, st1;
44 if (fd < 0
45 || fstat (fd, &st0) != 0
46 || sleep (1) != 0
47 || read (fd, &c, 1) != 1
48 || close (fd) != 0
49 || stat (file, &st1) != 0
50 || st0.st_atime != st1.st_atime)
51 status |= 64;
52 }
53 return status;]])],
54 [gl_cv_header_working_fcntl_h=yes],
55 [case $? in #(
56 32) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #(
57 64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #(
58 96) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #(
59 *) gl_cv_header_working_fcntl_h='no';;
60 esac],
61 [gl_cv_header_working_fcntl_h=cross-compiling])])
62
63 case $gl_cv_header_working_fcntl_h in #(
64 *O_NOATIME* | no | cross-compiling) ac_val=0;; #(
65 *) ac_val=1;;
66 esac
67 AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOATIME], [$ac_val],
68 [Define to 1 if O_NOATIME works.])
69
70 case $gl_cv_header_working_fcntl_h in #(
71 *O_NOFOLLOW* | no | cross-compiling) ac_val=0;; #(
72 *) ac_val=1;;
73 esac
74 AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOFOLLOW], [$ac_val],
75 [Define to 1 if O_NOFOLLOW works.])
76
77 gl_CHECK_NEXT_HEADERS([fcntl.h])
78 FCNTL_H='fcntl.h'
79 AC_SUBST([FCNTL_H])
80])
81
82AC_DEFUN([gl_FCNTL_MODULE_INDICATOR],
83[
84 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
85 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
86 GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
87])
88
89AC_DEFUN([gl_FCNTL_H_DEFAULTS],
90[
91 GNULIB_OPEN=0; AC_SUBST([GNULIB_OPEN])
92 dnl Assume proper GNU behavior unless another module says otherwise.
93 REPLACE_OPEN=0; AC_SUBST([REPLACE_OPEN])
94])
diff --git a/gl/m4/fsusage.m4 b/gl/m4/fsusage.m4
index 18eedbc..8b8cbf7 100644
--- a/gl/m4/fsusage.m4
+++ b/gl/m4/fsusage.m4
@@ -1,7 +1,7 @@
1#serial 23 1# serial 24
2# Obtaining file system usage information. 2# Obtaining file system usage information.
3 3
4# Copyright (C) 1997, 1998, 2000, 2001, 2003-2007 Free Software Foundation, Inc. 4# Copyright (C) 1997-1998, 2000-2001, 2003-2009 Free Software Foundation, Inc.
5# 5#
6# This file is free software; the Free Software Foundation 6# This file is free software; the Free Software Foundation
7# gives unlimited permission to copy and/or distribute it, 7# gives unlimited permission to copy and/or distribute it,
@@ -11,16 +11,16 @@
11 11
12AC_DEFUN([gl_FSUSAGE], 12AC_DEFUN([gl_FSUSAGE],
13[ 13[
14 AC_CHECK_HEADERS_ONCE(sys/param.h) 14 AC_CHECK_HEADERS_ONCE([sys/param.h])
15 AC_CHECK_HEADERS_ONCE(sys/vfs.h sys/fs_types.h) 15 AC_CHECK_HEADERS_ONCE([sys/vfs.h sys/fs_types.h])
16 AC_CHECK_HEADERS(sys/mount.h, [], [], 16 AC_CHECK_HEADERS([sys/mount.h], [], [],
17 [AC_INCLUDES_DEFAULT 17 [AC_INCLUDES_DEFAULT
18 [#if HAVE_SYS_PARAM_H 18 [#if HAVE_SYS_PARAM_H
19 #include <sys/param.h> 19 #include <sys/param.h>
20 #endif]]) 20 #endif]])
21 gl_FILE_SYSTEM_USAGE([gl_cv_fs_space=yes], [gl_cv_fs_space=no]) 21 gl_FILE_SYSTEM_USAGE([gl_cv_fs_space=yes], [gl_cv_fs_space=no])
22 if test $gl_cv_fs_space = yes; then 22 if test $gl_cv_fs_space = yes; then
23 AC_LIBOBJ(fsusage) 23 AC_LIBOBJ([fsusage])
24 gl_PREREQ_FSUSAGE_EXTRA 24 gl_PREREQ_FSUSAGE_EXTRA
25 fi 25 fi
26]) 26])
@@ -38,21 +38,21 @@ AC_MSG_NOTICE([checking how to get file system space usage])
38ac_fsusage_space=no 38ac_fsusage_space=no
39 39
40# Perform only the link test since it seems there are no variants of the 40# Perform only the link test since it seems there are no variants of the
41# statvfs function. This check is more than just AC_CHECK_FUNCS(statvfs) 41# statvfs function. This check is more than just AC_CHECK_FUNCS([statvfs])
42# because that got a false positive on SCO OSR5. Adding the declaration 42# because that got a false positive on SCO OSR5. Adding the declaration
43# of a `struct statvfs' causes this test to fail (as it should) on such 43# of a `struct statvfs' causes this test to fail (as it should) on such
44# systems. That system is reported to work fine with STAT_STATFS4 which 44# systems. That system is reported to work fine with STAT_STATFS4 which
45# is what it gets when this test fails. 45# is what it gets when this test fails.
46if test $ac_fsusage_space = no; then 46if test $ac_fsusage_space = no; then
47 # SVR4 47 # SVR4
48 AC_CACHE_CHECK([for statvfs function (SVR4)], fu_cv_sys_stat_statvfs, 48 AC_CACHE_CHECK([for statvfs function (SVR4)], [fu_cv_sys_stat_statvfs],
49 [AC_TRY_LINK([#include <sys/types.h> 49 [AC_TRY_LINK([#include <sys/types.h>
50#if defined __GLIBC__ && !defined __BEOS__ 50#if defined __GLIBC__ && defined __linux__
51Do not use statvfs on systems with GNU libc, because that function stats 51Do not use statvfs on systems with GNU libc on Linux, because that function
52all preceding entries in /proc/mounts, and that makes df hang if even 52stats all preceding entries in /proc/mounts, and that makes df hang if even
53one of the corresponding file systems is hard-mounted, but not available. 53one of the corresponding file systems is hard-mounted, but not available.
54statvfs in GNU libc on BeOS operates differently: it only makes a system 54statvfs in GNU libc on Hurd, BeOS, Haiku operates differently: it only makes
55call. 55a system call.
56#endif 56#endif
57 57
58#ifdef __osf__ 58#ifdef __osf__
@@ -65,7 +65,7 @@ call.
65 fu_cv_sys_stat_statvfs=no)]) 65 fu_cv_sys_stat_statvfs=no)])
66 if test $fu_cv_sys_stat_statvfs = yes; then 66 if test $fu_cv_sys_stat_statvfs = yes; then
67 ac_fsusage_space=yes 67 ac_fsusage_space=yes
68 AC_DEFINE(STAT_STATVFS, 1, 68 AC_DEFINE([STAT_STATVFS], [1],
69 [ Define if there is a function named statvfs. (SVR4)]) 69 [ Define if there is a function named statvfs. (SVR4)])
70 fi 70 fi
71fi 71fi
@@ -73,7 +73,7 @@ fi
73if test $ac_fsusage_space = no; then 73if test $ac_fsusage_space = no; then
74 # DEC Alpha running OSF/1 74 # DEC Alpha running OSF/1
75 AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)]) 75 AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
76 AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1, 76 AC_CACHE_VAL([fu_cv_sys_stat_statfs3_osf1],
77 [AC_TRY_RUN([ 77 [AC_TRY_RUN([
78#include <sys/param.h> 78#include <sys/param.h>
79#include <sys/types.h> 79#include <sys/types.h>
@@ -88,10 +88,10 @@ if test $ac_fsusage_space = no; then
88 fu_cv_sys_stat_statfs3_osf1=yes, 88 fu_cv_sys_stat_statfs3_osf1=yes,
89 fu_cv_sys_stat_statfs3_osf1=no, 89 fu_cv_sys_stat_statfs3_osf1=no,
90 fu_cv_sys_stat_statfs3_osf1=no)]) 90 fu_cv_sys_stat_statfs3_osf1=no)])
91 AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1) 91 AC_MSG_RESULT([$fu_cv_sys_stat_statfs3_osf1])
92 if test $fu_cv_sys_stat_statfs3_osf1 = yes; then 92 if test $fu_cv_sys_stat_statfs3_osf1 = yes; then
93 ac_fsusage_space=yes 93 ac_fsusage_space=yes
94 AC_DEFINE(STAT_STATFS3_OSF1, 1, 94 AC_DEFINE([STAT_STATFS3_OSF1], [1],
95 [ Define if statfs takes 3 args. (DEC Alpha running OSF/1)]) 95 [ Define if statfs takes 3 args. (DEC Alpha running OSF/1)])
96 fi 96 fi
97fi 97fi
@@ -100,7 +100,7 @@ if test $ac_fsusage_space = no; then
100# AIX 100# AIX
101 AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl 101 AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
102member (AIX, 4.3BSD)]) 102member (AIX, 4.3BSD)])
103 AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize, 103 AC_CACHE_VAL([fu_cv_sys_stat_statfs2_bsize],
104 [AC_TRY_RUN([ 104 [AC_TRY_RUN([
105#ifdef HAVE_SYS_PARAM_H 105#ifdef HAVE_SYS_PARAM_H
106#include <sys/param.h> 106#include <sys/param.h>
@@ -121,10 +121,10 @@ member (AIX, 4.3BSD)])
121 fu_cv_sys_stat_statfs2_bsize=yes, 121 fu_cv_sys_stat_statfs2_bsize=yes,
122 fu_cv_sys_stat_statfs2_bsize=no, 122 fu_cv_sys_stat_statfs2_bsize=no,
123 fu_cv_sys_stat_statfs2_bsize=no)]) 123 fu_cv_sys_stat_statfs2_bsize=no)])
124 AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize) 124 AC_MSG_RESULT([$fu_cv_sys_stat_statfs2_bsize])
125 if test $fu_cv_sys_stat_statfs2_bsize = yes; then 125 if test $fu_cv_sys_stat_statfs2_bsize = yes; then
126 ac_fsusage_space=yes 126 ac_fsusage_space=yes
127 AC_DEFINE(STAT_STATFS2_BSIZE, 1, 127 AC_DEFINE([STAT_STATFS2_BSIZE], [1],
128[ Define if statfs takes 2 args and struct statfs has a field named f_bsize. 128[ Define if statfs takes 2 args and struct statfs has a field named f_bsize.
129 (4.3BSD, SunOS 4, HP-UX, AIX PS/2)]) 129 (4.3BSD, SunOS 4, HP-UX, AIX PS/2)])
130 fi 130 fi
@@ -133,7 +133,7 @@ fi
133if test $ac_fsusage_space = no; then 133if test $ac_fsusage_space = no; then
134# SVR3 134# SVR3
135 AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)]) 135 AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
136 AC_CACHE_VAL(fu_cv_sys_stat_statfs4, 136 AC_CACHE_VAL([fu_cv_sys_stat_statfs4],
137 [AC_TRY_RUN([#include <sys/types.h> 137 [AC_TRY_RUN([#include <sys/types.h>
138#include <sys/statfs.h> 138#include <sys/statfs.h>
139 int 139 int
@@ -145,10 +145,10 @@ if test $ac_fsusage_space = no; then
145 fu_cv_sys_stat_statfs4=yes, 145 fu_cv_sys_stat_statfs4=yes,
146 fu_cv_sys_stat_statfs4=no, 146 fu_cv_sys_stat_statfs4=no,
147 fu_cv_sys_stat_statfs4=no)]) 147 fu_cv_sys_stat_statfs4=no)])
148 AC_MSG_RESULT($fu_cv_sys_stat_statfs4) 148 AC_MSG_RESULT([$fu_cv_sys_stat_statfs4])
149 if test $fu_cv_sys_stat_statfs4 = yes; then 149 if test $fu_cv_sys_stat_statfs4 = yes; then
150 ac_fsusage_space=yes 150 ac_fsusage_space=yes
151 AC_DEFINE(STAT_STATFS4, 1, 151 AC_DEFINE([STAT_STATFS4], [1],
152 [ Define if statfs takes 4 args. (SVR3, Dynix, Irix, Dolphin)]) 152 [ Define if statfs takes 4 args. (SVR3, Dynix, Irix, Dolphin)])
153 fi 153 fi
154fi 154fi
@@ -157,7 +157,7 @@ if test $ac_fsusage_space = no; then
157# 4.4BSD and NetBSD 157# 4.4BSD and NetBSD
158 AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl 158 AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
159member (4.4BSD and NetBSD)]) 159member (4.4BSD and NetBSD)])
160 AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize, 160 AC_CACHE_VAL([fu_cv_sys_stat_statfs2_fsize],
161 [AC_TRY_RUN([#include <sys/types.h> 161 [AC_TRY_RUN([#include <sys/types.h>
162#ifdef HAVE_SYS_PARAM_H 162#ifdef HAVE_SYS_PARAM_H
163#include <sys/param.h> 163#include <sys/param.h>
@@ -175,10 +175,10 @@ member (4.4BSD and NetBSD)])
175 fu_cv_sys_stat_statfs2_fsize=yes, 175 fu_cv_sys_stat_statfs2_fsize=yes,
176 fu_cv_sys_stat_statfs2_fsize=no, 176 fu_cv_sys_stat_statfs2_fsize=no,
177 fu_cv_sys_stat_statfs2_fsize=no)]) 177 fu_cv_sys_stat_statfs2_fsize=no)])
178 AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize) 178 AC_MSG_RESULT([$fu_cv_sys_stat_statfs2_fsize])
179 if test $fu_cv_sys_stat_statfs2_fsize = yes; then 179 if test $fu_cv_sys_stat_statfs2_fsize = yes; then
180 ac_fsusage_space=yes 180 ac_fsusage_space=yes
181 AC_DEFINE(STAT_STATFS2_FSIZE, 1, 181 AC_DEFINE([STAT_STATFS2_FSIZE], [1],
182[ Define if statfs takes 2 args and struct statfs has a field named f_fsize. 182[ Define if statfs takes 2 args and struct statfs has a field named f_fsize.
183 (4.4BSD, NetBSD)]) 183 (4.4BSD, NetBSD)])
184 fi 184 fi
@@ -187,7 +187,7 @@ fi
187if test $ac_fsusage_space = no; then 187if test $ac_fsusage_space = no; then
188 # Ultrix 188 # Ultrix
189 AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)]) 189 AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)])
190 AC_CACHE_VAL(fu_cv_sys_stat_fs_data, 190 AC_CACHE_VAL([fu_cv_sys_stat_fs_data],
191 [AC_TRY_RUN([#include <sys/types.h> 191 [AC_TRY_RUN([#include <sys/types.h>
192#ifdef HAVE_SYS_PARAM_H 192#ifdef HAVE_SYS_PARAM_H
193#include <sys/param.h> 193#include <sys/param.h>
@@ -209,10 +209,10 @@ if test $ac_fsusage_space = no; then
209 fu_cv_sys_stat_fs_data=yes, 209 fu_cv_sys_stat_fs_data=yes,
210 fu_cv_sys_stat_fs_data=no, 210 fu_cv_sys_stat_fs_data=no,
211 fu_cv_sys_stat_fs_data=no)]) 211 fu_cv_sys_stat_fs_data=no)])
212 AC_MSG_RESULT($fu_cv_sys_stat_fs_data) 212 AC_MSG_RESULT([$fu_cv_sys_stat_fs_data])
213 if test $fu_cv_sys_stat_fs_data = yes; then 213 if test $fu_cv_sys_stat_fs_data = yes; then
214 ac_fsusage_space=yes 214 ac_fsusage_space=yes
215 AC_DEFINE(STAT_STATFS2_FS_DATA, 1, 215 AC_DEFINE([STAT_STATFS2_FS_DATA], [1],
216[ Define if statfs takes 2 args and the second argument has 216[ Define if statfs takes 2 args and the second argument has
217 type struct fs_data. (Ultrix)]) 217 type struct fs_data. (Ultrix)])
218 fi 218 fi
@@ -222,7 +222,7 @@ if test $ac_fsusage_space = no; then
222 # SVR2 222 # SVR2
223 AC_TRY_CPP([#include <sys/filsys.h> 223 AC_TRY_CPP([#include <sys/filsys.h>
224 ], 224 ],
225 AC_DEFINE(STAT_READ_FILSYS, 1, 225 AC_DEFINE([STAT_READ_FILSYS], [1],
226 [Define if there is no specific function for reading file systems usage 226 [Define if there is no specific function for reading file systems usage
227 information and you have the <sys/filsys.h> header file. (SVR2)]) 227 information and you have the <sys/filsys.h> header file. (SVR2)])
228 ac_fsusage_space=yes) 228 ac_fsusage_space=yes)
@@ -239,7 +239,7 @@ AS_IF([test $ac_fsusage_space = yes], [$1], [$2])
239AC_DEFUN([gl_STATFS_TRUNCATES], 239AC_DEFUN([gl_STATFS_TRUNCATES],
240[ 240[
241 AC_MSG_CHECKING([for statfs that truncates block counts]) 241 AC_MSG_CHECKING([for statfs that truncates block counts])
242 AC_CACHE_VAL(fu_cv_sys_truncating_statfs, 242 AC_CACHE_VAL([fu_cv_sys_truncating_statfs],
243 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 243 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
244#if !defined(sun) && !defined(__sun) 244#if !defined(sun) && !defined(__sun)
245choke -- this is a workaround for a Sun-specific problem 245choke -- this is a workaround for a Sun-specific problem
@@ -251,19 +251,19 @@ choke -- this is a workaround for a Sun-specific problem
251 [fu_cv_sys_truncating_statfs=yes], 251 [fu_cv_sys_truncating_statfs=yes],
252 [fu_cv_sys_truncating_statfs=no])]) 252 [fu_cv_sys_truncating_statfs=no])])
253 if test $fu_cv_sys_truncating_statfs = yes; then 253 if test $fu_cv_sys_truncating_statfs = yes; then
254 AC_DEFINE(STATFS_TRUNCATES_BLOCK_COUNTS, 1, 254 AC_DEFINE([STATFS_TRUNCATES_BLOCK_COUNTS], [1],
255 [Define if the block counts reported by statfs may be truncated to 2GB 255 [Define if the block counts reported by statfs may be truncated to 2GB
256 and the correct values may be stored in the f_spare array. 256 and the correct values may be stored in the f_spare array.
257 (SunOS 4.1.2, 4.1.3, and 4.1.3_U1 are reported to have this problem. 257 (SunOS 4.1.2, 4.1.3, and 4.1.3_U1 are reported to have this problem.
258 SunOS 4.1.1 seems not to be affected.)]) 258 SunOS 4.1.1 seems not to be affected.)])
259 fi 259 fi
260 AC_MSG_RESULT($fu_cv_sys_truncating_statfs) 260 AC_MSG_RESULT([$fu_cv_sys_truncating_statfs])
261]) 261])
262 262
263 263
264# Prerequisites of lib/fsusage.c not done by gl_FILE_SYSTEM_USAGE. 264# Prerequisites of lib/fsusage.c not done by gl_FILE_SYSTEM_USAGE.
265AC_DEFUN([gl_PREREQ_FSUSAGE_EXTRA], 265AC_DEFUN([gl_PREREQ_FSUSAGE_EXTRA],
266[ 266[
267 AC_CHECK_HEADERS(dustat.h sys/fs/s5param.h sys/filsys.h sys/statfs.h) 267 AC_CHECK_HEADERS([dustat.h sys/fs/s5param.h sys/filsys.h sys/statfs.h])
268 gl_STATFS_TRUNCATES 268 gl_STATFS_TRUNCATES
269]) 269])
diff --git a/gl/m4/getaddrinfo.m4 b/gl/m4/getaddrinfo.m4
index 5d36c19..4088671 100644
--- a/gl/m4/getaddrinfo.m4
+++ b/gl/m4/getaddrinfo.m4
@@ -1,5 +1,5 @@
1# getaddrinfo.m4 serial 15 1# getaddrinfo.m4 serial 20
2dnl Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc. 2dnl Copyright (C) 2004-2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -7,11 +7,23 @@ dnl with or without modifications, as long as this notice is preserved.
7AC_DEFUN([gl_GETADDRINFO], 7AC_DEFUN([gl_GETADDRINFO],
8[ 8[
9 AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H 9 AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
10 AC_REQUIRE([gl_HEADER_NETDB])dnl for HAVE_NETDB_H
10 AC_MSG_NOTICE([checking how to do getaddrinfo, freeaddrinfo and getnameinfo]) 11 AC_MSG_NOTICE([checking how to do getaddrinfo, freeaddrinfo and getnameinfo])
12 GETADDRINFO_LIB=
13 gai_saved_LIBS="$LIBS"
11 14
12 AC_CHECK_HEADERS_ONCE(netdb.h) 15 dnl Where is getaddrinfo()?
16 dnl - On Solaris, it is in libsocket.
17 dnl - On Haiku, it is in libnetwork.
18 dnl - On BeOS, it is in libnet.
19 dnl - On native Windows, it is in ws2_32.dll.
20 dnl - Otherwise it is in libc.
21 AC_SEARCH_LIBS([getaddrinfo], [socket network net],
22 [if test "$ac_cv_search_getaddrinfo" != "none required"; then
23 GETADDRINFO_LIB="$ac_cv_search_getaddrinfo"
24 fi])
25 LIBS="$gai_saved_LIBS $GETADDRINFO_LIB"
13 26
14 AC_SEARCH_LIBS(getaddrinfo, [nsl socket])
15 AC_CACHE_CHECK([for getaddrinfo], [gl_cv_func_getaddrinfo], [ 27 AC_CACHE_CHECK([for getaddrinfo], [gl_cv_func_getaddrinfo], [
16 AC_TRY_LINK([ 28 AC_TRY_LINK([
17#include <sys/types.h> 29#include <sys/types.h>
@@ -26,7 +38,7 @@ AC_DEFUN([gl_GETADDRINFO],
26 [gl_cv_func_getaddrinfo=yes], 38 [gl_cv_func_getaddrinfo=yes],
27 [gl_cv_func_getaddrinfo=no])]) 39 [gl_cv_func_getaddrinfo=no])])
28 if test $gl_cv_func_getaddrinfo = no; then 40 if test $gl_cv_func_getaddrinfo = no; then
29 AC_CACHE_CHECK(for getaddrinfo in ws2tcpip.h and -lws2_32, 41 AC_CACHE_CHECK([for getaddrinfo in ws2tcpip.h and -lws2_32],
30 gl_cv_w32_getaddrinfo, [ 42 gl_cv_w32_getaddrinfo, [
31 gl_cv_w32_getaddrinfo=no 43 gl_cv_w32_getaddrinfo=no
32 am_save_LIBS="$LIBS" 44 am_save_LIBS="$LIBS"
@@ -37,11 +49,13 @@ AC_DEFUN([gl_GETADDRINFO],
37#endif 49#endif
38#include <stddef.h> 50#include <stddef.h>
39], [getaddrinfo(NULL, NULL, NULL, NULL);], gl_cv_w32_getaddrinfo=yes) 51], [getaddrinfo(NULL, NULL, NULL, NULL);], gl_cv_w32_getaddrinfo=yes)
40 LIBS="$am_save_LIBS"]) 52 LIBS="$am_save_LIBS"
53 ])
41 if test "$gl_cv_w32_getaddrinfo" = "yes"; then 54 if test "$gl_cv_w32_getaddrinfo" = "yes"; then
42 LIBS="$LIBS -lws2_32" 55 GETADDRINFO_LIB="-lws2_32"
56 LIBS="$gai_saved_LIBS $GETADDRINFO_LIB"
43 else 57 else
44 AC_LIBOBJ(getaddrinfo) 58 AC_LIBOBJ([getaddrinfo])
45 fi 59 fi
46 fi 60 fi
47 61
@@ -66,40 +80,34 @@ AC_DEFUN([gl_GETADDRINFO],
66 [gl_cv_func_gai_strerror=yes], 80 [gl_cv_func_gai_strerror=yes],
67 [gl_cv_func_gai_strerror=no])]) 81 [gl_cv_func_gai_strerror=no])])
68 if test $gl_cv_func_gai_strerror = no; then 82 if test $gl_cv_func_gai_strerror = no; then
69 AC_LIBOBJ(gai_strerror) 83 AC_LIBOBJ([gai_strerror])
70 fi 84 fi
71 85
86 LIBS="$gai_saved_LIBS"
87
72 gl_PREREQ_GETADDRINFO 88 gl_PREREQ_GETADDRINFO
89
90 AC_SUBST([GETADDRINFO_LIB])
73]) 91])
74 92
75# Prerequisites of lib/getaddrinfo.h and lib/getaddrinfo.c. 93# Prerequisites of lib/netdb.in.h and lib/getaddrinfo.c.
76AC_DEFUN([gl_PREREQ_GETADDRINFO], [ 94AC_DEFUN([gl_PREREQ_GETADDRINFO], [
95 AC_REQUIRE([gl_NETDB_H_DEFAULTS])
77 AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H 96 AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
78 AC_SEARCH_LIBS(gethostbyname, [inet nsl]) 97 AC_REQUIRE([gl_HOSTENT]) dnl for HOSTENT_LIB
79 AC_SEARCH_LIBS(getservbyname, [inet nsl socket xnet]) 98 AC_REQUIRE([gl_SERVENT]) dnl for SERVENT_LIB
80 AC_CHECK_FUNCS(gethostbyname,, [
81 AC_CACHE_CHECK(for gethostbyname in winsock2.h and -lws2_32,
82 gl_cv_w32_gethostbyname, [
83 gl_cv_w32_gethostbyname=no
84 am_save_LIBS="$LIBS"
85 LIBS="$LIBS -lws2_32"
86 AC_TRY_LINK([
87#ifdef HAVE_WINSOCK2_H
88#include <winsock2.h>
89#endif
90#include <stddef.h>
91], [gethostbyname(NULL);], gl_cv_w32_gethostbyname=yes)
92 LIBS="$am_save_LIBS"])
93 if test "$gl_cv_w32_gethostbyname" = "yes"; then
94 LIBS="$LIBS -lws2_32"
95 fi
96 ])
97 AC_REQUIRE([AC_C_RESTRICT]) 99 AC_REQUIRE([AC_C_RESTRICT])
98 AC_REQUIRE([gl_SOCKET_FAMILIES]) 100 AC_REQUIRE([gl_SOCKET_FAMILIES])
99 AC_REQUIRE([gl_HEADER_SYS_SOCKET]) 101 AC_REQUIRE([gl_HEADER_SYS_SOCKET])
100 AC_REQUIRE([AC_C_INLINE]) 102 AC_REQUIRE([AC_C_INLINE])
101 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) 103 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
102 AC_CHECK_HEADERS_ONCE(netinet/in.h netdb.h) 104
105 dnl Including sys/socket.h is wrong for Windows, but Windows does not
106 dnl have sa_len so the result is correct anyway.
107 AC_CHECK_MEMBERS([struct sockaddr.sa_len], , , [#include <sys/socket.h>])
108
109 AC_CHECK_HEADERS_ONCE([netinet/in.h])
110
103 AC_CHECK_DECLS([getaddrinfo, freeaddrinfo, gai_strerror, getnameinfo],,,[ 111 AC_CHECK_DECLS([getaddrinfo, freeaddrinfo, gai_strerror, getnameinfo],,,[
104 /* sys/types.h is not needed according to POSIX, but the 112 /* sys/types.h is not needed according to POSIX, but the
105 sys/socket.h in i386-unknown-freebsd4.10 and 113 sys/socket.h in i386-unknown-freebsd4.10 and
@@ -115,6 +123,19 @@ AC_DEFUN([gl_PREREQ_GETADDRINFO], [
115#include <ws2tcpip.h> 123#include <ws2tcpip.h>
116#endif 124#endif
117]) 125])
126 if test $ac_cv_have_decl_getaddrinfo = no; then
127 HAVE_DECL_GETADDRINFO=0
128 fi
129 if test $ac_cv_have_decl_freeaddrinfo = no; then
130 HAVE_DECL_FREEADDRINFO=0
131 fi
132 if test $ac_cv_have_decl_gai_strerror = no; then
133 HAVE_DECL_GAI_STRERROR=0
134 fi
135 if test $ac_cv_have_decl_getnameinfo = no; then
136 HAVE_DECL_GETNAMEINFO=0
137 fi
138
118 AC_CHECK_TYPES([struct addrinfo],,,[ 139 AC_CHECK_TYPES([struct addrinfo],,,[
119#include <sys/types.h> 140#include <sys/types.h>
120#ifdef HAVE_SYS_SOCKET_H 141#ifdef HAVE_SYS_SOCKET_H
@@ -127,4 +148,19 @@ AC_DEFUN([gl_PREREQ_GETADDRINFO], [
127#include <ws2tcpip.h> 148#include <ws2tcpip.h>
128#endif 149#endif
129]) 150])
151 if test $ac_cv_type_struct_addrinfo = no; then
152 HAVE_STRUCT_ADDRINFO=0
153 fi
154
155 dnl Append $HOSTENT_LIB to GETADDRINFO_LIB, avoiding gratuitous duplicates.
156 case " $GETADDRINFO_LIB " in
157 *" $HOSTENT_LIB "*) ;;
158 *) GETADDRINFO_LIB="$GETADDRINFO_LIB $HOSTENT_LIB" ;;
159 esac
160
161 dnl Append $SERVENT_LIB to GETADDRINFO_LIB, avoiding gratuitous duplicates.
162 case " $GETADDRINFO_LIB " in
163 *" $SERVENT_LIB "*) ;;
164 *) GETADDRINFO_LIB="$GETADDRINFO_LIB $SERVENT_LIB" ;;
165 esac
130]) 166])
diff --git a/gl/m4/gethostname.m4 b/gl/m4/gethostname.m4
index 1e9749d..6b6fca9 100644
--- a/gl/m4/gethostname.m4
+++ b/gl/m4/gethostname.m4
@@ -1,18 +1,21 @@
1# gethostname.m4 serial 2 1# gethostname.m4 serial 5
2dnl Copyright (C) 2002 Free Software Foundation, Inc. 2dnl Copyright (C) 2002, 2008, 2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN([gl_FUNC_GETHOSTNAME], 7AC_DEFUN([gl_FUNC_GETHOSTNAME],
8[ 8[
9 AC_REPLACE_FUNCS(gethostname) 9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10 gl_PREREQ_SYS_H_WINSOCK2
11 AC_REPLACE_FUNCS([gethostname])
10 if test $ac_cv_func_gethostname = no; then 12 if test $ac_cv_func_gethostname = no; then
13 HAVE_GETHOSTNAME=0
11 gl_PREREQ_GETHOSTNAME 14 gl_PREREQ_GETHOSTNAME
12 fi 15 fi
13]) 16])
14 17
15# Prerequisites of lib/gethostname.c. 18# Prerequisites of lib/gethostname.c.
16AC_DEFUN([gl_PREREQ_GETHOSTNAME], [ 19AC_DEFUN([gl_PREREQ_GETHOSTNAME], [
17 AC_CHECK_FUNCS(uname) 20 AC_CHECK_FUNCS([uname])
18]) 21])
diff --git a/gl/m4/getloadavg.m4 b/gl/m4/getloadavg.m4
index c1547c7..015bcac 100644
--- a/gl/m4/getloadavg.m4
+++ b/gl/m4/getloadavg.m4
@@ -1,7 +1,7 @@
1# Check for getloadavg. 1# Check for getloadavg.
2 2
3# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1999, 2000, 2002, 2003, 3# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1999, 2000, 2002, 2003,
4# 2006 Free Software Foundation, Inc. 4# 2006, 2008, 2009 Free Software Foundation, Inc.
5 5
6# This file is free software; the Free Software Foundation 6# This file is free software; the Free Software Foundation
7# gives unlimited permission to copy and/or distribute it, 7# gives unlimited permission to copy and/or distribute it,
@@ -13,7 +13,12 @@
13# gl_GETLOADAVG(LIBOBJDIR) 13# gl_GETLOADAVG(LIBOBJDIR)
14# ------------------------ 14# ------------------------
15AC_DEFUN([gl_GETLOADAVG], 15AC_DEFUN([gl_GETLOADAVG],
16[gl_have_func=no # yes means we've found a way to get the load average. 16[AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
17
18# Persuade glibc <stdlib.h> to declare getloadavg().
19AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
20
21gl_have_func=no # yes means we've found a way to get the load average.
17 22
18# Make sure getloadavg.c is where it belongs, at configure-time. 23# Make sure getloadavg.c is where it belongs, at configure-time.
19test -f "$srcdir/$1/getloadavg.c" || 24test -f "$srcdir/$1/getloadavg.c" ||
@@ -22,17 +27,17 @@ test -f "$srcdir/$1/getloadavg.c" ||
22gl_save_LIBS=$LIBS 27gl_save_LIBS=$LIBS
23 28
24# Check for getloadavg, but be sure not to touch the cache variable. 29# Check for getloadavg, but be sure not to touch the cache variable.
25(AC_CHECK_FUNC(getloadavg, exit 0, exit 1)) && gl_have_func=yes 30(AC_CHECK_FUNC([getloadavg], [exit 0], [exit 1])) && gl_have_func=yes
26 31
27# On HPUX9, an unprivileged user can get load averages through this function. 32# On HPUX9, an unprivileged user can get load averages through this function.
28AC_CHECK_FUNCS(pstat_getdynamic) 33AC_CHECK_FUNCS([pstat_getdynamic])
29 34
30# Solaris has libkstat which does not require root. 35# Solaris has libkstat which does not require root.
31AC_CHECK_LIB(kstat, kstat_open) 36AC_CHECK_LIB([kstat], [kstat_open])
32test $ac_cv_lib_kstat_kstat_open = yes && gl_have_func=yes 37test $ac_cv_lib_kstat_kstat_open = yes && gl_have_func=yes
33 38
34# AIX has libperfstat which does not require root 39# AIX has libperfstat which does not require root
35AC_CHECK_LIB(perfstat, perfstat_cpu_total) 40AC_CHECK_LIB([perfstat], [perfstat_cpu_total])
36test $ac_cv_lib_perfstat_perfstat_cpu_total = yes && gl_have_func=yes 41test $ac_cv_lib_perfstat_perfstat_cpu_total = yes && gl_have_func=yes
37 42
38# Some systems with -lutil have (and need) -lkvm as well, some do not. 43# Some systems with -lutil have (and need) -lkvm as well, some do not.
@@ -40,12 +45,12 @@ test $ac_cv_lib_perfstat_perfstat_cpu_total = yes && gl_have_func=yes
40# to get the right answer into the cache. 45# to get the right answer into the cache.
41# For kstat on solaris, we need libelf to force the definition of SVR4 below. 46# For kstat on solaris, we need libelf to force the definition of SVR4 below.
42if test $gl_have_func = no; then 47if test $gl_have_func = no; then
43 AC_CHECK_LIB(elf, elf_begin, LIBS="-lelf $LIBS") 48 AC_CHECK_LIB([elf], [elf_begin], [LIBS="-lelf $LIBS"])
44fi 49fi
45if test $gl_have_func = no; then 50if test $gl_have_func = no; then
46 AC_CHECK_LIB(kvm, kvm_open, LIBS="-lkvm $LIBS") 51 AC_CHECK_LIB([kvm], [kvm_open], [LIBS="-lkvm $LIBS"])
47 # Check for the 4.4BSD definition of getloadavg. 52 # Check for the 4.4BSD definition of getloadavg.
48 AC_CHECK_LIB(util, getloadavg, 53 AC_CHECK_LIB([util], [getloadavg],
49 [LIBS="-lutil $LIBS" gl_have_func=yes gl_cv_func_getloadavg_setgid=yes]) 54 [LIBS="-lutil $LIBS" gl_have_func=yes gl_cv_func_getloadavg_setgid=yes])
50fi 55fi
51 56
@@ -54,17 +59,17 @@ if test $gl_have_func = no; then
54 # Since it is not a standard part of AIX, it might be installed locally. 59 # Since it is not a standard part of AIX, it might be installed locally.
55 gl_getloadavg_LIBS=$LIBS 60 gl_getloadavg_LIBS=$LIBS
56 LIBS="-L/usr/local/lib $LIBS" 61 LIBS="-L/usr/local/lib $LIBS"
57 AC_CHECK_LIB(getloadavg, getloadavg, 62 AC_CHECK_LIB([getloadavg], [getloadavg],
58 [LIBS="-lgetloadavg $LIBS"], [LIBS=$gl_getloadavg_LIBS]) 63 [LIBS="-lgetloadavg $LIBS"], [LIBS=$gl_getloadavg_LIBS])
59fi 64fi
60 65
61# Make sure it is really in the library, if we think we found it, 66# Make sure it is really in the library, if we think we found it,
62# otherwise set up the replacement function. 67# otherwise set up the replacement function.
63AC_CHECK_FUNCS(getloadavg, [], 68AC_CHECK_FUNCS([getloadavg], [],
64 [gl_PREREQ_GETLOADAVG]) 69 [gl_PREREQ_GETLOADAVG])
65 70
66# Some definitions of getloadavg require that the program be installed setgid. 71# Some definitions of getloadavg require that the program be installed setgid.
67AC_CACHE_CHECK(whether getloadavg requires setgid, 72AC_CACHE_CHECK([whether getloadavg requires setgid],
68 gl_cv_func_getloadavg_setgid, 73 gl_cv_func_getloadavg_setgid,
69[AC_EGREP_CPP([Yowza Am I SETGID yet], 74[AC_EGREP_CPP([Yowza Am I SETGID yet],
70[#define CONFIGURING_GETLOADAVG 75[#define CONFIGURING_GETLOADAVG
@@ -77,16 +82,16 @@ Yowza Am I SETGID yet
77 gl_cv_func_getloadavg_setgid=no)]) 82 gl_cv_func_getloadavg_setgid=no)])
78if test $gl_cv_func_getloadavg_setgid = yes; then 83if test $gl_cv_func_getloadavg_setgid = yes; then
79 NEED_SETGID=true 84 NEED_SETGID=true
80 AC_DEFINE(GETLOADAVG_PRIVILEGED, 1, 85 AC_DEFINE([GETLOADAVG_PRIVILEGED], [1],
81 [Define to 1 if the `getloadavg' function needs to be run setuid 86 [Define to 1 if the `getloadavg' function needs to be run setuid
82 or setgid.]) 87 or setgid.])
83else 88else
84 NEED_SETGID=false 89 NEED_SETGID=false
85fi 90fi
86AC_SUBST(NEED_SETGID)dnl 91AC_SUBST([NEED_SETGID])dnl
87 92
88if test $gl_cv_func_getloadavg_setgid = yes; then 93if test $gl_cv_func_getloadavg_setgid = yes; then
89 AC_CACHE_CHECK(group of /dev/kmem, gl_cv_group_kmem, 94 AC_CACHE_CHECK([group of /dev/kmem], [gl_cv_group_kmem],
90[ # On Solaris, /dev/kmem is a symlink. Get info on the real file. 95[ # On Solaris, /dev/kmem is a symlink. Get info on the real file.
91 ac_ls_output=`ls -lgL /dev/kmem 2>/dev/null` 96 ac_ls_output=`ls -lgL /dev/kmem 2>/dev/null`
92 # If we got an error (system does not support symlinks), try without -L. 97 # If we got an error (system does not support symlinks), try without -L.
@@ -96,7 +101,7 @@ if test $gl_cv_func_getloadavg_setgid = yes; then
96 s/^.[sSrwx-]* *[0-9]* *\([^0-9]*\) *.*/\1/ 101 s/^.[sSrwx-]* *[0-9]* *\([^0-9]*\) *.*/\1/
97 / /s/.* //;p']` 102 / /s/.* //;p']`
98]) 103])
99 AC_SUBST(KMEM_GROUP, $gl_cv_group_kmem)dnl 104 AC_SUBST([KMEM_GROUP], [$gl_cv_group_kmem])dnl
100fi 105fi
101if test "x$gl_save_LIBS" = x; then 106if test "x$gl_save_LIBS" = x; then
102 GETLOADAVG_LIBS=$LIBS 107 GETLOADAVG_LIBS=$LIBS
@@ -105,7 +110,21 @@ else
105fi 110fi
106LIBS=$gl_save_LIBS 111LIBS=$gl_save_LIBS
107 112
108AC_SUBST(GETLOADAVG_LIBS)dnl 113AC_SUBST([GETLOADAVG_LIBS])dnl
114
115# Test whether the system declares getloadavg. Solaris has the function
116# but declares it in <sys/loadavg.h>, not <stdlib.h>.
117AC_CHECK_HEADERS([sys/loadavg.h])
118if test $ac_cv_header_sys_loadavg_h = yes; then
119 HAVE_SYS_LOADAVG_H=1
120else
121 HAVE_SYS_LOADAVG_H=0
122fi
123AC_CHECK_DECL([getloadavg], [], [HAVE_DECL_GETLOADAVG=0],
124 [#if HAVE_SYS_LOADAVG_H
125 # include <sys/loadavg.h>
126 #endif
127 #include <stdlib.h>])
109])# gl_GETLOADAVG 128])# gl_GETLOADAVG
110 129
111 130
@@ -113,44 +132,44 @@ AC_SUBST(GETLOADAVG_LIBS)dnl
113# -------------------- 132# --------------------
114# Set up the AC_LIBOBJ replacement of `getloadavg'. 133# Set up the AC_LIBOBJ replacement of `getloadavg'.
115AC_DEFUN([gl_PREREQ_GETLOADAVG], 134AC_DEFUN([gl_PREREQ_GETLOADAVG],
116[AC_LIBOBJ(getloadavg) 135[AC_LIBOBJ([getloadavg])
117AC_DEFINE(C_GETLOADAVG, 1, [Define to 1 if using `getloadavg.c'.]) 136AC_DEFINE([C_GETLOADAVG], [1], [Define to 1 if using `getloadavg.c'.])
118# Figure out what our getloadavg.c needs. 137# Figure out what our getloadavg.c needs.
119gl_have_func=no 138gl_have_func=no
120AC_CHECK_HEADER(sys/dg_sys_info.h, 139AC_CHECK_HEADER([sys/dg_sys_info.h],
121[gl_have_func=yes 140[gl_have_func=yes
122 AC_DEFINE(DGUX, 1, [Define to 1 for DGUX with <sys/dg_sys_info.h>.]) 141 AC_DEFINE([DGUX], [1], [Define to 1 for DGUX with <sys/dg_sys_info.h>.])
123 AC_CHECK_LIB(dgc, dg_sys_info)]) 142 AC_CHECK_LIB([dgc], [dg_sys_info])])
124 143
125# We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it 144# We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it
126# uses stabs), but it is still SVR4. We cannot check for <elf.h> because 145# uses stabs), but it is still SVR4. We cannot check for <elf.h> because
127# Irix 4.0.5F has the header but not the library. 146# Irix 4.0.5F has the header but not the library.
128if test $gl_have_func = no && test "$ac_cv_lib_elf_elf_begin" = yes; then 147if test $gl_have_func = no && test "$ac_cv_lib_elf_elf_begin" = yes; then
129 gl_have_func=yes 148 gl_have_func=yes
130 AC_DEFINE(SVR4, 1, [Define to 1 on System V Release 4.]) 149 AC_DEFINE([SVR4], [1], [Define to 1 on System V Release 4.])
131fi 150fi
132 151
133if test $gl_have_func = no; then 152if test $gl_have_func = no; then
134 AC_CHECK_HEADER(inq_stats/cpustats.h, 153 AC_CHECK_HEADER([inq_stats/cpustats.h],
135 [gl_have_func=yes 154 [gl_have_func=yes
136 AC_DEFINE(UMAX, 1, [Define to 1 for Encore UMAX.]) 155 AC_DEFINE([UMAX], [1], [Define to 1 for Encore UMAX.])
137 AC_DEFINE(UMAX4_3, 1, 156 AC_DEFINE([UMAX4_3], [1],
138 [Define to 1 for Encore UMAX 4.3 that has <inq_status/cpustats.h> 157 [Define to 1 for Encore UMAX 4.3 that has <inq_status/cpustats.h>
139 instead of <sys/cpustats.h>.])]) 158 instead of <sys/cpustats.h>.])])
140fi 159fi
141 160
142if test $gl_have_func = no; then 161if test $gl_have_func = no; then
143 AC_CHECK_HEADER(sys/cpustats.h, 162 AC_CHECK_HEADER([sys/cpustats.h],
144 [gl_have_func=yes; AC_DEFINE(UMAX)]) 163 [gl_have_func=yes; AC_DEFINE([UMAX])])
145fi 164fi
146 165
147if test $gl_have_func = no; then 166if test $gl_have_func = no; then
148 AC_CHECK_HEADERS(mach/mach.h) 167 AC_CHECK_HEADERS([mach/mach.h])
149fi 168fi
150 169
151AC_CHECK_HEADERS(nlist.h, 170AC_CHECK_HEADERS([nlist.h],
152[AC_CHECK_MEMBERS([struct nlist.n_un.n_name], 171[AC_CHECK_MEMBERS([struct nlist.n_un.n_name],
153 [AC_DEFINE(NLIST_NAME_UNION, 1, 172 [AC_DEFINE([NLIST_NAME_UNION], [1],
154 [Define to 1 if your `struct nlist' has an 173 [Define to 1 if your `struct nlist' has an
155 `n_un' member. Obsolete, depend on 174 `n_un' member. Obsolete, depend on
156 `HAVE_STRUCT_NLIST_N_UN_N_NAME])], [], 175 `HAVE_STRUCT_NLIST_N_UN_N_NAME])], [],
diff --git a/gl/m4/getopt.m4 b/gl/m4/getopt.m4
index c0a73b2..9b683c2 100644
--- a/gl/m4/getopt.m4
+++ b/gl/m4/getopt.m4
@@ -1,5 +1,5 @@
1# getopt.m4 serial 13 1# getopt.m4 serial 14
2dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2006, 2008 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -46,7 +46,7 @@ AC_DEFUN([gl_GETOPT_CHECK_HEADERS],
46 if test -z "$GETOPT_H"; then 46 if test -z "$GETOPT_H"; then
47 AC_CACHE_CHECK([for working GNU getopt function], [gl_cv_func_gnu_getopt], 47 AC_CACHE_CHECK([for working GNU getopt function], [gl_cv_func_gnu_getopt],
48 [AC_RUN_IFELSE( 48 [AC_RUN_IFELSE(
49 [AC_LANG_PROGRAM([#include <getopt.h>], 49 [AC_LANG_PROGRAM([[#include <getopt.h>]],
50 [[ 50 [[
51 char *myargv[3]; 51 char *myargv[3];
52 myargv[0] = "conftest"; 52 myargv[0] = "conftest";
diff --git a/gl/m4/gettext.m4 b/gl/m4/gettext.m4
index c9ae1f7..d90c850 100644
--- a/gl/m4/gettext.m4
+++ b/gl/m4/gettext.m4
@@ -1,5 +1,5 @@
1# gettext.m4 serial 60 (gettext-0.17) 1# gettext.m4 serial 62 (gettext-0.18)
2dnl Copyright (C) 1995-2007 Free Software Foundation, Inc. 2dnl Copyright (C) 1995-2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -123,11 +123,11 @@ AC_DEFUN([AM_GNU_GETTEXT],
123 gt_use_preinstalled_gnugettext=no 123 gt_use_preinstalled_gnugettext=no
124 ifelse(gt_included_intl, yes, [ 124 ifelse(gt_included_intl, yes, [
125 AC_MSG_CHECKING([whether included gettext is requested]) 125 AC_MSG_CHECKING([whether included gettext is requested])
126 AC_ARG_WITH(included-gettext, 126 AC_ARG_WITH([included-gettext],
127 [ --with-included-gettext use the GNU gettext library included here], 127 [ --with-included-gettext use the GNU gettext library included here],
128 nls_cv_force_use_gnu_gettext=$withval, 128 nls_cv_force_use_gnu_gettext=$withval,
129 nls_cv_force_use_gnu_gettext=no) 129 nls_cv_force_use_gnu_gettext=no)
130 AC_MSG_RESULT($nls_cv_force_use_gnu_gettext) 130 AC_MSG_RESULT([$nls_cv_force_use_gnu_gettext])
131 131
132 nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext" 132 nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
133 if test "$nls_cv_force_use_gnu_gettext" != "yes"; then 133 if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
@@ -267,7 +267,7 @@ return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_a
267 267
268 if test "$gt_use_preinstalled_gnugettext" = "yes" \ 268 if test "$gt_use_preinstalled_gnugettext" = "yes" \
269 || test "$nls_cv_use_gnu_gettext" = "yes"; then 269 || test "$nls_cv_use_gnu_gettext" = "yes"; then
270 AC_DEFINE(ENABLE_NLS, 1, 270 AC_DEFINE([ENABLE_NLS], [1],
271 [Define to 1 if translation of program messages to the user's native language 271 [Define to 1 if translation of program messages to the user's native language
272 is requested.]) 272 is requested.])
273 else 273 else
@@ -301,9 +301,9 @@ return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_a
301 fi 301 fi
302 302
303 dnl For backward compatibility. Some packages may be using this. 303 dnl For backward compatibility. Some packages may be using this.
304 AC_DEFINE(HAVE_GETTEXT, 1, 304 AC_DEFINE([HAVE_GETTEXT], [1],
305 [Define if the GNU gettext() function is already present or preinstalled.]) 305 [Define if the GNU gettext() function is already present or preinstalled.])
306 AC_DEFINE(HAVE_DCGETTEXT, 1, 306 AC_DEFINE([HAVE_DCGETTEXT], [1],
307 [Define if the GNU dcgettext() function is already present or preinstalled.]) 307 [Define if the GNU dcgettext() function is already present or preinstalled.])
308 fi 308 fi
309 309
@@ -319,9 +319,9 @@ return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_a
319 fi 319 fi
320 320
321 dnl Make all variables we use known to autoconf. 321 dnl Make all variables we use known to autoconf.
322 AC_SUBST(BUILD_INCLUDED_LIBINTL) 322 AC_SUBST([BUILD_INCLUDED_LIBINTL])
323 AC_SUBST(USE_INCLUDED_LIBINTL) 323 AC_SUBST([USE_INCLUDED_LIBINTL])
324 AC_SUBST(CATOBJEXT) 324 AC_SUBST([CATOBJEXT])
325 325
326 dnl For backward compatibility. Some configure.ins may be using this. 326 dnl For backward compatibility. Some configure.ins may be using this.
327 nls_cv_header_intl= 327 nls_cv_header_intl=
@@ -329,36 +329,36 @@ return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_a
329 329
330 dnl For backward compatibility. Some Makefiles may be using this. 330 dnl For backward compatibility. Some Makefiles may be using this.
331 DATADIRNAME=share 331 DATADIRNAME=share
332 AC_SUBST(DATADIRNAME) 332 AC_SUBST([DATADIRNAME])
333 333
334 dnl For backward compatibility. Some Makefiles may be using this. 334 dnl For backward compatibility. Some Makefiles may be using this.
335 INSTOBJEXT=.mo 335 INSTOBJEXT=.mo
336 AC_SUBST(INSTOBJEXT) 336 AC_SUBST([INSTOBJEXT])
337 337
338 dnl For backward compatibility. Some Makefiles may be using this. 338 dnl For backward compatibility. Some Makefiles may be using this.
339 GENCAT=gencat 339 GENCAT=gencat
340 AC_SUBST(GENCAT) 340 AC_SUBST([GENCAT])
341 341
342 dnl For backward compatibility. Some Makefiles may be using this. 342 dnl For backward compatibility. Some Makefiles may be using this.
343 INTLOBJS= 343 INTLOBJS=
344 if test "$USE_INCLUDED_LIBINTL" = yes; then 344 if test "$USE_INCLUDED_LIBINTL" = yes; then
345 INTLOBJS="\$(GETTOBJS)" 345 INTLOBJS="\$(GETTOBJS)"
346 fi 346 fi
347 AC_SUBST(INTLOBJS) 347 AC_SUBST([INTLOBJS])
348 348
349 dnl Enable libtool support if the surrounding package wishes it. 349 dnl Enable libtool support if the surrounding package wishes it.
350 INTL_LIBTOOL_SUFFIX_PREFIX=gt_libtool_suffix_prefix 350 INTL_LIBTOOL_SUFFIX_PREFIX=gt_libtool_suffix_prefix
351 AC_SUBST(INTL_LIBTOOL_SUFFIX_PREFIX) 351 AC_SUBST([INTL_LIBTOOL_SUFFIX_PREFIX])
352 ]) 352 ])
353 353
354 dnl For backward compatibility. Some Makefiles may be using this. 354 dnl For backward compatibility. Some Makefiles may be using this.
355 INTLLIBS="$LIBINTL" 355 INTLLIBS="$LIBINTL"
356 AC_SUBST(INTLLIBS) 356 AC_SUBST([INTLLIBS])
357 357
358 dnl Make all documented variables known to autoconf. 358 dnl Make all documented variables known to autoconf.
359 AC_SUBST(LIBINTL) 359 AC_SUBST([LIBINTL])
360 AC_SUBST(LTLIBINTL) 360 AC_SUBST([LTLIBINTL])
361 AC_SUBST(POSUB) 361 AC_SUBST([POSUB])
362]) 362])
363 363
364 364
diff --git a/gl/m4/glibc2.m4 b/gl/m4/glibc2.m4
index e8f5bfe..fe58a0f 100644
--- a/gl/m4/glibc2.m4
+++ b/gl/m4/glibc2.m4
@@ -1,5 +1,5 @@
1# glibc2.m4 serial 1 1# glibc2.m4 serial 2
2dnl Copyright (C) 2000-2002, 2004 Free Software Foundation, Inc. 2dnl Copyright (C) 2000-2002, 2004, 2008 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -9,8 +9,8 @@ dnl with or without modifications, as long as this notice is preserved.
9 9
10AC_DEFUN([gt_GLIBC2], 10AC_DEFUN([gt_GLIBC2],
11 [ 11 [
12 AC_CACHE_CHECK(whether we are using the GNU C Library 2 or newer, 12 AC_CACHE_CHECK([whether we are using the GNU C Library 2 or newer],
13 ac_cv_gnu_library_2, 13 [ac_cv_gnu_library_2],
14 [AC_EGREP_CPP([Lucky GNU user], 14 [AC_EGREP_CPP([Lucky GNU user],
15 [ 15 [
16#include <features.h> 16#include <features.h>
@@ -20,11 +20,11 @@ AC_DEFUN([gt_GLIBC2],
20 #endif 20 #endif
21#endif 21#endif
22 ], 22 ],
23 ac_cv_gnu_library_2=yes, 23 [ac_cv_gnu_library_2=yes],
24 ac_cv_gnu_library_2=no) 24 [ac_cv_gnu_library_2=no])
25 ] 25 ]
26 ) 26 )
27 AC_SUBST(GLIBC2) 27 AC_SUBST([GLIBC2])
28 GLIBC2="$ac_cv_gnu_library_2" 28 GLIBC2="$ac_cv_gnu_library_2"
29 ] 29 ]
30) 30)
diff --git a/gl/m4/glibc21.m4 b/gl/m4/glibc21.m4
index d95fd98..93fbf47 100644
--- a/gl/m4/glibc21.m4
+++ b/gl/m4/glibc21.m4
@@ -1,5 +1,5 @@
1# glibc21.m4 serial 3 1# glibc21.m4 serial 4
2dnl Copyright (C) 2000-2002, 2004 Free Software Foundation, Inc. 2dnl Copyright (C) 2000-2002, 2004, 2008 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -9,8 +9,8 @@ dnl with or without modifications, as long as this notice is preserved.
9 9
10AC_DEFUN([gl_GLIBC21], 10AC_DEFUN([gl_GLIBC21],
11 [ 11 [
12 AC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer, 12 AC_CACHE_CHECK([whether we are using the GNU C Library 2.1 or newer],
13 ac_cv_gnu_library_2_1, 13 [ac_cv_gnu_library_2_1],
14 [AC_EGREP_CPP([Lucky GNU user], 14 [AC_EGREP_CPP([Lucky GNU user],
15 [ 15 [
16#include <features.h> 16#include <features.h>
@@ -20,11 +20,11 @@ AC_DEFUN([gl_GLIBC21],
20 #endif 20 #endif
21#endif 21#endif
22 ], 22 ],
23 ac_cv_gnu_library_2_1=yes, 23 [ac_cv_gnu_library_2_1=yes],
24 ac_cv_gnu_library_2_1=no) 24 [ac_cv_gnu_library_2_1=no])
25 ] 25 ]
26 ) 26 )
27 AC_SUBST(GLIBC21) 27 AC_SUBST([GLIBC21])
28 GLIBC21="$ac_cv_gnu_library_2_1" 28 GLIBC21="$ac_cv_gnu_library_2_1"
29 ] 29 ]
30) 30)
diff --git a/gl/m4/gnulib-cache.m4 b/gl/m4/gnulib-cache.m4
index 302dc19..eb47134 100644
--- a/gl/m4/gnulib-cache.m4
+++ b/gl/m4/gnulib-cache.m4
@@ -1,4 +1,4 @@
1# Copyright (C) 2004-2007 Free Software Foundation, Inc. 1# Copyright (C) 2002-2009 Free Software Foundation, Inc.
2# 2#
3# This file is free software, distributed under the terms of the GNU 3# This file is free software, distributed under the terms of the GNU
4# General Public License. As a special exception to the GNU General 4# General Public License. As a special exception to the GNU General
@@ -15,11 +15,25 @@
15 15
16 16
17# Specification in the form of a command-line invocation: 17# Specification in the form of a command-line invocation:
18# gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --aux-dir=build-aux --no-libtool --macro-prefix=gl base64 dirname floorf fsusage getaddrinfo gethostname getloadavg getopt gettext mountlist regex vasprintf vsnprintf 18# gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-libtool --macro-prefix=gl base64 dirname floorf fsusage getaddrinfo gethostname getloadavg getopt gettext mountlist regex vasprintf vsnprintf
19 19
20# Specification in the form of a few gnulib-tool.m4 macro invocations: 20# Specification in the form of a few gnulib-tool.m4 macro invocations:
21gl_LOCAL_DIR([]) 21gl_LOCAL_DIR([])
22gl_MODULES([base64 dirname floorf fsusage getaddrinfo gethostname getloadavg getopt gettext mountlist regex vasprintf vsnprintf]) 22gl_MODULES([
23 base64
24 dirname
25 floorf
26 fsusage
27 getaddrinfo
28 gethostname
29 getloadavg
30 getopt
31 gettext
32 mountlist
33 regex
34 vasprintf
35 vsnprintf
36])
23gl_AVOID([]) 37gl_AVOID([])
24gl_SOURCE_BASE([gl]) 38gl_SOURCE_BASE([gl])
25gl_M4_BASE([gl/m4]) 39gl_M4_BASE([gl/m4])
diff --git a/gl/m4/gnulib-common.m4 b/gl/m4/gnulib-common.m4
index 9336d72..5804eb9 100644
--- a/gl/m4/gnulib-common.m4
+++ b/gl/m4/gnulib-common.m4
@@ -1,9 +1,38 @@
1# gnulib-common.m4 serial 3 1# gnulib-common.m4 serial 7
2dnl Copyright (C) 2007 Free Software Foundation, Inc. 2dnl Copyright (C) 2007-2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7# gl_COMMON
8# is expanded unconditionally through gnulib-tool magic.
9AC_DEFUN([gl_COMMON], [
10 dnl Use AC_REQUIRE here, so that the code is expanded once only.
11 AC_REQUIRE([gl_COMMON_BODY])
12])
13AC_DEFUN([gl_COMMON_BODY], [
14 AH_VERBATIM([isoc99_inline],
15[/* Work around a bug in Apple GCC 4.0.1 build 5465: In C99 mode, it supports
16 the ISO C 99 semantics of 'extern inline' (unlike the GNU C semantics of
17 earlier versions), but does not display it by setting __GNUC_STDC_INLINE__.
18 __APPLE__ && __MACH__ test for MacOS X.
19 __APPLE_CC__ tests for the Apple compiler and its version.
20 __STDC_VERSION__ tests for the C99 mode. */
21#if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined __cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__
22# define __GNUC_STDC_INLINE__ 1
23#endif])
24 AH_VERBATIM([unused_parameter],
25[/* Define as a marker that can be attached to function parameter declarations
26 for parameters that are not used. This helps to reduce warnings, such as
27 from GCC -Wunused-parameter. */
28#if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
29# define _UNUSED_PARAMETER_ __attribute__ ((__unused__))
30#else
31# define _UNUSED_PARAMETER_
32#endif
33])
34])
35
7# gl_MODULE_INDICATOR([modulename]) 36# gl_MODULE_INDICATOR([modulename])
8# defines a C macro indicating the presence of the given module. 37# defines a C macro indicating the presence of the given module.
9AC_DEFUN([gl_MODULE_INDICATOR], 38AC_DEFUN([gl_MODULE_INDICATOR],
@@ -12,6 +41,13 @@ AC_DEFUN([gl_MODULE_INDICATOR],
12 [Define to 1 when using the gnulib module ]$1[.]) 41 [Define to 1 when using the gnulib module ]$1[.])
13]) 42])
14 43
44# m4_foreach_w
45# is a backport of autoconf-2.59c's m4_foreach_w.
46# Remove this macro when we can assume autoconf >= 2.60.
47m4_ifndef([m4_foreach_w],
48 [m4_define([m4_foreach_w],
49 [m4_foreach([$1], m4_split(m4_normalize([$2]), [ ]), [$3])])])
50
15# AC_PROG_MKDIR_P 51# AC_PROG_MKDIR_P
16# is a backport of autoconf-2.60's AC_PROG_MKDIR_P. 52# is a backport of autoconf-2.60's AC_PROG_MKDIR_P.
17# Remove this macro when we can assume autoconf >= 2.60. 53# Remove this macro when we can assume autoconf >= 2.60.
@@ -27,7 +63,7 @@ m4_ifdef([AC_PROG_MKDIR_P], [], [
27# works. 63# works.
28# This definition can be removed once autoconf >= 2.62 can be assumed. 64# This definition can be removed once autoconf >= 2.62 can be assumed.
29AC_DEFUN([AC_C_RESTRICT], 65AC_DEFUN([AC_C_RESTRICT],
30[AC_CACHE_CHECK([for C/C++ restrict keyword], ac_cv_c_restrict, 66[AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict],
31 [ac_cv_c_restrict=no 67 [ac_cv_c_restrict=no
32 # The order here caters to the fact that C++ does not require restrict. 68 # The order here caters to the fact that C++ does not require restrict.
33 for ac_kw in __restrict __restrict__ _Restrict restrict; do 69 for ac_kw in __restrict __restrict__ _Restrict restrict; do
diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4
index 85ad2e9..99fa45d 100644
--- a/gl/m4/gnulib-comp.m4
+++ b/gl/m4/gnulib-comp.m4
@@ -1,5 +1,5 @@
1# DO NOT EDIT! GENERATED AUTOMATICALLY! 1# DO NOT EDIT! GENERATED AUTOMATICALLY!
2# Copyright (C) 2004-2007 Free Software Foundation, Inc. 2# Copyright (C) 2002-2009 Free Software Foundation, Inc.
3# 3#
4# This file is free software, distributed under the terms of the GNU 4# This file is free software, distributed under the terms of the GNU
5# General Public License. As a special exception to the GNU General 5# General Public License. As a special exception to the GNU General
@@ -40,20 +40,27 @@ AC_DEFUN([gl_INIT],
40 m4_pushdef([AC_LIBOBJ], m4_defn([gl_LIBOBJ])) 40 m4_pushdef([AC_LIBOBJ], m4_defn([gl_LIBOBJ]))
41 m4_pushdef([AC_REPLACE_FUNCS], m4_defn([gl_REPLACE_FUNCS])) 41 m4_pushdef([AC_REPLACE_FUNCS], m4_defn([gl_REPLACE_FUNCS]))
42 m4_pushdef([AC_LIBSOURCES], m4_defn([gl_LIBSOURCES])) 42 m4_pushdef([AC_LIBSOURCES], m4_defn([gl_LIBSOURCES]))
43 m4_pushdef([gl_LIBSOURCES_LIST], [])
44 m4_pushdef([gl_LIBSOURCES_DIR], [])
45 gl_COMMON
43 gl_source_base='gl' 46 gl_source_base='gl'
44 gl_FUNC_ALLOCA 47 gl_FUNC_ALLOCA
45 gl_HEADER_ARPA_INET 48 gl_HEADER_ARPA_INET
46 AC_PROG_MKDIR_P 49 AC_PROG_MKDIR_P
47 gl_FUNC_BASE64 50 gl_FUNC_BASE64
51 gl_FUNC_BTOWC
52 gl_WCHAR_MODULE_INDICATOR([btowc])
48 gl_C_STRTOD 53 gl_C_STRTOD
49 gl_CLOEXEC 54 gl_CLOEXEC
50 gl_DIRNAME 55 gl_DIRNAME
51 gl_DOUBLE_SLASH_ROOT 56 gl_DOUBLE_SLASH_ROOT
57 gl_HEADER_ERRNO_H
52 gl_ERROR 58 gl_ERROR
53 m4_ifdef([AM_XGETTEXT_OPTION], 59 m4_ifdef([AM_XGETTEXT_OPTION],
54 [AM_XGETTEXT_OPTION([--flag=error:3:c-format]) 60 [AM_XGETTEXT_OPTION([--flag=error:3:c-format])
55 AM_XGETTEXT_OPTION([--flag=error_at_line:5:c-format])]) 61 AM_XGETTEXT_OPTION([--flag=error_at_line:5:c-format])])
56 gl_EXITFAIL 62 gl_EXITFAIL
63 gl_FCNTL_H
57 gl_FCNTL_SAFER 64 gl_FCNTL_SAFER
58 gl_MODULE_INDICATOR([fcntl-safer]) 65 gl_MODULE_INDICATOR([fcntl-safer])
59 gl_FLOAT_H 66 gl_FLOAT_H
@@ -61,14 +68,19 @@ AC_DEFUN([gl_INIT],
61 gl_MATH_MODULE_INDICATOR([floorf]) 68 gl_MATH_MODULE_INDICATOR([floorf])
62 gl_FSUSAGE 69 gl_FSUSAGE
63 gl_GETADDRINFO 70 gl_GETADDRINFO
71 gl_NETDB_MODULE_INDICATOR([getaddrinfo])
64 gl_FUNC_GETHOSTNAME 72 gl_FUNC_GETHOSTNAME
73 gl_UNISTD_MODULE_INDICATOR([gethostname])
65 gl_GETLOADAVG([$gl_source_base]) 74 gl_GETLOADAVG([$gl_source_base])
75 gl_STDLIB_MODULE_INDICATOR([getloadavg])
66 gl_GETOPT 76 gl_GETOPT
67 dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac. 77 dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac.
68 AM_GNU_GETTEXT_VERSION([0.17]) 78 AM_GNU_GETTEXT_VERSION([0.17])
69 AC_SUBST([LIBINTL]) 79 AC_SUBST([LIBINTL])
70 AC_SUBST([LTLIBINTL]) 80 AC_SUBST([LTLIBINTL])
81 gl_HOSTENT
71 gl_INET_NTOP 82 gl_INET_NTOP
83 gl_ARPA_INET_MODULE_INDICATOR([inet_ntop])
72 gl_INLINE 84 gl_INLINE
73 gl_LOCALCHARSET 85 gl_LOCALCHARSET
74 LOCALCHARSET_TESTS_ENVIRONMENT="CHARSETALIASDIR=\"\$(top_builddir)/$gl_source_base\"" 86 LOCALCHARSET_TESTS_ENVIRONMENT="CHARSETALIASDIR=\"\$(top_builddir)/$gl_source_base\""
@@ -78,12 +90,22 @@ AC_DEFUN([gl_INIT],
78 gl_FUNC_MALLOC_POSIX 90 gl_FUNC_MALLOC_POSIX
79 gl_STDLIB_MODULE_INDICATOR([malloc-posix]) 91 gl_STDLIB_MODULE_INDICATOR([malloc-posix])
80 gl_MATH_H 92 gl_MATH_H
93 gl_FUNC_MBRTOWC
94 gl_WCHAR_MODULE_INDICATOR([mbrtowc])
95 gl_FUNC_MBSINIT
96 gl_WCHAR_MODULE_INDICATOR([mbsinit])
81 gl_MOUNTLIST 97 gl_MOUNTLIST
98 gl_MULTIARCH
99 gl_HEADER_NETDB
82 gl_HEADER_NETINET_IN 100 gl_HEADER_NETINET_IN
83 AC_PROG_MKDIR_P 101 AC_PROG_MKDIR_P
102 gl_FUNC_OPEN
103 gl_MODULE_INDICATOR([open])
104 gl_FCNTL_MODULE_INDICATOR([open])
84 gl_REGEX 105 gl_REGEX
85 gl_SAFE_READ 106 gl_SAFE_READ
86 gl_SAFE_WRITE 107 gl_SAFE_WRITE
108 gl_SERVENT
87 gl_SIZE_MAX 109 gl_SIZE_MAX
88 gl_FUNC_SNPRINTF 110 gl_FUNC_SNPRINTF
89 gl_STDIO_MODULE_INDICATOR([snprintf]) 111 gl_STDIO_MODULE_INDICATOR([snprintf])
@@ -93,8 +115,6 @@ AC_DEFUN([gl_INIT],
93 gl_STDINT_H 115 gl_STDINT_H
94 gl_STDIO_H 116 gl_STDIO_H
95 gl_STDLIB_H 117 gl_STDLIB_H
96 gl_FUNC_STRDUP
97 gl_STRING_MODULE_INDICATOR([strdup])
98 gl_FUNC_STRERROR 118 gl_FUNC_STRERROR
99 gl_STRING_MODULE_INDICATOR([strerror]) 119 gl_STRING_MODULE_INDICATOR([strerror])
100 gl_HEADER_STRING_H 120 gl_HEADER_STRING_H
@@ -103,6 +123,7 @@ AC_DEFUN([gl_INIT],
103 gl_FUNC_STRNLEN 123 gl_FUNC_STRNLEN
104 gl_STRING_MODULE_INDICATOR([strnlen]) 124 gl_STRING_MODULE_INDICATOR([strnlen])
105 gl_HEADER_SYS_SOCKET 125 gl_HEADER_SYS_SOCKET
126 gl_MODULE_INDICATOR([sys_socket])
106 AC_PROG_MKDIR_P 127 AC_PROG_MKDIR_P
107 gl_UNISTD_H 128 gl_UNISTD_H
108 gl_UNISTD_SAFER 129 gl_UNISTD_SAFER
@@ -115,10 +136,27 @@ AC_DEFUN([gl_INIT],
115 gl_FUNC_VSNPRINTF 136 gl_FUNC_VSNPRINTF
116 gl_STDIO_MODULE_INDICATOR([vsnprintf]) 137 gl_STDIO_MODULE_INDICATOR([vsnprintf])
117 gl_WCHAR_H 138 gl_WCHAR_H
139 gl_FUNC_WCRTOMB
140 gl_WCHAR_MODULE_INDICATOR([wcrtomb])
118 gl_WCTYPE_H 141 gl_WCTYPE_H
142 gl_FUNC_WRITE
143 gl_UNISTD_MODULE_INDICATOR([write])
119 gl_XALLOC 144 gl_XALLOC
120 gl_XSIZE 145 gl_XSIZE
121 gl_XSTRNDUP 146 gl_XSTRNDUP
147 m4_ifval(gl_LIBSOURCES_LIST, [
148 m4_syscmd([test ! -d ]m4_defn([gl_LIBSOURCES_DIR])[ ||
149 for gl_file in ]gl_LIBSOURCES_LIST[ ; do
150 if test ! -r ]m4_defn([gl_LIBSOURCES_DIR])[/$gl_file ; then
151 echo "missing file ]m4_defn([gl_LIBSOURCES_DIR])[/$gl_file" >&2
152 exit 1
153 fi
154 done])dnl
155 m4_if(m4_sysval, [0], [],
156 [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])
157 ])
158 m4_popdef([gl_LIBSOURCES_DIR])
159 m4_popdef([gl_LIBSOURCES_LIST])
122 m4_popdef([AC_LIBSOURCES]) 160 m4_popdef([AC_LIBSOURCES])
123 m4_popdef([AC_REPLACE_FUNCS]) 161 m4_popdef([AC_REPLACE_FUNCS])
124 m4_popdef([AC_LIBOBJ]) 162 m4_popdef([AC_LIBOBJ])
@@ -141,7 +179,23 @@ AC_DEFUN([gl_INIT],
141 m4_pushdef([AC_LIBOBJ], m4_defn([gltests_LIBOBJ])) 179 m4_pushdef([AC_LIBOBJ], m4_defn([gltests_LIBOBJ]))
142 m4_pushdef([AC_REPLACE_FUNCS], m4_defn([gltests_REPLACE_FUNCS])) 180 m4_pushdef([AC_REPLACE_FUNCS], m4_defn([gltests_REPLACE_FUNCS]))
143 m4_pushdef([AC_LIBSOURCES], m4_defn([gltests_LIBSOURCES])) 181 m4_pushdef([AC_LIBSOURCES], m4_defn([gltests_LIBSOURCES]))
182 m4_pushdef([gltests_LIBSOURCES_LIST], [])
183 m4_pushdef([gltests_LIBSOURCES_DIR], [])
184 gl_COMMON
144 gl_source_base='tests' 185 gl_source_base='tests'
186 m4_ifval(gltests_LIBSOURCES_LIST, [
187 m4_syscmd([test ! -d ]m4_defn([gltests_LIBSOURCES_DIR])[ ||
188 for gl_file in ]gltests_LIBSOURCES_LIST[ ; do
189 if test ! -r ]m4_defn([gltests_LIBSOURCES_DIR])[/$gl_file ; then
190 echo "missing file ]m4_defn([gltests_LIBSOURCES_DIR])[/$gl_file" >&2
191 exit 1
192 fi
193 done])dnl
194 m4_if(m4_sysval, [0], [],
195 [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])
196 ])
197 m4_popdef([gltests_LIBSOURCES_DIR])
198 m4_popdef([gltests_LIBSOURCES_LIST])
145 m4_popdef([AC_LIBSOURCES]) 199 m4_popdef([AC_LIBSOURCES])
146 m4_popdef([AC_REPLACE_FUNCS]) 200 m4_popdef([AC_REPLACE_FUNCS])
147 m4_popdef([AC_LIBOBJ]) 201 m4_popdef([AC_LIBOBJ])
@@ -172,13 +226,6 @@ AC_DEFUN([gl_LIBOBJ], [
172 gl_LIBOBJS="$gl_LIBOBJS $1.$ac_objext" 226 gl_LIBOBJS="$gl_LIBOBJS $1.$ac_objext"
173]) 227])
174 228
175# m4_foreach_w is provided by autoconf-2.59c and later.
176# This definition is to accommodate developers using versions
177# of autoconf older than that.
178m4_ifndef([m4_foreach_w],
179 [m4_define([m4_foreach_w],
180 [m4_foreach([$1], m4_split(m4_normalize([$2]), [ ]), [$3])])])
181
182# Like AC_REPLACE_FUNCS, except that the module name goes 229# Like AC_REPLACE_FUNCS, except that the module name goes
183# into gl_LIBOBJS instead of into LIBOBJS. 230# into gl_LIBOBJS instead of into LIBOBJS.
184AC_DEFUN([gl_REPLACE_FUNCS], [ 231AC_DEFUN([gl_REPLACE_FUNCS], [
@@ -187,15 +234,14 @@ AC_DEFUN([gl_REPLACE_FUNCS], [
187]) 234])
188 235
189# Like AC_LIBSOURCES, except the directory where the source file is 236# Like AC_LIBSOURCES, except the directory where the source file is
190# expected is derived from the gnulib-tool parametrization, 237# expected is derived from the gnulib-tool parameterization,
191# and alloca is special cased (for the alloca-opt module). 238# and alloca is special cased (for the alloca-opt module).
192# We could also entirely rely on EXTRA_lib..._SOURCES. 239# We could also entirely rely on EXTRA_lib..._SOURCES.
193AC_DEFUN([gl_LIBSOURCES], [ 240AC_DEFUN([gl_LIBSOURCES], [
194 m4_foreach([_gl_NAME], [$1], [ 241 m4_foreach([_gl_NAME], [$1], [
195 m4_if(_gl_NAME, [alloca.c], [], [ 242 m4_if(_gl_NAME, [alloca.c], [], [
196 m4_syscmd([test -r gl/]_gl_NAME[ || test ! -d gl])dnl 243 m4_define([gl_LIBSOURCES_DIR], [gl])
197 m4_if(m4_sysval, [0], [], 244 m4_append([gl_LIBSOURCES_LIST], _gl_NAME, [ ])
198 [AC_FATAL([missing gl/]_gl_NAME)])
199 ]) 245 ])
200 ]) 246 ])
201]) 247])
@@ -207,13 +253,6 @@ AC_DEFUN([gltests_LIBOBJ], [
207 gltests_LIBOBJS="$gltests_LIBOBJS $1.$ac_objext" 253 gltests_LIBOBJS="$gltests_LIBOBJS $1.$ac_objext"
208]) 254])
209 255
210# m4_foreach_w is provided by autoconf-2.59c and later.
211# This definition is to accommodate developers using versions
212# of autoconf older than that.
213m4_ifndef([m4_foreach_w],
214 [m4_define([m4_foreach_w],
215 [m4_foreach([$1], m4_split(m4_normalize([$2]), [ ]), [$3])])])
216
217# Like AC_REPLACE_FUNCS, except that the module name goes 256# Like AC_REPLACE_FUNCS, except that the module name goes
218# into gltests_LIBOBJS instead of into LIBOBJS. 257# into gltests_LIBOBJS instead of into LIBOBJS.
219AC_DEFUN([gltests_REPLACE_FUNCS], [ 258AC_DEFUN([gltests_REPLACE_FUNCS], [
@@ -222,15 +261,14 @@ AC_DEFUN([gltests_REPLACE_FUNCS], [
222]) 261])
223 262
224# Like AC_LIBSOURCES, except the directory where the source file is 263# Like AC_LIBSOURCES, except the directory where the source file is
225# expected is derived from the gnulib-tool parametrization, 264# expected is derived from the gnulib-tool parameterization,
226# and alloca is special cased (for the alloca-opt module). 265# and alloca is special cased (for the alloca-opt module).
227# We could also entirely rely on EXTRA_lib..._SOURCES. 266# We could also entirely rely on EXTRA_lib..._SOURCES.
228AC_DEFUN([gltests_LIBSOURCES], [ 267AC_DEFUN([gltests_LIBSOURCES], [
229 m4_foreach([_gl_NAME], [$1], [ 268 m4_foreach([_gl_NAME], [$1], [
230 m4_if(_gl_NAME, [alloca.c], [], [ 269 m4_if(_gl_NAME, [alloca.c], [], [
231 m4_syscmd([test -r tests/]_gl_NAME[ || test ! -d tests])dnl 270 m4_define([gltests_LIBSOURCES_DIR], [tests])
232 m4_if(m4_sysval, [0], [], 271 m4_append([gltests_LIBSOURCES_LIST], _gl_NAME, [ ])
233 [AC_FATAL([missing tests/]_gl_NAME)])
234 ]) 272 ])
235 ]) 273 ])
236]) 274])
@@ -242,11 +280,13 @@ AC_DEFUN([gl_FILE_LIST], [
242 build-aux/link-warning.h 280 build-aux/link-warning.h
243 lib/alloca.c 281 lib/alloca.c
244 lib/alloca.in.h 282 lib/alloca.in.h
283 lib/arpa_inet.in.h
245 lib/asnprintf.c 284 lib/asnprintf.c
246 lib/asprintf.c 285 lib/asprintf.c
247 lib/base64.c 286 lib/base64.c
248 lib/base64.h 287 lib/base64.h
249 lib/basename.c 288 lib/basename.c
289 lib/btowc.c
250 lib/c-strtod.c 290 lib/c-strtod.c
251 lib/c-strtod.h 291 lib/c-strtod.h
252 lib/cloexec.c 292 lib/cloexec.c
@@ -256,12 +296,14 @@ AC_DEFUN([gl_FILE_LIST], [
256 lib/dirname.c 296 lib/dirname.c
257 lib/dirname.h 297 lib/dirname.h
258 lib/dup-safer.c 298 lib/dup-safer.c
299 lib/errno.in.h
259 lib/error.c 300 lib/error.c
260 lib/error.h 301 lib/error.h
261 lib/exitfail.c 302 lib/exitfail.c
262 lib/exitfail.h 303 lib/exitfail.h
263 lib/fcntl--.h 304 lib/fcntl--.h
264 lib/fcntl-safer.h 305 lib/fcntl-safer.h
306 lib/fcntl.in.h
265 lib/fd-safer.c 307 lib/fd-safer.c
266 lib/float+.h 308 lib/float+.h
267 lib/float.in.h 309 lib/float.in.h
@@ -275,7 +317,6 @@ AC_DEFUN([gl_FILE_LIST], [
275 lib/full-write.h 317 lib/full-write.h
276 lib/gai_strerror.c 318 lib/gai_strerror.c
277 lib/getaddrinfo.c 319 lib/getaddrinfo.c
278 lib/getaddrinfo.h
279 lib/gethostname.c 320 lib/gethostname.c
280 lib/getloadavg.c 321 lib/getloadavg.c
281 lib/getopt.c 322 lib/getopt.c
@@ -284,16 +325,19 @@ AC_DEFUN([gl_FILE_LIST], [
284 lib/getopt_int.h 325 lib/getopt_int.h
285 lib/gettext.h 326 lib/gettext.h
286 lib/inet_ntop.c 327 lib/inet_ntop.c
287 lib/inet_ntop.h
288 lib/intprops.h 328 lib/intprops.h
289 lib/localcharset.c 329 lib/localcharset.c
290 lib/localcharset.h 330 lib/localcharset.h
291 lib/malloc.c 331 lib/malloc.c
292 lib/math.in.h 332 lib/math.in.h
333 lib/mbrtowc.c
334 lib/mbsinit.c
293 lib/mountlist.c 335 lib/mountlist.c
294 lib/mountlist.h 336 lib/mountlist.h
337 lib/netdb.in.h
295 lib/netinet_in.in.h 338 lib/netinet_in.in.h
296 lib/open-safer.c 339 lib/open-safer.c
340 lib/open.c
297 lib/pipe-safer.c 341 lib/pipe-safer.c
298 lib/printf-args.c 342 lib/printf-args.c
299 lib/printf-args.h 343 lib/printf-args.h
@@ -315,9 +359,10 @@ AC_DEFUN([gl_FILE_LIST], [
315 lib/snprintf.c 359 lib/snprintf.c
316 lib/stdbool.in.h 360 lib/stdbool.in.h
317 lib/stdint.in.h 361 lib/stdint.in.h
362 lib/stdio-write.c
318 lib/stdio.in.h 363 lib/stdio.in.h
319 lib/stdlib.in.h 364 lib/stdlib.in.h
320 lib/strdup.c 365 lib/streq.h
321 lib/strerror.c 366 lib/strerror.c
322 lib/string.in.h 367 lib/string.in.h
323 lib/stripslash.c 368 lib/stripslash.c
@@ -330,30 +375,34 @@ AC_DEFUN([gl_FILE_LIST], [
330 lib/vasnprintf.c 375 lib/vasnprintf.c
331 lib/vasnprintf.h 376 lib/vasnprintf.h
332 lib/vasprintf.c 377 lib/vasprintf.c
378 lib/verify.h
333 lib/vsnprintf.c 379 lib/vsnprintf.c
334 lib/wchar.in.h 380 lib/wchar.in.h
381 lib/wcrtomb.c
335 lib/wctype.in.h 382 lib/wctype.in.h
383 lib/write.c
336 lib/xalloc-die.c 384 lib/xalloc-die.c
337 lib/xalloc.h 385 lib/xalloc.h
338 lib/xmalloc.c 386 lib/xmalloc.c
339 lib/xsize.h 387 lib/xsize.h
340 lib/xstrndup.c 388 lib/xstrndup.c
341 lib/xstrndup.h 389 lib/xstrndup.h
342 m4/absolute-header.m4
343 m4/alloca.m4 390 m4/alloca.m4
344 m4/arpa_inet_h.m4 391 m4/arpa_inet_h.m4
345 m4/base64.m4 392 m4/base64.m4
393 m4/btowc.m4
346 m4/c-strtod.m4 394 m4/c-strtod.m4
347 m4/cloexec.m4 395 m4/cloexec.m4
348 m4/codeset.m4 396 m4/codeset.m4
349 m4/dirname.m4 397 m4/dirname.m4
350 m4/dos.m4 398 m4/dos.m4
351 m4/double-slash-root.m4 399 m4/double-slash-root.m4
352 m4/eoverflow.m4 400 m4/errno_h.m4
353 m4/error.m4 401 m4/error.m4
354 m4/exitfail.m4 402 m4/exitfail.m4
355 m4/extensions.m4 403 m4/extensions.m4
356 m4/fcntl-safer.m4 404 m4/fcntl-safer.m4
405 m4/fcntl_h.m4
357 m4/float_h.m4 406 m4/float_h.m4
358 m4/floorf.m4 407 m4/floorf.m4
359 m4/fstypename.m4 408 m4/fstypename.m4
@@ -366,6 +415,7 @@ AC_DEFUN([gl_FILE_LIST], [
366 m4/glibc2.m4 415 m4/glibc2.m4
367 m4/glibc21.m4 416 m4/glibc21.m4
368 m4/gnulib-common.m4 417 m4/gnulib-common.m4
418 m4/hostent.m4
369 m4/iconv.m4 419 m4/iconv.m4
370 m4/include_next.m4 420 m4/include_next.m4
371 m4/inet_ntop.m4 421 m4/inet_ntop.m4
@@ -383,21 +433,32 @@ AC_DEFUN([gl_FILE_LIST], [
383 m4/lib-link.m4 433 m4/lib-link.m4
384 m4/lib-prefix.m4 434 m4/lib-prefix.m4
385 m4/localcharset.m4 435 m4/localcharset.m4
436 m4/locale-fr.m4
437 m4/locale-ja.m4
438 m4/locale-zh.m4
386 m4/lock.m4 439 m4/lock.m4
387 m4/longlong.m4 440 m4/longlong.m4
388 m4/ls-mntd-fs.m4 441 m4/ls-mntd-fs.m4
389 m4/malloc.m4 442 m4/malloc.m4
390 m4/math_h.m4 443 m4/math_h.m4
444 m4/mbrtowc.m4
445 m4/mbsinit.m4
446 m4/mbstate_t.m4
391 m4/mountlist.m4 447 m4/mountlist.m4
448 m4/multiarch.m4
449 m4/netdb_h.m4
392 m4/netinet_in_h.m4 450 m4/netinet_in_h.m4
393 m4/nls.m4 451 m4/nls.m4
394 m4/onceonly_2_57.m4 452 m4/onceonly.m4
453 m4/open.m4
395 m4/po.m4 454 m4/po.m4
396 m4/printf-posix.m4 455 m4/printf-posix.m4
456 m4/printf.m4
397 m4/progtest.m4 457 m4/progtest.m4
398 m4/regex.m4 458 m4/regex.m4
399 m4/safe-read.m4 459 m4/safe-read.m4
400 m4/safe-write.m4 460 m4/safe-write.m4
461 m4/servent.m4
401 m4/size_max.m4 462 m4/size_max.m4
402 m4/snprintf.m4 463 m4/snprintf.m4
403 m4/socklen.m4 464 m4/socklen.m4
@@ -408,12 +469,12 @@ AC_DEFUN([gl_FILE_LIST], [
408 m4/stdint_h.m4 469 m4/stdint_h.m4
409 m4/stdio_h.m4 470 m4/stdio_h.m4
410 m4/stdlib_h.m4 471 m4/stdlib_h.m4
411 m4/strdup.m4
412 m4/strerror.m4 472 m4/strerror.m4
413 m4/string_h.m4 473 m4/string_h.m4
414 m4/strndup.m4 474 m4/strndup.m4
415 m4/strnlen.m4 475 m4/strnlen.m4
416 m4/sys_socket_h.m4 476 m4/sys_socket_h.m4
477 m4/threadlib.m4
417 m4/uintmax_t.m4 478 m4/uintmax_t.m4
418 m4/unistd-safer.m4 479 m4/unistd-safer.m4
419 m4/unistd_h.m4 480 m4/unistd_h.m4
@@ -423,8 +484,10 @@ AC_DEFUN([gl_FILE_LIST], [
423 m4/vsnprintf.m4 484 m4/vsnprintf.m4
424 m4/wchar.m4 485 m4/wchar.m4
425 m4/wchar_t.m4 486 m4/wchar_t.m4
487 m4/wcrtomb.m4
426 m4/wctype.m4 488 m4/wctype.m4
427 m4/wint_t.m4 489 m4/wint_t.m4
490 m4/write.m4
428 m4/xalloc.m4 491 m4/xalloc.m4
429 m4/xsize.m4 492 m4/xsize.m4
430 m4/xstrndup.m4 493 m4/xstrndup.m4
diff --git a/gl/m4/gnulib-tool.m4 b/gl/m4/gnulib-tool.m4
index ef59320..4438d48 100644
--- a/gl/m4/gnulib-tool.m4
+++ b/gl/m4/gnulib-tool.m4
@@ -1,4 +1,4 @@
1# gnulib-tool.m4 serial 1 1# gnulib-tool.m4 serial 2
2dnl Copyright (C) 2004-2005 Free Software Foundation, Inc. 2dnl Copyright (C) 2004-2005 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
@@ -8,6 +8,9 @@ dnl The following macros need not be invoked explicitly.
8dnl Invoking them does nothing except to declare default arguments 8dnl Invoking them does nothing except to declare default arguments
9dnl for "gnulib-tool --import". 9dnl for "gnulib-tool --import".
10 10
11dnl Usage: gl_LOCAL_DIR([DIR])
12AC_DEFUN([gl_LOCAL_DIR], [])
13
11dnl Usage: gl_MODULES([module1 module2 ...]) 14dnl Usage: gl_MODULES([module1 module2 ...])
12AC_DEFUN([gl_MODULES], []) 15AC_DEFUN([gl_MODULES], [])
13 16
@@ -20,14 +23,35 @@ AC_DEFUN([gl_SOURCE_BASE], [])
20dnl Usage: gl_M4_BASE([DIR]) 23dnl Usage: gl_M4_BASE([DIR])
21AC_DEFUN([gl_M4_BASE], []) 24AC_DEFUN([gl_M4_BASE], [])
22 25
26dnl Usage: gl_PO_BASE([DIR])
27AC_DEFUN([gl_PO_BASE], [])
28
29dnl Usage: gl_DOC_BASE([DIR])
30AC_DEFUN([gl_DOC_BASE], [])
31
32dnl Usage: gl_TESTS_BASE([DIR])
33AC_DEFUN([gl_TESTS_BASE], [])
34
35dnl Usage: gl_WITH_TESTS
36AC_DEFUN([gl_WITH_TESTS], [])
37
23dnl Usage: gl_LIB([LIBNAME]) 38dnl Usage: gl_LIB([LIBNAME])
24AC_DEFUN([gl_LIB], []) 39AC_DEFUN([gl_LIB], [])
25 40
26dnl Usage: gl_LGPL 41dnl Usage: gl_LGPL or gl_LGPL([VERSION])
27AC_DEFUN([gl_LGPL], []) 42AC_DEFUN([gl_LGPL], [])
28 43
44dnl Usage: gl_MAKEFILE_NAME([FILENAME])
45AC_DEFUN([gl_MAKEFILE_NAME], [])
46
29dnl Usage: gl_LIBTOOL 47dnl Usage: gl_LIBTOOL
30AC_DEFUN([gl_LIBTOOL], []) 48AC_DEFUN([gl_LIBTOOL], [])
31 49
32dnl Usage: gl_MACRO_PREFIX([PREFIX]) 50dnl Usage: gl_MACRO_PREFIX([PREFIX])
33AC_DEFUN([gl_MACRO_PREFIX], []) 51AC_DEFUN([gl_MACRO_PREFIX], [])
52
53dnl Usage: gl_PO_DOMAIN([DOMAIN])
54AC_DEFUN([gl_PO_DOMAIN], [])
55
56dnl Usage: gl_VC_FILES([BOOLEAN])
57AC_DEFUN([gl_VC_FILES], [])
diff --git a/gl/m4/hostent.m4 b/gl/m4/hostent.m4
new file mode 100644
index 0000000..4a96af7
--- /dev/null
+++ b/gl/m4/hostent.m4
@@ -0,0 +1,45 @@
1# hostent.m4 serial 1
2dnl Copyright (C) 2008 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_HOSTENT],
8[
9 dnl Where are gethostent(), sethostent(), endhostent(), gethostbyname(),
10 dnl gethostbyaddr() defined?
11 dnl - On Solaris, they are in libnsl. Ignore libxnet.
12 dnl - On Haiku, they are in libnetwork.
13 dnl - On BeOS, they are in libnet.
14 dnl - On native Windows, they are in ws2_32.dll.
15 dnl - Otherwise they are in libc.
16 AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
17 HOSTENT_LIB=
18 gl_saved_libs="$LIBS"
19 AC_SEARCH_LIBS([gethostbyname], [nsl network net],
20 [if test "$ac_cv_search_gethostbyname" != "none required"; then
21 HOSTENT_LIB="$ac_cv_search_gethostbyname"
22 fi])
23 LIBS="$gl_saved_libs"
24 if test -z "$HOSTENT_LIB"; then
25 AC_CHECK_FUNCS([gethostbyname], , [
26 AC_CACHE_CHECK([for gethostbyname in winsock2.h and -lws2_32],
27 [gl_cv_w32_gethostbyname],
28 [gl_cv_w32_gethostbyname=no
29 gl_save_LIBS="$LIBS"
30 LIBS="$LIBS -lws2_32"
31 AC_TRY_LINK([
32#ifdef HAVE_WINSOCK2_H
33#include <winsock2.h>
34#endif
35#include <stddef.h>
36], [gethostbyname(NULL);], [gl_cv_w32_gethostbyname=yes])
37 LIBS="$gl_save_LIBS"
38 ])
39 if test "$gl_cv_w32_gethostbyname" = "yes"; then
40 HOSTENT_LIB="-lws2_32"
41 fi
42 ])
43 fi
44 AC_SUBST([HOSTENT_LIB])
45])
diff --git a/gl/m4/iconv.m4 b/gl/m4/iconv.m4
index 66bc76f..3cc6268 100644
--- a/gl/m4/iconv.m4
+++ b/gl/m4/iconv.m4
@@ -1,5 +1,5 @@
1# iconv.m4 serial AM6 (gettext-0.17) 1# iconv.m4 serial AM7 (gettext-0.18)
2dnl Copyright (C) 2000-2002, 2007 Free Software Foundation, Inc. 2dnl Copyright (C) 2000-2002, 2007-2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -34,7 +34,7 @@ AC_DEFUN([AM_ICONV_LINK],
34 am_save_CPPFLAGS="$CPPFLAGS" 34 am_save_CPPFLAGS="$CPPFLAGS"
35 AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV]) 35 AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
36 36
37 AC_CACHE_CHECK([for iconv], am_cv_func_iconv, [ 37 AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [
38 am_cv_func_iconv="no, consider installing GNU libiconv" 38 am_cv_func_iconv="no, consider installing GNU libiconv"
39 am_cv_lib_iconv=no 39 am_cv_lib_iconv=no
40 AC_TRY_LINK([#include <stdlib.h> 40 AC_TRY_LINK([#include <stdlib.h>
@@ -42,7 +42,7 @@ AC_DEFUN([AM_ICONV_LINK],
42 [iconv_t cd = iconv_open("",""); 42 [iconv_t cd = iconv_open("","");
43 iconv(cd,NULL,NULL,NULL,NULL); 43 iconv(cd,NULL,NULL,NULL,NULL);
44 iconv_close(cd);], 44 iconv_close(cd);],
45 am_cv_func_iconv=yes) 45 [am_cv_func_iconv=yes])
46 if test "$am_cv_func_iconv" != yes; then 46 if test "$am_cv_func_iconv" != yes; then
47 am_save_LIBS="$LIBS" 47 am_save_LIBS="$LIBS"
48 LIBS="$LIBS $LIBICONV" 48 LIBS="$LIBS $LIBICONV"
@@ -51,13 +51,13 @@ AC_DEFUN([AM_ICONV_LINK],
51 [iconv_t cd = iconv_open("",""); 51 [iconv_t cd = iconv_open("","");
52 iconv(cd,NULL,NULL,NULL,NULL); 52 iconv(cd,NULL,NULL,NULL,NULL);
53 iconv_close(cd);], 53 iconv_close(cd);],
54 am_cv_lib_iconv=yes 54 [am_cv_lib_iconv=yes]
55 am_cv_func_iconv=yes) 55 [am_cv_func_iconv=yes])
56 LIBS="$am_save_LIBS" 56 LIBS="$am_save_LIBS"
57 fi 57 fi
58 ]) 58 ])
59 if test "$am_cv_func_iconv" = yes; then 59 if test "$am_cv_func_iconv" = yes; then
60 AC_CACHE_CHECK([for working iconv], am_cv_func_iconv_works, [ 60 AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [
61 dnl This tests against bugs in AIX 5.1 and HP-UX 11.11. 61 dnl This tests against bugs in AIX 5.1 and HP-UX 11.11.
62 am_save_LIBS="$LIBS" 62 am_save_LIBS="$LIBS"
63 if test $am_cv_lib_iconv = yes; then 63 if test $am_cv_lib_iconv = yes; then
@@ -134,7 +134,7 @@ int main ()
134 am_func_iconv=no am_cv_lib_iconv=no 134 am_func_iconv=no am_cv_lib_iconv=no
135 fi 135 fi
136 if test "$am_func_iconv" = yes; then 136 if test "$am_func_iconv" = yes; then
137 AC_DEFINE(HAVE_ICONV, 1, 137 AC_DEFINE([HAVE_ICONV], [1],
138 [Define if you have the iconv() function and it works.]) 138 [Define if you have the iconv() function and it works.])
139 fi 139 fi
140 if test "$am_cv_lib_iconv" = yes; then 140 if test "$am_cv_lib_iconv" = yes; then
@@ -147,8 +147,8 @@ int main ()
147 LIBICONV= 147 LIBICONV=
148 LTLIBICONV= 148 LTLIBICONV=
149 fi 149 fi
150 AC_SUBST(LIBICONV) 150 AC_SUBST([LIBICONV])
151 AC_SUBST(LTLIBICONV) 151 AC_SUBST([LTLIBICONV])
152]) 152])
153 153
154AC_DEFUN([AM_ICONV], 154AC_DEFUN([AM_ICONV],
@@ -156,7 +156,7 @@ AC_DEFUN([AM_ICONV],
156 AM_ICONV_LINK 156 AM_ICONV_LINK
157 if test "$am_cv_func_iconv" = yes; then 157 if test "$am_cv_func_iconv" = yes; then
158 AC_MSG_CHECKING([for iconv declaration]) 158 AC_MSG_CHECKING([for iconv declaration])
159 AC_CACHE_VAL(am_cv_proto_iconv, [ 159 AC_CACHE_VAL([am_cv_proto_iconv], [
160 AC_TRY_COMPILE([ 160 AC_TRY_COMPILE([
161#include <stdlib.h> 161#include <stdlib.h>
162#include <iconv.h> 162#include <iconv.h>
@@ -169,12 +169,12 @@ size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, si
169#else 169#else
170size_t iconv(); 170size_t iconv();
171#endif 171#endif
172], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const") 172], [], [am_cv_proto_iconv_arg1=""], [am_cv_proto_iconv_arg1="const"])
173 am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"]) 173 am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
174 am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` 174 am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
175 AC_MSG_RESULT([$]{ac_t:- 175 AC_MSG_RESULT([${ac_t:-
176 }[$]am_cv_proto_iconv) 176 }$am_cv_proto_iconv])
177 AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1, 177 AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1],
178 [Define as const if the declaration of iconv() needs const.]) 178 [Define as const if the declaration of iconv() needs const.])
179 fi 179 fi
180]) 180])
diff --git a/gl/m4/include_next.m4 b/gl/m4/include_next.m4
index 7ce472b..062753c 100644
--- a/gl/m4/include_next.m4
+++ b/gl/m4/include_next.m4
@@ -1,19 +1,46 @@
1# include_next.m4 serial 4 1# include_next.m4 serial 10
2dnl Copyright (C) 2006, 2007 Free Software Foundation, Inc. 2dnl Copyright (C) 2006-2008 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl From Paul Eggert and Derek Price. 7dnl From Paul Eggert and Derek Price.
8 8
9dnl Sets INCLUDE_NEXT and PRAGMA_SYSTEM_HEADER.
10dnl
11dnl INCLUDE_NEXT expands to 'include_next' if the compiler supports it, or to
12dnl 'include' otherwise.
13dnl
14dnl INCLUDE_NEXT_AS_FIRST_DIRECTIVE expands to 'include_next' if the compiler
15dnl supports it in the special case that it is the first include directive in
16dnl the given file, or to 'include' otherwise.
17dnl
18dnl PRAGMA_SYSTEM_HEADER can be used in files that contain #include_next,
19dnl so as to avoid GCC warnings when the gcc option -pedantic is used.
20dnl '#pragma GCC system_header' has the same effect as if the file was found
21dnl through the include search path specified with '-isystem' options (as
22dnl opposed to the search path specified with '-I' options). Namely, gcc
23dnl does not warn about some things, and on some systems (Solaris and Interix)
24dnl __STDC__ evaluates to 0 instead of to 1. The latter is an undesired side
25dnl effect; we are therefore careful to use 'defined __STDC__' or '1' instead
26dnl of plain '__STDC__'.
27
9AC_DEFUN([gl_INCLUDE_NEXT], 28AC_DEFUN([gl_INCLUDE_NEXT],
10[ 29[
11 AC_LANG_PREPROC_REQUIRE() 30 AC_LANG_PREPROC_REQUIRE()
12 AC_CACHE_CHECK([whether the preprocessor supports include_next], 31 AC_CACHE_CHECK([whether the preprocessor supports include_next],
13 [gl_cv_have_include_next], 32 [gl_cv_have_include_next],
14 [rm -rf conftestd1 conftestd2 33 [rm -rf conftestd1a conftestd1b conftestd2
15 mkdir conftestd1 conftestd2 34 mkdir conftestd1a conftestd1b conftestd2
16 cat <<EOF > conftestd1/conftest.h 35 dnl The include of <stdio.h> is because IBM C 9.0 on AIX 6.1 supports
36 dnl include_next when used as first preprocessor directive in a file,
37 dnl but not when preceded by another include directive. Additionally,
38 dnl with this same compiler, include_next is a no-op when used in a
39 dnl header file that was included by specifying its absolute file name.
40 dnl Despite these two bugs, include_next is used in the compiler's
41 dnl <math.h>. By virtue of the second bug, we need to use include_next
42 dnl as well in this case.
43 cat <<EOF > conftestd1a/conftest.h
17#define DEFINED_IN_CONFTESTD1 44#define DEFINED_IN_CONFTESTD1
18#include_next <conftest.h> 45#include_next <conftest.h>
19#ifdef DEFINED_IN_CONFTESTD2 46#ifdef DEFINED_IN_CONFTESTD2
@@ -22,32 +49,53 @@ int foo;
22#error "include_next doesn't work" 49#error "include_next doesn't work"
23#endif 50#endif
24EOF 51EOF
52 cat <<EOF > conftestd1b/conftest.h
53#define DEFINED_IN_CONFTESTD1
54#include <stdio.h>
55#include_next <conftest.h>
56#ifdef DEFINED_IN_CONFTESTD2
57int foo;
58#else
59#error "include_next doesn't work"
60#endif
61EOF
25 cat <<EOF > conftestd2/conftest.h 62 cat <<EOF > conftestd2/conftest.h
26#ifndef DEFINED_IN_CONFTESTD1 63#ifndef DEFINED_IN_CONFTESTD1
27#error "include_next test doesn't work" 64#error "include_next test doesn't work"
28#endif 65#endif
29#define DEFINED_IN_CONFTESTD2 66#define DEFINED_IN_CONFTESTD2
30EOF 67EOF
31 save_CPPFLAGS="$CPPFLAGS" 68 gl_save_CPPFLAGS="$CPPFLAGS"
32 CPPFLAGS="$CPPFLAGS -Iconftestd1 -Iconftestd2" 69 CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1b -Iconftestd2"
33 AC_COMPILE_IFELSE([#include <conftest.h>], 70 AC_COMPILE_IFELSE([#include <conftest.h>],
34 [gl_cv_have_include_next=yes], 71 [gl_cv_have_include_next=yes],
35 [gl_cv_have_include_next=no]) 72 [CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1a -Iconftestd2"
36 CPPFLAGS="$save_CPPFLAGS" 73 AC_COMPILE_IFELSE([#include <conftest.h>],
37 rm -rf conftestd1 conftestd2 74 [gl_cv_have_include_next=buggy],
75 [gl_cv_have_include_next=no])
76 ])
77 CPPFLAGS="$gl_save_CPPFLAGS"
78 rm -rf conftestd1a conftestd1b conftestd2
38 ]) 79 ])
80 PRAGMA_SYSTEM_HEADER=
39 if test $gl_cv_have_include_next = yes; then 81 if test $gl_cv_have_include_next = yes; then
40
41 dnl FIXME: Remove HAVE_INCLUDE_NEXT and update everything that uses it
42 dnl to use @INCLUDE_NEXT@ instead.
43 AC_DEFINE([HAVE_INCLUDE_NEXT], 1,
44 [Define if your compiler supports the #include_next directive.])
45
46 INCLUDE_NEXT=include_next 82 INCLUDE_NEXT=include_next
83 INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next
84 if test -n "$GCC"; then
85 PRAGMA_SYSTEM_HEADER='#pragma GCC system_header'
86 fi
47 else 87 else
48 INCLUDE_NEXT=include 88 if test $gl_cv_have_include_next = buggy; then
89 INCLUDE_NEXT=include
90 INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next
91 else
92 INCLUDE_NEXT=include
93 INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include
94 fi
49 fi 95 fi
50 AC_SUBST([INCLUDE_NEXT]) 96 AC_SUBST([INCLUDE_NEXT])
97 AC_SUBST([INCLUDE_NEXT_AS_FIRST_DIRECTIVE])
98 AC_SUBST([PRAGMA_SYSTEM_HEADER])
51]) 99])
52 100
53# gl_CHECK_NEXT_HEADERS(HEADER1 HEADER2 ...) 101# gl_CHECK_NEXT_HEADERS(HEADER1 HEADER2 ...)
@@ -63,12 +111,16 @@ EOF
63# The three "///" are to pacify Sun C 5.8, which otherwise would say 111# The three "///" are to pacify Sun C 5.8, which otherwise would say
64# "warning: #include of /usr/include/... may be non-portable". 112# "warning: #include of /usr/include/... may be non-portable".
65# Use `""', not `<>', so that the /// cannot be confused with a C99 comment. 113# Use `""', not `<>', so that the /// cannot be confused with a C99 comment.
114# Note: This macro assumes that the header file is not empty after
115# preprocessing, i.e. it does not only define preprocessor macros but also
116# provides some type/enum definitions or function/variable declarations.
66AC_DEFUN([gl_CHECK_NEXT_HEADERS], 117AC_DEFUN([gl_CHECK_NEXT_HEADERS],
67[ 118[
68 AC_REQUIRE([gl_INCLUDE_NEXT]) 119 AC_REQUIRE([gl_INCLUDE_NEXT])
120 AC_REQUIRE([AC_CANONICAL_HOST])
69 AC_CHECK_HEADERS_ONCE([$1]) 121 AC_CHECK_HEADERS_ONCE([$1])
70 122
71 AC_FOREACH([gl_HEADER_NAME], [$1], 123 m4_foreach_w([gl_HEADER_NAME], [$1],
72 [AS_VAR_PUSHDEF([gl_next_header], 124 [AS_VAR_PUSHDEF([gl_next_header],
73 [gl_cv_next_]m4_quote(m4_defn([gl_HEADER_NAME]))) 125 [gl_cv_next_]m4_quote(m4_defn([gl_HEADER_NAME])))
74 if test $gl_cv_have_include_next = yes; then 126 if test $gl_cv_have_include_next = yes; then
@@ -84,11 +136,22 @@ AC_DEFUN([gl_CHECK_NEXT_HEADERS],
84 [AC_LANG_SOURCE( 136 [AC_LANG_SOURCE(
85 [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]] 137 [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]]
86 )]) 138 )])
87 dnl eval is necessary to expand ac_cpp. 139 dnl AIX "xlc -E" and "cc -E" omit #line directives for header files
140 dnl that contain only a #include of other header files and no
141 dnl non-comment tokens of their own. This leads to a failure to
142 dnl detect the absolute name of <dirent.h>, <signal.h>, <poll.h>
143 dnl and others. The workaround is to force preservation of comments
144 dnl through option -C. This ensures all necessary #line directives
145 dnl are present. GCC supports option -C as well.
146 case "$host_os" in
147 aix*) gl_absname_cpp="$ac_cpp -C" ;;
148 *) gl_absname_cpp="$ac_cpp" ;;
149 esac
150 dnl eval is necessary to expand gl_absname_cpp.
88 dnl Ultrix and Pyramid sh refuse to redirect output of eval, 151 dnl Ultrix and Pyramid sh refuse to redirect output of eval,
89 dnl so use subshell. 152 dnl so use subshell.
90 AS_VAR_SET([gl_next_header], 153 AS_VAR_SET([gl_next_header],
91 ['"'`(eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD | 154 ['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
92 sed -n '\#/]m4_quote(m4_defn([gl_HEADER_NAME]))[#{ 155 sed -n '\#/]m4_quote(m4_defn([gl_HEADER_NAME]))[#{
93 s#.*"\(.*/]m4_quote(m4_defn([gl_HEADER_NAME]))[\)".*#\1# 156 s#.*"\(.*/]m4_quote(m4_defn([gl_HEADER_NAME]))[\)".*#\1#
94 s#^/[^/]#//&# 157 s#^/[^/]#//&#
diff --git a/gl/m4/inet_ntop.m4 b/gl/m4/inet_ntop.m4
index bb02d22..42bfc5e 100644
--- a/gl/m4/inet_ntop.m4
+++ b/gl/m4/inet_ntop.m4
@@ -1,19 +1,26 @@
1# inet_ntop.m4 serial 3 1# inet_ntop.m4 serial 8
2dnl Copyright (C) 2005, 2006 Free Software Foundation, Inc. 2dnl Copyright (C) 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN([gl_INET_NTOP], 7AC_DEFUN([gl_INET_NTOP],
8[ 8[
9 AC_REPLACE_FUNCS(inet_ntop) 9 dnl Persuade Solaris <arpa/inet.h> to declare inet_ntop.
10 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
11
12 gl_REPLACE_ARPA_INET_H
13
14 AC_REPLACE_FUNCS([inet_ntop])
10 gl_PREREQ_INET_NTOP 15 gl_PREREQ_INET_NTOP
11]) 16])
12 17
13# Prerequisites of lib/inet_ntop.h and lib/inet_ntop.c. 18# Prerequisites of lib/inet_ntop.c.
14AC_DEFUN([gl_PREREQ_INET_NTOP], [ 19AC_DEFUN([gl_PREREQ_INET_NTOP], [
15 AC_CHECK_HEADERS_ONCE([netinet/in.h arpa/inet.h])
16 AC_CHECK_DECLS([inet_ntop],,,[#include <arpa/inet.h>]) 20 AC_CHECK_DECLS([inet_ntop],,,[#include <arpa/inet.h>])
21 if test $ac_cv_have_decl_inet_ntop = no; then
22 HAVE_DECL_INET_NTOP=0
23 fi
17 AC_REQUIRE([gl_SOCKET_FAMILIES]) 24 AC_REQUIRE([gl_SOCKET_FAMILIES])
18 AC_REQUIRE([AC_C_RESTRICT]) 25 AC_REQUIRE([AC_C_RESTRICT])
19]) 26])
diff --git a/gl/m4/inline.m4 b/gl/m4/inline.m4
index a07076c..cee5109 100644
--- a/gl/m4/inline.m4
+++ b/gl/m4/inline.m4
@@ -1,5 +1,5 @@
1# inline.m4 serial 3 1# inline.m4 serial 4
2dnl Copyright (C) 2006 Free Software Foundation, Inc. 2dnl Copyright (C) 2006, 2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -32,7 +32,7 @@ AC_DEFUN([gl_INLINE],
32 fi 32 fi
33 ]) 33 ])
34 if test $gl_cv_c_inline_effective = yes; then 34 if test $gl_cv_c_inline_effective = yes; then
35 AC_DEFINE([HAVE_INLINE], 1, 35 AC_DEFINE([HAVE_INLINE], [1],
36 [Define to 1 if the compiler supports one of the keywords 36 [Define to 1 if the compiler supports one of the keywords
37 'inline', '__inline__', '__inline' and effectively inlines 37 'inline', '__inline__', '__inline' and effectively inlines
38 functions marked as such.]) 38 functions marked as such.])
diff --git a/gl/m4/intdiv0.m4 b/gl/m4/intdiv0.m4
index 8c8a670..29e6e0a 100644
--- a/gl/m4/intdiv0.m4
+++ b/gl/m4/intdiv0.m4
@@ -1,5 +1,5 @@
1# intdiv0.m4 serial 2 (gettext-0.17) 1# intdiv0.m4 serial 3 (gettext-0.18)
2dnl Copyright (C) 2002, 2007 Free Software Foundation, Inc. 2dnl Copyright (C) 2002, 2007-2008 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -61,7 +61,7 @@ int main ()
61 nan = y / y; 61 nan = y / y;
62 exit (1); 62 exit (1);
63} 63}
64], gt_cv_int_divbyzero_sigfpe=yes, gt_cv_int_divbyzero_sigfpe=no, 64], [gt_cv_int_divbyzero_sigfpe=yes], [gt_cv_int_divbyzero_sigfpe=no],
65 [ 65 [
66 # Guess based on the CPU. 66 # Guess based on the CPU.
67changequote(,)dnl 67changequote(,)dnl
@@ -79,6 +79,6 @@ changequote([,])dnl
79 *yes) value=1;; 79 *yes) value=1;;
80 *) value=0;; 80 *) value=0;;
81 esac 81 esac
82 AC_DEFINE_UNQUOTED(INTDIV0_RAISES_SIGFPE, $value, 82 AC_DEFINE_UNQUOTED([INTDIV0_RAISES_SIGFPE], [$value],
83 [Define if integer division by zero raises signal SIGFPE.]) 83 [Define if integer division by zero raises signal SIGFPE.])
84]) 84])
diff --git a/gl/m4/intldir.m4 b/gl/m4/intldir.m4
index 7a28843..0980e6f 100644
--- a/gl/m4/intldir.m4
+++ b/gl/m4/intldir.m4
@@ -1,5 +1,5 @@
1# intldir.m4 serial 1 (gettext-0.16) 1# intldir.m4 serial 2 (gettext-0.18)
2dnl Copyright (C) 2006 Free Software Foundation, Inc. 2dnl Copyright (C) 2006, 2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -13,7 +13,7 @@ dnl by the GNU Library General Public License, and the rest of the GNU
13dnl gettext package package is covered by the GNU General Public License. 13dnl gettext package package is covered by the GNU General Public License.
14dnl They are *not* in the public domain. 14dnl They are *not* in the public domain.
15 15
16AC_PREREQ(2.52) 16AC_PREREQ([2.52])
17 17
18dnl Tells the AM_GNU_GETTEXT macro to consider an intl/ directory. 18dnl Tells the AM_GNU_GETTEXT macro to consider an intl/ directory.
19AC_DEFUN([AM_GNU_GETTEXT_INTL_SUBDIR], []) 19AC_DEFUN([AM_GNU_GETTEXT_INTL_SUBDIR], [])
diff --git a/gl/m4/intlmacosx.m4 b/gl/m4/intlmacosx.m4
index d3f0d90..c24837c 100644
--- a/gl/m4/intlmacosx.m4
+++ b/gl/m4/intlmacosx.m4
@@ -1,5 +1,5 @@
1# intlmacosx.m4 serial 1 (gettext-0.17) 1# intlmacosx.m4 serial 3 (gettext-0.18)
2dnl Copyright (C) 2004-2007 Free Software Foundation, Inc. 2dnl Copyright (C) 2004-2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -19,7 +19,7 @@ AC_DEFUN([gt_INTL_MACOSX],
19[ 19[
20 dnl Check for API introduced in MacOS X 10.2. 20 dnl Check for API introduced in MacOS X 10.2.
21 AC_CACHE_CHECK([for CFPreferencesCopyAppValue], 21 AC_CACHE_CHECK([for CFPreferencesCopyAppValue],
22 gt_cv_func_CFPreferencesCopyAppValue, 22 [gt_cv_func_CFPreferencesCopyAppValue],
23 [gt_save_LIBS="$LIBS" 23 [gt_save_LIBS="$LIBS"
24 LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" 24 LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation"
25 AC_TRY_LINK([#include <CoreFoundation/CFPreferences.h>], 25 AC_TRY_LINK([#include <CoreFoundation/CFPreferences.h>],
@@ -28,11 +28,11 @@ AC_DEFUN([gt_INTL_MACOSX],
28 [gt_cv_func_CFPreferencesCopyAppValue=no]) 28 [gt_cv_func_CFPreferencesCopyAppValue=no])
29 LIBS="$gt_save_LIBS"]) 29 LIBS="$gt_save_LIBS"])
30 if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then 30 if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then
31 AC_DEFINE([HAVE_CFPREFERENCESCOPYAPPVALUE], 1, 31 AC_DEFINE([HAVE_CFPREFERENCESCOPYAPPVALUE], [1],
32 [Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in the CoreFoundation framework.]) 32 [Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in the CoreFoundation framework.])
33 fi 33 fi
34 dnl Check for API introduced in MacOS X 10.3. 34 dnl Check for API introduced in MacOS X 10.3.
35 AC_CACHE_CHECK([for CFLocaleCopyCurrent], gt_cv_func_CFLocaleCopyCurrent, 35 AC_CACHE_CHECK([for CFLocaleCopyCurrent], [gt_cv_func_CFLocaleCopyCurrent],
36 [gt_save_LIBS="$LIBS" 36 [gt_save_LIBS="$LIBS"
37 LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" 37 LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation"
38 AC_TRY_LINK([#include <CoreFoundation/CFLocale.h>], [CFLocaleCopyCurrent();], 38 AC_TRY_LINK([#include <CoreFoundation/CFLocale.h>], [CFLocaleCopyCurrent();],
@@ -40,7 +40,7 @@ AC_DEFUN([gt_INTL_MACOSX],
40 [gt_cv_func_CFLocaleCopyCurrent=no]) 40 [gt_cv_func_CFLocaleCopyCurrent=no])
41 LIBS="$gt_save_LIBS"]) 41 LIBS="$gt_save_LIBS"])
42 if test $gt_cv_func_CFLocaleCopyCurrent = yes; then 42 if test $gt_cv_func_CFLocaleCopyCurrent = yes; then
43 AC_DEFINE([HAVE_CFLOCALECOPYCURRENT], 1, 43 AC_DEFINE([HAVE_CFLOCALECOPYCURRENT], [1],
44 [Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the CoreFoundation framework.]) 44 [Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the CoreFoundation framework.])
45 fi 45 fi
46 INTL_MACOSX_LIBS= 46 INTL_MACOSX_LIBS=
diff --git a/gl/m4/intmax.m4 b/gl/m4/intmax.m4
index ce7a8a4..a3785e9 100644
--- a/gl/m4/intmax.m4
+++ b/gl/m4/intmax.m4
@@ -1,5 +1,5 @@
1# intmax.m4 serial 3 (gettext-0.16) 1# intmax.m4 serial 5 (gettext-0.18)
2dnl Copyright (C) 2002-2005 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2005, 2008, 2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -12,7 +12,7 @@ AC_DEFUN([gt_TYPE_INTMAX_T],
12[ 12[
13 AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) 13 AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
14 AC_REQUIRE([gl_AC_HEADER_STDINT_H]) 14 AC_REQUIRE([gl_AC_HEADER_STDINT_H])
15 AC_CACHE_CHECK(for intmax_t, gt_cv_c_intmax_t, 15 AC_CACHE_CHECK([for intmax_t], [gt_cv_c_intmax_t],
16 [AC_TRY_COMPILE([ 16 [AC_TRY_COMPILE([
17#include <stddef.h> 17#include <stddef.h>
18#include <stdlib.h> 18#include <stdlib.h>
@@ -24,10 +24,10 @@ AC_DEFUN([gt_TYPE_INTMAX_T],
24#endif 24#endif
25], [intmax_t x = -1; 25], [intmax_t x = -1;
26 return !x;], 26 return !x;],
27 gt_cv_c_intmax_t=yes, 27 [gt_cv_c_intmax_t=yes],
28 gt_cv_c_intmax_t=no)]) 28 [gt_cv_c_intmax_t=no])])
29 if test $gt_cv_c_intmax_t = yes; then 29 if test $gt_cv_c_intmax_t = yes; then
30 AC_DEFINE(HAVE_INTMAX_T, 1, 30 AC_DEFINE([HAVE_INTMAX_T], [1],
31 [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.]) 31 [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.])
32 fi 32 fi
33]) 33])
diff --git a/gl/m4/intmax_t.m4 b/gl/m4/intmax_t.m4
index 50ae35d..264cb57 100644
--- a/gl/m4/intmax_t.m4
+++ b/gl/m4/intmax_t.m4
@@ -1,12 +1,12 @@
1# intmax_t.m4 serial 6 1# intmax_t.m4 serial 7
2dnl Copyright (C) 1997-2004, 2006-2007 Free Software Foundation, Inc. 2dnl Copyright (C) 1997-2004, 2006-2007, 2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl From Paul Eggert. 7dnl From Paul Eggert.
8 8
9AC_PREREQ(2.13) 9AC_PREREQ([2.13])
10 10
11# Define intmax_t to 'long' or 'long long' 11# Define intmax_t to 'long' or 'long long'
12# if it is not already defined in <stdint.h> or <inttypes.h>. 12# if it is not already defined in <stdint.h> or <inttypes.h>.
@@ -22,10 +22,10 @@ AC_DEFUN([gl_AC_TYPE_INTMAX_T],
22 test $ac_cv_type_long_long_int = yes \ 22 test $ac_cv_type_long_long_int = yes \
23 && ac_type='long long' \ 23 && ac_type='long long' \
24 || ac_type='long' 24 || ac_type='long'
25 AC_DEFINE_UNQUOTED(intmax_t, $ac_type, 25 AC_DEFINE_UNQUOTED([intmax_t], [$ac_type],
26 [Define to long or long long if <inttypes.h> and <stdint.h> don't define.]) 26 [Define to long or long long if <inttypes.h> and <stdint.h> don't define.])
27 else 27 else
28 AC_DEFINE(HAVE_INTMAX_T, 1, 28 AC_DEFINE([HAVE_INTMAX_T], [1],
29 [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.]) 29 [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.])
30 fi 30 fi
31]) 31])
@@ -36,7 +36,7 @@ AC_DEFUN([gt_AC_TYPE_INTMAX_T],
36[ 36[
37 AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) 37 AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
38 AC_REQUIRE([gl_AC_HEADER_STDINT_H]) 38 AC_REQUIRE([gl_AC_HEADER_STDINT_H])
39 AC_CACHE_CHECK(for intmax_t, gt_cv_c_intmax_t, 39 AC_CACHE_CHECK([for intmax_t], [gt_cv_c_intmax_t],
40 [AC_TRY_COMPILE([ 40 [AC_TRY_COMPILE([
41#include <stddef.h> 41#include <stddef.h>
42#include <stdlib.h> 42#include <stdlib.h>
@@ -48,14 +48,14 @@ AC_DEFUN([gt_AC_TYPE_INTMAX_T],
48#endif 48#endif
49], [intmax_t x = -1; return !x;], gt_cv_c_intmax_t=yes, gt_cv_c_intmax_t=no)]) 49], [intmax_t x = -1; return !x;], gt_cv_c_intmax_t=yes, gt_cv_c_intmax_t=no)])
50 if test $gt_cv_c_intmax_t = yes; then 50 if test $gt_cv_c_intmax_t = yes; then
51 AC_DEFINE(HAVE_INTMAX_T, 1, 51 AC_DEFINE([HAVE_INTMAX_T], [1],
52 [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.]) 52 [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.])
53 else 53 else
54 AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) 54 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
55 test $ac_cv_type_long_long_int = yes \ 55 test $ac_cv_type_long_long_int = yes \
56 && ac_type='long long' \ 56 && ac_type='long long' \
57 || ac_type='long' 57 || ac_type='long'
58 AC_DEFINE_UNQUOTED(intmax_t, $ac_type, 58 AC_DEFINE_UNQUOTED([intmax_t], [$ac_type],
59 [Define to long or long long if <stdint.h> and <inttypes.h> don't define.]) 59 [Define to long or long long if <stdint.h> and <inttypes.h> don't define.])
60 fi 60 fi
61]) 61])
diff --git a/gl/m4/inttypes-pri.m4 b/gl/m4/inttypes-pri.m4
index 7c7f894..98fec7b 100644
--- a/gl/m4/inttypes-pri.m4
+++ b/gl/m4/inttypes-pri.m4
@@ -1,12 +1,12 @@
1# inttypes-pri.m4 serial 4 (gettext-0.16) 1# inttypes-pri.m4 serial 6 (gettext-0.18)
2dnl Copyright (C) 1997-2002, 2006 Free Software Foundation, Inc. 2dnl Copyright (C) 1997-2002, 2006, 2008, 2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl From Bruno Haible. 7dnl From Bruno Haible.
8 8
9AC_PREREQ(2.52) 9AC_PREREQ([2.52])
10 10
11# Define PRI_MACROS_BROKEN if <inttypes.h> exists and defines the PRI* 11# Define PRI_MACROS_BROKEN if <inttypes.h> exists and defines the PRI*
12# macros to non-string values. This is the case on AIX 4.3.3. 12# macros to non-string values. This is the case on AIX 4.3.3.
@@ -16,17 +16,17 @@ AC_DEFUN([gt_INTTYPES_PRI],
16 AC_CHECK_HEADERS([inttypes.h]) 16 AC_CHECK_HEADERS([inttypes.h])
17 if test $ac_cv_header_inttypes_h = yes; then 17 if test $ac_cv_header_inttypes_h = yes; then
18 AC_CACHE_CHECK([whether the inttypes.h PRIxNN macros are broken], 18 AC_CACHE_CHECK([whether the inttypes.h PRIxNN macros are broken],
19 gt_cv_inttypes_pri_broken, 19 [gt_cv_inttypes_pri_broken],
20 [ 20 [
21 AC_TRY_COMPILE([#include <inttypes.h> 21 AC_TRY_COMPILE([#include <inttypes.h>
22#ifdef PRId32 22#ifdef PRId32
23char *p = PRId32; 23char *p = PRId32;
24#endif 24#endif
25], [], gt_cv_inttypes_pri_broken=no, gt_cv_inttypes_pri_broken=yes) 25], [], [gt_cv_inttypes_pri_broken=no], [gt_cv_inttypes_pri_broken=yes])
26 ]) 26 ])
27 fi 27 fi
28 if test "$gt_cv_inttypes_pri_broken" = yes; then 28 if test "$gt_cv_inttypes_pri_broken" = yes; then
29 AC_DEFINE_UNQUOTED(PRI_MACROS_BROKEN, 1, 29 AC_DEFINE_UNQUOTED([PRI_MACROS_BROKEN], [1],
30 [Define if <inttypes.h> exists and defines unusable PRI* macros.]) 30 [Define if <inttypes.h> exists and defines unusable PRI* macros.])
31 PRI_MACROS_BROKEN=1 31 PRI_MACROS_BROKEN=1
32 else 32 else
diff --git a/gl/m4/inttypes_h.m4 b/gl/m4/inttypes_h.m4
index edc8ecb..f4ca160 100644
--- a/gl/m4/inttypes_h.m4
+++ b/gl/m4/inttypes_h.m4
@@ -1,5 +1,5 @@
1# inttypes_h.m4 serial 7 1# inttypes_h.m4 serial 9
2dnl Copyright (C) 1997-2004, 2006 Free Software Foundation, Inc. 2dnl Copyright (C) 1997-2004, 2006, 2008, 2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -11,15 +11,15 @@ dnl From Paul Eggert.
11 11
12AC_DEFUN([gl_AC_HEADER_INTTYPES_H], 12AC_DEFUN([gl_AC_HEADER_INTTYPES_H],
13[ 13[
14 AC_CACHE_CHECK([for inttypes.h], gl_cv_header_inttypes_h, 14 AC_CACHE_CHECK([for inttypes.h], [gl_cv_header_inttypes_h],
15 [AC_TRY_COMPILE( 15 [AC_TRY_COMPILE(
16 [#include <sys/types.h> 16 [#include <sys/types.h>
17#include <inttypes.h>], 17#include <inttypes.h>],
18 [uintmax_t i = (uintmax_t) -1; return !i;], 18 [uintmax_t i = (uintmax_t) -1; return !i;],
19 gl_cv_header_inttypes_h=yes, 19 [gl_cv_header_inttypes_h=yes],
20 gl_cv_header_inttypes_h=no)]) 20 [gl_cv_header_inttypes_h=no])])
21 if test $gl_cv_header_inttypes_h = yes; then 21 if test $gl_cv_header_inttypes_h = yes; then
22 AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H_WITH_UINTMAX, 1, 22 AC_DEFINE_UNQUOTED([HAVE_INTTYPES_H_WITH_UINTMAX], [1],
23 [Define if <inttypes.h> exists, doesn't clash with <sys/types.h>, 23 [Define if <inttypes.h> exists, doesn't clash with <sys/types.h>,
24 and declares uintmax_t. ]) 24 and declares uintmax_t. ])
25 fi 25 fi
diff --git a/gl/m4/lcmessage.m4 b/gl/m4/lcmessage.m4
index 19aa77e..fa8e416 100644
--- a/gl/m4/lcmessage.m4
+++ b/gl/m4/lcmessage.m4
@@ -1,5 +1,5 @@
1# lcmessage.m4 serial 4 (gettext-0.14.2) 1# lcmessage.m4 serial 6 (gettext-0.18)
2dnl Copyright (C) 1995-2002, 2004-2005 Free Software Foundation, Inc. 2dnl Copyright (C) 1995-2002, 2004-2005, 2008, 2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -20,11 +20,11 @@ dnl Ulrich Drepper <drepper@cygnus.com>, 1995.
20 20
21AC_DEFUN([gt_LC_MESSAGES], 21AC_DEFUN([gt_LC_MESSAGES],
22[ 22[
23 AC_CACHE_CHECK([for LC_MESSAGES], gt_cv_val_LC_MESSAGES, 23 AC_CACHE_CHECK([for LC_MESSAGES], [gt_cv_val_LC_MESSAGES],
24 [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES], 24 [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
25 gt_cv_val_LC_MESSAGES=yes, gt_cv_val_LC_MESSAGES=no)]) 25 [gt_cv_val_LC_MESSAGES=yes], [gt_cv_val_LC_MESSAGES=no])])
26 if test $gt_cv_val_LC_MESSAGES = yes; then 26 if test $gt_cv_val_LC_MESSAGES = yes; then
27 AC_DEFINE(HAVE_LC_MESSAGES, 1, 27 AC_DEFINE([HAVE_LC_MESSAGES], [1],
28 [Define if your <locale.h> file defines LC_MESSAGES.]) 28 [Define if your <locale.h> file defines LC_MESSAGES.])
29 fi 29 fi
30]) 30])
diff --git a/gl/m4/lib-ld.m4 b/gl/m4/lib-ld.m4
index 96c4e2c..e4863f2 100644
--- a/gl/m4/lib-ld.m4
+++ b/gl/m4/lib-ld.m4
@@ -1,5 +1,5 @@
1# lib-ld.m4 serial 3 (gettext-0.13) 1# lib-ld.m4 serial 4 (gettext-0.18)
2dnl Copyright (C) 1996-2003 Free Software Foundation, Inc. 2dnl Copyright (C) 1996-2003, 2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -10,7 +10,7 @@ dnl with libtool.m4.
10 10
11dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no. 11dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no.
12AC_DEFUN([AC_LIB_PROG_LD_GNU], 12AC_DEFUN([AC_LIB_PROG_LD_GNU],
13[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld, 13[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], [acl_cv_prog_gnu_ld],
14[# I'd rather use --version here, but apparently some GNU ld's only accept -v. 14[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
15case `$LD -v 2>&1 </dev/null` in 15case `$LD -v 2>&1 </dev/null` in
16*GNU* | *'with BFD'*) 16*GNU* | *'with BFD'*)
@@ -23,7 +23,7 @@ with_gnu_ld=$acl_cv_prog_gnu_ld
23 23
24dnl From libtool-1.4. Sets the variable LD. 24dnl From libtool-1.4. Sets the variable LD.
25AC_DEFUN([AC_LIB_PROG_LD], 25AC_DEFUN([AC_LIB_PROG_LD],
26[AC_ARG_WITH(gnu-ld, 26[AC_ARG_WITH([gnu-ld],
27[ --with-gnu-ld assume the C compiler uses GNU ld [default=no]], 27[ --with-gnu-ld assume the C compiler uses GNU ld [default=no]],
28test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no) 28test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
29AC_REQUIRE([AC_PROG_CC])dnl 29AC_REQUIRE([AC_PROG_CC])dnl
@@ -77,7 +77,7 @@ elif test "$with_gnu_ld" = yes; then
77else 77else
78 AC_MSG_CHECKING([for non-GNU ld]) 78 AC_MSG_CHECKING([for non-GNU ld])
79fi 79fi
80AC_CACHE_VAL(acl_cv_path_LD, 80AC_CACHE_VAL([acl_cv_path_LD],
81[if test -z "$LD"; then 81[if test -z "$LD"; then
82 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" 82 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
83 for ac_dir in $PATH; do 83 for ac_dir in $PATH; do
@@ -101,9 +101,9 @@ else
101fi]) 101fi])
102LD="$acl_cv_path_LD" 102LD="$acl_cv_path_LD"
103if test -n "$LD"; then 103if test -n "$LD"; then
104 AC_MSG_RESULT($LD) 104 AC_MSG_RESULT([$LD])
105else 105else
106 AC_MSG_RESULT(no) 106 AC_MSG_RESULT([no])
107fi 107fi
108test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) 108test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
109AC_LIB_PROG_LD_GNU 109AC_LIB_PROG_LD_GNU
diff --git a/gl/m4/lib-link.m4 b/gl/m4/lib-link.m4
index e3d26fc..fcd3391 100644
--- a/gl/m4/lib-link.m4
+++ b/gl/m4/lib-link.m4
@@ -1,12 +1,12 @@
1# lib-link.m4 serial 13 (gettext-0.17) 1# lib-link.m4 serial 18 (gettext-0.18)
2dnl Copyright (C) 2001-2007 Free Software Foundation, Inc. 2dnl Copyright (C) 2001-2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl From Bruno Haible. 7dnl From Bruno Haible.
8 8
9AC_PREREQ(2.54) 9AC_PREREQ([2.54])
10 10
11dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and 11dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
12dnl the libraries corresponding to explicit and implicit dependencies. 12dnl the libraries corresponding to explicit and implicit dependencies.
@@ -18,9 +18,9 @@ AC_DEFUN([AC_LIB_LINKFLAGS],
18[ 18[
19 AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) 19 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
20 AC_REQUIRE([AC_LIB_RPATH]) 20 AC_REQUIRE([AC_LIB_RPATH])
21 define([Name],[translit([$1],[./-], [___])]) 21 pushdef([Name],[translit([$1],[./-], [___])])
22 define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], 22 pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
23 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) 23 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
24 AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [ 24 AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
25 AC_LIB_LINKFLAGS_BODY([$1], [$2]) 25 AC_LIB_LINKFLAGS_BODY([$1], [$2])
26 ac_cv_lib[]Name[]_libs="$LIB[]NAME" 26 ac_cv_lib[]Name[]_libs="$LIB[]NAME"
@@ -39,8 +39,8 @@ AC_DEFUN([AC_LIB_LINKFLAGS],
39 dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the 39 dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
40 dnl results of this search when this library appears as a dependency. 40 dnl results of this search when this library appears as a dependency.
41 HAVE_LIB[]NAME=yes 41 HAVE_LIB[]NAME=yes
42 undefine([Name]) 42 popdef([NAME])
43 undefine([NAME]) 43 popdef([Name])
44]) 44])
45 45
46dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode) 46dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode)
@@ -57,9 +57,9 @@ AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
57[ 57[
58 AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) 58 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
59 AC_REQUIRE([AC_LIB_RPATH]) 59 AC_REQUIRE([AC_LIB_RPATH])
60 define([Name],[translit([$1],[./-], [___])]) 60 pushdef([Name],[translit([$1],[./-], [___])])
61 define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], 61 pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
62 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) 62 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
63 63
64 dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME 64 dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
65 dnl accordingly. 65 dnl accordingly.
@@ -95,8 +95,8 @@ AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
95 AC_SUBST([LIB]NAME) 95 AC_SUBST([LIB]NAME)
96 AC_SUBST([LTLIB]NAME) 96 AC_SUBST([LTLIB]NAME)
97 AC_SUBST([LIB]NAME[_PREFIX]) 97 AC_SUBST([LIB]NAME[_PREFIX])
98 undefine([Name]) 98 popdef([NAME])
99 undefine([NAME]) 99 popdef([Name])
100]) 100])
101 101
102dnl Determine the platform dependent parameters needed to use rpath: 102dnl Determine the platform dependent parameters needed to use rpath:
@@ -114,7 +114,7 @@ AC_DEFUN([AC_LIB_RPATH],
114 AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld 114 AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld
115 AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host 115 AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host
116 AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir 116 AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
117 AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [ 117 AC_CACHE_CHECK([for shared library run path origin], [acl_cv_rpath], [
118 CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ 118 CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
119 ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh 119 ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
120 . ./conftest.sh 120 . ./conftest.sh
@@ -131,11 +131,32 @@ AC_DEFUN([AC_LIB_RPATH],
131 acl_hardcode_direct="$acl_cv_hardcode_direct" 131 acl_hardcode_direct="$acl_cv_hardcode_direct"
132 acl_hardcode_minus_L="$acl_cv_hardcode_minus_L" 132 acl_hardcode_minus_L="$acl_cv_hardcode_minus_L"
133 dnl Determine whether the user wants rpath handling at all. 133 dnl Determine whether the user wants rpath handling at all.
134 AC_ARG_ENABLE(rpath, 134 AC_ARG_ENABLE([rpath],
135 [ --disable-rpath do not hardcode runtime library paths], 135 [ --disable-rpath do not hardcode runtime library paths],
136 :, enable_rpath=yes) 136 :, enable_rpath=yes)
137]) 137])
138 138
139dnl AC_LIB_FROMPACKAGE(name, package)
140dnl declares that libname comes from the given package. The configure file
141dnl will then not have a --with-libname-prefix option but a
142dnl --with-package-prefix option. Several libraries can come from the same
143dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar
144dnl macro call that searches for libname.
145AC_DEFUN([AC_LIB_FROMPACKAGE],
146[
147 pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
148 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
149 define([acl_frompackage_]NAME, [$2])
150 popdef([NAME])
151 pushdef([PACK],[$2])
152 pushdef([PACKUP],[translit(PACK,[abcdefghijklmnopqrstuvwxyz./-],
153 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
154 define([acl_libsinpackage_]PACKUP,
155 m4_ifdef([acl_libsinpackage_]PACKUP, [acl_libsinpackage_]PACKUP[[, ]],)[lib$1])
156 popdef([PACKUP])
157 popdef([PACK])
158])
159
139dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and 160dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
140dnl the libraries corresponding to explicit and implicit dependencies. 161dnl the libraries corresponding to explicit and implicit dependencies.
141dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables. 162dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
@@ -144,19 +165,23 @@ dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
144AC_DEFUN([AC_LIB_LINKFLAGS_BODY], 165AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
145[ 166[
146 AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) 167 AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
147 define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], 168 pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
148 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) 169 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
170 pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])])
171 pushdef([PACKUP],[translit(PACK,[abcdefghijklmnopqrstuvwxyz./-],
172 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
173 pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])])
149 dnl Autoconf >= 2.61 supports dots in --with options. 174 dnl Autoconf >= 2.61 supports dots in --with options.
150 define([N_A_M_E],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[translit([$1],[.],[_])],[$1])]) 175 pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[translit(PACK,[.],[_])],PACK)])
151 dnl By default, look in $includedir and $libdir. 176 dnl By default, look in $includedir and $libdir.
152 use_additional=yes 177 use_additional=yes
153 AC_LIB_WITH_FINAL_PREFIX([ 178 AC_LIB_WITH_FINAL_PREFIX([
154 eval additional_includedir=\"$includedir\" 179 eval additional_includedir=\"$includedir\"
155 eval additional_libdir=\"$libdir\" 180 eval additional_libdir=\"$libdir\"
156 ]) 181 ])
157 AC_LIB_ARG_WITH([lib]N_A_M_E[-prefix], 182 AC_ARG_WITH(P_A_C_K[-prefix],
158[ --with-lib]N_A_M_E[-prefix[=DIR] search for lib$1 in DIR/include and DIR/lib 183[[ --with-]]P_A_C_K[[-prefix[=DIR] search for ]PACKLIBS[ in DIR/include and DIR/lib
159 --without-lib]N_A_M_E[-prefix don't search for lib$1 in includedir and libdir], 184 --without-]]P_A_C_K[[-prefix don't search for ]PACKLIBS[ in includedir and libdir]],
160[ 185[
161 if test "X$withval" = "Xno"; then 186 if test "X$withval" = "Xno"; then
162 use_additional=no 187 use_additional=no
@@ -169,6 +194,10 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
169 else 194 else
170 additional_includedir="$withval/include" 195 additional_includedir="$withval/include"
171 additional_libdir="$withval/$acl_libdirstem" 196 additional_libdir="$withval/$acl_libdirstem"
197 if test "$acl_libdirstem2" != "$acl_libdirstem" \
198 && ! test -d "$withval/$acl_libdirstem"; then
199 additional_libdir="$withval/$acl_libdirstem2"
200 fi
172 fi 201 fi
173 fi 202 fi
174]) 203])
@@ -327,7 +356,9 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
327 dnl Linking with a shared library. We attempt to hardcode its 356 dnl Linking with a shared library. We attempt to hardcode its
328 dnl directory into the executable's runpath, unless it's the 357 dnl directory into the executable's runpath, unless it's the
329 dnl standard /usr/lib. 358 dnl standard /usr/lib.
330 if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/$acl_libdirstem"; then 359 if test "$enable_rpath" = no \
360 || test "X$found_dir" = "X/usr/$acl_libdirstem" \
361 || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then
331 dnl No hardcoding is needed. 362 dnl No hardcoding is needed.
332 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" 363 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
333 else 364 else
@@ -415,7 +446,16 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
415 case "$found_dir" in 446 case "$found_dir" in
416 */$acl_libdirstem | */$acl_libdirstem/) 447 */$acl_libdirstem | */$acl_libdirstem/)
417 basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` 448 basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'`
418 LIB[]NAME[]_PREFIX="$basedir" 449 if test "$name" = '$1'; then
450 LIB[]NAME[]_PREFIX="$basedir"
451 fi
452 additional_includedir="$basedir/include"
453 ;;
454 */$acl_libdirstem2 | */$acl_libdirstem2/)
455 basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'`
456 if test "$name" = '$1'; then
457 LIB[]NAME[]_PREFIX="$basedir"
458 fi
419 additional_includedir="$basedir/include" 459 additional_includedir="$basedir/include"
420 ;; 460 ;;
421 esac 461 esac
@@ -476,9 +516,11 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
476 dnl 3. if it's already present in $LDFLAGS or the already 516 dnl 3. if it's already present in $LDFLAGS or the already
477 dnl constructed $LIBNAME, 517 dnl constructed $LIBNAME,
478 dnl 4. if it doesn't exist as a directory. 518 dnl 4. if it doesn't exist as a directory.
479 if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then 519 if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \
520 && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then
480 haveit= 521 haveit=
481 if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then 522 if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \
523 || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then
482 if test -n "$GCC"; then 524 if test -n "$GCC"; then
483 case $host_os in 525 case $host_os in
484 linux* | gnu* | k*bsd*-gnu) haveit=yes;; 526 linux* | gnu* | k*bsd*-gnu) haveit=yes;;
@@ -609,6 +651,11 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
609 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir" 651 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
610 done 652 done
611 fi 653 fi
654 popdef([P_A_C_K])
655 popdef([PACKLIBS])
656 popdef([PACKUP])
657 popdef([PACK])
658 popdef([NAME])
612]) 659])
613 660
614dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR, 661dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
@@ -654,7 +701,8 @@ AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
654 if test -n "$next"; then 701 if test -n "$next"; then
655 dir="$next" 702 dir="$next"
656 dnl No need to hardcode the standard /usr/lib. 703 dnl No need to hardcode the standard /usr/lib.
657 if test "X$dir" != "X/usr/$acl_libdirstem"; then 704 if test "X$dir" != "X/usr/$acl_libdirstem" \
705 && test "X$dir" != "X/usr/$acl_libdirstem2"; then
658 rpathdirs="$rpathdirs $dir" 706 rpathdirs="$rpathdirs $dir"
659 fi 707 fi
660 next= 708 next=
@@ -663,7 +711,8 @@ AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
663 -L) next=yes ;; 711 -L) next=yes ;;
664 -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'` 712 -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'`
665 dnl No need to hardcode the standard /usr/lib. 713 dnl No need to hardcode the standard /usr/lib.
666 if test "X$dir" != "X/usr/$acl_libdirstem"; then 714 if test "X$dir" != "X/usr/$acl_libdirstem" \
715 && test "X$dir" != "X/usr/$acl_libdirstem2"; then
667 rpathdirs="$rpathdirs $dir" 716 rpathdirs="$rpathdirs $dir"
668 fi 717 fi
669 next= ;; 718 next= ;;
diff --git a/gl/m4/lib-prefix.m4 b/gl/m4/lib-prefix.m4
index a8684e1..3bdc0fc 100644
--- a/gl/m4/lib-prefix.m4
+++ b/gl/m4/lib-prefix.m4
@@ -1,5 +1,5 @@
1# lib-prefix.m4 serial 5 (gettext-0.15) 1# lib-prefix.m4 serial 6 (gettext-0.18)
2dnl Copyright (C) 2001-2005 Free Software Foundation, Inc. 2dnl Copyright (C) 2001-2005, 2008 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -153,33 +153,69 @@ AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX],
153 prefix="$acl_save_prefix" 153 prefix="$acl_save_prefix"
154]) 154])
155 155
156dnl AC_LIB_PREPARE_MULTILIB creates a variable acl_libdirstem, containing 156dnl AC_LIB_PREPARE_MULTILIB creates
157dnl the basename of the libdir, either "lib" or "lib64". 157dnl - a variable acl_libdirstem, containing the basename of the libdir, either
158dnl "lib" or "lib64" or "lib/64",
159dnl - a variable acl_libdirstem2, as a secondary possible value for
160dnl acl_libdirstem, either the same as acl_libdirstem or "lib/sparcv9" or
161dnl "lib/amd64".
158AC_DEFUN([AC_LIB_PREPARE_MULTILIB], 162AC_DEFUN([AC_LIB_PREPARE_MULTILIB],
159[ 163[
160 dnl There is no formal standard regarding lib and lib64. The current 164 dnl There is no formal standard regarding lib and lib64.
161 dnl practice is that on a system supporting 32-bit and 64-bit instruction 165 dnl On glibc systems, the current practice is that on a system supporting
162 dnl sets or ABIs, 64-bit libraries go under $prefix/lib64 and 32-bit 166 dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under
163 dnl libraries go under $prefix/lib. We determine the compiler's default 167 dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. We determine
164 dnl mode by looking at the compiler's library search path. If at least 168 dnl the compiler's default mode by looking at the compiler's library search
165 dnl of its elements ends in /lib64 or points to a directory whose absolute 169 dnl path. If at least one of its elements ends in /lib64 or points to a
166 dnl pathname ends in /lib64, we assume a 64-bit ABI. Otherwise we use the 170 dnl directory whose absolute pathname ends in /lib64, we assume a 64-bit ABI.
167 dnl default, namely "lib". 171 dnl Otherwise we use the default, namely "lib".
172 dnl On Solaris systems, the current practice is that on a system supporting
173 dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under
174 dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or
175 dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib.
176 AC_REQUIRE([AC_CANONICAL_HOST])
168 acl_libdirstem=lib 177 acl_libdirstem=lib
169 searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` 178 acl_libdirstem2=
170 if test -n "$searchpath"; then 179 case "$host_os" in
171 acl_save_IFS="${IFS= }"; IFS=":" 180 solaris*)
172 for searchdir in $searchpath; do 181 dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment
173 if test -d "$searchdir"; then 182 dnl <http://docs.sun.com/app/docs/doc/816-5138/dev-env?l=en&a=view>.
174 case "$searchdir" in 183 dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link."
175 */lib64/ | */lib64 ) acl_libdirstem=lib64 ;; 184 dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the
176 *) searchdir=`cd "$searchdir" && pwd` 185 dnl symlink is missing, so we set acl_libdirstem2 too.
177 case "$searchdir" in 186 AC_CACHE_CHECK([for 64-bit host], [gl_cv_solaris_64bit],
178 */lib64 ) acl_libdirstem=lib64 ;; 187 [AC_EGREP_CPP([sixtyfour bits], [
179 esac ;; 188#ifdef _LP64
189sixtyfour bits
190#endif
191 ], [gl_cv_solaris_64bit=yes], [gl_cv_solaris_64bit=no])
192 ])
193 if test $gl_cv_solaris_64bit = yes; then
194 acl_libdirstem=lib/64
195 case "$host_cpu" in
196 sparc*) acl_libdirstem2=lib/sparcv9 ;;
197 i*86 | x86_64) acl_libdirstem2=lib/amd64 ;;
180 esac 198 esac
181 fi 199 fi
182 done 200 ;;
183 IFS="$acl_save_IFS" 201 *)
184 fi 202 searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'`
203 if test -n "$searchpath"; then
204 acl_save_IFS="${IFS= }"; IFS=":"
205 for searchdir in $searchpath; do
206 if test -d "$searchdir"; then
207 case "$searchdir" in
208 */lib64/ | */lib64 ) acl_libdirstem=lib64 ;;
209 *) searchdir=`cd "$searchdir" && pwd`
210 case "$searchdir" in
211 */lib64 ) acl_libdirstem=lib64 ;;
212 esac ;;
213 esac
214 fi
215 done
216 IFS="$acl_save_IFS"
217 fi
218 ;;
219 esac
220 test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem"
185]) 221])
diff --git a/gl/m4/localcharset.m4 b/gl/m4/localcharset.m4
index b2b7733..e960104 100644
--- a/gl/m4/localcharset.m4
+++ b/gl/m4/localcharset.m4
@@ -1,5 +1,5 @@
1# localcharset.m4 serial 5 1# localcharset.m4 serial 6
2dnl Copyright (C) 2002, 2004, 2006 Free Software Foundation, Inc. 2dnl Copyright (C) 2002, 2004, 2006, 2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -8,7 +8,7 @@ AC_DEFUN([gl_LOCALCHARSET],
8[ 8[
9 dnl Prerequisites of lib/localcharset.c. 9 dnl Prerequisites of lib/localcharset.c.
10 AC_REQUIRE([AM_LANGINFO_CODESET]) 10 AC_REQUIRE([AM_LANGINFO_CODESET])
11 AC_CHECK_DECLS_ONCE(getc_unlocked) 11 AC_CHECK_DECLS_ONCE([getc_unlocked])
12 12
13 dnl Prerequisites of the lib/Makefile.am snippet. 13 dnl Prerequisites of the lib/Makefile.am snippet.
14 AC_REQUIRE([AC_CANONICAL_HOST]) 14 AC_REQUIRE([AC_CANONICAL_HOST])
diff --git a/gl/m4/locale-fr.m4 b/gl/m4/locale-fr.m4
new file mode 100644
index 0000000..e471839
--- /dev/null
+++ b/gl/m4/locale-fr.m4
@@ -0,0 +1,204 @@
1# locale-fr.m4 serial 10
2dnl Copyright (C) 2003, 2005-2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8
9dnl Determine the name of a french locale with traditional encoding.
10AC_DEFUN([gt_LOCALE_FR],
11[
12 AC_REQUIRE([AC_CANONICAL_HOST])
13 AC_REQUIRE([AM_LANGINFO_CODESET])
14 AC_CACHE_CHECK([for a traditional french locale], [gt_cv_locale_fr], [
15 macosx=
16changequote(,)dnl
17 case "$host_os" in
18 darwin[56]*) ;;
19 darwin*) macosx=yes;;
20 esac
21changequote([,])dnl
22 if test -n "$macosx"; then
23 # On Darwin 7 (MacOS X), the libc supports some locales in non-UTF-8
24 # encodings, but the kernel does not support them. The documentation
25 # says:
26 # "... all code that calls BSD system routines should ensure
27 # that the const *char parameters of these routines are in UTF-8
28 # encoding. All BSD system functions expect their string
29 # parameters to be in UTF-8 encoding and nothing else."
30 # See the comments in config.charset. Therefore we bypass the test.
31 gt_cv_locale_fr=none
32 else
33 AC_LANG_CONFTEST([AC_LANG_SOURCE([
34changequote(,)dnl
35#include <locale.h>
36#include <time.h>
37#if HAVE_LANGINFO_CODESET
38# include <langinfo.h>
39#endif
40#include <stdlib.h>
41#include <string.h>
42struct tm t;
43char buf[16];
44int main () {
45 /* Check whether the given locale name is recognized by the system. */
46 if (setlocale (LC_ALL, "") == NULL) return 1;
47 /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
48 On MacOS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
49 is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
50 On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
51 succeeds but then nl_langinfo(CODESET) is "646". In this situation,
52 some unit tests fail. */
53#if HAVE_LANGINFO_CODESET
54 {
55 const char *cs = nl_langinfo (CODESET);
56 if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0)
57 return 1;
58 }
59#endif
60#ifdef __CYGWIN__
61 /* On Cygwin, avoid locale names without encoding suffix, because the
62 locale_charset() function relies on the encoding suffix. Note that
63 LC_ALL is set on the command line. */
64 if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
65#endif
66 /* Check whether in the abbreviation of the second month, the second
67 character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is only
68 one byte long. This excludes the UTF-8 encoding. */
69 t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
70 if (strftime (buf, sizeof (buf), "%b", &t) < 3 || buf[2] != 'v') return 1;
71 /* Check whether the decimal separator is a comma.
72 On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
73 are nl_langinfo(RADIXCHAR) are both ".". */
74 if (localeconv () ->decimal_point[0] != ',') return 1;
75 return 0;
76}
77changequote([,])dnl
78 ])])
79 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
80 # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
81 # otherwise on MacOS X 10.3.5 the LC_TIME=C from the beginning of the
82 # configure script would override the LC_ALL setting. Likewise for
83 # LC_CTYPE, which is also set at the beginning of the configure script.
84 # Test for the usual locale name.
85 if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
86 gt_cv_locale_fr=fr_FR
87 else
88 # Test for the locale name with explicit encoding suffix.
89 if (LC_ALL=fr_FR.ISO-8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
90 gt_cv_locale_fr=fr_FR.ISO-8859-1
91 else
92 # Test for the AIX, OSF/1, FreeBSD, NetBSD, OpenBSD locale name.
93 if (LC_ALL=fr_FR.ISO8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
94 gt_cv_locale_fr=fr_FR.ISO8859-1
95 else
96 # Test for the HP-UX locale name.
97 if (LC_ALL=fr_FR.iso88591 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
98 gt_cv_locale_fr=fr_FR.iso88591
99 else
100 # Test for the Solaris 7 locale name.
101 if (LC_ALL=fr LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
102 gt_cv_locale_fr=fr
103 else
104 # None found.
105 gt_cv_locale_fr=none
106 fi
107 fi
108 fi
109 fi
110 fi
111 fi
112 rm -fr conftest*
113 fi
114 ])
115 LOCALE_FR=$gt_cv_locale_fr
116 AC_SUBST([LOCALE_FR])
117])
118
119dnl Determine the name of a french locale with UTF-8 encoding.
120AC_DEFUN([gt_LOCALE_FR_UTF8],
121[
122 AC_REQUIRE([AM_LANGINFO_CODESET])
123 AC_CACHE_CHECK([for a french Unicode locale], [gt_cv_locale_fr_utf8], [
124 AC_LANG_CONFTEST([AC_LANG_SOURCE([
125changequote(,)dnl
126#include <locale.h>
127#include <time.h>
128#if HAVE_LANGINFO_CODESET
129# include <langinfo.h>
130#endif
131#include <stdlib.h>
132#include <string.h>
133struct tm t;
134char buf[16];
135int main () {
136 /* On BeOS and Haiku, locales are not implemented in libc. Rather, libintl
137 imitates locale dependent behaviour by looking at the environment
138 variables, and all locales use the UTF-8 encoding. */
139#if !(defined __BEOS__ || defined __HAIKU__)
140 /* Check whether the given locale name is recognized by the system. */
141 if (setlocale (LC_ALL, "") == NULL) return 1;
142 /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
143 On MacOS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
144 is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
145 On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
146 succeeds but then nl_langinfo(CODESET) is "646". In this situation,
147 some unit tests fail. */
148# if HAVE_LANGINFO_CODESET
149 {
150 const char *cs = nl_langinfo (CODESET);
151 if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0)
152 return 1;
153 }
154# endif
155# ifdef __CYGWIN__
156 /* On Cygwin, avoid locale names without encoding suffix, because the
157 locale_charset() function relies on the encoding suffix. Note that
158 LC_ALL is set on the command line. */
159 if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
160# endif
161 /* Check whether in the abbreviation of the second month, the second
162 character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is
163 two bytes long, with UTF-8 encoding. */
164 t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
165 if (strftime (buf, sizeof (buf), "%b", &t) < 4
166 || buf[1] != (char) 0xc3 || buf[2] != (char) 0xa9 || buf[3] != 'v')
167 return 1;
168#endif
169 /* Check whether the decimal separator is a comma.
170 On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
171 are nl_langinfo(RADIXCHAR) are both ".". */
172 if (localeconv () ->decimal_point[0] != ',') return 1;
173 return 0;
174}
175changequote([,])dnl
176 ])])
177 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
178 # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
179 # otherwise on MacOS X 10.3.5 the LC_TIME=C from the beginning of the
180 # configure script would override the LC_ALL setting. Likewise for
181 # LC_CTYPE, which is also set at the beginning of the configure script.
182 # Test for the usual locale name.
183 if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
184 gt_cv_locale_fr_utf8=fr_FR
185 else
186 # Test for the locale name with explicit encoding suffix.
187 if (LC_ALL=fr_FR.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
188 gt_cv_locale_fr_utf8=fr_FR.UTF-8
189 else
190 # Test for the Solaris 7 locale name.
191 if (LC_ALL=fr.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
192 gt_cv_locale_fr_utf8=fr.UTF-8
193 else
194 # None found.
195 gt_cv_locale_fr_utf8=none
196 fi
197 fi
198 fi
199 fi
200 rm -fr conftest*
201 ])
202 LOCALE_FR_UTF8=$gt_cv_locale_fr_utf8
203 AC_SUBST([LOCALE_FR_UTF8])
204])
diff --git a/gl/m4/locale-ja.m4 b/gl/m4/locale-ja.m4
new file mode 100644
index 0000000..c80c5af
--- /dev/null
+++ b/gl/m4/locale-ja.m4
@@ -0,0 +1,126 @@
1# locale-ja.m4 serial 6
2dnl Copyright (C) 2003, 2005-2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8
9dnl Determine the name of a japanese locale with EUC-JP encoding.
10AC_DEFUN([gt_LOCALE_JA],
11[
12 AC_REQUIRE([AC_CANONICAL_HOST])
13 AC_REQUIRE([AM_LANGINFO_CODESET])
14 AC_CACHE_CHECK([for a traditional japanese locale], [gt_cv_locale_ja], [
15 macosx=
16changequote(,)dnl
17 case "$host_os" in
18 darwin[56]*) ;;
19 darwin*) macosx=yes;;
20 esac
21changequote([,])dnl
22 if test -n "$macosx"; then
23 # On Darwin 7 (MacOS X), the libc supports some locales in non-UTF-8
24 # encodings, but the kernel does not support them. The documentation
25 # says:
26 # "... all code that calls BSD system routines should ensure
27 # that the const *char parameters of these routines are in UTF-8
28 # encoding. All BSD system functions expect their string
29 # parameters to be in UTF-8 encoding and nothing else."
30 # See the comments in config.charset. Therefore we bypass the test.
31 gt_cv_locale_ja=none
32 else
33 AC_LANG_CONFTEST([AC_LANG_SOURCE([
34changequote(,)dnl
35#include <locale.h>
36#include <time.h>
37#if HAVE_LANGINFO_CODESET
38# include <langinfo.h>
39#endif
40#include <stdlib.h>
41#include <string.h>
42struct tm t;
43char buf[16];
44int main ()
45{
46 const char *p;
47 /* Check whether the given locale name is recognized by the system. */
48 if (setlocale (LC_ALL, "") == NULL) return 1;
49 /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
50 On MacOS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
51 is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
52 On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
53 succeeds but then nl_langinfo(CODESET) is "646". In this situation,
54 some unit tests fail. */
55#if HAVE_LANGINFO_CODESET
56 {
57 const char *cs = nl_langinfo (CODESET);
58 if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0)
59 return 1;
60 }
61#endif
62#ifdef __CYGWIN__
63 /* On Cygwin, avoid locale names without encoding suffix, because the
64 locale_charset() function relies on the encoding suffix. Note that
65 LC_ALL is set on the command line. */
66 if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
67#endif
68 /* Check whether MB_CUR_MAX is > 1. This excludes the dysfunctional locales
69 on Cygwin 1.5.x. */
70 if (MB_CUR_MAX == 1)
71 return 1;
72 /* Check whether in a month name, no byte in the range 0x80..0x9F occurs.
73 This excludes the UTF-8 encoding. */
74 t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
75 if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1;
76 for (p = buf; *p != '\0'; p++)
77 if ((unsigned char) *p >= 0x80 && (unsigned char) *p < 0xa0)
78 return 1;
79 return 0;
80}
81changequote([,])dnl
82 ])])
83 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
84 # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
85 # otherwise on MacOS X 10.3.5 the LC_TIME=C from the beginning of the
86 # configure script would override the LC_ALL setting. Likewise for
87 # LC_CTYPE, which is also set at the beginning of the configure script.
88 # Test for the AIX locale name.
89 if (LC_ALL=ja_JP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
90 gt_cv_locale_ja=ja_JP
91 else
92 # Test for the locale name with explicit encoding suffix.
93 if (LC_ALL=ja_JP.EUC-JP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
94 gt_cv_locale_ja=ja_JP.EUC-JP
95 else
96 # Test for the HP-UX, OSF/1, NetBSD locale name.
97 if (LC_ALL=ja_JP.eucJP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
98 gt_cv_locale_ja=ja_JP.eucJP
99 else
100 # Test for the IRIX, FreeBSD locale name.
101 if (LC_ALL=ja_JP.EUC LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
102 gt_cv_locale_ja=ja_JP.EUC
103 else
104 # Test for the Solaris 7 locale name.
105 if (LC_ALL=ja LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
106 gt_cv_locale_ja=ja
107 else
108 # Special test for NetBSD 1.6.
109 if test -f /usr/share/locale/ja_JP.eucJP/LC_CTYPE; then
110 gt_cv_locale_ja=ja_JP.eucJP
111 else
112 # None found.
113 gt_cv_locale_ja=none
114 fi
115 fi
116 fi
117 fi
118 fi
119 fi
120 fi
121 rm -fr conftest*
122 fi
123 ])
124 LOCALE_JA=$gt_cv_locale_ja
125 AC_SUBST([LOCALE_JA])
126])
diff --git a/gl/m4/locale-zh.m4 b/gl/m4/locale-zh.m4
new file mode 100644
index 0000000..ba7f9c5
--- /dev/null
+++ b/gl/m4/locale-zh.m4
@@ -0,0 +1,111 @@
1# locale-zh.m4 serial 5
2dnl Copyright (C) 2003, 2005-2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8
9dnl Determine the name of a chinese locale with GB18030 encoding.
10AC_DEFUN([gt_LOCALE_ZH_CN],
11[
12 AC_REQUIRE([AC_CANONICAL_HOST])
13 AC_REQUIRE([AM_LANGINFO_CODESET])
14 AC_CACHE_CHECK([for a transitional chinese locale], [gt_cv_locale_zh_CN], [
15 macosx=
16changequote(,)dnl
17 case "$host_os" in
18 darwin[56]*) ;;
19 darwin*) macosx=yes;;
20 esac
21changequote([,])dnl
22 if test -n "$macosx"; then
23 # On Darwin 7 (MacOS X), the libc supports some locales in non-UTF-8
24 # encodings, but the kernel does not support them. The documentation
25 # says:
26 # "... all code that calls BSD system routines should ensure
27 # that the const *char parameters of these routines are in UTF-8
28 # encoding. All BSD system functions expect their string
29 # parameters to be in UTF-8 encoding and nothing else."
30 # See the comments in config.charset. Therefore we bypass the test.
31 gt_cv_locale_zh_CN=none
32 else
33 AC_LANG_CONFTEST([AC_LANG_SOURCE([
34changequote(,)dnl
35#include <locale.h>
36#include <stdlib.h>
37#include <time.h>
38#if HAVE_LANGINFO_CODESET
39# include <langinfo.h>
40#endif
41#include <stdlib.h>
42#include <string.h>
43struct tm t;
44char buf[16];
45int main ()
46{
47 const char *p;
48 /* Check whether the given locale name is recognized by the system. */
49 if (setlocale (LC_ALL, "") == NULL) return 1;
50 /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
51 On MacOS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
52 is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
53 On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
54 succeeds but then nl_langinfo(CODESET) is "646". In this situation,
55 some unit tests fail. */
56#if HAVE_LANGINFO_CODESET
57 {
58 const char *cs = nl_langinfo (CODESET);
59 if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0)
60 return 1;
61 }
62#endif
63#ifdef __CYGWIN__
64 /* On Cygwin, avoid locale names without encoding suffix, because the
65 locale_charset() function relies on the encoding suffix. Note that
66 LC_ALL is set on the command line. */
67 if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
68#endif
69 /* Check whether in a month name, no byte in the range 0x80..0x9F occurs.
70 This excludes the UTF-8 encoding. */
71 t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
72 if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1;
73 for (p = buf; *p != '\0'; p++)
74 if ((unsigned char) *p >= 0x80 && (unsigned char) *p < 0xa0)
75 return 1;
76 /* Check whether a typical GB18030 multibyte sequence is recognized as a
77 single wide character. This excludes the GB2312 and GBK encodings. */
78 if (mblen ("\203\062\332\066", 5) != 4)
79 return 1;
80 return 0;
81}
82changequote([,])dnl
83 ])])
84 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
85 # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
86 # otherwise on MacOS X 10.3.5 the LC_TIME=C from the beginning of the
87 # configure script would override the LC_ALL setting. Likewise for
88 # LC_CTYPE, which is also set at the beginning of the configure script.
89 # Test for the locale name without encoding suffix.
90 if (LC_ALL=zh_CN LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
91 gt_cv_locale_zh_CN=zh_CN
92 else
93 # Test for the locale name with explicit encoding suffix.
94 if (LC_ALL=zh_CN.GB18030 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
95 gt_cv_locale_zh_CN=zh_CN.GB18030
96 else
97 # None found.
98 gt_cv_locale_zh_CN=none
99 fi
100 fi
101 else
102 # If there was a link error, due to mblen(), the system is so old that
103 # it certainly doesn't have a chinese locale.
104 gt_cv_locale_zh_CN=none
105 fi
106 rm -fr conftest*
107 fi
108 ])
109 LOCALE_ZH_CN=$gt_cv_locale_zh_CN
110 AC_SUBST([LOCALE_ZH_CN])
111])
diff --git a/gl/m4/lock.m4 b/gl/m4/lock.m4
index 9111933..b416e31 100644
--- a/gl/m4/lock.m4
+++ b/gl/m4/lock.m4
@@ -1,259 +1,33 @@
1# lock.m4 serial 7 (gettext-0.17) 1# lock.m4 serial 10 (gettext-0.18)
2dnl Copyright (C) 2005-2007 Free Software Foundation, Inc. 2dnl Copyright (C) 2005-2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl From Bruno Haible. 7dnl From Bruno Haible.
8 8
9dnl Tests for a multithreading library to be used. 9AC_DEFUN([gl_LOCK],
10dnl Defines at most one of the macros USE_POSIX_THREADS, USE_SOLARIS_THREADS,
11dnl USE_PTH_THREADS, USE_WIN32_THREADS
12dnl Sets the variables LIBTHREAD and LTLIBTHREAD to the linker options for use
13dnl in a Makefile (LIBTHREAD for use without libtool, LTLIBTHREAD for use with
14dnl libtool).
15dnl Sets the variables LIBMULTITHREAD and LTLIBMULTITHREAD similarly, for
16dnl programs that really need multithread functionality. The difference
17dnl between LIBTHREAD and LIBMULTITHREAD is that on platforms supporting weak
18dnl symbols, typically LIBTHREAD="" whereas LIBMULTITHREAD="-lpthread".
19dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for
20dnl multithread-safe programs.
21
22AC_DEFUN([gl_LOCK_EARLY],
23[
24 AC_REQUIRE([gl_LOCK_EARLY_BODY])
25])
26
27dnl The guts of gl_LOCK_EARLY. Needs to be expanded only once.
28
29AC_DEFUN([gl_LOCK_EARLY_BODY],
30[
31 dnl Ordering constraints: This macro modifies CPPFLAGS in a way that
32 dnl influences the result of the autoconf tests that test for *_unlocked
33 dnl declarations, on AIX 5 at least. Therefore it must come early.
34 AC_BEFORE([$0], [gl_FUNC_GLIBC_UNLOCKED_IO])dnl
35 AC_BEFORE([$0], [gl_ARGP])dnl
36
37 AC_REQUIRE([AC_CANONICAL_HOST])
38 dnl _GNU_SOURCE is needed for pthread_rwlock_t on glibc systems.
39 dnl AC_USE_SYSTEM_EXTENSIONS was introduced in autoconf 2.60 and obsoletes
40 dnl AC_GNU_SOURCE.
41 m4_ifdef([AC_USE_SYSTEM_EXTENSIONS],
42 [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])],
43 [AC_REQUIRE([AC_GNU_SOURCE])])
44 dnl Check for multithreading.
45 AC_ARG_ENABLE(threads,
46AC_HELP_STRING([--enable-threads={posix|solaris|pth|win32}], [specify multithreading API])
47AC_HELP_STRING([--disable-threads], [build without multithread safety]),
48 [gl_use_threads=$enableval],
49 [case "$host_os" in
50 dnl Disable multithreading by default on OSF/1, because it interferes
51 dnl with fork()/exec(): When msgexec is linked with -lpthread, its child
52 dnl process gets an endless segmentation fault inside execvp().
53 osf*) gl_use_threads=no ;;
54 *) gl_use_threads=yes ;;
55 esac
56 ])
57 if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then
58 # For using <pthread.h>:
59 case "$host_os" in
60 osf*)
61 # On OSF/1, the compiler needs the flag -D_REENTRANT so that it
62 # groks <pthread.h>. cc also understands the flag -pthread, but
63 # we don't use it because 1. gcc-2.95 doesn't understand -pthread,
64 # 2. putting a flag into CPPFLAGS that has an effect on the linker
65 # causes the AC_TRY_LINK test below to succeed unexpectedly,
66 # leading to wrong values of LIBTHREAD and LTLIBTHREAD.
67 CPPFLAGS="$CPPFLAGS -D_REENTRANT"
68 ;;
69 esac
70 # Some systems optimize for single-threaded programs by default, and
71 # need special flags to disable these optimizations. For example, the
72 # definition of 'errno' in <errno.h>.
73 case "$host_os" in
74 aix* | freebsd*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;;
75 solaris*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;;
76 esac
77 fi
78])
79
80dnl The guts of gl_LOCK. Needs to be expanded only once.
81
82AC_DEFUN([gl_LOCK_BODY],
83[ 10[
84 AC_REQUIRE([gl_LOCK_EARLY_BODY]) 11 AC_REQUIRE([gl_THREADLIB])
85 gl_threads_api=none 12 if test "$gl_threads_api" = posix; then
86 LIBTHREAD= 13 # OSF/1 4.0 and MacOS X 10.1 lack the pthread_rwlock_t type and the
87 LTLIBTHREAD= 14 # pthread_rwlock_* functions.
88 LIBMULTITHREAD= 15 AC_CHECK_TYPE([pthread_rwlock_t],
89 LTLIBMULTITHREAD= 16 [AC_DEFINE([HAVE_PTHREAD_RWLOCK], [1],
90 if test "$gl_use_threads" != no; then 17 [Define if the POSIX multithreading library has read/write locks.])],
91 dnl Check whether the compiler and linker support weak declarations. 18 [],
92 AC_MSG_CHECKING([whether imported symbols can be declared weak]) 19 [#include <pthread.h>])
93 gl_have_weak=no 20 # glibc defines PTHREAD_MUTEX_RECURSIVE as enum, not as a macro.
94 AC_TRY_LINK([extern void xyzzy (); 21 AC_TRY_COMPILE([#include <pthread.h>],
95#pragma weak xyzzy], [xyzzy();], [gl_have_weak=yes]) 22 [#if __FreeBSD__ == 4
96 AC_MSG_RESULT([$gl_have_weak])
97 if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then
98 # On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that
99 # it groks <pthread.h>. It's added above, in gl_LOCK_EARLY_BODY.
100 AC_CHECK_HEADER(pthread.h, gl_have_pthread_h=yes, gl_have_pthread_h=no)
101 if test "$gl_have_pthread_h" = yes; then
102 # Other possible tests:
103 # -lpthreads (FSU threads, PCthreads)
104 # -lgthreads
105 gl_have_pthread=
106 # Test whether both pthread_mutex_lock and pthread_mutexattr_init exist
107 # in libc. IRIX 6.5 has the first one in both libc and libpthread, but
108 # the second one only in libpthread, and lock.c needs it.
109 AC_TRY_LINK([#include <pthread.h>],
110 [pthread_mutex_lock((pthread_mutex_t*)0);
111 pthread_mutexattr_init((pthread_mutexattr_t*)0);],
112 [gl_have_pthread=yes])
113 # Test for libpthread by looking for pthread_kill. (Not pthread_self,
114 # since it is defined as a macro on OSF/1.)
115 if test -n "$gl_have_pthread"; then
116 # The program links fine without libpthread. But it may actually
117 # need to link with libpthread in order to create multiple threads.
118 AC_CHECK_LIB(pthread, pthread_kill,
119 [LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread
120 # On Solaris and HP-UX, most pthread functions exist also in libc.
121 # Therefore pthread_in_use() needs to actually try to create a
122 # thread: pthread_create from libc will fail, whereas
123 # pthread_create will actually create a thread.
124 case "$host_os" in
125 solaris* | hpux*)
126 AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], 1,
127 [Define if the pthread_in_use() detection is hard.])
128 esac
129 ])
130 else
131 # Some library is needed. Try libpthread and libc_r.
132 AC_CHECK_LIB(pthread, pthread_kill,
133 [gl_have_pthread=yes
134 LIBTHREAD=-lpthread LTLIBTHREAD=-lpthread
135 LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread])
136 if test -z "$gl_have_pthread"; then
137 # For FreeBSD 4.
138 AC_CHECK_LIB(c_r, pthread_kill,
139 [gl_have_pthread=yes
140 LIBTHREAD=-lc_r LTLIBTHREAD=-lc_r
141 LIBMULTITHREAD=-lc_r LTLIBMULTITHREAD=-lc_r])
142 fi
143 fi
144 if test -n "$gl_have_pthread"; then
145 gl_threads_api=posix
146 AC_DEFINE([USE_POSIX_THREADS], 1,
147 [Define if the POSIX multithreading library can be used.])
148 if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then
149 if test $gl_have_weak = yes; then
150 AC_DEFINE([USE_POSIX_THREADS_WEAK], 1,
151 [Define if references to the POSIX multithreading library should be made weak.])
152 LIBTHREAD=
153 LTLIBTHREAD=
154 fi
155 fi
156 # OSF/1 4.0 and MacOS X 10.1 lack the pthread_rwlock_t type and the
157 # pthread_rwlock_* functions.
158 AC_CHECK_TYPE([pthread_rwlock_t],
159 [AC_DEFINE([HAVE_PTHREAD_RWLOCK], 1,
160 [Define if the POSIX multithreading library has read/write locks.])],
161 [],
162 [#include <pthread.h>])
163 # glibc defines PTHREAD_MUTEX_RECURSIVE as enum, not as a macro.
164 AC_TRY_COMPILE([#include <pthread.h>],
165 [#if __FreeBSD__ == 4
166error "No, in FreeBSD 4.0 recursive mutexes actually don't work." 23error "No, in FreeBSD 4.0 recursive mutexes actually don't work."
167#else 24#else
168int x = (int)PTHREAD_MUTEX_RECURSIVE; 25int x = (int)PTHREAD_MUTEX_RECURSIVE;
169return !x; 26return !x;
170#endif], 27#endif],
171 [AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE], 1, 28 [AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE], [1],
172 [Define if the <pthread.h> defines PTHREAD_MUTEX_RECURSIVE.])]) 29 [Define if the <pthread.h> defines PTHREAD_MUTEX_RECURSIVE.])])
173 fi
174 fi
175 fi
176 if test -z "$gl_have_pthread"; then
177 if test "$gl_use_threads" = yes || test "$gl_use_threads" = solaris; then
178 gl_have_solaristhread=
179 gl_save_LIBS="$LIBS"
180 LIBS="$LIBS -lthread"
181 AC_TRY_LINK([#include <thread.h>
182#include <synch.h>],
183 [thr_self();],
184 [gl_have_solaristhread=yes])
185 LIBS="$gl_save_LIBS"
186 if test -n "$gl_have_solaristhread"; then
187 gl_threads_api=solaris
188 LIBTHREAD=-lthread
189 LTLIBTHREAD=-lthread
190 LIBMULTITHREAD="$LIBTHREAD"
191 LTLIBMULTITHREAD="$LTLIBTHREAD"
192 AC_DEFINE([USE_SOLARIS_THREADS], 1,
193 [Define if the old Solaris multithreading library can be used.])
194 if test $gl_have_weak = yes; then
195 AC_DEFINE([USE_SOLARIS_THREADS_WEAK], 1,
196 [Define if references to the old Solaris multithreading library should be made weak.])
197 LIBTHREAD=
198 LTLIBTHREAD=
199 fi
200 fi
201 fi
202 fi
203 if test "$gl_use_threads" = pth; then
204 gl_save_CPPFLAGS="$CPPFLAGS"
205 AC_LIB_LINKFLAGS(pth)
206 gl_have_pth=
207 gl_save_LIBS="$LIBS"
208 LIBS="$LIBS -lpth"
209 AC_TRY_LINK([#include <pth.h>], [pth_self();], gl_have_pth=yes)
210 LIBS="$gl_save_LIBS"
211 if test -n "$gl_have_pth"; then
212 gl_threads_api=pth
213 LIBTHREAD="$LIBPTH"
214 LTLIBTHREAD="$LTLIBPTH"
215 LIBMULTITHREAD="$LIBTHREAD"
216 LTLIBMULTITHREAD="$LTLIBTHREAD"
217 AC_DEFINE([USE_PTH_THREADS], 1,
218 [Define if the GNU Pth multithreading library can be used.])
219 if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then
220 if test $gl_have_weak = yes; then
221 AC_DEFINE([USE_PTH_THREADS_WEAK], 1,
222 [Define if references to the GNU Pth multithreading library should be made weak.])
223 LIBTHREAD=
224 LTLIBTHREAD=
225 fi
226 fi
227 else
228 CPPFLAGS="$gl_save_CPPFLAGS"
229 fi
230 fi
231 if test -z "$gl_have_pthread"; then
232 if test "$gl_use_threads" = yes || test "$gl_use_threads" = win32; then
233 if { case "$host_os" in
234 mingw*) true;;
235 *) false;;
236 esac
237 }; then
238 gl_threads_api=win32
239 AC_DEFINE([USE_WIN32_THREADS], 1,
240 [Define if the Win32 multithreading API can be used.])
241 fi
242 fi
243 fi
244 fi 30 fi
245 AC_MSG_CHECKING([for multithread API to use])
246 AC_MSG_RESULT([$gl_threads_api])
247 AC_SUBST(LIBTHREAD)
248 AC_SUBST(LTLIBTHREAD)
249 AC_SUBST(LIBMULTITHREAD)
250 AC_SUBST(LTLIBMULTITHREAD)
251])
252
253AC_DEFUN([gl_LOCK],
254[
255 AC_REQUIRE([gl_LOCK_EARLY])
256 AC_REQUIRE([gl_LOCK_BODY])
257 gl_PREREQ_LOCK 31 gl_PREREQ_LOCK
258]) 32])
259 33
@@ -261,56 +35,3 @@ AC_DEFUN([gl_LOCK],
261AC_DEFUN([gl_PREREQ_LOCK], [ 35AC_DEFUN([gl_PREREQ_LOCK], [
262 AC_REQUIRE([AC_C_INLINE]) 36 AC_REQUIRE([AC_C_INLINE])
263]) 37])
264
265dnl Survey of platforms:
266dnl
267dnl Platform Available Compiler Supports test-lock
268dnl flavours option weak result
269dnl --------------- --------- --------- -------- ---------
270dnl Linux 2.4/glibc posix -lpthread Y OK
271dnl
272dnl GNU Hurd/glibc posix
273dnl
274dnl FreeBSD 5.3 posix -lc_r Y
275dnl posix -lkse ? Y
276dnl posix -lpthread ? Y
277dnl posix -lthr Y
278dnl
279dnl FreeBSD 5.2 posix -lc_r Y
280dnl posix -lkse Y
281dnl posix -lthr Y
282dnl
283dnl FreeBSD 4.0,4.10 posix -lc_r Y OK
284dnl
285dnl NetBSD 1.6 --
286dnl
287dnl OpenBSD 3.4 posix -lpthread Y OK
288dnl
289dnl MacOS X 10.[123] posix -lpthread Y OK
290dnl
291dnl Solaris 7,8,9 posix -lpthread Y Sol 7,8: 0.0; Sol 9: OK
292dnl solaris -lthread Y Sol 7,8: 0.0; Sol 9: OK
293dnl
294dnl HP-UX 11 posix -lpthread N (cc) OK
295dnl Y (gcc)
296dnl
297dnl IRIX 6.5 posix -lpthread Y 0.5
298dnl
299dnl AIX 4.3,5.1 posix -lpthread N AIX 4: 0.5; AIX 5: OK
300dnl
301dnl OSF/1 4.0,5.1 posix -pthread (cc) N OK
302dnl -lpthread (gcc) Y
303dnl
304dnl Cygwin posix -lpthread Y OK
305dnl
306dnl Any of the above pth -lpth 0.0
307dnl
308dnl Mingw win32 N OK
309dnl
310dnl BeOS 5 --
311dnl
312dnl The test-lock result shows what happens if in test-lock.c EXPLICIT_YIELD is
313dnl turned off:
314dnl OK if all three tests terminate OK,
315dnl 0.5 if the first test terminates OK but the second one loops endlessly,
316dnl 0.0 if the first test already loops endlessly.
diff --git a/gl/m4/longlong.m4 b/gl/m4/longlong.m4
index 15bf9da..eedc8d5 100644
--- a/gl/m4/longlong.m4
+++ b/gl/m4/longlong.m4
@@ -1,5 +1,5 @@
1# longlong.m4 serial 13 1# longlong.m4 serial 14
2dnl Copyright (C) 1999-2007 Free Software Foundation, Inc. 2dnl Copyright (C) 1999-2007, 2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -46,7 +46,7 @@ AC_DEFUN([AC_TYPE_LONG_LONG_INT],
46 [ac_cv_type_long_long_int=yes])], 46 [ac_cv_type_long_long_int=yes])],
47 [ac_cv_type_long_long_int=no])]) 47 [ac_cv_type_long_long_int=no])])
48 if test $ac_cv_type_long_long_int = yes; then 48 if test $ac_cv_type_long_long_int = yes; then
49 AC_DEFINE([HAVE_LONG_LONG_INT], 1, 49 AC_DEFINE([HAVE_LONG_LONG_INT], [1],
50 [Define to 1 if the system has the type `long long int'.]) 50 [Define to 1 if the system has the type `long long int'.])
51 fi 51 fi
52]) 52])
@@ -69,7 +69,7 @@ AC_DEFUN([AC_TYPE_UNSIGNED_LONG_LONG_INT],
69 [ac_cv_type_unsigned_long_long_int=yes], 69 [ac_cv_type_unsigned_long_long_int=yes],
70 [ac_cv_type_unsigned_long_long_int=no])]) 70 [ac_cv_type_unsigned_long_long_int=no])])
71 if test $ac_cv_type_unsigned_long_long_int = yes; then 71 if test $ac_cv_type_unsigned_long_long_int = yes; then
72 AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], 1, 72 AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], [1],
73 [Define to 1 if the system has the type `unsigned long long int'.]) 73 [Define to 1 if the system has the type `unsigned long long int'.])
74 fi 74 fi
75]) 75])
diff --git a/gl/m4/ls-mntd-fs.m4 b/gl/m4/ls-mntd-fs.m4
index 21ac4e7..32ccb98 100644
--- a/gl/m4/ls-mntd-fs.m4
+++ b/gl/m4/ls-mntd-fs.m4
@@ -1,8 +1,7 @@
1#serial 26 1# serial 27
2# How to list mounted file systems. 2# How to list mounted file systems.
3 3
4# Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006 Free Software 4# Copyright (C) 1998-2004, 2006, 2009 Free Software Foundation, Inc.
5# Foundation, Inc.
6# 5#
7# This file is free software; the Free Software Foundation 6# This file is free software; the Free Software Foundation
8# gives unlimited permission to copy and/or distribute it, 7# gives unlimited permission to copy and/or distribute it,
@@ -20,27 +19,27 @@ dnl
20AC_DEFUN([AC_FUNC_GETMNTENT], 19AC_DEFUN([AC_FUNC_GETMNTENT],
21[# getmntent is in the standard C library on UNICOS, in -lsun on Irix 4, 20[# getmntent is in the standard C library on UNICOS, in -lsun on Irix 4,
22# -lseq on Dynix/PTX, -lgen on Unixware. 21# -lseq on Dynix/PTX, -lgen on Unixware.
23AC_SEARCH_LIBS(getmntent, [sun seq gen]) 22AC_SEARCH_LIBS([getmntent], [sun seq gen])
24AC_CHECK_FUNCS(getmntent) 23AC_CHECK_FUNCS([getmntent])
25]) 24])
26 25
27# gl_LIST_MOUNTED_FILE_SYSTEMS([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) 26# gl_LIST_MOUNTED_FILE_SYSTEMS([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
28AC_DEFUN([gl_LIST_MOUNTED_FILE_SYSTEMS], 27AC_DEFUN([gl_LIST_MOUNTED_FILE_SYSTEMS],
29 [ 28 [
30AC_CHECK_FUNCS(listmntent getmntinfo) 29AC_CHECK_FUNCS([listmntent getmntinfo])
31AC_CHECK_HEADERS_ONCE(sys/param.h sys/statvfs.h) 30AC_CHECK_HEADERS_ONCE([sys/param.h sys/statvfs.h])
32 31
33# We must include grp.h before ucred.h on OSF V4.0, since ucred.h uses 32# We must include grp.h before ucred.h on OSF V4.0, since ucred.h uses
34# NGROUPS (as the array dimension for a struct member) without a definition. 33# NGROUPS (as the array dimension for a struct member) without a definition.
35AC_CHECK_HEADERS(sys/ucred.h, [], [], [#include <grp.h>]) 34AC_CHECK_HEADERS([sys/ucred.h], [], [], [#include <grp.h>])
36 35
37AC_CHECK_HEADERS(sys/mount.h, [], [], 36AC_CHECK_HEADERS([sys/mount.h], [], [],
38 [AC_INCLUDES_DEFAULT 37 [AC_INCLUDES_DEFAULT
39 [#if HAVE_SYS_PARAM_H 38 [#if HAVE_SYS_PARAM_H
40 #include <sys/param.h> 39 #include <sys/param.h>
41 #endif]]) 40 #endif]])
42 41
43AC_CHECK_HEADERS(mntent.h sys/fs_types.h) 42AC_CHECK_HEADERS([mntent.h sys/fs_types.h])
44 getfsstat_includes="\ 43 getfsstat_includes="\
45$ac_includes_default 44$ac_includes_default
46#if HAVE_SYS_PARAM_H 45#if HAVE_SYS_PARAM_H
@@ -78,9 +77,9 @@ AC_FUNC_GETMNTENT
78if test -z "$ac_list_mounted_fs"; then 77if test -z "$ac_list_mounted_fs"; then
79 # Cray UNICOS 9 78 # Cray UNICOS 9
80 AC_MSG_CHECKING([for listmntent of Cray/Unicos-9]) 79 AC_MSG_CHECKING([for listmntent of Cray/Unicos-9])
81 AC_CACHE_VAL(fu_cv_sys_mounted_cray_listmntent, 80 AC_CACHE_VAL([fu_cv_sys_mounted_cray_listmntent],
82 [fu_cv_sys_mounted_cray_listmntent=no 81 [fu_cv_sys_mounted_cray_listmntent=no
83 AC_EGREP_CPP(yes, 82 AC_EGREP_CPP([yes],
84 [#ifdef _CRAY 83 [#ifdef _CRAY
85yes 84yes
86#endif 85#endif
@@ -89,10 +88,10 @@ yes
89 ) 88 )
90 ] 89 ]
91 ) 90 )
92 AC_MSG_RESULT($fu_cv_sys_mounted_cray_listmntent) 91 AC_MSG_RESULT([$fu_cv_sys_mounted_cray_listmntent])
93 if test $fu_cv_sys_mounted_cray_listmntent = yes; then 92 if test $fu_cv_sys_mounted_cray_listmntent = yes; then
94 ac_list_mounted_fs=found 93 ac_list_mounted_fs=found
95 AC_DEFINE(MOUNTED_LISTMNTENT, 1, 94 AC_DEFINE([MOUNTED_LISTMNTENT], [1],
96 [Define if there is a function named listmntent that can be used to 95 [Define if there is a function named listmntent that can be used to
97 list all mounted file systems. (UNICOS)]) 96 list all mounted file systems. (UNICOS)])
98 fi 97 fi
@@ -101,14 +100,14 @@ fi
101if test -z "$ac_list_mounted_fs"; then 100if test -z "$ac_list_mounted_fs"; then
102 # AIX. 101 # AIX.
103 AC_MSG_CHECKING([for mntctl function and struct vmount]) 102 AC_MSG_CHECKING([for mntctl function and struct vmount])
104 AC_CACHE_VAL(fu_cv_sys_mounted_vmount, 103 AC_CACHE_VAL([fu_cv_sys_mounted_vmount],
105 [AC_TRY_CPP([#include <fshelp.h>], 104 [AC_TRY_CPP([#include <fshelp.h>],
106 fu_cv_sys_mounted_vmount=yes, 105 fu_cv_sys_mounted_vmount=yes,
107 fu_cv_sys_mounted_vmount=no)]) 106 fu_cv_sys_mounted_vmount=no)])
108 AC_MSG_RESULT($fu_cv_sys_mounted_vmount) 107 AC_MSG_RESULT([$fu_cv_sys_mounted_vmount])
109 if test $fu_cv_sys_mounted_vmount = yes; then 108 if test $fu_cv_sys_mounted_vmount = yes; then
110 ac_list_mounted_fs=found 109 ac_list_mounted_fs=found
111 AC_DEFINE(MOUNTED_VMOUNT, 1, 110 AC_DEFINE([MOUNTED_VMOUNT], [1],
112 [Define if there is a function named mntctl that can be used to read 111 [Define if there is a function named mntctl that can be used to read
113 the list of mounted file systems, and there is a system header file 112 the list of mounted file systems, and there is a system header file
114 that declares `struct vmount.' (AIX)]) 113 that declares `struct vmount.' (AIX)])
@@ -123,7 +122,7 @@ if test $ac_cv_func_getmntent = yes; then
123 if test -z "$ac_list_mounted_fs"; then 122 if test -z "$ac_list_mounted_fs"; then
124 # 4.3BSD, SunOS, HP-UX, Dynix, Irix 123 # 4.3BSD, SunOS, HP-UX, Dynix, Irix
125 AC_MSG_CHECKING([for one-argument getmntent function]) 124 AC_MSG_CHECKING([for one-argument getmntent function])
126 AC_CACHE_VAL(fu_cv_sys_mounted_getmntent1, 125 AC_CACHE_VAL([fu_cv_sys_mounted_getmntent1],
127 [AC_TRY_COMPILE([ 126 [AC_TRY_COMPILE([
128/* SunOS 4.1.x /usr/include/mntent.h needs this for FILE */ 127/* SunOS 4.1.x /usr/include/mntent.h needs this for FILE */
129#include <stdio.h> 128#include <stdio.h>
@@ -145,10 +144,10 @@ if test $ac_cv_func_getmntent = yes; then
145 if (sizeof mnt && sizeof table) return 0;], 144 if (sizeof mnt && sizeof table) return 0;],
146 fu_cv_sys_mounted_getmntent1=yes, 145 fu_cv_sys_mounted_getmntent1=yes,
147 fu_cv_sys_mounted_getmntent1=no)]) 146 fu_cv_sys_mounted_getmntent1=no)])
148 AC_MSG_RESULT($fu_cv_sys_mounted_getmntent1) 147 AC_MSG_RESULT([$fu_cv_sys_mounted_getmntent1])
149 if test $fu_cv_sys_mounted_getmntent1 = yes; then 148 if test $fu_cv_sys_mounted_getmntent1 = yes; then
150 ac_list_mounted_fs=found 149 ac_list_mounted_fs=found
151 AC_DEFINE(MOUNTED_GETMNTENT1, 1, 150 AC_DEFINE([MOUNTED_GETMNTENT1], [1],
152 [Define if there is a function named getmntent for reading the list 151 [Define if there is a function named getmntent for reading the list
153 of mounted file systems, and that function takes a single argument. 152 of mounted file systems, and that function takes a single argument.
154 (4.3BSD, SunOS, HP-UX, Dynix, Irix)]) 153 (4.3BSD, SunOS, HP-UX, Dynix, Irix)])
@@ -158,17 +157,17 @@ if test $ac_cv_func_getmntent = yes; then
158 if test -z "$ac_list_mounted_fs"; then 157 if test -z "$ac_list_mounted_fs"; then
159 # SVR4 158 # SVR4
160 AC_MSG_CHECKING([for two-argument getmntent function]) 159 AC_MSG_CHECKING([for two-argument getmntent function])
161 AC_CACHE_VAL(fu_cv_sys_mounted_getmntent2, 160 AC_CACHE_VAL([fu_cv_sys_mounted_getmntent2],
162 [AC_EGREP_HEADER(getmntent, sys/mnttab.h, 161 [AC_EGREP_HEADER([getmntent], [sys/mnttab.h],
163 fu_cv_sys_mounted_getmntent2=yes, 162 fu_cv_sys_mounted_getmntent2=yes,
164 fu_cv_sys_mounted_getmntent2=no)]) 163 fu_cv_sys_mounted_getmntent2=no)])
165 AC_MSG_RESULT($fu_cv_sys_mounted_getmntent2) 164 AC_MSG_RESULT([$fu_cv_sys_mounted_getmntent2])
166 if test $fu_cv_sys_mounted_getmntent2 = yes; then 165 if test $fu_cv_sys_mounted_getmntent2 = yes; then
167 ac_list_mounted_fs=found 166 ac_list_mounted_fs=found
168 AC_DEFINE(MOUNTED_GETMNTENT2, 1, 167 AC_DEFINE([MOUNTED_GETMNTENT2], [1],
169 [Define if there is a function named getmntent for reading the list of 168 [Define if there is a function named getmntent for reading the list of
170 mounted file systems, and that function takes two arguments. (SVR4)]) 169 mounted file systems, and that function takes two arguments. (SVR4)])
171 AC_CHECK_FUNCS(hasmntopt) 170 AC_CHECK_FUNCS([hasmntopt])
172 fi 171 fi
173 fi 172 fi
174 173
@@ -179,7 +178,7 @@ if test -z "$ac_list_mounted_fs"; then
179 # powerpc-apple-darwin1.3.7 needs sys/param.h sys/ucred.h sys/fs_types.h 178 # powerpc-apple-darwin1.3.7 needs sys/param.h sys/ucred.h sys/fs_types.h
180 179
181 AC_MSG_CHECKING([for getfsstat function]) 180 AC_MSG_CHECKING([for getfsstat function])
182 AC_CACHE_VAL(fu_cv_sys_mounted_getfsstat, 181 AC_CACHE_VAL([fu_cv_sys_mounted_getfsstat],
183 [AC_TRY_LINK([ 182 [AC_TRY_LINK([
184#include <sys/types.h> 183#include <sys/types.h>
185#if HAVE_STRUCT_FSSTAT_F_FSTYPENAME 184#if HAVE_STRUCT_FSSTAT_F_FSTYPENAME
@@ -194,10 +193,10 @@ if test -z "$ac_list_mounted_fs"; then
194 char *t = FS_TYPE (*stats); ], 193 char *t = FS_TYPE (*stats); ],
195 fu_cv_sys_mounted_getfsstat=yes, 194 fu_cv_sys_mounted_getfsstat=yes,
196 fu_cv_sys_mounted_getfsstat=no)]) 195 fu_cv_sys_mounted_getfsstat=no)])
197 AC_MSG_RESULT($fu_cv_sys_mounted_getfsstat) 196 AC_MSG_RESULT([$fu_cv_sys_mounted_getfsstat])
198 if test $fu_cv_sys_mounted_getfsstat = yes; then 197 if test $fu_cv_sys_mounted_getfsstat = yes; then
199 ac_list_mounted_fs=found 198 ac_list_mounted_fs=found
200 AC_DEFINE(MOUNTED_GETFSSTAT, 1, 199 AC_DEFINE([MOUNTED_GETFSSTAT], [1],
201 [Define if there is a function named getfsstat for reading the 200 [Define if there is a function named getfsstat for reading the
202 list of mounted file systems. (DEC Alpha running OSF/1)]) 201 list of mounted file systems. (DEC Alpha running OSF/1)])
203 fi 202 fi
@@ -206,17 +205,17 @@ fi
206if test -z "$ac_list_mounted_fs"; then 205if test -z "$ac_list_mounted_fs"; then
207 # SVR3 206 # SVR3
208 AC_MSG_CHECKING([for FIXME existence of three headers]) 207 AC_MSG_CHECKING([for FIXME existence of three headers])
209 AC_CACHE_VAL(fu_cv_sys_mounted_fread_fstyp, 208 AC_CACHE_VAL([fu_cv_sys_mounted_fread_fstyp],
210 [AC_TRY_CPP([ 209 [AC_TRY_CPP([
211#include <sys/statfs.h> 210#include <sys/statfs.h>
212#include <sys/fstyp.h> 211#include <sys/fstyp.h>
213#include <mnttab.h>], 212#include <mnttab.h>],
214 fu_cv_sys_mounted_fread_fstyp=yes, 213 fu_cv_sys_mounted_fread_fstyp=yes,
215 fu_cv_sys_mounted_fread_fstyp=no)]) 214 fu_cv_sys_mounted_fread_fstyp=no)])
216 AC_MSG_RESULT($fu_cv_sys_mounted_fread_fstyp) 215 AC_MSG_RESULT([$fu_cv_sys_mounted_fread_fstyp])
217 if test $fu_cv_sys_mounted_fread_fstyp = yes; then 216 if test $fu_cv_sys_mounted_fread_fstyp = yes; then
218 ac_list_mounted_fs=found 217 ac_list_mounted_fs=found
219 AC_DEFINE(MOUNTED_FREAD_FSTYP, 1, 218 AC_DEFINE([MOUNTED_FREAD_FSTYP], [1],
220 [Define if (like SVR2) there is no specific function for reading the 219 [Define if (like SVR2) there is no specific function for reading the
221 list of mounted file systems, and your system has these header files: 220 list of mounted file systems, and your system has these header files:
222 <sys/fstyp.h> and <sys/statfs.h>. (SVR3)]) 221 <sys/fstyp.h> and <sys/statfs.h>. (SVR3)])
@@ -226,16 +225,16 @@ fi
226if test -z "$ac_list_mounted_fs"; then 225if test -z "$ac_list_mounted_fs"; then
227 # 4.4BSD and DEC OSF/1. 226 # 4.4BSD and DEC OSF/1.
228 AC_MSG_CHECKING([for getmntinfo function]) 227 AC_MSG_CHECKING([for getmntinfo function])
229 AC_CACHE_VAL(fu_cv_sys_mounted_getmntinfo, 228 AC_CACHE_VAL([fu_cv_sys_mounted_getmntinfo],
230 [ 229 [
231 test "$ac_cv_func_getmntinfo" = yes \ 230 test "$ac_cv_func_getmntinfo" = yes \
232 && fu_cv_sys_mounted_getmntinfo=yes \ 231 && fu_cv_sys_mounted_getmntinfo=yes \
233 || fu_cv_sys_mounted_getmntinfo=no 232 || fu_cv_sys_mounted_getmntinfo=no
234 ]) 233 ])
235 AC_MSG_RESULT($fu_cv_sys_mounted_getmntinfo) 234 AC_MSG_RESULT([$fu_cv_sys_mounted_getmntinfo])
236 if test $fu_cv_sys_mounted_getmntinfo = yes; then 235 if test $fu_cv_sys_mounted_getmntinfo = yes; then
237 AC_MSG_CHECKING([whether getmntinfo returns statvfs structures]) 236 AC_MSG_CHECKING([whether getmntinfo returns statvfs structures])
238 AC_CACHE_VAL(fu_cv_sys_mounted_getmntinfo2, 237 AC_CACHE_VAL([fu_cv_sys_mounted_getmntinfo2],
239 [ 238 [
240 AC_TRY_COMPILE([ 239 AC_TRY_COMPILE([
241#if HAVE_SYS_PARAM_H 240#if HAVE_SYS_PARAM_H
@@ -256,13 +255,13 @@ extern int getmntinfo (struct statfs **, int);
256 AC_MSG_RESULT([$fu_cv_sys_mounted_getmntinfo2]) 255 AC_MSG_RESULT([$fu_cv_sys_mounted_getmntinfo2])
257 if test $fu_cv_sys_mounted_getmntinfo2 = no; then 256 if test $fu_cv_sys_mounted_getmntinfo2 = no; then
258 ac_list_mounted_fs=found 257 ac_list_mounted_fs=found
259 AC_DEFINE(MOUNTED_GETMNTINFO, 1, 258 AC_DEFINE([MOUNTED_GETMNTINFO], [1],
260 [Define if there is a function named getmntinfo for reading the 259 [Define if there is a function named getmntinfo for reading the
261 list of mounted file systems and it returns an array of 260 list of mounted file systems and it returns an array of
262 'struct statfs'. (4.4BSD, Darwin)]) 261 'struct statfs'. (4.4BSD, Darwin)])
263 else 262 else
264 ac_list_mounted_fs=found 263 ac_list_mounted_fs=found
265 AC_DEFINE(MOUNTED_GETMNTINFO2, 1, 264 AC_DEFINE([MOUNTED_GETMNTINFO2], [1],
266 [Define if there is a function named getmntinfo for reading the 265 [Define if there is a function named getmntinfo for reading the
267 list of mounted file systems and it returns an array of 266 list of mounted file systems and it returns an array of
268 'struct statvfs'. (NetBSD 3.0)]) 267 'struct statvfs'. (NetBSD 3.0)])
@@ -273,16 +272,16 @@ fi
273if test -z "$ac_list_mounted_fs"; then 272if test -z "$ac_list_mounted_fs"; then
274 # Ultrix 273 # Ultrix
275 AC_MSG_CHECKING([for getmnt function]) 274 AC_MSG_CHECKING([for getmnt function])
276 AC_CACHE_VAL(fu_cv_sys_mounted_getmnt, 275 AC_CACHE_VAL([fu_cv_sys_mounted_getmnt],
277 [AC_TRY_CPP([ 276 [AC_TRY_CPP([
278#include <sys/fs_types.h> 277#include <sys/fs_types.h>
279#include <sys/mount.h>], 278#include <sys/mount.h>],
280 fu_cv_sys_mounted_getmnt=yes, 279 fu_cv_sys_mounted_getmnt=yes,
281 fu_cv_sys_mounted_getmnt=no)]) 280 fu_cv_sys_mounted_getmnt=no)])
282 AC_MSG_RESULT($fu_cv_sys_mounted_getmnt) 281 AC_MSG_RESULT([$fu_cv_sys_mounted_getmnt])
283 if test $fu_cv_sys_mounted_getmnt = yes; then 282 if test $fu_cv_sys_mounted_getmnt = yes; then
284 ac_list_mounted_fs=found 283 ac_list_mounted_fs=found
285 AC_DEFINE(MOUNTED_GETMNT, 1, 284 AC_DEFINE([MOUNTED_GETMNT], [1],
286 [Define if there is a function named getmnt for reading the list of 285 [Define if there is a function named getmnt for reading the list of
287 mounted file systems. (Ultrix)]) 286 mounted file systems. (Ultrix)])
288 fi 287 fi
@@ -290,8 +289,8 @@ fi
290 289
291if test -z "$ac_list_mounted_fs"; then 290if test -z "$ac_list_mounted_fs"; then
292 # BeOS 291 # BeOS
293 AC_CHECK_FUNCS(next_dev fs_stat_dev) 292 AC_CHECK_FUNCS([next_dev fs_stat_dev])
294 AC_CHECK_HEADERS(fs_info.h) 293 AC_CHECK_HEADERS([fs_info.h])
295 AC_MSG_CHECKING([for BEOS mounted file system support functions]) 294 AC_MSG_CHECKING([for BEOS mounted file system support functions])
296 if test $ac_cv_header_fs_info_h = yes \ 295 if test $ac_cv_header_fs_info_h = yes \
297 && test $ac_cv_func_next_dev = yes \ 296 && test $ac_cv_func_next_dev = yes \
@@ -300,10 +299,10 @@ if test -z "$ac_list_mounted_fs"; then
300 else 299 else
301 fu_result=no 300 fu_result=no
302 fi 301 fi
303 AC_MSG_RESULT($fu_result) 302 AC_MSG_RESULT([$fu_result])
304 if test $fu_result = yes; then 303 if test $fu_result = yes; then
305 ac_list_mounted_fs=found 304 ac_list_mounted_fs=found
306 AC_DEFINE(MOUNTED_FS_STAT_DEV, 1, 305 AC_DEFINE([MOUNTED_FS_STAT_DEV], [1],
307 [Define if there are functions named next_dev and fs_stat_dev for 306 [Define if there are functions named next_dev and fs_stat_dev for
308 reading the list of mounted file systems. (BeOS)]) 307 reading the list of mounted file systems. (BeOS)])
309 fi 308 fi
@@ -312,14 +311,14 @@ fi
312if test -z "$ac_list_mounted_fs"; then 311if test -z "$ac_list_mounted_fs"; then
313 # SVR2 312 # SVR2
314 AC_MSG_CHECKING([whether it is possible to resort to fread on /etc/mnttab]) 313 AC_MSG_CHECKING([whether it is possible to resort to fread on /etc/mnttab])
315 AC_CACHE_VAL(fu_cv_sys_mounted_fread, 314 AC_CACHE_VAL([fu_cv_sys_mounted_fread],
316 [AC_TRY_CPP([#include <mnttab.h>], 315 [AC_TRY_CPP([#include <mnttab.h>],
317 fu_cv_sys_mounted_fread=yes, 316 fu_cv_sys_mounted_fread=yes,
318 fu_cv_sys_mounted_fread=no)]) 317 fu_cv_sys_mounted_fread=no)])
319 AC_MSG_RESULT($fu_cv_sys_mounted_fread) 318 AC_MSG_RESULT([$fu_cv_sys_mounted_fread])
320 if test $fu_cv_sys_mounted_fread = yes; then 319 if test $fu_cv_sys_mounted_fread = yes; then
321 ac_list_mounted_fs=found 320 ac_list_mounted_fs=found
322 AC_DEFINE(MOUNTED_FREAD, 1, 321 AC_DEFINE([MOUNTED_FREAD], [1],
323 [Define if there is no specific function for reading the list of 322 [Define if there is no specific function for reading the list of
324 mounted file systems. fread will be used to read /etc/mnttab. 323 mounted file systems. fread will be used to read /etc/mnttab.
325 (SVR2) ]) 324 (SVR2) ])
diff --git a/gl/m4/malloc.m4 b/gl/m4/malloc.m4
index 764f2a9..8070171 100644
--- a/gl/m4/malloc.m4
+++ b/gl/m4/malloc.m4
@@ -1,5 +1,5 @@
1# malloc.m4 serial 8 1# malloc.m4 serial 9
2dnl Copyright (C) 2007 Free Software Foundation, Inc. 2dnl Copyright (C) 2007, 2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -13,7 +13,7 @@ AC_DEFUN([gl_FUNC_MALLOC_POSIX],
13 AC_REQUIRE([gl_CHECK_MALLOC_POSIX]) 13 AC_REQUIRE([gl_CHECK_MALLOC_POSIX])
14 if test $gl_cv_func_malloc_posix = yes; then 14 if test $gl_cv_func_malloc_posix = yes; then
15 HAVE_MALLOC_POSIX=1 15 HAVE_MALLOC_POSIX=1
16 AC_DEFINE([HAVE_MALLOC_POSIX], 1, 16 AC_DEFINE([HAVE_MALLOC_POSIX], [1],
17 [Define if the 'malloc' function is POSIX compliant.]) 17 [Define if the 'malloc' function is POSIX compliant.])
18 else 18 else
19 AC_LIBOBJ([malloc]) 19 AC_LIBOBJ([malloc])
diff --git a/gl/m4/math_h.m4 b/gl/m4/math_h.m4
index dd99e7f..d941bc3 100644
--- a/gl/m4/math_h.m4
+++ b/gl/m4/math_h.m4
@@ -1,4 +1,4 @@
1# math_h.m4 serial 9 1# math_h.m4 serial 14
2dnl Copyright (C) 2007-2008 Free Software Foundation, Inc. 2dnl Copyright (C) 2007-2008 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
@@ -8,6 +8,31 @@ AC_DEFUN([gl_MATH_H],
8[ 8[
9 AC_REQUIRE([gl_MATH_H_DEFAULTS]) 9 AC_REQUIRE([gl_MATH_H_DEFAULTS])
10 gl_CHECK_NEXT_HEADERS([math.h]) 10 gl_CHECK_NEXT_HEADERS([math.h])
11 AC_CACHE_CHECK([whether NAN macro works], [gl_cv_header_math_nan_works],
12 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <math.h>]],
13 [[/* Solaris 10 has a broken definition of NAN. Other platforms
14 fail to provide NAN, or provide it only in C99 mode; this
15 test only needs to fail when NAN is provided but wrong. */
16 float f = 1.0f;
17#ifdef NAN
18 f = NAN;
19#endif
20 return f == 0;]])],
21 [gl_cv_header_math_nan_works=yes],
22 [gl_cv_header_math_nan_works=no])])
23 if test $gl_cv_header_math_nan_works = no; then
24 REPLACE_NAN=1
25 fi
26 AC_CACHE_CHECK([whether HUGE_VAL works], [gl_cv_header_math_huge_val_works],
27 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <math.h>]],
28 [[/* Solaris 10 has a broken definition of HUGE_VAL. */
29 double d = HUGE_VAL;
30 return d == 0;]])],
31 [gl_cv_header_math_huge_val_works=yes],
32 [gl_cv_header_math_huge_val_works=no])])
33 if test $gl_cv_header_math_huge_val_works = no; then
34 REPLACE_HUGE_VAL=1
35 fi
11]) 36])
12 37
13AC_DEFUN([gl_MATH_MODULE_INDICATOR], 38AC_DEFUN([gl_MATH_MODULE_INDICATOR],
@@ -26,6 +51,11 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
26 GNULIB_FREXP=0; AC_SUBST([GNULIB_FREXP]) 51 GNULIB_FREXP=0; AC_SUBST([GNULIB_FREXP])
27 GNULIB_FREXPL=0; AC_SUBST([GNULIB_FREXPL]) 52 GNULIB_FREXPL=0; AC_SUBST([GNULIB_FREXPL])
28 GNULIB_ISFINITE=0; AC_SUBST([GNULIB_ISFINITE]) 53 GNULIB_ISFINITE=0; AC_SUBST([GNULIB_ISFINITE])
54 GNULIB_ISINF=0; AC_SUBST([GNULIB_ISINF])
55 GNULIB_ISNAN=0; AC_SUBST([GNULIB_ISNAN])
56 GNULIB_ISNANF=0; AC_SUBST([GNULIB_ISNANF])
57 GNULIB_ISNAND=0; AC_SUBST([GNULIB_ISNAND])
58 GNULIB_ISNANL=0; AC_SUBST([GNULIB_ISNANL])
29 GNULIB_LDEXPL=0; AC_SUBST([GNULIB_LDEXPL]) 59 GNULIB_LDEXPL=0; AC_SUBST([GNULIB_LDEXPL])
30 GNULIB_MATHL=0; AC_SUBST([GNULIB_MATHL]) 60 GNULIB_MATHL=0; AC_SUBST([GNULIB_MATHL])
31 GNULIB_ROUND=0; AC_SUBST([GNULIB_ROUND]) 61 GNULIB_ROUND=0; AC_SUBST([GNULIB_ROUND])
@@ -36,6 +66,9 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
36 GNULIB_TRUNCF=0; AC_SUBST([GNULIB_TRUNCF]) 66 GNULIB_TRUNCF=0; AC_SUBST([GNULIB_TRUNCF])
37 GNULIB_TRUNCL=0; AC_SUBST([GNULIB_TRUNCL]) 67 GNULIB_TRUNCL=0; AC_SUBST([GNULIB_TRUNCL])
38 dnl Assume proper GNU behavior unless another module says otherwise. 68 dnl Assume proper GNU behavior unless another module says otherwise.
69 HAVE_ISNANF=1; AC_SUBST([HAVE_ISNANF])
70 HAVE_ISNAND=1; AC_SUBST([HAVE_ISNAND])
71 HAVE_ISNANL=1; AC_SUBST([HAVE_ISNANL])
39 HAVE_DECL_ACOSL=1; AC_SUBST([HAVE_DECL_ACOSL]) 72 HAVE_DECL_ACOSL=1; AC_SUBST([HAVE_DECL_ACOSL])
40 HAVE_DECL_ASINL=1; AC_SUBST([HAVE_DECL_ASINL]) 73 HAVE_DECL_ASINL=1; AC_SUBST([HAVE_DECL_ASINL])
41 HAVE_DECL_ATANL=1; AC_SUBST([HAVE_DECL_ATANL]) 74 HAVE_DECL_ATANL=1; AC_SUBST([HAVE_DECL_ATANL])
@@ -49,18 +82,22 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
49 HAVE_DECL_TANL=1; AC_SUBST([HAVE_DECL_TANL]) 82 HAVE_DECL_TANL=1; AC_SUBST([HAVE_DECL_TANL])
50 HAVE_DECL_TRUNC=1; AC_SUBST([HAVE_DECL_TRUNC]) 83 HAVE_DECL_TRUNC=1; AC_SUBST([HAVE_DECL_TRUNC])
51 HAVE_DECL_TRUNCF=1; AC_SUBST([HAVE_DECL_TRUNCF]) 84 HAVE_DECL_TRUNCF=1; AC_SUBST([HAVE_DECL_TRUNCF])
52 HAVE_DECL_TRUNCL=1; AC_SUBST([HAVE_DECL_TRUNCL])
53 REPLACE_CEILF=0; AC_SUBST([REPLACE_CEILF]) 85 REPLACE_CEILF=0; AC_SUBST([REPLACE_CEILF])
54 REPLACE_CEILL=0; AC_SUBST([REPLACE_CEILL]) 86 REPLACE_CEILL=0; AC_SUBST([REPLACE_CEILL])
55 REPLACE_FLOORF=0; AC_SUBST([REPLACE_FLOORF]) 87 REPLACE_FLOORF=0; AC_SUBST([REPLACE_FLOORF])
56 REPLACE_FLOORL=0; AC_SUBST([REPLACE_FLOORL]) 88 REPLACE_FLOORL=0; AC_SUBST([REPLACE_FLOORL])
57 REPLACE_FREXP=0; AC_SUBST([REPLACE_FREXP]) 89 REPLACE_FREXP=0; AC_SUBST([REPLACE_FREXP])
58 REPLACE_FREXPL=0; AC_SUBST([REPLACE_FREXPL]) 90 REPLACE_FREXPL=0; AC_SUBST([REPLACE_FREXPL])
91 REPLACE_HUGE_VAL=0; AC_SUBST([REPLACE_HUGE_VAL])
59 REPLACE_ISFINITE=0; AC_SUBST([REPLACE_ISFINITE]) 92 REPLACE_ISFINITE=0; AC_SUBST([REPLACE_ISFINITE])
93 REPLACE_ISINF=0; AC_SUBST([REPLACE_ISINF])
94 REPLACE_ISNAN=0; AC_SUBST([REPLACE_ISNAN])
60 REPLACE_LDEXPL=0; AC_SUBST([REPLACE_LDEXPL]) 95 REPLACE_LDEXPL=0; AC_SUBST([REPLACE_LDEXPL])
96 REPLACE_NAN=0; AC_SUBST([REPLACE_NAN])
61 REPLACE_ROUND=0; AC_SUBST([REPLACE_ROUND]) 97 REPLACE_ROUND=0; AC_SUBST([REPLACE_ROUND])
62 REPLACE_ROUNDF=0; AC_SUBST([REPLACE_ROUNDF]) 98 REPLACE_ROUNDF=0; AC_SUBST([REPLACE_ROUNDF])
63 REPLACE_ROUNDL=0; AC_SUBST([REPLACE_ROUNDL]) 99 REPLACE_ROUNDL=0; AC_SUBST([REPLACE_ROUNDL])
64 REPLACE_SIGNBIT=0; AC_SUBST([REPLACE_SIGNBIT]) 100 REPLACE_SIGNBIT=0; AC_SUBST([REPLACE_SIGNBIT])
65 REPLACE_SIGNBIT_USING_GCC=0; AC_SUBST([REPLACE_SIGNBIT_USING_GCC]) 101 REPLACE_SIGNBIT_USING_GCC=0; AC_SUBST([REPLACE_SIGNBIT_USING_GCC])
102 REPLACE_TRUNCL=0; AC_SUBST([REPLACE_TRUNCL])
66]) 103])
diff --git a/gl/m4/mbrtowc.m4 b/gl/m4/mbrtowc.m4
new file mode 100644
index 0000000..726497b
--- /dev/null
+++ b/gl/m4/mbrtowc.m4
@@ -0,0 +1,325 @@
1# mbrtowc.m4 serial 13
2dnl Copyright (C) 2001-2002, 2004-2005, 2008, 2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_MBRTOWC],
8[
9 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
10
11 AC_REQUIRE([AC_TYPE_MBSTATE_T])
12 gl_MBSTATE_T_BROKEN
13 if test $REPLACE_MBSTATE_T = 1; then
14 REPLACE_MBRTOWC=1
15 fi
16 AC_CHECK_FUNCS_ONCE([mbrtowc])
17 if test $ac_cv_func_mbrtowc = no; then
18 HAVE_MBRTOWC=0
19 fi
20 if test $HAVE_MBRTOWC != 0 && test $REPLACE_MBRTOWC != 1; then
21 gl_MBRTOWC_NULL_ARG
22 gl_MBRTOWC_RETVAL
23 gl_MBRTOWC_NUL_RETVAL
24 case "$gl_cv_func_mbrtowc_null_arg" in
25 *yes) ;;
26 *) AC_DEFINE([MBRTOWC_NULL_ARG_BUG], [1],
27 [Define if the mbrtowc function has the NULL string argument bug.])
28 REPLACE_MBRTOWC=1
29 ;;
30 esac
31 case "$gl_cv_func_mbrtowc_retval" in
32 *yes) ;;
33 *) AC_DEFINE([MBRTOWC_RETVAL_BUG], [1],
34 [Define if the mbrtowc function returns a wrong return value.])
35 REPLACE_MBRTOWC=1
36 ;;
37 esac
38 case "$gl_cv_func_mbrtowc_nul_retval" in
39 *yes) ;;
40 *) AC_DEFINE([MBRTOWC_NUL_RETVAL_BUG], [1],
41 [Define if the mbrtowc function does not return 0 for a NUL character.])
42 REPLACE_MBRTOWC=1
43 ;;
44 esac
45 fi
46 if test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1; then
47 gl_REPLACE_WCHAR_H
48 AC_LIBOBJ([mbrtowc])
49 gl_PREREQ_MBRTOWC
50 fi
51])
52
53dnl Test whether mbsinit() and mbrtowc() need to be overridden in a way that
54dnl redefines the semantics of the given mbstate_t type.
55dnl Result is REPLACE_MBSTATE_T.
56dnl When this is set to 1, we replace both mbsinit() and mbrtowc(), in order to
57dnl avoid inconsistencies.
58
59AC_DEFUN([gl_MBSTATE_T_BROKEN],
60[
61 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
62
63 AC_REQUIRE([AC_TYPE_MBSTATE_T])
64 AC_CHECK_FUNCS_ONCE([mbsinit])
65 AC_CHECK_FUNCS_ONCE([mbrtowc])
66 if test $ac_cv_func_mbsinit = yes && test $ac_cv_func_mbrtowc = yes; then
67 gl_MBRTOWC_INCOMPLETE_STATE
68 case "$gl_cv_func_mbrtowc_incomplete_state" in
69 *yes) REPLACE_MBSTATE_T=0 ;;
70 *) REPLACE_MBSTATE_T=1 ;;
71 esac
72 else
73 REPLACE_MBSTATE_T=1
74 fi
75 if test $REPLACE_MBSTATE_T = 1; then
76 gl_REPLACE_WCHAR_H
77 fi
78])
79
80dnl Test whether mbrtowc puts the state into non-initial state when parsing an
81dnl incomplete multibyte character.
82dnl Result is gl_cv_func_mbrtowc_incomplete_state.
83
84AC_DEFUN([gl_MBRTOWC_INCOMPLETE_STATE],
85[
86 AC_REQUIRE([AC_PROG_CC])
87 AC_REQUIRE([gt_LOCALE_JA])
88 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
89 AC_CACHE_CHECK([whether mbrtowc handles incomplete characters],
90 [gl_cv_func_mbrtowc_incomplete_state],
91 [
92 dnl Initial guess, used when cross-compiling or when no suitable locale
93 dnl is present.
94changequote(,)dnl
95 case "$host_os" in
96 # Guess no on AIX and OSF/1.
97 osf*) gl_cv_func_mbrtowc_incomplete_state="guessing no" ;;
98 # Guess yes otherwise.
99 *) gl_cv_func_mbrtowc_incomplete_state="guessing yes" ;;
100 esac
101changequote([,])dnl
102 if test $LOCALE_JA != none; then
103 AC_TRY_RUN([
104#include <locale.h>
105#include <string.h>
106#include <wchar.h>
107int main ()
108{
109 if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
110 {
111 const char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */
112 mbstate_t state;
113 wchar_t wc;
114
115 memset (&state, '\0', sizeof (mbstate_t));
116 if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2))
117 if (mbsinit (&state))
118 return 1;
119 }
120 return 0;
121}],
122 [gl_cv_func_mbrtowc_incomplete_state=yes],
123 [gl_cv_func_mbrtowc_incomplete_state=no],
124 [])
125 fi
126 ])
127])
128
129dnl Test whether mbrtowc supports a NULL string argument correctly.
130dnl Result is gl_cv_func_mbrtowc_null_arg.
131
132AC_DEFUN([gl_MBRTOWC_NULL_ARG],
133[
134 AC_REQUIRE([AC_PROG_CC])
135 AC_REQUIRE([gt_LOCALE_FR_UTF8])
136 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
137 AC_CACHE_CHECK([whether mbrtowc handles a NULL string argument],
138 [gl_cv_func_mbrtowc_null_arg],
139 [
140 dnl Initial guess, used when cross-compiling or when no suitable locale
141 dnl is present.
142changequote(,)dnl
143 case "$host_os" in
144 # Guess no on OSF/1.
145 osf*) gl_cv_func_mbrtowc_null_arg="guessing no" ;;
146 # Guess yes otherwise.
147 *) gl_cv_func_mbrtowc_null_arg="guessing yes" ;;
148 esac
149changequote([,])dnl
150 if test $LOCALE_FR_UTF8 != none; then
151 AC_TRY_RUN([
152#include <locale.h>
153#include <string.h>
154#include <wchar.h>
155int main ()
156{
157 if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
158 {
159 mbstate_t state;
160 wchar_t wc;
161 int ret;
162
163 memset (&state, '\0', sizeof (mbstate_t));
164 wc = (wchar_t) 0xBADFACE;
165 mbrtowc (&wc, NULL, 5, &state);
166 /* Check that wc was not modified. */
167 if (wc != (wchar_t) 0xBADFACE)
168 return 1;
169 }
170 return 0;
171}], [gl_cv_func_mbrtowc_null_arg=yes], [gl_cv_func_mbrtowc_null_arg=no], [])
172 fi
173 ])
174])
175
176dnl Test whether mbrtowc, when parsing the end of a multibyte character,
177dnl correctly returns the number of bytes that were needed to complete the
178dnl character (not the total number of bytes of the multibyte character).
179dnl Result is gl_cv_func_mbrtowc_retval.
180
181AC_DEFUN([gl_MBRTOWC_RETVAL],
182[
183 AC_REQUIRE([AC_PROG_CC])
184 AC_REQUIRE([gt_LOCALE_FR_UTF8])
185 AC_REQUIRE([gt_LOCALE_JA])
186 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
187 AC_CACHE_CHECK([whether mbrtowc has a correct return value],
188 [gl_cv_func_mbrtowc_retval],
189 [
190 dnl Initial guess, used when cross-compiling or when no suitable locale
191 dnl is present.
192changequote(,)dnl
193 case "$host_os" in
194 # Guess no on HP-UX and Solaris.
195 hpux* | solaris*) gl_cv_func_mbrtowc_retval="guessing no" ;;
196 # Guess yes otherwise.
197 *) gl_cv_func_mbrtowc_retval="guessing yes" ;;
198 esac
199changequote([,])dnl
200 if test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none; then
201 AC_TRY_RUN([
202#include <locale.h>
203#include <string.h>
204#include <wchar.h>
205int main ()
206{
207 /* This fails on Solaris. */
208 if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
209 {
210 char input[] = "B\303\274\303\237er"; /* "Büßer" */
211 mbstate_t state;
212 wchar_t wc;
213
214 memset (&state, '\0', sizeof (mbstate_t));
215 if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2))
216 {
217 input[1] = '\0';
218 if (mbrtowc (&wc, input + 2, 5, &state) != 1)
219 return 1;
220 }
221 }
222 /* This fails on HP-UX 11.11. */
223 if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
224 {
225 char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */
226 mbstate_t state;
227 wchar_t wc;
228
229 memset (&state, '\0', sizeof (mbstate_t));
230 if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2))
231 {
232 input[1] = '\0';
233 if (mbrtowc (&wc, input + 2, 5, &state) != 2)
234 return 1;
235 }
236 }
237 return 0;
238}],
239 [gl_cv_func_mbrtowc_retval=yes],
240 [gl_cv_func_mbrtowc_retval=no],
241 [])
242 fi
243 ])
244])
245
246dnl Test whether mbrtowc, when parsing a NUL character, correctly returns 0.
247dnl Result is gl_cv_func_mbrtowc_nul_retval.
248
249AC_DEFUN([gl_MBRTOWC_NUL_RETVAL],
250[
251 AC_REQUIRE([AC_PROG_CC])
252 AC_REQUIRE([gt_LOCALE_ZH_CN])
253 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
254 AC_CACHE_CHECK([whether mbrtowc returns 0 when parsing a NUL character],
255 [gl_cv_func_mbrtowc_nul_retval],
256 [
257 dnl Initial guess, used when cross-compiling or when no suitable locale
258 dnl is present.
259changequote(,)dnl
260 case "$host_os" in
261 # Guess no on Solaris 9.
262 solaris2.9) gl_cv_func_mbrtowc_nul_retval="guessing no" ;;
263 # Guess yes otherwise.
264 *) gl_cv_func_mbrtowc_nul_retval="guessing yes" ;;
265 esac
266changequote([,])dnl
267 if test $LOCALE_ZH_CN != none; then
268 AC_TRY_RUN([
269#include <locale.h>
270#include <string.h>
271#include <wchar.h>
272int main ()
273{
274 /* This fails on Solaris 9. */
275 if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
276 {
277 mbstate_t state;
278 wchar_t wc;
279
280 memset (&state, '\0', sizeof (mbstate_t));
281 if (mbrtowc (&wc, "", 1, &state) != 0)
282 return 1;
283 }
284 return 0;
285}],
286 [gl_cv_func_mbrtowc_nul_retval=yes],
287 [gl_cv_func_mbrtowc_nul_retval=no],
288 [])
289 fi
290 ])
291])
292
293# Prerequisites of lib/mbrtowc.c.
294AC_DEFUN([gl_PREREQ_MBRTOWC], [
295 :
296])
297
298
299dnl From Paul Eggert
300
301dnl This override of an autoconf macro can be removed when autoconf 2.60 or
302dnl newer can be assumed everywhere.
303
304m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.60]),[-1],[
305AC_DEFUN([AC_FUNC_MBRTOWC],
306[
307 dnl Same as AC_FUNC_MBRTOWC in autoconf-2.60.
308 AC_CACHE_CHECK([whether mbrtowc and mbstate_t are properly declared],
309 gl_cv_func_mbrtowc,
310 [AC_LINK_IFELSE(
311 [AC_LANG_PROGRAM(
312 [[#include <wchar.h>]],
313 [[wchar_t wc;
314 char const s[] = "";
315 size_t n = 1;
316 mbstate_t state;
317 return ! (sizeof state && (mbrtowc) (&wc, s, n, &state));]])],
318 gl_cv_func_mbrtowc=yes,
319 gl_cv_func_mbrtowc=no)])
320 if test $gl_cv_func_mbrtowc = yes; then
321 AC_DEFINE([HAVE_MBRTOWC], [1],
322 [Define to 1 if mbrtowc and mbstate_t are properly declared.])
323 fi
324])
325])
diff --git a/gl/m4/mbsinit.m4 b/gl/m4/mbsinit.m4
new file mode 100644
index 0000000..03b055c
--- /dev/null
+++ b/gl/m4/mbsinit.m4
@@ -0,0 +1,30 @@
1# mbsinit.m4 serial 3
2dnl Copyright (C) 2008 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_MBSINIT],
8[
9 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
10
11 AC_REQUIRE([AC_TYPE_MBSTATE_T])
12 gl_MBSTATE_T_BROKEN
13 if test $REPLACE_MBSTATE_T = 1; then
14 REPLACE_MBSINIT=1
15 fi
16 AC_CHECK_FUNCS_ONCE([mbsinit])
17 if test $ac_cv_func_mbsinit = no; then
18 HAVE_MBSINIT=0
19 fi
20 if test $HAVE_MBSINIT = 0 || test $REPLACE_MBSINIT = 1; then
21 gl_REPLACE_WCHAR_H
22 AC_LIBOBJ([mbsinit])
23 gl_PREREQ_MBSINIT
24 fi
25])
26
27# Prerequisites of lib/mbsinit.c.
28AC_DEFUN([gl_PREREQ_MBSINIT], [
29 :
30])
diff --git a/gl/m4/mbstate_t.m4 b/gl/m4/mbstate_t.m4
index df2a275..d4ec6f0 100644
--- a/gl/m4/mbstate_t.m4
+++ b/gl/m4/mbstate_t.m4
@@ -1,5 +1,5 @@
1# mbstate_t.m4 serial 9 1# mbstate_t.m4 serial 12
2dnl Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc. 2dnl Copyright (C) 2000-2002, 2008, 2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -13,18 +13,22 @@ dnl with or without modifications, as long as this notice is preserved.
13# AC_TYPE_MBSTATE_T 13# AC_TYPE_MBSTATE_T
14# ----------------- 14# -----------------
15AC_DEFUN([AC_TYPE_MBSTATE_T], 15AC_DEFUN([AC_TYPE_MBSTATE_T],
16 [AC_CACHE_CHECK([for mbstate_t], ac_cv_type_mbstate_t, 16[
17 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) dnl for HP-UX 11.11
18
19 AC_CACHE_CHECK([for mbstate_t], [ac_cv_type_mbstate_t],
17 [AC_COMPILE_IFELSE( 20 [AC_COMPILE_IFELSE(
18 [AC_LANG_PROGRAM( 21 [AC_LANG_PROGRAM(
19 [AC_INCLUDES_DEFAULT 22 [AC_INCLUDES_DEFAULT[
20# include <wchar.h>], 23# include <wchar.h>]],
21 [mbstate_t x; return sizeof x;])], 24 [[mbstate_t x; return sizeof x;]])],
22 [ac_cv_type_mbstate_t=yes], 25 [ac_cv_type_mbstate_t=yes],
23 [ac_cv_type_mbstate_t=no])]) 26 [ac_cv_type_mbstate_t=no])])
24 if test $ac_cv_type_mbstate_t = yes; then 27 if test $ac_cv_type_mbstate_t = yes; then
25 AC_DEFINE([HAVE_MBSTATE_T], 1, 28 AC_DEFINE([HAVE_MBSTATE_T], [1],
26 [Define to 1 if <wchar.h> declares mbstate_t.]) 29 [Define to 1 if <wchar.h> declares mbstate_t.])
27 else 30 else
28 AC_DEFINE([mbstate_t], int, 31 AC_DEFINE([mbstate_t], [int],
29 [Define to a type if <wchar.h> does not define.]) 32 [Define to a type if <wchar.h> does not define.])
30 fi]) 33 fi
34])
diff --git a/gl/m4/mountlist.m4 b/gl/m4/mountlist.m4
index c25f44e..f62c57a 100644
--- a/gl/m4/mountlist.m4
+++ b/gl/m4/mountlist.m4
@@ -1,5 +1,5 @@
1#serial 9 1# serial 10
2dnl Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2006, 2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -9,7 +9,7 @@ AC_DEFUN([gl_MOUNTLIST],
9 gl_LIST_MOUNTED_FILE_SYSTEMS([gl_cv_list_mounted_fs=yes], 9 gl_LIST_MOUNTED_FILE_SYSTEMS([gl_cv_list_mounted_fs=yes],
10 [gl_cv_list_mounted_fs=no]) 10 [gl_cv_list_mounted_fs=no])
11 if test $gl_cv_list_mounted_fs = yes; then 11 if test $gl_cv_list_mounted_fs = yes; then
12 AC_LIBOBJ(mountlist) 12 AC_LIBOBJ([mountlist])
13 gl_PREREQ_MOUNTLIST_EXTRA 13 gl_PREREQ_MOUNTLIST_EXTRA
14 fi 14 fi
15]) 15])
@@ -18,6 +18,6 @@ AC_DEFUN([gl_MOUNTLIST],
18AC_DEFUN([gl_PREREQ_MOUNTLIST_EXTRA], 18AC_DEFUN([gl_PREREQ_MOUNTLIST_EXTRA],
19[ 19[
20 dnl Note gl_LIST_MOUNTED_FILE_SYSTEMS checks for mntent.h, not sys/mntent.h. 20 dnl Note gl_LIST_MOUNTED_FILE_SYSTEMS checks for mntent.h, not sys/mntent.h.
21 AC_CHECK_HEADERS(sys/mntent.h) 21 AC_CHECK_HEADERS([sys/mntent.h])
22 gl_FSTYPENAME 22 gl_FSTYPENAME
23]) 23])
diff --git a/gl/m4/multiarch.m4 b/gl/m4/multiarch.m4
new file mode 100644
index 0000000..7b73e15
--- /dev/null
+++ b/gl/m4/multiarch.m4
@@ -0,0 +1,74 @@
1# multiarch.m4 serial 3
2dnl Copyright (C) 2008 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7# Determine whether the compiler is or may be producing universal binaries.
8#
9# On MacOS X 10.5 and later systems, the user can create libraries and
10# executables that work on multiple system types--known as "fat" or
11# "universal" binaries--by specifying multiple '-arch' options to the
12# compiler but only a single '-arch' option to the preprocessor. Like
13# this:
14#
15# ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
16# CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
17# CPP="gcc -E" CXXCPP="g++ -E"
18#
19# Detect this situation and set the macro AA_APPLE_UNIVERSAL_BUILD at the
20# beginning of config.h and set APPLE_UNIVERSAL_BUILD accordingly.
21
22AC_DEFUN([gl_MULTIARCH],
23[
24 dnl This AC_REQUIRE is not necessary in theory. It works around a bug in
25 dnl autoconf <= 2.63: AC_REQUIRE invocations inside AC_REQUIREd macros are
26 dnl being handled better than AC_REQUIRE invocations inside normally invoked
27 dnl macros.
28 AC_REQUIRE([gl_MULTIARCH_BODY])
29])
30
31AC_DEFUN([gl_MULTIARCH_BODY],
32[
33 dnl Code similar to autoconf-2.63 AC_C_BIGENDIAN.
34 gl_cv_c_multiarch=no
35 AC_COMPILE_IFELSE(
36 [AC_LANG_SOURCE(
37 [[#ifndef __APPLE_CC__
38 not a universal capable compiler
39 #endif
40 typedef int dummy;
41 ]])],
42 [
43 dnl Check for potential -arch flags. It is not universal unless
44 dnl there are at least two -arch flags with different values.
45 arch=
46 prev=
47 for word in ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}; do
48 if test -n "$prev"; then
49 case $word in
50 i?86 | x86_64 | ppc | ppc64)
51 if test -z "$arch" || test "$arch" = "$word"; then
52 arch="$word"
53 else
54 gl_cv_c_multiarch=yes
55 fi
56 ;;
57 esac
58 prev=
59 else
60 if test "x$word" = "x-arch"; then
61 prev=arch
62 fi
63 fi
64 done
65 ])
66 if test $gl_cv_c_multiarch = yes; then
67 AC_DEFINE([AA_APPLE_UNIVERSAL_BUILD], [1],
68 [Define if the compiler is building for multiple architectures of Apple platforms at once.])
69 APPLE_UNIVERSAL_BUILD=1
70 else
71 APPLE_UNIVERSAL_BUILD=0
72 fi
73 AC_SUBST([APPLE_UNIVERSAL_BUILD])
74])
diff --git a/gl/m4/netdb_h.m4 b/gl/m4/netdb_h.m4
new file mode 100644
index 0000000..5a12251
--- /dev/null
+++ b/gl/m4/netdb_h.m4
@@ -0,0 +1,45 @@
1# netdb_h.m4 serial 5
2dnl Copyright (C) 2008 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_HEADER_NETDB],
8[
9 AC_REQUIRE([gl_NETDB_H_DEFAULTS])
10 gl_CHECK_NEXT_HEADERS([netdb.h])
11 if test $ac_cv_header_netdb_h = yes; then
12 AC_COMPILE_IFELSE(
13 [AC_LANG_PROGRAM([[
14 #include <netdb.h>
15 struct addrinfo a;
16 int b = EAI_OVERFLOW;
17 int c = AI_NUMERICSERV;
18 ]])],
19 [NETDB_H=''], [NETDB_H='netdb.h'])
20 HAVE_NETDB_H=1
21 else
22 NETDB_H='netdb.h'
23 HAVE_NETDB_H=0
24 fi
25 AC_SUBST([HAVE_NETDB_H])
26 AC_SUBST([NETDB_H])
27])
28
29AC_DEFUN([gl_NETDB_MODULE_INDICATOR],
30[
31 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
32 AC_REQUIRE([gl_NETDB_H_DEFAULTS])
33 GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
34])
35
36AC_DEFUN([gl_NETDB_H_DEFAULTS],
37[
38 GNULIB_GETADDRINFO=0; AC_SUBST([GNULIB_GETADDRINFO])
39 dnl Assume proper GNU behavior unless another module says otherwise.
40 HAVE_STRUCT_ADDRINFO=1; AC_SUBST([HAVE_STRUCT_ADDRINFO])
41 HAVE_DECL_FREEADDRINFO=1; AC_SUBST([HAVE_DECL_FREEADDRINFO])
42 HAVE_DECL_GAI_STRERROR=1; AC_SUBST([HAVE_DECL_GAI_STRERROR])
43 HAVE_DECL_GETADDRINFO=1; AC_SUBST([HAVE_DECL_GETADDRINFO])
44 HAVE_DECL_GETNAMEINFO=1; AC_SUBST([HAVE_DECL_GETNAMEINFO])
45])
diff --git a/gl/m4/netinet_in_h.m4 b/gl/m4/netinet_in_h.m4
index 096be74..47fd9cc 100644
--- a/gl/m4/netinet_in_h.m4
+++ b/gl/m4/netinet_in_h.m4
@@ -1,5 +1,5 @@
1# netinet_in_h.m4 serial 3 1# netinet_in_h.m4 serial 4
2dnl Copyright (C) 2006-2007 Free Software Foundation, Inc. 2dnl Copyright (C) 2006-2008 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -9,7 +9,7 @@ AC_DEFUN([gl_HEADER_NETINET_IN],
9 AC_CACHE_CHECK([whether <netinet/in.h> is self-contained], 9 AC_CACHE_CHECK([whether <netinet/in.h> is self-contained],
10 [gl_cv_header_netinet_in_h_selfcontained], 10 [gl_cv_header_netinet_in_h_selfcontained],
11 [ 11 [
12 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <netinet/in.h>], [])], 12 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <netinet/in.h>]], [[]])],
13 [gl_cv_header_netinet_in_h_selfcontained=yes], 13 [gl_cv_header_netinet_in_h_selfcontained=yes],
14 [gl_cv_header_netinet_in_h_selfcontained=no]) 14 [gl_cv_header_netinet_in_h_selfcontained=no])
15 ]) 15 ])
diff --git a/gl/m4/nls.m4 b/gl/m4/nls.m4
index 7967cc2..0b36434 100644
--- a/gl/m4/nls.m4
+++ b/gl/m4/nls.m4
@@ -1,5 +1,5 @@
1# nls.m4 serial 3 (gettext-0.15) 1# nls.m4 serial 5 (gettext-0.18)
2dnl Copyright (C) 1995-2003, 2005-2006 Free Software Foundation, Inc. 2dnl Copyright (C) 1995-2003, 2005-2006, 2008, 2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -17,15 +17,15 @@ dnl Authors:
17dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000. 17dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
18dnl Bruno Haible <haible@clisp.cons.org>, 2000-2003. 18dnl Bruno Haible <haible@clisp.cons.org>, 2000-2003.
19 19
20AC_PREREQ(2.50) 20AC_PREREQ([2.50])
21 21
22AC_DEFUN([AM_NLS], 22AC_DEFUN([AM_NLS],
23[ 23[
24 AC_MSG_CHECKING([whether NLS is requested]) 24 AC_MSG_CHECKING([whether NLS is requested])
25 dnl Default is enabled NLS 25 dnl Default is enabled NLS
26 AC_ARG_ENABLE(nls, 26 AC_ARG_ENABLE([nls],
27 [ --disable-nls do not use Native Language Support], 27 [ --disable-nls do not use Native Language Support],
28 USE_NLS=$enableval, USE_NLS=yes) 28 USE_NLS=$enableval, USE_NLS=yes)
29 AC_MSG_RESULT($USE_NLS) 29 AC_MSG_RESULT([$USE_NLS])
30 AC_SUBST(USE_NLS) 30 AC_SUBST([USE_NLS])
31]) 31])
diff --git a/gl/m4/onceonly_2_57.m4 b/gl/m4/onceonly.m4
index 15884b3..108cd6c 100644
--- a/gl/m4/onceonly_2_57.m4
+++ b/gl/m4/onceonly.m4
@@ -1,5 +1,5 @@
1# onceonly_2_57.m4 serial 4 1# onceonly.m4 serial 6
2dnl Copyright (C) 2002-2003, 2005-2006 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2003, 2005-2006, 2008 Free Software Foundation, Inc.
3dnl This file is free software, distributed under the terms of the GNU 3dnl This file is free software, distributed under the terms of the GNU
4dnl General Public License. As a special exception to the GNU General 4dnl General Public License. As a special exception to the GNU General
5dnl Public License, this file may be distributed as part of a program 5dnl Public License, this file may be distributed as part of a program
@@ -21,19 +21,23 @@ dnl inside an AC_DEFUNed function, the gl_CHECK_HEADERS macro call expands to
21dnl empty, and the check will be inserted before the body of the AC_DEFUNed 21dnl empty, and the check will be inserted before the body of the AC_DEFUNed
22dnl function. 22dnl function.
23 23
24dnl This is like onceonly.m4, except that it uses diversions to named sections 24dnl The original code implemented AC_CHECK_HEADERS_ONCE and AC_CHECK_FUNCS_ONCE
25dnl DEFAULTS and INIT_PREPARE in order to check all requested headers at once, 25dnl in terms of AC_DEFUN and AC_REQUIRE. This implementation uses diversions to
26dnl thus reducing the size of 'configure'. Works with autoconf-2.57. The 26dnl named sections DEFAULTS and INIT_PREPARE in order to check all requested
27dnl size reduction is ca. 9%. 27dnl headers at once, thus reducing the size of 'configure'. It is known to work
28dnl with autoconf 2.57..2.62 at least . The size reduction is ca. 9%.
28 29
29dnl Autoconf version 2.57 or newer is recommended. 30dnl Autoconf version 2.59 plus gnulib is required; this file is not needed
30AC_PREREQ(2.57) 31dnl with Autoconf 2.60 or greater. But note that autoconf's implementation of
32dnl AC_CHECK_DECLS_ONCE expects a comma-separated list of symbols as first
33dnl argument!
34AC_PREREQ([2.59])
31 35
32# AC_CHECK_HEADERS_ONCE(HEADER1 HEADER2 ...) is a once-only variant of 36# AC_CHECK_HEADERS_ONCE(HEADER1 HEADER2 ...) is a once-only variant of
33# AC_CHECK_HEADERS(HEADER1 HEADER2 ...). 37# AC_CHECK_HEADERS(HEADER1 HEADER2 ...).
34AC_DEFUN([AC_CHECK_HEADERS_ONCE], [ 38AC_DEFUN([AC_CHECK_HEADERS_ONCE], [
35 : 39 :
36 AC_FOREACH([gl_HEADER_NAME], [$1], [ 40 m4_foreach_w([gl_HEADER_NAME], [$1], [
37 AC_DEFUN([gl_CHECK_HEADER_]m4_quote(translit(gl_HEADER_NAME, 41 AC_DEFUN([gl_CHECK_HEADER_]m4_quote(translit(gl_HEADER_NAME,
38 [./-], [___])), [ 42 [./-], [___])), [
39 m4_divert_text([INIT_PREPARE], 43 m4_divert_text([INIT_PREPARE],
@@ -56,7 +60,7 @@ m4_define([gl_HEADERS_EXPANSION], [
56# AC_CHECK_FUNCS(FUNC1 FUNC2 ...). 60# AC_CHECK_FUNCS(FUNC1 FUNC2 ...).
57AC_DEFUN([AC_CHECK_FUNCS_ONCE], [ 61AC_DEFUN([AC_CHECK_FUNCS_ONCE], [
58 : 62 :
59 AC_FOREACH([gl_FUNC_NAME], [$1], [ 63 m4_foreach_w([gl_FUNC_NAME], [$1], [
60 AC_DEFUN([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME]), [ 64 AC_DEFUN([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME]), [
61 m4_divert_text([INIT_PREPARE], 65 m4_divert_text([INIT_PREPARE],
62 [gl_func_list="$gl_func_list gl_FUNC_NAME"]) 66 [gl_func_list="$gl_func_list gl_FUNC_NAME"])
@@ -77,7 +81,7 @@ m4_define([gl_FUNCS_EXPANSION], [
77# AC_CHECK_DECLS(DECL1, DECL2, ...). 81# AC_CHECK_DECLS(DECL1, DECL2, ...).
78AC_DEFUN([AC_CHECK_DECLS_ONCE], [ 82AC_DEFUN([AC_CHECK_DECLS_ONCE], [
79 : 83 :
80 AC_FOREACH([gl_DECL_NAME], [$1], [ 84 m4_foreach_w([gl_DECL_NAME], [$1], [
81 AC_DEFUN([gl_CHECK_DECL_]m4_defn([gl_DECL_NAME]), [ 85 AC_DEFUN([gl_CHECK_DECL_]m4_defn([gl_DECL_NAME]), [
82 AC_CHECK_DECLS(m4_defn([gl_DECL_NAME])) 86 AC_CHECK_DECLS(m4_defn([gl_DECL_NAME]))
83 ]) 87 ])
diff --git a/gl/m4/open.m4 b/gl/m4/open.m4
new file mode 100644
index 0000000..6e286c9
--- /dev/null
+++ b/gl/m4/open.m4
@@ -0,0 +1,66 @@
1# open.m4 serial 5
2dnl Copyright (C) 2007-2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_OPEN],
8[
9 AC_REQUIRE([AC_CANONICAL_HOST])
10 case "$host_os" in
11 mingw* | pw*)
12 gl_REPLACE_OPEN
13 ;;
14 *)
15 dnl open("foo/") should not create a file when the file name has a
16 dnl trailing slash.
17 AC_CACHE_CHECK([whether open recognizes a trailing slash],
18 [gl_cv_func_open_slash],
19 [
20 AC_TRY_RUN([
21#include <fcntl.h>
22#if HAVE_UNISTD_H
23# include <unistd.h>
24#endif
25int main ()
26{
27 return open ("conftest.sl/", O_CREAT, 0600) >= 0;
28}], [gl_cv_func_open_slash=yes], [gl_cv_func_open_slash=no],
29 [
30changequote(,)dnl
31 case "$host_os" in
32 solaris2.[0-9]*) gl_cv_func_open_slash="guessing no" ;;
33 hpux*) gl_cv_func_open_slash="guessing no" ;;
34 *) gl_cv_func_open_slash="guessing yes" ;;
35 esac
36changequote([,])dnl
37 ])
38 rm -f conftest.sl
39 ])
40 case "$gl_cv_func_open_slash" in
41 *no)
42 AC_DEFINE([OPEN_TRAILING_SLASH_BUG], [1],
43 [Define to 1 if open() fails to recognize a trailing slash.])
44 gl_REPLACE_OPEN
45 ;;
46 esac
47 ;;
48 esac
49])
50
51AC_DEFUN([gl_REPLACE_OPEN],
52[
53 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
54 if test $REPLACE_OPEN != 1; then
55 AC_LIBOBJ([open])
56 gl_PREREQ_OPEN
57 fi
58 REPLACE_OPEN=1
59])
60
61# Prerequisites of lib/open.c.
62AC_DEFUN([gl_PREREQ_OPEN],
63[
64 AC_REQUIRE([AC_C_INLINE])
65 :
66])
diff --git a/gl/m4/po.m4 b/gl/m4/po.m4
index 0734762..2284fa5 100644
--- a/gl/m4/po.m4
+++ b/gl/m4/po.m4
@@ -1,5 +1,5 @@
1# po.m4 serial 15 (gettext-0.17) 1# po.m4 serial 17 (gettext-0.18)
2dnl Copyright (C) 1995-2007 Free Software Foundation, Inc. 2dnl Copyright (C) 1995-2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -17,7 +17,7 @@ dnl Authors:
17dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000. 17dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
18dnl Bruno Haible <haible@clisp.cons.org>, 2000-2003. 18dnl Bruno Haible <haible@clisp.cons.org>, 2000-2003.
19 19
20AC_PREREQ(2.50) 20AC_PREREQ([2.50])
21 21
22dnl Checks for all prerequisites of the po subdirectory. 22dnl Checks for all prerequisites of the po subdirectory.
23AC_DEFUN([AM_PO_SUBDIRS], 23AC_DEFUN([AM_PO_SUBDIRS],
@@ -41,7 +41,7 @@ AC_DEFUN([AM_PO_SUBDIRS],
41 [$ac_dir/$ac_word --statistics /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 && 41 [$ac_dir/$ac_word --statistics /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 &&
42 (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)], 42 (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
43 :) 43 :)
44 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT) 44 AC_PATH_PROG([GMSGFMT], [gmsgfmt], [$MSGFMT])
45 45
46 dnl Test whether it is GNU msgfmt >= 0.15. 46 dnl Test whether it is GNU msgfmt >= 0.15.
47changequote(,)dnl 47changequote(,)dnl
diff --git a/gl/m4/printf-posix.m4 b/gl/m4/printf-posix.m4
index 14ba612..5922d27 100644
--- a/gl/m4/printf-posix.m4
+++ b/gl/m4/printf-posix.m4
@@ -1,5 +1,5 @@
1# printf-posix.m4 serial 3 (gettext-0.17) 1# printf-posix.m4 serial 5 (gettext-0.18)
2dnl Copyright (C) 2003, 2007 Free Software Foundation, Inc. 2dnl Copyright (C) 2003, 2007, 2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -27,17 +27,18 @@ int main ()
27 return (strcmp (buf, "55 33") != 0); 27 return (strcmp (buf, "55 33") != 0);
28}], gt_cv_func_printf_posix=yes, gt_cv_func_printf_posix=no, 28}], gt_cv_func_printf_posix=yes, gt_cv_func_printf_posix=no,
29 [ 29 [
30 AC_EGREP_CPP(notposix, [ 30 AC_EGREP_CPP([notposix], [
31#if defined __NetBSD__ || defined __BEOS__ || defined _MSC_VER || defined __MINGW32__ || defined __CYGWIN__ 31#if defined __NetBSD__ || defined __BEOS__ || defined _MSC_VER || defined __MINGW32__ || defined __CYGWIN__
32 notposix 32 notposix
33#endif 33#endif
34 ], gt_cv_func_printf_posix="guessing no", 34 ],
35 gt_cv_func_printf_posix="guessing yes") 35 [gt_cv_func_printf_posix="guessing no"],
36 [gt_cv_func_printf_posix="guessing yes"])
36 ]) 37 ])
37 ]) 38 ])
38 case $gt_cv_func_printf_posix in 39 case $gt_cv_func_printf_posix in
39 *yes) 40 *yes)
40 AC_DEFINE(HAVE_POSIX_PRINTF, 1, 41 AC_DEFINE([HAVE_POSIX_PRINTF], [1],
41 [Define if your printf() function supports format strings with positions.]) 42 [Define if your printf() function supports format strings with positions.])
42 ;; 43 ;;
43 esac 44 esac
diff --git a/gl/m4/printf.m4 b/gl/m4/printf.m4
new file mode 100644
index 0000000..4d10993
--- /dev/null
+++ b/gl/m4/printf.m4
@@ -0,0 +1,1322 @@
1# printf.m4 serial 26
2dnl Copyright (C) 2003, 2007-2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl Test whether the *printf family of functions supports the 'j', 'z', 't',
8dnl 'L' size specifiers. (ISO C99, POSIX:2001)
9dnl Result is gl_cv_func_printf_sizes_c99.
10
11AC_DEFUN([gl_PRINTF_SIZES_C99],
12[
13 AC_REQUIRE([AC_PROG_CC])
14 AC_REQUIRE([gl_AC_HEADER_STDINT_H])
15 AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
16 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
17 AC_CACHE_CHECK([whether printf supports size specifiers as in C99],
18 [gl_cv_func_printf_sizes_c99],
19 [
20 AC_TRY_RUN([
21#include <stddef.h>
22#include <stdio.h>
23#include <string.h>
24#include <sys/types.h>
25#if HAVE_STDINT_H_WITH_UINTMAX
26# include <stdint.h>
27#endif
28#if HAVE_INTTYPES_H_WITH_UINTMAX
29# include <inttypes.h>
30#endif
31static char buf[100];
32int main ()
33{
34#if HAVE_STDINT_H_WITH_UINTMAX || HAVE_INTTYPES_H_WITH_UINTMAX
35 buf[0] = '\0';
36 if (sprintf (buf, "%ju %d", (uintmax_t) 12345671, 33, 44, 55) < 0
37 || strcmp (buf, "12345671 33") != 0)
38 return 1;
39#endif
40 buf[0] = '\0';
41 if (sprintf (buf, "%zu %d", (size_t) 12345672, 33, 44, 55) < 0
42 || strcmp (buf, "12345672 33") != 0)
43 return 1;
44 buf[0] = '\0';
45 if (sprintf (buf, "%tu %d", (ptrdiff_t) 12345673, 33, 44, 55) < 0
46 || strcmp (buf, "12345673 33") != 0)
47 return 1;
48 buf[0] = '\0';
49 if (sprintf (buf, "%Lg %d", (long double) 1.5, 33, 44, 55) < 0
50 || strcmp (buf, "1.5 33") != 0)
51 return 1;
52 return 0;
53}], [gl_cv_func_printf_sizes_c99=yes], [gl_cv_func_printf_sizes_c99=no],
54 [
55changequote(,)dnl
56 case "$host_os" in
57 # Guess yes on glibc systems.
58 *-gnu*) gl_cv_func_printf_sizes_c99="guessing yes";;
59 # Guess yes on FreeBSD >= 5.
60 freebsd[1-4]*) gl_cv_func_printf_sizes_c99="guessing no";;
61 freebsd* | kfreebsd*) gl_cv_func_printf_sizes_c99="guessing yes";;
62 # Guess yes on MacOS X >= 10.3.
63 darwin[1-6].*) gl_cv_func_printf_sizes_c99="guessing no";;
64 darwin*) gl_cv_func_printf_sizes_c99="guessing yes";;
65 # Guess yes on OpenBSD >= 3.9.
66 openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*)
67 gl_cv_func_printf_sizes_c99="guessing no";;
68 openbsd*) gl_cv_func_printf_sizes_c99="guessing yes";;
69 # Guess yes on Solaris >= 2.10.
70 solaris2.[0-9]*) gl_cv_func_printf_sizes_c99="guessing no";;
71 solaris*) gl_cv_func_printf_sizes_c99="guessing yes";;
72 # Guess yes on NetBSD >= 3.
73 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
74 gl_cv_func_printf_sizes_c99="guessing no";;
75 netbsd*) gl_cv_func_printf_sizes_c99="guessing yes";;
76 # If we don't know, assume the worst.
77 *) gl_cv_func_printf_sizes_c99="guessing no";;
78 esac
79changequote([,])dnl
80 ])
81 ])
82])
83
84dnl Test whether the *printf family of functions supports 'long double'
85dnl arguments together with the 'L' size specifier. (ISO C99, POSIX:2001)
86dnl Result is gl_cv_func_printf_long_double.
87
88AC_DEFUN([gl_PRINTF_LONG_DOUBLE],
89[
90 AC_REQUIRE([AC_PROG_CC])
91 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
92 AC_CACHE_CHECK([whether printf supports 'long double' arguments],
93 [gl_cv_func_printf_long_double],
94 [
95 AC_TRY_RUN([
96#include <stdio.h>
97#include <string.h>
98static char buf[10000];
99int main ()
100{
101 buf[0] = '\0';
102 if (sprintf (buf, "%Lf %d", 1.75L, 33, 44, 55) < 0
103 || strcmp (buf, "1.750000 33") != 0)
104 return 1;
105 buf[0] = '\0';
106 if (sprintf (buf, "%Le %d", 1.75L, 33, 44, 55) < 0
107 || strcmp (buf, "1.750000e+00 33") != 0)
108 return 1;
109 buf[0] = '\0';
110 if (sprintf (buf, "%Lg %d", 1.75L, 33, 44, 55) < 0
111 || strcmp (buf, "1.75 33") != 0)
112 return 1;
113 return 0;
114}], [gl_cv_func_printf_long_double=yes], [gl_cv_func_printf_long_double=no],
115 [
116changequote(,)dnl
117 case "$host_os" in
118 beos*) gl_cv_func_printf_long_double="guessing no";;
119 mingw* | pw*) gl_cv_func_printf_long_double="guessing no";;
120 *) gl_cv_func_printf_long_double="guessing yes";;
121 esac
122changequote([,])dnl
123 ])
124 ])
125])
126
127dnl Test whether the *printf family of functions supports infinite and NaN
128dnl 'double' arguments in the %f, %e, %g directives. (ISO C99, POSIX:2001)
129dnl Result is gl_cv_func_printf_infinite.
130
131AC_DEFUN([gl_PRINTF_INFINITE],
132[
133 AC_REQUIRE([AC_PROG_CC])
134 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
135 AC_CACHE_CHECK([whether printf supports infinite 'double' arguments],
136 [gl_cv_func_printf_infinite],
137 [
138 AC_TRY_RUN([
139#include <stdio.h>
140#include <string.h>
141static int
142strisnan (const char *string, size_t start_index, size_t end_index)
143{
144 if (start_index < end_index)
145 {
146 if (string[start_index] == '-')
147 start_index++;
148 if (start_index + 3 <= end_index
149 && memcmp (string + start_index, "nan", 3) == 0)
150 {
151 start_index += 3;
152 if (start_index == end_index
153 || (string[start_index] == '(' && string[end_index - 1] == ')'))
154 return 1;
155 }
156 }
157 return 0;
158}
159static char buf[10000];
160static double zero = 0.0;
161int main ()
162{
163 if (sprintf (buf, "%f", 1.0 / 0.0) < 0
164 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
165 return 1;
166 if (sprintf (buf, "%f", -1.0 / 0.0) < 0
167 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
168 return 1;
169 if (sprintf (buf, "%f", zero / zero) < 0
170 || !strisnan (buf, 0, strlen (buf)))
171 return 1;
172 if (sprintf (buf, "%e", 1.0 / 0.0) < 0
173 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
174 return 1;
175 if (sprintf (buf, "%e", -1.0 / 0.0) < 0
176 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
177 return 1;
178 if (sprintf (buf, "%e", zero / zero) < 0
179 || !strisnan (buf, 0, strlen (buf)))
180 return 1;
181 if (sprintf (buf, "%g", 1.0 / 0.0) < 0
182 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
183 return 1;
184 if (sprintf (buf, "%g", -1.0 / 0.0) < 0
185 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
186 return 1;
187 if (sprintf (buf, "%g", zero / zero) < 0
188 || !strisnan (buf, 0, strlen (buf)))
189 return 1;
190 return 0;
191}], [gl_cv_func_printf_infinite=yes], [gl_cv_func_printf_infinite=no],
192 [
193changequote(,)dnl
194 case "$host_os" in
195 # Guess yes on glibc systems.
196 *-gnu*) gl_cv_func_printf_infinite="guessing yes";;
197 # Guess yes on FreeBSD >= 6.
198 freebsd[1-5]*) gl_cv_func_printf_infinite="guessing no";;
199 freebsd* | kfreebsd*) gl_cv_func_printf_infinite="guessing yes";;
200 # Guess yes on MacOS X >= 10.3.
201 darwin[1-6].*) gl_cv_func_printf_infinite="guessing no";;
202 darwin*) gl_cv_func_printf_infinite="guessing yes";;
203 # Guess yes on HP-UX >= 11.
204 hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite="guessing no";;
205 hpux*) gl_cv_func_printf_infinite="guessing yes";;
206 # Guess yes on NetBSD >= 3.
207 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
208 gl_cv_func_printf_infinite="guessing no";;
209 netbsd*) gl_cv_func_printf_infinite="guessing yes";;
210 # Guess yes on BeOS.
211 beos*) gl_cv_func_printf_infinite="guessing yes";;
212 # If we don't know, assume the worst.
213 *) gl_cv_func_printf_infinite="guessing no";;
214 esac
215changequote([,])dnl
216 ])
217 ])
218])
219
220dnl Test whether the *printf family of functions supports infinite and NaN
221dnl 'long double' arguments in the %f, %e, %g directives. (ISO C99, POSIX:2001)
222dnl Result is gl_cv_func_printf_infinite_long_double.
223
224AC_DEFUN([gl_PRINTF_INFINITE_LONG_DOUBLE],
225[
226 AC_REQUIRE([gl_PRINTF_LONG_DOUBLE])
227 AC_REQUIRE([AC_PROG_CC])
228 AC_REQUIRE([AC_C_BIGENDIAN])
229 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
230 dnl The user can set or unset the variable gl_printf_safe to indicate
231 dnl that he wishes a safe handling of non-IEEE-754 'long double' values.
232 if test -n "$gl_printf_safe"; then
233 AC_DEFINE([CHECK_PRINTF_SAFE], [1],
234 [Define if you wish *printf() functions that have a safe handling of
235 non-IEEE-754 'long double' values.])
236 fi
237 case "$gl_cv_func_printf_long_double" in
238 *yes)
239 AC_CACHE_CHECK([whether printf supports infinite 'long double' arguments],
240 [gl_cv_func_printf_infinite_long_double],
241 [
242 AC_TRY_RUN([
243]GL_NOCRASH[
244#include <float.h>
245#include <stdio.h>
246#include <string.h>
247static int
248strisnan (const char *string, size_t start_index, size_t end_index)
249{
250 if (start_index < end_index)
251 {
252 if (string[start_index] == '-')
253 start_index++;
254 if (start_index + 3 <= end_index
255 && memcmp (string + start_index, "nan", 3) == 0)
256 {
257 start_index += 3;
258 if (start_index == end_index
259 || (string[start_index] == '(' && string[end_index - 1] == ')'))
260 return 1;
261 }
262 }
263 return 0;
264}
265static char buf[10000];
266static long double zeroL = 0.0L;
267int main ()
268{
269 nocrash_init();
270 if (sprintf (buf, "%Lf", 1.0L / 0.0L) < 0
271 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
272 return 1;
273 if (sprintf (buf, "%Lf", -1.0L / 0.0L) < 0
274 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
275 return 1;
276 if (sprintf (buf, "%Lf", zeroL / zeroL) < 0
277 || !strisnan (buf, 0, strlen (buf)))
278 return 1;
279 if (sprintf (buf, "%Le", 1.0L / 0.0L) < 0
280 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
281 return 1;
282 if (sprintf (buf, "%Le", -1.0L / 0.0L) < 0
283 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
284 return 1;
285 if (sprintf (buf, "%Le", zeroL / zeroL) < 0
286 || !strisnan (buf, 0, strlen (buf)))
287 return 1;
288 if (sprintf (buf, "%Lg", 1.0L / 0.0L) < 0
289 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
290 return 1;
291 if (sprintf (buf, "%Lg", -1.0L / 0.0L) < 0
292 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
293 return 1;
294 if (sprintf (buf, "%Lg", zeroL / zeroL) < 0
295 || !strisnan (buf, 0, strlen (buf)))
296 return 1;
297#if CHECK_PRINTF_SAFE && ((defined __ia64 && LDBL_MANT_DIG == 64) || (defined __x86_64__ || defined __amd64__) || (defined __i386 || defined __i386__ || defined _I386 || defined _M_IX86 || defined _X86_))
298/* Representation of an 80-bit 'long double' as an initializer for a sequence
299 of 'unsigned int' words. */
300# ifdef WORDS_BIGENDIAN
301# define LDBL80_WORDS(exponent,manthi,mantlo) \
302 { ((unsigned int) (exponent) << 16) | ((unsigned int) (manthi) >> 16), \
303 ((unsigned int) (manthi) << 16) | (unsigned int) (mantlo) >> 16), \
304 (unsigned int) (mantlo) << 16 \
305 }
306# else
307# define LDBL80_WORDS(exponent,manthi,mantlo) \
308 { mantlo, manthi, exponent }
309# endif
310 { /* Quiet NaN. */
311 static union { unsigned int word[4]; long double value; } x =
312 { LDBL80_WORDS (0xFFFF, 0xC3333333, 0x00000000) };
313 if (sprintf (buf, "%Lf", x.value) < 0
314 || !strisnan (buf, 0, strlen (buf)))
315 return 1;
316 if (sprintf (buf, "%Le", x.value) < 0
317 || !strisnan (buf, 0, strlen (buf)))
318 return 1;
319 if (sprintf (buf, "%Lg", x.value) < 0
320 || !strisnan (buf, 0, strlen (buf)))
321 return 1;
322 }
323 {
324 /* Signalling NaN. */
325 static union { unsigned int word[4]; long double value; } x =
326 { LDBL80_WORDS (0xFFFF, 0x83333333, 0x00000000) };
327 if (sprintf (buf, "%Lf", x.value) < 0
328 || !strisnan (buf, 0, strlen (buf)))
329 return 1;
330 if (sprintf (buf, "%Le", x.value) < 0
331 || !strisnan (buf, 0, strlen (buf)))
332 return 1;
333 if (sprintf (buf, "%Lg", x.value) < 0
334 || !strisnan (buf, 0, strlen (buf)))
335 return 1;
336 }
337 { /* Pseudo-NaN. */
338 static union { unsigned int word[4]; long double value; } x =
339 { LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) };
340 if (sprintf (buf, "%Lf", x.value) < 0
341 || !strisnan (buf, 0, strlen (buf)))
342 return 1;
343 if (sprintf (buf, "%Le", x.value) < 0
344 || !strisnan (buf, 0, strlen (buf)))
345 return 1;
346 if (sprintf (buf, "%Lg", x.value) < 0
347 || !strisnan (buf, 0, strlen (buf)))
348 return 1;
349 }
350 { /* Pseudo-Infinity. */
351 static union { unsigned int word[4]; long double value; } x =
352 { LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) };
353 if (sprintf (buf, "%Lf", x.value) < 0
354 || !strisnan (buf, 0, strlen (buf)))
355 return 1;
356 if (sprintf (buf, "%Le", x.value) < 0
357 || !strisnan (buf, 0, strlen (buf)))
358 return 1;
359 if (sprintf (buf, "%Lg", x.value) < 0
360 || !strisnan (buf, 0, strlen (buf)))
361 return 1;
362 }
363 { /* Pseudo-Zero. */
364 static union { unsigned int word[4]; long double value; } x =
365 { LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) };
366 if (sprintf (buf, "%Lf", x.value) < 0
367 || !strisnan (buf, 0, strlen (buf)))
368 return 1;
369 if (sprintf (buf, "%Le", x.value) < 0
370 || !strisnan (buf, 0, strlen (buf)))
371 return 1;
372 if (sprintf (buf, "%Lg", x.value) < 0
373 || !strisnan (buf, 0, strlen (buf)))
374 return 1;
375 }
376 { /* Unnormalized number. */
377 static union { unsigned int word[4]; long double value; } x =
378 { LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) };
379 if (sprintf (buf, "%Lf", x.value) < 0
380 || !strisnan (buf, 0, strlen (buf)))
381 return 1;
382 if (sprintf (buf, "%Le", x.value) < 0
383 || !strisnan (buf, 0, strlen (buf)))
384 return 1;
385 if (sprintf (buf, "%Lg", x.value) < 0
386 || !strisnan (buf, 0, strlen (buf)))
387 return 1;
388 }
389 { /* Pseudo-Denormal. */
390 static union { unsigned int word[4]; long double value; } x =
391 { LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) };
392 if (sprintf (buf, "%Lf", x.value) < 0
393 || !strisnan (buf, 0, strlen (buf)))
394 return 1;
395 if (sprintf (buf, "%Le", x.value) < 0
396 || !strisnan (buf, 0, strlen (buf)))
397 return 1;
398 if (sprintf (buf, "%Lg", x.value) < 0
399 || !strisnan (buf, 0, strlen (buf)))
400 return 1;
401 }
402#endif
403 return 0;
404}],
405 [gl_cv_func_printf_infinite_long_double=yes],
406 [gl_cv_func_printf_infinite_long_double=no],
407 [
408changequote(,)dnl
409 case "$host_cpu" in
410 # Guess no on ia64, x86_64, i386.
411 ia64 | x86_64 | i*86) gl_cv_func_printf_infinite_long_double="guessing no";;
412 *)
413 case "$host_os" in
414 # Guess yes on glibc systems.
415 *-gnu*) gl_cv_func_printf_infinite_long_double="guessing yes";;
416 # Guess yes on FreeBSD >= 6.
417 freebsd[1-5]*) gl_cv_func_printf_infinite_long_double="guessing no";;
418 freebsd* | kfreebsd*) gl_cv_func_printf_infinite_long_double="guessing yes";;
419 # Guess yes on MacOS X >= 10.3.
420 darwin[1-6].*) gl_cv_func_printf_infinite_long_double="guessing no";;
421 darwin*) gl_cv_func_printf_infinite_long_double="guessing yes";;
422 # Guess yes on HP-UX >= 11.
423 hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite_long_double="guessing no";;
424 hpux*) gl_cv_func_printf_infinite_long_double="guessing yes";;
425 # Guess yes on NetBSD >= 3.
426 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
427 gl_cv_func_printf_infinite_long_double="guessing no";;
428 netbsd*) gl_cv_func_printf_infinite_long_double="guessing yes";;
429 # If we don't know, assume the worst.
430 *) gl_cv_func_printf_infinite_long_double="guessing no";;
431 esac
432 ;;
433 esac
434changequote([,])dnl
435 ])
436 ])
437 ;;
438 *)
439 gl_cv_func_printf_infinite_long_double="irrelevant"
440 ;;
441 esac
442])
443
444dnl Test whether the *printf family of functions supports the 'a' and 'A'
445dnl conversion specifier for hexadecimal output of floating-point numbers.
446dnl (ISO C99, POSIX:2001)
447dnl Result is gl_cv_func_printf_directive_a.
448
449AC_DEFUN([gl_PRINTF_DIRECTIVE_A],
450[
451 AC_REQUIRE([AC_PROG_CC])
452 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
453 AC_CACHE_CHECK([whether printf supports the 'a' and 'A' directives],
454 [gl_cv_func_printf_directive_a],
455 [
456 AC_TRY_RUN([
457#include <stdio.h>
458#include <string.h>
459static char buf[100];
460int main ()
461{
462 if (sprintf (buf, "%a %d", 3.1416015625, 33, 44, 55) < 0
463 || (strcmp (buf, "0x1.922p+1 33") != 0
464 && strcmp (buf, "0x3.244p+0 33") != 0
465 && strcmp (buf, "0x6.488p-1 33") != 0
466 && strcmp (buf, "0xc.91p-2 33") != 0))
467 return 1;
468 if (sprintf (buf, "%A %d", -3.1416015625, 33, 44, 55) < 0
469 || (strcmp (buf, "-0X1.922P+1 33") != 0
470 && strcmp (buf, "-0X3.244P+0 33") != 0
471 && strcmp (buf, "-0X6.488P-1 33") != 0
472 && strcmp (buf, "-0XC.91P-2 33") != 0))
473 return 1;
474 /* This catches a FreeBSD 6.1 bug: it doesn't round. */
475 if (sprintf (buf, "%.2a %d", 1.51, 33, 44, 55) < 0
476 || (strcmp (buf, "0x1.83p+0 33") != 0
477 && strcmp (buf, "0x3.05p-1 33") != 0
478 && strcmp (buf, "0x6.0ap-2 33") != 0
479 && strcmp (buf, "0xc.14p-3 33") != 0))
480 return 1;
481 /* This catches a FreeBSD 6.1 bug. See
482 <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
483 if (sprintf (buf, "%010a %d", 1.0 / 0.0, 33, 44, 55) < 0
484 || buf[0] == '0')
485 return 1;
486 /* This catches a MacOS X 10.3.9 (Darwin 7.9) bug. */
487 if (sprintf (buf, "%.1a", 1.999) < 0
488 || (strcmp (buf, "0x1.0p+1") != 0
489 && strcmp (buf, "0x2.0p+0") != 0
490 && strcmp (buf, "0x4.0p-1") != 0
491 && strcmp (buf, "0x8.0p-2") != 0))
492 return 1;
493 /* This catches the same MacOS X 10.3.9 (Darwin 7.9) bug and also a
494 glibc 2.4 bug <http://sourceware.org/bugzilla/show_bug.cgi?id=2908>. */
495 if (sprintf (buf, "%.1La", 1.999L) < 0
496 || (strcmp (buf, "0x1.0p+1") != 0
497 && strcmp (buf, "0x2.0p+0") != 0
498 && strcmp (buf, "0x4.0p-1") != 0
499 && strcmp (buf, "0x8.0p-2") != 0))
500 return 1;
501 return 0;
502}], [gl_cv_func_printf_directive_a=yes], [gl_cv_func_printf_directive_a=no],
503 [
504 case "$host_os" in
505 # Guess yes on glibc >= 2.5 systems.
506 *-gnu*)
507 AC_EGREP_CPP([BZ2908], [
508 #include <features.h>
509 #ifdef __GNU_LIBRARY__
510 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 5) || (__GLIBC__ > 2)
511 BZ2908
512 #endif
513 #endif
514 ],
515 [gl_cv_func_printf_directive_a="guessing yes"],
516 [gl_cv_func_printf_directive_a="guessing no"])
517 ;;
518 # If we don't know, assume the worst.
519 *) gl_cv_func_printf_directive_a="guessing no";;
520 esac
521 ])
522 ])
523])
524
525dnl Test whether the *printf family of functions supports the %F format
526dnl directive. (ISO C99, POSIX:2001)
527dnl Result is gl_cv_func_printf_directive_f.
528
529AC_DEFUN([gl_PRINTF_DIRECTIVE_F],
530[
531 AC_REQUIRE([AC_PROG_CC])
532 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
533 AC_CACHE_CHECK([whether printf supports the 'F' directive],
534 [gl_cv_func_printf_directive_f],
535 [
536 AC_TRY_RUN([
537#include <stdio.h>
538#include <string.h>
539static char buf[100];
540int main ()
541{
542 if (sprintf (buf, "%F %d", 1234567.0, 33, 44, 55) < 0
543 || strcmp (buf, "1234567.000000 33") != 0)
544 return 1;
545 if (sprintf (buf, "%F", 1.0 / 0.0) < 0
546 || (strcmp (buf, "INF") != 0 && strcmp (buf, "INFINITY") != 0))
547 return 1;
548 /* This catches a Cygwin 2007 bug. */
549 if (sprintf (buf, "%.F", 1234.0) < 0
550 || strcmp (buf, "1234") != 0)
551 return 1;
552 return 0;
553}], [gl_cv_func_printf_directive_f=yes], [gl_cv_func_printf_directive_f=no],
554 [
555changequote(,)dnl
556 case "$host_os" in
557 # Guess yes on glibc systems.
558 *-gnu*) gl_cv_func_printf_directive_f="guessing yes";;
559 # Guess yes on FreeBSD >= 6.
560 freebsd[1-5]*) gl_cv_func_printf_directive_f="guessing no";;
561 freebsd* | kfreebsd*) gl_cv_func_printf_directive_f="guessing yes";;
562 # Guess yes on MacOS X >= 10.3.
563 darwin[1-6].*) gl_cv_func_printf_directive_f="guessing no";;
564 darwin*) gl_cv_func_printf_directive_f="guessing yes";;
565 # Guess yes on Solaris >= 2.10.
566 solaris2.[0-9]*) gl_cv_func_printf_directive_f="guessing no";;
567 solaris*) gl_cv_func_printf_directive_f="guessing yes";;
568 # If we don't know, assume the worst.
569 *) gl_cv_func_printf_directive_f="guessing no";;
570 esac
571changequote([,])dnl
572 ])
573 ])
574])
575
576dnl Test whether the *printf family of functions supports the %n format
577dnl directive. (ISO C99, POSIX:2001)
578dnl Result is gl_cv_func_printf_directive_n.
579
580AC_DEFUN([gl_PRINTF_DIRECTIVE_N],
581[
582 AC_REQUIRE([AC_PROG_CC])
583 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
584 AC_CACHE_CHECK([whether printf supports the 'n' directive],
585 [gl_cv_func_printf_directive_n],
586 [
587 AC_TRY_RUN([
588#include <stdio.h>
589#include <string.h>
590static char fmtstring[10];
591static char buf[100];
592int main ()
593{
594 int count = -1;
595 /* Copy the format string. Some systems (glibc with _FORTIFY_SOURCE=2)
596 support %n in format strings in read-only memory but not in writable
597 memory. */
598 strcpy (fmtstring, "%d %n");
599 if (sprintf (buf, fmtstring, 123, &count, 33, 44, 55) < 0
600 || strcmp (buf, "123 ") != 0
601 || count != 4)
602 return 1;
603 return 0;
604}], [gl_cv_func_printf_directive_n=yes], [gl_cv_func_printf_directive_n=no],
605 [
606changequote(,)dnl
607 case "$host_os" in
608 *) gl_cv_func_printf_directive_n="guessing yes";;
609 esac
610changequote([,])dnl
611 ])
612 ])
613])
614
615dnl Test whether the *printf family of functions supports POSIX/XSI format
616dnl strings with positions. (POSIX:2001)
617dnl Result is gl_cv_func_printf_positions.
618
619AC_DEFUN([gl_PRINTF_POSITIONS],
620[
621 AC_REQUIRE([AC_PROG_CC])
622 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
623 AC_CACHE_CHECK([whether printf supports POSIX/XSI format strings with positions],
624 [gl_cv_func_printf_positions],
625 [
626 AC_TRY_RUN([
627#include <stdio.h>
628#include <string.h>
629/* The string "%2$d %1$d", with dollar characters protected from the shell's
630 dollar expansion (possibly an autoconf bug). */
631static char format[] = { '%', '2', '$', 'd', ' ', '%', '1', '$', 'd', '\0' };
632static char buf[100];
633int main ()
634{
635 sprintf (buf, format, 33, 55);
636 return (strcmp (buf, "55 33") != 0);
637}], [gl_cv_func_printf_positions=yes], [gl_cv_func_printf_positions=no],
638 [
639changequote(,)dnl
640 case "$host_os" in
641 netbsd[1-3]* | netbsdelf[1-3]* | netbsdaout[1-3]* | netbsdcoff[1-3]*)
642 gl_cv_func_printf_positions="guessing no";;
643 beos*) gl_cv_func_printf_positions="guessing no";;
644 mingw* | pw*) gl_cv_func_printf_positions="guessing no";;
645 *) gl_cv_func_printf_positions="guessing yes";;
646 esac
647changequote([,])dnl
648 ])
649 ])
650])
651
652dnl Test whether the *printf family of functions supports POSIX/XSI format
653dnl strings with the ' flag for grouping of decimal digits. (POSIX:2001)
654dnl Result is gl_cv_func_printf_flag_grouping.
655
656AC_DEFUN([gl_PRINTF_FLAG_GROUPING],
657[
658 AC_REQUIRE([AC_PROG_CC])
659 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
660 AC_CACHE_CHECK([whether printf supports the grouping flag],
661 [gl_cv_func_printf_flag_grouping],
662 [
663 AC_TRY_RUN([
664#include <stdio.h>
665#include <string.h>
666static char buf[100];
667int main ()
668{
669 if (sprintf (buf, "%'d %d", 1234567, 99) < 0
670 || buf[strlen (buf) - 1] != '9')
671 return 1;
672 return 0;
673}], [gl_cv_func_printf_flag_grouping=yes], [gl_cv_func_printf_flag_grouping=no],
674 [
675changequote(,)dnl
676 case "$host_os" in
677 cygwin*) gl_cv_func_printf_flag_grouping="guessing no";;
678 netbsd*) gl_cv_func_printf_flag_grouping="guessing no";;
679 mingw* | pw*) gl_cv_func_printf_flag_grouping="guessing no";;
680 *) gl_cv_func_printf_flag_grouping="guessing yes";;
681 esac
682changequote([,])dnl
683 ])
684 ])
685])
686
687dnl Test whether the *printf family of functions supports the - flag correctly.
688dnl (ISO C99.) See
689dnl <http://lists.gnu.org/archive/html/bug-coreutils/2008-02/msg00035.html>
690dnl Result is gl_cv_func_printf_flag_leftadjust.
691
692AC_DEFUN([gl_PRINTF_FLAG_LEFTADJUST],
693[
694 AC_REQUIRE([AC_PROG_CC])
695 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
696 AC_CACHE_CHECK([whether printf supports the left-adjust flag correctly],
697 [gl_cv_func_printf_flag_leftadjust],
698 [
699 AC_TRY_RUN([
700#include <stdio.h>
701#include <string.h>
702static char buf[100];
703int main ()
704{
705 /* Check that a '-' flag is not annihilated by a negative width. */
706 if (sprintf (buf, "a%-*sc", -3, "b") < 0
707 || strcmp (buf, "ab c") != 0)
708 return 1;
709 return 0;
710}],
711 [gl_cv_func_printf_flag_leftadjust=yes],
712 [gl_cv_func_printf_flag_leftadjust=no],
713 [
714changequote(,)dnl
715 case "$host_os" in
716 # Guess yes on HP-UX 11.
717 hpux11*) gl_cv_func_printf_flag_leftadjust="guessing yes";;
718 # Guess no on HP-UX 10 and older.
719 hpux*) gl_cv_func_printf_flag_leftadjust="guessing no";;
720 # Guess yes otherwise.
721 *) gl_cv_func_printf_flag_leftadjust="guessing yes";;
722 esac
723changequote([,])dnl
724 ])
725 ])
726])
727
728dnl Test whether the *printf family of functions supports padding of non-finite
729dnl values with the 0 flag correctly. (ISO C99 + TC1 + TC2.) See
730dnl <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html>
731dnl Result is gl_cv_func_printf_flag_zero.
732
733AC_DEFUN([gl_PRINTF_FLAG_ZERO],
734[
735 AC_REQUIRE([AC_PROG_CC])
736 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
737 AC_CACHE_CHECK([whether printf supports the zero flag correctly],
738 [gl_cv_func_printf_flag_zero],
739 [
740 AC_TRY_RUN([
741#include <stdio.h>
742#include <string.h>
743static char buf[100];
744int main ()
745{
746 if (sprintf (buf, "%010f", 1.0 / 0.0, 33, 44, 55) < 0
747 || (strcmp (buf, " inf") != 0
748 && strcmp (buf, " infinity") != 0))
749 return 1;
750 return 0;
751}], [gl_cv_func_printf_flag_zero=yes], [gl_cv_func_printf_flag_zero=no],
752 [
753changequote(,)dnl
754 case "$host_os" in
755 # Guess yes on glibc systems.
756 *-gnu*) gl_cv_func_printf_flag_zero="guessing yes";;
757 # Guess yes on BeOS.
758 beos*) gl_cv_func_printf_flag_zero="guessing yes";;
759 # If we don't know, assume the worst.
760 *) gl_cv_func_printf_flag_zero="guessing no";;
761 esac
762changequote([,])dnl
763 ])
764 ])
765])
766
767dnl Test whether the *printf family of functions supports large precisions.
768dnl On mingw, precisions larger than 512 are treated like 512, in integer,
769dnl floating-point or pointer output. On BeOS, precisions larger than 1044
770dnl crash the program.
771dnl Result is gl_cv_func_printf_precision.
772
773AC_DEFUN([gl_PRINTF_PRECISION],
774[
775 AC_REQUIRE([AC_PROG_CC])
776 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
777 AC_CACHE_CHECK([whether printf supports large precisions],
778 [gl_cv_func_printf_precision],
779 [
780 AC_TRY_RUN([
781#include <stdio.h>
782#include <string.h>
783static char buf[5000];
784int main ()
785{
786#ifdef __BEOS__
787 /* On BeOS, this would crash and show a dialog box. Avoid the crash. */
788 return 1;
789#endif
790 if (sprintf (buf, "%.4000d %d", 1, 33, 44) < 4000 + 3)
791 return 1;
792 return 0;
793}], [gl_cv_func_printf_precision=yes], [gl_cv_func_printf_precision=no],
794 [
795changequote(,)dnl
796 case "$host_os" in
797 # Guess no only on native Win32 and BeOS systems.
798 mingw* | pw*) gl_cv_func_printf_precision="guessing no" ;;
799 beos*) gl_cv_func_printf_precision="guessing no" ;;
800 *) gl_cv_func_printf_precision="guessing yes" ;;
801 esac
802changequote([,])dnl
803 ])
804 ])
805])
806
807dnl Test whether the *printf family of functions recovers gracefully in case
808dnl of an out-of-memory condition, or whether it crashes the entire program.
809dnl Result is gl_cv_func_printf_enomem.
810
811AC_DEFUN([gl_PRINTF_ENOMEM],
812[
813 AC_REQUIRE([AC_PROG_CC])
814 AC_REQUIRE([gl_MULTIARCH])
815 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
816 AC_CACHE_CHECK([whether printf survives out-of-memory conditions],
817 [gl_cv_func_printf_enomem],
818 [
819 gl_cv_func_printf_enomem="guessing no"
820 if test "$cross_compiling" = no; then
821 if test $APPLE_UNIVERSAL_BUILD = 0; then
822 AC_LANG_CONFTEST([AC_LANG_SOURCE([
823]GL_NOCRASH[
824changequote(,)dnl
825#include <stdio.h>
826#include <sys/types.h>
827#include <sys/time.h>
828#include <sys/resource.h>
829#include <errno.h>
830int main()
831{
832 struct rlimit limit;
833 int ret;
834 nocrash_init ();
835 /* Some printf implementations allocate temporary space with malloc. */
836 /* On BSD systems, malloc() is limited by RLIMIT_DATA. */
837#ifdef RLIMIT_DATA
838 if (getrlimit (RLIMIT_DATA, &limit) < 0)
839 return 77;
840 if (limit.rlim_max == RLIM_INFINITY || limit.rlim_max > 5000000)
841 limit.rlim_max = 5000000;
842 limit.rlim_cur = limit.rlim_max;
843 if (setrlimit (RLIMIT_DATA, &limit) < 0)
844 return 77;
845#endif
846 /* On Linux systems, malloc() is limited by RLIMIT_AS. */
847#ifdef RLIMIT_AS
848 if (getrlimit (RLIMIT_AS, &limit) < 0)
849 return 77;
850 if (limit.rlim_max == RLIM_INFINITY || limit.rlim_max > 5000000)
851 limit.rlim_max = 5000000;
852 limit.rlim_cur = limit.rlim_max;
853 if (setrlimit (RLIMIT_AS, &limit) < 0)
854 return 77;
855#endif
856 /* Some printf implementations allocate temporary space on the stack. */
857#ifdef RLIMIT_STACK
858 if (getrlimit (RLIMIT_STACK, &limit) < 0)
859 return 77;
860 if (limit.rlim_max == RLIM_INFINITY || limit.rlim_max > 5000000)
861 limit.rlim_max = 5000000;
862 limit.rlim_cur = limit.rlim_max;
863 if (setrlimit (RLIMIT_STACK, &limit) < 0)
864 return 77;
865#endif
866 ret = printf ("%.5000000f", 1.0);
867 return !(ret == 5000002 || (ret < 0 && errno == ENOMEM));
868}
869changequote([,])dnl
870 ])])
871 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
872 (./conftest
873 result=$?
874 if test $result != 0 && test $result != 77; then result=1; fi
875 exit $result
876 ) >/dev/null 2>/dev/null
877 case $? in
878 0) gl_cv_func_printf_enomem="yes" ;;
879 77) gl_cv_func_printf_enomem="guessing no" ;;
880 *) gl_cv_func_printf_enomem="no" ;;
881 esac
882 else
883 gl_cv_func_printf_enomem="guessing no"
884 fi
885 rm -fr conftest*
886 else
887 dnl A universal build on Apple MacOS X platforms.
888 dnl The result would be 'no' in 32-bit mode and 'yes' in 64-bit mode.
889 dnl But we need a configuration result that is valid in both modes.
890 gl_cv_func_printf_enomem="guessing no"
891 fi
892 fi
893 if test "$gl_cv_func_printf_enomem" = "guessing no"; then
894changequote(,)dnl
895 case "$host_os" in
896 # Guess yes on glibc systems.
897 *-gnu*) gl_cv_func_printf_enomem="guessing yes";;
898 # Guess yes on Solaris.
899 solaris*) gl_cv_func_printf_enomem="guessing yes";;
900 # Guess yes on AIX.
901 aix*) gl_cv_func_printf_enomem="guessing yes";;
902 # Guess yes on HP-UX/hppa.
903 hpux*) case "$host_cpu" in
904 hppa*) gl_cv_func_printf_enomem="guessing yes";;
905 *) gl_cv_func_printf_enomem="guessing no";;
906 esac
907 ;;
908 # Guess yes on IRIX.
909 irix*) gl_cv_func_printf_enomem="guessing yes";;
910 # Guess yes on OSF/1.
911 osf*) gl_cv_func_printf_enomem="guessing yes";;
912 # Guess yes on BeOS.
913 beos*) gl_cv_func_printf_enomem="guessing yes";;
914 # Guess yes on Haiku.
915 haiku*) gl_cv_func_printf_enomem="guessing yes";;
916 # If we don't know, assume the worst.
917 *) gl_cv_func_printf_enomem="guessing no";;
918 esac
919changequote([,])dnl
920 fi
921 ])
922])
923
924dnl Test whether the snprintf function exists. (ISO C99, POSIX:2001)
925dnl Result is ac_cv_func_snprintf.
926
927AC_DEFUN([gl_SNPRINTF_PRESENCE],
928[
929 AC_CHECK_FUNCS_ONCE([snprintf])
930])
931
932dnl Test whether the string produced by the snprintf function is always NUL
933dnl terminated. (ISO C99, POSIX:2001)
934dnl Result is gl_cv_func_snprintf_truncation_c99.
935
936AC_DEFUN([gl_SNPRINTF_TRUNCATION_C99],
937[
938 AC_REQUIRE([AC_PROG_CC])
939 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
940 AC_CACHE_CHECK([whether snprintf truncates the result as in C99],
941 [gl_cv_func_snprintf_truncation_c99],
942 [
943 AC_TRY_RUN([
944#include <stdio.h>
945#include <string.h>
946static char buf[100];
947int main ()
948{
949 strcpy (buf, "ABCDEF");
950 snprintf (buf, 3, "%d %d", 4567, 89);
951 if (memcmp (buf, "45\0DEF", 6) != 0)
952 return 1;
953 return 0;
954}], [gl_cv_func_snprintf_truncation_c99=yes], [gl_cv_func_snprintf_truncation_c99=no],
955 [
956changequote(,)dnl
957 case "$host_os" in
958 # Guess yes on glibc systems.
959 *-gnu*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
960 # Guess yes on FreeBSD >= 5.
961 freebsd[1-4]*) gl_cv_func_snprintf_truncation_c99="guessing no";;
962 freebsd* | kfreebsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
963 # Guess yes on MacOS X >= 10.3.
964 darwin[1-6].*) gl_cv_func_snprintf_truncation_c99="guessing no";;
965 darwin*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
966 # Guess yes on OpenBSD >= 3.9.
967 openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*)
968 gl_cv_func_snprintf_truncation_c99="guessing no";;
969 openbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
970 # Guess yes on Solaris >= 2.6.
971 solaris2.[0-5]*) gl_cv_func_snprintf_truncation_c99="guessing no";;
972 solaris*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
973 # Guess yes on AIX >= 4.
974 aix[1-3]*) gl_cv_func_snprintf_truncation_c99="guessing no";;
975 aix*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
976 # Guess yes on HP-UX >= 11.
977 hpux[7-9]* | hpux10*) gl_cv_func_snprintf_truncation_c99="guessing no";;
978 hpux*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
979 # Guess yes on IRIX >= 6.5.
980 irix6.5) gl_cv_func_snprintf_truncation_c99="guessing yes";;
981 # Guess yes on OSF/1 >= 5.
982 osf[3-4]*) gl_cv_func_snprintf_truncation_c99="guessing no";;
983 osf*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
984 # Guess yes on NetBSD >= 3.
985 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
986 gl_cv_func_snprintf_truncation_c99="guessing no";;
987 netbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
988 # Guess yes on BeOS.
989 beos*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
990 # If we don't know, assume the worst.
991 *) gl_cv_func_snprintf_truncation_c99="guessing no";;
992 esac
993changequote([,])dnl
994 ])
995 ])
996])
997
998dnl Test whether the return value of the snprintf function is the number
999dnl of bytes (excluding the terminating NUL) that would have been produced
1000dnl if the buffer had been large enough. (ISO C99, POSIX:2001)
1001dnl For example, this test program fails on IRIX 6.5:
1002dnl ---------------------------------------------------------------------
1003dnl #include <stdio.h>
1004dnl int main()
1005dnl {
1006dnl static char buf[8];
1007dnl int retval = snprintf (buf, 3, "%d", 12345);
1008dnl return retval >= 0 && retval < 3;
1009dnl }
1010dnl ---------------------------------------------------------------------
1011dnl Result is gl_cv_func_snprintf_retval_c99.
1012
1013AC_DEFUN([gl_SNPRINTF_RETVAL_C99],
1014[
1015 AC_REQUIRE([AC_PROG_CC])
1016 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
1017 AC_CACHE_CHECK([whether snprintf returns a byte count as in C99],
1018 [gl_cv_func_snprintf_retval_c99],
1019 [
1020 AC_TRY_RUN([
1021#include <stdio.h>
1022#include <string.h>
1023static char buf[100];
1024int main ()
1025{
1026 strcpy (buf, "ABCDEF");
1027 if (snprintf (buf, 3, "%d %d", 4567, 89) != 7)
1028 return 1;
1029 return 0;
1030}], [gl_cv_func_snprintf_retval_c99=yes], [gl_cv_func_snprintf_retval_c99=no],
1031 [
1032changequote(,)dnl
1033 case "$host_os" in
1034 # Guess yes on glibc systems.
1035 *-gnu*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1036 # Guess yes on FreeBSD >= 5.
1037 freebsd[1-4]*) gl_cv_func_snprintf_retval_c99="guessing no";;
1038 freebsd* | kfreebsd*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1039 # Guess yes on MacOS X >= 10.3.
1040 darwin[1-6].*) gl_cv_func_snprintf_retval_c99="guessing no";;
1041 darwin*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1042 # Guess yes on OpenBSD >= 3.9.
1043 openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*)
1044 gl_cv_func_snprintf_retval_c99="guessing no";;
1045 openbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1046 # Guess yes on Solaris >= 2.6.
1047 solaris2.[0-5]*) gl_cv_func_snprintf_retval_c99="guessing no";;
1048 solaris*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1049 # Guess yes on AIX >= 4.
1050 aix[1-3]*) gl_cv_func_snprintf_retval_c99="guessing no";;
1051 aix*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1052 # Guess yes on NetBSD >= 3.
1053 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
1054 gl_cv_func_snprintf_retval_c99="guessing no";;
1055 netbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1056 # Guess yes on BeOS.
1057 beos*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1058 # If we don't know, assume the worst.
1059 *) gl_cv_func_snprintf_retval_c99="guessing no";;
1060 esac
1061changequote([,])dnl
1062 ])
1063 ])
1064])
1065
1066dnl Test whether the snprintf function supports the %n format directive
1067dnl also in truncated portions of the format string. (ISO C99, POSIX:2001)
1068dnl Result is gl_cv_func_snprintf_directive_n.
1069
1070AC_DEFUN([gl_SNPRINTF_DIRECTIVE_N],
1071[
1072 AC_REQUIRE([AC_PROG_CC])
1073 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
1074 AC_CACHE_CHECK([whether snprintf fully supports the 'n' directive],
1075 [gl_cv_func_snprintf_directive_n],
1076 [
1077 AC_TRY_RUN([
1078#include <stdio.h>
1079#include <string.h>
1080static char fmtstring[10];
1081static char buf[100];
1082int main ()
1083{
1084 int count = -1;
1085 /* Copy the format string. Some systems (glibc with _FORTIFY_SOURCE=2)
1086 support %n in format strings in read-only memory but not in writable
1087 memory. */
1088 strcpy (fmtstring, "%d %n");
1089 snprintf (buf, 4, fmtstring, 12345, &count, 33, 44, 55);
1090 if (count != 6)
1091 return 1;
1092 return 0;
1093}], [gl_cv_func_snprintf_directive_n=yes], [gl_cv_func_snprintf_directive_n=no],
1094 [
1095changequote(,)dnl
1096 case "$host_os" in
1097 # Guess yes on glibc systems.
1098 *-gnu*) gl_cv_func_snprintf_directive_n="guessing yes";;
1099 # Guess yes on FreeBSD >= 5.
1100 freebsd[1-4]*) gl_cv_func_snprintf_directive_n="guessing no";;
1101 freebsd* | kfreebsd*) gl_cv_func_snprintf_directive_n="guessing yes";;
1102 # Guess yes on MacOS X >= 10.3.
1103 darwin[1-6].*) gl_cv_func_snprintf_directive_n="guessing no";;
1104 darwin*) gl_cv_func_snprintf_directive_n="guessing yes";;
1105 # Guess yes on Solaris >= 2.6.
1106 solaris2.[0-5]*) gl_cv_func_snprintf_directive_n="guessing no";;
1107 solaris*) gl_cv_func_snprintf_directive_n="guessing yes";;
1108 # Guess yes on AIX >= 4.
1109 aix[1-3]*) gl_cv_func_snprintf_directive_n="guessing no";;
1110 aix*) gl_cv_func_snprintf_directive_n="guessing yes";;
1111 # Guess yes on IRIX >= 6.5.
1112 irix6.5) gl_cv_func_snprintf_directive_n="guessing yes";;
1113 # Guess yes on OSF/1 >= 5.
1114 osf[3-4]*) gl_cv_func_snprintf_directive_n="guessing no";;
1115 osf*) gl_cv_func_snprintf_directive_n="guessing yes";;
1116 # Guess yes on NetBSD >= 3.
1117 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
1118 gl_cv_func_snprintf_directive_n="guessing no";;
1119 netbsd*) gl_cv_func_snprintf_directive_n="guessing yes";;
1120 # Guess yes on BeOS.
1121 beos*) gl_cv_func_snprintf_directive_n="guessing yes";;
1122 # If we don't know, assume the worst.
1123 *) gl_cv_func_snprintf_directive_n="guessing no";;
1124 esac
1125changequote([,])dnl
1126 ])
1127 ])
1128])
1129
1130dnl Test whether the snprintf function, when passed a size = 1, writes any
1131dnl output without bounds in this case, behaving like sprintf. This is the
1132dnl case on Linux libc5.
1133dnl Result is gl_cv_func_snprintf_size1.
1134
1135AC_DEFUN([gl_SNPRINTF_SIZE1],
1136[
1137 AC_REQUIRE([AC_PROG_CC])
1138 AC_CACHE_CHECK([whether snprintf respects a size of 1],
1139 [gl_cv_func_snprintf_size1],
1140 [
1141 AC_TRY_RUN([
1142#include <stdio.h>
1143int main()
1144{
1145 static char buf[8] = "DEADBEEF";
1146 snprintf (buf, 1, "%d", 12345);
1147 return buf[1] != 'E';
1148}],
1149 [gl_cv_func_snprintf_size1=yes],
1150 [gl_cv_func_snprintf_size1=no],
1151 [gl_cv_func_snprintf_size1="guessing yes"])
1152 ])
1153])
1154
1155dnl Test whether the vsnprintf function, when passed a zero size, produces no
1156dnl output. (ISO C99, POSIX:2001)
1157dnl For example, snprintf nevertheless writes a NUL byte in this case
1158dnl on OSF/1 5.1:
1159dnl ---------------------------------------------------------------------
1160dnl #include <stdio.h>
1161dnl int main()
1162dnl {
1163dnl static char buf[8] = "DEADBEEF";
1164dnl snprintf (buf, 0, "%d", 12345);
1165dnl return buf[0] != 'D';
1166dnl }
1167dnl ---------------------------------------------------------------------
1168dnl And vsnprintf writes any output without bounds in this case, behaving like
1169dnl vsprintf, on HP-UX 11 and OSF/1 5.1:
1170dnl ---------------------------------------------------------------------
1171dnl #include <stdarg.h>
1172dnl #include <stdio.h>
1173dnl static int my_snprintf (char *buf, int size, const char *format, ...)
1174dnl {
1175dnl va_list args;
1176dnl int ret;
1177dnl va_start (args, format);
1178dnl ret = vsnprintf (buf, size, format, args);
1179dnl va_end (args);
1180dnl return ret;
1181dnl }
1182dnl int main()
1183dnl {
1184dnl static char buf[8] = "DEADBEEF";
1185dnl my_snprintf (buf, 0, "%d", 12345);
1186dnl return buf[0] != 'D';
1187dnl }
1188dnl ---------------------------------------------------------------------
1189dnl Result is gl_cv_func_vsnprintf_zerosize_c99.
1190
1191AC_DEFUN([gl_VSNPRINTF_ZEROSIZE_C99],
1192[
1193 AC_REQUIRE([AC_PROG_CC])
1194 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
1195 AC_CACHE_CHECK([whether vsnprintf respects a zero size as in C99],
1196 [gl_cv_func_vsnprintf_zerosize_c99],
1197 [
1198 AC_TRY_RUN([
1199#include <stdarg.h>
1200#include <stdio.h>
1201static int my_snprintf (char *buf, int size, const char *format, ...)
1202{
1203 va_list args;
1204 int ret;
1205 va_start (args, format);
1206 ret = vsnprintf (buf, size, format, args);
1207 va_end (args);
1208 return ret;
1209}
1210int main()
1211{
1212 static char buf[8] = "DEADBEEF";
1213 my_snprintf (buf, 0, "%d", 12345);
1214 return buf[0] != 'D';
1215}],
1216 [gl_cv_func_vsnprintf_zerosize_c99=yes],
1217 [gl_cv_func_vsnprintf_zerosize_c99=no],
1218 [
1219changequote(,)dnl
1220 case "$host_os" in
1221 # Guess yes on glibc systems.
1222 *-gnu*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1223 # Guess yes on FreeBSD >= 5.
1224 freebsd[1-4]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
1225 freebsd* | kfreebsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1226 # Guess yes on MacOS X >= 10.3.
1227 darwin[1-6].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
1228 darwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1229 # Guess yes on Cygwin.
1230 cygwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1231 # Guess yes on Solaris >= 2.6.
1232 solaris2.[0-5]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
1233 solaris*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1234 # Guess yes on AIX >= 4.
1235 aix[1-3]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
1236 aix*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1237 # Guess yes on IRIX >= 6.5.
1238 irix6.5) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1239 # Guess yes on NetBSD >= 3.
1240 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
1241 gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
1242 netbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1243 # Guess yes on BeOS.
1244 beos*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1245 # Guess yes on mingw.
1246 mingw* | pw*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1247 # If we don't know, assume the worst.
1248 *) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
1249 esac
1250changequote([,])dnl
1251 ])
1252 ])
1253])
1254
1255dnl The results of these tests on various platforms are:
1256dnl
1257dnl 1 = gl_PRINTF_SIZES_C99
1258dnl 2 = gl_PRINTF_LONG_DOUBLE
1259dnl 3 = gl_PRINTF_INFINITE
1260dnl 4 = gl_PRINTF_INFINITE_LONG_DOUBLE
1261dnl 5 = gl_PRINTF_DIRECTIVE_A
1262dnl 6 = gl_PRINTF_DIRECTIVE_F
1263dnl 7 = gl_PRINTF_DIRECTIVE_N
1264dnl 8 = gl_PRINTF_POSITIONS
1265dnl 9 = gl_PRINTF_FLAG_GROUPING
1266dnl 10 = gl_PRINTF_FLAG_LEFTADJUST
1267dnl 11 = gl_PRINTF_FLAG_ZERO
1268dnl 12 = gl_PRINTF_PRECISION
1269dnl 13 = gl_PRINTF_ENOMEM
1270dnl 14 = gl_SNPRINTF_PRESENCE
1271dnl 15 = gl_SNPRINTF_TRUNCATION_C99
1272dnl 16 = gl_SNPRINTF_RETVAL_C99
1273dnl 17 = gl_SNPRINTF_DIRECTIVE_N
1274dnl 18 = gl_SNPRINTF_SIZE1
1275dnl 19 = gl_VSNPRINTF_ZEROSIZE_C99
1276dnl
1277dnl 1 = checking whether printf supports size specifiers as in C99...
1278dnl 2 = checking whether printf supports 'long double' arguments...
1279dnl 3 = checking whether printf supports infinite 'double' arguments...
1280dnl 4 = checking whether printf supports infinite 'long double' arguments...
1281dnl 5 = checking whether printf supports the 'a' and 'A' directives...
1282dnl 6 = checking whether printf supports the 'F' directive...
1283dnl 7 = checking whether printf supports the 'n' directive...
1284dnl 8 = checking whether printf supports POSIX/XSI format strings with positions...
1285dnl 9 = checking whether printf supports the grouping flag...
1286dnl 10 = checking whether printf supports the left-adjust flag correctly...
1287dnl 11 = checking whether printf supports the zero flag correctly...
1288dnl 12 = checking whether printf supports large precisions...
1289dnl 13 = checking whether printf survives out-of-memory conditions...
1290dnl 14 = checking for snprintf...
1291dnl 15 = checking whether snprintf truncates the result as in C99...
1292dnl 16 = checking whether snprintf returns a byte count as in C99...
1293dnl 17 = checking whether snprintf fully supports the 'n' directive...
1294dnl 18 = checking whether snprintf respects a size of 1...
1295dnl 19 = checking whether vsnprintf respects a zero size as in C99...
1296dnl
1297dnl . = yes, # = no.
1298dnl
1299dnl 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
1300dnl glibc 2.5 . . . . . . . . . . . . . . . . . . .
1301dnl glibc 2.3.6 . . . . # . . . . . . . . . . . . . .
1302dnl FreeBSD 5.4, 6.1 . . . . # . . . . . # . # . . . . . .
1303dnl MacOS X 10.3.9 . . . . # . . . . . # . # . . . . . .
1304dnl OpenBSD 3.9, 4.0 . . # # # # . . # . # . # . . . . . .
1305dnl Cygwin 2007 (= Cygwin 1.5.24) . . . . # # . . . ? # ? ? . . . . . .
1306dnl Cygwin 2006 (= Cygwin 1.5.19) # . . . # # . . # ? # ? ? . . . . . .
1307dnl Solaris 10 . . # # # . . . . . # . . . . . . . .
1308dnl Solaris 2.6 ... 9 # . # # # # . . . . # . . . . . . . .
1309dnl Solaris 2.5.1 # . # # # # . . . . # . . # # # # # #
1310dnl AIX 5.2 . . # # # . . . . . # . . . . . . . .
1311dnl AIX 4.3.2, 5.1 # . # # # # . . . . # . . . . . . . .
1312dnl HP-UX 11.31 . . . . # . . . . . # . . . . # # . .
1313dnl HP-UX 11.{00,11,23} # . . . # # . . . . # . . . . # # . #
1314dnl HP-UX 10.20 # . . . # # . . . # # . . . . # # ? #
1315dnl IRIX 6.5 # . # # # # . . . . # . . . . # . . .
1316dnl OSF/1 5.1 # . # # # # . . . . # . . . . # . . #
1317dnl OSF/1 4.0d # . # # # # . . . . # . . # # # # # #
1318dnl NetBSD 4.0 . ? ? ? ? ? . . ? ? ? ? ? . . . ? ? ?
1319dnl NetBSD 3.0 . . . . # # . # # ? # . # . . . . . .
1320dnl Haiku . . . # # # . . . . . . ? . . . . . .
1321dnl BeOS # # . # # # . # . ? . # ? . . . . . .
1322dnl mingw # # # # # # . # # . # # ? . # # # . .
diff --git a/gl/m4/progtest.m4 b/gl/m4/progtest.m4
index a56365c..e1d445d 100644
--- a/gl/m4/progtest.m4
+++ b/gl/m4/progtest.m4
@@ -1,5 +1,5 @@
1# progtest.m4 serial 4 (gettext-0.14.2) 1# progtest.m4 serial 6 (gettext-0.18)
2dnl Copyright (C) 1996-2003, 2005 Free Software Foundation, Inc. 2dnl Copyright (C) 1996-2003, 2005, 2008, 2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -16,7 +16,7 @@ dnl They are *not* in the public domain.
16dnl Authors: 16dnl Authors:
17dnl Ulrich Drepper <drepper@cygnus.com>, 1996. 17dnl Ulrich Drepper <drepper@cygnus.com>, 1996.
18 18
19AC_PREREQ(2.50) 19AC_PREREQ([2.50])
20 20
21# Search path for a program which passes the given test. 21# Search path for a program which passes the given test.
22 22
@@ -55,7 +55,7 @@ rm -f conf$$.file
55# Extract the first word of "$2", so it can be a program name with args. 55# Extract the first word of "$2", so it can be a program name with args.
56set dummy $2; ac_word=[$]2 56set dummy $2; ac_word=[$]2
57AC_MSG_CHECKING([for $ac_word]) 57AC_MSG_CHECKING([for $ac_word])
58AC_CACHE_VAL(ac_cv_path_$1, 58AC_CACHE_VAL([ac_cv_path_$1],
59[case "[$]$1" in 59[case "[$]$1" in
60 [[\\/]]* | ?:[[\\/]]*) 60 [[\\/]]* | ?:[[\\/]]*)
61 ac_cv_path_$1="[$]$1" # Let the user override the test with a path. 61 ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
@@ -84,9 +84,9 @@ ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
84esac])dnl 84esac])dnl
85$1="$ac_cv_path_$1" 85$1="$ac_cv_path_$1"
86if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then 86if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then
87 AC_MSG_RESULT([$]$1) 87 AC_MSG_RESULT([$][$1])
88else 88else
89 AC_MSG_RESULT(no) 89 AC_MSG_RESULT([no])
90fi 90fi
91AC_SUBST($1)dnl 91AC_SUBST([$1])dnl
92]) 92])
diff --git a/gl/m4/regex.m4 b/gl/m4/regex.m4
index 7da6efe..43b0463 100644
--- a/gl/m4/regex.m4
+++ b/gl/m4/regex.m4
@@ -1,7 +1,7 @@
1#serial 48 1# serial 53
2 2
3# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 3# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
4# 2006, 2007 Free Software Foundation, Inc. 4# 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
5# 5#
6# This file is free software; the Free Software Foundation 6# This file is free software; the Free Software Foundation
7# gives unlimited permission to copy and/or distribute it, 7# gives unlimited permission to copy and/or distribute it,
@@ -17,7 +17,7 @@ AC_DEFUN([gl_REGEX],
17 AC_CHECK_HEADERS_ONCE([locale.h]) 17 AC_CHECK_HEADERS_ONCE([locale.h])
18 18
19 AC_ARG_WITH([included-regex], 19 AC_ARG_WITH([included-regex],
20 [AC_HELP_STRING([--without-included-regex], 20 [AS_HELP_STRING([--without-included-regex],
21 [don't compile regex; this is the default on 32-bit 21 [don't compile regex; this is the default on 32-bit
22 systems with recent-enough versions of the GNU C 22 systems with recent-enough versions of the GNU C
23 Library (use with caution on other systems). 23 Library (use with caution on other systems).
@@ -37,13 +37,13 @@ AC_DEFUN([gl_REGEX],
37 [gl_cv_func_re_compile_pattern_working], 37 [gl_cv_func_re_compile_pattern_working],
38 [AC_RUN_IFELSE( 38 [AC_RUN_IFELSE(
39 [AC_LANG_PROGRAM( 39 [AC_LANG_PROGRAM(
40 [AC_INCLUDES_DEFAULT 40 [AC_INCLUDES_DEFAULT[
41 #if HAVE_LOCALE_H 41 #if HAVE_LOCALE_H
42 #include <locale.h> 42 #include <locale.h>
43 #endif 43 #endif
44 #include <limits.h> 44 #include <limits.h>
45 #include <regex.h> 45 #include <regex.h>
46 ], 46 ]],
47 [[static struct re_pattern_buffer regex; 47 [[static struct re_pattern_buffer regex;
48 unsigned char folded_chars[UCHAR_MAX + 1]; 48 unsigned char folded_chars[UCHAR_MAX + 1];
49 int i; 49 int i;
@@ -175,7 +175,7 @@ AC_DEFUN([gl_REGEX],
175 esac 175 esac
176 176
177 if test $ac_use_included_regex = yes; then 177 if test $ac_use_included_regex = yes; then
178 AC_DEFINE([_REGEX_LARGE_OFFSETS], 1, 178 AC_DEFINE([_REGEX_LARGE_OFFSETS], [1],
179 [Define if you want regoff_t to be at least as wide POSIX requires.]) 179 [Define if you want regoff_t to be at least as wide POSIX requires.])
180 AC_DEFINE([re_syntax_options], [rpl_re_syntax_options], 180 AC_DEFINE([re_syntax_options], [rpl_re_syntax_options],
181 [Define to rpl_re_syntax_options if the replacement should be used.]) 181 [Define to rpl_re_syntax_options if the replacement should be used.])
@@ -217,6 +217,8 @@ AC_DEFUN([gl_PREREQ_REGEX],
217[ 217[
218 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) 218 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
219 AC_REQUIRE([AC_C_RESTRICT]) 219 AC_REQUIRE([AC_C_RESTRICT])
220 AC_CHECK_FUNCS_ONCE([isblank iswctype mbrtowc wcrtomb wcscoll]) 220 AC_REQUIRE([AC_TYPE_MBSTATE_T])
221 AC_CHECK_HEADERS([libintl.h])
222 AC_CHECK_FUNCS_ONCE([isblank iswctype wcscoll])
221 AC_CHECK_DECLS([isblank], [], [], [#include <ctype.h>]) 223 AC_CHECK_DECLS([isblank], [], [], [#include <ctype.h>])
222]) 224])
diff --git a/gl/m4/servent.m4 b/gl/m4/servent.m4
new file mode 100644
index 0000000..242f9e3
--- /dev/null
+++ b/gl/m4/servent.m4
@@ -0,0 +1,47 @@
1# servent.m4 serial 1
2dnl Copyright (C) 2008 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_SERVENT],
8[
9 dnl Where are getservent(), setservent(), endservent(), getservbyname(),
10 dnl getservbyport() defined?
11 dnl Where are getprotoent(), setprotoent(), endprotoent(), getprotobyname(),
12 dnl getprotobynumber() defined?
13 dnl - On Solaris, they are in libsocket. Ignore libxnet.
14 dnl - On Haiku, they are in libnetwork.
15 dnl - On BeOS, they are in libnet.
16 dnl - On native Windows, they are in ws2_32.dll.
17 dnl - Otherwise they are in libc.
18 AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
19 SERVENT_LIB=
20 gl_saved_libs="$LIBS"
21 AC_SEARCH_LIBS([getservbyname], [socket network net],
22 [if test "$ac_cv_search_getservbyname" != "none required"; then
23 SERVENT_LIB="$ac_cv_search_getservbyname"
24 fi])
25 LIBS="$gl_saved_libs"
26 if test -z "$SERVENT_LIB"; then
27 AC_CHECK_FUNCS([getservbyname], , [
28 AC_CACHE_CHECK([for getservbyname in winsock2.h and -lws2_32],
29 [gl_cv_w32_getservbyname],
30 [gl_cv_w32_getservbyname=no
31 gl_save_LIBS="$LIBS"
32 LIBS="$LIBS -lws2_32"
33 AC_TRY_LINK([
34#ifdef HAVE_WINSOCK2_H
35#include <winsock2.h>
36#endif
37#include <stddef.h>
38], [getservbyname(NULL,NULL);], [gl_cv_w32_getservbyname=yes])
39 LIBS="$gl_save_LIBS"
40 ])
41 if test "$gl_cv_w32_getservbyname" = "yes"; then
42 SERVENT_LIB="-lws2_32"
43 fi
44 ])
45 fi
46 AC_SUBST([SERVENT_LIB])
47])
diff --git a/gl/m4/size_max.m4 b/gl/m4/size_max.m4
index 6cb4868..e0e7b3f 100644
--- a/gl/m4/size_max.m4
+++ b/gl/m4/size_max.m4
@@ -1,5 +1,5 @@
1# size_max.m4 serial 6 1# size_max.m4 serial 7
2dnl Copyright (C) 2003, 2005-2006 Free Software Foundation, Inc. 2dnl Copyright (C) 2003, 2005-2006, 2008 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -8,7 +8,7 @@ dnl From Bruno Haible.
8 8
9AC_DEFUN([gl_SIZE_MAX], 9AC_DEFUN([gl_SIZE_MAX],
10[ 10[
11 AC_CHECK_HEADERS(stdint.h) 11 AC_CHECK_HEADERS([stdint.h])
12 dnl First test whether the system already has SIZE_MAX. 12 dnl First test whether the system already has SIZE_MAX.
13 AC_MSG_CHECKING([for SIZE_MAX]) 13 AC_MSG_CHECKING([for SIZE_MAX])
14 AC_CACHE_VAL([gl_cv_size_max], [ 14 AC_CACHE_VAL([gl_cv_size_max], [
@@ -21,16 +21,16 @@ AC_DEFUN([gl_SIZE_MAX],
21#ifdef SIZE_MAX 21#ifdef SIZE_MAX
22Found it 22Found it
23#endif 23#endif
24], gl_cv_size_max=yes) 24], [gl_cv_size_max=yes])
25 if test -z "$gl_cv_size_max"; then 25 if test -z "$gl_cv_size_max"; then
26 dnl Define it ourselves. Here we assume that the type 'size_t' is not wider 26 dnl Define it ourselves. Here we assume that the type 'size_t' is not wider
27 dnl than the type 'unsigned long'. Try hard to find a definition that can 27 dnl than the type 'unsigned long'. Try hard to find a definition that can
28 dnl be used in a preprocessor #if, i.e. doesn't contain a cast. 28 dnl be used in a preprocessor #if, i.e. doesn't contain a cast.
29 AC_COMPUTE_INT([size_t_bits_minus_1], [sizeof (size_t) * CHAR_BIT - 1], 29 AC_COMPUTE_INT([size_t_bits_minus_1], [sizeof (size_t) * CHAR_BIT - 1],
30 [#include <stddef.h> 30 [#include <stddef.h>
31#include <limits.h>], size_t_bits_minus_1=) 31#include <limits.h>], [size_t_bits_minus_1=])
32 AC_COMPUTE_INT([fits_in_uint], [sizeof (size_t) <= sizeof (unsigned int)], 32 AC_COMPUTE_INT([fits_in_uint], [sizeof (size_t) <= sizeof (unsigned int)],
33 [#include <stddef.h>], fits_in_uint=) 33 [#include <stddef.h>], [fits_in_uint=])
34 if test -n "$size_t_bits_minus_1" && test -n "$fits_in_uint"; then 34 if test -n "$size_t_bits_minus_1" && test -n "$fits_in_uint"; then
35 if test $fits_in_uint = 1; then 35 if test $fits_in_uint = 1; then
36 dnl Even though SIZE_MAX fits in an unsigned int, it must be of type 36 dnl Even though SIZE_MAX fits in an unsigned int, it must be of type
@@ -38,7 +38,7 @@ Found it
38 AC_TRY_COMPILE([#include <stddef.h> 38 AC_TRY_COMPILE([#include <stddef.h>
39 extern size_t foo; 39 extern size_t foo;
40 extern unsigned long foo; 40 extern unsigned long foo;
41 ], [], fits_in_uint=0) 41 ], [], [fits_in_uint=0])
42 fi 42 fi
43 dnl We cannot use 'expr' to simplify this expression, because 'expr' 43 dnl We cannot use 'expr' to simplify this expression, because 'expr'
44 dnl works only with 'long' integers in the host environment, while we 44 dnl works only with 'long' integers in the host environment, while we
diff --git a/gl/m4/snprintf.m4 b/gl/m4/snprintf.m4
index f21200d..6021786 100644
--- a/gl/m4/snprintf.m4
+++ b/gl/m4/snprintf.m4
@@ -1,5 +1,5 @@
1# snprintf.m4 serial 4 1# snprintf.m4 serial 5
2dnl Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2004, 2007-2008 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -7,8 +7,17 @@ dnl with or without modifications, as long as this notice is preserved.
7AC_DEFUN([gl_FUNC_SNPRINTF], 7AC_DEFUN([gl_FUNC_SNPRINTF],
8[ 8[
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS]) 9 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
10 gl_cv_func_snprintf_usable=no
10 AC_CHECK_FUNCS([snprintf]) 11 AC_CHECK_FUNCS([snprintf])
11 if test $ac_cv_func_snprintf = no; then 12 if test $ac_cv_func_snprintf = yes; then
13 gl_SNPRINTF_SIZE1
14 case "$gl_cv_func_snprintf_size1" in
15 *yes)
16 gl_cv_func_snprintf_usable=yes
17 ;;
18 esac
19 fi
20 if test $gl_cv_func_snprintf_usable = no; then
12 gl_REPLACE_SNPRINTF 21 gl_REPLACE_SNPRINTF
13 fi 22 fi
14 AC_CHECK_DECLS_ONCE([snprintf]) 23 AC_CHECK_DECLS_ONCE([snprintf])
diff --git a/gl/m4/sockpfaf.m4 b/gl/m4/sockpfaf.m4
index 25d9755..99ea06f 100644
--- a/gl/m4/sockpfaf.m4
+++ b/gl/m4/sockpfaf.m4
@@ -1,5 +1,5 @@
1# sockpfaf.m4 serial 5 1# sockpfaf.m4 serial 6
2dnl Copyright (C) 2004, 2006 Free Software Foundation, Inc. 2dnl Copyright (C) 2004, 2006, 2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -16,8 +16,8 @@ AC_DEFUN([gl_SOCKET_FAMILIES],
16 AC_REQUIRE([gl_HEADER_SYS_SOCKET]) 16 AC_REQUIRE([gl_HEADER_SYS_SOCKET])
17 AC_CHECK_HEADERS_ONCE([netinet/in.h]) 17 AC_CHECK_HEADERS_ONCE([netinet/in.h])
18 18
19 AC_MSG_CHECKING(for IPv4 sockets) 19 AC_MSG_CHECKING([for IPv4 sockets])
20 AC_CACHE_VAL(gl_cv_socket_ipv4, 20 AC_CACHE_VAL([gl_cv_socket_ipv4],
21 [AC_TRY_COMPILE([#include <sys/types.h> 21 [AC_TRY_COMPILE([#include <sys/types.h>
22#ifdef HAVE_SYS_SOCKET_H 22#ifdef HAVE_SYS_SOCKET_H
23#include <sys/socket.h> 23#include <sys/socket.h>
@@ -31,13 +31,13 @@ AC_DEFUN([gl_SOCKET_FAMILIES],
31[int x = AF_INET; struct in_addr y; struct sockaddr_in z; 31[int x = AF_INET; struct in_addr y; struct sockaddr_in z;
32 if (&x && &y && &z) return 0;], 32 if (&x && &y && &z) return 0;],
33 gl_cv_socket_ipv4=yes, gl_cv_socket_ipv4=no)]) 33 gl_cv_socket_ipv4=yes, gl_cv_socket_ipv4=no)])
34 AC_MSG_RESULT($gl_cv_socket_ipv4) 34 AC_MSG_RESULT([$gl_cv_socket_ipv4])
35 if test $gl_cv_socket_ipv4 = yes; then 35 if test $gl_cv_socket_ipv4 = yes; then
36 AC_DEFINE(HAVE_IPV4, 1, [Define to 1 if <sys/socket.h> defines AF_INET.]) 36 AC_DEFINE([HAVE_IPV4], [1], [Define to 1 if <sys/socket.h> defines AF_INET.])
37 fi 37 fi
38 38
39 AC_MSG_CHECKING(for IPv6 sockets) 39 AC_MSG_CHECKING([for IPv6 sockets])
40 AC_CACHE_VAL(gl_cv_socket_ipv6, 40 AC_CACHE_VAL([gl_cv_socket_ipv6],
41 [AC_TRY_COMPILE([#include <sys/types.h> 41 [AC_TRY_COMPILE([#include <sys/types.h>
42#ifdef HAVE_SYS_SOCKET_H 42#ifdef HAVE_SYS_SOCKET_H
43#include <sys/socket.h> 43#include <sys/socket.h>
@@ -51,8 +51,8 @@ AC_DEFUN([gl_SOCKET_FAMILIES],
51[int x = AF_INET6; struct in6_addr y; struct sockaddr_in6 z; 51[int x = AF_INET6; struct in6_addr y; struct sockaddr_in6 z;
52 if (&x && &y && &z) return 0;], 52 if (&x && &y && &z) return 0;],
53 gl_cv_socket_ipv6=yes, gl_cv_socket_ipv6=no)]) 53 gl_cv_socket_ipv6=yes, gl_cv_socket_ipv6=no)])
54 AC_MSG_RESULT($gl_cv_socket_ipv6) 54 AC_MSG_RESULT([$gl_cv_socket_ipv6])
55 if test $gl_cv_socket_ipv6 = yes; then 55 if test $gl_cv_socket_ipv6 = yes; then
56 AC_DEFINE(HAVE_IPV6, 1, [Define to 1 if <sys/socket.h> defines AF_INET6.]) 56 AC_DEFINE([HAVE_IPV6], [1], [Define to 1 if <sys/socket.h> defines AF_INET6.])
57 fi 57 fi
58]) 58])
diff --git a/gl/m4/stdbool.m4 b/gl/m4/stdbool.m4
index 2204ecd..57c804a 100644
--- a/gl/m4/stdbool.m4
+++ b/gl/m4/stdbool.m4
@@ -1,6 +1,6 @@
1# Check for stdbool.h that conforms to C99. 1# Check for stdbool.h that conforms to C99.
2 2
3dnl Copyright (C) 2002-2006 Free Software Foundation, Inc. 3dnl Copyright (C) 2002-2006, 2009 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
@@ -111,5 +111,5 @@ AC_DEFUN([AC_HEADER_STDBOOL],
111 [ac_cv_header_stdbool_h=no])]) 111 [ac_cv_header_stdbool_h=no])])
112 AC_CHECK_TYPES([_Bool]) 112 AC_CHECK_TYPES([_Bool])
113 if test $ac_cv_header_stdbool_h = yes; then 113 if test $ac_cv_header_stdbool_h = yes; then
114 AC_DEFINE(HAVE_STDBOOL_H, 1, [Define to 1 if stdbool.h conforms to C99.]) 114 AC_DEFINE([HAVE_STDBOOL_H], [1], [Define to 1 if stdbool.h conforms to C99.])
115 fi]) 115 fi])
diff --git a/gl/m4/stdint.m4 b/gl/m4/stdint.m4
index bb6c34f..b4194c8 100644
--- a/gl/m4/stdint.m4
+++ b/gl/m4/stdint.m4
@@ -1,5 +1,5 @@
1# stdint.m4 serial 29 1# stdint.m4 serial 33
2dnl Copyright (C) 2001-2007 Free Software Foundation, Inc. 2dnl Copyright (C) 2001-2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -9,7 +9,7 @@ dnl Test whether <stdint.h> is supported or must be substituted.
9 9
10AC_DEFUN([gl_STDINT_H], 10AC_DEFUN([gl_STDINT_H],
11[ 11[
12 AC_PREREQ(2.59)dnl 12 AC_PREREQ([2.59])dnl
13 13
14 dnl Check for long long int and unsigned long long int. 14 dnl Check for long long int and unsigned long long int.
15 AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) 15 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
@@ -229,7 +229,7 @@ struct s {
229 gl_STDINT_TYPE_PROPERTIES 229 gl_STDINT_TYPE_PROPERTIES
230 STDINT_H=stdint.h 230 STDINT_H=stdint.h
231 fi 231 fi
232 AC_SUBST(STDINT_H) 232 AC_SUBST([STDINT_H])
233]) 233])
234 234
235dnl gl_STDINT_BITSIZEOF(TYPES, INCLUDES) 235dnl gl_STDINT_BITSIZEOF(TYPES, INCLUDES)
@@ -240,7 +240,7 @@ AC_DEFUN([gl_STDINT_BITSIZEOF],
240 dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into 240 dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
241 dnl config.h.in, 241 dnl config.h.in,
242 dnl - extra AC_SUBST calls, so that the right substitutions are made. 242 dnl - extra AC_SUBST calls, so that the right substitutions are made.
243 AC_FOREACH([gltype], [$1], 243 m4_foreach_w([gltype], [$1],
244 [AH_TEMPLATE([BITSIZEOF_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]), 244 [AH_TEMPLATE([BITSIZEOF_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]),
245 [Define to the number of bits in type ']gltype['.])]) 245 [Define to the number of bits in type ']gltype['.])])
246 for gltype in $1 ; do 246 for gltype in $1 ; do
@@ -265,7 +265,7 @@ AC_DEFUN([gl_STDINT_BITSIZEOF],
265 AC_DEFINE_UNQUOTED([BITSIZEOF_${GLTYPE}], [$result]) 265 AC_DEFINE_UNQUOTED([BITSIZEOF_${GLTYPE}], [$result])
266 eval BITSIZEOF_${GLTYPE}=\$result 266 eval BITSIZEOF_${GLTYPE}=\$result
267 done 267 done
268 AC_FOREACH([gltype], [$1], 268 m4_foreach_w([gltype], [$1],
269 [AC_SUBST([BITSIZEOF_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))]) 269 [AC_SUBST([BITSIZEOF_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))])
270]) 270])
271 271
@@ -278,7 +278,7 @@ AC_DEFUN([gl_CHECK_TYPES_SIGNED],
278 dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into 278 dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
279 dnl config.h.in, 279 dnl config.h.in,
280 dnl - extra AC_SUBST calls, so that the right substitutions are made. 280 dnl - extra AC_SUBST calls, so that the right substitutions are made.
281 AC_FOREACH([gltype], [$1], 281 m4_foreach_w([gltype], [$1],
282 [AH_TEMPLATE([HAVE_SIGNED_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]), 282 [AH_TEMPLATE([HAVE_SIGNED_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]),
283 [Define to 1 if ']gltype[' is a signed integer type.])]) 283 [Define to 1 if ']gltype[' is a signed integer type.])])
284 for gltype in $1 ; do 284 for gltype in $1 ; do
@@ -292,13 +292,13 @@ AC_DEFUN([gl_CHECK_TYPES_SIGNED],
292 eval result=\$gl_cv_type_${gltype}_signed 292 eval result=\$gl_cv_type_${gltype}_signed
293 GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'` 293 GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`
294 if test "$result" = yes; then 294 if test "$result" = yes; then
295 AC_DEFINE_UNQUOTED([HAVE_SIGNED_${GLTYPE}], 1) 295 AC_DEFINE_UNQUOTED([HAVE_SIGNED_${GLTYPE}], [1])
296 eval HAVE_SIGNED_${GLTYPE}=1 296 eval HAVE_SIGNED_${GLTYPE}=1
297 else 297 else
298 eval HAVE_SIGNED_${GLTYPE}=0 298 eval HAVE_SIGNED_${GLTYPE}=0
299 fi 299 fi
300 done 300 done
301 AC_FOREACH([gltype], [$1], 301 m4_foreach_w([gltype], [$1],
302 [AC_SUBST([HAVE_SIGNED_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))]) 302 [AC_SUBST([HAVE_SIGNED_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))])
303]) 303])
304 304
@@ -311,7 +311,7 @@ AC_DEFUN([gl_INTEGER_TYPE_SUFFIX],
311 dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into 311 dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
312 dnl config.h.in, 312 dnl config.h.in,
313 dnl - extra AC_SUBST calls, so that the right substitutions are made. 313 dnl - extra AC_SUBST calls, so that the right substitutions are made.
314 AC_FOREACH([gltype], [$1], 314 m4_foreach_w([gltype], [$1],
315 [AH_TEMPLATE(translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX], 315 [AH_TEMPLATE(translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX],
316 [Define to l, ll, u, ul, ull, etc., as suitable for 316 [Define to l, ll, u, ul, ull, etc., as suitable for
317 constants of type ']gltype['.])]) 317 constants of type ']gltype['.])])
@@ -337,9 +337,9 @@ AC_DEFUN([gl_INTEGER_TYPE_SUFFIX],
337 ui64)gltype1='unsigned __int64';; 337 ui64)gltype1='unsigned __int64';;
338 esac 338 esac
339 AC_COMPILE_IFELSE( 339 AC_COMPILE_IFELSE(
340 [AC_LANG_PROGRAM([$2 340 [AC_LANG_PROGRAM([$2[
341 extern $gltype foo; 341 extern $gltype foo;
342 extern $gltype1 foo;])], 342 extern $gltype1 foo;]])],
343 [eval gl_cv_type_${gltype}_suffix=\$glsuf]) 343 [eval gl_cv_type_${gltype}_suffix=\$glsuf])
344 eval result=\$gl_cv_type_${gltype}_suffix 344 eval result=\$gl_cv_type_${gltype}_suffix
345 test "$result" != no && break 345 test "$result" != no && break
@@ -348,9 +348,9 @@ AC_DEFUN([gl_INTEGER_TYPE_SUFFIX],
348 eval result=\$gl_cv_type_${gltype}_suffix 348 eval result=\$gl_cv_type_${gltype}_suffix
349 test "$result" = no && result= 349 test "$result" = no && result=
350 eval ${GLTYPE}_SUFFIX=\$result 350 eval ${GLTYPE}_SUFFIX=\$result
351 AC_DEFINE_UNQUOTED([${GLTYPE}_SUFFIX], $result) 351 AC_DEFINE_UNQUOTED([${GLTYPE}_SUFFIX], [$result])
352 done 352 done
353 AC_FOREACH([gltype], [$1], 353 m4_foreach_w([gltype], [$1],
354 [AC_SUBST(translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX])]) 354 [AC_SUBST(translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX])])
355]) 355])
356 356
@@ -373,13 +373,22 @@ dnl Compute HAVE_SIGNED_t, BITSIZEOF_t and t_SUFFIX, for all the types t
373dnl of interest to stdint.in.h. 373dnl of interest to stdint.in.h.
374AC_DEFUN([gl_STDINT_TYPE_PROPERTIES], 374AC_DEFUN([gl_STDINT_TYPE_PROPERTIES],
375[ 375[
376 gl_STDINT_BITSIZEOF([ptrdiff_t sig_atomic_t size_t wchar_t wint_t], 376 AC_REQUIRE([gl_MULTIARCH])
377 if test $APPLE_UNIVERSAL_BUILD = 0; then
378 gl_STDINT_BITSIZEOF([ptrdiff_t size_t],
379 [gl_STDINT_INCLUDES])
380 fi
381 gl_STDINT_BITSIZEOF([sig_atomic_t wchar_t wint_t],
377 [gl_STDINT_INCLUDES]) 382 [gl_STDINT_INCLUDES])
378 gl_CHECK_TYPES_SIGNED([sig_atomic_t wchar_t wint_t], 383 gl_CHECK_TYPES_SIGNED([sig_atomic_t wchar_t wint_t],
379 [gl_STDINT_INCLUDES]) 384 [gl_STDINT_INCLUDES])
380 gl_cv_type_ptrdiff_t_signed=yes 385 gl_cv_type_ptrdiff_t_signed=yes
381 gl_cv_type_size_t_signed=no 386 gl_cv_type_size_t_signed=no
382 gl_INTEGER_TYPE_SUFFIX([ptrdiff_t sig_atomic_t size_t wchar_t wint_t], 387 if test $APPLE_UNIVERSAL_BUILD = 0; then
388 gl_INTEGER_TYPE_SUFFIX([ptrdiff_t size_t],
389 [gl_STDINT_INCLUDES])
390 fi
391 gl_INTEGER_TYPE_SUFFIX([sig_atomic_t wchar_t wint_t],
383 [gl_STDINT_INCLUDES]) 392 [gl_STDINT_INCLUDES])
384]) 393])
385 394
diff --git a/gl/m4/stdint_h.m4 b/gl/m4/stdint_h.m4
index db9a8ac..82f0c24 100644
--- a/gl/m4/stdint_h.m4
+++ b/gl/m4/stdint_h.m4
@@ -1,5 +1,5 @@
1# stdint_h.m4 serial 6 1# stdint_h.m4 serial 8
2dnl Copyright (C) 1997-2004, 2006 Free Software Foundation, Inc. 2dnl Copyright (C) 1997-2004, 2006, 2008, 2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -11,15 +11,15 @@ dnl From Paul Eggert.
11 11
12AC_DEFUN([gl_AC_HEADER_STDINT_H], 12AC_DEFUN([gl_AC_HEADER_STDINT_H],
13[ 13[
14 AC_CACHE_CHECK([for stdint.h], gl_cv_header_stdint_h, 14 AC_CACHE_CHECK([for stdint.h], [gl_cv_header_stdint_h],
15 [AC_TRY_COMPILE( 15 [AC_TRY_COMPILE(
16 [#include <sys/types.h> 16 [#include <sys/types.h>
17#include <stdint.h>], 17#include <stdint.h>],
18 [uintmax_t i = (uintmax_t) -1; return !i;], 18 [uintmax_t i = (uintmax_t) -1; return !i;],
19 gl_cv_header_stdint_h=yes, 19 [gl_cv_header_stdint_h=yes],
20 gl_cv_header_stdint_h=no)]) 20 [gl_cv_header_stdint_h=no])])
21 if test $gl_cv_header_stdint_h = yes; then 21 if test $gl_cv_header_stdint_h = yes; then
22 AC_DEFINE_UNQUOTED(HAVE_STDINT_H_WITH_UINTMAX, 1, 22 AC_DEFINE_UNQUOTED([HAVE_STDINT_H_WITH_UINTMAX], [1],
23 [Define if <stdint.h> exists, doesn't clash with <sys/types.h>, 23 [Define if <stdint.h> exists, doesn't clash with <sys/types.h>,
24 and declares uintmax_t. ]) 24 and declares uintmax_t. ])
25 fi 25 fi
diff --git a/gl/m4/stdio_h.m4 b/gl/m4/stdio_h.m4
index a40d418..60b4bd7 100644
--- a/gl/m4/stdio_h.m4
+++ b/gl/m4/stdio_h.m4
@@ -1,5 +1,5 @@
1# stdio_h.m4 serial 9 1# stdio_h.m4 serial 14
2dnl Copyright (C) 2007 Free Software Foundation, Inc. 2dnl Copyright (C) 2007-2008 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -8,6 +8,28 @@ AC_DEFUN([gl_STDIO_H],
8[ 8[
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS]) 9 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
10 gl_CHECK_NEXT_HEADERS([stdio.h]) 10 gl_CHECK_NEXT_HEADERS([stdio.h])
11 dnl No need to create extra modules for these functions. Everyone who uses
12 dnl <stdio.h> likely needs them.
13 GNULIB_FPRINTF=1
14 GNULIB_PRINTF=1
15 GNULIB_VFPRINTF=1
16 GNULIB_VPRINTF=1
17 GNULIB_FPUTC=1
18 GNULIB_PUTC=1
19 GNULIB_PUTCHAR=1
20 GNULIB_FPUTS=1
21 GNULIB_PUTS=1
22 GNULIB_FWRITE=1
23 dnl This ifdef is just an optimization, to avoid performing a configure
24 dnl check whose result is not used. It does not make the test of
25 dnl GNULIB_STDIO_H_SIGPIPE or GNULIB_SIGPIPE redundant.
26 m4_ifdef([gl_SIGNAL_SIGPIPE], [
27 gl_SIGNAL_SIGPIPE
28 if test $gl_cv_header_signal_h_SIGPIPE != yes; then
29 REPLACE_STDIO_WRITE_FUNCS=1
30 AC_LIBOBJ([stdio-write])
31 fi
32 ])
11]) 33])
12 34
13AC_DEFUN([gl_STDIO_MODULE_INDICATOR], 35AC_DEFUN([gl_STDIO_MODULE_INDICATOR],
@@ -19,49 +41,69 @@ AC_DEFUN([gl_STDIO_MODULE_INDICATOR],
19 41
20AC_DEFUN([gl_STDIO_H_DEFAULTS], 42AC_DEFUN([gl_STDIO_H_DEFAULTS],
21[ 43[
22 GNULIB_FPRINTF_POSIX=0; AC_SUBST([GNULIB_FPRINTF_POSIX]) 44 GNULIB_FPRINTF=0; AC_SUBST([GNULIB_FPRINTF])
23 GNULIB_PRINTF_POSIX=0; AC_SUBST([GNULIB_PRINTF_POSIX]) 45 GNULIB_FPRINTF_POSIX=0; AC_SUBST([GNULIB_FPRINTF_POSIX])
24 GNULIB_SNPRINTF=0; AC_SUBST([GNULIB_SNPRINTF]) 46 GNULIB_PRINTF=0; AC_SUBST([GNULIB_PRINTF])
25 GNULIB_SPRINTF_POSIX=0; AC_SUBST([GNULIB_SPRINTF_POSIX]) 47 GNULIB_PRINTF_POSIX=0; AC_SUBST([GNULIB_PRINTF_POSIX])
26 GNULIB_VFPRINTF_POSIX=0; AC_SUBST([GNULIB_VFPRINTF_POSIX]) 48 GNULIB_SNPRINTF=0; AC_SUBST([GNULIB_SNPRINTF])
27 GNULIB_VPRINTF_POSIX=0; AC_SUBST([GNULIB_VPRINTF_POSIX]) 49 GNULIB_SPRINTF_POSIX=0; AC_SUBST([GNULIB_SPRINTF_POSIX])
28 GNULIB_VSNPRINTF=0; AC_SUBST([GNULIB_VSNPRINTF]) 50 GNULIB_VFPRINTF=0; AC_SUBST([GNULIB_VFPRINTF])
29 GNULIB_VSPRINTF_POSIX=0; AC_SUBST([GNULIB_VSPRINTF_POSIX]) 51 GNULIB_VFPRINTF_POSIX=0; AC_SUBST([GNULIB_VFPRINTF_POSIX])
30 GNULIB_VASPRINTF=0; AC_SUBST([GNULIB_VASPRINTF]) 52 GNULIB_VPRINTF=0; AC_SUBST([GNULIB_VPRINTF])
31 GNULIB_FOPEN=0; AC_SUBST([GNULIB_FOPEN]) 53 GNULIB_VPRINTF_POSIX=0; AC_SUBST([GNULIB_VPRINTF_POSIX])
32 GNULIB_FREOPEN=0; AC_SUBST([GNULIB_FREOPEN]) 54 GNULIB_VSNPRINTF=0; AC_SUBST([GNULIB_VSNPRINTF])
33 GNULIB_FSEEK=0; AC_SUBST([GNULIB_FSEEK]) 55 GNULIB_VSPRINTF_POSIX=0; AC_SUBST([GNULIB_VSPRINTF_POSIX])
34 GNULIB_FSEEKO=0; AC_SUBST([GNULIB_FSEEKO]) 56 GNULIB_VASPRINTF=0; AC_SUBST([GNULIB_VASPRINTF])
35 GNULIB_FTELL=0; AC_SUBST([GNULIB_FTELL]) 57 GNULIB_OBSTACK_PRINTF=0; AC_SUBST([GNULIB_OBSTACK_PRINTF])
36 GNULIB_FTELLO=0; AC_SUBST([GNULIB_FTELLO]) 58 GNULIB_OBSTACK_PRINTF_POSIX=0; AC_SUBST([GNULIB_OBSTACK_PRINTF_POSIX])
37 GNULIB_FFLUSH=0; AC_SUBST([GNULIB_FFLUSH]) 59 GNULIB_FOPEN=0; AC_SUBST([GNULIB_FOPEN])
38 GNULIB_GETDELIM=0; AC_SUBST([GNULIB_GETDELIM]) 60 GNULIB_FREOPEN=0; AC_SUBST([GNULIB_FREOPEN])
39 GNULIB_GETLINE=0; AC_SUBST([GNULIB_GETLINE]) 61 GNULIB_FSEEK=0; AC_SUBST([GNULIB_FSEEK])
62 GNULIB_FSEEKO=0; AC_SUBST([GNULIB_FSEEKO])
63 GNULIB_FTELL=0; AC_SUBST([GNULIB_FTELL])
64 GNULIB_FTELLO=0; AC_SUBST([GNULIB_FTELLO])
65 GNULIB_FFLUSH=0; AC_SUBST([GNULIB_FFLUSH])
66 GNULIB_FCLOSE=0; AC_SUBST([GNULIB_FCLOSE])
67 GNULIB_FPUTC=0; AC_SUBST([GNULIB_FPUTC])
68 GNULIB_PUTC=0; AC_SUBST([GNULIB_PUTC])
69 GNULIB_PUTCHAR=0; AC_SUBST([GNULIB_PUTCHAR])
70 GNULIB_FPUTS=0; AC_SUBST([GNULIB_FPUTS])
71 GNULIB_PUTS=0; AC_SUBST([GNULIB_PUTS])
72 GNULIB_FWRITE=0; AC_SUBST([GNULIB_FWRITE])
73 GNULIB_GETDELIM=0; AC_SUBST([GNULIB_GETDELIM])
74 GNULIB_GETLINE=0; AC_SUBST([GNULIB_GETLINE])
75 GNULIB_PERROR=0; AC_SUBST([GNULIB_PERROR])
76 GNULIB_STDIO_H_SIGPIPE=0; AC_SUBST([GNULIB_STDIO_H_SIGPIPE])
40 dnl Assume proper GNU behavior unless another module says otherwise. 77 dnl Assume proper GNU behavior unless another module says otherwise.
41 REPLACE_FPRINTF=0; AC_SUBST([REPLACE_FPRINTF]) 78 REPLACE_STDIO_WRITE_FUNCS=0; AC_SUBST([REPLACE_STDIO_WRITE_FUNCS])
42 REPLACE_VFPRINTF=0; AC_SUBST([REPLACE_VFPRINTF]) 79 REPLACE_FPRINTF=0; AC_SUBST([REPLACE_FPRINTF])
43 REPLACE_PRINTF=0; AC_SUBST([REPLACE_PRINTF]) 80 REPLACE_VFPRINTF=0; AC_SUBST([REPLACE_VFPRINTF])
44 REPLACE_VPRINTF=0; AC_SUBST([REPLACE_VPRINTF]) 81 REPLACE_PRINTF=0; AC_SUBST([REPLACE_PRINTF])
45 REPLACE_SNPRINTF=0; AC_SUBST([REPLACE_SNPRINTF]) 82 REPLACE_VPRINTF=0; AC_SUBST([REPLACE_VPRINTF])
46 HAVE_DECL_SNPRINTF=1; AC_SUBST([HAVE_DECL_SNPRINTF]) 83 REPLACE_SNPRINTF=0; AC_SUBST([REPLACE_SNPRINTF])
47 REPLACE_VSNPRINTF=0; AC_SUBST([REPLACE_VSNPRINTF]) 84 HAVE_DECL_SNPRINTF=1; AC_SUBST([HAVE_DECL_SNPRINTF])
48 HAVE_DECL_VSNPRINTF=1; AC_SUBST([HAVE_DECL_VSNPRINTF]) 85 REPLACE_VSNPRINTF=0; AC_SUBST([REPLACE_VSNPRINTF])
49 REPLACE_SPRINTF=0; AC_SUBST([REPLACE_SPRINTF]) 86 HAVE_DECL_VSNPRINTF=1; AC_SUBST([HAVE_DECL_VSNPRINTF])
50 REPLACE_VSPRINTF=0; AC_SUBST([REPLACE_VSPRINTF]) 87 REPLACE_SPRINTF=0; AC_SUBST([REPLACE_SPRINTF])
51 HAVE_VASPRINTF=1; AC_SUBST([HAVE_VASPRINTF]) 88 REPLACE_VSPRINTF=0; AC_SUBST([REPLACE_VSPRINTF])
52 REPLACE_VASPRINTF=0; AC_SUBST([REPLACE_VASPRINTF]) 89 HAVE_VASPRINTF=1; AC_SUBST([HAVE_VASPRINTF])
53 REPLACE_FOPEN=0; AC_SUBST([REPLACE_FOPEN]) 90 REPLACE_VASPRINTF=0; AC_SUBST([REPLACE_VASPRINTF])
54 REPLACE_FREOPEN=0; AC_SUBST([REPLACE_FREOPEN]) 91 HAVE_DECL_OBSTACK_PRINTF=1; AC_SUBST([HAVE_DECL_OBSTACK_PRINTF])
55 HAVE_FSEEKO=1; AC_SUBST([HAVE_FSEEKO]) 92 REPLACE_OBSTACK_PRINTF=0; AC_SUBST([REPLACE_OBSTACK_PRINTF])
56 REPLACE_FSEEKO=0; AC_SUBST([REPLACE_FSEEKO]) 93 REPLACE_FOPEN=0; AC_SUBST([REPLACE_FOPEN])
57 REPLACE_FSEEK=0; AC_SUBST([REPLACE_FSEEK]) 94 REPLACE_FREOPEN=0; AC_SUBST([REPLACE_FREOPEN])
58 HAVE_FTELLO=1; AC_SUBST([HAVE_FTELLO]) 95 HAVE_FSEEKO=1; AC_SUBST([HAVE_FSEEKO])
59 REPLACE_FTELLO=0; AC_SUBST([REPLACE_FTELLO]) 96 REPLACE_FSEEKO=0; AC_SUBST([REPLACE_FSEEKO])
60 REPLACE_FTELL=0; AC_SUBST([REPLACE_FTELL]) 97 REPLACE_FSEEK=0; AC_SUBST([REPLACE_FSEEK])
61 REPLACE_FFLUSH=0; AC_SUBST([REPLACE_FFLUSH]) 98 HAVE_FTELLO=1; AC_SUBST([HAVE_FTELLO])
62 HAVE_DECL_GETDELIM=1; AC_SUBST([HAVE_DECL_GETDELIM]) 99 REPLACE_FTELLO=0; AC_SUBST([REPLACE_FTELLO])
63 HAVE_DECL_GETLINE=1; AC_SUBST([HAVE_DECL_GETLINE]) 100 REPLACE_FTELL=0; AC_SUBST([REPLACE_FTELL])
64 REPLACE_GETLINE=0; AC_SUBST([REPLACE_GETLINE]) 101 REPLACE_FFLUSH=0; AC_SUBST([REPLACE_FFLUSH])
102 REPLACE_FCLOSE=0; AC_SUBST([REPLACE_FCLOSE])
103 HAVE_DECL_GETDELIM=1; AC_SUBST([HAVE_DECL_GETDELIM])
104 HAVE_DECL_GETLINE=1; AC_SUBST([HAVE_DECL_GETLINE])
105 REPLACE_GETLINE=0; AC_SUBST([REPLACE_GETLINE])
106 REPLACE_PERROR=0; AC_SUBST([REPLACE_PERROR])
65]) 107])
66 108
67dnl Code shared by fseeko and ftello. Determine if large files are supported, 109dnl Code shared by fseeko and ftello. Determine if large files are supported,
@@ -70,8 +112,8 @@ AC_DEFUN([gl_STDIN_LARGE_OFFSET],
70 [ 112 [
71 AC_CACHE_CHECK([whether stdin defaults to large file offsets], 113 AC_CACHE_CHECK([whether stdin defaults to large file offsets],
72 [gl_cv_var_stdin_large_offset], 114 [gl_cv_var_stdin_large_offset],
73 [AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>], 115 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]],
74[#if defined __SL64 && defined __SCLE /* cygwin */ 116[[#if defined __SL64 && defined __SCLE /* cygwin */
75 /* Cygwin 1.5.24 and earlier fail to put stdin in 64-bit mode, making 117 /* Cygwin 1.5.24 and earlier fail to put stdin in 64-bit mode, making
76 fseeko/ftello needlessly fail. This bug was fixed in 1.5.25, and 118 fseeko/ftello needlessly fail. This bug was fixed in 1.5.25, and
77 it is easier to do a version check than building a runtime test. */ 119 it is easier to do a version check than building a runtime test. */
@@ -79,7 +121,7 @@ AC_DEFUN([gl_STDIN_LARGE_OFFSET],
79# if CYGWIN_VERSION_DLL_COMBINED < CYGWIN_VERSION_DLL_MAKE_COMBINED (1005, 25) 121# if CYGWIN_VERSION_DLL_COMBINED < CYGWIN_VERSION_DLL_MAKE_COMBINED (1005, 25)
80 choke me 122 choke me
81# endif 123# endif
82#endif])], 124#endif]])],
83 [gl_cv_var_stdin_large_offset=yes], 125 [gl_cv_var_stdin_large_offset=yes],
84 [gl_cv_var_stdin_large_offset=no])]) 126 [gl_cv_var_stdin_large_offset=no])])
85]) 127])
diff --git a/gl/m4/stdlib_h.m4 b/gl/m4/stdlib_h.m4
index fe4ce12..582db13 100644
--- a/gl/m4/stdlib_h.m4
+++ b/gl/m4/stdlib_h.m4
@@ -1,5 +1,5 @@
1# stdlib_h.m4 serial 5 1# stdlib_h.m4 serial 13
2dnl Copyright (C) 2007 Free Software Foundation, Inc. 2dnl Copyright (C) 2007, 2008 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -8,6 +8,9 @@ AC_DEFUN([gl_STDLIB_H],
8[ 8[
9 AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) 9 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
10 gl_CHECK_NEXT_HEADERS([stdlib.h]) 10 gl_CHECK_NEXT_HEADERS([stdlib.h])
11 AC_CHECK_TYPES([struct random_data],
12 [], [HAVE_STRUCT_RANDOM_DATA=0],
13 [[#include <stdlib.h>]])
11]) 14])
12 15
13AC_DEFUN([gl_STDLIB_MODULE_INDICATOR], 16AC_DEFUN([gl_STDLIB_MODULE_INDICATOR],
@@ -22,21 +25,38 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
22 GNULIB_MALLOC_POSIX=0; AC_SUBST([GNULIB_MALLOC_POSIX]) 25 GNULIB_MALLOC_POSIX=0; AC_SUBST([GNULIB_MALLOC_POSIX])
23 GNULIB_REALLOC_POSIX=0; AC_SUBST([GNULIB_REALLOC_POSIX]) 26 GNULIB_REALLOC_POSIX=0; AC_SUBST([GNULIB_REALLOC_POSIX])
24 GNULIB_CALLOC_POSIX=0; AC_SUBST([GNULIB_CALLOC_POSIX]) 27 GNULIB_CALLOC_POSIX=0; AC_SUBST([GNULIB_CALLOC_POSIX])
28 GNULIB_ATOLL=0; AC_SUBST([GNULIB_ATOLL])
29 GNULIB_GETLOADAVG=0; AC_SUBST([GNULIB_GETLOADAVG])
25 GNULIB_GETSUBOPT=0; AC_SUBST([GNULIB_GETSUBOPT]) 30 GNULIB_GETSUBOPT=0; AC_SUBST([GNULIB_GETSUBOPT])
26 GNULIB_MKDTEMP=0; AC_SUBST([GNULIB_MKDTEMP]) 31 GNULIB_MKDTEMP=0; AC_SUBST([GNULIB_MKDTEMP])
27 GNULIB_MKSTEMP=0; AC_SUBST([GNULIB_MKSTEMP]) 32 GNULIB_MKSTEMP=0; AC_SUBST([GNULIB_MKSTEMP])
28 GNULIB_PUTENV=0; AC_SUBST([GNULIB_PUTENV]) 33 GNULIB_PUTENV=0; AC_SUBST([GNULIB_PUTENV])
34 GNULIB_RANDOM_R=0; AC_SUBST([GNULIB_RANDOM_R])
35 GNULIB_RPMATCH=0; AC_SUBST([GNULIB_RPMATCH])
29 GNULIB_SETENV=0; AC_SUBST([GNULIB_SETENV]) 36 GNULIB_SETENV=0; AC_SUBST([GNULIB_SETENV])
37 GNULIB_STRTOD=0; AC_SUBST([GNULIB_STRTOD])
38 GNULIB_STRTOLL=0; AC_SUBST([GNULIB_STRTOLL])
39 GNULIB_STRTOULL=0; AC_SUBST([GNULIB_STRTOULL])
30 GNULIB_UNSETENV=0; AC_SUBST([GNULIB_UNSETENV]) 40 GNULIB_UNSETENV=0; AC_SUBST([GNULIB_UNSETENV])
31 dnl Assume proper GNU behavior unless another module says otherwise. 41 dnl Assume proper GNU behavior unless another module says otherwise.
32 HAVE_CALLOC_POSIX=1; AC_SUBST([HAVE_CALLOC_POSIX]) 42 HAVE_ATOLL=1; AC_SUBST([HAVE_ATOLL])
33 HAVE_GETSUBOPT=1; AC_SUBST([HAVE_GETSUBOPT]) 43 HAVE_CALLOC_POSIX=1; AC_SUBST([HAVE_CALLOC_POSIX])
34 HAVE_MALLOC_POSIX=1; AC_SUBST([HAVE_MALLOC_POSIX]) 44 HAVE_GETSUBOPT=1; AC_SUBST([HAVE_GETSUBOPT])
35 HAVE_MKDTEMP=1; AC_SUBST([HAVE_MKDTEMP]) 45 HAVE_MALLOC_POSIX=1; AC_SUBST([HAVE_MALLOC_POSIX])
36 HAVE_REALLOC_POSIX=1; AC_SUBST([HAVE_REALLOC_POSIX]) 46 HAVE_MKDTEMP=1; AC_SUBST([HAVE_MKDTEMP])
37 HAVE_SETENV=1; AC_SUBST([HAVE_SETENV]) 47 HAVE_REALLOC_POSIX=1; AC_SUBST([HAVE_REALLOC_POSIX])
38 HAVE_UNSETENV=1; AC_SUBST([HAVE_UNSETENV]) 48 HAVE_RANDOM_R=1; AC_SUBST([HAVE_RANDOM_R])
39 REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP]) 49 HAVE_RPMATCH=1; AC_SUBST([HAVE_RPMATCH])
40 REPLACE_PUTENV=0; AC_SUBST([REPLACE_PUTENV]) 50 HAVE_SETENV=1; AC_SUBST([HAVE_SETENV])
41 VOID_UNSETENV=0; AC_SUBST([VOID_UNSETENV]) 51 HAVE_STRTOD=1; AC_SUBST([HAVE_STRTOD])
52 HAVE_STRTOLL=1; AC_SUBST([HAVE_STRTOLL])
53 HAVE_STRTOULL=1; AC_SUBST([HAVE_STRTOULL])
54 HAVE_STRUCT_RANDOM_DATA=1; AC_SUBST([HAVE_STRUCT_RANDOM_DATA])
55 HAVE_SYS_LOADAVG_H=0; AC_SUBST([HAVE_SYS_LOADAVG_H])
56 HAVE_UNSETENV=1; AC_SUBST([HAVE_UNSETENV])
57 HAVE_DECL_GETLOADAVG=1; AC_SUBST([HAVE_DECL_GETLOADAVG])
58 REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP])
59 REPLACE_PUTENV=0; AC_SUBST([REPLACE_PUTENV])
60 REPLACE_STRTOD=0; AC_SUBST([REPLACE_STRTOD])
61 VOID_UNSETENV=0; AC_SUBST([VOID_UNSETENV])
42]) 62])
diff --git a/gl/m4/strdup.m4 b/gl/m4/strdup.m4
deleted file mode 100644
index 8796e9e..0000000
--- a/gl/m4/strdup.m4
+++ /dev/null
@@ -1,22 +0,0 @@
1# strdup.m4 serial 9
2
3dnl Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software
4dnl Foundation, Inc.
5
6dnl This file is free software; the Free Software Foundation
7dnl gives unlimited permission to copy and/or distribute it,
8dnl with or without modifications, as long as this notice is preserved.
9
10AC_DEFUN([gl_FUNC_STRDUP],
11[
12 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
13 AC_REPLACE_FUNCS(strdup)
14 AC_CHECK_DECLS_ONCE(strdup)
15 if test $ac_cv_have_decl_strdup = no; then
16 HAVE_DECL_STRDUP=0
17 fi
18 gl_PREREQ_STRDUP
19])
20
21# Prerequisites of lib/strdup.c.
22AC_DEFUN([gl_PREREQ_STRDUP], [:])
diff --git a/gl/m4/strerror.m4 b/gl/m4/strerror.m4
index eb7d45a..8c16ca9 100644
--- a/gl/m4/strerror.m4
+++ b/gl/m4/strerror.m4
@@ -1,5 +1,5 @@
1# strerror.m4 serial 7 1# strerror.m4 serial 9
2dnl Copyright (C) 2002, 2007 Free Software Foundation, Inc. 2dnl Copyright (C) 2002, 2007-2008 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -7,7 +7,7 @@ dnl with or without modifications, as long as this notice is preserved.
7AC_DEFUN([gl_FUNC_STRERROR], 7AC_DEFUN([gl_FUNC_STRERROR],
8[ 8[
9 AC_REQUIRE([gl_FUNC_STRERROR_SEPARATE]) 9 AC_REQUIRE([gl_FUNC_STRERROR_SEPARATE])
10 if test $gl_cv_func_working_strerror = no; then 10 if test $REPLACE_STRERROR = 1; then
11 AC_LIBOBJ([strerror]) 11 AC_LIBOBJ([strerror])
12 AC_DEFINE_UNQUOTED([REPLACE_STRERROR], [$REPLACE_STRERROR], 12 AC_DEFINE_UNQUOTED([REPLACE_STRERROR], [$REPLACE_STRERROR],
13 [Define this to 1 if strerror is broken.]) 13 [Define this to 1 if strerror is broken.])
@@ -18,25 +18,38 @@ AC_DEFUN([gl_FUNC_STRERROR],
18AC_DEFUN([gl_FUNC_STRERROR_SEPARATE], 18AC_DEFUN([gl_FUNC_STRERROR_SEPARATE],
19[ 19[
20 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) 20 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
21 AC_CACHE_CHECK([for working strerror function], 21 AC_REQUIRE([gl_HEADER_ERRNO_H])
22 [gl_cv_func_working_strerror], 22 if test -z "$ERRNO_H"; then
23 [AC_RUN_IFELSE( 23 AC_CACHE_CHECK([for working strerror function],
24 [AC_LANG_PROGRAM( 24 [gl_cv_func_working_strerror],
25 [#include <string.h> 25 [AC_RUN_IFELSE(
26 ], 26 [AC_LANG_PROGRAM(
27 [return !*strerror (-2);])], 27 [[#include <string.h>
28 [gl_cv_func_working_strerror=yes], 28 ]],
29 [gl_cv_func_working_strerror=no], 29 [[return !*strerror (-2);]])],
30 [dnl Assume crossbuild works if it compiles. 30 [gl_cv_func_working_strerror=yes],
31 AC_COMPILE_IFELSE( 31 [gl_cv_func_working_strerror=no],
32 [AC_LANG_PROGRAM( 32 [dnl Assume crossbuild works if it compiles.
33 [#include <string.h> 33 AC_COMPILE_IFELSE(
34 ], 34 [AC_LANG_PROGRAM(
35 [return !*strerror (-2);])], 35 [[#include <string.h>
36 [gl_cv_func_working_strerror=yes], 36 ]],
37 [gl_cv_func_working_strerror=no])])]) 37 [[return !*strerror (-2);]])],
38 if test $gl_cv_func_working_strerror = no ; then 38 [gl_cv_func_working_strerror=yes],
39 [gl_cv_func_working_strerror=no])
40 ])
41 ])
42 if test $gl_cv_func_working_strerror = no; then
43 dnl The system's strerror() fails to return a string for out-of-range
44 dnl integers. Replace it.
45 REPLACE_STRERROR=1
46 fi
47 else
48 dnl The system's strerror() cannot know about the new errno values we add
49 dnl to <errno.h>. Replace it.
39 REPLACE_STRERROR=1 50 REPLACE_STRERROR=1
51 fi
52 if test $REPLACE_STRERROR = 1; then
40 gl_PREREQ_STRERROR 53 gl_PREREQ_STRERROR
41 fi 54 fi
42]) 55])
@@ -44,4 +57,12 @@ AC_DEFUN([gl_FUNC_STRERROR_SEPARATE],
44# Prerequisites of lib/strerror.c. 57# Prerequisites of lib/strerror.c.
45AC_DEFUN([gl_PREREQ_STRERROR], [ 58AC_DEFUN([gl_PREREQ_STRERROR], [
46 AC_CHECK_DECLS([strerror]) 59 AC_CHECK_DECLS([strerror])
60 AC_CHECK_HEADERS_ONCE([sys/socket.h])
61 if test $ac_cv_header_sys_socket_h != yes; then
62 dnl We cannot use AC_CHECK_HEADERS_ONCE here, because that would make
63 dnl the check for those headers unconditional; yet cygwin reports
64 dnl that the headers are present but cannot be compiled (since on
65 dnl cygwin, all socket information should come from sys/socket.h).
66 AC_CHECK_HEADERS([winsock2.h])
67 fi
47]) 68])
diff --git a/gl/m4/string_h.m4 b/gl/m4/string_h.m4
index 766d7e9..2d5553c 100644
--- a/gl/m4/string_h.m4
+++ b/gl/m4/string_h.m4
@@ -5,7 +5,7 @@
5# gives unlimited permission to copy and/or distribute it, 5# gives unlimited permission to copy and/or distribute it,
6# with or without modifications, as long as this notice is preserved. 6# with or without modifications, as long as this notice is preserved.
7 7
8# serial 4 8# serial 6
9 9
10# Written by Paul Eggert. 10# Written by Paul Eggert.
11 11
@@ -35,6 +35,7 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
35 GNULIB_MEMMEM=0; AC_SUBST([GNULIB_MEMMEM]) 35 GNULIB_MEMMEM=0; AC_SUBST([GNULIB_MEMMEM])
36 GNULIB_MEMPCPY=0; AC_SUBST([GNULIB_MEMPCPY]) 36 GNULIB_MEMPCPY=0; AC_SUBST([GNULIB_MEMPCPY])
37 GNULIB_MEMRCHR=0; AC_SUBST([GNULIB_MEMRCHR]) 37 GNULIB_MEMRCHR=0; AC_SUBST([GNULIB_MEMRCHR])
38 GNULIB_RAWMEMCHR=0; AC_SUBST([GNULIB_RAWMEMCHR])
38 GNULIB_STPCPY=0; AC_SUBST([GNULIB_STPCPY]) 39 GNULIB_STPCPY=0; AC_SUBST([GNULIB_STPCPY])
39 GNULIB_STPNCPY=0; AC_SUBST([GNULIB_STPNCPY]) 40 GNULIB_STPNCPY=0; AC_SUBST([GNULIB_STPNCPY])
40 GNULIB_STRCHRNUL=0; AC_SUBST([GNULIB_STRCHRNUL]) 41 GNULIB_STRCHRNUL=0; AC_SUBST([GNULIB_STRCHRNUL])
@@ -62,10 +63,12 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
62 GNULIB_MBSTOK_R=0; AC_SUBST([GNULIB_MBSTOK_R]) 63 GNULIB_MBSTOK_R=0; AC_SUBST([GNULIB_MBSTOK_R])
63 GNULIB_STRERROR=0; AC_SUBST([GNULIB_STRERROR]) 64 GNULIB_STRERROR=0; AC_SUBST([GNULIB_STRERROR])
64 GNULIB_STRSIGNAL=0; AC_SUBST([GNULIB_STRSIGNAL]) 65 GNULIB_STRSIGNAL=0; AC_SUBST([GNULIB_STRSIGNAL])
66 GNULIB_STRVERSCMP=0; AC_SUBST([GNULIB_STRVERSCMP])
65 dnl Assume proper GNU behavior unless another module says otherwise. 67 dnl Assume proper GNU behavior unless another module says otherwise.
66 HAVE_DECL_MEMMEM=1; AC_SUBST([HAVE_DECL_MEMMEM]) 68 HAVE_DECL_MEMMEM=1; AC_SUBST([HAVE_DECL_MEMMEM])
67 HAVE_MEMPCPY=1; AC_SUBST([HAVE_MEMPCPY]) 69 HAVE_MEMPCPY=1; AC_SUBST([HAVE_MEMPCPY])
68 HAVE_DECL_MEMRCHR=1; AC_SUBST([HAVE_DECL_MEMRCHR]) 70 HAVE_DECL_MEMRCHR=1; AC_SUBST([HAVE_DECL_MEMRCHR])
71 HAVE_RAWMEMCHR=1; AC_SUBST([HAVE_RAWMEMCHR])
69 HAVE_STPCPY=1; AC_SUBST([HAVE_STPCPY]) 72 HAVE_STPCPY=1; AC_SUBST([HAVE_STPCPY])
70 HAVE_STPNCPY=1; AC_SUBST([HAVE_STPNCPY]) 73 HAVE_STPNCPY=1; AC_SUBST([HAVE_STPNCPY])
71 HAVE_STRCHRNUL=1; AC_SUBST([HAVE_STRCHRNUL]) 74 HAVE_STRCHRNUL=1; AC_SUBST([HAVE_STRCHRNUL])
@@ -79,9 +82,11 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
79 HAVE_DECL_STRTOK_R=1; AC_SUBST([HAVE_DECL_STRTOK_R]) 82 HAVE_DECL_STRTOK_R=1; AC_SUBST([HAVE_DECL_STRTOK_R])
80 HAVE_DECL_STRERROR=1; AC_SUBST([HAVE_DECL_STRERROR]) 83 HAVE_DECL_STRERROR=1; AC_SUBST([HAVE_DECL_STRERROR])
81 HAVE_DECL_STRSIGNAL=1; AC_SUBST([HAVE_DECL_STRSIGNAL]) 84 HAVE_DECL_STRSIGNAL=1; AC_SUBST([HAVE_DECL_STRSIGNAL])
82 REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR]) 85 HAVE_STRVERSCMP=1; AC_SUBST([HAVE_STRVERSCMP])
83 REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL])
84 REPLACE_MEMMEM=0; AC_SUBST([REPLACE_MEMMEM]) 86 REPLACE_MEMMEM=0; AC_SUBST([REPLACE_MEMMEM])
85 REPLACE_STRCASESTR=0; AC_SUBST([REPLACE_STRCASESTR]) 87 REPLACE_STRDUP=0; AC_SUBST([REPLACE_STRDUP])
86 REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR]) 88 REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR])
89 REPLACE_STRCASESTR=0; AC_SUBST([REPLACE_STRCASESTR])
90 REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR])
91 REPLACE_STRSIGNAL=0; AC_SUBST([REPLACE_STRSIGNAL])
87]) 92])
diff --git a/gl/m4/strndup.m4 b/gl/m4/strndup.m4
index f7934ef..4fa7d5a 100644
--- a/gl/m4/strndup.m4
+++ b/gl/m4/strndup.m4
@@ -1,5 +1,5 @@
1# strndup.m4 serial 14 1# strndup.m4 serial 16
2dnl Copyright (C) 2002-2003, 2005-2007 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2003, 2005-2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -16,10 +16,10 @@ AC_DEFUN([gl_FUNC_STRNDUP],
16 fi 16 fi
17 17
18 # AIX 4.3.3, AIX 5.1 have a function that fails to add the terminating '\0'. 18 # AIX 4.3.3, AIX 5.1 have a function that fails to add the terminating '\0'.
19 AC_CACHE_CHECK([for working strndup], gl_cv_func_strndup, 19 AC_CACHE_CHECK([for working strndup], [gl_cv_func_strndup],
20 [AC_RUN_IFELSE([ 20 [AC_RUN_IFELSE([
21 AC_LANG_PROGRAM([#include <string.h> 21 AC_LANG_PROGRAM([[#include <string.h>
22 #include <stdlib.h>], [[ 22 #include <stdlib.h>]], [[
23#ifndef HAVE_DECL_STRNDUP 23#ifndef HAVE_DECL_STRNDUP
24 extern char *strndup (const char *, size_t); 24 extern char *strndup (const char *, size_t);
25#endif 25#endif
@@ -40,7 +40,7 @@ AC_DEFUN([gl_FUNC_STRNDUP],
40 [gl_cv_func_strndup=yes])], 40 [gl_cv_func_strndup=yes])],
41 [gl_cv_func_strndup=no])])]) 41 [gl_cv_func_strndup=no])])])
42 if test $gl_cv_func_strndup = yes; then 42 if test $gl_cv_func_strndup = yes; then
43 AC_DEFINE([HAVE_STRNDUP], 1, 43 AC_DEFINE([HAVE_STRNDUP], [1],
44 [Define if you have the strndup() function and it works.]) 44 [Define if you have the strndup() function and it works.])
45 else 45 else
46 HAVE_STRNDUP=0 46 HAVE_STRNDUP=0
diff --git a/gl/m4/strnlen.m4 b/gl/m4/strnlen.m4
index d8307ed..1c97859 100644
--- a/gl/m4/strnlen.m4
+++ b/gl/m4/strnlen.m4
@@ -1,5 +1,5 @@
1# strnlen.m4 serial 9 1# strnlen.m4 serial 10
2dnl Copyright (C) 2002-2003, 2005-2007 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2003, 2005-2007, 2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -20,8 +20,8 @@ AC_DEFUN([gl_FUNC_STRNLEN],
20 # This is necessary because automake-1.6.1 doesn't understand 20 # This is necessary because automake-1.6.1 doesn't understand
21 # that the above use of AC_FUNC_STRNLEN means we may have to use 21 # that the above use of AC_FUNC_STRNLEN means we may have to use
22 # lib/strnlen.c. 22 # lib/strnlen.c.
23 #AC_LIBOBJ(strnlen) 23 #AC_LIBOBJ([strnlen])
24 AC_DEFINE(strnlen, rpl_strnlen, 24 AC_DEFINE([strnlen], [rpl_strnlen],
25 [Define to rpl_strnlen if the replacement function should be used.]) 25 [Define to rpl_strnlen if the replacement function should be used.])
26 gl_PREREQ_STRNLEN 26 gl_PREREQ_STRNLEN
27 fi 27 fi
diff --git a/gl/m4/sys_socket_h.m4 b/gl/m4/sys_socket_h.m4
index d9659c2..85a0ace 100644
--- a/gl/m4/sys_socket_h.m4
+++ b/gl/m4/sys_socket_h.m4
@@ -1,5 +1,5 @@
1# sys_socket_h.m4 serial 4 1# sys_socket_h.m4 serial 12
2dnl Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc. 2dnl Copyright (C) 2005-2008 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -8,22 +8,43 @@ dnl From Simon Josefsson.
8 8
9AC_DEFUN([gl_HEADER_SYS_SOCKET], 9AC_DEFUN([gl_HEADER_SYS_SOCKET],
10[ 10[
11 AC_REQUIRE([gl_SYS_SOCKET_H_DEFAULTS])
12 AC_REQUIRE([AC_C_INLINE])
13
11 AC_CACHE_CHECK([whether <sys/socket.h> is self-contained], 14 AC_CACHE_CHECK([whether <sys/socket.h> is self-contained],
12 [gl_cv_header_sys_socket_h_selfcontained], 15 [gl_cv_header_sys_socket_h_selfcontained],
13 [ 16 [
14 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/socket.h>], [])], 17 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/socket.h>]], [[]])],
15 [gl_cv_header_sys_socket_h_selfcontained=yes], 18 [gl_cv_header_sys_socket_h_selfcontained=yes],
16 [gl_cv_header_sys_socket_h_selfcontained=no]) 19 [gl_cv_header_sys_socket_h_selfcontained=no])
17 ]) 20 ])
18 if test $gl_cv_header_sys_socket_h_selfcontained = yes; then 21 if test $gl_cv_header_sys_socket_h_selfcontained = yes; then
19 SYS_SOCKET_H='' 22 SYS_SOCKET_H=''
23 dnl If the shutdown function exists, <sys/socket.h> should define
24 dnl SHUT_RD, SHUT_WR, SHUT_RDWR.
25 AC_CHECK_FUNCS([shutdown])
26 if test $ac_cv_func_shutdown = yes; then
27 AC_CACHE_CHECK([whether <sys/socket.h> defines the SHUT_* macros],
28 [gl_cv_header_sys_socket_h_shut],
29 [
30 AC_COMPILE_IFELSE(
31 [AC_LANG_PROGRAM([[#include <sys/socket.h>]],
32 [[int a[] = { SHUT_RD, SHUT_WR, SHUT_RDWR };]])],
33 [gl_cv_header_sys_socket_h_shut=yes],
34 [gl_cv_header_sys_socket_h_shut=no])
35 ])
36 if test $gl_cv_header_sys_socket_h_shut = no; then
37 SYS_SOCKET_H='sys/socket.h'
38 fi
39 fi
20 else 40 else
21 SYS_SOCKET_H='sys/socket.h' 41 SYS_SOCKET_H='sys/socket.h'
22 42 fi
43 if test -n "$SYS_SOCKET_H"; then
44 dnl Check prerequisites of the <sys/socket.h> replacement.
23 gl_CHECK_NEXT_HEADERS([sys/socket.h]) 45 gl_CHECK_NEXT_HEADERS([sys/socket.h])
24 if test $ac_cv_header_sys_socket_h = yes; then 46 if test $ac_cv_header_sys_socket_h = yes; then
25 HAVE_SYS_SOCKET_H=1 47 HAVE_SYS_SOCKET_H=1
26 HAVE_WINSOCK2_H=0
27 HAVE_WS2TCPIP_H=0 48 HAVE_WS2TCPIP_H=0
28 else 49 else
29 HAVE_SYS_SOCKET_H=0 50 HAVE_SYS_SOCKET_H=0
@@ -31,21 +52,66 @@ AC_DEFUN([gl_HEADER_SYS_SOCKET],
31 dnl the check for those headers unconditional; yet cygwin reports 52 dnl the check for those headers unconditional; yet cygwin reports
32 dnl that the headers are present but cannot be compiled (since on 53 dnl that the headers are present but cannot be compiled (since on
33 dnl cygwin, all socket information should come from sys/socket.h). 54 dnl cygwin, all socket information should come from sys/socket.h).
34 AC_CHECK_HEADERS([winsock2.h ws2tcpip.h]) 55 AC_CHECK_HEADERS([ws2tcpip.h])
35 if test $ac_cv_header_winsock2_h = yes; then
36 HAVE_WINSOCK2_H=1
37 else
38 HAVE_WINSOCK2_H=0
39 fi
40 if test $ac_cv_header_ws2tcpip_h = yes; then 56 if test $ac_cv_header_ws2tcpip_h = yes; then
41 HAVE_WS2TCPIP_H=1 57 HAVE_WS2TCPIP_H=1
42 else 58 else
43 HAVE_WS2TCPIP_H=0 59 HAVE_WS2TCPIP_H=0
44 fi 60 fi
45 fi 61 fi
62 gl_PREREQ_SYS_H_WINSOCK2
46 AC_SUBST([HAVE_SYS_SOCKET_H]) 63 AC_SUBST([HAVE_SYS_SOCKET_H])
47 AC_SUBST([HAVE_WINSOCK2_H])
48 AC_SUBST([HAVE_WS2TCPIP_H]) 64 AC_SUBST([HAVE_WS2TCPIP_H])
49 fi 65 fi
50 AC_SUBST([SYS_SOCKET_H]) 66 AC_SUBST([SYS_SOCKET_H])
51]) 67])
68
69# Common prerequisites of of the <sys/socket.h> replacement and of the
70# <sys/select.h> replacement.
71# Sets and substitutes HAVE_WINSOCK2_H.
72AC_DEFUN([gl_PREREQ_SYS_H_WINSOCK2],
73[
74 m4_ifdef([gl_UNISTD_H_DEFAULTS], [AC_REQUIRE([gl_UNISTD_H_DEFAULTS])])
75 m4_ifdef([gl_SYS_IOCTL_H_DEFAULTS], [AC_REQUIRE([gl_SYS_IOCTL_H_DEFAULTS])])
76 AC_CHECK_HEADERS_ONCE([sys/socket.h])
77 if test $ac_cv_header_sys_socket_h != yes; then
78 dnl We cannot use AC_CHECK_HEADERS_ONCE here, because that would make
79 dnl the check for those headers unconditional; yet cygwin reports
80 dnl that the headers are present but cannot be compiled (since on
81 dnl cygwin, all socket information should come from sys/socket.h).
82 AC_CHECK_HEADERS([winsock2.h])
83 fi
84 if test "$ac_cv_header_winsock2_h" = yes; then
85 HAVE_WINSOCK2_H=1
86 UNISTD_H_HAVE_WINSOCK2_H=1
87 SYS_IOCTL_H_HAVE_WINSOCK2_H=1
88 else
89 HAVE_WINSOCK2_H=0
90 fi
91 AC_SUBST([HAVE_WINSOCK2_H])
92])
93
94AC_DEFUN([gl_SYS_SOCKET_MODULE_INDICATOR],
95[
96 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
97 AC_REQUIRE([gl_SYS_SOCKET_H_DEFAULTS])
98 GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
99])
100
101AC_DEFUN([gl_SYS_SOCKET_H_DEFAULTS],
102[
103 GNULIB_SOCKET=0; AC_SUBST([GNULIB_SOCKET])
104 GNULIB_CONNECT=0; AC_SUBST([GNULIB_CONNECT])
105 GNULIB_ACCEPT=0; AC_SUBST([GNULIB_ACCEPT])
106 GNULIB_BIND=0; AC_SUBST([GNULIB_BIND])
107 GNULIB_GETPEERNAME=0; AC_SUBST([GNULIB_GETPEERNAME])
108 GNULIB_GETSOCKNAME=0; AC_SUBST([GNULIB_GETSOCKNAME])
109 GNULIB_GETSOCKOPT=0; AC_SUBST([GNULIB_GETSOCKOPT])
110 GNULIB_LISTEN=0; AC_SUBST([GNULIB_LISTEN])
111 GNULIB_RECV=0; AC_SUBST([GNULIB_RECV])
112 GNULIB_SEND=0; AC_SUBST([GNULIB_SEND])
113 GNULIB_RECVFROM=0; AC_SUBST([GNULIB_RECVFROM])
114 GNULIB_SENDTO=0; AC_SUBST([GNULIB_SENDTO])
115 GNULIB_SETSOCKOPT=0; AC_SUBST([GNULIB_SETSOCKOPT])
116 GNULIB_SHUTDOWN=0; AC_SUBST([GNULIB_SHUTDOWN])
117])
diff --git a/gl/m4/threadlib.m4 b/gl/m4/threadlib.m4
new file mode 100644
index 0000000..3dd38aa
--- /dev/null
+++ b/gl/m4/threadlib.m4
@@ -0,0 +1,313 @@
1# threadlib.m4 serial 3 (gettext-0.18)
2dnl Copyright (C) 2005-2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8
9dnl gl_THREADLIB
10dnl ------------
11dnl Tests for a multithreading library to be used.
12dnl Defines at most one of the macros USE_POSIX_THREADS, USE_SOLARIS_THREADS,
13dnl USE_PTH_THREADS, USE_WIN32_THREADS
14dnl Sets the variables LIBTHREAD and LTLIBTHREAD to the linker options for use
15dnl in a Makefile (LIBTHREAD for use without libtool, LTLIBTHREAD for use with
16dnl libtool).
17dnl Sets the variables LIBMULTITHREAD and LTLIBMULTITHREAD similarly, for
18dnl programs that really need multithread functionality. The difference
19dnl between LIBTHREAD and LIBMULTITHREAD is that on platforms supporting weak
20dnl symbols, typically LIBTHREAD="" whereas LIBMULTITHREAD="-lpthread".
21dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for
22dnl multithread-safe programs.
23
24AC_DEFUN([gl_THREADLIB_EARLY],
25[
26 AC_REQUIRE([gl_THREADLIB_EARLY_BODY])
27])
28
29dnl The guts of gl_THREADLIB_EARLY. Needs to be expanded only once.
30
31AC_DEFUN([gl_THREADLIB_EARLY_BODY],
32[
33 dnl Ordering constraints: This macro modifies CPPFLAGS in a way that
34 dnl influences the result of the autoconf tests that test for *_unlocked
35 dnl declarations, on AIX 5 at least. Therefore it must come early.
36 AC_BEFORE([$0], [gl_FUNC_GLIBC_UNLOCKED_IO])dnl
37 AC_BEFORE([$0], [gl_ARGP])dnl
38
39 AC_REQUIRE([AC_CANONICAL_HOST])
40 dnl _GNU_SOURCE is needed for pthread_rwlock_t on glibc systems.
41 dnl AC_USE_SYSTEM_EXTENSIONS was introduced in autoconf 2.60 and obsoletes
42 dnl AC_GNU_SOURCE.
43 m4_ifdef([AC_USE_SYSTEM_EXTENSIONS],
44 [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])],
45 [AC_REQUIRE([AC_GNU_SOURCE])])
46 dnl Check for multithreading.
47 m4_divert_text([DEFAULTS], [gl_use_threads_default=])
48 AC_ARG_ENABLE([threads],
49AC_HELP_STRING([--enable-threads={posix|solaris|pth|win32}], [specify multithreading API])
50AC_HELP_STRING([--disable-threads], [build without multithread safety]),
51 [gl_use_threads=$enableval],
52 [if test -n "$gl_use_threads_default"; then
53 gl_use_threads="$gl_use_threads_default"
54 else
55 case "$host_os" in
56 dnl Disable multithreading by default on OSF/1, because it interferes
57 dnl with fork()/exec(): When msgexec is linked with -lpthread, its
58 dnl child process gets an endless segmentation fault inside execvp().
59 osf*) gl_use_threads=no ;;
60 *) gl_use_threads=yes ;;
61 esac
62 fi
63 ])
64 if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then
65 # For using <pthread.h>:
66 case "$host_os" in
67 osf*)
68 # On OSF/1, the compiler needs the flag -D_REENTRANT so that it
69 # groks <pthread.h>. cc also understands the flag -pthread, but
70 # we don't use it because 1. gcc-2.95 doesn't understand -pthread,
71 # 2. putting a flag into CPPFLAGS that has an effect on the linker
72 # causes the AC_TRY_LINK test below to succeed unexpectedly,
73 # leading to wrong values of LIBTHREAD and LTLIBTHREAD.
74 CPPFLAGS="$CPPFLAGS -D_REENTRANT"
75 ;;
76 esac
77 # Some systems optimize for single-threaded programs by default, and
78 # need special flags to disable these optimizations. For example, the
79 # definition of 'errno' in <errno.h>.
80 case "$host_os" in
81 aix* | freebsd*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;;
82 solaris*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;;
83 esac
84 fi
85])
86
87dnl The guts of gl_THREADLIB. Needs to be expanded only once.
88
89AC_DEFUN([gl_THREADLIB_BODY],
90[
91 AC_REQUIRE([gl_THREADLIB_EARLY_BODY])
92 gl_threads_api=none
93 LIBTHREAD=
94 LTLIBTHREAD=
95 LIBMULTITHREAD=
96 LTLIBMULTITHREAD=
97 if test "$gl_use_threads" != no; then
98 dnl Check whether the compiler and linker support weak declarations.
99 AC_MSG_CHECKING([whether imported symbols can be declared weak])
100 gl_have_weak=no
101 AC_TRY_LINK([extern void xyzzy ();
102#pragma weak xyzzy], [xyzzy();], [gl_have_weak=yes])
103 AC_MSG_RESULT([$gl_have_weak])
104 if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then
105 # On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that
106 # it groks <pthread.h>. It's added above, in gl_THREADLIB_EARLY_BODY.
107 AC_CHECK_HEADER([pthread.h],
108 [gl_have_pthread_h=yes], [gl_have_pthread_h=no])
109 if test "$gl_have_pthread_h" = yes; then
110 # Other possible tests:
111 # -lpthreads (FSU threads, PCthreads)
112 # -lgthreads
113 gl_have_pthread=
114 # Test whether both pthread_mutex_lock and pthread_mutexattr_init exist
115 # in libc. IRIX 6.5 has the first one in both libc and libpthread, but
116 # the second one only in libpthread, and lock.c needs it.
117 AC_TRY_LINK([#include <pthread.h>],
118 [pthread_mutex_lock((pthread_mutex_t*)0);
119 pthread_mutexattr_init((pthread_mutexattr_t*)0);],
120 [gl_have_pthread=yes])
121 # Test for libpthread by looking for pthread_kill. (Not pthread_self,
122 # since it is defined as a macro on OSF/1.)
123 if test -n "$gl_have_pthread"; then
124 # The program links fine without libpthread. But it may actually
125 # need to link with libpthread in order to create multiple threads.
126 AC_CHECK_LIB([pthread], [pthread_kill],
127 [LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread
128 # On Solaris and HP-UX, most pthread functions exist also in libc.
129 # Therefore pthread_in_use() needs to actually try to create a
130 # thread: pthread_create from libc will fail, whereas
131 # pthread_create will actually create a thread.
132 case "$host_os" in
133 solaris* | hpux*)
134 AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], [1],
135 [Define if the pthread_in_use() detection is hard.])
136 esac
137 ])
138 else
139 # Some library is needed. Try libpthread and libc_r.
140 AC_CHECK_LIB([pthread], [pthread_kill],
141 [gl_have_pthread=yes
142 LIBTHREAD=-lpthread LTLIBTHREAD=-lpthread
143 LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread])
144 if test -z "$gl_have_pthread"; then
145 # For FreeBSD 4.
146 AC_CHECK_LIB([c_r], [pthread_kill],
147 [gl_have_pthread=yes
148 LIBTHREAD=-lc_r LTLIBTHREAD=-lc_r
149 LIBMULTITHREAD=-lc_r LTLIBMULTITHREAD=-lc_r])
150 fi
151 fi
152 if test -n "$gl_have_pthread"; then
153 gl_threads_api=posix
154 AC_DEFINE([USE_POSIX_THREADS], [1],
155 [Define if the POSIX multithreading library can be used.])
156 if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then
157 if test $gl_have_weak = yes; then
158 AC_DEFINE([USE_POSIX_THREADS_WEAK], [1],
159 [Define if references to the POSIX multithreading library should be made weak.])
160 LIBTHREAD=
161 LTLIBTHREAD=
162 fi
163 fi
164 fi
165 fi
166 fi
167 if test -z "$gl_have_pthread"; then
168 if test "$gl_use_threads" = yes || test "$gl_use_threads" = solaris; then
169 gl_have_solaristhread=
170 gl_save_LIBS="$LIBS"
171 LIBS="$LIBS -lthread"
172 AC_TRY_LINK([#include <thread.h>
173#include <synch.h>],
174 [thr_self();],
175 [gl_have_solaristhread=yes])
176 LIBS="$gl_save_LIBS"
177 if test -n "$gl_have_solaristhread"; then
178 gl_threads_api=solaris
179 LIBTHREAD=-lthread
180 LTLIBTHREAD=-lthread
181 LIBMULTITHREAD="$LIBTHREAD"
182 LTLIBMULTITHREAD="$LTLIBTHREAD"
183 AC_DEFINE([USE_SOLARIS_THREADS], [1],
184 [Define if the old Solaris multithreading library can be used.])
185 if test $gl_have_weak = yes; then
186 AC_DEFINE([USE_SOLARIS_THREADS_WEAK], [1],
187 [Define if references to the old Solaris multithreading library should be made weak.])
188 LIBTHREAD=
189 LTLIBTHREAD=
190 fi
191 fi
192 fi
193 fi
194 if test "$gl_use_threads" = pth; then
195 gl_save_CPPFLAGS="$CPPFLAGS"
196 AC_LIB_LINKFLAGS([pth])
197 gl_have_pth=
198 gl_save_LIBS="$LIBS"
199 LIBS="$LIBS -lpth"
200 AC_TRY_LINK([#include <pth.h>], [pth_self();], [gl_have_pth=yes])
201 LIBS="$gl_save_LIBS"
202 if test -n "$gl_have_pth"; then
203 gl_threads_api=pth
204 LIBTHREAD="$LIBPTH"
205 LTLIBTHREAD="$LTLIBPTH"
206 LIBMULTITHREAD="$LIBTHREAD"
207 LTLIBMULTITHREAD="$LTLIBTHREAD"
208 AC_DEFINE([USE_PTH_THREADS], [1],
209 [Define if the GNU Pth multithreading library can be used.])
210 if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then
211 if test $gl_have_weak = yes; then
212 AC_DEFINE([USE_PTH_THREADS_WEAK], [1],
213 [Define if references to the GNU Pth multithreading library should be made weak.])
214 LIBTHREAD=
215 LTLIBTHREAD=
216 fi
217 fi
218 else
219 CPPFLAGS="$gl_save_CPPFLAGS"
220 fi
221 fi
222 if test -z "$gl_have_pthread"; then
223 if test "$gl_use_threads" = yes || test "$gl_use_threads" = win32; then
224 if { case "$host_os" in
225 mingw*) true;;
226 *) false;;
227 esac
228 }; then
229 gl_threads_api=win32
230 AC_DEFINE([USE_WIN32_THREADS], [1],
231 [Define if the Win32 multithreading API can be used.])
232 fi
233 fi
234 fi
235 fi
236 AC_MSG_CHECKING([for multithread API to use])
237 AC_MSG_RESULT([$gl_threads_api])
238 AC_SUBST([LIBTHREAD])
239 AC_SUBST([LTLIBTHREAD])
240 AC_SUBST([LIBMULTITHREAD])
241 AC_SUBST([LTLIBMULTITHREAD])
242])
243
244AC_DEFUN([gl_THREADLIB],
245[
246 AC_REQUIRE([gl_THREADLIB_EARLY])
247 AC_REQUIRE([gl_THREADLIB_BODY])
248])
249
250
251dnl gl_DISABLE_THREADS
252dnl ------------------
253dnl Sets the gl_THREADLIB default so that threads are not used by default.
254dnl The user can still override it at installation time, by using the
255dnl configure option '--enable-threads'.
256
257AC_DEFUN([gl_DISABLE_THREADS], [
258 m4_divert_text([INIT_PREPARE], [gl_use_threads_default=no])
259])
260
261
262dnl Survey of platforms:
263dnl
264dnl Platform Available Compiler Supports test-lock
265dnl flavours option weak result
266dnl --------------- --------- --------- -------- ---------
267dnl Linux 2.4/glibc posix -lpthread Y OK
268dnl
269dnl GNU Hurd/glibc posix
270dnl
271dnl FreeBSD 5.3 posix -lc_r Y
272dnl posix -lkse ? Y
273dnl posix -lpthread ? Y
274dnl posix -lthr Y
275dnl
276dnl FreeBSD 5.2 posix -lc_r Y
277dnl posix -lkse Y
278dnl posix -lthr Y
279dnl
280dnl FreeBSD 4.0,4.10 posix -lc_r Y OK
281dnl
282dnl NetBSD 1.6 --
283dnl
284dnl OpenBSD 3.4 posix -lpthread Y OK
285dnl
286dnl MacOS X 10.[123] posix -lpthread Y OK
287dnl
288dnl Solaris 7,8,9 posix -lpthread Y Sol 7,8: 0.0; Sol 9: OK
289dnl solaris -lthread Y Sol 7,8: 0.0; Sol 9: OK
290dnl
291dnl HP-UX 11 posix -lpthread N (cc) OK
292dnl Y (gcc)
293dnl
294dnl IRIX 6.5 posix -lpthread Y 0.5
295dnl
296dnl AIX 4.3,5.1 posix -lpthread N AIX 4: 0.5; AIX 5: OK
297dnl
298dnl OSF/1 4.0,5.1 posix -pthread (cc) N OK
299dnl -lpthread (gcc) Y
300dnl
301dnl Cygwin posix -lpthread Y OK
302dnl
303dnl Any of the above pth -lpth 0.0
304dnl
305dnl Mingw win32 N OK
306dnl
307dnl BeOS 5 --
308dnl
309dnl The test-lock result shows what happens if in test-lock.c EXPLICIT_YIELD is
310dnl turned off:
311dnl OK if all three tests terminate OK,
312dnl 0.5 if the first test terminates OK but the second one loops endlessly,
313dnl 0.0 if the first test already loops endlessly.
diff --git a/gl/m4/uintmax_t.m4 b/gl/m4/uintmax_t.m4
index 641c489..734b693 100644
--- a/gl/m4/uintmax_t.m4
+++ b/gl/m4/uintmax_t.m4
@@ -1,12 +1,12 @@
1# uintmax_t.m4 serial 10 1# uintmax_t.m4 serial 12
2dnl Copyright (C) 1997-2004, 2007 Free Software Foundation, Inc. 2dnl Copyright (C) 1997-2004, 2007-2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7dnl From Paul Eggert. 7dnl From Paul Eggert.
8 8
9AC_PREREQ(2.13) 9AC_PREREQ([2.13])
10 10
11# Define uintmax_t to 'unsigned long' or 'unsigned long long' 11# Define uintmax_t to 'unsigned long' or 'unsigned long long'
12# if it is not already defined in <stdint.h> or <inttypes.h>. 12# if it is not already defined in <stdint.h> or <inttypes.h>.
@@ -20,11 +20,11 @@ AC_DEFUN([gl_AC_TYPE_UINTMAX_T],
20 test $ac_cv_type_unsigned_long_long_int = yes \ 20 test $ac_cv_type_unsigned_long_long_int = yes \
21 && ac_type='unsigned long long' \ 21 && ac_type='unsigned long long' \
22 || ac_type='unsigned long' 22 || ac_type='unsigned long'
23 AC_DEFINE_UNQUOTED(uintmax_t, $ac_type, 23 AC_DEFINE_UNQUOTED([uintmax_t], [$ac_type],
24 [Define to unsigned long or unsigned long long 24 [Define to unsigned long or unsigned long long
25 if <stdint.h> and <inttypes.h> don't define.]) 25 if <stdint.h> and <inttypes.h> don't define.])
26 else 26 else
27 AC_DEFINE(HAVE_UINTMAX_T, 1, 27 AC_DEFINE([HAVE_UINTMAX_T], [1],
28 [Define if you have the 'uintmax_t' type in <stdint.h> or <inttypes.h>.]) 28 [Define if you have the 'uintmax_t' type in <stdint.h> or <inttypes.h>.])
29 fi 29 fi
30]) 30])
diff --git a/gl/m4/unistd_h.m4 b/gl/m4/unistd_h.m4
index 4b8857c..5685273 100644
--- a/gl/m4/unistd_h.m4
+++ b/gl/m4/unistd_h.m4
@@ -1,5 +1,5 @@
1# unistd_h.m4 serial 10 1# unistd_h.m4 serial 16
2dnl Copyright (C) 2006-2007 Free Software Foundation, Inc. 2dnl Copyright (C) 2006-2008 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -32,30 +32,50 @@ AC_DEFUN([gl_UNISTD_MODULE_INDICATOR],
32 32
33AC_DEFUN([gl_UNISTD_H_DEFAULTS], 33AC_DEFUN([gl_UNISTD_H_DEFAULTS],
34[ 34[
35 GNULIB_CHOWN=0; AC_SUBST([GNULIB_CHOWN]) 35 GNULIB_CHOWN=0; AC_SUBST([GNULIB_CHOWN])
36 GNULIB_DUP2=0; AC_SUBST([GNULIB_DUP2]) 36 GNULIB_CLOSE=0; AC_SUBST([GNULIB_CLOSE])
37 GNULIB_FCHDIR=0; AC_SUBST([GNULIB_FCHDIR]) 37 GNULIB_DUP2=0; AC_SUBST([GNULIB_DUP2])
38 GNULIB_FTRUNCATE=0; AC_SUBST([GNULIB_FTRUNCATE]) 38 GNULIB_ENVIRON=0; AC_SUBST([GNULIB_ENVIRON])
39 GNULIB_GETCWD=0; AC_SUBST([GNULIB_GETCWD]) 39 GNULIB_EUIDACCESS=0; AC_SUBST([GNULIB_EUIDACCESS])
40 GNULIB_GETLOGIN_R=0; AC_SUBST([GNULIB_GETLOGIN_R]) 40 GNULIB_FCHDIR=0; AC_SUBST([GNULIB_FCHDIR])
41 GNULIB_GETPAGESIZE=0; AC_SUBST([GNULIB_GETPAGESIZE]) 41 GNULIB_FSYNC=0; AC_SUBST([GNULIB_FSYNC])
42 GNULIB_LCHOWN=0; AC_SUBST([GNULIB_LCHOWN]) 42 GNULIB_FTRUNCATE=0; AC_SUBST([GNULIB_FTRUNCATE])
43 GNULIB_LSEEK=0; AC_SUBST([GNULIB_LSEEK]) 43 GNULIB_GETCWD=0; AC_SUBST([GNULIB_GETCWD])
44 GNULIB_READLINK=0; AC_SUBST([GNULIB_READLINK]) 44 GNULIB_GETDOMAINNAME=0; AC_SUBST([GNULIB_GETDOMAINNAME])
45 GNULIB_SLEEP=0; AC_SUBST([GNULIB_SLEEP]) 45 GNULIB_GETDTABLESIZE=0; AC_SUBST([GNULIB_GETDTABLESIZE])
46 GNULIB_GETHOSTNAME=0; AC_SUBST([GNULIB_GETHOSTNAME])
47 GNULIB_GETLOGIN_R=0; AC_SUBST([GNULIB_GETLOGIN_R])
48 GNULIB_GETPAGESIZE=0; AC_SUBST([GNULIB_GETPAGESIZE])
49 GNULIB_GETUSERSHELL=0; AC_SUBST([GNULIB_GETUSERSHELL])
50 GNULIB_LCHOWN=0; AC_SUBST([GNULIB_LCHOWN])
51 GNULIB_LSEEK=0; AC_SUBST([GNULIB_LSEEK])
52 GNULIB_READLINK=0; AC_SUBST([GNULIB_READLINK])
53 GNULIB_SLEEP=0; AC_SUBST([GNULIB_SLEEP])
54 GNULIB_UNISTD_H_SIGPIPE=0; AC_SUBST([GNULIB_UNISTD_H_SIGPIPE])
55 GNULIB_WRITE=0; AC_SUBST([GNULIB_WRITE])
46 dnl Assume proper GNU behavior unless another module says otherwise. 56 dnl Assume proper GNU behavior unless another module says otherwise.
47 HAVE_DUP2=1; AC_SUBST([HAVE_DUP2]) 57 HAVE_DUP2=1; AC_SUBST([HAVE_DUP2])
58 HAVE_EUIDACCESS=1; AC_SUBST([HAVE_EUIDACCESS])
59 HAVE_FSYNC=1; AC_SUBST([HAVE_FSYNC])
48 HAVE_FTRUNCATE=1; AC_SUBST([HAVE_FTRUNCATE]) 60 HAVE_FTRUNCATE=1; AC_SUBST([HAVE_FTRUNCATE])
61 HAVE_GETDOMAINNAME=1; AC_SUBST([HAVE_GETDOMAINNAME])
62 HAVE_GETDTABLESIZE=1; AC_SUBST([HAVE_GETDTABLESIZE])
63 HAVE_GETHOSTNAME=1; AC_SUBST([HAVE_GETHOSTNAME])
49 HAVE_GETPAGESIZE=1; AC_SUBST([HAVE_GETPAGESIZE]) 64 HAVE_GETPAGESIZE=1; AC_SUBST([HAVE_GETPAGESIZE])
65 HAVE_GETUSERSHELL=1; AC_SUBST([HAVE_GETUSERSHELL])
50 HAVE_READLINK=1; AC_SUBST([HAVE_READLINK]) 66 HAVE_READLINK=1; AC_SUBST([HAVE_READLINK])
51 HAVE_SLEEP=1; AC_SUBST([HAVE_SLEEP]) 67 HAVE_SLEEP=1; AC_SUBST([HAVE_SLEEP])
68 HAVE_DECL_ENVIRON=1; AC_SUBST([HAVE_DECL_ENVIRON])
52 HAVE_DECL_GETLOGIN_R=1; AC_SUBST([HAVE_DECL_GETLOGIN_R]) 69 HAVE_DECL_GETLOGIN_R=1; AC_SUBST([HAVE_DECL_GETLOGIN_R])
53 HAVE_OS_H=0; AC_SUBST([HAVE_OS_H]) 70 HAVE_OS_H=0; AC_SUBST([HAVE_OS_H])
54 HAVE_SYS_PARAM_H=0; AC_SUBST([HAVE_SYS_PARAM_H]) 71 HAVE_SYS_PARAM_H=0; AC_SUBST([HAVE_SYS_PARAM_H])
55 REPLACE_CHOWN=0; AC_SUBST([REPLACE_CHOWN]) 72 REPLACE_CHOWN=0; AC_SUBST([REPLACE_CHOWN])
73 REPLACE_CLOSE=0; AC_SUBST([REPLACE_CLOSE])
56 REPLACE_FCHDIR=0; AC_SUBST([REPLACE_FCHDIR]) 74 REPLACE_FCHDIR=0; AC_SUBST([REPLACE_FCHDIR])
57 REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD]) 75 REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD])
58 REPLACE_GETPAGESIZE=0; AC_SUBST([REPLACE_GETPAGESIZE]) 76 REPLACE_GETPAGESIZE=0; AC_SUBST([REPLACE_GETPAGESIZE])
59 REPLACE_LCHOWN=0; AC_SUBST([REPLACE_LCHOWN]) 77 REPLACE_LCHOWN=0; AC_SUBST([REPLACE_LCHOWN])
60 REPLACE_LSEEK=0; AC_SUBST([REPLACE_LSEEK]) 78 REPLACE_LSEEK=0; AC_SUBST([REPLACE_LSEEK])
79 REPLACE_WRITE=0; AC_SUBST([REPLACE_WRITE])
80 UNISTD_H_HAVE_WINSOCK2_H=0; AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H])
61]) 81])
diff --git a/gl/m4/vasnprintf.m4 b/gl/m4/vasnprintf.m4
index c4d3f4f..9e839d2 100644
--- a/gl/m4/vasnprintf.m4
+++ b/gl/m4/vasnprintf.m4
@@ -1,12 +1,11 @@
1# vasnprintf.m4 serial 24 1# vasnprintf.m4 serial 26
2dnl Copyright (C) 2002-2004, 2006-2008 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2004, 2006-2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
6 6
7AC_DEFUN([gl_FUNC_VASNPRINTF], 7AC_DEFUN([gl_FUNC_VASNPRINTF],
8[ 8[
9 AC_REQUIRE([gl_EOVERFLOW])
10 AC_CHECK_FUNCS_ONCE([vasnprintf]) 9 AC_CHECK_FUNCS_ONCE([vasnprintf])
11 if test $ac_cv_func_vasnprintf = no; then 10 if test $ac_cv_func_vasnprintf = no; then
12 gl_REPLACE_VASNPRINTF 11 gl_REPLACE_VASNPRINTF
@@ -21,7 +20,7 @@ AC_DEFUN([gl_REPLACE_VASNPRINTF],
21 AC_LIBOBJ([printf-parse]) 20 AC_LIBOBJ([printf-parse])
22 AC_LIBOBJ([asnprintf]) 21 AC_LIBOBJ([asnprintf])
23 if test $ac_cv_func_vasnprintf = yes; then 22 if test $ac_cv_func_vasnprintf = yes; then
24 AC_DEFINE([REPLACE_VASNPRINTF], 1, 23 AC_DEFINE([REPLACE_VASNPRINTF], [1],
25 [Define if vasnprintf exists but is overridden by gnulib.]) 24 [Define if vasnprintf exists but is overridden by gnulib.])
26 fi 25 fi
27 gl_PREREQ_PRINTF_ARGS 26 gl_PREREQ_PRINTF_ARGS
@@ -59,7 +58,7 @@ AC_DEFUN([gl_PREREQ_VASNPRINTF],
59 AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) 58 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
60 AC_REQUIRE([gt_TYPE_WCHAR_T]) 59 AC_REQUIRE([gt_TYPE_WCHAR_T])
61 AC_REQUIRE([gt_TYPE_WINT_T]) 60 AC_REQUIRE([gt_TYPE_WINT_T])
62 AC_CHECK_FUNCS(snprintf wcslen) 61 AC_CHECK_FUNCS([snprintf wcslen])
63 dnl Use the _snprintf function only if it is declared (because on NetBSD it 62 dnl Use the _snprintf function only if it is declared (because on NetBSD it
64 dnl is defined as a weak alias of snprintf; we prefer to use the latter). 63 dnl is defined as a weak alias of snprintf; we prefer to use the latter).
65 AC_CHECK_DECLS([_snprintf], , , [#include <stdio.h>]) 64 AC_CHECK_DECLS([_snprintf], , , [#include <stdio.h>])
@@ -74,7 +73,7 @@ AC_DEFUN([gl_PREREQ_VASNPRINTF_LONG_DOUBLE],
74 *yes) 73 *yes)
75 ;; 74 ;;
76 *) 75 *)
77 AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], 1, 76 AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1],
78 [Define if the vasnprintf implementation needs special code for 77 [Define if the vasnprintf implementation needs special code for
79 'long double' arguments.]) 78 'long double' arguments.])
80 ;; 79 ;;
@@ -90,7 +89,7 @@ AC_DEFUN([gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE],
90 *yes) 89 *yes)
91 ;; 90 ;;
92 *) 91 *)
93 AC_DEFINE([NEED_PRINTF_INFINITE_DOUBLE], 1, 92 AC_DEFINE([NEED_PRINTF_INFINITE_DOUBLE], [1],
94 [Define if the vasnprintf implementation needs special code for 93 [Define if the vasnprintf implementation needs special code for
95 infinite 'double' arguments.]) 94 infinite 'double' arguments.])
96 ;; 95 ;;
@@ -111,7 +110,7 @@ AC_DEFUN([gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE],
111 *yes) 110 *yes)
112 ;; 111 ;;
113 *) 112 *)
114 AC_DEFINE([NEED_PRINTF_INFINITE_LONG_DOUBLE], 1, 113 AC_DEFINE([NEED_PRINTF_INFINITE_LONG_DOUBLE], [1],
115 [Define if the vasnprintf implementation needs special code for 114 [Define if the vasnprintf implementation needs special code for
116 infinite 'long double' arguments.]) 115 infinite 'long double' arguments.])
117 ;; 116 ;;
@@ -128,7 +127,7 @@ AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_A],
128 *yes) 127 *yes)
129 ;; 128 ;;
130 *) 129 *)
131 AC_DEFINE([NEED_PRINTF_DIRECTIVE_A], 1, 130 AC_DEFINE([NEED_PRINTF_DIRECTIVE_A], [1],
132 [Define if the vasnprintf implementation needs special code for 131 [Define if the vasnprintf implementation needs special code for
133 the 'a' and 'A' directives.]) 132 the 'a' and 'A' directives.])
134 AC_CHECK_FUNCS([nl_langinfo]) 133 AC_CHECK_FUNCS([nl_langinfo])
@@ -144,7 +143,7 @@ AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_F],
144 *yes) 143 *yes)
145 ;; 144 ;;
146 *) 145 *)
147 AC_DEFINE([NEED_PRINTF_DIRECTIVE_F], 1, 146 AC_DEFINE([NEED_PRINTF_DIRECTIVE_F], [1],
148 [Define if the vasnprintf implementation needs special code for 147 [Define if the vasnprintf implementation needs special code for
149 the 'F' directive.]) 148 the 'F' directive.])
150 ;; 149 ;;
@@ -159,7 +158,7 @@ AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_GROUPING],
159 *yes) 158 *yes)
160 ;; 159 ;;
161 *) 160 *)
162 AC_DEFINE([NEED_PRINTF_FLAG_GROUPING], 1, 161 AC_DEFINE([NEED_PRINTF_FLAG_GROUPING], [1],
163 [Define if the vasnprintf implementation needs special code for the 162 [Define if the vasnprintf implementation needs special code for the
164 ' flag.]) 163 ' flag.])
165 ;; 164 ;;
@@ -174,7 +173,7 @@ AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_LEFTADJUST],
174 *yes) 173 *yes)
175 ;; 174 ;;
176 *) 175 *)
177 AC_DEFINE([NEED_PRINTF_FLAG_LEFTADJUST], 1, 176 AC_DEFINE([NEED_PRINTF_FLAG_LEFTADJUST], [1],
178 [Define if the vasnprintf implementation needs special code for the 177 [Define if the vasnprintf implementation needs special code for the
179 '-' flag.]) 178 '-' flag.])
180 ;; 179 ;;
@@ -189,7 +188,7 @@ AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_ZERO],
189 *yes) 188 *yes)
190 ;; 189 ;;
191 *) 190 *)
192 AC_DEFINE([NEED_PRINTF_FLAG_ZERO], 1, 191 AC_DEFINE([NEED_PRINTF_FLAG_ZERO], [1],
193 [Define if the vasnprintf implementation needs special code for the 192 [Define if the vasnprintf implementation needs special code for the
194 0 flag.]) 193 0 flag.])
195 ;; 194 ;;
@@ -204,13 +203,13 @@ AC_DEFUN([gl_PREREQ_VASNPRINTF_PRECISION],
204 *yes) 203 *yes)
205 ;; 204 ;;
206 *) 205 *)
207 AC_DEFINE([NEED_PRINTF_UNBOUNDED_PRECISION], 1, 206 AC_DEFINE([NEED_PRINTF_UNBOUNDED_PRECISION], [1],
208 [Define if the vasnprintf implementation needs special code for 207 [Define if the vasnprintf implementation needs special code for
209 supporting large precisions without arbitrary bounds.]) 208 supporting large precisions without arbitrary bounds.])
210 AC_DEFINE([NEED_PRINTF_DOUBLE], 1, 209 AC_DEFINE([NEED_PRINTF_DOUBLE], [1],
211 [Define if the vasnprintf implementation needs special code for 210 [Define if the vasnprintf implementation needs special code for
212 'double' arguments.]) 211 'double' arguments.])
213 AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], 1, 212 AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1],
214 [Define if the vasnprintf implementation needs special code for 213 [Define if the vasnprintf implementation needs special code for
215 'long double' arguments.]) 214 'long double' arguments.])
216 ;; 215 ;;
@@ -226,13 +225,13 @@ AC_DEFUN([gl_PREREQ_VASNPRINTF_ENOMEM],
226 *yes) 225 *yes)
227 ;; 226 ;;
228 *) 227 *)
229 AC_DEFINE([NEED_PRINTF_ENOMEM], 1, 228 AC_DEFINE([NEED_PRINTF_ENOMEM], [1],
230 [Define if the vasnprintf implementation needs special code for 229 [Define if the vasnprintf implementation needs special code for
231 surviving out-of-memory conditions.]) 230 surviving out-of-memory conditions.])
232 AC_DEFINE([NEED_PRINTF_DOUBLE], 1, 231 AC_DEFINE([NEED_PRINTF_DOUBLE], [1],
233 [Define if the vasnprintf implementation needs special code for 232 [Define if the vasnprintf implementation needs special code for
234 'double' arguments.]) 233 'double' arguments.])
235 AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], 1, 234 AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1],
236 [Define if the vasnprintf implementation needs special code for 235 [Define if the vasnprintf implementation needs special code for
237 'long double' arguments.]) 236 'long double' arguments.])
238 ;; 237 ;;
diff --git a/gl/m4/visibility.m4 b/gl/m4/visibility.m4
index 2ff6330..70bca56 100644
--- a/gl/m4/visibility.m4
+++ b/gl/m4/visibility.m4
@@ -1,5 +1,5 @@
1# visibility.m4 serial 1 (gettext-0.15) 1# visibility.m4 serial 2 (gettext-0.18)
2dnl Copyright (C) 2005 Free Software Foundation, Inc. 2dnl Copyright (C) 2005, 2008 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -27,7 +27,7 @@ AC_DEFUN([gl_VISIBILITY],
27 HAVE_VISIBILITY=0 27 HAVE_VISIBILITY=0
28 if test -n "$GCC"; then 28 if test -n "$GCC"; then
29 AC_MSG_CHECKING([for simple visibility declarations]) 29 AC_MSG_CHECKING([for simple visibility declarations])
30 AC_CACHE_VAL(gl_cv_cc_visibility, [ 30 AC_CACHE_VAL([gl_cv_cc_visibility], [
31 gl_save_CFLAGS="$CFLAGS" 31 gl_save_CFLAGS="$CFLAGS"
32 CFLAGS="$CFLAGS -fvisibility=hidden" 32 CFLAGS="$CFLAGS -fvisibility=hidden"
33 AC_TRY_COMPILE( 33 AC_TRY_COMPILE(
@@ -36,8 +36,8 @@ AC_DEFUN([gl_VISIBILITY],
36 extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void); 36 extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void);
37 extern __attribute__((__visibility__("default"))) int exportedfunc (void);], 37 extern __attribute__((__visibility__("default"))) int exportedfunc (void);],
38 [], 38 [],
39 gl_cv_cc_visibility=yes, 39 [gl_cv_cc_visibility=yes],
40 gl_cv_cc_visibility=no) 40 [gl_cv_cc_visibility=no])
41 CFLAGS="$gl_save_CFLAGS"]) 41 CFLAGS="$gl_save_CFLAGS"])
42 AC_MSG_RESULT([$gl_cv_cc_visibility]) 42 AC_MSG_RESULT([$gl_cv_cc_visibility])
43 if test $gl_cv_cc_visibility = yes; then 43 if test $gl_cv_cc_visibility = yes; then
diff --git a/gl/m4/vsnprintf.m4 b/gl/m4/vsnprintf.m4
index accc79f..3b37d46 100644
--- a/gl/m4/vsnprintf.m4
+++ b/gl/m4/vsnprintf.m4
@@ -1,5 +1,5 @@
1# vsnprintf.m4 serial 4 1# vsnprintf.m4 serial 5
2dnl Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2004, 2007-2008 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -7,8 +7,17 @@ dnl with or without modifications, as long as this notice is preserved.
7AC_DEFUN([gl_FUNC_VSNPRINTF], 7AC_DEFUN([gl_FUNC_VSNPRINTF],
8[ 8[
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS]) 9 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
10 gl_cv_func_vsnprintf_usable=no
10 AC_CHECK_FUNCS([vsnprintf]) 11 AC_CHECK_FUNCS([vsnprintf])
11 if test $ac_cv_func_vsnprintf = no; then 12 if test $ac_cv_func_vsnprintf = yes; then
13 gl_SNPRINTF_SIZE1
14 case "$gl_cv_func_snprintf_size1" in
15 *yes)
16 gl_cv_func_vsnprintf_usable=yes
17 ;;
18 esac
19 fi
20 if test $gl_cv_func_vsnprintf_usable = no; then
12 gl_REPLACE_VSNPRINTF 21 gl_REPLACE_VSNPRINTF
13 fi 22 fi
14 AC_CHECK_DECLS_ONCE([vsnprintf]) 23 AC_CHECK_DECLS_ONCE([vsnprintf])
diff --git a/gl/m4/wchar.m4 b/gl/m4/wchar.m4
index 70b1248..ba8ee6a 100644
--- a/gl/m4/wchar.m4
+++ b/gl/m4/wchar.m4
@@ -1,13 +1,13 @@
1dnl A placeholder for ISO C99 <wchar.h>, for platforms that have issues. 1dnl A placeholder for ISO C99 <wchar.h>, for platforms that have issues.
2 2
3dnl Copyright (C) 2007 Free Software Foundation, Inc. 3dnl Copyright (C) 2007-2008 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
7 7
8dnl Written by Eric Blake. 8dnl Written by Eric Blake.
9 9
10# wchar.m4 serial 4 10# wchar.m4 serial 22
11 11
12AC_DEFUN([gl_WCHAR_H], 12AC_DEFUN([gl_WCHAR_H],
13[ 13[
@@ -18,7 +18,16 @@ AC_DEFUN([gl_WCHAR_H],
18wchar_t w;]], 18wchar_t w;]],
19 [gl_cv_header_wchar_h_standalone=yes], 19 [gl_cv_header_wchar_h_standalone=yes],
20 [gl_cv_header_wchar_h_standalone=no])]) 20 [gl_cv_header_wchar_h_standalone=no])])
21 if test $gl_cv_header_wchar_h_standalone != yes; then 21
22 AC_REQUIRE([gt_TYPE_WINT_T])
23 if test $gt_cv_c_wint_t = yes; then
24 HAVE_WINT_T=1
25 else
26 HAVE_WINT_T=0
27 fi
28 AC_SUBST([HAVE_WINT_T])
29
30 if test $gl_cv_header_wchar_h_standalone != yes || test $gt_cv_c_wint_t != yes; then
22 WCHAR_H=wchar.h 31 WCHAR_H=wchar.h
23 fi 32 fi
24 33
@@ -36,6 +45,13 @@ wchar_t w;]],
36 gl_CHECK_NEXT_HEADERS([wchar.h]) 45 gl_CHECK_NEXT_HEADERS([wchar.h])
37]) 46])
38 47
48dnl Unconditionally enables the replacement of <wchar.h>.
49AC_DEFUN([gl_REPLACE_WCHAR_H],
50[
51 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
52 WCHAR_H=wchar.h
53])
54
39AC_DEFUN([gl_WCHAR_MODULE_INDICATOR], 55AC_DEFUN([gl_WCHAR_MODULE_INDICATOR],
40[ 56[
41 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 57 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
@@ -45,10 +61,39 @@ AC_DEFUN([gl_WCHAR_MODULE_INDICATOR],
45 61
46AC_DEFUN([gl_WCHAR_H_DEFAULTS], 62AC_DEFUN([gl_WCHAR_H_DEFAULTS],
47[ 63[
48 GNULIB_WCWIDTH=0; AC_SUBST([GNULIB_WCWIDTH]) 64 GNULIB_BTOWC=0; AC_SUBST([GNULIB_BTOWC])
65 GNULIB_WCTOB=0; AC_SUBST([GNULIB_WCTOB])
66 GNULIB_MBSINIT=0; AC_SUBST([GNULIB_MBSINIT])
67 GNULIB_MBRTOWC=0; AC_SUBST([GNULIB_MBRTOWC])
68 GNULIB_MBRLEN=0; AC_SUBST([GNULIB_MBRLEN])
69 GNULIB_MBSRTOWCS=0; AC_SUBST([GNULIB_MBSRTOWCS])
70 GNULIB_MBSNRTOWCS=0; AC_SUBST([GNULIB_MBSNRTOWCS])
71 GNULIB_WCRTOMB=0; AC_SUBST([GNULIB_WCRTOMB])
72 GNULIB_WCSRTOMBS=0; AC_SUBST([GNULIB_WCSRTOMBS])
73 GNULIB_WCSNRTOMBS=0; AC_SUBST([GNULIB_WCSNRTOMBS])
74 GNULIB_WCWIDTH=0; AC_SUBST([GNULIB_WCWIDTH])
49 dnl Assume proper GNU behavior unless another module says otherwise. 75 dnl Assume proper GNU behavior unless another module says otherwise.
76 HAVE_BTOWC=1; AC_SUBST([HAVE_BTOWC])
77 HAVE_MBSINIT=1; AC_SUBST([HAVE_MBSINIT])
78 HAVE_MBRTOWC=1; AC_SUBST([HAVE_MBRTOWC])
79 HAVE_MBRLEN=1; AC_SUBST([HAVE_MBRLEN])
80 HAVE_MBSRTOWCS=1; AC_SUBST([HAVE_MBSRTOWCS])
81 HAVE_MBSNRTOWCS=1; AC_SUBST([HAVE_MBSNRTOWCS])
82 HAVE_WCRTOMB=1; AC_SUBST([HAVE_WCRTOMB])
83 HAVE_WCSRTOMBS=1; AC_SUBST([HAVE_WCSRTOMBS])
84 HAVE_WCSNRTOMBS=1; AC_SUBST([HAVE_WCSNRTOMBS])
85 HAVE_DECL_WCTOB=1; AC_SUBST([HAVE_DECL_WCTOB])
50 HAVE_DECL_WCWIDTH=1; AC_SUBST([HAVE_DECL_WCWIDTH]) 86 HAVE_DECL_WCWIDTH=1; AC_SUBST([HAVE_DECL_WCWIDTH])
87 REPLACE_MBSTATE_T=0; AC_SUBST([REPLACE_MBSTATE_T])
88 REPLACE_BTOWC=0; AC_SUBST([REPLACE_BTOWC])
89 REPLACE_WCTOB=0; AC_SUBST([REPLACE_WCTOB])
90 REPLACE_MBSINIT=0; AC_SUBST([REPLACE_MBSINIT])
91 REPLACE_MBRTOWC=0; AC_SUBST([REPLACE_MBRTOWC])
92 REPLACE_MBRLEN=0; AC_SUBST([REPLACE_MBRLEN])
93 REPLACE_MBSRTOWCS=0; AC_SUBST([REPLACE_MBSRTOWCS])
94 REPLACE_MBSNRTOWCS=0;AC_SUBST([REPLACE_MBSNRTOWCS])
95 REPLACE_WCRTOMB=0; AC_SUBST([REPLACE_WCRTOMB])
96 REPLACE_WCSRTOMBS=0; AC_SUBST([REPLACE_WCSRTOMBS])
51 REPLACE_WCWIDTH=0; AC_SUBST([REPLACE_WCWIDTH]) 97 REPLACE_WCWIDTH=0; AC_SUBST([REPLACE_WCWIDTH])
52 WCHAR_H= 98 WCHAR_H=''; AC_SUBST([WCHAR_H])
53 AC_SUBST([WCHAR_H])
54]) 99])
diff --git a/gl/m4/wchar_t.m4 b/gl/m4/wchar_t.m4
index cde2129..fb27a7f 100644
--- a/gl/m4/wchar_t.m4
+++ b/gl/m4/wchar_t.m4
@@ -1,5 +1,5 @@
1# wchar_t.m4 serial 1 (gettext-0.12) 1# wchar_t.m4 serial 3 (gettext-0.18)
2dnl Copyright (C) 2002-2003 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2003, 2008, 2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -10,11 +10,11 @@ dnl Prerequisite: AC_PROG_CC
10 10
11AC_DEFUN([gt_TYPE_WCHAR_T], 11AC_DEFUN([gt_TYPE_WCHAR_T],
12[ 12[
13 AC_CACHE_CHECK([for wchar_t], gt_cv_c_wchar_t, 13 AC_CACHE_CHECK([for wchar_t], [gt_cv_c_wchar_t],
14 [AC_TRY_COMPILE([#include <stddef.h> 14 [AC_TRY_COMPILE([#include <stddef.h>
15 wchar_t foo = (wchar_t)'\0';], , 15 wchar_t foo = (wchar_t)'\0';], ,
16 gt_cv_c_wchar_t=yes, gt_cv_c_wchar_t=no)]) 16 [gt_cv_c_wchar_t=yes], [gt_cv_c_wchar_t=no])])
17 if test $gt_cv_c_wchar_t = yes; then 17 if test $gt_cv_c_wchar_t = yes; then
18 AC_DEFINE(HAVE_WCHAR_T, 1, [Define if you have the 'wchar_t' type.]) 18 AC_DEFINE([HAVE_WCHAR_T], [1], [Define if you have the 'wchar_t' type.])
19 fi 19 fi
20]) 20])
diff --git a/gl/m4/wcrtomb.m4 b/gl/m4/wcrtomb.m4
new file mode 100644
index 0000000..22d9433
--- /dev/null
+++ b/gl/m4/wcrtomb.m4
@@ -0,0 +1,88 @@
1# wcrtomb.m4 serial 2
2dnl Copyright (C) 2008 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_WCRTOMB],
8[
9 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
10
11 AC_REQUIRE([AC_TYPE_MBSTATE_T])
12 AC_CHECK_FUNCS_ONCE([wcrtomb])
13 if test $ac_cv_func_wcrtomb = no; then
14 HAVE_WCRTOMB=0
15 else
16
17 dnl On OSF/1 5.1 and Solaris 10, wcrtomb (NULL, 0, NULL) sometimes
18 dnl returns 0 instead of 1.
19 AC_REQUIRE([AC_PROG_CC])
20 AC_REQUIRE([gt_LOCALE_FR])
21 AC_REQUIRE([gt_LOCALE_FR_UTF8])
22 AC_REQUIRE([gt_LOCALE_JA])
23 AC_REQUIRE([gt_LOCALE_ZH_CN])
24 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
25 AC_CACHE_CHECK([whether wcrtomb return value is correct],
26 [gl_cv_func_wcrtomb_retval],
27 [
28 dnl Initial guess, used when cross-compiling or when no suitable locale
29 dnl is present.
30changequote(,)dnl
31 case "$host_os" in
32 # Guess no on OSF/1 and Solaris.
33 osf* | solaris*) gl_cv_func_wcrtomb_retval="guessing no" ;;
34 # Guess yes otherwise.
35 *) gl_cv_func_wcrtomb_retval="guessing yes" ;;
36 esac
37changequote([,])dnl
38 if test $LOCALE_FR != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none || test $LOCALE_ZH_CN != none; then
39 AC_TRY_RUN([
40#include <locale.h>
41#include <stdio.h>
42#include <string.h>
43#include <wchar.h>
44int main ()
45{
46 if (setlocale (LC_ALL, "$LOCALE_FR") != NULL)
47 {
48 if (wcrtomb (NULL, 0, NULL) != 1)
49 return 1;
50 }
51 if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
52 {
53 if (wcrtomb (NULL, 0, NULL) != 1)
54 return 1;
55 }
56 if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
57 {
58 if (wcrtomb (NULL, 0, NULL) != 1)
59 return 1;
60 }
61 if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
62 {
63 if (wcrtomb (NULL, 0, NULL) != 1)
64 return 1;
65 }
66 return 0;
67}],
68 [gl_cv_func_wcrtomb_retval=yes],
69 [gl_cv_func_wcrtomb_retval=no],
70 [])
71 fi
72 ])
73 case "$gl_cv_func_wcrtomb_retval" in
74 *yes) ;;
75 *) REPLACE_WCRTOMB=1 ;;
76 esac
77 fi
78 if test $HAVE_WCRTOMB = 0 || test $REPLACE_WCRTOMB = 1; then
79 gl_REPLACE_WCHAR_H
80 AC_LIBOBJ([wcrtomb])
81 gl_PREREQ_WCRTOMB
82 fi
83])
84
85# Prerequisites of lib/wcrtomb.c.
86AC_DEFUN([gl_PREREQ_WCRTOMB], [
87 :
88])
diff --git a/gl/m4/wctype.m4 b/gl/m4/wctype.m4
index 7483c4f..6a1b6f0 100644
--- a/gl/m4/wctype.m4
+++ b/gl/m4/wctype.m4
@@ -1,6 +1,8 @@
1# wctype.m4 serial 2
2
1dnl A placeholder for ISO C99 <wctype.h>, for platforms that lack it. 3dnl A placeholder for ISO C99 <wctype.h>, for platforms that lack it.
2 4
3dnl Copyright (C) 2006, 2007 Free Software Foundation, Inc. 5dnl Copyright (C) 2006-2008 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 6dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 7dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 8dnl with or without modifications, as long as this notice is preserved.
@@ -9,6 +11,7 @@ dnl Written by Paul Eggert.
9 11
10AC_DEFUN([gl_WCTYPE_H], 12AC_DEFUN([gl_WCTYPE_H],
11[ 13[
14 AC_REQUIRE([AC_PROG_CC])
12 AC_CHECK_FUNCS_ONCE([iswcntrl]) 15 AC_CHECK_FUNCS_ONCE([iswcntrl])
13 if test $ac_cv_func_iswcntrl = yes; then 16 if test $ac_cv_func_iswcntrl = yes; then
14 HAVE_ISWCNTRL=1 17 HAVE_ISWCNTRL=1
@@ -30,7 +33,27 @@ AC_DEFUN([gl_WCTYPE_H],
30 WCTYPE_H=wctype.h 33 WCTYPE_H=wctype.h
31 if test $ac_cv_header_wctype_h = yes; then 34 if test $ac_cv_header_wctype_h = yes; then
32 if test $ac_cv_func_iswcntrl = yes; then 35 if test $ac_cv_func_iswcntrl = yes; then
33 WCTYPE_H= 36 dnl Linux libc5 has an iswprint function that returns 0 for all arguments.
37 dnl The other functions are likely broken in the same way.
38 AC_CACHE_CHECK([whether iswcntrl works], [gl_cv_func_iswcntrl_works],
39 [
40 AC_TRY_RUN([#include <stddef.h>
41 #include <stdio.h>
42 #include <time.h>
43 #include <wchar.h>
44 #include <wctype.h>
45 int main () { return iswprint ('x') == 0; }],
46 [gl_cv_func_iswcntrl_works=yes], [gl_cv_func_iswcntrl_works=no],
47 [AC_TRY_COMPILE([#include <stdlib.h>
48 #if __GNU_LIBRARY__ == 1
49 Linux libc5 i18n is broken.
50 #endif], [],
51 [gl_cv_func_iswcntrl_works=yes], [gl_cv_func_iswcntrl_works=no])
52 ])
53 ])
54 if test $gl_cv_func_iswcntrl_works = yes; then
55 WCTYPE_H=
56 fi
34 fi 57 fi
35 dnl Compute NEXT_WCTYPE_H even if WCTYPE_H is empty, 58 dnl Compute NEXT_WCTYPE_H even if WCTYPE_H is empty,
36 dnl for the benefit of builds from non-distclean directories. 59 dnl for the benefit of builds from non-distclean directories.
@@ -41,4 +64,11 @@ AC_DEFUN([gl_WCTYPE_H],
41 fi 64 fi
42 AC_SUBST([HAVE_WCTYPE_H]) 65 AC_SUBST([HAVE_WCTYPE_H])
43 AC_SUBST([WCTYPE_H]) 66 AC_SUBST([WCTYPE_H])
67
68 if test "$gl_cv_func_iswcntrl_works" = no; then
69 REPLACE_ISWCNTRL=1
70 else
71 REPLACE_ISWCNTRL=0
72 fi
73 AC_SUBST([REPLACE_ISWCNTRL])
44]) 74])
diff --git a/gl/m4/wint_t.m4 b/gl/m4/wint_t.m4
index af5ed93..47a4363 100644
--- a/gl/m4/wint_t.m4
+++ b/gl/m4/wint_t.m4
@@ -1,5 +1,5 @@
1# wint_t.m4 serial 2 (gettext-0.17) 1# wint_t.m4 serial 4 (gettext-0.18)
2dnl Copyright (C) 2003, 2007 Free Software Foundation, Inc. 2dnl Copyright (C) 2003, 2007-2009 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -10,7 +10,7 @@ dnl Prerequisite: AC_PROG_CC
10 10
11AC_DEFUN([gt_TYPE_WINT_T], 11AC_DEFUN([gt_TYPE_WINT_T],
12[ 12[
13 AC_CACHE_CHECK([for wint_t], gt_cv_c_wint_t, 13 AC_CACHE_CHECK([for wint_t], [gt_cv_c_wint_t],
14 [AC_TRY_COMPILE([ 14 [AC_TRY_COMPILE([
15/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before 15/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
16 <wchar.h>. 16 <wchar.h>.
@@ -21,8 +21,8 @@ AC_DEFUN([gt_TYPE_WINT_T],
21#include <time.h> 21#include <time.h>
22#include <wchar.h> 22#include <wchar.h>
23 wint_t foo = (wchar_t)'\0';], , 23 wint_t foo = (wchar_t)'\0';], ,
24 gt_cv_c_wint_t=yes, gt_cv_c_wint_t=no)]) 24 [gt_cv_c_wint_t=yes], [gt_cv_c_wint_t=no])])
25 if test $gt_cv_c_wint_t = yes; then 25 if test $gt_cv_c_wint_t = yes; then
26 AC_DEFINE(HAVE_WINT_T, 1, [Define if you have the 'wint_t' type.]) 26 AC_DEFINE([HAVE_WINT_T], [1], [Define if you have the 'wint_t' type.])
27 fi 27 fi
28]) 28])
diff --git a/gl/m4/write.m4 b/gl/m4/write.m4
new file mode 100644
index 0000000..812b19b
--- /dev/null
+++ b/gl/m4/write.m4
@@ -0,0 +1,20 @@
1# write.m4 serial 1
2dnl Copyright (C) 2008 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_WRITE],
8[
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10 dnl This ifdef is just an optimization, to avoid performing a configure
11 dnl check whose result is not used. It does not make the test of
12 dnl GNULIB_UNISTD_H_SIGPIPE or GNULIB_SIGPIPE redundant.
13 m4_ifdef([gl_SIGNAL_SIGPIPE], [
14 gl_SIGNAL_SIGPIPE
15 if test $gl_cv_header_signal_h_SIGPIPE != yes; then
16 REPLACE_WRITE=1
17 AC_LIBOBJ([write])
18 fi
19 ])
20])
diff --git a/gl/m4/xsize.m4 b/gl/m4/xsize.m4
index 85bb721..631893c 100644
--- a/gl/m4/xsize.m4
+++ b/gl/m4/xsize.m4
@@ -1,5 +1,5 @@
1# xsize.m4 serial 3 1# xsize.m4 serial 4
2dnl Copyright (C) 2003-2004 Free Software Foundation, Inc. 2dnl Copyright (C) 2003-2004, 2008 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -9,5 +9,5 @@ AC_DEFUN([gl_XSIZE],
9 dnl Prerequisites of lib/xsize.h. 9 dnl Prerequisites of lib/xsize.h.
10 AC_REQUIRE([gl_SIZE_MAX]) 10 AC_REQUIRE([gl_SIZE_MAX])
11 AC_REQUIRE([AC_C_INLINE]) 11 AC_REQUIRE([AC_C_INLINE])
12 AC_CHECK_HEADERS(stdint.h) 12 AC_CHECK_HEADERS([stdint.h])
13]) 13])
diff --git a/gl/math.in.h b/gl/math.in.h
index c3515d7..6e1b9a2 100644
--- a/gl/math.in.h
+++ b/gl/math.in.h
@@ -1,6 +1,6 @@
1/* A GNU-like <math.h>. 1/* A GNU-like <math.h>.
2 2
3 Copyright (C) 2002-2003, 2007 Free Software Foundation, Inc. 3 Copyright (C) 2002-2003, 2007-2008 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
@@ -17,8 +17,12 @@
17 17
18#ifndef _GL_MATH_H 18#ifndef _GL_MATH_H
19 19
20#if __GNUC__ >= 3
21@PRAGMA_SYSTEM_HEADER@
22#endif
23
20/* The include_next requires a split double-inclusion guard. */ 24/* The include_next requires a split double-inclusion guard. */
21#@INCLUDE_NEXT@ @NEXT_MATH_H@ 25#@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_MATH_H@
22 26
23#ifndef _GL_MATH_H 27#ifndef _GL_MATH_H
24#define _GL_MATH_H 28#define _GL_MATH_H
@@ -32,6 +36,34 @@ extern "C" {
32#endif 36#endif
33 37
34 38
39/* POSIX allows platforms that don't support NAN. But all major
40 machines in the past 15 years have supported something close to
41 IEEE NaN, so we define this unconditionally. We also must define
42 it on platforms like Solaris 10, where NAN is present but defined
43 as a function pointer rather than a floating point constant. */
44#if !defined NAN || @REPLACE_NAN@
45# undef NAN
46 /* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */
47# ifdef __DECC
48static float
49_NaN ()
50{
51 static float zero = 0.0f;
52 return zero / zero;
53}
54# define NAN (_NaN())
55# else
56# define NAN (0.0f / 0.0f)
57# endif
58#endif
59
60/* Solaris 10 defines HUGE_VAL, but as a function pointer rather
61 than a floating point constant. */
62#if @REPLACE_HUGE_VAL@
63# undef HUGE_VAL
64# define HUGE_VAL (1.0 / 0.0)
65#endif
66
35/* Write x as 67/* Write x as
36 x = mantissa * 2^exp 68 x = mantissa * 2^exp
37 where 69 where
@@ -323,7 +355,8 @@ extern double trunc (double x);
323#endif 355#endif
324 356
325#if @GNULIB_TRUNCL@ 357#if @GNULIB_TRUNCL@
326# if !@HAVE_DECL_TRUNCL@ 358# if @REPLACE_TRUNCL@
359# undef truncl
327# define truncl rpl_truncl 360# define truncl rpl_truncl
328extern long double truncl (long double x); 361extern long double truncl (long double x);
329# endif 362# endif
@@ -352,6 +385,124 @@ extern int gl_isfinitel (long double x);
352#endif 385#endif
353 386
354 387
388#if @GNULIB_ISINF@
389# if @REPLACE_ISINF@
390extern int gl_isinff (float x);
391extern int gl_isinfd (double x);
392extern int gl_isinfl (long double x);
393# undef isinf
394# define isinf(x) \
395 (sizeof (x) == sizeof (long double) ? gl_isinfl (x) : \
396 sizeof (x) == sizeof (double) ? gl_isinfd (x) : \
397 gl_isinff (x))
398# endif
399#elif defined GNULIB_POSIXCHECK
400 /* How to override a macro? */
401#endif
402
403
404#if @GNULIB_ISNANF@
405/* Test for NaN for 'float' numbers. */
406# if @HAVE_ISNANF@
407/* The original <math.h> included above provides a declaration of isnan macro
408 or (older) isnanf function. */
409# include <math.h>
410# if __GNUC__ >= 4
411 /* GCC 4.0 and newer provides three built-ins for isnan. */
412# undef isnanf
413# define isnanf(x) __builtin_isnanf ((float)(x))
414# elif defined isnan
415# undef isnanf
416# define isnanf(x) isnan ((float)(x))
417# endif
418# else
419/* Test whether X is a NaN. */
420# undef isnanf
421# define isnanf rpl_isnanf
422extern int isnanf (float x);
423# endif
424#endif
425
426#if @GNULIB_ISNAND@
427/* Test for NaN for 'double' numbers.
428 This function is a gnulib extension, unlike isnan() which applied only
429 to 'double' numbers earlier but now is a type-generic macro. */
430# if @HAVE_ISNAND@
431/* The original <math.h> included above provides a declaration of isnan macro. */
432# include <math.h>
433# if __GNUC__ >= 4
434 /* GCC 4.0 and newer provides three built-ins for isnan. */
435# undef isnand
436# define isnand(x) __builtin_isnan ((double)(x))
437# else
438# undef isnand
439# define isnand(x) isnan ((double)(x))
440# endif
441# else
442/* Test whether X is a NaN. */
443# undef isnand
444# define isnand rpl_isnand
445extern int isnand (double x);
446# endif
447#endif
448
449#if @GNULIB_ISNANL@
450/* Test for NaN for 'long double' numbers. */
451# if @HAVE_ISNANL@
452/* The original <math.h> included above provides a declaration of isnan macro or (older) isnanl function. */
453# include <math.h>
454# if __GNUC__ >= 4
455 /* GCC 4.0 and newer provides three built-ins for isnan. */
456# undef isnanl
457# define isnanl(x) __builtin_isnanl ((long double)(x))
458# elif defined isnan
459# undef isnanl
460# define isnanl(x) isnan ((long double)(x))
461# endif
462# else
463/* Test whether X is a NaN. */
464# undef isnanl
465# define isnanl rpl_isnanl
466extern int isnanl (long double x);
467# endif
468#endif
469
470/* This must come *after* the snippets for GNULIB_ISNANF and GNULIB_ISNANL! */
471#if @GNULIB_ISNAN@
472# if @REPLACE_ISNAN@
473/* We can't just use the isnanf macro (e.g.) as exposed by
474 isnanf.h (e.g.) here, because those may end up being macros
475 that recursively expand back to isnan. So use the gnulib
476 replacements for them directly. */
477# if @HAVE_ISNANF@ && __GNUC__ >= 4
478# define gl_isnan_f(x) __builtin_isnan ((float)(x))
479# else
480extern int rpl_isnanf (float x);
481# define gl_isnan_f(x) rpl_isnanf (x)
482# endif
483# if @HAVE_ISNAND@ && __GNUC__ >= 4
484# define gl_isnan_d(x) __builtin_isnan ((double)(x))
485# else
486extern int rpl_isnand (double x);
487# define gl_isnan_d(x) rpl_isnand (x)
488# endif
489# if @HAVE_ISNANL@ && __GNUC__ >= 4
490# define gl_isnan_l(x) __builtin_isnan ((long double)(x))
491# else
492extern int rpl_isnanl (long double x);
493# define gl_isnan_l(x) rpl_isnanl (x)
494# endif
495# undef isnan
496# define isnan(x) \
497 (sizeof (x) == sizeof (long double) ? gl_isnan_l (x) : \
498 sizeof (x) == sizeof (double) ? gl_isnan_d (x) : \
499 gl_isnan_f (x))
500# endif
501#elif defined GNULIB_POSIXCHECK
502 /* How to override a macro? */
503#endif
504
505
355#if @GNULIB_SIGNBIT@ 506#if @GNULIB_SIGNBIT@
356# if @REPLACE_SIGNBIT_USING_GCC@ 507# if @REPLACE_SIGNBIT_USING_GCC@
357# undef signbit 508# undef signbit
diff --git a/gl/mbrtowc.c b/gl/mbrtowc.c
new file mode 100644
index 0000000..603f006
--- /dev/null
+++ b/gl/mbrtowc.c
@@ -0,0 +1,349 @@
1/* Convert multibyte character to wide character.
2 Copyright (C) 1999-2002, 2005-2008 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2008.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#include <wchar.h>
22
23#if GNULIB_defined_mbstate_t
24/* Implement mbrtowc() on top of mbtowc(). */
25
26# include <errno.h>
27# include <stdlib.h>
28
29# include "localcharset.h"
30# include "streq.h"
31# include "verify.h"
32
33
34verify (sizeof (mbstate_t) >= 4);
35
36static char internal_state[4];
37
38size_t
39mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
40{
41 char *pstate = (char *)ps;
42
43 if (pstate == NULL)
44 pstate = internal_state;
45
46 if (s == NULL)
47 {
48 pwc = NULL;
49 s = "";
50 n = 1;
51 }
52
53 if (n == 0)
54 return (size_t)(-2);
55
56 /* Here n > 0. */
57 {
58 size_t nstate = pstate[0];
59 char buf[4];
60 const char *p;
61 size_t m;
62
63 switch (nstate)
64 {
65 case 0:
66 p = s;
67 m = n;
68 break;
69 case 3:
70 buf[2] = pstate[3];
71 /*FALLTHROUGH*/
72 case 2:
73 buf[1] = pstate[2];
74 /*FALLTHROUGH*/
75 case 1:
76 buf[0] = pstate[1];
77 p = buf;
78 m = nstate;
79 buf[m++] = s[0];
80 if (n >= 2 && m < 4)
81 {
82 buf[m++] = s[1];
83 if (n >= 3 && m < 4)
84 buf[m++] = s[2];
85 }
86 break;
87 default:
88 errno = EINVAL;
89 return (size_t)(-1);
90 }
91
92 /* Here 0 < m ≤ 4. */
93
94# if __GLIBC__
95 /* Work around bug <http://sourceware.org/bugzilla/show_bug.cgi?id=9674> */
96 mbtowc (NULL, NULL, 0);
97# endif
98 {
99 int res = mbtowc (pwc, p, m);
100
101 if (res >= 0)
102 {
103 if (pwc != NULL && ((*pwc == 0) != (res == 0)))
104 abort ();
105 if (nstate >= (res > 0 ? res : 1))
106 abort ();
107 res -= nstate;
108 pstate[0] = 0;
109 return res;
110 }
111
112 /* mbtowc does not distinguish between invalid and incomplete multibyte
113 sequences. But mbrtowc needs to make this distinction.
114 There are two possible approaches:
115 - Use iconv() and its return value.
116 - Use built-in knowledge about the possible encodings.
117 Given the low quality of implementation of iconv() on the systems that
118 lack mbrtowc(), we use the second approach.
119 The possible encodings are:
120 - 8-bit encodings,
121 - EUC-JP, EUC-KR, GB2312, EUC-TW, BIG5, SJIS,
122 - UTF-8.
123 Use specialized code for each. */
124 if (m >= 4 || m >= MB_CUR_MAX)
125 goto invalid;
126 /* Here MB_CUR_MAX > 1 and 0 < m < 4. */
127 {
128 const char *encoding = locale_charset ();
129
130 if (STREQ (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0))
131 {
132 /* Cf. unistr/u8-mblen.c. */
133 unsigned char c = (unsigned char) p[0];
134
135 if (c >= 0xc2)
136 {
137 if (c < 0xe0)
138 {
139 if (m == 1)
140 goto incomplete;
141 }
142 else if (c < 0xf0)
143 {
144 if (m == 1)
145 goto incomplete;
146 if (m == 2)
147 {
148 unsigned char c2 = (unsigned char) p[1];
149
150 if ((c2 ^ 0x80) < 0x40
151 && (c >= 0xe1 || c2 >= 0xa0)
152 && (c != 0xed || c2 < 0xa0))
153 goto incomplete;
154 }
155 }
156 else if (c <= 0xf4)
157 {
158 if (m == 1)
159 goto incomplete;
160 else /* m == 2 || m == 3 */
161 {
162 unsigned char c2 = (unsigned char) p[1];
163
164 if ((c2 ^ 0x80) < 0x40
165 && (c >= 0xf1 || c2 >= 0x90)
166 && (c < 0xf4 || (c == 0xf4 && c2 < 0x90)))
167 {
168 if (m == 2)
169 goto incomplete;
170 else /* m == 3 */
171 {
172 unsigned char c3 = (unsigned char) p[2];
173
174 if ((c3 ^ 0x80) < 0x40)
175 goto incomplete;
176 }
177 }
178 }
179 }
180 }
181 goto invalid;
182 }
183
184 /* As a reference for this code, you can use the GNU libiconv
185 implementation. Look for uses of the RET_TOOFEW macro. */
186
187 if (STREQ (encoding, "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0))
188 {
189 if (m == 1)
190 {
191 unsigned char c = (unsigned char) p[0];
192
193 if ((c >= 0xa1 && c < 0xff) || c == 0x8e || c == 0x8f)
194 goto incomplete;
195 }
196 if (m == 2)
197 {
198 unsigned char c = (unsigned char) p[0];
199
200 if (c == 0x8f)
201 {
202 unsigned char c2 = (unsigned char) p[1];
203
204 if (c2 >= 0xa1 && c2 < 0xff)
205 goto incomplete;
206 }
207 }
208 goto invalid;
209 }
210 if (STREQ (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
211 || STREQ (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0)
212 || STREQ (encoding, "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0))
213 {
214 if (m == 1)
215 {
216 unsigned char c = (unsigned char) p[0];
217
218 if (c >= 0xa1 && c < 0xff)
219 goto incomplete;
220 }
221 goto invalid;
222 }
223 if (STREQ (encoding, "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0))
224 {
225 if (m == 1)
226 {
227 unsigned char c = (unsigned char) p[0];
228
229 if ((c >= 0xa1 && c < 0xff) || c == 0x8e)
230 goto incomplete;
231 }
232 else /* m == 2 || m == 3 */
233 {
234 unsigned char c = (unsigned char) p[0];
235
236 if (c == 0x8e)
237 goto incomplete;
238 }
239 goto invalid;
240 }
241 if (STREQ (encoding, "SJIS", 'S', 'J', 'I', 'S', 0, 0, 0, 0, 0))
242 {
243 if (m == 1)
244 {
245 unsigned char c = (unsigned char) p[0];
246
247 if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xea)
248 || (c >= 0xf0 && c <= 0xf9))
249 goto incomplete;
250 }
251 goto invalid;
252 }
253
254 /* An unknown multibyte encoding. */
255 goto incomplete;
256 }
257
258 incomplete:
259 {
260 size_t k = nstate;
261 /* Here 0 < k < m < 4. */
262 pstate[++k] = s[0];
263 if (k < m)
264 pstate[++k] = s[1];
265 if (k != m)
266 abort ();
267 }
268 pstate[0] = m;
269 return (size_t)(-2);
270
271 invalid:
272 errno = EILSEQ;
273 /* The conversion state is undefined, says POSIX. */
274 return (size_t)(-1);
275 }
276 }
277}
278
279#else
280/* Override the system's mbrtowc() function. */
281
282# undef mbrtowc
283
284size_t
285rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
286{
287# if MBRTOWC_NULL_ARG_BUG || MBRTOWC_RETVAL_BUG
288 if (s == NULL)
289 {
290 pwc = NULL;
291 s = "";
292 n = 1;
293 }
294# endif
295
296# if MBRTOWC_RETVAL_BUG
297 {
298 static mbstate_t internal_state;
299
300 /* Override mbrtowc's internal state. We can not call mbsinit() on the
301 hidden internal state, but we can call it on our variable. */
302 if (ps == NULL)
303 ps = &internal_state;
304
305 if (!mbsinit (ps))
306 {
307 /* Parse the rest of the multibyte character byte for byte. */
308 size_t count = 0;
309 for (; n > 0; s++, n--)
310 {
311 wchar_t wc;
312 size_t ret = mbrtowc (&wc, s, 1, ps);
313
314 if (ret == (size_t)(-1))
315 return (size_t)(-1);
316 count++;
317 if (ret != (size_t)(-2))
318 {
319 /* The multibyte character has been completed. */
320 if (pwc != NULL)
321 *pwc = wc;
322 return (wc == 0 ? 0 : count);
323 }
324 }
325 return (size_t)(-2);
326 }
327 }
328# endif
329
330# if MBRTOWC_NUL_RETVAL_BUG
331 {
332 wchar_t wc;
333 size_t ret = mbrtowc (&wc, s, n, ps);
334
335 if (ret != (size_t)(-1) && ret != (size_t)(-2))
336 {
337 if (pwc != NULL)
338 *pwc = wc;
339 if (wc == 0)
340 ret = 0;
341 }
342 return ret;
343 }
344# else
345 return mbrtowc (pwc, s, n, ps);
346# endif
347}
348
349#endif
diff --git a/gl/mbsinit.c b/gl/mbsinit.c
new file mode 100644
index 0000000..81fed5a
--- /dev/null
+++ b/gl/mbsinit.c
@@ -0,0 +1,47 @@
1/* Test for initial conversion state.
2 Copyright (C) 2008 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2008.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#include <wchar.h>
22
23#include "verify.h"
24
25/* Platforms that lack mbsinit() also lack mbrlen(), mbrtowc(), mbsrtowcs()
26 and wcrtomb(), wcsrtombs().
27 We assume that
28 - sizeof (mbstate_t) >= 4,
29 - only stateless encodings are supported (such as UTF-8 and EUC-JP, but
30 not ISO-2022 variants),
31 - for each encoding, the number of bytes for a wide character is <= 4.
32 (This maximum is attained for UTF-8, GB18030, EUC-TW.)
33 We define the meaning of mbstate_t as follows:
34 - In mb -> wc direction, mbstate_t's first byte contains the number of
35 buffered bytes (in the range 0..3), followed by up to 3 buffered bytes.
36 - In wc -> mb direction, mbstate_t contains no information. In other
37 words, it is always in the initial state. */
38
39verify (sizeof (mbstate_t) >= 4);
40
41int
42mbsinit (const mbstate_t *ps)
43{
44 const char *pstate = (const char *)ps;
45
46 return pstate[0] == 0;
47}
diff --git a/gl/netdb.in.h b/gl/netdb.in.h
new file mode 100644
index 0000000..363206d
--- /dev/null
+++ b/gl/netdb.in.h
@@ -0,0 +1,182 @@
1/* Provide a netdb.h header file for systems lacking it (read: MinGW).
2 Copyright (C) 2008 Free Software Foundation, Inc.
3 Written by Simon Josefsson.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3, or (at your option)
8 any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software Foundation,
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18
19/* This file is supposed to be used on platforms that lack <netdb.h>.
20 It is intended to provide definitions and prototypes needed by an
21 application. */
22
23#ifndef _GL_NETDB_H
24
25#if @HAVE_NETDB_H@
26
27# if __GNUC__ >= 3
28@PRAGMA_SYSTEM_HEADER@
29# endif
30
31/* The include_next requires a split double-inclusion guard. */
32# @INCLUDE_NEXT@ @NEXT_NETDB_H@
33
34#endif
35
36#ifndef _GL_NETDB_H
37#define _GL_NETDB_H
38
39/* Get netdb.h definitions such as struct hostent for MinGW. */
40#include <sys/socket.h>
41
42/* Declarations for a platform that lacks <netdb.h>, or where it is
43 incomplete. */
44
45#if @GNULIB_GETADDRINFO@
46
47# if !@HAVE_STRUCT_ADDRINFO@
48
49/* Structure to contain information about address of a service provider. */
50struct addrinfo
51{
52 int ai_flags; /* Input flags. */
53 int ai_family; /* Protocol family for socket. */
54 int ai_socktype; /* Socket type. */
55 int ai_protocol; /* Protocol for socket. */
56 socklen_t ai_addrlen; /* Length of socket address. */
57 struct sockaddr *ai_addr; /* Socket address for socket. */
58 char *ai_canonname; /* Canonical name for service location. */
59 struct addrinfo *ai_next; /* Pointer to next in list. */
60};
61# endif
62
63/* Possible values for `ai_flags' field in `addrinfo' structure. */
64# ifndef AI_PASSIVE
65# define AI_PASSIVE 0x0001 /* Socket address is intended for `bind'. */
66# endif
67# ifndef AI_CANONNAME
68# define AI_CANONNAME 0x0002 /* Request for canonical name. */
69# endif
70# ifndef AI_NUMERICSERV
71# define AI_NUMERICSERV 0x0400 /* Don't use name resolution. */
72# endif
73
74# if 0
75/* The commented out definitions below are not yet implemented in the
76 GNULIB getaddrinfo() replacement, so are not yet needed and may, in fact,
77 cause conflicts on systems with a getaddrinfo() function which does not
78 define them.
79
80 If they are restored, be sure to protect the definitions with #ifndef. */
81# define AI_NUMERICHOST 0x0004 /* Don't use name resolution. */
82# define AI_V4MAPPED 0x0008 /* IPv4 mapped addresses are acceptable. */
83# define AI_ALL 0x0010 /* Return IPv4 mapped and IPv6 addresses. */
84# define AI_ADDRCONFIG 0x0020 /* Use configuration of this host to choose
85 returned address type.. */
86# endif /* 0 */
87
88/* Error values for `getaddrinfo' function. */
89# ifndef EAI_BADFLAGS
90# define EAI_BADFLAGS -1 /* Invalid value for `ai_flags' field. */
91# define EAI_NONAME -2 /* NAME or SERVICE is unknown. */
92# define EAI_AGAIN -3 /* Temporary failure in name resolution. */
93# define EAI_FAIL -4 /* Non-recoverable failure in name res. */
94# define EAI_NODATA -5 /* No address associated with NAME. */
95# define EAI_FAMILY -6 /* `ai_family' not supported. */
96# define EAI_SOCKTYPE -7 /* `ai_socktype' not supported. */
97# define EAI_SERVICE -8 /* SERVICE not supported for `ai_socktype'. */
98# define EAI_MEMORY -10 /* Memory allocation failure. */
99# endif
100
101/* Since EAI_NODATA is deprecated by RFC3493, some systems (at least
102 FreeBSD, which does define EAI_BADFLAGS) have removed the definition
103 in favor of EAI_NONAME. */
104# if !defined EAI_NODATA && defined EAI_NONAME
105# define EAI_NODATA EAI_NONAME
106# endif
107
108# ifndef EAI_OVERFLOW
109/* Not defined on mingw32 and Haiku. */
110# define EAI_OVERFLOW -12 /* Argument buffer overflow. */
111# endif
112# ifndef EAI_ADDRFAMILY
113/* Not defined on mingw32. */
114# define EAI_ADDRFAMILY -9 /* Address family for NAME not supported. */
115# endif
116# ifndef EAI_SYSTEM
117/* Not defined on mingw32. */
118# define EAI_SYSTEM -11 /* System error returned in `errno'. */
119# endif
120
121# if 0
122/* The commented out definitions below are not yet implemented in the
123 GNULIB getaddrinfo() replacement, so are not yet needed.
124
125 If they are restored, be sure to protect the definitions with #ifndef. */
126# ifndef EAI_INPROGRESS
127# define EAI_INPROGRESS -100 /* Processing request in progress. */
128# define EAI_CANCELED -101 /* Request canceled. */
129# define EAI_NOTCANCELED -102 /* Request not canceled. */
130# define EAI_ALLDONE -103 /* All requests done. */
131# define EAI_INTR -104 /* Interrupted by a signal. */
132# define EAI_IDN_ENCODE -105 /* IDN encoding failed. */
133# endif
134# endif
135
136# if !@HAVE_DECL_GETADDRINFO@
137/* Translate name of a service location and/or a service name to set of
138 socket addresses.
139 For more details, see the POSIX:2001 specification
140 <http://www.opengroup.org/susv3xsh/getaddrinfo.html>. */
141extern int getaddrinfo (const char *restrict nodename,
142 const char *restrict servname,
143 const struct addrinfo *restrict hints,
144 struct addrinfo **restrict res);
145# endif
146
147# if !@HAVE_DECL_FREEADDRINFO@
148/* Free `addrinfo' structure AI including associated storage.
149 For more details, see the POSIX:2001 specification
150 <http://www.opengroup.org/susv3xsh/getaddrinfo.html>. */
151extern void freeaddrinfo (struct addrinfo *ai);
152# endif
153
154# if !@HAVE_DECL_GAI_STRERROR@
155/* Convert error return from getaddrinfo() to a string.
156 For more details, see the POSIX:2001 specification
157 <http://www.opengroup.org/susv3xsh/gai_strerror.html>. */
158extern const char *gai_strerror (int ecode);
159# endif
160
161# if !@HAVE_DECL_GETNAMEINFO@
162/* Convert socket address to printable node and service names.
163 For more details, see the POSIX:2001 specification
164 <http://www.opengroup.org/susv3xsh/getnameinfo.html>. */
165extern int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen,
166 char *restrict node, socklen_t nodelen,
167 char *restrict service, socklen_t servicelen,
168 int flags);
169# endif
170
171/* Possible flags for getnameinfo. */
172# ifndef NI_NUMERICHOST
173# define NI_NUMERICHOST 1
174# endif
175# ifndef NI_NUMERICSERV
176# define NI_NUMERICSERV 2
177# endif
178
179#endif /* @GNULIB_GETADDRINFO@ */
180
181#endif /* _GL_NETDB_H */
182#endif /* _GL_NETDB_H */
diff --git a/gl/netinet_in.in.h b/gl/netinet_in.in.h
index c45e53b..97e11a7 100644
--- a/gl/netinet_in.in.h
+++ b/gl/netinet_in.in.h
@@ -1,5 +1,5 @@
1/* Substitute for <netinet/in.h>. 1/* Substitute for <netinet/in.h>.
2 Copyright (C) 2007 Free Software Foundation, Inc. 2 Copyright (C) 2007-2008 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
@@ -19,6 +19,10 @@
19 19
20#if @HAVE_NETINET_IN_H@ 20#if @HAVE_NETINET_IN_H@
21 21
22# if __GNUC__ >= 3
23@PRAGMA_SYSTEM_HEADER@
24# endif
25
22/* On many platforms, <netinet/in.h> assumes prior inclusion of 26/* On many platforms, <netinet/in.h> assumes prior inclusion of
23 <sys/types.h>. */ 27 <sys/types.h>. */
24# include <sys/types.h> 28# include <sys/types.h>
diff --git a/gl/open-safer.c b/gl/open-safer.c
index ce493d5..15bf6a6 100644
--- a/gl/open-safer.c
+++ b/gl/open-safer.c
@@ -1,6 +1,6 @@
1/* Invoke open, but avoid some glitches. 1/* Invoke open, but avoid some glitches.
2 2
3 Copyright (C) 2005, 2006 Free Software Foundation, Inc. 3 Copyright (C) 2005, 2006, 2008 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
@@ -38,9 +38,10 @@ open_safer (char const *file, int flags, ...)
38 /* Assume mode_t promotes to int if and only if it is smaller. 38 /* Assume mode_t promotes to int if and only if it is smaller.
39 This assumption isn't guaranteed by the C standard, but we 39 This assumption isn't guaranteed by the C standard, but we
40 don't know of any real-world counterexamples. */ 40 don't know of any real-world counterexamples. */
41 mode = (sizeof (mode_t) < sizeof (int) 41 if (sizeof (mode_t) < sizeof (int))
42 ? va_arg (ap, int) 42 mode = va_arg (ap, int);
43 : va_arg (ap, mode_t)); 43 else
44 mode = va_arg (ap, mode_t);
44 45
45 va_end (ap); 46 va_end (ap);
46 } 47 }
diff --git a/gl/open.c b/gl/open.c
new file mode 100644
index 0000000..13af274
--- /dev/null
+++ b/gl/open.c
@@ -0,0 +1,140 @@
1/* Open a descriptor to a file.
2 Copyright (C) 2007-2008 Free Software Foundation, Inc.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
18
19#include <config.h>
20
21/* Get the original definition of open. It might be defined as a macro. */
22#define __need_system_fcntl_h
23#include <fcntl.h>
24#undef __need_system_fcntl_h
25#include <sys/types.h>
26
27static inline int
28orig_open (const char *filename, int flags, mode_t mode)
29{
30 return open (filename, flags, mode);
31}
32
33/* Specification. */
34#include <fcntl.h>
35
36#include <errno.h>
37#include <stdarg.h>
38#include <string.h>
39#include <sys/types.h>
40#include <sys/stat.h>
41
42int
43open (const char *filename, int flags, ...)
44{
45 mode_t mode;
46 int fd;
47
48 mode = 0;
49 if (flags & O_CREAT)
50 {
51 va_list arg;
52 va_start (arg, flags);
53
54 /* If mode_t is narrower than int, use the promoted type (int),
55 not mode_t. Use sizeof to guess whether mode_t is narrower;
56 we don't know of any practical counterexamples. */
57 mode = (sizeof (mode_t) < sizeof (int)
58 ? va_arg (arg, int)
59 : va_arg (arg, mode_t));
60
61 va_end (arg);
62 }
63
64#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
65 if (strcmp (filename, "/dev/null") == 0)
66 filename = "NUL";
67#endif
68
69#if OPEN_TRAILING_SLASH_BUG
70 /* If the filename ends in a slash and one of O_CREAT, O_WRONLY, O_RDWR
71 is specified, then fail.
72 Rationale: POSIX <http://www.opengroup.org/susv3/basedefs/xbd_chap04.html>
73 says that
74 "A pathname that contains at least one non-slash character and that
75 ends with one or more trailing slashes shall be resolved as if a
76 single dot character ( '.' ) were appended to the pathname."
77 and
78 "The special filename dot shall refer to the directory specified by
79 its predecessor."
80 If the named file already exists as a directory, then
81 - if O_CREAT is specified, open() must fail because of the semantics
82 of O_CREAT,
83 - if O_WRONLY or O_RDWR is specified, open() must fail because POSIX
84 <http://www.opengroup.org/susv3/functions/open.html> says that it
85 fails with errno = EISDIR in this case.
86 If the named file does not exist or does not name a directory, then
87 - if O_CREAT is specified, open() must fail since open() cannot create
88 directories,
89 - if O_WRONLY or O_RDWR is specified, open() must fail because the
90 file does not contain a '.' directory. */
91 if (flags & (O_CREAT | O_WRONLY | O_RDWR))
92 {
93 size_t len = strlen (filename);
94 if (len > 0 && filename[len - 1] == '/')
95 {
96 errno = EISDIR;
97 return -1;
98 }
99 }
100#endif
101
102 fd = orig_open (filename, flags, mode);
103
104#if OPEN_TRAILING_SLASH_BUG
105 /* If the filename ends in a slash and fd does not refer to a directory,
106 then fail.
107 Rationale: POSIX <http://www.opengroup.org/susv3/basedefs/xbd_chap04.html>
108 says that
109 "A pathname that contains at least one non-slash character and that
110 ends with one or more trailing slashes shall be resolved as if a
111 single dot character ( '.' ) were appended to the pathname."
112 and
113 "The special filename dot shall refer to the directory specified by
114 its predecessor."
115 If the named file without the slash is not a directory, open() must fail
116 with ENOTDIR. */
117 if (fd >= 0)
118 {
119 size_t len = strlen (filename);
120 if (len > 0 && filename[len - 1] == '/')
121 {
122 struct stat statbuf;
123
124 if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode))
125 {
126 close (fd);
127 errno = ENOTDIR;
128 return -1;
129 }
130 }
131 }
132#endif
133
134#ifdef FCHDIR_REPLACEMENT
135 if (fd >= 0)
136 _gl_register_fd (fd, filename);
137#endif
138
139 return fd;
140}
diff --git a/gl/regcomp.c b/gl/regcomp.c
index 8827e03..b114b4d 100644
--- a/gl/regcomp.c
+++ b/gl/regcomp.c
@@ -1,5 +1,6 @@
1/* Extended regular expression matching and search library. 1/* Extended regular expression matching and search library.
2 Copyright (C) 2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc. 2 Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009
3 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 4 This file is part of the GNU C Library.
4 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>. 5 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
5 6
@@ -333,8 +334,8 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
333 && dfa->nodes[node].mb_partial) 334 && dfa->nodes[node].mb_partial)
334 *p++ = dfa->nodes[node].opr.c; 335 *p++ = dfa->nodes[node].opr.c;
335 memset (&state, '\0', sizeof (state)); 336 memset (&state, '\0', sizeof (state));
336 if (mbrtowc (&wc, (const char *) buf, p - buf, 337 if (__mbrtowc (&wc, (const char *) buf, p - buf,
337 &state) == p - buf 338 &state) == p - buf
338 && (__wcrtomb ((char *) buf, towlower (wc), &state) 339 && (__wcrtomb ((char *) buf, towlower (wc), &state)
339 != (size_t) -1)) 340 != (size_t) -1))
340 re_set_fastmap (fastmap, false, buf[0]); 341 re_set_fastmap (fastmap, false, buf[0]);
@@ -356,45 +357,65 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
356#ifdef RE_ENABLE_I18N 357#ifdef RE_ENABLE_I18N
357 else if (type == COMPLEX_BRACKET) 358 else if (type == COMPLEX_BRACKET)
358 { 359 {
359 Idx i;
360 re_charset_t *cset = dfa->nodes[node].opr.mbcset; 360 re_charset_t *cset = dfa->nodes[node].opr.mbcset;
361 if (cset->non_match || cset->ncoll_syms || cset->nequiv_classes 361 Idx i;
362 || cset->nranges || cset->nchar_classes) 362
363 {
364# ifdef _LIBC 363# ifdef _LIBC
365 if (_NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES) != 0) 364 /* See if we have to try all bytes which start multiple collation
365 elements.
366 e.g. In da_DK, we want to catch 'a' since "aa" is a valid
367 collation element, and don't catch 'b' since 'b' is
368 the only collation element which starts from 'b' (and
369 it is caught by SIMPLE_BRACKET). */
370 if (_NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES) != 0
371 && (cset->ncoll_syms || cset->nranges))
366 { 372 {
367 /* In this case we want to catch the bytes which are
368 the first byte of any collation elements.
369 e.g. In da_DK, we want to catch 'a' since "aa"
370 is a valid collation element, and don't catch
371 'b' since 'b' is the only collation element
372 which starts from 'b'. */
373 const int32_t *table = (const int32_t *) 373 const int32_t *table = (const int32_t *)
374 _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB); 374 _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB);
375 for (i = 0; i < SBC_MAX; ++i) 375 for (i = 0; i < SBC_MAX; ++i)
376 if (table[i] < 0) 376 if (table[i] < 0)
377 re_set_fastmap (fastmap, icase, i); 377 re_set_fastmap (fastmap, icase, i);
378 } 378 }
379# else 379# endif /* _LIBC */
380 if (dfa->mb_cur_max > 1) 380
381 for (i = 0; i < SBC_MAX; ++i) 381 /* See if we have to start the match at all multibyte characters,
382 if (__btowc (i) == WEOF) 382 i.e. where we would not find an invalid sequence. This only
383 re_set_fastmap (fastmap, icase, i); 383 applies to multibyte character sets; for single byte character
384# endif /* not _LIBC */ 384 sets, the SIMPLE_BRACKET again suffices. */
385 if (dfa->mb_cur_max > 1
386 && (cset->nchar_classes || cset->non_match
387# ifdef _LIBC
388 || cset->nequiv_classes
389# endif /* _LIBC */
390 ))
391 {
392 unsigned char c = 0;
393 do
394 {
395 mbstate_t mbs;
396 memset (&mbs, 0, sizeof (mbs));
397 if (__mbrtowc (NULL, (char *) &c, 1, &mbs) == (size_t) -2)
398 re_set_fastmap (fastmap, false, (int) c);
399 }
400 while (++c != 0);
385 } 401 }
386 for (i = 0; i < cset->nmbchars; ++i) 402
403 else
387 { 404 {
388 char buf[256]; 405 /* ... Else catch all bytes which can start the mbchars. */
389 mbstate_t state; 406 for (i = 0; i < cset->nmbchars; ++i)
390 memset (&state, '\0', sizeof (state));
391 if (__wcrtomb (buf, cset->mbchars[i], &state) != (size_t) -1)
392 re_set_fastmap (fastmap, icase, *(unsigned char *) buf);
393 if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1)
394 { 407 {
395 if (__wcrtomb (buf, towlower (cset->mbchars[i]), &state) 408 char buf[256];
396 != (size_t) -1) 409 mbstate_t state;
397 re_set_fastmap (fastmap, false, *(unsigned char *) buf); 410 memset (&state, '\0', sizeof (state));
411 if (__wcrtomb (buf, cset->mbchars[i], &state) != (size_t) -1)
412 re_set_fastmap (fastmap, icase, *(unsigned char *) buf);
413 if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1)
414 {
415 if (__wcrtomb (buf, towlower (cset->mbchars[i]), &state)
416 != (size_t) -1)
417 re_set_fastmap (fastmap, false, *(unsigned char *) buf);
418 }
398 } 419 }
399 } 420 }
400 } 421 }
@@ -776,7 +797,7 @@ re_compile_internal (regex_t *preg, const char * pattern, size_t length,
776 __libc_lock_init (dfa->lock); 797 __libc_lock_init (dfa->lock);
777 798
778 err = re_string_construct (&regexp, pattern, length, preg->translate, 799 err = re_string_construct (&regexp, pattern, length, preg->translate,
779 syntax & RE_ICASE, dfa); 800 (syntax & RE_ICASE) != 0, dfa);
780 if (BE (err != REG_NOERROR, 0)) 801 if (BE (err != REG_NOERROR, 0))
781 { 802 {
782 re_compile_internal_free_return: 803 re_compile_internal_free_return:
@@ -1057,7 +1078,9 @@ optimize_utf8 (re_dfa_t *dfa)
1057 case BUF_LAST: 1078 case BUF_LAST:
1058 break; 1079 break;
1059 default: 1080 default:
1060 /* Word anchors etc. cannot be handled. */ 1081 /* Word anchors etc. cannot be handled. It's okay to test
1082 opr.ctx_type since constraints (for all DFA nodes) are
1083 created by ORing one or more opr.ctx_type values. */
1061 return; 1084 return;
1062 } 1085 }
1063 break; 1086 break;
@@ -1344,6 +1367,8 @@ calc_first (void *extra, bin_tree_t *node)
1344 node->node_idx = re_dfa_add_node (dfa, node->token); 1367 node->node_idx = re_dfa_add_node (dfa, node->token);
1345 if (BE (node->node_idx == REG_MISSING, 0)) 1368 if (BE (node->node_idx == REG_MISSING, 0))
1346 return REG_ESPACE; 1369 return REG_ESPACE;
1370 if (node->token.type == ANCHOR)
1371 dfa->nodes[node->node_idx].constraint = node->token.opr.ctx_type;
1347 } 1372 }
1348 return REG_NOERROR; 1373 return REG_NOERROR;
1349} 1374}
@@ -1473,21 +1498,18 @@ duplicate_node_closure (re_dfa_t *dfa, Idx top_org_node, Idx top_clone_node,
1473 destination. */ 1498 destination. */
1474 org_dest = dfa->edests[org_node].elems[0]; 1499 org_dest = dfa->edests[org_node].elems[0];
1475 re_node_set_empty (dfa->edests + clone_node); 1500 re_node_set_empty (dfa->edests + clone_node);
1476 if (dfa->nodes[org_node].type == ANCHOR) 1501 clone_dest = search_duplicated_node (dfa, org_dest, constraint);
1502 /* If the node is root_node itself, it means the epsilon closure
1503 has a loop. Then tie it to the destination of the root_node. */
1504 if (org_node == root_node && clone_node != org_node)
1477 { 1505 {
1478 /* In case of the node has another constraint, append it. */ 1506 ok = re_node_set_insert (dfa->edests + clone_node, org_dest);
1479 if (org_node == root_node && clone_node != org_node) 1507 if (BE (! ok, 0))
1480 { 1508 return REG_ESPACE;
1481 /* ...but if the node is root_node itself, it means the 1509 break;
1482 epsilon closure have a loop, then tie it to the
1483 destination of the root_node. */
1484 ok = re_node_set_insert (dfa->edests + clone_node, org_dest);
1485 if (BE (! ok, 0))
1486 return REG_ESPACE;
1487 break;
1488 }
1489 constraint |= dfa->nodes[org_node].opr.ctx_type;
1490 } 1510 }
1511 /* In case the node has another constraint, append it. */
1512 constraint |= dfa->nodes[org_node].constraint;
1491 clone_dest = duplicate_node (dfa, org_dest, constraint); 1513 clone_dest = duplicate_node (dfa, org_dest, constraint);
1492 if (BE (clone_dest == REG_MISSING, 0)) 1514 if (BE (clone_dest == REG_MISSING, 0))
1493 return REG_ESPACE; 1515 return REG_ESPACE;
@@ -1505,7 +1527,7 @@ duplicate_node_closure (re_dfa_t *dfa, Idx top_org_node, Idx top_clone_node,
1505 clone_dest = search_duplicated_node (dfa, org_dest, constraint); 1527 clone_dest = search_duplicated_node (dfa, org_dest, constraint);
1506 if (clone_dest == REG_MISSING) 1528 if (clone_dest == REG_MISSING)
1507 { 1529 {
1508 /* There are no such a duplicated node, create a new one. */ 1530 /* There is no such duplicated node, create a new one. */
1509 reg_errcode_t err; 1531 reg_errcode_t err;
1510 clone_dest = duplicate_node (dfa, org_dest, constraint); 1532 clone_dest = duplicate_node (dfa, org_dest, constraint);
1511 if (BE (clone_dest == REG_MISSING, 0)) 1533 if (BE (clone_dest == REG_MISSING, 0))
@@ -1520,7 +1542,7 @@ duplicate_node_closure (re_dfa_t *dfa, Idx top_org_node, Idx top_clone_node,
1520 } 1542 }
1521 else 1543 else
1522 { 1544 {
1523 /* There are a duplicated node which satisfy the constraint, 1545 /* There is a duplicated node which satisfy the constraint,
1524 use it to avoid infinite loop. */ 1546 use it to avoid infinite loop. */
1525 ok = re_node_set_insert (dfa->edests + clone_node, clone_dest); 1547 ok = re_node_set_insert (dfa->edests + clone_node, clone_dest);
1526 if (BE (! ok, 0)) 1548 if (BE (! ok, 0))
@@ -1569,8 +1591,7 @@ duplicate_node (re_dfa_t *dfa, Idx org_idx, unsigned int constraint)
1569 if (BE (dup_idx != REG_MISSING, 1)) 1591 if (BE (dup_idx != REG_MISSING, 1))
1570 { 1592 {
1571 dfa->nodes[dup_idx].constraint = constraint; 1593 dfa->nodes[dup_idx].constraint = constraint;
1572 if (dfa->nodes[org_idx].type == ANCHOR) 1594 dfa->nodes[dup_idx].constraint |= dfa->nodes[org_idx].constraint;
1573 dfa->nodes[dup_idx].constraint |= dfa->nodes[org_idx].opr.ctx_type;
1574 dfa->nodes[dup_idx].duplicated = 1; 1595 dfa->nodes[dup_idx].duplicated = 1;
1575 1596
1576 /* Store the index of the original node. */ 1597 /* Store the index of the original node. */
@@ -1652,7 +1673,6 @@ static reg_errcode_t
1652calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root) 1673calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root)
1653{ 1674{
1654 reg_errcode_t err; 1675 reg_errcode_t err;
1655 unsigned int constraint;
1656 Idx i; 1676 Idx i;
1657 bool incomplete; 1677 bool incomplete;
1658 bool ok; 1678 bool ok;
@@ -1666,15 +1686,14 @@ calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root)
1666 We reference this value to avoid infinite loop. */ 1686 We reference this value to avoid infinite loop. */
1667 dfa->eclosures[node].nelem = REG_MISSING; 1687 dfa->eclosures[node].nelem = REG_MISSING;
1668 1688
1669 constraint = ((dfa->nodes[node].type == ANCHOR) 1689 /* If the current node has constraints, duplicate all nodes
1670 ? dfa->nodes[node].opr.ctx_type : 0); 1690 since they must inherit the constraints. */
1671 /* If the current node has constraints, duplicate all nodes. 1691 if (dfa->nodes[node].constraint
1672 Since they must inherit the constraints. */
1673 if (constraint
1674 && dfa->edests[node].nelem 1692 && dfa->edests[node].nelem
1675 && !dfa->nodes[dfa->edests[node].elems[0]].duplicated) 1693 && !dfa->nodes[dfa->edests[node].elems[0]].duplicated)
1676 { 1694 {
1677 err = duplicate_node_closure (dfa, node, node, node, constraint); 1695 err = duplicate_node_closure (dfa, node, node, node,
1696 dfa->nodes[node].constraint);
1678 if (BE (err != REG_NOERROR, 0)) 1697 if (BE (err != REG_NOERROR, 0))
1679 return err; 1698 return err;
1680 } 1699 }
diff --git a/gl/regex_internal.c b/gl/regex_internal.c
index cf3bf1b..7acec79 100644
--- a/gl/regex_internal.c
+++ b/gl/regex_internal.c
@@ -1,6 +1,6 @@
1/* Extended regular expression matching and search library. 1/* Extended regular expression matching and search library.
2 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software 2 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
3 Foundation, Inc. 3 Free Software Foundation, Inc.
4 This file is part of the GNU C Library. 4 This file is part of the GNU C Library.
5 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>. 5 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
6 6
@@ -236,7 +236,7 @@ build_wcs_buffer (re_string_t *pstr)
236 } 236 }
237 else 237 else
238 p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + byte_idx; 238 p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + byte_idx;
239 mbclen = mbrtowc (&wc, p, remain_len, &pstr->cur_state); 239 mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state);
240 if (BE (mbclen == (size_t) -2, 0)) 240 if (BE (mbclen == (size_t) -2, 0))
241 { 241 {
242 /* The buffer doesn't have enough space, finish to build. */ 242 /* The buffer doesn't have enough space, finish to build. */
@@ -306,9 +306,9 @@ build_wcs_upper_buffer (re_string_t *pstr)
306 306
307 remain_len = end_idx - byte_idx; 307 remain_len = end_idx - byte_idx;
308 prev_st = pstr->cur_state; 308 prev_st = pstr->cur_state;
309 mbclen = mbrtowc (&wc, 309 mbclen = __mbrtowc (&wc,
310 ((const char *) pstr->raw_mbs + pstr->raw_mbs_idx 310 ((const char *) pstr->raw_mbs + pstr->raw_mbs_idx
311 + byte_idx), remain_len, &pstr->cur_state); 311 + byte_idx), remain_len, &pstr->cur_state);
312 if (BE (mbclen < (size_t) -2, 1)) 312 if (BE (mbclen < (size_t) -2, 1))
313 { 313 {
314 wchar_t wcu = wc; 314 wchar_t wcu = wc;
@@ -376,7 +376,7 @@ build_wcs_upper_buffer (re_string_t *pstr)
376 } 376 }
377 else 377 else
378 p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + src_idx; 378 p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + src_idx;
379 mbclen = mbrtowc (&wc, p, remain_len, &pstr->cur_state); 379 mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state);
380 if (BE (mbclen < (size_t) -2, 1)) 380 if (BE (mbclen < (size_t) -2, 1))
381 { 381 {
382 wchar_t wcu = wc; 382 wchar_t wcu = wc;
@@ -499,8 +499,8 @@ re_string_skip_chars (re_string_t *pstr, Idx new_raw_idx, wint_t *last_wc)
499 Idx remain_len; 499 Idx remain_len;
500 remain_len = pstr->len - rawbuf_idx; 500 remain_len = pstr->len - rawbuf_idx;
501 prev_st = pstr->cur_state; 501 prev_st = pstr->cur_state;
502 mbclen = mbrtowc (&wc2, (const char *) pstr->raw_mbs + rawbuf_idx, 502 mbclen = __mbrtowc (&wc2, (const char *) pstr->raw_mbs + rawbuf_idx,
503 remain_len, &pstr->cur_state); 503 remain_len, &pstr->cur_state);
504 if (BE (mbclen == (size_t) -2 || mbclen == (size_t) -1 || mbclen == 0, 0)) 504 if (BE (mbclen == (size_t) -2 || mbclen == (size_t) -1 || mbclen == 0, 0))
505 { 505 {
506 /* We treat these cases as a single byte character. */ 506 /* We treat these cases as a single byte character. */
@@ -687,10 +687,10 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
687 } 687 }
688 else 688 else
689 { 689 {
690#ifdef RE_ENABLE_I18N
690 /* No, skip all characters until IDX. */ 691 /* No, skip all characters until IDX. */
691 Idx prev_valid_len = pstr->valid_len; 692 Idx prev_valid_len = pstr->valid_len;
692 693
693#ifdef RE_ENABLE_I18N
694 if (BE (pstr->offsets_needed, 0)) 694 if (BE (pstr->offsets_needed, 0))
695 { 695 {
696 pstr->len = pstr->raw_len - idx + offset; 696 pstr->len = pstr->raw_len - idx + offset;
@@ -745,8 +745,8 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
745 /* XXX Don't use mbrtowc, we know which conversion 745 /* XXX Don't use mbrtowc, we know which conversion
746 to use (UTF-8 -> UCS4). */ 746 to use (UTF-8 -> UCS4). */
747 memset (&cur_state, 0, sizeof (cur_state)); 747 memset (&cur_state, 0, sizeof (cur_state));
748 mbclen = mbrtowc (&wc2, (const char *) p, mlen, 748 mbclen = __mbrtowc (&wc2, (const char *) p, mlen,
749 &cur_state); 749 &cur_state);
750 if (raw + offset - p <= mbclen 750 if (raw + offset - p <= mbclen
751 && mbclen < (size_t) -2) 751 && mbclen < (size_t) -2)
752 { 752 {
@@ -1689,11 +1689,9 @@ create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
1689 1689
1690 for (i = 0 ; i < nodes->nelem ; i++) 1690 for (i = 0 ; i < nodes->nelem ; i++)
1691 { 1691 {
1692 unsigned int constraint = 0;
1693 re_token_t *node = dfa->nodes + nodes->elems[i]; 1692 re_token_t *node = dfa->nodes + nodes->elems[i];
1694 re_token_type_t type = node->type; 1693 re_token_type_t type = node->type;
1695 if (node->constraint) 1694 unsigned int constraint = node->constraint;
1696 constraint = node->constraint;
1697 1695
1698 if (type == CHARACTER && !constraint) 1696 if (type == CHARACTER && !constraint)
1699 continue; 1697 continue;
@@ -1706,8 +1704,6 @@ create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes,
1706 newstate->halt = 1; 1704 newstate->halt = 1;
1707 else if (type == OP_BACK_REF) 1705 else if (type == OP_BACK_REF)
1708 newstate->has_backref = 1; 1706 newstate->has_backref = 1;
1709 else if (type == ANCHOR)
1710 constraint = node->opr.ctx_type;
1711 1707
1712 if (constraint) 1708 if (constraint)
1713 { 1709 {
diff --git a/gl/regex_internal.h b/gl/regex_internal.h
index f96291d..ac34811 100644
--- a/gl/regex_internal.h
+++ b/gl/regex_internal.h
@@ -1,5 +1,6 @@
1/* Extended regular expression matching and search library. 1/* Extended regular expression matching and search library.
2 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. 2 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
3 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 4 This file is part of the GNU C Library.
4 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>. 5 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
5 6
@@ -84,7 +85,7 @@
84# define SIZE_MAX ((size_t) -1) 85# define SIZE_MAX ((size_t) -1)
85#endif 86#endif
86 87
87#if (defined MB_CUR_MAX && HAVE_LOCALE_H && HAVE_WCTYPE_H && HAVE_ISWCTYPE && HAVE_WCRTOMB && HAVE_MBRTOWC && HAVE_WCSCOLL) || _LIBC 88#if (defined MB_CUR_MAX && HAVE_LOCALE_H && HAVE_WCTYPE_H && HAVE_ISWCTYPE && HAVE_WCSCOLL) || _LIBC
88# define RE_ENABLE_I18N 89# define RE_ENABLE_I18N
89#endif 90#endif
90 91
@@ -115,6 +116,7 @@
115# define __iswctype iswctype 116# define __iswctype iswctype
116# define __btowc btowc 117# define __btowc btowc
117# define __wcrtomb wcrtomb 118# define __wcrtomb wcrtomb
119# define __mbrtowc mbrtowc
118# define __regfree regfree 120# define __regfree regfree
119# define attribute_hidden 121# define attribute_hidden
120#endif /* not _LIBC */ 122#endif /* not _LIBC */
@@ -161,9 +163,9 @@ typedef unsigned long int bitset_word_t;
161 instead, deduce it directly from BITSET_WORD_MAX. Avoid 163 instead, deduce it directly from BITSET_WORD_MAX. Avoid
162 greater-than-32-bit integers and unconditional shifts by more than 164 greater-than-32-bit integers and unconditional shifts by more than
163 31 bits, as they're not portable. */ 165 31 bits, as they're not portable. */
164#if BITSET_WORD_MAX == 0xffffffff 166#if BITSET_WORD_MAX == 0xffffffffUL
165# define BITSET_WORD_BITS 32 167# define BITSET_WORD_BITS 32
166#elif BITSET_WORD_MAX >> 31 >> 5 == 1 168#elif BITSET_WORD_MAX >> 31 >> 4 == 1
167# define BITSET_WORD_BITS 36 169# define BITSET_WORD_BITS 36
168#elif BITSET_WORD_MAX >> 31 >> 16 == 1 170#elif BITSET_WORD_MAX >> 31 >> 16 == 1
169# define BITSET_WORD_BITS 48 171# define BITSET_WORD_BITS 48
@@ -421,7 +423,7 @@ struct re_dfa_t;
421typedef struct re_dfa_t re_dfa_t; 423typedef struct re_dfa_t re_dfa_t;
422 424
423#ifndef _LIBC 425#ifndef _LIBC
424# ifdef __i386__ 426# if defined __i386__ && !defined __EMX__
425# define internal_function __attribute ((regparm (3), stdcall)) 427# define internal_function __attribute ((regparm (3), stdcall))
426# else 428# else
427# define internal_function 429# define internal_function
diff --git a/gl/regexec.c b/gl/regexec.c
index ac6c258..5452ef7 100644
--- a/gl/regexec.c
+++ b/gl/regexec.c
@@ -1,6 +1,6 @@
1/* Extended regular expression matching and search library. 1/* Extended regular expression matching and search library.
2 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, 2 Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
3 Inc. 3 Free Software Foundation, Inc.
4 This file is part of the GNU C Library. 4 This file is part of the GNU C Library.
5 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>. 5 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
6 6
@@ -701,7 +701,8 @@ re_search_internal (const regex_t *preg,
701 fl_longest_match = (nmatch != 0 || dfa->nbackref); 701 fl_longest_match = (nmatch != 0 || dfa->nbackref);
702 702
703 err = re_string_allocate (&mctx.input, string, length, dfa->nodes_len + 1, 703 err = re_string_allocate (&mctx.input, string, length, dfa->nodes_len + 1,
704 preg->translate, preg->syntax & RE_ICASE, dfa); 704 preg->translate, (preg->syntax & RE_ICASE) != 0,
705 dfa);
705 if (BE (err != REG_NOERROR, 0)) 706 if (BE (err != REG_NOERROR, 0))
706 goto free_return; 707 goto free_return;
707 mctx.input.stop = stop; 708 mctx.input.stop = stop;
@@ -1044,6 +1045,11 @@ prune_impossible_nodes (re_match_context_t *mctx)
1044 re_node_set_free (&sctx.limits); 1045 re_node_set_free (&sctx.limits);
1045 if (BE (ret != REG_NOERROR, 0)) 1046 if (BE (ret != REG_NOERROR, 0))
1046 goto free_return; 1047 goto free_return;
1048 if (sifted_states[0] == NULL)
1049 {
1050 ret = REG_NOMATCH;
1051 goto free_return;
1052 }
1047 } 1053 }
1048 re_free (mctx->state_log); 1054 re_free (mctx->state_log);
1049 mctx->state_log = sifted_states; 1055 mctx->state_log = sifted_states;
@@ -3078,7 +3084,9 @@ check_arrival_add_next_nodes (re_match_context_t *mctx, Idx str_idx,
3078 const re_dfa_t *const dfa = mctx->dfa; 3084 const re_dfa_t *const dfa = mctx->dfa;
3079 bool ok; 3085 bool ok;
3080 Idx cur_idx; 3086 Idx cur_idx;
3087#ifdef RE_ENABLE_I18N
3081 reg_errcode_t err = REG_NOERROR; 3088 reg_errcode_t err = REG_NOERROR;
3089#endif
3082 re_node_set union_set; 3090 re_node_set union_set;
3083 re_node_set_init_empty (&union_set); 3091 re_node_set_init_empty (&union_set);
3084 for (cur_idx = 0; cur_idx < cur_nodes->nelem; ++cur_idx) 3092 for (cur_idx = 0; cur_idx < cur_nodes->nelem; ++cur_idx)
@@ -3467,7 +3475,7 @@ out_free:
3467 CONTEXT_NEWLINE); 3475 CONTEXT_NEWLINE);
3468 if (BE (dest_states_nl[i] == NULL && err != REG_NOERROR, 0)) 3476 if (BE (dest_states_nl[i] == NULL && err != REG_NOERROR, 0))
3469 goto out_free; 3477 goto out_free;
3470 } 3478 }
3471 else 3479 else
3472 { 3480 {
3473 dest_states_word[i] = dest_states[i]; 3481 dest_states_word[i] = dest_states[i];
diff --git a/gl/snprintf.c b/gl/snprintf.c
index 960cfdb..dafbda8 100644
--- a/gl/snprintf.c
+++ b/gl/snprintf.c
@@ -1,5 +1,5 @@
1/* Formatted output to strings. 1/* Formatted output to strings.
2 Copyright (C) 2004, 2006-2007 Free Software Foundation, Inc. 2 Copyright (C) 2004, 2006-2008 Free Software Foundation, Inc.
3 Written by Simon Josefsson and Paul Eggert. 3 Written by Simon Josefsson and Paul Eggert.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
@@ -29,11 +29,6 @@
29 29
30#include "vasnprintf.h" 30#include "vasnprintf.h"
31 31
32/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */
33#ifndef EOVERFLOW
34# define EOVERFLOW E2BIG
35#endif
36
37/* Print formatted output to string STR. Similar to sprintf, but 32/* Print formatted output to string STR. Similar to sprintf, but
38 additional length SIZE limit how much is written into STR. Returns 33 additional length SIZE limit how much is written into STR. Returns
39 string length of formatted string (which may be larger than SIZE). 34 string length of formatted string (which may be larger than SIZE).
diff --git a/gl/stdbool.in.h b/gl/stdbool.in.h
index 171d70a..cffa0ab 100644
--- a/gl/stdbool.in.h
+++ b/gl/stdbool.in.h
@@ -1,4 +1,4 @@
1/* Copyright (C) 2001, 2002, 2003, 2006, 2007 Free Software Foundation, Inc. 1/* Copyright (C) 2001-2003, 2006-2008 Free Software Foundation, Inc.
2 Written by Bruno Haible <haible@clisp.cons.org>, 2001. 2 Written by Bruno Haible <haible@clisp.cons.org>, 2001.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
@@ -58,7 +58,7 @@
58 58
59/* BeOS <sys/socket.h> already #defines false 0, true 1. We use the same 59/* BeOS <sys/socket.h> already #defines false 0, true 1. We use the same
60 definitions below, but temporarily we have to #undef them. */ 60 definitions below, but temporarily we have to #undef them. */
61#ifdef __BEOS__ 61#if defined __BEOS__ && !defined __HAIKU__
62# include <OS.h> /* defines bool but not _Bool */ 62# include <OS.h> /* defines bool but not _Bool */
63# undef false 63# undef false
64# undef true 64# undef true
@@ -73,7 +73,7 @@
73 (see ISO C 99 6.7.2.2.(4)); however, '_Bool' must promote to 'int' 73 (see ISO C 99 6.7.2.2.(4)); however, '_Bool' must promote to 'int'
74 (see ISO C 99 6.3.1.1.(2)). So we add a negative value to the 74 (see ISO C 99 6.3.1.1.(2)). So we add a negative value to the
75 enum; this ensures that '_Bool' promotes to 'int'. */ 75 enum; this ensures that '_Bool' promotes to 'int'. */
76#if defined __cplusplus || defined __BEOS__ 76#if defined __cplusplus || (defined __BEOS__ && !defined __HAIKU__)
77 /* A compiler known to have 'bool'. */ 77 /* A compiler known to have 'bool'. */
78 /* If the compiler already has both 'bool' and '_Bool', we can assume they 78 /* If the compiler already has both 'bool' and '_Bool', we can assume they
79 are the same types. */ 79 are the same types. */
diff --git a/gl/stdint.in.h b/gl/stdint.in.h
index 67baceb..f141c8f 100644
--- a/gl/stdint.in.h
+++ b/gl/stdint.in.h
@@ -1,4 +1,4 @@
1/* Copyright (C) 2001-2002, 2004-2007 Free Software Foundation, Inc. 1/* Copyright (C) 2001-2002, 2004-2009 Free Software Foundation, Inc.
2 Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood. 2 Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood.
3 This file is part of gnulib. 3 This file is part of gnulib.
4 4
@@ -49,6 +49,9 @@
49 in <inttypes.h> would reinclude us, skipping our contents because 49 in <inttypes.h> would reinclude us, skipping our contents because
50 _GL_STDINT_H is defined. 50 _GL_STDINT_H is defined.
51 The include_next requires a split double-inclusion guard. */ 51 The include_next requires a split double-inclusion guard. */
52# if __GNUC__ >= 3
53@PRAGMA_SYSTEM_HEADER@
54# endif
52# @INCLUDE_NEXT@ @NEXT_STDINT_H@ 55# @INCLUDE_NEXT@ @NEXT_STDINT_H@
53#endif 56#endif
54 57
@@ -86,15 +89,6 @@
86# include <sys/bitypes.h> 89# include <sys/bitypes.h>
87#endif 90#endif
88 91
89#if ! defined __cplusplus || defined __STDC_CONSTANT_MACROS
90
91/* Get WCHAR_MIN, WCHAR_MAX. */
92# if ! (defined WCHAR_MIN && defined WCHAR_MAX)
93# include <wchar.h>
94# endif
95
96#endif
97
98#undef _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H 92#undef _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
99 93
100/* Minimum and maximum values for a integer type under the usual assumption. 94/* Minimum and maximum values for a integer type under the usual assumption.
@@ -119,46 +113,58 @@
119 113
120#undef int8_t 114#undef int8_t
121#undef uint8_t 115#undef uint8_t
122#define int8_t signed char 116typedef signed char gl_int8_t;
123#define uint8_t unsigned char 117typedef unsigned char gl_uint8_t;
118#define int8_t gl_int8_t
119#define uint8_t gl_uint8_t
124 120
125#undef int16_t 121#undef int16_t
126#undef uint16_t 122#undef uint16_t
127#define int16_t short int 123typedef short int gl_int16_t;
128#define uint16_t unsigned short int 124typedef unsigned short int gl_uint16_t;
125#define int16_t gl_int16_t
126#define uint16_t gl_uint16_t
129 127
130#undef int32_t 128#undef int32_t
131#undef uint32_t 129#undef uint32_t
132#define int32_t int 130typedef int gl_int32_t;
133#define uint32_t unsigned int 131typedef unsigned int gl_uint32_t;
132#define int32_t gl_int32_t
133#define uint32_t gl_uint32_t
134 134
135/* Do not undefine int64_t if gnulib is not being used with 64-bit 135/* Do not undefine int64_t if gnulib is not being used with 64-bit
136 types, since otherwise it breaks platforms like Tandem/NSK. */ 136 types, since otherwise it breaks platforms like Tandem/NSK. */
137#if LONG_MAX >> 31 >> 31 == 1 137#if LONG_MAX >> 31 >> 31 == 1
138# undef int64_t 138# undef int64_t
139# define int64_t long int 139typedef long int gl_int64_t;
140# define int64_t gl_int64_t
140# define GL_INT64_T 141# define GL_INT64_T
141#elif defined _MSC_VER 142#elif defined _MSC_VER
142# undef int64_t 143# undef int64_t
143# define int64_t __int64 144typedef __int64 gl_int64_t;
145# define int64_t gl_int64_t
144# define GL_INT64_T 146# define GL_INT64_T
145#elif @HAVE_LONG_LONG_INT@ 147#elif @HAVE_LONG_LONG_INT@
146# undef int64_t 148# undef int64_t
147# define int64_t long long int 149typedef long long int gl_int64_t;
150# define int64_t gl_int64_t
148# define GL_INT64_T 151# define GL_INT64_T
149#endif 152#endif
150 153
151#if ULONG_MAX >> 31 >> 31 >> 1 == 1 154#if ULONG_MAX >> 31 >> 31 >> 1 == 1
152# undef uint64_t 155# undef uint64_t
153# define uint64_t unsigned long int 156typedef unsigned long int gl_uint64_t;
157# define uint64_t gl_uint64_t
154# define GL_UINT64_T 158# define GL_UINT64_T
155#elif defined _MSC_VER 159#elif defined _MSC_VER
156# undef uint64_t 160# undef uint64_t
157# define uint64_t unsigned __int64 161typedef unsigned __int64 gl_uint64_t;
162# define uint64_t gl_uint64_t
158# define GL_UINT64_T 163# define GL_UINT64_T
159#elif @HAVE_UNSIGNED_LONG_LONG_INT@ 164#elif @HAVE_UNSIGNED_LONG_LONG_INT@
160# undef uint64_t 165# undef uint64_t
161# define uint64_t unsigned long long int 166typedef unsigned long long int gl_uint64_t;
167# define uint64_t gl_uint64_t
162# define GL_UINT64_T 168# define GL_UINT64_T
163#endif 169#endif
164 170
@@ -213,12 +219,18 @@
213#undef uint_fast32_t 219#undef uint_fast32_t
214#undef int_fast64_t 220#undef int_fast64_t
215#undef uint_fast64_t 221#undef uint_fast64_t
216#define int_fast8_t long int 222typedef long int gl_int_fast8_t;
217#define uint_fast8_t unsigned int_fast8_t 223typedef unsigned long int gl_uint_fast8_t;
218#define int_fast16_t long int 224typedef long int gl_int_fast16_t;
219#define uint_fast16_t unsigned int_fast16_t 225typedef unsigned long int gl_uint_fast16_t;
220#define int_fast32_t long int 226typedef long int gl_int_fast32_t;
221#define uint_fast32_t unsigned int_fast32_t 227typedef unsigned long int gl_uint_fast32_t;
228#define int_fast8_t gl_int_fast8_t
229#define uint_fast8_t gl_uint_fast8_t
230#define int_fast16_t gl_int_fast16_t
231#define uint_fast16_t gl_uint_fast16_t
232#define int_fast32_t gl_int_fast32_t
233#define uint_fast32_t gl_uint_fast32_t
222#ifdef GL_INT64_T 234#ifdef GL_INT64_T
223# define int_fast64_t int64_t 235# define int_fast64_t int64_t
224#endif 236#endif
@@ -230,8 +242,10 @@
230 242
231#undef intptr_t 243#undef intptr_t
232#undef uintptr_t 244#undef uintptr_t
233#define intptr_t long int 245typedef long int gl_intptr_t;
234#define uintptr_t unsigned long int 246typedef unsigned long int gl_uintptr_t;
247#define intptr_t gl_intptr_t
248#define uintptr_t gl_uintptr_t
235 249
236/* 7.18.1.5. Greatest-width integer types */ 250/* 7.18.1.5. Greatest-width integer types */
237 251
@@ -240,20 +254,24 @@
240 254
241#undef intmax_t 255#undef intmax_t
242#if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1 256#if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
243# define intmax_t long long int 257typedef long long int gl_intmax_t;
258# define intmax_t gl_intmax_t
244#elif defined GL_INT64_T 259#elif defined GL_INT64_T
245# define intmax_t int64_t 260# define intmax_t int64_t
246#else 261#else
247# define intmax_t long int 262typedef long int gl_intmax_t;
263# define intmax_t gl_intmax_t
248#endif 264#endif
249 265
250#undef uintmax_t 266#undef uintmax_t
251#if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1 267#if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1
252# define uintmax_t unsigned long long int 268typedef unsigned long long int gl_uintmax_t;
269# define uintmax_t gl_uintmax_t
253#elif defined GL_UINT64_T 270#elif defined GL_UINT64_T
254# define uintmax_t uint64_t 271# define uintmax_t uint64_t
255#else 272#else
256# define uintmax_t unsigned long int 273typedef unsigned long int gl_uintmax_t;
274# define uintmax_t gl_uintmax_t
257#endif 275#endif
258 276
259/* Verify that intmax_t and uintmax_t have the same size. Too much code 277/* Verify that intmax_t and uintmax_t have the same size. Too much code
@@ -416,10 +434,20 @@ typedef int _verify_intmax_size[2 * (sizeof (intmax_t) == sizeof (uintmax_t)) -
416/* ptrdiff_t limits */ 434/* ptrdiff_t limits */
417#undef PTRDIFF_MIN 435#undef PTRDIFF_MIN
418#undef PTRDIFF_MAX 436#undef PTRDIFF_MAX
419#define PTRDIFF_MIN \ 437#if @APPLE_UNIVERSAL_BUILD@
420 _STDINT_MIN (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@) 438# if _LP64
421#define PTRDIFF_MAX \ 439# define PTRDIFF_MIN _STDINT_MIN (1, 64, 0l)
422 _STDINT_MAX (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@) 440# define PTRDIFF_MAX _STDINT_MAX (1, 64, 0l)
441# else
442# define PTRDIFF_MIN _STDINT_MIN (1, 32, 0)
443# define PTRDIFF_MAX _STDINT_MAX (1, 32, 0)
444# endif
445#else
446# define PTRDIFF_MIN \
447 _STDINT_MIN (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@)
448# define PTRDIFF_MAX \
449 _STDINT_MAX (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@)
450#endif
423 451
424/* sig_atomic_t limits */ 452/* sig_atomic_t limits */
425#undef SIG_ATOMIC_MIN 453#undef SIG_ATOMIC_MIN
@@ -434,9 +462,26 @@ typedef int _verify_intmax_size[2 * (sizeof (intmax_t) == sizeof (uintmax_t)) -
434 462
435/* size_t limit */ 463/* size_t limit */
436#undef SIZE_MAX 464#undef SIZE_MAX
437#define SIZE_MAX _STDINT_MAX (0, @BITSIZEOF_SIZE_T@, 0@SIZE_T_SUFFIX@) 465#if @APPLE_UNIVERSAL_BUILD@
466# if _LP64
467# define SIZE_MAX _STDINT_MAX (0, 64, 0ul)
468# else
469# define SIZE_MAX _STDINT_MAX (0, 32, 0ul)
470# endif
471#else
472# define SIZE_MAX _STDINT_MAX (0, @BITSIZEOF_SIZE_T@, 0@SIZE_T_SUFFIX@)
473#endif
438 474
439/* wchar_t limits */ 475/* wchar_t limits */
476/* Get WCHAR_MIN, WCHAR_MAX.
477 This include is not on the top, above, because on OSF/1 4.0 we have a sequence of nested
478 includes <wchar.h> -> <stdio.h> -> <getopt.h> -> <stdlib.h>, and the latter includes
479 <stdint.h> and assumes its types are already defined. */
480#if ! (defined WCHAR_MIN && defined WCHAR_MAX)
481# define _GL_JUST_INCLUDE_SYSTEM_WCHAR_H
482# include <wchar.h>
483# undef _GL_JUST_INCLUDE_SYSTEM_WCHAR_H
484#endif
440#undef WCHAR_MIN 485#undef WCHAR_MIN
441#undef WCHAR_MAX 486#undef WCHAR_MAX
442#define WCHAR_MIN \ 487#define WCHAR_MIN \
diff --git a/gl/stdio-write.c b/gl/stdio-write.c
new file mode 100644
index 0000000..f1d0fcb
--- /dev/null
+++ b/gl/stdio-write.c
@@ -0,0 +1,148 @@
1/* POSIX compatible FILE stream write function.
2 Copyright (C) 2008 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2008.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#include <stdio.h>
22
23/* Replace these functions only if module 'sigpipe' is requested. */
24#if GNULIB_SIGPIPE
25
26/* On native Windows platforms, SIGPIPE does not exist. When write() is
27 called on a pipe with no readers, WriteFile() fails with error
28 GetLastError() = ERROR_NO_DATA, and write() in consequence fails with
29 error EINVAL. This write() function is at the basis of the function
30 which flushes the buffer of a FILE stream. */
31
32# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
33
34# include <errno.h>
35# include <signal.h>
36# include <io.h>
37
38# define WIN32_LEAN_AND_MEAN /* avoid including junk */
39# include <windows.h>
40
41# define CALL_WITH_SIGPIPE_EMULATION(RETTYPE, EXPRESSION, FAILED) \
42 if (ferror (stream)) \
43 return (EXPRESSION); \
44 else \
45 { \
46 RETTYPE ret; \
47 SetLastError (0); \
48 ret = (EXPRESSION); \
49 if (FAILED && GetLastError () == ERROR_NO_DATA && ferror (stream)) \
50 { \
51 int fd = fileno (stream); \
52 if (fd >= 0 \
53 && GetFileType ((HANDLE) _get_osfhandle (fd)) == FILE_TYPE_PIPE)\
54 { \
55 /* Try to raise signal SIGPIPE. */ \
56 raise (SIGPIPE); \
57 /* If it is currently blocked or ignored, change errno from \
58 EINVAL to EPIPE. */ \
59 errno = EPIPE; \
60 } \
61 } \
62 return ret; \
63 }
64
65# if !REPLACE_PRINTF_POSIX /* avoid collision with printf.c */
66int
67printf (const char *format, ...)
68{
69 int retval;
70 va_list args;
71
72 va_start (args, format);
73 retval = vfprintf (stdout, format, args);
74 va_end (args);
75
76 return retval;
77}
78# endif
79
80# if !REPLACE_FPRINTF_POSIX /* avoid collision with fprintf.c */
81int
82fprintf (FILE *stream, const char *format, ...)
83{
84 int retval;
85 va_list args;
86
87 va_start (args, format);
88 retval = vfprintf (stream, format, args);
89 va_end (args);
90
91 return retval;
92}
93# endif
94
95# if !REPLACE_VFPRINTF_POSIX /* avoid collision with vprintf.c */
96int
97vprintf (const char *format, va_list args)
98{
99 return vfprintf (stdout, format, args);
100}
101# endif
102
103# if !REPLACE_VPRINTF_POSIX /* avoid collision with vfprintf.c */
104int
105vfprintf (FILE *stream, const char *format, va_list args)
106#undef vfprintf
107{
108 CALL_WITH_SIGPIPE_EMULATION (int, vfprintf (stream, format, args), ret == EOF)
109}
110# endif
111
112int
113putchar (int c)
114{
115 return fputc (c, stdout);
116}
117
118int
119fputc (int c, FILE *stream)
120#undef fputc
121{
122 CALL_WITH_SIGPIPE_EMULATION (int, fputc (c, stream), ret == EOF)
123}
124
125int
126fputs (const char *string, FILE *stream)
127#undef fputs
128{
129 CALL_WITH_SIGPIPE_EMULATION (int, fputs (string, stream), ret == EOF)
130}
131
132int
133puts (const char *string)
134#undef puts
135{
136 FILE *stream = stdout;
137 CALL_WITH_SIGPIPE_EMULATION (int, puts (string), ret == EOF)
138}
139
140size_t
141fwrite (const void *ptr, size_t s, size_t n, FILE *stream)
142#undef fwrite
143{
144 CALL_WITH_SIGPIPE_EMULATION (size_t, fwrite (ptr, s, n, stream), ret < n)
145}
146
147# endif
148#endif
diff --git a/gl/stdio.in.h b/gl/stdio.in.h
index 434fa8e..96cb257 100644
--- a/gl/stdio.in.h
+++ b/gl/stdio.in.h
@@ -16,6 +16,10 @@
16 along with this program; if not, write to the Free Software Foundation, 16 along with this program; if not, write to the Free Software Foundation,
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ 17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 18
19#if __GNUC__ >= 3
20@PRAGMA_SYSTEM_HEADER@
21#endif
22
19#if defined __need_FILE || defined __need___FILE 23#if defined __need_FILE || defined __need___FILE
20/* Special invocation convention inside glibc header files. */ 24/* Special invocation convention inside glibc header files. */
21 25
@@ -71,6 +75,10 @@ extern "C" {
71extern int fprintf (FILE *fp, const char *format, ...) 75extern int fprintf (FILE *fp, const char *format, ...)
72 __attribute__ ((__format__ (__printf__, 2, 3))); 76 __attribute__ ((__format__ (__printf__, 2, 3)));
73# endif 77# endif
78#elif @GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
79# define fprintf rpl_fprintf
80extern int fprintf (FILE *fp, const char *format, ...)
81 __attribute__ ((__format__ (__printf__, 2, 3)));
74#elif defined GNULIB_POSIXCHECK 82#elif defined GNULIB_POSIXCHECK
75# undef fprintf 83# undef fprintf
76# define fprintf \ 84# define fprintf \
@@ -86,6 +94,10 @@ extern int fprintf (FILE *fp, const char *format, ...)
86extern int vfprintf (FILE *fp, const char *format, va_list args) 94extern int vfprintf (FILE *fp, const char *format, va_list args)
87 __attribute__ ((__format__ (__printf__, 2, 0))); 95 __attribute__ ((__format__ (__printf__, 2, 0)));
88# endif 96# endif
97#elif @GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
98# define vfprintf rpl_vfprintf
99extern int vfprintf (FILE *fp, const char *format, va_list args)
100 __attribute__ ((__format__ (__printf__, 2, 0)));
89#elif defined GNULIB_POSIXCHECK 101#elif defined GNULIB_POSIXCHECK
90# undef vfprintf 102# undef vfprintf
91# define vfprintf(s,f,a) \ 103# define vfprintf(s,f,a) \
@@ -102,6 +114,11 @@ extern int vfprintf (FILE *fp, const char *format, va_list args)
102extern int printf (const char *format, ...) 114extern int printf (const char *format, ...)
103 __attribute__ ((__format__ (__printf__, 1, 2))); 115 __attribute__ ((__format__ (__printf__, 1, 2)));
104# endif 116# endif
117#elif @GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
118/* Don't break __attribute__((format(printf,M,N))). */
119# define printf __printf__
120extern int printf (const char *format, ...)
121 __attribute__ ((__format__ (__printf__, 1, 2)));
105#elif defined GNULIB_POSIXCHECK 122#elif defined GNULIB_POSIXCHECK
106# undef printf 123# undef printf
107# define printf \ 124# define printf \
@@ -124,6 +141,10 @@ extern int printf (const char *format, ...)
124extern int vprintf (const char *format, va_list args) 141extern int vprintf (const char *format, va_list args)
125 __attribute__ ((__format__ (__printf__, 1, 0))); 142 __attribute__ ((__format__ (__printf__, 1, 0)));
126# endif 143# endif
144#elif @GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
145# define vprintf rpl_vprintf
146extern int vprintf (const char *format, va_list args)
147 __attribute__ ((__format__ (__printf__, 1, 0)));
127#elif defined GNULIB_POSIXCHECK 148#elif defined GNULIB_POSIXCHECK
128# undef vprintf 149# undef vprintf
129# define vprintf(f,a) \ 150# define vprintf(f,a) \
@@ -212,8 +233,29 @@ extern int vsprintf (char *str, const char *format, va_list args)
212# endif 233# endif
213#endif 234#endif
214 235
236#if @GNULIB_OBSTACK_PRINTF@
237# if @REPLACE_OBSTACK_PRINTF@
238# define obstack_printf rpl_osbtack_printf
239# define obstack_vprintf rpl_obstack_vprintf
240# endif
241# if @REPLACE_OBSTACK_PRINTF@ || !@HAVE_DECL_OBSTACK_PRINTF@
242 struct obstack;
243 /* Grow an obstack with formatted output. Return the number of
244 bytes added to OBS. No trailing nul byte is added, and the
245 object should be closed with obstack_finish before use. Upon
246 memory allocation error, call obstack_alloc_failed_handler. Upon
247 other error, return -1. */
248 extern int obstack_printf (struct obstack *obs, const char *format, ...)
249 __attribute__ ((__format__ (__printf__, 2, 3)));
250 extern int obstack_vprintf (struct obstack *obs, const char *format,
251 va_list args)
252 __attribute__ ((__format__ (__printf__, 2, 0)));
253# endif
254#endif
255
215#if @GNULIB_FOPEN@ 256#if @GNULIB_FOPEN@
216# if @REPLACE_FOPEN@ 257# if @REPLACE_FOPEN@
258# undef fopen
217# define fopen rpl_fopen 259# define fopen rpl_fopen
218extern FILE * fopen (const char *filename, const char *mode); 260extern FILE * fopen (const char *filename, const char *mode);
219# endif 261# endif
@@ -227,6 +269,7 @@ extern FILE * fopen (const char *filename, const char *mode);
227 269
228#if @GNULIB_FREOPEN@ 270#if @GNULIB_FREOPEN@
229# if @REPLACE_FREOPEN@ 271# if @REPLACE_FREOPEN@
272# undef freopen
230# define freopen rpl_freopen 273# define freopen rpl_freopen
231extern FILE * freopen (const char *filename, const char *mode, FILE *stream); 274extern FILE * freopen (const char *filename, const char *mode, FILE *stream);
232# endif 275# endif
@@ -332,6 +375,57 @@ extern long rpl_ftell (FILE *fp);
332 fflush (f)) 375 fflush (f))
333#endif 376#endif
334 377
378#if @GNULIB_FCLOSE@
379# if @REPLACE_FCLOSE@
380# define fclose rpl_fclose
381 /* Close STREAM and its underlying file descriptor. */
382extern int fclose (FILE *stream);
383# endif
384#elif defined GNULIB_POSIXCHECK
385# undef fclose
386# define fclose(f) \
387 (GL_LINK_WARNING ("fclose is not always POSIX compliant - " \
388 "use gnulib module fclose for portable " \
389 "POSIX compliance"), \
390 fclose (f))
391#endif
392
393#if @GNULIB_FPUTC@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
394# undef fputc
395# define fputc rpl_fputc
396extern int fputc (int c, FILE *stream);
397#endif
398
399#if @GNULIB_PUTC@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
400# undef putc
401# define putc rpl_fputc
402extern int putc (int c, FILE *stream);
403#endif
404
405#if @GNULIB_PUTCHAR@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
406# undef putchar
407# define putchar rpl_putchar
408extern int putchar (int c);
409#endif
410
411#if @GNULIB_FPUTS@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
412# undef fputs
413# define fputs rpl_fputs
414extern int fputs (const char *string, FILE *stream);
415#endif
416
417#if @GNULIB_PUTS@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
418# undef puts
419# define puts rpl_puts
420extern int puts (const char *string);
421#endif
422
423#if @GNULIB_FWRITE@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
424# undef fwrite
425# define fwrite rpl_fwrite
426extern size_t fwrite (const void *ptr, size_t s, size_t n, FILE *stream);
427#endif
428
335#if @GNULIB_GETDELIM@ 429#if @GNULIB_GETDELIM@
336# if !@HAVE_DECL_GETDELIM@ 430# if !@HAVE_DECL_GETDELIM@
337/* Read input, up to (and including) the next occurrence of DELIMITER, from 431/* Read input, up to (and including) the next occurrence of DELIMITER, from
@@ -373,6 +467,22 @@ extern ssize_t getline (char **lineptr, size_t *linesize, FILE *stream);
373 getline (l, s, f)) 467 getline (l, s, f))
374#endif 468#endif
375 469
470#if @GNULIB_PERROR@
471# if @REPLACE_PERROR@
472# define perror rpl_perror
473/* Print a message to standard error, describing the value of ERRNO,
474 (if STRING is not NULL and not empty) prefixed with STRING and ": ",
475 and terminated with a newline. */
476extern void perror (const char *string);
477# endif
478#elif defined GNULIB_POSIXCHECK
479# undef perror
480# define perror(s) \
481 (GL_LINK_WARNING ("perror is not always POSIX compliant - " \
482 "use gnulib module perror for portability"), \
483 perror (s))
484#endif
485
376#ifdef __cplusplus 486#ifdef __cplusplus
377} 487}
378#endif 488#endif
diff --git a/gl/stdlib.in.h b/gl/stdlib.in.h
index 100ff52..3820b10 100644
--- a/gl/stdlib.in.h
+++ b/gl/stdlib.in.h
@@ -1,6 +1,6 @@
1/* A GNU-like <stdlib.h>. 1/* A GNU-like <stdlib.h>.
2 2
3 Copyright (C) 1995, 2001-2004, 2006-2007 Free Software Foundation, Inc. 3 Copyright (C) 1995, 2001-2004, 2006-2008 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
@@ -15,6 +15,10 @@
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17 17
18#if __GNUC__ >= 3
19@PRAGMA_SYSTEM_HEADER@
20#endif
21
18#if defined __need_malloc_and_calloc 22#if defined __need_malloc_and_calloc
19/* Special invocation convention inside glibc header files. */ 23/* Special invocation convention inside glibc header files. */
20 24
@@ -32,6 +36,28 @@
32#define _GL_STDLIB_H 36#define _GL_STDLIB_H
33 37
34 38
39/* Solaris declares getloadavg() in <sys/loadavg.h>. */
40#if @GNULIB_GETLOADAVG@ && @HAVE_SYS_LOADAVG_H@
41# include <sys/loadavg.h>
42#endif
43
44#if @GNULIB_RANDOM_R@ || !@HAVE_STRUCT_RANDOM_DATA@
45# include <stdint.h>
46#endif
47
48#if !@HAVE_STRUCT_RANDOM_DATA@
49struct random_data
50{
51 int32_t *fptr; /* Front pointer. */
52 int32_t *rptr; /* Rear pointer. */
53 int32_t *state; /* Array of state values. */
54 int rand_type; /* Type of random number generator. */
55 int rand_deg; /* Degree of random number generator. */
56 int rand_sep; /* Distance between front and rear. */
57 int32_t *end_ptr; /* Pointer behind state table. */
58};
59#endif
60
35/* The definition of GL_LINK_WARNING is copied here. */ 61/* The definition of GL_LINK_WARNING is copied here. */
36 62
37 63
@@ -99,6 +125,38 @@ extern void * calloc (size_t nmemb, size_t size);
99#endif 125#endif
100 126
101 127
128#if @GNULIB_ATOLL@
129# if !@HAVE_ATOLL@
130/* Parse a signed decimal integer.
131 Returns the value of the integer. Errors are not detected. */
132extern long long atoll (const char *string);
133# endif
134#elif defined GNULIB_POSIXCHECK
135# undef atoll
136# define atoll(s) \
137 (GL_LINK_WARNING ("atoll is unportable - " \
138 "use gnulib module atoll for portability"), \
139 atoll (s))
140#endif
141
142
143#if @GNULIB_GETLOADAVG@
144# if !@HAVE_DECL_GETLOADAVG@
145/* Store max(NELEM,3) load average numbers in LOADAVG[].
146 The three numbers are the load average of the last 1 minute, the last 5
147 minutes, and the last 15 minutes, respectively.
148 LOADAVG is an array of NELEM numbers. */
149extern int getloadavg (double loadavg[], int nelem);
150# endif
151#elif defined GNULIB_POSIXCHECK
152# undef getloadavg
153# define getloadavg(l,n) \
154 (GL_LINK_WARNING ("getloadavg is not portable - " \
155 "use gnulib module getloadavg for portability"), \
156 getloadavg (l, n))
157#endif
158
159
102#if @GNULIB_GETSUBOPT@ 160#if @GNULIB_GETSUBOPT@
103/* Assuming *OPTIONP is a comma separated list of elements of the form 161/* Assuming *OPTIONP is a comma separated list of elements of the form
104 "token" or "token=value", getsubopt parses the first of these elements. 162 "token" or "token=value", getsubopt parses the first of these elements.
@@ -176,6 +234,58 @@ extern int putenv (char *string);
176#endif 234#endif
177 235
178 236
237#if @GNULIB_RANDOM_R@
238# if !@HAVE_RANDOM_R@
239
240# ifndef RAND_MAX
241# define RAND_MAX 2147483647
242# endif
243
244int srandom_r (unsigned int seed, struct random_data *rand_state);
245int initstate_r (unsigned int seed, char *buf, size_t buf_size,
246 struct random_data *rand_state);
247int setstate_r (char *arg_state, struct random_data *rand_state);
248int random_r (struct random_data *buf, int32_t *result);
249# endif
250#elif defined GNULIB_POSIXCHECK
251# undef random_r
252# define random_r(b,r) \
253 (GL_LINK_WARNING ("random_r is unportable - " \
254 "use gnulib module random_r for portability"), \
255 random_r (b,r))
256# undef initstate_r
257# define initstate_r(s,b,sz,r) \
258 (GL_LINK_WARNING ("initstate_r is unportable - " \
259 "use gnulib module random_r for portability"), \
260 initstate_r (s,b,sz,r))
261# undef srandom_r
262# define srandom_r(s,r) \
263 (GL_LINK_WARNING ("srandom_r is unportable - " \
264 "use gnulib module random_r for portability"), \
265 srandom_r (s,r))
266# undef setstate_r
267# define setstate_r(a,r) \
268 (GL_LINK_WARNING ("setstate_r is unportable - " \
269 "use gnulib module random_r for portability"), \
270 setstate_r (a,r))
271#endif
272
273
274#if @GNULIB_RPMATCH@
275# if !@HAVE_RPMATCH@
276/* Test a user response to a question.
277 Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear. */
278extern int rpmatch (const char *response);
279# endif
280#elif defined GNULIB_POSIXCHECK
281# undef rpmatch
282# define rpmatch(r) \
283 (GL_LINK_WARNING ("rpmatch is unportable - " \
284 "use gnulib module rpmatch for portability"), \
285 rpmatch (r))
286#endif
287
288
179#if @GNULIB_SETENV@ 289#if @GNULIB_SETENV@
180# if !@HAVE_SETENV@ 290# if !@HAVE_SETENV@
181/* Set NAME to VALUE in the environment. 291/* Set NAME to VALUE in the environment.
@@ -199,6 +309,65 @@ extern int unsetenv (const char *name);
199#endif 309#endif
200 310
201 311
312#if @GNULIB_STRTOD@
313# if @REPLACE_STRTOD@
314# define strtod rpl_strtod
315# endif
316# if !@HAVE_STRTOD@ || @REPLACE_STRTOD@
317 /* Parse a double from STRING, updating ENDP if appropriate. */
318extern double strtod (const char *str, char **endp);
319# endif
320#elif defined GNULIB_POSIXCHECK
321# undef strtod
322# define strtod(s, e) \
323 (GL_LINK_WARNING ("strtod is unportable - " \
324 "use gnulib module strtod for portability"), \
325 strtod (s, e))
326#endif
327
328
329#if @GNULIB_STRTOLL@
330# if !@HAVE_STRTOLL@
331/* Parse a signed integer whose textual representation starts at STRING.
332 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
333 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
334 "0x").
335 If ENDPTR is not NULL, the address of the first byte after the integer is
336 stored in *ENDPTR.
337 Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set
338 to ERANGE. */
339extern long long strtoll (const char *string, char **endptr, int base);
340# endif
341#elif defined GNULIB_POSIXCHECK
342# undef strtoll
343# define strtoll(s,e,b) \
344 (GL_LINK_WARNING ("strtoll is unportable - " \
345 "use gnulib module strtoll for portability"), \
346 strtoll (s, e, b))
347#endif
348
349
350#if @GNULIB_STRTOULL@
351# if !@HAVE_STRTOULL@
352/* Parse an unsigned integer whose textual representation starts at STRING.
353 The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
354 it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
355 "0x").
356 If ENDPTR is not NULL, the address of the first byte after the integer is
357 stored in *ENDPTR.
358 Upon overflow, the return value is ULLONG_MAX, and errno is set to
359 ERANGE. */
360extern unsigned long long strtoull (const char *string, char **endptr, int base);
361# endif
362#elif defined GNULIB_POSIXCHECK
363# undef strtoull
364# define strtoull(s,e,b) \
365 (GL_LINK_WARNING ("strtoull is unportable - " \
366 "use gnulib module strtoull for portability"), \
367 strtoull (s, e, b))
368#endif
369
370
202#ifdef __cplusplus 371#ifdef __cplusplus
203} 372}
204#endif 373#endif
diff --git a/gl/strdup.c b/gl/strdup.c
deleted file mode 100644
index bebe5c8..0000000
--- a/gl/strdup.c
+++ /dev/null
@@ -1,55 +0,0 @@
1/* Copyright (C) 1991, 1996, 1997, 1998, 2002, 2003, 2004, 2006, 2007 Free
2 Software Foundation, Inc.
3
4 This file is part of the GNU C Library.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
9 any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License along
17 with this program; if not, write to the Free Software Foundation,
18 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
19
20#ifndef _LIBC
21# include <config.h>
22#endif
23
24/* Get specification. */
25#include <string.h>
26
27#include <stdlib.h>
28
29#undef __strdup
30#ifdef _LIBC
31# undef strdup
32#endif
33
34#ifndef weak_alias
35# define __strdup strdup
36#endif
37
38/* Duplicate S, returning an identical malloc'd string. */
39char *
40__strdup (const char *s)
41{
42 size_t len = strlen (s) + 1;
43 void *new = malloc (len);
44
45 if (new == NULL)
46 return NULL;
47
48 return (char *) memcpy (new, s, len);
49}
50#ifdef libc_hidden_def
51libc_hidden_def (__strdup)
52#endif
53#ifdef weak_alias
54weak_alias (__strdup, strdup)
55#endif
diff --git a/gl/streq.h b/gl/streq.h
new file mode 100644
index 0000000..80df916
--- /dev/null
+++ b/gl/streq.h
@@ -0,0 +1,176 @@
1/* Optimized string comparison.
2 Copyright (C) 2001-2002, 2007 Free Software Foundation, Inc.
3
4 This program is free software: you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published
6 by the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
16
17/* Written by Bruno Haible <bruno@clisp.org>. */
18
19#ifndef _GL_STREQ_H
20#define _GL_STREQ_H
21
22#include <string.h>
23
24/* STREQ allows to optimize string comparison with a small literal string.
25 STREQ (s, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
26 is semantically equivalent to
27 strcmp (s, "EUC-KR") == 0
28 just faster. */
29
30/* Help GCC to generate good code for string comparisons with
31 immediate strings. */
32#if defined (__GNUC__) && defined (__OPTIMIZE__)
33
34static inline int
35streq9 (const char *s1, const char *s2)
36{
37 return strcmp (s1 + 9, s2 + 9) == 0;
38}
39
40static inline int
41streq8 (const char *s1, const char *s2, char s28)
42{
43 if (s1[8] == s28)
44 {
45 if (s28 == 0)
46 return 1;
47 else
48 return streq9 (s1, s2);
49 }
50 else
51 return 0;
52}
53
54static inline int
55streq7 (const char *s1, const char *s2, char s27, char s28)
56{
57 if (s1[7] == s27)
58 {
59 if (s27 == 0)
60 return 1;
61 else
62 return streq8 (s1, s2, s28);
63 }
64 else
65 return 0;
66}
67
68static inline int
69streq6 (const char *s1, const char *s2, char s26, char s27, char s28)
70{
71 if (s1[6] == s26)
72 {
73 if (s26 == 0)
74 return 1;
75 else
76 return streq7 (s1, s2, s27, s28);
77 }
78 else
79 return 0;
80}
81
82static inline int
83streq5 (const char *s1, const char *s2, char s25, char s26, char s27, char s28)
84{
85 if (s1[5] == s25)
86 {
87 if (s25 == 0)
88 return 1;
89 else
90 return streq6 (s1, s2, s26, s27, s28);
91 }
92 else
93 return 0;
94}
95
96static inline int
97streq4 (const char *s1, const char *s2, char s24, char s25, char s26, char s27, char s28)
98{
99 if (s1[4] == s24)
100 {
101 if (s24 == 0)
102 return 1;
103 else
104 return streq5 (s1, s2, s25, s26, s27, s28);
105 }
106 else
107 return 0;
108}
109
110static inline int
111streq3 (const char *s1, const char *s2, char s23, char s24, char s25, char s26, char s27, char s28)
112{
113 if (s1[3] == s23)
114 {
115 if (s23 == 0)
116 return 1;
117 else
118 return streq4 (s1, s2, s24, s25, s26, s27, s28);
119 }
120 else
121 return 0;
122}
123
124static inline int
125streq2 (const char *s1, const char *s2, char s22, char s23, char s24, char s25, char s26, char s27, char s28)
126{
127 if (s1[2] == s22)
128 {
129 if (s22 == 0)
130 return 1;
131 else
132 return streq3 (s1, s2, s23, s24, s25, s26, s27, s28);
133 }
134 else
135 return 0;
136}
137
138static inline int
139streq1 (const char *s1, const char *s2, char s21, char s22, char s23, char s24, char s25, char s26, char s27, char s28)
140{
141 if (s1[1] == s21)
142 {
143 if (s21 == 0)
144 return 1;
145 else
146 return streq2 (s1, s2, s22, s23, s24, s25, s26, s27, s28);
147 }
148 else
149 return 0;
150}
151
152static inline int
153streq0 (const char *s1, const char *s2, char s20, char s21, char s22, char s23, char s24, char s25, char s26, char s27, char s28)
154{
155 if (s1[0] == s20)
156 {
157 if (s20 == 0)
158 return 1;
159 else
160 return streq1 (s1, s2, s21, s22, s23, s24, s25, s26, s27, s28);
161 }
162 else
163 return 0;
164}
165
166#define STREQ(s1,s2,s20,s21,s22,s23,s24,s25,s26,s27,s28) \
167 streq0 (s1, s2, s20, s21, s22, s23, s24, s25, s26, s27, s28)
168
169#else
170
171#define STREQ(s1,s2,s20,s21,s22,s23,s24,s25,s26,s27,s28) \
172 (strcmp (s1, s2) == 0)
173
174#endif
175
176#endif /* _GL_STREQ_H */
diff --git a/gl/strerror.c b/gl/strerror.c
index 9fe437d..787575f 100644
--- a/gl/strerror.c
+++ b/gl/strerror.c
@@ -1,6 +1,6 @@
1/* strerror.c --- POSIX compatible system error routine 1/* strerror.c --- POSIX compatible system error routine
2 2
3 Copyright (C) 2007 Free Software Foundation, Inc. 3 Copyright (C) 2007-2008 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
@@ -21,8 +21,15 @@
21 21
22#if REPLACE_STRERROR 22#if REPLACE_STRERROR
23 23
24# include <errno.h>
24# include <stdio.h> 25# include <stdio.h>
25 26
27# if GNULIB_defined_ESOCK /* native Windows platforms */
28# if HAVE_WINSOCK2_H
29# include <winsock2.h>
30# endif
31# endif
32
26# include "intprops.h" 33# include "intprops.h"
27 34
28# undef strerror 35# undef strerror
@@ -33,17 +40,234 @@
33char * 40char *
34rpl_strerror (int n) 41rpl_strerror (int n)
35{ 42{
36 char *result = strerror (n); 43 /* These error messages are taken from glibc/sysdeps/gnu/errlist.c. */
37 44 switch (n)
38 if (result == NULL || result[0] == '\0')
39 { 45 {
40 static char const fmt[] = "Unknown error (%d)"; 46# if GNULIB_defined_ETXTBSY
41 static char mesg[sizeof fmt + INT_STRLEN_BOUND (n)]; 47 case ETXTBSY:
42 sprintf (mesg, fmt, n); 48 return "Text file busy";
43 return mesg; 49# endif
50
51# if GNULIB_defined_ESOCK /* native Windows platforms */
52 /* EWOULDBLOCK is the same as EAGAIN. */
53 case EINPROGRESS:
54 return "Operation now in progress";
55 case EALREADY:
56 return "Operation already in progress";
57 case ENOTSOCK:
58 return "Socket operation on non-socket";
59 case EDESTADDRREQ:
60 return "Destination address required";
61 case EMSGSIZE:
62 return "Message too long";
63 case EPROTOTYPE:
64 return "Protocol wrong type for socket";
65 case ENOPROTOOPT:
66 return "Protocol not available";
67 case EPROTONOSUPPORT:
68 return "Protocol not supported";
69 case ESOCKTNOSUPPORT:
70 return "Socket type not supported";
71 case EOPNOTSUPP:
72 return "Operation not supported";
73 case EPFNOSUPPORT:
74 return "Protocol family not supported";
75 case EAFNOSUPPORT:
76 return "Address family not supported by protocol";
77 case EADDRINUSE:
78 return "Address already in use";
79 case EADDRNOTAVAIL:
80 return "Cannot assign requested address";
81 case ENETDOWN:
82 return "Network is down";
83 case ENETUNREACH:
84 return "Network is unreachable";
85 case ENETRESET:
86 return "Network dropped connection on reset";
87 case ECONNABORTED:
88 return "Software caused connection abort";
89 case ECONNRESET:
90 return "Connection reset by peer";
91 case ENOBUFS:
92 return "No buffer space available";
93 case EISCONN:
94 return "Transport endpoint is already connected";
95 case ENOTCONN:
96 return "Transport endpoint is not connected";
97 case ESHUTDOWN:
98 return "Cannot send after transport endpoint shutdown";
99 case ETOOMANYREFS:
100 return "Too many references: cannot splice";
101 case ETIMEDOUT:
102 return "Connection timed out";
103 case ECONNREFUSED:
104 return "Connection refused";
105 case ELOOP:
106 return "Too many levels of symbolic links";
107 case EHOSTDOWN:
108 return "Host is down";
109 case EHOSTUNREACH:
110 return "No route to host";
111 case EPROCLIM:
112 return "Too many processes";
113 case EUSERS:
114 return "Too many users";
115 case EDQUOT:
116 return "Disk quota exceeded";
117 case ESTALE:
118 return "Stale NFS file handle";
119 case EREMOTE:
120 return "Object is remote";
121# if HAVE_WINSOCK2_H
122 /* WSA_INVALID_HANDLE maps to EBADF */
123 /* WSA_NOT_ENOUGH_MEMORY maps to ENOMEM */
124 /* WSA_INVALID_PARAMETER maps to EINVAL */
125 case WSA_OPERATION_ABORTED:
126 return "Overlapped operation aborted";
127 case WSA_IO_INCOMPLETE:
128 return "Overlapped I/O event object not in signaled state";
129 case WSA_IO_PENDING:
130 return "Overlapped operations will complete later";
131 /* WSAEINTR maps to EINTR */
132 /* WSAEBADF maps to EBADF */
133 /* WSAEACCES maps to EACCES */
134 /* WSAEFAULT maps to EFAULT */
135 /* WSAEINVAL maps to EINVAL */
136 /* WSAEMFILE maps to EMFILE */
137 /* WSAEWOULDBLOCK maps to EWOULDBLOCK */
138 /* WSAEINPROGRESS is EINPROGRESS */
139 /* WSAEALREADY is EALREADY */
140 /* WSAENOTSOCK is ENOTSOCK */
141 /* WSAEDESTADDRREQ is EDESTADDRREQ */
142 /* WSAEMSGSIZE is EMSGSIZE */
143 /* WSAEPROTOTYPE is EPROTOTYPE */
144 /* WSAENOPROTOOPT is ENOPROTOOPT */
145 /* WSAEPROTONOSUPPORT is EPROTONOSUPPORT */
146 /* WSAESOCKTNOSUPPORT is ESOCKTNOSUPPORT */
147 /* WSAEOPNOTSUPP is EOPNOTSUPP */
148 /* WSAEPFNOSUPPORT is EPFNOSUPPORT */
149 /* WSAEAFNOSUPPORT is EAFNOSUPPORT */
150 /* WSAEADDRINUSE is EADDRINUSE */
151 /* WSAEADDRNOTAVAIL is EADDRNOTAVAIL */
152 /* WSAENETDOWN is ENETDOWN */
153 /* WSAENETUNREACH is ENETUNREACH */
154 /* WSAENETRESET is ENETRESET */
155 /* WSAECONNABORTED is ECONNABORTED */
156 /* WSAECONNRESET is ECONNRESET */
157 /* WSAENOBUFS is ENOBUFS */
158 /* WSAEISCONN is EISCONN */
159 /* WSAENOTCONN is ENOTCONN */
160 /* WSAESHUTDOWN is ESHUTDOWN */
161 /* WSAETOOMANYREFS is ETOOMANYREFS */
162 /* WSAETIMEDOUT is ETIMEDOUT */
163 /* WSAECONNREFUSED is ECONNREFUSED */
164 /* WSAELOOP is ELOOP */
165 /* WSAENAMETOOLONG maps to ENAMETOOLONG */
166 /* WSAEHOSTDOWN is EHOSTDOWN */
167 /* WSAEHOSTUNREACH is EHOSTUNREACH */
168 /* WSAENOTEMPTY maps to ENOTEMPTY */
169 /* WSAEPROCLIM is EPROCLIM */
170 /* WSAEUSERS is EUSERS */
171 /* WSAEDQUOT is EDQUOT */
172 /* WSAESTALE is ESTALE */
173 /* WSAEREMOTE is EREMOTE */
174 case WSASYSNOTREADY:
175 return "Network subsystem is unavailable";
176 case WSAVERNOTSUPPORTED:
177 return "Winsock.dll version out of range";
178 case WSANOTINITIALISED:
179 return "Successful WSAStartup not yet performed";
180 case WSAEDISCON:
181 return "Graceful shutdown in progress";
182 case WSAENOMORE: case WSA_E_NO_MORE:
183 return "No more results";
184 case WSAECANCELLED: case WSA_E_CANCELLED:
185 return "Call was canceled";
186 case WSAEINVALIDPROCTABLE:
187 return "Procedure call table is invalid";
188 case WSAEINVALIDPROVIDER:
189 return "Service provider is invalid";
190 case WSAEPROVIDERFAILEDINIT:
191 return "Service provider failed to initialize";
192 case WSASYSCALLFAILURE:
193 return "System call failure";
194 case WSASERVICE_NOT_FOUND:
195 return "Service not found";
196 case WSATYPE_NOT_FOUND:
197 return "Class type not found";
198 case WSAEREFUSED:
199 return "Database query was refused";
200 case WSAHOST_NOT_FOUND:
201 return "Host not found";
202 case WSATRY_AGAIN:
203 return "Nonauthoritative host not found";
204 case WSANO_RECOVERY:
205 return "Nonrecoverable error";
206 case WSANO_DATA:
207 return "Valid name, no data record of requested type";
208 /* WSA_QOS_* omitted */
209# endif
210# endif
211
212# if GNULIB_defined_ENOMSG
213 case ENOMSG:
214 return "No message of desired type";
215# endif
216
217# if GNULIB_defined_EIDRM
218 case EIDRM:
219 return "Identifier removed";
220# endif
221
222# if GNULIB_defined_ENOLINK
223 case ENOLINK:
224 return "Link has been severed";
225# endif
226
227# if GNULIB_defined_EPROTO
228 case EPROTO:
229 return "Protocol error";
230# endif
231
232# if GNULIB_defined_EMULTIHOP
233 case EMULTIHOP:
234 return "Multihop attempted";
235# endif
236
237# if GNULIB_defined_EBADMSG
238 case EBADMSG:
239 return "Bad message";
240# endif
241
242# if GNULIB_defined_EOVERFLOW
243 case EOVERFLOW:
244 return "Value too large for defined data type";
245# endif
246
247# if GNULIB_defined_ENOTSUP
248 case ENOTSUP:
249 return "Not supported";
250# endif
251
252# if GNULIB_defined_
253 case ECANCELED:
254 return "Operation canceled";
255# endif
44 } 256 }
45 257
46 return result; 258 {
259 char *result = strerror (n);
260
261 if (result == NULL || result[0] == '\0')
262 {
263 static char const fmt[] = "Unknown error (%d)";
264 static char mesg[sizeof fmt + INT_STRLEN_BOUND (n)];
265 sprintf (mesg, fmt, n);
266 return mesg;
267 }
268
269 return result;
270 }
47} 271}
48 272
49#endif 273#endif
diff --git a/gl/string.in.h b/gl/string.in.h
index 5c7597c..f021a3e 100644
--- a/gl/string.in.h
+++ b/gl/string.in.h
@@ -18,6 +18,10 @@
18 18
19#ifndef _GL_STRING_H 19#ifndef _GL_STRING_H
20 20
21#if __GNUC__ >= 3
22@PRAGMA_SYSTEM_HEADER@
23#endif
24
21/* The include_next requires a split double-inclusion guard. */ 25/* The include_next requires a split double-inclusion guard. */
22#@INCLUDE_NEXT@ @NEXT_STRING_H@ 26#@INCLUDE_NEXT@ @NEXT_STRING_H@
23 27
@@ -93,6 +97,22 @@ extern void *memrchr (void const *, int, size_t)
93 memrchr (a, b, c)) 97 memrchr (a, b, c))
94#endif 98#endif
95 99
100/* Find the first occurrence of C in S. More efficient than
101 memchr(S,C,N), at the expense of undefined behavior if C does not
102 occur within N bytes. */
103#if @GNULIB_RAWMEMCHR@
104# if ! @HAVE_RAWMEMCHR@
105extern void *rawmemchr (void const *__s, int __c_in)
106 __attribute__ ((__pure__));
107# endif
108#elif defined GNULIB_POSIXCHECK
109# undef rawmemchr
110# define rawmemchr(a,b) \
111 (GL_LINK_WARNING ("rawmemchr is unportable - " \
112 "use gnulib module rawmemchr for portability"), \
113 rawmemchr (a, b))
114#endif
115
96/* Copy SRC to DST, returning the address of the terminating '\0' in DST. */ 116/* Copy SRC to DST, returning the address of the terminating '\0' in DST. */
97#if @GNULIB_STPCPY@ 117#if @GNULIB_STPCPY@
98# if ! @HAVE_STPCPY@ 118# if ! @HAVE_STPCPY@
@@ -149,7 +169,11 @@ extern char *strchrnul (char const *__s, int __c_in)
149 169
150/* Duplicate S, returning an identical malloc'd string. */ 170/* Duplicate S, returning an identical malloc'd string. */
151#if @GNULIB_STRDUP@ 171#if @GNULIB_STRDUP@
152# if ! @HAVE_DECL_STRDUP@ && ! defined strdup 172# if @REPLACE_STRDUP@
173# undef strdup
174# define strdup rpl_strdup
175# endif
176# if !(@HAVE_DECL_STRDUP@ || defined strdup) || @REPLACE_STRDUP@
153extern char *strdup (char const *__s); 177extern char *strdup (char const *__s);
154# endif 178# endif
155#elif defined GNULIB_POSIXCHECK 179#elif defined GNULIB_POSIXCHECK
@@ -560,6 +584,18 @@ extern char *strsignal (int __sig);
560 strsignal (a)) 584 strsignal (a))
561#endif 585#endif
562 586
587#if @GNULIB_STRVERSCMP@
588# if !@HAVE_STRVERSCMP@
589extern int strverscmp (const char *, const char *);
590# endif
591#elif defined GNULIB_POSIXCHECK
592# undef strverscmp
593# define strverscmp(a, b) \
594 (GL_LINK_WARNING ("strverscmp is unportable - " \
595 "use gnulib module strverscmp for portability"), \
596 strverscmp (a, b))
597#endif
598
563 599
564#ifdef __cplusplus 600#ifdef __cplusplus
565} 601}
diff --git a/gl/sys_socket.in.h b/gl/sys_socket.in.h
index 5e0b097..5d9b3cd 100644
--- a/gl/sys_socket.in.h
+++ b/gl/sys_socket.in.h
@@ -1,5 +1,6 @@
1/* Provide a sys/socket header file for systems lacking it (read: MinGW). 1/* Provide a sys/socket header file for systems lacking it (read: MinGW)
2 Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc. 2 and for systems where it is incomplete.
3 Copyright (C) 2005-2008 Free Software Foundation, Inc.
3 Written by Simon Josefsson. 4 Written by Simon Josefsson.
4 5
5 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
@@ -16,8 +17,9 @@
16 along with this program; if not, write to the Free Software Foundation, 17 along with this program; if not, write to the Free Software Foundation,
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ 18 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 19
19/* This file is supposed to be used on platforms that lack <sys/socket.h> 20/* This file is supposed to be used on platforms that lack <sys/socket.h>,
20 and on platforms where <sys/socket.h> cannot be included standalone. 21 on platforms where <sys/socket.h> cannot be included standalone, and on
22 platforms where <sys/socket.h> does not provide all necessary definitions.
21 It is intended to provide definitions and prototypes needed by an 23 It is intended to provide definitions and prototypes needed by an
22 application. */ 24 application. */
23 25
@@ -25,6 +27,10 @@
25 27
26#if @HAVE_SYS_SOCKET_H@ 28#if @HAVE_SYS_SOCKET_H@
27 29
30# if __GNUC__ >= 3
31@PRAGMA_SYSTEM_HEADER@
32# endif
33
28/* On many platforms, <sys/socket.h> assumes prior inclusion of 34/* On many platforms, <sys/socket.h> assumes prior inclusion of
29 <sys/types.h>. */ 35 <sys/types.h>. */
30# include <sys/types.h> 36# include <sys/types.h>
@@ -37,7 +43,26 @@
37#ifndef _GL_SYS_SOCKET_H 43#ifndef _GL_SYS_SOCKET_H
38#define _GL_SYS_SOCKET_H 44#define _GL_SYS_SOCKET_H
39 45
40#if !@HAVE_SYS_SOCKET_H@ 46#if @HAVE_SYS_SOCKET_H@
47
48/* A platform that has <sys/socket.h>. */
49
50/* For shutdown(). */
51# if !defined SHUT_RD
52# define SHUT_RD 0
53# endif
54# if !defined SHUT_WR
55# define SHUT_WR 1
56# endif
57# if !defined SHUT_RDWR
58# define SHUT_RDWR 2
59# endif
60
61#else
62
63# ifdef __CYGWIN__
64# error "Cygwin does have a sys/socket.h, doesn't it?!?"
65# endif
41 66
42/* A platform that lacks <sys/socket.h>. 67/* A platform that lacks <sys/socket.h>.
43 68
@@ -75,14 +100,301 @@
75# define SHUT_RDWR SD_BOTH 100# define SHUT_RDWR SD_BOTH
76# endif 101# endif
77 102
78# if defined _WIN32 || defined __WIN32__ 103/* The definition of GL_LINK_WARNING is copied here. */
79# define ENOTSOCK WSAENOTSOCK 104
80# define EADDRINUSE WSAEADDRINUSE 105# if @HAVE_WINSOCK2_H@
81# define ENETRESET WSAENETRESET 106/* Include headers needed by the emulation code. */
82# define ECONNABORTED WSAECONNABORTED 107# include <sys/types.h>
83# define ECONNRESET WSAECONNRESET 108# include <io.h>
84# define ENOTCONN WSAENOTCONN 109
85# define ESHUTDOWN WSAESHUTDOWN 110typedef int socklen_t;
111
112# endif
113
114# ifdef __cplusplus
115extern "C" {
116# endif
117
118# if @HAVE_WINSOCK2_H@
119
120/* Re-define FD_ISSET to avoid a WSA call while we are not using
121 network sockets. */
122static inline int
123rpl_fd_isset (SOCKET fd, fd_set * set)
124{
125 u_int i;
126 if (set == NULL)
127 return 0;
128
129 for (i = 0; i < set->fd_count; i++)
130 if (set->fd_array[i] == fd)
131 return 1;
132
133 return 0;
134}
135
136# undef FD_ISSET
137# define FD_ISSET(fd, set) rpl_fd_isset(fd, set)
138
139# endif
140
141/* Wrap everything else to use libc file descriptors for sockets. */
142
143# if @HAVE_WINSOCK2_H@ && !defined _GL_UNISTD_H
144# undef close
145# define close close_used_without_including_unistd_h
146# endif
147
148# if @HAVE_WINSOCK2_H@ && !defined _GL_UNISTD_H
149# undef gethostname
150# define gethostname gethostname_used_without_including_unistd_h
151# endif
152
153# if @GNULIB_SOCKET@
154# if @HAVE_WINSOCK2_H@
155# undef socket
156# define socket rpl_socket
157extern int rpl_socket (int, int, int protocol);
158# endif
159# elif @HAVE_WINSOCK2_H@
160# undef socket
161# define socket socket_used_without_requesting_gnulib_module_socket
162# elif defined GNULIB_POSIXCHECK
163# undef socket
164# define socket(d,t,p) \
165 (GL_LINK_WARNING ("socket is not always POSIX compliant - " \
166 "use gnulib module socket for portability"), \
167 socket (d, t, p))
168# endif
169
170# if @GNULIB_CONNECT@
171# if @HAVE_WINSOCK2_H@
172# undef connect
173# define connect rpl_connect
174extern int rpl_connect (int, struct sockaddr *, int);
175# endif
176# elif @HAVE_WINSOCK2_H@
177# undef connect
178# define connect socket_used_without_requesting_gnulib_module_connect
179# elif defined GNULIB_POSIXCHECK
180# undef connect
181# define connect(s,a,l) \
182 (GL_LINK_WARNING ("connect is not always POSIX compliant - " \
183 "use gnulib module connect for portability"), \
184 connect (s, a, l))
185# endif
186
187# if @GNULIB_ACCEPT@
188# if @HAVE_WINSOCK2_H@
189# undef accept
190# define accept rpl_accept
191extern int rpl_accept (int, struct sockaddr *, int *);
192# endif
193# elif @HAVE_WINSOCK2_H@
194# undef accept
195# define accept accept_used_without_requesting_gnulib_module_accept
196# elif defined GNULIB_POSIXCHECK
197# undef accept
198# define accept(s,a,l) \
199 (GL_LINK_WARNING ("accept is not always POSIX compliant - " \
200 "use gnulib module accept for portability"), \
201 accept (s, a, l))
202# endif
203
204# if @GNULIB_BIND@
205# if @HAVE_WINSOCK2_H@
206# undef bind
207# define bind rpl_bind
208extern int rpl_bind (int, struct sockaddr *, int);
209# endif
210# elif @HAVE_WINSOCK2_H@
211# undef bind
212# define bind bind_used_without_requesting_gnulib_module_bind
213# elif defined GNULIB_POSIXCHECK
214# undef bind
215# define bind(s,a,l) \
216 (GL_LINK_WARNING ("bind is not always POSIX compliant - " \
217 "use gnulib module bind for portability"), \
218 bind (s, a, l))
219# endif
220
221# if @GNULIB_GETPEERNAME@
222# if @HAVE_WINSOCK2_H@
223# undef getpeername
224# define getpeername rpl_getpeername
225extern int rpl_getpeername (int, struct sockaddr *, int *);
226# endif
227# elif @HAVE_WINSOCK2_H@
228# undef getpeername
229# define getpeername getpeername_used_without_requesting_gnulib_module_getpeername
230# elif defined GNULIB_POSIXCHECK
231# undef getpeername
232# define getpeername(s,a,l) \
233 (GL_LINK_WARNING ("getpeername is not always POSIX compliant - " \
234 "use gnulib module getpeername for portability"), \
235 getpeername (s, a, l))
236# endif
237
238# if @GNULIB_GETSOCKNAME@
239# if @HAVE_WINSOCK2_H@
240# undef getsockname
241# define getsockname rpl_getsockname
242extern int rpl_getsockname (int, struct sockaddr *, int *);
243# endif
244# elif @HAVE_WINSOCK2_H@
245# undef getsockname
246# define getsockname getsockname_used_without_requesting_gnulib_module_getsockname
247# elif defined GNULIB_POSIXCHECK
248# undef getsockname
249# define getsockname(s,a,l) \
250 (GL_LINK_WARNING ("getsockname is not always POSIX compliant - " \
251 "use gnulib module getsockname for portability"), \
252 getsockname (s, a, l))
253# endif
254
255# if @GNULIB_GETSOCKOPT@
256# if @HAVE_WINSOCK2_H@
257# undef getsockopt
258# define getsockopt rpl_getsockopt
259extern int rpl_getsockopt (int, int, int, void *, int *);
260# endif
261# elif @HAVE_WINSOCK2_H@
262# undef getsockopt
263# define getsockopt getsockopt_used_without_requesting_gnulib_module_getsockopt
264# elif defined GNULIB_POSIXCHECK
265# undef getsockopt
266# define getsockopt(s,lvl,o,v,l) \
267 (GL_LINK_WARNING ("getsockopt is not always POSIX compliant - " \
268 "use gnulib module getsockopt for portability"), \
269 getsockopt (s, lvl, o, v, l))
270# endif
271
272# if @GNULIB_LISTEN@
273# if @HAVE_WINSOCK2_H@
274# undef listen
275# define listen rpl_listen
276extern int rpl_listen (int, int);
277# endif
278# elif @HAVE_WINSOCK2_H@
279# undef listen
280# define listen listen_used_without_requesting_gnulib_module_listen
281# elif defined GNULIB_POSIXCHECK
282# undef listen
283# define listen(s,b) \
284 (GL_LINK_WARNING ("listen is not always POSIX compliant - " \
285 "use gnulib module listen for portability"), \
286 listen (s, b))
287# endif
288
289# if @GNULIB_RECV@
290# if @HAVE_WINSOCK2_H@
291# undef recv
292# define recv rpl_recv
293extern int rpl_recv (int, void *, int, int);
294# endif
295# elif @HAVE_WINSOCK2_H@
296# undef recv
297# define recv recv_used_without_requesting_gnulib_module_recv
298# elif defined GNULIB_POSIXCHECK
299# undef recv
300# define recv(s,b,n,f) \
301 (GL_LINK_WARNING ("recv is not always POSIX compliant - " \
302 "use gnulib module recv for portability"), \
303 recv (s, b, n, f))
304# endif
305
306# if @GNULIB_SEND@
307# if @HAVE_WINSOCK2_H@
308# undef send
309# define send rpl_send
310extern int rpl_send (int, const void *, int, int);
311# endif
312# elif @HAVE_WINSOCK2_H@
313# undef send
314# define send send_used_without_requesting_gnulib_module_send
315# elif defined GNULIB_POSIXCHECK
316# undef send
317# define send(s,b,n,f) \
318 (GL_LINK_WARNING ("send is not always POSIX compliant - " \
319 "use gnulib module send for portability"), \
320 send (s, b, n, f))
321# endif
322
323# if @GNULIB_RECVFROM@
324# if @HAVE_WINSOCK2_H@
325# undef recvfrom
326# define recvfrom rpl_recvfrom
327extern int rpl_recvfrom (int, void *, int, int, struct sockaddr *, int *);
328# endif
329# elif @HAVE_WINSOCK2_H@
330# undef recvfrom
331# define recvfrom recvfrom_used_without_requesting_gnulib_module_recvfrom
332# elif defined GNULIB_POSIXCHECK
333# undef recvfrom
334# define recvfrom(s,b,n,f,a,l) \
335 (GL_LINK_WARNING ("recvfrom is not always POSIX compliant - " \
336 "use gnulib module recvfrom for portability"), \
337 recvfrom (s, b, n, f, a, l))
338# endif
339
340# if @GNULIB_SENDTO@
341# if @HAVE_WINSOCK2_H@
342# undef sendto
343# define sendto rpl_sendto
344extern int rpl_sendto (int, const void *, int, int, struct sockaddr *, int);
345# endif
346# elif @HAVE_WINSOCK2_H@
347# undef sendto
348# define sendto sendto_used_without_requesting_gnulib_module_sendto
349# elif defined GNULIB_POSIXCHECK
350# undef sendto
351# define sendto(s,b,n,f,a,l) \
352 (GL_LINK_WARNING ("sendto is not always POSIX compliant - " \
353 "use gnulib module sendto for portability"), \
354 sendto (s, b, n, f, a, l))
355# endif
356
357# if @GNULIB_SETSOCKOPT@
358# if @HAVE_WINSOCK2_H@
359# undef setsockopt
360# define setsockopt rpl_setsockopt
361extern int rpl_setsockopt (int, int, int, const void *, int);
362# endif
363# elif @HAVE_WINSOCK2_H@
364# undef setsockopt
365# define setsockopt setsockopt_used_without_requesting_gnulib_module_setsockopt
366# elif defined GNULIB_POSIXCHECK
367# undef setsockopt
368# define setsockopt(s,lvl,o,v,l) \
369 (GL_LINK_WARNING ("setsockopt is not always POSIX compliant - " \
370 "use gnulib module setsockopt for portability"), \
371 setsockopt (s, lvl, o, v, l))
372# endif
373
374# if @GNULIB_SHUTDOWN@
375# if @HAVE_WINSOCK2_H@
376# undef shutdown
377# define shutdown rpl_shutdown
378extern int rpl_shutdown (int, int);
379# endif
380# elif @HAVE_WINSOCK2_H@
381# undef shutdown
382# define shutdown shutdown_used_without_requesting_gnulib_module_shutdown
383# elif defined GNULIB_POSIXCHECK
384# undef shutdown
385# define shutdown(s,h) \
386 (GL_LINK_WARNING ("shutdown is not always POSIX compliant - " \
387 "use gnulib module shutdown for portability"), \
388 shutdown (s, h))
389# endif
390
391# if @HAVE_WINSOCK2_H@
392# undef select
393# define select select_used_without_including_sys_select_h
394# endif
395
396# ifdef __cplusplus
397}
86# endif 398# endif
87 399
88#endif /* HAVE_SYS_SOCKET_H */ 400#endif /* HAVE_SYS_SOCKET_H */
diff --git a/gl/unistd.in.h b/gl/unistd.in.h
index a5dc04c..1b2f80e 100644
--- a/gl/unistd.in.h
+++ b/gl/unistd.in.h
@@ -1,5 +1,5 @@
1/* Substitute for and wrapper around <unistd.h>. 1/* Substitute for and wrapper around <unistd.h>.
2 Copyright (C) 2004-2007 Free Software Foundation, Inc. 2 Copyright (C) 2003-2008 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
@@ -17,6 +17,10 @@
17 17
18#ifndef _GL_UNISTD_H 18#ifndef _GL_UNISTD_H
19 19
20#if __GNUC__ >= 3
21@PRAGMA_SYSTEM_HEADER@
22#endif
23
20/* The include_next requires a split double-inclusion guard. */ 24/* The include_next requires a split double-inclusion guard. */
21#if @HAVE_UNISTD_H@ 25#if @HAVE_UNISTD_H@
22# @INCLUDE_NEXT@ @NEXT_UNISTD_H@ 26# @INCLUDE_NEXT@ @NEXT_UNISTD_H@
@@ -31,8 +35,55 @@
31#endif 35#endif
32 36
33/* mingw fails to declare _exit in <unistd.h>. */ 37/* mingw fails to declare _exit in <unistd.h>. */
38/* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>. */
34#include <stdlib.h> 39#include <stdlib.h>
35 40
41#if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
42/* Get ssize_t. */
43# include <sys/types.h>
44#endif
45
46#if @GNULIB_GETHOSTNAME@
47/* Get all possible declarations of gethostname(). */
48# if @UNISTD_H_HAVE_WINSOCK2_H@
49# include <winsock2.h>
50# if !defined _GL_SYS_SOCKET_H
51# undef socket
52# define socket socket_used_without_including_sys_socket_h
53# undef connect
54# define connect connect_used_without_including_sys_socket_h
55# undef accept
56# define accept accept_used_without_including_sys_socket_h
57# undef bind
58# define bind bind_used_without_including_sys_socket_h
59# undef getpeername
60# define getpeername getpeername_used_without_including_sys_socket_h
61# undef getsockname
62# define getsockname getsockname_used_without_including_sys_socket_h
63# undef getsockopt
64# define getsockopt getsockopt_used_without_including_sys_socket_h
65# undef listen
66# define listen listen_used_without_including_sys_socket_h
67# undef recv
68# define recv recv_used_without_including_sys_socket_h
69# undef send
70# define send send_used_without_including_sys_socket_h
71# undef recvfrom
72# define recvfrom recvfrom_used_without_including_sys_socket_h
73# undef sendto
74# define sendto sendto_used_without_including_sys_socket_h
75# undef setsockopt
76# define setsockopt setsockopt_used_without_including_sys_socket_h
77# undef shutdown
78# define shutdown shutdown_used_without_including_sys_socket_h
79# endif
80# if !defined _GL_SYS_SELECT_H
81# undef select
82# define select select_used_without_including_sys_select_h
83# endif
84# endif
85#endif
86
36/* The definition of GL_LINK_WARNING is copied here. */ 87/* The definition of GL_LINK_WARNING is copied here. */
37 88
38 89
@@ -68,6 +119,29 @@ extern int chown (const char *file, uid_t uid, gid_t gid);
68#endif 119#endif
69 120
70 121
122#if @GNULIB_CLOSE@
123# if @UNISTD_H_HAVE_WINSOCK2_H@
124/* Need a gnulib internal function. */
125# define HAVE__GL_CLOSE_FD_MAYBE_SOCKET 1
126# endif
127# if @REPLACE_CLOSE@
128/* Automatically included by modules that need a replacement for close. */
129# undef close
130# define close rpl_close
131extern int close (int);
132# endif
133#elif @UNISTD_H_HAVE_WINSOCK2_H@
134# undef close
135# define close close_used_without_requesting_gnulib_module_close
136#elif defined GNULIB_POSIXCHECK
137# undef close
138# define close(f) \
139 (GL_LINK_WARNING ("close does not portably work on sockets - " \
140 "use gnulib module close for portability"), \
141 close (f))
142#endif
143
144
71#if @GNULIB_DUP2@ 145#if @GNULIB_DUP2@
72# if !@HAVE_DUP2@ 146# if !@HAVE_DUP2@
73/* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if 147/* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
@@ -86,6 +160,41 @@ extern int dup2 (int oldfd, int newfd);
86#endif 160#endif
87 161
88 162
163#if @GNULIB_ENVIRON@
164# if !@HAVE_DECL_ENVIRON@
165/* Set of environment variables and values. An array of strings of the form
166 "VARIABLE=VALUE", terminated with a NULL. */
167# if defined __APPLE__ && defined __MACH__
168# include <crt_externs.h>
169# define environ (*_NSGetEnviron ())
170# else
171extern char **environ;
172# endif
173# endif
174#elif defined GNULIB_POSIXCHECK
175# undef environ
176# define environ \
177 (GL_LINK_WARNING ("environ is unportable - " \
178 "use gnulib module environ for portability"), \
179 environ)
180#endif
181
182
183#if @GNULIB_EUIDACCESS@
184# if !@HAVE_EUIDACCESS@
185/* Like access(), except that is uses the effective user id and group id of
186 the current process. */
187extern int euidaccess (const char *filename, int mode);
188# endif
189#elif defined GNULIB_POSIXCHECK
190# undef euidaccess
191# define euidaccess(f,m) \
192 (GL_LINK_WARNING ("euidaccess is unportable - " \
193 "use gnulib module euidaccess for portability"), \
194 euidaccess (f, m))
195#endif
196
197
89#if @GNULIB_FCHDIR@ 198#if @GNULIB_FCHDIR@
90# if @REPLACE_FCHDIR@ 199# if @REPLACE_FCHDIR@
91 200
@@ -96,8 +205,6 @@ extern int dup2 (int oldfd, int newfd);
96 <http://www.opengroup.org/susv3xsh/fchdir.html>. */ 205 <http://www.opengroup.org/susv3xsh/fchdir.html>. */
97extern int fchdir (int /*fd*/); 206extern int fchdir (int /*fd*/);
98 207
99# define close rpl_close
100extern int close (int);
101# define dup rpl_dup 208# define dup rpl_dup
102extern int dup (int); 209extern int dup (int);
103# define dup2 rpl_dup2 210# define dup2 rpl_dup2
@@ -113,6 +220,23 @@ extern int dup2 (int, int);
113#endif 220#endif
114 221
115 222
223#if @GNULIB_FSYNC@
224/* Synchronize changes to a file.
225 Return 0 if successful, otherwise -1 and errno set.
226 See POSIX:2001 specification
227 <http://www.opengroup.org/susv3xsh/fsync.html>. */
228# if !@HAVE_FSYNC@
229extern int fsync (int fd);
230# endif
231#elif defined GNULIB_POSIXCHECK
232# undef fsync
233# define fsync(fd) \
234 (GL_LINK_WARNING ("fsync is unportable - " \
235 "use gnulib module fsync for portability"), \
236 fsync (fd))
237#endif
238
239
116#if @GNULIB_FTRUNCATE@ 240#if @GNULIB_FTRUNCATE@
117# if !@HAVE_FTRUNCATE@ 241# if !@HAVE_FTRUNCATE@
118/* Change the size of the file to which FD is opened to become equal to LENGTH. 242/* Change the size of the file to which FD is opened to become equal to LENGTH.
@@ -157,6 +281,70 @@ extern char * getcwd (char *buf, size_t size);
157#endif 281#endif
158 282
159 283
284#if @GNULIB_GETDOMAINNAME@
285/* Return the NIS domain name of the machine.
286 WARNING! The NIS domain name is unrelated to the fully qualified host name
287 of the machine. It is also unrelated to email addresses.
288 WARNING! The NIS domain name is usually the empty string or "(none)" when
289 not using NIS.
290
291 Put up to LEN bytes of the NIS domain name into NAME.
292 Null terminate it if the name is shorter than LEN.
293 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
294 Return 0 if successful, otherwise set errno and return -1. */
295# if !@HAVE_GETDOMAINNAME@
296extern int getdomainname(char *name, size_t len);
297# endif
298#elif defined GNULIB_POSIXCHECK
299# undef getdomainname
300# define getdomainname(n,l) \
301 (GL_LINK_WARNING ("getdomainname is unportable - " \
302 "use gnulib module getdomainname for portability"), \
303 getdomainname (n, l))
304#endif
305
306
307#if @GNULIB_GETDTABLESIZE@
308# if !@HAVE_GETDTABLESIZE@
309/* Return the maximum number of file descriptors in the current process. */
310extern int getdtablesize (void);
311# endif
312#elif defined GNULIB_POSIXCHECK
313# undef getdtablesize
314# define getdtablesize() \
315 (GL_LINK_WARNING ("getdtablesize is unportable - " \
316 "use gnulib module getdtablesize for portability"), \
317 getdtablesize ())
318#endif
319
320
321#if @GNULIB_GETHOSTNAME@
322/* Return the standard host name of the machine.
323 WARNING! The host name may or may not be fully qualified.
324
325 Put up to LEN bytes of the host name into NAME.
326 Null terminate it if the name is shorter than LEN.
327 If the host name is longer than LEN, set errno = EINVAL and return -1.
328 Return 0 if successful, otherwise set errno and return -1. */
329# if @UNISTD_H_HAVE_WINSOCK2_H@
330# undef gethostname
331# define gethostname rpl_gethostname
332# endif
333# if @UNISTD_H_HAVE_WINSOCK2_H@ || !@HAVE_GETHOSTNAME@
334extern int gethostname(char *name, size_t len);
335# endif
336#elif @UNISTD_H_HAVE_WINSOCK2_H@
337# undef gethostname
338# define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
339#elif defined GNULIB_POSIXCHECK
340# undef gethostname
341# define gethostname(n,l) \
342 (GL_LINK_WARNING ("gethostname is unportable - " \
343 "use gnulib module gethostname for portability"), \
344 gethostname (n, l))
345#endif
346
347
160#if @GNULIB_GETLOGIN_R@ 348#if @GNULIB_GETLOGIN_R@
161/* Copies the user's login name to NAME. 349/* Copies the user's login name to NAME.
162 The array pointed to by NAME has room for SIZE bytes. 350 The array pointed to by NAME has room for SIZE bytes.
@@ -238,6 +426,36 @@ extern int getpagesize (void);
238#endif 426#endif
239 427
240 428
429#if @GNULIB_GETUSERSHELL@
430# if !@HAVE_GETUSERSHELL@
431/* Return the next valid login shell on the system, or NULL when the end of
432 the list has been reached. */
433extern char *getusershell (void);
434/* Rewind to pointer that is advanced at each getusershell() call. */
435extern void setusershell (void);
436/* Free the pointer that is advanced at each getusershell() call and
437 associated resources. */
438extern void endusershell (void);
439# endif
440#elif defined GNULIB_POSIXCHECK
441# undef getusershell
442# define getusershell() \
443 (GL_LINK_WARNING ("getusershell is unportable - " \
444 "use gnulib module getusershell for portability"), \
445 getusershell ())
446# undef setusershell
447# define setusershell() \
448 (GL_LINK_WARNING ("setusershell is unportable - " \
449 "use gnulib module getusershell for portability"), \
450 setusershell ())
451# undef endusershell
452# define endusershell() \
453 (GL_LINK_WARNING ("endusershell is unportable - " \
454 "use gnulib module getusershell for portability"), \
455 endusershell ())
456#endif
457
458
241#if @GNULIB_LCHOWN@ 459#if @GNULIB_LCHOWN@
242# if @REPLACE_LCHOWN@ 460# if @REPLACE_LCHOWN@
243/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE 461/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
@@ -311,6 +529,22 @@ extern unsigned int sleep (unsigned int n);
311#endif 529#endif
312 530
313 531
532#if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
533/* Write up to COUNT bytes starting at BUF to file descriptor FD.
534 See the POSIX:2001 specification
535 <http://www.opengroup.org/susv3xsh/write.html>. */
536# undef write
537# define write rpl_write
538extern ssize_t write (int fd, const void *buf, size_t count);
539#endif
540
541
542#ifdef FCHDIR_REPLACEMENT
543/* gnulib internal function. */
544extern void _gl_unregister_fd (int fd);
545#endif
546
547
314#ifdef __cplusplus 548#ifdef __cplusplus
315} 549}
316#endif 550#endif
diff --git a/gl/vasnprintf.c b/gl/vasnprintf.c
index d5b4028..93aef6f 100644
--- a/gl/vasnprintf.c
+++ b/gl/vasnprintf.c
@@ -95,7 +95,7 @@
95 95
96#if (NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && !defined IN_LIBINTL 96#if (NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && !defined IN_LIBINTL
97# include <math.h> 97# include <math.h>
98# include "isnand.h" 98# include "isnand-nolibm.h"
99#endif 99#endif
100 100
101#if (NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE) && !defined IN_LIBINTL 101#if (NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE) && !defined IN_LIBINTL
@@ -106,7 +106,7 @@
106 106
107#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL 107#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL
108# include <math.h> 108# include <math.h>
109# include "isnand.h" 109# include "isnand-nolibm.h"
110# include "printf-frexp.h" 110# include "printf-frexp.h"
111#endif 111#endif
112 112
@@ -117,11 +117,6 @@
117# include "fpucw.h" 117# include "fpucw.h"
118#endif 118#endif
119 119
120/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */
121#ifndef EOVERFLOW
122# define EOVERFLOW E2BIG
123#endif
124
125#if HAVE_WCHAR_T 120#if HAVE_WCHAR_T
126# if HAVE_WCSLEN 121# if HAVE_WCSLEN
127# define local_wcslen wcslen 122# define local_wcslen wcslen
@@ -182,10 +177,12 @@ local_wcslen (const wchar_t *s)
182# endif 177# endif
183#else 178#else
184 /* TCHAR_T is char. */ 179 /* TCHAR_T is char. */
185# /* Use snprintf if it exists under the name 'snprintf' or '_snprintf'. 180 /* Use snprintf if it exists under the name 'snprintf' or '_snprintf'.
186 But don't use it on BeOS, since BeOS snprintf produces no output if the 181 But don't use it on BeOS, since BeOS snprintf produces no output if the
187 size argument is >= 0x3000000. */ 182 size argument is >= 0x3000000.
188# if (HAVE_DECL__SNPRINTF || HAVE_SNPRINTF) && !defined __BEOS__ 183 Also don't use it on Linux libc5, since there snprintf with size = 1
184 writes any output without bounds, like sprintf. */
185# if (HAVE_DECL__SNPRINTF || HAVE_SNPRINTF) && !defined __BEOS__ && !(__GNU_LIBRARY__ == 1)
189# define USE_SNPRINTF 1 186# define USE_SNPRINTF 1
190# else 187# else
191# define USE_SNPRINTF 0 188# define USE_SNPRINTF 0
@@ -203,7 +200,22 @@ local_wcslen (const wchar_t *s)
203/* Here we need to call the native sprintf, not rpl_sprintf. */ 200/* Here we need to call the native sprintf, not rpl_sprintf. */
204#undef sprintf 201#undef sprintf
205 202
206#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && !defined IN_LIBINTL 203/* GCC >= 4.0 with -Wall emits unjustified "... may be used uninitialized"
204 warnings in this file. Use -Dlint to suppress them. */
205#ifdef lint
206# define IF_LINT(Code) Code
207#else
208# define IF_LINT(Code) /* empty */
209#endif
210
211/* Avoid some warnings from "gcc -Wshadow".
212 This file doesn't use the exp() and remainder() functions. */
213#undef exp
214#define exp expo
215#undef remainder
216#define remainder rem
217
218#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && !defined IN_LIBINTL
207/* Determine the decimal-point character according to the current locale. */ 219/* Determine the decimal-point character according to the current locale. */
208# ifndef decimal_point_char_defined 220# ifndef decimal_point_char_defined
209# define decimal_point_char_defined 1 221# define decimal_point_char_defined 1
@@ -243,11 +255,11 @@ is_infinite_or_zero (double x)
243 255
244#if NEED_PRINTF_INFINITE_LONG_DOUBLE && !NEED_PRINTF_LONG_DOUBLE && !defined IN_LIBINTL 256#if NEED_PRINTF_INFINITE_LONG_DOUBLE && !NEED_PRINTF_LONG_DOUBLE && !defined IN_LIBINTL
245 257
246/* Equivalent to !isfinite(x), but does not require libm. */ 258/* Equivalent to !isfinite(x) || x == 0, but does not require libm. */
247static int 259static int
248is_infinitel (long double x) 260is_infinite_or_zerol (long double x)
249{ 261{
250 return isnanl (x) || (x + x == x && x != 0.0L); 262 return isnanl (x) || x + x == x;
251} 263}
252 264
253#endif 265#endif
@@ -1201,7 +1213,7 @@ scale10_round_decimal_decoded (int e, mpn_t m, void *memory, int n)
1201static char * 1213static char *
1202scale10_round_decimal_long_double (long double x, int n) 1214scale10_round_decimal_long_double (long double x, int n)
1203{ 1215{
1204 int e; 1216 int e IF_LINT(= 0);
1205 mpn_t m; 1217 mpn_t m;
1206 void *memory = decode_long_double (x, &e, &m); 1218 void *memory = decode_long_double (x, &e, &m);
1207 return scale10_round_decimal_decoded (e, m, memory, n); 1219 return scale10_round_decimal_decoded (e, m, memory, n);
@@ -1219,7 +1231,7 @@ scale10_round_decimal_long_double (long double x, int n)
1219static char * 1231static char *
1220scale10_round_decimal_double (double x, int n) 1232scale10_round_decimal_double (double x, int n)
1221{ 1233{
1222 int e; 1234 int e IF_LINT(= 0);
1223 mpn_t m; 1235 mpn_t m;
1224 void *memory = decode_double (x, &e, &m); 1236 void *memory = decode_double (x, &e, &m);
1225 return scale10_round_decimal_decoded (e, m, memory, n); 1237 return scale10_round_decimal_decoded (e, m, memory, n);
@@ -1306,9 +1318,9 @@ floorlog10l (long double x)
1306 } 1318 }
1307 /* Now 0.95 <= z <= 1.01. */ 1319 /* Now 0.95 <= z <= 1.01. */
1308 z = 1 - z; 1320 z = 1 - z;
1309 /* log(1-z) = - z - z^2/2 - z^3/3 - z^4/4 - ... 1321 /* log2(1-z) = 1/log(2) * (- z - z^2/2 - z^3/3 - z^4/4 - ...)
1310 Four terms are enough to get an approximation with error < 10^-7. */ 1322 Four terms are enough to get an approximation with error < 10^-7. */
1311 l -= z * (1.0 + z * (0.5 + z * ((1.0 / 3) + z * 0.25))); 1323 l -= 1.4426950408889634074 * z * (1.0 + z * (0.5 + z * ((1.0 / 3) + z * 0.25)));
1312 /* Finally multiply with log(2)/log(10), yields an approximation for 1324 /* Finally multiply with log(2)/log(10), yields an approximation for
1313 log10(x). */ 1325 log10(x). */
1314 l *= 0.30102999566398119523; 1326 l *= 0.30102999566398119523;
@@ -1397,9 +1409,9 @@ floorlog10 (double x)
1397 } 1409 }
1398 /* Now 0.95 <= z <= 1.01. */ 1410 /* Now 0.95 <= z <= 1.01. */
1399 z = 1 - z; 1411 z = 1 - z;
1400 /* log(1-z) = - z - z^2/2 - z^3/3 - z^4/4 - ... 1412 /* log2(1-z) = 1/log(2) * (- z - z^2/2 - z^3/3 - z^4/4 - ...)
1401 Four terms are enough to get an approximation with error < 10^-7. */ 1413 Four terms are enough to get an approximation with error < 10^-7. */
1402 l -= z * (1.0 + z * (0.5 + z * ((1.0 / 3) + z * 0.25))); 1414 l -= 1.4426950408889634074 * z * (1.0 + z * (0.5 + z * ((1.0 / 3) + z * 0.25)));
1403 /* Finally multiply with log(2)/log(10), yields an approximation for 1415 /* Finally multiply with log(2)/log(10), yields an approximation for
1404 log10(x). */ 1416 log10(x). */
1405 l *= 0.30102999566398119523; 1417 l *= 0.30102999566398119523;
@@ -1409,6 +1421,20 @@ floorlog10 (double x)
1409 1421
1410# endif 1422# endif
1411 1423
1424/* Tests whether a string of digits consists of exactly PRECISION zeroes and
1425 a single '1' digit. */
1426static int
1427is_borderline (const char *digits, size_t precision)
1428{
1429 for (; precision > 0; precision--, digits++)
1430 if (*digits != '0')
1431 return 0;
1432 if (*digits != '1')
1433 return 0;
1434 digits++;
1435 return *digits == '\0';
1436}
1437
1412#endif 1438#endif
1413 1439
1414DCHAR_T * 1440DCHAR_T *
@@ -2552,8 +2578,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2552# elif NEED_PRINTF_INFINITE_LONG_DOUBLE 2578# elif NEED_PRINTF_INFINITE_LONG_DOUBLE
2553 || (a.arg[dp->arg_index].type == TYPE_LONGDOUBLE 2579 || (a.arg[dp->arg_index].type == TYPE_LONGDOUBLE
2554 /* Some systems produce wrong output for Inf, 2580 /* Some systems produce wrong output for Inf,
2555 -Inf, and NaN. */ 2581 -Inf, and NaN. Some systems in this category
2556 && is_infinitel (a.arg[dp->arg_index].a.a_longdouble)) 2582 (IRIX 5.3) also do so for -0.0. Therefore we
2583 treat this case here as well. */
2584 && is_infinite_or_zerol (a.arg[dp->arg_index].a.a_longdouble))
2557# endif 2585# endif
2558 )) 2586 ))
2559 { 2587 {
@@ -2635,9 +2663,11 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2635 2663
2636 /* POSIX specifies the default precision to be 6 for %f, %F, 2664 /* POSIX specifies the default precision to be 6 for %f, %F,
2637 %e, %E, but not for %g, %G. Implementations appear to use 2665 %e, %E, but not for %g, %G. Implementations appear to use
2638 the same default precision also for %g, %G. */ 2666 the same default precision also for %g, %G. But for %a, %A,
2667 the default precision is 0. */
2639 if (!has_precision) 2668 if (!has_precision)
2640 precision = 6; 2669 if (!(dp->conversion == 'a' || dp->conversion == 'A'))
2670 precision = 6;
2641 2671
2642 /* Allocate a temporary buffer of sufficient size. */ 2672 /* Allocate a temporary buffer of sufficient size. */
2643# if NEED_PRINTF_DOUBLE && NEED_PRINTF_LONG_DOUBLE 2673# if NEED_PRINTF_DOUBLE && NEED_PRINTF_LONG_DOUBLE
@@ -2858,8 +2888,32 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2858 exponent += 1; 2888 exponent += 1;
2859 adjusted = 1; 2889 adjusted = 1;
2860 } 2890 }
2861
2862 /* Here ndigits = precision+1. */ 2891 /* Here ndigits = precision+1. */
2892 if (is_borderline (digits, precision))
2893 {
2894 /* Maybe the exponent guess was too high
2895 and a smaller exponent can be reached
2896 by turning a 10...0 into 9...9x. */
2897 char *digits2 =
2898 scale10_round_decimal_long_double (arg,
2899 (int)precision - exponent + 1);
2900 if (digits2 == NULL)
2901 {
2902 free (digits);
2903 END_LONG_DOUBLE_ROUNDING ();
2904 goto out_of_memory;
2905 }
2906 if (strlen (digits2) == precision + 1)
2907 {
2908 free (digits);
2909 digits = digits2;
2910 exponent -= 1;
2911 }
2912 else
2913 free (digits2);
2914 }
2915 /* Here ndigits = precision+1. */
2916
2863 *p++ = digits[--ndigits]; 2917 *p++ = digits[--ndigits];
2864 if ((flags & FLAG_ALT) || precision > 0) 2918 if ((flags & FLAG_ALT) || precision > 0)
2865 { 2919 {
@@ -2971,6 +3025,30 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2971 adjusted = 1; 3025 adjusted = 1;
2972 } 3026 }
2973 /* Here ndigits = precision. */ 3027 /* Here ndigits = precision. */
3028 if (is_borderline (digits, precision - 1))
3029 {
3030 /* Maybe the exponent guess was too high
3031 and a smaller exponent can be reached
3032 by turning a 10...0 into 9...9x. */
3033 char *digits2 =
3034 scale10_round_decimal_long_double (arg,
3035 (int)(precision - 1) - exponent + 1);
3036 if (digits2 == NULL)
3037 {
3038 free (digits);
3039 END_LONG_DOUBLE_ROUNDING ();
3040 goto out_of_memory;
3041 }
3042 if (strlen (digits2) == precision)
3043 {
3044 free (digits);
3045 digits = digits2;
3046 exponent -= 1;
3047 }
3048 else
3049 free (digits2);
3050 }
3051 /* Here ndigits = precision. */
2974 3052
2975 /* Determine the number of trailing zeroes 3053 /* Determine the number of trailing zeroes
2976 that have to be dropped. */ 3054 that have to be dropped. */
@@ -3065,7 +3143,65 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3065 abort (); 3143 abort ();
3066# else 3144# else
3067 /* arg is finite. */ 3145 /* arg is finite. */
3068 abort (); 3146 if (!(arg == 0.0L))
3147 abort ();
3148
3149 pad_ptr = p;
3150
3151 if (dp->conversion == 'f' || dp->conversion == 'F')
3152 {
3153 *p++ = '0';
3154 if ((flags & FLAG_ALT) || precision > 0)
3155 {
3156 *p++ = decimal_point_char ();
3157 for (; precision > 0; precision--)
3158 *p++ = '0';
3159 }
3160 }
3161 else if (dp->conversion == 'e' || dp->conversion == 'E')
3162 {
3163 *p++ = '0';
3164 if ((flags & FLAG_ALT) || precision > 0)
3165 {
3166 *p++ = decimal_point_char ();
3167 for (; precision > 0; precision--)
3168 *p++ = '0';
3169 }
3170 *p++ = dp->conversion; /* 'e' or 'E' */
3171 *p++ = '+';
3172 *p++ = '0';
3173 *p++ = '0';
3174 }
3175 else if (dp->conversion == 'g' || dp->conversion == 'G')
3176 {
3177 *p++ = '0';
3178 if (flags & FLAG_ALT)
3179 {
3180 size_t ndigits =
3181 (precision > 0 ? precision - 1 : 0);
3182 *p++ = decimal_point_char ();
3183 for (; ndigits > 0; --ndigits)
3184 *p++ = '0';
3185 }
3186 }
3187 else if (dp->conversion == 'a' || dp->conversion == 'A')
3188 {
3189 *p++ = '0';
3190 *p++ = dp->conversion - 'A' + 'X';
3191 pad_ptr = p;
3192 *p++ = '0';
3193 if ((flags & FLAG_ALT) || precision > 0)
3194 {
3195 *p++ = decimal_point_char ();
3196 for (; precision > 0; precision--)
3197 *p++ = '0';
3198 }
3199 *p++ = dp->conversion - 'A' + 'P';
3200 *p++ = '+';
3201 *p++ = '0';
3202 }
3203 else
3204 abort ();
3069# endif 3205# endif
3070 } 3206 }
3071 3207
@@ -3211,8 +3347,31 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3211 exponent += 1; 3347 exponent += 1;
3212 adjusted = 1; 3348 adjusted = 1;
3213 } 3349 }
3214
3215 /* Here ndigits = precision+1. */ 3350 /* Here ndigits = precision+1. */
3351 if (is_borderline (digits, precision))
3352 {
3353 /* Maybe the exponent guess was too high
3354 and a smaller exponent can be reached
3355 by turning a 10...0 into 9...9x. */
3356 char *digits2 =
3357 scale10_round_decimal_double (arg,
3358 (int)precision - exponent + 1);
3359 if (digits2 == NULL)
3360 {
3361 free (digits);
3362 goto out_of_memory;
3363 }
3364 if (strlen (digits2) == precision + 1)
3365 {
3366 free (digits);
3367 digits = digits2;
3368 exponent -= 1;
3369 }
3370 else
3371 free (digits2);
3372 }
3373 /* Here ndigits = precision+1. */
3374
3216 *p++ = digits[--ndigits]; 3375 *p++ = digits[--ndigits];
3217 if ((flags & FLAG_ALT) || precision > 0) 3376 if ((flags & FLAG_ALT) || precision > 0)
3218 { 3377 {
@@ -3337,6 +3496,29 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3337 adjusted = 1; 3496 adjusted = 1;
3338 } 3497 }
3339 /* Here ndigits = precision. */ 3498 /* Here ndigits = precision. */
3499 if (is_borderline (digits, precision - 1))
3500 {
3501 /* Maybe the exponent guess was too high
3502 and a smaller exponent can be reached
3503 by turning a 10...0 into 9...9x. */
3504 char *digits2 =
3505 scale10_round_decimal_double (arg,
3506 (int)(precision - 1) - exponent + 1);
3507 if (digits2 == NULL)
3508 {
3509 free (digits);
3510 goto out_of_memory;
3511 }
3512 if (strlen (digits2) == precision)
3513 {
3514 free (digits);
3515 digits = digits2;
3516 exponent -= 1;
3517 }
3518 else
3519 free (digits2);
3520 }
3521 /* Here ndigits = precision. */
3340 3522
3341 /* Determine the number of trailing zeroes 3523 /* Determine the number of trailing zeroes
3342 that have to be dropped. */ 3524 that have to be dropped. */
@@ -3588,7 +3770,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3588#endif 3770#endif
3589 TCHAR_T *fbp; 3771 TCHAR_T *fbp;
3590 unsigned int prefix_count; 3772 unsigned int prefix_count;
3591 int prefixes[2]; 3773 int prefixes[2] IF_LINT (= { 0 });
3592#if !USE_SNPRINTF 3774#if !USE_SNPRINTF
3593 size_t tmp_length; 3775 size_t tmp_length;
3594 TCHAR_T tmpbuf[700]; 3776 TCHAR_T tmpbuf[700];
@@ -3661,6 +3843,44 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3661 } 3843 }
3662#endif 3844#endif
3663 3845
3846 /* Decide whether to handle the precision ourselves. */
3847#if NEED_PRINTF_UNBOUNDED_PRECISION
3848 switch (dp->conversion)
3849 {
3850 case 'd': case 'i': case 'u':
3851 case 'o':
3852 case 'x': case 'X': case 'p':
3853 prec_ourselves = has_precision && (precision > 0);
3854 break;
3855 default:
3856 prec_ourselves = 0;
3857 break;
3858 }
3859#endif
3860
3861 /* Decide whether to perform the padding ourselves. */
3862#if !NEED_PRINTF_FLAG_LEFTADJUST && (!DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION)
3863 switch (dp->conversion)
3864 {
3865# if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO
3866 /* If we need conversion from TCHAR_T[] to DCHAR_T[], we need
3867 to perform the padding after this conversion. Functions
3868 with unistdio extensions perform the padding based on
3869 character count rather than element count. */
3870 case 'c': case 's':
3871# endif
3872# if NEED_PRINTF_FLAG_ZERO
3873 case 'f': case 'F': case 'e': case 'E': case 'g': case 'G':
3874 case 'a': case 'A':
3875# endif
3876 pad_ourselves = 1;
3877 break;
3878 default:
3879 pad_ourselves = prec_ourselves;
3880 break;
3881 }
3882#endif
3883
3664#if !USE_SNPRINTF 3884#if !USE_SNPRINTF
3665 /* Allocate a temporary buffer of sufficient size for calling 3885 /* Allocate a temporary buffer of sufficient size for calling
3666 sprintf. */ 3886 sprintf. */
@@ -3837,18 +4057,22 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3837 abort (); 4057 abort ();
3838 } 4058 }
3839 4059
4060 if (!pad_ourselves)
4061 {
3840# if ENABLE_UNISTDIO 4062# if ENABLE_UNISTDIO
3841 /* Padding considers the number of characters, therefore the 4063 /* Padding considers the number of characters, therefore
3842 number of elements after padding may be 4064 the number of elements after padding may be
3843 > max (tmp_length, width) 4065 > max (tmp_length, width)
3844 but is certainly 4066 but is certainly
3845 <= tmp_length + width. */ 4067 <= tmp_length + width. */
3846 tmp_length = xsum (tmp_length, width); 4068 tmp_length = xsum (tmp_length, width);
3847# else 4069# else
3848 /* Padding considers the number of elements, says POSIX. */ 4070 /* Padding considers the number of elements,
3849 if (tmp_length < width) 4071 says POSIX. */
3850 tmp_length = width; 4072 if (tmp_length < width)
4073 tmp_length = width;
3851# endif 4074# endif
4075 }
3852 4076
3853 tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */ 4077 tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */
3854 } 4078 }
@@ -3869,44 +4093,6 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
3869 } 4093 }
3870#endif 4094#endif
3871 4095
3872 /* Decide whether to handle the precision ourselves. */
3873#if NEED_PRINTF_UNBOUNDED_PRECISION
3874 switch (dp->conversion)
3875 {
3876 case 'd': case 'i': case 'u':
3877 case 'o':
3878 case 'x': case 'X': case 'p':
3879 prec_ourselves = has_precision && (precision > 0);
3880 break;
3881 default:
3882 prec_ourselves = 0;
3883 break;
3884 }
3885#endif
3886
3887 /* Decide whether to perform the padding ourselves. */
3888#if !NEED_PRINTF_FLAG_LEFTADJUST && (!DCHAR_IS_TCHAR || ENABLE_UNISTDIO || NEED_PRINTF_FLAG_ZERO || NEED_PRINTF_UNBOUNDED_PRECISION)
3889 switch (dp->conversion)
3890 {
3891# if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO
3892 /* If we need conversion from TCHAR_T[] to DCHAR_T[], we need
3893 to perform the padding after this conversion. Functions
3894 with unistdio extensions perform the padding based on
3895 character count rather than element count. */
3896 case 'c': case 's':
3897# endif
3898# if NEED_PRINTF_FLAG_ZERO
3899 case 'f': case 'F': case 'e': case 'E': case 'g': case 'G':
3900 case 'a': case 'A':
3901# endif
3902 pad_ourselves = 1;
3903 break;
3904 default:
3905 pad_ourselves = prec_ourselves;
3906 break;
3907 }
3908#endif
3909
3910 /* Construct the format string for calling snprintf or 4096 /* Construct the format string for calling snprintf or
3911 sprintf. */ 4097 sprintf. */
3912 fbp = buf; 4098 fbp = buf;
@@ -4052,7 +4238,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4052 abort (); 4238 abort ();
4053 prefixes[prefix_count++] = a.arg[dp->width_arg_index].a.a_int; 4239 prefixes[prefix_count++] = a.arg[dp->width_arg_index].a.a_int;
4054 } 4240 }
4055 if (dp->precision_arg_index != ARG_NONE) 4241 if (!prec_ourselves && dp->precision_arg_index != ARG_NONE)
4056 { 4242 {
4057 if (!(a.arg[dp->precision_arg_index].type == TYPE_INT)) 4243 if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
4058 abort (); 4244 abort ();
@@ -4403,14 +4589,14 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4403 } 4589 }
4404#endif 4590#endif
4405 4591
4406#if !DCHAR_IS_TCHAR 4592#if !USE_SNPRINTF
4407# if !USE_SNPRINTF
4408 if (count >= tmp_length) 4593 if (count >= tmp_length)
4409 /* tmp_length was incorrectly calculated - fix the 4594 /* tmp_length was incorrectly calculated - fix the
4410 code above! */ 4595 code above! */
4411 abort (); 4596 abort ();
4412# endif 4597#endif
4413 4598
4599#if !DCHAR_IS_TCHAR
4414 /* Convert from TCHAR_T[] to DCHAR_T[]. */ 4600 /* Convert from TCHAR_T[] to DCHAR_T[]. */
4415 if (dp->conversion == 'c' || dp->conversion == 's') 4601 if (dp->conversion == 'c' || dp->conversion == 's')
4416 { 4602 {
@@ -4528,7 +4714,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4528 if (w < width) 4714 if (w < width)
4529 { 4715 {
4530 size_t pad = width - w; 4716 size_t pad = width - w;
4531# if USE_SNPRINTF 4717
4532 /* Make room for the result. */ 4718 /* Make room for the result. */
4533 if (xsum (count, pad) > allocated - length) 4719 if (xsum (count, pad) > allocated - length)
4534 { 4720 {
@@ -4538,12 +4724,16 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4538 xmax (xsum3 (length, count, pad), 4724 xmax (xsum3 (length, count, pad),
4539 xtimes (allocated, 2)); 4725 xtimes (allocated, 2));
4540 4726
4727# if USE_SNPRINTF
4541 length += count; 4728 length += count;
4542 ENSURE_ALLOCATION (n); 4729 ENSURE_ALLOCATION (n);
4543 length -= count; 4730 length -= count;
4731# else
4732 ENSURE_ALLOCATION (n);
4733# endif
4544 } 4734 }
4545 /* Here count + pad <= allocated - length. */ 4735 /* Here count + pad <= allocated - length. */
4546# endif 4736
4547 { 4737 {
4548# if !DCHAR_IS_TCHAR || USE_SNPRINTF 4738# if !DCHAR_IS_TCHAR || USE_SNPRINTF
4549 DCHAR_T * const rp = result + length; 4739 DCHAR_T * const rp = result + length;
@@ -4553,7 +4743,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4553 DCHAR_T *p = rp + count; 4743 DCHAR_T *p = rp + count;
4554 DCHAR_T *end = p + pad; 4744 DCHAR_T *end = p + pad;
4555 DCHAR_T *pad_ptr; 4745 DCHAR_T *pad_ptr;
4556# if !DCHAR_IS_TCHAR 4746# if !DCHAR_IS_TCHAR || ENABLE_UNISTDIO
4557 if (dp->conversion == 'c' 4747 if (dp->conversion == 'c'
4558 || dp->conversion == 's') 4748 || dp->conversion == 's')
4559 /* No zero-padding for string directives. */ 4749 /* No zero-padding for string directives. */
@@ -4604,13 +4794,6 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4604 } 4794 }
4605#endif 4795#endif
4606 4796
4607#if DCHAR_IS_TCHAR && !USE_SNPRINTF
4608 if (count >= tmp_length)
4609 /* tmp_length was incorrectly calculated - fix the
4610 code above! */
4611 abort ();
4612#endif
4613
4614 /* Here still count <= allocated - length. */ 4797 /* Here still count <= allocated - length. */
4615 4798
4616#if !DCHAR_IS_TCHAR || USE_SNPRINTF 4799#if !DCHAR_IS_TCHAR || USE_SNPRINTF
diff --git a/gl/vasprintf.c b/gl/vasprintf.c
index 90f64e9..d1b8137 100644
--- a/gl/vasprintf.c
+++ b/gl/vasprintf.c
@@ -1,5 +1,5 @@
1/* Formatted output to strings. 1/* Formatted output to strings.
2 Copyright (C) 1999, 2002, 2006-2007 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2002, 2006-2008 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
@@ -30,11 +30,6 @@
30 30
31#include "vasnprintf.h" 31#include "vasnprintf.h"
32 32
33/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */
34#ifndef EOVERFLOW
35# define EOVERFLOW E2BIG
36#endif
37
38int 33int
39vasprintf (char **resultp, const char *format, va_list args) 34vasprintf (char **resultp, const char *format, va_list args)
40{ 35{
diff --git a/gl/verify.h b/gl/verify.h
new file mode 100644
index 0000000..fac53f6
--- /dev/null
+++ b/gl/verify.h
@@ -0,0 +1,140 @@
1/* Compile-time assert-like macros.
2
3 Copyright (C) 2005, 2006 Free Software Foundation, Inc.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18/* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */
19
20#ifndef VERIFY_H
21# define VERIFY_H 1
22
23/* Each of these macros verifies that its argument R is nonzero. To
24 be portable, R should be an integer constant expression. Unlike
25 assert (R), there is no run-time overhead.
26
27 There are two macros, since no single macro can be used in all
28 contexts in C. verify_true (R) is for scalar contexts, including
29 integer constant expression contexts. verify (R) is for declaration
30 contexts, e.g., the top level.
31
32 Symbols ending in "__" are private to this header.
33
34 The code below uses several ideas.
35
36 * The first step is ((R) ? 1 : -1). Given an expression R, of
37 integral or boolean or floating-point type, this yields an
38 expression of integral type, whose value is later verified to be
39 constant and nonnegative.
40
41 * Next this expression W is wrapped in a type
42 struct verify_type__ { unsigned int verify_error_if_negative_size__: W; }.
43 If W is negative, this yields a compile-time error. No compiler can
44 deal with a bit-field of negative size.
45
46 One might think that an array size check would have the same
47 effect, that is, that the type struct { unsigned int dummy[W]; }
48 would work as well. However, inside a function, some compilers
49 (such as C++ compilers and GNU C) allow local parameters and
50 variables inside array size expressions. With these compilers,
51 an array size check would not properly diagnose this misuse of
52 the verify macro:
53
54 void function (int n) { verify (n < 0); }
55
56 * For the verify macro, the struct verify_type__ will need to
57 somehow be embedded into a declaration. To be portable, this
58 declaration must declare an object, a constant, a function, or a
59 typedef name. If the declared entity uses the type directly,
60 such as in
61
62 struct dummy {...};
63 typedef struct {...} dummy;
64 extern struct {...} *dummy;
65 extern void dummy (struct {...} *);
66 extern struct {...} *dummy (void);
67
68 two uses of the verify macro would yield colliding declarations
69 if the entity names are not disambiguated. A workaround is to
70 attach the current line number to the entity name:
71
72 #define GL_CONCAT0(x, y) x##y
73 #define GL_CONCAT(x, y) GL_CONCAT0 (x, y)
74 extern struct {...} * GL_CONCAT(dummy,__LINE__);
75
76 But this has the problem that two invocations of verify from
77 within the same macro would collide, since the __LINE__ value
78 would be the same for both invocations.
79
80 A solution is to use the sizeof operator. It yields a number,
81 getting rid of the identity of the type. Declarations like
82
83 extern int dummy [sizeof (struct {...})];
84 extern void dummy (int [sizeof (struct {...})]);
85 extern int (*dummy (void)) [sizeof (struct {...})];
86
87 can be repeated.
88
89 * Should the implementation use a named struct or an unnamed struct?
90 Which of the following alternatives can be used?
91
92 extern int dummy [sizeof (struct {...})];
93 extern int dummy [sizeof (struct verify_type__ {...})];
94 extern void dummy (int [sizeof (struct {...})]);
95 extern void dummy (int [sizeof (struct verify_type__ {...})]);
96 extern int (*dummy (void)) [sizeof (struct {...})];
97 extern int (*dummy (void)) [sizeof (struct verify_type__ {...})];
98
99 In the second and sixth case, the struct type is exported to the
100 outer scope; two such declarations therefore collide. GCC warns
101 about the first, third, and fourth cases. So the only remaining
102 possibility is the fifth case:
103
104 extern int (*dummy (void)) [sizeof (struct {...})];
105
106 * This implementation exploits the fact that GCC does not warn about
107 the last declaration mentioned above. If a future version of GCC
108 introduces a warning for this, the problem could be worked around
109 by using code specialized to GCC, e.g.,:
110
111 #if 4 <= __GNUC__
112 # define verify(R) \
113 extern int (* verify_function__ (void)) \
114 [__builtin_constant_p (R) && (R) ? 1 : -1]
115 #endif
116
117 * In C++, any struct definition inside sizeof is invalid.
118 Use a template type to work around the problem. */
119
120
121/* Verify requirement R at compile-time, as an integer constant expression.
122 Return 1. */
123
124# ifdef __cplusplus
125template <int w>
126 struct verify_type__ { unsigned int verify_error_if_negative_size__: w; };
127# define verify_true(R) \
128 (!!sizeof (verify_type__<(R) ? 1 : -1>))
129# else
130# define verify_true(R) \
131 (!!sizeof \
132 (struct { unsigned int verify_error_if_negative_size__: (R) ? 1 : -1; }))
133# endif
134
135/* Verify requirement R at compile-time, as a declaration without a
136 trailing ';'. */
137
138# define verify(R) extern int (* verify_function__ (void)) [verify_true (R)]
139
140#endif
diff --git a/gl/vsnprintf.c b/gl/vsnprintf.c
index cc8f61f..02af252 100644
--- a/gl/vsnprintf.c
+++ b/gl/vsnprintf.c
@@ -1,5 +1,5 @@
1/* Formatted output to strings. 1/* Formatted output to strings.
2 Copyright (C) 2004, 2006-2007 Free Software Foundation, Inc. 2 Copyright (C) 2004, 2006-2008 Free Software Foundation, Inc.
3 Written by Simon Josefsson and Yoann Vandoorselaere <yoann@prelude-ids.org>. 3 Written by Simon Josefsson and Yoann Vandoorselaere <yoann@prelude-ids.org>.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
@@ -31,11 +31,6 @@
31 31
32#include "vasnprintf.h" 32#include "vasnprintf.h"
33 33
34/* Some systems, like OSF/1 4.0 and Woe32, don't have EOVERFLOW. */
35#ifndef EOVERFLOW
36# define EOVERFLOW E2BIG
37#endif
38
39/* Print formatted output to string STR. Similar to vsprintf, but 34/* Print formatted output to string STR. Similar to vsprintf, but
40 additional length SIZE limit how much is written into STR. Returns 35 additional length SIZE limit how much is written into STR. Returns
41 string length of formatted string (which may be larger than SIZE). 36 string length of formatted string (which may be larger than SIZE).
diff --git a/gl/wchar.in.h b/gl/wchar.in.h
index b721572..e069cfa 100644
--- a/gl/wchar.in.h
+++ b/gl/wchar.in.h
@@ -1,6 +1,6 @@
1/* A substitute for ISO C99 <wchar.h>, for platforms that have issues. 1/* A substitute for ISO C99 <wchar.h>, for platforms that have issues.
2 2
3 Copyright (C) 2007 Free Software Foundation, Inc. 3 Copyright (C) 2007-2009 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
@@ -26,6 +26,25 @@
26 * the declaration of wcwidth(). 26 * the declaration of wcwidth().
27 */ 27 */
28 28
29#if __GNUC__ >= 3
30@PRAGMA_SYSTEM_HEADER@
31#endif
32
33#if defined __need_mbstate_t || (defined __hpux && ((defined _INTTYPES_INCLUDED && !defined strtoimax) || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H))
34/* Special invocation convention:
35 - Inside uClibc header files.
36 - On HP-UX 11.00 we have a sequence of nested includes
37 <wchar.h> -> <stdlib.h> -> <stdint.h>, and the latter includes <wchar.h>,
38 once indirectly <stdint.h> -> <sys/types.h> -> <inttypes.h> -> <wchar.h>
39 and once directly. In both situations 'wint_t' is not yet defined,
40 therefore we cannot provide the function overrides; instead include only
41 the system's <wchar.h>. */
42
43#@INCLUDE_NEXT@ @NEXT_WCHAR_H@
44
45#else
46/* Normal invocation convention. */
47
29#ifndef _GL_WCHAR_H 48#ifndef _GL_WCHAR_H
30 49
31/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before 50/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
@@ -53,6 +72,203 @@ extern "C" {
53#endif 72#endif
54 73
55 74
75/* Define wint_t. (Also done in wctype.in.h.) */
76#if !@HAVE_WINT_T@ && !defined wint_t
77# define wint_t int
78# ifndef WEOF
79# define WEOF -1
80# endif
81#endif
82
83
84/* Override mbstate_t if it is too small.
85 On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for
86 implementing mbrtowc for encodings like UTF-8. */
87#if !(@HAVE_MBSINIT@ && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@
88typedef int rpl_mbstate_t;
89# undef mbstate_t
90# define mbstate_t rpl_mbstate_t
91# define GNULIB_defined_mbstate_t 1
92#endif
93
94
95/* Convert a single-byte character to a wide character. */
96#if @GNULIB_BTOWC@
97# if @REPLACE_BTOWC@
98# undef btowc
99# define btowc rpl_btowc
100# endif
101# if !@HAVE_BTOWC@ || @REPLACE_BTOWC@
102extern wint_t btowc (int c);
103# endif
104#elif defined GNULIB_POSIXCHECK
105# undef btowc
106# define btowc(c) \
107 (GL_LINK_WARNING ("btowc is unportable - " \
108 "use gnulib module btowc for portability"), \
109 btowc (c))
110#endif
111
112
113/* Convert a wide character to a single-byte character. */
114#if @GNULIB_WCTOB@
115# if @REPLACE_WCTOB@
116# undef wctob
117# define wctob rpl_wctob
118# endif
119# if (!defined wctob && !@HAVE_DECL_WCTOB@) || @REPLACE_WCTOB@
120/* wctob is provided by gnulib, or wctob exists but is not declared. */
121extern int wctob (wint_t wc);
122# endif
123#elif defined GNULIB_POSIXCHECK
124# undef wctob
125# define wctob(w) \
126 (GL_LINK_WARNING ("wctob is unportable - " \
127 "use gnulib module wctob for portability"), \
128 wctob (w))
129#endif
130
131
132/* Test whether *PS is in the initial state. */
133#if @GNULIB_MBSINIT@
134# if @REPLACE_MBSINIT@
135# undef mbsinit
136# define mbsinit rpl_mbsinit
137# endif
138# if !@HAVE_MBSINIT@ || @REPLACE_MBSINIT@
139extern int mbsinit (const mbstate_t *ps);
140# endif
141#elif defined GNULIB_POSIXCHECK
142# undef mbsinit
143# define mbsinit(p) \
144 (GL_LINK_WARNING ("mbsinit is unportable - " \
145 "use gnulib module mbsinit for portability"), \
146 mbsinit (p))
147#endif
148
149
150/* Convert a multibyte character to a wide character. */
151#if @GNULIB_MBRTOWC@
152# if @REPLACE_MBRTOWC@
153# undef mbrtowc
154# define mbrtowc rpl_mbrtowc
155# endif
156# if !@HAVE_MBRTOWC@ || @REPLACE_MBRTOWC@
157extern size_t mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps);
158# endif
159#elif defined GNULIB_POSIXCHECK
160# undef mbrtowc
161# define mbrtowc(w,s,n,p) \
162 (GL_LINK_WARNING ("mbrtowc is unportable - " \
163 "use gnulib module mbrtowc for portability"), \
164 mbrtowc (w, s, n, p))
165#endif
166
167
168/* Recognize a multibyte character. */
169#if @GNULIB_MBRLEN@
170# if @REPLACE_MBRLEN@
171# undef mbrlen
172# define mbrlen rpl_mbrlen
173# endif
174# if !@HAVE_MBRLEN@ || @REPLACE_MBRLEN@
175extern size_t mbrlen (const char *s, size_t n, mbstate_t *ps);
176# endif
177#elif defined GNULIB_POSIXCHECK
178# undef mbrlen
179# define mbrlen(s,n,p) \
180 (GL_LINK_WARNING ("mbrlen is unportable - " \
181 "use gnulib module mbrlen for portability"), \
182 mbrlen (s, n, p))
183#endif
184
185
186/* Convert a string to a wide string. */
187#if @GNULIB_MBSRTOWCS@
188# if @REPLACE_MBSRTOWCS@
189# undef mbsrtowcs
190# define mbsrtowcs rpl_mbsrtowcs
191# endif
192# if !@HAVE_MBSRTOWCS@ || @REPLACE_MBSRTOWCS@
193extern size_t mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps);
194# endif
195#elif defined GNULIB_POSIXCHECK
196# undef mbsrtowcs
197# define mbsrtowcs(d,s,l,p) \
198 (GL_LINK_WARNING ("mbsrtowcs is unportable - " \
199 "use gnulib module mbsrtowcs for portability"), \
200 mbsrtowcs (d, s, l, p))
201#endif
202
203
204/* Convert a string to a wide string. */
205#if @GNULIB_MBSNRTOWCS@
206# if @REPLACE_MBSNRTOWCS@
207# undef mbsnrtowcs
208# define mbsnrtowcs rpl_mbsnrtowcs
209# endif
210# if !@HAVE_MBSNRTOWCS@ || @REPLACE_MBSNRTOWCS@
211extern size_t mbsnrtowcs (wchar_t *dest, const char **srcp, size_t srclen, size_t len, mbstate_t *ps);
212# endif
213#elif defined GNULIB_POSIXCHECK
214# undef mbsnrtowcs
215# define mbsnrtowcs(d,s,n,l,p) \
216 (GL_LINK_WARNING ("mbsnrtowcs is unportable - " \
217 "use gnulib module mbsnrtowcs for portability"), \
218 mbsnrtowcs (d, s, n, l, p))
219#endif
220
221
222/* Convert a wide character to a multibyte character. */
223#if @GNULIB_WCRTOMB@
224# if @REPLACE_WCRTOMB@
225# undef wcrtomb
226# define wcrtomb rpl_wcrtomb
227# endif
228# if !@HAVE_WCRTOMB@ || @REPLACE_WCRTOMB@
229extern size_t wcrtomb (char *s, wchar_t wc, mbstate_t *ps);
230# endif
231#elif defined GNULIB_POSIXCHECK
232# undef wcrtomb
233# define wcrtomb(s,w,p) \
234 (GL_LINK_WARNING ("wcrtomb is unportable - " \
235 "use gnulib module wcrtomb for portability"), \
236 wcrtomb (s, w, p))
237#endif
238
239
240/* Convert a wide string to a string. */
241#if @GNULIB_WCSRTOMBS@
242# if @REPLACE_WCSRTOMBS@
243# undef wcsrtombs
244# define wcsrtombs rpl_wcsrtombs
245# endif
246# if !@HAVE_WCSRTOMBS@ || @REPLACE_WCSRTOMBS@
247extern size_t wcsrtombs (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps);
248# endif
249#elif defined GNULIB_POSIXCHECK
250# undef wcsrtombs
251# define wcsrtombs(d,s,l,p) \
252 (GL_LINK_WARNING ("wcsrtombs is unportable - " \
253 "use gnulib module wcsrtombs for portability"), \
254 wcsrtombs (d, s, l, p))
255#endif
256
257
258/* Convert a wide string to a string. */
259#if @GNULIB_WCSNRTOMBS@
260# if !@HAVE_WCSNRTOMBS@
261extern size_t wcsnrtombs (char *dest, const wchar_t **srcp, size_t srclen, size_t len, mbstate_t *ps);
262# endif
263#elif defined GNULIB_POSIXCHECK
264# undef wcsnrtombs
265# define wcsnrtombs(d,s,n,l,p) \
266 (GL_LINK_WARNING ("wcsnrtombs is unportable - " \
267 "use gnulib module wcsnrtombs for portability"), \
268 wcsnrtombs (d, s, n, l, p))
269#endif
270
271
56/* Return the number of screen columns needed for WC. */ 272/* Return the number of screen columns needed for WC. */
57#if @GNULIB_WCWIDTH@ 273#if @GNULIB_WCWIDTH@
58# if @REPLACE_WCWIDTH@ 274# if @REPLACE_WCWIDTH@
@@ -80,3 +296,4 @@ extern int wcwidth (int /* actually wchar_t */);
80 296
81#endif /* _GL_WCHAR_H */ 297#endif /* _GL_WCHAR_H */
82#endif /* _GL_WCHAR_H */ 298#endif /* _GL_WCHAR_H */
299#endif
diff --git a/gl/wcrtomb.c b/gl/wcrtomb.c
new file mode 100644
index 0000000..79df99f
--- /dev/null
+++ b/gl/wcrtomb.c
@@ -0,0 +1,53 @@
1/* Convert wide character to multibyte character.
2 Copyright (C) 2008 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2008.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#include <wchar.h>
22
23#include <errno.h>
24#include <stdlib.h>
25
26
27size_t
28wcrtomb (char *s, wchar_t wc, mbstate_t *ps)
29{
30 /* This implementation of wcrtomb on top of wctomb() supports only
31 stateless encodings. ps must be in the initial state. */
32 if (ps != NULL && !mbsinit (ps))
33 {
34 errno = EINVAL;
35 return (size_t)(-1);
36 }
37
38 if (s == NULL)
39 /* We know the NUL wide character corresponds to the NUL character. */
40 return 1;
41 else
42 {
43 int ret = wctomb (s, wc);
44
45 if (ret >= 0)
46 return ret;
47 else
48 {
49 errno = EILSEQ;
50 return (size_t)(-1);
51 }
52 }
53}
diff --git a/gl/wctype.in.h b/gl/wctype.in.h
index a86b5ad..f008d8f 100644
--- a/gl/wctype.in.h
+++ b/gl/wctype.in.h
@@ -1,6 +1,6 @@
1/* A substitute for ISO C99 <wctype.h>, for platforms that lack it. 1/* A substitute for ISO C99 <wctype.h>, for platforms that lack it.
2 2
3 Copyright (C) 2006, 2007 Free Software Foundation, Inc. 3 Copyright (C) 2006-2008 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
@@ -28,6 +28,10 @@
28 28
29#ifndef _GL_WCTYPE_H 29#ifndef _GL_WCTYPE_H
30 30
31#if __GNUC__ >= 3
32@PRAGMA_SYSTEM_HEADER@
33#endif
34
31#if @HAVE_WINT_T@ 35#if @HAVE_WINT_T@
32/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>. 36/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>.
33 Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before 37 Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
@@ -50,15 +54,18 @@
50#ifndef _GL_WCTYPE_H 54#ifndef _GL_WCTYPE_H
51#define _GL_WCTYPE_H 55#define _GL_WCTYPE_H
52 56
53#if @HAVE_WINT_T@ 57/* Define wint_t. (Also done in wchar.in.h.) */
54typedef wint_t __wctype_wint_t; 58#if !@HAVE_WINT_T@ && !defined wint_t
55#else 59# define wint_t int
56typedef int __wctype_wint_t; 60# ifndef WEOF
61# define WEOF -1
62# endif
57#endif 63#endif
58 64
59/* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions. 65/* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions.
66 Linux libc5 has <wctype.h> and the functions but they are broken.
60 Assume all 12 functions are implemented the same way, or not at all. */ 67 Assume all 12 functions are implemented the same way, or not at all. */
61#if ! @HAVE_ISWCNTRL@ 68#if ! @HAVE_ISWCNTRL@ || @REPLACE_ISWCNTRL@
62 69
63/* IRIX 5.3 has macros but no functions, its isw* macros refer to an 70/* IRIX 5.3 has macros but no functions, its isw* macros refer to an
64 undefined variable _ctmp_ and to <ctype.h> macros like _P, and they 71 undefined variable _ctmp_ and to <ctype.h> macros like _P, and they
@@ -78,57 +85,73 @@ typedef int __wctype_wint_t;
78# undef iswupper 85# undef iswupper
79# undef iswxdigit 86# undef iswxdigit
80 87
88/* Linux libc5 has <wctype.h> and the functions but they are broken. */
89# if @REPLACE_ISWCNTRL@
90# define iswalnum rpl_iswalnum
91# define iswalpha rpl_iswalpha
92# define iswblank rpl_iswblank
93# define iswcntrl rpl_iswcntrl
94# define iswdigit rpl_iswdigit
95# define iswgraph rpl_iswgraph
96# define iswlower rpl_iswlower
97# define iswprint rpl_iswprint
98# define iswpunct rpl_iswpunct
99# define iswspace rpl_iswspace
100# define iswupper rpl_iswupper
101# define iswxdigit rpl_iswxdigit
102# endif
103
81static inline int 104static inline int
82iswalnum (__wctype_wint_t wc) 105iswalnum (wint_t wc)
83{ 106{
84 return ((wc >= '0' && wc <= '9') 107 return ((wc >= '0' && wc <= '9')
85 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')); 108 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'));
86} 109}
87 110
88static inline int 111static inline int
89iswalpha (__wctype_wint_t wc) 112iswalpha (wint_t wc)
90{ 113{
91 return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'; 114 return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z';
92} 115}
93 116
94static inline int 117static inline int
95iswblank (__wctype_wint_t wc) 118iswblank (wint_t wc)
96{ 119{
97 return wc == ' ' || wc == '\t'; 120 return wc == ' ' || wc == '\t';
98} 121}
99 122
100static inline int 123static inline int
101iswcntrl (__wctype_wint_t wc) 124iswcntrl (wint_t wc)
102{ 125{
103 return (wc & ~0x1f) == 0 || wc == 0x7f; 126 return (wc & ~0x1f) == 0 || wc == 0x7f;
104} 127}
105 128
106static inline int 129static inline int
107iswdigit (__wctype_wint_t wc) 130iswdigit (wint_t wc)
108{ 131{
109 return wc >= '0' && wc <= '9'; 132 return wc >= '0' && wc <= '9';
110} 133}
111 134
112static inline int 135static inline int
113iswgraph (__wctype_wint_t wc) 136iswgraph (wint_t wc)
114{ 137{
115 return wc >= '!' && wc <= '~'; 138 return wc >= '!' && wc <= '~';
116} 139}
117 140
118static inline int 141static inline int
119iswlower (__wctype_wint_t wc) 142iswlower (wint_t wc)
120{ 143{
121 return wc >= 'a' && wc <= 'z'; 144 return wc >= 'a' && wc <= 'z';
122} 145}
123 146
124static inline int 147static inline int
125iswprint (__wctype_wint_t wc) 148iswprint (wint_t wc)
126{ 149{
127 return wc >= ' ' && wc <= '~'; 150 return wc >= ' ' && wc <= '~';
128} 151}
129 152
130static inline int 153static inline int
131iswpunct (__wctype_wint_t wc) 154iswpunct (wint_t wc)
132{ 155{
133 return (wc >= '!' && wc <= '~' 156 return (wc >= '!' && wc <= '~'
134 && !((wc >= '0' && wc <= '9') 157 && !((wc >= '0' && wc <= '9')
@@ -136,20 +159,20 @@ iswpunct (__wctype_wint_t wc)
136} 159}
137 160
138static inline int 161static inline int
139iswspace (__wctype_wint_t wc) 162iswspace (wint_t wc)
140{ 163{
141 return (wc == ' ' || wc == '\t' 164 return (wc == ' ' || wc == '\t'
142 || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r'); 165 || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r');
143} 166}
144 167
145static inline int 168static inline int
146iswupper (__wctype_wint_t wc) 169iswupper (wint_t wc)
147{ 170{
148 return wc >= 'A' && wc <= 'Z'; 171 return wc >= 'A' && wc <= 'Z';
149} 172}
150 173
151static inline int 174static inline int
152iswxdigit (__wctype_wint_t wc) 175iswxdigit (wint_t wc)
153{ 176{
154 return ((wc >= '0' && wc <= '9') 177 return ((wc >= '0' && wc <= '9')
155 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F')); 178 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F'));
diff --git a/gl/write.c b/gl/write.c
new file mode 100644
index 0000000..250b5cc
--- /dev/null
+++ b/gl/write.c
@@ -0,0 +1,62 @@
1/* POSIX compatible write() function.
2 Copyright (C) 2008 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2008.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#include <unistd.h>
22
23/* Replace this function only if module 'sigpipe' is requested. */
24#if GNULIB_SIGPIPE
25
26/* On native Windows platforms, SIGPIPE does not exist. When write() is
27 called on a pipe with no readers, WriteFile() fails with error
28 GetLastError() = ERROR_NO_DATA, and write() in consequence fails with
29 error EINVAL. */
30
31# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
32
33# include <errno.h>
34# include <signal.h>
35# include <io.h>
36
37# define WIN32_LEAN_AND_MEAN /* avoid including junk */
38# include <windows.h>
39
40ssize_t
41rpl_write (int fd, const void *buf, size_t count)
42#undef write
43{
44 ssize_t ret = write (fd, buf, count);
45
46 if (ret < 0)
47 {
48 if (GetLastError () == ERROR_NO_DATA
49 && GetFileType (_get_osfhandle (fd)) == FILE_TYPE_PIPE)
50 {
51 /* Try to raise signal SIGPIPE. */
52 raise (SIGPIPE);
53 /* If it is currently blocked or ignored, change errno from EINVAL
54 to EPIPE. */
55 errno = EPIPE;
56 }
57 }
58 return ret;
59}
60
61# endif
62#endif
diff --git a/gl/xalloc.h b/gl/xalloc.h
index 40dcf4b..57a13e0 100644
--- a/gl/xalloc.h
+++ b/gl/xalloc.h
@@ -37,6 +37,14 @@ extern "C" {
37# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) 37# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
38# endif 38# endif
39 39
40# ifndef ATTRIBUTE_MALLOC
41# if __GNUC__ >= 3
42# define ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
43# else
44# define ATTRIBUTE_MALLOC
45# endif
46# endif
47
40/* This function is always triggered when memory is exhausted. 48/* This function is always triggered when memory is exhausted.
41 It must be defined by the application, either explicitly 49 It must be defined by the application, either explicitly
42 or by using gnulib's xalloc-die module. This is the 50 or by using gnulib's xalloc-die module. This is the
@@ -44,13 +52,13 @@ extern "C" {
44 memory allocation failure. */ 52 memory allocation failure. */
45extern void xalloc_die (void) ATTRIBUTE_NORETURN; 53extern void xalloc_die (void) ATTRIBUTE_NORETURN;
46 54
47void *xmalloc (size_t s); 55void *xmalloc (size_t s) ATTRIBUTE_MALLOC;
48void *xzalloc (size_t s); 56void *xzalloc (size_t s) ATTRIBUTE_MALLOC;
49void *xcalloc (size_t n, size_t s); 57void *xcalloc (size_t n, size_t s) ATTRIBUTE_MALLOC;
50void *xrealloc (void *p, size_t s); 58void *xrealloc (void *p, size_t s);
51void *x2realloc (void *p, size_t *pn); 59void *x2realloc (void *p, size_t *pn);
52void *xmemdup (void const *p, size_t s); 60void *xmemdup (void const *p, size_t s) ATTRIBUTE_MALLOC;
53char *xstrdup (char const *str); 61char *xstrdup (char const *str) ATTRIBUTE_MALLOC;
54 62
55/* Return 1 if an array of N objects, each of size S, cannot exist due 63/* Return 1 if an array of N objects, each of size S, cannot exist due
56 to size arithmetic overflow. S must be positive and N must be 64 to size arithmetic overflow. S must be positive and N must be
@@ -97,10 +105,10 @@ char *xstrdup (char const *str);
97# if HAVE_INLINE 105# if HAVE_INLINE
98# define static_inline static inline 106# define static_inline static inline
99# else 107# else
100 void *xnmalloc (size_t n, size_t s); 108 void *xnmalloc (size_t n, size_t s) ATTRIBUTE_MALLOC;
101 void *xnrealloc (void *p, size_t n, size_t s); 109 void *xnrealloc (void *p, size_t n, size_t s);
102 void *x2nrealloc (void *p, size_t *pn, size_t s); 110 void *x2nrealloc (void *p, size_t *pn, size_t s);
103 char *xcharalloc (size_t n); 111 char *xcharalloc (size_t n) ATTRIBUTE_MALLOC;
104# endif 112# endif
105 113
106# ifdef static_inline 114# ifdef static_inline
@@ -108,6 +116,7 @@ char *xstrdup (char const *str);
108/* Allocate an array of N objects, each with S bytes of memory, 116/* Allocate an array of N objects, each with S bytes of memory,
109 dynamically, with error checking. S must be nonzero. */ 117 dynamically, with error checking. S must be nonzero. */
110 118
119static_inline void *xnmalloc (size_t n, size_t s) ATTRIBUTE_MALLOC;
111static_inline void * 120static_inline void *
112xnmalloc (size_t n, size_t s) 121xnmalloc (size_t n, size_t s)
113{ 122{
@@ -219,6 +228,7 @@ x2nrealloc (void *p, size_t *pn, size_t s)
219/* Return a pointer to a new buffer of N bytes. This is like xmalloc, 228/* Return a pointer to a new buffer of N bytes. This is like xmalloc,
220 except it returns char *. */ 229 except it returns char *. */
221 230
231static_inline char *xcharalloc (size_t n) ATTRIBUTE_MALLOC;
222static_inline char * 232static_inline char *
223xcharalloc (size_t n) 233xcharalloc (size_t n)
224{ 234{
diff --git a/gl/xmalloc.c b/gl/xmalloc.c
index 3a12345..89ecf17 100644
--- a/gl/xmalloc.c
+++ b/gl/xmalloc.c
@@ -1,7 +1,7 @@
1/* xmalloc.c -- malloc with out of memory checking 1/* xmalloc.c -- malloc with out of memory checking
2 2
3 Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 3 Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
4 1999, 2000, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, 4 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2008 Free Software Foundation,
5 Inc. 5 Inc.
6 6
7 This program is free software: you can redistribute it and/or modify 7 This program is free software: you can redistribute it and/or modify
diff --git a/gl/xsize.h b/gl/xsize.h
index b294d66..284cf7f 100644
--- a/gl/xsize.h
+++ b/gl/xsize.h
@@ -1,6 +1,6 @@
1/* xsize.h -- Checked size_t computations. 1/* xsize.h -- Checked size_t computations.
2 2
3 Copyright (C) 2003 Free Software Foundation, Inc. 3 Copyright (C) 2003, 2008 Free Software Foundation, Inc.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
@@ -94,7 +94,7 @@ xmax (size_t size1, size_t size2)
94/* Multiplication of a count with an element size, with overflow check. 94/* Multiplication of a count with an element size, with overflow check.
95 The count must be >= 0 and the element size must be > 0. 95 The count must be >= 0 and the element size must be > 0.
96 This is a macro, not an inline function, so that it works correctly even 96 This is a macro, not an inline function, so that it works correctly even
97 when N is of a wider tupe and N > SIZE_MAX. */ 97 when N is of a wider type and N > SIZE_MAX. */
98#define xtimes(N, ELSIZE) \ 98#define xtimes(N, ELSIZE) \
99 ((N) <= SIZE_MAX / (ELSIZE) ? (size_t) (N) * (ELSIZE) : SIZE_MAX) 99 ((N) <= SIZE_MAX / (ELSIZE) ? (size_t) (N) * (ELSIZE) : SIZE_MAX)
100 100