summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2013-08-19 21:27:12 (GMT)
committerHolger Weiss <holger@zedat.fu-berlin.de>2013-08-19 21:27:12 (GMT)
commit26fbe7f1e68bb0c96da32491efcf3696fe6c299b (patch)
treec4d95289187a64e9c7517bf73d8208026c3d2fb3
parent5f79e3e9f62ca5487d9881973149136ba1d19d3e (diff)
downloadmonitoring-plugins-26fbe7f1e68bb0c96da32491efcf3696fe6c299b.tar.gz
Sync with the latest Gnulib code (6f2d632)
-rwxr-xr-xbuild-aux/config.rpath106
-rw-r--r--build-aux/snippet/_Noreturn.h10
-rw-r--r--build-aux/snippet/arg-nonnull.h (renamed from build-aux/arg-nonnull.h)4
-rw-r--r--build-aux/snippet/c++defs.h (renamed from build-aux/c++defs.h)4
-rw-r--r--build-aux/snippet/warn-on-use.h (renamed from build-aux/warn-on-use.h)6
-rw-r--r--gl/Makefile.am1525
-rw-r--r--gl/alignof.h53
-rw-r--r--gl/alloca.in.h15
-rw-r--r--gl/arpa_inet.in.h89
-rw-r--r--gl/asnprintf.c5
-rw-r--r--gl/asprintf.c5
-rw-r--r--gl/base64.c20
-rw-r--r--gl/base64.h15
-rw-r--r--gl/basename-lgpl.c2
-rw-r--r--gl/basename.c6
-rw-r--r--gl/btowc.c2
-rw-r--r--gl/c-strtod.c112
-rw-r--r--gl/c-strtod.h37
-rw-r--r--gl/cloexec.c83
-rw-r--r--gl/cloexec.h38
-rw-r--r--gl/close-hook.c91
-rw-r--r--gl/close-hook.h72
-rw-r--r--gl/config.charset7
-rw-r--r--gl/dirname-lgpl.c8
-rw-r--r--gl/dirname.c2
-rw-r--r--gl/dirname.h38
-rw-r--r--gl/dosname.h53
-rw-r--r--gl/dup-safer.c34
-rw-r--r--gl/dup2.c128
-rw-r--r--gl/errno.in.h195
-rw-r--r--gl/error.c27
-rw-r--r--gl/error.h24
-rw-r--r--gl/exitfail.c3
-rw-r--r--gl/exitfail.h2
-rw-r--r--gl/fcntl--.h32
-rw-r--r--gl/fcntl-safer.h27
-rw-r--r--gl/fcntl.c294
-rw-r--r--gl/fcntl.in.h279
-rw-r--r--gl/fd-hook.c116
-rw-r--r--gl/fd-hook.h119
-rw-r--r--gl/fd-safer.c49
-rw-r--r--gl/float+.h11
-rw-r--r--gl/float.c33
-rw-r--r--gl/float.in.h138
-rw-r--r--gl/floor.c18
-rw-r--r--gl/floorf.c2
-rw-r--r--gl/fsusage.c100
-rw-r--r--gl/fsusage.h2
-rw-r--r--gl/full-read.c2
-rw-r--r--gl/full-read.h2
-rw-r--r--gl/full-write.c2
-rw-r--r--gl/full-write.h34
-rw-r--r--gl/gai_strerror.c28
-rw-r--r--gl/getaddrinfo.c28
-rw-r--r--gl/getdtablesize.c63
-rw-r--r--gl/gethostname.c3
-rw-r--r--gl/getloadavg.c234
-rw-r--r--gl/getopt.c159
-rw-r--r--gl/getopt.in.h70
-rw-r--r--gl/getopt1.c8
-rw-r--r--gl/getopt_int.h18
-rw-r--r--gl/gettext.h22
-rw-r--r--gl/glthread/lock.c1057
-rw-r--r--gl/glthread/lock.h927
-rw-r--r--gl/glthread/threadlib.c73
-rw-r--r--gl/inet_ntop.c62
-rw-r--r--gl/intprops.h318
-rw-r--r--gl/itold.c (renamed from gl/creat-safer.c)21
-rw-r--r--gl/langinfo.in.h30
-rw-r--r--gl/localcharset.c50
-rw-r--r--gl/localcharset.h5
-rw-r--r--gl/locale.in.h158
-rw-r--r--gl/localeconv.c103
-rw-r--r--gl/m4/00gnulib.m42
-rw-r--r--gl/m4/alloca.m486
-rw-r--r--gl/m4/arpa_inet_h.m420
-rw-r--r--gl/m4/asm-underscore.m448
-rw-r--r--gl/m4/base64.m45
-rw-r--r--gl/m4/btowc.m435
-rw-r--r--gl/m4/c-strtod.m457
-rw-r--r--gl/m4/codeset.m414
-rw-r--r--gl/m4/configmake.m450
-rw-r--r--gl/m4/dirname.m411
-rw-r--r--gl/m4/dos.m471
-rw-r--r--gl/m4/double-slash-root.m42
-rw-r--r--gl/m4/dup2.m458
-rw-r--r--gl/m4/eealloc.m45
-rw-r--r--gl/m4/environ.m427
-rw-r--r--gl/m4/errno_h.m428
-rw-r--r--gl/m4/error.m417
-rw-r--r--gl/m4/exponentd.m4116
-rw-r--r--gl/m4/extensions.m456
-rw-r--r--gl/m4/extern-inline.m470
-rw-r--r--gl/m4/fcntl-o.m489
-rw-r--r--gl/m4/fcntl-safer.m419
-rw-r--r--gl/m4/fcntl.m483
-rw-r--r--gl/m4/fcntl_h.m443
-rw-r--r--gl/m4/float_h.m487
-rw-r--r--gl/m4/floorf.m484
-rw-r--r--gl/m4/fstypename.m42
-rw-r--r--gl/m4/fsusage.m4107
-rw-r--r--gl/m4/getaddrinfo.m466
-rw-r--r--gl/m4/getdtablesize.m415
-rw-r--r--gl/m4/gethostname.m420
-rw-r--r--gl/m4/getloadavg.m4185
-rw-r--r--gl/m4/getopt.m4402
-rw-r--r--gl/m4/gettext.m458
-rw-r--r--gl/m4/glibc2.m47
-rw-r--r--gl/m4/glibc21.m414
-rw-r--r--gl/m4/gnulib-cache.m429
-rw-r--r--gl/m4/gnulib-common.m4192
-rw-r--r--gl/m4/gnulib-comp.m4486
-rw-r--r--gl/m4/gnulib-tool.m42
-rw-r--r--gl/m4/hostent.m412
-rw-r--r--gl/m4/iconv.m4110
-rw-r--r--gl/m4/include_next.m4167
-rw-r--r--gl/m4/inet_ntop.m464
-rw-r--r--gl/m4/inline.m440
-rw-r--r--gl/m4/intdiv0.m415
-rw-r--r--gl/m4/intl.m447
-rw-r--r--gl/m4/intldir.m42
-rw-r--r--gl/m4/intlmacosx.m425
-rw-r--r--gl/m4/intmax.m413
-rw-r--r--gl/m4/intmax_t.m415
-rw-r--r--gl/m4/inttypes-pri.m416
-rw-r--r--gl/m4/inttypes_h.m419
-rw-r--r--gl/m4/langinfo_h.m434
-rw-r--r--gl/m4/largefile.m4146
-rw-r--r--gl/m4/lcmessage.m412
-rw-r--r--gl/m4/lib-ld.m477
-rw-r--r--gl/m4/lib-link.m49
-rw-r--r--gl/m4/lib-prefix.m42
-rw-r--r--gl/m4/localcharset.m42
-rw-r--r--gl/m4/locale-fr.m4161
-rw-r--r--gl/m4/locale-ja.m497
-rw-r--r--gl/m4/locale-zh.m480
-rw-r--r--gl/m4/locale_h.m480
-rw-r--r--gl/m4/localeconv.m422
-rw-r--r--gl/m4/lock.m425
-rw-r--r--gl/m4/longlong.m487
-rw-r--r--gl/m4/ls-mntd-fs.m431
-rw-r--r--gl/m4/malloc.m470
-rw-r--r--gl/m4/malloca.m42
-rw-r--r--gl/m4/math_h.m4287
-rw-r--r--gl/m4/mbrtowc.m4281
-rw-r--r--gl/m4/mbsinit.m433
-rw-r--r--gl/m4/mbstate_t.m413
-rw-r--r--gl/m4/mbtowc.m419
-rw-r--r--gl/m4/memchr.m431
-rw-r--r--gl/m4/mktime.m4145
-rw-r--r--gl/m4/mmap-anon.m418
-rw-r--r--gl/m4/mode_t.m426
-rw-r--r--gl/m4/mountlist.m48
-rw-r--r--gl/m4/msvc-inval.m419
-rw-r--r--gl/m4/msvc-nothrow.m4 (renamed from gl/m4/cloexec.m4)8
-rw-r--r--gl/m4/multiarch.m411
-rw-r--r--gl/m4/netdb_h.m48
-rw-r--r--gl/m4/netinet_in_h.m45
-rw-r--r--gl/m4/nl_langinfo.m435
-rw-r--r--gl/m4/nls.m42
-rw-r--r--gl/m4/nocrash.m4130
-rw-r--r--gl/m4/off_t.m418
-rw-r--r--gl/m4/onceonly.m425
-rw-r--r--gl/m4/open.m474
-rw-r--r--gl/m4/po.m436
-rw-r--r--gl/m4/printf-posix.m423
-rw-r--r--gl/m4/printf.m41044
-rw-r--r--gl/m4/progtest.m421
-rw-r--r--gl/m4/read.m426
-rw-r--r--gl/m4/regex.m4157
-rw-r--r--gl/m4/safe-read.m411
-rw-r--r--gl/m4/safe-write.m418
-rw-r--r--gl/m4/servent.m412
-rw-r--r--gl/m4/setenv.m4127
-rw-r--r--gl/m4/sha1.m48
-rw-r--r--gl/m4/size_max.m416
-rw-r--r--gl/m4/snprintf.m420
-rw-r--r--gl/m4/socketlib.m486
-rw-r--r--gl/m4/sockets.m479
-rw-r--r--gl/m4/socklen.m455
-rw-r--r--gl/m4/sockpfaf.m430
-rw-r--r--gl/m4/ssize_t.m412
-rw-r--r--gl/m4/stat.m463
-rw-r--r--gl/m4/stdalign.m453
-rw-r--r--gl/m4/stdbool.m4137
-rw-r--r--gl/m4/stddef_h.m410
-rw-r--r--gl/m4/stdint.m440
-rw-r--r--gl/m4/stdint_h.m417
-rw-r--r--gl/m4/stdio_h.m497
-rw-r--r--gl/m4/stdlib_h.m449
-rw-r--r--gl/m4/strdup.m445
-rw-r--r--gl/m4/strerror.m4116
-rw-r--r--gl/m4/string_h.m420
-rw-r--r--gl/m4/strndup.m432
-rw-r--r--gl/m4/strnlen.m412
-rw-r--r--gl/m4/strsep.m48
-rw-r--r--gl/m4/strstr.m491
-rw-r--r--gl/m4/sys_socket_h.m447
-rw-r--r--gl/m4/sys_stat_h.m482
-rw-r--r--gl/m4/sys_types_h.m424
-rw-r--r--gl/m4/sys_uio_h.m431
-rw-r--r--gl/m4/threadlib.m4136
-rw-r--r--gl/m4/time_h.m410
-rw-r--r--gl/m4/time_r.m414
-rw-r--r--gl/m4/timegm.m422
-rw-r--r--gl/m4/uintmax_t.m42
-rw-r--r--gl/m4/unistd-safer.m413
-rw-r--r--gl/m4/unistd_h.m4137
-rw-r--r--gl/m4/vasnprintf.m415
-rw-r--r--gl/m4/vasprintf.m42
-rw-r--r--gl/m4/visibility.m425
-rw-r--r--gl/m4/vsnprintf.m420
-rw-r--r--gl/m4/warn-on-use.m414
-rw-r--r--gl/m4/wchar_h.m4123
-rw-r--r--gl/m4/wchar_t.m414
-rw-r--r--gl/m4/wcrtomb.m449
-rw-r--r--gl/m4/wctype_h.m4181
-rw-r--r--gl/m4/wint_t.m414
-rw-r--r--gl/m4/write.m420
-rw-r--r--gl/m4/xalloc.m424
-rw-r--r--gl/m4/xsize.m45
-rw-r--r--gl/m4/xstrndup.m42
-rw-r--r--gl/malloc.c17
-rw-r--r--gl/malloca.c45
-rw-r--r--gl/malloca.h9
-rw-r--r--gl/math.c3
-rw-r--r--gl/math.in.h1675
-rw-r--r--gl/mbrtowc.c48
-rw-r--r--gl/mbsinit.c18
-rw-r--r--gl/mbtowc-impl.h44
-rw-r--r--gl/mbtowc.c (renamed from gl/safe-write.c)16
-rw-r--r--gl/memchr.c2
-rw-r--r--gl/mktime.c544
-rw-r--r--gl/mountlist.c182
-rw-r--r--gl/mountlist.h3
-rw-r--r--gl/msvc-inval.c129
-rw-r--r--gl/msvc-inval.h222
-rw-r--r--gl/msvc-nothrow.c49
-rw-r--r--gl/msvc-nothrow.h43
-rw-r--r--gl/netdb.in.h105
-rw-r--r--gl/netinet_in.in.h16
-rw-r--r--gl/nl_langinfo.c15
-rw-r--r--gl/open-safer.c46
-rw-r--r--gl/open.c166
-rw-r--r--gl/pipe-safer.c56
-rw-r--r--gl/printf-args.c5
-rw-r--r--gl/printf-args.h9
-rw-r--r--gl/printf-parse.c55
-rw-r--r--gl/printf-parse.h19
-rw-r--r--gl/read.c85
-rw-r--r--gl/ref-add.sin5
-rw-r--r--gl/ref-del.sin5
-rw-r--r--gl/regcomp.c359
-rw-r--r--gl/regex.c37
-rw-r--r--gl/regex.h259
-rw-r--r--gl/regex_internal.c99
-rw-r--r--gl/regex_internal.h194
-rw-r--r--gl/regexec.c214
-rw-r--r--gl/safe-read.c2
-rw-r--r--gl/safe-read.h15
-rw-r--r--gl/safe-write.h24
-rw-r--r--gl/setenv.c28
-rw-r--r--gl/sha1.c20
-rw-r--r--gl/sha1.h5
-rw-r--r--gl/size_max.h5
-rw-r--r--gl/snprintf.c5
-rw-r--r--gl/sockets.c50
-rw-r--r--gl/sockets.h17
-rw-r--r--gl/stat.c104
-rw-r--r--gl/stdalign.in.h109
-rw-r--r--gl/stdbool.in.h56
-rw-r--r--gl/stddef.in.h20
-rw-r--r--gl/stdint.in.h286
-rw-r--r--gl/stdio-write.c148
-rw-r--r--gl/stdio.in.h461
-rw-r--r--gl/stdlib.in.h332
-rw-r--r--gl/str-two-way.h38
-rw-r--r--gl/strdup.c55
-rw-r--r--gl/streq.h12
-rw-r--r--gl/strerror-override.c302
-rw-r--r--gl/strerror-override.h56
-rw-r--r--gl/strerror.c354
-rw-r--r--gl/string.in.h160
-rw-r--r--gl/stripslash.c4
-rw-r--r--gl/strndup.c7
-rw-r--r--gl/strnlen.c5
-rw-r--r--gl/strsep.c5
-rw-r--r--gl/strstr.c7
-rw-r--r--gl/sys_socket.c3
-rw-r--r--gl/sys_socket.in.h163
-rw-r--r--gl/sys_stat.in.h640
-rw-r--r--gl/sys_types.in.h51
-rw-r--r--gl/sys_uio.in.h63
-rw-r--r--gl/time.in.h37
-rw-r--r--gl/time_r.c5
-rw-r--r--gl/timegm.c5
-rw-r--r--gl/unistd--.h32
-rw-r--r--gl/unistd-safer.h31
-rw-r--r--gl/unistd.c3
-rw-r--r--gl/unistd.in.h510
-rw-r--r--gl/unsetenv.c15
-rw-r--r--gl/vasnprintf.c140
-rw-r--r--gl/vasnprintf.h19
-rw-r--r--gl/vasprintf.c5
-rw-r--r--gl/verify.h180
-rw-r--r--gl/vsnprintf.c5
-rw-r--r--gl/w32sock.h89
-rw-r--r--gl/wchar.in.h636
-rw-r--r--gl/wcrtomb.c2
-rw-r--r--gl/wctype-h.c4
-rw-r--r--gl/wctype.in.h368
-rw-r--r--gl/write.c62
-rw-r--r--gl/xalloc-die.c6
-rw-r--r--gl/xalloc-oversized.h38
-rw-r--r--gl/xalloc.h133
-rw-r--r--gl/xmalloc.c24
-rw-r--r--gl/xsize.c3
-rw-r--r--gl/xsize.h22
-rw-r--r--gl/xstrndup.c2
-rw-r--r--gl/xstrndup.h2
320 files changed, 17703 insertions, 9646 deletions
diff --git a/build-aux/config.rpath b/build-aux/config.rpath
index 17298f2..c38b914 100755
--- a/build-aux/config.rpath
+++ b/build-aux/config.rpath
@@ -2,7 +2,7 @@
2# Output a system dependent set of variables, describing how to set the 2# Output a system dependent set of variables, describing how to set the
3# run time search path of shared libraries in an executable. 3# run time search path of shared libraries in an executable.
4# 4#
5# Copyright 1996-2010 Free Software Foundation, Inc. 5# Copyright 1996-2013 Free Software Foundation, Inc.
6# Taken from GNU libtool, 2001 6# Taken from GNU libtool, 2001
7# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 7# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
8# 8#
@@ -25,7 +25,7 @@
25# known workaround is to choose shorter directory names for the build 25# known workaround is to choose shorter directory names for the build
26# directory and/or the installation directory. 26# directory and/or the installation directory.
27 27
28# All known linkers require a `.a' archive for static linking (except MSVC, 28# All known linkers require a '.a' archive for static linking (except MSVC,
29# which needs '.lib'). 29# which needs '.lib').
30libext=a 30libext=a
31shrext=.so 31shrext=.so
@@ -57,13 +57,6 @@ else
57 aix*) 57 aix*)
58 wl='-Wl,' 58 wl='-Wl,'
59 ;; 59 ;;
60 darwin*)
61 case $cc_basename in
62 xlc*)
63 wl='-Wl,'
64 ;;
65 esac
66 ;;
67 mingw* | cygwin* | pw32* | os2* | cegcc*) 60 mingw* | cygwin* | pw32* | os2* | cegcc*)
68 ;; 61 ;;
69 hpux9* | hpux10* | hpux11*) 62 hpux9* | hpux10* | hpux11*)
@@ -72,9 +65,7 @@ else
72 irix5* | irix6* | nonstopux*) 65 irix5* | irix6* | nonstopux*)
73 wl='-Wl,' 66 wl='-Wl,'
74 ;; 67 ;;
75 newsos6) 68 linux* | k*bsd*-gnu | kopensolaris*-gnu)
76 ;;
77 linux* | k*bsd*-gnu)
78 case $cc_basename in 69 case $cc_basename in
79 ecc*) 70 ecc*)
80 wl='-Wl,' 71 wl='-Wl,'
@@ -85,17 +76,26 @@ else
85 lf95*) 76 lf95*)
86 wl='-Wl,' 77 wl='-Wl,'
87 ;; 78 ;;
88 pgcc | pgf77 | pgf90) 79 nagfor*)
80 wl='-Wl,-Wl,,'
81 ;;
82 pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
89 wl='-Wl,' 83 wl='-Wl,'
90 ;; 84 ;;
91 ccc*) 85 ccc*)
92 wl='-Wl,' 86 wl='-Wl,'
93 ;; 87 ;;
88 xl* | bgxl* | bgf* | mpixl*)
89 wl='-Wl,'
90 ;;
94 como) 91 como)
95 wl='-lopt=' 92 wl='-lopt='
96 ;; 93 ;;
97 *) 94 *)
98 case `$CC -V 2>&1 | sed 5q` in 95 case `$CC -V 2>&1 | sed 5q` in
96 *Sun\ F* | *Sun*Fortran*)
97 wl=
98 ;;
99 *Sun\ C*) 99 *Sun\ C*)
100 wl='-Wl,' 100 wl='-Wl,'
101 ;; 101 ;;
@@ -103,13 +103,24 @@ else
103 ;; 103 ;;
104 esac 104 esac
105 ;; 105 ;;
106 newsos6)
107 ;;
108 *nto* | *qnx*)
109 ;;
106 osf3* | osf4* | osf5*) 110 osf3* | osf4* | osf5*)
107 wl='-Wl,' 111 wl='-Wl,'
108 ;; 112 ;;
109 rdos*) 113 rdos*)
110 ;; 114 ;;
111 solaris*) 115 solaris*)
112 wl='-Wl,' 116 case $cc_basename in
117 f77* | f90* | f95* | sunf77* | sunf90* | sunf95*)
118 wl='-Qoption ld '
119 ;;
120 *)
121 wl='-Wl,'
122 ;;
123 esac
113 ;; 124 ;;
114 sunos4*) 125 sunos4*)
115 wl='-Qoption ld ' 126 wl='-Qoption ld '
@@ -171,15 +182,14 @@ if test "$with_gnu_ld" = yes; then
171 fi 182 fi
172 ;; 183 ;;
173 amigaos*) 184 amigaos*)
174 hardcode_libdir_flag_spec='-L$libdir' 185 case "$host_cpu" in
175 hardcode_minus_L=yes 186 powerpc)
176 # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports 187 ;;
177 # that the semantics of dynamic libraries on AmigaOS, at least up 188 m68k)
178 # to version 4, is to share data among multiple programs linked 189 hardcode_libdir_flag_spec='-L$libdir'
179 # with the same dynamic library. Since this doesn't match the 190 hardcode_minus_L=yes
180 # behavior of shared libraries on other platforms, we cannot use 191 ;;
181 # them. 192 esac
182 ld_shlibs=no
183 ;; 193 ;;
184 beos*) 194 beos*)
185 if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then 195 if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
@@ -198,11 +208,13 @@ if test "$with_gnu_ld" = yes; then
198 ld_shlibs=no 208 ld_shlibs=no
199 fi 209 fi
200 ;; 210 ;;
211 haiku*)
212 ;;
201 interix[3-9]*) 213 interix[3-9]*)
202 hardcode_direct=no 214 hardcode_direct=no
203 hardcode_libdir_flag_spec='${wl}-rpath,$libdir' 215 hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
204 ;; 216 ;;
205 gnu* | linux* | k*bsd*-gnu) 217 gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
206 if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then 218 if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
207 : 219 :
208 else 220 else
@@ -325,10 +337,14 @@ else
325 fi 337 fi
326 ;; 338 ;;
327 amigaos*) 339 amigaos*)
328 hardcode_libdir_flag_spec='-L$libdir' 340 case "$host_cpu" in
329 hardcode_minus_L=yes 341 powerpc)
330 # see comment about different semantics on the GNU ld section 342 ;;
331 ld_shlibs=no 343 m68k)
344 hardcode_libdir_flag_spec='-L$libdir'
345 hardcode_minus_L=yes
346 ;;
347 esac
332 ;; 348 ;;
333 bsdi[45]*) 349 bsdi[45]*)
334 ;; 350 ;;
@@ -342,24 +358,15 @@ else
342 ;; 358 ;;
343 darwin* | rhapsody*) 359 darwin* | rhapsody*)
344 hardcode_direct=no 360 hardcode_direct=no
345 if test "$GCC" = yes ; then 361 if { case $cc_basename in ifort*) true;; *) test "$GCC" = yes;; esac; }; then
346 : 362 :
347 else 363 else
348 case $cc_basename in 364 ld_shlibs=no
349 xlc*)
350 ;;
351 *)
352 ld_shlibs=no
353 ;;
354 esac
355 fi 365 fi
356 ;; 366 ;;
357 dgux*) 367 dgux*)
358 hardcode_libdir_flag_spec='-L$libdir' 368 hardcode_libdir_flag_spec='-L$libdir'
359 ;; 369 ;;
360 freebsd1*)
361 ld_shlibs=no
362 ;;
363 freebsd2.2*) 370 freebsd2.2*)
364 hardcode_libdir_flag_spec='-R$libdir' 371 hardcode_libdir_flag_spec='-R$libdir'
365 hardcode_direct=yes 372 hardcode_direct=yes
@@ -420,6 +427,8 @@ else
420 hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' 427 hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
421 hardcode_libdir_separator=: 428 hardcode_libdir_separator=:
422 ;; 429 ;;
430 *nto* | *qnx*)
431 ;;
423 openbsd*) 432 openbsd*)
424 if test -f /usr/libexec/ld.so; then 433 if test -f /usr/libexec/ld.so; then
425 hardcode_direct=yes 434 hardcode_direct=yes
@@ -515,7 +524,12 @@ case "$host_os" in
515 library_names_spec='$libname$shrext' 524 library_names_spec='$libname$shrext'
516 ;; 525 ;;
517 amigaos*) 526 amigaos*)
518 library_names_spec='$libname.a' 527 case "$host_cpu" in
528 powerpc*)
529 library_names_spec='$libname$shrext' ;;
530 m68k)
531 library_names_spec='$libname.a' ;;
532 esac
519 ;; 533 ;;
520 beos*) 534 beos*)
521 library_names_spec='$libname$shrext' 535 library_names_spec='$libname$shrext'
@@ -534,8 +548,6 @@ case "$host_os" in
534 dgux*) 548 dgux*)
535 library_names_spec='$libname$shrext' 549 library_names_spec='$libname$shrext'
536 ;; 550 ;;
537 freebsd1*)
538 ;;
539 freebsd* | dragonfly*) 551 freebsd* | dragonfly*)
540 case "$host_os" in 552 case "$host_os" in
541 freebsd[123]*) 553 freebsd[123]*)
@@ -547,6 +559,9 @@ case "$host_os" in
547 gnu*) 559 gnu*)
548 library_names_spec='$libname$shrext' 560 library_names_spec='$libname$shrext'
549 ;; 561 ;;
562 haiku*)
563 library_names_spec='$libname$shrext'
564 ;;
550 hpux9* | hpux10* | hpux11*) 565 hpux9* | hpux10* | hpux11*)
551 case $host_cpu in 566 case $host_cpu in
552 ia64*) 567 ia64*)
@@ -582,7 +597,7 @@ case "$host_os" in
582 ;; 597 ;;
583 linux*oldld* | linux*aout* | linux*coff*) 598 linux*oldld* | linux*aout* | linux*coff*)
584 ;; 599 ;;
585 linux* | k*bsd*-gnu) 600 linux* | k*bsd*-gnu | kopensolaris*-gnu)
586 library_names_spec='$libname$shrext' 601 library_names_spec='$libname$shrext'
587 ;; 602 ;;
588 knetbsd*-gnu) 603 knetbsd*-gnu)
@@ -594,7 +609,7 @@ case "$host_os" in
594 newsos6) 609 newsos6)
595 library_names_spec='$libname$shrext' 610 library_names_spec='$libname$shrext'
596 ;; 611 ;;
597 nto-qnx*) 612 *nto* | *qnx*)
598 library_names_spec='$libname$shrext' 613 library_names_spec='$libname$shrext'
599 ;; 614 ;;
600 openbsd*) 615 openbsd*)
@@ -625,6 +640,9 @@ case "$host_os" in
625 sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) 640 sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
626 library_names_spec='$libname$shrext' 641 library_names_spec='$libname$shrext'
627 ;; 642 ;;
643 tpf*)
644 library_names_spec='$libname$shrext'
645 ;;
628 uts4*) 646 uts4*)
629 library_names_spec='$libname$shrext' 647 library_names_spec='$libname$shrext'
630 ;; 648 ;;
diff --git a/build-aux/snippet/_Noreturn.h b/build-aux/snippet/_Noreturn.h
new file mode 100644
index 0000000..c44ad89
--- /dev/null
+++ b/build-aux/snippet/_Noreturn.h
@@ -0,0 +1,10 @@
1#if !defined _Noreturn && __STDC_VERSION__ < 201112
2# if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \
3 || 0x5110 <= __SUNPRO_C)
4# define _Noreturn __attribute__ ((__noreturn__))
5# elif 1200 <= _MSC_VER
6# define _Noreturn __declspec (noreturn)
7# else
8# define _Noreturn
9# endif
10#endif
diff --git a/build-aux/arg-nonnull.h b/build-aux/snippet/arg-nonnull.h
index 7e3e2db..8ea2a47 100644
--- a/build-aux/arg-nonnull.h
+++ b/build-aux/snippet/arg-nonnull.h
@@ -1,5 +1,5 @@
1/* A C macro for declaring that specific arguments must not be NULL. 1/* A C macro for declaring that specific arguments must not be NULL.
2 Copyright (C) 2009, 2010 Free Software Foundation, Inc. 2 Copyright (C) 2009-2013 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify it 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 5 under the terms of the GNU General Public License as published
@@ -9,7 +9,7 @@
9 This program is distributed in the hope that it will be useful, 9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details. 12 General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 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/>. */ 15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
diff --git a/build-aux/c++defs.h b/build-aux/snippet/c++defs.h
index 0c2fad7..b35b933 100644
--- a/build-aux/c++defs.h
+++ b/build-aux/snippet/c++defs.h
@@ -1,5 +1,5 @@
1/* C++ compatible function declaration macros. 1/* C++ compatible function declaration macros.
2 Copyright (C) 2010 Free Software Foundation, Inc. 2 Copyright (C) 2010-2013 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify it 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 5 under the terms of the GNU General Public License as published
@@ -9,7 +9,7 @@
9 This program is distributed in the hope that it will be useful, 9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details. 12 General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 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/>. */ 15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
diff --git a/build-aux/warn-on-use.h b/build-aux/snippet/warn-on-use.h
index 171e599..1736a1b 100644
--- a/build-aux/warn-on-use.h
+++ b/build-aux/snippet/warn-on-use.h
@@ -1,5 +1,5 @@
1/* A C macro for emitting warnings if a function is used. 1/* A C macro for emitting warnings if a function is used.
2 Copyright (C) 2010 Free Software Foundation, Inc. 2 Copyright (C) 2010-2013 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify it 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 5 under the terms of the GNU General Public License as published
@@ -9,7 +9,7 @@
9 This program is distributed in the hope that it will be useful, 9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details. 12 General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 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/>. */ 15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
@@ -55,7 +55,7 @@
55 rather than issue the nice warning, but the end result of informing 55 rather than issue the nice warning, but the end result of informing
56 the developer about their portability problem is still achieved): 56 the developer about their portability problem is still achieved):
57 #if HAVE_RAW_DECL_ENVIRON 57 #if HAVE_RAW_DECL_ENVIRON
58 static inline char ***rpl_environ (void) { return &environ; } 58 static char ***rpl_environ (void) { return &environ; }
59 _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared"); 59 _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
60 # undef environ 60 # undef environ
61 # define environ (*rpl_environ ()) 61 # define environ (*rpl_environ ())
diff --git a/gl/Makefile.am b/gl/Makefile.am
index edc7db1..d3a6450 100644
--- a/gl/Makefile.am
+++ b/gl/Makefile.am
@@ -1,17 +1,29 @@
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) 2002-2010 Free Software Foundation, Inc. 3# Copyright (C) 2002-2013 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; you can redistribute it and/or modify
6# General Public License. As a special exception to the GNU General 6# it under the terms of the GNU General Public License as published by
7# Public License, this file may be distributed as part of a program 7# the Free Software Foundation; either version 3 of the License, or
8# that contains a configuration script generated by Autoconf, under 8# (at your option) any later version.
9#
10# This file 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 file. If not, see <http://www.gnu.org/licenses/>.
17#
18# As a special exception to the GNU General Public License,
19# this file may be distributed as part of a program that
20# contains a configuration script generated by Autoconf, under
9# the same distribution terms as the rest of that program. 21# the same distribution terms as the rest of that program.
10# 22#
11# Generated by gnulib-tool. 23# Generated by gnulib-tool.
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 --no-vc-files base64 crypto/sha1 dirname environ floorf fsusage getaddrinfo gethostname getloadavg getopt gettext mountlist regex setenv strsep timegm unsetenv vasprintf vsnprintf 24# 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-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files base64 crypto/sha1 dirname environ floorf fsusage getaddrinfo gethostname getloadavg getopt gettext mountlist regex setenv strsep timegm unsetenv vasprintf vsnprintf
13 25
14AUTOMAKE_OPTIONS = 1.5 gnits 26AUTOMAKE_OPTIONS = 1.9.6 gnits subdir-objects
15 27
16SUBDIRS = 28SUBDIRS =
17noinst_HEADERS = 29noinst_HEADERS =
@@ -37,73 +49,53 @@ libgnu_a_LIBADD = $(gl_LIBOBJS)
37libgnu_a_DEPENDENCIES = $(gl_LIBOBJS) 49libgnu_a_DEPENDENCIES = $(gl_LIBOBJS)
38EXTRA_libgnu_a_SOURCES = 50EXTRA_libgnu_a_SOURCES =
39 51
40## begin gnulib module alignof
41
42
43EXTRA_DIST += alignof.h
44
45## end gnulib module alignof
46
47## begin gnulib module alloca-opt 52## begin gnulib module alloca-opt
48 53
49BUILT_SOURCES += $(ALLOCA_H) 54BUILT_SOURCES += $(ALLOCA_H)
50 55
51# We need the following in order to create <alloca.h> when the system 56# We need the following in order to create <alloca.h> when the system
52# doesn't have one that works with the given compiler. 57# doesn't have one that works with the given compiler.
53alloca.h: alloca.in.h 58if GL_GENERATE_ALLOCA_H
59alloca.h: alloca.in.h $(top_builddir)/config.status
54 $(AM_V_GEN)rm -f $@-t $@ && \ 60 $(AM_V_GEN)rm -f $@-t $@ && \
55 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 61 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
56 cat $(srcdir)/alloca.in.h; \ 62 cat $(srcdir)/alloca.in.h; \
57 } > $@-t && \ 63 } > $@-t && \
58 mv -f $@-t $@ 64 mv -f $@-t $@
65else
66alloca.h: $(top_builddir)/config.status
67 rm -f $@
68endif
59MOSTLYCLEANFILES += alloca.h alloca.h-t 69MOSTLYCLEANFILES += alloca.h alloca.h-t
60 70
61EXTRA_DIST += alloca.in.h 71EXTRA_DIST += alloca.in.h
62 72
63## end gnulib module alloca-opt 73## end gnulib module alloca-opt
64 74
65## begin gnulib module arg-nonnull
66
67# The BUILT_SOURCES created by this Makefile snippet are not used via #include
68# statements but through direct file reference. Therefore this snippet must be
69# present in all Makefile.am that need it. This is ensured by the applicability
70# 'all' defined above.
71
72BUILT_SOURCES += arg-nonnull.h
73# The arg-nonnull.h that gets inserted into generated .h files is the same as
74# build-aux/arg-nonnull.h, except that it has the copyright header cut off.
75arg-nonnull.h: $(top_srcdir)/build-aux/arg-nonnull.h
76 $(AM_V_GEN)rm -f $@-t $@ && \
77 sed -n -e '/GL_ARG_NONNULL/,$$p' \
78 < $(top_srcdir)/build-aux/arg-nonnull.h \
79 > $@-t && \
80 mv $@-t $@
81MOSTLYCLEANFILES += arg-nonnull.h arg-nonnull.h-t
82
83ARG_NONNULL_H=arg-nonnull.h
84
85EXTRA_DIST += $(top_srcdir)/build-aux/arg-nonnull.h
86
87## end gnulib module arg-nonnull
88
89## begin gnulib module arpa_inet 75## begin gnulib module arpa_inet
90 76
91BUILT_SOURCES += arpa/inet.h 77BUILT_SOURCES += arpa/inet.h
92 78
93# We need the following in order to create <arpa/inet.h> when the system 79# We need the following in order to create <arpa/inet.h> when the system
94# doesn't have one. 80# doesn't have one.
95arpa/inet.h: arpa_inet.in.h $(WARN_ON_USE_H) $(ARG_NONNULL_H) 81arpa/inet.h: arpa_inet.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
96 $(AM_V_at)$(MKDIR_P) arpa 82 $(AM_V_at)$(MKDIR_P) arpa
97 $(AM_V_GEN)rm -f $@-t $@ && \ 83 $(AM_V_GEN)rm -f $@-t $@ && \
98 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 84 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
99 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 85 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
86 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
100 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 87 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
88 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
89 -e 's|@''HAVE_FEATURES_H''@|$(HAVE_FEATURES_H)|g' \
101 -e 's|@''NEXT_ARPA_INET_H''@|$(NEXT_ARPA_INET_H)|g' \ 90 -e 's|@''NEXT_ARPA_INET_H''@|$(NEXT_ARPA_INET_H)|g' \
102 -e 's|@''HAVE_ARPA_INET_H''@|$(HAVE_ARPA_INET_H)|g' \ 91 -e 's|@''HAVE_ARPA_INET_H''@|$(HAVE_ARPA_INET_H)|g' \
103 -e 's|@''GNULIB_INET_NTOP''@|$(GNULIB_INET_NTOP)|g' \ 92 -e 's/@''GNULIB_INET_NTOP''@/$(GNULIB_INET_NTOP)/g' \
104 -e 's|@''GNULIB_INET_PTON''@|$(GNULIB_INET_PTON)|g' \ 93 -e 's/@''GNULIB_INET_PTON''@/$(GNULIB_INET_PTON)/g' \
105 -e 's|@''HAVE_DECL_INET_NTOP''@|$(HAVE_DECL_INET_NTOP)|g' \ 94 -e 's|@''HAVE_DECL_INET_NTOP''@|$(HAVE_DECL_INET_NTOP)|g' \
106 -e 's|@''HAVE_DECL_INET_PTON''@|$(HAVE_DECL_INET_PTON)|g' \ 95 -e 's|@''HAVE_DECL_INET_PTON''@|$(HAVE_DECL_INET_PTON)|g' \
96 -e 's|@''REPLACE_INET_NTOP''@|$(REPLACE_INET_NTOP)|g' \
97 -e 's|@''REPLACE_INET_PTON''@|$(REPLACE_INET_PTON)|g' \
98 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
107 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 99 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
108 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ 100 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
109 < $(srcdir)/arpa_inet.in.h; \ 101 < $(srcdir)/arpa_inet.in.h; \
@@ -131,73 +123,10 @@ EXTRA_libgnu_a_SOURCES += btowc.c
131 123
132## end gnulib module btowc 124## end gnulib module btowc
133 125
134## begin gnulib module c++defs
135
136# The BUILT_SOURCES created by this Makefile snippet are not used via #include
137# statements but through direct file reference. Therefore this snippet must be
138# present in all Makefile.am that need it. This is ensured by the applicability
139# 'all' defined above.
140
141BUILT_SOURCES += c++defs.h
142# The c++defs.h that gets inserted into generated .h files is the same as
143# build-aux/c++defs.h, except that it has the copyright header cut off.
144c++defs.h: $(top_srcdir)/build-aux/c++defs.h
145 $(AM_V_GEN)rm -f $@-t $@ && \
146 sed -n -e '/_GL_CXXDEFS/,$$p' \
147 < $(top_srcdir)/build-aux/c++defs.h \
148 > $@-t && \
149 mv $@-t $@
150MOSTLYCLEANFILES += c++defs.h c++defs.h-t
151
152CXXDEFS_H=c++defs.h
153
154EXTRA_DIST += $(top_srcdir)/build-aux/c++defs.h
155
156## end gnulib module c++defs
157
158## begin gnulib module c-strtod
159
160
161EXTRA_DIST += c-strtod.c c-strtod.h
162
163EXTRA_libgnu_a_SOURCES += c-strtod.c
164
165## end gnulib module c-strtod
166
167## begin gnulib module cloexec
168
169
170EXTRA_DIST += cloexec.c cloexec.h
171
172EXTRA_libgnu_a_SOURCES += cloexec.c
173
174## end gnulib module cloexec
175
176## begin gnulib module close-hook
177
178libgnu_a_SOURCES += close-hook.c
179
180EXTRA_DIST += close-hook.h
181
182## end gnulib module close-hook
183
184## begin gnulib module configmake 126## begin gnulib module configmake
185 127
186# Retrieve values of the variables through 'configure' followed by 128# Listed in the same order as the GNU makefile conventions, and
187# 'make', not directly through 'configure', so that a user who 129# provided by autoconf 2.59c+.
188# sets some of these variables consistently on the 'make' command
189# line gets correct results.
190#
191# One advantage of this approach, compared to the classical
192# approach of adding -DLIBDIR=\"$(libdir)\" etc. to AM_CPPFLAGS,
193# is that it protects against the use of undefined variables.
194# If, say, $(libdir) is not set in the Makefile, LIBDIR is not
195# defined by this module, and code using LIBDIR gives a
196# compilation error.
197#
198# Another advantage is that 'make' output is shorter.
199#
200# Listed in the same order as the GNU makefile conventions.
201# The Automake-defined pkg* macros are appended, in the order 130# The Automake-defined pkg* macros are appended, in the order
202# listed in the Automake 1.10a+ documentation. 131# listed in the Automake 1.10a+ documentation.
203configmake.h: Makefile 132configmake.h: Makefile
@@ -231,11 +160,7 @@ configmake.h: Makefile
231 echo '#define PKGLIBDIR "$(pkglibdir)"'; \ 160 echo '#define PKGLIBDIR "$(pkglibdir)"'; \
232 echo '#define PKGLIBEXECDIR "$(pkglibexecdir)"'; \ 161 echo '#define PKGLIBEXECDIR "$(pkglibexecdir)"'; \
233 } | sed '/""/d' > $@-t && \ 162 } | sed '/""/d' > $@-t && \
234 if test -f $@ && cmp $@-t $@ > /dev/null; then \ 163 mv -f $@-t $@
235 rm -f $@-t; \
236 else \
237 rm -f $@; mv $@-t $@; \
238 fi
239 164
240BUILT_SOURCES += configmake.h 165BUILT_SOURCES += configmake.h
241CLEANFILES += configmake.h configmake.h-t 166CLEANFILES += configmake.h configmake.h-t
@@ -244,39 +169,36 @@ CLEANFILES += configmake.h configmake.h-t
244 169
245## begin gnulib module crypto/sha1 170## begin gnulib module crypto/sha1
246 171
172libgnu_a_SOURCES += sha1.c
247 173
248EXTRA_DIST += sha1.c sha1.h 174EXTRA_DIST += sha1.h
249
250EXTRA_libgnu_a_SOURCES += sha1.c
251 175
252## end gnulib module crypto/sha1 176## end gnulib module crypto/sha1
253 177
254## begin gnulib module dirname 178## begin gnulib module dirname
255 179
180libgnu_a_SOURCES += dirname.c basename.c
256 181
257EXTRA_DIST += basename.c dirname.c stripslash.c 182EXTRA_DIST += stripslash.c
258 183
259EXTRA_libgnu_a_SOURCES += basename.c dirname.c stripslash.c 184EXTRA_libgnu_a_SOURCES += stripslash.c
260 185
261## end gnulib module dirname 186## end gnulib module dirname
262 187
263## begin gnulib module dirname-lgpl 188## begin gnulib module dirname-lgpl
264 189
190libgnu_a_SOURCES += dirname-lgpl.c basename-lgpl.c stripslash.c
265 191
266EXTRA_DIST += basename-lgpl.c dirname-lgpl.c dirname.h stripslash.c 192EXTRA_DIST += dirname.h
267
268EXTRA_libgnu_a_SOURCES += basename-lgpl.c dirname-lgpl.c stripslash.c
269 193
270## end gnulib module dirname-lgpl 194## end gnulib module dirname-lgpl
271 195
272## begin gnulib module dup2 196## begin gnulib module dosname
273 197
274 198
275EXTRA_DIST += dup2.c 199EXTRA_DIST += dosname.h
276 200
277EXTRA_libgnu_a_SOURCES += dup2.c 201## end gnulib module dosname
278
279## end gnulib module dup2
280 202
281## begin gnulib module errno 203## begin gnulib module errno
282 204
@@ -284,11 +206,14 @@ BUILT_SOURCES += $(ERRNO_H)
284 206
285# We need the following in order to create <errno.h> when the system 207# We need the following in order to create <errno.h> when the system
286# doesn't have one that is POSIX compliant. 208# doesn't have one that is POSIX compliant.
287errno.h: errno.in.h 209if GL_GENERATE_ERRNO_H
210errno.h: errno.in.h $(top_builddir)/config.status
288 $(AM_V_GEN)rm -f $@-t $@ && \ 211 $(AM_V_GEN)rm -f $@-t $@ && \
289 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 212 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
290 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 213 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
214 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
291 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 215 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
216 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
292 -e 's|@''NEXT_ERRNO_H''@|$(NEXT_ERRNO_H)|g' \ 217 -e 's|@''NEXT_ERRNO_H''@|$(NEXT_ERRNO_H)|g' \
293 -e 's|@''EMULTIHOP_HIDDEN''@|$(EMULTIHOP_HIDDEN)|g' \ 218 -e 's|@''EMULTIHOP_HIDDEN''@|$(EMULTIHOP_HIDDEN)|g' \
294 -e 's|@''EMULTIHOP_VALUE''@|$(EMULTIHOP_VALUE)|g' \ 219 -e 's|@''EMULTIHOP_VALUE''@|$(EMULTIHOP_VALUE)|g' \
@@ -299,6 +224,10 @@ errno.h: errno.in.h
299 < $(srcdir)/errno.in.h; \ 224 < $(srcdir)/errno.in.h; \
300 } > $@-t && \ 225 } > $@-t && \
301 mv $@-t $@ 226 mv $@-t $@
227else
228errno.h: $(top_builddir)/config.status
229 rm -f $@
230endif
302MOSTLYCLEANFILES += errno.h errno.h-t 231MOSTLYCLEANFILES += errno.h errno.h-t
303 232
304EXTRA_DIST += errno.in.h 233EXTRA_DIST += errno.in.h
@@ -322,55 +251,13 @@ EXTRA_DIST += exitfail.h
322 251
323## end gnulib module exitfail 252## end gnulib module exitfail
324 253
325## begin gnulib module fcntl 254## begin gnulib module fd-hook
326 255
256libgnu_a_SOURCES += fd-hook.c
327 257
328EXTRA_DIST += fcntl.c 258EXTRA_DIST += fd-hook.h
329 259
330EXTRA_libgnu_a_SOURCES += fcntl.c 260## end gnulib module fd-hook
331
332## end gnulib module fcntl
333
334## begin gnulib module fcntl-h
335
336BUILT_SOURCES += fcntl.h
337
338# We need the following in order to create <fcntl.h> when the system
339# doesn't have one that works with the given compiler.
340fcntl.h: fcntl.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
341 $(AM_V_GEN)rm -f $@-t $@ && \
342 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
343 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
344 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
345 -e 's|@''NEXT_FCNTL_H''@|$(NEXT_FCNTL_H)|g' \
346 -e 's|@''GNULIB_FCNTL''@|$(GNULIB_FCNTL)|g' \
347 -e 's|@''GNULIB_OPEN''@|$(GNULIB_OPEN)|g' \
348 -e 's|@''GNULIB_OPENAT''@|$(GNULIB_OPENAT)|g' \
349 -e 's|@''HAVE_FCNTL''@|$(HAVE_FCNTL)|g' \
350 -e 's|@''HAVE_OPENAT''@|$(HAVE_OPENAT)|g' \
351 -e 's|@''REPLACE_FCNTL''@|$(REPLACE_FCNTL)|g' \
352 -e 's|@''REPLACE_OPEN''@|$(REPLACE_OPEN)|g' \
353 -e 's|@''REPLACE_OPENAT''@|$(REPLACE_OPENAT)|g' \
354 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
355 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
356 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
357 < $(srcdir)/fcntl.in.h; \
358 } > $@-t && \
359 mv $@-t $@
360MOSTLYCLEANFILES += fcntl.h fcntl.h-t
361
362EXTRA_DIST += fcntl.in.h
363
364## end gnulib module fcntl-h
365
366## begin gnulib module fcntl-safer
367
368
369EXTRA_DIST += creat-safer.c fcntl--.h fcntl-safer.h open-safer.c
370
371EXTRA_libgnu_a_SOURCES += creat-safer.c open-safer.c
372
373## end gnulib module fcntl-safer
374 261
375## begin gnulib module float 262## begin gnulib module float
376 263
@@ -378,18 +265,28 @@ BUILT_SOURCES += $(FLOAT_H)
378 265
379# We need the following in order to create <float.h> when the system 266# We need the following in order to create <float.h> when the system
380# doesn't have one that works with the given compiler. 267# doesn't have one that works with the given compiler.
381float.h: float.in.h 268if GL_GENERATE_FLOAT_H
269float.h: float.in.h $(top_builddir)/config.status
382 $(AM_V_GEN)rm -f $@-t $@ && \ 270 $(AM_V_GEN)rm -f $@-t $@ && \
383 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 271 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
384 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 272 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
273 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
385 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 274 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
275 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
386 -e 's|@''NEXT_FLOAT_H''@|$(NEXT_FLOAT_H)|g' \ 276 -e 's|@''NEXT_FLOAT_H''@|$(NEXT_FLOAT_H)|g' \
277 -e 's|@''REPLACE_ITOLD''@|$(REPLACE_ITOLD)|g' \
387 < $(srcdir)/float.in.h; \ 278 < $(srcdir)/float.in.h; \
388 } > $@-t && \ 279 } > $@-t && \
389 mv $@-t $@ 280 mv $@-t $@
281else
282float.h: $(top_builddir)/config.status
283 rm -f $@
284endif
390MOSTLYCLEANFILES += float.h float.h-t 285MOSTLYCLEANFILES += float.h float.h-t
391 286
392EXTRA_DIST += float.in.h 287EXTRA_DIST += float.c float.in.h itold.c
288
289EXTRA_libgnu_a_SOURCES += float.c itold.c
393 290
394## end gnulib module float 291## end gnulib module float
395 292
@@ -415,13 +312,11 @@ EXTRA_libgnu_a_SOURCES += fsusage.c
415 312
416libgnu_a_SOURCES += full-read.h full-read.c 313libgnu_a_SOURCES += full-read.h full-read.c
417 314
418## end gnulib module full-read 315EXTRA_DIST += full-write.c
419 316
420## begin gnulib module full-write 317EXTRA_libgnu_a_SOURCES += full-write.c
421 318
422libgnu_a_SOURCES += full-write.h full-write.c 319## end gnulib module full-read
423
424## end gnulib module full-write
425 320
426## begin gnulib module getaddrinfo 321## begin gnulib module getaddrinfo
427 322
@@ -432,15 +327,6 @@ EXTRA_libgnu_a_SOURCES += gai_strerror.c getaddrinfo.c
432 327
433## end gnulib module getaddrinfo 328## end gnulib module getaddrinfo
434 329
435## begin gnulib module getdtablesize
436
437
438EXTRA_DIST += getdtablesize.c
439
440EXTRA_libgnu_a_SOURCES += getdtablesize.c
441
442## end gnulib module getdtablesize
443
444## begin gnulib module gethostname 330## begin gnulib module gethostname
445 331
446 332
@@ -465,12 +351,14 @@ BUILT_SOURCES += $(GETOPT_H)
465 351
466# We need the following in order to create <getopt.h> when the system 352# We need the following in order to create <getopt.h> when the system
467# doesn't have one that works with the given compiler. 353# doesn't have one that works with the given compiler.
468getopt.h: getopt.in.h $(ARG_NONNULL_H) 354getopt.h: getopt.in.h $(top_builddir)/config.status $(ARG_NONNULL_H)
469 $(AM_V_GEN)rm -f $@-t $@ && \ 355 $(AM_V_GEN)rm -f $@-t $@ && \
470 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 356 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
471 sed -e 's|@''HAVE_GETOPT_H''@|$(HAVE_GETOPT_H)|g' \ 357 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
358 -e 's|@''HAVE_GETOPT_H''@|$(HAVE_GETOPT_H)|g' \
472 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 359 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
473 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 360 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
361 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
474 -e 's|@''NEXT_GETOPT_H''@|$(NEXT_GETOPT_H)|g' \ 362 -e 's|@''NEXT_GETOPT_H''@|$(NEXT_GETOPT_H)|g' \
475 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 363 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
476 < $(srcdir)/getopt.in.h; \ 364 < $(srcdir)/getopt.in.h; \
@@ -486,15 +374,16 @@ EXTRA_libgnu_a_SOURCES += getopt.c getopt1.c
486 374
487## begin gnulib module gettext 375## begin gnulib module gettext
488 376
489# This is for those projects which use "gettextize --intl" to put a source-code 377# If your project uses "gettextize --intl" to put a source-code
490# copy of libintl into their package. In such projects, every Makefile.am needs 378# copy of libintl into the package, every Makefile.am needs
491# -I$(top_builddir)/intl, so that <libintl.h> can be found in this directory. 379# -I$(top_builddir)/intl, so that <libintl.h> can be found in this directory.
492# For the Makefile.ams in other directories it is the maintainer's 380# Here's one way to do this:
493# responsibility; for the one from gnulib we do it here. 381#AM_CPPFLAGS += -I$(top_builddir)/intl
494# This option has no effect when the user disables NLS (because then the intl 382# This option has no effect when the user disables NLS (because then
495# directory contains no libintl.h file) or when the project does not use 383# the intl directory contains no libintl.h file). This option is not
496# "gettextize --intl". 384# enabled by default because the intl directory might not exist if
497AM_CPPFLAGS += -I$(top_builddir)/intl 385# your project does not use "gettext --intl", and some compilers
386# complain about -I options applied to nonexistent directories.
498 387
499EXTRA_DIST += $(top_srcdir)/build-aux/config.rpath 388EXTRA_DIST += $(top_srcdir)/build-aux/config.rpath
500 389
@@ -535,16 +424,20 @@ BUILT_SOURCES += langinfo.h
535 424
536# We need the following in order to create an empty placeholder for 425# We need the following in order to create an empty placeholder for
537# <langinfo.h> when the system doesn't have one. 426# <langinfo.h> when the system doesn't have one.
538langinfo.h: langinfo.in.h $(CXXDEFS_H) $(WARN_ON_USE_H) 427langinfo.h: langinfo.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H)
539 $(AM_V_GEN)rm -f $@-t $@ && \ 428 $(AM_V_GEN)rm -f $@-t $@ && \
540 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 429 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
541 sed -e 's|@''HAVE_LANGINFO_H''@|$(HAVE_LANGINFO_H)|g' \ 430 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
431 -e 's|@''HAVE_LANGINFO_H''@|$(HAVE_LANGINFO_H)|g' \
542 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 432 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
543 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 433 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
434 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
544 -e 's|@''NEXT_LANGINFO_H''@|$(NEXT_LANGINFO_H)|g' \ 435 -e 's|@''NEXT_LANGINFO_H''@|$(NEXT_LANGINFO_H)|g' \
545 -e 's|@''GNULIB_NL_LANGINFO''@|$(GNULIB_NL_LANGINFO)|g' \ 436 -e 's/@''GNULIB_NL_LANGINFO''@/$(GNULIB_NL_LANGINFO)/g' \
546 -e 's|@''HAVE_LANGINFO_CODESET''@|$(HAVE_LANGINFO_CODESET)|g' \ 437 -e 's|@''HAVE_LANGINFO_CODESET''@|$(HAVE_LANGINFO_CODESET)|g' \
438 -e 's|@''HAVE_LANGINFO_T_FMT_AMPM''@|$(HAVE_LANGINFO_T_FMT_AMPM)|g' \
547 -e 's|@''HAVE_LANGINFO_ERA''@|$(HAVE_LANGINFO_ERA)|g' \ 439 -e 's|@''HAVE_LANGINFO_ERA''@|$(HAVE_LANGINFO_ERA)|g' \
440 -e 's|@''HAVE_LANGINFO_YESEXPR''@|$(HAVE_LANGINFO_YESEXPR)|g' \
548 -e 's|@''HAVE_NL_LANGINFO''@|$(HAVE_NL_LANGINFO)|g' \ 441 -e 's|@''HAVE_NL_LANGINFO''@|$(HAVE_NL_LANGINFO)|g' \
549 -e 's|@''REPLACE_NL_LANGINFO''@|$(REPLACE_NL_LANGINFO)|g' \ 442 -e 's|@''REPLACE_NL_LANGINFO''@|$(REPLACE_NL_LANGINFO)|g' \
550 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 443 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
@@ -638,16 +531,23 @@ BUILT_SOURCES += locale.h
638 531
639# We need the following in order to create <locale.h> when the system 532# We need the following in order to create <locale.h> when the system
640# doesn't have one that provides all definitions. 533# doesn't have one that provides all definitions.
641locale.h: locale.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 534locale.h: locale.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
642 $(AM_V_GEN)rm -f $@-t $@ && \ 535 $(AM_V_GEN)rm -f $@-t $@ && \
643 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 536 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
644 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 537 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
538 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
645 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 539 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
540 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
646 -e 's|@''NEXT_LOCALE_H''@|$(NEXT_LOCALE_H)|g' \ 541 -e 's|@''NEXT_LOCALE_H''@|$(NEXT_LOCALE_H)|g' \
647 -e 's|@''GNULIB_DUPLOCALE''@|$(GNULIB_DUPLOCALE)|g' \ 542 -e 's/@''GNULIB_LOCALECONV''@/$(GNULIB_LOCALECONV)/g' \
543 -e 's/@''GNULIB_SETLOCALE''@/$(GNULIB_SETLOCALE)/g' \
544 -e 's/@''GNULIB_DUPLOCALE''@/$(GNULIB_DUPLOCALE)/g' \
648 -e 's|@''HAVE_DUPLOCALE''@|$(HAVE_DUPLOCALE)|g' \ 545 -e 's|@''HAVE_DUPLOCALE''@|$(HAVE_DUPLOCALE)|g' \
649 -e 's|@''HAVE_XLOCALE_H''@|$(HAVE_XLOCALE_H)|g' \ 546 -e 's|@''HAVE_XLOCALE_H''@|$(HAVE_XLOCALE_H)|g' \
547 -e 's|@''REPLACE_LOCALECONV''@|$(REPLACE_LOCALECONV)|g' \
548 -e 's|@''REPLACE_SETLOCALE''@|$(REPLACE_SETLOCALE)|g' \
650 -e 's|@''REPLACE_DUPLOCALE''@|$(REPLACE_DUPLOCALE)|g' \ 549 -e 's|@''REPLACE_DUPLOCALE''@|$(REPLACE_DUPLOCALE)|g' \
550 -e 's|@''REPLACE_STRUCT_LCONV''@|$(REPLACE_STRUCT_LCONV)|g' \
651 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 551 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
652 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 552 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
653 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ 553 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
@@ -660,14 +560,29 @@ EXTRA_DIST += locale.in.h
660 560
661## end gnulib module locale 561## end gnulib module locale
662 562
663## begin gnulib module malloc 563## begin gnulib module localeconv
564
565
566EXTRA_DIST += localeconv.c
567
568EXTRA_libgnu_a_SOURCES += localeconv.c
569
570## end gnulib module localeconv
571
572## begin gnulib module lock
573
574libgnu_a_SOURCES += glthread/lock.h glthread/lock.c
575
576## end gnulib module lock
577
578## begin gnulib module malloc-gnu
664 579
665 580
666EXTRA_DIST += malloc.c 581EXTRA_DIST += malloc.c
667 582
668EXTRA_libgnu_a_SOURCES += malloc.c 583EXTRA_libgnu_a_SOURCES += malloc.c
669 584
670## end gnulib module malloc 585## end gnulib module malloc-gnu
671 586
672## begin gnulib module malloc-posix 587## begin gnulib module malloc-posix
673 588
@@ -689,70 +604,202 @@ EXTRA_DIST += malloca.h malloca.valgrind
689## begin gnulib module math 604## begin gnulib module math
690 605
691BUILT_SOURCES += math.h 606BUILT_SOURCES += math.h
607libgnu_a_SOURCES += math.c
692 608
693# We need the following in order to create <math.h> when the system 609# We need the following in order to create <math.h> when the system
694# doesn't have one that works with the given compiler. 610# doesn't have one that works with the given compiler.
695math.h: math.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 611math.h: math.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
696 $(AM_V_GEN)rm -f $@-t $@ && \ 612 $(AM_V_GEN)rm -f $@-t $@ && \
697 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 613 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
698 sed -e 's|@''INCLUDE_NEXT_AS_FIRST_DIRECTIVE''@|$(INCLUDE_NEXT_AS_FIRST_DIRECTIVE)|g' \ 614 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
615 -e 's|@''INCLUDE_NEXT_AS_FIRST_DIRECTIVE''@|$(INCLUDE_NEXT_AS_FIRST_DIRECTIVE)|g' \
699 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 616 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
617 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
700 -e 's|@''NEXT_AS_FIRST_DIRECTIVE_MATH_H''@|$(NEXT_AS_FIRST_DIRECTIVE_MATH_H)|g' \ 618 -e 's|@''NEXT_AS_FIRST_DIRECTIVE_MATH_H''@|$(NEXT_AS_FIRST_DIRECTIVE_MATH_H)|g' \
701 -e 's|@''GNULIB_ACOSL''@|$(GNULIB_ACOSL)|g' \ 619 -e 's/@''GNULIB_ACOSF''@/$(GNULIB_ACOSF)/g' \
702 -e 's|@''GNULIB_ASINL''@|$(GNULIB_ASINL)|g' \ 620 -e 's/@''GNULIB_ACOSL''@/$(GNULIB_ACOSL)/g' \
703 -e 's|@''GNULIB_ATANL''@|$(GNULIB_ATANL)|g' \ 621 -e 's/@''GNULIB_ASINF''@/$(GNULIB_ASINF)/g' \
704 -e 's|@''GNULIB_CEILF''@|$(GNULIB_CEILF)|g' \ 622 -e 's/@''GNULIB_ASINL''@/$(GNULIB_ASINL)/g' \
705 -e 's|@''GNULIB_CEILL''@|$(GNULIB_CEILL)|g' \ 623 -e 's/@''GNULIB_ATANF''@/$(GNULIB_ATANF)/g' \
706 -e 's|@''GNULIB_COSL''@|$(GNULIB_COSL)|g' \ 624 -e 's/@''GNULIB_ATANL''@/$(GNULIB_ATANL)/g' \
707 -e 's|@''GNULIB_EXPL''@|$(GNULIB_EXPL)|g' \ 625 -e 's/@''GNULIB_ATAN2F''@/$(GNULIB_ATAN2F)/g' \
708 -e 's|@''GNULIB_FLOORF''@|$(GNULIB_FLOORF)|g' \ 626 -e 's/@''GNULIB_CBRT''@/$(GNULIB_CBRT)/g' \
709 -e 's|@''GNULIB_FLOORL''@|$(GNULIB_FLOORL)|g' \ 627 -e 's/@''GNULIB_CBRTF''@/$(GNULIB_CBRTF)/g' \
710 -e 's|@''GNULIB_FREXP''@|$(GNULIB_FREXP)|g' \ 628 -e 's/@''GNULIB_CBRTL''@/$(GNULIB_CBRTL)/g' \
711 -e 's|@''GNULIB_FREXPL''@|$(GNULIB_FREXPL)|g' \ 629 -e 's/@''GNULIB_CEIL''@/$(GNULIB_CEIL)/g' \
712 -e 's|@''GNULIB_ISFINITE''@|$(GNULIB_ISFINITE)|g' \ 630 -e 's/@''GNULIB_CEILF''@/$(GNULIB_CEILF)/g' \
713 -e 's|@''GNULIB_ISINF''@|$(GNULIB_ISINF)|g' \ 631 -e 's/@''GNULIB_CEILL''@/$(GNULIB_CEILL)/g' \
714 -e 's|@''GNULIB_ISNAN''@|$(GNULIB_ISNAN)|g' \ 632 -e 's/@''GNULIB_COPYSIGN''@/$(GNULIB_COPYSIGN)/g' \
715 -e 's|@''GNULIB_ISNANF''@|$(GNULIB_ISNANF)|g' \ 633 -e 's/@''GNULIB_COPYSIGNF''@/$(GNULIB_COPYSIGNF)/g' \
716 -e 's|@''GNULIB_ISNAND''@|$(GNULIB_ISNAND)|g' \ 634 -e 's/@''GNULIB_COPYSIGNL''@/$(GNULIB_COPYSIGNL)/g' \
717 -e 's|@''GNULIB_ISNANL''@|$(GNULIB_ISNANL)|g' \ 635 -e 's/@''GNULIB_COSF''@/$(GNULIB_COSF)/g' \
718 -e 's|@''GNULIB_LDEXPL''@|$(GNULIB_LDEXPL)|g' \ 636 -e 's/@''GNULIB_COSL''@/$(GNULIB_COSL)/g' \
719 -e 's|@''GNULIB_LOGB''@|$(GNULIB_LOGB)|g' \ 637 -e 's/@''GNULIB_COSHF''@/$(GNULIB_COSHF)/g' \
720 -e 's|@''GNULIB_LOGL''@|$(GNULIB_LOGL)|g' \ 638 -e 's/@''GNULIB_EXPF''@/$(GNULIB_EXPF)/g' \
721 -e 's|@''GNULIB_ROUND''@|$(GNULIB_ROUND)|g' \ 639 -e 's/@''GNULIB_EXPL''@/$(GNULIB_EXPL)/g' \
722 -e 's|@''GNULIB_ROUNDF''@|$(GNULIB_ROUNDF)|g' \ 640 -e 's/@''GNULIB_EXP2''@/$(GNULIB_EXP2)/g' \
723 -e 's|@''GNULIB_ROUNDL''@|$(GNULIB_ROUNDL)|g' \ 641 -e 's/@''GNULIB_EXP2F''@/$(GNULIB_EXP2F)/g' \
724 -e 's|@''GNULIB_SIGNBIT''@|$(GNULIB_SIGNBIT)|g' \ 642 -e 's/@''GNULIB_EXP2L''@/$(GNULIB_EXP2L)/g' \
725 -e 's|@''GNULIB_SINL''@|$(GNULIB_SINL)|g' \ 643 -e 's/@''GNULIB_EXPM1''@/$(GNULIB_EXPM1)/g' \
726 -e 's|@''GNULIB_SQRTL''@|$(GNULIB_SQRTL)|g' \ 644 -e 's/@''GNULIB_EXPM1F''@/$(GNULIB_EXPM1F)/g' \
727 -e 's|@''GNULIB_TANL''@|$(GNULIB_TANL)|g' \ 645 -e 's/@''GNULIB_EXPM1L''@/$(GNULIB_EXPM1L)/g' \
728 -e 's|@''GNULIB_TRUNC''@|$(GNULIB_TRUNC)|g' \ 646 -e 's/@''GNULIB_FABSF''@/$(GNULIB_FABSF)/g' \
729 -e 's|@''GNULIB_TRUNCF''@|$(GNULIB_TRUNCF)|g' \ 647 -e 's/@''GNULIB_FABSL''@/$(GNULIB_FABSL)/g' \
730 -e 's|@''GNULIB_TRUNCL''@|$(GNULIB_TRUNCL)|g' \ 648 -e 's/@''GNULIB_FLOOR''@/$(GNULIB_FLOOR)/g' \
649 -e 's/@''GNULIB_FLOORF''@/$(GNULIB_FLOORF)/g' \
650 -e 's/@''GNULIB_FLOORL''@/$(GNULIB_FLOORL)/g' \
651 -e 's/@''GNULIB_FMA''@/$(GNULIB_FMA)/g' \
652 -e 's/@''GNULIB_FMAF''@/$(GNULIB_FMAF)/g' \
653 -e 's/@''GNULIB_FMAL''@/$(GNULIB_FMAL)/g' \
654 -e 's/@''GNULIB_FMOD''@/$(GNULIB_FMOD)/g' \
655 -e 's/@''GNULIB_FMODF''@/$(GNULIB_FMODF)/g' \
656 -e 's/@''GNULIB_FMODL''@/$(GNULIB_FMODL)/g' \
657 -e 's/@''GNULIB_FREXPF''@/$(GNULIB_FREXPF)/g' \
658 -e 's/@''GNULIB_FREXP''@/$(GNULIB_FREXP)/g' \
659 -e 's/@''GNULIB_FREXPL''@/$(GNULIB_FREXPL)/g' \
660 -e 's/@''GNULIB_HYPOT''@/$(GNULIB_HYPOT)/g' \
661 -e 's/@''GNULIB_HYPOTF''@/$(GNULIB_HYPOTF)/g' \
662 -e 's/@''GNULIB_HYPOTL''@/$(GNULIB_HYPOTL)/g' \
663 < $(srcdir)/math.in.h | \
664 sed -e 's/@''GNULIB_ILOGB''@/$(GNULIB_ILOGB)/g' \
665 -e 's/@''GNULIB_ILOGBF''@/$(GNULIB_ILOGBF)/g' \
666 -e 's/@''GNULIB_ILOGBL''@/$(GNULIB_ILOGBL)/g' \
667 -e 's/@''GNULIB_ISFINITE''@/$(GNULIB_ISFINITE)/g' \
668 -e 's/@''GNULIB_ISINF''@/$(GNULIB_ISINF)/g' \
669 -e 's/@''GNULIB_ISNAN''@/$(GNULIB_ISNAN)/g' \
670 -e 's/@''GNULIB_ISNANF''@/$(GNULIB_ISNANF)/g' \
671 -e 's/@''GNULIB_ISNAND''@/$(GNULIB_ISNAND)/g' \
672 -e 's/@''GNULIB_ISNANL''@/$(GNULIB_ISNANL)/g' \
673 -e 's/@''GNULIB_LDEXPF''@/$(GNULIB_LDEXPF)/g' \
674 -e 's/@''GNULIB_LDEXPL''@/$(GNULIB_LDEXPL)/g' \
675 -e 's/@''GNULIB_LOG''@/$(GNULIB_LOG)/g' \
676 -e 's/@''GNULIB_LOGF''@/$(GNULIB_LOGF)/g' \
677 -e 's/@''GNULIB_LOGL''@/$(GNULIB_LOGL)/g' \
678 -e 's/@''GNULIB_LOG10''@/$(GNULIB_LOG10)/g' \
679 -e 's/@''GNULIB_LOG10F''@/$(GNULIB_LOG10F)/g' \
680 -e 's/@''GNULIB_LOG10L''@/$(GNULIB_LOG10L)/g' \
681 -e 's/@''GNULIB_LOG1P''@/$(GNULIB_LOG1P)/g' \
682 -e 's/@''GNULIB_LOG1PF''@/$(GNULIB_LOG1PF)/g' \
683 -e 's/@''GNULIB_LOG1PL''@/$(GNULIB_LOG1PL)/g' \
684 -e 's/@''GNULIB_LOG2''@/$(GNULIB_LOG2)/g' \
685 -e 's/@''GNULIB_LOG2F''@/$(GNULIB_LOG2F)/g' \
686 -e 's/@''GNULIB_LOG2L''@/$(GNULIB_LOG2L)/g' \
687 -e 's/@''GNULIB_LOGB''@/$(GNULIB_LOGB)/g' \
688 -e 's/@''GNULIB_LOGBF''@/$(GNULIB_LOGBF)/g' \
689 -e 's/@''GNULIB_LOGBL''@/$(GNULIB_LOGBL)/g' \
690 -e 's/@''GNULIB_MODF''@/$(GNULIB_MODF)/g' \
691 -e 's/@''GNULIB_MODFF''@/$(GNULIB_MODFF)/g' \
692 -e 's/@''GNULIB_MODFL''@/$(GNULIB_MODFL)/g' \
693 -e 's/@''GNULIB_POWF''@/$(GNULIB_POWF)/g' \
694 -e 's/@''GNULIB_REMAINDER''@/$(GNULIB_REMAINDER)/g' \
695 -e 's/@''GNULIB_REMAINDERF''@/$(GNULIB_REMAINDERF)/g' \
696 -e 's/@''GNULIB_REMAINDERL''@/$(GNULIB_REMAINDERL)/g' \
697 -e 's/@''GNULIB_RINT''@/$(GNULIB_RINT)/g' \
698 -e 's/@''GNULIB_RINTF''@/$(GNULIB_RINTF)/g' \
699 -e 's/@''GNULIB_RINTL''@/$(GNULIB_RINTL)/g' \
700 -e 's/@''GNULIB_ROUND''@/$(GNULIB_ROUND)/g' \
701 -e 's/@''GNULIB_ROUNDF''@/$(GNULIB_ROUNDF)/g' \
702 -e 's/@''GNULIB_ROUNDL''@/$(GNULIB_ROUNDL)/g' \
703 -e 's/@''GNULIB_SIGNBIT''@/$(GNULIB_SIGNBIT)/g' \
704 -e 's/@''GNULIB_SINF''@/$(GNULIB_SINF)/g' \
705 -e 's/@''GNULIB_SINL''@/$(GNULIB_SINL)/g' \
706 -e 's/@''GNULIB_SINHF''@/$(GNULIB_SINHF)/g' \
707 -e 's/@''GNULIB_SQRTF''@/$(GNULIB_SQRTF)/g' \
708 -e 's/@''GNULIB_SQRTL''@/$(GNULIB_SQRTL)/g' \
709 -e 's/@''GNULIB_TANF''@/$(GNULIB_TANF)/g' \
710 -e 's/@''GNULIB_TANL''@/$(GNULIB_TANL)/g' \
711 -e 's/@''GNULIB_TANHF''@/$(GNULIB_TANHF)/g' \
712 -e 's/@''GNULIB_TRUNC''@/$(GNULIB_TRUNC)/g' \
713 -e 's/@''GNULIB_TRUNCF''@/$(GNULIB_TRUNCF)/g' \
714 -e 's/@''GNULIB_TRUNCL''@/$(GNULIB_TRUNCL)/g' \
715 | \
716 sed -e 's|@''HAVE_ACOSF''@|$(HAVE_ACOSF)|g' \
731 -e 's|@''HAVE_ACOSL''@|$(HAVE_ACOSL)|g' \ 717 -e 's|@''HAVE_ACOSL''@|$(HAVE_ACOSL)|g' \
718 -e 's|@''HAVE_ASINF''@|$(HAVE_ASINF)|g' \
732 -e 's|@''HAVE_ASINL''@|$(HAVE_ASINL)|g' \ 719 -e 's|@''HAVE_ASINL''@|$(HAVE_ASINL)|g' \
720 -e 's|@''HAVE_ATANF''@|$(HAVE_ATANF)|g' \
733 -e 's|@''HAVE_ATANL''@|$(HAVE_ATANL)|g' \ 721 -e 's|@''HAVE_ATANL''@|$(HAVE_ATANL)|g' \
722 -e 's|@''HAVE_ATAN2F''@|$(HAVE_ATAN2F)|g' \
723 -e 's|@''HAVE_CBRT''@|$(HAVE_CBRT)|g' \
724 -e 's|@''HAVE_CBRTF''@|$(HAVE_CBRTF)|g' \
725 -e 's|@''HAVE_CBRTL''@|$(HAVE_CBRTL)|g' \
726 -e 's|@''HAVE_COPYSIGN''@|$(HAVE_COPYSIGN)|g' \
727 -e 's|@''HAVE_COPYSIGNL''@|$(HAVE_COPYSIGNL)|g' \
728 -e 's|@''HAVE_COSF''@|$(HAVE_COSF)|g' \
734 -e 's|@''HAVE_COSL''@|$(HAVE_COSL)|g' \ 729 -e 's|@''HAVE_COSL''@|$(HAVE_COSL)|g' \
730 -e 's|@''HAVE_COSHF''@|$(HAVE_COSHF)|g' \
731 -e 's|@''HAVE_EXPF''@|$(HAVE_EXPF)|g' \
735 -e 's|@''HAVE_EXPL''@|$(HAVE_EXPL)|g' \ 732 -e 's|@''HAVE_EXPL''@|$(HAVE_EXPL)|g' \
733 -e 's|@''HAVE_EXPM1''@|$(HAVE_EXPM1)|g' \
734 -e 's|@''HAVE_EXPM1F''@|$(HAVE_EXPM1F)|g' \
735 -e 's|@''HAVE_FABSF''@|$(HAVE_FABSF)|g' \
736 -e 's|@''HAVE_FABSL''@|$(HAVE_FABSL)|g' \
737 -e 's|@''HAVE_FMA''@|$(HAVE_FMA)|g' \
738 -e 's|@''HAVE_FMAF''@|$(HAVE_FMAF)|g' \
739 -e 's|@''HAVE_FMAL''@|$(HAVE_FMAL)|g' \
740 -e 's|@''HAVE_FMODF''@|$(HAVE_FMODF)|g' \
741 -e 's|@''HAVE_FMODL''@|$(HAVE_FMODL)|g' \
742 -e 's|@''HAVE_FREXPF''@|$(HAVE_FREXPF)|g' \
743 -e 's|@''HAVE_HYPOTF''@|$(HAVE_HYPOTF)|g' \
744 -e 's|@''HAVE_HYPOTL''@|$(HAVE_HYPOTL)|g' \
745 -e 's|@''HAVE_ILOGB''@|$(HAVE_ILOGB)|g' \
746 -e 's|@''HAVE_ILOGBF''@|$(HAVE_ILOGBF)|g' \
747 -e 's|@''HAVE_ILOGBL''@|$(HAVE_ILOGBL)|g' \
736 -e 's|@''HAVE_ISNANF''@|$(HAVE_ISNANF)|g' \ 748 -e 's|@''HAVE_ISNANF''@|$(HAVE_ISNANF)|g' \
737 -e 's|@''HAVE_ISNAND''@|$(HAVE_ISNAND)|g' \ 749 -e 's|@''HAVE_ISNAND''@|$(HAVE_ISNAND)|g' \
738 -e 's|@''HAVE_ISNANL''@|$(HAVE_ISNANL)|g' \ 750 -e 's|@''HAVE_ISNANL''@|$(HAVE_ISNANL)|g' \
751 -e 's|@''HAVE_LDEXPF''@|$(HAVE_LDEXPF)|g' \
752 -e 's|@''HAVE_LOGF''@|$(HAVE_LOGF)|g' \
739 -e 's|@''HAVE_LOGL''@|$(HAVE_LOGL)|g' \ 753 -e 's|@''HAVE_LOGL''@|$(HAVE_LOGL)|g' \
754 -e 's|@''HAVE_LOG10F''@|$(HAVE_LOG10F)|g' \
755 -e 's|@''HAVE_LOG10L''@|$(HAVE_LOG10L)|g' \
756 -e 's|@''HAVE_LOG1P''@|$(HAVE_LOG1P)|g' \
757 -e 's|@''HAVE_LOG1PF''@|$(HAVE_LOG1PF)|g' \
758 -e 's|@''HAVE_LOG1PL''@|$(HAVE_LOG1PL)|g' \
759 -e 's|@''HAVE_LOGBF''@|$(HAVE_LOGBF)|g' \
760 -e 's|@''HAVE_LOGBL''@|$(HAVE_LOGBL)|g' \
761 -e 's|@''HAVE_MODFF''@|$(HAVE_MODFF)|g' \
762 -e 's|@''HAVE_MODFL''@|$(HAVE_MODFL)|g' \
763 -e 's|@''HAVE_POWF''@|$(HAVE_POWF)|g' \
764 -e 's|@''HAVE_REMAINDER''@|$(HAVE_REMAINDER)|g' \
765 -e 's|@''HAVE_REMAINDERF''@|$(HAVE_REMAINDERF)|g' \
766 -e 's|@''HAVE_RINT''@|$(HAVE_RINT)|g' \
767 -e 's|@''HAVE_RINTL''@|$(HAVE_RINTL)|g' \
768 -e 's|@''HAVE_SINF''@|$(HAVE_SINF)|g' \
740 -e 's|@''HAVE_SINL''@|$(HAVE_SINL)|g' \ 769 -e 's|@''HAVE_SINL''@|$(HAVE_SINL)|g' \
770 -e 's|@''HAVE_SINHF''@|$(HAVE_SINHF)|g' \
771 -e 's|@''HAVE_SQRTF''@|$(HAVE_SQRTF)|g' \
741 -e 's|@''HAVE_SQRTL''@|$(HAVE_SQRTL)|g' \ 772 -e 's|@''HAVE_SQRTL''@|$(HAVE_SQRTL)|g' \
773 -e 's|@''HAVE_TANF''@|$(HAVE_TANF)|g' \
742 -e 's|@''HAVE_TANL''@|$(HAVE_TANL)|g' \ 774 -e 's|@''HAVE_TANL''@|$(HAVE_TANL)|g' \
775 -e 's|@''HAVE_TANHF''@|$(HAVE_TANHF)|g' \
743 -e 's|@''HAVE_DECL_ACOSL''@|$(HAVE_DECL_ACOSL)|g' \ 776 -e 's|@''HAVE_DECL_ACOSL''@|$(HAVE_DECL_ACOSL)|g' \
744 -e 's|@''HAVE_DECL_ASINL''@|$(HAVE_DECL_ASINL)|g' \ 777 -e 's|@''HAVE_DECL_ASINL''@|$(HAVE_DECL_ASINL)|g' \
745 -e 's|@''HAVE_DECL_ATANL''@|$(HAVE_DECL_ATANL)|g' \ 778 -e 's|@''HAVE_DECL_ATANL''@|$(HAVE_DECL_ATANL)|g' \
779 -e 's|@''HAVE_DECL_CBRTF''@|$(HAVE_DECL_CBRTF)|g' \
780 -e 's|@''HAVE_DECL_CBRTL''@|$(HAVE_DECL_CBRTL)|g' \
746 -e 's|@''HAVE_DECL_CEILF''@|$(HAVE_DECL_CEILF)|g' \ 781 -e 's|@''HAVE_DECL_CEILF''@|$(HAVE_DECL_CEILF)|g' \
747 -e 's|@''HAVE_DECL_CEILL''@|$(HAVE_DECL_CEILL)|g' \ 782 -e 's|@''HAVE_DECL_CEILL''@|$(HAVE_DECL_CEILL)|g' \
783 -e 's|@''HAVE_DECL_COPYSIGNF''@|$(HAVE_DECL_COPYSIGNF)|g' \
748 -e 's|@''HAVE_DECL_COSL''@|$(HAVE_DECL_COSL)|g' \ 784 -e 's|@''HAVE_DECL_COSL''@|$(HAVE_DECL_COSL)|g' \
749 -e 's|@''HAVE_DECL_EXPL''@|$(HAVE_DECL_EXPL)|g' \ 785 -e 's|@''HAVE_DECL_EXPL''@|$(HAVE_DECL_EXPL)|g' \
786 -e 's|@''HAVE_DECL_EXP2''@|$(HAVE_DECL_EXP2)|g' \
787 -e 's|@''HAVE_DECL_EXP2F''@|$(HAVE_DECL_EXP2F)|g' \
788 -e 's|@''HAVE_DECL_EXP2L''@|$(HAVE_DECL_EXP2L)|g' \
789 -e 's|@''HAVE_DECL_EXPM1L''@|$(HAVE_DECL_EXPM1L)|g' \
750 -e 's|@''HAVE_DECL_FLOORF''@|$(HAVE_DECL_FLOORF)|g' \ 790 -e 's|@''HAVE_DECL_FLOORF''@|$(HAVE_DECL_FLOORF)|g' \
751 -e 's|@''HAVE_DECL_FLOORL''@|$(HAVE_DECL_FLOORL)|g' \ 791 -e 's|@''HAVE_DECL_FLOORL''@|$(HAVE_DECL_FLOORL)|g' \
752 -e 's|@''HAVE_DECL_FREXPL''@|$(HAVE_DECL_FREXPL)|g' \ 792 -e 's|@''HAVE_DECL_FREXPL''@|$(HAVE_DECL_FREXPL)|g' \
753 -e 's|@''HAVE_DECL_LDEXPL''@|$(HAVE_DECL_LDEXPL)|g' \ 793 -e 's|@''HAVE_DECL_LDEXPL''@|$(HAVE_DECL_LDEXPL)|g' \
754 -e 's|@''HAVE_DECL_LOGB''@|$(HAVE_DECL_LOGB)|g' \
755 -e 's|@''HAVE_DECL_LOGL''@|$(HAVE_DECL_LOGL)|g' \ 794 -e 's|@''HAVE_DECL_LOGL''@|$(HAVE_DECL_LOGL)|g' \
795 -e 's|@''HAVE_DECL_LOG10L''@|$(HAVE_DECL_LOG10L)|g' \
796 -e 's|@''HAVE_DECL_LOG2''@|$(HAVE_DECL_LOG2)|g' \
797 -e 's|@''HAVE_DECL_LOG2F''@|$(HAVE_DECL_LOG2F)|g' \
798 -e 's|@''HAVE_DECL_LOG2L''@|$(HAVE_DECL_LOG2L)|g' \
799 -e 's|@''HAVE_DECL_LOGB''@|$(HAVE_DECL_LOGB)|g' \
800 -e 's|@''HAVE_DECL_REMAINDER''@|$(HAVE_DECL_REMAINDER)|g' \
801 -e 's|@''HAVE_DECL_REMAINDERL''@|$(HAVE_DECL_REMAINDERL)|g' \
802 -e 's|@''HAVE_DECL_RINTF''@|$(HAVE_DECL_RINTF)|g' \
756 -e 's|@''HAVE_DECL_ROUND''@|$(HAVE_DECL_ROUND)|g' \ 803 -e 's|@''HAVE_DECL_ROUND''@|$(HAVE_DECL_ROUND)|g' \
757 -e 's|@''HAVE_DECL_ROUNDF''@|$(HAVE_DECL_ROUNDF)|g' \ 804 -e 's|@''HAVE_DECL_ROUNDF''@|$(HAVE_DECL_ROUNDF)|g' \
758 -e 's|@''HAVE_DECL_ROUNDL''@|$(HAVE_DECL_ROUNDL)|g' \ 805 -e 's|@''HAVE_DECL_ROUNDL''@|$(HAVE_DECL_ROUNDL)|g' \
@@ -762,28 +809,74 @@ math.h: math.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
762 -e 's|@''HAVE_DECL_TRUNC''@|$(HAVE_DECL_TRUNC)|g' \ 809 -e 's|@''HAVE_DECL_TRUNC''@|$(HAVE_DECL_TRUNC)|g' \
763 -e 's|@''HAVE_DECL_TRUNCF''@|$(HAVE_DECL_TRUNCF)|g' \ 810 -e 's|@''HAVE_DECL_TRUNCF''@|$(HAVE_DECL_TRUNCF)|g' \
764 -e 's|@''HAVE_DECL_TRUNCL''@|$(HAVE_DECL_TRUNCL)|g' \ 811 -e 's|@''HAVE_DECL_TRUNCL''@|$(HAVE_DECL_TRUNCL)|g' \
812 | \
813 sed -e 's|@''REPLACE_CBRTF''@|$(REPLACE_CBRTF)|g' \
814 -e 's|@''REPLACE_CBRTL''@|$(REPLACE_CBRTL)|g' \
815 -e 's|@''REPLACE_CEIL''@|$(REPLACE_CEIL)|g' \
765 -e 's|@''REPLACE_CEILF''@|$(REPLACE_CEILF)|g' \ 816 -e 's|@''REPLACE_CEILF''@|$(REPLACE_CEILF)|g' \
766 -e 's|@''REPLACE_CEILL''@|$(REPLACE_CEILL)|g' \ 817 -e 's|@''REPLACE_CEILL''@|$(REPLACE_CEILL)|g' \
818 -e 's|@''REPLACE_EXPM1''@|$(REPLACE_EXPM1)|g' \
819 -e 's|@''REPLACE_EXPM1F''@|$(REPLACE_EXPM1F)|g' \
820 -e 's|@''REPLACE_EXP2''@|$(REPLACE_EXP2)|g' \
821 -e 's|@''REPLACE_EXP2L''@|$(REPLACE_EXP2L)|g' \
822 -e 's|@''REPLACE_FABSL''@|$(REPLACE_FABSL)|g' \
823 -e 's|@''REPLACE_FLOOR''@|$(REPLACE_FLOOR)|g' \
767 -e 's|@''REPLACE_FLOORF''@|$(REPLACE_FLOORF)|g' \ 824 -e 's|@''REPLACE_FLOORF''@|$(REPLACE_FLOORF)|g' \
768 -e 's|@''REPLACE_FLOORL''@|$(REPLACE_FLOORL)|g' \ 825 -e 's|@''REPLACE_FLOORL''@|$(REPLACE_FLOORL)|g' \
826 -e 's|@''REPLACE_FMA''@|$(REPLACE_FMA)|g' \
827 -e 's|@''REPLACE_FMAF''@|$(REPLACE_FMAF)|g' \
828 -e 's|@''REPLACE_FMAL''@|$(REPLACE_FMAL)|g' \
829 -e 's|@''REPLACE_FMOD''@|$(REPLACE_FMOD)|g' \
830 -e 's|@''REPLACE_FMODF''@|$(REPLACE_FMODF)|g' \
831 -e 's|@''REPLACE_FMODL''@|$(REPLACE_FMODL)|g' \
832 -e 's|@''REPLACE_FREXPF''@|$(REPLACE_FREXPF)|g' \
769 -e 's|@''REPLACE_FREXP''@|$(REPLACE_FREXP)|g' \ 833 -e 's|@''REPLACE_FREXP''@|$(REPLACE_FREXP)|g' \
770 -e 's|@''REPLACE_FREXPL''@|$(REPLACE_FREXPL)|g' \ 834 -e 's|@''REPLACE_FREXPL''@|$(REPLACE_FREXPL)|g' \
771 -e 's|@''REPLACE_HUGE_VAL''@|$(REPLACE_HUGE_VAL)|g' \ 835 -e 's|@''REPLACE_HUGE_VAL''@|$(REPLACE_HUGE_VAL)|g' \
836 -e 's|@''REPLACE_HYPOT''@|$(REPLACE_HYPOT)|g' \
837 -e 's|@''REPLACE_HYPOTF''@|$(REPLACE_HYPOTF)|g' \
838 -e 's|@''REPLACE_HYPOTL''@|$(REPLACE_HYPOTL)|g' \
839 -e 's|@''REPLACE_ILOGB''@|$(REPLACE_ILOGB)|g' \
840 -e 's|@''REPLACE_ILOGBF''@|$(REPLACE_ILOGBF)|g' \
772 -e 's|@''REPLACE_ISFINITE''@|$(REPLACE_ISFINITE)|g' \ 841 -e 's|@''REPLACE_ISFINITE''@|$(REPLACE_ISFINITE)|g' \
773 -e 's|@''REPLACE_ISINF''@|$(REPLACE_ISINF)|g' \ 842 -e 's|@''REPLACE_ISINF''@|$(REPLACE_ISINF)|g' \
774 -e 's|@''REPLACE_ISNAN''@|$(REPLACE_ISNAN)|g' \ 843 -e 's|@''REPLACE_ISNAN''@|$(REPLACE_ISNAN)|g' \
844 -e 's|@''REPLACE_ITOLD''@|$(REPLACE_ITOLD)|g' \
775 -e 's|@''REPLACE_LDEXPL''@|$(REPLACE_LDEXPL)|g' \ 845 -e 's|@''REPLACE_LDEXPL''@|$(REPLACE_LDEXPL)|g' \
846 -e 's|@''REPLACE_LOG''@|$(REPLACE_LOG)|g' \
847 -e 's|@''REPLACE_LOGF''@|$(REPLACE_LOGF)|g' \
848 -e 's|@''REPLACE_LOGL''@|$(REPLACE_LOGL)|g' \
849 -e 's|@''REPLACE_LOG10''@|$(REPLACE_LOG10)|g' \
850 -e 's|@''REPLACE_LOG10F''@|$(REPLACE_LOG10F)|g' \
851 -e 's|@''REPLACE_LOG10L''@|$(REPLACE_LOG10L)|g' \
852 -e 's|@''REPLACE_LOG1P''@|$(REPLACE_LOG1P)|g' \
853 -e 's|@''REPLACE_LOG1PF''@|$(REPLACE_LOG1PF)|g' \
854 -e 's|@''REPLACE_LOG1PL''@|$(REPLACE_LOG1PL)|g' \
855 -e 's|@''REPLACE_LOG2''@|$(REPLACE_LOG2)|g' \
856 -e 's|@''REPLACE_LOG2F''@|$(REPLACE_LOG2F)|g' \
857 -e 's|@''REPLACE_LOG2L''@|$(REPLACE_LOG2L)|g' \
858 -e 's|@''REPLACE_LOGB''@|$(REPLACE_LOGB)|g' \
859 -e 's|@''REPLACE_LOGBF''@|$(REPLACE_LOGBF)|g' \
860 -e 's|@''REPLACE_LOGBL''@|$(REPLACE_LOGBL)|g' \
861 -e 's|@''REPLACE_MODF''@|$(REPLACE_MODF)|g' \
862 -e 's|@''REPLACE_MODFF''@|$(REPLACE_MODFF)|g' \
863 -e 's|@''REPLACE_MODFL''@|$(REPLACE_MODFL)|g' \
776 -e 's|@''REPLACE_NAN''@|$(REPLACE_NAN)|g' \ 864 -e 's|@''REPLACE_NAN''@|$(REPLACE_NAN)|g' \
865 -e 's|@''REPLACE_REMAINDER''@|$(REPLACE_REMAINDER)|g' \
866 -e 's|@''REPLACE_REMAINDERF''@|$(REPLACE_REMAINDERF)|g' \
867 -e 's|@''REPLACE_REMAINDERL''@|$(REPLACE_REMAINDERL)|g' \
777 -e 's|@''REPLACE_ROUND''@|$(REPLACE_ROUND)|g' \ 868 -e 's|@''REPLACE_ROUND''@|$(REPLACE_ROUND)|g' \
778 -e 's|@''REPLACE_ROUNDF''@|$(REPLACE_ROUNDF)|g' \ 869 -e 's|@''REPLACE_ROUNDF''@|$(REPLACE_ROUNDF)|g' \
779 -e 's|@''REPLACE_ROUNDL''@|$(REPLACE_ROUNDL)|g' \ 870 -e 's|@''REPLACE_ROUNDL''@|$(REPLACE_ROUNDL)|g' \
780 -e 's|@''REPLACE_SIGNBIT''@|$(REPLACE_SIGNBIT)|g' \ 871 -e 's|@''REPLACE_SIGNBIT''@|$(REPLACE_SIGNBIT)|g' \
781 -e 's|@''REPLACE_SIGNBIT_USING_GCC''@|$(REPLACE_SIGNBIT_USING_GCC)|g' \ 872 -e 's|@''REPLACE_SIGNBIT_USING_GCC''@|$(REPLACE_SIGNBIT_USING_GCC)|g' \
873 -e 's|@''REPLACE_SQRTL''@|$(REPLACE_SQRTL)|g' \
874 -e 's|@''REPLACE_TRUNC''@|$(REPLACE_TRUNC)|g' \
875 -e 's|@''REPLACE_TRUNCF''@|$(REPLACE_TRUNCF)|g' \
782 -e 's|@''REPLACE_TRUNCL''@|$(REPLACE_TRUNCL)|g' \ 876 -e 's|@''REPLACE_TRUNCL''@|$(REPLACE_TRUNCL)|g' \
783 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 877 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
784 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 878 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
785 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ 879 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
786 < $(srcdir)/math.in.h; \
787 } > $@-t && \ 880 } > $@-t && \
788 mv $@-t $@ 881 mv $@-t $@
789MOSTLYCLEANFILES += math.h math.h-t 882MOSTLYCLEANFILES += math.h math.h-t
@@ -810,6 +903,15 @@ EXTRA_libgnu_a_SOURCES += mbsinit.c
810 903
811## end gnulib module mbsinit 904## end gnulib module mbsinit
812 905
906## begin gnulib module mbtowc
907
908
909EXTRA_DIST += mbtowc-impl.h mbtowc.c
910
911EXTRA_libgnu_a_SOURCES += mbtowc.c
912
913## end gnulib module mbtowc
914
813## begin gnulib module memchr 915## begin gnulib module memchr
814 916
815 917
@@ -828,6 +930,15 @@ EXTRA_libgnu_a_SOURCES += mktime.c
828 930
829## end gnulib module mktime 931## end gnulib module mktime
830 932
933## begin gnulib module mktime-internal
934
935
936EXTRA_DIST += mktime-internal.h mktime.c
937
938EXTRA_libgnu_a_SOURCES += mktime.c
939
940## end gnulib module mktime-internal
941
831## begin gnulib module mountlist 942## begin gnulib module mountlist
832 943
833 944
@@ -837,25 +948,47 @@ EXTRA_libgnu_a_SOURCES += mountlist.c
837 948
838## end gnulib module mountlist 949## end gnulib module mountlist
839 950
951## begin gnulib module msvc-inval
952
953
954EXTRA_DIST += msvc-inval.c msvc-inval.h
955
956EXTRA_libgnu_a_SOURCES += msvc-inval.c
957
958## end gnulib module msvc-inval
959
960## begin gnulib module msvc-nothrow
961
962
963EXTRA_DIST += msvc-nothrow.c msvc-nothrow.h
964
965EXTRA_libgnu_a_SOURCES += msvc-nothrow.c
966
967## end gnulib module msvc-nothrow
968
840## begin gnulib module netdb 969## begin gnulib module netdb
841 970
842BUILT_SOURCES += netdb.h 971BUILT_SOURCES += netdb.h
843 972
844# We need the following in order to create <netdb.h> when the system 973# We need the following in order to create <netdb.h> when the system
845# doesn't have one that works with the given compiler. 974# doesn't have one that works with the given compiler.
846netdb.h: netdb.in.h $(ARG_NONNULL_H) $(WARN_ON_USE_H) 975netdb.h: netdb.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
847 $(AM_V_GEN)rm -f $@-t $@ && \ 976 $(AM_V_GEN)rm -f $@-t $@ && \
848 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 977 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
849 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 978 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
979 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
850 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 980 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
981 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
851 -e 's|@''NEXT_NETDB_H''@|$(NEXT_NETDB_H)|g' \ 982 -e 's|@''NEXT_NETDB_H''@|$(NEXT_NETDB_H)|g' \
852 -e 's|@''HAVE_NETDB_H''@|$(HAVE_NETDB_H)|g' \ 983 -e 's|@''HAVE_NETDB_H''@|$(HAVE_NETDB_H)|g' \
853 -e 's|@''GNULIB_GETADDRINFO''@|$(GNULIB_GETADDRINFO)|g' \ 984 -e 's/@''GNULIB_GETADDRINFO''@/$(GNULIB_GETADDRINFO)/g' \
854 -e 's|@''HAVE_STRUCT_ADDRINFO''@|$(HAVE_STRUCT_ADDRINFO)|g' \ 985 -e 's|@''HAVE_STRUCT_ADDRINFO''@|$(HAVE_STRUCT_ADDRINFO)|g' \
855 -e 's|@''HAVE_DECL_FREEADDRINFO''@|$(HAVE_DECL_FREEADDRINFO)|g' \ 986 -e 's|@''HAVE_DECL_FREEADDRINFO''@|$(HAVE_DECL_FREEADDRINFO)|g' \
856 -e 's|@''HAVE_DECL_GAI_STRERROR''@|$(HAVE_DECL_GAI_STRERROR)|g' \ 987 -e 's|@''HAVE_DECL_GAI_STRERROR''@|$(HAVE_DECL_GAI_STRERROR)|g' \
857 -e 's|@''HAVE_DECL_GETADDRINFO''@|$(HAVE_DECL_GETADDRINFO)|g' \ 988 -e 's|@''HAVE_DECL_GETADDRINFO''@|$(HAVE_DECL_GETADDRINFO)|g' \
858 -e 's|@''HAVE_DECL_GETNAMEINFO''@|$(HAVE_DECL_GETNAMEINFO)|g' \ 989 -e 's|@''HAVE_DECL_GETNAMEINFO''@|$(HAVE_DECL_GETNAMEINFO)|g' \
990 -e 's|@''REPLACE_GAI_STRERROR''@|$(REPLACE_GAI_STRERROR)|g' \
991 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
859 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 992 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
860 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ 993 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
861 < $(srcdir)/netdb.in.h; \ 994 < $(srcdir)/netdb.in.h; \
@@ -873,17 +1006,24 @@ BUILT_SOURCES += $(NETINET_IN_H)
873 1006
874# We need the following in order to create <netinet/in.h> when the system 1007# We need the following in order to create <netinet/in.h> when the system
875# doesn't have one. 1008# doesn't have one.
876netinet/in.h: netinet_in.in.h 1009if GL_GENERATE_NETINET_IN_H
1010netinet/in.h: netinet_in.in.h $(top_builddir)/config.status
877 $(AM_V_at)$(MKDIR_P) netinet 1011 $(AM_V_at)$(MKDIR_P) netinet
878 $(AM_V_GEN)rm -f $@-t $@ && \ 1012 $(AM_V_GEN)rm -f $@-t $@ && \
879 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 1013 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
880 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 1014 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1015 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
881 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 1016 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1017 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
882 -e 's|@''NEXT_NETINET_IN_H''@|$(NEXT_NETINET_IN_H)|g' \ 1018 -e 's|@''NEXT_NETINET_IN_H''@|$(NEXT_NETINET_IN_H)|g' \
883 -e 's|@''HAVE_NETINET_IN_H''@|$(HAVE_NETINET_IN_H)|g' \ 1019 -e 's|@''HAVE_NETINET_IN_H''@|$(HAVE_NETINET_IN_H)|g' \
884 < $(srcdir)/netinet_in.in.h; \ 1020 < $(srcdir)/netinet_in.in.h; \
885 } > $@-t && \ 1021 } > $@-t && \
886 mv $@-t $@ 1022 mv $@-t $@
1023else
1024netinet/in.h: $(top_builddir)/config.status
1025 rm -f $@
1026endif
887MOSTLYCLEANFILES += netinet/in.h netinet/in.h-t 1027MOSTLYCLEANFILES += netinet/in.h netinet/in.h-t
888MOSTLYCLEANDIRS += netinet 1028MOSTLYCLEANDIRS += netinet
889 1029
@@ -900,14 +1040,14 @@ EXTRA_libgnu_a_SOURCES += nl_langinfo.c
900 1040
901## end gnulib module nl_langinfo 1041## end gnulib module nl_langinfo
902 1042
903## begin gnulib module open 1043## begin gnulib module read
904 1044
905 1045
906EXTRA_DIST += open.c 1046EXTRA_DIST += read.c
907 1047
908EXTRA_libgnu_a_SOURCES += open.c 1048EXTRA_libgnu_a_SOURCES += read.c
909 1049
910## end gnulib module open 1050## end gnulib module read
911 1051
912## begin gnulib module regex 1052## begin gnulib module regex
913 1053
@@ -920,22 +1060,12 @@ EXTRA_libgnu_a_SOURCES += regcomp.c regex.c regex_internal.c regexec.c
920 1060
921## begin gnulib module safe-read 1061## begin gnulib module safe-read
922 1062
1063libgnu_a_SOURCES += safe-read.c
923 1064
924EXTRA_DIST += safe-read.c safe-read.h 1065EXTRA_DIST += safe-read.h
925
926EXTRA_libgnu_a_SOURCES += safe-read.c
927 1066
928## end gnulib module safe-read 1067## end gnulib module safe-read
929 1068
930## begin gnulib module safe-write
931
932
933EXTRA_DIST += safe-write.c safe-write.h
934
935EXTRA_libgnu_a_SOURCES += safe-write.c
936
937## end gnulib module safe-write
938
939## begin gnulib module setenv 1069## begin gnulib module setenv
940 1070
941 1071
@@ -951,6 +1081,87 @@ libgnu_a_SOURCES += size_max.h
951 1081
952## end gnulib module size_max 1082## end gnulib module size_max
953 1083
1084## begin gnulib module snippet/_Noreturn
1085
1086# Because this Makefile snippet defines a variable used by other
1087# gnulib Makefile snippets, it must be present in all Makefile.am that
1088# need it. This is ensured by the applicability 'all' defined above.
1089
1090_NORETURN_H=$(top_srcdir)/build-aux/snippet/_Noreturn.h
1091
1092EXTRA_DIST += $(top_srcdir)/build-aux/snippet/_Noreturn.h
1093
1094## end gnulib module snippet/_Noreturn
1095
1096## begin gnulib module snippet/arg-nonnull
1097
1098# The BUILT_SOURCES created by this Makefile snippet are not used via #include
1099# statements but through direct file reference. Therefore this snippet must be
1100# present in all Makefile.am that need it. This is ensured by the applicability
1101# 'all' defined above.
1102
1103BUILT_SOURCES += arg-nonnull.h
1104# The arg-nonnull.h that gets inserted into generated .h files is the same as
1105# build-aux/snippet/arg-nonnull.h, except that it has the copyright header cut
1106# off.
1107arg-nonnull.h: $(top_srcdir)/build-aux/snippet/arg-nonnull.h
1108 $(AM_V_GEN)rm -f $@-t $@ && \
1109 sed -n -e '/GL_ARG_NONNULL/,$$p' \
1110 < $(top_srcdir)/build-aux/snippet/arg-nonnull.h \
1111 > $@-t && \
1112 mv $@-t $@
1113MOSTLYCLEANFILES += arg-nonnull.h arg-nonnull.h-t
1114
1115ARG_NONNULL_H=arg-nonnull.h
1116
1117EXTRA_DIST += $(top_srcdir)/build-aux/snippet/arg-nonnull.h
1118
1119## end gnulib module snippet/arg-nonnull
1120
1121## begin gnulib module snippet/c++defs
1122
1123# The BUILT_SOURCES created by this Makefile snippet are not used via #include
1124# statements but through direct file reference. Therefore this snippet must be
1125# present in all Makefile.am that need it. This is ensured by the applicability
1126# 'all' defined above.
1127
1128BUILT_SOURCES += c++defs.h
1129# The c++defs.h that gets inserted into generated .h files is the same as
1130# build-aux/snippet/c++defs.h, except that it has the copyright header cut off.
1131c++defs.h: $(top_srcdir)/build-aux/snippet/c++defs.h
1132 $(AM_V_GEN)rm -f $@-t $@ && \
1133 sed -n -e '/_GL_CXXDEFS/,$$p' \
1134 < $(top_srcdir)/build-aux/snippet/c++defs.h \
1135 > $@-t && \
1136 mv $@-t $@
1137MOSTLYCLEANFILES += c++defs.h c++defs.h-t
1138
1139CXXDEFS_H=c++defs.h
1140
1141EXTRA_DIST += $(top_srcdir)/build-aux/snippet/c++defs.h
1142
1143## end gnulib module snippet/c++defs
1144
1145## begin gnulib module snippet/warn-on-use
1146
1147BUILT_SOURCES += warn-on-use.h
1148# The warn-on-use.h that gets inserted into generated .h files is the same as
1149# build-aux/snippet/warn-on-use.h, except that it has the copyright header cut
1150# off.
1151warn-on-use.h: $(top_srcdir)/build-aux/snippet/warn-on-use.h
1152 $(AM_V_GEN)rm -f $@-t $@ && \
1153 sed -n -e '/^.ifndef/,$$p' \
1154 < $(top_srcdir)/build-aux/snippet/warn-on-use.h \
1155 > $@-t && \
1156 mv $@-t $@
1157MOSTLYCLEANFILES += warn-on-use.h warn-on-use.h-t
1158
1159WARN_ON_USE_H=warn-on-use.h
1160
1161EXTRA_DIST += $(top_srcdir)/build-aux/snippet/warn-on-use.h
1162
1163## end gnulib module snippet/warn-on-use
1164
954## begin gnulib module snprintf 1165## begin gnulib module snprintf
955 1166
956 1167
@@ -968,14 +1179,28 @@ EXTRA_DIST += w32sock.h
968 1179
969## end gnulib module sockets 1180## end gnulib module sockets
970 1181
971## begin gnulib module stat 1182## begin gnulib module stdalign
972 1183
1184BUILT_SOURCES += $(STDALIGN_H)
973 1185
974EXTRA_DIST += stat.c 1186# We need the following in order to create <stdalign.h> when the system
1187# doesn't have one that works.
1188if GL_GENERATE_STDALIGN_H
1189stdalign.h: stdalign.in.h $(top_builddir)/config.status
1190 $(AM_V_GEN)rm -f $@-t $@ && \
1191 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
1192 cat $(srcdir)/stdalign.in.h; \
1193 } > $@-t && \
1194 mv $@-t $@
1195else
1196stdalign.h: $(top_builddir)/config.status
1197 rm -f $@
1198endif
1199MOSTLYCLEANFILES += stdalign.h stdalign.h-t
975 1200
976EXTRA_libgnu_a_SOURCES += stat.c 1201EXTRA_DIST += stdalign.in.h
977 1202
978## end gnulib module stat 1203## end gnulib module stdalign
979 1204
980## begin gnulib module stdbool 1205## begin gnulib module stdbool
981 1206
@@ -983,12 +1208,17 @@ BUILT_SOURCES += $(STDBOOL_H)
983 1208
984# We need the following in order to create <stdbool.h> when the system 1209# We need the following in order to create <stdbool.h> when the system
985# doesn't have one that works. 1210# doesn't have one that works.
986stdbool.h: stdbool.in.h 1211if GL_GENERATE_STDBOOL_H
1212stdbool.h: stdbool.in.h $(top_builddir)/config.status
987 $(AM_V_GEN)rm -f $@-t $@ && \ 1213 $(AM_V_GEN)rm -f $@-t $@ && \
988 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 1214 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
989 sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' < $(srcdir)/stdbool.in.h; \ 1215 sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' < $(srcdir)/stdbool.in.h; \
990 } > $@-t && \ 1216 } > $@-t && \
991 mv $@-t $@ 1217 mv $@-t $@
1218else
1219stdbool.h: $(top_builddir)/config.status
1220 rm -f $@
1221endif
992MOSTLYCLEANFILES += stdbool.h stdbool.h-t 1222MOSTLYCLEANFILES += stdbool.h stdbool.h-t
993 1223
994EXTRA_DIST += stdbool.in.h 1224EXTRA_DIST += stdbool.in.h
@@ -1001,17 +1231,24 @@ BUILT_SOURCES += $(STDDEF_H)
1001 1231
1002# We need the following in order to create <stddef.h> when the system 1232# We need the following in order to create <stddef.h> when the system
1003# doesn't have one that works with the given compiler. 1233# doesn't have one that works with the given compiler.
1004stddef.h: stddef.in.h 1234if GL_GENERATE_STDDEF_H
1235stddef.h: stddef.in.h $(top_builddir)/config.status
1005 $(AM_V_GEN)rm -f $@-t $@ && \ 1236 $(AM_V_GEN)rm -f $@-t $@ && \
1006 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 1237 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
1007 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 1238 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1239 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1008 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 1240 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1241 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1009 -e 's|@''NEXT_STDDEF_H''@|$(NEXT_STDDEF_H)|g' \ 1242 -e 's|@''NEXT_STDDEF_H''@|$(NEXT_STDDEF_H)|g' \
1010 -e 's|@''HAVE_WCHAR_T''@|$(HAVE_WCHAR_T)|g' \ 1243 -e 's|@''HAVE_WCHAR_T''@|$(HAVE_WCHAR_T)|g' \
1011 -e 's|@''REPLACE_NULL''@|$(REPLACE_NULL)|g' \ 1244 -e 's|@''REPLACE_NULL''@|$(REPLACE_NULL)|g' \
1012 < $(srcdir)/stddef.in.h; \ 1245 < $(srcdir)/stddef.in.h; \
1013 } > $@-t && \ 1246 } > $@-t && \
1014 mv $@-t $@ 1247 mv $@-t $@
1248else
1249stddef.h: $(top_builddir)/config.status
1250 rm -f $@
1251endif
1015MOSTLYCLEANFILES += stddef.h stddef.h-t 1252MOSTLYCLEANFILES += stddef.h stddef.h-t
1016 1253
1017EXTRA_DIST += stddef.in.h 1254EXTRA_DIST += stddef.in.h
@@ -1024,17 +1261,21 @@ BUILT_SOURCES += $(STDINT_H)
1024 1261
1025# We need the following in order to create <stdint.h> when the system 1262# We need the following in order to create <stdint.h> when the system
1026# doesn't have one that works with the given compiler. 1263# doesn't have one that works with the given compiler.
1027stdint.h: stdint.in.h 1264if GL_GENERATE_STDINT_H
1265stdint.h: stdint.in.h $(top_builddir)/config.status
1028 $(AM_V_GEN)rm -f $@-t $@ && \ 1266 $(AM_V_GEN)rm -f $@-t $@ && \
1029 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 1267 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
1030 sed -e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \ 1268 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1269 -e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \
1031 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 1270 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1032 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 1271 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1272 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1033 -e 's|@''NEXT_STDINT_H''@|$(NEXT_STDINT_H)|g' \ 1273 -e 's|@''NEXT_STDINT_H''@|$(NEXT_STDINT_H)|g' \
1034 -e 's/@''HAVE_SYS_TYPES_H''@/$(HAVE_SYS_TYPES_H)/g' \ 1274 -e 's/@''HAVE_SYS_TYPES_H''@/$(HAVE_SYS_TYPES_H)/g' \
1035 -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \ 1275 -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \
1036 -e 's/@''HAVE_SYS_INTTYPES_H''@/$(HAVE_SYS_INTTYPES_H)/g' \ 1276 -e 's/@''HAVE_SYS_INTTYPES_H''@/$(HAVE_SYS_INTTYPES_H)/g' \
1037 -e 's/@''HAVE_SYS_BITYPES_H''@/$(HAVE_SYS_BITYPES_H)/g' \ 1277 -e 's/@''HAVE_SYS_BITYPES_H''@/$(HAVE_SYS_BITYPES_H)/g' \
1278 -e 's/@''HAVE_WCHAR_H''@/$(HAVE_WCHAR_H)/g' \
1038 -e 's/@''HAVE_LONG_LONG_INT''@/$(HAVE_LONG_LONG_INT)/g' \ 1279 -e 's/@''HAVE_LONG_LONG_INT''@/$(HAVE_LONG_LONG_INT)/g' \
1039 -e 's/@''HAVE_UNSIGNED_LONG_LONG_INT''@/$(HAVE_UNSIGNED_LONG_LONG_INT)/g' \ 1280 -e 's/@''HAVE_UNSIGNED_LONG_LONG_INT''@/$(HAVE_UNSIGNED_LONG_LONG_INT)/g' \
1040 -e 's/@''APPLE_UNIVERSAL_BUILD''@/$(APPLE_UNIVERSAL_BUILD)/g' \ 1281 -e 's/@''APPLE_UNIVERSAL_BUILD''@/$(APPLE_UNIVERSAL_BUILD)/g' \
@@ -1054,6 +1295,10 @@ stdint.h: stdint.in.h
1054 < $(srcdir)/stdint.in.h; \ 1295 < $(srcdir)/stdint.in.h; \
1055 } > $@-t && \ 1296 } > $@-t && \
1056 mv $@-t $@ 1297 mv $@-t $@
1298else
1299stdint.h: $(top_builddir)/config.status
1300 rm -f $@
1301endif
1057MOSTLYCLEANFILES += stdint.h stdint.h-t 1302MOSTLYCLEANFILES += stdint.h stdint.h-t
1058 1303
1059EXTRA_DIST += stdint.in.h 1304EXTRA_DIST += stdint.in.h
@@ -1066,55 +1311,71 @@ BUILT_SOURCES += stdio.h
1066 1311
1067# We need the following in order to create <stdio.h> when the system 1312# We need the following in order to create <stdio.h> when the system
1068# doesn't have one that works with the given compiler. 1313# doesn't have one that works with the given compiler.
1069stdio.h: stdio.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 1314stdio.h: stdio.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
1070 $(AM_V_GEN)rm -f $@-t $@ && \ 1315 $(AM_V_GEN)rm -f $@-t $@ && \
1071 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 1316 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
1072 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 1317 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1318 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1073 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 1319 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1320 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1074 -e 's|@''NEXT_STDIO_H''@|$(NEXT_STDIO_H)|g' \ 1321 -e 's|@''NEXT_STDIO_H''@|$(NEXT_STDIO_H)|g' \
1075 -e 's|@''GNULIB_DPRINTF''@|$(GNULIB_DPRINTF)|g' \ 1322 -e 's/@''GNULIB_DPRINTF''@/$(GNULIB_DPRINTF)/g' \
1076 -e 's|@''GNULIB_FCLOSE''@|$(GNULIB_FCLOSE)|g' \ 1323 -e 's/@''GNULIB_FCLOSE''@/$(GNULIB_FCLOSE)/g' \
1077 -e 's|@''GNULIB_FFLUSH''@|$(GNULIB_FFLUSH)|g' \ 1324 -e 's/@''GNULIB_FDOPEN''@/$(GNULIB_FDOPEN)/g' \
1078 -e 's|@''GNULIB_FOPEN''@|$(GNULIB_FOPEN)|g' \ 1325 -e 's/@''GNULIB_FFLUSH''@/$(GNULIB_FFLUSH)/g' \
1079 -e 's|@''GNULIB_FPRINTF''@|$(GNULIB_FPRINTF)|g' \ 1326 -e 's/@''GNULIB_FGETC''@/$(GNULIB_FGETC)/g' \
1080 -e 's|@''GNULIB_FPRINTF_POSIX''@|$(GNULIB_FPRINTF_POSIX)|g' \ 1327 -e 's/@''GNULIB_FGETS''@/$(GNULIB_FGETS)/g' \
1081 -e 's|@''GNULIB_FPURGE''@|$(GNULIB_FPURGE)|g' \ 1328 -e 's/@''GNULIB_FOPEN''@/$(GNULIB_FOPEN)/g' \
1082 -e 's|@''GNULIB_FPUTC''@|$(GNULIB_FPUTC)|g' \ 1329 -e 's/@''GNULIB_FPRINTF''@/$(GNULIB_FPRINTF)/g' \
1083 -e 's|@''GNULIB_FPUTS''@|$(GNULIB_FPUTS)|g' \ 1330 -e 's/@''GNULIB_FPRINTF_POSIX''@/$(GNULIB_FPRINTF_POSIX)/g' \
1084 -e 's|@''GNULIB_FREOPEN''@|$(GNULIB_FREOPEN)|g' \ 1331 -e 's/@''GNULIB_FPURGE''@/$(GNULIB_FPURGE)/g' \
1085 -e 's|@''GNULIB_FSEEK''@|$(GNULIB_FSEEK)|g' \ 1332 -e 's/@''GNULIB_FPUTC''@/$(GNULIB_FPUTC)/g' \
1086 -e 's|@''GNULIB_FSEEKO''@|$(GNULIB_FSEEKO)|g' \ 1333 -e 's/@''GNULIB_FPUTS''@/$(GNULIB_FPUTS)/g' \
1087 -e 's|@''GNULIB_FTELL''@|$(GNULIB_FTELL)|g' \ 1334 -e 's/@''GNULIB_FREAD''@/$(GNULIB_FREAD)/g' \
1088 -e 's|@''GNULIB_FTELLO''@|$(GNULIB_FTELLO)|g' \ 1335 -e 's/@''GNULIB_FREOPEN''@/$(GNULIB_FREOPEN)/g' \
1089 -e 's|@''GNULIB_FWRITE''@|$(GNULIB_FWRITE)|g' \ 1336 -e 's/@''GNULIB_FSCANF''@/$(GNULIB_FSCANF)/g' \
1090 -e 's|@''GNULIB_GETDELIM''@|$(GNULIB_GETDELIM)|g' \ 1337 -e 's/@''GNULIB_FSEEK''@/$(GNULIB_FSEEK)/g' \
1091 -e 's|@''GNULIB_GETLINE''@|$(GNULIB_GETLINE)|g' \ 1338 -e 's/@''GNULIB_FSEEKO''@/$(GNULIB_FSEEKO)/g' \
1092 -e 's|@''GNULIB_OBSTACK_PRINTF''@|$(GNULIB_OBSTACK_PRINTF)|g' \ 1339 -e 's/@''GNULIB_FTELL''@/$(GNULIB_FTELL)/g' \
1093 -e 's|@''GNULIB_OBSTACK_PRINTF_POSIX''@|$(GNULIB_OBSTACK_PRINTF_POSIX)|g' \ 1340 -e 's/@''GNULIB_FTELLO''@/$(GNULIB_FTELLO)/g' \
1094 -e 's|@''GNULIB_PERROR''@|$(GNULIB_PERROR)|g' \ 1341 -e 's/@''GNULIB_FWRITE''@/$(GNULIB_FWRITE)/g' \
1095 -e 's|@''GNULIB_POPEN''@|$(GNULIB_POPEN)|g' \ 1342 -e 's/@''GNULIB_GETC''@/$(GNULIB_GETC)/g' \
1096 -e 's|@''GNULIB_PRINTF''@|$(GNULIB_PRINTF)|g' \ 1343 -e 's/@''GNULIB_GETCHAR''@/$(GNULIB_GETCHAR)/g' \
1097 -e 's|@''GNULIB_PRINTF_POSIX''@|$(GNULIB_PRINTF_POSIX)|g' \ 1344 -e 's/@''GNULIB_GETDELIM''@/$(GNULIB_GETDELIM)/g' \
1098 -e 's|@''GNULIB_PUTC''@|$(GNULIB_PUTC)|g' \ 1345 -e 's/@''GNULIB_GETLINE''@/$(GNULIB_GETLINE)/g' \
1099 -e 's|@''GNULIB_PUTCHAR''@|$(GNULIB_PUTCHAR)|g' \ 1346 -e 's/@''GNULIB_OBSTACK_PRINTF''@/$(GNULIB_OBSTACK_PRINTF)/g' \
1100 -e 's|@''GNULIB_PUTS''@|$(GNULIB_PUTS)|g' \ 1347 -e 's/@''GNULIB_OBSTACK_PRINTF_POSIX''@/$(GNULIB_OBSTACK_PRINTF_POSIX)/g' \
1101 -e 's|@''GNULIB_REMOVE''@|$(GNULIB_REMOVE)|g' \ 1348 -e 's/@''GNULIB_PCLOSE''@/$(GNULIB_PCLOSE)/g' \
1102 -e 's|@''GNULIB_RENAME''@|$(GNULIB_RENAME)|g' \ 1349 -e 's/@''GNULIB_PERROR''@/$(GNULIB_PERROR)/g' \
1103 -e 's|@''GNULIB_RENAMEAT''@|$(GNULIB_RENAMEAT)|g' \ 1350 -e 's/@''GNULIB_POPEN''@/$(GNULIB_POPEN)/g' \
1104 -e 's|@''GNULIB_SNPRINTF''@|$(GNULIB_SNPRINTF)|g' \ 1351 -e 's/@''GNULIB_PRINTF''@/$(GNULIB_PRINTF)/g' \
1105 -e 's|@''GNULIB_SPRINTF_POSIX''@|$(GNULIB_SPRINTF_POSIX)|g' \ 1352 -e 's/@''GNULIB_PRINTF_POSIX''@/$(GNULIB_PRINTF_POSIX)/g' \
1106 -e 's|@''GNULIB_STDIO_H_SIGPIPE''@|$(GNULIB_STDIO_H_SIGPIPE)|g' \ 1353 -e 's/@''GNULIB_PUTC''@/$(GNULIB_PUTC)/g' \
1107 -e 's|@''GNULIB_TMPFILE''@|$(GNULIB_TMPFILE)|g' \ 1354 -e 's/@''GNULIB_PUTCHAR''@/$(GNULIB_PUTCHAR)/g' \
1108 -e 's|@''GNULIB_VASPRINTF''@|$(GNULIB_VASPRINTF)|g' \ 1355 -e 's/@''GNULIB_PUTS''@/$(GNULIB_PUTS)/g' \
1109 -e 's|@''GNULIB_VDPRINTF''@|$(GNULIB_VDPRINTF)|g' \ 1356 -e 's/@''GNULIB_REMOVE''@/$(GNULIB_REMOVE)/g' \
1110 -e 's|@''GNULIB_VFPRINTF''@|$(GNULIB_VFPRINTF)|g' \ 1357 -e 's/@''GNULIB_RENAME''@/$(GNULIB_RENAME)/g' \
1111 -e 's|@''GNULIB_VFPRINTF_POSIX''@|$(GNULIB_VFPRINTF_POSIX)|g' \ 1358 -e 's/@''GNULIB_RENAMEAT''@/$(GNULIB_RENAMEAT)/g' \
1112 -e 's|@''GNULIB_VPRINTF''@|$(GNULIB_VPRINTF)|g' \ 1359 -e 's/@''GNULIB_SCANF''@/$(GNULIB_SCANF)/g' \
1113 -e 's|@''GNULIB_VPRINTF_POSIX''@|$(GNULIB_VPRINTF_POSIX)|g' \ 1360 -e 's/@''GNULIB_SNPRINTF''@/$(GNULIB_SNPRINTF)/g' \
1114 -e 's|@''GNULIB_VSNPRINTF''@|$(GNULIB_VSNPRINTF)|g' \ 1361 -e 's/@''GNULIB_SPRINTF_POSIX''@/$(GNULIB_SPRINTF_POSIX)/g' \
1115 -e 's|@''GNULIB_VSPRINTF_POSIX''@|$(GNULIB_VSPRINTF_POSIX)|g' \ 1362 -e 's/@''GNULIB_STDIO_H_NONBLOCKING''@/$(GNULIB_STDIO_H_NONBLOCKING)/g' \
1363 -e 's/@''GNULIB_STDIO_H_SIGPIPE''@/$(GNULIB_STDIO_H_SIGPIPE)/g' \
1364 -e 's/@''GNULIB_TMPFILE''@/$(GNULIB_TMPFILE)/g' \
1365 -e 's/@''GNULIB_VASPRINTF''@/$(GNULIB_VASPRINTF)/g' \
1366 -e 's/@''GNULIB_VDPRINTF''@/$(GNULIB_VDPRINTF)/g' \
1367 -e 's/@''GNULIB_VFPRINTF''@/$(GNULIB_VFPRINTF)/g' \
1368 -e 's/@''GNULIB_VFPRINTF_POSIX''@/$(GNULIB_VFPRINTF_POSIX)/g' \
1369 -e 's/@''GNULIB_VFSCANF''@/$(GNULIB_VFSCANF)/g' \
1370 -e 's/@''GNULIB_VSCANF''@/$(GNULIB_VSCANF)/g' \
1371 -e 's/@''GNULIB_VPRINTF''@/$(GNULIB_VPRINTF)/g' \
1372 -e 's/@''GNULIB_VPRINTF_POSIX''@/$(GNULIB_VPRINTF_POSIX)/g' \
1373 -e 's/@''GNULIB_VSNPRINTF''@/$(GNULIB_VSNPRINTF)/g' \
1374 -e 's/@''GNULIB_VSPRINTF_POSIX''@/$(GNULIB_VSPRINTF_POSIX)/g' \
1116 < $(srcdir)/stdio.in.h | \ 1375 < $(srcdir)/stdio.in.h | \
1117 sed -e 's|@''HAVE_DECL_FPURGE''@|$(HAVE_DECL_FPURGE)|g' \ 1376 sed -e 's|@''HAVE_DECL_FPURGE''@|$(HAVE_DECL_FPURGE)|g' \
1377 -e 's|@''HAVE_DECL_FSEEKO''@|$(HAVE_DECL_FSEEKO)|g' \
1378 -e 's|@''HAVE_DECL_FTELLO''@|$(HAVE_DECL_FTELLO)|g' \
1118 -e 's|@''HAVE_DECL_GETDELIM''@|$(HAVE_DECL_GETDELIM)|g' \ 1379 -e 's|@''HAVE_DECL_GETDELIM''@|$(HAVE_DECL_GETDELIM)|g' \
1119 -e 's|@''HAVE_DECL_GETLINE''@|$(HAVE_DECL_GETLINE)|g' \ 1380 -e 's|@''HAVE_DECL_GETLINE''@|$(HAVE_DECL_GETLINE)|g' \
1120 -e 's|@''HAVE_DECL_OBSTACK_PRINTF''@|$(HAVE_DECL_OBSTACK_PRINTF)|g' \ 1381 -e 's|@''HAVE_DECL_OBSTACK_PRINTF''@|$(HAVE_DECL_OBSTACK_PRINTF)|g' \
@@ -1123,11 +1384,14 @@ stdio.h: stdio.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
1123 -e 's|@''HAVE_DPRINTF''@|$(HAVE_DPRINTF)|g' \ 1384 -e 's|@''HAVE_DPRINTF''@|$(HAVE_DPRINTF)|g' \
1124 -e 's|@''HAVE_FSEEKO''@|$(HAVE_FSEEKO)|g' \ 1385 -e 's|@''HAVE_FSEEKO''@|$(HAVE_FSEEKO)|g' \
1125 -e 's|@''HAVE_FTELLO''@|$(HAVE_FTELLO)|g' \ 1386 -e 's|@''HAVE_FTELLO''@|$(HAVE_FTELLO)|g' \
1387 -e 's|@''HAVE_PCLOSE''@|$(HAVE_PCLOSE)|g' \
1388 -e 's|@''HAVE_POPEN''@|$(HAVE_POPEN)|g' \
1126 -e 's|@''HAVE_RENAMEAT''@|$(HAVE_RENAMEAT)|g' \ 1389 -e 's|@''HAVE_RENAMEAT''@|$(HAVE_RENAMEAT)|g' \
1127 -e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \ 1390 -e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \
1128 -e 's|@''HAVE_VDPRINTF''@|$(HAVE_VDPRINTF)|g' \ 1391 -e 's|@''HAVE_VDPRINTF''@|$(HAVE_VDPRINTF)|g' \
1129 -e 's|@''REPLACE_DPRINTF''@|$(REPLACE_DPRINTF)|g' \ 1392 -e 's|@''REPLACE_DPRINTF''@|$(REPLACE_DPRINTF)|g' \
1130 -e 's|@''REPLACE_FCLOSE''@|$(REPLACE_FCLOSE)|g' \ 1393 -e 's|@''REPLACE_FCLOSE''@|$(REPLACE_FCLOSE)|g' \
1394 -e 's|@''REPLACE_FDOPEN''@|$(REPLACE_FDOPEN)|g' \
1131 -e 's|@''REPLACE_FFLUSH''@|$(REPLACE_FFLUSH)|g' \ 1395 -e 's|@''REPLACE_FFLUSH''@|$(REPLACE_FFLUSH)|g' \
1132 -e 's|@''REPLACE_FOPEN''@|$(REPLACE_FOPEN)|g' \ 1396 -e 's|@''REPLACE_FOPEN''@|$(REPLACE_FOPEN)|g' \
1133 -e 's|@''REPLACE_FPRINTF''@|$(REPLACE_FPRINTF)|g' \ 1397 -e 's|@''REPLACE_FPRINTF''@|$(REPLACE_FPRINTF)|g' \
@@ -1148,6 +1412,7 @@ stdio.h: stdio.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
1148 -e 's|@''REPLACE_RENAMEAT''@|$(REPLACE_RENAMEAT)|g' \ 1412 -e 's|@''REPLACE_RENAMEAT''@|$(REPLACE_RENAMEAT)|g' \
1149 -e 's|@''REPLACE_SNPRINTF''@|$(REPLACE_SNPRINTF)|g' \ 1413 -e 's|@''REPLACE_SNPRINTF''@|$(REPLACE_SNPRINTF)|g' \
1150 -e 's|@''REPLACE_SPRINTF''@|$(REPLACE_SPRINTF)|g' \ 1414 -e 's|@''REPLACE_SPRINTF''@|$(REPLACE_SPRINTF)|g' \
1415 -e 's|@''REPLACE_STDIO_READ_FUNCS''@|$(REPLACE_STDIO_READ_FUNCS)|g' \
1151 -e 's|@''REPLACE_STDIO_WRITE_FUNCS''@|$(REPLACE_STDIO_WRITE_FUNCS)|g' \ 1416 -e 's|@''REPLACE_STDIO_WRITE_FUNCS''@|$(REPLACE_STDIO_WRITE_FUNCS)|g' \
1152 -e 's|@''REPLACE_TMPFILE''@|$(REPLACE_TMPFILE)|g' \ 1417 -e 's|@''REPLACE_TMPFILE''@|$(REPLACE_TMPFILE)|g' \
1153 -e 's|@''REPLACE_VASPRINTF''@|$(REPLACE_VASPRINTF)|g' \ 1418 -e 's|@''REPLACE_VASPRINTF''@|$(REPLACE_VASPRINTF)|g' \
@@ -1164,9 +1429,7 @@ stdio.h: stdio.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
1164 mv $@-t $@ 1429 mv $@-t $@
1165MOSTLYCLEANFILES += stdio.h stdio.h-t 1430MOSTLYCLEANFILES += stdio.h stdio.h-t
1166 1431
1167EXTRA_DIST += stdio-write.c stdio.in.h 1432EXTRA_DIST += stdio.in.h
1168
1169EXTRA_libgnu_a_SOURCES += stdio-write.c
1170 1433
1171## end gnulib module stdio 1434## end gnulib module stdio
1172 1435
@@ -1176,38 +1439,49 @@ BUILT_SOURCES += stdlib.h
1176 1439
1177# We need the following in order to create <stdlib.h> when the system 1440# We need the following in order to create <stdlib.h> when the system
1178# doesn't have one that works with the given compiler. 1441# doesn't have one that works with the given compiler.
1179stdlib.h: stdlib.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 1442stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
1443 $(_NORETURN_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
1180 $(AM_V_GEN)rm -f $@-t $@ && \ 1444 $(AM_V_GEN)rm -f $@-t $@ && \
1181 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 1445 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
1182 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 1446 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1447 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1183 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 1448 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1449 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1184 -e 's|@''NEXT_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \ 1450 -e 's|@''NEXT_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \
1185 -e 's|@''GNULIB__EXIT''@|$(GNULIB__EXIT)|g' \ 1451 -e 's/@''GNULIB__EXIT''@/$(GNULIB__EXIT)/g' \
1186 -e 's|@''GNULIB_ATOLL''@|$(GNULIB_ATOLL)|g' \ 1452 -e 's/@''GNULIB_ATOLL''@/$(GNULIB_ATOLL)/g' \
1187 -e 's|@''GNULIB_CALLOC_POSIX''@|$(GNULIB_CALLOC_POSIX)|g' \ 1453 -e 's/@''GNULIB_CALLOC_POSIX''@/$(GNULIB_CALLOC_POSIX)/g' \
1188 -e 's|@''GNULIB_CANONICALIZE_FILE_NAME''@|$(GNULIB_CANONICALIZE_FILE_NAME)|g' \ 1454 -e 's/@''GNULIB_CANONICALIZE_FILE_NAME''@/$(GNULIB_CANONICALIZE_FILE_NAME)/g' \
1189 -e 's|@''GNULIB_GETLOADAVG''@|$(GNULIB_GETLOADAVG)|g' \ 1455 -e 's/@''GNULIB_GETLOADAVG''@/$(GNULIB_GETLOADAVG)/g' \
1190 -e 's|@''GNULIB_GETSUBOPT''@|$(GNULIB_GETSUBOPT)|g' \ 1456 -e 's/@''GNULIB_GETSUBOPT''@/$(GNULIB_GETSUBOPT)/g' \
1191 -e 's|@''GNULIB_GRANTPT''@|$(GNULIB_GRANTPT)|g' \ 1457 -e 's/@''GNULIB_GRANTPT''@/$(GNULIB_GRANTPT)/g' \
1192 -e 's|@''GNULIB_MALLOC_POSIX''@|$(GNULIB_MALLOC_POSIX)|g' \ 1458 -e 's/@''GNULIB_MALLOC_POSIX''@/$(GNULIB_MALLOC_POSIX)/g' \
1193 -e 's|@''GNULIB_MKDTEMP''@|$(GNULIB_MKDTEMP)|g' \ 1459 -e 's/@''GNULIB_MBTOWC''@/$(GNULIB_MBTOWC)/g' \
1194 -e 's|@''GNULIB_MKOSTEMP''@|$(GNULIB_MKOSTEMP)|g' \ 1460 -e 's/@''GNULIB_MKDTEMP''@/$(GNULIB_MKDTEMP)/g' \
1195 -e 's|@''GNULIB_MKOSTEMPS''@|$(GNULIB_MKOSTEMPS)|g' \ 1461 -e 's/@''GNULIB_MKOSTEMP''@/$(GNULIB_MKOSTEMP)/g' \
1196 -e 's|@''GNULIB_MKSTEMP''@|$(GNULIB_MKSTEMP)|g' \ 1462 -e 's/@''GNULIB_MKOSTEMPS''@/$(GNULIB_MKOSTEMPS)/g' \
1197 -e 's|@''GNULIB_MKSTEMPS''@|$(GNULIB_MKSTEMPS)|g' \ 1463 -e 's/@''GNULIB_MKSTEMP''@/$(GNULIB_MKSTEMP)/g' \
1198 -e 's|@''GNULIB_PTSNAME''@|$(GNULIB_PTSNAME)|g' \ 1464 -e 's/@''GNULIB_MKSTEMPS''@/$(GNULIB_MKSTEMPS)/g' \
1199 -e 's|@''GNULIB_PUTENV''@|$(GNULIB_PUTENV)|g' \ 1465 -e 's/@''GNULIB_POSIX_OPENPT''@/$(GNULIB_POSIX_OPENPT)/g' \
1200 -e 's|@''GNULIB_RANDOM_R''@|$(GNULIB_RANDOM_R)|g' \ 1466 -e 's/@''GNULIB_PTSNAME''@/$(GNULIB_PTSNAME)/g' \
1201 -e 's|@''GNULIB_REALLOC_POSIX''@|$(GNULIB_REALLOC_POSIX)|g' \ 1467 -e 's/@''GNULIB_PTSNAME_R''@/$(GNULIB_PTSNAME_R)/g' \
1202 -e 's|@''GNULIB_REALPATH''@|$(GNULIB_REALPATH)|g' \ 1468 -e 's/@''GNULIB_PUTENV''@/$(GNULIB_PUTENV)/g' \
1203 -e 's|@''GNULIB_RPMATCH''@|$(GNULIB_RPMATCH)|g' \ 1469 -e 's/@''GNULIB_RANDOM''@/$(GNULIB_RANDOM)/g' \
1204 -e 's|@''GNULIB_SETENV''@|$(GNULIB_SETENV)|g' \ 1470 -e 's/@''GNULIB_RANDOM_R''@/$(GNULIB_RANDOM_R)/g' \
1205 -e 's|@''GNULIB_STRTOD''@|$(GNULIB_STRTOD)|g' \ 1471 -e 's/@''GNULIB_REALLOC_POSIX''@/$(GNULIB_REALLOC_POSIX)/g' \
1206 -e 's|@''GNULIB_STRTOLL''@|$(GNULIB_STRTOLL)|g' \ 1472 -e 's/@''GNULIB_REALPATH''@/$(GNULIB_REALPATH)/g' \
1207 -e 's|@''GNULIB_STRTOULL''@|$(GNULIB_STRTOULL)|g' \ 1473 -e 's/@''GNULIB_RPMATCH''@/$(GNULIB_RPMATCH)/g' \
1208 -e 's|@''GNULIB_UNLOCKPT''@|$(GNULIB_UNLOCKPT)|g' \ 1474 -e 's/@''GNULIB_SECURE_GETENV''@/$(GNULIB_SECURE_GETENV)/g' \
1209 -e 's|@''GNULIB_UNSETENV''@|$(GNULIB_UNSETENV)|g' \ 1475 -e 's/@''GNULIB_SETENV''@/$(GNULIB_SETENV)/g' \
1210 -e 's|@''HAVE__EXIT''@|$(HAVE__EXIT)|g' \ 1476 -e 's/@''GNULIB_STRTOD''@/$(GNULIB_STRTOD)/g' \
1477 -e 's/@''GNULIB_STRTOLL''@/$(GNULIB_STRTOLL)/g' \
1478 -e 's/@''GNULIB_STRTOULL''@/$(GNULIB_STRTOULL)/g' \
1479 -e 's/@''GNULIB_SYSTEM_POSIX''@/$(GNULIB_SYSTEM_POSIX)/g' \
1480 -e 's/@''GNULIB_UNLOCKPT''@/$(GNULIB_UNLOCKPT)/g' \
1481 -e 's/@''GNULIB_UNSETENV''@/$(GNULIB_UNSETENV)/g' \
1482 -e 's/@''GNULIB_WCTOMB''@/$(GNULIB_WCTOMB)/g' \
1483 < $(srcdir)/stdlib.in.h | \
1484 sed -e 's|@''HAVE__EXIT''@|$(HAVE__EXIT)|g' \
1211 -e 's|@''HAVE_ATOLL''@|$(HAVE_ATOLL)|g' \ 1485 -e 's|@''HAVE_ATOLL''@|$(HAVE_ATOLL)|g' \
1212 -e 's|@''HAVE_CANONICALIZE_FILE_NAME''@|$(HAVE_CANONICALIZE_FILE_NAME)|g' \ 1486 -e 's|@''HAVE_CANONICALIZE_FILE_NAME''@|$(HAVE_CANONICALIZE_FILE_NAME)|g' \
1213 -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \ 1487 -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \
@@ -1218,33 +1492,42 @@ stdlib.h: stdlib.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
1218 -e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \ 1492 -e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \
1219 -e 's|@''HAVE_MKSTEMP''@|$(HAVE_MKSTEMP)|g' \ 1493 -e 's|@''HAVE_MKSTEMP''@|$(HAVE_MKSTEMP)|g' \
1220 -e 's|@''HAVE_MKSTEMPS''@|$(HAVE_MKSTEMPS)|g' \ 1494 -e 's|@''HAVE_MKSTEMPS''@|$(HAVE_MKSTEMPS)|g' \
1495 -e 's|@''HAVE_POSIX_OPENPT''@|$(HAVE_POSIX_OPENPT)|g' \
1221 -e 's|@''HAVE_PTSNAME''@|$(HAVE_PTSNAME)|g' \ 1496 -e 's|@''HAVE_PTSNAME''@|$(HAVE_PTSNAME)|g' \
1497 -e 's|@''HAVE_PTSNAME_R''@|$(HAVE_PTSNAME_R)|g' \
1498 -e 's|@''HAVE_RANDOM''@|$(HAVE_RANDOM)|g' \
1222 -e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \ 1499 -e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \
1223 -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \ 1500 -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \
1224 -e 's|@''HAVE_REALPATH''@|$(HAVE_REALPATH)|g' \ 1501 -e 's|@''HAVE_REALPATH''@|$(HAVE_REALPATH)|g' \
1225 -e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \ 1502 -e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \
1226 -e 's|@''HAVE_SETENV''@|$(HAVE_SETENV)|g' \ 1503 -e 's|@''HAVE_SECURE_GETENV''@|$(HAVE_SECURE_GETENV)|g' \
1504 -e 's|@''HAVE_DECL_SETENV''@|$(HAVE_DECL_SETENV)|g' \
1227 -e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \ 1505 -e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \
1228 -e 's|@''HAVE_STRTOLL''@|$(HAVE_STRTOLL)|g' \ 1506 -e 's|@''HAVE_STRTOLL''@|$(HAVE_STRTOLL)|g' \
1229 -e 's|@''HAVE_STRTOULL''@|$(HAVE_STRTOULL)|g' \ 1507 -e 's|@''HAVE_STRTOULL''@|$(HAVE_STRTOULL)|g' \
1230 -e 's|@''HAVE_STRUCT_RANDOM_DATA''@|$(HAVE_STRUCT_RANDOM_DATA)|g' \ 1508 -e 's|@''HAVE_STRUCT_RANDOM_DATA''@|$(HAVE_STRUCT_RANDOM_DATA)|g' \
1231 -e 's|@''HAVE_SYS_LOADAVG_H''@|$(HAVE_SYS_LOADAVG_H)|g' \ 1509 -e 's|@''HAVE_SYS_LOADAVG_H''@|$(HAVE_SYS_LOADAVG_H)|g' \
1232 -e 's|@''HAVE_UNLOCKPT''@|$(HAVE_UNLOCKPT)|g' \ 1510 -e 's|@''HAVE_UNLOCKPT''@|$(HAVE_UNLOCKPT)|g' \
1233 -e 's|@''HAVE_UNSETENV''@|$(HAVE_UNSETENV)|g' \ 1511 -e 's|@''HAVE_DECL_UNSETENV''@|$(HAVE_DECL_UNSETENV)|g' \
1234 -e 's|@''REPLACE_CALLOC''@|$(REPLACE_CALLOC)|g' \ 1512 -e 's|@''REPLACE_CALLOC''@|$(REPLACE_CALLOC)|g' \
1235 -e 's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \ 1513 -e 's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \
1236 -e 's|@''REPLACE_MALLOC''@|$(REPLACE_MALLOC)|g' \ 1514 -e 's|@''REPLACE_MALLOC''@|$(REPLACE_MALLOC)|g' \
1515 -e 's|@''REPLACE_MBTOWC''@|$(REPLACE_MBTOWC)|g' \
1237 -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \ 1516 -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \
1517 -e 's|@''REPLACE_PTSNAME''@|$(REPLACE_PTSNAME)|g' \
1518 -e 's|@''REPLACE_PTSNAME_R''@|$(REPLACE_PTSNAME_R)|g' \
1238 -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \ 1519 -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \
1520 -e 's|@''REPLACE_RANDOM_R''@|$(REPLACE_RANDOM_R)|g' \
1239 -e 's|@''REPLACE_REALLOC''@|$(REPLACE_REALLOC)|g' \ 1521 -e 's|@''REPLACE_REALLOC''@|$(REPLACE_REALLOC)|g' \
1240 -e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \ 1522 -e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \
1241 -e 's|@''REPLACE_SETENV''@|$(REPLACE_SETENV)|g' \ 1523 -e 's|@''REPLACE_SETENV''@|$(REPLACE_SETENV)|g' \
1242 -e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \ 1524 -e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \
1243 -e 's|@''REPLACE_UNSETENV''@|$(REPLACE_UNSETENV)|g' \ 1525 -e 's|@''REPLACE_UNSETENV''@|$(REPLACE_UNSETENV)|g' \
1526 -e 's|@''REPLACE_WCTOMB''@|$(REPLACE_WCTOMB)|g' \
1244 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 1527 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
1528 -e '/definition of _Noreturn/r $(_NORETURN_H)' \
1245 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 1529 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
1246 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ 1530 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
1247 < $(srcdir)/stdlib.in.h; \
1248 } > $@-t && \ 1531 } > $@-t && \
1249 mv $@-t $@ 1532 mv $@-t $@
1250MOSTLYCLEANFILES += stdlib.h stdlib.h-t 1533MOSTLYCLEANFILES += stdlib.h stdlib.h-t
@@ -1253,15 +1536,6 @@ EXTRA_DIST += stdlib.in.h
1253 1536
1254## end gnulib module stdlib 1537## end gnulib module stdlib
1255 1538
1256## begin gnulib module strdup-posix
1257
1258
1259EXTRA_DIST += strdup.c
1260
1261EXTRA_libgnu_a_SOURCES += strdup.c
1262
1263## end gnulib module strdup-posix
1264
1265## begin gnulib module streq 1539## begin gnulib module streq
1266 1540
1267 1541
@@ -1278,54 +1552,70 @@ EXTRA_libgnu_a_SOURCES += strerror.c
1278 1552
1279## end gnulib module strerror 1553## end gnulib module strerror
1280 1554
1555## begin gnulib module strerror-override
1556
1557
1558EXTRA_DIST += strerror-override.c strerror-override.h
1559
1560EXTRA_libgnu_a_SOURCES += strerror-override.c
1561
1562## end gnulib module strerror-override
1563
1281## begin gnulib module string 1564## begin gnulib module string
1282 1565
1283BUILT_SOURCES += string.h 1566BUILT_SOURCES += string.h
1284 1567
1285# We need the following in order to create <string.h> when the system 1568# We need the following in order to create <string.h> when the system
1286# doesn't have one that works with the given compiler. 1569# doesn't have one that works with the given compiler.
1287string.h: string.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 1570string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
1288 $(AM_V_GEN)rm -f $@-t $@ && \ 1571 $(AM_V_GEN)rm -f $@-t $@ && \
1289 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 1572 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
1290 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 1573 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1574 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1291 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 1575 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1576 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1292 -e 's|@''NEXT_STRING_H''@|$(NEXT_STRING_H)|g' \ 1577 -e 's|@''NEXT_STRING_H''@|$(NEXT_STRING_H)|g' \
1293 -e 's|@''GNULIB_MBSLEN''@|$(GNULIB_MBSLEN)|g' \ 1578 -e 's/@''GNULIB_FFSL''@/$(GNULIB_FFSL)/g' \
1294 -e 's|@''GNULIB_MBSNLEN''@|$(GNULIB_MBSNLEN)|g' \ 1579 -e 's/@''GNULIB_FFSLL''@/$(GNULIB_FFSLL)/g' \
1295 -e 's|@''GNULIB_MBSCHR''@|$(GNULIB_MBSCHR)|g' \ 1580 -e 's/@''GNULIB_MBSLEN''@/$(GNULIB_MBSLEN)/g' \
1296 -e 's|@''GNULIB_MBSRCHR''@|$(GNULIB_MBSRCHR)|g' \ 1581 -e 's/@''GNULIB_MBSNLEN''@/$(GNULIB_MBSNLEN)/g' \
1297 -e 's|@''GNULIB_MBSSTR''@|$(GNULIB_MBSSTR)|g' \ 1582 -e 's/@''GNULIB_MBSCHR''@/$(GNULIB_MBSCHR)/g' \
1298 -e 's|@''GNULIB_MBSCASECMP''@|$(GNULIB_MBSCASECMP)|g' \ 1583 -e 's/@''GNULIB_MBSRCHR''@/$(GNULIB_MBSRCHR)/g' \
1299 -e 's|@''GNULIB_MBSNCASECMP''@|$(GNULIB_MBSNCASECMP)|g' \ 1584 -e 's/@''GNULIB_MBSSTR''@/$(GNULIB_MBSSTR)/g' \
1300 -e 's|@''GNULIB_MBSPCASECMP''@|$(GNULIB_MBSPCASECMP)|g' \ 1585 -e 's/@''GNULIB_MBSCASECMP''@/$(GNULIB_MBSCASECMP)/g' \
1301 -e 's|@''GNULIB_MBSCASESTR''@|$(GNULIB_MBSCASESTR)|g' \ 1586 -e 's/@''GNULIB_MBSNCASECMP''@/$(GNULIB_MBSNCASECMP)/g' \
1302 -e 's|@''GNULIB_MBSCSPN''@|$(GNULIB_MBSCSPN)|g' \ 1587 -e 's/@''GNULIB_MBSPCASECMP''@/$(GNULIB_MBSPCASECMP)/g' \
1303 -e 's|@''GNULIB_MBSPBRK''@|$(GNULIB_MBSPBRK)|g' \ 1588 -e 's/@''GNULIB_MBSCASESTR''@/$(GNULIB_MBSCASESTR)/g' \
1304 -e 's|@''GNULIB_MBSSPN''@|$(GNULIB_MBSSPN)|g' \ 1589 -e 's/@''GNULIB_MBSCSPN''@/$(GNULIB_MBSCSPN)/g' \
1305 -e 's|@''GNULIB_MBSSEP''@|$(GNULIB_MBSSEP)|g' \ 1590 -e 's/@''GNULIB_MBSPBRK''@/$(GNULIB_MBSPBRK)/g' \
1306 -e 's|@''GNULIB_MBSTOK_R''@|$(GNULIB_MBSTOK_R)|g' \ 1591 -e 's/@''GNULIB_MBSSPN''@/$(GNULIB_MBSSPN)/g' \
1307 -e 's|@''GNULIB_MEMCHR''@|$(GNULIB_MEMCHR)|g' \ 1592 -e 's/@''GNULIB_MBSSEP''@/$(GNULIB_MBSSEP)/g' \
1308 -e 's|@''GNULIB_MEMMEM''@|$(GNULIB_MEMMEM)|g' \ 1593 -e 's/@''GNULIB_MBSTOK_R''@/$(GNULIB_MBSTOK_R)/g' \
1309 -e 's|@''GNULIB_MEMPCPY''@|$(GNULIB_MEMPCPY)|g' \ 1594 -e 's/@''GNULIB_MEMCHR''@/$(GNULIB_MEMCHR)/g' \
1310 -e 's|@''GNULIB_MEMRCHR''@|$(GNULIB_MEMRCHR)|g' \ 1595 -e 's/@''GNULIB_MEMMEM''@/$(GNULIB_MEMMEM)/g' \
1311 -e 's|@''GNULIB_RAWMEMCHR''@|$(GNULIB_RAWMEMCHR)|g' \ 1596 -e 's/@''GNULIB_MEMPCPY''@/$(GNULIB_MEMPCPY)/g' \
1312 -e 's|@''GNULIB_STPCPY''@|$(GNULIB_STPCPY)|g' \ 1597 -e 's/@''GNULIB_MEMRCHR''@/$(GNULIB_MEMRCHR)/g' \
1313 -e 's|@''GNULIB_STPNCPY''@|$(GNULIB_STPNCPY)|g' \ 1598 -e 's/@''GNULIB_RAWMEMCHR''@/$(GNULIB_RAWMEMCHR)/g' \
1314 -e 's|@''GNULIB_STRCHRNUL''@|$(GNULIB_STRCHRNUL)|g' \ 1599 -e 's/@''GNULIB_STPCPY''@/$(GNULIB_STPCPY)/g' \
1315 -e 's|@''GNULIB_STRDUP''@|$(GNULIB_STRDUP)|g' \ 1600 -e 's/@''GNULIB_STPNCPY''@/$(GNULIB_STPNCPY)/g' \
1316 -e 's|@''GNULIB_STRNCAT''@|$(GNULIB_STRNCAT)|g' \ 1601 -e 's/@''GNULIB_STRCHRNUL''@/$(GNULIB_STRCHRNUL)/g' \
1317 -e 's|@''GNULIB_STRNDUP''@|$(GNULIB_STRNDUP)|g' \ 1602 -e 's/@''GNULIB_STRDUP''@/$(GNULIB_STRDUP)/g' \
1318 -e 's|@''GNULIB_STRNLEN''@|$(GNULIB_STRNLEN)|g' \ 1603 -e 's/@''GNULIB_STRNCAT''@/$(GNULIB_STRNCAT)/g' \
1319 -e 's|@''GNULIB_STRPBRK''@|$(GNULIB_STRPBRK)|g' \ 1604 -e 's/@''GNULIB_STRNDUP''@/$(GNULIB_STRNDUP)/g' \
1320 -e 's|@''GNULIB_STRSEP''@|$(GNULIB_STRSEP)|g' \ 1605 -e 's/@''GNULIB_STRNLEN''@/$(GNULIB_STRNLEN)/g' \
1321 -e 's|@''GNULIB_STRSTR''@|$(GNULIB_STRSTR)|g' \ 1606 -e 's/@''GNULIB_STRPBRK''@/$(GNULIB_STRPBRK)/g' \
1322 -e 's|@''GNULIB_STRCASESTR''@|$(GNULIB_STRCASESTR)|g' \ 1607 -e 's/@''GNULIB_STRSEP''@/$(GNULIB_STRSEP)/g' \
1323 -e 's|@''GNULIB_STRTOK_R''@|$(GNULIB_STRTOK_R)|g' \ 1608 -e 's/@''GNULIB_STRSTR''@/$(GNULIB_STRSTR)/g' \
1324 -e 's|@''GNULIB_STRERROR''@|$(GNULIB_STRERROR)|g' \ 1609 -e 's/@''GNULIB_STRCASESTR''@/$(GNULIB_STRCASESTR)/g' \
1325 -e 's|@''GNULIB_STRSIGNAL''@|$(GNULIB_STRSIGNAL)|g' \ 1610 -e 's/@''GNULIB_STRTOK_R''@/$(GNULIB_STRTOK_R)/g' \
1326 -e 's|@''GNULIB_STRVERSCMP''@|$(GNULIB_STRVERSCMP)|g' \ 1611 -e 's/@''GNULIB_STRERROR''@/$(GNULIB_STRERROR)/g' \
1612 -e 's/@''GNULIB_STRERROR_R''@/$(GNULIB_STRERROR_R)/g' \
1613 -e 's/@''GNULIB_STRSIGNAL''@/$(GNULIB_STRSIGNAL)/g' \
1614 -e 's/@''GNULIB_STRVERSCMP''@/$(GNULIB_STRVERSCMP)/g' \
1327 < $(srcdir)/string.in.h | \ 1615 < $(srcdir)/string.in.h | \
1328 sed -e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \ 1616 sed -e 's|@''HAVE_FFSL''@|$(HAVE_FFSL)|g' \
1617 -e 's|@''HAVE_FFSLL''@|$(HAVE_FFSLL)|g' \
1618 -e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \
1329 -e 's|@''HAVE_MEMCHR''@|$(HAVE_MEMCHR)|g' \ 1619 -e 's|@''HAVE_MEMCHR''@|$(HAVE_MEMCHR)|g' \
1330 -e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \ 1620 -e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \
1331 -e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \ 1621 -e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \
@@ -1341,15 +1631,18 @@ string.h: string.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
1341 -e 's|@''HAVE_STRSEP''@|$(HAVE_STRSEP)|g' \ 1631 -e 's|@''HAVE_STRSEP''@|$(HAVE_STRSEP)|g' \
1342 -e 's|@''HAVE_STRCASESTR''@|$(HAVE_STRCASESTR)|g' \ 1632 -e 's|@''HAVE_STRCASESTR''@|$(HAVE_STRCASESTR)|g' \
1343 -e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \ 1633 -e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \
1634 -e 's|@''HAVE_DECL_STRERROR_R''@|$(HAVE_DECL_STRERROR_R)|g' \
1344 -e 's|@''HAVE_DECL_STRSIGNAL''@|$(HAVE_DECL_STRSIGNAL)|g' \ 1635 -e 's|@''HAVE_DECL_STRSIGNAL''@|$(HAVE_DECL_STRSIGNAL)|g' \
1345 -e 's|@''HAVE_STRVERSCMP''@|$(HAVE_STRVERSCMP)|g' \ 1636 -e 's|@''HAVE_STRVERSCMP''@|$(HAVE_STRVERSCMP)|g' \
1346 -e 's|@''REPLACE_STPNCPY''@|$(REPLACE_STPNCPY)|g' \ 1637 -e 's|@''REPLACE_STPNCPY''@|$(REPLACE_STPNCPY)|g' \
1347 -e 's|@''REPLACE_MEMCHR''@|$(REPLACE_MEMCHR)|g' \ 1638 -e 's|@''REPLACE_MEMCHR''@|$(REPLACE_MEMCHR)|g' \
1348 -e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \ 1639 -e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \
1349 -e 's|@''REPLACE_STRCASESTR''@|$(REPLACE_STRCASESTR)|g' \ 1640 -e 's|@''REPLACE_STRCASESTR''@|$(REPLACE_STRCASESTR)|g' \
1641 -e 's|@''REPLACE_STRCHRNUL''@|$(REPLACE_STRCHRNUL)|g' \
1350 -e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \ 1642 -e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \
1351 -e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \ 1643 -e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \
1352 -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \ 1644 -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \
1645 -e 's|@''REPLACE_STRERROR_R''@|$(REPLACE_STRERROR_R)|g' \
1353 -e 's|@''REPLACE_STRNCAT''@|$(REPLACE_STRNCAT)|g' \ 1646 -e 's|@''REPLACE_STRNCAT''@|$(REPLACE_STRNCAT)|g' \
1354 -e 's|@''REPLACE_STRNDUP''@|$(REPLACE_STRNDUP)|g' \ 1647 -e 's|@''REPLACE_STRNDUP''@|$(REPLACE_STRNDUP)|g' \
1355 -e 's|@''REPLACE_STRNLEN''@|$(REPLACE_STRNLEN)|g' \ 1648 -e 's|@''REPLACE_STRNLEN''@|$(REPLACE_STRNLEN)|g' \
@@ -1407,36 +1700,40 @@ EXTRA_libgnu_a_SOURCES += strstr.c
1407## begin gnulib module sys_socket 1700## begin gnulib module sys_socket
1408 1701
1409BUILT_SOURCES += sys/socket.h 1702BUILT_SOURCES += sys/socket.h
1703libgnu_a_SOURCES += sys_socket.c
1410 1704
1411# We need the following in order to create <sys/socket.h> when the system 1705# We need the following in order to create <sys/socket.h> when the system
1412# doesn't have one that works with the given compiler. 1706# doesn't have one that works with the given compiler.
1413sys/socket.h: sys_socket.in.h $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H) 1707sys/socket.h: sys_socket.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H) $(ARG_NONNULL_H)
1414 $(AM_V_at)$(MKDIR_P) sys 1708 $(AM_V_at)$(MKDIR_P) sys
1415 $(AM_V_GEN)rm -f $@-t $@ && \ 1709 $(AM_V_GEN)rm -f $@-t $@ && \
1416 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 1710 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
1417 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 1711 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1712 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1418 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 1713 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1714 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1419 -e 's|@''NEXT_SYS_SOCKET_H''@|$(NEXT_SYS_SOCKET_H)|g' \ 1715 -e 's|@''NEXT_SYS_SOCKET_H''@|$(NEXT_SYS_SOCKET_H)|g' \
1420 -e 's|@''HAVE_SYS_SOCKET_H''@|$(HAVE_SYS_SOCKET_H)|g' \ 1716 -e 's|@''HAVE_SYS_SOCKET_H''@|$(HAVE_SYS_SOCKET_H)|g' \
1421 -e 's|@''GNULIB_CLOSE''@|$(GNULIB_CLOSE)|g' \ 1717 -e 's/@''GNULIB_CLOSE''@/$(GNULIB_CLOSE)/g' \
1422 -e 's|@''GNULIB_SOCKET''@|$(GNULIB_SOCKET)|g' \ 1718 -e 's/@''GNULIB_SOCKET''@/$(GNULIB_SOCKET)/g' \
1423 -e 's|@''GNULIB_CONNECT''@|$(GNULIB_CONNECT)|g' \ 1719 -e 's/@''GNULIB_CONNECT''@/$(GNULIB_CONNECT)/g' \
1424 -e 's|@''GNULIB_ACCEPT''@|$(GNULIB_ACCEPT)|g' \ 1720 -e 's/@''GNULIB_ACCEPT''@/$(GNULIB_ACCEPT)/g' \
1425 -e 's|@''GNULIB_BIND''@|$(GNULIB_BIND)|g' \ 1721 -e 's/@''GNULIB_BIND''@/$(GNULIB_BIND)/g' \
1426 -e 's|@''GNULIB_GETPEERNAME''@|$(GNULIB_GETPEERNAME)|g' \ 1722 -e 's/@''GNULIB_GETPEERNAME''@/$(GNULIB_GETPEERNAME)/g' \
1427 -e 's|@''GNULIB_GETSOCKNAME''@|$(GNULIB_GETSOCKNAME)|g' \ 1723 -e 's/@''GNULIB_GETSOCKNAME''@/$(GNULIB_GETSOCKNAME)/g' \
1428 -e 's|@''GNULIB_GETSOCKOPT''@|$(GNULIB_GETSOCKOPT)|g' \ 1724 -e 's/@''GNULIB_GETSOCKOPT''@/$(GNULIB_GETSOCKOPT)/g' \
1429 -e 's|@''GNULIB_LISTEN''@|$(GNULIB_LISTEN)|g' \ 1725 -e 's/@''GNULIB_LISTEN''@/$(GNULIB_LISTEN)/g' \
1430 -e 's|@''GNULIB_RECV''@|$(GNULIB_RECV)|g' \ 1726 -e 's/@''GNULIB_RECV''@/$(GNULIB_RECV)/g' \
1431 -e 's|@''GNULIB_SEND''@|$(GNULIB_SEND)|g' \ 1727 -e 's/@''GNULIB_SEND''@/$(GNULIB_SEND)/g' \
1432 -e 's|@''GNULIB_RECVFROM''@|$(GNULIB_RECVFROM)|g' \ 1728 -e 's/@''GNULIB_RECVFROM''@/$(GNULIB_RECVFROM)/g' \
1433 -e 's|@''GNULIB_SENDTO''@|$(GNULIB_SENDTO)|g' \ 1729 -e 's/@''GNULIB_SENDTO''@/$(GNULIB_SENDTO)/g' \
1434 -e 's|@''GNULIB_SETSOCKOPT''@|$(GNULIB_SETSOCKOPT)|g' \ 1730 -e 's/@''GNULIB_SETSOCKOPT''@/$(GNULIB_SETSOCKOPT)/g' \
1435 -e 's|@''GNULIB_SHUTDOWN''@|$(GNULIB_SHUTDOWN)|g' \ 1731 -e 's/@''GNULIB_SHUTDOWN''@/$(GNULIB_SHUTDOWN)/g' \
1436 -e 's|@''GNULIB_ACCEPT4''@|$(GNULIB_ACCEPT4)|g' \ 1732 -e 's/@''GNULIB_ACCEPT4''@/$(GNULIB_ACCEPT4)/g' \
1437 -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \ 1733 -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \
1438 -e 's|@''HAVE_WS2TCPIP_H''@|$(HAVE_WS2TCPIP_H)|g' \ 1734 -e 's|@''HAVE_WS2TCPIP_H''@|$(HAVE_WS2TCPIP_H)|g' \
1439 -e 's|@''HAVE_STRUCT_SOCKADDR_STORAGE''@|$(HAVE_STRUCT_SOCKADDR_STORAGE)|g' \ 1735 -e 's|@''HAVE_STRUCT_SOCKADDR_STORAGE''@|$(HAVE_STRUCT_SOCKADDR_STORAGE)|g' \
1736 -e 's|@''HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY''@|$(HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY)|g' \
1440 -e 's|@''HAVE_SA_FAMILY_T''@|$(HAVE_SA_FAMILY_T)|g' \ 1737 -e 's|@''HAVE_SA_FAMILY_T''@|$(HAVE_SA_FAMILY_T)|g' \
1441 -e 's|@''HAVE_ACCEPT4''@|$(HAVE_ACCEPT4)|g' \ 1738 -e 's|@''HAVE_ACCEPT4''@|$(HAVE_ACCEPT4)|g' \
1442 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 1739 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
@@ -1452,63 +1749,64 @@ EXTRA_DIST += sys_socket.in.h
1452 1749
1453## end gnulib module sys_socket 1750## end gnulib module sys_socket
1454 1751
1455## begin gnulib module sys_stat 1752## begin gnulib module sys_types
1456 1753
1457BUILT_SOURCES += sys/stat.h 1754BUILT_SOURCES += sys/types.h
1458 1755
1459# We need the following in order to create <sys/stat.h> when the system 1756# We need the following in order to create <sys/types.h> when the system
1460# has one that is incomplete. 1757# doesn't have one that works with the given compiler.
1461sys/stat.h: sys_stat.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 1758sys/types.h: sys_types.in.h $(top_builddir)/config.status
1462 $(AM_V_at)$(MKDIR_P) sys 1759 $(AM_V_at)$(MKDIR_P) sys
1463 $(AM_V_GEN)rm -f $@-t $@ && \ 1760 $(AM_V_GEN)rm -f $@-t $@ && \
1464 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 1761 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
1465 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 1762 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1763 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1466 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 1764 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1467 -e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \ 1765 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1468 -e 's|@''GNULIB_FCHMODAT''@|$(GNULIB_FCHMODAT)|g' \ 1766 -e 's|@''NEXT_SYS_TYPES_H''@|$(NEXT_SYS_TYPES_H)|g' \
1469 -e 's|@''GNULIB_FSTATAT''@|$(GNULIB_FSTATAT)|g' \ 1767 -e 's|@''WINDOWS_64_BIT_OFF_T''@|$(WINDOWS_64_BIT_OFF_T)|g' \
1470 -e 's|@''GNULIB_FUTIMENS''@|$(GNULIB_FUTIMENS)|g' \ 1768 < $(srcdir)/sys_types.in.h; \
1471 -e 's|@''GNULIB_LCHMOD''@|$(GNULIB_LCHMOD)|g' \
1472 -e 's|@''GNULIB_LSTAT''@|$(GNULIB_LSTAT)|g' \
1473 -e 's|@''GNULIB_MKDIRAT''@|$(GNULIB_MKDIRAT)|g' \
1474 -e 's|@''GNULIB_MKFIFO''@|$(GNULIB_MKFIFO)|g' \
1475 -e 's|@''GNULIB_MKFIFOAT''@|$(GNULIB_MKFIFOAT)|g' \
1476 -e 's|@''GNULIB_MKNOD''@|$(GNULIB_MKNOD)|g' \
1477 -e 's|@''GNULIB_MKNODAT''@|$(GNULIB_MKNODAT)|g' \
1478 -e 's|@''GNULIB_STAT''@|$(GNULIB_STAT)|g' \
1479 -e 's|@''GNULIB_UTIMENSAT''@|$(GNULIB_UTIMENSAT)|g' \
1480 -e 's|@''HAVE_FCHMODAT''@|$(HAVE_FCHMODAT)|g' \
1481 -e 's|@''HAVE_FSTATAT''@|$(HAVE_FSTATAT)|g' \
1482 -e 's|@''HAVE_FUTIMENS''@|$(HAVE_FUTIMENS)|g' \
1483 -e 's|@''HAVE_LCHMOD''@|$(HAVE_LCHMOD)|g' \
1484 -e 's|@''HAVE_LSTAT''@|$(HAVE_LSTAT)|g' \
1485 -e 's|@''HAVE_MKDIRAT''@|$(HAVE_MKDIRAT)|g' \
1486 -e 's|@''HAVE_MKFIFO''@|$(HAVE_MKFIFO)|g' \
1487 -e 's|@''HAVE_MKFIFOAT''@|$(HAVE_MKFIFOAT)|g' \
1488 -e 's|@''HAVE_MKNOD''@|$(HAVE_MKNOD)|g' \
1489 -e 's|@''HAVE_MKNODAT''@|$(HAVE_MKNODAT)|g' \
1490 -e 's|@''HAVE_UTIMENSAT''@|$(HAVE_UTIMENSAT)|g' \
1491 -e 's|@''REPLACE_FSTAT''@|$(REPLACE_FSTAT)|g' \
1492 -e 's|@''REPLACE_FSTATAT''@|$(REPLACE_FSTATAT)|g' \
1493 -e 's|@''REPLACE_FUTIMENS''@|$(REPLACE_FUTIMENS)|g' \
1494 -e 's|@''REPLACE_LSTAT''@|$(REPLACE_LSTAT)|g' \
1495 -e 's|@''REPLACE_MKDIR''@|$(REPLACE_MKDIR)|g' \
1496 -e 's|@''REPLACE_MKFIFO''@|$(REPLACE_MKFIFO)|g' \
1497 -e 's|@''REPLACE_MKNOD''@|$(REPLACE_MKNOD)|g' \
1498 -e 's|@''REPLACE_STAT''@|$(REPLACE_STAT)|g' \
1499 -e 's|@''REPLACE_UTIMENSAT''@|$(REPLACE_UTIMENSAT)|g' \
1500 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
1501 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
1502 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
1503 < $(srcdir)/sys_stat.in.h; \
1504 } > $@-t && \ 1769 } > $@-t && \
1505 mv $@-t $@ 1770 mv $@-t $@
1506MOSTLYCLEANFILES += sys/stat.h sys/stat.h-t 1771MOSTLYCLEANFILES += sys/types.h sys/types.h-t
1772
1773EXTRA_DIST += sys_types.in.h
1774
1775## end gnulib module sys_types
1776
1777## begin gnulib module sys_uio
1778
1779BUILT_SOURCES += sys/uio.h
1780
1781# We need the following in order to create <sys/uio.h> when the system
1782# doesn't have one that works with the given compiler.
1783sys/uio.h: sys_uio.in.h $(top_builddir)/config.status
1784 $(AM_V_at)$(MKDIR_P) sys
1785 $(AM_V_GEN)rm -f $@-t $@ && \
1786 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
1787 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1788 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1789 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1790 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1791 -e 's|@''NEXT_SYS_UIO_H''@|$(NEXT_SYS_UIO_H)|g' \
1792 -e 's|@''HAVE_SYS_UIO_H''@|$(HAVE_SYS_UIO_H)|g' \
1793 < $(srcdir)/sys_uio.in.h; \
1794 } > $@-t && \
1795 mv -f $@-t $@
1796MOSTLYCLEANFILES += sys/uio.h sys/uio.h-t
1507MOSTLYCLEANDIRS += sys 1797MOSTLYCLEANDIRS += sys
1508 1798
1509EXTRA_DIST += sys_stat.in.h 1799EXTRA_DIST += sys_uio.in.h
1510 1800
1511## end gnulib module sys_stat 1801## end gnulib module sys_uio
1802
1803## begin gnulib module threadlib
1804
1805libgnu_a_SOURCES += glthread/threadlib.c
1806
1807EXTRA_DIST += $(top_srcdir)/build-aux/config.rpath
1808
1809## end gnulib module threadlib
1512 1810
1513## begin gnulib module time 1811## begin gnulib module time
1514 1812
@@ -1516,18 +1814,20 @@ BUILT_SOURCES += time.h
1516 1814
1517# We need the following in order to create <time.h> when the system 1815# We need the following in order to create <time.h> when the system
1518# doesn't have one that works with the given compiler. 1816# doesn't have one that works with the given compiler.
1519time.h: time.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 1817time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
1520 $(AM_V_GEN)rm -f $@-t $@ && \ 1818 $(AM_V_GEN)rm -f $@-t $@ && \
1521 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ 1819 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
1522 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 1820 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1821 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1523 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 1822 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1823 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1524 -e 's|@''NEXT_TIME_H''@|$(NEXT_TIME_H)|g' \ 1824 -e 's|@''NEXT_TIME_H''@|$(NEXT_TIME_H)|g' \
1525 -e 's|@''GNULIB_MKTIME''@|$(GNULIB_MKTIME)|g' \ 1825 -e 's/@''GNULIB_MKTIME''@/$(GNULIB_MKTIME)/g' \
1526 -e 's|@''GNULIB_NANOSLEEP''@|$(GNULIB_NANOSLEEP)|g' \ 1826 -e 's/@''GNULIB_NANOSLEEP''@/$(GNULIB_NANOSLEEP)/g' \
1527 -e 's|@''GNULIB_STRPTIME''@|$(GNULIB_STRPTIME)|g' \ 1827 -e 's/@''GNULIB_STRPTIME''@/$(GNULIB_STRPTIME)/g' \
1528 -e 's|@''GNULIB_TIMEGM''@|$(GNULIB_TIMEGM)|g' \ 1828 -e 's/@''GNULIB_TIMEGM''@/$(GNULIB_TIMEGM)/g' \
1529 -e 's|@''GNULIB_TIME_R''@|$(GNULIB_TIME_R)|g' \ 1829 -e 's/@''GNULIB_TIME_R''@/$(GNULIB_TIME_R)/g' \
1530 -e 's|@''HAVE_LOCALTIME_R''@|$(HAVE_LOCALTIME_R)|g' \ 1830 -e 's|@''HAVE_DECL_LOCALTIME_R''@|$(HAVE_DECL_LOCALTIME_R)|g' \
1531 -e 's|@''HAVE_NANOSLEEP''@|$(HAVE_NANOSLEEP)|g' \ 1831 -e 's|@''HAVE_NANOSLEEP''@|$(HAVE_NANOSLEEP)|g' \
1532 -e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \ 1832 -e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \
1533 -e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \ 1833 -e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \
@@ -1571,56 +1871,69 @@ EXTRA_libgnu_a_SOURCES += timegm.c
1571## begin gnulib module unistd 1871## begin gnulib module unistd
1572 1872
1573BUILT_SOURCES += unistd.h 1873BUILT_SOURCES += unistd.h
1874libgnu_a_SOURCES += unistd.c
1574 1875
1575# We need the following in order to create an empty placeholder for 1876# We need the following in order to create an empty placeholder for
1576# <unistd.h> when the system doesn't have one. 1877# <unistd.h> when the system doesn't have one.
1577unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 1878unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
1578 $(AM_V_GEN)rm -f $@-t $@ && \ 1879 $(AM_V_GEN)rm -f $@-t $@ && \
1579 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 1880 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
1580 sed -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \ 1881 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
1882 -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \
1581 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 1883 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1582 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 1884 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
1885 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1583 -e 's|@''NEXT_UNISTD_H''@|$(NEXT_UNISTD_H)|g' \ 1886 -e 's|@''NEXT_UNISTD_H''@|$(NEXT_UNISTD_H)|g' \
1584 -e 's|@''GNULIB_CHOWN''@|$(GNULIB_CHOWN)|g' \ 1887 -e 's|@''WINDOWS_64_BIT_OFF_T''@|$(WINDOWS_64_BIT_OFF_T)|g' \
1585 -e 's|@''GNULIB_CLOSE''@|$(GNULIB_CLOSE)|g' \ 1888 -e 's/@''GNULIB_CHDIR''@/$(GNULIB_CHDIR)/g' \
1586 -e 's|@''GNULIB_DUP2''@|$(GNULIB_DUP2)|g' \ 1889 -e 's/@''GNULIB_CHOWN''@/$(GNULIB_CHOWN)/g' \
1587 -e 's|@''GNULIB_DUP3''@|$(GNULIB_DUP3)|g' \ 1890 -e 's/@''GNULIB_CLOSE''@/$(GNULIB_CLOSE)/g' \
1588 -e 's|@''GNULIB_ENVIRON''@|$(GNULIB_ENVIRON)|g' \ 1891 -e 's/@''GNULIB_DUP''@/$(GNULIB_DUP)/g' \
1589 -e 's|@''GNULIB_EUIDACCESS''@|$(GNULIB_EUIDACCESS)|g' \ 1892 -e 's/@''GNULIB_DUP2''@/$(GNULIB_DUP2)/g' \
1590 -e 's|@''GNULIB_FACCESSAT''@|$(GNULIB_FACCESSAT)|g' \ 1893 -e 's/@''GNULIB_DUP3''@/$(GNULIB_DUP3)/g' \
1591 -e 's|@''GNULIB_FCHDIR''@|$(GNULIB_FCHDIR)|g' \ 1894 -e 's/@''GNULIB_ENVIRON''@/$(GNULIB_ENVIRON)/g' \
1592 -e 's|@''GNULIB_FCHOWNAT''@|$(GNULIB_FCHOWNAT)|g' \ 1895 -e 's/@''GNULIB_EUIDACCESS''@/$(GNULIB_EUIDACCESS)/g' \
1593 -e 's|@''GNULIB_FSYNC''@|$(GNULIB_FSYNC)|g' \ 1896 -e 's/@''GNULIB_FACCESSAT''@/$(GNULIB_FACCESSAT)/g' \
1594 -e 's|@''GNULIB_FTRUNCATE''@|$(GNULIB_FTRUNCATE)|g' \ 1897 -e 's/@''GNULIB_FCHDIR''@/$(GNULIB_FCHDIR)/g' \
1595 -e 's|@''GNULIB_GETCWD''@|$(GNULIB_GETCWD)|g' \ 1898 -e 's/@''GNULIB_FCHOWNAT''@/$(GNULIB_FCHOWNAT)/g' \
1596 -e 's|@''GNULIB_GETDOMAINNAME''@|$(GNULIB_GETDOMAINNAME)|g' \ 1899 -e 's/@''GNULIB_FDATASYNC''@/$(GNULIB_FDATASYNC)/g' \
1597 -e 's|@''GNULIB_GETDTABLESIZE''@|$(GNULIB_GETDTABLESIZE)|g' \ 1900 -e 's/@''GNULIB_FSYNC''@/$(GNULIB_FSYNC)/g' \
1598 -e 's|@''GNULIB_GETGROUPS''@|$(GNULIB_GETGROUPS)|g' \ 1901 -e 's/@''GNULIB_FTRUNCATE''@/$(GNULIB_FTRUNCATE)/g' \
1599 -e 's|@''GNULIB_GETHOSTNAME''@|$(GNULIB_GETHOSTNAME)|g' \ 1902 -e 's/@''GNULIB_GETCWD''@/$(GNULIB_GETCWD)/g' \
1600 -e 's|@''GNULIB_GETLOGIN''@|$(GNULIB_GETLOGIN)|g' \ 1903 -e 's/@''GNULIB_GETDOMAINNAME''@/$(GNULIB_GETDOMAINNAME)/g' \
1601 -e 's|@''GNULIB_GETLOGIN_R''@|$(GNULIB_GETLOGIN_R)|g' \ 1904 -e 's/@''GNULIB_GETDTABLESIZE''@/$(GNULIB_GETDTABLESIZE)/g' \
1602 -e 's|@''GNULIB_GETPAGESIZE''@|$(GNULIB_GETPAGESIZE)|g' \ 1905 -e 's/@''GNULIB_GETGROUPS''@/$(GNULIB_GETGROUPS)/g' \
1603 -e 's|@''GNULIB_GETUSERSHELL''@|$(GNULIB_GETUSERSHELL)|g' \ 1906 -e 's/@''GNULIB_GETHOSTNAME''@/$(GNULIB_GETHOSTNAME)/g' \
1604 -e 's|@''GNULIB_LCHOWN''@|$(GNULIB_LCHOWN)|g' \ 1907 -e 's/@''GNULIB_GETLOGIN''@/$(GNULIB_GETLOGIN)/g' \
1605 -e 's|@''GNULIB_LINK''@|$(GNULIB_LINK)|g' \ 1908 -e 's/@''GNULIB_GETLOGIN_R''@/$(GNULIB_GETLOGIN_R)/g' \
1606 -e 's|@''GNULIB_LINKAT''@|$(GNULIB_LINKAT)|g' \ 1909 -e 's/@''GNULIB_GETPAGESIZE''@/$(GNULIB_GETPAGESIZE)/g' \
1607 -e 's|@''GNULIB_LSEEK''@|$(GNULIB_LSEEK)|g' \ 1910 -e 's/@''GNULIB_GETUSERSHELL''@/$(GNULIB_GETUSERSHELL)/g' \
1608 -e 's|@''GNULIB_PIPE2''@|$(GNULIB_PIPE2)|g' \ 1911 -e 's/@''GNULIB_GROUP_MEMBER''@/$(GNULIB_GROUP_MEMBER)/g' \
1609 -e 's|@''GNULIB_PREAD''@|$(GNULIB_PREAD)|g' \ 1912 -e 's/@''GNULIB_ISATTY''@/$(GNULIB_ISATTY)/g' \
1610 -e 's|@''GNULIB_PWRITE''@|$(GNULIB_PWRITE)|g' \ 1913 -e 's/@''GNULIB_LCHOWN''@/$(GNULIB_LCHOWN)/g' \
1611 -e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \ 1914 -e 's/@''GNULIB_LINK''@/$(GNULIB_LINK)/g' \
1612 -e 's|@''GNULIB_READLINKAT''@|$(GNULIB_READLINKAT)|g' \ 1915 -e 's/@''GNULIB_LINKAT''@/$(GNULIB_LINKAT)/g' \
1613 -e 's|@''GNULIB_RMDIR''@|$(GNULIB_RMDIR)|g' \ 1916 -e 's/@''GNULIB_LSEEK''@/$(GNULIB_LSEEK)/g' \
1614 -e 's|@''GNULIB_SLEEP''@|$(GNULIB_SLEEP)|g' \ 1917 -e 's/@''GNULIB_PIPE''@/$(GNULIB_PIPE)/g' \
1615 -e 's|@''GNULIB_SYMLINK''@|$(GNULIB_SYMLINK)|g' \ 1918 -e 's/@''GNULIB_PIPE2''@/$(GNULIB_PIPE2)/g' \
1616 -e 's|@''GNULIB_SYMLINKAT''@|$(GNULIB_SYMLINKAT)|g' \ 1919 -e 's/@''GNULIB_PREAD''@/$(GNULIB_PREAD)/g' \
1617 -e 's|@''GNULIB_TTYNAME_R''@|$(GNULIB_TTYNAME_R)|g' \ 1920 -e 's/@''GNULIB_PWRITE''@/$(GNULIB_PWRITE)/g' \
1618 -e 's|@''GNULIB_UNISTD_H_GETOPT''@|$(GNULIB_UNISTD_H_GETOPT)|g' \ 1921 -e 's/@''GNULIB_READ''@/$(GNULIB_READ)/g' \
1619 -e 's|@''GNULIB_UNISTD_H_SIGPIPE''@|$(GNULIB_UNISTD_H_SIGPIPE)|g' \ 1922 -e 's/@''GNULIB_READLINK''@/$(GNULIB_READLINK)/g' \
1620 -e 's|@''GNULIB_UNLINK''@|$(GNULIB_UNLINK)|g' \ 1923 -e 's/@''GNULIB_READLINKAT''@/$(GNULIB_READLINKAT)/g' \
1621 -e 's|@''GNULIB_UNLINKAT''@|$(GNULIB_UNLINKAT)|g' \ 1924 -e 's/@''GNULIB_RMDIR''@/$(GNULIB_RMDIR)/g' \
1622 -e 's|@''GNULIB_USLEEP''@|$(GNULIB_USLEEP)|g' \ 1925 -e 's/@''GNULIB_SETHOSTNAME''@/$(GNULIB_SETHOSTNAME)/g' \
1623 -e 's|@''GNULIB_WRITE''@|$(GNULIB_WRITE)|g' \ 1926 -e 's/@''GNULIB_SLEEP''@/$(GNULIB_SLEEP)/g' \
1927 -e 's/@''GNULIB_SYMLINK''@/$(GNULIB_SYMLINK)/g' \
1928 -e 's/@''GNULIB_SYMLINKAT''@/$(GNULIB_SYMLINKAT)/g' \
1929 -e 's/@''GNULIB_TTYNAME_R''@/$(GNULIB_TTYNAME_R)/g' \
1930 -e 's/@''GNULIB_UNISTD_H_GETOPT''@/0$(GNULIB_GL_UNISTD_H_GETOPT)/g' \
1931 -e 's/@''GNULIB_UNISTD_H_NONBLOCKING''@/$(GNULIB_UNISTD_H_NONBLOCKING)/g' \
1932 -e 's/@''GNULIB_UNISTD_H_SIGPIPE''@/$(GNULIB_UNISTD_H_SIGPIPE)/g' \
1933 -e 's/@''GNULIB_UNLINK''@/$(GNULIB_UNLINK)/g' \
1934 -e 's/@''GNULIB_UNLINKAT''@/$(GNULIB_UNLINKAT)/g' \
1935 -e 's/@''GNULIB_USLEEP''@/$(GNULIB_USLEEP)/g' \
1936 -e 's/@''GNULIB_WRITE''@/$(GNULIB_WRITE)/g' \
1624 < $(srcdir)/unistd.in.h | \ 1937 < $(srcdir)/unistd.in.h | \
1625 sed -e 's|@''HAVE_CHOWN''@|$(HAVE_CHOWN)|g' \ 1938 sed -e 's|@''HAVE_CHOWN''@|$(HAVE_CHOWN)|g' \
1626 -e 's|@''HAVE_DUP2''@|$(HAVE_DUP2)|g' \ 1939 -e 's|@''HAVE_DUP2''@|$(HAVE_DUP2)|g' \
@@ -1629,48 +1942,61 @@ unistd.h: unistd.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
1629 -e 's|@''HAVE_FACCESSAT''@|$(HAVE_FACCESSAT)|g' \ 1942 -e 's|@''HAVE_FACCESSAT''@|$(HAVE_FACCESSAT)|g' \
1630 -e 's|@''HAVE_FCHDIR''@|$(HAVE_FCHDIR)|g' \ 1943 -e 's|@''HAVE_FCHDIR''@|$(HAVE_FCHDIR)|g' \
1631 -e 's|@''HAVE_FCHOWNAT''@|$(HAVE_FCHOWNAT)|g' \ 1944 -e 's|@''HAVE_FCHOWNAT''@|$(HAVE_FCHOWNAT)|g' \
1945 -e 's|@''HAVE_FDATASYNC''@|$(HAVE_FDATASYNC)|g' \
1632 -e 's|@''HAVE_FSYNC''@|$(HAVE_FSYNC)|g' \ 1946 -e 's|@''HAVE_FSYNC''@|$(HAVE_FSYNC)|g' \
1633 -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \ 1947 -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \
1634 -e 's|@''HAVE_GETDOMAINNAME''@|$(HAVE_GETDOMAINNAME)|g' \
1635 -e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \ 1948 -e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \
1636 -e 's|@''HAVE_GETGROUPS''@|$(HAVE_GETGROUPS)|g' \ 1949 -e 's|@''HAVE_GETGROUPS''@|$(HAVE_GETGROUPS)|g' \
1637 -e 's|@''HAVE_GETHOSTNAME''@|$(HAVE_GETHOSTNAME)|g' \ 1950 -e 's|@''HAVE_GETHOSTNAME''@|$(HAVE_GETHOSTNAME)|g' \
1638 -e 's|@''HAVE_GETLOGIN''@|$(HAVE_GETLOGIN)|g' \ 1951 -e 's|@''HAVE_GETLOGIN''@|$(HAVE_GETLOGIN)|g' \
1639 -e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \ 1952 -e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \
1953 -e 's|@''HAVE_GROUP_MEMBER''@|$(HAVE_GROUP_MEMBER)|g' \
1640 -e 's|@''HAVE_LCHOWN''@|$(HAVE_LCHOWN)|g' \ 1954 -e 's|@''HAVE_LCHOWN''@|$(HAVE_LCHOWN)|g' \
1641 -e 's|@''HAVE_LINK''@|$(HAVE_LINK)|g' \ 1955 -e 's|@''HAVE_LINK''@|$(HAVE_LINK)|g' \
1642 -e 's|@''HAVE_LINKAT''@|$(HAVE_LINKAT)|g' \ 1956 -e 's|@''HAVE_LINKAT''@|$(HAVE_LINKAT)|g' \
1957 -e 's|@''HAVE_PIPE''@|$(HAVE_PIPE)|g' \
1643 -e 's|@''HAVE_PIPE2''@|$(HAVE_PIPE2)|g' \ 1958 -e 's|@''HAVE_PIPE2''@|$(HAVE_PIPE2)|g' \
1644 -e 's|@''HAVE_PREAD''@|$(HAVE_PREAD)|g' \ 1959 -e 's|@''HAVE_PREAD''@|$(HAVE_PREAD)|g' \
1645 -e 's|@''HAVE_PWRITE''@|$(HAVE_PWRITE)|g' \ 1960 -e 's|@''HAVE_PWRITE''@|$(HAVE_PWRITE)|g' \
1646 -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \ 1961 -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \
1647 -e 's|@''HAVE_READLINKAT''@|$(HAVE_READLINKAT)|g' \ 1962 -e 's|@''HAVE_READLINKAT''@|$(HAVE_READLINKAT)|g' \
1963 -e 's|@''HAVE_SETHOSTNAME''@|$(HAVE_SETHOSTNAME)|g' \
1648 -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \ 1964 -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \
1649 -e 's|@''HAVE_SYMLINK''@|$(HAVE_SYMLINK)|g' \ 1965 -e 's|@''HAVE_SYMLINK''@|$(HAVE_SYMLINK)|g' \
1650 -e 's|@''HAVE_SYMLINKAT''@|$(HAVE_SYMLINKAT)|g' \ 1966 -e 's|@''HAVE_SYMLINKAT''@|$(HAVE_SYMLINKAT)|g' \
1651 -e 's|@''HAVE_TTYNAME_R''@|$(HAVE_TTYNAME_R)|g' \
1652 -e 's|@''HAVE_UNLINKAT''@|$(HAVE_UNLINKAT)|g' \ 1967 -e 's|@''HAVE_UNLINKAT''@|$(HAVE_UNLINKAT)|g' \
1653 -e 's|@''HAVE_USLEEP''@|$(HAVE_USLEEP)|g' \ 1968 -e 's|@''HAVE_USLEEP''@|$(HAVE_USLEEP)|g' \
1654 -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \ 1969 -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \
1970 -e 's|@''HAVE_DECL_FCHDIR''@|$(HAVE_DECL_FCHDIR)|g' \
1971 -e 's|@''HAVE_DECL_FDATASYNC''@|$(HAVE_DECL_FDATASYNC)|g' \
1972 -e 's|@''HAVE_DECL_GETDOMAINNAME''@|$(HAVE_DECL_GETDOMAINNAME)|g' \
1655 -e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \ 1973 -e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \
1656 -e 's|@''HAVE_DECL_GETPAGESIZE''@|$(HAVE_DECL_GETPAGESIZE)|g' \ 1974 -e 's|@''HAVE_DECL_GETPAGESIZE''@|$(HAVE_DECL_GETPAGESIZE)|g' \
1657 -e 's|@''HAVE_DECL_GETUSERSHELL''@|$(HAVE_DECL_GETUSERSHELL)|g' \ 1975 -e 's|@''HAVE_DECL_GETUSERSHELL''@|$(HAVE_DECL_GETUSERSHELL)|g' \
1976 -e 's|@''HAVE_DECL_SETHOSTNAME''@|$(HAVE_DECL_SETHOSTNAME)|g' \
1977 -e 's|@''HAVE_DECL_TTYNAME_R''@|$(HAVE_DECL_TTYNAME_R)|g' \
1658 -e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \ 1978 -e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \
1659 -e 's|@''HAVE_SYS_PARAM_H''@|$(HAVE_SYS_PARAM_H)|g' \ 1979 -e 's|@''HAVE_SYS_PARAM_H''@|$(HAVE_SYS_PARAM_H)|g' \
1660 -e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \ 1980 | \
1981 sed -e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \
1661 -e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \ 1982 -e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \
1662 -e 's|@''REPLACE_DUP''@|$(REPLACE_DUP)|g' \ 1983 -e 's|@''REPLACE_DUP''@|$(REPLACE_DUP)|g' \
1663 -e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \ 1984 -e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \
1664 -e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \ 1985 -e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \
1986 -e 's|@''REPLACE_FTRUNCATE''@|$(REPLACE_FTRUNCATE)|g' \
1665 -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \ 1987 -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \
1988 -e 's|@''REPLACE_GETDOMAINNAME''@|$(REPLACE_GETDOMAINNAME)|g' \
1989 -e 's|@''REPLACE_GETLOGIN_R''@|$(REPLACE_GETLOGIN_R)|g' \
1666 -e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \ 1990 -e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \
1667 -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \ 1991 -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \
1992 -e 's|@''REPLACE_ISATTY''@|$(REPLACE_ISATTY)|g' \
1668 -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \ 1993 -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \
1669 -e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \ 1994 -e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \
1670 -e 's|@''REPLACE_LINKAT''@|$(REPLACE_LINKAT)|g' \ 1995 -e 's|@''REPLACE_LINKAT''@|$(REPLACE_LINKAT)|g' \
1671 -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \ 1996 -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \
1672 -e 's|@''REPLACE_PREAD''@|$(REPLACE_PREAD)|g' \ 1997 -e 's|@''REPLACE_PREAD''@|$(REPLACE_PREAD)|g' \
1673 -e 's|@''REPLACE_PWRITE''@|$(REPLACE_PWRITE)|g' \ 1998 -e 's|@''REPLACE_PWRITE''@|$(REPLACE_PWRITE)|g' \
1999 -e 's|@''REPLACE_READ''@|$(REPLACE_READ)|g' \
1674 -e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \ 2000 -e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \
1675 -e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \ 2001 -e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \
1676 -e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \ 2002 -e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \
@@ -1693,15 +2019,6 @@ EXTRA_DIST += unistd.in.h
1693 2019
1694## end gnulib module unistd 2020## end gnulib module unistd
1695 2021
1696## begin gnulib module unistd-safer
1697
1698
1699EXTRA_DIST += dup-safer.c fd-safer.c pipe-safer.c unistd--.h unistd-safer.h
1700
1701EXTRA_libgnu_a_SOURCES += dup-safer.c fd-safer.c pipe-safer.c
1702
1703## end gnulib module unistd-safer
1704
1705## begin gnulib module unsetenv 2022## begin gnulib module unsetenv
1706 2023
1707 2024
@@ -1731,7 +2048,8 @@ EXTRA_libgnu_a_SOURCES += asprintf.c vasprintf.c
1731 2048
1732## begin gnulib module verify 2049## begin gnulib module verify
1733 2050
1734libgnu_a_SOURCES += verify.h 2051
2052EXTRA_DIST += verify.h
1735 2053
1736## end gnulib module verify 2054## end gnulib module verify
1737 2055
@@ -1744,50 +2062,63 @@ EXTRA_libgnu_a_SOURCES += vsnprintf.c
1744 2062
1745## end gnulib module vsnprintf 2063## end gnulib module vsnprintf
1746 2064
1747## begin gnulib module warn-on-use
1748
1749BUILT_SOURCES += warn-on-use.h
1750# The warn-on-use.h that gets inserted into generated .h files is the same as
1751# build-aux/warn-on-use.h, except that it has the copyright header cut off.
1752warn-on-use.h: $(top_srcdir)/build-aux/warn-on-use.h
1753 $(AM_V_GEN)rm -f $@-t $@ && \
1754 sed -n -e '/^.ifndef/,$$p' \
1755 < $(top_srcdir)/build-aux/warn-on-use.h \
1756 > $@-t && \
1757 mv $@-t $@
1758MOSTLYCLEANFILES += warn-on-use.h warn-on-use.h-t
1759
1760WARN_ON_USE_H=warn-on-use.h
1761
1762EXTRA_DIST += $(top_srcdir)/build-aux/warn-on-use.h
1763
1764## end gnulib module warn-on-use
1765
1766## begin gnulib module wchar 2065## begin gnulib module wchar
1767 2066
1768BUILT_SOURCES += wchar.h 2067BUILT_SOURCES += wchar.h
1769 2068
1770# We need the following in order to create <wchar.h> when the system 2069# We need the following in order to create <wchar.h> when the system
1771# version does not work standalone. 2070# version does not work standalone.
1772wchar.h: wchar.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) 2071wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
1773 $(AM_V_GEN)rm -f $@-t $@ && \ 2072 $(AM_V_GEN)rm -f $@-t $@ && \
1774 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 2073 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
1775 sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 2074 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
2075 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1776 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 2076 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
2077 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
2078 -e 's|@''HAVE_FEATURES_H''@|$(HAVE_FEATURES_H)|g' \
1777 -e 's|@''NEXT_WCHAR_H''@|$(NEXT_WCHAR_H)|g' \ 2079 -e 's|@''NEXT_WCHAR_H''@|$(NEXT_WCHAR_H)|g' \
1778 -e 's|@''HAVE_WCHAR_H''@|$(HAVE_WCHAR_H)|g' \ 2080 -e 's|@''HAVE_WCHAR_H''@|$(HAVE_WCHAR_H)|g' \
1779 -e 's|@''GNULIB_BTOWC''@|$(GNULIB_BTOWC)|g' \ 2081 -e 's/@''GNULIB_BTOWC''@/$(GNULIB_BTOWC)/g' \
1780 -e 's|@''GNULIB_WCTOB''@|$(GNULIB_WCTOB)|g' \ 2082 -e 's/@''GNULIB_WCTOB''@/$(GNULIB_WCTOB)/g' \
1781 -e 's|@''GNULIB_MBSINIT''@|$(GNULIB_MBSINIT)|g' \ 2083 -e 's/@''GNULIB_MBSINIT''@/$(GNULIB_MBSINIT)/g' \
1782 -e 's|@''GNULIB_MBRTOWC''@|$(GNULIB_MBRTOWC)|g' \ 2084 -e 's/@''GNULIB_MBRTOWC''@/$(GNULIB_MBRTOWC)/g' \
1783 -e 's|@''GNULIB_MBRLEN''@|$(GNULIB_MBRLEN)|g' \ 2085 -e 's/@''GNULIB_MBRLEN''@/$(GNULIB_MBRLEN)/g' \
1784 -e 's|@''GNULIB_MBSRTOWCS''@|$(GNULIB_MBSRTOWCS)|g' \ 2086 -e 's/@''GNULIB_MBSRTOWCS''@/$(GNULIB_MBSRTOWCS)/g' \
1785 -e 's|@''GNULIB_MBSNRTOWCS''@|$(GNULIB_MBSNRTOWCS)|g' \ 2087 -e 's/@''GNULIB_MBSNRTOWCS''@/$(GNULIB_MBSNRTOWCS)/g' \
1786 -e 's|@''GNULIB_WCRTOMB''@|$(GNULIB_WCRTOMB)|g' \ 2088 -e 's/@''GNULIB_WCRTOMB''@/$(GNULIB_WCRTOMB)/g' \
1787 -e 's|@''GNULIB_WCSRTOMBS''@|$(GNULIB_WCSRTOMBS)|g' \ 2089 -e 's/@''GNULIB_WCSRTOMBS''@/$(GNULIB_WCSRTOMBS)/g' \
1788 -e 's|@''GNULIB_WCSNRTOMBS''@|$(GNULIB_WCSNRTOMBS)|g' \ 2090 -e 's/@''GNULIB_WCSNRTOMBS''@/$(GNULIB_WCSNRTOMBS)/g' \
1789 -e 's|@''GNULIB_WCWIDTH''@|$(GNULIB_WCWIDTH)|g' \ 2091 -e 's/@''GNULIB_WCWIDTH''@/$(GNULIB_WCWIDTH)/g' \
1790 -e 's|@''HAVE_WINT_T''@|$(HAVE_WINT_T)|g' \ 2092 -e 's/@''GNULIB_WMEMCHR''@/$(GNULIB_WMEMCHR)/g' \
2093 -e 's/@''GNULIB_WMEMCMP''@/$(GNULIB_WMEMCMP)/g' \
2094 -e 's/@''GNULIB_WMEMCPY''@/$(GNULIB_WMEMCPY)/g' \
2095 -e 's/@''GNULIB_WMEMMOVE''@/$(GNULIB_WMEMMOVE)/g' \
2096 -e 's/@''GNULIB_WMEMSET''@/$(GNULIB_WMEMSET)/g' \
2097 -e 's/@''GNULIB_WCSLEN''@/$(GNULIB_WCSLEN)/g' \
2098 -e 's/@''GNULIB_WCSNLEN''@/$(GNULIB_WCSNLEN)/g' \
2099 -e 's/@''GNULIB_WCSCPY''@/$(GNULIB_WCSCPY)/g' \
2100 -e 's/@''GNULIB_WCPCPY''@/$(GNULIB_WCPCPY)/g' \
2101 -e 's/@''GNULIB_WCSNCPY''@/$(GNULIB_WCSNCPY)/g' \
2102 -e 's/@''GNULIB_WCPNCPY''@/$(GNULIB_WCPNCPY)/g' \
2103 -e 's/@''GNULIB_WCSCAT''@/$(GNULIB_WCSCAT)/g' \
2104 -e 's/@''GNULIB_WCSNCAT''@/$(GNULIB_WCSNCAT)/g' \
2105 -e 's/@''GNULIB_WCSCMP''@/$(GNULIB_WCSCMP)/g' \
2106 -e 's/@''GNULIB_WCSNCMP''@/$(GNULIB_WCSNCMP)/g' \
2107 -e 's/@''GNULIB_WCSCASECMP''@/$(GNULIB_WCSCASECMP)/g' \
2108 -e 's/@''GNULIB_WCSNCASECMP''@/$(GNULIB_WCSNCASECMP)/g' \
2109 -e 's/@''GNULIB_WCSCOLL''@/$(GNULIB_WCSCOLL)/g' \
2110 -e 's/@''GNULIB_WCSXFRM''@/$(GNULIB_WCSXFRM)/g' \
2111 -e 's/@''GNULIB_WCSDUP''@/$(GNULIB_WCSDUP)/g' \
2112 -e 's/@''GNULIB_WCSCHR''@/$(GNULIB_WCSCHR)/g' \
2113 -e 's/@''GNULIB_WCSRCHR''@/$(GNULIB_WCSRCHR)/g' \
2114 -e 's/@''GNULIB_WCSCSPN''@/$(GNULIB_WCSCSPN)/g' \
2115 -e 's/@''GNULIB_WCSSPN''@/$(GNULIB_WCSSPN)/g' \
2116 -e 's/@''GNULIB_WCSPBRK''@/$(GNULIB_WCSPBRK)/g' \
2117 -e 's/@''GNULIB_WCSSTR''@/$(GNULIB_WCSSTR)/g' \
2118 -e 's/@''GNULIB_WCSTOK''@/$(GNULIB_WCSTOK)/g' \
2119 -e 's/@''GNULIB_WCSWIDTH''@/$(GNULIB_WCSWIDTH)/g' \
2120 < $(srcdir)/wchar.in.h | \
2121 sed -e 's|@''HAVE_WINT_T''@|$(HAVE_WINT_T)|g' \
1791 -e 's|@''HAVE_BTOWC''@|$(HAVE_BTOWC)|g' \ 2122 -e 's|@''HAVE_BTOWC''@|$(HAVE_BTOWC)|g' \
1792 -e 's|@''HAVE_MBSINIT''@|$(HAVE_MBSINIT)|g' \ 2123 -e 's|@''HAVE_MBSINIT''@|$(HAVE_MBSINIT)|g' \
1793 -e 's|@''HAVE_MBRTOWC''@|$(HAVE_MBRTOWC)|g' \ 2124 -e 's|@''HAVE_MBRTOWC''@|$(HAVE_MBRTOWC)|g' \
@@ -1797,9 +2128,38 @@ wchar.h: wchar.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
1797 -e 's|@''HAVE_WCRTOMB''@|$(HAVE_WCRTOMB)|g' \ 2128 -e 's|@''HAVE_WCRTOMB''@|$(HAVE_WCRTOMB)|g' \
1798 -e 's|@''HAVE_WCSRTOMBS''@|$(HAVE_WCSRTOMBS)|g' \ 2129 -e 's|@''HAVE_WCSRTOMBS''@|$(HAVE_WCSRTOMBS)|g' \
1799 -e 's|@''HAVE_WCSNRTOMBS''@|$(HAVE_WCSNRTOMBS)|g' \ 2130 -e 's|@''HAVE_WCSNRTOMBS''@|$(HAVE_WCSNRTOMBS)|g' \
2131 -e 's|@''HAVE_WMEMCHR''@|$(HAVE_WMEMCHR)|g' \
2132 -e 's|@''HAVE_WMEMCMP''@|$(HAVE_WMEMCMP)|g' \
2133 -e 's|@''HAVE_WMEMCPY''@|$(HAVE_WMEMCPY)|g' \
2134 -e 's|@''HAVE_WMEMMOVE''@|$(HAVE_WMEMMOVE)|g' \
2135 -e 's|@''HAVE_WMEMSET''@|$(HAVE_WMEMSET)|g' \
2136 -e 's|@''HAVE_WCSLEN''@|$(HAVE_WCSLEN)|g' \
2137 -e 's|@''HAVE_WCSNLEN''@|$(HAVE_WCSNLEN)|g' \
2138 -e 's|@''HAVE_WCSCPY''@|$(HAVE_WCSCPY)|g' \
2139 -e 's|@''HAVE_WCPCPY''@|$(HAVE_WCPCPY)|g' \
2140 -e 's|@''HAVE_WCSNCPY''@|$(HAVE_WCSNCPY)|g' \
2141 -e 's|@''HAVE_WCPNCPY''@|$(HAVE_WCPNCPY)|g' \
2142 -e 's|@''HAVE_WCSCAT''@|$(HAVE_WCSCAT)|g' \
2143 -e 's|@''HAVE_WCSNCAT''@|$(HAVE_WCSNCAT)|g' \
2144 -e 's|@''HAVE_WCSCMP''@|$(HAVE_WCSCMP)|g' \
2145 -e 's|@''HAVE_WCSNCMP''@|$(HAVE_WCSNCMP)|g' \
2146 -e 's|@''HAVE_WCSCASECMP''@|$(HAVE_WCSCASECMP)|g' \
2147 -e 's|@''HAVE_WCSNCASECMP''@|$(HAVE_WCSNCASECMP)|g' \
2148 -e 's|@''HAVE_WCSCOLL''@|$(HAVE_WCSCOLL)|g' \
2149 -e 's|@''HAVE_WCSXFRM''@|$(HAVE_WCSXFRM)|g' \
2150 -e 's|@''HAVE_WCSDUP''@|$(HAVE_WCSDUP)|g' \
2151 -e 's|@''HAVE_WCSCHR''@|$(HAVE_WCSCHR)|g' \
2152 -e 's|@''HAVE_WCSRCHR''@|$(HAVE_WCSRCHR)|g' \
2153 -e 's|@''HAVE_WCSCSPN''@|$(HAVE_WCSCSPN)|g' \
2154 -e 's|@''HAVE_WCSSPN''@|$(HAVE_WCSSPN)|g' \
2155 -e 's|@''HAVE_WCSPBRK''@|$(HAVE_WCSPBRK)|g' \
2156 -e 's|@''HAVE_WCSSTR''@|$(HAVE_WCSSTR)|g' \
2157 -e 's|@''HAVE_WCSTOK''@|$(HAVE_WCSTOK)|g' \
2158 -e 's|@''HAVE_WCSWIDTH''@|$(HAVE_WCSWIDTH)|g' \
1800 -e 's|@''HAVE_DECL_WCTOB''@|$(HAVE_DECL_WCTOB)|g' \ 2159 -e 's|@''HAVE_DECL_WCTOB''@|$(HAVE_DECL_WCTOB)|g' \
1801 -e 's|@''HAVE_DECL_WCWIDTH''@|$(HAVE_DECL_WCWIDTH)|g' \ 2160 -e 's|@''HAVE_DECL_WCWIDTH''@|$(HAVE_DECL_WCWIDTH)|g' \
1802 -e 's|@''REPLACE_MBSTATE_T''@|$(REPLACE_MBSTATE_T)|g' \ 2161 | \
2162 sed -e 's|@''REPLACE_MBSTATE_T''@|$(REPLACE_MBSTATE_T)|g' \
1803 -e 's|@''REPLACE_BTOWC''@|$(REPLACE_BTOWC)|g' \ 2163 -e 's|@''REPLACE_BTOWC''@|$(REPLACE_BTOWC)|g' \
1804 -e 's|@''REPLACE_WCTOB''@|$(REPLACE_WCTOB)|g' \ 2164 -e 's|@''REPLACE_WCTOB''@|$(REPLACE_WCTOB)|g' \
1805 -e 's|@''REPLACE_MBSINIT''@|$(REPLACE_MBSINIT)|g' \ 2165 -e 's|@''REPLACE_MBSINIT''@|$(REPLACE_MBSINIT)|g' \
@@ -1811,10 +2171,10 @@ wchar.h: wchar.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
1811 -e 's|@''REPLACE_WCSRTOMBS''@|$(REPLACE_WCSRTOMBS)|g' \ 2171 -e 's|@''REPLACE_WCSRTOMBS''@|$(REPLACE_WCSRTOMBS)|g' \
1812 -e 's|@''REPLACE_WCSNRTOMBS''@|$(REPLACE_WCSNRTOMBS)|g' \ 2172 -e 's|@''REPLACE_WCSNRTOMBS''@|$(REPLACE_WCSNRTOMBS)|g' \
1813 -e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \ 2173 -e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \
2174 -e 's|@''REPLACE_WCSWIDTH''@|$(REPLACE_WCSWIDTH)|g' \
1814 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 2175 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
1815 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ 2176 -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
1816 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ 2177 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
1817 < $(srcdir)/wchar.in.h; \
1818 } > $@-t && \ 2178 } > $@-t && \
1819 mv $@-t $@ 2179 mv $@-t $@
1820MOSTLYCLEANFILES += wchar.h wchar.h-t 2180MOSTLYCLEANFILES += wchar.h wchar.h-t
@@ -1832,23 +2192,35 @@ EXTRA_libgnu_a_SOURCES += wcrtomb.c
1832 2192
1833## end gnulib module wcrtomb 2193## end gnulib module wcrtomb
1834 2194
1835## begin gnulib module wctype 2195## begin gnulib module wctype-h
1836 2196
1837BUILT_SOURCES += wctype.h 2197BUILT_SOURCES += wctype.h
2198libgnu_a_SOURCES += wctype-h.c
1838 2199
1839# We need the following in order to create <wctype.h> when the system 2200# We need the following in order to create <wctype.h> when the system
1840# doesn't have one that works with the given compiler. 2201# doesn't have one that works with the given compiler.
1841wctype.h: wctype.in.h $(CXXDEFS_H) $(WARN_ON_USE_H) 2202wctype.h: wctype.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H)
1842 $(AM_V_GEN)rm -f $@-t $@ && \ 2203 $(AM_V_GEN)rm -f $@-t $@ && \
1843 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ 2204 { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
1844 sed -e 's/@''HAVE_WCTYPE_H''@/$(HAVE_WCTYPE_H)/g' \ 2205 sed -e 's|@''GUARD_PREFIX''@|GL|g' \
2206 -e 's/@''HAVE_WCTYPE_H''@/$(HAVE_WCTYPE_H)/g' \
1845 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ 2207 -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
1846 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ 2208 -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
2209 -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
1847 -e 's|@''NEXT_WCTYPE_H''@|$(NEXT_WCTYPE_H)|g' \ 2210 -e 's|@''NEXT_WCTYPE_H''@|$(NEXT_WCTYPE_H)|g' \
2211 -e 's/@''GNULIB_ISWBLANK''@/$(GNULIB_ISWBLANK)/g' \
2212 -e 's/@''GNULIB_WCTYPE''@/$(GNULIB_WCTYPE)/g' \
2213 -e 's/@''GNULIB_ISWCTYPE''@/$(GNULIB_ISWCTYPE)/g' \
2214 -e 's/@''GNULIB_WCTRANS''@/$(GNULIB_WCTRANS)/g' \
2215 -e 's/@''GNULIB_TOWCTRANS''@/$(GNULIB_TOWCTRANS)/g' \
1848 -e 's/@''HAVE_ISWBLANK''@/$(HAVE_ISWBLANK)/g' \ 2216 -e 's/@''HAVE_ISWBLANK''@/$(HAVE_ISWBLANK)/g' \
1849 -e 's/@''HAVE_ISWCNTRL''@/$(HAVE_ISWCNTRL)/g' \ 2217 -e 's/@''HAVE_ISWCNTRL''@/$(HAVE_ISWCNTRL)/g' \
2218 -e 's/@''HAVE_WCTYPE_T''@/$(HAVE_WCTYPE_T)/g' \
2219 -e 's/@''HAVE_WCTRANS_T''@/$(HAVE_WCTRANS_T)/g' \
1850 -e 's/@''HAVE_WINT_T''@/$(HAVE_WINT_T)/g' \ 2220 -e 's/@''HAVE_WINT_T''@/$(HAVE_WINT_T)/g' \
2221 -e 's/@''REPLACE_ISWBLANK''@/$(REPLACE_ISWBLANK)/g' \
1851 -e 's/@''REPLACE_ISWCNTRL''@/$(REPLACE_ISWCNTRL)/g' \ 2222 -e 's/@''REPLACE_ISWCNTRL''@/$(REPLACE_ISWCNTRL)/g' \
2223 -e 's/@''REPLACE_TOWLOWER''@/$(REPLACE_TOWLOWER)/g' \
1852 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ 2224 -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
1853 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ 2225 -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
1854 < $(srcdir)/wctype.in.h; \ 2226 < $(srcdir)/wctype.in.h; \
@@ -1858,23 +2230,13 @@ MOSTLYCLEANFILES += wctype.h wctype.h-t
1858 2230
1859EXTRA_DIST += wctype.in.h 2231EXTRA_DIST += wctype.in.h
1860 2232
1861## end gnulib module wctype 2233## end gnulib module wctype-h
1862
1863## begin gnulib module write
1864
1865
1866EXTRA_DIST += write.c
1867
1868EXTRA_libgnu_a_SOURCES += write.c
1869
1870## end gnulib module write
1871 2234
1872## begin gnulib module xalloc 2235## begin gnulib module xalloc
1873 2236
2237libgnu_a_SOURCES += xmalloc.c
1874 2238
1875EXTRA_DIST += xalloc.h xmalloc.c 2239EXTRA_DIST += xalloc.h
1876
1877EXTRA_libgnu_a_SOURCES += xmalloc.c
1878 2240
1879## end gnulib module xalloc 2241## end gnulib module xalloc
1880 2242
@@ -1884,9 +2246,16 @@ libgnu_a_SOURCES += xalloc-die.c
1884 2246
1885## end gnulib module xalloc-die 2247## end gnulib module xalloc-die
1886 2248
2249## begin gnulib module xalloc-oversized
2250
2251
2252EXTRA_DIST += xalloc-oversized.h
2253
2254## end gnulib module xalloc-oversized
2255
1887## begin gnulib module xsize 2256## begin gnulib module xsize
1888 2257
1889libgnu_a_SOURCES += xsize.h 2258libgnu_a_SOURCES += xsize.h xsize.c
1890 2259
1891## end gnulib module xsize 2260## end gnulib module xsize
1892 2261
diff --git a/gl/alignof.h b/gl/alignof.h
deleted file mode 100644
index 240468c..0000000
--- a/gl/alignof.h
+++ /dev/null
@@ -1,53 +0,0 @@
1/* Determine alignment of types.
2 Copyright (C) 2003-2004, 2006, 2009-2010 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, or (at your option)
7 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, write to the Free Software Foundation,
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
17
18#ifndef _ALIGNOF_H
19#define _ALIGNOF_H
20
21#include <stddef.h>
22
23/* Determine the alignment of a structure slot (field) of a given type,
24 at compile time. Note that the result depends on the ABI.
25 Note: The result cannot be used as a value for an 'enum' constant,
26 due to bugs in HP-UX 10.20 cc and AIX 3.2.5 xlc. */
27#if defined __cplusplus
28 template <class type> struct alignof_helper { char __slot1; type __slot2; };
29# define alignof_slot(type) offsetof (alignof_helper<type>, __slot2)
30#else
31# define alignof_slot(type) offsetof (struct { char __slot1; type __slot2; }, __slot2)
32#endif
33
34/* Determine the good alignment of a object of the given type at compile time.
35 Note that this is not necessarily the same as alignof_slot(type).
36 For example, with GNU C on x86 platforms: alignof_type(double) = 8, but
37 - when -malign-double is not specified: alignof_slot(double) = 4,
38 - when -malign-double is specified: alignof_slot(double) = 8.
39 Note: The result cannot be used as a value for an 'enum' constant,
40 due to bugs in HP-UX 10.20 cc and AIX 3.2.5 xlc. */
41#if defined __GNUC__
42# define alignof_type __alignof__
43#else
44# define alignof_type alignof_slot
45#endif
46
47/* alignof is an alias for alignof_slot semantics, since that's what most
48 callers need.
49 Note: The result cannot be used as a value for an 'enum' constant,
50 due to bugs in HP-UX 10.20 cc and AIX 3.2.5 xlc. */
51#define alignof alignof_slot
52
53#endif /* _ALIGNOF_H */
diff --git a/gl/alloca.in.h b/gl/alloca.in.h
index 44f20b7..72d28ee 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-2010 Free Software Foundation, 3 Copyright (C) 1995, 1999, 2001-2004, 2006-2013 Free Software Foundation,
4 Inc. 4 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
@@ -14,9 +14,9 @@
14 General Public License for more details. 14 General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public 16 You should have received a copy of the GNU General Public
17 License along with this program; if not, write to the Free Software 17 License along with this program; if not, see
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 18 <http://www.gnu.org/licenses/>.
19 USA. */ 19 */
20 20
21/* Avoid using the symbol _ALLOCA_H here, as Bison assumes _ALLOCA_H 21/* Avoid using the symbol _ALLOCA_H here, as Bison assumes _ALLOCA_H
22 means there is a real alloca function. */ 22 means there is a real alloca function. */
@@ -44,6 +44,13 @@
44# define alloca _alloca 44# define alloca _alloca
45# elif defined __DECC && defined __VMS 45# elif defined __DECC && defined __VMS
46# define alloca __ALLOCA 46# define alloca __ALLOCA
47# elif defined __TANDEM && defined _TNS_E_TARGET
48# ifdef __cplusplus
49extern "C"
50# endif
51void *_alloca (unsigned short);
52# pragma intrinsic (_alloca)
53# define alloca _alloca
47# else 54# else
48# include <stddef.h> 55# include <stddef.h>
49# ifdef __cplusplus 56# ifdef __cplusplus
diff --git a/gl/arpa_inet.in.h b/gl/arpa_inet.in.h
index f7c3bc7..ba89e97 100644
--- a/gl/arpa_inet.in.h
+++ b/gl/arpa_inet.in.h
@@ -1,6 +1,6 @@
1/* A GNU-like <arpa/inet.h>. 1/* A GNU-like <arpa/inet.h>.
2 2
3 Copyright (C) 2005-2006, 2008-2010 Free Software Foundation, Inc. 3 Copyright (C) 2005-2006, 2008-2013 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
@@ -13,22 +13,32 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
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, write to the Free Software Foundation, 16 along with this program; if not, see <http://www.gnu.org/licenses/>. */
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 17
19#ifndef _GL_ARPA_INET_H 18#ifndef _@GUARD_PREFIX@_ARPA_INET_H
20 19
21#if __GNUC__ >= 3 20#if __GNUC__ >= 3
22@PRAGMA_SYSTEM_HEADER@ 21@PRAGMA_SYSTEM_HEADER@
23#endif 22#endif
23@PRAGMA_COLUMNS@
24 24
25/* Gnulib's sys/socket.h is responsible for pulling in winsock2.h etc 25#if @HAVE_FEATURES_H@
26 under MinGW. 26# include <features.h> /* for __GLIBC__ */
27#endif
28
29/* Gnulib's sys/socket.h is responsible for defining socklen_t (used below) and
30 for pulling in winsock2.h etc. under MinGW.
27 But avoid namespace pollution on glibc systems. */ 31 But avoid namespace pollution on glibc systems. */
28#ifndef __GLIBC__ 32#ifndef __GLIBC__
29# include <sys/socket.h> 33# include <sys/socket.h>
30#endif 34#endif
31 35
36/* On NonStop Kernel, inet_ntop and inet_pton are declared in <netdb.h>.
37 But avoid namespace pollution on glibc systems. */
38#if defined __TANDEM && !defined __GLIBC__
39# include <netdb.h>
40#endif
41
32#if @HAVE_ARPA_INET_H@ 42#if @HAVE_ARPA_INET_H@
33 43
34/* The include_next requires a split double-inclusion guard. */ 44/* The include_next requires a split double-inclusion guard. */
@@ -36,19 +46,17 @@
36 46
37#endif 47#endif
38 48
39#ifndef _GL_ARPA_INET_H 49#ifndef _@GUARD_PREFIX@_ARPA_INET_H
40#define _GL_ARPA_INET_H 50#define _@GUARD_PREFIX@_ARPA_INET_H
51
52/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
41 53
42/* The definition of _GL_ARG_NONNULL is copied here. */ 54/* The definition of _GL_ARG_NONNULL is copied here. */
43 55
44/* The definition of _GL_WARN_ON_USE is copied here. */ 56/* The definition of _GL_WARN_ON_USE is copied here. */
45 57
46#ifdef __cplusplus
47extern "C" {
48#endif
49 58
50#if @GNULIB_INET_NTOP@ 59#if @GNULIB_INET_NTOP@
51# if !@HAVE_DECL_INET_NTOP@
52/* Converts an internet address from internal format to a printable, 60/* Converts an internet address from internal format to a printable,
53 presentable format. 61 presentable format.
54 AF is an internet address family, such as AF_INET or AF_INET6. 62 AF is an internet address family, such as AF_INET or AF_INET6.
@@ -64,10 +72,32 @@ extern "C" {
64 72
65 For more details, see the POSIX:2001 specification 73 For more details, see the POSIX:2001 specification
66 <http://www.opengroup.org/susv3xsh/inet_ntop.html>. */ 74 <http://www.opengroup.org/susv3xsh/inet_ntop.html>. */
67extern const char *inet_ntop (int af, const void *restrict src, 75# if @REPLACE_INET_NTOP@
68 char *restrict dst, socklen_t cnt) 76# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
69 _GL_ARG_NONNULL ((2, 3)); 77# undef inet_ntop
78# define inet_ntop rpl_inet_ntop
79# endif
80_GL_FUNCDECL_RPL (inet_ntop, const char *,
81 (int af, const void *restrict src,
82 char *restrict dst, socklen_t cnt)
83 _GL_ARG_NONNULL ((2, 3)));
84_GL_CXXALIAS_RPL (inet_ntop, const char *,
85 (int af, const void *restrict src,
86 char *restrict dst, socklen_t cnt));
87# else
88# if !@HAVE_DECL_INET_NTOP@
89_GL_FUNCDECL_SYS (inet_ntop, const char *,
90 (int af, const void *restrict src,
91 char *restrict dst, socklen_t cnt)
92 _GL_ARG_NONNULL ((2, 3)));
93# endif
94/* Need to cast, because on NonStop Kernel, the fourth parameter is
95 size_t cnt. */
96_GL_CXXALIAS_SYS_CAST (inet_ntop, const char *,
97 (int af, const void *restrict src,
98 char *restrict dst, socklen_t cnt));
70# endif 99# endif
100_GL_CXXALIASWARN (inet_ntop);
71#elif defined GNULIB_POSIXCHECK 101#elif defined GNULIB_POSIXCHECK
72# undef inet_ntop 102# undef inet_ntop
73# if HAVE_RAW_DECL_INET_NTOP 103# if HAVE_RAW_DECL_INET_NTOP
@@ -77,10 +107,26 @@ _GL_WARN_ON_USE (inet_ntop, "inet_ntop is unportable - "
77#endif 107#endif
78 108
79#if @GNULIB_INET_PTON@ 109#if @GNULIB_INET_PTON@
80# if !@HAVE_DECL_INET_PTON@ 110# if @REPLACE_INET_PTON@
81extern int inet_pton (int af, const char *restrict src, void *restrict dst) 111# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
82 _GL_ARG_NONNULL ((2, 3)); 112# undef inet_pton
113# define inet_pton rpl_inet_pton
114# endif
115_GL_FUNCDECL_RPL (inet_pton, int,
116 (int af, const char *restrict src, void *restrict dst)
117 _GL_ARG_NONNULL ((2, 3)));
118_GL_CXXALIAS_RPL (inet_pton, int,
119 (int af, const char *restrict src, void *restrict dst));
120# else
121# if !@HAVE_DECL_INET_PTON@
122_GL_FUNCDECL_SYS (inet_pton, int,
123 (int af, const char *restrict src, void *restrict dst)
124 _GL_ARG_NONNULL ((2, 3)));
125# endif
126_GL_CXXALIAS_SYS (inet_pton, int,
127 (int af, const char *restrict src, void *restrict dst));
83# endif 128# endif
129_GL_CXXALIASWARN (inet_pton);
84#elif defined GNULIB_POSIXCHECK 130#elif defined GNULIB_POSIXCHECK
85# undef inet_pton 131# undef inet_pton
86# if HAVE_RAW_DECL_INET_PTON 132# if HAVE_RAW_DECL_INET_PTON
@@ -89,9 +135,6 @@ _GL_WARN_ON_USE (inet_pton, "inet_pton is unportable - "
89# endif 135# endif
90#endif 136#endif
91 137
92#ifdef __cplusplus
93}
94#endif
95 138
96#endif /* _GL_ARPA_INET_H */ 139#endif /* _@GUARD_PREFIX@_ARPA_INET_H */
97#endif /* _GL_ARPA_INET_H */ 140#endif /* _@GUARD_PREFIX@_ARPA_INET_H */
diff --git a/gl/asnprintf.c b/gl/asnprintf.c
index 3bd2229..76e228d 100644
--- a/gl/asnprintf.c
+++ b/gl/asnprintf.c
@@ -1,5 +1,5 @@
1/* Formatted output to strings. 1/* Formatted output to strings.
2 Copyright (C) 1999, 2002, 2006, 2009, 2010 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2002, 2006, 2009-2013 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
@@ -12,8 +12,7 @@
12 GNU General Public License for more details. 12 GNU General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License along 14 You should have received a copy of the GNU General Public License along
15 with this program; if not, write to the Free Software Foundation, 15 with this program; if not, see <http://www.gnu.org/licenses/>. */
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
17 16
18#include <config.h> 17#include <config.h>
19 18
diff --git a/gl/asprintf.c b/gl/asprintf.c
index 8273ecf..713dae1 100644
--- a/gl/asprintf.c
+++ b/gl/asprintf.c
@@ -1,5 +1,5 @@
1/* Formatted output to strings. 1/* Formatted output to strings.
2 Copyright (C) 1999, 2002, 2006-2007, 2009-2010 Free Software Foundation, 2 Copyright (C) 1999, 2002, 2006-2007, 2009-2013 Free Software Foundation,
3 Inc. 3 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
@@ -13,8 +13,7 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License along 15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, 16 with this program; if not, see <http://www.gnu.org/licenses/>. */
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 17
19#include <config.h> 18#include <config.h>
20 19
diff --git a/gl/base64.c b/gl/base64.c
index d99e175..8da969c 100644
--- a/gl/base64.c
+++ b/gl/base64.c
@@ -1,6 +1,5 @@
1/* base64.c -- Encode binary data using printable characters. 1/* base64.c -- Encode binary data using printable characters.
2 Copyright (C) 1999, 2000, 2001, 2004, 2005, 2006, 2009, 2010 Free Software 2 Copyright (C) 1999-2001, 2004-2006, 2009-2013 Free Software Foundation, Inc.
3 Foundation, Inc.
4 3
5 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
6 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
@@ -13,14 +12,13 @@
13 GNU General Public License for more details. 12 GNU General Public License for more details.
14 13
15 You should have received a copy of the GNU General Public License 14 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, 15 along with this program; if not, see <http://www.gnu.org/licenses/>. */
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 16
19/* Written by Simon Josefsson. Partially adapted from GNU MailUtils 17/* Written by Simon Josefsson. Partially adapted from GNU MailUtils
20 * (mailbox/filter_trans.c, as of 2004-11-28). Improved by review 18 * (mailbox/filter_trans.c, as of 2004-11-28). Improved by review
21 * from Paul Eggert, Bruno Haible, and Stepan Kasal. 19 * from Paul Eggert, Bruno Haible, and Stepan Kasal.
22 * 20 *
23 * See also RFC 3548 <http://www.ietf.org/rfc/rfc3548.txt>. 21 * See also RFC 4648 <http://www.ietf.org/rfc/rfc4648.txt>.
24 * 22 *
25 * Be careful with error checking. Here is how you would typically 23 * Be careful with error checking. Here is how you would typically
26 * use these functions: 24 * use these functions:
@@ -55,7 +53,7 @@
55#include <string.h> 53#include <string.h>
56 54
57/* C89 compliant way to cast 'char' to 'unsigned char'. */ 55/* C89 compliant way to cast 'char' to 'unsigned char'. */
58static inline unsigned char 56static unsigned char
59to_uchar (char ch) 57to_uchar (char ch)
60{ 58{
61 return ch; 59 return ch;
@@ -316,7 +314,7 @@ base64_decode_ctx_init (struct base64_decode_context *ctx)
316 and return CTX->buf. In either case, advance *IN to point to the byte 314 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 315 after the last one processed, and set *N_NON_NEWLINE to the number of
318 verified non-newline bytes accessible through the returned pointer. */ 316 verified non-newline bytes accessible through the returned pointer. */
319static inline char * 317static char *
320get_4 (struct base64_decode_context *ctx, 318get_4 (struct base64_decode_context *ctx,
321 char const *restrict *in, char const *restrict in_end, 319 char const *restrict *in, char const *restrict in_end,
322 size_t *n_non_newline) 320 size_t *n_non_newline)
@@ -370,7 +368,7 @@ get_4 (struct base64_decode_context *ctx,
370 as many bytes as possible are written to *OUT. On return, advance 368 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 369 *OUT to point to the byte after the last one written, and decrement
372 *OUTLEN to reflect the number of bytes remaining in *OUT. */ 370 *OUTLEN to reflect the number of bytes remaining in *OUT. */
373static inline bool 371static bool
374decode_4 (char const *restrict in, size_t inlen, 372decode_4 (char const *restrict in, size_t inlen,
375 char *restrict *outp, size_t *outleft) 373 char *restrict *outp, size_t *outleft)
376{ 374{
@@ -553,10 +551,10 @@ base64_decode_alloc_ctx (struct base64_decode_context *ctx,
553{ 551{
554 /* This may allocate a few bytes too many, depending on input, 552 /* This may allocate a few bytes too many, depending on input,
555 but it's not worth the extra CPU time to compute the exact size. 553 but it's not worth the extra CPU time to compute the exact size.
556 The exact size is 3 * inlen / 4, minus 1 if the input ends 554 The exact size is 3 * (inlen + (ctx ? ctx->i : 0)) / 4, minus 1 if the
557 with "=" and minus another 1 if the input ends with "==". 555 input ends with "=" and minus another 1 if the input ends with "==".
558 Dividing before multiplying avoids the possibility of overflow. */ 556 Dividing before multiplying avoids the possibility of overflow. */
559 size_t needlen = 3 * (inlen / 4) + 2; 557 size_t needlen = 3 * (inlen / 4) + 3;
560 558
561 *out = malloc (needlen); 559 *out = malloc (needlen);
562 if (!*out) 560 if (!*out)
diff --git a/gl/base64.h b/gl/base64.h
index 2be394b..343150c 100644
--- a/gl/base64.h
+++ b/gl/base64.h
@@ -1,5 +1,5 @@
1/* base64.h -- Encode binary data using printable characters. 1/* base64.h -- Encode binary data using printable characters.
2 Copyright (C) 2004, 2005, 2006, 2009, 2010 Free Software Foundation, Inc. 2 Copyright (C) 2004-2006, 2009-2013 Free Software Foundation, Inc.
3 Written by Simon Josefsson. 3 Written by Simon Josefsson.
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
@@ -13,8 +13,7 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
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, write to the Free Software Foundation, 16 along with this program; if not, see <http://www.gnu.org/licenses/>. */
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 17
19#ifndef BASE64_H 18#ifndef BASE64_H
20# define BASE64_H 19# define BASE64_H
@@ -25,6 +24,10 @@
25/* Get bool. */ 24/* Get bool. */
26# include <stdbool.h> 25# include <stdbool.h>
27 26
27# ifdef __cplusplus
28extern "C" {
29# endif
30
28/* This uses that the expression (n+(k-1))/k means the smallest 31/* This uses that the expression (n+(k-1))/k means the smallest
29 integer >= n/k, i.e., the ceiling of n/k. */ 32 integer >= n/k, i.e., the ceiling of n/k. */
30# define BASE64_LENGTH(inlen) ((((inlen) + 2) / 3) * 4) 33# define BASE64_LENGTH(inlen) ((((inlen) + 2) / 3) * 4)
@@ -35,7 +38,7 @@ struct base64_decode_context
35 char buf[4]; 38 char buf[4];
36}; 39};
37 40
38extern bool isbase64 (char ch); 41extern bool isbase64 (char ch) _GL_ATTRIBUTE_CONST;
39 42
40extern void base64_encode (const char *restrict in, size_t inlen, 43extern void base64_encode (const char *restrict in, size_t inlen,
41 char *restrict out, size_t outlen); 44 char *restrict out, size_t outlen);
@@ -58,4 +61,8 @@ extern bool base64_decode_alloc_ctx (struct base64_decode_context *ctx,
58#define base64_decode_alloc(in, inlen, out, outlen) \ 61#define base64_decode_alloc(in, inlen, out, outlen) \
59 base64_decode_alloc_ctx (NULL, in, inlen, out, outlen) 62 base64_decode_alloc_ctx (NULL, in, inlen, out, outlen)
60 63
64# ifdef __cplusplus
65}
66# endif
67
61#endif /* BASE64_H */ 68#endif /* BASE64_H */
diff --git a/gl/basename-lgpl.c b/gl/basename-lgpl.c
index a35ff01..9307e83 100644
--- a/gl/basename-lgpl.c
+++ b/gl/basename-lgpl.c
@@ -1,6 +1,6 @@
1/* basename.c -- return the last element in a file name 1/* basename.c -- return the last element in a file name
2 2
3 Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2010 Free Software 3 Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2013 Free Software
4 Foundation, Inc. 4 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
diff --git a/gl/basename.c b/gl/basename.c
index 24da93a..d73fd41 100644
--- a/gl/basename.c
+++ b/gl/basename.c
@@ -1,6 +1,6 @@
1/* basename.c -- return the last element in a file name 1/* basename.c -- return the last element in a file name
2 2
3 Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2010 Free Software 3 Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2013 Free Software
4 Foundation, Inc. 4 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
@@ -40,8 +40,8 @@ base_name (char const *name)
40 if (ISSLASH (base[length])) 40 if (ISSLASH (base[length]))
41 length++; 41 length++;
42 42
43 /* On systems with drive letters, `a/b:c' must return `./b:c' rather 43 /* On systems with drive letters, "a/b:c" must return "./b:c" rather
44 than `b:c' to avoid confusion with a drive letter. On systems 44 than "b:c" to avoid confusion with a drive letter. On systems
45 with pure POSIX semantics, this is not an issue. */ 45 with pure POSIX semantics, this is not an issue. */
46 if (FILE_SYSTEM_PREFIX_LEN (base)) 46 if (FILE_SYSTEM_PREFIX_LEN (base))
47 { 47 {
diff --git a/gl/btowc.c b/gl/btowc.c
index 8744602..6c7cbec 100644
--- a/gl/btowc.c
+++ b/gl/btowc.c
@@ -1,5 +1,5 @@
1/* Convert unibyte character to wide character. 1/* Convert unibyte character to wide character.
2 Copyright (C) 2008, 2010 Free Software Foundation, Inc. 2 Copyright (C) 2008, 2010-2013 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2008. 3 Written by Bruno Haible <bruno@clisp.org>, 2008.
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
diff --git a/gl/c-strtod.c b/gl/c-strtod.c
deleted file mode 100644
index 38d472b..0000000
--- a/gl/c-strtod.c
+++ /dev/null
@@ -1,112 +0,0 @@
1/* Convert string to double, using the C locale.
2
3 Copyright (C) 2003-2004, 2006, 2009-2010 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#include <config.h>
21
22#include "c-strtod.h"
23
24#include <errno.h>
25#include <locale.h>
26#include <stdlib.h>
27#include <string.h>
28
29#if LONG
30# define C_STRTOD c_strtold
31# define DOUBLE long double
32# define STRTOD_L strtold_l
33#else
34# define C_STRTOD c_strtod
35# define DOUBLE double
36# define STRTOD_L strtod_l
37#endif
38
39/* c_strtold falls back on strtod if strtold doesn't conform to C99. */
40#if LONG && HAVE_C99_STRTOLD
41# define STRTOD strtold
42#else
43# define STRTOD strtod
44#endif
45
46#ifdef LC_ALL_MASK
47
48/* Cache for the C locale object.
49 Marked volatile so that different threads see the same value
50 (avoids locking). */
51static volatile locale_t c_locale_cache;
52
53/* Return the C locale object, or (locale_t) 0 with errno set
54 if it cannot be created. */
55static inline locale_t
56c_locale (void)
57{
58 if (!c_locale_cache)
59 c_locale_cache = newlocale (LC_ALL_MASK, "C", (locale_t) 0);
60 return c_locale_cache;
61}
62
63#endif
64
65DOUBLE
66C_STRTOD (char const *nptr, char **endptr)
67{
68 DOUBLE r;
69
70#ifdef LC_ALL_MASK
71
72 locale_t locale = c_locale ();
73 if (!locale)
74 {
75 if (endptr)
76 *endptr = (char *) nptr;
77 return 0; /* errno is set here */
78 }
79
80 r = STRTOD_L (nptr, endptr, locale);
81
82#else
83
84 char *saved_locale = setlocale (LC_NUMERIC, NULL);
85
86 if (saved_locale)
87 {
88 saved_locale = strdup (saved_locale);
89 if (saved_locale == NULL)
90 {
91 if (endptr)
92 *endptr = (char *) nptr;
93 return 0; /* errno is set here */
94 }
95 setlocale (LC_NUMERIC, "C");
96 }
97
98 r = STRTOD (nptr, endptr);
99
100 if (saved_locale)
101 {
102 int saved_errno = errno;
103
104 setlocale (LC_NUMERIC, saved_locale);
105 free (saved_locale);
106 errno = saved_errno;
107 }
108
109#endif
110
111 return r;
112}
diff --git a/gl/c-strtod.h b/gl/c-strtod.h
deleted file mode 100644
index c2adf1e..0000000
--- a/gl/c-strtod.h
+++ /dev/null
@@ -1,37 +0,0 @@
1/* Convert string to double, using the C locale.
2
3 Copyright (C) 2003-2004, 2009-2010 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/* Parse the initial portion of the string pointed to by NPTR as a floating-
19 point number (in decimal or hexadecimal notation), like in the C locale:
20 accepting only the ASCII digits '0'..'9', and only '.' as decimal point
21 character.
22 If ENDPTR is not NULL, set *ENDPTR to point to the first byte beyond the
23 parsed number or to NPTR if the string does not start with a parseable
24 number.
25 Return value:
26 - If successful, return the value as a double or 'long double',
27 respectively, and don't modify errno.
28 - In case of overflow, return ±HUGE_VAL or ±HUGE_VALL, respectively, and
29 set errno to ERANGE.
30 - In case of underflow, return a value very near to 0 and set errno to
31 ERANGE.
32 - If the string does not start with a number at all, return 0 (and recall
33 that if ENDPTR != NULL, *ENDPTR is set to NPTR), and maybe set errno to
34 EINVAL.
35 - In case of other error, return 0 and set errno, for example to ENOMEM. */
36extern double c_strtod (char const *nptr, char **endptr);
37extern long double c_strtold (char const *nptr, char **endptr);
diff --git a/gl/cloexec.c b/gl/cloexec.c
deleted file mode 100644
index 2d12efe..0000000
--- a/gl/cloexec.c
+++ /dev/null
@@ -1,83 +0,0 @@
1/* closexec.c - set or clear the close-on-exec descriptor flag
2
3 Copyright (C) 1991, 2004-2006, 2009-2010 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 The code is taken from glibc/manual/llio.texi */
19
20#include <config.h>
21
22#include "cloexec.h"
23
24#include <errno.h>
25#include <fcntl.h>
26#include <unistd.h>
27
28/* Set the `FD_CLOEXEC' flag of DESC if VALUE is true,
29 or clear the flag if VALUE is false.
30 Return 0 on success, or -1 on error with `errno' set.
31
32 Note that on MingW, this function does NOT protect DESC from being
33 inherited into spawned children. Instead, either use dup_cloexec
34 followed by closing the original DESC, or use interfaces such as
35 open or pipe2 that accept flags like O_CLOEXEC to create DESC
36 non-inheritable in the first place. */
37
38int
39set_cloexec_flag (int desc, bool value)
40{
41#ifdef F_SETFD
42
43 int flags = fcntl (desc, F_GETFD, 0);
44
45 if (0 <= flags)
46 {
47 int newflags = (value ? flags | FD_CLOEXEC : flags & ~FD_CLOEXEC);
48
49 if (flags == newflags
50 || fcntl (desc, F_SETFD, newflags) != -1)
51 return 0;
52 }
53
54 return -1;
55
56#else /* !F_SETFD */
57
58 /* Use dup2 to reject invalid file descriptors; the cloexec flag
59 will be unaffected. */
60 if (desc < 0)
61 {
62 errno = EBADF;
63 return -1;
64 }
65 if (dup2 (desc, desc) < 0)
66 /* errno is EBADF here. */
67 return -1;
68
69 /* There is nothing we can do on this kind of platform. Punt. */
70 return 0;
71#endif /* !F_SETFD */
72}
73
74
75/* Duplicates a file handle FD, while marking the copy to be closed
76 prior to exec or spawn. Returns -1 and sets errno if FD could not
77 be duplicated. */
78
79int
80dup_cloexec (int fd)
81{
82 return fcntl (fd, F_DUPFD_CLOEXEC, 0);
83}
diff --git a/gl/cloexec.h b/gl/cloexec.h
deleted file mode 100644
index e3a2cb8..0000000
--- a/gl/cloexec.h
+++ /dev/null
@@ -1,38 +0,0 @@
1/* closexec.c - set or clear the close-on-exec descriptor flag
2
3 Copyright (C) 2004, 2009-2010 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*/
19
20#include <stdbool.h>
21
22/* Set the `FD_CLOEXEC' flag of DESC if VALUE is true,
23 or clear the flag if VALUE is false.
24 Return 0 on success, or -1 on error with `errno' set.
25
26 Note that on MingW, this function does NOT protect DESC from being
27 inherited into spawned children. Instead, either use dup_cloexec
28 followed by closing the original DESC, or use interfaces such as
29 open or pipe2 that accept flags like O_CLOEXEC to create DESC
30 non-inheritable in the first place. */
31
32int set_cloexec_flag (int desc, bool value);
33
34/* Duplicates a file handle FD, while marking the copy to be closed
35 prior to exec or spawn. Returns -1 and sets errno if FD could not
36 be duplicated. */
37
38int dup_cloexec (int fd);
diff --git a/gl/close-hook.c b/gl/close-hook.c
deleted file mode 100644
index 0253c4d..0000000
--- a/gl/close-hook.c
+++ /dev/null
@@ -1,91 +0,0 @@
1/* Hook for making the close() function extensible.
2 Copyright (C) 2009, 2010 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2009.
4
5 This program is free software: you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published
7 by 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 GNU
13 Lesser 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 "close-hook.h"
22
23#include <stdlib.h>
24#include <unistd.h>
25
26#undef close
27
28
29/* Currently, this entire code is only needed for the handling of sockets
30 on native Windows platforms. */
31#if WINDOWS_SOCKETS
32
33/* The first and last link in the doubly linked list.
34 Initially the list is empty. */
35static struct close_hook anchor = { &anchor, &anchor, NULL };
36
37int
38execute_close_hooks (int fd, const struct close_hook *remaining_list)
39{
40 if (remaining_list == &anchor)
41 /* End of list reached. */
42 return close (fd);
43 else
44 return remaining_list->private_fn (fd, remaining_list->private_next);
45}
46
47int
48execute_all_close_hooks (int fd)
49{
50 return execute_close_hooks (fd, anchor.private_next);
51}
52
53void
54register_close_hook (close_hook_fn hook, struct close_hook *link)
55{
56 if (link->private_next == NULL && link->private_prev == NULL)
57 {
58 /* Add the link to the doubly linked list. */
59 link->private_next = anchor.private_next;
60 link->private_prev = &anchor;
61 link->private_fn = hook;
62 anchor.private_next->private_prev = link;
63 anchor.private_next = link;
64 }
65 else
66 {
67 /* The link is already in use. */
68 if (link->private_fn != hook)
69 abort ();
70 }
71}
72
73void
74unregister_close_hook (struct close_hook *link)
75{
76 struct close_hook *next = link->private_next;
77 struct close_hook *prev = link->private_prev;
78
79 if (next != NULL && prev != NULL)
80 {
81 /* The link is in use. Remove it from the doubly linked list. */
82 prev->private_next = next;
83 next->private_prev = prev;
84 /* Clear the link, to mark it unused. */
85 link->private_next = NULL;
86 link->private_prev = NULL;
87 link->private_fn = NULL;
88 }
89}
90
91#endif
diff --git a/gl/close-hook.h b/gl/close-hook.h
deleted file mode 100644
index 1e11551..0000000
--- a/gl/close-hook.h
+++ /dev/null
@@ -1,72 +0,0 @@
1/* Hook for making the close() function extensible.
2 Copyright (C) 2009, 2010 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
18#ifndef CLOSE_HOOK_H
19#define CLOSE_HOOK_H
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25
26/* Currently, this entire code is only needed for the handling of sockets
27 on native Windows platforms. */
28#if WINDOWS_SOCKETS
29
30
31/* An element of the list of close hooks.
32 The fields of this structure are considered private. */
33struct close_hook
34{
35 /* Doubly linked list. */
36 struct close_hook *private_next;
37 struct close_hook *private_prev;
38 /* Function that treats the types of FD that it knows about and calls
39 execute_close_hooks (FD, REMAINING_LIST) as a fallback. */
40 int (*private_fn) (int fd, const struct close_hook *remaining_list);
41};
42
43/* This type of function closes FD, applying special knowledge for the FD
44 types it knows about, and calls execute_close_hooks (FD, REMAINING_LIST)
45 for the other FD types. */
46typedef int (*close_hook_fn) (int fd, const struct close_hook *remaining_list);
47
48/* Execute the close hooks in REMAINING_LIST.
49 Return 0 or -1, like close() would do. */
50extern int execute_close_hooks (int fd, const struct close_hook *remaining_list);
51
52/* Execute all close hooks.
53 Return 0 or -1, like close() would do. */
54extern int execute_all_close_hooks (int fd);
55
56/* Add a function to the list of close hooks.
57 The LINK variable points to a piece of memory which is guaranteed to be
58 accessible until the corresponding call to unregister_close_hook. */
59extern void register_close_hook (close_hook_fn hook, struct close_hook *link);
60
61/* Removes a function from the list of close hooks. */
62extern void unregister_close_hook (struct close_hook *link);
63
64
65#endif
66
67
68#ifdef __cplusplus
69}
70#endif
71
72#endif /* CLOSE_HOOK_H */
diff --git a/gl/config.charset b/gl/config.charset
index aa7d00d..a991419 100644
--- 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-2010 Free Software Foundation, Inc. 4# Copyright (C) 2000-2004, 2006-2013 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
@@ -14,8 +14,7 @@
14# GNU General Public License for more details. 14# GNU General Public License for more details.
15# 15#
16# You should have received a copy of the GNU General Public License along 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, 17# with this program; if not, see <http://www.gnu.org/licenses/>.
18# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19# 18#
20# The table consists of lines of the form 19# The table consists of lines of the form
21# ALIAS CANONICAL 20# ALIAS CANONICAL
@@ -30,6 +29,8 @@
30# The current list of GNU canonical charset names is as follows. 29# The current list of GNU canonical charset names is as follows.
31# 30#
32# name MIME? used by which systems 31# name MIME? used by which systems
32# (darwin = Mac OS X, woe32 = native Windows)
33#
33# ASCII, ANSI_X3.4-1968 glibc solaris freebsd netbsd darwin cygwin 34# ASCII, ANSI_X3.4-1968 glibc solaris freebsd netbsd darwin cygwin
34# ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin 35# ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
35# ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin 36# ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd netbsd openbsd darwin cygwin
diff --git a/gl/dirname-lgpl.c b/gl/dirname-lgpl.c
index d4506e0..82f6630 100644
--- a/gl/dirname-lgpl.c
+++ b/gl/dirname-lgpl.c
@@ -1,6 +1,6 @@
1/* dirname.c -- return all but the last element in a file name 1/* dirname.c -- return all but the last element in a file name
2 2
3 Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2010 Free Software 3 Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2013 Free Software
4 Foundation, Inc. 4 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
@@ -25,7 +25,7 @@
25 25
26/* Return the length of the prefix of FILE that will be used by 26/* Return the length of the prefix of FILE that will be used by
27 dir_name. If FILE is in the working directory, this returns zero 27 dir_name. If FILE is in the working directory, this returns zero
28 even though `dir_name (FILE)' will return ".". Works properly even 28 even though 'dir_name (FILE)' will return ".". Works properly even
29 if there are trailing slashes (by effectively ignoring them). */ 29 if there are trailing slashes (by effectively ignoring them). */
30 30
31size_t 31size_t
@@ -53,9 +53,9 @@ dir_len (char const *file)
53} 53}
54 54
55 55
56/* In general, we can't use the builtin `dirname' function if available, 56/* In general, we can't use the builtin 'dirname' function if available,
57 since it has different meanings in different environments. 57 since it has different meanings in different environments.
58 In some environments the builtin `dirname' modifies its argument. 58 In some environments the builtin 'dirname' modifies its argument.
59 59
60 Return the leading directories part of FILE, allocated with malloc. 60 Return the leading directories part of FILE, allocated with malloc.
61 Works properly even if there are trailing slashes (by effectively 61 Works properly even if there are trailing slashes (by effectively
diff --git a/gl/dirname.c b/gl/dirname.c
index 953a9ac..1fb6588 100644
--- a/gl/dirname.c
+++ b/gl/dirname.c
@@ -1,6 +1,6 @@
1/* dirname.c -- return all but the last element in a file name 1/* dirname.c -- return all but the last element in a file name
2 2
3 Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2010 Free Software 3 Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2013 Free Software
4 Foundation, Inc. 4 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
diff --git a/gl/dirname.h b/gl/dirname.h
index fb19508..4ad0312 100644
--- a/gl/dirname.h
+++ b/gl/dirname.h
@@ -1,6 +1,6 @@
1/* Take file names apart into directory and base names. 1/* Take file names apart into directory and base names.
2 2
3 Copyright (C) 1998, 2001, 2003-2006, 2009-2010 Free Software Foundation, 3 Copyright (C) 1998, 2001, 2003-2006, 2009-2013 Free Software Foundation,
4 Inc. 4 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
@@ -21,53 +21,25 @@
21 21
22# include <stdbool.h> 22# include <stdbool.h>
23# include <stddef.h> 23# include <stddef.h>
24# include "dosname.h"
24 25
25# ifndef DIRECTORY_SEPARATOR 26# ifndef DIRECTORY_SEPARATOR
26# define DIRECTORY_SEPARATOR '/' 27# define DIRECTORY_SEPARATOR '/'
27# endif 28# endif
28 29
29# ifndef ISSLASH
30# define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR)
31# endif
32
33# ifndef FILE_SYSTEM_PREFIX_LEN
34# if FILE_SYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX
35 /* This internal macro assumes ASCII, but all hosts that support drive
36 letters use ASCII. */
37# define _IS_DRIVE_LETTER(c) (((unsigned int) (c) | ('a' - 'A')) - 'a' \
38 <= 'z' - 'a')
39# define FILE_SYSTEM_PREFIX_LEN(Filename) \
40 (_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':' ? 2 : 0)
41# else
42# define FILE_SYSTEM_PREFIX_LEN(Filename) 0
43# endif
44# endif
45
46# ifndef FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
47# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
48# endif
49
50# ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT 30# ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT
51# define DOUBLE_SLASH_IS_DISTINCT_ROOT 0 31# define DOUBLE_SLASH_IS_DISTINCT_ROOT 0
52# endif 32# endif
53 33
54# if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
55# define IS_ABSOLUTE_FILE_NAME(F) ISSLASH ((F)[FILE_SYSTEM_PREFIX_LEN (F)])
56# else
57# define IS_ABSOLUTE_FILE_NAME(F) \
58 (ISSLASH ((F)[0]) || 0 < FILE_SYSTEM_PREFIX_LEN (F))
59# endif
60# define IS_RELATIVE_FILE_NAME(F) (! IS_ABSOLUTE_FILE_NAME (F))
61
62# if GNULIB_DIRNAME 34# if GNULIB_DIRNAME
63char *base_name (char const *file); 35char *base_name (char const *file);
64char *dir_name (char const *file); 36char *dir_name (char const *file);
65# endif 37# endif
66 38
67char *mdir_name (char const *file); 39char *mdir_name (char const *file);
68size_t base_len (char const *file); 40size_t base_len (char const *file) _GL_ATTRIBUTE_PURE;
69size_t dir_len (char const *file); 41size_t dir_len (char const *file) _GL_ATTRIBUTE_PURE;
70char *last_component (char const *file); 42char *last_component (char const *file) _GL_ATTRIBUTE_PURE;
71 43
72bool strip_trailing_slashes (char *file); 44bool strip_trailing_slashes (char *file);
73 45
diff --git a/gl/dosname.h b/gl/dosname.h
new file mode 100644
index 0000000..ba63ce4
--- /dev/null
+++ b/gl/dosname.h
@@ -0,0 +1,53 @@
1/* File names on MS-DOS/Windows systems.
2
3 Copyright (C) 2000-2001, 2004-2006, 2009-2013 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 From Paul Eggert and Jim Meyering. */
19
20#ifndef _DOSNAME_H
21#define _DOSNAME_H
22
23#if (defined _WIN32 || defined __WIN32__ || \
24 defined __MSDOS__ || defined __CYGWIN__ || \
25 defined __EMX__ || defined __DJGPP__)
26 /* This internal macro assumes ASCII, but all hosts that support drive
27 letters use ASCII. */
28# define _IS_DRIVE_LETTER(C) (((unsigned int) (C) | ('a' - 'A')) - 'a' \
29 <= 'z' - 'a')
30# define FILE_SYSTEM_PREFIX_LEN(Filename) \
31 (_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':' ? 2 : 0)
32# ifndef __CYGWIN__
33# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 1
34# endif
35# define ISSLASH(C) ((C) == '/' || (C) == '\\')
36#else
37# define FILE_SYSTEM_PREFIX_LEN(Filename) 0
38# define ISSLASH(C) ((C) == '/')
39#endif
40
41#ifndef FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
42# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
43#endif
44
45#if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
46# define IS_ABSOLUTE_FILE_NAME(F) ISSLASH ((F)[FILE_SYSTEM_PREFIX_LEN (F)])
47# else
48# define IS_ABSOLUTE_FILE_NAME(F) \
49 (ISSLASH ((F)[0]) || FILE_SYSTEM_PREFIX_LEN (F) != 0)
50#endif
51#define IS_RELATIVE_FILE_NAME(F) (! IS_ABSOLUTE_FILE_NAME (F))
52
53#endif /* DOSNAME_H_ */
diff --git a/gl/dup-safer.c b/gl/dup-safer.c
deleted file mode 100644
index 33f599b..0000000
--- a/gl/dup-safer.c
+++ /dev/null
@@ -1,34 +0,0 @@
1/* Invoke dup, but avoid some glitches.
2
3 Copyright (C) 2001, 2004-2006, 2009-2010 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#include <config.h>
21
22#include "unistd-safer.h"
23
24#include <fcntl.h>
25#include <unistd.h>
26
27/* Like dup, but do not return STDIN_FILENO, STDOUT_FILENO, or
28 STDERR_FILENO. */
29
30int
31dup_safer (int fd)
32{
33 return fcntl (fd, F_DUPFD, STDERR_FILENO + 1);
34}
diff --git a/gl/dup2.c b/gl/dup2.c
deleted file mode 100644
index a4422bf..0000000
--- a/gl/dup2.c
+++ /dev/null
@@ -1,128 +0,0 @@
1/* Duplicate an open file descriptor to a specified file descriptor.
2
3 Copyright (C) 1999, 2004-2007, 2009-2010 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#include <config.h>
21
22/* Specification. */
23#include <unistd.h>
24
25#include <errno.h>
26#include <fcntl.h>
27
28#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
29/* Get declarations of the Win32 API functions. */
30# define WIN32_LEAN_AND_MEAN
31# include <windows.h>
32#endif
33
34#if HAVE_DUP2
35
36# undef dup2
37
38int
39rpl_dup2 (int fd, int desired_fd)
40{
41 int result;
42# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
43 /* If fd is closed, mingw hangs on dup2 (fd, fd). If fd is open,
44 dup2 (fd, fd) returns 0, but all further attempts to use fd in
45 future dup2 calls will hang. */
46 if (fd == desired_fd)
47 {
48 if ((HANDLE) _get_osfhandle (fd) == INVALID_HANDLE_VALUE)
49 {
50 errno = EBADF;
51 return -1;
52 }
53 return fd;
54 }
55 /* Wine 1.0.1 return 0 when desired_fd is negative but not -1:
56 http://bugs.winehq.org/show_bug.cgi?id=21289 */
57 if (desired_fd < 0)
58 {
59 errno = EBADF;
60 return -1;
61 }
62# endif
63 result = dup2 (fd, desired_fd);
64# ifdef __linux__
65 /* Correct a Linux return value.
66 <http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.30.y.git;a=commitdiff;h=2b79bc4f7ebbd5af3c8b867968f9f15602d5f802>
67 */
68 if (fd == desired_fd && result == (unsigned int) -EBADF)
69 {
70 errno = EBADF;
71 result = -1;
72 }
73# endif
74 if (result == 0)
75 result = desired_fd;
76 /* Correct a cygwin 1.5.x errno value. */
77 else if (result == -1 && errno == EMFILE)
78 errno = EBADF;
79# if REPLACE_FCHDIR
80 if (fd != desired_fd && result != -1)
81 result = _gl_register_dup (fd, result);
82# endif
83 return result;
84}
85
86#else /* !HAVE_DUP2 */
87
88/* On older platforms, dup2 did not exist. */
89
90# ifndef F_DUPFD
91static int
92dupfd (int fd, int desired_fd)
93{
94 int duplicated_fd = dup (fd);
95 if (duplicated_fd < 0 || duplicated_fd == desired_fd)
96 return duplicated_fd;
97 else
98 {
99 int r = dupfd (fd, desired_fd);
100 int e = errno;
101 close (duplicated_fd);
102 errno = e;
103 return r;
104 }
105}
106# endif
107
108int
109dup2 (int fd, int desired_fd)
110{
111 int result = fcntl (fd, F_GETFL) < 0 ? -1 : fd;
112 if (result == -1 || fd == desired_fd)
113 return result;
114 close (desired_fd);
115# ifdef F_DUPFD
116 result = fcntl (fd, F_DUPFD, desired_fd);
117# if REPLACE_FCHDIR
118 if (0 <= result)
119 result = _gl_register_dup (fd, result);
120# endif
121# else
122 result = dupfd (fd, desired_fd);
123# endif
124 if (result == -1 && (errno == EMFILE || errno == EINVAL))
125 errno = EBADF;
126 return result;
127}
128#endif /* !HAVE_DUP2 */
diff --git a/gl/errno.in.h b/gl/errno.in.h
index 140e5d1..49b3546 100644
--- a/gl/errno.in.h
+++ b/gl/errno.in.h
@@ -1,6 +1,6 @@
1/* A POSIX-like <errno.h>. 1/* A POSIX-like <errno.h>.
2 2
3 Copyright (C) 2008-2010 Free Software Foundation, Inc. 3 Copyright (C) 2008-2013 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
@@ -13,69 +13,137 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
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, write to the Free Software Foundation, 16 along with this program; if not, see <http://www.gnu.org/licenses/>. */
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 17
19#ifndef _GL_ERRNO_H 18#ifndef _@GUARD_PREFIX@_ERRNO_H
20 19
21#if __GNUC__ >= 3 20#if __GNUC__ >= 3
22@PRAGMA_SYSTEM_HEADER@ 21@PRAGMA_SYSTEM_HEADER@
23#endif 22#endif
23@PRAGMA_COLUMNS@
24 24
25/* The include_next requires a split double-inclusion guard. */ 25/* The include_next requires a split double-inclusion guard. */
26#@INCLUDE_NEXT@ @NEXT_ERRNO_H@ 26#@INCLUDE_NEXT@ @NEXT_ERRNO_H@
27 27
28#ifndef _GL_ERRNO_H 28#ifndef _@GUARD_PREFIX@_ERRNO_H
29#define _GL_ERRNO_H 29#define _@GUARD_PREFIX@_ERRNO_H
30 30
31 31
32/* On native Windows platforms, many macros are not defined. */ 32/* On native Windows platforms, many macros are not defined. */
33# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 33# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
34 34
35/* POSIX says that EAGAIN and EWOULDBLOCK may have the same value. */ 35/* These are the same values as defined by MSVC 10, for interoperability. */
36# define EWOULDBLOCK EAGAIN
37 36
38/* Values >= 100 seem safe to use. */ 37# ifndef ENOMSG
39# define ETXTBSY 100 38# define ENOMSG 122
40# define GNULIB_defined_ETXTBSY 1 39# define GNULIB_defined_ENOMSG 1
40# endif
41
42# ifndef EIDRM
43# define EIDRM 111
44# define GNULIB_defined_EIDRM 1
45# endif
46
47# ifndef ENOLINK
48# define ENOLINK 121
49# define GNULIB_defined_ENOLINK 1
50# endif
51
52# ifndef EPROTO
53# define EPROTO 134
54# define GNULIB_defined_EPROTO 1
55# endif
56
57# ifndef EBADMSG
58# define EBADMSG 104
59# define GNULIB_defined_EBADMSG 1
60# endif
61
62# ifndef EOVERFLOW
63# define EOVERFLOW 132
64# define GNULIB_defined_EOVERFLOW 1
65# endif
66
67# ifndef ENOTSUP
68# define ENOTSUP 129
69# define GNULIB_defined_ENOTSUP 1
70# endif
71
72# ifndef ENETRESET
73# define ENETRESET 117
74# define GNULIB_defined_ENETRESET 1
75# endif
76
77# ifndef ECONNABORTED
78# define ECONNABORTED 106
79# define GNULIB_defined_ECONNABORTED 1
80# endif
81
82# ifndef ECANCELED
83# define ECANCELED 105
84# define GNULIB_defined_ECANCELED 1
85# endif
86
87# ifndef EOWNERDEAD
88# define EOWNERDEAD 133
89# define GNULIB_defined_EOWNERDEAD 1
90# endif
91
92# ifndef ENOTRECOVERABLE
93# define ENOTRECOVERABLE 127
94# define GNULIB_defined_ENOTRECOVERABLE 1
95# endif
96
97# ifndef EINPROGRESS
98# define EINPROGRESS 112
99# define EALREADY 103
100# define ENOTSOCK 128
101# define EDESTADDRREQ 109
102# define EMSGSIZE 115
103# define EPROTOTYPE 136
104# define ENOPROTOOPT 123
105# define EPROTONOSUPPORT 135
106# define EOPNOTSUPP 130
107# define EAFNOSUPPORT 102
108# define EADDRINUSE 100
109# define EADDRNOTAVAIL 101
110# define ENETDOWN 116
111# define ENETUNREACH 118
112# define ECONNRESET 108
113# define ENOBUFS 119
114# define EISCONN 113
115# define ENOTCONN 126
116# define ETIMEDOUT 138
117# define ECONNREFUSED 107
118# define ELOOP 114
119# define EHOSTUNREACH 110
120# define EWOULDBLOCK 140
121# define GNULIB_defined_ESOCK 1
122# endif
123
124# ifndef ETXTBSY
125# define ETXTBSY 139
126# define ENODATA 120 /* not required by POSIX */
127# define ENOSR 124 /* not required by POSIX */
128# define ENOSTR 125 /* not required by POSIX */
129# define ETIME 137 /* not required by POSIX */
130# define EOTHER 131 /* not required by POSIX */
131# define GNULIB_defined_ESTREAMS 1
132# endif
41 133
42/* These are intentionally the same values as the WSA* error numbers, defined 134/* These are intentionally the same values as the WSA* error numbers, defined
43 in <winsock2.h>. */ 135 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 */ 136# define ESOCKTNOSUPPORT 10044 /* not required by POSIX */
53# define EOPNOTSUPP 10045
54# define EPFNOSUPPORT 10046 /* not required by POSIX */ 137# 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 */ 138# define ESHUTDOWN 10058 /* not required by POSIX */
67# define ETOOMANYREFS 10059 /* not required by POSIX */ 139# 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 */ 140# define EHOSTDOWN 10064 /* not required by POSIX */
72# define EHOSTUNREACH 10065
73# define EPROCLIM 10067 /* not required by POSIX */ 141# define EPROCLIM 10067 /* not required by POSIX */
74# define EUSERS 10068 /* not required by POSIX */ 142# define EUSERS 10068 /* not required by POSIX */
75# define EDQUOT 10069 143# define EDQUOT 10069
76# define ESTALE 10070 144# define ESTALE 10070
77# define EREMOTE 10071 /* not required by POSIX */ 145# define EREMOTE 10071 /* not required by POSIX */
78# define GNULIB_defined_ESOCK 1 146# define GNULIB_defined_EWINSOCK 1
79 147
80# endif 148# endif
81 149
@@ -98,6 +166,7 @@
98 166
99/* On OpenBSD 4.0 and on native Windows, the macros ENOMSG, EIDRM, ENOLINK, 167/* On OpenBSD 4.0 and on native Windows, the macros ENOMSG, EIDRM, ENOLINK,
100 EPROTO, EMULTIHOP, EBADMSG, EOVERFLOW, ENOTSUP, ECANCELED are not defined. 168 EPROTO, EMULTIHOP, EBADMSG, EOVERFLOW, ENOTSUP, ECANCELED are not defined.
169 Likewise, on NonStop Kernel, EDQUOT is not defined.
101 Define them here. Values >= 2000 seem safe to use: Solaris ESTALE = 151, 170 Define them here. Values >= 2000 seem safe to use: Solaris ESTALE = 151,
102 HP-UX EWOULDBLOCK = 246, IRIX EDQUOT = 1133. 171 HP-UX EWOULDBLOCK = 246, IRIX EDQUOT = 1133.
103 172
@@ -145,16 +214,66 @@
145# define GNULIB_defined_ENOTSUP 1 214# define GNULIB_defined_ENOTSUP 1
146# endif 215# endif
147 216
217# ifndef ENETRESET
218# define ENETRESET 2011
219# define GNULIB_defined_ENETRESET 1
220# endif
221
222# ifndef ECONNABORTED
223# define ECONNABORTED 2012
224# define GNULIB_defined_ECONNABORTED 1
225# endif
226
148# ifndef ESTALE 227# ifndef ESTALE
149# define ESTALE 2009 228# define ESTALE 2009
150# define GNULIB_defined_ESTALE 1 229# define GNULIB_defined_ESTALE 1
151# endif 230# endif
152 231
232# ifndef EDQUOT
233# define EDQUOT 2010
234# define GNULIB_defined_EDQUOT 1
235# endif
236
153# ifndef ECANCELED 237# ifndef ECANCELED
154# define ECANCELED 2008 238# define ECANCELED 2008
155# define GNULIB_defined_ECANCELED 1 239# define GNULIB_defined_ECANCELED 1
156# endif 240# endif
157 241
242/* On many platforms, the macros EOWNERDEAD and ENOTRECOVERABLE are not
243 defined. */
244
245# ifndef EOWNERDEAD
246# if defined __sun
247 /* Use the same values as defined for Solaris >= 8, for
248 interoperability. */
249# define EOWNERDEAD 58
250# define ENOTRECOVERABLE 59
251# elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
252 /* We have a conflict here: pthreads-win32 defines these values
253 differently than MSVC 10. It's hairy to decide which one to use. */
254# if defined __MINGW32__ && !defined USE_WINDOWS_THREADS
255 /* Use the same values as defined by pthreads-win32, for
256 interoperability. */
257# define EOWNERDEAD 43
258# define ENOTRECOVERABLE 44
259# else
260 /* Use the same values as defined by MSVC 10, for
261 interoperability. */
262# define EOWNERDEAD 133
263# define ENOTRECOVERABLE 127
264# endif
265# else
266# define EOWNERDEAD 2013
267# define ENOTRECOVERABLE 2014
268# endif
269# define GNULIB_defined_EOWNERDEAD 1
270# define GNULIB_defined_ENOTRECOVERABLE 1
271# endif
272
273# ifndef EILSEQ
274# define EILSEQ 2015
275# define GNULIB_defined_EILSEQ 1
276# endif
158 277
159#endif /* _GL_ERRNO_H */ 278#endif /* _@GUARD_PREFIX@_ERRNO_H */
160#endif /* _GL_ERRNO_H */ 279#endif /* _@GUARD_PREFIX@_ERRNO_H */
diff --git a/gl/error.c b/gl/error.c
index ed9dba0..865b293 100644
--- a/gl/error.c
+++ b/gl/error.c
@@ -1,5 +1,5 @@
1/* Error handler for noninteractive utilities 1/* Error handler for noninteractive utilities
2 Copyright (C) 1990-1998, 2000-2007, 2009-2010 Free Software Foundation, Inc. 2 Copyright (C) 1990-1998, 2000-2007, 2009-2013 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
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
@@ -54,7 +54,7 @@
54 function without parameters instead. */ 54 function without parameters instead. */
55void (*error_print_progname) (void); 55void (*error_print_progname) (void);
56 56
57/* This variable is incremented each time `error' is called. */ 57/* This variable is incremented each time 'error' is called. */
58unsigned int error_message_count; 58unsigned int error_message_count;
59 59
60#ifdef _LIBC 60#ifdef _LIBC
@@ -65,7 +65,7 @@ unsigned int error_message_count;
65# include <limits.h> 65# include <limits.h>
66# include <libio/libioP.h> 66# include <libio/libioP.h>
67 67
68/* In GNU libc we want do not want to use the common name `error' directly. 68/* In GNU libc we want do not want to use the common name 'error' directly.
69 Instead make it a weak alias. */ 69 Instead make it a weak alias. */
70extern void __error (int status, int errnum, const char *message, ...) 70extern void __error (int status, int errnum, const char *message, ...)
71 __attribute__ ((__format__ (__printf__, 3, 4))); 71 __attribute__ ((__format__ (__printf__, 3, 4)));
@@ -89,19 +89,25 @@ extern void __error_at_line (int status, int errnum, const char *file_name,
89# include <unistd.h> 89# include <unistd.h>
90 90
91# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 91# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
92/* Get declarations of the Win32 API functions. */ 92/* Get declarations of the native Windows API functions. */
93# define WIN32_LEAN_AND_MEAN 93# define WIN32_LEAN_AND_MEAN
94# include <windows.h> 94# include <windows.h>
95/* Get _get_osfhandle. */
96# include "msvc-nothrow.h"
95# endif 97# endif
96 98
97/* The gnulib override of fcntl is not needed in this file. */ 99/* The gnulib override of fcntl is not needed in this file. */
98# undef fcntl 100# undef fcntl
99 101
100# if !HAVE_DECL_STRERROR_R && STRERROR_R_CHAR_P 102# if !HAVE_DECL_STRERROR_R
101# ifndef HAVE_DECL_STRERROR_R 103# ifndef HAVE_DECL_STRERROR_R
102"this configure-time declaration test was not run" 104"this configure-time declaration test was not run"
103# endif 105# endif
106# if STRERROR_R_CHAR_P
104char *strerror_r (); 107char *strerror_r ();
108# else
109int strerror_r ();
110# endif
105# endif 111# endif
106 112
107/* The calling program should define program_name and set it to the 113/* The calling program should define program_name and set it to the
@@ -115,13 +121,14 @@ extern char *program_name;
115 121
116#if !_LIBC 122#if !_LIBC
117/* Return non-zero if FD is open. */ 123/* Return non-zero if FD is open. */
118static inline int 124static int
119is_open (int fd) 125is_open (int fd)
120{ 126{
121# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 127# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
122 /* On Win32: The initial state of unassigned standard file descriptors is 128 /* On native Windows: The initial state of unassigned standard file
123 that they are open but point to an INVALID_HANDLE_VALUE. There is no 129 descriptors is that they are open but point to an INVALID_HANDLE_VALUE.
124 fcntl, and the gnulib replacement fcntl does not support F_GETFL. */ 130 There is no fcntl, and the gnulib replacement fcntl does not support
131 F_GETFL. */
125 return (HANDLE) _get_osfhandle (fd) != INVALID_HANDLE_VALUE; 132 return (HANDLE) _get_osfhandle (fd) != INVALID_HANDLE_VALUE;
126# else 133# else
127# ifndef F_GETFL 134# ifndef F_GETFL
@@ -132,7 +139,7 @@ is_open (int fd)
132} 139}
133#endif 140#endif
134 141
135static inline void 142static void
136flush_stdout (void) 143flush_stdout (void)
137{ 144{
138#if !_LIBC 145#if !_LIBC
diff --git a/gl/error.h b/gl/error.h
index 9deef02..afcb0e1 100644
--- a/gl/error.h
+++ b/gl/error.h
@@ -1,6 +1,6 @@
1/* Declaration for error-reporting function 1/* Declaration for error-reporting function
2 Copyright (C) 1995, 1996, 1997, 2003, 2006, 2008, 2009, 2010 Free Software 2 Copyright (C) 1995-1997, 2003, 2006, 2008-2013 Free Software Foundation,
3 Foundation, Inc. 3 Inc.
4 This file is part of the GNU C Library. 4 This file is part of the GNU C Library.
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
@@ -19,39 +19,39 @@
19#ifndef _ERROR_H 19#ifndef _ERROR_H
20#define _ERROR_H 1 20#define _ERROR_H 1
21 21
22#ifndef __attribute__
23/* The __attribute__ feature is available in gcc versions 2.5 and later. 22/* The __attribute__ feature is available in gcc versions 2.5 and later.
24 The __-protected variants of the attributes 'format' and 'printf' are 23 The __-protected variants of the attributes 'format' and 'printf' are
25 accepted by gcc versions 2.6.4 (effectively 2.7) and later. 24 accepted by gcc versions 2.6.4 (effectively 2.7) and later.
26 We enable __attribute__ only if these are supported too, because 25 We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because
27 gnulib and libintl do '#define printf __printf__' when they override 26 gnulib and libintl do '#define printf __printf__' when they override
28 the 'printf' function. */ 27 the 'printf' function. */
29# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) 28#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
30# define __attribute__(Spec) /* empty */ 29# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
31# endif 30#else
31# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
32#endif 32#endif
33 33
34#ifdef __cplusplus 34#ifdef __cplusplus
35extern "C" { 35extern "C" {
36#endif 36#endif
37 37
38/* Print a message with `fprintf (stderr, FORMAT, ...)'; 38/* Print a message with 'fprintf (stderr, FORMAT, ...)';
39 if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM). 39 if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
40 If STATUS is nonzero, terminate the program with `exit (STATUS)'. */ 40 If STATUS is nonzero, terminate the program with 'exit (STATUS)'. */
41 41
42extern void error (int __status, int __errnum, const char *__format, ...) 42extern void error (int __status, int __errnum, const char *__format, ...)
43 __attribute__ ((__format__ (__printf__, 3, 4))); 43 _GL_ATTRIBUTE_FORMAT ((__printf__, 3, 4));
44 44
45extern void error_at_line (int __status, int __errnum, const char *__fname, 45extern void error_at_line (int __status, int __errnum, const char *__fname,
46 unsigned int __lineno, const char *__format, ...) 46 unsigned int __lineno, const char *__format, ...)
47 __attribute__ ((__format__ (__printf__, 5, 6))); 47 _GL_ATTRIBUTE_FORMAT ((__printf__, 5, 6));
48 48
49/* If NULL, error will flush stdout, then print on stderr the program 49/* If NULL, error will flush stdout, then print on stderr the program
50 name, a colon and a space. Otherwise, error will call this 50 name, a colon and a space. Otherwise, error will call this
51 function without parameters instead. */ 51 function without parameters instead. */
52extern void (*error_print_progname) (void); 52extern void (*error_print_progname) (void);
53 53
54/* This variable is incremented each time `error' is called. */ 54/* This variable is incremented each time 'error' is called. */
55extern unsigned int error_message_count; 55extern unsigned int error_message_count;
56 56
57/* Sometimes we want to have at most one error per line. This 57/* Sometimes we want to have at most one error per line. This
diff --git a/gl/exitfail.c b/gl/exitfail.c
index 3b63f8a..b0b4ebe 100644
--- a/gl/exitfail.c
+++ b/gl/exitfail.c
@@ -1,7 +1,6 @@
1/* Failure exit status 1/* Failure exit status
2 2
3 Copyright (C) 2002, 2003, 2005, 2006, 2007, 2009, 2010 Free Software 3 Copyright (C) 2002-2003, 2005-2007, 2009-2013 Free Software Foundation, Inc.
4 Foundation, Inc.
5 4
6 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
7 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
diff --git a/gl/exitfail.h b/gl/exitfail.h
index 7ffffe5..e54333b 100644
--- a/gl/exitfail.h
+++ b/gl/exitfail.h
@@ -1,6 +1,6 @@
1/* Failure exit status 1/* Failure exit status
2 2
3 Copyright (C) 2002, 2009, 2010 Free Software Foundation, Inc. 3 Copyright (C) 2002, 2009-2013 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
diff --git a/gl/fcntl--.h b/gl/fcntl--.h
deleted file mode 100644
index 7baa2cb..0000000
--- a/gl/fcntl--.h
+++ /dev/null
@@ -1,32 +0,0 @@
1/* Like fcntl.h, but redefine some names to avoid glitches.
2
3 Copyright (C) 2005, 2009-2010 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#include <fcntl.h>
21#include "fcntl-safer.h"
22
23#undef open
24#define open open_safer
25
26#undef creat
27#define creat creat_safer
28
29#if GNULIB_OPENAT_SAFER
30# undef openat
31# define openat openat_safer
32#endif
diff --git a/gl/fcntl-safer.h b/gl/fcntl-safer.h
deleted file mode 100644
index 5c76b4b..0000000
--- a/gl/fcntl-safer.h
+++ /dev/null
@@ -1,27 +0,0 @@
1/* Invoke fcntl-like functions, but avoid some glitches.
2
3 Copyright (C) 2005, 2009-2010 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#include <sys/types.h>
21
22int open_safer (char const *, int, ...);
23int creat_safer (char const *, mode_t);
24
25#if GNULIB_OPENAT_SAFER
26int openat_safer (int, char const *, int, ...);
27#endif
diff --git a/gl/fcntl.c b/gl/fcntl.c
deleted file mode 100644
index c51e8de..0000000
--- a/gl/fcntl.c
+++ /dev/null
@@ -1,294 +0,0 @@
1/* Provide file descriptor control.
2
3 Copyright (C) 2009, 2010 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 Eric Blake <ebb9@byu.net>. */
19
20#include <config.h>
21
22/* Specification. */
23#include <fcntl.h>
24
25#include <errno.h>
26#include <limits.h>
27#include <stdarg.h>
28#include <unistd.h>
29
30#if !HAVE_FCNTL
31# define rpl_fcntl fcntl
32#endif
33#undef fcntl
34
35#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
36/* Get declarations of the Win32 API functions. */
37# define WIN32_LEAN_AND_MEAN
38# include <windows.h>
39
40/* Upper bound on getdtablesize(). See lib/getdtablesize.c. */
41# define OPEN_MAX_MAX 0x10000
42
43/* Duplicate OLDFD into the first available slot of at least NEWFD,
44 which must be positive, with FLAGS determining whether the duplicate
45 will be inheritable. */
46static int
47dupfd (int oldfd, int newfd, int flags)
48{
49 /* Mingw has no way to create an arbitrary fd. Iterate until all
50 file descriptors less than newfd are filled up. */
51 HANDLE curr_process = GetCurrentProcess ();
52 HANDLE old_handle = (HANDLE) _get_osfhandle (oldfd);
53 unsigned char fds_to_close[OPEN_MAX_MAX / CHAR_BIT];
54 unsigned int fds_to_close_bound = 0;
55 int result;
56 BOOL inherit = flags & O_CLOEXEC ? FALSE : TRUE;
57 int mode;
58
59 if (newfd < 0 || getdtablesize () <= newfd)
60 {
61 errno = EINVAL;
62 return -1;
63 }
64 if (old_handle == INVALID_HANDLE_VALUE
65 || (mode = setmode (oldfd, O_BINARY)) == -1)
66 {
67 /* oldfd is not open, or is an unassigned standard file
68 descriptor. */
69 errno = EBADF;
70 return -1;
71 }
72 setmode (oldfd, mode);
73 flags |= mode;
74
75 for (;;)
76 {
77 HANDLE new_handle;
78 int duplicated_fd;
79 unsigned int index;
80
81 if (!DuplicateHandle (curr_process, /* SourceProcessHandle */
82 old_handle, /* SourceHandle */
83 curr_process, /* TargetProcessHandle */
84 (PHANDLE) &new_handle, /* TargetHandle */
85 (DWORD) 0, /* DesiredAccess */
86 inherit, /* InheritHandle */
87 DUPLICATE_SAME_ACCESS)) /* Options */
88 {
89 /* TODO: Translate GetLastError () into errno. */
90 errno = EMFILE;
91 result = -1;
92 break;
93 }
94 duplicated_fd = _open_osfhandle ((long) new_handle, flags);
95 if (duplicated_fd < 0)
96 {
97 CloseHandle (new_handle);
98 errno = EMFILE;
99 result = -1;
100 break;
101 }
102 if (newfd <= duplicated_fd)
103 {
104 result = duplicated_fd;
105 break;
106 }
107
108 /* Set the bit duplicated_fd in fds_to_close[]. */
109 index = (unsigned int) duplicated_fd / CHAR_BIT;
110 if (fds_to_close_bound <= index)
111 {
112 if (sizeof fds_to_close <= index)
113 /* Need to increase OPEN_MAX_MAX. */
114 abort ();
115 memset (fds_to_close + fds_to_close_bound, '\0',
116 index + 1 - fds_to_close_bound);
117 fds_to_close_bound = index + 1;
118 }
119 fds_to_close[index] |= 1 << ((unsigned int) duplicated_fd % CHAR_BIT);
120 }
121
122 /* Close the previous fds that turned out to be too small. */
123 {
124 int saved_errno = errno;
125 unsigned int duplicated_fd;
126
127 for (duplicated_fd = 0;
128 duplicated_fd < fds_to_close_bound * CHAR_BIT;
129 duplicated_fd++)
130 if ((fds_to_close[duplicated_fd / CHAR_BIT]
131 >> (duplicated_fd % CHAR_BIT))
132 & 1)
133 close (duplicated_fd);
134
135 errno = saved_errno;
136 }
137
138# if REPLACE_FCHDIR
139 if (0 <= result)
140 result = _gl_register_dup (oldfd, result);
141# endif
142 return result;
143}
144#endif /* W32 */
145
146/* Perform the specified ACTION on the file descriptor FD, possibly
147 using the argument ARG further described below. This replacement
148 handles the following actions, and forwards all others on to the
149 native fcntl. An unrecognized ACTION returns -1 with errno set to
150 EINVAL.
151
152 F_DUPFD - duplicate FD, with int ARG being the minimum target fd.
153 If successful, return the duplicate, which will be inheritable;
154 otherwise return -1 and set errno.
155
156 F_DUPFD_CLOEXEC - duplicate FD, with int ARG being the minimum
157 target fd. If successful, return the duplicate, which will not be
158 inheritable; otherwise return -1 and set errno.
159
160 F_GETFD - ARG need not be present. If successful, return a
161 non-negative value containing the descriptor flags of FD (only
162 FD_CLOEXEC is portable, but other flags may be present); otherwise
163 return -1 and set errno. */
164
165int
166rpl_fcntl (int fd, int action, /* arg */...)
167{
168 va_list arg;
169 int result = -1;
170 va_start (arg, action);
171 switch (action)
172 {
173
174#if !HAVE_FCNTL
175 case F_DUPFD:
176 {
177 int target = va_arg (arg, int);
178 result = dupfd (fd, target, 0);
179 break;
180 }
181#elif FCNTL_DUPFD_BUGGY || REPLACE_FCHDIR
182 case F_DUPFD:
183 {
184 int target = va_arg (arg, int);
185 /* Detect invalid target; needed for cygwin 1.5.x. */
186 if (target < 0 || getdtablesize () <= target)
187 errno = EINVAL;
188 else
189 {
190 result = fcntl (fd, action, target);
191# if REPLACE_FCHDIR
192 if (0 <= result)
193 result = _gl_register_dup (fd, result);
194# endif
195 }
196 break;
197 } /* F_DUPFD */
198#endif /* FCNTL_DUPFD_BUGGY || REPLACE_FCHDIR */
199
200 case F_DUPFD_CLOEXEC:
201 {
202 int target = va_arg (arg, int);
203
204#if !HAVE_FCNTL
205 result = dupfd (fd, target, O_CLOEXEC);
206 break;
207#else /* HAVE_FCNTL */
208 /* Try the system call first, if the headers claim it exists
209 (that is, if GNULIB_defined_F_DUPFD_CLOEXEC is 0), since we
210 may be running with a glibc that has the macro but with an
211 older kernel that does not support it. Cache the
212 information on whether the system call really works, but
213 avoid caching failure if the corresponding F_DUPFD fails
214 for any reason. 0 = unknown, 1 = yes, -1 = no. */
215 static int have_dupfd_cloexec = GNULIB_defined_F_DUPFD_CLOEXEC ? -1 : 0;
216 if (0 <= have_dupfd_cloexec)
217 {
218 result = fcntl (fd, action, target);
219 if (0 <= result || errno != EINVAL)
220 {
221 have_dupfd_cloexec = 1;
222# if REPLACE_FCHDIR
223 if (0 <= result)
224 result = _gl_register_dup (fd, result);
225# endif
226 }
227 else
228 {
229 result = rpl_fcntl (fd, F_DUPFD, target);
230 if (result < 0)
231 break;
232 have_dupfd_cloexec = -1;
233 }
234 }
235 else
236 result = rpl_fcntl (fd, F_DUPFD, target);
237 if (0 <= result && have_dupfd_cloexec == -1)
238 {
239 int flags = fcntl (result, F_GETFD);
240 if (flags < 0 || fcntl (result, F_SETFD, flags | FD_CLOEXEC) == -1)
241 {
242 int saved_errno = errno;
243 close (result);
244 errno = saved_errno;
245 result = -1;
246 }
247 }
248 break;
249#endif /* HAVE_FCNTL */
250 } /* F_DUPFD_CLOEXEC */
251
252#if !HAVE_FCNTL
253 case F_GETFD:
254 {
255# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
256 HANDLE handle = (HANDLE) _get_osfhandle (fd);
257 DWORD flags;
258 if (handle == INVALID_HANDLE_VALUE
259 || GetHandleInformation (handle, &flags) == 0)
260 errno = EBADF;
261 else
262 result = (flags & HANDLE_FLAG_INHERIT) ? 0 : FD_CLOEXEC;
263# else /* !W32 */
264 /* Use dup2 to reject invalid file descriptors. No way to
265 access this information, so punt. */
266 if (0 <= dup2 (fd, fd))
267 result = 0;
268# endif /* !W32 */
269 break;
270 } /* F_GETFD */
271#endif /* !HAVE_FCNTL */
272
273 /* Implementing F_SETFD on mingw is not trivial - there is no
274 API for changing the O_NOINHERIT bit on an fd, and merely
275 changing the HANDLE_FLAG_INHERIT bit on the underlying handle
276 can lead to odd state. It may be possible by duplicating the
277 handle, using _open_osfhandle with the right flags, then
278 using dup2 to move the duplicate onto the original, but that
279 is not supported for now. */
280
281 default:
282 {
283#if HAVE_FCNTL
284 void *p = va_arg (arg, void *);
285 result = fcntl (fd, action, p);
286#else
287 errno = EINVAL;
288#endif
289 break;
290 }
291 }
292 va_end (arg);
293 return result;
294}
diff --git a/gl/fcntl.in.h b/gl/fcntl.in.h
deleted file mode 100644
index 8fb7852..0000000
--- a/gl/fcntl.in.h
+++ /dev/null
@@ -1,279 +0,0 @@
1/* Like <fcntl.h>, but with non-working flags defined to 0.
2
3 Copyright (C) 2006-2010 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#ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */
29# include <sys/stat.h>
30#endif
31#@INCLUDE_NEXT@ @NEXT_FCNTL_H@
32
33#else
34/* Normal invocation convention. */
35
36#ifndef _GL_FCNTL_H
37
38#include <sys/types.h>
39#ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */
40# include <sys/stat.h>
41#endif
42/* The include_next requires a split double-inclusion guard. */
43#@INCLUDE_NEXT@ @NEXT_FCNTL_H@
44
45#ifndef _GL_FCNTL_H
46#define _GL_FCNTL_H
47
48#ifndef __GLIBC__ /* Avoid namespace pollution on glibc systems. */
49# include <unistd.h>
50#endif
51
52
53/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
54
55/* The definition of _GL_ARG_NONNULL is copied here. */
56
57/* The definition of _GL_WARN_ON_USE is copied here. */
58
59
60/* Declare overridden functions. */
61
62#if @GNULIB_FCNTL@
63# if @REPLACE_FCNTL@
64# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
65# undef fcntl
66# define fcntl rpl_fcntl
67# endif
68_GL_FUNCDECL_RPL (fcntl, int, (int fd, int action, ...));
69_GL_CXXALIAS_RPL (fcntl, int, (int fd, int action, ...));
70# else
71# if !@HAVE_FCNTL@
72_GL_FUNCDECL_SYS (fcntl, int, (int fd, int action, ...));
73# endif
74_GL_CXXALIAS_SYS (fcntl, int, (int fd, int action, ...));
75# endif
76_GL_CXXALIASWARN (fcntl);
77#elif defined GNULIB_POSIXCHECK
78# undef fcntl
79# if HAVE_RAW_DECL_FCNTL
80_GL_WARN_ON_USE (fcntl, "fcntl is not always POSIX compliant - "
81 "use gnulib module fcntl for portability");
82# endif
83#endif
84
85#if @GNULIB_OPEN@
86# if @REPLACE_OPEN@
87# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
88# undef open
89# define open rpl_open
90# endif
91_GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
92 _GL_ARG_NONNULL ((1)));
93_GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
94# else
95_GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
96# endif
97_GL_CXXALIASWARN (open);
98#elif defined GNULIB_POSIXCHECK
99# undef open
100/* Assume open is always declared. */
101_GL_WARN_ON_USE (open, "open is not always POSIX compliant - "
102 "use gnulib module open for portability");
103#endif
104
105#if @GNULIB_OPENAT@
106# if @REPLACE_OPENAT@
107# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
108# undef openat
109# define openat rpl_openat
110# endif
111_GL_FUNCDECL_RPL (openat, int,
112 (int fd, char const *file, int flags, /* mode_t mode */ ...)
113 _GL_ARG_NONNULL ((2)));
114_GL_CXXALIAS_RPL (openat, int,
115 (int fd, char const *file, int flags, /* mode_t mode */ ...));
116# else
117# if !@HAVE_OPENAT@
118_GL_FUNCDECL_SYS (openat, int,
119 (int fd, char const *file, int flags, /* mode_t mode */ ...)
120 _GL_ARG_NONNULL ((2)));
121# endif
122_GL_CXXALIAS_SYS (openat, int,
123 (int fd, char const *file, int flags, /* mode_t mode */ ...));
124# endif
125_GL_CXXALIASWARN (openat);
126#elif defined GNULIB_POSIXCHECK
127# undef openat
128# if HAVE_RAW_DECL_OPENAT
129_GL_WARN_ON_USE (openat, "openat is not portable - "
130 "use gnulib module openat for portability");
131# endif
132#endif
133
134
135/* Fix up the FD_* macros, only known to be missing on mingw. */
136
137#ifndef FD_CLOEXEC
138# define FD_CLOEXEC 1
139#endif
140
141/* Fix up the supported F_* macros. Intentionally leave other F_*
142 macros undefined. Only known to be missing on mingw. */
143
144#ifndef F_DUPFD_CLOEXEC
145# define F_DUPFD_CLOEXEC 0x40000000
146/* Witness variable: 1 if gnulib defined F_DUPFD_CLOEXEC, 0 otherwise. */
147# define GNULIB_defined_F_DUPFD_CLOEXEC 1
148#else
149# define GNULIB_defined_F_DUPFD_CLOEXEC 0
150#endif
151
152#ifndef F_DUPFD
153# define F_DUPFD 1
154#endif
155
156#ifndef F_GETFD
157# define F_GETFD 2
158#endif
159
160/* Fix up the O_* macros. */
161
162#if !defined O_DIRECT && defined O_DIRECTIO
163/* Tru64 spells it `O_DIRECTIO'. */
164# define O_DIRECT O_DIRECTIO
165#endif
166
167#if !defined O_CLOEXEC && defined O_NOINHERIT
168/* Mingw spells it `O_NOINHERIT'. Intentionally leave it
169 undefined if not available. */
170# define O_CLOEXEC O_NOINHERIT
171#endif
172
173#ifndef O_DIRECT
174# define O_DIRECT 0
175#endif
176
177#ifndef O_DIRECTORY
178# define O_DIRECTORY 0
179#endif
180
181#ifndef O_DSYNC
182# define O_DSYNC 0
183#endif
184
185#ifndef O_NDELAY
186# define O_NDELAY 0
187#endif
188
189#ifndef O_NOATIME
190# define O_NOATIME 0
191#endif
192
193#ifndef O_NONBLOCK
194# define O_NONBLOCK O_NDELAY
195#endif
196
197#ifndef O_NOCTTY
198# define O_NOCTTY 0
199#endif
200
201#ifndef O_NOFOLLOW
202# define O_NOFOLLOW 0
203#endif
204
205#ifndef O_NOLINKS
206# define O_NOLINKS 0
207#endif
208
209#ifndef O_RSYNC
210# define O_RSYNC 0
211#endif
212
213#ifndef O_SYNC
214# define O_SYNC 0
215#endif
216
217#ifndef O_TTY_INIT
218# define O_TTY_INIT 0
219#endif
220
221/* For systems that distinguish between text and binary I/O.
222 O_BINARY is usually declared in fcntl.h */
223#if !defined O_BINARY && defined _O_BINARY
224 /* For MSC-compatible compilers. */
225# define O_BINARY _O_BINARY
226# define O_TEXT _O_TEXT
227#endif
228
229#if defined __BEOS__ || defined __HAIKU__
230 /* BeOS 5 and Haiku have O_BINARY and O_TEXT, but they have no effect. */
231# undef O_BINARY
232# undef O_TEXT
233#endif
234
235#ifndef O_BINARY
236# define O_BINARY 0
237# define O_TEXT 0
238#endif
239
240/* Fix up the AT_* macros. */
241
242/* Work around a bug in Solaris 9 and 10: AT_FDCWD is positive. Its
243 value exceeds INT_MAX, so its use as an int doesn't conform to the
244 C standard, and GCC and Sun C complain in some cases. If the bug
245 is present, undef AT_FDCWD here, so it can be redefined below. */
246#if 0 < AT_FDCWD && AT_FDCWD == 0xffd19553
247# undef AT_FDCWD
248#endif
249
250/* Use the same bit pattern as Solaris 9, but with the proper
251 signedness. The bit pattern is important, in case this actually is
252 Solaris with the above workaround. */
253#ifndef AT_FDCWD
254# define AT_FDCWD (-3041965)
255#endif
256
257/* Use the same values as Solaris 9. This shouldn't matter, but
258 there's no real reason to differ. */
259#ifndef AT_SYMLINK_NOFOLLOW
260# define AT_SYMLINK_NOFOLLOW 4096
261#endif
262
263#ifndef AT_REMOVEDIR
264# define AT_REMOVEDIR 1
265#endif
266
267/* Solaris 9 lacks these two, so just pick unique values. */
268#ifndef AT_SYMLINK_FOLLOW
269# define AT_SYMLINK_FOLLOW 2
270#endif
271
272#ifndef AT_EACCESS
273# define AT_EACCESS 4
274#endif
275
276
277#endif /* _GL_FCNTL_H */
278#endif /* _GL_FCNTL_H */
279#endif
diff --git a/gl/fd-hook.c b/gl/fd-hook.c
new file mode 100644
index 0000000..e158a52
--- /dev/null
+++ b/gl/fd-hook.c
@@ -0,0 +1,116 @@
1/* Hook for making making file descriptor functions close(), ioctl() extensible.
2 Copyright (C) 2009-2013 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2009.
4
5 This program is free software: you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published
7 by 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 GNU
13 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 "fd-hook.h"
22
23#include <stdlib.h>
24
25/* Currently, this entire code is only needed for the handling of sockets
26 on native Windows platforms. */
27#if WINDOWS_SOCKETS
28
29/* The first and last link in the doubly linked list.
30 Initially the list is empty. */
31static struct fd_hook anchor = { &anchor, &anchor, NULL, NULL };
32
33int
34execute_close_hooks (const struct fd_hook *remaining_list, gl_close_fn primary,
35 int fd)
36{
37 if (remaining_list == &anchor)
38 /* End of list reached. */
39 return primary (fd);
40 else
41 return remaining_list->private_close_fn (remaining_list->private_next,
42 primary, fd);
43}
44
45int
46execute_all_close_hooks (gl_close_fn primary, int fd)
47{
48 return execute_close_hooks (anchor.private_next, primary, fd);
49}
50
51int
52execute_ioctl_hooks (const struct fd_hook *remaining_list, gl_ioctl_fn primary,
53 int fd, int request, void *arg)
54{
55 if (remaining_list == &anchor)
56 /* End of list reached. */
57 return primary (fd, request, arg);
58 else
59 return remaining_list->private_ioctl_fn (remaining_list->private_next,
60 primary, fd, request, arg);
61}
62
63int
64execute_all_ioctl_hooks (gl_ioctl_fn primary,
65 int fd, int request, void *arg)
66{
67 return execute_ioctl_hooks (anchor.private_next, primary, fd, request, arg);
68}
69
70void
71register_fd_hook (close_hook_fn close_hook, ioctl_hook_fn ioctl_hook, struct fd_hook *link)
72{
73 if (close_hook == NULL)
74 close_hook = execute_close_hooks;
75 if (ioctl_hook == NULL)
76 ioctl_hook = execute_ioctl_hooks;
77
78 if (link->private_next == NULL && link->private_prev == NULL)
79 {
80 /* Add the link to the doubly linked list. */
81 link->private_next = anchor.private_next;
82 link->private_prev = &anchor;
83 link->private_close_fn = close_hook;
84 link->private_ioctl_fn = ioctl_hook;
85 anchor.private_next->private_prev = link;
86 anchor.private_next = link;
87 }
88 else
89 {
90 /* The link is already in use. */
91 if (link->private_close_fn != close_hook
92 || link->private_ioctl_fn != ioctl_hook)
93 abort ();
94 }
95}
96
97void
98unregister_fd_hook (struct fd_hook *link)
99{
100 struct fd_hook *next = link->private_next;
101 struct fd_hook *prev = link->private_prev;
102
103 if (next != NULL && prev != NULL)
104 {
105 /* The link is in use. Remove it from the doubly linked list. */
106 prev->private_next = next;
107 next->private_prev = prev;
108 /* Clear the link, to mark it unused. */
109 link->private_next = NULL;
110 link->private_prev = NULL;
111 link->private_close_fn = NULL;
112 link->private_ioctl_fn = NULL;
113 }
114}
115
116#endif
diff --git a/gl/fd-hook.h b/gl/fd-hook.h
new file mode 100644
index 0000000..d15b577
--- /dev/null
+++ b/gl/fd-hook.h
@@ -0,0 +1,119 @@
1/* Hook for making making file descriptor functions close(), ioctl() extensible.
2 Copyright (C) 2009-2013 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 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
18#ifndef FD_HOOK_H
19#define FD_HOOK_H
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25
26/* Currently, this entire code is only needed for the handling of sockets
27 on native Windows platforms. */
28#if WINDOWS_SOCKETS
29
30
31/* Type of function that closes FD. */
32typedef int (*gl_close_fn) (int fd);
33
34/* Type of function that applies a control request to FD. */
35typedef int (*gl_ioctl_fn) (int fd, int request, void *arg);
36
37/* An element of the list of file descriptor hooks.
38 In CLOS (Common Lisp Object System) speak, it consists of an "around"
39 method for the close() function and an "around" method for the ioctl()
40 function.
41 The fields of this structure are considered private. */
42struct fd_hook
43{
44 /* Doubly linked list. */
45 struct fd_hook *private_next;
46 struct fd_hook *private_prev;
47 /* Function that treats the types of FD that it knows about and calls
48 execute_close_hooks (REMAINING_LIST, PRIMARY, FD) as a fallback. */
49 int (*private_close_fn) (const struct fd_hook *remaining_list,
50 gl_close_fn primary,
51 int fd);
52 /* Function that treats the types of FD that it knows about and calls
53 execute_ioctl_hooks (REMAINING_LIST, PRIMARY, FD, REQUEST, ARG) as a
54 fallback. */
55 int (*private_ioctl_fn) (const struct fd_hook *remaining_list,
56 gl_ioctl_fn primary,
57 int fd, int request, void *arg);
58};
59
60/* This type of function closes FD, applying special knowledge for the FD
61 types it knows about, and calls
62 execute_close_hooks (REMAINING_LIST, PRIMARY, FD)
63 for the other FD types.
64 In CLOS speak, REMAINING_LIST is the remaining list of "around" methods,
65 and PRIMARY is the "primary" method for close(). */
66typedef int (*close_hook_fn) (const struct fd_hook *remaining_list,
67 gl_close_fn primary,
68 int fd);
69
70/* Execute the close hooks in REMAINING_LIST, with PRIMARY as "primary" method.
71 Return 0 or -1, like close() would do. */
72extern int execute_close_hooks (const struct fd_hook *remaining_list,
73 gl_close_fn primary,
74 int fd);
75
76/* Execute all close hooks, with PRIMARY as "primary" method.
77 Return 0 or -1, like close() would do. */
78extern int execute_all_close_hooks (gl_close_fn primary, int fd);
79
80/* This type of function applies a control request to FD, applying special
81 knowledge for the FD types it knows about, and calls
82 execute_ioctl_hooks (REMAINING_LIST, PRIMARY, FD, REQUEST, ARG)
83 for the other FD types.
84 In CLOS speak, REMAINING_LIST is the remaining list of "around" methods,
85 and PRIMARY is the "primary" method for ioctl(). */
86typedef int (*ioctl_hook_fn) (const struct fd_hook *remaining_list,
87 gl_ioctl_fn primary,
88 int fd, int request, void *arg);
89
90/* Execute the ioctl hooks in REMAINING_LIST, with PRIMARY as "primary" method.
91 Return 0 or -1, like ioctl() would do. */
92extern int execute_ioctl_hooks (const struct fd_hook *remaining_list,
93 gl_ioctl_fn primary,
94 int fd, int request, void *arg);
95
96/* Execute all ioctl hooks, with PRIMARY as "primary" method.
97 Return 0 or -1, like ioctl() would do. */
98extern int execute_all_ioctl_hooks (gl_ioctl_fn primary,
99 int fd, int request, void *arg);
100
101/* Add a function pair to the list of file descriptor hooks.
102 CLOSE_HOOK and IOCTL_HOOK may be NULL, indicating no change.
103 The LINK variable points to a piece of memory which is guaranteed to be
104 accessible until the corresponding call to unregister_fd_hook. */
105extern void register_fd_hook (close_hook_fn close_hook, ioctl_hook_fn ioctl_hook,
106 struct fd_hook *link);
107
108/* Removes a hook from the list of file descriptor hooks. */
109extern void unregister_fd_hook (struct fd_hook *link);
110
111
112#endif
113
114
115#ifdef __cplusplus
116}
117#endif
118
119#endif /* FD_HOOK_H */
diff --git a/gl/fd-safer.c b/gl/fd-safer.c
deleted file mode 100644
index c1c6000..0000000
--- a/gl/fd-safer.c
+++ /dev/null
@@ -1,49 +0,0 @@
1/* Return a safer copy of a file descriptor.
2
3 Copyright (C) 2005-2006, 2009-2010 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#include <config.h>
21
22#include "unistd-safer.h"
23
24#include <errno.h>
25#include <unistd.h>
26
27/* Return FD, unless FD would be a copy of standard input, output, or
28 error; in that case, return a duplicate of FD, closing FD. On
29 failure to duplicate, close FD, set errno, and return -1. Preserve
30 errno if FD is negative, so that the caller can always inspect
31 errno when the returned value is negative.
32
33 This function is usefully wrapped around functions that return file
34 descriptors, e.g., fd_safer (open ("file", O_RDONLY)). */
35
36int
37fd_safer (int fd)
38{
39 if (STDIN_FILENO <= fd && fd <= STDERR_FILENO)
40 {
41 int f = dup_safer (fd);
42 int e = errno;
43 close (fd);
44 errno = e;
45 fd = f;
46 }
47
48 return fd;
49}
diff --git a/gl/float+.h b/gl/float+.h
index b55e5e6..32fb790 100644
--- a/gl/float+.h
+++ b/gl/float+.h
@@ -1,5 +1,5 @@
1/* Supplemental information about the floating-point formats. 1/* Supplemental information about the floating-point formats.
2 Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. 2 Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2007. 3 Written by Bruno Haible <bruno@clisp.org>, 2007.
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
@@ -13,8 +13,7 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
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, write to the Free Software Foundation, 16 along with this program; if not, see <http://www.gnu.org/licenses/>. */
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 17
19#ifndef _FLOATPLUS_H 18#ifndef _FLOATPLUS_H
20#define _FLOATPLUS_H 19#define _FLOATPLUS_H
@@ -141,8 +140,8 @@
141#define SIZEOF_LDBL ((LDBL_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT) 140#define SIZEOF_LDBL ((LDBL_TOTAL_BIT + CHAR_BIT - 1) / CHAR_BIT)
142 141
143/* Verify that SIZEOF_FLT <= sizeof (float) etc. */ 142/* Verify that SIZEOF_FLT <= sizeof (float) etc. */
144typedef int verify_sizeof_flt[2 * (SIZEOF_FLT <= sizeof (float)) - 1]; 143typedef int verify_sizeof_flt[SIZEOF_FLT <= sizeof (float) ? 1 : -1];
145typedef int verify_sizeof_dbl[2 * (SIZEOF_DBL <= sizeof (double)) - 1]; 144typedef int verify_sizeof_dbl[SIZEOF_DBL <= sizeof (double) ? 1 : - 1];
146typedef int verify_sizeof_ldbl[2 * (SIZEOF_LDBL <= sizeof (long double)) - 1]; 145typedef int verify_sizeof_ldbl[SIZEOF_LDBL <= sizeof (long double) ? 1 : - 1];
147 146
148#endif /* _FLOATPLUS_H */ 147#endif /* _FLOATPLUS_H */
diff --git a/gl/float.c b/gl/float.c
new file mode 100644
index 0000000..366945f
--- /dev/null
+++ b/gl/float.c
@@ -0,0 +1,33 @@
1/* Auxiliary definitions for <float.h>.
2 Copyright (C) 2011-2013 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2011.
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 <float.h>
22
23#if (defined _ARCH_PPC || defined _POWER) && (defined _AIX || defined __linux__) && (LDBL_MANT_DIG == 106) && defined __GNUC__
24const union gl_long_double_union gl_LDBL_MAX =
25 { { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL } };
26#elif defined __i386__
27const union gl_long_double_union gl_LDBL_MAX =
28 { { 0xFFFFFFFF, 0xFFFFFFFF, 32766 } };
29#else
30/* This declaration is solely to ensure that after preprocessing
31 this file is never empty. */
32typedef int dummy;
33#endif
diff --git a/gl/float.in.h b/gl/float.in.h
index caf822f..84e1950 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-2010 Free Software Foundation, Inc. 3 Copyright (C) 2007-2013 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,19 +15,21 @@
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#ifndef _GL_FLOAT_H 18#ifndef _@GUARD_PREFIX@_FLOAT_H
19 19
20#if __GNUC__ >= 3 20#if __GNUC__ >= 3
21@PRAGMA_SYSTEM_HEADER@ 21@PRAGMA_SYSTEM_HEADER@
22#endif 22#endif
23@PRAGMA_COLUMNS@
23 24
24/* The include_next requires a split double-inclusion guard. */ 25/* The include_next requires a split double-inclusion guard. */
25#@INCLUDE_NEXT@ @NEXT_FLOAT_H@ 26#@INCLUDE_NEXT@ @NEXT_FLOAT_H@
26 27
27#ifndef _GL_FLOAT_H 28#ifndef _@GUARD_PREFIX@_FLOAT_H
28#define _GL_FLOAT_H 29#define _@GUARD_PREFIX@_FLOAT_H
29 30
30/* 'long double' properties. */ 31/* 'long double' properties. */
32
31#if defined __i386__ && (defined __BEOS__ || defined __OpenBSD__) 33#if defined __i386__ && (defined __BEOS__ || defined __OpenBSD__)
32/* Number of mantissa units, in base FLT_RADIX. */ 34/* Number of mantissa units, in base FLT_RADIX. */
33# undef LDBL_MANT_DIG 35# undef LDBL_MANT_DIG
@@ -58,5 +60,129 @@
58# define LDBL_MAX_10_EXP 4932 60# define LDBL_MAX_10_EXP 4932
59#endif 61#endif
60 62
61#endif /* _GL_FLOAT_H */ 63/* On FreeBSD/x86 6.4, the 'long double' type really has only 53 bits of
62#endif /* _GL_FLOAT_H */ 64 precision in the compiler but 64 bits of precision at runtime. See
65 <http://lists.gnu.org/archive/html/bug-gnulib/2008-07/msg00063.html>. */
66#if defined __i386__ && defined __FreeBSD__
67/* Number of mantissa units, in base FLT_RADIX. */
68# undef LDBL_MANT_DIG
69# define LDBL_MANT_DIG 64
70/* Number of decimal digits that is sufficient for representing a number. */
71# undef LDBL_DIG
72# define LDBL_DIG 18
73/* x-1 where x is the smallest representable number > 1. */
74# undef LDBL_EPSILON
75# define LDBL_EPSILON 1.084202172485504434007452800869941711426e-19L /* 2^-63 */
76/* Minimum e such that FLT_RADIX^(e-1) is a normalized number. */
77# undef LDBL_MIN_EXP
78# define LDBL_MIN_EXP (-16381)
79/* Maximum e such that FLT_RADIX^(e-1) is a representable finite number. */
80# undef LDBL_MAX_EXP
81# define LDBL_MAX_EXP 16384
82/* Minimum positive normalized number. */
83# undef LDBL_MIN
84# define LDBL_MIN 3.3621031431120935E-4932L /* = 0x1p-16382L */
85/* Maximum representable finite number. */
86# undef LDBL_MAX
87/* LDBL_MAX is represented as { 0xFFFFFFFF, 0xFFFFFFFF, 32766 }.
88 But the largest literal that GCC allows us to write is
89 0x0.fffffffffffff8p16384L = { 0xFFFFF800, 0xFFFFFFFF, 32766 }.
90 So, define it like this through a reference to an external variable
91
92 const unsigned int LDBL_MAX[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 32766 };
93 extern const long double LDBL_MAX;
94
95 Unfortunately, this is not a constant expression. */
96union gl_long_double_union
97 {
98 struct { unsigned int lo; unsigned int hi; unsigned int exponent; } xd;
99 long double ld;
100 };
101extern const union gl_long_double_union gl_LDBL_MAX;
102# define LDBL_MAX (gl_LDBL_MAX.ld)
103/* Minimum e such that 10^e is in the range of normalized numbers. */
104# undef LDBL_MIN_10_EXP
105# define LDBL_MIN_10_EXP (-4931)
106/* Maximum e such that 10^e is in the range of representable finite numbers. */
107# undef LDBL_MAX_10_EXP
108# define LDBL_MAX_10_EXP 4932
109#endif
110
111/* On AIX 7.1 with gcc 4.2, the values of LDBL_MIN_EXP, LDBL_MIN, LDBL_MAX are
112 wrong.
113 On Linux/PowerPC with gcc 4.4, the value of LDBL_MAX is wrong. */
114#if (defined _ARCH_PPC || defined _POWER) && defined _AIX && (LDBL_MANT_DIG == 106) && defined __GNUC__
115# undef LDBL_MIN_EXP
116# define LDBL_MIN_EXP DBL_MIN_EXP
117# undef LDBL_MIN_10_EXP
118# define LDBL_MIN_10_EXP DBL_MIN_10_EXP
119# undef LDBL_MIN
120# define LDBL_MIN 2.22507385850720138309023271733240406422e-308L /* DBL_MIN = 2^-1022 */
121#endif
122#if (defined _ARCH_PPC || defined _POWER) && (defined _AIX || defined __linux__) && (LDBL_MANT_DIG == 106) && defined __GNUC__
123# undef LDBL_MAX
124/* LDBL_MAX is represented as { 0x7FEFFFFF, 0xFFFFFFFF, 0x7C8FFFFF, 0xFFFFFFFF }.
125 It is not easy to define:
126 #define LDBL_MAX 1.79769313486231580793728971405302307166e308L
127 is too small, whereas
128 #define LDBL_MAX 1.79769313486231580793728971405302307167e308L
129 is too large. Apparently a bug in GCC decimal-to-binary conversion.
130 Also, I can't get values larger than
131 #define LDBL63 ((long double) (1ULL << 63))
132 #define LDBL882 (LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63)
133 #define LDBL945 (LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63)
134 #define LDBL1008 (LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63 * LDBL63)
135 #define LDBL_MAX (LDBL1008 * 65535.0L + LDBL945 * (long double) 9223372036821221375ULL + LDBL882 * (long double) 4611686018427387904ULL)
136 which is represented as { 0x7FEFFFFF, 0xFFFFFFFF, 0x7C8FFFFF, 0xF8000000 }.
137 So, define it like this through a reference to an external variable
138
139 const double LDBL_MAX[2] = { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL };
140 extern const long double LDBL_MAX;
141
142 or through a pointer cast
143
144 #define LDBL_MAX \
145 (*(const long double *) (double[]) { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL })
146
147 Unfortunately, this is not a constant expression, and the latter expression
148 does not work well when GCC is optimizing.. */
149union gl_long_double_union
150 {
151 struct { double hi; double lo; } dd;
152 long double ld;
153 };
154extern const union gl_long_double_union gl_LDBL_MAX;
155# define LDBL_MAX (gl_LDBL_MAX.ld)
156#endif
157
158/* On IRIX 6.5, with cc, the value of LDBL_MANT_DIG is wrong.
159 On IRIX 6.5, with gcc 4.2, the values of LDBL_MIN_EXP, LDBL_MIN, LDBL_EPSILON
160 are wrong. */
161#if defined __sgi && (LDBL_MANT_DIG >= 106)
162# undef LDBL_MANT_DIG
163# define LDBL_MANT_DIG 106
164# if defined __GNUC__
165# undef LDBL_MIN_EXP
166# define LDBL_MIN_EXP DBL_MIN_EXP
167# undef LDBL_MIN_10_EXP
168# define LDBL_MIN_10_EXP DBL_MIN_10_EXP
169# undef LDBL_MIN
170# define LDBL_MIN 2.22507385850720138309023271733240406422e-308L /* DBL_MIN = 2^-1022 */
171# undef LDBL_EPSILON
172# define LDBL_EPSILON 2.46519032881566189191165176650870696773e-32L /* 2^-105 */
173# endif
174#endif
175
176#if @REPLACE_ITOLD@
177/* Pull in a function that fixes the 'int' to 'long double' conversion
178 of glibc 2.7. */
179extern
180# ifdef __cplusplus
181"C"
182# endif
183void _Qp_itoq (long double *, int);
184static void (*_gl_float_fix_itold) (long double *, int) = _Qp_itoq;
185#endif
186
187#endif /* _@GUARD_PREFIX@_FLOAT_H */
188#endif /* _@GUARD_PREFIX@_FLOAT_H */
diff --git a/gl/floor.c b/gl/floor.c
index 593b526..cf29b19 100644
--- a/gl/floor.c
+++ b/gl/floor.c
@@ -1,5 +1,5 @@
1/* Round towards negative infinity. 1/* Round towards negative infinity.
2 Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. 2 Copyright (C) 2007, 2010-2013 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
@@ -16,7 +16,9 @@
16 16
17/* Written by Bruno Haible <bruno@clisp.org>, 2007. */ 17/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
18 18
19#include <config.h> 19#if ! defined USE_LONG_DOUBLE
20# include <config.h>
21#endif
20 22
21/* Specification. */ 23/* Specification. */
22#include <math.h> 24#include <math.h>
@@ -40,6 +42,12 @@
40# define L_(literal) literal##f 42# define L_(literal) literal##f
41#endif 43#endif
42 44
45/* MSVC with option -fp:strict refuses to compile constant initializers that
46 contain floating-point operations. Pacify this compiler. */
47#ifdef _MSC_VER
48# pragma fenv_access (off)
49#endif
50
43/* 2^(MANT_DIG-1). */ 51/* 2^(MANT_DIG-1). */
44static const DOUBLE TWO_MANT_DIG = 52static const DOUBLE TWO_MANT_DIG =
45 /* Assume MANT_DIG <= 5 * 31. 53 /* Assume MANT_DIG <= 5 * 31.
@@ -65,8 +73,12 @@ FUNC (DOUBLE x)
65 73
66 if (z > L_(0.0)) 74 if (z > L_(0.0))
67 { 75 {
76 /* For 0 < x < 1, return +0.0 even if the current rounding mode is
77 FE_DOWNWARD. */
78 if (z < L_(1.0))
79 z = L_(0.0);
68 /* Avoid rounding errors for values near 2^k, where k >= MANT_DIG-1. */ 80 /* Avoid rounding errors for values near 2^k, where k >= MANT_DIG-1. */
69 if (z < TWO_MANT_DIG) 81 else if (z < TWO_MANT_DIG)
70 { 82 {
71 /* Round to the next integer (nearest or up or down, doesn't matter). */ 83 /* Round to the next integer (nearest or up or down, doesn't matter). */
72 z += TWO_MANT_DIG; 84 z += TWO_MANT_DIG;
diff --git a/gl/floorf.c b/gl/floorf.c
index eae5793..bbd3382 100644
--- a/gl/floorf.c
+++ b/gl/floorf.c
@@ -1,5 +1,5 @@
1/* Round towards negative infinity. 1/* Round towards negative infinity.
2 Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. 2 Copyright (C) 2007, 2009-2013 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
diff --git a/gl/fsusage.c b/gl/fsusage.c
index 17102aa..0657555 100644
--- a/gl/fsusage.c
+++ b/gl/fsusage.c
@@ -1,6 +1,6 @@
1/* fsusage.c -- return space usage of mounted file systems 1/* fsusage.c -- return space usage of mounted file systems
2 2
3 Copyright (C) 1991-1992, 1996, 1998-1999, 2002-2006, 2009-2010 Free Software 3 Copyright (C) 1991-1992, 1996, 1998-1999, 2002-2006, 2009-2013 Free Software
4 Foundation, Inc. 4 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
@@ -23,7 +23,7 @@
23#include <limits.h> 23#include <limits.h>
24#include <sys/types.h> 24#include <sys/types.h>
25 25
26#if STAT_STATVFS /* POSIX 1003.1-2001 (and later) with XSI */ 26#if STAT_STATVFS || STAT_STATVFS64 /* POSIX 1003.1-2001 (and later) with XSI */
27# include <sys/statvfs.h> 27# include <sys/statvfs.h>
28#else 28#else
29/* Don't include backward-compatibility files unless they're needed. 29/* Don't include backward-compatibility files unless they're needed.
@@ -31,15 +31,15 @@
31# include <fcntl.h> 31# include <fcntl.h>
32# include <unistd.h> 32# include <unistd.h>
33# include <sys/stat.h> 33# include <sys/stat.h>
34# if HAVE_SYS_PARAM_H 34#if HAVE_SYS_PARAM_H
35# include <sys/param.h> 35# include <sys/param.h>
36# endif 36#endif
37# if HAVE_SYS_MOUNT_H 37#if HAVE_SYS_MOUNT_H
38# include <sys/mount.h> 38# include <sys/mount.h>
39# endif 39#endif
40# if HAVE_SYS_VFS_H 40#if HAVE_SYS_VFS_H
41# include <sys/vfs.h> 41# include <sys/vfs.h>
42# endif 42#endif
43# if HAVE_SYS_FS_S5PARAM_H /* Fujitsu UXP/V */ 43# if HAVE_SYS_FS_S5PARAM_H /* Fujitsu UXP/V */
44# include <sys/fs/s5param.h> 44# include <sys/fs/s5param.h>
45# endif 45# endif
@@ -84,6 +84,35 @@
84 otherwise, use PROPAGATE_ALL_ONES. */ 84 otherwise, use PROPAGATE_ALL_ONES. */
85#define PROPAGATE_TOP_BIT(x) ((x) | ~ (EXTRACT_TOP_BIT (x) - 1)) 85#define PROPAGATE_TOP_BIT(x) ((x) | ~ (EXTRACT_TOP_BIT (x) - 1))
86 86
87#ifdef STAT_STATVFS
88/* Return true if statvfs works. This is false for statvfs on systems
89 with GNU libc on Linux kernels before 2.6.36, which stats all
90 preceding entries in /proc/mounts; that makes df hang if even one
91 of the corresponding file systems is hard-mounted but not available. */
92# if ! (__linux__ && (__GLIBC__ || __UCLIBC__))
93/* The FRSIZE fallback is not required in this case. */
94# undef STAT_STATFS2_FRSIZE
95static int statvfs_works (void) { return 1; }
96# else
97# include <string.h> /* for strverscmp */
98# include <sys/utsname.h>
99# include <sys/statfs.h>
100# define STAT_STATFS2_BSIZE 1
101
102static int
103statvfs_works (void)
104{
105 static int statvfs_works_cache = -1;
106 struct utsname name;
107 if (statvfs_works_cache < 0)
108 statvfs_works_cache = (uname (&name) == 0
109 && 0 <= strverscmp (name.release, "2.6.36"));
110 return statvfs_works_cache;
111}
112# endif
113#endif
114
115
87/* Fill in the fields of FSP with information about space usage for 116/* Fill in the fields of FSP with information about space usage for
88 the file system on which FILE resides. 117 the file system on which FILE resides.
89 DISK is the device on which FILE is mounted, for space-getting 118 DISK is the device on which FILE is mounted, for space-getting
@@ -94,11 +123,36 @@
94int 123int
95get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp) 124get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
96{ 125{
97#if defined STAT_STATVFS /* POSIX, except glibc/Linux */ 126#ifdef STAT_STATVFS /* POSIX, except pre-2.6.36 glibc/Linux */
127
128 if (statvfs_works ())
129 {
130 struct statvfs vfsd;
131
132 if (statvfs (file, &vfsd) < 0)
133 return -1;
134
135 /* f_frsize isn't guaranteed to be supported. */
136 fsp->fsu_blocksize = (vfsd.f_frsize
137 ? PROPAGATE_ALL_ONES (vfsd.f_frsize)
138 : PROPAGATE_ALL_ONES (vfsd.f_bsize));
139
140 fsp->fsu_blocks = PROPAGATE_ALL_ONES (vfsd.f_blocks);
141 fsp->fsu_bfree = PROPAGATE_ALL_ONES (vfsd.f_bfree);
142 fsp->fsu_bavail = PROPAGATE_TOP_BIT (vfsd.f_bavail);
143 fsp->fsu_bavail_top_bit_set = EXTRACT_TOP_BIT (vfsd.f_bavail) != 0;
144 fsp->fsu_files = PROPAGATE_ALL_ONES (vfsd.f_files);
145 fsp->fsu_ffree = PROPAGATE_ALL_ONES (vfsd.f_ffree);
146 return 0;
147 }
148
149#endif
150
151#if defined STAT_STATVFS64 /* AIX */
98 152
99 struct statvfs fsd; 153 struct statvfs64 fsd;
100 154
101 if (statvfs (file, &fsd) < 0) 155 if (statvfs64 (file, &fsd) < 0)
102 return -1; 156 return -1;
103 157
104 /* f_frsize isn't guaranteed to be supported. */ 158 /* f_frsize isn't guaranteed to be supported. */
@@ -165,8 +219,17 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
165 219
166 fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize); 220 fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize);
167 221
168#elif defined STAT_STATFS2_BSIZE /* glibc/Linux, 4.3BSD, SunOS 4, \ 222#elif defined STAT_STATFS2_FRSIZE /* 2.6 < glibc/Linux < 2.6.36 */
169 MacOS X < 10.4, FreeBSD < 5.0, \ 223
224 struct statfs fsd;
225
226 if (statfs (file, &fsd) < 0)
227 return -1;
228
229 fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_frsize);
230
231#elif defined STAT_STATFS2_BSIZE /* glibc/Linux < 2.6, 4.3BSD, SunOS 4, \
232 Mac OS X < 10.4, FreeBSD < 5.0, \
170 NetBSD < 3.0, OpenBSD < 4.4 */ 233 NetBSD < 3.0, OpenBSD < 4.4 */
171 234
172 struct statfs fsd; 235 struct statfs fsd;
@@ -223,8 +286,9 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
223 286
224#endif 287#endif
225 288
226#if (defined STAT_STATVFS \ 289#if (defined STAT_STATVFS64 || defined STAT_STATFS3_OSF1 \
227 || (!defined STAT_STATFS2_FS_DATA && !defined STAT_READ_FILSYS)) 290 || defined STAT_STATFS2_FRSIZE || defined STAT_STATFS2_BSIZE \
291 || defined STAT_STATFS2_FSIZE || defined STAT_STATFS4)
228 292
229 fsp->fsu_blocks = PROPAGATE_ALL_ONES (fsd.f_blocks); 293 fsp->fsu_blocks = PROPAGATE_ALL_ONES (fsd.f_blocks);
230 fsp->fsu_bfree = PROPAGATE_ALL_ONES (fsd.f_bfree); 294 fsp->fsu_bfree = PROPAGATE_ALL_ONES (fsd.f_bfree);
diff --git a/gl/fsusage.h b/gl/fsusage.h
index bb2d86f..7810fc0 100644
--- a/gl/fsusage.h
+++ b/gl/fsusage.h
@@ -1,6 +1,6 @@
1/* fsusage.h -- declarations for file system space usage info 1/* fsusage.h -- declarations for file system space usage info
2 2
3 Copyright (C) 1991-1992, 1997, 2003-2006, 2009-2010 Free Software 3 Copyright (C) 1991-1992, 1997, 2003-2006, 2009-2013 Free Software
4 Foundation, Inc. 4 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
diff --git a/gl/full-read.c b/gl/full-read.c
index e5de376..a0dc82c 100644
--- a/gl/full-read.c
+++ b/gl/full-read.c
@@ -1,5 +1,5 @@
1/* An interface to read that retries after partial reads and interrupts. 1/* An interface to read that retries after partial reads and interrupts.
2 Copyright (C) 2002-2003, 2009-2010 Free Software Foundation, Inc. 2 Copyright (C) 2002-2003, 2009-2013 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
diff --git a/gl/full-read.h b/gl/full-read.h
index a41f617..66c8c5c 100644
--- a/gl/full-read.h
+++ b/gl/full-read.h
@@ -1,6 +1,6 @@
1/* An interface to read() that reads all it is asked to read. 1/* An interface to read() that reads all it is asked to read.
2 2
3 Copyright (C) 2002, 2009-2010 Free Software Foundation, Inc. 3 Copyright (C) 2002, 2009-2013 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
diff --git a/gl/full-write.c b/gl/full-write.c
index 5d9b7c3..beb5bf9 100644
--- a/gl/full-write.c
+++ b/gl/full-write.c
@@ -1,6 +1,6 @@
1/* An interface to read and write that retries (if necessary) until complete. 1/* An interface to read and write that retries (if necessary) until complete.
2 2
3 Copyright (C) 1993-1994, 1997-2006, 2009-2010 Free Software Foundation, Inc. 3 Copyright (C) 1993-1994, 1997-2006, 2009-2013 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
diff --git a/gl/full-write.h b/gl/full-write.h
deleted file mode 100644
index 15d6180..0000000
--- a/gl/full-write.h
+++ /dev/null
@@ -1,34 +0,0 @@
1/* An interface to write() that writes all it is asked to write.
2
3 Copyright (C) 2002-2003, 2009-2010 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#include <stddef.h>
19
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25
26/* Write COUNT bytes at BUF to descriptor FD, retrying if interrupted
27 or if partial writes occur. Return the number of bytes successfully
28 written, setting errno if that is less than COUNT. */
29extern size_t full_write (int fd, const void *buf, size_t count);
30
31
32#ifdef __cplusplus
33}
34#endif
diff --git a/gl/gai_strerror.c b/gl/gai_strerror.c
index c05b5c4..1e371d2 100644
--- a/gl/gai_strerror.c
+++ b/gl/gai_strerror.c
@@ -1,5 +1,5 @@
1/* Copyright (C) 1997, 2001, 2002, 2004, 2005, 2006, 2008, 2009, 2010 Free 1/* Copyright (C) 1997, 2001-2002, 2004-2006, 2008-2013 Free Software
2 Software Foundation, Inc. 2 Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 Contributed by Philip Blundell <pjb27@cam.ac.uk>, 1997. 4 Contributed by Philip Blundell <pjb27@cam.ac.uk>, 1997.
5 5
@@ -14,8 +14,7 @@
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 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, 17 along with this program; if not, see <http://www.gnu.org/licenses/>. */
18 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
19 18
20#ifndef _LIBC 19#ifndef _LIBC
21# include <config.h> 20# include <config.h>
@@ -32,6 +31,22 @@
32# define N_(String) String 31# define N_(String) String
33#endif 32#endif
34 33
34#if HAVE_DECL_GAI_STRERROR
35
36# include <sys/socket.h>
37# undef gai_strerror
38# if HAVE_DECL_GAI_STRERRORA
39# define gai_strerror gai_strerrorA
40# endif
41
42const char *
43rpl_gai_strerror (int code)
44{
45 return gai_strerror (code);
46}
47
48#else /* !HAVE_DECL_GAI_STRERROR */
49
35static struct 50static struct
36 { 51 {
37 int code; 52 int code;
@@ -71,6 +86,7 @@ gai_strerror (int code)
71 86
72 return _("Unknown error"); 87 return _("Unknown error");
73} 88}
74#ifdef _LIBC 89# ifdef _LIBC
75libc_hidden_def (gai_strerror) 90libc_hidden_def (gai_strerror)
76#endif 91# endif
92#endif /* !HAVE_DECL_GAI_STRERROR */
diff --git a/gl/getaddrinfo.c b/gl/getaddrinfo.c
index 6aa676c..58d2811 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-2010 Free Software Foundation, Inc. 2 Copyright (C) 1997, 2001-2002, 2004-2013 Free Software Foundation, Inc.
3 Contributed by Simon Josefsson <simon@josefsson.org>. 3 Contributed by Simon Josefsson <simon@josefsson.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
@@ -13,15 +13,14 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
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, write to the Free Software Foundation, 16 along with this program; if not, see <http://www.gnu.org/licenses/>. */
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18
19#include <config.h>
20 17
21/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc 18/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc
22 optimizes away the sa == NULL test below. */ 19 optimizes away the sa == NULL test below. */
23#define _GL_ARG_NONNULL(params) 20#define _GL_ARG_NONNULL(params)
24 21
22#include <config.h>
23
25#include <netdb.h> 24#include <netdb.h>
26 25
27#if HAVE_NETINET_IN_H 26#if HAVE_NETINET_IN_H
@@ -56,10 +55,13 @@
56#endif 55#endif
57 56
58#if defined _WIN32 || defined __WIN32__ 57#if defined _WIN32 || defined __WIN32__
59# define WIN32_NATIVE 58# define WINDOWS_NATIVE
60#endif 59#endif
61 60
62#ifdef WIN32_NATIVE 61/* gl_sockets_startup */
62#include "sockets.h"
63
64#ifdef WINDOWS_NATIVE
63typedef int (WSAAPI *getaddrinfo_func) (const char*, const char*, 65typedef int (WSAAPI *getaddrinfo_func) (const char*, const char*,
64 const struct addrinfo*, 66 const struct addrinfo*,
65 struct addrinfo**); 67 struct addrinfo**);
@@ -101,11 +103,13 @@ use_win32_p (void)
101 return 0; 103 return 0;
102 } 104 }
103 105
106 gl_sockets_startup (SOCKETS_1_1);
107
104 return 1; 108 return 1;
105} 109}
106#endif 110#endif
107 111
108static inline bool 112static bool
109validate_family (int family) 113validate_family (int family)
110{ 114{
111 /* FIXME: Support more families. */ 115 /* FIXME: Support more families. */
@@ -148,7 +152,7 @@ getaddrinfo (const char *restrict nodename,
148 }; 152 };
149#endif 153#endif
150 154
151#ifdef WIN32_NATIVE 155#ifdef WINDOWS_NATIVE
152 if (use_win32_p ()) 156 if (use_win32_p ())
153 return getaddrinfo_ptr (nodename, servname, hints, res); 157 return getaddrinfo_ptr (nodename, servname, hints, res);
154#endif 158#endif
@@ -327,11 +331,11 @@ getaddrinfo (const char *restrict nodename,
327 return 0; 331 return 0;
328} 332}
329 333
330/* Free `addrinfo' structure AI including associated storage. */ 334/* Free 'addrinfo' structure AI including associated storage. */
331void 335void
332freeaddrinfo (struct addrinfo *ai) 336freeaddrinfo (struct addrinfo *ai)
333{ 337{
334#ifdef WIN32_NATIVE 338#ifdef WINDOWS_NATIVE
335 if (use_win32_p ()) 339 if (use_win32_p ())
336 { 340 {
337 freeaddrinfo_ptr (ai); 341 freeaddrinfo_ptr (ai);
@@ -357,7 +361,7 @@ getnameinfo (const struct sockaddr *restrict sa, socklen_t salen,
357 char *restrict service, socklen_t servicelen, 361 char *restrict service, socklen_t servicelen,
358 int flags) 362 int flags)
359{ 363{
360#ifdef WIN32_NATIVE 364#ifdef WINDOWS_NATIVE
361 if (use_win32_p ()) 365 if (use_win32_p ())
362 return getnameinfo_ptr (sa, salen, node, nodelen, 366 return getnameinfo_ptr (sa, salen, node, nodelen,
363 service, servicelen, flags); 367 service, servicelen, flags);
diff --git a/gl/getdtablesize.c b/gl/getdtablesize.c
deleted file mode 100644
index a565a2d..0000000
--- a/gl/getdtablesize.c
+++ /dev/null
@@ -1,63 +0,0 @@
1/* getdtablesize() function for platforms that don't have it.
2 Copyright (C) 2008-2010 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#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
24
25#include <stdio.h>
26
27/* Cache for the previous getdtablesize () result. */
28static int dtablesize;
29
30int
31getdtablesize (void)
32{
33 if (dtablesize == 0)
34 {
35 /* We are looking for the number N such that the valid file descriptors
36 are 0..N-1. It can be obtained through a loop as follows:
37 {
38 int fd;
39 for (fd = 3; fd < 65536; fd++)
40 if (dup2 (0, fd) == -1)
41 break;
42 return fd;
43 }
44 On Windows XP, the result is 2048.
45 The drawback of this loop is that it allocates memory for a libc
46 internal array that is never freed.
47
48 The number N can also be obtained as the upper bound for
49 _getmaxstdio (). _getmaxstdio () returns the maximum number of open
50 FILE objects. The sanity check in _setmaxstdio reveals the maximum
51 number of file descriptors. This too allocates memory, but it is
52 freed when we call _setmaxstdio with the original value. */
53 int orig_max_stdio = _getmaxstdio ();
54 unsigned int bound;
55 for (bound = 0x10000; _setmaxstdio (bound) < 0; bound = bound / 2)
56 ;
57 _setmaxstdio (orig_max_stdio);
58 dtablesize = bound;
59 }
60 return dtablesize;
61}
62
63#endif
diff --git a/gl/gethostname.c b/gl/gethostname.c
index b0da748..2201573 100644
--- a/gl/gethostname.c
+++ b/gl/gethostname.c
@@ -1,7 +1,6 @@
1/* gethostname emulation for SysV and POSIX.1. 1/* gethostname emulation for SysV and POSIX.1.
2 2
3 Copyright (C) 1992, 2003, 2006, 2008, 2009, 2010 Free Software Foundation, 3 Copyright (C) 1992, 2003, 2006, 2008-2013 Free Software Foundation, Inc.
4 Inc.
5 4
6 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
7 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
diff --git a/gl/getloadavg.c b/gl/getloadavg.c
index c6d782b..6e22819 100644
--- a/gl/getloadavg.c
+++ b/gl/getloadavg.c
@@ -1,6 +1,6 @@
1/* Get the system load averages. 1/* Get the system load averages.
2 2
3 Copyright (C) 1985-1989, 1991-1995, 1997, 1999-2000, 2003-2010 Free Software 3 Copyright (C) 1985-1989, 1991-1995, 1997, 1999-2000, 2003-2013 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 5
6 NOTE: The canonical source of this file is maintained with gnulib. 6 NOTE: The canonical source of this file is maintained with gnulib.
@@ -28,7 +28,7 @@
28 macro that comes with autoconf 2.13 or newer. 28 macro that comes with autoconf 2.13 or newer.
29 If that isn't an option, then just put 29 If that isn't an option, then just put
30 AC_CHECK_FUNCS(pstat_getdynamic) in your 30 AC_CHECK_FUNCS(pstat_getdynamic) in your
31 configure.in file. 31 configure.ac file.
32 HAVE_LIBPERFSTAT Define this if your system has the 32 HAVE_LIBPERFSTAT Define this if your system has the
33 perfstat_cpu_total function in libperfstat (AIX). 33 perfstat_cpu_total function in libperfstat (AIX).
34 FIXUP_KERNEL_SYMBOL_ADDR() Adjust address in returned struct nlist. 34 FIXUP_KERNEL_SYMBOL_ADDR() Adjust address in returned struct nlist.
@@ -46,7 +46,7 @@
46 NLIST_STRUCT Include nlist.h, not a.out.h. 46 NLIST_STRUCT Include nlist.h, not a.out.h.
47 N_NAME_POINTER The nlist n_name element is a pointer, 47 N_NAME_POINTER The nlist n_name element is a pointer,
48 not an array. 48 not an array.
49 HAVE_STRUCT_NLIST_N_UN_N_NAME `n_un.n_name' is member of `struct nlist'. 49 HAVE_STRUCT_NLIST_N_UN_N_NAME 'n_un.n_name' is member of 'struct nlist'.
50 LINUX_LDAV_FILE [__linux__, __CYGWIN__]: File containing 50 LINUX_LDAV_FILE [__linux__, __CYGWIN__]: File containing
51 load averages. 51 load averages.
52 52
@@ -80,52 +80,23 @@
80 We also #define LDAV_PRIVILEGED if a program will require 80 We also #define LDAV_PRIVILEGED if a program will require
81 special installation to be able to call getloadavg. */ 81 special installation to be able to call getloadavg. */
82 82
83/* "configure" defines CONFIGURING_GETLOADAVG to sidestep problems 83#include <config.h>
84 with partially-configured source directories. */
85
86#ifndef CONFIGURING_GETLOADAVG
87# include <config.h>
88# include <stdbool.h>
89#endif
90 84
91/* Specification. */ 85/* Specification. */
92#include <stdlib.h> 86#include <stdlib.h>
93 87
94#include <errno.h> 88#include <errno.h>
89#include <stdbool.h>
95#include <stdio.h> 90#include <stdio.h>
96 91
97/* Exclude all the code except the test program at the end
98 if the system has its own `getloadavg' function. */
99
100#ifndef HAVE_GETLOADAVG
101
102# include <sys/types.h> 92# include <sys/types.h>
103 93
104/* Both the Emacs and non-Emacs sections want this. Some 94# if HAVE_SYS_PARAM_H
105 configuration files' definitions for the LOAD_AVE_CVT macro (like
106 sparc.h's) use macros like FSCALE, defined here. */
107# if defined (unix) || defined (__unix)
108# include <sys/param.h> 95# include <sys/param.h>
109# endif 96# endif
110 97
111# include "c-strtod.h"
112# include "cloexec.h"
113# include "intprops.h" 98# include "intprops.h"
114 99
115/* The existing Emacs configuration files define a macro called
116 LOAD_AVE_CVT, which accepts a value of type LOAD_AVE_TYPE, and
117 returns the load average multiplied by 100. What we actually want
118 is a macro called LDAV_CVT, which returns the load average as an
119 unmultiplied double.
120
121 For backwards compatibility, we'll define LDAV_CVT in terms of
122 LOAD_AVE_CVT, but future machine config files should just define
123 LDAV_CVT directly. */
124
125# if !defined (LDAV_CVT) && defined (LOAD_AVE_CVT)
126# define LDAV_CVT(n) (LOAD_AVE_CVT (n) / 100.0)
127# endif
128
129# if !defined (BSD) && defined (ultrix) 100# if !defined (BSD) && defined (ultrix)
130/* Ultrix behaves like BSD on Vaxen. */ 101/* Ultrix behaves like BSD on Vaxen. */
131# define BSD 102# define BSD
@@ -372,7 +343,6 @@
372# endif /* NLIST_STRUCT */ 343# endif /* NLIST_STRUCT */
373 344
374# ifdef SUNOS_5 345# ifdef SUNOS_5
375# include <fcntl.h>
376# include <kvm.h> 346# include <kvm.h>
377# include <kstat.h> 347# include <kstat.h>
378# endif 348# endif
@@ -461,7 +431,10 @@
461# include <sys/dg_sys_info.h> 431# include <sys/dg_sys_info.h>
462# endif 432# endif
463 433
464# include "fcntl--.h" 434# if (defined __linux__ || defined __CYGWIN__ || defined SUNOS_5 \
435 || (defined LOAD_AVE_TYPE && ! defined __VMS))
436# include <fcntl.h>
437# endif
465 438
466/* Avoid static vars inside a function since in HPUX they dump as pure. */ 439/* Avoid static vars inside a function since in HPUX they dump as pure. */
467 440
@@ -482,13 +455,13 @@ static struct dg_sys_info_load_info load_info; /* what-a-mouthful! */
482# if !defined (HAVE_LIBKSTAT) && defined (LOAD_AVE_TYPE) 455# if !defined (HAVE_LIBKSTAT) && defined (LOAD_AVE_TYPE)
483/* File descriptor open to /dev/kmem or VMS load ave driver. */ 456/* File descriptor open to /dev/kmem or VMS load ave driver. */
484static int channel; 457static int channel;
485/* True iff channel is valid. */ 458/* True if channel is valid. */
486static bool getloadavg_initialized; 459static bool getloadavg_initialized;
487/* Offset in kmem to seek to read load average, or 0 means invalid. */ 460/* Offset in kmem to seek to read load average, or 0 means invalid. */
488static long offset; 461static long offset;
489 462
490# if ! defined __VMS && ! defined sgi && ! defined __linux__ 463# if ! defined __VMS && ! defined sgi && ! defined __linux__
491static struct nlist nl[2]; 464static struct nlist name_list[2];
492# endif 465# endif
493 466
494# ifdef SUNOS_5 467# ifdef SUNOS_5
@@ -500,7 +473,7 @@ static kvm_t *kd;
500/* Put the 1 minute, 5 minute and 15 minute load averages 473/* Put the 1 minute, 5 minute and 15 minute load averages
501 into the first NELEM elements of LOADAVG. 474 into the first NELEM elements of LOADAVG.
502 Return the number written (never more than 3, but may be less than NELEM), 475 Return the number written (never more than 3, but may be less than NELEM),
503 or -1 if an error occurred. */ 476 or -1 (setting errno) if an error occurred. */
504 477
505int 478int
506getloadavg (double loadavg[], int nelem) 479getloadavg (double loadavg[], int nelem)
@@ -509,18 +482,17 @@ getloadavg (double loadavg[], int nelem)
509 482
510# ifdef NO_GET_LOAD_AVG 483# ifdef NO_GET_LOAD_AVG
511# define LDAV_DONE 484# define LDAV_DONE
512 /* Set errno to zero to indicate that there was no particular error; 485 errno = ENOSYS;
513 this function just can't work at all on this system. */
514 errno = 0;
515 elem = -1; 486 elem = -1;
516# endif 487# endif
517 488
518# if !defined (LDAV_DONE) && defined (HAVE_LIBKSTAT) 489# if !defined (LDAV_DONE) && defined (HAVE_LIBKSTAT) /* Solaris <= 2.6 */
519/* Use libkstat because we don't have to be root. */ 490/* Use libkstat because we don't have to be root. */
520# define LDAV_DONE 491# define LDAV_DONE
521 kstat_ctl_t *kc; 492 kstat_ctl_t *kc;
522 kstat_t *ksp; 493 kstat_t *ksp;
523 kstat_named_t *kn; 494 kstat_named_t *kn;
495 int saved_errno;
524 496
525 kc = kstat_open (); 497 kc = kstat_open ();
526 if (kc == 0) 498 if (kc == 0)
@@ -559,10 +531,13 @@ getloadavg (double loadavg[], int nelem)
559 } 531 }
560 } 532 }
561 533
534 saved_errno = errno;
562 kstat_close (kc); 535 kstat_close (kc);
536 errno = saved_errno;
563# endif /* HAVE_LIBKSTAT */ 537# endif /* HAVE_LIBKSTAT */
564 538
565# if !defined (LDAV_DONE) && defined (hpux) && defined (HAVE_PSTAT_GETDYNAMIC) 539# if !defined (LDAV_DONE) && defined (hpux) && defined (HAVE_PSTAT_GETDYNAMIC)
540 /* HP-UX */
566/* Use pstat_getdynamic() because we don't have to be root. */ 541/* Use pstat_getdynamic() because we don't have to be root. */
567# define LDAV_DONE 542# define LDAV_DONE
568# undef LOAD_AVE_TYPE 543# undef LOAD_AVE_TYPE
@@ -579,7 +554,7 @@ getloadavg (double loadavg[], int nelem)
579 554
580# endif /* hpux && HAVE_PSTAT_GETDYNAMIC */ 555# endif /* hpux && HAVE_PSTAT_GETDYNAMIC */
581 556
582# if ! defined LDAV_DONE && defined HAVE_LIBPERFSTAT 557# if ! defined LDAV_DONE && defined HAVE_LIBPERFSTAT /* AIX */
583# define LDAV_DONE 558# define LDAV_DONE
584# undef LOAD_AVE_TYPE 559# undef LOAD_AVE_TYPE
585/* Use perfstat_cpu_total because we don't have to be root. */ 560/* Use perfstat_cpu_total because we don't have to be root. */
@@ -596,6 +571,7 @@ getloadavg (double loadavg[], int nelem)
596# endif 571# endif
597 572
598# if !defined (LDAV_DONE) && (defined (__linux__) || defined (__CYGWIN__)) 573# if !defined (LDAV_DONE) && (defined (__linux__) || defined (__CYGWIN__))
574 /* Linux without glibc, Cygwin */
599# define LDAV_DONE 575# define LDAV_DONE
600# undef LOAD_AVE_TYPE 576# undef LOAD_AVE_TYPE
601 577
@@ -605,39 +581,54 @@ getloadavg (double loadavg[], int nelem)
605 581
606 char ldavgbuf[3 * (INT_STRLEN_BOUND (int) + sizeof ".00 ")]; 582 char ldavgbuf[3 * (INT_STRLEN_BOUND (int) + sizeof ".00 ")];
607 char const *ptr = ldavgbuf; 583 char const *ptr = ldavgbuf;
608 int fd, count; 584 int fd, count, saved_errno;
609 585
610 fd = open (LINUX_LDAV_FILE, O_RDONLY); 586 fd = open (LINUX_LDAV_FILE, O_RDONLY);
611 if (fd == -1) 587 if (fd == -1)
612 return -1; 588 return -1;
613 count = read (fd, ldavgbuf, sizeof ldavgbuf - 1); 589 count = read (fd, ldavgbuf, sizeof ldavgbuf - 1);
590 saved_errno = errno;
614 (void) close (fd); 591 (void) close (fd);
592 errno = saved_errno;
615 if (count <= 0) 593 if (count <= 0)
616 return -1; 594 return -1;
617 ldavgbuf[count] = '\0'; 595 ldavgbuf[count] = '\0';
618 596
619 for (elem = 0; elem < nelem; elem++) 597 for (elem = 0; elem < nelem; elem++)
620 { 598 {
621 char *endptr; 599 double numerator = 0;
622 double d; 600 double denominator = 1;
601
602 while (*ptr == ' ')
603 ptr++;
623 604
624 errno = 0; 605 /* Finish if this number is missing, and report an error if all
625 d = c_strtod (ptr, &endptr); 606 were missing. */
626 if (ptr == endptr || (d == 0 && errno != 0)) 607 if (! ('0' <= *ptr && *ptr <= '9'))
627 { 608 {
628 if (elem == 0) 609 if (elem == 0)
629 return -1; 610 {
611 errno = ENOTSUP;
612 return -1;
613 }
630 break; 614 break;
631 } 615 }
632 loadavg[elem] = d; 616
633 ptr = endptr; 617 while ('0' <= *ptr && *ptr <= '9')
618 numerator = 10 * numerator + (*ptr++ - '0');
619
620 if (*ptr == '.')
621 for (ptr++; '0' <= *ptr && *ptr <= '9'; ptr++)
622 numerator = 10 * numerator + (*ptr - '0'), denominator *= 10;
623
624 loadavg[elem++] = numerator / denominator;
634 } 625 }
635 626
636 return elem; 627 return elem;
637 628
638# endif /* __linux__ || __CYGWIN__ */ 629# endif /* __linux__ || __CYGWIN__ */
639 630
640# if !defined (LDAV_DONE) && defined (__NetBSD__) 631# if !defined (LDAV_DONE) && defined (__NetBSD__) /* NetBSD < 0.9 */
641# define LDAV_DONE 632# define LDAV_DONE
642# undef LOAD_AVE_TYPE 633# undef LOAD_AVE_TYPE
643 634
@@ -657,7 +648,10 @@ getloadavg (double loadavg[], int nelem)
657 &scale); 648 &scale);
658 (void) fclose (fp); 649 (void) fclose (fp);
659 if (count != 4) 650 if (count != 4)
660 return -1; 651 {
652 errno = ENOTSUP;
653 return -1;
654 }
661 655
662 for (elem = 0; elem < nelem; elem++) 656 for (elem = 0; elem < nelem; elem++)
663 loadavg[elem] = (double) load_ave[elem] / (double) scale; 657 loadavg[elem] = (double) load_ave[elem] / (double) scale;
@@ -666,7 +660,7 @@ getloadavg (double loadavg[], int nelem)
666 660
667# endif /* __NetBSD__ */ 661# endif /* __NetBSD__ */
668 662
669# if !defined (LDAV_DONE) && defined (NeXT) 663# if !defined (LDAV_DONE) && defined (NeXT) /* NeXTStep */
670# define LDAV_DONE 664# define LDAV_DONE
671 /* The NeXT code was adapted from iscreen 3.2. */ 665 /* The NeXT code was adapted from iscreen 3.2. */
672 666
@@ -698,7 +692,10 @@ getloadavg (double loadavg[], int nelem)
698 } 692 }
699 693
700 if (!getloadavg_initialized) 694 if (!getloadavg_initialized)
701 return -1; 695 {
696 errno = ENOTSUP;
697 return -1;
698 }
702# endif /* NeXT */ 699# endif /* NeXT */
703 700
704# if !defined (LDAV_DONE) && defined (UMAX) 701# if !defined (LDAV_DONE) && defined (UMAX)
@@ -732,7 +729,7 @@ getloadavg (double loadavg[], int nelem)
732 for (i = 0; i < conf.config_maxclass; ++i) 729 for (i = 0; i < conf.config_maxclass; ++i)
733 { 730 {
734 struct class_stats stats; 731 struct class_stats stats;
735 bzero ((char *) &stats, sizeof stats); 732 memset (&stats, 0, sizeof stats);
736 733
737 desc.sd_type = CPUTYPE_CLASS; 734 desc.sd_type = CPUTYPE_CLASS;
738 desc.sd_objid = i; 735 desc.sd_objid = i;
@@ -775,7 +772,7 @@ getloadavg (double loadavg[], int nelem)
775# define LDAV_DONE 772# define LDAV_DONE
776 /* This call can return -1 for an error, but with good args 773 /* This call can return -1 for an error, but with good args
777 it's not supposed to fail. The first argument is for no 774 it's not supposed to fail. The first argument is for no
778 apparent reason of type `long int *'. */ 775 apparent reason of type 'long int *'. */
779 dg_sys_info ((long int *) &load_info, 776 dg_sys_info ((long int *) &load_info,
780 DG_SYS_INFO_LOAD_INFO_TYPE, 777 DG_SYS_INFO_LOAD_INFO_TYPE,
781 DG_SYS_INFO_LOAD_VERSION_0); 778 DG_SYS_INFO_LOAD_VERSION_0);
@@ -825,6 +822,7 @@ getloadavg (double loadavg[], int nelem)
825# endif /* OSF_MIPS */ 822# endif /* OSF_MIPS */
826 823
827# if !defined (LDAV_DONE) && (defined (__MSDOS__) || defined (WINDOWS32)) 824# if !defined (LDAV_DONE) && (defined (__MSDOS__) || defined (WINDOWS32))
825 /* DJGPP */
828# define LDAV_DONE 826# define LDAV_DONE
829 827
830 /* A faithful emulation is going to have to be saved for a rainy day. */ 828 /* A faithful emulation is going to have to be saved for a rainy day. */
@@ -834,7 +832,7 @@ getloadavg (double loadavg[], int nelem)
834 } 832 }
835# endif /* __MSDOS__ || WINDOWS32 */ 833# endif /* __MSDOS__ || WINDOWS32 */
836 834
837# if !defined (LDAV_DONE) && defined (OSF_ALPHA) 835# if !defined (LDAV_DONE) && defined (OSF_ALPHA) /* OSF/1 */
838# define LDAV_DONE 836# define LDAV_DONE
839 837
840 struct tbl_loadavg load_ave; 838 struct tbl_loadavg load_ave;
@@ -846,7 +844,7 @@ getloadavg (double loadavg[], int nelem)
846 : (load_ave.tl_avenrun.l[elem] / (double) load_ave.tl_lscale)); 844 : (load_ave.tl_avenrun.l[elem] / (double) load_ave.tl_lscale));
847# endif /* OSF_ALPHA */ 845# endif /* OSF_ALPHA */
848 846
849# if ! defined LDAV_DONE && defined __VMS 847# if ! defined LDAV_DONE && defined __VMS /* VMS */
850 /* VMS specific code -- read from the Load Ave driver. */ 848 /* VMS specific code -- read from the Load Ave driver. */
851 849
852 LOAD_AVE_TYPE load_ave[3]; 850 LOAD_AVE_TYPE load_ave[3];
@@ -883,10 +881,14 @@ getloadavg (double loadavg[], int nelem)
883 } 881 }
884 882
885 if (!getloadavg_initialized) 883 if (!getloadavg_initialized)
886 return -1; 884 {
885 errno = ENOTSUP;
886 return -1;
887 }
887# endif /* ! defined LDAV_DONE && defined __VMS */ 888# endif /* ! defined LDAV_DONE && defined __VMS */
888 889
889# if ! defined LDAV_DONE && defined LOAD_AVE_TYPE && ! defined __VMS 890# if ! defined LDAV_DONE && defined LOAD_AVE_TYPE && ! defined __VMS
891 /* IRIX, other old systems */
890 892
891 /* UNIX-specific code -- read the average from /dev/kmem. */ 893 /* UNIX-specific code -- read the average from /dev/kmem. */
892 894
@@ -899,38 +901,36 @@ getloadavg (double loadavg[], int nelem)
899 { 901 {
900# ifndef sgi 902# ifndef sgi
901# if ! defined NLIST_STRUCT || ! defined N_NAME_POINTER 903# if ! defined NLIST_STRUCT || ! defined N_NAME_POINTER
902 strcpy (nl[0].n_name, LDAV_SYMBOL); 904 strcpy (name_list[0].n_name, LDAV_SYMBOL);
903 strcpy (nl[1].n_name, ""); 905 strcpy (name_list[1].n_name, "");
904# else /* NLIST_STRUCT */ 906# else /* NLIST_STRUCT */
905# ifdef HAVE_STRUCT_NLIST_N_UN_N_NAME 907# ifdef HAVE_STRUCT_NLIST_N_UN_N_NAME
906 nl[0].n_un.n_name = LDAV_SYMBOL; 908 name_list[0].n_un.n_name = LDAV_SYMBOL;
907 nl[1].n_un.n_name = 0; 909 name_list[1].n_un.n_name = 0;
908# else /* not HAVE_STRUCT_NLIST_N_UN_N_NAME */ 910# else /* not HAVE_STRUCT_NLIST_N_UN_N_NAME */
909 nl[0].n_name = LDAV_SYMBOL; 911 name_list[0].n_name = LDAV_SYMBOL;
910 nl[1].n_name = 0; 912 name_list[1].n_name = 0;
911# endif /* not HAVE_STRUCT_NLIST_N_UN_N_NAME */ 913# endif /* not HAVE_STRUCT_NLIST_N_UN_N_NAME */
912# endif /* NLIST_STRUCT */ 914# endif /* NLIST_STRUCT */
913 915
914# ifndef SUNOS_5 916# ifndef SUNOS_5
915 if ( 917 if (
916# if !(defined (_AIX) && !defined (ps2)) 918# if !(defined (_AIX) && !defined (ps2))
917 nlist (KERNEL_FILE, nl) 919 nlist (KERNEL_FILE, name_list)
918# else /* _AIX */ 920# else /* _AIX */
919 knlist (nl, 1, sizeof (nl[0])) 921 knlist (name_list, 1, sizeof (name_list[0]))
920# endif 922# endif
921 >= 0) 923 >= 0)
922 /* Omit "&& nl[0].n_type != 0 " -- it breaks on Sun386i. */ 924 /* Omit "&& name_list[0].n_type != 0 " -- it breaks on Sun386i. */
923 { 925 {
924# ifdef FIXUP_KERNEL_SYMBOL_ADDR 926# ifdef FIXUP_KERNEL_SYMBOL_ADDR
925 FIXUP_KERNEL_SYMBOL_ADDR (nl); 927 FIXUP_KERNEL_SYMBOL_ADDR (name_list);
926# endif 928# endif
927 offset = nl[0].n_value; 929 offset = name_list[0].n_value;
928 } 930 }
929# endif /* !SUNOS_5 */ 931# endif /* !SUNOS_5 */
930# else /* sgi */ 932# else /* sgi */
931 int ldav_off; 933 ptrdiff_t ldav_off = sysmp (MP_KERNADDR, MPKA_AVENRUN);
932
933 ldav_off = sysmp (MP_KERNADDR, MPKA_AVENRUN);
934 if (ldav_off != -1) 934 if (ldav_off != -1)
935 offset = (long int) ldav_off & 0x7fffffff; 935 offset = (long int) ldav_off & 0x7fffffff;
936# endif /* sgi */ 936# endif /* sgi */
@@ -940,13 +940,27 @@ getloadavg (double loadavg[], int nelem)
940 if (!getloadavg_initialized) 940 if (!getloadavg_initialized)
941 { 941 {
942# ifndef SUNOS_5 942# ifndef SUNOS_5
943 channel = open ("/dev/kmem", O_RDONLY); 943 /* Set the channel to close on exec, so it does not
944 if (channel >= 0) 944 litter any child's descriptor table. */
945# ifndef O_CLOEXEC
946# define O_CLOEXEC 0
947# endif
948 int fd = open ("/dev/kmem", O_RDONLY | O_CLOEXEC);
949 if (0 <= fd)
945 { 950 {
946 /* Set the channel to close on exec, so it does not 951# if F_DUPFD_CLOEXEC
947 litter any child's descriptor table. */ 952 if (fd <= STDERR_FILENO)
948 set_cloexec_flag (channel, true); 953 {
949 getloadavg_initialized = true; 954 int fd1 = fcntl (fd, F_DUPFD_CLOEXEC, STDERR_FILENO + 1);
955 close (fd);
956 fd = fd1;
957 }
958# endif
959 if (0 <= fd)
960 {
961 channel = fd;
962 getloadavg_initialized = true;
963 }
950 } 964 }
951# else /* SUNOS_5 */ 965# else /* SUNOS_5 */
952 /* We pass 0 for the kernel, corefile, and swapfile names 966 /* We pass 0 for the kernel, corefile, and swapfile names
@@ -955,8 +969,8 @@ getloadavg (double loadavg[], int nelem)
955 if (kd != 0) 969 if (kd != 0)
956 { 970 {
957 /* nlist the currently running kernel. */ 971 /* nlist the currently running kernel. */
958 kvm_nlist (kd, nl); 972 kvm_nlist (kd, name_list);
959 offset = nl[0].n_value; 973 offset = name_list[0].n_value;
960 getloadavg_initialized = true; 974 getloadavg_initialized = true;
961 } 975 }
962# endif /* SUNOS_5 */ 976# endif /* SUNOS_5 */
@@ -985,7 +999,10 @@ getloadavg (double loadavg[], int nelem)
985 } 999 }
986 1000
987 if (offset == 0 || !getloadavg_initialized) 1001 if (offset == 0 || !getloadavg_initialized)
988 return -1; 1002 {
1003 errno = ENOTSUP;
1004 return -1;
1005 }
989# endif /* ! defined LDAV_DONE && defined LOAD_AVE_TYPE && ! defined __VMS */ 1006# endif /* ! defined LDAV_DONE && defined LOAD_AVE_TYPE && ! defined __VMS */
990 1007
991# if !defined (LDAV_DONE) && defined (LOAD_AVE_TYPE) /* Including VMS. */ 1008# if !defined (LDAV_DONE) && defined (LOAD_AVE_TYPE) /* Including VMS. */
@@ -1000,51 +1017,8 @@ getloadavg (double loadavg[], int nelem)
1000# endif /* !LDAV_DONE && LOAD_AVE_TYPE */ 1017# endif /* !LDAV_DONE && LOAD_AVE_TYPE */
1001 1018
1002# if !defined LDAV_DONE 1019# if !defined LDAV_DONE
1003 /* Set errno to zero to indicate that there was no particular error; 1020 errno = ENOSYS;
1004 this function just can't work at all on this system. */
1005 errno = 0;
1006 elem = -1; 1021 elem = -1;
1007# endif 1022# endif
1008 return elem; 1023 return elem;
1009} 1024}
1010
1011#endif /* ! HAVE_GETLOADAVG */
1012
1013#ifdef TEST
1014int
1015main (int argc, char **argv)
1016{
1017 int naptime = 0;
1018
1019 if (argc > 1)
1020 naptime = atoi (argv[1]);
1021
1022 while (1)
1023 {
1024 double avg[3];
1025 int loads;
1026
1027 errno = 0; /* Don't be misled if it doesn't set errno. */
1028 loads = getloadavg (avg, 3);
1029 if (loads == -1)
1030 {
1031 perror ("Error getting load average");
1032 return EXIT_FAILURE;
1033 }
1034 if (loads > 0)
1035 printf ("1-minute: %f ", avg[0]);
1036 if (loads > 1)
1037 printf ("5-minute: %f ", avg[1]);
1038 if (loads > 2)
1039 printf ("15-minute: %f ", avg[2]);
1040 if (loads > 0)
1041 putchar ('\n');
1042
1043 if (naptime == 0)
1044 break;
1045 sleep (naptime);
1046 }
1047
1048 return EXIT_SUCCESS;
1049}
1050#endif /* TEST */
diff --git a/gl/getopt.c b/gl/getopt.c
index 3791f12..ef0f4ce 100644
--- a/gl/getopt.c
+++ b/gl/getopt.c
@@ -2,7 +2,7 @@
2 NOTE: getopt is part of the C library, so if you don't know what 2 NOTE: getopt is 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-1996, 1998-2004, 2006, 2008-2010 Free Software 5 Copyright (C) 1987-1996, 1998-2004, 2006, 2008-2013 Free Software
6 Foundation, Inc. 6 Foundation, Inc.
7 This file is part of the GNU C Library. 7 This file is part of the GNU C Library.
8 8
@@ -41,15 +41,15 @@
41# include <wchar.h> 41# include <wchar.h>
42#endif 42#endif
43 43
44/* This version of `getopt' appears to the caller like standard Unix `getopt' 44/* This version of 'getopt' appears to the caller like standard Unix 'getopt'
45 but it behaves differently for the user, since it allows the user 45 but it behaves differently for the user, since it allows the user
46 to intersperse the options with the other arguments. 46 to intersperse the options with the other arguments.
47 47
48 As `getopt_long' works, it permutes the elements of ARGV so that, 48 As 'getopt_long' works, it permutes the elements of ARGV so that,
49 when it is done, all the options precede everything else. Thus 49 when it is done, all the options precede everything else. Thus
50 all application programs are extended to handle flexible argument order. 50 all application programs are extended to handle flexible argument order.
51 51
52 Using `getopt' or setting the environment variable POSIXLY_CORRECT 52 Using 'getopt' or setting the environment variable POSIXLY_CORRECT
53 disables permutation. 53 disables permutation.
54 Then the behavior is completely standard. 54 Then the behavior is completely standard.
55 55
@@ -58,24 +58,24 @@
58 58
59#include "getopt_int.h" 59#include "getopt_int.h"
60 60
61/* For communication from `getopt' to the caller. 61/* For communication from 'getopt' to the caller.
62 When `getopt' finds an option that takes an argument, 62 When 'getopt' finds an option that takes an argument,
63 the argument value is returned here. 63 the argument value is returned here.
64 Also, when `ordering' is RETURN_IN_ORDER, 64 Also, when 'ordering' is RETURN_IN_ORDER,
65 each non-option ARGV-element is returned here. */ 65 each non-option ARGV-element is returned here. */
66 66
67char *optarg; 67char *optarg;
68 68
69/* Index in ARGV of the next element to be scanned. 69/* Index in ARGV of the next element to be scanned.
70 This is used for communication to and from the caller 70 This is used for communication to and from the caller
71 and for communication between successive calls to `getopt'. 71 and for communication between successive calls to 'getopt'.
72 72
73 On entry to `getopt', zero means this is the first call; initialize. 73 On entry to 'getopt', zero means this is the first call; initialize.
74 74
75 When `getopt' returns -1, this is the index of the first of the 75 When 'getopt' returns -1, this is the index of the first of the
76 non-option elements that the caller should itself scan. 76 non-option elements that the caller should itself scan.
77 77
78 Otherwise, `optind' communicates from one call to the next 78 Otherwise, 'optind' communicates from one call to the next
79 how much of ARGV has been scanned so far. */ 79 how much of ARGV has been scanned so far. */
80 80
81/* 1003.2 says this must be 1 before any call. */ 81/* 1003.2 says this must be 1 before any call. */
@@ -137,7 +137,7 @@ extern char *__getopt_nonoption_flags;
137 The other is elements [last_nonopt,optind), which contains all 137 The other is elements [last_nonopt,optind), which contains all
138 the options processed since those non-options were skipped. 138 the options processed since those non-options were skipped.
139 139
140 `first_nonopt' and `last_nonopt' are relocated so that they describe 140 'first_nonopt' and 'last_nonopt' are relocated so that they describe
141 the new indices of the non-options in ARGV after they are moved. */ 141 the new indices of the non-options in ARGV after they are moved. */
142 142
143static void 143static void
@@ -154,7 +154,7 @@ exchange (char **argv, struct _getopt_data *d)
154 but it consists of two parts that need to be swapped next. */ 154 but it consists of two parts that need to be swapped next. */
155 155
156#if defined _LIBC && defined USE_NONOPTION_FLAGS 156#if defined _LIBC && defined USE_NONOPTION_FLAGS
157 /* First make sure the handling of the `__getopt_nonoption_flags' 157 /* First make sure the handling of the '__getopt_nonoption_flags'
158 string can work normally. Our top argument must be in the range 158 string can work normally. Our top argument must be in the range
159 of the string. */ 159 of the string. */
160 if (d->__nonoption_flags_len > 0 && top >= d->__nonoption_flags_max_len) 160 if (d->__nonoption_flags_len > 0 && top >= d->__nonoption_flags_max_len)
@@ -291,48 +291,48 @@ _getopt_initialize (int argc _GL_UNUSED,
291 291
292 If an element of ARGV starts with '-', and is not exactly "-" or "--", 292 If an element of ARGV starts with '-', and is not exactly "-" or "--",
293 then it is an option element. The characters of this element 293 then it is an option element. The characters of this element
294 (aside from the initial '-') are option characters. If `getopt' 294 (aside from the initial '-') are option characters. If 'getopt'
295 is called repeatedly, it returns successively each of the option characters 295 is called repeatedly, it returns successively each of the option characters
296 from each of the option elements. 296 from each of the option elements.
297 297
298 If `getopt' finds another option character, it returns that character, 298 If 'getopt' finds another option character, it returns that character,
299 updating `optind' and `nextchar' so that the next call to `getopt' can 299 updating 'optind' and 'nextchar' so that the next call to 'getopt' can
300 resume the scan with the following option character or ARGV-element. 300 resume the scan with the following option character or ARGV-element.
301 301
302 If there are no more option characters, `getopt' returns -1. 302 If there are no more option characters, 'getopt' returns -1.
303 Then `optind' is the index in ARGV of the first ARGV-element 303 Then 'optind' is the index in ARGV of the first ARGV-element
304 that is not an option. (The ARGV-elements have been permuted 304 that is not an option. (The ARGV-elements have been permuted
305 so that those that are not options now come last.) 305 so that those that are not options now come last.)
306 306
307 OPTSTRING is a string containing the legitimate option characters. 307 OPTSTRING is a string containing the legitimate option characters.
308 If an option character is seen that is not listed in OPTSTRING, 308 If an option character is seen that is not listed in OPTSTRING,
309 return '?' after printing an error message. If you set `opterr' to 309 return '?' after printing an error message. If you set 'opterr' to
310 zero, the error message is suppressed but we still return '?'. 310 zero, the error message is suppressed but we still return '?'.
311 311
312 If a char in OPTSTRING is followed by a colon, that means it wants an arg, 312 If a char in OPTSTRING is followed by a colon, that means it wants an arg,
313 so the following text in the same ARGV-element, or the text of the following 313 so the following text in the same ARGV-element, or the text of the following
314 ARGV-element, is returned in `optarg'. Two colons mean an option that 314 ARGV-element, is returned in 'optarg'. Two colons mean an option that
315 wants an optional arg; if there is text in the current ARGV-element, 315 wants an optional arg; if there is text in the current ARGV-element,
316 it is returned in `optarg', otherwise `optarg' is set to zero. 316 it is returned in 'optarg', otherwise 'optarg' is set to zero.
317 317
318 If OPTSTRING starts with `-' or `+', it requests different methods of 318 If OPTSTRING starts with '-' or '+', it requests different methods of
319 handling the non-option ARGV-elements. 319 handling the non-option ARGV-elements.
320 See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. 320 See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
321 321
322 Long-named options begin with `--' instead of `-'. 322 Long-named options begin with '--' instead of '-'.
323 Their names may be abbreviated as long as the abbreviation is unique 323 Their names may be abbreviated as long as the abbreviation is unique
324 or is an exact match for some defined option. If they have an 324 or is an exact match for some defined option. If they have an
325 argument, it follows the option name in the same ARGV-element, separated 325 argument, it follows the option name in the same ARGV-element, separated
326 from the option name by a `=', or else the in next ARGV-element. 326 from the option name by a '=', or else the in next ARGV-element.
327 When `getopt' finds a long-named option, it returns 0 if that option's 327 When 'getopt' finds a long-named option, it returns 0 if that option's
328 `flag' field is nonzero, the value of the option's `val' field 328 'flag' field is nonzero, the value of the option's 'val' field
329 if the `flag' field is zero. 329 if the 'flag' field is zero.
330 330
331 The elements of ARGV aren't really const, because we permute them. 331 The elements of ARGV aren't really const, because we permute them.
332 But we pretend they're const in the prototype to be compatible 332 But we pretend they're const in the prototype to be compatible
333 with other systems. 333 with other systems.
334 334
335 LONGOPTS is a vector of `struct option' terminated by an 335 LONGOPTS is a vector of 'struct option' terminated by an
336 element containing a name which is zero. 336 element containing a name which is zero.
337 337
338 LONGIND returns the index in LONGOPT of the long-named option found. 338 LONGIND returns the index in LONGOPT of the long-named option found.
@@ -409,7 +409,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
409 d->__last_nonopt = d->optind; 409 d->__last_nonopt = d->optind;
410 } 410 }
411 411
412 /* The special ARGV-element `--' means premature end of options. 412 /* The special ARGV-element '--' means premature end of options.
413 Skip it like a null option, 413 Skip it like a null option,
414 then exchange with previous non-options as if it were an option, 414 then exchange with previous non-options as if it were an option,
415 then skip everything else like a non-option. */ 415 then skip everything else like a non-option. */
@@ -479,23 +479,28 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
479 || !strchr (optstring, argv[d->optind][1]))))) 479 || !strchr (optstring, argv[d->optind][1])))))
480 { 480 {
481 char *nameend; 481 char *nameend;
482 unsigned int namelen;
482 const struct option *p; 483 const struct option *p;
483 const struct option *pfound = NULL; 484 const struct option *pfound = NULL;
485 struct option_list
486 {
487 const struct option *p;
488 struct option_list *next;
489 } *ambig_list = NULL;
484 int exact = 0; 490 int exact = 0;
485 int ambig = 0;
486 int indfound = -1; 491 int indfound = -1;
487 int option_index; 492 int option_index;
488 493
489 for (nameend = d->__nextchar; *nameend && *nameend != '='; nameend++) 494 for (nameend = d->__nextchar; *nameend && *nameend != '='; nameend++)
490 /* Do nothing. */ ; 495 /* Do nothing. */ ;
496 namelen = nameend - d->__nextchar;
491 497
492 /* Test all long options for either exact match 498 /* Test all long options for either exact match
493 or abbreviated matches. */ 499 or abbreviated matches. */
494 for (p = longopts, option_index = 0; p->name; p++, option_index++) 500 for (p = longopts, option_index = 0; p->name; p++, option_index++)
495 if (!strncmp (p->name, d->__nextchar, nameend - d->__nextchar)) 501 if (!strncmp (p->name, d->__nextchar, namelen))
496 { 502 {
497 if ((unsigned int) (nameend - d->__nextchar) 503 if (namelen == (unsigned int) strlen (p->name))
498 == (unsigned int) strlen (p->name))
499 { 504 {
500 /* Exact match found. */ 505 /* Exact match found. */
501 pfound = p; 506 pfound = p;
@@ -513,35 +518,71 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
513 || pfound->has_arg != p->has_arg 518 || pfound->has_arg != p->has_arg
514 || pfound->flag != p->flag 519 || pfound->flag != p->flag
515 || pfound->val != p->val) 520 || pfound->val != p->val)
516 /* Second or later nonexact match found. */ 521 {
517 ambig = 1; 522 /* Second or later nonexact match found. */
523 struct option_list *newp = malloc (sizeof (*newp));
524 newp->p = p;
525 newp->next = ambig_list;
526 ambig_list = newp;
527 }
518 } 528 }
519 529
520 if (ambig && !exact) 530 if (ambig_list != NULL && !exact)
521 { 531 {
522 if (print_errors) 532 if (print_errors)
523 { 533 {
534 struct option_list first;
535 first.p = pfound;
536 first.next = ambig_list;
537 ambig_list = &first;
538
524#if defined _LIBC && defined USE_IN_LIBIO 539#if defined _LIBC && defined USE_IN_LIBIO
525 char *buf; 540 char *buf = NULL;
541 size_t buflen = 0;
526 542
527 if (__asprintf (&buf, _("%s: option '%s' is ambiguous\n"), 543 FILE *fp = open_memstream (&buf, &buflen);
528 argv[0], argv[d->optind]) >= 0) 544 if (fp != NULL)
529 { 545 {
530 _IO_flockfile (stderr); 546 fprintf (fp,
547 _("%s: option '%s' is ambiguous; possibilities:"),
548 argv[0], argv[d->optind]);
531 549
532 int old_flags2 = ((_IO_FILE *) stderr)->_flags2; 550 do
533 ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; 551 {
552 fprintf (fp, " '--%s'", ambig_list->p->name);
553 ambig_list = ambig_list->next;
554 }
555 while (ambig_list != NULL);
534 556
535 __fxprintf (NULL, "%s", buf); 557 fputc_unlocked ('\n', fp);
536 558
537 ((_IO_FILE *) stderr)->_flags2 = old_flags2; 559 if (__builtin_expect (fclose (fp) != EOF, 1))
538 _IO_funlockfile (stderr); 560 {
561 _IO_flockfile (stderr);
539 562
540 free (buf); 563 int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
564 ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
565
566 __fxprintf (NULL, "%s", buf);
567
568 ((_IO_FILE *) stderr)->_flags2 = old_flags2;
569 _IO_funlockfile (stderr);
570
571 free (buf);
572 }
541 } 573 }
542#else 574#else
543 fprintf (stderr, _("%s: option '%s' is ambiguous\n"), 575 fprintf (stderr,
576 _("%s: option '%s' is ambiguous; possibilities:"),
544 argv[0], argv[d->optind]); 577 argv[0], argv[d->optind]);
578 do
579 {
580 fprintf (stderr, " '--%s'", ambig_list->p->name);
581 ambig_list = ambig_list->next;
582 }
583 while (ambig_list != NULL);
584
585 fputc ('\n', stderr);
545#endif 586#endif
546 } 587 }
547 d->__nextchar += strlen (d->__nextchar); 588 d->__nextchar += strlen (d->__nextchar);
@@ -550,6 +591,13 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
550 return '?'; 591 return '?';
551 } 592 }
552 593
594 while (ambig_list != NULL)
595 {
596 struct option_list *pn = ambig_list->next;
597 free (ambig_list);
598 ambig_list = pn;
599 }
600
553 if (pfound != NULL) 601 if (pfound != NULL)
554 { 602 {
555 option_index = indfound; 603 option_index = indfound;
@@ -740,7 +788,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
740 char c = *d->__nextchar++; 788 char c = *d->__nextchar++;
741 const char *temp = strchr (optstring, c); 789 const char *temp = strchr (optstring, c);
742 790
743 /* Increment `optind' when we start to process its last character. */ 791 /* Increment 'optind' when we start to process its last character. */
744 if (*d->__nextchar == '\0') 792 if (*d->__nextchar == '\0')
745 ++d->optind; 793 ++d->optind;
746 794
@@ -791,6 +839,9 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
791 int indfound = 0; 839 int indfound = 0;
792 int option_index; 840 int option_index;
793 841
842 if (longopts == NULL)
843 goto no_longs;
844
794 /* This is an option that requires an argument. */ 845 /* This is an option that requires an argument. */
795 if (*d->__nextchar != '\0') 846 if (*d->__nextchar != '\0')
796 { 847 {
@@ -836,7 +887,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
836 return c; 887 return c;
837 } 888 }
838 else 889 else
839 /* We already incremented `d->optind' once; 890 /* We already incremented 'd->optind' once;
840 increment it again when taking next ARGV-elt as argument. */ 891 increment it again when taking next ARGV-elt as argument. */
841 d->optarg = argv[d->optind++]; 892 d->optarg = argv[d->optind++];
842 893
@@ -998,8 +1049,10 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
998 } 1049 }
999 return pfound->val; 1050 return pfound->val;
1000 } 1051 }
1001 d->__nextchar = NULL; 1052
1002 return 'W'; /* Let the application handle it. */ 1053 no_longs:
1054 d->__nextchar = NULL;
1055 return 'W'; /* Let the application handle it. */
1003 } 1056 }
1004 if (temp[1] == ':') 1057 if (temp[1] == ':')
1005 { 1058 {
@@ -1061,7 +1114,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring,
1061 c = '?'; 1114 c = '?';
1062 } 1115 }
1063 else 1116 else
1064 /* We already incremented `optind' once; 1117 /* We already incremented 'optind' once;
1065 increment it again when taking next ARGV-elt as argument. */ 1118 increment it again when taking next ARGV-elt as argument. */
1066 d->optarg = argv[d->optind++]; 1119 d->optarg = argv[d->optind++];
1067 d->__nextchar = NULL; 1120 d->__nextchar = NULL;
@@ -1124,7 +1177,7 @@ __posix_getopt (int argc, char *const *argv, const char *optstring)
1124#ifdef TEST 1177#ifdef TEST
1125 1178
1126/* Compile with -DTEST to make an executable for use in testing 1179/* Compile with -DTEST to make an executable for use in testing
1127 the above definition of `getopt'. */ 1180 the above definition of 'getopt'. */
1128 1181
1129int 1182int
1130main (int argc, char **argv) 1183main (int argc, char **argv)
diff --git a/gl/getopt.in.h b/gl/getopt.in.h
index 57a8e89..d9c7d81 100644
--- a/gl/getopt.in.h
+++ b/gl/getopt.in.h
@@ -1,5 +1,5 @@
1/* Declarations for getopt. 1/* Declarations for getopt.
2 Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2007, 2009-2010 Free Software 2 Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2007, 2009-2013 Free Software
3 Foundation, Inc. 3 Foundation, Inc.
4 This file is part of the GNU C Library. 4 This file is part of the GNU C Library.
5 5
@@ -16,11 +16,12 @@
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 18
19#ifndef _GL_GETOPT_H 19#ifndef _@GUARD_PREFIX@_GETOPT_H
20 20
21#if __GNUC__ >= 3 21#if __GNUC__ >= 3
22@PRAGMA_SYSTEM_HEADER@ 22@PRAGMA_SYSTEM_HEADER@
23#endif 23#endif
24@PRAGMA_COLUMNS@
24 25
25/* The include_next requires a split double-inclusion guard. We must 26/* The include_next requires a split double-inclusion guard. We must
26 also inform the replacement unistd.h to not recursively use 27 also inform the replacement unistd.h to not recursively use
@@ -31,10 +32,10 @@
31# undef _GL_SYSTEM_GETOPT 32# undef _GL_SYSTEM_GETOPT
32#endif 33#endif
33 34
34#ifndef _GL_GETOPT_H 35#ifndef _@GUARD_PREFIX@_GETOPT_H
35 36
36#ifndef __need_getopt 37#ifndef __need_getopt
37# define _GL_GETOPT_H 1 38# define _@GUARD_PREFIX@_GETOPT_H 1
38#endif 39#endif
39 40
40/* Standalone applications should #define __GETOPT_PREFIX to an 41/* Standalone applications should #define __GETOPT_PREFIX to an
@@ -48,7 +49,9 @@
48 linkers. */ 49 linkers. */
49#if defined __GETOPT_PREFIX && !defined __need_getopt 50#if defined __GETOPT_PREFIX && !defined __need_getopt
50# if !@HAVE_GETOPT_H@ 51# if !@HAVE_GETOPT_H@
52# define __need_system_stdlib_h
51# include <stdlib.h> 53# include <stdlib.h>
54# undef __need_system_stdlib_h
52# include <stdio.h> 55# include <stdio.h>
53# include <unistd.h> 56# include <unistd.h>
54# endif 57# endif
@@ -81,7 +84,7 @@
81 getopt_long_only can permute argv; this is required for backward 84 getopt_long_only can permute argv; this is required for backward
82 compatibility (e.g., for LSB 2.0.1). 85 compatibility (e.g., for LSB 2.0.1).
83 86
84 This used to be `#if defined __GETOPT_PREFIX && !defined __need_getopt', 87 This used to be '#if defined __GETOPT_PREFIX && !defined __need_getopt',
85 but it caused redefinition warnings if both unistd.h and getopt.h were 88 but it caused redefinition warnings if both unistd.h and getopt.h were
86 included, since unistd.h includes getopt.h having previously defined 89 included, since unistd.h includes getopt.h having previously defined
87 __need_getopt. 90 __need_getopt.
@@ -127,29 +130,29 @@
127extern "C" { 130extern "C" {
128#endif 131#endif
129 132
130/* For communication from `getopt' to the caller. 133/* For communication from 'getopt' to the caller.
131 When `getopt' finds an option that takes an argument, 134 When 'getopt' finds an option that takes an argument,
132 the argument value is returned here. 135 the argument value is returned here.
133 Also, when `ordering' is RETURN_IN_ORDER, 136 Also, when 'ordering' is RETURN_IN_ORDER,
134 each non-option ARGV-element is returned here. */ 137 each non-option ARGV-element is returned here. */
135 138
136extern char *optarg; 139extern char *optarg;
137 140
138/* Index in ARGV of the next element to be scanned. 141/* Index in ARGV of the next element to be scanned.
139 This is used for communication to and from the caller 142 This is used for communication to and from the caller
140 and for communication between successive calls to `getopt'. 143 and for communication between successive calls to 'getopt'.
141 144
142 On entry to `getopt', zero means this is the first call; initialize. 145 On entry to 'getopt', zero means this is the first call; initialize.
143 146
144 When `getopt' returns -1, this is the index of the first of the 147 When 'getopt' returns -1, this is the index of the first of the
145 non-option elements that the caller should itself scan. 148 non-option elements that the caller should itself scan.
146 149
147 Otherwise, `optind' communicates from one call to the next 150 Otherwise, 'optind' communicates from one call to the next
148 how much of ARGV has been scanned so far. */ 151 how much of ARGV has been scanned so far. */
149 152
150extern int optind; 153extern int optind;
151 154
152/* Callers store zero here to inhibit the error message `getopt' prints 155/* Callers store zero here to inhibit the error message 'getopt' prints
153 for unrecognized options. */ 156 for unrecognized options. */
154 157
155extern int opterr; 158extern int opterr;
@@ -161,25 +164,26 @@ extern int optopt;
161#ifndef __need_getopt 164#ifndef __need_getopt
162/* Describe the long-named options requested by the application. 165/* Describe the long-named options requested by the application.
163 The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector 166 The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
164 of `struct option' terminated by an element containing a name which is 167 of 'struct option' terminated by an element containing a name which is
165 zero. 168 zero.
166 169
167 The field `has_arg' is: 170 The field 'has_arg' is:
168 no_argument (or 0) if the option does not take an argument, 171 no_argument (or 0) if the option does not take an argument,
169 required_argument (or 1) if the option requires an argument, 172 required_argument (or 1) if the option requires an argument,
170 optional_argument (or 2) if the option takes an optional argument. 173 optional_argument (or 2) if the option takes an optional argument.
171 174
172 If the field `flag' is not NULL, it points to a variable that is set 175 If the field 'flag' is not NULL, it points to a variable that is set
173 to the value given in the field `val' when the option is found, but 176 to the value given in the field 'val' when the option is found, but
174 left unchanged if the option is not found. 177 left unchanged if the option is not found.
175 178
176 To have a long-named option do something other than set an `int' to 179 To have a long-named option do something other than set an 'int' to
177 a compiled-in constant, such as set a value from `optarg', set the 180 a compiled-in constant, such as set a value from 'optarg', set the
178 option's `flag' field to zero and its `val' field to a nonzero 181 option's 'flag' field to zero and its 'val' field to a nonzero
179 value (the equivalent single-letter option character, if there is 182 value (the equivalent single-letter option character, if there is
180 one). For long options that have a zero `flag' field, `getopt' 183 one). For long options that have a zero 'flag' field, 'getopt'
181 returns the contents of the `val' field. */ 184 returns the contents of the 'val' field. */
182 185
186# if !GNULIB_defined_struct_option
183struct option 187struct option
184{ 188{
185 const char *name; 189 const char *name;
@@ -189,8 +193,10 @@ struct option
189 int *flag; 193 int *flag;
190 int val; 194 int val;
191}; 195};
196# define GNULIB_defined_struct_option 1
197# endif
192 198
193/* Names for the values of the `has_arg' field of `struct option'. */ 199/* Names for the values of the 'has_arg' field of 'struct option'. */
194 200
195# define no_argument 0 201# define no_argument 0
196# define required_argument 1 202# define required_argument 1
@@ -204,23 +210,23 @@ struct option
204 210
205 Return the option character from OPTS just read. Return -1 when 211 Return the option character from OPTS just read. Return -1 when
206 there are no more options. For unrecognized options, or options 212 there are no more options. For unrecognized options, or options
207 missing arguments, `optopt' is set to the option letter, and '?' is 213 missing arguments, 'optopt' is set to the option letter, and '?' is
208 returned. 214 returned.
209 215
210 The OPTS string is a list of characters which are recognized option 216 The OPTS string is a list of characters which are recognized option
211 letters, optionally followed by colons, specifying that that letter 217 letters, optionally followed by colons, specifying that that letter
212 takes an argument, to be placed in `optarg'. 218 takes an argument, to be placed in 'optarg'.
213 219
214 If a letter in OPTS is followed by two colons, its argument is 220 If a letter in OPTS is followed by two colons, its argument is
215 optional. This behavior is specific to the GNU `getopt'. 221 optional. This behavior is specific to the GNU 'getopt'.
216 222
217 The argument `--' causes premature termination of argument 223 The argument '--' causes premature termination of argument
218 scanning, explicitly telling `getopt' that there are no more 224 scanning, explicitly telling 'getopt' that there are no more
219 options. 225 options.
220 226
221 If OPTS begins with `-', then non-option arguments are treated as 227 If OPTS begins with '-', then non-option arguments are treated as
222 arguments to the option '\1'. This behavior is specific to the GNU 228 arguments to the option '\1'. This behavior is specific to the GNU
223 `getopt'. If OPTS begins with `+', or POSIXLY_CORRECT is set in 229 'getopt'. If OPTS begins with '+', or POSIXLY_CORRECT is set in
224 the environment, then do not permute arguments. */ 230 the environment, then do not permute arguments. */
225 231
226extern int getopt (int ___argc, char *const *___argv, const char *__shortopts) 232extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
@@ -245,5 +251,5 @@ extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
245/* Make sure we later can get all the definitions and declarations. */ 251/* Make sure we later can get all the definitions and declarations. */
246#undef __need_getopt 252#undef __need_getopt
247 253
248#endif /* getopt.h */ 254#endif /* _@GUARD_PREFIX@_GETOPT_H */
249#endif /* getopt.h */ 255#endif /* _@GUARD_PREFIX@_GETOPT_H */
diff --git a/gl/getopt1.c b/gl/getopt1.c
index 046d69f..55a6b4e 100644
--- a/gl/getopt1.c
+++ b/gl/getopt1.c
@@ -1,6 +1,6 @@
1/* getopt_long and getopt_long_only entry points for GNU getopt. 1/* getopt_long and getopt_long_only entry points for GNU getopt.
2 Copyright (C) 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997, 2 Copyright (C) 1987-1994, 1996-1998, 2004, 2006, 2009-2013 Free Software
3 1998, 2004, 2006, 2009, 2010 Free Software Foundation, Inc. 3 Foundation, Inc.
4 This file is part of the GNU C Library. 4 This file is part of the GNU C Library.
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
@@ -141,11 +141,11 @@ main (int argc, char **argv)
141 break; 141 break;
142 142
143 case 'c': 143 case 'c':
144 printf ("option c with value `%s'\n", optarg); 144 printf ("option c with value '%s'\n", optarg);
145 break; 145 break;
146 146
147 case 'd': 147 case 'd':
148 printf ("option d with value `%s'\n", optarg); 148 printf ("option d with value '%s'\n", optarg);
149 break; 149 break;
150 150
151 case '?': 151 case '?':
diff --git a/gl/getopt_int.h b/gl/getopt_int.h
index 980b750..a6e4b9e 100644
--- a/gl/getopt_int.h
+++ b/gl/getopt_int.h
@@ -1,5 +1,5 @@
1/* Internal declarations for getopt. 1/* Internal declarations for getopt.
2 Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2004, 2009-2010 Free Software 2 Copyright (C) 1989-1994, 1996-1999, 2001, 2003-2004, 2009-2013 Free Software
3 Foundation, Inc. 3 Foundation, Inc.
4 This file is part of the GNU C Library. 4 This file is part of the GNU C Library.
5 5
@@ -40,7 +40,7 @@ extern int _getopt_internal (int ___argc, char **___argv,
40 stop option processing when the first non-option is seen. 40 stop option processing when the first non-option is seen.
41 This is what Unix does. 41 This is what Unix does.
42 This mode of operation is selected by either setting the environment 42 This mode of operation is selected by either setting the environment
43 variable POSIXLY_CORRECT, or using `+' as the first character 43 variable POSIXLY_CORRECT, or using '+' as the first character
44 of the list of option characters, or by calling getopt. 44 of the list of option characters, or by calling getopt.
45 45
46 PERMUTE is the default. We permute the contents of ARGV as we 46 PERMUTE is the default. We permute the contents of ARGV as we
@@ -52,12 +52,12 @@ extern int _getopt_internal (int ___argc, char **___argv,
52 written to expect options and other ARGV-elements in any order 52 written to expect options and other ARGV-elements in any order
53 and that care about the ordering of the two. We describe each 53 and that care about the ordering of the two. We describe each
54 non-option ARGV-element as if it were the argument of an option 54 non-option ARGV-element as if it were the argument of an option
55 with character code 1. Using `-' as the first character of the 55 with character code 1. Using '-' as the first character of the
56 list of option characters selects this mode of operation. 56 list of option characters selects this mode of operation.
57 57
58 The special argument `--' forces an end of option-scanning regardless 58 The special argument '--' forces an end of option-scanning regardless
59 of the value of `ordering'. In the case of RETURN_IN_ORDER, only 59 of the value of 'ordering'. In the case of RETURN_IN_ORDER, only
60 `--' can cause `getopt' to return -1 with `optind' != ARGC. */ 60 '--' can cause 'getopt' to return -1 with 'optind' != ARGC. */
61 61
62enum __ord 62enum __ord
63 { 63 {
@@ -99,8 +99,8 @@ struct _getopt_data
99 /* Handle permutation of arguments. */ 99 /* Handle permutation of arguments. */
100 100
101 /* Describe the part of ARGV that contains non-options that have 101 /* Describe the part of ARGV that contains non-options that have
102 been skipped. `first_nonopt' is the index in ARGV of the first 102 been skipped. 'first_nonopt' is the index in ARGV of the first
103 of them; `last_nonopt' is the index after the last of them. */ 103 of them; 'last_nonopt' is the index after the last of them. */
104 104
105 int __first_nonopt; 105 int __first_nonopt;
106 int __last_nonopt; 106 int __last_nonopt;
@@ -108,7 +108,7 @@ struct _getopt_data
108#if defined _LIBC && defined USE_NONOPTION_FLAGS 108#if defined _LIBC && defined USE_NONOPTION_FLAGS
109 int __nonoption_flags_max_len; 109 int __nonoption_flags_max_len;
110 int __nonoption_flags_len; 110 int __nonoption_flags_len;
111# endif 111#endif
112}; 112};
113 113
114/* The initializer is necessary to set OPTIND and OPTERR to their 114/* The initializer is necessary to set OPTIND and OPTERR to their
diff --git a/gl/gettext.h b/gl/gettext.h
index 881ae33..d021571 100644
--- a/gl/gettext.h
+++ b/gl/gettext.h
@@ -1,5 +1,5 @@
1/* Convenience header for conditional use of GNU <libintl.h>. 1/* Convenience header for conditional use of GNU <libintl.h>.
2 Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2010 Free Software 2 Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2013 Free Software
3 Foundation, Inc. 3 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
@@ -13,8 +13,7 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License along 15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, 16 with this program; if not, see <http://www.gnu.org/licenses/>. */
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 17
19#ifndef _LIBGETTEXT_H 18#ifndef _LIBGETTEXT_H
20#define _LIBGETTEXT_H 1 19#define _LIBGETTEXT_H 1
@@ -54,7 +53,7 @@
54 it now, to make later inclusions of <libintl.h> a NOP. */ 53 it now, to make later inclusions of <libintl.h> a NOP. */
55#if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3) 54#if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3)
56# include <cstdlib> 55# include <cstdlib>
57# if (__GLIBC__ >= 2) || _GLIBCXX_HAVE_LIBINTL_H 56# if (__GLIBC__ >= 2 && !defined __UCLIBC__) || _GLIBCXX_HAVE_LIBINTL_H
58# include <libintl.h> 57# include <libintl.h>
59# endif 58# endif
60#endif 59#endif
@@ -93,6 +92,12 @@
93 92
94#endif 93#endif
95 94
95/* Prefer gnulib's setlocale override over libintl's setlocale override. */
96#ifdef GNULIB_defined_setlocale
97# undef setlocale
98# define setlocale rpl_setlocale
99#endif
100
96/* A pseudo function call that serves as a marker for the automated 101/* A pseudo function call that serves as a marker for the automated
97 extraction of messages, but does not call gettext(). The run-time 102 extraction of messages, but does not call gettext(). The run-time
98 translation is done at a different place in the code. 103 translation is done at a different place in the code.
@@ -178,9 +183,12 @@ npgettext_aux (const char *domain,
178 183
179#include <string.h> 184#include <string.h>
180 185
181#define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \ 186#if (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \
182 (((__GNUC__ >= 3 || __GNUG__ >= 2) && !__STRICT_ANSI__) \ 187 /* || __STDC_VERSION__ >= 199901L */ )
183 /* || __STDC_VERSION__ >= 199901L */ ) 188# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1
189#else
190# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 0
191#endif
184 192
185#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 193#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
186#include <stdlib.h> 194#include <stdlib.h>
diff --git a/gl/glthread/lock.c b/gl/glthread/lock.c
new file mode 100644
index 0000000..f62aa30
--- /dev/null
+++ b/gl/glthread/lock.c
@@ -0,0 +1,1057 @@
1/* Locking in multithreaded situations.
2 Copyright (C) 2005-2013 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, or (at your option)
7 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>, 2005.
18 Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-solaris.h,
19 gthr-win32.h. */
20
21#include <config.h>
22
23#include "glthread/lock.h"
24
25/* ========================================================================= */
26
27#if USE_POSIX_THREADS
28
29/* -------------------------- gl_lock_t datatype -------------------------- */
30
31/* ------------------------- gl_rwlock_t datatype ------------------------- */
32
33# if HAVE_PTHREAD_RWLOCK
34
35# if !defined PTHREAD_RWLOCK_INITIALIZER
36
37int
38glthread_rwlock_init_multithreaded (gl_rwlock_t *lock)
39{
40 int err;
41
42 err = pthread_rwlock_init (&lock->rwlock, NULL);
43 if (err != 0)
44 return err;
45 lock->initialized = 1;
46 return 0;
47}
48
49int
50glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock)
51{
52 if (!lock->initialized)
53 {
54 int err;
55
56 err = pthread_mutex_lock (&lock->guard);
57 if (err != 0)
58 return err;
59 if (!lock->initialized)
60 {
61 err = glthread_rwlock_init_multithreaded (lock);
62 if (err != 0)
63 {
64 pthread_mutex_unlock (&lock->guard);
65 return err;
66 }
67 }
68 err = pthread_mutex_unlock (&lock->guard);
69 if (err != 0)
70 return err;
71 }
72 return pthread_rwlock_rdlock (&lock->rwlock);
73}
74
75int
76glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock)
77{
78 if (!lock->initialized)
79 {
80 int err;
81
82 err = pthread_mutex_lock (&lock->guard);
83 if (err != 0)
84 return err;
85 if (!lock->initialized)
86 {
87 err = glthread_rwlock_init_multithreaded (lock);
88 if (err != 0)
89 {
90 pthread_mutex_unlock (&lock->guard);
91 return err;
92 }
93 }
94 err = pthread_mutex_unlock (&lock->guard);
95 if (err != 0)
96 return err;
97 }
98 return pthread_rwlock_wrlock (&lock->rwlock);
99}
100
101int
102glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock)
103{
104 if (!lock->initialized)
105 return EINVAL;
106 return pthread_rwlock_unlock (&lock->rwlock);
107}
108
109int
110glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock)
111{
112 int err;
113
114 if (!lock->initialized)
115 return EINVAL;
116 err = pthread_rwlock_destroy (&lock->rwlock);
117 if (err != 0)
118 return err;
119 lock->initialized = 0;
120 return 0;
121}
122
123# endif
124
125# else
126
127int
128glthread_rwlock_init_multithreaded (gl_rwlock_t *lock)
129{
130 int err;
131
132 err = pthread_mutex_init (&lock->lock, NULL);
133 if (err != 0)
134 return err;
135 err = pthread_cond_init (&lock->waiting_readers, NULL);
136 if (err != 0)
137 return err;
138 err = pthread_cond_init (&lock->waiting_writers, NULL);
139 if (err != 0)
140 return err;
141 lock->waiting_writers_count = 0;
142 lock->runcount = 0;
143 return 0;
144}
145
146int
147glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock)
148{
149 int err;
150
151 err = pthread_mutex_lock (&lock->lock);
152 if (err != 0)
153 return err;
154 /* Test whether only readers are currently running, and whether the runcount
155 field will not overflow. */
156 /* POSIX says: "It is implementation-defined whether the calling thread
157 acquires the lock when a writer does not hold the lock and there are
158 writers blocked on the lock." Let's say, no: give the writers a higher
159 priority. */
160 while (!(lock->runcount + 1 > 0 && lock->waiting_writers_count == 0))
161 {
162 /* This thread has to wait for a while. Enqueue it among the
163 waiting_readers. */
164 err = pthread_cond_wait (&lock->waiting_readers, &lock->lock);
165 if (err != 0)
166 {
167 pthread_mutex_unlock (&lock->lock);
168 return err;
169 }
170 }
171 lock->runcount++;
172 return pthread_mutex_unlock (&lock->lock);
173}
174
175int
176glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock)
177{
178 int err;
179
180 err = pthread_mutex_lock (&lock->lock);
181 if (err != 0)
182 return err;
183 /* Test whether no readers or writers are currently running. */
184 while (!(lock->runcount == 0))
185 {
186 /* This thread has to wait for a while. Enqueue it among the
187 waiting_writers. */
188 lock->waiting_writers_count++;
189 err = pthread_cond_wait (&lock->waiting_writers, &lock->lock);
190 if (err != 0)
191 {
192 lock->waiting_writers_count--;
193 pthread_mutex_unlock (&lock->lock);
194 return err;
195 }
196 lock->waiting_writers_count--;
197 }
198 lock->runcount--; /* runcount becomes -1 */
199 return pthread_mutex_unlock (&lock->lock);
200}
201
202int
203glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock)
204{
205 int err;
206
207 err = pthread_mutex_lock (&lock->lock);
208 if (err != 0)
209 return err;
210 if (lock->runcount < 0)
211 {
212 /* Drop a writer lock. */
213 if (!(lock->runcount == -1))
214 {
215 pthread_mutex_unlock (&lock->lock);
216 return EINVAL;
217 }
218 lock->runcount = 0;
219 }
220 else
221 {
222 /* Drop a reader lock. */
223 if (!(lock->runcount > 0))
224 {
225 pthread_mutex_unlock (&lock->lock);
226 return EINVAL;
227 }
228 lock->runcount--;
229 }
230 if (lock->runcount == 0)
231 {
232 /* POSIX recommends that "write locks shall take precedence over read
233 locks", to avoid "writer starvation". */
234 if (lock->waiting_writers_count > 0)
235 {
236 /* Wake up one of the waiting writers. */
237 err = pthread_cond_signal (&lock->waiting_writers);
238 if (err != 0)
239 {
240 pthread_mutex_unlock (&lock->lock);
241 return err;
242 }
243 }
244 else
245 {
246 /* Wake up all waiting readers. */
247 err = pthread_cond_broadcast (&lock->waiting_readers);
248 if (err != 0)
249 {
250 pthread_mutex_unlock (&lock->lock);
251 return err;
252 }
253 }
254 }
255 return pthread_mutex_unlock (&lock->lock);
256}
257
258int
259glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock)
260{
261 int err;
262
263 err = pthread_mutex_destroy (&lock->lock);
264 if (err != 0)
265 return err;
266 err = pthread_cond_destroy (&lock->waiting_readers);
267 if (err != 0)
268 return err;
269 err = pthread_cond_destroy (&lock->waiting_writers);
270 if (err != 0)
271 return err;
272 return 0;
273}
274
275# endif
276
277/* --------------------- gl_recursive_lock_t datatype --------------------- */
278
279# if HAVE_PTHREAD_MUTEX_RECURSIVE
280
281# if defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER || defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
282
283int
284glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock)
285{
286 pthread_mutexattr_t attributes;
287 int err;
288
289 err = pthread_mutexattr_init (&attributes);
290 if (err != 0)
291 return err;
292 err = pthread_mutexattr_settype (&attributes, PTHREAD_MUTEX_RECURSIVE);
293 if (err != 0)
294 {
295 pthread_mutexattr_destroy (&attributes);
296 return err;
297 }
298 err = pthread_mutex_init (lock, &attributes);
299 if (err != 0)
300 {
301 pthread_mutexattr_destroy (&attributes);
302 return err;
303 }
304 err = pthread_mutexattr_destroy (&attributes);
305 if (err != 0)
306 return err;
307 return 0;
308}
309
310# else
311
312int
313glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock)
314{
315 pthread_mutexattr_t attributes;
316 int err;
317
318 err = pthread_mutexattr_init (&attributes);
319 if (err != 0)
320 return err;
321 err = pthread_mutexattr_settype (&attributes, PTHREAD_MUTEX_RECURSIVE);
322 if (err != 0)
323 {
324 pthread_mutexattr_destroy (&attributes);
325 return err;
326 }
327 err = pthread_mutex_init (&lock->recmutex, &attributes);
328 if (err != 0)
329 {
330 pthread_mutexattr_destroy (&attributes);
331 return err;
332 }
333 err = pthread_mutexattr_destroy (&attributes);
334 if (err != 0)
335 return err;
336 lock->initialized = 1;
337 return 0;
338}
339
340int
341glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock)
342{
343 if (!lock->initialized)
344 {
345 int err;
346
347 err = pthread_mutex_lock (&lock->guard);
348 if (err != 0)
349 return err;
350 if (!lock->initialized)
351 {
352 err = glthread_recursive_lock_init_multithreaded (lock);
353 if (err != 0)
354 {
355 pthread_mutex_unlock (&lock->guard);
356 return err;
357 }
358 }
359 err = pthread_mutex_unlock (&lock->guard);
360 if (err != 0)
361 return err;
362 }
363 return pthread_mutex_lock (&lock->recmutex);
364}
365
366int
367glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock)
368{
369 if (!lock->initialized)
370 return EINVAL;
371 return pthread_mutex_unlock (&lock->recmutex);
372}
373
374int
375glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock)
376{
377 int err;
378
379 if (!lock->initialized)
380 return EINVAL;
381 err = pthread_mutex_destroy (&lock->recmutex);
382 if (err != 0)
383 return err;
384 lock->initialized = 0;
385 return 0;
386}
387
388# endif
389
390# else
391
392int
393glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock)
394{
395 int err;
396
397 err = pthread_mutex_init (&lock->mutex, NULL);
398 if (err != 0)
399 return err;
400 lock->owner = (pthread_t) 0;
401 lock->depth = 0;
402 return 0;
403}
404
405int
406glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock)
407{
408 pthread_t self = pthread_self ();
409 if (lock->owner != self)
410 {
411 int err;
412
413 err = pthread_mutex_lock (&lock->mutex);
414 if (err != 0)
415 return err;
416 lock->owner = self;
417 }
418 if (++(lock->depth) == 0) /* wraparound? */
419 {
420 lock->depth--;
421 return EAGAIN;
422 }
423 return 0;
424}
425
426int
427glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock)
428{
429 if (lock->owner != pthread_self ())
430 return EPERM;
431 if (lock->depth == 0)
432 return EINVAL;
433 if (--(lock->depth) == 0)
434 {
435 lock->owner = (pthread_t) 0;
436 return pthread_mutex_unlock (&lock->mutex);
437 }
438 else
439 return 0;
440}
441
442int
443glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock)
444{
445 if (lock->owner != (pthread_t) 0)
446 return EBUSY;
447 return pthread_mutex_destroy (&lock->mutex);
448}
449
450# endif
451
452/* -------------------------- gl_once_t datatype -------------------------- */
453
454static const pthread_once_t fresh_once = PTHREAD_ONCE_INIT;
455
456int
457glthread_once_singlethreaded (pthread_once_t *once_control)
458{
459 /* We don't know whether pthread_once_t is an integer type, a floating-point
460 type, a pointer type, or a structure type. */
461 char *firstbyte = (char *)once_control;
462 if (*firstbyte == *(const char *)&fresh_once)
463 {
464 /* First time use of once_control. Invert the first byte. */
465 *firstbyte = ~ *(const char *)&fresh_once;
466 return 1;
467 }
468 else
469 return 0;
470}
471
472#endif
473
474/* ========================================================================= */
475
476#if USE_PTH_THREADS
477
478/* Use the GNU Pth threads library. */
479
480/* -------------------------- gl_lock_t datatype -------------------------- */
481
482/* ------------------------- gl_rwlock_t datatype ------------------------- */
483
484/* --------------------- gl_recursive_lock_t datatype --------------------- */
485
486/* -------------------------- gl_once_t datatype -------------------------- */
487
488static void
489glthread_once_call (void *arg)
490{
491 void (**gl_once_temp_addr) (void) = (void (**) (void)) arg;
492 void (*initfunction) (void) = *gl_once_temp_addr;
493 initfunction ();
494}
495
496int
497glthread_once_multithreaded (pth_once_t *once_control, void (*initfunction) (void))
498{
499 void (*temp) (void) = initfunction;
500 return (!pth_once (once_control, glthread_once_call, &temp) ? errno : 0);
501}
502
503int
504glthread_once_singlethreaded (pth_once_t *once_control)
505{
506 /* We know that pth_once_t is an integer type. */
507 if (*once_control == PTH_ONCE_INIT)
508 {
509 /* First time use of once_control. Invert the marker. */
510 *once_control = ~ PTH_ONCE_INIT;
511 return 1;
512 }
513 else
514 return 0;
515}
516
517#endif
518
519/* ========================================================================= */
520
521#if USE_SOLARIS_THREADS
522
523/* Use the old Solaris threads library. */
524
525/* -------------------------- gl_lock_t datatype -------------------------- */
526
527/* ------------------------- gl_rwlock_t datatype ------------------------- */
528
529/* --------------------- gl_recursive_lock_t datatype --------------------- */
530
531int
532glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock)
533{
534 int err;
535
536 err = mutex_init (&lock->mutex, USYNC_THREAD, NULL);
537 if (err != 0)
538 return err;
539 lock->owner = (thread_t) 0;
540 lock->depth = 0;
541 return 0;
542}
543
544int
545glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock)
546{
547 thread_t self = thr_self ();
548 if (lock->owner != self)
549 {
550 int err;
551
552 err = mutex_lock (&lock->mutex);
553 if (err != 0)
554 return err;
555 lock->owner = self;
556 }
557 if (++(lock->depth) == 0) /* wraparound? */
558 {
559 lock->depth--;
560 return EAGAIN;
561 }
562 return 0;
563}
564
565int
566glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock)
567{
568 if (lock->owner != thr_self ())
569 return EPERM;
570 if (lock->depth == 0)
571 return EINVAL;
572 if (--(lock->depth) == 0)
573 {
574 lock->owner = (thread_t) 0;
575 return mutex_unlock (&lock->mutex);
576 }
577 else
578 return 0;
579}
580
581int
582glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock)
583{
584 if (lock->owner != (thread_t) 0)
585 return EBUSY;
586 return mutex_destroy (&lock->mutex);
587}
588
589/* -------------------------- gl_once_t datatype -------------------------- */
590
591int
592glthread_once_multithreaded (gl_once_t *once_control, void (*initfunction) (void))
593{
594 if (!once_control->inited)
595 {
596 int err;
597
598 /* Use the mutex to guarantee that if another thread is already calling
599 the initfunction, this thread waits until it's finished. */
600 err = mutex_lock (&once_control->mutex);
601 if (err != 0)
602 return err;
603 if (!once_control->inited)
604 {
605 once_control->inited = 1;
606 initfunction ();
607 }
608 return mutex_unlock (&once_control->mutex);
609 }
610 else
611 return 0;
612}
613
614int
615glthread_once_singlethreaded (gl_once_t *once_control)
616{
617 /* We know that gl_once_t contains an integer type. */
618 if (!once_control->inited)
619 {
620 /* First time use of once_control. Invert the marker. */
621 once_control->inited = ~ 0;
622 return 1;
623 }
624 else
625 return 0;
626}
627
628#endif
629
630/* ========================================================================= */
631
632#if USE_WINDOWS_THREADS
633
634/* -------------------------- gl_lock_t datatype -------------------------- */
635
636void
637glthread_lock_init_func (gl_lock_t *lock)
638{
639 InitializeCriticalSection (&lock->lock);
640 lock->guard.done = 1;
641}
642
643int
644glthread_lock_lock_func (gl_lock_t *lock)
645{
646 if (!lock->guard.done)
647 {
648 if (InterlockedIncrement (&lock->guard.started) == 0)
649 /* This thread is the first one to need this lock. Initialize it. */
650 glthread_lock_init (lock);
651 else
652 /* Yield the CPU while waiting for another thread to finish
653 initializing this lock. */
654 while (!lock->guard.done)
655 Sleep (0);
656 }
657 EnterCriticalSection (&lock->lock);
658 return 0;
659}
660
661int
662glthread_lock_unlock_func (gl_lock_t *lock)
663{
664 if (!lock->guard.done)
665 return EINVAL;
666 LeaveCriticalSection (&lock->lock);
667 return 0;
668}
669
670int
671glthread_lock_destroy_func (gl_lock_t *lock)
672{
673 if (!lock->guard.done)
674 return EINVAL;
675 DeleteCriticalSection (&lock->lock);
676 lock->guard.done = 0;
677 return 0;
678}
679
680/* ------------------------- gl_rwlock_t datatype ------------------------- */
681
682/* In this file, the waitqueues are implemented as circular arrays. */
683#define gl_waitqueue_t gl_carray_waitqueue_t
684
685static void
686gl_waitqueue_init (gl_waitqueue_t *wq)
687{
688 wq->array = NULL;
689 wq->count = 0;
690 wq->alloc = 0;
691 wq->offset = 0;
692}
693
694/* Enqueues the current thread, represented by an event, in a wait queue.
695 Returns INVALID_HANDLE_VALUE if an allocation failure occurs. */
696static HANDLE
697gl_waitqueue_add (gl_waitqueue_t *wq)
698{
699 HANDLE event;
700 unsigned int index;
701
702 if (wq->count == wq->alloc)
703 {
704 unsigned int new_alloc = 2 * wq->alloc + 1;
705 HANDLE *new_array =
706 (HANDLE *) realloc (wq->array, new_alloc * sizeof (HANDLE));
707 if (new_array == NULL)
708 /* No more memory. */
709 return INVALID_HANDLE_VALUE;
710 /* Now is a good opportunity to rotate the array so that its contents
711 starts at offset 0. */
712 if (wq->offset > 0)
713 {
714 unsigned int old_count = wq->count;
715 unsigned int old_alloc = wq->alloc;
716 unsigned int old_offset = wq->offset;
717 unsigned int i;
718 if (old_offset + old_count > old_alloc)
719 {
720 unsigned int limit = old_offset + old_count - old_alloc;
721 for (i = 0; i < limit; i++)
722 new_array[old_alloc + i] = new_array[i];
723 }
724 for (i = 0; i < old_count; i++)
725 new_array[i] = new_array[old_offset + i];
726 wq->offset = 0;
727 }
728 wq->array = new_array;
729 wq->alloc = new_alloc;
730 }
731 /* Whether the created event is a manual-reset one or an auto-reset one,
732 does not matter, since we will wait on it only once. */
733 event = CreateEvent (NULL, TRUE, FALSE, NULL);
734 if (event == INVALID_HANDLE_VALUE)
735 /* No way to allocate an event. */
736 return INVALID_HANDLE_VALUE;
737 index = wq->offset + wq->count;
738 if (index >= wq->alloc)
739 index -= wq->alloc;
740 wq->array[index] = event;
741 wq->count++;
742 return event;
743}
744
745/* Notifies the first thread from a wait queue and dequeues it. */
746static void
747gl_waitqueue_notify_first (gl_waitqueue_t *wq)
748{
749 SetEvent (wq->array[wq->offset + 0]);
750 wq->offset++;
751 wq->count--;
752 if (wq->count == 0 || wq->offset == wq->alloc)
753 wq->offset = 0;
754}
755
756/* Notifies all threads from a wait queue and dequeues them all. */
757static void
758gl_waitqueue_notify_all (gl_waitqueue_t *wq)
759{
760 unsigned int i;
761
762 for (i = 0; i < wq->count; i++)
763 {
764 unsigned int index = wq->offset + i;
765 if (index >= wq->alloc)
766 index -= wq->alloc;
767 SetEvent (wq->array[index]);
768 }
769 wq->count = 0;
770 wq->offset = 0;
771}
772
773void
774glthread_rwlock_init_func (gl_rwlock_t *lock)
775{
776 InitializeCriticalSection (&lock->lock);
777 gl_waitqueue_init (&lock->waiting_readers);
778 gl_waitqueue_init (&lock->waiting_writers);
779 lock->runcount = 0;
780 lock->guard.done = 1;
781}
782
783int
784glthread_rwlock_rdlock_func (gl_rwlock_t *lock)
785{
786 if (!lock->guard.done)
787 {
788 if (InterlockedIncrement (&lock->guard.started) == 0)
789 /* This thread is the first one to need this lock. Initialize it. */
790 glthread_rwlock_init (lock);
791 else
792 /* Yield the CPU while waiting for another thread to finish
793 initializing this lock. */
794 while (!lock->guard.done)
795 Sleep (0);
796 }
797 EnterCriticalSection (&lock->lock);
798 /* Test whether only readers are currently running, and whether the runcount
799 field will not overflow. */
800 if (!(lock->runcount + 1 > 0))
801 {
802 /* This thread has to wait for a while. Enqueue it among the
803 waiting_readers. */
804 HANDLE event = gl_waitqueue_add (&lock->waiting_readers);
805 if (event != INVALID_HANDLE_VALUE)
806 {
807 DWORD result;
808 LeaveCriticalSection (&lock->lock);
809 /* Wait until another thread signals this event. */
810 result = WaitForSingleObject (event, INFINITE);
811 if (result == WAIT_FAILED || result == WAIT_TIMEOUT)
812 abort ();
813 CloseHandle (event);
814 /* The thread which signalled the event already did the bookkeeping:
815 removed us from the waiting_readers, incremented lock->runcount. */
816 if (!(lock->runcount > 0))
817 abort ();
818 return 0;
819 }
820 else
821 {
822 /* Allocation failure. Weird. */
823 do
824 {
825 LeaveCriticalSection (&lock->lock);
826 Sleep (1);
827 EnterCriticalSection (&lock->lock);
828 }
829 while (!(lock->runcount + 1 > 0));
830 }
831 }
832 lock->runcount++;
833 LeaveCriticalSection (&lock->lock);
834 return 0;
835}
836
837int
838glthread_rwlock_wrlock_func (gl_rwlock_t *lock)
839{
840 if (!lock->guard.done)
841 {
842 if (InterlockedIncrement (&lock->guard.started) == 0)
843 /* This thread is the first one to need this lock. Initialize it. */
844 glthread_rwlock_init (lock);
845 else
846 /* Yield the CPU while waiting for another thread to finish
847 initializing this lock. */
848 while (!lock->guard.done)
849 Sleep (0);
850 }
851 EnterCriticalSection (&lock->lock);
852 /* Test whether no readers or writers are currently running. */
853 if (!(lock->runcount == 0))
854 {
855 /* This thread has to wait for a while. Enqueue it among the
856 waiting_writers. */
857 HANDLE event = gl_waitqueue_add (&lock->waiting_writers);
858 if (event != INVALID_HANDLE_VALUE)
859 {
860 DWORD result;
861 LeaveCriticalSection (&lock->lock);
862 /* Wait until another thread signals this event. */
863 result = WaitForSingleObject (event, INFINITE);
864 if (result == WAIT_FAILED || result == WAIT_TIMEOUT)
865 abort ();
866 CloseHandle (event);
867 /* The thread which signalled the event already did the bookkeeping:
868 removed us from the waiting_writers, set lock->runcount = -1. */
869 if (!(lock->runcount == -1))
870 abort ();
871 return 0;
872 }
873 else
874 {
875 /* Allocation failure. Weird. */
876 do
877 {
878 LeaveCriticalSection (&lock->lock);
879 Sleep (1);
880 EnterCriticalSection (&lock->lock);
881 }
882 while (!(lock->runcount == 0));
883 }
884 }
885 lock->runcount--; /* runcount becomes -1 */
886 LeaveCriticalSection (&lock->lock);
887 return 0;
888}
889
890int
891glthread_rwlock_unlock_func (gl_rwlock_t *lock)
892{
893 if (!lock->guard.done)
894 return EINVAL;
895 EnterCriticalSection (&lock->lock);
896 if (lock->runcount < 0)
897 {
898 /* Drop a writer lock. */
899 if (!(lock->runcount == -1))
900 abort ();
901 lock->runcount = 0;
902 }
903 else
904 {
905 /* Drop a reader lock. */
906 if (!(lock->runcount > 0))
907 {
908 LeaveCriticalSection (&lock->lock);
909 return EPERM;
910 }
911 lock->runcount--;
912 }
913 if (lock->runcount == 0)
914 {
915 /* POSIX recommends that "write locks shall take precedence over read
916 locks", to avoid "writer starvation". */
917 if (lock->waiting_writers.count > 0)
918 {
919 /* Wake up one of the waiting writers. */
920 lock->runcount--;
921 gl_waitqueue_notify_first (&lock->waiting_writers);
922 }
923 else
924 {
925 /* Wake up all waiting readers. */
926 lock->runcount += lock->waiting_readers.count;
927 gl_waitqueue_notify_all (&lock->waiting_readers);
928 }
929 }
930 LeaveCriticalSection (&lock->lock);
931 return 0;
932}
933
934int
935glthread_rwlock_destroy_func (gl_rwlock_t *lock)
936{
937 if (!lock->guard.done)
938 return EINVAL;
939 if (lock->runcount != 0)
940 return EBUSY;
941 DeleteCriticalSection (&lock->lock);
942 if (lock->waiting_readers.array != NULL)
943 free (lock->waiting_readers.array);
944 if (lock->waiting_writers.array != NULL)
945 free (lock->waiting_writers.array);
946 lock->guard.done = 0;
947 return 0;
948}
949
950/* --------------------- gl_recursive_lock_t datatype --------------------- */
951
952void
953glthread_recursive_lock_init_func (gl_recursive_lock_t *lock)
954{
955 lock->owner = 0;
956 lock->depth = 0;
957 InitializeCriticalSection (&lock->lock);
958 lock->guard.done = 1;
959}
960
961int
962glthread_recursive_lock_lock_func (gl_recursive_lock_t *lock)
963{
964 if (!lock->guard.done)
965 {
966 if (InterlockedIncrement (&lock->guard.started) == 0)
967 /* This thread is the first one to need this lock. Initialize it. */
968 glthread_recursive_lock_init (lock);
969 else
970 /* Yield the CPU while waiting for another thread to finish
971 initializing this lock. */
972 while (!lock->guard.done)
973 Sleep (0);
974 }
975 {
976 DWORD self = GetCurrentThreadId ();
977 if (lock->owner != self)
978 {
979 EnterCriticalSection (&lock->lock);
980 lock->owner = self;
981 }
982 if (++(lock->depth) == 0) /* wraparound? */
983 {
984 lock->depth--;
985 return EAGAIN;
986 }
987 }
988 return 0;
989}
990
991int
992glthread_recursive_lock_unlock_func (gl_recursive_lock_t *lock)
993{
994 if (lock->owner != GetCurrentThreadId ())
995 return EPERM;
996 if (lock->depth == 0)
997 return EINVAL;
998 if (--(lock->depth) == 0)
999 {
1000 lock->owner = 0;
1001 LeaveCriticalSection (&lock->lock);
1002 }
1003 return 0;
1004}
1005
1006int
1007glthread_recursive_lock_destroy_func (gl_recursive_lock_t *lock)
1008{
1009 if (lock->owner != 0)
1010 return EBUSY;
1011 DeleteCriticalSection (&lock->lock);
1012 lock->guard.done = 0;
1013 return 0;
1014}
1015
1016/* -------------------------- gl_once_t datatype -------------------------- */
1017
1018void
1019glthread_once_func (gl_once_t *once_control, void (*initfunction) (void))
1020{
1021 if (once_control->inited <= 0)
1022 {
1023 if (InterlockedIncrement (&once_control->started) == 0)
1024 {
1025 /* This thread is the first one to come to this once_control. */
1026 InitializeCriticalSection (&once_control->lock);
1027 EnterCriticalSection (&once_control->lock);
1028 once_control->inited = 0;
1029 initfunction ();
1030 once_control->inited = 1;
1031 LeaveCriticalSection (&once_control->lock);
1032 }
1033 else
1034 {
1035 /* Undo last operation. */
1036 InterlockedDecrement (&once_control->started);
1037 /* Some other thread has already started the initialization.
1038 Yield the CPU while waiting for the other thread to finish
1039 initializing and taking the lock. */
1040 while (once_control->inited < 0)
1041 Sleep (0);
1042 if (once_control->inited <= 0)
1043 {
1044 /* Take the lock. This blocks until the other thread has
1045 finished calling the initfunction. */
1046 EnterCriticalSection (&once_control->lock);
1047 LeaveCriticalSection (&once_control->lock);
1048 if (!(once_control->inited > 0))
1049 abort ();
1050 }
1051 }
1052 }
1053}
1054
1055#endif
1056
1057/* ========================================================================= */
diff --git a/gl/glthread/lock.h b/gl/glthread/lock.h
new file mode 100644
index 0000000..d20bbde
--- /dev/null
+++ b/gl/glthread/lock.h
@@ -0,0 +1,927 @@
1/* Locking in multithreaded situations.
2 Copyright (C) 2005-2013 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, or (at your option)
7 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>, 2005.
18 Based on GCC's gthr-posix.h, gthr-posix95.h, gthr-solaris.h,
19 gthr-win32.h. */
20
21/* This file contains locking primitives for use with a given thread library.
22 It does not contain primitives for creating threads or for other
23 synchronization primitives.
24
25 Normal (non-recursive) locks:
26 Type: gl_lock_t
27 Declaration: gl_lock_define(extern, name)
28 Initializer: gl_lock_define_initialized(, name)
29 Initialization: gl_lock_init (name);
30 Taking the lock: gl_lock_lock (name);
31 Releasing the lock: gl_lock_unlock (name);
32 De-initialization: gl_lock_destroy (name);
33 Equivalent functions with control of error handling:
34 Initialization: err = glthread_lock_init (&name);
35 Taking the lock: err = glthread_lock_lock (&name);
36 Releasing the lock: err = glthread_lock_unlock (&name);
37 De-initialization: err = glthread_lock_destroy (&name);
38
39 Read-Write (non-recursive) locks:
40 Type: gl_rwlock_t
41 Declaration: gl_rwlock_define(extern, name)
42 Initializer: gl_rwlock_define_initialized(, name)
43 Initialization: gl_rwlock_init (name);
44 Taking the lock: gl_rwlock_rdlock (name);
45 gl_rwlock_wrlock (name);
46 Releasing the lock: gl_rwlock_unlock (name);
47 De-initialization: gl_rwlock_destroy (name);
48 Equivalent functions with control of error handling:
49 Initialization: err = glthread_rwlock_init (&name);
50 Taking the lock: err = glthread_rwlock_rdlock (&name);
51 err = glthread_rwlock_wrlock (&name);
52 Releasing the lock: err = glthread_rwlock_unlock (&name);
53 De-initialization: err = glthread_rwlock_destroy (&name);
54
55 Recursive locks:
56 Type: gl_recursive_lock_t
57 Declaration: gl_recursive_lock_define(extern, name)
58 Initializer: gl_recursive_lock_define_initialized(, name)
59 Initialization: gl_recursive_lock_init (name);
60 Taking the lock: gl_recursive_lock_lock (name);
61 Releasing the lock: gl_recursive_lock_unlock (name);
62 De-initialization: gl_recursive_lock_destroy (name);
63 Equivalent functions with control of error handling:
64 Initialization: err = glthread_recursive_lock_init (&name);
65 Taking the lock: err = glthread_recursive_lock_lock (&name);
66 Releasing the lock: err = glthread_recursive_lock_unlock (&name);
67 De-initialization: err = glthread_recursive_lock_destroy (&name);
68
69 Once-only execution:
70 Type: gl_once_t
71 Initializer: gl_once_define(extern, name)
72 Execution: gl_once (name, initfunction);
73 Equivalent functions with control of error handling:
74 Execution: err = glthread_once (&name, initfunction);
75*/
76
77
78#ifndef _LOCK_H
79#define _LOCK_H
80
81#include <errno.h>
82#include <stdlib.h>
83
84/* ========================================================================= */
85
86#if USE_POSIX_THREADS
87
88/* Use the POSIX threads library. */
89
90# include <pthread.h>
91
92# ifdef __cplusplus
93extern "C" {
94# endif
95
96# if PTHREAD_IN_USE_DETECTION_HARD
97
98/* The pthread_in_use() detection needs to be done at runtime. */
99# define pthread_in_use() \
100 glthread_in_use ()
101extern int glthread_in_use (void);
102
103# endif
104
105# if USE_POSIX_THREADS_WEAK
106
107/* Use weak references to the POSIX threads library. */
108
109/* Weak references avoid dragging in external libraries if the other parts
110 of the program don't use them. Here we use them, because we don't want
111 every program that uses libintl to depend on libpthread. This assumes
112 that libpthread would not be loaded after libintl; i.e. if libintl is
113 loaded first, by an executable that does not depend on libpthread, and
114 then a module is dynamically loaded that depends on libpthread, libintl
115 will not be multithread-safe. */
116
117/* The way to test at runtime whether libpthread is present is to test
118 whether a function pointer's value, such as &pthread_mutex_init, is
119 non-NULL. However, some versions of GCC have a bug through which, in
120 PIC mode, &foo != NULL always evaluates to true if there is a direct
121 call to foo(...) in the same function. To avoid this, we test the
122 address of a function in libpthread that we don't use. */
123
124# pragma weak pthread_mutex_init
125# pragma weak pthread_mutex_lock
126# pragma weak pthread_mutex_unlock
127# pragma weak pthread_mutex_destroy
128# pragma weak pthread_rwlock_init
129# pragma weak pthread_rwlock_rdlock
130# pragma weak pthread_rwlock_wrlock
131# pragma weak pthread_rwlock_unlock
132# pragma weak pthread_rwlock_destroy
133# pragma weak pthread_once
134# pragma weak pthread_cond_init
135# pragma weak pthread_cond_wait
136# pragma weak pthread_cond_signal
137# pragma weak pthread_cond_broadcast
138# pragma weak pthread_cond_destroy
139# pragma weak pthread_mutexattr_init
140# pragma weak pthread_mutexattr_settype
141# pragma weak pthread_mutexattr_destroy
142# ifndef pthread_self
143# pragma weak pthread_self
144# endif
145
146# if !PTHREAD_IN_USE_DETECTION_HARD
147# pragma weak pthread_cancel
148# define pthread_in_use() (pthread_cancel != NULL)
149# endif
150
151# else
152
153# if !PTHREAD_IN_USE_DETECTION_HARD
154# define pthread_in_use() 1
155# endif
156
157# endif
158
159/* -------------------------- gl_lock_t datatype -------------------------- */
160
161typedef pthread_mutex_t gl_lock_t;
162# define gl_lock_define(STORAGECLASS, NAME) \
163 STORAGECLASS pthread_mutex_t NAME;
164# define gl_lock_define_initialized(STORAGECLASS, NAME) \
165 STORAGECLASS pthread_mutex_t NAME = gl_lock_initializer;
166# define gl_lock_initializer \
167 PTHREAD_MUTEX_INITIALIZER
168# define glthread_lock_init(LOCK) \
169 (pthread_in_use () ? pthread_mutex_init (LOCK, NULL) : 0)
170# define glthread_lock_lock(LOCK) \
171 (pthread_in_use () ? pthread_mutex_lock (LOCK) : 0)
172# define glthread_lock_unlock(LOCK) \
173 (pthread_in_use () ? pthread_mutex_unlock (LOCK) : 0)
174# define glthread_lock_destroy(LOCK) \
175 (pthread_in_use () ? pthread_mutex_destroy (LOCK) : 0)
176
177/* ------------------------- gl_rwlock_t datatype ------------------------- */
178
179# if HAVE_PTHREAD_RWLOCK
180
181# ifdef PTHREAD_RWLOCK_INITIALIZER
182
183typedef pthread_rwlock_t gl_rwlock_t;
184# define gl_rwlock_define(STORAGECLASS, NAME) \
185 STORAGECLASS pthread_rwlock_t NAME;
186# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
187 STORAGECLASS pthread_rwlock_t NAME = gl_rwlock_initializer;
188# define gl_rwlock_initializer \
189 PTHREAD_RWLOCK_INITIALIZER
190# define glthread_rwlock_init(LOCK) \
191 (pthread_in_use () ? pthread_rwlock_init (LOCK, NULL) : 0)
192# define glthread_rwlock_rdlock(LOCK) \
193 (pthread_in_use () ? pthread_rwlock_rdlock (LOCK) : 0)
194# define glthread_rwlock_wrlock(LOCK) \
195 (pthread_in_use () ? pthread_rwlock_wrlock (LOCK) : 0)
196# define glthread_rwlock_unlock(LOCK) \
197 (pthread_in_use () ? pthread_rwlock_unlock (LOCK) : 0)
198# define glthread_rwlock_destroy(LOCK) \
199 (pthread_in_use () ? pthread_rwlock_destroy (LOCK) : 0)
200
201# else
202
203typedef struct
204 {
205 int initialized;
206 pthread_mutex_t guard; /* protects the initialization */
207 pthread_rwlock_t rwlock; /* read-write lock */
208 }
209 gl_rwlock_t;
210# define gl_rwlock_define(STORAGECLASS, NAME) \
211 STORAGECLASS gl_rwlock_t NAME;
212# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
213 STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer;
214# define gl_rwlock_initializer \
215 { 0, PTHREAD_MUTEX_INITIALIZER }
216# define glthread_rwlock_init(LOCK) \
217 (pthread_in_use () ? glthread_rwlock_init_multithreaded (LOCK) : 0)
218# define glthread_rwlock_rdlock(LOCK) \
219 (pthread_in_use () ? glthread_rwlock_rdlock_multithreaded (LOCK) : 0)
220# define glthread_rwlock_wrlock(LOCK) \
221 (pthread_in_use () ? glthread_rwlock_wrlock_multithreaded (LOCK) : 0)
222# define glthread_rwlock_unlock(LOCK) \
223 (pthread_in_use () ? glthread_rwlock_unlock_multithreaded (LOCK) : 0)
224# define glthread_rwlock_destroy(LOCK) \
225 (pthread_in_use () ? glthread_rwlock_destroy_multithreaded (LOCK) : 0)
226extern int glthread_rwlock_init_multithreaded (gl_rwlock_t *lock);
227extern int glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock);
228extern int glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock);
229extern int glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock);
230extern int glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock);
231
232# endif
233
234# else
235
236typedef struct
237 {
238 pthread_mutex_t lock; /* protects the remaining fields */
239 pthread_cond_t waiting_readers; /* waiting readers */
240 pthread_cond_t waiting_writers; /* waiting writers */
241 unsigned int waiting_writers_count; /* number of waiting writers */
242 int runcount; /* number of readers running, or -1 when a writer runs */
243 }
244 gl_rwlock_t;
245# define gl_rwlock_define(STORAGECLASS, NAME) \
246 STORAGECLASS gl_rwlock_t NAME;
247# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
248 STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer;
249# define gl_rwlock_initializer \
250 { PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, PTHREAD_COND_INITIALIZER, 0, 0 }
251# define glthread_rwlock_init(LOCK) \
252 (pthread_in_use () ? glthread_rwlock_init_multithreaded (LOCK) : 0)
253# define glthread_rwlock_rdlock(LOCK) \
254 (pthread_in_use () ? glthread_rwlock_rdlock_multithreaded (LOCK) : 0)
255# define glthread_rwlock_wrlock(LOCK) \
256 (pthread_in_use () ? glthread_rwlock_wrlock_multithreaded (LOCK) : 0)
257# define glthread_rwlock_unlock(LOCK) \
258 (pthread_in_use () ? glthread_rwlock_unlock_multithreaded (LOCK) : 0)
259# define glthread_rwlock_destroy(LOCK) \
260 (pthread_in_use () ? glthread_rwlock_destroy_multithreaded (LOCK) : 0)
261extern int glthread_rwlock_init_multithreaded (gl_rwlock_t *lock);
262extern int glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock);
263extern int glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock);
264extern int glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock);
265extern int glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock);
266
267# endif
268
269/* --------------------- gl_recursive_lock_t datatype --------------------- */
270
271# if HAVE_PTHREAD_MUTEX_RECURSIVE
272
273# if defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER || defined PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
274
275typedef pthread_mutex_t gl_recursive_lock_t;
276# define gl_recursive_lock_define(STORAGECLASS, NAME) \
277 STORAGECLASS pthread_mutex_t NAME;
278# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
279 STORAGECLASS pthread_mutex_t NAME = gl_recursive_lock_initializer;
280# ifdef PTHREAD_RECURSIVE_MUTEX_INITIALIZER
281# define gl_recursive_lock_initializer \
282 PTHREAD_RECURSIVE_MUTEX_INITIALIZER
283# else
284# define gl_recursive_lock_initializer \
285 PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
286# endif
287# define glthread_recursive_lock_init(LOCK) \
288 (pthread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0)
289# define glthread_recursive_lock_lock(LOCK) \
290 (pthread_in_use () ? pthread_mutex_lock (LOCK) : 0)
291# define glthread_recursive_lock_unlock(LOCK) \
292 (pthread_in_use () ? pthread_mutex_unlock (LOCK) : 0)
293# define glthread_recursive_lock_destroy(LOCK) \
294 (pthread_in_use () ? pthread_mutex_destroy (LOCK) : 0)
295extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock);
296
297# else
298
299typedef struct
300 {
301 pthread_mutex_t recmutex; /* recursive mutex */
302 pthread_mutex_t guard; /* protects the initialization */
303 int initialized;
304 }
305 gl_recursive_lock_t;
306# define gl_recursive_lock_define(STORAGECLASS, NAME) \
307 STORAGECLASS gl_recursive_lock_t NAME;
308# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
309 STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer;
310# define gl_recursive_lock_initializer \
311 { PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, 0 }
312# define glthread_recursive_lock_init(LOCK) \
313 (pthread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0)
314# define glthread_recursive_lock_lock(LOCK) \
315 (pthread_in_use () ? glthread_recursive_lock_lock_multithreaded (LOCK) : 0)
316# define glthread_recursive_lock_unlock(LOCK) \
317 (pthread_in_use () ? glthread_recursive_lock_unlock_multithreaded (LOCK) : 0)
318# define glthread_recursive_lock_destroy(LOCK) \
319 (pthread_in_use () ? glthread_recursive_lock_destroy_multithreaded (LOCK) : 0)
320extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock);
321extern int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock);
322extern int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock);
323extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock);
324
325# endif
326
327# else
328
329/* Old versions of POSIX threads on Solaris did not have recursive locks.
330 We have to implement them ourselves. */
331
332typedef struct
333 {
334 pthread_mutex_t mutex;
335 pthread_t owner;
336 unsigned long depth;
337 }
338 gl_recursive_lock_t;
339# define gl_recursive_lock_define(STORAGECLASS, NAME) \
340 STORAGECLASS gl_recursive_lock_t NAME;
341# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
342 STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer;
343# define gl_recursive_lock_initializer \
344 { PTHREAD_MUTEX_INITIALIZER, (pthread_t) 0, 0 }
345# define glthread_recursive_lock_init(LOCK) \
346 (pthread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0)
347# define glthread_recursive_lock_lock(LOCK) \
348 (pthread_in_use () ? glthread_recursive_lock_lock_multithreaded (LOCK) : 0)
349# define glthread_recursive_lock_unlock(LOCK) \
350 (pthread_in_use () ? glthread_recursive_lock_unlock_multithreaded (LOCK) : 0)
351# define glthread_recursive_lock_destroy(LOCK) \
352 (pthread_in_use () ? glthread_recursive_lock_destroy_multithreaded (LOCK) : 0)
353extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock);
354extern int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock);
355extern int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock);
356extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock);
357
358# endif
359
360/* -------------------------- gl_once_t datatype -------------------------- */
361
362typedef pthread_once_t gl_once_t;
363# define gl_once_define(STORAGECLASS, NAME) \
364 STORAGECLASS pthread_once_t NAME = PTHREAD_ONCE_INIT;
365# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
366 (pthread_in_use () \
367 ? pthread_once (ONCE_CONTROL, INITFUNCTION) \
368 : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0))
369extern int glthread_once_singlethreaded (pthread_once_t *once_control);
370
371# ifdef __cplusplus
372}
373# endif
374
375#endif
376
377/* ========================================================================= */
378
379#if USE_PTH_THREADS
380
381/* Use the GNU Pth threads library. */
382
383# include <pth.h>
384
385# ifdef __cplusplus
386extern "C" {
387# endif
388
389# if USE_PTH_THREADS_WEAK
390
391/* Use weak references to the GNU Pth threads library. */
392
393# pragma weak pth_mutex_init
394# pragma weak pth_mutex_acquire
395# pragma weak pth_mutex_release
396# pragma weak pth_rwlock_init
397# pragma weak pth_rwlock_acquire
398# pragma weak pth_rwlock_release
399# pragma weak pth_once
400
401# pragma weak pth_cancel
402# define pth_in_use() (pth_cancel != NULL)
403
404# else
405
406# define pth_in_use() 1
407
408# endif
409
410/* -------------------------- gl_lock_t datatype -------------------------- */
411
412typedef pth_mutex_t gl_lock_t;
413# define gl_lock_define(STORAGECLASS, NAME) \
414 STORAGECLASS pth_mutex_t NAME;
415# define gl_lock_define_initialized(STORAGECLASS, NAME) \
416 STORAGECLASS pth_mutex_t NAME = gl_lock_initializer;
417# define gl_lock_initializer \
418 PTH_MUTEX_INIT
419# define glthread_lock_init(LOCK) \
420 (pth_in_use () && !pth_mutex_init (LOCK) ? errno : 0)
421# define glthread_lock_lock(LOCK) \
422 (pth_in_use () && !pth_mutex_acquire (LOCK, 0, NULL) ? errno : 0)
423# define glthread_lock_unlock(LOCK) \
424 (pth_in_use () && !pth_mutex_release (LOCK) ? errno : 0)
425# define glthread_lock_destroy(LOCK) \
426 ((void)(LOCK), 0)
427
428/* ------------------------- gl_rwlock_t datatype ------------------------- */
429
430typedef pth_rwlock_t gl_rwlock_t;
431# define gl_rwlock_define(STORAGECLASS, NAME) \
432 STORAGECLASS pth_rwlock_t NAME;
433# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
434 STORAGECLASS pth_rwlock_t NAME = gl_rwlock_initializer;
435# define gl_rwlock_initializer \
436 PTH_RWLOCK_INIT
437# define glthread_rwlock_init(LOCK) \
438 (pth_in_use () && !pth_rwlock_init (LOCK) ? errno : 0)
439# define glthread_rwlock_rdlock(LOCK) \
440 (pth_in_use () && !pth_rwlock_acquire (LOCK, PTH_RWLOCK_RD, 0, NULL) ? errno : 0)
441# define glthread_rwlock_wrlock(LOCK) \
442 (pth_in_use () && !pth_rwlock_acquire (LOCK, PTH_RWLOCK_RW, 0, NULL) ? errno : 0)
443# define glthread_rwlock_unlock(LOCK) \
444 (pth_in_use () && !pth_rwlock_release (LOCK) ? errno : 0)
445# define glthread_rwlock_destroy(LOCK) \
446 ((void)(LOCK), 0)
447
448/* --------------------- gl_recursive_lock_t datatype --------------------- */
449
450/* In Pth, mutexes are recursive by default. */
451typedef pth_mutex_t gl_recursive_lock_t;
452# define gl_recursive_lock_define(STORAGECLASS, NAME) \
453 STORAGECLASS pth_mutex_t NAME;
454# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
455 STORAGECLASS pth_mutex_t NAME = gl_recursive_lock_initializer;
456# define gl_recursive_lock_initializer \
457 PTH_MUTEX_INIT
458# define glthread_recursive_lock_init(LOCK) \
459 (pth_in_use () && !pth_mutex_init (LOCK) ? errno : 0)
460# define glthread_recursive_lock_lock(LOCK) \
461 (pth_in_use () && !pth_mutex_acquire (LOCK, 0, NULL) ? errno : 0)
462# define glthread_recursive_lock_unlock(LOCK) \
463 (pth_in_use () && !pth_mutex_release (LOCK) ? errno : 0)
464# define glthread_recursive_lock_destroy(LOCK) \
465 ((void)(LOCK), 0)
466
467/* -------------------------- gl_once_t datatype -------------------------- */
468
469typedef pth_once_t gl_once_t;
470# define gl_once_define(STORAGECLASS, NAME) \
471 STORAGECLASS pth_once_t NAME = PTH_ONCE_INIT;
472# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
473 (pth_in_use () \
474 ? glthread_once_multithreaded (ONCE_CONTROL, INITFUNCTION) \
475 : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0))
476extern int glthread_once_multithreaded (pth_once_t *once_control, void (*initfunction) (void));
477extern int glthread_once_singlethreaded (pth_once_t *once_control);
478
479# ifdef __cplusplus
480}
481# endif
482
483#endif
484
485/* ========================================================================= */
486
487#if USE_SOLARIS_THREADS
488
489/* Use the old Solaris threads library. */
490
491# include <thread.h>
492# include <synch.h>
493
494# ifdef __cplusplus
495extern "C" {
496# endif
497
498# if USE_SOLARIS_THREADS_WEAK
499
500/* Use weak references to the old Solaris threads library. */
501
502# pragma weak mutex_init
503# pragma weak mutex_lock
504# pragma weak mutex_unlock
505# pragma weak mutex_destroy
506# pragma weak rwlock_init
507# pragma weak rw_rdlock
508# pragma weak rw_wrlock
509# pragma weak rw_unlock
510# pragma weak rwlock_destroy
511# pragma weak thr_self
512
513# pragma weak thr_suspend
514# define thread_in_use() (thr_suspend != NULL)
515
516# else
517
518# define thread_in_use() 1
519
520# endif
521
522/* -------------------------- gl_lock_t datatype -------------------------- */
523
524typedef mutex_t gl_lock_t;
525# define gl_lock_define(STORAGECLASS, NAME) \
526 STORAGECLASS mutex_t NAME;
527# define gl_lock_define_initialized(STORAGECLASS, NAME) \
528 STORAGECLASS mutex_t NAME = gl_lock_initializer;
529# define gl_lock_initializer \
530 DEFAULTMUTEX
531# define glthread_lock_init(LOCK) \
532 (thread_in_use () ? mutex_init (LOCK, USYNC_THREAD, NULL) : 0)
533# define glthread_lock_lock(LOCK) \
534 (thread_in_use () ? mutex_lock (LOCK) : 0)
535# define glthread_lock_unlock(LOCK) \
536 (thread_in_use () ? mutex_unlock (LOCK) : 0)
537# define glthread_lock_destroy(LOCK) \
538 (thread_in_use () ? mutex_destroy (LOCK) : 0)
539
540/* ------------------------- gl_rwlock_t datatype ------------------------- */
541
542typedef rwlock_t gl_rwlock_t;
543# define gl_rwlock_define(STORAGECLASS, NAME) \
544 STORAGECLASS rwlock_t NAME;
545# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
546 STORAGECLASS rwlock_t NAME = gl_rwlock_initializer;
547# define gl_rwlock_initializer \
548 DEFAULTRWLOCK
549# define glthread_rwlock_init(LOCK) \
550 (thread_in_use () ? rwlock_init (LOCK, USYNC_THREAD, NULL) : 0)
551# define glthread_rwlock_rdlock(LOCK) \
552 (thread_in_use () ? rw_rdlock (LOCK) : 0)
553# define glthread_rwlock_wrlock(LOCK) \
554 (thread_in_use () ? rw_wrlock (LOCK) : 0)
555# define glthread_rwlock_unlock(LOCK) \
556 (thread_in_use () ? rw_unlock (LOCK) : 0)
557# define glthread_rwlock_destroy(LOCK) \
558 (thread_in_use () ? rwlock_destroy (LOCK) : 0)
559
560/* --------------------- gl_recursive_lock_t datatype --------------------- */
561
562/* Old Solaris threads did not have recursive locks.
563 We have to implement them ourselves. */
564
565typedef struct
566 {
567 mutex_t mutex;
568 thread_t owner;
569 unsigned long depth;
570 }
571 gl_recursive_lock_t;
572# define gl_recursive_lock_define(STORAGECLASS, NAME) \
573 STORAGECLASS gl_recursive_lock_t NAME;
574# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
575 STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer;
576# define gl_recursive_lock_initializer \
577 { DEFAULTMUTEX, (thread_t) 0, 0 }
578# define glthread_recursive_lock_init(LOCK) \
579 (thread_in_use () ? glthread_recursive_lock_init_multithreaded (LOCK) : 0)
580# define glthread_recursive_lock_lock(LOCK) \
581 (thread_in_use () ? glthread_recursive_lock_lock_multithreaded (LOCK) : 0)
582# define glthread_recursive_lock_unlock(LOCK) \
583 (thread_in_use () ? glthread_recursive_lock_unlock_multithreaded (LOCK) : 0)
584# define glthread_recursive_lock_destroy(LOCK) \
585 (thread_in_use () ? glthread_recursive_lock_destroy_multithreaded (LOCK) : 0)
586extern int glthread_recursive_lock_init_multithreaded (gl_recursive_lock_t *lock);
587extern int glthread_recursive_lock_lock_multithreaded (gl_recursive_lock_t *lock);
588extern int glthread_recursive_lock_unlock_multithreaded (gl_recursive_lock_t *lock);
589extern int glthread_recursive_lock_destroy_multithreaded (gl_recursive_lock_t *lock);
590
591/* -------------------------- gl_once_t datatype -------------------------- */
592
593typedef struct
594 {
595 volatile int inited;
596 mutex_t mutex;
597 }
598 gl_once_t;
599# define gl_once_define(STORAGECLASS, NAME) \
600 STORAGECLASS gl_once_t NAME = { 0, DEFAULTMUTEX };
601# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
602 (thread_in_use () \
603 ? glthread_once_multithreaded (ONCE_CONTROL, INITFUNCTION) \
604 : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0))
605extern int glthread_once_multithreaded (gl_once_t *once_control, void (*initfunction) (void));
606extern int glthread_once_singlethreaded (gl_once_t *once_control);
607
608# ifdef __cplusplus
609}
610# endif
611
612#endif
613
614/* ========================================================================= */
615
616#if USE_WINDOWS_THREADS
617
618# define WIN32_LEAN_AND_MEAN /* avoid including junk */
619# include <windows.h>
620
621# ifdef __cplusplus
622extern "C" {
623# endif
624
625/* We can use CRITICAL_SECTION directly, rather than the native Windows Event,
626 Mutex, Semaphore types, because
627 - we need only to synchronize inside a single process (address space),
628 not inter-process locking,
629 - we don't need to support trylock operations. (TryEnterCriticalSection
630 does not work on Windows 95/98/ME. Packages that need trylock usually
631 define their own mutex type.) */
632
633/* There is no way to statically initialize a CRITICAL_SECTION. It needs
634 to be done lazily, once only. For this we need spinlocks. */
635
636typedef struct { volatile int done; volatile long started; } gl_spinlock_t;
637
638/* -------------------------- gl_lock_t datatype -------------------------- */
639
640typedef struct
641 {
642 gl_spinlock_t guard; /* protects the initialization */
643 CRITICAL_SECTION lock;
644 }
645 gl_lock_t;
646# define gl_lock_define(STORAGECLASS, NAME) \
647 STORAGECLASS gl_lock_t NAME;
648# define gl_lock_define_initialized(STORAGECLASS, NAME) \
649 STORAGECLASS gl_lock_t NAME = gl_lock_initializer;
650# define gl_lock_initializer \
651 { { 0, -1 } }
652# define glthread_lock_init(LOCK) \
653 (glthread_lock_init_func (LOCK), 0)
654# define glthread_lock_lock(LOCK) \
655 glthread_lock_lock_func (LOCK)
656# define glthread_lock_unlock(LOCK) \
657 glthread_lock_unlock_func (LOCK)
658# define glthread_lock_destroy(LOCK) \
659 glthread_lock_destroy_func (LOCK)
660extern void glthread_lock_init_func (gl_lock_t *lock);
661extern int glthread_lock_lock_func (gl_lock_t *lock);
662extern int glthread_lock_unlock_func (gl_lock_t *lock);
663extern int glthread_lock_destroy_func (gl_lock_t *lock);
664
665/* ------------------------- gl_rwlock_t datatype ------------------------- */
666
667/* It is impossible to implement read-write locks using plain locks, without
668 introducing an extra thread dedicated to managing read-write locks.
669 Therefore here we need to use the low-level Event type. */
670
671typedef struct
672 {
673 HANDLE *array; /* array of waiting threads, each represented by an event */
674 unsigned int count; /* number of waiting threads */
675 unsigned int alloc; /* length of allocated array */
676 unsigned int offset; /* index of first waiting thread in array */
677 }
678 gl_carray_waitqueue_t;
679typedef struct
680 {
681 gl_spinlock_t guard; /* protects the initialization */
682 CRITICAL_SECTION lock; /* protects the remaining fields */
683 gl_carray_waitqueue_t waiting_readers; /* waiting readers */
684 gl_carray_waitqueue_t waiting_writers; /* waiting writers */
685 int runcount; /* number of readers running, or -1 when a writer runs */
686 }
687 gl_rwlock_t;
688# define gl_rwlock_define(STORAGECLASS, NAME) \
689 STORAGECLASS gl_rwlock_t NAME;
690# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \
691 STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer;
692# define gl_rwlock_initializer \
693 { { 0, -1 } }
694# define glthread_rwlock_init(LOCK) \
695 (glthread_rwlock_init_func (LOCK), 0)
696# define glthread_rwlock_rdlock(LOCK) \
697 glthread_rwlock_rdlock_func (LOCK)
698# define glthread_rwlock_wrlock(LOCK) \
699 glthread_rwlock_wrlock_func (LOCK)
700# define glthread_rwlock_unlock(LOCK) \
701 glthread_rwlock_unlock_func (LOCK)
702# define glthread_rwlock_destroy(LOCK) \
703 glthread_rwlock_destroy_func (LOCK)
704extern void glthread_rwlock_init_func (gl_rwlock_t *lock);
705extern int glthread_rwlock_rdlock_func (gl_rwlock_t *lock);
706extern int glthread_rwlock_wrlock_func (gl_rwlock_t *lock);
707extern int glthread_rwlock_unlock_func (gl_rwlock_t *lock);
708extern int glthread_rwlock_destroy_func (gl_rwlock_t *lock);
709
710/* --------------------- gl_recursive_lock_t datatype --------------------- */
711
712/* The native Windows documentation says that CRITICAL_SECTION already
713 implements a recursive lock. But we need not rely on it: It's easy to
714 implement a recursive lock without this assumption. */
715
716typedef struct
717 {
718 gl_spinlock_t guard; /* protects the initialization */
719 DWORD owner;
720 unsigned long depth;
721 CRITICAL_SECTION lock;
722 }
723 gl_recursive_lock_t;
724# define gl_recursive_lock_define(STORAGECLASS, NAME) \
725 STORAGECLASS gl_recursive_lock_t NAME;
726# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \
727 STORAGECLASS gl_recursive_lock_t NAME = gl_recursive_lock_initializer;
728# define gl_recursive_lock_initializer \
729 { { 0, -1 }, 0, 0 }
730# define glthread_recursive_lock_init(LOCK) \
731 (glthread_recursive_lock_init_func (LOCK), 0)
732# define glthread_recursive_lock_lock(LOCK) \
733 glthread_recursive_lock_lock_func (LOCK)
734# define glthread_recursive_lock_unlock(LOCK) \
735 glthread_recursive_lock_unlock_func (LOCK)
736# define glthread_recursive_lock_destroy(LOCK) \
737 glthread_recursive_lock_destroy_func (LOCK)
738extern void glthread_recursive_lock_init_func (gl_recursive_lock_t *lock);
739extern int glthread_recursive_lock_lock_func (gl_recursive_lock_t *lock);
740extern int glthread_recursive_lock_unlock_func (gl_recursive_lock_t *lock);
741extern int glthread_recursive_lock_destroy_func (gl_recursive_lock_t *lock);
742
743/* -------------------------- gl_once_t datatype -------------------------- */
744
745typedef struct
746 {
747 volatile int inited;
748 volatile long started;
749 CRITICAL_SECTION lock;
750 }
751 gl_once_t;
752# define gl_once_define(STORAGECLASS, NAME) \
753 STORAGECLASS gl_once_t NAME = { -1, -1 };
754# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
755 (glthread_once_func (ONCE_CONTROL, INITFUNCTION), 0)
756extern void glthread_once_func (gl_once_t *once_control, void (*initfunction) (void));
757
758# ifdef __cplusplus
759}
760# endif
761
762#endif
763
764/* ========================================================================= */
765
766#if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_SOLARIS_THREADS || USE_WINDOWS_THREADS)
767
768/* Provide dummy implementation if threads are not supported. */
769
770/* -------------------------- gl_lock_t datatype -------------------------- */
771
772typedef int gl_lock_t;
773# define gl_lock_define(STORAGECLASS, NAME)
774# define gl_lock_define_initialized(STORAGECLASS, NAME)
775# define glthread_lock_init(NAME) 0
776# define glthread_lock_lock(NAME) 0
777# define glthread_lock_unlock(NAME) 0
778# define glthread_lock_destroy(NAME) 0
779
780/* ------------------------- gl_rwlock_t datatype ------------------------- */
781
782typedef int gl_rwlock_t;
783# define gl_rwlock_define(STORAGECLASS, NAME)
784# define gl_rwlock_define_initialized(STORAGECLASS, NAME)
785# define glthread_rwlock_init(NAME) 0
786# define glthread_rwlock_rdlock(NAME) 0
787# define glthread_rwlock_wrlock(NAME) 0
788# define glthread_rwlock_unlock(NAME) 0
789# define glthread_rwlock_destroy(NAME) 0
790
791/* --------------------- gl_recursive_lock_t datatype --------------------- */
792
793typedef int gl_recursive_lock_t;
794# define gl_recursive_lock_define(STORAGECLASS, NAME)
795# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME)
796# define glthread_recursive_lock_init(NAME) 0
797# define glthread_recursive_lock_lock(NAME) 0
798# define glthread_recursive_lock_unlock(NAME) 0
799# define glthread_recursive_lock_destroy(NAME) 0
800
801/* -------------------------- gl_once_t datatype -------------------------- */
802
803typedef int gl_once_t;
804# define gl_once_define(STORAGECLASS, NAME) \
805 STORAGECLASS gl_once_t NAME = 0;
806# define glthread_once(ONCE_CONTROL, INITFUNCTION) \
807 (*(ONCE_CONTROL) == 0 ? (*(ONCE_CONTROL) = ~ 0, INITFUNCTION (), 0) : 0)
808
809#endif
810
811/* ========================================================================= */
812
813/* Macros with built-in error handling. */
814
815/* -------------------------- gl_lock_t datatype -------------------------- */
816
817#define gl_lock_init(NAME) \
818 do \
819 { \
820 if (glthread_lock_init (&NAME)) \
821 abort (); \
822 } \
823 while (0)
824#define gl_lock_lock(NAME) \
825 do \
826 { \
827 if (glthread_lock_lock (&NAME)) \
828 abort (); \
829 } \
830 while (0)
831#define gl_lock_unlock(NAME) \
832 do \
833 { \
834 if (glthread_lock_unlock (&NAME)) \
835 abort (); \
836 } \
837 while (0)
838#define gl_lock_destroy(NAME) \
839 do \
840 { \
841 if (glthread_lock_destroy (&NAME)) \
842 abort (); \
843 } \
844 while (0)
845
846/* ------------------------- gl_rwlock_t datatype ------------------------- */
847
848#define gl_rwlock_init(NAME) \
849 do \
850 { \
851 if (glthread_rwlock_init (&NAME)) \
852 abort (); \
853 } \
854 while (0)
855#define gl_rwlock_rdlock(NAME) \
856 do \
857 { \
858 if (glthread_rwlock_rdlock (&NAME)) \
859 abort (); \
860 } \
861 while (0)
862#define gl_rwlock_wrlock(NAME) \
863 do \
864 { \
865 if (glthread_rwlock_wrlock (&NAME)) \
866 abort (); \
867 } \
868 while (0)
869#define gl_rwlock_unlock(NAME) \
870 do \
871 { \
872 if (glthread_rwlock_unlock (&NAME)) \
873 abort (); \
874 } \
875 while (0)
876#define gl_rwlock_destroy(NAME) \
877 do \
878 { \
879 if (glthread_rwlock_destroy (&NAME)) \
880 abort (); \
881 } \
882 while (0)
883
884/* --------------------- gl_recursive_lock_t datatype --------------------- */
885
886#define gl_recursive_lock_init(NAME) \
887 do \
888 { \
889 if (glthread_recursive_lock_init (&NAME)) \
890 abort (); \
891 } \
892 while (0)
893#define gl_recursive_lock_lock(NAME) \
894 do \
895 { \
896 if (glthread_recursive_lock_lock (&NAME)) \
897 abort (); \
898 } \
899 while (0)
900#define gl_recursive_lock_unlock(NAME) \
901 do \
902 { \
903 if (glthread_recursive_lock_unlock (&NAME)) \
904 abort (); \
905 } \
906 while (0)
907#define gl_recursive_lock_destroy(NAME) \
908 do \
909 { \
910 if (glthread_recursive_lock_destroy (&NAME)) \
911 abort (); \
912 } \
913 while (0)
914
915/* -------------------------- gl_once_t datatype -------------------------- */
916
917#define gl_once(NAME, INITFUNCTION) \
918 do \
919 { \
920 if (glthread_once (&NAME, INITFUNCTION)) \
921 abort (); \
922 } \
923 while (0)
924
925/* ========================================================================= */
926
927#endif /* _LOCK_H */
diff --git a/gl/glthread/threadlib.c b/gl/glthread/threadlib.c
new file mode 100644
index 0000000..b447657
--- /dev/null
+++ b/gl/glthread/threadlib.c
@@ -0,0 +1,73 @@
1/* Multithreading primitives.
2 Copyright (C) 2005-2013 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, or (at your option)
7 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>, 2005. */
18
19#include <config.h>
20
21/* ========================================================================= */
22
23#if USE_POSIX_THREADS
24
25/* Use the POSIX threads library. */
26
27# include <pthread.h>
28# include <stdlib.h>
29
30# if PTHREAD_IN_USE_DETECTION_HARD
31
32/* The function to be executed by a dummy thread. */
33static void *
34dummy_thread_func (void *arg)
35{
36 return arg;
37}
38
39int
40glthread_in_use (void)
41{
42 static int tested;
43 static int result; /* 1: linked with -lpthread, 0: only with libc */
44
45 if (!tested)
46 {
47 pthread_t thread;
48
49 if (pthread_create (&thread, NULL, dummy_thread_func, NULL) != 0)
50 /* Thread creation failed. */
51 result = 0;
52 else
53 {
54 /* Thread creation works. */
55 void *retval;
56 if (pthread_join (thread, &retval) != 0)
57 abort ();
58 result = 1;
59 }
60 tested = 1;
61 }
62 return result;
63}
64
65# endif
66
67#endif
68
69/* ========================================================================= */
70
71/* This declaration is solely to ensure that after preprocessing
72 this file is never empty. */
73typedef int dummy;
diff --git a/gl/inet_ntop.c b/gl/inet_ntop.c
index baaa23f..fdfd21d 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, 2008-2010 Free Software Foundation, Inc. 3 Copyright (C) 2005-2006, 2008-2013 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
@@ -13,8 +13,7 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
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, write to the Free Software Foundation, 16 along with this program; if not, see <http://www.gnu.org/licenses/>. */
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 17
19/* 18/*
20 * Copyright (c) 1996-1999 by Internet Software Consortium. 19 * Copyright (c) 1996-1999 by Internet Software Consortium.
@@ -38,30 +37,53 @@
38/* Specification. */ 37/* Specification. */
39#include <arpa/inet.h> 38#include <arpa/inet.h>
40 39
41#include <stdio.h> 40/* Use this to suppress gcc's "...may be used before initialized" warnings.
42#include <string.h> 41 Beware: The Code argument must not contain commas. */
43#include <errno.h> 42#ifndef IF_LINT
43# ifdef lint
44# define IF_LINT(Code) Code
45# else
46# define IF_LINT(Code) /* empty */
47# endif
48#endif
49
50#if HAVE_DECL_INET_NTOP
51
52# undef inet_ntop
53
54const char *
55rpl_inet_ntop (int af, const void *restrict src,
56 char *restrict dst, socklen_t cnt)
57{
58 return inet_ntop (af, src, dst, cnt);
59}
44 60
45#define NS_IN6ADDRSZ 16 61#else
46#define NS_INT16SZ 2 62
63# include <stdio.h>
64# include <string.h>
65# include <errno.h>
66
67# define NS_IN6ADDRSZ 16
68# define NS_INT16SZ 2
47 69
48/* 70/*
49 * WARNING: Don't even consider trying to compile this on a system where 71 * WARNING: Don't even consider trying to compile this on a system where
50 * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. 72 * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
51 */ 73 */
52typedef int verify_int_size[2 * sizeof (int) - 7]; 74typedef int verify_int_size[4 <= sizeof (int) ? 1 : -1];
53 75
54static const char *inet_ntop4 (const unsigned char *src, char *dst, socklen_t size); 76static const char *inet_ntop4 (const unsigned char *src, char *dst, socklen_t size);
55#if HAVE_IPV6 77# if HAVE_IPV6
56static const char *inet_ntop6 (const unsigned char *src, char *dst, socklen_t size); 78static const char *inet_ntop6 (const unsigned char *src, char *dst, socklen_t size);
57#endif 79# endif
58 80
59 81
60/* char * 82/* char *
61 * inet_ntop(af, src, dst, size) 83 * inet_ntop(af, src, dst, size)
62 * convert a network format address to presentation format. 84 * convert a network format address to presentation format.
63 * return: 85 * return:
64 * pointer to presentation format address (`dst'), or NULL (see errno). 86 * pointer to presentation format address ('dst'), or NULL (see errno).
65 * author: 87 * author:
66 * Paul Vixie, 1996. 88 * Paul Vixie, 1996.
67 */ 89 */
@@ -71,15 +93,15 @@ inet_ntop (int af, const void *restrict src,
71{ 93{
72 switch (af) 94 switch (af)
73 { 95 {
74#if HAVE_IPV4 96# if HAVE_IPV4
75 case AF_INET: 97 case AF_INET:
76 return (inet_ntop4 (src, dst, cnt)); 98 return (inet_ntop4 (src, dst, cnt));
77#endif 99# endif
78 100
79#if HAVE_IPV6 101# if HAVE_IPV6
80 case AF_INET6: 102 case AF_INET6:
81 return (inet_ntop6 (src, dst, cnt)); 103 return (inet_ntop6 (src, dst, cnt));
82#endif 104# endif
83 105
84 default: 106 default:
85 errno = EAFNOSUPPORT; 107 errno = EAFNOSUPPORT;
@@ -92,7 +114,7 @@ inet_ntop (int af, const void *restrict src,
92 * inet_ntop4(src, dst, size) 114 * inet_ntop4(src, dst, size)
93 * format an IPv4 address 115 * format an IPv4 address
94 * return: 116 * return:
95 * `dst' (as a const) 117 * 'dst' (as a const)
96 * notes: 118 * notes:
97 * (1) uses no statics 119 * (1) uses no statics
98 * (2) takes a u_char* not an in_addr as input 120 * (2) takes a u_char* not an in_addr as input
@@ -118,7 +140,7 @@ inet_ntop4 (const unsigned char *src, char *dst, socklen_t size)
118 return strcpy (dst, tmp); 140 return strcpy (dst, tmp);
119} 141}
120 142
121#if HAVE_IPV6 143# if HAVE_IPV6
122 144
123/* const char * 145/* const char *
124 * inet_ntop6(src, dst, size) 146 * inet_ntop6(src, dst, size)
@@ -154,6 +176,8 @@ inet_ntop6 (const unsigned char *src, char *dst, socklen_t size)
154 words[i / 2] = (src[i] << 8) | src[i + 1]; 176 words[i / 2] = (src[i] << 8) | src[i + 1];
155 best.base = -1; 177 best.base = -1;
156 cur.base = -1; 178 cur.base = -1;
179 IF_LINT(best.len = 0);
180 IF_LINT(cur.len = 0);
157 for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) 181 for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++)
158 { 182 {
159 if (words[i] == 0) 183 if (words[i] == 0)
@@ -231,4 +255,6 @@ inet_ntop6 (const unsigned char *src, char *dst, socklen_t size)
231 return strcpy (dst, tmp); 255 return strcpy (dst, tmp);
232} 256}
233 257
258# endif
259
234#endif 260#endif
diff --git a/gl/intprops.h b/gl/intprops.h
index 46f4d47..f57f9b4 100644
--- a/gl/intprops.h
+++ b/gl/intprops.h
@@ -1,7 +1,6 @@
1/* intprops.h -- properties of integer types 1/* intprops.h -- properties of integer types
2 2
3 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2009, 2010 Free Software 3 Copyright (C) 2001-2005, 2009-2013 Free Software Foundation, Inc.
4 Foundation, Inc.
5 4
6 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
7 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
@@ -18,66 +17,303 @@
18 17
19/* Written by Paul Eggert. */ 18/* Written by Paul Eggert. */
20 19
21#ifndef GL_INTPROPS_H 20#ifndef _GL_INTPROPS_H
22# define GL_INTPROPS_H 21#define _GL_INTPROPS_H
23 22
24# include <limits.h> 23#include <limits.h>
24
25/* Return an integer value, converted to the same type as the integer
26 expression E after integer type promotion. V is the unconverted value. */
27#define _GL_INT_CONVERT(e, v) (0 * (e) + (v))
28
29/* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see
30 <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00406.html>. */
31#define _GL_INT_NEGATE_CONVERT(e, v) (0 * (e) - (v))
25 32
26/* The extra casts in the following macros work around compiler bugs, 33/* The extra casts in the following macros work around compiler bugs,
27 e.g., in Cray C 5.0.3.0. */ 34 e.g., in Cray C 5.0.3.0. */
28 35
29/* True if the arithmetic type T is an integer type. bool counts as 36/* True if the arithmetic type T is an integer type. bool counts as
30 an integer. */ 37 an integer. */
31# define TYPE_IS_INTEGER(t) ((t) 1.5 == 1) 38#define TYPE_IS_INTEGER(t) ((t) 1.5 == 1)
32 39
33/* True if negative values of the signed integer type T use two's 40/* True if negative values of the signed integer type T use two's
34 complement, ones' complement, or signed magnitude representation, 41 complement, ones' complement, or signed magnitude representation,
35 respectively. Much GNU code assumes two's complement, but some 42 respectively. Much GNU code assumes two's complement, but some
36 people like to be portable to all possible C hosts. */ 43 people like to be portable to all possible C hosts. */
37# define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1) 44#define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1)
38# define TYPE_ONES_COMPLEMENT(t) ((t) ~ (t) 0 == 0) 45#define TYPE_ONES_COMPLEMENT(t) ((t) ~ (t) 0 == 0)
39# define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1) 46#define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1)
47
48/* True if the signed integer expression E uses two's complement. */
49#define _GL_INT_TWOS_COMPLEMENT(e) (~ _GL_INT_CONVERT (e, 0) == -1)
40 50
41/* True if the arithmetic type T is signed. */ 51/* True if the arithmetic type T is signed. */
42# define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) 52#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
43 53
44/* The maximum and minimum values for the integer type T. These 54/* Return 1 if the integer expression E, after integer promotion, has
55 a signed type. */
56#define _GL_INT_SIGNED(e) (_GL_INT_NEGATE_CONVERT (e, 1) < 0)
57
58
59/* Minimum and maximum values for integer types and expressions. These
45 macros have undefined behavior if T is signed and has padding bits. 60 macros have undefined behavior if T is signed and has padding bits.
46 If this is a problem for you, please let us know how to fix it for 61 If this is a problem for you, please let us know how to fix it for
47 your host. */ 62 your host. */
48# define TYPE_MINIMUM(t) \ 63
49 ((t) (! TYPE_SIGNED (t) \ 64/* The maximum and minimum values for the integer type T. */
50 ? (t) 0 \ 65#define TYPE_MINIMUM(t) \
51 : TYPE_SIGNED_MAGNITUDE (t) \ 66 ((t) (! TYPE_SIGNED (t) \
52 ? ~ (t) 0 \ 67 ? (t) 0 \
53 : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))) 68 : TYPE_SIGNED_MAGNITUDE (t) \
54# define TYPE_MAXIMUM(t) \ 69 ? ~ (t) 0 \
55 ((t) (! TYPE_SIGNED (t) \ 70 : ~ TYPE_MAXIMUM (t)))
56 ? (t) -1 \ 71#define TYPE_MAXIMUM(t) \
57 : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))) 72 ((t) (! TYPE_SIGNED (t) \
58 73 ? (t) -1 \
59/* Return zero if T can be determined to be an unsigned type. 74 : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1)))
60 Otherwise, return 1. 75
61 When compiling with GCC, INT_STRLEN_BOUND uses this macro to obtain a 76/* The maximum and minimum values for the type of the expression E,
62 tighter bound. Otherwise, it overestimates the true bound by one byte 77 after integer promotion. E should not have side effects. */
63 when applied to unsigned types of size 2, 4, 16, ... bytes. 78#define _GL_INT_MINIMUM(e) \
64 The symbol signed_type_or_expr__ is private to this header file. */ 79 (_GL_INT_SIGNED (e) \
65# if __GNUC__ >= 2 80 ? - _GL_INT_TWOS_COMPLEMENT (e) - _GL_SIGNED_INT_MAXIMUM (e) \
66# define signed_type_or_expr__(t) TYPE_SIGNED (__typeof__ (t)) 81 : _GL_INT_CONVERT (e, 0))
67# else 82#define _GL_INT_MAXIMUM(e) \
68# define signed_type_or_expr__(t) 1 83 (_GL_INT_SIGNED (e) \
69# endif 84 ? _GL_SIGNED_INT_MAXIMUM (e) \
85 : _GL_INT_NEGATE_CONVERT (e, 1))
86#define _GL_SIGNED_INT_MAXIMUM(e) \
87 (((_GL_INT_CONVERT (e, 1) << (sizeof ((e) + 0) * CHAR_BIT - 2)) - 1) * 2 + 1)
88
89
90/* Return 1 if the __typeof__ keyword works. This could be done by
91 'configure', but for now it's easier to do it by hand. */
92#if 2 <= __GNUC__ || defined __IBM__TYPEOF__ || 0x5110 <= __SUNPRO_C
93# define _GL_HAVE___TYPEOF__ 1
94#else
95# define _GL_HAVE___TYPEOF__ 0
96#endif
97
98/* Return 1 if the integer type or expression T might be signed. Return 0
99 if it is definitely unsigned. This macro does not evaluate its argument,
100 and expands to an integer constant expression. */
101#if _GL_HAVE___TYPEOF__
102# define _GL_SIGNED_TYPE_OR_EXPR(t) TYPE_SIGNED (__typeof__ (t))
103#else
104# define _GL_SIGNED_TYPE_OR_EXPR(t) 1
105#endif
106
107/* Bound on length of the string representing an unsigned integer
108 value representable in B bits. log10 (2.0) < 146/485. The
109 smallest value of B where this bound is not tight is 2621. */
110#define INT_BITS_STRLEN_BOUND(b) (((b) * 146 + 484) / 485)
70 111
71/* Bound on length of the string representing an integer type or expression T. 112/* Bound on length of the string representing an integer type or expression T.
72 Subtract 1 for the sign bit if T is signed; log10 (2.0) < 146/485; 113 Subtract 1 for the sign bit if T is signed, and then add 1 more for
73 add 1 for integer division truncation; add 1 more for a minus sign 114 a minus sign if needed.
74 if needed. */ 115
75# define INT_STRLEN_BOUND(t) \ 116 Because _GL_SIGNED_TYPE_OR_EXPR sometimes returns 0 when its argument is
76 ((sizeof (t) * CHAR_BIT - signed_type_or_expr__ (t)) * 146 / 485 \ 117 signed, this macro may overestimate the true bound by one byte when
77 + signed_type_or_expr__ (t) + 1) 118 applied to unsigned types of size 2, 4, 16, ... bytes. */
119#define INT_STRLEN_BOUND(t) \
120 (INT_BITS_STRLEN_BOUND (sizeof (t) * CHAR_BIT \
121 - _GL_SIGNED_TYPE_OR_EXPR (t)) \
122 + _GL_SIGNED_TYPE_OR_EXPR (t))
78 123
79/* Bound on buffer size needed to represent an integer type or expression T, 124/* Bound on buffer size needed to represent an integer type or expression T,
80 including the terminating null. */ 125 including the terminating null. */
81# define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1) 126#define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1)
127
128
129/* Range overflow checks.
130
131 The INT_<op>_RANGE_OVERFLOW macros return 1 if the corresponding C
132 operators might not yield numerically correct answers due to
133 arithmetic overflow. They do not rely on undefined or
134 implementation-defined behavior. Their implementations are simple
135 and straightforward, but they are a bit harder to use than the
136 INT_<op>_OVERFLOW macros described below.
137
138 Example usage:
139
140 long int i = ...;
141 long int j = ...;
142 if (INT_MULTIPLY_RANGE_OVERFLOW (i, j, LONG_MIN, LONG_MAX))
143 printf ("multiply would overflow");
144 else
145 printf ("product is %ld", i * j);
146
147 Restrictions on *_RANGE_OVERFLOW macros:
148
149 These macros do not check for all possible numerical problems or
150 undefined or unspecified behavior: they do not check for division
151 by zero, for bad shift counts, or for shifting negative numbers.
152
153 These macros may evaluate their arguments zero or multiple times,
154 so the arguments should not have side effects. The arithmetic
155 arguments (including the MIN and MAX arguments) must be of the same
156 integer type after the usual arithmetic conversions, and the type
157 must have minimum value MIN and maximum MAX. Unsigned types should
158 use a zero MIN of the proper type.
159
160 These macros are tuned for constant MIN and MAX. For commutative
161 operations such as A + B, they are also tuned for constant B. */
162
163/* Return 1 if A + B would overflow in [MIN,MAX] arithmetic.
164 See above for restrictions. */
165#define INT_ADD_RANGE_OVERFLOW(a, b, min, max) \
166 ((b) < 0 \
167 ? (a) < (min) - (b) \
168 : (max) - (b) < (a))
169
170/* Return 1 if A - B would overflow in [MIN,MAX] arithmetic.
171 See above for restrictions. */
172#define INT_SUBTRACT_RANGE_OVERFLOW(a, b, min, max) \
173 ((b) < 0 \
174 ? (max) + (b) < (a) \
175 : (a) < (min) + (b))
176
177/* Return 1 if - A would overflow in [MIN,MAX] arithmetic.
178 See above for restrictions. */
179#define INT_NEGATE_RANGE_OVERFLOW(a, min, max) \
180 ((min) < 0 \
181 ? (a) < - (max) \
182 : 0 < (a))
183
184/* Return 1 if A * B would overflow in [MIN,MAX] arithmetic.
185 See above for restrictions. Avoid && and || as they tickle
186 bugs in Sun C 5.11 2010/08/13 and other compilers; see
187 <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00401.html>. */
188#define INT_MULTIPLY_RANGE_OVERFLOW(a, b, min, max) \
189 ((b) < 0 \
190 ? ((a) < 0 \
191 ? (a) < (max) / (b) \
192 : (b) == -1 \
193 ? 0 \
194 : (min) / (b) < (a)) \
195 : (b) == 0 \
196 ? 0 \
197 : ((a) < 0 \
198 ? (a) < (min) / (b) \
199 : (max) / (b) < (a)))
200
201/* Return 1 if A / B would overflow in [MIN,MAX] arithmetic.
202 See above for restrictions. Do not check for division by zero. */
203#define INT_DIVIDE_RANGE_OVERFLOW(a, b, min, max) \
204 ((min) < 0 && (b) == -1 && (a) < - (max))
205
206/* Return 1 if A % B would overflow in [MIN,MAX] arithmetic.
207 See above for restrictions. Do not check for division by zero.
208 Mathematically, % should never overflow, but on x86-like hosts
209 INT_MIN % -1 traps, and the C standard permits this, so treat this
210 as an overflow too. */
211#define INT_REMAINDER_RANGE_OVERFLOW(a, b, min, max) \
212 INT_DIVIDE_RANGE_OVERFLOW (a, b, min, max)
213
214/* Return 1 if A << B would overflow in [MIN,MAX] arithmetic.
215 See above for restrictions. Here, MIN and MAX are for A only, and B need
216 not be of the same type as the other arguments. The C standard says that
217 behavior is undefined for shifts unless 0 <= B < wordwidth, and that when
218 A is negative then A << B has undefined behavior and A >> B has
219 implementation-defined behavior, but do not check these other
220 restrictions. */
221#define INT_LEFT_SHIFT_RANGE_OVERFLOW(a, b, min, max) \
222 ((a) < 0 \
223 ? (a) < (min) >> (b) \
224 : (max) >> (b) < (a))
225
226
227/* The _GL*_OVERFLOW macros have the same restrictions as the
228 *_RANGE_OVERFLOW macros, except that they do not assume that operands
229 (e.g., A and B) have the same type as MIN and MAX. Instead, they assume
230 that the result (e.g., A + B) has that type. */
231#define _GL_ADD_OVERFLOW(a, b, min, max) \
232 ((min) < 0 ? INT_ADD_RANGE_OVERFLOW (a, b, min, max) \
233 : (a) < 0 ? (b) <= (a) + (b) \
234 : (b) < 0 ? (a) <= (a) + (b) \
235 : (a) + (b) < (b))
236#define _GL_SUBTRACT_OVERFLOW(a, b, min, max) \
237 ((min) < 0 ? INT_SUBTRACT_RANGE_OVERFLOW (a, b, min, max) \
238 : (a) < 0 ? 1 \
239 : (b) < 0 ? (a) - (b) <= (a) \
240 : (a) < (b))
241#define _GL_MULTIPLY_OVERFLOW(a, b, min, max) \
242 (((min) == 0 && (((a) < 0 && 0 < (b)) || ((b) < 0 && 0 < (a)))) \
243 || INT_MULTIPLY_RANGE_OVERFLOW (a, b, min, max))
244#define _GL_DIVIDE_OVERFLOW(a, b, min, max) \
245 ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \
246 : (a) < 0 ? (b) <= (a) + (b) - 1 \
247 : (b) < 0 && (a) + (b) <= (a))
248#define _GL_REMAINDER_OVERFLOW(a, b, min, max) \
249 ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max) \
250 : (a) < 0 ? (a) % (b) != ((max) - (b) + 1) % (b) \
251 : (b) < 0 && ! _GL_UNSIGNED_NEG_MULTIPLE (a, b, max))
252
253/* Return a nonzero value if A is a mathematical multiple of B, where
254 A is unsigned, B is negative, and MAX is the maximum value of A's
255 type. A's type must be the same as (A % B)'s type. Normally (A %
256 -B == 0) suffices, but things get tricky if -B would overflow. */
257#define _GL_UNSIGNED_NEG_MULTIPLE(a, b, max) \
258 (((b) < -_GL_SIGNED_INT_MAXIMUM (b) \
259 ? (_GL_SIGNED_INT_MAXIMUM (b) == (max) \
260 ? (a) \
261 : (a) % (_GL_INT_CONVERT (a, _GL_SIGNED_INT_MAXIMUM (b)) + 1)) \
262 : (a) % - (b)) \
263 == 0)
264
265
266/* Integer overflow checks.
267
268 The INT_<op>_OVERFLOW macros return 1 if the corresponding C operators
269 might not yield numerically correct answers due to arithmetic overflow.
270 They work correctly on all known practical hosts, and do not rely
271 on undefined behavior due to signed arithmetic overflow.
272
273 Example usage:
274
275 long int i = ...;
276 long int j = ...;
277 if (INT_MULTIPLY_OVERFLOW (i, j))
278 printf ("multiply would overflow");
279 else
280 printf ("product is %ld", i * j);
281
282 These macros do not check for all possible numerical problems or
283 undefined or unspecified behavior: they do not check for division
284 by zero, for bad shift counts, or for shifting negative numbers.
285
286 These macros may evaluate their arguments zero or multiple times, so the
287 arguments should not have side effects.
288
289 These macros are tuned for their last argument being a constant.
290
291 Return 1 if the integer expressions A * B, A - B, -A, A * B, A / B,
292 A % B, and A << B would overflow, respectively. */
293
294#define INT_ADD_OVERFLOW(a, b) \
295 _GL_BINARY_OP_OVERFLOW (a, b, _GL_ADD_OVERFLOW)
296#define INT_SUBTRACT_OVERFLOW(a, b) \
297 _GL_BINARY_OP_OVERFLOW (a, b, _GL_SUBTRACT_OVERFLOW)
298#define INT_NEGATE_OVERFLOW(a) \
299 INT_NEGATE_RANGE_OVERFLOW (a, _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a))
300#define INT_MULTIPLY_OVERFLOW(a, b) \
301 _GL_BINARY_OP_OVERFLOW (a, b, _GL_MULTIPLY_OVERFLOW)
302#define INT_DIVIDE_OVERFLOW(a, b) \
303 _GL_BINARY_OP_OVERFLOW (a, b, _GL_DIVIDE_OVERFLOW)
304#define INT_REMAINDER_OVERFLOW(a, b) \
305 _GL_BINARY_OP_OVERFLOW (a, b, _GL_REMAINDER_OVERFLOW)
306#define INT_LEFT_SHIFT_OVERFLOW(a, b) \
307 INT_LEFT_SHIFT_RANGE_OVERFLOW (a, b, \
308 _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a))
309
310/* Return 1 if the expression A <op> B would overflow,
311 where OP_RESULT_OVERFLOW (A, B, MIN, MAX) does the actual test,
312 assuming MIN and MAX are the minimum and maximum for the result type.
313 Arguments should be free of side effects. */
314#define _GL_BINARY_OP_OVERFLOW(a, b, op_result_overflow) \
315 op_result_overflow (a, b, \
316 _GL_INT_MINIMUM (0 * (b) + (a)), \
317 _GL_INT_MAXIMUM (0 * (b) + (a)))
82 318
83#endif /* GL_INTPROPS_H */ 319#endif /* _GL_INTPROPS_H */
diff --git a/gl/creat-safer.c b/gl/itold.c
index da0418d..9aabc7e 100644
--- a/gl/creat-safer.c
+++ b/gl/itold.c
@@ -1,6 +1,6 @@
1/* Invoke creat, but avoid some glitches. 1/* Replacement for 'int' to 'long double' conversion routine.
2 2 Copyright (C) 2011-2013 Free Software Foundation, Inc.
3 Copyright (C) 2005-2006, 2009-2010 Free Software Foundation, Inc. 3 Written by Bruno Haible <bruno@clisp.org>, 2011.
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,17 +15,14 @@
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/* Written by Jim Meyering. */
19
20#include <config.h> 18#include <config.h>
21 19
22#include "fcntl-safer.h" 20/* Specification. */
23 21#include <float.h>
24#include <fcntl.h>
25#include "unistd-safer.h"
26 22
27int 23void
28creat_safer (char const *file, mode_t mode) 24_Qp_itoq (long double *result, int a)
29{ 25{
30 return fd_safer (creat (file, mode)); 26 /* Convert from 'int' to 'double', then from 'double' to 'long double'. */
27 *result = (double) a;
31} 28}
diff --git a/gl/langinfo.in.h b/gl/langinfo.in.h
index 0865d96..5388ce6 100644
--- a/gl/langinfo.in.h
+++ b/gl/langinfo.in.h
@@ -1,5 +1,5 @@
1/* Substitute for and wrapper around <langinfo.h>. 1/* Substitute for and wrapper around <langinfo.h>.
2 Copyright (C) 2009, 2010 Free Software Foundation, Inc. 2 Copyright (C) 2009-2013 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
@@ -12,27 +12,27 @@
12 GNU General Public License for more details. 12 GNU General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software Foundation, 15 along with this program; if not, see <http://www.gnu.org/licenses/>. */
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
17 16
18/* 17/*
19 * POSIX <langinfo.h> for platforms that lack it or have an incomplete one. 18 * POSIX <langinfo.h> for platforms that lack it or have an incomplete one.
20 * <http://www.opengroup.org/onlinepubs/9699919799/basedefs/langinfo.h.html> 19 * <http://www.opengroup.org/onlinepubs/9699919799/basedefs/langinfo.h.html>
21 */ 20 */
22 21
23#ifndef _GL_LANGINFO_H 22#ifndef _@GUARD_PREFIX@_LANGINFO_H
24 23
25#if __GNUC__ >= 3 24#if __GNUC__ >= 3
26@PRAGMA_SYSTEM_HEADER@ 25@PRAGMA_SYSTEM_HEADER@
27#endif 26#endif
27@PRAGMA_COLUMNS@
28 28
29/* The include_next requires a split double-inclusion guard. */ 29/* The include_next requires a split double-inclusion guard. */
30#if @HAVE_LANGINFO_H@ 30#if @HAVE_LANGINFO_H@
31# @INCLUDE_NEXT@ @NEXT_LANGINFO_H@ 31# @INCLUDE_NEXT@ @NEXT_LANGINFO_H@
32#endif 32#endif
33 33
34#ifndef _GL_LANGINFO_H 34#ifndef _@GUARD_PREFIX@_LANGINFO_H
35#define _GL_LANGINFO_H 35#define _@GUARD_PREFIX@_LANGINFO_H
36 36
37 37
38#if !@HAVE_LANGINFO_H@ 38#if !@HAVE_LANGINFO_H@
@@ -40,7 +40,10 @@
40/* A platform that lacks <langinfo.h>. */ 40/* A platform that lacks <langinfo.h>. */
41 41
42/* Assume that it also lacks <nl_types.h> and the nl_item type. */ 42/* Assume that it also lacks <nl_types.h> and the nl_item type. */
43# if !GNULIB_defined_nl_item
43typedef int nl_item; 44typedef int nl_item;
45# define GNULIB_defined_nl_item 1
46# endif
44 47
45/* nl_langinfo items of the LC_CTYPE category */ 48/* nl_langinfo items of the LC_CTYPE category */
46# define CODESET 10000 49# define CODESET 10000
@@ -112,6 +115,11 @@ typedef int nl_item;
112# define GNULIB_defined_CODESET 1 115# define GNULIB_defined_CODESET 1
113# endif 116# endif
114 117
118# if !@HAVE_LANGINFO_T_FMT_AMPM@
119# define T_FMT_AMPM 10006
120# define GNULIB_defined_T_FMT_AMPM 1
121# endif
122
115# if !@HAVE_LANGINFO_ERA@ 123# if !@HAVE_LANGINFO_ERA@
116# define ERA 10047 124# define ERA 10047
117# define ERA_D_FMT 10048 125# define ERA_D_FMT 10048
@@ -121,6 +129,12 @@ typedef int nl_item;
121# define GNULIB_defined_ERA 1 129# define GNULIB_defined_ERA 1
122# endif 130# endif
123 131
132# if !@HAVE_LANGINFO_YESEXPR@
133# define YESEXPR 10053
134# define NOEXPR 10054
135# define GNULIB_defined_YESEXPR 1
136# endif
137
124#endif 138#endif
125 139
126/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 140/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
@@ -158,5 +172,5 @@ _GL_WARN_ON_USE (nl_langinfo, "nl_langinfo is not portable - "
158#endif 172#endif
159 173
160 174
161#endif /* _GL_LANGINFO_H */ 175#endif /* _@GUARD_PREFIX@_LANGINFO_H */
162#endif /* _GL_LANGINFO_H */ 176#endif /* _@GUARD_PREFIX@_LANGINFO_H */
diff --git a/gl/localcharset.c b/gl/localcharset.c
index fa2207f..a225a2e 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, 2008-2010 Free Software Foundation, Inc. 3 Copyright (C) 2000-2006, 2008-2013 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
@@ -13,8 +13,7 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License along 15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, 16 with this program; if not, see <http://www.gnu.org/licenses/>. */
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 17
19/* Written by Bruno Haible <bruno@clisp.org>. */ 18/* Written by Bruno Haible <bruno@clisp.org>. */
20 19
@@ -30,11 +29,11 @@
30#include <stdlib.h> 29#include <stdlib.h>
31 30
32#if defined __APPLE__ && defined __MACH__ && HAVE_LANGINFO_CODESET 31#if defined __APPLE__ && defined __MACH__ && HAVE_LANGINFO_CODESET
33# define DARWIN7 /* Darwin 7 or newer, i.e. MacOS X 10.3 or newer */ 32# define DARWIN7 /* Darwin 7 or newer, i.e. Mac OS X 10.3 or newer */
34#endif 33#endif
35 34
36#if defined _WIN32 || defined __WIN32__ 35#if defined _WIN32 || defined __WIN32__
37# define WIN32_NATIVE 36# define WINDOWS_NATIVE
38#endif 37#endif
39 38
40#if defined __EMX__ 39#if defined __EMX__
@@ -44,7 +43,7 @@
44# endif 43# endif
45#endif 44#endif
46 45
47#if !defined WIN32_NATIVE 46#if !defined WINDOWS_NATIVE
48# include <unistd.h> 47# include <unistd.h>
49# if HAVE_LANGINFO_CODESET 48# if HAVE_LANGINFO_CODESET
50# include <langinfo.h> 49# include <langinfo.h>
@@ -57,7 +56,7 @@
57# define WIN32_LEAN_AND_MEAN 56# define WIN32_LEAN_AND_MEAN
58# include <windows.h> 57# include <windows.h>
59# endif 58# endif
60#elif defined WIN32_NATIVE 59#elif defined WINDOWS_NATIVE
61# define WIN32_LEAN_AND_MEAN 60# define WIN32_LEAN_AND_MEAN
62# include <windows.h> 61# include <windows.h>
63#endif 62#endif
@@ -66,6 +65,11 @@
66# include <os2.h> 65# include <os2.h>
67#endif 66#endif
68 67
68/* For MB_CUR_MAX_L */
69#if defined DARWIN7
70# include <xlocale.h>
71#endif
72
69#if ENABLE_RELOCATABLE 73#if ENABLE_RELOCATABLE
70# include "relocatable.h" 74# include "relocatable.h"
71#else 75#else
@@ -83,7 +87,7 @@
83#endif 87#endif
84 88
85#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__ 89#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
86 /* Win32, Cygwin, OS/2, DOS */ 90 /* Native Windows, Cygwin, OS/2, DOS */
87# define ISSLASH(C) ((C) == '/' || (C) == '\\') 91# define ISSLASH(C) ((C) == '/' || (C) == '\\')
88#endif 92#endif
89 93
@@ -123,7 +127,7 @@ get_charset_aliases (void)
123 cp = charset_aliases; 127 cp = charset_aliases;
124 if (cp == NULL) 128 if (cp == NULL)
125 { 129 {
126#if !(defined DARWIN7 || defined VMS || defined WIN32_NATIVE || defined __CYGWIN__) 130#if !(defined DARWIN7 || defined VMS || defined WINDOWS_NATIVE || defined __CYGWIN__)
127 const char *dir; 131 const char *dir;
128 const char *base = "charset.alias"; 132 const char *base = "charset.alias";
129 char *file_name; 133 char *file_name;
@@ -228,8 +232,7 @@ get_charset_aliases (void)
228 { 232 {
229 /* Out of memory. */ 233 /* Out of memory. */
230 res_size = 0; 234 res_size = 0;
231 if (old_res_ptr != NULL) 235 free (old_res_ptr);
232 free (old_res_ptr);
233 break; 236 break;
234 } 237 }
235 strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1); 238 strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1);
@@ -309,7 +312,7 @@ get_charset_aliases (void)
309 "DECKOREAN" "\0" "EUC-KR" "\0"; 312 "DECKOREAN" "\0" "EUC-KR" "\0";
310# endif 313# endif
311 314
312# if defined WIN32_NATIVE || defined __CYGWIN__ 315# if defined WINDOWS_NATIVE || defined __CYGWIN__
313 /* To avoid the troubles of installing a separate file in the same 316 /* To avoid the troubles of installing a separate file in the same
314 directory as the DLL and of retrieving the DLL's directory at 317 directory as the DLL and of retrieving the DLL's directory at
315 runtime, simply inline the aliases here. */ 318 runtime, simply inline the aliases here. */
@@ -361,7 +364,7 @@ locale_charset (void)
361 const char *codeset; 364 const char *codeset;
362 const char *aliases; 365 const char *aliases;
363 366
364#if !(defined WIN32_NATIVE || defined OS2) 367#if !(defined WINDOWS_NATIVE || defined OS2)
365 368
366# if HAVE_LANGINFO_CODESET 369# if HAVE_LANGINFO_CODESET
367 370
@@ -408,10 +411,10 @@ locale_charset (void)
408 } 411 }
409 } 412 }
410 413
411 /* Woe32 has a function returning the locale's codepage as a number: 414 /* The Windows API has a function returning the locale's codepage as a
412 GetACP(). This encoding is used by Cygwin, unless the user has set 415 number: GetACP(). This encoding is used by Cygwin, unless the user
413 the environment variable CYGWIN=codepage:oem (which very few people 416 has set the environment variable CYGWIN=codepage:oem (which very few
414 do). 417 people do).
415 Output directed to console windows needs to be converted (to 418 Output directed to console windows needs to be converted (to
416 GetOEMCP() if the console is using a raster font, or to 419 GetOEMCP() if the console is using a raster font, or to
417 GetConsoleOutputCP() if it is using a TrueType font). Cygwin does 420 GetConsoleOutputCP() if it is using a TrueType font). Cygwin does
@@ -454,12 +457,12 @@ locale_charset (void)
454 457
455# endif 458# endif
456 459
457#elif defined WIN32_NATIVE 460#elif defined WINDOWS_NATIVE
458 461
459 static char buf[2 + 10 + 1]; 462 static char buf[2 + 10 + 1];
460 463
461 /* Woe32 has a function returning the locale's codepage as a number: 464 /* The Windows API has a function returning the locale's codepage as a
462 GetACP(). 465 number: GetACP().
463 When the output goes to a console window, it needs to be provided in 466 When the output goes to a console window, it needs to be provided in
464 GetOEMCP() encoding if the console is using a raster font, or in 467 GetOEMCP() encoding if the console is using a raster font, or in
465 GetConsoleOutputCP() encoding if it is using a TrueType font. 468 GetConsoleOutputCP() encoding if it is using a TrueType font.
@@ -544,5 +547,12 @@ locale_charset (void)
544 if (codeset[0] == '\0') 547 if (codeset[0] == '\0')
545 codeset = "ASCII"; 548 codeset = "ASCII";
546 549
550#ifdef DARWIN7
551 /* Mac OS X sets MB_CUR_MAX to 1 when LC_ALL=C, and "UTF-8"
552 (the default codeset) does not work when MB_CUR_MAX is 1. */
553 if (strcmp (codeset, "UTF-8") == 0 && MB_CUR_MAX_L (uselocale (NULL)) <= 1)
554 codeset = "ASCII";
555#endif
556
547 return codeset; 557 return codeset;
548} 558}
diff --git a/gl/localcharset.h b/gl/localcharset.h
index 899b3ba..c209829 100644
--- a/gl/localcharset.h
+++ b/gl/localcharset.h
@@ -1,5 +1,5 @@
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 Copyright (C) 2000-2003, 2009-2010 Free Software Foundation, Inc. 2 Copyright (C) 2000-2003, 2009-2013 Free Software Foundation, Inc.
3 This file is part of the GNU CHARSET Library. 3 This file is part of the GNU CHARSET Library.
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
@@ -13,8 +13,7 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License along 15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, 16 with this program; if not, see <http://www.gnu.org/licenses/>. */
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 17
19#ifndef _LOCALCHARSET_H 18#ifndef _LOCALCHARSET_H
20#define _LOCALCHARSET_H 19#define _LOCALCHARSET_H
diff --git a/gl/locale.in.h b/gl/locale.in.h
index 75b5299..264161a 100644
--- a/gl/locale.in.h
+++ b/gl/locale.in.h
@@ -1,5 +1,5 @@
1/* A POSIX <locale.h>. 1/* A POSIX <locale.h>.
2 Copyright (C) 2007-2010 Free Software Foundation, Inc. 2 Copyright (C) 2007-2013 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
@@ -14,22 +14,37 @@
14 You should have received a copy of the GNU General Public License 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/>. */ 15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
16 16
17#ifndef _GL_LOCALE_H
18
19#if __GNUC__ >= 3 17#if __GNUC__ >= 3
20@PRAGMA_SYSTEM_HEADER@ 18@PRAGMA_SYSTEM_HEADER@
21#endif 19#endif
20@PRAGMA_COLUMNS@
21
22#ifdef _GL_ALREADY_INCLUDING_LOCALE_H
23
24/* Special invocation conventions to handle Solaris header files
25 (through Solaris 10) when combined with gettext's libintl.h. */
26
27#@INCLUDE_NEXT@ @NEXT_LOCALE_H@
28
29#else
30/* Normal invocation convention. */
31
32#ifndef _@GUARD_PREFIX@_LOCALE_H
33
34#define _GL_ALREADY_INCLUDING_LOCALE_H
22 35
23/* The include_next requires a split double-inclusion guard. */ 36/* The include_next requires a split double-inclusion guard. */
24#@INCLUDE_NEXT@ @NEXT_LOCALE_H@ 37#@INCLUDE_NEXT@ @NEXT_LOCALE_H@
25 38
26#ifndef _GL_LOCALE_H 39#undef _GL_ALREADY_INCLUDING_LOCALE_H
27#define _GL_LOCALE_H 40
41#ifndef _@GUARD_PREFIX@_LOCALE_H
42#define _@GUARD_PREFIX@_LOCALE_H
28 43
29/* NetBSD 5.0 mis-defines NULL. */ 44/* NetBSD 5.0 mis-defines NULL. */
30#include <stddef.h> 45#include <stddef.h>
31 46
32/* MacOS X 10.5 defines the locale_t type in <xlocale.h>. */ 47/* Mac OS X 10.5 defines the locale_t type in <xlocale.h>. */
33#if @HAVE_XLOCALE_H@ 48#if @HAVE_XLOCALE_H@
34# include <xlocale.h> 49# include <xlocale.h>
35#endif 50#endif
@@ -46,6 +61,132 @@
46# define LC_MESSAGES 1729 61# define LC_MESSAGES 1729
47#endif 62#endif
48 63
64/* Bionic libc's 'struct lconv' is just a dummy. */
65#if @REPLACE_STRUCT_LCONV@
66# define lconv rpl_lconv
67struct lconv
68{
69 /* All 'char *' are actually 'const char *'. */
70
71 /* Members that depend on the LC_NUMERIC category of the locale. See
72 <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html#tag_07_03_04> */
73
74 /* Symbol used as decimal point. */
75 char *decimal_point;
76 /* Symbol used to separate groups of digits to the left of the decimal
77 point. */
78 char *thousands_sep;
79 /* Definition of the size of groups of digits to the left of the decimal
80 point. */
81 char *grouping;
82
83 /* Members that depend on the LC_MONETARY category of the locale. See
84 <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html#tag_07_03_03> */
85
86 /* Symbol used as decimal point. */
87 char *mon_decimal_point;
88 /* Symbol used to separate groups of digits to the left of the decimal
89 point. */
90 char *mon_thousands_sep;
91 /* Definition of the size of groups of digits to the left of the decimal
92 point. */
93 char *mon_grouping;
94 /* Sign used to indicate a value >= 0. */
95 char *positive_sign;
96 /* Sign used to indicate a value < 0. */
97 char *negative_sign;
98
99 /* For formatting local currency. */
100 /* Currency symbol (3 characters) followed by separator (1 character). */
101 char *currency_symbol;
102 /* Number of digits after the decimal point. */
103 char frac_digits;
104 /* For values >= 0: 1 if the currency symbol precedes the number, 0 if it
105 comes after the number. */
106 char p_cs_precedes;
107 /* For values >= 0: Position of the sign. */
108 char p_sign_posn;
109 /* For values >= 0: Placement of spaces between currency symbol, sign, and
110 number. */
111 char p_sep_by_space;
112 /* For values < 0: 1 if the currency symbol precedes the number, 0 if it
113 comes after the number. */
114 char n_cs_precedes;
115 /* For values < 0: Position of the sign. */
116 char n_sign_posn;
117 /* For values < 0: Placement of spaces between currency symbol, sign, and
118 number. */
119 char n_sep_by_space;
120
121 /* For formatting international currency. */
122 /* Currency symbol (3 characters) followed by separator (1 character). */
123 char *int_curr_symbol;
124 /* Number of digits after the decimal point. */
125 char int_frac_digits;
126 /* For values >= 0: 1 if the currency symbol precedes the number, 0 if it
127 comes after the number. */
128 char int_p_cs_precedes;
129 /* For values >= 0: Position of the sign. */
130 char int_p_sign_posn;
131 /* For values >= 0: Placement of spaces between currency symbol, sign, and
132 number. */
133 char int_p_sep_by_space;
134 /* For values < 0: 1 if the currency symbol precedes the number, 0 if it
135 comes after the number. */
136 char int_n_cs_precedes;
137 /* For values < 0: Position of the sign. */
138 char int_n_sign_posn;
139 /* For values < 0: Placement of spaces between currency symbol, sign, and
140 number. */
141 char int_n_sep_by_space;
142};
143#endif
144
145#if @GNULIB_LOCALECONV@
146# if @REPLACE_LOCALECONV@
147# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
148# undef localeconv
149# define localeconv rpl_localeconv
150# endif
151_GL_FUNCDECL_RPL (localeconv, struct lconv *, (void));
152_GL_CXXALIAS_RPL (localeconv, struct lconv *, (void));
153# else
154_GL_CXXALIAS_SYS (localeconv, struct lconv *, (void));
155# endif
156_GL_CXXALIASWARN (localeconv);
157#elif @REPLACE_STRUCT_LCONV@
158# undef localeconv
159# define localeconv localeconv_used_without_requesting_gnulib_module_localeconv
160#elif defined GNULIB_POSIXCHECK
161# undef localeconv
162# if HAVE_RAW_DECL_LOCALECONV
163_GL_WARN_ON_USE (localeconv,
164 "localeconv returns too few information on some platforms - "
165 "use gnulib module localeconv for portability");
166# endif
167#endif
168
169#if @GNULIB_SETLOCALE@
170# if @REPLACE_SETLOCALE@
171# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
172# undef setlocale
173# define setlocale rpl_setlocale
174# define GNULIB_defined_setlocale 1
175# endif
176_GL_FUNCDECL_RPL (setlocale, char *, (int category, const char *locale));
177_GL_CXXALIAS_RPL (setlocale, char *, (int category, const char *locale));
178# else
179_GL_CXXALIAS_SYS (setlocale, char *, (int category, const char *locale));
180# endif
181_GL_CXXALIASWARN (setlocale);
182#elif defined GNULIB_POSIXCHECK
183# undef setlocale
184# if HAVE_RAW_DECL_SETLOCALE
185_GL_WARN_ON_USE (setlocale, "setlocale works differently on native Windows - "
186 "use gnulib module setlocale for portability");
187# endif
188#endif
189
49#if @GNULIB_DUPLOCALE@ 190#if @GNULIB_DUPLOCALE@
50# if @REPLACE_DUPLOCALE@ 191# if @REPLACE_DUPLOCALE@
51# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 192# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -70,5 +211,6 @@ _GL_WARN_ON_USE (duplocale, "duplocale is buggy on some glibc systems - "
70# endif 211# endif
71#endif 212#endif
72 213
73#endif /* _GL_LOCALE_H */ 214#endif /* _@GUARD_PREFIX@_LOCALE_H */
74#endif /* _GL_LOCALE_H */ 215#endif /* ! _GL_ALREADY_INCLUDING_LOCALE_H */
216#endif /* _@GUARD_PREFIX@_LOCALE_H */
diff --git a/gl/localeconv.c b/gl/localeconv.c
new file mode 100644
index 0000000..7c7c77c
--- /dev/null
+++ b/gl/localeconv.c
@@ -0,0 +1,103 @@
1/* Query locale dependent information for formatting numbers.
2 Copyright (C) 2012-2013 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#include <config.h>
18
19/* Specification. */
20#include <locale.h>
21
22#if HAVE_STRUCT_LCONV_DECIMAL_POINT
23
24/* Override for platforms where 'struct lconv' lacks the int_p_*, int_n_*
25 members. */
26
27struct lconv *
28localeconv (void)
29{
30 static struct lconv result;
31# undef lconv
32# undef localeconv
33 struct lconv *sys_result = localeconv ();
34
35 result.decimal_point = sys_result->decimal_point;
36 result.thousands_sep = sys_result->thousands_sep;
37 result.grouping = sys_result->grouping;
38 result.mon_decimal_point = sys_result->mon_decimal_point;
39 result.mon_thousands_sep = sys_result->mon_thousands_sep;
40 result.mon_grouping = sys_result->mon_grouping;
41 result.positive_sign = sys_result->positive_sign;
42 result.negative_sign = sys_result->negative_sign;
43 result.currency_symbol = sys_result->currency_symbol;
44 result.frac_digits = sys_result->frac_digits;
45 result.p_cs_precedes = sys_result->p_cs_precedes;
46 result.p_sign_posn = sys_result->p_sign_posn;
47 result.p_sep_by_space = sys_result->p_sep_by_space;
48 result.n_cs_precedes = sys_result->n_cs_precedes;
49 result.n_sign_posn = sys_result->n_sign_posn;
50 result.n_sep_by_space = sys_result->n_sep_by_space;
51 result.int_curr_symbol = sys_result->int_curr_symbol;
52 result.int_frac_digits = sys_result->int_frac_digits;
53 result.int_p_cs_precedes = sys_result->p_cs_precedes;
54 result.int_p_sign_posn = sys_result->p_sign_posn;
55 result.int_p_sep_by_space = sys_result->p_sep_by_space;
56 result.int_n_cs_precedes = sys_result->n_cs_precedes;
57 result.int_n_sign_posn = sys_result->n_sign_posn;
58 result.int_n_sep_by_space = sys_result->n_sep_by_space;
59
60 return &result;
61}
62
63#else
64
65/* Override for platforms where 'struct lconv' is a dummy. */
66
67# include <limits.h>
68
69struct lconv *
70localeconv (void)
71{
72 static /*const*/ struct lconv result =
73 {
74 /* decimal_point */ ".",
75 /* thousands_sep */ "",
76 /* grouping */ "",
77 /* mon_decimal_point */ "",
78 /* mon_thousands_sep */ "",
79 /* mon_grouping */ "",
80 /* positive_sign */ "",
81 /* negative_sign */ "",
82 /* currency_symbol */ "",
83 /* frac_digits */ CHAR_MAX,
84 /* p_cs_precedes */ CHAR_MAX,
85 /* p_sign_posn */ CHAR_MAX,
86 /* p_sep_by_space */ CHAR_MAX,
87 /* n_cs_precedes */ CHAR_MAX,
88 /* n_sign_posn */ CHAR_MAX,
89 /* n_sep_by_space */ CHAR_MAX,
90 /* int_curr_symbol */ "",
91 /* int_frac_digits */ CHAR_MAX,
92 /* int_p_cs_precedes */ CHAR_MAX,
93 /* int_p_sign_posn */ CHAR_MAX,
94 /* int_p_sep_by_space */ CHAR_MAX,
95 /* int_n_cs_precedes */ CHAR_MAX,
96 /* int_n_sign_posn */ CHAR_MAX,
97 /* int_n_sep_by_space */ CHAR_MAX
98 };
99
100 return &result;
101}
102
103#endif
diff --git a/gl/m4/00gnulib.m4 b/gl/m4/00gnulib.m4
index 301469b..d4ad759 100644
--- a/gl/m4/00gnulib.m4
+++ b/gl/m4/00gnulib.m4
@@ -1,5 +1,5 @@
1# 00gnulib.m4 serial 2 1# 00gnulib.m4 serial 2
2dnl Copyright (C) 2009-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2009-2013 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.
diff --git a/gl/m4/alloca.m4 b/gl/m4/alloca.m4
index f3ee343..270abd0 100644
--- a/gl/m4/alloca.m4
+++ b/gl/m4/alloca.m4
@@ -1,5 +1,5 @@
1# alloca.m4 serial 9 1# alloca.m4 serial 14
2dnl Copyright (C) 2002-2004, 2006-2007, 2009-2010 Free Software Foundation, 2dnl Copyright (C) 2002-2004, 2006-2007, 2009-2013 Free Software Foundation,
3dnl Inc. 3dnl Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
@@ -7,10 +7,6 @@ dnl with or without modifications, as long as this notice is preserved.
7 7
8AC_DEFUN([gl_FUNC_ALLOCA], 8AC_DEFUN([gl_FUNC_ALLOCA],
9[ 9[
10 dnl Work around a bug of AC_EGREP_CPP in autoconf-2.57.
11 AC_REQUIRE([AC_PROG_CPP])
12 AC_REQUIRE([AC_PROG_EGREP])
13
14 AC_REQUIRE([AC_FUNC_ALLOCA]) 10 AC_REQUIRE([AC_FUNC_ALLOCA])
15 if test $ac_cv_func_alloca_works = no; then 11 if test $ac_cv_func_alloca_works = no; then
16 gl_PREREQ_ALLOCA 12 gl_PREREQ_ALLOCA
@@ -40,8 +36,86 @@ AC_DEFUN([gl_FUNC_ALLOCA],
40 ALLOCA_H=alloca.h 36 ALLOCA_H=alloca.h
41 fi 37 fi
42 AC_SUBST([ALLOCA_H]) 38 AC_SUBST([ALLOCA_H])
39 AM_CONDITIONAL([GL_GENERATE_ALLOCA_H], [test -n "$ALLOCA_H"])
43]) 40])
44 41
45# Prerequisites of lib/alloca.c. 42# Prerequisites of lib/alloca.c.
46# STACK_DIRECTION is already handled by AC_FUNC_ALLOCA. 43# STACK_DIRECTION is already handled by AC_FUNC_ALLOCA.
47AC_DEFUN([gl_PREREQ_ALLOCA], [:]) 44AC_DEFUN([gl_PREREQ_ALLOCA], [:])
45
46# This works around a bug in autoconf <= 2.68.
47# See <http://lists.gnu.org/archive/html/bug-gnulib/2011-06/msg00277.html>.
48
49m4_version_prereq([2.69], [] ,[
50
51# This is taken from the following Autoconf patch:
52# http://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=6cd9f12520b0d6f76d3230d7565feba1ecf29497
53
54# _AC_LIBOBJ_ALLOCA
55# -----------------
56# Set up the LIBOBJ replacement of 'alloca'. Well, not exactly
57# AC_LIBOBJ since we actually set the output variable 'ALLOCA'.
58# Nevertheless, for Automake, AC_LIBSOURCES it.
59m4_define([_AC_LIBOBJ_ALLOCA],
60[# The SVR3 libPW and SVR4 libucb both contain incompatible functions
61# that cause trouble. Some versions do not even contain alloca or
62# contain a buggy version. If you still want to use their alloca,
63# use ar to extract alloca.o from them instead of compiling alloca.c.
64AC_LIBSOURCES(alloca.c)
65AC_SUBST([ALLOCA], [\${LIBOBJDIR}alloca.$ac_objext])dnl
66AC_DEFINE(C_ALLOCA, 1, [Define to 1 if using 'alloca.c'.])
67
68AC_CACHE_CHECK(whether 'alloca.c' needs Cray hooks, ac_cv_os_cray,
69[AC_EGREP_CPP(webecray,
70[#if defined CRAY && ! defined CRAY2
71webecray
72#else
73wenotbecray
74#endif
75], ac_cv_os_cray=yes, ac_cv_os_cray=no)])
76if test $ac_cv_os_cray = yes; then
77 for ac_func in _getb67 GETB67 getb67; do
78 AC_CHECK_FUNC($ac_func,
79 [AC_DEFINE_UNQUOTED(CRAY_STACKSEG_END, $ac_func,
80 [Define to one of '_getb67', 'GETB67',
81 'getb67' for Cray-2 and Cray-YMP
82 systems. This function is required for
83 'alloca.c' support on those systems.])
84 break])
85 done
86fi
87
88AC_CACHE_CHECK([stack direction for C alloca],
89 [ac_cv_c_stack_direction],
90[AC_RUN_IFELSE([AC_LANG_SOURCE(
91[AC_INCLUDES_DEFAULT
92int
93find_stack_direction (int *addr, int depth)
94{
95 int dir, dummy = 0;
96 if (! addr)
97 addr = &dummy;
98 *addr = addr < &dummy ? 1 : addr == &dummy ? 0 : -1;
99 dir = depth ? find_stack_direction (addr, depth - 1) : 0;
100 return dir + dummy;
101}
102
103int
104main (int argc, char **argv)
105{
106 return find_stack_direction (0, argc + !argv + 20) < 0;
107}])],
108 [ac_cv_c_stack_direction=1],
109 [ac_cv_c_stack_direction=-1],
110 [ac_cv_c_stack_direction=0])])
111AH_VERBATIM([STACK_DIRECTION],
112[/* If using the C implementation of alloca, define if you know the
113 direction of stack growth for your system; otherwise it will be
114 automatically deduced at runtime.
115 STACK_DIRECTION > 0 => grows toward higher addresses
116 STACK_DIRECTION < 0 => grows toward lower addresses
117 STACK_DIRECTION = 0 => direction of growth unknown */
118@%:@undef STACK_DIRECTION])dnl
119AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction)
120])# _AC_LIBOBJ_ALLOCA
121])
diff --git a/gl/m4/arpa_inet_h.m4 b/gl/m4/arpa_inet_h.m4
index 15a30e2..ea69af5 100644
--- a/gl/m4/arpa_inet_h.m4
+++ b/gl/m4/arpa_inet_h.m4
@@ -1,5 +1,5 @@
1# arpa_inet_h.m4 serial 8 1# arpa_inet_h.m4 serial 13
2dnl Copyright (C) 2006, 2008, 2009, 2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2006, 2008-2013 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.
@@ -22,24 +22,22 @@ AC_DEFUN([gl_HEADER_ARPA_INET],
22 dnl <arpa/inet.h> is always overridden, because of GNULIB_POSIXCHECK. 22 dnl <arpa/inet.h> is always overridden, because of GNULIB_POSIXCHECK.
23 gl_CHECK_NEXT_HEADERS([arpa/inet.h]) 23 gl_CHECK_NEXT_HEADERS([arpa/inet.h])
24 24
25 AC_REQUIRE([gl_FEATURES_H])
26
25 dnl Check for declarations of anything we want to poison if the 27 dnl Check for declarations of anything we want to poison if the
26 dnl corresponding gnulib module is not in use. 28 dnl corresponding gnulib module is not in use.
27 gl_WARN_ON_USE_PREPARE([[ 29 gl_WARN_ON_USE_PREPARE([[
28/* On some systems, this header is not self-consistent. */ 30/* On some systems, this header is not self-consistent. */
29#ifndef __GLIBC__ 31#if !(defined __GLIBC__ || defined __UCLIBC__)
30# include <sys/socket.h> 32# include <sys/socket.h>
31#endif 33#endif
34#ifdef __TANDEM
35# include <netdb.h>
36#endif
32#include <arpa/inet.h> 37#include <arpa/inet.h>
33 ]], [inet_ntop inet_pton]) 38 ]], [inet_ntop inet_pton])
34]) 39])
35 40
36dnl Unconditionally enables the replacement of <arpa/inet.h>.
37AC_DEFUN([gl_REPLACE_ARPA_INET_H],
38[
39 dnl This is a no-op, because <arpa/inet.h> is always overridden.
40 :
41])
42
43AC_DEFUN([gl_ARPA_INET_MODULE_INDICATOR], 41AC_DEFUN([gl_ARPA_INET_MODULE_INDICATOR],
44[ 42[
45 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 43 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
@@ -54,4 +52,6 @@ AC_DEFUN([gl_ARPA_INET_H_DEFAULTS],
54 dnl Assume proper GNU behavior unless another module says otherwise. 52 dnl Assume proper GNU behavior unless another module says otherwise.
55 HAVE_DECL_INET_NTOP=1; AC_SUBST([HAVE_DECL_INET_NTOP]) 53 HAVE_DECL_INET_NTOP=1; AC_SUBST([HAVE_DECL_INET_NTOP])
56 HAVE_DECL_INET_PTON=1; AC_SUBST([HAVE_DECL_INET_PTON]) 54 HAVE_DECL_INET_PTON=1; AC_SUBST([HAVE_DECL_INET_PTON])
55 REPLACE_INET_NTOP=0; AC_SUBST([REPLACE_INET_NTOP])
56 REPLACE_INET_PTON=0; AC_SUBST([REPLACE_INET_PTON])
57]) 57])
diff --git a/gl/m4/asm-underscore.m4 b/gl/m4/asm-underscore.m4
deleted file mode 100644
index 1736cc4..0000000
--- a/gl/m4/asm-underscore.m4
+++ /dev/null
@@ -1,48 +0,0 @@
1# asm-underscore.m4 serial 1
2dnl Copyright (C) 2010 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible. Based on as-underscore.m4 in GNU clisp.
8
9# gl_ASM_SYMBOL_PREFIX
10# Tests for the prefix of C symbols at the assembly language level and the
11# linker level. This prefix is either an underscore or empty. Defines the
12# C macro USER_LABEL_PREFIX to this prefix, and sets ASM_SYMBOL_PREFIX to
13# a stringified variant of this prefix.
14
15AC_DEFUN([gl_ASM_SYMBOL_PREFIX],
16[
17 dnl We don't use GCC's __USER_LABEL_PREFIX__ here, because
18 dnl 1. It works only for GCC.
19 dnl 2. It is incorrectly defined on some platforms, in some GCC versions.
20 AC_CACHE_CHECK(
21 [whether C symbols are prefixed with underscore at the linker level],
22 [gl_cv_prog_as_underscore],
23 [cat > conftest.c <<EOF
24#ifdef __cplusplus
25extern "C" int foo (void);
26#endif
27int foo(void) { return 0; }
28EOF
29 # Look for the assembly language name in the .s file.
30 AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS -S conftest.c) >/dev/null 2>&1
31 if grep _foo conftest.s >/dev/null ; then
32 gl_cv_prog_as_underscore=yes
33 else
34 gl_cv_prog_as_underscore=no
35 fi
36 rm -f conftest*
37 ])
38 if test $gl_cv_prog_as_underscore = yes; then
39 USER_LABEL_PREFIX=_
40 else
41 USER_LABEL_PREFIX=
42 fi
43 AC_DEFINE_UNQUOTED([USER_LABEL_PREFIX], [$USER_LABEL_PREFIX],
44 [Define to the prefix of C symbols at the assembler and linker level,
45 either an underscore or empty.])
46 ASM_SYMBOL_PREFIX='"'${USER_LABEL_PREFIX}'"'
47 AC_SUBST([ASM_SYMBOL_PREFIX])
48])
diff --git a/gl/m4/base64.m4 b/gl/m4/base64.m4
index d1e1352..fc19893 100644
--- a/gl/m4/base64.m4
+++ b/gl/m4/base64.m4
@@ -1,5 +1,5 @@
1# base64.m4 serial 3 1# base64.m4 serial 4
2dnl Copyright (C) 2004, 2006, 2009, 2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2004, 2006, 2009-2013 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,6 +11,5 @@ AC_DEFUN([gl_FUNC_BASE64],
11 11
12# Prerequisites of lib/base64.c. 12# Prerequisites of lib/base64.c.
13AC_DEFUN([gl_PREREQ_BASE64], [ 13AC_DEFUN([gl_PREREQ_BASE64], [
14 AC_REQUIRE([AC_C_INLINE])
15 AC_REQUIRE([AC_C_RESTRICT]) 14 AC_REQUIRE([AC_C_RESTRICT])
16]) 15])
diff --git a/gl/m4/btowc.m4 b/gl/m4/btowc.m4
index c4ee4e4..978a06e 100644
--- a/gl/m4/btowc.m4
+++ b/gl/m4/btowc.m4
@@ -1,5 +1,5 @@
1# btowc.m4 serial 6 1# btowc.m4 serial 10
2dnl Copyright (C) 2008-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2008-2013 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,16 +26,23 @@ AC_DEFUN([gl_FUNC_BTOWC],
26 AC_CACHE_CHECK([whether btowc(0) is correct], 26 AC_CACHE_CHECK([whether btowc(0) is correct],
27 [gl_cv_func_btowc_nul], 27 [gl_cv_func_btowc_nul],
28 [ 28 [
29 AC_TRY_RUN([ 29 AC_RUN_IFELSE(
30#include <stdio.h> 30 [AC_LANG_SOURCE([[
31#include <string.h> 31#include <string.h>
32/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
33 <wchar.h>.
34 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
35 included before <wchar.h>. */
36#include <stddef.h>
37#include <stdio.h>
38#include <time.h>
32#include <wchar.h> 39#include <wchar.h>
33int main () 40int main ()
34{ 41{
35 if (btowc ('\0') != 0) 42 if (btowc ('\0') != 0)
36 return 1; 43 return 1;
37 return 0; 44 return 0;
38}], 45}]])],
39 [gl_cv_func_btowc_nul=yes], 46 [gl_cv_func_btowc_nul=yes],
40 [gl_cv_func_btowc_nul=no], 47 [gl_cv_func_btowc_nul=no],
41 [ 48 [
@@ -65,10 +72,17 @@ changequote(,)dnl
65 esac 72 esac
66changequote([,])dnl 73changequote([,])dnl
67 if test $LOCALE_FR != none; then 74 if test $LOCALE_FR != none; then
68 AC_TRY_RUN([ 75 AC_RUN_IFELSE(
76 [AC_LANG_SOURCE([[
69#include <locale.h> 77#include <locale.h>
70#include <stdio.h>
71#include <string.h> 78#include <string.h>
79/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
80 <wchar.h>.
81 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
82 included before <wchar.h>. */
83#include <stddef.h>
84#include <stdio.h>
85#include <time.h>
72#include <wchar.h> 86#include <wchar.h>
73int main () 87int main ()
74{ 88{
@@ -78,7 +92,7 @@ int main ()
78 return 1; 92 return 1;
79 } 93 }
80 return 0; 94 return 0;
81}], 95}]])],
82 [gl_cv_func_btowc_eof=yes], 96 [gl_cv_func_btowc_eof=yes],
83 [gl_cv_func_btowc_eof=no], 97 [gl_cv_func_btowc_eof=no],
84 [:]) 98 [:])
@@ -94,11 +108,6 @@ int main ()
94 *) REPLACE_BTOWC=1 ;; 108 *) REPLACE_BTOWC=1 ;;
95 esac 109 esac
96 fi 110 fi
97 if test $HAVE_BTOWC = 0 || test $REPLACE_BTOWC = 1; then
98 gl_REPLACE_WCHAR_H
99 AC_LIBOBJ([btowc])
100 gl_PREREQ_BTOWC
101 fi
102]) 111])
103 112
104# Prerequisites of lib/btowc.c. 113# Prerequisites of lib/btowc.c.
diff --git a/gl/m4/c-strtod.m4 b/gl/m4/c-strtod.m4
deleted file mode 100644
index 41cf18e..0000000
--- a/gl/m4/c-strtod.m4
+++ /dev/null
@@ -1,57 +0,0 @@
1# c-strtod.m4 serial 11
2
3# Copyright (C) 2004-2006, 2009-2010 Free Software Foundation, Inc.
4# This file is free software; the Free Software Foundation
5# gives unlimited permission to copy and/or distribute it,
6# with or without modifications, as long as this notice is preserved.
7
8# Written by Paul Eggert.
9
10AC_DEFUN([gl_C99_STRTOLD],
11[
12 AC_CACHE_CHECK([whether strtold conforms to C99],
13 [gl_cv_func_c99_strtold],
14 [AC_LINK_IFELSE(
15 [AC_LANG_PROGRAM(
16 [[/* On HP-UX before 11.23, strtold returns a struct instead of
17 long double. Reject implementations like that, by requiring
18 compatibility with the C99 prototype. */
19 #include <stdlib.h>
20 static long double (*p) (char const *, char **) = strtold;
21 static long double
22 test (char const *nptr, char **endptr)
23 {
24 long double r;
25 r = strtold (nptr, endptr);
26 return r;
27 }]],
28 [[return test ("1.0", NULL) != 1 || p ("1.0", NULL) != 1;]])],
29 [gl_cv_func_c99_strtold=yes],
30 [gl_cv_func_c99_strtold=no])])
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.])
33 fi
34])
35
36AC_DEFUN([gl_C_STRTOD],
37[
38 AC_LIBOBJ([c-strtod])
39
40 dnl Prerequisites of lib/c-strtod.c.
41 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
42
43 AC_REQUIRE([AC_C_INLINE])
44 :
45])
46
47AC_DEFUN([gl_C_STRTOLD],
48[
49 AC_LIBOBJ([c-strtold])
50
51 dnl Prerequisites of lib/c-strtold.c.
52 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
53 AC_REQUIRE([gl_C99_STRTOLD])
54
55 AC_REQUIRE([AC_C_INLINE])
56 :
57])
diff --git a/gl/m4/codeset.m4 b/gl/m4/codeset.m4
index a53c042..c2761be 100644
--- a/gl/m4/codeset.m4
+++ b/gl/m4/codeset.m4
@@ -1,5 +1,5 @@
1# codeset.m4 serial 4 (gettext-0.18) 1# codeset.m4 serial 5 (gettext-0.18.2)
2dnl Copyright (C) 2000-2002, 2006, 2008-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2000-2002, 2006, 2008-2013 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,10 +9,12 @@ dnl From Bruno Haible.
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_LINK_IFELSE(
13 [char* cs = nl_langinfo(CODESET); return !cs;], 13 [AC_LANG_PROGRAM(
14 [am_cv_langinfo_codeset=yes], 14 [[#include <langinfo.h>]],
15 [am_cv_langinfo_codeset=no]) 15 [[char* cs = nl_langinfo(CODESET); return !cs;]])],
16 [am_cv_langinfo_codeset=yes],
17 [am_cv_langinfo_codeset=no])
16 ]) 18 ])
17 if test $am_cv_langinfo_codeset = yes; then 19 if test $am_cv_langinfo_codeset = yes; then
18 AC_DEFINE([HAVE_LANGINFO_CODESET], [1], 20 AC_DEFINE([HAVE_LANGINFO_CODESET], [1],
diff --git a/gl/m4/configmake.m4 b/gl/m4/configmake.m4
new file mode 100644
index 0000000..823ffc0
--- /dev/null
+++ b/gl/m4/configmake.m4
@@ -0,0 +1,50 @@
1# configmake.m4 serial 1
2dnl Copyright (C) 2010-2013 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# gl_CONFIGMAKE_PREP
8# ------------------
9# Guarantee all of the standard directory variables, even when used with
10# autoconf 2.59 (datarootdir wasn't supported until 2.59c) or automake
11# 1.9.6 (pkglibexecdir wasn't supported until 1.10b.).
12AC_DEFUN([gl_CONFIGMAKE_PREP],
13[
14 dnl Technically, datadir should default to datarootdir. But if
15 dnl autoconf is too old to provide datarootdir, then reversing the
16 dnl definition is a reasonable compromise. Only AC_SUBST a variable
17 dnl if it was not already defined earlier by autoconf.
18 if test "x$datarootdir" = x; then
19 AC_SUBST([datarootdir], ['${datadir}'])
20 fi
21 dnl Copy the approach used in autoconf 2.60.
22 if test "x$docdir" = x; then
23 AC_SUBST([docdir], [m4_ifset([AC_PACKAGE_TARNAME],
24 ['${datarootdir}/doc/${PACKAGE_TARNAME}'],
25 ['${datarootdir}/doc/${PACKAGE}'])])
26 fi
27 dnl The remaining variables missing from autoconf 2.59 are easier.
28 if test "x$htmldir" = x; then
29 AC_SUBST([htmldir], ['${docdir}'])
30 fi
31 if test "x$dvidir" = x; then
32 AC_SUBST([dvidir], ['${docdir}'])
33 fi
34 if test "x$pdfdir" = x; then
35 AC_SUBST([pdfdir], ['${docdir}'])
36 fi
37 if test "x$psdir" = x; then
38 AC_SUBST([psdir], ['${docdir}'])
39 fi
40 if test "x$lispdir" = x; then
41 AC_SUBST([lispdir], ['${datarootdir}/emacs/site-lisp'])
42 fi
43 if test "x$localedir" = x; then
44 AC_SUBST([localedir], ['${datarootdir}/locale'])
45 fi
46
47 dnl Automake 1.9.6 only lacks pkglibexecdir; and since 1.11 merely
48 dnl provides it without AC_SUBST, this blind use of AC_SUBST is safe.
49 AC_SUBST([pkglibexecdir], ['${libexecdir}/${PACKAGE}'])
50])
diff --git a/gl/m4/dirname.m4 b/gl/m4/dirname.m4
index 576b5be..5897a2a 100644
--- a/gl/m4/dirname.m4
+++ b/gl/m4/dirname.m4
@@ -1,5 +1,5 @@
1#serial 8 -*- autoconf -*- 1#serial 10 -*- autoconf -*-
2dnl Copyright (C) 2002-2006, 2009-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2006, 2009-2013 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,18 +7,11 @@ dnl with or without modifications, as long as this notice is preserved.
7AC_DEFUN([gl_DIRNAME], 7AC_DEFUN([gl_DIRNAME],
8[ 8[
9 AC_REQUIRE([gl_DIRNAME_LGPL]) 9 AC_REQUIRE([gl_DIRNAME_LGPL])
10 AC_LIBOBJ([basename])
11 AC_LIBOBJ([dirname])
12]) 10])
13 11
14AC_DEFUN([gl_DIRNAME_LGPL], 12AC_DEFUN([gl_DIRNAME_LGPL],
15[ 13[
16 AC_LIBOBJ([basename-lgpl])
17 AC_LIBOBJ([dirname-lgpl])
18 AC_LIBOBJ([stripslash])
19
20 dnl Prerequisites of lib/dirname.h. 14 dnl Prerequisites of lib/dirname.h.
21 AC_REQUIRE([gl_AC_DOS])
22 AC_REQUIRE([gl_DOUBLE_SLASH_ROOT]) 15 AC_REQUIRE([gl_DOUBLE_SLASH_ROOT])
23 16
24 dnl No prerequisites of lib/basename-lgpl.c, lib/dirname-lgpl.c, 17 dnl No prerequisites of lib/basename-lgpl.c, lib/dirname-lgpl.c,
diff --git a/gl/m4/dos.m4 b/gl/m4/dos.m4
deleted file mode 100644
index 5660542..0000000
--- a/gl/m4/dos.m4
+++ /dev/null
@@ -1,71 +0,0 @@
1#serial 11 -*- autoconf -*-
2
3# Define some macros required for proper operation of code in lib/*.c
4# on MSDOS/Windows systems.
5
6# Copyright (C) 2000-2001, 2004-2006, 2009-2010 Free Software Foundation, Inc.
7# This file is free software; the Free Software Foundation
8# gives unlimited permission to copy and/or distribute it,
9# with or without modifications, as long as this notice is preserved.
10
11# From Jim Meyering.
12
13AC_DEFUN([gl_AC_DOS],
14 [
15 AC_CACHE_CHECK([whether system is Windows or MSDOS], [ac_cv_win_or_dos],
16 [
17 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
18#if !defined _WIN32 && !defined __WIN32__ && !defined __MSDOS__ && !defined __CYGWIN__
19neither MSDOS nor Windows
20#endif]])],
21 [ac_cv_win_or_dos=yes],
22 [ac_cv_win_or_dos=no])
23 ])
24
25 if test x"$ac_cv_win_or_dos" = xyes; then
26 ac_fs_accepts_drive_letter_prefix=1
27 ac_fs_backslash_is_file_name_separator=1
28 AC_CACHE_CHECK([whether drive letter can start relative path],
29 [ac_cv_drive_letter_can_be_relative],
30 [
31 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
32#if defined __CYGWIN__
33drive letters are always absolute
34#endif]])],
35 [ac_cv_drive_letter_can_be_relative=yes],
36 [ac_cv_drive_letter_can_be_relative=no])
37 ])
38 if test x"$ac_cv_drive_letter_can_be_relative" = xyes; then
39 ac_fs_drive_letter_can_be_relative=1
40 else
41 ac_fs_drive_letter_can_be_relative=0
42 fi
43 else
44 ac_fs_accepts_drive_letter_prefix=0
45 ac_fs_backslash_is_file_name_separator=0
46 ac_fs_drive_letter_can_be_relative=0
47 fi
48
49 AC_DEFINE_UNQUOTED([FILE_SYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX],
50 $ac_fs_accepts_drive_letter_prefix,
51 [Define on systems for which file names may have a so-called
52 `drive letter' prefix, define this to compute the length of that
53 prefix, including the colon.])
54
55 AH_VERBATIM(ISSLASH,
56 [#if FILE_SYSTEM_BACKSLASH_IS_FILE_NAME_SEPARATOR
57# define ISSLASH(C) ((C) == '/' || (C) == '\\')
58#else
59# define ISSLASH(C) ((C) == '/')
60#endif])
61
62 AC_DEFINE_UNQUOTED([FILE_SYSTEM_BACKSLASH_IS_FILE_NAME_SEPARATOR],
63 $ac_fs_backslash_is_file_name_separator,
64 [Define if the backslash character may also serve as a file name
65 component separator.])
66
67 AC_DEFINE_UNQUOTED([FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE],
68 $ac_fs_drive_letter_can_be_relative,
69 [Define if a drive letter prefix denotes a relative path if it is
70 not followed by a file name component separator.])
71 ])
diff --git a/gl/m4/double-slash-root.m4 b/gl/m4/double-slash-root.m4
index 66a79c0..bd6f867 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 4 -*- Autoconf -*- 1# double-slash-root.m4 serial 4 -*- Autoconf -*-
2dnl Copyright (C) 2006, 2008-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2006, 2008-2013 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.
diff --git a/gl/m4/dup2.m4 b/gl/m4/dup2.m4
deleted file mode 100644
index 998d66f..0000000
--- a/gl/m4/dup2.m4
+++ /dev/null
@@ -1,58 +0,0 @@
1#serial 10
2dnl Copyright (C) 2002, 2005, 2007, 2009-2010 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_DUP2],
8[
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10 AC_REQUIRE([AC_CANONICAL_HOST])
11 AC_CHECK_FUNCS_ONCE([dup2])
12 if test $ac_cv_func_dup2 = no; then
13 HAVE_DUP2=0
14 AC_LIBOBJ([dup2])
15 else
16 AC_CACHE_CHECK([whether dup2 works], [gl_cv_func_dup2_works],
17 [AC_RUN_IFELSE([
18 AC_LANG_PROGRAM([[#include <unistd.h>
19#include <errno.h>]],
20 [if (dup2 (1, 1) == 0)
21 return 1;
22 close (0);
23 if (dup2 (0, 0) != -1)
24 return 2;
25 /* Many gnulib modules require POSIX conformance of EBADF. */
26 if (dup2 (1, 1000000) == -1 && errno != EBADF)
27 return 3;
28 return 0;
29 ])
30 ],
31 [gl_cv_func_dup2_works=yes], [gl_cv_func_dup2_works=no],
32 [case "$host_os" in
33 mingw*) # on this platform, dup2 always returns 0 for success
34 gl_cv_func_dup2_works=no;;
35 cygwin*) # on cygwin 1.5.x, dup2(1,1) returns 0
36 gl_cv_func_dup2_works=no;;
37 linux*) # On linux between 2008-07-27 and 2009-05-11, dup2 of a
38 # closed fd may yield -EBADF instead of -1 / errno=EBADF.
39 gl_cv_func_dup2_works=no;;
40 freebsd*) # on FreeBSD 6.1, dup2(1,1000000) gives EMFILE, not EBADF.
41 gl_cv_func_dup2_works=no;;
42 *) gl_cv_func_dup2_works=yes;;
43 esac])
44 ])
45 if test "$gl_cv_func_dup2_works" = no; then
46 gl_REPLACE_DUP2
47 fi
48 fi
49])
50
51AC_DEFUN([gl_REPLACE_DUP2],
52[
53 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
54 if test $ac_cv_func_dup2 = yes; then
55 REPLACE_DUP2=1
56 fi
57 AC_LIBOBJ([dup2])
58])
diff --git a/gl/m4/eealloc.m4 b/gl/m4/eealloc.m4
index 63dd920..c640ec1 100644
--- a/gl/m4/eealloc.m4
+++ b/gl/m4/eealloc.m4
@@ -1,5 +1,5 @@
1# eealloc.m4 serial 2 1# eealloc.m4 serial 3
2dnl Copyright (C) 2003, 2009, 2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2003, 2009-2013 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,6 @@ AC_DEFUN([gl_EEALLOC],
8[ 8[
9 AC_REQUIRE([gl_EEMALLOC]) 9 AC_REQUIRE([gl_EEMALLOC])
10 AC_REQUIRE([gl_EEREALLOC]) 10 AC_REQUIRE([gl_EEREALLOC])
11 AC_REQUIRE([AC_C_INLINE])
12]) 11])
13 12
14AC_DEFUN([gl_EEMALLOC], 13AC_DEFUN([gl_EEMALLOC],
diff --git a/gl/m4/environ.m4 b/gl/m4/environ.m4
index 4c6849a..593a33e 100644
--- a/gl/m4/environ.m4
+++ b/gl/m4/environ.m4
@@ -1,5 +1,5 @@
1# environ.m4 serial 4 1# environ.m4 serial 6
2dnl Copyright (C) 2001-2004, 2006-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2001-2004, 2006-2013 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,16 @@ AC_DEFUN_ONCE([gl_ENVIRON],
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) 9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10 dnl Persuade glibc <unistd.h> to declare environ. 10 dnl Persuade glibc <unistd.h> to declare environ.
11 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) 11 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
12 gt_CHECK_VAR_DECL([#include <unistd.h>], environ) 12
13 AC_CHECK_HEADERS_ONCE([unistd.h])
14 gt_CHECK_VAR_DECL(
15 [#if HAVE_UNISTD_H
16 #include <unistd.h>
17 #endif
18 /* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>. */
19 #include <stdlib.h>
20 ],
21 [environ])
13 if test $gt_cv_var_environ_declaration != yes; then 22 if test $gt_cv_var_environ_declaration != yes; then
14 HAVE_DECL_ENVIRON=0 23 HAVE_DECL_ENVIRON=0
15 fi 24 fi
@@ -22,11 +31,13 @@ AC_DEFUN([gt_CHECK_VAR_DECL],
22 define([gt_cv_var], [gt_cv_var_]$2[_declaration]) 31 define([gt_cv_var], [gt_cv_var_]$2[_declaration])
23 AC_MSG_CHECKING([if $2 is properly declared]) 32 AC_MSG_CHECKING([if $2 is properly declared])
24 AC_CACHE_VAL([gt_cv_var], [ 33 AC_CACHE_VAL([gt_cv_var], [
25 AC_TRY_COMPILE([$1 34 AC_COMPILE_IFELSE(
26 extern struct { int foo; } $2;], 35 [AC_LANG_PROGRAM(
27 [$2.foo = 1;], 36 [[$1
28 gt_cv_var=no, 37 extern struct { int foo; } $2;]],
29 gt_cv_var=yes)]) 38 [[$2.foo = 1;]])],
39 [gt_cv_var=no],
40 [gt_cv_var=yes])])
30 AC_MSG_RESULT([$gt_cv_var]) 41 AC_MSG_RESULT([$gt_cv_var])
31 if test $gt_cv_var = yes; then 42 if test $gt_cv_var = yes; then
32 AC_DEFINE([HAVE_]m4_translit($2, [a-z], [A-Z])[_DECL], 1, 43 AC_DEFINE([HAVE_]m4_translit($2, [a-z], [A-Z])[_DECL], 1,
diff --git a/gl/m4/errno_h.m4 b/gl/m4/errno_h.m4
index d02a039..c813ea5 100644
--- a/gl/m4/errno_h.m4
+++ b/gl/m4/errno_h.m4
@@ -1,5 +1,5 @@
1# errno_h.m4 serial 6 1# errno_h.m4 serial 12
2dnl Copyright (C) 2004, 2006, 2008, 2009, 2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2004, 2006, 2008-2013 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,6 +10,9 @@ AC_DEFUN_ONCE([gl_HEADER_ERRNO_H],
10 AC_CACHE_CHECK([for complete errno.h], [gl_cv_header_errno_h_complete], [ 10 AC_CACHE_CHECK([for complete errno.h], [gl_cv_header_errno_h_complete], [
11 AC_EGREP_CPP([booboo],[ 11 AC_EGREP_CPP([booboo],[
12#include <errno.h> 12#include <errno.h>
13#if !defined ETXTBSY
14booboo
15#endif
13#if !defined ENOMSG 16#if !defined ENOMSG
14booboo 17booboo
15#endif 18#endif
@@ -34,12 +37,30 @@ booboo
34#if !defined ENOTSUP 37#if !defined ENOTSUP
35booboo 38booboo
36#endif 39#endif
40#if !defined ENETRESET
41booboo
42#endif
43#if !defined ECONNABORTED
44booboo
45#endif
37#if !defined ESTALE 46#if !defined ESTALE
38booboo 47booboo
39#endif 48#endif
49#if !defined EDQUOT
50booboo
51#endif
40#if !defined ECANCELED 52#if !defined ECANCELED
41booboo 53booboo
42#endif 54#endif
55#if !defined EOWNERDEAD
56booboo
57#endif
58#if !defined ENOTRECOVERABLE
59booboo
60#endif
61#if !defined EILSEQ
62booboo
63#endif
43 ], 64 ],
44 [gl_cv_header_errno_h_complete=no], 65 [gl_cv_header_errno_h_complete=no],
45 [gl_cv_header_errno_h_complete=yes]) 66 [gl_cv_header_errno_h_complete=yes])
@@ -47,10 +68,11 @@ booboo
47 if test $gl_cv_header_errno_h_complete = yes; then 68 if test $gl_cv_header_errno_h_complete = yes; then
48 ERRNO_H='' 69 ERRNO_H=''
49 else 70 else
50 gl_CHECK_NEXT_HEADERS([errno.h]) 71 gl_NEXT_HEADERS([errno.h])
51 ERRNO_H='errno.h' 72 ERRNO_H='errno.h'
52 fi 73 fi
53 AC_SUBST([ERRNO_H]) 74 AC_SUBST([ERRNO_H])
75 AM_CONDITIONAL([GL_GENERATE_ERRNO_H], [test -n "$ERRNO_H"])
54 gl_REPLACE_ERRNO_VALUE([EMULTIHOP]) 76 gl_REPLACE_ERRNO_VALUE([EMULTIHOP])
55 gl_REPLACE_ERRNO_VALUE([ENOLINK]) 77 gl_REPLACE_ERRNO_VALUE([ENOLINK])
56 gl_REPLACE_ERRNO_VALUE([EOVERFLOW]) 78 gl_REPLACE_ERRNO_VALUE([EOVERFLOW])
diff --git a/gl/m4/error.m4 b/gl/m4/error.m4
index 9f1307a..29e6fdc 100644
--- a/gl/m4/error.m4
+++ b/gl/m4/error.m4
@@ -1,6 +1,6 @@
1#serial 12 1#serial 14
2 2
3# Copyright (C) 1996-1998, 2001-2004, 2009-2010 Free Software Foundation, Inc. 3# Copyright (C) 1996-1998, 2001-2004, 2009-2013 Free Software Foundation, Inc.
4# 4#
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,
@@ -8,15 +8,20 @@
8 8
9AC_DEFUN([gl_ERROR], 9AC_DEFUN([gl_ERROR],
10[ 10[
11 AC_FUNC_ERROR_AT_LINE 11 dnl We don't use AC_FUNC_ERROR_AT_LINE any more, because it is no longer
12 dnl Note: AC_FUNC_ERROR_AT_LINE does AC_LIBSOURCES([error.h, error.c]). 12 dnl maintained in Autoconf and because it invokes AC_LIBOBJ.
13 gl_PREREQ_ERROR 13 AC_CACHE_CHECK([for error_at_line], [ac_cv_lib_error_at_line],
14 [AC_LINK_IFELSE(
15 [AC_LANG_PROGRAM(
16 [[#include <error.h>]],
17 [[error_at_line (0, 0, "", 0, "an error occurred");]])],
18 [ac_cv_lib_error_at_line=yes],
19 [ac_cv_lib_error_at_line=no])])
14]) 20])
15 21
16# Prerequisites of lib/error.c. 22# Prerequisites of lib/error.c.
17AC_DEFUN([gl_PREREQ_ERROR], 23AC_DEFUN([gl_PREREQ_ERROR],
18[ 24[
19 AC_REQUIRE([AC_FUNC_STRERROR_R]) 25 AC_REQUIRE([AC_FUNC_STRERROR_R])
20 AC_REQUIRE([AC_C_INLINE])
21 : 26 :
22]) 27])
diff --git a/gl/m4/exponentd.m4 b/gl/m4/exponentd.m4
new file mode 100644
index 0000000..09df468
--- /dev/null
+++ b/gl/m4/exponentd.m4
@@ -0,0 +1,116 @@
1# exponentd.m4 serial 3
2dnl Copyright (C) 2007-2008, 2010-2013 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.
6AC_DEFUN([gl_DOUBLE_EXPONENT_LOCATION],
7[
8 AC_CACHE_CHECK([where to find the exponent in a 'double'],
9 [gl_cv_cc_double_expbit0],
10 [
11 AC_RUN_IFELSE(
12 [AC_LANG_SOURCE([[
13#include <float.h>
14#include <stddef.h>
15#include <stdio.h>
16#include <string.h>
17#define NWORDS \
18 ((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int))
19typedef union { double value; unsigned int word[NWORDS]; } memory_double;
20static unsigned int ored_words[NWORDS];
21static unsigned int anded_words[NWORDS];
22static void add_to_ored_words (double x)
23{
24 memory_double m;
25 size_t i;
26 /* Clear it first, in case sizeof (double) < sizeof (memory_double). */
27 memset (&m, 0, sizeof (memory_double));
28 m.value = x;
29 for (i = 0; i < NWORDS; i++)
30 {
31 ored_words[i] |= m.word[i];
32 anded_words[i] &= m.word[i];
33 }
34}
35int main ()
36{
37 size_t j;
38 FILE *fp = fopen ("conftest.out", "w");
39 if (fp == NULL)
40 return 1;
41 for (j = 0; j < NWORDS; j++)
42 anded_words[j] = ~ (unsigned int) 0;
43 add_to_ored_words (0.25);
44 add_to_ored_words (0.5);
45 add_to_ored_words (1.0);
46 add_to_ored_words (2.0);
47 add_to_ored_words (4.0);
48 /* Remove bits that are common (e.g. if representation of the first mantissa
49 bit is explicit). */
50 for (j = 0; j < NWORDS; j++)
51 ored_words[j] &= ~anded_words[j];
52 /* Now find the nonzero word. */
53 for (j = 0; j < NWORDS; j++)
54 if (ored_words[j] != 0)
55 break;
56 if (j < NWORDS)
57 {
58 size_t i;
59 for (i = j + 1; i < NWORDS; i++)
60 if (ored_words[i] != 0)
61 {
62 fprintf (fp, "unknown");
63 return (fclose (fp) != 0);
64 }
65 for (i = 0; ; i++)
66 if ((ored_words[j] >> i) & 1)
67 {
68 fprintf (fp, "word %d bit %d", (int) j, (int) i);
69 return (fclose (fp) != 0);
70 }
71 }
72 fprintf (fp, "unknown");
73 return (fclose (fp) != 0);
74}
75 ]])],
76 [gl_cv_cc_double_expbit0=`cat conftest.out`],
77 [gl_cv_cc_double_expbit0="unknown"],
78 [
79 dnl On ARM, there are two 'double' floating-point formats, used by
80 dnl different sets of instructions: The older FPA instructions assume
81 dnl that they are stored in big-endian word order, while the words
82 dnl (like integer types) are stored in little-endian byte order.
83 dnl The newer VFP instructions assume little-endian order
84 dnl consistently.
85 AC_EGREP_CPP([mixed_endianness], [
86#if defined arm || defined __arm || defined __arm__
87 mixed_endianness
88#endif
89 ],
90 [gl_cv_cc_double_expbit0="unknown"],
91 [
92 pushdef([AC_MSG_CHECKING],[:])dnl
93 pushdef([AC_MSG_RESULT],[:])dnl
94 pushdef([AC_MSG_RESULT_UNQUOTED],[:])dnl
95 AC_C_BIGENDIAN(
96 [gl_cv_cc_double_expbit0="word 0 bit 20"],
97 [gl_cv_cc_double_expbit0="word 1 bit 20"],
98 [gl_cv_cc_double_expbit0="unknown"])
99 popdef([AC_MSG_RESULT_UNQUOTED])dnl
100 popdef([AC_MSG_RESULT])dnl
101 popdef([AC_MSG_CHECKING])dnl
102 ])
103 ])
104 rm -f conftest.out
105 ])
106 case "$gl_cv_cc_double_expbit0" in
107 word*bit*)
108 word=`echo "$gl_cv_cc_double_expbit0" | sed -e 's/word //' -e 's/ bit.*//'`
109 bit=`echo "$gl_cv_cc_double_expbit0" | sed -e 's/word.*bit //'`
110 AC_DEFINE_UNQUOTED([DBL_EXPBIT0_WORD], [$word],
111 [Define as the word index where to find the exponent of 'double'.])
112 AC_DEFINE_UNQUOTED([DBL_EXPBIT0_BIT], [$bit],
113 [Define as the bit index in the word where to find bit 0 of the exponent of 'double'.])
114 ;;
115 esac
116])
diff --git a/gl/m4/extensions.m4 b/gl/m4/extensions.m4
index 7d9458a..e30f122 100644
--- a/gl/m4/extensions.m4
+++ b/gl/m4/extensions.m4
@@ -1,14 +1,14 @@
1# serial 9 -*- Autoconf -*- 1# serial 13 -*- 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-2010 Free Software Foundation, Inc. 4# Copyright (C) 2003, 2006-2013 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.
8 8
9# This definition of AC_USE_SYSTEM_EXTENSIONS is stolen from CVS 9# This definition of AC_USE_SYSTEM_EXTENSIONS is stolen from git
10# Autoconf. Perhaps we can remove this once we can assume Autoconf 10# Autoconf. Perhaps we can remove this once we can assume Autoconf
11# 2.62 or later everywhere, but since CVS Autoconf mutates rapidly 11# 2.70 or later everywhere, but since Autoconf mutates rapidly
12# enough in this area it's likely we'll need to redefine 12# enough in this area it's likely we'll need to redefine
13# AC_USE_SYSTEM_EXTENSIONS for quite some time. 13# AC_USE_SYSTEM_EXTENSIONS for quite some time.
14 14
@@ -30,6 +30,7 @@
30# ------------------------ 30# ------------------------
31# Enable extensions on systems that normally disable them, 31# Enable extensions on systems that normally disable them,
32# typically due to standards-conformance issues. 32# typically due to standards-conformance issues.
33#
33# Remember that #undef in AH_VERBATIM gets replaced with #define by 34# Remember that #undef in AH_VERBATIM gets replaced with #define by
34# AC_DEFINE. The goal here is to define all known feature-enabling 35# AC_DEFINE. The goal here is to define all known feature-enabling
35# macros, then, if reports of conflicts are made, disable macros that 36# macros, then, if reports of conflicts are made, disable macros that
@@ -38,35 +39,31 @@ AC_DEFUN_ONCE([AC_USE_SYSTEM_EXTENSIONS],
38[AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl 39[AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
39AC_BEFORE([$0], [AC_RUN_IFELSE])dnl 40AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
40 41
41 AC_REQUIRE([AC_CANONICAL_HOST])
42
43 AC_CHECK_HEADER([minix/config.h], [MINIX=yes], [MINIX=]) 42 AC_CHECK_HEADER([minix/config.h], [MINIX=yes], [MINIX=])
44 if test "$MINIX" = yes; then 43 if test "$MINIX" = yes; then
45 AC_DEFINE([_POSIX_SOURCE], [1], 44 AC_DEFINE([_POSIX_SOURCE], [1],
46 [Define to 1 if you need to in order for `stat' and other 45 [Define to 1 if you need to in order for 'stat' and other
47 things to work.]) 46 things to work.])
48 AC_DEFINE([_POSIX_1_SOURCE], [2], 47 AC_DEFINE([_POSIX_1_SOURCE], [2],
49 [Define to 2 if the system does not provide POSIX.1 features 48 [Define to 2 if the system does not provide POSIX.1 features
50 except with this defined.]) 49 except with this defined.])
51 AC_DEFINE([_MINIX], [1], 50 AC_DEFINE([_MINIX], [1],
52 [Define to 1 if on MINIX.]) 51 [Define to 1 if on MINIX.])
52 AC_DEFINE([_NETBSD_SOURCE], [1],
53 [Define to 1 to make NetBSD features available. MINIX 3 needs this.])
53 fi 54 fi
54 55
55 dnl HP-UX 11.11 defines mbstate_t only if _XOPEN_SOURCE is defined to 500, 56dnl Use a different key than __EXTENSIONS__, as that name broke existing
56 dnl regardless of whether the flags -Ae or _D_HPUX_SOURCE=1 are already 57dnl configure.ac when using autoheader 2.62.
57 dnl provided. 58 AH_VERBATIM([USE_SYSTEM_EXTENSIONS],
58 case "$host_os" in
59 hpux*)
60 AC_DEFINE([_XOPEN_SOURCE], [500],
61 [Define to 500 only on HP-UX.])
62 ;;
63 esac
64
65 AH_VERBATIM([__EXTENSIONS__],
66[/* Enable extensions on AIX 3, Interix. */ 59[/* Enable extensions on AIX 3, Interix. */
67#ifndef _ALL_SOURCE 60#ifndef _ALL_SOURCE
68# undef _ALL_SOURCE 61# undef _ALL_SOURCE
69#endif 62#endif
63/* Enable general extensions on OS X. */
64#ifndef _DARWIN_C_SOURCE
65# undef _DARWIN_C_SOURCE
66#endif
70/* Enable GNU extensions on systems that have them. */ 67/* Enable GNU extensions on systems that have them. */
71#ifndef _GNU_SOURCE 68#ifndef _GNU_SOURCE
72# undef _GNU_SOURCE 69# undef _GNU_SOURCE
@@ -79,6 +76,12 @@ AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
79#ifndef _TANDEM_SOURCE 76#ifndef _TANDEM_SOURCE
80# undef _TANDEM_SOURCE 77# undef _TANDEM_SOURCE
81#endif 78#endif
79/* Enable X/Open extensions if necessary. HP-UX 11.11 defines
80 mbstate_t only if _XOPEN_SOURCE is defined to 500, regardless of
81 whether compiling with -Ae or -D_HPUX_SOURCE=1. */
82#ifndef _XOPEN_SOURCE
83# undef _XOPEN_SOURCE
84#endif
82/* Enable general extensions on Solaris. */ 85/* Enable general extensions on Solaris. */
83#ifndef __EXTENSIONS__ 86#ifndef __EXTENSIONS__
84# undef __EXTENSIONS__ 87# undef __EXTENSIONS__
@@ -95,9 +98,26 @@ AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
95 test $ac_cv_safe_to_define___extensions__ = yes && 98 test $ac_cv_safe_to_define___extensions__ = yes &&
96 AC_DEFINE([__EXTENSIONS__]) 99 AC_DEFINE([__EXTENSIONS__])
97 AC_DEFINE([_ALL_SOURCE]) 100 AC_DEFINE([_ALL_SOURCE])
101 AC_DEFINE([_DARWIN_C_SOURCE])
98 AC_DEFINE([_GNU_SOURCE]) 102 AC_DEFINE([_GNU_SOURCE])
99 AC_DEFINE([_POSIX_PTHREAD_SEMANTICS]) 103 AC_DEFINE([_POSIX_PTHREAD_SEMANTICS])
100 AC_DEFINE([_TANDEM_SOURCE]) 104 AC_DEFINE([_TANDEM_SOURCE])
105 AC_CACHE_CHECK([whether _XOPEN_SOURCE should be defined],
106 [ac_cv_should_define__xopen_source],
107 [ac_cv_should_define__xopen_source=no
108 AC_COMPILE_IFELSE(
109 [AC_LANG_PROGRAM([[
110 #include <wchar.h>
111 mbstate_t x;]])],
112 [],
113 [AC_COMPILE_IFELSE(
114 [AC_LANG_PROGRAM([[
115 #define _XOPEN_SOURCE 500
116 #include <wchar.h>
117 mbstate_t x;]])],
118 [ac_cv_should_define__xopen_source=yes])])])
119 test $ac_cv_should_define__xopen_source = yes &&
120 AC_DEFINE([_XOPEN_SOURCE], [500])
101])# AC_USE_SYSTEM_EXTENSIONS 121])# AC_USE_SYSTEM_EXTENSIONS
102 122
103# gl_USE_SYSTEM_EXTENSIONS 123# gl_USE_SYSTEM_EXTENSIONS
diff --git a/gl/m4/extern-inline.m4 b/gl/m4/extern-inline.m4
new file mode 100644
index 0000000..c4c5e7f
--- /dev/null
+++ b/gl/m4/extern-inline.m4
@@ -0,0 +1,70 @@
1dnl 'extern inline' a la ISO C99.
2
3dnl Copyright 2012-2013 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8AC_DEFUN([gl_EXTERN_INLINE],
9[
10 AH_VERBATIM([extern_inline],
11[/* Please see the Gnulib manual for how to use these macros.
12
13 Suppress extern inline with HP-UX cc, as it appears to be broken; see
14 <http://lists.gnu.org/archive/html/bug-texinfo/2013-02/msg00030.html>.
15
16 Suppress extern inline with Sun C in standards-conformance mode, as it
17 mishandles inline functions that call each other. E.g., for 'inline void f
18 (void) { } inline void g (void) { f (); }', c99 incorrectly complains
19 'reference to static identifier "f" in extern inline function'.
20 This bug was observed with Sun C 5.12 SunOS_i386 2011/11/16.
21
22 Suppress the use of extern inline on Apple's platforms, as Libc at least
23 through Libc-825.26 (2013-04-09) is incompatible with it; see, e.g.,
24 <http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html>.
25 Perhaps Apple will fix this some day. */
26#if ((__GNUC__ \
27 ? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \
28 : (199901L <= __STDC_VERSION__ \
29 && !defined __HP_cc \
30 && !(defined __SUNPRO_C && __STDC__))) \
31 && !defined __APPLE__)
32# define _GL_INLINE inline
33# define _GL_EXTERN_INLINE extern inline
34#elif (2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __STRICT_ANSI__ \
35 && !defined __APPLE__)
36# if __GNUC_GNU_INLINE__
37 /* __gnu_inline__ suppresses a GCC 4.2 diagnostic. */
38# define _GL_INLINE extern inline __attribute__ ((__gnu_inline__))
39# else
40# define _GL_INLINE extern inline
41# endif
42# define _GL_EXTERN_INLINE extern
43#else
44# define _GL_INLINE static _GL_UNUSED
45# define _GL_EXTERN_INLINE static _GL_UNUSED
46#endif
47
48#if 4 < __GNUC__ + (6 <= __GNUC_MINOR__)
49# if defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__
50# define _GL_INLINE_HEADER_CONST_PRAGMA
51# else
52# define _GL_INLINE_HEADER_CONST_PRAGMA \
53 _Pragma ("GCC diagnostic ignored \"-Wsuggest-attribute=const\"")
54# endif
55 /* Suppress GCC's bogus "no previous prototype for 'FOO'"
56 and "no previous declaration for 'FOO'" diagnostics,
57 when FOO is an inline function in the header; see
58 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113>. */
59# define _GL_INLINE_HEADER_BEGIN \
60 _Pragma ("GCC diagnostic push") \
61 _Pragma ("GCC diagnostic ignored \"-Wmissing-prototypes\"") \
62 _Pragma ("GCC diagnostic ignored \"-Wmissing-declarations\"") \
63 _GL_INLINE_HEADER_CONST_PRAGMA
64# define _GL_INLINE_HEADER_END \
65 _Pragma ("GCC diagnostic pop")
66#else
67# define _GL_INLINE_HEADER_BEGIN
68# define _GL_INLINE_HEADER_END
69#endif])
70])
diff --git a/gl/m4/fcntl-o.m4 b/gl/m4/fcntl-o.m4
index 1adacc8..87cc4bd 100644
--- a/gl/m4/fcntl-o.m4
+++ b/gl/m4/fcntl-o.m4
@@ -1,5 +1,5 @@
1# fcntl-o.m4 serial 2 1# fcntl-o.m4 serial 4
2dnl Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2006, 2009-2013 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,12 +17,21 @@ AC_DEFUN([gl_FCNTL_O_FLAGS],
17 m4_ifdef([AC_USE_SYSTEM_EXTENSIONS], 17 m4_ifdef([AC_USE_SYSTEM_EXTENSIONS],
18 [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])], 18 [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])],
19 [AC_REQUIRE([AC_GNU_SOURCE])]) 19 [AC_REQUIRE([AC_GNU_SOURCE])])
20
21 AC_CHECK_HEADERS_ONCE([unistd.h])
22 AC_CHECK_FUNCS_ONCE([symlink])
20 AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h], 23 AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h],
21 [AC_RUN_IFELSE( 24 [AC_RUN_IFELSE(
22 [AC_LANG_PROGRAM( 25 [AC_LANG_PROGRAM(
23 [[#include <sys/types.h> 26 [[#include <sys/types.h>
24 #include <sys/stat.h> 27 #include <sys/stat.h>
25 #include <unistd.h> 28 #if HAVE_UNISTD_H
29 # include <unistd.h>
30 #else /* on Windows with MSVC */
31 # include <io.h>
32 # include <stdlib.h>
33 # defined sleep(n) _sleep ((n) * 1000)
34 #endif
26 #include <fcntl.h> 35 #include <fcntl.h>
27 #ifndef O_NOATIME 36 #ifndef O_NOATIME
28 #define O_NOATIME 0 37 #define O_NOATIME 0
@@ -37,34 +46,74 @@ AC_DEFUN([gl_FCNTL_O_FLAGS],
37 }; 46 };
38 ]], 47 ]],
39 [[ 48 [[
40 int status = !constants; 49 int result = !constants;
50 #if HAVE_SYMLINK
41 { 51 {
42 static char const sym[] = "conftest.sym"; 52 static char const sym[] = "conftest.sym";
43 if (symlink (".", sym) != 0 53 if (symlink ("/dev/null", sym) != 0)
44 || close (open (sym, O_RDONLY | O_NOFOLLOW)) == 0) 54 result |= 2;
45 status |= 32; 55 else
56 {
57 int fd = open (sym, O_WRONLY | O_NOFOLLOW | O_CREAT, 0);
58 if (fd >= 0)
59 {
60 close (fd);
61 result |= 4;
62 }
63 }
64 if (unlink (sym) != 0 || symlink (".", sym) != 0)
65 result |= 2;
66 else
67 {
68 int fd = open (sym, O_RDONLY | O_NOFOLLOW);
69 if (fd >= 0)
70 {
71 close (fd);
72 result |= 4;
73 }
74 }
46 unlink (sym); 75 unlink (sym);
47 } 76 }
77 #endif
48 { 78 {
49 static char const file[] = "confdefs.h"; 79 static char const file[] = "confdefs.h";
50 int fd = open (file, O_RDONLY | O_NOATIME); 80 int fd = open (file, O_RDONLY | O_NOATIME);
51 char c; 81 if (fd < 0)
52 struct stat st0, st1; 82 result |= 8;
53 if (fd < 0 83 else
54 || fstat (fd, &st0) != 0 84 {
55 || sleep (1) != 0 85 struct stat st0;
56 || read (fd, &c, 1) != 1 86 if (fstat (fd, &st0) != 0)
57 || close (fd) != 0 87 result |= 16;
58 || stat (file, &st1) != 0 88 else
59 || st0.st_atime != st1.st_atime) 89 {
60 status |= 64; 90 char c;
91 sleep (1);
92 if (read (fd, &c, 1) != 1)
93 result |= 24;
94 else
95 {
96 if (close (fd) != 0)
97 result |= 32;
98 else
99 {
100 struct stat st1;
101 if (stat (file, &st1) != 0)
102 result |= 40;
103 else
104 if (st0.st_atime != st1.st_atime)
105 result |= 64;
106 }
107 }
108 }
109 }
61 } 110 }
62 return status;]])], 111 return result;]])],
63 [gl_cv_header_working_fcntl_h=yes], 112 [gl_cv_header_working_fcntl_h=yes],
64 [case $? in #( 113 [case $? in #(
65 32) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #( 114 4) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #(
66 64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #( 115 64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #(
67 96) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #( 116 68) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #(
68 *) gl_cv_header_working_fcntl_h='no';; 117 *) gl_cv_header_working_fcntl_h='no';;
69 esac], 118 esac],
70 [gl_cv_header_working_fcntl_h=cross-compiling])]) 119 [gl_cv_header_working_fcntl_h=cross-compiling])])
diff --git a/gl/m4/fcntl-safer.m4 b/gl/m4/fcntl-safer.m4
deleted file mode 100644
index 1a739b0..0000000
--- a/gl/m4/fcntl-safer.m4
+++ /dev/null
@@ -1,19 +0,0 @@
1#serial 7
2dnl Copyright (C) 2005-2007, 2009-2010 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FCNTL_SAFER],
8[
9 AC_LIBOBJ([open-safer])
10 AC_LIBOBJ([creat-safer])
11 # Prerequisites of lib/open-safer.c.
12 AC_REQUIRE([gl_PROMOTED_TYPE_MODE_T])
13])
14
15AC_DEFUN([gl_OPENAT_SAFER],
16[
17 AC_REQUIRE([gl_FCNTL_SAFER])
18 AC_LIBOBJ([openat-safer])
19])
diff --git a/gl/m4/fcntl.m4 b/gl/m4/fcntl.m4
deleted file mode 100644
index fcb5f44..0000000
--- a/gl/m4/fcntl.m4
+++ /dev/null
@@ -1,83 +0,0 @@
1# fcntl.m4 serial 3
2dnl Copyright (C) 2009, 2010 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7# For now, this module ensures that fcntl()
8# - supports F_DUPFD correctly
9# - supports or emulates F_DUPFD_CLOEXEC
10# - supports F_GETFD
11# Still to be ported to mingw:
12# - F_SETFD
13# - F_GETFL, F_SETFL
14# - F_GETOWN, F_SETOWN
15# - F_GETLK, F_SETLK, F_SETLKW
16AC_DEFUN([gl_FUNC_FCNTL],
17[
18 dnl Persuade glibc to expose F_DUPFD_CLOEXEC.
19 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
20 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
21 AC_REQUIRE([AC_CANONICAL_HOST])
22 AC_CHECK_FUNCS_ONCE([fcntl])
23 if test $ac_cv_func_fcntl = no; then
24 gl_REPLACE_FCNTL
25 else
26 dnl cygwin 1.5.x F_DUPFD has wrong errno, and allows negative target
27 AC_CACHE_CHECK([whether fcntl handles F_DUPFD correctly],
28 [gl_cv_func_fcntl_f_dupfd_works],
29 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
30#include <fcntl.h>
31]], [[return fcntl (0, F_DUPFD, -1) != -1;
32 ]])],
33 [gl_cv_func_fcntl_f_dupfd_works=yes],
34 [gl_cv_func_fcntl_f_dupfd_works=no],
35 [# Guess that it works on glibc systems
36 case $host_os in #((
37 *-gnu*) gl_cv_func_fcntl_f_dupfd_works="guessing yes";;
38 *) gl_cv_func_fcntl_f_dupfd_works="guessing no";;
39 esac])])
40 case $gl_cv_func_fcntl_f_dupfd_works in
41 *yes) ;;
42 *) gl_REPLACE_FCNTL
43 AC_DEFINE([FCNTL_DUPFD_BUGGY], [1], [Define this to 1 if F_DUPFD
44 behavior does not match POSIX]) ;;
45 esac
46
47 dnl Many systems lack F_DUPFD_CLOEXEC
48 AC_CACHE_CHECK([whether fcntl understands F_DUPFD_CLOEXEC],
49 [gl_cv_func_fcntl_f_dupfd_cloexec],
50 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
51#include <fcntl.h>
52#ifndef F_DUPFD_CLOEXEC
53choke me
54#endif
55 ]])],
56 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
57#ifdef __linux__
58/* The Linux kernel only added F_DUPFD_CLOEXEC in 2.6.24, so we always replace
59 it to support the semantics on older kernels that failed with EINVAL. */
60choke me
61#endif
62 ]])],
63 [gl_cv_func_fcntl_f_dupfd_cloexec=yes],
64 [gl_cv_func_fcntl_f_dupfd_cloexec="needs runtime check"])],
65 [gl_cv_func_fcntl_f_dupfd_cloexec=no])])
66 if test "$gl_cv_func_fcntl_f_dupfd_cloexec" != yes; then
67 gl_REPLACE_FCNTL
68 dnl No witness macro needed for this bug.
69 fi
70 fi
71])
72
73AC_DEFUN([gl_REPLACE_FCNTL],
74[
75 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
76 AC_CHECK_FUNCS_ONCE([fcntl])
77 if test $ac_cv_func_fcntl = no; then
78 HAVE_FCNTL=0
79 else
80 REPLACE_FCNTL=1
81 fi
82 AC_LIBOBJ([fcntl])
83])
diff --git a/gl/m4/fcntl_h.m4 b/gl/m4/fcntl_h.m4
deleted file mode 100644
index e41915c..0000000
--- a/gl/m4/fcntl_h.m4
+++ /dev/null
@@ -1,43 +0,0 @@
1# serial 12
2# Configure fcntl.h.
3dnl Copyright (C) 2006, 2007, 2009, 2010 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8dnl Written by Paul Eggert.
9
10AC_DEFUN([gl_FCNTL_H],
11[
12 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
13 AC_REQUIRE([gl_FCNTL_O_FLAGS])
14 gl_CHECK_NEXT_HEADERS([fcntl.h])
15
16 dnl Check for declarations of anything we want to poison if the
17 dnl corresponding gnulib module is not in use, if it is not common
18 dnl enough to be declared everywhere.
19 gl_WARN_ON_USE_PREPARE([[#include <fcntl.h>
20 ]], [fcntl openat])
21])
22
23AC_DEFUN([gl_FCNTL_MODULE_INDICATOR],
24[
25 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
26 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
27 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
28 dnl Define it also as a C macro, for the benefit of the unit tests.
29 gl_MODULE_INDICATOR_FOR_TESTS([$1])
30])
31
32AC_DEFUN([gl_FCNTL_H_DEFAULTS],
33[
34 GNULIB_FCNTL=0; AC_SUBST([GNULIB_FCNTL])
35 GNULIB_OPEN=0; AC_SUBST([GNULIB_OPEN])
36 GNULIB_OPENAT=0; AC_SUBST([GNULIB_OPENAT])
37 dnl Assume proper GNU behavior unless another module says otherwise.
38 HAVE_FCNTL=1; AC_SUBST([HAVE_FCNTL])
39 HAVE_OPENAT=1; AC_SUBST([HAVE_OPENAT])
40 REPLACE_FCNTL=0; AC_SUBST([REPLACE_FCNTL])
41 REPLACE_OPEN=0; AC_SUBST([REPLACE_OPEN])
42 REPLACE_OPENAT=0; AC_SUBST([REPLACE_OPENAT])
43])
diff --git a/gl/m4/float_h.m4 b/gl/m4/float_h.m4
index a74a0d9..397f2d1 100644
--- a/gl/m4/float_h.m4
+++ b/gl/m4/float_h.m4
@@ -1,5 +1,5 @@
1# float_h.m4 serial 3 1# float_h.m4 serial 9
2dnl Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2007, 2009-2013 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,11 +9,90 @@ AC_DEFUN([gl_FLOAT_H],
9 AC_REQUIRE([AC_PROG_CC]) 9 AC_REQUIRE([AC_PROG_CC])
10 AC_REQUIRE([AC_CANONICAL_HOST]) 10 AC_REQUIRE([AC_CANONICAL_HOST])
11 FLOAT_H= 11 FLOAT_H=
12 REPLACE_FLOAT_LDBL=0
12 case "$host_os" in 13 case "$host_os" in
13 beos* | openbsd*) 14 aix* | beos* | openbsd* | mirbsd* | irix*)
14 FLOAT_H=float.h 15 FLOAT_H=float.h
15 gl_CHECK_NEXT_HEADERS([float.h]) 16 ;;
17 freebsd*)
18 case "$host_cpu" in
19changequote(,)dnl
20 i[34567]86 )
21changequote([,])dnl
22 FLOAT_H=float.h
23 ;;
24 x86_64 )
25 # On x86_64 systems, the C compiler may still be generating
26 # 32-bit code.
27 AC_EGREP_CPP([yes],
28 [#if defined __LP64__ || defined __x86_64__ || defined __amd64__
29 yes
30 #endif],
31 [],
32 [FLOAT_H=float.h])
33 ;;
34 esac
35 ;;
36 linux*)
37 case "$host_cpu" in
38 powerpc*)
39 FLOAT_H=float.h
40 ;;
41 esac
42 ;;
43 esac
44 case "$host_os" in
45 aix* | freebsd* | linux*)
46 if test -n "$FLOAT_H"; then
47 REPLACE_FLOAT_LDBL=1
48 fi
16 ;; 49 ;;
17 esac 50 esac
51
52 dnl Test against glibc-2.7 Linux/SPARC64 bug.
53 REPLACE_ITOLD=0
54 AC_CACHE_CHECK([whether conversion from 'int' to 'long double' works],
55 [gl_cv_func_itold_works],
56 [
57 AC_RUN_IFELSE(
58 [AC_LANG_SOURCE([[
59int i = -1;
60volatile long double ld;
61int main ()
62{
63 ld += i * 1.0L;
64 if (ld > 0)
65 return 1;
66 return 0;
67}]])],
68 [gl_cv_func_itold_works=yes],
69 [gl_cv_func_itold_works=no],
70 [case "$host" in
71 sparc*-*-linux*)
72 AC_EGREP_CPP([yes],
73 [#if defined __LP64__ || defined __arch64__
74 yes
75 #endif],
76 [gl_cv_func_itold_works="guessing no"],
77 [gl_cv_func_itold_works="guessing yes"])
78 ;;
79 *) gl_cv_func_itold_works="guessing yes" ;;
80 esac
81 ])
82 ])
83 case "$gl_cv_func_itold_works" in
84 *no)
85 REPLACE_ITOLD=1
86 dnl We add the workaround to <float.h> but also to <math.h>,
87 dnl to increase the chances that the fix function gets pulled in.
88 FLOAT_H=float.h
89 ;;
90 esac
91
92 if test -n "$FLOAT_H"; then
93 gl_NEXT_HEADERS([float.h])
94 fi
18 AC_SUBST([FLOAT_H]) 95 AC_SUBST([FLOAT_H])
96 AM_CONDITIONAL([GL_GENERATE_FLOAT_H], [test -n "$FLOAT_H"])
97 AC_SUBST([REPLACE_ITOLD])
19]) 98])
diff --git a/gl/m4/floorf.m4 b/gl/m4/floorf.m4
index fb17a5e..c892ff9 100644
--- a/gl/m4/floorf.m4
+++ b/gl/m4/floorf.m4
@@ -1,16 +1,17 @@
1# floorf.m4 serial 6 1# floorf.m4 serial 13
2dnl Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2007, 2009-2013 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_FLOORF], 7AC_DEFUN([gl_FUNC_FLOORF],
8[ 8[
9 m4_divert_text([DEFAULTS], [gl_floorf_required=plain])
9 AC_REQUIRE([gl_MATH_H_DEFAULTS]) 10 AC_REQUIRE([gl_MATH_H_DEFAULTS])
10 dnl Persuade glibc <math.h> to declare floorf(). 11 dnl Persuade glibc <math.h> to declare floorf().
11 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) 12 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
12 dnl Test whether floorf() is declared. 13 dnl Test whether floorf() is declared.
13 AC_CHECK_DECLS([floorf], , , [#include <math.h>]) 14 AC_CHECK_DECLS([floorf], , , [[#include <math.h>]])
14 if test "$ac_cv_have_decl_floorf" = yes; then 15 if test "$ac_cv_have_decl_floorf" = yes; then
15 dnl Test whether floorf() can be used without libm. 16 dnl Test whether floorf() can be used without libm.
16 gl_FUNC_FLOORF_LIBS 17 gl_FUNC_FLOORF_LIBS
@@ -19,11 +20,54 @@ AC_DEFUN([gl_FUNC_FLOORF],
19 dnl libm.so, but not in the libm.so that the compiler uses. 20 dnl libm.so, but not in the libm.so that the compiler uses.
20 REPLACE_FLOORF=1 21 REPLACE_FLOORF=1
21 fi 22 fi
23 m4_ifdef([gl_FUNC_FLOORF_IEEE], [
24 if test $gl_floorf_required = ieee && test $REPLACE_FLOORF = 0; then
25 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
26 AC_CACHE_CHECK([whether floorf works according to ISO C 99 with IEC 60559],
27 [gl_cv_func_floorf_ieee],
28 [
29 save_LIBS="$LIBS"
30 LIBS="$LIBS $FLOORF_LIBM"
31 AC_RUN_IFELSE(
32 [AC_LANG_SOURCE([[
33#ifndef __NO_MATH_INLINES
34# define __NO_MATH_INLINES 1 /* for glibc */
35#endif
36#include <math.h>
37]gl_FLOAT_MINUS_ZERO_CODE[
38]gl_FLOAT_SIGNBIT_CODE[
39static float dummy (float f) { return 0; }
40int main (int argc, char *argv[])
41{
42 float (*my_floorf) (float) = argc ? floorf : dummy;
43 /* Test whether floorf (-0.0f) is -0.0f. */
44 if (signbitf (minus_zerof) && !signbitf (my_floorf (minus_zerof)))
45 return 1;
46 return 0;
47}
48 ]])],
49 [gl_cv_func_floorf_ieee=yes],
50 [gl_cv_func_floorf_ieee=no],
51 [case "$host_os" in
52 # Guess yes on glibc systems.
53 *-gnu*) gl_cv_func_floorf_ieee="guessing yes" ;;
54 # If we don't know, assume the worst.
55 *) gl_cv_func_floorf_ieee="guessing no" ;;
56 esac
57 ])
58 LIBS="$save_LIBS"
59 ])
60 case "$gl_cv_func_floorf_ieee" in
61 *yes) ;;
62 *) REPLACE_FLOORF=1 ;;
63 esac
64 fi
65 ])
22 else 66 else
23 HAVE_DECL_FLOORF=0 67 HAVE_DECL_FLOORF=0
24 fi 68 fi
25 if test $HAVE_DECL_FLOORF = 0 || test $REPLACE_FLOORF = 1; then 69 if test $HAVE_DECL_FLOORF = 0 || test $REPLACE_FLOORF = 1; then
26 AC_LIBOBJ([floorf]) 70 dnl No libraries are needed to link lib/floorf.c.
27 FLOORF_LIBM= 71 FLOORF_LIBM=
28 fi 72 fi
29 AC_SUBST([FLOORF_LIBM]) 73 AC_SUBST([FLOORF_LIBM])
@@ -35,24 +79,28 @@ AC_DEFUN([gl_FUNC_FLOORF_LIBS],
35[ 79[
36 gl_CACHE_VAL_SILENT([gl_cv_func_floorf_libm], [ 80 gl_CACHE_VAL_SILENT([gl_cv_func_floorf_libm], [
37 gl_cv_func_floorf_libm=? 81 gl_cv_func_floorf_libm=?
38 AC_TRY_LINK([ 82 AC_LINK_IFELSE(
39 #ifndef __NO_MATH_INLINES 83 [AC_LANG_PROGRAM(
40 # define __NO_MATH_INLINES 1 /* for glibc */ 84 [[#ifndef __NO_MATH_INLINES
41 #endif 85 # define __NO_MATH_INLINES 1 /* for glibc */
42 #include <math.h> 86 #endif
43 float x;], 87 #include <math.h>
44 [x = floorf(x);], 88 float (*funcptr) (float) = floorf;
89 float x;]],
90 [[x = funcptr(x) + floorf(x);]])],
45 [gl_cv_func_floorf_libm=]) 91 [gl_cv_func_floorf_libm=])
46 if test "$gl_cv_func_floorf_libm" = "?"; then 92 if test "$gl_cv_func_floorf_libm" = "?"; then
47 save_LIBS="$LIBS" 93 save_LIBS="$LIBS"
48 LIBS="$LIBS -lm" 94 LIBS="$LIBS -lm"
49 AC_TRY_LINK([ 95 AC_LINK_IFELSE(
50 #ifndef __NO_MATH_INLINES 96 [AC_LANG_PROGRAM(
51 # define __NO_MATH_INLINES 1 /* for glibc */ 97 [[#ifndef __NO_MATH_INLINES
52 #endif 98 # define __NO_MATH_INLINES 1 /* for glibc */
53 #include <math.h> 99 #endif
54 float x;], 100 #include <math.h>
55 [x = floorf(x);], 101 float (*funcptr) (float) = floorf;
102 float x;]],
103 [[x = funcptr(x) + floorf(x);]])],
56 [gl_cv_func_floorf_libm="-lm"]) 104 [gl_cv_func_floorf_libm="-lm"])
57 LIBS="$save_LIBS" 105 LIBS="$save_LIBS"
58 fi 106 fi
diff --git a/gl/m4/fstypename.m4 b/gl/m4/fstypename.m4
index 9e81efe..c72ecb8 100644
--- a/gl/m4/fstypename.m4
+++ b/gl/m4/fstypename.m4
@@ -6,7 +6,7 @@ dnl See if struct statfs has the f_fstypename member.
6dnl If so, define HAVE_STRUCT_STATFS_F_FSTYPENAME. 6dnl If so, define HAVE_STRUCT_STATFS_F_FSTYPENAME.
7dnl 7dnl
8 8
9# Copyright (C) 1998-1999, 2001, 2004, 2006, 2009-2010 Free Software 9# Copyright (C) 1998-1999, 2001, 2004, 2006, 2009-2013 Free Software
10# Foundation, Inc. 10# Foundation, Inc.
11# This file is free software; the Free Software Foundation 11# This file is free software; the Free Software Foundation
12# gives unlimited permission to copy and/or distribute it, 12# gives unlimited permission to copy and/or distribute it,
diff --git a/gl/m4/fsusage.m4 b/gl/m4/fsusage.m4
index 68684c2..6277bfa 100644
--- a/gl/m4/fsusage.m4
+++ b/gl/m4/fsusage.m4
@@ -1,7 +1,7 @@
1# serial 26 1# serial 30
2# Obtaining file system usage information. 2# Obtaining file system usage information.
3 3
4# Copyright (C) 1997-1998, 2000-2001, 2003-2010 Free Software Foundation, Inc. 4# Copyright (C) 1997-1998, 2000-2001, 2003-2013 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,
@@ -19,10 +19,6 @@ AC_DEFUN([gl_FSUSAGE],
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
23 AC_LIBOBJ([fsusage])
24 gl_PREREQ_FSUSAGE_EXTRA
25 fi
26]) 22])
27 23
28# Try to determine how a program can obtain file system usage information. 24# Try to determine how a program can obtain file system usage information.
@@ -33,6 +29,12 @@ AC_DEFUN([gl_FSUSAGE],
33 29
34AC_DEFUN([gl_FILE_SYSTEM_USAGE], 30AC_DEFUN([gl_FILE_SYSTEM_USAGE],
35[ 31[
32dnl Enable large-file support. This has the effect of changing the size
33dnl of field f_blocks in 'struct statvfs' from 32 bit to 64 bit on
34dnl glibc/Hurd, HP-UX 11, Solaris (32-bit mode). It also changes the size
35dnl of field f_blocks in 'struct statfs' from 32 bit to 64 bit on
36dnl Mac OS X >= 10.5 (32-bit mode).
37AC_REQUIRE([AC_SYS_LARGEFILE])
36 38
37AC_MSG_NOTICE([checking how to get file system space usage]) 39AC_MSG_NOTICE([checking how to get file system space usage])
38ac_fsusage_space=no 40ac_fsusage_space=no
@@ -40,37 +42,98 @@ ac_fsusage_space=no
40# Perform only the link test since it seems there are no variants of the 42# 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]) 43# 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 44# 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 45# 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 46# systems. That system is reported to work fine with STAT_STATFS4 which
45# is what it gets when this test fails. 47# is what it gets when this test fails.
46if test $ac_fsusage_space = no; then 48if test $ac_fsusage_space = no; then
47 # glibc/{Hurd,kFreeBSD}, MacOS X >= 10.4, FreeBSD >= 5.0, NetBSD >= 3.0, 49 # glibc/{Hurd,kFreeBSD}, FreeBSD >= 5.0, NetBSD >= 3.0,
48 # OpenBSD >= 4.4, AIX, HP-UX, IRIX, Solaris, Cygwin, Interix, BeOS. 50 # OpenBSD >= 4.4, AIX, HP-UX, IRIX, Solaris, Cygwin, Interix, BeOS.
49 AC_CACHE_CHECK([for statvfs function (SVR4)], [fu_cv_sys_stat_statvfs], 51 AC_CACHE_CHECK([for statvfs function (SVR4)], [fu_cv_sys_stat_statvfs],
50 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> 52 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
51#if defined __GLIBC__ && defined __linux__
52Do not use statvfs on systems with GNU libc on Linux, because that function
53stats all preceding entries in /proc/mounts, and that makes df hang if even
54one of the corresponding file systems is hard-mounted, but not available.
55statvfs in GNU libc on Hurd, BeOS, Haiku operates differently: it only makes
56a system call.
57#endif
58
59#ifdef __osf__ 53#ifdef __osf__
60"Do not use Tru64's statvfs implementation" 54"Do not use Tru64's statvfs implementation"
61#endif 55#endif
62 56
63#include <sys/statvfs.h>]], 57#include <sys/statvfs.h>
64 [[struct statvfs fsd; statvfs (0, &fsd);]])], 58
59struct statvfs fsd;
60
61#if defined __APPLE__ && defined __MACH__
62#include <limits.h>
63/* On Mac OS X >= 10.5, f_blocks in 'struct statvfs' is a 32-bit quantity;
64 that commonly limits file systems to 4 TiB. Whereas f_blocks in
65 'struct statfs' is a 64-bit type, thanks to the large-file support
66 that was enabled above. In this case, don't use statvfs(); use statfs()
67 instead. */
68int check_f_blocks_size[sizeof fsd.f_blocks * CHAR_BIT <= 32 ? -1 : 1];
69#endif
70]],
71 [[statvfs (0, &fsd);]])],
65 [fu_cv_sys_stat_statvfs=yes], 72 [fu_cv_sys_stat_statvfs=yes],
66 [fu_cv_sys_stat_statvfs=no])]) 73 [fu_cv_sys_stat_statvfs=no])])
67 if test $fu_cv_sys_stat_statvfs = yes; then 74 if test $fu_cv_sys_stat_statvfs = yes; then
68 ac_fsusage_space=yes 75 ac_fsusage_space=yes
69 AC_DEFINE([STAT_STATVFS], [1], 76 # AIX >= 5.2 has statvfs64 that has a wider f_blocks field than statvfs.
70 [ Define if there is a function named statvfs. (SVR4)]) 77 # glibc, HP-UX, IRIX, Solaris have statvfs64 as well, but on these systems
78 # statvfs with large-file support is already equivalent to statvfs64.
79 AC_CACHE_CHECK([whether to use statvfs64],
80 [fu_cv_sys_stat_statvfs64],
81 [AC_LINK_IFELSE(
82 [AC_LANG_PROGRAM(
83 [[#include <sys/types.h>
84 #include <sys/statvfs.h>
85 struct statvfs64 fsd;
86 int check_f_blocks_larger_in_statvfs64
87 [sizeof (((struct statvfs64 *) 0)->f_blocks)
88 > sizeof (((struct statvfs *) 0)->f_blocks)
89 ? 1 : -1];
90 ]],
91 [[statvfs64 (0, &fsd);]])],
92 [fu_cv_sys_stat_statvfs64=yes],
93 [fu_cv_sys_stat_statvfs64=no])
94 ])
95 if test $fu_cv_sys_stat_statvfs64 = yes; then
96 AC_DEFINE([STAT_STATVFS64], [1],
97 [ Define if statvfs64 should be preferred over statvfs.])
98 else
99 AC_DEFINE([STAT_STATVFS], [1],
100 [ Define if there is a function named statvfs. (SVR4)])
101 fi
71 fi 102 fi
72fi 103fi
73 104
105# Check for this unconditionally so we have a
106# good fallback on glibc/Linux > 2.6 < 2.6.36
107AC_MSG_CHECKING([for two-argument statfs with statfs.f_frsize member])
108AC_CACHE_VAL([fu_cv_sys_stat_statfs2_frsize],
109[AC_RUN_IFELSE([AC_LANG_SOURCE([[
110#ifdef HAVE_SYS_PARAM_H
111#include <sys/param.h>
112#endif
113#ifdef HAVE_SYS_MOUNT_H
114#include <sys/mount.h>
115#endif
116#ifdef HAVE_SYS_VFS_H
117#include <sys/vfs.h>
118#endif
119 int
120 main ()
121 {
122 struct statfs fsd;
123 fsd.f_frsize = 0;
124 return statfs (".", &fsd) != 0;
125 }]])],
126 [fu_cv_sys_stat_statfs2_frsize=yes],
127 [fu_cv_sys_stat_statfs2_frsize=no],
128 [fu_cv_sys_stat_statfs2_frsize=no])])
129AC_MSG_RESULT([$fu_cv_sys_stat_statfs2_frsize])
130if test $fu_cv_sys_stat_statfs2_frsize = yes; then
131 ac_fsusage_space=yes
132 AC_DEFINE([STAT_STATFS2_FRSIZE], [1],
133[ Define if statfs takes 2 args and struct statfs has a field named f_frsize.
134 (glibc/Linux > 2.6)])
135fi
136
74if test $ac_fsusage_space = no; then 137if test $ac_fsusage_space = no; then
75 # DEC Alpha running OSF/1 138 # DEC Alpha running OSF/1
76 AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)]) 139 AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
@@ -98,8 +161,8 @@ if test $ac_fsusage_space = no; then
98fi 161fi
99 162
100if test $ac_fsusage_space = no; then 163if test $ac_fsusage_space = no; then
101 # glibc/Linux, MacOS X < 10.4, FreeBSD < 5.0, NetBSD < 3.0, OpenBSD < 4.4. 164 # glibc/Linux, Mac OS X, FreeBSD < 5.0, NetBSD < 3.0, OpenBSD < 4.4.
102 # (glibc/{Hurd,kFreeBSD}, MacOS X >= 10.4, FreeBSD >= 5.0, NetBSD >= 3.0, 165 # (glibc/{Hurd,kFreeBSD}, FreeBSD >= 5.0, NetBSD >= 3.0,
103 # OpenBSD >= 4.4, AIX, HP-UX, OSF/1, Cygwin already handled above.) 166 # OpenBSD >= 4.4, AIX, HP-UX, OSF/1, Cygwin already handled above.)
104 # (On IRIX you need to include <sys/statfs.h>, not only <sys/mount.h> and 167 # (On IRIX you need to include <sys/statfs.h>, not only <sys/mount.h> and
105 # <sys/vfs.h>.) 168 # <sys/vfs.h>.)
diff --git a/gl/m4/getaddrinfo.m4 b/gl/m4/getaddrinfo.m4
index bc3066d..1d631f8 100644
--- a/gl/m4/getaddrinfo.m4
+++ b/gl/m4/getaddrinfo.m4
@@ -1,5 +1,5 @@
1# getaddrinfo.m4 serial 23 1# getaddrinfo.m4 serial 30
2dnl Copyright (C) 2004-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2004-2013 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,6 +24,7 @@ AC_DEFUN([gl_GETADDRINFO],
24 fi]) 24 fi])
25 LIBS="$gai_saved_LIBS $GETADDRINFO_LIB" 25 LIBS="$gai_saved_LIBS $GETADDRINFO_LIB"
26 26
27 HAVE_GETADDRINFO=1
27 AC_CACHE_CHECK([for getaddrinfo], [gl_cv_func_getaddrinfo], [ 28 AC_CACHE_CHECK([for getaddrinfo], [gl_cv_func_getaddrinfo], [
28 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ 29 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
29#include <sys/types.h> 30#include <sys/types.h>
@@ -55,16 +56,14 @@ AC_DEFUN([gl_GETADDRINFO],
55 GETADDRINFO_LIB="-lws2_32" 56 GETADDRINFO_LIB="-lws2_32"
56 LIBS="$gai_saved_LIBS $GETADDRINFO_LIB" 57 LIBS="$gai_saved_LIBS $GETADDRINFO_LIB"
57 else 58 else
58 AC_LIBOBJ([getaddrinfo]) 59 HAVE_GETADDRINFO=0
59 fi 60 fi
60 fi 61 fi
61 62
62 # We can't use AC_REPLACE_FUNCS here because gai_strerror may be an 63 # We can't use AC_REPLACE_FUNCS here because gai_strerror may be an
63 # inline function declared in ws2tcpip.h, so we need to get that 64 # inline function declared in ws2tcpip.h, so we need to get that
64 # header included somehow. 65 # header included somehow.
65 AC_CACHE_CHECK([for gai_strerror (possibly via ws2tcpip.h)], 66 AC_CHECK_DECLS([gai_strerror], [], [], [[
66 gl_cv_func_gai_strerror, [
67 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
68#include <sys/types.h> 67#include <sys/types.h>
69#ifdef HAVE_SYS_SOCKET_H 68#ifdef HAVE_SYS_SOCKET_H
70#include <sys/socket.h> 69#include <sys/socket.h>
@@ -76,11 +75,46 @@ AC_DEFUN([gl_GETADDRINFO],
76#include <ws2tcpip.h> 75#include <ws2tcpip.h>
77#endif 76#endif
78#include <stddef.h> 77#include <stddef.h>
79]], [[gai_strerror (NULL);]])], 78]])
80 [gl_cv_func_gai_strerror=yes], 79 if test $ac_cv_have_decl_gai_strerror = yes; then
81 [gl_cv_func_gai_strerror=no])]) 80 AC_CHECK_DECLS([gai_strerrorA], [], [], [[
82 if test $gl_cv_func_gai_strerror = no; then 81#include <sys/types.h>
83 AC_LIBOBJ([gai_strerror]) 82#ifdef HAVE_SYS_SOCKET_H
83#include <sys/socket.h>
84#endif
85#ifdef HAVE_NETDB_H
86#include <netdb.h>
87#endif
88#ifdef HAVE_WS2TCPIP_H
89#include <ws2tcpip.h>
90#endif
91#include <stddef.h>
92]])
93 dnl check for correct signature
94 AC_CACHE_CHECK([for gai_strerror with POSIX signature],
95 [gl_cv_func_gai_strerror_posix_signature], [
96 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
97#include <sys/types.h>
98#ifdef HAVE_SYS_SOCKET_H
99#include <sys/socket.h>
100#endif
101#ifdef HAVE_NETDB_H
102#include <netdb.h>
103#endif
104#ifdef HAVE_WS2TCPIP_H
105#include <ws2tcpip.h>
106#endif
107#include <stddef.h>
108extern
109#ifdef __cplusplus
110"C"
111#endif
112const char *gai_strerror(int);]])],
113 [gl_cv_func_gai_strerror_posix_signature=yes],
114 [gl_cv_func_gai_strerror_posix_signature=no])])
115 if test $gl_cv_func_gai_strerror_posix_signature = no; then
116 REPLACE_GAI_STRERROR=1
117 fi
84 fi 118 fi
85 119
86 LIBS="$gai_saved_LIBS" 120 LIBS="$gai_saved_LIBS"
@@ -100,16 +134,18 @@ AC_DEFUN([gl_PREREQ_GETADDRINFO], [
100 AC_REQUIRE([AC_C_RESTRICT]) 134 AC_REQUIRE([AC_C_RESTRICT])
101 AC_REQUIRE([gl_SOCKET_FAMILIES]) 135 AC_REQUIRE([gl_SOCKET_FAMILIES])
102 AC_REQUIRE([gl_HEADER_SYS_SOCKET]) 136 AC_REQUIRE([gl_HEADER_SYS_SOCKET])
103 AC_REQUIRE([AC_C_INLINE])
104 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) 137 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
105 138
106 dnl Including sys/socket.h is wrong for Windows, but Windows does not 139 dnl Including sys/socket.h is wrong for Windows, but Windows does not
107 dnl have sa_len so the result is correct anyway. 140 dnl have sa_len so the result is correct anyway.
108 AC_CHECK_MEMBERS([struct sockaddr.sa_len], , , [#include <sys/socket.h>]) 141 AC_CHECK_MEMBERS([struct sockaddr.sa_len], , , [
142#include <sys/types.h>
143#include <sys/socket.h>
144])
109 145
110 AC_CHECK_HEADERS_ONCE([netinet/in.h]) 146 AC_CHECK_HEADERS_ONCE([netinet/in.h])
111 147
112 AC_CHECK_DECLS([getaddrinfo, freeaddrinfo, gai_strerror, getnameinfo],,,[ 148 AC_CHECK_DECLS([getaddrinfo, freeaddrinfo, getnameinfo],,,[[
113 /* sys/types.h is not needed according to POSIX, but the 149 /* sys/types.h is not needed according to POSIX, but the
114 sys/socket.h in i386-unknown-freebsd4.10 and 150 sys/socket.h in i386-unknown-freebsd4.10 and
115 powerpc-apple-darwin5.5 required it. */ 151 powerpc-apple-darwin5.5 required it. */
@@ -123,7 +159,7 @@ AC_DEFUN([gl_PREREQ_GETADDRINFO], [
123#ifdef HAVE_WS2TCPIP_H 159#ifdef HAVE_WS2TCPIP_H
124#include <ws2tcpip.h> 160#include <ws2tcpip.h>
125#endif 161#endif
126]) 162]])
127 if test $ac_cv_have_decl_getaddrinfo = no; then 163 if test $ac_cv_have_decl_getaddrinfo = no; then
128 HAVE_DECL_GETADDRINFO=0 164 HAVE_DECL_GETADDRINFO=0
129 fi 165 fi
diff --git a/gl/m4/getdtablesize.m4 b/gl/m4/getdtablesize.m4
deleted file mode 100644
index d238628..0000000
--- a/gl/m4/getdtablesize.m4
+++ /dev/null
@@ -1,15 +0,0 @@
1# getdtablesize.m4 serial 1
2dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_GETDTABLESIZE],
8[
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10 AC_CHECK_FUNCS_ONCE([getdtablesize])
11 if test $ac_cv_func_getdtablesize != yes; then
12 HAVE_GETDTABLESIZE=0
13 AC_LIBOBJ([getdtablesize])
14 fi
15])
diff --git a/gl/m4/gethostname.m4 b/gl/m4/gethostname.m4
index ef0b43e..7413f9e 100644
--- a/gl/m4/gethostname.m4
+++ b/gl/m4/gethostname.m4
@@ -1,5 +1,5 @@
1# gethostname.m4 serial 9 1# gethostname.m4 serial 13
2dnl Copyright (C) 2002, 2008, 2009, 2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2002, 2008-2013 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.
@@ -14,7 +14,7 @@ AC_DEFUN([gl_FUNC_GETHOSTNAME],
14 14
15 dnl Where is gethostname() defined? 15 dnl Where is gethostname() defined?
16 dnl - On native Windows, it is in ws2_32.dll. 16 dnl - On native Windows, it is in ws2_32.dll.
17 dnl - Otherwise is is in libc. 17 dnl - Otherwise it is in libc.
18 GETHOSTNAME_LIB= 18 GETHOSTNAME_LIB=
19 AC_CHECK_FUNCS([gethostname], , [ 19 AC_CHECK_FUNCS([gethostname], , [
20 AC_CACHE_CHECK([for gethostname in winsock2.h and -lws2_32], 20 AC_CACHE_CHECK([for gethostname in winsock2.h and -lws2_32],
@@ -37,12 +37,14 @@ AC_DEFUN([gl_FUNC_GETHOSTNAME],
37 AC_SUBST([GETHOSTNAME_LIB]) 37 AC_SUBST([GETHOSTNAME_LIB])
38 38
39 if test "$ac_cv_func_gethostname" = no; then 39 if test "$ac_cv_func_gethostname" = no; then
40 AC_LIBOBJ([gethostname])
41 HAVE_GETHOSTNAME=0 40 HAVE_GETHOSTNAME=0
42 gl_PREREQ_GETHOSTNAME
43 fi 41 fi
44 42
45 dnl Also provide HOST_NAME_MAX when <limits.h> lacks it. 43 gl_PREREQ_HOST_NAME_MAX
44])
45
46# Provide HOST_NAME_MAX when <limits.h> lacks it.
47AC_DEFUN([gl_PREREQ_HOST_NAME_MAX], [
46 dnl - On most Unix systems, use MAXHOSTNAMELEN from <sys/param.h> instead. 48 dnl - On most Unix systems, use MAXHOSTNAMELEN from <sys/param.h> instead.
47 dnl - On Solaris, Cygwin, BeOS, use MAXHOSTNAMELEN from <netdb.h> instead. 49 dnl - On Solaris, Cygwin, BeOS, use MAXHOSTNAMELEN from <netdb.h> instead.
48 dnl - On mingw, use 256, because 50 dnl - On mingw, use 256, because
@@ -83,7 +85,11 @@ lucky
83#if HAVE_NETDB_H 85#if HAVE_NETDB_H
84# include <netdb.h> 86# include <netdb.h>
85#endif 87#endif
86]) 88],
89 [dnl The system does not define MAXHOSTNAMELEN in any of the common
90 dnl headers. Use a safe fallback.
91 gl_cv_decl_HOST_NAME_MAX=256
92 ])
87 fi 93 fi
88 fi 94 fi
89 ]) 95 ])
diff --git a/gl/m4/getloadavg.m4 b/gl/m4/getloadavg.m4
index 0a731c4..611372a 100644
--- a/gl/m4/getloadavg.m4
+++ b/gl/m4/getloadavg.m4
@@ -1,108 +1,78 @@
1# Check for getloadavg. 1# Check for getloadavg.
2 2
3# Copyright (C) 1992-1996, 1999-2000, 2002-2003, 2006, 2008-2010 Free Software 3# Copyright (C) 1992-1996, 1999-2000, 2002-2003, 2006, 2008-2013 Free Software
4# Foundation, Inc. 4# 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,
8# with or without modifications, as long as this notice is preserved. 8# with or without modifications, as long as this notice is preserved.
9 9
10#serial 6
11
10# Autoconf defines AC_FUNC_GETLOADAVG, but that is obsolescent. 12# Autoconf defines AC_FUNC_GETLOADAVG, but that is obsolescent.
11# New applications should use gl_GETLOADAVG instead. 13# New applications should use gl_GETLOADAVG instead.
12 14
13# gl_GETLOADAVG(LIBOBJDIR) 15# gl_GETLOADAVG
14# ------------------------ 16# -------------
15AC_DEFUN([gl_GETLOADAVG], 17AC_DEFUN([gl_GETLOADAVG],
16[AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) 18[AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
17 19
18# Persuade glibc <stdlib.h> to declare getloadavg(). 20# Persuade glibc <stdlib.h> to declare getloadavg().
19AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) 21AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
20 22
21gl_have_func=no # yes means we've found a way to get the load average.
22
23# Make sure getloadavg.c is where it belongs, at configure-time.
24test -f "$srcdir/$1/getloadavg.c" ||
25 AC_MSG_ERROR([$srcdir/$1/getloadavg.c is missing])
26
27gl_save_LIBS=$LIBS 23gl_save_LIBS=$LIBS
28 24
29# Check for getloadavg, but be sure not to touch the cache variable. 25# getloadvg is present in libc on glibc >= 2.2, Mac OS X, FreeBSD >= 2.0,
30(AC_CHECK_FUNC([getloadavg], [exit 0], [exit 1])) && gl_have_func=yes 26# NetBSD >= 0.9, OpenBSD >= 2.0, Solaris >= 7.
31 27HAVE_GETLOADAVG=1
32# On HPUX9, an unprivileged user can get load averages through this function. 28AC_CHECK_FUNC([getloadavg], [],
33AC_CHECK_FUNCS([pstat_getdynamic]) 29 [gl_func_getloadavg_done=no
34 30
35# Solaris has libkstat which does not require root. 31 # Some systems with -lutil have (and need) -lkvm as well, some do not.
36AC_CHECK_LIB([kstat], [kstat_open]) 32 # On Solaris, -lkvm requires nlist from -lelf, so check that first
37test $ac_cv_lib_kstat_kstat_open = yes && gl_have_func=yes 33 # to get the right answer into the cache.
38 34 # For kstat on solaris, we need to test for libelf and libkvm to force the
39# AIX has libperfstat which does not require root 35 # definition of SVR4 below.
40AC_CHECK_LIB([perfstat], [perfstat_cpu_total]) 36 if test $gl_func_getloadavg_done = no; then
41test $ac_cv_lib_perfstat_perfstat_cpu_total = yes && gl_have_func=yes 37 AC_CHECK_LIB([elf], [elf_begin], [LIBS="-lelf $LIBS"])
42 38 AC_CHECK_LIB([kvm], [kvm_open], [LIBS="-lkvm $LIBS"])
43# Some systems with -lutil have (and need) -lkvm as well, some do not. 39 # Check for the 4.4BSD definition of getloadavg.
44# On Solaris, -lkvm requires nlist from -lelf, so check that first 40 AC_CHECK_LIB([util], [getloadavg],
45# to get the right answer into the cache. 41 [LIBS="-lutil $LIBS" gl_func_getloadavg_done=yes])
46# For kstat on solaris, we need libelf to force the definition of SVR4 below. 42 fi
47if test $gl_have_func = no; then 43
48 AC_CHECK_LIB([elf], [elf_begin], [LIBS="-lelf $LIBS"]) 44 if test $gl_func_getloadavg_done = no; then
49fi 45 # There is a commonly available library for RS/6000 AIX.
50if test $gl_have_func = no; then 46 # Since it is not a standard part of AIX, it might be installed locally.
51 AC_CHECK_LIB([kvm], [kvm_open], [LIBS="-lkvm $LIBS"]) 47 gl_getloadavg_LIBS=$LIBS
52 # Check for the 4.4BSD definition of getloadavg. 48 LIBS="-L/usr/local/lib $LIBS"
53 AC_CHECK_LIB([util], [getloadavg], 49 AC_CHECK_LIB([getloadavg], [getloadavg],
54 [LIBS="-lutil $LIBS" gl_have_func=yes gl_cv_func_getloadavg_setgid=yes]) 50 [LIBS="-lgetloadavg $LIBS" gl_func_getloadavg_done=yes],
55fi 51 [LIBS=$gl_getloadavg_LIBS])
52 fi
53
54 # Set up the replacement function if necessary.
55 if test $gl_func_getloadavg_done = no; then
56 HAVE_GETLOADAVG=0
57
58 # Solaris has libkstat which does not require root.
59 AC_CHECK_LIB([kstat], [kstat_open])
60 test $ac_cv_lib_kstat_kstat_open = yes && gl_func_getloadavg_done=yes
61
62 # AIX has libperfstat which does not require root
63 if test $gl_func_getloadavg_done = no; then
64 AC_CHECK_LIB([perfstat], [perfstat_cpu_total])
65 test $ac_cv_lib_perfstat_perfstat_cpu_total = yes && gl_func_getloadavg_done=yes
66 fi
67
68 if test $gl_func_getloadavg_done = no; then
69 AC_CHECK_HEADER([sys/dg_sys_info.h],
70 [gl_func_getloadavg_done=yes
71 AC_DEFINE([DGUX], [1], [Define to 1 for DGUX with <sys/dg_sys_info.h>.])
72 AC_CHECK_LIB([dgc], [dg_sys_info])])
73 fi
74 fi])
56 75
57if test $gl_have_func = no; then
58 # There is a commonly available library for RS/6000 AIX.
59 # Since it is not a standard part of AIX, it might be installed locally.
60 gl_getloadavg_LIBS=$LIBS
61 LIBS="-L/usr/local/lib $LIBS"
62 AC_CHECK_LIB([getloadavg], [getloadavg],
63 [LIBS="-lgetloadavg $LIBS"], [LIBS=$gl_getloadavg_LIBS])
64fi
65
66# Make sure it is really in the library, if we think we found it,
67# otherwise set up the replacement function.
68AC_CHECK_FUNCS([getloadavg], [],
69 [gl_PREREQ_GETLOADAVG])
70
71# Some definitions of getloadavg require that the program be installed setgid.
72AC_CACHE_CHECK([whether getloadavg requires setgid],
73 gl_cv_func_getloadavg_setgid,
74[AC_EGREP_CPP([Yowza Am I SETGID yet],
75[#define CONFIGURING_GETLOADAVG
76#include "$srcdir/$1/getloadavg.c"
77#ifdef LDAV_PRIVILEGED
78Yowza Am I SETGID yet
79#endif
80],
81 gl_cv_func_getloadavg_setgid=yes,
82 gl_cv_func_getloadavg_setgid=no)])
83if test $gl_cv_func_getloadavg_setgid = yes; then
84 NEED_SETGID=true
85 AC_DEFINE([GETLOADAVG_PRIVILEGED], [1],
86 [Define to 1 if the `getloadavg' function needs to be run setuid
87 or setgid.])
88else
89 NEED_SETGID=false
90fi
91AC_SUBST([NEED_SETGID])dnl
92
93if test $gl_cv_func_getloadavg_setgid = yes; then
94 AC_CACHE_CHECK([group of /dev/kmem], [gl_cv_group_kmem],
95[ # On Solaris, /dev/kmem is a symlink. Get info on the real file.
96 ac_ls_output=`ls -lgL /dev/kmem 2>/dev/null`
97 # If we got an error (system does not support symlinks), try without -L.
98 test -z "$ac_ls_output" && ac_ls_output=`ls -lg /dev/kmem`
99 gl_cv_group_kmem=`echo $ac_ls_output \
100 | sed -ne ['s/[ ][ ]*/ /g
101 s/^.[sSrwx-]* *[0-9]* *\([^0-9]*\) *.*/\1/
102 / /s/.* //;p']`
103])
104 AC_SUBST([KMEM_GROUP], [$gl_cv_group_kmem])dnl
105fi
106if test "x$gl_save_LIBS" = x; then 76if test "x$gl_save_LIBS" = x; then
107 GETLOADAVG_LIBS=$LIBS 77 GETLOADAVG_LIBS=$LIBS
108else 78else
@@ -121,58 +91,57 @@ else
121 HAVE_SYS_LOADAVG_H=0 91 HAVE_SYS_LOADAVG_H=0
122fi 92fi
123AC_CHECK_DECL([getloadavg], [], [HAVE_DECL_GETLOADAVG=0], 93AC_CHECK_DECL([getloadavg], [], [HAVE_DECL_GETLOADAVG=0],
124 [#if HAVE_SYS_LOADAVG_H 94 [[#if HAVE_SYS_LOADAVG_H
125 # include <sys/loadavg.h> 95 # include <sys/loadavg.h>
126 #endif 96 #endif
127 #include <stdlib.h>]) 97 #include <stdlib.h>]])
128])# gl_GETLOADAVG 98])# gl_GETLOADAVG
129 99
130 100
131# gl_PREREQ_GETLOADAVG 101# gl_PREREQ_GETLOADAVG
132# -------------------- 102# --------------------
133# Set up the AC_LIBOBJ replacement of `getloadavg'. 103# Set up the AC_LIBOBJ replacement of 'getloadavg'.
134AC_DEFUN([gl_PREREQ_GETLOADAVG], 104AC_DEFUN([gl_PREREQ_GETLOADAVG],
135[AC_LIBOBJ([getloadavg]) 105[
136AC_DEFINE([C_GETLOADAVG], [1], [Define to 1 if using `getloadavg.c'.])
137# Figure out what our getloadavg.c needs. 106# Figure out what our getloadavg.c needs.
138gl_have_func=no 107
139AC_CHECK_HEADER([sys/dg_sys_info.h], 108AC_CHECK_HEADERS_ONCE([sys/param.h])
140[gl_have_func=yes 109
141 AC_DEFINE([DGUX], [1], [Define to 1 for DGUX with <sys/dg_sys_info.h>.]) 110# On HPUX9, an unprivileged user can get load averages this way.
142 AC_CHECK_LIB([dgc], [dg_sys_info])]) 111if test $gl_func_getloadavg_done = no; then
112 AC_CHECK_FUNCS([pstat_getdynamic], [gl_func_getloadavg_done=yes])
113fi
143 114
144# We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it 115# We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it
145# uses stabs), but it is still SVR4. We cannot check for <elf.h> because 116# uses stabs), but it is still SVR4. We cannot check for <elf.h> because
146# Irix 4.0.5F has the header but not the library. 117# Irix 4.0.5F has the header but not the library.
147if test $gl_have_func = no && test "$ac_cv_lib_elf_elf_begin" = yes; then 118if test $gl_func_getloadavg_done = no && test "$ac_cv_lib_elf_elf_begin" = yes \
148 gl_have_func=yes 119 && test "$ac_cv_lib_kvm_kvm_open" = yes; then
120 gl_func_getloadavg_done=yes
149 AC_DEFINE([SVR4], [1], [Define to 1 on System V Release 4.]) 121 AC_DEFINE([SVR4], [1], [Define to 1 on System V Release 4.])
150fi 122fi
151 123
152if test $gl_have_func = no; then 124if test $gl_func_getloadavg_done = no; then
153 AC_CHECK_HEADER([inq_stats/cpustats.h], 125 AC_CHECK_HEADER([inq_stats/cpustats.h],
154 [gl_have_func=yes 126 [gl_func_getloadavg_done=yes
155 AC_DEFINE([UMAX], [1], [Define to 1 for Encore UMAX.]) 127 AC_DEFINE([UMAX], [1], [Define to 1 for Encore UMAX.])
156 AC_DEFINE([UMAX4_3], [1], 128 AC_DEFINE([UMAX4_3], [1],
157 [Define to 1 for Encore UMAX 4.3 that has <inq_status/cpustats.h> 129 [Define to 1 for Encore UMAX 4.3 that has <inq_status/cpustats.h>
158 instead of <sys/cpustats.h>.])]) 130 instead of <sys/cpustats.h>.])])
159fi 131fi
160 132
161if test $gl_have_func = no; then 133if test $gl_func_getloadavg_done = no; then
162 AC_CHECK_HEADER([sys/cpustats.h], 134 AC_CHECK_HEADER([sys/cpustats.h],
163 [gl_have_func=yes; AC_DEFINE([UMAX])]) 135 [gl_func_getloadavg_done=yes; AC_DEFINE([UMAX])])
164fi 136fi
165 137
166if test $gl_have_func = no; then 138if test $gl_func_getloadavg_done = no; then
167 AC_CHECK_HEADERS([mach/mach.h]) 139 AC_CHECK_HEADERS([mach/mach.h])
168fi 140fi
169 141
170AC_CHECK_HEADERS([nlist.h], 142AC_CHECK_HEADERS([nlist.h],
171[AC_CHECK_MEMBERS([struct nlist.n_un.n_name], 143[AC_CHECK_MEMBERS([struct nlist.n_un.n_name],
172 [AC_DEFINE([NLIST_NAME_UNION], [1], 144 [], [],
173 [Define to 1 if your `struct nlist' has an
174 `n_un' member. Obsolete, depend on
175 `HAVE_STRUCT_NLIST_N_UN_N_NAME])], [],
176 [@%:@include <nlist.h>]) 145 [@%:@include <nlist.h>])
177 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <nlist.h>]], 146 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <nlist.h>]],
178 [[struct nlist x; 147 [[struct nlist x;
diff --git a/gl/m4/getopt.m4 b/gl/m4/getopt.m4
index 5b211e5..50f4509 100644
--- a/gl/m4/getopt.m4
+++ b/gl/m4/getopt.m4
@@ -1,5 +1,5 @@
1# getopt.m4 serial 28 1# getopt.m4 serial 44
2dnl Copyright (C) 2002-2006, 2008-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2006, 2008-2013 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,10 +9,22 @@ AC_DEFUN([gl_FUNC_GETOPT_POSIX],
9[ 9[
10 m4_divert_text([DEFAULTS], [gl_getopt_required=POSIX]) 10 m4_divert_text([DEFAULTS], [gl_getopt_required=POSIX])
11 AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) 11 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
12 gl_GETOPT_IFELSE([ 12 AC_REQUIRE([gl_GETOPT_CHECK_HEADERS])
13 gl_REPLACE_GETOPT 13 dnl Other modules can request the gnulib implementation of the getopt
14 ], 14 dnl functions unconditionally, by defining gl_REPLACE_GETOPT_ALWAYS.
15 []) 15 dnl argp.m4 does this.
16 m4_ifdef([gl_REPLACE_GETOPT_ALWAYS], [
17 REPLACE_GETOPT=1
18 ], [
19 REPLACE_GETOPT=0
20 if test -n "$gl_replace_getopt"; then
21 REPLACE_GETOPT=1
22 fi
23 ])
24 if test $REPLACE_GETOPT = 1; then
25 dnl Arrange for getopt.h to be created.
26 gl_GETOPT_SUBSTITUTE_HEADER
27 fi
16]) 28])
17 29
18# Request a POSIX compliant getopt function with GNU extensions (such as 30# Request a POSIX compliant getopt function with GNU extensions (such as
@@ -25,37 +37,16 @@ AC_DEFUN([gl_FUNC_GETOPT_GNU],
25 AC_REQUIRE([gl_FUNC_GETOPT_POSIX]) 37 AC_REQUIRE([gl_FUNC_GETOPT_POSIX])
26]) 38])
27 39
28# Request the gnulib implementation of the getopt functions unconditionally.
29# argp.m4 uses this.
30AC_DEFUN([gl_REPLACE_GETOPT],
31[
32 dnl Arrange for getopt.h to be created.
33 gl_GETOPT_SUBSTITUTE_HEADER
34 dnl Arrange for unistd.h to include getopt.h.
35 GNULIB_UNISTD_H_GETOPT=1
36 dnl Arrange to compile the getopt implementation.
37 AC_LIBOBJ([getopt])
38 AC_LIBOBJ([getopt1])
39 gl_PREREQ_GETOPT
40])
41
42# emacs' configure.in uses this.
43AC_DEFUN([gl_GETOPT_IFELSE],
44[
45 AC_REQUIRE([gl_GETOPT_CHECK_HEADERS])
46 AS_IF([test -n "$gl_replace_getopt"], [$1], [$2])
47])
48
49# Determine whether to replace the entire getopt facility. 40# Determine whether to replace the entire getopt facility.
50AC_DEFUN([gl_GETOPT_CHECK_HEADERS], 41AC_DEFUN([gl_GETOPT_CHECK_HEADERS],
51[ 42[
52 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 43 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
44 AC_REQUIRE([AC_PROG_AWK]) dnl for awk that supports ENVIRON
53 45
54 dnl Persuade Solaris <unistd.h> to declare optarg, optind, opterr, optopt. 46 dnl Persuade Solaris <unistd.h> to declare optarg, optind, opterr, optopt.
55 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) 47 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
56 48
57 gl_CHECK_NEXT_HEADERS([getopt.h]) 49 gl_CHECK_NEXT_HEADERS([getopt.h])
58 AC_CHECK_HEADERS_ONCE([getopt.h])
59 if test $ac_cv_header_getopt_h = yes; then 50 if test $ac_cv_header_getopt_h = yes; then
60 HAVE_GETOPT_H=1 51 HAVE_GETOPT_H=1
61 else 52 else
@@ -75,25 +66,6 @@ AC_DEFUN([gl_GETOPT_CHECK_HEADERS],
75 AC_CHECK_FUNCS([getopt_long_only], [], [gl_replace_getopt=yes]) 66 AC_CHECK_FUNCS([getopt_long_only], [], [gl_replace_getopt=yes])
76 fi 67 fi
77 68
78 dnl BSD getopt_long uses an incompatible method to reset option processing.
79 dnl Existence of the variable, in and of itself, is not a reason to replace
80 dnl getopt, but knowledge of the variable is needed to determine how to
81 dnl reset and whether a reset reparses the environment.
82 dnl Solaris supports neither optreset nor optind=0, but keeps no state that
83 dnl needs a reset beyond setting optind=1; detect Solaris by getopt_clip.
84 if test -z "$gl_replace_getopt"; then
85 AC_CHECK_DECLS([optreset], [],
86 [AC_CHECK_DECLS([getopt_clip], [], [],
87 [[#include <getopt.h>]])
88 ],
89 [[#include <getopt.h>]])
90 fi
91
92 dnl mingw's getopt (in libmingwex.a) does weird things when the options
93 dnl strings starts with '+' and it's not the first call. Some internal state
94 dnl is left over from earlier calls, and neither setting optind = 0 nor
95 dnl setting optreset = 1 get rid of this internal state.
96 dnl POSIX is silent on optind vs. optreset, so we allow either behavior.
97 dnl POSIX 2008 does not specify leading '+' behavior, but see 69 dnl POSIX 2008 does not specify leading '+' behavior, but see
98 dnl http://austingroupbugs.net/view.php?id=191 for a recommendation on 70 dnl http://austingroupbugs.net/view.php?id=191 for a recommendation on
99 dnl the next version of POSIX. For now, we only guarantee leading '+' 71 dnl the next version of POSIX. For now, we only guarantee leading '+'
@@ -102,105 +74,124 @@ AC_DEFUN([gl_GETOPT_CHECK_HEADERS],
102 AC_CACHE_CHECK([whether getopt is POSIX compatible], 74 AC_CACHE_CHECK([whether getopt is POSIX compatible],
103 [gl_cv_func_getopt_posix], 75 [gl_cv_func_getopt_posix],
104 [ 76 [
105 dnl This test fails on mingw and succeeds on all other platforms. 77 dnl Merging these three different test programs into a single one
106 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 78 dnl would require a reset mechanism. On BSD systems, it can be done
79 dnl through 'optreset'; on some others (glibc), it can be done by
80 dnl setting 'optind' to 0; on others again (HP-UX, IRIX, OSF/1,
81 dnl Solaris 9, musl libc), there is no such mechanism.
82 if test $cross_compiling = no; then
83 dnl Sanity check. Succeeds everywhere (except on MSVC,
84 dnl which lacks <unistd.h> and getopt() entirely).
85 AC_RUN_IFELSE(
86 [AC_LANG_SOURCE([[
107#include <unistd.h> 87#include <unistd.h>
108#include <stdlib.h> 88#include <stdlib.h>
109#include <string.h> 89#include <string.h>
110 90
111#if !HAVE_DECL_OPTRESET && !HAVE_DECL_GETOPT_CLIP
112# define OPTIND_MIN 0
113#else
114# define OPTIND_MIN 1
115#endif
116
117int 91int
118main () 92main ()
119{ 93{
120 { 94 static char program[] = "program";
121 int argc = 0; 95 static char a[] = "-a";
122 char *argv[10]; 96 static char foo[] = "foo";
123 int c; 97 static char bar[] = "bar";
124 98 char *argv[] = { program, a, foo, bar, NULL };
125 argv[argc++] = "program"; 99 int c;
126 argv[argc++] = "-a";
127 argv[argc++] = "foo";
128 argv[argc++] = "bar";
129 argv[argc] = NULL;
130 optind = OPTIND_MIN;
131 opterr = 0;
132 100
133 c = getopt (argc, argv, "ab"); 101 c = getopt (4, argv, "ab");
134 if (!(c == 'a')) 102 if (!(c == 'a'))
135 return 1; 103 return 1;
136 c = getopt (argc, argv, "ab"); 104 c = getopt (4, argv, "ab");
137 if (!(c == -1)) 105 if (!(c == -1))
138 return 2; 106 return 2;
139 if (!(optind == 2)) 107 if (!(optind == 2))
140 return 3; 108 return 3;
141 } 109 return 0;
142 /* Some internal state exists at this point. */ 110}
143 { 111]])],
144 int argc = 0; 112 [gl_cv_func_getopt_posix=maybe],
145 char *argv[10]; 113 [gl_cv_func_getopt_posix=no])
146 int c; 114 if test $gl_cv_func_getopt_posix = maybe; then
115 dnl Sanity check with '+'. Succeeds everywhere (except on MSVC,
116 dnl which lacks <unistd.h> and getopt() entirely).
117 AC_RUN_IFELSE(
118 [AC_LANG_SOURCE([[
119#include <unistd.h>
120#include <stdlib.h>
121#include <string.h>
147 122
148 argv[argc++] = "program"; 123int
149 argv[argc++] = "donald"; 124main ()
150 argv[argc++] = "-p"; 125{
151 argv[argc++] = "billy"; 126 static char program[] = "program";
152 argv[argc++] = "duck"; 127 static char donald[] = "donald";
153 argv[argc++] = "-a"; 128 static char p[] = "-p";
154 argv[argc++] = "bar"; 129 static char billy[] = "billy";
155 argv[argc] = NULL; 130 static char duck[] = "duck";
156 optind = OPTIND_MIN; 131 static char a[] = "-a";
157 opterr = 0; 132 static char bar[] = "bar";
133 char *argv[] = { program, donald, p, billy, duck, a, bar, NULL };
134 int c;
158 135
159 c = getopt (argc, argv, "+abp:q:"); 136 c = getopt (7, argv, "+abp:q:");
160 if (!(c == -1)) 137 if (!(c == -1))
161 return 4; 138 return 4;
162 if (!(strcmp (argv[0], "program") == 0)) 139 if (!(strcmp (argv[0], "program") == 0))
163 return 5; 140 return 5;
164 if (!(strcmp (argv[1], "donald") == 0)) 141 if (!(strcmp (argv[1], "donald") == 0))
165 return 6; 142 return 6;
166 if (!(strcmp (argv[2], "-p") == 0)) 143 if (!(strcmp (argv[2], "-p") == 0))
167 return 7; 144 return 7;
168 if (!(strcmp (argv[3], "billy") == 0)) 145 if (!(strcmp (argv[3], "billy") == 0))
169 return 8; 146 return 8;
170 if (!(strcmp (argv[4], "duck") == 0)) 147 if (!(strcmp (argv[4], "duck") == 0))
171 return 9; 148 return 9;
172 if (!(strcmp (argv[5], "-a") == 0)) 149 if (!(strcmp (argv[5], "-a") == 0))
173 return 10; 150 return 10;
174 if (!(strcmp (argv[6], "bar") == 0)) 151 if (!(strcmp (argv[6], "bar") == 0))
175 return 11; 152 return 11;
176 if (!(optind == 1)) 153 if (!(optind == 1))
177 return 12; 154 return 12;
178 } 155 return 0;
179 /* Detect MacOS 10.5 bug. */ 156}
180 { 157]])],
181 char *argv[3] = { "program", "-ab", NULL }; 158 [gl_cv_func_getopt_posix=maybe],
182 optind = OPTIND_MIN; 159 [gl_cv_func_getopt_posix=no])
183 opterr = 0; 160 fi
184 if (getopt (2, argv, "ab:") != 'a') 161 if test $gl_cv_func_getopt_posix = maybe; then
185 return 13; 162 dnl Detect Mac OS X 10.5, AIX 7.1, mingw bug.
186 if (getopt (2, argv, "ab:") != '?') 163 AC_RUN_IFELSE(
187 return 14; 164 [AC_LANG_SOURCE([[
188 if (optopt != 'b') 165#include <unistd.h>
189 return 15; 166#include <stdlib.h>
190 if (optind != 2) 167#include <string.h>
191 return 16;
192 }
193 168
169int
170main ()
171{
172 static char program[] = "program";
173 static char ab[] = "-ab";
174 char *argv[3] = { program, ab, NULL };
175 if (getopt (2, argv, "ab:") != 'a')
176 return 13;
177 if (getopt (2, argv, "ab:") != '?')
178 return 14;
179 if (optopt != 'b')
180 return 15;
181 if (optind != 2)
182 return 16;
194 return 0; 183 return 0;
195} 184}
196]])], 185]])],
197 [gl_cv_func_getopt_posix=yes], [gl_cv_func_getopt_posix=no], 186 [gl_cv_func_getopt_posix=yes],
198 [case "$host_os" in 187 [gl_cv_func_getopt_posix=no])
199 mingw*) gl_cv_func_getopt_posix="guessing no";; 188 fi
200 darwin*) gl_cv_func_getopt_posix="guessing no";; 189 else
201 *) gl_cv_func_getopt_posix="guessing yes";; 190 case "$host_os" in
202 esac 191 darwin* | aix* | mingw*) gl_cv_func_getopt_posix="guessing no";;
203 ]) 192 *) gl_cv_func_getopt_posix="guessing yes";;
193 esac
194 fi
204 ]) 195 ])
205 case "$gl_cv_func_getopt_posix" in 196 case "$gl_cv_func_getopt_posix" in
206 *no) gl_replace_getopt=yes ;; 197 *no) gl_replace_getopt=yes ;;
@@ -213,82 +204,154 @@ main ()
213 # optstring is necessary for programs like m4 that have POSIX-mandated 204 # optstring is necessary for programs like m4 that have POSIX-mandated
214 # semantics for supporting options interspersed with files. 205 # semantics for supporting options interspersed with files.
215 # Also, since getopt_long is a GNU extension, we require optind=0. 206 # Also, since getopt_long is a GNU extension, we require optind=0.
216 gl_had_POSIXLY_CORRECT=${POSIXLY_CORRECT:+yes} 207 # Bash ties 'set -o posix' to a non-exported POSIXLY_CORRECT;
208 # so take care to revert to the correct (non-)export state.
209dnl GNU Coding Standards currently allow awk but not env; besides, env
210dnl is ambiguous with environment values that contain newlines.
211 gl_awk_probe='BEGIN { if ("POSIXLY_CORRECT" in ENVIRON) print "x" }'
212 case ${POSIXLY_CORRECT+x}`$AWK "$gl_awk_probe" </dev/null` in
213 xx) gl_had_POSIXLY_CORRECT=exported ;;
214 x) gl_had_POSIXLY_CORRECT=yes ;;
215 *) gl_had_POSIXLY_CORRECT= ;;
216 esac
217 POSIXLY_CORRECT=1 217 POSIXLY_CORRECT=1
218 export POSIXLY_CORRECT 218 export POSIXLY_CORRECT
219 AC_RUN_IFELSE( 219 AC_RUN_IFELSE(
220 [AC_LANG_PROGRAM([[#include <getopt.h> 220 [AC_LANG_PROGRAM([[#include <getopt.h>
221 #include <stddef.h> 221 #include <stddef.h>
222 #include <string.h> 222 #include <string.h>
223 ]GL_NOCRASH[
223 ]], [[ 224 ]], [[
225 int result = 0;
226
227 nocrash_init();
228
224 /* This code succeeds on glibc 2.8, OpenBSD 4.0, Cygwin, mingw, 229 /* This code succeeds on glibc 2.8, OpenBSD 4.0, Cygwin, mingw,
225 and fails on MacOS X 10.5, AIX 5.2, HP-UX 11, IRIX 6.5, 230 and fails on Mac OS X 10.5, AIX 5.2, HP-UX 11, IRIX 6.5,
226 OSF/1 5.1, Solaris 10. */ 231 OSF/1 5.1, Solaris 10. */
227 { 232 {
228 char *myargv[3]; 233 static char conftest[] = "conftest";
229 myargv[0] = "conftest"; 234 static char plus[] = "-+";
230 myargv[1] = "-+"; 235 char *argv[3] = { conftest, plus, NULL };
231 myargv[2] = 0;
232 opterr = 0; 236 opterr = 0;
233 if (getopt (2, myargv, "+a") != '?') 237 if (getopt (2, argv, "+a") != '?')
234 return 1; 238 result |= 1;
235 } 239 }
236 /* This code succeeds on glibc 2.8, mingw, 240 /* This code succeeds on glibc 2.8, mingw,
237 and fails on MacOS X 10.5, OpenBSD 4.0, AIX 5.2, HP-UX 11, 241 and fails on Mac OS X 10.5, OpenBSD 4.0, AIX 5.2, HP-UX 11,
238 IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x. */ 242 IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x. */
239 { 243 {
240 char *argv[] = { "program", "-p", "foo", "bar", NULL }; 244 static char program[] = "program";
245 static char p[] = "-p";
246 static char foo[] = "foo";
247 static char bar[] = "bar";
248 char *argv[] = { program, p, foo, bar, NULL };
241 249
242 optind = 1; 250 optind = 1;
243 if (getopt (4, argv, "p::") != 'p') 251 if (getopt (4, argv, "p::") != 'p')
244 return 2; 252 result |= 2;
245 if (optarg != NULL) 253 else if (optarg != NULL)
246 return 3; 254 result |= 4;
247 if (getopt (4, argv, "p::") != -1) 255 else if (getopt (4, argv, "p::") != -1)
248 return 4; 256 result |= 6;
249 if (optind != 2) 257 else if (optind != 2)
250 return 5; 258 result |= 8;
251 } 259 }
252 /* This code succeeds on glibc 2.8 and fails on Cygwin 1.7.0. */ 260 /* This code succeeds on glibc 2.8 and fails on Cygwin 1.7.0. */
253 { 261 {
254 char *argv[] = { "program", "foo", "-p", NULL }; 262 static char program[] = "program";
263 static char foo[] = "foo";
264 static char p[] = "-p";
265 char *argv[] = { program, foo, p, NULL };
255 optind = 0; 266 optind = 0;
256 if (getopt (3, argv, "-p") != 1) 267 if (getopt (3, argv, "-p") != 1)
257 return 6; 268 result |= 16;
258 if (getopt (3, argv, "-p") != 'p') 269 else if (getopt (3, argv, "-p") != 'p')
259 return 7; 270 result |= 16;
260 } 271 }
261 /* This code fails on glibc 2.11. */ 272 /* This code fails on glibc 2.11. */
262 { 273 {
263 char *argv[] = { "program", "-b", "-a", NULL }; 274 static char program[] = "program";
275 static char b[] = "-b";
276 static char a[] = "-a";
277 char *argv[] = { program, b, a, NULL };
264 optind = opterr = 0; 278 optind = opterr = 0;
265 if (getopt (3, argv, "+:a:b") != 'b') 279 if (getopt (3, argv, "+:a:b") != 'b')
266 return 8; 280 result |= 32;
267 if (getopt (3, argv, "+:a:b") != ':') 281 else if (getopt (3, argv, "+:a:b") != ':')
268 return 9; 282 result |= 32;
283 }
284 /* This code dumps core on glibc 2.14. */
285 {
286 static char program[] = "program";
287 static char w[] = "-W";
288 static char dummy[] = "dummy";
289 char *argv[] = { program, w, dummy, NULL };
290 optind = opterr = 1;
291 if (getopt (3, argv, "W;") != 'W')
292 result |= 64;
269 } 293 }
270 return 0; 294 return result;
271 ]])], 295 ]])],
272 [gl_cv_func_getopt_gnu=yes], 296 [gl_cv_func_getopt_gnu=yes],
273 [gl_cv_func_getopt_gnu=no], 297 [gl_cv_func_getopt_gnu=no],
274 [dnl Cross compiling. Guess based on host and declarations. 298 [dnl Cross compiling. Assume the worst, even on glibc platforms.
275 case $host_os:$ac_cv_have_decl_optreset in 299 gl_cv_func_getopt_gnu="guessing no"
276 *-gnu*:* | mingw*:*) gl_cv_func_getopt_gnu=no;;
277 *:yes) gl_cv_func_getopt_gnu=no;;
278 *) gl_cv_func_getopt_gnu=yes;;
279 esac
280 ]) 300 ])
281 if test "$gl_had_POSIXLY_CORRECT" != yes; then 301 case $gl_had_POSIXLY_CORRECT in
282 AS_UNSET([POSIXLY_CORRECT]) 302 exported) ;;
283 fi 303 yes) AS_UNSET([POSIXLY_CORRECT]); POSIXLY_CORRECT=1 ;;
304 *) AS_UNSET([POSIXLY_CORRECT]) ;;
305 esac
284 ]) 306 ])
285 if test "$gl_cv_func_getopt_gnu" = "no"; then 307 if test "$gl_cv_func_getopt_gnu" != yes; then
286 gl_replace_getopt=yes 308 gl_replace_getopt=yes
309 else
310 AC_CACHE_CHECK([for working GNU getopt_long function],
311 [gl_cv_func_getopt_long_gnu],
312 [AC_RUN_IFELSE(
313 [AC_LANG_PROGRAM(
314 [[#include <getopt.h>
315 #include <stddef.h>
316 #include <string.h>
317 ]],
318 [[static const struct option long_options[] =
319 {
320 { "xtremely-",no_argument, NULL, 1003 },
321 { "xtra", no_argument, NULL, 1001 },
322 { "xtreme", no_argument, NULL, 1002 },
323 { "xtremely", no_argument, NULL, 1003 },
324 { NULL, 0, NULL, 0 }
325 };
326 /* This code fails on OpenBSD 5.0. */
327 {
328 static char program[] = "program";
329 static char xtremel[] = "--xtremel";
330 char *argv[] = { program, xtremel, NULL };
331 int option_index;
332 optind = 1; opterr = 0;
333 if (getopt_long (2, argv, "", long_options, &option_index) != 1003)
334 return 1;
335 }
336 return 0;
337 ]])],
338 [gl_cv_func_getopt_long_gnu=yes],
339 [gl_cv_func_getopt_long_gnu=no],
340 [dnl Cross compiling. Guess no on OpenBSD, yes otherwise.
341 case "$host_os" in
342 openbsd*) gl_cv_func_getopt_long_gnu="guessing no";;
343 *) gl_cv_func_getopt_long_gnu="guessing yes";;
344 esac
345 ])
346 ])
347 case "$gl_cv_func_getopt_long_gnu" in
348 *yes) ;;
349 *) gl_replace_getopt=yes ;;
350 esac
287 fi 351 fi
288 fi 352 fi
289]) 353])
290 354
291# emacs' configure.in uses this.
292AC_DEFUN([gl_GETOPT_SUBSTITUTE_HEADER], 355AC_DEFUN([gl_GETOPT_SUBSTITUTE_HEADER],
293[ 356[
294 GETOPT_H=getopt.h 357 GETOPT_H=getopt.h
@@ -299,7 +362,6 @@ AC_DEFUN([gl_GETOPT_SUBSTITUTE_HEADER],
299]) 362])
300 363
301# Prerequisites of lib/getopt*. 364# Prerequisites of lib/getopt*.
302# emacs' configure.in uses this.
303AC_DEFUN([gl_PREREQ_GETOPT], 365AC_DEFUN([gl_PREREQ_GETOPT],
304[ 366[
305 AC_CHECK_DECLS_ONCE([getenv]) 367 AC_CHECK_DECLS_ONCE([getenv])
diff --git a/gl/m4/gettext.m4 b/gl/m4/gettext.m4
index f84e6a5..8d1f066 100644
--- a/gl/m4/gettext.m4
+++ b/gl/m4/gettext.m4
@@ -1,5 +1,5 @@
1# gettext.m4 serial 63 (gettext-0.18) 1# gettext.m4 serial 66 (gettext-0.18.2)
2dnl Copyright (C) 1995-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 1995-2013 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.
@@ -35,7 +35,7 @@ dnl will be ignored. If NEEDSYMBOL is specified and is
35dnl 'need-formatstring-macros', then GNU gettext implementations that don't 35dnl 'need-formatstring-macros', then GNU gettext implementations that don't
36dnl support the ISO C 99 <inttypes.h> formatstring macros will be ignored. 36dnl support the ISO C 99 <inttypes.h> formatstring macros will be ignored.
37dnl INTLDIR is used to find the intl libraries. If empty, 37dnl INTLDIR is used to find the intl libraries. If empty,
38dnl the value `$(top_builddir)/intl/' is used. 38dnl the value '$(top_builddir)/intl/' is used.
39dnl 39dnl
40dnl The result of the configuration is one of three cases: 40dnl The result of the configuration is one of three cases:
41dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled 41dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled
@@ -97,7 +97,7 @@ AC_DEFUN([AM_GNU_GETTEXT],
97 AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) 97 AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
98 ]) 98 ])
99 99
100 dnl Sometimes, on MacOS X, libintl requires linking with CoreFoundation. 100 dnl Sometimes, on Mac OS X, libintl requires linking with CoreFoundation.
101 gt_INTL_MACOSX 101 gt_INTL_MACOSX
102 102
103 dnl Set USE_NLS. 103 dnl Set USE_NLS.
@@ -157,12 +157,18 @@ changequote([,])dnl
157 fi 157 fi
158 158
159 AC_CACHE_CHECK([for GNU gettext in libc], [$gt_func_gnugettext_libc], 159 AC_CACHE_CHECK([for GNU gettext in libc], [$gt_func_gnugettext_libc],
160 [AC_TRY_LINK([#include <libintl.h> 160 [AC_LINK_IFELSE(
161 [AC_LANG_PROGRAM(
162 [[
163#include <libintl.h>
161$gt_revision_test_code 164$gt_revision_test_code
162extern int _nl_msg_cat_cntr; 165extern int _nl_msg_cat_cntr;
163extern int *_nl_domain_bindings;], 166extern int *_nl_domain_bindings;
164 [bindtextdomain ("", ""); 167 ]],
165return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_domain_bindings], 168 [[
169bindtextdomain ("", "");
170return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_domain_bindings
171 ]])],
166 [eval "$gt_func_gnugettext_libc=yes"], 172 [eval "$gt_func_gnugettext_libc=yes"],
167 [eval "$gt_func_gnugettext_libc=no"])]) 173 [eval "$gt_func_gnugettext_libc=no"])])
168 174
@@ -183,35 +189,47 @@ return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_domain_b
183 gt_save_LIBS="$LIBS" 189 gt_save_LIBS="$LIBS"
184 LIBS="$LIBS $LIBINTL" 190 LIBS="$LIBS $LIBINTL"
185 dnl Now see whether libintl exists and does not depend on libiconv. 191 dnl Now see whether libintl exists and does not depend on libiconv.
186 AC_TRY_LINK([#include <libintl.h> 192 AC_LINK_IFELSE(
193 [AC_LANG_PROGRAM(
194 [[
195#include <libintl.h>
187$gt_revision_test_code 196$gt_revision_test_code
188extern int _nl_msg_cat_cntr; 197extern int _nl_msg_cat_cntr;
189extern 198extern
190#ifdef __cplusplus 199#ifdef __cplusplus
191"C" 200"C"
192#endif 201#endif
193const char *_nl_expand_alias (const char *);], 202const char *_nl_expand_alias (const char *);
194 [bindtextdomain ("", ""); 203 ]],
195return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")], 204 [[
205bindtextdomain ("", "");
206return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")
207 ]])],
196 [eval "$gt_func_gnugettext_libintl=yes"], 208 [eval "$gt_func_gnugettext_libintl=yes"],
197 [eval "$gt_func_gnugettext_libintl=no"]) 209 [eval "$gt_func_gnugettext_libintl=no"])
198 dnl Now see whether libintl exists and depends on libiconv. 210 dnl Now see whether libintl exists and depends on libiconv.
199 if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" != yes; } && test -n "$LIBICONV"; then 211 if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" != yes; } && test -n "$LIBICONV"; then
200 LIBS="$LIBS $LIBICONV" 212 LIBS="$LIBS $LIBICONV"
201 AC_TRY_LINK([#include <libintl.h> 213 AC_LINK_IFELSE(
214 [AC_LANG_PROGRAM(
215 [[
216#include <libintl.h>
202$gt_revision_test_code 217$gt_revision_test_code
203extern int _nl_msg_cat_cntr; 218extern int _nl_msg_cat_cntr;
204extern 219extern
205#ifdef __cplusplus 220#ifdef __cplusplus
206"C" 221"C"
207#endif 222#endif
208const char *_nl_expand_alias (const char *);], 223const char *_nl_expand_alias (const char *);
209 [bindtextdomain ("", ""); 224 ]],
210return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")], 225 [[
211 [LIBINTL="$LIBINTL $LIBICONV" 226bindtextdomain ("", "");
212 LTLIBINTL="$LTLIBINTL $LTLIBICONV" 227return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")
213 eval "$gt_func_gnugettext_libintl=yes" 228 ]])],
214 ]) 229 [LIBINTL="$LIBINTL $LIBICONV"
230 LTLIBINTL="$LTLIBINTL $LTLIBICONV"
231 eval "$gt_func_gnugettext_libintl=yes"
232 ])
215 fi 233 fi
216 CPPFLAGS="$gt_save_CPPFLAGS" 234 CPPFLAGS="$gt_save_CPPFLAGS"
217 LIBS="$gt_save_LIBS"]) 235 LIBS="$gt_save_LIBS"])
diff --git a/gl/m4/glibc2.m4 b/gl/m4/glibc2.m4
index f148c12..0e50682 100644
--- a/gl/m4/glibc2.m4
+++ b/gl/m4/glibc2.m4
@@ -1,5 +1,6 @@
1# glibc2.m4 serial 2 1# glibc2.m4 serial 3
2dnl Copyright (C) 2000-2002, 2004, 2008-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2000-2002, 2004, 2008, 2010-2013 Free Software Foundation,
3dnl Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
@@ -15,7 +16,7 @@ AC_DEFUN([gt_GLIBC2],
15 [ 16 [
16#include <features.h> 17#include <features.h>
17#ifdef __GNU_LIBRARY__ 18#ifdef __GNU_LIBRARY__
18 #if (__GLIBC__ >= 2) 19 #if (__GLIBC__ >= 2) && !defined __UCLIBC__
19 Lucky GNU user 20 Lucky GNU user
20 #endif 21 #endif
21#endif 22#endif
diff --git a/gl/m4/glibc21.m4 b/gl/m4/glibc21.m4
index 68ada9d..613fb2a 100644
--- a/gl/m4/glibc21.m4
+++ b/gl/m4/glibc21.m4
@@ -1,17 +1,18 @@
1# glibc21.m4 serial 4 1# glibc21.m4 serial 5
2dnl Copyright (C) 2000-2002, 2004, 2008-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2000-2002, 2004, 2008, 2010-2013 Free Software Foundation,
3dnl Inc.
3dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved. 6dnl with or without modifications, as long as this notice is preserved.
6 7
7# Test for the GNU C Library, version 2.1 or newer. 8# Test for the GNU C Library, version 2.1 or newer, or uClibc.
8# From Bruno Haible. 9# From Bruno Haible.
9 10
10AC_DEFUN([gl_GLIBC21], 11AC_DEFUN([gl_GLIBC21],
11 [ 12 [
12 AC_CACHE_CHECK([whether we are using the GNU C Library 2.1 or newer], 13 AC_CACHE_CHECK([whether we are using the GNU C Library >= 2.1 or uClibc],
13 [ac_cv_gnu_library_2_1], 14 [ac_cv_gnu_library_2_1],
14 [AC_EGREP_CPP([Lucky GNU user], 15 [AC_EGREP_CPP([Lucky],
15 [ 16 [
16#include <features.h> 17#include <features.h>
17#ifdef __GNU_LIBRARY__ 18#ifdef __GNU_LIBRARY__
@@ -19,6 +20,9 @@ AC_DEFUN([gl_GLIBC21],
19 Lucky GNU user 20 Lucky GNU user
20 #endif 21 #endif
21#endif 22#endif
23#ifdef __UCLIBC__
24 Lucky user
25#endif
22 ], 26 ],
23 [ac_cv_gnu_library_2_1=yes], 27 [ac_cv_gnu_library_2_1=yes],
24 [ac_cv_gnu_library_2_1=no]) 28 [ac_cv_gnu_library_2_1=no])
diff --git a/gl/m4/gnulib-cache.m4 b/gl/m4/gnulib-cache.m4
index 1b6516d..0e1e87d 100644
--- a/gl/m4/gnulib-cache.m4
+++ b/gl/m4/gnulib-cache.m4
@@ -1,21 +1,33 @@
1# Copyright (C) 2002-2010 Free Software Foundation, Inc. 1# Copyright (C) 2002-2013 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; you can redistribute it and/or modify
4# General Public License. As a special exception to the GNU General 4# it under the terms of the GNU General Public License as published by
5# Public License, this file may be distributed as part of a program 5# the Free Software Foundation; either version 3 of the License, or
6# that contains a configuration script generated by Autoconf, under 6# (at your option) any later version.
7#
8# This file is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this file. If not, see <http://www.gnu.org/licenses/>.
15#
16# As a special exception to the GNU General Public License,
17# this file may be distributed as part of a program that
18# contains a configuration script generated by Autoconf, under
7# the same distribution terms as the rest of that program. 19# the same distribution terms as the rest of that program.
8# 20#
9# Generated by gnulib-tool. 21# Generated by gnulib-tool.
10# 22#
11# This file represents the specification of how gnulib-tool is used. 23# This file represents the specification of how gnulib-tool is used.
12# It acts as a cache: It is written and read by gnulib-tool. 24# It acts as a cache: It is written and read by gnulib-tool.
13# In projects using CVS, this file is meant to be stored in CVS, 25# In projects that use version control, this file is meant to be put under
14# like the configure.ac and various Makefile.am files. 26# version control, like the configure.ac and various Makefile.am files.
15 27
16 28
17# Specification in the form of a command-line invocation: 29# 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 --tests-base=tests --aux-dir=build-aux --no-libtool --macro-prefix=gl --no-vc-files base64 crypto/sha1 dirname environ floorf fsusage getaddrinfo gethostname getloadavg getopt gettext mountlist regex setenv strsep timegm unsetenv vasprintf vsnprintf 30# gnulib-tool --import --dir=. --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --no-conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files base64 crypto/sha1 dirname environ floorf fsusage getaddrinfo gethostname getloadavg getopt gettext mountlist regex setenv strsep timegm unsetenv vasprintf vsnprintf
19 31
20# Specification in the form of a few gnulib-tool.m4 macro invocations: 32# Specification in the form of a few gnulib-tool.m4 macro invocations:
21gl_LOCAL_DIR([]) 33gl_LOCAL_DIR([])
@@ -50,4 +62,5 @@ gl_LIB([libgnu])
50gl_MAKEFILE_NAME([]) 62gl_MAKEFILE_NAME([])
51gl_MACRO_PREFIX([gl]) 63gl_MACRO_PREFIX([gl])
52gl_PO_DOMAIN([]) 64gl_PO_DOMAIN([])
65gl_WITNESS_C_MACRO([])
53gl_VC_FILES([false]) 66gl_VC_FILES([false])
diff --git a/gl/m4/gnulib-common.m4 b/gl/m4/gnulib-common.m4
index 4c7ac30..0ae5a9e 100644
--- a/gl/m4/gnulib-common.m4
+++ b/gl/m4/gnulib-common.m4
@@ -1,5 +1,5 @@
1# gnulib-common.m4 serial 20 1# gnulib-common.m4 serial 33
2dnl Copyright (C) 2007-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2007-2013 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,11 +12,25 @@ AC_DEFUN([gl_COMMON], [
12 AC_REQUIRE([gl_COMMON_BODY]) 12 AC_REQUIRE([gl_COMMON_BODY])
13]) 13])
14AC_DEFUN([gl_COMMON_BODY], [ 14AC_DEFUN([gl_COMMON_BODY], [
15 AH_VERBATIM([_Noreturn],
16[/* The _Noreturn keyword of C11. */
17#if ! (defined _Noreturn \
18 || (defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__))
19# if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \
20 || 0x5110 <= __SUNPRO_C)
21# define _Noreturn __attribute__ ((__noreturn__))
22# elif defined _MSC_VER && 1200 <= _MSC_VER
23# define _Noreturn __declspec (noreturn)
24# else
25# define _Noreturn
26# endif
27#endif
28])
15 AH_VERBATIM([isoc99_inline], 29 AH_VERBATIM([isoc99_inline],
16[/* Work around a bug in Apple GCC 4.0.1 build 5465: In C99 mode, it supports 30[/* Work around a bug in Apple GCC 4.0.1 build 5465: In C99 mode, it supports
17 the ISO C 99 semantics of 'extern inline' (unlike the GNU C semantics of 31 the ISO C 99 semantics of 'extern inline' (unlike the GNU C semantics of
18 earlier versions), but does not display it by setting __GNUC_STDC_INLINE__. 32 earlier versions), but does not display it by setting __GNUC_STDC_INLINE__.
19 __APPLE__ && __MACH__ test for MacOS X. 33 __APPLE__ && __MACH__ test for Mac OS X.
20 __APPLE_CC__ tests for the Apple compiler and its version. 34 __APPLE_CC__ tests for the Apple compiler and its version.
21 __STDC_VERSION__ tests for the C99 mode. */ 35 __STDC_VERSION__ tests for the C99 mode. */
22#if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined __cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__ 36#if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined __cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__
@@ -34,6 +48,20 @@ AC_DEFUN([gl_COMMON_BODY], [
34/* The name _UNUSED_PARAMETER_ is an earlier spelling, although the name 48/* The name _UNUSED_PARAMETER_ is an earlier spelling, although the name
35 is a misnomer outside of parameter lists. */ 49 is a misnomer outside of parameter lists. */
36#define _UNUSED_PARAMETER_ _GL_UNUSED 50#define _UNUSED_PARAMETER_ _GL_UNUSED
51
52/* The __pure__ attribute was added in gcc 2.96. */
53#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
54# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
55#else
56# define _GL_ATTRIBUTE_PURE /* empty */
57#endif
58
59/* The __const__ attribute was added in gcc 2.95. */
60#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
61# define _GL_ATTRIBUTE_CONST __attribute__ ((__const__))
62#else
63# define _GL_ATTRIBUTE_CONST /* empty */
64#endif
37]) 65])
38 dnl Preparation for running test programs: 66 dnl Preparation for running test programs:
39 dnl Tell glibc to write diagnostics from -D_FORTIFY_SOURCE=2 to stderr, not 67 dnl Tell glibc to write diagnostics from -D_FORTIFY_SOURCE=2 to stderr, not
@@ -47,16 +75,49 @@ AC_DEFUN([gl_COMMON_BODY], [
47# expands to a C preprocessor expression that evaluates to 1 or 0, depending 75# expands to a C preprocessor expression that evaluates to 1 or 0, depending
48# whether a gnulib module that has been requested shall be considered present 76# whether a gnulib module that has been requested shall be considered present
49# or not. 77# or not.
50AC_DEFUN([gl_MODULE_INDICATOR_CONDITION], [1]) 78m4_define([gl_MODULE_INDICATOR_CONDITION], [1])
51 79
52# gl_MODULE_INDICATOR_SET_VARIABLE([modulename]) 80# gl_MODULE_INDICATOR_SET_VARIABLE([modulename])
53# sets the shell variable that indicates the presence of the given module to 81# sets the shell variable that indicates the presence of the given module to
54# a C preprocessor expression that will evaluate to 1. 82# a C preprocessor expression that will evaluate to 1.
55AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE], 83AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE],
56[ 84[
57 GNULIB_[]m4_translit([[$1]], 85 gl_MODULE_INDICATOR_SET_VARIABLE_AUX(
58 [abcdefghijklmnopqrstuvwxyz./-], 86 [GNULIB_[]m4_translit([[$1]],
59 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=gl_MODULE_INDICATOR_CONDITION 87 [abcdefghijklmnopqrstuvwxyz./-],
88 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])],
89 [gl_MODULE_INDICATOR_CONDITION])
90])
91
92# gl_MODULE_INDICATOR_SET_VARIABLE_AUX([variable])
93# modifies the shell variable to include the gl_MODULE_INDICATOR_CONDITION.
94# The shell variable's value is a C preprocessor expression that evaluates
95# to 0 or 1.
96AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE_AUX],
97[
98 m4_if(m4_defn([gl_MODULE_INDICATOR_CONDITION]), [1],
99 [
100 dnl Simplify the expression VALUE || 1 to 1.
101 $1=1
102 ],
103 [gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR([$1],
104 [gl_MODULE_INDICATOR_CONDITION])])
105])
106
107# gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR([variable], [condition])
108# modifies the shell variable to include the given condition. The shell
109# variable's value is a C preprocessor expression that evaluates to 0 or 1.
110AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE_AUX_OR],
111[
112 dnl Simplify the expression 1 || CONDITION to 1.
113 if test "$[]$1" != 1; then
114 dnl Simplify the expression 0 || CONDITION to CONDITION.
115 if test "$[]$1" = 0; then
116 $1=$2
117 else
118 $1="($[]$1 || $2)"
119 fi
120 fi
60]) 121])
61 122
62# gl_MODULE_INDICATOR([modulename]) 123# gl_MODULE_INDICATOR([modulename])
@@ -102,6 +163,40 @@ AC_DEFUN([gl_MODULE_INDICATOR_FOR_TESTS],
102 [Define to 1 when the gnulib module $1 should be tested.]) 163 [Define to 1 when the gnulib module $1 should be tested.])
103]) 164])
104 165
166# gl_ASSERT_NO_GNULIB_POSIXCHECK
167# asserts that there will never be a need to #define GNULIB_POSIXCHECK.
168# and thereby enables an optimization of configure and config.h.
169# Used by Emacs.
170AC_DEFUN([gl_ASSERT_NO_GNULIB_POSIXCHECK],
171[
172 dnl Override gl_WARN_ON_USE_PREPARE.
173 dnl But hide this definition from 'aclocal'.
174 AC_DEFUN([gl_W][ARN_ON_USE_PREPARE], [])
175])
176
177# gl_ASSERT_NO_GNULIB_TESTS
178# asserts that there will be no gnulib tests in the scope of the configure.ac
179# and thereby enables an optimization of config.h.
180# Used by Emacs.
181AC_DEFUN([gl_ASSERT_NO_GNULIB_TESTS],
182[
183 dnl Override gl_MODULE_INDICATOR_FOR_TESTS.
184 AC_DEFUN([gl_MODULE_INDICATOR_FOR_TESTS], [])
185])
186
187# Test whether <features.h> exists.
188# Set HAVE_FEATURES_H.
189AC_DEFUN([gl_FEATURES_H],
190[
191 AC_CHECK_HEADERS_ONCE([features.h])
192 if test $ac_cv_header_features_h = yes; then
193 HAVE_FEATURES_H=1
194 else
195 HAVE_FEATURES_H=0
196 fi
197 AC_SUBST([HAVE_FEATURES_H])
198])
199
105# m4_foreach_w 200# m4_foreach_w
106# is a backport of autoconf-2.59c's m4_foreach_w. 201# is a backport of autoconf-2.59c's m4_foreach_w.
107# Remove this macro when we can assume autoconf >= 2.60. 202# Remove this macro when we can assume autoconf >= 2.60.
@@ -117,11 +212,90 @@ m4_ifndef([AS_VAR_IF],
117[m4_define([AS_VAR_IF], 212[m4_define([AS_VAR_IF],
118[AS_IF([test x"AS_VAR_GET([$1])" = x""$2], [$3], [$4])])]) 213[AS_IF([test x"AS_VAR_GET([$1])" = x""$2], [$3], [$4])])])
119 214
215# gl_PROG_CC_C99
216# Modifies the value of the shell variable CC in an attempt to make $CC
217# understand ISO C99 source code.
218# This is like AC_PROG_CC_C99, except that
219# - AC_PROG_CC_C99 did not exist in Autoconf versions < 2.60,
220# - AC_PROG_CC_C99 does not mix well with AC_PROG_CC_STDC
221# <http://lists.gnu.org/archive/html/bug-gnulib/2011-09/msg00367.html>,
222# but many more packages use AC_PROG_CC_STDC than AC_PROG_CC_C99
223# <http://lists.gnu.org/archive/html/bug-gnulib/2011-09/msg00441.html>.
224# Remaining problems:
225# - When AC_PROG_CC_STDC is invoked twice, it adds the C99 enabling options
226# to CC twice
227# <http://lists.gnu.org/archive/html/bug-gnulib/2011-09/msg00431.html>.
228# - AC_PROG_CC_STDC is likely to change now that C11 is an ISO standard.
229AC_DEFUN([gl_PROG_CC_C99],
230[
231 dnl Change that version number to the minimum Autoconf version that supports
232 dnl mixing AC_PROG_CC_C99 calls with AC_PROG_CC_STDC calls.
233 m4_version_prereq([9.0],
234 [AC_REQUIRE([AC_PROG_CC_C99])],
235 [AC_REQUIRE([AC_PROG_CC_STDC])])
236])
237
238# gl_PROG_AR_RANLIB
239# Determines the values for AR, ARFLAGS, RANLIB that fit with the compiler.
240# The user can set the variables AR, ARFLAGS, RANLIB if he wants to override
241# the values.
242AC_DEFUN([gl_PROG_AR_RANLIB],
243[
244 dnl Minix 3 comes with two toolchains: The Amsterdam Compiler Kit compiler
245 dnl as "cc", and GCC as "gcc". They have different object file formats and
246 dnl library formats. In particular, the GNU binutils programs ar, ranlib
247 dnl produce libraries that work only with gcc, not with cc.
248 AC_REQUIRE([AC_PROG_CC])
249 AC_CACHE_CHECK([for Minix Amsterdam compiler], [gl_cv_c_amsterdam_compiler],
250 [
251 AC_EGREP_CPP([Amsterdam],
252 [
253#ifdef __ACK__
254Amsterdam
255#endif
256 ],
257 [gl_cv_c_amsterdam_compiler=yes],
258 [gl_cv_c_amsterdam_compiler=no])
259 ])
260 if test -z "$AR"; then
261 if test $gl_cv_c_amsterdam_compiler = yes; then
262 AR='cc -c.a'
263 if test -z "$ARFLAGS"; then
264 ARFLAGS='-o'
265 fi
266 else
267 dnl Use the Automake-documented default values for AR and ARFLAGS,
268 dnl but prefer ${host}-ar over ar (useful for cross-compiling).
269 AC_CHECK_TOOL([AR], [ar], [ar])
270 if test -z "$ARFLAGS"; then
271 ARFLAGS='cru'
272 fi
273 fi
274 else
275 if test -z "$ARFLAGS"; then
276 ARFLAGS='cru'
277 fi
278 fi
279 AC_SUBST([AR])
280 AC_SUBST([ARFLAGS])
281 if test -z "$RANLIB"; then
282 if test $gl_cv_c_amsterdam_compiler = yes; then
283 RANLIB=':'
284 else
285 dnl Use the ranlib program if it is available.
286 AC_PROG_RANLIB
287 fi
288 fi
289 AC_SUBST([RANLIB])
290])
291
120# AC_PROG_MKDIR_P 292# AC_PROG_MKDIR_P
121# is a backport of autoconf-2.60's AC_PROG_MKDIR_P, with a fix 293# is a backport of autoconf-2.60's AC_PROG_MKDIR_P, with a fix
122# for interoperability with automake-1.9.6 from autoconf-2.62. 294# for interoperability with automake-1.9.6 from autoconf-2.62.
123# Remove this macro when we can assume autoconf >= 2.62 or 295# Remove this macro when we can assume autoconf >= 2.62 or
124# autoconf >= 2.60 && automake >= 1.10. 296# autoconf >= 2.60 && automake >= 1.10.
297# AC_AUTOCONF_VERSION was introduced in 2.62, so use that as the witness.
298m4_ifndef([AC_AUTOCONF_VERSION],[
125m4_ifdef([AC_PROG_MKDIR_P], [ 299m4_ifdef([AC_PROG_MKDIR_P], [
126 dnl For automake-1.9.6 && autoconf < 2.62: Ensure MKDIR_P is AC_SUBSTed. 300 dnl For automake-1.9.6 && autoconf < 2.62: Ensure MKDIR_P is AC_SUBSTed.
127 m4_define([AC_PROG_MKDIR_P], 301 m4_define([AC_PROG_MKDIR_P],
@@ -132,13 +306,15 @@ m4_ifdef([AC_PROG_MKDIR_P], [
132 [AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake 306 [AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake
133 MKDIR_P='$(mkdir_p)' 307 MKDIR_P='$(mkdir_p)'
134 AC_SUBST([MKDIR_P])])]) 308 AC_SUBST([MKDIR_P])])])
309])
135 310
136# AC_C_RESTRICT 311# AC_C_RESTRICT
137# This definition overrides the AC_C_RESTRICT macro from autoconf 2.60..2.61, 312# This definition overrides the AC_C_RESTRICT macro from autoconf 2.60..2.61,
138# so that mixed use of GNU C and GNU C++ and mixed use of Sun C and Sun C++ 313# so that mixed use of GNU C and GNU C++ and mixed use of Sun C and Sun C++
139# works. 314# works.
140# This definition can be removed once autoconf >= 2.62 can be assumed. 315# This definition can be removed once autoconf >= 2.62 can be assumed.
141m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.62]),[-1],[ 316# AC_AUTOCONF_VERSION was introduced in 2.62, so use that as the witness.
317m4_ifndef([AC_AUTOCONF_VERSION],[
142AC_DEFUN([AC_C_RESTRICT], 318AC_DEFUN([AC_C_RESTRICT],
143[AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict], 319[AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict],
144 [ac_cv_c_restrict=no 320 [ac_cv_c_restrict=no
diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4
index b5e6b43..c6cc73a 100644
--- a/gl/m4/gnulib-comp.m4
+++ b/gl/m4/gnulib-comp.m4
@@ -1,10 +1,22 @@
1# DO NOT EDIT! GENERATED AUTOMATICALLY! 1# DO NOT EDIT! GENERATED AUTOMATICALLY!
2# Copyright (C) 2002-2010 Free Software Foundation, Inc. 2# Copyright (C) 2002-2013 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; you can redistribute it and/or modify
5# General Public License. As a special exception to the GNU General 5# it under the terms of the GNU General Public License as published by
6# Public License, this file may be distributed as part of a program 6# the Free Software Foundation; either version 3 of the License, or
7# that contains a configuration script generated by Autoconf, under 7# (at your option) any later version.
8#
9# This file 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 file. If not, see <http://www.gnu.org/licenses/>.
16#
17# As a special exception to the GNU General Public License,
18# this file may be distributed as part of a program that
19# contains a configuration script generated by Autoconf, under
8# the same distribution terms as the rest of that program. 20# the same distribution terms as the rest of that program.
9# 21#
10# Generated by gnulib-tool. 22# Generated by gnulib-tool.
@@ -12,7 +24,8 @@
12# This file represents the compiled summary of the specification in 24# This file represents the compiled summary of the specification in
13# gnulib-cache.m4. It lists the computed macro invocations that need 25# gnulib-cache.m4. It lists the computed macro invocations that need
14# to be invoked from configure.ac. 26# to be invoked from configure.ac.
15# In projects using CVS, this file can be treated like other built files. 27# In projects that use version control, this file can be treated like
28# other built files.
16 29
17 30
18# This macro should be invoked from ./configure.in, in the section 31# This macro should be invoked from ./configure.in, in the section
@@ -24,39 +37,31 @@ AC_DEFUN([gl_EARLY],
24 m4_pattern_allow([^gl_ES$])dnl a valid locale name 37 m4_pattern_allow([^gl_ES$])dnl a valid locale name
25 m4_pattern_allow([^gl_LIBOBJS$])dnl a variable 38 m4_pattern_allow([^gl_LIBOBJS$])dnl a variable
26 m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable 39 m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable
27 AC_REQUIRE([AC_PROG_RANLIB]) 40 AC_REQUIRE([gl_PROG_AR_RANLIB])
28 # Code from module alignof: 41 AC_REQUIRE([AM_PROG_CC_C_O])
29 # Code from module alloca-opt: 42 # Code from module alloca-opt:
30 # Code from module arg-nonnull:
31 # Code from module arpa_inet: 43 # Code from module arpa_inet:
32 # Code from module base64: 44 # Code from module base64:
33 # Code from module btowc: 45 # Code from module btowc:
34 # Code from module c++defs:
35 # Code from module c-strtod:
36 # Code from module cloexec:
37 # Code from module close-hook:
38 # Code from module configmake: 46 # Code from module configmake:
39 # Code from module crypto/sha1: 47 # Code from module crypto/sha1:
40 # Code from module dirname: 48 # Code from module dirname:
41 # Code from module dirname-lgpl: 49 # Code from module dirname-lgpl:
50 # Code from module dosname:
42 # Code from module double-slash-root: 51 # Code from module double-slash-root:
43 # Code from module dup2:
44 # Code from module environ: 52 # Code from module environ:
45 # Code from module errno: 53 # Code from module errno:
46 # Code from module error: 54 # Code from module error:
47 # Code from module exitfail: 55 # Code from module exitfail:
48 # Code from module extensions: 56 # Code from module extensions:
49 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) 57 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
50 # Code from module fcntl: 58 # Code from module extern-inline:
51 # Code from module fcntl-h: 59 # Code from module fd-hook:
52 # Code from module fcntl-safer:
53 # Code from module float: 60 # Code from module float:
54 # Code from module floorf: 61 # Code from module floorf:
55 # Code from module fsusage: 62 # Code from module fsusage:
56 # Code from module full-read: 63 # Code from module full-read:
57 # Code from module full-write:
58 # Code from module getaddrinfo: 64 # Code from module getaddrinfo:
59 # Code from module getdtablesize:
60 # Code from module gethostname: 65 # Code from module gethostname:
61 # Code from module getloadavg: 66 # Code from module getloadavg:
62 # Code from module getopt: 67 # Code from module getopt:
@@ -68,68 +73,81 @@ AC_DEFUN([gl_EARLY],
68 # Code from module hostent: 73 # Code from module hostent:
69 # Code from module include_next: 74 # Code from module include_next:
70 # Code from module inet_ntop: 75 # Code from module inet_ntop:
71 # Code from module inline:
72 # Code from module intprops: 76 # Code from module intprops:
73 # Code from module langinfo: 77 # Code from module langinfo:
78 # Code from module largefile:
79 AC_REQUIRE([AC_SYS_LARGEFILE])
74 # Code from module localcharset: 80 # Code from module localcharset:
75 # Code from module locale: 81 # Code from module locale:
76 # Code from module malloc: 82 # Code from module localeconv:
83 # Code from module lock:
84 # Code from module malloc-gnu:
77 # Code from module malloc-posix: 85 # Code from module malloc-posix:
78 # Code from module malloca: 86 # Code from module malloca:
79 # Code from module math: 87 # Code from module math:
80 # Code from module mbrtowc: 88 # Code from module mbrtowc:
81 # Code from module mbsinit: 89 # Code from module mbsinit:
90 # Code from module mbtowc:
82 # Code from module memchr: 91 # Code from module memchr:
83 # Code from module mktime: 92 # Code from module mktime:
93 # Code from module mktime-internal:
84 # Code from module mountlist: 94 # Code from module mountlist:
95 # Code from module msvc-inval:
96 # Code from module msvc-nothrow:
85 # Code from module multiarch: 97 # Code from module multiarch:
86 # Code from module netdb: 98 # Code from module netdb:
87 # Code from module netinet_in: 99 # Code from module netinet_in:
88 # Code from module nl_langinfo: 100 # Code from module nl_langinfo:
89 # Code from module open: 101 # Code from module nocrash:
102 # Code from module read:
90 # Code from module regex: 103 # Code from module regex:
91 # Code from module safe-read: 104 # Code from module safe-read:
92 # Code from module safe-write:
93 # Code from module servent: 105 # Code from module servent:
94 # Code from module setenv: 106 # Code from module setenv:
95 # Code from module size_max: 107 # Code from module size_max:
108 # Code from module snippet/_Noreturn:
109 # Code from module snippet/arg-nonnull:
110 # Code from module snippet/c++defs:
111 # Code from module snippet/warn-on-use:
96 # Code from module snprintf: 112 # Code from module snprintf:
113 # Code from module socketlib:
97 # Code from module sockets: 114 # Code from module sockets:
98 # Code from module socklen: 115 # Code from module socklen:
99 # Code from module ssize_t: 116 # Code from module ssize_t:
100 # Code from module stat: 117 # Code from module stdalign:
101 # Code from module stdbool: 118 # Code from module stdbool:
102 # Code from module stddef: 119 # Code from module stddef:
103 # Code from module stdint: 120 # Code from module stdint:
104 # Code from module stdio: 121 # Code from module stdio:
105 # Code from module stdlib: 122 # Code from module stdlib:
106 # Code from module strdup-posix:
107 # Code from module streq: 123 # Code from module streq:
108 # Code from module strerror: 124 # Code from module strerror:
125 # Code from module strerror-override:
109 # Code from module string: 126 # Code from module string:
110 # Code from module strndup: 127 # Code from module strndup:
111 # Code from module strnlen: 128 # Code from module strnlen:
112 # Code from module strsep: 129 # Code from module strsep:
113 # Code from module strstr-simple: 130 # Code from module strstr-simple:
114 # Code from module sys_socket: 131 # Code from module sys_socket:
115 # Code from module sys_stat: 132 # Code from module sys_types:
133 # Code from module sys_uio:
134 # Code from module threadlib:
135 gl_THREADLIB_EARLY
116 # Code from module time: 136 # Code from module time:
117 # Code from module time_r: 137 # Code from module time_r:
118 # Code from module timegm: 138 # Code from module timegm:
119 # Code from module unistd: 139 # Code from module unistd:
120 # Code from module unistd-safer:
121 # Code from module unsetenv: 140 # Code from module unsetenv:
122 # Code from module vasnprintf: 141 # Code from module vasnprintf:
123 # Code from module vasprintf: 142 # Code from module vasprintf:
124 # Code from module verify: 143 # Code from module verify:
125 # Code from module vsnprintf: 144 # Code from module vsnprintf:
126 # Code from module warn-on-use:
127 # Code from module wchar: 145 # Code from module wchar:
128 # Code from module wcrtomb: 146 # Code from module wcrtomb:
129 # Code from module wctype: 147 # Code from module wctype-h:
130 # Code from module write:
131 # Code from module xalloc: 148 # Code from module xalloc:
132 # Code from module xalloc-die: 149 # Code from module xalloc-die:
150 # Code from module xalloc-oversized:
133 # Code from module xsize: 151 # Code from module xsize:
134 # Code from module xstrndup: 152 # Code from module xstrndup:
135]) 153])
@@ -150,252 +168,296 @@ AC_DEFUN([gl_INIT],
150 m4_pushdef([gl_LIBSOURCES_DIR], []) 168 m4_pushdef([gl_LIBSOURCES_DIR], [])
151 gl_COMMON 169 gl_COMMON
152 gl_source_base='gl' 170 gl_source_base='gl'
153 # Code from module alignof:
154 # Code from module alloca-opt:
155 gl_FUNC_ALLOCA 171 gl_FUNC_ALLOCA
156 # Code from module arg-nonnull:
157 # Code from module arpa_inet:
158 gl_HEADER_ARPA_INET 172 gl_HEADER_ARPA_INET
159 AC_PROG_MKDIR_P 173 AC_PROG_MKDIR_P
160 # Code from module base64:
161 gl_FUNC_BASE64 174 gl_FUNC_BASE64
162 # Code from module btowc:
163 gl_FUNC_BTOWC 175 gl_FUNC_BTOWC
176 if test $HAVE_BTOWC = 0 || test $REPLACE_BTOWC = 1; then
177 AC_LIBOBJ([btowc])
178 gl_PREREQ_BTOWC
179 fi
164 gl_WCHAR_MODULE_INDICATOR([btowc]) 180 gl_WCHAR_MODULE_INDICATOR([btowc])
165 # Code from module c++defs: 181 gl_CONFIGMAKE_PREP
166 # Code from module c-strtod:
167 gl_C_STRTOD
168 # Code from module cloexec:
169 gl_CLOEXEC
170 gl_MODULE_INDICATOR_FOR_TESTS([cloexec])
171 # Code from module close-hook:
172 # Code from module configmake:
173 # Code from module crypto/sha1:
174 gl_SHA1 182 gl_SHA1
175 # Code from module dirname:
176 gl_DIRNAME 183 gl_DIRNAME
177 gl_MODULE_INDICATOR([dirname]) 184 gl_MODULE_INDICATOR([dirname])
178 # Code from module dirname-lgpl:
179 gl_DIRNAME_LGPL 185 gl_DIRNAME_LGPL
180 # Code from module double-slash-root:
181 gl_DOUBLE_SLASH_ROOT 186 gl_DOUBLE_SLASH_ROOT
182 # Code from module dup2:
183 gl_FUNC_DUP2
184 gl_UNISTD_MODULE_INDICATOR([dup2])
185 # Code from module environ:
186 gl_ENVIRON 187 gl_ENVIRON
187 gl_UNISTD_MODULE_INDICATOR([environ]) 188 gl_UNISTD_MODULE_INDICATOR([environ])
188 # Code from module errno:
189 gl_HEADER_ERRNO_H 189 gl_HEADER_ERRNO_H
190 # Code from module error:
191 gl_ERROR 190 gl_ERROR
191 if test $ac_cv_lib_error_at_line = no; then
192 AC_LIBOBJ([error])
193 gl_PREREQ_ERROR
194 fi
192 m4_ifdef([AM_XGETTEXT_OPTION], 195 m4_ifdef([AM_XGETTEXT_OPTION],
193 [AM_][XGETTEXT_OPTION([--flag=error:3:c-format]) 196 [AM_][XGETTEXT_OPTION([--flag=error:3:c-format])
194 AM_][XGETTEXT_OPTION([--flag=error_at_line:5:c-format])]) 197 AM_][XGETTEXT_OPTION([--flag=error_at_line:5:c-format])])
195 # Code from module exitfail: 198 AC_REQUIRE([gl_EXTERN_INLINE])
196 # Code from module extensions:
197 # Code from module fcntl:
198 gl_FUNC_FCNTL
199 gl_FCNTL_MODULE_INDICATOR([fcntl])
200 # Code from module fcntl-h:
201 gl_FCNTL_H
202 # Code from module fcntl-safer:
203 gl_FCNTL_SAFER
204 gl_MODULE_INDICATOR([fcntl-safer])
205 # Code from module float:
206 gl_FLOAT_H 199 gl_FLOAT_H
207 # Code from module floorf: 200 if test $REPLACE_FLOAT_LDBL = 1; then
201 AC_LIBOBJ([float])
202 fi
203 if test $REPLACE_ITOLD = 1; then
204 AC_LIBOBJ([itold])
205 fi
208 gl_FUNC_FLOORF 206 gl_FUNC_FLOORF
207 if test $HAVE_DECL_FLOORF = 0 || test $REPLACE_FLOORF = 1; then
208 AC_LIBOBJ([floorf])
209 fi
209 gl_MATH_MODULE_INDICATOR([floorf]) 210 gl_MATH_MODULE_INDICATOR([floorf])
210 # Code from module fsusage:
211 gl_FSUSAGE 211 gl_FSUSAGE
212 # Code from module full-read: 212 if test $gl_cv_fs_space = yes; then
213 # Code from module full-write: 213 AC_LIBOBJ([fsusage])
214 # Code from module getaddrinfo: 214 gl_PREREQ_FSUSAGE_EXTRA
215 fi
215 gl_GETADDRINFO 216 gl_GETADDRINFO
217 if test $HAVE_GETADDRINFO = 0; then
218 AC_LIBOBJ([getaddrinfo])
219 fi
220 if test $HAVE_DECL_GAI_STRERROR = 0 || test $REPLACE_GAI_STRERROR = 1; then
221 AC_LIBOBJ([gai_strerror])
222 fi
216 gl_NETDB_MODULE_INDICATOR([getaddrinfo]) 223 gl_NETDB_MODULE_INDICATOR([getaddrinfo])
217 # Code from module getdtablesize:
218 gl_FUNC_GETDTABLESIZE
219 gl_UNISTD_MODULE_INDICATOR([getdtablesize])
220 # Code from module gethostname:
221 gl_FUNC_GETHOSTNAME 224 gl_FUNC_GETHOSTNAME
225 if test $HAVE_GETHOSTNAME = 0; then
226 AC_LIBOBJ([gethostname])
227 gl_PREREQ_GETHOSTNAME
228 fi
222 gl_UNISTD_MODULE_INDICATOR([gethostname]) 229 gl_UNISTD_MODULE_INDICATOR([gethostname])
223 # Code from module getloadavg: 230 gl_GETLOADAVG
224 gl_GETLOADAVG([$gl_source_base]) 231 if test $HAVE_GETLOADAVG = 0; then
232 AC_LIBOBJ([getloadavg])
233 gl_PREREQ_GETLOADAVG
234 fi
225 gl_STDLIB_MODULE_INDICATOR([getloadavg]) 235 gl_STDLIB_MODULE_INDICATOR([getloadavg])
226 # Code from module getopt:
227 # Code from module getopt-gnu:
228 gl_FUNC_GETOPT_GNU 236 gl_FUNC_GETOPT_GNU
237 if test $REPLACE_GETOPT = 1; then
238 AC_LIBOBJ([getopt])
239 AC_LIBOBJ([getopt1])
240 gl_PREREQ_GETOPT
241 dnl Arrange for unistd.h to include getopt.h.
242 GNULIB_GL_UNISTD_H_GETOPT=1
243 fi
244 AC_SUBST([GNULIB_GL_UNISTD_H_GETOPT])
229 gl_MODULE_INDICATOR_FOR_TESTS([getopt-gnu]) 245 gl_MODULE_INDICATOR_FOR_TESTS([getopt-gnu])
230 # Code from module getopt-posix:
231 gl_FUNC_GETOPT_POSIX 246 gl_FUNC_GETOPT_POSIX
232 # Code from module gettext: 247 if test $REPLACE_GETOPT = 1; then
248 AC_LIBOBJ([getopt])
249 AC_LIBOBJ([getopt1])
250 gl_PREREQ_GETOPT
251 dnl Arrange for unistd.h to include getopt.h.
252 GNULIB_GL_UNISTD_H_GETOPT=1
253 fi
254 AC_SUBST([GNULIB_GL_UNISTD_H_GETOPT])
233 dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac. 255 dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac.
234 AM_GNU_GETTEXT_VERSION([0.18.1]) 256 AM_GNU_GETTEXT_VERSION([0.18.1])
235 # Code from module gettext-h:
236 AC_SUBST([LIBINTL]) 257 AC_SUBST([LIBINTL])
237 AC_SUBST([LTLIBINTL]) 258 AC_SUBST([LTLIBINTL])
238 # Code from module havelib:
239 # Code from module hostent:
240 gl_HOSTENT 259 gl_HOSTENT
241 # Code from module include_next:
242 # Code from module inet_ntop:
243 gl_FUNC_INET_NTOP 260 gl_FUNC_INET_NTOP
261 if test $HAVE_INET_NTOP = 0 || test $REPLACE_INET_NTOP = 1; then
262 AC_LIBOBJ([inet_ntop])
263 gl_PREREQ_INET_NTOP
264 fi
244 gl_ARPA_INET_MODULE_INDICATOR([inet_ntop]) 265 gl_ARPA_INET_MODULE_INDICATOR([inet_ntop])
245 # Code from module inline:
246 gl_INLINE
247 # Code from module intprops:
248 # Code from module langinfo:
249 gl_LANGINFO_H 266 gl_LANGINFO_H
250 # Code from module localcharset: 267 AC_REQUIRE([gl_LARGEFILE])
251 gl_LOCALCHARSET 268 gl_LOCALCHARSET
252 LOCALCHARSET_TESTS_ENVIRONMENT="CHARSETALIASDIR=\"\$(top_builddir)/$gl_source_base\"" 269 LOCALCHARSET_TESTS_ENVIRONMENT="CHARSETALIASDIR=\"\$(abs_top_builddir)/$gl_source_base\""
253 AC_SUBST([LOCALCHARSET_TESTS_ENVIRONMENT]) 270 AC_SUBST([LOCALCHARSET_TESTS_ENVIRONMENT])
254 # Code from module locale:
255 gl_LOCALE_H 271 gl_LOCALE_H
256 # Code from module malloc: 272 gl_FUNC_LOCALECONV
273 if test $REPLACE_LOCALECONV = 1; then
274 AC_LIBOBJ([localeconv])
275 gl_PREREQ_LOCALECONV
276 fi
277 gl_LOCALE_MODULE_INDICATOR([localeconv])
278 gl_LOCK
279 gl_MODULE_INDICATOR([lock])
257 gl_FUNC_MALLOC_GNU 280 gl_FUNC_MALLOC_GNU
258 AC_DEFINE([GNULIB_MALLOC_GNU], 1, [Define to indicate the 'malloc' module.]) 281 if test $REPLACE_MALLOC = 1; then
259 # Code from module malloc-posix: 282 AC_LIBOBJ([malloc])
283 fi
284 gl_MODULE_INDICATOR([malloc-gnu])
260 gl_FUNC_MALLOC_POSIX 285 gl_FUNC_MALLOC_POSIX
286 if test $REPLACE_MALLOC = 1; then
287 AC_LIBOBJ([malloc])
288 fi
261 gl_STDLIB_MODULE_INDICATOR([malloc-posix]) 289 gl_STDLIB_MODULE_INDICATOR([malloc-posix])
262 # Code from module malloca:
263 gl_MALLOCA 290 gl_MALLOCA
264 # Code from module math:
265 gl_MATH_H 291 gl_MATH_H
266 # Code from module mbrtowc:
267 gl_FUNC_MBRTOWC 292 gl_FUNC_MBRTOWC
293 if test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1; then
294 AC_LIBOBJ([mbrtowc])
295 gl_PREREQ_MBRTOWC
296 fi
268 gl_WCHAR_MODULE_INDICATOR([mbrtowc]) 297 gl_WCHAR_MODULE_INDICATOR([mbrtowc])
269 # Code from module mbsinit:
270 gl_FUNC_MBSINIT 298 gl_FUNC_MBSINIT
299 if test $HAVE_MBSINIT = 0 || test $REPLACE_MBSINIT = 1; then
300 AC_LIBOBJ([mbsinit])
301 gl_PREREQ_MBSINIT
302 fi
271 gl_WCHAR_MODULE_INDICATOR([mbsinit]) 303 gl_WCHAR_MODULE_INDICATOR([mbsinit])
272 # Code from module memchr: 304 gl_FUNC_MBTOWC
305 if test $REPLACE_MBTOWC = 1; then
306 AC_LIBOBJ([mbtowc])
307 gl_PREREQ_MBTOWC
308 fi
309 gl_STDLIB_MODULE_INDICATOR([mbtowc])
273 gl_FUNC_MEMCHR 310 gl_FUNC_MEMCHR
311 if test $HAVE_MEMCHR = 0 || test $REPLACE_MEMCHR = 1; then
312 AC_LIBOBJ([memchr])
313 gl_PREREQ_MEMCHR
314 fi
274 gl_STRING_MODULE_INDICATOR([memchr]) 315 gl_STRING_MODULE_INDICATOR([memchr])
275 # Code from module mktime:
276 gl_FUNC_MKTIME 316 gl_FUNC_MKTIME
317 if test $REPLACE_MKTIME = 1; then
318 AC_LIBOBJ([mktime])
319 gl_PREREQ_MKTIME
320 fi
277 gl_TIME_MODULE_INDICATOR([mktime]) 321 gl_TIME_MODULE_INDICATOR([mktime])
278 # Code from module mountlist: 322 gl_FUNC_MKTIME_INTERNAL
323 if test $REPLACE_MKTIME = 1; then
324 AC_LIBOBJ([mktime])
325 gl_PREREQ_MKTIME
326 fi
279 gl_MOUNTLIST 327 gl_MOUNTLIST
280 # Code from module multiarch: 328 if test $gl_cv_list_mounted_fs = yes; then
329 AC_LIBOBJ([mountlist])
330 gl_PREREQ_MOUNTLIST_EXTRA
331 fi
332 gl_MSVC_INVAL
333 if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then
334 AC_LIBOBJ([msvc-inval])
335 fi
336 gl_MSVC_NOTHROW
337 if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then
338 AC_LIBOBJ([msvc-nothrow])
339 fi
281 gl_MULTIARCH 340 gl_MULTIARCH
282 # Code from module netdb:
283 gl_HEADER_NETDB 341 gl_HEADER_NETDB
284 # Code from module netinet_in:
285 gl_HEADER_NETINET_IN 342 gl_HEADER_NETINET_IN
286 AC_PROG_MKDIR_P 343 AC_PROG_MKDIR_P
287 # Code from module nl_langinfo:
288 gl_FUNC_NL_LANGINFO 344 gl_FUNC_NL_LANGINFO
345 if test $HAVE_NL_LANGINFO = 0 || test $REPLACE_NL_LANGINFO = 1; then
346 AC_LIBOBJ([nl_langinfo])
347 fi
289 gl_LANGINFO_MODULE_INDICATOR([nl_langinfo]) 348 gl_LANGINFO_MODULE_INDICATOR([nl_langinfo])
290 # Code from module open: 349 gl_FUNC_READ
291 gl_FUNC_OPEN 350 if test $REPLACE_READ = 1; then
292 gl_FCNTL_MODULE_INDICATOR([open]) 351 AC_LIBOBJ([read])
293 # Code from module regex: 352 gl_PREREQ_READ
353 fi
354 gl_UNISTD_MODULE_INDICATOR([read])
294 gl_REGEX 355 gl_REGEX
295 # Code from module safe-read: 356 if test $ac_use_included_regex = yes; then
296 gl_SAFE_READ 357 AC_LIBOBJ([regex])
297 # Code from module safe-write: 358 gl_PREREQ_REGEX
298 gl_SAFE_WRITE 359 fi
299 # Code from module servent: 360 gl_PREREQ_SAFE_READ
300 gl_SERVENT 361 gl_SERVENT
301 # Code from module setenv:
302 gl_FUNC_SETENV 362 gl_FUNC_SETENV
363 if test $HAVE_SETENV = 0 || test $REPLACE_SETENV = 1; then
364 AC_LIBOBJ([setenv])
365 fi
303 gl_STDLIB_MODULE_INDICATOR([setenv]) 366 gl_STDLIB_MODULE_INDICATOR([setenv])
304 # Code from module size_max:
305 gl_SIZE_MAX 367 gl_SIZE_MAX
306 # Code from module snprintf:
307 gl_FUNC_SNPRINTF 368 gl_FUNC_SNPRINTF
308 gl_STDIO_MODULE_INDICATOR([snprintf]) 369 gl_STDIO_MODULE_INDICATOR([snprintf])
309 # Code from module sockets: 370 gl_MODULE_INDICATOR([snprintf])
371 gl_SOCKETLIB
310 gl_SOCKETS 372 gl_SOCKETS
311 # Code from module socklen:
312 gl_TYPE_SOCKLEN_T 373 gl_TYPE_SOCKLEN_T
313 # Code from module ssize_t:
314 gt_TYPE_SSIZE_T 374 gt_TYPE_SSIZE_T
315 # Code from module stat: 375 gl_STDALIGN_H
316 gl_FUNC_STAT
317 gl_SYS_STAT_MODULE_INDICATOR([stat])
318 # Code from module stdbool:
319 AM_STDBOOL_H 376 AM_STDBOOL_H
320 # Code from module stddef:
321 gl_STDDEF_H 377 gl_STDDEF_H
322 # Code from module stdint:
323 gl_STDINT_H 378 gl_STDINT_H
324 # Code from module stdio:
325 gl_STDIO_H 379 gl_STDIO_H
326 # Code from module stdlib:
327 gl_STDLIB_H 380 gl_STDLIB_H
328 # Code from module strdup-posix:
329 gl_FUNC_STRDUP_POSIX
330 gl_STRING_MODULE_INDICATOR([strdup])
331 # Code from module streq:
332 # Code from module strerror:
333 gl_FUNC_STRERROR 381 gl_FUNC_STRERROR
382 if test $REPLACE_STRERROR = 1; then
383 AC_LIBOBJ([strerror])
384 fi
385 gl_MODULE_INDICATOR([strerror])
334 gl_STRING_MODULE_INDICATOR([strerror]) 386 gl_STRING_MODULE_INDICATOR([strerror])
335 # Code from module string: 387 AC_REQUIRE([gl_HEADER_ERRNO_H])
388 AC_REQUIRE([gl_FUNC_STRERROR_0])
389 if test -n "$ERRNO_H" || test $REPLACE_STRERROR_0 = 1; then
390 AC_LIBOBJ([strerror-override])
391 gl_PREREQ_SYS_H_WINSOCK2
392 fi
336 gl_HEADER_STRING_H 393 gl_HEADER_STRING_H
337 # Code from module strndup:
338 gl_FUNC_STRNDUP 394 gl_FUNC_STRNDUP
395 if test $HAVE_STRNDUP = 0 || test $REPLACE_STRNDUP = 1; then
396 AC_LIBOBJ([strndup])
397 fi
339 gl_STRING_MODULE_INDICATOR([strndup]) 398 gl_STRING_MODULE_INDICATOR([strndup])
340 # Code from module strnlen:
341 gl_FUNC_STRNLEN 399 gl_FUNC_STRNLEN
400 if test $HAVE_DECL_STRNLEN = 0 || test $REPLACE_STRNLEN = 1; then
401 AC_LIBOBJ([strnlen])
402 gl_PREREQ_STRNLEN
403 fi
342 gl_STRING_MODULE_INDICATOR([strnlen]) 404 gl_STRING_MODULE_INDICATOR([strnlen])
343 # Code from module strsep:
344 gl_FUNC_STRSEP 405 gl_FUNC_STRSEP
406 if test $HAVE_STRSEP = 0; then
407 AC_LIBOBJ([strsep])
408 gl_PREREQ_STRSEP
409 fi
345 gl_STRING_MODULE_INDICATOR([strsep]) 410 gl_STRING_MODULE_INDICATOR([strsep])
346 # Code from module strstr-simple:
347 gl_FUNC_STRSTR_SIMPLE 411 gl_FUNC_STRSTR_SIMPLE
412 if test $REPLACE_STRSTR = 1; then
413 AC_LIBOBJ([strstr])
414 fi
348 gl_STRING_MODULE_INDICATOR([strstr]) 415 gl_STRING_MODULE_INDICATOR([strstr])
349 # Code from module sys_socket:
350 gl_HEADER_SYS_SOCKET 416 gl_HEADER_SYS_SOCKET
351 AC_PROG_MKDIR_P 417 AC_PROG_MKDIR_P
352 # Code from module sys_stat: 418 gl_SYS_TYPES_H
353 gl_HEADER_SYS_STAT_H
354 AC_PROG_MKDIR_P 419 AC_PROG_MKDIR_P
355 # Code from module time: 420 gl_HEADER_SYS_UIO
421 AC_PROG_MKDIR_P
422 gl_THREADLIB
356 gl_HEADER_TIME_H 423 gl_HEADER_TIME_H
357 # Code from module time_r:
358 gl_TIME_R 424 gl_TIME_R
425 if test $HAVE_LOCALTIME_R = 0 || test $REPLACE_LOCALTIME_R = 1; then
426 AC_LIBOBJ([time_r])
427 gl_PREREQ_TIME_R
428 fi
359 gl_TIME_MODULE_INDICATOR([time_r]) 429 gl_TIME_MODULE_INDICATOR([time_r])
360 # Code from module timegm:
361 gl_FUNC_TIMEGM 430 gl_FUNC_TIMEGM
431 if test $HAVE_TIMEGM = 0 || test $REPLACE_TIMEGM = 1; then
432 AC_LIBOBJ([timegm])
433 gl_PREREQ_TIMEGM
434 fi
362 gl_TIME_MODULE_INDICATOR([timegm]) 435 gl_TIME_MODULE_INDICATOR([timegm])
363 # Code from module unistd:
364 gl_UNISTD_H 436 gl_UNISTD_H
365 # Code from module unistd-safer:
366 gl_UNISTD_SAFER
367 # Code from module unsetenv:
368 gl_FUNC_UNSETENV 437 gl_FUNC_UNSETENV
438 if test $HAVE_UNSETENV = 0 || test $REPLACE_UNSETENV = 1; then
439 AC_LIBOBJ([unsetenv])
440 gl_PREREQ_UNSETENV
441 fi
369 gl_STDLIB_MODULE_INDICATOR([unsetenv]) 442 gl_STDLIB_MODULE_INDICATOR([unsetenv])
370 # Code from module vasnprintf:
371 gl_FUNC_VASNPRINTF 443 gl_FUNC_VASNPRINTF
372 # Code from module vasprintf:
373 gl_FUNC_VASPRINTF 444 gl_FUNC_VASPRINTF
374 gl_STDIO_MODULE_INDICATOR([vasprintf]) 445 gl_STDIO_MODULE_INDICATOR([vasprintf])
375 m4_ifdef([AM_XGETTEXT_OPTION], 446 m4_ifdef([AM_XGETTEXT_OPTION],
376 [AM_][XGETTEXT_OPTION([--flag=asprintf:2:c-format]) 447 [AM_][XGETTEXT_OPTION([--flag=asprintf:2:c-format])
377 AM_][XGETTEXT_OPTION([--flag=vasprintf:2:c-format])]) 448 AM_][XGETTEXT_OPTION([--flag=vasprintf:2:c-format])])
378 # Code from module verify:
379 # Code from module vsnprintf:
380 gl_FUNC_VSNPRINTF 449 gl_FUNC_VSNPRINTF
381 gl_STDIO_MODULE_INDICATOR([vsnprintf]) 450 gl_STDIO_MODULE_INDICATOR([vsnprintf])
382 # Code from module warn-on-use:
383 # Code from module wchar:
384 gl_WCHAR_H 451 gl_WCHAR_H
385 # Code from module wcrtomb:
386 gl_FUNC_WCRTOMB 452 gl_FUNC_WCRTOMB
453 if test $HAVE_WCRTOMB = 0 || test $REPLACE_WCRTOMB = 1; then
454 AC_LIBOBJ([wcrtomb])
455 gl_PREREQ_WCRTOMB
456 fi
387 gl_WCHAR_MODULE_INDICATOR([wcrtomb]) 457 gl_WCHAR_MODULE_INDICATOR([wcrtomb])
388 # Code from module wctype:
389 gl_WCTYPE_H 458 gl_WCTYPE_H
390 # Code from module write:
391 gl_FUNC_WRITE
392 gl_UNISTD_MODULE_INDICATOR([write])
393 # Code from module xalloc:
394 gl_XALLOC 459 gl_XALLOC
395 # Code from module xalloc-die:
396 # Code from module xsize:
397 gl_XSIZE 460 gl_XSIZE
398 # Code from module xstrndup:
399 gl_XSTRNDUP 461 gl_XSTRNDUP
400 # End of code from modules 462 # End of code from modules
401 m4_ifval(gl_LIBSOURCES_LIST, [ 463 m4_ifval(gl_LIBSOURCES_LIST, [
@@ -537,11 +599,11 @@ AC_DEFUN([gltests_LIBSOURCES], [
537# This macro records the list of files which have been installed by 599# This macro records the list of files which have been installed by
538# gnulib-tool and may be removed by future gnulib-tool invocations. 600# gnulib-tool and may be removed by future gnulib-tool invocations.
539AC_DEFUN([gl_FILE_LIST], [ 601AC_DEFUN([gl_FILE_LIST], [
540 build-aux/arg-nonnull.h
541 build-aux/c++defs.h
542 build-aux/config.rpath 602 build-aux/config.rpath
543 build-aux/warn-on-use.h 603 build-aux/snippet/_Noreturn.h
544 lib/alignof.h 604 build-aux/snippet/arg-nonnull.h
605 build-aux/snippet/c++defs.h
606 build-aux/snippet/warn-on-use.h
545 lib/alloca.in.h 607 lib/alloca.in.h
546 lib/arpa_inet.in.h 608 lib/arpa_inet.in.h
547 lib/asnprintf.c 609 lib/asnprintf.c
@@ -551,30 +613,20 @@ AC_DEFUN([gl_FILE_LIST], [
551 lib/basename-lgpl.c 613 lib/basename-lgpl.c
552 lib/basename.c 614 lib/basename.c
553 lib/btowc.c 615 lib/btowc.c
554 lib/c-strtod.c
555 lib/c-strtod.h
556 lib/cloexec.c
557 lib/cloexec.h
558 lib/close-hook.c
559 lib/close-hook.h
560 lib/config.charset 616 lib/config.charset
561 lib/creat-safer.c
562 lib/dirname-lgpl.c 617 lib/dirname-lgpl.c
563 lib/dirname.c 618 lib/dirname.c
564 lib/dirname.h 619 lib/dirname.h
565 lib/dup-safer.c 620 lib/dosname.h
566 lib/dup2.c
567 lib/errno.in.h 621 lib/errno.in.h
568 lib/error.c 622 lib/error.c
569 lib/error.h 623 lib/error.h
570 lib/exitfail.c 624 lib/exitfail.c
571 lib/exitfail.h 625 lib/exitfail.h
572 lib/fcntl--.h 626 lib/fd-hook.c
573 lib/fcntl-safer.h 627 lib/fd-hook.h
574 lib/fcntl.c
575 lib/fcntl.in.h
576 lib/fd-safer.c
577 lib/float+.h 628 lib/float+.h
629 lib/float.c
578 lib/float.in.h 630 lib/float.in.h
579 lib/floor.c 631 lib/floor.c
580 lib/floorf.c 632 lib/floorf.c
@@ -583,10 +635,8 @@ AC_DEFUN([gl_FILE_LIST], [
583 lib/full-read.c 635 lib/full-read.c
584 lib/full-read.h 636 lib/full-read.h
585 lib/full-write.c 637 lib/full-write.c
586 lib/full-write.h
587 lib/gai_strerror.c 638 lib/gai_strerror.c
588 lib/getaddrinfo.c 639 lib/getaddrinfo.c
589 lib/getdtablesize.c
590 lib/gethostname.c 640 lib/gethostname.c
591 lib/getloadavg.c 641 lib/getloadavg.c
592 lib/getopt.c 642 lib/getopt.c
@@ -594,35 +644,45 @@ AC_DEFUN([gl_FILE_LIST], [
594 lib/getopt1.c 644 lib/getopt1.c
595 lib/getopt_int.h 645 lib/getopt_int.h
596 lib/gettext.h 646 lib/gettext.h
647 lib/glthread/lock.c
648 lib/glthread/lock.h
649 lib/glthread/threadlib.c
597 lib/inet_ntop.c 650 lib/inet_ntop.c
598 lib/intprops.h 651 lib/intprops.h
652 lib/itold.c
599 lib/langinfo.in.h 653 lib/langinfo.in.h
600 lib/localcharset.c 654 lib/localcharset.c
601 lib/localcharset.h 655 lib/localcharset.h
602 lib/locale.in.h 656 lib/locale.in.h
657 lib/localeconv.c
603 lib/malloc.c 658 lib/malloc.c
604 lib/malloca.c 659 lib/malloca.c
605 lib/malloca.h 660 lib/malloca.h
606 lib/malloca.valgrind 661 lib/malloca.valgrind
662 lib/math.c
607 lib/math.in.h 663 lib/math.in.h
608 lib/mbrtowc.c 664 lib/mbrtowc.c
609 lib/mbsinit.c 665 lib/mbsinit.c
666 lib/mbtowc-impl.h
667 lib/mbtowc.c
610 lib/memchr.c 668 lib/memchr.c
611 lib/memchr.valgrind 669 lib/memchr.valgrind
612 lib/mktime-internal.h 670 lib/mktime-internal.h
613 lib/mktime.c 671 lib/mktime.c
614 lib/mountlist.c 672 lib/mountlist.c
615 lib/mountlist.h 673 lib/mountlist.h
674 lib/msvc-inval.c
675 lib/msvc-inval.h
676 lib/msvc-nothrow.c
677 lib/msvc-nothrow.h
616 lib/netdb.in.h 678 lib/netdb.in.h
617 lib/netinet_in.in.h 679 lib/netinet_in.in.h
618 lib/nl_langinfo.c 680 lib/nl_langinfo.c
619 lib/open-safer.c
620 lib/open.c
621 lib/pipe-safer.c
622 lib/printf-args.c 681 lib/printf-args.c
623 lib/printf-args.h 682 lib/printf-args.h
624 lib/printf-parse.c 683 lib/printf-parse.c
625 lib/printf-parse.h 684 lib/printf-parse.h
685 lib/read.c
626 lib/ref-add.sin 686 lib/ref-add.sin
627 lib/ref-del.sin 687 lib/ref-del.sin
628 lib/regcomp.c 688 lib/regcomp.c
@@ -633,8 +693,6 @@ AC_DEFUN([gl_FILE_LIST], [
633 lib/regexec.c 693 lib/regexec.c
634 lib/safe-read.c 694 lib/safe-read.c
635 lib/safe-read.h 695 lib/safe-read.h
636 lib/safe-write.c
637 lib/safe-write.h
638 lib/setenv.c 696 lib/setenv.c
639 lib/sha1.c 697 lib/sha1.c
640 lib/sha1.h 698 lib/sha1.h
@@ -642,16 +700,16 @@ AC_DEFUN([gl_FILE_LIST], [
642 lib/snprintf.c 700 lib/snprintf.c
643 lib/sockets.c 701 lib/sockets.c
644 lib/sockets.h 702 lib/sockets.h
645 lib/stat.c 703 lib/stdalign.in.h
646 lib/stdbool.in.h 704 lib/stdbool.in.h
647 lib/stddef.in.h 705 lib/stddef.in.h
648 lib/stdint.in.h 706 lib/stdint.in.h
649 lib/stdio-write.c
650 lib/stdio.in.h 707 lib/stdio.in.h
651 lib/stdlib.in.h 708 lib/stdlib.in.h
652 lib/str-two-way.h 709 lib/str-two-way.h
653 lib/strdup.c
654 lib/streq.h 710 lib/streq.h
711 lib/strerror-override.c
712 lib/strerror-override.h
655 lib/strerror.c 713 lib/strerror.c
656 lib/string.in.h 714 lib/string.in.h
657 lib/stripslash.c 715 lib/stripslash.c
@@ -659,13 +717,14 @@ AC_DEFUN([gl_FILE_LIST], [
659 lib/strnlen.c 717 lib/strnlen.c
660 lib/strsep.c 718 lib/strsep.c
661 lib/strstr.c 719 lib/strstr.c
720 lib/sys_socket.c
662 lib/sys_socket.in.h 721 lib/sys_socket.in.h
663 lib/sys_stat.in.h 722 lib/sys_types.in.h
723 lib/sys_uio.in.h
664 lib/time.in.h 724 lib/time.in.h
665 lib/time_r.c 725 lib/time_r.c
666 lib/timegm.c 726 lib/timegm.c
667 lib/unistd--.h 727 lib/unistd.c
668 lib/unistd-safer.h
669 lib/unistd.in.h 728 lib/unistd.in.h
670 lib/unsetenv.c 729 lib/unsetenv.c
671 lib/vasnprintf.c 730 lib/vasnprintf.c
@@ -676,42 +735,38 @@ AC_DEFUN([gl_FILE_LIST], [
676 lib/w32sock.h 735 lib/w32sock.h
677 lib/wchar.in.h 736 lib/wchar.in.h
678 lib/wcrtomb.c 737 lib/wcrtomb.c
738 lib/wctype-h.c
679 lib/wctype.in.h 739 lib/wctype.in.h
680 lib/write.c
681 lib/xalloc-die.c 740 lib/xalloc-die.c
741 lib/xalloc-oversized.h
682 lib/xalloc.h 742 lib/xalloc.h
683 lib/xmalloc.c 743 lib/xmalloc.c
744 lib/xsize.c
684 lib/xsize.h 745 lib/xsize.h
685 lib/xstrndup.c 746 lib/xstrndup.c
686 lib/xstrndup.h 747 lib/xstrndup.h
687 m4/00gnulib.m4 748 m4/00gnulib.m4
688 m4/alloca.m4 749 m4/alloca.m4
689 m4/arpa_inet_h.m4 750 m4/arpa_inet_h.m4
690 m4/asm-underscore.m4
691 m4/base64.m4 751 m4/base64.m4
692 m4/btowc.m4 752 m4/btowc.m4
693 m4/c-strtod.m4
694 m4/cloexec.m4
695 m4/codeset.m4 753 m4/codeset.m4
754 m4/configmake.m4
696 m4/dirname.m4 755 m4/dirname.m4
697 m4/dos.m4
698 m4/double-slash-root.m4 756 m4/double-slash-root.m4
699 m4/dup2.m4
700 m4/eealloc.m4 757 m4/eealloc.m4
701 m4/environ.m4 758 m4/environ.m4
702 m4/errno_h.m4 759 m4/errno_h.m4
703 m4/error.m4 760 m4/error.m4
761 m4/exponentd.m4
704 m4/extensions.m4 762 m4/extensions.m4
763 m4/extern-inline.m4
705 m4/fcntl-o.m4 764 m4/fcntl-o.m4
706 m4/fcntl-safer.m4
707 m4/fcntl.m4
708 m4/fcntl_h.m4
709 m4/float_h.m4 765 m4/float_h.m4
710 m4/floorf.m4 766 m4/floorf.m4
711 m4/fstypename.m4 767 m4/fstypename.m4
712 m4/fsusage.m4 768 m4/fsusage.m4
713 m4/getaddrinfo.m4 769 m4/getaddrinfo.m4
714 m4/getdtablesize.m4
715 m4/gethostname.m4 770 m4/gethostname.m4
716 m4/getloadavg.m4 771 m4/getloadavg.m4
717 m4/getopt.m4 772 m4/getopt.m4
@@ -723,7 +778,6 @@ AC_DEFUN([gl_FILE_LIST], [
723 m4/iconv.m4 778 m4/iconv.m4
724 m4/include_next.m4 779 m4/include_next.m4
725 m4/inet_ntop.m4 780 m4/inet_ntop.m4
726 m4/inline.m4
727 m4/intdiv0.m4 781 m4/intdiv0.m4
728 m4/intl.m4 782 m4/intl.m4
729 m4/intldir.m4 783 m4/intldir.m4
@@ -733,6 +787,7 @@ AC_DEFUN([gl_FILE_LIST], [
733 m4/inttypes-pri.m4 787 m4/inttypes-pri.m4
734 m4/inttypes_h.m4 788 m4/inttypes_h.m4
735 m4/langinfo_h.m4 789 m4/langinfo_h.m4
790 m4/largefile.m4
736 m4/lcmessage.m4 791 m4/lcmessage.m4
737 m4/lib-ld.m4 792 m4/lib-ld.m4
738 m4/lib-link.m4 793 m4/lib-link.m4
@@ -742,6 +797,7 @@ AC_DEFUN([gl_FILE_LIST], [
742 m4/locale-ja.m4 797 m4/locale-ja.m4
743 m4/locale-zh.m4 798 m4/locale-zh.m4
744 m4/locale_h.m4 799 m4/locale_h.m4
800 m4/localeconv.m4
745 m4/lock.m4 801 m4/lock.m4
746 m4/longlong.m4 802 m4/longlong.m4
747 m4/ls-mntd-fs.m4 803 m4/ls-mntd-fs.m4
@@ -751,42 +807,45 @@ AC_DEFUN([gl_FILE_LIST], [
751 m4/mbrtowc.m4 807 m4/mbrtowc.m4
752 m4/mbsinit.m4 808 m4/mbsinit.m4
753 m4/mbstate_t.m4 809 m4/mbstate_t.m4
810 m4/mbtowc.m4
754 m4/memchr.m4 811 m4/memchr.m4
755 m4/mktime.m4 812 m4/mktime.m4
756 m4/mmap-anon.m4 813 m4/mmap-anon.m4
757 m4/mode_t.m4
758 m4/mountlist.m4 814 m4/mountlist.m4
815 m4/msvc-inval.m4
816 m4/msvc-nothrow.m4
759 m4/multiarch.m4 817 m4/multiarch.m4
760 m4/netdb_h.m4 818 m4/netdb_h.m4
761 m4/netinet_in_h.m4 819 m4/netinet_in_h.m4
762 m4/nl_langinfo.m4 820 m4/nl_langinfo.m4
763 m4/nls.m4 821 m4/nls.m4
822 m4/nocrash.m4
823 m4/off_t.m4
764 m4/onceonly.m4 824 m4/onceonly.m4
765 m4/open.m4
766 m4/po.m4 825 m4/po.m4
767 m4/printf-posix.m4 826 m4/printf-posix.m4
768 m4/printf.m4 827 m4/printf.m4
769 m4/progtest.m4 828 m4/progtest.m4
829 m4/read.m4
770 m4/regex.m4 830 m4/regex.m4
771 m4/safe-read.m4 831 m4/safe-read.m4
772 m4/safe-write.m4
773 m4/servent.m4 832 m4/servent.m4
774 m4/setenv.m4 833 m4/setenv.m4
775 m4/sha1.m4 834 m4/sha1.m4
776 m4/size_max.m4 835 m4/size_max.m4
777 m4/snprintf.m4 836 m4/snprintf.m4
837 m4/socketlib.m4
778 m4/sockets.m4 838 m4/sockets.m4
779 m4/socklen.m4 839 m4/socklen.m4
780 m4/sockpfaf.m4 840 m4/sockpfaf.m4
781 m4/ssize_t.m4 841 m4/ssize_t.m4
782 m4/stat.m4 842 m4/stdalign.m4
783 m4/stdbool.m4 843 m4/stdbool.m4
784 m4/stddef_h.m4 844 m4/stddef_h.m4
785 m4/stdint.m4 845 m4/stdint.m4
786 m4/stdint_h.m4 846 m4/stdint_h.m4
787 m4/stdio_h.m4 847 m4/stdio_h.m4
788 m4/stdlib_h.m4 848 m4/stdlib_h.m4
789 m4/strdup.m4
790 m4/strerror.m4 849 m4/strerror.m4
791 m4/string_h.m4 850 m4/string_h.m4
792 m4/strndup.m4 851 m4/strndup.m4
@@ -794,13 +853,13 @@ AC_DEFUN([gl_FILE_LIST], [
794 m4/strsep.m4 853 m4/strsep.m4
795 m4/strstr.m4 854 m4/strstr.m4
796 m4/sys_socket_h.m4 855 m4/sys_socket_h.m4
797 m4/sys_stat_h.m4 856 m4/sys_types_h.m4
857 m4/sys_uio_h.m4
798 m4/threadlib.m4 858 m4/threadlib.m4
799 m4/time_h.m4 859 m4/time_h.m4
800 m4/time_r.m4 860 m4/time_r.m4
801 m4/timegm.m4 861 m4/timegm.m4
802 m4/uintmax_t.m4 862 m4/uintmax_t.m4
803 m4/unistd-safer.m4
804 m4/unistd_h.m4 863 m4/unistd_h.m4
805 m4/vasnprintf.m4 864 m4/vasnprintf.m4
806 m4/vasprintf.m4 865 m4/vasprintf.m4
@@ -812,7 +871,6 @@ AC_DEFUN([gl_FILE_LIST], [
812 m4/wcrtomb.m4 871 m4/wcrtomb.m4
813 m4/wctype_h.m4 872 m4/wctype_h.m4
814 m4/wint_t.m4 873 m4/wint_t.m4
815 m4/write.m4
816 m4/xalloc.m4 874 m4/xalloc.m4
817 m4/xsize.m4 875 m4/xsize.m4
818 m4/xstrndup.m4 876 m4/xstrndup.m4
diff --git a/gl/m4/gnulib-tool.m4 b/gl/m4/gnulib-tool.m4
index 69e7733..f3dea1a 100644
--- a/gl/m4/gnulib-tool.m4
+++ b/gl/m4/gnulib-tool.m4
@@ -1,5 +1,5 @@
1# gnulib-tool.m4 serial 2 1# gnulib-tool.m4 serial 2
2dnl Copyright (C) 2004-2005, 2009-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2004-2005, 2009-2013 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.
diff --git a/gl/m4/hostent.m4 b/gl/m4/hostent.m4
index 1111041..72be876 100644
--- a/gl/m4/hostent.m4
+++ b/gl/m4/hostent.m4
@@ -1,5 +1,5 @@
1# hostent.m4 serial 1 1# hostent.m4 serial 2
2dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2008, 2010-2013 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.
@@ -28,12 +28,16 @@ AC_DEFUN([gl_HOSTENT],
28 [gl_cv_w32_gethostbyname=no 28 [gl_cv_w32_gethostbyname=no
29 gl_save_LIBS="$LIBS" 29 gl_save_LIBS="$LIBS"
30 LIBS="$LIBS -lws2_32" 30 LIBS="$LIBS -lws2_32"
31 AC_TRY_LINK([ 31 AC_LINK_IFELSE(
32 [AC_LANG_PROGRAM(
33 [[
32#ifdef HAVE_WINSOCK2_H 34#ifdef HAVE_WINSOCK2_H
33#include <winsock2.h> 35#include <winsock2.h>
34#endif 36#endif
35#include <stddef.h> 37#include <stddef.h>
36], [gethostbyname(NULL);], [gl_cv_w32_gethostbyname=yes]) 38 ]],
39 [[gethostbyname(NULL);]])],
40 [gl_cv_w32_gethostbyname=yes])
37 LIBS="$gl_save_LIBS" 41 LIBS="$gl_save_LIBS"
38 ]) 42 ])
39 if test "$gl_cv_w32_gethostbyname" = "yes"; then 43 if test "$gl_cv_w32_gethostbyname" = "yes"; then
diff --git a/gl/m4/iconv.m4 b/gl/m4/iconv.m4
index e2041b9..a503646 100644
--- a/gl/m4/iconv.m4
+++ b/gl/m4/iconv.m4
@@ -1,5 +1,5 @@
1# iconv.m4 serial 11 (gettext-0.18.1) 1# iconv.m4 serial 18 (gettext-0.18.2)
2dnl Copyright (C) 2000-2002, 2007-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2000-2002, 2007-2013 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.
@@ -30,27 +30,35 @@ AC_DEFUN([AM_ICONV_LINK],
30 dnl Add $INCICONV to CPPFLAGS before performing the following checks, 30 dnl Add $INCICONV to CPPFLAGS before performing the following checks,
31 dnl because if the user has installed libiconv and not disabled its use 31 dnl because if the user has installed libiconv and not disabled its use
32 dnl via --without-libiconv-prefix, he wants to use it. The first 32 dnl via --without-libiconv-prefix, he wants to use it. The first
33 dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed. 33 dnl AC_LINK_IFELSE will then fail, the second AC_LINK_IFELSE will succeed.
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_LINK_IFELSE(
41#include <iconv.h>], 41 [AC_LANG_PROGRAM(
42 [iconv_t cd = iconv_open("",""); 42 [[
43 iconv(cd,NULL,NULL,NULL,NULL); 43#include <stdlib.h>
44 iconv_close(cd);], 44#include <iconv.h>
45 ]],
46 [[iconv_t cd = iconv_open("","");
47 iconv(cd,NULL,NULL,NULL,NULL);
48 iconv_close(cd);]])],
45 [am_cv_func_iconv=yes]) 49 [am_cv_func_iconv=yes])
46 if test "$am_cv_func_iconv" != yes; then 50 if test "$am_cv_func_iconv" != yes; then
47 am_save_LIBS="$LIBS" 51 am_save_LIBS="$LIBS"
48 LIBS="$LIBS $LIBICONV" 52 LIBS="$LIBS $LIBICONV"
49 AC_TRY_LINK([#include <stdlib.h> 53 AC_LINK_IFELSE(
50#include <iconv.h>], 54 [AC_LANG_PROGRAM(
51 [iconv_t cd = iconv_open("",""); 55 [[
52 iconv(cd,NULL,NULL,NULL,NULL); 56#include <stdlib.h>
53 iconv_close(cd);], 57#include <iconv.h>
58 ]],
59 [[iconv_t cd = iconv_open("","");
60 iconv(cd,NULL,NULL,NULL,NULL);
61 iconv_close(cd);]])],
54 [am_cv_lib_iconv=yes] 62 [am_cv_lib_iconv=yes]
55 [am_cv_func_iconv=yes]) 63 [am_cv_func_iconv=yes])
56 LIBS="$am_save_LIBS" 64 LIBS="$am_save_LIBS"
@@ -58,16 +66,19 @@ AC_DEFUN([AM_ICONV_LINK],
58 ]) 66 ])
59 if test "$am_cv_func_iconv" = yes; then 67 if test "$am_cv_func_iconv" = yes; then
60 AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [ 68 AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [
61 dnl This tests against bugs in AIX 5.1, HP-UX 11.11, Solaris 10. 69 dnl This tests against bugs in AIX 5.1, AIX 6.1..7.1, HP-UX 11.11,
70 dnl Solaris 10.
62 am_save_LIBS="$LIBS" 71 am_save_LIBS="$LIBS"
63 if test $am_cv_lib_iconv = yes; then 72 if test $am_cv_lib_iconv = yes; then
64 LIBS="$LIBS $LIBICONV" 73 LIBS="$LIBS $LIBICONV"
65 fi 74 fi
66 AC_TRY_RUN([ 75 AC_RUN_IFELSE(
76 [AC_LANG_SOURCE([[
67#include <iconv.h> 77#include <iconv.h>
68#include <string.h> 78#include <string.h>
69int main () 79int main ()
70{ 80{
81 int result = 0;
71 /* Test against AIX 5.1 bug: Failures are not distinguishable from successful 82 /* Test against AIX 5.1 bug: Failures are not distinguishable from successful
72 returns. */ 83 returns. */
73 { 84 {
@@ -84,7 +95,8 @@ int main ()
84 (char **) &inptr, &inbytesleft, 95 (char **) &inptr, &inbytesleft,
85 &outptr, &outbytesleft); 96 &outptr, &outbytesleft);
86 if (res == 0) 97 if (res == 0)
87 return 1; 98 result |= 1;
99 iconv_close (cd_utf8_to_88591);
88 } 100 }
89 } 101 }
90 /* Test against Solaris 10 bug: Failures are not distinguishable from 102 /* Test against Solaris 10 bug: Failures are not distinguishable from
@@ -103,7 +115,27 @@ int main ()
103 (char **) &inptr, &inbytesleft, 115 (char **) &inptr, &inbytesleft,
104 &outptr, &outbytesleft); 116 &outptr, &outbytesleft);
105 if (res == 0) 117 if (res == 0)
106 return 1; 118 result |= 2;
119 iconv_close (cd_ascii_to_88591);
120 }
121 }
122 /* Test against AIX 6.1..7.1 bug: Buffer overrun. */
123 {
124 iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1");
125 if (cd_88591_to_utf8 != (iconv_t)(-1))
126 {
127 static const char input[] = "\304";
128 static char buf[2] = { (char)0xDE, (char)0xAD };
129 const char *inptr = input;
130 size_t inbytesleft = 1;
131 char *outptr = buf;
132 size_t outbytesleft = 1;
133 size_t res = iconv (cd_88591_to_utf8,
134 (char **) &inptr, &inbytesleft,
135 &outptr, &outbytesleft);
136 if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD)
137 result |= 4;
138 iconv_close (cd_88591_to_utf8);
107 } 139 }
108 } 140 }
109#if 0 /* This bug could be worked around by the caller. */ 141#if 0 /* This bug could be worked around by the caller. */
@@ -122,7 +154,8 @@ int main ()
122 (char **) &inptr, &inbytesleft, 154 (char **) &inptr, &inbytesleft,
123 &outptr, &outbytesleft); 155 &outptr, &outbytesleft);
124 if ((int)res > 0) 156 if ((int)res > 0)
125 return 1; 157 result |= 8;
158 iconv_close (cd_88591_to_utf8);
126 } 159 }
127 } 160 }
128#endif 161#endif
@@ -136,13 +169,19 @@ int main ()
136 && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1) 169 && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1)
137 /* Try HP-UX names. */ 170 /* Try HP-UX names. */
138 && iconv_open ("utf8", "eucJP") == (iconv_t)(-1)) 171 && iconv_open ("utf8", "eucJP") == (iconv_t)(-1))
139 return 1; 172 result |= 16;
140 return 0; 173 return result;
141}], [am_cv_func_iconv_works=yes], [am_cv_func_iconv_works=no], 174}]])],
142 [case "$host_os" in 175 [am_cv_func_iconv_works=yes],
176 [am_cv_func_iconv_works=no],
177 [
178changequote(,)dnl
179 case "$host_os" in
143 aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; 180 aix* | hpux*) am_cv_func_iconv_works="guessing no" ;;
144 *) am_cv_func_iconv_works="guessing yes" ;; 181 *) am_cv_func_iconv_works="guessing yes" ;;
145 esac]) 182 esac
183changequote([,])dnl
184 ])
146 LIBS="$am_save_LIBS" 185 LIBS="$am_save_LIBS"
147 ]) 186 ])
148 case "$am_cv_func_iconv_works" in 187 case "$am_cv_func_iconv_works" in
@@ -183,32 +222,47 @@ m4_define([gl_iconv_AC_DEFUN],
183 m4_version_prereq([2.64], 222 m4_version_prereq([2.64],
184 [[AC_DEFUN_ONCE( 223 [[AC_DEFUN_ONCE(
185 [$1], [$2])]], 224 [$1], [$2])]],
186 [[AC_DEFUN( 225 [m4_ifdef([gl_00GNULIB],
187 [$1], [$2])]])) 226 [[AC_DEFUN_ONCE(
227 [$1], [$2])]],
228 [[AC_DEFUN(
229 [$1], [$2])]])]))
188gl_iconv_AC_DEFUN([AM_ICONV], 230gl_iconv_AC_DEFUN([AM_ICONV],
189[ 231[
190 AM_ICONV_LINK 232 AM_ICONV_LINK
191 if test "$am_cv_func_iconv" = yes; then 233 if test "$am_cv_func_iconv" = yes; then
192 AC_MSG_CHECKING([for iconv declaration]) 234 AC_MSG_CHECKING([for iconv declaration])
193 AC_CACHE_VAL([am_cv_proto_iconv], [ 235 AC_CACHE_VAL([am_cv_proto_iconv], [
194 AC_TRY_COMPILE([ 236 AC_COMPILE_IFELSE(
237 [AC_LANG_PROGRAM(
238 [[
195#include <stdlib.h> 239#include <stdlib.h>
196#include <iconv.h> 240#include <iconv.h>
197extern 241extern
198#ifdef __cplusplus 242#ifdef __cplusplus
199"C" 243"C"
200#endif 244#endif
201#if defined(__STDC__) || defined(__cplusplus) 245#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus)
202size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); 246size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
203#else 247#else
204size_t iconv(); 248size_t iconv();
205#endif 249#endif
206], [], [am_cv_proto_iconv_arg1=""], [am_cv_proto_iconv_arg1="const"]) 250 ]],
251 [[]])],
252 [am_cv_proto_iconv_arg1=""],
253 [am_cv_proto_iconv_arg1="const"])
207 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);"]) 254 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);"])
208 am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` 255 am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
209 AC_MSG_RESULT([ 256 AC_MSG_RESULT([
210 $am_cv_proto_iconv]) 257 $am_cv_proto_iconv])
211 AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1], 258 AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1],
212 [Define as const if the declaration of iconv() needs const.]) 259 [Define as const if the declaration of iconv() needs const.])
260 dnl Also substitute ICONV_CONST in the gnulib generated <iconv.h>.
261 m4_ifdef([gl_ICONV_H_DEFAULTS],
262 [AC_REQUIRE([gl_ICONV_H_DEFAULTS])
263 if test -n "$am_cv_proto_iconv_arg1"; then
264 ICONV_CONST="const"
265 fi
266 ])
213 fi 267 fi
214]) 268])
diff --git a/gl/m4/include_next.m4 b/gl/m4/include_next.m4
index c7e0672..108d945 100644
--- a/gl/m4/include_next.m4
+++ b/gl/m4/include_next.m4
@@ -1,5 +1,5 @@
1# include_next.m4 serial 14 1# include_next.m4 serial 23
2dnl Copyright (C) 2006-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2006-2013 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,6 +24,13 @@ dnl 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 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 25dnl effect; we are therefore careful to use 'defined __STDC__' or '1' instead
26dnl of plain '__STDC__'. 26dnl of plain '__STDC__'.
27dnl
28dnl PRAGMA_COLUMNS can be used in files that override system header files, so
29dnl as to avoid compilation errors on HP NonStop systems when the gnulib file
30dnl is included by a system header file that does a "#pragma COLUMNS 80" (which
31dnl has the effect of truncating the lines of that file and all files that it
32dnl includes to 80 columns) and the gnulib file has lines longer than 80
33dnl columns.
27 34
28AC_DEFUN([gl_INCLUDE_NEXT], 35AC_DEFUN([gl_INCLUDE_NEXT],
29[ 36[
@@ -68,10 +75,11 @@ EOF
68EOF 75EOF
69 gl_save_CPPFLAGS="$CPPFLAGS" 76 gl_save_CPPFLAGS="$CPPFLAGS"
70 CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1b -Iconftestd2" 77 CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1b -Iconftestd2"
71 AC_COMPILE_IFELSE([#include <conftest.h>], 78dnl We intentionally avoid using AC_LANG_SOURCE here.
79 AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[#include <conftest.h>]],
72 [gl_cv_have_include_next=yes], 80 [gl_cv_have_include_next=yes],
73 [CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1a -Iconftestd2" 81 [CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1a -Iconftestd2"
74 AC_COMPILE_IFELSE([#include <conftest.h>], 82 AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[#include <conftest.h>]],
75 [gl_cv_have_include_next=buggy], 83 [gl_cv_have_include_next=buggy],
76 [gl_cv_have_include_next=no]) 84 [gl_cv_have_include_next=no])
77 ]) 85 ])
@@ -97,6 +105,24 @@ EOF
97 AC_SUBST([INCLUDE_NEXT]) 105 AC_SUBST([INCLUDE_NEXT])
98 AC_SUBST([INCLUDE_NEXT_AS_FIRST_DIRECTIVE]) 106 AC_SUBST([INCLUDE_NEXT_AS_FIRST_DIRECTIVE])
99 AC_SUBST([PRAGMA_SYSTEM_HEADER]) 107 AC_SUBST([PRAGMA_SYSTEM_HEADER])
108 AC_CACHE_CHECK([whether system header files limit the line length],
109 [gl_cv_pragma_columns],
110 [dnl HP NonStop systems, which define __TANDEM, have this misfeature.
111 AC_EGREP_CPP([choke me],
112 [
113#ifdef __TANDEM
114choke me
115#endif
116 ],
117 [gl_cv_pragma_columns=yes],
118 [gl_cv_pragma_columns=no])
119 ])
120 if test $gl_cv_pragma_columns = yes; then
121 PRAGMA_COLUMNS="#pragma COLUMNS 10000"
122 else
123 PRAGMA_COLUMNS=
124 fi
125 AC_SUBST([PRAGMA_COLUMNS])
100]) 126])
101 127
102# gl_CHECK_NEXT_HEADERS(HEADER1 HEADER2 ...) 128# gl_CHECK_NEXT_HEADERS(HEADER1 HEADER2 ...)
@@ -117,71 +143,128 @@ EOF
117# even if the compiler does not support include_next. 143# even if the compiler does not support include_next.
118# The three "///" are to pacify Sun C 5.8, which otherwise would say 144# The three "///" are to pacify Sun C 5.8, which otherwise would say
119# "warning: #include of /usr/include/... may be non-portable". 145# "warning: #include of /usr/include/... may be non-portable".
120# Use `""', not `<>', so that the /// cannot be confused with a C99 comment. 146# Use '""', not '<>', so that the /// cannot be confused with a C99 comment.
121# Note: This macro assumes that the header file is not empty after 147# Note: This macro assumes that the header file is not empty after
122# preprocessing, i.e. it does not only define preprocessor macros but also 148# preprocessing, i.e. it does not only define preprocessor macros but also
123# provides some type/enum definitions or function/variable declarations. 149# provides some type/enum definitions or function/variable declarations.
150#
151# This macro also checks whether each header exists, by invoking
152# AC_CHECK_HEADERS_ONCE or AC_CHECK_HEADERS on each argument.
124AC_DEFUN([gl_CHECK_NEXT_HEADERS], 153AC_DEFUN([gl_CHECK_NEXT_HEADERS],
125[ 154[
155 gl_NEXT_HEADERS_INTERNAL([$1], [check])
156])
157
158# gl_NEXT_HEADERS(HEADER1 HEADER2 ...)
159# ------------------------------------
160# Like gl_CHECK_NEXT_HEADERS, except do not check whether the headers exist.
161# This is suitable for headers like <stddef.h> that are standardized by C89
162# and therefore can be assumed to exist.
163AC_DEFUN([gl_NEXT_HEADERS],
164[
165 gl_NEXT_HEADERS_INTERNAL([$1], [assume])
166])
167
168# The guts of gl_CHECK_NEXT_HEADERS and gl_NEXT_HEADERS.
169AC_DEFUN([gl_NEXT_HEADERS_INTERNAL],
170[
126 AC_REQUIRE([gl_INCLUDE_NEXT]) 171 AC_REQUIRE([gl_INCLUDE_NEXT])
127 AC_REQUIRE([AC_CANONICAL_HOST]) 172 AC_REQUIRE([AC_CANONICAL_HOST])
128 AC_CHECK_HEADERS_ONCE([$1])
129 173
174 m4_if([$2], [check],
175 [AC_CHECK_HEADERS_ONCE([$1])
176 ])
177
178dnl FIXME: gl_next_header and gl_header_exists must be used unquoted
179dnl until we can assume autoconf 2.64 or newer.
130 m4_foreach_w([gl_HEADER_NAME], [$1], 180 m4_foreach_w([gl_HEADER_NAME], [$1],
131 [AS_VAR_PUSHDEF([gl_next_header], 181 [AS_VAR_PUSHDEF([gl_next_header],
132 [gl_cv_next_]m4_defn([gl_HEADER_NAME])) 182 [gl_cv_next_]m4_defn([gl_HEADER_NAME]))
133 if test $gl_cv_have_include_next = yes; then 183 if test $gl_cv_have_include_next = yes; then
134 AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>']) 184 AS_VAR_SET(gl_next_header, ['<'gl_HEADER_NAME'>'])
135 else 185 else
136 AC_CACHE_CHECK( 186 AC_CACHE_CHECK(
137 [absolute name of <]m4_defn([gl_HEADER_NAME])[>], 187 [absolute name of <]m4_defn([gl_HEADER_NAME])[>],
138 m4_defn([gl_next_header]), 188 m4_defn([gl_next_header]),
139 [AS_VAR_PUSHDEF([gl_header_exists], 189 [m4_if([$2], [check],
140 [ac_cv_header_]m4_defn([gl_HEADER_NAME])) 190 [AS_VAR_PUSHDEF([gl_header_exists],
141 if test AS_VAR_GET(gl_header_exists) = yes; then 191 [ac_cv_header_]m4_defn([gl_HEADER_NAME]))
142 AC_LANG_CONFTEST( 192 if test AS_VAR_GET(gl_header_exists) = yes; then
143 [AC_LANG_SOURCE( 193 AS_VAR_POPDEF([gl_header_exists])
144 [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]] 194 ])
145 )]) 195 AC_LANG_CONFTEST(
146 dnl AIX "xlc -E" and "cc -E" omit #line directives for header files 196 [AC_LANG_SOURCE(
147 dnl that contain only a #include of other header files and no 197 [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]]
148 dnl non-comment tokens of their own. This leads to a failure to 198 )])
149 dnl detect the absolute name of <dirent.h>, <signal.h>, <poll.h> 199 dnl AIX "xlc -E" and "cc -E" omit #line directives for header
150 dnl and others. The workaround is to force preservation of comments 200 dnl files that contain only a #include of other header files and
151 dnl through option -C. This ensures all necessary #line directives 201 dnl no non-comment tokens of their own. This leads to a failure
152 dnl are present. GCC supports option -C as well. 202 dnl to detect the absolute name of <dirent.h>, <signal.h>,
153 case "$host_os" in 203 dnl <poll.h> and others. The workaround is to force preservation
154 aix*) gl_absname_cpp="$ac_cpp -C" ;; 204 dnl of comments through option -C. This ensures all necessary
155 *) gl_absname_cpp="$ac_cpp" ;; 205 dnl #line directives are present. GCC supports option -C as well.
156 esac 206 case "$host_os" in
157 dnl eval is necessary to expand gl_absname_cpp. 207 aix*) gl_absname_cpp="$ac_cpp -C" ;;
158 dnl Ultrix and Pyramid sh refuse to redirect output of eval, 208 *) gl_absname_cpp="$ac_cpp" ;;
159 dnl so use subshell. 209 esac
160 AS_VAR_SET([gl_next_header], 210changequote(,)
161 ['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD | 211 case "$host_os" in
162 sed -n '\#/]m4_defn([gl_HEADER_NAME])[#{ 212 mingw*)
163 s#.*"\(.*/]m4_defn([gl_HEADER_NAME])[\)".*#\1# 213 dnl For the sake of native Windows compilers (excluding gcc),
164 s#^/[^/]#//&# 214 dnl treat backslash as a directory separator, like /.
165 p 215 dnl Actually, these compilers use a double-backslash as
166 q 216 dnl directory separator, inside the
167 }'`'"']) 217 dnl # line "filename"
168 else 218 dnl directives.
169 AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>']) 219 gl_dirsep_regex='[/\\]'
170 fi 220 ;;
171 AS_VAR_POPDEF([gl_header_exists])]) 221 *)
222 gl_dirsep_regex='\/'
223 ;;
224 esac
225 dnl A sed expression that turns a string into a basic regular
226 dnl expression, for use within "/.../".
227 gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g'
228changequote([,])
229 gl_header_literal_regex=`echo ']m4_defn([gl_HEADER_NAME])[' \
230 | sed -e "$gl_make_literal_regex_sed"`
231 gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{
232 s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/
233changequote(,)dnl
234 s|^/[^/]|//&|
235changequote([,])dnl
236 p
237 q
238 }'
239 dnl eval is necessary to expand gl_absname_cpp.
240 dnl Ultrix and Pyramid sh refuse to redirect output of eval,
241 dnl so use subshell.
242 AS_VAR_SET(gl_next_header,
243 ['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
244 sed -n "$gl_absolute_header_sed"`'"'])
245 m4_if([$2], [check],
246 [else
247 AS_VAR_SET(gl_next_header, ['<'gl_HEADER_NAME'>'])
248 fi
249 ])
250 ])
172 fi 251 fi
173 AC_SUBST( 252 AC_SUBST(
174 AS_TR_CPP([NEXT_]m4_defn([gl_HEADER_NAME])), 253 AS_TR_CPP([NEXT_]m4_defn([gl_HEADER_NAME])),
175 [AS_VAR_GET([gl_next_header])]) 254 [AS_VAR_GET(gl_next_header)])
176 if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then 255 if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
177 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next' 256 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
178 gl_next_as_first_directive='<'gl_HEADER_NAME'>' 257 gl_next_as_first_directive='<'gl_HEADER_NAME'>'
179 else 258 else
180 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include' 259 # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
181 gl_next_as_first_directive=AS_VAR_GET([gl_next_header]) 260 gl_next_as_first_directive=AS_VAR_GET(gl_next_header)
182 fi 261 fi
183 AC_SUBST( 262 AC_SUBST(
184 AS_TR_CPP([NEXT_AS_FIRST_DIRECTIVE_]m4_defn([gl_HEADER_NAME])), 263 AS_TR_CPP([NEXT_AS_FIRST_DIRECTIVE_]m4_defn([gl_HEADER_NAME])),
185 [$gl_next_as_first_directive]) 264 [$gl_next_as_first_directive])
186 AS_VAR_POPDEF([gl_next_header])]) 265 AS_VAR_POPDEF([gl_next_header])])
187]) 266])
267
268# Autoconf 2.68 added warnings for our use of AC_COMPILE_IFELSE;
269# this fallback is safe for all earlier autoconf versions.
270m4_define_default([AC_LANG_DEFINES_PROVIDED])
diff --git a/gl/m4/inet_ntop.m4 b/gl/m4/inet_ntop.m4
index a6d219c..476f063 100644
--- a/gl/m4/inet_ntop.m4
+++ b/gl/m4/inet_ntop.m4
@@ -1,38 +1,68 @@
1# inet_ntop.m4 serial 12 1# inet_ntop.m4 serial 19
2dnl Copyright (C) 2005, 2006, 2008, 2009, 2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2005-2006, 2008-2013 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_INET_NTOP], 7AC_DEFUN([gl_FUNC_INET_NTOP],
8[ 8[
9 AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS])
10
9 dnl Persuade Solaris <arpa/inet.h> to declare inet_ntop. 11 dnl Persuade Solaris <arpa/inet.h> to declare inet_ntop.
10 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) 12 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
11 13
12 gl_REPLACE_ARPA_INET_H 14 AC_REQUIRE([AC_C_RESTRICT])
13 15
14 dnl Most platforms that provide inet_ntop define it in libc. 16 dnl Most platforms that provide inet_ntop define it in libc.
15 dnl Solaris 8..10 provide inet_ntop in libnsl instead. 17 dnl Solaris 8..10 provide inet_ntop in libnsl instead.
16 gl_save_LIBS=$LIBS 18 dnl Solaris 2.6..7 provide inet_ntop in libresolv instead.
17 AC_SEARCH_LIBS([inet_ntop], [nsl], [], 19 dnl Native Windows provides it in -lws2_32 instead, with a declaration in
18 [AC_REPLACE_FUNCS([inet_ntop])]) 20 dnl <ws2tcpip.h>, and it uses stdcall calling convention, not cdecl
19 LIBS=$gl_save_LIBS 21 dnl (hence we cannot use AC_CHECK_FUNCS, AC_SEARCH_LIBS to find it).
22 HAVE_INET_NTOP=1
20 INET_NTOP_LIB= 23 INET_NTOP_LIB=
21 if test "$ac_cv_search_inet_ntop" != "no" && 24 gl_PREREQ_SYS_H_WINSOCK2
22 test "$ac_cv_search_inet_ntop" != "none required"; then 25 if test $HAVE_WINSOCK2_H = 1; then
23 INET_NTOP_LIB="$ac_cv_search_inet_ntop" 26 AC_CHECK_DECLS([inet_ntop],,, [[#include <ws2tcpip.h>]])
27 if test $ac_cv_have_decl_inet_ntop = yes; then
28 dnl It needs to be overridden, because the stdcall calling convention
29 dnl is not compliant with POSIX.
30 REPLACE_INET_NTOP=1
31 INET_NTOP_LIB="-lws2_32"
32 else
33 HAVE_DECL_INET_NTOP=0
34 HAVE_INET_NTOP=0
35 fi
36 else
37 gl_save_LIBS=$LIBS
38 AC_SEARCH_LIBS([inet_ntop], [nsl resolv], [],
39 [AC_CHECK_FUNCS([inet_ntop])
40 if test $ac_cv_func_inet_ntop = no; then
41 HAVE_INET_NTOP=0
42 fi
43 ])
44 LIBS=$gl_save_LIBS
45
46 if test "$ac_cv_search_inet_ntop" != "no" \
47 && test "$ac_cv_search_inet_ntop" != "none required"; then
48 INET_NTOP_LIB="$ac_cv_search_inet_ntop"
49 fi
50
51 AC_CHECK_HEADERS_ONCE([netdb.h])
52 AC_CHECK_DECLS([inet_ntop],,,
53 [[#include <arpa/inet.h>
54 #if HAVE_NETDB_H
55 # include <netdb.h>
56 #endif
57 ]])
58 if test $ac_cv_have_decl_inet_ntop = no; then
59 HAVE_DECL_INET_NTOP=0
60 fi
24 fi 61 fi
25 AC_SUBST([INET_NTOP_LIB]) 62 AC_SUBST([INET_NTOP_LIB])
26
27 gl_PREREQ_INET_NTOP
28]) 63])
29 64
30# Prerequisites of lib/inet_ntop.c. 65# Prerequisites of lib/inet_ntop.c.
31AC_DEFUN([gl_PREREQ_INET_NTOP], [ 66AC_DEFUN([gl_PREREQ_INET_NTOP], [
32 AC_CHECK_DECLS([inet_ntop],,,[#include <arpa/inet.h>])
33 if test $ac_cv_have_decl_inet_ntop = no; then
34 HAVE_DECL_INET_NTOP=0
35 fi
36 AC_REQUIRE([gl_SOCKET_FAMILIES]) 67 AC_REQUIRE([gl_SOCKET_FAMILIES])
37 AC_REQUIRE([AC_C_RESTRICT])
38]) 68])
diff --git a/gl/m4/inline.m4 b/gl/m4/inline.m4
deleted file mode 100644
index 4ef768d..0000000
--- a/gl/m4/inline.m4
+++ /dev/null
@@ -1,40 +0,0 @@
1# inline.m4 serial 4
2dnl Copyright (C) 2006, 2009, 2010 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl Test for the 'inline' keyword or equivalent.
8dnl Define 'inline' to a supported equivalent, or to nothing if not supported,
9dnl like AC_C_INLINE does. Also, define HAVE_INLINE if 'inline' or an
10dnl equivalent is effectively supported, i.e. if the compiler is likely to
11dnl drop unused 'static inline' functions.
12AC_DEFUN([gl_INLINE],
13[
14 AC_REQUIRE([AC_C_INLINE])
15 AC_CACHE_CHECK([whether the compiler generally respects inline],
16 [gl_cv_c_inline_effective],
17 [if test $ac_cv_c_inline = no; then
18 gl_cv_c_inline_effective=no
19 else
20 dnl GCC defines __NO_INLINE__ if not optimizing or if -fno-inline is
21 dnl specified.
22 dnl Use AC_COMPILE_IFELSE here, not AC_EGREP_CPP, because the result
23 dnl depends on optimization flags, which can be in CFLAGS.
24 dnl (AC_EGREP_CPP looks only at the CPPFLAGS.)
25 AC_COMPILE_IFELSE(
26 [AC_LANG_PROGRAM([[]],
27 [[#ifdef __NO_INLINE__
28 #error "inline is not effective"
29 #endif]])],
30 [gl_cv_c_inline_effective=yes],
31 [gl_cv_c_inline_effective=no])
32 fi
33 ])
34 if test $gl_cv_c_inline_effective = yes; then
35 AC_DEFINE([HAVE_INLINE], [1],
36 [Define to 1 if the compiler supports one of the keywords
37 'inline', '__inline__', '__inline' and effectively inlines
38 functions marked as such.])
39 fi
40])
diff --git a/gl/m4/intdiv0.m4 b/gl/m4/intdiv0.m4
index 289c4df..74d0e80 100644
--- a/gl/m4/intdiv0.m4
+++ b/gl/m4/intdiv0.m4
@@ -1,5 +1,5 @@
1# intdiv0.m4 serial 3 (gettext-0.18) 1# intdiv0.m4 serial 6 (gettext-0.18.2)
2dnl Copyright (C) 2002, 2007-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2002, 2007-2008, 2010-2013 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.
@@ -18,7 +18,7 @@ AC_DEFUN([gt_INTDIV0],
18changequote(,)dnl 18changequote(,)dnl
19 case "$host_os" in 19 case "$host_os" in
20 macos* | darwin[6-9]* | darwin[1-9][0-9]*) 20 macos* | darwin[6-9]* | darwin[1-9][0-9]*)
21 # On MacOS X 10.2 or newer, just assume the same as when cross- 21 # On Mac OS X 10.2 or newer, just assume the same as when cross-
22 # compiling. If we were to perform the real test, 1 Crash Report 22 # compiling. If we were to perform the real test, 1 Crash Report
23 # dialog window would pop up. 23 # dialog window would pop up.
24 case "$host_cpu" in 24 case "$host_cpu" in
@@ -29,7 +29,8 @@ changequote(,)dnl
29 esac 29 esac
30changequote([,])dnl 30changequote([,])dnl
31 if test -z "$gt_cv_int_divbyzero_sigfpe"; then 31 if test -z "$gt_cv_int_divbyzero_sigfpe"; then
32 AC_TRY_RUN([ 32 AC_RUN_IFELSE(
33 [AC_LANG_SOURCE([[
33#include <stdlib.h> 34#include <stdlib.h>
34#include <signal.h> 35#include <signal.h>
35 36
@@ -59,9 +60,11 @@ int main ()
59 60
60 z = x / y; 61 z = x / y;
61 nan = y / y; 62 nan = y / y;
62 exit (1); 63 exit (2);
63} 64}
64], [gt_cv_int_divbyzero_sigfpe=yes], [gt_cv_int_divbyzero_sigfpe=no], 65]])],
66 [gt_cv_int_divbyzero_sigfpe=yes],
67 [gt_cv_int_divbyzero_sigfpe=no],
65 [ 68 [
66 # Guess based on the CPU. 69 # Guess based on the CPU.
67changequote(,)dnl 70changequote(,)dnl
diff --git a/gl/m4/intl.m4 b/gl/m4/intl.m4
index 335b23c..959bd04 100644
--- a/gl/m4/intl.m4
+++ b/gl/m4/intl.m4
@@ -1,5 +1,5 @@
1# intl.m4 serial 17 (gettext-0.18) 1# intl.m4 serial 23 (gettext-0.18.3)
2dnl Copyright (C) 1995-2009 Free Software Foundation, Inc. 2dnl Copyright (C) 1995-2013 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-2009. 18dnl Bruno Haible <haible@clisp.cons.org>, 2000-2009.
19 19
20AC_PREREQ([2.52]) 20AC_PREREQ([2.60])
21 21
22dnl Checks for all prerequisites of the intl subdirectory, 22dnl Checks for all prerequisites of the intl subdirectory,
23dnl except for INTL_LIBTOOL_SUFFIX_PREFIX (and possibly LIBTOOL), INTLOBJS, 23dnl except for INTL_LIBTOOL_SUFFIX_PREFIX (and possibly LIBTOOL), INTLOBJS,
@@ -25,7 +25,7 @@ dnl USE_INCLUDED_LIBINTL, BUILD_INCLUDED_LIBINTL.
25AC_DEFUN([AM_INTL_SUBDIR], 25AC_DEFUN([AM_INTL_SUBDIR],
26[ 26[
27 AC_REQUIRE([AC_PROG_INSTALL])dnl 27 AC_REQUIRE([AC_PROG_INSTALL])dnl
28 AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake 28 AC_REQUIRE([AC_PROG_MKDIR_P])dnl
29 AC_REQUIRE([AC_PROG_CC])dnl 29 AC_REQUIRE([AC_PROG_CC])dnl
30 AC_REQUIRE([AC_CANONICAL_HOST])dnl 30 AC_REQUIRE([AC_CANONICAL_HOST])dnl
31 AC_REQUIRE([gt_GLIBC2])dnl 31 AC_REQUIRE([gt_GLIBC2])dnl
@@ -55,21 +55,19 @@ AC_DEFUN([AM_INTL_SUBDIR],
55 [AC_DEFINE([ptrdiff_t], [long], 55 [AC_DEFINE([ptrdiff_t], [long],
56 [Define as the type of the result of subtracting two pointers, if the system doesn't define it.]) 56 [Define as the type of the result of subtracting two pointers, if the system doesn't define it.])
57 ]) 57 ])
58 AC_CHECK_HEADERS([stddef.h stdlib.h string.h]) 58 AC_CHECK_HEADERS([features.h stddef.h stdlib.h string.h])
59 AC_CHECK_FUNCS([asprintf fwprintf newlocale putenv setenv setlocale \ 59 AC_CHECK_FUNCS([asprintf fwprintf newlocale putenv setenv setlocale \
60 snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb]) 60 snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb])
61 61
62 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
63 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).
64 gt_CHECK_DECL(_snprintf, [#include <stdio.h>]) 64 AC_CHECK_DECLS([_snprintf _snwprintf], , , [#include <stdio.h>])
65 gt_CHECK_DECL(_snwprintf, [#include <stdio.h>])
66 65
67 dnl Use the *_unlocked functions only if they are declared. 66 dnl Use the *_unlocked functions only if they are declared.
68 dnl (because some of them were defined without being declared in Solaris 67 dnl (because some of them were defined without being declared in Solaris
69 dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built 68 dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built
70 dnl on Solaris 2.5.1 to run on Solaris 2.6). 69 dnl on Solaris 2.5.1 to run on Solaris 2.6).
71 dnl Don't use AC_CHECK_DECLS because it isn't supported in autoconf-2.13. 70 AC_CHECK_DECLS([getc_unlocked], , , [#include <stdio.h>])
72 gt_CHECK_DECL(getc_unlocked, [#include <stdio.h>])
73 71
74 case $gt_cv_func_printf_posix in 72 case $gt_cv_func_printf_posix in
75 *yes) HAVE_POSIX_PRINTF=1 ;; 73 *yes) HAVE_POSIX_PRINTF=1 ;;
@@ -220,9 +218,10 @@ AC_DEFUN([gt_INTL_SUBDIR_CORE],
220 AC_REQUIRE([gt_INTTYPES_PRI])dnl 218 AC_REQUIRE([gt_INTTYPES_PRI])dnl
221 AC_REQUIRE([gl_LOCK])dnl 219 AC_REQUIRE([gl_LOCK])dnl
222 220
223 AC_TRY_LINK( 221 AC_LINK_IFELSE(
224 [int foo (int a) { a = __builtin_expect (a, 10); return a == 10 ? 0 : 1; }], 222 [AC_LANG_PROGRAM(
225 [], 223 [[int foo (int a) { a = __builtin_expect (a, 10); return a == 10 ? 0 : 1; }]],
224 [[]])],
226 [AC_DEFINE([HAVE_BUILTIN_EXPECT], [1], 225 [AC_DEFINE([HAVE_BUILTIN_EXPECT], [1],
227 [Define to 1 if the compiler understands __builtin_expect.])]) 226 [Define to 1 if the compiler understands __builtin_expect.])])
228 227
@@ -235,9 +234,7 @@ AC_DEFUN([gt_INTL_SUBDIR_CORE],
235 dnl (because some of them were defined without being declared in Solaris 234 dnl (because some of them were defined without being declared in Solaris
236 dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built 235 dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built
237 dnl on Solaris 2.5.1 to run on Solaris 2.6). 236 dnl on Solaris 2.5.1 to run on Solaris 2.6).
238 dnl Don't use AC_CHECK_DECLS because it isn't supported in autoconf-2.13. 237 AC_CHECK_DECLS([feof_unlocked fgets_unlocked], , , [#include <stdio.h>])
239 gt_CHECK_DECL([feof_unlocked], [#include <stdio.h>])
240 gt_CHECK_DECL([fgets_unlocked], [#include <stdio.h>])
241 238
242 AM_ICONV 239 AM_ICONV
243 240
@@ -272,23 +269,3 @@ changequote([,])dnl
272 INTLBISON=: 269 INTLBISON=:
273 fi 270 fi
274]) 271])
275
276
277dnl gt_CHECK_DECL(FUNC, INCLUDES)
278dnl Check whether a function is declared.
279AC_DEFUN([gt_CHECK_DECL],
280[
281 AC_CACHE_CHECK([whether $1 is declared], [ac_cv_have_decl_$1],
282 [AC_TRY_COMPILE([$2], [
283#ifndef $1
284 char *p = (char *) $1;
285#endif
286], ac_cv_have_decl_$1=yes, ac_cv_have_decl_$1=no)])
287 if test $ac_cv_have_decl_$1 = yes; then
288 gt_value=1
289 else
290 gt_value=0
291 fi
292 AC_DEFINE_UNQUOTED([HAVE_DECL_]translit($1, [a-z], [A-Z]), [$gt_value],
293 [Define to 1 if you have the declaration of `$1', and to 0 if you don't.])
294])
diff --git a/gl/m4/intldir.m4 b/gl/m4/intldir.m4
index ebae76d..388ecd6 100644
--- a/gl/m4/intldir.m4
+++ b/gl/m4/intldir.m4
@@ -1,5 +1,5 @@
1# intldir.m4 serial 2 (gettext-0.18) 1# intldir.m4 serial 2 (gettext-0.18)
2dnl Copyright (C) 2006, 2009-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2006, 2009-2013 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.
diff --git a/gl/m4/intlmacosx.m4 b/gl/m4/intlmacosx.m4
index dd91025..ab97d39 100644
--- a/gl/m4/intlmacosx.m4
+++ b/gl/m4/intlmacosx.m4
@@ -1,5 +1,5 @@
1# intlmacosx.m4 serial 3 (gettext-0.18) 1# intlmacosx.m4 serial 5 (gettext-0.18.2)
2dnl Copyright (C) 2004-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2004-2013 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,35 +13,40 @@ 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
16dnl Checks for special options needed on MacOS X. 16dnl Checks for special options needed on Mac OS X.
17dnl Defines INTL_MACOSX_LIBS. 17dnl Defines INTL_MACOSX_LIBS.
18AC_DEFUN([gt_INTL_MACOSX], 18AC_DEFUN([gt_INTL_MACOSX],
19[ 19[
20 dnl Check for API introduced in MacOS X 10.2. 20 dnl Check for API introduced in Mac OS 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_LINK_IFELSE(
26 [CFPreferencesCopyAppValue(NULL, NULL)], 26 [AC_LANG_PROGRAM(
27 [[#include <CoreFoundation/CFPreferences.h>]],
28 [[CFPreferencesCopyAppValue(NULL, NULL)]])],
27 [gt_cv_func_CFPreferencesCopyAppValue=yes], 29 [gt_cv_func_CFPreferencesCopyAppValue=yes],
28 [gt_cv_func_CFPreferencesCopyAppValue=no]) 30 [gt_cv_func_CFPreferencesCopyAppValue=no])
29 LIBS="$gt_save_LIBS"]) 31 LIBS="$gt_save_LIBS"])
30 if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then 32 if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then
31 AC_DEFINE([HAVE_CFPREFERENCESCOPYAPPVALUE], [1], 33 AC_DEFINE([HAVE_CFPREFERENCESCOPYAPPVALUE], [1],
32 [Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in the CoreFoundation framework.]) 34 [Define to 1 if you have the Mac OS X function CFPreferencesCopyAppValue in the CoreFoundation framework.])
33 fi 35 fi
34 dnl Check for API introduced in MacOS X 10.3. 36 dnl Check for API introduced in Mac OS X 10.3.
35 AC_CACHE_CHECK([for CFLocaleCopyCurrent], [gt_cv_func_CFLocaleCopyCurrent], 37 AC_CACHE_CHECK([for CFLocaleCopyCurrent], [gt_cv_func_CFLocaleCopyCurrent],
36 [gt_save_LIBS="$LIBS" 38 [gt_save_LIBS="$LIBS"
37 LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" 39 LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation"
38 AC_TRY_LINK([#include <CoreFoundation/CFLocale.h>], [CFLocaleCopyCurrent();], 40 AC_LINK_IFELSE(
41 [AC_LANG_PROGRAM(
42 [[#include <CoreFoundation/CFLocale.h>]],
43 [[CFLocaleCopyCurrent();]])],
39 [gt_cv_func_CFLocaleCopyCurrent=yes], 44 [gt_cv_func_CFLocaleCopyCurrent=yes],
40 [gt_cv_func_CFLocaleCopyCurrent=no]) 45 [gt_cv_func_CFLocaleCopyCurrent=no])
41 LIBS="$gt_save_LIBS"]) 46 LIBS="$gt_save_LIBS"])
42 if test $gt_cv_func_CFLocaleCopyCurrent = yes; then 47 if test $gt_cv_func_CFLocaleCopyCurrent = yes; then
43 AC_DEFINE([HAVE_CFLOCALECOPYCURRENT], [1], 48 AC_DEFINE([HAVE_CFLOCALECOPYCURRENT], [1],
44 [Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the CoreFoundation framework.]) 49 [Define to 1 if you have the Mac OS X function CFLocaleCopyCurrent in the CoreFoundation framework.])
45 fi 50 fi
46 INTL_MACOSX_LIBS= 51 INTL_MACOSX_LIBS=
47 if test $gt_cv_func_CFPreferencesCopyAppValue = yes || test $gt_cv_func_CFLocaleCopyCurrent = yes; then 52 if test $gt_cv_func_CFPreferencesCopyAppValue = yes || test $gt_cv_func_CFLocaleCopyCurrent = yes; then
diff --git a/gl/m4/intmax.m4 b/gl/m4/intmax.m4
index 74aaaf5..18733a5 100644
--- a/gl/m4/intmax.m4
+++ b/gl/m4/intmax.m4
@@ -1,5 +1,5 @@
1# intmax.m4 serial 5 (gettext-0.18) 1# intmax.m4 serial 6 (gettext-0.18.2)
2dnl Copyright (C) 2002-2005, 2008-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2005, 2008-2013 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,9 @@ AC_DEFUN([gt_TYPE_INTMAX_T],
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_COMPILE_IFELSE(
17 [AC_LANG_PROGRAM(
18 [[
17#include <stddef.h> 19#include <stddef.h>
18#include <stdlib.h> 20#include <stdlib.h>
19#if HAVE_STDINT_H_WITH_UINTMAX 21#if HAVE_STDINT_H_WITH_UINTMAX
@@ -22,8 +24,9 @@ AC_DEFUN([gt_TYPE_INTMAX_T],
22#if HAVE_INTTYPES_H_WITH_UINTMAX 24#if HAVE_INTTYPES_H_WITH_UINTMAX
23#include <inttypes.h> 25#include <inttypes.h>
24#endif 26#endif
25], [intmax_t x = -1; 27 ]],
26 return !x;], 28 [[intmax_t x = -1;
29 return !x;]])],
27 [gt_cv_c_intmax_t=yes], 30 [gt_cv_c_intmax_t=yes],
28 [gt_cv_c_intmax_t=no])]) 31 [gt_cv_c_intmax_t=no])])
29 if test $gt_cv_c_intmax_t = yes; then 32 if test $gt_cv_c_intmax_t = yes; then
diff --git a/gl/m4/intmax_t.m4 b/gl/m4/intmax_t.m4
index 975caac..6ea7053 100644
--- a/gl/m4/intmax_t.m4
+++ b/gl/m4/intmax_t.m4
@@ -1,5 +1,5 @@
1# intmax_t.m4 serial 7 1# intmax_t.m4 serial 8
2dnl Copyright (C) 1997-2004, 2006-2007, 2009-2010 Free Software Foundation, 2dnl Copyright (C) 1997-2004, 2006-2007, 2009-2013 Free Software Foundation,
3dnl Inc. 3dnl Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
@@ -7,7 +7,7 @@ dnl with or without modifications, as long as this notice is preserved.
7 7
8dnl From Paul Eggert. 8dnl From Paul Eggert.
9 9
10AC_PREREQ([2.13]) 10AC_PREREQ([2.53])
11 11
12# Define intmax_t to 'long' or 'long long' 12# Define intmax_t to 'long' or 'long long'
13# if it is not already defined in <stdint.h> or <inttypes.h>. 13# if it is not already defined in <stdint.h> or <inttypes.h>.
@@ -38,7 +38,9 @@ AC_DEFUN([gt_AC_TYPE_INTMAX_T],
38 AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) 38 AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
39 AC_REQUIRE([gl_AC_HEADER_STDINT_H]) 39 AC_REQUIRE([gl_AC_HEADER_STDINT_H])
40 AC_CACHE_CHECK([for intmax_t], [gt_cv_c_intmax_t], 40 AC_CACHE_CHECK([for intmax_t], [gt_cv_c_intmax_t],
41 [AC_TRY_COMPILE([ 41 [AC_COMPILE_IFELSE(
42 [AC_LANG_PROGRAM(
43 [[
42#include <stddef.h> 44#include <stddef.h>
43#include <stdlib.h> 45#include <stdlib.h>
44#if HAVE_STDINT_H_WITH_UINTMAX 46#if HAVE_STDINT_H_WITH_UINTMAX
@@ -47,7 +49,10 @@ AC_DEFUN([gt_AC_TYPE_INTMAX_T],
47#if HAVE_INTTYPES_H_WITH_UINTMAX 49#if HAVE_INTTYPES_H_WITH_UINTMAX
48#include <inttypes.h> 50#include <inttypes.h>
49#endif 51#endif
50], [intmax_t x = -1; return !x;], gt_cv_c_intmax_t=yes, gt_cv_c_intmax_t=no)]) 52 ]],
53 [[intmax_t x = -1; return !x;]])],
54 [gt_cv_c_intmax_t=yes],
55 [gt_cv_c_intmax_t=no])])
51 if test $gt_cv_c_intmax_t = yes; then 56 if test $gt_cv_c_intmax_t = yes; then
52 AC_DEFINE([HAVE_INTMAX_T], [1], 57 AC_DEFINE([HAVE_INTMAX_T], [1],
53 [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.]) 58 [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.])
diff --git a/gl/m4/inttypes-pri.m4 b/gl/m4/inttypes-pri.m4
index 718a4f4..e5a1e05 100644
--- a/gl/m4/inttypes-pri.m4
+++ b/gl/m4/inttypes-pri.m4
@@ -1,12 +1,12 @@
1# inttypes-pri.m4 serial 6 (gettext-0.18) 1# inttypes-pri.m4 serial 7 (gettext-0.18.2)
2dnl Copyright (C) 1997-2002, 2006, 2008-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 1997-2002, 2006, 2008-2013 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.53])
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.
@@ -18,11 +18,17 @@ AC_DEFUN([gt_INTTYPES_PRI],
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_COMPILE_IFELSE(
22 [AC_LANG_PROGRAM(
23 [[
24#include <inttypes.h>
22#ifdef PRId32 25#ifdef PRId32
23char *p = PRId32; 26char *p = PRId32;
24#endif 27#endif
25], [], [gt_cv_inttypes_pri_broken=no], [gt_cv_inttypes_pri_broken=yes]) 28 ]],
29 [[]])],
30 [gt_cv_inttypes_pri_broken=no],
31 [gt_cv_inttypes_pri_broken=yes])
26 ]) 32 ])
27 fi 33 fi
28 if test "$gt_cv_inttypes_pri_broken" = yes; then 34 if test "$gt_cv_inttypes_pri_broken" = yes; then
diff --git a/gl/m4/inttypes_h.m4 b/gl/m4/inttypes_h.m4
index 782d77e..5f05ac5 100644
--- a/gl/m4/inttypes_h.m4
+++ b/gl/m4/inttypes_h.m4
@@ -1,5 +1,5 @@
1# inttypes_h.m4 serial 9 1# inttypes_h.m4 serial 10
2dnl Copyright (C) 1997-2004, 2006, 2008-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 1997-2004, 2006, 2008-2013 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,12 +12,15 @@ dnl From Paul Eggert.
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_COMPILE_IFELSE(
16 [#include <sys/types.h> 16 [AC_LANG_PROGRAM(
17#include <inttypes.h>], 17 [[
18 [uintmax_t i = (uintmax_t) -1; return !i;], 18#include <sys/types.h>
19 [gl_cv_header_inttypes_h=yes], 19#include <inttypes.h>
20 [gl_cv_header_inttypes_h=no])]) 20 ]],
21 [[uintmax_t i = (uintmax_t) -1; return !i;]])],
22 [gl_cv_header_inttypes_h=yes],
23 [gl_cv_header_inttypes_h=no])])
21 if test $gl_cv_header_inttypes_h = yes; then 24 if test $gl_cv_header_inttypes_h = yes; then
22 AC_DEFINE_UNQUOTED([HAVE_INTTYPES_H_WITH_UINTMAX], [1], 25 AC_DEFINE_UNQUOTED([HAVE_INTTYPES_H_WITH_UINTMAX], [1],
23 [Define if <inttypes.h> exists, doesn't clash with <sys/types.h>, 26 [Define if <inttypes.h> exists, doesn't clash with <sys/types.h>,
diff --git a/gl/m4/langinfo_h.m4 b/gl/m4/langinfo_h.m4
index 11a5698..73bef8b 100644
--- a/gl/m4/langinfo_h.m4
+++ b/gl/m4/langinfo_h.m4
@@ -1,5 +1,5 @@
1# langinfo_h.m4 serial 6 1# langinfo_h.m4 serial 7
2dnl Copyright (C) 2009-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2009-2013 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,12 +16,14 @@ AC_DEFUN([gl_LANGINFO_H],
16 16
17 dnl Determine whether <langinfo.h> exists. It is missing on mingw and BeOS. 17 dnl Determine whether <langinfo.h> exists. It is missing on mingw and BeOS.
18 HAVE_LANGINFO_CODESET=0 18 HAVE_LANGINFO_CODESET=0
19 HAVE_LANGINFO_T_FMT_AMPM=0
19 HAVE_LANGINFO_ERA=0 20 HAVE_LANGINFO_ERA=0
21 HAVE_LANGINFO_YESEXPR=0
20 AC_CHECK_HEADERS_ONCE([langinfo.h]) 22 AC_CHECK_HEADERS_ONCE([langinfo.h])
21 if test $ac_cv_header_langinfo_h = yes; then 23 if test $ac_cv_header_langinfo_h = yes; then
22 HAVE_LANGINFO_H=1 24 HAVE_LANGINFO_H=1
23 dnl Determine what <langinfo.h> defines. CODESET and ERA etc. are missing 25 dnl Determine what <langinfo.h> defines. CODESET and ERA etc. are missing
24 dnl on OpenBSD 3.8. 26 dnl on OpenBSD 3.8. T_FMT_AMPM and YESEXPR, NOEXPR are missing on IRIX 5.3.
25 AC_CACHE_CHECK([whether langinfo.h defines CODESET], 27 AC_CACHE_CHECK([whether langinfo.h defines CODESET],
26 [gl_cv_header_langinfo_codeset], 28 [gl_cv_header_langinfo_codeset],
27 [AC_COMPILE_IFELSE( 29 [AC_COMPILE_IFELSE(
@@ -34,6 +36,18 @@ int a = CODESET;
34 if test $gl_cv_header_langinfo_codeset = yes; then 36 if test $gl_cv_header_langinfo_codeset = yes; then
35 HAVE_LANGINFO_CODESET=1 37 HAVE_LANGINFO_CODESET=1
36 fi 38 fi
39 AC_CACHE_CHECK([whether langinfo.h defines T_FMT_AMPM],
40 [gl_cv_header_langinfo_t_fmt_ampm],
41 [AC_COMPILE_IFELSE(
42 [AC_LANG_PROGRAM([[#include <langinfo.h>
43int a = T_FMT_AMPM;
44]])],
45 [gl_cv_header_langinfo_t_fmt_ampm=yes],
46 [gl_cv_header_langinfo_t_fmt_ampm=no])
47 ])
48 if test $gl_cv_header_langinfo_t_fmt_ampm = yes; then
49 HAVE_LANGINFO_T_FMT_AMPM=1
50 fi
37 AC_CACHE_CHECK([whether langinfo.h defines ERA], 51 AC_CACHE_CHECK([whether langinfo.h defines ERA],
38 [gl_cv_header_langinfo_era], 52 [gl_cv_header_langinfo_era],
39 [AC_COMPILE_IFELSE( 53 [AC_COMPILE_IFELSE(
@@ -46,12 +60,26 @@ int a = ERA;
46 if test $gl_cv_header_langinfo_era = yes; then 60 if test $gl_cv_header_langinfo_era = yes; then
47 HAVE_LANGINFO_ERA=1 61 HAVE_LANGINFO_ERA=1
48 fi 62 fi
63 AC_CACHE_CHECK([whether langinfo.h defines YESEXPR],
64 [gl_cv_header_langinfo_yesexpr],
65 [AC_COMPILE_IFELSE(
66 [AC_LANG_PROGRAM([[#include <langinfo.h>
67int a = YESEXPR;
68]])],
69 [gl_cv_header_langinfo_yesexpr=yes],
70 [gl_cv_header_langinfo_yesexpr=no])
71 ])
72 if test $gl_cv_header_langinfo_yesexpr = yes; then
73 HAVE_LANGINFO_YESEXPR=1
74 fi
49 else 75 else
50 HAVE_LANGINFO_H=0 76 HAVE_LANGINFO_H=0
51 fi 77 fi
52 AC_SUBST([HAVE_LANGINFO_H]) 78 AC_SUBST([HAVE_LANGINFO_H])
53 AC_SUBST([HAVE_LANGINFO_CODESET]) 79 AC_SUBST([HAVE_LANGINFO_CODESET])
80 AC_SUBST([HAVE_LANGINFO_T_FMT_AMPM])
54 AC_SUBST([HAVE_LANGINFO_ERA]) 81 AC_SUBST([HAVE_LANGINFO_ERA])
82 AC_SUBST([HAVE_LANGINFO_YESEXPR])
55 83
56 dnl Check for declarations of anything we want to poison if the 84 dnl Check for declarations of anything we want to poison if the
57 dnl corresponding gnulib module is not in use. 85 dnl corresponding gnulib module is not in use.
diff --git a/gl/m4/largefile.m4 b/gl/m4/largefile.m4
new file mode 100644
index 0000000..1e605e3
--- /dev/null
+++ b/gl/m4/largefile.m4
@@ -0,0 +1,146 @@
1# Enable large files on systems where this is not the default.
2
3# Copyright 1992-1996, 1998-2013 Free Software Foundation, Inc.
4# This file is free software; the Free Software Foundation
5# gives unlimited permission to copy and/or distribute it,
6# with or without modifications, as long as this notice is preserved.
7
8# The following implementation works around a problem in autoconf <= 2.69;
9# AC_SYS_LARGEFILE does not configure for large inodes on Mac OS X 10.5,
10# or configures them incorrectly in some cases.
11m4_version_prereq([2.70], [] ,[
12
13# _AC_SYS_LARGEFILE_TEST_INCLUDES
14# -------------------------------
15m4_define([_AC_SYS_LARGEFILE_TEST_INCLUDES],
16[@%:@include <sys/types.h>
17 /* Check that off_t can represent 2**63 - 1 correctly.
18 We can't simply define LARGE_OFF_T to be 9223372036854775807,
19 since some C++ compilers masquerading as C compilers
20 incorrectly reject 9223372036854775807. */
21@%:@define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
22 int off_t_is_large[[(LARGE_OFF_T % 2147483629 == 721
23 && LARGE_OFF_T % 2147483647 == 1)
24 ? 1 : -1]];[]dnl
25])
26
27
28# _AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE,
29# CACHE-VAR,
30# DESCRIPTION,
31# PROLOGUE, [FUNCTION-BODY])
32# --------------------------------------------------------
33m4_define([_AC_SYS_LARGEFILE_MACRO_VALUE],
34[AC_CACHE_CHECK([for $1 value needed for large files], [$3],
35[while :; do
36 m4_ifval([$6], [AC_LINK_IFELSE], [AC_COMPILE_IFELSE])(
37 [AC_LANG_PROGRAM([$5], [$6])],
38 [$3=no; break])
39 m4_ifval([$6], [AC_LINK_IFELSE], [AC_COMPILE_IFELSE])(
40 [AC_LANG_PROGRAM([@%:@define $1 $2
41$5], [$6])],
42 [$3=$2; break])
43 $3=unknown
44 break
45done])
46case $$3 in #(
47 no | unknown) ;;
48 *) AC_DEFINE_UNQUOTED([$1], [$$3], [$4]);;
49esac
50rm -rf conftest*[]dnl
51])# _AC_SYS_LARGEFILE_MACRO_VALUE
52
53
54# AC_SYS_LARGEFILE
55# ----------------
56# By default, many hosts won't let programs access large files;
57# one must use special compiler options to get large-file access to work.
58# For more details about this brain damage please see:
59# http://www.unix-systems.org/version2/whatsnew/lfs20mar.html
60AC_DEFUN([AC_SYS_LARGEFILE],
61[AC_ARG_ENABLE(largefile,
62 [ --disable-largefile omit support for large files])
63if test "$enable_largefile" != no; then
64
65 AC_CACHE_CHECK([for special C compiler options needed for large files],
66 ac_cv_sys_largefile_CC,
67 [ac_cv_sys_largefile_CC=no
68 if test "$GCC" != yes; then
69 ac_save_CC=$CC
70 while :; do
71 # IRIX 6.2 and later do not support large files by default,
72 # so use the C compiler's -n32 option if that helps.
73 AC_LANG_CONFTEST([AC_LANG_PROGRAM([_AC_SYS_LARGEFILE_TEST_INCLUDES])])
74 AC_COMPILE_IFELSE([], [break])
75 CC="$CC -n32"
76 AC_COMPILE_IFELSE([], [ac_cv_sys_largefile_CC=' -n32'; break])
77 break
78 done
79 CC=$ac_save_CC
80 rm -f conftest.$ac_ext
81 fi])
82 if test "$ac_cv_sys_largefile_CC" != no; then
83 CC=$CC$ac_cv_sys_largefile_CC
84 fi
85
86 _AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64,
87 ac_cv_sys_file_offset_bits,
88 [Number of bits in a file offset, on hosts where this is settable.],
89 [_AC_SYS_LARGEFILE_TEST_INCLUDES])
90 if test $ac_cv_sys_file_offset_bits = unknown; then
91 _AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1,
92 ac_cv_sys_large_files,
93 [Define for large files, on AIX-style hosts.],
94 [_AC_SYS_LARGEFILE_TEST_INCLUDES])
95 fi
96
97 AC_DEFINE([_DARWIN_USE_64_BIT_INODE], [1],
98 [Enable large inode numbers on Mac OS X 10.5.])
99fi
100])# AC_SYS_LARGEFILE
101])# m4_version_prereq 2.70
102
103# Enable large files on systems where this is implemented by Gnulib, not by the
104# system headers.
105# Set the variables WINDOWS_64_BIT_OFF_T, WINDOWS_64_BIT_ST_SIZE if Gnulib
106# overrides ensure that off_t or 'struct size.st_size' are 64-bit, respectively.
107AC_DEFUN([gl_LARGEFILE],
108[
109 AC_REQUIRE([AC_CANONICAL_HOST])
110 case "$host_os" in
111 mingw*)
112 dnl Native Windows.
113 dnl mingw64 defines off_t to a 64-bit type already, if
114 dnl _FILE_OFFSET_BITS=64, which is ensured by AC_SYS_LARGEFILE.
115 AC_CACHE_CHECK([for 64-bit off_t], [gl_cv_type_off_t_64],
116 [AC_COMPILE_IFELSE(
117 [AC_LANG_PROGRAM(
118 [[#include <sys/types.h>
119 int verify_off_t_size[sizeof (off_t) >= 8 ? 1 : -1];
120 ]],
121 [[]])],
122 [gl_cv_type_off_t_64=yes], [gl_cv_type_off_t_64=no])
123 ])
124 if test $gl_cv_type_off_t_64 = no; then
125 WINDOWS_64_BIT_OFF_T=1
126 else
127 WINDOWS_64_BIT_OFF_T=0
128 fi
129 dnl But all native Windows platforms (including mingw64) have a 32-bit
130 dnl st_size member in 'struct stat'.
131 WINDOWS_64_BIT_ST_SIZE=1
132 ;;
133 *)
134 dnl Nothing to do on gnulib's side.
135 dnl A 64-bit off_t is
136 dnl - already the default on Mac OS X, FreeBSD, NetBSD, OpenBSD, IRIX,
137 dnl OSF/1, Cygwin,
138 dnl - enabled by _FILE_OFFSET_BITS=64 (ensured by AC_SYS_LARGEFILE) on
139 dnl glibc, HP-UX, Solaris,
140 dnl - enabled by _LARGE_FILES=1 (ensured by AC_SYS_LARGEFILE) on AIX,
141 dnl - impossible to achieve on Minix 3.1.8.
142 WINDOWS_64_BIT_OFF_T=0
143 WINDOWS_64_BIT_ST_SIZE=0
144 ;;
145 esac
146])
diff --git a/gl/m4/lcmessage.m4 b/gl/m4/lcmessage.m4
index 1a70543..d62a175 100644
--- a/gl/m4/lcmessage.m4
+++ b/gl/m4/lcmessage.m4
@@ -1,5 +1,5 @@
1# lcmessage.m4 serial 6 (gettext-0.18) 1# lcmessage.m4 serial 7 (gettext-0.18.2)
2dnl Copyright (C) 1995-2002, 2004-2005, 2008-2010 Free Software Foundation, 2dnl Copyright (C) 1995-2002, 2004-2005, 2008-2013 Free Software Foundation,
3dnl Inc. 3dnl Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
@@ -22,8 +22,12 @@ dnl Ulrich Drepper <drepper@cygnus.com>, 1995.
22AC_DEFUN([gt_LC_MESSAGES], 22AC_DEFUN([gt_LC_MESSAGES],
23[ 23[
24 AC_CACHE_CHECK([for LC_MESSAGES], [gt_cv_val_LC_MESSAGES], 24 AC_CACHE_CHECK([for LC_MESSAGES], [gt_cv_val_LC_MESSAGES],
25 [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES], 25 [AC_LINK_IFELSE(
26 [gt_cv_val_LC_MESSAGES=yes], [gt_cv_val_LC_MESSAGES=no])]) 26 [AC_LANG_PROGRAM(
27 [[#include <locale.h>]],
28 [[return LC_MESSAGES]])],
29 [gt_cv_val_LC_MESSAGES=yes],
30 [gt_cv_val_LC_MESSAGES=no])])
27 if test $gt_cv_val_LC_MESSAGES = yes; then 31 if test $gt_cv_val_LC_MESSAGES = yes; then
28 AC_DEFINE([HAVE_LC_MESSAGES], [1], 32 AC_DEFINE([HAVE_LC_MESSAGES], [1],
29 [Define if your <locale.h> file defines LC_MESSAGES.]) 33 [Define if your <locale.h> file defines LC_MESSAGES.])
diff --git a/gl/m4/lib-ld.m4 b/gl/m4/lib-ld.m4
index ebb3052..c145e47 100644
--- a/gl/m4/lib-ld.m4
+++ b/gl/m4/lib-ld.m4
@@ -1,50 +1,56 @@
1# lib-ld.m4 serial 4 (gettext-0.18) 1# lib-ld.m4 serial 6
2dnl Copyright (C) 1996-2003, 2009-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 1996-2003, 2009-2013 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 Subroutines of libtool.m4, 7dnl Subroutines of libtool.m4,
8dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision 8dnl with replacements s/_*LT_PATH/AC_LIB_PROG/ and s/lt_/acl_/ to avoid
9dnl with libtool.m4. 9dnl collision with libtool.m4.
10 10
11dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no. 11dnl From libtool-2.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 lds 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'*)
17 acl_cv_prog_gnu_ld=yes ;; 17 acl_cv_prog_gnu_ld=yes
18 ;;
18*) 19*)
19 acl_cv_prog_gnu_ld=no ;; 20 acl_cv_prog_gnu_ld=no
21 ;;
20esac]) 22esac])
21with_gnu_ld=$acl_cv_prog_gnu_ld 23with_gnu_ld=$acl_cv_prog_gnu_ld
22]) 24])
23 25
24dnl From libtool-1.4. Sets the variable LD. 26dnl From libtool-2.4. Sets the variable LD.
25AC_DEFUN([AC_LIB_PROG_LD], 27AC_DEFUN([AC_LIB_PROG_LD],
26[AC_ARG_WITH([gnu-ld], 28[AC_REQUIRE([AC_PROG_CC])dnl
27[ --with-gnu-ld assume the C compiler uses GNU ld [default=no]],
28test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
29AC_REQUIRE([AC_PROG_CC])dnl
30AC_REQUIRE([AC_CANONICAL_HOST])dnl 29AC_REQUIRE([AC_CANONICAL_HOST])dnl
30
31AC_ARG_WITH([gnu-ld],
32 [AS_HELP_STRING([--with-gnu-ld],
33 [assume the C compiler uses GNU ld [default=no]])],
34 [test "$withval" = no || with_gnu_ld=yes],
35 [with_gnu_ld=no])dnl
36
31# Prepare PATH_SEPARATOR. 37# Prepare PATH_SEPARATOR.
32# The user is always right. 38# The user is always right.
33if test "${PATH_SEPARATOR+set}" != set; then 39if test "${PATH_SEPARATOR+set}" != set; then
34 echo "#! /bin/sh" >conf$$.sh 40 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
35 echo "exit 0" >>conf$$.sh 41 # contains only /bin. Note that ksh looks also at the FPATH variable,
36 chmod +x conf$$.sh 42 # so we have to set that as well for the test.
37 if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then 43 PATH_SEPARATOR=:
38 PATH_SEPARATOR=';' 44 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
39 else 45 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
40 PATH_SEPARATOR=: 46 || PATH_SEPARATOR=';'
41 fi 47 }
42 rm -f conf$$.sh
43fi 48fi
49
44ac_prog=ld 50ac_prog=ld
45if test "$GCC" = yes; then 51if test "$GCC" = yes; then
46 # Check if gcc -print-prog-name=ld gives a path. 52 # Check if gcc -print-prog-name=ld gives a path.
47 AC_MSG_CHECKING([for ld used by GCC]) 53 AC_MSG_CHECKING([for ld used by $CC])
48 case $host in 54 case $host in
49 *-*-mingw*) 55 *-*-mingw*)
50 # gcc leaves a trailing carriage return which upsets mingw 56 # gcc leaves a trailing carriage return which upsets mingw
@@ -54,11 +60,11 @@ if test "$GCC" = yes; then
54 esac 60 esac
55 case $ac_prog in 61 case $ac_prog in
56 # Accept absolute paths. 62 # Accept absolute paths.
57 [[\\/]* | [A-Za-z]:[\\/]*)] 63 [[\\/]]* | ?:[[\\/]]*)
58 [re_direlt='/[^/][^/]*/\.\./'] 64 re_direlt='/[[^/]][[^/]]*/\.\./'
59 # Canonicalize the path of ld 65 # Canonicalize the pathname of ld
60 ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` 66 ac_prog=`echo "$ac_prog"| sed 's%\\\\%/%g'`
61 while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do 67 while echo "$ac_prog" | grep "$re_direlt" > /dev/null 2>&1; do
62 ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` 68 ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
63 done 69 done
64 test -z "$LD" && LD="$ac_prog" 70 test -z "$LD" && LD="$ac_prog"
@@ -79,23 +85,26 @@ else
79fi 85fi
80AC_CACHE_VAL([acl_cv_path_LD], 86AC_CACHE_VAL([acl_cv_path_LD],
81[if test -z "$LD"; then 87[if test -z "$LD"; then
82 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" 88 acl_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
83 for ac_dir in $PATH; do 89 for ac_dir in $PATH; do
90 IFS="$acl_save_ifs"
84 test -z "$ac_dir" && ac_dir=. 91 test -z "$ac_dir" && ac_dir=.
85 if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then 92 if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
86 acl_cv_path_LD="$ac_dir/$ac_prog" 93 acl_cv_path_LD="$ac_dir/$ac_prog"
87 # Check to see if the program is GNU ld. I'd rather use --version, 94 # Check to see if the program is GNU ld. I'd rather use --version,
88 # but apparently some GNU ld's only accept -v. 95 # but apparently some variants of GNU ld only accept -v.
89 # Break only if it was the GNU/non-GNU ld that we prefer. 96 # Break only if it was the GNU/non-GNU ld that we prefer.
90 case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in 97 case `"$acl_cv_path_LD" -v 2>&1 </dev/null` in
91 *GNU* | *'with BFD'*) 98 *GNU* | *'with BFD'*)
92 test "$with_gnu_ld" != no && break ;; 99 test "$with_gnu_ld" != no && break
100 ;;
93 *) 101 *)
94 test "$with_gnu_ld" != yes && break ;; 102 test "$with_gnu_ld" != yes && break
103 ;;
95 esac 104 esac
96 fi 105 fi
97 done 106 done
98 IFS="$ac_save_ifs" 107 IFS="$acl_save_ifs"
99else 108else
100 acl_cv_path_LD="$LD" # Let the user override the test with a path. 109 acl_cv_path_LD="$LD" # Let the user override the test with a path.
101fi]) 110fi])
diff --git a/gl/m4/lib-link.m4 b/gl/m4/lib-link.m4
index 9f3be3a..073f040 100644
--- a/gl/m4/lib-link.m4
+++ b/gl/m4/lib-link.m4
@@ -1,5 +1,5 @@
1# lib-link.m4 serial 24 (gettext-0.18.2) 1# lib-link.m4 serial 26 (gettext-0.18.2)
2dnl Copyright (C) 2001-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2001-2013 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.
@@ -85,7 +85,8 @@ AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
85 *" -l"*) LIBS="$LIBS $LIB[]NAME" ;; 85 *" -l"*) LIBS="$LIBS $LIB[]NAME" ;;
86 *) LIBS="$LIB[]NAME $LIBS" ;; 86 *) LIBS="$LIB[]NAME $LIBS" ;;
87 esac 87 esac
88 AC_TRY_LINK([$3], [$4], 88 AC_LINK_IFELSE(
89 [AC_LANG_PROGRAM([[$3]], [[$4]])],
89 [ac_cv_lib[]Name=yes], 90 [ac_cv_lib[]Name=yes],
90 [ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])']) 91 [ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])'])
91 LIBS="$ac_save_LIBS" 92 LIBS="$ac_save_LIBS"
@@ -115,6 +116,8 @@ AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
115dnl Determine the platform dependent parameters needed to use rpath: 116dnl Determine the platform dependent parameters needed to use rpath:
116dnl acl_libext, 117dnl acl_libext,
117dnl acl_shlibext, 118dnl acl_shlibext,
119dnl acl_libname_spec,
120dnl acl_library_names_spec,
118dnl acl_hardcode_libdir_flag_spec, 121dnl acl_hardcode_libdir_flag_spec,
119dnl acl_hardcode_libdir_separator, 122dnl acl_hardcode_libdir_separator,
120dnl acl_hardcode_direct, 123dnl acl_hardcode_direct,
diff --git a/gl/m4/lib-prefix.m4 b/gl/m4/lib-prefix.m4
index 1601cea..60908e8 100644
--- a/gl/m4/lib-prefix.m4
+++ b/gl/m4/lib-prefix.m4
@@ -1,5 +1,5 @@
1# lib-prefix.m4 serial 7 (gettext-0.18) 1# lib-prefix.m4 serial 7 (gettext-0.18)
2dnl Copyright (C) 2001-2005, 2008-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2001-2005, 2008-2013 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.
diff --git a/gl/m4/localcharset.m4 b/gl/m4/localcharset.m4
index ee2e801..2e93e58 100644
--- a/gl/m4/localcharset.m4
+++ b/gl/m4/localcharset.m4
@@ -1,5 +1,5 @@
1# localcharset.m4 serial 7 1# localcharset.m4 serial 7
2dnl Copyright (C) 2002, 2004, 2006, 2009, 2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2002, 2004, 2006, 2009-2013 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.
diff --git a/gl/m4/locale-fr.m4 b/gl/m4/locale-fr.m4
index 001f539..ef199e3 100644
--- a/gl/m4/locale-fr.m4
+++ b/gl/m4/locale-fr.m4
@@ -1,5 +1,5 @@
1# locale-fr.m4 serial 11 1# locale-fr.m4 serial 17
2dnl Copyright (C) 2003, 2005-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2003, 2005-2013 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.
@@ -25,17 +25,30 @@ struct tm t;
25char buf[16]; 25char buf[16];
26int main () { 26int main () {
27 /* Check whether the given locale name is recognized by the system. */ 27 /* Check whether the given locale name is recognized by the system. */
28#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
29 /* On native Windows, setlocale(category, "") looks at the system settings,
30 not at the environment variables. Also, when an encoding suffix such
31 as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE
32 category of the locale to "C". */
33 if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL
34 || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
35 return 1;
36#else
28 if (setlocale (LC_ALL, "") == NULL) return 1; 37 if (setlocale (LC_ALL, "") == NULL) return 1;
38#endif
29 /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646". 39 /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
30 On MacOS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET) 40 On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
31 is empty, and the behaviour of Tcl 8.4 in this locale is not useful. 41 is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
32 On OpenBSD 4.0, when an unsupported locale is specified, setlocale() 42 On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
33 succeeds but then nl_langinfo(CODESET) is "646". In this situation, 43 succeeds but then nl_langinfo(CODESET) is "646". In this situation,
34 some unit tests fail. */ 44 some unit tests fail.
45 On MirBSD 10, when an unsupported locale is specified, setlocale()
46 succeeds but then nl_langinfo(CODESET) is "UTF-8". */
35#if HAVE_LANGINFO_CODESET 47#if HAVE_LANGINFO_CODESET
36 { 48 {
37 const char *cs = nl_langinfo (CODESET); 49 const char *cs = nl_langinfo (CODESET);
38 if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0) 50 if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
51 || strcmp (cs, "UTF-8") == 0)
39 return 1; 52 return 1;
40 } 53 }
41#endif 54#endif
@@ -50,46 +63,67 @@ int main () {
50 one byte long. This excludes the UTF-8 encoding. */ 63 one byte long. This excludes the UTF-8 encoding. */
51 t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4; 64 t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
52 if (strftime (buf, sizeof (buf), "%b", &t) < 3 || buf[2] != 'v') return 1; 65 if (strftime (buf, sizeof (buf), "%b", &t) < 3 || buf[2] != 'v') return 1;
66#if !defined __BIONIC__ /* Bionic libc's 'struct lconv' is just a dummy. */
53 /* Check whether the decimal separator is a comma. 67 /* Check whether the decimal separator is a comma.
54 On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point 68 On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
55 are nl_langinfo(RADIXCHAR) are both ".". */ 69 are nl_langinfo(RADIXCHAR) are both ".". */
56 if (localeconv () ->decimal_point[0] != ',') return 1; 70 if (localeconv () ->decimal_point[0] != ',') return 1;
71#endif
57 return 0; 72 return 0;
58} 73}
59changequote([,])dnl 74changequote([,])dnl
60 ])]) 75 ])])
61 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then 76 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
62 # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because 77 case "$host_os" in
63 # otherwise on MacOS X 10.3.5 the LC_TIME=C from the beginning of the 78 # Handle native Windows specially, because there setlocale() interprets
64 # configure script would override the LC_ALL setting. Likewise for 79 # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256",
65 # LC_CTYPE, which is also set at the beginning of the configure script. 80 # "fr" or "fra" as "French" or "French_France.1252",
66 # Test for the usual locale name. 81 # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252",
67 if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then 82 # "ja" as "Japanese" or "Japanese_Japan.932",
68 gt_cv_locale_fr=fr_FR 83 # and similar.
69 else 84 mingw*)
70 # Test for the locale name with explicit encoding suffix. 85 # Test for the native Windows locale name.
71 if (LC_ALL=fr_FR.ISO-8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then 86 if (LC_ALL=French_France.1252 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
72 gt_cv_locale_fr=fr_FR.ISO-8859-1 87 gt_cv_locale_fr=French_France.1252
73 else
74 # Test for the AIX, OSF/1, FreeBSD, NetBSD, OpenBSD locale name.
75 if (LC_ALL=fr_FR.ISO8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
76 gt_cv_locale_fr=fr_FR.ISO8859-1
77 else 88 else
78 # Test for the HP-UX locale name. 89 # None found.
79 if (LC_ALL=fr_FR.iso88591 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then 90 gt_cv_locale_fr=none
80 gt_cv_locale_fr=fr_FR.iso88591 91 fi
92 ;;
93 *)
94 # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
95 # otherwise on Mac OS X 10.3.5 the LC_TIME=C from the beginning of the
96 # configure script would override the LC_ALL setting. Likewise for
97 # LC_CTYPE, which is also set at the beginning of the configure script.
98 # Test for the usual locale name.
99 if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
100 gt_cv_locale_fr=fr_FR
101 else
102 # Test for the locale name with explicit encoding suffix.
103 if (LC_ALL=fr_FR.ISO-8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
104 gt_cv_locale_fr=fr_FR.ISO-8859-1
81 else 105 else
82 # Test for the Solaris 7 locale name. 106 # Test for the AIX, OSF/1, FreeBSD, NetBSD, OpenBSD locale name.
83 if (LC_ALL=fr LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then 107 if (LC_ALL=fr_FR.ISO8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
84 gt_cv_locale_fr=fr 108 gt_cv_locale_fr=fr_FR.ISO8859-1
85 else 109 else
86 # None found. 110 # Test for the HP-UX locale name.
87 gt_cv_locale_fr=none 111 if (LC_ALL=fr_FR.iso88591 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
112 gt_cv_locale_fr=fr_FR.iso88591
113 else
114 # Test for the Solaris 7 locale name.
115 if (LC_ALL=fr LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
116 gt_cv_locale_fr=fr
117 else
118 # None found.
119 gt_cv_locale_fr=none
120 fi
121 fi
88 fi 122 fi
89 fi 123 fi
90 fi 124 fi
91 fi 125 ;;
92 fi 126 esac
93 fi 127 fi
94 rm -fr conftest* 128 rm -fr conftest*
95 ]) 129 ])
@@ -119,9 +153,19 @@ int main () {
119 variables, and all locales use the UTF-8 encoding. */ 153 variables, and all locales use the UTF-8 encoding. */
120#if !(defined __BEOS__ || defined __HAIKU__) 154#if !(defined __BEOS__ || defined __HAIKU__)
121 /* Check whether the given locale name is recognized by the system. */ 155 /* Check whether the given locale name is recognized by the system. */
156# if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
157 /* On native Windows, setlocale(category, "") looks at the system settings,
158 not at the environment variables. Also, when an encoding suffix such
159 as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE
160 category of the locale to "C". */
161 if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL
162 || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
163 return 1;
164# else
122 if (setlocale (LC_ALL, "") == NULL) return 1; 165 if (setlocale (LC_ALL, "") == NULL) return 1;
166# endif
123 /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646". 167 /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
124 On MacOS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET) 168 On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
125 is empty, and the behaviour of Tcl 8.4 in this locale is not useful. 169 is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
126 On OpenBSD 4.0, when an unsupported locale is specified, setlocale() 170 On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
127 succeeds but then nl_langinfo(CODESET) is "646". In this situation, 171 succeeds but then nl_langinfo(CODESET) is "646". In this situation,
@@ -147,36 +191,57 @@ int main () {
147 || buf[1] != (char) 0xc3 || buf[2] != (char) 0xa9 || buf[3] != 'v') 191 || buf[1] != (char) 0xc3 || buf[2] != (char) 0xa9 || buf[3] != 'v')
148 return 1; 192 return 1;
149#endif 193#endif
194#if !defined __BIONIC__ /* Bionic libc's 'struct lconv' is just a dummy. */
150 /* Check whether the decimal separator is a comma. 195 /* Check whether the decimal separator is a comma.
151 On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point 196 On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
152 are nl_langinfo(RADIXCHAR) are both ".". */ 197 are nl_langinfo(RADIXCHAR) are both ".". */
153 if (localeconv () ->decimal_point[0] != ',') return 1; 198 if (localeconv () ->decimal_point[0] != ',') return 1;
199#endif
154 return 0; 200 return 0;
155} 201}
156changequote([,])dnl 202changequote([,])dnl
157 ])]) 203 ])])
158 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then 204 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
159 # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because 205 case "$host_os" in
160 # otherwise on MacOS X 10.3.5 the LC_TIME=C from the beginning of the 206 # Handle native Windows specially, because there setlocale() interprets
161 # configure script would override the LC_ALL setting. Likewise for 207 # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256",
162 # LC_CTYPE, which is also set at the beginning of the configure script. 208 # "fr" or "fra" as "French" or "French_France.1252",
163 # Test for the usual locale name. 209 # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252",
164 if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then 210 # "ja" as "Japanese" or "Japanese_Japan.932",
165 gt_cv_locale_fr_utf8=fr_FR 211 # and similar.
166 else 212 mingw*)
167 # Test for the locale name with explicit encoding suffix. 213 # Test for the hypothetical native Windows locale name.
168 if (LC_ALL=fr_FR.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then 214 if (LC_ALL=French_France.65001 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
169 gt_cv_locale_fr_utf8=fr_FR.UTF-8 215 gt_cv_locale_fr_utf8=French_France.65001
170 else
171 # Test for the Solaris 7 locale name.
172 if (LC_ALL=fr.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
173 gt_cv_locale_fr_utf8=fr.UTF-8
174 else 216 else
175 # None found. 217 # None found.
176 gt_cv_locale_fr_utf8=none 218 gt_cv_locale_fr_utf8=none
177 fi 219 fi
178 fi 220 ;;
179 fi 221 *)
222 # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
223 # otherwise on Mac OS X 10.3.5 the LC_TIME=C from the beginning of the
224 # configure script would override the LC_ALL setting. Likewise for
225 # LC_CTYPE, which is also set at the beginning of the configure script.
226 # Test for the usual locale name.
227 if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
228 gt_cv_locale_fr_utf8=fr_FR
229 else
230 # Test for the locale name with explicit encoding suffix.
231 if (LC_ALL=fr_FR.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
232 gt_cv_locale_fr_utf8=fr_FR.UTF-8
233 else
234 # Test for the Solaris 7 locale name.
235 if (LC_ALL=fr.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
236 gt_cv_locale_fr_utf8=fr.UTF-8
237 else
238 # None found.
239 gt_cv_locale_fr_utf8=none
240 fi
241 fi
242 fi
243 ;;
244 esac
180 fi 245 fi
181 rm -fr conftest* 246 rm -fr conftest*
182 ]) 247 ])
diff --git a/gl/m4/locale-ja.m4 b/gl/m4/locale-ja.m4
index 0eedaf1..132a3e7 100644
--- a/gl/m4/locale-ja.m4
+++ b/gl/m4/locale-ja.m4
@@ -1,5 +1,5 @@
1# locale-ja.m4 serial 7 1# locale-ja.m4 serial 12
2dnl Copyright (C) 2003, 2005-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2003, 2005-2013 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,30 @@ int main ()
27{ 27{
28 const char *p; 28 const char *p;
29 /* Check whether the given locale name is recognized by the system. */ 29 /* Check whether the given locale name is recognized by the system. */
30#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
31 /* On native Windows, setlocale(category, "") looks at the system settings,
32 not at the environment variables. Also, when an encoding suffix such
33 as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE
34 category of the locale to "C". */
35 if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL
36 || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
37 return 1;
38#else
30 if (setlocale (LC_ALL, "") == NULL) return 1; 39 if (setlocale (LC_ALL, "") == NULL) return 1;
40#endif
31 /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646". 41 /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
32 On MacOS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET) 42 On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
33 is empty, and the behaviour of Tcl 8.4 in this locale is not useful. 43 is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
34 On OpenBSD 4.0, when an unsupported locale is specified, setlocale() 44 On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
35 succeeds but then nl_langinfo(CODESET) is "646". In this situation, 45 succeeds but then nl_langinfo(CODESET) is "646". In this situation,
36 some unit tests fail. */ 46 some unit tests fail.
47 On MirBSD 10, when an unsupported locale is specified, setlocale()
48 succeeds but then nl_langinfo(CODESET) is "UTF-8". */
37#if HAVE_LANGINFO_CODESET 49#if HAVE_LANGINFO_CODESET
38 { 50 {
39 const char *cs = nl_langinfo (CODESET); 51 const char *cs = nl_langinfo (CODESET);
40 if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0) 52 if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
53 || strcmp (cs, "UTF-8") == 0)
41 return 1; 54 return 1;
42 } 55 }
43#endif 56#endif
@@ -52,7 +65,7 @@ int main ()
52 if (MB_CUR_MAX == 1) 65 if (MB_CUR_MAX == 1)
53 return 1; 66 return 1;
54 /* Check whether in a month name, no byte in the range 0x80..0x9F occurs. 67 /* Check whether in a month name, no byte in the range 0x80..0x9F occurs.
55 This excludes the UTF-8 encoding. */ 68 This excludes the UTF-8 encoding (except on MirBSD). */
56 t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4; 69 t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
57 if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1; 70 if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1;
58 for (p = buf; *p != '\0'; p++) 71 for (p = buf; *p != '\0'; p++)
@@ -63,42 +76,58 @@ int main ()
63changequote([,])dnl 76changequote([,])dnl
64 ])]) 77 ])])
65 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then 78 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
66 # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because 79 case "$host_os" in
67 # otherwise on MacOS X 10.3.5 the LC_TIME=C from the beginning of the 80 # Handle native Windows specially, because there setlocale() interprets
68 # configure script would override the LC_ALL setting. Likewise for 81 # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256",
69 # LC_CTYPE, which is also set at the beginning of the configure script. 82 # "fr" or "fra" as "French" or "French_France.1252",
70 # Test for the AIX locale name. 83 # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252",
71 if (LC_ALL=ja_JP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then 84 # "ja" as "Japanese" or "Japanese_Japan.932",
72 gt_cv_locale_ja=ja_JP 85 # and similar.
73 else 86 mingw*)
74 # Test for the locale name with explicit encoding suffix. 87 # Note that on native Windows, the Japanese locale is
75 if (LC_ALL=ja_JP.EUC-JP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then 88 # Japanese_Japan.932, and CP932 is very different from EUC-JP, so we
76 gt_cv_locale_ja=ja_JP.EUC-JP 89 # cannot use it here.
77 else 90 gt_cv_locale_ja=none
78 # Test for the HP-UX, OSF/1, NetBSD locale name. 91 ;;
79 if (LC_ALL=ja_JP.eucJP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then 92 *)
80 gt_cv_locale_ja=ja_JP.eucJP 93 # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
94 # otherwise on Mac OS X 10.3.5 the LC_TIME=C from the beginning of the
95 # configure script would override the LC_ALL setting. Likewise for
96 # LC_CTYPE, which is also set at the beginning of the configure script.
97 # Test for the AIX locale name.
98 if (LC_ALL=ja_JP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
99 gt_cv_locale_ja=ja_JP
81 else 100 else
82 # Test for the IRIX, FreeBSD locale name. 101 # Test for the locale name with explicit encoding suffix.
83 if (LC_ALL=ja_JP.EUC LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then 102 if (LC_ALL=ja_JP.EUC-JP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
84 gt_cv_locale_ja=ja_JP.EUC 103 gt_cv_locale_ja=ja_JP.EUC-JP
85 else 104 else
86 # Test for the Solaris 7 locale name. 105 # Test for the HP-UX, OSF/1, NetBSD locale name.
87 if (LC_ALL=ja LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then 106 if (LC_ALL=ja_JP.eucJP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
88 gt_cv_locale_ja=ja 107 gt_cv_locale_ja=ja_JP.eucJP
89 else 108 else
90 # Special test for NetBSD 1.6. 109 # Test for the IRIX, FreeBSD locale name.
91 if test -f /usr/share/locale/ja_JP.eucJP/LC_CTYPE; then 110 if (LC_ALL=ja_JP.EUC LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
92 gt_cv_locale_ja=ja_JP.eucJP 111 gt_cv_locale_ja=ja_JP.EUC
93 else 112 else
94 # None found. 113 # Test for the Solaris 7 locale name.
95 gt_cv_locale_ja=none 114 if (LC_ALL=ja LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
115 gt_cv_locale_ja=ja
116 else
117 # Special test for NetBSD 1.6.
118 if test -f /usr/share/locale/ja_JP.eucJP/LC_CTYPE; then
119 gt_cv_locale_ja=ja_JP.eucJP
120 else
121 # None found.
122 gt_cv_locale_ja=none
123 fi
124 fi
96 fi 125 fi
97 fi 126 fi
98 fi 127 fi
99 fi 128 fi
100 fi 129 ;;
101 fi 130 esac
102 fi 131 fi
103 rm -fr conftest* 132 rm -fr conftest*
104 ]) 133 ])
diff --git a/gl/m4/locale-zh.m4 b/gl/m4/locale-zh.m4
index 777fd14..4eed73f 100644
--- a/gl/m4/locale-zh.m4
+++ b/gl/m4/locale-zh.m4
@@ -1,5 +1,5 @@
1# locale-zh.m4 serial 6 1# locale-zh.m4 serial 12
2dnl Copyright (C) 2003, 2005-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2003, 2005-2013 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.
@@ -28,17 +28,30 @@ int main ()
28{ 28{
29 const char *p; 29 const char *p;
30 /* Check whether the given locale name is recognized by the system. */ 30 /* Check whether the given locale name is recognized by the system. */
31#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
32 /* On native Windows, setlocale(category, "") looks at the system settings,
33 not at the environment variables. Also, when an encoding suffix such
34 as ".65001" or ".54936" is specified, it succeeds but sets the LC_CTYPE
35 category of the locale to "C". */
36 if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL
37 || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
38 return 1;
39#else
31 if (setlocale (LC_ALL, "") == NULL) return 1; 40 if (setlocale (LC_ALL, "") == NULL) return 1;
41#endif
32 /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646". 42 /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
33 On MacOS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET) 43 On Mac OS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
34 is empty, and the behaviour of Tcl 8.4 in this locale is not useful. 44 is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
35 On OpenBSD 4.0, when an unsupported locale is specified, setlocale() 45 On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
36 succeeds but then nl_langinfo(CODESET) is "646". In this situation, 46 succeeds but then nl_langinfo(CODESET) is "646". In this situation,
37 some unit tests fail. */ 47 some unit tests fail.
48 On MirBSD 10, when an unsupported locale is specified, setlocale()
49 succeeds but then nl_langinfo(CODESET) is "UTF-8". */
38#if HAVE_LANGINFO_CODESET 50#if HAVE_LANGINFO_CODESET
39 { 51 {
40 const char *cs = nl_langinfo (CODESET); 52 const char *cs = nl_langinfo (CODESET);
41 if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0) 53 if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0
54 || strcmp (cs, "UTF-8") == 0)
42 return 1; 55 return 1;
43 } 56 }
44#endif 57#endif
@@ -49,7 +62,7 @@ int main ()
49 if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1; 62 if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
50#endif 63#endif
51 /* Check whether in a month name, no byte in the range 0x80..0x9F occurs. 64 /* Check whether in a month name, no byte in the range 0x80..0x9F occurs.
52 This excludes the UTF-8 encoding. */ 65 This excludes the UTF-8 encoding (except on MirBSD). */
53 t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4; 66 t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
54 if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1; 67 if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1;
55 for (p = buf; *p != '\0'; p++) 68 for (p = buf; *p != '\0'; p++)
@@ -64,22 +77,47 @@ int main ()
64changequote([,])dnl 77changequote([,])dnl
65 ])]) 78 ])])
66 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then 79 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
67 # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because 80 case "$host_os" in
68 # otherwise on MacOS X 10.3.5 the LC_TIME=C from the beginning of the 81 # Handle native Windows specially, because there setlocale() interprets
69 # configure script would override the LC_ALL setting. Likewise for 82 # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256",
70 # LC_CTYPE, which is also set at the beginning of the configure script. 83 # "fr" or "fra" as "French" or "French_France.1252",
71 # Test for the locale name without encoding suffix. 84 # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252",
72 if (LC_ALL=zh_CN LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then 85 # "ja" as "Japanese" or "Japanese_Japan.932",
73 gt_cv_locale_zh_CN=zh_CN 86 # and similar.
74 else 87 mingw*)
75 # Test for the locale name with explicit encoding suffix. 88 # Test for the hypothetical native Windows locale name.
76 if (LC_ALL=zh_CN.GB18030 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then 89 if (LC_ALL=Chinese_China.54936 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
77 gt_cv_locale_zh_CN=zh_CN.GB18030 90 gt_cv_locale_zh_CN=Chinese_China.54936
78 else 91 else
79 # None found. 92 # None found.
93 gt_cv_locale_zh_CN=none
94 fi
95 ;;
96 solaris2.8)
97 # On Solaris 8, the locales zh_CN.GB18030, zh_CN.GBK, zh.GBK are
98 # broken. One witness is the test case in gl_MBRTOWC_SANITYCHECK.
99 # Another witness is that "LC_ALL=zh_CN.GB18030 bash -c true" dumps core.
80 gt_cv_locale_zh_CN=none 100 gt_cv_locale_zh_CN=none
81 fi 101 ;;
82 fi 102 *)
103 # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
104 # otherwise on Mac OS X 10.3.5 the LC_TIME=C from the beginning of the
105 # configure script would override the LC_ALL setting. Likewise for
106 # LC_CTYPE, which is also set at the beginning of the configure script.
107 # Test for the locale name without encoding suffix.
108 if (LC_ALL=zh_CN LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
109 gt_cv_locale_zh_CN=zh_CN
110 else
111 # Test for the locale name with explicit encoding suffix.
112 if (LC_ALL=zh_CN.GB18030 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
113 gt_cv_locale_zh_CN=zh_CN.GB18030
114 else
115 # None found.
116 gt_cv_locale_zh_CN=none
117 fi
118 fi
119 ;;
120 esac
83 else 121 else
84 # If there was a link error, due to mblen(), the system is so old that 122 # If there was a link error, due to mblen(), the system is so old that
85 # it certainly doesn't have a chinese locale. 123 # it certainly doesn't have a chinese locale.
diff --git a/gl/m4/locale_h.m4 b/gl/m4/locale_h.m4
index 18a119b..8bd12e8 100644
--- a/gl/m4/locale_h.m4
+++ b/gl/m4/locale_h.m4
@@ -1,5 +1,5 @@
1# locale_h.m4 serial 10 1# locale_h.m4 serial 19
2dnl Copyright (C) 2007, 2009-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2007, 2009-2013 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,16 +10,30 @@ AC_DEFUN([gl_LOCALE_H],
10 dnl once only, before all statements that occur in other macros. 10 dnl once only, before all statements that occur in other macros.
11 AC_REQUIRE([gl_LOCALE_H_DEFAULTS]) 11 AC_REQUIRE([gl_LOCALE_H_DEFAULTS])
12 12
13 dnl Persuade glibc <locale.h> to define locale_t. 13 dnl Persuade glibc <locale.h> to define locale_t and the int_p_*, int_n_*
14 dnl members of 'struct lconv'.
14 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) 15 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
15 16
16 dnl If <stddef.h> is replaced, then <locale.h> must also be replaced. 17 dnl If <stddef.h> is replaced, then <locale.h> must also be replaced.
17 AC_REQUIRE([gl_STDDEF_H]) 18 AC_REQUIRE([gl_STDDEF_H])
18 19
20 dnl Solaris 11 2011-11 defines the int_p_*, int_n_* members of 'struct lconv'
21 dnl only if _LCONV_C99 is defined.
22 AC_REQUIRE([AC_CANONICAL_HOST])
23 case "$host_os" in
24 solaris*)
25 AC_DEFINE([_LCONV_C99], [1], [Define to 1 on Solaris.])
26 ;;
27 esac
28
19 AC_CACHE_CHECK([whether locale.h conforms to POSIX:2001], 29 AC_CACHE_CHECK([whether locale.h conforms to POSIX:2001],
20 [gl_cv_header_locale_h_posix2001], 30 [gl_cv_header_locale_h_posix2001],
21 [AC_TRY_COMPILE([#include <locale.h> 31 [AC_COMPILE_IFELSE(
22int x = LC_MESSAGES;], [], 32 [AC_LANG_PROGRAM(
33 [[#include <locale.h>
34 int x = LC_MESSAGES;
35 int y = sizeof (((struct lconv *) 0)->decimal_point);]],
36 [[]])],
23 [gl_cv_header_locale_h_posix2001=yes], 37 [gl_cv_header_locale_h_posix2001=yes],
24 [gl_cv_header_locale_h_posix2001=no])]) 38 [gl_cv_header_locale_h_posix2001=no])])
25 39
@@ -28,12 +42,15 @@ int x = LC_MESSAGES;], [],
28 if test $ac_cv_header_xlocale_h = yes; then 42 if test $ac_cv_header_xlocale_h = yes; then
29 HAVE_XLOCALE_H=1 43 HAVE_XLOCALE_H=1
30 dnl Check whether use of locale_t requires inclusion of <xlocale.h>, 44 dnl Check whether use of locale_t requires inclusion of <xlocale.h>,
31 dnl e.g. on MacOS X 10.5. If <locale.h> does not define locale_t by 45 dnl e.g. on Mac OS X 10.5. If <locale.h> does not define locale_t by
32 dnl itself, we assume that <xlocale.h> will do so. 46 dnl itself, we assume that <xlocale.h> will do so.
33 AC_CACHE_CHECK([whether locale.h defines locale_t], 47 AC_CACHE_CHECK([whether locale.h defines locale_t],
34 [gl_cv_header_locale_has_locale_t], 48 [gl_cv_header_locale_has_locale_t],
35 [AC_TRY_COMPILE([#include <locale.h> 49 [AC_COMPILE_IFELSE(
36locale_t x;], [], 50 [AC_LANG_PROGRAM(
51 [[#include <locale.h>
52 locale_t x;]],
53 [[]])],
37 [gl_cv_header_locale_has_locale_t=yes], 54 [gl_cv_header_locale_has_locale_t=yes],
38 [gl_cv_header_locale_has_locale_t=no]) 55 [gl_cv_header_locale_has_locale_t=no])
39 ]) 56 ])
@@ -48,15 +65,29 @@ locale_t x;], [],
48 fi 65 fi
49 AC_SUBST([HAVE_XLOCALE_H]) 66 AC_SUBST([HAVE_XLOCALE_H])
50 67
51 dnl <locale.h> is always overridden, because of GNULIB_POSIXCHECK. 68 dnl Check whether 'struct lconv' is complete.
52 gl_CHECK_NEXT_HEADERS([locale.h]) 69 dnl Bionic libc's 'struct lconv' is just a dummy.
53 70 dnl On OpenBSD 4.9, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 9, Cygwin 1.5.x,
54 if test -n "$STDDEF_H" \ 71 dnl mingw, MSVC 9, it lacks the int_p_* and int_n_* members.
55 || test $gl_cv_header_locale_h_posix2001 = no \ 72 AC_CACHE_CHECK([whether struct lconv is properly defined],
56 || test $gl_cv_header_locale_h_needs_xlocale_h = yes; then 73 [gl_cv_sys_struct_lconv_ok],
57 gl_REPLACE_LOCALE_H 74 [AC_COMPILE_IFELSE(
75 [AC_LANG_PROGRAM(
76 [[#include <locale.h>
77 struct lconv l;
78 int x = sizeof (l.decimal_point);
79 int y = sizeof (l.int_p_cs_precedes);]],
80 [[]])],
81 [gl_cv_sys_struct_lconv_ok=yes],
82 [gl_cv_sys_struct_lconv_ok=no])
83 ])
84 if test $gl_cv_sys_struct_lconv_ok = no; then
85 REPLACE_STRUCT_LCONV=1
58 fi 86 fi
59 87
88 dnl <locale.h> is always overridden, because of GNULIB_POSIXCHECK.
89 gl_NEXT_HEADERS([locale.h])
90
60 dnl Check for declarations of anything we want to poison if the 91 dnl Check for declarations of anything we want to poison if the
61 dnl corresponding gnulib module is not in use. 92 dnl corresponding gnulib module is not in use.
62 gl_WARN_ON_USE_PREPARE([[#include <locale.h> 93 gl_WARN_ON_USE_PREPARE([[#include <locale.h>
@@ -64,14 +95,8 @@ locale_t x;], [],
64#if HAVE_XLOCALE_H 95#if HAVE_XLOCALE_H
65# include <xlocale.h> 96# include <xlocale.h>
66#endif 97#endif
67 ]], [duplocale]) 98 ]],
68]) 99 [setlocale duplocale])
69
70dnl Unconditionally enables the replacement of <locale.h>.
71AC_DEFUN([gl_REPLACE_LOCALE_H],
72[
73 dnl This is a no-op, because <locale.h> is always overridden.
74 :
75]) 100])
76 101
77AC_DEFUN([gl_LOCALE_MODULE_INDICATOR], 102AC_DEFUN([gl_LOCALE_MODULE_INDICATOR],
@@ -85,8 +110,13 @@ AC_DEFUN([gl_LOCALE_MODULE_INDICATOR],
85 110
86AC_DEFUN([gl_LOCALE_H_DEFAULTS], 111AC_DEFUN([gl_LOCALE_H_DEFAULTS],
87[ 112[
113 GNULIB_LOCALECONV=0; AC_SUBST([GNULIB_LOCALECONV])
114 GNULIB_SETLOCALE=0; AC_SUBST([GNULIB_SETLOCALE])
88 GNULIB_DUPLOCALE=0; AC_SUBST([GNULIB_DUPLOCALE]) 115 GNULIB_DUPLOCALE=0; AC_SUBST([GNULIB_DUPLOCALE])
89 dnl Assume proper GNU behavior unless another module says otherwise. 116 dnl Assume proper GNU behavior unless another module says otherwise.
90 HAVE_DUPLOCALE=1; AC_SUBST([HAVE_DUPLOCALE]) 117 HAVE_DUPLOCALE=1; AC_SUBST([HAVE_DUPLOCALE])
91 REPLACE_DUPLOCALE=0; AC_SUBST([REPLACE_DUPLOCALE]) 118 REPLACE_LOCALECONV=0; AC_SUBST([REPLACE_LOCALECONV])
119 REPLACE_SETLOCALE=0; AC_SUBST([REPLACE_SETLOCALE])
120 REPLACE_DUPLOCALE=0; AC_SUBST([REPLACE_DUPLOCALE])
121 REPLACE_STRUCT_LCONV=0; AC_SUBST([REPLACE_STRUCT_LCONV])
92]) 122])
diff --git a/gl/m4/localeconv.m4 b/gl/m4/localeconv.m4
new file mode 100644
index 0000000..b8bb596
--- /dev/null
+++ b/gl/m4/localeconv.m4
@@ -0,0 +1,22 @@
1# localeconv.m4 serial 1
2dnl Copyright (C) 2012-2013 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_LOCALECONV],
8[
9 AC_REQUIRE([gl_LOCALE_H_DEFAULTS])
10 AC_REQUIRE([gl_LOCALE_H])
11
12 if test $REPLACE_STRUCT_LCONV = 1; then
13 REPLACE_LOCALECONV=1
14 fi
15])
16
17# Prerequisites of lib/localeconv.c.
18AC_DEFUN([gl_PREREQ_LOCALECONV],
19[
20 AC_CHECK_MEMBERS([struct lconv.decimal_point], [], [],
21 [[#include <locale.h>]])
22])
diff --git a/gl/m4/lock.m4 b/gl/m4/lock.m4
index 9da8465..aae1701 100644
--- a/gl/m4/lock.m4
+++ b/gl/m4/lock.m4
@@ -1,5 +1,5 @@
1# lock.m4 serial 10 (gettext-0.18) 1# lock.m4 serial 13 (gettext-0.18.2)
2dnl Copyright (C) 2005-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2005-2013 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 @@ AC_DEFUN([gl_LOCK],
10[ 10[
11 AC_REQUIRE([gl_THREADLIB]) 11 AC_REQUIRE([gl_THREADLIB])
12 if test "$gl_threads_api" = posix; then 12 if test "$gl_threads_api" = posix; then
13 # OSF/1 4.0 and MacOS X 10.1 lack the pthread_rwlock_t type and the 13 # OSF/1 4.0 and Mac OS X 10.1 lack the pthread_rwlock_t type and the
14 # pthread_rwlock_* functions. 14 # pthread_rwlock_* functions.
15 AC_CHECK_TYPE([pthread_rwlock_t], 15 AC_CHECK_TYPE([pthread_rwlock_t],
16 [AC_DEFINE([HAVE_PTHREAD_RWLOCK], [1], 16 [AC_DEFINE([HAVE_PTHREAD_RWLOCK], [1],
@@ -18,20 +18,25 @@ AC_DEFUN([gl_LOCK],
18 [], 18 [],
19 [#include <pthread.h>]) 19 [#include <pthread.h>])
20 # glibc defines PTHREAD_MUTEX_RECURSIVE as enum, not as a macro. 20 # glibc defines PTHREAD_MUTEX_RECURSIVE as enum, not as a macro.
21 AC_TRY_COMPILE([#include <pthread.h>], 21 AC_COMPILE_IFELSE([
22 [#if __FreeBSD__ == 4 22 AC_LANG_PROGRAM(
23 [[#include <pthread.h>]],
24 [[
25#if __FreeBSD__ == 4
23error "No, in FreeBSD 4.0 recursive mutexes actually don't work." 26error "No, in FreeBSD 4.0 recursive mutexes actually don't work."
27#elif (defined __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ \
28 && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070)
29error "No, in Mac OS X < 10.7 recursive mutexes actually don't work."
24#else 30#else
25int x = (int)PTHREAD_MUTEX_RECURSIVE; 31int x = (int)PTHREAD_MUTEX_RECURSIVE;
26return !x; 32return !x;
27#endif], 33#endif
34 ]])],
28 [AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE], [1], 35 [AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE], [1],
29 [Define if the <pthread.h> defines PTHREAD_MUTEX_RECURSIVE.])]) 36 [Define if the <pthread.h> defines PTHREAD_MUTEX_RECURSIVE.])])
30 fi 37 fi
31 gl_PREREQ_LOCK 38 gl_PREREQ_LOCK
32]) 39])
33 40
34# Prerequisites of lib/lock.c. 41# Prerequisites of lib/glthread/lock.c.
35AC_DEFUN([gl_PREREQ_LOCK], [ 42AC_DEFUN([gl_PREREQ_LOCK], [:])
36 AC_REQUIRE([AC_C_INLINE])
37])
diff --git a/gl/m4/longlong.m4 b/gl/m4/longlong.m4
index cca3c1a..3af6ab5 100644
--- a/gl/m4/longlong.m4
+++ b/gl/m4/longlong.m4
@@ -1,5 +1,5 @@
1# longlong.m4 serial 14 1# longlong.m4 serial 17
2dnl Copyright (C) 1999-2007, 2009-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 1999-2007, 2009-2013 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,8 @@ dnl with or without modifications, as long as this notice is preserved.
7dnl From Paul Eggert. 7dnl From Paul Eggert.
8 8
9# Define HAVE_LONG_LONG_INT if 'long long int' works. 9# Define HAVE_LONG_LONG_INT if 'long long int' works.
10# This fixes a bug in Autoconf 2.61, but can be removed once we 10# This fixes a bug in Autoconf 2.61, and can be faster
11# assume 2.62 everywhere. 11# than what's in Autoconf 2.62 through 2.68.
12 12
13# Note: If the type 'long long int' exists but is only 32 bits large 13# Note: If the type 'long long int' exists but is only 32 bits large
14# (as on some very old compilers), HAVE_LONG_LONG_INT will not be 14# (as on some very old compilers), HAVE_LONG_LONG_INT will not be
@@ -16,44 +16,48 @@ dnl From Paul Eggert.
16 16
17AC_DEFUN([AC_TYPE_LONG_LONG_INT], 17AC_DEFUN([AC_TYPE_LONG_LONG_INT],
18[ 18[
19 AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
19 AC_CACHE_CHECK([for long long int], [ac_cv_type_long_long_int], 20 AC_CACHE_CHECK([for long long int], [ac_cv_type_long_long_int],
20 [AC_LINK_IFELSE( 21 [ac_cv_type_long_long_int=yes
21 [_AC_TYPE_LONG_LONG_SNIPPET], 22 if test "x${ac_cv_prog_cc_c99-no}" = xno; then
22 [dnl This catches a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004. 23 ac_cv_type_long_long_int=$ac_cv_type_unsigned_long_long_int
23 dnl If cross compiling, assume the bug isn't important, since 24 if test $ac_cv_type_long_long_int = yes; then
24 dnl nobody cross compiles for this platform as far as we know. 25 dnl Catch a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004.
25 AC_RUN_IFELSE( 26 dnl If cross compiling, assume the bug is not important, since
26 [AC_LANG_PROGRAM( 27 dnl nobody cross compiles for this platform as far as we know.
27 [[@%:@include <limits.h> 28 AC_RUN_IFELSE(
28 @%:@ifndef LLONG_MAX 29 [AC_LANG_PROGRAM(
29 @%:@ define HALF \ 30 [[@%:@include <limits.h>
30 (1LL << (sizeof (long long int) * CHAR_BIT - 2)) 31 @%:@ifndef LLONG_MAX
31 @%:@ define LLONG_MAX (HALF - 1 + HALF) 32 @%:@ define HALF \
32 @%:@endif]], 33 (1LL << (sizeof (long long int) * CHAR_BIT - 2))
33 [[long long int n = 1; 34 @%:@ define LLONG_MAX (HALF - 1 + HALF)
34 int i; 35 @%:@endif]],
35 for (i = 0; ; i++) 36 [[long long int n = 1;
36 { 37 int i;
37 long long int m = n << i; 38 for (i = 0; ; i++)
38 if (m >> i != n) 39 {
39 return 1; 40 long long int m = n << i;
40 if (LLONG_MAX / 2 < m) 41 if (m >> i != n)
41 break; 42 return 1;
42 } 43 if (LLONG_MAX / 2 < m)
43 return 0;]])], 44 break;
44 [ac_cv_type_long_long_int=yes], 45 }
45 [ac_cv_type_long_long_int=no], 46 return 0;]])],
46 [ac_cv_type_long_long_int=yes])], 47 [],
47 [ac_cv_type_long_long_int=no])]) 48 [ac_cv_type_long_long_int=no],
49 [:])
50 fi
51 fi])
48 if test $ac_cv_type_long_long_int = yes; then 52 if test $ac_cv_type_long_long_int = yes; then
49 AC_DEFINE([HAVE_LONG_LONG_INT], [1], 53 AC_DEFINE([HAVE_LONG_LONG_INT], [1],
50 [Define to 1 if the system has the type `long long int'.]) 54 [Define to 1 if the system has the type 'long long int'.])
51 fi 55 fi
52]) 56])
53 57
54# Define HAVE_UNSIGNED_LONG_LONG_INT if 'unsigned long long int' works. 58# Define HAVE_UNSIGNED_LONG_LONG_INT if 'unsigned long long int' works.
55# This fixes a bug in Autoconf 2.61, but can be removed once we 59# This fixes a bug in Autoconf 2.61, and can be faster
56# assume 2.62 everywhere. 60# than what's in Autoconf 2.62 through 2.68.
57 61
58# Note: If the type 'unsigned long long int' exists but is only 32 bits 62# Note: If the type 'unsigned long long int' exists but is only 32 bits
59# large (as on some very old compilers), AC_TYPE_UNSIGNED_LONG_LONG_INT 63# large (as on some very old compilers), AC_TYPE_UNSIGNED_LONG_LONG_INT
@@ -64,13 +68,16 @@ AC_DEFUN([AC_TYPE_UNSIGNED_LONG_LONG_INT],
64[ 68[
65 AC_CACHE_CHECK([for unsigned long long int], 69 AC_CACHE_CHECK([for unsigned long long int],
66 [ac_cv_type_unsigned_long_long_int], 70 [ac_cv_type_unsigned_long_long_int],
67 [AC_LINK_IFELSE( 71 [ac_cv_type_unsigned_long_long_int=yes
68 [_AC_TYPE_LONG_LONG_SNIPPET], 72 if test "x${ac_cv_prog_cc_c99-no}" = xno; then
69 [ac_cv_type_unsigned_long_long_int=yes], 73 AC_LINK_IFELSE(
70 [ac_cv_type_unsigned_long_long_int=no])]) 74 [_AC_TYPE_LONG_LONG_SNIPPET],
75 [],
76 [ac_cv_type_unsigned_long_long_int=no])
77 fi])
71 if test $ac_cv_type_unsigned_long_long_int = yes; then 78 if test $ac_cv_type_unsigned_long_long_int = yes; then
72 AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], [1], 79 AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], [1],
73 [Define to 1 if the system has the type `unsigned long long int'.]) 80 [Define to 1 if the system has the type 'unsigned long long int'.])
74 fi 81 fi
75]) 82])
76 83
diff --git a/gl/m4/ls-mntd-fs.m4 b/gl/m4/ls-mntd-fs.m4
index 40b9336..fb116c8 100644
--- a/gl/m4/ls-mntd-fs.m4
+++ b/gl/m4/ls-mntd-fs.m4
@@ -1,7 +1,7 @@
1# serial 28 1# serial 30
2# How to list mounted file systems. 2# How to list mounted file systems.
3 3
4# Copyright (C) 1998-2004, 2006, 2009-2010 Free Software Foundation, Inc. 4# Copyright (C) 1998-2004, 2006, 2009-2013 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,
@@ -70,7 +70,7 @@ AC_FUNC_GETMNTENT
70# with other getmntent implementations. 70# with other getmntent implementations.
71 71
72# NOTE: Normally, I wouldn't use a check for system type as I've done for 72# NOTE: Normally, I wouldn't use a check for system type as I've done for
73# `CRAY' below since that goes against the whole autoconf philosophy. But 73# 'CRAY' below since that goes against the whole autoconf philosophy. But
74# I think there is too great a chance that some non-Cray system has a 74# I think there is too great a chance that some non-Cray system has a
75# function named listmntent to risk the false positive. 75# function named listmntent to risk the false positive.
76 76
@@ -110,7 +110,7 @@ if test -z "$ac_list_mounted_fs"; then
110 AC_DEFINE([MOUNTED_VMOUNT], [1], 110 AC_DEFINE([MOUNTED_VMOUNT], [1],
111 [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
112 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
113 that declares `struct vmount.' (AIX)]) 113 that declares 'struct vmount'. (AIX)])
114 fi 114 fi
115fi 115fi
116 116
@@ -247,7 +247,11 @@ if test -z "$ac_list_mounted_fs"; then
247#if HAVE_SYS_STATVFS_H 247#if HAVE_SYS_STATVFS_H
248# include <sys/statvfs.h> 248# include <sys/statvfs.h>
249#endif 249#endif
250extern int getmntinfo (struct statfs **, int); 250extern
251#ifdef __cplusplus
252"C"
253#endif
254int getmntinfo (struct statfs **, int);
251 ]], [])], 255 ]], [])],
252 [fu_cv_sys_mounted_getmntinfo2=no], 256 [fu_cv_sys_mounted_getmntinfo2=no],
253 [fu_cv_sys_mounted_getmntinfo2=yes]) 257 [fu_cv_sys_mounted_getmntinfo2=yes])
@@ -326,6 +330,23 @@ if test -z "$ac_list_mounted_fs"; then
326fi 330fi
327 331
328if test -z "$ac_list_mounted_fs"; then 332if test -z "$ac_list_mounted_fs"; then
333 # Interix / BSD alike statvfs
334 # the code is really interix specific, so make sure, we're on it.
335 case "$host" in
336 *-interix*)
337 AC_CHECK_FUNCS([statvfs])
338 if test $ac_cv_func_statvfs = yes; then
339 ac_list_mounted_fs=found
340 AC_DEFINE([MOUNTED_INTERIX_STATVFS], [1],
341 [Define if we are on interix, and ought to use statvfs plus
342 some special knowledge on where mounted file systems can be
343 found. (Interix)])
344 fi
345 ;;
346 esac
347fi
348
349if test -z "$ac_list_mounted_fs"; then
329 AC_MSG_ERROR([could not determine how to read list of mounted file systems]) 350 AC_MSG_ERROR([could not determine how to read list of mounted file systems])
330 # FIXME -- no need to abort building the whole package 351 # FIXME -- no need to abort building the whole package
331 # Can't build mountlist.c or anything that needs its functions 352 # Can't build mountlist.c or anything that needs its functions
diff --git a/gl/m4/malloc.m4 b/gl/m4/malloc.m4
index fe5befc..4b24a0b 100644
--- a/gl/m4/malloc.m4
+++ b/gl/m4/malloc.m4
@@ -1,9 +1,47 @@
1# malloc.m4 serial 10 1# malloc.m4 serial 14
2dnl Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2007, 2009-2013 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
7m4_version_prereq([2.70], [] ,[
8
9# This is taken from the following Autoconf patch:
10# http://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=commitdiff;h=7fbb553727ed7e0e689a17594b58559ecf3ea6e9
11AC_DEFUN([_AC_FUNC_MALLOC_IF],
12[
13 AC_REQUIRE([AC_HEADER_STDC])dnl
14 AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles
15 AC_CHECK_HEADERS([stdlib.h])
16 AC_CACHE_CHECK([for GNU libc compatible malloc],
17 [ac_cv_func_malloc_0_nonnull],
18 [AC_RUN_IFELSE(
19 [AC_LANG_PROGRAM(
20 [[#if defined STDC_HEADERS || defined HAVE_STDLIB_H
21 # include <stdlib.h>
22 #else
23 char *malloc ();
24 #endif
25 ]],
26 [[return ! malloc (0);]])
27 ],
28 [ac_cv_func_malloc_0_nonnull=yes],
29 [ac_cv_func_malloc_0_nonnull=no],
30 [case "$host_os" in
31 # Guess yes on platforms where we know the result.
32 *-gnu* | freebsd* | netbsd* | openbsd* \
33 | hpux* | solaris* | cygwin* | mingw*)
34 ac_cv_func_malloc_0_nonnull=yes ;;
35 # If we don't know, assume the worst.
36 *) ac_cv_func_malloc_0_nonnull=no ;;
37 esac
38 ])
39 ])
40 AS_IF([test $ac_cv_func_malloc_0_nonnull = yes], [$1], [$2])
41])# _AC_FUNC_MALLOC_IF
42
43])
44
7# gl_FUNC_MALLOC_GNU 45# gl_FUNC_MALLOC_GNU
8# ------------------ 46# ------------------
9# Test whether 'malloc (0)' is handled like in GNU libc, and replace malloc if 47# Test whether 'malloc (0)' is handled like in GNU libc, and replace malloc if
@@ -13,11 +51,11 @@ AC_DEFUN([gl_FUNC_MALLOC_GNU],
13 AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) 51 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
14 dnl _AC_FUNC_MALLOC_IF is defined in Autoconf. 52 dnl _AC_FUNC_MALLOC_IF is defined in Autoconf.
15 _AC_FUNC_MALLOC_IF( 53 _AC_FUNC_MALLOC_IF(
16 [AC_DEFINE([HAVE_MALLOC], [1], 54 [AC_DEFINE([HAVE_MALLOC_GNU], [1],
17 [Define to 1 if your system has a GNU libc compatible 'malloc' 55 [Define to 1 if your system has a GNU libc compatible 'malloc'
18 function, and to 0 otherwise.])], 56 function, and to 0 otherwise.])],
19 [AC_DEFINE([HAVE_MALLOC], [0]) 57 [AC_DEFINE([HAVE_MALLOC_GNU], [0])
20 gl_REPLACE_MALLOC 58 REPLACE_MALLOC=1
21 ]) 59 ])
22]) 60])
23 61
@@ -33,7 +71,7 @@ AC_DEFUN([gl_FUNC_MALLOC_POSIX],
33 AC_DEFINE([HAVE_MALLOC_POSIX], [1], 71 AC_DEFINE([HAVE_MALLOC_POSIX], [1],
34 [Define if the 'malloc' function is POSIX compliant.]) 72 [Define if the 'malloc' function is POSIX compliant.])
35 else 73 else
36 gl_REPLACE_MALLOC 74 REPLACE_MALLOC=1
37 fi 75 fi
38]) 76])
39 77
@@ -47,16 +85,14 @@ AC_DEFUN([gl_CHECK_MALLOC_POSIX],
47 dnl It is too dangerous to try to allocate a large amount of memory: 85 dnl It is too dangerous to try to allocate a large amount of memory:
48 dnl some systems go to their knees when you do that. So assume that 86 dnl some systems go to their knees when you do that. So assume that
49 dnl all Unix implementations of the function are POSIX compliant. 87 dnl all Unix implementations of the function are POSIX compliant.
50 AC_TRY_COMPILE([], 88 AC_COMPILE_IFELSE(
51 [#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 89 [AC_LANG_PROGRAM(
52 choke me 90 [[]],
53 #endif 91 [[#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
54 ], [gl_cv_func_malloc_posix=yes], [gl_cv_func_malloc_posix=no]) 92 choke me
93 #endif
94 ]])],
95 [gl_cv_func_malloc_posix=yes],
96 [gl_cv_func_malloc_posix=no])
55 ]) 97 ])
56]) 98])
57
58AC_DEFUN([gl_REPLACE_MALLOC],
59[
60 AC_LIBOBJ([malloc])
61 REPLACE_MALLOC=1
62])
diff --git a/gl/m4/malloca.m4 b/gl/m4/malloca.m4
index e07c6d9..791ce10 100644
--- a/gl/m4/malloca.m4
+++ b/gl/m4/malloca.m4
@@ -1,5 +1,5 @@
1# malloca.m4 serial 1 1# malloca.m4 serial 1
2dnl Copyright (C) 2003-2004, 2006-2007, 2009-2010 Free Software Foundation, 2dnl Copyright (C) 2003-2004, 2006-2007, 2009-2013 Free Software Foundation,
3dnl Inc. 3dnl Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
diff --git a/gl/m4/math_h.m4 b/gl/m4/math_h.m4
index 2d89ca3..bf0845f 100644
--- a/gl/m4/math_h.m4
+++ b/gl/m4/math_h.m4
@@ -1,5 +1,5 @@
1# math_h.m4 serial 21 1# math_h.m4 serial 114
2dnl Copyright (C) 2007-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2007-2013 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,6 @@ 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_REQUIRE([AC_C_INLINE])
12 11
13 AC_CACHE_CHECK([whether NAN macro works], [gl_cv_header_math_nan_works], 12 AC_CACHE_CHECK([whether NAN macro works], [gl_cv_header_math_nan_works],
14 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <math.h>]], 13 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include <math.h>]],
@@ -38,9 +37,20 @@ AC_DEFUN([gl_MATH_H],
38 37
39 dnl Check for declarations of anything we want to poison if the 38 dnl Check for declarations of anything we want to poison if the
40 dnl corresponding gnulib module is not in use. 39 dnl corresponding gnulib module is not in use.
41 gl_WARN_ON_USE_PREPARE([[#include <math.h> 40 gl_WARN_ON_USE_PREPARE([[#include <math.h>]],
42 ]], [acosl asinl atanl ceilf ceill cosl expl floorf floorl frexpl 41 [acosf acosl asinf asinl atanf atanl
43 ldexpl logb logl round roundf roundl sinl sqrtl tanl trunc truncf truncl]) 42 cbrt cbrtf cbrtl ceilf ceill copysign copysignf copysignl cosf cosl coshf
43 expf expl exp2 exp2f exp2l expm1 expm1f expm1l
44 fabsf fabsl floorf floorl fma fmaf fmal
45 fmod fmodf fmodl frexpf frexpl hypotf hypotl
46 ilogb ilogbf ilogbl
47 ldexpf ldexpl
48 log logf logl log10 log10f log10l log1p log1pf log1pl log2 log2f log2l
49 logb logbf logbl
50 modf modff modfl powf
51 remainder remainderf remainderl
52 rint rintf rintl round roundf roundl sinf sinl sinhf sqrtf sqrtl
53 tanf tanl tanhf trunc truncf truncl])
44]) 54])
45 55
46AC_DEFUN([gl_MATH_MODULE_INDICATOR], 56AC_DEFUN([gl_MATH_MODULE_INDICATOR],
@@ -54,62 +64,189 @@ AC_DEFUN([gl_MATH_MODULE_INDICATOR],
54 64
55AC_DEFUN([gl_MATH_H_DEFAULTS], 65AC_DEFUN([gl_MATH_H_DEFAULTS],
56[ 66[
57 GNULIB_ACOSL=0; AC_SUBST([GNULIB_ACOSL]) 67 GNULIB_ACOSF=0; AC_SUBST([GNULIB_ACOSF])
58 GNULIB_ASINL=0; AC_SUBST([GNULIB_ASINL]) 68 GNULIB_ACOSL=0; AC_SUBST([GNULIB_ACOSL])
59 GNULIB_ATANL=0; AC_SUBST([GNULIB_ATANL]) 69 GNULIB_ASINF=0; AC_SUBST([GNULIB_ASINF])
60 GNULIB_CEILF=0; AC_SUBST([GNULIB_CEILF]) 70 GNULIB_ASINL=0; AC_SUBST([GNULIB_ASINL])
61 GNULIB_CEILL=0; AC_SUBST([GNULIB_CEILL]) 71 GNULIB_ATANF=0; AC_SUBST([GNULIB_ATANF])
62 GNULIB_COSL=0; AC_SUBST([GNULIB_COSL]) 72 GNULIB_ATANL=0; AC_SUBST([GNULIB_ATANL])
63 GNULIB_EXPL=0; AC_SUBST([GNULIB_EXPL]) 73 GNULIB_ATAN2F=0; AC_SUBST([GNULIB_ATAN2F])
64 GNULIB_FLOORF=0; AC_SUBST([GNULIB_FLOORF]) 74 GNULIB_CBRT=0; AC_SUBST([GNULIB_CBRT])
65 GNULIB_FLOORL=0; AC_SUBST([GNULIB_FLOORL]) 75 GNULIB_CBRTF=0; AC_SUBST([GNULIB_CBRTF])
66 GNULIB_FREXP=0; AC_SUBST([GNULIB_FREXP]) 76 GNULIB_CBRTL=0; AC_SUBST([GNULIB_CBRTL])
67 GNULIB_FREXPL=0; AC_SUBST([GNULIB_FREXPL]) 77 GNULIB_CEIL=0; AC_SUBST([GNULIB_CEIL])
68 GNULIB_ISFINITE=0; AC_SUBST([GNULIB_ISFINITE]) 78 GNULIB_CEILF=0; AC_SUBST([GNULIB_CEILF])
69 GNULIB_ISINF=0; AC_SUBST([GNULIB_ISINF]) 79 GNULIB_CEILL=0; AC_SUBST([GNULIB_CEILL])
70 GNULIB_ISNAN=0; AC_SUBST([GNULIB_ISNAN]) 80 GNULIB_COPYSIGN=0; AC_SUBST([GNULIB_COPYSIGN])
71 GNULIB_ISNANF=0; AC_SUBST([GNULIB_ISNANF]) 81 GNULIB_COPYSIGNF=0; AC_SUBST([GNULIB_COPYSIGNF])
72 GNULIB_ISNAND=0; AC_SUBST([GNULIB_ISNAND]) 82 GNULIB_COPYSIGNL=0; AC_SUBST([GNULIB_COPYSIGNL])
73 GNULIB_ISNANL=0; AC_SUBST([GNULIB_ISNANL]) 83 GNULIB_COSF=0; AC_SUBST([GNULIB_COSF])
74 GNULIB_LDEXPL=0; AC_SUBST([GNULIB_LDEXPL]) 84 GNULIB_COSL=0; AC_SUBST([GNULIB_COSL])
75 GNULIB_LOGB=0; AC_SUBST([GNULIB_LOGB]) 85 GNULIB_COSHF=0; AC_SUBST([GNULIB_COSHF])
76 GNULIB_LOGL=0; AC_SUBST([GNULIB_LOGL]) 86 GNULIB_EXPF=0; AC_SUBST([GNULIB_EXPF])
77 GNULIB_ROUND=0; AC_SUBST([GNULIB_ROUND]) 87 GNULIB_EXPL=0; AC_SUBST([GNULIB_EXPL])
78 GNULIB_ROUNDF=0; AC_SUBST([GNULIB_ROUNDF]) 88 GNULIB_EXP2=0; AC_SUBST([GNULIB_EXP2])
79 GNULIB_ROUNDL=0; AC_SUBST([GNULIB_ROUNDL]) 89 GNULIB_EXP2F=0; AC_SUBST([GNULIB_EXP2F])
80 GNULIB_SIGNBIT=0; AC_SUBST([GNULIB_SIGNBIT]) 90 GNULIB_EXP2L=0; AC_SUBST([GNULIB_EXP2L])
81 GNULIB_SINL=0; AC_SUBST([GNULIB_SINL]) 91 GNULIB_EXPM1=0; AC_SUBST([GNULIB_EXPM1])
82 GNULIB_SQRTL=0; AC_SUBST([GNULIB_SQRTL]) 92 GNULIB_EXPM1F=0; AC_SUBST([GNULIB_EXPM1F])
83 GNULIB_TANL=0; AC_SUBST([GNULIB_TANL]) 93 GNULIB_EXPM1L=0; AC_SUBST([GNULIB_EXPM1L])
84 GNULIB_TRUNC=0; AC_SUBST([GNULIB_TRUNC]) 94 GNULIB_FABSF=0; AC_SUBST([GNULIB_FABSF])
85 GNULIB_TRUNCF=0; AC_SUBST([GNULIB_TRUNCF]) 95 GNULIB_FABSL=0; AC_SUBST([GNULIB_FABSL])
86 GNULIB_TRUNCL=0; AC_SUBST([GNULIB_TRUNCL]) 96 GNULIB_FLOOR=0; AC_SUBST([GNULIB_FLOOR])
97 GNULIB_FLOORF=0; AC_SUBST([GNULIB_FLOORF])
98 GNULIB_FLOORL=0; AC_SUBST([GNULIB_FLOORL])
99 GNULIB_FMA=0; AC_SUBST([GNULIB_FMA])
100 GNULIB_FMAF=0; AC_SUBST([GNULIB_FMAF])
101 GNULIB_FMAL=0; AC_SUBST([GNULIB_FMAL])
102 GNULIB_FMOD=0; AC_SUBST([GNULIB_FMOD])
103 GNULIB_FMODF=0; AC_SUBST([GNULIB_FMODF])
104 GNULIB_FMODL=0; AC_SUBST([GNULIB_FMODL])
105 GNULIB_FREXPF=0; AC_SUBST([GNULIB_FREXPF])
106 GNULIB_FREXP=0; AC_SUBST([GNULIB_FREXP])
107 GNULIB_FREXPL=0; AC_SUBST([GNULIB_FREXPL])
108 GNULIB_HYPOT=0; AC_SUBST([GNULIB_HYPOT])
109 GNULIB_HYPOTF=0; AC_SUBST([GNULIB_HYPOTF])
110 GNULIB_HYPOTL=0; AC_SUBST([GNULIB_HYPOTL])
111 GNULIB_ILOGB=0; AC_SUBST([GNULIB_ILOGB])
112 GNULIB_ILOGBF=0; AC_SUBST([GNULIB_ILOGBF])
113 GNULIB_ILOGBL=0; AC_SUBST([GNULIB_ILOGBL])
114 GNULIB_ISFINITE=0; AC_SUBST([GNULIB_ISFINITE])
115 GNULIB_ISINF=0; AC_SUBST([GNULIB_ISINF])
116 GNULIB_ISNAN=0; AC_SUBST([GNULIB_ISNAN])
117 GNULIB_ISNANF=0; AC_SUBST([GNULIB_ISNANF])
118 GNULIB_ISNAND=0; AC_SUBST([GNULIB_ISNAND])
119 GNULIB_ISNANL=0; AC_SUBST([GNULIB_ISNANL])
120 GNULIB_LDEXPF=0; AC_SUBST([GNULIB_LDEXPF])
121 GNULIB_LDEXPL=0; AC_SUBST([GNULIB_LDEXPL])
122 GNULIB_LOG=0; AC_SUBST([GNULIB_LOG])
123 GNULIB_LOGF=0; AC_SUBST([GNULIB_LOGF])
124 GNULIB_LOGL=0; AC_SUBST([GNULIB_LOGL])
125 GNULIB_LOG10=0; AC_SUBST([GNULIB_LOG10])
126 GNULIB_LOG10F=0; AC_SUBST([GNULIB_LOG10F])
127 GNULIB_LOG10L=0; AC_SUBST([GNULIB_LOG10L])
128 GNULIB_LOG1P=0; AC_SUBST([GNULIB_LOG1P])
129 GNULIB_LOG1PF=0; AC_SUBST([GNULIB_LOG1PF])
130 GNULIB_LOG1PL=0; AC_SUBST([GNULIB_LOG1PL])
131 GNULIB_LOG2=0; AC_SUBST([GNULIB_LOG2])
132 GNULIB_LOG2F=0; AC_SUBST([GNULIB_LOG2F])
133 GNULIB_LOG2L=0; AC_SUBST([GNULIB_LOG2L])
134 GNULIB_LOGB=0; AC_SUBST([GNULIB_LOGB])
135 GNULIB_LOGBF=0; AC_SUBST([GNULIB_LOGBF])
136 GNULIB_LOGBL=0; AC_SUBST([GNULIB_LOGBL])
137 GNULIB_MODF=0; AC_SUBST([GNULIB_MODF])
138 GNULIB_MODFF=0; AC_SUBST([GNULIB_MODFF])
139 GNULIB_MODFL=0; AC_SUBST([GNULIB_MODFL])
140 GNULIB_POWF=0; AC_SUBST([GNULIB_POWF])
141 GNULIB_REMAINDER=0; AC_SUBST([GNULIB_REMAINDER])
142 GNULIB_REMAINDERF=0; AC_SUBST([GNULIB_REMAINDERF])
143 GNULIB_REMAINDERL=0; AC_SUBST([GNULIB_REMAINDERL])
144 GNULIB_RINT=0; AC_SUBST([GNULIB_RINT])
145 GNULIB_RINTF=0; AC_SUBST([GNULIB_RINTF])
146 GNULIB_RINTL=0; AC_SUBST([GNULIB_RINTL])
147 GNULIB_ROUND=0; AC_SUBST([GNULIB_ROUND])
148 GNULIB_ROUNDF=0; AC_SUBST([GNULIB_ROUNDF])
149 GNULIB_ROUNDL=0; AC_SUBST([GNULIB_ROUNDL])
150 GNULIB_SIGNBIT=0; AC_SUBST([GNULIB_SIGNBIT])
151 GNULIB_SINF=0; AC_SUBST([GNULIB_SINF])
152 GNULIB_SINL=0; AC_SUBST([GNULIB_SINL])
153 GNULIB_SINHF=0; AC_SUBST([GNULIB_SINHF])
154 GNULIB_SQRTF=0; AC_SUBST([GNULIB_SQRTF])
155 GNULIB_SQRTL=0; AC_SUBST([GNULIB_SQRTL])
156 GNULIB_TANF=0; AC_SUBST([GNULIB_TANF])
157 GNULIB_TANL=0; AC_SUBST([GNULIB_TANL])
158 GNULIB_TANHF=0; AC_SUBST([GNULIB_TANHF])
159 GNULIB_TRUNC=0; AC_SUBST([GNULIB_TRUNC])
160 GNULIB_TRUNCF=0; AC_SUBST([GNULIB_TRUNCF])
161 GNULIB_TRUNCL=0; AC_SUBST([GNULIB_TRUNCL])
87 dnl Assume proper GNU behavior unless another module says otherwise. 162 dnl Assume proper GNU behavior unless another module says otherwise.
163 HAVE_ACOSF=1; AC_SUBST([HAVE_ACOSF])
88 HAVE_ACOSL=1; AC_SUBST([HAVE_ACOSL]) 164 HAVE_ACOSL=1; AC_SUBST([HAVE_ACOSL])
165 HAVE_ASINF=1; AC_SUBST([HAVE_ASINF])
89 HAVE_ASINL=1; AC_SUBST([HAVE_ASINL]) 166 HAVE_ASINL=1; AC_SUBST([HAVE_ASINL])
167 HAVE_ATANF=1; AC_SUBST([HAVE_ATANF])
90 HAVE_ATANL=1; AC_SUBST([HAVE_ATANL]) 168 HAVE_ATANL=1; AC_SUBST([HAVE_ATANL])
169 HAVE_ATAN2F=1; AC_SUBST([HAVE_ATAN2F])
170 HAVE_CBRT=1; AC_SUBST([HAVE_CBRT])
171 HAVE_CBRTF=1; AC_SUBST([HAVE_CBRTF])
172 HAVE_CBRTL=1; AC_SUBST([HAVE_CBRTL])
173 HAVE_COPYSIGN=1; AC_SUBST([HAVE_COPYSIGN])
174 HAVE_COPYSIGNL=1; AC_SUBST([HAVE_COPYSIGNL])
175 HAVE_COSF=1; AC_SUBST([HAVE_COSF])
91 HAVE_COSL=1; AC_SUBST([HAVE_COSL]) 176 HAVE_COSL=1; AC_SUBST([HAVE_COSL])
177 HAVE_COSHF=1; AC_SUBST([HAVE_COSHF])
178 HAVE_EXPF=1; AC_SUBST([HAVE_EXPF])
92 HAVE_EXPL=1; AC_SUBST([HAVE_EXPL]) 179 HAVE_EXPL=1; AC_SUBST([HAVE_EXPL])
180 HAVE_EXPM1=1; AC_SUBST([HAVE_EXPM1])
181 HAVE_EXPM1F=1; AC_SUBST([HAVE_EXPM1F])
182 HAVE_FABSF=1; AC_SUBST([HAVE_FABSF])
183 HAVE_FABSL=1; AC_SUBST([HAVE_FABSL])
184 HAVE_FMA=1; AC_SUBST([HAVE_FMA])
185 HAVE_FMAF=1; AC_SUBST([HAVE_FMAF])
186 HAVE_FMAL=1; AC_SUBST([HAVE_FMAL])
187 HAVE_FMODF=1; AC_SUBST([HAVE_FMODF])
188 HAVE_FMODL=1; AC_SUBST([HAVE_FMODL])
189 HAVE_FREXPF=1; AC_SUBST([HAVE_FREXPF])
190 HAVE_HYPOTF=1; AC_SUBST([HAVE_HYPOTF])
191 HAVE_HYPOTL=1; AC_SUBST([HAVE_HYPOTL])
192 HAVE_ILOGB=1; AC_SUBST([HAVE_ILOGB])
193 HAVE_ILOGBF=1; AC_SUBST([HAVE_ILOGBF])
194 HAVE_ILOGBL=1; AC_SUBST([HAVE_ILOGBL])
93 HAVE_ISNANF=1; AC_SUBST([HAVE_ISNANF]) 195 HAVE_ISNANF=1; AC_SUBST([HAVE_ISNANF])
94 HAVE_ISNAND=1; AC_SUBST([HAVE_ISNAND]) 196 HAVE_ISNAND=1; AC_SUBST([HAVE_ISNAND])
95 HAVE_ISNANL=1; AC_SUBST([HAVE_ISNANL]) 197 HAVE_ISNANL=1; AC_SUBST([HAVE_ISNANL])
198 HAVE_LDEXPF=1; AC_SUBST([HAVE_LDEXPF])
199 HAVE_LOGF=1; AC_SUBST([HAVE_LOGF])
96 HAVE_LOGL=1; AC_SUBST([HAVE_LOGL]) 200 HAVE_LOGL=1; AC_SUBST([HAVE_LOGL])
201 HAVE_LOG10F=1; AC_SUBST([HAVE_LOG10F])
202 HAVE_LOG10L=1; AC_SUBST([HAVE_LOG10L])
203 HAVE_LOG1P=1; AC_SUBST([HAVE_LOG1P])
204 HAVE_LOG1PF=1; AC_SUBST([HAVE_LOG1PF])
205 HAVE_LOG1PL=1; AC_SUBST([HAVE_LOG1PL])
206 HAVE_LOGBF=1; AC_SUBST([HAVE_LOGBF])
207 HAVE_LOGBL=1; AC_SUBST([HAVE_LOGBL])
208 HAVE_MODFF=1; AC_SUBST([HAVE_MODFF])
209 HAVE_MODFL=1; AC_SUBST([HAVE_MODFL])
210 HAVE_POWF=1; AC_SUBST([HAVE_POWF])
211 HAVE_REMAINDER=1; AC_SUBST([HAVE_REMAINDER])
212 HAVE_REMAINDERF=1; AC_SUBST([HAVE_REMAINDERF])
213 HAVE_RINT=1; AC_SUBST([HAVE_RINT])
214 HAVE_RINTL=1; AC_SUBST([HAVE_RINTL])
215 HAVE_SINF=1; AC_SUBST([HAVE_SINF])
97 HAVE_SINL=1; AC_SUBST([HAVE_SINL]) 216 HAVE_SINL=1; AC_SUBST([HAVE_SINL])
217 HAVE_SINHF=1; AC_SUBST([HAVE_SINHF])
218 HAVE_SQRTF=1; AC_SUBST([HAVE_SQRTF])
98 HAVE_SQRTL=1; AC_SUBST([HAVE_SQRTL]) 219 HAVE_SQRTL=1; AC_SUBST([HAVE_SQRTL])
220 HAVE_TANF=1; AC_SUBST([HAVE_TANF])
99 HAVE_TANL=1; AC_SUBST([HAVE_TANL]) 221 HAVE_TANL=1; AC_SUBST([HAVE_TANL])
222 HAVE_TANHF=1; AC_SUBST([HAVE_TANHF])
100 HAVE_DECL_ACOSL=1; AC_SUBST([HAVE_DECL_ACOSL]) 223 HAVE_DECL_ACOSL=1; AC_SUBST([HAVE_DECL_ACOSL])
101 HAVE_DECL_ASINL=1; AC_SUBST([HAVE_DECL_ASINL]) 224 HAVE_DECL_ASINL=1; AC_SUBST([HAVE_DECL_ASINL])
102 HAVE_DECL_ATANL=1; AC_SUBST([HAVE_DECL_ATANL]) 225 HAVE_DECL_ATANL=1; AC_SUBST([HAVE_DECL_ATANL])
226 HAVE_DECL_CBRTF=1; AC_SUBST([HAVE_DECL_CBRTF])
227 HAVE_DECL_CBRTL=1; AC_SUBST([HAVE_DECL_CBRTL])
103 HAVE_DECL_CEILF=1; AC_SUBST([HAVE_DECL_CEILF]) 228 HAVE_DECL_CEILF=1; AC_SUBST([HAVE_DECL_CEILF])
104 HAVE_DECL_CEILL=1; AC_SUBST([HAVE_DECL_CEILL]) 229 HAVE_DECL_CEILL=1; AC_SUBST([HAVE_DECL_CEILL])
230 HAVE_DECL_COPYSIGNF=1; AC_SUBST([HAVE_DECL_COPYSIGNF])
105 HAVE_DECL_COSL=1; AC_SUBST([HAVE_DECL_COSL]) 231 HAVE_DECL_COSL=1; AC_SUBST([HAVE_DECL_COSL])
106 HAVE_DECL_EXPL=1; AC_SUBST([HAVE_DECL_EXPL]) 232 HAVE_DECL_EXPL=1; AC_SUBST([HAVE_DECL_EXPL])
233 HAVE_DECL_EXP2=1; AC_SUBST([HAVE_DECL_EXP2])
234 HAVE_DECL_EXP2F=1; AC_SUBST([HAVE_DECL_EXP2F])
235 HAVE_DECL_EXP2L=1; AC_SUBST([HAVE_DECL_EXP2L])
236 HAVE_DECL_EXPM1L=1; AC_SUBST([HAVE_DECL_EXPM1L])
107 HAVE_DECL_FLOORF=1; AC_SUBST([HAVE_DECL_FLOORF]) 237 HAVE_DECL_FLOORF=1; AC_SUBST([HAVE_DECL_FLOORF])
108 HAVE_DECL_FLOORL=1; AC_SUBST([HAVE_DECL_FLOORL]) 238 HAVE_DECL_FLOORL=1; AC_SUBST([HAVE_DECL_FLOORL])
109 HAVE_DECL_FREXPL=1; AC_SUBST([HAVE_DECL_FREXPL]) 239 HAVE_DECL_FREXPL=1; AC_SUBST([HAVE_DECL_FREXPL])
110 HAVE_DECL_LDEXPL=1; AC_SUBST([HAVE_DECL_LDEXPL]) 240 HAVE_DECL_LDEXPL=1; AC_SUBST([HAVE_DECL_LDEXPL])
111 HAVE_DECL_LOGB=1; AC_SUBST([HAVE_DECL_LOGB])
112 HAVE_DECL_LOGL=1; AC_SUBST([HAVE_DECL_LOGL]) 241 HAVE_DECL_LOGL=1; AC_SUBST([HAVE_DECL_LOGL])
242 HAVE_DECL_LOG10L=1; AC_SUBST([HAVE_DECL_LOG10L])
243 HAVE_DECL_LOG2=1; AC_SUBST([HAVE_DECL_LOG2])
244 HAVE_DECL_LOG2F=1; AC_SUBST([HAVE_DECL_LOG2F])
245 HAVE_DECL_LOG2L=1; AC_SUBST([HAVE_DECL_LOG2L])
246 HAVE_DECL_LOGB=1; AC_SUBST([HAVE_DECL_LOGB])
247 HAVE_DECL_REMAINDER=1; AC_SUBST([HAVE_DECL_REMAINDER])
248 HAVE_DECL_REMAINDERL=1; AC_SUBST([HAVE_DECL_REMAINDERL])
249 HAVE_DECL_RINTF=1; AC_SUBST([HAVE_DECL_RINTF])
113 HAVE_DECL_ROUND=1; AC_SUBST([HAVE_DECL_ROUND]) 250 HAVE_DECL_ROUND=1; AC_SUBST([HAVE_DECL_ROUND])
114 HAVE_DECL_ROUNDF=1; AC_SUBST([HAVE_DECL_ROUNDF]) 251 HAVE_DECL_ROUNDF=1; AC_SUBST([HAVE_DECL_ROUNDF])
115 HAVE_DECL_ROUNDL=1; AC_SUBST([HAVE_DECL_ROUNDL]) 252 HAVE_DECL_ROUNDL=1; AC_SUBST([HAVE_DECL_ROUNDL])
@@ -119,22 +256,98 @@ AC_DEFUN([gl_MATH_H_DEFAULTS],
119 HAVE_DECL_TRUNC=1; AC_SUBST([HAVE_DECL_TRUNC]) 256 HAVE_DECL_TRUNC=1; AC_SUBST([HAVE_DECL_TRUNC])
120 HAVE_DECL_TRUNCF=1; AC_SUBST([HAVE_DECL_TRUNCF]) 257 HAVE_DECL_TRUNCF=1; AC_SUBST([HAVE_DECL_TRUNCF])
121 HAVE_DECL_TRUNCL=1; AC_SUBST([HAVE_DECL_TRUNCL]) 258 HAVE_DECL_TRUNCL=1; AC_SUBST([HAVE_DECL_TRUNCL])
259 REPLACE_CBRTF=0; AC_SUBST([REPLACE_CBRTF])
260 REPLACE_CBRTL=0; AC_SUBST([REPLACE_CBRTL])
261 REPLACE_CEIL=0; AC_SUBST([REPLACE_CEIL])
122 REPLACE_CEILF=0; AC_SUBST([REPLACE_CEILF]) 262 REPLACE_CEILF=0; AC_SUBST([REPLACE_CEILF])
123 REPLACE_CEILL=0; AC_SUBST([REPLACE_CEILL]) 263 REPLACE_CEILL=0; AC_SUBST([REPLACE_CEILL])
264 REPLACE_EXPM1=0; AC_SUBST([REPLACE_EXPM1])
265 REPLACE_EXPM1F=0; AC_SUBST([REPLACE_EXPM1F])
266 REPLACE_EXP2=0; AC_SUBST([REPLACE_EXP2])
267 REPLACE_EXP2L=0; AC_SUBST([REPLACE_EXP2L])
268 REPLACE_FABSL=0; AC_SUBST([REPLACE_FABSL])
269 REPLACE_FLOOR=0; AC_SUBST([REPLACE_FLOOR])
124 REPLACE_FLOORF=0; AC_SUBST([REPLACE_FLOORF]) 270 REPLACE_FLOORF=0; AC_SUBST([REPLACE_FLOORF])
125 REPLACE_FLOORL=0; AC_SUBST([REPLACE_FLOORL]) 271 REPLACE_FLOORL=0; AC_SUBST([REPLACE_FLOORL])
272 REPLACE_FMA=0; AC_SUBST([REPLACE_FMA])
273 REPLACE_FMAF=0; AC_SUBST([REPLACE_FMAF])
274 REPLACE_FMAL=0; AC_SUBST([REPLACE_FMAL])
275 REPLACE_FMOD=0; AC_SUBST([REPLACE_FMOD])
276 REPLACE_FMODF=0; AC_SUBST([REPLACE_FMODF])
277 REPLACE_FMODL=0; AC_SUBST([REPLACE_FMODL])
278 REPLACE_FREXPF=0; AC_SUBST([REPLACE_FREXPF])
126 REPLACE_FREXP=0; AC_SUBST([REPLACE_FREXP]) 279 REPLACE_FREXP=0; AC_SUBST([REPLACE_FREXP])
127 REPLACE_FREXPL=0; AC_SUBST([REPLACE_FREXPL]) 280 REPLACE_FREXPL=0; AC_SUBST([REPLACE_FREXPL])
128 REPLACE_HUGE_VAL=0; AC_SUBST([REPLACE_HUGE_VAL]) 281 REPLACE_HUGE_VAL=0; AC_SUBST([REPLACE_HUGE_VAL])
282 REPLACE_HYPOT=0; AC_SUBST([REPLACE_HYPOT])
283 REPLACE_HYPOTF=0; AC_SUBST([REPLACE_HYPOTF])
284 REPLACE_HYPOTL=0; AC_SUBST([REPLACE_HYPOTL])
285 REPLACE_ILOGB=0; AC_SUBST([REPLACE_ILOGB])
286 REPLACE_ILOGBF=0; AC_SUBST([REPLACE_ILOGBF])
129 REPLACE_ISFINITE=0; AC_SUBST([REPLACE_ISFINITE]) 287 REPLACE_ISFINITE=0; AC_SUBST([REPLACE_ISFINITE])
130 REPLACE_ISINF=0; AC_SUBST([REPLACE_ISINF]) 288 REPLACE_ISINF=0; AC_SUBST([REPLACE_ISINF])
131 REPLACE_ISNAN=0; AC_SUBST([REPLACE_ISNAN]) 289 REPLACE_ISNAN=0; AC_SUBST([REPLACE_ISNAN])
132 REPLACE_LDEXPL=0; AC_SUBST([REPLACE_LDEXPL]) 290 REPLACE_LDEXPL=0; AC_SUBST([REPLACE_LDEXPL])
291 REPLACE_LOG=0; AC_SUBST([REPLACE_LOG])
292 REPLACE_LOGF=0; AC_SUBST([REPLACE_LOGF])
293 REPLACE_LOGL=0; AC_SUBST([REPLACE_LOGL])
294 REPLACE_LOG10=0; AC_SUBST([REPLACE_LOG10])
295 REPLACE_LOG10F=0; AC_SUBST([REPLACE_LOG10F])
296 REPLACE_LOG10L=0; AC_SUBST([REPLACE_LOG10L])
297 REPLACE_LOG1P=0; AC_SUBST([REPLACE_LOG1P])
298 REPLACE_LOG1PF=0; AC_SUBST([REPLACE_LOG1PF])
299 REPLACE_LOG1PL=0; AC_SUBST([REPLACE_LOG1PL])
300 REPLACE_LOG2=0; AC_SUBST([REPLACE_LOG2])
301 REPLACE_LOG2F=0; AC_SUBST([REPLACE_LOG2F])
302 REPLACE_LOG2L=0; AC_SUBST([REPLACE_LOG2L])
303 REPLACE_LOGB=0; AC_SUBST([REPLACE_LOGB])
304 REPLACE_LOGBF=0; AC_SUBST([REPLACE_LOGBF])
305 REPLACE_LOGBL=0; AC_SUBST([REPLACE_LOGBL])
306 REPLACE_MODF=0; AC_SUBST([REPLACE_MODF])
307 REPLACE_MODFF=0; AC_SUBST([REPLACE_MODFF])
308 REPLACE_MODFL=0; AC_SUBST([REPLACE_MODFL])
133 REPLACE_NAN=0; AC_SUBST([REPLACE_NAN]) 309 REPLACE_NAN=0; AC_SUBST([REPLACE_NAN])
310 REPLACE_REMAINDER=0; AC_SUBST([REPLACE_REMAINDER])
311 REPLACE_REMAINDERF=0; AC_SUBST([REPLACE_REMAINDERF])
312 REPLACE_REMAINDERL=0; AC_SUBST([REPLACE_REMAINDERL])
134 REPLACE_ROUND=0; AC_SUBST([REPLACE_ROUND]) 313 REPLACE_ROUND=0; AC_SUBST([REPLACE_ROUND])
135 REPLACE_ROUNDF=0; AC_SUBST([REPLACE_ROUNDF]) 314 REPLACE_ROUNDF=0; AC_SUBST([REPLACE_ROUNDF])
136 REPLACE_ROUNDL=0; AC_SUBST([REPLACE_ROUNDL]) 315 REPLACE_ROUNDL=0; AC_SUBST([REPLACE_ROUNDL])
137 REPLACE_SIGNBIT=0; AC_SUBST([REPLACE_SIGNBIT]) 316 REPLACE_SIGNBIT=0; AC_SUBST([REPLACE_SIGNBIT])
138 REPLACE_SIGNBIT_USING_GCC=0; AC_SUBST([REPLACE_SIGNBIT_USING_GCC]) 317 REPLACE_SIGNBIT_USING_GCC=0; AC_SUBST([REPLACE_SIGNBIT_USING_GCC])
318 REPLACE_SQRTL=0; AC_SUBST([REPLACE_SQRTL])
319 REPLACE_TRUNC=0; AC_SUBST([REPLACE_TRUNC])
320 REPLACE_TRUNCF=0; AC_SUBST([REPLACE_TRUNCF])
139 REPLACE_TRUNCL=0; AC_SUBST([REPLACE_TRUNCL]) 321 REPLACE_TRUNCL=0; AC_SUBST([REPLACE_TRUNCL])
140]) 322])
323
324# gl_LONG_DOUBLE_VS_DOUBLE
325# determines whether 'long double' and 'double' have the same representation.
326# Sets variable HAVE_SAME_LONG_DOUBLE_AS_DOUBLE to 0 or 1, and defines
327# HAVE_SAME_LONG_DOUBLE_AS_DOUBLE accordingly.
328# The currently known platforms where this is the case are:
329# Linux/HPPA, Minix 3.1.8, AIX 5, AIX 6 and 7 with xlc, MSVC 9.
330AC_DEFUN([gl_LONG_DOUBLE_VS_DOUBLE],
331[
332 AC_CACHE_CHECK([whether long double and double are the same],
333 [gl_cv_long_double_equals_double],
334 [AC_COMPILE_IFELSE(
335 [AC_LANG_PROGRAM([[#include <float.h>]],
336 [[typedef int check[sizeof (long double) == sizeof (double)
337 && LDBL_MANT_DIG == DBL_MANT_DIG
338 && LDBL_MAX_EXP == DBL_MAX_EXP
339 && LDBL_MIN_EXP == DBL_MIN_EXP
340 ? 1 : -1];
341 ]])],
342 [gl_cv_long_double_equals_double=yes],
343 [gl_cv_long_double_equals_double=no])
344 ])
345 if test $gl_cv_long_double_equals_double = yes; then
346 AC_DEFINE([HAVE_SAME_LONG_DOUBLE_AS_DOUBLE], [1],
347 [Define to 1 if 'long double' and 'double' have the same representation.])
348 HAVE_SAME_LONG_DOUBLE_AS_DOUBLE=1
349 else
350 HAVE_SAME_LONG_DOUBLE_AS_DOUBLE=0
351 fi
352 AC_SUBST([HAVE_SAME_LONG_DOUBLE_AS_DOUBLE])
353])
diff --git a/gl/m4/mbrtowc.m4 b/gl/m4/mbrtowc.m4
index 606de5c..4c9f388 100644
--- a/gl/m4/mbrtowc.m4
+++ b/gl/m4/mbrtowc.m4
@@ -1,5 +1,5 @@
1# mbrtowc.m4 serial 17 1# mbrtowc.m4 serial 25
2dnl Copyright (C) 2001-2002, 2004-2005, 2008-2010 Free Software Foundation, 2dnl Copyright (C) 2001-2002, 2004-2005, 2008-2013 Free Software Foundation,
3dnl Inc. 3dnl Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
@@ -15,16 +15,40 @@ AC_DEFUN([gl_FUNC_MBRTOWC],
15 AC_CHECK_FUNCS_ONCE([mbrtowc]) 15 AC_CHECK_FUNCS_ONCE([mbrtowc])
16 if test $ac_cv_func_mbrtowc = no; then 16 if test $ac_cv_func_mbrtowc = no; then
17 HAVE_MBRTOWC=0 17 HAVE_MBRTOWC=0
18 AC_CHECK_DECLS([mbrtowc],,, [[
19/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
20 <wchar.h>.
21 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
22 included before <wchar.h>. */
23#include <stddef.h>
24#include <stdio.h>
25#include <time.h>
26#include <wchar.h>
27]])
28 if test $ac_cv_have_decl_mbrtowc = yes; then
29 dnl On Minix 3.1.8, the system's <wchar.h> declares mbrtowc() although
30 dnl it does not have the function. Avoid a collision with gnulib's
31 dnl replacement.
32 REPLACE_MBRTOWC=1
33 fi
18 else 34 else
19 if test $REPLACE_MBSTATE_T = 1; then 35 if test $REPLACE_MBSTATE_T = 1; then
20 REPLACE_MBRTOWC=1 36 REPLACE_MBRTOWC=1
21 else 37 else
22 gl_MBRTOWC_NULL_ARG 38 gl_MBRTOWC_NULL_ARG1
39 gl_MBRTOWC_NULL_ARG2
23 gl_MBRTOWC_RETVAL 40 gl_MBRTOWC_RETVAL
24 gl_MBRTOWC_NUL_RETVAL 41 gl_MBRTOWC_NUL_RETVAL
25 case "$gl_cv_func_mbrtowc_null_arg" in 42 case "$gl_cv_func_mbrtowc_null_arg1" in
43 *yes) ;;
44 *) AC_DEFINE([MBRTOWC_NULL_ARG1_BUG], [1],
45 [Define if the mbrtowc function has the NULL pwc argument bug.])
46 REPLACE_MBRTOWC=1
47 ;;
48 esac
49 case "$gl_cv_func_mbrtowc_null_arg2" in
26 *yes) ;; 50 *yes) ;;
27 *) AC_DEFINE([MBRTOWC_NULL_ARG_BUG], [1], 51 *) AC_DEFINE([MBRTOWC_NULL_ARG2_BUG], [1],
28 [Define if the mbrtowc function has the NULL string argument bug.]) 52 [Define if the mbrtowc function has the NULL string argument bug.])
29 REPLACE_MBRTOWC=1 53 REPLACE_MBRTOWC=1
30 ;; 54 ;;
@@ -45,11 +69,6 @@ AC_DEFUN([gl_FUNC_MBRTOWC],
45 esac 69 esac
46 fi 70 fi
47 fi 71 fi
48 if test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1; then
49 gl_REPLACE_WCHAR_H
50 AC_LIBOBJ([mbrtowc])
51 gl_PREREQ_MBRTOWC
52 fi
53]) 72])
54 73
55dnl Test whether mbsinit() and mbrtowc() need to be overridden in a way that 74dnl Test whether mbsinit() and mbrtowc() need to be overridden in a way that
@@ -80,9 +99,6 @@ AC_DEFUN([gl_MBSTATE_T_BROKEN],
80 else 99 else
81 REPLACE_MBSTATE_T=1 100 REPLACE_MBSTATE_T=1
82 fi 101 fi
83 if test $REPLACE_MBSTATE_T = 1; then
84 gl_REPLACE_WCHAR_H
85 fi
86]) 102])
87 103
88dnl Test whether mbrtowc puts the state into non-initial state when parsing an 104dnl Test whether mbrtowc puts the state into non-initial state when parsing an
@@ -101,16 +117,24 @@ AC_DEFUN([gl_MBRTOWC_INCOMPLETE_STATE],
101 dnl is present. 117 dnl is present.
102changequote(,)dnl 118changequote(,)dnl
103 case "$host_os" in 119 case "$host_os" in
104 # Guess no on AIX and OSF/1. 120 # Guess no on AIX and OSF/1.
105 osf*) gl_cv_func_mbrtowc_incomplete_state="guessing no" ;; 121 aix* | osf*) gl_cv_func_mbrtowc_incomplete_state="guessing no" ;;
106 # Guess yes otherwise. 122 # Guess yes otherwise.
107 *) gl_cv_func_mbrtowc_incomplete_state="guessing yes" ;; 123 *) gl_cv_func_mbrtowc_incomplete_state="guessing yes" ;;
108 esac 124 esac
109changequote([,])dnl 125changequote([,])dnl
110 if test $LOCALE_JA != none; then 126 if test $LOCALE_JA != none; then
111 AC_TRY_RUN([ 127 AC_RUN_IFELSE(
128 [AC_LANG_SOURCE([[
112#include <locale.h> 129#include <locale.h>
113#include <string.h> 130#include <string.h>
131/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
132 <wchar.h>.
133 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
134 included before <wchar.h>. */
135#include <stddef.h>
136#include <stdio.h>
137#include <time.h>
114#include <wchar.h> 138#include <wchar.h>
115int main () 139int main ()
116{ 140{
@@ -126,7 +150,7 @@ int main ()
126 return 1; 150 return 1;
127 } 151 }
128 return 0; 152 return 0;
129}], 153}]])],
130 [gl_cv_func_mbrtowc_incomplete_state=yes], 154 [gl_cv_func_mbrtowc_incomplete_state=yes],
131 [gl_cv_func_mbrtowc_incomplete_state=no], 155 [gl_cv_func_mbrtowc_incomplete_state=no],
132 [:]) 156 [:])
@@ -156,10 +180,18 @@ changequote(,)dnl
156 esac 180 esac
157changequote([,])dnl 181changequote([,])dnl
158 if test $LOCALE_ZH_CN != none; then 182 if test $LOCALE_ZH_CN != none; then
159 AC_TRY_RUN([ 183 AC_RUN_IFELSE(
184 [AC_LANG_SOURCE([[
160#include <locale.h> 185#include <locale.h>
161#include <stdlib.h> 186#include <stdlib.h>
162#include <string.h> 187#include <string.h>
188/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
189 <wchar.h>.
190 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
191 included before <wchar.h>. */
192#include <stddef.h>
193#include <stdio.h>
194#include <time.h>
163#include <wchar.h> 195#include <wchar.h>
164int main () 196int main ()
165{ 197{
@@ -178,7 +210,7 @@ int main ()
178 return 1; 210 return 1;
179 } 211 }
180 return 0; 212 return 0;
181}], 213}]])],
182 [gl_cv_func_mbrtowc_sanitycheck=yes], 214 [gl_cv_func_mbrtowc_sanitycheck=yes],
183 [gl_cv_func_mbrtowc_sanitycheck=no], 215 [gl_cv_func_mbrtowc_sanitycheck=no],
184 [:]) 216 [:])
@@ -186,31 +218,109 @@ int main ()
186 ]) 218 ])
187]) 219])
188 220
221dnl Test whether mbrtowc supports a NULL pwc argument correctly.
222dnl Result is gl_cv_func_mbrtowc_null_arg1.
223
224AC_DEFUN([gl_MBRTOWC_NULL_ARG1],
225[
226 AC_REQUIRE([AC_PROG_CC])
227 AC_REQUIRE([gt_LOCALE_FR_UTF8])
228 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
229 AC_CACHE_CHECK([whether mbrtowc handles a NULL pwc argument],
230 [gl_cv_func_mbrtowc_null_arg1],
231 [
232 dnl Initial guess, used when cross-compiling or when no suitable locale
233 dnl is present.
234changequote(,)dnl
235 case "$host_os" in
236 # Guess no on Solaris.
237 solaris*) gl_cv_func_mbrtowc_null_arg1="guessing no" ;;
238 # Guess yes otherwise.
239 *) gl_cv_func_mbrtowc_null_arg1="guessing yes" ;;
240 esac
241changequote([,])dnl
242 if test $LOCALE_FR_UTF8 != none; then
243 AC_RUN_IFELSE(
244 [AC_LANG_SOURCE([[
245#include <locale.h>
246#include <stdlib.h>
247#include <string.h>
248/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
249 <wchar.h>.
250 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
251 included before <wchar.h>. */
252#include <stddef.h>
253#include <stdio.h>
254#include <time.h>
255#include <wchar.h>
256int main ()
257{
258 int result = 0;
259
260 if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
261 {
262 char input[] = "\303\237er";
263 mbstate_t state;
264 wchar_t wc;
265 size_t ret;
266
267 memset (&state, '\0', sizeof (mbstate_t));
268 wc = (wchar_t) 0xBADFACE;
269 ret = mbrtowc (&wc, input, 5, &state);
270 if (ret != 2)
271 result |= 1;
272 if (!mbsinit (&state))
273 result |= 2;
274
275 memset (&state, '\0', sizeof (mbstate_t));
276 ret = mbrtowc (NULL, input, 5, &state);
277 if (ret != 2) /* Solaris 7 fails here: ret is -1. */
278 result |= 4;
279 if (!mbsinit (&state))
280 result |= 8;
281 }
282 return result;
283}]])],
284 [gl_cv_func_mbrtowc_null_arg1=yes],
285 [gl_cv_func_mbrtowc_null_arg1=no],
286 [:])
287 fi
288 ])
289])
290
189dnl Test whether mbrtowc supports a NULL string argument correctly. 291dnl Test whether mbrtowc supports a NULL string argument correctly.
190dnl Result is gl_cv_func_mbrtowc_null_arg. 292dnl Result is gl_cv_func_mbrtowc_null_arg2.
191 293
192AC_DEFUN([gl_MBRTOWC_NULL_ARG], 294AC_DEFUN([gl_MBRTOWC_NULL_ARG2],
193[ 295[
194 AC_REQUIRE([AC_PROG_CC]) 296 AC_REQUIRE([AC_PROG_CC])
195 AC_REQUIRE([gt_LOCALE_FR_UTF8]) 297 AC_REQUIRE([gt_LOCALE_FR_UTF8])
196 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 298 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
197 AC_CACHE_CHECK([whether mbrtowc handles a NULL string argument], 299 AC_CACHE_CHECK([whether mbrtowc handles a NULL string argument],
198 [gl_cv_func_mbrtowc_null_arg], 300 [gl_cv_func_mbrtowc_null_arg2],
199 [ 301 [
200 dnl Initial guess, used when cross-compiling or when no suitable locale 302 dnl Initial guess, used when cross-compiling or when no suitable locale
201 dnl is present. 303 dnl is present.
202changequote(,)dnl 304changequote(,)dnl
203 case "$host_os" in 305 case "$host_os" in
204 # Guess no on OSF/1. 306 # Guess no on OSF/1.
205 osf*) gl_cv_func_mbrtowc_null_arg="guessing no" ;; 307 osf*) gl_cv_func_mbrtowc_null_arg2="guessing no" ;;
206 # Guess yes otherwise. 308 # Guess yes otherwise.
207 *) gl_cv_func_mbrtowc_null_arg="guessing yes" ;; 309 *) gl_cv_func_mbrtowc_null_arg2="guessing yes" ;;
208 esac 310 esac
209changequote([,])dnl 311changequote([,])dnl
210 if test $LOCALE_FR_UTF8 != none; then 312 if test $LOCALE_FR_UTF8 != none; then
211 AC_TRY_RUN([ 313 AC_RUN_IFELSE(
314 [AC_LANG_SOURCE([[
212#include <locale.h> 315#include <locale.h>
213#include <string.h> 316#include <string.h>
317/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
318 <wchar.h>.
319 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
320 included before <wchar.h>. */
321#include <stddef.h>
322#include <stdio.h>
323#include <time.h>
214#include <wchar.h> 324#include <wchar.h>
215int main () 325int main ()
216{ 326{
@@ -228,7 +338,10 @@ int main ()
228 return 1; 338 return 1;
229 } 339 }
230 return 0; 340 return 0;
231}], [gl_cv_func_mbrtowc_null_arg=yes], [gl_cv_func_mbrtowc_null_arg=no], [:]) 341}]])],
342 [gl_cv_func_mbrtowc_null_arg2=yes],
343 [gl_cv_func_mbrtowc_null_arg2=no],
344 [:])
232 fi 345 fi
233 ]) 346 ])
234]) 347])
@@ -243,7 +356,7 @@ AC_DEFUN([gl_MBRTOWC_RETVAL],
243 AC_REQUIRE([AC_PROG_CC]) 356 AC_REQUIRE([AC_PROG_CC])
244 AC_REQUIRE([gt_LOCALE_FR_UTF8]) 357 AC_REQUIRE([gt_LOCALE_FR_UTF8])
245 AC_REQUIRE([gt_LOCALE_JA]) 358 AC_REQUIRE([gt_LOCALE_JA])
246 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 359 AC_REQUIRE([AC_CANONICAL_HOST])
247 AC_CACHE_CHECK([whether mbrtowc has a correct return value], 360 AC_CACHE_CHECK([whether mbrtowc has a correct return value],
248 [gl_cv_func_mbrtowc_retval], 361 [gl_cv_func_mbrtowc_retval],
249 [ 362 [
@@ -251,19 +364,30 @@ AC_DEFUN([gl_MBRTOWC_RETVAL],
251 dnl is present. 364 dnl is present.
252changequote(,)dnl 365changequote(,)dnl
253 case "$host_os" in 366 case "$host_os" in
254 # Guess no on HP-UX and Solaris. 367 # Guess no on HP-UX, Solaris, native Windows.
255 hpux* | solaris*) gl_cv_func_mbrtowc_retval="guessing no" ;; 368 hpux* | solaris* | mingw*) gl_cv_func_mbrtowc_retval="guessing no" ;;
256 # Guess yes otherwise. 369 # Guess yes otherwise.
257 *) gl_cv_func_mbrtowc_retval="guessing yes" ;; 370 *) gl_cv_func_mbrtowc_retval="guessing yes" ;;
258 esac 371 esac
259changequote([,])dnl 372changequote([,])dnl
260 if test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none; then 373 if test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none \
261 AC_TRY_RUN([ 374 || { case "$host_os" in mingw*) true;; *) false;; esac; }; then
375 AC_RUN_IFELSE(
376 [AC_LANG_SOURCE([[
262#include <locale.h> 377#include <locale.h>
263#include <string.h> 378#include <string.h>
379/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
380 <wchar.h>.
381 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
382 included before <wchar.h>. */
383#include <stddef.h>
384#include <stdio.h>
385#include <time.h>
264#include <wchar.h> 386#include <wchar.h>
265int main () 387int main ()
266{ 388{
389 int result = 0;
390 int found_some_locale = 0;
267 /* This fails on Solaris. */ 391 /* This fails on Solaris. */
268 if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) 392 if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
269 { 393 {
@@ -276,8 +400,9 @@ int main ()
276 { 400 {
277 input[1] = '\0'; 401 input[1] = '\0';
278 if (mbrtowc (&wc, input + 2, 5, &state) != 1) 402 if (mbrtowc (&wc, input + 2, 5, &state) != 1)
279 return 1; 403 result |= 1;
280 } 404 }
405 found_some_locale = 1;
281 } 406 }
282 /* This fails on HP-UX 11.11. */ 407 /* This fails on HP-UX 11.11. */
283 if (setlocale (LC_ALL, "$LOCALE_JA") != NULL) 408 if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
@@ -291,13 +416,63 @@ int main ()
291 { 416 {
292 input[1] = '\0'; 417 input[1] = '\0';
293 if (mbrtowc (&wc, input + 2, 5, &state) != 2) 418 if (mbrtowc (&wc, input + 2, 5, &state) != 2)
294 return 1; 419 result |= 2;
295 } 420 }
421 found_some_locale = 1;
296 } 422 }
297 return 0; 423 /* This fails on native Windows. */
298}], 424 if (setlocale (LC_ALL, "Japanese_Japan.932") != NULL)
425 {
426 char input[] = "<\223\372\226\173\214\352>"; /* "<日本語>" */
427 mbstate_t state;
428 wchar_t wc;
429
430 memset (&state, '\0', sizeof (mbstate_t));
431 if (mbrtowc (&wc, input + 3, 1, &state) == (size_t)(-2))
432 {
433 input[3] = '\0';
434 if (mbrtowc (&wc, input + 4, 4, &state) != 1)
435 result |= 4;
436 }
437 found_some_locale = 1;
438 }
439 if (setlocale (LC_ALL, "Chinese_Taiwan.950") != NULL)
440 {
441 char input[] = "<\244\351\245\273\273\171>"; /* "<日本語>" */
442 mbstate_t state;
443 wchar_t wc;
444
445 memset (&state, '\0', sizeof (mbstate_t));
446 if (mbrtowc (&wc, input + 3, 1, &state) == (size_t)(-2))
447 {
448 input[3] = '\0';
449 if (mbrtowc (&wc, input + 4, 4, &state) != 1)
450 result |= 8;
451 }
452 found_some_locale = 1;
453 }
454 if (setlocale (LC_ALL, "Chinese_China.936") != NULL)
455 {
456 char input[] = "<\310\325\261\276\325\132>"; /* "<日本語>" */
457 mbstate_t state;
458 wchar_t wc;
459
460 memset (&state, '\0', sizeof (mbstate_t));
461 if (mbrtowc (&wc, input + 3, 1, &state) == (size_t)(-2))
462 {
463 input[3] = '\0';
464 if (mbrtowc (&wc, input + 4, 4, &state) != 1)
465 result |= 16;
466 }
467 found_some_locale = 1;
468 }
469 return (found_some_locale ? result : 77);
470}]])],
299 [gl_cv_func_mbrtowc_retval=yes], 471 [gl_cv_func_mbrtowc_retval=yes],
300 [gl_cv_func_mbrtowc_retval=no], 472 [if test $? != 77; then
473 gl_cv_func_mbrtowc_retval=no
474 fi
475 ],
301 [:]) 476 [:])
302 fi 477 fi
303 ]) 478 ])
@@ -325,9 +500,17 @@ changequote(,)dnl
325 esac 500 esac
326changequote([,])dnl 501changequote([,])dnl
327 if test $LOCALE_ZH_CN != none; then 502 if test $LOCALE_ZH_CN != none; then
328 AC_TRY_RUN([ 503 AC_RUN_IFELSE(
504 [AC_LANG_SOURCE([[
329#include <locale.h> 505#include <locale.h>
330#include <string.h> 506#include <string.h>
507/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
508 <wchar.h>.
509 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
510 included before <wchar.h>. */
511#include <stddef.h>
512#include <stdio.h>
513#include <time.h>
331#include <wchar.h> 514#include <wchar.h>
332int main () 515int main ()
333{ 516{
@@ -342,7 +525,7 @@ int main ()
342 return 1; 525 return 1;
343 } 526 }
344 return 0; 527 return 0;
345}], 528}]])],
346 [gl_cv_func_mbrtowc_nul_retval=yes], 529 [gl_cv_func_mbrtowc_nul_retval=yes],
347 [gl_cv_func_mbrtowc_nul_retval=no], 530 [gl_cv_func_mbrtowc_nul_retval=no],
348 [:]) 531 [:])
@@ -358,10 +541,8 @@ AC_DEFUN([gl_PREREQ_MBRTOWC], [
358 541
359dnl From Paul Eggert 542dnl From Paul Eggert
360 543
361dnl This override of an autoconf macro can be removed when autoconf 2.60 or 544dnl This is an override of an autoconf macro.
362dnl newer can be assumed everywhere.
363 545
364m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.60]),[-1],[
365AC_DEFUN([AC_FUNC_MBRTOWC], 546AC_DEFUN([AC_FUNC_MBRTOWC],
366[ 547[
367 dnl Same as AC_FUNC_MBRTOWC in autoconf-2.60. 548 dnl Same as AC_FUNC_MBRTOWC in autoconf-2.60.
@@ -369,7 +550,14 @@ AC_DEFUN([AC_FUNC_MBRTOWC],
369 gl_cv_func_mbrtowc, 550 gl_cv_func_mbrtowc,
370 [AC_LINK_IFELSE( 551 [AC_LINK_IFELSE(
371 [AC_LANG_PROGRAM( 552 [AC_LANG_PROGRAM(
372 [[#include <wchar.h>]], 553 [[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be
554 included before <wchar.h>.
555 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
556 must be included before <wchar.h>. */
557 #include <stddef.h>
558 #include <stdio.h>
559 #include <time.h>
560 #include <wchar.h>]],
373 [[wchar_t wc; 561 [[wchar_t wc;
374 char const s[] = ""; 562 char const s[] = "";
375 size_t n = 1; 563 size_t n = 1;
@@ -382,4 +570,3 @@ AC_DEFUN([AC_FUNC_MBRTOWC],
382 [Define to 1 if mbrtowc and mbstate_t are properly declared.]) 570 [Define to 1 if mbrtowc and mbstate_t are properly declared.])
383 fi 571 fi
384]) 572])
385])
diff --git a/gl/m4/mbsinit.m4 b/gl/m4/mbsinit.m4
index 46c106f..2e6d092 100644
--- a/gl/m4/mbsinit.m4
+++ b/gl/m4/mbsinit.m4
@@ -1,5 +1,5 @@
1# mbsinit.m4 serial 4 1# mbsinit.m4 serial 8
2dnl Copyright (C) 2008, 2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2008, 2010-2013 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,6 +7,7 @@ dnl with or without modifications, as long as this notice is preserved.
7AC_DEFUN([gl_FUNC_MBSINIT], 7AC_DEFUN([gl_FUNC_MBSINIT],
8[ 8[
9 AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) 9 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
10 AC_REQUIRE([AC_CANONICAL_HOST])
10 11
11 AC_REQUIRE([AC_TYPE_MBSTATE_T]) 12 AC_REQUIRE([AC_TYPE_MBSTATE_T])
12 gl_MBSTATE_T_BROKEN 13 gl_MBSTATE_T_BROKEN
@@ -14,16 +15,34 @@ AC_DEFUN([gl_FUNC_MBSINIT],
14 AC_CHECK_FUNCS_ONCE([mbsinit]) 15 AC_CHECK_FUNCS_ONCE([mbsinit])
15 if test $ac_cv_func_mbsinit = no; then 16 if test $ac_cv_func_mbsinit = no; then
16 HAVE_MBSINIT=0 17 HAVE_MBSINIT=0
18 AC_CHECK_DECLS([mbsinit],,, [[
19/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
20 <wchar.h>.
21 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
22 included before <wchar.h>. */
23#include <stddef.h>
24#include <stdio.h>
25#include <time.h>
26#include <wchar.h>
27]])
28 if test $ac_cv_have_decl_mbsinit = yes; then
29 dnl On Minix 3.1.8, the system's <wchar.h> declares mbsinit() although
30 dnl it does not have the function. Avoid a collision with gnulib's
31 dnl replacement.
32 REPLACE_MBSINIT=1
33 fi
17 else 34 else
18 if test $REPLACE_MBSTATE_T = 1; then 35 if test $REPLACE_MBSTATE_T = 1; then
19 REPLACE_MBSINIT=1 36 REPLACE_MBSINIT=1
37 else
38 dnl On mingw, mbsinit() always returns 1, which is inappropriate for
39 dnl states produced by mbrtowc() for an incomplete multibyte character
40 dnl in multibyte locales.
41 case "$host_os" in
42 mingw*) REPLACE_MBSINIT=1 ;;
43 esac
20 fi 44 fi
21 fi 45 fi
22 if test $HAVE_MBSINIT = 0 || test $REPLACE_MBSINIT = 1; then
23 gl_REPLACE_WCHAR_H
24 AC_LIBOBJ([mbsinit])
25 gl_PREREQ_MBSINIT
26 fi
27]) 46])
28 47
29# Prerequisites of lib/mbsinit.c. 48# Prerequisites of lib/mbsinit.c.
diff --git a/gl/m4/mbstate_t.m4 b/gl/m4/mbstate_t.m4
index 3e2df29..ed00117 100644
--- a/gl/m4/mbstate_t.m4
+++ b/gl/m4/mbstate_t.m4
@@ -1,5 +1,5 @@
1# mbstate_t.m4 serial 12 1# mbstate_t.m4 serial 13
2dnl Copyright (C) 2000-2002, 2008-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2000-2002, 2008-2013 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,7 +20,14 @@ AC_DEFUN([AC_TYPE_MBSTATE_T],
20 [AC_COMPILE_IFELSE( 20 [AC_COMPILE_IFELSE(
21 [AC_LANG_PROGRAM( 21 [AC_LANG_PROGRAM(
22 [AC_INCLUDES_DEFAULT[ 22 [AC_INCLUDES_DEFAULT[
23# include <wchar.h>]], 23/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
24 <wchar.h>.
25 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
26 included before <wchar.h>. */
27#include <stddef.h>
28#include <stdio.h>
29#include <time.h>
30#include <wchar.h>]],
24 [[mbstate_t x; return sizeof x;]])], 31 [[mbstate_t x; return sizeof x;]])],
25 [ac_cv_type_mbstate_t=yes], 32 [ac_cv_type_mbstate_t=yes],
26 [ac_cv_type_mbstate_t=no])]) 33 [ac_cv_type_mbstate_t=no])])
diff --git a/gl/m4/mbtowc.m4 b/gl/m4/mbtowc.m4
new file mode 100644
index 0000000..e479461
--- /dev/null
+++ b/gl/m4/mbtowc.m4
@@ -0,0 +1,19 @@
1# mbtowc.m4 serial 2
2dnl Copyright (C) 2011-2013 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_MBTOWC],
8[
9 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
10
11 if false; then
12 REPLACE_MBTOWC=1
13 fi
14])
15
16# Prerequisites of lib/mbtowc.c.
17AC_DEFUN([gl_PREREQ_MBTOWC], [
18 :
19])
diff --git a/gl/m4/memchr.m4 b/gl/m4/memchr.m4
index ab773b8..2d8abe7 100644
--- a/gl/m4/memchr.m4
+++ b/gl/m4/memchr.m4
@@ -1,5 +1,5 @@
1# memchr.m4 serial 8 1# memchr.m4 serial 12
2dnl Copyright (C) 2002-2004, 2009-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2004, 2009-2013 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,10 +11,16 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
11 AC_CHECK_HEADERS_ONCE([sys/mman.h]) 11 AC_CHECK_HEADERS_ONCE([sys/mman.h])
12 AC_CHECK_FUNCS_ONCE([mprotect]) 12 AC_CHECK_FUNCS_ONCE([mprotect])
13 13
14 dnl These days, we assume memchr is present. But just in case...
15 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) 14 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
16 AC_CHECK_FUNCS_ONCE([memchr]) 15 m4_ifdef([gl_FUNC_MEMCHR_OBSOLETE], [
17 if test $ac_cv_func_memchr = yes; then 16 dnl These days, we assume memchr is present. But if support for old
17 dnl platforms is desired:
18 AC_CHECK_FUNCS_ONCE([memchr])
19 if test $ac_cv_func_memchr = no; then
20 HAVE_MEMCHR=0
21 fi
22 ])
23 if test $HAVE_MEMCHR = 1; then
18 # Detect platform-specific bugs in some versions of glibc: 24 # Detect platform-specific bugs in some versions of glibc:
19 # memchr should not dereference anything with length 0 25 # memchr should not dereference anything with length 0
20 # http://bugzilla.redhat.com/499689 26 # http://bugzilla.redhat.com/499689
@@ -35,6 +41,7 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
35# endif 41# endif
36#endif 42#endif
37]], [[ 43]], [[
44 int result = 0;
38 char *fence = NULL; 45 char *fence = NULL;
39#if HAVE_SYS_MMAN_H && HAVE_MPROTECT 46#if HAVE_SYS_MMAN_H && HAVE_MPROTECT
40# if HAVE_MAP_ANONYMOUS 47# if HAVE_MAP_ANONYMOUS
@@ -58,24 +65,20 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
58 if (fence) 65 if (fence)
59 { 66 {
60 if (memchr (fence, 0, 0)) 67 if (memchr (fence, 0, 0))
61 return 1; 68 result |= 1;
62 strcpy (fence - 9, "12345678"); 69 strcpy (fence - 9, "12345678");
63 if (memchr (fence - 9, 0, 79) != fence - 1) 70 if (memchr (fence - 9, 0, 79) != fence - 1)
64 return 2; 71 result |= 2;
72 if (memchr (fence - 1, 0, 3) != fence - 1)
73 result |= 4;
65 } 74 }
66 return 0; 75 return result;
67]])], [gl_cv_func_memchr_works=yes], [gl_cv_func_memchr_works=no], 76]])], [gl_cv_func_memchr_works=yes], [gl_cv_func_memchr_works=no],
68 [dnl Be pessimistic for now. 77 [dnl Be pessimistic for now.
69 gl_cv_func_memchr_works="guessing no"])]) 78 gl_cv_func_memchr_works="guessing no"])])
70 if test "$gl_cv_func_memchr_works" != yes; then 79 if test "$gl_cv_func_memchr_works" != yes; then
71 REPLACE_MEMCHR=1 80 REPLACE_MEMCHR=1
72 fi 81 fi
73 else
74 HAVE_MEMCHR=0
75 fi
76 if test $HAVE_MEMCHR = 0 || test $REPLACE_MEMCHR = 1; then
77 AC_LIBOBJ([memchr])
78 gl_PREREQ_MEMCHR
79 fi 82 fi
80]) 83])
81 84
diff --git a/gl/m4/mktime.m4 b/gl/m4/mktime.m4
index 44b8d87..faefb77 100644
--- a/gl/m4/mktime.m4
+++ b/gl/m4/mktime.m4
@@ -1,5 +1,5 @@
1# serial 15 1# serial 25
2dnl Copyright (C) 2002-2003, 2005-2007, 2009-2010 Free Software Foundation, 2dnl Copyright (C) 2002-2003, 2005-2007, 2009-2013 Free Software Foundation,
3dnl Inc. 3dnl Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
@@ -7,24 +7,24 @@ dnl with or without modifications, as long as this notice is preserved.
7 7
8dnl From Jim Meyering. 8dnl From Jim Meyering.
9 9
10# Redefine AC_FUNC_MKTIME, to fix a bug in Autoconf 2.61a and earlier. 10AC_DEFUN([gl_FUNC_MKTIME],
11# This redefinition can be removed once a new version of Autoconf is assumed. 11[
12# The redefinition is taken from 12 AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
13# <http://cvs.sv.gnu.org/viewcvs/*checkout*/autoconf/autoconf/lib/autoconf/functions.m4?rev=1.119>. 13
14# AC_FUNC_MKTIME 14 dnl We don't use AC_FUNC_MKTIME any more, because it is no longer maintained
15# -------------- 15 dnl in Autoconf and because it invokes AC_LIBOBJ.
16AC_DEFUN([AC_FUNC_MKTIME], 16 AC_CHECK_HEADERS_ONCE([unistd.h])
17[AC_CHECK_HEADERS_ONCE([unistd.h]) 17 AC_CHECK_DECLS_ONCE([alarm])
18AC_CHECK_FUNCS_ONCE([alarm]) 18 AC_REQUIRE([gl_MULTIARCH])
19AC_REQUIRE([gl_MULTIARCH]) 19 if test $APPLE_UNIVERSAL_BUILD = 1; then
20if test $APPLE_UNIVERSAL_BUILD = 1; then 20 # A universal build on Apple Mac OS X platforms.
21 # A universal build on Apple MacOS X platforms. 21 # The test result would be 'yes' in 32-bit mode and 'no' in 64-bit mode.
22 # The test result would be 'yes' in 32-bit mode and 'no' in 64-bit mode. 22 # But we need a configuration result that is valid in both modes.
23 # But we need a configuration result that is valid in both modes. 23 gl_cv_func_working_mktime=no
24 ac_cv_func_working_mktime=no 24 fi
25fi 25 AC_CACHE_CHECK([for working mktime], [gl_cv_func_working_mktime],
26AC_CACHE_CHECK([for working mktime], [ac_cv_func_working_mktime], 26 [AC_RUN_IFELSE(
27[AC_RUN_IFELSE([AC_LANG_SOURCE( 27 [AC_LANG_SOURCE(
28[[/* Test program from Paul Eggert and Tony Leneis. */ 28[[/* Test program from Paul Eggert and Tony Leneis. */
29#include <limits.h> 29#include <limits.h>
30#include <stdlib.h> 30#include <stdlib.h>
@@ -34,8 +34,8 @@ AC_CACHE_CHECK([for working mktime], [ac_cv_func_working_mktime],
34# include <unistd.h> 34# include <unistd.h>
35#endif 35#endif
36 36
37#ifndef HAVE_ALARM 37#if HAVE_DECL_ALARM
38# define alarm(X) /* empty */ 38# include <signal.h>
39#endif 39#endif
40 40
41/* Work around redefinition to rpl_putenv by other config tests. */ 41/* Work around redefinition to rpl_putenv by other config tests. */
@@ -165,22 +165,29 @@ year_2050_test ()
165int 165int
166main () 166main ()
167{ 167{
168 int result = 0;
168 time_t t, delta; 169 time_t t, delta;
169 int i, j; 170 int i, j;
171 int time_t_signed_magnitude = (time_t) ~ (time_t) 0 < (time_t) -1;
172 int time_t_signed = ! ((time_t) 0 < (time_t) -1);
170 173
174#if HAVE_DECL_ALARM
171 /* This test makes some buggy mktime implementations loop. 175 /* This test makes some buggy mktime implementations loop.
172 Give up after 60 seconds; a mktime slower than that 176 Give up after 60 seconds; a mktime slower than that
173 isn't worth using anyway. */ 177 isn't worth using anyway. */
178 signal (SIGALRM, SIG_DFL);
174 alarm (60); 179 alarm (60);
180#endif
175 181
176 for (;;) 182 time_t_max = (! time_t_signed
177 { 183 ? (time_t) -1
178 t = (time_t_max << 1) + 1; 184 : ((((time_t) 1 << (sizeof (time_t) * CHAR_BIT - 2)) - 1)
179 if (t <= time_t_max) 185 * 2 + 1));
180 break; 186 time_t_min = (! time_t_signed
181 time_t_max = t; 187 ? (time_t) 0
182 } 188 : time_t_signed_magnitude
183 time_t_min = - ((time_t) ~ (time_t) 0 == (time_t) -1) - time_t_max; 189 ? ~ (time_t) 0
190 : ~ time_t_max);
184 191
185 delta = time_t_max / 997; /* a suitable prime number */ 192 delta = time_t_max / 997; /* a suitable prime number */
186 for (i = 0; i < N_STRINGS; i++) 193 for (i = 0; i < N_STRINGS; i++)
@@ -188,47 +195,59 @@ main ()
188 if (tz_strings[i]) 195 if (tz_strings[i])
189 putenv (tz_strings[i]); 196 putenv (tz_strings[i]);
190 197
191 for (t = 0; t <= time_t_max - delta; t += delta) 198 for (t = 0; t <= time_t_max - delta && (result & 1) == 0; t += delta)
192 if (! mktime_test (t)) 199 if (! mktime_test (t))
193 return 1; 200 result |= 1;
194 if (! (mktime_test ((time_t) 1) 201 if ((result & 2) == 0
195 && mktime_test ((time_t) (60 * 60)) 202 && ! (mktime_test ((time_t) 1)
196 && mktime_test ((time_t) (60 * 60 * 24)))) 203 && mktime_test ((time_t) (60 * 60))
197 return 1; 204 && mktime_test ((time_t) (60 * 60 * 24))))
198 205 result |= 2;
199 for (j = 1; ; j <<= 1) 206
200 if (! bigtime_test (j)) 207 for (j = 1; (result & 4) == 0; j <<= 1)
201 return 1; 208 {
202 else if (INT_MAX / 2 < j) 209 if (! bigtime_test (j))
203 break; 210 result |= 4;
204 if (! bigtime_test (INT_MAX)) 211 if (INT_MAX / 2 < j)
205 return 1; 212 break;
213 }
214 if ((result & 8) == 0 && ! bigtime_test (INT_MAX))
215 result |= 8;
206 } 216 }
207 return ! (irix_6_4_bug () && spring_forward_gap () && year_2050_test ()); 217 if (! irix_6_4_bug ())
218 result |= 16;
219 if (! spring_forward_gap ())
220 result |= 32;
221 if (! year_2050_test ())
222 result |= 64;
223 return result;
208}]])], 224}]])],
209 [ac_cv_func_working_mktime=yes], 225 [gl_cv_func_working_mktime=yes],
210 [ac_cv_func_working_mktime=no], 226 [gl_cv_func_working_mktime=no],
211 [ac_cv_func_working_mktime=no])]) 227 [gl_cv_func_working_mktime=no])
212if test $ac_cv_func_working_mktime = no; then 228 ])
213 AC_LIBOBJ([mktime])
214fi
215])# AC_FUNC_MKTIME
216 229
217AC_DEFUN([gl_FUNC_MKTIME], 230 if test $gl_cv_func_working_mktime = no; then
218[
219 AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
220 AC_FUNC_MKTIME
221 dnl Note: AC_FUNC_MKTIME does AC_LIBOBJ([mktime]).
222 if test $ac_cv_func_working_mktime = no; then
223 REPLACE_MKTIME=1 231 REPLACE_MKTIME=1
224 gl_PREREQ_MKTIME
225 else 232 else
226 REPLACE_MKTIME=0 233 REPLACE_MKTIME=0
227 fi 234 fi
228]) 235])
229 236
230# Prerequisites of lib/mktime.c. 237AC_DEFUN([gl_FUNC_MKTIME_INTERNAL], [
231AC_DEFUN([gl_PREREQ_MKTIME], 238 AC_REQUIRE([gl_FUNC_MKTIME])
232[ 239 if test $REPLACE_MKTIME = 0; then
233 AC_REQUIRE([AC_C_INLINE]) 240 dnl BeOS has __mktime_internal in libc, but other platforms don't.
241 AC_CHECK_FUNC([__mktime_internal],
242 [AC_DEFINE([mktime_internal], [__mktime_internal],
243 [Define to the real name of the mktime_internal function.])
244 ],
245 [dnl mktime works but it doesn't export __mktime_internal,
246 dnl so we need to substitute our own mktime implementation.
247 REPLACE_MKTIME=1
248 ])
249 fi
234]) 250])
251
252# Prerequisites of lib/mktime.c.
253AC_DEFUN([gl_PREREQ_MKTIME], [:])
diff --git a/gl/m4/mmap-anon.m4 b/gl/m4/mmap-anon.m4
index a6b7b9a..9b60ddf 100644
--- a/gl/m4/mmap-anon.m4
+++ b/gl/m4/mmap-anon.m4
@@ -1,5 +1,5 @@
1# mmap-anon.m4 serial 8 1# mmap-anon.m4 serial 10
2dnl Copyright (C) 2005, 2007, 2009-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2005, 2007, 2009-2013 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,16 +9,12 @@ dnl with or without modifications, as long as this notice is preserved.
9# - On Linux, AIX, OSF/1, Solaris, Cygwin, Interix, Haiku, both MAP_ANONYMOUS 9# - On Linux, AIX, OSF/1, Solaris, Cygwin, Interix, Haiku, both MAP_ANONYMOUS
10# and MAP_ANON exist and have the same value. 10# and MAP_ANON exist and have the same value.
11# - On HP-UX, only MAP_ANONYMOUS exists. 11# - On HP-UX, only MAP_ANONYMOUS exists.
12# - On MacOS X, FreeBSD, NetBSD, OpenBSD, only MAP_ANON exists. 12# - On Mac OS X, FreeBSD, NetBSD, OpenBSD, only MAP_ANON exists.
13# - On IRIX, neither exists, and a file descriptor opened to /dev/zero must be 13# - On IRIX, neither exists, and a file descriptor opened to /dev/zero must be
14# used. 14# used.
15 15
16AC_DEFUN([gl_FUNC_MMAP_ANON], 16AC_DEFUN([gl_FUNC_MMAP_ANON],
17[ 17[
18 dnl Work around a bug of AC_EGREP_CPP in autoconf-2.57.
19 AC_REQUIRE([AC_PROG_CPP])
20 AC_REQUIRE([AC_PROG_EGREP])
21
22 dnl Persuade glibc <sys/mman.h> to define MAP_ANONYMOUS. 18 dnl Persuade glibc <sys/mman.h> to define MAP_ANONYMOUS.
23 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) 19 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
24 20
@@ -31,18 +27,18 @@ AC_DEFUN([gl_FUNC_MMAP_ANON],
31 gl_have_mmap_anonymous=no 27 gl_have_mmap_anonymous=no
32 if test $gl_have_mmap = yes; then 28 if test $gl_have_mmap = yes; then
33 AC_MSG_CHECKING([for MAP_ANONYMOUS]) 29 AC_MSG_CHECKING([for MAP_ANONYMOUS])
34 AC_EGREP_CPP([I cant identify this map.], [ 30 AC_EGREP_CPP([I cannot identify this map], [
35#include <sys/mman.h> 31#include <sys/mman.h>
36#ifdef MAP_ANONYMOUS 32#ifdef MAP_ANONYMOUS
37 I cant identify this map. 33 I cannot identify this map
38#endif 34#endif
39], 35],
40 [gl_have_mmap_anonymous=yes]) 36 [gl_have_mmap_anonymous=yes])
41 if test $gl_have_mmap_anonymous != yes; then 37 if test $gl_have_mmap_anonymous != yes; then
42 AC_EGREP_CPP([I cant identify this map.], [ 38 AC_EGREP_CPP([I cannot identify this map], [
43#include <sys/mman.h> 39#include <sys/mman.h>
44#ifdef MAP_ANON 40#ifdef MAP_ANON
45 I cant identify this map. 41 I cannot identify this map
46#endif 42#endif
47], 43],
48 [AC_DEFINE([MAP_ANONYMOUS], [MAP_ANON], 44 [AC_DEFINE([MAP_ANONYMOUS], [MAP_ANON],
diff --git a/gl/m4/mode_t.m4 b/gl/m4/mode_t.m4
deleted file mode 100644
index 3178dfd..0000000
--- a/gl/m4/mode_t.m4
+++ /dev/null
@@ -1,26 +0,0 @@
1# mode_t.m4 serial 2
2dnl Copyright (C) 2009-2010 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7# For using mode_t, it's sufficient to use AC_TYPE_MODE_T and
8# include <sys/types.h>.
9
10# Define PROMOTED_MODE_T to the type that is the result of "default argument
11# promotion" (ISO C 6.5.2.2.(6)) of the type mode_t.
12AC_DEFUN([gl_PROMOTED_TYPE_MODE_T],
13[
14 AC_REQUIRE([AC_TYPE_MODE_T])
15 AC_CACHE_CHECK([for promoted mode_t type], [gl_cv_promoted_mode_t], [
16 dnl Assume mode_t promotes to 'int' if and only if it is smaller than 'int',
17 dnl and to itself otherwise. This assumption is not guaranteed by the ISO C
18 dnl standard, but we don't know of any real-world counterexamples.
19 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>]],
20 [[typedef int array[2 * (sizeof (mode_t) < sizeof (int)) - 1];]])],
21 [gl_cv_promoted_mode_t='int'],
22 [gl_cv_promoted_mode_t='mode_t'])
23 ])
24 AC_DEFINE_UNQUOTED([PROMOTED_MODE_T], [$gl_cv_promoted_mode_t],
25 [Define to the type that is the result of default argument promotions of type mode_t.])
26])
diff --git a/gl/m4/mountlist.m4 b/gl/m4/mountlist.m4
index f2d5950..cd137c9 100644
--- a/gl/m4/mountlist.m4
+++ b/gl/m4/mountlist.m4
@@ -1,5 +1,5 @@
1# serial 10 1# serial 11
2dnl Copyright (C) 2002-2006, 2009-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2006, 2009-2013 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,10 +8,6 @@ AC_DEFUN([gl_MOUNTLIST],
8[ 8[
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
12 AC_LIBOBJ([mountlist])
13 gl_PREREQ_MOUNTLIST_EXTRA
14 fi
15]) 11])
16 12
17# Prerequisites of lib/mountlist.c not done by gl_LIST_MOUNTED_FILE_SYSTEMS. 13# Prerequisites of lib/mountlist.c not done by gl_LIST_MOUNTED_FILE_SYSTEMS.
diff --git a/gl/m4/msvc-inval.m4 b/gl/m4/msvc-inval.m4
new file mode 100644
index 0000000..9a6a47a
--- /dev/null
+++ b/gl/m4/msvc-inval.m4
@@ -0,0 +1,19 @@
1# msvc-inval.m4 serial 1
2dnl Copyright (C) 2011-2013 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_MSVC_INVAL],
8[
9 AC_CHECK_FUNCS_ONCE([_set_invalid_parameter_handler])
10 if test $ac_cv_func__set_invalid_parameter_handler = yes; then
11 HAVE_MSVC_INVALID_PARAMETER_HANDLER=1
12 AC_DEFINE([HAVE_MSVC_INVALID_PARAMETER_HANDLER], [1],
13 [Define to 1 on MSVC platforms that have the "invalid parameter handler"
14 concept.])
15 else
16 HAVE_MSVC_INVALID_PARAMETER_HANDLER=0
17 fi
18 AC_SUBST([HAVE_MSVC_INVALID_PARAMETER_HANDLER])
19])
diff --git a/gl/m4/cloexec.m4 b/gl/m4/msvc-nothrow.m4
index c75595c..a39618a 100644
--- a/gl/m4/cloexec.m4
+++ b/gl/m4/msvc-nothrow.m4
@@ -1,10 +1,10 @@
1#serial 6 1# msvc-nothrow.m4 serial 1
2dnl Copyright (C) 2004-2006, 2009-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2011-2013 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_CLOEXEC], 7AC_DEFUN([gl_MSVC_NOTHROW],
8[ 8[
9 AC_LIBOBJ([cloexec]) 9 AC_REQUIRE([gl_MSVC_INVAL])
10]) 10])
diff --git a/gl/m4/multiarch.m4 b/gl/m4/multiarch.m4
index 389bd2b..552ec7e 100644
--- a/gl/m4/multiarch.m4
+++ b/gl/m4/multiarch.m4
@@ -1,12 +1,12 @@
1# multiarch.m4 serial 5 1# multiarch.m4 serial 7
2dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2008-2013 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# Determine whether the compiler is or may be producing universal binaries. 7# Determine whether the compiler is or may be producing universal binaries.
8# 8#
9# On MacOS X 10.5 and later systems, the user can create libraries and 9# On Mac OS X 10.5 and later systems, the user can create libraries and
10# executables that work on multiple system types--known as "fat" or 10# executables that work on multiple system types--known as "fat" or
11# "universal" binaries--by specifying multiple '-arch' options to the 11# "universal" binaries--by specifying multiple '-arch' options to the
12# compiler but only a single '-arch' option to the preprocessor. Like 12# compiler but only a single '-arch' option to the preprocessor. Like
@@ -16,8 +16,7 @@ dnl with or without modifications, as long as this notice is preserved.
16# CXX="g++ -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" 17# CPP="gcc -E" CXXCPP="g++ -E"
18# 18#
19# Detect this situation and set the macro AA_APPLE_UNIVERSAL_BUILD at the 19# Detect this situation and set APPLE_UNIVERSAL_BUILD accordingly.
20# beginning of config.h and set APPLE_UNIVERSAL_BUILD accordingly.
21 20
22AC_DEFUN_ONCE([gl_MULTIARCH], 21AC_DEFUN_ONCE([gl_MULTIARCH],
23[ 22[
@@ -55,8 +54,6 @@ AC_DEFUN_ONCE([gl_MULTIARCH],
55 done 54 done
56 ]) 55 ])
57 if test $gl_cv_c_multiarch = yes; then 56 if test $gl_cv_c_multiarch = yes; then
58 AC_DEFINE([AA_APPLE_UNIVERSAL_BUILD], [1],
59 [Define if the compiler is building for multiple architectures of Apple platforms at once.])
60 APPLE_UNIVERSAL_BUILD=1 57 APPLE_UNIVERSAL_BUILD=1
61 else 58 else
62 APPLE_UNIVERSAL_BUILD=0 59 APPLE_UNIVERSAL_BUILD=0
diff --git a/gl/m4/netdb_h.m4 b/gl/m4/netdb_h.m4
index c870fb6..2c69f99 100644
--- a/gl/m4/netdb_h.m4
+++ b/gl/m4/netdb_h.m4
@@ -1,5 +1,5 @@
1# netdb_h.m4 serial 9 1# netdb_h.m4 serial 11
2dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2008-2013 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,6 @@ dnl with or without modifications, as long as this notice is preserved.
7AC_DEFUN([gl_HEADER_NETDB], 7AC_DEFUN([gl_HEADER_NETDB],
8[ 8[
9 AC_REQUIRE([gl_NETDB_H_DEFAULTS]) 9 AC_REQUIRE([gl_NETDB_H_DEFAULTS])
10 AC_CHECK_HEADERS_ONCE([netdb.h])
11 gl_CHECK_NEXT_HEADERS([netdb.h]) 10 gl_CHECK_NEXT_HEADERS([netdb.h])
12 if test $ac_cv_header_netdb_h = yes; then 11 if test $ac_cv_header_netdb_h = yes; then
13 HAVE_NETDB_H=1 12 HAVE_NETDB_H=1
@@ -27,6 +26,8 @@ AC_DEFUN([gl_NETDB_MODULE_INDICATOR],
27 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 26 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
28 AC_REQUIRE([gl_NETDB_H_DEFAULTS]) 27 AC_REQUIRE([gl_NETDB_H_DEFAULTS])
29 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 28 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
29 dnl Define it also as a C macro, for the benefit of the unit tests.
30 gl_MODULE_INDICATOR_FOR_TESTS([$1])
30]) 31])
31 32
32AC_DEFUN([gl_NETDB_H_DEFAULTS], 33AC_DEFUN([gl_NETDB_H_DEFAULTS],
@@ -38,4 +39,5 @@ AC_DEFUN([gl_NETDB_H_DEFAULTS],
38 HAVE_DECL_GAI_STRERROR=1; AC_SUBST([HAVE_DECL_GAI_STRERROR]) 39 HAVE_DECL_GAI_STRERROR=1; AC_SUBST([HAVE_DECL_GAI_STRERROR])
39 HAVE_DECL_GETADDRINFO=1; AC_SUBST([HAVE_DECL_GETADDRINFO]) 40 HAVE_DECL_GETADDRINFO=1; AC_SUBST([HAVE_DECL_GETADDRINFO])
40 HAVE_DECL_GETNAMEINFO=1; AC_SUBST([HAVE_DECL_GETNAMEINFO]) 41 HAVE_DECL_GETNAMEINFO=1; AC_SUBST([HAVE_DECL_GETNAMEINFO])
42 REPLACE_GAI_STRERROR=0; AC_SUBST([REPLACE_GAI_STRERROR])
41]) 43])
diff --git a/gl/m4/netinet_in_h.m4 b/gl/m4/netinet_in_h.m4
index cc7a44c..21971b2 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 4 1# netinet_in_h.m4 serial 5
2dnl Copyright (C) 2006-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2006-2013 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,4 +27,5 @@ AC_DEFUN([gl_HEADER_NETINET_IN],
27 AC_SUBST([HAVE_NETINET_IN_H]) 27 AC_SUBST([HAVE_NETINET_IN_H])
28 fi 28 fi
29 AC_SUBST([NETINET_IN_H]) 29 AC_SUBST([NETINET_IN_H])
30 AM_CONDITIONAL([GL_GENERATE_NETINET_IN_H], [test -n "$NETINET_IN_H"])
30]) 31])
diff --git a/gl/m4/nl_langinfo.m4 b/gl/m4/nl_langinfo.m4
index ad456a2..25e2101 100644
--- a/gl/m4/nl_langinfo.m4
+++ b/gl/m4/nl_langinfo.m4
@@ -1,5 +1,5 @@
1# nl_langinfo.m4 serial 3 1# nl_langinfo.m4 serial 5
2dnl Copyright (C) 2009, 2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2009-2013 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,17 +9,42 @@ AC_DEFUN([gl_FUNC_NL_LANGINFO],
9 AC_REQUIRE([gl_LANGINFO_H_DEFAULTS]) 9 AC_REQUIRE([gl_LANGINFO_H_DEFAULTS])
10 AC_REQUIRE([gl_LANGINFO_H]) 10 AC_REQUIRE([gl_LANGINFO_H])
11 AC_CHECK_FUNCS_ONCE([nl_langinfo]) 11 AC_CHECK_FUNCS_ONCE([nl_langinfo])
12 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
12 if test $ac_cv_func_nl_langinfo = yes; then 13 if test $ac_cv_func_nl_langinfo = yes; then
13 if test $HAVE_LANGINFO_CODESET = 1 && test $HAVE_LANGINFO_ERA = 1; then 14 # On Irix 6.5, YESEXPR is defined, but nl_langinfo(YESEXPR) is broken.
15 AC_CACHE_CHECK([whether YESEXPR works],
16 [gl_cv_func_nl_langinfo_yesexpr_works],
17 [AC_RUN_IFELSE(
18 [AC_LANG_PROGRAM([[#include <langinfo.h>
19]], [[return !*nl_langinfo(YESEXPR);
20]])],
21 [gl_cv_func_nl_langinfo_yesexpr_works=yes],
22 [gl_cv_func_nl_langinfo_yesexpr_works=no],
23 [
24 case "$host_os" in
25 # Guess no on irix systems.
26 irix*) gl_cv_func_nl_langinfo_yesexpr_works="guessing no";;
27 # Guess yes elsewhere.
28 *) gl_cv_func_nl_langinfo_yesexpr_works="guessing yes";;
29 esac
30 ])
31 ])
32 case $gl_cv_func_nl_langinfo_yesexpr_works in
33 *yes) FUNC_NL_LANGINFO_YESEXPR_WORKS=1 ;;
34 *) FUNC_NL_LANGINFO_YESEXPR_WORKS=0 ;;
35 esac
36 AC_DEFINE_UNQUOTED([FUNC_NL_LANGINFO_YESEXPR_WORKS],
37 [$FUNC_NL_LANGINFO_YESEXPR_WORKS],
38 [Define to 1 if nl_langinfo (YESEXPR) returns a non-empty string.])
39 if test $HAVE_LANGINFO_CODESET = 1 && test $HAVE_LANGINFO_ERA = 1 \
40 && test $FUNC_NL_LANGINFO_YESEXPR_WORKS = 1; then
14 : 41 :
15 else 42 else
16 REPLACE_NL_LANGINFO=1 43 REPLACE_NL_LANGINFO=1
17 AC_DEFINE([REPLACE_NL_LANGINFO], [1], 44 AC_DEFINE([REPLACE_NL_LANGINFO], [1],
18 [Define if nl_langinfo exists but is overridden by gnulib.]) 45 [Define if nl_langinfo exists but is overridden by gnulib.])
19 AC_LIBOBJ([nl_langinfo])
20 fi 46 fi
21 else 47 else
22 HAVE_NL_LANGINFO=0 48 HAVE_NL_LANGINFO=0
23 AC_LIBOBJ([nl_langinfo])
24 fi 49 fi
25]) 50])
diff --git a/gl/m4/nls.m4 b/gl/m4/nls.m4
index 003704c..8f8a147 100644
--- a/gl/m4/nls.m4
+++ b/gl/m4/nls.m4
@@ -1,5 +1,5 @@
1# nls.m4 serial 5 (gettext-0.18) 1# nls.m4 serial 5 (gettext-0.18)
2dnl Copyright (C) 1995-2003, 2005-2006, 2008-2010 Free Software Foundation, 2dnl Copyright (C) 1995-2003, 2005-2006, 2008-2013 Free Software Foundation,
3dnl Inc. 3dnl Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
diff --git a/gl/m4/nocrash.m4 b/gl/m4/nocrash.m4
new file mode 100644
index 0000000..105b884
--- /dev/null
+++ b/gl/m4/nocrash.m4
@@ -0,0 +1,130 @@
1# nocrash.m4 serial 4
2dnl Copyright (C) 2005, 2009-2013 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 Based on libsigsegv, from Bruno Haible and Paolo Bonzini.
8
9AC_PREREQ([2.13])
10
11dnl Expands to some code for use in .c programs that will cause the configure
12dnl test to exit instead of crashing. This is useful to avoid triggering
13dnl action from a background debugger and to avoid core dumps.
14dnl Usage: ...
15dnl ]GL_NOCRASH[
16dnl ...
17dnl int main() { nocrash_init(); ... }
18AC_DEFUN([GL_NOCRASH],[[
19#include <stdlib.h>
20#if defined __MACH__ && defined __APPLE__
21/* Avoid a crash on Mac OS X. */
22#include <mach/mach.h>
23#include <mach/mach_error.h>
24#include <mach/thread_status.h>
25#include <mach/exception.h>
26#include <mach/task.h>
27#include <pthread.h>
28/* The exception port on which our thread listens. */
29static mach_port_t our_exception_port;
30/* The main function of the thread listening for exceptions of type
31 EXC_BAD_ACCESS. */
32static void *
33mach_exception_thread (void *arg)
34{
35 /* Buffer for a message to be received. */
36 struct {
37 mach_msg_header_t head;
38 mach_msg_body_t msgh_body;
39 char data[1024];
40 } msg;
41 mach_msg_return_t retval;
42 /* Wait for a message on the exception port. */
43 retval = mach_msg (&msg.head, MACH_RCV_MSG | MACH_RCV_LARGE, 0, sizeof (msg),
44 our_exception_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
45 if (retval != MACH_MSG_SUCCESS)
46 abort ();
47 exit (1);
48}
49static void
50nocrash_init (void)
51{
52 mach_port_t self = mach_task_self ();
53 /* Allocate a port on which the thread shall listen for exceptions. */
54 if (mach_port_allocate (self, MACH_PORT_RIGHT_RECEIVE, &our_exception_port)
55 == KERN_SUCCESS) {
56 /* See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/mach_port_insert_right.html. */
57 if (mach_port_insert_right (self, our_exception_port, our_exception_port,
58 MACH_MSG_TYPE_MAKE_SEND)
59 == KERN_SUCCESS) {
60 /* The exceptions we want to catch. Only EXC_BAD_ACCESS is interesting
61 for us. */
62 exception_mask_t mask = EXC_MASK_BAD_ACCESS;
63 /* Create the thread listening on the exception port. */
64 pthread_attr_t attr;
65 pthread_t thread;
66 if (pthread_attr_init (&attr) == 0
67 && pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED) == 0
68 && pthread_create (&thread, &attr, mach_exception_thread, NULL) == 0) {
69 pthread_attr_destroy (&attr);
70 /* Replace the exception port info for these exceptions with our own.
71 Note that we replace the exception port for the entire task, not only
72 for a particular thread. This has the effect that when our exception
73 port gets the message, the thread specific exception port has already
74 been asked, and we don't need to bother about it.
75 See http://web.mit.edu/darwin/src/modules/xnu/osfmk/man/task_set_exception_ports.html. */
76 task_set_exception_ports (self, mask, our_exception_port,
77 EXCEPTION_DEFAULT, MACHINE_THREAD_STATE);
78 }
79 }
80 }
81}
82#elif (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
83/* Avoid a crash on native Windows. */
84#define WIN32_LEAN_AND_MEAN
85#include <windows.h>
86#include <winerror.h>
87static LONG WINAPI
88exception_filter (EXCEPTION_POINTERS *ExceptionInfo)
89{
90 switch (ExceptionInfo->ExceptionRecord->ExceptionCode)
91 {
92 case EXCEPTION_ACCESS_VIOLATION:
93 case EXCEPTION_IN_PAGE_ERROR:
94 case EXCEPTION_STACK_OVERFLOW:
95 case EXCEPTION_GUARD_PAGE:
96 case EXCEPTION_PRIV_INSTRUCTION:
97 case EXCEPTION_ILLEGAL_INSTRUCTION:
98 case EXCEPTION_DATATYPE_MISALIGNMENT:
99 case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
100 case EXCEPTION_NONCONTINUABLE_EXCEPTION:
101 exit (1);
102 }
103 return EXCEPTION_CONTINUE_SEARCH;
104}
105static void
106nocrash_init (void)
107{
108 SetUnhandledExceptionFilter ((LPTOP_LEVEL_EXCEPTION_FILTER) exception_filter);
109}
110#else
111/* Avoid a crash on POSIX systems. */
112#include <signal.h>
113/* A POSIX signal handler. */
114static void
115exception_handler (int sig)
116{
117 exit (1);
118}
119static void
120nocrash_init (void)
121{
122#ifdef SIGSEGV
123 signal (SIGSEGV, exception_handler);
124#endif
125#ifdef SIGBUS
126 signal (SIGBUS, exception_handler);
127#endif
128}
129#endif
130]])
diff --git a/gl/m4/off_t.m4 b/gl/m4/off_t.m4
new file mode 100644
index 0000000..d355d01
--- /dev/null
+++ b/gl/m4/off_t.m4
@@ -0,0 +1,18 @@
1# off_t.m4 serial 1
2dnl Copyright (C) 2012-2013 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 Check whether to override the 'off_t' type.
8dnl Set WINDOWS_64_BIT_OFF_T.
9
10AC_DEFUN([gl_TYPE_OFF_T],
11[
12 m4_ifdef([gl_LARGEFILE], [
13 AC_REQUIRE([gl_LARGEFILE])
14 ], [
15 WINDOWS_64_BIT_OFF_T=0
16 ])
17 AC_SUBST([WINDOWS_64_BIT_OFF_T])
18])
diff --git a/gl/m4/onceonly.m4 b/gl/m4/onceonly.m4
index 6a9c87b..0a875a3 100644
--- a/gl/m4/onceonly.m4
+++ b/gl/m4/onceonly.m4
@@ -1,9 +1,22 @@
1# onceonly.m4 serial 7 1# onceonly.m4 serial 9
2dnl Copyright (C) 2002-2003, 2005-2006, 2008-2010 Free Software Foundation, 2dnl Copyright (C) 2002-2003, 2005-2006, 2008-2013 Free Software Foundation,
3dnl Inc. 3dnl Inc.
4dnl This file is free software, distributed under the terms of the GNU 4dnl
5dnl General Public License. As a special exception to the GNU General 5dnl This file is free software; you can redistribute it and/or modify
6dnl Public License, this file may be distributed as part of a program 6dnl it under the terms of the GNU General Public License as published by
7dnl the Free Software Foundation; either version 3 of the License, or
8dnl (at your option) any later version.
9dnl
10dnl This file is distributed in the hope that it will be useful,
11dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
12dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13dnl GNU General Public License for more details.
14dnl
15dnl You should have received a copy of the GNU General Public License
16dnl along with this file. If not, see <http://www.gnu.org/licenses/>.
17dnl
18dnl As a special exception to the GNU General Public License,
19dnl this file may be distributed as part of a program
7dnl that contains a configuration script generated by Autoconf, under 20dnl that contains a configuration script generated by Autoconf, under
8dnl the same distribution terms as the rest of that program. 21dnl the same distribution terms as the rest of that program.
9 22
@@ -67,7 +80,7 @@ AC_DEFUN([AC_CHECK_FUNCS_ONCE], [
67 [gl_func_list="$gl_func_list gl_FUNC_NAME"]) 80 [gl_func_list="$gl_func_list gl_FUNC_NAME"])
68 gl_FUNCS_EXPANSION 81 gl_FUNCS_EXPANSION
69 AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([gl_FUNC_NAME])), 82 AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([gl_FUNC_NAME])),
70 [Define to 1 if you have the `]m4_defn([gl_FUNC_NAME])[' function.]) 83 [Define to 1 if you have the ']m4_defn([gl_FUNC_NAME])[' function.])
71 ]) 84 ])
72 AC_REQUIRE([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME])) 85 AC_REQUIRE([gl_CHECK_FUNC_]m4_defn([gl_FUNC_NAME]))
73 ]) 86 ])
diff --git a/gl/m4/open.m4 b/gl/m4/open.m4
deleted file mode 100644
index d705b3a..0000000
--- a/gl/m4/open.m4
+++ /dev/null
@@ -1,74 +0,0 @@
1# open.m4 serial 8
2dnl Copyright (C) 2007-2010 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
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. FreeBSD only has the problem on symlinks.
17 AC_CHECK_FUNCS_ONCE([lstat])
18 AC_CACHE_CHECK([whether open recognizes a trailing slash],
19 [gl_cv_func_open_slash],
20 [# Assume that if we have lstat, we can also check symlinks.
21 if test $ac_cv_func_lstat = yes; then
22 touch conftest.tmp
23 ln -s conftest.tmp conftest.lnk
24 fi
25 AC_TRY_RUN([
26#include <fcntl.h>
27#if HAVE_UNISTD_H
28# include <unistd.h>
29#endif
30int main ()
31{
32#if HAVE_LSTAT
33 if (open ("conftest.lnk/", O_RDONLY) != -1) return 2;
34#endif
35 return open ("conftest.sl/", O_CREAT, 0600) >= 0;
36}], [gl_cv_func_open_slash=yes], [gl_cv_func_open_slash=no],
37 [
38changequote(,)dnl
39 case "$host_os" in
40 freebsd*) gl_cv_func_open_slash="guessing no" ;;
41 solaris2.[0-9]*) gl_cv_func_open_slash="guessing no" ;;
42 hpux*) gl_cv_func_open_slash="guessing no" ;;
43 *) gl_cv_func_open_slash="guessing yes" ;;
44 esac
45changequote([,])dnl
46 ])
47 rm -f conftest.sl conftest.tmp conftest.lnk
48 ])
49 case "$gl_cv_func_open_slash" in
50 *no)
51 AC_DEFINE([OPEN_TRAILING_SLASH_BUG], [1],
52 [Define to 1 if open() fails to recognize a trailing slash.])
53 gl_REPLACE_OPEN
54 ;;
55 esac
56 ;;
57 esac
58])
59
60AC_DEFUN([gl_REPLACE_OPEN],
61[
62 AC_REQUIRE([gl_FCNTL_H_DEFAULTS])
63 REPLACE_OPEN=1
64 AC_LIBOBJ([open])
65 gl_PREREQ_OPEN
66])
67
68# Prerequisites of lib/open.c.
69AC_DEFUN([gl_PREREQ_OPEN],
70[
71 AC_REQUIRE([AC_C_INLINE])
72 AC_REQUIRE([gl_PROMOTED_TYPE_MODE_T])
73 :
74])
diff --git a/gl/m4/po.m4 b/gl/m4/po.m4
index 47f36a4..1c70b6c 100644
--- a/gl/m4/po.m4
+++ b/gl/m4/po.m4
@@ -1,5 +1,5 @@
1# po.m4 serial 17 (gettext-0.18) 1# po.m4 serial 21 (gettext-0.18.3)
2dnl Copyright (C) 1995-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 1995-2013 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,14 +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.60])
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],
24[ 24[
25 AC_REQUIRE([AC_PROG_MAKE_SET])dnl 25 AC_REQUIRE([AC_PROG_MAKE_SET])dnl
26 AC_REQUIRE([AC_PROG_INSTALL])dnl 26 AC_REQUIRE([AC_PROG_INSTALL])dnl
27 AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake 27 AC_REQUIRE([AC_PROG_MKDIR_P])dnl
28 AC_REQUIRE([AC_PROG_SED])dnl
28 AC_REQUIRE([AM_NLS])dnl 29 AC_REQUIRE([AM_NLS])dnl
29 30
30 dnl Release version of the gettext macros. This is used to ensure that 31 dnl Release version of the gettext macros. This is used to ensure that
@@ -102,7 +103,7 @@ changequote([,])dnl
102 case "$ac_file" in */Makefile.in) 103 case "$ac_file" in */Makefile.in)
103 # Adjust a relative srcdir. 104 # Adjust a relative srcdir.
104 ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` 105 ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
105 ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`" 106 ac_dir_suffix=/`echo "$ac_dir"|sed 's%^\./%%'`
106 ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` 107 ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
107 # In autoconf-2.13 it is called $ac_given_srcdir. 108 # In autoconf-2.13 it is called $ac_given_srcdir.
108 # In autoconf-2.50 it is called $srcdir. 109 # In autoconf-2.50 it is called $srcdir.
@@ -118,7 +119,8 @@ changequote([,])dnl
118 if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then 119 if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then
119 rm -f "$ac_dir/POTFILES" 120 rm -f "$ac_dir/POTFILES"
120 test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES" 121 test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES"
121 cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ ]*\$/d" -e "s,.*, $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES" 122 gt_tab=`printf '\t'`
123 cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ ${gt_tab}]*\$/d" -e "s,.*, $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES"
122 POMAKEFILEDEPS="POTFILES.in" 124 POMAKEFILEDEPS="POTFILES.in"
123 # ALL_LINGUAS, POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES depend 125 # ALL_LINGUAS, POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES depend
124 # on $ac_dir but don't depend on user-specified configuration 126 # on $ac_dir but don't depend on user-specified configuration
@@ -129,12 +131,12 @@ changequote([,])dnl
129 test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete" 131 test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete"
130 fi 132 fi
131 ALL_LINGUAS_=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"` 133 ALL_LINGUAS_=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"`
132 # Hide the ALL_LINGUAS assigment from automake < 1.5. 134 # Hide the ALL_LINGUAS assignment from automake < 1.5.
133 eval 'ALL_LINGUAS''=$ALL_LINGUAS_' 135 eval 'ALL_LINGUAS''=$ALL_LINGUAS_'
134 POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS" 136 POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS"
135 else 137 else
136 # The set of available languages was given in configure.in. 138 # The set of available languages was given in configure.in.
137 # Hide the ALL_LINGUAS assigment from automake < 1.5. 139 # Hide the ALL_LINGUAS assignment from automake < 1.5.
138 eval 'ALL_LINGUAS''=$OBSOLETE_ALL_LINGUAS' 140 eval 'ALL_LINGUAS''=$OBSOLETE_ALL_LINGUAS'
139 fi 141 fi
140 # Compute POFILES 142 # Compute POFILES
@@ -226,7 +228,7 @@ AC_DEFUN([AM_POSTPROCESS_PO_MAKEFILE],
226changequote(,)dnl 228changequote(,)dnl
227 # Adjust a relative srcdir. 229 # Adjust a relative srcdir.
228 ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` 230 ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
229 ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`" 231 ac_dir_suffix=/`echo "$ac_dir"|sed 's%^\./%%'`
230 ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` 232 ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
231 # In autoconf-2.13 it is called $ac_given_srcdir. 233 # In autoconf-2.13 it is called $ac_given_srcdir.
232 # In autoconf-2.50 it is called $srcdir. 234 # In autoconf-2.50 it is called $srcdir.
@@ -254,6 +256,7 @@ EOT
254 fi 256 fi
255 257
256 # A sed script that extracts the value of VARIABLE from a Makefile. 258 # A sed script that extracts the value of VARIABLE from a Makefile.
259 tab=`printf '\t'`
257 sed_x_variable=' 260 sed_x_variable='
258# Test if the hold space is empty. 261# Test if the hold space is empty.
259x 262x
@@ -261,9 +264,9 @@ s/P/P/
261x 264x
262ta 265ta
263# Yes it was empty. Look if we have the expected variable definition. 266# Yes it was empty. Look if we have the expected variable definition.
264/^[ ]*VARIABLE[ ]*=/{ 267/^['"${tab}"' ]*VARIABLE['"${tab}"' ]*=/{
265 # Seen the first line of the variable definition. 268 # Seen the first line of the variable definition.
266 s/^[ ]*VARIABLE[ ]*=// 269 s/^['"${tab}"' ]*VARIABLE['"${tab}"' ]*=//
267 ba 270 ba
268} 271}
269bd 272bd
@@ -315,7 +318,7 @@ changequote([,])dnl
315 sed_x_LINGUAS=`$gt_echo "$sed_x_variable" | sed -e '/^ *#/d' -e 's/VARIABLE/LINGUAS/g'` 318 sed_x_LINGUAS=`$gt_echo "$sed_x_variable" | sed -e '/^ *#/d' -e 's/VARIABLE/LINGUAS/g'`
316 ALL_LINGUAS_=`sed -n -e "$sed_x_LINGUAS" < "$ac_file"` 319 ALL_LINGUAS_=`sed -n -e "$sed_x_LINGUAS" < "$ac_file"`
317 fi 320 fi
318 # Hide the ALL_LINGUAS assigment from automake < 1.5. 321 # Hide the ALL_LINGUAS assignment from automake < 1.5.
319 eval 'ALL_LINGUAS''=$ALL_LINGUAS_' 322 eval 'ALL_LINGUAS''=$ALL_LINGUAS_'
320 # Compute POFILES 323 # Compute POFILES
321 # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po) 324 # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po)
@@ -405,14 +408,15 @@ changequote([,])dnl
405 fi 408 fi
406 409
407 sed -e "s|@POTFILES_DEPS@|$POTFILES_DEPS|g" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@PROPERTIESFILES@|$PROPERTIESFILES|g" -e "s|@CLASSFILES@|$CLASSFILES|g" -e "s|@QMFILES@|$QMFILES|g" -e "s|@MSGFILES@|$MSGFILES|g" -e "s|@RESOURCESDLLFILES@|$RESOURCESDLLFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@JAVACATALOGS@|$JAVACATALOGS|g" -e "s|@QTCATALOGS@|$QTCATALOGS|g" -e "s|@TCLCATALOGS@|$TCLCATALOGS|g" -e "s|@CSHARPCATALOGS@|$CSHARPCATALOGS|g" -e 's,^#distdir:,distdir:,' < "$ac_file" > "$ac_file.tmp" 410 sed -e "s|@POTFILES_DEPS@|$POTFILES_DEPS|g" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@PROPERTIESFILES@|$PROPERTIESFILES|g" -e "s|@CLASSFILES@|$CLASSFILES|g" -e "s|@QMFILES@|$QMFILES|g" -e "s|@MSGFILES@|$MSGFILES|g" -e "s|@RESOURCESDLLFILES@|$RESOURCESDLLFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@JAVACATALOGS@|$JAVACATALOGS|g" -e "s|@QTCATALOGS@|$QTCATALOGS|g" -e "s|@TCLCATALOGS@|$TCLCATALOGS|g" -e "s|@CSHARPCATALOGS@|$CSHARPCATALOGS|g" -e 's,^#distdir:,distdir:,' < "$ac_file" > "$ac_file.tmp"
411 tab=`printf '\t'`
408 if grep -l '@TCLCATALOGS@' "$ac_file" > /dev/null; then 412 if grep -l '@TCLCATALOGS@' "$ac_file" > /dev/null; then
409 # Add dependencies that cannot be formulated as a simple suffix rule. 413 # Add dependencies that cannot be formulated as a simple suffix rule.
410 for lang in $ALL_LINGUAS; do 414 for lang in $ALL_LINGUAS; do
411 frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` 415 frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
412 cat >> "$ac_file.tmp" <<EOF 416 cat >> "$ac_file.tmp" <<EOF
413$frobbedlang.msg: $lang.po 417$frobbedlang.msg: $lang.po
414 @echo "\$(MSGFMT) -c --tcl -d \$(srcdir) -l $lang $srcdirpre$lang.po"; \ 418${tab}@echo "\$(MSGFMT) -c --tcl -d \$(srcdir) -l $lang $srcdirpre$lang.po"; \
415 \$(MSGFMT) -c --tcl -d "\$(srcdir)" -l $lang $srcdirpre$lang.po || { rm -f "\$(srcdir)/$frobbedlang.msg"; exit 1; } 419${tab}\$(MSGFMT) -c --tcl -d "\$(srcdir)" -l $lang $srcdirpre$lang.po || { rm -f "\$(srcdir)/$frobbedlang.msg"; exit 1; }
416EOF 420EOF
417 done 421 done
418 fi 422 fi
@@ -422,8 +426,8 @@ EOF
422 frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'` 426 frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'`
423 cat >> "$ac_file.tmp" <<EOF 427 cat >> "$ac_file.tmp" <<EOF
424$frobbedlang/\$(DOMAIN).resources.dll: $lang.po 428$frobbedlang/\$(DOMAIN).resources.dll: $lang.po
425 @echo "\$(MSGFMT) -c --csharp -d \$(srcdir) -l $lang $srcdirpre$lang.po -r \$(DOMAIN)"; \ 429${tab}@echo "\$(MSGFMT) -c --csharp -d \$(srcdir) -l $lang $srcdirpre$lang.po -r \$(DOMAIN)"; \
426 \$(MSGFMT) -c --csharp -d "\$(srcdir)" -l $lang $srcdirpre$lang.po -r "\$(DOMAIN)" || { rm -f "\$(srcdir)/$frobbedlang.msg"; exit 1; } 430${tab}\$(MSGFMT) -c --csharp -d "\$(srcdir)" -l $lang $srcdirpre$lang.po -r "\$(DOMAIN)" || { rm -f "\$(srcdir)/$frobbedlang.msg"; exit 1; }
427EOF 431EOF
428 done 432 done
429 fi 433 fi
diff --git a/gl/m4/printf-posix.m4 b/gl/m4/printf-posix.m4
index 1eacf95..d7dfb60 100644
--- a/gl/m4/printf-posix.m4
+++ b/gl/m4/printf-posix.m4
@@ -1,5 +1,5 @@
1# printf-posix.m4 serial 5 (gettext-0.18) 1# printf-posix.m4 serial 6 (gettext-0.18.2)
2dnl Copyright (C) 2003, 2007, 2009-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2003, 2007, 2009-2013 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.
@@ -14,7 +14,8 @@ AC_DEFUN([gt_PRINTF_POSIX],
14 AC_CACHE_CHECK([whether printf() supports POSIX/XSI format strings], 14 AC_CACHE_CHECK([whether printf() supports POSIX/XSI format strings],
15 gt_cv_func_printf_posix, 15 gt_cv_func_printf_posix,
16 [ 16 [
17 AC_TRY_RUN([ 17 AC_RUN_IFELSE(
18 [AC_LANG_SOURCE([[
18#include <stdio.h> 19#include <stdio.h>
19#include <string.h> 20#include <string.h>
20/* The string "%2$d %1$d", with dollar characters protected from the shell's 21/* The string "%2$d %1$d", with dollar characters protected from the shell's
@@ -25,16 +26,18 @@ int main ()
25{ 26{
26 sprintf (buf, format, 33, 55); 27 sprintf (buf, format, 33, 55);
27 return (strcmp (buf, "55 33") != 0); 28 return (strcmp (buf, "55 33") != 0);
28}], gt_cv_func_printf_posix=yes, gt_cv_func_printf_posix=no, 29}]])],
29 [ 30 [gt_cv_func_printf_posix=yes],
30 AC_EGREP_CPP([notposix], [ 31 [gt_cv_func_printf_posix=no],
32 [
33 AC_EGREP_CPP([notposix], [
31#if defined __NetBSD__ || defined __BEOS__ || defined _MSC_VER || defined __MINGW32__ || defined __CYGWIN__ 34#if defined __NetBSD__ || defined __BEOS__ || defined _MSC_VER || defined __MINGW32__ || defined __CYGWIN__
32 notposix 35 notposix
33#endif 36#endif
34 ], 37 ],
35 [gt_cv_func_printf_posix="guessing no"], 38 [gt_cv_func_printf_posix="guessing no"],
36 [gt_cv_func_printf_posix="guessing yes"]) 39 [gt_cv_func_printf_posix="guessing yes"])
37 ]) 40 ])
38 ]) 41 ])
39 case $gt_cv_func_printf_posix in 42 case $gt_cv_func_printf_posix in
40 *yes) 43 *yes)
diff --git a/gl/m4/printf.m4 b/gl/m4/printf.m4
index b31efe3..ef44f78 100644
--- a/gl/m4/printf.m4
+++ b/gl/m4/printf.m4
@@ -1,5 +1,5 @@
1# printf.m4 serial 34 1# printf.m4 serial 50
2dnl Copyright (C) 2003, 2007-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2003, 2007-2013 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,8 @@ AC_DEFUN([gl_PRINTF_SIZES_C99],
17 AC_CACHE_CHECK([whether printf supports size specifiers as in C99], 17 AC_CACHE_CHECK([whether printf supports size specifiers as in C99],
18 [gl_cv_func_printf_sizes_c99], 18 [gl_cv_func_printf_sizes_c99],
19 [ 19 [
20 AC_TRY_RUN([ 20 AC_RUN_IFELSE(
21 [AC_LANG_SOURCE([[
21#include <stddef.h> 22#include <stddef.h>
22#include <stdio.h> 23#include <stdio.h>
23#include <string.h> 24#include <string.h>
@@ -31,53 +32,56 @@ AC_DEFUN([gl_PRINTF_SIZES_C99],
31static char buf[100]; 32static char buf[100];
32int main () 33int main ()
33{ 34{
35 int result = 0;
34#if HAVE_STDINT_H_WITH_UINTMAX || HAVE_INTTYPES_H_WITH_UINTMAX 36#if HAVE_STDINT_H_WITH_UINTMAX || HAVE_INTTYPES_H_WITH_UINTMAX
35 buf[0] = '\0'; 37 buf[0] = '\0';
36 if (sprintf (buf, "%ju %d", (uintmax_t) 12345671, 33, 44, 55) < 0 38 if (sprintf (buf, "%ju %d", (uintmax_t) 12345671, 33, 44, 55) < 0
37 || strcmp (buf, "12345671 33") != 0) 39 || strcmp (buf, "12345671 33") != 0)
38 return 1; 40 result |= 1;
39#endif 41#endif
40 buf[0] = '\0'; 42 buf[0] = '\0';
41 if (sprintf (buf, "%zu %d", (size_t) 12345672, 33, 44, 55) < 0 43 if (sprintf (buf, "%zu %d", (size_t) 12345672, 33, 44, 55) < 0
42 || strcmp (buf, "12345672 33") != 0) 44 || strcmp (buf, "12345672 33") != 0)
43 return 1; 45 result |= 2;
44 buf[0] = '\0'; 46 buf[0] = '\0';
45 if (sprintf (buf, "%tu %d", (ptrdiff_t) 12345673, 33, 44, 55) < 0 47 if (sprintf (buf, "%tu %d", (ptrdiff_t) 12345673, 33, 44, 55) < 0
46 || strcmp (buf, "12345673 33") != 0) 48 || strcmp (buf, "12345673 33") != 0)
47 return 1; 49 result |= 4;
48 buf[0] = '\0'; 50 buf[0] = '\0';
49 if (sprintf (buf, "%Lg %d", (long double) 1.5, 33, 44, 55) < 0 51 if (sprintf (buf, "%Lg %d", (long double) 1.5, 33, 44, 55) < 0
50 || strcmp (buf, "1.5 33") != 0) 52 || strcmp (buf, "1.5 33") != 0)
51 return 1; 53 result |= 8;
52 return 0; 54 return result;
53}], [gl_cv_func_printf_sizes_c99=yes], [gl_cv_func_printf_sizes_c99=no], 55}]])],
54 [ 56 [gl_cv_func_printf_sizes_c99=yes],
57 [gl_cv_func_printf_sizes_c99=no],
58 [
55changequote(,)dnl 59changequote(,)dnl
56 case "$host_os" in 60 case "$host_os" in
57 # Guess yes on glibc systems. 61 # Guess yes on glibc systems.
58 *-gnu*) gl_cv_func_printf_sizes_c99="guessing yes";; 62 *-gnu*) gl_cv_func_printf_sizes_c99="guessing yes";;
59 # Guess yes on FreeBSD >= 5. 63 # Guess yes on FreeBSD >= 5.
60 freebsd[1-4]*) gl_cv_func_printf_sizes_c99="guessing no";; 64 freebsd[1-4]*) gl_cv_func_printf_sizes_c99="guessing no";;
61 freebsd* | kfreebsd*) gl_cv_func_printf_sizes_c99="guessing yes";; 65 freebsd* | kfreebsd*) gl_cv_func_printf_sizes_c99="guessing yes";;
62 # Guess yes on MacOS X >= 10.3. 66 # Guess yes on Mac OS X >= 10.3.
63 darwin[1-6].*) gl_cv_func_printf_sizes_c99="guessing no";; 67 darwin[1-6].*) gl_cv_func_printf_sizes_c99="guessing no";;
64 darwin*) gl_cv_func_printf_sizes_c99="guessing yes";; 68 darwin*) gl_cv_func_printf_sizes_c99="guessing yes";;
65 # Guess yes on OpenBSD >= 3.9. 69 # Guess yes on OpenBSD >= 3.9.
66 openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*) 70 openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*)
67 gl_cv_func_printf_sizes_c99="guessing no";; 71 gl_cv_func_printf_sizes_c99="guessing no";;
68 openbsd*) gl_cv_func_printf_sizes_c99="guessing yes";; 72 openbsd*) gl_cv_func_printf_sizes_c99="guessing yes";;
69 # Guess yes on Solaris >= 2.10. 73 # Guess yes on Solaris >= 2.10.
70 solaris2.[0-9]*) gl_cv_func_printf_sizes_c99="guessing no";; 74 solaris2.[1-9][0-9]*) gl_cv_func_printf_sizes_c99="guessing yes";;
71 solaris*) gl_cv_func_printf_sizes_c99="guessing yes";; 75 solaris*) gl_cv_func_printf_sizes_c99="guessing no";;
72 # Guess yes on NetBSD >= 3. 76 # Guess yes on NetBSD >= 3.
73 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) 77 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
74 gl_cv_func_printf_sizes_c99="guessing no";; 78 gl_cv_func_printf_sizes_c99="guessing no";;
75 netbsd*) gl_cv_func_printf_sizes_c99="guessing yes";; 79 netbsd*) gl_cv_func_printf_sizes_c99="guessing yes";;
76 # If we don't know, assume the worst. 80 # If we don't know, assume the worst.
77 *) gl_cv_func_printf_sizes_c99="guessing no";; 81 *) gl_cv_func_printf_sizes_c99="guessing no";;
78 esac 82 esac
79changequote([,])dnl 83changequote([,])dnl
80 ]) 84 ])
81 ]) 85 ])
82]) 86])
83 87
@@ -92,35 +96,39 @@ AC_DEFUN([gl_PRINTF_LONG_DOUBLE],
92 AC_CACHE_CHECK([whether printf supports 'long double' arguments], 96 AC_CACHE_CHECK([whether printf supports 'long double' arguments],
93 [gl_cv_func_printf_long_double], 97 [gl_cv_func_printf_long_double],
94 [ 98 [
95 AC_TRY_RUN([ 99 AC_RUN_IFELSE(
100 [AC_LANG_SOURCE([[
96#include <stdio.h> 101#include <stdio.h>
97#include <string.h> 102#include <string.h>
98static char buf[10000]; 103static char buf[10000];
99int main () 104int main ()
100{ 105{
106 int result = 0;
101 buf[0] = '\0'; 107 buf[0] = '\0';
102 if (sprintf (buf, "%Lf %d", 1.75L, 33, 44, 55) < 0 108 if (sprintf (buf, "%Lf %d", 1.75L, 33, 44, 55) < 0
103 || strcmp (buf, "1.750000 33") != 0) 109 || strcmp (buf, "1.750000 33") != 0)
104 return 1; 110 result |= 1;
105 buf[0] = '\0'; 111 buf[0] = '\0';
106 if (sprintf (buf, "%Le %d", 1.75L, 33, 44, 55) < 0 112 if (sprintf (buf, "%Le %d", 1.75L, 33, 44, 55) < 0
107 || strcmp (buf, "1.750000e+00 33") != 0) 113 || strcmp (buf, "1.750000e+00 33") != 0)
108 return 1; 114 result |= 2;
109 buf[0] = '\0'; 115 buf[0] = '\0';
110 if (sprintf (buf, "%Lg %d", 1.75L, 33, 44, 55) < 0 116 if (sprintf (buf, "%Lg %d", 1.75L, 33, 44, 55) < 0
111 || strcmp (buf, "1.75 33") != 0) 117 || strcmp (buf, "1.75 33") != 0)
112 return 1; 118 result |= 4;
113 return 0; 119 return result;
114}], [gl_cv_func_printf_long_double=yes], [gl_cv_func_printf_long_double=no], 120}]])],
115 [ 121 [gl_cv_func_printf_long_double=yes],
122 [gl_cv_func_printf_long_double=no],
123 [
116changequote(,)dnl 124changequote(,)dnl
117 case "$host_os" in 125 case "$host_os" in
118 beos*) gl_cv_func_printf_long_double="guessing no";; 126 beos*) gl_cv_func_printf_long_double="guessing no";;
119 mingw* | pw*) gl_cv_func_printf_long_double="guessing no";; 127 mingw* | pw*) gl_cv_func_printf_long_double="guessing no";;
120 *) gl_cv_func_printf_long_double="guessing yes";; 128 *) gl_cv_func_printf_long_double="guessing yes";;
121 esac 129 esac
122changequote([,])dnl 130changequote([,])dnl
123 ]) 131 ])
124 ]) 132 ])
125]) 133])
126 134
@@ -136,7 +144,8 @@ AC_DEFUN([gl_PRINTF_INFINITE],
136 AC_CACHE_CHECK([whether printf supports infinite 'double' arguments], 144 AC_CACHE_CHECK([whether printf supports infinite 'double' arguments],
137 [gl_cv_func_printf_infinite], 145 [gl_cv_func_printf_infinite],
138 [ 146 [
139 AC_TRY_RUN([ 147 AC_RUN_IFELSE(
148 [AC_LANG_SOURCE([[
140#include <stdio.h> 149#include <stdio.h>
141#include <string.h> 150#include <string.h>
142static int 151static int
@@ -168,65 +177,68 @@ static char buf[10000];
168static double zero = 0.0; 177static double zero = 0.0;
169int main () 178int main ()
170{ 179{
171 if (sprintf (buf, "%f", 1.0 / 0.0) < 0 180 int result = 0;
181 if (sprintf (buf, "%f", 1.0 / zero) < 0
172 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0)) 182 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
173 return 1; 183 result |= 1;
174 if (sprintf (buf, "%f", -1.0 / 0.0) < 0 184 if (sprintf (buf, "%f", -1.0 / zero) < 0
175 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0)) 185 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
176 return 1; 186 result |= 1;
177 if (sprintf (buf, "%f", zero / zero) < 0 187 if (sprintf (buf, "%f", zero / zero) < 0
178 || !strisnan (buf, 0, strlen (buf))) 188 || !strisnan (buf, 0, strlen (buf)))
179 return 1; 189 result |= 2;
180 if (sprintf (buf, "%e", 1.0 / 0.0) < 0 190 if (sprintf (buf, "%e", 1.0 / zero) < 0
181 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0)) 191 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
182 return 1; 192 result |= 4;
183 if (sprintf (buf, "%e", -1.0 / 0.0) < 0 193 if (sprintf (buf, "%e", -1.0 / zero) < 0
184 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0)) 194 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
185 return 1; 195 result |= 4;
186 if (sprintf (buf, "%e", zero / zero) < 0 196 if (sprintf (buf, "%e", zero / zero) < 0
187 || !strisnan (buf, 0, strlen (buf))) 197 || !strisnan (buf, 0, strlen (buf)))
188 return 1; 198 result |= 8;
189 if (sprintf (buf, "%g", 1.0 / 0.0) < 0 199 if (sprintf (buf, "%g", 1.0 / zero) < 0
190 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0)) 200 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
191 return 1; 201 result |= 16;
192 if (sprintf (buf, "%g", -1.0 / 0.0) < 0 202 if (sprintf (buf, "%g", -1.0 / zero) < 0
193 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0)) 203 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
194 return 1; 204 result |= 16;
195 if (sprintf (buf, "%g", zero / zero) < 0 205 if (sprintf (buf, "%g", zero / zero) < 0
196 || !strisnan (buf, 0, strlen (buf))) 206 || !strisnan (buf, 0, strlen (buf)))
197 return 1; 207 result |= 32;
198 /* This test fails on HP-UX 10.20. */ 208 /* This test fails on HP-UX 10.20. */
199 if (have_minus_zero ()) 209 if (have_minus_zero ())
200 if (sprintf (buf, "%g", - zero) < 0 210 if (sprintf (buf, "%g", - zero) < 0
201 || strcmp (buf, "-0") != 0) 211 || strcmp (buf, "-0") != 0)
202 return 1; 212 result |= 64;
203 return 0; 213 return result;
204}], [gl_cv_func_printf_infinite=yes], [gl_cv_func_printf_infinite=no], 214}]])],
205 [ 215 [gl_cv_func_printf_infinite=yes],
216 [gl_cv_func_printf_infinite=no],
217 [
206changequote(,)dnl 218changequote(,)dnl
207 case "$host_os" in 219 case "$host_os" in
208 # Guess yes on glibc systems. 220 # Guess yes on glibc systems.
209 *-gnu*) gl_cv_func_printf_infinite="guessing yes";; 221 *-gnu*) gl_cv_func_printf_infinite="guessing yes";;
210 # Guess yes on FreeBSD >= 6. 222 # Guess yes on FreeBSD >= 6.
211 freebsd[1-5]*) gl_cv_func_printf_infinite="guessing no";; 223 freebsd[1-5]*) gl_cv_func_printf_infinite="guessing no";;
212 freebsd* | kfreebsd*) gl_cv_func_printf_infinite="guessing yes";; 224 freebsd* | kfreebsd*) gl_cv_func_printf_infinite="guessing yes";;
213 # Guess yes on MacOS X >= 10.3. 225 # Guess yes on Mac OS X >= 10.3.
214 darwin[1-6].*) gl_cv_func_printf_infinite="guessing no";; 226 darwin[1-6].*) gl_cv_func_printf_infinite="guessing no";;
215 darwin*) gl_cv_func_printf_infinite="guessing yes";; 227 darwin*) gl_cv_func_printf_infinite="guessing yes";;
216 # Guess yes on HP-UX >= 11. 228 # Guess yes on HP-UX >= 11.
217 hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite="guessing no";; 229 hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite="guessing no";;
218 hpux*) gl_cv_func_printf_infinite="guessing yes";; 230 hpux*) gl_cv_func_printf_infinite="guessing yes";;
219 # Guess yes on NetBSD >= 3. 231 # Guess yes on NetBSD >= 3.
220 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) 232 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
221 gl_cv_func_printf_infinite="guessing no";; 233 gl_cv_func_printf_infinite="guessing no";;
222 netbsd*) gl_cv_func_printf_infinite="guessing yes";; 234 netbsd*) gl_cv_func_printf_infinite="guessing yes";;
223 # Guess yes on BeOS. 235 # Guess yes on BeOS.
224 beos*) gl_cv_func_printf_infinite="guessing yes";; 236 beos*) gl_cv_func_printf_infinite="guessing yes";;
225 # If we don't know, assume the worst. 237 # If we don't know, assume the worst.
226 *) gl_cv_func_printf_infinite="guessing no";; 238 *) gl_cv_func_printf_infinite="guessing no";;
227 esac 239 esac
228changequote([,])dnl 240changequote([,])dnl
229 ]) 241 ])
230 ]) 242 ])
231]) 243])
232 244
@@ -239,6 +251,7 @@ AC_DEFUN([gl_PRINTF_INFINITE_LONG_DOUBLE],
239 AC_REQUIRE([gl_PRINTF_LONG_DOUBLE]) 251 AC_REQUIRE([gl_PRINTF_LONG_DOUBLE])
240 AC_REQUIRE([AC_PROG_CC]) 252 AC_REQUIRE([AC_PROG_CC])
241 AC_REQUIRE([gl_BIGENDIAN]) 253 AC_REQUIRE([gl_BIGENDIAN])
254 AC_REQUIRE([gl_LONG_DOUBLE_VS_DOUBLE])
242 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 255 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
243 dnl The user can set or unset the variable gl_printf_safe to indicate 256 dnl The user can set or unset the variable gl_printf_safe to indicate
244 dnl that he wishes a safe handling of non-IEEE-754 'long double' values. 257 dnl that he wishes a safe handling of non-IEEE-754 'long double' values.
@@ -252,7 +265,8 @@ AC_DEFUN([gl_PRINTF_INFINITE_LONG_DOUBLE],
252 AC_CACHE_CHECK([whether printf supports infinite 'long double' arguments], 265 AC_CACHE_CHECK([whether printf supports infinite 'long double' arguments],
253 [gl_cv_func_printf_infinite_long_double], 266 [gl_cv_func_printf_infinite_long_double],
254 [ 267 [
255 AC_TRY_RUN([ 268 AC_RUN_IFELSE(
269 [AC_LANG_SOURCE([[
256]GL_NOCRASH[ 270]GL_NOCRASH[
257#include <float.h> 271#include <float.h>
258#include <stdio.h> 272#include <stdio.h>
@@ -279,35 +293,36 @@ static char buf[10000];
279static long double zeroL = 0.0L; 293static long double zeroL = 0.0L;
280int main () 294int main ()
281{ 295{
296 int result = 0;
282 nocrash_init(); 297 nocrash_init();
283 if (sprintf (buf, "%Lf", 1.0L / 0.0L) < 0 298 if (sprintf (buf, "%Lf", 1.0L / zeroL) < 0
284 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0)) 299 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
285 return 1; 300 result |= 1;
286 if (sprintf (buf, "%Lf", -1.0L / 0.0L) < 0 301 if (sprintf (buf, "%Lf", -1.0L / zeroL) < 0
287 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0)) 302 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
288 return 1; 303 result |= 1;
289 if (sprintf (buf, "%Lf", zeroL / zeroL) < 0 304 if (sprintf (buf, "%Lf", zeroL / zeroL) < 0
290 || !strisnan (buf, 0, strlen (buf))) 305 || !strisnan (buf, 0, strlen (buf)))
291 return 1; 306 result |= 1;
292 if (sprintf (buf, "%Le", 1.0L / 0.0L) < 0 307 if (sprintf (buf, "%Le", 1.0L / zeroL) < 0
293 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0)) 308 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
294 return 1; 309 result |= 1;
295 if (sprintf (buf, "%Le", -1.0L / 0.0L) < 0 310 if (sprintf (buf, "%Le", -1.0L / zeroL) < 0
296 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0)) 311 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
297 return 1; 312 result |= 1;
298 if (sprintf (buf, "%Le", zeroL / zeroL) < 0 313 if (sprintf (buf, "%Le", zeroL / zeroL) < 0
299 || !strisnan (buf, 0, strlen (buf))) 314 || !strisnan (buf, 0, strlen (buf)))
300 return 1; 315 result |= 1;
301 if (sprintf (buf, "%Lg", 1.0L / 0.0L) < 0 316 if (sprintf (buf, "%Lg", 1.0L / zeroL) < 0
302 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0)) 317 || (strcmp (buf, "inf") != 0 && strcmp (buf, "infinity") != 0))
303 return 1; 318 result |= 1;
304 if (sprintf (buf, "%Lg", -1.0L / 0.0L) < 0 319 if (sprintf (buf, "%Lg", -1.0L / zeroL) < 0
305 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0)) 320 || (strcmp (buf, "-inf") != 0 && strcmp (buf, "-infinity") != 0))
306 return 1; 321 result |= 1;
307 if (sprintf (buf, "%Lg", zeroL / zeroL) < 0 322 if (sprintf (buf, "%Lg", zeroL / zeroL) < 0
308 || !strisnan (buf, 0, strlen (buf))) 323 || !strisnan (buf, 0, strlen (buf)))
309 return 1; 324 result |= 1;
310#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_)) 325#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_)) && !HAVE_SAME_LONG_DOUBLE_AS_DOUBLE
311/* Representation of an 80-bit 'long double' as an initializer for a sequence 326/* Representation of an 80-bit 'long double' as an initializer for a sequence
312 of 'unsigned int' words. */ 327 of 'unsigned int' words. */
313# ifdef WORDS_BIGENDIAN 328# ifdef WORDS_BIGENDIAN
@@ -325,13 +340,13 @@ int main ()
325 { LDBL80_WORDS (0xFFFF, 0xC3333333, 0x00000000) }; 340 { LDBL80_WORDS (0xFFFF, 0xC3333333, 0x00000000) };
326 if (sprintf (buf, "%Lf", x.value) < 0 341 if (sprintf (buf, "%Lf", x.value) < 0
327 || !strisnan (buf, 0, strlen (buf))) 342 || !strisnan (buf, 0, strlen (buf)))
328 return 1; 343 result |= 2;
329 if (sprintf (buf, "%Le", x.value) < 0 344 if (sprintf (buf, "%Le", x.value) < 0
330 || !strisnan (buf, 0, strlen (buf))) 345 || !strisnan (buf, 0, strlen (buf)))
331 return 1; 346 result |= 2;
332 if (sprintf (buf, "%Lg", x.value) < 0 347 if (sprintf (buf, "%Lg", x.value) < 0
333 || !strisnan (buf, 0, strlen (buf))) 348 || !strisnan (buf, 0, strlen (buf)))
334 return 1; 349 result |= 2;
335 } 350 }
336 { 351 {
337 /* Signalling NaN. */ 352 /* Signalling NaN. */
@@ -339,113 +354,106 @@ int main ()
339 { LDBL80_WORDS (0xFFFF, 0x83333333, 0x00000000) }; 354 { LDBL80_WORDS (0xFFFF, 0x83333333, 0x00000000) };
340 if (sprintf (buf, "%Lf", x.value) < 0 355 if (sprintf (buf, "%Lf", x.value) < 0
341 || !strisnan (buf, 0, strlen (buf))) 356 || !strisnan (buf, 0, strlen (buf)))
342 return 1; 357 result |= 2;
343 if (sprintf (buf, "%Le", x.value) < 0 358 if (sprintf (buf, "%Le", x.value) < 0
344 || !strisnan (buf, 0, strlen (buf))) 359 || !strisnan (buf, 0, strlen (buf)))
345 return 1; 360 result |= 2;
346 if (sprintf (buf, "%Lg", x.value) < 0 361 if (sprintf (buf, "%Lg", x.value) < 0
347 || !strisnan (buf, 0, strlen (buf))) 362 || !strisnan (buf, 0, strlen (buf)))
348 return 1; 363 result |= 2;
349 } 364 }
350 { /* Pseudo-NaN. */ 365 { /* Pseudo-NaN. */
351 static union { unsigned int word[4]; long double value; } x = 366 static union { unsigned int word[4]; long double value; } x =
352 { LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) }; 367 { LDBL80_WORDS (0xFFFF, 0x40000001, 0x00000000) };
353 if (sprintf (buf, "%Lf", x.value) < 0 368 if (sprintf (buf, "%Lf", x.value) < 0
354 || !strisnan (buf, 0, strlen (buf))) 369 || !strisnan (buf, 0, strlen (buf)))
355 return 1; 370 result |= 4;
356 if (sprintf (buf, "%Le", x.value) < 0 371 if (sprintf (buf, "%Le", x.value) < 0
357 || !strisnan (buf, 0, strlen (buf))) 372 || !strisnan (buf, 0, strlen (buf)))
358 return 1; 373 result |= 4;
359 if (sprintf (buf, "%Lg", x.value) < 0 374 if (sprintf (buf, "%Lg", x.value) < 0
360 || !strisnan (buf, 0, strlen (buf))) 375 || !strisnan (buf, 0, strlen (buf)))
361 return 1; 376 result |= 4;
362 } 377 }
363 { /* Pseudo-Infinity. */ 378 { /* Pseudo-Infinity. */
364 static union { unsigned int word[4]; long double value; } x = 379 static union { unsigned int word[4]; long double value; } x =
365 { LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) }; 380 { LDBL80_WORDS (0xFFFF, 0x00000000, 0x00000000) };
366 if (sprintf (buf, "%Lf", x.value) < 0 381 if (sprintf (buf, "%Lf", x.value) < 0
367 || !strisnan (buf, 0, strlen (buf))) 382 || !strisnan (buf, 0, strlen (buf)))
368 return 1; 383 result |= 8;
369 if (sprintf (buf, "%Le", x.value) < 0 384 if (sprintf (buf, "%Le", x.value) < 0
370 || !strisnan (buf, 0, strlen (buf))) 385 || !strisnan (buf, 0, strlen (buf)))
371 return 1; 386 result |= 8;
372 if (sprintf (buf, "%Lg", x.value) < 0 387 if (sprintf (buf, "%Lg", x.value) < 0
373 || !strisnan (buf, 0, strlen (buf))) 388 || !strisnan (buf, 0, strlen (buf)))
374 return 1; 389 result |= 8;
375 } 390 }
376 { /* Pseudo-Zero. */ 391 { /* Pseudo-Zero. */
377 static union { unsigned int word[4]; long double value; } x = 392 static union { unsigned int word[4]; long double value; } x =
378 { LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) }; 393 { LDBL80_WORDS (0x4004, 0x00000000, 0x00000000) };
379 if (sprintf (buf, "%Lf", x.value) < 0 394 if (sprintf (buf, "%Lf", x.value) < 0
380 || !strisnan (buf, 0, strlen (buf))) 395 || !strisnan (buf, 0, strlen (buf)))
381 return 1; 396 result |= 16;
382 if (sprintf (buf, "%Le", x.value) < 0 397 if (sprintf (buf, "%Le", x.value) < 0
383 || !strisnan (buf, 0, strlen (buf))) 398 || !strisnan (buf, 0, strlen (buf)))
384 return 1; 399 result |= 16;
385 if (sprintf (buf, "%Lg", x.value) < 0 400 if (sprintf (buf, "%Lg", x.value) < 0
386 || !strisnan (buf, 0, strlen (buf))) 401 || !strisnan (buf, 0, strlen (buf)))
387 return 1; 402 result |= 16;
388 } 403 }
389 { /* Unnormalized number. */ 404 { /* Unnormalized number. */
390 static union { unsigned int word[4]; long double value; } x = 405 static union { unsigned int word[4]; long double value; } x =
391 { LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) }; 406 { LDBL80_WORDS (0x4000, 0x63333333, 0x00000000) };
392 if (sprintf (buf, "%Lf", x.value) < 0 407 if (sprintf (buf, "%Lf", x.value) < 0
393 || !strisnan (buf, 0, strlen (buf))) 408 || !strisnan (buf, 0, strlen (buf)))
394 return 1; 409 result |= 32;
395 if (sprintf (buf, "%Le", x.value) < 0 410 if (sprintf (buf, "%Le", x.value) < 0
396 || !strisnan (buf, 0, strlen (buf))) 411 || !strisnan (buf, 0, strlen (buf)))
397 return 1; 412 result |= 32;
398 if (sprintf (buf, "%Lg", x.value) < 0 413 if (sprintf (buf, "%Lg", x.value) < 0
399 || !strisnan (buf, 0, strlen (buf))) 414 || !strisnan (buf, 0, strlen (buf)))
400 return 1; 415 result |= 32;
401 } 416 }
402 { /* Pseudo-Denormal. */ 417 { /* Pseudo-Denormal. */
403 static union { unsigned int word[4]; long double value; } x = 418 static union { unsigned int word[4]; long double value; } x =
404 { LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) }; 419 { LDBL80_WORDS (0x0000, 0x83333333, 0x00000000) };
405 if (sprintf (buf, "%Lf", x.value) < 0 420 if (sprintf (buf, "%Lf", x.value) < 0
406 || !strisnan (buf, 0, strlen (buf))) 421 || !strisnan (buf, 0, strlen (buf)))
407 return 1; 422 result |= 64;
408 if (sprintf (buf, "%Le", x.value) < 0 423 if (sprintf (buf, "%Le", x.value) < 0
409 || !strisnan (buf, 0, strlen (buf))) 424 || !strisnan (buf, 0, strlen (buf)))
410 return 1; 425 result |= 64;
411 if (sprintf (buf, "%Lg", x.value) < 0 426 if (sprintf (buf, "%Lg", x.value) < 0
412 || !strisnan (buf, 0, strlen (buf))) 427 || !strisnan (buf, 0, strlen (buf)))
413 return 1; 428 result |= 64;
414 } 429 }
415#endif 430#endif
416 return 0; 431 return result;
417}], 432}]])],
418 [gl_cv_func_printf_infinite_long_double=yes], 433 [gl_cv_func_printf_infinite_long_double=yes],
419 [gl_cv_func_printf_infinite_long_double=no], 434 [gl_cv_func_printf_infinite_long_double=no],
420 [ 435 [
421changequote(,)dnl 436changequote(,)dnl
422 case "$host_cpu" in 437 case "$host_cpu" in
423 # Guess no on ia64, x86_64, i386. 438 # Guess no on ia64, x86_64, i386.
424 ia64 | x86_64 | i*86) gl_cv_func_printf_infinite_long_double="guessing no";; 439 ia64 | x86_64 | i*86) gl_cv_func_printf_infinite_long_double="guessing no";;
425 *) 440 *)
426 case "$host_os" in 441 case "$host_os" in
427 # Guess yes on glibc systems. 442 # Guess yes on glibc systems.
428 *-gnu*) gl_cv_func_printf_infinite_long_double="guessing yes";; 443 *-gnu*) gl_cv_func_printf_infinite_long_double="guessing yes";;
429 # Guess yes on FreeBSD >= 6. 444 # Guess yes on FreeBSD >= 6.
430 freebsd[1-5]*) gl_cv_func_printf_infinite_long_double="guessing no";; 445 freebsd[1-5]*) gl_cv_func_printf_infinite_long_double="guessing no";;
431 freebsd* | kfreebsd*) gl_cv_func_printf_infinite_long_double="guessing yes";; 446 freebsd* | kfreebsd*) gl_cv_func_printf_infinite_long_double="guessing yes";;
432 # Guess yes on MacOS X >= 10.3. 447 # Guess yes on HP-UX >= 11.
433 darwin[1-6].*) gl_cv_func_printf_infinite_long_double="guessing no";; 448 hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite_long_double="guessing no";;
434 darwin*) gl_cv_func_printf_infinite_long_double="guessing yes";; 449 hpux*) gl_cv_func_printf_infinite_long_double="guessing yes";;
435 # Guess yes on HP-UX >= 11. 450 # If we don't know, assume the worst.
436 hpux[7-9]* | hpux10*) gl_cv_func_printf_infinite_long_double="guessing no";; 451 *) gl_cv_func_printf_infinite_long_double="guessing no";;
437 hpux*) gl_cv_func_printf_infinite_long_double="guessing yes";; 452 esac
438 # Guess yes on NetBSD >= 3. 453 ;;
439 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) 454 esac
440 gl_cv_func_printf_infinite_long_double="guessing no";;
441 netbsd*) gl_cv_func_printf_infinite_long_double="guessing yes";;
442 # If we don't know, assume the worst.
443 *) gl_cv_func_printf_infinite_long_double="guessing no";;
444 esac
445 ;;
446 esac
447changequote([,])dnl 455changequote([,])dnl
448 ]) 456 ])
449 ]) 457 ])
450 ;; 458 ;;
451 *) 459 *)
@@ -466,72 +474,77 @@ AC_DEFUN([gl_PRINTF_DIRECTIVE_A],
466 AC_CACHE_CHECK([whether printf supports the 'a' and 'A' directives], 474 AC_CACHE_CHECK([whether printf supports the 'a' and 'A' directives],
467 [gl_cv_func_printf_directive_a], 475 [gl_cv_func_printf_directive_a],
468 [ 476 [
469 AC_TRY_RUN([ 477 AC_RUN_IFELSE(
478 [AC_LANG_SOURCE([[
470#include <stdio.h> 479#include <stdio.h>
471#include <string.h> 480#include <string.h>
472static char buf[100]; 481static char buf[100];
482static double zero = 0.0;
473int main () 483int main ()
474{ 484{
485 int result = 0;
475 if (sprintf (buf, "%a %d", 3.1416015625, 33, 44, 55) < 0 486 if (sprintf (buf, "%a %d", 3.1416015625, 33, 44, 55) < 0
476 || (strcmp (buf, "0x1.922p+1 33") != 0 487 || (strcmp (buf, "0x1.922p+1 33") != 0
477 && strcmp (buf, "0x3.244p+0 33") != 0 488 && strcmp (buf, "0x3.244p+0 33") != 0
478 && strcmp (buf, "0x6.488p-1 33") != 0 489 && strcmp (buf, "0x6.488p-1 33") != 0
479 && strcmp (buf, "0xc.91p-2 33") != 0)) 490 && strcmp (buf, "0xc.91p-2 33") != 0))
480 return 1; 491 result |= 1;
481 if (sprintf (buf, "%A %d", -3.1416015625, 33, 44, 55) < 0 492 if (sprintf (buf, "%A %d", -3.1416015625, 33, 44, 55) < 0
482 || (strcmp (buf, "-0X1.922P+1 33") != 0 493 || (strcmp (buf, "-0X1.922P+1 33") != 0
483 && strcmp (buf, "-0X3.244P+0 33") != 0 494 && strcmp (buf, "-0X3.244P+0 33") != 0
484 && strcmp (buf, "-0X6.488P-1 33") != 0 495 && strcmp (buf, "-0X6.488P-1 33") != 0
485 && strcmp (buf, "-0XC.91P-2 33") != 0)) 496 && strcmp (buf, "-0XC.91P-2 33") != 0))
486 return 1; 497 result |= 2;
487 /* This catches a FreeBSD 6.1 bug: it doesn't round. */ 498 /* This catches a FreeBSD 6.1 bug: it doesn't round. */
488 if (sprintf (buf, "%.2a %d", 1.51, 33, 44, 55) < 0 499 if (sprintf (buf, "%.2a %d", 1.51, 33, 44, 55) < 0
489 || (strcmp (buf, "0x1.83p+0 33") != 0 500 || (strcmp (buf, "0x1.83p+0 33") != 0
490 && strcmp (buf, "0x3.05p-1 33") != 0 501 && strcmp (buf, "0x3.05p-1 33") != 0
491 && strcmp (buf, "0x6.0ap-2 33") != 0 502 && strcmp (buf, "0x6.0ap-2 33") != 0
492 && strcmp (buf, "0xc.14p-3 33") != 0)) 503 && strcmp (buf, "0xc.14p-3 33") != 0))
493 return 1; 504 result |= 4;
494 /* This catches a FreeBSD 6.1 bug. See 505 /* This catches a FreeBSD 6.1 bug. See
495 <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */ 506 <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
496 if (sprintf (buf, "%010a %d", 1.0 / 0.0, 33, 44, 55) < 0 507 if (sprintf (buf, "%010a %d", 1.0 / zero, 33, 44, 55) < 0
497 || buf[0] == '0') 508 || buf[0] == '0')
498 return 1; 509 result |= 8;
499 /* This catches a MacOS X 10.3.9 (Darwin 7.9) bug. */ 510 /* This catches a Mac OS X 10.3.9 (Darwin 7.9) bug. */
500 if (sprintf (buf, "%.1a", 1.999) < 0 511 if (sprintf (buf, "%.1a", 1.999) < 0
501 || (strcmp (buf, "0x1.0p+1") != 0 512 || (strcmp (buf, "0x1.0p+1") != 0
502 && strcmp (buf, "0x2.0p+0") != 0 513 && strcmp (buf, "0x2.0p+0") != 0
503 && strcmp (buf, "0x4.0p-1") != 0 514 && strcmp (buf, "0x4.0p-1") != 0
504 && strcmp (buf, "0x8.0p-2") != 0)) 515 && strcmp (buf, "0x8.0p-2") != 0))
505 return 1; 516 result |= 16;
506 /* This catches the same MacOS X 10.3.9 (Darwin 7.9) bug and also a 517 /* This catches the same Mac OS X 10.3.9 (Darwin 7.9) bug and also a
507 glibc 2.4 bug <http://sourceware.org/bugzilla/show_bug.cgi?id=2908>. */ 518 glibc 2.4 bug <http://sourceware.org/bugzilla/show_bug.cgi?id=2908>. */
508 if (sprintf (buf, "%.1La", 1.999L) < 0 519 if (sprintf (buf, "%.1La", 1.999L) < 0
509 || (strcmp (buf, "0x1.0p+1") != 0 520 || (strcmp (buf, "0x1.0p+1") != 0
510 && strcmp (buf, "0x2.0p+0") != 0 521 && strcmp (buf, "0x2.0p+0") != 0
511 && strcmp (buf, "0x4.0p-1") != 0 522 && strcmp (buf, "0x4.0p-1") != 0
512 && strcmp (buf, "0x8.0p-2") != 0)) 523 && strcmp (buf, "0x8.0p-2") != 0))
513 return 1; 524 result |= 32;
514 return 0; 525 return result;
515}], [gl_cv_func_printf_directive_a=yes], [gl_cv_func_printf_directive_a=no], 526}]])],
516 [ 527 [gl_cv_func_printf_directive_a=yes],
517 case "$host_os" in 528 [gl_cv_func_printf_directive_a=no],
518 # Guess yes on glibc >= 2.5 systems. 529 [
519 *-gnu*) 530 case "$host_os" in
520 AC_EGREP_CPP([BZ2908], [ 531 # Guess yes on glibc >= 2.5 systems.
521 #include <features.h> 532 *-gnu*)
522 #ifdef __GNU_LIBRARY__ 533 AC_EGREP_CPP([BZ2908], [
523 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 5) || (__GLIBC__ > 2) 534 #include <features.h>
524 BZ2908 535 #ifdef __GNU_LIBRARY__
525 #endif 536 #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 5) || (__GLIBC__ > 2)) && !defined __UCLIBC__
526 #endif 537 BZ2908
527 ], 538 #endif
528 [gl_cv_func_printf_directive_a="guessing yes"], 539 #endif
529 [gl_cv_func_printf_directive_a="guessing no"]) 540 ],
530 ;; 541 [gl_cv_func_printf_directive_a="guessing yes"],
531 # If we don't know, assume the worst. 542 [gl_cv_func_printf_directive_a="guessing no"])
532 *) gl_cv_func_printf_directive_a="guessing no";; 543 ;;
533 esac 544 # If we don't know, assume the worst.
534 ]) 545 *) gl_cv_func_printf_directive_a="guessing no";;
546 esac
547 ])
535 ]) 548 ])
536]) 549])
537 550
@@ -546,43 +559,48 @@ AC_DEFUN([gl_PRINTF_DIRECTIVE_F],
546 AC_CACHE_CHECK([whether printf supports the 'F' directive], 559 AC_CACHE_CHECK([whether printf supports the 'F' directive],
547 [gl_cv_func_printf_directive_f], 560 [gl_cv_func_printf_directive_f],
548 [ 561 [
549 AC_TRY_RUN([ 562 AC_RUN_IFELSE(
563 [AC_LANG_SOURCE([[
550#include <stdio.h> 564#include <stdio.h>
551#include <string.h> 565#include <string.h>
552static char buf[100]; 566static char buf[100];
567static double zero = 0.0;
553int main () 568int main ()
554{ 569{
570 int result = 0;
555 if (sprintf (buf, "%F %d", 1234567.0, 33, 44, 55) < 0 571 if (sprintf (buf, "%F %d", 1234567.0, 33, 44, 55) < 0
556 || strcmp (buf, "1234567.000000 33") != 0) 572 || strcmp (buf, "1234567.000000 33") != 0)
557 return 1; 573 result |= 1;
558 if (sprintf (buf, "%F", 1.0 / 0.0) < 0 574 if (sprintf (buf, "%F", 1.0 / zero) < 0
559 || (strcmp (buf, "INF") != 0 && strcmp (buf, "INFINITY") != 0)) 575 || (strcmp (buf, "INF") != 0 && strcmp (buf, "INFINITY") != 0))
560 return 1; 576 result |= 2;
561 /* This catches a Cygwin 1.5.x bug. */ 577 /* This catches a Cygwin 1.5.x bug. */
562 if (sprintf (buf, "%.F", 1234.0) < 0 578 if (sprintf (buf, "%.F", 1234.0) < 0
563 || strcmp (buf, "1234") != 0) 579 || strcmp (buf, "1234") != 0)
564 return 1; 580 result |= 4;
565 return 0; 581 return result;
566}], [gl_cv_func_printf_directive_f=yes], [gl_cv_func_printf_directive_f=no], 582}]])],
567 [ 583 [gl_cv_func_printf_directive_f=yes],
584 [gl_cv_func_printf_directive_f=no],
585 [
568changequote(,)dnl 586changequote(,)dnl
569 case "$host_os" in 587 case "$host_os" in
570 # Guess yes on glibc systems. 588 # Guess yes on glibc systems.
571 *-gnu*) gl_cv_func_printf_directive_f="guessing yes";; 589 *-gnu*) gl_cv_func_printf_directive_f="guessing yes";;
572 # Guess yes on FreeBSD >= 6. 590 # Guess yes on FreeBSD >= 6.
573 freebsd[1-5]*) gl_cv_func_printf_directive_f="guessing no";; 591 freebsd[1-5]*) gl_cv_func_printf_directive_f="guessing no";;
574 freebsd* | kfreebsd*) gl_cv_func_printf_directive_f="guessing yes";; 592 freebsd* | kfreebsd*) gl_cv_func_printf_directive_f="guessing yes";;
575 # Guess yes on MacOS X >= 10.3. 593 # Guess yes on Mac OS X >= 10.3.
576 darwin[1-6].*) gl_cv_func_printf_directive_f="guessing no";; 594 darwin[1-6].*) gl_cv_func_printf_directive_f="guessing no";;
577 darwin*) gl_cv_func_printf_directive_f="guessing yes";; 595 darwin*) gl_cv_func_printf_directive_f="guessing yes";;
578 # Guess yes on Solaris >= 2.10. 596 # Guess yes on Solaris >= 2.10.
579 solaris2.[0-9]*) gl_cv_func_printf_directive_f="guessing no";; 597 solaris2.[1-9][0-9]*) gl_cv_func_printf_sizes_c99="guessing yes";;
580 solaris*) gl_cv_func_printf_directive_f="guessing yes";; 598 solaris*) gl_cv_func_printf_sizes_c99="guessing no";;
581 # If we don't know, assume the worst. 599 # If we don't know, assume the worst.
582 *) gl_cv_func_printf_directive_f="guessing no";; 600 *) gl_cv_func_printf_directive_f="guessing no";;
583 esac 601 esac
584changequote([,])dnl 602changequote([,])dnl
585 ]) 603 ])
586 ]) 604 ])
587]) 605])
588 606
@@ -597,14 +615,30 @@ AC_DEFUN([gl_PRINTF_DIRECTIVE_N],
597 AC_CACHE_CHECK([whether printf supports the 'n' directive], 615 AC_CACHE_CHECK([whether printf supports the 'n' directive],
598 [gl_cv_func_printf_directive_n], 616 [gl_cv_func_printf_directive_n],
599 [ 617 [
600 AC_TRY_RUN([ 618 AC_RUN_IFELSE(
619 [AC_LANG_SOURCE([[
601#include <stdio.h> 620#include <stdio.h>
621#include <stdlib.h>
602#include <string.h> 622#include <string.h>
623#ifdef _MSC_VER
624/* See page about "Parameter Validation" on msdn.microsoft.com. */
625static void cdecl
626invalid_parameter_handler (const wchar_t *expression,
627 const wchar_t *function,
628 const wchar_t *file, unsigned int line,
629 uintptr_t dummy)
630{
631 exit (1);
632}
633#endif
603static char fmtstring[10]; 634static char fmtstring[10];
604static char buf[100]; 635static char buf[100];
605int main () 636int main ()
606{ 637{
607 int count = -1; 638 int count = -1;
639#ifdef _MSC_VER
640 _set_invalid_parameter_handler (invalid_parameter_handler);
641#endif
608 /* Copy the format string. Some systems (glibc with _FORTIFY_SOURCE=2) 642 /* Copy the format string. Some systems (glibc with _FORTIFY_SOURCE=2)
609 support %n in format strings in read-only memory but not in writable 643 support %n in format strings in read-only memory but not in writable
610 memory. */ 644 memory. */
@@ -614,14 +648,17 @@ int main ()
614 || count != 4) 648 || count != 4)
615 return 1; 649 return 1;
616 return 0; 650 return 0;
617}], [gl_cv_func_printf_directive_n=yes], [gl_cv_func_printf_directive_n=no], 651}]])],
618 [ 652 [gl_cv_func_printf_directive_n=yes],
653 [gl_cv_func_printf_directive_n=no],
654 [
619changequote(,)dnl 655changequote(,)dnl
620 case "$host_os" in 656 case "$host_os" in
621 *) gl_cv_func_printf_directive_n="guessing yes";; 657 mingw*) gl_cv_func_printf_directive_n="guessing no";;
622 esac 658 *) gl_cv_func_printf_directive_n="guessing yes";;
659 esac
623changequote([,])dnl 660changequote([,])dnl
624 ]) 661 ])
625 ]) 662 ])
626]) 663])
627 664
@@ -639,7 +676,8 @@ AC_DEFUN([gl_PRINTF_DIRECTIVE_LS],
639 AC_CACHE_CHECK([whether printf supports the 'ls' directive], 676 AC_CACHE_CHECK([whether printf supports the 'ls' directive],
640 [gl_cv_func_printf_directive_ls], 677 [gl_cv_func_printf_directive_ls],
641 [ 678 [
642 AC_TRY_RUN([ 679 AC_RUN_IFELSE(
680 [AC_LANG_SOURCE([[
643/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before 681/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
644 <wchar.h>. 682 <wchar.h>.
645 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be 683 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
@@ -651,6 +689,7 @@ AC_DEFUN([gl_PRINTF_DIRECTIVE_LS],
651#include <string.h> 689#include <string.h>
652int main () 690int main ()
653{ 691{
692 int result = 0;
654 char buf[100]; 693 char buf[100];
655 /* Test whether %ls works at all. 694 /* Test whether %ls works at all.
656 This test fails on OpenBSD 4.0, IRIX 6.5, Solaris 2.6, Haiku, but not on 695 This test fails on OpenBSD 4.0, IRIX 6.5, Solaris 2.6, Haiku, but not on
@@ -660,7 +699,7 @@ int main ()
660 buf[0] = '\0'; 699 buf[0] = '\0';
661 if (sprintf (buf, "%ls", wstring) < 0 700 if (sprintf (buf, "%ls", wstring) < 0
662 || strcmp (buf, "abc") != 0) 701 || strcmp (buf, "abc") != 0)
663 return 1; 702 result |= 1;
664 } 703 }
665 /* This test fails on IRIX 6.5, Solaris 2.6, Cygwin 1.5, Haiku (with an 704 /* This test fails on IRIX 6.5, Solaris 2.6, Cygwin 1.5, Haiku (with an
666 assertion failure inside libc), but not on OpenBSD 4.0. */ 705 assertion failure inside libc), but not on OpenBSD 4.0. */
@@ -669,7 +708,7 @@ int main ()
669 buf[0] = '\0'; 708 buf[0] = '\0';
670 if (sprintf (buf, "%ls", wstring) < 0 709 if (sprintf (buf, "%ls", wstring) < 0
671 || strcmp (buf, "a") != 0) 710 || strcmp (buf, "a") != 0)
672 return 1; 711 result |= 2;
673 } 712 }
674 /* Test whether precisions in %ls are supported as specified in ISO C 99 713 /* Test whether precisions in %ls are supported as specified in ISO C 99
675 section 7.19.6.1: 714 section 7.19.6.1:
@@ -684,22 +723,24 @@ int main ()
684 buf[0] = '\0'; 723 buf[0] = '\0';
685 if (sprintf (buf, "%.2ls", wstring) < 0 724 if (sprintf (buf, "%.2ls", wstring) < 0
686 || strcmp (buf, "ab") != 0) 725 || strcmp (buf, "ab") != 0)
687 return 1; 726 result |= 8;
688 } 727 }
689 return 0; 728 return result;
690}], [gl_cv_func_printf_directive_ls=yes], [gl_cv_func_printf_directive_ls=no], 729}]])],
691 [ 730 [gl_cv_func_printf_directive_ls=yes],
731 [gl_cv_func_printf_directive_ls=no],
732 [
692changequote(,)dnl 733changequote(,)dnl
693 case "$host_os" in 734 case "$host_os" in
694 openbsd*) gl_cv_func_printf_directive_ls="guessing no";; 735 openbsd*) gl_cv_func_printf_directive_ls="guessing no";;
695 irix*) gl_cv_func_printf_directive_ls="guessing no";; 736 irix*) gl_cv_func_printf_directive_ls="guessing no";;
696 solaris*) gl_cv_func_printf_directive_ls="guessing no";; 737 solaris*) gl_cv_func_printf_directive_ls="guessing no";;
697 cygwin*) gl_cv_func_printf_directive_ls="guessing no";; 738 cygwin*) gl_cv_func_printf_directive_ls="guessing no";;
698 beos* | haiku*) gl_cv_func_printf_directive_ls="guessing no";; 739 beos* | haiku*) gl_cv_func_printf_directive_ls="guessing no";;
699 *) gl_cv_func_printf_directive_ls="guessing yes";; 740 *) gl_cv_func_printf_directive_ls="guessing yes";;
700 esac 741 esac
701changequote([,])dnl 742changequote([,])dnl
702 ]) 743 ])
703 ]) 744 ])
704]) 745])
705 746
@@ -714,7 +755,8 @@ AC_DEFUN([gl_PRINTF_POSITIONS],
714 AC_CACHE_CHECK([whether printf supports POSIX/XSI format strings with positions], 755 AC_CACHE_CHECK([whether printf supports POSIX/XSI format strings with positions],
715 [gl_cv_func_printf_positions], 756 [gl_cv_func_printf_positions],
716 [ 757 [
717 AC_TRY_RUN([ 758 AC_RUN_IFELSE(
759 [AC_LANG_SOURCE([[
718#include <stdio.h> 760#include <stdio.h>
719#include <string.h> 761#include <string.h>
720/* The string "%2$d %1$d", with dollar characters protected from the shell's 762/* The string "%2$d %1$d", with dollar characters protected from the shell's
@@ -725,18 +767,20 @@ int main ()
725{ 767{
726 sprintf (buf, format, 33, 55); 768 sprintf (buf, format, 33, 55);
727 return (strcmp (buf, "55 33") != 0); 769 return (strcmp (buf, "55 33") != 0);
728}], [gl_cv_func_printf_positions=yes], [gl_cv_func_printf_positions=no], 770}]])],
729 [ 771 [gl_cv_func_printf_positions=yes],
772 [gl_cv_func_printf_positions=no],
773 [
730changequote(,)dnl 774changequote(,)dnl
731 case "$host_os" in 775 case "$host_os" in
732 netbsd[1-3]* | netbsdelf[1-3]* | netbsdaout[1-3]* | netbsdcoff[1-3]*) 776 netbsd[1-3]* | netbsdelf[1-3]* | netbsdaout[1-3]* | netbsdcoff[1-3]*)
733 gl_cv_func_printf_positions="guessing no";; 777 gl_cv_func_printf_positions="guessing no";;
734 beos*) gl_cv_func_printf_positions="guessing no";; 778 beos*) gl_cv_func_printf_positions="guessing no";;
735 mingw* | pw*) gl_cv_func_printf_positions="guessing no";; 779 mingw* | pw*) gl_cv_func_printf_positions="guessing no";;
736 *) gl_cv_func_printf_positions="guessing yes";; 780 *) gl_cv_func_printf_positions="guessing yes";;
737 esac 781 esac
738changequote([,])dnl 782changequote([,])dnl
739 ]) 783 ])
740 ]) 784 ])
741]) 785])
742 786
@@ -751,7 +795,8 @@ AC_DEFUN([gl_PRINTF_FLAG_GROUPING],
751 AC_CACHE_CHECK([whether printf supports the grouping flag], 795 AC_CACHE_CHECK([whether printf supports the grouping flag],
752 [gl_cv_func_printf_flag_grouping], 796 [gl_cv_func_printf_flag_grouping],
753 [ 797 [
754 AC_TRY_RUN([ 798 AC_RUN_IFELSE(
799 [AC_LANG_SOURCE([[
755#include <stdio.h> 800#include <stdio.h>
756#include <string.h> 801#include <string.h>
757static char buf[100]; 802static char buf[100];
@@ -761,17 +806,19 @@ int main ()
761 || buf[strlen (buf) - 1] != '9') 806 || buf[strlen (buf) - 1] != '9')
762 return 1; 807 return 1;
763 return 0; 808 return 0;
764}], [gl_cv_func_printf_flag_grouping=yes], [gl_cv_func_printf_flag_grouping=no], 809}]])],
765 [ 810 [gl_cv_func_printf_flag_grouping=yes],
811 [gl_cv_func_printf_flag_grouping=no],
812 [
766changequote(,)dnl 813changequote(,)dnl
767 case "$host_os" in 814 case "$host_os" in
768 cygwin*) gl_cv_func_printf_flag_grouping="guessing no";; 815 cygwin*) gl_cv_func_printf_flag_grouping="guessing no";;
769 netbsd*) gl_cv_func_printf_flag_grouping="guessing no";; 816 netbsd*) gl_cv_func_printf_flag_grouping="guessing no";;
770 mingw* | pw*) gl_cv_func_printf_flag_grouping="guessing no";; 817 mingw* | pw*) gl_cv_func_printf_flag_grouping="guessing no";;
771 *) gl_cv_func_printf_flag_grouping="guessing yes";; 818 *) gl_cv_func_printf_flag_grouping="guessing yes";;
772 esac 819 esac
773changequote([,])dnl 820changequote([,])dnl
774 ]) 821 ])
775 ]) 822 ])
776]) 823])
777 824
@@ -787,7 +834,8 @@ AC_DEFUN([gl_PRINTF_FLAG_LEFTADJUST],
787 AC_CACHE_CHECK([whether printf supports the left-adjust flag correctly], 834 AC_CACHE_CHECK([whether printf supports the left-adjust flag correctly],
788 [gl_cv_func_printf_flag_leftadjust], 835 [gl_cv_func_printf_flag_leftadjust],
789 [ 836 [
790 AC_TRY_RUN([ 837 AC_RUN_IFELSE(
838 [AC_LANG_SOURCE([[
791#include <stdio.h> 839#include <stdio.h>
792#include <string.h> 840#include <string.h>
793static char buf[100]; 841static char buf[100];
@@ -798,7 +846,7 @@ int main ()
798 || strcmp (buf, "ab c") != 0) 846 || strcmp (buf, "ab c") != 0)
799 return 1; 847 return 1;
800 return 0; 848 return 0;
801}], 849}]])],
802 [gl_cv_func_printf_flag_leftadjust=yes], 850 [gl_cv_func_printf_flag_leftadjust=yes],
803 [gl_cv_func_printf_flag_leftadjust=no], 851 [gl_cv_func_printf_flag_leftadjust=no],
804 [ 852 [
@@ -828,37 +876,44 @@ AC_DEFUN([gl_PRINTF_FLAG_ZERO],
828 AC_CACHE_CHECK([whether printf supports the zero flag correctly], 876 AC_CACHE_CHECK([whether printf supports the zero flag correctly],
829 [gl_cv_func_printf_flag_zero], 877 [gl_cv_func_printf_flag_zero],
830 [ 878 [
831 AC_TRY_RUN([ 879 AC_RUN_IFELSE(
880 [AC_LANG_SOURCE([[
832#include <stdio.h> 881#include <stdio.h>
833#include <string.h> 882#include <string.h>
834static char buf[100]; 883static char buf[100];
884static double zero = 0.0;
835int main () 885int main ()
836{ 886{
837 if (sprintf (buf, "%010f", 1.0 / 0.0, 33, 44, 55) < 0 887 if (sprintf (buf, "%010f", 1.0 / zero, 33, 44, 55) < 0
838 || (strcmp (buf, " inf") != 0 888 || (strcmp (buf, " inf") != 0
839 && strcmp (buf, " infinity") != 0)) 889 && strcmp (buf, " infinity") != 0))
840 return 1; 890 return 1;
841 return 0; 891 return 0;
842}], [gl_cv_func_printf_flag_zero=yes], [gl_cv_func_printf_flag_zero=no], 892}]])],
843 [ 893 [gl_cv_func_printf_flag_zero=yes],
894 [gl_cv_func_printf_flag_zero=no],
895 [
844changequote(,)dnl 896changequote(,)dnl
845 case "$host_os" in 897 case "$host_os" in
846 # Guess yes on glibc systems. 898 # Guess yes on glibc systems.
847 *-gnu*) gl_cv_func_printf_flag_zero="guessing yes";; 899 *-gnu*) gl_cv_func_printf_flag_zero="guessing yes";;
848 # Guess yes on BeOS. 900 # Guess yes on BeOS.
849 beos*) gl_cv_func_printf_flag_zero="guessing yes";; 901 beos*) gl_cv_func_printf_flag_zero="guessing yes";;
850 # If we don't know, assume the worst. 902 # If we don't know, assume the worst.
851 *) gl_cv_func_printf_flag_zero="guessing no";; 903 *) gl_cv_func_printf_flag_zero="guessing no";;
852 esac 904 esac
853changequote([,])dnl 905changequote([,])dnl
854 ]) 906 ])
855 ]) 907 ])
856]) 908])
857 909
858dnl Test whether the *printf family of functions supports large precisions. 910dnl Test whether the *printf family of functions supports large precisions.
859dnl On mingw, precisions larger than 512 are treated like 512, in integer, 911dnl On mingw, precisions larger than 512 are treated like 512, in integer,
860dnl floating-point or pointer output. On BeOS, precisions larger than 1044 912dnl floating-point or pointer output. On Solaris 10/x86, precisions larger
861dnl crash the program. 913dnl than 510 in floating-point output crash the program. On Solaris 10/SPARC,
914dnl precisions larger than 510 in floating-point output yield wrong results.
915dnl On AIX 7.1, precisions larger than 998 in floating-point output yield
916dnl wrong results. On BeOS, precisions larger than 1044 crash the program.
862dnl Result is gl_cv_func_printf_precision. 917dnl Result is gl_cv_func_printf_precision.
863 918
864AC_DEFUN([gl_PRINTF_PRECISION], 919AC_DEFUN([gl_PRINTF_PRECISION],
@@ -868,30 +923,43 @@ AC_DEFUN([gl_PRINTF_PRECISION],
868 AC_CACHE_CHECK([whether printf supports large precisions], 923 AC_CACHE_CHECK([whether printf supports large precisions],
869 [gl_cv_func_printf_precision], 924 [gl_cv_func_printf_precision],
870 [ 925 [
871 AC_TRY_RUN([ 926 AC_RUN_IFELSE(
927 [AC_LANG_SOURCE([[
872#include <stdio.h> 928#include <stdio.h>
873#include <string.h> 929#include <string.h>
874static char buf[5000]; 930static char buf[5000];
875int main () 931int main ()
876{ 932{
933 int result = 0;
877#ifdef __BEOS__ 934#ifdef __BEOS__
878 /* On BeOS, this would crash and show a dialog box. Avoid the crash. */ 935 /* On BeOS, this would crash and show a dialog box. Avoid the crash. */
879 return 1; 936 return 1;
880#endif 937#endif
881 if (sprintf (buf, "%.4000d %d", 1, 33, 44) < 4000 + 3) 938 if (sprintf (buf, "%.4000d %d", 1, 33, 44) < 4000 + 3)
882 return 1; 939 result |= 1;
883 return 0; 940 if (sprintf (buf, "%.4000f %d", 1.0, 33, 44) < 4000 + 5)
884}], [gl_cv_func_printf_precision=yes], [gl_cv_func_printf_precision=no], 941 result |= 2;
885 [ 942 if (sprintf (buf, "%.511f %d", 1.0, 33, 44) < 511 + 5
943 || buf[0] != '1')
944 result |= 4;
945 if (sprintf (buf, "%.999f %d", 1.0, 33, 44) < 999 + 5
946 || buf[0] != '1')
947 result |= 4;
948 return result;
949}]])],
950 [gl_cv_func_printf_precision=yes],
951 [gl_cv_func_printf_precision=no],
952 [
886changequote(,)dnl 953changequote(,)dnl
887 case "$host_os" in 954 case "$host_os" in
888 # Guess no only on native Win32 and BeOS systems. 955 # Guess no only on Solaris, native Windows, and BeOS systems.
889 mingw* | pw*) gl_cv_func_printf_precision="guessing no" ;; 956 solaris*) gl_cv_func_printf_precision="guessing no" ;;
890 beos*) gl_cv_func_printf_precision="guessing no" ;; 957 mingw* | pw*) gl_cv_func_printf_precision="guessing no" ;;
891 *) gl_cv_func_printf_precision="guessing yes" ;; 958 beos*) gl_cv_func_printf_precision="guessing no" ;;
892 esac 959 *) gl_cv_func_printf_precision="guessing yes" ;;
960 esac
893changequote([,])dnl 961changequote([,])dnl
894 ]) 962 ])
895 ]) 963 ])
896]) 964])
897 965
@@ -960,8 +1028,9 @@ int main()
960changequote([,])dnl 1028changequote([,])dnl
961 ])]) 1029 ])])
962 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then 1030 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
963 (./conftest 1031 (./conftest 2>&AS_MESSAGE_LOG_FD
964 result=$? 1032 result=$?
1033 _AS_ECHO_LOG([\$? = $result])
965 if test $result != 0 && test $result != 77; then result=1; fi 1034 if test $result != 0 && test $result != 77; then result=1; fi
966 exit $result 1035 exit $result
967 ) >/dev/null 2>/dev/null 1036 ) >/dev/null 2>/dev/null
@@ -975,7 +1044,7 @@ changequote([,])dnl
975 fi 1044 fi
976 rm -fr conftest* 1045 rm -fr conftest*
977 else 1046 else
978 dnl A universal build on Apple MacOS X platforms. 1047 dnl A universal build on Apple Mac OS X platforms.
979 dnl The result would be 'no' in 32-bit mode and 'yes' in 64-bit mode. 1048 dnl The result would be 'no' in 32-bit mode and 'yes' in 64-bit mode.
980 dnl But we need a configuration result that is valid in both modes. 1049 dnl But we need a configuration result that is valid in both modes.
981 gl_cv_func_printf_enomem="guessing no" 1050 gl_cv_func_printf_enomem="guessing no"
@@ -1028,61 +1097,80 @@ AC_DEFUN([gl_SNPRINTF_TRUNCATION_C99],
1028[ 1097[
1029 AC_REQUIRE([AC_PROG_CC]) 1098 AC_REQUIRE([AC_PROG_CC])
1030 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 1099 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
1100 AC_REQUIRE([gl_SNPRINTF_PRESENCE])
1031 AC_CACHE_CHECK([whether snprintf truncates the result as in C99], 1101 AC_CACHE_CHECK([whether snprintf truncates the result as in C99],
1032 [gl_cv_func_snprintf_truncation_c99], 1102 [gl_cv_func_snprintf_truncation_c99],
1033 [ 1103 [
1034 AC_TRY_RUN([ 1104 AC_RUN_IFELSE(
1105 [AC_LANG_SOURCE([[
1035#include <stdio.h> 1106#include <stdio.h>
1036#include <string.h> 1107#include <string.h>
1108#if HAVE_SNPRINTF
1109# define my_snprintf snprintf
1110#else
1111# include <stdarg.h>
1112static int my_snprintf (char *buf, int size, const char *format, ...)
1113{
1114 va_list args;
1115 int ret;
1116 va_start (args, format);
1117 ret = vsnprintf (buf, size, format, args);
1118 va_end (args);
1119 return ret;
1120}
1121#endif
1037static char buf[100]; 1122static char buf[100];
1038int main () 1123int main ()
1039{ 1124{
1040 strcpy (buf, "ABCDEF"); 1125 strcpy (buf, "ABCDEF");
1041 snprintf (buf, 3, "%d %d", 4567, 89); 1126 my_snprintf (buf, 3, "%d %d", 4567, 89);
1042 if (memcmp (buf, "45\0DEF", 6) != 0) 1127 if (memcmp (buf, "45\0DEF", 6) != 0)
1043 return 1; 1128 return 1;
1044 return 0; 1129 return 0;
1045}], [gl_cv_func_snprintf_truncation_c99=yes], [gl_cv_func_snprintf_truncation_c99=no], 1130}]])],
1046 [ 1131 [gl_cv_func_snprintf_truncation_c99=yes],
1132 [gl_cv_func_snprintf_truncation_c99=no],
1133 [
1047changequote(,)dnl 1134changequote(,)dnl
1048 case "$host_os" in 1135 case "$host_os" in
1049 # Guess yes on glibc systems. 1136 # Guess yes on glibc systems.
1050 *-gnu*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1137 *-gnu*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1051 # Guess yes on FreeBSD >= 5. 1138 # Guess yes on FreeBSD >= 5.
1052 freebsd[1-4]*) gl_cv_func_snprintf_truncation_c99="guessing no";; 1139 freebsd[1-4]*) gl_cv_func_snprintf_truncation_c99="guessing no";;
1053 freebsd* | kfreebsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1140 freebsd* | kfreebsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1054 # Guess yes on MacOS X >= 10.3. 1141 # Guess yes on Mac OS X >= 10.3.
1055 darwin[1-6].*) gl_cv_func_snprintf_truncation_c99="guessing no";; 1142 darwin[1-6].*) gl_cv_func_snprintf_truncation_c99="guessing no";;
1056 darwin*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1143 darwin*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1057 # Guess yes on OpenBSD >= 3.9. 1144 # Guess yes on OpenBSD >= 3.9.
1058 openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*) 1145 openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*)
1059 gl_cv_func_snprintf_truncation_c99="guessing no";; 1146 gl_cv_func_snprintf_truncation_c99="guessing no";;
1060 openbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1147 openbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1061 # Guess yes on Solaris >= 2.6. 1148 # Guess yes on Solaris >= 2.6.
1062 solaris2.[0-5]*) gl_cv_func_snprintf_truncation_c99="guessing no";; 1149 solaris2.[0-5] | solaris2.[0-5].*)
1063 solaris*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1150 gl_cv_func_snprintf_truncation_c99="guessing no";;
1064 # Guess yes on AIX >= 4. 1151 solaris*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1065 aix[1-3]*) gl_cv_func_snprintf_truncation_c99="guessing no";; 1152 # Guess yes on AIX >= 4.
1066 aix*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1153 aix[1-3]*) gl_cv_func_snprintf_truncation_c99="guessing no";;
1067 # Guess yes on HP-UX >= 11. 1154 aix*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1068 hpux[7-9]* | hpux10*) gl_cv_func_snprintf_truncation_c99="guessing no";; 1155 # Guess yes on HP-UX >= 11.
1069 hpux*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1156 hpux[7-9]* | hpux10*) gl_cv_func_snprintf_truncation_c99="guessing no";;
1070 # Guess yes on IRIX >= 6.5. 1157 hpux*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1071 irix6.5) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1158 # Guess yes on IRIX >= 6.5.
1072 # Guess yes on OSF/1 >= 5. 1159 irix6.5) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1073 osf[3-4]*) gl_cv_func_snprintf_truncation_c99="guessing no";; 1160 # Guess yes on OSF/1 >= 5.
1074 osf*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1161 osf[3-4]*) gl_cv_func_snprintf_truncation_c99="guessing no";;
1075 # Guess yes on NetBSD >= 3. 1162 osf*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1076 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) 1163 # Guess yes on NetBSD >= 3.
1077 gl_cv_func_snprintf_truncation_c99="guessing no";; 1164 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
1078 netbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1165 gl_cv_func_snprintf_truncation_c99="guessing no";;
1079 # Guess yes on BeOS. 1166 netbsd*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1080 beos*) gl_cv_func_snprintf_truncation_c99="guessing yes";; 1167 # Guess yes on BeOS.
1081 # If we don't know, assume the worst. 1168 beos*) gl_cv_func_snprintf_truncation_c99="guessing yes";;
1082 *) gl_cv_func_snprintf_truncation_c99="guessing no";; 1169 # If we don't know, assume the worst.
1083 esac 1170 *) gl_cv_func_snprintf_truncation_c99="guessing no";;
1171 esac
1084changequote([,])dnl 1172changequote([,])dnl
1085 ]) 1173 ])
1086 ]) 1174 ])
1087]) 1175])
1088 1176
@@ -1105,52 +1193,74 @@ AC_DEFUN_ONCE([gl_SNPRINTF_RETVAL_C99],
1105[ 1193[
1106 AC_REQUIRE([AC_PROG_CC]) 1194 AC_REQUIRE([AC_PROG_CC])
1107 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 1195 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
1196 AC_REQUIRE([gl_SNPRINTF_PRESENCE])
1108 AC_CACHE_CHECK([whether snprintf returns a byte count as in C99], 1197 AC_CACHE_CHECK([whether snprintf returns a byte count as in C99],
1109 [gl_cv_func_snprintf_retval_c99], 1198 [gl_cv_func_snprintf_retval_c99],
1110 [ 1199 [
1111 AC_TRY_RUN([ 1200 AC_RUN_IFELSE(
1201 [AC_LANG_SOURCE([[
1112#include <stdio.h> 1202#include <stdio.h>
1113#include <string.h> 1203#include <string.h>
1204#if HAVE_SNPRINTF
1205# define my_snprintf snprintf
1206#else
1207# include <stdarg.h>
1208static int my_snprintf (char *buf, int size, const char *format, ...)
1209{
1210 va_list args;
1211 int ret;
1212 va_start (args, format);
1213 ret = vsnprintf (buf, size, format, args);
1214 va_end (args);
1215 return ret;
1216}
1217#endif
1114static char buf[100]; 1218static char buf[100];
1115int main () 1219int main ()
1116{ 1220{
1117 strcpy (buf, "ABCDEF"); 1221 strcpy (buf, "ABCDEF");
1118 if (snprintf (buf, 3, "%d %d", 4567, 89) != 7) 1222 if (my_snprintf (buf, 3, "%d %d", 4567, 89) != 7)
1119 return 1; 1223 return 1;
1224 if (my_snprintf (buf, 0, "%d %d", 4567, 89) != 7)
1225 return 2;
1226 if (my_snprintf (NULL, 0, "%d %d", 4567, 89) != 7)
1227 return 3;
1120 return 0; 1228 return 0;
1121}], [gl_cv_func_snprintf_retval_c99=yes], [gl_cv_func_snprintf_retval_c99=no], 1229}]])],
1122 [ 1230 [gl_cv_func_snprintf_retval_c99=yes],
1231 [gl_cv_func_snprintf_retval_c99=no],
1232 [
1123changequote(,)dnl 1233changequote(,)dnl
1124 case "$host_os" in 1234 case "$host_os" in
1125 # Guess yes on glibc systems. 1235 # Guess yes on glibc systems.
1126 *-gnu*) gl_cv_func_snprintf_retval_c99="guessing yes";; 1236 *-gnu*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1127 # Guess yes on FreeBSD >= 5. 1237 # Guess yes on FreeBSD >= 5.
1128 freebsd[1-4]*) gl_cv_func_snprintf_retval_c99="guessing no";; 1238 freebsd[1-4]*) gl_cv_func_snprintf_retval_c99="guessing no";;
1129 freebsd* | kfreebsd*) gl_cv_func_snprintf_retval_c99="guessing yes";; 1239 freebsd* | kfreebsd*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1130 # Guess yes on MacOS X >= 10.3. 1240 # Guess yes on Mac OS X >= 10.3.
1131 darwin[1-6].*) gl_cv_func_snprintf_retval_c99="guessing no";; 1241 darwin[1-6].*) gl_cv_func_snprintf_retval_c99="guessing no";;
1132 darwin*) gl_cv_func_snprintf_retval_c99="guessing yes";; 1242 darwin*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1133 # Guess yes on OpenBSD >= 3.9. 1243 # Guess yes on OpenBSD >= 3.9.
1134 openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*) 1244 openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*)
1135 gl_cv_func_snprintf_retval_c99="guessing no";; 1245 gl_cv_func_snprintf_retval_c99="guessing no";;
1136 openbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";; 1246 openbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1137 # Guess yes on Solaris >= 2.6. 1247 # Guess yes on Solaris >= 2.10.
1138 solaris2.[0-5]*) gl_cv_func_snprintf_retval_c99="guessing no";; 1248 solaris2.[1-9][0-9]*) gl_cv_func_printf_sizes_c99="guessing yes";;
1139 solaris*) gl_cv_func_snprintf_retval_c99="guessing yes";; 1249 solaris*) gl_cv_func_printf_sizes_c99="guessing no";;
1140 # Guess yes on AIX >= 4. 1250 # Guess yes on AIX >= 4.
1141 aix[1-3]*) gl_cv_func_snprintf_retval_c99="guessing no";; 1251 aix[1-3]*) gl_cv_func_snprintf_retval_c99="guessing no";;
1142 aix*) gl_cv_func_snprintf_retval_c99="guessing yes";; 1252 aix*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1143 # Guess yes on NetBSD >= 3. 1253 # Guess yes on NetBSD >= 3.
1144 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) 1254 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
1145 gl_cv_func_snprintf_retval_c99="guessing no";; 1255 gl_cv_func_snprintf_retval_c99="guessing no";;
1146 netbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";; 1256 netbsd*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1147 # Guess yes on BeOS. 1257 # Guess yes on BeOS.
1148 beos*) gl_cv_func_snprintf_retval_c99="guessing yes";; 1258 beos*) gl_cv_func_snprintf_retval_c99="guessing yes";;
1149 # If we don't know, assume the worst. 1259 # If we don't know, assume the worst.
1150 *) gl_cv_func_snprintf_retval_c99="guessing no";; 1260 *) gl_cv_func_snprintf_retval_c99="guessing no";;
1151 esac 1261 esac
1152changequote([,])dnl 1262changequote([,])dnl
1153 ]) 1263 ])
1154 ]) 1264 ])
1155]) 1265])
1156 1266
@@ -1162,12 +1272,28 @@ AC_DEFUN([gl_SNPRINTF_DIRECTIVE_N],
1162[ 1272[
1163 AC_REQUIRE([AC_PROG_CC]) 1273 AC_REQUIRE([AC_PROG_CC])
1164 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles 1274 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
1275 AC_REQUIRE([gl_SNPRINTF_PRESENCE])
1165 AC_CACHE_CHECK([whether snprintf fully supports the 'n' directive], 1276 AC_CACHE_CHECK([whether snprintf fully supports the 'n' directive],
1166 [gl_cv_func_snprintf_directive_n], 1277 [gl_cv_func_snprintf_directive_n],
1167 [ 1278 [
1168 AC_TRY_RUN([ 1279 AC_RUN_IFELSE(
1280 [AC_LANG_SOURCE([[
1169#include <stdio.h> 1281#include <stdio.h>
1170#include <string.h> 1282#include <string.h>
1283#if HAVE_SNPRINTF
1284# define my_snprintf snprintf
1285#else
1286# include <stdarg.h>
1287static int my_snprintf (char *buf, int size, const char *format, ...)
1288{
1289 va_list args;
1290 int ret;
1291 va_start (args, format);
1292 ret = vsnprintf (buf, size, format, args);
1293 va_end (args);
1294 return ret;
1295}
1296#endif
1171static char fmtstring[10]; 1297static char fmtstring[10];
1172static char buf[100]; 1298static char buf[100];
1173int main () 1299int main ()
@@ -1177,44 +1303,47 @@ int main ()
1177 support %n in format strings in read-only memory but not in writable 1303 support %n in format strings in read-only memory but not in writable
1178 memory. */ 1304 memory. */
1179 strcpy (fmtstring, "%d %n"); 1305 strcpy (fmtstring, "%d %n");
1180 snprintf (buf, 4, fmtstring, 12345, &count, 33, 44, 55); 1306 my_snprintf (buf, 4, fmtstring, 12345, &count, 33, 44, 55);
1181 if (count != 6) 1307 if (count != 6)
1182 return 1; 1308 return 1;
1183 return 0; 1309 return 0;
1184}], [gl_cv_func_snprintf_directive_n=yes], [gl_cv_func_snprintf_directive_n=no], 1310}]])],
1185 [ 1311 [gl_cv_func_snprintf_directive_n=yes],
1312 [gl_cv_func_snprintf_directive_n=no],
1313 [
1186changequote(,)dnl 1314changequote(,)dnl
1187 case "$host_os" in 1315 case "$host_os" in
1188 # Guess yes on glibc systems. 1316 # Guess yes on glibc systems.
1189 *-gnu*) gl_cv_func_snprintf_directive_n="guessing yes";; 1317 *-gnu*) gl_cv_func_snprintf_directive_n="guessing yes";;
1190 # Guess yes on FreeBSD >= 5. 1318 # Guess yes on FreeBSD >= 5.
1191 freebsd[1-4]*) gl_cv_func_snprintf_directive_n="guessing no";; 1319 freebsd[1-4]*) gl_cv_func_snprintf_directive_n="guessing no";;
1192 freebsd* | kfreebsd*) gl_cv_func_snprintf_directive_n="guessing yes";; 1320 freebsd* | kfreebsd*) gl_cv_func_snprintf_directive_n="guessing yes";;
1193 # Guess yes on MacOS X >= 10.3. 1321 # Guess yes on Mac OS X >= 10.3.
1194 darwin[1-6].*) gl_cv_func_snprintf_directive_n="guessing no";; 1322 darwin[1-6].*) gl_cv_func_snprintf_directive_n="guessing no";;
1195 darwin*) gl_cv_func_snprintf_directive_n="guessing yes";; 1323 darwin*) gl_cv_func_snprintf_directive_n="guessing yes";;
1196 # Guess yes on Solaris >= 2.6. 1324 # Guess yes on Solaris >= 2.6.
1197 solaris2.[0-5]*) gl_cv_func_snprintf_directive_n="guessing no";; 1325 solaris2.[0-5] | solaris2.[0-5].*)
1198 solaris*) gl_cv_func_snprintf_directive_n="guessing yes";; 1326 gl_cv_func_snprintf_directive_n="guessing no";;
1199 # Guess yes on AIX >= 4. 1327 solaris*) gl_cv_func_snprintf_directive_n="guessing yes";;
1200 aix[1-3]*) gl_cv_func_snprintf_directive_n="guessing no";; 1328 # Guess yes on AIX >= 4.
1201 aix*) gl_cv_func_snprintf_directive_n="guessing yes";; 1329 aix[1-3]*) gl_cv_func_snprintf_directive_n="guessing no";;
1202 # Guess yes on IRIX >= 6.5. 1330 aix*) gl_cv_func_snprintf_directive_n="guessing yes";;
1203 irix6.5) gl_cv_func_snprintf_directive_n="guessing yes";; 1331 # Guess yes on IRIX >= 6.5.
1204 # Guess yes on OSF/1 >= 5. 1332 irix6.5) gl_cv_func_snprintf_directive_n="guessing yes";;
1205 osf[3-4]*) gl_cv_func_snprintf_directive_n="guessing no";; 1333 # Guess yes on OSF/1 >= 5.
1206 osf*) gl_cv_func_snprintf_directive_n="guessing yes";; 1334 osf[3-4]*) gl_cv_func_snprintf_directive_n="guessing no";;
1207 # Guess yes on NetBSD >= 3. 1335 osf*) gl_cv_func_snprintf_directive_n="guessing yes";;
1208 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) 1336 # Guess yes on NetBSD >= 3.
1209 gl_cv_func_snprintf_directive_n="guessing no";; 1337 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
1210 netbsd*) gl_cv_func_snprintf_directive_n="guessing yes";; 1338 gl_cv_func_snprintf_directive_n="guessing no";;
1211 # Guess yes on BeOS. 1339 netbsd*) gl_cv_func_snprintf_directive_n="guessing yes";;
1212 beos*) gl_cv_func_snprintf_directive_n="guessing yes";; 1340 # Guess yes on BeOS.
1213 # If we don't know, assume the worst. 1341 beos*) gl_cv_func_snprintf_directive_n="guessing yes";;
1214 *) gl_cv_func_snprintf_directive_n="guessing no";; 1342 # If we don't know, assume the worst.
1215 esac 1343 *) gl_cv_func_snprintf_directive_n="guessing no";;
1344 esac
1216changequote([,])dnl 1345changequote([,])dnl
1217 ]) 1346 ])
1218 ]) 1347 ])
1219]) 1348])
1220 1349
@@ -1226,20 +1355,36 @@ dnl Result is gl_cv_func_snprintf_size1.
1226AC_DEFUN([gl_SNPRINTF_SIZE1], 1355AC_DEFUN([gl_SNPRINTF_SIZE1],
1227[ 1356[
1228 AC_REQUIRE([AC_PROG_CC]) 1357 AC_REQUIRE([AC_PROG_CC])
1358 AC_REQUIRE([gl_SNPRINTF_PRESENCE])
1229 AC_CACHE_CHECK([whether snprintf respects a size of 1], 1359 AC_CACHE_CHECK([whether snprintf respects a size of 1],
1230 [gl_cv_func_snprintf_size1], 1360 [gl_cv_func_snprintf_size1],
1231 [ 1361 [
1232 AC_TRY_RUN([ 1362 AC_RUN_IFELSE(
1363 [AC_LANG_SOURCE([[
1233#include <stdio.h> 1364#include <stdio.h>
1365#if HAVE_SNPRINTF
1366# define my_snprintf snprintf
1367#else
1368# include <stdarg.h>
1369static int my_snprintf (char *buf, int size, const char *format, ...)
1370{
1371 va_list args;
1372 int ret;
1373 va_start (args, format);
1374 ret = vsnprintf (buf, size, format, args);
1375 va_end (args);
1376 return ret;
1377}
1378#endif
1234int main() 1379int main()
1235{ 1380{
1236 static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' }; 1381 static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' };
1237 snprintf (buf, 1, "%d", 12345); 1382 my_snprintf (buf, 1, "%d", 12345);
1238 return buf[1] != 'E'; 1383 return buf[1] != 'E';
1239}], 1384}]])],
1240 [gl_cv_func_snprintf_size1=yes], 1385 [gl_cv_func_snprintf_size1=yes],
1241 [gl_cv_func_snprintf_size1=no], 1386 [gl_cv_func_snprintf_size1=no],
1242 [gl_cv_func_snprintf_size1="guessing yes"]) 1387 [gl_cv_func_snprintf_size1="guessing yes"])
1243 ]) 1388 ])
1244]) 1389])
1245 1390
@@ -1286,7 +1431,8 @@ AC_DEFUN([gl_VSNPRINTF_ZEROSIZE_C99],
1286 AC_CACHE_CHECK([whether vsnprintf respects a zero size as in C99], 1431 AC_CACHE_CHECK([whether vsnprintf respects a zero size as in C99],
1287 [gl_cv_func_vsnprintf_zerosize_c99], 1432 [gl_cv_func_vsnprintf_zerosize_c99],
1288 [ 1433 [
1289 AC_TRY_RUN([ 1434 AC_RUN_IFELSE(
1435 [AC_LANG_SOURCE([[
1290#include <stdarg.h> 1436#include <stdarg.h>
1291#include <stdio.h> 1437#include <stdio.h>
1292static int my_snprintf (char *buf, int size, const char *format, ...) 1438static int my_snprintf (char *buf, int size, const char *format, ...)
@@ -1303,43 +1449,44 @@ int main()
1303 static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' }; 1449 static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' };
1304 my_snprintf (buf, 0, "%d", 12345); 1450 my_snprintf (buf, 0, "%d", 12345);
1305 return buf[0] != 'D'; 1451 return buf[0] != 'D';
1306}], 1452}]])],
1307 [gl_cv_func_vsnprintf_zerosize_c99=yes], 1453 [gl_cv_func_vsnprintf_zerosize_c99=yes],
1308 [gl_cv_func_vsnprintf_zerosize_c99=no], 1454 [gl_cv_func_vsnprintf_zerosize_c99=no],
1309 [ 1455 [
1310changequote(,)dnl 1456changequote(,)dnl
1311 case "$host_os" in 1457 case "$host_os" in
1312 # Guess yes on glibc systems. 1458 # Guess yes on glibc systems.
1313 *-gnu*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 1459 *-gnu*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1314 # Guess yes on FreeBSD >= 5. 1460 # Guess yes on FreeBSD >= 5.
1315 freebsd[1-4]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; 1461 freebsd[1-4]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
1316 freebsd* | kfreebsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 1462 freebsd* | kfreebsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1317 # Guess yes on MacOS X >= 10.3. 1463 # Guess yes on Mac OS X >= 10.3.
1318 darwin[1-6].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; 1464 darwin[1-6].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
1319 darwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 1465 darwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1320 # Guess yes on Cygwin. 1466 # Guess yes on Cygwin.
1321 cygwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 1467 cygwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1322 # Guess yes on Solaris >= 2.6. 1468 # Guess yes on Solaris >= 2.6.
1323 solaris2.[0-5]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; 1469 solaris2.[0-5] | solaris2.[0-5].*)
1324 solaris*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 1470 gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
1325 # Guess yes on AIX >= 4. 1471 solaris*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1326 aix[1-3]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; 1472 # Guess yes on AIX >= 4.
1327 aix*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 1473 aix[1-3]*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
1328 # Guess yes on IRIX >= 6.5. 1474 aix*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1329 irix6.5) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 1475 # Guess yes on IRIX >= 6.5.
1330 # Guess yes on NetBSD >= 3. 1476 irix6.5) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1331 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*) 1477 # Guess yes on NetBSD >= 3.
1332 gl_cv_func_vsnprintf_zerosize_c99="guessing no";; 1478 netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
1333 netbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 1479 gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
1334 # Guess yes on BeOS. 1480 netbsd*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1335 beos*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 1481 # Guess yes on BeOS.
1336 # Guess yes on mingw. 1482 beos*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1337 mingw* | pw*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";; 1483 # Guess yes on mingw.
1338 # If we don't know, assume the worst. 1484 mingw* | pw*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
1339 *) gl_cv_func_vsnprintf_zerosize_c99="guessing no";; 1485 # If we don't know, assume the worst.
1340 esac 1486 *) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
1487 esac
1341changequote([,])dnl 1488changequote([,])dnl
1342 ]) 1489 ])
1343 ]) 1490 ])
1344]) 1491])
1345 1492
@@ -1393,24 +1540,31 @@ dnl 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1393dnl glibc 2.5 . . . . . . . . . . . . . . . . . . . . 1540dnl glibc 2.5 . . . . . . . . . . . . . . . . . . . .
1394dnl glibc 2.3.6 . . . . # . . . . . . . . . . . . . . . 1541dnl glibc 2.3.6 . . . . # . . . . . . . . . . . . . . .
1395dnl FreeBSD 5.4, 6.1 . . . . # . . . . . . # . # . . . . . . 1542dnl FreeBSD 5.4, 6.1 . . . . # . . . . . . # . # . . . . . .
1396dnl MacOS X 10.3.9 . . . . # . . . . . . # . # . . . . . . 1543dnl Mac OS X 10.5.8 . . . # # . . . . . . # . . . . . . . .
1544dnl Mac OS X 10.3.9 . . . . # . . . . . . # . # . . . . . .
1397dnl OpenBSD 3.9, 4.0 . . # # # # . # . # . # . # . . . . . . 1545dnl OpenBSD 3.9, 4.0 . . # # # # . # . # . # . # . . . . . .
1398dnl Cygwin 1.7.0 (2009) . . . # . . . ? . . . . . ? . . . . . . 1546dnl Cygwin 1.7.0 (2009) . . . # . . . ? . . . . . ? . . . . . .
1399dnl Cygwin 1.5.25 (2008) . . . # # . . # . . . . . # . . . . . . 1547dnl Cygwin 1.5.25 (2008) . . . # # . . # . . . . . # . . . . . .
1400dnl Cygwin 1.5.19 (2006) # . . # # # . # . # . # # # . . . . . . 1548dnl Cygwin 1.5.19 (2006) # . . # # # . # . # . # # # . . . . . .
1401dnl Solaris 10 . . # # # . . # . . . # . . . . . . . . 1549dnl Solaris 11 2011-11 . . # # # . . # . . . # . . . . . . . .
1402dnl Solaris 2.6 ... 9 # . # # # # . # . . . # . . . . . . . . 1550dnl Solaris 10 . . # # # . . # . . . # # . . . . . . .
1551dnl Solaris 2.6 ... 9 # . # # # # . # . . . # # . . . # . . .
1403dnl Solaris 2.5.1 # . # # # # . # . . . # . . # # # # # # 1552dnl Solaris 2.5.1 # . # # # # . # . . . # . . # # # # # #
1553dnl AIX 7.1 . . # # # . . . . . . # # . . . . . . .
1404dnl AIX 5.2 . . # # # . . . . . . # . . . . . . . . 1554dnl AIX 5.2 . . # # # . . . . . . # . . . . . . . .
1405dnl AIX 4.3.2, 5.1 # . # # # # . . . . . # . . . . . . . . 1555dnl AIX 4.3.2, 5.1 # . # # # # . . . . . # . . . . # . . .
1406dnl HP-UX 11.31 . . . . # . . . . . . # . . . . # # . . 1556dnl HP-UX 11.31 . . . . # . . . . . . # . . . . # # . .
1407dnl HP-UX 11.{00,11,23} # . . . # # . . . . . # . . . . # # . # 1557dnl HP-UX 11.{00,11,23} # . . . # # . . . . . # . . . . # # . #
1408dnl HP-UX 10.20 # . # . # # . ? . . # # . . . . # # ? # 1558dnl HP-UX 10.20 # . # . # # . ? . . # # . . . . # # ? #
1409dnl IRIX 6.5 # . # # # # . # . . . # . . . . # . . . 1559dnl IRIX 6.5 # . # # # # . # . . . # . . . . # . . .
1410dnl OSF/1 5.1 # . # # # # . . . . . # . . . . # . . # 1560dnl OSF/1 5.1 # . # # # # . . . . . # . . . . # . . #
1411dnl OSF/1 4.0d # . # # # # . . . . . # . . # # # # # # 1561dnl OSF/1 4.0d # . # # # # . . . . . # . . # # # # # #
1562dnl NetBSD 5.0 . . . # # . . . . . . # . # . . . . . .
1412dnl NetBSD 4.0 . ? ? ? ? ? . ? . ? ? ? ? ? . . . ? ? ? 1563dnl NetBSD 4.0 . ? ? ? ? ? . ? . ? ? ? ? ? . . . ? ? ?
1413dnl NetBSD 3.0 . . . . # # . ? # # ? # . # . . . . . . 1564dnl NetBSD 3.0 . . . . # # . ? # # ? # . # . . . . . .
1414dnl Haiku . . . # # # . # . . . . . ? . . . . . . 1565dnl Haiku . . . # # # . # . . . . . ? . . ? . . .
1415dnl BeOS # # . # # # . ? # . ? . # ? . . . . . . 1566dnl BeOS # # . # # # . ? # . ? . # ? . . ? . . .
1416dnl mingw # # # # # # . . # # . # # ? . # # # . . 1567dnl old mingw / msvcrt # # # # # # . . # # . # # ? . # # # . .
1568dnl MSVC 9 # # # # # # # . # # . # # ? # # # # . .
1569dnl mingw 2009-2011 . # . # . . . . # # . . . ? . . . . . .
1570dnl mingw-w64 2011 # # # # # # . . # # . # # ? . # # # . .
diff --git a/gl/m4/progtest.m4 b/gl/m4/progtest.m4
index 2d804ac..7b39123 100644
--- a/gl/m4/progtest.m4
+++ b/gl/m4/progtest.m4
@@ -1,5 +1,5 @@
1# progtest.m4 serial 6 (gettext-0.18) 1# progtest.m4 serial 7 (gettext-0.18.2)
2dnl Copyright (C) 1996-2003, 2005, 2008-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 1996-2003, 2005, 2008-2013 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,15 +27,14 @@ AC_DEFUN([AM_PATH_PROG_WITH_TEST],
27# Prepare PATH_SEPARATOR. 27# Prepare PATH_SEPARATOR.
28# The user is always right. 28# The user is always right.
29if test "${PATH_SEPARATOR+set}" != set; then 29if test "${PATH_SEPARATOR+set}" != set; then
30 echo "#! /bin/sh" >conf$$.sh 30 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
31 echo "exit 0" >>conf$$.sh 31 # contains only /bin. Note that ksh looks also at the FPATH variable,
32 chmod +x conf$$.sh 32 # so we have to set that as well for the test.
33 if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then 33 PATH_SEPARATOR=:
34 PATH_SEPARATOR=';' 34 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
35 else 35 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
36 PATH_SEPARATOR=: 36 || PATH_SEPARATOR=';'
37 fi 37 }
38 rm -f conf$$.sh
39fi 38fi
40 39
41# Find out how to test for executable files. Don't use a zero-byte file, 40# Find out how to test for executable files. Don't use a zero-byte file,
diff --git a/gl/m4/read.m4 b/gl/m4/read.m4
new file mode 100644
index 0000000..81f0f3a
--- /dev/null
+++ b/gl/m4/read.m4
@@ -0,0 +1,26 @@
1# read.m4 serial 4
2dnl Copyright (C) 2011-2013 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_READ],
8[
9 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10 AC_REQUIRE([gl_MSVC_INVAL])
11 if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then
12 REPLACE_READ=1
13 fi
14 dnl This ifdef is just an optimization, to avoid performing a configure
15 dnl check whose result is not used. It does not make the test of
16 dnl GNULIB_UNISTD_H_NONBLOCKING or GNULIB_NONBLOCKING redundant.
17 m4_ifdef([gl_NONBLOCKING_IO], [
18 gl_NONBLOCKING_IO
19 if test $gl_cv_have_nonblocking != yes; then
20 REPLACE_READ=1
21 fi
22 ])
23])
24
25# Prerequisites of lib/read.c.
26AC_DEFUN([gl_PREREQ_READ], [:])
diff --git a/gl/m4/regex.m4 b/gl/m4/regex.m4
index 95784e4..0945c11 100644
--- a/gl/m4/regex.m4
+++ b/gl/m4/regex.m4
@@ -1,7 +1,6 @@
1# serial 56 1# serial 64
2 2
3# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 3# Copyright (C) 1996-2001, 2003-2013 Free Software Foundation, Inc.
4# 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
5# 4#
6# This file is free software; the Free Software Foundation 5# This file is free software; the Free Software Foundation
7# gives unlimited permission to copy and/or distribute it, 6# gives unlimited permission to copy and/or distribute it,
@@ -14,8 +13,6 @@ AC_PREREQ([2.50])
14 13
15AC_DEFUN([gl_REGEX], 14AC_DEFUN([gl_REGEX],
16[ 15[
17 AC_CHECK_HEADERS_ONCE([locale.h])
18
19 AC_ARG_WITH([included-regex], 16 AC_ARG_WITH([included-regex],
20 [AS_HELP_STRING([--without-included-regex], 17 [AS_HELP_STRING([--without-included-regex],
21 [don't compile regex; this is the default on systems 18 [don't compile regex; this is the default on systems
@@ -30,31 +27,41 @@ AC_DEFUN([gl_REGEX],
30 # following run test, then default to *not* using the included regex.c. 27 # following run test, then default to *not* using the included regex.c.
31 # If cross compiling, assume the test would fail and use the included 28 # If cross compiling, assume the test would fail and use the included
32 # regex.c. 29 # regex.c.
30 AC_CHECK_DECLS_ONCE([alarm])
33 AC_CACHE_CHECK([for working re_compile_pattern], 31 AC_CACHE_CHECK([for working re_compile_pattern],
34 [gl_cv_func_re_compile_pattern_working], 32 [gl_cv_func_re_compile_pattern_working],
35 [AC_RUN_IFELSE( 33 [AC_RUN_IFELSE(
36 [AC_LANG_PROGRAM( 34 [AC_LANG_PROGRAM(
37 [AC_INCLUDES_DEFAULT[ 35 [[#include <regex.h>
38 #if HAVE_LOCALE_H 36
39 #include <locale.h> 37 #include <locale.h>
40 #endif 38 #include <limits.h>
41 #include <limits.h> 39 #include <string.h>
42 #include <regex.h> 40 #if HAVE_DECL_ALARM
43 ]], 41 # include <unistd.h>
44 [[static struct re_pattern_buffer regex; 42 # include <signal.h>
43 #endif
44 ]],
45 [[int result = 0;
46 static struct re_pattern_buffer regex;
45 unsigned char folded_chars[UCHAR_MAX + 1]; 47 unsigned char folded_chars[UCHAR_MAX + 1];
46 int i; 48 int i;
47 const char *s; 49 const char *s;
48 struct re_registers regs; 50 struct re_registers regs;
49 51
50 #if HAVE_LOCALE_H 52#if HAVE_DECL_ALARM
51 /* http://sourceware.org/ml/libc-hacker/2006-09/msg00008.html 53 /* Some builds of glibc go into an infinite loop on this test. */
52 This test needs valgrind to catch the bug on Debian 54 signal (SIGALRM, SIG_DFL);
53 GNU/Linux 3.1 x86, but it might catch the bug better 55 alarm (2);
54 on other platforms and it shouldn't hurt to try the 56#endif
55 test here. */ 57 if (setlocale (LC_ALL, "en_US.UTF-8"))
56 if (setlocale (LC_ALL, "en_US.UTF-8")) 58 {
57 { 59 {
60 /* http://sourceware.org/ml/libc-hacker/2006-09/msg00008.html
61 This test needs valgrind to catch the bug on Debian
62 GNU/Linux 3.1 x86, but it might catch the bug better
63 on other platforms and it shouldn't hurt to try the
64 test here. */
58 static char const pat[] = "insert into"; 65 static char const pat[] = "insert into";
59 static char const data[] = 66 static char const data[] =
60 "\xFF\0\x12\xA2\xAA\xC4\xB1,K\x12\xC4\xB1*\xACK"; 67 "\xFF\0\x12\xA2\xAA\xC4\xB1,K\x12\xC4\xB1*\xACK";
@@ -63,26 +70,57 @@ AC_DEFUN([gl_REGEX],
63 memset (&regex, 0, sizeof regex); 70 memset (&regex, 0, sizeof regex);
64 s = re_compile_pattern (pat, sizeof pat - 1, &regex); 71 s = re_compile_pattern (pat, sizeof pat - 1, &regex);
65 if (s) 72 if (s)
66 return 1; 73 result |= 1;
67 if (re_search (&regex, data, sizeof data - 1, 74 else if (re_search (&regex, data, sizeof data - 1,
68 0, sizeof data - 1, &regs) 75 0, sizeof data - 1, &regs)
69 != -1) 76 != -1)
70 return 1; 77 result |= 1;
71 if (! setlocale (LC_ALL, "C"))
72 return 1;
73 } 78 }
74 #endif 79
80 {
81 /* This test is from glibc bug 15078.
82 The test case is from Andreas Schwab in
83 <http://www.sourceware.org/ml/libc-alpha/2013-01/msg00967.html>.
84 */
85 static char const pat[] = "[^x]x";
86 static char const data[] =
87 /* <U1000><U103B><U103D><U1014><U103A><U102F><U1015><U103A> */
88 "\xe1\x80\x80"
89 "\xe1\x80\xbb"
90 "\xe1\x80\xbd"
91 "\xe1\x80\x94"
92 "\xe1\x80\xba"
93 "\xe1\x80\xaf"
94 "\xe1\x80\x95"
95 "\xe1\x80\xba"
96 "x";
97 re_set_syntax (0);
98 memset (&regex, 0, sizeof regex);
99 s = re_compile_pattern (pat, sizeof pat - 1, &regex);
100 if (s)
101 result |= 1;
102 else
103 {
104 i = re_search (&regex, data, sizeof data - 1,
105 0, sizeof data - 1, 0);
106 if (i != 0 && i != 21)
107 result |= 1;
108 }
109 }
110
111 if (! setlocale (LC_ALL, "C"))
112 return 1;
113 }
75 114
76 /* This test is from glibc bug 3957, reported by Andrew Mackey. */ 115 /* This test is from glibc bug 3957, reported by Andrew Mackey. */
77 re_set_syntax (RE_SYNTAX_EGREP | RE_HAT_LISTS_NOT_NEWLINE); 116 re_set_syntax (RE_SYNTAX_EGREP | RE_HAT_LISTS_NOT_NEWLINE);
78 memset (&regex, 0, sizeof regex); 117 memset (&regex, 0, sizeof regex);
79 s = re_compile_pattern ("a[^x]b", 6, &regex); 118 s = re_compile_pattern ("a[^x]b", 6, &regex);
80 if (s) 119 if (s)
81 return 1; 120 result |= 2;
82
83 /* This should fail, but succeeds for glibc-2.5. */ 121 /* This should fail, but succeeds for glibc-2.5. */
84 if (re_search (&regex, "a\nb", 3, 0, 3, &regs) != -1) 122 else if (re_search (&regex, "a\nb", 3, 0, 3, &regs) != -1)
85 return 1; 123 result |= 2;
86 124
87 /* This regular expression is from Spencer ere test number 75 125 /* This regular expression is from Spencer ere test number 75
88 in grep-2.3. */ 126 in grep-2.3. */
@@ -94,7 +132,7 @@ AC_DEFUN([gl_REGEX],
94 s = re_compile_pattern ("a[[:@:>@:]]b\n", 11, &regex); 132 s = re_compile_pattern ("a[[:@:>@:]]b\n", 11, &regex);
95 /* This should fail with _Invalid character class name_ error. */ 133 /* This should fail with _Invalid character class name_ error. */
96 if (!s) 134 if (!s)
97 return 1; 135 result |= 4;
98 136
99 /* Ensure that [b-a] is diagnosed as invalid, when 137 /* Ensure that [b-a] is diagnosed as invalid, when
100 using RE_NO_EMPTY_RANGES. */ 138 using RE_NO_EMPTY_RANGES. */
@@ -102,34 +140,31 @@ AC_DEFUN([gl_REGEX],
102 memset (&regex, 0, sizeof regex); 140 memset (&regex, 0, sizeof regex);
103 s = re_compile_pattern ("a[b-a]", 6, &regex); 141 s = re_compile_pattern ("a[b-a]", 6, &regex);
104 if (s == 0) 142 if (s == 0)
105 return 1; 143 result |= 8;
106 144
107 /* This should succeed, but does not for glibc-2.1.3. */ 145 /* This should succeed, but does not for glibc-2.1.3. */
108 memset (&regex, 0, sizeof regex); 146 memset (&regex, 0, sizeof regex);
109 s = re_compile_pattern ("{1", 2, &regex); 147 s = re_compile_pattern ("{1", 2, &regex);
110
111 if (s) 148 if (s)
112 return 1; 149 result |= 8;
113 150
114 /* The following example is derived from a problem report 151 /* The following example is derived from a problem report
115 against gawk from Jorge Stolfi <stolfi@ic.unicamp.br>. */ 152 against gawk from Jorge Stolfi <stolfi@ic.unicamp.br>. */
116 memset (&regex, 0, sizeof regex); 153 memset (&regex, 0, sizeof regex);
117 s = re_compile_pattern ("[an\371]*n", 7, &regex); 154 s = re_compile_pattern ("[an\371]*n", 7, &regex);
118 if (s) 155 if (s)
119 return 1; 156 result |= 8;
120
121 /* This should match, but does not for glibc-2.2.1. */ 157 /* This should match, but does not for glibc-2.2.1. */
122 if (re_match (&regex, "an", 2, 0, &regs) != 2) 158 else if (re_match (&regex, "an", 2, 0, &regs) != 2)
123 return 1; 159 result |= 8;
124 160
125 memset (&regex, 0, sizeof regex); 161 memset (&regex, 0, sizeof regex);
126 s = re_compile_pattern ("x", 1, &regex); 162 s = re_compile_pattern ("x", 1, &regex);
127 if (s) 163 if (s)
128 return 1; 164 result |= 8;
129
130 /* glibc-2.2.93 does not work with a negative RANGE argument. */ 165 /* glibc-2.2.93 does not work with a negative RANGE argument. */
131 if (re_search (&regex, "wxy", 3, 2, -2, &regs) != 1) 166 else if (re_search (&regex, "wxy", 3, 2, -2, &regs) != 1)
132 return 1; 167 result |= 8;
133 168
134 /* The version of regex.c in older versions of gnulib 169 /* The version of regex.c in older versions of gnulib
135 ignored RE_ICASE. Detect that problem too. */ 170 ignored RE_ICASE. Detect that problem too. */
@@ -137,10 +172,9 @@ AC_DEFUN([gl_REGEX],
137 memset (&regex, 0, sizeof regex); 172 memset (&regex, 0, sizeof regex);
138 s = re_compile_pattern ("x", 1, &regex); 173 s = re_compile_pattern ("x", 1, &regex);
139 if (s) 174 if (s)
140 return 1; 175 result |= 16;
141 176 else if (re_search (&regex, "WXY", 3, 0, 3, &regs) < 0)
142 if (re_search (&regex, "WXY", 3, 0, 3, &regs) < 0) 177 result |= 16;
143 return 1;
144 178
145 /* Catch a bug reported by Vin Shelton in 179 /* Catch a bug reported by Vin Shelton in
146 http://lists.gnu.org/archive/html/bug-coreutils/2007-06/msg00089.html 180 http://lists.gnu.org/archive/html/bug-coreutils/2007-06/msg00089.html
@@ -151,21 +185,27 @@ AC_DEFUN([gl_REGEX],
151 memset (&regex, 0, sizeof regex); 185 memset (&regex, 0, sizeof regex);
152 s = re_compile_pattern ("[[:alnum:]_-]\\\\+$", 16, &regex); 186 s = re_compile_pattern ("[[:alnum:]_-]\\\\+$", 16, &regex);
153 if (s) 187 if (s)
154 return 1; 188 result |= 32;
155 189
156 /* REG_STARTEND was added to glibc on 2004-01-15. 190 /* REG_STARTEND was added to glibc on 2004-01-15.
157 Reject older versions. */ 191 Reject older versions. */
158 if (! REG_STARTEND) 192 if (! REG_STARTEND)
159 return 1; 193 result |= 64;
160 194
161 /* Reject hosts whose regoff_t values are too narrow. 195#if 0
162 These include glibc 2.3.5 on hosts with 64-bit ptrdiff_t 196 /* It would be nice to reject hosts whose regoff_t values are too
163 and 32-bit int. */ 197 narrow (including glibc on hosts with 64-bit ptrdiff_t and
198 32-bit int), but we should wait until glibc implements this
199 feature. Otherwise, support for equivalence classes and
200 multibyte collation symbols would always be broken except
201 when compiling --without-included-regex. */
164 if (sizeof (regoff_t) < sizeof (ptrdiff_t) 202 if (sizeof (regoff_t) < sizeof (ptrdiff_t)
165 || sizeof (regoff_t) < sizeof (ssize_t)) 203 || sizeof (regoff_t) < sizeof (ssize_t))
166 return 1; 204 result |= 64;
205#endif
167 206
168 return 0;]])], 207 return result;
208 ]])],
169 [gl_cv_func_re_compile_pattern_working=yes], 209 [gl_cv_func_re_compile_pattern_working=yes],
170 [gl_cv_func_re_compile_pattern_working=no], 210 [gl_cv_func_re_compile_pattern_working=no],
171 dnl When crosscompiling, assume it is not working. 211 dnl When crosscompiling, assume it is not working.
@@ -180,6 +220,9 @@ AC_DEFUN([gl_REGEX],
180 esac 220 esac
181 221
182 if test $ac_use_included_regex = yes; then 222 if test $ac_use_included_regex = yes; then
223 AC_DEFINE([_REGEX_INCLUDE_LIMITS_H], [1],
224 [Define if you want <regex.h> to include <limits.h>, so that it
225 consistently overrides <limits.h>'s RE_DUP_MAX.])
183 AC_DEFINE([_REGEX_LARGE_OFFSETS], [1], 226 AC_DEFINE([_REGEX_LARGE_OFFSETS], [1],
184 [Define if you want regoff_t to be at least as wide POSIX requires.]) 227 [Define if you want regoff_t to be at least as wide POSIX requires.])
185 AC_DEFINE([re_syntax_options], [rpl_re_syntax_options], 228 AC_DEFINE([re_syntax_options], [rpl_re_syntax_options],
@@ -212,8 +255,6 @@ AC_DEFUN([gl_REGEX],
212 [Define to rpl_regerror if the replacement should be used.]) 255 [Define to rpl_regerror if the replacement should be used.])
213 AC_DEFINE([regfree], [rpl_regfree], 256 AC_DEFINE([regfree], [rpl_regfree],
214 [Define to rpl_regfree if the replacement should be used.]) 257 [Define to rpl_regfree if the replacement should be used.])
215 AC_LIBOBJ([regex])
216 gl_PREREQ_REGEX
217 fi 258 fi
218]) 259])
219 260
@@ -224,7 +265,9 @@ AC_DEFUN([gl_PREREQ_REGEX],
224 AC_REQUIRE([AC_C_INLINE]) 265 AC_REQUIRE([AC_C_INLINE])
225 AC_REQUIRE([AC_C_RESTRICT]) 266 AC_REQUIRE([AC_C_RESTRICT])
226 AC_REQUIRE([AC_TYPE_MBSTATE_T]) 267 AC_REQUIRE([AC_TYPE_MBSTATE_T])
268 AC_REQUIRE([gl_EEMALLOC])
269 AC_REQUIRE([gl_GLIBC21])
227 AC_CHECK_HEADERS([libintl.h]) 270 AC_CHECK_HEADERS([libintl.h])
228 AC_CHECK_FUNCS_ONCE([isblank iswctype wcscoll]) 271 AC_CHECK_FUNCS_ONCE([isblank iswctype wcscoll])
229 AC_CHECK_DECLS([isblank], [], [], [#include <ctype.h>]) 272 AC_CHECK_DECLS([isblank], [], [], [[#include <ctype.h>]])
230]) 273])
diff --git a/gl/m4/safe-read.m4 b/gl/m4/safe-read.m4
index d087bd3..be5207a 100644
--- a/gl/m4/safe-read.m4
+++ b/gl/m4/safe-read.m4
@@ -1,17 +1,10 @@
1# safe-read.m4 serial 5 1# safe-read.m4 serial 6
2dnl Copyright (C) 2002-2003, 2005-2006, 2009-2010 Free Software Foundation, 2dnl Copyright (C) 2002-2003, 2005-2006, 2009-2013 Free Software Foundation,
3dnl Inc. 3dnl Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
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
8AC_DEFUN([gl_SAFE_READ],
9[
10 AC_LIBOBJ([safe-read])
11
12 gl_PREREQ_SAFE_READ
13])
14
15# Prerequisites of lib/safe-read.c. 8# Prerequisites of lib/safe-read.c.
16AC_DEFUN([gl_PREREQ_SAFE_READ], 9AC_DEFUN([gl_PREREQ_SAFE_READ],
17[ 10[
diff --git a/gl/m4/safe-write.m4 b/gl/m4/safe-write.m4
deleted file mode 100644
index 2ff11d2..0000000
--- a/gl/m4/safe-write.m4
+++ /dev/null
@@ -1,18 +0,0 @@
1# safe-write.m4 serial 3
2dnl Copyright (C) 2002, 2005-2006, 2009-2010 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_SAFE_WRITE],
8[
9 AC_LIBOBJ([safe-write])
10
11 gl_PREREQ_SAFE_WRITE
12])
13
14# Prerequisites of lib/safe-write.c.
15AC_DEFUN([gl_PREREQ_SAFE_WRITE],
16[
17 gl_PREREQ_SAFE_READ
18])
diff --git a/gl/m4/servent.m4 b/gl/m4/servent.m4
index 2ed961a..01c037a 100644
--- a/gl/m4/servent.m4
+++ b/gl/m4/servent.m4
@@ -1,5 +1,5 @@
1# servent.m4 serial 1 1# servent.m4 serial 2
2dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2008, 2010-2013 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.
@@ -30,12 +30,16 @@ AC_DEFUN([gl_SERVENT],
30 [gl_cv_w32_getservbyname=no 30 [gl_cv_w32_getservbyname=no
31 gl_save_LIBS="$LIBS" 31 gl_save_LIBS="$LIBS"
32 LIBS="$LIBS -lws2_32" 32 LIBS="$LIBS -lws2_32"
33 AC_TRY_LINK([ 33 AC_LINK_IFELSE(
34 [AC_LANG_PROGRAM(
35 [[
34#ifdef HAVE_WINSOCK2_H 36#ifdef HAVE_WINSOCK2_H
35#include <winsock2.h> 37#include <winsock2.h>
36#endif 38#endif
37#include <stddef.h> 39#include <stddef.h>
38], [getservbyname(NULL,NULL);], [gl_cv_w32_getservbyname=yes]) 40 ]],
41 [[getservbyname(NULL,NULL);]])],
42 [gl_cv_w32_getservbyname=yes])
39 LIBS="$gl_save_LIBS" 43 LIBS="$gl_save_LIBS"
40 ]) 44 ])
41 if test "$gl_cv_w32_getservbyname" = "yes"; then 45 if test "$gl_cv_w32_getservbyname" = "yes"; then
diff --git a/gl/m4/setenv.m4 b/gl/m4/setenv.m4
index 58f6d13..cb5351a 100644
--- a/gl/m4/setenv.m4
+++ b/gl/m4/setenv.m4
@@ -1,5 +1,5 @@
1# setenv.m4 serial 16 1# setenv.m4 serial 26
2dnl Copyright (C) 2001-2004, 2006-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2001-2004, 2006-2013 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,16 +7,7 @@ dnl with or without modifications, as long as this notice is preserved.
7AC_DEFUN([gl_FUNC_SETENV], 7AC_DEFUN([gl_FUNC_SETENV],
8[ 8[
9 AC_REQUIRE([gl_FUNC_SETENV_SEPARATE]) 9 AC_REQUIRE([gl_FUNC_SETENV_SEPARATE])
10 if test $HAVE_SETENV$REPLACE_SETENV != 10; then 10 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
11 AC_LIBOBJ([setenv])
12 fi
13])
14
15# Like gl_FUNC_SETENV, except prepare for separate compilation (no AC_LIBOBJ).
16AC_DEFUN([gl_FUNC_SETENV_SEPARATE],
17[
18 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
19 AC_CHECK_FUNCS_ONCE([setenv])
20 if test $ac_cv_func_setenv = no; then 11 if test $ac_cv_func_setenv = no; then
21 HAVE_SETENV=0 12 HAVE_SETENV=0
22 else 13 else
@@ -27,69 +18,127 @@ AC_DEFUN([gl_FUNC_SETENV_SEPARATE],
27 #include <errno.h> 18 #include <errno.h>
28 #include <string.h> 19 #include <string.h>
29 ]], [[ 20 ]], [[
30 if (setenv ("", "", 0) != -1) return 1; 21 int result = 0;
31 if (errno != EINVAL) return 2; 22 {
32 if (setenv ("a", "=", 1) != 0) return 3; 23 if (setenv ("", "", 0) != -1)
33 if (strcmp (getenv ("a"), "=") != 0) return 4; 24 result |= 1;
25 else if (errno != EINVAL)
26 result |= 2;
27 }
28 {
29 if (setenv ("a", "=", 1) != 0)
30 result |= 4;
31 else if (strcmp (getenv ("a"), "=") != 0)
32 result |= 8;
33 }
34 return result;
34 ]])], 35 ]])],
35 [gl_cv_func_setenv_works=yes], [gl_cv_func_setenv_works=no], 36 [gl_cv_func_setenv_works=yes], [gl_cv_func_setenv_works=no],
36 [gl_cv_func_setenv_works="guessing no"])]) 37 [case "$host_os" in
37 if test "$gl_cv_func_setenv_works" != yes; then 38 # Guess yes on glibc systems.
38 REPLACE_SETENV=1 39 *-gnu*) gl_cv_func_setenv_works="guessing yes" ;;
39 AC_LIBOBJ([setenv]) 40 # If we don't know, assume the worst.
40 fi 41 *) gl_cv_func_setenv_works="guessing no" ;;
42 esac
43 ])])
44 case "$gl_cv_func_setenv_works" in
45 *yes) ;;
46 *)
47 REPLACE_SETENV=1
48 ;;
49 esac
41 fi 50 fi
51])
52
53# Like gl_FUNC_SETENV, except prepare for separate compilation
54# (no REPLACE_SETENV, no AC_LIBOBJ).
55AC_DEFUN([gl_FUNC_SETENV_SEPARATE],
56[
57 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
58 AC_CHECK_DECLS_ONCE([setenv])
59 if test $ac_cv_have_decl_setenv = no; then
60 HAVE_DECL_SETENV=0
61 fi
62 AC_CHECK_FUNCS_ONCE([setenv])
42 gl_PREREQ_SETENV 63 gl_PREREQ_SETENV
43]) 64])
44 65
45AC_DEFUN([gl_FUNC_UNSETENV], 66AC_DEFUN([gl_FUNC_UNSETENV],
46[ 67[
47 AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) 68 AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
69 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
70 AC_CHECK_DECLS_ONCE([unsetenv])
71 if test $ac_cv_have_decl_unsetenv = no; then
72 HAVE_DECL_UNSETENV=0
73 fi
48 AC_CHECK_FUNCS([unsetenv]) 74 AC_CHECK_FUNCS([unsetenv])
49 if test $ac_cv_func_unsetenv = no; then 75 if test $ac_cv_func_unsetenv = no; then
50 HAVE_UNSETENV=0 76 HAVE_UNSETENV=0
51 AC_LIBOBJ([unsetenv])
52 gl_PREREQ_UNSETENV
53 else 77 else
78 HAVE_UNSETENV=1
54 dnl Some BSDs return void, failing to do error checking. 79 dnl Some BSDs return void, failing to do error checking.
55 AC_CACHE_CHECK([for unsetenv() return type], [gt_cv_func_unsetenv_ret], 80 AC_CACHE_CHECK([for unsetenv() return type], [gt_cv_func_unsetenv_ret],
56 [AC_TRY_COMPILE([#include <stdlib.h> 81 [AC_COMPILE_IFELSE(
82 [AC_LANG_PROGRAM(
83 [[
84#undef _BSD
85#define _BSD 1 /* unhide unsetenv declaration in OSF/1 5.1 <stdlib.h> */
86#include <stdlib.h>
57extern 87extern
58#ifdef __cplusplus 88#ifdef __cplusplus
59"C" 89"C"
60#endif 90#endif
61#if defined(__STDC__) || defined(__cplusplus)
62int unsetenv (const char *name); 91int unsetenv (const char *name);
63#else 92 ]],
64int unsetenv(); 93 [[]])],
65#endif 94 [gt_cv_func_unsetenv_ret='int'],
66], , gt_cv_func_unsetenv_ret='int', gt_cv_func_unsetenv_ret='void')]) 95 [gt_cv_func_unsetenv_ret='void'])])
67 if test $gt_cv_func_unsetenv_ret = 'void'; then 96 if test $gt_cv_func_unsetenv_ret = 'void'; then
68 AC_DEFINE([VOID_UNSETENV], [1], [Define to 1 if unsetenv returns void 97 AC_DEFINE([VOID_UNSETENV], [1], [Define to 1 if unsetenv returns void
69 instead of int.]) 98 instead of int.])
70 REPLACE_UNSETENV=1 99 REPLACE_UNSETENV=1
71 AC_LIBOBJ([unsetenv])
72 fi 100 fi
73 101
74 dnl Solaris 10 unsetenv does not remove all copies of a name. 102 dnl Solaris 10 unsetenv does not remove all copies of a name.
75 AC_CACHE_CHECK([whether unsetenv works on duplicates], 103 dnl Haiku alpha 2 unsetenv gets confused by assignment to environ.
104 dnl OpenBSD 4.7 unsetenv("") does not fail.
105 AC_CACHE_CHECK([whether unsetenv obeys POSIX],
76 [gl_cv_func_unsetenv_works], 106 [gl_cv_func_unsetenv_works],
77 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ 107 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
78 #include <stdlib.h> 108 #include <stdlib.h>
109 #include <errno.h>
110 extern char **environ;
79 ]], [[ 111 ]], [[
80 char entry[] = "b=2"; 112 char entry1[] = "a=1";
113 char entry2[] = "b=2";
114 char *env[] = { entry1, entry2, NULL };
81 if (putenv ((char *) "a=1")) return 1; 115 if (putenv ((char *) "a=1")) return 1;
82 if (putenv (entry)) return 2; 116 if (putenv (entry2)) return 2;
83 entry[0] = 'a'; 117 entry2[0] = 'a';
84 unsetenv ("a"); 118 unsetenv ("a");
85 if (getenv ("a")) return 3; 119 if (getenv ("a")) return 3;
120 if (!unsetenv ("") || errno != EINVAL) return 4;
121 entry2[0] = 'b';
122 environ = env;
123 if (!getenv ("a")) return 5;
124 entry2[0] = 'a';
125 unsetenv ("a");
126 if (getenv ("a")) return 6;
86 ]])], 127 ]])],
87 [gl_cv_func_unsetenv_works=yes], [gl_cv_func_unsetenv_works=no], 128 [gl_cv_func_unsetenv_works=yes], [gl_cv_func_unsetenv_works=no],
88 [gl_cv_func_unsetenv_works="guessing no"])]) 129 [case "$host_os" in
89 if test "$gl_cv_func_unsetenv_works" != yes; then 130 # Guess yes on glibc systems.
90 REPLACE_UNSETENV=1 131 *-gnu*) gl_cv_func_unsetenv_works="guessing yes" ;;
91 AC_LIBOBJ([unsetenv]) 132 # If we don't know, assume the worst.
92 fi 133 *) gl_cv_func_unsetenv_works="guessing no" ;;
134 esac
135 ])])
136 case "$gl_cv_func_unsetenv_works" in
137 *yes) ;;
138 *)
139 REPLACE_UNSETENV=1
140 ;;
141 esac
93 fi 142 fi
94]) 143])
95 144
diff --git a/gl/m4/sha1.m4 b/gl/m4/sha1.m4
index 0d18d85..21c775e 100644
--- a/gl/m4/sha1.m4
+++ b/gl/m4/sha1.m4
@@ -1,16 +1,12 @@
1# sha1.m4 serial 9 1# sha1.m4 serial 11
2dnl Copyright (C) 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010 Free Software 2dnl Copyright (C) 2002-2006, 2008-2013 Free Software Foundation, Inc.
3dnl Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
7 6
8AC_DEFUN([gl_SHA1], 7AC_DEFUN([gl_SHA1],
9[ 8[
10 AC_LIBOBJ([sha1])
11
12 dnl Prerequisites of lib/sha1.c. 9 dnl Prerequisites of lib/sha1.c.
13 AC_REQUIRE([gl_BIGENDIAN]) 10 AC_REQUIRE([gl_BIGENDIAN])
14 AC_REQUIRE([AC_C_INLINE])
15 : 11 :
16]) 12])
diff --git a/gl/m4/size_max.m4 b/gl/m4/size_max.m4
index ce992db..4b247ab 100644
--- a/gl/m4/size_max.m4
+++ b/gl/m4/size_max.m4
@@ -1,5 +1,5 @@
1# size_max.m4 serial 9 1# size_max.m4 serial 10
2dnl Copyright (C) 2003, 2005-2006, 2008-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2003, 2005-2006, 2008-2013 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,10 +34,14 @@ Found it
34 if test $fits_in_uint = 1; then 34 if test $fits_in_uint = 1; then
35 dnl Even though SIZE_MAX fits in an unsigned int, it must be of type 35 dnl Even though SIZE_MAX fits in an unsigned int, it must be of type
36 dnl 'unsigned long' if the type 'size_t' is the same as 'unsigned long'. 36 dnl 'unsigned long' if the type 'size_t' is the same as 'unsigned long'.
37 AC_TRY_COMPILE([#include <stddef.h> 37 AC_COMPILE_IFELSE(
38 extern size_t foo; 38 [AC_LANG_PROGRAM(
39 extern unsigned long foo; 39 [[#include <stddef.h>
40 ], [], [fits_in_uint=0]) 40 extern size_t foo;
41 extern unsigned long foo;
42 ]],
43 [[]])],
44 [fits_in_uint=0])
41 fi 45 fi
42 dnl We cannot use 'expr' to simplify this expression, because 'expr' 46 dnl We cannot use 'expr' to simplify this expression, because 'expr'
43 dnl works only with 'long' integers in the host environment, while we 47 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 522b107..3698e84 100644
--- a/gl/m4/snprintf.m4
+++ b/gl/m4/snprintf.m4
@@ -1,9 +1,13 @@
1# snprintf.m4 serial 5 1# snprintf.m4 serial 6
2dnl Copyright (C) 2002-2004, 2007-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2004, 2007-2013 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 Libintl 0.17 will replace snprintf only if it does not support %1$s,
8dnl but defers to any gnulib snprintf replacements. Therefore, gnulib
9dnl must guarantee that the decision for replacing snprintf is a superset
10dnl of the reasons checked by libintl.
7AC_DEFUN([gl_FUNC_SNPRINTF], 11AC_DEFUN([gl_FUNC_SNPRINTF],
8[ 12[
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS]) 13 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
@@ -13,7 +17,17 @@ AC_DEFUN([gl_FUNC_SNPRINTF],
13 gl_SNPRINTF_SIZE1 17 gl_SNPRINTF_SIZE1
14 case "$gl_cv_func_snprintf_size1" in 18 case "$gl_cv_func_snprintf_size1" in
15 *yes) 19 *yes)
16 gl_cv_func_snprintf_usable=yes 20 gl_SNPRINTF_RETVAL_C99
21 case "$gl_cv_func_snprintf_retval_c99" in
22 *yes)
23 gl_PRINTF_POSITIONS
24 case "$gl_cv_func_printf_positions" in
25 *yes)
26 gl_cv_func_snprintf_usable=yes
27 ;;
28 esac
29 ;;
30 esac
17 ;; 31 ;;
18 esac 32 esac
19 fi 33 fi
diff --git a/gl/m4/socketlib.m4 b/gl/m4/socketlib.m4
new file mode 100644
index 0000000..b08a72f
--- /dev/null
+++ b/gl/m4/socketlib.m4
@@ -0,0 +1,86 @@
1# socketlib.m4 serial 1
2dnl Copyright (C) 2008-2013 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 gl_SOCKETLIB
8dnl Determines the library to use for socket functions.
9dnl Sets and AC_SUBSTs LIBSOCKET.
10
11AC_DEFUN([gl_SOCKETLIB],
12[
13 gl_PREREQ_SYS_H_WINSOCK2 dnl for HAVE_WINSOCK2_H
14 LIBSOCKET=
15 if test $HAVE_WINSOCK2_H = 1; then
16 dnl Native Windows API (not Cygwin).
17 AC_CACHE_CHECK([if we need to call WSAStartup in winsock2.h and -lws2_32],
18 [gl_cv_func_wsastartup], [
19 gl_save_LIBS="$LIBS"
20 LIBS="$LIBS -lws2_32"
21 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
22#ifdef HAVE_WINSOCK2_H
23# include <winsock2.h>
24#endif]], [[
25 WORD wVersionRequested = MAKEWORD(1, 1);
26 WSADATA wsaData;
27 int err = WSAStartup(wVersionRequested, &wsaData);
28 WSACleanup ();]])],
29 gl_cv_func_wsastartup=yes, gl_cv_func_wsastartup=no)
30 LIBS="$gl_save_LIBS"
31 ])
32 if test "$gl_cv_func_wsastartup" = "yes"; then
33 AC_DEFINE([WINDOWS_SOCKETS], [1], [Define if WSAStartup is needed.])
34 LIBSOCKET='-lws2_32'
35 fi
36 else
37 dnl Unix API.
38 dnl Solaris has most socket functions in libsocket.
39 dnl Haiku has most socket functions in libnetwork.
40 dnl BeOS has most socket functions in libnet.
41 AC_CACHE_CHECK([for library containing setsockopt], [gl_cv_lib_socket], [
42 gl_cv_lib_socket=
43 AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern
44#ifdef __cplusplus
45"C"
46#endif
47char setsockopt();]], [[setsockopt();]])],
48 [],
49 [gl_save_LIBS="$LIBS"
50 LIBS="$gl_save_LIBS -lsocket"
51 AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern
52#ifdef __cplusplus
53"C"
54#endif
55char setsockopt();]], [[setsockopt();]])],
56 [gl_cv_lib_socket="-lsocket"])
57 if test -z "$gl_cv_lib_socket"; then
58 LIBS="$gl_save_LIBS -lnetwork"
59 AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern
60#ifdef __cplusplus
61"C"
62#endif
63char setsockopt();]], [[setsockopt();]])],
64 [gl_cv_lib_socket="-lnetwork"])
65 if test -z "$gl_cv_lib_socket"; then
66 LIBS="$gl_save_LIBS -lnet"
67 AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern
68#ifdef __cplusplus
69"C"
70#endif
71char setsockopt();]], [[setsockopt();]])],
72 [gl_cv_lib_socket="-lnet"])
73 fi
74 fi
75 LIBS="$gl_save_LIBS"
76 ])
77 if test -z "$gl_cv_lib_socket"; then
78 gl_cv_lib_socket="none needed"
79 fi
80 ])
81 if test "$gl_cv_lib_socket" != "none needed"; then
82 LIBSOCKET="$gl_cv_lib_socket"
83 fi
84 fi
85 AC_SUBST([LIBSOCKET])
86])
diff --git a/gl/m4/sockets.m4 b/gl/m4/sockets.m4
index aefb936..b407391 100644
--- a/gl/m4/sockets.m4
+++ b/gl/m4/sockets.m4
@@ -1,5 +1,5 @@
1# sockets.m4 serial 6 1# sockets.m4 serial 7
2dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2008-2013 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,80 +7,7 @@ dnl with or without modifications, as long as this notice is preserved.
7AC_DEFUN([gl_SOCKETS], 7AC_DEFUN([gl_SOCKETS],
8[ 8[
9 AC_REQUIRE([AC_C_INLINE]) 9 AC_REQUIRE([AC_C_INLINE])
10 10 AC_REQUIRE([gl_SOCKETLIB])
11 gl_PREREQ_SYS_H_WINSOCK2 dnl for HAVE_WINSOCK2_H
12 LIBSOCKET=
13 if test $HAVE_WINSOCK2_H = 1; then
14 dnl Native Windows API (not Cygwin).
15 AC_CACHE_CHECK([if we need to call WSAStartup in winsock2.h and -lws2_32],
16 [gl_cv_func_wsastartup], [
17 gl_save_LIBS="$LIBS"
18 LIBS="$LIBS -lws2_32"
19 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
20#ifdef HAVE_WINSOCK2_H
21# include <winsock2.h>
22#endif]], [[
23 WORD wVersionRequested = MAKEWORD(1, 1);
24 WSADATA wsaData;
25 int err = WSAStartup(wVersionRequested, &wsaData);
26 WSACleanup ();]])],
27 gl_cv_func_wsastartup=yes, gl_cv_func_wsastartup=no)
28 LIBS="$gl_save_LIBS"
29 ])
30 if test "$gl_cv_func_wsastartup" = "yes"; then
31 AC_DEFINE([WINDOWS_SOCKETS], [1], [Define if WSAStartup is needed.])
32 LIBSOCKET='-lws2_32'
33 fi
34 else
35 dnl Unix API.
36 dnl Solaris has most socket functions in libsocket.
37 dnl Haiku has most socket functions in libnetwork.
38 dnl BeOS has most socket functions in libnet.
39 AC_CACHE_CHECK([for library containing setsockopt], [gl_cv_lib_socket], [
40 gl_cv_lib_socket=
41 AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern
42#ifdef __cplusplus
43"C"
44#endif
45char setsockopt();]], [[setsockopt();]])],
46 [],
47 [gl_save_LIBS="$LIBS"
48 LIBS="$gl_save_LIBS -lsocket"
49 AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern
50#ifdef __cplusplus
51"C"
52#endif
53char setsockopt();]], [[setsockopt();]])],
54 [gl_cv_lib_socket="-lsocket"])
55 if test -z "$gl_cv_lib_socket"; then
56 LIBS="$gl_save_LIBS -lnetwork"
57 AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern
58#ifdef __cplusplus
59"C"
60#endif
61char setsockopt();]], [[setsockopt();]])],
62 [gl_cv_lib_socket="-lnetwork"])
63 if test -z "$gl_cv_lib_socket"; then
64 LIBS="$gl_save_LIBS -lnet"
65 AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern
66#ifdef __cplusplus
67"C"
68#endif
69char setsockopt();]], [[setsockopt();]])],
70 [gl_cv_lib_socket="-lnet"])
71 fi
72 fi
73 LIBS="$gl_save_LIBS"
74 ])
75 if test -z "$gl_cv_lib_socket"; then
76 gl_cv_lib_socket="none needed"
77 fi
78 ])
79 if test "$gl_cv_lib_socket" != "none needed"; then
80 LIBSOCKET="$gl_cv_lib_socket"
81 fi
82 fi
83 AC_SUBST([LIBSOCKET])
84 gl_PREREQ_SOCKETS 11 gl_PREREQ_SOCKETS
85]) 12])
86 13
diff --git a/gl/m4/socklen.m4 b/gl/m4/socklen.m4
index 2933d4b..e3efd6e 100644
--- a/gl/m4/socklen.m4
+++ b/gl/m4/socklen.m4
@@ -1,5 +1,5 @@
1# socklen.m4 serial 7 1# socklen.m4 serial 10
2dnl Copyright (C) 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2005-2007, 2009-2013 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,15 +8,12 @@ dnl From Albert Chin, Windows fixes from Simon Josefsson.
8 8
9dnl Check for socklen_t: historically on BSD it is an int, and in 9dnl Check for socklen_t: historically on BSD it is an int, and in
10dnl POSIX 1g it is a type of its own, but some platforms use different 10dnl POSIX 1g it is a type of its own, but some platforms use different
11dnl types for the argument to getsockopt, getpeername, etc. So we 11dnl types for the argument to getsockopt, getpeername, etc.:
12dnl have to test to find something that will work. 12dnl HP-UX 10.20, IRIX 6.5, OSF/1 4.0, Interix 3.5, BeOS.
13dnl So we have to test to find something that will work.
13 14
14dnl On mingw32, socklen_t is in ws2tcpip.h ('int'), so we try to find
15dnl it there first. That file is included by gnulib's sys_socket.in.h, which
16dnl all users of this module should include. Cygwin must not include
17dnl ws2tcpip.h.
18AC_DEFUN([gl_TYPE_SOCKLEN_T], 15AC_DEFUN([gl_TYPE_SOCKLEN_T],
19 [AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl 16 [AC_REQUIRE([gl_CHECK_SOCKET_HEADERS])dnl
20 AC_CHECK_TYPE([socklen_t], , 17 AC_CHECK_TYPE([socklen_t], ,
21 [AC_MSG_CHECKING([for socklen_t equivalent]) 18 [AC_MSG_CHECKING([for socklen_t equivalent])
22 AC_CACHE_VAL([gl_cv_socklen_t_equiv], 19 AC_CACHE_VAL([gl_cv_socklen_t_equiv],
@@ -44,9 +41,37 @@ AC_DEFUN([gl_TYPE_SOCKLEN_T],
44 AC_MSG_RESULT([$gl_cv_socklen_t_equiv]) 41 AC_MSG_RESULT([$gl_cv_socklen_t_equiv])
45 AC_DEFINE_UNQUOTED([socklen_t], [$gl_cv_socklen_t_equiv], 42 AC_DEFINE_UNQUOTED([socklen_t], [$gl_cv_socklen_t_equiv],
46 [type to use in place of socklen_t if not defined])], 43 [type to use in place of socklen_t if not defined])],
47 [#include <sys/types.h> 44 [gl_SOCKET_HEADERS])])
48 #if HAVE_SYS_SOCKET_H 45
49 # include <sys/socket.h> 46dnl On mingw32, socklen_t is in ws2tcpip.h ('int'), so we try to find
50 #elif HAVE_WS2TCPIP_H 47dnl it there too. But on Cygwin, wc2tcpip.h must not be included. Users
51 # include <ws2tcpip.h> 48dnl of this module should use the same include pattern as gl_SOCKET_HEADERS.
52 #endif])]) 49dnl When you change this macro, keep also in sync:
50dnl - gl_CHECK_SOCKET_HEADERS,
51dnl - the Include section of modules/socklen.
52AC_DEFUN([gl_SOCKET_HEADERS],
53[
54/* <sys/types.h> is not needed according to POSIX, but the
55 <sys/socket.h> in i386-unknown-freebsd4.10 and
56 powerpc-apple-darwin5.5 required it. */
57#include <sys/types.h>
58#if HAVE_SYS_SOCKET_H
59# include <sys/socket.h>
60#elif HAVE_WS2TCPIP_H
61# include <ws2tcpip.h>
62#endif
63])
64
65dnl Tests for the existence of the header for socket facilities.
66dnl Defines the C macros HAVE_SYS_SOCKET_H, HAVE_WS2TCPIP_H.
67dnl This macro must match gl_SOCKET_HEADERS.
68AC_DEFUN([gl_CHECK_SOCKET_HEADERS],
69 [AC_CHECK_HEADERS_ONCE([sys/socket.h])
70 if test $ac_cv_header_sys_socket_h = no; then
71 dnl We cannot use AC_CHECK_HEADERS_ONCE here, because that would make
72 dnl the check for those headers unconditional; yet cygwin reports
73 dnl that the headers are present but cannot be compiled (since on
74 dnl cygwin, all socket information should come from sys/socket.h).
75 AC_CHECK_HEADERS([ws2tcpip.h])
76 fi
77 ])
diff --git a/gl/m4/sockpfaf.m4 b/gl/m4/sockpfaf.m4
index 8806705..89557b1 100644
--- a/gl/m4/sockpfaf.m4
+++ b/gl/m4/sockpfaf.m4
@@ -1,5 +1,5 @@
1# sockpfaf.m4 serial 7 1# sockpfaf.m4 serial 8
2dnl Copyright (C) 2004, 2006, 2009, 2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2004, 2006, 2009-2013 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.
@@ -59,3 +59,29 @@ AC_DEFUN([gl_SOCKET_FAMILIES],
59 AC_DEFINE([HAVE_IPV6], [1], [Define to 1 if <sys/socket.h> defines AF_INET6.]) 59 AC_DEFINE([HAVE_IPV6], [1], [Define to 1 if <sys/socket.h> defines AF_INET6.])
60 fi 60 fi
61]) 61])
62
63AC_DEFUN([gl_SOCKET_FAMILY_UNIX],
64[
65 AC_REQUIRE([gl_HEADER_SYS_SOCKET])
66 AC_CHECK_HEADERS_ONCE([sys/un.h])
67
68 AC_MSG_CHECKING([for UNIX domain sockets])
69 AC_CACHE_VAL([gl_cv_socket_unix],
70 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
71#ifdef HAVE_SYS_SOCKET_H
72#include <sys/socket.h>
73#endif
74#ifdef HAVE_SYS_UN_H
75#include <sys/un.h>
76#endif
77#ifdef HAVE_WINSOCK2_H
78#include <winsock2.h>
79#endif]],
80[[int x = AF_UNIX; struct sockaddr_un y;
81 if (&x && &y) return 0;]])],
82 gl_cv_socket_unix=yes, gl_cv_socket_unix=no)])
83 AC_MSG_RESULT([$gl_cv_socket_unix])
84 if test $gl_cv_socket_unix = yes; then
85 AC_DEFINE([HAVE_UNIXSOCKET], [1], [Define to 1 if <sys/socket.h> defines AF_UNIX.])
86 fi
87])
diff --git a/gl/m4/ssize_t.m4 b/gl/m4/ssize_t.m4
index e0ccee3..6338134 100644
--- a/gl/m4/ssize_t.m4
+++ b/gl/m4/ssize_t.m4
@@ -1,5 +1,5 @@
1# ssize_t.m4 serial 4 (gettext-0.15) 1# ssize_t.m4 serial 5 (gettext-0.18.2)
2dnl Copyright (C) 2001-2003, 2006, 2009-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2001-2003, 2006, 2010-2013 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,9 +10,11 @@ dnl Test whether ssize_t is defined.
10AC_DEFUN([gt_TYPE_SSIZE_T], 10AC_DEFUN([gt_TYPE_SSIZE_T],
11[ 11[
12 AC_CACHE_CHECK([for ssize_t], [gt_cv_ssize_t], 12 AC_CACHE_CHECK([for ssize_t], [gt_cv_ssize_t],
13 [AC_TRY_COMPILE([#include <sys/types.h>], 13 [AC_COMPILE_IFELSE(
14 [int x = sizeof (ssize_t *) + sizeof (ssize_t); 14 [AC_LANG_PROGRAM(
15 return !x;], 15 [[#include <sys/types.h>]],
16 [[int x = sizeof (ssize_t *) + sizeof (ssize_t);
17 return !x;]])],
16 [gt_cv_ssize_t=yes], [gt_cv_ssize_t=no])]) 18 [gt_cv_ssize_t=yes], [gt_cv_ssize_t=no])])
17 if test $gt_cv_ssize_t = no; then 19 if test $gt_cv_ssize_t = no; then
18 AC_DEFINE([ssize_t], [int], 20 AC_DEFINE([ssize_t], [int],
diff --git a/gl/m4/stat.m4 b/gl/m4/stat.m4
deleted file mode 100644
index acd32d8..0000000
--- a/gl/m4/stat.m4
+++ /dev/null
@@ -1,63 +0,0 @@
1# serial 4
2
3# Copyright (C) 2009, 2010 Free Software Foundation, Inc.
4#
5# This file is free software; the Free Software Foundation
6# gives unlimited permission to copy and/or distribute it,
7# with or without modifications, as long as this notice is preserved.
8
9AC_DEFUN([gl_FUNC_STAT],
10[
11 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
12 AC_REQUIRE([gl_AC_DOS])
13 AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
14 AC_CHECK_FUNCS_ONCE([lstat])
15 dnl mingw is the only known platform where stat(".") and stat("./") differ
16 AC_CACHE_CHECK([whether stat handles trailing slashes on directories],
17 [gl_cv_func_stat_dir_slash],
18 [AC_RUN_IFELSE(
19 [AC_LANG_PROGRAM(
20 [[#include <sys/stat.h>
21]], [[struct stat st; return stat (".", &st) != stat ("./", &st);]])],
22 [gl_cv_func_stat_dir_slash=yes], [gl_cv_func_stat_dir_slash=no],
23 [case $host_os in
24 mingw*) gl_cv_func_stat_dir_slash="guessing no";;
25 *) gl_cv_func_stat_dir_slash="guessing yes";;
26 esac])])
27 dnl Solaris 9 mistakenly succeeds on stat("file/")
28 dnl FreeBSD 7.2 mistakenly succeeds on stat("link-to-file/")
29 AC_CACHE_CHECK([whether stat handles trailing slashes on files],
30 [gl_cv_func_stat_file_slash],
31 [touch conftest.tmp
32 # Assume that if we have lstat, we can also check symlinks.
33 if test $ac_cv_func_lstat = yes; then
34 ln -s conftest.tmp conftest.lnk
35 fi
36 AC_RUN_IFELSE(
37 [AC_LANG_PROGRAM(
38 [[#include <sys/stat.h>
39]], [[struct stat st;
40 if (!stat ("conftest.tmp/", &st)) return 1;
41#if HAVE_LSTAT
42 if (!stat ("conftest.lnk/", &st)) return 2;
43#endif
44 ]])],
45 [gl_cv_func_stat_file_slash=yes], [gl_cv_func_stat_file_slash=no],
46 [gl_cv_func_stat_file_slash="guessing no"])
47 rm -f conftest.tmp conftest.lnk])
48 case $gl_cv_func_stat_dir_slash in
49 *no) REPLACE_STAT=1
50 AC_DEFINE([REPLACE_FUNC_STAT_DIR], [1], [Define to 1 if stat needs
51 help when passed a directory name with a trailing slash]);;
52 esac
53 case $gl_cv_func_stat_file_slash in
54 *no) REPLACE_STAT=1
55 AC_DEFINE([REPLACE_FUNC_STAT_FILE], [1], [Define to 1 if stat needs
56 help when passed a file name with a trailing slash]);;
57 esac
58 if test $REPLACE_STAT = 1; then
59 AC_LIBOBJ([stat])
60 dnl Prerequisites of lib/stat.c.
61 AC_REQUIRE([AC_C_INLINE])
62 fi
63])
diff --git a/gl/m4/stdalign.m4 b/gl/m4/stdalign.m4
new file mode 100644
index 0000000..20be01a
--- /dev/null
+++ b/gl/m4/stdalign.m4
@@ -0,0 +1,53 @@
1# Check for stdalign.h that conforms to C11.
2
3dnl Copyright 2011-2013 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8# Prepare for substituting <stdalign.h> if it is not supported.
9
10AC_DEFUN([gl_STDALIGN_H],
11[
12 AC_CACHE_CHECK([for working stdalign.h],
13 [gl_cv_header_working_stdalign_h],
14 [AC_COMPILE_IFELSE(
15 [AC_LANG_PROGRAM(
16 [[#include <stdalign.h>
17 #include <stddef.h>
18
19 /* Test that alignof yields a result consistent with offsetof.
20 This catches GCC bug 52023
21 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>. */
22 #ifdef __cplusplus
23 template <class t> struct alignof_helper { char a; t b; };
24 # define ao(type) offsetof (alignof_helper<type>, b)
25 #else
26 # define ao(type) offsetof (struct { char a; type b; }, b)
27 #endif
28 char test_double[ao (double) % _Alignof (double) == 0 ? 1 : -1];
29 char test_long[ao (long int) % _Alignof (long int) == 0 ? 1 : -1];
30 char test_alignof[alignof (double) == _Alignof (double) ? 1 : -1];
31
32 /* Test _Alignas only on platforms where gnulib can help. */
33 #if \
34 ((defined __cplusplus && 201103 <= __cplusplus) \
35 || __GNUC__ || __IBMC__ || __IBMCPP__ || __ICC \
36 || 0x5110 <= __SUNPRO_C || 1300 <= _MSC_VER)
37 struct alignas_test { char c; char alignas (8) alignas_8; };
38 char test_alignas[offsetof (struct alignas_test, alignas_8) == 8
39 ? 1 : -1];
40 #endif
41 ]])],
42 [gl_cv_header_working_stdalign_h=yes],
43 [gl_cv_header_working_stdalign_h=no])])
44
45 if test $gl_cv_header_working_stdalign_h = yes; then
46 STDALIGN_H=''
47 else
48 STDALIGN_H='stdalign.h'
49 fi
50
51 AC_SUBST([STDALIGN_H])
52 AM_CONDITIONAL([GL_GENERATE_STDALIGN_H], [test -n "$STDALIGN_H"])
53])
diff --git a/gl/m4/stdbool.m4 b/gl/m4/stdbool.m4
index 3d672d7..80d5559 100644
--- a/gl/m4/stdbool.m4
+++ b/gl/m4/stdbool.m4
@@ -1,15 +1,17 @@
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, 2009-2010 Free Software Foundation, Inc. 3dnl Copyright (C) 2002-2006, 2009-2013 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
8#serial 5
9
8# Prepare for substituting <stdbool.h> if it is not supported. 10# Prepare for substituting <stdbool.h> if it is not supported.
9 11
10AC_DEFUN([AM_STDBOOL_H], 12AC_DEFUN([AM_STDBOOL_H],
11[ 13[
12 AC_REQUIRE([AC_HEADER_STDBOOL]) 14 AC_REQUIRE([AC_CHECK_HEADER_STDBOOL])
13 15
14 # Define two additional variables used in the Makefile substitution. 16 # Define two additional variables used in the Makefile substitution.
15 17
@@ -19,6 +21,7 @@ AC_DEFUN([AM_STDBOOL_H],
19 STDBOOL_H='stdbool.h' 21 STDBOOL_H='stdbool.h'
20 fi 22 fi
21 AC_SUBST([STDBOOL_H]) 23 AC_SUBST([STDBOOL_H])
24 AM_CONDITIONAL([GL_GENERATE_STDBOOL_H], [test -n "$STDBOOL_H"])
22 25
23 if test "$ac_cv_type__Bool" = yes; then 26 if test "$ac_cv_type__Bool" = yes; then
24 HAVE__BOOL=1 27 HAVE__BOOL=1
@@ -31,85 +34,67 @@ AC_DEFUN([AM_STDBOOL_H],
31# AM_STDBOOL_H will be renamed to gl_STDBOOL_H in the future. 34# AM_STDBOOL_H will be renamed to gl_STDBOOL_H in the future.
32AC_DEFUN([gl_STDBOOL_H], [AM_STDBOOL_H]) 35AC_DEFUN([gl_STDBOOL_H], [AM_STDBOOL_H])
33 36
34# This macro is only needed in autoconf <= 2.59. Newer versions of autoconf 37# This version of the macro is needed in autoconf <= 2.68.
35# have this macro built-in.
36 38
37AC_DEFUN([AC_HEADER_STDBOOL], 39AC_DEFUN([AC_CHECK_HEADER_STDBOOL],
38 [AC_CACHE_CHECK([for stdbool.h that conforms to C99], 40 [AC_CACHE_CHECK([for stdbool.h that conforms to C99],
39 [ac_cv_header_stdbool_h], 41 [ac_cv_header_stdbool_h],
40 [AC_TRY_COMPILE( 42 [AC_COMPILE_IFELSE(
41 [ 43 [AC_LANG_PROGRAM(
42 #include <stdbool.h> 44 [[
43 #ifndef bool 45 #include <stdbool.h>
44 "error: bool is not defined" 46 #ifndef bool
45 #endif 47 "error: bool is not defined"
46 #ifndef false 48 #endif
47 "error: false is not defined" 49 #ifndef false
48 #endif 50 "error: false is not defined"
49 #if false 51 #endif
50 "error: false is not 0" 52 #if false
51 #endif 53 "error: false is not 0"
52 #ifndef true 54 #endif
53 "error: true is not defined" 55 #ifndef true
54 #endif 56 "error: true is not defined"
55 #if true != 1 57 #endif
56 "error: true is not 1" 58 #if true != 1
57 #endif 59 "error: true is not 1"
58 #ifndef __bool_true_false_are_defined 60 #endif
59 "error: __bool_true_false_are_defined is not defined" 61 #ifndef __bool_true_false_are_defined
60 #endif 62 "error: __bool_true_false_are_defined is not defined"
63 #endif
61 64
62 struct s { _Bool s: 1; _Bool t; } s; 65 struct s { _Bool s: 1; _Bool t; } s;
63 66
64 char a[true == 1 ? 1 : -1]; 67 char a[true == 1 ? 1 : -1];
65 char b[false == 0 ? 1 : -1]; 68 char b[false == 0 ? 1 : -1];
66 char c[__bool_true_false_are_defined == 1 ? 1 : -1]; 69 char c[__bool_true_false_are_defined == 1 ? 1 : -1];
67 char d[(bool) 0.5 == true ? 1 : -1]; 70 char d[(bool) 0.5 == true ? 1 : -1];
68 bool e = &s; 71 /* See body of main program for 'e'. */
69 char f[(_Bool) 0.0 == false ? 1 : -1]; 72 char f[(_Bool) 0.0 == false ? 1 : -1];
70 char g[true]; 73 char g[true];
71 char h[sizeof (_Bool)]; 74 char h[sizeof (_Bool)];
72 char i[sizeof s.t]; 75 char i[sizeof s.t];
73 enum { j = false, k = true, l = false * true, m = true * 256 }; 76 enum { j = false, k = true, l = false * true, m = true * 256 };
74 _Bool n[m]; 77 /* The following fails for
75 char o[sizeof n == m * sizeof n[0] ? 1 : -1]; 78 HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */
76 char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; 79 _Bool n[m];
77 #if defined __xlc__ || defined __GNUC__ 80 char o[sizeof n == m * sizeof n[0] ? 1 : -1];
78 /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0 81 char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
79 reported by James Lemley on 2005-10-05; see 82 /* Catch a bug in an HP-UX C compiler. See
80 http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html 83 http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
81 This test is not quite right, since xlc is allowed to 84 http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
82 reject this program, as the initializer for xlcbug is 85 */
83 not one of the forms that C requires support for. 86 _Bool q = true;
84 However, doing the test right would require a run-time 87 _Bool *pq = &q;
85 test, and that would make cross-compilation harder. 88 ]],
86 Let us hope that IBM fixes the xlc bug, and also adds 89 [[
87 support for this kind of constant expression. In the 90 bool e = &s;
88 meantime, this test will reject xlc, which is OK, since 91 *pq |= q;
89 our stdbool.h substitute should suffice. We also test 92 *pq |= ! q;
90 this with GCC, where it should work, to detect more 93 /* Refer to every declared value, to avoid compiler optimizations. */
91 quickly whether someone messes up the test in the 94 return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
92 future. */ 95 + !m + !n + !o + !p + !q + !pq);
93 char digs[] = "0123456789"; 96 ]])],
94 int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1);
95 #endif
96 /* Catch a bug in an HP-UX C compiler. See
97 http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
98 http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
99 */
100 _Bool q = true;
101 _Bool *pq = &q;
102 ],
103 [
104 *pq |= q;
105 *pq |= ! q;
106 /* Refer to every declared value, to avoid compiler optimizations. */
107 return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
108 + !m + !n + !o + !p + !q + !pq);
109 ],
110 [ac_cv_header_stdbool_h=yes], 97 [ac_cv_header_stdbool_h=yes],
111 [ac_cv_header_stdbool_h=no])]) 98 [ac_cv_header_stdbool_h=no])])
112 AC_CHECK_TYPES([_Bool]) 99 AC_CHECK_TYPES([_Bool])
113 if test $ac_cv_header_stdbool_h = yes; then 100])
114 AC_DEFINE([HAVE_STDBOOL_H], [1], [Define to 1 if stdbool.h conforms to C99.])
115 fi])
diff --git a/gl/m4/stddef_h.m4 b/gl/m4/stddef_h.m4
index c3ae569..5da8ab1 100644
--- a/gl/m4/stddef_h.m4
+++ b/gl/m4/stddef_h.m4
@@ -1,6 +1,6 @@
1dnl A placeholder for POSIX 2008 <stddef.h>, for platforms that have issues. 1dnl A placeholder for POSIX 2008 <stddef.h>, for platforms that have issues.
2# stddef_h.m4 serial 2 2# stddef_h.m4 serial 4
3dnl Copyright (C) 2009, 2010 Free Software Foundation, Inc. 3dnl Copyright (C) 2009-2013 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.
@@ -9,6 +9,7 @@ AC_DEFUN([gl_STDDEF_H],
9[ 9[
10 AC_REQUIRE([gl_STDDEF_H_DEFAULTS]) 10 AC_REQUIRE([gl_STDDEF_H_DEFAULTS])
11 AC_REQUIRE([gt_TYPE_WCHAR_T]) 11 AC_REQUIRE([gt_TYPE_WCHAR_T])
12 STDDEF_H=
12 if test $gt_cv_c_wchar_t = no; then 13 if test $gt_cv_c_wchar_t = no; then
13 HAVE_WCHAR_T=0 14 HAVE_WCHAR_T=0
14 STDDEF_H=stddef.h 15 STDDEF_H=stddef.h
@@ -24,8 +25,10 @@ AC_DEFUN([gl_STDDEF_H],
24 REPLACE_NULL=1 25 REPLACE_NULL=1
25 STDDEF_H=stddef.h 26 STDDEF_H=stddef.h
26 fi 27 fi
28 AC_SUBST([STDDEF_H])
29 AM_CONDITIONAL([GL_GENERATE_STDDEF_H], [test -n "$STDDEF_H"])
27 if test -n "$STDDEF_H"; then 30 if test -n "$STDDEF_H"; then
28 gl_CHECK_NEXT_HEADERS([stddef.h]) 31 gl_NEXT_HEADERS([stddef.h])
29 fi 32 fi
30]) 33])
31 34
@@ -41,5 +44,4 @@ AC_DEFUN([gl_STDDEF_H_DEFAULTS],
41 dnl Assume proper GNU behavior unless another module says otherwise. 44 dnl Assume proper GNU behavior unless another module says otherwise.
42 REPLACE_NULL=0; AC_SUBST([REPLACE_NULL]) 45 REPLACE_NULL=0; AC_SUBST([REPLACE_NULL])
43 HAVE_WCHAR_T=1; AC_SUBST([HAVE_WCHAR_T]) 46 HAVE_WCHAR_T=1; AC_SUBST([HAVE_WCHAR_T])
44 STDDEF_H=''; AC_SUBST([STDDEF_H])
45]) 47])
diff --git a/gl/m4/stdint.m4 b/gl/m4/stdint.m4
index c5e813a..27cdcdb 100644
--- a/gl/m4/stdint.m4
+++ b/gl/m4/stdint.m4
@@ -1,5 +1,5 @@
1# stdint.m4 serial 35 1# stdint.m4 serial 43
2dnl Copyright (C) 2001-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2001-2013 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.
7dnl From Paul Eggert and Bruno Haible. 7dnl From Paul Eggert and Bruno Haible.
8dnl Test whether <stdint.h> is supported or must be substituted. 8dnl Test whether <stdint.h> is supported or must be substituted.
9 9
10AC_DEFUN([gl_STDINT_H], 10AC_DEFUN_ONCE([gl_STDINT_H],
11[ 11[
12 AC_PREREQ([2.59])dnl 12 AC_PREREQ([2.59])dnl
13 13
@@ -27,6 +27,15 @@ AC_DEFUN([gl_STDINT_H],
27 fi 27 fi
28 AC_SUBST([HAVE_UNSIGNED_LONG_LONG_INT]) 28 AC_SUBST([HAVE_UNSIGNED_LONG_LONG_INT])
29 29
30 dnl Check for <wchar.h>, in the same way as gl_WCHAR_H does.
31 AC_CHECK_HEADERS_ONCE([wchar.h])
32 if test $ac_cv_header_wchar_h = yes; then
33 HAVE_WCHAR_H=1
34 else
35 HAVE_WCHAR_H=0
36 fi
37 AC_SUBST([HAVE_WCHAR_H])
38
30 dnl Check for <inttypes.h>. 39 dnl Check for <inttypes.h>.
31 dnl AC_INCLUDES_DEFAULT defines $ac_cv_header_inttypes_h. 40 dnl AC_INCLUDES_DEFAULT defines $ac_cv_header_inttypes_h.
32 if test $ac_cv_header_inttypes_h = yes; then 41 if test $ac_cv_header_inttypes_h = yes; then
@@ -60,8 +69,6 @@ AC_DEFUN([gl_STDINT_H],
60 [gl_cv_header_working_stdint_h=no 69 [gl_cv_header_working_stdint_h=no
61 AC_COMPILE_IFELSE([ 70 AC_COMPILE_IFELSE([
62 AC_LANG_PROGRAM([[ 71 AC_LANG_PROGRAM([[
63#define __STDC_LIMIT_MACROS 1 /* to make it work also in C++ mode */
64#define __STDC_CONSTANT_MACROS 1 /* to make it work also in C++ mode */
65#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */ 72#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
66#include <stdint.h> 73#include <stdint.h>
67/* Dragonfly defines WCHAR_MIN, WCHAR_MAX only in <wchar.h>. */ 74/* Dragonfly defines WCHAR_MIN, WCHAR_MAX only in <wchar.h>. */
@@ -145,9 +152,11 @@ uintmax_t j = UINTMAX_MAX;
145 152
146#include <limits.h> /* for CHAR_BIT */ 153#include <limits.h> /* for CHAR_BIT */
147#define TYPE_MINIMUM(t) \ 154#define TYPE_MINIMUM(t) \
148 ((t) ((t) 0 < (t) -1 ? (t) 0 : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))) 155 ((t) ((t) 0 < (t) -1 ? (t) 0 : ~ TYPE_MAXIMUM (t)))
149#define TYPE_MAXIMUM(t) \ 156#define TYPE_MAXIMUM(t) \
150 ((t) ((t) 0 < (t) -1 ? (t) -1 : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))) 157 ((t) ((t) 0 < (t) -1 \
158 ? (t) -1 \
159 : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1)))
151struct s { 160struct s {
152 int check_PTRDIFF: 161 int check_PTRDIFF:
153 PTRDIFF_MIN == TYPE_MINIMUM (ptrdiff_t) 162 PTRDIFF_MIN == TYPE_MINIMUM (ptrdiff_t)
@@ -208,8 +217,6 @@ struct s {
208 dnl This detects a bug on HP-UX 11.23/ia64. 217 dnl This detects a bug on HP-UX 11.23/ia64.
209 AC_RUN_IFELSE([ 218 AC_RUN_IFELSE([
210 AC_LANG_PROGRAM([[ 219 AC_LANG_PROGRAM([[
211#define __STDC_LIMIT_MACROS 1 /* to make it work also in C++ mode */
212#define __STDC_CONSTANT_MACROS 1 /* to make it work also in C++ mode */
213#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */ 220#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
214#include <stdint.h> 221#include <stdint.h>
215] 222]
@@ -259,7 +266,7 @@ static const char *macro_values[] =
259 || strncmp (value, "((int)"/*)*/, 6) == 0 266 || strncmp (value, "((int)"/*)*/, 6) == 0
260 || strncmp (value, "((signed short)"/*)*/, 15) == 0 267 || strncmp (value, "((signed short)"/*)*/, 15) == 0
261 || strncmp (value, "((signed char)"/*)*/, 14) == 0) 268 || strncmp (value, "((signed char)"/*)*/, 14) == 0)
262 return 1; 269 return mv - macro_values + 1;
263 } 270 }
264 return 0; 271 return 0;
265]])], 272]])],
@@ -290,14 +297,11 @@ static const char *macro_values[] =
290 fi 297 fi
291 AC_SUBST([HAVE_SYS_BITYPES_H]) 298 AC_SUBST([HAVE_SYS_BITYPES_H])
292 299
293 dnl Check for <wchar.h> (missing in Linux uClibc when built without wide
294 dnl character support).
295 AC_CHECK_HEADERS_ONCE([wchar.h])
296
297 gl_STDINT_TYPE_PROPERTIES 300 gl_STDINT_TYPE_PROPERTIES
298 STDINT_H=stdint.h 301 STDINT_H=stdint.h
299 fi 302 fi
300 AC_SUBST([STDINT_H]) 303 AC_SUBST([STDINT_H])
304 AM_CONDITIONAL([GL_GENERATE_STDINT_H], [test -n "$STDINT_H"])
301]) 305])
302 306
303dnl gl_STDINT_BITSIZEOF(TYPES, INCLUDES) 307dnl gl_STDINT_BITSIZEOF(TYPES, INCLUDES)
@@ -458,6 +462,14 @@ AC_DEFUN([gl_STDINT_TYPE_PROPERTIES],
458 fi 462 fi
459 gl_INTEGER_TYPE_SUFFIX([sig_atomic_t wchar_t wint_t], 463 gl_INTEGER_TYPE_SUFFIX([sig_atomic_t wchar_t wint_t],
460 [gl_STDINT_INCLUDES]) 464 [gl_STDINT_INCLUDES])
465
466 dnl If wint_t is smaller than 'int', it cannot satisfy the ISO C 99
467 dnl requirement that wint_t is "unchanged by default argument promotions".
468 dnl In this case gnulib's <wchar.h> and <wctype.h> override wint_t.
469 dnl Set the variable BITSIZEOF_WINT_T accordingly.
470 if test $BITSIZEOF_WINT_T -lt 32; then
471 BITSIZEOF_WINT_T=32
472 fi
461]) 473])
462 474
463dnl Autoconf >= 2.61 has AC_COMPUTE_INT built-in. 475dnl Autoconf >= 2.61 has AC_COMPUTE_INT built-in.
diff --git a/gl/m4/stdint_h.m4 b/gl/m4/stdint_h.m4
index b8e3c6c..511ab4e 100644
--- a/gl/m4/stdint_h.m4
+++ b/gl/m4/stdint_h.m4
@@ -1,5 +1,5 @@
1# stdint_h.m4 serial 8 1# stdint_h.m4 serial 9
2dnl Copyright (C) 1997-2004, 2006, 2008-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 1997-2004, 2006, 2008-2013 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,12 +12,13 @@ dnl From Paul Eggert.
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_COMPILE_IFELSE(
16 [#include <sys/types.h> 16 [AC_LANG_PROGRAM(
17#include <stdint.h>], 17 [[#include <sys/types.h>
18 [uintmax_t i = (uintmax_t) -1; return !i;], 18 #include <stdint.h>]],
19 [gl_cv_header_stdint_h=yes], 19 [[uintmax_t i = (uintmax_t) -1; return !i;]])],
20 [gl_cv_header_stdint_h=no])]) 20 [gl_cv_header_stdint_h=yes],
21 [gl_cv_header_stdint_h=no])])
21 if test $gl_cv_header_stdint_h = yes; then 22 if test $gl_cv_header_stdint_h = yes; then
22 AC_DEFINE_UNQUOTED([HAVE_STDINT_H_WITH_UINTMAX], [1], 23 AC_DEFINE_UNQUOTED([HAVE_STDINT_H_WITH_UINTMAX], [1],
23 [Define if <stdint.h> exists, doesn't clash with <sys/types.h>, 24 [Define if <stdint.h> exists, doesn't clash with <sys/types.h>,
diff --git a/gl/m4/stdio_h.m4 b/gl/m4/stdio_h.m4
index f5650cd..ebade06 100644
--- a/gl/m4/stdio_h.m4
+++ b/gl/m4/stdio_h.m4
@@ -1,5 +1,5 @@
1# stdio_h.m4 serial 31 1# stdio_h.m4 serial 43
2dnl Copyright (C) 2007-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2007-2013 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,9 +7,32 @@ dnl with or without modifications, as long as this notice is preserved.
7AC_DEFUN([gl_STDIO_H], 7AC_DEFUN([gl_STDIO_H],
8[ 8[
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS]) 9 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
10 AC_REQUIRE([AC_C_INLINE]) 10 gl_NEXT_HEADERS([stdio.h])
11 AC_REQUIRE([gl_ASM_SYMBOL_PREFIX]) 11
12 gl_CHECK_NEXT_HEADERS([stdio.h]) 12 dnl No need to create extra modules for these functions. Everyone who uses
13 dnl <stdio.h> likely needs them.
14 GNULIB_FSCANF=1
15 gl_MODULE_INDICATOR([fscanf])
16 GNULIB_SCANF=1
17 gl_MODULE_INDICATOR([scanf])
18 GNULIB_FGETC=1
19 GNULIB_GETC=1
20 GNULIB_GETCHAR=1
21 GNULIB_FGETS=1
22 GNULIB_FREAD=1
23 dnl This ifdef is necessary to avoid an error "missing file lib/stdio-read.c"
24 dnl "expected source file, required through AC_LIBSOURCES, not found". It is
25 dnl also an optimization, to avoid performing a configure check whose result
26 dnl is not used. But it does not make the test of GNULIB_STDIO_H_NONBLOCKING
27 dnl or GNULIB_NONBLOCKING redundant.
28 m4_ifdef([gl_NONBLOCKING_IO], [
29 gl_NONBLOCKING_IO
30 if test $gl_cv_have_nonblocking != yes; then
31 REPLACE_STDIO_READ_FUNCS=1
32 AC_LIBOBJ([stdio-read])
33 fi
34 ])
35
13 dnl No need to create extra modules for these functions. Everyone who uses 36 dnl No need to create extra modules for these functions. Everyone who uses
14 dnl <stdio.h> likely needs them. 37 dnl <stdio.h> likely needs them.
15 GNULIB_FPRINTF=1 38 GNULIB_FPRINTF=1
@@ -22,9 +45,11 @@ AC_DEFUN([gl_STDIO_H],
22 GNULIB_FPUTS=1 45 GNULIB_FPUTS=1
23 GNULIB_PUTS=1 46 GNULIB_PUTS=1
24 GNULIB_FWRITE=1 47 GNULIB_FWRITE=1
25 dnl This ifdef is just an optimization, to avoid performing a configure 48 dnl This ifdef is necessary to avoid an error "missing file lib/stdio-write.c"
26 dnl check whose result is not used. It does not make the test of 49 dnl "expected source file, required through AC_LIBSOURCES, not found". It is
27 dnl GNULIB_STDIO_H_SIGPIPE or GNULIB_SIGPIPE redundant. 50 dnl also an optimization, to avoid performing a configure check whose result
51 dnl is not used. But it does not make the test of GNULIB_STDIO_H_SIGPIPE or
52 dnl GNULIB_SIGPIPE redundant.
28 m4_ifdef([gl_SIGNAL_SIGPIPE], [ 53 m4_ifdef([gl_SIGNAL_SIGPIPE], [
29 gl_SIGNAL_SIGPIPE 54 gl_SIGNAL_SIGPIPE
30 if test $gl_cv_header_signal_h_SIGPIPE != yes; then 55 if test $gl_cv_header_signal_h_SIGPIPE != yes; then
@@ -32,13 +57,25 @@ AC_DEFUN([gl_STDIO_H],
32 AC_LIBOBJ([stdio-write]) 57 AC_LIBOBJ([stdio-write])
33 fi 58 fi
34 ]) 59 ])
60 dnl This ifdef is necessary to avoid an error "missing file lib/stdio-write.c"
61 dnl "expected source file, required through AC_LIBSOURCES, not found". It is
62 dnl also an optimization, to avoid performing a configure check whose result
63 dnl is not used. But it does not make the test of GNULIB_STDIO_H_NONBLOCKING
64 dnl or GNULIB_NONBLOCKING redundant.
65 m4_ifdef([gl_NONBLOCKING_IO], [
66 gl_NONBLOCKING_IO
67 if test $gl_cv_have_nonblocking != yes; then
68 REPLACE_STDIO_WRITE_FUNCS=1
69 AC_LIBOBJ([stdio-write])
70 fi
71 ])
35 72
36 dnl Check for declarations of anything we want to poison if the 73 dnl Check for declarations of anything we want to poison if the
37 dnl corresponding gnulib module is not in use, and which is not 74 dnl corresponding gnulib module is not in use, and which is not
38 dnl guaranteed by C89. 75 dnl guaranteed by both C89 and C11.
39 gl_WARN_ON_USE_PREPARE([[#include <stdio.h> 76 gl_WARN_ON_USE_PREPARE([[#include <stdio.h>
40 ]], [dprintf fpurge fseeko ftello getdelim getline popen renameat 77 ]], [dprintf fpurge fseeko ftello getdelim getline gets pclose popen
41 snprintf tmpfile vdprintf vsnprintf]) 78 renameat snprintf tmpfile vdprintf vsnprintf])
42]) 79])
43 80
44AC_DEFUN([gl_STDIO_MODULE_INDICATOR], 81AC_DEFUN([gl_STDIO_MODULE_INDICATOR],
@@ -54,23 +91,31 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS],
54[ 91[
55 GNULIB_DPRINTF=0; AC_SUBST([GNULIB_DPRINTF]) 92 GNULIB_DPRINTF=0; AC_SUBST([GNULIB_DPRINTF])
56 GNULIB_FCLOSE=0; AC_SUBST([GNULIB_FCLOSE]) 93 GNULIB_FCLOSE=0; AC_SUBST([GNULIB_FCLOSE])
94 GNULIB_FDOPEN=0; AC_SUBST([GNULIB_FDOPEN])
57 GNULIB_FFLUSH=0; AC_SUBST([GNULIB_FFLUSH]) 95 GNULIB_FFLUSH=0; AC_SUBST([GNULIB_FFLUSH])
96 GNULIB_FGETC=0; AC_SUBST([GNULIB_FGETC])
97 GNULIB_FGETS=0; AC_SUBST([GNULIB_FGETS])
58 GNULIB_FOPEN=0; AC_SUBST([GNULIB_FOPEN]) 98 GNULIB_FOPEN=0; AC_SUBST([GNULIB_FOPEN])
59 GNULIB_FPRINTF=0; AC_SUBST([GNULIB_FPRINTF]) 99 GNULIB_FPRINTF=0; AC_SUBST([GNULIB_FPRINTF])
60 GNULIB_FPRINTF_POSIX=0; AC_SUBST([GNULIB_FPRINTF_POSIX]) 100 GNULIB_FPRINTF_POSIX=0; AC_SUBST([GNULIB_FPRINTF_POSIX])
61 GNULIB_FPURGE=0; AC_SUBST([GNULIB_FPURGE]) 101 GNULIB_FPURGE=0; AC_SUBST([GNULIB_FPURGE])
62 GNULIB_FPUTC=0; AC_SUBST([GNULIB_FPUTC]) 102 GNULIB_FPUTC=0; AC_SUBST([GNULIB_FPUTC])
63 GNULIB_FPUTS=0; AC_SUBST([GNULIB_FPUTS]) 103 GNULIB_FPUTS=0; AC_SUBST([GNULIB_FPUTS])
104 GNULIB_FREAD=0; AC_SUBST([GNULIB_FREAD])
64 GNULIB_FREOPEN=0; AC_SUBST([GNULIB_FREOPEN]) 105 GNULIB_FREOPEN=0; AC_SUBST([GNULIB_FREOPEN])
106 GNULIB_FSCANF=0; AC_SUBST([GNULIB_FSCANF])
65 GNULIB_FSEEK=0; AC_SUBST([GNULIB_FSEEK]) 107 GNULIB_FSEEK=0; AC_SUBST([GNULIB_FSEEK])
66 GNULIB_FSEEKO=0; AC_SUBST([GNULIB_FSEEKO]) 108 GNULIB_FSEEKO=0; AC_SUBST([GNULIB_FSEEKO])
67 GNULIB_FTELL=0; AC_SUBST([GNULIB_FTELL]) 109 GNULIB_FTELL=0; AC_SUBST([GNULIB_FTELL])
68 GNULIB_FTELLO=0; AC_SUBST([GNULIB_FTELLO]) 110 GNULIB_FTELLO=0; AC_SUBST([GNULIB_FTELLO])
69 GNULIB_FWRITE=0; AC_SUBST([GNULIB_FWRITE]) 111 GNULIB_FWRITE=0; AC_SUBST([GNULIB_FWRITE])
112 GNULIB_GETC=0; AC_SUBST([GNULIB_GETC])
113 GNULIB_GETCHAR=0; AC_SUBST([GNULIB_GETCHAR])
70 GNULIB_GETDELIM=0; AC_SUBST([GNULIB_GETDELIM]) 114 GNULIB_GETDELIM=0; AC_SUBST([GNULIB_GETDELIM])
71 GNULIB_GETLINE=0; AC_SUBST([GNULIB_GETLINE]) 115 GNULIB_GETLINE=0; AC_SUBST([GNULIB_GETLINE])
72 GNULIB_OBSTACK_PRINTF=0; AC_SUBST([GNULIB_OBSTACK_PRINTF]) 116 GNULIB_OBSTACK_PRINTF=0; AC_SUBST([GNULIB_OBSTACK_PRINTF])
73 GNULIB_OBSTACK_PRINTF_POSIX=0; AC_SUBST([GNULIB_OBSTACK_PRINTF_POSIX]) 117 GNULIB_OBSTACK_PRINTF_POSIX=0; AC_SUBST([GNULIB_OBSTACK_PRINTF_POSIX])
118 GNULIB_PCLOSE=0; AC_SUBST([GNULIB_PCLOSE])
74 GNULIB_PERROR=0; AC_SUBST([GNULIB_PERROR]) 119 GNULIB_PERROR=0; AC_SUBST([GNULIB_PERROR])
75 GNULIB_POPEN=0; AC_SUBST([GNULIB_POPEN]) 120 GNULIB_POPEN=0; AC_SUBST([GNULIB_POPEN])
76 GNULIB_PRINTF=0; AC_SUBST([GNULIB_PRINTF]) 121 GNULIB_PRINTF=0; AC_SUBST([GNULIB_PRINTF])
@@ -81,11 +126,15 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS],
81 GNULIB_REMOVE=0; AC_SUBST([GNULIB_REMOVE]) 126 GNULIB_REMOVE=0; AC_SUBST([GNULIB_REMOVE])
82 GNULIB_RENAME=0; AC_SUBST([GNULIB_RENAME]) 127 GNULIB_RENAME=0; AC_SUBST([GNULIB_RENAME])
83 GNULIB_RENAMEAT=0; AC_SUBST([GNULIB_RENAMEAT]) 128 GNULIB_RENAMEAT=0; AC_SUBST([GNULIB_RENAMEAT])
129 GNULIB_SCANF=0; AC_SUBST([GNULIB_SCANF])
84 GNULIB_SNPRINTF=0; AC_SUBST([GNULIB_SNPRINTF]) 130 GNULIB_SNPRINTF=0; AC_SUBST([GNULIB_SNPRINTF])
85 GNULIB_SPRINTF_POSIX=0; AC_SUBST([GNULIB_SPRINTF_POSIX]) 131 GNULIB_SPRINTF_POSIX=0; AC_SUBST([GNULIB_SPRINTF_POSIX])
132 GNULIB_STDIO_H_NONBLOCKING=0; AC_SUBST([GNULIB_STDIO_H_NONBLOCKING])
86 GNULIB_STDIO_H_SIGPIPE=0; AC_SUBST([GNULIB_STDIO_H_SIGPIPE]) 133 GNULIB_STDIO_H_SIGPIPE=0; AC_SUBST([GNULIB_STDIO_H_SIGPIPE])
87 GNULIB_TMPFILE=0; AC_SUBST([GNULIB_TMPFILE]) 134 GNULIB_TMPFILE=0; AC_SUBST([GNULIB_TMPFILE])
88 GNULIB_VASPRINTF=0; AC_SUBST([GNULIB_VASPRINTF]) 135 GNULIB_VASPRINTF=0; AC_SUBST([GNULIB_VASPRINTF])
136 GNULIB_VFSCANF=0; AC_SUBST([GNULIB_VFSCANF])
137 GNULIB_VSCANF=0; AC_SUBST([GNULIB_VSCANF])
89 GNULIB_VDPRINTF=0; AC_SUBST([GNULIB_VDPRINTF]) 138 GNULIB_VDPRINTF=0; AC_SUBST([GNULIB_VDPRINTF])
90 GNULIB_VFPRINTF=0; AC_SUBST([GNULIB_VFPRINTF]) 139 GNULIB_VFPRINTF=0; AC_SUBST([GNULIB_VFPRINTF])
91 GNULIB_VFPRINTF_POSIX=0; AC_SUBST([GNULIB_VFPRINTF_POSIX]) 140 GNULIB_VFPRINTF_POSIX=0; AC_SUBST([GNULIB_VFPRINTF_POSIX])
@@ -95,6 +144,8 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS],
95 GNULIB_VSPRINTF_POSIX=0; AC_SUBST([GNULIB_VSPRINTF_POSIX]) 144 GNULIB_VSPRINTF_POSIX=0; AC_SUBST([GNULIB_VSPRINTF_POSIX])
96 dnl Assume proper GNU behavior unless another module says otherwise. 145 dnl Assume proper GNU behavior unless another module says otherwise.
97 HAVE_DECL_FPURGE=1; AC_SUBST([HAVE_DECL_FPURGE]) 146 HAVE_DECL_FPURGE=1; AC_SUBST([HAVE_DECL_FPURGE])
147 HAVE_DECL_FSEEKO=1; AC_SUBST([HAVE_DECL_FSEEKO])
148 HAVE_DECL_FTELLO=1; AC_SUBST([HAVE_DECL_FTELLO])
98 HAVE_DECL_GETDELIM=1; AC_SUBST([HAVE_DECL_GETDELIM]) 149 HAVE_DECL_GETDELIM=1; AC_SUBST([HAVE_DECL_GETDELIM])
99 HAVE_DECL_GETLINE=1; AC_SUBST([HAVE_DECL_GETLINE]) 150 HAVE_DECL_GETLINE=1; AC_SUBST([HAVE_DECL_GETLINE])
100 HAVE_DECL_OBSTACK_PRINTF=1; AC_SUBST([HAVE_DECL_OBSTACK_PRINTF]) 151 HAVE_DECL_OBSTACK_PRINTF=1; AC_SUBST([HAVE_DECL_OBSTACK_PRINTF])
@@ -103,11 +154,14 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS],
103 HAVE_DPRINTF=1; AC_SUBST([HAVE_DPRINTF]) 154 HAVE_DPRINTF=1; AC_SUBST([HAVE_DPRINTF])
104 HAVE_FSEEKO=1; AC_SUBST([HAVE_FSEEKO]) 155 HAVE_FSEEKO=1; AC_SUBST([HAVE_FSEEKO])
105 HAVE_FTELLO=1; AC_SUBST([HAVE_FTELLO]) 156 HAVE_FTELLO=1; AC_SUBST([HAVE_FTELLO])
157 HAVE_PCLOSE=1; AC_SUBST([HAVE_PCLOSE])
158 HAVE_POPEN=1; AC_SUBST([HAVE_POPEN])
106 HAVE_RENAMEAT=1; AC_SUBST([HAVE_RENAMEAT]) 159 HAVE_RENAMEAT=1; AC_SUBST([HAVE_RENAMEAT])
107 HAVE_VASPRINTF=1; AC_SUBST([HAVE_VASPRINTF]) 160 HAVE_VASPRINTF=1; AC_SUBST([HAVE_VASPRINTF])
108 HAVE_VDPRINTF=1; AC_SUBST([HAVE_VDPRINTF]) 161 HAVE_VDPRINTF=1; AC_SUBST([HAVE_VDPRINTF])
109 REPLACE_DPRINTF=0; AC_SUBST([REPLACE_DPRINTF]) 162 REPLACE_DPRINTF=0; AC_SUBST([REPLACE_DPRINTF])
110 REPLACE_FCLOSE=0; AC_SUBST([REPLACE_FCLOSE]) 163 REPLACE_FCLOSE=0; AC_SUBST([REPLACE_FCLOSE])
164 REPLACE_FDOPEN=0; AC_SUBST([REPLACE_FDOPEN])
111 REPLACE_FFLUSH=0; AC_SUBST([REPLACE_FFLUSH]) 165 REPLACE_FFLUSH=0; AC_SUBST([REPLACE_FFLUSH])
112 REPLACE_FOPEN=0; AC_SUBST([REPLACE_FOPEN]) 166 REPLACE_FOPEN=0; AC_SUBST([REPLACE_FOPEN])
113 REPLACE_FPRINTF=0; AC_SUBST([REPLACE_FPRINTF]) 167 REPLACE_FPRINTF=0; AC_SUBST([REPLACE_FPRINTF])
@@ -128,6 +182,7 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS],
128 REPLACE_RENAMEAT=0; AC_SUBST([REPLACE_RENAMEAT]) 182 REPLACE_RENAMEAT=0; AC_SUBST([REPLACE_RENAMEAT])
129 REPLACE_SNPRINTF=0; AC_SUBST([REPLACE_SNPRINTF]) 183 REPLACE_SNPRINTF=0; AC_SUBST([REPLACE_SNPRINTF])
130 REPLACE_SPRINTF=0; AC_SUBST([REPLACE_SPRINTF]) 184 REPLACE_SPRINTF=0; AC_SUBST([REPLACE_SPRINTF])
185 REPLACE_STDIO_READ_FUNCS=0; AC_SUBST([REPLACE_STDIO_READ_FUNCS])
131 REPLACE_STDIO_WRITE_FUNCS=0; AC_SUBST([REPLACE_STDIO_WRITE_FUNCS]) 186 REPLACE_STDIO_WRITE_FUNCS=0; AC_SUBST([REPLACE_STDIO_WRITE_FUNCS])
132 REPLACE_TMPFILE=0; AC_SUBST([REPLACE_TMPFILE]) 187 REPLACE_TMPFILE=0; AC_SUBST([REPLACE_TMPFILE])
133 REPLACE_VASPRINTF=0; AC_SUBST([REPLACE_VASPRINTF]) 188 REPLACE_VASPRINTF=0; AC_SUBST([REPLACE_VASPRINTF])
@@ -137,23 +192,3 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS],
137 REPLACE_VSNPRINTF=0; AC_SUBST([REPLACE_VSNPRINTF]) 192 REPLACE_VSNPRINTF=0; AC_SUBST([REPLACE_VSNPRINTF])
138 REPLACE_VSPRINTF=0; AC_SUBST([REPLACE_VSPRINTF]) 193 REPLACE_VSPRINTF=0; AC_SUBST([REPLACE_VSPRINTF])
139]) 194])
140
141dnl Code shared by fseeko and ftello. Determine if large files are supported,
142dnl but stdin does not start as a large file by default.
143AC_DEFUN([gl_STDIN_LARGE_OFFSET],
144 [
145 AC_CACHE_CHECK([whether stdin defaults to large file offsets],
146 [gl_cv_var_stdin_large_offset],
147 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]],
148[[#if defined __SL64 && defined __SCLE /* cygwin */
149 /* Cygwin 1.5.24 and earlier fail to put stdin in 64-bit mode, making
150 fseeko/ftello needlessly fail. This bug was fixed in 1.5.25, and
151 it is easier to do a version check than building a runtime test. */
152# include <cygwin/version.h>
153# if CYGWIN_VERSION_DLL_COMBINED < CYGWIN_VERSION_DLL_MAKE_COMBINED (1005, 25)
154 choke me
155# endif
156#endif]])],
157 [gl_cv_var_stdin_large_offset=yes],
158 [gl_cv_var_stdin_large_offset=no])])
159])
diff --git a/gl/m4/stdlib_h.m4 b/gl/m4/stdlib_h.m4
index fc15019..2027ab3 100644
--- a/gl/m4/stdlib_h.m4
+++ b/gl/m4/stdlib_h.m4
@@ -1,5 +1,5 @@
1# stdlib_h.m4 serial 30 1# stdlib_h.m4 serial 42
2dnl Copyright (C) 2007-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2007-2013 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,21 +7,7 @@ dnl with or without modifications, as long as this notice is preserved.
7AC_DEFUN([gl_STDLIB_H], 7AC_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_NEXT_HEADERS([stdlib.h])
11 AC_CHECK_HEADERS([random.h], [], [], [AC_INCLUDES_DEFAULT])
12 if test $ac_cv_header_random_h = yes; then
13 HAVE_RANDOM_H=1
14 else
15 HAVE_RANDOM_H=0
16 fi
17 AC_SUBST([HAVE_RANDOM_H])
18 AC_CHECK_TYPES([struct random_data],
19 [], [HAVE_STRUCT_RANDOM_DATA=0],
20 [[#include <stdlib.h>
21 #if HAVE_RANDOM_H
22 # include <random.h>
23 #endif
24 ]])
25 11
26 dnl Check for declarations of anything we want to poison if the 12 dnl Check for declarations of anything we want to poison if the
27 dnl corresponding gnulib module is not in use, and which is not 13 dnl corresponding gnulib module is not in use, and which is not
@@ -33,10 +19,11 @@ AC_DEFUN([gl_STDLIB_H],
33#if HAVE_RANDOM_H 19#if HAVE_RANDOM_H
34# include <random.h> 20# include <random.h>
35#endif 21#endif
36 ]], [_Exit atoll canonicalize_file_name getloadavg getsubopt grantpt mkdtemp 22 ]], [_Exit atoll canonicalize_file_name getloadavg getsubopt grantpt
37 mkostemp mkostemps mkstemp mkstemps ptsname random_r initstat_r srandom_r 23 initstate initstate_r mkdtemp mkostemp mkostemps mkstemp mkstemps
38 setstate_r realpath rpmatch setenv strtod strtoll strtoull unlockpt 24 posix_openpt ptsname ptsname_r random random_r realpath rpmatch
39 unsetenv]) 25 secure_getenv setenv setstate setstate_r srandom srandom_r
26 strtod strtoll strtoull unlockpt unsetenv])
40]) 27])
41 28
42AC_DEFUN([gl_STDLIB_MODULE_INDICATOR], 29AC_DEFUN([gl_STDLIB_MODULE_INDICATOR],
@@ -58,23 +45,30 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
58 GNULIB_GETSUBOPT=0; AC_SUBST([GNULIB_GETSUBOPT]) 45 GNULIB_GETSUBOPT=0; AC_SUBST([GNULIB_GETSUBOPT])
59 GNULIB_GRANTPT=0; AC_SUBST([GNULIB_GRANTPT]) 46 GNULIB_GRANTPT=0; AC_SUBST([GNULIB_GRANTPT])
60 GNULIB_MALLOC_POSIX=0; AC_SUBST([GNULIB_MALLOC_POSIX]) 47 GNULIB_MALLOC_POSIX=0; AC_SUBST([GNULIB_MALLOC_POSIX])
48 GNULIB_MBTOWC=0; AC_SUBST([GNULIB_MBTOWC])
61 GNULIB_MKDTEMP=0; AC_SUBST([GNULIB_MKDTEMP]) 49 GNULIB_MKDTEMP=0; AC_SUBST([GNULIB_MKDTEMP])
62 GNULIB_MKOSTEMP=0; AC_SUBST([GNULIB_MKOSTEMP]) 50 GNULIB_MKOSTEMP=0; AC_SUBST([GNULIB_MKOSTEMP])
63 GNULIB_MKOSTEMPS=0; AC_SUBST([GNULIB_MKOSTEMPS]) 51 GNULIB_MKOSTEMPS=0; AC_SUBST([GNULIB_MKOSTEMPS])
64 GNULIB_MKSTEMP=0; AC_SUBST([GNULIB_MKSTEMP]) 52 GNULIB_MKSTEMP=0; AC_SUBST([GNULIB_MKSTEMP])
65 GNULIB_MKSTEMPS=0; AC_SUBST([GNULIB_MKSTEMPS]) 53 GNULIB_MKSTEMPS=0; AC_SUBST([GNULIB_MKSTEMPS])
54 GNULIB_POSIX_OPENPT=0; AC_SUBST([GNULIB_POSIX_OPENPT])
66 GNULIB_PTSNAME=0; AC_SUBST([GNULIB_PTSNAME]) 55 GNULIB_PTSNAME=0; AC_SUBST([GNULIB_PTSNAME])
56 GNULIB_PTSNAME_R=0; AC_SUBST([GNULIB_PTSNAME_R])
67 GNULIB_PUTENV=0; AC_SUBST([GNULIB_PUTENV]) 57 GNULIB_PUTENV=0; AC_SUBST([GNULIB_PUTENV])
58 GNULIB_RANDOM=0; AC_SUBST([GNULIB_RANDOM])
68 GNULIB_RANDOM_R=0; AC_SUBST([GNULIB_RANDOM_R]) 59 GNULIB_RANDOM_R=0; AC_SUBST([GNULIB_RANDOM_R])
69 GNULIB_REALLOC_POSIX=0; AC_SUBST([GNULIB_REALLOC_POSIX]) 60 GNULIB_REALLOC_POSIX=0; AC_SUBST([GNULIB_REALLOC_POSIX])
70 GNULIB_REALPATH=0; AC_SUBST([GNULIB_REALPATH]) 61 GNULIB_REALPATH=0; AC_SUBST([GNULIB_REALPATH])
71 GNULIB_RPMATCH=0; AC_SUBST([GNULIB_RPMATCH]) 62 GNULIB_RPMATCH=0; AC_SUBST([GNULIB_RPMATCH])
63 GNULIB_SECURE_GETENV=0; AC_SUBST([GNULIB_SECURE_GETENV])
72 GNULIB_SETENV=0; AC_SUBST([GNULIB_SETENV]) 64 GNULIB_SETENV=0; AC_SUBST([GNULIB_SETENV])
73 GNULIB_STRTOD=0; AC_SUBST([GNULIB_STRTOD]) 65 GNULIB_STRTOD=0; AC_SUBST([GNULIB_STRTOD])
74 GNULIB_STRTOLL=0; AC_SUBST([GNULIB_STRTOLL]) 66 GNULIB_STRTOLL=0; AC_SUBST([GNULIB_STRTOLL])
75 GNULIB_STRTOULL=0; AC_SUBST([GNULIB_STRTOULL]) 67 GNULIB_STRTOULL=0; AC_SUBST([GNULIB_STRTOULL])
68 GNULIB_SYSTEM_POSIX=0; AC_SUBST([GNULIB_SYSTEM_POSIX])
76 GNULIB_UNLOCKPT=0; AC_SUBST([GNULIB_UNLOCKPT]) 69 GNULIB_UNLOCKPT=0; AC_SUBST([GNULIB_UNLOCKPT])
77 GNULIB_UNSETENV=0; AC_SUBST([GNULIB_UNSETENV]) 70 GNULIB_UNSETENV=0; AC_SUBST([GNULIB_UNSETENV])
71 GNULIB_WCTOMB=0; AC_SUBST([GNULIB_WCTOMB])
78 dnl Assume proper GNU behavior unless another module says otherwise. 72 dnl Assume proper GNU behavior unless another module says otherwise.
79 HAVE__EXIT=1; AC_SUBST([HAVE__EXIT]) 73 HAVE__EXIT=1; AC_SUBST([HAVE__EXIT])
80 HAVE_ATOLL=1; AC_SUBST([HAVE_ATOLL]) 74 HAVE_ATOLL=1; AC_SUBST([HAVE_ATOLL])
@@ -87,26 +81,37 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
87 HAVE_MKOSTEMPS=1; AC_SUBST([HAVE_MKOSTEMPS]) 81 HAVE_MKOSTEMPS=1; AC_SUBST([HAVE_MKOSTEMPS])
88 HAVE_MKSTEMP=1; AC_SUBST([HAVE_MKSTEMP]) 82 HAVE_MKSTEMP=1; AC_SUBST([HAVE_MKSTEMP])
89 HAVE_MKSTEMPS=1; AC_SUBST([HAVE_MKSTEMPS]) 83 HAVE_MKSTEMPS=1; AC_SUBST([HAVE_MKSTEMPS])
84 HAVE_POSIX_OPENPT=1; AC_SUBST([HAVE_POSIX_OPENPT])
90 HAVE_PTSNAME=1; AC_SUBST([HAVE_PTSNAME]) 85 HAVE_PTSNAME=1; AC_SUBST([HAVE_PTSNAME])
86 HAVE_PTSNAME_R=1; AC_SUBST([HAVE_PTSNAME_R])
87 HAVE_RANDOM=1; AC_SUBST([HAVE_RANDOM])
88 HAVE_RANDOM_H=1; AC_SUBST([HAVE_RANDOM_H])
91 HAVE_RANDOM_R=1; AC_SUBST([HAVE_RANDOM_R]) 89 HAVE_RANDOM_R=1; AC_SUBST([HAVE_RANDOM_R])
92 HAVE_REALPATH=1; AC_SUBST([HAVE_REALPATH]) 90 HAVE_REALPATH=1; AC_SUBST([HAVE_REALPATH])
93 HAVE_RPMATCH=1; AC_SUBST([HAVE_RPMATCH]) 91 HAVE_RPMATCH=1; AC_SUBST([HAVE_RPMATCH])
92 HAVE_SECURE_GETENV=1; AC_SUBST([HAVE_SECURE_GETENV])
94 HAVE_SETENV=1; AC_SUBST([HAVE_SETENV]) 93 HAVE_SETENV=1; AC_SUBST([HAVE_SETENV])
94 HAVE_DECL_SETENV=1; AC_SUBST([HAVE_DECL_SETENV])
95 HAVE_STRTOD=1; AC_SUBST([HAVE_STRTOD]) 95 HAVE_STRTOD=1; AC_SUBST([HAVE_STRTOD])
96 HAVE_STRTOLL=1; AC_SUBST([HAVE_STRTOLL]) 96 HAVE_STRTOLL=1; AC_SUBST([HAVE_STRTOLL])
97 HAVE_STRTOULL=1; AC_SUBST([HAVE_STRTOULL]) 97 HAVE_STRTOULL=1; AC_SUBST([HAVE_STRTOULL])
98 HAVE_STRUCT_RANDOM_DATA=1; AC_SUBST([HAVE_STRUCT_RANDOM_DATA]) 98 HAVE_STRUCT_RANDOM_DATA=1; AC_SUBST([HAVE_STRUCT_RANDOM_DATA])
99 HAVE_SYS_LOADAVG_H=0; AC_SUBST([HAVE_SYS_LOADAVG_H]) 99 HAVE_SYS_LOADAVG_H=0; AC_SUBST([HAVE_SYS_LOADAVG_H])
100 HAVE_UNLOCKPT=1; AC_SUBST([HAVE_UNLOCKPT]) 100 HAVE_UNLOCKPT=1; AC_SUBST([HAVE_UNLOCKPT])
101 HAVE_UNSETENV=1; AC_SUBST([HAVE_UNSETENV]) 101 HAVE_DECL_UNSETENV=1; AC_SUBST([HAVE_DECL_UNSETENV])
102 REPLACE_CALLOC=0; AC_SUBST([REPLACE_CALLOC]) 102 REPLACE_CALLOC=0; AC_SUBST([REPLACE_CALLOC])
103 REPLACE_CANONICALIZE_FILE_NAME=0; AC_SUBST([REPLACE_CANONICALIZE_FILE_NAME]) 103 REPLACE_CANONICALIZE_FILE_NAME=0; AC_SUBST([REPLACE_CANONICALIZE_FILE_NAME])
104 REPLACE_MALLOC=0; AC_SUBST([REPLACE_MALLOC]) 104 REPLACE_MALLOC=0; AC_SUBST([REPLACE_MALLOC])
105 REPLACE_MBTOWC=0; AC_SUBST([REPLACE_MBTOWC])
105 REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP]) 106 REPLACE_MKSTEMP=0; AC_SUBST([REPLACE_MKSTEMP])
107 REPLACE_PTSNAME=0; AC_SUBST([REPLACE_PTSNAME])
108 REPLACE_PTSNAME_R=0; AC_SUBST([REPLACE_PTSNAME_R])
106 REPLACE_PUTENV=0; AC_SUBST([REPLACE_PUTENV]) 109 REPLACE_PUTENV=0; AC_SUBST([REPLACE_PUTENV])
110 REPLACE_RANDOM_R=0; AC_SUBST([REPLACE_RANDOM_R])
107 REPLACE_REALLOC=0; AC_SUBST([REPLACE_REALLOC]) 111 REPLACE_REALLOC=0; AC_SUBST([REPLACE_REALLOC])
108 REPLACE_REALPATH=0; AC_SUBST([REPLACE_REALPATH]) 112 REPLACE_REALPATH=0; AC_SUBST([REPLACE_REALPATH])
109 REPLACE_SETENV=0; AC_SUBST([REPLACE_SETENV]) 113 REPLACE_SETENV=0; AC_SUBST([REPLACE_SETENV])
110 REPLACE_STRTOD=0; AC_SUBST([REPLACE_STRTOD]) 114 REPLACE_STRTOD=0; AC_SUBST([REPLACE_STRTOD])
111 REPLACE_UNSETENV=0; AC_SUBST([REPLACE_UNSETENV]) 115 REPLACE_UNSETENV=0; AC_SUBST([REPLACE_UNSETENV])
116 REPLACE_WCTOMB=0; AC_SUBST([REPLACE_WCTOMB])
112]) 117])
diff --git a/gl/m4/strdup.m4 b/gl/m4/strdup.m4
deleted file mode 100644
index ce40c21..0000000
--- a/gl/m4/strdup.m4
+++ /dev/null
@@ -1,45 +0,0 @@
1# strdup.m4 serial 12
2
3dnl Copyright (C) 2002-2010 Free Software Foundation, Inc.
4
5dnl This file is free software; the Free Software Foundation
6dnl gives unlimited permission to copy and/or distribute it,
7dnl with or without modifications, as long as this notice is preserved.
8
9AC_DEFUN([gl_FUNC_STRDUP],
10[
11 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
12 AC_CHECK_FUNCS_ONCE([strdup])
13 if test $ac_cv_func_strdup != yes; then
14 AC_LIBOBJ([strdup])
15 gl_PREREQ_STRDUP
16 fi
17 AC_CHECK_DECLS_ONCE([strdup])
18 if test $ac_cv_have_decl_strdup = no; then
19 HAVE_DECL_STRDUP=0
20 fi
21])
22
23AC_DEFUN([gl_FUNC_STRDUP_POSIX],
24[
25 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
26 AC_REQUIRE([gl_CHECK_MALLOC_POSIX])
27 AC_CHECK_FUNCS_ONCE([strdup])
28 if test $ac_cv_func_strdup = yes; then
29 if test $gl_cv_func_malloc_posix != yes; then
30 REPLACE_STRDUP=1
31 AC_LIBOBJ([strdup])
32 gl_PREREQ_STRDUP
33 fi
34 else
35 AC_LIBOBJ([strdup])
36 gl_PREREQ_STRDUP
37 fi
38 AC_CHECK_DECLS_ONCE([strdup])
39 if test $ac_cv_have_decl_strdup = no; then
40 HAVE_DECL_STRDUP=0
41 fi
42])
43
44# Prerequisites of lib/strdup.c.
45AC_DEFUN([gl_PREREQ_STRDUP], [:])
diff --git a/gl/m4/strerror.m4 b/gl/m4/strerror.m4
index 1649b24..3989844 100644
--- a/gl/m4/strerror.m4
+++ b/gl/m4/strerror.m4
@@ -1,68 +1,96 @@
1# strerror.m4 serial 9 1# strerror.m4 serial 17
2dnl Copyright (C) 2002, 2007-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2002, 2007-2013 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_STRERROR], 7AC_DEFUN([gl_FUNC_STRERROR],
8[ 8[
9 AC_REQUIRE([gl_FUNC_STRERROR_SEPARATE])
10 if test $REPLACE_STRERROR = 1; then
11 AC_LIBOBJ([strerror])
12 AC_DEFINE_UNQUOTED([REPLACE_STRERROR], [$REPLACE_STRERROR],
13 [Define this to 1 if strerror is broken.])
14 fi
15])
16
17# Like gl_FUNC_STRERROR, except prepare for separate compilation (no AC_LIBOBJ).
18AC_DEFUN([gl_FUNC_STRERROR_SEPARATE],
19[
20 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) 9 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
21 AC_REQUIRE([gl_HEADER_ERRNO_H]) 10 AC_REQUIRE([gl_HEADER_ERRNO_H])
22 if test -z "$ERRNO_H"; then 11 AC_REQUIRE([gl_FUNC_STRERROR_0])
12 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
13 m4_ifdef([gl_FUNC_STRERROR_R_WORKS], [
14 AC_REQUIRE([gl_FUNC_STRERROR_R_WORKS])
15 ])
16 if test "$ERRNO_H:$REPLACE_STRERROR_0" = :0; then
23 AC_CACHE_CHECK([for working strerror function], 17 AC_CACHE_CHECK([for working strerror function],
24 [gl_cv_func_working_strerror], 18 [gl_cv_func_working_strerror],
25 [AC_RUN_IFELSE( 19 [AC_RUN_IFELSE(
26 [AC_LANG_PROGRAM( 20 [AC_LANG_PROGRAM(
27 [[#include <string.h> 21 [[#include <string.h>
28 ]], 22 ]],
29 [[return !*strerror (-2);]])], 23 [[if (!*strerror (-2)) return 1;]])],
30 [gl_cv_func_working_strerror=yes], 24 [gl_cv_func_working_strerror=yes],
31 [gl_cv_func_working_strerror=no], 25 [gl_cv_func_working_strerror=no],
32 [dnl Assume crossbuild works if it compiles. 26 [case "$host_os" in
33 AC_COMPILE_IFELSE( 27 # Guess yes on glibc systems.
34 [AC_LANG_PROGRAM( 28 *-gnu*) gl_cv_func_working_strerror="guessing yes" ;;
35 [[#include <string.h> 29 # If we don't know, assume the worst.
36 ]], 30 *) gl_cv_func_working_strerror="guessing no" ;;
37 [[return !*strerror (-2);]])], 31 esac
38 [gl_cv_func_working_strerror=yes], 32 ])
39 [gl_cv_func_working_strerror=no]) 33 ])
40 ]) 34 case "$gl_cv_func_working_strerror" in
35 *yes) ;;
36 *)
37 dnl The system's strerror() fails to return a string for out-of-range
38 dnl integers. Replace it.
39 REPLACE_STRERROR=1
40 ;;
41 esac
42 m4_ifdef([gl_FUNC_STRERROR_R_WORKS], [
43 dnl If the system's strerror_r or __xpg_strerror_r clobbers strerror's
44 dnl buffer, we must replace strerror.
45 case "$gl_cv_func_strerror_r_works" in
46 *no) REPLACE_STRERROR=1 ;;
47 esac
41 ]) 48 ])
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 49 else
48 dnl The system's strerror() cannot know about the new errno values we add 50 dnl The system's strerror() cannot know about the new errno values we add
49 dnl to <errno.h>. Replace it. 51 dnl to <errno.h>, or any fix for strerror(0). Replace it.
50 REPLACE_STRERROR=1 52 REPLACE_STRERROR=1
51 fi 53 fi
52 if test $REPLACE_STRERROR = 1; then
53 gl_PREREQ_STRERROR
54 fi
55]) 54])
56 55
57# Prerequisites of lib/strerror.c. 56dnl Detect if strerror(0) passes (that is, does not set errno, and does not
58AC_DEFUN([gl_PREREQ_STRERROR], [ 57dnl return a string that matches strerror(-1)).
59 AC_CHECK_DECLS([strerror]) 58AC_DEFUN([gl_FUNC_STRERROR_0],
60 AC_CHECK_HEADERS_ONCE([sys/socket.h]) 59[
61 if test $ac_cv_header_sys_socket_h != yes; then 60 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
62 dnl We cannot use AC_CHECK_HEADERS_ONCE here, because that would make 61 REPLACE_STRERROR_0=0
63 dnl the check for those headers unconditional; yet cygwin reports 62 AC_CACHE_CHECK([whether strerror(0) succeeds],
64 dnl that the headers are present but cannot be compiled (since on 63 [gl_cv_func_strerror_0_works],
65 dnl cygwin, all socket information should come from sys/socket.h). 64 [AC_RUN_IFELSE(
66 AC_CHECK_HEADERS([winsock2.h]) 65 [AC_LANG_PROGRAM(
67 fi 66 [[#include <string.h>
67 #include <errno.h>
68 ]],
69 [[int result = 0;
70 char *str;
71 errno = 0;
72 str = strerror (0);
73 if (!*str) result |= 1;
74 if (errno) result |= 2;
75 if (strstr (str, "nknown") || strstr (str, "ndefined"))
76 result |= 4;
77 return result;]])],
78 [gl_cv_func_strerror_0_works=yes],
79 [gl_cv_func_strerror_0_works=no],
80 [case "$host_os" in
81 # Guess yes on glibc systems.
82 *-gnu*) gl_cv_func_strerror_0_works="guessing yes" ;;
83 # If we don't know, assume the worst.
84 *) gl_cv_func_strerror_0_works="guessing no" ;;
85 esac
86 ])
87 ])
88 case "$gl_cv_func_strerror_0_works" in
89 *yes) ;;
90 *)
91 REPLACE_STRERROR_0=1
92 AC_DEFINE([REPLACE_STRERROR_0], [1], [Define to 1 if strerror(0)
93 does not return a message implying success.])
94 ;;
95 esac
68]) 96])
diff --git a/gl/m4/string_h.m4 b/gl/m4/string_h.m4
index 1977aec..cc5fbbb 100644
--- a/gl/m4/string_h.m4
+++ b/gl/m4/string_h.m4
@@ -1,11 +1,11 @@
1# Configure a GNU-like replacement for <string.h>. 1# Configure a GNU-like replacement for <string.h>.
2 2
3# Copyright (C) 2007-2010 Free Software Foundation, Inc. 3# Copyright (C) 2007-2013 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.
7 7
8# serial 17 8# serial 21
9 9
10# Written by Paul Eggert. 10# Written by Paul Eggert.
11 11
@@ -20,16 +20,16 @@ AC_DEFUN([gl_HEADER_STRING_H_BODY],
20[ 20[
21 AC_REQUIRE([AC_C_RESTRICT]) 21 AC_REQUIRE([AC_C_RESTRICT])
22 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) 22 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
23 gl_CHECK_NEXT_HEADERS([string.h]) 23 gl_NEXT_HEADERS([string.h])
24 24
25 dnl Check for declarations of anything we want to poison if the 25 dnl Check for declarations of anything we want to poison if the
26 dnl corresponding gnulib module is not in use, and which is not 26 dnl corresponding gnulib module is not in use, and which is not
27 dnl guaranteed by C89. 27 dnl guaranteed by C89.
28 gl_WARN_ON_USE_PREPARE([[#include <string.h> 28 gl_WARN_ON_USE_PREPARE([[#include <string.h>
29 ]], 29 ]],
30 [memmem mempcpy memrchr rawmemchr stpcpy stpncpy strchrnul strdup 30 [ffsl ffsll memmem mempcpy memrchr rawmemchr stpcpy stpncpy strchrnul
31 strncat strndup strnlen strpbrk strsep strcasestr strtok_r strsignal 31 strdup strncat strndup strnlen strpbrk strsep strcasestr strtok_r
32 strverscmp]) 32 strerror_r strsignal strverscmp])
33]) 33])
34 34
35AC_DEFUN([gl_STRING_MODULE_INDICATOR], 35AC_DEFUN([gl_STRING_MODULE_INDICATOR],
@@ -43,6 +43,8 @@ AC_DEFUN([gl_STRING_MODULE_INDICATOR],
43 43
44AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS], 44AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
45[ 45[
46 GNULIB_FFSL=0; AC_SUBST([GNULIB_FFSL])
47 GNULIB_FFSLL=0; AC_SUBST([GNULIB_FFSLL])
46 GNULIB_MEMCHR=0; AC_SUBST([GNULIB_MEMCHR]) 48 GNULIB_MEMCHR=0; AC_SUBST([GNULIB_MEMCHR])
47 GNULIB_MEMMEM=0; AC_SUBST([GNULIB_MEMMEM]) 49 GNULIB_MEMMEM=0; AC_SUBST([GNULIB_MEMMEM])
48 GNULIB_MEMPCPY=0; AC_SUBST([GNULIB_MEMPCPY]) 50 GNULIB_MEMPCPY=0; AC_SUBST([GNULIB_MEMPCPY])
@@ -75,10 +77,13 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
75 GNULIB_MBSSEP=0; AC_SUBST([GNULIB_MBSSEP]) 77 GNULIB_MBSSEP=0; AC_SUBST([GNULIB_MBSSEP])
76 GNULIB_MBSTOK_R=0; AC_SUBST([GNULIB_MBSTOK_R]) 78 GNULIB_MBSTOK_R=0; AC_SUBST([GNULIB_MBSTOK_R])
77 GNULIB_STRERROR=0; AC_SUBST([GNULIB_STRERROR]) 79 GNULIB_STRERROR=0; AC_SUBST([GNULIB_STRERROR])
80 GNULIB_STRERROR_R=0; AC_SUBST([GNULIB_STRERROR_R])
78 GNULIB_STRSIGNAL=0; AC_SUBST([GNULIB_STRSIGNAL]) 81 GNULIB_STRSIGNAL=0; AC_SUBST([GNULIB_STRSIGNAL])
79 GNULIB_STRVERSCMP=0; AC_SUBST([GNULIB_STRVERSCMP]) 82 GNULIB_STRVERSCMP=0; AC_SUBST([GNULIB_STRVERSCMP])
80 HAVE_MBSLEN=0; AC_SUBST([HAVE_MBSLEN]) 83 HAVE_MBSLEN=0; AC_SUBST([HAVE_MBSLEN])
81 dnl Assume proper GNU behavior unless another module says otherwise. 84 dnl Assume proper GNU behavior unless another module says otherwise.
85 HAVE_FFSL=1; AC_SUBST([HAVE_FFSL])
86 HAVE_FFSLL=1; AC_SUBST([HAVE_FFSLL])
82 HAVE_MEMCHR=1; AC_SUBST([HAVE_MEMCHR]) 87 HAVE_MEMCHR=1; AC_SUBST([HAVE_MEMCHR])
83 HAVE_DECL_MEMMEM=1; AC_SUBST([HAVE_DECL_MEMMEM]) 88 HAVE_DECL_MEMMEM=1; AC_SUBST([HAVE_DECL_MEMMEM])
84 HAVE_MEMPCPY=1; AC_SUBST([HAVE_MEMPCPY]) 89 HAVE_MEMPCPY=1; AC_SUBST([HAVE_MEMPCPY])
@@ -94,6 +99,7 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
94 HAVE_STRSEP=1; AC_SUBST([HAVE_STRSEP]) 99 HAVE_STRSEP=1; AC_SUBST([HAVE_STRSEP])
95 HAVE_STRCASESTR=1; AC_SUBST([HAVE_STRCASESTR]) 100 HAVE_STRCASESTR=1; AC_SUBST([HAVE_STRCASESTR])
96 HAVE_DECL_STRTOK_R=1; AC_SUBST([HAVE_DECL_STRTOK_R]) 101 HAVE_DECL_STRTOK_R=1; AC_SUBST([HAVE_DECL_STRTOK_R])
102 HAVE_DECL_STRERROR_R=1; AC_SUBST([HAVE_DECL_STRERROR_R])
97 HAVE_DECL_STRSIGNAL=1; AC_SUBST([HAVE_DECL_STRSIGNAL]) 103 HAVE_DECL_STRSIGNAL=1; AC_SUBST([HAVE_DECL_STRSIGNAL])
98 HAVE_STRVERSCMP=1; AC_SUBST([HAVE_STRVERSCMP]) 104 HAVE_STRVERSCMP=1; AC_SUBST([HAVE_STRVERSCMP])
99 REPLACE_MEMCHR=0; AC_SUBST([REPLACE_MEMCHR]) 105 REPLACE_MEMCHR=0; AC_SUBST([REPLACE_MEMCHR])
@@ -102,7 +108,9 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
102 REPLACE_STRDUP=0; AC_SUBST([REPLACE_STRDUP]) 108 REPLACE_STRDUP=0; AC_SUBST([REPLACE_STRDUP])
103 REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR]) 109 REPLACE_STRSTR=0; AC_SUBST([REPLACE_STRSTR])
104 REPLACE_STRCASESTR=0; AC_SUBST([REPLACE_STRCASESTR]) 110 REPLACE_STRCASESTR=0; AC_SUBST([REPLACE_STRCASESTR])
111 REPLACE_STRCHRNUL=0; AC_SUBST([REPLACE_STRCHRNUL])
105 REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR]) 112 REPLACE_STRERROR=0; AC_SUBST([REPLACE_STRERROR])
113 REPLACE_STRERROR_R=0; AC_SUBST([REPLACE_STRERROR_R])
106 REPLACE_STRNCAT=0; AC_SUBST([REPLACE_STRNCAT]) 114 REPLACE_STRNCAT=0; AC_SUBST([REPLACE_STRNCAT])
107 REPLACE_STRNDUP=0; AC_SUBST([REPLACE_STRNDUP]) 115 REPLACE_STRNDUP=0; AC_SUBST([REPLACE_STRNDUP])
108 REPLACE_STRNLEN=0; AC_SUBST([REPLACE_STRNLEN]) 116 REPLACE_STRNLEN=0; AC_SUBST([REPLACE_STRNLEN])
diff --git a/gl/m4/strndup.m4 b/gl/m4/strndup.m4
index 810313c..a1f8274 100644
--- a/gl/m4/strndup.m4
+++ b/gl/m4/strndup.m4
@@ -1,5 +1,5 @@
1# strndup.m4 serial 17 1# strndup.m4 serial 21
2dnl Copyright (C) 2002-2003, 2005-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2003, 2005-2013 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.
@@ -18,13 +18,18 @@ AC_DEFUN([gl_FUNC_STRNDUP],
18 fi 18 fi
19 19
20 if test $ac_cv_func_strndup = yes; then 20 if test $ac_cv_func_strndup = yes; then
21 HAVE_STRNDUP=1
21 # AIX 4.3.3, AIX 5.1 have a function that fails to add the terminating '\0'. 22 # AIX 4.3.3, AIX 5.1 have a function that fails to add the terminating '\0'.
22 AC_CACHE_CHECK([for working strndup], [gl_cv_func_strndup_works], 23 AC_CACHE_CHECK([for working strndup], [gl_cv_func_strndup_works],
23 [AC_RUN_IFELSE([ 24 [AC_RUN_IFELSE([
24 AC_LANG_PROGRAM([[#include <string.h> 25 AC_LANG_PROGRAM([[#include <string.h>
25 #include <stdlib.h>]], [[ 26 #include <stdlib.h>]], [[
26#ifndef HAVE_DECL_STRNDUP 27#if !HAVE_DECL_STRNDUP
27 extern char *strndup (const char *, size_t); 28 extern
29 #ifdef __cplusplus
30 "C"
31 #endif
32 char *strndup (const char *, size_t);
28#endif 33#endif
29 char *s; 34 char *s;
30 s = strndup ("some longer string", 15); 35 s = strndup ("some longer string", 15);
@@ -33,17 +38,18 @@ AC_DEFUN([gl_FUNC_STRNDUP],
33 return s[13] != '\0';]])], 38 return s[13] != '\0';]])],
34 [gl_cv_func_strndup_works=yes], 39 [gl_cv_func_strndup_works=yes],
35 [gl_cv_func_strndup_works=no], 40 [gl_cv_func_strndup_works=no],
36 [case $host_os in 41 [
37 aix*) gl_cv_func_strndup_works="guessing no";; 42changequote(,)dnl
38 *) gl_cv_func_strndup_works="guessing yes";; 43 case $host_os in
39 esac])]) 44 aix | aix[3-6]*) gl_cv_func_strndup_works="guessing no";;
45 *) gl_cv_func_strndup_works="guessing yes";;
46 esac
47changequote([,])dnl
48 ])])
40 case $gl_cv_func_strndup_works in 49 case $gl_cv_func_strndup_works in
41 *no) 50 *no) REPLACE_STRNDUP=1 ;;
42 REPLACE_STRNDUP=1
43 AC_LIBOBJ([strndup])
44 ;;
45 esac 51 esac
46 else 52 else
47 AC_LIBOBJ([strndup]) 53 HAVE_STRNDUP=0
48 fi 54 fi
49]) 55])
diff --git a/gl/m4/strnlen.m4 b/gl/m4/strnlen.m4
index 52bb838..eae82b7 100644
--- a/gl/m4/strnlen.m4
+++ b/gl/m4/strnlen.m4
@@ -1,5 +1,5 @@
1# strnlen.m4 serial 12 1# strnlen.m4 serial 13
2dnl Copyright (C) 2002-2003, 2005-2007, 2009-2010 Free Software Foundation, 2dnl Copyright (C) 2002-2003, 2005-2007, 2009-2013 Free Software Foundation,
3dnl Inc. 3dnl Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
@@ -16,16 +16,14 @@ AC_DEFUN([gl_FUNC_STRNLEN],
16 if test $ac_cv_have_decl_strnlen = no; then 16 if test $ac_cv_have_decl_strnlen = no; then
17 HAVE_DECL_STRNLEN=0 17 HAVE_DECL_STRNLEN=0
18 else 18 else
19 AC_FUNC_STRNLEN 19 m4_pushdef([AC_LIBOBJ], [:])
20 dnl Note: AC_FUNC_STRNLEN does AC_LIBOBJ([strnlen]). 20 dnl Note: AC_FUNC_STRNLEN does AC_LIBOBJ([strnlen]).
21 AC_FUNC_STRNLEN
22 m4_popdef([AC_LIBOBJ])
21 if test $ac_cv_func_strnlen_working = no; then 23 if test $ac_cv_func_strnlen_working = no; then
22 REPLACE_STRNLEN=1 24 REPLACE_STRNLEN=1
23 fi 25 fi
24 fi 26 fi
25 if test $HAVE_DECL_STRNLEN = 0 || test $REPLACE_STRNLEN = 1; then
26 AC_LIBOBJ([strnlen])
27 gl_PREREQ_STRNLEN
28 fi
29]) 27])
30 28
31# Prerequisites of lib/strnlen.c. 29# Prerequisites of lib/strnlen.c.
diff --git a/gl/m4/strsep.m4 b/gl/m4/strsep.m4
index fb4d396..825fdb8 100644
--- a/gl/m4/strsep.m4
+++ b/gl/m4/strsep.m4
@@ -1,6 +1,5 @@
1# strsep.m4 serial 9 1# strsep.m4 serial 10
2dnl Copyright (C) 2002, 2003, 2004, 2007, 2009, 2010 Free Software Foundation, 2dnl Copyright (C) 2002-2004, 2007, 2009-2013 Free Software Foundation, Inc.
3dnl Inc.
4dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
@@ -14,10 +13,9 @@ AC_DEFUN([gl_FUNC_STRSEP],
14 AC_REQUIRE([AC_C_RESTRICT]) 13 AC_REQUIRE([AC_C_RESTRICT])
15 14
16 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) 15 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
17 AC_REPLACE_FUNCS([strsep]) 16 AC_CHECK_FUNCS([strsep])
18 if test $ac_cv_func_strsep = no; then 17 if test $ac_cv_func_strsep = no; then
19 HAVE_STRSEP=0 18 HAVE_STRSEP=0
20 gl_PREREQ_STRSEP
21 fi 19 fi
22]) 20])
23 21
diff --git a/gl/m4/strstr.m4 b/gl/m4/strstr.m4
index 779957a..c486bdb 100644
--- a/gl/m4/strstr.m4
+++ b/gl/m4/strstr.m4
@@ -1,5 +1,5 @@
1# strstr.m4 serial 7 1# strstr.m4 serial 16
2dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2008-2013 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,7 +11,51 @@ AC_DEFUN([gl_FUNC_STRSTR_SIMPLE],
11 AC_REQUIRE([gl_FUNC_MEMCHR]) 11 AC_REQUIRE([gl_FUNC_MEMCHR])
12 if test "$gl_cv_func_memchr_works" != yes; then 12 if test "$gl_cv_func_memchr_works" != yes; then
13 REPLACE_STRSTR=1 13 REPLACE_STRSTR=1
14 AC_LIBOBJ([strstr]) 14 else
15 dnl Detect http://sourceware.org/bugzilla/show_bug.cgi?id=12092.
16 AC_CACHE_CHECK([whether strstr works],
17 [gl_cv_func_strstr_works_always],
18 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
19#include <string.h> /* for strstr */
20#define P "_EF_BF_BD"
21#define HAYSTACK "F_BD_CE_BD" P P P P "_C3_88_20" P P P "_C3_A7_20" P
22#define NEEDLE P P P P P
23]], [[return !!strstr (HAYSTACK, NEEDLE);
24 ]])],
25 [gl_cv_func_strstr_works_always=yes],
26 [gl_cv_func_strstr_works_always=no],
27 [dnl glibc 2.12 and cygwin 1.7.7 have a known bug. uClibc is not
28 dnl affected, since it uses different source code for strstr than
29 dnl glibc.
30 dnl Assume that it works on all other platforms, even if it is not
31 dnl linear.
32 AC_EGREP_CPP([Lucky user],
33 [
34#ifdef __GNU_LIBRARY__
35 #include <features.h>
36 #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ > 12) || (__GLIBC__ > 2)) \
37 || defined __UCLIBC__
38 Lucky user
39 #endif
40#elif defined __CYGWIN__
41 #include <cygwin/version.h>
42 #if CYGWIN_VERSION_DLL_COMBINED > CYGWIN_VERSION_DLL_MAKE_COMBINED (1007, 7)
43 Lucky user
44 #endif
45#else
46 Lucky user
47#endif
48 ],
49 [gl_cv_func_strstr_works_always="guessing yes"],
50 [gl_cv_func_strstr_works_always="guessing no"])
51 ])
52 ])
53 case "$gl_cv_func_strstr_works_always" in
54 *yes) ;;
55 *)
56 REPLACE_STRSTR=1
57 ;;
58 esac
15 fi 59 fi
16]) # gl_FUNC_STRSTR_SIMPLE 60]) # gl_FUNC_STRSTR_SIMPLE
17 61
@@ -24,16 +68,18 @@ AC_DEFUN([gl_FUNC_STRSTR],
24 [gl_cv_func_strstr_linear], 68 [gl_cv_func_strstr_linear],
25 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[ 69 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
26#include <signal.h> /* for signal */ 70#include <signal.h> /* for signal */
27#include <string.h> /* for memmem */ 71#include <string.h> /* for strstr */
28#include <stdlib.h> /* for malloc */ 72#include <stdlib.h> /* for malloc */
29#include <unistd.h> /* for alarm */ 73#include <unistd.h> /* for alarm */
30]], [[size_t m = 1000000; 74static void quit (int sig) { exit (sig + 128); }
75]], [[
76 int result = 0;
77 size_t m = 1000000;
31 char *haystack = (char *) malloc (2 * m + 2); 78 char *haystack = (char *) malloc (2 * m + 2);
32 char *needle = (char *) malloc (m + 2); 79 char *needle = (char *) malloc (m + 2);
33 void *result = 0;
34 /* Failure to compile this test due to missing alarm is okay, 80 /* Failure to compile this test due to missing alarm is okay,
35 since all such platforms (mingw) also have quadratic strstr. */ 81 since all such platforms (mingw) also have quadratic strstr. */
36 signal (SIGALRM, SIG_DFL); 82 signal (SIGALRM, quit);
37 alarm (5); 83 alarm (5);
38 /* Check for quadratic performance. */ 84 /* Check for quadratic performance. */
39 if (haystack && needle) 85 if (haystack && needle)
@@ -44,36 +90,41 @@ AC_DEFUN([gl_FUNC_STRSTR],
44 memset (needle, 'A', m); 90 memset (needle, 'A', m);
45 needle[m] = 'B'; 91 needle[m] = 'B';
46 needle[m + 1] = 0; 92 needle[m + 1] = 0;
47 result = strstr (haystack, needle); 93 if (!strstr (haystack, needle))
94 result |= 1;
48 } 95 }
49 return !result;]])], 96 return result;
97 ]])],
50 [gl_cv_func_strstr_linear=yes], [gl_cv_func_strstr_linear=no], 98 [gl_cv_func_strstr_linear=yes], [gl_cv_func_strstr_linear=no],
51 [dnl Only glibc >= 2.9 and cygwin >= 1.7.0 are known to have a 99 [dnl Only glibc > 2.12 on processors without SSE 4.2 instructions and
52 dnl strstr that works in linear time. 100 dnl cygwin > 1.7.7 are known to have a bug-free strstr that works in
101 dnl linear time.
53 AC_EGREP_CPP([Lucky user], 102 AC_EGREP_CPP([Lucky user],
54 [ 103 [
55#include <features.h> 104#include <features.h>
56#ifdef __GNU_LIBRARY__ 105#ifdef __GNU_LIBRARY__
57 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 9) || (__GLIBC__ > 2) 106 #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ > 12) || (__GLIBC__ > 2)) \
107 && !(defined __i386__ || defined __x86_64__) \
108 && !defined __UCLIBC__
58 Lucky user 109 Lucky user
59 #endif 110 #endif
60#endif 111#endif
61#ifdef __CYGWIN__ 112#ifdef __CYGWIN__
62 #include <cygwin/version.h> 113 #include <cygwin/version.h>
63 #if CYGWIN_VERSION_DLL_MAJOR >= 1007 114 #if CYGWIN_VERSION_DLL_COMBINED > CYGWIN_VERSION_DLL_MAKE_COMBINED (1007, 7)
64 Lucky user 115 Lucky user
65 #endif 116 #endif
66#endif 117#endif
67 ], 118 ],
68 [gl_cv_func_strstr_linear=yes], 119 [gl_cv_func_strstr_linear="guessing yes"],
69 [gl_cv_func_strstr_linear="guessing no"]) 120 [gl_cv_func_strstr_linear="guessing no"])
70 ]) 121 ])
71 ]) 122 ])
72 if test "$gl_cv_func_strstr_linear" != yes; then 123 case "$gl_cv_func_strstr_linear" in
73 REPLACE_STRSTR=1 124 *yes) ;;
74 fi 125 *)
75 fi 126 REPLACE_STRSTR=1
76 if test $REPLACE_STRSTR = 1; then 127 ;;
77 AC_LIBOBJ([strstr]) 128 esac
78 fi 129 fi
79]) # gl_FUNC_STRSTR 130]) # gl_FUNC_STRSTR
diff --git a/gl/m4/sys_socket_h.m4 b/gl/m4/sys_socket_h.m4
index 9f4db56..9486377 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 17 1# sys_socket_h.m4 serial 23
2dnl Copyright (C) 2005-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2005-2013 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,18 @@ dnl From Simon Josefsson.
9AC_DEFUN([gl_HEADER_SYS_SOCKET], 9AC_DEFUN([gl_HEADER_SYS_SOCKET],
10[ 10[
11 AC_REQUIRE([gl_SYS_SOCKET_H_DEFAULTS]) 11 AC_REQUIRE([gl_SYS_SOCKET_H_DEFAULTS])
12 AC_REQUIRE([AC_C_INLINE]) 12 AC_REQUIRE([AC_CANONICAL_HOST])
13
14 dnl On OSF/1, the functions recv(), send(), recvfrom(), sendto() have
15 dnl old-style declarations (with return type 'int' instead of 'ssize_t')
16 dnl unless _POSIX_PII_SOCKET is defined.
17 case "$host_os" in
18 osf*)
19 AC_DEFINE([_POSIX_PII_SOCKET], [1],
20 [Define to 1 in order to get the POSIX compatible declarations
21 of socket functions.])
22 ;;
23 esac
13 24
14 AC_CACHE_CHECK([whether <sys/socket.h> is self-contained], 25 AC_CACHE_CHECK([whether <sys/socket.h> is self-contained],
15 [gl_cv_header_sys_socket_h_selfcontained], 26 [gl_cv_header_sys_socket_h_selfcontained],
@@ -57,6 +68,23 @@ AC_DEFUN([gl_HEADER_SYS_SOCKET],
57 if test $ac_cv_type_sa_family_t = no; then 68 if test $ac_cv_type_sa_family_t = no; then
58 HAVE_SA_FAMILY_T=0 69 HAVE_SA_FAMILY_T=0
59 fi 70 fi
71 if test $ac_cv_type_struct_sockaddr_storage != no; then
72 AC_CHECK_MEMBERS([struct sockaddr_storage.ss_family],
73 [],
74 [HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY=0],
75 [#include <sys/types.h>
76 #ifdef HAVE_SYS_SOCKET_H
77 #include <sys/socket.h>
78 #endif
79 #ifdef HAVE_WS2TCPIP_H
80 #include <ws2tcpip.h>
81 #endif
82 ])
83 fi
84 if test $HAVE_STRUCT_SOCKADDR_STORAGE = 0 || test $HAVE_SA_FAMILY_T = 0 \
85 || test $HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY = 0; then
86 SYS_SOCKET_H='sys/socket.h'
87 fi
60 gl_PREREQ_SYS_H_WINSOCK2 88 gl_PREREQ_SYS_H_WINSOCK2
61 89
62 dnl Check for declarations of anything we want to poison if the 90 dnl Check for declarations of anything we want to poison if the
@@ -64,10 +92,7 @@ AC_DEFUN([gl_HEADER_SYS_SOCKET],
64 gl_WARN_ON_USE_PREPARE([[ 92 gl_WARN_ON_USE_PREPARE([[
65/* Some systems require prerequisite headers. */ 93/* Some systems require prerequisite headers. */
66#include <sys/types.h> 94#include <sys/types.h>
67#if !defined __GLIBC__ && HAVE_SYS_TIME_H 95#include <sys/socket.h>
68# include <sys/time.h>
69#endif
70#include <sys/select.h>
71 ]], [socket connect accept bind getpeername getsockname getsockopt 96 ]], [socket connect accept bind getpeername getsockname getsockopt
72 listen recv send recvfrom sendto setsockopt shutdown accept4]) 97 listen recv send recvfrom sendto setsockopt shutdown accept4])
73]) 98])
@@ -75,17 +100,13 @@ AC_DEFUN([gl_HEADER_SYS_SOCKET],
75AC_DEFUN([gl_PREREQ_SYS_H_SOCKET], 100AC_DEFUN([gl_PREREQ_SYS_H_SOCKET],
76[ 101[
77 dnl Check prerequisites of the <sys/socket.h> replacement. 102 dnl Check prerequisites of the <sys/socket.h> replacement.
103 AC_REQUIRE([gl_CHECK_SOCKET_HEADERS])
78 gl_CHECK_NEXT_HEADERS([sys/socket.h]) 104 gl_CHECK_NEXT_HEADERS([sys/socket.h])
79 if test $ac_cv_header_sys_socket_h = yes; then 105 if test $ac_cv_header_sys_socket_h = yes; then
80 HAVE_SYS_SOCKET_H=1 106 HAVE_SYS_SOCKET_H=1
81 HAVE_WS2TCPIP_H=0 107 HAVE_WS2TCPIP_H=0
82 else 108 else
83 HAVE_SYS_SOCKET_H=0 109 HAVE_SYS_SOCKET_H=0
84 dnl We cannot use AC_CHECK_HEADERS_ONCE here, because that would make
85 dnl the check for those headers unconditional; yet cygwin reports
86 dnl that the headers are present but cannot be compiled (since on
87 dnl cygwin, all socket information should come from sys/socket.h).
88 AC_CHECK_HEADERS([ws2tcpip.h])
89 if test $ac_cv_header_ws2tcpip_h = yes; then 110 if test $ac_cv_header_ws2tcpip_h = yes; then
90 HAVE_WS2TCPIP_H=1 111 HAVE_WS2TCPIP_H=1
91 else 112 else
@@ -148,6 +169,8 @@ AC_DEFUN([gl_SYS_SOCKET_H_DEFAULTS],
148 GNULIB_SHUTDOWN=0; AC_SUBST([GNULIB_SHUTDOWN]) 169 GNULIB_SHUTDOWN=0; AC_SUBST([GNULIB_SHUTDOWN])
149 GNULIB_ACCEPT4=0; AC_SUBST([GNULIB_ACCEPT4]) 170 GNULIB_ACCEPT4=0; AC_SUBST([GNULIB_ACCEPT4])
150 HAVE_STRUCT_SOCKADDR_STORAGE=1; AC_SUBST([HAVE_STRUCT_SOCKADDR_STORAGE]) 171 HAVE_STRUCT_SOCKADDR_STORAGE=1; AC_SUBST([HAVE_STRUCT_SOCKADDR_STORAGE])
172 HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY=1;
173 AC_SUBST([HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY])
151 HAVE_SA_FAMILY_T=1; AC_SUBST([HAVE_SA_FAMILY_T]) 174 HAVE_SA_FAMILY_T=1; AC_SUBST([HAVE_SA_FAMILY_T])
152 HAVE_ACCEPT4=1; AC_SUBST([HAVE_ACCEPT4]) 175 HAVE_ACCEPT4=1; AC_SUBST([HAVE_ACCEPT4])
153]) 176])
diff --git a/gl/m4/sys_stat_h.m4 b/gl/m4/sys_stat_h.m4
deleted file mode 100644
index 7181c25..0000000
--- a/gl/m4/sys_stat_h.m4
+++ /dev/null
@@ -1,82 +0,0 @@
1# sys_stat_h.m4 serial 24 -*- Autoconf -*-
2dnl Copyright (C) 2006-2010 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Eric Blake.
8dnl Provide a GNU-like <sys/stat.h>.
9
10AC_DEFUN([gl_HEADER_SYS_STAT_H],
11[
12 AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
13
14 dnl For the mkdir substitute.
15 AC_REQUIRE([AC_C_INLINE])
16
17 dnl Check for broken stat macros.
18 AC_REQUIRE([AC_HEADER_STAT])
19
20 gl_CHECK_NEXT_HEADERS([sys/stat.h])
21
22 dnl Define types that are supposed to be defined in <sys/types.h> or
23 dnl <sys/stat.h>.
24 AC_CHECK_TYPE([nlink_t], [],
25 [AC_DEFINE([nlink_t], [int],
26 [Define to the type of st_nlink in struct stat, or a supertype.])],
27 [#include <sys/types.h>
28 #include <sys/stat.h>])
29
30 dnl Check for declarations of anything we want to poison if the
31 dnl corresponding gnulib module is not in use.
32 gl_WARN_ON_USE_PREPARE([[#include <sys/stat.h>
33 ]], [fchmodat fstatat futimens lchmod lstat mkdirat mkfifo mkfifoat
34 mknod mknodat stat utimensat])
35]) # gl_HEADER_SYS_STAT_H
36
37AC_DEFUN([gl_SYS_STAT_MODULE_INDICATOR],
38[
39 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
40 AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
41 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
42 dnl Define it also as a C macro, for the benefit of the unit tests.
43 gl_MODULE_INDICATOR_FOR_TESTS([$1])
44])
45
46AC_DEFUN([gl_SYS_STAT_H_DEFAULTS],
47[
48 AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) dnl for REPLACE_FCHDIR
49 GNULIB_FCHMODAT=0; AC_SUBST([GNULIB_FCHMODAT])
50 GNULIB_FSTATAT=0; AC_SUBST([GNULIB_FSTATAT])
51 GNULIB_FUTIMENS=0; AC_SUBST([GNULIB_FUTIMENS])
52 GNULIB_LCHMOD=0; AC_SUBST([GNULIB_LCHMOD])
53 GNULIB_LSTAT=0; AC_SUBST([GNULIB_LSTAT])
54 GNULIB_MKDIRAT=0; AC_SUBST([GNULIB_MKDIRAT])
55 GNULIB_MKFIFO=0; AC_SUBST([GNULIB_MKFIFO])
56 GNULIB_MKFIFOAT=0; AC_SUBST([GNULIB_MKFIFOAT])
57 GNULIB_MKNOD=0; AC_SUBST([GNULIB_MKNOD])
58 GNULIB_MKNODAT=0; AC_SUBST([GNULIB_MKNODAT])
59 GNULIB_STAT=0; AC_SUBST([GNULIB_STAT])
60 GNULIB_UTIMENSAT=0; AC_SUBST([GNULIB_UTIMENSAT])
61 dnl Assume proper GNU behavior unless another module says otherwise.
62 HAVE_FCHMODAT=1; AC_SUBST([HAVE_FCHMODAT])
63 HAVE_FSTATAT=1; AC_SUBST([HAVE_FSTATAT])
64 HAVE_FUTIMENS=1; AC_SUBST([HAVE_FUTIMENS])
65 HAVE_LCHMOD=1; AC_SUBST([HAVE_LCHMOD])
66 HAVE_LSTAT=1; AC_SUBST([HAVE_LSTAT])
67 HAVE_MKDIRAT=1; AC_SUBST([HAVE_MKDIRAT])
68 HAVE_MKFIFO=1; AC_SUBST([HAVE_MKFIFO])
69 HAVE_MKFIFOAT=1; AC_SUBST([HAVE_MKFIFOAT])
70 HAVE_MKNOD=1; AC_SUBST([HAVE_MKNOD])
71 HAVE_MKNODAT=1; AC_SUBST([HAVE_MKNODAT])
72 HAVE_UTIMENSAT=1; AC_SUBST([HAVE_UTIMENSAT])
73 REPLACE_FSTAT=0; AC_SUBST([REPLACE_FSTAT])
74 REPLACE_FSTATAT=0; AC_SUBST([REPLACE_FSTATAT])
75 REPLACE_FUTIMENS=0; AC_SUBST([REPLACE_FUTIMENS])
76 REPLACE_LSTAT=0; AC_SUBST([REPLACE_LSTAT])
77 REPLACE_MKDIR=0; AC_SUBST([REPLACE_MKDIR])
78 REPLACE_MKFIFO=0; AC_SUBST([REPLACE_MKFIFO])
79 REPLACE_MKNOD=0; AC_SUBST([REPLACE_MKNOD])
80 REPLACE_STAT=0; AC_SUBST([REPLACE_STAT])
81 REPLACE_UTIMENSAT=0; AC_SUBST([REPLACE_UTIMENSAT])
82])
diff --git a/gl/m4/sys_types_h.m4 b/gl/m4/sys_types_h.m4
new file mode 100644
index 0000000..d15c1b3
--- /dev/null
+++ b/gl/m4/sys_types_h.m4
@@ -0,0 +1,24 @@
1# sys_types_h.m4 serial 5
2dnl Copyright (C) 2011-2013 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_ONCE([gl_SYS_TYPES_H],
8[
9 AC_REQUIRE([gl_SYS_TYPES_H_DEFAULTS])
10 gl_NEXT_HEADERS([sys/types.h])
11
12 dnl Ensure the type pid_t gets defined.
13 AC_REQUIRE([AC_TYPE_PID_T])
14
15 dnl Ensure the type mode_t gets defined.
16 AC_REQUIRE([AC_TYPE_MODE_T])
17
18 dnl Whether to override the 'off_t' type.
19 AC_REQUIRE([gl_TYPE_OFF_T])
20])
21
22AC_DEFUN([gl_SYS_TYPES_H_DEFAULTS],
23[
24])
diff --git a/gl/m4/sys_uio_h.m4 b/gl/m4/sys_uio_h.m4
new file mode 100644
index 0000000..c75cbbd
--- /dev/null
+++ b/gl/m4/sys_uio_h.m4
@@ -0,0 +1,31 @@
1# sys_uio_h.m4 serial 1
2dnl Copyright (C) 2011-2013 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_SYS_UIO],
8[
9 AC_REQUIRE([gl_SYS_UIO_H_DEFAULTS])
10 dnl <sys/uio.h> is always overridden, because of GNULIB_POSIXCHECK.
11 gl_CHECK_NEXT_HEADERS([sys/uio.h])
12 if test $ac_cv_header_sys_uio_h = yes; then
13 HAVE_SYS_UIO_H=1
14 else
15 HAVE_SYS_UIO_H=0
16 fi
17 AC_SUBST([HAVE_SYS_UIO_H])
18])
19
20AC_DEFUN([gl_SYS_UIO_MODULE_INDICATOR],
21[
22 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
23 AC_REQUIRE([gl_SYS_UIO_H_DEFAULTS])
24 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
25 dnl Define it also as a C macro, for the benefit of the unit tests.
26 gl_MODULE_INDICATOR_FOR_TESTS([$1])
27])
28
29AC_DEFUN([gl_SYS_UIO_H_DEFAULTS],
30[
31])
diff --git a/gl/m4/threadlib.m4 b/gl/m4/threadlib.m4
index 05cc4ff..26bdeb5 100644
--- a/gl/m4/threadlib.m4
+++ b/gl/m4/threadlib.m4
@@ -1,5 +1,5 @@
1# threadlib.m4 serial 5 (gettext-0.18) 1# threadlib.m4 serial 10 (gettext-0.18.2)
2dnl Copyright (C) 2005-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2005-2013 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,13 @@ dnl From Bruno Haible.
9dnl gl_THREADLIB 9dnl gl_THREADLIB
10dnl ------------ 10dnl ------------
11dnl Tests for a multithreading library to be used. 11dnl Tests for a multithreading library to be used.
12dnl If the configure.ac contains a definition of the gl_THREADLIB_DEFAULT_NO
13dnl (it must be placed before the invocation of gl_THREADLIB_EARLY!), then the
14dnl default is 'no', otherwise it is system dependent. In both cases, the user
15dnl can change the choice through the options --enable-threads=choice or
16dnl --disable-threads.
12dnl Defines at most one of the macros USE_POSIX_THREADS, USE_SOLARIS_THREADS, 17dnl Defines at most one of the macros USE_POSIX_THREADS, USE_SOLARIS_THREADS,
13dnl USE_PTH_THREADS, USE_WIN32_THREADS 18dnl USE_PTH_THREADS, USE_WINDOWS_THREADS
14dnl Sets the variables LIBTHREAD and LTLIBTHREAD to the linker options for use 19dnl 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 20dnl in a Makefile (LIBTHREAD for use without libtool, LTLIBTHREAD for use with
16dnl libtool). 21dnl libtool).
@@ -44,10 +49,12 @@ AC_DEFUN([gl_THREADLIB_EARLY_BODY],
44 [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])], 49 [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])],
45 [AC_REQUIRE([AC_GNU_SOURCE])]) 50 [AC_REQUIRE([AC_GNU_SOURCE])])
46 dnl Check for multithreading. 51 dnl Check for multithreading.
47 m4_divert_text([DEFAULTS], [gl_use_threads_default=]) 52 m4_ifdef([gl_THREADLIB_DEFAULT_NO],
53 [m4_divert_text([DEFAULTS], [gl_use_threads_default=no])],
54 [m4_divert_text([DEFAULTS], [gl_use_threads_default=])])
48 AC_ARG_ENABLE([threads], 55 AC_ARG_ENABLE([threads],
49AC_HELP_STRING([--enable-threads={posix|solaris|pth|win32}], [specify multithreading API]) 56AC_HELP_STRING([--enable-threads={posix|solaris|pth|windows}], [specify multithreading API])m4_ifdef([gl_THREADLIB_DEFAULT_NO], [], [
50AC_HELP_STRING([--disable-threads], [build without multithread safety]), 57AC_HELP_STRING([--disable-threads], [build without multithread safety])]),
51 [gl_use_threads=$enableval], 58 [gl_use_threads=$enableval],
52 [if test -n "$gl_use_threads_default"; then 59 [if test -n "$gl_use_threads_default"; then
53 gl_use_threads="$gl_use_threads_default" 60 gl_use_threads="$gl_use_threads_default"
@@ -80,7 +87,7 @@ changequote([,])dnl
80 # groks <pthread.h>. cc also understands the flag -pthread, but 87 # groks <pthread.h>. cc also understands the flag -pthread, but
81 # we don't use it because 1. gcc-2.95 doesn't understand -pthread, 88 # we don't use it because 1. gcc-2.95 doesn't understand -pthread,
82 # 2. putting a flag into CPPFLAGS that has an effect on the linker 89 # 2. putting a flag into CPPFLAGS that has an effect on the linker
83 # causes the AC_TRY_LINK test below to succeed unexpectedly, 90 # causes the AC_LINK_IFELSE test below to succeed unexpectedly,
84 # leading to wrong values of LIBTHREAD and LTLIBTHREAD. 91 # leading to wrong values of LIBTHREAD and LTLIBTHREAD.
85 CPPFLAGS="$CPPFLAGS -D_REENTRANT" 92 CPPFLAGS="$CPPFLAGS -D_REENTRANT"
86 ;; 93 ;;
@@ -111,18 +118,25 @@ AC_DEFUN([gl_THREADLIB_BODY],
111 [gl_cv_have_weak], 118 [gl_cv_have_weak],
112 [gl_cv_have_weak=no 119 [gl_cv_have_weak=no
113 dnl First, test whether the compiler accepts it syntactically. 120 dnl First, test whether the compiler accepts it syntactically.
114 AC_TRY_LINK([extern void xyzzy (); 121 AC_LINK_IFELSE(
115#pragma weak xyzzy], [xyzzy();], [gl_cv_have_weak=maybe]) 122 [AC_LANG_PROGRAM(
123 [[extern void xyzzy ();
124#pragma weak xyzzy]],
125 [[xyzzy();]])],
126 [gl_cv_have_weak=maybe])
116 if test $gl_cv_have_weak = maybe; then 127 if test $gl_cv_have_weak = maybe; then
117 dnl Second, test whether it actually works. On Cygwin 1.7.2, with 128 dnl Second, test whether it actually works. On Cygwin 1.7.2, with
118 dnl gcc 4.3, symbols declared weak always evaluate to the address 0. 129 dnl gcc 4.3, symbols declared weak always evaluate to the address 0.
119 AC_TRY_RUN([ 130 AC_RUN_IFELSE(
131 [AC_LANG_SOURCE([[
120#include <stdio.h> 132#include <stdio.h>
121#pragma weak fputs 133#pragma weak fputs
122int main () 134int main ()
123{ 135{
124 return (fputs == NULL); 136 return (fputs == NULL);
125}], [gl_cv_have_weak=yes], [gl_cv_have_weak=no], 137}]])],
138 [gl_cv_have_weak=yes],
139 [gl_cv_have_weak=no],
126 [dnl When cross-compiling, assume that only ELF platforms support 140 [dnl When cross-compiling, assume that only ELF platforms support
127 dnl weak symbols. 141 dnl weak symbols.
128 AC_EGREP_CPP([Extensible Linking Format], 142 AC_EGREP_CPP([Extensible Linking Format],
@@ -148,9 +162,11 @@ int main ()
148 # Test whether both pthread_mutex_lock and pthread_mutexattr_init exist 162 # Test whether both pthread_mutex_lock and pthread_mutexattr_init exist
149 # in libc. IRIX 6.5 has the first one in both libc and libpthread, but 163 # in libc. IRIX 6.5 has the first one in both libc and libpthread, but
150 # the second one only in libpthread, and lock.c needs it. 164 # the second one only in libpthread, and lock.c needs it.
151 AC_TRY_LINK([#include <pthread.h>], 165 AC_LINK_IFELSE(
152 [pthread_mutex_lock((pthread_mutex_t*)0); 166 [AC_LANG_PROGRAM(
153 pthread_mutexattr_init((pthread_mutexattr_t*)0);], 167 [[#include <pthread.h>]],
168 [[pthread_mutex_lock((pthread_mutex_t*)0);
169 pthread_mutexattr_init((pthread_mutexattr_t*)0);]])],
154 [gl_have_pthread=yes]) 170 [gl_have_pthread=yes])
155 # Test for libpthread by looking for pthread_kill. (Not pthread_self, 171 # Test for libpthread by looking for pthread_kill. (Not pthread_self,
156 # since it is defined as a macro on OSF/1.) 172 # since it is defined as a macro on OSF/1.)
@@ -203,9 +219,13 @@ int main ()
203 gl_have_solaristhread= 219 gl_have_solaristhread=
204 gl_save_LIBS="$LIBS" 220 gl_save_LIBS="$LIBS"
205 LIBS="$LIBS -lthread" 221 LIBS="$LIBS -lthread"
206 AC_TRY_LINK([#include <thread.h> 222 AC_LINK_IFELSE(
207#include <synch.h>], 223 [AC_LANG_PROGRAM(
208 [thr_self();], 224 [[
225#include <thread.h>
226#include <synch.h>
227 ]],
228 [[thr_self();]])],
209 [gl_have_solaristhread=yes]) 229 [gl_have_solaristhread=yes])
210 LIBS="$gl_save_LIBS" 230 LIBS="$gl_save_LIBS"
211 if test -n "$gl_have_solaristhread"; then 231 if test -n "$gl_have_solaristhread"; then
@@ -230,8 +250,10 @@ int main ()
230 AC_LIB_LINKFLAGS([pth]) 250 AC_LIB_LINKFLAGS([pth])
231 gl_have_pth= 251 gl_have_pth=
232 gl_save_LIBS="$LIBS" 252 gl_save_LIBS="$LIBS"
233 LIBS="$LIBS -lpth" 253 LIBS="$LIBS $LIBPTH"
234 AC_TRY_LINK([#include <pth.h>], [pth_self();], [gl_have_pth=yes]) 254 AC_LINK_IFELSE(
255 [AC_LANG_PROGRAM([[#include <pth.h>]], [[pth_self();]])],
256 [gl_have_pth=yes])
235 LIBS="$gl_save_LIBS" 257 LIBS="$gl_save_LIBS"
236 if test -n "$gl_have_pth"; then 258 if test -n "$gl_have_pth"; then
237 gl_threads_api=pth 259 gl_threads_api=pth
@@ -254,17 +276,19 @@ int main ()
254 fi 276 fi
255 fi 277 fi
256 if test -z "$gl_have_pthread"; then 278 if test -z "$gl_have_pthread"; then
257 if test "$gl_use_threads" = yes || test "$gl_use_threads" = win32; then 279 case "$gl_use_threads" in
258 if { case "$host_os" in 280 yes | windows | win32) # The 'win32' is for backward compatibility.
259 mingw*) true;; 281 if { case "$host_os" in
260 *) false;; 282 mingw*) true;;
261 esac 283 *) false;;
262 }; then 284 esac
263 gl_threads_api=win32 285 }; then
264 AC_DEFINE([USE_WIN32_THREADS], [1], 286 gl_threads_api=windows
265 [Define if the Win32 multithreading API can be used.]) 287 AC_DEFINE([USE_WINDOWS_THREADS], [1],
266 fi 288 [Define if the native Windows multithreading API can be used.])
267 fi 289 fi
290 ;;
291 esac
268 fi 292 fi
269 fi 293 fi
270 AC_MSG_CHECKING([for multithread API to use]) 294 AC_MSG_CHECKING([for multithread API to use])
@@ -295,50 +319,50 @@ AC_DEFUN([gl_DISABLE_THREADS], [
295 319
296dnl Survey of platforms: 320dnl Survey of platforms:
297dnl 321dnl
298dnl Platform Available Compiler Supports test-lock 322dnl Platform Available Compiler Supports test-lock
299dnl flavours option weak result 323dnl flavours option weak result
300dnl --------------- --------- --------- -------- --------- 324dnl --------------- --------- --------- -------- ---------
301dnl Linux 2.4/glibc posix -lpthread Y OK 325dnl Linux 2.4/glibc posix -lpthread Y OK
302dnl 326dnl
303dnl GNU Hurd/glibc posix 327dnl GNU Hurd/glibc posix
304dnl 328dnl
305dnl FreeBSD 5.3 posix -lc_r Y 329dnl FreeBSD 5.3 posix -lc_r Y
306dnl posix -lkse ? Y 330dnl posix -lkse ? Y
307dnl posix -lpthread ? Y 331dnl posix -lpthread ? Y
308dnl posix -lthr Y 332dnl posix -lthr Y
309dnl 333dnl
310dnl FreeBSD 5.2 posix -lc_r Y 334dnl FreeBSD 5.2 posix -lc_r Y
311dnl posix -lkse Y 335dnl posix -lkse Y
312dnl posix -lthr Y 336dnl posix -lthr Y
313dnl 337dnl
314dnl FreeBSD 4.0,4.10 posix -lc_r Y OK 338dnl FreeBSD 4.0,4.10 posix -lc_r Y OK
315dnl 339dnl
316dnl NetBSD 1.6 -- 340dnl NetBSD 1.6 --
317dnl 341dnl
318dnl OpenBSD 3.4 posix -lpthread Y OK 342dnl OpenBSD 3.4 posix -lpthread Y OK
319dnl 343dnl
320dnl MacOS X 10.[123] posix -lpthread Y OK 344dnl Mac OS X 10.[123] posix -lpthread Y OK
321dnl 345dnl
322dnl Solaris 7,8,9 posix -lpthread Y Sol 7,8: 0.0; Sol 9: OK 346dnl Solaris 7,8,9 posix -lpthread Y Sol 7,8: 0.0; Sol 9: OK
323dnl solaris -lthread Y Sol 7,8: 0.0; Sol 9: OK 347dnl solaris -lthread Y Sol 7,8: 0.0; Sol 9: OK
324dnl 348dnl
325dnl HP-UX 11 posix -lpthread N (cc) OK 349dnl HP-UX 11 posix -lpthread N (cc) OK
326dnl Y (gcc) 350dnl Y (gcc)
327dnl 351dnl
328dnl IRIX 6.5 posix -lpthread Y 0.5 352dnl IRIX 6.5 posix -lpthread Y 0.5
329dnl 353dnl
330dnl AIX 4.3,5.1 posix -lpthread N AIX 4: 0.5; AIX 5: OK 354dnl AIX 4.3,5.1 posix -lpthread N AIX 4: 0.5; AIX 5: OK
331dnl 355dnl
332dnl OSF/1 4.0,5.1 posix -pthread (cc) N OK 356dnl OSF/1 4.0,5.1 posix -pthread (cc) N OK
333dnl -lpthread (gcc) Y 357dnl -lpthread (gcc) Y
334dnl 358dnl
335dnl Cygwin posix -lpthread Y OK 359dnl Cygwin posix -lpthread Y OK
336dnl 360dnl
337dnl Any of the above pth -lpth 0.0 361dnl Any of the above pth -lpth 0.0
338dnl 362dnl
339dnl Mingw win32 N OK 363dnl Mingw windows N OK
340dnl 364dnl
341dnl BeOS 5 -- 365dnl BeOS 5 --
342dnl 366dnl
343dnl The test-lock result shows what happens if in test-lock.c EXPLICIT_YIELD is 367dnl The test-lock result shows what happens if in test-lock.c EXPLICIT_YIELD is
344dnl turned off: 368dnl turned off:
diff --git a/gl/m4/time_h.m4 b/gl/m4/time_h.m4
index a45a10a..3b83900 100644
--- a/gl/m4/time_h.m4
+++ b/gl/m4/time_h.m4
@@ -1,8 +1,8 @@
1# Configure a more-standard replacement for <time.h>. 1# Configure a more-standard replacement for <time.h>.
2 2
3# Copyright (C) 2000-2001, 2003-2007, 2009-2010 Free Software Foundation, Inc. 3# Copyright (C) 2000-2001, 2003-2007, 2009-2013 Free Software Foundation, Inc.
4 4
5# serial 2 5# serial 7
6 6
7# This file is free software; the Free Software Foundation 7# This file is free software; the Free Software Foundation
8# gives unlimited permission to copy and/or distribute it, 8# gives unlimited permission to copy and/or distribute it,
@@ -21,11 +21,11 @@ AC_DEFUN([gl_HEADER_TIME_H_BODY],
21[ 21[
22 AC_REQUIRE([AC_C_RESTRICT]) 22 AC_REQUIRE([AC_C_RESTRICT])
23 AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) 23 AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
24 gl_CHECK_NEXT_HEADERS([time.h]) 24 gl_NEXT_HEADERS([time.h])
25 AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC]) 25 AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC])
26]) 26])
27 27
28dnl Define HAVE_STRUCT_TIMESPEC if `struct timespec' is declared 28dnl Check whether 'struct timespec' is declared
29dnl in time.h, sys/time.h, or pthread.h. 29dnl in time.h, sys/time.h, or pthread.h.
30 30
31AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC], 31AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
@@ -95,7 +95,7 @@ AC_DEFUN([gl_HEADER_TIME_H_DEFAULTS],
95 GNULIB_TIMEGM=0; AC_SUBST([GNULIB_TIMEGM]) 95 GNULIB_TIMEGM=0; AC_SUBST([GNULIB_TIMEGM])
96 GNULIB_TIME_R=0; AC_SUBST([GNULIB_TIME_R]) 96 GNULIB_TIME_R=0; AC_SUBST([GNULIB_TIME_R])
97 dnl Assume proper GNU behavior unless another module says otherwise. 97 dnl Assume proper GNU behavior unless another module says otherwise.
98 HAVE_LOCALTIME_R=1; AC_SUBST([HAVE_LOCALTIME_R]) 98 HAVE_DECL_LOCALTIME_R=1; AC_SUBST([HAVE_DECL_LOCALTIME_R])
99 HAVE_NANOSLEEP=1; AC_SUBST([HAVE_NANOSLEEP]) 99 HAVE_NANOSLEEP=1; AC_SUBST([HAVE_NANOSLEEP])
100 HAVE_STRPTIME=1; AC_SUBST([HAVE_STRPTIME]) 100 HAVE_STRPTIME=1; AC_SUBST([HAVE_STRPTIME])
101 HAVE_TIMEGM=1; AC_SUBST([HAVE_TIMEGM]) 101 HAVE_TIMEGM=1; AC_SUBST([HAVE_TIMEGM])
diff --git a/gl/m4/time_r.m4 b/gl/m4/time_r.m4
index 9e82d39..c388a83 100644
--- a/gl/m4/time_r.m4
+++ b/gl/m4/time_r.m4
@@ -1,6 +1,6 @@
1dnl Reentrant time functions: localtime_r, gmtime_r. 1dnl Reentrant time functions: localtime_r, gmtime_r.
2 2
3dnl Copyright (C) 2003, 2006-2010 Free Software Foundation, Inc. 3dnl Copyright (C) 2003, 2006-2013 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.
@@ -15,8 +15,16 @@ AC_DEFUN([gl_TIME_R],
15 AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) 15 AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
16 AC_REQUIRE([AC_C_RESTRICT]) 16 AC_REQUIRE([AC_C_RESTRICT])
17 17
18 dnl Some systems don't declare localtime_r() and gmtime_r() if _REENTRANT is
19 dnl not defined.
20 AC_CHECK_DECLS([localtime_r], [], [], [[#include <time.h>]])
21 if test $ac_cv_have_decl_localtime_r = no; then
22 HAVE_DECL_LOCALTIME_R=0
23 fi
24
18 AC_CHECK_FUNCS_ONCE([localtime_r]) 25 AC_CHECK_FUNCS_ONCE([localtime_r])
19 if test $ac_cv_func_localtime_r = yes; then 26 if test $ac_cv_func_localtime_r = yes; then
27 HAVE_LOCALTIME_R=1
20 AC_CACHE_CHECK([whether localtime_r is compatible with its POSIX signature], 28 AC_CACHE_CHECK([whether localtime_r is compatible with its POSIX signature],
21 [gl_cv_time_r_posix], 29 [gl_cv_time_r_posix],
22 [AC_COMPILE_IFELSE( 30 [AC_COMPILE_IFELSE(
@@ -42,10 +50,6 @@ AC_DEFUN([gl_TIME_R],
42 else 50 else
43 HAVE_LOCALTIME_R=0 51 HAVE_LOCALTIME_R=0
44 fi 52 fi
45 if test $HAVE_LOCALTIME_R = 0 || test $REPLACE_LOCALTIME_R = 1; then
46 AC_LIBOBJ([time_r])
47 gl_PREREQ_TIME_R
48 fi
49]) 53])
50 54
51# Prerequisites of lib/time_r.c. 55# Prerequisites of lib/time_r.c.
diff --git a/gl/m4/timegm.m4 b/gl/m4/timegm.m4
index bdaafbf..997953c 100644
--- a/gl/m4/timegm.m4
+++ b/gl/m4/timegm.m4
@@ -1,5 +1,5 @@
1# timegm.m4 serial 8 1# timegm.m4 serial 11
2dnl Copyright (C) 2003, 2007, 2009, 2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2003, 2007, 2009-2013 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,30 +11,16 @@ AC_DEFUN([gl_FUNC_TIMEGM],
11 REPLACE_TIMEGM=0 11 REPLACE_TIMEGM=0
12 AC_CHECK_FUNCS_ONCE([timegm]) 12 AC_CHECK_FUNCS_ONCE([timegm])
13 if test $ac_cv_func_timegm = yes; then 13 if test $ac_cv_func_timegm = yes; then
14 if test $ac_cv_func_working_mktime = no; then 14 if test $gl_cv_func_working_mktime = no; then
15 # Assume that timegm is buggy if mktime is. 15 # Assume that timegm is buggy if mktime is.
16 REPLACE_TIMEGM=1 16 REPLACE_TIMEGM=1
17 fi 17 fi
18 else 18 else
19 HAVE_TIMEGM=0 19 HAVE_TIMEGM=0
20 fi 20 fi
21 if test $HAVE_TIMEGM = 0 || test $REPLACE_TIMEGM = 1; then
22 AC_LIBOBJ([timegm])
23 gl_PREREQ_TIMEGM
24 fi
25]) 21])
26 22
27# Prerequisites of lib/timegm.c. 23# Prerequisites of lib/timegm.c.
28AC_DEFUN([gl_PREREQ_TIMEGM], [ 24AC_DEFUN([gl_PREREQ_TIMEGM], [
29 AC_REQUIRE([gl_TIME_R]) 25 :
30 AC_REQUIRE([gl_FUNC_MKTIME])
31 if test $ac_cv_func_working_mktime = yes; then
32 AC_CHECK_FUNC([__mktime_internal], ,
33 [# mktime works but it doesn't export __mktime_internal,
34 # so we need to substitute our own mktime implementation.
35 AC_LIBOBJ([mktime])
36 AC_DEFINE([mktime], [rpl_mktime],
37 [Define to rpl_mktime if the replacement function should be used.])
38 gl_PREREQ_MKTIME])
39 fi
40]) 26])
diff --git a/gl/m4/uintmax_t.m4 b/gl/m4/uintmax_t.m4
index 03b51bc..c6ff800 100644
--- a/gl/m4/uintmax_t.m4
+++ b/gl/m4/uintmax_t.m4
@@ -1,5 +1,5 @@
1# uintmax_t.m4 serial 12 1# uintmax_t.m4 serial 12
2dnl Copyright (C) 1997-2004, 2007-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 1997-2004, 2007-2013 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.
diff --git a/gl/m4/unistd-safer.m4 b/gl/m4/unistd-safer.m4
deleted file mode 100644
index 74c3ce6..0000000
--- a/gl/m4/unistd-safer.m4
+++ /dev/null
@@ -1,13 +0,0 @@
1#serial 8
2dnl Copyright (C) 2002, 2005-2006, 2009-2010 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_UNISTD_SAFER],
8[
9 AC_CHECK_FUNCS_ONCE([pipe])
10 AC_LIBOBJ([dup-safer])
11 AC_LIBOBJ([fd-safer])
12 AC_LIBOBJ([pipe-safer])
13])
diff --git a/gl/m4/unistd_h.m4 b/gl/m4/unistd_h.m4
index 48d06c7..32dcfa5 100644
--- a/gl/m4/unistd_h.m4
+++ b/gl/m4/unistd_h.m4
@@ -1,5 +1,5 @@
1# unistd_h.m4 serial 46 1# unistd_h.m4 serial 66
2dnl Copyright (C) 2006-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2006-2013 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,11 +11,8 @@ AC_DEFUN([gl_UNISTD_H],
11 dnl Use AC_REQUIRE here, so that the default behavior below is expanded 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. 12 dnl once only, before all statements that occur in other macros.
13 AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) 13 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
14 AC_REQUIRE([AC_C_INLINE])
15 14
16 gl_CHECK_NEXT_HEADERS([unistd.h]) 15 gl_CHECK_NEXT_HEADERS([unistd.h])
17
18 AC_CHECK_HEADERS_ONCE([unistd.h])
19 if test $ac_cv_header_unistd_h = yes; then 16 if test $ac_cv_header_unistd_h = yes; then
20 HAVE_UNISTD_H=1 17 HAVE_UNISTD_H=1
21 else 18 else
@@ -23,11 +20,20 @@ AC_DEFUN([gl_UNISTD_H],
23 fi 20 fi
24 AC_SUBST([HAVE_UNISTD_H]) 21 AC_SUBST([HAVE_UNISTD_H])
25 22
23 dnl Ensure the type pid_t gets defined.
24 AC_REQUIRE([AC_TYPE_PID_T])
25
26 dnl Determine WINDOWS_64_BIT_OFF_T.
27 AC_REQUIRE([gl_TYPE_OFF_T])
28
26 dnl Check for declarations of anything we want to poison if the 29 dnl Check for declarations of anything we want to poison if the
27 dnl corresponding gnulib module is not in use. 30 dnl corresponding gnulib module is not in use.
28 gl_WARN_ON_USE_PREPARE([[#include <unistd.h> 31 gl_WARN_ON_USE_PREPARE([[
32#if HAVE_UNISTD_H
33# include <unistd.h>
34#endif
29/* Some systems declare various items in the wrong headers. */ 35/* Some systems declare various items in the wrong headers. */
30#ifndef __GLIBC__ 36#if !(defined __GLIBC__ && !defined __UCLIBC__)
31# include <fcntl.h> 37# include <fcntl.h>
32# include <stdio.h> 38# include <stdio.h>
33# include <stdlib.h> 39# include <stdlib.h>
@@ -35,12 +41,13 @@ AC_DEFUN([gl_UNISTD_H],
35# include <io.h> 41# include <io.h>
36# endif 42# endif
37#endif 43#endif
38 ]], [chown dup2 dup3 environ euidaccess faccessat fchdir fchownat 44 ]], [chdir chown dup dup2 dup3 environ euidaccess faccessat fchdir fchownat
39 fsync ftruncate getcwd getdomainname getdtablesize getgroups 45 fdatasync fsync ftruncate getcwd getdomainname getdtablesize getgroups
40 gethostname getlogin getlogin_r getpagesize getusershell setusershell 46 gethostname getlogin getlogin_r getpagesize
41 endusershell lchown link linkat lseek pipe2 pread pwrite readlink 47 getusershell setusershell endusershell
42 readlinkat rmdir sleep symlink symlinkat ttyname_r unlink unlinkat 48 group_member isatty lchown link linkat lseek pipe pipe2 pread pwrite
43 usleep]) 49 readlink readlinkat rmdir sethostname sleep symlink symlinkat ttyname_r
50 unlink unlinkat usleep])
44]) 51])
45 52
46AC_DEFUN([gl_UNISTD_MODULE_INDICATOR], 53AC_DEFUN([gl_UNISTD_MODULE_INDICATOR],
@@ -54,46 +61,54 @@ AC_DEFUN([gl_UNISTD_MODULE_INDICATOR],
54 61
55AC_DEFUN([gl_UNISTD_H_DEFAULTS], 62AC_DEFUN([gl_UNISTD_H_DEFAULTS],
56[ 63[
57 GNULIB_CHOWN=0; AC_SUBST([GNULIB_CHOWN]) 64 GNULIB_CHDIR=0; AC_SUBST([GNULIB_CHDIR])
58 GNULIB_CLOSE=0; AC_SUBST([GNULIB_CLOSE]) 65 GNULIB_CHOWN=0; AC_SUBST([GNULIB_CHOWN])
59 GNULIB_DUP2=0; AC_SUBST([GNULIB_DUP2]) 66 GNULIB_CLOSE=0; AC_SUBST([GNULIB_CLOSE])
60 GNULIB_DUP3=0; AC_SUBST([GNULIB_DUP3]) 67 GNULIB_DUP=0; AC_SUBST([GNULIB_DUP])
61 GNULIB_ENVIRON=0; AC_SUBST([GNULIB_ENVIRON]) 68 GNULIB_DUP2=0; AC_SUBST([GNULIB_DUP2])
62 GNULIB_EUIDACCESS=0; AC_SUBST([GNULIB_EUIDACCESS]) 69 GNULIB_DUP3=0; AC_SUBST([GNULIB_DUP3])
63 GNULIB_FACCESSAT=0; AC_SUBST([GNULIB_FACCESSAT]) 70 GNULIB_ENVIRON=0; AC_SUBST([GNULIB_ENVIRON])
64 GNULIB_FCHDIR=0; AC_SUBST([GNULIB_FCHDIR]) 71 GNULIB_EUIDACCESS=0; AC_SUBST([GNULIB_EUIDACCESS])
65 GNULIB_FCHOWNAT=0; AC_SUBST([GNULIB_FCHOWNAT]) 72 GNULIB_FACCESSAT=0; AC_SUBST([GNULIB_FACCESSAT])
66 GNULIB_FSYNC=0; AC_SUBST([GNULIB_FSYNC]) 73 GNULIB_FCHDIR=0; AC_SUBST([GNULIB_FCHDIR])
67 GNULIB_FTRUNCATE=0; AC_SUBST([GNULIB_FTRUNCATE]) 74 GNULIB_FCHOWNAT=0; AC_SUBST([GNULIB_FCHOWNAT])
68 GNULIB_GETCWD=0; AC_SUBST([GNULIB_GETCWD]) 75 GNULIB_FDATASYNC=0; AC_SUBST([GNULIB_FDATASYNC])
69 GNULIB_GETDOMAINNAME=0; AC_SUBST([GNULIB_GETDOMAINNAME]) 76 GNULIB_FSYNC=0; AC_SUBST([GNULIB_FSYNC])
70 GNULIB_GETDTABLESIZE=0; AC_SUBST([GNULIB_GETDTABLESIZE]) 77 GNULIB_FTRUNCATE=0; AC_SUBST([GNULIB_FTRUNCATE])
71 GNULIB_GETGROUPS=0; AC_SUBST([GNULIB_GETGROUPS]) 78 GNULIB_GETCWD=0; AC_SUBST([GNULIB_GETCWD])
72 GNULIB_GETHOSTNAME=0; AC_SUBST([GNULIB_GETHOSTNAME]) 79 GNULIB_GETDOMAINNAME=0; AC_SUBST([GNULIB_GETDOMAINNAME])
73 GNULIB_GETLOGIN=0; AC_SUBST([GNULIB_GETLOGIN]) 80 GNULIB_GETDTABLESIZE=0; AC_SUBST([GNULIB_GETDTABLESIZE])
74 GNULIB_GETLOGIN_R=0; AC_SUBST([GNULIB_GETLOGIN_R]) 81 GNULIB_GETGROUPS=0; AC_SUBST([GNULIB_GETGROUPS])
75 GNULIB_GETPAGESIZE=0; AC_SUBST([GNULIB_GETPAGESIZE]) 82 GNULIB_GETHOSTNAME=0; AC_SUBST([GNULIB_GETHOSTNAME])
76 GNULIB_GETUSERSHELL=0; AC_SUBST([GNULIB_GETUSERSHELL]) 83 GNULIB_GETLOGIN=0; AC_SUBST([GNULIB_GETLOGIN])
77 GNULIB_LCHOWN=0; AC_SUBST([GNULIB_LCHOWN]) 84 GNULIB_GETLOGIN_R=0; AC_SUBST([GNULIB_GETLOGIN_R])
78 GNULIB_LINK=0; AC_SUBST([GNULIB_LINK]) 85 GNULIB_GETPAGESIZE=0; AC_SUBST([GNULIB_GETPAGESIZE])
79 GNULIB_LINKAT=0; AC_SUBST([GNULIB_LINKAT]) 86 GNULIB_GETUSERSHELL=0; AC_SUBST([GNULIB_GETUSERSHELL])
80 GNULIB_LSEEK=0; AC_SUBST([GNULIB_LSEEK]) 87 GNULIB_GROUP_MEMBER=0; AC_SUBST([GNULIB_GROUP_MEMBER])
81 GNULIB_PIPE2=0; AC_SUBST([GNULIB_PIPE2]) 88 GNULIB_ISATTY=0; AC_SUBST([GNULIB_ISATTY])
82 GNULIB_PREAD=0; AC_SUBST([GNULIB_PREAD]) 89 GNULIB_LCHOWN=0; AC_SUBST([GNULIB_LCHOWN])
83 GNULIB_PWRITE=0; AC_SUBST([GNULIB_PWRITE]) 90 GNULIB_LINK=0; AC_SUBST([GNULIB_LINK])
84 GNULIB_READLINK=0; AC_SUBST([GNULIB_READLINK]) 91 GNULIB_LINKAT=0; AC_SUBST([GNULIB_LINKAT])
85 GNULIB_READLINKAT=0; AC_SUBST([GNULIB_READLINKAT]) 92 GNULIB_LSEEK=0; AC_SUBST([GNULIB_LSEEK])
86 GNULIB_RMDIR=0; AC_SUBST([GNULIB_RMDIR]) 93 GNULIB_PIPE=0; AC_SUBST([GNULIB_PIPE])
87 GNULIB_SLEEP=0; AC_SUBST([GNULIB_SLEEP]) 94 GNULIB_PIPE2=0; AC_SUBST([GNULIB_PIPE2])
88 GNULIB_SYMLINK=0; AC_SUBST([GNULIB_SYMLINK]) 95 GNULIB_PREAD=0; AC_SUBST([GNULIB_PREAD])
89 GNULIB_SYMLINKAT=0; AC_SUBST([GNULIB_SYMLINKAT]) 96 GNULIB_PWRITE=0; AC_SUBST([GNULIB_PWRITE])
90 GNULIB_TTYNAME_R=0; AC_SUBST([GNULIB_TTYNAME_R]) 97 GNULIB_READ=0; AC_SUBST([GNULIB_READ])
91 GNULIB_UNISTD_H_GETOPT=0; AC_SUBST([GNULIB_UNISTD_H_GETOPT]) 98 GNULIB_READLINK=0; AC_SUBST([GNULIB_READLINK])
92 GNULIB_UNISTD_H_SIGPIPE=0; AC_SUBST([GNULIB_UNISTD_H_SIGPIPE]) 99 GNULIB_READLINKAT=0; AC_SUBST([GNULIB_READLINKAT])
93 GNULIB_UNLINK=0; AC_SUBST([GNULIB_UNLINK]) 100 GNULIB_RMDIR=0; AC_SUBST([GNULIB_RMDIR])
94 GNULIB_UNLINKAT=0; AC_SUBST([GNULIB_UNLINKAT]) 101 GNULIB_SETHOSTNAME=0; AC_SUBST([GNULIB_SETHOSTNAME])
95 GNULIB_USLEEP=0; AC_SUBST([GNULIB_USLEEP]) 102 GNULIB_SLEEP=0; AC_SUBST([GNULIB_SLEEP])
96 GNULIB_WRITE=0; AC_SUBST([GNULIB_WRITE]) 103 GNULIB_SYMLINK=0; AC_SUBST([GNULIB_SYMLINK])
104 GNULIB_SYMLINKAT=0; AC_SUBST([GNULIB_SYMLINKAT])
105 GNULIB_TTYNAME_R=0; AC_SUBST([GNULIB_TTYNAME_R])
106 GNULIB_UNISTD_H_NONBLOCKING=0; AC_SUBST([GNULIB_UNISTD_H_NONBLOCKING])
107 GNULIB_UNISTD_H_SIGPIPE=0; AC_SUBST([GNULIB_UNISTD_H_SIGPIPE])
108 GNULIB_UNLINK=0; AC_SUBST([GNULIB_UNLINK])
109 GNULIB_UNLINKAT=0; AC_SUBST([GNULIB_UNLINKAT])
110 GNULIB_USLEEP=0; AC_SUBST([GNULIB_USLEEP])
111 GNULIB_WRITE=0; AC_SUBST([GNULIB_WRITE])
97 dnl Assume proper GNU behavior unless another module says otherwise. 112 dnl Assume proper GNU behavior unless another module says otherwise.
98 HAVE_CHOWN=1; AC_SUBST([HAVE_CHOWN]) 113 HAVE_CHOWN=1; AC_SUBST([HAVE_CHOWN])
99 HAVE_DUP2=1; AC_SUBST([HAVE_DUP2]) 114 HAVE_DUP2=1; AC_SUBST([HAVE_DUP2])
@@ -102,32 +117,39 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
102 HAVE_FACCESSAT=1; AC_SUBST([HAVE_FACCESSAT]) 117 HAVE_FACCESSAT=1; AC_SUBST([HAVE_FACCESSAT])
103 HAVE_FCHDIR=1; AC_SUBST([HAVE_FCHDIR]) 118 HAVE_FCHDIR=1; AC_SUBST([HAVE_FCHDIR])
104 HAVE_FCHOWNAT=1; AC_SUBST([HAVE_FCHOWNAT]) 119 HAVE_FCHOWNAT=1; AC_SUBST([HAVE_FCHOWNAT])
120 HAVE_FDATASYNC=1; AC_SUBST([HAVE_FDATASYNC])
105 HAVE_FSYNC=1; AC_SUBST([HAVE_FSYNC]) 121 HAVE_FSYNC=1; AC_SUBST([HAVE_FSYNC])
106 HAVE_FTRUNCATE=1; AC_SUBST([HAVE_FTRUNCATE]) 122 HAVE_FTRUNCATE=1; AC_SUBST([HAVE_FTRUNCATE])
107 HAVE_GETDOMAINNAME=1; AC_SUBST([HAVE_GETDOMAINNAME])
108 HAVE_GETDTABLESIZE=1; AC_SUBST([HAVE_GETDTABLESIZE]) 123 HAVE_GETDTABLESIZE=1; AC_SUBST([HAVE_GETDTABLESIZE])
109 HAVE_GETGROUPS=1; AC_SUBST([HAVE_GETGROUPS]) 124 HAVE_GETGROUPS=1; AC_SUBST([HAVE_GETGROUPS])
110 HAVE_GETHOSTNAME=1; AC_SUBST([HAVE_GETHOSTNAME]) 125 HAVE_GETHOSTNAME=1; AC_SUBST([HAVE_GETHOSTNAME])
111 HAVE_GETLOGIN=1; AC_SUBST([HAVE_GETLOGIN]) 126 HAVE_GETLOGIN=1; AC_SUBST([HAVE_GETLOGIN])
112 HAVE_GETPAGESIZE=1; AC_SUBST([HAVE_GETPAGESIZE]) 127 HAVE_GETPAGESIZE=1; AC_SUBST([HAVE_GETPAGESIZE])
128 HAVE_GROUP_MEMBER=1; AC_SUBST([HAVE_GROUP_MEMBER])
113 HAVE_LCHOWN=1; AC_SUBST([HAVE_LCHOWN]) 129 HAVE_LCHOWN=1; AC_SUBST([HAVE_LCHOWN])
114 HAVE_LINK=1; AC_SUBST([HAVE_LINK]) 130 HAVE_LINK=1; AC_SUBST([HAVE_LINK])
115 HAVE_LINKAT=1; AC_SUBST([HAVE_LINKAT]) 131 HAVE_LINKAT=1; AC_SUBST([HAVE_LINKAT])
132 HAVE_PIPE=1; AC_SUBST([HAVE_PIPE])
116 HAVE_PIPE2=1; AC_SUBST([HAVE_PIPE2]) 133 HAVE_PIPE2=1; AC_SUBST([HAVE_PIPE2])
117 HAVE_PREAD=1; AC_SUBST([HAVE_PREAD]) 134 HAVE_PREAD=1; AC_SUBST([HAVE_PREAD])
118 HAVE_PWRITE=1; AC_SUBST([HAVE_PWRITE]) 135 HAVE_PWRITE=1; AC_SUBST([HAVE_PWRITE])
119 HAVE_READLINK=1; AC_SUBST([HAVE_READLINK]) 136 HAVE_READLINK=1; AC_SUBST([HAVE_READLINK])
120 HAVE_READLINKAT=1; AC_SUBST([HAVE_READLINKAT]) 137 HAVE_READLINKAT=1; AC_SUBST([HAVE_READLINKAT])
138 HAVE_SETHOSTNAME=1; AC_SUBST([HAVE_SETHOSTNAME])
121 HAVE_SLEEP=1; AC_SUBST([HAVE_SLEEP]) 139 HAVE_SLEEP=1; AC_SUBST([HAVE_SLEEP])
122 HAVE_SYMLINK=1; AC_SUBST([HAVE_SYMLINK]) 140 HAVE_SYMLINK=1; AC_SUBST([HAVE_SYMLINK])
123 HAVE_SYMLINKAT=1; AC_SUBST([HAVE_SYMLINKAT]) 141 HAVE_SYMLINKAT=1; AC_SUBST([HAVE_SYMLINKAT])
124 HAVE_TTYNAME_R=1; AC_SUBST([HAVE_TTYNAME_R])
125 HAVE_UNLINKAT=1; AC_SUBST([HAVE_UNLINKAT]) 142 HAVE_UNLINKAT=1; AC_SUBST([HAVE_UNLINKAT])
126 HAVE_USLEEP=1; AC_SUBST([HAVE_USLEEP]) 143 HAVE_USLEEP=1; AC_SUBST([HAVE_USLEEP])
127 HAVE_DECL_ENVIRON=1; AC_SUBST([HAVE_DECL_ENVIRON]) 144 HAVE_DECL_ENVIRON=1; AC_SUBST([HAVE_DECL_ENVIRON])
145 HAVE_DECL_FCHDIR=1; AC_SUBST([HAVE_DECL_FCHDIR])
146 HAVE_DECL_FDATASYNC=1; AC_SUBST([HAVE_DECL_FDATASYNC])
147 HAVE_DECL_GETDOMAINNAME=1; AC_SUBST([HAVE_DECL_GETDOMAINNAME])
128 HAVE_DECL_GETLOGIN_R=1; AC_SUBST([HAVE_DECL_GETLOGIN_R]) 148 HAVE_DECL_GETLOGIN_R=1; AC_SUBST([HAVE_DECL_GETLOGIN_R])
129 HAVE_DECL_GETPAGESIZE=1; AC_SUBST([HAVE_DECL_GETPAGESIZE]) 149 HAVE_DECL_GETPAGESIZE=1; AC_SUBST([HAVE_DECL_GETPAGESIZE])
130 HAVE_DECL_GETUSERSHELL=1; AC_SUBST([HAVE_DECL_GETUSERSHELL]) 150 HAVE_DECL_GETUSERSHELL=1; AC_SUBST([HAVE_DECL_GETUSERSHELL])
151 HAVE_DECL_SETHOSTNAME=1; AC_SUBST([HAVE_DECL_SETHOSTNAME])
152 HAVE_DECL_TTYNAME_R=1; AC_SUBST([HAVE_DECL_TTYNAME_R])
131 HAVE_OS_H=0; AC_SUBST([HAVE_OS_H]) 153 HAVE_OS_H=0; AC_SUBST([HAVE_OS_H])
132 HAVE_SYS_PARAM_H=0; AC_SUBST([HAVE_SYS_PARAM_H]) 154 HAVE_SYS_PARAM_H=0; AC_SUBST([HAVE_SYS_PARAM_H])
133 REPLACE_CHOWN=0; AC_SUBST([REPLACE_CHOWN]) 155 REPLACE_CHOWN=0; AC_SUBST([REPLACE_CHOWN])
@@ -135,15 +157,20 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
135 REPLACE_DUP=0; AC_SUBST([REPLACE_DUP]) 157 REPLACE_DUP=0; AC_SUBST([REPLACE_DUP])
136 REPLACE_DUP2=0; AC_SUBST([REPLACE_DUP2]) 158 REPLACE_DUP2=0; AC_SUBST([REPLACE_DUP2])
137 REPLACE_FCHOWNAT=0; AC_SUBST([REPLACE_FCHOWNAT]) 159 REPLACE_FCHOWNAT=0; AC_SUBST([REPLACE_FCHOWNAT])
160 REPLACE_FTRUNCATE=0; AC_SUBST([REPLACE_FTRUNCATE])
138 REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD]) 161 REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD])
162 REPLACE_GETDOMAINNAME=0; AC_SUBST([REPLACE_GETDOMAINNAME])
163 REPLACE_GETLOGIN_R=0; AC_SUBST([REPLACE_GETLOGIN_R])
139 REPLACE_GETGROUPS=0; AC_SUBST([REPLACE_GETGROUPS]) 164 REPLACE_GETGROUPS=0; AC_SUBST([REPLACE_GETGROUPS])
140 REPLACE_GETPAGESIZE=0; AC_SUBST([REPLACE_GETPAGESIZE]) 165 REPLACE_GETPAGESIZE=0; AC_SUBST([REPLACE_GETPAGESIZE])
166 REPLACE_ISATTY=0; AC_SUBST([REPLACE_ISATTY])
141 REPLACE_LCHOWN=0; AC_SUBST([REPLACE_LCHOWN]) 167 REPLACE_LCHOWN=0; AC_SUBST([REPLACE_LCHOWN])
142 REPLACE_LINK=0; AC_SUBST([REPLACE_LINK]) 168 REPLACE_LINK=0; AC_SUBST([REPLACE_LINK])
143 REPLACE_LINKAT=0; AC_SUBST([REPLACE_LINKAT]) 169 REPLACE_LINKAT=0; AC_SUBST([REPLACE_LINKAT])
144 REPLACE_LSEEK=0; AC_SUBST([REPLACE_LSEEK]) 170 REPLACE_LSEEK=0; AC_SUBST([REPLACE_LSEEK])
145 REPLACE_PREAD=0; AC_SUBST([REPLACE_PREAD]) 171 REPLACE_PREAD=0; AC_SUBST([REPLACE_PREAD])
146 REPLACE_PWRITE=0; AC_SUBST([REPLACE_PWRITE]) 172 REPLACE_PWRITE=0; AC_SUBST([REPLACE_PWRITE])
173 REPLACE_READ=0; AC_SUBST([REPLACE_READ])
147 REPLACE_READLINK=0; AC_SUBST([REPLACE_READLINK]) 174 REPLACE_READLINK=0; AC_SUBST([REPLACE_READLINK])
148 REPLACE_RMDIR=0; AC_SUBST([REPLACE_RMDIR]) 175 REPLACE_RMDIR=0; AC_SUBST([REPLACE_RMDIR])
149 REPLACE_SLEEP=0; AC_SUBST([REPLACE_SLEEP]) 176 REPLACE_SLEEP=0; AC_SUBST([REPLACE_SLEEP])
diff --git a/gl/m4/vasnprintf.m4 b/gl/m4/vasnprintf.m4
index ebe3c52..d730e43 100644
--- a/gl/m4/vasnprintf.m4
+++ b/gl/m4/vasnprintf.m4
@@ -1,5 +1,5 @@
1# vasnprintf.m4 serial 31 1# vasnprintf.m4 serial 36
2dnl Copyright (C) 2002-2004, 2006-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2004, 2006-2013 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.
@@ -29,7 +29,7 @@ AC_DEFUN([gl_REPLACE_VASNPRINTF],
29 gl_PREREQ_ASNPRINTF 29 gl_PREREQ_ASNPRINTF
30]) 30])
31 31
32# Prequisites of lib/printf-args.h, lib/printf-args.c. 32# Prerequisites of lib/printf-args.h, lib/printf-args.c.
33AC_DEFUN([gl_PREREQ_PRINTF_ARGS], 33AC_DEFUN([gl_PREREQ_PRINTF_ARGS],
34[ 34[
35 AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) 35 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
@@ -37,9 +37,10 @@ AC_DEFUN([gl_PREREQ_PRINTF_ARGS],
37 AC_REQUIRE([gt_TYPE_WINT_T]) 37 AC_REQUIRE([gt_TYPE_WINT_T])
38]) 38])
39 39
40# Prequisites of lib/printf-parse.h, lib/printf-parse.c. 40# Prerequisites of lib/printf-parse.h, lib/printf-parse.c.
41AC_DEFUN([gl_PREREQ_PRINTF_PARSE], 41AC_DEFUN([gl_PREREQ_PRINTF_PARSE],
42[ 42[
43 AC_REQUIRE([gl_FEATURES_H])
43 AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) 44 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
44 AC_REQUIRE([gt_TYPE_WCHAR_T]) 45 AC_REQUIRE([gt_TYPE_WCHAR_T])
45 AC_REQUIRE([gt_TYPE_WINT_T]) 46 AC_REQUIRE([gt_TYPE_WINT_T])
@@ -54,7 +55,6 @@ AC_DEFUN([gl_PREREQ_PRINTF_PARSE],
54# Prerequisites of lib/vasnprintf.c. 55# Prerequisites of lib/vasnprintf.c.
55AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF], 56AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF],
56[ 57[
57 AC_REQUIRE([AC_C_INLINE])
58 AC_REQUIRE([AC_FUNC_ALLOCA]) 58 AC_REQUIRE([AC_FUNC_ALLOCA])
59 AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) 59 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
60 AC_REQUIRE([gt_TYPE_WCHAR_T]) 60 AC_REQUIRE([gt_TYPE_WCHAR_T])
@@ -62,7 +62,10 @@ AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF],
62 AC_CHECK_FUNCS([snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb]) 62 AC_CHECK_FUNCS([snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb])
63 dnl Use the _snprintf function only if it is declared (because on NetBSD it 63 dnl Use the _snprintf function only if it is declared (because on NetBSD it
64 dnl is defined as a weak alias of snprintf; we prefer to use the latter). 64 dnl is defined as a weak alias of snprintf; we prefer to use the latter).
65 AC_CHECK_DECLS([_snprintf], , , [#include <stdio.h>]) 65 AC_CHECK_DECLS([_snprintf], , , [[#include <stdio.h>]])
66 dnl Knowing DBL_EXPBIT0_WORD and DBL_EXPBIT0_BIT enables an optimization
67 dnl in the code for NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE.
68 AC_REQUIRE([gl_DOUBLE_EXPONENT_LOCATION])
66 dnl We can avoid a lot of code by assuming that snprintf's return value 69 dnl We can avoid a lot of code by assuming that snprintf's return value
67 dnl conforms to ISO C99. So check that. 70 dnl conforms to ISO C99. So check that.
68 AC_REQUIRE([gl_SNPRINTF_RETVAL_C99]) 71 AC_REQUIRE([gl_SNPRINTF_RETVAL_C99])
diff --git a/gl/m4/vasprintf.m4 b/gl/m4/vasprintf.m4
index b142bc0..c214ff1 100644
--- a/gl/m4/vasprintf.m4
+++ b/gl/m4/vasprintf.m4
@@ -1,5 +1,5 @@
1# vasprintf.m4 serial 6 1# vasprintf.m4 serial 6
2dnl Copyright (C) 2002-2003, 2006-2007, 2009-2010 Free Software Foundation, 2dnl Copyright (C) 2002-2003, 2006-2007, 2009-2013 Free Software Foundation,
3dnl Inc. 3dnl Inc.
4dnl This file is free software; the Free Software Foundation 4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 5dnl gives unlimited permission to copy and/or distribute it,
diff --git a/gl/m4/visibility.m4 b/gl/m4/visibility.m4
index 077c476..6cbd7e5 100644
--- a/gl/m4/visibility.m4
+++ b/gl/m4/visibility.m4
@@ -1,5 +1,5 @@
1# visibility.m4 serial 3 (gettext-0.18) 1# visibility.m4 serial 5 (gettext-0.18.2)
2dnl Copyright (C) 2005, 2008-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2005, 2008, 2010-2013 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 @@ dnl __attribute__((__visibility__("hidden"))) and
12dnl __attribute__((__visibility__("default"))). 12dnl __attribute__((__visibility__("default"))).
13dnl Does *not* test for __visibility__("protected") - which has tricky 13dnl Does *not* test for __visibility__("protected") - which has tricky
14dnl semantics (see the 'vismain' test in glibc) and does not exist e.g. on 14dnl semantics (see the 'vismain' test in glibc) and does not exist e.g. on
15dnl MacOS X. 15dnl Mac OS X.
16dnl Does *not* test for __visibility__("internal") - which has processor 16dnl Does *not* test for __visibility__("internal") - which has processor
17dnl dependent semantics. 17dnl dependent semantics.
18dnl Does *not* test for #pragma GCC visibility push(hidden) - which is 18dnl Does *not* test for #pragma GCC visibility push(hidden) - which is
@@ -33,7 +33,8 @@ AC_DEFUN([gl_VISIBILITY],
33 AC_CACHE_VAL([gl_cv_cc_vis_werror], [ 33 AC_CACHE_VAL([gl_cv_cc_vis_werror], [
34 gl_save_CFLAGS="$CFLAGS" 34 gl_save_CFLAGS="$CFLAGS"
35 CFLAGS="$CFLAGS -Werror" 35 CFLAGS="$CFLAGS -Werror"
36 AC_TRY_COMPILE([], [], 36 AC_COMPILE_IFELSE(
37 [AC_LANG_PROGRAM([[]], [[]])],
37 [gl_cv_cc_vis_werror=yes], 38 [gl_cv_cc_vis_werror=yes],
38 [gl_cv_cc_vis_werror=no]) 39 [gl_cv_cc_vis_werror=no])
39 CFLAGS="$gl_save_CFLAGS"]) 40 CFLAGS="$gl_save_CFLAGS"])
@@ -51,13 +52,15 @@ AC_DEFUN([gl_VISIBILITY],
51 if test $gl_cv_cc_vis_werror = yes; then 52 if test $gl_cv_cc_vis_werror = yes; then
52 CFLAGS="$CFLAGS -Werror" 53 CFLAGS="$CFLAGS -Werror"
53 fi 54 fi
54 AC_TRY_COMPILE( 55 AC_COMPILE_IFELSE(
55 [extern __attribute__((__visibility__("hidden"))) int hiddenvar; 56 [AC_LANG_PROGRAM(
56 extern __attribute__((__visibility__("default"))) int exportedvar; 57 [[extern __attribute__((__visibility__("hidden"))) int hiddenvar;
57 extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void); 58 extern __attribute__((__visibility__("default"))) int exportedvar;
58 extern __attribute__((__visibility__("default"))) int exportedfunc (void); 59 extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void);
59 void dummyfunc (void) {}], 60 extern __attribute__((__visibility__("default"))) int exportedfunc (void);
60 [], 61 void dummyfunc (void) {}
62 ]],
63 [[]])],
61 [gl_cv_cc_visibility=yes], 64 [gl_cv_cc_visibility=yes],
62 [gl_cv_cc_visibility=no]) 65 [gl_cv_cc_visibility=no])
63 CFLAGS="$gl_save_CFLAGS"]) 66 CFLAGS="$gl_save_CFLAGS"])
diff --git a/gl/m4/vsnprintf.m4 b/gl/m4/vsnprintf.m4
index ed189c2..4900764 100644
--- a/gl/m4/vsnprintf.m4
+++ b/gl/m4/vsnprintf.m4
@@ -1,9 +1,13 @@
1# vsnprintf.m4 serial 5 1# vsnprintf.m4 serial 6
2dnl Copyright (C) 2002-2004, 2007-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2004, 2007-2013 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 Libintl 0.17 will replace vsnprintf only if it does not support %1$s,
8dnl but defers to any gnulib vsnprintf replacements. Therefore, gnulib
9dnl must guarantee that the decision for replacing vsnprintf is a superset
10dnl of the reasons checked by libintl.
7AC_DEFUN([gl_FUNC_VSNPRINTF], 11AC_DEFUN([gl_FUNC_VSNPRINTF],
8[ 12[
9 AC_REQUIRE([gl_STDIO_H_DEFAULTS]) 13 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
@@ -13,7 +17,17 @@ AC_DEFUN([gl_FUNC_VSNPRINTF],
13 gl_SNPRINTF_SIZE1 17 gl_SNPRINTF_SIZE1
14 case "$gl_cv_func_snprintf_size1" in 18 case "$gl_cv_func_snprintf_size1" in
15 *yes) 19 *yes)
16 gl_cv_func_vsnprintf_usable=yes 20 gl_SNPRINTF_RETVAL_C99
21 case "$gl_cv_func_snprintf_retval_c99" in
22 *yes)
23 gl_PRINTF_POSITIONS
24 case "$gl_cv_func_printf_positions" in
25 *yes)
26 gl_cv_func_vsnprintf_usable=yes
27 ;;
28 esac
29 ;;
30 esac
17 ;; 31 ;;
18 esac 32 esac
19 fi 33 fi
diff --git a/gl/m4/warn-on-use.m4 b/gl/m4/warn-on-use.m4
index 42daae8..e43beeb 100644
--- a/gl/m4/warn-on-use.m4
+++ b/gl/m4/warn-on-use.m4
@@ -1,5 +1,5 @@
1# warn-on-use.m4 serial 2 1# warn-on-use.m4 serial 5
2dnl Copyright (C) 2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2010-2013 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.
@@ -18,8 +18,8 @@ dnl with or without modifications, as long as this notice is preserved.
18# some systems declare functions in the wrong header, then INCLUDES 18# some systems declare functions in the wrong header, then INCLUDES
19# should do likewise. 19# should do likewise.
20# 20#
21# If you assume C89, then it is generally safe to assume declarations 21# It is generally safe to assume declarations for functions declared
22# for functions declared in that standard (such as gets) without 22# in the intersection of C89 and C11 (such as printf) without
23# needing gl_WARN_ON_USE_PREPARE. 23# needing gl_WARN_ON_USE_PREPARE.
24AC_DEFUN([gl_WARN_ON_USE_PREPARE], 24AC_DEFUN([gl_WARN_ON_USE_PREPARE],
25[ 25[
@@ -27,6 +27,8 @@ AC_DEFUN([gl_WARN_ON_USE_PREPARE],
27 [AH_TEMPLATE([HAVE_RAW_DECL_]AS_TR_CPP(m4_defn([gl_decl])), 27 [AH_TEMPLATE([HAVE_RAW_DECL_]AS_TR_CPP(m4_defn([gl_decl])),
28 [Define to 1 if ]m4_defn([gl_decl])[ is declared even after 28 [Define to 1 if ]m4_defn([gl_decl])[ is declared even after
29 undefining macros.])])dnl 29 undefining macros.])])dnl
30dnl FIXME: gl_Symbol must be used unquoted until we can assume
31dnl autoconf 2.64 or newer.
30 for gl_func in m4_flatten([$2]); do 32 for gl_func in m4_flatten([$2]); do
31 AS_VAR_PUSHDEF([gl_Symbol], [gl_cv_have_raw_decl_$gl_func])dnl 33 AS_VAR_PUSHDEF([gl_Symbol], [gl_cv_have_raw_decl_$gl_func])dnl
32 AC_CACHE_CHECK([whether $gl_func is declared without a macro], 34 AC_CACHE_CHECK([whether $gl_func is declared without a macro],
@@ -35,8 +37,8 @@ AC_DEFUN([gl_WARN_ON_USE_PREPARE],
35[@%:@undef $gl_func 37[@%:@undef $gl_func
36 (void) $gl_func;])], 38 (void) $gl_func;])],
37 [AS_VAR_SET(gl_Symbol, [yes])], [AS_VAR_SET(gl_Symbol, [no])])]) 39 [AS_VAR_SET(gl_Symbol, [yes])], [AS_VAR_SET(gl_Symbol, [no])])])
38 AS_VAR_IF(gl_Symbol, [yes], 40 AS_VAR_IF(gl_Symbol, [yes],
39 [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_RAW_DECL_$gl_func]), [1]) 41 [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_RAW_DECL_$gl_func]), [1])
40 dnl shortcut - if the raw declaration exists, then set a cache 42 dnl shortcut - if the raw declaration exists, then set a cache
41 dnl variable to allow skipping any later AC_CHECK_DECL efforts 43 dnl variable to allow skipping any later AC_CHECK_DECL efforts
42 eval ac_cv_have_decl_$gl_func=yes]) 44 eval ac_cv_have_decl_$gl_func=yes])
diff --git a/gl/m4/wchar_h.m4 b/gl/m4/wchar_h.m4
index 8cae82d..bedb15a 100644
--- a/gl/m4/wchar_h.m4
+++ b/gl/m4/wchar_h.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-2010 Free Software Foundation, Inc. 3dnl Copyright (C) 2007-2013 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_h.m4 serial 33 10# wchar_h.m4 serial 39
11 11
12AC_DEFUN([gl_WCHAR_H], 12AC_DEFUN([gl_WCHAR_H],
13[ 13[
@@ -17,7 +17,6 @@ AC_DEFUN([gl_WCHAR_H],
17 dnl Check for <wchar.h> (missing in Linux uClibc when built without wide 17 dnl Check for <wchar.h> (missing in Linux uClibc when built without wide
18 dnl character support). 18 dnl character support).
19 dnl <wchar.h> is always overridden, because of GNULIB_POSIXCHECK. 19 dnl <wchar.h> is always overridden, because of GNULIB_POSIXCHECK.
20 AC_CHECK_HEADERS_ONCE([wchar.h])
21 gl_CHECK_NEXT_HEADERS([wchar.h]) 20 gl_CHECK_NEXT_HEADERS([wchar.h])
22 if test $ac_cv_header_wchar_h = yes; then 21 if test $ac_cv_header_wchar_h = yes; then
23 HAVE_WCHAR_H=1 22 HAVE_WCHAR_H=1
@@ -26,6 +25,8 @@ AC_DEFUN([gl_WCHAR_H],
26 fi 25 fi
27 AC_SUBST([HAVE_WCHAR_H]) 26 AC_SUBST([HAVE_WCHAR_H])
28 27
28 AC_REQUIRE([gl_FEATURES_H])
29
29 AC_REQUIRE([gt_TYPE_WINT_T]) 30 AC_REQUIRE([gt_TYPE_WINT_T])
30 if test $gt_cv_c_wint_t = yes; then 31 if test $gt_cv_c_wint_t = yes; then
31 HAVE_WINT_T=1 32 HAVE_WINT_T=1
@@ -37,15 +38,23 @@ AC_DEFUN([gl_WCHAR_H],
37 dnl Check for declarations of anything we want to poison if the 38 dnl Check for declarations of anything we want to poison if the
38 dnl corresponding gnulib module is not in use. 39 dnl corresponding gnulib module is not in use.
39 gl_WARN_ON_USE_PREPARE([[ 40 gl_WARN_ON_USE_PREPARE([[
40/* Some systems require additional headers. */ 41/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
41#ifndef __GLIBC__ 42 <wchar.h>.
43 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
44 included before <wchar.h>. */
45#if !(defined __GLIBC__ && !defined __UCLIBC__)
42# include <stddef.h> 46# include <stddef.h>
43# include <stdio.h> 47# include <stdio.h>
44# include <time.h> 48# include <time.h>
45#endif 49#endif
46#include <wchar.h> 50#include <wchar.h>
47 ]], [btowc wctob mbsinit mbrtowc mbrlen mbsrtowcs mbsnrtowcs wcrtomb 51 ]],
48 wcsrtombs wcsnrtombs wcwidth]) 52 [btowc wctob mbsinit mbrtowc mbrlen mbsrtowcs mbsnrtowcs wcrtomb
53 wcsrtombs wcsnrtombs wcwidth wmemchr wmemcmp wmemcpy wmemmove wmemset
54 wcslen wcsnlen wcscpy wcpcpy wcsncpy wcpncpy wcscat wcsncat wcscmp
55 wcsncmp wcscasecmp wcsncasecmp wcscoll wcsxfrm wcsdup wcschr wcsrchr
56 wcscspn wcsspn wcspbrk wcsstr wcstok wcswidth
57 ])
49]) 58])
50 59
51dnl Check whether <wchar.h> is usable at all. 60dnl Check whether <wchar.h> is usable at all.
@@ -61,6 +70,13 @@ AC_DEFUN([gl_WCHAR_H_INLINE_OK],
61 [gl_cv_header_wchar_h_correct_inline=yes 70 [gl_cv_header_wchar_h_correct_inline=yes
62 AC_LANG_CONFTEST([ 71 AC_LANG_CONFTEST([
63 AC_LANG_SOURCE([[#define wcstod renamed_wcstod 72 AC_LANG_SOURCE([[#define wcstod renamed_wcstod
73/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
74 <wchar.h>.
75 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
76 included before <wchar.h>. */
77#include <stddef.h>
78#include <stdio.h>
79#include <time.h>
64#include <wchar.h> 80#include <wchar.h>
65extern int zero (void); 81extern int zero (void);
66int main () { return zero(); } 82int main () { return zero(); }
@@ -69,6 +85,13 @@ int main () { return zero(); }
69 mv conftest.$ac_objext conftest1.$ac_objext 85 mv conftest.$ac_objext conftest1.$ac_objext
70 AC_LANG_CONFTEST([ 86 AC_LANG_CONFTEST([
71 AC_LANG_SOURCE([[#define wcstod renamed_wcstod 87 AC_LANG_SOURCE([[#define wcstod renamed_wcstod
88/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
89 <wchar.h>.
90 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
91 included before <wchar.h>. */
92#include <stddef.h>
93#include <stdio.h>
94#include <time.h>
72#include <wchar.h> 95#include <wchar.h>
73int zero (void) { return 0; } 96int zero (void) { return 0; }
74]])]) 97]])])
@@ -96,13 +119,6 @@ Configuration aborted.])
96 fi 119 fi
97]) 120])
98 121
99dnl Unconditionally enables the replacement of <wchar.h>.
100AC_DEFUN([gl_REPLACE_WCHAR_H],
101[
102 dnl This is a no-op, because <wchar.h> is always overridden.
103 :
104])
105
106AC_DEFUN([gl_WCHAR_MODULE_INDICATOR], 122AC_DEFUN([gl_WCHAR_MODULE_INDICATOR],
107[ 123[
108 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 124 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
@@ -114,17 +130,45 @@ AC_DEFUN([gl_WCHAR_MODULE_INDICATOR],
114 130
115AC_DEFUN([gl_WCHAR_H_DEFAULTS], 131AC_DEFUN([gl_WCHAR_H_DEFAULTS],
116[ 132[
117 GNULIB_BTOWC=0; AC_SUBST([GNULIB_BTOWC]) 133 GNULIB_BTOWC=0; AC_SUBST([GNULIB_BTOWC])
118 GNULIB_WCTOB=0; AC_SUBST([GNULIB_WCTOB]) 134 GNULIB_WCTOB=0; AC_SUBST([GNULIB_WCTOB])
119 GNULIB_MBSINIT=0; AC_SUBST([GNULIB_MBSINIT]) 135 GNULIB_MBSINIT=0; AC_SUBST([GNULIB_MBSINIT])
120 GNULIB_MBRTOWC=0; AC_SUBST([GNULIB_MBRTOWC]) 136 GNULIB_MBRTOWC=0; AC_SUBST([GNULIB_MBRTOWC])
121 GNULIB_MBRLEN=0; AC_SUBST([GNULIB_MBRLEN]) 137 GNULIB_MBRLEN=0; AC_SUBST([GNULIB_MBRLEN])
122 GNULIB_MBSRTOWCS=0; AC_SUBST([GNULIB_MBSRTOWCS]) 138 GNULIB_MBSRTOWCS=0; AC_SUBST([GNULIB_MBSRTOWCS])
123 GNULIB_MBSNRTOWCS=0; AC_SUBST([GNULIB_MBSNRTOWCS]) 139 GNULIB_MBSNRTOWCS=0; AC_SUBST([GNULIB_MBSNRTOWCS])
124 GNULIB_WCRTOMB=0; AC_SUBST([GNULIB_WCRTOMB]) 140 GNULIB_WCRTOMB=0; AC_SUBST([GNULIB_WCRTOMB])
125 GNULIB_WCSRTOMBS=0; AC_SUBST([GNULIB_WCSRTOMBS]) 141 GNULIB_WCSRTOMBS=0; AC_SUBST([GNULIB_WCSRTOMBS])
126 GNULIB_WCSNRTOMBS=0; AC_SUBST([GNULIB_WCSNRTOMBS]) 142 GNULIB_WCSNRTOMBS=0; AC_SUBST([GNULIB_WCSNRTOMBS])
127 GNULIB_WCWIDTH=0; AC_SUBST([GNULIB_WCWIDTH]) 143 GNULIB_WCWIDTH=0; AC_SUBST([GNULIB_WCWIDTH])
144 GNULIB_WMEMCHR=0; AC_SUBST([GNULIB_WMEMCHR])
145 GNULIB_WMEMCMP=0; AC_SUBST([GNULIB_WMEMCMP])
146 GNULIB_WMEMCPY=0; AC_SUBST([GNULIB_WMEMCPY])
147 GNULIB_WMEMMOVE=0; AC_SUBST([GNULIB_WMEMMOVE])
148 GNULIB_WMEMSET=0; AC_SUBST([GNULIB_WMEMSET])
149 GNULIB_WCSLEN=0; AC_SUBST([GNULIB_WCSLEN])
150 GNULIB_WCSNLEN=0; AC_SUBST([GNULIB_WCSNLEN])
151 GNULIB_WCSCPY=0; AC_SUBST([GNULIB_WCSCPY])
152 GNULIB_WCPCPY=0; AC_SUBST([GNULIB_WCPCPY])
153 GNULIB_WCSNCPY=0; AC_SUBST([GNULIB_WCSNCPY])
154 GNULIB_WCPNCPY=0; AC_SUBST([GNULIB_WCPNCPY])
155 GNULIB_WCSCAT=0; AC_SUBST([GNULIB_WCSCAT])
156 GNULIB_WCSNCAT=0; AC_SUBST([GNULIB_WCSNCAT])
157 GNULIB_WCSCMP=0; AC_SUBST([GNULIB_WCSCMP])
158 GNULIB_WCSNCMP=0; AC_SUBST([GNULIB_WCSNCMP])
159 GNULIB_WCSCASECMP=0; AC_SUBST([GNULIB_WCSCASECMP])
160 GNULIB_WCSNCASECMP=0; AC_SUBST([GNULIB_WCSNCASECMP])
161 GNULIB_WCSCOLL=0; AC_SUBST([GNULIB_WCSCOLL])
162 GNULIB_WCSXFRM=0; AC_SUBST([GNULIB_WCSXFRM])
163 GNULIB_WCSDUP=0; AC_SUBST([GNULIB_WCSDUP])
164 GNULIB_WCSCHR=0; AC_SUBST([GNULIB_WCSCHR])
165 GNULIB_WCSRCHR=0; AC_SUBST([GNULIB_WCSRCHR])
166 GNULIB_WCSCSPN=0; AC_SUBST([GNULIB_WCSCSPN])
167 GNULIB_WCSSPN=0; AC_SUBST([GNULIB_WCSSPN])
168 GNULIB_WCSPBRK=0; AC_SUBST([GNULIB_WCSPBRK])
169 GNULIB_WCSSTR=0; AC_SUBST([GNULIB_WCSSTR])
170 GNULIB_WCSTOK=0; AC_SUBST([GNULIB_WCSTOK])
171 GNULIB_WCSWIDTH=0; AC_SUBST([GNULIB_WCSWIDTH])
128 dnl Assume proper GNU behavior unless another module says otherwise. 172 dnl Assume proper GNU behavior unless another module says otherwise.
129 HAVE_BTOWC=1; AC_SUBST([HAVE_BTOWC]) 173 HAVE_BTOWC=1; AC_SUBST([HAVE_BTOWC])
130 HAVE_MBSINIT=1; AC_SUBST([HAVE_MBSINIT]) 174 HAVE_MBSINIT=1; AC_SUBST([HAVE_MBSINIT])
@@ -135,6 +179,34 @@ AC_DEFUN([gl_WCHAR_H_DEFAULTS],
135 HAVE_WCRTOMB=1; AC_SUBST([HAVE_WCRTOMB]) 179 HAVE_WCRTOMB=1; AC_SUBST([HAVE_WCRTOMB])
136 HAVE_WCSRTOMBS=1; AC_SUBST([HAVE_WCSRTOMBS]) 180 HAVE_WCSRTOMBS=1; AC_SUBST([HAVE_WCSRTOMBS])
137 HAVE_WCSNRTOMBS=1; AC_SUBST([HAVE_WCSNRTOMBS]) 181 HAVE_WCSNRTOMBS=1; AC_SUBST([HAVE_WCSNRTOMBS])
182 HAVE_WMEMCHR=1; AC_SUBST([HAVE_WMEMCHR])
183 HAVE_WMEMCMP=1; AC_SUBST([HAVE_WMEMCMP])
184 HAVE_WMEMCPY=1; AC_SUBST([HAVE_WMEMCPY])
185 HAVE_WMEMMOVE=1; AC_SUBST([HAVE_WMEMMOVE])
186 HAVE_WMEMSET=1; AC_SUBST([HAVE_WMEMSET])
187 HAVE_WCSLEN=1; AC_SUBST([HAVE_WCSLEN])
188 HAVE_WCSNLEN=1; AC_SUBST([HAVE_WCSNLEN])
189 HAVE_WCSCPY=1; AC_SUBST([HAVE_WCSCPY])
190 HAVE_WCPCPY=1; AC_SUBST([HAVE_WCPCPY])
191 HAVE_WCSNCPY=1; AC_SUBST([HAVE_WCSNCPY])
192 HAVE_WCPNCPY=1; AC_SUBST([HAVE_WCPNCPY])
193 HAVE_WCSCAT=1; AC_SUBST([HAVE_WCSCAT])
194 HAVE_WCSNCAT=1; AC_SUBST([HAVE_WCSNCAT])
195 HAVE_WCSCMP=1; AC_SUBST([HAVE_WCSCMP])
196 HAVE_WCSNCMP=1; AC_SUBST([HAVE_WCSNCMP])
197 HAVE_WCSCASECMP=1; AC_SUBST([HAVE_WCSCASECMP])
198 HAVE_WCSNCASECMP=1; AC_SUBST([HAVE_WCSNCASECMP])
199 HAVE_WCSCOLL=1; AC_SUBST([HAVE_WCSCOLL])
200 HAVE_WCSXFRM=1; AC_SUBST([HAVE_WCSXFRM])
201 HAVE_WCSDUP=1; AC_SUBST([HAVE_WCSDUP])
202 HAVE_WCSCHR=1; AC_SUBST([HAVE_WCSCHR])
203 HAVE_WCSRCHR=1; AC_SUBST([HAVE_WCSRCHR])
204 HAVE_WCSCSPN=1; AC_SUBST([HAVE_WCSCSPN])
205 HAVE_WCSSPN=1; AC_SUBST([HAVE_WCSSPN])
206 HAVE_WCSPBRK=1; AC_SUBST([HAVE_WCSPBRK])
207 HAVE_WCSSTR=1; AC_SUBST([HAVE_WCSSTR])
208 HAVE_WCSTOK=1; AC_SUBST([HAVE_WCSTOK])
209 HAVE_WCSWIDTH=1; AC_SUBST([HAVE_WCSWIDTH])
138 HAVE_DECL_WCTOB=1; AC_SUBST([HAVE_DECL_WCTOB]) 210 HAVE_DECL_WCTOB=1; AC_SUBST([HAVE_DECL_WCTOB])
139 HAVE_DECL_WCWIDTH=1; AC_SUBST([HAVE_DECL_WCWIDTH]) 211 HAVE_DECL_WCWIDTH=1; AC_SUBST([HAVE_DECL_WCWIDTH])
140 REPLACE_MBSTATE_T=0; AC_SUBST([REPLACE_MBSTATE_T]) 212 REPLACE_MBSTATE_T=0; AC_SUBST([REPLACE_MBSTATE_T])
@@ -149,4 +221,5 @@ AC_DEFUN([gl_WCHAR_H_DEFAULTS],
149 REPLACE_WCSRTOMBS=0; AC_SUBST([REPLACE_WCSRTOMBS]) 221 REPLACE_WCSRTOMBS=0; AC_SUBST([REPLACE_WCSRTOMBS])
150 REPLACE_WCSNRTOMBS=0; AC_SUBST([REPLACE_WCSNRTOMBS]) 222 REPLACE_WCSNRTOMBS=0; AC_SUBST([REPLACE_WCSNRTOMBS])
151 REPLACE_WCWIDTH=0; AC_SUBST([REPLACE_WCWIDTH]) 223 REPLACE_WCWIDTH=0; AC_SUBST([REPLACE_WCWIDTH])
224 REPLACE_WCSWIDTH=0; AC_SUBST([REPLACE_WCSWIDTH])
152]) 225])
diff --git a/gl/m4/wchar_t.m4 b/gl/m4/wchar_t.m4
index ed804e6..e1e1e69 100644
--- a/gl/m4/wchar_t.m4
+++ b/gl/m4/wchar_t.m4
@@ -1,5 +1,5 @@
1# wchar_t.m4 serial 3 (gettext-0.18) 1# wchar_t.m4 serial 4 (gettext-0.18.2)
2dnl Copyright (C) 2002-2003, 2008-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2002-2003, 2008-2013 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,9 +11,13 @@ dnl Prerequisite: AC_PROG_CC
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_COMPILE_IFELSE(
15 wchar_t foo = (wchar_t)'\0';], , 15 [AC_LANG_PROGRAM(
16 [gt_cv_c_wchar_t=yes], [gt_cv_c_wchar_t=no])]) 16 [[#include <stddef.h>
17 wchar_t foo = (wchar_t)'\0';]],
18 [[]])],
19 [gt_cv_c_wchar_t=yes],
20 [gt_cv_c_wchar_t=no])])
17 if test $gt_cv_c_wchar_t = yes; then 21 if test $gt_cv_c_wchar_t = yes; then
18 AC_DEFINE([HAVE_WCHAR_T], [1], [Define if you have the 'wchar_t' type.]) 22 AC_DEFINE([HAVE_WCHAR_T], [1], [Define if you have the 'wchar_t' type.])
19 fi 23 fi
diff --git a/gl/m4/wcrtomb.m4 b/gl/m4/wcrtomb.m4
index 6a2d772..f56b5ba 100644
--- a/gl/m4/wcrtomb.m4
+++ b/gl/m4/wcrtomb.m4
@@ -1,5 +1,5 @@
1# wcrtomb.m4 serial 5 1# wcrtomb.m4 serial 11
2dnl Copyright (C) 2008-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2008-2013 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.
@@ -14,6 +14,22 @@ AC_DEFUN([gl_FUNC_WCRTOMB],
14 AC_CHECK_FUNCS_ONCE([wcrtomb]) 14 AC_CHECK_FUNCS_ONCE([wcrtomb])
15 if test $ac_cv_func_wcrtomb = no; then 15 if test $ac_cv_func_wcrtomb = no; then
16 HAVE_WCRTOMB=0 16 HAVE_WCRTOMB=0
17 AC_CHECK_DECLS([wcrtomb],,, [[
18/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
19 <wchar.h>.
20 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
21 included before <wchar.h>. */
22#include <stddef.h>
23#include <stdio.h>
24#include <time.h>
25#include <wchar.h>
26]])
27 if test $ac_cv_have_decl_wcrtomb = yes; then
28 dnl On Minix 3.1.8, the system's <wchar.h> declares wcrtomb() although
29 dnl it does not have the function. Avoid a collision with gnulib's
30 dnl replacement.
31 REPLACE_WCRTOMB=1
32 fi
17 else 33 else
18 if test $REPLACE_MBSTATE_T = 1; then 34 if test $REPLACE_MBSTATE_T = 1; then
19 REPLACE_WCRTOMB=1 35 REPLACE_WCRTOMB=1
@@ -40,35 +56,43 @@ changequote(,)dnl
40 esac 56 esac
41changequote([,])dnl 57changequote([,])dnl
42 if test $LOCALE_FR != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none || test $LOCALE_ZH_CN != none; then 58 if test $LOCALE_FR != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none || test $LOCALE_ZH_CN != none; then
43 AC_TRY_RUN([ 59 AC_RUN_IFELSE(
60 [AC_LANG_SOURCE([[
44#include <locale.h> 61#include <locale.h>
45#include <stdio.h>
46#include <string.h> 62#include <string.h>
63/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
64 <wchar.h>.
65 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
66 included before <wchar.h>. */
67#include <stddef.h>
68#include <stdio.h>
69#include <time.h>
47#include <wchar.h> 70#include <wchar.h>
48int main () 71int main ()
49{ 72{
73 int result = 0;
50 if (setlocale (LC_ALL, "$LOCALE_FR") != NULL) 74 if (setlocale (LC_ALL, "$LOCALE_FR") != NULL)
51 { 75 {
52 if (wcrtomb (NULL, 0, NULL) != 1) 76 if (wcrtomb (NULL, 0, NULL) != 1)
53 return 1; 77 result |= 1;
54 } 78 }
55 if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL) 79 if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
56 { 80 {
57 if (wcrtomb (NULL, 0, NULL) != 1) 81 if (wcrtomb (NULL, 0, NULL) != 1)
58 return 1; 82 result |= 2;
59 } 83 }
60 if (setlocale (LC_ALL, "$LOCALE_JA") != NULL) 84 if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
61 { 85 {
62 if (wcrtomb (NULL, 0, NULL) != 1) 86 if (wcrtomb (NULL, 0, NULL) != 1)
63 return 1; 87 result |= 4;
64 } 88 }
65 if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL) 89 if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
66 { 90 {
67 if (wcrtomb (NULL, 0, NULL) != 1) 91 if (wcrtomb (NULL, 0, NULL) != 1)
68 return 1; 92 result |= 8;
69 } 93 }
70 return 0; 94 return result;
71}], 95}]])],
72 [gl_cv_func_wcrtomb_retval=yes], 96 [gl_cv_func_wcrtomb_retval=yes],
73 [gl_cv_func_wcrtomb_retval=no], 97 [gl_cv_func_wcrtomb_retval=no],
74 [:]) 98 [:])
@@ -80,11 +104,6 @@ int main ()
80 esac 104 esac
81 fi 105 fi
82 fi 106 fi
83 if test $HAVE_WCRTOMB = 0 || test $REPLACE_WCRTOMB = 1; then
84 gl_REPLACE_WCHAR_H
85 AC_LIBOBJ([wcrtomb])
86 gl_PREREQ_WCRTOMB
87 fi
88]) 107])
89 108
90# Prerequisites of lib/wcrtomb.c. 109# Prerequisites of lib/wcrtomb.c.
diff --git a/gl/m4/wctype_h.m4 b/gl/m4/wctype_h.m4
index 3292451..82ada0e 100644
--- a/gl/m4/wctype_h.m4
+++ b/gl/m4/wctype_h.m4
@@ -1,8 +1,8 @@
1# wctype_h.m4 serial 6 1# wctype_h.m4 serial 18
2 2
3dnl 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.
4 4
5dnl Copyright (C) 2006-2010 Free Software Foundation, Inc. 5dnl Copyright (C) 2006-2013 Free Software Foundation, Inc.
6dnl This file is free software; the Free Software Foundation 6dnl This file is free software; the Free Software Foundation
7dnl gives unlimited permission to copy and/or distribute it, 7dnl gives unlimited permission to copy and/or distribute it,
8dnl with or without modifications, as long as this notice is preserved. 8dnl with or without modifications, as long as this notice is preserved.
@@ -11,6 +11,7 @@ dnl Written by Paul Eggert.
11 11
12AC_DEFUN([gl_WCTYPE_H], 12AC_DEFUN([gl_WCTYPE_H],
13[ 13[
14 AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
14 AC_REQUIRE([AC_PROG_CC]) 15 AC_REQUIRE([AC_PROG_CC])
15 AC_REQUIRE([AC_CANONICAL_HOST]) 16 AC_REQUIRE([AC_CANONICAL_HOST])
16 AC_CHECK_FUNCS_ONCE([iswcntrl]) 17 AC_CHECK_FUNCS_ONCE([iswcntrl])
@@ -20,15 +21,6 @@ AC_DEFUN([gl_WCTYPE_H],
20 HAVE_ISWCNTRL=0 21 HAVE_ISWCNTRL=0
21 fi 22 fi
22 AC_SUBST([HAVE_ISWCNTRL]) 23 AC_SUBST([HAVE_ISWCNTRL])
23 AC_CHECK_FUNCS_ONCE([iswblank])
24 if test $ac_cv_func_iswblank = yes; then
25 HAVE_ISWBLANK=1
26 else
27 HAVE_ISWBLANK=0
28 fi
29 AC_SUBST([HAVE_ISWBLANK])
30 AC_CHECK_HEADERS_ONCE([wctype.h])
31 AC_REQUIRE([AC_C_INLINE])
32 24
33 AC_REQUIRE([gt_TYPE_WINT_T]) 25 AC_REQUIRE([gt_TYPE_WINT_T])
34 if test $gt_cv_c_wint_t = yes; then 26 if test $gt_cv_c_wint_t = yes; then
@@ -38,39 +30,180 @@ AC_DEFUN([gl_WCTYPE_H],
38 fi 30 fi
39 AC_SUBST([HAVE_WINT_T]) 31 AC_SUBST([HAVE_WINT_T])
40 32
33 gl_CHECK_NEXT_HEADERS([wctype.h])
41 if test $ac_cv_header_wctype_h = yes; then 34 if test $ac_cv_header_wctype_h = yes; then
42 if test $ac_cv_func_iswcntrl = yes; then 35 if test $ac_cv_func_iswcntrl = yes; then
43 dnl Linux libc5 has an iswprint function that returns 0 for all arguments. 36 dnl Linux libc5 has an iswprint function that returns 0 for all arguments.
44 dnl The other functions are likely broken in the same way. 37 dnl The other functions are likely broken in the same way.
45 AC_CACHE_CHECK([whether iswcntrl works], [gl_cv_func_iswcntrl_works], 38 AC_CACHE_CHECK([whether iswcntrl works], [gl_cv_func_iswcntrl_works],
46 [ 39 [
47 AC_RUN_IFELSE([AC_LANG_SOURCE([[ 40 AC_RUN_IFELSE(
48 #include <stddef.h> 41 [AC_LANG_SOURCE([[
49 #include <stdio.h> 42 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be
50 #include <time.h> 43 included before <wchar.h>.
51 #include <wchar.h> 44 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
52 #include <wctype.h> 45 must be included before <wchar.h>. */
53 int main () { return iswprint ('x') == 0; }]])], 46 #include <stddef.h>
47 #include <stdio.h>
48 #include <time.h>
49 #include <wchar.h>
50 #include <wctype.h>
51 int main () { return iswprint ('x') == 0; }
52 ]])],
54 [gl_cv_func_iswcntrl_works=yes], [gl_cv_func_iswcntrl_works=no], 53 [gl_cv_func_iswcntrl_works=yes], [gl_cv_func_iswcntrl_works=no],
55 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h> 54 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
56 #if __GNU_LIBRARY__ == 1 55 #if __GNU_LIBRARY__ == 1
57 Linux libc5 i18n is broken. 56 Linux libc5 i18n is broken.
58 #endif]], [])], 57 #endif]], [])],
59 [gl_cv_func_iswcntrl_works=yes], [gl_cv_func_iswcntrl_works=no]) 58 [gl_cv_func_iswcntrl_works="guessing yes"],
59 [gl_cv_func_iswcntrl_works="guessing no"])
60 ]) 60 ])
61 ]) 61 ])
62 fi 62 fi
63 gl_CHECK_NEXT_HEADERS([wctype.h])
64 HAVE_WCTYPE_H=1 63 HAVE_WCTYPE_H=1
65 else 64 else
66 HAVE_WCTYPE_H=0 65 HAVE_WCTYPE_H=0
67 fi 66 fi
68 AC_SUBST([HAVE_WCTYPE_H]) 67 AC_SUBST([HAVE_WCTYPE_H])
69 68
70 if test "$gl_cv_func_iswcntrl_works" = no; then 69 case "$gl_cv_func_iswcntrl_works" in
71 REPLACE_ISWCNTRL=1 70 *yes) REPLACE_ISWCNTRL=0 ;;
71 *) REPLACE_ISWCNTRL=1 ;;
72 esac
73 AC_SUBST([REPLACE_ISWCNTRL])
74
75 if test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; then
76 dnl Redefine all of iswcntrl, ..., iswxdigit in <wctype.h>.
77 :
78 fi
79
80 if test $REPLACE_ISWCNTRL = 1; then
81 REPLACE_TOWLOWER=1
72 else 82 else
73 REPLACE_ISWCNTRL=0 83 AC_CHECK_FUNCS([towlower])
84 if test $ac_cv_func_towlower = yes; then
85 REPLACE_TOWLOWER=0
86 else
87 AC_CHECK_DECLS([towlower],,,
88 [[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be
89 included before <wchar.h>.
90 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
91 must be included before <wchar.h>. */
92 #include <stddef.h>
93 #include <stdio.h>
94 #include <time.h>
95 #include <wchar.h>
96 #if HAVE_WCTYPE_H
97 # include <wctype.h>
98 #endif
99 ]])
100 if test $ac_cv_have_decl_towlower = yes; then
101 dnl On Minix 3.1.8, the system's <wctype.h> declares towlower() and
102 dnl towupper() although it does not have the functions. Avoid a
103 dnl collision with gnulib's replacement.
104 REPLACE_TOWLOWER=1
105 else
106 REPLACE_TOWLOWER=0
107 fi
108 fi
74 fi 109 fi
75 AC_SUBST([REPLACE_ISWCNTRL]) 110 AC_SUBST([REPLACE_TOWLOWER])
111
112 if test $HAVE_ISWCNTRL = 0 || test $REPLACE_TOWLOWER = 1; then
113 dnl Redefine towlower, towupper in <wctype.h>.
114 :
115 fi
116
117 dnl We assume that the wctype() and iswctype() functions exist if and only
118 dnl if the type wctype_t is defined in <wchar.h> or in <wctype.h> if that
119 dnl exists.
120 dnl HP-UX 11.00 declares all these in <wchar.h> and lacks <wctype.h>.
121 AC_CACHE_CHECK([for wctype_t], [gl_cv_type_wctype_t],
122 [AC_COMPILE_IFELSE(
123 [AC_LANG_PROGRAM(
124 [[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be
125 included before <wchar.h>.
126 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
127 must be included before <wchar.h>. */
128 #include <stddef.h>
129 #include <stdio.h>
130 #include <time.h>
131 #include <wchar.h>
132 #if HAVE_WCTYPE_H
133 # include <wctype.h>
134 #endif
135 wctype_t a;
136 ]],
137 [[]])],
138 [gl_cv_type_wctype_t=yes],
139 [gl_cv_type_wctype_t=no])
140 ])
141 if test $gl_cv_type_wctype_t = no; then
142 HAVE_WCTYPE_T=0
143 fi
144
145 dnl We assume that the wctrans() and towctrans() functions exist if and only
146 dnl if the type wctrans_t is defined in <wctype.h>.
147 AC_CACHE_CHECK([for wctrans_t], [gl_cv_type_wctrans_t],
148 [AC_COMPILE_IFELSE(
149 [AC_LANG_PROGRAM(
150 [[/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be
151 included before <wchar.h>.
152 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h>
153 must be included before <wchar.h>. */
154 #include <stddef.h>
155 #include <stdio.h>
156 #include <time.h>
157 #include <wchar.h>
158 #include <wctype.h>
159 wctrans_t a;
160 ]],
161 [[]])],
162 [gl_cv_type_wctrans_t=yes],
163 [gl_cv_type_wctrans_t=no])
164 ])
165 if test $gl_cv_type_wctrans_t = no; then
166 HAVE_WCTRANS_T=0
167 fi
168
169 dnl Check for declarations of anything we want to poison if the
170 dnl corresponding gnulib module is not in use.
171 gl_WARN_ON_USE_PREPARE([[
172/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
173 <wchar.h>.
174 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
175 included before <wchar.h>. */
176#if !(defined __GLIBC__ && !defined __UCLIBC__)
177# include <stddef.h>
178# include <stdio.h>
179# include <time.h>
180# include <wchar.h>
181#endif
182#include <wctype.h>
183 ]],
184 [wctype iswctype wctrans towctrans
185 ])
186])
187
188AC_DEFUN([gl_WCTYPE_MODULE_INDICATOR],
189[
190 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
191 AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
192 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
193 dnl Define it also as a C macro, for the benefit of the unit tests.
194 gl_MODULE_INDICATOR_FOR_TESTS([$1])
195])
196
197AC_DEFUN([gl_WCTYPE_H_DEFAULTS],
198[
199 GNULIB_ISWBLANK=0; AC_SUBST([GNULIB_ISWBLANK])
200 GNULIB_WCTYPE=0; AC_SUBST([GNULIB_WCTYPE])
201 GNULIB_ISWCTYPE=0; AC_SUBST([GNULIB_ISWCTYPE])
202 GNULIB_WCTRANS=0; AC_SUBST([GNULIB_WCTRANS])
203 GNULIB_TOWCTRANS=0; AC_SUBST([GNULIB_TOWCTRANS])
204 dnl Assume proper GNU behavior unless another module says otherwise.
205 HAVE_ISWBLANK=1; AC_SUBST([HAVE_ISWBLANK])
206 HAVE_WCTYPE_T=1; AC_SUBST([HAVE_WCTYPE_T])
207 HAVE_WCTRANS_T=1; AC_SUBST([HAVE_WCTRANS_T])
208 REPLACE_ISWBLANK=0; AC_SUBST([REPLACE_ISWBLANK])
76]) 209])
diff --git a/gl/m4/wint_t.m4 b/gl/m4/wint_t.m4
index a6c7d15..d7cd3db 100644
--- a/gl/m4/wint_t.m4
+++ b/gl/m4/wint_t.m4
@@ -1,5 +1,5 @@
1# wint_t.m4 serial 4 (gettext-0.18) 1# wint_t.m4 serial 5 (gettext-0.18.2)
2dnl Copyright (C) 2003, 2007-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2003, 2007-2013 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,7 +11,9 @@ dnl Prerequisite: AC_PROG_CC
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_COMPILE_IFELSE(
15 [AC_LANG_PROGRAM(
16 [[
15/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before 17/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
16 <wchar.h>. 18 <wchar.h>.
17 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be included 19 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be included
@@ -20,8 +22,10 @@ AC_DEFUN([gt_TYPE_WINT_T],
20#include <stdio.h> 22#include <stdio.h>
21#include <time.h> 23#include <time.h>
22#include <wchar.h> 24#include <wchar.h>
23 wint_t foo = (wchar_t)'\0';], , 25 wint_t foo = (wchar_t)'\0';]],
24 [gt_cv_c_wint_t=yes], [gt_cv_c_wint_t=no])]) 26 [[]])],
27 [gt_cv_c_wint_t=yes],
28 [gt_cv_c_wint_t=no])])
25 if test $gt_cv_c_wint_t = yes; then 29 if test $gt_cv_c_wint_t = yes; then
26 AC_DEFINE([HAVE_WINT_T], [1], [Define if you have the 'wint_t' type.]) 30 AC_DEFINE([HAVE_WINT_T], [1], [Define if you have the 'wint_t' type.])
27 fi 31 fi
diff --git a/gl/m4/write.m4 b/gl/m4/write.m4
deleted file mode 100644
index 56325ab..0000000
--- a/gl/m4/write.m4
+++ /dev/null
@@ -1,20 +0,0 @@
1# write.m4 serial 1
2dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
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/xalloc.m4 b/gl/m4/xalloc.m4
index 83247fe..64ca701 100644
--- a/gl/m4/xalloc.m4
+++ b/gl/m4/xalloc.m4
@@ -1,25 +1,7 @@
1# xalloc.m4 serial 16 1# xalloc.m4 serial 18
2dnl Copyright (C) 2002, 2003, 2004, 2005, 2006, 2009, 2010 Free Software 2dnl Copyright (C) 2002-2006, 2009-2013 Free Software Foundation, Inc.
3dnl Foundation, Inc.
4dnl This file is free software; the Free Software Foundation 3dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it, 4dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved. 5dnl with or without modifications, as long as this notice is preserved.
7 6
8AC_DEFUN([gl_XALLOC], 7AC_DEFUN([gl_XALLOC], [:])
9[
10 AC_LIBOBJ([xmalloc])
11
12 gl_PREREQ_XALLOC
13 gl_PREREQ_XMALLOC
14])
15
16# Prerequisites of lib/xalloc.h.
17AC_DEFUN([gl_PREREQ_XALLOC], [
18 AC_REQUIRE([gl_INLINE])
19 :
20])
21
22# Prerequisites of lib/xmalloc.c.
23AC_DEFUN([gl_PREREQ_XMALLOC], [
24 :
25])
diff --git a/gl/m4/xsize.m4 b/gl/m4/xsize.m4
index b653693..8ea9f2c 100644
--- a/gl/m4/xsize.m4
+++ b/gl/m4/xsize.m4
@@ -1,5 +1,5 @@
1# xsize.m4 serial 4 1# xsize.m4 serial 5
2dnl Copyright (C) 2003-2004, 2008-2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2003-2004, 2008-2013 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,5 @@ AC_DEFUN([gl_XSIZE],
8[ 8[
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])
12 AC_CHECK_HEADERS([stdint.h]) 11 AC_CHECK_HEADERS([stdint.h])
13]) 12])
diff --git a/gl/m4/xstrndup.m4 b/gl/m4/xstrndup.m4
index 74302cc..4a9330b 100644
--- a/gl/m4/xstrndup.m4
+++ b/gl/m4/xstrndup.m4
@@ -1,5 +1,5 @@
1# xstrndup.m4 serial 2 1# xstrndup.m4 serial 2
2dnl Copyright (C) 2003, 2009, 2010 Free Software Foundation, Inc. 2dnl Copyright (C) 2003, 2009-2013 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.
diff --git a/gl/malloc.c b/gl/malloc.c
index a3095c1..908735d 100644
--- a/gl/malloc.c
+++ b/gl/malloc.c
@@ -1,6 +1,6 @@
1/* malloc() function that is glibc compatible. 1/* malloc() function that is glibc compatible.
2 2
3 Copyright (C) 1997-1998, 2006-2007, 2009-2010 Free Software Foundation, Inc. 3 Copyright (C) 1997-1998, 2006-2007, 2009-2013 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
@@ -13,26 +13,25 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
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, write to the Free Software Foundation, 16 along with this program; if not, see <http://www.gnu.org/licenses/>. */
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 17
19/* written by Jim Meyering and Bruno Haible */ 18/* written by Jim Meyering and Bruno Haible */
20 19
20#define _GL_USE_STDLIB_ALLOC 1
21#include <config.h> 21#include <config.h>
22/* Only the AC_FUNC_MALLOC macro defines 'malloc' already in config.h. */ 22/* Only the AC_FUNC_MALLOC macro defines 'malloc' already in config.h. */
23#ifdef malloc 23#ifdef malloc
24# define NEED_MALLOC_GNU 24# define NEED_MALLOC_GNU 1
25# undef malloc 25# undef malloc
26/* Whereas the gnulib module 'malloc-gnu' defines HAVE_MALLOC_GNU. */
27#elif GNULIB_MALLOC_GNU && !HAVE_MALLOC_GNU
28# define NEED_MALLOC_GNU 1
26#endif 29#endif
27 30
28/* Specification. */
29#include <stdlib.h> 31#include <stdlib.h>
30 32
31#include <errno.h> 33#include <errno.h>
32 34
33/* Call the system's malloc below. */
34#undef malloc
35
36/* Allocate an N-byte block of memory from the heap. 35/* Allocate an N-byte block of memory from the heap.
37 If N is zero, allocate a 1-byte block. */ 36 If N is zero, allocate a 1-byte block. */
38 37
@@ -41,7 +40,7 @@ rpl_malloc (size_t n)
41{ 40{
42 void *result; 41 void *result;
43 42
44#ifdef NEED_MALLOC_GNU 43#if NEED_MALLOC_GNU
45 if (n == 0) 44 if (n == 0)
46 n = 1; 45 n = 1;
47#endif 46#endif
diff --git a/gl/malloca.c b/gl/malloca.c
index 21bbc1f..311be56 100644
--- a/gl/malloca.c
+++ b/gl/malloca.c
@@ -1,5 +1,5 @@
1/* Safe automatic memory allocation. 1/* Safe automatic memory allocation.
2 Copyright (C) 2003, 2006-2007, 2009-2010 Free Software Foundation, Inc. 2 Copyright (C) 2003, 2006-2007, 2009-2013 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2003. 3 Written by Bruno Haible <bruno@clisp.org>, 2003.
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
@@ -13,16 +13,17 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
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, write to the Free Software Foundation, 16 along with this program; if not, see <http://www.gnu.org/licenses/>. */
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 17
18#define _GL_USE_STDLIB_ALLOC 1
19#include <config.h> 19#include <config.h>
20 20
21/* Specification. */ 21/* Specification. */
22#include "malloca.h" 22#include "malloca.h"
23 23
24/* Use the system functions, not the gnulib overrides in this file. */ 24#include <stdint.h>
25#undef malloc 25
26#include "verify.h"
26 27
27/* The speed critical point in this file is freea() applied to an alloca() 28/* The speed critical point in this file is freea() applied to an alloca()
28 result: it must be fast, to match the speed of alloca(). The speed of 29 result: it must be fast, to match the speed of alloca(). The speed of
@@ -48,13 +49,18 @@
48#define MAGIC_SIZE sizeof (int) 49#define MAGIC_SIZE sizeof (int)
49/* This is how the header info would look like without any alignment 50/* This is how the header info would look like without any alignment
50 considerations. */ 51 considerations. */
51struct preliminary_header { void *next; char room[MAGIC_SIZE]; }; 52struct preliminary_header { void *next; int magic; };
52/* But the header's size must be a multiple of sa_alignment_max. */ 53/* But the header's size must be a multiple of sa_alignment_max. */
53#define HEADER_SIZE \ 54#define HEADER_SIZE \
54 (((sizeof (struct preliminary_header) + sa_alignment_max - 1) / sa_alignment_max) * sa_alignment_max) 55 (((sizeof (struct preliminary_header) + sa_alignment_max - 1) / sa_alignment_max) * sa_alignment_max)
55struct header { void *next; char room[HEADER_SIZE - sizeof (struct preliminary_header) + MAGIC_SIZE]; }; 56union header {
56/* Verify that HEADER_SIZE == sizeof (struct header). */ 57 void *next;
57typedef int verify1[2 * (HEADER_SIZE == sizeof (struct header)) - 1]; 58 struct {
59 char room[HEADER_SIZE - MAGIC_SIZE];
60 int word;
61 } magic;
62};
63verify (HEADER_SIZE == sizeof (union header));
58/* We make the hash table quite big, so that during lookups the probability 64/* We make the hash table quite big, so that during lookups the probability
59 of empty hash buckets is quite high. There is no need to make the hash 65 of empty hash buckets is quite high. There is no need to make the hash
60 table resizable, because when the hash table gets filled so much that the 66 table resizable, because when the hash table gets filled so much that the
@@ -74,20 +80,21 @@ mmalloca (size_t n)
74 80
75 if (nplus >= n) 81 if (nplus >= n)
76 { 82 {
77 char *p = (char *) malloc (nplus); 83 void *p = malloc (nplus);
78 84
79 if (p != NULL) 85 if (p != NULL)
80 { 86 {
81 size_t slot; 87 size_t slot;
88 union header *h = p;
82 89
83 p += HEADER_SIZE; 90 p = h + 1;
84 91
85 /* Put a magic number into the indicator word. */ 92 /* Put a magic number into the indicator word. */
86 ((int *) p)[-1] = MAGIC_NUMBER; 93 h->magic.word = MAGIC_NUMBER;
87 94
88 /* Enter p into the hash table. */ 95 /* Enter p into the hash table. */
89 slot = (unsigned long) p % HASH_TABLE_SIZE; 96 slot = (uintptr_t) p % HASH_TABLE_SIZE;
90 ((struct header *) (p - HEADER_SIZE))->next = mmalloca_results[slot]; 97 h->next = mmalloca_results[slot];
91 mmalloca_results[slot] = p; 98 mmalloca_results[slot] = p;
92 99
93 return p; 100 return p;
@@ -119,19 +126,21 @@ freea (void *p)
119 { 126 {
120 /* Looks like a mmalloca() result. To see whether it really is one, 127 /* Looks like a mmalloca() result. To see whether it really is one,
121 perform a lookup in the hash table. */ 128 perform a lookup in the hash table. */
122 size_t slot = (unsigned long) p % HASH_TABLE_SIZE; 129 size_t slot = (uintptr_t) p % HASH_TABLE_SIZE;
123 void **chain = &mmalloca_results[slot]; 130 void **chain = &mmalloca_results[slot];
124 for (; *chain != NULL;) 131 for (; *chain != NULL;)
125 { 132 {
133 union header *h = p;
126 if (*chain == p) 134 if (*chain == p)
127 { 135 {
128 /* Found it. Remove it from the hash table and free it. */ 136 /* Found it. Remove it from the hash table and free it. */
129 char *p_begin = (char *) p - HEADER_SIZE; 137 union header *p_begin = h - 1;
130 *chain = ((struct header *) p_begin)->next; 138 *chain = p_begin->next;
131 free (p_begin); 139 free (p_begin);
132 return; 140 return;
133 } 141 }
134 chain = &((struct header *) ((char *) *chain - HEADER_SIZE))->next; 142 h = *chain;
143 chain = &h[-1].next;
135 } 144 }
136 } 145 }
137 /* At this point, we know it was not a mmalloca() result. */ 146 /* At this point, we know it was not a mmalloca() result. */
diff --git a/gl/malloca.h b/gl/malloca.h
index 0d5ded3..6fbe45e 100644
--- a/gl/malloca.h
+++ b/gl/malloca.h
@@ -1,5 +1,5 @@
1/* Safe automatic memory allocation. 1/* Safe automatic memory allocation.
2 Copyright (C) 2003-2007, 2009-2010 Free Software Foundation, Inc. 2 Copyright (C) 2003-2007, 2009-2013 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2003. 3 Written by Bruno Haible <bruno@clisp.org>, 2003.
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
@@ -13,8 +13,7 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
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, write to the Free Software Foundation, 16 along with this program; if not, see <http://www.gnu.org/licenses/>. */
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 17
19#ifndef _MALLOCA_H 18#ifndef _MALLOCA_H
20#define _MALLOCA_H 19#define _MALLOCA_H
@@ -43,7 +42,7 @@ extern "C" {
43 and a page size can be as small as 4096 bytes. So we cannot safely 42 and a page size can be as small as 4096 bytes. So we cannot safely
44 allocate anything larger than 4096 bytes. Also care for the possibility 43 allocate anything larger than 4096 bytes. Also care for the possibility
45 of a few compiler-allocated temporary stack slots. 44 of a few compiler-allocated temporary stack slots.
46 This must be a macro, not an inline function. */ 45 This must be a macro, not a function. */
47# define safe_alloca(N) ((N) < 4032 ? alloca (N) : NULL) 46# define safe_alloca(N) ((N) < 4032 ? alloca (N) : NULL)
48#else 47#else
49# define safe_alloca(N) ((void) (N), NULL) 48# define safe_alloca(N) ((void) (N), NULL)
@@ -93,7 +92,7 @@ extern void * nmalloca (size_t n, size_t s);
93/* ------------------- Auxiliary, non-public definitions ------------------- */ 92/* ------------------- Auxiliary, non-public definitions ------------------- */
94 93
95/* Determine the alignment of a type at compile time. */ 94/* Determine the alignment of a type at compile time. */
96#if defined __GNUC__ 95#if defined __GNUC__ || defined __IBM__ALIGNOF__
97# define sa_alignof __alignof__ 96# define sa_alignof __alignof__
98#elif defined __cplusplus 97#elif defined __cplusplus
99 template <class type> struct sa_alignof_helper { char __slot1; type __slot2; }; 98 template <class type> struct sa_alignof_helper { char __slot1; type __slot2; };
diff --git a/gl/math.c b/gl/math.c
new file mode 100644
index 0000000..ddb2ded
--- /dev/null
+++ b/gl/math.c
@@ -0,0 +1,3 @@
1#include <config.h>
2#define _GL_MATH_INLINE _GL_EXTERN_INLINE
3#include "math.h"
diff --git a/gl/math.in.h b/gl/math.in.h
index fbc2918..7189819 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-2010 Free Software Foundation, Inc. 3 Copyright (C) 2002-2003, 2007-2013 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,18 +15,23 @@
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#ifndef _GL_MATH_H 18#ifndef _@GUARD_PREFIX@_MATH_H
19 19
20#if __GNUC__ >= 3 20#if __GNUC__ >= 3
21@PRAGMA_SYSTEM_HEADER@ 21@PRAGMA_SYSTEM_HEADER@
22#endif 22#endif
23@PRAGMA_COLUMNS@
23 24
24/* The include_next requires a split double-inclusion guard. */ 25/* The include_next requires a split double-inclusion guard. */
25#@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_MATH_H@ 26#@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_MATH_H@
26 27
27#ifndef _GL_MATH_H 28#ifndef _@GUARD_PREFIX@_MATH_H
28#define _GL_MATH_H 29#define _@GUARD_PREFIX@_MATH_H
29 30
31_GL_INLINE_HEADER_BEGIN
32#ifndef _GL_MATH_INLINE
33# define _GL_MATH_INLINE _GL_INLINE
34#endif
30 35
31/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 36/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
32 37
@@ -34,22 +39,60 @@
34 39
35/* The definition of _GL_WARN_ON_USE is copied here. */ 40/* The definition of _GL_WARN_ON_USE is copied here. */
36 41
42#ifdef __cplusplus
43/* Helper macros to define type-generic function FUNC as overloaded functions,
44 rather than as macros like in C. POSIX declares these with an argument of
45 real-floating (that is, one of float, double, or long double). */
46# define _GL_MATH_CXX_REAL_FLOATING_DECL_1(func) \
47static inline int \
48_gl_cxx_ ## func ## f (float f) \
49{ \
50 return func (f); \
51} \
52static inline int \
53_gl_cxx_ ## func ## d (double d) \
54{ \
55 return func (d); \
56} \
57static inline int \
58_gl_cxx_ ## func ## l (long double l) \
59{ \
60 return func (l); \
61}
62# define _GL_MATH_CXX_REAL_FLOATING_DECL_2(func) \
63inline int \
64func (float f) \
65{ \
66 return _gl_cxx_ ## func ## f (f); \
67} \
68inline int \
69func (double d) \
70{ \
71 return _gl_cxx_ ## func ## d (d); \
72} \
73inline int \
74func (long double l) \
75{ \
76 return _gl_cxx_ ## func ## l (l); \
77}
78#endif
79
37/* Helper macros to define a portability warning for the 80/* Helper macros to define a portability warning for the
38 classification macro FUNC called with VALUE. POSIX declares the 81 classification macro FUNC called with VALUE. POSIX declares the
39 classification macros with an argument of real-floating (that is, 82 classification macros with an argument of real-floating (that is,
40 one of float, double, or long double). */ 83 one of float, double, or long double). */
41#define _GL_WARN_REAL_FLOATING_DECL(func) \ 84#define _GL_WARN_REAL_FLOATING_DECL(func) \
42static inline int \ 85_GL_MATH_INLINE int \
43rpl_ ## func ## f (float f) \ 86rpl_ ## func ## f (float f) \
44{ \ 87{ \
45 return func (f); \ 88 return func (f); \
46} \ 89} \
47static inline int \ 90_GL_MATH_INLINE int \
48rpl_ ## func ## d (double d) \ 91rpl_ ## func ## d (double d) \
49{ \ 92{ \
50 return func (d); \ 93 return func (d); \
51} \ 94} \
52static inline int \ 95_GL_MATH_INLINE int \
53rpl_ ## func ## l (long double l) \ 96rpl_ ## func ## l (long double l) \
54{ \ 97{ \
55 return func (l); \ 98 return func (l); \
@@ -66,76 +109,121 @@ _GL_WARN_ON_USE (rpl_ ## func ## l, #func " is unportable - " \
66 : rpl_ ## func ## l (value)) 109 : rpl_ ## func ## l (value))
67 110
68 111
112#if @REPLACE_ITOLD@
113/* Pull in a function that fixes the 'int' to 'long double' conversion
114 of glibc 2.7. */
115_GL_EXTERN_C void _Qp_itoq (long double *, int);
116static void (*_gl_math_fix_itold) (long double *, int) = _Qp_itoq;
117#endif
118
119
69/* POSIX allows platforms that don't support NAN. But all major 120/* POSIX allows platforms that don't support NAN. But all major
70 machines in the past 15 years have supported something close to 121 machines in the past 15 years have supported something close to
71 IEEE NaN, so we define this unconditionally. We also must define 122 IEEE NaN, so we define this unconditionally. We also must define
72 it on platforms like Solaris 10, where NAN is present but defined 123 it on platforms like Solaris 10, where NAN is present but defined
73 as a function pointer rather than a floating point constant. */ 124 as a function pointer rather than a floating point constant. */
74#if !defined NAN || @REPLACE_NAN@ 125#if !defined NAN || @REPLACE_NAN@
75# undef NAN 126# if !GNULIB_defined_NAN
76 /* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */ 127# undef NAN
77# ifdef __DECC 128 /* The Compaq (ex-DEC) C 6.4 compiler and the Microsoft MSVC 9 compiler
78static float 129 choke on the expression 0.0 / 0.0. */
130# if defined __DECC || defined _MSC_VER
131_GL_MATH_INLINE float
79_NaN () 132_NaN ()
80{ 133{
81 static float zero = 0.0f; 134 static float zero = 0.0f;
82 return zero / zero; 135 return zero / zero;
83} 136}
84# define NAN (_NaN()) 137# define NAN (_NaN())
85# else 138# else
86# define NAN (0.0f / 0.0f) 139# define NAN (0.0f / 0.0f)
140# endif
141# define GNULIB_defined_NAN 1
87# endif 142# endif
88#endif 143#endif
89 144
90/* Solaris 10 defines HUGE_VAL, but as a function pointer rather 145/* Solaris 10 defines HUGE_VAL, but as a function pointer rather
91 than a floating point constant. */ 146 than a floating point constant. */
92#if @REPLACE_HUGE_VAL@ 147#if @REPLACE_HUGE_VAL@
148# undef HUGE_VALF
149# define HUGE_VALF (1.0f / 0.0f)
93# undef HUGE_VAL 150# undef HUGE_VAL
94# define HUGE_VAL (1.0 / 0.0) 151# define HUGE_VAL (1.0 / 0.0)
152# undef HUGE_VALL
153# define HUGE_VALL (1.0L / 0.0L)
95#endif 154#endif
96 155
156/* HUGE_VALF is a 'float' Infinity. */
157#ifndef HUGE_VALF
158# if defined _MSC_VER
159/* The Microsoft MSVC 9 compiler chokes on the expression 1.0f / 0.0f. */
160# define HUGE_VALF (1e25f * 1e25f)
161# else
162# define HUGE_VALF (1.0f / 0.0f)
163# endif
164#endif
97 165
98/* Write x as 166/* HUGE_VAL is a 'double' Infinity. */
99 x = mantissa * 2^exp 167#ifndef HUGE_VAL
100 where 168# if defined _MSC_VER
101 If x finite and nonzero: 0.5 <= |mantissa| < 1.0. 169/* The Microsoft MSVC 9 compiler chokes on the expression 1.0 / 0.0. */
102 If x is zero: mantissa = x, exp = 0. 170# define HUGE_VAL (1e250 * 1e250)
103 If x is infinite or NaN: mantissa = x, exp unspecified.
104 Store exp in *EXPPTR and return mantissa. */
105#if @GNULIB_FREXP@
106# if @REPLACE_FREXP@
107# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
108# define frexp rpl_frexp
109# endif
110_GL_FUNCDECL_RPL (frexp, double, (double x, int *expptr) _GL_ARG_NONNULL ((2)));
111_GL_CXXALIAS_RPL (frexp, double, (double x, int *expptr));
112# else 171# else
113_GL_CXXALIAS_SYS (frexp, double, (double x, int *expptr)); 172# define HUGE_VAL (1.0 / 0.0)
173# endif
174#endif
175
176/* HUGE_VALL is a 'long double' Infinity. */
177#ifndef HUGE_VALL
178# if defined _MSC_VER
179/* The Microsoft MSVC 9 compiler chokes on the expression 1.0L / 0.0L. */
180# define HUGE_VALL (1e250L * 1e250L)
181# else
182# define HUGE_VALL (1.0L / 0.0L)
114# endif 183# endif
115_GL_CXXALIASWARN (frexp);
116#elif defined GNULIB_POSIXCHECK
117# undef frexp
118/* Assume frexp is always declared. */
119_GL_WARN_ON_USE (frexp, "frexp is unportable - "
120 "use gnulib module frexp for portability");
121#endif 184#endif
122 185
123 186
124#if @GNULIB_LOGB@ 187/* Ensure FP_ILOGB0 and FP_ILOGBNAN are defined. */
125# if !@HAVE_DECL_LOGB@ 188#if !(defined FP_ILOGB0 && defined FP_ILOGBNAN)
126_GL_EXTERN_C double logb (double x); 189# if defined __NetBSD__ || defined __sgi
190 /* NetBSD, IRIX 6.5: match what ilogb() does */
191# define FP_ILOGB0 (- 2147483647 - 1) /* INT_MIN */
192# define FP_ILOGBNAN (- 2147483647 - 1) /* INT_MIN */
193# elif defined _AIX
194 /* AIX 5.1: match what ilogb() does in AIX >= 5.2 */
195# define FP_ILOGB0 (- 2147483647 - 1) /* INT_MIN */
196# define FP_ILOGBNAN 2147483647 /* INT_MAX */
197# elif defined __sun
198 /* Solaris 9: match what ilogb() does */
199# define FP_ILOGB0 (- 2147483647) /* - INT_MAX */
200# define FP_ILOGBNAN 2147483647 /* INT_MAX */
201# else
202 /* Gnulib defined values. */
203# define FP_ILOGB0 (- 2147483647) /* - INT_MAX */
204# define FP_ILOGBNAN (- 2147483647 - 1) /* INT_MIN */
205# endif
206#endif
207
208
209#if @GNULIB_ACOSF@
210# if !@HAVE_ACOSF@
211# undef acosf
212_GL_FUNCDECL_SYS (acosf, float, (float x));
127# endif 213# endif
214_GL_CXXALIAS_SYS (acosf, float, (float x));
215_GL_CXXALIASWARN (acosf);
128#elif defined GNULIB_POSIXCHECK 216#elif defined GNULIB_POSIXCHECK
129# undef logb 217# undef acosf
130# if HAVE_RAW_DECL_LOGB 218# if HAVE_RAW_DECL_ACOSF
131_GL_WARN_ON_USE (logb, "logb is unportable - " 219_GL_WARN_ON_USE (acosf, "acosf is unportable - "
132 "use gnulib module logb for portability"); 220 "use gnulib module acosf for portability");
133# endif 221# endif
134#endif 222#endif
135 223
136
137#if @GNULIB_ACOSL@ 224#if @GNULIB_ACOSL@
138# if !@HAVE_ACOSL@ || !@HAVE_DECL_ACOSL@ 225# if !@HAVE_ACOSL@ || !@HAVE_DECL_ACOSL@
226# undef acosl
139_GL_FUNCDECL_SYS (acosl, long double, (long double x)); 227_GL_FUNCDECL_SYS (acosl, long double, (long double x));
140# endif 228# endif
141_GL_CXXALIAS_SYS (acosl, long double, (long double x)); 229_GL_CXXALIAS_SYS (acosl, long double, (long double x));
@@ -144,13 +232,29 @@ _GL_CXXALIASWARN (acosl);
144# undef acosl 232# undef acosl
145# if HAVE_RAW_DECL_ACOSL 233# if HAVE_RAW_DECL_ACOSL
146_GL_WARN_ON_USE (acosl, "acosl is unportable - " 234_GL_WARN_ON_USE (acosl, "acosl is unportable - "
147 "use gnulib module mathl for portability"); 235 "use gnulib module acosl for portability");
148# endif 236# endif
149#endif 237#endif
150 238
151 239
240#if @GNULIB_ASINF@
241# if !@HAVE_ASINF@
242# undef asinf
243_GL_FUNCDECL_SYS (asinf, float, (float x));
244# endif
245_GL_CXXALIAS_SYS (asinf, float, (float x));
246_GL_CXXALIASWARN (asinf);
247#elif defined GNULIB_POSIXCHECK
248# undef asinf
249# if HAVE_RAW_DECL_ASINF
250_GL_WARN_ON_USE (asinf, "asinf is unportable - "
251 "use gnulib module asinf for portability");
252# endif
253#endif
254
152#if @GNULIB_ASINL@ 255#if @GNULIB_ASINL@
153# if !@HAVE_ASINL@ || !@HAVE_DECL_ASINL@ 256# if !@HAVE_ASINL@ || !@HAVE_DECL_ASINL@
257# undef asinl
154_GL_FUNCDECL_SYS (asinl, long double, (long double x)); 258_GL_FUNCDECL_SYS (asinl, long double, (long double x));
155# endif 259# endif
156_GL_CXXALIAS_SYS (asinl, long double, (long double x)); 260_GL_CXXALIAS_SYS (asinl, long double, (long double x));
@@ -159,13 +263,29 @@ _GL_CXXALIASWARN (asinl);
159# undef asinl 263# undef asinl
160# if HAVE_RAW_DECL_ASINL 264# if HAVE_RAW_DECL_ASINL
161_GL_WARN_ON_USE (asinl, "asinl is unportable - " 265_GL_WARN_ON_USE (asinl, "asinl is unportable - "
162 "use gnulib module mathl for portability"); 266 "use gnulib module asinl for portability");
163# endif 267# endif
164#endif 268#endif
165 269
166 270
271#if @GNULIB_ATANF@
272# if !@HAVE_ATANF@
273# undef atanf
274_GL_FUNCDECL_SYS (atanf, float, (float x));
275# endif
276_GL_CXXALIAS_SYS (atanf, float, (float x));
277_GL_CXXALIASWARN (atanf);
278#elif defined GNULIB_POSIXCHECK
279# undef atanf
280# if HAVE_RAW_DECL_ATANF
281_GL_WARN_ON_USE (atanf, "atanf is unportable - "
282 "use gnulib module atanf for portability");
283# endif
284#endif
285
167#if @GNULIB_ATANL@ 286#if @GNULIB_ATANL@
168# if !@HAVE_ATANL@ || !@HAVE_DECL_ATANL@ 287# if !@HAVE_ATANL@ || !@HAVE_DECL_ATANL@
288# undef atanl
169_GL_FUNCDECL_SYS (atanl, long double, (long double x)); 289_GL_FUNCDECL_SYS (atanl, long double, (long double x));
170# endif 290# endif
171_GL_CXXALIAS_SYS (atanl, long double, (long double x)); 291_GL_CXXALIAS_SYS (atanl, long double, (long double x));
@@ -174,7 +294,84 @@ _GL_CXXALIASWARN (atanl);
174# undef atanl 294# undef atanl
175# if HAVE_RAW_DECL_ATANL 295# if HAVE_RAW_DECL_ATANL
176_GL_WARN_ON_USE (atanl, "atanl is unportable - " 296_GL_WARN_ON_USE (atanl, "atanl is unportable - "
177 "use gnulib module mathl for portability"); 297 "use gnulib module atanl for portability");
298# endif
299#endif
300
301
302#if @GNULIB_ATAN2F@
303# if !@HAVE_ATAN2F@
304# undef atan2f
305_GL_FUNCDECL_SYS (atan2f, float, (float y, float x));
306# endif
307_GL_CXXALIAS_SYS (atan2f, float, (float y, float x));
308_GL_CXXALIASWARN (atan2f);
309#elif defined GNULIB_POSIXCHECK
310# undef atan2f
311# if HAVE_RAW_DECL_ATAN2F
312_GL_WARN_ON_USE (atan2f, "atan2f is unportable - "
313 "use gnulib module atan2f for portability");
314# endif
315#endif
316
317
318#if @GNULIB_CBRTF@
319# if @REPLACE_CBRTF@
320# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
321# undef cbrtf
322# define cbrtf rpl_cbrtf
323# endif
324_GL_FUNCDECL_RPL (cbrtf, float, (float x));
325_GL_CXXALIAS_RPL (cbrtf, float, (float x));
326# else
327# if !@HAVE_DECL_CBRTF@
328_GL_FUNCDECL_SYS (cbrtf, float, (float x));
329# endif
330_GL_CXXALIAS_SYS (cbrtf, float, (float x));
331# endif
332_GL_CXXALIASWARN (cbrtf);
333#elif defined GNULIB_POSIXCHECK
334# undef cbrtf
335# if HAVE_RAW_DECL_CBRTF
336_GL_WARN_ON_USE (cbrtf, "cbrtf is unportable - "
337 "use gnulib module cbrtf for portability");
338# endif
339#endif
340
341#if @GNULIB_CBRT@
342# if !@HAVE_CBRT@
343_GL_FUNCDECL_SYS (cbrt, double, (double x));
344# endif
345_GL_CXXALIAS_SYS (cbrt, double, (double x));
346_GL_CXXALIASWARN (cbrt);
347#elif defined GNULIB_POSIXCHECK
348# undef cbrt
349# if HAVE_RAW_DECL_CBRT
350_GL_WARN_ON_USE (cbrt, "cbrt is unportable - "
351 "use gnulib module cbrt for portability");
352# endif
353#endif
354
355#if @GNULIB_CBRTL@
356# if @REPLACE_CBRTL@
357# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
358# undef cbrtl
359# define cbrtl rpl_cbrtl
360# endif
361_GL_FUNCDECL_RPL (cbrtl, long double, (long double x));
362_GL_CXXALIAS_RPL (cbrtl, long double, (long double x));
363# else
364# if !@HAVE_DECL_CBRTL@
365_GL_FUNCDECL_SYS (cbrtl, long double, (long double x));
366# endif
367_GL_CXXALIAS_SYS (cbrtl, long double, (long double x));
368# endif
369_GL_CXXALIASWARN (cbrtl);
370#elif defined GNULIB_POSIXCHECK
371# undef cbrtl
372# if HAVE_RAW_DECL_CBRTL
373_GL_WARN_ON_USE (cbrtl, "cbrtl is unportable - "
374 "use gnulib module cbrtl for portability");
178# endif 375# endif
179#endif 376#endif
180 377
@@ -182,12 +379,14 @@ _GL_WARN_ON_USE (atanl, "atanl is unportable - "
182#if @GNULIB_CEILF@ 379#if @GNULIB_CEILF@
183# if @REPLACE_CEILF@ 380# if @REPLACE_CEILF@
184# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 381# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
382# undef ceilf
185# define ceilf rpl_ceilf 383# define ceilf rpl_ceilf
186# endif 384# endif
187_GL_FUNCDECL_RPL (ceilf, float, (float x)); 385_GL_FUNCDECL_RPL (ceilf, float, (float x));
188_GL_CXXALIAS_RPL (ceilf, float, (float x)); 386_GL_CXXALIAS_RPL (ceilf, float, (float x));
189# else 387# else
190# if !@HAVE_DECL_CEILF@ 388# if !@HAVE_DECL_CEILF@
389# undef ceilf
191_GL_FUNCDECL_SYS (ceilf, float, (float x)); 390_GL_FUNCDECL_SYS (ceilf, float, (float x));
192# endif 391# endif
193_GL_CXXALIAS_SYS (ceilf, float, (float x)); 392_GL_CXXALIAS_SYS (ceilf, float, (float x));
@@ -201,15 +400,30 @@ _GL_WARN_ON_USE (ceilf, "ceilf is unportable - "
201# endif 400# endif
202#endif 401#endif
203 402
403#if @GNULIB_CEIL@
404# if @REPLACE_CEIL@
405# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
406# define ceil rpl_ceil
407# endif
408_GL_FUNCDECL_RPL (ceil, double, (double x));
409_GL_CXXALIAS_RPL (ceil, double, (double x));
410# else
411_GL_CXXALIAS_SYS (ceil, double, (double x));
412# endif
413_GL_CXXALIASWARN (ceil);
414#endif
415
204#if @GNULIB_CEILL@ 416#if @GNULIB_CEILL@
205# if @REPLACE_CEILL@ 417# if @REPLACE_CEILL@
206# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 418# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
419# undef ceill
207# define ceill rpl_ceill 420# define ceill rpl_ceill
208# endif 421# endif
209_GL_FUNCDECL_RPL (ceill, long double, (long double x)); 422_GL_FUNCDECL_RPL (ceill, long double, (long double x));
210_GL_CXXALIAS_RPL (ceill, long double, (long double x)); 423_GL_CXXALIAS_RPL (ceill, long double, (long double x));
211# else 424# else
212# if !@HAVE_DECL_CEILL@ 425# if !@HAVE_DECL_CEILL@
426# undef ceill
213_GL_FUNCDECL_SYS (ceill, long double, (long double x)); 427_GL_FUNCDECL_SYS (ceill, long double, (long double x));
214# endif 428# endif
215_GL_CXXALIAS_SYS (ceill, long double, (long double x)); 429_GL_CXXALIAS_SYS (ceill, long double, (long double x));
@@ -224,8 +438,67 @@ _GL_WARN_ON_USE (ceill, "ceill is unportable - "
224#endif 438#endif
225 439
226 440
441#if @GNULIB_COPYSIGNF@
442# if !@HAVE_DECL_COPYSIGNF@
443_GL_FUNCDECL_SYS (copysignf, float, (float x, float y));
444# endif
445_GL_CXXALIAS_SYS (copysignf, float, (float x, float y));
446_GL_CXXALIASWARN (copysignf);
447#elif defined GNULIB_POSIXCHECK
448# undef copysignf
449# if HAVE_RAW_DECL_COPYSIGNF
450_GL_WARN_ON_USE (copysignf, "copysignf is unportable - "
451 "use gnulib module copysignf for portability");
452# endif
453#endif
454
455#if @GNULIB_COPYSIGN@
456# if !@HAVE_COPYSIGN@
457_GL_FUNCDECL_SYS (copysign, double, (double x, double y));
458# endif
459_GL_CXXALIAS_SYS (copysign, double, (double x, double y));
460_GL_CXXALIASWARN (copysign);
461#elif defined GNULIB_POSIXCHECK
462# undef copysign
463# if HAVE_RAW_DECL_COPYSIGN
464_GL_WARN_ON_USE (copysign, "copysign is unportable - "
465 "use gnulib module copysign for portability");
466# endif
467#endif
468
469#if @GNULIB_COPYSIGNL@
470# if !@HAVE_COPYSIGNL@
471_GL_FUNCDECL_SYS (copysignl, long double, (long double x, long double y));
472# endif
473_GL_CXXALIAS_SYS (copysignl, long double, (long double x, long double y));
474_GL_CXXALIASWARN (copysignl);
475#elif defined GNULIB_POSIXCHECK
476# undef copysignl
477# if HAVE_RAW_DECL_COPYSIGNL
478_GL_WARN_ON_USE (copysign, "copysignl is unportable - "
479 "use gnulib module copysignl for portability");
480# endif
481#endif
482
483
484#if @GNULIB_COSF@
485# if !@HAVE_COSF@
486# undef cosf
487_GL_FUNCDECL_SYS (cosf, float, (float x));
488# endif
489_GL_CXXALIAS_SYS (cosf, float, (float x));
490_GL_CXXALIASWARN (cosf);
491#elif defined GNULIB_POSIXCHECK
492# undef cosf
493# if HAVE_RAW_DECL_COSF
494_GL_WARN_ON_USE (cosf, "cosf is unportable - "
495 "use gnulib module cosf for portability");
496# endif
497#endif
498
227#if @GNULIB_COSL@ 499#if @GNULIB_COSL@
228# if !@HAVE_COSL@ || !@HAVE_DECL_COSL@ 500# if !@HAVE_COSL@ || !@HAVE_DECL_COSL@
501# undef cosl
229_GL_FUNCDECL_SYS (cosl, long double, (long double x)); 502_GL_FUNCDECL_SYS (cosl, long double, (long double x));
230# endif 503# endif
231_GL_CXXALIAS_SYS (cosl, long double, (long double x)); 504_GL_CXXALIAS_SYS (cosl, long double, (long double x));
@@ -234,13 +507,45 @@ _GL_CXXALIASWARN (cosl);
234# undef cosl 507# undef cosl
235# if HAVE_RAW_DECL_COSL 508# if HAVE_RAW_DECL_COSL
236_GL_WARN_ON_USE (cosl, "cosl is unportable - " 509_GL_WARN_ON_USE (cosl, "cosl is unportable - "
237 "use gnulib module mathl for portability"); 510 "use gnulib module cosl for portability");
511# endif
512#endif
513
514
515#if @GNULIB_COSHF@
516# if !@HAVE_COSHF@
517# undef coshf
518_GL_FUNCDECL_SYS (coshf, float, (float x));
519# endif
520_GL_CXXALIAS_SYS (coshf, float, (float x));
521_GL_CXXALIASWARN (coshf);
522#elif defined GNULIB_POSIXCHECK
523# undef coshf
524# if HAVE_RAW_DECL_COSHF
525_GL_WARN_ON_USE (coshf, "coshf is unportable - "
526 "use gnulib module coshf for portability");
238# endif 527# endif
239#endif 528#endif
240 529
241 530
531#if @GNULIB_EXPF@
532# if !@HAVE_EXPF@
533# undef expf
534_GL_FUNCDECL_SYS (expf, float, (float x));
535# endif
536_GL_CXXALIAS_SYS (expf, float, (float x));
537_GL_CXXALIASWARN (expf);
538#elif defined GNULIB_POSIXCHECK
539# undef expf
540# if HAVE_RAW_DECL_EXPF
541_GL_WARN_ON_USE (expf, "expf is unportable - "
542 "use gnulib module expf for portability");
543# endif
544#endif
545
242#if @GNULIB_EXPL@ 546#if @GNULIB_EXPL@
243# if !@HAVE_EXPL@ || !@HAVE_DECL_EXPL@ 547# if !@HAVE_EXPL@ || !@HAVE_DECL_EXPL@
548# undef expl
244_GL_FUNCDECL_SYS (expl, long double, (long double x)); 549_GL_FUNCDECL_SYS (expl, long double, (long double x));
245# endif 550# endif
246_GL_CXXALIAS_SYS (expl, long double, (long double x)); 551_GL_CXXALIAS_SYS (expl, long double, (long double x));
@@ -249,7 +554,171 @@ _GL_CXXALIASWARN (expl);
249# undef expl 554# undef expl
250# if HAVE_RAW_DECL_EXPL 555# if HAVE_RAW_DECL_EXPL
251_GL_WARN_ON_USE (expl, "expl is unportable - " 556_GL_WARN_ON_USE (expl, "expl is unportable - "
252 "use gnulib module mathl for portability"); 557 "use gnulib module expl for portability");
558# endif
559#endif
560
561
562#if @GNULIB_EXP2F@
563# if !@HAVE_DECL_EXP2F@
564_GL_FUNCDECL_SYS (exp2f, float, (float x));
565# endif
566_GL_CXXALIAS_SYS (exp2f, float, (float x));
567_GL_CXXALIASWARN (exp2f);
568#elif defined GNULIB_POSIXCHECK
569# undef exp2f
570# if HAVE_RAW_DECL_EXP2F
571_GL_WARN_ON_USE (exp2f, "exp2f is unportable - "
572 "use gnulib module exp2f for portability");
573# endif
574#endif
575
576#if @GNULIB_EXP2@
577# if @REPLACE_EXP2@
578# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
579# undef exp2
580# define exp2 rpl_exp2
581# endif
582_GL_FUNCDECL_RPL (exp2, double, (double x));
583_GL_CXXALIAS_RPL (exp2, double, (double x));
584# else
585# if !@HAVE_DECL_EXP2@
586_GL_FUNCDECL_SYS (exp2, double, (double x));
587# endif
588_GL_CXXALIAS_SYS (exp2, double, (double x));
589# endif
590_GL_CXXALIASWARN (exp2);
591#elif defined GNULIB_POSIXCHECK
592# undef exp2
593# if HAVE_RAW_DECL_EXP2
594_GL_WARN_ON_USE (exp2, "exp2 is unportable - "
595 "use gnulib module exp2 for portability");
596# endif
597#endif
598
599#if @GNULIB_EXP2L@
600# if @REPLACE_EXP2L@
601# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
602# undef exp2l
603# define exp2l rpl_exp2l
604# endif
605_GL_FUNCDECL_RPL (exp2l, long double, (long double x));
606_GL_CXXALIAS_RPL (exp2l, long double, (long double x));
607# else
608# if !@HAVE_DECL_EXP2L@
609# undef exp2l
610_GL_FUNCDECL_SYS (exp2l, long double, (long double x));
611# endif
612_GL_CXXALIAS_SYS (exp2l, long double, (long double x));
613# endif
614_GL_CXXALIASWARN (exp2l);
615#elif defined GNULIB_POSIXCHECK
616# undef exp2l
617# if HAVE_RAW_DECL_EXP2L
618_GL_WARN_ON_USE (exp2l, "exp2l is unportable - "
619 "use gnulib module exp2l for portability");
620# endif
621#endif
622
623
624#if @GNULIB_EXPM1F@
625# if @REPLACE_EXPM1F@
626# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
627# undef expm1f
628# define expm1f rpl_expm1f
629# endif
630_GL_FUNCDECL_RPL (expm1f, float, (float x));
631_GL_CXXALIAS_RPL (expm1f, float, (float x));
632# else
633# if !@HAVE_EXPM1F@
634_GL_FUNCDECL_SYS (expm1f, float, (float x));
635# endif
636_GL_CXXALIAS_SYS (expm1f, float, (float x));
637# endif
638_GL_CXXALIASWARN (expm1f);
639#elif defined GNULIB_POSIXCHECK
640# undef expm1f
641# if HAVE_RAW_DECL_EXPM1F
642_GL_WARN_ON_USE (expm1f, "expm1f is unportable - "
643 "use gnulib module expm1f for portability");
644# endif
645#endif
646
647#if @GNULIB_EXPM1@
648# if @REPLACE_EXPM1@
649# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
650# undef expm1
651# define expm1 rpl_expm1
652# endif
653_GL_FUNCDECL_RPL (expm1, double, (double x));
654_GL_CXXALIAS_RPL (expm1, double, (double x));
655# else
656# if !@HAVE_EXPM1@
657_GL_FUNCDECL_SYS (expm1, double, (double x));
658# endif
659_GL_CXXALIAS_SYS (expm1, double, (double x));
660# endif
661_GL_CXXALIASWARN (expm1);
662#elif defined GNULIB_POSIXCHECK
663# undef expm1
664# if HAVE_RAW_DECL_EXPM1
665_GL_WARN_ON_USE (expm1, "expm1 is unportable - "
666 "use gnulib module expm1 for portability");
667# endif
668#endif
669
670#if @GNULIB_EXPM1L@
671# if !@HAVE_DECL_EXPM1L@
672# undef expm1l
673_GL_FUNCDECL_SYS (expm1l, long double, (long double x));
674# endif
675_GL_CXXALIAS_SYS (expm1l, long double, (long double x));
676_GL_CXXALIASWARN (expm1l);
677#elif defined GNULIB_POSIXCHECK
678# undef expm1l
679# if HAVE_RAW_DECL_EXPM1L
680_GL_WARN_ON_USE (expm1l, "expm1l is unportable - "
681 "use gnulib module expm1l for portability");
682# endif
683#endif
684
685
686#if @GNULIB_FABSF@
687# if !@HAVE_FABSF@
688# undef fabsf
689_GL_FUNCDECL_SYS (fabsf, float, (float x));
690# endif
691_GL_CXXALIAS_SYS (fabsf, float, (float x));
692_GL_CXXALIASWARN (fabsf);
693#elif defined GNULIB_POSIXCHECK
694# undef fabsf
695# if HAVE_RAW_DECL_FABSF
696_GL_WARN_ON_USE (fabsf, "fabsf is unportable - "
697 "use gnulib module fabsf for portability");
698# endif
699#endif
700
701#if @GNULIB_FABSL@
702# if @REPLACE_FABSL@
703# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
704# undef fabsl
705# define fabsl rpl_fabsl
706# endif
707_GL_FUNCDECL_RPL (fabsl, long double, (long double x));
708_GL_CXXALIAS_RPL (fabsl, long double, (long double x));
709# else
710# if !@HAVE_FABSL@
711# undef fabsl
712_GL_FUNCDECL_SYS (fabsl, long double, (long double x));
713# endif
714_GL_CXXALIAS_SYS (fabsl, long double, (long double x));
715# endif
716_GL_CXXALIASWARN (fabsl);
717#elif defined GNULIB_POSIXCHECK
718# undef fabsl
719# if HAVE_RAW_DECL_FABSL
720_GL_WARN_ON_USE (fabsl, "fabsl is unportable - "
721 "use gnulib module fabsl for portability");
253# endif 722# endif
254#endif 723#endif
255 724
@@ -257,12 +726,14 @@ _GL_WARN_ON_USE (expl, "expl is unportable - "
257#if @GNULIB_FLOORF@ 726#if @GNULIB_FLOORF@
258# if @REPLACE_FLOORF@ 727# if @REPLACE_FLOORF@
259# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 728# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
729# undef floorf
260# define floorf rpl_floorf 730# define floorf rpl_floorf
261# endif 731# endif
262_GL_FUNCDECL_RPL (floorf, float, (float x)); 732_GL_FUNCDECL_RPL (floorf, float, (float x));
263_GL_CXXALIAS_RPL (floorf, float, (float x)); 733_GL_CXXALIAS_RPL (floorf, float, (float x));
264#else 734# else
265# if !@HAVE_DECL_FLOORF@ 735# if !@HAVE_DECL_FLOORF@
736# undef floorf
266_GL_FUNCDECL_SYS (floorf, float, (float x)); 737_GL_FUNCDECL_SYS (floorf, float, (float x));
267# endif 738# endif
268_GL_CXXALIAS_SYS (floorf, float, (float x)); 739_GL_CXXALIAS_SYS (floorf, float, (float x));
@@ -276,15 +747,30 @@ _GL_WARN_ON_USE (floorf, "floorf is unportable - "
276# endif 747# endif
277#endif 748#endif
278 749
750#if @GNULIB_FLOOR@
751# if @REPLACE_FLOOR@
752# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
753# define floor rpl_floor
754# endif
755_GL_FUNCDECL_RPL (floor, double, (double x));
756_GL_CXXALIAS_RPL (floor, double, (double x));
757# else
758_GL_CXXALIAS_SYS (floor, double, (double x));
759# endif
760_GL_CXXALIASWARN (floor);
761#endif
762
279#if @GNULIB_FLOORL@ 763#if @GNULIB_FLOORL@
280# if @REPLACE_FLOORL@ 764# if @REPLACE_FLOORL@
281# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 765# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
766# undef floorl
282# define floorl rpl_floorl 767# define floorl rpl_floorl
283# endif 768# endif
284_GL_FUNCDECL_RPL (floorl, long double, (long double x)); 769_GL_FUNCDECL_RPL (floorl, long double, (long double x));
285_GL_CXXALIAS_RPL (floorl, long double, (long double x)); 770_GL_CXXALIAS_RPL (floorl, long double, (long double x));
286# else 771# else
287# if !@HAVE_DECL_FLOORL@ 772# if !@HAVE_DECL_FLOORL@
773# undef floorl
288_GL_FUNCDECL_SYS (floorl, long double, (long double x)); 774_GL_FUNCDECL_SYS (floorl, long double, (long double x));
289# endif 775# endif
290_GL_CXXALIAS_SYS (floorl, long double, (long double x)); 776_GL_CXXALIAS_SYS (floorl, long double, (long double x));
@@ -299,6 +785,206 @@ _GL_WARN_ON_USE (floorl, "floorl is unportable - "
299#endif 785#endif
300 786
301 787
788#if @GNULIB_FMAF@
789# if @REPLACE_FMAF@
790# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
791# undef fmaf
792# define fmaf rpl_fmaf
793# endif
794_GL_FUNCDECL_RPL (fmaf, float, (float x, float y, float z));
795_GL_CXXALIAS_RPL (fmaf, float, (float x, float y, float z));
796# else
797# if !@HAVE_FMAF@
798_GL_FUNCDECL_SYS (fmaf, float, (float x, float y, float z));
799# endif
800_GL_CXXALIAS_SYS (fmaf, float, (float x, float y, float z));
801# endif
802_GL_CXXALIASWARN (fmaf);
803#elif defined GNULIB_POSIXCHECK
804# undef fmaf
805# if HAVE_RAW_DECL_FMAF
806_GL_WARN_ON_USE (fmaf, "fmaf is unportable - "
807 "use gnulib module fmaf for portability");
808# endif
809#endif
810
811#if @GNULIB_FMA@
812# if @REPLACE_FMA@
813# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
814# undef fma
815# define fma rpl_fma
816# endif
817_GL_FUNCDECL_RPL (fma, double, (double x, double y, double z));
818_GL_CXXALIAS_RPL (fma, double, (double x, double y, double z));
819# else
820# if !@HAVE_FMA@
821_GL_FUNCDECL_SYS (fma, double, (double x, double y, double z));
822# endif
823_GL_CXXALIAS_SYS (fma, double, (double x, double y, double z));
824# endif
825_GL_CXXALIASWARN (fma);
826#elif defined GNULIB_POSIXCHECK
827# undef fma
828# if HAVE_RAW_DECL_FMA
829_GL_WARN_ON_USE (fma, "fma is unportable - "
830 "use gnulib module fma for portability");
831# endif
832#endif
833
834#if @GNULIB_FMAL@
835# if @REPLACE_FMAL@
836# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
837# undef fmal
838# define fmal rpl_fmal
839# endif
840_GL_FUNCDECL_RPL (fmal, long double,
841 (long double x, long double y, long double z));
842_GL_CXXALIAS_RPL (fmal, long double,
843 (long double x, long double y, long double z));
844# else
845# if !@HAVE_FMAL@
846# undef fmal
847_GL_FUNCDECL_SYS (fmal, long double,
848 (long double x, long double y, long double z));
849# endif
850_GL_CXXALIAS_SYS (fmal, long double,
851 (long double x, long double y, long double z));
852# endif
853_GL_CXXALIASWARN (fmal);
854#elif defined GNULIB_POSIXCHECK
855# undef fmal
856# if HAVE_RAW_DECL_FMAL
857_GL_WARN_ON_USE (fmal, "fmal is unportable - "
858 "use gnulib module fmal for portability");
859# endif
860#endif
861
862
863#if @GNULIB_FMODF@
864# if @REPLACE_FMODF@
865# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
866# undef fmodf
867# define fmodf rpl_fmodf
868# endif
869_GL_FUNCDECL_RPL (fmodf, float, (float x, float y));
870_GL_CXXALIAS_RPL (fmodf, float, (float x, float y));
871# else
872# if !@HAVE_FMODF@
873# undef fmodf
874_GL_FUNCDECL_SYS (fmodf, float, (float x, float y));
875# endif
876_GL_CXXALIAS_SYS (fmodf, float, (float x, float y));
877# endif
878_GL_CXXALIASWARN (fmodf);
879#elif defined GNULIB_POSIXCHECK
880# undef fmodf
881# if HAVE_RAW_DECL_FMODF
882_GL_WARN_ON_USE (fmodf, "fmodf is unportable - "
883 "use gnulib module fmodf for portability");
884# endif
885#endif
886
887#if @GNULIB_FMOD@
888# if @REPLACE_FMOD@
889# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
890# undef fmod
891# define fmod rpl_fmod
892# endif
893_GL_FUNCDECL_RPL (fmod, double, (double x, double y));
894_GL_CXXALIAS_RPL (fmod, double, (double x, double y));
895# else
896_GL_CXXALIAS_SYS (fmod, double, (double x, double y));
897# endif
898_GL_CXXALIASWARN (fmod);
899#elif defined GNULIB_POSIXCHECK
900# undef fmod
901# if HAVE_RAW_DECL_FMOD
902_GL_WARN_ON_USE (fmod, "fmod has portability problems - "
903 "use gnulib module fmod for portability");
904# endif
905#endif
906
907#if @GNULIB_FMODL@
908# if @REPLACE_FMODL@
909# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
910# undef fmodl
911# define fmodl rpl_fmodl
912# endif
913_GL_FUNCDECL_RPL (fmodl, long double, (long double x, long double y));
914_GL_CXXALIAS_RPL (fmodl, long double, (long double x, long double y));
915# else
916# if !@HAVE_FMODL@
917# undef fmodl
918_GL_FUNCDECL_SYS (fmodl, long double, (long double x, long double y));
919# endif
920_GL_CXXALIAS_SYS (fmodl, long double, (long double x, long double y));
921# endif
922_GL_CXXALIASWARN (fmodl);
923#elif defined GNULIB_POSIXCHECK
924# undef fmodl
925# if HAVE_RAW_DECL_FMODL
926_GL_WARN_ON_USE (fmodl, "fmodl is unportable - "
927 "use gnulib module fmodl for portability");
928# endif
929#endif
930
931
932/* Write x as
933 x = mantissa * 2^exp
934 where
935 If x finite and nonzero: 0.5 <= |mantissa| < 1.0.
936 If x is zero: mantissa = x, exp = 0.
937 If x is infinite or NaN: mantissa = x, exp unspecified.
938 Store exp in *EXPPTR and return mantissa. */
939#if @GNULIB_FREXPF@
940# if @REPLACE_FREXPF@
941# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
942# undef frexpf
943# define frexpf rpl_frexpf
944# endif
945_GL_FUNCDECL_RPL (frexpf, float, (float x, int *expptr) _GL_ARG_NONNULL ((2)));
946_GL_CXXALIAS_RPL (frexpf, float, (float x, int *expptr));
947# else
948# if !@HAVE_FREXPF@
949# undef frexpf
950_GL_FUNCDECL_SYS (frexpf, float, (float x, int *expptr) _GL_ARG_NONNULL ((2)));
951# endif
952_GL_CXXALIAS_SYS (frexpf, float, (float x, int *expptr));
953# endif
954_GL_CXXALIASWARN (frexpf);
955#elif defined GNULIB_POSIXCHECK
956# undef frexpf
957# if HAVE_RAW_DECL_FREXPF
958_GL_WARN_ON_USE (frexpf, "frexpf is unportable - "
959 "use gnulib module frexpf for portability");
960# endif
961#endif
962
963/* Write x as
964 x = mantissa * 2^exp
965 where
966 If x finite and nonzero: 0.5 <= |mantissa| < 1.0.
967 If x is zero: mantissa = x, exp = 0.
968 If x is infinite or NaN: mantissa = x, exp unspecified.
969 Store exp in *EXPPTR and return mantissa. */
970#if @GNULIB_FREXP@
971# if @REPLACE_FREXP@
972# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
973# define frexp rpl_frexp
974# endif
975_GL_FUNCDECL_RPL (frexp, double, (double x, int *expptr) _GL_ARG_NONNULL ((2)));
976_GL_CXXALIAS_RPL (frexp, double, (double x, int *expptr));
977# else
978_GL_CXXALIAS_SYS (frexp, double, (double x, int *expptr));
979# endif
980_GL_CXXALIASWARN (frexp);
981#elif defined GNULIB_POSIXCHECK
982# undef frexp
983/* Assume frexp is always declared. */
984_GL_WARN_ON_USE (frexp, "frexp is unportable - "
985 "use gnulib module frexp for portability");
986#endif
987
302/* Write x as 988/* Write x as
303 x = mantissa * 2^exp 989 x = mantissa * 2^exp
304 where 990 where
@@ -308,6 +994,7 @@ _GL_WARN_ON_USE (floorl, "floorl is unportable - "
308 Store exp in *EXPPTR and return mantissa. */ 994 Store exp in *EXPPTR and return mantissa. */
309#if @GNULIB_FREXPL@ && @REPLACE_FREXPL@ 995#if @GNULIB_FREXPL@ && @REPLACE_FREXPL@
310# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 996# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
997# undef frexpl
311# define frexpl rpl_frexpl 998# define frexpl rpl_frexpl
312# endif 999# endif
313_GL_FUNCDECL_RPL (frexpl, long double, 1000_GL_FUNCDECL_RPL (frexpl, long double,
@@ -334,9 +1021,157 @@ _GL_WARN_ON_USE (frexpl, "frexpl is unportable - "
334#endif 1021#endif
335 1022
336 1023
1024/* Return sqrt(x^2+y^2). */
1025#if @GNULIB_HYPOTF@
1026# if @REPLACE_HYPOTF@
1027# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1028# undef hypotf
1029# define hypotf rpl_hypotf
1030# endif
1031_GL_FUNCDECL_RPL (hypotf, float, (float x, float y));
1032_GL_CXXALIAS_RPL (hypotf, float, (float x, float y));
1033# else
1034# if !@HAVE_HYPOTF@
1035_GL_FUNCDECL_SYS (hypotf, float, (float x, float y));
1036# endif
1037_GL_CXXALIAS_SYS (hypotf, float, (float x, float y));
1038# endif
1039_GL_CXXALIASWARN (hypotf);
1040#elif defined GNULIB_POSIXCHECK
1041# undef hypotf
1042# if HAVE_RAW_DECL_HYPOTF
1043_GL_WARN_ON_USE (hypotf, "hypotf is unportable - "
1044 "use gnulib module hypotf for portability");
1045# endif
1046#endif
1047
1048/* Return sqrt(x^2+y^2). */
1049#if @GNULIB_HYPOT@
1050# if @REPLACE_HYPOT@
1051# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1052# undef hypot
1053# define hypot rpl_hypot
1054# endif
1055_GL_FUNCDECL_RPL (hypot, double, (double x, double y));
1056_GL_CXXALIAS_RPL (hypot, double, (double x, double y));
1057# else
1058_GL_CXXALIAS_SYS (hypot, double, (double x, double y));
1059# endif
1060_GL_CXXALIASWARN (hypot);
1061#elif defined GNULIB_POSIXCHECK
1062# undef hypot
1063# if HAVE_RAW_DECL_HYPOT
1064_GL_WARN_ON_USE (hypotf, "hypot has portability problems - "
1065 "use gnulib module hypot for portability");
1066# endif
1067#endif
1068
1069/* Return sqrt(x^2+y^2). */
1070#if @GNULIB_HYPOTL@
1071# if @REPLACE_HYPOTL@
1072# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1073# undef hypotl
1074# define hypotl rpl_hypotl
1075# endif
1076_GL_FUNCDECL_RPL (hypotl, long double, (long double x, long double y));
1077_GL_CXXALIAS_RPL (hypotl, long double, (long double x, long double y));
1078# else
1079# if !@HAVE_HYPOTL@
1080_GL_FUNCDECL_SYS (hypotl, long double, (long double x, long double y));
1081# endif
1082_GL_CXXALIAS_SYS (hypotl, long double, (long double x, long double y));
1083# endif
1084_GL_CXXALIASWARN (hypotl);
1085#elif defined GNULIB_POSIXCHECK
1086# undef hypotl
1087# if HAVE_RAW_DECL_HYPOTL
1088_GL_WARN_ON_USE (hypotl, "hypotl is unportable - "
1089 "use gnulib module hypotl for portability");
1090# endif
1091#endif
1092
1093
1094#if @GNULIB_ILOGBF@
1095# if @REPLACE_ILOGBF@
1096# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1097# undef ilogbf
1098# define ilogbf rpl_ilogbf
1099# endif
1100_GL_FUNCDECL_RPL (ilogbf, int, (float x));
1101_GL_CXXALIAS_RPL (ilogbf, int, (float x));
1102# else
1103# if !@HAVE_ILOGBF@
1104_GL_FUNCDECL_SYS (ilogbf, int, (float x));
1105# endif
1106_GL_CXXALIAS_SYS (ilogbf, int, (float x));
1107# endif
1108_GL_CXXALIASWARN (ilogbf);
1109#elif defined GNULIB_POSIXCHECK
1110# undef ilogbf
1111# if HAVE_RAW_DECL_ILOGBF
1112_GL_WARN_ON_USE (ilogbf, "ilogbf is unportable - "
1113 "use gnulib module ilogbf for portability");
1114# endif
1115#endif
1116
1117#if @GNULIB_ILOGB@
1118# if @REPLACE_ILOGB@
1119# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1120# undef ilogb
1121# define ilogb rpl_ilogb
1122# endif
1123_GL_FUNCDECL_RPL (ilogb, int, (double x));
1124_GL_CXXALIAS_RPL (ilogb, int, (double x));
1125# else
1126# if !@HAVE_ILOGB@
1127_GL_FUNCDECL_SYS (ilogb, int, (double x));
1128# endif
1129_GL_CXXALIAS_SYS (ilogb, int, (double x));
1130# endif
1131_GL_CXXALIASWARN (ilogb);
1132#elif defined GNULIB_POSIXCHECK
1133# undef ilogb
1134# if HAVE_RAW_DECL_ILOGB
1135_GL_WARN_ON_USE (ilogb, "ilogb is unportable - "
1136 "use gnulib module ilogb for portability");
1137# endif
1138#endif
1139
1140#if @GNULIB_ILOGBL@
1141# if !@HAVE_ILOGBL@
1142_GL_FUNCDECL_SYS (ilogbl, int, (long double x));
1143# endif
1144_GL_CXXALIAS_SYS (ilogbl, int, (long double x));
1145_GL_CXXALIASWARN (ilogbl);
1146#elif defined GNULIB_POSIXCHECK
1147# undef ilogbl
1148# if HAVE_RAW_DECL_ILOGBL
1149_GL_WARN_ON_USE (ilogbl, "ilogbl is unportable - "
1150 "use gnulib module ilogbl for portability");
1151# endif
1152#endif
1153
1154
1155/* Return x * 2^exp. */
1156#if @GNULIB_LDEXPF@
1157# if !@HAVE_LDEXPF@
1158# undef ldexpf
1159_GL_FUNCDECL_SYS (ldexpf, float, (float x, int exp));
1160# endif
1161_GL_CXXALIAS_SYS (ldexpf, float, (float x, int exp));
1162_GL_CXXALIASWARN (ldexpf);
1163#elif defined GNULIB_POSIXCHECK
1164# undef ldexpf
1165# if HAVE_RAW_DECL_LDEXPF
1166_GL_WARN_ON_USE (ldexpf, "ldexpf is unportable - "
1167 "use gnulib module ldexpf for portability");
1168# endif
1169#endif
1170
337/* Return x * 2^exp. */ 1171/* Return x * 2^exp. */
338#if @GNULIB_LDEXPL@ && @REPLACE_LDEXPL@ 1172#if @GNULIB_LDEXPL@ && @REPLACE_LDEXPL@
339# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1173# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1174# undef ldexpl
340# define ldexpl rpl_ldexpl 1175# define ldexpl rpl_ldexpl
341# endif 1176# endif
342_GL_FUNCDECL_RPL (ldexpl, long double, (long double x, int exp)); 1177_GL_FUNCDECL_RPL (ldexpl, long double, (long double x, int exp));
@@ -361,17 +1196,553 @@ _GL_WARN_ON_USE (ldexpl, "ldexpl is unportable - "
361#endif 1196#endif
362 1197
363 1198
1199#if @GNULIB_LOGF@
1200# if @REPLACE_LOGF@
1201# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1202# undef logf
1203# define logf rpl_logf
1204# endif
1205_GL_FUNCDECL_RPL (logf, float, (float x));
1206_GL_CXXALIAS_RPL (logf, float, (float x));
1207# else
1208# if !@HAVE_LOGF@
1209# undef logf
1210_GL_FUNCDECL_SYS (logf, float, (float x));
1211# endif
1212_GL_CXXALIAS_SYS (logf, float, (float x));
1213# endif
1214_GL_CXXALIASWARN (logf);
1215#elif defined GNULIB_POSIXCHECK
1216# undef logf
1217# if HAVE_RAW_DECL_LOGF
1218_GL_WARN_ON_USE (logf, "logf is unportable - "
1219 "use gnulib module logf for portability");
1220# endif
1221#endif
1222
1223#if @GNULIB_LOG@
1224# if @REPLACE_LOG@
1225# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1226# undef log
1227# define log rpl_log
1228# endif
1229_GL_FUNCDECL_RPL (log, double, (double x));
1230_GL_CXXALIAS_RPL (log, double, (double x));
1231# else
1232_GL_CXXALIAS_SYS (log, double, (double x));
1233# endif
1234_GL_CXXALIASWARN (log);
1235#elif defined GNULIB_POSIXCHECK
1236# undef log
1237# if HAVE_RAW_DECL_LOG
1238_GL_WARN_ON_USE (log, "log has portability problems - "
1239 "use gnulib module log for portability");
1240# endif
1241#endif
1242
364#if @GNULIB_LOGL@ 1243#if @GNULIB_LOGL@
365# if !@HAVE_LOGL@ || !@HAVE_DECL_LOGL@ 1244# if @REPLACE_LOGL@
1245# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1246# undef logl
1247# define logl rpl_logl
1248# endif
1249_GL_FUNCDECL_RPL (logl, long double, (long double x));
1250_GL_CXXALIAS_RPL (logl, long double, (long double x));
1251# else
1252# if !@HAVE_LOGL@ || !@HAVE_DECL_LOGL@
1253# undef logl
366_GL_FUNCDECL_SYS (logl, long double, (long double x)); 1254_GL_FUNCDECL_SYS (logl, long double, (long double x));
367# endif 1255# endif
368_GL_CXXALIAS_SYS (logl, long double, (long double x)); 1256_GL_CXXALIAS_SYS (logl, long double, (long double x));
1257# endif
369_GL_CXXALIASWARN (logl); 1258_GL_CXXALIASWARN (logl);
370#elif defined GNULIB_POSIXCHECK 1259#elif defined GNULIB_POSIXCHECK
371# undef logl 1260# undef logl
372# if HAVE_RAW_DECL_LOGL 1261# if HAVE_RAW_DECL_LOGL
373_GL_WARN_ON_USE (logl, "logl is unportable - " 1262_GL_WARN_ON_USE (logl, "logl is unportable - "
374 "use gnulib module mathl for portability"); 1263 "use gnulib module logl for portability");
1264# endif
1265#endif
1266
1267
1268#if @GNULIB_LOG10F@
1269# if @REPLACE_LOG10F@
1270# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1271# undef log10f
1272# define log10f rpl_log10f
1273# endif
1274_GL_FUNCDECL_RPL (log10f, float, (float x));
1275_GL_CXXALIAS_RPL (log10f, float, (float x));
1276# else
1277# if !@HAVE_LOG10F@
1278# undef log10f
1279_GL_FUNCDECL_SYS (log10f, float, (float x));
1280# endif
1281_GL_CXXALIAS_SYS (log10f, float, (float x));
1282# endif
1283_GL_CXXALIASWARN (log10f);
1284#elif defined GNULIB_POSIXCHECK
1285# undef log10f
1286# if HAVE_RAW_DECL_LOG10F
1287_GL_WARN_ON_USE (log10f, "log10f is unportable - "
1288 "use gnulib module log10f for portability");
1289# endif
1290#endif
1291
1292#if @GNULIB_LOG10@
1293# if @REPLACE_LOG10@
1294# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1295# undef log10
1296# define log10 rpl_log10
1297# endif
1298_GL_FUNCDECL_RPL (log10, double, (double x));
1299_GL_CXXALIAS_RPL (log10, double, (double x));
1300# else
1301_GL_CXXALIAS_SYS (log10, double, (double x));
1302# endif
1303_GL_CXXALIASWARN (log10);
1304#elif defined GNULIB_POSIXCHECK
1305# undef log10
1306# if HAVE_RAW_DECL_LOG10
1307_GL_WARN_ON_USE (log10, "log10 has portability problems - "
1308 "use gnulib module log10 for portability");
1309# endif
1310#endif
1311
1312#if @GNULIB_LOG10L@
1313# if @REPLACE_LOG10L@
1314# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1315# undef log10l
1316# define log10l rpl_log10l
1317# endif
1318_GL_FUNCDECL_RPL (log10l, long double, (long double x));
1319_GL_CXXALIAS_RPL (log10l, long double, (long double x));
1320# else
1321# if !@HAVE_LOG10L@ || !@HAVE_DECL_LOG10L@
1322# undef log10l
1323_GL_FUNCDECL_SYS (log10l, long double, (long double x));
1324# endif
1325_GL_CXXALIAS_SYS (log10l, long double, (long double x));
1326# endif
1327_GL_CXXALIASWARN (log10l);
1328#elif defined GNULIB_POSIXCHECK
1329# undef log10l
1330# if HAVE_RAW_DECL_LOG10L
1331_GL_WARN_ON_USE (log10l, "log10l is unportable - "
1332 "use gnulib module log10l for portability");
1333# endif
1334#endif
1335
1336
1337#if @GNULIB_LOG1PF@
1338# if @REPLACE_LOG1PF@
1339# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1340# undef log1pf
1341# define log1pf rpl_log1pf
1342# endif
1343_GL_FUNCDECL_RPL (log1pf, float, (float x));
1344_GL_CXXALIAS_RPL (log1pf, float, (float x));
1345# else
1346# if !@HAVE_LOG1PF@
1347_GL_FUNCDECL_SYS (log1pf, float, (float x));
1348# endif
1349_GL_CXXALIAS_SYS (log1pf, float, (float x));
1350# endif
1351_GL_CXXALIASWARN (log1pf);
1352#elif defined GNULIB_POSIXCHECK
1353# undef log1pf
1354# if HAVE_RAW_DECL_LOG1PF
1355_GL_WARN_ON_USE (log1pf, "log1pf is unportable - "
1356 "use gnulib module log1pf for portability");
1357# endif
1358#endif
1359
1360#if @GNULIB_LOG1P@
1361# if @REPLACE_LOG1P@
1362# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1363# undef log1p
1364# define log1p rpl_log1p
1365# endif
1366_GL_FUNCDECL_RPL (log1p, double, (double x));
1367_GL_CXXALIAS_RPL (log1p, double, (double x));
1368# else
1369# if !@HAVE_LOG1P@
1370_GL_FUNCDECL_SYS (log1p, double, (double x));
1371# endif
1372_GL_CXXALIAS_SYS (log1p, double, (double x));
1373# endif
1374_GL_CXXALIASWARN (log1p);
1375#elif defined GNULIB_POSIXCHECK
1376# undef log1p
1377# if HAVE_RAW_DECL_LOG1P
1378_GL_WARN_ON_USE (log1p, "log1p has portability problems - "
1379 "use gnulib module log1p for portability");
1380# endif
1381#endif
1382
1383#if @GNULIB_LOG1PL@
1384# if @REPLACE_LOG1PL@
1385# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1386# undef log1pl
1387# define log1pl rpl_log1pl
1388# endif
1389_GL_FUNCDECL_RPL (log1pl, long double, (long double x));
1390_GL_CXXALIAS_RPL (log1pl, long double, (long double x));
1391# else
1392# if !@HAVE_LOG1PL@
1393_GL_FUNCDECL_SYS (log1pl, long double, (long double x));
1394# endif
1395_GL_CXXALIAS_SYS (log1pl, long double, (long double x));
1396# endif
1397_GL_CXXALIASWARN (log1pl);
1398#elif defined GNULIB_POSIXCHECK
1399# undef log1pl
1400# if HAVE_RAW_DECL_LOG1PL
1401_GL_WARN_ON_USE (log1pl, "log1pl has portability problems - "
1402 "use gnulib module log1pl for portability");
1403# endif
1404#endif
1405
1406
1407#if @GNULIB_LOG2F@
1408# if @REPLACE_LOG2F@
1409# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1410# undef log2f
1411# define log2f rpl_log2f
1412# endif
1413_GL_FUNCDECL_RPL (log2f, float, (float x));
1414_GL_CXXALIAS_RPL (log2f, float, (float x));
1415# else
1416# if !@HAVE_DECL_LOG2F@
1417# undef log2f
1418_GL_FUNCDECL_SYS (log2f, float, (float x));
1419# endif
1420_GL_CXXALIAS_SYS (log2f, float, (float x));
1421# endif
1422_GL_CXXALIASWARN (log2f);
1423#elif defined GNULIB_POSIXCHECK
1424# undef log2f
1425# if HAVE_RAW_DECL_LOG2F
1426_GL_WARN_ON_USE (log2f, "log2f is unportable - "
1427 "use gnulib module log2f for portability");
1428# endif
1429#endif
1430
1431#if @GNULIB_LOG2@
1432# if @REPLACE_LOG2@
1433# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1434# undef log2
1435# define log2 rpl_log2
1436# endif
1437_GL_FUNCDECL_RPL (log2, double, (double x));
1438_GL_CXXALIAS_RPL (log2, double, (double x));
1439# else
1440# if !@HAVE_DECL_LOG2@
1441# undef log2
1442_GL_FUNCDECL_SYS (log2, double, (double x));
1443# endif
1444_GL_CXXALIAS_SYS (log2, double, (double x));
1445# endif
1446_GL_CXXALIASWARN (log2);
1447#elif defined GNULIB_POSIXCHECK
1448# undef log2
1449# if HAVE_RAW_DECL_LOG2
1450_GL_WARN_ON_USE (log2, "log2 is unportable - "
1451 "use gnulib module log2 for portability");
1452# endif
1453#endif
1454
1455#if @GNULIB_LOG2L@
1456# if @REPLACE_LOG2L@
1457# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1458# undef log2l
1459# define log2l rpl_log2l
1460# endif
1461_GL_FUNCDECL_RPL (log2l, long double, (long double x));
1462_GL_CXXALIAS_RPL (log2l, long double, (long double x));
1463# else
1464# if !@HAVE_DECL_LOG2L@
1465_GL_FUNCDECL_SYS (log2l, long double, (long double x));
1466# endif
1467_GL_CXXALIAS_SYS (log2l, long double, (long double x));
1468# endif
1469_GL_CXXALIASWARN (log2l);
1470#elif defined GNULIB_POSIXCHECK
1471# undef log2l
1472# if HAVE_RAW_DECL_LOG2L
1473_GL_WARN_ON_USE (log2l, "log2l is unportable - "
1474 "use gnulib module log2l for portability");
1475# endif
1476#endif
1477
1478
1479#if @GNULIB_LOGBF@
1480# if @REPLACE_LOGBF@
1481# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1482# undef logbf
1483# define logbf rpl_logbf
1484# endif
1485_GL_FUNCDECL_RPL (logbf, float, (float x));
1486_GL_CXXALIAS_RPL (logbf, float, (float x));
1487# else
1488# if !@HAVE_LOGBF@
1489_GL_FUNCDECL_SYS (logbf, float, (float x));
1490# endif
1491_GL_CXXALIAS_SYS (logbf, float, (float x));
1492# endif
1493_GL_CXXALIASWARN (logbf);
1494#elif defined GNULIB_POSIXCHECK
1495# undef logbf
1496# if HAVE_RAW_DECL_LOGBF
1497_GL_WARN_ON_USE (logbf, "logbf is unportable - "
1498 "use gnulib module logbf for portability");
1499# endif
1500#endif
1501
1502#if @GNULIB_LOGB@
1503# if @REPLACE_LOGB@
1504# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1505# undef logb
1506# define logb rpl_logb
1507# endif
1508_GL_FUNCDECL_RPL (logb, double, (double x));
1509_GL_CXXALIAS_RPL (logb, double, (double x));
1510# else
1511# if !@HAVE_DECL_LOGB@
1512_GL_FUNCDECL_SYS (logb, double, (double x));
1513# endif
1514_GL_CXXALIAS_SYS (logb, double, (double x));
1515# endif
1516_GL_CXXALIASWARN (logb);
1517#elif defined GNULIB_POSIXCHECK
1518# undef logb
1519# if HAVE_RAW_DECL_LOGB
1520_GL_WARN_ON_USE (logb, "logb is unportable - "
1521 "use gnulib module logb for portability");
1522# endif
1523#endif
1524
1525#if @GNULIB_LOGBL@
1526# if @REPLACE_LOGBL@
1527# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1528# undef logbl
1529# define logbl rpl_logbl
1530# endif
1531_GL_FUNCDECL_RPL (logbl, long double, (long double x));
1532_GL_CXXALIAS_RPL (logbl, long double, (long double x));
1533# else
1534# if !@HAVE_LOGBL@
1535_GL_FUNCDECL_SYS (logbl, long double, (long double x));
1536# endif
1537_GL_CXXALIAS_SYS (logbl, long double, (long double x));
1538# endif
1539_GL_CXXALIASWARN (logbl);
1540#elif defined GNULIB_POSIXCHECK
1541# undef logbl
1542# if HAVE_RAW_DECL_LOGBL
1543_GL_WARN_ON_USE (logbl, "logbl is unportable - "
1544 "use gnulib module logbl for portability");
1545# endif
1546#endif
1547
1548
1549#if @GNULIB_MODFF@
1550# if @REPLACE_MODFF@
1551# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1552# undef modff
1553# define modff rpl_modff
1554# endif
1555_GL_FUNCDECL_RPL (modff, float, (float x, float *iptr) _GL_ARG_NONNULL ((2)));
1556_GL_CXXALIAS_RPL (modff, float, (float x, float *iptr));
1557# else
1558# if !@HAVE_MODFF@
1559# undef modff
1560_GL_FUNCDECL_SYS (modff, float, (float x, float *iptr) _GL_ARG_NONNULL ((2)));
1561# endif
1562_GL_CXXALIAS_SYS (modff, float, (float x, float *iptr));
1563# endif
1564_GL_CXXALIASWARN (modff);
1565#elif defined GNULIB_POSIXCHECK
1566# undef modff
1567# if HAVE_RAW_DECL_MODFF
1568_GL_WARN_ON_USE (modff, "modff is unportable - "
1569 "use gnulib module modff for portability");
1570# endif
1571#endif
1572
1573#if @GNULIB_MODF@
1574# if @REPLACE_MODF@
1575# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1576# undef modf
1577# define modf rpl_modf
1578# endif
1579_GL_FUNCDECL_RPL (modf, double, (double x, double *iptr) _GL_ARG_NONNULL ((2)));
1580_GL_CXXALIAS_RPL (modf, double, (double x, double *iptr));
1581# else
1582_GL_CXXALIAS_SYS (modf, double, (double x, double *iptr));
1583# endif
1584_GL_CXXALIASWARN (modf);
1585#elif defined GNULIB_POSIXCHECK
1586# undef modf
1587# if HAVE_RAW_DECL_MODF
1588_GL_WARN_ON_USE (modf, "modf has portability problems - "
1589 "use gnulib module modf for portability");
1590# endif
1591#endif
1592
1593#if @GNULIB_MODFL@
1594# if @REPLACE_MODFL@
1595# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1596# undef modfl
1597# define modfl rpl_modfl
1598# endif
1599_GL_FUNCDECL_RPL (modfl, long double, (long double x, long double *iptr)
1600 _GL_ARG_NONNULL ((2)));
1601_GL_CXXALIAS_RPL (modfl, long double, (long double x, long double *iptr));
1602# else
1603# if !@HAVE_MODFL@
1604# undef modfl
1605_GL_FUNCDECL_SYS (modfl, long double, (long double x, long double *iptr)
1606 _GL_ARG_NONNULL ((2)));
1607# endif
1608_GL_CXXALIAS_SYS (modfl, long double, (long double x, long double *iptr));
1609# endif
1610_GL_CXXALIASWARN (modfl);
1611#elif defined GNULIB_POSIXCHECK
1612# undef modfl
1613# if HAVE_RAW_DECL_MODFL
1614_GL_WARN_ON_USE (modfl, "modfl is unportable - "
1615 "use gnulib module modfl for portability");
1616# endif
1617#endif
1618
1619
1620#if @GNULIB_POWF@
1621# if !@HAVE_POWF@
1622# undef powf
1623_GL_FUNCDECL_SYS (powf, float, (float x, float y));
1624# endif
1625_GL_CXXALIAS_SYS (powf, float, (float x, float y));
1626_GL_CXXALIASWARN (powf);
1627#elif defined GNULIB_POSIXCHECK
1628# undef powf
1629# if HAVE_RAW_DECL_POWF
1630_GL_WARN_ON_USE (powf, "powf is unportable - "
1631 "use gnulib module powf for portability");
1632# endif
1633#endif
1634
1635
1636#if @GNULIB_REMAINDERF@
1637# if @REPLACE_REMAINDERF@
1638# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1639# undef remainderf
1640# define remainderf rpl_remainderf
1641# endif
1642_GL_FUNCDECL_RPL (remainderf, float, (float x, float y));
1643_GL_CXXALIAS_RPL (remainderf, float, (float x, float y));
1644# else
1645# if !@HAVE_REMAINDERF@
1646_GL_FUNCDECL_SYS (remainderf, float, (float x, float y));
1647# endif
1648_GL_CXXALIAS_SYS (remainderf, float, (float x, float y));
1649# endif
1650_GL_CXXALIASWARN (remainderf);
1651#elif defined GNULIB_POSIXCHECK
1652# undef remainderf
1653# if HAVE_RAW_DECL_REMAINDERF
1654_GL_WARN_ON_USE (remainderf, "remainderf is unportable - "
1655 "use gnulib module remainderf for portability");
1656# endif
1657#endif
1658
1659#if @GNULIB_REMAINDER@
1660# if @REPLACE_REMAINDER@
1661# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1662# undef remainder
1663# define remainder rpl_remainder
1664# endif
1665_GL_FUNCDECL_RPL (remainder, double, (double x, double y));
1666_GL_CXXALIAS_RPL (remainder, double, (double x, double y));
1667# else
1668# if !@HAVE_REMAINDER@ || !@HAVE_DECL_REMAINDER@
1669_GL_FUNCDECL_SYS (remainder, double, (double x, double y));
1670# endif
1671_GL_CXXALIAS_SYS (remainder, double, (double x, double y));
1672# endif
1673_GL_CXXALIASWARN (remainder);
1674#elif defined GNULIB_POSIXCHECK
1675# undef remainder
1676# if HAVE_RAW_DECL_REMAINDER
1677_GL_WARN_ON_USE (remainder, "remainder is unportable - "
1678 "use gnulib module remainder for portability");
1679# endif
1680#endif
1681
1682#if @GNULIB_REMAINDERL@
1683# if @REPLACE_REMAINDERL@
1684# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1685# undef remainderl
1686# define remainderl rpl_remainderl
1687# endif
1688_GL_FUNCDECL_RPL (remainderl, long double, (long double x, long double y));
1689_GL_CXXALIAS_RPL (remainderl, long double, (long double x, long double y));
1690# else
1691# if !@HAVE_DECL_REMAINDERL@
1692# undef remainderl
1693_GL_FUNCDECL_SYS (remainderl, long double, (long double x, long double y));
1694# endif
1695_GL_CXXALIAS_SYS (remainderl, long double, (long double x, long double y));
1696# endif
1697_GL_CXXALIASWARN (remainderl);
1698#elif defined GNULIB_POSIXCHECK
1699# undef remainderl
1700# if HAVE_RAW_DECL_REMAINDERL
1701_GL_WARN_ON_USE (remainderl, "remainderl is unportable - "
1702 "use gnulib module remainderl for portability");
1703# endif
1704#endif
1705
1706
1707#if @GNULIB_RINTF@
1708# if !@HAVE_DECL_RINTF@
1709_GL_FUNCDECL_SYS (rintf, float, (float x));
1710# endif
1711_GL_CXXALIAS_SYS (rintf, float, (float x));
1712_GL_CXXALIASWARN (rintf);
1713#elif defined GNULIB_POSIXCHECK
1714# undef rintf
1715# if HAVE_RAW_DECL_RINTF
1716_GL_WARN_ON_USE (rintf, "rintf is unportable - "
1717 "use gnulib module rintf for portability");
1718# endif
1719#endif
1720
1721#if @GNULIB_RINT@
1722# if !@HAVE_RINT@
1723_GL_FUNCDECL_SYS (rint, double, (double x));
1724# endif
1725_GL_CXXALIAS_SYS (rint, double, (double x));
1726_GL_CXXALIASWARN (rint);
1727#elif defined GNULIB_POSIXCHECK
1728# undef rint
1729# if HAVE_RAW_DECL_RINT
1730_GL_WARN_ON_USE (rint, "rint is unportable - "
1731 "use gnulib module rint for portability");
1732# endif
1733#endif
1734
1735#if @GNULIB_RINTL@
1736# if !@HAVE_RINTL@
1737_GL_FUNCDECL_SYS (rintl, long double, (long double x));
1738# endif
1739_GL_CXXALIAS_SYS (rintl, long double, (long double x));
1740_GL_CXXALIASWARN (rintl);
1741#elif defined GNULIB_POSIXCHECK
1742# undef rintl
1743# if HAVE_RAW_DECL_RINTL
1744_GL_WARN_ON_USE (rintl, "rintl is unportable - "
1745 "use gnulib module rintl for portability");
375# endif 1746# endif
376#endif 1747#endif
377 1748
@@ -432,6 +1803,7 @@ _GL_FUNCDECL_RPL (roundl, long double, (long double x));
432_GL_CXXALIAS_RPL (roundl, long double, (long double x)); 1803_GL_CXXALIAS_RPL (roundl, long double, (long double x));
433# else 1804# else
434# if !@HAVE_DECL_ROUNDL@ 1805# if !@HAVE_DECL_ROUNDL@
1806# undef roundl
435_GL_FUNCDECL_SYS (roundl, long double, (long double x)); 1807_GL_FUNCDECL_SYS (roundl, long double, (long double x));
436# endif 1808# endif
437_GL_CXXALIAS_SYS (roundl, long double, (long double x)); 1809_GL_CXXALIAS_SYS (roundl, long double, (long double x));
@@ -446,8 +1818,24 @@ _GL_WARN_ON_USE (roundl, "roundl is unportable - "
446#endif 1818#endif
447 1819
448 1820
1821#if @GNULIB_SINF@
1822# if !@HAVE_SINF@
1823# undef sinf
1824_GL_FUNCDECL_SYS (sinf, float, (float x));
1825# endif
1826_GL_CXXALIAS_SYS (sinf, float, (float x));
1827_GL_CXXALIASWARN (sinf);
1828#elif defined GNULIB_POSIXCHECK
1829# undef sinf
1830# if HAVE_RAW_DECL_SINF
1831_GL_WARN_ON_USE (sinf, "sinf is unportable - "
1832 "use gnulib module sinf for portability");
1833# endif
1834#endif
1835
449#if @GNULIB_SINL@ 1836#if @GNULIB_SINL@
450# if !@HAVE_SINL@ || !@HAVE_DECL_SINL@ 1837# if !@HAVE_SINL@ || !@HAVE_DECL_SINL@
1838# undef sinl
451_GL_FUNCDECL_SYS (sinl, long double, (long double x)); 1839_GL_FUNCDECL_SYS (sinl, long double, (long double x));
452# endif 1840# endif
453_GL_CXXALIAS_SYS (sinl, long double, (long double x)); 1841_GL_CXXALIAS_SYS (sinl, long double, (long double x));
@@ -456,28 +1844,85 @@ _GL_CXXALIASWARN (sinl);
456# undef sinl 1844# undef sinl
457# if HAVE_RAW_DECL_SINL 1845# if HAVE_RAW_DECL_SINL
458_GL_WARN_ON_USE (sinl, "sinl is unportable - " 1846_GL_WARN_ON_USE (sinl, "sinl is unportable - "
459 "use gnulib module mathl for portability"); 1847 "use gnulib module sinl for portability");
1848# endif
1849#endif
1850
1851
1852#if @GNULIB_SINHF@
1853# if !@HAVE_SINHF@
1854# undef sinhf
1855_GL_FUNCDECL_SYS (sinhf, float, (float x));
1856# endif
1857_GL_CXXALIAS_SYS (sinhf, float, (float x));
1858_GL_CXXALIASWARN (sinhf);
1859#elif defined GNULIB_POSIXCHECK
1860# undef sinhf
1861# if HAVE_RAW_DECL_SINHF
1862_GL_WARN_ON_USE (sinhf, "sinhf is unportable - "
1863 "use gnulib module sinhf for portability");
460# endif 1864# endif
461#endif 1865#endif
462 1866
463 1867
1868#if @GNULIB_SQRTF@
1869# if !@HAVE_SQRTF@
1870# undef sqrtf
1871_GL_FUNCDECL_SYS (sqrtf, float, (float x));
1872# endif
1873_GL_CXXALIAS_SYS (sqrtf, float, (float x));
1874_GL_CXXALIASWARN (sqrtf);
1875#elif defined GNULIB_POSIXCHECK
1876# undef sqrtf
1877# if HAVE_RAW_DECL_SQRTF
1878_GL_WARN_ON_USE (sqrtf, "sqrtf is unportable - "
1879 "use gnulib module sqrtf for portability");
1880# endif
1881#endif
1882
464#if @GNULIB_SQRTL@ 1883#if @GNULIB_SQRTL@
465# if !@HAVE_SQRTL@ || !@HAVE_DECL_SQRTL@ 1884# if @REPLACE_SQRTL@
1885# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1886# undef sqrtl
1887# define sqrtl rpl_sqrtl
1888# endif
1889_GL_FUNCDECL_RPL (sqrtl, long double, (long double x));
1890_GL_CXXALIAS_RPL (sqrtl, long double, (long double x));
1891# else
1892# if !@HAVE_SQRTL@ || !@HAVE_DECL_SQRTL@
1893# undef sqrtl
466_GL_FUNCDECL_SYS (sqrtl, long double, (long double x)); 1894_GL_FUNCDECL_SYS (sqrtl, long double, (long double x));
467# endif 1895# endif
468_GL_CXXALIAS_SYS (sqrtl, long double, (long double x)); 1896_GL_CXXALIAS_SYS (sqrtl, long double, (long double x));
1897# endif
469_GL_CXXALIASWARN (sqrtl); 1898_GL_CXXALIASWARN (sqrtl);
470#elif defined GNULIB_POSIXCHECK 1899#elif defined GNULIB_POSIXCHECK
471# undef sqrtl 1900# undef sqrtl
472# if HAVE_RAW_DECL_SQRTL 1901# if HAVE_RAW_DECL_SQRTL
473_GL_WARN_ON_USE (sqrtl, "sqrtl is unportable - " 1902_GL_WARN_ON_USE (sqrtl, "sqrtl is unportable - "
474 "use gnulib module mathl for portability"); 1903 "use gnulib module sqrtl for portability");
475# endif 1904# endif
476#endif 1905#endif
477 1906
478 1907
1908#if @GNULIB_TANF@
1909# if !@HAVE_TANF@
1910# undef tanf
1911_GL_FUNCDECL_SYS (tanf, float, (float x));
1912# endif
1913_GL_CXXALIAS_SYS (tanf, float, (float x));
1914_GL_CXXALIASWARN (tanf);
1915#elif defined GNULIB_POSIXCHECK
1916# undef tanf
1917# if HAVE_RAW_DECL_TANF
1918_GL_WARN_ON_USE (tanf, "tanf is unportable - "
1919 "use gnulib module tanf for portability");
1920# endif
1921#endif
1922
479#if @GNULIB_TANL@ 1923#if @GNULIB_TANL@
480# if !@HAVE_TANL@ || !@HAVE_DECL_TANL@ 1924# if !@HAVE_TANL@ || !@HAVE_DECL_TANL@
1925# undef tanl
481_GL_FUNCDECL_SYS (tanl, long double, (long double x)); 1926_GL_FUNCDECL_SYS (tanl, long double, (long double x));
482# endif 1927# endif
483_GL_CXXALIAS_SYS (tanl, long double, (long double x)); 1928_GL_CXXALIAS_SYS (tanl, long double, (long double x));
@@ -486,16 +1931,40 @@ _GL_CXXALIASWARN (tanl);
486# undef tanl 1931# undef tanl
487# if HAVE_RAW_DECL_TANL 1932# if HAVE_RAW_DECL_TANL
488_GL_WARN_ON_USE (tanl, "tanl is unportable - " 1933_GL_WARN_ON_USE (tanl, "tanl is unportable - "
489 "use gnulib module mathl for portability"); 1934 "use gnulib module tanl for portability");
1935# endif
1936#endif
1937
1938
1939#if @GNULIB_TANHF@
1940# if !@HAVE_TANHF@
1941# undef tanhf
1942_GL_FUNCDECL_SYS (tanhf, float, (float x));
1943# endif
1944_GL_CXXALIAS_SYS (tanhf, float, (float x));
1945_GL_CXXALIASWARN (tanhf);
1946#elif defined GNULIB_POSIXCHECK
1947# undef tanhf
1948# if HAVE_RAW_DECL_TANHF
1949_GL_WARN_ON_USE (tanhf, "tanhf is unportable - "
1950 "use gnulib module tanhf for portability");
490# endif 1951# endif
491#endif 1952#endif
492 1953
493 1954
494#if @GNULIB_TRUNCF@ 1955#if @GNULIB_TRUNCF@
495# if !@HAVE_DECL_TRUNCF@ 1956# if @REPLACE_TRUNCF@
1957# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1958# define truncf rpl_truncf
1959# endif
1960_GL_FUNCDECL_RPL (truncf, float, (float x));
1961_GL_CXXALIAS_RPL (truncf, float, (float x));
1962# else
1963# if !@HAVE_DECL_TRUNCF@
496_GL_FUNCDECL_SYS (truncf, float, (float x)); 1964_GL_FUNCDECL_SYS (truncf, float, (float x));
497# endif 1965# endif
498_GL_CXXALIAS_SYS (truncf, float, (float x)); 1966_GL_CXXALIAS_SYS (truncf, float, (float x));
1967# endif
499_GL_CXXALIASWARN (truncf); 1968_GL_CXXALIASWARN (truncf);
500#elif defined GNULIB_POSIXCHECK 1969#elif defined GNULIB_POSIXCHECK
501# undef truncf 1970# undef truncf
@@ -506,10 +1975,18 @@ _GL_WARN_ON_USE (truncf, "truncf is unportable - "
506#endif 1975#endif
507 1976
508#if @GNULIB_TRUNC@ 1977#if @GNULIB_TRUNC@
509# if !@HAVE_DECL_TRUNC@ 1978# if @REPLACE_TRUNC@
1979# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1980# define trunc rpl_trunc
1981# endif
1982_GL_FUNCDECL_RPL (trunc, double, (double x));
1983_GL_CXXALIAS_RPL (trunc, double, (double x));
1984# else
1985# if !@HAVE_DECL_TRUNC@
510_GL_FUNCDECL_SYS (trunc, double, (double x)); 1986_GL_FUNCDECL_SYS (trunc, double, (double x));
511# endif 1987# endif
512_GL_CXXALIAS_SYS (trunc, double, (double x)); 1988_GL_CXXALIAS_SYS (trunc, double, (double x));
1989# endif
513_GL_CXXALIASWARN (trunc); 1990_GL_CXXALIASWARN (trunc);
514#elif defined GNULIB_POSIXCHECK 1991#elif defined GNULIB_POSIXCHECK
515# undef trunc 1992# undef trunc
@@ -543,6 +2020,10 @@ _GL_WARN_ON_USE (truncl, "truncl is unportable - "
543#endif 2020#endif
544 2021
545 2022
2023/* Definitions of function-like macros come here, after the function
2024 declarations. */
2025
2026
546#if @GNULIB_ISFINITE@ 2027#if @GNULIB_ISFINITE@
547# if @REPLACE_ISFINITE@ 2028# if @REPLACE_ISFINITE@
548_GL_EXTERN_C int gl_isfinitef (float x); 2029_GL_EXTERN_C int gl_isfinitef (float x);
@@ -554,6 +2035,13 @@ _GL_EXTERN_C int gl_isfinitel (long double x);
554 sizeof (x) == sizeof (double) ? gl_isfinited (x) : \ 2035 sizeof (x) == sizeof (double) ? gl_isfinited (x) : \
555 gl_isfinitef (x)) 2036 gl_isfinitef (x))
556# endif 2037# endif
2038# ifdef __cplusplus
2039# ifdef isfinite
2040_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isfinite)
2041# undef isfinite
2042_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isfinite)
2043# endif
2044# endif
557#elif defined GNULIB_POSIXCHECK 2045#elif defined GNULIB_POSIXCHECK
558# if defined isfinite 2046# if defined isfinite
559_GL_WARN_REAL_FLOATING_DECL (isfinite); 2047_GL_WARN_REAL_FLOATING_DECL (isfinite);
@@ -574,6 +2062,13 @@ _GL_EXTERN_C int gl_isinfl (long double x);
574 sizeof (x) == sizeof (double) ? gl_isinfd (x) : \ 2062 sizeof (x) == sizeof (double) ? gl_isinfd (x) : \
575 gl_isinff (x)) 2063 gl_isinff (x))
576# endif 2064# endif
2065# ifdef __cplusplus
2066# ifdef isinf
2067_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isinf)
2068# undef isinf
2069_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isinf)
2070# endif
2071# endif
577#elif defined GNULIB_POSIXCHECK 2072#elif defined GNULIB_POSIXCHECK
578# if defined isinf 2073# if defined isinf
579_GL_WARN_REAL_FLOATING_DECL (isinf); 2074_GL_WARN_REAL_FLOATING_DECL (isinf);
@@ -609,7 +2104,8 @@ _GL_EXTERN_C int isnanf (float x);
609 This function is a gnulib extension, unlike isnan() which applied only 2104 This function is a gnulib extension, unlike isnan() which applied only
610 to 'double' numbers earlier but now is a type-generic macro. */ 2105 to 'double' numbers earlier but now is a type-generic macro. */
611# if @HAVE_ISNAND@ 2106# if @HAVE_ISNAND@
612/* The original <math.h> included above provides a declaration of isnan macro. */ 2107/* The original <math.h> included above provides a declaration of isnan
2108 macro. */
613# if __GNUC__ >= 4 2109# if __GNUC__ >= 4
614 /* GCC 4.0 and newer provides three built-ins for isnan. */ 2110 /* GCC 4.0 and newer provides three built-ins for isnan. */
615# undef isnand 2111# undef isnand
@@ -629,7 +2125,8 @@ _GL_EXTERN_C int isnand (double x);
629#if @GNULIB_ISNANL@ 2125#if @GNULIB_ISNANL@
630/* Test for NaN for 'long double' numbers. */ 2126/* Test for NaN for 'long double' numbers. */
631# if @HAVE_ISNANL@ 2127# if @HAVE_ISNANL@
632/* The original <math.h> included above provides a declaration of isnan macro or (older) isnanl function. */ 2128/* The original <math.h> included above provides a declaration of isnan
2129 macro or (older) isnanl function. */
633# if __GNUC__ >= 4 2130# if __GNUC__ >= 4
634 /* GCC 4.0 and newer provides three built-ins for isnan. */ 2131 /* GCC 4.0 and newer provides three built-ins for isnan. */
635# undef isnanl 2132# undef isnanl
@@ -642,7 +2139,7 @@ _GL_EXTERN_C int isnand (double x);
642/* Test whether X is a NaN. */ 2139/* Test whether X is a NaN. */
643# undef isnanl 2140# undef isnanl
644# define isnanl rpl_isnanl 2141# define isnanl rpl_isnanl
645_GL_EXTERN_C int isnanl (long double x); 2142_GL_EXTERN_C int isnanl (long double x) _GL_ATTRIBUTE_CONST;
646# endif 2143# endif
647#endif 2144#endif
648 2145
@@ -654,7 +2151,7 @@ _GL_EXTERN_C int isnanl (long double x);
654 that recursively expand back to isnan. So use the gnulib 2151 that recursively expand back to isnan. So use the gnulib
655 replacements for them directly. */ 2152 replacements for them directly. */
656# if @HAVE_ISNANF@ && __GNUC__ >= 4 2153# if @HAVE_ISNANF@ && __GNUC__ >= 4
657# define gl_isnan_f(x) __builtin_isnan ((float)(x)) 2154# define gl_isnan_f(x) __builtin_isnanf ((float)(x))
658# else 2155# else
659_GL_EXTERN_C int rpl_isnanf (float x); 2156_GL_EXTERN_C int rpl_isnanf (float x);
660# define gl_isnan_f(x) rpl_isnanf (x) 2157# define gl_isnan_f(x) rpl_isnanf (x)
@@ -666,9 +2163,9 @@ _GL_EXTERN_C int rpl_isnand (double x);
666# define gl_isnan_d(x) rpl_isnand (x) 2163# define gl_isnan_d(x) rpl_isnand (x)
667# endif 2164# endif
668# if @HAVE_ISNANL@ && __GNUC__ >= 4 2165# if @HAVE_ISNANL@ && __GNUC__ >= 4
669# define gl_isnan_l(x) __builtin_isnan ((long double)(x)) 2166# define gl_isnan_l(x) __builtin_isnanl ((long double)(x))
670# else 2167# else
671_GL_EXTERN_C int rpl_isnanl (long double x); 2168_GL_EXTERN_C int rpl_isnanl (long double x) _GL_ATTRIBUTE_CONST;
672# define gl_isnan_l(x) rpl_isnanl (x) 2169# define gl_isnan_l(x) rpl_isnanl (x)
673# endif 2170# endif
674# undef isnan 2171# undef isnan
@@ -676,6 +2173,24 @@ _GL_EXTERN_C int rpl_isnanl (long double x);
676 (sizeof (x) == sizeof (long double) ? gl_isnan_l (x) : \ 2173 (sizeof (x) == sizeof (long double) ? gl_isnan_l (x) : \
677 sizeof (x) == sizeof (double) ? gl_isnan_d (x) : \ 2174 sizeof (x) == sizeof (double) ? gl_isnan_d (x) : \
678 gl_isnan_f (x)) 2175 gl_isnan_f (x))
2176# elif __GNUC__ >= 4
2177# undef isnan
2178# define isnan(x) \
2179 (sizeof (x) == sizeof (long double) ? __builtin_isnanl ((long double)(x)) : \
2180 sizeof (x) == sizeof (double) ? __builtin_isnan ((double)(x)) : \
2181 __builtin_isnanf ((float)(x)))
2182# endif
2183# ifdef __cplusplus
2184# ifdef isnan
2185_GL_MATH_CXX_REAL_FLOATING_DECL_1 (isnan)
2186# undef isnan
2187_GL_MATH_CXX_REAL_FLOATING_DECL_2 (isnan)
2188# endif
2189# else
2190/* Ensure isnan is a macro. */
2191# ifndef isnan
2192# define isnan isnan
2193# endif
679# endif 2194# endif
680#elif defined GNULIB_POSIXCHECK 2195#elif defined GNULIB_POSIXCHECK
681# if defined isnan 2196# if defined isnan
@@ -700,12 +2215,14 @@ _GL_WARN_REAL_FLOATING_DECL (isnan);
700_GL_EXTERN_C int gl_signbitf (float arg); 2215_GL_EXTERN_C int gl_signbitf (float arg);
701_GL_EXTERN_C int gl_signbitd (double arg); 2216_GL_EXTERN_C int gl_signbitd (double arg);
702_GL_EXTERN_C int gl_signbitl (long double arg); 2217_GL_EXTERN_C int gl_signbitl (long double arg);
703# if __GNUC__ >= 2 && !__STRICT_ANSI__ 2218# if __GNUC__ >= 2 && !defined __STRICT_ANSI__
2219# define _GL_NUM_UINT_WORDS(type) \
2220 ((sizeof (type) + sizeof (unsigned int) - 1) / sizeof (unsigned int))
704# if defined FLT_SIGNBIT_WORD && defined FLT_SIGNBIT_BIT && !defined gl_signbitf 2221# if defined FLT_SIGNBIT_WORD && defined FLT_SIGNBIT_BIT && !defined gl_signbitf
705# define gl_signbitf_OPTIMIZED_MACRO 2222# define gl_signbitf_OPTIMIZED_MACRO
706# define gl_signbitf(arg) \ 2223# define gl_signbitf(arg) \
707 ({ union { float _value; \ 2224 ({ union { float _value; \
708 unsigned int _word[(sizeof (float) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \ 2225 unsigned int _word[_GL_NUM_UINT_WORDS (float)]; \
709 } _m; \ 2226 } _m; \
710 _m._value = (arg); \ 2227 _m._value = (arg); \
711 (_m._word[FLT_SIGNBIT_WORD] >> FLT_SIGNBIT_BIT) & 1; \ 2228 (_m._word[FLT_SIGNBIT_WORD] >> FLT_SIGNBIT_BIT) & 1; \
@@ -714,8 +2231,8 @@ _GL_EXTERN_C int gl_signbitl (long double arg);
714# if defined DBL_SIGNBIT_WORD && defined DBL_SIGNBIT_BIT && !defined gl_signbitd 2231# if defined DBL_SIGNBIT_WORD && defined DBL_SIGNBIT_BIT && !defined gl_signbitd
715# define gl_signbitd_OPTIMIZED_MACRO 2232# define gl_signbitd_OPTIMIZED_MACRO
716# define gl_signbitd(arg) \ 2233# define gl_signbitd(arg) \
717 ({ union { double _value; \ 2234 ({ union { double _value; \
718 unsigned int _word[(sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \ 2235 unsigned int _word[_GL_NUM_UINT_WORDS (double)]; \
719 } _m; \ 2236 } _m; \
720 _m._value = (arg); \ 2237 _m._value = (arg); \
721 (_m._word[DBL_SIGNBIT_WORD] >> DBL_SIGNBIT_BIT) & 1; \ 2238 (_m._word[DBL_SIGNBIT_WORD] >> DBL_SIGNBIT_BIT) & 1; \
@@ -725,10 +2242,10 @@ _GL_EXTERN_C int gl_signbitl (long double arg);
725# define gl_signbitl_OPTIMIZED_MACRO 2242# define gl_signbitl_OPTIMIZED_MACRO
726# define gl_signbitl(arg) \ 2243# define gl_signbitl(arg) \
727 ({ union { long double _value; \ 2244 ({ union { long double _value; \
728 unsigned int _word[(sizeof (long double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \ 2245 unsigned int _word[_GL_NUM_UINT_WORDS (long double)]; \
729 } _m; \ 2246 } _m; \
730 _m._value = (arg); \ 2247 _m._value = (arg); \
731 (_m._word[LDBL_SIGNBIT_WORD] >> LDBL_SIGNBIT_BIT) & 1; \ 2248 (_m._word[LDBL_SIGNBIT_WORD] >> LDBL_SIGNBIT_BIT) & 1; \
732 }) 2249 })
733# endif 2250# endif
734# endif 2251# endif
@@ -737,6 +2254,13 @@ _GL_EXTERN_C int gl_signbitl (long double arg);
737 sizeof (x) == sizeof (double) ? gl_signbitd (x) : \ 2254 sizeof (x) == sizeof (double) ? gl_signbitd (x) : \
738 gl_signbitf (x)) 2255 gl_signbitf (x))
739# endif 2256# endif
2257# ifdef __cplusplus
2258# ifdef signbit
2259_GL_MATH_CXX_REAL_FLOATING_DECL_1 (signbit)
2260# undef signbit
2261_GL_MATH_CXX_REAL_FLOATING_DECL_2 (signbit)
2262# endif
2263# endif
740#elif defined GNULIB_POSIXCHECK 2264#elif defined GNULIB_POSIXCHECK
741# if defined signbit 2265# if defined signbit
742_GL_WARN_REAL_FLOATING_DECL (signbit); 2266_GL_WARN_REAL_FLOATING_DECL (signbit);
@@ -745,6 +2269,7 @@ _GL_WARN_REAL_FLOATING_DECL (signbit);
745# endif 2269# endif
746#endif 2270#endif
747 2271
2272_GL_INLINE_HEADER_END
748 2273
749#endif /* _GL_MATH_H */ 2274#endif /* _@GUARD_PREFIX@_MATH_H */
750#endif /* _GL_MATH_H */ 2275#endif /* _@GUARD_PREFIX@_MATH_H */
diff --git a/gl/mbrtowc.c b/gl/mbrtowc.c
index 5c2650e..5ee44ae 100644
--- a/gl/mbrtowc.c
+++ b/gl/mbrtowc.c
@@ -1,5 +1,5 @@
1/* Convert multibyte character to wide character. 1/* Convert multibyte character to wide character.
2 Copyright (C) 1999-2002, 2005-2010 Free Software Foundation, Inc. 2 Copyright (C) 1999-2002, 2005-2013 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2008. 3 Written by Bruno Haible <bruno@clisp.org>, 2008.
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
@@ -40,9 +40,6 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
40{ 40{
41 char *pstate = (char *)ps; 41 char *pstate = (char *)ps;
42 42
43 if (pstate == NULL)
44 pstate = internal_state;
45
46 if (s == NULL) 43 if (s == NULL)
47 { 44 {
48 pwc = NULL; 45 pwc = NULL;
@@ -54,6 +51,10 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
54 return (size_t)(-2); 51 return (size_t)(-2);
55 52
56 /* Here n > 0. */ 53 /* Here n > 0. */
54
55 if (pstate == NULL)
56 pstate = internal_state;
57
57 { 58 {
58 size_t nstate = pstate[0]; 59 size_t nstate = pstate[0];
59 char buf[4]; 60 char buf[4];
@@ -91,7 +92,7 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
91 92
92 /* Here m > 0. */ 93 /* Here m > 0. */
93 94
94# if __GLIBC__ 95# if __GLIBC__ || defined __UCLIBC__
95 /* Work around bug <http://sourceware.org/bugzilla/show_bug.cgi?id=9674> */ 96 /* Work around bug <http://sourceware.org/bugzilla/show_bug.cgi?id=9674> */
96 mbtowc (NULL, NULL, 0); 97 mbtowc (NULL, NULL, 0);
97# endif 98# endif
@@ -127,7 +128,7 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
127 { 128 {
128 const char *encoding = locale_charset (); 129 const char *encoding = locale_charset ();
129 130
130 if (STREQ (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0)) 131 if (STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0))
131 { 132 {
132 /* Cf. unistr/u8-mblen.c. */ 133 /* Cf. unistr/u8-mblen.c. */
133 unsigned char c = (unsigned char) p[0]; 134 unsigned char c = (unsigned char) p[0];
@@ -184,7 +185,8 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
184 /* As a reference for this code, you can use the GNU libiconv 185 /* As a reference for this code, you can use the GNU libiconv
185 implementation. Look for uses of the RET_TOOFEW macro. */ 186 implementation. Look for uses of the RET_TOOFEW macro. */
186 187
187 if (STREQ (encoding, "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0)) 188 if (STREQ_OPT (encoding,
189 "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0))
188 { 190 {
189 if (m == 1) 191 if (m == 1)
190 { 192 {
@@ -207,9 +209,12 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
207 } 209 }
208 goto invalid; 210 goto invalid;
209 } 211 }
210 if (STREQ (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0) 212 if (STREQ_OPT (encoding,
211 || STREQ (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0) 213 "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
212 || STREQ (encoding, "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0)) 214 || STREQ_OPT (encoding,
215 "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0)
216 || STREQ_OPT (encoding,
217 "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0))
213 { 218 {
214 if (m == 1) 219 if (m == 1)
215 { 220 {
@@ -220,7 +225,8 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
220 } 225 }
221 goto invalid; 226 goto invalid;
222 } 227 }
223 if (STREQ (encoding, "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0)) 228 if (STREQ_OPT (encoding,
229 "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0))
224 { 230 {
225 if (m == 1) 231 if (m == 1)
226 { 232 {
@@ -238,7 +244,8 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
238 } 244 }
239 goto invalid; 245 goto invalid;
240 } 246 }
241 if (STREQ (encoding, "GB18030", 'G', 'B', '1', '8', '0', '3', '0', 0, 0)) 247 if (STREQ_OPT (encoding,
248 "GB18030", 'G', 'B', '1', '8', '0', '3', '0', 0, 0))
242 { 249 {
243 if (m == 1) 250 if (m == 1)
244 { 251 {
@@ -271,7 +278,7 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
271 } 278 }
272 goto invalid; 279 goto invalid;
273 } 280 }
274 if (STREQ (encoding, "SJIS", 'S', 'J', 'I', 'S', 0, 0, 0, 0, 0)) 281 if (STREQ_OPT (encoding, "SJIS", 'S', 'J', 'I', 'S', 0, 0, 0, 0, 0))
275 { 282 {
276 if (m == 1) 283 if (m == 1)
277 { 284 {
@@ -321,7 +328,7 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
321size_t 328size_t
322rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) 329rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
323{ 330{
324# if MBRTOWC_NULL_ARG_BUG || MBRTOWC_RETVAL_BUG 331# if MBRTOWC_NULL_ARG2_BUG || MBRTOWC_RETVAL_BUG
325 if (s == NULL) 332 if (s == NULL)
326 { 333 {
327 pwc = NULL; 334 pwc = NULL;
@@ -334,7 +341,7 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
334 { 341 {
335 static mbstate_t internal_state; 342 static mbstate_t internal_state;
336 343
337 /* Override mbrtowc's internal state. We can not call mbsinit() on the 344 /* Override mbrtowc's internal state. We cannot call mbsinit() on the
338 hidden internal state, but we can call it on our variable. */ 345 hidden internal state, but we can call it on our variable. */
339 if (ps == NULL) 346 if (ps == NULL)
340 ps = &internal_state; 347 ps = &internal_state;
@@ -379,7 +386,16 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
379 return ret; 386 return ret;
380 } 387 }
381# else 388# else
382 return mbrtowc (pwc, s, n, ps); 389 {
390# if MBRTOWC_NULL_ARG1_BUG
391 wchar_t dummy;
392
393 if (pwc == NULL)
394 pwc = &dummy;
395# endif
396
397 return mbrtowc (pwc, s, n, ps);
398 }
383# endif 399# endif
384} 400}
385 401
diff --git a/gl/mbsinit.c b/gl/mbsinit.c
index 066ddfe..26fbb7f 100644
--- a/gl/mbsinit.c
+++ b/gl/mbsinit.c
@@ -1,5 +1,5 @@
1/* Test for initial conversion state. 1/* Test for initial conversion state.
2 Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. 2 Copyright (C) 2008-2013 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2008. 3 Written by Bruno Haible <bruno@clisp.org>, 2008.
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
@@ -22,6 +22,18 @@
22 22
23#include "verify.h" 23#include "verify.h"
24 24
25#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
26
27/* On native Windows, 'mbstate_t' is defined as 'int'. */
28
29int
30mbsinit (const mbstate_t *ps)
31{
32 return ps == NULL || *ps == 0;
33}
34
35#else
36
25/* Platforms that lack mbsinit() also lack mbrlen(), mbrtowc(), mbsrtowcs() 37/* Platforms that lack mbsinit() also lack mbrlen(), mbrtowc(), mbsrtowcs()
26 and wcrtomb(), wcsrtombs(). 38 and wcrtomb(), wcsrtombs().
27 We assume that 39 We assume that
@@ -43,5 +55,7 @@ mbsinit (const mbstate_t *ps)
43{ 55{
44 const char *pstate = (const char *)ps; 56 const char *pstate = (const char *)ps;
45 57
46 return pstate[0] == 0; 58 return pstate == NULL || pstate[0] == 0;
47} 59}
60
61#endif
diff --git a/gl/mbtowc-impl.h b/gl/mbtowc-impl.h
new file mode 100644
index 0000000..767ab39
--- /dev/null
+++ b/gl/mbtowc-impl.h
@@ -0,0 +1,44 @@
1/* Convert multibyte character to wide character.
2 Copyright (C) 2011-2013 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2011.
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/* We don't need a static internal state, because the encoding is not state
19 dependent, and when mbrtowc returns (size_t)(-2). we throw the result
20 away. */
21
22int
23mbtowc (wchar_t *pwc, const char *s, size_t n)
24{
25 if (s == NULL)
26 return 0;
27 else
28 {
29 mbstate_t state;
30 wchar_t wc;
31 size_t result;
32
33 memset (&state, 0, sizeof (mbstate_t));
34 result = mbrtowc (&wc, s, n, &state);
35 if (result == (size_t)-1 || result == (size_t)-2)
36 {
37 errno = EILSEQ;
38 return -1;
39 }
40 if (pwc != NULL)
41 *pwc = wc;
42 return (wc == 0 ? 0 : result);
43 }
44}
diff --git a/gl/safe-write.c b/gl/mbtowc.c
index a2c3b4d..632f2e1 100644
--- a/gl/safe-write.c
+++ b/gl/mbtowc.c
@@ -1,5 +1,6 @@
1/* An interface to write that retries after interrupts. 1/* Convert multibyte character to wide character.
2 Copyright (C) 2002, 2009-2010 Free Software Foundation, Inc. 2 Copyright (C) 2011-2013 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2011.
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
@@ -14,5 +15,12 @@
14 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
15 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/>. */
16 17
17#define SAFE_WRITE 18#include <config.h>
18#include "safe-read.c" 19
20#include <stdlib.h>
21
22#include <errno.h>
23#include <string.h>
24#include <wchar.h>
25
26#include "mbtowc-impl.h"
diff --git a/gl/memchr.c b/gl/memchr.c
index 6c2b2d6..3db38a9 100644
--- a/gl/memchr.c
+++ b/gl/memchr.c
@@ -1,4 +1,4 @@
1/* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2010 1/* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2013
2 Free Software Foundation, Inc. 2 Free Software Foundation, Inc.
3 3
4 Based on strlen implementation by Torbjorn Granlund (tege@sics.se), 4 Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
diff --git a/gl/mktime.c b/gl/mktime.c
index b0324b8..e660a23 100644
--- a/gl/mktime.c
+++ b/gl/mktime.c
@@ -1,21 +1,21 @@
1/* Convert a `struct tm' to a time_t value. 1/* Convert a 'struct tm' to a time_t value.
2 Copyright (C) 1993-1999, 2002-2007, 2009-2010 Free Software Foundation, Inc. 2 Copyright (C) 1993-2013 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 Contributed by Paul Eggert <eggert@twinsun.com>. 4 Contributed by Paul Eggert <eggert@twinsun.com>.
5 5
6 This program is free software; you can redistribute it and/or modify 6 The GNU C Library is free software; you can redistribute it and/or
7 it under the terms of the GNU General Public License as published by 7 modify it under the terms of the GNU General Public
8 the Free Software Foundation; either version 3, or (at your option) 8 License as published by the Free Software Foundation; either
9 any later version. 9 version 3 of the License, or (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 GNU General Public License for more details. 14 General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License along 16 You should have received a copy of the GNU General Public
17 with this program; if not, write to the Free Software Foundation, 17 License along with the GNU C Library; if not, see
18 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ 18 <http://www.gnu.org/licenses/>. */
19 19
20/* Define this to have a standalone program to test this implementation of 20/* Define this to have a standalone program to test this implementation of
21 mktime. */ 21 mktime. */
@@ -26,7 +26,7 @@
26#endif 26#endif
27 27
28/* Assume that leap seconds are possible, unless told otherwise. 28/* Assume that leap seconds are possible, unless told otherwise.
29 If the host has a `zic' command with a `-L leapsecondfilename' option, 29 If the host has a 'zic' command with a '-L leapsecondfilename' option,
30 then it supports leap seconds; otherwise it probably doesn't. */ 30 then it supports leap seconds; otherwise it probably doesn't. */
31#ifndef LEAP_SECONDS_POSSIBLE 31#ifndef LEAP_SECONDS_POSSIBLE
32# define LEAP_SECONDS_POSSIBLE 1 32# define LEAP_SECONDS_POSSIBLE 1
@@ -36,15 +36,49 @@
36 36
37#include <limits.h> 37#include <limits.h>
38 38
39#include <string.h> /* For the real memcpy prototype. */ 39#include <string.h> /* For the real memcpy prototype. */
40 40
41#if DEBUG 41#if DEBUG
42# include <stdio.h> 42# include <stdio.h>
43# include <stdlib.h> 43# include <stdlib.h>
44/* Make it work even if the system's libc has its own mktime routine. */ 44/* Make it work even if the system's libc has its own mktime routine. */
45# undef mktime
45# define mktime my_mktime 46# define mktime my_mktime
46#endif /* DEBUG */ 47#endif /* DEBUG */
47 48
49/* Some of the code in this file assumes that signed integer overflow
50 silently wraps around. This assumption can't easily be programmed
51 around, nor can it be checked for portably at compile-time or
52 easily eliminated at run-time.
53
54 Define WRAPV to 1 if the assumption is valid and if
55 #pragma GCC optimize ("wrapv")
56 does not trigger GCC bug 51793
57 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51793>.
58 Otherwise, define it to 0; this forces the use of slower code that,
59 while not guaranteed by the C Standard, works on all production
60 platforms that we know about. */
61#ifndef WRAPV
62# if (((__GNUC__ == 4 && 4 <= __GNUC_MINOR__) || 4 < __GNUC__) \
63 && defined __GLIBC__)
64# pragma GCC optimize ("wrapv")
65# define WRAPV 1
66# else
67# define WRAPV 0
68# endif
69#endif
70
71/* Verify a requirement at compile-time (unlike assert, which is runtime). */
72#define verify(name, assertion) struct name { char a[(assertion) ? 1 : -1]; }
73
74/* A signed type that is at least one bit wider than int. */
75#if INT_MAX <= LONG_MAX / 2
76typedef long int long_int;
77#else
78typedef long long int long_int;
79#endif
80verify (long_int_is_wide_enough, INT_MAX == INT_MAX * (long_int) 2 / 2);
81
48/* Shift A right by B bits portably, by dividing A by 2**B and 82/* Shift A right by B bits portably, by dividing A by 2**B and
49 truncating towards minus infinity. A and B should be free of side 83 truncating towards minus infinity. A and B should be free of side
50 effects, and B should be in the range 0 <= B <= INT_BITS - 2, where 84 effects, and B should be in the range 0 <= B <= INT_BITS - 2, where
@@ -55,9 +89,11 @@
55 implementations (e.g., UNICOS 9.0 on a Cray Y-MP EL) don't shift 89 implementations (e.g., UNICOS 9.0 on a Cray Y-MP EL) don't shift
56 right in the usual way when A < 0, so SHR falls back on division if 90 right in the usual way when A < 0, so SHR falls back on division if
57 ordinary A >> B doesn't seem to be the usual signed shift. */ 91 ordinary A >> B doesn't seem to be the usual signed shift. */
58#define SHR(a, b) \ 92#define SHR(a, b) \
59 (-1 >> 1 == -1 \ 93 ((-1 >> 1 == -1 \
60 ? (a) >> (b) \ 94 && (long_int) -1 >> 1 == -1 \
95 && ((time_t) -1 >> 1 == -1 || ! TYPE_SIGNED (time_t))) \
96 ? (a) >> (b) \
61 : (a) / (1 << (b)) - ((a) % (1 << (b)) < 0)) 97 : (a) / (1 << (b)) - ((a) % (1 << (b)) < 0))
62 98
63/* The extra casts in the following macros work around compiler bugs, 99/* The extra casts in the following macros work around compiler bugs,
@@ -68,12 +104,8 @@
68#define TYPE_IS_INTEGER(t) ((t) 1.5 == 1) 104#define TYPE_IS_INTEGER(t) ((t) 1.5 == 1)
69 105
70/* True if negative values of the signed integer type T use two's 106/* True if negative values of the signed integer type T use two's
71 complement, ones' complement, or signed magnitude representation, 107 complement, or if T is an unsigned integer type. */
72 respectively. Much GNU code assumes two's complement, but some
73 people like to be portable to all possible C hosts. */
74#define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1) 108#define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1)
75#define TYPE_ONES_COMPLEMENT(t) ((t) ~ (t) 0 == 0)
76#define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1)
77 109
78/* True if the arithmetic type T is signed. */ 110/* True if the arithmetic type T is signed. */
79#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) 111#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
@@ -84,14 +116,12 @@
84 your host. */ 116 your host. */
85#define TYPE_MINIMUM(t) \ 117#define TYPE_MINIMUM(t) \
86 ((t) (! TYPE_SIGNED (t) \ 118 ((t) (! TYPE_SIGNED (t) \
87 ? (t) 0 \ 119 ? (t) 0 \
88 : TYPE_SIGNED_MAGNITUDE (t) \ 120 : ~ TYPE_MAXIMUM (t)))
89 ? ~ (t) 0 \
90 : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))
91#define TYPE_MAXIMUM(t) \ 121#define TYPE_MAXIMUM(t) \
92 ((t) (! TYPE_SIGNED (t) \ 122 ((t) (! TYPE_SIGNED (t) \
93 ? (t) -1 \ 123 ? (t) -1 \
94 : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))) 124 : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1)))
95 125
96#ifndef TIME_T_MIN 126#ifndef TIME_T_MIN
97# define TIME_T_MIN TYPE_MINIMUM (time_t) 127# define TIME_T_MIN TYPE_MINIMUM (time_t)
@@ -101,29 +131,26 @@
101#endif 131#endif
102#define TIME_T_MIDPOINT (SHR (TIME_T_MIN + TIME_T_MAX, 1) + 1) 132#define TIME_T_MIDPOINT (SHR (TIME_T_MIN + TIME_T_MAX, 1) + 1)
103 133
104/* Verify a requirement at compile-time (unlike assert, which is runtime). */
105#define verify(name, assertion) struct name { char a[(assertion) ? 1 : -1]; }
106
107verify (time_t_is_integer, TYPE_IS_INTEGER (time_t)); 134verify (time_t_is_integer, TYPE_IS_INTEGER (time_t));
108verify (twos_complement_arithmetic, TYPE_TWOS_COMPLEMENT (int)); 135verify (twos_complement_arithmetic,
109/* The code also assumes that signed integer overflow silently wraps 136 (TYPE_TWOS_COMPLEMENT (int)
110 around, but this assumption can't be stated without causing a 137 && TYPE_TWOS_COMPLEMENT (long_int)
111 diagnostic on some hosts. */ 138 && TYPE_TWOS_COMPLEMENT (time_t)));
112 139
113#define EPOCH_YEAR 1970 140#define EPOCH_YEAR 1970
114#define TM_YEAR_BASE 1900 141#define TM_YEAR_BASE 1900
115verify (base_year_is_a_multiple_of_100, TM_YEAR_BASE % 100 == 0); 142verify (base_year_is_a_multiple_of_100, TM_YEAR_BASE % 100 == 0);
116 143
117/* Return 1 if YEAR + TM_YEAR_BASE is a leap year. */ 144/* Return 1 if YEAR + TM_YEAR_BASE is a leap year. */
118static inline int 145static int
119leapyear (long int year) 146leapyear (long_int year)
120{ 147{
121 /* Don't add YEAR to TM_YEAR_BASE, as that might overflow. 148 /* Don't add YEAR to TM_YEAR_BASE, as that might overflow.
122 Also, work even if YEAR is negative. */ 149 Also, work even if YEAR is negative. */
123 return 150 return
124 ((year & 3) == 0 151 ((year & 3) == 0
125 && (year % 100 != 0 152 && (year % 100 != 0
126 || ((year / 100) & 3) == (- (TM_YEAR_BASE / 100) & 3))); 153 || ((year / 100) & 3) == (- (TM_YEAR_BASE / 100) & 3)));
127} 154}
128 155
129/* How many days come before each month (0-12). */ 156/* How many days come before each month (0-12). */
@@ -150,6 +177,14 @@ const unsigned short int __mon_yday[2][13] =
150# include "mktime-internal.h" 177# include "mktime-internal.h"
151#endif 178#endif
152 179
180/* Return 1 if the values A and B differ according to the rules for
181 tm_isdst: A and B differ if one is zero and the other positive. */
182static int
183isdst_differ (int a, int b)
184{
185 return (!a != !b) && (0 <= a) && (0 <= b);
186}
187
153/* Return an integer value measuring (YEAR1-YDAY1 HOUR1:MIN1:SEC1) - 188/* Return an integer value measuring (YEAR1-YDAY1 HOUR1:MIN1:SEC1) -
154 (YEAR0-YDAY0 HOUR0:MIN0:SEC0) in seconds, assuming that the clocks 189 (YEAR0-YDAY0 HOUR0:MIN0:SEC0) in seconds, assuming that the clocks
155 were not adjusted between the time stamps. 190 were not adjusted between the time stamps.
@@ -161,16 +196,11 @@ const unsigned short int __mon_yday[2][13] =
161 The result may overflow. It is the caller's responsibility to 196 The result may overflow. It is the caller's responsibility to
162 detect overflow. */ 197 detect overflow. */
163 198
164static inline time_t 199static time_t
165ydhms_diff (long int year1, long int yday1, int hour1, int min1, int sec1, 200ydhms_diff (long_int year1, long_int yday1, int hour1, int min1, int sec1,
166 int year0, int yday0, int hour0, int min0, int sec0) 201 int year0, int yday0, int hour0, int min0, int sec0)
167{ 202{
168 verify (C99_integer_division, -1 / 2 == 0); 203 verify (C99_integer_division, -1 / 2 == 0);
169#if 0 /* This assertion fails on 32-bit systems with 64-bit time_t, such as
170 NetBSD 5 on i386. */
171 verify (long_int_year_and_yday_are_wide_enough,
172 INT_MAX <= LONG_MAX / 2 || TIME_T_MAX <= UINT_MAX);
173#endif
174 204
175 /* Compute intervening leap days correctly even if year is negative. 205 /* Compute intervening leap days correctly even if year is negative.
176 Take care to avoid integer overflow here. */ 206 Take care to avoid integer overflow here. */
@@ -193,6 +223,53 @@ ydhms_diff (long int year1, long int yday1, int hour1, int min1, int sec1,
193 return seconds; 223 return seconds;
194} 224}
195 225
226/* Return the average of A and B, even if A + B would overflow. */
227static time_t
228time_t_avg (time_t a, time_t b)
229{
230 return SHR (a, 1) + SHR (b, 1) + (a & b & 1);
231}
232
233/* Return 1 if A + B does not overflow. If time_t is unsigned and if
234 B's top bit is set, assume that the sum represents A - -B, and
235 return 1 if the subtraction does not wrap around. */
236static int
237time_t_add_ok (time_t a, time_t b)
238{
239 if (! TYPE_SIGNED (time_t))
240 {
241 time_t sum = a + b;
242 return (sum < a) == (TIME_T_MIDPOINT <= b);
243 }
244 else if (WRAPV)
245 {
246 time_t sum = a + b;
247 return (sum < a) == (b < 0);
248 }
249 else
250 {
251 time_t avg = time_t_avg (a, b);
252 return TIME_T_MIN / 2 <= avg && avg <= TIME_T_MAX / 2;
253 }
254}
255
256/* Return 1 if A + B does not overflow. */
257static int
258time_t_int_add_ok (time_t a, int b)
259{
260 verify (int_no_wider_than_time_t, INT_MAX <= TIME_T_MAX);
261 if (WRAPV)
262 {
263 time_t sum = a + b;
264 return (sum < a) == (b < 0);
265 }
266 else
267 {
268 int a_odd = a & 1;
269 time_t avg = SHR (a, 1) + (SHR (b, 1) + (a_odd & b));
270 return TIME_T_MIN / 2 <= avg && avg <= TIME_T_MAX / 2;
271 }
272}
196 273
197/* Return a time_t value corresponding to (YEAR-YDAY HOUR:MIN:SEC), 274/* Return a time_t value corresponding to (YEAR-YDAY HOUR:MIN:SEC),
198 assuming that *T corresponds to *TP and that no clock adjustments 275 assuming that *T corresponds to *TP and that no clock adjustments
@@ -201,17 +278,16 @@ ydhms_diff (long int year1, long int yday1, int hour1, int min1, int sec1,
201 If overflow occurs, yield the minimal or maximal value, except do not 278 If overflow occurs, yield the minimal or maximal value, except do not
202 yield a value equal to *T. */ 279 yield a value equal to *T. */
203static time_t 280static time_t
204guess_time_tm (long int year, long int yday, int hour, int min, int sec, 281guess_time_tm (long_int year, long_int yday, int hour, int min, int sec,
205 const time_t *t, const struct tm *tp) 282 const time_t *t, const struct tm *tp)
206{ 283{
207 if (tp) 284 if (tp)
208 { 285 {
209 time_t d = ydhms_diff (year, yday, hour, min, sec, 286 time_t d = ydhms_diff (year, yday, hour, min, sec,
210 tp->tm_year, tp->tm_yday, 287 tp->tm_year, tp->tm_yday,
211 tp->tm_hour, tp->tm_min, tp->tm_sec); 288 tp->tm_hour, tp->tm_min, tp->tm_sec);
212 time_t t1 = *t + d; 289 if (time_t_add_ok (*t, d))
213 if ((t1 < *t) == (TYPE_SIGNED (time_t) ? d < 0 : TIME_T_MAX / 2 < d)) 290 return *t + d;
214 return t1;
215 } 291 }
216 292
217 /* Overflow occurred one way or another. Return the nearest result 293 /* Overflow occurred one way or another. Return the nearest result
@@ -220,8 +296,8 @@ guess_time_tm (long int year, long int yday, int hour, int min, int sec,
220 match; and don't oscillate between two values, as that would 296 match; and don't oscillate between two values, as that would
221 confuse the spring-forward gap detector. */ 297 confuse the spring-forward gap detector. */
222 return (*t < TIME_T_MIDPOINT 298 return (*t < TIME_T_MIDPOINT
223 ? (*t <= TIME_T_MIN + 1 ? *t + 1 : TIME_T_MIN) 299 ? (*t <= TIME_T_MIN + 1 ? *t + 1 : TIME_T_MIN)
224 : (TIME_T_MAX - 1 <= *t ? *t - 1 : TIME_T_MAX)); 300 : (TIME_T_MAX - 1 <= *t ? *t - 1 : TIME_T_MAX));
225} 301}
226 302
227/* Use CONVERT to convert *T to a broken down time in *TP. 303/* Use CONVERT to convert *T to a broken down time in *TP.
@@ -229,7 +305,7 @@ guess_time_tm (long int year, long int yday, int hour, int min, int sec,
229 it is the nearest in-range value and then convert that. */ 305 it is the nearest in-range value and then convert that. */
230static struct tm * 306static struct tm *
231ranged_convert (struct tm *(*convert) (const time_t *, struct tm *), 307ranged_convert (struct tm *(*convert) (const time_t *, struct tm *),
232 time_t *t, struct tm *tp) 308 time_t *t, struct tm *tp)
233{ 309{
234 struct tm *r = convert (t, tp); 310 struct tm *r = convert (t, tp);
235 311
@@ -239,27 +315,25 @@ ranged_convert (struct tm *(*convert) (const time_t *, struct tm *),
239 time_t ok = 0; 315 time_t ok = 0;
240 316
241 /* BAD is a known unconvertible time_t, and OK is a known good one. 317 /* BAD is a known unconvertible time_t, and OK is a known good one.
242 Use binary search to narrow the range between BAD and OK until 318 Use binary search to narrow the range between BAD and OK until
243 they differ by 1. */ 319 they differ by 1. */
244 while (bad != ok + (bad < 0 ? -1 : 1)) 320 while (bad != ok + (bad < 0 ? -1 : 1))
245 { 321 {
246 time_t mid = *t = (bad < 0 322 time_t mid = *t = time_t_avg (ok, bad);
247 ? bad + ((ok - bad) >> 1) 323 r = convert (t, tp);
248 : ok + ((bad - ok) >> 1)); 324 if (r)
249 r = convert (t, tp); 325 ok = mid;
250 if (r) 326 else
251 ok = mid; 327 bad = mid;
252 else 328 }
253 bad = mid;
254 }
255 329
256 if (!r && ok) 330 if (!r && ok)
257 { 331 {
258 /* The last conversion attempt failed; 332 /* The last conversion attempt failed;
259 revert to the most recent successful attempt. */ 333 revert to the most recent successful attempt. */
260 *t = ok; 334 *t = ok;
261 r = convert (t, tp); 335 r = convert (t, tp);
262 } 336 }
263 } 337 }
264 338
265 return r; 339 return r;
@@ -274,8 +348,8 @@ ranged_convert (struct tm *(*convert) (const time_t *, struct tm *),
274 This function is external because it is used also by timegm.c. */ 348 This function is external because it is used also by timegm.c. */
275time_t 349time_t
276__mktime_internal (struct tm *tp, 350__mktime_internal (struct tm *tp,
277 struct tm *(*convert) (const time_t *, struct tm *), 351 struct tm *(*convert) (const time_t *, struct tm *),
278 time_t *offset) 352 time_t *offset)
279{ 353{
280 time_t t, gt, t0, t1, t2; 354 time_t t, gt, t0, t1, t2;
281 struct tm tm; 355 struct tm tm;
@@ -294,9 +368,7 @@ __mktime_internal (struct tm *tp,
294 int mday = tp->tm_mday; 368 int mday = tp->tm_mday;
295 int mon = tp->tm_mon; 369 int mon = tp->tm_mon;
296 int year_requested = tp->tm_year; 370 int year_requested = tp->tm_year;
297 /* Normalize the value. */ 371 int isdst = tp->tm_isdst;
298 int isdst = ((tp->tm_isdst >> (8 * sizeof (tp->tm_isdst) - 1))
299 | (tp->tm_isdst != 0));
300 372
301 /* 1 if the previous probe was DST. */ 373 /* 1 if the previous probe was DST. */
302 int dst2; 374 int dst2;
@@ -305,8 +377,8 @@ __mktime_internal (struct tm *tp,
305 int mon_remainder = mon % 12; 377 int mon_remainder = mon % 12;
306 int negative_mon_remainder = mon_remainder < 0; 378 int negative_mon_remainder = mon_remainder < 0;
307 int mon_years = mon / 12 - negative_mon_remainder; 379 int mon_years = mon / 12 - negative_mon_remainder;
308 long int lyear_requested = year_requested; 380 long_int lyear_requested = year_requested;
309 long int year = lyear_requested + mon_years; 381 long_int year = lyear_requested + mon_years;
310 382
311 /* The other values need not be in range: 383 /* The other values need not be in range:
312 the remaining code handles minor overflows correctly, 384 the remaining code handles minor overflows correctly,
@@ -316,10 +388,10 @@ __mktime_internal (struct tm *tp,
316 /* Calculate day of year from year, month, and day of month. 388 /* Calculate day of year from year, month, and day of month.
317 The result need not be in range. */ 389 The result need not be in range. */
318 int mon_yday = ((__mon_yday[leapyear (year)] 390 int mon_yday = ((__mon_yday[leapyear (year)]
319 [mon_remainder + 12 * negative_mon_remainder]) 391 [mon_remainder + 12 * negative_mon_remainder])
320 - 1); 392 - 1);
321 long int lmday = mday; 393 long_int lmday = mday;
322 long int yday = mon_yday + lmday; 394 long_int yday = mon_yday + lmday;
323 395
324 time_t guessed_offset = *offset; 396 time_t guessed_offset = *offset;
325 397
@@ -328,33 +400,33 @@ __mktime_internal (struct tm *tp,
328 if (LEAP_SECONDS_POSSIBLE) 400 if (LEAP_SECONDS_POSSIBLE)
329 { 401 {
330 /* Handle out-of-range seconds specially, 402 /* Handle out-of-range seconds specially,
331 since ydhms_tm_diff assumes every minute has 60 seconds. */ 403 since ydhms_tm_diff assumes every minute has 60 seconds. */
332 if (sec < 0) 404 if (sec < 0)
333 sec = 0; 405 sec = 0;
334 if (59 < sec) 406 if (59 < sec)
335 sec = 59; 407 sec = 59;
336 } 408 }
337 409
338 /* Invert CONVERT by probing. First assume the same offset as last 410 /* Invert CONVERT by probing. First assume the same offset as last
339 time. */ 411 time. */
340 412
341 t0 = ydhms_diff (year, yday, hour, min, sec, 413 t0 = ydhms_diff (year, yday, hour, min, sec,
342 EPOCH_YEAR - TM_YEAR_BASE, 0, 0, 0, - guessed_offset); 414 EPOCH_YEAR - TM_YEAR_BASE, 0, 0, 0, - guessed_offset);
343 415
344 if (TIME_T_MAX / INT_MAX / 366 / 24 / 60 / 60 < 3) 416 if (TIME_T_MAX / INT_MAX / 366 / 24 / 60 / 60 < 3)
345 { 417 {
346 /* time_t isn't large enough to rule out overflows, so check 418 /* time_t isn't large enough to rule out overflows, so check
347 for major overflows. A gross check suffices, since if t0 419 for major overflows. A gross check suffices, since if t0
348 has overflowed, it is off by a multiple of TIME_T_MAX - 420 has overflowed, it is off by a multiple of TIME_T_MAX -
349 TIME_T_MIN + 1. So ignore any component of the difference 421 TIME_T_MIN + 1. So ignore any component of the difference
350 that is bounded by a small value. */ 422 that is bounded by a small value. */
351 423
352 /* Approximate log base 2 of the number of time units per 424 /* Approximate log base 2 of the number of time units per
353 biennium. A biennium is 2 years; use this unit instead of 425 biennium. A biennium is 2 years; use this unit instead of
354 years to avoid integer overflow. For example, 2 average 426 years to avoid integer overflow. For example, 2 average
355 Gregorian years are 2 * 365.2425 * 24 * 60 * 60 seconds, 427 Gregorian years are 2 * 365.2425 * 24 * 60 * 60 seconds,
356 which is 63113904 seconds, and rint (log2 (63113904)) is 428 which is 63113904 seconds, and rint (log2 (63113904)) is
357 26. */ 429 26. */
358 int ALOG2_SECONDS_PER_BIENNIUM = 26; 430 int ALOG2_SECONDS_PER_BIENNIUM = 26;
359 int ALOG2_MINUTES_PER_BIENNIUM = 20; 431 int ALOG2_MINUTES_PER_BIENNIUM = 20;
360 int ALOG2_HOURS_PER_BIENNIUM = 14; 432 int ALOG2_HOURS_PER_BIENNIUM = 14;
@@ -362,119 +434,117 @@ __mktime_internal (struct tm *tp,
362 int LOG2_YEARS_PER_BIENNIUM = 1; 434 int LOG2_YEARS_PER_BIENNIUM = 1;
363 435
364 int approx_requested_biennia = 436 int approx_requested_biennia =
365 (SHR (year_requested, LOG2_YEARS_PER_BIENNIUM) 437 (SHR (year_requested, LOG2_YEARS_PER_BIENNIUM)
366 - SHR (EPOCH_YEAR - TM_YEAR_BASE, LOG2_YEARS_PER_BIENNIUM) 438 - SHR (EPOCH_YEAR - TM_YEAR_BASE, LOG2_YEARS_PER_BIENNIUM)
367 + SHR (mday, ALOG2_DAYS_PER_BIENNIUM) 439 + SHR (mday, ALOG2_DAYS_PER_BIENNIUM)
368 + SHR (hour, ALOG2_HOURS_PER_BIENNIUM) 440 + SHR (hour, ALOG2_HOURS_PER_BIENNIUM)
369 + SHR (min, ALOG2_MINUTES_PER_BIENNIUM) 441 + SHR (min, ALOG2_MINUTES_PER_BIENNIUM)
370 + (LEAP_SECONDS_POSSIBLE 442 + (LEAP_SECONDS_POSSIBLE
371 ? 0 443 ? 0
372 : SHR (sec, ALOG2_SECONDS_PER_BIENNIUM))); 444 : SHR (sec, ALOG2_SECONDS_PER_BIENNIUM)));
373 445
374 int approx_biennia = SHR (t0, ALOG2_SECONDS_PER_BIENNIUM); 446 int approx_biennia = SHR (t0, ALOG2_SECONDS_PER_BIENNIUM);
375 int diff = approx_biennia - approx_requested_biennia; 447 int diff = approx_biennia - approx_requested_biennia;
376 int abs_diff = diff < 0 ? - diff : diff; 448 int approx_abs_diff = diff < 0 ? -1 - diff : diff;
377 449
378 /* IRIX 4.0.5 cc miscaculates TIME_T_MIN / 3: it erroneously 450 /* IRIX 4.0.5 cc miscalculates TIME_T_MIN / 3: it erroneously
379 gives a positive value of 715827882. Setting a variable 451 gives a positive value of 715827882. Setting a variable
380 first then doing math on it seems to work. 452 first then doing math on it seems to work.
381 (ghazi@caip.rutgers.edu) */ 453 (ghazi@caip.rutgers.edu) */
382 time_t time_t_max = TIME_T_MAX; 454 time_t time_t_max = TIME_T_MAX;
383 time_t time_t_min = TIME_T_MIN; 455 time_t time_t_min = TIME_T_MIN;
384 time_t overflow_threshold = 456 time_t overflow_threshold =
385 (time_t_max / 3 - time_t_min / 3) >> ALOG2_SECONDS_PER_BIENNIUM; 457 (time_t_max / 3 - time_t_min / 3) >> ALOG2_SECONDS_PER_BIENNIUM;
386 458
387 if (overflow_threshold < abs_diff) 459 if (overflow_threshold < approx_abs_diff)
388 { 460 {
389 /* Overflow occurred. Try repairing it; this might work if 461 /* Overflow occurred. Try repairing it; this might work if
390 the time zone offset is enough to undo the overflow. */ 462 the time zone offset is enough to undo the overflow. */
391 time_t repaired_t0 = -1 - t0; 463 time_t repaired_t0 = -1 - t0;
392 approx_biennia = SHR (repaired_t0, ALOG2_SECONDS_PER_BIENNIUM); 464 approx_biennia = SHR (repaired_t0, ALOG2_SECONDS_PER_BIENNIUM);
393 diff = approx_biennia - approx_requested_biennia; 465 diff = approx_biennia - approx_requested_biennia;
394 abs_diff = diff < 0 ? - diff : diff; 466 approx_abs_diff = diff < 0 ? -1 - diff : diff;
395 if (overflow_threshold < abs_diff) 467 if (overflow_threshold < approx_abs_diff)
396 return -1; 468 return -1;
397 guessed_offset += repaired_t0 - t0; 469 guessed_offset += repaired_t0 - t0;
398 t0 = repaired_t0; 470 t0 = repaired_t0;
399 } 471 }
400 } 472 }
401 473
402 /* Repeatedly use the error to improve the guess. */ 474 /* Repeatedly use the error to improve the guess. */
403 475
404 for (t = t1 = t2 = t0, dst2 = 0; 476 for (t = t1 = t2 = t0, dst2 = 0;
405 (gt = guess_time_tm (year, yday, hour, min, sec, &t, 477 (gt = guess_time_tm (year, yday, hour, min, sec, &t,
406 ranged_convert (convert, &t, &tm)), 478 ranged_convert (convert, &t, &tm)),
407 t != gt); 479 t != gt);
408 t1 = t2, t2 = t, t = gt, dst2 = tm.tm_isdst != 0) 480 t1 = t2, t2 = t, t = gt, dst2 = tm.tm_isdst != 0)
409 if (t == t1 && t != t2 481 if (t == t1 && t != t2
410 && (tm.tm_isdst < 0 482 && (tm.tm_isdst < 0
411 || (isdst < 0 483 || (isdst < 0
412 ? dst2 <= (tm.tm_isdst != 0) 484 ? dst2 <= (tm.tm_isdst != 0)
413 : (isdst != 0) != (tm.tm_isdst != 0)))) 485 : (isdst != 0) != (tm.tm_isdst != 0))))
414 /* We can't possibly find a match, as we are oscillating 486 /* We can't possibly find a match, as we are oscillating
415 between two values. The requested time probably falls 487 between two values. The requested time probably falls
416 within a spring-forward gap of size GT - T. Follow the common 488 within a spring-forward gap of size GT - T. Follow the common
417 practice in this case, which is to return a time that is GT - T 489 practice in this case, which is to return a time that is GT - T
418 away from the requested time, preferring a time whose 490 away from the requested time, preferring a time whose
419 tm_isdst differs from the requested value. (If no tm_isdst 491 tm_isdst differs from the requested value. (If no tm_isdst
420 was requested and only one of the two values has a nonzero 492 was requested and only one of the two values has a nonzero
421 tm_isdst, prefer that value.) In practice, this is more 493 tm_isdst, prefer that value.) In practice, this is more
422 useful than returning -1. */ 494 useful than returning -1. */
423 goto offset_found; 495 goto offset_found;
424 else if (--remaining_probes == 0) 496 else if (--remaining_probes == 0)
425 return -1; 497 return -1;
426 498
427 /* We have a match. Check whether tm.tm_isdst has the requested 499 /* We have a match. Check whether tm.tm_isdst has the requested
428 value, if any. */ 500 value, if any. */
429 if (isdst != tm.tm_isdst && 0 <= isdst && 0 <= tm.tm_isdst) 501 if (isdst_differ (isdst, tm.tm_isdst))
430 { 502 {
431 /* tm.tm_isdst has the wrong value. Look for a neighboring 503 /* tm.tm_isdst has the wrong value. Look for a neighboring
432 time with the right value, and use its UTC offset. 504 time with the right value, and use its UTC offset.
433 505
434 Heuristic: probe the adjacent timestamps in both directions, 506 Heuristic: probe the adjacent timestamps in both directions,
435 looking for the desired isdst. This should work for all real 507 looking for the desired isdst. This should work for all real
436 time zone histories in the tz database. */ 508 time zone histories in the tz database. */
437 509
438 /* Distance between probes when looking for a DST boundary. In 510 /* Distance between probes when looking for a DST boundary. In
439 tzdata2003a, the shortest period of DST is 601200 seconds 511 tzdata2003a, the shortest period of DST is 601200 seconds
440 (e.g., America/Recife starting 2000-10-08 01:00), and the 512 (e.g., America/Recife starting 2000-10-08 01:00), and the
441 shortest period of non-DST surrounded by DST is 694800 513 shortest period of non-DST surrounded by DST is 694800
442 seconds (Africa/Tunis starting 1943-04-17 01:00). Use the 514 seconds (Africa/Tunis starting 1943-04-17 01:00). Use the
443 minimum of these two values, so we don't miss these short 515 minimum of these two values, so we don't miss these short
444 periods when probing. */ 516 periods when probing. */
445 int stride = 601200; 517 int stride = 601200;
446 518
447 /* The longest period of DST in tzdata2003a is 536454000 seconds 519 /* The longest period of DST in tzdata2003a is 536454000 seconds
448 (e.g., America/Jujuy starting 1946-10-01 01:00). The longest 520 (e.g., America/Jujuy starting 1946-10-01 01:00). The longest
449 period of non-DST is much longer, but it makes no real sense 521 period of non-DST is much longer, but it makes no real sense
450 to search for more than a year of non-DST, so use the DST 522 to search for more than a year of non-DST, so use the DST
451 max. */ 523 max. */
452 int duration_max = 536454000; 524 int duration_max = 536454000;
453 525
454 /* Search in both directions, so the maximum distance is half 526 /* Search in both directions, so the maximum distance is half
455 the duration; add the stride to avoid off-by-1 problems. */ 527 the duration; add the stride to avoid off-by-1 problems. */
456 int delta_bound = duration_max / 2 + stride; 528 int delta_bound = duration_max / 2 + stride;
457 529
458 int delta, direction; 530 int delta, direction;
459 531
460 for (delta = stride; delta < delta_bound; delta += stride) 532 for (delta = stride; delta < delta_bound; delta += stride)
461 for (direction = -1; direction <= 1; direction += 2) 533 for (direction = -1; direction <= 1; direction += 2)
462 { 534 if (time_t_int_add_ok (t, delta * direction))
463 time_t ot = t + delta * direction; 535 {
464 if ((ot < t) == (direction < 0)) 536 time_t ot = t + delta * direction;
465 { 537 struct tm otm;
466 struct tm otm; 538 ranged_convert (convert, &ot, &otm);
467 ranged_convert (convert, &ot, &otm); 539 if (! isdst_differ (isdst, otm.tm_isdst))
468 if (otm.tm_isdst == isdst) 540 {
469 { 541 /* We found the desired tm_isdst.
470 /* We found the desired tm_isdst. 542 Extrapolate back to the desired time. */
471 Extrapolate back to the desired time. */ 543 t = guess_time_tm (year, yday, hour, min, sec, &ot, &otm);
472 t = guess_time_tm (year, yday, hour, min, sec, &ot, &otm); 544 ranged_convert (convert, &t, &tm);
473 ranged_convert (convert, &t, &tm); 545 goto offset_found;
474 goto offset_found; 546 }
475 } 547 }
476 }
477 }
478 } 548 }
479 549
480 offset_found: 550 offset_found:
@@ -483,14 +553,16 @@ __mktime_internal (struct tm *tp,
483 if (LEAP_SECONDS_POSSIBLE && sec_requested != tm.tm_sec) 553 if (LEAP_SECONDS_POSSIBLE && sec_requested != tm.tm_sec)
484 { 554 {
485 /* Adjust time to reflect the tm_sec requested, not the normalized value. 555 /* Adjust time to reflect the tm_sec requested, not the normalized value.
486 Also, repair any damage from a false match due to a leap second. */ 556 Also, repair any damage from a false match due to a leap second. */
487 int sec_adjustment = (sec == 0 && tm.tm_sec == 60) - sec; 557 int sec_adjustment = (sec == 0 && tm.tm_sec == 60) - sec;
558 if (! time_t_int_add_ok (t, sec_requested))
559 return -1;
488 t1 = t + sec_requested; 560 t1 = t + sec_requested;
561 if (! time_t_int_add_ok (t1, sec_adjustment))
562 return -1;
489 t2 = t1 + sec_adjustment; 563 t2 = t1 + sec_adjustment;
490 if (((t1 < t) != (sec_requested < 0)) 564 if (! convert (&t2, &tm))
491 | ((t2 < t1) != (sec_adjustment < 0)) 565 return -1;
492 | ! convert (&t2, &tm))
493 return -1;
494 t = t2; 566 t = t2;
495 } 567 }
496 568
@@ -511,7 +583,7 @@ mktime (struct tm *tp)
511{ 583{
512#ifdef _LIBC 584#ifdef _LIBC
513 /* POSIX.1 8.1.1 requires that whenever mktime() is called, the 585 /* POSIX.1 8.1.1 requires that whenever mktime() is called, the
514 time zone names contained in the external variable `tzname' shall 586 time zone names contained in the external variable 'tzname' shall
515 be set as if the tzset() function had been called. */ 587 be set as if the tzset() function had been called. */
516 __tzset (); 588 __tzset ();
517#endif 589#endif
@@ -534,13 +606,13 @@ static int
534not_equal_tm (const struct tm *a, const struct tm *b) 606not_equal_tm (const struct tm *a, const struct tm *b)
535{ 607{
536 return ((a->tm_sec ^ b->tm_sec) 608 return ((a->tm_sec ^ b->tm_sec)
537 | (a->tm_min ^ b->tm_min) 609 | (a->tm_min ^ b->tm_min)
538 | (a->tm_hour ^ b->tm_hour) 610 | (a->tm_hour ^ b->tm_hour)
539 | (a->tm_mday ^ b->tm_mday) 611 | (a->tm_mday ^ b->tm_mday)
540 | (a->tm_mon ^ b->tm_mon) 612 | (a->tm_mon ^ b->tm_mon)
541 | (a->tm_year ^ b->tm_year) 613 | (a->tm_year ^ b->tm_year)
542 | (a->tm_yday ^ b->tm_yday) 614 | (a->tm_yday ^ b->tm_yday)
543 | (a->tm_isdst ^ b->tm_isdst)); 615 | isdst_differ (a->tm_isdst, b->tm_isdst));
544} 616}
545 617
546static void 618static void
@@ -548,9 +620,9 @@ print_tm (const struct tm *tp)
548{ 620{
549 if (tp) 621 if (tp)
550 printf ("%04d-%02d-%02d %02d:%02d:%02d yday %03d wday %d isdst %d", 622 printf ("%04d-%02d-%02d %02d:%02d:%02d yday %03d wday %d isdst %d",
551 tp->tm_year + TM_YEAR_BASE, tp->tm_mon + 1, tp->tm_mday, 623 tp->tm_year + TM_YEAR_BASE, tp->tm_mon + 1, tp->tm_mday,
552 tp->tm_hour, tp->tm_min, tp->tm_sec, 624 tp->tm_hour, tp->tm_min, tp->tm_sec,
553 tp->tm_yday, tp->tm_wday, tp->tm_isdst); 625 tp->tm_yday, tp->tm_wday, tp->tm_isdst);
554 else 626 else
555 printf ("0"); 627 printf ("0");
556} 628}
@@ -582,11 +654,11 @@ main (int argc, char **argv)
582 654
583 if ((argc == 3 || argc == 4) 655 if ((argc == 3 || argc == 4)
584 && (sscanf (argv[1], "%d-%d-%d%c", 656 && (sscanf (argv[1], "%d-%d-%d%c",
585 &tm.tm_year, &tm.tm_mon, &tm.tm_mday, &trailer) 657 &tm.tm_year, &tm.tm_mon, &tm.tm_mday, &trailer)
586 == 3) 658 == 3)
587 && (sscanf (argv[2], "%d:%d:%d%c", 659 && (sscanf (argv[2], "%d:%d:%d%c",
588 &tm.tm_hour, &tm.tm_min, &tm.tm_sec, &trailer) 660 &tm.tm_hour, &tm.tm_min, &tm.tm_sec, &trailer)
589 == 3)) 661 == 3))
590 { 662 {
591 tm.tm_year -= TM_YEAR_BASE; 663 tm.tm_year -= TM_YEAR_BASE;
592 tm.tm_mon--; 664 tm.tm_mon--;
@@ -595,10 +667,10 @@ main (int argc, char **argv)
595 tl = mktime (&tmk); 667 tl = mktime (&tmk);
596 lt = localtime (&tl); 668 lt = localtime (&tl);
597 if (lt) 669 if (lt)
598 { 670 {
599 tml = *lt; 671 tml = *lt;
600 lt = &tml; 672 lt = &tml;
601 } 673 }
602 printf ("mktime returns %ld == ", (long int) tl); 674 printf ("mktime returns %ld == ", (long int) tl);
603 print_tm (&tmk); 675 print_tm (&tmk);
604 printf ("\n"); 676 printf ("\n");
@@ -611,51 +683,51 @@ main (int argc, char **argv)
611 time_t to = atol (argv[3]); 683 time_t to = atol (argv[3]);
612 684
613 if (argc == 4) 685 if (argc == 4)
614 for (tl = from; by < 0 ? to <= tl : tl <= to; tl = tl1) 686 for (tl = from; by < 0 ? to <= tl : tl <= to; tl = tl1)
615 { 687 {
616 lt = localtime (&tl); 688 lt = localtime (&tl);
617 if (lt) 689 if (lt)
618 { 690 {
619 tmk = tml = *lt; 691 tmk = tml = *lt;
620 tk = mktime (&tmk); 692 tk = mktime (&tmk);
621 status |= check_result (tk, tmk, tl, &tml); 693 status |= check_result (tk, tmk, tl, &tml);
622 } 694 }
623 else 695 else
624 { 696 {
625 printf ("localtime (%ld) yields 0\n", (long int) tl); 697 printf ("localtime (%ld) yields 0\n", (long int) tl);
626 status = 1; 698 status = 1;
627 } 699 }
628 tl1 = tl + by; 700 tl1 = tl + by;
629 if ((tl1 < tl) != (by < 0)) 701 if ((tl1 < tl) != (by < 0))
630 break; 702 break;
631 } 703 }
632 else 704 else
633 for (tl = from; by < 0 ? to <= tl : tl <= to; tl = tl1) 705 for (tl = from; by < 0 ? to <= tl : tl <= to; tl = tl1)
634 { 706 {
635 /* Null benchmark. */ 707 /* Null benchmark. */
636 lt = localtime (&tl); 708 lt = localtime (&tl);
637 if (lt) 709 if (lt)
638 { 710 {
639 tmk = tml = *lt; 711 tmk = tml = *lt;
640 tk = tl; 712 tk = tl;
641 status |= check_result (tk, tmk, tl, &tml); 713 status |= check_result (tk, tmk, tl, &tml);
642 } 714 }
643 else 715 else
644 { 716 {
645 printf ("localtime (%ld) yields 0\n", (long int) tl); 717 printf ("localtime (%ld) yields 0\n", (long int) tl);
646 status = 1; 718 status = 1;
647 } 719 }
648 tl1 = tl + by; 720 tl1 = tl + by;
649 if ((tl1 < tl) != (by < 0)) 721 if ((tl1 < tl) != (by < 0))
650 break; 722 break;
651 } 723 }
652 } 724 }
653 else 725 else
654 printf ("Usage:\ 726 printf ("Usage:\
655\t%s YYYY-MM-DD HH:MM:SS [ISDST] # Test given time.\n\ 727\t%s YYYY-MM-DD HH:MM:SS [ISDST] # Test given time.\n\
656\t%s FROM BY TO # Test values FROM, FROM+BY, ..., TO.\n\ 728\t%s FROM BY TO # Test values FROM, FROM+BY, ..., TO.\n\
657\t%s FROM BY TO - # Do not test those values (for benchmark).\n", 729\t%s FROM BY TO - # Do not test those values (for benchmark).\n",
658 argv[0], argv[0], argv[0]); 730 argv[0], argv[0], argv[0]);
659 731
660 return status; 732 return status;
661} 733}
@@ -664,6 +736,6 @@ main (int argc, char **argv)
664 736
665/* 737/*
666Local Variables: 738Local Variables:
667compile-command: "gcc -DDEBUG -Wall -W -O -g mktime.c -o mktime" 739compile-command: "gcc -DDEBUG -I. -Wall -W -O2 -g mktime.c -o mktime"
668End: 740End:
669*/ 741*/
diff --git a/gl/mountlist.c b/gl/mountlist.c
index 996b71a..30f4286 100644
--- a/gl/mountlist.c
+++ b/gl/mountlist.c
@@ -1,6 +1,6 @@
1/* mountlist.c -- return a list of mounted file systems 1/* mountlist.c -- return a list of mounted file systems
2 2
3 Copyright (C) 1991-1992, 1997-2010 Free Software Foundation, Inc. 3 Copyright (C) 1991-1992, 1997-2013 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
@@ -112,6 +112,11 @@
112# include <sys/vfs.h> 112# include <sys/vfs.h>
113#endif 113#endif
114 114
115#ifdef MOUNTED_INTERIX_STATVFS /* Interix. */
116# include <sys/statvfs.h>
117# include <dirent.h>
118#endif
119
115#ifdef DOLPHIN 120#ifdef DOLPHIN
116/* So special that it's not worth putting this in autoconf. */ 121/* So special that it's not worth putting this in autoconf. */
117# undef MOUNTED_FREAD_FSTYP 122# undef MOUNTED_FREAD_FSTYP
@@ -123,8 +128,12 @@
123# include <sys/mntent.h> 128# include <sys/mntent.h>
124#endif 129#endif
125 130
131#ifndef HAVE_HASMNTOPT
132# define hasmntopt(mnt, opt) ((char *) 0)
133#endif
134
126#undef MNT_IGNORE 135#undef MNT_IGNORE
127#if defined MNTOPT_IGNORE && defined HAVE_HASMNTOPT 136#ifdef MNTOPT_IGNORE
128# define MNT_IGNORE(M) hasmntopt (M, MNTOPT_IGNORE) 137# define MNT_IGNORE(M) hasmntopt (M, MNTOPT_IGNORE)
129#else 138#else
130# define MNT_IGNORE(M) 0 139# define MNT_IGNORE(M) 0
@@ -144,21 +153,66 @@
144#undef opendir 153#undef opendir
145#undef closedir 154#undef closedir
146 155
147#ifndef ME_DUMMY 156#define ME_DUMMY_0(Fs_name, Fs_type) \
148# define ME_DUMMY(Fs_name, Fs_type) \ 157 (strcmp (Fs_type, "autofs") == 0 \
149 (strcmp (Fs_type, "autofs") == 0 \ 158 || strcmp (Fs_type, "proc") == 0 \
150 || strcmp (Fs_type, "none") == 0 \ 159 || strcmp (Fs_type, "subfs") == 0 \
151 || strcmp (Fs_type, "proc") == 0 \ 160 /* for Linux 2.6/3.x */ \
152 || strcmp (Fs_type, "subfs") == 0 \ 161 || strcmp (Fs_type, "debugfs") == 0 \
153 /* for NetBSD 3.0 */ \ 162 || strcmp (Fs_type, "devpts") == 0 \
154 || strcmp (Fs_type, "kernfs") == 0 \ 163 || strcmp (Fs_type, "fusectl") == 0 \
155 /* for Irix 6.5 */ \ 164 || strcmp (Fs_type, "mqueue") == 0 \
156 || strcmp (Fs_type, "ignore") == 0) 165 || strcmp (Fs_type, "rpc_pipefs") == 0 \
166 || strcmp (Fs_type, "sysfs") == 0 \
167 /* FreeBSD, Linux 2.4 */ \
168 || strcmp (Fs_type, "devfs") == 0 \
169 /* for NetBSD 3.0 */ \
170 || strcmp (Fs_type, "kernfs") == 0 \
171 /* for Irix 6.5 */ \
172 || strcmp (Fs_type, "ignore") == 0)
173
174/* Historically, we have marked as "dummy" any file system of type "none",
175 but now that programs like du need to know about bind-mounted directories,
176 we grant an exception to any with "bind" in its list of mount options.
177 I.e., those are *not* dummy entries. */
178#ifdef MOUNTED_GETMNTENT1
179# define ME_DUMMY(Fs_name, Fs_type, Fs_ent) \
180 (ME_DUMMY_0 (Fs_name, Fs_type) \
181 || (strcmp (Fs_type, "none") == 0 \
182 && !hasmntopt (Fs_ent, "bind")))
183#else
184# define ME_DUMMY(Fs_name, Fs_type) \
185 (ME_DUMMY_0 (Fs_name, Fs_type) || strcmp (Fs_type, "none") == 0)
186#endif
187
188#ifdef __CYGWIN__
189# include <windows.h>
190# define ME_REMOTE me_remote
191/* All cygwin mount points include ':' or start with '//'; so it
192 requires a native Windows call to determine remote disks. */
193static bool
194me_remote (char const *fs_name, char const *fs_type _GL_UNUSED)
195{
196 if (fs_name[0] && fs_name[1] == ':')
197 {
198 char drive[4];
199 sprintf (drive, "%c:\\", fs_name[0]);
200 switch (GetDriveType (drive))
201 {
202 case DRIVE_REMOVABLE:
203 case DRIVE_FIXED:
204 case DRIVE_CDROM:
205 case DRIVE_RAMDISK:
206 return false;
207 }
208 }
209 return true;
210}
157#endif 211#endif
158 212
159#ifndef ME_REMOTE 213#ifndef ME_REMOTE
160/* A file system is `remote' if its Fs_name contains a `:' 214/* A file system is "remote" if its Fs_name contains a ':'
161 or if (it is of type (smbfs or cifs) and its Fs_name starts with `//'). */ 215 or if (it is of type (smbfs or cifs) and its Fs_name starts with '//'). */
162# define ME_REMOTE(Fs_name, Fs_type) \ 216# define ME_REMOTE(Fs_name, Fs_type) \
163 (strchr (Fs_name, ':') != NULL \ 217 (strchr (Fs_name, ':') != NULL \
164 || ((Fs_name)[0] == '/' \ 218 || ((Fs_name)[0] == '/' \
@@ -354,19 +408,20 @@ read_file_system_list (bool need_fs_type)
354 408
355 if (listmntent (&mntlist, KMTAB, NULL, NULL) < 0) 409 if (listmntent (&mntlist, KMTAB, NULL, NULL) < 0)
356 return NULL; 410 return NULL;
357 for (p = mntlist; p; p = p->next) { 411 for (p = mntlist; p; p = p->next)
358 mnt = p->ment; 412 {
359 me = xmalloc (sizeof *me); 413 mnt = p->ment;
360 me->me_devname = xstrdup (mnt->mnt_fsname); 414 me = xmalloc (sizeof *me);
361 me->me_mountdir = xstrdup (mnt->mnt_dir); 415 me->me_devname = xstrdup (mnt->mnt_fsname);
362 me->me_type = xstrdup (mnt->mnt_type); 416 me->me_mountdir = xstrdup (mnt->mnt_dir);
363 me->me_type_malloced = 1; 417 me->me_type = xstrdup (mnt->mnt_type);
364 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); 418 me->me_type_malloced = 1;
365 me->me_remote = ME_REMOTE (me->me_devname, me->me_type); 419 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
366 me->me_dev = -1; 420 me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
367 *mtail = me; 421 me->me_dev = -1;
368 mtail = &me->me_next; 422 *mtail = me;
369 } 423 mtail = &me->me_next;
424 }
370 freemntlist (mntlist); 425 freemntlist (mntlist);
371 } 426 }
372#endif 427#endif
@@ -388,7 +443,7 @@ read_file_system_list (bool need_fs_type)
388 me->me_mountdir = xstrdup (mnt->mnt_dir); 443 me->me_mountdir = xstrdup (mnt->mnt_dir);
389 me->me_type = xstrdup (mnt->mnt_type); 444 me->me_type = xstrdup (mnt->mnt_type);
390 me->me_type_malloced = 1; 445 me->me_type_malloced = 1;
391 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); 446 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type, mnt);
392 me->me_remote = ME_REMOTE (me->me_devname, me->me_type); 447 me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
393 me->me_dev = dev_from_mount_options (mnt->mnt_opts); 448 me->me_dev = dev_from_mount_options (mnt->mnt_opts);
394 449
@@ -564,7 +619,8 @@ read_file_system_list (bool need_fs_type)
564 break; 619 break;
565 620
566 me = xmalloc (sizeof *me); 621 me = xmalloc (sizeof *me);
567 me->me_devname = xstrdup (fi.device_name[0] != '\0' ? fi.device_name : fi.fsh_name); 622 me->me_devname = xstrdup (fi.device_name[0] != '\0'
623 ? fi.device_name : fi.fsh_name);
568 me->me_mountdir = xstrdup (re != NULL ? re->name : fi.fsh_name); 624 me->me_mountdir = xstrdup (re != NULL ? re->name : fi.fsh_name);
569 me->me_type = xstrdup (fi.fsh_name); 625 me->me_type = xstrdup (fi.fsh_name);
570 me->me_type_malloced = 1; 626 me->me_type_malloced = 1;
@@ -594,9 +650,9 @@ read_file_system_list (bool need_fs_type)
594 size_t bufsize; 650 size_t bufsize;
595 struct statfs *stats; 651 struct statfs *stats;
596 652
597 numsys = getfsstat ((struct statfs *)0, 0L, MNT_NOWAIT); 653 numsys = getfsstat (NULL, 0L, MNT_NOWAIT);
598 if (numsys < 0) 654 if (numsys < 0)
599 return (NULL); 655 return NULL;
600 if (SIZE_MAX / sizeof *stats <= numsys) 656 if (SIZE_MAX / sizeof *stats <= numsys)
601 xalloc_die (); 657 xalloc_die ();
602 658
@@ -607,7 +663,7 @@ read_file_system_list (bool need_fs_type)
607 if (numsys < 0) 663 if (numsys < 0)
608 { 664 {
609 free (stats); 665 free (stats);
610 return (NULL); 666 return NULL;
611 } 667 }
612 668
613 for (counter = 0; counter < numsys; counter++) 669 for (counter = 0; counter < numsys; counter++)
@@ -693,11 +749,11 @@ read_file_system_list (bool need_fs_type)
693#ifdef MOUNTED_GETMNTTBL /* DolphinOS goes its own way. */ 749#ifdef MOUNTED_GETMNTTBL /* DolphinOS goes its own way. */
694 { 750 {
695 struct mntent **mnttbl = getmnttbl (), **ent; 751 struct mntent **mnttbl = getmnttbl (), **ent;
696 for (ent=mnttbl;*ent;ent++) 752 for (ent = mnttbl; *ent; ent++)
697 { 753 {
698 me = xmalloc (sizeof *me); 754 me = xmalloc (sizeof *me);
699 me->me_devname = xstrdup ( (*ent)->mt_resource); 755 me->me_devname = xstrdup ((*ent)->mt_resource);
700 me->me_mountdir = xstrdup ( (*ent)->mt_directory); 756 me->me_mountdir = xstrdup ((*ent)->mt_directory);
701 me->me_type = xstrdup ((*ent)->mt_fstype); 757 me->me_type = xstrdup ((*ent)->mt_fstype);
702 me->me_type_malloced = 1; 758 me->me_type_malloced = 1;
703 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type); 759 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
@@ -854,6 +910,45 @@ read_file_system_list (bool need_fs_type)
854 } 910 }
855#endif /* MOUNTED_VMOUNT. */ 911#endif /* MOUNTED_VMOUNT. */
856 912
913#ifdef MOUNTED_INTERIX_STATVFS
914 {
915 DIR *dirp = opendir ("/dev/fs");
916 char node[9 + NAME_MAX];
917
918 if (!dirp)
919 goto free_then_fail;
920
921 while (1)
922 {
923 struct statvfs dev;
924 struct dirent entry;
925 struct dirent *result;
926
927 if (readdir_r (dirp, &entry, &result) || result == NULL)
928 break;
929
930 strcpy (node, "/dev/fs/");
931 strcat (node, entry.d_name);
932
933 if (statvfs (node, &dev) == 0)
934 {
935 me = xmalloc (sizeof *me);
936 me->me_devname = xstrdup (dev.f_mntfromname);
937 me->me_mountdir = xstrdup (dev.f_mntonname);
938 me->me_type = xstrdup (dev.f_fstypename);
939 me->me_type_malloced = 1;
940 me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
941 me->me_remote = ME_REMOTE (me->me_devname, me->me_type);
942 me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
943
944 /* Add to the linked list. */
945 *mtail = me;
946 mtail = &me->me_next;
947 }
948 }
949 }
950#endif /* MOUNTED_INTERIX_STATVFS */
951
857 *mtail = NULL; 952 *mtail = NULL;
858 return mount_list; 953 return mount_list;
859 954
@@ -866,11 +961,7 @@ read_file_system_list (bool need_fs_type)
866 while (mount_list) 961 while (mount_list)
867 { 962 {
868 me = mount_list->me_next; 963 me = mount_list->me_next;
869 free (mount_list->me_devname); 964 free_mount_entry (mount_list);
870 free (mount_list->me_mountdir);
871 if (mount_list->me_type_malloced)
872 free (mount_list->me_type);
873 free (mount_list);
874 mount_list = me; 965 mount_list = me;
875 } 966 }
876 967
@@ -878,3 +969,14 @@ read_file_system_list (bool need_fs_type)
878 return NULL; 969 return NULL;
879 } 970 }
880} 971}
972
973/* Free a mount entry as returned from read_file_system_list (). */
974
975void free_mount_entry (struct mount_entry *me)
976{
977 free (me->me_devname);
978 free (me->me_mountdir);
979 if (me->me_type_malloced)
980 free (me->me_type);
981 free (me);
982}
diff --git a/gl/mountlist.h b/gl/mountlist.h
index ad66def..55877e2 100644
--- a/gl/mountlist.h
+++ b/gl/mountlist.h
@@ -1,6 +1,6 @@
1/* mountlist.h -- declarations for list of mounted file systems 1/* mountlist.h -- declarations for list of mounted file systems
2 2
3 Copyright (C) 1991-1992, 1998, 2000-2005, 2009-2010 Free Software 3 Copyright (C) 1991-1992, 1998, 2000-2005, 2009-2013 Free Software
4 Foundation, Inc. 4 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
@@ -36,5 +36,6 @@ struct mount_entry
36}; 36};
37 37
38struct mount_entry *read_file_system_list (bool need_fs_type); 38struct mount_entry *read_file_system_list (bool need_fs_type);
39void free_mount_entry (struct mount_entry *entry);
39 40
40#endif 41#endif
diff --git a/gl/msvc-inval.c b/gl/msvc-inval.c
new file mode 100644
index 0000000..396031e
--- /dev/null
+++ b/gl/msvc-inval.c
@@ -0,0 +1,129 @@
1/* Invalid parameter handler for MSVC runtime libraries.
2 Copyright (C) 2011-2013 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, or (at your option)
7 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 along
15 with this program; if not, see <http://www.gnu.org/licenses/>. */
16
17#include <config.h>
18
19/* Specification. */
20#include "msvc-inval.h"
21
22#if HAVE_MSVC_INVALID_PARAMETER_HANDLER \
23 && !(MSVC_INVALID_PARAMETER_HANDLING == SANE_LIBRARY_HANDLING)
24
25/* Get _invalid_parameter_handler type and _set_invalid_parameter_handler
26 declaration. */
27# include <stdlib.h>
28
29# if MSVC_INVALID_PARAMETER_HANDLING == DEFAULT_HANDLING
30
31static void __cdecl
32gl_msvc_invalid_parameter_handler (const wchar_t *expression,
33 const wchar_t *function,
34 const wchar_t *file,
35 unsigned int line,
36 uintptr_t dummy)
37{
38}
39
40# else
41
42/* Get declarations of the native Windows API functions. */
43# define WIN32_LEAN_AND_MEAN
44# include <windows.h>
45
46# if defined _MSC_VER
47
48static void __cdecl
49gl_msvc_invalid_parameter_handler (const wchar_t *expression,
50 const wchar_t *function,
51 const wchar_t *file,
52 unsigned int line,
53 uintptr_t dummy)
54{
55 RaiseException (STATUS_GNULIB_INVALID_PARAMETER, 0, 0, NULL);
56}
57
58# else
59
60/* An index to thread-local storage. */
61static DWORD tls_index;
62static int tls_initialized /* = 0 */;
63
64/* Used as a fallback only. */
65static struct gl_msvc_inval_per_thread not_per_thread;
66
67struct gl_msvc_inval_per_thread *
68gl_msvc_inval_current (void)
69{
70 if (!tls_initialized)
71 {
72 tls_index = TlsAlloc ();
73 tls_initialized = 1;
74 }
75 if (tls_index == TLS_OUT_OF_INDEXES)
76 /* TlsAlloc had failed. */
77 return &not_per_thread;
78 else
79 {
80 struct gl_msvc_inval_per_thread *pointer =
81 (struct gl_msvc_inval_per_thread *) TlsGetValue (tls_index);
82 if (pointer == NULL)
83 {
84 /* First call. Allocate a new 'struct gl_msvc_inval_per_thread'. */
85 pointer =
86 (struct gl_msvc_inval_per_thread *)
87 malloc (sizeof (struct gl_msvc_inval_per_thread));
88 if (pointer == NULL)
89 /* Could not allocate memory. Use the global storage. */
90 pointer = &not_per_thread;
91 TlsSetValue (tls_index, pointer);
92 }
93 return pointer;
94 }
95}
96
97static void __cdecl
98gl_msvc_invalid_parameter_handler (const wchar_t *expression,
99 const wchar_t *function,
100 const wchar_t *file,
101 unsigned int line,
102 uintptr_t dummy)
103{
104 struct gl_msvc_inval_per_thread *current = gl_msvc_inval_current ();
105 if (current->restart_valid)
106 longjmp (current->restart, 1);
107 else
108 /* An invalid parameter notification from outside the gnulib code.
109 Give the caller a chance to intervene. */
110 RaiseException (STATUS_GNULIB_INVALID_PARAMETER, 0, 0, NULL);
111}
112
113# endif
114
115# endif
116
117static int gl_msvc_inval_initialized /* = 0 */;
118
119void
120gl_msvc_inval_ensure_handler (void)
121{
122 if (gl_msvc_inval_initialized == 0)
123 {
124 _set_invalid_parameter_handler (gl_msvc_invalid_parameter_handler);
125 gl_msvc_inval_initialized = 1;
126 }
127}
128
129#endif
diff --git a/gl/msvc-inval.h b/gl/msvc-inval.h
new file mode 100644
index 0000000..dcb0353
--- /dev/null
+++ b/gl/msvc-inval.h
@@ -0,0 +1,222 @@
1/* Invalid parameter handler for MSVC runtime libraries.
2 Copyright (C) 2011-2013 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, or (at your option)
7 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 along
15 with this program; if not, see <http://www.gnu.org/licenses/>. */
16
17#ifndef _MSVC_INVAL_H
18#define _MSVC_INVAL_H
19
20/* With MSVC runtime libraries with the "invalid parameter handler" concept,
21 functions like fprintf(), dup2(), or close() crash when the caller passes
22 an invalid argument. But POSIX wants error codes (such as EINVAL or EBADF)
23 instead.
24 This file defines macros that turn such an invalid parameter notification
25 into a non-local exit. An error code can then be produced at the target
26 of this exit. You can thus write code like
27
28 TRY_MSVC_INVAL
29 {
30 <Code that can trigger an invalid parameter notification
31 but does not do 'return', 'break', 'continue', nor 'goto'.>
32 }
33 CATCH_MSVC_INVAL
34 {
35 <Code that handles an invalid parameter notification
36 but does not do 'return', 'break', 'continue', nor 'goto'.>
37 }
38 DONE_MSVC_INVAL;
39
40 This entire block expands to a single statement.
41
42 The handling of invalid parameters can be done in three ways:
43
44 * The default way, which is reasonable for programs (not libraries):
45 AC_DEFINE([MSVC_INVALID_PARAMETER_HANDLING], [DEFAULT_HANDLING])
46
47 * The way for libraries that make "hairy" calls (like close(-1), or
48 fclose(fp) where fileno(fp) is closed, or simply getdtablesize()):
49 AC_DEFINE([MSVC_INVALID_PARAMETER_HANDLING], [HAIRY_LIBRARY_HANDLING])
50
51 * The way for libraries that make no "hairy" calls:
52 AC_DEFINE([MSVC_INVALID_PARAMETER_HANDLING], [SANE_LIBRARY_HANDLING])
53 */
54
55#define DEFAULT_HANDLING 0
56#define HAIRY_LIBRARY_HANDLING 1
57#define SANE_LIBRARY_HANDLING 2
58
59#if HAVE_MSVC_INVALID_PARAMETER_HANDLER \
60 && !(MSVC_INVALID_PARAMETER_HANDLING == SANE_LIBRARY_HANDLING)
61/* A native Windows platform with the "invalid parameter handler" concept,
62 and either DEFAULT_HANDLING or HAIRY_LIBRARY_HANDLING. */
63
64# if MSVC_INVALID_PARAMETER_HANDLING == DEFAULT_HANDLING
65/* Default handling. */
66
67# ifdef __cplusplus
68extern "C" {
69# endif
70
71/* Ensure that the invalid parameter handler in installed that just returns.
72 Because we assume no other part of the program installs a different
73 invalid parameter handler, this solution is multithread-safe. */
74extern void gl_msvc_inval_ensure_handler (void);
75
76# ifdef __cplusplus
77}
78# endif
79
80# define TRY_MSVC_INVAL \
81 do \
82 { \
83 gl_msvc_inval_ensure_handler (); \
84 if (1)
85# define CATCH_MSVC_INVAL \
86 else
87# define DONE_MSVC_INVAL \
88 } \
89 while (0)
90
91# else
92/* Handling for hairy libraries. */
93
94# include <excpt.h>
95
96/* Gnulib can define its own status codes, as described in the page
97 "Raising Software Exceptions" on microsoft.com
98 <http://msdn.microsoft.com/en-us/library/het71c37.aspx>.
99 Our status codes are composed of
100 - 0xE0000000, mandatory for all user-defined status codes,
101 - 0x474E550, a API identifier ("GNU"),
102 - 0, 1, 2, ..., used to distinguish different status codes from the
103 same API. */
104# define STATUS_GNULIB_INVALID_PARAMETER (0xE0000000 + 0x474E550 + 0)
105
106# if defined _MSC_VER
107/* A compiler that supports __try/__except, as described in the page
108 "try-except statement" on microsoft.com
109 <http://msdn.microsoft.com/en-us/library/s58ftw19.aspx>.
110 With __try/__except, we can use the multithread-safe exception handling. */
111
112# ifdef __cplusplus
113extern "C" {
114# endif
115
116/* Ensure that the invalid parameter handler in installed that raises a
117 software exception with code STATUS_GNULIB_INVALID_PARAMETER.
118 Because we assume no other part of the program installs a different
119 invalid parameter handler, this solution is multithread-safe. */
120extern void gl_msvc_inval_ensure_handler (void);
121
122# ifdef __cplusplus
123}
124# endif
125
126# define TRY_MSVC_INVAL \
127 do \
128 { \
129 gl_msvc_inval_ensure_handler (); \
130 __try
131# define CATCH_MSVC_INVAL \
132 __except (GetExceptionCode () == STATUS_GNULIB_INVALID_PARAMETER \
133 ? EXCEPTION_EXECUTE_HANDLER \
134 : EXCEPTION_CONTINUE_SEARCH)
135# define DONE_MSVC_INVAL \
136 } \
137 while (0)
138
139# else
140/* Any compiler.
141 We can only use setjmp/longjmp. */
142
143# include <setjmp.h>
144
145# ifdef __cplusplus
146extern "C" {
147# endif
148
149struct gl_msvc_inval_per_thread
150{
151 /* The restart that will resume execution at the code between
152 CATCH_MSVC_INVAL and DONE_MSVC_INVAL. It is enabled only between
153 TRY_MSVC_INVAL and CATCH_MSVC_INVAL. */
154 jmp_buf restart;
155
156 /* Tells whether the contents of restart is valid. */
157 int restart_valid;
158};
159
160/* Ensure that the invalid parameter handler in installed that passes
161 control to the gl_msvc_inval_restart if it is valid, or raises a
162 software exception with code STATUS_GNULIB_INVALID_PARAMETER otherwise.
163 Because we assume no other part of the program installs a different
164 invalid parameter handler, this solution is multithread-safe. */
165extern void gl_msvc_inval_ensure_handler (void);
166
167/* Return a pointer to the per-thread data for the current thread. */
168extern struct gl_msvc_inval_per_thread *gl_msvc_inval_current (void);
169
170# ifdef __cplusplus
171}
172# endif
173
174# define TRY_MSVC_INVAL \
175 do \
176 { \
177 struct gl_msvc_inval_per_thread *msvc_inval_current; \
178 gl_msvc_inval_ensure_handler (); \
179 msvc_inval_current = gl_msvc_inval_current (); \
180 /* First, initialize gl_msvc_inval_restart. */ \
181 if (setjmp (msvc_inval_current->restart) == 0) \
182 { \
183 /* Then, mark it as valid. */ \
184 msvc_inval_current->restart_valid = 1;
185# define CATCH_MSVC_INVAL \
186 /* Execution completed. \
187 Mark gl_msvc_inval_restart as invalid. */ \
188 msvc_inval_current->restart_valid = 0; \
189 } \
190 else \
191 { \
192 /* Execution triggered an invalid parameter notification. \
193 Mark gl_msvc_inval_restart as invalid. */ \
194 msvc_inval_current->restart_valid = 0;
195# define DONE_MSVC_INVAL \
196 } \
197 } \
198 while (0)
199
200# endif
201
202# endif
203
204#else
205/* A platform that does not need to the invalid parameter handler,
206 or when SANE_LIBRARY_HANDLING is desired. */
207
208/* The braces here avoid GCC warnings like
209 "warning: suggest explicit braces to avoid ambiguous 'else'". */
210# define TRY_MSVC_INVAL \
211 do \
212 { \
213 if (1)
214# define CATCH_MSVC_INVAL \
215 else
216# define DONE_MSVC_INVAL \
217 } \
218 while (0)
219
220#endif
221
222#endif /* _MSVC_INVAL_H */
diff --git a/gl/msvc-nothrow.c b/gl/msvc-nothrow.c
new file mode 100644
index 0000000..8d65472
--- /dev/null
+++ b/gl/msvc-nothrow.c
@@ -0,0 +1,49 @@
1/* Wrappers that don't throw invalid parameter notifications
2 with MSVC runtime libraries.
3 Copyright (C) 2011-2013 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 along
16 with this program; if not, see <http://www.gnu.org/licenses/>. */
17
18#include <config.h>
19
20/* Specification. */
21#include "msvc-nothrow.h"
22
23/* Get declarations of the native Windows API functions. */
24#define WIN32_LEAN_AND_MEAN
25#include <windows.h>
26
27#include "msvc-inval.h"
28
29#undef _get_osfhandle
30
31#if HAVE_MSVC_INVALID_PARAMETER_HANDLER
32intptr_t
33_gl_nothrow_get_osfhandle (int fd)
34{
35 intptr_t result;
36
37 TRY_MSVC_INVAL
38 {
39 result = _get_osfhandle (fd);
40 }
41 CATCH_MSVC_INVAL
42 {
43 result = (intptr_t) INVALID_HANDLE_VALUE;
44 }
45 DONE_MSVC_INVAL;
46
47 return result;
48}
49#endif
diff --git a/gl/msvc-nothrow.h b/gl/msvc-nothrow.h
new file mode 100644
index 0000000..5f52181
--- /dev/null
+++ b/gl/msvc-nothrow.h
@@ -0,0 +1,43 @@
1/* Wrappers that don't throw invalid parameter notifications
2 with MSVC runtime libraries.
3 Copyright (C) 2011-2013 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 along
16 with this program; if not, see <http://www.gnu.org/licenses/>. */
17
18#ifndef _MSVC_NOTHROW_H
19#define _MSVC_NOTHROW_H
20
21/* With MSVC runtime libraries with the "invalid parameter handler" concept,
22 functions like fprintf(), dup2(), or close() crash when the caller passes
23 an invalid argument. But POSIX wants error codes (such as EINVAL or EBADF)
24 instead.
25 This file defines wrappers that turn such an invalid parameter notification
26 into an error code. */
27
28#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
29
30/* Get original declaration of _get_osfhandle. */
31# include <io.h>
32
33# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
34
35/* Override _get_osfhandle. */
36extern intptr_t _gl_nothrow_get_osfhandle (int fd);
37# define _get_osfhandle _gl_nothrow_get_osfhandle
38
39# endif
40
41#endif
42
43#endif /* _MSVC_NOTHROW_H */
diff --git a/gl/netdb.in.h b/gl/netdb.in.h
index f800cac..0da1800 100644
--- a/gl/netdb.in.h
+++ b/gl/netdb.in.h
@@ -1,5 +1,5 @@
1/* Provide a netdb.h header file for systems lacking it (read: MinGW). 1/* Provide a netdb.h header file for systems lacking it (read: MinGW).
2 Copyright (C) 2008-2010 Free Software Foundation, Inc. 2 Copyright (C) 2008-2013 Free Software Foundation, Inc.
3 Written by Simon Josefsson. 3 Written by Simon Josefsson.
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
@@ -13,18 +13,18 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
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, write to the Free Software Foundation, 16 along with this program; if not, see <http://www.gnu.org/licenses/>. */
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 17
19/* This file is supposed to be used on platforms that lack <netdb.h>. 18/* 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 19 It is intended to provide definitions and prototypes needed by an
21 application. */ 20 application. */
22 21
23#ifndef _GL_NETDB_H 22#ifndef _@GUARD_PREFIX@_NETDB_H
24 23
25#if __GNUC__ >= 3 24#if __GNUC__ >= 3
26@PRAGMA_SYSTEM_HEADER@ 25@PRAGMA_SYSTEM_HEADER@
27#endif 26#endif
27@PRAGMA_COLUMNS@
28 28
29#if @HAVE_NETDB_H@ 29#if @HAVE_NETDB_H@
30 30
@@ -33,12 +33,15 @@
33 33
34#endif 34#endif
35 35
36#ifndef _GL_NETDB_H 36#ifndef _@GUARD_PREFIX@_NETDB_H
37#define _GL_NETDB_H 37#define _@GUARD_PREFIX@_NETDB_H
38 38
39/* Get netdb.h definitions such as struct hostent for MinGW. */ 39/* Get <netdb.h> definitions such as 'socklen_t' on IRIX 6.5 and OSF/1 4.0 and
40 'struct hostent' on MinGW. */
40#include <sys/socket.h> 41#include <sys/socket.h>
41 42
43/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
44
42/* The definition of _GL_ARG_NONNULL is copied here. */ 45/* The definition of _GL_ARG_NONNULL is copied here. */
43 46
44/* The definition of _GL_WARN_ON_USE is copied here. */ 47/* The definition of _GL_WARN_ON_USE is copied here. */
@@ -50,6 +53,11 @@
50 53
51# if !@HAVE_STRUCT_ADDRINFO@ 54# if !@HAVE_STRUCT_ADDRINFO@
52 55
56# ifdef __cplusplus
57extern "C" {
58# endif
59
60# if !GNULIB_defined_struct_addrinfo
53/* Structure to contain information about address of a service provider. */ 61/* Structure to contain information about address of a service provider. */
54struct addrinfo 62struct addrinfo
55{ 63{
@@ -62,11 +70,18 @@ struct addrinfo
62 char *ai_canonname; /* Canonical name for service location. */ 70 char *ai_canonname; /* Canonical name for service location. */
63 struct addrinfo *ai_next; /* Pointer to next in list. */ 71 struct addrinfo *ai_next; /* Pointer to next in list. */
64}; 72};
73# define GNULIB_defined_struct_addrinfo 1
74# endif
75
76# ifdef __cplusplus
77}
78# endif
79
65# endif 80# endif
66 81
67/* Possible values for `ai_flags' field in `addrinfo' structure. */ 82/* Possible values for 'ai_flags' field in 'addrinfo' structure. */
68# ifndef AI_PASSIVE 83# ifndef AI_PASSIVE
69# define AI_PASSIVE 0x0001 /* Socket address is intended for `bind'. */ 84# define AI_PASSIVE 0x0001 /* Socket address is intended for 'bind'. */
70# endif 85# endif
71# ifndef AI_CANONNAME 86# ifndef AI_CANONNAME
72# define AI_CANONNAME 0x0002 /* Request for canonical name. */ 87# define AI_CANONNAME 0x0002 /* Request for canonical name. */
@@ -95,16 +110,16 @@ struct addrinfo
95 returned address type. */ 110 returned address type. */
96# endif 111# endif
97 112
98/* Error values for `getaddrinfo' function. */ 113/* Error values for 'getaddrinfo' function. */
99# ifndef EAI_BADFLAGS 114# ifndef EAI_BADFLAGS
100# define EAI_BADFLAGS -1 /* Invalid value for `ai_flags' field. */ 115# define EAI_BADFLAGS -1 /* Invalid value for 'ai_flags' field. */
101# define EAI_NONAME -2 /* NAME or SERVICE is unknown. */ 116# define EAI_NONAME -2 /* NAME or SERVICE is unknown. */
102# define EAI_AGAIN -3 /* Temporary failure in name resolution. */ 117# define EAI_AGAIN -3 /* Temporary failure in name resolution. */
103# define EAI_FAIL -4 /* Non-recoverable failure in name res. */ 118# define EAI_FAIL -4 /* Non-recoverable failure in name res. */
104# define EAI_NODATA -5 /* No address associated with NAME. */ 119# define EAI_NODATA -5 /* No address associated with NAME. */
105# define EAI_FAMILY -6 /* `ai_family' not supported. */ 120# define EAI_FAMILY -6 /* 'ai_family' not supported. */
106# define EAI_SOCKTYPE -7 /* `ai_socktype' not supported. */ 121# define EAI_SOCKTYPE -7 /* 'ai_socktype' not supported. */
107# define EAI_SERVICE -8 /* SERVICE not supported for `ai_socktype'. */ 122# define EAI_SERVICE -8 /* SERVICE not supported for 'ai_socktype'. */
108# define EAI_MEMORY -10 /* Memory allocation failure. */ 123# define EAI_MEMORY -10 /* Memory allocation failure. */
109# endif 124# endif
110 125
@@ -125,7 +140,7 @@ struct addrinfo
125# endif 140# endif
126# ifndef EAI_SYSTEM 141# ifndef EAI_SYSTEM
127/* Not defined on mingw32. */ 142/* Not defined on mingw32. */
128# define EAI_SYSTEM -11 /* System error returned in `errno'. */ 143# define EAI_SYSTEM -11 /* System error returned in 'errno'. */
129# endif 144# endif
130 145
131# if 0 146# if 0
@@ -148,37 +163,67 @@ struct addrinfo
148 socket addresses. 163 socket addresses.
149 For more details, see the POSIX:2001 specification 164 For more details, see the POSIX:2001 specification
150 <http://www.opengroup.org/susv3xsh/getaddrinfo.html>. */ 165 <http://www.opengroup.org/susv3xsh/getaddrinfo.html>. */
151extern int getaddrinfo (const char *restrict nodename, 166_GL_FUNCDECL_SYS (getaddrinfo, int,
152 const char *restrict servname, 167 (const char *restrict nodename,
153 const struct addrinfo *restrict hints, 168 const char *restrict servname,
154 struct addrinfo **restrict res) 169 const struct addrinfo *restrict hints,
155 _GL_ARG_NONNULL ((4)); 170 struct addrinfo **restrict res)
171 _GL_ARG_NONNULL ((4)));
156# endif 172# endif
173_GL_CXXALIAS_SYS (getaddrinfo, int,
174 (const char *restrict nodename,
175 const char *restrict servname,
176 const struct addrinfo *restrict hints,
177 struct addrinfo **restrict res));
178_GL_CXXALIASWARN (getaddrinfo);
157 179
158# if !@HAVE_DECL_FREEADDRINFO@ 180# if !@HAVE_DECL_FREEADDRINFO@
159/* Free `addrinfo' structure AI including associated storage. 181/* Free 'addrinfo' structure AI including associated storage.
160 For more details, see the POSIX:2001 specification 182 For more details, see the POSIX:2001 specification
161 <http://www.opengroup.org/susv3xsh/getaddrinfo.html>. */ 183 <http://www.opengroup.org/susv3xsh/getaddrinfo.html>. */
162extern void freeaddrinfo (struct addrinfo *ai) _GL_ARG_NONNULL ((1)); 184_GL_FUNCDECL_SYS (freeaddrinfo, void, (struct addrinfo *ai)
185 _GL_ARG_NONNULL ((1)));
163# endif 186# endif
187_GL_CXXALIAS_SYS (freeaddrinfo, void, (struct addrinfo *ai));
188_GL_CXXALIASWARN (freeaddrinfo);
164 189
165# if !@HAVE_DECL_GAI_STRERROR@ 190# if @REPLACE_GAI_STRERROR@
191# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
192# undef gai_strerror
193# define gai_strerror rpl_gai_strerror
194# endif
195_GL_FUNCDECL_RPL (gai_strerror, const char *, (int ecode));
196_GL_CXXALIAS_RPL (gai_strerror, const char *, (int ecode));
197# else
198# if !@HAVE_DECL_GAI_STRERROR@
166/* Convert error return from getaddrinfo() to a string. 199/* Convert error return from getaddrinfo() to a string.
167 For more details, see the POSIX:2001 specification 200 For more details, see the POSIX:2001 specification
168 <http://www.opengroup.org/susv3xsh/gai_strerror.html>. */ 201 <http://www.opengroup.org/susv3xsh/gai_strerror.html>. */
169extern const char *gai_strerror (int ecode); 202_GL_FUNCDECL_SYS (gai_strerror, const char *, (int ecode));
203# endif
204_GL_CXXALIAS_SYS (gai_strerror, const char *, (int ecode));
170# endif 205# endif
206_GL_CXXALIASWARN (gai_strerror);
171 207
172# if !@HAVE_DECL_GETNAMEINFO@ 208# if !@HAVE_DECL_GETNAMEINFO@
173/* Convert socket address to printable node and service names. 209/* Convert socket address to printable node and service names.
174 For more details, see the POSIX:2001 specification 210 For more details, see the POSIX:2001 specification
175 <http://www.opengroup.org/susv3xsh/getnameinfo.html>. */ 211 <http://www.opengroup.org/susv3xsh/getnameinfo.html>. */
176extern int getnameinfo (const struct sockaddr *restrict sa, socklen_t salen, 212_GL_FUNCDECL_SYS (getnameinfo, int,
213 (const struct sockaddr *restrict sa, socklen_t salen,
214 char *restrict node, socklen_t nodelen,
215 char *restrict service, socklen_t servicelen,
216 int flags)
217 _GL_ARG_NONNULL ((1)));
218# endif
219/* Need to cast, because on glibc systems, the seventh parameter is
220 unsigned int flags. */
221_GL_CXXALIAS_SYS_CAST (getnameinfo, int,
222 (const struct sockaddr *restrict sa, socklen_t salen,
177 char *restrict node, socklen_t nodelen, 223 char *restrict node, socklen_t nodelen,
178 char *restrict service, socklen_t servicelen, 224 char *restrict service, socklen_t servicelen,
179 int flags) 225 int flags));
180 _GL_ARG_NONNULL ((1)); 226_GL_CXXALIASWARN (getnameinfo);
181# endif
182 227
183/* Possible flags for getnameinfo. */ 228/* Possible flags for getnameinfo. */
184# ifndef NI_NUMERICHOST 229# ifndef NI_NUMERICHOST
@@ -216,5 +261,5 @@ _GL_WARN_ON_USE (getnameinfo, "getnameinfo is unportable - "
216 261
217#endif 262#endif
218 263
219#endif /* _GL_NETDB_H */ 264#endif /* _@GUARD_PREFIX@_NETDB_H */
220#endif /* _GL_NETDB_H */ 265#endif /* _@GUARD_PREFIX@_NETDB_H */
diff --git a/gl/netinet_in.in.h b/gl/netinet_in.in.h
index 7f0ff42..b456c4f 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-2010 Free Software Foundation, Inc. 2 Copyright (C) 2007-2013 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
@@ -12,14 +12,14 @@
12 GNU General Public License for more details. 12 GNU General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software Foundation, 15 along with this program; if not, see <http://www.gnu.org/licenses/>. */
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
17 16
18#ifndef _GL_NETINET_IN_H 17#ifndef _@GUARD_PREFIX@_NETINET_IN_H
19 18
20#if __GNUC__ >= 3 19#if __GNUC__ >= 3
21@PRAGMA_SYSTEM_HEADER@ 20@PRAGMA_SYSTEM_HEADER@
22#endif 21#endif
22@PRAGMA_COLUMNS@
23 23
24#if @HAVE_NETINET_IN_H@ 24#if @HAVE_NETINET_IN_H@
25 25
@@ -32,8 +32,8 @@
32 32
33#endif 33#endif
34 34
35#ifndef _GL_NETINET_IN_H 35#ifndef _@GUARD_PREFIX@_NETINET_IN_H
36#define _GL_NETINET_IN_H 36#define _@GUARD_PREFIX@_NETINET_IN_H
37 37
38#if !@HAVE_NETINET_IN_H@ 38#if !@HAVE_NETINET_IN_H@
39 39
@@ -43,5 +43,5 @@
43 43
44#endif 44#endif
45 45
46#endif /* _GL_NETINET_IN_H */ 46#endif /* _@GUARD_PREFIX@_NETINET_IN_H */
47#endif /* _GL_NETINET_IN_H */ 47#endif /* _@GUARD_PREFIX@_NETINET_IN_H */
diff --git a/gl/nl_langinfo.c b/gl/nl_langinfo.c
index e81c81e..771c953 100644
--- a/gl/nl_langinfo.c
+++ b/gl/nl_langinfo.c
@@ -1,6 +1,6 @@
1/* nl_langinfo() replacement: query locale dependent information. 1/* nl_langinfo() replacement: query locale dependent information.
2 2
3 Copyright (C) 2007-2010 Free Software Foundation, Inc. 3 Copyright (C) 2007-2013 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
@@ -67,6 +67,10 @@ rpl_nl_langinfo (nl_item item)
67 return ""; 67 return "";
68 } 68 }
69# endif 69# endif
70# if GNULIB_defined_T_FMT_AMPM
71 case T_FMT_AMPM:
72 return "%I:%M:%S %p";
73# endif
70# if GNULIB_defined_ERA 74# if GNULIB_defined_ERA
71 case ERA: 75 case ERA:
72 /* The format is not standardized. In glibc it is a sequence of strings 76 /* The format is not standardized. In glibc it is a sequence of strings
@@ -93,6 +97,12 @@ rpl_nl_langinfo (nl_item item)
93 strings, appended in memory. */ 97 strings, appended in memory. */
94 return "\0\0\0\0\0\0\0\0\0\0"; 98 return "\0\0\0\0\0\0\0\0\0\0";
95# endif 99# endif
100# if GNULIB_defined_YESEXPR || !FUNC_NL_LANGINFO_YESEXPR_WORKS
101 case YESEXPR:
102 return "^[yY]";
103 case NOEXPR:
104 return "^[nN]";
105# endif
96 default: 106 default:
97 break; 107 break;
98 } 108 }
@@ -131,7 +141,8 @@ nl_langinfo (nl_item item)
131 { 141 {
132 static char buf[2 + 10 + 1]; 142 static char buf[2 + 10 + 1];
133 143
134 /* Woe32 has a function returning the locale's codepage as a number. */ 144 /* The Windows API has a function returning the locale's codepage as
145 a number. */
135 sprintf (buf, "CP%u", GetACP ()); 146 sprintf (buf, "CP%u", GetACP ());
136 return buf; 147 return buf;
137 } 148 }
diff --git a/gl/open-safer.c b/gl/open-safer.c
deleted file mode 100644
index 3b36471..0000000
--- a/gl/open-safer.c
+++ /dev/null
@@ -1,46 +0,0 @@
1/* Invoke open, but avoid some glitches.
2
3 Copyright (C) 2005-2006, 2008-2010 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#include <config.h>
21
22#include "fcntl-safer.h"
23
24#include <fcntl.h>
25#include <stdarg.h>
26#include "unistd-safer.h"
27
28int
29open_safer (char const *file, int flags, ...)
30{
31 mode_t mode = 0;
32
33 if (flags & O_CREAT)
34 {
35 va_list ap;
36 va_start (ap, flags);
37
38 /* We have to use PROMOTED_MODE_T instead of mode_t, otherwise GCC 4
39 creates crashing code when 'mode_t' is smaller than 'int'. */
40 mode = va_arg (ap, PROMOTED_MODE_T);
41
42 va_end (ap);
43 }
44
45 return fd_safer (open (file, flags, mode));
46}
diff --git a/gl/open.c b/gl/open.c
deleted file mode 100644
index f612b80..0000000
--- a/gl/open.c
+++ /dev/null
@@ -1,166 +0,0 @@
1/* Open a descriptor to a file.
2 Copyright (C) 2007-2010 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#include <unistd.h>
42
43#ifndef REPLACE_OPEN_DIRECTORY
44# define REPLACE_OPEN_DIRECTORY 0
45#endif
46
47int
48open (const char *filename, int flags, ...)
49{
50 mode_t mode;
51 int fd;
52
53 mode = 0;
54 if (flags & O_CREAT)
55 {
56 va_list arg;
57 va_start (arg, flags);
58
59 /* We have to use PROMOTED_MODE_T instead of mode_t, otherwise GCC 4
60 creates crashing code when 'mode_t' is smaller than 'int'. */
61 mode = va_arg (arg, PROMOTED_MODE_T);
62
63 va_end (arg);
64 }
65
66#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
67 if (strcmp (filename, "/dev/null") == 0)
68 filename = "NUL";
69#endif
70
71#if OPEN_TRAILING_SLASH_BUG
72 /* If the filename ends in a slash and one of O_CREAT, O_WRONLY, O_RDWR
73 is specified, then fail.
74 Rationale: POSIX <http://www.opengroup.org/susv3/basedefs/xbd_chap04.html>
75 says that
76 "A pathname that contains at least one non-slash character and that
77 ends with one or more trailing slashes shall be resolved as if a
78 single dot character ( '.' ) were appended to the pathname."
79 and
80 "The special filename dot shall refer to the directory specified by
81 its predecessor."
82 If the named file already exists as a directory, then
83 - if O_CREAT is specified, open() must fail because of the semantics
84 of O_CREAT,
85 - if O_WRONLY or O_RDWR is specified, open() must fail because POSIX
86 <http://www.opengroup.org/susv3/functions/open.html> says that it
87 fails with errno = EISDIR in this case.
88 If the named file does not exist or does not name a directory, then
89 - if O_CREAT is specified, open() must fail since open() cannot create
90 directories,
91 - if O_WRONLY or O_RDWR is specified, open() must fail because the
92 file does not contain a '.' directory. */
93 if (flags & (O_CREAT | O_WRONLY | O_RDWR))
94 {
95 size_t len = strlen (filename);
96 if (len > 0 && filename[len - 1] == '/')
97 {
98 errno = EISDIR;
99 return -1;
100 }
101 }
102#endif
103
104 fd = orig_open (filename, flags, mode);
105
106#if REPLACE_FCHDIR
107 /* Implementing fchdir and fdopendir requires the ability to open a
108 directory file descriptor. If open doesn't support that (as on
109 mingw), we use a dummy file that behaves the same as directories
110 on Linux (ie. always reports EOF on attempts to read()), and
111 override fstat() in fchdir.c to hide the fact that we have a
112 dummy. */
113 if (REPLACE_OPEN_DIRECTORY && fd < 0 && errno == EACCES
114 && (flags & O_ACCMODE) == O_RDONLY)
115 {
116 struct stat statbuf;
117 if (stat (filename, &statbuf) == 0 && S_ISDIR (statbuf.st_mode))
118 {
119 /* Maximum recursion depth of 1. */
120 fd = open ("/dev/null", flags, mode);
121 if (0 <= fd)
122 fd = _gl_register_fd (fd, filename);
123 }
124 else
125 errno = EACCES;
126 }
127#endif
128
129#if OPEN_TRAILING_SLASH_BUG
130 /* If the filename ends in a slash and fd does not refer to a directory,
131 then fail.
132 Rationale: POSIX <http://www.opengroup.org/susv3/basedefs/xbd_chap04.html>
133 says that
134 "A pathname that contains at least one non-slash character and that
135 ends with one or more trailing slashes shall be resolved as if a
136 single dot character ( '.' ) were appended to the pathname."
137 and
138 "The special filename dot shall refer to the directory specified by
139 its predecessor."
140 If the named file without the slash is not a directory, open() must fail
141 with ENOTDIR. */
142 if (fd >= 0)
143 {
144 /* We know len is positive, since open did not fail with ENOENT. */
145 size_t len = strlen (filename);
146 if (filename[len - 1] == '/')
147 {
148 struct stat statbuf;
149
150 if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode))
151 {
152 close (fd);
153 errno = ENOTDIR;
154 return -1;
155 }
156 }
157 }
158#endif
159
160#if REPLACE_FCHDIR
161 if (!REPLACE_OPEN_DIRECTORY && 0 <= fd)
162 fd = _gl_register_fd (fd, filename);
163#endif
164
165 return fd;
166}
diff --git a/gl/pipe-safer.c b/gl/pipe-safer.c
deleted file mode 100644
index ae9f2e3..0000000
--- a/gl/pipe-safer.c
+++ /dev/null
@@ -1,56 +0,0 @@
1/* Invoke pipe, but avoid some glitches.
2 Copyright (C) 2005-2006, 2009-2010 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 Jim Meyering. */
18
19#include <config.h>
20
21#include "unistd-safer.h"
22
23#include <unistd.h>
24#include <errno.h>
25
26/* Like pipe, but ensure that neither of the file descriptors is
27 STDIN_FILENO, STDOUT_FILENO, or STDERR_FILENO. Fail with ENOSYS on
28 platforms that lack pipe. */
29
30int
31pipe_safer (int fd[2])
32{
33#if HAVE_PIPE
34 if (pipe (fd) == 0)
35 {
36 int i;
37 for (i = 0; i < 2; i++)
38 {
39 fd[i] = fd_safer (fd[i]);
40 if (fd[i] < 0)
41 {
42 int e = errno;
43 close (fd[1 - i]);
44 errno = e;
45 return -1;
46 }
47 }
48
49 return 0;
50 }
51#else
52 errno = ENOSYS;
53#endif
54
55 return -1;
56}
diff --git a/gl/printf-args.c b/gl/printf-args.c
index 46c03a2..c27e6bc 100644
--- a/gl/printf-args.c
+++ b/gl/printf-args.c
@@ -1,5 +1,5 @@
1/* Decomposed printf argument list. 1/* Decomposed printf argument list.
2 Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2010 Free Software 2 Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2013 Free Software
3 Foundation, Inc. 3 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
@@ -13,8 +13,7 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License along 15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, 16 with this program; if not, see <http://www.gnu.org/licenses/>. */
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 17
19/* This file can be parametrized with the following macros: 18/* This file can be parametrized with the following macros:
20 ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions. 19 ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions.
diff --git a/gl/printf-args.h b/gl/printf-args.h
index 2536eba..2a9c2a3 100644
--- a/gl/printf-args.h
+++ b/gl/printf-args.h
@@ -1,5 +1,5 @@
1/* Decomposed printf argument list. 1/* Decomposed printf argument list.
2 Copyright (C) 1999, 2002-2003, 2006-2007, 2009-2010 Free Software 2 Copyright (C) 1999, 2002-2003, 2006-2007, 2011-2013 Free Software
3 Foundation, Inc. 3 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
@@ -13,8 +13,7 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License along 15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, 16 with this program; if not, see <http://www.gnu.org/licenses/>. */
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 17
19#ifndef _PRINTF_ARGS_H 18#ifndef _PRINTF_ARGS_H
20#define _PRINTF_ARGS_H 19#define _PRINTF_ARGS_H
@@ -136,10 +135,14 @@ typedef struct
136} 135}
137argument; 136argument;
138 137
138/* Number of directly allocated arguments (no malloc() needed). */
139#define N_DIRECT_ALLOC_ARGUMENTS 7
140
139typedef struct 141typedef struct
140{ 142{
141 size_t count; 143 size_t count;
142 argument *arg; 144 argument *arg;
145 argument direct_alloc_arg[N_DIRECT_ALLOC_ARGUMENTS];
143} 146}
144arguments; 147arguments;
145 148
diff --git a/gl/printf-parse.c b/gl/printf-parse.c
index f612beb..23cacc1 100644
--- a/gl/printf-parse.c
+++ b/gl/printf-parse.c
@@ -1,5 +1,5 @@
1/* Formatted output to strings. 1/* Formatted output to strings.
2 Copyright (C) 1999-2000, 2002-2003, 2006-2010 Free Software Foundation, Inc. 2 Copyright (C) 1999-2000, 2002-2003, 2006-2013 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
@@ -12,8 +12,7 @@
12 GNU General Public License for more details. 12 GNU General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License along 14 You should have received a copy of the GNU General Public License along
15 with this program; if not, write to the Free Software Foundation, 15 with this program; if not, see <http://www.gnu.org/licenses/>. */
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
17 16
18/* This file can be parametrized with the following macros: 17/* This file can be parametrized with the following macros:
19 CHAR_T The element type of the format string. 18 CHAR_T The element type of the format string.
@@ -63,6 +62,9 @@
63/* malloc(), realloc(), free(). */ 62/* malloc(), realloc(), free(). */
64#include <stdlib.h> 63#include <stdlib.h>
65 64
65/* memcpy(). */
66#include <string.h>
67
66/* errno. */ 68/* errno. */
67#include <errno.h> 69#include <errno.h>
68 70
@@ -80,23 +82,20 @@ STATIC
80int 82int
81PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a) 83PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
82{ 84{
83 const CHAR_T *cp = format; /* pointer into format */ 85 const CHAR_T *cp = format; /* pointer into format */
84 size_t arg_posn = 0; /* number of regular arguments consumed */ 86 size_t arg_posn = 0; /* number of regular arguments consumed */
85 size_t d_allocated; /* allocated elements of d->dir */ 87 size_t d_allocated; /* allocated elements of d->dir */
86 size_t a_allocated; /* allocated elements of a->arg */ 88 size_t a_allocated; /* allocated elements of a->arg */
87 size_t max_width_length = 0; 89 size_t max_width_length = 0;
88 size_t max_precision_length = 0; 90 size_t max_precision_length = 0;
89 91
90 d->count = 0; 92 d->count = 0;
91 d_allocated = 1; 93 d_allocated = N_DIRECT_ALLOC_DIRECTIVES;
92 d->dir = (DIRECTIVE *) malloc (d_allocated * sizeof (DIRECTIVE)); 94 d->dir = d->direct_alloc_dir;
93 if (d->dir == NULL)
94 /* Out of memory. */
95 goto out_of_memory_1;
96 95
97 a->count = 0; 96 a->count = 0;
98 a_allocated = 0; 97 a_allocated = N_DIRECT_ALLOC_ARGUMENTS;
99 a->arg = NULL; 98 a->arg = a->direct_alloc_arg;
100 99
101#define REGISTER_ARG(_index_,_type_) \ 100#define REGISTER_ARG(_index_,_type_) \
102 { \ 101 { \
@@ -113,12 +112,14 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
113 if (size_overflow_p (memory_size)) \ 112 if (size_overflow_p (memory_size)) \
114 /* Overflow, would lead to out of memory. */ \ 113 /* Overflow, would lead to out of memory. */ \
115 goto out_of_memory; \ 114 goto out_of_memory; \
116 memory = (argument *) (a->arg \ 115 memory = (argument *) (a->arg != a->direct_alloc_arg \
117 ? realloc (a->arg, memory_size) \ 116 ? realloc (a->arg, memory_size) \
118 : malloc (memory_size)); \ 117 : malloc (memory_size)); \
119 if (memory == NULL) \ 118 if (memory == NULL) \
120 /* Out of memory. */ \ 119 /* Out of memory. */ \
121 goto out_of_memory; \ 120 goto out_of_memory; \
121 if (a->arg == a->direct_alloc_arg) \
122 memcpy (memory, a->arg, a->count * sizeof (argument)); \
122 a->arg = memory; \ 123 a->arg = memory; \
123 } \ 124 } \
124 while (a->count <= n) \ 125 while (a->count <= n) \
@@ -206,6 +207,13 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
206 dp->flags |= FLAG_ZERO; 207 dp->flags |= FLAG_ZERO;
207 cp++; 208 cp++;
208 } 209 }
210#if __GLIBC__ >= 2 && !defined __UCLIBC__
211 else if (*cp == 'I')
212 {
213 dp->flags |= FLAG_LOCALIZED;
214 cp++;
215 }
216#endif
209 else 217 else
210 break; 218 break;
211 } 219 }
@@ -393,7 +401,7 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
393 cp++; 401 cp++;
394 } 402 }
395#if defined __APPLE__ && defined __MACH__ 403#if defined __APPLE__ && defined __MACH__
396 /* On MacOS X 10.3, PRIdMAX is defined as "qd". 404 /* On Mac OS X 10.3, PRIdMAX is defined as "qd".
397 We cannot change it to "lld" because PRIdMAX must also 405 We cannot change it to "lld" because PRIdMAX must also
398 be understood by the system's printf routines. */ 406 be understood by the system's printf routines. */
399 else if (*cp == 'q') 407 else if (*cp == 'q')
@@ -412,7 +420,7 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
412 } 420 }
413#endif 421#endif
414#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 422#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
415 /* On native Win32, PRIdMAX is defined as "I64d". 423 /* On native Windows, PRIdMAX is defined as "I64d".
416 We cannot change it to "lld" because PRIdMAX must also 424 We cannot change it to "lld" because PRIdMAX must also
417 be understood by the system's printf routines. */ 425 be understood by the system's printf routines. */
418 else if (*cp == 'I' && cp[1] == '6' && cp[2] == '4') 426 else if (*cp == 'I' && cp[1] == '6' && cp[2] == '4')
@@ -581,10 +589,14 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
581 if (size_overflow_p (memory_size)) 589 if (size_overflow_p (memory_size))
582 /* Overflow, would lead to out of memory. */ 590 /* Overflow, would lead to out of memory. */
583 goto out_of_memory; 591 goto out_of_memory;
584 memory = (DIRECTIVE *) realloc (d->dir, memory_size); 592 memory = (DIRECTIVE *) (d->dir != d->direct_alloc_dir
593 ? realloc (d->dir, memory_size)
594 : malloc (memory_size));
585 if (memory == NULL) 595 if (memory == NULL)
586 /* Out of memory. */ 596 /* Out of memory. */
587 goto out_of_memory; 597 goto out_of_memory;
598 if (d->dir == d->direct_alloc_dir)
599 memcpy (memory, d->dir, d->count * sizeof (DIRECTIVE));
588 d->dir = memory; 600 d->dir = memory;
589 } 601 }
590 } 602 }
@@ -603,19 +615,18 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
603 return 0; 615 return 0;
604 616
605error: 617error:
606 if (a->arg) 618 if (a->arg != a->direct_alloc_arg)
607 free (a->arg); 619 free (a->arg);
608 if (d->dir) 620 if (d->dir != d->direct_alloc_dir)
609 free (d->dir); 621 free (d->dir);
610 errno = EINVAL; 622 errno = EINVAL;
611 return -1; 623 return -1;
612 624
613out_of_memory: 625out_of_memory:
614 if (a->arg) 626 if (a->arg != a->direct_alloc_arg)
615 free (a->arg); 627 free (a->arg);
616 if (d->dir) 628 if (d->dir != d->direct_alloc_dir)
617 free (d->dir); 629 free (d->dir);
618out_of_memory_1:
619 errno = ENOMEM; 630 errno = ENOMEM;
620 return -1; 631 return -1;
621} 632}
diff --git a/gl/printf-parse.h b/gl/printf-parse.h
index 0f2b708..d8474be 100644
--- a/gl/printf-parse.h
+++ b/gl/printf-parse.h
@@ -1,5 +1,5 @@
1/* Parse printf format string. 1/* Parse printf format string.
2 Copyright (C) 1999, 2002-2003, 2005, 2007, 2009-2010 Free Software 2 Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2013 Free Software
3 Foundation, Inc. 3 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
@@ -13,8 +13,7 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License along 15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, 16 with this program; if not, see <http://www.gnu.org/licenses/>. */
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 17
19#ifndef _PRINTF_PARSE_H 18#ifndef _PRINTF_PARSE_H
20#define _PRINTF_PARSE_H 19#define _PRINTF_PARSE_H
@@ -23,6 +22,10 @@
23 ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions. 22 ENABLE_UNISTDIO Set to 1 to enable the unistdio extensions.
24 STATIC Set to 'static' to declare the function static. */ 23 STATIC Set to 'static' to declare the function static. */
25 24
25#if HAVE_FEATURES_H
26# include <features.h> /* for __GLIBC__, __UCLIBC__ */
27#endif
28
26#include "printf-args.h" 29#include "printf-args.h"
27 30
28 31
@@ -33,6 +36,9 @@
33#define FLAG_SPACE 8 /* space flag */ 36#define FLAG_SPACE 8 /* space flag */
34#define FLAG_ALT 16 /* # flag */ 37#define FLAG_ALT 16 /* # flag */
35#define FLAG_ZERO 32 38#define FLAG_ZERO 32
39#if __GLIBC__ >= 2 && !defined __UCLIBC__
40# define FLAG_LOCALIZED 64 /* I flag, uses localized digits */
41#endif
36 42
37/* arg_index value indicating that no argument is consumed. */ 43/* arg_index value indicating that no argument is consumed. */
38#define ARG_NONE (~(size_t)0) 44#define ARG_NONE (~(size_t)0)
@@ -40,6 +46,9 @@
40/* xxx_directive: A parsed directive. 46/* xxx_directive: A parsed directive.
41 xxx_directives: A parsed format string. */ 47 xxx_directives: A parsed format string. */
42 48
49/* Number of directly allocated directives (no malloc() needed). */
50#define N_DIRECT_ALLOC_DIRECTIVES 7
51
43/* A parsed directive. */ 52/* A parsed directive. */
44typedef struct 53typedef struct
45{ 54{
@@ -64,6 +73,7 @@ typedef struct
64 char_directive *dir; 73 char_directive *dir;
65 size_t max_width_length; 74 size_t max_width_length;
66 size_t max_precision_length; 75 size_t max_precision_length;
76 char_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES];
67} 77}
68char_directives; 78char_directives;
69 79
@@ -93,6 +103,7 @@ typedef struct
93 u8_directive *dir; 103 u8_directive *dir;
94 size_t max_width_length; 104 size_t max_width_length;
95 size_t max_precision_length; 105 size_t max_precision_length;
106 u8_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES];
96} 107}
97u8_directives; 108u8_directives;
98 109
@@ -120,6 +131,7 @@ typedef struct
120 u16_directive *dir; 131 u16_directive *dir;
121 size_t max_width_length; 132 size_t max_width_length;
122 size_t max_precision_length; 133 size_t max_precision_length;
134 u16_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES];
123} 135}
124u16_directives; 136u16_directives;
125 137
@@ -147,6 +159,7 @@ typedef struct
147 u32_directive *dir; 159 u32_directive *dir;
148 size_t max_width_length; 160 size_t max_width_length;
149 size_t max_precision_length; 161 size_t max_precision_length;
162 u32_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES];
150} 163}
151u32_directives; 164u32_directives;
152 165
diff --git a/gl/read.c b/gl/read.c
new file mode 100644
index 0000000..0fe0306
--- /dev/null
+++ b/gl/read.c
@@ -0,0 +1,85 @@
1/* POSIX compatible read() function.
2 Copyright (C) 2008-2013 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2011.
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#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
24
25# include <errno.h>
26# include <io.h>
27
28# define WIN32_LEAN_AND_MEAN /* avoid including junk */
29# include <windows.h>
30
31# include "msvc-inval.h"
32# include "msvc-nothrow.h"
33
34# undef read
35
36# if HAVE_MSVC_INVALID_PARAMETER_HANDLER
37static ssize_t
38read_nothrow (int fd, void *buf, size_t count)
39{
40 ssize_t result;
41
42 TRY_MSVC_INVAL
43 {
44 result = read (fd, buf, count);
45 }
46 CATCH_MSVC_INVAL
47 {
48 result = -1;
49 errno = EBADF;
50 }
51 DONE_MSVC_INVAL;
52
53 return result;
54}
55# else
56# define read_nothrow read
57# endif
58
59ssize_t
60rpl_read (int fd, void *buf, size_t count)
61{
62 ssize_t ret = read_nothrow (fd, buf, count);
63
64# if GNULIB_NONBLOCKING
65 if (ret < 0
66 && GetLastError () == ERROR_NO_DATA)
67 {
68 HANDLE h = (HANDLE) _get_osfhandle (fd);
69 if (GetFileType (h) == FILE_TYPE_PIPE)
70 {
71 /* h is a pipe or socket. */
72 DWORD state;
73 if (GetNamedPipeHandleState (h, &state, NULL, NULL, NULL, NULL, 0)
74 && (state & PIPE_NOWAIT) != 0)
75 /* h is a pipe in non-blocking mode.
76 Change errno from EINVAL to EAGAIN. */
77 errno = EAGAIN;
78 }
79 }
80# endif
81
82 return ret;
83}
84
85#endif
diff --git a/gl/ref-add.sin b/gl/ref-add.sin
index dbb61df..112bcdc64 100644
--- a/gl/ref-add.sin
+++ b/gl/ref-add.sin
@@ -1,6 +1,6 @@
1# Add this package to a list of references stored in a text file. 1# Add this package to a list of references stored in a text file.
2# 2#
3# Copyright (C) 2000, 2009, 2010 Free Software Foundation, Inc. 3# Copyright (C) 2000, 2009-2013 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
@@ -13,8 +13,7 @@
13# GNU General Public License for more details. 13# GNU General Public License for more details.
14# 14#
15# You should have received a copy of the GNU General Public License along 15# You should have received a copy of the GNU General Public License along
16# with this program; if not, write to the Free Software Foundation, 16# with this program; if not, see <http://www.gnu.org/licenses/>.
17# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18# 17#
19# Written by Bruno Haible <haible@clisp.cons.org>. 18# Written by Bruno Haible <haible@clisp.cons.org>.
20# 19#
diff --git a/gl/ref-del.sin b/gl/ref-del.sin
index 4c31a6e..6f73868 100644
--- a/gl/ref-del.sin
+++ b/gl/ref-del.sin
@@ -1,6 +1,6 @@
1# Remove this package from a list of references stored in a text file. 1# Remove this package from a list of references stored in a text file.
2# 2#
3# Copyright (C) 2000, 2009, 2010 Free Software Foundation, Inc. 3# Copyright (C) 2000, 2009-2013 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
@@ -13,8 +13,7 @@
13# GNU General Public License for more details. 13# GNU General Public License for more details.
14# 14#
15# You should have received a copy of the GNU General Public License along 15# You should have received a copy of the GNU General Public License along
16# with this program; if not, write to the Free Software Foundation, 16# with this program; if not, see <http://www.gnu.org/licenses/>.
17# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18# 17#
19# Written by Bruno Haible <haible@clisp.cons.org>. 18# Written by Bruno Haible <haible@clisp.cons.org>.
20# 19#
diff --git a/gl/regcomp.c b/gl/regcomp.c
index 86ca02b..f0b2e52 100644
--- a/gl/regcomp.c
+++ b/gl/regcomp.c
@@ -1,22 +1,21 @@
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, 2008, 2009, 2010 Free 2 Copyright (C) 2002-2013 Free Software Foundation, Inc.
3 Software Foundation, Inc.
4 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
5 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>. 4 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
6 5
7 This program is free software; you can redistribute it and/or modify 6 The GNU C Library is free software; you can redistribute it and/or
8 it under the terms of the GNU General Public License as published by 7 modify it under the terms of the GNU General Public
9 the Free Software Foundation; either version 3, or (at your option) 8 License as published by the Free Software Foundation; either
10 any later version. 9 version 3 of the License, or (at your option) any later version.
11 10
12 This program is distributed in the hope that it will be useful, 11 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 GNU General Public License for more details. 14 General Public License for more details.
16 15
17 You should have received a copy of the GNU General Public License along 16 You should have received a copy of the GNU General Public
18 with this program; if not, write to the Free Software Foundation, 17 License along with the GNU C Library; if not, see
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ 18 <http://www.gnu.org/licenses/>. */
20 19
21static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern, 20static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern,
22 size_t length, reg_syntax_t syntax); 21 size_t length, reg_syntax_t syntax);
@@ -95,20 +94,20 @@ static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans,
95 bitset_t sbcset, 94 bitset_t sbcset,
96 re_charset_t *mbcset, 95 re_charset_t *mbcset,
97 Idx *char_class_alloc, 96 Idx *char_class_alloc,
98 const unsigned char *class_name, 97 const char *class_name,
99 reg_syntax_t syntax); 98 reg_syntax_t syntax);
100#else /* not RE_ENABLE_I18N */ 99#else /* not RE_ENABLE_I18N */
101static reg_errcode_t build_equiv_class (bitset_t sbcset, 100static reg_errcode_t build_equiv_class (bitset_t sbcset,
102 const unsigned char *name); 101 const unsigned char *name);
103static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans, 102static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans,
104 bitset_t sbcset, 103 bitset_t sbcset,
105 const unsigned char *class_name, 104 const char *class_name,
106 reg_syntax_t syntax); 105 reg_syntax_t syntax);
107#endif /* not RE_ENABLE_I18N */ 106#endif /* not RE_ENABLE_I18N */
108static bin_tree_t *build_charclass_op (re_dfa_t *dfa, 107static bin_tree_t *build_charclass_op (re_dfa_t *dfa,
109 RE_TRANSLATE_TYPE trans, 108 RE_TRANSLATE_TYPE trans,
110 const unsigned char *class_name, 109 const char *class_name,
111 const unsigned char *extra, 110 const char *extra,
112 bool non_match, reg_errcode_t *err); 111 bool non_match, reg_errcode_t *err);
113static bin_tree_t *create_tree (re_dfa_t *dfa, 112static bin_tree_t *create_tree (re_dfa_t *dfa,
114 bin_tree_t *left, bin_tree_t *right, 113 bin_tree_t *left, bin_tree_t *right,
@@ -207,7 +206,7 @@ static const size_t __re_error_msgid_idx[] =
207 compiles PATTERN (of length LENGTH) and puts the result in BUFP. 206 compiles PATTERN (of length LENGTH) and puts the result in BUFP.
208 Returns 0 if the pattern was valid, otherwise an error string. 207 Returns 0 if the pattern was valid, otherwise an error string.
209 208
210 Assumes the `allocated' (and perhaps `buffer') and `translate' fields 209 Assumes the 'allocated' (and perhaps 'buffer') and 'translate' fields
211 are set in BUFP on entry. */ 210 are set in BUFP on entry. */
212 211
213#ifdef _LIBC 212#ifdef _LIBC
@@ -242,7 +241,7 @@ re_compile_pattern (const char *pattern, size_t length,
242weak_alias (__re_compile_pattern, re_compile_pattern) 241weak_alias (__re_compile_pattern, re_compile_pattern)
243#endif 242#endif
244 243
245/* Set by `re_set_syntax' to the current regexp syntax to recognize. Can 244/* Set by 're_set_syntax' to the current regexp syntax to recognize. Can
246 also be assigned to arbitrarily: each pattern buffer stores its own 245 also be assigned to arbitrarily: each pattern buffer stores its own
247 syntax, so it can be changed between regex compilations. */ 246 syntax, so it can be changed between regex compilations. */
248/* This has no initializer because initialized variables in Emacs 247/* This has no initializer because initialized variables in Emacs
@@ -274,7 +273,7 @@ int
274re_compile_fastmap (bufp) 273re_compile_fastmap (bufp)
275 struct re_pattern_buffer *bufp; 274 struct re_pattern_buffer *bufp;
276{ 275{
277 re_dfa_t *dfa = (re_dfa_t *) bufp->buffer; 276 re_dfa_t *dfa = bufp->buffer;
278 char *fastmap = bufp->fastmap; 277 char *fastmap = bufp->fastmap;
279 278
280 memset (fastmap, '\0', sizeof (char) * SBC_MAX); 279 memset (fastmap, '\0', sizeof (char) * SBC_MAX);
@@ -293,7 +292,7 @@ weak_alias (__re_compile_fastmap, re_compile_fastmap)
293#endif 292#endif
294 293
295static inline void 294static inline void
296__attribute ((always_inline)) 295__attribute__ ((always_inline))
297re_set_fastmap (char *fastmap, bool icase, int ch) 296re_set_fastmap (char *fastmap, bool icase, int ch)
298{ 297{
299 fastmap[ch] = 1; 298 fastmap[ch] = 1;
@@ -308,7 +307,7 @@ static void
308re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state, 307re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
309 char *fastmap) 308 char *fastmap)
310{ 309{
311 re_dfa_t *dfa = (re_dfa_t *) bufp->buffer; 310 re_dfa_t *dfa = bufp->buffer;
312 Idx node_cnt; 311 Idx node_cnt;
313 bool icase = (dfa->mb_cur_max == 1 && (bufp->syntax & RE_ICASE)); 312 bool icase = (dfa->mb_cur_max == 1 && (bufp->syntax & RE_ICASE));
314 for (node_cnt = 0; node_cnt < init_state->nodes.nelem; ++node_cnt) 313 for (node_cnt = 0; node_cnt < init_state->nodes.nelem; ++node_cnt)
@@ -440,15 +439,15 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state,
440 PREG is a regex_t *. We do not expect any fields to be initialized, 439 PREG is a regex_t *. We do not expect any fields to be initialized,
441 since POSIX says we shouldn't. Thus, we set 440 since POSIX says we shouldn't. Thus, we set
442 441
443 `buffer' to the compiled pattern; 442 'buffer' to the compiled pattern;
444 `used' to the length of the compiled pattern; 443 'used' to the length of the compiled pattern;
445 `syntax' to RE_SYNTAX_POSIX_EXTENDED if the 444 'syntax' to RE_SYNTAX_POSIX_EXTENDED if the
446 REG_EXTENDED bit in CFLAGS is set; otherwise, to 445 REG_EXTENDED bit in CFLAGS is set; otherwise, to
447 RE_SYNTAX_POSIX_BASIC; 446 RE_SYNTAX_POSIX_BASIC;
448 `newline_anchor' to REG_NEWLINE being set in CFLAGS; 447 'newline_anchor' to REG_NEWLINE being set in CFLAGS;
449 `fastmap' to an allocated space for the fastmap; 448 'fastmap' to an allocated space for the fastmap;
450 `fastmap_accurate' to zero; 449 'fastmap_accurate' to zero;
451 `re_nsub' to the number of subexpressions in PATTERN. 450 're_nsub' to the number of subexpressions in PATTERN.
452 451
453 PATTERN is the address of the pattern string. 452 PATTERN is the address of the pattern string.
454 453
@@ -587,19 +586,23 @@ weak_alias (__regerror, regerror)
587static const bitset_t utf8_sb_map = 586static const bitset_t utf8_sb_map =
588{ 587{
589 /* Set the first 128 bits. */ 588 /* Set the first 128 bits. */
590# if 4 * BITSET_WORD_BITS < ASCII_CHARS 589# if defined __GNUC__ && !defined __STRICT_ANSI__
591# error "bitset_word_t is narrower than 32 bits" 590 [0 ... 0x80 / BITSET_WORD_BITS - 1] = BITSET_WORD_MAX
592# elif 3 * BITSET_WORD_BITS < ASCII_CHARS 591# else
592# if 4 * BITSET_WORD_BITS < ASCII_CHARS
593# error "bitset_word_t is narrower than 32 bits"
594# elif 3 * BITSET_WORD_BITS < ASCII_CHARS
593 BITSET_WORD_MAX, BITSET_WORD_MAX, BITSET_WORD_MAX, 595 BITSET_WORD_MAX, BITSET_WORD_MAX, BITSET_WORD_MAX,
594# elif 2 * BITSET_WORD_BITS < ASCII_CHARS 596# elif 2 * BITSET_WORD_BITS < ASCII_CHARS
595 BITSET_WORD_MAX, BITSET_WORD_MAX, 597 BITSET_WORD_MAX, BITSET_WORD_MAX,
596# elif 1 * BITSET_WORD_BITS < ASCII_CHARS 598# elif 1 * BITSET_WORD_BITS < ASCII_CHARS
597 BITSET_WORD_MAX, 599 BITSET_WORD_MAX,
598# endif 600# endif
599 (BITSET_WORD_MAX 601 (BITSET_WORD_MAX
600 >> (SBC_MAX % BITSET_WORD_BITS == 0 602 >> (SBC_MAX % BITSET_WORD_BITS == 0
601 ? 0 603 ? 0
602 : BITSET_WORD_BITS - SBC_MAX % BITSET_WORD_BITS)) 604 : BITSET_WORD_BITS - SBC_MAX % BITSET_WORD_BITS))
605# endif
603}; 606};
604#endif 607#endif
605 608
@@ -658,9 +661,12 @@ void
658regfree (preg) 661regfree (preg)
659 regex_t *preg; 662 regex_t *preg;
660{ 663{
661 re_dfa_t *dfa = (re_dfa_t *) preg->buffer; 664 re_dfa_t *dfa = preg->buffer;
662 if (BE (dfa != NULL, 1)) 665 if (BE (dfa != NULL, 1))
663 free_dfa_content (dfa); 666 {
667 lock_fini (dfa->lock);
668 free_dfa_content (dfa);
669 }
664 preg->buffer = NULL; 670 preg->buffer = NULL;
665 preg->allocated = 0; 671 preg->allocated = 0;
666 672
@@ -719,7 +725,7 @@ re_comp (s)
719 + __re_error_msgid_idx[(int) REG_ESPACE]); 725 + __re_error_msgid_idx[(int) REG_ESPACE]);
720 } 726 }
721 727
722 /* Since `re_exec' always passes NULL for the `regs' argument, we 728 /* Since 're_exec' always passes NULL for the 'regs' argument, we
723 don't need to initialize the pattern buffer fields which affect it. */ 729 don't need to initialize the pattern buffer fields which affect it. */
724 730
725 /* Match anchors at newlines. */ 731 /* Match anchors at newlines. */
@@ -730,7 +736,7 @@ re_comp (s)
730 if (!ret) 736 if (!ret)
731 return NULL; 737 return NULL;
732 738
733 /* Yes, we're discarding `const' here if !HAVE_LIBINTL. */ 739 /* Yes, we're discarding 'const' here if !HAVE_LIBINTL. */
734 return (char *) gettext (__re_error_msgid + __re_error_msgid_idx[(int) ret]); 740 return (char *) gettext (__re_error_msgid + __re_error_msgid_idx[(int) ret]);
735} 741}
736 742
@@ -765,7 +771,7 @@ re_compile_internal (regex_t *preg, const char * pattern, size_t length,
765 preg->regs_allocated = REGS_UNALLOCATED; 771 preg->regs_allocated = REGS_UNALLOCATED;
766 772
767 /* Initialize the dfa. */ 773 /* Initialize the dfa. */
768 dfa = (re_dfa_t *) preg->buffer; 774 dfa = preg->buffer;
769 if (BE (preg->allocated < sizeof (re_dfa_t), 0)) 775 if (BE (preg->allocated < sizeof (re_dfa_t), 0))
770 { 776 {
771 /* If zero allocated, but buffer is non-null, try to realloc 777 /* If zero allocated, but buffer is non-null, try to realloc
@@ -776,11 +782,13 @@ re_compile_internal (regex_t *preg, const char * pattern, size_t length,
776 if (dfa == NULL) 782 if (dfa == NULL)
777 return REG_ESPACE; 783 return REG_ESPACE;
778 preg->allocated = sizeof (re_dfa_t); 784 preg->allocated = sizeof (re_dfa_t);
779 preg->buffer = (unsigned char *) dfa; 785 preg->buffer = dfa;
780 } 786 }
781 preg->used = sizeof (re_dfa_t); 787 preg->used = sizeof (re_dfa_t);
782 788
783 err = init_dfa (dfa, length); 789 err = init_dfa (dfa, length);
790 if (BE (err == REG_NOERROR && lock_init (dfa->lock) != 0, 0))
791 err = REG_ESPACE;
784 if (BE (err != REG_NOERROR, 0)) 792 if (BE (err != REG_NOERROR, 0))
785 { 793 {
786 free_dfa_content (dfa); 794 free_dfa_content (dfa);
@@ -794,8 +802,6 @@ re_compile_internal (regex_t *preg, const char * pattern, size_t length,
794 strncpy (dfa->re_str, pattern, length + 1); 802 strncpy (dfa->re_str, pattern, length + 1);
795#endif 803#endif
796 804
797 __libc_lock_init (dfa->lock);
798
799 err = re_string_construct (&regexp, pattern, length, preg->translate, 805 err = re_string_construct (&regexp, pattern, length, preg->translate,
800 (syntax & RE_ICASE) != 0, dfa); 806 (syntax & RE_ICASE) != 0, dfa);
801 if (BE (err != REG_NOERROR, 0)) 807 if (BE (err != REG_NOERROR, 0))
@@ -803,6 +809,7 @@ re_compile_internal (regex_t *preg, const char * pattern, size_t length,
803 re_compile_internal_free_return: 809 re_compile_internal_free_return:
804 free_workarea_compile (preg); 810 free_workarea_compile (preg);
805 re_string_destruct (&regexp); 811 re_string_destruct (&regexp);
812 lock_fini (dfa->lock);
806 free_dfa_content (dfa); 813 free_dfa_content (dfa);
807 preg->buffer = NULL; 814 preg->buffer = NULL;
808 preg->allocated = 0; 815 preg->allocated = 0;
@@ -835,6 +842,7 @@ re_compile_internal (regex_t *preg, const char * pattern, size_t length,
835 842
836 if (BE (err != REG_NOERROR, 0)) 843 if (BE (err != REG_NOERROR, 0))
837 { 844 {
845 lock_fini (dfa->lock);
838 free_dfa_content (dfa); 846 free_dfa_content (dfa);
839 preg->buffer = NULL; 847 preg->buffer = NULL;
840 preg->allocated = 0; 848 preg->allocated = 0;
@@ -851,7 +859,7 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
851{ 859{
852 __re_size_t table_size; 860 __re_size_t table_size;
853#ifndef _LIBC 861#ifndef _LIBC
854 char *codeset_name; 862 const char *codeset_name;
855#endif 863#endif
856#ifdef RE_ENABLE_I18N 864#ifdef RE_ENABLE_I18N
857 size_t max_i18n_object_size = MAX (sizeof (wchar_t), sizeof (wctype_t)); 865 size_t max_i18n_object_size = MAX (sizeof (wchar_t), sizeof (wctype_t));
@@ -874,7 +882,7 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
874 calculation below, and for similar doubling calculations 882 calculation below, and for similar doubling calculations
875 elsewhere. And it's <= rather than <, because some of the 883 elsewhere. And it's <= rather than <, because some of the
876 doubling calculations add 1 afterwards. */ 884 doubling calculations add 1 afterwards. */
877 if (BE (SIZE_MAX / max_object_size / 2 <= pat_len, 0)) 885 if (BE (MIN (IDX_MAX, SIZE_MAX / max_object_size) / 2 <= pat_len, 0))
878 return REG_ESPACE; 886 return REG_ESPACE;
879 887
880 dfa->nodes_alloc = pat_len + 1; 888 dfa->nodes_alloc = pat_len + 1;
@@ -897,8 +905,10 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
897 != 0); 905 != 0);
898#else 906#else
899 codeset_name = nl_langinfo (CODESET); 907 codeset_name = nl_langinfo (CODESET);
900 if (strcasecmp (codeset_name, "UTF-8") == 0 908 if ((codeset_name[0] == 'U' || codeset_name[0] == 'u')
901 || strcasecmp (codeset_name, "UTF8") == 0) 909 && (codeset_name[1] == 'T' || codeset_name[1] == 't')
910 && (codeset_name[2] == 'F' || codeset_name[2] == 'f')
911 && strcmp (codeset_name + 3 + (codeset_name[3] == '-'), "8") == 0)
902 dfa->is_utf8 = 1; 912 dfa->is_utf8 = 1;
903 913
904 /* We check exhaustively in the loop below if this charset is a 914 /* We check exhaustively in the loop below if this charset is a
@@ -948,9 +958,43 @@ static void
948internal_function 958internal_function
949init_word_char (re_dfa_t *dfa) 959init_word_char (re_dfa_t *dfa)
950{ 960{
951 int i, j, ch; 961 int i = 0;
962 int j;
963 int ch = 0;
952 dfa->word_ops_used = 1; 964 dfa->word_ops_used = 1;
953 for (i = 0, ch = 0; i < BITSET_WORDS; ++i) 965 if (BE (dfa->map_notascii == 0, 1))
966 {
967 bitset_word_t bits0 = 0x00000000;
968 bitset_word_t bits1 = 0x03ff0000;
969 bitset_word_t bits2 = 0x87fffffe;
970 bitset_word_t bits3 = 0x07fffffe;
971 if (BITSET_WORD_BITS == 64)
972 {
973 dfa->word_char[0] = bits1 << 31 << 1 | bits0;
974 dfa->word_char[1] = bits3 << 31 << 1 | bits2;
975 i = 2;
976 }
977 else if (BITSET_WORD_BITS == 32)
978 {
979 dfa->word_char[0] = bits0;
980 dfa->word_char[1] = bits1;
981 dfa->word_char[2] = bits2;
982 dfa->word_char[3] = bits3;
983 i = 4;
984 }
985 else
986 goto general_case;
987 ch = 128;
988
989 if (BE (dfa->is_utf8, 1))
990 {
991 memset (&dfa->word_char[i], '\0', (SBC_MAX - ch) / 8);
992 return;
993 }
994 }
995
996 general_case:
997 for (; i < BITSET_WORDS; ++i)
954 for (j = 0; j < BITSET_WORD_BITS; ++j, ++ch) 998 for (j = 0; j < BITSET_WORD_BITS; ++j, ++ch)
955 if (isalnum (ch) || ch == '_') 999 if (isalnum (ch) || ch == '_')
956 dfa->word_char[i] |= (bitset_word_t) 1 << j; 1000 dfa->word_char[i] |= (bitset_word_t) 1 << j;
@@ -961,7 +1005,7 @@ init_word_char (re_dfa_t *dfa)
961static void 1005static void
962free_workarea_compile (regex_t *preg) 1006free_workarea_compile (regex_t *preg)
963{ 1007{
964 re_dfa_t *dfa = (re_dfa_t *) preg->buffer; 1008 re_dfa_t *dfa = preg->buffer;
965 bin_tree_storage_t *storage, *next; 1009 bin_tree_storage_t *storage, *next;
966 for (storage = dfa->str_tree_storage; storage; storage = next) 1010 for (storage = dfa->str_tree_storage; storage; storage = next)
967 { 1011 {
@@ -1145,7 +1189,7 @@ optimize_utf8 (re_dfa_t *dfa)
1145static reg_errcode_t 1189static reg_errcode_t
1146analyze (regex_t *preg) 1190analyze (regex_t *preg)
1147{ 1191{
1148 re_dfa_t *dfa = (re_dfa_t *) preg->buffer; 1192 re_dfa_t *dfa = preg->buffer;
1149 reg_errcode_t ret; 1193 reg_errcode_t ret;
1150 1194
1151 /* Allocate arrays. */ 1195 /* Allocate arrays. */
@@ -1326,7 +1370,7 @@ lower_subexps (void *extra, bin_tree_t *node)
1326static bin_tree_t * 1370static bin_tree_t *
1327lower_subexp (reg_errcode_t *err, regex_t *preg, bin_tree_t *node) 1371lower_subexp (reg_errcode_t *err, regex_t *preg, bin_tree_t *node)
1328{ 1372{
1329 re_dfa_t *dfa = (re_dfa_t *) preg->buffer; 1373 re_dfa_t *dfa = preg->buffer;
1330 bin_tree_t *body = node->left; 1374 bin_tree_t *body = node->left;
1331 bin_tree_t *op, *cls, *tree1, *tree; 1375 bin_tree_t *op, *cls, *tree1, *tree;
1332 1376
@@ -1660,7 +1704,7 @@ calc_eclosure (re_dfa_t *dfa)
1660 /* If we have already calculated, skip it. */ 1704 /* If we have already calculated, skip it. */
1661 if (dfa->eclosures[node_idx].nelem != 0) 1705 if (dfa->eclosures[node_idx].nelem != 0)
1662 continue; 1706 continue;
1663 /* Calculate epsilon closure of `node_idx'. */ 1707 /* Calculate epsilon closure of 'node_idx'. */
1664 err = calc_eclosure_iter (&eclosure_elem, dfa, node_idx, true); 1708 err = calc_eclosure_iter (&eclosure_elem, dfa, node_idx, true);
1665 if (BE (err != REG_NOERROR, 0)) 1709 if (BE (err != REG_NOERROR, 0))
1666 return err; 1710 return err;
@@ -1710,14 +1754,14 @@ calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root)
1710 { 1754 {
1711 re_node_set eclosure_elem; 1755 re_node_set eclosure_elem;
1712 Idx edest = dfa->edests[node].elems[i]; 1756 Idx edest = dfa->edests[node].elems[i];
1713 /* If calculating the epsilon closure of `edest' is in progress, 1757 /* If calculating the epsilon closure of 'edest' is in progress,
1714 return intermediate result. */ 1758 return intermediate result. */
1715 if (dfa->eclosures[edest].nelem == REG_MISSING) 1759 if (dfa->eclosures[edest].nelem == REG_MISSING)
1716 { 1760 {
1717 incomplete = true; 1761 incomplete = true;
1718 continue; 1762 continue;
1719 } 1763 }
1720 /* If we haven't calculated the epsilon closure of `edest' yet, 1764 /* If we haven't calculated the epsilon closure of 'edest' yet,
1721 calculate now. Otherwise use calculated epsilon closure. */ 1765 calculate now. Otherwise use calculated epsilon closure. */
1722 if (dfa->eclosures[edest].nelem == 0) 1766 if (dfa->eclosures[edest].nelem == 0)
1723 { 1767 {
@@ -1727,11 +1771,11 @@ calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, Idx node, bool root)
1727 } 1771 }
1728 else 1772 else
1729 eclosure_elem = dfa->eclosures[edest]; 1773 eclosure_elem = dfa->eclosures[edest];
1730 /* Merge the epsilon closure of `edest'. */ 1774 /* Merge the epsilon closure of 'edest'. */
1731 err = re_node_set_merge (&eclosure, &eclosure_elem); 1775 err = re_node_set_merge (&eclosure, &eclosure_elem);
1732 if (BE (err != REG_NOERROR, 0)) 1776 if (BE (err != REG_NOERROR, 0))
1733 return err; 1777 return err;
1734 /* If the epsilon closure of `edest' is incomplete, 1778 /* If the epsilon closure of 'edest' is incomplete,
1735 the epsilon closure of this node is also incomplete. */ 1779 the epsilon closure of this node is also incomplete. */
1736 if (dfa->eclosures[edest].nelem == 0) 1780 if (dfa->eclosures[edest].nelem == 0)
1737 { 1781 {
@@ -2093,7 +2137,7 @@ peek_token_bracket (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
2093 2137
2094/* Entry point of the parser. 2138/* Entry point of the parser.
2095 Parse the regular expression REGEXP and return the structure tree. 2139 Parse the regular expression REGEXP and return the structure tree.
2096 If an error is occured, ERR is set by error code, and return NULL. 2140 If an error occurs, ERR is set by error code, and return NULL.
2097 This function build the following tree, from regular expression <reg_exp>: 2141 This function build the following tree, from regular expression <reg_exp>:
2098 CAT 2142 CAT
2099 / \ 2143 / \
@@ -2107,7 +2151,7 @@ static bin_tree_t *
2107parse (re_string_t *regexp, regex_t *preg, reg_syntax_t syntax, 2151parse (re_string_t *regexp, regex_t *preg, reg_syntax_t syntax,
2108 reg_errcode_t *err) 2152 reg_errcode_t *err)
2109{ 2153{
2110 re_dfa_t *dfa = (re_dfa_t *) preg->buffer; 2154 re_dfa_t *dfa = preg->buffer;
2111 bin_tree_t *tree, *eor, *root; 2155 bin_tree_t *tree, *eor, *root;
2112 re_token_t current_token; 2156 re_token_t current_token;
2113 dfa->syntax = syntax; 2157 dfa->syntax = syntax;
@@ -2135,13 +2179,13 @@ parse (re_string_t *regexp, regex_t *preg, reg_syntax_t syntax,
2135 / \ 2179 / \
2136 <branch1> <branch2> 2180 <branch1> <branch2>
2137 2181
2138 ALT means alternative, which represents the operator `|'. */ 2182 ALT means alternative, which represents the operator '|'. */
2139 2183
2140static bin_tree_t * 2184static bin_tree_t *
2141parse_reg_exp (re_string_t *regexp, regex_t *preg, re_token_t *token, 2185parse_reg_exp (re_string_t *regexp, regex_t *preg, re_token_t *token,
2142 reg_syntax_t syntax, Idx nest, reg_errcode_t *err) 2186 reg_syntax_t syntax, Idx nest, reg_errcode_t *err)
2143{ 2187{
2144 re_dfa_t *dfa = (re_dfa_t *) preg->buffer; 2188 re_dfa_t *dfa = preg->buffer;
2145 bin_tree_t *tree, *branch = NULL; 2189 bin_tree_t *tree, *branch = NULL;
2146 tree = parse_branch (regexp, preg, token, syntax, nest, err); 2190 tree = parse_branch (regexp, preg, token, syntax, nest, err);
2147 if (BE (*err != REG_NOERROR && tree == NULL, 0)) 2191 if (BE (*err != REG_NOERROR && tree == NULL, 0))
@@ -2183,7 +2227,7 @@ parse_branch (re_string_t *regexp, regex_t *preg, re_token_t *token,
2183 reg_syntax_t syntax, Idx nest, reg_errcode_t *err) 2227 reg_syntax_t syntax, Idx nest, reg_errcode_t *err)
2184{ 2228{
2185 bin_tree_t *tree, *expr; 2229 bin_tree_t *tree, *expr;
2186 re_dfa_t *dfa = (re_dfa_t *) preg->buffer; 2230 re_dfa_t *dfa = preg->buffer;
2187 tree = parse_expression (regexp, preg, token, syntax, nest, err); 2231 tree = parse_expression (regexp, preg, token, syntax, nest, err);
2188 if (BE (*err != REG_NOERROR && tree == NULL, 0)) 2232 if (BE (*err != REG_NOERROR && tree == NULL, 0))
2189 return NULL; 2233 return NULL;
@@ -2194,16 +2238,21 @@ parse_branch (re_string_t *regexp, regex_t *preg, re_token_t *token,
2194 expr = parse_expression (regexp, preg, token, syntax, nest, err); 2238 expr = parse_expression (regexp, preg, token, syntax, nest, err);
2195 if (BE (*err != REG_NOERROR && expr == NULL, 0)) 2239 if (BE (*err != REG_NOERROR && expr == NULL, 0))
2196 { 2240 {
2241 if (tree != NULL)
2242 postorder (tree, free_tree, NULL);
2197 return NULL; 2243 return NULL;
2198 } 2244 }
2199 if (tree != NULL && expr != NULL) 2245 if (tree != NULL && expr != NULL)
2200 { 2246 {
2201 tree = create_tree (dfa, tree, expr, CONCAT); 2247 bin_tree_t *newtree = create_tree (dfa, tree, expr, CONCAT);
2202 if (tree == NULL) 2248 if (newtree == NULL)
2203 { 2249 {
2250 postorder (expr, free_tree, NULL);
2251 postorder (tree, free_tree, NULL);
2204 *err = REG_ESPACE; 2252 *err = REG_ESPACE;
2205 return NULL; 2253 return NULL;
2206 } 2254 }
2255 tree = newtree;
2207 } 2256 }
2208 else if (tree == NULL) 2257 else if (tree == NULL)
2209 tree = expr; 2258 tree = expr;
@@ -2222,7 +2271,7 @@ static bin_tree_t *
2222parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token, 2271parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
2223 reg_syntax_t syntax, Idx nest, reg_errcode_t *err) 2272 reg_syntax_t syntax, Idx nest, reg_errcode_t *err)
2224{ 2273{
2225 re_dfa_t *dfa = (re_dfa_t *) preg->buffer; 2274 re_dfa_t *dfa = preg->buffer;
2226 bin_tree_t *tree; 2275 bin_tree_t *tree;
2227 switch (token->type) 2276 switch (token->type)
2228 { 2277 {
@@ -2378,8 +2427,8 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
2378 case OP_WORD: 2427 case OP_WORD:
2379 case OP_NOTWORD: 2428 case OP_NOTWORD:
2380 tree = build_charclass_op (dfa, regexp->trans, 2429 tree = build_charclass_op (dfa, regexp->trans,
2381 (const unsigned char *) "alnum", 2430 "alnum",
2382 (const unsigned char *) "_", 2431 "_",
2383 token->type == OP_NOTWORD, err); 2432 token->type == OP_NOTWORD, err);
2384 if (BE (*err != REG_NOERROR && tree == NULL, 0)) 2433 if (BE (*err != REG_NOERROR && tree == NULL, 0))
2385 return NULL; 2434 return NULL;
@@ -2387,8 +2436,8 @@ parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token,
2387 case OP_SPACE: 2436 case OP_SPACE:
2388 case OP_NOTSPACE: 2437 case OP_NOTSPACE:
2389 tree = build_charclass_op (dfa, regexp->trans, 2438 tree = build_charclass_op (dfa, regexp->trans,
2390 (const unsigned char *) "space", 2439 "space",
2391 (const unsigned char *) "", 2440 "",
2392 token->type == OP_NOTSPACE, err); 2441 token->type == OP_NOTSPACE, err);
2393 if (BE (*err != REG_NOERROR && tree == NULL, 0)) 2442 if (BE (*err != REG_NOERROR && tree == NULL, 0))
2394 return NULL; 2443 return NULL;
@@ -2438,7 +2487,7 @@ static bin_tree_t *
2438parse_sub_exp (re_string_t *regexp, regex_t *preg, re_token_t *token, 2487parse_sub_exp (re_string_t *regexp, regex_t *preg, re_token_t *token,
2439 reg_syntax_t syntax, Idx nest, reg_errcode_t *err) 2488 reg_syntax_t syntax, Idx nest, reg_errcode_t *err)
2440{ 2489{
2441 re_dfa_t *dfa = (re_dfa_t *) preg->buffer; 2490 re_dfa_t *dfa = preg->buffer;
2442 bin_tree_t *tree; 2491 bin_tree_t *tree;
2443 size_t cur_nsub; 2492 size_t cur_nsub;
2444 cur_nsub = preg->re_nsub++; 2493 cur_nsub = preg->re_nsub++;
@@ -2452,7 +2501,11 @@ parse_sub_exp (re_string_t *regexp, regex_t *preg, re_token_t *token,
2452 { 2501 {
2453 tree = parse_reg_exp (regexp, preg, token, syntax, nest, err); 2502 tree = parse_reg_exp (regexp, preg, token, syntax, nest, err);
2454 if (BE (*err == REG_NOERROR && token->type != OP_CLOSE_SUBEXP, 0)) 2503 if (BE (*err == REG_NOERROR && token->type != OP_CLOSE_SUBEXP, 0))
2455 *err = REG_EPAREN; 2504 {
2505 if (tree != NULL)
2506 postorder (tree, free_tree, NULL);
2507 *err = REG_EPAREN;
2508 }
2456 if (BE (*err != REG_NOERROR, 0)) 2509 if (BE (*err != REG_NOERROR, 0))
2457 return NULL; 2510 return NULL;
2458 } 2511 }
@@ -2530,6 +2583,12 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
2530 *err = REG_BADBR; 2583 *err = REG_BADBR;
2531 return NULL; 2584 return NULL;
2532 } 2585 }
2586
2587 if (BE (RE_DUP_MAX < (end == REG_MISSING ? start : end), 0))
2588 {
2589 *err = REG_ESIZE;
2590 return NULL;
2591 }
2533 } 2592 }
2534 else 2593 else
2535 { 2594 {
@@ -2570,7 +2629,10 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
2570 old_tree = NULL; 2629 old_tree = NULL;
2571 2630
2572 if (elem->token.type == SUBEXP) 2631 if (elem->token.type == SUBEXP)
2573 postorder (elem, mark_opt_subexp, (void *) (long) elem->token.opr.idx); 2632 {
2633 uintptr_t subidx = elem->token.opr.idx;
2634 postorder (elem, mark_opt_subexp, (void *) subidx);
2635 }
2574 2636
2575 tree = create_tree (dfa, elem, NULL, 2637 tree = create_tree (dfa, elem, NULL,
2576 (end == REG_MISSING ? OP_DUP_ASTERISK : OP_ALT)); 2638 (end == REG_MISSING ? OP_DUP_ASTERISK : OP_ALT));
@@ -2616,7 +2678,7 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
2616 Build the range expression which starts from START_ELEM, and ends 2678 Build the range expression which starts from START_ELEM, and ends
2617 at END_ELEM. The result are written to MBCSET and SBCSET. 2679 at END_ELEM. The result are written to MBCSET and SBCSET.
2618 RANGE_ALLOC is the allocated size of mbcset->range_starts, and 2680 RANGE_ALLOC is the allocated size of mbcset->range_starts, and
2619 mbcset->range_ends, is a pointer argument sinse we may 2681 mbcset->range_ends, is a pointer argument since we may
2620 update it. */ 2682 update it. */
2621 2683
2622static reg_errcode_t 2684static reg_errcode_t
@@ -2655,7 +2717,6 @@ build_range_exp (const reg_syntax_t syntax,
2655 wchar_t wc; 2717 wchar_t wc;
2656 wint_t start_wc; 2718 wint_t start_wc;
2657 wint_t end_wc; 2719 wint_t end_wc;
2658 wchar_t cmp_buf[6] = {L'\0', L'\0', L'\0', L'\0', L'\0', L'\0'};
2659 2720
2660 start_ch = ((start_elem->type == SB_CHAR) ? start_elem->opr.ch 2721 start_ch = ((start_elem->type == SB_CHAR) ? start_elem->opr.ch
2661 : ((start_elem->type == COLL_SYM) ? start_elem->opr.name[0] 2722 : ((start_elem->type == COLL_SYM) ? start_elem->opr.name[0]
@@ -2669,11 +2730,7 @@ build_range_exp (const reg_syntax_t syntax,
2669 ? __btowc (end_ch) : end_elem->opr.wch); 2730 ? __btowc (end_ch) : end_elem->opr.wch);
2670 if (start_wc == WEOF || end_wc == WEOF) 2731 if (start_wc == WEOF || end_wc == WEOF)
2671 return REG_ECOLLATE; 2732 return REG_ECOLLATE;
2672 cmp_buf[0] = start_wc; 2733 else if (BE ((syntax & RE_NO_EMPTY_RANGES) && start_wc > end_wc, 0))
2673 cmp_buf[4] = end_wc;
2674
2675 if (BE ((syntax & RE_NO_EMPTY_RANGES)
2676 && wcscoll (cmp_buf, cmp_buf + 4) > 0, 0))
2677 return REG_ERANGE; 2734 return REG_ERANGE;
2678 2735
2679 /* Got valid collation sequence values, add them as a new entry. 2736 /* Got valid collation sequence values, add them as a new entry.
@@ -2714,9 +2771,7 @@ build_range_exp (const reg_syntax_t syntax,
2714 /* Build the table for single byte characters. */ 2771 /* Build the table for single byte characters. */
2715 for (wc = 0; wc < SBC_MAX; ++wc) 2772 for (wc = 0; wc < SBC_MAX; ++wc)
2716 { 2773 {
2717 cmp_buf[2] = wc; 2774 if (start_wc <= wc && wc <= end_wc)
2718 if (wcscoll (cmp_buf, cmp_buf + 2) <= 0
2719 && wcscoll (cmp_buf + 2, cmp_buf + 4) <= 0)
2720 bitset_set (sbcset, wc); 2775 bitset_set (sbcset, wc);
2721 } 2776 }
2722 } 2777 }
@@ -2750,11 +2805,12 @@ build_range_exp (const reg_syntax_t syntax,
2750 2805
2751static reg_errcode_t 2806static reg_errcode_t
2752internal_function 2807internal_function
2753build_collating_symbol (bitset_t sbcset,
2754# ifdef RE_ENABLE_I18N 2808# ifdef RE_ENABLE_I18N
2755 re_charset_t *mbcset, Idx *coll_sym_alloc, 2809build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset,
2756# endif 2810 Idx *coll_sym_alloc, const unsigned char *name)
2757 const unsigned char *name) 2811# else /* not RE_ENABLE_I18N */
2812build_collating_symbol (bitset_t sbcset, const unsigned char *name)
2813# endif /* not RE_ENABLE_I18N */
2758{ 2814{
2759 size_t name_len = strlen ((const char *) name); 2815 size_t name_len = strlen ((const char *) name);
2760 if (BE (name_len != 1, 0)) 2816 if (BE (name_len != 1, 0))
@@ -2782,42 +2838,31 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
2782 const int32_t *symb_table; 2838 const int32_t *symb_table;
2783 const unsigned char *extra; 2839 const unsigned char *extra;
2784 2840
2785 /* Local function for parse_bracket_exp used in _LIBC environement. 2841 /* Local function for parse_bracket_exp used in _LIBC environment.
2786 Seek the collating symbol entry correspondings to NAME. 2842 Seek the collating symbol entry corresponding to NAME.
2787 Return the index of the symbol in the SYMB_TABLE. */ 2843 Return the index of the symbol in the SYMB_TABLE,
2844 or -1 if not found. */
2788 2845
2789 auto inline int32_t 2846 auto inline int32_t
2790 __attribute ((always_inline)) 2847 __attribute__ ((always_inline))
2791 seek_collating_symbol_entry (name, name_len) 2848 seek_collating_symbol_entry (const unsigned char *name, size_t name_len)
2792 const unsigned char *name;
2793 size_t name_len;
2794 { 2849 {
2795 int32_t hash = elem_hash ((const char *) name, name_len); 2850 int32_t elem;
2796 int32_t elem = hash % table_size;
2797 if (symb_table[2 * elem] != 0)
2798 {
2799 int32_t second = hash % (table_size - 2) + 1;
2800 2851
2801 do 2852 for (elem = 0; elem < table_size; elem++)
2802 { 2853 if (symb_table[2 * elem] != 0)
2803 /* First compare the hashing value. */ 2854 {
2804 if (symb_table[2 * elem] == hash 2855 int32_t idx = symb_table[2 * elem + 1];
2805 /* Compare the length of the name. */ 2856 /* Skip the name of collating element name. */
2806 && name_len == extra[symb_table[2 * elem + 1]] 2857 idx += 1 + extra[idx];
2807 /* Compare the name. */ 2858 if (/* Compare the length of the name. */
2808 && memcmp (name, &extra[symb_table[2 * elem + 1] + 1], 2859 name_len == extra[idx]
2809 name_len) == 0) 2860 /* Compare the name. */
2810 { 2861 && memcmp (name, &extra[idx + 1], name_len) == 0)
2811 /* Yep, this is the entry. */ 2862 /* Yep, this is the entry. */
2812 break; 2863 return elem;
2813 } 2864 }
2814 2865 return -1;
2815 /* Next entry. */
2816 elem += second;
2817 }
2818 while (symb_table[2 * elem] != 0);
2819 }
2820 return elem;
2821 } 2866 }
2822 2867
2823 /* Local function for parse_bracket_exp used in _LIBC environment. 2868 /* Local function for parse_bracket_exp used in _LIBC environment.
@@ -2825,9 +2870,8 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
2825 Return the value if succeeded, UINT_MAX otherwise. */ 2870 Return the value if succeeded, UINT_MAX otherwise. */
2826 2871
2827 auto inline unsigned int 2872 auto inline unsigned int
2828 __attribute ((always_inline)) 2873 __attribute__ ((always_inline))
2829 lookup_collation_sequence_value (br_elem) 2874 lookup_collation_sequence_value (bracket_elem_t *br_elem)
2830 bracket_elem_t *br_elem;
2831 { 2875 {
2832 if (br_elem->type == SB_CHAR) 2876 if (br_elem->type == SB_CHAR)
2833 { 2877 {
@@ -2855,7 +2899,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
2855 int32_t elem, idx; 2899 int32_t elem, idx;
2856 elem = seek_collating_symbol_entry (br_elem->opr.name, 2900 elem = seek_collating_symbol_entry (br_elem->opr.name,
2857 sym_name_len); 2901 sym_name_len);
2858 if (symb_table[2 * elem] != 0) 2902 if (elem != -1)
2859 { 2903 {
2860 /* We found the entry. */ 2904 /* We found the entry. */
2861 idx = symb_table[2 * elem + 1]; 2905 idx = symb_table[2 * elem + 1];
@@ -2873,7 +2917,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
2873 /* Return the collation sequence value. */ 2917 /* Return the collation sequence value. */
2874 return *(unsigned int *) (extra + idx); 2918 return *(unsigned int *) (extra + idx);
2875 } 2919 }
2876 else if (symb_table[2 * elem] == 0 && sym_name_len == 1) 2920 else if (sym_name_len == 1)
2877 { 2921 {
2878 /* No valid character. Match it as a single byte 2922 /* No valid character. Match it as a single byte
2879 character. */ 2923 character. */
@@ -2886,20 +2930,17 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
2886 return UINT_MAX; 2930 return UINT_MAX;
2887 } 2931 }
2888 2932
2889 /* Local function for parse_bracket_exp used in _LIBC environement. 2933 /* Local function for parse_bracket_exp used in _LIBC environment.
2890 Build the range expression which starts from START_ELEM, and ends 2934 Build the range expression which starts from START_ELEM, and ends
2891 at END_ELEM. The result are written to MBCSET and SBCSET. 2935 at END_ELEM. The result are written to MBCSET and SBCSET.
2892 RANGE_ALLOC is the allocated size of mbcset->range_starts, and 2936 RANGE_ALLOC is the allocated size of mbcset->range_starts, and
2893 mbcset->range_ends, is a pointer argument sinse we may 2937 mbcset->range_ends, is a pointer argument since we may
2894 update it. */ 2938 update it. */
2895 2939
2896 auto inline reg_errcode_t 2940 auto inline reg_errcode_t
2897 __attribute ((always_inline)) 2941 __attribute__ ((always_inline))
2898 build_range_exp (sbcset, mbcset, range_alloc, start_elem, end_elem) 2942 build_range_exp (bitset_t sbcset, re_charset_t *mbcset, int *range_alloc,
2899 re_charset_t *mbcset; 2943 bracket_elem_t *start_elem, bracket_elem_t *end_elem)
2900 Idx *range_alloc;
2901 bitset_t sbcset;
2902 bracket_elem_t *start_elem, *end_elem;
2903 { 2944 {
2904 unsigned int ch; 2945 unsigned int ch;
2905 uint32_t start_collseq; 2946 uint32_t start_collseq;
@@ -2912,6 +2953,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
2912 0)) 2953 0))
2913 return REG_ERANGE; 2954 return REG_ERANGE;
2914 2955
2956 /* FIXME: Implement rational ranges here, too. */
2915 start_collseq = lookup_collation_sequence_value (start_elem); 2957 start_collseq = lookup_collation_sequence_value (start_elem);
2916 end_collseq = lookup_collation_sequence_value (end_elem); 2958 end_collseq = lookup_collation_sequence_value (end_elem);
2917 /* Check start/end collation sequence values. */ 2959 /* Check start/end collation sequence values. */
@@ -2970,33 +3012,30 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
2970 return REG_NOERROR; 3012 return REG_NOERROR;
2971 } 3013 }
2972 3014
2973 /* Local function for parse_bracket_exp used in _LIBC environement. 3015 /* Local function for parse_bracket_exp used in _LIBC environment.
2974 Build the collating element which is represented by NAME. 3016 Build the collating element which is represented by NAME.
2975 The result are written to MBCSET and SBCSET. 3017 The result are written to MBCSET and SBCSET.
2976 COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a 3018 COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a
2977 pointer argument sinse we may update it. */ 3019 pointer argument since we may update it. */
2978 3020
2979 auto inline reg_errcode_t 3021 auto inline reg_errcode_t
2980 __attribute ((always_inline)) 3022 __attribute__ ((always_inline))
2981 build_collating_symbol (sbcset, mbcset, coll_sym_alloc, name) 3023 build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset,
2982 re_charset_t *mbcset; 3024 Idx *coll_sym_alloc, const unsigned char *name)
2983 Idx *coll_sym_alloc;
2984 bitset_t sbcset;
2985 const unsigned char *name;
2986 { 3025 {
2987 int32_t elem, idx; 3026 int32_t elem, idx;
2988 size_t name_len = strlen ((const char *) name); 3027 size_t name_len = strlen ((const char *) name);
2989 if (nrules != 0) 3028 if (nrules != 0)
2990 { 3029 {
2991 elem = seek_collating_symbol_entry (name, name_len); 3030 elem = seek_collating_symbol_entry (name, name_len);
2992 if (symb_table[2 * elem] != 0) 3031 if (elem != -1)
2993 { 3032 {
2994 /* We found the entry. */ 3033 /* We found the entry. */
2995 idx = symb_table[2 * elem + 1]; 3034 idx = symb_table[2 * elem + 1];
2996 /* Skip the name of collating element name. */ 3035 /* Skip the name of collating element name. */
2997 idx += 1 + extra[idx]; 3036 idx += 1 + extra[idx];
2998 } 3037 }
2999 else if (symb_table[2 * elem] == 0 && name_len == 1) 3038 else if (name_len == 1)
3000 { 3039 {
3001 /* No valid character, treat it as a normal 3040 /* No valid character, treat it as a normal
3002 character. */ 3041 character. */
@@ -3076,6 +3115,10 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3076 if (BE (sbcset == NULL, 0)) 3115 if (BE (sbcset == NULL, 0))
3077#endif /* RE_ENABLE_I18N */ 3116#endif /* RE_ENABLE_I18N */
3078 { 3117 {
3118 re_free (sbcset);
3119#ifdef RE_ENABLE_I18N
3120 re_free (mbcset);
3121#endif
3079 *err = REG_ESPACE; 3122 *err = REG_ESPACE;
3080 return NULL; 3123 return NULL;
3081 } 3124 }
@@ -3235,7 +3278,8 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
3235#ifdef RE_ENABLE_I18N 3278#ifdef RE_ENABLE_I18N
3236 mbcset, &char_class_alloc, 3279 mbcset, &char_class_alloc,
3237#endif /* RE_ENABLE_I18N */ 3280#endif /* RE_ENABLE_I18N */
3238 start_elem.opr.name, syntax); 3281 (const char *) start_elem.opr.name,
3282 syntax);
3239 if (BE (*err != REG_NOERROR, 0)) 3283 if (BE (*err != REG_NOERROR, 0))
3240 goto parse_bracket_exp_free_return; 3284 goto parse_bracket_exp_free_return;
3241 break; 3285 break;
@@ -3414,7 +3458,7 @@ parse_bracket_symbol (bracket_elem_t *elem, re_string_t *regexp,
3414 Build the equivalence class which is represented by NAME. 3458 Build the equivalence class which is represented by NAME.
3415 The result are written to MBCSET and SBCSET. 3459 The result are written to MBCSET and SBCSET.
3416 EQUIV_CLASS_ALLOC is the allocated size of mbcset->equiv_classes, 3460 EQUIV_CLASS_ALLOC is the allocated size of mbcset->equiv_classes,
3417 is a pointer argument sinse we may update it. */ 3461 is a pointer argument since we may update it. */
3418 3462
3419static reg_errcode_t 3463static reg_errcode_t
3420#ifdef RE_ENABLE_I18N 3464#ifdef RE_ENABLE_I18N
@@ -3445,19 +3489,18 @@ build_equiv_class (bitset_t sbcset, const unsigned char *name)
3445 _NL_COLLATE_EXTRAMB); 3489 _NL_COLLATE_EXTRAMB);
3446 indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE, 3490 indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE,
3447 _NL_COLLATE_INDIRECTMB); 3491 _NL_COLLATE_INDIRECTMB);
3448 idx1 = findidx (&cp); 3492 idx1 = findidx (&cp, -1);
3449 if (BE (idx1 == 0 || cp < name + strlen ((const char *) name), 0)) 3493 if (BE (idx1 == 0 || *cp != '\0', 0))
3450 /* This isn't a valid character. */ 3494 /* This isn't a valid character. */
3451 return REG_ECOLLATE; 3495 return REG_ECOLLATE;
3452 3496
3453 /* Build single byte matcing table for this equivalence class. */ 3497 /* Build single byte matching table for this equivalence class. */
3454 char_buf[1] = (unsigned char) '\0';
3455 len = weights[idx1 & 0xffffff]; 3498 len = weights[idx1 & 0xffffff];
3456 for (ch = 0; ch < SBC_MAX; ++ch) 3499 for (ch = 0; ch < SBC_MAX; ++ch)
3457 { 3500 {
3458 char_buf[0] = ch; 3501 char_buf[0] = ch;
3459 cp = char_buf; 3502 cp = char_buf;
3460 idx2 = findidx (&cp); 3503 idx2 = findidx (&cp, 1);
3461/* 3504/*
3462 idx2 = table[ch]; 3505 idx2 = table[ch];
3463*/ 3506*/
@@ -3510,20 +3553,20 @@ build_equiv_class (bitset_t sbcset, const unsigned char *name)
3510 Build the character class which is represented by NAME. 3553 Build the character class which is represented by NAME.
3511 The result are written to MBCSET and SBCSET. 3554 The result are written to MBCSET and SBCSET.
3512 CHAR_CLASS_ALLOC is the allocated size of mbcset->char_classes, 3555 CHAR_CLASS_ALLOC is the allocated size of mbcset->char_classes,
3513 is a pointer argument sinse we may update it. */ 3556 is a pointer argument since we may update it. */
3514 3557
3515static reg_errcode_t 3558static reg_errcode_t
3516#ifdef RE_ENABLE_I18N 3559#ifdef RE_ENABLE_I18N
3517build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset, 3560build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
3518 re_charset_t *mbcset, Idx *char_class_alloc, 3561 re_charset_t *mbcset, Idx *char_class_alloc,
3519 const unsigned char *class_name, reg_syntax_t syntax) 3562 const char *class_name, reg_syntax_t syntax)
3520#else /* not RE_ENABLE_I18N */ 3563#else /* not RE_ENABLE_I18N */
3521build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset, 3564build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
3522 const unsigned char *class_name, reg_syntax_t syntax) 3565 const char *class_name, reg_syntax_t syntax)
3523#endif /* not RE_ENABLE_I18N */ 3566#endif /* not RE_ENABLE_I18N */
3524{ 3567{
3525 int i; 3568 int i;
3526 const char *name = (const char *) class_name; 3569 const char *name = class_name;
3527 3570
3528 /* In case of REG_ICASE "upper" and "lower" match the both of 3571 /* In case of REG_ICASE "upper" and "lower" match the both of
3529 upper and lower cases. */ 3572 upper and lower cases. */
@@ -3597,8 +3640,8 @@ build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
3597 3640
3598static bin_tree_t * 3641static bin_tree_t *
3599build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans, 3642build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
3600 const unsigned char *class_name, 3643 const char *class_name,
3601 const unsigned char *extra, bool non_match, 3644 const char *extra, bool non_match,
3602 reg_errcode_t *err) 3645 reg_errcode_t *err)
3603{ 3646{
3604 re_bitset_ptr_t sbcset; 3647 re_bitset_ptr_t sbcset;
@@ -3704,8 +3747,9 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
3704} 3747}
3705 3748
3706/* This is intended for the expressions like "a{1,3}". 3749/* This is intended for the expressions like "a{1,3}".
3707 Fetch a number from `input', and return the number. 3750 Fetch a number from 'input', and return the number.
3708 Return REG_MISSING if the number field is empty like "{,1}". 3751 Return REG_MISSING if the number field is empty like "{,1}".
3752 Return RE_DUP_MAX + 1 if the number field is too large.
3709 Return REG_ERROR if an error occurred. */ 3753 Return REG_ERROR if an error occurred. */
3710 3754
3711static Idx 3755static Idx
@@ -3724,8 +3768,9 @@ fetch_number (re_string_t *input, re_token_t *token, reg_syntax_t syntax)
3724 num = ((token->type != CHARACTER || c < '0' || '9' < c 3768 num = ((token->type != CHARACTER || c < '0' || '9' < c
3725 || num == REG_ERROR) 3769 || num == REG_ERROR)
3726 ? REG_ERROR 3770 ? REG_ERROR
3727 : ((num == REG_MISSING) ? c - '0' : num * 10 + c - '0')); 3771 : num == REG_MISSING
3728 num = (num > RE_DUP_MAX) ? REG_ERROR : num; 3772 ? c - '0'
3773 : MIN (RE_DUP_MAX + 1, num * 10 + c - '0'));
3729 } 3774 }
3730 return num; 3775 return num;
3731} 3776}
@@ -3799,7 +3844,7 @@ create_token_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right,
3799static reg_errcode_t 3844static reg_errcode_t
3800mark_opt_subexp (void *extra, bin_tree_t *node) 3845mark_opt_subexp (void *extra, bin_tree_t *node)
3801{ 3846{
3802 Idx idx = (Idx) (long) extra; 3847 Idx idx = (uintptr_t) extra;
3803 if (node->token.type == SUBEXP && node->token.opr.idx == idx) 3848 if (node->token.type == SUBEXP && node->token.opr.idx == idx)
3804 node->token.opt_subexp = 1; 3849 node->token.opt_subexp = 1;
3805 3850
diff --git a/gl/regex.c b/gl/regex.c
index ba0eebe..5a0332e 100644
--- a/gl/regex.c
+++ b/gl/regex.c
@@ -1,26 +1,35 @@
1/* Extended regular expression matching and search library. 1/* Extended regular expression matching and search library.
2 Copyright (C) 2002, 2003, 2005, 2006, 2009, 2010 Free Software Foundation, 2 Copyright (C) 2002-2013 Free Software Foundation, Inc.
3 Inc.
4 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
5 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>. 4 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
6 5
7 This program is free software; you can redistribute it and/or modify 6 The GNU C Library is free software; you can redistribute it and/or
8 it under the terms of the GNU General Public License as published by 7 modify it under the terms of the GNU General Public
9 the Free Software Foundation; either version 3, or (at your option) 8 License as published by the Free Software Foundation; either
10 any later version. 9 version 3 of the License, or (at your option) any later version.
11 10
12 This program is distributed in the hope that it will be useful, 11 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 GNU General Public License for more details. 14 General Public License for more details.
16 15
17 You should have received a copy of the GNU General Public License along 16 You should have received a copy of the GNU General Public
18 with this program; if not, write to the Free Software Foundation, 17 License along with the GNU C Library; if not, see
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ 18 <http://www.gnu.org/licenses/>. */
20 19
21#include <config.h> 20#ifndef _LIBC
21# include <config.h>
22 22
23/* Make sure noone compiles this code with a C++ compiler. */ 23# if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__
24# pragma GCC diagnostic ignored "-Wsuggest-attribute=pure"
25# endif
26# if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__
27# pragma GCC diagnostic ignored "-Wold-style-definition"
28# pragma GCC diagnostic ignored "-Wtype-limits"
29# endif
30#endif
31
32/* Make sure no one compiles this code with a C++ compiler. */
24#if defined __cplusplus && defined _LIBC 33#if defined __cplusplus && defined _LIBC
25# error "This is C code, use a C compiler" 34# error "This is C code, use a C compiler"
26#endif 35#endif
diff --git a/gl/regex.h b/gl/regex.h
index d7426c7..854c6ed 100644
--- a/gl/regex.h
+++ b/gl/regex.h
@@ -1,23 +1,22 @@
1/* Definitions for data structures and routines for the regular 1/* Definitions for data structures and routines for the regular
2 expression library. 2 expression library.
3 Copyright (C) 1985, 1989, 1990, 1991, 1992, 1993, 1995, 1996, 1997, 1998, 3 Copyright (C) 1985, 1989-1993, 1995-1998, 2000-2003, 2005-2013 Free Software
4 2000, 2001, 2002, 2003, 2005, 2006, 2009, 2010 Free Software Foundation, 4 Foundation, Inc.
5 Inc.
6 This file is part of the GNU C Library. 5 This file is part of the GNU C Library.
7 6
8 This program is free software; you can redistribute it and/or modify 7 The GNU C Library is free software; you can redistribute it and/or
9 it under the terms of the GNU General Public License as published by 8 modify it under the terms of the GNU General Public
10 the Free Software Foundation; either version 3, or (at your option) 9 License as published by the Free Software Foundation; either
11 any later version. 10 version 3 of the License, or (at your option) any later version.
12 11
13 This program is distributed in the hope that it will be useful, 12 The GNU C Library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 GNU General Public License for more details. 15 General Public License for more details.
17 16
18 You should have received a copy of the GNU General Public License along 17 You should have received a copy of the GNU General Public
19 with this program; if not, write to the Free Software Foundation, 18 License along with the GNU C Library; if not, see
20 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ 19 <http://www.gnu.org/licenses/>. */
21 20
22#ifndef _REGEX_H 21#ifndef _REGEX_H
23#define _REGEX_H 1 22#define _REGEX_H 1
@@ -29,13 +28,10 @@
29extern "C" { 28extern "C" {
30#endif 29#endif
31 30
32/* Define __USE_GNU_REGEX to declare GNU extensions that violate the 31/* Define __USE_GNU to declare GNU extensions that violate the
33 POSIX name space rules. */ 32 POSIX name space rules. */
34#undef __USE_GNU_REGEX 33#ifdef _GNU_SOURCE
35#if (defined _GNU_SOURCE \ 34# define __USE_GNU 1
36 || (!defined _POSIX_C_SOURCE && !defined _POSIX_SOURCE \
37 && !defined _XOPEN_SOURCE))
38# define __USE_GNU_REGEX 1
39#endif 35#endif
40 36
41#ifdef _REGEX_LARGE_OFFSETS 37#ifdef _REGEX_LARGE_OFFSETS
@@ -46,16 +42,6 @@ extern "C" {
46 supported within glibc itself, and glibc users should not define 42 supported within glibc itself, and glibc users should not define
47 _REGEX_LARGE_OFFSETS. */ 43 _REGEX_LARGE_OFFSETS. */
48 44
49/* The type of the offset of a byte within a string.
50 For historical reasons POSIX 1003.1-2004 requires that regoff_t be
51 at least as wide as off_t. However, many common POSIX platforms set
52 regoff_t to the more-sensible ssize_t and the Open Group has
53 signalled its intention to change the requirement to be that
54 regoff_t be at least as wide as ptrdiff_t and ssize_t; see XBD ERN
55 60 (2005-08-25). We don't know of any hosts where ssize_t or
56 ptrdiff_t is wider than ssize_t, so ssize_t is safe. */
57typedef ssize_t regoff_t;
58
59/* The type of nonnegative object indexes. Traditionally, GNU regex 45/* The type of nonnegative object indexes. Traditionally, GNU regex
60 uses 'int' for these. Code that uses __re_idx_t should work 46 uses 'int' for these. Code that uses __re_idx_t should work
61 regardless of whether the type is signed. */ 47 regardless of whether the type is signed. */
@@ -70,10 +56,8 @@ typedef size_t __re_long_size_t;
70 56
71#else 57#else
72 58
73/* Use types that are binary-compatible with the traditional GNU regex 59/* The traditional GNU regex implementation mishandles strings longer
74 implementation, which mishandles strings longer than INT_MAX. */ 60 than INT_MAX. */
75
76typedef int regoff_t;
77typedef int __re_idx_t; 61typedef int __re_idx_t;
78typedef unsigned int __re_size_t; 62typedef unsigned int __re_size_t;
79typedef unsigned long int __re_long_size_t; 63typedef unsigned long int __re_long_size_t;
@@ -94,8 +78,7 @@ typedef unsigned long int active_reg_t;
94 add or remove a bit, only one other definition need change. */ 78 add or remove a bit, only one other definition need change. */
95typedef unsigned long int reg_syntax_t; 79typedef unsigned long int reg_syntax_t;
96 80
97#ifdef __USE_GNU_REGEX 81#ifdef __USE_GNU
98
99/* If this bit is not set, then \ inside a bracket expression is literal. 82/* If this bit is not set, then \ inside a bracket expression is literal.
100 If set, then such a \ quotes the following character. */ 83 If set, then such a \ quotes the following character. */
101# define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1) 84# define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1)
@@ -114,10 +97,10 @@ typedef unsigned long int reg_syntax_t;
114/* If this bit is set, then ^ and $ are always anchors (outside bracket 97/* If this bit is set, then ^ and $ are always anchors (outside bracket
115 expressions, of course). 98 expressions, of course).
116 If this bit is not set, then it depends: 99 If this bit is not set, then it depends:
117 ^ is an anchor if it is at the beginning of a regular 100 ^ is an anchor if it is at the beginning of a regular
118 expression or after an open-group or an alternation operator; 101 expression or after an open-group or an alternation operator;
119 $ is an anchor if it is at the end of a regular expression, or 102 $ is an anchor if it is at the end of a regular expression, or
120 before a close-group or an alternation operator. 103 before a close-group or an alternation operator.
121 104
122 This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because 105 This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because
123 POSIX draft 11.2 says that * etc. in leading positions is undefined. 106 POSIX draft 11.2 says that * etc. in leading positions is undefined.
@@ -162,9 +145,9 @@ typedef unsigned long int reg_syntax_t;
162 If not set, newline is literal. */ 145 If not set, newline is literal. */
163# define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1) 146# define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1)
164 147
165/* If this bit is set, then `{...}' defines an interval, and \{ and \} 148/* If this bit is set, then '{...}' defines an interval, and \{ and \}
166 are literals. 149 are literals.
167 If not set, then `\{...\}' defines an interval. */ 150 If not set, then '\{...\}' defines an interval. */
168# define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1) 151# define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1)
169 152
170/* If this bit is set, (...) defines a group, and \( and \) are literals. 153/* If this bit is set, (...) defines a group, and \( and \) are literals.
@@ -219,15 +202,14 @@ typedef unsigned long int reg_syntax_t;
219 whether ^ should be special. */ 202 whether ^ should be special. */
220# define RE_CARET_ANCHORS_HERE (RE_ICASE << 1) 203# define RE_CARET_ANCHORS_HERE (RE_ICASE << 1)
221 204
222/* If this bit is set, then \{ cannot be first in an bre or 205/* If this bit is set, then \{ cannot be first in a regex or
223 immediately after an alternation or begin-group operator. */ 206 immediately after an alternation, open-group or \} operator. */
224# define RE_CONTEXT_INVALID_DUP (RE_CARET_ANCHORS_HERE << 1) 207# define RE_CONTEXT_INVALID_DUP (RE_CARET_ANCHORS_HERE << 1)
225 208
226/* If this bit is set, then no_sub will be set to 1 during 209/* If this bit is set, then no_sub will be set to 1 during
227 re_compile_pattern. */ 210 re_compile_pattern. */
228# define RE_NO_SUB (RE_CONTEXT_INVALID_DUP << 1) 211# define RE_NO_SUB (RE_CONTEXT_INVALID_DUP << 1)
229 212#endif
230#endif /* defined __USE_GNU_REGEX */
231 213
232/* This global variable defines the particular regexp syntax to use (for 214/* This global variable defines the particular regexp syntax to use (for
233 some interfaces). When a regexp is compiled, the syntax used is 215 some interfaces). When a regexp is compiled, the syntax used is
@@ -235,7 +217,7 @@ typedef unsigned long int reg_syntax_t;
235 already-compiled regexps. */ 217 already-compiled regexps. */
236extern reg_syntax_t re_syntax_options; 218extern reg_syntax_t re_syntax_options;
237 219
238#ifdef __USE_GNU_REGEX 220#ifdef __USE_GNU
239/* Define combinations of the above bits for the standard possibilities. 221/* Define combinations of the above bits for the standard possibilities.
240 (The [[[ comments delimit what gets put into the Texinfo file, so 222 (The [[[ comments delimit what gets put into the Texinfo file, so
241 don't delete them!) */ 223 don't delete them!) */
@@ -247,16 +229,19 @@ extern reg_syntax_t re_syntax_options;
247 | RE_NO_BK_PARENS | RE_NO_BK_REFS \ 229 | RE_NO_BK_PARENS | RE_NO_BK_REFS \
248 | RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \ 230 | RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \
249 | RE_DOT_NEWLINE | RE_CONTEXT_INDEP_ANCHORS \ 231 | RE_DOT_NEWLINE | RE_CONTEXT_INDEP_ANCHORS \
232 | RE_CHAR_CLASSES \
250 | RE_UNMATCHED_RIGHT_PAREN_ORD | RE_NO_GNU_OPS) 233 | RE_UNMATCHED_RIGHT_PAREN_ORD | RE_NO_GNU_OPS)
251 234
252# define RE_SYNTAX_GNU_AWK \ 235# define RE_SYNTAX_GNU_AWK \
253 ((RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DEBUG) \ 236 ((RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS \
254 & ~(RE_DOT_NOT_NULL | RE_INTERVALS | RE_CONTEXT_INDEP_OPS \ 237 | RE_INVALID_INTERVAL_ORD) \
255 | RE_CONTEXT_INVALID_OPS )) 238 & ~(RE_DOT_NOT_NULL | RE_CONTEXT_INDEP_OPS \
239 | RE_CONTEXT_INVALID_OPS ))
256 240
257# define RE_SYNTAX_POSIX_AWK \ 241# define RE_SYNTAX_POSIX_AWK \
258 (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS \ 242 (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS \
259 | RE_INTERVALS | RE_NO_GNU_OPS) 243 | RE_INTERVALS | RE_NO_GNU_OPS \
244 | RE_INVALID_INTERVAL_ORD)
260 245
261# define RE_SYNTAX_GREP \ 246# define RE_SYNTAX_GREP \
262 (RE_BK_PLUS_QM | RE_CHAR_CLASSES \ 247 (RE_BK_PLUS_QM | RE_CHAR_CLASSES \
@@ -307,13 +292,12 @@ extern reg_syntax_t re_syntax_options;
307 | RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD) 292 | RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD)
308/* [[[end syntaxes]]] */ 293/* [[[end syntaxes]]] */
309 294
310#endif /* defined __USE_GNU_REGEX */
311
312#ifdef __USE_GNU_REGEX
313
314/* Maximum number of duplicates an interval can allow. POSIX-conforming 295/* Maximum number of duplicates an interval can allow. POSIX-conforming
315 systems might define this in <limits.h>, but we want our 296 systems might define this in <limits.h>, but we want our
316 value, so remove any previous define. */ 297 value, so remove any previous define. */
298# ifdef _REGEX_INCLUDE_LIMITS_H
299# include <limits.h>
300# endif
317# ifdef RE_DUP_MAX 301# ifdef RE_DUP_MAX
318# undef RE_DUP_MAX 302# undef RE_DUP_MAX
319# endif 303# endif
@@ -321,16 +305,15 @@ extern reg_syntax_t re_syntax_options;
321/* RE_DUP_MAX is 2**15 - 1 because an earlier implementation stored 305/* RE_DUP_MAX is 2**15 - 1 because an earlier implementation stored
322 the counter as a 2-byte signed integer. This is no longer true, so 306 the counter as a 2-byte signed integer. This is no longer true, so
323 RE_DUP_MAX could be increased to (INT_MAX / 10 - 1), or to 307 RE_DUP_MAX could be increased to (INT_MAX / 10 - 1), or to
324 ((SIZE_MAX - 2) / 10 - 1) if _REGEX_LARGE_OFFSETS is defined. 308 ((SIZE_MAX - 9) / 10) if _REGEX_LARGE_OFFSETS is defined.
325 However, there would be a huge performance problem if someone 309 However, there would be a huge performance problem if someone
326 actually used a pattern like a\{214748363\}, so RE_DUP_MAX retains 310 actually used a pattern like a\{214748363\}, so RE_DUP_MAX retains
327 its historical value. */ 311 its historical value. */
328# define RE_DUP_MAX (0x7fff) 312# define RE_DUP_MAX (0x7fff)
329 313#endif
330#endif /* defined __USE_GNU_REGEX */
331 314
332 315
333/* POSIX `cflags' bits (i.e., information for `regcomp'). */ 316/* POSIX 'cflags' bits (i.e., information for 'regcomp'). */
334 317
335/* If this bit is set, then use extended regular expression syntax. 318/* If this bit is set, then use extended regular expression syntax.
336 If not set, then use basic regular expression syntax. */ 319 If not set, then use basic regular expression syntax. */
@@ -350,7 +333,7 @@ extern reg_syntax_t re_syntax_options;
350#define REG_NOSUB (1 << 3) 333#define REG_NOSUB (1 << 3)
351 334
352 335
353/* POSIX `eflags' bits (i.e., information for regexec). */ 336/* POSIX 'eflags' bits (i.e., information for regexec). */
354 337
355/* If this bit is set, then the beginning-of-line operator doesn't match 338/* If this bit is set, then the beginning-of-line operator doesn't match
356 the beginning of the string (presumably because it's not the 339 the beginning of the string (presumably because it's not the
@@ -368,7 +351,7 @@ extern reg_syntax_t re_syntax_options;
368 351
369 352
370/* If any error codes are removed, changed, or added, update the 353/* If any error codes are removed, changed, or added, update the
371 `__re_error_msgid' table in regcomp.c. */ 354 '__re_error_msgid' table in regcomp.c. */
372 355
373typedef enum 356typedef enum
374{ 357{
@@ -393,11 +376,11 @@ typedef enum
393 376
394 /* Error codes we've added. */ 377 /* Error codes we've added. */
395 _REG_EEND, /* Premature end. */ 378 _REG_EEND, /* Premature end. */
396 _REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */ 379 _REG_ESIZE, /* Too large (e.g., repeat count too large). */
397 _REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */ 380 _REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */
398} reg_errcode_t; 381} reg_errcode_t;
399 382
400#ifdef _XOPEN_SOURCE 383#if defined _XOPEN_SOURCE || defined __USE_XOPEN2K
401# define REG_ENOSYS _REG_ENOSYS 384# define REG_ENOSYS _REG_ENOSYS
402#endif 385#endif
403#define REG_NOERROR _REG_NOERROR 386#define REG_NOERROR _REG_NOERROR
@@ -418,126 +401,127 @@ typedef enum
418#define REG_ESIZE _REG_ESIZE 401#define REG_ESIZE _REG_ESIZE
419#define REG_ERPAREN _REG_ERPAREN 402#define REG_ERPAREN _REG_ERPAREN
420 403
421/* struct re_pattern_buffer normally uses member names like `buffer' 404/* This data structure represents a compiled pattern. Before calling
422 that POSIX does not allow. In POSIX mode these members have names 405 the pattern compiler, the fields 'buffer', 'allocated', 'fastmap',
423 with leading `re_' (e.g., `re_buffer'). */ 406 and 'translate' can be set. After the pattern has been compiled,
424#ifdef __USE_GNU_REGEX 407 the fields 're_nsub', 'not_bol' and 'not_eol' are available. All
425# define _REG_RE_NAME(id) id 408 other fields are private to the regex routines. */
426# define _REG_RM_NAME(id) id 409
427#else 410#ifndef RE_TRANSLATE_TYPE
428# define _REG_RE_NAME(id) re_##id 411# define __RE_TRANSLATE_TYPE unsigned char *
429# define _REG_RM_NAME(id) rm_##id 412# ifdef __USE_GNU
413# define RE_TRANSLATE_TYPE __RE_TRANSLATE_TYPE
414# endif
430#endif 415#endif
431 416
432/* The user can specify the type of the re_translate member by 417#ifdef __USE_GNU
433 defining the macro RE_TRANSLATE_TYPE, which defaults to unsigned 418# define __REPB_PREFIX(name) name
434 char *. This pollutes the POSIX name space, so in POSIX mode just
435 use unsigned char *. */
436#ifdef __USE_GNU_REGEX
437# ifndef RE_TRANSLATE_TYPE
438# define RE_TRANSLATE_TYPE unsigned char *
439# endif
440# define REG_TRANSLATE_TYPE RE_TRANSLATE_TYPE
441#else 419#else
442# define REG_TRANSLATE_TYPE unsigned char * 420# define __REPB_PREFIX(name) __##name
443#endif 421#endif
444 422
445/* This data structure represents a compiled pattern. Before calling
446 the pattern compiler, the fields `buffer', `allocated', `fastmap',
447 `translate', and `no_sub' can be set. After the pattern has been
448 compiled, the `re_nsub' field is available. All other fields are
449 private to the regex routines. */
450
451struct re_pattern_buffer 423struct re_pattern_buffer
452{ 424{
453 /* Space that holds the compiled pattern. It is declared as 425 /* Space that holds the compiled pattern. The type
454 `unsigned char *' because its elements are sometimes used as 426 'struct re_dfa_t' is private and is not declared here. */
455 array indexes. */ 427 struct re_dfa_t *__REPB_PREFIX(buffer);
456 unsigned char *_REG_RE_NAME (buffer);
457 428
458 /* Number of bytes to which `buffer' points. */ 429 /* Number of bytes to which 'buffer' points. */
459 __re_long_size_t _REG_RE_NAME (allocated); 430 __re_long_size_t __REPB_PREFIX(allocated);
460 431
461 /* Number of bytes actually used in `buffer'. */ 432 /* Number of bytes actually used in 'buffer'. */
462 __re_long_size_t _REG_RE_NAME (used); 433 __re_long_size_t __REPB_PREFIX(used);
463 434
464 /* Syntax setting with which the pattern was compiled. */ 435 /* Syntax setting with which the pattern was compiled. */
465 reg_syntax_t _REG_RE_NAME (syntax); 436 reg_syntax_t __REPB_PREFIX(syntax);
466 437
467 /* Pointer to a fastmap, if any, otherwise zero. re_search uses the 438 /* Pointer to a fastmap, if any, otherwise zero. re_search uses the
468 fastmap, if there is one, to skip over impossible starting points 439 fastmap, if there is one, to skip over impossible starting points
469 for matches. */ 440 for matches. */
470 char *_REG_RE_NAME (fastmap); 441 char *__REPB_PREFIX(fastmap);
471 442
472 /* Either a translate table to apply to all characters before 443 /* Either a translate table to apply to all characters before
473 comparing them, or zero for no translation. The translation is 444 comparing them, or zero for no translation. The translation is
474 applied to a pattern when it is compiled and to a string when it 445 applied to a pattern when it is compiled and to a string when it
475 is matched. */ 446 is matched. */
476 REG_TRANSLATE_TYPE _REG_RE_NAME (translate); 447 __RE_TRANSLATE_TYPE __REPB_PREFIX(translate);
477 448
478 /* Number of subexpressions found by the compiler. */ 449 /* Number of subexpressions found by the compiler. */
479 size_t re_nsub; 450 size_t re_nsub;
480 451
481 /* Zero if this pattern cannot match the empty string, one else. 452 /* Zero if this pattern cannot match the empty string, one else.
482 Well, in truth it's used only in `re_search_2', to see whether or 453 Well, in truth it's used only in 're_search_2', to see whether or
483 not we should use the fastmap, so we don't set this absolutely 454 not we should use the fastmap, so we don't set this absolutely
484 perfectly; see `re_compile_fastmap' (the `duplicate' case). */ 455 perfectly; see 're_compile_fastmap' (the "duplicate" case). */
485 unsigned int _REG_RE_NAME (can_be_null) : 1; 456 unsigned __REPB_PREFIX(can_be_null) : 1;
486 457
487 /* If REGS_UNALLOCATED, allocate space in the `regs' structure 458 /* If REGS_UNALLOCATED, allocate space in the 'regs' structure
488 for `max (RE_NREGS, re_nsub + 1)' groups. 459 for 'max (RE_NREGS, re_nsub + 1)' groups.
489 If REGS_REALLOCATE, reallocate space if necessary. 460 If REGS_REALLOCATE, reallocate space if necessary.
490 If REGS_FIXED, use what's there. */ 461 If REGS_FIXED, use what's there. */
491#ifdef __USE_GNU_REGEX 462#ifdef __USE_GNU
492# define REGS_UNALLOCATED 0 463# define REGS_UNALLOCATED 0
493# define REGS_REALLOCATE 1 464# define REGS_REALLOCATE 1
494# define REGS_FIXED 2 465# define REGS_FIXED 2
495#endif 466#endif
496 unsigned int _REG_RE_NAME (regs_allocated) : 2; 467 unsigned __REPB_PREFIX(regs_allocated) : 2;
497 468
498 /* Set to zero when `regex_compile' compiles a pattern; set to one 469 /* Set to zero when 're_compile_pattern' compiles a pattern; set to
499 by `re_compile_fastmap' if it updates the fastmap. */ 470 one by 're_compile_fastmap' if it updates the fastmap. */
500 unsigned int _REG_RE_NAME (fastmap_accurate) : 1; 471 unsigned __REPB_PREFIX(fastmap_accurate) : 1;
501 472
502 /* If set, `re_match_2' does not return information about 473 /* If set, 're_match_2' does not return information about
503 subexpressions. */ 474 subexpressions. */
504 unsigned int _REG_RE_NAME (no_sub) : 1; 475 unsigned __REPB_PREFIX(no_sub) : 1;
505 476
506 /* If set, a beginning-of-line anchor doesn't match at the beginning 477 /* If set, a beginning-of-line anchor doesn't match at the beginning
507 of the string. */ 478 of the string. */
508 unsigned int _REG_RE_NAME (not_bol) : 1; 479 unsigned __REPB_PREFIX(not_bol) : 1;
509 480
510 /* Similarly for an end-of-line anchor. */ 481 /* Similarly for an end-of-line anchor. */
511 unsigned int _REG_RE_NAME (not_eol) : 1; 482 unsigned __REPB_PREFIX(not_eol) : 1;
512 483
513 /* If true, an anchor at a newline matches. */ 484 /* If true, an anchor at a newline matches. */
514 unsigned int _REG_RE_NAME (newline_anchor) : 1; 485 unsigned __REPB_PREFIX(newline_anchor) : 1;
515
516/* [[[end pattern_buffer]]] */
517}; 486};
518 487
519typedef struct re_pattern_buffer regex_t; 488typedef struct re_pattern_buffer regex_t;
520 489
490/* Type for byte offsets within the string. POSIX mandates this. */
491#ifdef _REGEX_LARGE_OFFSETS
492/* POSIX 1003.1-2008 requires that regoff_t be at least as wide as
493 ptrdiff_t and ssize_t. We don't know of any hosts where ptrdiff_t
494 is wider than ssize_t, so ssize_t is safe. */
495typedef ssize_t regoff_t;
496#else
497/* The traditional GNU regex implementation mishandles strings longer
498 than INT_MAX. */
499typedef int regoff_t;
500#endif
501
502
503#ifdef __USE_GNU
521/* This is the structure we store register match data in. See 504/* This is the structure we store register match data in. See
522 regex.texinfo for a full description of what registers match. */ 505 regex.texinfo for a full description of what registers match. */
523struct re_registers 506struct re_registers
524{ 507{
525 __re_size_t _REG_RM_NAME (num_regs); 508 __re_size_t num_regs;
526 regoff_t *_REG_RM_NAME (start); 509 regoff_t *start;
527 regoff_t *_REG_RM_NAME (end); 510 regoff_t *end;
528}; 511};
529 512
530 513
531/* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer, 514/* If 'regs_allocated' is REGS_UNALLOCATED in the pattern buffer,
532 `re_match_2' returns information about at least this many registers 515 're_match_2' returns information about at least this many registers
533 the first time a `regs' structure is passed. */ 516 the first time a 'regs' structure is passed. */
534#if !defined RE_NREGS && defined __USE_GNU_REGEX 517# ifndef RE_NREGS
535# define RE_NREGS 30 518# define RE_NREGS 30
519# endif
536#endif 520#endif
537 521
538 522
539/* POSIX specification for registers. Aside from the different names than 523/* POSIX specification for registers. Aside from the different names than
540 `re_registers', POSIX uses an array of structures, instead of a 524 're_registers', POSIX uses an array of structures, instead of a
541 structure of arrays. */ 525 structure of arrays. */
542typedef struct 526typedef struct
543{ 527{
@@ -547,13 +531,19 @@ typedef struct
547 531
548/* Declarations for routines. */ 532/* Declarations for routines. */
549 533
534#ifdef __USE_GNU
550/* Sets the current default syntax to SYNTAX, and return the old syntax. 535/* Sets the current default syntax to SYNTAX, and return the old syntax.
551 You can also simply assign to the `re_syntax_options' variable. */ 536 You can also simply assign to the 're_syntax_options' variable. */
552extern reg_syntax_t re_set_syntax (reg_syntax_t __syntax); 537extern reg_syntax_t re_set_syntax (reg_syntax_t __syntax);
553 538
554/* Compile the regular expression PATTERN, with length LENGTH 539/* Compile the regular expression PATTERN, with length LENGTH
555 and syntax given by the global `re_syntax_options', into the buffer 540 and syntax given by the global 're_syntax_options', into the buffer
556 BUFFER. Return NULL if successful, and an error string if not. */ 541 BUFFER. Return NULL if successful, and an error string if not.
542
543 To free the allocated storage, you must call 'regfree' on BUFFER.
544 Note that the translate table must either have been initialised by
545 'regcomp', with a malloc'ed value, or set to NULL before calling
546 'regfree'. */
557extern const char *re_compile_pattern (const char *__pattern, size_t __length, 547extern const char *re_compile_pattern (const char *__pattern, size_t __length,
558 struct re_pattern_buffer *__buffer); 548 struct re_pattern_buffer *__buffer);
559 549
@@ -575,7 +565,7 @@ extern regoff_t re_search (struct re_pattern_buffer *__buffer,
575 struct re_registers *__regs); 565 struct re_registers *__regs);
576 566
577 567
578/* Like `re_search', but search in the concatenation of STRING1 and 568/* Like 're_search', but search in the concatenation of STRING1 and
579 STRING2. Also, stop searching at index START + STOP. */ 569 STRING2. Also, stop searching at index START + STOP. */
580extern regoff_t re_search_2 (struct re_pattern_buffer *__buffer, 570extern regoff_t re_search_2 (struct re_pattern_buffer *__buffer,
581 const char *__string1, __re_idx_t __length1, 571 const char *__string1, __re_idx_t __length1,
@@ -585,14 +575,14 @@ extern regoff_t re_search_2 (struct re_pattern_buffer *__buffer,
585 __re_idx_t __stop); 575 __re_idx_t __stop);
586 576
587 577
588/* Like `re_search', but return how many characters in STRING the regexp 578/* Like 're_search', but return how many characters in STRING the regexp
589 in BUFFER matched, starting at position START. */ 579 in BUFFER matched, starting at position START. */
590extern regoff_t re_match (struct re_pattern_buffer *__buffer, 580extern regoff_t re_match (struct re_pattern_buffer *__buffer,
591 const char *__string, __re_idx_t __length, 581 const char *__string, __re_idx_t __length,
592 __re_idx_t __start, struct re_registers *__regs); 582 __re_idx_t __start, struct re_registers *__regs);
593 583
594 584
595/* Relates to `re_match' as `re_search_2' relates to `re_search'. */ 585/* Relates to 're_match' as 're_search_2' relates to 're_search'. */
596extern regoff_t re_match_2 (struct re_pattern_buffer *__buffer, 586extern regoff_t re_match_2 (struct re_pattern_buffer *__buffer,
597 const char *__string1, __re_idx_t __length1, 587 const char *__string1, __re_idx_t __length1,
598 const char *__string2, __re_idx_t __length2, 588 const char *__string2, __re_idx_t __length2,
@@ -603,21 +593,22 @@ extern regoff_t re_match_2 (struct re_pattern_buffer *__buffer,
603/* Set REGS to hold NUM_REGS registers, storing them in STARTS and 593/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
604 ENDS. Subsequent matches using BUFFER and REGS will use this memory 594 ENDS. Subsequent matches using BUFFER and REGS will use this memory
605 for recording register information. STARTS and ENDS must be 595 for recording register information. STARTS and ENDS must be
606 allocated with malloc, and must each be at least `NUM_REGS * sizeof 596 allocated with malloc, and must each be at least 'NUM_REGS * sizeof
607 (regoff_t)' bytes long. 597 (regoff_t)' bytes long.
608 598
609 If NUM_REGS == 0, then subsequent matches should allocate their own 599 If NUM_REGS == 0, then subsequent matches should allocate their own
610 register data. 600 register data.
611 601
612 Unless this function is called, the first search or match using 602 Unless this function is called, the first search or match using
613 PATTERN_BUFFER will allocate its own register data, without 603 BUFFER will allocate its own register data, without
614 freeing the old data. */ 604 freeing the old data. */
615extern void re_set_registers (struct re_pattern_buffer *__buffer, 605extern void re_set_registers (struct re_pattern_buffer *__buffer,
616 struct re_registers *__regs, 606 struct re_registers *__regs,
617 __re_size_t __num_regs, 607 __re_size_t __num_regs,
618 regoff_t *__starts, regoff_t *__ends); 608 regoff_t *__starts, regoff_t *__ends);
609#endif /* Use GNU */
619 610
620#if defined _REGEX_RE_COMP || defined _LIBC 611#if defined _REGEX_RE_COMP || (defined _LIBC && defined __USE_BSD)
621# ifndef _CRAY 612# ifndef _CRAY
622/* 4.2 bsd compatibility. */ 613/* 4.2 bsd compatibility. */
623extern char *re_comp (const char *); 614extern char *re_comp (const char *);
@@ -645,7 +636,7 @@ extern int re_exec (const char *);
645#ifndef _Restrict_arr_ 636#ifndef _Restrict_arr_
646# if ((199901L <= __STDC_VERSION__ \ 637# if ((199901L <= __STDC_VERSION__ \
647 || ((3 < __GNUC__ || (3 == __GNUC__ && 1 <= __GNUC_MINOR__)) \ 638 || ((3 < __GNUC__ || (3 == __GNUC__ && 1 <= __GNUC_MINOR__)) \
648 && !__STRICT_ANSI__)) \ 639 && !defined __STRICT_ANSI__)) \
649 && !defined __GNUG__) 640 && !defined __GNUG__)
650# define _Restrict_arr_ _Restrict_ 641# define _Restrict_arr_ _Restrict_
651# else 642# else
diff --git a/gl/regex_internal.c b/gl/regex_internal.c
index 98b8d5d..899b0ae 100644
--- a/gl/regex_internal.c
+++ b/gl/regex_internal.c
@@ -1,22 +1,21 @@
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, 2008, 2009, 2010 Free 2 Copyright (C) 2002-2013 Free Software Foundation, Inc.
3 Software Foundation, Inc.
4 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
5 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>. 4 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
6 5
7 This program is free software; you can redistribute it and/or modify 6 The GNU C Library is free software; you can redistribute it and/or
8 it under the terms of the GNU General Public License as published by 7 modify it under the terms of the GNU General Public
9 the Free Software Foundation; either version 3, or (at your option) 8 License as published by the Free Software Foundation; either
10 any later version. 9 version 3 of the License, or (at your option) any later version.
11 10
12 This program is distributed in the hope that it will be useful, 11 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 GNU General Public License for more details. 14 General Public License for more details.
16 15
17 You should have received a copy of the GNU General Public License along 16 You should have received a copy of the GNU General Public
18 with this program; if not, write to the Free Software Foundation, 17 License along with the GNU C Library; if not, see
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ 18 <http://www.gnu.org/licenses/>. */
20 19
21static void re_string_construct_common (const char *str, Idx len, 20static void re_string_construct_common (const char *str, Idx len,
22 re_string_t *pstr, 21 re_string_t *pstr,
@@ -135,9 +134,9 @@ re_string_realloc_buffers (re_string_t *pstr, Idx new_buf_len)
135 { 134 {
136 wint_t *new_wcs; 135 wint_t *new_wcs;
137 136
138 /* Avoid overflow. */ 137 /* Avoid overflow in realloc. */
139 size_t max_object_size = MAX (sizeof (wint_t), sizeof (Idx)); 138 const size_t max_object_size = MAX (sizeof (wint_t), sizeof (Idx));
140 if (BE (SIZE_MAX / max_object_size < new_buf_len, 0)) 139 if (BE (MIN (IDX_MAX, SIZE_MAX / max_object_size) < new_buf_len, 0))
141 return REG_ESPACE; 140 return REG_ESPACE;
142 141
143 new_wcs = re_realloc (pstr->wcs, wint_t, new_buf_len); 142 new_wcs = re_realloc (pstr->wcs, wint_t, new_buf_len);
@@ -237,13 +236,8 @@ build_wcs_buffer (re_string_t *pstr)
237 else 236 else
238 p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + byte_idx; 237 p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + byte_idx;
239 mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state); 238 mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state);
240 if (BE (mbclen == (size_t) -2, 0)) 239 if (BE (mbclen == (size_t) -1 || mbclen == 0
241 { 240 || (mbclen == (size_t) -2 && pstr->bufs_len >= pstr->len), 0))
242 /* The buffer doesn't have enough space, finish to build. */
243 pstr->cur_state = prev_st;
244 break;
245 }
246 else if (BE (mbclen == (size_t) -1 || mbclen == 0, 0))
247 { 241 {
248 /* We treat these cases as a singlebyte character. */ 242 /* We treat these cases as a singlebyte character. */
249 mbclen = 1; 243 mbclen = 1;
@@ -252,6 +246,12 @@ build_wcs_buffer (re_string_t *pstr)
252 wc = pstr->trans[wc]; 246 wc = pstr->trans[wc];
253 pstr->cur_state = prev_st; 247 pstr->cur_state = prev_st;
254 } 248 }
249 else if (BE (mbclen == (size_t) -2, 0))
250 {
251 /* The buffer doesn't have enough space, finish to build. */
252 pstr->cur_state = prev_st;
253 break;
254 }
255 255
256 /* Write wide character and padding. */ 256 /* Write wide character and padding. */
257 pstr->wcs[byte_idx++] = wc; 257 pstr->wcs[byte_idx++] = wc;
@@ -334,9 +334,11 @@ build_wcs_upper_buffer (re_string_t *pstr)
334 for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;) 334 for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;)
335 pstr->wcs[byte_idx++] = WEOF; 335 pstr->wcs[byte_idx++] = WEOF;
336 } 336 }
337 else if (mbclen == (size_t) -1 || mbclen == 0) 337 else if (mbclen == (size_t) -1 || mbclen == 0
338 || (mbclen == (size_t) -2 && pstr->bufs_len >= pstr->len))
338 { 339 {
339 /* It is an invalid character or '\0'. Just use the byte. */ 340 /* It is an invalid character, an incomplete character
341 at the end of the string, or '\0'. Just use the byte. */
340 int ch = pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]; 342 int ch = pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx];
341 pstr->mbs[byte_idx] = ch; 343 pstr->mbs[byte_idx] = ch;
342 /* And also cast it to wide char. */ 344 /* And also cast it to wide char. */
@@ -449,7 +451,8 @@ build_wcs_upper_buffer (re_string_t *pstr)
449 for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;) 451 for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;)
450 pstr->wcs[byte_idx++] = WEOF; 452 pstr->wcs[byte_idx++] = WEOF;
451 } 453 }
452 else if (mbclen == (size_t) -1 || mbclen == 0) 454 else if (mbclen == (size_t) -1 || mbclen == 0
455 || (mbclen == (size_t) -2 && pstr->bufs_len >= pstr->len))
453 { 456 {
454 /* It is an invalid character or '\0'. Just use the byte. */ 457 /* It is an invalid character or '\0'. Just use the byte. */
455 int ch = pstr->raw_mbs[pstr->raw_mbs_idx + src_idx]; 458 int ch = pstr->raw_mbs[pstr->raw_mbs_idx + src_idx];
@@ -496,8 +499,7 @@ re_string_skip_chars (re_string_t *pstr, Idx new_raw_idx, wint_t *last_wc)
496 rawbuf_idx < new_raw_idx;) 499 rawbuf_idx < new_raw_idx;)
497 { 500 {
498 wchar_t wc2; 501 wchar_t wc2;
499 Idx remain_len; 502 Idx remain_len = pstr->raw_len - rawbuf_idx;
500 remain_len = pstr->len - rawbuf_idx;
501 prev_st = pstr->cur_state; 503 prev_st = pstr->cur_state;
502 mbclen = __mbrtowc (&wc2, (const char *) pstr->raw_mbs + rawbuf_idx, 504 mbclen = __mbrtowc (&wc2, (const char *) pstr->raw_mbs + rawbuf_idx,
503 remain_len, &pstr->cur_state); 505 remain_len, &pstr->cur_state);
@@ -733,21 +735,21 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
733 mbstate_t cur_state; 735 mbstate_t cur_state;
734 wchar_t wc2; 736 wchar_t wc2;
735 Idx mlen = raw + pstr->len - p; 737 Idx mlen = raw + pstr->len - p;
738 unsigned char buf[6];
736 size_t mbclen; 739 size_t mbclen;
737 740
738#if 0 /* dead code: buf is set but never used */ 741 const unsigned char *pp = p;
739 unsigned char buf[6];
740 if (BE (pstr->trans != NULL, 0)) 742 if (BE (pstr->trans != NULL, 0))
741 { 743 {
742 int i = mlen < 6 ? mlen : 6; 744 int i = mlen < 6 ? mlen : 6;
743 while (--i >= 0) 745 while (--i >= 0)
744 buf[i] = pstr->trans[p[i]]; 746 buf[i] = pstr->trans[p[i]];
747 pp = buf;
745 } 748 }
746#endif
747 /* XXX Don't use mbrtowc, we know which conversion 749 /* XXX Don't use mbrtowc, we know which conversion
748 to use (UTF-8 -> UCS4). */ 750 to use (UTF-8 -> UCS4). */
749 memset (&cur_state, 0, sizeof (cur_state)); 751 memset (&cur_state, 0, sizeof (cur_state));
750 mbclen = __mbrtowc (&wc2, (const char *) p, mlen, 752 mbclen = __mbrtowc (&wc2, (const char *) pp, mlen,
751 &cur_state); 753 &cur_state);
752 if (raw + offset - p <= mbclen 754 if (raw + offset - p <= mbclen
753 && mbclen < (size_t) -2) 755 && mbclen < (size_t) -2)
@@ -832,7 +834,7 @@ re_string_reconstruct (re_string_t *pstr, Idx idx, int eflags)
832} 834}
833 835
834static unsigned char 836static unsigned char
835internal_function __attribute ((pure)) 837internal_function __attribute__ ((pure))
836re_string_peek_byte_case (const re_string_t *pstr, Idx idx) 838re_string_peek_byte_case (const re_string_t *pstr, Idx idx)
837{ 839{
838 int ch; 840 int ch;
@@ -869,7 +871,7 @@ re_string_peek_byte_case (const re_string_t *pstr, Idx idx)
869} 871}
870 872
871static unsigned char 873static unsigned char
872internal_function __attribute ((pure)) 874internal_function
873re_string_fetch_byte_case (re_string_t *pstr) 875re_string_fetch_byte_case (re_string_t *pstr)
874{ 876{
875 if (BE (!pstr->mbs_allocated, 1)) 877 if (BE (!pstr->mbs_allocated, 1))
@@ -972,7 +974,7 @@ re_node_set_alloc (re_node_set *set, Idx size)
972 set->alloc = size; 974 set->alloc = size;
973 set->nelem = 0; 975 set->nelem = 0;
974 set->elems = re_malloc (Idx, size); 976 set->elems = re_malloc (Idx, size);
975 if (BE (set->elems == NULL, 0)) 977 if (BE (set->elems == NULL, 0) && (MALLOC_0_IS_NONNULL || size != 0))
976 return REG_ESPACE; 978 return REG_ESPACE;
977 return REG_NOERROR; 979 return REG_NOERROR;
978} 980}
@@ -1352,7 +1354,7 @@ re_node_set_insert_last (re_node_set *set, Idx elem)
1352 Return true if SET1 and SET2 are equivalent. */ 1354 Return true if SET1 and SET2 are equivalent. */
1353 1355
1354static bool 1356static bool
1355internal_function __attribute ((pure)) 1357internal_function __attribute__ ((pure))
1356re_node_set_compare (const re_node_set *set1, const re_node_set *set2) 1358re_node_set_compare (const re_node_set *set1, const re_node_set *set2)
1357{ 1359{
1358 Idx i; 1360 Idx i;
@@ -1367,7 +1369,7 @@ re_node_set_compare (const re_node_set *set1, const re_node_set *set2)
1367/* Return (idx + 1) if SET contains the element ELEM, return 0 otherwise. */ 1369/* Return (idx + 1) if SET contains the element ELEM, return 0 otherwise. */
1368 1370
1369static Idx 1371static Idx
1370internal_function __attribute ((pure)) 1372internal_function __attribute__ ((pure))
1371re_node_set_contains (const re_node_set *set, Idx elem) 1373re_node_set_contains (const re_node_set *set, Idx elem)
1372{ 1374{
1373 __re_size_t idx, right, mid; 1375 __re_size_t idx, right, mid;
@@ -1413,13 +1415,12 @@ re_dfa_add_node (re_dfa_t *dfa, re_token_t token)
1413 Idx *new_nexts, *new_indices; 1415 Idx *new_nexts, *new_indices;
1414 re_node_set *new_edests, *new_eclosures; 1416 re_node_set *new_edests, *new_eclosures;
1415 re_token_t *new_nodes; 1417 re_token_t *new_nodes;
1416 size_t max_object_size =
1417 MAX (sizeof (re_token_t),
1418 MAX (sizeof (re_node_set),
1419 sizeof (Idx)));
1420 1418
1421 /* Avoid overflows. */ 1419 /* Avoid overflows in realloc. */
1422 if (BE (SIZE_MAX / 2 / max_object_size < dfa->nodes_alloc, 0)) 1420 const size_t max_object_size = MAX (sizeof (re_token_t),
1421 MAX (sizeof (re_node_set),
1422 sizeof (Idx)));
1423 if (BE (MIN (IDX_MAX, SIZE_MAX / max_object_size) < new_nodes_alloc, 0))
1423 return REG_MISSING; 1424 return REG_MISSING;
1424 1425
1425 new_nodes = re_realloc (dfa->nodes, re_token_t, new_nodes_alloc); 1426 new_nodes = re_realloc (dfa->nodes, re_token_t, new_nodes_alloc);
@@ -1442,11 +1443,9 @@ re_dfa_add_node (re_dfa_t *dfa, re_token_t token)
1442 dfa->nodes[dfa->nodes_len] = token; 1443 dfa->nodes[dfa->nodes_len] = token;
1443 dfa->nodes[dfa->nodes_len].constraint = 0; 1444 dfa->nodes[dfa->nodes_len].constraint = 0;
1444#ifdef RE_ENABLE_I18N 1445#ifdef RE_ENABLE_I18N
1445 {
1446 int type = token.type;
1447 dfa->nodes[dfa->nodes_len].accept_mb = 1446 dfa->nodes[dfa->nodes_len].accept_mb =
1448 (type == OP_PERIOD && dfa->mb_cur_max > 1) || type == COMPLEX_BRACKET; 1447 ((token.type == OP_PERIOD && dfa->mb_cur_max > 1)
1449 } 1448 || token.type == COMPLEX_BRACKET);
1450#endif 1449#endif
1451 dfa->nexts[dfa->nodes_len] = REG_MISSING; 1450 dfa->nexts[dfa->nodes_len] = REG_MISSING;
1452 re_node_set_init_empty (dfa->edests + dfa->nodes_len); 1451 re_node_set_init_empty (dfa->edests + dfa->nodes_len);
@@ -1454,7 +1453,7 @@ re_dfa_add_node (re_dfa_t *dfa, re_token_t token)
1454 return dfa->nodes_len++; 1453 return dfa->nodes_len++;
1455} 1454}
1456 1455
1457static inline re_hashval_t 1456static re_hashval_t
1458internal_function 1457internal_function
1459calc_state_hash (const re_node_set *nodes, unsigned int context) 1458calc_state_hash (const re_node_set *nodes, unsigned int context)
1460{ 1459{
@@ -1551,7 +1550,7 @@ re_acquire_state_context (reg_errcode_t *err, const re_dfa_t *dfa,
1551 && re_node_set_compare (state->entrance_nodes, nodes)) 1550 && re_node_set_compare (state->entrance_nodes, nodes))
1552 return state; 1551 return state;
1553 } 1552 }
1554 /* There are no appropriate state in `dfa', create the new one. */ 1553 /* There are no appropriate state in 'dfa', create the new one. */
1555 new_state = create_cd_newstate (dfa, nodes, context, hash); 1554 new_state = create_cd_newstate (dfa, nodes, context, hash);
1556 if (BE (new_state == NULL, 0)) 1555 if (BE (new_state == NULL, 0))
1557 *err = REG_ESPACE; 1556 *err = REG_ESPACE;
@@ -1580,7 +1579,7 @@ register_state (const re_dfa_t *dfa, re_dfastate_t *newstate,
1580 { 1579 {
1581 Idx elem = newstate->nodes.elems[i]; 1580 Idx elem = newstate->nodes.elems[i];
1582 if (!IS_EPSILON_NODE (dfa->nodes[elem].type)) 1581 if (!IS_EPSILON_NODE (dfa->nodes[elem].type))
1583 if (BE (! re_node_set_insert_last (&newstate->non_eps_nodes, elem), 0)) 1582 if (! re_node_set_insert_last (&newstate->non_eps_nodes, elem))
1584 return REG_ESPACE; 1583 return REG_ESPACE;
1585 } 1584 }
1586 1585
@@ -1615,7 +1614,7 @@ free_state (re_dfastate_t *state)
1615 re_free (state); 1614 re_free (state);
1616} 1615}
1617 1616
1618/* Create the new state which is independ of contexts. 1617/* Create the new state which is independent of contexts.
1619 Return the new state if succeeded, otherwise return NULL. */ 1618 Return the new state if succeeded, otherwise return NULL. */
1620 1619
1621static re_dfastate_t * 1620static re_dfastate_t *
diff --git a/gl/regex_internal.h b/gl/regex_internal.h
index 5aa5aa2..a2b8f16 100644
--- a/gl/regex_internal.h
+++ b/gl/regex_internal.h
@@ -1,50 +1,81 @@
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, 2008, 2009, 2010 Free 2 Copyright (C) 2002-2013 Free Software Foundation, Inc.
3 Software Foundation, Inc.
4 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
5 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>. 4 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
6 5
7 This program is free software; you can redistribute it and/or modify 6 The GNU C Library is free software; you can redistribute it and/or
8 it under the terms of the GNU General Public License as published by 7 modify it under the terms of the GNU General Public
9 the Free Software Foundation; either version 3, or (at your option) 8 License as published by the Free Software Foundation; either
10 any later version. 9 version 3 of the License, or (at your option) any later version.
11 10
12 This program is distributed in the hope that it will be useful, 11 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 GNU General Public License for more details. 14 General Public License for more details.
16 15
17 You should have received a copy of the GNU General Public License along 16 You should have received a copy of the GNU General Public
18 with this program; if not, write to the Free Software Foundation, 17 License along with the GNU C Library; if not, see
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ 18 <http://www.gnu.org/licenses/>. */
20 19
21#ifndef _REGEX_INTERNAL_H 20#ifndef _REGEX_INTERNAL_H
22#define _REGEX_INTERNAL_H 1 21#define _REGEX_INTERNAL_H 1
23 22
24#include <assert.h> 23#include <assert.h>
25#include <ctype.h> 24#include <ctype.h>
26#include <stdbool.h>
27#include <stdio.h> 25#include <stdio.h>
28#include <stdlib.h> 26#include <stdlib.h>
29#include <string.h> 27#include <string.h>
30 28
31#include <langinfo.h> 29#include <langinfo.h>
32#ifndef _LIBC 30#include <locale.h>
33# include "localcharset.h"
34#endif
35#if defined HAVE_LOCALE_H || defined _LIBC
36# include <locale.h>
37#endif
38
39#include <wchar.h> 31#include <wchar.h>
40#include <wctype.h> 32#include <wctype.h>
33#include <stdbool.h>
41#include <stdint.h> 34#include <stdint.h>
42#if defined _LIBC 35
36#ifdef _LIBC
43# include <bits/libc-lock.h> 37# include <bits/libc-lock.h>
38# define lock_define(name) __libc_lock_define (, name)
39# define lock_init(lock) (__libc_lock_init (lock), 0)
40# define lock_fini(lock) 0
41# define lock_lock(lock) __libc_lock_lock (lock)
42# define lock_unlock(lock) __libc_lock_unlock (lock)
43#elif defined GNULIB_LOCK
44# include "glthread/lock.h"
45 /* Use gl_lock_define if empty macro arguments are known to work.
46 Otherwise, fall back on less-portable substitutes. */
47# if ((defined __GNUC__ && !defined __STRICT_ANSI__) \
48 || (defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__))
49# define lock_define(name) gl_lock_define (, name)
50# elif USE_POSIX_THREADS
51# define lock_define(name) pthread_mutex_t name;
52# elif USE_PTH_THREADS
53# define lock_define(name) pth_mutex_t name;
54# elif USE_SOLARIS_THREADS
55# define lock_define(name) mutex_t name;
56# elif USE_WINDOWS_THREADS
57# define lock_define(name) gl_lock_t name;
58# else
59# define lock_define(name)
60# endif
61# define lock_init(lock) glthread_lock_init (&(lock))
62# define lock_fini(lock) glthread_lock_destroy (&(lock))
63# define lock_lock(lock) glthread_lock_lock (&(lock))
64# define lock_unlock(lock) glthread_lock_unlock (&(lock))
65#elif defined GNULIB_PTHREAD
66# include <pthread.h>
67# define lock_define(name) pthread_mutex_t name;
68# define lock_init(lock) pthread_mutex_init (&(lock), 0)
69# define lock_fini(lock) pthread_mutex_destroy (&(lock))
70# define lock_lock(lock) pthread_mutex_lock (&(lock))
71# define lock_unlock(lock) pthread_mutex_unlock (&(lock))
44#else 72#else
45# define __libc_lock_init(NAME) do { } while (0) 73# define lock_define(name)
46# define __libc_lock_lock(NAME) do { } while (0) 74# define lock_init(lock) 0
47# define __libc_lock_unlock(NAME) do { } while (0) 75# define lock_fini(lock) ((void) 0)
76 /* The 'dfa' avoids an "unused variable 'dfa'" warning from GCC. */
77# define lock_lock(lock) ((void) dfa)
78# define lock_unlock(lock) ((void) 0)
48#endif 79#endif
49 80
50/* In case that the system doesn't have isblank(). */ 81/* In case that the system doesn't have isblank(). */
@@ -67,7 +98,7 @@
67# ifdef _LIBC 98# ifdef _LIBC
68# undef gettext 99# undef gettext
69# define gettext(msgid) \ 100# define gettext(msgid) \
70 INTUSE(__dcgettext) (_libc_intl_domainname, msgid, LC_MESSAGES) 101 __dcgettext (_libc_intl_domainname, msgid, LC_MESSAGES)
71# endif 102# endif
72#else 103#else
73# define gettext(msgid) (msgid) 104# define gettext(msgid) (msgid)
@@ -79,12 +110,7 @@
79# define gettext_noop(String) String 110# define gettext_noop(String) String
80#endif 111#endif
81 112
82/* For loser systems without the definition. */ 113#if (defined MB_CUR_MAX && HAVE_WCTYPE_H && HAVE_ISWCTYPE && HAVE_WCSCOLL) || _LIBC
83#ifndef SIZE_MAX
84# define SIZE_MAX ((size_t) -1)
85#endif
86
87#if (defined MB_CUR_MAX && HAVE_LOCALE_H && HAVE_WCTYPE_H && HAVE_ISWCTYPE && HAVE_WCSCOLL) || _LIBC
88# define RE_ENABLE_I18N 114# define RE_ENABLE_I18N
89#endif 115#endif
90 116
@@ -92,9 +118,6 @@
92# define BE(expr, val) __builtin_expect (expr, val) 118# define BE(expr, val) __builtin_expect (expr, val)
93#else 119#else
94# define BE(expr, val) (expr) 120# define BE(expr, val) (expr)
95# ifdef _LIBC
96# define inline
97# endif
98#endif 121#endif
99 122
100/* Number of ASCII characters. */ 123/* Number of ASCII characters. */
@@ -111,22 +134,27 @@
111 134
112/* Rename to standard API for using out of glibc. */ 135/* Rename to standard API for using out of glibc. */
113#ifndef _LIBC 136#ifndef _LIBC
137# undef __wctype
138# undef __iswctype
114# define __wctype wctype 139# define __wctype wctype
115# define __iswctype iswctype 140# define __iswctype iswctype
116# define __btowc btowc 141# define __btowc btowc
117# define __wcrtomb wcrtomb
118# define __mbrtowc mbrtowc 142# define __mbrtowc mbrtowc
143# define __wcrtomb wcrtomb
119# define __regfree regfree 144# define __regfree regfree
120# define attribute_hidden 145# define attribute_hidden
121#endif /* not _LIBC */ 146#endif /* not _LIBC */
122 147
123#if __GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) 148#if __GNUC__ < 3 + (__GNUC_MINOR__ < 1)
124# define __attribute(arg) __attribute__ (arg) 149# define __attribute__(arg)
125#else
126# define __attribute(arg)
127#endif 150#endif
128 151
129typedef __re_idx_t Idx; 152typedef __re_idx_t Idx;
153#ifdef _REGEX_LARGE_OFFSETS
154# define IDX_MAX (SIZE_MAX - 2)
155#else
156# define IDX_MAX INT_MAX
157#endif
130 158
131/* Special return value for failure to match. */ 159/* Special return value for failure to match. */
132#define REG_MISSING ((Idx) -1) 160#define REG_MISSING ((Idx) -1)
@@ -337,7 +365,7 @@ typedef struct
337 Idx idx; /* for BACK_REF */ 365 Idx idx; /* for BACK_REF */
338 re_context_type ctx_type; /* for ANCHOR */ 366 re_context_type ctx_type; /* for ANCHOR */
339 } opr; 367 } opr;
340#if __GNUC__ >= 2 && !__STRICT_ANSI__ 368#if __GNUC__ >= 2 && !defined __STRICT_ANSI__
341 re_token_type_t type : 8; 369 re_token_type_t type : 8;
342#else 370#else
343 re_token_type_t type; 371 re_token_type_t type;
@@ -418,26 +446,24 @@ struct re_dfa_t;
418typedef struct re_dfa_t re_dfa_t; 446typedef struct re_dfa_t re_dfa_t;
419 447
420#ifndef _LIBC 448#ifndef _LIBC
421# if defined __i386__ && !defined __EMX__ 449# define internal_function
422# define internal_function __attribute ((regparm (3), stdcall))
423# else
424# define internal_function
425# endif
426#endif 450#endif
427 451
452#ifndef NOT_IN_libc
428static reg_errcode_t re_string_realloc_buffers (re_string_t *pstr, 453static reg_errcode_t re_string_realloc_buffers (re_string_t *pstr,
429 Idx new_buf_len) 454 Idx new_buf_len)
430 internal_function; 455 internal_function;
431#ifdef RE_ENABLE_I18N 456# ifdef RE_ENABLE_I18N
432static void build_wcs_buffer (re_string_t *pstr) internal_function; 457static void build_wcs_buffer (re_string_t *pstr) internal_function;
433static reg_errcode_t build_wcs_upper_buffer (re_string_t *pstr) 458static reg_errcode_t build_wcs_upper_buffer (re_string_t *pstr)
434 internal_function; 459 internal_function;
435#endif /* RE_ENABLE_I18N */ 460# endif /* RE_ENABLE_I18N */
436static void build_upper_buffer (re_string_t *pstr) internal_function; 461static void build_upper_buffer (re_string_t *pstr) internal_function;
437static void re_string_translate_buffer (re_string_t *pstr) internal_function; 462static void re_string_translate_buffer (re_string_t *pstr) internal_function;
438static unsigned int re_string_context_at (const re_string_t *input, Idx idx, 463static unsigned int re_string_context_at (const re_string_t *input, Idx idx,
439 int eflags) 464 int eflags)
440 internal_function __attribute ((pure)); 465 internal_function __attribute__ ((pure));
466#endif
441#define re_string_peek_byte(pstr, offset) \ 467#define re_string_peek_byte(pstr, offset) \
442 ((pstr)->mbs[(pstr)->cur_idx + offset]) 468 ((pstr)->mbs[(pstr)->cur_idx + offset])
443#define re_string_fetch_byte(pstr) \ 469#define re_string_fetch_byte(pstr) \
@@ -455,7 +481,9 @@ static unsigned int re_string_context_at (const re_string_t *input, Idx idx,
455#define re_string_skip_bytes(pstr,idx) ((pstr)->cur_idx += (idx)) 481#define re_string_skip_bytes(pstr,idx) ((pstr)->cur_idx += (idx))
456#define re_string_set_index(pstr,idx) ((pstr)->cur_idx = (idx)) 482#define re_string_set_index(pstr,idx) ((pstr)->cur_idx = (idx))
457 483
458#include <alloca.h> 484#if defined _LIBC || HAVE_ALLOCA
485# include <alloca.h>
486#endif
459 487
460#ifndef _LIBC 488#ifndef _LIBC
461# if HAVE_ALLOCA 489# if HAVE_ALLOCA
@@ -472,9 +500,18 @@ static unsigned int re_string_context_at (const re_string_t *input, Idx idx,
472# endif 500# endif
473#endif 501#endif
474 502
503#ifdef _LIBC
504# define MALLOC_0_IS_NONNULL 1
505#elif !defined MALLOC_0_IS_NONNULL
506# define MALLOC_0_IS_NONNULL 0
507#endif
508
475#ifndef MAX 509#ifndef MAX
476# define MAX(a,b) ((a) < (b) ? (b) : (a)) 510# define MAX(a,b) ((a) < (b) ? (b) : (a))
477#endif 511#endif
512#ifndef MIN
513# define MIN(a,b) ((a) < (b) ? (a) : (b))
514#endif
478 515
479#define re_malloc(t,n) ((t *) malloc ((n) * sizeof (t))) 516#define re_malloc(t,n) ((t *) malloc ((n) * sizeof (t)))
480#define re_realloc(p,t,n) ((t *) realloc (p, (n) * sizeof (t))) 517#define re_realloc(p,t,n) ((t *) realloc (p, (n) * sizeof (t)))
@@ -490,8 +527,8 @@ struct bin_tree_t
490 527
491 re_token_t token; 528 re_token_t token;
492 529
493 /* `node_idx' is the index in dfa->nodes, if `type' == 0. 530 /* 'node_idx' is the index in dfa->nodes, if 'type' == 0.
494 Otherwise `type' indicate the type of this node. */ 531 Otherwise 'type' indicate the type of this node. */
495 Idx node_idx; 532 Idx node_idx;
496}; 533};
497typedef struct bin_tree_t bin_tree_t; 534typedef struct bin_tree_t bin_tree_t;
@@ -544,9 +581,9 @@ struct re_dfastate_t
544 struct re_dfastate_t **trtable, **word_trtable; 581 struct re_dfastate_t **trtable, **word_trtable;
545 unsigned int context : 4; 582 unsigned int context : 4;
546 unsigned int halt : 1; 583 unsigned int halt : 1;
547 /* If this state can accept `multi byte'. 584 /* If this state can accept "multi byte".
548 Note that we refer to multibyte characters, and multi character 585 Note that we refer to multibyte characters, and multi character
549 collating elements as `multi byte'. */ 586 collating elements as "multi byte". */
550 unsigned int accept_mb : 1; 587 unsigned int accept_mb : 1;
551 /* If this state has backreference node(s). */ 588 /* If this state has backreference node(s). */
552 unsigned int has_backref : 1; 589 unsigned int has_backref : 1;
@@ -675,7 +712,7 @@ struct re_dfa_t
675 re_bitset_ptr_t sb_char; 712 re_bitset_ptr_t sb_char;
676 int str_tree_storage_idx; 713 int str_tree_storage_idx;
677 714
678 /* number of subexpressions `re_nsub' is in regex_t. */ 715 /* number of subexpressions 're_nsub' is in regex_t. */
679 re_hashval_t state_hash_mask; 716 re_hashval_t state_hash_mask;
680 Idx init_node; 717 Idx init_node;
681 Idx nbackref; /* The number of backreference in this dfa. */ 718 Idx nbackref; /* The number of backreference in this dfa. */
@@ -699,9 +736,7 @@ struct re_dfa_t
699#ifdef DEBUG 736#ifdef DEBUG
700 char* re_str; 737 char* re_str;
701#endif 738#endif
702#ifdef _LIBC 739 lock_define (lock)
703 __libc_lock_define (, lock)
704#endif
705}; 740};
706 741
707#define re_node_set_init_empty(set) memset (set, '\0', sizeof (re_node_set)) 742#define re_node_set_init_empty(set) memset (set, '\0', sizeof (re_node_set))
@@ -732,33 +767,33 @@ typedef struct
732} bracket_elem_t; 767} bracket_elem_t;
733 768
734 769
735/* Inline functions for bitset_t operation. */ 770/* Functions for bitset_t operation. */
736 771
737static inline void 772static void
738bitset_set (bitset_t set, Idx i) 773bitset_set (bitset_t set, Idx i)
739{ 774{
740 set[i / BITSET_WORD_BITS] |= (bitset_word_t) 1 << i % BITSET_WORD_BITS; 775 set[i / BITSET_WORD_BITS] |= (bitset_word_t) 1 << i % BITSET_WORD_BITS;
741} 776}
742 777
743static inline void 778static void
744bitset_clear (bitset_t set, Idx i) 779bitset_clear (bitset_t set, Idx i)
745{ 780{
746 set[i / BITSET_WORD_BITS] &= ~ ((bitset_word_t) 1 << i % BITSET_WORD_BITS); 781 set[i / BITSET_WORD_BITS] &= ~ ((bitset_word_t) 1 << i % BITSET_WORD_BITS);
747} 782}
748 783
749static inline bool 784static bool
750bitset_contain (const bitset_t set, Idx i) 785bitset_contain (const bitset_t set, Idx i)
751{ 786{
752 return (set[i / BITSET_WORD_BITS] >> i % BITSET_WORD_BITS) & 1; 787 return (set[i / BITSET_WORD_BITS] >> i % BITSET_WORD_BITS) & 1;
753} 788}
754 789
755static inline void 790static void
756bitset_empty (bitset_t set) 791bitset_empty (bitset_t set)
757{ 792{
758 memset (set, '\0', sizeof (bitset_t)); 793 memset (set, '\0', sizeof (bitset_t));
759} 794}
760 795
761static inline void 796static void
762bitset_set_all (bitset_t set) 797bitset_set_all (bitset_t set)
763{ 798{
764 memset (set, -1, sizeof (bitset_word_t) * (SBC_MAX / BITSET_WORD_BITS)); 799 memset (set, -1, sizeof (bitset_word_t) * (SBC_MAX / BITSET_WORD_BITS));
@@ -767,13 +802,13 @@ bitset_set_all (bitset_t set)
767 ((bitset_word_t) 1 << SBC_MAX % BITSET_WORD_BITS) - 1; 802 ((bitset_word_t) 1 << SBC_MAX % BITSET_WORD_BITS) - 1;
768} 803}
769 804
770static inline void 805static void
771bitset_copy (bitset_t dest, const bitset_t src) 806bitset_copy (bitset_t dest, const bitset_t src)
772{ 807{
773 memcpy (dest, src, sizeof (bitset_t)); 808 memcpy (dest, src, sizeof (bitset_t));
774} 809}
775 810
776static inline void 811static void __attribute__ ((unused))
777bitset_not (bitset_t set) 812bitset_not (bitset_t set)
778{ 813{
779 int bitset_i; 814 int bitset_i;
@@ -785,7 +820,7 @@ bitset_not (bitset_t set)
785 & ~set[BITSET_WORDS - 1]); 820 & ~set[BITSET_WORDS - 1]);
786} 821}
787 822
788static inline void 823static void __attribute__ ((unused))
789bitset_merge (bitset_t dest, const bitset_t src) 824bitset_merge (bitset_t dest, const bitset_t src)
790{ 825{
791 int bitset_i; 826 int bitset_i;
@@ -793,7 +828,7 @@ bitset_merge (bitset_t dest, const bitset_t src)
793 dest[bitset_i] |= src[bitset_i]; 828 dest[bitset_i] |= src[bitset_i];
794} 829}
795 830
796static inline void 831static void __attribute__ ((unused))
797bitset_mask (bitset_t dest, const bitset_t src) 832bitset_mask (bitset_t dest, const bitset_t src)
798{ 833{
799 int bitset_i; 834 int bitset_i;
@@ -802,9 +837,9 @@ bitset_mask (bitset_t dest, const bitset_t src)
802} 837}
803 838
804#ifdef RE_ENABLE_I18N 839#ifdef RE_ENABLE_I18N
805/* Inline functions for re_string. */ 840/* Functions for re_string. */
806static inline int 841static int
807internal_function __attribute ((pure)) 842internal_function __attribute__ ((pure, unused))
808re_string_char_size_at (const re_string_t *pstr, Idx idx) 843re_string_char_size_at (const re_string_t *pstr, Idx idx)
809{ 844{
810 int byte_idx; 845 int byte_idx;
@@ -816,8 +851,8 @@ re_string_char_size_at (const re_string_t *pstr, Idx idx)
816 return byte_idx; 851 return byte_idx;
817} 852}
818 853
819static inline wint_t 854static wint_t
820internal_function __attribute ((pure)) 855internal_function __attribute__ ((pure, unused))
821re_string_wchar_at (const re_string_t *pstr, Idx idx) 856re_string_wchar_at (const re_string_t *pstr, Idx idx)
822{ 857{
823 if (pstr->mb_cur_max == 1) 858 if (pstr->mb_cur_max == 1)
@@ -825,15 +860,15 @@ re_string_wchar_at (const re_string_t *pstr, Idx idx)
825 return (wint_t) pstr->wcs[idx]; 860 return (wint_t) pstr->wcs[idx];
826} 861}
827 862
863# ifndef NOT_IN_libc
828static int 864static int
829internal_function __attribute ((pure)) 865internal_function __attribute__ ((pure, unused))
830re_string_elem_size_at (const re_string_t *pstr, Idx idx) 866re_string_elem_size_at (const re_string_t *pstr, Idx idx)
831{ 867{
832# ifdef _LIBC 868# ifdef _LIBC
833 const unsigned char *p, *extra; 869 const unsigned char *p, *extra;
834 const int32_t *table, *indirect; 870 const int32_t *table, *indirect;
835 int32_t tmp; 871# include <locale/weight.h>
836# include <locale/weight.h>
837 uint_fast32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); 872 uint_fast32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
838 873
839 if (nrules != 0) 874 if (nrules != 0)
@@ -844,13 +879,14 @@ re_string_elem_size_at (const re_string_t *pstr, Idx idx)
844 indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE, 879 indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE,
845 _NL_COLLATE_INDIRECTMB); 880 _NL_COLLATE_INDIRECTMB);
846 p = pstr->mbs + idx; 881 p = pstr->mbs + idx;
847 tmp = findidx (&p); 882 findidx (&p, pstr->len - idx);
848 return p - pstr->mbs - idx; 883 return p - pstr->mbs - idx;
849 } 884 }
850 else 885 else
851# endif /* _LIBC */ 886# endif /* _LIBC */
852 return 1; 887 return 1;
853} 888}
889# endif
854#endif /* RE_ENABLE_I18N */ 890#endif /* RE_ENABLE_I18N */
855 891
856#ifndef __GNUC_PREREQ 892#ifndef __GNUC_PREREQ
diff --git a/gl/regexec.c b/gl/regexec.c
index dc449ce..d29d442 100644
--- a/gl/regexec.c
+++ b/gl/regexec.c
@@ -1,22 +1,21 @@
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, 2008, 2009, 2010 Free 2 Copyright (C) 2002-2013 Free Software Foundation, Inc.
3 Software Foundation, Inc.
4 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
5 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>. 4 Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>.
6 5
7 This program is free software; you can redistribute it and/or modify 6 The GNU C Library is free software; you can redistribute it and/or
8 it under the terms of the GNU General Public License as published by 7 modify it under the terms of the GNU General Public
9 the Free Software Foundation; either version 3, or (at your option) 8 License as published by the Free Software Foundation; either
10 any later version. 9 version 3 of the License, or (at your option) any later version.
11 10
12 This program is distributed in the hope that it will be useful, 11 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 GNU General Public License for more details. 14 General Public License for more details.
16 15
17 You should have received a copy of the GNU General Public License along 16 You should have received a copy of the GNU General Public
18 with this program; if not, write to the Free Software Foundation, 17 License along with the GNU C Library; if not, see
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ 18 <http://www.gnu.org/licenses/>. */
20 19
21static reg_errcode_t match_ctx_init (re_match_context_t *cache, int eflags, 20static reg_errcode_t match_ctx_init (re_match_context_t *cache, int eflags,
22 Idx n) internal_function; 21 Idx n) internal_function;
@@ -52,9 +51,8 @@ static regoff_t re_search_stub (struct re_pattern_buffer *bufp,
52 regoff_t range, Idx stop, 51 regoff_t range, Idx stop,
53 struct re_registers *regs, 52 struct re_registers *regs,
54 bool ret_len) internal_function; 53 bool ret_len) internal_function;
55static unsigned int re_copy_regs (struct re_registers *regs, regmatch_t *pmatch, 54static unsigned re_copy_regs (struct re_registers *regs, regmatch_t *pmatch,
56 Idx nregs, int regs_allocated) 55 Idx nregs, int regs_allocated) internal_function;
57 internal_function;
58static reg_errcode_t prune_impossible_nodes (re_match_context_t *mctx) 56static reg_errcode_t prune_impossible_nodes (re_match_context_t *mctx)
59 internal_function; 57 internal_function;
60static Idx check_matching (re_match_context_t *mctx, bool fl_longest_match, 58static Idx check_matching (re_match_context_t *mctx, bool fl_longest_match,
@@ -201,7 +199,7 @@ static Idx group_nodes_into_DFAstates (const re_dfa_t *dfa,
201static bool check_node_accept (const re_match_context_t *mctx, 199static bool check_node_accept (const re_match_context_t *mctx,
202 const re_token_t *node, Idx idx) 200 const re_token_t *node, Idx idx)
203 internal_function; 201 internal_function;
204static reg_errcode_t extend_buffers (re_match_context_t *mctx) 202static reg_errcode_t extend_buffers (re_match_context_t *mctx, int min_len)
205 internal_function; 203 internal_function;
206 204
207/* Entry point for POSIX code. */ 205/* Entry point for POSIX code. */
@@ -210,11 +208,11 @@ static reg_errcode_t extend_buffers (re_match_context_t *mctx)
210 string STRING. 208 string STRING.
211 209
212 If NMATCH is zero or REG_NOSUB was set in the cflags argument to 210 If NMATCH is zero or REG_NOSUB was set in the cflags argument to
213 `regcomp', we ignore PMATCH. Otherwise, we assume PMATCH has at 211 'regcomp', we ignore PMATCH. Otherwise, we assume PMATCH has at
214 least NMATCH elements, and we set them to the offsets of the 212 least NMATCH elements, and we set them to the offsets of the
215 corresponding matched substrings. 213 corresponding matched substrings.
216 214
217 EFLAGS specifies `execution flags' which affect matching: if 215 EFLAGS specifies "execution flags" which affect matching: if
218 REG_NOTBOL is set, then ^ does not match at the beginning of the 216 REG_NOTBOL is set, then ^ does not match at the beginning of the
219 string; if REG_NOTEOL is set, then $ does not match at the end. 217 string; if REG_NOTEOL is set, then $ does not match at the end.
220 218
@@ -230,9 +228,7 @@ regexec (preg, string, nmatch, pmatch, eflags)
230{ 228{
231 reg_errcode_t err; 229 reg_errcode_t err;
232 Idx start, length; 230 Idx start, length;
233#ifdef _LIBC 231 re_dfa_t *dfa = preg->buffer;
234 re_dfa_t *dfa = (re_dfa_t *) preg->buffer;
235#endif
236 232
237 if (eflags & ~(REG_NOTBOL | REG_NOTEOL | REG_STARTEND)) 233 if (eflags & ~(REG_NOTBOL | REG_NOTEOL | REG_STARTEND))
238 return REG_BADPAT; 234 return REG_BADPAT;
@@ -248,14 +244,14 @@ regexec (preg, string, nmatch, pmatch, eflags)
248 length = strlen (string); 244 length = strlen (string);
249 } 245 }
250 246
251 __libc_lock_lock (dfa->lock); 247 lock_lock (dfa->lock);
252 if (preg->no_sub) 248 if (preg->no_sub)
253 err = re_search_internal (preg, string, length, start, length, 249 err = re_search_internal (preg, string, length, start, length,
254 length, 0, NULL, eflags); 250 length, 0, NULL, eflags);
255 else 251 else
256 err = re_search_internal (preg, string, length, start, length, 252 err = re_search_internal (preg, string, length, start, length,
257 length, nmatch, pmatch, eflags); 253 length, nmatch, pmatch, eflags);
258 __libc_lock_unlock (dfa->lock); 254 lock_unlock (dfa->lock);
259 return err != REG_NOERROR; 255 return err != REG_NOERROR;
260} 256}
261 257
@@ -366,7 +362,6 @@ weak_alias (__re_search_2, re_search_2)
366#endif 362#endif
367 363
368static regoff_t 364static regoff_t
369internal_function
370re_search_2_stub (struct re_pattern_buffer *bufp, 365re_search_2_stub (struct re_pattern_buffer *bufp,
371 const char *string1, Idx length1, 366 const char *string1, Idx length1,
372 const char *string2, Idx length2, 367 const char *string2, Idx length2,
@@ -414,7 +409,6 @@ re_search_2_stub (struct re_pattern_buffer *bufp,
414 otherwise the position of the match is returned. */ 409 otherwise the position of the match is returned. */
415 410
416static regoff_t 411static regoff_t
417internal_function
418re_search_stub (struct re_pattern_buffer *bufp, 412re_search_stub (struct re_pattern_buffer *bufp,
419 const char *string, Idx length, 413 const char *string, Idx length,
420 Idx start, regoff_t range, Idx stop, struct re_registers *regs, 414 Idx start, regoff_t range, Idx stop, struct re_registers *regs,
@@ -425,9 +419,7 @@ re_search_stub (struct re_pattern_buffer *bufp,
425 Idx nregs; 419 Idx nregs;
426 regoff_t rval; 420 regoff_t rval;
427 int eflags = 0; 421 int eflags = 0;
428#ifdef _LIBC 422 re_dfa_t *dfa = bufp->buffer;
429 re_dfa_t *dfa = (re_dfa_t *) bufp->buffer;
430#endif
431 Idx last_start = start + range; 423 Idx last_start = start + range;
432 424
433 /* Check for out-of-range. */ 425 /* Check for out-of-range. */
@@ -438,7 +430,7 @@ re_search_stub (struct re_pattern_buffer *bufp,
438 else if (BE (last_start < 0 || (range < 0 && start <= last_start), 0)) 430 else if (BE (last_start < 0 || (range < 0 && start <= last_start), 0))
439 last_start = 0; 431 last_start = 0;
440 432
441 __libc_lock_lock (dfa->lock); 433 lock_lock (dfa->lock);
442 434
443 eflags |= (bufp->not_bol) ? REG_NOTBOL : 0; 435 eflags |= (bufp->not_bol) ? REG_NOTBOL : 0;
444 eflags |= (bufp->not_eol) ? REG_NOTEOL : 0; 436 eflags |= (bufp->not_eol) ? REG_NOTEOL : 0;
@@ -478,9 +470,9 @@ re_search_stub (struct re_pattern_buffer *bufp,
478 470
479 rval = 0; 471 rval = 0;
480 472
481 /* I hope we needn't fill ther regs with -1's when no match was found. */ 473 /* I hope we needn't fill their regs with -1's when no match was found. */
482 if (result != REG_NOERROR) 474 if (result != REG_NOERROR)
483 rval = -1; 475 rval = result == REG_NOMATCH ? -1 : -2;
484 else if (regs != NULL) 476 else if (regs != NULL)
485 { 477 {
486 /* If caller wants register contents data back, copy them. */ 478 /* If caller wants register contents data back, copy them. */
@@ -502,19 +494,18 @@ re_search_stub (struct re_pattern_buffer *bufp,
502 } 494 }
503 re_free (pmatch); 495 re_free (pmatch);
504 out: 496 out:
505 __libc_lock_unlock (dfa->lock); 497 lock_unlock (dfa->lock);
506 return rval; 498 return rval;
507} 499}
508 500
509static unsigned int 501static unsigned
510internal_function
511re_copy_regs (struct re_registers *regs, regmatch_t *pmatch, Idx nregs, 502re_copy_regs (struct re_registers *regs, regmatch_t *pmatch, Idx nregs,
512 int regs_allocated) 503 int regs_allocated)
513{ 504{
514 int rval = REGS_REALLOCATE; 505 int rval = REGS_REALLOCATE;
515 Idx i; 506 Idx i;
516 Idx need_regs = nregs + 1; 507 Idx need_regs = nregs + 1;
517 /* We need one extra element beyond `num_regs' for the `-1' marker GNU code 508 /* We need one extra element beyond 'num_regs' for the '-1' marker GNU code
518 uses. */ 509 uses. */
519 510
520 /* Have the register data arrays been allocated? */ 511 /* Have the register data arrays been allocated? */
@@ -637,7 +628,7 @@ re_exec (s)
637 (0 <= LAST_START && LAST_START <= LENGTH) */ 628 (0 <= LAST_START && LAST_START <= LENGTH) */
638 629
639static reg_errcode_t 630static reg_errcode_t
640internal_function __attribute_warn_unused_result__ 631__attribute_warn_unused_result__
641re_search_internal (const regex_t *preg, 632re_search_internal (const regex_t *preg,
642 const char *string, Idx length, 633 const char *string, Idx length,
643 Idx start, Idx last_start, Idx stop, 634 Idx start, Idx last_start, Idx stop,
@@ -645,7 +636,7 @@ re_search_internal (const regex_t *preg,
645 int eflags) 636 int eflags)
646{ 637{
647 reg_errcode_t err; 638 reg_errcode_t err;
648 const re_dfa_t *dfa = (const re_dfa_t *) preg->buffer; 639 const re_dfa_t *dfa = preg->buffer;
649 Idx left_lim, right_lim; 640 Idx left_lim, right_lim;
650 int incr; 641 int incr;
651 bool fl_longest_match; 642 bool fl_longest_match;
@@ -720,7 +711,8 @@ re_search_internal (const regex_t *preg,
720 if (nmatch > 1 || dfa->has_mb_node) 711 if (nmatch > 1 || dfa->has_mb_node)
721 { 712 {
722 /* Avoid overflow. */ 713 /* Avoid overflow. */
723 if (BE (SIZE_MAX / sizeof (re_dfastate_t *) <= mctx.input.bufs_len, 0)) 714 if (BE ((MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *))
715 <= mctx.input.bufs_len), 0))
724 { 716 {
725 err = REG_ESPACE; 717 err = REG_ESPACE;
726 goto free_return; 718 goto free_return;
@@ -740,7 +732,7 @@ re_search_internal (const regex_t *preg,
740 mctx.input.tip_context = (eflags & REG_NOTBOL) ? CONTEXT_BEGBUF 732 mctx.input.tip_context = (eflags & REG_NOTBOL) ? CONTEXT_BEGBUF
741 : CONTEXT_NEWLINE | CONTEXT_BEGBUF; 733 : CONTEXT_NEWLINE | CONTEXT_BEGBUF;
742 734
743 /* Check incrementally whether of not the input string match. */ 735 /* Check incrementally whether the input string matches. */
744 incr = (last_start < start) ? -1 : 1; 736 incr = (last_start < start) ? -1 : 1;
745 left_lim = (last_start < start) ? last_start : start; 737 left_lim = (last_start < start) ? last_start : start;
746 right_lim = (last_start < start) ? start : last_start; 738 right_lim = (last_start < start) ? start : last_start;
@@ -922,7 +914,7 @@ re_search_internal (const regex_t *preg,
922 goto free_return; 914 goto free_return;
923 } 915 }
924 916
925 /* At last, add the offset to the each registers, since we slided 917 /* At last, add the offset to each register, since we slid
926 the buffers so that we could assume that the matching starts 918 the buffers so that we could assume that the matching starts
927 from 0. */ 919 from 0. */
928 for (reg_idx = 0; reg_idx < nmatch; ++reg_idx) 920 for (reg_idx = 0; reg_idx < nmatch; ++reg_idx)
@@ -972,7 +964,7 @@ re_search_internal (const regex_t *preg,
972} 964}
973 965
974static reg_errcode_t 966static reg_errcode_t
975internal_function __attribute_warn_unused_result__ 967__attribute_warn_unused_result__
976prune_impossible_nodes (re_match_context_t *mctx) 968prune_impossible_nodes (re_match_context_t *mctx)
977{ 969{
978 const re_dfa_t *const dfa = mctx->dfa; 970 const re_dfa_t *const dfa = mctx->dfa;
@@ -988,7 +980,7 @@ prune_impossible_nodes (re_match_context_t *mctx)
988 halt_node = mctx->last_node; 980 halt_node = mctx->last_node;
989 981
990 /* Avoid overflow. */ 982 /* Avoid overflow. */
991 if (BE (SIZE_MAX / sizeof (re_dfastate_t *) <= match_last, 0)) 983 if (BE (MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *)) <= match_last, 0))
992 return REG_ESPACE; 984 return REG_ESPACE;
993 985
994 sifted_states = re_malloc (re_dfastate_t *, match_last + 1); 986 sifted_states = re_malloc (re_dfastate_t *, match_last + 1);
@@ -1068,7 +1060,7 @@ prune_impossible_nodes (re_match_context_t *mctx)
1068 since initial states may have constraints like "\<", "^", etc.. */ 1060 since initial states may have constraints like "\<", "^", etc.. */
1069 1061
1070static inline re_dfastate_t * 1062static inline re_dfastate_t *
1071__attribute ((always_inline)) internal_function 1063__attribute__ ((always_inline)) internal_function
1072acquire_init_state_context (reg_errcode_t *err, const re_match_context_t *mctx, 1064acquire_init_state_context (reg_errcode_t *err, const re_match_context_t *mctx,
1073 Idx idx) 1065 Idx idx)
1074{ 1066{
@@ -1106,7 +1098,7 @@ acquire_init_state_context (reg_errcode_t *err, const re_match_context_t *mctx,
1106 FL_LONGEST_MATCH means we want the POSIX longest matching. 1098 FL_LONGEST_MATCH means we want the POSIX longest matching.
1107 If P_MATCH_FIRST is not NULL, and the match fails, it is set to the 1099 If P_MATCH_FIRST is not NULL, and the match fails, it is set to the
1108 next place where we may want to try matching. 1100 next place where we may want to try matching.
1109 Note that the matcher assume that the maching starts from the current 1101 Note that the matcher assumes that the matching starts from the current
1110 index of the buffer. */ 1102 index of the buffer. */
1111 1103
1112static Idx 1104static Idx
@@ -1175,11 +1167,12 @@ check_matching (re_match_context_t *mctx, bool fl_longest_match,
1175 re_dfastate_t *old_state = cur_state; 1167 re_dfastate_t *old_state = cur_state;
1176 Idx next_char_idx = re_string_cur_idx (&mctx->input) + 1; 1168 Idx next_char_idx = re_string_cur_idx (&mctx->input) + 1;
1177 1169
1178 if (BE (next_char_idx >= mctx->input.bufs_len, 0) 1170 if ((BE (next_char_idx >= mctx->input.bufs_len, 0)
1171 && mctx->input.bufs_len < mctx->input.len)
1179 || (BE (next_char_idx >= mctx->input.valid_len, 0) 1172 || (BE (next_char_idx >= mctx->input.valid_len, 0)
1180 && mctx->input.valid_len < mctx->input.len)) 1173 && mctx->input.valid_len < mctx->input.len))
1181 { 1174 {
1182 err = extend_buffers (mctx); 1175 err = extend_buffers (mctx, next_char_idx + 1);
1183 if (BE (err != REG_NOERROR, 0)) 1176 if (BE (err != REG_NOERROR, 0))
1184 { 1177 {
1185 assert (err == REG_ESPACE); 1178 assert (err == REG_ESPACE);
@@ -1436,7 +1429,7 @@ internal_function __attribute_warn_unused_result__
1436set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch, 1429set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch,
1437 regmatch_t *pmatch, bool fl_backtrack) 1430 regmatch_t *pmatch, bool fl_backtrack)
1438{ 1431{
1439 const re_dfa_t *dfa = (const re_dfa_t *) preg->buffer; 1432 const re_dfa_t *dfa = preg->buffer;
1440 Idx idx, cur_node; 1433 Idx idx, cur_node;
1441 re_node_set eps_via_nodes; 1434 re_node_set eps_via_nodes;
1442 struct re_fail_stack_t *fs; 1435 struct re_fail_stack_t *fs;
@@ -1608,21 +1601,21 @@ update_regs (const re_dfa_t *dfa, regmatch_t *pmatch,
1608 and sift the nodes in each states according to the following rules. 1601 and sift the nodes in each states according to the following rules.
1609 Updated state_log will be wrote to STATE_LOG. 1602 Updated state_log will be wrote to STATE_LOG.
1610 1603
1611 Rules: We throw away the Node `a' in the STATE_LOG[STR_IDX] if... 1604 Rules: We throw away the Node 'a' in the STATE_LOG[STR_IDX] if...
1612 1. When STR_IDX == MATCH_LAST(the last index in the state_log): 1605 1. When STR_IDX == MATCH_LAST(the last index in the state_log):
1613 If `a' isn't the LAST_NODE and `a' can't epsilon transit to 1606 If 'a' isn't the LAST_NODE and 'a' can't epsilon transit to
1614 the LAST_NODE, we throw away the node `a'. 1607 the LAST_NODE, we throw away the node 'a'.
1615 2. When 0 <= STR_IDX < MATCH_LAST and `a' accepts 1608 2. When 0 <= STR_IDX < MATCH_LAST and 'a' accepts
1616 string `s' and transit to `b': 1609 string 's' and transit to 'b':
1617 i. If 'b' isn't in the STATE_LOG[STR_IDX+strlen('s')], we throw 1610 i. If 'b' isn't in the STATE_LOG[STR_IDX+strlen('s')], we throw
1618 away the node `a'. 1611 away the node 'a'.
1619 ii. If 'b' is in the STATE_LOG[STR_IDX+strlen('s')] but 'b' is 1612 ii. If 'b' is in the STATE_LOG[STR_IDX+strlen('s')] but 'b' is
1620 thrown away, we throw away the node `a'. 1613 thrown away, we throw away the node 'a'.
1621 3. When 0 <= STR_IDX < MATCH_LAST and 'a' epsilon transit to 'b': 1614 3. When 0 <= STR_IDX < MATCH_LAST and 'a' epsilon transit to 'b':
1622 i. If 'b' isn't in the STATE_LOG[STR_IDX], we throw away the 1615 i. If 'b' isn't in the STATE_LOG[STR_IDX], we throw away the
1623 node `a'. 1616 node 'a'.
1624 ii. If 'b' is in the STATE_LOG[STR_IDX] but 'b' is thrown away, 1617 ii. If 'b' is in the STATE_LOG[STR_IDX] but 'b' is thrown away,
1625 we throw away the node `a'. */ 1618 we throw away the node 'a'. */
1626 1619
1627#define STATE_NODE_CONTAINS(state,node) \ 1620#define STATE_NODE_CONTAINS(state,node) \
1628 ((state) != NULL && re_node_set_contains (&(state)->nodes, node)) 1621 ((state) != NULL && re_node_set_contains (&(state)->nodes, node))
@@ -1695,11 +1688,11 @@ build_sifted_states (const re_match_context_t *mctx, re_sift_context_t *sctx,
1695 Idx i; 1688 Idx i;
1696 1689
1697 /* Then build the next sifted state. 1690 /* Then build the next sifted state.
1698 We build the next sifted state on `cur_dest', and update 1691 We build the next sifted state on 'cur_dest', and update
1699 `sifted_states[str_idx]' with `cur_dest'. 1692 'sifted_states[str_idx]' with 'cur_dest'.
1700 Note: 1693 Note:
1701 `cur_dest' is the sifted state from `state_log[str_idx + 1]'. 1694 'cur_dest' is the sifted state from 'state_log[str_idx + 1]'.
1702 `cur_src' points the node_set of the old `state_log[str_idx]' 1695 'cur_src' points the node_set of the old 'state_log[str_idx]'
1703 (with the epsilon nodes pre-filtered out). */ 1696 (with the epsilon nodes pre-filtered out). */
1704 for (i = 0; i < cur_src->nelem; i++) 1697 for (i = 0; i < cur_src->nelem; i++)
1705 { 1698 {
@@ -1712,7 +1705,7 @@ build_sifted_states (const re_match_context_t *mctx, re_sift_context_t *sctx,
1712 assert (!IS_EPSILON_NODE (type)); 1705 assert (!IS_EPSILON_NODE (type));
1713#endif 1706#endif
1714#ifdef RE_ENABLE_I18N 1707#ifdef RE_ENABLE_I18N
1715 /* If the node may accept `multi byte'. */ 1708 /* If the node may accept "multi byte". */
1716 if (dfa->nodes[prev_node].accept_mb) 1709 if (dfa->nodes[prev_node].accept_mb)
1717 naccepted = sift_states_iter_mb (mctx, sctx, prev_node, 1710 naccepted = sift_states_iter_mb (mctx, sctx, prev_node,
1718 str_idx, sctx->last_str_idx); 1711 str_idx, sctx->last_str_idx);
@@ -1753,12 +1746,13 @@ clean_state_log_if_needed (re_match_context_t *mctx, Idx next_state_log_idx)
1753{ 1746{
1754 Idx top = mctx->state_log_top; 1747 Idx top = mctx->state_log_top;
1755 1748
1756 if (next_state_log_idx >= mctx->input.bufs_len 1749 if ((next_state_log_idx >= mctx->input.bufs_len
1750 && mctx->input.bufs_len < mctx->input.len)
1757 || (next_state_log_idx >= mctx->input.valid_len 1751 || (next_state_log_idx >= mctx->input.valid_len
1758 && mctx->input.valid_len < mctx->input.len)) 1752 && mctx->input.valid_len < mctx->input.len))
1759 { 1753 {
1760 reg_errcode_t err; 1754 reg_errcode_t err;
1761 err = extend_buffers (mctx); 1755 err = extend_buffers (mctx, next_state_log_idx + 1);
1762 if (BE (err != REG_NOERROR, 0)) 1756 if (BE (err != REG_NOERROR, 0))
1763 return err; 1757 return err;
1764 } 1758 }
@@ -2268,17 +2262,17 @@ sift_states_iter_mb (const re_match_context_t *mctx, re_sift_context_t *sctx,
2268{ 2262{
2269 const re_dfa_t *const dfa = mctx->dfa; 2263 const re_dfa_t *const dfa = mctx->dfa;
2270 int naccepted; 2264 int naccepted;
2271 /* Check the node can accept `multi byte'. */ 2265 /* Check the node can accept "multi byte". */
2272 naccepted = check_node_accept_bytes (dfa, node_idx, &mctx->input, str_idx); 2266 naccepted = check_node_accept_bytes (dfa, node_idx, &mctx->input, str_idx);
2273 if (naccepted > 0 && str_idx + naccepted <= max_str_idx && 2267 if (naccepted > 0 && str_idx + naccepted <= max_str_idx &&
2274 !STATE_NODE_CONTAINS (sctx->sifted_states[str_idx + naccepted], 2268 !STATE_NODE_CONTAINS (sctx->sifted_states[str_idx + naccepted],
2275 dfa->nexts[node_idx])) 2269 dfa->nexts[node_idx]))
2276 /* The node can't accept the `multi byte', or the 2270 /* The node can't accept the "multi byte", or the
2277 destination was already thrown away, then the node 2271 destination was already thrown away, then the node
2278 could't accept the current input `multi byte'. */ 2272 could't accept the current input "multi byte". */
2279 naccepted = 0; 2273 naccepted = 0;
2280 /* Otherwise, it is sure that the node could accept 2274 /* Otherwise, it is sure that the node could accept
2281 `naccepted' bytes input. */ 2275 'naccepted' bytes input. */
2282 return naccepted; 2276 return naccepted;
2283} 2277}
2284#endif /* RE_ENABLE_I18N */ 2278#endif /* RE_ENABLE_I18N */
@@ -2457,7 +2451,7 @@ find_recover_state (reg_errcode_t *err, re_match_context_t *mctx)
2457/* From the node set CUR_NODES, pick up the nodes whose types are 2451/* From the node set CUR_NODES, pick up the nodes whose types are
2458 OP_OPEN_SUBEXP and which have corresponding back references in the regular 2452 OP_OPEN_SUBEXP and which have corresponding back references in the regular
2459 expression. And register them to use them later for evaluating the 2453 expression. And register them to use them later for evaluating the
2460 correspoding back references. */ 2454 corresponding back references. */
2461 2455
2462static reg_errcode_t 2456static reg_errcode_t
2463internal_function 2457internal_function
@@ -2568,7 +2562,7 @@ transit_state_mb (re_match_context_t *mctx, re_dfastate_t *pstate)
2568 if (naccepted == 0) 2562 if (naccepted == 0)
2569 continue; 2563 continue;
2570 2564
2571 /* The node can accepts `naccepted' bytes. */ 2565 /* The node can accepts 'naccepted' bytes. */
2572 dest_idx = re_string_cur_idx (&mctx->input) + naccepted; 2566 dest_idx = re_string_cur_idx (&mctx->input) + naccepted;
2573 mctx->max_mb_elem_len = ((mctx->max_mb_elem_len < naccepted) ? naccepted 2567 mctx->max_mb_elem_len = ((mctx->max_mb_elem_len < naccepted) ? naccepted
2574 : mctx->max_mb_elem_len); 2568 : mctx->max_mb_elem_len);
@@ -2620,7 +2614,7 @@ transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes)
2620 const re_token_t *node = dfa->nodes + node_idx; 2614 const re_token_t *node = dfa->nodes + node_idx;
2621 re_node_set *new_dest_nodes; 2615 re_node_set *new_dest_nodes;
2622 2616
2623 /* Check whether `node' is a backreference or not. */ 2617 /* Check whether 'node' is a backreference or not. */
2624 if (node->type != OP_BACK_REF) 2618 if (node->type != OP_BACK_REF)
2625 continue; 2619 continue;
2626 2620
@@ -2632,14 +2626,14 @@ transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes)
2632 continue; 2626 continue;
2633 } 2627 }
2634 2628
2635 /* `node' is a backreference. 2629 /* 'node' is a backreference.
2636 Check the substring which the substring matched. */ 2630 Check the substring which the substring matched. */
2637 bkc_idx = mctx->nbkref_ents; 2631 bkc_idx = mctx->nbkref_ents;
2638 err = get_subexp (mctx, node_idx, cur_str_idx); 2632 err = get_subexp (mctx, node_idx, cur_str_idx);
2639 if (BE (err != REG_NOERROR, 0)) 2633 if (BE (err != REG_NOERROR, 0))
2640 goto free_return; 2634 goto free_return;
2641 2635
2642 /* And add the epsilon closures (which is `new_dest_nodes') of 2636 /* And add the epsilon closures (which is 'new_dest_nodes') of
2643 the backreference to appropriate state_log. */ 2637 the backreference to appropriate state_log. */
2644#ifdef DEBUG 2638#ifdef DEBUG
2645 assert (dfa->nexts[node_idx] != REG_MISSING); 2639 assert (dfa->nexts[node_idx] != REG_MISSING);
@@ -2663,7 +2657,7 @@ transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes)
2663 dest_state = mctx->state_log[dest_str_idx]; 2657 dest_state = mctx->state_log[dest_str_idx];
2664 prev_nelem = ((mctx->state_log[cur_str_idx] == NULL) ? 0 2658 prev_nelem = ((mctx->state_log[cur_str_idx] == NULL) ? 0
2665 : mctx->state_log[cur_str_idx]->nodes.nelem); 2659 : mctx->state_log[cur_str_idx]->nodes.nelem);
2666 /* Add `new_dest_node' to state_log. */ 2660 /* Add 'new_dest_node' to state_log. */
2667 if (dest_state == NULL) 2661 if (dest_state == NULL)
2668 { 2662 {
2669 mctx->state_log[dest_str_idx] 2663 mctx->state_log[dest_str_idx]
@@ -2815,7 +2809,7 @@ get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx bkref_str_idx)
2815 if (bkref_str_off >= mctx->input.len) 2809 if (bkref_str_off >= mctx->input.len)
2816 break; 2810 break;
2817 2811
2818 err = extend_buffers (mctx); 2812 err = extend_buffers (mctx, bkref_str_off + 1);
2819 if (BE (err != REG_NOERROR, 0)) 2813 if (BE (err != REG_NOERROR, 0))
2820 return err; 2814 return err;
2821 2815
@@ -2937,9 +2931,12 @@ check_arrival (re_match_context_t *mctx, state_array_t *path, Idx top_node,
2937 { 2931 {
2938 re_dfastate_t **new_array; 2932 re_dfastate_t **new_array;
2939 Idx old_alloc = path->alloc; 2933 Idx old_alloc = path->alloc;
2940 Idx new_alloc = old_alloc + last_str + mctx->max_mb_elem_len + 1; 2934 Idx incr_alloc = last_str + mctx->max_mb_elem_len + 1;
2941 if (BE (new_alloc < old_alloc, 0) 2935 Idx new_alloc;
2942 || BE (SIZE_MAX / sizeof (re_dfastate_t *) < new_alloc, 0)) 2936 if (BE (IDX_MAX - old_alloc < incr_alloc, 0))
2937 return REG_ESPACE;
2938 new_alloc = old_alloc + incr_alloc;
2939 if (BE (SIZE_MAX / sizeof (re_dfastate_t *) < new_alloc, 0))
2943 return REG_ESPACE; 2940 return REG_ESPACE;
2944 new_array = re_realloc (path->array, re_dfastate_t *, new_alloc); 2941 new_array = re_realloc (path->array, re_dfastate_t *, new_alloc);
2945 if (BE (new_array == NULL, 0)) 2942 if (BE (new_array == NULL, 0))
@@ -3102,7 +3099,7 @@ check_arrival_add_next_nodes (re_match_context_t *mctx, Idx str_idx,
3102 assert (!IS_EPSILON_NODE (type)); 3099 assert (!IS_EPSILON_NODE (type));
3103#endif 3100#endif
3104#ifdef RE_ENABLE_I18N 3101#ifdef RE_ENABLE_I18N
3105 /* If the node may accept `multi byte'. */ 3102 /* If the node may accept "multi byte". */
3106 if (dfa->nodes[cur_node].accept_mb) 3103 if (dfa->nodes[cur_node].accept_mb)
3107 { 3104 {
3108 naccepted = check_node_accept_bytes (dfa, cur_node, &mctx->input, 3105 naccepted = check_node_accept_bytes (dfa, cur_node, &mctx->input,
@@ -3359,7 +3356,7 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
3359 bitset_word_t elem, mask; 3356 bitset_word_t elem, mask;
3360 bool dests_node_malloced = false; 3357 bool dests_node_malloced = false;
3361 bool dest_states_malloced = false; 3358 bool dest_states_malloced = false;
3362 Idx ndests; /* Number of the destination states from `state'. */ 3359 Idx ndests; /* Number of the destination states from 'state'. */
3363 re_dfastate_t **trtable; 3360 re_dfastate_t **trtable;
3364 re_dfastate_t **dest_states = NULL, **dest_states_word, **dest_states_nl; 3361 re_dfastate_t **dest_states = NULL, **dest_states_word, **dest_states_nl;
3365 re_node_set follows, *dests_node; 3362 re_node_set follows, *dests_node;
@@ -3373,8 +3370,8 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
3373 } *dests_alloc; 3370 } *dests_alloc;
3374 3371
3375 /* We build DFA states which corresponds to the destination nodes 3372 /* We build DFA states which corresponds to the destination nodes
3376 from `state'. `dests_node[i]' represents the nodes which i-th 3373 from 'state'. 'dests_node[i]' represents the nodes which i-th
3377 destination state contains, and `dests_ch[i]' represents the 3374 destination state contains, and 'dests_ch[i]' represents the
3378 characters which i-th destination state accepts. */ 3375 characters which i-th destination state accepts. */
3379 if (__libc_use_alloca (sizeof (struct dests_alloc))) 3376 if (__libc_use_alloca (sizeof (struct dests_alloc)))
3380 dests_alloc = (struct dests_alloc *) alloca (sizeof (struct dests_alloc)); 3377 dests_alloc = (struct dests_alloc *) alloca (sizeof (struct dests_alloc));
@@ -3388,20 +3385,23 @@ build_trtable (const re_dfa_t *dfa, re_dfastate_t *state)
3388 dests_node = dests_alloc->dests_node; 3385 dests_node = dests_alloc->dests_node;
3389 dests_ch = dests_alloc->dests_ch; 3386 dests_ch = dests_alloc->dests_ch;
3390 3387
3391 /* Initialize transiton table. */ 3388 /* Initialize transition table. */
3392 state->word_trtable = state->trtable = NULL; 3389 state->word_trtable = state->trtable = NULL;
3393 3390
3394 /* At first, group all nodes belonging to `state' into several 3391 /* At first, group all nodes belonging to 'state' into several
3395 destinations. */ 3392 destinations. */
3396 ndests = group_nodes_into_DFAstates (dfa, state, dests_node, dests_ch); 3393 ndests = group_nodes_into_DFAstates (dfa, state, dests_node, dests_ch);
3397 if (BE (! REG_VALID_NONZERO_INDEX (ndests), 0)) 3394 if (BE (! REG_VALID_NONZERO_INDEX (ndests), 0))
3398 { 3395 {
3399 if (dests_node_malloced) 3396 if (dests_node_malloced)
3400 free (dests_alloc); 3397 free (dests_alloc);
3398 /* Return false in case of an error, true otherwise. */
3401 if (ndests == 0) 3399 if (ndests == 0)
3402 { 3400 {
3403 state->trtable = (re_dfastate_t **) 3401 state->trtable = (re_dfastate_t **)
3404 calloc (sizeof (re_dfastate_t *), SBC_MAX); 3402 calloc (sizeof (re_dfastate_t *), SBC_MAX);
3403 if (BE (state->trtable == NULL, 0))
3404 return false;
3405 return true; 3405 return true;
3406 } 3406 }
3407 return false; 3407 return false;
@@ -3591,13 +3591,13 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
3591 reg_errcode_t err; 3591 reg_errcode_t err;
3592 bool ok; 3592 bool ok;
3593 Idx i, j, k; 3593 Idx i, j, k;
3594 Idx ndests; /* Number of the destinations from `state'. */ 3594 Idx ndests; /* Number of the destinations from 'state'. */
3595 bitset_t accepts; /* Characters a node can accept. */ 3595 bitset_t accepts; /* Characters a node can accept. */
3596 const re_node_set *cur_nodes = &state->nodes; 3596 const re_node_set *cur_nodes = &state->nodes;
3597 bitset_empty (accepts); 3597 bitset_empty (accepts);
3598 ndests = 0; 3598 ndests = 0;
3599 3599
3600 /* For all the nodes belonging to `state', */ 3600 /* For all the nodes belonging to 'state', */
3601 for (i = 0; i < cur_nodes->nelem; ++i) 3601 for (i = 0; i < cur_nodes->nelem; ++i)
3602 { 3602 {
3603 re_token_t *node = &dfa->nodes[cur_nodes->elems[i]]; 3603 re_token_t *node = &dfa->nodes[cur_nodes->elems[i]];
@@ -3640,7 +3640,7 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
3640 else 3640 else
3641 continue; 3641 continue;
3642 3642
3643 /* Check the `accepts' and sift the characters which are not 3643 /* Check the 'accepts' and sift the characters which are not
3644 match it the context. */ 3644 match it the context. */
3645 if (constraint) 3645 if (constraint)
3646 { 3646 {
@@ -3699,7 +3699,7 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
3699 } 3699 }
3700 } 3700 }
3701 3701
3702 /* Then divide `accepts' into DFA states, or create a new 3702 /* Then divide 'accepts' into DFA states, or create a new
3703 state. Above, we make sure that accepts is not empty. */ 3703 state. Above, we make sure that accepts is not empty. */
3704 for (j = 0; j < ndests; ++j) 3704 for (j = 0; j < ndests; ++j)
3705 { 3705 {
@@ -3712,7 +3712,7 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
3712 if (type == CHARACTER && !bitset_contain (dests_ch[j], node->opr.c)) 3712 if (type == CHARACTER && !bitset_contain (dests_ch[j], node->opr.c))
3713 continue; 3713 continue;
3714 3714
3715 /* Enumerate the intersection set of this state and `accepts'. */ 3715 /* Enumerate the intersection set of this state and 'accepts'. */
3716 has_intersec = 0; 3716 has_intersec = 0;
3717 for (k = 0; k < BITSET_WORDS; ++k) 3717 for (k = 0; k < BITSET_WORDS; ++k)
3718 has_intersec |= intersec[k] = accepts[k] & dests_ch[j][k]; 3718 has_intersec |= intersec[k] = accepts[k] & dests_ch[j][k];
@@ -3720,7 +3720,7 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
3720 if (!has_intersec) 3720 if (!has_intersec)
3721 continue; 3721 continue;
3722 3722
3723 /* Then check if this state is a subset of `accepts'. */ 3723 /* Then check if this state is a subset of 'accepts'. */
3724 not_subset = not_consumed = 0; 3724 not_subset = not_consumed = 0;
3725 for (k = 0; k < BITSET_WORDS; ++k) 3725 for (k = 0; k < BITSET_WORDS; ++k)
3726 { 3726 {
@@ -3728,8 +3728,8 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
3728 not_consumed |= accepts[k] = accepts[k] & ~dests_ch[j][k]; 3728 not_consumed |= accepts[k] = accepts[k] & ~dests_ch[j][k];
3729 } 3729 }
3730 3730
3731 /* If this state isn't a subset of `accepts', create a 3731 /* If this state isn't a subset of 'accepts', create a
3732 new group state, which has the `remains'. */ 3732 new group state, which has the 'remains'. */
3733 if (not_subset) 3733 if (not_subset)
3734 { 3734 {
3735 bitset_copy (dests_ch[ndests], remains); 3735 bitset_copy (dests_ch[ndests], remains);
@@ -3768,7 +3768,7 @@ group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state,
3768} 3768}
3769 3769
3770#ifdef RE_ENABLE_I18N 3770#ifdef RE_ENABLE_I18N
3771/* Check how many bytes the node `dfa->nodes[node_idx]' accepts. 3771/* Check how many bytes the node 'dfa->nodes[node_idx]' accepts.
3772 Return the number of the bytes the node accepts. 3772 Return the number of the bytes the node accepts.
3773 STR_IDX is the current index of the input string. 3773 STR_IDX is the current index of the input string.
3774 3774
@@ -3895,7 +3895,6 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
3895 const int32_t *table, *indirect; 3895 const int32_t *table, *indirect;
3896 const unsigned char *weights, *extra; 3896 const unsigned char *weights, *extra;
3897 const char *collseqwc; 3897 const char *collseqwc;
3898 int32_t idx;
3899 /* This #include defines a local function! */ 3898 /* This #include defines a local function! */
3900# include <locale/weight.h> 3899# include <locale/weight.h>
3901 3900
@@ -3933,6 +3932,7 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
3933 in_collseq = find_collation_sequence_value (pin, elem_len); 3932 in_collseq = find_collation_sequence_value (pin, elem_len);
3934 } 3933 }
3935 /* match with range expression? */ 3934 /* match with range expression? */
3935 /* FIXME: Implement rational ranges here, too. */
3936 for (i = 0; i < cset->nranges; ++i) 3936 for (i = 0; i < cset->nranges; ++i)
3937 if (cset->range_starts[i] <= in_collseq 3937 if (cset->range_starts[i] <= in_collseq
3938 && in_collseq <= cset->range_ends[i]) 3938 && in_collseq <= cset->range_ends[i])
@@ -3953,7 +3953,7 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
3953 _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB); 3953 _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB);
3954 indirect = (const int32_t *) 3954 indirect = (const int32_t *)
3955 _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB); 3955 _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB);
3956 int32_t idx = findidx (&cp); 3956 int32_t idx = findidx (&cp, elem_len);
3957 if (idx > 0) 3957 if (idx > 0)
3958 for (i = 0; i < cset->nequiv_classes; ++i) 3958 for (i = 0; i < cset->nequiv_classes; ++i)
3959 { 3959 {
@@ -3984,18 +3984,9 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx node_idx,
3984# endif /* _LIBC */ 3984# endif /* _LIBC */
3985 { 3985 {
3986 /* match with range expression? */ 3986 /* match with range expression? */
3987#if __GNUC__ >= 2 && ! (__STDC_VERSION__ < 199901L && __STRICT_ANSI__)
3988 wchar_t cmp_buf[] = {L'\0', L'\0', wc, L'\0', L'\0', L'\0'};
3989#else
3990 wchar_t cmp_buf[] = {L'\0', L'\0', L'\0', L'\0', L'\0', L'\0'};
3991 cmp_buf[2] = wc;
3992#endif
3993 for (i = 0; i < cset->nranges; ++i) 3987 for (i = 0; i < cset->nranges; ++i)
3994 { 3988 {
3995 cmp_buf[0] = cset->range_starts[i]; 3989 if (cset->range_starts[i] <= wc && wc <= cset->range_ends[i])
3996 cmp_buf[4] = cset->range_ends[i];
3997 if (wcscoll (cmp_buf, cmp_buf + 2) <= 0
3998 && wcscoll (cmp_buf + 2, cmp_buf + 4) <= 0)
3999 { 3990 {
4000 match_len = char_len; 3991 match_len = char_len;
4001 goto check_node_accept_bytes_match; 3992 goto check_node_accept_bytes_match;
@@ -4065,7 +4056,7 @@ find_collation_sequence_value (const unsigned char *mbs, size_t mbs_len)
4065 /* Skip the collation sequence value. */ 4056 /* Skip the collation sequence value. */
4066 idx += sizeof (uint32_t); 4057 idx += sizeof (uint32_t);
4067 /* Skip the wide char sequence of the collating element. */ 4058 /* Skip the wide char sequence of the collating element. */
4068 idx = idx + sizeof (uint32_t) * (extra[idx] + 1); 4059 idx = idx + sizeof (uint32_t) * (*(int32_t *) (extra + idx) + 1);
4069 /* If we found the entry, return the sequence value. */ 4060 /* If we found the entry, return the sequence value. */
4070 if (found) 4061 if (found)
4071 return *(uint32_t *) (extra + idx); 4062 return *(uint32_t *) (extra + idx);
@@ -4133,17 +4124,20 @@ check_node_accept (const re_match_context_t *mctx, const re_token_t *node,
4133 4124
4134static reg_errcode_t 4125static reg_errcode_t
4135internal_function __attribute_warn_unused_result__ 4126internal_function __attribute_warn_unused_result__
4136extend_buffers (re_match_context_t *mctx) 4127extend_buffers (re_match_context_t *mctx, int min_len)
4137{ 4128{
4138 reg_errcode_t ret; 4129 reg_errcode_t ret;
4139 re_string_t *pstr = &mctx->input; 4130 re_string_t *pstr = &mctx->input;
4140 4131
4141 /* Avoid overflow. */ 4132 /* Avoid overflow. */
4142 if (BE (SIZE_MAX / 2 / sizeof (re_dfastate_t *) <= pstr->bufs_len, 0)) 4133 if (BE (MIN (IDX_MAX, SIZE_MAX / sizeof (re_dfastate_t *)) / 2
4134 <= pstr->bufs_len, 0))
4143 return REG_ESPACE; 4135 return REG_ESPACE;
4144 4136
4145 /* Double the lengthes of the buffers. */ 4137 /* Double the lengths of the buffers, but allocate at least MIN_LEN. */
4146 ret = re_string_realloc_buffers (pstr, pstr->bufs_len * 2); 4138 ret = re_string_realloc_buffers (pstr,
4139 MAX (min_len,
4140 MIN (pstr->len, pstr->bufs_len * 2)));
4147 if (BE (ret != REG_NOERROR, 0)) 4141 if (BE (ret != REG_NOERROR, 0))
4148 return ret; 4142 return ret;
4149 4143
@@ -4206,7 +4200,7 @@ match_ctx_init (re_match_context_t *mctx, int eflags, Idx n)
4206 size_t max_object_size = 4200 size_t max_object_size =
4207 MAX (sizeof (struct re_backref_cache_entry), 4201 MAX (sizeof (struct re_backref_cache_entry),
4208 sizeof (re_sub_match_top_t *)); 4202 sizeof (re_sub_match_top_t *));
4209 if (BE (SIZE_MAX / max_object_size < n, 0)) 4203 if (BE (MIN (IDX_MAX, SIZE_MAX / max_object_size) < n, 0))
4210 return REG_ESPACE; 4204 return REG_ESPACE;
4211 4205
4212 mctx->bkref_ents = re_malloc (struct re_backref_cache_entry, n); 4206 mctx->bkref_ents = re_malloc (struct re_backref_cache_entry, n);
diff --git a/gl/safe-read.c b/gl/safe-read.c
index 855be67..6a48c0c 100644
--- a/gl/safe-read.c
+++ b/gl/safe-read.c
@@ -1,6 +1,6 @@
1/* An interface to read and write that retries after interrupts. 1/* An interface to read and write that retries after interrupts.
2 2
3 Copyright (C) 1993-1994, 1998, 2002-2006, 2009-2010 Free Software 3 Copyright (C) 1993-1994, 1998, 2002-2006, 2009-2013 Free Software
4 Foundation, Inc. 4 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
diff --git a/gl/safe-read.h b/gl/safe-read.h
index 1f15b01..992b7a6 100644
--- a/gl/safe-read.h
+++ b/gl/safe-read.h
@@ -1,5 +1,5 @@
1/* An interface to read() that retries after interrupts. 1/* An interface to read() that retries after interrupts.
2 Copyright (C) 2002, 2006, 2009-2010 Free Software Foundation, Inc. 2 Copyright (C) 2002, 2006, 2009-2013 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
@@ -14,6 +14,19 @@
14 You should have received a copy of the GNU General Public License 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/>. */ 15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
16 16
17/* Some system calls may be interrupted and fail with errno = EINTR in the
18 following situations:
19 - The process is stopped and restarted (signal SIGSTOP and SIGCONT, user
20 types Ctrl-Z) on some platforms: Mac OS X.
21 - The process receives a signal for which a signal handler was installed
22 with sigaction() with an sa_flags field that does not contain
23 SA_RESTART.
24 - The process receives a signal for which a signal handler was installed
25 with signal() and for which no call to siginterrupt(sig,0) was done,
26 on some platforms: AIX, HP-UX, IRIX, OSF/1, Solaris.
27
28 This module provides a wrapper around read() that handles EINTR. */
29
17#include <stddef.h> 30#include <stddef.h>
18 31
19#ifdef __cplusplus 32#ifdef __cplusplus
diff --git a/gl/safe-write.h b/gl/safe-write.h
deleted file mode 100644
index 185f660..0000000
--- a/gl/safe-write.h
+++ /dev/null
@@ -1,24 +0,0 @@
1/* An interface to write() that retries after interrupts.
2 Copyright (C) 2002, 2009-2010 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#include <stddef.h>
18
19#define SAFE_WRITE_ERROR ((size_t) -1)
20
21/* Write up to COUNT bytes at BUF to descriptor FD, retrying if interrupted.
22 Return the actual number of bytes written, zero for EOF, or SAFE_WRITE_ERROR
23 upon error. */
24extern size_t safe_write (int fd, const void *buf, size_t count);
diff --git a/gl/setenv.c b/gl/setenv.c
index ba760d6..995a0f2 100644
--- a/gl/setenv.c
+++ b/gl/setenv.c
@@ -1,4 +1,4 @@
1/* Copyright (C) 1992, 1995-2003, 2005-2010 Free Software Foundation, Inc. 1/* Copyright (C) 1992, 1995-2003, 2005-2013 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 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
@@ -15,12 +15,13 @@
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
16 16
17#if !_LIBC 17#if !_LIBC
18# include <config.h>
19#endif
20
21/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc 18/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc
22 optimizes away the name == NULL test below. */ 19 optimizes away the name == NULL test below. */
23#define _GL_ARG_NONNULL(params) 20# define _GL_ARG_NONNULL(params)
21
22# define _GL_USE_STDLIB_ALLOC 1
23# include <config.h>
24#endif
24 25
25#include <alloca.h> 26#include <alloca.h>
26 27
@@ -48,7 +49,7 @@
48#endif 49#endif
49 50
50#if _LIBC 51#if _LIBC
51/* This lock protects against simultaneous modifications of `environ'. */ 52/* This lock protects against simultaneous modifications of 'environ'. */
52# include <bits/libc-lock.h> 53# include <bits/libc-lock.h>
53__libc_lock_define_initialized (static, envlock) 54__libc_lock_define_initialized (static, envlock)
54# define LOCK __libc_lock_lock (envlock) 55# define LOCK __libc_lock_lock (envlock)
@@ -64,10 +65,6 @@ __libc_lock_define_initialized (static, envlock)
64# define clearenv __clearenv 65# define clearenv __clearenv
65# define tfind __tfind 66# define tfind __tfind
66# define tsearch __tsearch 67# define tsearch __tsearch
67#else
68/* Use the system functions, not the gnulib overrides in this file. */
69# undef malloc
70# undef realloc
71#endif 68#endif
72 69
73/* In the GNU C library implementation we try to be more clever and 70/* In the GNU C library implementation we try to be more clever and
@@ -106,11 +103,11 @@ static void *known_values;
106static char **last_environ; 103static char **last_environ;
107 104
108 105
109/* This function is used by `setenv' and `putenv'. The difference between 106/* This function is used by 'setenv' and 'putenv'. The difference between
110 the two functions is that for the former must create a new string which 107 the two functions is that for the former must create a new string which
111 is then placed in the environment, while the argument of `putenv' 108 is then placed in the environment, while the argument of 'putenv'
112 must be used directly. This is all complicated by the fact that we try 109 must be used directly. This is all complicated by the fact that we try
113 to reuse values once generated for a `setenv' call since we can never 110 to reuse values once generated for a 'setenv' call since we can never
114 free the strings. */ 111 free the strings. */
115int 112int
116__add_to_environ (const char *name, const char *value, const char *combined, 113__add_to_environ (const char *name, const char *value, const char *combined,
@@ -302,7 +299,7 @@ setenv (const char *name, const char *value, int replace)
302 return __add_to_environ (name, value, NULL, replace); 299 return __add_to_environ (name, value, NULL, replace);
303} 300}
304 301
305/* The `clearenv' was planned to be added to POSIX.1 but probably 302/* The 'clearenv' was planned to be added to POSIX.1 but probably
306 never made it. Nevertheless the POSIX.9 standard (POSIX bindings 303 never made it. Nevertheless the POSIX.9 standard (POSIX bindings
307 for Fortran 77) requires this function. */ 304 for Fortran 77) requires this function. */
308int 305int
@@ -353,6 +350,9 @@ weak_alias (__clearenv, clearenv)
353#if HAVE_SETENV 350#if HAVE_SETENV
354 351
355# undef setenv 352# undef setenv
353# if !HAVE_DECL_SETENV
354extern int setenv (const char *, const char *, int);
355# endif
356# define STREQ(a, b) (strcmp (a, b) == 0) 356# define STREQ(a, b) (strcmp (a, b) == 0)
357 357
358int 358int
diff --git a/gl/sha1.c b/gl/sha1.c
index 7251ca8..778389a 100644
--- a/gl/sha1.c
+++ b/gl/sha1.c
@@ -1,8 +1,7 @@
1/* sha1.c - Functions to compute SHA1 message digest of files or 1/* sha1.c - Functions to compute SHA1 message digest of files or
2 memory blocks according to the NIST specification FIPS-180-1. 2 memory blocks according to the NIST specification FIPS-180-1.
3 3
4 Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006, 2008, 2009, 2010 Free 4 Copyright (C) 2000-2001, 2003-2006, 2008-2013 Free Software Foundation, Inc.
5 Software Foundation, Inc.
6 5
7 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
8 under the terms of the GNU General Public License as published by the 7 under the terms of the GNU General Public License as published by the
@@ -15,8 +14,7 @@
15 GNU General Public License for more details. 14 GNU General Public License for more details.
16 15
17 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software Foundation, 17 along with this program; if not, see <http://www.gnu.org/licenses/>. */
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
20 18
21/* Written by Scott G. Miller 19/* Written by Scott G. Miller
22 Credits: 20 Credits:
@@ -27,7 +25,8 @@
27 25
28#include "sha1.h" 26#include "sha1.h"
29 27
30#include <stddef.h> 28#include <stdalign.h>
29#include <stdint.h>
31#include <stdlib.h> 30#include <stdlib.h>
32#include <string.h> 31#include <string.h>
33 32
@@ -71,7 +70,7 @@ sha1_init_ctx (struct sha1_ctx *ctx)
71/* Copy the 4 byte value from v into the memory location pointed to by *cp, 70/* Copy the 4 byte value from v into the memory location pointed to by *cp,
72 If your architecture allows unaligned access this is equivalent to 71 If your architecture allows unaligned access this is equivalent to
73 * (uint32_t *) cp = v */ 72 * (uint32_t *) cp = v */
74static inline void 73static void
75set_uint32 (char *cp, uint32_t v) 74set_uint32 (char *cp, uint32_t v)
76{ 75{
77 memcpy (cp, &v, sizeof v); 76 memcpy (cp, &v, sizeof v);
@@ -242,8 +241,7 @@ sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx)
242 if (len >= 64) 241 if (len >= 64)
243 { 242 {
244#if !_STRING_ARCH_unaligned 243#if !_STRING_ARCH_unaligned
245# define alignof(type) offsetof (struct { char c; type x; }, x) 244# define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (uint32_t) != 0)
246# define UNALIGNED_P(p) (((size_t) p) % alignof (uint32_t) != 0)
247 if (UNALIGNED_P (buffer)) 245 if (UNALIGNED_P (buffer))
248 while (len > 64) 246 while (len > 64)
249 { 247 {
@@ -307,13 +305,13 @@ sha1_process_block (const void *buffer, size_t len, struct sha1_ctx *ctx)
307 uint32_t c = ctx->C; 305 uint32_t c = ctx->C;
308 uint32_t d = ctx->D; 306 uint32_t d = ctx->D;
309 uint32_t e = ctx->E; 307 uint32_t e = ctx->E;
308 uint32_t lolen = len;
310 309
311 /* First increment the byte count. RFC 1321 specifies the possible 310 /* First increment the byte count. RFC 1321 specifies the possible
312 length of the file up to 2^64 bits. Here we only compute the 311 length of the file up to 2^64 bits. Here we only compute the
313 number of bytes. Do a double word increment. */ 312 number of bytes. Do a double word increment. */
314 ctx->total[0] += len; 313 ctx->total[0] += lolen;
315 if (ctx->total[0] < len) 314 ctx->total[1] += (len >> 31 >> 1) + (ctx->total[0] < lolen);
316 ++ctx->total[1];
317 315
318#define rol(x, n) (((x) << (n)) | ((uint32_t) (x) >> (32 - (n)))) 316#define rol(x, n) (((x) << (n)) | ((uint32_t) (x) >> (32 - (n))))
319 317
diff --git a/gl/sha1.h b/gl/sha1.h
index de209b2..ddd386f 100644
--- a/gl/sha1.h
+++ b/gl/sha1.h
@@ -1,6 +1,6 @@
1/* Declarations of functions and data types used for SHA1 sum 1/* Declarations of functions and data types used for SHA1 sum
2 library functions. 2 library functions.
3 Copyright (C) 2000, 2001, 2003, 2005, 2006, 2008, 2009, 2010 Free Software 3 Copyright (C) 2000-2001, 2003, 2005-2006, 2008-2013 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
@@ -14,8 +14,7 @@
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 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, 17 along with this program; if not, see <http://www.gnu.org/licenses/>. */
18 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
19 18
20#ifndef SHA1_H 19#ifndef SHA1_H
21# define SHA1_H 1 20# define SHA1_H 1
diff --git a/gl/size_max.h b/gl/size_max.h
index 56d5a9b..5f33124 100644
--- a/gl/size_max.h
+++ b/gl/size_max.h
@@ -1,5 +1,5 @@
1/* size_max.h -- declare SIZE_MAX through system headers 1/* size_max.h -- declare SIZE_MAX through system headers
2 Copyright (C) 2005-2006, 2009-2010 Free Software Foundation, Inc. 2 Copyright (C) 2005-2006, 2009-2013 Free Software Foundation, Inc.
3 Written by Simon Josefsson. 3 Written by Simon Josefsson.
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
@@ -13,8 +13,7 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
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, write to the Free Software Foundation, 16 along with this program; if not, see <http://www.gnu.org/licenses/>. */
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 17
19#ifndef GNULIB_SIZE_MAX_H 18#ifndef GNULIB_SIZE_MAX_H
20#define GNULIB_SIZE_MAX_H 19#define GNULIB_SIZE_MAX_H
diff --git a/gl/snprintf.c b/gl/snprintf.c
index 810ca14..9c4ab3f 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-2010 Free Software Foundation, Inc. 2 Copyright (C) 2004, 2006-2013 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
@@ -13,8 +13,7 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License along 15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, 16 with this program; if not, see <http://www.gnu.org/licenses/>. */
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 17
19#include <config.h> 18#include <config.h>
20 19
diff --git a/gl/sockets.c b/gl/sockets.c
index b946c7e..ae96148 100644
--- a/gl/sockets.c
+++ b/gl/sockets.c
@@ -1,6 +1,6 @@
1/* sockets.c --- wrappers for Windows socket functions 1/* sockets.c --- wrappers for Windows socket functions
2 2
3 Copyright (C) 2008-2010 Free Software Foundation, Inc. 3 Copyright (C) 2008-2013 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
@@ -27,14 +27,21 @@
27/* This includes winsock2.h on MinGW. */ 27/* This includes winsock2.h on MinGW. */
28# include <sys/socket.h> 28# include <sys/socket.h>
29 29
30# include "close-hook.h" 30# include "fd-hook.h"
31# include "msvc-nothrow.h"
31 32
32/* Get set_winsock_errno, FD_TO_SOCKET etc. */ 33/* Get set_winsock_errno, FD_TO_SOCKET etc. */
33# include "w32sock.h" 34# include "w32sock.h"
34 35
35static int 36static int
36close_fd_maybe_socket (int fd, const struct close_hook *remaining_list) 37close_fd_maybe_socket (const struct fd_hook *remaining_list,
38 gl_close_fn primary,
39 int fd)
37{ 40{
41 /* Note about multithread-safety: There is a race condition where, between
42 our calls to closesocket() and the primary close(), some other thread
43 could make system calls that allocate precisely the same HANDLE value
44 as sock; then the primary close() would call CloseHandle() on it. */
38 SOCKET sock; 45 SOCKET sock;
39 WSANETWORKEVENTS ev; 46 WSANETWORKEVENTS ev;
40 47
@@ -64,10 +71,38 @@ close_fd_maybe_socket (int fd, const struct close_hook *remaining_list)
64 } 71 }
65 else 72 else
66 /* Some other type of file descriptor. */ 73 /* Some other type of file descriptor. */
67 return execute_close_hooks (fd, remaining_list); 74 return execute_close_hooks (remaining_list, primary, fd);
68} 75}
69 76
70static struct close_hook close_sockets_hook; 77static int
78ioctl_fd_maybe_socket (const struct fd_hook *remaining_list,
79 gl_ioctl_fn primary,
80 int fd, int request, void *arg)
81{
82 SOCKET sock;
83 WSANETWORKEVENTS ev;
84
85 /* Test whether fd refers to a socket. */
86 sock = FD_TO_SOCKET (fd);
87 ev.lNetworkEvents = 0xDEADBEEF;
88 WSAEnumNetworkEvents (sock, NULL, &ev);
89 if (ev.lNetworkEvents != 0xDEADBEEF)
90 {
91 /* fd refers to a socket. */
92 if (ioctlsocket (sock, request, arg) < 0)
93 {
94 set_winsock_errno ();
95 return -1;
96 }
97 else
98 return 0;
99 }
100 else
101 /* Some other type of file descriptor. */
102 return execute_ioctl_hooks (remaining_list, primary, fd, request, arg);
103}
104
105static struct fd_hook fd_sockets_hook;
71 106
72static int initialized_sockets_version /* = 0 */; 107static int initialized_sockets_version /* = 0 */;
73 108
@@ -90,7 +125,8 @@ gl_sockets_startup (int version _GL_UNUSED)
90 return 2; 125 return 2;
91 126
92 if (initialized_sockets_version == 0) 127 if (initialized_sockets_version == 0)
93 register_close_hook (close_fd_maybe_socket, &close_sockets_hook); 128 register_fd_hook (close_fd_maybe_socket, ioctl_fd_maybe_socket,
129 &fd_sockets_hook);
94 130
95 initialized_sockets_version = version; 131 initialized_sockets_version = version;
96 } 132 }
@@ -107,7 +143,7 @@ gl_sockets_cleanup (void)
107 143
108 initialized_sockets_version = 0; 144 initialized_sockets_version = 0;
109 145
110 unregister_close_hook (&close_sockets_hook); 146 unregister_fd_hook (&fd_sockets_hook);
111 147
112 err = WSACleanup (); 148 err = WSACleanup ();
113 if (err != 0) 149 if (err != 0)
diff --git a/gl/sockets.h b/gl/sockets.h
index 921bf6f..1570ad8 100644
--- a/gl/sockets.h
+++ b/gl/sockets.h
@@ -1,6 +1,6 @@
1/* sockets.h - wrappers for Windows socket functions 1/* sockets.h - wrappers for Windows socket functions
2 2
3 Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. 3 Copyright (C) 2008-2013 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,8 +26,17 @@
26#define SOCKETS_2_1 0x201 26#define SOCKETS_2_1 0x201
27#define SOCKETS_2_2 0x202 27#define SOCKETS_2_2 0x202
28 28
29int gl_sockets_startup (int version); 29int gl_sockets_startup (int version)
30int gl_sockets_cleanup (void); 30#if !WINDOWS_SOCKETS
31 _GL_ATTRIBUTE_CONST
32#endif
33 ;
34
35int gl_sockets_cleanup (void)
36#if !WINDOWS_SOCKETS
37 _GL_ATTRIBUTE_CONST
38#endif
39 ;
31 40
32/* This function is useful it you create a socket using gnulib's 41/* This function is useful it you create a socket using gnulib's
33 Winsock wrappers but needs to pass on the socket handle to some 42 Winsock wrappers but needs to pass on the socket handle to some
@@ -36,6 +45,8 @@ int gl_sockets_cleanup (void);
36 45
37#include <sys/socket.h> 46#include <sys/socket.h>
38 47
48#include "msvc-nothrow.h"
49
39static inline SOCKET 50static inline SOCKET
40gl_fd_to_handle (int fd) 51gl_fd_to_handle (int fd)
41{ 52{
diff --git a/gl/stat.c b/gl/stat.c
deleted file mode 100644
index 875317b..0000000
--- a/gl/stat.c
+++ /dev/null
@@ -1,104 +0,0 @@
1/* Work around platform bugs in stat.
2 Copyright (C) 2009, 2010 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 Eric Blake */
18
19#include <config.h>
20
21/* Get the original definition of stat. It might be defined as a macro. */
22#define __need_system_sys_stat_h
23#include <sys/types.h>
24#include <sys/stat.h>
25#undef __need_system_sys_stat_h
26
27static inline int
28orig_stat (const char *filename, struct stat *buf)
29{
30 return stat (filename, buf);
31}
32
33/* Specification. */
34#include <sys/stat.h>
35
36#include <errno.h>
37#include <limits.h>
38#include <stdbool.h>
39#include <string.h>
40
41/* Store information about NAME into ST. Work around bugs with
42 trailing slashes. Mingw has other bugs (such as st_ino always
43 being 0 on success) which this wrapper does not work around. But
44 at least this implementation provides the ability to emulate fchdir
45 correctly. */
46
47int
48rpl_stat (char const *name, struct stat *st)
49{
50 int result = orig_stat (name, st);
51#if REPLACE_FUNC_STAT_FILE
52 /* Solaris 9 mistakenly succeeds when given a non-directory with a
53 trailing slash. */
54 if (result == 0 && !S_ISDIR (st->st_mode))
55 {
56 size_t len = strlen (name);
57 if (ISSLASH (name[len - 1]))
58 {
59 errno = ENOTDIR;
60 return -1;
61 }
62 }
63#endif /* REPLACE_FUNC_STAT_FILE */
64#if REPLACE_FUNC_STAT_DIR
65 if (result == -1 && errno == ENOENT)
66 {
67 /* Due to mingw's oddities, there are some directories (like
68 c:\) where stat() only succeeds with a trailing slash, and
69 other directories (like c:\windows) where stat() only
70 succeeds without a trailing slash. But we want the two to be
71 synonymous, since chdir() manages either style. Likewise, Mingw also
72 reports ENOENT for names longer than PATH_MAX, when we want
73 ENAMETOOLONG, and for stat("file/"), when we want ENOTDIR.
74 Fortunately, mingw PATH_MAX is small enough for stack
75 allocation. */
76 char fixed_name[PATH_MAX + 1] = {0};
77 size_t len = strlen (name);
78 bool check_dir = false;
79 if (PATH_MAX <= len)
80 errno = ENAMETOOLONG;
81 else if (len)
82 {
83 strcpy (fixed_name, name);
84 if (ISSLASH (fixed_name[len - 1]))
85 {
86 check_dir = true;
87 while (len && ISSLASH (fixed_name[len - 1]))
88 fixed_name[--len] = '\0';
89 if (!len)
90 fixed_name[0] = '/';
91 }
92 else
93 fixed_name[len++] = '/';
94 result = orig_stat (fixed_name, st);
95 if (result == 0 && check_dir && !S_ISDIR (st->st_mode))
96 {
97 result = -1;
98 errno = ENOTDIR;
99 }
100 }
101 }
102#endif /* REPLACE_FUNC_STAT_DIR */
103 return result;
104}
diff --git a/gl/stdalign.in.h b/gl/stdalign.in.h
new file mode 100644
index 0000000..7254a3d
--- /dev/null
+++ b/gl/stdalign.in.h
@@ -0,0 +1,109 @@
1/* A substitute for ISO C11 <stdalign.h>.
2
3 Copyright 2011-2013 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, see <http://www.gnu.org/licenses/>. */
17
18/* Written by Paul Eggert and Bruno Haible. */
19
20#ifndef _GL_STDALIGN_H
21#define _GL_STDALIGN_H
22
23/* ISO C11 <stdalign.h> for platforms that lack it.
24
25 References:
26 ISO C11 (latest free draft
27 <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf>)
28 sections 6.5.3.4, 6.7.5, 7.15.
29 C++11 (latest free draft
30 <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf>)
31 section 18.10. */
32
33/* alignof (TYPE), also known as _Alignof (TYPE), yields the alignment
34 requirement of a structure member (i.e., slot or field) that is of
35 type TYPE, as an integer constant expression.
36
37 This differs from GCC's __alignof__ operator, which can yield a
38 better-performing alignment for an object of that type. For
39 example, on x86 with GCC, __alignof__ (double) and __alignof__
40 (long long) are 8, whereas alignof (double) and alignof (long long)
41 are 4 unless the option '-malign-double' is used.
42
43 The result cannot be used as a value for an 'enum' constant, if you
44 want to be portable to HP-UX 10.20 cc and AIX 3.2.5 xlc.
45
46 Include <stddef.h> for offsetof. */
47#include <stddef.h>
48
49/* FreeBSD 9.1 <sys/cdefs.h>, included by <stddef.h> and lots of other
50 standard headers, defines conflicting implementations of _Alignas
51 and _Alignof that are no better than ours; override them. */
52#undef _Alignas
53#undef _Alignof
54
55#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112
56# ifdef __cplusplus
57# if 201103 <= __cplusplus
58# define _Alignof(type) alignof (type)
59# else
60 template <class __t> struct __alignof_helper { char __a; __t __b; };
61# define _Alignof(type) offsetof (__alignof_helper<type>, __b)
62# endif
63# else
64# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b)
65# endif
66#endif
67#define alignof _Alignof
68#define __alignof_is_defined 1
69
70/* alignas (A), also known as _Alignas (A), aligns a variable or type
71 to the alignment A, where A is an integer constant expression. For
72 example:
73
74 int alignas (8) foo;
75 struct s { int a; int alignas (8) bar; };
76
77 aligns the address of FOO and the offset of BAR to be multiples of 8.
78
79 A should be a power of two that is at least the type's alignment
80 and at most the implementation's alignment limit. This limit is
81 2**28 on typical GNUish hosts, and 2**13 on MSVC. To be portable
82 to MSVC through at least version 10.0, A should be an integer
83 constant, as MSVC does not support expressions such as 1 << 3.
84 To be portable to Sun C 5.11, do not align auto variables to
85 anything stricter than their default alignment.
86
87 The following C11 requirements are not supported here:
88
89 - If A is zero, alignas has no effect.
90 - alignas can be used multiple times; the strictest one wins.
91 - alignas (TYPE) is equivalent to alignas (alignof (TYPE)).
92
93 */
94
95#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112
96# if defined __cplusplus && 201103 <= __cplusplus
97# define _Alignas(a) alignas (a)
98# elif __GNUC__ || __IBMC__ || __IBMCPP__ || __ICC || 0x5110 <= __SUNPRO_C
99# define _Alignas(a) __attribute__ ((__aligned__ (a)))
100# elif 1300 <= _MSC_VER
101# define _Alignas(a) __declspec (align (a))
102# endif
103#endif
104#if defined _Alignas || (defined __STDC_VERSION && 201112 <= __STDC_VERSION__)
105# define alignas _Alignas
106# define __alignas_is_defined 1
107#endif
108
109#endif /* _GL_STDALIGN_H */
diff --git a/gl/stdbool.in.h b/gl/stdbool.in.h
index 574c281..7c15772 100644
--- a/gl/stdbool.in.h
+++ b/gl/stdbool.in.h
@@ -1,4 +1,4 @@
1/* Copyright (C) 2001-2003, 2006-2010 Free Software Foundation, Inc. 1/* Copyright (C) 2001-2003, 2006-2013 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
@@ -12,8 +12,7 @@
12 GNU General Public License for more details. 12 GNU General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software Foundation, 15 along with this program; if not, see <http://www.gnu.org/licenses/>. */
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
17 16
18#ifndef _GL_STDBOOL_H 17#ifndef _GL_STDBOOL_H
19#define _GL_STDBOOL_H 18#define _GL_STDBOOL_H
@@ -67,24 +66,19 @@
67# undef true 66# undef true
68#endif 67#endif
69 68
70/* For the sake of symbolic names in gdb, we define true and false as 69#ifdef __cplusplus
71 enum constants, not only as macros. 70# define _Bool bool
72 It is tempting to write 71# define bool bool
73 typedef enum { false = 0, true = 1 } _Bool; 72#else
74 so that gdb prints values of type 'bool' symbolically. But if we do 73# if defined __BEOS__ && !defined __HAIKU__
75 this, values of type '_Bool' may promote to 'int' or 'unsigned int'
76 (see ISO C 99 6.7.2.2.(4)); however, '_Bool' must promote to 'int'
77 (see ISO C 99 6.3.1.1.(2)). So we add a negative value to the
78 enum; this ensures that '_Bool' promotes to 'int'. */
79#if defined __cplusplus || (defined __BEOS__ && !defined __HAIKU__)
80 /* A compiler known to have 'bool'. */ 74 /* A compiler known to have 'bool'. */
81 /* If the compiler already has both 'bool' and '_Bool', we can assume they 75 /* If the compiler already has both 'bool' and '_Bool', we can assume they
82 are the same types. */ 76 are the same types. */
83# if !@HAVE__BOOL@ 77# if !@HAVE__BOOL@
84typedef bool _Bool; 78typedef bool _Bool;
85# endif 79# endif
86#else 80# else
87# if !defined __GNUC__ 81# if !defined __GNUC__
88 /* If @HAVE__BOOL@: 82 /* If @HAVE__BOOL@:
89 Some HP-UX cc and AIX IBM C compiler versions have compiler bugs when 83 Some HP-UX cc and AIX IBM C compiler versions have compiler bugs when
90 the built-in _Bool type is used. See 84 the built-in _Bool type is used. See
@@ -104,19 +98,35 @@ typedef bool _Bool;
104 "Invalid enumerator. (badenum)" with HP-UX cc on Tru64. 98 "Invalid enumerator. (badenum)" with HP-UX cc on Tru64.
105 The only benefit of the enum, debuggability, is not important 99 The only benefit of the enum, debuggability, is not important
106 with these compilers. So use 'signed char' and no enum. */ 100 with these compilers. So use 'signed char' and no enum. */
107# define _Bool signed char 101# define _Bool signed char
108# else 102# else
109 /* With this compiler, trust the _Bool type if the compiler has it. */ 103 /* With this compiler, trust the _Bool type if the compiler has it. */
110# if !@HAVE__BOOL@ 104# if !@HAVE__BOOL@
105 /* For the sake of symbolic names in gdb, define true and false as
106 enum constants, not only as macros.
107 It is tempting to write
108 typedef enum { false = 0, true = 1 } _Bool;
109 so that gdb prints values of type 'bool' symbolically. But then
110 values of type '_Bool' might promote to 'int' or 'unsigned int'
111 (see ISO C 99 6.7.2.2.(4)); however, '_Bool' must promote to 'int'
112 (see ISO C 99 6.3.1.1.(2)). So add a negative value to the
113 enum; this ensures that '_Bool' promotes to 'int'. */
111typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool; 114typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool;
115# endif
112# endif 116# endif
113# endif 117# endif
118# define bool _Bool
114#endif 119#endif
115#define bool _Bool
116 120
117/* The other macros must be usable in preprocessor directives. */ 121/* The other macros must be usable in preprocessor directives. */
118#define false 0 122#ifdef __cplusplus
119#define true 1 123# define false false
124# define true true
125#else
126# define false 0
127# define true 1
128#endif
129
120#define __bool_true_false_are_defined 1 130#define __bool_true_false_are_defined 1
121 131
122#endif /* _GL_STDBOOL_H */ 132#endif /* _GL_STDBOOL_H */
diff --git a/gl/stddef.in.h b/gl/stddef.in.h
index 08778a2..40f0536 100644
--- a/gl/stddef.in.h
+++ b/gl/stddef.in.h
@@ -1,6 +1,6 @@
1/* A substitute for POSIX 2008 <stddef.h>, for platforms that have issues. 1/* A substitute for POSIX 2008 <stddef.h>, for platforms that have issues.
2 2
3 Copyright (C) 2009, 2010 Free Software Foundation, Inc. 3 Copyright (C) 2009-2013 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
@@ -13,8 +13,7 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
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, write to the Free Software Foundation, 16 along with this program; if not, see <http://www.gnu.org/licenses/>. */
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 17
19/* Written by Eric Blake. */ 18/* Written by Eric Blake. */
20 19
@@ -26,6 +25,7 @@
26#if __GNUC__ >= 3 25#if __GNUC__ >= 3
27@PRAGMA_SYSTEM_HEADER@ 26@PRAGMA_SYSTEM_HEADER@
28#endif 27#endif
28@PRAGMA_COLUMNS@
29 29
30#if defined __need_wchar_t || defined __need_size_t \ 30#if defined __need_wchar_t || defined __need_size_t \
31 || defined __need_ptrdiff_t || defined __need_NULL \ 31 || defined __need_ptrdiff_t || defined __need_NULL \
@@ -37,9 +37,9 @@
37 remember if special invocation has ever been used to obtain wint_t, 37 remember if special invocation has ever been used to obtain wint_t,
38 in which case we need to clean up NULL yet again. */ 38 in which case we need to clean up NULL yet again. */
39 39
40# if !(defined _GL_STDDEF_H && defined _GL_STDDEF_WINT_T) 40# if !(defined _@GUARD_PREFIX@_STDDEF_H && defined _GL_STDDEF_WINT_T)
41# ifdef __need_wint_t 41# ifdef __need_wint_t
42# undef _GL_STDDEF_H 42# undef _@GUARD_PREFIX@_STDDEF_H
43# define _GL_STDDEF_WINT_T 43# define _GL_STDDEF_WINT_T
44# endif 44# endif
45# @INCLUDE_NEXT@ @NEXT_STDDEF_H@ 45# @INCLUDE_NEXT@ @NEXT_STDDEF_H@
@@ -48,14 +48,14 @@
48#else 48#else
49/* Normal invocation convention. */ 49/* Normal invocation convention. */
50 50
51# ifndef _GL_STDDEF_H 51# ifndef _@GUARD_PREFIX@_STDDEF_H
52 52
53/* The include_next requires a split double-inclusion guard. */ 53/* The include_next requires a split double-inclusion guard. */
54 54
55# @INCLUDE_NEXT@ @NEXT_STDDEF_H@ 55# @INCLUDE_NEXT@ @NEXT_STDDEF_H@
56 56
57# ifndef _GL_STDDEF_H 57# ifndef _@GUARD_PREFIX@_STDDEF_H
58# define _GL_STDDEF_H 58# define _@GUARD_PREFIX@_STDDEF_H
59 59
60/* On NetBSD 5.0, the definition of NULL lacks proper parentheses. */ 60/* On NetBSD 5.0, the definition of NULL lacks proper parentheses. */
61#if @REPLACE_NULL@ 61#if @REPLACE_NULL@
@@ -81,6 +81,6 @@
81# define wchar_t int 81# define wchar_t int
82#endif 82#endif
83 83
84# endif /* _GL_STDDEF_H */ 84# endif /* _@GUARD_PREFIX@_STDDEF_H */
85# endif /* _GL_STDDEF_H */ 85# endif /* _@GUARD_PREFIX@_STDDEF_H */
86#endif /* __need_XXX */ 86#endif /* __need_XXX */
diff --git a/gl/stdint.in.h b/gl/stdint.in.h
index 5da5f17..2db8b2e 100644
--- a/gl/stdint.in.h
+++ b/gl/stdint.in.h
@@ -1,4 +1,4 @@
1/* Copyright (C) 2001-2002, 2004-2010 Free Software Foundation, Inc. 1/* Copyright (C) 2001-2002, 2004-2013 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
@@ -13,19 +13,19 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
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, write to the Free Software Foundation, 16 along with this program; if not, see <http://www.gnu.org/licenses/>. */
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 17
19/* 18/*
20 * ISO C 99 <stdint.h> for platforms that lack it. 19 * ISO C 99 <stdint.h> for platforms that lack it.
21 * <http://www.opengroup.org/susv3xbd/stdint.h.html> 20 * <http://www.opengroup.org/susv3xbd/stdint.h.html>
22 */ 21 */
23 22
24#ifndef _GL_STDINT_H 23#ifndef _@GUARD_PREFIX@_STDINT_H
25 24
26#if __GNUC__ >= 3 25#if __GNUC__ >= 3
27@PRAGMA_SYSTEM_HEADER@ 26@PRAGMA_SYSTEM_HEADER@
28#endif 27#endif
28@PRAGMA_COLUMNS@
29 29
30/* When including a system file that in turn includes <inttypes.h>, 30/* When including a system file that in turn includes <inttypes.h>,
31 use the system <inttypes.h>, not our substitute. This avoids 31 use the system <inttypes.h>, not our substitute. This avoids
@@ -33,6 +33,16 @@
33 <inttypes.h>. */ 33 <inttypes.h>. */
34#define _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H 34#define _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
35 35
36/* On Android (Bionic libc), <sys/types.h> includes this file before
37 having defined 'time_t'. Therefore in this case avoid including
38 other system header files; just include the system's <stdint.h>.
39 Ideally we should test __BIONIC__ here, but it is only defined after
40 <sys/cdefs.h> has been included; hence test __ANDROID__ instead. */
41#if defined __ANDROID__ \
42 && defined _SYS_TYPES_H_ && !defined __need_size_t
43# @INCLUDE_NEXT@ @NEXT_STDINT_H@
44#else
45
36/* Get those types that are already defined in other system include 46/* Get those types that are already defined in other system include
37 files, so that we can "#define int8_t signed char" below without 47 files, so that we can "#define int8_t signed char" below without
38 worrying about a later system include file containing a "typedef 48 worrying about a later system include file containing a "typedef
@@ -48,28 +58,40 @@
48 diagnostics. */ 58 diagnostics. */
49# define __STDINT_H__ 59# define __STDINT_H__
50# endif 60# endif
61
62 /* Some pre-C++11 <stdint.h> implementations need this. */
63# ifdef __cplusplus
64# ifndef __STDC_CONSTANT_MACROS
65# define __STDC_CONSTANT_MACROS 1
66# endif
67# ifndef __STDC_LIMIT_MACROS
68# define __STDC_LIMIT_MACROS 1
69# endif
70# endif
71
51 /* Other systems may have an incomplete or buggy <stdint.h>. 72 /* Other systems may have an incomplete or buggy <stdint.h>.
52 Include it before <inttypes.h>, since any "#include <stdint.h>" 73 Include it before <inttypes.h>, since any "#include <stdint.h>"
53 in <inttypes.h> would reinclude us, skipping our contents because 74 in <inttypes.h> would reinclude us, skipping our contents because
54 _GL_STDINT_H is defined. 75 _@GUARD_PREFIX@_STDINT_H is defined.
55 The include_next requires a split double-inclusion guard. */ 76 The include_next requires a split double-inclusion guard. */
56# @INCLUDE_NEXT@ @NEXT_STDINT_H@ 77# @INCLUDE_NEXT@ @NEXT_STDINT_H@
57#endif 78#endif
58 79
59#if ! defined _GL_STDINT_H && ! defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H 80#if ! defined _@GUARD_PREFIX@_STDINT_H && ! defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H
60#define _GL_STDINT_H 81#define _@GUARD_PREFIX@_STDINT_H
61 82
62/* <sys/types.h> defines some of the stdint.h types as well, on glibc, 83/* <sys/types.h> defines some of the stdint.h types as well, on glibc,
63 IRIX 6.5, and OpenBSD 3.8 (via <machine/types.h>). 84 IRIX 6.5, and OpenBSD 3.8 (via <machine/types.h>).
64 AIX 5.2 <sys/types.h> isn't needed and causes troubles. 85 AIX 5.2 <sys/types.h> isn't needed and causes troubles.
65 MacOS X 10.4.6 <sys/types.h> includes <stdint.h> (which is us), but 86 Mac OS X 10.4.6 <sys/types.h> includes <stdint.h> (which is us), but
66 relies on the system <stdint.h> definitions, so include 87 relies on the system <stdint.h> definitions, so include
67 <sys/types.h> after @NEXT_STDINT_H@. */ 88 <sys/types.h> after @NEXT_STDINT_H@. */
68#if @HAVE_SYS_TYPES_H@ && ! defined _AIX 89#if @HAVE_SYS_TYPES_H@ && ! defined _AIX
69# include <sys/types.h> 90# include <sys/types.h>
70#endif 91#endif
71 92
72/* Get LONG_MIN, LONG_MAX, ULONG_MAX. */ 93/* Get SCHAR_MIN, SCHAR_MAX, UCHAR_MAX, INT_MIN, INT_MAX,
94 LONG_MIN, LONG_MAX, ULONG_MAX. */
73#include <limits.h> 95#include <limits.h>
74 96
75#if @HAVE_INTTYPES_H@ 97#if @HAVE_INTTYPES_H@
@@ -92,7 +114,7 @@
92 114
93#undef _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H 115#undef _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
94 116
95/* Minimum and maximum values for a integer type under the usual assumption. 117/* Minimum and maximum values for an integer type under the usual assumption.
96 Return an unspecified value if BITS == 0, adding a check to pacify 118 Return an unspecified value if BITS == 0, adding a check to pacify
97 picky compilers. */ 119 picky compilers. */
98 120
@@ -107,6 +129,8 @@
107 warnings in the signed case. */ \ 129 warnings in the signed case. */ \
108 ((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1) 130 ((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1)
109 131
132#if !GNULIB_defined_stdint_types
133
110/* 7.18.1.1. Exact-width integer types */ 134/* 7.18.1.1. Exact-width integer types */
111 135
112/* Here we assume a standard architecture where the hardware integer 136/* Here we assume a standard architecture where the hardware integer
@@ -133,40 +157,54 @@ typedef unsigned int gl_uint32_t;
133#define int32_t gl_int32_t 157#define int32_t gl_int32_t
134#define uint32_t gl_uint32_t 158#define uint32_t gl_uint32_t
135 159
160/* If the system defines INT64_MAX, assume int64_t works. That way,
161 if the underlying platform defines int64_t to be a 64-bit long long
162 int, the code below won't mistakenly define it to be a 64-bit long
163 int, which would mess up C++ name mangling. We must use #ifdef
164 rather than #if, to avoid an error with HP-UX 10.20 cc. */
165
166#ifdef INT64_MAX
167# define GL_INT64_T
168#else
136/* Do not undefine int64_t if gnulib is not being used with 64-bit 169/* Do not undefine int64_t if gnulib is not being used with 64-bit
137 types, since otherwise it breaks platforms like Tandem/NSK. */ 170 types, since otherwise it breaks platforms like Tandem/NSK. */
138#if LONG_MAX >> 31 >> 31 == 1 171# if LONG_MAX >> 31 >> 31 == 1
139# undef int64_t 172# undef int64_t
140typedef long int gl_int64_t; 173typedef long int gl_int64_t;
141# define int64_t gl_int64_t 174# define int64_t gl_int64_t
142# define GL_INT64_T 175# define GL_INT64_T
143#elif defined _MSC_VER 176# elif defined _MSC_VER
144# undef int64_t 177# undef int64_t
145typedef __int64 gl_int64_t; 178typedef __int64 gl_int64_t;
146# define int64_t gl_int64_t 179# define int64_t gl_int64_t
147# define GL_INT64_T 180# define GL_INT64_T
148#elif @HAVE_LONG_LONG_INT@ 181# elif @HAVE_LONG_LONG_INT@
149# undef int64_t 182# undef int64_t
150typedef long long int gl_int64_t; 183typedef long long int gl_int64_t;
151# define int64_t gl_int64_t 184# define int64_t gl_int64_t
152# define GL_INT64_T 185# define GL_INT64_T
186# endif
153#endif 187#endif
154 188
155#if ULONG_MAX >> 31 >> 31 >> 1 == 1 189#ifdef UINT64_MAX
156# undef uint64_t
157typedef unsigned long int gl_uint64_t;
158# define uint64_t gl_uint64_t
159# define GL_UINT64_T 190# define GL_UINT64_T
160#elif defined _MSC_VER 191#else
161# undef uint64_t 192# if ULONG_MAX >> 31 >> 31 >> 1 == 1
193# undef uint64_t
194typedef unsigned long int gl_uint64_t;
195# define uint64_t gl_uint64_t
196# define GL_UINT64_T
197# elif defined _MSC_VER
198# undef uint64_t
162typedef unsigned __int64 gl_uint64_t; 199typedef unsigned __int64 gl_uint64_t;
163# define uint64_t gl_uint64_t 200# define uint64_t gl_uint64_t
164# define GL_UINT64_T 201# define GL_UINT64_T
165#elif @HAVE_UNSIGNED_LONG_LONG_INT@ 202# elif @HAVE_UNSIGNED_LONG_LONG_INT@
166# undef uint64_t 203# undef uint64_t
167typedef unsigned long long int gl_uint64_t; 204typedef unsigned long long int gl_uint64_t;
168# define uint64_t gl_uint64_t 205# define uint64_t gl_uint64_t
169# define GL_UINT64_T 206# define GL_UINT64_T
207# endif
170#endif 208#endif
171 209
172/* Avoid collision with Solaris 2.5.1 <pthread.h> etc. */ 210/* Avoid collision with Solaris 2.5.1 <pthread.h> etc. */
@@ -209,8 +247,9 @@ typedef unsigned long long int gl_uint64_t;
209 247
210/* Here we assume a standard architecture where the hardware integer 248/* Here we assume a standard architecture where the hardware integer
211 types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types 249 types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
212 are taken from the same list of types. Assume that 'long int' 250 are taken from the same list of types. The following code normally
213 is fast enough for all narrower integers. */ 251 uses types consistent with glibc, as that lessens the chance of
252 incompatibility with older GNU hosts. */
214 253
215#undef int_fast8_t 254#undef int_fast8_t
216#undef uint_fast8_t 255#undef uint_fast8_t
@@ -220,12 +259,21 @@ typedef unsigned long long int gl_uint64_t;
220#undef uint_fast32_t 259#undef uint_fast32_t
221#undef int_fast64_t 260#undef int_fast64_t
222#undef uint_fast64_t 261#undef uint_fast64_t
223typedef long int gl_int_fast8_t; 262typedef signed char gl_int_fast8_t;
224typedef unsigned long int gl_uint_fast8_t; 263typedef unsigned char gl_uint_fast8_t;
225typedef long int gl_int_fast16_t; 264
226typedef unsigned long int gl_uint_fast16_t; 265#ifdef __sun
266/* Define types compatible with SunOS 5.10, so that code compiled under
267 earlier SunOS versions works with code compiled under SunOS 5.10. */
268typedef int gl_int_fast32_t;
269typedef unsigned int gl_uint_fast32_t;
270#else
227typedef long int gl_int_fast32_t; 271typedef long int gl_int_fast32_t;
228typedef unsigned long int gl_uint_fast32_t; 272typedef unsigned long int gl_uint_fast32_t;
273#endif
274typedef gl_int_fast32_t gl_int_fast16_t;
275typedef gl_uint_fast32_t gl_uint_fast16_t;
276
229#define int_fast8_t gl_int_fast8_t 277#define int_fast8_t gl_int_fast8_t
230#define uint_fast8_t gl_uint_fast8_t 278#define uint_fast8_t gl_uint_fast8_t
231#define int_fast16_t gl_int_fast16_t 279#define int_fast16_t gl_int_fast16_t
@@ -253,36 +301,48 @@ typedef unsigned long int gl_uintptr_t;
253/* Note: These types are compiler dependent. It may be unwise to use them in 301/* Note: These types are compiler dependent. It may be unwise to use them in
254 public header files. */ 302 public header files. */
255 303
256#undef intmax_t 304/* If the system defines INTMAX_MAX, assume that intmax_t works, and
257#if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1 305 similarly for UINTMAX_MAX and uintmax_t. This avoids problems with
306 assuming one type where another is used by the system. */
307
308#ifndef INTMAX_MAX
309# undef INTMAX_C
310# undef intmax_t
311# if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
258typedef long long int gl_intmax_t; 312typedef long long int gl_intmax_t;
259# define intmax_t gl_intmax_t 313# define intmax_t gl_intmax_t
260#elif defined GL_INT64_T 314# elif defined GL_INT64_T
261# define intmax_t int64_t 315# define intmax_t int64_t
262#else 316# else
263typedef long int gl_intmax_t; 317typedef long int gl_intmax_t;
264# define intmax_t gl_intmax_t 318# define intmax_t gl_intmax_t
319# endif
265#endif 320#endif
266 321
267#undef uintmax_t 322#ifndef UINTMAX_MAX
268#if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1 323# undef UINTMAX_C
324# undef uintmax_t
325# if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1
269typedef unsigned long long int gl_uintmax_t; 326typedef unsigned long long int gl_uintmax_t;
270# define uintmax_t gl_uintmax_t 327# define uintmax_t gl_uintmax_t
271#elif defined GL_UINT64_T 328# elif defined GL_UINT64_T
272# define uintmax_t uint64_t 329# define uintmax_t uint64_t
273#else 330# else
274typedef unsigned long int gl_uintmax_t; 331typedef unsigned long int gl_uintmax_t;
275# define uintmax_t gl_uintmax_t 332# define uintmax_t gl_uintmax_t
333# endif
276#endif 334#endif
277 335
278/* Verify that intmax_t and uintmax_t have the same size. Too much code 336/* Verify that intmax_t and uintmax_t have the same size. Too much code
279 breaks if this is not the case. If this check fails, the reason is likely 337 breaks if this is not the case. If this check fails, the reason is likely
280 to be found in the autoconf macros. */ 338 to be found in the autoconf macros. */
281typedef int _verify_intmax_size[2 * (sizeof (intmax_t) == sizeof (uintmax_t)) - 1]; 339typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t)
340 ? 1 : -1];
282 341
283/* 7.18.2. Limits of specified-width integer types */ 342#define GNULIB_defined_stdint_types 1
343#endif /* !GNULIB_defined_stdint_types */
284 344
285#if ! defined __cplusplus || defined __STDC_LIMIT_MACROS 345/* 7.18.2. Limits of specified-width integer types */
286 346
287/* 7.18.2.1. Limits of exact-width integer types */ 347/* 7.18.2.1. Limits of exact-width integer types */
288 348
@@ -310,17 +370,14 @@ typedef int _verify_intmax_size[2 * (sizeof (intmax_t) == sizeof (uintmax_t)) -
310#define INT32_MAX 2147483647 370#define INT32_MAX 2147483647
311#define UINT32_MAX 4294967295U 371#define UINT32_MAX 4294967295U
312 372
313#undef INT64_MIN 373#if defined GL_INT64_T && ! defined INT64_MAX
314#undef INT64_MAX
315#ifdef GL_INT64_T
316/* Prefer (- INTMAX_C (1) << 63) over (~ INT64_MAX) because SunPRO C 5.0 374/* Prefer (- INTMAX_C (1) << 63) over (~ INT64_MAX) because SunPRO C 5.0
317 evaluates the latter incorrectly in preprocessor expressions. */ 375 evaluates the latter incorrectly in preprocessor expressions. */
318# define INT64_MIN (- INTMAX_C (1) << 63) 376# define INT64_MIN (- INTMAX_C (1) << 63)
319# define INT64_MAX INTMAX_C (9223372036854775807) 377# define INT64_MAX INTMAX_C (9223372036854775807)
320#endif 378#endif
321 379
322#undef UINT64_MAX 380#if defined GL_UINT64_T && ! defined UINT64_MAX
323#ifdef GL_UINT64_T
324# define UINT64_MAX UINTMAX_C (18446744073709551615) 381# define UINT64_MAX UINTMAX_C (18446744073709551615)
325#endif 382#endif
326 383
@@ -372,23 +429,29 @@ typedef int _verify_intmax_size[2 * (sizeof (intmax_t) == sizeof (uintmax_t)) -
372#undef INT_FAST8_MIN 429#undef INT_FAST8_MIN
373#undef INT_FAST8_MAX 430#undef INT_FAST8_MAX
374#undef UINT_FAST8_MAX 431#undef UINT_FAST8_MAX
375#define INT_FAST8_MIN LONG_MIN 432#define INT_FAST8_MIN SCHAR_MIN
376#define INT_FAST8_MAX LONG_MAX 433#define INT_FAST8_MAX SCHAR_MAX
377#define UINT_FAST8_MAX ULONG_MAX 434#define UINT_FAST8_MAX UCHAR_MAX
378 435
379#undef INT_FAST16_MIN 436#undef INT_FAST16_MIN
380#undef INT_FAST16_MAX 437#undef INT_FAST16_MAX
381#undef UINT_FAST16_MAX 438#undef UINT_FAST16_MAX
382#define INT_FAST16_MIN LONG_MIN 439#define INT_FAST16_MIN INT_FAST32_MIN
383#define INT_FAST16_MAX LONG_MAX 440#define INT_FAST16_MAX INT_FAST32_MAX
384#define UINT_FAST16_MAX ULONG_MAX 441#define UINT_FAST16_MAX UINT_FAST32_MAX
385 442
386#undef INT_FAST32_MIN 443#undef INT_FAST32_MIN
387#undef INT_FAST32_MAX 444#undef INT_FAST32_MAX
388#undef UINT_FAST32_MAX 445#undef UINT_FAST32_MAX
389#define INT_FAST32_MIN LONG_MIN 446#ifdef __sun
390#define INT_FAST32_MAX LONG_MAX 447# define INT_FAST32_MIN INT_MIN
391#define UINT_FAST32_MAX ULONG_MAX 448# define INT_FAST32_MAX INT_MAX
449# define UINT_FAST32_MAX UINT_MAX
450#else
451# define INT_FAST32_MIN LONG_MIN
452# define INT_FAST32_MAX LONG_MAX
453# define UINT_FAST32_MAX ULONG_MAX
454#endif
392 455
393#undef INT_FAST64_MIN 456#undef INT_FAST64_MIN
394#undef INT_FAST64_MAX 457#undef INT_FAST64_MAX
@@ -413,21 +476,23 @@ typedef int _verify_intmax_size[2 * (sizeof (intmax_t) == sizeof (uintmax_t)) -
413 476
414/* 7.18.2.5. Limits of greatest-width integer types */ 477/* 7.18.2.5. Limits of greatest-width integer types */
415 478
416#undef INTMAX_MIN 479#ifndef INTMAX_MAX
417#undef INTMAX_MAX 480# undef INTMAX_MIN
418#ifdef INT64_MAX 481# ifdef INT64_MAX
419# define INTMAX_MIN INT64_MIN 482# define INTMAX_MIN INT64_MIN
420# define INTMAX_MAX INT64_MAX 483# define INTMAX_MAX INT64_MAX
421#else 484# else
422# define INTMAX_MIN INT32_MIN 485# define INTMAX_MIN INT32_MIN
423# define INTMAX_MAX INT32_MAX 486# define INTMAX_MAX INT32_MAX
487# endif
424#endif 488#endif
425 489
426#undef UINTMAX_MAX 490#ifndef UINTMAX_MAX
427#ifdef UINT64_MAX 491# ifdef UINT64_MAX
428# define UINTMAX_MAX UINT64_MAX 492# define UINTMAX_MAX UINT64_MAX
429#else 493# else
430# define UINTMAX_MAX UINT32_MAX 494# define UINTMAX_MAX UINT32_MAX
495# endif
431#endif 496#endif
432 497
433/* 7.18.3. Limits of other integer types */ 498/* 7.18.3. Limits of other integer types */
@@ -475,10 +540,16 @@ typedef int _verify_intmax_size[2 * (sizeof (intmax_t) == sizeof (uintmax_t)) -
475 540
476/* wchar_t limits */ 541/* wchar_t limits */
477/* Get WCHAR_MIN, WCHAR_MAX. 542/* Get WCHAR_MIN, WCHAR_MAX.
478 This include is not on the top, above, because on OSF/1 4.0 we have a sequence of nested 543 This include is not on the top, above, because on OSF/1 4.0 we have a
479 includes <wchar.h> -> <stdio.h> -> <getopt.h> -> <stdlib.h>, and the latter includes 544 sequence of nested includes
545 <wchar.h> -> <stdio.h> -> <getopt.h> -> <stdlib.h>, and the latter includes
480 <stdint.h> and assumes its types are already defined. */ 546 <stdint.h> and assumes its types are already defined. */
481#if ! (defined WCHAR_MIN && defined WCHAR_MAX) 547#if @HAVE_WCHAR_H@ && ! (defined WCHAR_MIN && defined WCHAR_MAX)
548 /* BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
549 included before <wchar.h>. */
550# include <stddef.h>
551# include <stdio.h>
552# include <time.h>
482# define _GL_JUST_INCLUDE_SYSTEM_WCHAR_H 553# define _GL_JUST_INCLUDE_SYSTEM_WCHAR_H
483# include <wchar.h> 554# include <wchar.h>
484# undef _GL_JUST_INCLUDE_SYSTEM_WCHAR_H 555# undef _GL_JUST_INCLUDE_SYSTEM_WCHAR_H
@@ -498,12 +569,8 @@ typedef int _verify_intmax_size[2 * (sizeof (intmax_t) == sizeof (uintmax_t)) -
498#define WINT_MAX \ 569#define WINT_MAX \
499 _STDINT_MAX (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@) 570 _STDINT_MAX (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@)
500 571
501#endif /* !defined __cplusplus || defined __STDC_LIMIT_MACROS */
502
503/* 7.18.4. Macros for integer constants */ 572/* 7.18.4. Macros for integer constants */
504 573
505#if ! defined __cplusplus || defined __STDC_CONSTANT_MACROS
506
507/* 7.18.4.1. Macros for minimum-width integer constants */ 574/* 7.18.4.1. Macros for minimum-width integer constants */
508/* According to ISO C 99 Technical Corrigendum 1 */ 575/* According to ISO C 99 Technical Corrigendum 1 */
509 576
@@ -544,25 +611,26 @@ typedef int _verify_intmax_size[2 * (sizeof (intmax_t) == sizeof (uintmax_t)) -
544 611
545/* 7.18.4.2. Macros for greatest-width integer constants */ 612/* 7.18.4.2. Macros for greatest-width integer constants */
546 613
547#undef INTMAX_C 614#ifndef INTMAX_C
548#if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1 615# if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
549# define INTMAX_C(x) x##LL 616# define INTMAX_C(x) x##LL
550#elif defined GL_INT64_T 617# elif defined GL_INT64_T
551# define INTMAX_C(x) INT64_C(x) 618# define INTMAX_C(x) INT64_C(x)
552#else 619# else
553# define INTMAX_C(x) x##L 620# define INTMAX_C(x) x##L
621# endif
554#endif 622#endif
555 623
556#undef UINTMAX_C 624#ifndef UINTMAX_C
557#if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1 625# if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1
558# define UINTMAX_C(x) x##ULL 626# define UINTMAX_C(x) x##ULL
559#elif defined GL_UINT64_T 627# elif defined GL_UINT64_T
560# define UINTMAX_C(x) UINT64_C(x) 628# define UINTMAX_C(x) UINT64_C(x)
561#else 629# else
562# define UINTMAX_C(x) x##UL 630# define UINTMAX_C(x) x##UL
631# endif
563#endif 632#endif
564 633
565#endif /* !defined __cplusplus || defined __STDC_CONSTANT_MACROS */ 634#endif /* _@GUARD_PREFIX@_STDINT_H */
566 635#endif /* !(defined __ANDROID__ && ...) */
567#endif /* _GL_STDINT_H */ 636#endif /* !defined _@GUARD_PREFIX@_STDINT_H && !defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H */
568#endif /* !defined _GL_STDINT_H && !defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H */
diff --git a/gl/stdio-write.c b/gl/stdio-write.c
deleted file mode 100644
index a6a0eb1..0000000
--- a/gl/stdio-write.c
+++ /dev/null
@@ -1,148 +0,0 @@
1/* POSIX compatible FILE stream write function.
2 Copyright (C) 2008-2010 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_VPRINTF_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_VFPRINTF_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 80b9dbf..06cbad0 100644
--- a/gl/stdio.in.h
+++ b/gl/stdio.in.h
@@ -1,6 +1,6 @@
1/* A GNU-like <stdio.h>. 1/* A GNU-like <stdio.h>.
2 2
3 Copyright (C) 2004, 2007-2010 Free Software Foundation, Inc. 3 Copyright (C) 2004, 2007-2013 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
@@ -13,47 +13,104 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
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, write to the Free Software Foundation, 16 along with this program; if not, see <http://www.gnu.org/licenses/>. */
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 17
19#if __GNUC__ >= 3 18#if __GNUC__ >= 3
20@PRAGMA_SYSTEM_HEADER@ 19@PRAGMA_SYSTEM_HEADER@
21#endif 20#endif
21@PRAGMA_COLUMNS@
22 22
23#if defined __need_FILE || defined __need___FILE 23#if defined __need_FILE || defined __need___FILE || defined _GL_ALREADY_INCLUDING_STDIO_H
24/* Special invocation convention inside glibc header files. */ 24/* Special invocation convention:
25 - Inside glibc header files.
26 - On OSF/1 5.1 we have a sequence of nested includes
27 <stdio.h> -> <getopt.h> -> <ctype.h> -> <sys/localedef.h> ->
28 <sys/lc_core.h> -> <nl_types.h> -> <mesg.h> -> <stdio.h>.
29 In this situation, the functions are not yet declared, therefore we cannot
30 provide the C++ aliases. */
25 31
26#@INCLUDE_NEXT@ @NEXT_STDIO_H@ 32#@INCLUDE_NEXT@ @NEXT_STDIO_H@
27 33
28#else 34#else
29/* Normal invocation convention. */ 35/* Normal invocation convention. */
30 36
31#ifndef _GL_STDIO_H 37#ifndef _@GUARD_PREFIX@_STDIO_H
38
39#define _GL_ALREADY_INCLUDING_STDIO_H
32 40
33/* The include_next requires a split double-inclusion guard. */ 41/* The include_next requires a split double-inclusion guard. */
34#@INCLUDE_NEXT@ @NEXT_STDIO_H@ 42#@INCLUDE_NEXT@ @NEXT_STDIO_H@
35 43
36#ifndef _GL_STDIO_H 44#undef _GL_ALREADY_INCLUDING_STDIO_H
37#define _GL_STDIO_H 45
46#ifndef _@GUARD_PREFIX@_STDIO_H
47#define _@GUARD_PREFIX@_STDIO_H
38 48
39/* Get va_list. Needed on many systems, including glibc 2.8. */ 49/* Get va_list. Needed on many systems, including glibc 2.8. */
40#include <stdarg.h> 50#include <stdarg.h>
41 51
42#include <stddef.h> 52#include <stddef.h>
43 53
44/* Get off_t and ssize_t. Needed on many systems, including glibc 2.8. */ 54/* Get off_t and ssize_t. Needed on many systems, including glibc 2.8
55 and eglibc 2.11.2.
56 May also define off_t to a 64-bit type on native Windows. */
45#include <sys/types.h> 57#include <sys/types.h>
46 58
47#ifndef __attribute__
48/* The __attribute__ feature is available in gcc versions 2.5 and later. 59/* The __attribute__ feature is available in gcc versions 2.5 and later.
49 The __-protected variants of the attributes 'format' and 'printf' are 60 The __-protected variants of the attributes 'format' and 'printf' are
50 accepted by gcc versions 2.6.4 (effectively 2.7) and later. 61 accepted by gcc versions 2.6.4 (effectively 2.7) and later.
51 We enable __attribute__ only if these are supported too, because 62 We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because
52 gnulib and libintl do '#define printf __printf__' when they override 63 gnulib and libintl do '#define printf __printf__' when they override
53 the 'printf' function. */ 64 the 'printf' function. */
54# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) 65#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
55# define __attribute__(Spec) /* empty */ 66# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
56# endif 67#else
68# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
69#endif
70
71/* _GL_ATTRIBUTE_FORMAT_PRINTF
72 indicates to GCC that the function takes a format string and arguments,
73 where the format string directives are the ones standardized by ISO C99
74 and POSIX. */
75#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
76# define _GL_ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \
77 _GL_ATTRIBUTE_FORMAT ((__gnu_printf__, formatstring_parameter, first_argument))
78#else
79# define _GL_ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \
80 _GL_ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument))
81#endif
82
83/* _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM is like _GL_ATTRIBUTE_FORMAT_PRINTF,
84 except that it indicates to GCC that the supported format string directives
85 are the ones of the system printf(), rather than the ones standardized by
86 ISO C99 and POSIX. */
87#define _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM(formatstring_parameter, first_argument) \
88 _GL_ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument))
89
90/* _GL_ATTRIBUTE_FORMAT_SCANF
91 indicates to GCC that the function takes a format string and arguments,
92 where the format string directives are the ones standardized by ISO C99
93 and POSIX. */
94#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
95# define _GL_ATTRIBUTE_FORMAT_SCANF(formatstring_parameter, first_argument) \
96 _GL_ATTRIBUTE_FORMAT ((__gnu_scanf__, formatstring_parameter, first_argument))
97#else
98# define _GL_ATTRIBUTE_FORMAT_SCANF(formatstring_parameter, first_argument) \
99 _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument))
100#endif
101
102/* _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM is like _GL_ATTRIBUTE_FORMAT_SCANF,
103 except that it indicates to GCC that the supported format string directives
104 are the ones of the system scanf(), rather than the ones standardized by
105 ISO C99 and POSIX. */
106#define _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM(formatstring_parameter, first_argument) \
107 _GL_ATTRIBUTE_FORMAT ((__scanf__, formatstring_parameter, first_argument))
108
109/* Solaris 10 declares renameat in <unistd.h>, not in <stdio.h>. */
110/* But in any case avoid namespace pollution on glibc systems. */
111#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && defined __sun \
112 && ! defined __GLIBC__
113# include <unistd.h>
57#endif 114#endif
58 115
59 116
@@ -74,13 +131,13 @@
74# define dprintf rpl_dprintf 131# define dprintf rpl_dprintf
75# endif 132# endif
76_GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *format, ...) 133_GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *format, ...)
77 __attribute__ ((__format__ (__printf__, 2, 3))) 134 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
78 _GL_ARG_NONNULL ((2))); 135 _GL_ARG_NONNULL ((2)));
79_GL_CXXALIAS_RPL (dprintf, int, (int fd, const char *format, ...)); 136_GL_CXXALIAS_RPL (dprintf, int, (int fd, const char *format, ...));
80# else 137# else
81# if !@HAVE_DPRINTF@ 138# if !@HAVE_DPRINTF@
82_GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *format, ...) 139_GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *format, ...)
83 __attribute__ ((__format__ (__printf__, 2, 3))) 140 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
84 _GL_ARG_NONNULL ((2))); 141 _GL_ARG_NONNULL ((2)));
85# endif 142# endif
86_GL_CXXALIAS_SYS (dprintf, int, (int fd, const char *format, ...)); 143_GL_CXXALIAS_SYS (dprintf, int, (int fd, const char *format, ...));
@@ -113,6 +170,26 @@ _GL_WARN_ON_USE (fclose, "fclose is not always POSIX compliant - "
113 "use gnulib module fclose for portable POSIX compliance"); 170 "use gnulib module fclose for portable POSIX compliance");
114#endif 171#endif
115 172
173#if @GNULIB_FDOPEN@
174# if @REPLACE_FDOPEN@
175# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
176# undef fdopen
177# define fdopen rpl_fdopen
178# endif
179_GL_FUNCDECL_RPL (fdopen, FILE *, (int fd, const char *mode)
180 _GL_ARG_NONNULL ((2)));
181_GL_CXXALIAS_RPL (fdopen, FILE *, (int fd, const char *mode));
182# else
183_GL_CXXALIAS_SYS (fdopen, FILE *, (int fd, const char *mode));
184# endif
185_GL_CXXALIASWARN (fdopen);
186#elif defined GNULIB_POSIXCHECK
187# undef fdopen
188/* Assume fdopen is always declared. */
189_GL_WARN_ON_USE (fdopen, "fdopen on native Windows platforms is not POSIX compliant - "
190 "use gnulib module fdopen for portability");
191#endif
192
116#if @GNULIB_FFLUSH@ 193#if @GNULIB_FFLUSH@
117/* Flush all pending data on STREAM according to POSIX rules. Both 194/* Flush all pending data on STREAM according to POSIX rules. Both
118 output and seekable input streams are supported. 195 output and seekable input streams are supported.
@@ -137,11 +214,34 @@ _GL_WARN_ON_USE (fflush, "fflush is not always POSIX compliant - "
137 "use gnulib module fflush for portable POSIX compliance"); 214 "use gnulib module fflush for portable POSIX compliance");
138#endif 215#endif
139 216
140/* It is very rare that the developer ever has full control of stdin, 217#if @GNULIB_FGETC@
141 so any use of gets warrants an unconditional warning. Assume it is 218# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
142 always declared, since it is required by C89. */ 219# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
143#undef gets 220# undef fgetc
144_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); 221# define fgetc rpl_fgetc
222# endif
223_GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
224_GL_CXXALIAS_RPL (fgetc, int, (FILE *stream));
225# else
226_GL_CXXALIAS_SYS (fgetc, int, (FILE *stream));
227# endif
228_GL_CXXALIASWARN (fgetc);
229#endif
230
231#if @GNULIB_FGETS@
232# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
233# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
234# undef fgets
235# define fgets rpl_fgets
236# endif
237_GL_FUNCDECL_RPL (fgets, char *, (char *s, int n, FILE *stream)
238 _GL_ARG_NONNULL ((1, 3)));
239_GL_CXXALIAS_RPL (fgets, char *, (char *s, int n, FILE *stream));
240# else
241_GL_CXXALIAS_SYS (fgets, char *, (char *s, int n, FILE *stream));
242# endif
243_GL_CXXALIASWARN (fgets);
244#endif
145 245
146#if @GNULIB_FOPEN@ 246#if @GNULIB_FOPEN@
147# if @REPLACE_FOPEN@ 247# if @REPLACE_FOPEN@
@@ -159,20 +259,26 @@ _GL_CXXALIASWARN (fopen);
159#elif defined GNULIB_POSIXCHECK 259#elif defined GNULIB_POSIXCHECK
160# undef fopen 260# undef fopen
161/* Assume fopen is always declared. */ 261/* Assume fopen is always declared. */
162_GL_WARN_ON_USE (fopen, "fopen on Win32 platforms is not POSIX compatible - " 262_GL_WARN_ON_USE (fopen, "fopen on native Windows platforms is not POSIX compliant - "
163 "use gnulib module fopen for portability"); 263 "use gnulib module fopen for portability");
164#endif 264#endif
165 265
166#if @GNULIB_FPRINTF_POSIX@ || @GNULIB_FPRINTF@ 266#if @GNULIB_FPRINTF_POSIX@ || @GNULIB_FPRINTF@
167# if (@GNULIB_FPRINTF_POSIX@ && @REPLACE_FPRINTF@) \ 267# if (@GNULIB_FPRINTF_POSIX@ && @REPLACE_FPRINTF@) \
168 || (@GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@) 268 || (@GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
169# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 269# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
170# define fprintf rpl_fprintf 270# define fprintf rpl_fprintf
171# endif 271# endif
172# define GNULIB_overrides_fprintf 1 272# define GNULIB_overrides_fprintf 1
273# if @GNULIB_FPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
173_GL_FUNCDECL_RPL (fprintf, int, (FILE *fp, const char *format, ...) 274_GL_FUNCDECL_RPL (fprintf, int, (FILE *fp, const char *format, ...)
174 __attribute__ ((__format__ (__printf__, 2, 3))) 275 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
175 _GL_ARG_NONNULL ((1, 2))); 276 _GL_ARG_NONNULL ((1, 2)));
277# else
278_GL_FUNCDECL_RPL (fprintf, int, (FILE *fp, const char *format, ...)
279 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 3)
280 _GL_ARG_NONNULL ((1, 2)));
281# endif
176_GL_CXXALIAS_RPL (fprintf, int, (FILE *fp, const char *format, ...)); 282_GL_CXXALIAS_RPL (fprintf, int, (FILE *fp, const char *format, ...));
177# else 283# else
178_GL_CXXALIAS_SYS (fprintf, int, (FILE *fp, const char *format, ...)); 284_GL_CXXALIAS_SYS (fprintf, int, (FILE *fp, const char *format, ...));
@@ -218,7 +324,7 @@ _GL_WARN_ON_USE (fpurge, "fpurge is not always present - "
218#endif 324#endif
219 325
220#if @GNULIB_FPUTC@ 326#if @GNULIB_FPUTC@
221# if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ 327# if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
222# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 328# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
223# undef fputc 329# undef fputc
224# define fputc rpl_fputc 330# define fputc rpl_fputc
@@ -232,7 +338,7 @@ _GL_CXXALIASWARN (fputc);
232#endif 338#endif
233 339
234#if @GNULIB_FPUTS@ 340#if @GNULIB_FPUTS@
235# if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ 341# if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
236# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 342# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
237# undef fputs 343# undef fputs
238# define fputs rpl_fputs 344# define fputs rpl_fputs
@@ -246,6 +352,21 @@ _GL_CXXALIAS_SYS (fputs, int, (const char *string, FILE *stream));
246_GL_CXXALIASWARN (fputs); 352_GL_CXXALIASWARN (fputs);
247#endif 353#endif
248 354
355#if @GNULIB_FREAD@
356# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
357# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
358# undef fread
359# define fread rpl_fread
360# endif
361_GL_FUNCDECL_RPL (fread, size_t, (void *ptr, size_t s, size_t n, FILE *stream)
362 _GL_ARG_NONNULL ((4)));
363_GL_CXXALIAS_RPL (fread, size_t, (void *ptr, size_t s, size_t n, FILE *stream));
364# else
365_GL_CXXALIAS_SYS (fread, size_t, (void *ptr, size_t s, size_t n, FILE *stream));
366# endif
367_GL_CXXALIASWARN (fread);
368#endif
369
249#if @GNULIB_FREOPEN@ 370#if @GNULIB_FREOPEN@
250# if @REPLACE_FREOPEN@ 371# if @REPLACE_FREOPEN@
251# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 372# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -265,10 +386,27 @@ _GL_CXXALIASWARN (freopen);
265#elif defined GNULIB_POSIXCHECK 386#elif defined GNULIB_POSIXCHECK
266# undef freopen 387# undef freopen
267/* Assume freopen is always declared. */ 388/* Assume freopen is always declared. */
268_GL_WARN_ON_USE (freopen, "freopen on Win32 platforms is not POSIX compatible - " 389_GL_WARN_ON_USE (freopen,
390 "freopen on native Windows platforms is not POSIX compliant - "
269 "use gnulib module freopen for portability"); 391 "use gnulib module freopen for portability");
270#endif 392#endif
271 393
394#if @GNULIB_FSCANF@
395# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
396# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
397# undef fscanf
398# define fscanf rpl_fscanf
399# endif
400_GL_FUNCDECL_RPL (fscanf, int, (FILE *stream, const char *format, ...)
401 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 3)
402 _GL_ARG_NONNULL ((1, 2)));
403_GL_CXXALIAS_RPL (fscanf, int, (FILE *stream, const char *format, ...));
404# else
405_GL_CXXALIAS_SYS (fscanf, int, (FILE *stream, const char *format, ...));
406# endif
407_GL_CXXALIASWARN (fscanf);
408#endif
409
272 410
273/* Set up the following warnings, based on which modules are in use. 411/* Set up the following warnings, based on which modules are in use.
274 GNU Coding Standards discourage the use of fseek, since it imposes 412 GNU Coding Standards discourage the use of fseek, since it imposes
@@ -336,29 +474,13 @@ _GL_FUNCDECL_RPL (fseeko, int, (FILE *fp, off_t offset, int whence)
336 _GL_ARG_NONNULL ((1))); 474 _GL_ARG_NONNULL ((1)));
337_GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence)); 475_GL_CXXALIAS_RPL (fseeko, int, (FILE *fp, off_t offset, int whence));
338# else 476# else
339# if ! @HAVE_FSEEKO@ 477# if ! @HAVE_DECL_FSEEKO@
340_GL_FUNCDECL_SYS (fseeko, int, (FILE *fp, off_t offset, int whence) 478_GL_FUNCDECL_SYS (fseeko, int, (FILE *fp, off_t offset, int whence)
341 _GL_ARG_NONNULL ((1))); 479 _GL_ARG_NONNULL ((1)));
342# endif 480# endif
343_GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence)); 481_GL_CXXALIAS_SYS (fseeko, int, (FILE *fp, off_t offset, int whence));
344# endif 482# endif
345_GL_CXXALIASWARN (fseeko); 483_GL_CXXALIASWARN (fseeko);
346# if (@REPLACE_FSEEKO@ || !@HAVE_FSEEKO@) && !@GNULIB_FSEEK@
347 /* Provide an fseek function that is consistent with fseeko. */
348 /* In order to avoid that fseek gets defined as a macro here, the
349 developer can request the 'fseek' module. */
350# undef fseek
351# define fseek rpl_fseek
352static inline int _GL_ARG_NONNULL ((1))
353rpl_fseek (FILE *fp, long offset, int whence)
354{
355# if @REPLACE_FSEEKO@
356 return rpl_fseeko (fp, offset, whence);
357# else
358 return fseeko (fp, offset, whence);
359# endif
360}
361# endif
362#elif defined GNULIB_POSIXCHECK 484#elif defined GNULIB_POSIXCHECK
363# define _GL_FSEEK_WARN /* Category 1, above. */ 485# define _GL_FSEEK_WARN /* Category 1, above. */
364# undef fseek 486# undef fseek
@@ -412,28 +534,12 @@ _GL_CXXALIASWARN (ftell);
412_GL_FUNCDECL_RPL (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1))); 534_GL_FUNCDECL_RPL (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1)));
413_GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp)); 535_GL_CXXALIAS_RPL (ftello, off_t, (FILE *fp));
414# else 536# else
415# if ! @HAVE_FTELLO@ 537# if ! @HAVE_DECL_FTELLO@
416_GL_FUNCDECL_SYS (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1))); 538_GL_FUNCDECL_SYS (ftello, off_t, (FILE *fp) _GL_ARG_NONNULL ((1)));
417# endif 539# endif
418_GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp)); 540_GL_CXXALIAS_SYS (ftello, off_t, (FILE *fp));
419# endif 541# endif
420_GL_CXXALIASWARN (ftello); 542_GL_CXXALIASWARN (ftello);
421# if (@REPLACE_FTELLO@ || !@HAVE_FTELLO@) && !@GNULIB_FTELL@
422 /* Provide an ftell function that is consistent with ftello. */
423 /* In order to avoid that ftell gets defined as a macro here, the
424 developer can request the 'ftell' module. */
425# undef ftell
426# define ftell rpl_ftell
427static inline long _GL_ARG_NONNULL ((1))
428rpl_ftell (FILE *f)
429{
430# if @REPLACE_FTELLO@
431 return rpl_ftello (f);
432# else
433 return ftello (f);
434# endif
435}
436# endif
437#elif defined GNULIB_POSIXCHECK 543#elif defined GNULIB_POSIXCHECK
438# define _GL_FTELL_WARN /* Category 1, above. */ 544# define _GL_FTELL_WARN /* Category 1, above. */
439# undef ftell 545# undef ftell
@@ -455,7 +561,7 @@ _GL_WARN_ON_USE (ftell, "ftell cannot handle files larger than 4 GB "
455 561
456 562
457#if @GNULIB_FWRITE@ 563#if @GNULIB_FWRITE@
458# if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ 564# if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
459# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 565# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
460# undef fwrite 566# undef fwrite
461# define fwrite rpl_fwrite 567# define fwrite rpl_fwrite
@@ -468,10 +574,61 @@ _GL_CXXALIAS_RPL (fwrite, size_t,
468# else 574# else
469_GL_CXXALIAS_SYS (fwrite, size_t, 575_GL_CXXALIAS_SYS (fwrite, size_t,
470 (const void *ptr, size_t s, size_t n, FILE *stream)); 576 (const void *ptr, size_t s, size_t n, FILE *stream));
577
578/* Work around bug 11959 when fortifying glibc 2.4 through 2.15
579 <http://sources.redhat.com/bugzilla/show_bug.cgi?id=11959>,
580 which sometimes causes an unwanted diagnostic for fwrite calls.
581 This affects only function declaration attributes under certain
582 versions of gcc and clang, and is not needed for C++. */
583# if (0 < __USE_FORTIFY_LEVEL \
584 && __GLIBC__ == 2 && 4 <= __GLIBC_MINOR__ && __GLIBC_MINOR__ <= 15 \
585 && 3 < __GNUC__ + (4 <= __GNUC_MINOR__) \
586 && !defined __cplusplus)
587# undef fwrite
588# undef fwrite_unlocked
589extern size_t __REDIRECT (rpl_fwrite,
590 (const void *__restrict, size_t, size_t,
591 FILE *__restrict),
592 fwrite);
593extern size_t __REDIRECT (rpl_fwrite_unlocked,
594 (const void *__restrict, size_t, size_t,
595 FILE *__restrict),
596 fwrite_unlocked);
597# define fwrite rpl_fwrite
598# define fwrite_unlocked rpl_fwrite_unlocked
599# endif
471# endif 600# endif
472_GL_CXXALIASWARN (fwrite); 601_GL_CXXALIASWARN (fwrite);
473#endif 602#endif
474 603
604#if @GNULIB_GETC@
605# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
606# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
607# undef getc
608# define getc rpl_fgetc
609# endif
610_GL_FUNCDECL_RPL (fgetc, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
611_GL_CXXALIAS_RPL_1 (getc, rpl_fgetc, int, (FILE *stream));
612# else
613_GL_CXXALIAS_SYS (getc, int, (FILE *stream));
614# endif
615_GL_CXXALIASWARN (getc);
616#endif
617
618#if @GNULIB_GETCHAR@
619# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
620# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
621# undef getchar
622# define getchar rpl_getchar
623# endif
624_GL_FUNCDECL_RPL (getchar, int, (void));
625_GL_CXXALIAS_RPL (getchar, int, (void));
626# else
627_GL_CXXALIAS_SYS (getchar, int, (void));
628# endif
629_GL_CXXALIASWARN (getchar);
630#endif
631
475#if @GNULIB_GETDELIM@ 632#if @GNULIB_GETDELIM@
476/* Read input, up to (and including) the next occurrence of DELIMITER, from 633/* Read input, up to (and including) the next occurrence of DELIMITER, from
477 STREAM, store it in *LINEPTR (and NUL-terminate it). 634 STREAM, store it in *LINEPTR (and NUL-terminate it).
@@ -548,6 +705,15 @@ _GL_WARN_ON_USE (getline, "getline is unportable - "
548# endif 705# endif
549#endif 706#endif
550 707
708/* It is very rare that the developer ever has full control of stdin,
709 so any use of gets warrants an unconditional warning; besides, C11
710 removed it. */
711#undef gets
712#if HAVE_RAW_DECL_GETS
713_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
714#endif
715
716
551#if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@ 717#if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@
552struct obstack; 718struct obstack;
553/* Grow an obstack with formatted output. Return the number of 719/* Grow an obstack with formatted output. Return the number of
@@ -561,7 +727,7 @@ struct obstack;
561# endif 727# endif
562_GL_FUNCDECL_RPL (obstack_printf, int, 728_GL_FUNCDECL_RPL (obstack_printf, int,
563 (struct obstack *obs, const char *format, ...) 729 (struct obstack *obs, const char *format, ...)
564 __attribute__ ((__format__ (__printf__, 2, 3))) 730 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
565 _GL_ARG_NONNULL ((1, 2))); 731 _GL_ARG_NONNULL ((1, 2)));
566_GL_CXXALIAS_RPL (obstack_printf, int, 732_GL_CXXALIAS_RPL (obstack_printf, int,
567 (struct obstack *obs, const char *format, ...)); 733 (struct obstack *obs, const char *format, ...));
@@ -569,7 +735,7 @@ _GL_CXXALIAS_RPL (obstack_printf, int,
569# if !@HAVE_DECL_OBSTACK_PRINTF@ 735# if !@HAVE_DECL_OBSTACK_PRINTF@
570_GL_FUNCDECL_SYS (obstack_printf, int, 736_GL_FUNCDECL_SYS (obstack_printf, int,
571 (struct obstack *obs, const char *format, ...) 737 (struct obstack *obs, const char *format, ...)
572 __attribute__ ((__format__ (__printf__, 2, 3))) 738 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
573 _GL_ARG_NONNULL ((1, 2))); 739 _GL_ARG_NONNULL ((1, 2)));
574# endif 740# endif
575_GL_CXXALIAS_SYS (obstack_printf, int, 741_GL_CXXALIAS_SYS (obstack_printf, int,
@@ -582,7 +748,7 @@ _GL_CXXALIASWARN (obstack_printf);
582# endif 748# endif
583_GL_FUNCDECL_RPL (obstack_vprintf, int, 749_GL_FUNCDECL_RPL (obstack_vprintf, int,
584 (struct obstack *obs, const char *format, va_list args) 750 (struct obstack *obs, const char *format, va_list args)
585 __attribute__ ((__format__ (__printf__, 2, 0))) 751 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
586 _GL_ARG_NONNULL ((1, 2))); 752 _GL_ARG_NONNULL ((1, 2)));
587_GL_CXXALIAS_RPL (obstack_vprintf, int, 753_GL_CXXALIAS_RPL (obstack_vprintf, int,
588 (struct obstack *obs, const char *format, va_list args)); 754 (struct obstack *obs, const char *format, va_list args));
@@ -590,7 +756,7 @@ _GL_CXXALIAS_RPL (obstack_vprintf, int,
590# if !@HAVE_DECL_OBSTACK_PRINTF@ 756# if !@HAVE_DECL_OBSTACK_PRINTF@
591_GL_FUNCDECL_SYS (obstack_vprintf, int, 757_GL_FUNCDECL_SYS (obstack_vprintf, int,
592 (struct obstack *obs, const char *format, va_list args) 758 (struct obstack *obs, const char *format, va_list args)
593 __attribute__ ((__format__ (__printf__, 2, 0))) 759 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
594 _GL_ARG_NONNULL ((1, 2))); 760 _GL_ARG_NONNULL ((1, 2)));
595# endif 761# endif
596_GL_CXXALIAS_SYS (obstack_vprintf, int, 762_GL_CXXALIAS_SYS (obstack_vprintf, int,
@@ -599,6 +765,20 @@ _GL_CXXALIAS_SYS (obstack_vprintf, int,
599_GL_CXXALIASWARN (obstack_vprintf); 765_GL_CXXALIASWARN (obstack_vprintf);
600#endif 766#endif
601 767
768#if @GNULIB_PCLOSE@
769# if !@HAVE_PCLOSE@
770_GL_FUNCDECL_SYS (pclose, int, (FILE *stream) _GL_ARG_NONNULL ((1)));
771# endif
772_GL_CXXALIAS_SYS (pclose, int, (FILE *stream));
773_GL_CXXALIASWARN (pclose);
774#elif defined GNULIB_POSIXCHECK
775# undef pclose
776# if HAVE_RAW_DECL_PCLOSE
777_GL_WARN_ON_USE (pclose, "pclose is unportable - "
778 "use gnulib module pclose for more portability");
779# endif
780#endif
781
602#if @GNULIB_PERROR@ 782#if @GNULIB_PERROR@
603/* Print a message to standard error, describing the value of ERRNO, 783/* Print a message to standard error, describing the value of ERRNO,
604 (if STRING is not NULL and not empty) prefixed with STRING and ": ", 784 (if STRING is not NULL and not empty) prefixed with STRING and ": ",
@@ -630,6 +810,10 @@ _GL_FUNCDECL_RPL (popen, FILE *, (const char *cmd, const char *mode)
630 _GL_ARG_NONNULL ((1, 2))); 810 _GL_ARG_NONNULL ((1, 2)));
631_GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode)); 811_GL_CXXALIAS_RPL (popen, FILE *, (const char *cmd, const char *mode));
632# else 812# else
813# if !@HAVE_POPEN@
814_GL_FUNCDECL_SYS (popen, FILE *, (const char *cmd, const char *mode)
815 _GL_ARG_NONNULL ((1, 2)));
816# endif
633_GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode)); 817_GL_CXXALIAS_SYS (popen, FILE *, (const char *cmd, const char *mode));
634# endif 818# endif
635_GL_CXXALIASWARN (popen); 819_GL_CXXALIASWARN (popen);
@@ -643,23 +827,35 @@ _GL_WARN_ON_USE (popen, "popen is buggy on some platforms - "
643 827
644#if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@ 828#if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@
645# if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \ 829# if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \
646 || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@) 830 || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
647# if defined __GNUC__ 831# if defined __GNUC__
648# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 832# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
649/* Don't break __attribute__((format(printf,M,N))). */ 833/* Don't break __attribute__((format(printf,M,N))). */
650# define printf __printf__ 834# define printf __printf__
651# endif 835# endif
836# if @GNULIB_PRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
837_GL_FUNCDECL_RPL_1 (__printf__, int,
838 (const char *format, ...)
839 __asm__ (@ASM_SYMBOL_PREFIX@
840 _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf))
841 _GL_ATTRIBUTE_FORMAT_PRINTF (1, 2)
842 _GL_ARG_NONNULL ((1)));
843# else
652_GL_FUNCDECL_RPL_1 (__printf__, int, 844_GL_FUNCDECL_RPL_1 (__printf__, int,
653 (const char *format, ...) 845 (const char *format, ...)
654 __asm__ (@ASM_SYMBOL_PREFIX@ 846 __asm__ (@ASM_SYMBOL_PREFIX@
655 _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf)) 847 _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf))
656 __attribute__ ((__format__ (__printf__, 1, 2))) 848 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 2)
657 _GL_ARG_NONNULL ((1))); 849 _GL_ARG_NONNULL ((1)));
850# endif
658_GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...)); 851_GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...));
659# else 852# else
853# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
854# define printf rpl_printf
855# endif
660_GL_FUNCDECL_RPL (printf, int, 856_GL_FUNCDECL_RPL (printf, int,
661 (const char *format, ...) 857 (const char *format, ...)
662 __attribute__ ((__format__ (__printf__, 1, 2))) 858 _GL_ATTRIBUTE_FORMAT_PRINTF (1, 2)
663 _GL_ARG_NONNULL ((1))); 859 _GL_ARG_NONNULL ((1)));
664_GL_CXXALIAS_RPL (printf, int, (const char *format, ...)); 860_GL_CXXALIAS_RPL (printf, int, (const char *format, ...));
665# endif 861# endif
@@ -680,7 +876,7 @@ _GL_WARN_ON_USE (printf, "printf is not always POSIX compliant - "
680#endif 876#endif
681 877
682#if @GNULIB_PUTC@ 878#if @GNULIB_PUTC@
683# if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ 879# if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
684# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 880# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
685# undef putc 881# undef putc
686# define putc rpl_fputc 882# define putc rpl_fputc
@@ -694,7 +890,7 @@ _GL_CXXALIASWARN (putc);
694#endif 890#endif
695 891
696#if @GNULIB_PUTCHAR@ 892#if @GNULIB_PUTCHAR@
697# if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ 893# if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
698# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 894# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
699# undef putchar 895# undef putchar
700# define putchar rpl_putchar 896# define putchar rpl_putchar
@@ -708,7 +904,7 @@ _GL_CXXALIASWARN (putchar);
708#endif 904#endif
709 905
710#if @GNULIB_PUTS@ 906#if @GNULIB_PUTS@
711# if @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@ 907# if @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@)
712# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 908# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
713# undef puts 909# undef puts
714# define puts rpl_puts 910# define puts rpl_puts
@@ -792,6 +988,37 @@ _GL_WARN_ON_USE (renameat, "renameat is not portable - "
792# endif 988# endif
793#endif 989#endif
794 990
991#if @GNULIB_SCANF@
992# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
993# if defined __GNUC__
994# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
995# undef scanf
996/* Don't break __attribute__((format(scanf,M,N))). */
997# define scanf __scanf__
998# endif
999_GL_FUNCDECL_RPL_1 (__scanf__, int,
1000 (const char *format, ...)
1001 __asm__ (@ASM_SYMBOL_PREFIX@
1002 _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_scanf))
1003 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2)
1004 _GL_ARG_NONNULL ((1)));
1005_GL_CXXALIAS_RPL_1 (scanf, __scanf__, int, (const char *format, ...));
1006# else
1007# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1008# undef scanf
1009# define scanf rpl_scanf
1010# endif
1011_GL_FUNCDECL_RPL (scanf, int, (const char *format, ...)
1012 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 2)
1013 _GL_ARG_NONNULL ((1)));
1014_GL_CXXALIAS_RPL (scanf, int, (const char *format, ...));
1015# endif
1016# else
1017_GL_CXXALIAS_SYS (scanf, int, (const char *format, ...));
1018# endif
1019_GL_CXXALIASWARN (scanf);
1020#endif
1021
795#if @GNULIB_SNPRINTF@ 1022#if @GNULIB_SNPRINTF@
796# if @REPLACE_SNPRINTF@ 1023# if @REPLACE_SNPRINTF@
797# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1024# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -799,7 +1026,7 @@ _GL_WARN_ON_USE (renameat, "renameat is not portable - "
799# endif 1026# endif
800_GL_FUNCDECL_RPL (snprintf, int, 1027_GL_FUNCDECL_RPL (snprintf, int,
801 (char *str, size_t size, const char *format, ...) 1028 (char *str, size_t size, const char *format, ...)
802 __attribute__ ((__format__ (__printf__, 3, 4))) 1029 _GL_ATTRIBUTE_FORMAT_PRINTF (3, 4)
803 _GL_ARG_NONNULL ((3))); 1030 _GL_ARG_NONNULL ((3)));
804_GL_CXXALIAS_RPL (snprintf, int, 1031_GL_CXXALIAS_RPL (snprintf, int,
805 (char *str, size_t size, const char *format, ...)); 1032 (char *str, size_t size, const char *format, ...));
@@ -807,7 +1034,7 @@ _GL_CXXALIAS_RPL (snprintf, int,
807# if !@HAVE_DECL_SNPRINTF@ 1034# if !@HAVE_DECL_SNPRINTF@
808_GL_FUNCDECL_SYS (snprintf, int, 1035_GL_FUNCDECL_SYS (snprintf, int,
809 (char *str, size_t size, const char *format, ...) 1036 (char *str, size_t size, const char *format, ...)
810 __attribute__ ((__format__ (__printf__, 3, 4))) 1037 _GL_ATTRIBUTE_FORMAT_PRINTF (3, 4)
811 _GL_ARG_NONNULL ((3))); 1038 _GL_ARG_NONNULL ((3)));
812# endif 1039# endif
813_GL_CXXALIAS_SYS (snprintf, int, 1040_GL_CXXALIAS_SYS (snprintf, int,
@@ -822,9 +1049,9 @@ _GL_WARN_ON_USE (snprintf, "snprintf is unportable - "
822# endif 1049# endif
823#endif 1050#endif
824 1051
825/* Some people would argue that sprintf should be handled like gets 1052/* Some people would argue that all sprintf uses should be warned about
826 (for example, OpenBSD issues a link warning for both functions), 1053 (for example, OpenBSD issues a link warning for it),
827 since both can cause security holes due to buffer overruns. 1054 since it can cause security holes due to buffer overruns.
828 However, we believe that sprintf can be used safely, and is more 1055 However, we believe that sprintf can be used safely, and is more
829 efficient than snprintf in those safe cases; and as proof of our 1056 efficient than snprintf in those safe cases; and as proof of our
830 belief, we use sprintf in several gnulib modules. So this header 1057 belief, we use sprintf in several gnulib modules. So this header
@@ -837,7 +1064,7 @@ _GL_WARN_ON_USE (snprintf, "snprintf is unportable - "
837# define sprintf rpl_sprintf 1064# define sprintf rpl_sprintf
838# endif 1065# endif
839_GL_FUNCDECL_RPL (sprintf, int, (char *str, const char *format, ...) 1066_GL_FUNCDECL_RPL (sprintf, int, (char *str, const char *format, ...)
840 __attribute__ ((__format__ (__printf__, 2, 3))) 1067 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
841 _GL_ARG_NONNULL ((1, 2))); 1068 _GL_ARG_NONNULL ((1, 2)));
842_GL_CXXALIAS_RPL (sprintf, int, (char *str, const char *format, ...)); 1069_GL_CXXALIAS_RPL (sprintf, int, (char *str, const char *format, ...));
843# else 1070# else
@@ -882,7 +1109,7 @@ _GL_WARN_ON_USE (tmpfile, "tmpfile is not usable on mingw - "
882# endif 1109# endif
883_GL_FUNCDECL_RPL (asprintf, int, 1110_GL_FUNCDECL_RPL (asprintf, int,
884 (char **result, const char *format, ...) 1111 (char **result, const char *format, ...)
885 __attribute__ ((__format__ (__printf__, 2, 3))) 1112 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
886 _GL_ARG_NONNULL ((1, 2))); 1113 _GL_ARG_NONNULL ((1, 2)));
887_GL_CXXALIAS_RPL (asprintf, int, 1114_GL_CXXALIAS_RPL (asprintf, int,
888 (char **result, const char *format, ...)); 1115 (char **result, const char *format, ...));
@@ -890,7 +1117,7 @@ _GL_CXXALIAS_RPL (asprintf, int,
890# if !@HAVE_VASPRINTF@ 1117# if !@HAVE_VASPRINTF@
891_GL_FUNCDECL_SYS (asprintf, int, 1118_GL_FUNCDECL_SYS (asprintf, int,
892 (char **result, const char *format, ...) 1119 (char **result, const char *format, ...)
893 __attribute__ ((__format__ (__printf__, 2, 3))) 1120 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
894 _GL_ARG_NONNULL ((1, 2))); 1121 _GL_ARG_NONNULL ((1, 2)));
895# endif 1122# endif
896_GL_CXXALIAS_SYS (asprintf, int, 1123_GL_CXXALIAS_SYS (asprintf, int,
@@ -903,7 +1130,7 @@ _GL_CXXALIASWARN (asprintf);
903# endif 1130# endif
904_GL_FUNCDECL_RPL (vasprintf, int, 1131_GL_FUNCDECL_RPL (vasprintf, int,
905 (char **result, const char *format, va_list args) 1132 (char **result, const char *format, va_list args)
906 __attribute__ ((__format__ (__printf__, 2, 0))) 1133 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
907 _GL_ARG_NONNULL ((1, 2))); 1134 _GL_ARG_NONNULL ((1, 2)));
908_GL_CXXALIAS_RPL (vasprintf, int, 1135_GL_CXXALIAS_RPL (vasprintf, int,
909 (char **result, const char *format, va_list args)); 1136 (char **result, const char *format, va_list args));
@@ -911,7 +1138,7 @@ _GL_CXXALIAS_RPL (vasprintf, int,
911# if !@HAVE_VASPRINTF@ 1138# if !@HAVE_VASPRINTF@
912_GL_FUNCDECL_SYS (vasprintf, int, 1139_GL_FUNCDECL_SYS (vasprintf, int,
913 (char **result, const char *format, va_list args) 1140 (char **result, const char *format, va_list args)
914 __attribute__ ((__format__ (__printf__, 2, 0))) 1141 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
915 _GL_ARG_NONNULL ((1, 2))); 1142 _GL_ARG_NONNULL ((1, 2)));
916# endif 1143# endif
917_GL_CXXALIAS_SYS (vasprintf, int, 1144_GL_CXXALIAS_SYS (vasprintf, int,
@@ -926,13 +1153,13 @@ _GL_CXXALIASWARN (vasprintf);
926# define vdprintf rpl_vdprintf 1153# define vdprintf rpl_vdprintf
927# endif 1154# endif
928_GL_FUNCDECL_RPL (vdprintf, int, (int fd, const char *format, va_list args) 1155_GL_FUNCDECL_RPL (vdprintf, int, (int fd, const char *format, va_list args)
929 __attribute__ ((__format__ (__printf__, 2, 0))) 1156 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
930 _GL_ARG_NONNULL ((2))); 1157 _GL_ARG_NONNULL ((2)));
931_GL_CXXALIAS_RPL (vdprintf, int, (int fd, const char *format, va_list args)); 1158_GL_CXXALIAS_RPL (vdprintf, int, (int fd, const char *format, va_list args));
932# else 1159# else
933# if !@HAVE_VDPRINTF@ 1160# if !@HAVE_VDPRINTF@
934_GL_FUNCDECL_SYS (vdprintf, int, (int fd, const char *format, va_list args) 1161_GL_FUNCDECL_SYS (vdprintf, int, (int fd, const char *format, va_list args)
935 __attribute__ ((__format__ (__printf__, 2, 0))) 1162 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
936 _GL_ARG_NONNULL ((2))); 1163 _GL_ARG_NONNULL ((2)));
937# endif 1164# endif
938/* Need to cast, because on Solaris, the third parameter will likely be 1165/* Need to cast, because on Solaris, the third parameter will likely be
@@ -951,14 +1178,20 @@ _GL_WARN_ON_USE (vdprintf, "vdprintf is unportable - "
951 1178
952#if @GNULIB_VFPRINTF_POSIX@ || @GNULIB_VFPRINTF@ 1179#if @GNULIB_VFPRINTF_POSIX@ || @GNULIB_VFPRINTF@
953# if (@GNULIB_VFPRINTF_POSIX@ && @REPLACE_VFPRINTF@) \ 1180# if (@GNULIB_VFPRINTF_POSIX@ && @REPLACE_VFPRINTF@) \
954 || (@GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@) 1181 || (@GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
955# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1182# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
956# define vfprintf rpl_vfprintf 1183# define vfprintf rpl_vfprintf
957# endif 1184# endif
958# define GNULIB_overrides_vfprintf 1 1185# define GNULIB_overrides_vfprintf 1
1186# if @GNULIB_VFPRINTF_POSIX@
1187_GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args)
1188 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
1189 _GL_ARG_NONNULL ((1, 2)));
1190# else
959_GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args) 1191_GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args)
960 __attribute__ ((__format__ (__printf__, 2, 0))) 1192 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 0)
961 _GL_ARG_NONNULL ((1, 2))); 1193 _GL_ARG_NONNULL ((1, 2)));
1194# endif
962_GL_CXXALIAS_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args)); 1195_GL_CXXALIAS_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args));
963# else 1196# else
964/* Need to cast, because on Solaris, the third parameter is 1197/* Need to cast, because on Solaris, the third parameter is
@@ -979,16 +1212,41 @@ _GL_WARN_ON_USE (vfprintf, "vfprintf is not always POSIX compliant - "
979 "POSIX compliance"); 1212 "POSIX compliance");
980#endif 1213#endif
981 1214
1215#if @GNULIB_VFSCANF@
1216# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
1217# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1218# undef vfscanf
1219# define vfscanf rpl_vfscanf
1220# endif
1221_GL_FUNCDECL_RPL (vfscanf, int,
1222 (FILE *stream, const char *format, va_list args)
1223 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (2, 0)
1224 _GL_ARG_NONNULL ((1, 2)));
1225_GL_CXXALIAS_RPL (vfscanf, int,
1226 (FILE *stream, const char *format, va_list args));
1227# else
1228_GL_CXXALIAS_SYS (vfscanf, int,
1229 (FILE *stream, const char *format, va_list args));
1230# endif
1231_GL_CXXALIASWARN (vfscanf);
1232#endif
1233
982#if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@ 1234#if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@
983# if (@GNULIB_VPRINTF_POSIX@ && @REPLACE_VPRINTF@) \ 1235# if (@GNULIB_VPRINTF_POSIX@ && @REPLACE_VPRINTF@) \
984 || (@GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@) 1236 || (@GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
985# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1237# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
986# define vprintf rpl_vprintf 1238# define vprintf rpl_vprintf
987# endif 1239# endif
988# define GNULIB_overrides_vprintf 1 1240# define GNULIB_overrides_vprintf 1
1241# if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
989_GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args) 1242_GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args)
990 __attribute__ ((__format__ (__printf__, 1, 0))) 1243 _GL_ATTRIBUTE_FORMAT_PRINTF (1, 0)
991 _GL_ARG_NONNULL ((1))); 1244 _GL_ARG_NONNULL ((1)));
1245# else
1246_GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args)
1247 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 0)
1248 _GL_ARG_NONNULL ((1)));
1249# endif
992_GL_CXXALIAS_RPL (vprintf, int, (const char *format, va_list args)); 1250_GL_CXXALIAS_RPL (vprintf, int, (const char *format, va_list args));
993# else 1251# else
994/* Need to cast, because on Solaris, the second parameter is 1252/* Need to cast, because on Solaris, the second parameter is
@@ -1008,6 +1266,22 @@ _GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - "
1008 "POSIX compliance"); 1266 "POSIX compliance");
1009#endif 1267#endif
1010 1268
1269#if @GNULIB_VSCANF@
1270# if @REPLACE_STDIO_READ_FUNCS@ && @GNULIB_STDIO_H_NONBLOCKING@
1271# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1272# undef vscanf
1273# define vscanf rpl_vscanf
1274# endif
1275_GL_FUNCDECL_RPL (vscanf, int, (const char *format, va_list args)
1276 _GL_ATTRIBUTE_FORMAT_SCANF_SYSTEM (1, 0)
1277 _GL_ARG_NONNULL ((1)));
1278_GL_CXXALIAS_RPL (vscanf, int, (const char *format, va_list args));
1279# else
1280_GL_CXXALIAS_SYS (vscanf, int, (const char *format, va_list args));
1281# endif
1282_GL_CXXALIASWARN (vscanf);
1283#endif
1284
1011#if @GNULIB_VSNPRINTF@ 1285#if @GNULIB_VSNPRINTF@
1012# if @REPLACE_VSNPRINTF@ 1286# if @REPLACE_VSNPRINTF@
1013# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1287# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -1015,7 +1289,7 @@ _GL_WARN_ON_USE (vprintf, "vprintf is not always POSIX compliant - "
1015# endif 1289# endif
1016_GL_FUNCDECL_RPL (vsnprintf, int, 1290_GL_FUNCDECL_RPL (vsnprintf, int,
1017 (char *str, size_t size, const char *format, va_list args) 1291 (char *str, size_t size, const char *format, va_list args)
1018 __attribute__ ((__format__ (__printf__, 3, 0))) 1292 _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0)
1019 _GL_ARG_NONNULL ((3))); 1293 _GL_ARG_NONNULL ((3)));
1020_GL_CXXALIAS_RPL (vsnprintf, int, 1294_GL_CXXALIAS_RPL (vsnprintf, int,
1021 (char *str, size_t size, const char *format, va_list args)); 1295 (char *str, size_t size, const char *format, va_list args));
@@ -1023,7 +1297,7 @@ _GL_CXXALIAS_RPL (vsnprintf, int,
1023# if !@HAVE_DECL_VSNPRINTF@ 1297# if !@HAVE_DECL_VSNPRINTF@
1024_GL_FUNCDECL_SYS (vsnprintf, int, 1298_GL_FUNCDECL_SYS (vsnprintf, int,
1025 (char *str, size_t size, const char *format, va_list args) 1299 (char *str, size_t size, const char *format, va_list args)
1026 __attribute__ ((__format__ (__printf__, 3, 0))) 1300 _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0)
1027 _GL_ARG_NONNULL ((3))); 1301 _GL_ARG_NONNULL ((3)));
1028# endif 1302# endif
1029_GL_CXXALIAS_SYS (vsnprintf, int, 1303_GL_CXXALIAS_SYS (vsnprintf, int,
@@ -1045,7 +1319,7 @@ _GL_WARN_ON_USE (vsnprintf, "vsnprintf is unportable - "
1045# endif 1319# endif
1046_GL_FUNCDECL_RPL (vsprintf, int, 1320_GL_FUNCDECL_RPL (vsprintf, int,
1047 (char *str, const char *format, va_list args) 1321 (char *str, const char *format, va_list args)
1048 __attribute__ ((__format__ (__printf__, 2, 0))) 1322 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
1049 _GL_ARG_NONNULL ((1, 2))); 1323 _GL_ARG_NONNULL ((1, 2)));
1050_GL_CXXALIAS_RPL (vsprintf, int, 1324_GL_CXXALIAS_RPL (vsprintf, int,
1051 (char *str, const char *format, va_list args)); 1325 (char *str, const char *format, va_list args));
@@ -1065,7 +1339,6 @@ _GL_WARN_ON_USE (vsprintf, "vsprintf is not always POSIX compliant - "
1065 "POSIX compliance"); 1339 "POSIX compliance");
1066#endif 1340#endif
1067 1341
1068 1342#endif /* _@GUARD_PREFIX@_STDIO_H */
1069#endif /* _GL_STDIO_H */ 1343#endif /* _@GUARD_PREFIX@_STDIO_H */
1070#endif /* _GL_STDIO_H */
1071#endif 1344#endif
diff --git a/gl/stdlib.in.h b/gl/stdlib.in.h
index d4ac469..c955248 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-2010 Free Software Foundation, Inc. 3 Copyright (C) 1995, 2001-2004, 2006-2013 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
@@ -18,43 +18,60 @@
18#if __GNUC__ >= 3 18#if __GNUC__ >= 3
19@PRAGMA_SYSTEM_HEADER@ 19@PRAGMA_SYSTEM_HEADER@
20#endif 20#endif
21@PRAGMA_COLUMNS@
21 22
22#if defined __need_malloc_and_calloc 23#if defined __need_system_stdlib_h || defined __need_malloc_and_calloc
23/* Special invocation convention inside glibc header files. */ 24/* Special invocation conventions inside some gnulib header files,
25 and inside some glibc header files, respectively. */
24 26
25#@INCLUDE_NEXT@ @NEXT_STDLIB_H@ 27#@INCLUDE_NEXT@ @NEXT_STDLIB_H@
26 28
27#else 29#else
28/* Normal invocation convention. */ 30/* Normal invocation convention. */
29 31
30#ifndef _GL_STDLIB_H 32#ifndef _@GUARD_PREFIX@_STDLIB_H
31 33
32/* The include_next requires a split double-inclusion guard. */ 34/* The include_next requires a split double-inclusion guard. */
33#@INCLUDE_NEXT@ @NEXT_STDLIB_H@ 35#@INCLUDE_NEXT@ @NEXT_STDLIB_H@
34 36
35#ifndef _GL_STDLIB_H 37#ifndef _@GUARD_PREFIX@_STDLIB_H
36#define _GL_STDLIB_H 38#define _@GUARD_PREFIX@_STDLIB_H
37 39
38/* NetBSD 5.0 mis-defines NULL. */ 40/* NetBSD 5.0 mis-defines NULL. */
39#include <stddef.h> 41#include <stddef.h>
40 42
43/* MirBSD 10 defines WEXITSTATUS in <sys/wait.h>, not in <stdlib.h>. */
44#if @GNULIB_SYSTEM_POSIX@ && !defined WEXITSTATUS
45# include <sys/wait.h>
46#endif
47
41/* Solaris declares getloadavg() in <sys/loadavg.h>. */ 48/* Solaris declares getloadavg() in <sys/loadavg.h>. */
42#if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@ 49#if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@
43# include <sys/loadavg.h> 50# include <sys/loadavg.h>
44#endif 51#endif
45 52
46/* OSF/1 5.1 declares 'struct random_data' in <random.h>, which is included 53/* Native Windows platforms declare mktemp() in <io.h>. */
47 from <stdlib.h> if _REENTRANT is defined. Include it always. */ 54#if 0 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
48#if @HAVE_RANDOM_H@ 55# include <io.h>
49# include <random.h>
50#endif 56#endif
51 57
52#if !@HAVE_STRUCT_RANDOM_DATA@ || (@GNULIB_RANDOM_R@ && !@HAVE_RANDOM_R@) \ 58#if @GNULIB_RANDOM_R@
53 || defined GNULIB_POSIXCHECK 59
54# include <stdint.h> 60/* OSF/1 5.1 declares 'struct random_data' in <random.h>, which is included
55#endif 61 from <stdlib.h> if _REENTRANT is defined. Include it whenever we need
62 'struct random_data'. */
63# if @HAVE_RANDOM_H@
64# include <random.h>
65# endif
56 66
57#if !@HAVE_STRUCT_RANDOM_DATA@ 67# if !@HAVE_STRUCT_RANDOM_DATA@ || @REPLACE_RANDOM_R@ || !@HAVE_RANDOM_R@
68# include <stdint.h>
69# endif
70
71# if !@HAVE_STRUCT_RANDOM_DATA@
72/* Define 'struct random_data'.
73 But allow multiple gnulib generated <stdlib.h> replacements to coexist. */
74# if !GNULIB_defined_struct_random_data
58struct random_data 75struct random_data
59{ 76{
60 int32_t *fptr; /* Front pointer. */ 77 int32_t *fptr; /* Front pointer. */
@@ -65,21 +82,29 @@ struct random_data
65 int rand_sep; /* Distance between front and rear. */ 82 int rand_sep; /* Distance between front and rear. */
66 int32_t *end_ptr; /* Pointer behind state table. */ 83 int32_t *end_ptr; /* Pointer behind state table. */
67}; 84};
85# define GNULIB_defined_struct_random_data 1
86# endif
87# endif
68#endif 88#endif
69 89
70#if (@GNULIB_MKSTEMP@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) 90#if (@GNULIB_MKSTEMP@ || @GNULIB_MKSTEMPS@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
71/* On MacOS X 10.3, only <unistd.h> declares mkstemp. */ 91/* On Mac OS X 10.3, only <unistd.h> declares mkstemp. */
92/* On Mac OS X 10.5, only <unistd.h> declares mkstemps. */
72/* On Cygwin 1.7.1, only <unistd.h> declares getsubopt. */ 93/* On Cygwin 1.7.1, only <unistd.h> declares getsubopt. */
73/* But avoid namespace pollution on glibc systems and native Windows. */ 94/* But avoid namespace pollution on glibc systems and native Windows. */
74# include <unistd.h> 95# include <unistd.h>
75#endif 96#endif
76 97
77#ifndef __attribute__ 98/* The __attribute__ feature is available in gcc versions 2.5 and later.
78# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) 99 The attribute __pure__ was added in gcc 2.96. */
79# define __attribute__(Spec) /* empty */ 100#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
80# endif 101# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
102#else
103# define _GL_ATTRIBUTE_PURE /* empty */
81#endif 104#endif
82 105
106/* The definition of _Noreturn is copied here. */
107
83/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 108/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
84 109
85/* The definition of _GL_ARG_NONNULL is copied here. */ 110/* The definition of _GL_ARG_NONNULL is copied here. */
@@ -105,7 +130,7 @@ struct random_data
105/* Terminate the current process with the given return code, without running 130/* Terminate the current process with the given return code, without running
106 the 'atexit' handlers. */ 131 the 'atexit' handlers. */
107# if !@HAVE__EXIT@ 132# if !@HAVE__EXIT@
108_GL_FUNCDECL_SYS (_Exit, void, (int status) __attribute__ ((__noreturn__))); 133_GL_FUNCDECL_SYS (_Exit, _Noreturn void, (int status));
109# endif 134# endif
110_GL_CXXALIAS_SYS (_Exit, void, (int status)); 135_GL_CXXALIAS_SYS (_Exit, void, (int status));
111_GL_CXXALIASWARN (_Exit); 136_GL_CXXALIASWARN (_Exit);
@@ -122,7 +147,9 @@ _GL_WARN_ON_USE (_Exit, "_Exit is unportable - "
122/* Parse a signed decimal integer. 147/* Parse a signed decimal integer.
123 Returns the value of the integer. Errors are not detected. */ 148 Returns the value of the integer. Errors are not detected. */
124# if !@HAVE_ATOLL@ 149# if !@HAVE_ATOLL@
125_GL_FUNCDECL_SYS (atoll, long long, (const char *string) _GL_ARG_NONNULL ((1))); 150_GL_FUNCDECL_SYS (atoll, long long, (const char *string)
151 _GL_ATTRIBUTE_PURE
152 _GL_ARG_NONNULL ((1)));
126# endif 153# endif
127_GL_CXXALIAS_SYS (atoll, long long, (const char *string)); 154_GL_CXXALIAS_SYS (atoll, long long, (const char *string));
128_GL_CXXALIASWARN (atoll); 155_GL_CXXALIASWARN (atoll);
@@ -172,7 +199,8 @@ _GL_CXXALIASWARN (canonicalize_file_name);
172#elif defined GNULIB_POSIXCHECK 199#elif defined GNULIB_POSIXCHECK
173# undef canonicalize_file_name 200# undef canonicalize_file_name
174# if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME 201# if HAVE_RAW_DECL_CANONICALIZE_FILE_NAME
175_GL_WARN_ON_USE (canonicalize_file_name, "canonicalize_file_name is unportable - " 202_GL_WARN_ON_USE (canonicalize_file_name,
203 "canonicalize_file_name is unportable - "
176 "use gnulib module canonicalize-lgpl for portability"); 204 "use gnulib module canonicalize-lgpl for portability");
177# endif 205# endif
178#endif 206#endif
@@ -235,14 +263,19 @@ _GL_CXXALIASWARN (grantpt);
235#elif defined GNULIB_POSIXCHECK 263#elif defined GNULIB_POSIXCHECK
236# undef grantpt 264# undef grantpt
237# if HAVE_RAW_DECL_GRANTPT 265# if HAVE_RAW_DECL_GRANTPT
238_GL_WARN_ON_USE (ptsname, "grantpt is not portable - " 266_GL_WARN_ON_USE (grantpt, "grantpt is not portable - "
239 "use gnulib module grantpt for portability"); 267 "use gnulib module grantpt for portability");
240# endif 268# endif
241#endif 269#endif
242 270
271/* If _GL_USE_STDLIB_ALLOC is nonzero, the including module does not
272 rely on GNU or POSIX semantics for malloc and realloc (for example,
273 by never specifying a zero size), so it does not need malloc or
274 realloc to be redefined. */
243#if @GNULIB_MALLOC_POSIX@ 275#if @GNULIB_MALLOC_POSIX@
244# if @REPLACE_MALLOC@ 276# if @REPLACE_MALLOC@
245# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 277# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
278 || _GL_USE_STDLIB_ALLOC)
246# undef malloc 279# undef malloc
247# define malloc rpl_malloc 280# define malloc rpl_malloc
248# endif 281# endif
@@ -252,13 +285,28 @@ _GL_CXXALIAS_RPL (malloc, void *, (size_t size));
252_GL_CXXALIAS_SYS (malloc, void *, (size_t size)); 285_GL_CXXALIAS_SYS (malloc, void *, (size_t size));
253# endif 286# endif
254_GL_CXXALIASWARN (malloc); 287_GL_CXXALIASWARN (malloc);
255#elif defined GNULIB_POSIXCHECK 288#elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
256# undef malloc 289# undef malloc
257/* Assume malloc is always declared. */ 290/* Assume malloc is always declared. */
258_GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - " 291_GL_WARN_ON_USE (malloc, "malloc is not POSIX compliant everywhere - "
259 "use gnulib module malloc-posix for portability"); 292 "use gnulib module malloc-posix for portability");
260#endif 293#endif
261 294
295/* Convert a multibyte character to a wide character. */
296#if @GNULIB_MBTOWC@
297# if @REPLACE_MBTOWC@
298# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
299# undef mbtowc
300# define mbtowc rpl_mbtowc
301# endif
302_GL_FUNCDECL_RPL (mbtowc, int, (wchar_t *pwc, const char *s, size_t n));
303_GL_CXXALIAS_RPL (mbtowc, int, (wchar_t *pwc, const char *s, size_t n));
304# else
305_GL_CXXALIAS_SYS (mbtowc, int, (wchar_t *pwc, const char *s, size_t n));
306# endif
307_GL_CXXALIASWARN (mbtowc);
308#endif
309
262#if @GNULIB_MKDTEMP@ 310#if @GNULIB_MKDTEMP@
263/* Create a unique temporary directory from TEMPLATE. 311/* Create a unique temporary directory from TEMPLATE.
264 The last six characters of TEMPLATE must be "XXXXXX"; 312 The last six characters of TEMPLATE must be "XXXXXX";
@@ -391,13 +439,38 @@ _GL_WARN_ON_USE (mkstemps, "mkstemps is unportable - "
391# endif 439# endif
392#endif 440#endif
393 441
442#if @GNULIB_POSIX_OPENPT@
443/* Return an FD open to the master side of a pseudo-terminal. Flags should
444 include O_RDWR, and may also include O_NOCTTY. */
445# if !@HAVE_POSIX_OPENPT@
446_GL_FUNCDECL_SYS (posix_openpt, int, (int flags));
447# endif
448_GL_CXXALIAS_SYS (posix_openpt, int, (int flags));
449_GL_CXXALIASWARN (posix_openpt);
450#elif defined GNULIB_POSIXCHECK
451# undef posix_openpt
452# if HAVE_RAW_DECL_POSIX_OPENPT
453_GL_WARN_ON_USE (posix_openpt, "posix_openpt is not portable - "
454 "use gnulib module posix_openpt for portability");
455# endif
456#endif
457
394#if @GNULIB_PTSNAME@ 458#if @GNULIB_PTSNAME@
395/* Return the pathname of the pseudo-terminal slave associated with 459/* Return the pathname of the pseudo-terminal slave associated with
396 the master FD is open on, or NULL on errors. */ 460 the master FD is open on, or NULL on errors. */
397# if !@HAVE_PTSNAME@ 461# if @REPLACE_PTSNAME@
462# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
463# undef ptsname
464# define ptsname rpl_ptsname
465# endif
466_GL_FUNCDECL_RPL (ptsname, char *, (int fd));
467_GL_CXXALIAS_RPL (ptsname, char *, (int fd));
468# else
469# if !@HAVE_PTSNAME@
398_GL_FUNCDECL_SYS (ptsname, char *, (int fd)); 470_GL_FUNCDECL_SYS (ptsname, char *, (int fd));
399# endif 471# endif
400_GL_CXXALIAS_SYS (ptsname, char *, (int fd)); 472_GL_CXXALIAS_SYS (ptsname, char *, (int fd));
473# endif
401_GL_CXXALIASWARN (ptsname); 474_GL_CXXALIASWARN (ptsname);
402#elif defined GNULIB_POSIXCHECK 475#elif defined GNULIB_POSIXCHECK
403# undef ptsname 476# undef ptsname
@@ -407,6 +480,32 @@ _GL_WARN_ON_USE (ptsname, "ptsname is not portable - "
407# endif 480# endif
408#endif 481#endif
409 482
483#if @GNULIB_PTSNAME_R@
484/* Set the pathname of the pseudo-terminal slave associated with
485 the master FD is open on and return 0, or set errno and return
486 non-zero on errors. */
487# if @REPLACE_PTSNAME_R@
488# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
489# undef ptsname_r
490# define ptsname_r rpl_ptsname_r
491# endif
492_GL_FUNCDECL_RPL (ptsname_r, int, (int fd, char *buf, size_t len));
493_GL_CXXALIAS_RPL (ptsname_r, int, (int fd, char *buf, size_t len));
494# else
495# if !@HAVE_PTSNAME_R@
496_GL_FUNCDECL_SYS (ptsname_r, int, (int fd, char *buf, size_t len));
497# endif
498_GL_CXXALIAS_SYS (ptsname_r, int, (int fd, char *buf, size_t len));
499# endif
500_GL_CXXALIASWARN (ptsname_r);
501#elif defined GNULIB_POSIXCHECK
502# undef ptsname_r
503# if HAVE_RAW_DECL_PTSNAME_R
504_GL_WARN_ON_USE (ptsname_r, "ptsname_r is not portable - "
505 "use gnulib module ptsname_r for portability");
506# endif
507#endif
508
410#if @GNULIB_PUTENV@ 509#if @GNULIB_PUTENV@
411# if @REPLACE_PUTENV@ 510# if @REPLACE_PUTENV@
412# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 511# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -430,12 +529,83 @@ _GL_CXXALIASWARN (putenv);
430# endif 529# endif
431#endif 530#endif
432 531
532
533#if @GNULIB_RANDOM@
534# if !@HAVE_RANDOM@
535_GL_FUNCDECL_SYS (random, long, (void));
536# endif
537_GL_CXXALIAS_SYS (random, long, (void));
538_GL_CXXALIASWARN (random);
539#elif defined GNULIB_POSIXCHECK
540# undef random
541# if HAVE_RAW_DECL_RANDOM
542_GL_WARN_ON_USE (random, "random is unportable - "
543 "use gnulib module random for portability");
544# endif
545#endif
546
547#if @GNULIB_RANDOM@
548# if !@HAVE_RANDOM@
549_GL_FUNCDECL_SYS (srandom, void, (unsigned int seed));
550# endif
551_GL_CXXALIAS_SYS (srandom, void, (unsigned int seed));
552_GL_CXXALIASWARN (srandom);
553#elif defined GNULIB_POSIXCHECK
554# undef srandom
555# if HAVE_RAW_DECL_SRANDOM
556_GL_WARN_ON_USE (srandom, "srandom is unportable - "
557 "use gnulib module random for portability");
558# endif
559#endif
560
561#if @GNULIB_RANDOM@
562# if !@HAVE_RANDOM@
563_GL_FUNCDECL_SYS (initstate, char *,
564 (unsigned int seed, char *buf, size_t buf_size)
565 _GL_ARG_NONNULL ((2)));
566# endif
567_GL_CXXALIAS_SYS (initstate, char *,
568 (unsigned int seed, char *buf, size_t buf_size));
569_GL_CXXALIASWARN (initstate);
570#elif defined GNULIB_POSIXCHECK
571# undef initstate
572# if HAVE_RAW_DECL_INITSTATE_R
573_GL_WARN_ON_USE (initstate, "initstate is unportable - "
574 "use gnulib module random for portability");
575# endif
576#endif
577
578#if @GNULIB_RANDOM@
579# if !@HAVE_RANDOM@
580_GL_FUNCDECL_SYS (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1)));
581# endif
582_GL_CXXALIAS_SYS (setstate, char *, (char *arg_state));
583_GL_CXXALIASWARN (setstate);
584#elif defined GNULIB_POSIXCHECK
585# undef setstate
586# if HAVE_RAW_DECL_SETSTATE_R
587_GL_WARN_ON_USE (setstate, "setstate is unportable - "
588 "use gnulib module random for portability");
589# endif
590#endif
591
592
433#if @GNULIB_RANDOM_R@ 593#if @GNULIB_RANDOM_R@
434# if !@HAVE_RANDOM_R@ 594# if @REPLACE_RANDOM_R@
595# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
596# undef random_r
597# define random_r rpl_random_r
598# endif
599_GL_FUNCDECL_RPL (random_r, int, (struct random_data *buf, int32_t *result)
600 _GL_ARG_NONNULL ((1, 2)));
601_GL_CXXALIAS_RPL (random_r, int, (struct random_data *buf, int32_t *result));
602# else
603# if !@HAVE_RANDOM_R@
435_GL_FUNCDECL_SYS (random_r, int, (struct random_data *buf, int32_t *result) 604_GL_FUNCDECL_SYS (random_r, int, (struct random_data *buf, int32_t *result)
436 _GL_ARG_NONNULL ((1, 2))); 605 _GL_ARG_NONNULL ((1, 2)));
437# endif 606# endif
438_GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result)); 607_GL_CXXALIAS_SYS (random_r, int, (struct random_data *buf, int32_t *result));
608# endif
439_GL_CXXALIASWARN (random_r); 609_GL_CXXALIASWARN (random_r);
440#elif defined GNULIB_POSIXCHECK 610#elif defined GNULIB_POSIXCHECK
441# undef random_r 611# undef random_r
@@ -446,13 +616,25 @@ _GL_WARN_ON_USE (random_r, "random_r is unportable - "
446#endif 616#endif
447 617
448#if @GNULIB_RANDOM_R@ 618#if @GNULIB_RANDOM_R@
449# if !@HAVE_RANDOM_R@ 619# if @REPLACE_RANDOM_R@
620# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
621# undef srandom_r
622# define srandom_r rpl_srandom_r
623# endif
624_GL_FUNCDECL_RPL (srandom_r, int,
625 (unsigned int seed, struct random_data *rand_state)
626 _GL_ARG_NONNULL ((2)));
627_GL_CXXALIAS_RPL (srandom_r, int,
628 (unsigned int seed, struct random_data *rand_state));
629# else
630# if !@HAVE_RANDOM_R@
450_GL_FUNCDECL_SYS (srandom_r, int, 631_GL_FUNCDECL_SYS (srandom_r, int,
451 (unsigned int seed, struct random_data *rand_state) 632 (unsigned int seed, struct random_data *rand_state)
452 _GL_ARG_NONNULL ((2))); 633 _GL_ARG_NONNULL ((2)));
453# endif 634# endif
454_GL_CXXALIAS_SYS (srandom_r, int, 635_GL_CXXALIAS_SYS (srandom_r, int,
455 (unsigned int seed, struct random_data *rand_state)); 636 (unsigned int seed, struct random_data *rand_state));
637# endif
456_GL_CXXALIASWARN (srandom_r); 638_GL_CXXALIASWARN (srandom_r);
457#elif defined GNULIB_POSIXCHECK 639#elif defined GNULIB_POSIXCHECK
458# undef srandom_r 640# undef srandom_r
@@ -463,15 +645,29 @@ _GL_WARN_ON_USE (srandom_r, "srandom_r is unportable - "
463#endif 645#endif
464 646
465#if @GNULIB_RANDOM_R@ 647#if @GNULIB_RANDOM_R@
466# if !@HAVE_RANDOM_R@ 648# if @REPLACE_RANDOM_R@
649# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
650# undef initstate_r
651# define initstate_r rpl_initstate_r
652# endif
653_GL_FUNCDECL_RPL (initstate_r, int,
654 (unsigned int seed, char *buf, size_t buf_size,
655 struct random_data *rand_state)
656 _GL_ARG_NONNULL ((2, 4)));
657_GL_CXXALIAS_RPL (initstate_r, int,
658 (unsigned int seed, char *buf, size_t buf_size,
659 struct random_data *rand_state));
660# else
661# if !@HAVE_RANDOM_R@
467_GL_FUNCDECL_SYS (initstate_r, int, 662_GL_FUNCDECL_SYS (initstate_r, int,
468 (unsigned int seed, char *buf, size_t buf_size, 663 (unsigned int seed, char *buf, size_t buf_size,
469 struct random_data *rand_state) 664 struct random_data *rand_state)
470 _GL_ARG_NONNULL ((2, 4))); 665 _GL_ARG_NONNULL ((2, 4)));
471# endif 666# endif
472_GL_CXXALIAS_SYS (initstate_r, int, 667_GL_CXXALIAS_SYS (initstate_r, int,
473 (unsigned int seed, char *buf, size_t buf_size, 668 (unsigned int seed, char *buf, size_t buf_size,
474 struct random_data *rand_state)); 669 struct random_data *rand_state));
670# endif
475_GL_CXXALIASWARN (initstate_r); 671_GL_CXXALIASWARN (initstate_r);
476#elif defined GNULIB_POSIXCHECK 672#elif defined GNULIB_POSIXCHECK
477# undef initstate_r 673# undef initstate_r
@@ -482,13 +678,25 @@ _GL_WARN_ON_USE (initstate_r, "initstate_r is unportable - "
482#endif 678#endif
483 679
484#if @GNULIB_RANDOM_R@ 680#if @GNULIB_RANDOM_R@
485# if !@HAVE_RANDOM_R@ 681# if @REPLACE_RANDOM_R@
682# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
683# undef setstate_r
684# define setstate_r rpl_setstate_r
685# endif
686_GL_FUNCDECL_RPL (setstate_r, int,
687 (char *arg_state, struct random_data *rand_state)
688 _GL_ARG_NONNULL ((1, 2)));
689_GL_CXXALIAS_RPL (setstate_r, int,
690 (char *arg_state, struct random_data *rand_state));
691# else
692# if !@HAVE_RANDOM_R@
486_GL_FUNCDECL_SYS (setstate_r, int, 693_GL_FUNCDECL_SYS (setstate_r, int,
487 (char *arg_state, struct random_data *rand_state) 694 (char *arg_state, struct random_data *rand_state)
488 _GL_ARG_NONNULL ((1, 2))); 695 _GL_ARG_NONNULL ((1, 2)));
489# endif 696# endif
490_GL_CXXALIAS_SYS (setstate_r, int, 697_GL_CXXALIAS_SYS (setstate_r, int,
491 (char *arg_state, struct random_data *rand_state)); 698 (char *arg_state, struct random_data *rand_state));
699# endif
492_GL_CXXALIASWARN (setstate_r); 700_GL_CXXALIASWARN (setstate_r);
493#elif defined GNULIB_POSIXCHECK 701#elif defined GNULIB_POSIXCHECK
494# undef setstate_r 702# undef setstate_r
@@ -501,7 +709,8 @@ _GL_WARN_ON_USE (setstate_r, "setstate_r is unportable - "
501 709
502#if @GNULIB_REALLOC_POSIX@ 710#if @GNULIB_REALLOC_POSIX@
503# if @REPLACE_REALLOC@ 711# if @REPLACE_REALLOC@
504# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 712# if !((defined __cplusplus && defined GNULIB_NAMESPACE) \
713 || _GL_USE_STDLIB_ALLOC)
505# undef realloc 714# undef realloc
506# define realloc rpl_realloc 715# define realloc rpl_realloc
507# endif 716# endif
@@ -511,7 +720,7 @@ _GL_CXXALIAS_RPL (realloc, void *, (void *ptr, size_t size));
511_GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size)); 720_GL_CXXALIAS_SYS (realloc, void *, (void *ptr, size_t size));
512# endif 721# endif
513_GL_CXXALIASWARN (realloc); 722_GL_CXXALIASWARN (realloc);
514#elif defined GNULIB_POSIXCHECK 723#elif defined GNULIB_POSIXCHECK && !_GL_USE_STDLIB_ALLOC
515# undef realloc 724# undef realloc
516/* Assume realloc is always declared. */ 725/* Assume realloc is always declared. */
517_GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - " 726_GL_WARN_ON_USE (realloc, "realloc is not POSIX compliant everywhere - "
@@ -558,6 +767,22 @@ _GL_WARN_ON_USE (rpmatch, "rpmatch is unportable - "
558# endif 767# endif
559#endif 768#endif
560 769
770#if @GNULIB_SECURE_GETENV@
771/* Look up NAME in the environment, returning 0 in insecure situations. */
772# if !@HAVE_SECURE_GETENV@
773_GL_FUNCDECL_SYS (secure_getenv, char *,
774 (char const *name) _GL_ARG_NONNULL ((1)));
775# endif
776_GL_CXXALIAS_SYS (secure_getenv, char *, (char const *name));
777_GL_CXXALIASWARN (secure_getenv);
778#elif defined GNULIB_POSIXCHECK
779# undef secure_getenv
780# if HAVE_RAW_DECL_SECURE_GETENV
781_GL_WARN_ON_USE (secure_getenv, "secure_getenv is unportable - "
782 "use gnulib module secure_getenv for portability");
783# endif
784#endif
785
561#if @GNULIB_SETENV@ 786#if @GNULIB_SETENV@
562/* Set NAME to VALUE in the environment. 787/* Set NAME to VALUE in the environment.
563 If REPLACE is nonzero, overwrite an existing value. */ 788 If REPLACE is nonzero, overwrite an existing value. */
@@ -572,7 +797,7 @@ _GL_FUNCDECL_RPL (setenv, int,
572_GL_CXXALIAS_RPL (setenv, int, 797_GL_CXXALIAS_RPL (setenv, int,
573 (const char *name, const char *value, int replace)); 798 (const char *name, const char *value, int replace));
574# else 799# else
575# if !@HAVE_SETENV@ 800# if !@HAVE_DECL_SETENV@
576_GL_FUNCDECL_SYS (setenv, int, 801_GL_FUNCDECL_SYS (setenv, int,
577 (const char *name, const char *value, int replace) 802 (const char *name, const char *value, int replace)
578 _GL_ARG_NONNULL ((1))); 803 _GL_ARG_NONNULL ((1)));
@@ -580,7 +805,9 @@ _GL_FUNCDECL_SYS (setenv, int,
580_GL_CXXALIAS_SYS (setenv, int, 805_GL_CXXALIAS_SYS (setenv, int,
581 (const char *name, const char *value, int replace)); 806 (const char *name, const char *value, int replace));
582# endif 807# endif
808# if !(@REPLACE_SETENV@ && !@HAVE_DECL_SETENV@)
583_GL_CXXALIASWARN (setenv); 809_GL_CXXALIASWARN (setenv);
810# endif
584#elif defined GNULIB_POSIXCHECK 811#elif defined GNULIB_POSIXCHECK
585# undef setenv 812# undef setenv
586# if HAVE_RAW_DECL_SETENV 813# if HAVE_RAW_DECL_SETENV
@@ -675,7 +902,7 @@ _GL_CXXALIASWARN (unlockpt);
675#elif defined GNULIB_POSIXCHECK 902#elif defined GNULIB_POSIXCHECK
676# undef unlockpt 903# undef unlockpt
677# if HAVE_RAW_DECL_UNLOCKPT 904# if HAVE_RAW_DECL_UNLOCKPT
678_GL_WARN_ON_USE (ptsname, "unlockpt is not portable - " 905_GL_WARN_ON_USE (unlockpt, "unlockpt is not portable - "
679 "use gnulib module unlockpt for portability"); 906 "use gnulib module unlockpt for portability");
680# endif 907# endif
681#endif 908#endif
@@ -690,12 +917,14 @@ _GL_WARN_ON_USE (ptsname, "unlockpt is not portable - "
690_GL_FUNCDECL_RPL (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1))); 917_GL_FUNCDECL_RPL (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1)));
691_GL_CXXALIAS_RPL (unsetenv, int, (const char *name)); 918_GL_CXXALIAS_RPL (unsetenv, int, (const char *name));
692# else 919# else
693# if !@HAVE_UNSETENV@ 920# if !@HAVE_DECL_UNSETENV@
694_GL_FUNCDECL_SYS (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1))); 921_GL_FUNCDECL_SYS (unsetenv, int, (const char *name) _GL_ARG_NONNULL ((1)));
695# endif 922# endif
696_GL_CXXALIAS_SYS (unsetenv, int, (const char *name)); 923_GL_CXXALIAS_SYS (unsetenv, int, (const char *name));
697# endif 924# endif
925# if !(@REPLACE_UNSETENV@ && !@HAVE_DECL_UNSETENV@)
698_GL_CXXALIASWARN (unsetenv); 926_GL_CXXALIASWARN (unsetenv);
927# endif
699#elif defined GNULIB_POSIXCHECK 928#elif defined GNULIB_POSIXCHECK
700# undef unsetenv 929# undef unsetenv
701# if HAVE_RAW_DECL_UNSETENV 930# if HAVE_RAW_DECL_UNSETENV
@@ -704,7 +933,22 @@ _GL_WARN_ON_USE (unsetenv, "unsetenv is unportable - "
704# endif 933# endif
705#endif 934#endif
706 935
936/* Convert a wide character to a multibyte character. */
937#if @GNULIB_WCTOMB@
938# if @REPLACE_WCTOMB@
939# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
940# undef wctomb
941# define wctomb rpl_wctomb
942# endif
943_GL_FUNCDECL_RPL (wctomb, int, (char *s, wchar_t wc));
944_GL_CXXALIAS_RPL (wctomb, int, (char *s, wchar_t wc));
945# else
946_GL_CXXALIAS_SYS (wctomb, int, (char *s, wchar_t wc));
947# endif
948_GL_CXXALIASWARN (wctomb);
949#endif
950
707 951
708#endif /* _GL_STDLIB_H */ 952#endif /* _@GUARD_PREFIX@_STDLIB_H */
709#endif /* _GL_STDLIB_H */ 953#endif /* _@GUARD_PREFIX@_STDLIB_H */
710#endif 954#endif
diff --git a/gl/str-two-way.h b/gl/str-two-way.h
index 4d555f9..707145d 100644
--- a/gl/str-two-way.h
+++ b/gl/str-two-way.h
@@ -1,5 +1,5 @@
1/* Byte-wise substring search, using the Two-Way algorithm. 1/* Byte-wise substring search, using the Two-Way algorithm.
2 Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. 2 Copyright (C) 2008-2013 Free Software Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 Written by Eric Blake <ebb9@byu.net>, 2008. 4 Written by Eric Blake <ebb9@byu.net>, 2008.
5 5
@@ -14,8 +14,7 @@
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License along 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, 17 with this program; if not, see <http://www.gnu.org/licenses/>. */
18 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
19 18
20/* Before including this file, you need to include <config.h> and 19/* Before including this file, you need to include <config.h> and
21 <string.h>, and define: 20 <string.h>, and define:
@@ -44,14 +43,15 @@
44#include <limits.h> 43#include <limits.h>
45#include <stdint.h> 44#include <stdint.h>
46 45
47/* We use the Two-Way string matching algorithm, which guarantees 46/* We use the Two-Way string matching algorithm (also known as
48 linear complexity with constant space. Additionally, for long 47 Chrochemore-Perrin), which guarantees linear complexity with
49 needles, we also use a bad character shift table similar to the 48 constant space. Additionally, for long needles, we also use a bad
50 Boyer-Moore algorithm to achieve improved (potentially sub-linear) 49 character shift table similar to the Boyer-Moore algorithm to
51 performance. 50 achieve improved (potentially sub-linear) performance.
52 51
53 See http://www-igm.univ-mlv.fr/~lecroq/string/node26.html#SECTION00260 52 See http://www-igm.univ-mlv.fr/~lecroq/string/node26.html#SECTION00260,
54 and http://en.wikipedia.org/wiki/Boyer-Moore_string_search_algorithm 53 http://en.wikipedia.org/wiki/Boyer-Moore_string_search_algorithm,
54 http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.34.6641&rep=rep1&type=pdf
55*/ 55*/
56 56
57/* Point at which computing a bad-byte shift table is likely to be 57/* Point at which computing a bad-byte shift table is likely to be
@@ -108,7 +108,7 @@ static size_t
108critical_factorization (const unsigned char *needle, size_t needle_len, 108critical_factorization (const unsigned char *needle, size_t needle_len,
109 size_t *period) 109 size_t *period)
110{ 110{
111 /* Index of last byte of left half. */ 111 /* Index of last byte of left half, or SIZE_MAX. */
112 size_t max_suffix, max_suffix_rev; 112 size_t max_suffix, max_suffix_rev;
113 size_t j; /* Index into NEEDLE for current candidate suffix. */ 113 size_t j; /* Index into NEEDLE for current candidate suffix. */
114 size_t k; /* Offset into current period. */ 114 size_t k; /* Offset into current period. */
@@ -124,8 +124,8 @@ critical_factorization (const unsigned char *needle, size_t needle_len,
124 } 124 }
125 125
126 /* Invariants: 126 /* Invariants:
127 1 <= j < NEEDLE_LEN - 1 127 0 <= j < NEEDLE_LEN - 1
128 0 <= max_suffix{,_rev} < j 128 -1 <= max_suffix{,_rev} < j (treating SIZE_MAX as if it were signed)
129 min(max_suffix, max_suffix_rev) < global period of NEEDLE 129 min(max_suffix, max_suffix_rev) < global period of NEEDLE
130 1 <= p <= global period of NEEDLE 130 1 <= p <= global period of NEEDLE
131 p == global period of the substring NEEDLE[max_suffix{,_rev}+1...j] 131 p == global period of the substring NEEDLE[max_suffix{,_rev}+1...j]
@@ -133,8 +133,9 @@ critical_factorization (const unsigned char *needle, size_t needle_len,
133 */ 133 */
134 134
135 /* Perform lexicographic search. */ 135 /* Perform lexicographic search. */
136 max_suffix = 0; 136 max_suffix = SIZE_MAX;
137 j = k = p = 1; 137 j = 0;
138 k = p = 1;
138 while (j + k < needle_len) 139 while (j + k < needle_len)
139 { 140 {
140 a = CANON_ELEMENT (needle[j + k]); 141 a = CANON_ELEMENT (needle[j + k]);
@@ -167,8 +168,9 @@ critical_factorization (const unsigned char *needle, size_t needle_len,
167 *period = p; 168 *period = p;
168 169
169 /* Perform reverse lexicographic search. */ 170 /* Perform reverse lexicographic search. */
170 max_suffix_rev = 0; 171 max_suffix_rev = SIZE_MAX;
171 j = k = p = 1; 172 j = 0;
173 k = p = 1;
172 while (j + k < needle_len) 174 while (j + k < needle_len)
173 { 175 {
174 a = CANON_ELEMENT (needle[j + k]); 176 a = CANON_ELEMENT (needle[j + k]);
@@ -370,8 +372,8 @@ two_way_long_needle (const unsigned char *haystack, size_t haystack_len,
370 a byte out of place, there can be no match until 372 a byte out of place, there can be no match until
371 after the mismatch. */ 373 after the mismatch. */
372 shift = needle_len - period; 374 shift = needle_len - period;
373 memory = 0;
374 } 375 }
376 memory = 0;
375 j += shift; 377 j += shift;
376 continue; 378 continue;
377 } 379 }
diff --git a/gl/strdup.c b/gl/strdup.c
deleted file mode 100644
index 4b1794e..0000000
--- a/gl/strdup.c
+++ /dev/null
@@ -1,55 +0,0 @@
1/* Copyright (C) 1991, 1996, 1997, 1998, 2002, 2003, 2004, 2006, 2007, 2009,
2 2010 Free 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
index aa65bb8..12c1867 100644
--- a/gl/streq.h
+++ b/gl/streq.h
@@ -1,5 +1,5 @@
1/* Optimized string comparison. 1/* Optimized string comparison.
2 Copyright (C) 2001-2002, 2007, 2009-2010 Free Software Foundation, Inc. 2 Copyright (C) 2001-2002, 2007, 2009-2013 Free Software Foundation, Inc.
3 3
4 This program is free software: you can redistribute it and/or modify it 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 5 under the terms of the GNU General Public License as published
@@ -9,7 +9,7 @@
9 This program is distributed in the hope that it will be useful, 9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details. 12 General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 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/>. */ 15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
@@ -21,8 +21,8 @@
21 21
22#include <string.h> 22#include <string.h>
23 23
24/* STREQ allows to optimize string comparison with a small literal string. 24/* STREQ_OPT allows to optimize string comparison with a small literal string.
25 STREQ (s, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0) 25 STREQ_OPT (s, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
26 is semantically equivalent to 26 is semantically equivalent to
27 strcmp (s, "EUC-KR") == 0 27 strcmp (s, "EUC-KR") == 0
28 just faster. */ 28 just faster. */
@@ -163,12 +163,12 @@ streq0 (const char *s1, const char *s2, char s20, char s21, char s22, char s23,
163 return 0; 163 return 0;
164} 164}
165 165
166#define STREQ(s1,s2,s20,s21,s22,s23,s24,s25,s26,s27,s28) \ 166#define STREQ_OPT(s1,s2,s20,s21,s22,s23,s24,s25,s26,s27,s28) \
167 streq0 (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 168
169#else 169#else
170 170
171#define STREQ(s1,s2,s20,s21,s22,s23,s24,s25,s26,s27,s28) \ 171#define STREQ_OPT(s1,s2,s20,s21,s22,s23,s24,s25,s26,s27,s28) \
172 (strcmp (s1, s2) == 0) 172 (strcmp (s1, s2) == 0)
173 173
174#endif 174#endif
diff --git a/gl/strerror-override.c b/gl/strerror-override.c
new file mode 100644
index 0000000..d0ed2fb
--- /dev/null
+++ b/gl/strerror-override.c
@@ -0,0 +1,302 @@
1/* strerror-override.c --- POSIX compatible system error routine
2
3 Copyright (C) 2010-2013 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 Bruno Haible <bruno@clisp.org>, 2010. */
19
20#include <config.h>
21
22#include "strerror-override.h"
23
24#include <errno.h>
25
26#if GNULIB_defined_EWINSOCK /* native Windows platforms */
27# if HAVE_WINSOCK2_H
28# include <winsock2.h>
29# endif
30#endif
31
32/* If ERRNUM maps to an errno value defined by gnulib, return a string
33 describing the error. Otherwise return NULL. */
34const char *
35strerror_override (int errnum)
36{
37 /* These error messages are taken from glibc/sysdeps/gnu/errlist.c. */
38 switch (errnum)
39 {
40#if REPLACE_STRERROR_0
41 case 0:
42 return "Success";
43#endif
44
45#if GNULIB_defined_ESOCK /* native Windows platforms with older <errno.h> */
46 case EINPROGRESS:
47 return "Operation now in progress";
48 case EALREADY:
49 return "Operation already in progress";
50 case ENOTSOCK:
51 return "Socket operation on non-socket";
52 case EDESTADDRREQ:
53 return "Destination address required";
54 case EMSGSIZE:
55 return "Message too long";
56 case EPROTOTYPE:
57 return "Protocol wrong type for socket";
58 case ENOPROTOOPT:
59 return "Protocol not available";
60 case EPROTONOSUPPORT:
61 return "Protocol not supported";
62 case EOPNOTSUPP:
63 return "Operation not supported";
64 case EAFNOSUPPORT:
65 return "Address family not supported by protocol";
66 case EADDRINUSE:
67 return "Address already in use";
68 case EADDRNOTAVAIL:
69 return "Cannot assign requested address";
70 case ENETDOWN:
71 return "Network is down";
72 case ENETUNREACH:
73 return "Network is unreachable";
74 case ECONNRESET:
75 return "Connection reset by peer";
76 case ENOBUFS:
77 return "No buffer space available";
78 case EISCONN:
79 return "Transport endpoint is already connected";
80 case ENOTCONN:
81 return "Transport endpoint is not connected";
82 case ETIMEDOUT:
83 return "Connection timed out";
84 case ECONNREFUSED:
85 return "Connection refused";
86 case ELOOP:
87 return "Too many levels of symbolic links";
88 case EHOSTUNREACH:
89 return "No route to host";
90 case EWOULDBLOCK:
91 return "Operation would block";
92#endif
93#if GNULIB_defined_ESTREAMS /* native Windows platforms with older <errno.h> */
94 case ETXTBSY:
95 return "Text file busy";
96 case ENODATA:
97 return "No data available";
98 case ENOSR:
99 return "Out of streams resources";
100 case ENOSTR:
101 return "Device not a stream";
102 case ETIME:
103 return "Timer expired";
104 case EOTHER:
105 return "Other error";
106#endif
107#if GNULIB_defined_EWINSOCK /* native Windows platforms */
108 case ESOCKTNOSUPPORT:
109 return "Socket type not supported";
110 case EPFNOSUPPORT:
111 return "Protocol family not supported";
112 case ESHUTDOWN:
113 return "Cannot send after transport endpoint shutdown";
114 case ETOOMANYREFS:
115 return "Too many references: cannot splice";
116 case EHOSTDOWN:
117 return "Host is down";
118 case EPROCLIM:
119 return "Too many processes";
120 case EUSERS:
121 return "Too many users";
122 case EDQUOT:
123 return "Disk quota exceeded";
124 case ESTALE:
125 return "Stale NFS file handle";
126 case EREMOTE:
127 return "Object is remote";
128# if HAVE_WINSOCK2_H
129 /* WSA_INVALID_HANDLE maps to EBADF */
130 /* WSA_NOT_ENOUGH_MEMORY maps to ENOMEM */
131 /* WSA_INVALID_PARAMETER maps to EINVAL */
132 case WSA_OPERATION_ABORTED:
133 return "Overlapped operation aborted";
134 case WSA_IO_INCOMPLETE:
135 return "Overlapped I/O event object not in signaled state";
136 case WSA_IO_PENDING:
137 return "Overlapped operations will complete later";
138 /* WSAEINTR maps to EINTR */
139 /* WSAEBADF maps to EBADF */
140 /* WSAEACCES maps to EACCES */
141 /* WSAEFAULT maps to EFAULT */
142 /* WSAEINVAL maps to EINVAL */
143 /* WSAEMFILE maps to EMFILE */
144 /* WSAEWOULDBLOCK maps to EWOULDBLOCK */
145 /* WSAEINPROGRESS maps to EINPROGRESS */
146 /* WSAEALREADY maps to EALREADY */
147 /* WSAENOTSOCK maps to ENOTSOCK */
148 /* WSAEDESTADDRREQ maps to EDESTADDRREQ */
149 /* WSAEMSGSIZE maps to EMSGSIZE */
150 /* WSAEPROTOTYPE maps to EPROTOTYPE */
151 /* WSAENOPROTOOPT maps to ENOPROTOOPT */
152 /* WSAEPROTONOSUPPORT maps to EPROTONOSUPPORT */
153 /* WSAESOCKTNOSUPPORT is ESOCKTNOSUPPORT */
154 /* WSAEOPNOTSUPP maps to EOPNOTSUPP */
155 /* WSAEPFNOSUPPORT is EPFNOSUPPORT */
156 /* WSAEAFNOSUPPORT maps to EAFNOSUPPORT */
157 /* WSAEADDRINUSE maps to EADDRINUSE */
158 /* WSAEADDRNOTAVAIL maps to EADDRNOTAVAIL */
159 /* WSAENETDOWN maps to ENETDOWN */
160 /* WSAENETUNREACH maps to ENETUNREACH */
161 /* WSAENETRESET maps to ENETRESET */
162 /* WSAECONNABORTED maps to ECONNABORTED */
163 /* WSAECONNRESET maps to ECONNRESET */
164 /* WSAENOBUFS maps to ENOBUFS */
165 /* WSAEISCONN maps to EISCONN */
166 /* WSAENOTCONN maps to ENOTCONN */
167 /* WSAESHUTDOWN is ESHUTDOWN */
168 /* WSAETOOMANYREFS is ETOOMANYREFS */
169 /* WSAETIMEDOUT maps to ETIMEDOUT */
170 /* WSAECONNREFUSED maps to ECONNREFUSED */
171 /* WSAELOOP maps to ELOOP */
172 /* WSAENAMETOOLONG maps to ENAMETOOLONG */
173 /* WSAEHOSTDOWN is EHOSTDOWN */
174 /* WSAEHOSTUNREACH maps to EHOSTUNREACH */
175 /* WSAENOTEMPTY maps to ENOTEMPTY */
176 /* WSAEPROCLIM is EPROCLIM */
177 /* WSAEUSERS is EUSERS */
178 /* WSAEDQUOT is EDQUOT */
179 /* WSAESTALE is ESTALE */
180 /* WSAEREMOTE is EREMOTE */
181 case WSASYSNOTREADY:
182 return "Network subsystem is unavailable";
183 case WSAVERNOTSUPPORTED:
184 return "Winsock.dll version out of range";
185 case WSANOTINITIALISED:
186 return "Successful WSAStartup not yet performed";
187 case WSAEDISCON:
188 return "Graceful shutdown in progress";
189 case WSAENOMORE: case WSA_E_NO_MORE:
190 return "No more results";
191 case WSAECANCELLED: case WSA_E_CANCELLED:
192 return "Call was canceled";
193 case WSAEINVALIDPROCTABLE:
194 return "Procedure call table is invalid";
195 case WSAEINVALIDPROVIDER:
196 return "Service provider is invalid";
197 case WSAEPROVIDERFAILEDINIT:
198 return "Service provider failed to initialize";
199 case WSASYSCALLFAILURE:
200 return "System call failure";
201 case WSASERVICE_NOT_FOUND:
202 return "Service not found";
203 case WSATYPE_NOT_FOUND:
204 return "Class type not found";
205 case WSAEREFUSED:
206 return "Database query was refused";
207 case WSAHOST_NOT_FOUND:
208 return "Host not found";
209 case WSATRY_AGAIN:
210 return "Nonauthoritative host not found";
211 case WSANO_RECOVERY:
212 return "Nonrecoverable error";
213 case WSANO_DATA:
214 return "Valid name, no data record of requested type";
215 /* WSA_QOS_* omitted */
216# endif
217#endif
218
219#if GNULIB_defined_ENOMSG
220 case ENOMSG:
221 return "No message of desired type";
222#endif
223
224#if GNULIB_defined_EIDRM
225 case EIDRM:
226 return "Identifier removed";
227#endif
228
229#if GNULIB_defined_ENOLINK
230 case ENOLINK:
231 return "Link has been severed";
232#endif
233
234#if GNULIB_defined_EPROTO
235 case EPROTO:
236 return "Protocol error";
237#endif
238
239#if GNULIB_defined_EMULTIHOP
240 case EMULTIHOP:
241 return "Multihop attempted";
242#endif
243
244#if GNULIB_defined_EBADMSG
245 case EBADMSG:
246 return "Bad message";
247#endif
248
249#if GNULIB_defined_EOVERFLOW
250 case EOVERFLOW:
251 return "Value too large for defined data type";
252#endif
253
254#if GNULIB_defined_ENOTSUP
255 case ENOTSUP:
256 return "Not supported";
257#endif
258
259#if GNULIB_defined_ENETRESET
260 case ENETRESET:
261 return "Network dropped connection on reset";
262#endif
263
264#if GNULIB_defined_ECONNABORTED
265 case ECONNABORTED:
266 return "Software caused connection abort";
267#endif
268
269#if GNULIB_defined_ESTALE
270 case ESTALE:
271 return "Stale NFS file handle";
272#endif
273
274#if GNULIB_defined_EDQUOT
275 case EDQUOT:
276 return "Disk quota exceeded";
277#endif
278
279#if GNULIB_defined_ECANCELED
280 case ECANCELED:
281 return "Operation canceled";
282#endif
283
284#if GNULIB_defined_EOWNERDEAD
285 case EOWNERDEAD:
286 return "Owner died";
287#endif
288
289#if GNULIB_defined_ENOTRECOVERABLE
290 case ENOTRECOVERABLE:
291 return "State not recoverable";
292#endif
293
294#if GNULIB_defined_EILSEQ
295 case EILSEQ:
296 return "Invalid or incomplete multibyte or wide character";
297#endif
298
299 default:
300 return NULL;
301 }
302}
diff --git a/gl/strerror-override.h b/gl/strerror-override.h
new file mode 100644
index 0000000..3b8f24b
--- /dev/null
+++ b/gl/strerror-override.h
@@ -0,0 +1,56 @@
1/* strerror-override.h --- POSIX compatible system error routine
2
3 Copyright (C) 2010-2013 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#ifndef _GL_STRERROR_OVERRIDE_H
19# define _GL_STRERROR_OVERRIDE_H
20
21# include <errno.h>
22# include <stddef.h>
23
24/* Reasonable buffer size that should never trigger ERANGE; if this
25 proves too small, we intentionally abort(), to remind us to fix
26 this value. */
27# define STACKBUF_LEN 256
28
29/* If ERRNUM maps to an errno value defined by gnulib, return a string
30 describing the error. Otherwise return NULL. */
31# if REPLACE_STRERROR_0 \
32 || GNULIB_defined_ESOCK \
33 || GNULIB_defined_ESTREAMS \
34 || GNULIB_defined_EWINSOCK \
35 || GNULIB_defined_ENOMSG \
36 || GNULIB_defined_EIDRM \
37 || GNULIB_defined_ENOLINK \
38 || GNULIB_defined_EPROTO \
39 || GNULIB_defined_EMULTIHOP \
40 || GNULIB_defined_EBADMSG \
41 || GNULIB_defined_EOVERFLOW \
42 || GNULIB_defined_ENOTSUP \
43 || GNULIB_defined_ENETRESET \
44 || GNULIB_defined_ECONNABORTED \
45 || GNULIB_defined_ESTALE \
46 || GNULIB_defined_EDQUOT \
47 || GNULIB_defined_ECANCELED \
48 || GNULIB_defined_EOWNERDEAD \
49 || GNULIB_defined_ENOTRECOVERABLE \
50 || GNULIB_defined_EILSEQ
51extern const char *strerror_override (int errnum);
52# else
53# define strerror_override(ignored) NULL
54# endif
55
56#endif /* _GL_STRERROR_OVERRIDE_H */
diff --git a/gl/strerror.c b/gl/strerror.c
index 46153ab..80a2f2e 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-2010 Free Software Foundation, Inc. 3 Copyright (C) 2007-2013 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,334 +17,54 @@
17 17
18#include <config.h> 18#include <config.h>
19 19
20/* Specification. */
20#include <string.h> 21#include <string.h>
21 22
22#if REPLACE_STRERROR 23#include <errno.h>
23 24#include <stdio.h>
24# include <errno.h> 25#include <stdlib.h>
25# include <stdio.h> 26#include <string.h>
26
27# if GNULIB_defined_ESOCK /* native Windows platforms */
28# if HAVE_WINSOCK2_H
29# include <winsock2.h>
30# endif
31# endif
32 27
33# include "intprops.h" 28#include "intprops.h"
29#include "strerror-override.h"
30#include "verify.h"
34 31
35/* Use the system functions, not the gnulib overrides in this file. */ 32/* Use the system functions, not the gnulib overrides in this file. */
36# undef sprintf 33#undef sprintf
37
38# undef strerror
39# if ! HAVE_DECL_STRERROR
40# define strerror(n) NULL
41# endif
42 34
43char * 35char *
44rpl_strerror (int n) 36strerror (int n)
37#undef strerror
45{ 38{
46 char const *msg = NULL; 39 static char buf[STACKBUF_LEN];
47 /* These error messages are taken from glibc/sysdeps/gnu/errlist.c. */ 40 size_t len;
48 switch (n)
49 {
50# if GNULIB_defined_ETXTBSY
51 case ETXTBSY:
52 msg = "Text file busy";
53 break;
54# endif
55
56# if GNULIB_defined_ESOCK /* native Windows platforms */
57 /* EWOULDBLOCK is the same as EAGAIN. */
58 case EINPROGRESS:
59 msg = "Operation now in progress";
60 break;
61 case EALREADY:
62 msg = "Operation already in progress";
63 break;
64 case ENOTSOCK:
65 msg = "Socket operation on non-socket";
66 break;
67 case EDESTADDRREQ:
68 msg = "Destination address required";
69 break;
70 case EMSGSIZE:
71 msg = "Message too long";
72 break;
73 case EPROTOTYPE:
74 msg = "Protocol wrong type for socket";
75 break;
76 case ENOPROTOOPT:
77 msg = "Protocol not available";
78 break;
79 case EPROTONOSUPPORT:
80 msg = "Protocol not supported";
81 break;
82 case ESOCKTNOSUPPORT:
83 msg = "Socket type not supported";
84 break;
85 case EOPNOTSUPP:
86 msg = "Operation not supported";
87 break;
88 case EPFNOSUPPORT:
89 msg = "Protocol family not supported";
90 break;
91 case EAFNOSUPPORT:
92 msg = "Address family not supported by protocol";
93 break;
94 case EADDRINUSE:
95 msg = "Address already in use";
96 break;
97 case EADDRNOTAVAIL:
98 msg = "Cannot assign requested address";
99 break;
100 case ENETDOWN:
101 msg = "Network is down";
102 break;
103 case ENETUNREACH:
104 msg = "Network is unreachable";
105 break;
106 case ENETRESET:
107 msg = "Network dropped connection on reset";
108 break;
109 case ECONNABORTED:
110 msg = "Software caused connection abort";
111 break;
112 case ECONNRESET:
113 msg = "Connection reset by peer";
114 break;
115 case ENOBUFS:
116 msg = "No buffer space available";
117 break;
118 case EISCONN:
119 msg = "Transport endpoint is already connected";
120 break;
121 case ENOTCONN:
122 msg = "Transport endpoint is not connected";
123 break;
124 case ESHUTDOWN:
125 msg = "Cannot send after transport endpoint shutdown";
126 break;
127 case ETOOMANYREFS:
128 msg = "Too many references: cannot splice";
129 break;
130 case ETIMEDOUT:
131 msg = "Connection timed out";
132 break;
133 case ECONNREFUSED:
134 msg = "Connection refused";
135 break;
136 case ELOOP:
137 msg = "Too many levels of symbolic links";
138 break;
139 case EHOSTDOWN:
140 msg = "Host is down";
141 break;
142 case EHOSTUNREACH:
143 msg = "No route to host";
144 break;
145 case EPROCLIM:
146 msg = "Too many processes";
147 break;
148 case EUSERS:
149 msg = "Too many users";
150 break;
151 case EDQUOT:
152 msg = "Disk quota exceeded";
153 break;
154 case ESTALE:
155 msg = "Stale NFS file handle";
156 break;
157 case EREMOTE:
158 msg = "Object is remote";
159 break;
160# if HAVE_WINSOCK2_H
161 /* WSA_INVALID_HANDLE maps to EBADF */
162 /* WSA_NOT_ENOUGH_MEMORY maps to ENOMEM */
163 /* WSA_INVALID_PARAMETER maps to EINVAL */
164 case WSA_OPERATION_ABORTED:
165 msg = "Overlapped operation aborted";
166 break;
167 case WSA_IO_INCOMPLETE:
168 msg = "Overlapped I/O event object not in signaled state";
169 break;
170 case WSA_IO_PENDING:
171 msg = "Overlapped operations will complete later";
172 break;
173 /* WSAEINTR maps to EINTR */
174 /* WSAEBADF maps to EBADF */
175 /* WSAEACCES maps to EACCES */
176 /* WSAEFAULT maps to EFAULT */
177 /* WSAEINVAL maps to EINVAL */
178 /* WSAEMFILE maps to EMFILE */
179 /* WSAEWOULDBLOCK maps to EWOULDBLOCK */
180 /* WSAEINPROGRESS is EINPROGRESS */
181 /* WSAEALREADY is EALREADY */
182 /* WSAENOTSOCK is ENOTSOCK */
183 /* WSAEDESTADDRREQ is EDESTADDRREQ */
184 /* WSAEMSGSIZE is EMSGSIZE */
185 /* WSAEPROTOTYPE is EPROTOTYPE */
186 /* WSAENOPROTOOPT is ENOPROTOOPT */
187 /* WSAEPROTONOSUPPORT is EPROTONOSUPPORT */
188 /* WSAESOCKTNOSUPPORT is ESOCKTNOSUPPORT */
189 /* WSAEOPNOTSUPP is EOPNOTSUPP */
190 /* WSAEPFNOSUPPORT is EPFNOSUPPORT */
191 /* WSAEAFNOSUPPORT is EAFNOSUPPORT */
192 /* WSAEADDRINUSE is EADDRINUSE */
193 /* WSAEADDRNOTAVAIL is EADDRNOTAVAIL */
194 /* WSAENETDOWN is ENETDOWN */
195 /* WSAENETUNREACH is ENETUNREACH */
196 /* WSAENETRESET is ENETRESET */
197 /* WSAECONNABORTED is ECONNABORTED */
198 /* WSAECONNRESET is ECONNRESET */
199 /* WSAENOBUFS is ENOBUFS */
200 /* WSAEISCONN is EISCONN */
201 /* WSAENOTCONN is ENOTCONN */
202 /* WSAESHUTDOWN is ESHUTDOWN */
203 /* WSAETOOMANYREFS is ETOOMANYREFS */
204 /* WSAETIMEDOUT is ETIMEDOUT */
205 /* WSAECONNREFUSED is ECONNREFUSED */
206 /* WSAELOOP is ELOOP */
207 /* WSAENAMETOOLONG maps to ENAMETOOLONG */
208 /* WSAEHOSTDOWN is EHOSTDOWN */
209 /* WSAEHOSTUNREACH is EHOSTUNREACH */
210 /* WSAENOTEMPTY maps to ENOTEMPTY */
211 /* WSAEPROCLIM is EPROCLIM */
212 /* WSAEUSERS is EUSERS */
213 /* WSAEDQUOT is EDQUOT */
214 /* WSAESTALE is ESTALE */
215 /* WSAEREMOTE is EREMOTE */
216 case WSASYSNOTREADY:
217 msg = "Network subsystem is unavailable";
218 break;
219 case WSAVERNOTSUPPORTED:
220 msg = "Winsock.dll version out of range";
221 break;
222 case WSANOTINITIALISED:
223 msg = "Successful WSAStartup not yet performed";
224 break;
225 case WSAEDISCON:
226 msg = "Graceful shutdown in progress";
227 break;
228 case WSAENOMORE: case WSA_E_NO_MORE:
229 msg = "No more results";
230 break;
231 case WSAECANCELLED: case WSA_E_CANCELLED:
232 msg = "Call was canceled";
233 break;
234 case WSAEINVALIDPROCTABLE:
235 msg = "Procedure call table is invalid";
236 break;
237 case WSAEINVALIDPROVIDER:
238 msg = "Service provider is invalid";
239 break;
240 case WSAEPROVIDERFAILEDINIT:
241 msg = "Service provider failed to initialize";
242 break;
243 case WSASYSCALLFAILURE:
244 msg = "System call failure";
245 break;
246 case WSASERVICE_NOT_FOUND:
247 msg = "Service not found";
248 break;
249 case WSATYPE_NOT_FOUND:
250 msg = "Class type not found";
251 break;
252 case WSAEREFUSED:
253 msg = "Database query was refused";
254 break;
255 case WSAHOST_NOT_FOUND:
256 msg = "Host not found";
257 break;
258 case WSATRY_AGAIN:
259 msg = "Nonauthoritative host not found";
260 break;
261 case WSANO_RECOVERY:
262 msg = "Nonrecoverable error";
263 break;
264 case WSANO_DATA:
265 msg = "Valid name, no data record of requested type";
266 break;
267 /* WSA_QOS_* omitted */
268# endif
269# endif
270
271# if GNULIB_defined_ENOMSG
272 case ENOMSG:
273 msg = "No message of desired type";
274 break;
275# endif
276
277# if GNULIB_defined_EIDRM
278 case EIDRM:
279 msg = "Identifier removed";
280 break;
281# endif
282
283# if GNULIB_defined_ENOLINK
284 case ENOLINK:
285 msg = "Link has been severed";
286 break;
287# endif
288
289# if GNULIB_defined_EPROTO
290 case EPROTO:
291 msg = "Protocol error";
292 break;
293# endif
294
295# if GNULIB_defined_EMULTIHOP
296 case EMULTIHOP:
297 msg = "Multihop attempted";
298 break;
299# endif
300
301# if GNULIB_defined_EBADMSG
302 case EBADMSG:
303 msg = "Bad message";
304 break;
305# endif
306
307# if GNULIB_defined_EOVERFLOW
308 case EOVERFLOW:
309 msg = "Value too large for defined data type";
310 break;
311# endif
312
313# if GNULIB_defined_ENOTSUP
314 case ENOTSUP:
315 msg = "Not supported";
316 break;
317# endif
318
319# if GNULIB_defined_ESTALE
320 case ESTALE:
321 msg = "Stale NFS file handle";
322 break;
323# endif
324
325# if GNULIB_defined_ECANCELED
326 case ECANCELED:
327 msg = "Operation canceled";
328 break;
329# endif
330 }
331 41
42 /* Cast away const, due to the historical signature of strerror;
43 callers should not be modifying the string. */
44 const char *msg = strerror_override (n);
332 if (msg) 45 if (msg)
333 return (char *) msg; 46 return (char *) msg;
334 47
335 { 48 msg = strerror (n);
336 char *result = strerror (n);
337 49
338 if (result == NULL || result[0] == '\0') 50 /* Our strerror_r implementation might use the system's strerror
339 { 51 buffer, so all other clients of strerror have to see the error
340 static char const fmt[] = "Unknown error (%d)"; 52 copied into a buffer that we manage. This is not thread-safe,
341 static char msg_buf[sizeof fmt + INT_STRLEN_BOUND (n)]; 53 even if the system strerror is, but portable programs shouldn't
342 sprintf (msg_buf, fmt, n); 54 be using strerror if they care about thread-safety. */
343 return msg_buf; 55 if (!msg || !*msg)
344 } 56 {
57 static char const fmt[] = "Unknown error %d";
58 verify (sizeof buf >= sizeof (fmt) + INT_STRLEN_BOUND (n));
59 sprintf (buf, fmt, n);
60 errno = EINVAL;
61 return buf;
62 }
345 63
346 return result; 64 /* Fix STACKBUF_LEN if this ever aborts. */
347 } 65 len = strlen (msg);
348} 66 if (sizeof buf <= len)
67 abort ();
349 68
350#endif 69 return memcpy (buf, msg, len + 1);
70}
diff --git a/gl/string.in.h b/gl/string.in.h
index f64fce3..d7a6c9c 100644
--- a/gl/string.in.h
+++ b/gl/string.in.h
@@ -1,6 +1,6 @@
1/* A GNU-like <string.h>. 1/* A GNU-like <string.h>.
2 2
3 Copyright (C) 1995-1996, 2001-2010 Free Software Foundation, Inc. 3 Copyright (C) 1995-1996, 2001-2013 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
@@ -13,20 +13,20 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
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, write to the Free Software Foundation, 16 along with this program; if not, see <http://www.gnu.org/licenses/>. */
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 17
19#ifndef _GL_STRING_H 18#ifndef _@GUARD_PREFIX@_STRING_H
20 19
21#if __GNUC__ >= 3 20#if __GNUC__ >= 3
22@PRAGMA_SYSTEM_HEADER@ 21@PRAGMA_SYSTEM_HEADER@
23#endif 22#endif
23@PRAGMA_COLUMNS@
24 24
25/* The include_next requires a split double-inclusion guard. */ 25/* The include_next requires a split double-inclusion guard. */
26#@INCLUDE_NEXT@ @NEXT_STRING_H@ 26#@INCLUDE_NEXT@ @NEXT_STRING_H@
27 27
28#ifndef _GL_STRING_H 28#ifndef _@GUARD_PREFIX@_STRING_H
29#define _GL_STRING_H 29#define _@GUARD_PREFIX@_STRING_H
30 30
31/* NetBSD 5.0 mis-defines NULL. */ 31/* NetBSD 5.0 mis-defines NULL. */
32#include <stddef.h> 32#include <stddef.h>
@@ -36,19 +36,20 @@
36# include <wchar.h> 36# include <wchar.h>
37#endif 37#endif
38 38
39#ifndef __attribute__ 39/* The __attribute__ feature is available in gcc versions 2.5 and later.
40/* This feature is available in gcc versions 2.5 and later. */ 40 The attribute __pure__ was added in gcc 2.96. */
41# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
42# define __attribute__(Spec) /* empty */
43# endif
44#endif
45/* The attribute __pure__ was added in gcc 2.96. */
46#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) 41#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
47# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) 42# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
48#else 43#else
49# define _GL_ATTRIBUTE_PURE /* empty */ 44# define _GL_ATTRIBUTE_PURE /* empty */
50#endif 45#endif
51 46
47/* NetBSD 5.0 declares strsignal in <unistd.h>, not in <string.h>. */
48/* But in any case avoid namespace pollution on glibc systems. */
49#if (@GNULIB_STRSIGNAL@ || defined GNULIB_POSIXCHECK) && defined __NetBSD__ \
50 && ! defined __GLIBC__
51# include <unistd.h>
52#endif
52 53
53/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 54/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
54 55
@@ -57,6 +58,36 @@
57/* The definition of _GL_WARN_ON_USE is copied here. */ 58/* The definition of _GL_WARN_ON_USE is copied here. */
58 59
59 60
61/* Find the index of the least-significant set bit. */
62#if @GNULIB_FFSL@
63# if !@HAVE_FFSL@
64_GL_FUNCDECL_SYS (ffsl, int, (long int i));
65# endif
66_GL_CXXALIAS_SYS (ffsl, int, (long int i));
67_GL_CXXALIASWARN (ffsl);
68#elif defined GNULIB_POSIXCHECK
69# undef ffsl
70# if HAVE_RAW_DECL_FFSL
71_GL_WARN_ON_USE (ffsl, "ffsl is not portable - use the ffsl module");
72# endif
73#endif
74
75
76/* Find the index of the least-significant set bit. */
77#if @GNULIB_FFSLL@
78# if !@HAVE_FFSLL@
79_GL_FUNCDECL_SYS (ffsll, int, (long long int i));
80# endif
81_GL_CXXALIAS_SYS (ffsll, int, (long long int i));
82_GL_CXXALIASWARN (ffsll);
83#elif defined GNULIB_POSIXCHECK
84# undef ffsll
85# if HAVE_RAW_DECL_FFSLL
86_GL_WARN_ON_USE (ffsll, "ffsll is not portable - use the ffsll module");
87# endif
88#endif
89
90
60/* Return the first instance of C within N bytes of S, or NULL. */ 91/* Return the first instance of C within N bytes of S, or NULL. */
61#if @GNULIB_MEMCHR@ 92#if @GNULIB_MEMCHR@
62# if @REPLACE_MEMCHR@ 93# if @REPLACE_MEMCHR@
@@ -80,7 +111,7 @@ _GL_CXXALIAS_SYS_CAST2 (memchr,
80 void *, (void const *__s, int __c, size_t __n), 111 void *, (void const *__s, int __c, size_t __n),
81 void const *, (void const *__s, int __c, size_t __n)); 112 void const *, (void const *__s, int __c, size_t __n));
82# endif 113# endif
83# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ 114# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
84 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 115 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
85_GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n)); 116_GL_CXXALIASWARN1 (memchr, void *, (void *__s, int __c, size_t __n));
86_GL_CXXALIASWARN1 (memchr, void const *, 117_GL_CXXALIASWARN1 (memchr, void const *,
@@ -165,7 +196,7 @@ _GL_FUNCDECL_SYS (memrchr, void *, (void const *, int, size_t)
165_GL_CXXALIAS_SYS_CAST2 (memrchr, 196_GL_CXXALIAS_SYS_CAST2 (memrchr,
166 void *, (void const *, int, size_t), 197 void *, (void const *, int, size_t),
167 void const *, (void const *, int, size_t)); 198 void const *, (void const *, int, size_t));
168# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ 199# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
169 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 200 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
170_GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t)); 201_GL_CXXALIASWARN1 (memrchr, void *, (void *, int, size_t));
171_GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t)); 202_GL_CXXALIASWARN1 (memrchr, void const *, (void const *, int, size_t));
@@ -195,7 +226,7 @@ _GL_FUNCDECL_SYS (rawmemchr, void *, (void const *__s, int __c_in)
195_GL_CXXALIAS_SYS_CAST2 (rawmemchr, 226_GL_CXXALIAS_SYS_CAST2 (rawmemchr,
196 void *, (void const *__s, int __c_in), 227 void *, (void const *__s, int __c_in),
197 void const *, (void const *__s, int __c_in)); 228 void const *, (void const *__s, int __c_in));
198# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ 229# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
199 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 230 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
200_GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in)); 231_GL_CXXALIASWARN1 (rawmemchr, void *, (void *__s, int __c_in));
201_GL_CXXALIASWARN1 (rawmemchr, void const *, (void const *__s, int __c_in)); 232_GL_CXXALIASWARN1 (rawmemchr, void const *, (void const *__s, int __c_in));
@@ -233,6 +264,7 @@ _GL_WARN_ON_USE (stpcpy, "stpcpy is unportable - "
233#if @GNULIB_STPNCPY@ 264#if @GNULIB_STPNCPY@
234# if @REPLACE_STPNCPY@ 265# if @REPLACE_STPNCPY@
235# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 266# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
267# undef stpncpy
236# define stpncpy rpl_stpncpy 268# define stpncpy rpl_stpncpy
237# endif 269# endif
238_GL_FUNCDECL_RPL (stpncpy, char *, 270_GL_FUNCDECL_RPL (stpncpy, char *,
@@ -274,18 +306,29 @@ _GL_WARN_ON_USE (strchr, "strchr cannot work correctly on character strings "
274 306
275/* Find the first occurrence of C in S or the final NUL byte. */ 307/* Find the first occurrence of C in S or the final NUL byte. */
276#if @GNULIB_STRCHRNUL@ 308#if @GNULIB_STRCHRNUL@
277# if ! @HAVE_STRCHRNUL@ 309# if @REPLACE_STRCHRNUL@
310# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
311# define strchrnul rpl_strchrnul
312# endif
313_GL_FUNCDECL_RPL (strchrnul, char *, (const char *__s, int __c_in)
314 _GL_ATTRIBUTE_PURE
315 _GL_ARG_NONNULL ((1)));
316_GL_CXXALIAS_RPL (strchrnul, char *,
317 (const char *str, int ch));
318# else
319# if ! @HAVE_STRCHRNUL@
278_GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in) 320_GL_FUNCDECL_SYS (strchrnul, char *, (char const *__s, int __c_in)
279 _GL_ATTRIBUTE_PURE 321 _GL_ATTRIBUTE_PURE
280 _GL_ARG_NONNULL ((1))); 322 _GL_ARG_NONNULL ((1)));
281# endif 323# endif
282 /* On some systems, this function is defined as an overloaded function: 324 /* On some systems, this function is defined as an overloaded function:
283 extern "C++" { const char * std::strchrnul (const char *, int); } 325 extern "C++" { const char * std::strchrnul (const char *, int); }
284 extern "C++" { char * std::strchrnul (char *, int); } */ 326 extern "C++" { char * std::strchrnul (char *, int); } */
285_GL_CXXALIAS_SYS_CAST2 (strchrnul, 327_GL_CXXALIAS_SYS_CAST2 (strchrnul,
286 char *, (char const *__s, int __c_in), 328 char *, (char const *__s, int __c_in),
287 char const *, (char const *__s, int __c_in)); 329 char const *, (char const *__s, int __c_in));
288# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ 330# endif
331# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
289 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 332 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
290_GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in)); 333_GL_CXXALIASWARN1 (strchrnul, char *, (char *__s, int __c_in));
291_GL_CXXALIASWARN1 (strchrnul, char const *, (char const *__s, int __c_in)); 334_GL_CXXALIASWARN1 (strchrnul, char const *, (char const *__s, int __c_in));
@@ -310,6 +353,10 @@ _GL_WARN_ON_USE (strchrnul, "strchrnul is unportable - "
310_GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1))); 353_GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
311_GL_CXXALIAS_RPL (strdup, char *, (char const *__s)); 354_GL_CXXALIAS_RPL (strdup, char *, (char const *__s));
312# else 355# else
356# if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup
357 /* strdup exists as a function and as a macro. Get rid of the macro. */
358# undef strdup
359# endif
313# if !(@HAVE_DECL_STRDUP@ || defined strdup) 360# if !(@HAVE_DECL_STRDUP@ || defined strdup)
314_GL_FUNCDECL_SYS (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1))); 361_GL_FUNCDECL_SYS (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
315# endif 362# endif
@@ -427,7 +474,7 @@ _GL_FUNCDECL_SYS (strpbrk, char *, (char const *__s, char const *__accept)
427_GL_CXXALIAS_SYS_CAST2 (strpbrk, 474_GL_CXXALIAS_SYS_CAST2 (strpbrk,
428 char *, (char const *__s, char const *__accept), 475 char *, (char const *__s, char const *__accept),
429 const char *, (char const *__s, char const *__accept)); 476 const char *, (char const *__s, char const *__accept));
430# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ 477# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
431 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 478 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
432_GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept)); 479_GL_CXXALIASWARN1 (strpbrk, char *, (char *__s, char const *__accept));
433_GL_CXXALIASWARN1 (strpbrk, char const *, 480_GL_CXXALIASWARN1 (strpbrk, char const *,
@@ -529,7 +576,7 @@ _GL_CXXALIAS_SYS_CAST2 (strstr,
529 char *, (const char *haystack, const char *needle), 576 char *, (const char *haystack, const char *needle),
530 const char *, (const char *haystack, const char *needle)); 577 const char *, (const char *haystack, const char *needle));
531# endif 578# endif
532# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ 579# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
533 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 580 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
534_GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle)); 581_GL_CXXALIASWARN1 (strstr, char *, (char *haystack, const char *needle));
535_GL_CXXALIASWARN1 (strstr, const char *, 582_GL_CXXALIASWARN1 (strstr, const char *,
@@ -578,7 +625,7 @@ _GL_CXXALIAS_SYS_CAST2 (strcasestr,
578 char *, (const char *haystack, const char *needle), 625 char *, (const char *haystack, const char *needle),
579 const char *, (const char *haystack, const char *needle)); 626 const char *, (const char *haystack, const char *needle));
580# endif 627# endif
581# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 10 \ 628# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
582 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) 629 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
583_GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle)); 630_GL_CXXALIASWARN1 (strcasestr, char *, (char *haystack, const char *needle));
584_GL_CXXALIASWARN1 (strcasestr, const char *, 631_GL_CXXALIASWARN1 (strcasestr, const char *,
@@ -677,10 +724,14 @@ _GL_WARN_ON_USE (strtok_r, "strtok_r is unportable - "
677# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 724# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
678# define mbslen rpl_mbslen 725# define mbslen rpl_mbslen
679# endif 726# endif
680_GL_FUNCDECL_RPL (mbslen, size_t, (const char *string) _GL_ARG_NONNULL ((1))); 727_GL_FUNCDECL_RPL (mbslen, size_t, (const char *string)
728 _GL_ATTRIBUTE_PURE
729 _GL_ARG_NONNULL ((1)));
681_GL_CXXALIAS_RPL (mbslen, size_t, (const char *string)); 730_GL_CXXALIAS_RPL (mbslen, size_t, (const char *string));
682# else 731# else
683_GL_FUNCDECL_SYS (mbslen, size_t, (const char *string) _GL_ARG_NONNULL ((1))); 732_GL_FUNCDECL_SYS (mbslen, size_t, (const char *string)
733 _GL_ATTRIBUTE_PURE
734 _GL_ARG_NONNULL ((1)));
684_GL_CXXALIAS_SYS (mbslen, size_t, (const char *string)); 735_GL_CXXALIAS_SYS (mbslen, size_t, (const char *string));
685# endif 736# endif
686_GL_CXXALIASWARN (mbslen); 737_GL_CXXALIASWARN (mbslen);
@@ -690,6 +741,7 @@ _GL_CXXALIASWARN (mbslen);
690/* Return the number of multibyte characters in the character string starting 741/* Return the number of multibyte characters in the character string starting
691 at STRING and ending at STRING + LEN. */ 742 at STRING and ending at STRING + LEN. */
692_GL_EXTERN_C size_t mbsnlen (const char *string, size_t len) 743_GL_EXTERN_C size_t mbsnlen (const char *string, size_t len)
744 _GL_ATTRIBUTE_PURE
693 _GL_ARG_NONNULL ((1)); 745 _GL_ARG_NONNULL ((1));
694#endif 746#endif
695 747
@@ -703,10 +755,12 @@ _GL_EXTERN_C size_t mbsnlen (const char *string, size_t len)
703# define mbschr rpl_mbschr /* avoid collision with HP-UX function */ 755# define mbschr rpl_mbschr /* avoid collision with HP-UX function */
704# endif 756# endif
705_GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c) 757_GL_FUNCDECL_RPL (mbschr, char *, (const char *string, int c)
758 _GL_ATTRIBUTE_PURE
706 _GL_ARG_NONNULL ((1))); 759 _GL_ARG_NONNULL ((1)));
707_GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c)); 760_GL_CXXALIAS_RPL (mbschr, char *, (const char *string, int c));
708# else 761# else
709_GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c) 762_GL_FUNCDECL_SYS (mbschr, char *, (const char *string, int c)
763 _GL_ATTRIBUTE_PURE
710 _GL_ARG_NONNULL ((1))); 764 _GL_ARG_NONNULL ((1)));
711_GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c)); 765_GL_CXXALIAS_SYS (mbschr, char *, (const char *string, int c));
712# endif 766# endif
@@ -718,15 +772,17 @@ _GL_CXXALIASWARN (mbschr);
718 and return a pointer to it. Return NULL if C is not found in STRING. 772 and return a pointer to it. Return NULL if C is not found in STRING.
719 Unlike strrchr(), this function works correctly in multibyte locales with 773 Unlike strrchr(), this function works correctly in multibyte locales with
720 encodings such as GB18030. */ 774 encodings such as GB18030. */
721# if defined __hpux 775# if defined __hpux || defined __INTERIX
722# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 776# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
723# define mbsrchr rpl_mbsrchr /* avoid collision with HP-UX function */ 777# define mbsrchr rpl_mbsrchr /* avoid collision with system function */
724# endif 778# endif
725_GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c) 779_GL_FUNCDECL_RPL (mbsrchr, char *, (const char *string, int c)
780 _GL_ATTRIBUTE_PURE
726 _GL_ARG_NONNULL ((1))); 781 _GL_ARG_NONNULL ((1)));
727_GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c)); 782_GL_CXXALIAS_RPL (mbsrchr, char *, (const char *string, int c));
728# else 783# else
729_GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c) 784_GL_FUNCDECL_SYS (mbsrchr, char *, (const char *string, int c)
785 _GL_ATTRIBUTE_PURE
730 _GL_ARG_NONNULL ((1))); 786 _GL_ARG_NONNULL ((1)));
731_GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c)); 787_GL_CXXALIAS_SYS (mbsrchr, char *, (const char *string, int c));
732# endif 788# endif
@@ -739,6 +795,7 @@ _GL_CXXALIASWARN (mbsrchr);
739 Unlike strstr(), this function works correctly in multibyte locales with 795 Unlike strstr(), this function works correctly in multibyte locales with
740 encodings different from UTF-8. */ 796 encodings different from UTF-8. */
741_GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle) 797_GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle)
798 _GL_ATTRIBUTE_PURE
742 _GL_ARG_NONNULL ((1, 2)); 799 _GL_ARG_NONNULL ((1, 2));
743#endif 800#endif
744 801
@@ -750,6 +807,7 @@ _GL_EXTERN_C char * mbsstr (const char *haystack, const char *needle)
750 different lengths! 807 different lengths!
751 Unlike strcasecmp(), this function works correctly in multibyte locales. */ 808 Unlike strcasecmp(), this function works correctly in multibyte locales. */
752_GL_EXTERN_C int mbscasecmp (const char *s1, const char *s2) 809_GL_EXTERN_C int mbscasecmp (const char *s1, const char *s2)
810 _GL_ATTRIBUTE_PURE
753 _GL_ARG_NONNULL ((1, 2)); 811 _GL_ARG_NONNULL ((1, 2));
754#endif 812#endif
755 813
@@ -764,20 +822,21 @@ _GL_EXTERN_C int mbscasecmp (const char *s1, const char *s2)
764 Unlike strncasecmp(), this function works correctly in multibyte locales. 822 Unlike strncasecmp(), this function works correctly in multibyte locales.
765 But beware that N is not a byte count but a character count! */ 823 But beware that N is not a byte count but a character count! */
766_GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n) 824_GL_EXTERN_C int mbsncasecmp (const char *s1, const char *s2, size_t n)
825 _GL_ATTRIBUTE_PURE
767 _GL_ARG_NONNULL ((1, 2)); 826 _GL_ARG_NONNULL ((1, 2));
768#endif 827#endif
769 828
770#if @GNULIB_MBSPCASECMP@ 829#if @GNULIB_MBSPCASECMP@
771/* Compare the initial segment of the character string STRING consisting of 830/* Compare the initial segment of the character string STRING consisting of
772 at most mbslen (PREFIX) characters with the character string PREFIX, 831 at most mbslen (PREFIX) characters with the character string PREFIX,
773 ignoring case, returning less than, equal to or greater than zero if this 832 ignoring case. If the two match, return a pointer to the first byte
774 initial segment is lexicographically less than, equal to or greater than 833 after this prefix in STRING. Otherwise, return NULL.
775 PREFIX. 834 Note: This function may, in multibyte locales, return non-NULL if STRING
776 Note: This function may, in multibyte locales, return 0 if STRING is of 835 is of smaller length than PREFIX!
777 smaller length than PREFIX!
778 Unlike strncasecmp(), this function works correctly in multibyte 836 Unlike strncasecmp(), this function works correctly in multibyte
779 locales. */ 837 locales. */
780_GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix) 838_GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix)
839 _GL_ATTRIBUTE_PURE
781 _GL_ARG_NONNULL ((1, 2)); 840 _GL_ARG_NONNULL ((1, 2));
782#endif 841#endif
783 842
@@ -788,6 +847,7 @@ _GL_EXTERN_C char * mbspcasecmp (const char *string, const char *prefix)
788 strlen (haystack) < strlen (needle) ! 847 strlen (haystack) < strlen (needle) !
789 Unlike strcasestr(), this function works correctly in multibyte locales. */ 848 Unlike strcasestr(), this function works correctly in multibyte locales. */
790_GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle) 849_GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle)
850 _GL_ATTRIBUTE_PURE
791 _GL_ARG_NONNULL ((1, 2)); 851 _GL_ARG_NONNULL ((1, 2));
792#endif 852#endif
793 853
@@ -798,6 +858,7 @@ _GL_EXTERN_C char * mbscasestr (const char *haystack, const char *needle)
798 if none exists. 858 if none exists.
799 Unlike strcspn(), this function works correctly in multibyte locales. */ 859 Unlike strcspn(), this function works correctly in multibyte locales. */
800_GL_EXTERN_C size_t mbscspn (const char *string, const char *accept) 860_GL_EXTERN_C size_t mbscspn (const char *string, const char *accept)
861 _GL_ATTRIBUTE_PURE
801 _GL_ARG_NONNULL ((1, 2)); 862 _GL_ARG_NONNULL ((1, 2));
802#endif 863#endif
803 864
@@ -811,10 +872,12 @@ _GL_EXTERN_C size_t mbscspn (const char *string, const char *accept)
811# define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */ 872# define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */
812# endif 873# endif
813_GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept) 874_GL_FUNCDECL_RPL (mbspbrk, char *, (const char *string, const char *accept)
875 _GL_ATTRIBUTE_PURE
814 _GL_ARG_NONNULL ((1, 2))); 876 _GL_ARG_NONNULL ((1, 2)));
815_GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept)); 877_GL_CXXALIAS_RPL (mbspbrk, char *, (const char *string, const char *accept));
816# else 878# else
817_GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept) 879_GL_FUNCDECL_SYS (mbspbrk, char *, (const char *string, const char *accept)
880 _GL_ATTRIBUTE_PURE
818 _GL_ARG_NONNULL ((1, 2))); 881 _GL_ARG_NONNULL ((1, 2)));
819_GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept)); 882_GL_CXXALIAS_SYS (mbspbrk, char *, (const char *string, const char *accept));
820# endif 883# endif
@@ -828,6 +891,7 @@ _GL_CXXALIASWARN (mbspbrk);
828 if none exists. 891 if none exists.
829 Unlike strspn(), this function works correctly in multibyte locales. */ 892 Unlike strspn(), this function works correctly in multibyte locales. */
830_GL_EXTERN_C size_t mbsspn (const char *string, const char *reject) 893_GL_EXTERN_C size_t mbsspn (const char *string, const char *reject)
894 _GL_ATTRIBUTE_PURE
831 _GL_ARG_NONNULL ((1, 2)); 895 _GL_ARG_NONNULL ((1, 2));
832#endif 896#endif
833 897
@@ -891,6 +955,35 @@ _GL_WARN_ON_USE (strerror, "strerror is unportable - "
891 "use gnulib module strerror to guarantee non-NULL result"); 955 "use gnulib module strerror to guarantee non-NULL result");
892#endif 956#endif
893 957
958/* Map any int, typically from errno, into an error message. Multithread-safe.
959 Uses the POSIX declaration, not the glibc declaration. */
960#if @GNULIB_STRERROR_R@
961# if @REPLACE_STRERROR_R@
962# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
963# undef strerror_r
964# define strerror_r rpl_strerror_r
965# endif
966_GL_FUNCDECL_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen)
967 _GL_ARG_NONNULL ((2)));
968_GL_CXXALIAS_RPL (strerror_r, int, (int errnum, char *buf, size_t buflen));
969# else
970# if !@HAVE_DECL_STRERROR_R@
971_GL_FUNCDECL_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen)
972 _GL_ARG_NONNULL ((2)));
973# endif
974_GL_CXXALIAS_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen));
975# endif
976# if @HAVE_DECL_STRERROR_R@
977_GL_CXXALIASWARN (strerror_r);
978# endif
979#elif defined GNULIB_POSIXCHECK
980# undef strerror_r
981# if HAVE_RAW_DECL_STRERROR_R
982_GL_WARN_ON_USE (strerror_r, "strerror_r is unportable - "
983 "use gnulib module strerror_r-posix for portability");
984# endif
985#endif
986
894#if @GNULIB_STRSIGNAL@ 987#if @GNULIB_STRSIGNAL@
895# if @REPLACE_STRSIGNAL@ 988# if @REPLACE_STRSIGNAL@
896# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 989# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -918,6 +1011,7 @@ _GL_WARN_ON_USE (strsignal, "strsignal is unportable - "
918#if @GNULIB_STRVERSCMP@ 1011#if @GNULIB_STRVERSCMP@
919# if !@HAVE_STRVERSCMP@ 1012# if !@HAVE_STRVERSCMP@
920_GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *) 1013_GL_FUNCDECL_SYS (strverscmp, int, (const char *, const char *)
1014 _GL_ATTRIBUTE_PURE
921 _GL_ARG_NONNULL ((1, 2))); 1015 _GL_ARG_NONNULL ((1, 2)));
922# endif 1016# endif
923_GL_CXXALIAS_SYS (strverscmp, int, (const char *, const char *)); 1017_GL_CXXALIAS_SYS (strverscmp, int, (const char *, const char *));
@@ -931,5 +1025,5 @@ _GL_WARN_ON_USE (strverscmp, "strverscmp is unportable - "
931#endif 1025#endif
932 1026
933 1027
934#endif /* _GL_STRING_H */ 1028#endif /* _@GUARD_PREFIX@_STRING_H */
935#endif /* _GL_STRING_H */ 1029#endif /* _@GUARD_PREFIX@_STRING_H */
diff --git a/gl/stripslash.c b/gl/stripslash.c
index 3a5996f..0e452a9 100644
--- a/gl/stripslash.c
+++ b/gl/stripslash.c
@@ -1,6 +1,6 @@
1/* stripslash.c -- remove redundant trailing slashes from a file name 1/* stripslash.c -- remove redundant trailing slashes from a file name
2 2
3 Copyright (C) 1990, 2001, 2003-2006, 2009-2010 Free Software Foundation, 3 Copyright (C) 1990, 2001, 2003-2006, 2009-2013 Free Software Foundation,
4 Inc. 4 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
@@ -35,7 +35,7 @@ strip_trailing_slashes (char *file)
35 bool had_slash; 35 bool had_slash;
36 36
37 /* last_component returns "" for file system roots, but we need to turn 37 /* last_component returns "" for file system roots, but we need to turn
38 `///' into `/'. */ 38 "///" into "/". */
39 if (! *base) 39 if (! *base)
40 base = file; 40 base = file;
41 base_lim = base + base_len (base); 41 base_lim = base + base_len (base);
diff --git a/gl/strndup.c b/gl/strndup.c
index 3de3dbc..e60268b 100644
--- a/gl/strndup.c
+++ b/gl/strndup.c
@@ -1,7 +1,7 @@
1/* A replacement function, for systems that lack strndup. 1/* A replacement function, for systems that lack strndup.
2 2
3 Copyright (C) 1996, 1997, 1998, 2001, 2002, 2003, 2005, 2006, 2007, 2009, 3 Copyright (C) 1996-1998, 2001-2003, 2005-2007, 2009-2013 Free Software
4 2010 Free Software 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
7 under the terms of the GNU General Public License as published by the 7 under the terms of the GNU General Public License as published by the
@@ -14,8 +14,7 @@
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 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, 17 along with this program; if not, see <http://www.gnu.org/licenses/>. */
18 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
19 18
20#include <config.h> 19#include <config.h>
21 20
diff --git a/gl/strnlen.c b/gl/strnlen.c
index f1ec356..57fdfe7 100644
--- a/gl/strnlen.c
+++ b/gl/strnlen.c
@@ -1,5 +1,5 @@
1/* Find the length of STRING, but scan at most MAXLEN characters. 1/* Find the length of STRING, but scan at most MAXLEN characters.
2 Copyright (C) 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. 2 Copyright (C) 2005-2007, 2009-2013 Free Software Foundation, Inc.
3 Written by Simon Josefsson. 3 Written by Simon Josefsson.
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
@@ -13,8 +13,7 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
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, write to the Free Software Foundation, 16 along with this program; if not, see <http://www.gnu.org/licenses/>. */
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 17
19#include <config.h> 18#include <config.h>
20 19
diff --git a/gl/strsep.c b/gl/strsep.c
index a2a3ffa..c51ac0d 100644
--- a/gl/strsep.c
+++ b/gl/strsep.c
@@ -1,4 +1,4 @@
1/* Copyright (C) 2004, 2007, 2009, 2010 Free Software Foundation, Inc. 1/* Copyright (C) 2004, 2007, 2009-2013 Free Software Foundation, Inc.
2 2
3 Written by Yoann Vandoorselaere <yoann@prelude-ids.org>. 3 Written by Yoann Vandoorselaere <yoann@prelude-ids.org>.
4 4
@@ -13,8 +13,7 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
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, write to the Free Software Foundation, 16 along with this program; if not, see <http://www.gnu.org/licenses/>. */
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 17
19#ifdef HAVE_CONFIG_H 18#ifdef HAVE_CONFIG_H
20# include <config.h> 19# include <config.h>
diff --git a/gl/strstr.c b/gl/strstr.c
index ae184ff..b91acec 100644
--- a/gl/strstr.c
+++ b/gl/strstr.c
@@ -1,5 +1,5 @@
1/* Copyright (C) 1991, 1992, 1993, 1994, 1996, 1997, 1998, 2000, 2004, 2007, 1/* Copyright (C) 1991-1994, 1996-1998, 2000, 2004, 2007-2013 Free Software
2 2008, 2009, 2010 Free Software Foundation, Inc. 2 Foundation, Inc.
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
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
@@ -13,8 +13,7 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License along 15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, 16 with this program; if not, see <http://www.gnu.org/licenses/>. */
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 17
19/* This particular implementation was written by Eric Blake, 2008. */ 18/* This particular implementation was written by Eric Blake, 2008. */
20 19
diff --git a/gl/sys_socket.c b/gl/sys_socket.c
new file mode 100644
index 0000000..3f017f8
--- /dev/null
+++ b/gl/sys_socket.c
@@ -0,0 +1,3 @@
1#include <config.h>
2#define _GL_SYS_SOCKET_INLINE _GL_EXTERN_INLINE
3#include "sys/socket.h"
diff --git a/gl/sys_socket.in.h b/gl/sys_socket.in.h
index fc105e6..b4cf0c3 100644
--- a/gl/sys_socket.in.h
+++ b/gl/sys_socket.in.h
@@ -1,6 +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 and for systems where it is incomplete. 2 and for systems where it is incomplete.
3 Copyright (C) 2005-2010 Free Software Foundation, Inc. 3 Copyright (C) 2005-2013 Free Software Foundation, Inc.
4 Written by Simon Josefsson. 4 Written by Simon Josefsson.
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
@@ -14,8 +14,7 @@
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 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, 17 along with this program; if not, see <http://www.gnu.org/licenses/>. */
18 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
19 18
20/* This file is supposed to be used on platforms that lack <sys/socket.h>, 19/* This file is supposed to be used on platforms that lack <sys/socket.h>,
21 on platforms where <sys/socket.h> cannot be included standalone, and on 20 on platforms where <sys/socket.h> cannot be included standalone, and on
@@ -26,6 +25,7 @@
26#if __GNUC__ >= 3 25#if __GNUC__ >= 3
27@PRAGMA_SYSTEM_HEADER@ 26@PRAGMA_SYSTEM_HEADER@
28#endif 27#endif
28@PRAGMA_COLUMNS@
29 29
30#if defined _GL_ALREADY_INCLUDING_SYS_SOCKET_H 30#if defined _GL_ALREADY_INCLUDING_SYS_SOCKET_H
31/* Special invocation convention: 31/* Special invocation convention:
@@ -39,7 +39,7 @@
39#else 39#else
40/* Normal invocation convention. */ 40/* Normal invocation convention. */
41 41
42#ifndef _GL_SYS_SOCKET_H 42#ifndef _@GUARD_PREFIX@_SYS_SOCKET_H
43 43
44#if @HAVE_SYS_SOCKET_H@ 44#if @HAVE_SYS_SOCKET_H@
45 45
@@ -49,6 +49,10 @@
49 <sys/types.h>. */ 49 <sys/types.h>. */
50# include <sys/types.h> 50# include <sys/types.h>
51 51
52/* On FreeBSD 6.4, <sys/socket.h> defines some macros that assume that NULL
53 is defined. */
54# include <stddef.h>
55
52/* The include_next requires a split double-inclusion guard. */ 56/* The include_next requires a split double-inclusion guard. */
53# @INCLUDE_NEXT@ @NEXT_SYS_SOCKET_H@ 57# @INCLUDE_NEXT@ @NEXT_SYS_SOCKET_H@
54 58
@@ -56,8 +60,13 @@
56 60
57#endif 61#endif
58 62
59#ifndef _GL_SYS_SOCKET_H 63#ifndef _@GUARD_PREFIX@_SYS_SOCKET_H
60#define _GL_SYS_SOCKET_H 64#define _@GUARD_PREFIX@_SYS_SOCKET_H
65
66_GL_INLINE_HEADER_BEGIN
67#ifndef _GL_SYS_SOCKET_INLINE
68# define _GL_SYS_SOCKET_INLINE _GL_INLINE
69#endif
61 70
62/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 71/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
63 72
@@ -66,11 +75,21 @@
66/* The definition of _GL_WARN_ON_USE is copied here. */ 75/* The definition of _GL_WARN_ON_USE is copied here. */
67 76
68#if !@HAVE_SA_FAMILY_T@ 77#if !@HAVE_SA_FAMILY_T@
78# if !GNULIB_defined_sa_family_t
69typedef unsigned short sa_family_t; 79typedef unsigned short sa_family_t;
80# define GNULIB_defined_sa_family_t 1
81# endif
70#endif 82#endif
71 83
72#if !@HAVE_STRUCT_SOCKADDR_STORAGE@ 84#if @HAVE_STRUCT_SOCKADDR_STORAGE@
73# include <alignof.h> 85/* Make the 'struct sockaddr_storage' field 'ss_family' visible on AIX 7.1. */
86# if !@HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY@
87# ifndef ss_family
88# define ss_family __ss_family
89# endif
90# endif
91#else
92# include <stdalign.h>
74/* Code taken from glibc sysdeps/unix/sysv/linux/bits/socket.h on 93/* Code taken from glibc sysdeps/unix/sysv/linux/bits/socket.h on
75 2009-05-08, licensed under LGPLv2.1+, plus portability fixes. */ 94 2009-05-08, licensed under LGPLv2.1+, plus portability fixes. */
76# define __ss_aligntype unsigned long int 95# define __ss_aligntype unsigned long int
@@ -81,12 +100,22 @@ typedef unsigned short sa_family_t;
81 : alignof (__ss_aligntype)) \ 100 : alignof (__ss_aligntype)) \
82 + sizeof (__ss_aligntype))) 101 + sizeof (__ss_aligntype)))
83 102
103# if !GNULIB_defined_struct_sockaddr_storage
84struct sockaddr_storage 104struct sockaddr_storage
85{ 105{
86 sa_family_t ss_family; /* Address family, etc. */ 106 sa_family_t ss_family; /* Address family, etc. */
87 __ss_aligntype __ss_align; /* Force desired alignment. */ 107 __ss_aligntype __ss_align; /* Force desired alignment. */
88 char __ss_padding[_SS_PADSIZE]; 108 char __ss_padding[_SS_PADSIZE];
89}; 109};
110# define GNULIB_defined_struct_sockaddr_storage 1
111# endif
112
113#endif
114
115/* Get struct iovec. */
116/* But avoid namespace pollution on glibc systems. */
117#if ! defined __GLIBC__
118# include <sys/uio.h>
90#endif 119#endif
91 120
92#if @HAVE_SYS_SOCKET_H@ 121#if @HAVE_SYS_SOCKET_H@
@@ -118,16 +147,15 @@ struct sockaddr_storage
118 that you can influence which definitions you get by setting the 147 that you can influence which definitions you get by setting the
119 WINVER symbol before including these two files. For example, 148 WINVER symbol before including these two files. For example,
120 getaddrinfo is only available if _WIN32_WINNT >= 0x0501 (that 149 getaddrinfo is only available if _WIN32_WINNT >= 0x0501 (that
121 symbol is set indiriectly through WINVER). You can set this by 150 symbol is set indirectly through WINVER). You can set this by
122 adding AC_DEFINE(WINVER, 0x0501) to configure.ac. Note that your 151 adding AC_DEFINE(WINVER, 0x0501) to configure.ac. Note that your
123 code may not run on older Windows releases then. My Windows 2000 152 code may not run on older Windows releases then. My Windows 2000
124 box was not able to run the code, for example. The situation is 153 box was not able to run the code, for example. The situation is
125 slightly confusing because: 154 slightly confusing because
126 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/getaddrinfo_2.asp 155 <http://msdn.microsoft.com/en-us/library/ms738520>
127 suggests that getaddrinfo should be available on all Windows 156 suggests that getaddrinfo should be available on all Windows
128 releases. */ 157 releases. */
129 158
130
131# if @HAVE_WINSOCK2_H@ 159# if @HAVE_WINSOCK2_H@
132# include <winsock2.h> 160# include <winsock2.h>
133# endif 161# endif
@@ -151,17 +179,34 @@ struct sockaddr_storage
151# include <sys/types.h> 179# include <sys/types.h>
152# include <io.h> 180# include <io.h>
153 181
182# if !GNULIB_defined_socklen_t
154typedef int socklen_t; 183typedef int socklen_t;
184# define GNULIB_defined_socklen_t 1
185# endif
155 186
156# endif 187# endif
157 188
189/* Rudimentary 'struct msghdr'; this works as long as you don't try to
190 access msg_control or msg_controllen. */
191struct msghdr {
192 void *msg_name;
193 socklen_t msg_namelen;
194 struct iovec *msg_iov;
195 int msg_iovlen;
196 int msg_flags;
197};
198
158#endif 199#endif
159 200
201/* Fix some definitions from <winsock2.h>. */
202
160#if @HAVE_WINSOCK2_H@ 203#if @HAVE_WINSOCK2_H@
161 204
205# if !GNULIB_defined_rpl_fd_isset
206
162/* Re-define FD_ISSET to avoid a WSA call while we are not using 207/* Re-define FD_ISSET to avoid a WSA call while we are not using
163 network sockets. */ 208 network sockets. */
164static inline int 209_GL_SYS_SOCKET_INLINE int
165rpl_fd_isset (SOCKET fd, fd_set * set) 210rpl_fd_isset (SOCKET fd, fd_set * set)
166{ 211{
167 u_int i; 212 u_int i;
@@ -175,33 +220,46 @@ rpl_fd_isset (SOCKET fd, fd_set * set)
175 return 0; 220 return 0;
176} 221}
177 222
223# define GNULIB_defined_rpl_fd_isset 1
224# endif
225
178# undef FD_ISSET 226# undef FD_ISSET
179# define FD_ISSET(fd, set) rpl_fd_isset(fd, set) 227# define FD_ISSET(fd, set) rpl_fd_isset(fd, set)
180 228
181#endif 229#endif
182 230
183/* Wrap everything else to use libc file descriptors for sockets. */ 231/* Hide some function declarations from <winsock2.h>. */
184 232
185#if @HAVE_WINSOCK2_H@ && !defined _GL_UNISTD_H 233#if @HAVE_WINSOCK2_H@
186# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 234# if !defined _@GUARD_PREFIX@_UNISTD_H
187# undef close 235# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
188# define close close_used_without_including_unistd_h 236# undef close
189# else 237# define close close_used_without_including_unistd_h
190 _GL_WARN_ON_USE (close, 238# else
191 "close() used without including <unistd.h>"); 239 _GL_WARN_ON_USE (close,
240 "close() used without including <unistd.h>");
241# endif
242# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
243# undef gethostname
244# define gethostname gethostname_used_without_including_unistd_h
245# else
246 _GL_WARN_ON_USE (gethostname,
247 "gethostname() used without including <unistd.h>");
248# endif
192# endif 249# endif
193#endif 250# if !defined _@GUARD_PREFIX@_SYS_SELECT_H
194 251# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
195#if @HAVE_WINSOCK2_H@ && !defined _GL_UNISTD_H 252# undef select
196# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 253# define select select_used_without_including_sys_select_h
197# undef gethostname 254# else
198# define gethostname gethostname_used_without_including_unistd_h 255 _GL_WARN_ON_USE (select,
199# else 256 "select() used without including <sys/select.h>");
200 _GL_WARN_ON_USE (gethostname, 257# endif
201 "gethostname() used without including <unistd.h>");
202# endif 258# endif
203#endif 259#endif
204 260
261/* Wrap everything else to use libc file descriptors for sockets. */
262
205#if @GNULIB_SOCKET@ 263#if @GNULIB_SOCKET@
206# if @HAVE_WINSOCK2_H@ 264# if @HAVE_WINSOCK2_H@
207# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 265# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -237,8 +295,11 @@ _GL_FUNCDECL_RPL (connect, int,
237_GL_CXXALIAS_RPL (connect, int, 295_GL_CXXALIAS_RPL (connect, int,
238 (int fd, const struct sockaddr *addr, socklen_t addrlen)); 296 (int fd, const struct sockaddr *addr, socklen_t addrlen));
239# else 297# else
240_GL_CXXALIAS_SYS (connect, int, 298/* Need to cast, because on NonStop Kernel, the third parameter is
241 (int fd, const struct sockaddr *addr, socklen_t addrlen)); 299 size_t addrlen. */
300_GL_CXXALIAS_SYS_CAST (connect, int,
301 (int fd,
302 const struct sockaddr *addr, socklen_t addrlen));
242# endif 303# endif
243_GL_CXXALIASWARN (connect); 304_GL_CXXALIASWARN (connect);
244#elif @HAVE_WINSOCK2_H@ 305#elif @HAVE_WINSOCK2_H@
@@ -292,8 +353,11 @@ _GL_FUNCDECL_RPL (bind, int,
292_GL_CXXALIAS_RPL (bind, int, 353_GL_CXXALIAS_RPL (bind, int,
293 (int fd, const struct sockaddr *addr, socklen_t addrlen)); 354 (int fd, const struct sockaddr *addr, socklen_t addrlen));
294# else 355# else
295_GL_CXXALIAS_SYS (bind, int, 356/* Need to cast, because on NonStop Kernel, the third parameter is
296 (int fd, const struct sockaddr *addr, socklen_t addrlen)); 357 size_t addrlen. */
358_GL_CXXALIAS_SYS_CAST (bind, int,
359 (int fd,
360 const struct sockaddr *addr, socklen_t addrlen));
297# endif 361# endif
298_GL_CXXALIASWARN (bind); 362_GL_CXXALIASWARN (bind);
299#elif @HAVE_WINSOCK2_H@ 363#elif @HAVE_WINSOCK2_H@
@@ -514,9 +578,11 @@ _GL_CXXALIAS_RPL (sendto, ssize_t,
514 (int fd, const void *buf, size_t len, int flags, 578 (int fd, const void *buf, size_t len, int flags,
515 const struct sockaddr *to, socklen_t tolen)); 579 const struct sockaddr *to, socklen_t tolen));
516# else 580# else
517_GL_CXXALIAS_SYS (sendto, ssize_t, 581/* Need to cast, because on NonStop Kernel, the sixth parameter is
518 (int fd, const void *buf, size_t len, int flags, 582 size_t tolen. */
519 const struct sockaddr *to, socklen_t tolen)); 583_GL_CXXALIAS_SYS_CAST (sendto, ssize_t,
584 (int fd, const void *buf, size_t len, int flags,
585 const struct sockaddr *to, socklen_t tolen));
520# endif 586# endif
521_GL_CXXALIASWARN (sendto); 587_GL_CXXALIASWARN (sendto);
522#elif @HAVE_WINSOCK2_H@ 588#elif @HAVE_WINSOCK2_H@
@@ -542,8 +608,11 @@ _GL_FUNCDECL_RPL (setsockopt, int, (int fd, int level, int optname,
542_GL_CXXALIAS_RPL (setsockopt, int, (int fd, int level, int optname, 608_GL_CXXALIAS_RPL (setsockopt, int, (int fd, int level, int optname,
543 const void * optval, socklen_t optlen)); 609 const void * optval, socklen_t optlen));
544# else 610# else
545_GL_CXXALIAS_SYS (setsockopt, int, (int fd, int level, int optname, 611/* Need to cast, because on NonStop Kernel, the fifth parameter is
546 const void * optval, socklen_t optlen)); 612 size_t optlen. */
613_GL_CXXALIAS_SYS_CAST (setsockopt, int,
614 (int fd, int level, int optname,
615 const void * optval, socklen_t optlen));
547# endif 616# endif
548_GL_CXXALIASWARN (setsockopt); 617_GL_CXXALIASWARN (setsockopt);
549#elif @HAVE_WINSOCK2_H@ 618#elif @HAVE_WINSOCK2_H@
@@ -580,16 +649,6 @@ _GL_WARN_ON_USE (shutdown, "shutdown is not always POSIX compliant - "
580# endif 649# endif
581#endif 650#endif
582 651
583#if @HAVE_WINSOCK2_H@
584# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
585# undef select
586# define select select_used_without_including_sys_select_h
587# else
588 _GL_WARN_ON_USE (select,
589 "select() used without including <sys/select.h>");
590# endif
591#endif
592
593#if @GNULIB_ACCEPT4@ 652#if @GNULIB_ACCEPT4@
594/* Accept a connection on a socket, with specific opening flags. 653/* Accept a connection on a socket, with specific opening flags.
595 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>) 654 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
@@ -623,6 +682,8 @@ _GL_WARN_ON_USE (accept4, "accept4 is unportable - "
623# endif 682# endif
624#endif 683#endif
625 684
626#endif /* _GL_SYS_SOCKET_H */ 685_GL_INLINE_HEADER_END
627#endif /* _GL_SYS_SOCKET_H */ 686
687#endif /* _@GUARD_PREFIX@_SYS_SOCKET_H */
688#endif /* _@GUARD_PREFIX@_SYS_SOCKET_H */
628#endif 689#endif
diff --git a/gl/sys_stat.in.h b/gl/sys_stat.in.h
deleted file mode 100644
index dc7ef51..0000000
--- a/gl/sys_stat.in.h
+++ /dev/null
@@ -1,640 +0,0 @@
1/* Provide a more complete sys/stat header file.
2 Copyright (C) 2005-2010 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, or (at your option)
7 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, write to the Free Software Foundation,
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
17
18/* Written by Eric Blake, Paul Eggert, and Jim Meyering. */
19
20/* This file is supposed to be used on platforms where <sys/stat.h> is
21 incomplete. It is intended to provide definitions and prototypes
22 needed by an application. Start with what the system provides. */
23
24#if __GNUC__ >= 3
25@PRAGMA_SYSTEM_HEADER@
26#endif
27
28#if defined __need_system_sys_stat_h
29/* Special invocation convention. */
30
31#@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
32
33#else
34/* Normal invocation convention. */
35
36#ifndef _GL_SYS_STAT_H
37
38/* Get nlink_t. */
39#include <sys/types.h>
40
41/* Get struct timespec. */
42#include <time.h>
43
44/* The include_next requires a split double-inclusion guard. */
45#@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
46
47#ifndef _GL_SYS_STAT_H
48#define _GL_SYS_STAT_H
49
50/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
51
52/* The definition of _GL_ARG_NONNULL is copied here. */
53
54/* The definition of _GL_WARN_ON_USE is copied here. */
55
56/* Before doing "#define mkdir rpl_mkdir" below, we need to include all
57 headers that may declare mkdir(). */
58#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
59# include <io.h> /* mingw32, mingw64 */
60# include <direct.h> /* mingw64 */
61#endif
62
63#ifndef S_IFMT
64# define S_IFMT 0170000
65#endif
66
67#if STAT_MACROS_BROKEN
68# undef S_ISBLK
69# undef S_ISCHR
70# undef S_ISDIR
71# undef S_ISFIFO
72# undef S_ISLNK
73# undef S_ISNAM
74# undef S_ISMPB
75# undef S_ISMPC
76# undef S_ISNWK
77# undef S_ISREG
78# undef S_ISSOCK
79#endif
80
81#ifndef S_ISBLK
82# ifdef S_IFBLK
83# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
84# else
85# define S_ISBLK(m) 0
86# endif
87#endif
88
89#ifndef S_ISCHR
90# ifdef S_IFCHR
91# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
92# else
93# define S_ISCHR(m) 0
94# endif
95#endif
96
97#ifndef S_ISDIR
98# ifdef S_IFDIR
99# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
100# else
101# define S_ISDIR(m) 0
102# endif
103#endif
104
105#ifndef S_ISDOOR /* Solaris 2.5 and up */
106# define S_ISDOOR(m) 0
107#endif
108
109#ifndef S_ISFIFO
110# ifdef S_IFIFO
111# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
112# else
113# define S_ISFIFO(m) 0
114# endif
115#endif
116
117#ifndef S_ISLNK
118# ifdef S_IFLNK
119# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
120# else
121# define S_ISLNK(m) 0
122# endif
123#endif
124
125#ifndef S_ISMPB /* V7 */
126# ifdef S_IFMPB
127# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
128# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
129# else
130# define S_ISMPB(m) 0
131# define S_ISMPC(m) 0
132# endif
133#endif
134
135#ifndef S_ISNAM /* Xenix */
136# ifdef S_IFNAM
137# define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
138# else
139# define S_ISNAM(m) 0
140# endif
141#endif
142
143#ifndef S_ISNWK /* HP/UX */
144# ifdef S_IFNWK
145# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
146# else
147# define S_ISNWK(m) 0
148# endif
149#endif
150
151#ifndef S_ISPORT /* Solaris 10 and up */
152# define S_ISPORT(m) 0
153#endif
154
155#ifndef S_ISREG
156# ifdef S_IFREG
157# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
158# else
159# define S_ISREG(m) 0
160# endif
161#endif
162
163#ifndef S_ISSOCK
164# ifdef S_IFSOCK
165# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
166# else
167# define S_ISSOCK(m) 0
168# endif
169#endif
170
171
172#ifndef S_TYPEISMQ
173# define S_TYPEISMQ(p) 0
174#endif
175
176#ifndef S_TYPEISTMO
177# define S_TYPEISTMO(p) 0
178#endif
179
180
181#ifndef S_TYPEISSEM
182# ifdef S_INSEM
183# define S_TYPEISSEM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSEM)
184# else
185# define S_TYPEISSEM(p) 0
186# endif
187#endif
188
189#ifndef S_TYPEISSHM
190# ifdef S_INSHD
191# define S_TYPEISSHM(p) (S_ISNAM ((p)->st_mode) && (p)->st_rdev == S_INSHD)
192# else
193# define S_TYPEISSHM(p) 0
194# endif
195#endif
196
197/* high performance ("contiguous data") */
198#ifndef S_ISCTG
199# define S_ISCTG(p) 0
200#endif
201
202/* Cray DMF (data migration facility): off line, with data */
203#ifndef S_ISOFD
204# define S_ISOFD(p) 0
205#endif
206
207/* Cray DMF (data migration facility): off line, with no data */
208#ifndef S_ISOFL
209# define S_ISOFL(p) 0
210#endif
211
212/* 4.4BSD whiteout */
213#ifndef S_ISWHT
214# define S_ISWHT(m) 0
215#endif
216
217/* If any of the following are undefined,
218 define them to their de facto standard values. */
219#if !S_ISUID
220# define S_ISUID 04000
221#endif
222#if !S_ISGID
223# define S_ISGID 02000
224#endif
225
226/* S_ISVTX is a common extension to POSIX. */
227#ifndef S_ISVTX
228# define S_ISVTX 01000
229#endif
230
231#if !S_IRUSR && S_IREAD
232# define S_IRUSR S_IREAD
233#endif
234#if !S_IRUSR
235# define S_IRUSR 00400
236#endif
237#if !S_IRGRP
238# define S_IRGRP (S_IRUSR >> 3)
239#endif
240#if !S_IROTH
241# define S_IROTH (S_IRUSR >> 6)
242#endif
243
244#if !S_IWUSR && S_IWRITE
245# define S_IWUSR S_IWRITE
246#endif
247#if !S_IWUSR
248# define S_IWUSR 00200
249#endif
250#if !S_IWGRP
251# define S_IWGRP (S_IWUSR >> 3)
252#endif
253#if !S_IWOTH
254# define S_IWOTH (S_IWUSR >> 6)
255#endif
256
257#if !S_IXUSR && S_IEXEC
258# define S_IXUSR S_IEXEC
259#endif
260#if !S_IXUSR
261# define S_IXUSR 00100
262#endif
263#if !S_IXGRP
264# define S_IXGRP (S_IXUSR >> 3)
265#endif
266#if !S_IXOTH
267# define S_IXOTH (S_IXUSR >> 6)
268#endif
269
270#if !S_IRWXU
271# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
272#endif
273#if !S_IRWXG
274# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
275#endif
276#if !S_IRWXO
277# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
278#endif
279
280/* S_IXUGO is a common extension to POSIX. */
281#if !S_IXUGO
282# define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
283#endif
284
285#ifndef S_IRWXUGO
286# define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
287#endif
288
289/* Macros for futimens and utimensat. */
290#ifndef UTIME_NOW
291# define UTIME_NOW (-1)
292# define UTIME_OMIT (-2)
293#endif
294
295
296#if @GNULIB_FCHMODAT@
297# if !@HAVE_FCHMODAT@
298_GL_FUNCDECL_SYS (fchmodat, int,
299 (int fd, char const *file, mode_t mode, int flag)
300 _GL_ARG_NONNULL ((2)));
301# endif
302_GL_CXXALIAS_SYS (fchmodat, int,
303 (int fd, char const *file, mode_t mode, int flag));
304_GL_CXXALIASWARN (fchmodat);
305#elif defined GNULIB_POSIXCHECK
306# undef fchmodat
307# if HAVE_RAW_DECL_FCHMODAT
308_GL_WARN_ON_USE (fchmodat, "fchmodat is not portable - "
309 "use gnulib module openat for portability");
310# endif
311#endif
312
313
314#if @REPLACE_FSTAT@
315# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
316# define fstat rpl_fstat
317# endif
318_GL_FUNCDECL_RPL (fstat, int, (int fd, struct stat *buf) _GL_ARG_NONNULL ((2)));
319_GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf));
320#else
321_GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf));
322#endif
323_GL_CXXALIASWARN (fstat);
324
325
326#if @GNULIB_FSTATAT@
327# if @REPLACE_FSTATAT@
328# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
329# undef fstatat
330# define fstatat rpl_fstatat
331# endif
332_GL_FUNCDECL_RPL (fstatat, int,
333 (int fd, char const *name, struct stat *st, int flags)
334 _GL_ARG_NONNULL ((2, 3)));
335_GL_CXXALIAS_RPL (fstatat, int,
336 (int fd, char const *name, struct stat *st, int flags));
337# else
338# if !@HAVE_FSTATAT@
339_GL_FUNCDECL_SYS (fstatat, int,
340 (int fd, char const *name, struct stat *st, int flags)
341 _GL_ARG_NONNULL ((2, 3)));
342# endif
343_GL_CXXALIAS_SYS (fstatat, int,
344 (int fd, char const *name, struct stat *st, int flags));
345# endif
346_GL_CXXALIASWARN (fstatat);
347#elif defined GNULIB_POSIXCHECK
348# undef fstatat
349# if HAVE_RAW_DECL_FSTATAT
350_GL_WARN_ON_USE (fstatat, "fstatat is not portable - "
351 "use gnulib module openat for portability");
352# endif
353#endif
354
355
356#if @GNULIB_FUTIMENS@
357# if @REPLACE_FUTIMENS@
358# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
359# undef futimens
360# define futimens rpl_futimens
361# endif
362_GL_FUNCDECL_RPL (futimens, int, (int fd, struct timespec const times[2]));
363_GL_CXXALIAS_RPL (futimens, int, (int fd, struct timespec const times[2]));
364# else
365# if !@HAVE_FUTIMENS@
366_GL_FUNCDECL_SYS (futimens, int, (int fd, struct timespec const times[2]));
367# endif
368_GL_CXXALIAS_SYS (futimens, int, (int fd, struct timespec const times[2]));
369# endif
370_GL_CXXALIASWARN (futimens);
371#elif defined GNULIB_POSIXCHECK
372# undef futimens
373# if HAVE_RAW_DECL_FUTIMENS
374_GL_WARN_ON_USE (futimens, "futimens is not portable - "
375 "use gnulib module futimens for portability");
376# endif
377#endif
378
379
380#if @GNULIB_LCHMOD@
381/* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME
382 denotes a symbolic link. */
383# if !@HAVE_LCHMOD@
384/* The lchmod replacement follows symbolic links. Callers should take
385 this into account; lchmod should be applied only to arguments that
386 are known to not be symbolic links. On hosts that lack lchmod,
387 this can lead to race conditions between the check and the
388 invocation of lchmod, but we know of no workarounds that are
389 reliable in general. You might try requesting support for lchmod
390 from your operating system supplier. */
391# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
392# define lchmod chmod
393# endif
394/* Need to cast, because on mingw, the second parameter of chmod is
395 int mode. */
396_GL_CXXALIAS_RPL_CAST_1 (lchmod, chmod, int,
397 (const char *filename, mode_t mode));
398# else
399# if 0 /* assume already declared */
400_GL_FUNCDECL_SYS (lchmod, int, (const char *filename, mode_t mode)
401 _GL_ARG_NONNULL ((1)));
402# endif
403_GL_CXXALIAS_SYS (lchmod, int, (const char *filename, mode_t mode));
404# endif
405# if @HAVE_LCHMOD@
406_GL_CXXALIASWARN (lchmod);
407# endif
408#elif defined GNULIB_POSIXCHECK
409# undef lchmod
410# if HAVE_RAW_DECL_LCHMOD
411_GL_WARN_ON_USE (lchmod, "lchmod is unportable - "
412 "use gnulib module lchmod for portability");
413# endif
414#endif
415
416
417#if @GNULIB_LSTAT@
418# if ! @HAVE_LSTAT@
419/* mingw does not support symlinks, therefore it does not have lstat. But
420 without links, stat does just fine. */
421# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
422# define lstat stat
423# endif
424_GL_CXXALIAS_RPL_1 (lstat, stat, int, (const char *name, struct stat *buf));
425# elif @REPLACE_LSTAT@
426# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
427# undef lstat
428# define lstat rpl_lstat
429# endif
430_GL_FUNCDECL_RPL (lstat, int, (const char *name, struct stat *buf)
431 _GL_ARG_NONNULL ((1, 2)));
432_GL_CXXALIAS_RPL (lstat, int, (const char *name, struct stat *buf));
433# else
434_GL_CXXALIAS_SYS (lstat, int, (const char *name, struct stat *buf));
435# endif
436# if @HAVE_LSTAT@
437_GL_CXXALIASWARN (lstat);
438# endif
439#elif defined GNULIB_POSIXCHECK
440# undef lstat
441# if HAVE_RAW_DECL_LSTAT
442_GL_WARN_ON_USE (lstat, "lstat is unportable - "
443 "use gnulib module lstat for portability");
444# endif
445#endif
446
447
448#if @REPLACE_MKDIR@
449# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
450# undef mkdir
451# define mkdir rpl_mkdir
452# endif
453_GL_FUNCDECL_RPL (mkdir, int, (char const *name, mode_t mode)
454 _GL_ARG_NONNULL ((1)));
455_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
456#else
457/* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
458 Additionally, it declares _mkdir (and depending on compile flags, an
459 alias mkdir), only in the nonstandard includes <direct.h> and <io.h>,
460 which are included above. */
461# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
462
463static inline int
464rpl_mkdir (char const *name, mode_t mode)
465{
466 return _mkdir (name);
467}
468
469# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
470# define mkdir rpl_mkdir
471# endif
472_GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t mode));
473# else
474_GL_CXXALIAS_SYS (mkdir, int, (char const *name, mode_t mode));
475# endif
476#endif
477_GL_CXXALIASWARN (mkdir);
478
479
480#if @GNULIB_MKDIRAT@
481# if !@HAVE_MKDIRAT@
482_GL_FUNCDECL_SYS (mkdirat, int, (int fd, char const *file, mode_t mode)
483 _GL_ARG_NONNULL ((2)));
484# endif
485_GL_CXXALIAS_SYS (mkdirat, int, (int fd, char const *file, mode_t mode));
486_GL_CXXALIASWARN (mkdirat);
487#elif defined GNULIB_POSIXCHECK
488# undef mkdirat
489# if HAVE_RAW_DECL_MKDIRAT
490_GL_WARN_ON_USE (mkdirat, "mkdirat is not portable - "
491 "use gnulib module openat for portability");
492# endif
493#endif
494
495
496#if @GNULIB_MKFIFO@
497# if @REPLACE_MKFIFO@
498# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
499# undef mkfifo
500# define mkfifo rpl_mkfifo
501# endif
502_GL_FUNCDECL_RPL (mkfifo, int, (char const *file, mode_t mode)
503 _GL_ARG_NONNULL ((1)));
504_GL_CXXALIAS_RPL (mkfifo, int, (char const *file, mode_t mode));
505# else
506# if !@HAVE_MKFIFO@
507_GL_FUNCDECL_SYS (mkfifo, int, (char const *file, mode_t mode)
508 _GL_ARG_NONNULL ((1)));
509# endif
510_GL_CXXALIAS_SYS (mkfifo, int, (char const *file, mode_t mode));
511# endif
512_GL_CXXALIASWARN (mkfifo);
513#elif defined GNULIB_POSIXCHECK
514# undef mkfifo
515# if HAVE_RAW_DECL_MKFIFO
516_GL_WARN_ON_USE (mkfifo, "mkfifo is not portable - "
517 "use gnulib module mkfifo for portability");
518# endif
519#endif
520
521
522#if @GNULIB_MKFIFOAT@
523# if !@HAVE_MKFIFOAT@
524_GL_FUNCDECL_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode)
525 _GL_ARG_NONNULL ((2)));
526# endif
527_GL_CXXALIAS_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode));
528_GL_CXXALIASWARN (mkfifoat);
529#elif defined GNULIB_POSIXCHECK
530# undef mkfifoat
531# if HAVE_RAW_DECL_MKFIFOAT
532_GL_WARN_ON_USE (mkfifoat, "mkfifoat is not portable - "
533 "use gnulib module mkfifoat for portability");
534# endif
535#endif
536
537
538#if @GNULIB_MKNOD@
539# if @REPLACE_MKNOD@
540# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
541# undef mknod
542# define mknod rpl_mknod
543# endif
544_GL_FUNCDECL_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev)
545 _GL_ARG_NONNULL ((1)));
546_GL_CXXALIAS_RPL (mknod, int, (char const *file, mode_t mode, dev_t dev));
547# else
548# if !@HAVE_MKNOD@
549_GL_FUNCDECL_SYS (mknod, int, (char const *file, mode_t mode, dev_t dev)
550 _GL_ARG_NONNULL ((1)));
551# endif
552_GL_CXXALIAS_SYS (mknod, int, (char const *file, mode_t mode, dev_t dev));
553# endif
554_GL_CXXALIASWARN (mknod);
555#elif defined GNULIB_POSIXCHECK
556# undef mknod
557# if HAVE_RAW_DECL_MKNOD
558_GL_WARN_ON_USE (mknod, "mknod is not portable - "
559 "use gnulib module mknod for portability");
560# endif
561#endif
562
563
564#if @GNULIB_MKNODAT@
565# if !@HAVE_MKNODAT@
566_GL_FUNCDECL_SYS (mknodat, int,
567 (int fd, char const *file, mode_t mode, dev_t dev)
568 _GL_ARG_NONNULL ((2)));
569# endif
570_GL_CXXALIAS_SYS (mknodat, int,
571 (int fd, char const *file, mode_t mode, dev_t dev));
572_GL_CXXALIASWARN (mknodat);
573#elif defined GNULIB_POSIXCHECK
574# undef mknodat
575# if HAVE_RAW_DECL_MKNODAT
576_GL_WARN_ON_USE (mknodat, "mknodat is not portable - "
577 "use gnulib module mkfifoat for portability");
578# endif
579#endif
580
581
582#if @GNULIB_STAT@
583# if @REPLACE_STAT@
584/* We can't use the object-like #define stat rpl_stat, because of
585 struct stat. This means that rpl_stat will not be used if the user
586 does (stat)(a,b). Oh well. */
587# undef stat
588# ifdef _LARGE_FILES
589 /* With _LARGE_FILES defined, AIX (only) defines stat to stat64,
590 so we have to replace stat64() instead of stat(). */
591# define stat stat64
592# undef stat64
593# define stat64(name, st) rpl_stat (name, st)
594# else /* !_LARGE_FILES */
595# define stat(name, st) rpl_stat (name, st)
596# endif /* !_LARGE_FILES */
597_GL_EXTERN_C int stat (const char *name, struct stat *buf) _GL_ARG_NONNULL ((1, 2));
598# endif
599#elif defined GNULIB_POSIXCHECK
600# undef stat
601# if HAVE_RAW_DECL_STAT
602_GL_WARN_ON_USE (stat, "stat is unportable - "
603 "use gnulib module stat for portability");
604# endif
605#endif
606
607
608#if @GNULIB_UTIMENSAT@
609# if @REPLACE_UTIMENSAT@
610# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
611# undef utimensat
612# define utimensat rpl_utimensat
613# endif
614_GL_FUNCDECL_RPL (utimensat, int, (int fd, char const *name,
615 struct timespec const times[2], int flag)
616 _GL_ARG_NONNULL ((2)));
617_GL_CXXALIAS_RPL (utimensat, int, (int fd, char const *name,
618 struct timespec const times[2], int flag));
619# else
620# if !@HAVE_UTIMENSAT@
621_GL_FUNCDECL_SYS (utimensat, int, (int fd, char const *name,
622 struct timespec const times[2], int flag)
623 _GL_ARG_NONNULL ((2)));
624# endif
625_GL_CXXALIAS_SYS (utimensat, int, (int fd, char const *name,
626 struct timespec const times[2], int flag));
627# endif
628_GL_CXXALIASWARN (utimensat);
629#elif defined GNULIB_POSIXCHECK
630# undef utimensat
631# if HAVE_RAW_DECL_UTIMENSAT
632_GL_WARN_ON_USE (utimensat, "utimensat is not portable - "
633 "use gnulib module utimensat for portability");
634# endif
635#endif
636
637
638#endif /* _GL_SYS_STAT_H */
639#endif /* _GL_SYS_STAT_H */
640#endif
diff --git a/gl/sys_types.in.h b/gl/sys_types.in.h
new file mode 100644
index 0000000..d7da356
--- /dev/null
+++ b/gl/sys_types.in.h
@@ -0,0 +1,51 @@
1/* Provide a more complete sys/types.h.
2
3 Copyright (C) 2011-2013 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, see <http://www.gnu.org/licenses/>. */
17
18#if __GNUC__ >= 3
19@PRAGMA_SYSTEM_HEADER@
20#endif
21@PRAGMA_COLUMNS@
22
23#ifndef _@GUARD_PREFIX@_SYS_TYPES_H
24
25/* The include_next requires a split double-inclusion guard. */
26#@INCLUDE_NEXT@ @NEXT_SYS_TYPES_H@
27
28#ifndef _@GUARD_PREFIX@_SYS_TYPES_H
29#define _@GUARD_PREFIX@_SYS_TYPES_H
30
31/* Override off_t if Large File Support is requested on native Windows. */
32#if @WINDOWS_64_BIT_OFF_T@
33/* Same as int64_t in <stdint.h>. */
34# if defined _MSC_VER
35# define off_t __int64
36# else
37# define off_t long long int
38# endif
39/* Indicator, for gnulib internal purposes. */
40# define _GL_WINDOWS_64_BIT_OFF_T 1
41#endif
42
43/* MSVC 9 defines size_t in <stddef.h>, not in <sys/types.h>. */
44/* But avoid namespace pollution on glibc systems. */
45#if ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__) \
46 && ! defined __GLIBC__
47# include <stddef.h>
48#endif
49
50#endif /* _@GUARD_PREFIX@_SYS_TYPES_H */
51#endif /* _@GUARD_PREFIX@_SYS_TYPES_H */
diff --git a/gl/sys_uio.in.h b/gl/sys_uio.in.h
new file mode 100644
index 0000000..fef19dc
--- /dev/null
+++ b/gl/sys_uio.in.h
@@ -0,0 +1,63 @@
1/* Substitute for <sys/uio.h>.
2 Copyright (C) 2011-2013 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, or (at your option)
7 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# if __GNUC__ >= 3
18@PRAGMA_SYSTEM_HEADER@
19# endif
20@PRAGMA_COLUMNS@
21
22#ifndef _@GUARD_PREFIX@_SYS_UIO_H
23
24#if @HAVE_SYS_UIO_H@
25
26/* On OpenBSD 4.4, <sys/uio.h> assumes prior inclusion of <sys/types.h>. */
27# include <sys/types.h>
28
29/* The include_next requires a split double-inclusion guard. */
30# @INCLUDE_NEXT@ @NEXT_SYS_UIO_H@
31
32#endif
33
34#ifndef _@GUARD_PREFIX@_SYS_UIO_H
35#define _@GUARD_PREFIX@_SYS_UIO_H
36
37#if !@HAVE_SYS_UIO_H@
38/* A platform that lacks <sys/uio.h>. */
39/* Get 'size_t' and 'ssize_t'. */
40# include <sys/types.h>
41
42# ifdef __cplusplus
43extern "C" {
44# endif
45
46# if !GNULIB_defined_struct_iovec
47/* All known platforms that lack <sys/uio.h> also lack any declaration
48 of struct iovec in any other header. */
49struct iovec {
50 void *iov_base;
51 size_t iov_len;
52};
53# define GNULIB_defined_struct_iovec 1
54# endif
55
56# ifdef __cplusplus
57}
58# endif
59
60#endif
61
62#endif /* _@GUARD_PREFIX@_SYS_UIO_H */
63#endif /* _@GUARD_PREFIX@_SYS_UIO_H */
diff --git a/gl/time.in.h b/gl/time.in.h
index 6fb4fd7..8ced794 100644
--- a/gl/time.in.h
+++ b/gl/time.in.h
@@ -1,6 +1,6 @@
1/* A more-standard <time.h>. 1/* A more-standard <time.h>.
2 2
3 Copyright (C) 2007-2010 Free Software Foundation, Inc. 3 Copyright (C) 2007-2013 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
@@ -13,12 +13,12 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
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, write to the Free Software Foundation, 16 along with this program; if not, see <http://www.gnu.org/licenses/>. */
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 17
19#if __GNUC__ >= 3 18#if __GNUC__ >= 3
20@PRAGMA_SYSTEM_HEADER@ 19@PRAGMA_SYSTEM_HEADER@
21#endif 20#endif
21@PRAGMA_COLUMNS@
22 22
23/* Don't get in the way of glibc when it includes time.h merely to 23/* Don't get in the way of glibc when it includes time.h merely to
24 declare a few standard symbols, rather than to declare all the 24 declare a few standard symbols, rather than to declare all the
@@ -27,13 +27,13 @@
27 without adding our own declarations. */ 27 without adding our own declarations. */
28#if (defined __need_time_t || defined __need_clock_t \ 28#if (defined __need_time_t || defined __need_clock_t \
29 || defined __need_timespec \ 29 || defined __need_timespec \
30 || defined _GL_TIME_H) 30 || defined _@GUARD_PREFIX@_TIME_H)
31 31
32# @INCLUDE_NEXT@ @NEXT_TIME_H@ 32# @INCLUDE_NEXT@ @NEXT_TIME_H@
33 33
34#else 34#else
35 35
36# define _GL_TIME_H 36# define _@GUARD_PREFIX@_TIME_H
37 37
38# @INCLUDE_NEXT@ @NEXT_TIME_H@ 38# @INCLUDE_NEXT@ @NEXT_TIME_H@
39 39
@@ -68,13 +68,16 @@
68extern "C" { 68extern "C" {
69# endif 69# endif
70 70
71# undef timespec 71# if !GNULIB_defined_struct_timespec
72# define timespec rpl_timespec 72# undef timespec
73# define timespec rpl_timespec
73struct timespec 74struct timespec
74{ 75{
75 time_t tv_sec; 76 time_t tv_sec;
76 long int tv_nsec; 77 long int tv_nsec;
77}; 78};
79# define GNULIB_defined_struct_timespec 1
80# endif
78 81
79# ifdef __cplusplus 82# ifdef __cplusplus
80} 83}
@@ -83,6 +86,18 @@ struct timespec
83# endif 86# endif
84# endif 87# endif
85 88
89# if !GNULIB_defined_struct_time_t_must_be_integral
90/* Per http://austingroupbugs.net/view.php?id=327, POSIX requires
91 time_t to be an integer type, even though C99 permits floating
92 point. We don't know of any implementation that uses floating
93 point, and it is much easier to write code that doesn't have to
94 worry about that corner case, so we force the issue. */
95struct __time_t_must_be_integral {
96 unsigned int __floating_time_t_unsupported : (time_t) 1;
97};
98# define GNULIB_defined_struct_time_t_must_be_integral 1
99# endif
100
86/* Sleep for at least RQTP seconds unless interrupted, If interrupted, 101/* Sleep for at least RQTP seconds unless interrupted, If interrupted,
87 return -1 and store the remaining time into RMTP. See 102 return -1 and store the remaining time into RMTP. See
88 <http://www.opengroup.org/susv3xsh/nanosleep.html>. */ 103 <http://www.opengroup.org/susv3xsh/nanosleep.html>. */
@@ -137,7 +152,7 @@ _GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
137_GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer, 152_GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
138 struct tm *restrict __result)); 153 struct tm *restrict __result));
139# else 154# else
140# if ! @HAVE_LOCALTIME_R@ 155# if ! @HAVE_DECL_LOCALTIME_R@
141_GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer, 156_GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
142 struct tm *restrict __result) 157 struct tm *restrict __result)
143 _GL_ARG_NONNULL ((1, 2))); 158 _GL_ARG_NONNULL ((1, 2)));
@@ -145,7 +160,9 @@ _GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
145_GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer, 160_GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
146 struct tm *restrict __result)); 161 struct tm *restrict __result));
147# endif 162# endif
163# if @HAVE_DECL_LOCALTIME_R@
148_GL_CXXALIASWARN (localtime_r); 164_GL_CXXALIASWARN (localtime_r);
165# endif
149# if @REPLACE_LOCALTIME_R@ 166# if @REPLACE_LOCALTIME_R@
150# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 167# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
151# undef gmtime_r 168# undef gmtime_r
@@ -157,7 +174,7 @@ _GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
157_GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer, 174_GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
158 struct tm *restrict __result)); 175 struct tm *restrict __result));
159# else 176# else
160# if ! @HAVE_LOCALTIME_R@ 177# if ! @HAVE_DECL_LOCALTIME_R@
161_GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer, 178_GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
162 struct tm *restrict __result) 179 struct tm *restrict __result)
163 _GL_ARG_NONNULL ((1, 2))); 180 _GL_ARG_NONNULL ((1, 2)));
@@ -165,7 +182,9 @@ _GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
165_GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer, 182_GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
166 struct tm *restrict __result)); 183 struct tm *restrict __result));
167# endif 184# endif
185# if @HAVE_DECL_LOCALTIME_R@
168_GL_CXXALIASWARN (gmtime_r); 186_GL_CXXALIASWARN (gmtime_r);
187# endif
169# endif 188# endif
170 189
171/* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store 190/* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store
diff --git a/gl/time_r.c b/gl/time_r.c
index 3b2b3e9..9866299 100644
--- a/gl/time_r.c
+++ b/gl/time_r.c
@@ -1,6 +1,6 @@
1/* Reentrant time functions like localtime_r. 1/* Reentrant time functions like localtime_r.
2 2
3 Copyright (C) 2003, 2006-2007, 2010 Free Software Foundation, Inc. 3 Copyright (C) 2003, 2006-2007, 2010-2013 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
@@ -13,8 +13,7 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License along 15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, 16 with this program; if not, see <http://www.gnu.org/licenses/>. */
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 17
19/* Written by Paul Eggert. */ 18/* Written by Paul Eggert. */
20 19
diff --git a/gl/timegm.c b/gl/timegm.c
index e484ddd..6338baa 100644
--- a/gl/timegm.c
+++ b/gl/timegm.c
@@ -1,6 +1,6 @@
1/* Convert UTC calendar time to simple time. Like mktime but assumes UTC. 1/* Convert UTC calendar time to simple time. Like mktime but assumes UTC.
2 2
3 Copyright (C) 1994, 1997, 2003, 2004, 2006, 2007, 2009, 2010 Free Software 3 Copyright (C) 1994, 1997, 2003-2004, 2006-2007, 2009-2013 Free Software
4 Foundation, Inc. This file is part of the GNU C Library. 4 Foundation, Inc. This file is part of the GNU C Library.
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
@@ -14,8 +14,7 @@
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 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, 17 along with this program; if not, see <http://www.gnu.org/licenses/>. */
18 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
19 18
20#ifndef _LIBC 19#ifndef _LIBC
21# include <config.h> 20# include <config.h>
diff --git a/gl/unistd--.h b/gl/unistd--.h
deleted file mode 100644
index 5283d2c..0000000
--- a/gl/unistd--.h
+++ /dev/null
@@ -1,32 +0,0 @@
1/* Like unistd.h, but redefine some names to avoid glitches.
2
3 Copyright (C) 2005, 2009-2010 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#include <unistd.h>
21#include "unistd-safer.h"
22
23#undef dup
24#define dup dup_safer
25
26#undef pipe
27#define pipe pipe_safer
28
29#if GNULIB_PIPE2_SAFER
30# undef pipe2
31# define pipe2 pipe2_safer
32#endif
diff --git a/gl/unistd-safer.h b/gl/unistd-safer.h
deleted file mode 100644
index 190f108..0000000
--- a/gl/unistd-safer.h
+++ /dev/null
@@ -1,31 +0,0 @@
1/* Invoke unistd-like functions, but avoid some glitches.
2
3 Copyright (C) 2001, 2003, 2005, 2009-2010 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 and Eric Blake. */
19
20int dup_safer (int);
21int fd_safer (int);
22int pipe_safer (int[2]);
23
24#if GNULIB_FD_SAFER_FLAG
25int dup_safer_flag (int, int);
26int fd_safer_flag (int, int);
27#endif
28
29#if GNULIB_PIPE2_SAFER
30int pipe2_safer (int[2], int);
31#endif
diff --git a/gl/unistd.c b/gl/unistd.c
new file mode 100644
index 0000000..6c6a8e2
--- /dev/null
+++ b/gl/unistd.c
@@ -0,0 +1,3 @@
1#include <config.h>
2#define _GL_UNISTD_INLINE _GL_EXTERN_INLINE
3#include "unistd.h"
diff --git a/gl/unistd.in.h b/gl/unistd.in.h
index 7914f22..2ea9af4 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) 2003-2010 Free Software Foundation, Inc. 2 Copyright (C) 2003-2013 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
@@ -12,30 +12,14 @@
12 GNU General Public License for more details. 12 GNU General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software Foundation, 15 along with this program; if not, see <http://www.gnu.org/licenses/>. */
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ 16
17#ifndef _@GUARD_PREFIX@_UNISTD_H
17 18
18#if __GNUC__ >= 3 19#if __GNUC__ >= 3
19@PRAGMA_SYSTEM_HEADER@ 20@PRAGMA_SYSTEM_HEADER@
20#endif 21#endif
21 22@PRAGMA_COLUMNS@
22/* Special invocation convention:
23 - On mingw, several headers, including <winsock2.h>, include <unistd.h>,
24 but we need to ensure that both the system <unistd.h> and <winsock2.h>
25 are completely included before we replace gethostname. */
26#if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
27 && !defined _GL_WINSOCK2_H_WITNESS && defined _WINSOCK2_H
28/* <unistd.h> is being indirectly included for the first time from
29 <winsock2.h>; avoid declaring any overrides. */
30# if @HAVE_UNISTD_H@
31# @INCLUDE_NEXT@ @NEXT_UNISTD_H@
32# else
33# error unexpected; report this to bug-gnulib@gnu.org
34# endif
35# define _GL_WINSOCK2_H_WITNESS
36
37/* Normal invocation. */
38#elif !defined _GL_UNISTD_H
39 23
40/* The include_next requires a split double-inclusion guard. */ 24/* The include_next requires a split double-inclusion guard. */
41#if @HAVE_UNISTD_H@ 25#if @HAVE_UNISTD_H@
@@ -50,8 +34,8 @@
50# undef _GL_INCLUDING_WINSOCK2_H 34# undef _GL_INCLUDING_WINSOCK2_H
51#endif 35#endif
52 36
53#if !defined _GL_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H 37#if !defined _@GUARD_PREFIX@_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H
54#define _GL_UNISTD_H 38#define _@GUARD_PREFIX@_UNISTD_H
55 39
56/* NetBSD 5.0 mis-defines NULL. Also get size_t. */ 40/* NetBSD 5.0 mis-defines NULL. Also get size_t. */
57#include <stddef.h> 41#include <stddef.h>
@@ -60,32 +44,66 @@
60/* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */ 44/* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */
61/* But avoid namespace pollution on glibc systems. */ 45/* But avoid namespace pollution on glibc systems. */
62#if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \ 46#if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
63 || (@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK)) \ 47 || ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \
48 && defined __CYGWIN__)) \
64 && ! defined __GLIBC__ 49 && ! defined __GLIBC__
65# include <stdio.h> 50# include <stdio.h>
66#endif 51#endif
67 52
68/* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>. */ 53/* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>. */
69/* But avoid namespace pollution on glibc systems. */ 54/* But avoid namespace pollution on glibc systems. */
70#if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__ 55#if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && defined __CYGWIN__ \
56 && ! defined __GLIBC__
71# include <fcntl.h> 57# include <fcntl.h>
72#endif 58#endif
73 59
74/* mingw fails to declare _exit in <unistd.h>. */ 60/* mingw fails to declare _exit in <unistd.h>. */
75/* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>. */ 61/* mingw, MSVC, BeOS, Haiku declare environ in <stdlib.h>, not in
62 <unistd.h>. */
76/* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */ 63/* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */
64/* OSF Tru64 Unix cannot see gnulib rpl_strtod when system <stdlib.h> is
65 included here. */
77/* But avoid namespace pollution on glibc systems. */ 66/* But avoid namespace pollution on glibc systems. */
78#ifndef __GLIBC__ 67#if !defined __GLIBC__ && !defined __osf__
68# define __need_system_stdlib_h
79# include <stdlib.h> 69# include <stdlib.h>
70# undef __need_system_stdlib_h
80#endif 71#endif
81 72
82/* mingw declares getcwd in <io.h>, not in <unistd.h>. */ 73/* Native Windows platforms declare chdir, getcwd, rmdir in
83#if ((@GNULIB_GETCWD@ || defined GNULIB_POSIXCHECK) \ 74 <io.h> and/or <direct.h>, not in <unistd.h>.
75 They also declare access(), chmod(), close(), dup(), dup2(), isatty(),
76 lseek(), read(), unlink(), write() in <io.h>. */
77#if ((@GNULIB_CHDIR@ || @GNULIB_GETCWD@ || @GNULIB_RMDIR@ \
78 || defined GNULIB_POSIXCHECK) \
84 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)) 79 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
80# include <io.h> /* mingw32, mingw64 */
81# include <direct.h> /* mingw64, MSVC 9 */
82#elif (@GNULIB_CLOSE@ || @GNULIB_DUP@ || @GNULIB_DUP2@ || @GNULIB_ISATTY@ \
83 || @GNULIB_LSEEK@ || @GNULIB_READ@ || @GNULIB_UNLINK@ || @GNULIB_WRITE@ \
84 || defined GNULIB_POSIXCHECK) \
85 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
85# include <io.h> 86# include <io.h>
86#endif 87#endif
87 88
88#if (@GNULIB_WRITE@ || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \ 89/* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>.
90 NonStop Kernel declares gethostname in <netdb.h>, not in <unistd.h>. */
91/* But avoid namespace pollution on glibc systems. */
92#if ((@GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__)) \
93 || (@GNULIB_GETHOSTNAME@ && defined __TANDEM)) \
94 && !defined __GLIBC__
95# include <netdb.h>
96#endif
97
98/* MSVC defines off_t in <sys/types.h>.
99 May also define off_t to a 64-bit type on native Windows. */
100#if !@HAVE_UNISTD_H@ || @WINDOWS_64_BIT_OFF_T@
101/* Get off_t. */
102# include <sys/types.h>
103#endif
104
105#if (@GNULIB_READ@ || @GNULIB_WRITE@ \
106 || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
89 || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK) 107 || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK)
90/* Get ssize_t. */ 108/* Get ssize_t. */
91# include <sys/types.h> 109# include <sys/types.h>
@@ -94,9 +112,15 @@
94/* Get getopt(), optarg, optind, opterr, optopt. 112/* Get getopt(), optarg, optind, opterr, optopt.
95 But avoid namespace pollution on glibc systems. */ 113 But avoid namespace pollution on glibc systems. */
96#if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT 114#if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
115# define __need_getopt
97# include <getopt.h> 116# include <getopt.h>
98#endif 117#endif
99 118
119_GL_INLINE_HEADER_BEGIN
120#ifndef _GL_UNISTD_INLINE
121# define _GL_UNISTD_INLINE _GL_INLINE
122#endif
123
100/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 124/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
101 125
102/* The definition of _GL_ARG_NONNULL is copied here. */ 126/* The definition of _GL_ARG_NONNULL is copied here. */
@@ -104,78 +128,77 @@
104/* The definition of _GL_WARN_ON_USE is copied here. */ 128/* The definition of _GL_WARN_ON_USE is copied here. */
105 129
106 130
107#if @GNULIB_GETHOSTNAME@ 131/* Hide some function declarations from <winsock2.h>. */
108/* Get all possible declarations of gethostname(). */ 132
109# if @UNISTD_H_HAVE_WINSOCK2_H@ 133#if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@
110# if !defined _GL_SYS_SOCKET_H 134# if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
111# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 135# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
112# undef socket 136# undef socket
113# define socket socket_used_without_including_sys_socket_h 137# define socket socket_used_without_including_sys_socket_h
114# undef connect 138# undef connect
115# define connect connect_used_without_including_sys_socket_h 139# define connect connect_used_without_including_sys_socket_h
116# undef accept 140# undef accept
117# define accept accept_used_without_including_sys_socket_h 141# define accept accept_used_without_including_sys_socket_h
118# undef bind 142# undef bind
119# define bind bind_used_without_including_sys_socket_h 143# define bind bind_used_without_including_sys_socket_h
120# undef getpeername 144# undef getpeername
121# define getpeername getpeername_used_without_including_sys_socket_h 145# define getpeername getpeername_used_without_including_sys_socket_h
122# undef getsockname 146# undef getsockname
123# define getsockname getsockname_used_without_including_sys_socket_h 147# define getsockname getsockname_used_without_including_sys_socket_h
124# undef getsockopt 148# undef getsockopt
125# define getsockopt getsockopt_used_without_including_sys_socket_h 149# define getsockopt getsockopt_used_without_including_sys_socket_h
126# undef listen 150# undef listen
127# define listen listen_used_without_including_sys_socket_h 151# define listen listen_used_without_including_sys_socket_h
128# undef recv 152# undef recv
129# define recv recv_used_without_including_sys_socket_h 153# define recv recv_used_without_including_sys_socket_h
130# undef send 154# undef send
131# define send send_used_without_including_sys_socket_h 155# define send send_used_without_including_sys_socket_h
132# undef recvfrom 156# undef recvfrom
133# define recvfrom recvfrom_used_without_including_sys_socket_h 157# define recvfrom recvfrom_used_without_including_sys_socket_h
134# undef sendto 158# undef sendto
135# define sendto sendto_used_without_including_sys_socket_h 159# define sendto sendto_used_without_including_sys_socket_h
136# undef setsockopt 160# undef setsockopt
137# define setsockopt setsockopt_used_without_including_sys_socket_h 161# define setsockopt setsockopt_used_without_including_sys_socket_h
138# undef shutdown 162# undef shutdown
139# define shutdown shutdown_used_without_including_sys_socket_h 163# define shutdown shutdown_used_without_including_sys_socket_h
140# else 164# else
141 _GL_WARN_ON_USE (socket, 165 _GL_WARN_ON_USE (socket,
142 "socket() used without including <sys/socket.h>"); 166 "socket() used without including <sys/socket.h>");
143 _GL_WARN_ON_USE (connect, 167 _GL_WARN_ON_USE (connect,
144 "connect() used without including <sys/socket.h>"); 168 "connect() used without including <sys/socket.h>");
145 _GL_WARN_ON_USE (accept, 169 _GL_WARN_ON_USE (accept,
146 "accept() used without including <sys/socket.h>"); 170 "accept() used without including <sys/socket.h>");
147 _GL_WARN_ON_USE (bind, 171 _GL_WARN_ON_USE (bind,
148 "bind() used without including <sys/socket.h>"); 172 "bind() used without including <sys/socket.h>");
149 _GL_WARN_ON_USE (getpeername, 173 _GL_WARN_ON_USE (getpeername,
150 "getpeername() used without including <sys/socket.h>"); 174 "getpeername() used without including <sys/socket.h>");
151 _GL_WARN_ON_USE (getsockname, 175 _GL_WARN_ON_USE (getsockname,
152 "getsockname() used without including <sys/socket.h>"); 176 "getsockname() used without including <sys/socket.h>");
153 _GL_WARN_ON_USE (getsockopt, 177 _GL_WARN_ON_USE (getsockopt,
154 "getsockopt() used without including <sys/socket.h>"); 178 "getsockopt() used without including <sys/socket.h>");
155 _GL_WARN_ON_USE (listen, 179 _GL_WARN_ON_USE (listen,
156 "listen() used without including <sys/socket.h>"); 180 "listen() used without including <sys/socket.h>");
157 _GL_WARN_ON_USE (recv, 181 _GL_WARN_ON_USE (recv,
158 "recv() used without including <sys/socket.h>"); 182 "recv() used without including <sys/socket.h>");
159 _GL_WARN_ON_USE (send, 183 _GL_WARN_ON_USE (send,
160 "send() used without including <sys/socket.h>"); 184 "send() used without including <sys/socket.h>");
161 _GL_WARN_ON_USE (recvfrom, 185 _GL_WARN_ON_USE (recvfrom,
162 "recvfrom() used without including <sys/socket.h>"); 186 "recvfrom() used without including <sys/socket.h>");
163 _GL_WARN_ON_USE (sendto, 187 _GL_WARN_ON_USE (sendto,
164 "sendto() used without including <sys/socket.h>"); 188 "sendto() used without including <sys/socket.h>");
165 _GL_WARN_ON_USE (setsockopt, 189 _GL_WARN_ON_USE (setsockopt,
166 "setsockopt() used without including <sys/socket.h>"); 190 "setsockopt() used without including <sys/socket.h>");
167 _GL_WARN_ON_USE (shutdown, 191 _GL_WARN_ON_USE (shutdown,
168 "shutdown() used without including <sys/socket.h>"); 192 "shutdown() used without including <sys/socket.h>");
169# endif
170# endif 193# endif
171# if !defined _GL_SYS_SELECT_H 194# endif
172# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 195# if !defined _@GUARD_PREFIX@_SYS_SELECT_H
173# undef select 196# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
174# define select select_used_without_including_sys_select_h 197# undef select
175# else 198# define select select_used_without_including_sys_select_h
176 _GL_WARN_ON_USE (select, 199# else
177 "select() used without including <sys/select.h>"); 200 _GL_WARN_ON_USE (select,
178# endif 201 "select() used without including <sys/select.h>");
179# endif 202# endif
180# endif 203# endif
181#endif 204#endif
@@ -211,12 +234,24 @@ _GL_WARN_ON_USE (access, "the access function is a security risk - "
211#endif 234#endif
212 235
213 236
237#if @GNULIB_CHDIR@
238_GL_CXXALIAS_SYS (chdir, int, (const char *file) _GL_ARG_NONNULL ((1)));
239_GL_CXXALIASWARN (chdir);
240#elif defined GNULIB_POSIXCHECK
241# undef chdir
242# if HAVE_RAW_DECL_CHDIR
243_GL_WARN_ON_USE (chown, "chdir is not always in <unistd.h> - "
244 "use gnulib module chdir for portability");
245# endif
246#endif
247
248
214#if @GNULIB_CHOWN@ 249#if @GNULIB_CHOWN@
215/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE 250/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
216 to GID (if GID is not -1). Follow symbolic links. 251 to GID (if GID is not -1). Follow symbolic links.
217 Return 0 if successful, otherwise -1 and errno set. 252 Return 0 if successful, otherwise -1 and errno set.
218 See the POSIX:2001 specification 253 See the POSIX:2008 specification
219 <http://www.opengroup.org/susv3xsh/chown.html>. */ 254 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html. */
220# if @REPLACE_CHOWN@ 255# if @REPLACE_CHOWN@
221# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 256# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
222# undef chown 257# undef chown
@@ -267,24 +302,32 @@ _GL_WARN_ON_USE (close, "close does not portably work on sockets - "
267#endif 302#endif
268 303
269 304
270#if @REPLACE_DUP@ 305#if @GNULIB_DUP@
271# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 306# if @REPLACE_DUP@
272# define dup rpl_dup 307# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
273# endif 308# define dup rpl_dup
309# endif
274_GL_FUNCDECL_RPL (dup, int, (int oldfd)); 310_GL_FUNCDECL_RPL (dup, int, (int oldfd));
275_GL_CXXALIAS_RPL (dup, int, (int oldfd)); 311_GL_CXXALIAS_RPL (dup, int, (int oldfd));
276#else 312# else
277_GL_CXXALIAS_SYS (dup, int, (int oldfd)); 313_GL_CXXALIAS_SYS (dup, int, (int oldfd));
278#endif 314# endif
279_GL_CXXALIASWARN (dup); 315_GL_CXXALIASWARN (dup);
316#elif defined GNULIB_POSIXCHECK
317# undef dup
318# if HAVE_RAW_DECL_DUP
319_GL_WARN_ON_USE (dup, "dup is unportable - "
320 "use gnulib module dup for portability");
321# endif
322#endif
280 323
281 324
282#if @GNULIB_DUP2@ 325#if @GNULIB_DUP2@
283/* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if 326/* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
284 NEWFD = OLDFD, otherwise close NEWFD first if it is open. 327 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
285 Return newfd if successful, otherwise -1 and errno set. 328 Return newfd if successful, otherwise -1 and errno set.
286 See the POSIX:2001 specification 329 See the POSIX:2008 specification
287 <http://www.opengroup.org/susv3xsh/dup2.html>. */ 330 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */
288# if @REPLACE_DUP2@ 331# if @REPLACE_DUP2@
289# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 332# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
290# define dup2 rpl_dup2 333# define dup2 rpl_dup2
@@ -355,7 +398,7 @@ extern char **environ;
355# endif 398# endif
356#elif defined GNULIB_POSIXCHECK 399#elif defined GNULIB_POSIXCHECK
357# if HAVE_RAW_DECL_ENVIRON 400# if HAVE_RAW_DECL_ENVIRON
358static inline char *** 401_GL_UNISTD_INLINE char ***
359rpl_environ (void) 402rpl_environ (void)
360{ 403{
361 return &environ; 404 return &environ;
@@ -413,8 +456,8 @@ _GL_WARN_ON_USE (faccessat, "faccessat is not portable - "
413/* Change the process' current working directory to the directory on which 456/* Change the process' current working directory to the directory on which
414 the given file descriptor is open. 457 the given file descriptor is open.
415 Return 0 if successful, otherwise -1 and errno set. 458 Return 0 if successful, otherwise -1 and errno set.
416 See the POSIX:2001 specification 459 See the POSIX:2008 specification
417 <http://www.opengroup.org/susv3xsh/fchdir.html>. */ 460 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */
418# if ! @HAVE_FCHDIR@ 461# if ! @HAVE_FCHDIR@
419_GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/)); 462_GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
420 463
@@ -425,6 +468,10 @@ _GL_EXTERN_C void _gl_unregister_fd (int fd);
425_GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd); 468_GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd);
426_GL_EXTERN_C const char *_gl_directory_name (int fd); 469_GL_EXTERN_C const char *_gl_directory_name (int fd);
427 470
471# else
472# if !@HAVE_DECL_FCHDIR@
473_GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
474# endif
428# endif 475# endif
429_GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/)); 476_GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/));
430_GL_CXXALIASWARN (fchdir); 477_GL_CXXALIASWARN (fchdir);
@@ -467,11 +514,30 @@ _GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
467#endif 514#endif
468 515
469 516
470#if @GNULIB_FSYNC@ 517#if @GNULIB_FDATASYNC@
471/* Synchronize changes to a file. 518/* Synchronize changes to a file.
472 Return 0 if successful, otherwise -1 and errno set. 519 Return 0 if successful, otherwise -1 and errno set.
473 See POSIX:2001 specification 520 See POSIX:2008 specification
474 <http://www.opengroup.org/susv3xsh/fsync.html>. */ 521 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */
522# if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@
523_GL_FUNCDECL_SYS (fdatasync, int, (int fd));
524# endif
525_GL_CXXALIAS_SYS (fdatasync, int, (int fd));
526_GL_CXXALIASWARN (fdatasync);
527#elif defined GNULIB_POSIXCHECK
528# undef fdatasync
529# if HAVE_RAW_DECL_FDATASYNC
530_GL_WARN_ON_USE (fdatasync, "fdatasync is unportable - "
531 "use gnulib module fdatasync for portability");
532# endif
533#endif
534
535
536#if @GNULIB_FSYNC@
537/* Synchronize changes, including metadata, to a file.
538 Return 0 if successful, otherwise -1 and errno set.
539 See POSIX:2008 specification
540 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */
475# if !@HAVE_FSYNC@ 541# if !@HAVE_FSYNC@
476_GL_FUNCDECL_SYS (fsync, int, (int fd)); 542_GL_FUNCDECL_SYS (fsync, int, (int fd));
477# endif 543# endif
@@ -489,12 +555,21 @@ _GL_WARN_ON_USE (fsync, "fsync is unportable - "
489#if @GNULIB_FTRUNCATE@ 555#if @GNULIB_FTRUNCATE@
490/* Change the size of the file to which FD is opened to become equal to LENGTH. 556/* Change the size of the file to which FD is opened to become equal to LENGTH.
491 Return 0 if successful, otherwise -1 and errno set. 557 Return 0 if successful, otherwise -1 and errno set.
492 See the POSIX:2001 specification 558 See the POSIX:2008 specification
493 <http://www.opengroup.org/susv3xsh/ftruncate.html>. */ 559 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */
494# if !@HAVE_FTRUNCATE@ 560# if @REPLACE_FTRUNCATE@
561# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
562# undef ftruncate
563# define ftruncate rpl_ftruncate
564# endif
565_GL_FUNCDECL_RPL (ftruncate, int, (int fd, off_t length));
566_GL_CXXALIAS_RPL (ftruncate, int, (int fd, off_t length));
567# else
568# if !@HAVE_FTRUNCATE@
495_GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length)); 569_GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length));
496# endif 570# endif
497_GL_CXXALIAS_SYS (ftruncate, int, (int fd, off_t length)); 571_GL_CXXALIAS_SYS (ftruncate, int, (int fd, off_t length));
572# endif
498_GL_CXXALIASWARN (ftruncate); 573_GL_CXXALIASWARN (ftruncate);
499#elif defined GNULIB_POSIXCHECK 574#elif defined GNULIB_POSIXCHECK
500# undef ftruncate 575# undef ftruncate
@@ -510,8 +585,8 @@ _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
510 of BUF. 585 of BUF.
511 Return BUF if successful, or NULL if the directory couldn't be determined 586 Return BUF if successful, or NULL if the directory couldn't be determined
512 or SIZE was too small. 587 or SIZE was too small.
513 See the POSIX:2001 specification 588 See the POSIX:2008 specification
514 <http://www.opengroup.org/susv3xsh/getcwd.html>. 589 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
515 Additionally, the gnulib module 'getcwd' guarantees the following GNU 590 Additionally, the gnulib module 'getcwd' guarantees the following GNU
516 extension: If BUF is NULL, an array is allocated with 'malloc'; the array 591 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
517 is SIZE bytes long, unless SIZE == 0, in which case it is as big as 592 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
@@ -548,13 +623,21 @@ _GL_WARN_ON_USE (getcwd, "getcwd is unportable - "
548 Null terminate it if the name is shorter than LEN. 623 Null terminate it if the name is shorter than LEN.
549 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1. 624 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
550 Return 0 if successful, otherwise set errno and return -1. */ 625 Return 0 if successful, otherwise set errno and return -1. */
551# if !@HAVE_GETDOMAINNAME@ 626# if @REPLACE_GETDOMAINNAME@
627# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
628# undef getdomainname
629# define getdomainname rpl_getdomainname
630# endif
631_GL_FUNCDECL_RPL (getdomainname, int, (char *name, size_t len)
632 _GL_ARG_NONNULL ((1)));
633_GL_CXXALIAS_RPL (getdomainname, int, (char *name, size_t len));
634# else
635# if !@HAVE_DECL_GETDOMAINNAME@
552_GL_FUNCDECL_SYS (getdomainname, int, (char *name, size_t len) 636_GL_FUNCDECL_SYS (getdomainname, int, (char *name, size_t len)
553 _GL_ARG_NONNULL ((1))); 637 _GL_ARG_NONNULL ((1)));
638# endif
639_GL_CXXALIAS_SYS (getdomainname, int, (char *name, size_t len));
554# endif 640# endif
555/* Need to cast, because on MacOS X 10.5 systems, the second parameter is
556 int len. */
557_GL_CXXALIAS_SYS_CAST (getdomainname, int, (char *name, size_t len));
558_GL_CXXALIASWARN (getdomainname); 641_GL_CXXALIASWARN (getdomainname);
559#elif defined GNULIB_POSIXCHECK 642#elif defined GNULIB_POSIXCHECK
560# undef getdomainname 643# undef getdomainname
@@ -632,7 +715,8 @@ _GL_CXXALIAS_RPL (gethostname, int, (char *name, size_t len));
632_GL_FUNCDECL_SYS (gethostname, int, (char *name, size_t len) 715_GL_FUNCDECL_SYS (gethostname, int, (char *name, size_t len)
633 _GL_ARG_NONNULL ((1))); 716 _GL_ARG_NONNULL ((1)));
634# endif 717# endif
635/* Need to cast, because on Solaris 10 systems, the second parameter is 718/* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second
719 parameter is
636 int len. */ 720 int len. */
637_GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len)); 721_GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len));
638# endif 722# endif
@@ -689,13 +773,22 @@ _GL_WARN_ON_USE (getlogin, "getlogin is unportable - "
689 ${LOGNAME-$USER} on Unix platforms, 773 ${LOGNAME-$USER} on Unix platforms,
690 $USERNAME on native Windows platforms. 774 $USERNAME on native Windows platforms.
691 */ 775 */
692# if !@HAVE_DECL_GETLOGIN_R@ 776# if @REPLACE_GETLOGIN_R@
777# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
778# define getlogin_r rpl_getlogin_r
779# endif
780_GL_FUNCDECL_RPL (getlogin_r, int, (char *name, size_t size)
781 _GL_ARG_NONNULL ((1)));
782_GL_CXXALIAS_RPL (getlogin_r, int, (char *name, size_t size));
783# else
784# if !@HAVE_DECL_GETLOGIN_R@
693_GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size) 785_GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size)
694 _GL_ARG_NONNULL ((1))); 786 _GL_ARG_NONNULL ((1)));
695# endif 787# endif
696/* Need to cast, because on Solaris 10 systems, the second argument is 788/* Need to cast, because on Solaris 10 systems, the second argument is
697 int size. */ 789 int size. */
698_GL_CXXALIAS_SYS_CAST (getlogin_r, int, (char *name, size_t size)); 790_GL_CXXALIAS_SYS_CAST (getlogin_r, int, (char *name, size_t size));
791# endif
699_GL_CXXALIASWARN (getlogin_r); 792_GL_CXXALIASWARN (getlogin_r);
700#elif defined GNULIB_POSIXCHECK 793#elif defined GNULIB_POSIXCHECK
701# undef getlogin_r 794# undef getlogin_r
@@ -762,11 +855,14 @@ _GL_CXXALIAS_RPL (getpagesize, int, (void));
762# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 855# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
763# define getpagesize() _gl_getpagesize () 856# define getpagesize() _gl_getpagesize ()
764# else 857# else
765static inline int 858# if !GNULIB_defined_getpagesize_function
859_GL_UNISTD_INLINE int
766getpagesize () 860getpagesize ()
767{ 861{
768 return _gl_getpagesize (); 862 return _gl_getpagesize ();
769} 863}
864# define GNULIB_defined_getpagesize_function 1
865# endif
770# endif 866# endif
771# endif 867# endif
772# endif 868# endif
@@ -833,12 +929,49 @@ _GL_WARN_ON_USE (endusershell, "endusershell is unportable - "
833#endif 929#endif
834 930
835 931
932#if @GNULIB_GROUP_MEMBER@
933/* Determine whether group id is in calling user's group list. */
934# if !@HAVE_GROUP_MEMBER@
935_GL_FUNCDECL_SYS (group_member, int, (gid_t gid));
936# endif
937_GL_CXXALIAS_SYS (group_member, int, (gid_t gid));
938_GL_CXXALIASWARN (group_member);
939#elif defined GNULIB_POSIXCHECK
940# undef group_member
941# if HAVE_RAW_DECL_GROUP_MEMBER
942_GL_WARN_ON_USE (group_member, "group_member is unportable - "
943 "use gnulib module group-member for portability");
944# endif
945#endif
946
947
948#if @GNULIB_ISATTY@
949# if @REPLACE_ISATTY@
950# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
951# undef isatty
952# define isatty rpl_isatty
953# endif
954_GL_FUNCDECL_RPL (isatty, int, (int fd));
955_GL_CXXALIAS_RPL (isatty, int, (int fd));
956# else
957_GL_CXXALIAS_SYS (isatty, int, (int fd));
958# endif
959_GL_CXXALIASWARN (isatty);
960#elif defined GNULIB_POSIXCHECK
961# undef isatty
962# if HAVE_RAW_DECL_ISATTY
963_GL_WARN_ON_USE (isatty, "isatty has portability problems on native Windows - "
964 "use gnulib module isatty for portability");
965# endif
966#endif
967
968
836#if @GNULIB_LCHOWN@ 969#if @GNULIB_LCHOWN@
837/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE 970/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
838 to GID (if GID is not -1). Do not follow symbolic links. 971 to GID (if GID is not -1). Do not follow symbolic links.
839 Return 0 if successful, otherwise -1 and errno set. 972 Return 0 if successful, otherwise -1 and errno set.
840 See the POSIX:2001 specification 973 See the POSIX:2008 specification
841 <http://www.opengroup.org/susv3xsh/lchown.html>. */ 974 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
842# if @REPLACE_LCHOWN@ 975# if @REPLACE_LCHOWN@
843# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 976# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
844# undef lchown 977# undef lchown
@@ -867,8 +1000,8 @@ _GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - "
867#if @GNULIB_LINK@ 1000#if @GNULIB_LINK@
868/* Create a new hard link for an existing file. 1001/* Create a new hard link for an existing file.
869 Return 0 if successful, otherwise -1 and errno set. 1002 Return 0 if successful, otherwise -1 and errno set.
870 See POSIX:2001 specification 1003 See POSIX:2008 specification
871 <http://www.opengroup.org/susv3xsh/link.html>. */ 1004 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
872# if @REPLACE_LINK@ 1005# if @REPLACE_LINK@
873# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1006# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
874# define link rpl_link 1007# define link rpl_link
@@ -933,8 +1066,8 @@ _GL_WARN_ON_USE (linkat, "linkat is unportable - "
933#if @GNULIB_LSEEK@ 1066#if @GNULIB_LSEEK@
934/* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END. 1067/* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
935 Return the new offset if successful, otherwise -1 and errno set. 1068 Return the new offset if successful, otherwise -1 and errno set.
936 See the POSIX:2001 specification 1069 See the POSIX:2008 specification
937 <http://www.opengroup.org/susv3xsh/lseek.html>. */ 1070 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
938# if @REPLACE_LSEEK@ 1071# if @REPLACE_LSEEK@
939# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1072# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
940# define lseek rpl_lseek 1073# define lseek rpl_lseek
@@ -954,6 +1087,24 @@ _GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some "
954#endif 1087#endif
955 1088
956 1089
1090#if @GNULIB_PIPE@
1091/* Create a pipe, defaulting to O_BINARY mode.
1092 Store the read-end as fd[0] and the write-end as fd[1].
1093 Return 0 upon success, or -1 with errno set upon failure. */
1094# if !@HAVE_PIPE@
1095_GL_FUNCDECL_SYS (pipe, int, (int fd[2]) _GL_ARG_NONNULL ((1)));
1096# endif
1097_GL_CXXALIAS_SYS (pipe, int, (int fd[2]));
1098_GL_CXXALIASWARN (pipe);
1099#elif defined GNULIB_POSIXCHECK
1100# undef pipe
1101# if HAVE_RAW_DECL_PIPE
1102_GL_WARN_ON_USE (pipe, "pipe is unportable - "
1103 "use gnulib module pipe-posix for portability");
1104# endif
1105#endif
1106
1107
957#if @GNULIB_PIPE2@ 1108#if @GNULIB_PIPE2@
958/* Create a pipe, applying the given flags when opening the read-end of the 1109/* Create a pipe, applying the given flags when opening the read-end of the
959 pipe and the write-end of the pipe. 1110 pipe and the write-end of the pipe.
@@ -986,10 +1137,12 @@ _GL_WARN_ON_USE (pipe2, "pipe2 is unportable - "
986#if @GNULIB_PREAD@ 1137#if @GNULIB_PREAD@
987/* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET. 1138/* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
988 Return the number of bytes placed into BUF if successful, otherwise 1139 Return the number of bytes placed into BUF if successful, otherwise
989 set errno and return -1. 0 indicates EOF. See the POSIX:2001 1140 set errno and return -1. 0 indicates EOF.
990 specification <http://www.opengroup.org/susv3xsh/pread.html>. */ 1141 See the POSIX:2008 specification
1142 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */
991# if @REPLACE_PREAD@ 1143# if @REPLACE_PREAD@
992# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1144# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1145# undef pread
993# define pread rpl_pread 1146# define pread rpl_pread
994# endif 1147# endif
995_GL_FUNCDECL_RPL (pread, ssize_t, 1148_GL_FUNCDECL_RPL (pread, ssize_t,
@@ -1020,10 +1173,11 @@ _GL_WARN_ON_USE (pread, "pread is unportable - "
1020/* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET. 1173/* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1021 Return the number of bytes written if successful, otherwise 1174 Return the number of bytes written if successful, otherwise
1022 set errno and return -1. 0 indicates nothing written. See the 1175 set errno and return -1. 0 indicates nothing written. See the
1023 POSIX:2001 specification 1176 POSIX:2008 specification
1024 <http://www.opengroup.org/susv3xsh/pwrite.html>. */ 1177 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
1025# if @REPLACE_PWRITE@ 1178# if @REPLACE_PWRITE@
1026# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1179# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1180# undef pwrite
1027# define pwrite rpl_pwrite 1181# define pwrite rpl_pwrite
1028# endif 1182# endif
1029_GL_FUNCDECL_RPL (pwrite, ssize_t, 1183_GL_FUNCDECL_RPL (pwrite, ssize_t,
@@ -1050,12 +1204,34 @@ _GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
1050#endif 1204#endif
1051 1205
1052 1206
1207#if @GNULIB_READ@
1208/* Read up to COUNT bytes from file descriptor FD into the buffer starting
1209 at BUF. See the POSIX:2008 specification
1210 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
1211# if @REPLACE_READ@
1212# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1213# undef read
1214# define read rpl_read
1215# endif
1216_GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count)
1217 _GL_ARG_NONNULL ((2)));
1218_GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count));
1219# else
1220/* Need to cast, because on mingw, the third parameter is
1221 unsigned int count
1222 and the return type is 'int'. */
1223_GL_CXXALIAS_SYS_CAST (read, ssize_t, (int fd, void *buf, size_t count));
1224# endif
1225_GL_CXXALIASWARN (read);
1226#endif
1227
1228
1053#if @GNULIB_READLINK@ 1229#if @GNULIB_READLINK@
1054/* Read the contents of the symbolic link FILE and place the first BUFSIZE 1230/* Read the contents of the symbolic link FILE and place the first BUFSIZE
1055 bytes of it into BUF. Return the number of bytes placed into BUF if 1231 bytes of it into BUF. Return the number of bytes placed into BUF if
1056 successful, otherwise -1 and errno set. 1232 successful, otherwise -1 and errno set.
1057 See the POSIX:2001 specification 1233 See the POSIX:2008 specification
1058 <http://www.opengroup.org/susv3xsh/readlink.html>. */ 1234 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
1059# if @REPLACE_READLINK@ 1235# if @REPLACE_READLINK@
1060# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1236# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1061# define readlink rpl_readlink 1237# define readlink rpl_readlink
@@ -1097,7 +1273,7 @@ _GL_CXXALIASWARN (readlinkat);
1097# undef readlinkat 1273# undef readlinkat
1098# if HAVE_RAW_DECL_READLINKAT 1274# if HAVE_RAW_DECL_READLINKAT
1099_GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - " 1275_GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - "
1100 "use gnulib module symlinkat for portability"); 1276 "use gnulib module readlinkat for portability");
1101# endif 1277# endif
1102#endif 1278#endif
1103 1279
@@ -1123,11 +1299,38 @@ _GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
1123#endif 1299#endif
1124 1300
1125 1301
1302#if @GNULIB_SETHOSTNAME@
1303/* Set the host name of the machine.
1304 The host name may or may not be fully qualified.
1305
1306 Put LEN bytes of NAME into the host name.
1307 Return 0 if successful, otherwise, set errno and return -1.
1308
1309 Platforms with no ability to set the hostname return -1 and set
1310 errno = ENOSYS. */
1311# if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@
1312_GL_FUNCDECL_SYS (sethostname, int, (const char *name, size_t len)
1313 _GL_ARG_NONNULL ((1)));
1314# endif
1315/* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5
1316 and FreeBSD 6.4 the second parameter is int. On Solaris 11
1317 2011-10, the first parameter is not const. */
1318_GL_CXXALIAS_SYS_CAST (sethostname, int, (const char *name, size_t len));
1319_GL_CXXALIASWARN (sethostname);
1320#elif defined GNULIB_POSIXCHECK
1321# undef sethostname
1322# if HAVE_RAW_DECL_SETHOSTNAME
1323_GL_WARN_ON_USE (sethostname, "sethostname is unportable - "
1324 "use gnulib module sethostname for portability");
1325# endif
1326#endif
1327
1328
1126#if @GNULIB_SLEEP@ 1329#if @GNULIB_SLEEP@
1127/* Pause the execution of the current thread for N seconds. 1330/* Pause the execution of the current thread for N seconds.
1128 Returns the number of seconds left to sleep. 1331 Returns the number of seconds left to sleep.
1129 See the POSIX:2001 specification 1332 See the POSIX:2008 specification
1130 <http://www.opengroup.org/susv3xsh/sleep.html>. */ 1333 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
1131# if @REPLACE_SLEEP@ 1334# if @REPLACE_SLEEP@
1132# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1335# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1133# undef sleep 1336# undef sleep
@@ -1208,7 +1411,7 @@ _GL_FUNCDECL_RPL (ttyname_r, int,
1208_GL_CXXALIAS_RPL (ttyname_r, int, 1411_GL_CXXALIAS_RPL (ttyname_r, int,
1209 (int fd, char *buf, size_t buflen)); 1412 (int fd, char *buf, size_t buflen));
1210# else 1413# else
1211# if !@HAVE_TTYNAME_R@ 1414# if !@HAVE_DECL_TTYNAME_R@
1212_GL_FUNCDECL_SYS (ttyname_r, int, 1415_GL_FUNCDECL_SYS (ttyname_r, int,
1213 (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2))); 1416 (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
1214# endif 1417# endif
@@ -1276,7 +1479,7 @@ _GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
1276/* Pause the execution of the current thread for N microseconds. 1479/* Pause the execution of the current thread for N microseconds.
1277 Returns 0 on completion, or -1 on range error. 1480 Returns 0 on completion, or -1 on range error.
1278 See the POSIX:2001 specification 1481 See the POSIX:2001 specification
1279 <http://www.opengroup.org/susv3xsh/sleep.html>. */ 1482 <http://www.opengroup.org/susv3xsh/usleep.html>. */
1280# if @REPLACE_USLEEP@ 1483# if @REPLACE_USLEEP@
1281# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1484# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1282# undef usleep 1485# undef usleep
@@ -1302,9 +1505,9 @@ _GL_WARN_ON_USE (usleep, "usleep is unportable - "
1302 1505
1303#if @GNULIB_WRITE@ 1506#if @GNULIB_WRITE@
1304/* Write up to COUNT bytes starting at BUF to file descriptor FD. 1507/* Write up to COUNT bytes starting at BUF to file descriptor FD.
1305 See the POSIX:2001 specification 1508 See the POSIX:2008 specification
1306 <http://www.opengroup.org/susv3xsh/write.html>. */ 1509 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
1307# if @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@ 1510# if @REPLACE_WRITE@
1308# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 1511# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1309# undef write 1512# undef write
1310# define write rpl_write 1513# define write rpl_write
@@ -1321,6 +1524,7 @@ _GL_CXXALIAS_SYS_CAST (write, ssize_t, (int fd, const void *buf, size_t count));
1321_GL_CXXALIASWARN (write); 1524_GL_CXXALIASWARN (write);
1322#endif 1525#endif
1323 1526
1527_GL_INLINE_HEADER_END
1324 1528
1325#endif /* _GL_UNISTD_H */ 1529#endif /* _@GUARD_PREFIX@_UNISTD_H */
1326#endif /* _GL_UNISTD_H */ 1530#endif /* _@GUARD_PREFIX@_UNISTD_H */
diff --git a/gl/unsetenv.c b/gl/unsetenv.c
index 65a19cc..c58c82f 100644
--- a/gl/unsetenv.c
+++ b/gl/unsetenv.c
@@ -1,4 +1,4 @@
1/* Copyright (C) 1992, 1995-2002, 2005-2010 Free Software Foundation, Inc. 1/* Copyright (C) 1992, 1995-2002, 2005-2013 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 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
@@ -14,12 +14,12 @@
14 You should have received a copy of the GNU General Public License 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/>. */ 15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
16 16
17#include <config.h>
18
19/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc 17/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc
20 optimizes away the name == NULL test below. */ 18 optimizes away the name == NULL test below. */
21#define _GL_ARG_NONNULL(params) 19#define _GL_ARG_NONNULL(params)
22 20
21#include <config.h>
22
23/* Specification. */ 23/* Specification. */
24#include <stdlib.h> 24#include <stdlib.h>
25 25
@@ -36,7 +36,7 @@
36#endif 36#endif
37 37
38#if _LIBC 38#if _LIBC
39/* This lock protects against simultaneous modifications of `environ'. */ 39/* This lock protects against simultaneous modifications of 'environ'. */
40# include <bits/libc-lock.h> 40# include <bits/libc-lock.h>
41__libc_lock_define_initialized (static, envlock) 41__libc_lock_define_initialized (static, envlock)
42# define LOCK __libc_lock_lock (envlock) 42# define LOCK __libc_lock_lock (envlock)
@@ -97,6 +97,13 @@ weak_alias (__unsetenv, unsetenv)
97#else /* HAVE_UNSETENV */ 97#else /* HAVE_UNSETENV */
98 98
99# undef unsetenv 99# undef unsetenv
100# if !HAVE_DECL_UNSETENV
101# if VOID_UNSETENV
102extern void unsetenv (const char *);
103# else
104extern int unsetenv (const char *);
105# endif
106# endif
100 107
101/* Call the underlying unsetenv, in case there is hidden bookkeeping 108/* Call the underlying unsetenv, in case there is hidden bookkeeping
102 that needs updating beyond just modifying environ. */ 109 that needs updating beyond just modifying environ. */
diff --git a/gl/vasnprintf.c b/gl/vasnprintf.c
index e618901..5267b1b 100644
--- a/gl/vasnprintf.c
+++ b/gl/vasnprintf.c
@@ -1,5 +1,5 @@
1/* vsprintf with automatic memory allocation. 1/* vsprintf with automatic memory allocation.
2 Copyright (C) 1999, 2002-2010 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2002-2013 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
@@ -12,8 +12,7 @@
12 GNU General Public License for more details. 12 GNU General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License along 14 You should have received a copy of the GNU General Public License along
15 with this program; if not, write to the Free Software Foundation, 15 with this program; if not, see <http://www.gnu.org/licenses/>. */
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
17 16
18/* This file can be parametrized with the following macros: 17/* This file can be parametrized with the following macros:
19 VASNPRINTF The name of the function being defined. 18 VASNPRINTF The name of the function being defined.
@@ -88,6 +87,8 @@
88/* Checked size_t computations. */ 87/* Checked size_t computations. */
89#include "xsize.h" 88#include "xsize.h"
90 89
90#include "verify.h"
91
91#if (NEED_PRINTF_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL 92#if (NEED_PRINTF_DOUBLE || NEED_PRINTF_LONG_DOUBLE) && !defined IN_LIBINTL
92# include <math.h> 93# include <math.h>
93# include "float+.h" 94# include "float+.h"
@@ -274,10 +275,10 @@ decimal_point_char (void)
274{ 275{
275 const char *point; 276 const char *point;
276 /* Determine it in a multithread-safe way. We know nl_langinfo is 277 /* Determine it in a multithread-safe way. We know nl_langinfo is
277 multithread-safe on glibc systems and MacOS X systems, but is not required 278 multithread-safe on glibc systems and Mac OS X systems, but is not required
278 to be multithread-safe by POSIX. sprintf(), however, is multithread-safe. 279 to be multithread-safe by POSIX. sprintf(), however, is multithread-safe.
279 localeconv() is rarely multithread-safe. */ 280 localeconv() is rarely multithread-safe. */
280# if HAVE_NL_LANGINFO && (__GLIBC__ || (defined __APPLE__ && defined __MACH__)) 281# if HAVE_NL_LANGINFO && (__GLIBC__ || defined __UCLIBC__ || (defined __APPLE__ && defined __MACH__))
281 point = nl_langinfo (RADIXCHAR); 282 point = nl_langinfo (RADIXCHAR);
282# elif 1 283# elif 1
283 char pointbuf[5]; 284 char pointbuf[5];
@@ -322,11 +323,11 @@ is_infinite_or_zerol (long double x)
322 323
323typedef unsigned int mp_limb_t; 324typedef unsigned int mp_limb_t;
324# define GMP_LIMB_BITS 32 325# define GMP_LIMB_BITS 32
325typedef int mp_limb_verify[2 * (sizeof (mp_limb_t) * CHAR_BIT == GMP_LIMB_BITS) - 1]; 326verify (sizeof (mp_limb_t) * CHAR_BIT == GMP_LIMB_BITS);
326 327
327typedef unsigned long long mp_twolimb_t; 328typedef unsigned long long mp_twolimb_t;
328# define GMP_TWOLIMB_BITS 64 329# define GMP_TWOLIMB_BITS 64
329typedef int mp_twolimb_verify[2 * (sizeof (mp_twolimb_t) * CHAR_BIT == GMP_TWOLIMB_BITS) - 1]; 330verify (sizeof (mp_twolimb_t) * CHAR_BIT == GMP_TWOLIMB_BITS);
330 331
331/* Representation of a bignum >= 0. */ 332/* Representation of a bignum >= 0. */
332typedef struct 333typedef struct
@@ -551,32 +552,61 @@ divide (mpn_t a, mpn_t b, mpn_t *q)
551 size_t s; 552 size_t s;
552 { 553 {
553 mp_limb_t msd = b_ptr[b_len - 1]; /* = b[n-1], > 0 */ 554 mp_limb_t msd = b_ptr[b_len - 1]; /* = b[n-1], > 0 */
554 s = 31; 555 /* Determine s = GMP_LIMB_BITS - integer_length (msd).
555 if (msd >= 0x10000) 556 Code copied from gnulib's integer_length.c. */
556 { 557# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
557 msd = msd >> 16; 558 s = __builtin_clz (msd);
558 s -= 16; 559# else
559 } 560# if defined DBL_EXPBIT0_WORD && defined DBL_EXPBIT0_BIT
560 if (msd >= 0x100) 561 if (GMP_LIMB_BITS <= DBL_MANT_BIT)
561 {
562 msd = msd >> 8;
563 s -= 8;
564 }
565 if (msd >= 0x10)
566 {
567 msd = msd >> 4;
568 s -= 4;
569 }
570 if (msd >= 0x4)
571 { 562 {
572 msd = msd >> 2; 563 /* Use 'double' operations.
573 s -= 2; 564 Assumes an IEEE 754 'double' implementation. */
565# define DBL_EXP_MASK ((DBL_MAX_EXP - DBL_MIN_EXP) | 7)
566# define DBL_EXP_BIAS (DBL_EXP_MASK / 2 - 1)
567# define NWORDS \
568 ((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int))
569 union { double value; unsigned int word[NWORDS]; } m;
570
571 /* Use a single integer to floating-point conversion. */
572 m.value = msd;
573
574 s = GMP_LIMB_BITS
575 - (((m.word[DBL_EXPBIT0_WORD] >> DBL_EXPBIT0_BIT) & DBL_EXP_MASK)
576 - DBL_EXP_BIAS);
574 } 577 }
575 if (msd >= 0x2) 578 else
579# undef NWORDS
580# endif
576 { 581 {
577 msd = msd >> 1; 582 s = 31;
578 s -= 1; 583 if (msd >= 0x10000)
584 {
585 msd = msd >> 16;
586 s -= 16;
587 }
588 if (msd >= 0x100)
589 {
590 msd = msd >> 8;
591 s -= 8;
592 }
593 if (msd >= 0x10)
594 {
595 msd = msd >> 4;
596 s -= 4;
597 }
598 if (msd >= 0x4)
599 {
600 msd = msd >> 2;
601 s -= 2;
602 }
603 if (msd >= 0x2)
604 {
605 msd = msd >> 1;
606 s -= 1;
607 }
579 } 608 }
609# endif
580 } 610 }
581 /* 0 <= s < GMP_LIMB_BITS. 611 /* 0 <= s < GMP_LIMB_BITS.
582 Copy b, shifting it left by s bits. */ 612 Copy b, shifting it left by s bits. */
@@ -883,9 +913,9 @@ decode_long_double (long double x, int *ep, mpn_t *mp)
883 y = frexpl (x, &exp); 913 y = frexpl (x, &exp);
884 if (!(y >= 0.0L && y < 1.0L)) 914 if (!(y >= 0.0L && y < 1.0L))
885 abort (); 915 abort ();
886 /* x = 2^exp * y = 2^(exp - LDBL_MANT_BIT) * (y * LDBL_MANT_BIT), and the 916 /* x = 2^exp * y = 2^(exp - LDBL_MANT_BIT) * (y * 2^LDBL_MANT_BIT), and the
887 latter is an integer. */ 917 latter is an integer. */
888 /* Convert the mantissa (y * LDBL_MANT_BIT) to a sequence of limbs. 918 /* Convert the mantissa (y * 2^LDBL_MANT_BIT) to a sequence of limbs.
889 I'm not sure whether it's safe to cast a 'long double' value between 919 I'm not sure whether it's safe to cast a 'long double' value between
890 2^31 and 2^32 to 'unsigned int', therefore play safe and cast only 920 2^31 and 2^32 to 'unsigned int', therefore play safe and cast only
891 'long double' values between 0 and 2^16 (to 'unsigned int' or 'int', 921 'long double' values between 0 and 2^16 (to 'unsigned int' or 'int',
@@ -933,11 +963,11 @@ decode_long_double (long double x, int *ep, mpn_t *mp)
933 abort (); 963 abort ();
934 m.limbs[--i] = (hi << (GMP_LIMB_BITS / 2)) | lo; 964 m.limbs[--i] = (hi << (GMP_LIMB_BITS / 2)) | lo;
935 } 965 }
936#if 0 /* On FreeBSD 6.1/x86, 'long double' numbers sometimes have excess 966# if 0 /* On FreeBSD 6.1/x86, 'long double' numbers sometimes have excess
937 precision. */ 967 precision. */
938 if (!(y == 0.0L)) 968 if (!(y == 0.0L))
939 abort (); 969 abort ();
940#endif 970# endif
941 /* Normalise. */ 971 /* Normalise. */
942 while (m.nlimbs > 0 && m.limbs[m.nlimbs - 1] == 0) 972 while (m.nlimbs > 0 && m.limbs[m.nlimbs - 1] == 0)
943 m.nlimbs--; 973 m.nlimbs--;
@@ -971,9 +1001,9 @@ decode_double (double x, int *ep, mpn_t *mp)
971 y = frexp (x, &exp); 1001 y = frexp (x, &exp);
972 if (!(y >= 0.0 && y < 1.0)) 1002 if (!(y >= 0.0 && y < 1.0))
973 abort (); 1003 abort ();
974 /* x = 2^exp * y = 2^(exp - DBL_MANT_BIT) * (y * DBL_MANT_BIT), and the 1004 /* x = 2^exp * y = 2^(exp - DBL_MANT_BIT) * (y * 2^DBL_MANT_BIT), and the
975 latter is an integer. */ 1005 latter is an integer. */
976 /* Convert the mantissa (y * DBL_MANT_BIT) to a sequence of limbs. 1006 /* Convert the mantissa (y * 2^DBL_MANT_BIT) to a sequence of limbs.
977 I'm not sure whether it's safe to cast a 'double' value between 1007 I'm not sure whether it's safe to cast a 'double' value between
978 2^31 and 2^32 to 'unsigned int', therefore play safe and cast only 1008 2^31 and 2^32 to 'unsigned int', therefore play safe and cast only
979 'double' values between 0 and 2^16 (to 'unsigned int' or 'int', 1009 'double' values between 0 and 2^16 (to 'unsigned int' or 'int',
@@ -1500,7 +1530,7 @@ is_borderline (const char *digits, size_t precision)
1500 1530
1501/* Returns the number of TCHAR_T units needed as temporary space for the result 1531/* Returns the number of TCHAR_T units needed as temporary space for the result
1502 of sprintf or SNPRINTF of a single conversion directive. */ 1532 of sprintf or SNPRINTF of a single conversion directive. */
1503static inline size_t 1533static size_t
1504MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion, 1534MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion,
1505 arg_type type, int flags, size_t width, int has_precision, 1535 arg_type type, int flags, size_t width, int has_precision,
1506 size_t precision, int pad_ourselves) 1536 size_t precision, int pad_ourselves)
@@ -1751,8 +1781,9 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
1751 return NULL; 1781 return NULL;
1752 1782
1753#define CLEANUP() \ 1783#define CLEANUP() \
1754 free (d.dir); \ 1784 if (d.dir != d.direct_alloc_dir) \
1755 if (a.arg) \ 1785 free (d.dir); \
1786 if (a.arg != a.direct_alloc_arg) \
1756 free (a.arg); 1787 free (a.arg);
1757 1788
1758 if (PRINTF_FETCHARGS (args, &a) < 0) 1789 if (PRINTF_FETCHARGS (args, &a) < 0)
@@ -2621,7 +2652,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2621 size_t characters; 2652 size_t characters;
2622# if !DCHAR_IS_TCHAR 2653# if !DCHAR_IS_TCHAR
2623 /* This code assumes that TCHAR_T is 'char'. */ 2654 /* This code assumes that TCHAR_T is 'char'. */
2624 typedef int TCHAR_T_verify[2 * (sizeof (TCHAR_T) == 1) - 1]; 2655 verify (sizeof (TCHAR_T) == 1);
2625 TCHAR_T *tmpsrc; 2656 TCHAR_T *tmpsrc;
2626 DCHAR_T *tmpdst; 2657 DCHAR_T *tmpdst;
2627 size_t tmpdst_len; 2658 size_t tmpdst_len;
@@ -2782,7 +2813,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
2782 if (has_width) 2813 if (has_width)
2783 { 2814 {
2784# if ENABLE_UNISTDIO 2815# if ENABLE_UNISTDIO
2785 /* Outside POSIX, it's preferrable to compare the width 2816 /* Outside POSIX, it's preferable to compare the width
2786 against the number of _characters_ of the converted 2817 against the number of _characters_ of the converted
2787 value. */ 2818 value. */
2788 w = DCHAR_MBSNLEN (result + length, characters); 2819 w = DCHAR_MBSNLEN (result + length, characters);
@@ -4597,6 +4628,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4597 TCHAR_T *fbp; 4628 TCHAR_T *fbp;
4598 unsigned int prefix_count; 4629 unsigned int prefix_count;
4599 int prefixes[2] IF_LINT (= { 0 }); 4630 int prefixes[2] IF_LINT (= { 0 });
4631 int orig_errno;
4600#if !USE_SNPRINTF 4632#if !USE_SNPRINTF
4601 size_t tmp_length; 4633 size_t tmp_length;
4602 TCHAR_T tmpbuf[700]; 4634 TCHAR_T tmpbuf[700];
@@ -4751,6 +4783,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4751 *fbp++ = ' '; 4783 *fbp++ = ' ';
4752 if (flags & FLAG_ALT) 4784 if (flags & FLAG_ALT)
4753 *fbp++ = '#'; 4785 *fbp++ = '#';
4786#if __GLIBC__ >= 2 && !defined __UCLIBC__
4787 if (flags & FLAG_LOCALIZED)
4788 *fbp++ = 'I';
4789#endif
4754 if (!pad_ourselves) 4790 if (!pad_ourselves)
4755 { 4791 {
4756 if (flags & FLAG_ZERO) 4792 if (flags & FLAG_ZERO)
@@ -4834,20 +4870,21 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4834#endif 4870#endif
4835 *fbp = dp->conversion; 4871 *fbp = dp->conversion;
4836#if USE_SNPRINTF 4872#if USE_SNPRINTF
4837# if !(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)) 4873# if !(((__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined __UCLIBC__) || ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
4838 fbp[1] = '%'; 4874 fbp[1] = '%';
4839 fbp[2] = 'n'; 4875 fbp[2] = 'n';
4840 fbp[3] = '\0'; 4876 fbp[3] = '\0';
4841# else 4877# else
4842 /* On glibc2 systems from glibc >= 2.3 - probably also older 4878 /* On glibc2 systems from glibc >= 2.3 - probably also older
4843 ones - we know that snprintf's returns value conforms to 4879 ones - we know that snprintf's return value conforms to
4844 ISO C 99: the gl_SNPRINTF_DIRECTIVE_N test passes. 4880 ISO C 99: the tests gl_SNPRINTF_RETVAL_C99 and
4881 gl_SNPRINTF_TRUNCATION_C99 pass.
4845 Therefore we can avoid using %n in this situation. 4882 Therefore we can avoid using %n in this situation.
4846 On glibc2 systems from 2004-10-18 or newer, the use of %n 4883 On glibc2 systems from 2004-10-18 or newer, the use of %n
4847 in format strings in writable memory may crash the program 4884 in format strings in writable memory may crash the program
4848 (if compiled with _FORTIFY_SOURCE=2), so we should avoid it 4885 (if compiled with _FORTIFY_SOURCE=2), so we should avoid it
4849 in this situation. */ 4886 in this situation. */
4850 /* On native Win32 systems (such as mingw), we can avoid using 4887 /* On native Windows systems (such as mingw), we can avoid using
4851 %n because: 4888 %n because:
4852 - Although the gl_SNPRINTF_TRUNCATION_C99 test fails, 4889 - Although the gl_SNPRINTF_TRUNCATION_C99 test fails,
4853 snprintf does not write more than the specified number 4890 snprintf does not write more than the specified number
@@ -4856,7 +4893,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4856 - Although the gl_SNPRINTF_RETVAL_C99 test fails, snprintf 4893 - Although the gl_SNPRINTF_RETVAL_C99 test fails, snprintf
4857 allows us to recognize the case of an insufficient 4894 allows us to recognize the case of an insufficient
4858 buffer size: it returns -1 in this case. 4895 buffer size: it returns -1 in this case.
4859 On native Win32 systems (such as mingw) where the OS is 4896 On native Windows systems (such as mingw) where the OS is
4860 Windows Vista, the use of %n in format strings by default 4897 Windows Vista, the use of %n in format strings by default
4861 crashes the program. See 4898 crashes the program. See
4862 <http://gcc.gnu.org/ml/gcc/2007-06/msg00122.html> and 4899 <http://gcc.gnu.org/ml/gcc/2007-06/msg00122.html> and
@@ -4900,6 +4937,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
4900 *(TCHAR_T *) (result + length) = '\0'; 4937 *(TCHAR_T *) (result + length) = '\0';
4901#endif 4938#endif
4902 4939
4940 orig_errno = errno;
4941
4903 for (;;) 4942 for (;;)
4904 { 4943 {
4905 int count = -1; 4944 int count = -1;
@@ -5114,7 +5153,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5114 size_t tmp_length = 5153 size_t tmp_length =
5115 MAX_ROOM_NEEDED (&a, dp->arg_index, 5154 MAX_ROOM_NEEDED (&a, dp->arg_index,
5116 dp->conversion, type, flags, 5155 dp->conversion, type, flags,
5117 width, has_precision, 5156 has_width ? width : 0,
5157 has_precision,
5118 precision, pad_ourselves); 5158 precision, pad_ourselves);
5119 5159
5120 if (maxlen < tmp_length) 5160 if (maxlen < tmp_length)
@@ -5284,8 +5324,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5284 DCHAR_T *tmpdst; 5324 DCHAR_T *tmpdst;
5285 size_t tmpdst_len; 5325 size_t tmpdst_len;
5286 /* This code assumes that TCHAR_T is 'char'. */ 5326 /* This code assumes that TCHAR_T is 'char'. */
5287 typedef int TCHAR_T_verify 5327 verify (sizeof (TCHAR_T) == 1);
5288 [2 * (sizeof (TCHAR_T) == 1) - 1];
5289# if USE_SNPRINTF 5328# if USE_SNPRINTF
5290 tmpsrc = (TCHAR_T *) (result + length); 5329 tmpsrc = (TCHAR_T *) (result + length);
5291# else 5330# else
@@ -5378,7 +5417,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5378 { 5417 {
5379 size_t w; 5418 size_t w;
5380# if ENABLE_UNISTDIO 5419# if ENABLE_UNISTDIO
5381 /* Outside POSIX, it's preferrable to compare the width 5420 /* Outside POSIX, it's preferable to compare the width
5382 against the number of _characters_ of the converted 5421 against the number of _characters_ of the converted
5383 value. */ 5422 value. */
5384 w = DCHAR_MBSNLEN (result + length, count); 5423 w = DCHAR_MBSNLEN (result + length, count);
@@ -5498,6 +5537,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
5498 length += count; 5537 length += count;
5499 break; 5538 break;
5500 } 5539 }
5540 errno = orig_errno;
5501#undef pad_ourselves 5541#undef pad_ourselves
5502#undef prec_ourselves 5542#undef prec_ourselves
5503 } 5543 }
diff --git a/gl/vasnprintf.h b/gl/vasnprintf.h
index a689bad..7658f50 100644
--- a/gl/vasnprintf.h
+++ b/gl/vasnprintf.h
@@ -1,5 +1,5 @@
1/* vsprintf with automatic memory allocation. 1/* vsprintf with automatic memory allocation.
2 Copyright (C) 2002-2004, 2007-2010 Free Software Foundation, Inc. 2 Copyright (C) 2002-2004, 2007-2013 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
@@ -12,8 +12,7 @@
12 GNU General Public License for more details. 12 GNU General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License along 14 You should have received a copy of the GNU General Public License along
15 with this program; if not, write to the Free Software Foundation, 15 with this program; if not, see <http://www.gnu.org/licenses/>. */
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
17 16
18#ifndef _VASNPRINTF_H 17#ifndef _VASNPRINTF_H
19#define _VASNPRINTF_H 18#define _VASNPRINTF_H
@@ -24,16 +23,16 @@
24/* Get size_t. */ 23/* Get size_t. */
25#include <stddef.h> 24#include <stddef.h>
26 25
27#ifndef __attribute__
28/* The __attribute__ feature is available in gcc versions 2.5 and later. 26/* The __attribute__ feature is available in gcc versions 2.5 and later.
29 The __-protected variants of the attributes 'format' and 'printf' are 27 The __-protected variants of the attributes 'format' and 'printf' are
30 accepted by gcc versions 2.6.4 (effectively 2.7) and later. 28 accepted by gcc versions 2.6.4 (effectively 2.7) and later.
31 We enable __attribute__ only if these are supported too, because 29 We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because
32 gnulib and libintl do '#define printf __printf__' when they override 30 gnulib and libintl do '#define printf __printf__' when they override
33 the 'printf' function. */ 31 the 'printf' function. */
34# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) 32#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
35# define __attribute__(Spec) /* empty */ 33# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
36# endif 34#else
35# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
37#endif 36#endif
38 37
39#ifdef __cplusplus 38#ifdef __cplusplus
@@ -69,9 +68,9 @@ extern "C" {
69# define vasnprintf rpl_vasnprintf 68# define vasnprintf rpl_vasnprintf
70#endif 69#endif
71extern char * asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...) 70extern char * asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...)
72 __attribute__ ((__format__ (__printf__, 3, 4))); 71 _GL_ATTRIBUTE_FORMAT ((__printf__, 3, 4));
73extern char * vasnprintf (char *resultbuf, size_t *lengthp, const char *format, va_list args) 72extern char * vasnprintf (char *resultbuf, size_t *lengthp, const char *format, va_list args)
74 __attribute__ ((__format__ (__printf__, 3, 0))); 73 _GL_ATTRIBUTE_FORMAT ((__printf__, 3, 0));
75 74
76#ifdef __cplusplus 75#ifdef __cplusplus
77} 76}
diff --git a/gl/vasprintf.c b/gl/vasprintf.c
index 46486f3..d0d4a11 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-2010 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2002, 2006-2013 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
@@ -12,8 +12,7 @@
12 GNU General Public License for more details. 12 GNU General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License along 14 You should have received a copy of the GNU General Public License along
15 with this program; if not, write to the Free Software Foundation, 15 with this program; if not, see <http://www.gnu.org/licenses/>. */
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
17 16
18#include <config.h> 17#include <config.h>
19 18
diff --git a/gl/verify.h b/gl/verify.h
index 4ad780c..d42d075 100644
--- a/gl/verify.h
+++ b/gl/verify.h
@@ -1,6 +1,6 @@
1/* Compile-time assert-like macros. 1/* Compile-time assert-like macros.
2 2
3 Copyright (C) 2005-2006, 2009-2010 Free Software Foundation, Inc. 3 Copyright (C) 2005-2006, 2009-2013 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,21 +17,49 @@
17 17
18/* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */ 18/* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */
19 19
20#ifndef VERIFY_H 20#ifndef _GL_VERIFY_H
21# define VERIFY_H 1 21#define _GL_VERIFY_H
22
23
24/* Define _GL_HAVE__STATIC_ASSERT to 1 if _Static_assert works as per C11.
25 This is supported by GCC 4.6.0 and later, in C mode, and its use
26 here generates easier-to-read diagnostics when verify (R) fails.
27
28 Define _GL_HAVE_STATIC_ASSERT to 1 if static_assert works as per C++11.
29 This will likely be supported by future GCC versions, in C++ mode.
30
31 Use this only with GCC. If we were willing to slow 'configure'
32 down we could also use it with other compilers, but since this
33 affects only the quality of diagnostics, why bother? */
34#if (4 < __GNUC__ + (6 <= __GNUC_MINOR__) \
35 && (201112L <= __STDC_VERSION__ || !defined __STRICT_ANSI__) \
36 && !defined __cplusplus)
37# define _GL_HAVE__STATIC_ASSERT 1
38#endif
39/* The condition (99 < __GNUC__) is temporary, until we know about the
40 first G++ release that supports static_assert. */
41#if (99 < __GNUC__) && defined __cplusplus
42# define _GL_HAVE_STATIC_ASSERT 1
43#endif
44
45/* FreeBSD 9.1 <sys/cdefs.h>, included by <stddef.h> and lots of other
46 system headers, defines a conflicting _Static_assert that is no
47 better than ours; override it. */
48#ifndef _GL_HAVE_STATIC_ASSERT
49# include <stddef.h>
50# undef _Static_assert
51#endif
22 52
23/* Each of these macros verifies that its argument R is nonzero. To 53/* Each of these macros verifies that its argument R is nonzero. To
24 be portable, R should be an integer constant expression. Unlike 54 be portable, R should be an integer constant expression. Unlike
25 assert (R), there is no run-time overhead. 55 assert (R), there is no run-time overhead.
26 56
27 There are two macros, since no single macro can be used in all 57 If _Static_assert works, verify (R) uses it directly. Similarly,
28 contexts in C. verify_true (R) is for scalar contexts, including 58 _GL_VERIFY_TRUE works by packaging a _Static_assert inside a struct
29 integer constant expression contexts. verify (R) is for declaration 59 that is an operand of sizeof.
30 contexts, e.g., the top level.
31
32 Symbols ending in "__" are private to this header.
33 60
34 The code below uses several ideas. 61 The code below uses several ideas for C++ compilers, and for C
62 compilers that do not support _Static_assert:
35 63
36 * The first step is ((R) ? 1 : -1). Given an expression R, of 64 * The first step is ((R) ? 1 : -1). Given an expression R, of
37 integral or boolean or floating-point type, this yields an 65 integral or boolean or floating-point type, this yields an
@@ -39,7 +67,9 @@
39 constant and nonnegative. 67 constant and nonnegative.
40 68
41 * Next this expression W is wrapped in a type 69 * Next this expression W is wrapped in a type
42 struct verify_type__ { unsigned int verify_error_if_negative_size__: W; }. 70 struct _gl_verify_type {
71 unsigned int _gl_verify_error_if_negative: W;
72 }.
43 If W is negative, this yields a compile-time error. No compiler can 73 If W is negative, this yields a compile-time error. No compiler can
44 deal with a bit-field of negative size. 74 deal with a bit-field of negative size.
45 75
@@ -53,7 +83,7 @@
53 83
54 void function (int n) { verify (n < 0); } 84 void function (int n) { verify (n < 0); }
55 85
56 * For the verify macro, the struct verify_type__ will need to 86 * For the verify macro, the struct _gl_verify_type will need to
57 somehow be embedded into a declaration. To be portable, this 87 somehow be embedded into a declaration. To be portable, this
58 declaration must declare an object, a constant, a function, or a 88 declaration must declare an object, a constant, a function, or a
59 typedef name. If the declared entity uses the type directly, 89 typedef name. If the declared entity uses the type directly,
@@ -91,11 +121,11 @@
91 Which of the following alternatives can be used? 121 Which of the following alternatives can be used?
92 122
93 extern int dummy [sizeof (struct {...})]; 123 extern int dummy [sizeof (struct {...})];
94 extern int dummy [sizeof (struct verify_type__ {...})]; 124 extern int dummy [sizeof (struct _gl_verify_type {...})];
95 extern void dummy (int [sizeof (struct {...})]); 125 extern void dummy (int [sizeof (struct {...})]);
96 extern void dummy (int [sizeof (struct verify_type__ {...})]); 126 extern void dummy (int [sizeof (struct _gl_verify_type {...})]);
97 extern int (*dummy (void)) [sizeof (struct {...})]; 127 extern int (*dummy (void)) [sizeof (struct {...})];
98 extern int (*dummy (void)) [sizeof (struct verify_type__ {...})]; 128 extern int (*dummy (void)) [sizeof (struct _gl_verify_type {...})];
99 129
100 In the second and sixth case, the struct type is exported to the 130 In the second and sixth case, the struct type is exported to the
101 outer scope; two such declarations therefore collide. GCC warns 131 outer scope; two such declarations therefore collide. GCC warns
@@ -105,59 +135,121 @@
105 extern int (*dummy (void)) [sizeof (struct {...})]; 135 extern int (*dummy (void)) [sizeof (struct {...})];
106 136
107 * GCC warns about duplicate declarations of the dummy function if 137 * GCC warns about duplicate declarations of the dummy function if
108 -Wredundant_decls is used. GCC 4.3 and later have a builtin 138 -Wredundant-decls is used. GCC 4.3 and later have a builtin
109 __COUNTER__ macro that can let us generate unique identifiers for 139 __COUNTER__ macro that can let us generate unique identifiers for
110 each dummy function, to suppress this warning. 140 each dummy function, to suppress this warning.
111 141
112 * This implementation exploits the fact that GCC does not warn about 142 * This implementation exploits the fact that older versions of GCC,
113 the last declaration mentioned above. If a future version of GCC 143 which do not support _Static_assert, also do not warn about the
114 introduces a warning for this, the problem could be worked around 144 last declaration mentioned above.
115 by using code specialized to GCC, just as __COUNTER__ is already
116 being used if available.
117 145
118 #if 4 <= __GNUC__ 146 * GCC warns if -Wnested-externs is enabled and verify() is used
119 # define verify(R) [another version to keep GCC happy] 147 within a function body; but inside a function, you can always
120 #endif 148 arrange to use verify_expr() instead.
121 149
122 * In C++, any struct definition inside sizeof is invalid. 150 * In C++, any struct definition inside sizeof is invalid.
123 Use a template type to work around the problem. */ 151 Use a template type to work around the problem. */
124 152
125/* Concatenate two preprocessor tokens. */ 153/* Concatenate two preprocessor tokens. */
126# define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y) 154#define _GL_CONCAT(x, y) _GL_CONCAT0 (x, y)
127# define _GL_CONCAT0(x, y) x##y 155#define _GL_CONCAT0(x, y) x##y
128 156
129/* _GL_COUNTER is an integer, preferably one that changes each time we 157/* _GL_COUNTER is an integer, preferably one that changes each time we
130 use it. Use __COUNTER__ if it works, falling back on __LINE__ 158 use it. Use __COUNTER__ if it works, falling back on __LINE__
131 otherwise. __LINE__ isn't perfect, but it's better than a 159 otherwise. __LINE__ isn't perfect, but it's better than a
132 constant. */ 160 constant. */
133# if defined __COUNTER__ && __COUNTER__ != __COUNTER__ 161#if defined __COUNTER__ && __COUNTER__ != __COUNTER__
134# define _GL_COUNTER __COUNTER__ 162# define _GL_COUNTER __COUNTER__
135# else 163#else
136# define _GL_COUNTER __LINE__ 164# define _GL_COUNTER __LINE__
137# endif 165#endif
138 166
139/* Generate a symbol with the given prefix, making it unique if 167/* Generate a symbol with the given prefix, making it unique if
140 possible. */ 168 possible. */
141# define _GL_GENSYM(prefix) _GL_CONCAT (prefix, _GL_COUNTER) 169#define _GL_GENSYM(prefix) _GL_CONCAT (prefix, _GL_COUNTER)
142 170
143/* Verify requirement R at compile-time, as an integer constant expression. 171/* Verify requirement R at compile-time, as an integer constant expression
144 Return 1. */ 172 that returns 1. If R is false, fail at compile-time, preferably
173 with a diagnostic that includes the string-literal DIAGNOSTIC. */
145 174
146# ifdef __cplusplus 175#define _GL_VERIFY_TRUE(R, DIAGNOSTIC) \
176 (!!sizeof (_GL_VERIFY_TYPE (R, DIAGNOSTIC)))
177
178#ifdef __cplusplus
179# if !GNULIB_defined_struct__gl_verify_type
147template <int w> 180template <int w>
148 struct verify_type__ { unsigned int verify_error_if_negative_size__: w; }; 181 struct _gl_verify_type {
149# define verify_true(R) \ 182 unsigned int _gl_verify_error_if_negative: w;
150 (!!sizeof (verify_type__<(R) ? 1 : -1>)) 183 };
151# else 184# define GNULIB_defined_struct__gl_verify_type 1
152# define verify_true(R) \ 185# endif
153 (!!sizeof \ 186# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
154 (struct { unsigned int verify_error_if_negative_size__: (R) ? 1 : -1; })) 187 _gl_verify_type<(R) ? 1 : -1>
188#elif defined _GL_HAVE__STATIC_ASSERT
189# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
190 struct { \
191 _Static_assert (R, DIAGNOSTIC); \
192 int _gl_dummy; \
193 }
194#else
195# define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
196 struct { unsigned int _gl_verify_error_if_negative: (R) ? 1 : -1; }
197#endif
198
199/* Verify requirement R at compile-time, as a declaration without a
200 trailing ';'. If R is false, fail at compile-time, preferably
201 with a diagnostic that includes the string-literal DIAGNOSTIC.
202
203 Unfortunately, unlike C11, this implementation must appear as an
204 ordinary declaration, and cannot appear inside struct { ... }. */
205
206#ifdef _GL_HAVE__STATIC_ASSERT
207# define _GL_VERIFY _Static_assert
208#else
209# define _GL_VERIFY(R, DIAGNOSTIC) \
210 extern int (*_GL_GENSYM (_gl_verify_function) (void)) \
211 [_GL_VERIFY_TRUE (R, DIAGNOSTIC)]
212#endif
213
214/* _GL_STATIC_ASSERT_H is defined if this code is copied into assert.h. */
215#ifdef _GL_STATIC_ASSERT_H
216# if !defined _GL_HAVE__STATIC_ASSERT && !defined _Static_assert
217# define _Static_assert(R, DIAGNOSTIC) _GL_VERIFY (R, DIAGNOSTIC)
218# endif
219# if !defined _GL_HAVE_STATIC_ASSERT && !defined static_assert
220# define static_assert _Static_assert /* C11 requires this #define. */
155# endif 221# endif
222#endif
223
224/* @assert.h omit start@ */
225
226/* Each of these macros verifies that its argument R is nonzero. To
227 be portable, R should be an integer constant expression. Unlike
228 assert (R), there is no run-time overhead.
229
230 There are two macros, since no single macro can be used in all
231 contexts in C. verify_true (R) is for scalar contexts, including
232 integer constant expression contexts. verify (R) is for declaration
233 contexts, e.g., the top level. */
234
235/* Verify requirement R at compile-time, as an integer constant expression.
236 Return 1. This is equivalent to verify_expr (R, 1).
237
238 verify_true is obsolescent; please use verify_expr instead. */
239
240#define verify_true(R) _GL_VERIFY_TRUE (R, "verify_true (" #R ")")
241
242/* Verify requirement R at compile-time. Return the value of the
243 expression E. */
244
245#define verify_expr(R, E) \
246 (_GL_VERIFY_TRUE (R, "verify_expr (" #R ", " #E ")") ? (E) : (E))
156 247
157/* Verify requirement R at compile-time, as a declaration without a 248/* Verify requirement R at compile-time, as a declaration without a
158 trailing ';'. */ 249 trailing ';'. */
159 250
160# define verify(R) \ 251#define verify(R) _GL_VERIFY (R, "verify (" #R ")")
161 extern int (* _GL_GENSYM (verify_function) (void)) [verify_true (R)] 252
253/* @assert.h omit end@ */
162 254
163#endif 255#endif
diff --git a/gl/vsnprintf.c b/gl/vsnprintf.c
index d447cc2..7d4dfbe 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-2010 Free Software Foundation, Inc. 2 Copyright (C) 2004, 2006-2013 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
@@ -13,8 +13,7 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License along 15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, 16 with this program; if not, see <http://www.gnu.org/licenses/>. */
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 17
19#ifdef HAVE_CONFIG_H 18#ifdef HAVE_CONFIG_H
20# include <config.h> 19# include <config.h>
diff --git a/gl/w32sock.h b/gl/w32sock.h
index b472bd0..44f3a1a 100644
--- a/gl/w32sock.h
+++ b/gl/w32sock.h
@@ -1,6 +1,6 @@
1/* w32sock.h --- internal auxilliary functions for Windows socket functions 1/* w32sock.h --- internal auxiliary functions for Windows socket functions
2 2
3 Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. 3 Copyright (C) 2008-2013 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
@@ -22,11 +22,14 @@
22/* Get O_RDWR and O_BINARY. */ 22/* Get O_RDWR and O_BINARY. */
23#include <fcntl.h> 23#include <fcntl.h>
24 24
25/* Get _get_osfhandle() and _open_osfhandle(). */ 25/* Get _open_osfhandle(). */
26#include <io.h> 26#include <io.h>
27 27
28/* Get _get_osfhandle(). */
29#include "msvc-nothrow.h"
30
28#define FD_TO_SOCKET(fd) ((SOCKET) _get_osfhandle ((fd))) 31#define FD_TO_SOCKET(fd) ((SOCKET) _get_osfhandle ((fd)))
29#define SOCKET_TO_FD(fh) (_open_osfhandle ((long) (fh), O_RDWR | O_BINARY)) 32#define SOCKET_TO_FD(fh) (_open_osfhandle ((intptr_t) (fh), O_RDWR | O_BINARY))
30 33
31static inline void 34static inline void
32set_winsock_errno (void) 35set_winsock_errno (void)
@@ -45,15 +48,87 @@ set_winsock_errno (void)
45 case WSA_INVALID_PARAMETER: 48 case WSA_INVALID_PARAMETER:
46 errno = EINVAL; 49 errno = EINVAL;
47 break; 50 break;
48 case WSAEWOULDBLOCK:
49 errno = EWOULDBLOCK;
50 break;
51 case WSAENAMETOOLONG: 51 case WSAENAMETOOLONG:
52 errno = ENAMETOOLONG; 52 errno = ENAMETOOLONG;
53 break; 53 break;
54 case WSAENOTEMPTY: 54 case WSAENOTEMPTY:
55 errno = ENOTEMPTY; 55 errno = ENOTEMPTY;
56 break; 56 break;
57 case WSAEWOULDBLOCK:
58 errno = EWOULDBLOCK;
59 break;
60 case WSAEINPROGRESS:
61 errno = EINPROGRESS;
62 break;
63 case WSAEALREADY:
64 errno = EALREADY;
65 break;
66 case WSAENOTSOCK:
67 errno = ENOTSOCK;
68 break;
69 case WSAEDESTADDRREQ:
70 errno = EDESTADDRREQ;
71 break;
72 case WSAEMSGSIZE:
73 errno = EMSGSIZE;
74 break;
75 case WSAEPROTOTYPE:
76 errno = EPROTOTYPE;
77 break;
78 case WSAENOPROTOOPT:
79 errno = ENOPROTOOPT;
80 break;
81 case WSAEPROTONOSUPPORT:
82 errno = EPROTONOSUPPORT;
83 break;
84 case WSAEOPNOTSUPP:
85 errno = EOPNOTSUPP;
86 break;
87 case WSAEAFNOSUPPORT:
88 errno = EAFNOSUPPORT;
89 break;
90 case WSAEADDRINUSE:
91 errno = EADDRINUSE;
92 break;
93 case WSAEADDRNOTAVAIL:
94 errno = EADDRNOTAVAIL;
95 break;
96 case WSAENETDOWN:
97 errno = ENETDOWN;
98 break;
99 case WSAENETUNREACH:
100 errno = ENETUNREACH;
101 break;
102 case WSAENETRESET:
103 errno = ENETRESET;
104 break;
105 case WSAECONNABORTED:
106 errno = ECONNABORTED;
107 break;
108 case WSAECONNRESET:
109 errno = ECONNRESET;
110 break;
111 case WSAENOBUFS:
112 errno = ENOBUFS;
113 break;
114 case WSAEISCONN:
115 errno = EISCONN;
116 break;
117 case WSAENOTCONN:
118 errno = ENOTCONN;
119 break;
120 case WSAETIMEDOUT:
121 errno = ETIMEDOUT;
122 break;
123 case WSAECONNREFUSED:
124 errno = ECONNREFUSED;
125 break;
126 case WSAELOOP:
127 errno = ELOOP;
128 break;
129 case WSAEHOSTUNREACH:
130 errno = EHOSTUNREACH;
131 break;
57 default: 132 default:
58 errno = (err > 10000 && err < 10025) ? err - 10000 : err; 133 errno = (err > 10000 && err < 10025) ? err - 10000 : err;
59 break; 134 break;
diff --git a/gl/wchar.in.h b/gl/wchar.in.h
index 88d47db..b6e4362 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-2010 Free Software Foundation, Inc. 3 Copyright (C) 2007-2013 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
@@ -13,8 +13,7 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
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, write to the Free Software Foundation, 16 along with this program; if not, see <http://www.gnu.org/licenses/>. */
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 17
19/* Written by Eric Blake. */ 18/* Written by Eric Blake. */
20 19
@@ -29,6 +28,7 @@
29#if __GNUC__ >= 3 28#if __GNUC__ >= 3
30@PRAGMA_SYSTEM_HEADER@ 29@PRAGMA_SYSTEM_HEADER@
31#endif 30#endif
31@PRAGMA_COLUMNS@
32 32
33#if defined __need_mbstate_t || defined __need_wint_t || (defined __hpux && ((defined _INTTYPES_INCLUDED && !defined strtoimax) || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) || defined _GL_ALREADY_INCLUDING_WCHAR_H 33#if defined __need_mbstate_t || defined __need_wint_t || (defined __hpux && ((defined _INTTYPES_INCLUDED && !defined strtoimax) || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) || defined _GL_ALREADY_INCLUDING_WCHAR_H
34/* Special invocation convention: 34/* Special invocation convention:
@@ -48,17 +48,25 @@
48#else 48#else
49/* Normal invocation convention. */ 49/* Normal invocation convention. */
50 50
51#ifndef _GL_WCHAR_H 51#ifndef _@GUARD_PREFIX@_WCHAR_H
52 52
53#define _GL_ALREADY_INCLUDING_WCHAR_H 53#define _GL_ALREADY_INCLUDING_WCHAR_H
54 54
55#if @HAVE_FEATURES_H@
56# include <features.h> /* for __GLIBC__ */
57#endif
58
55/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before 59/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
56 <wchar.h>. 60 <wchar.h>.
57 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be 61 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
58 included before <wchar.h>. 62 included before <wchar.h>.
63 In some builds of uClibc, <wchar.h> is nonexistent and wchar_t is defined
64 by <stddef.h>.
59 But avoid namespace pollution on glibc systems. */ 65 But avoid namespace pollution on glibc systems. */
60#ifndef __GLIBC__ 66#if !(defined __GLIBC__ && !defined __UCLIBC__)
61# include <stddef.h> 67# include <stddef.h>
68#endif
69#ifndef __GLIBC__
62# include <stdio.h> 70# include <stdio.h>
63# include <time.h> 71# include <time.h>
64#endif 72#endif
@@ -72,8 +80,16 @@
72 80
73#undef _GL_ALREADY_INCLUDING_WCHAR_H 81#undef _GL_ALREADY_INCLUDING_WCHAR_H
74 82
75#ifndef _GL_WCHAR_H 83#ifndef _@GUARD_PREFIX@_WCHAR_H
76#define _GL_WCHAR_H 84#define _@GUARD_PREFIX@_WCHAR_H
85
86/* The __attribute__ feature is available in gcc versions 2.5 and later.
87 The attribute __pure__ was added in gcc 2.96. */
88#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
89# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
90#else
91# define _GL_ATTRIBUTE_PURE /* empty */
92#endif
77 93
78/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 94/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
79 95
@@ -89,6 +105,18 @@
89# define WEOF -1 105# define WEOF -1
90# endif 106# endif
91#else 107#else
108/* MSVC defines wint_t as 'unsigned short' in <crtdefs.h>.
109 This is too small: ISO C 99 section 7.24.1.(2) says that wint_t must be
110 "unchanged by default argument promotions". Override it. */
111# if defined _MSC_VER
112# if !GNULIB_defined_wint_t
113# include <crtdefs.h>
114typedef unsigned int rpl_wint_t;
115# undef wint_t
116# define wint_t rpl_wint_t
117# define GNULIB_defined_wint_t 1
118# endif
119# endif
92# ifndef WEOF 120# ifndef WEOF
93# define WEOF ((wint_t) -1) 121# define WEOF ((wint_t) -1)
94# endif 122# endif
@@ -99,10 +127,12 @@
99 On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for 127 On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for
100 implementing mbrtowc for encodings like UTF-8. */ 128 implementing mbrtowc for encodings like UTF-8. */
101#if !(@HAVE_MBSINIT@ && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@ 129#if !(@HAVE_MBSINIT@ && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@
130# if !GNULIB_defined_mbstate_t
102typedef int rpl_mbstate_t; 131typedef int rpl_mbstate_t;
103# undef mbstate_t 132# undef mbstate_t
104# define mbstate_t rpl_mbstate_t 133# define mbstate_t rpl_mbstate_t
105# define GNULIB_defined_mbstate_t 1 134# define GNULIB_defined_mbstate_t 1
135# endif
106#endif 136#endif
107 137
108 138
@@ -113,11 +143,11 @@ typedef int rpl_mbstate_t;
113# undef btowc 143# undef btowc
114# define btowc rpl_btowc 144# define btowc rpl_btowc
115# endif 145# endif
116_GL_FUNCDECL_RPL (btowc, wint_t, (int c)); 146_GL_FUNCDECL_RPL (btowc, wint_t, (int c) _GL_ATTRIBUTE_PURE);
117_GL_CXXALIAS_RPL (btowc, wint_t, (int c)); 147_GL_CXXALIAS_RPL (btowc, wint_t, (int c));
118# else 148# else
119# if !@HAVE_BTOWC@ 149# if !@HAVE_BTOWC@
120_GL_FUNCDECL_SYS (btowc, wint_t, (int c)); 150_GL_FUNCDECL_SYS (btowc, wint_t, (int c) _GL_ATTRIBUTE_PURE);
121# endif 151# endif
122_GL_CXXALIAS_SYS (btowc, wint_t, (int c)); 152_GL_CXXALIAS_SYS (btowc, wint_t, (int c));
123# endif 153# endif
@@ -138,12 +168,12 @@ _GL_WARN_ON_USE (btowc, "btowc is unportable - "
138# undef wctob 168# undef wctob
139# define wctob rpl_wctob 169# define wctob rpl_wctob
140# endif 170# endif
141_GL_FUNCDECL_RPL (wctob, int, (wint_t wc)); 171_GL_FUNCDECL_RPL (wctob, int, (wint_t wc) _GL_ATTRIBUTE_PURE);
142_GL_CXXALIAS_RPL (wctob, int, (wint_t wc)); 172_GL_CXXALIAS_RPL (wctob, int, (wint_t wc));
143# else 173# else
144# if !defined wctob && !@HAVE_DECL_WCTOB@ 174# if !defined wctob && !@HAVE_DECL_WCTOB@
145/* wctob is provided by gnulib, or wctob exists but is not declared. */ 175/* wctob is provided by gnulib, or wctob exists but is not declared. */
146_GL_FUNCDECL_SYS (wctob, int, (wint_t wc)); 176_GL_FUNCDECL_SYS (wctob, int, (wint_t wc) _GL_ATTRIBUTE_PURE);
147# endif 177# endif
148_GL_CXXALIAS_SYS (wctob, int, (wint_t wc)); 178_GL_CXXALIAS_SYS (wctob, int, (wint_t wc));
149# endif 179# endif
@@ -404,12 +434,12 @@ _GL_WARN_ON_USE (wcsnrtombs, "wcsnrtombs is unportable - "
404# undef wcwidth 434# undef wcwidth
405# define wcwidth rpl_wcwidth 435# define wcwidth rpl_wcwidth
406# endif 436# endif
407_GL_FUNCDECL_RPL (wcwidth, int, (wchar_t)); 437_GL_FUNCDECL_RPL (wcwidth, int, (wchar_t) _GL_ATTRIBUTE_PURE);
408_GL_CXXALIAS_RPL (wcwidth, int, (wchar_t)); 438_GL_CXXALIAS_RPL (wcwidth, int, (wchar_t));
409# else 439# else
410# if !@HAVE_DECL_WCWIDTH@ 440# if !@HAVE_DECL_WCWIDTH@
411/* wcwidth exists but is not declared. */ 441/* wcwidth exists but is not declared. */
412_GL_FUNCDECL_SYS (wcwidth, int, (wchar_t)); 442_GL_FUNCDECL_SYS (wcwidth, int, (wchar_t) _GL_ATTRIBUTE_PURE);
413# endif 443# endif
414_GL_CXXALIAS_SYS (wcwidth, int, (wchar_t)); 444_GL_CXXALIAS_SYS (wcwidth, int, (wchar_t));
415# endif 445# endif
@@ -423,6 +453,576 @@ _GL_WARN_ON_USE (wcwidth, "wcwidth is unportable - "
423#endif 453#endif
424 454
425 455
426#endif /* _GL_WCHAR_H */ 456/* Search N wide characters of S for C. */
427#endif /* _GL_WCHAR_H */ 457#if @GNULIB_WMEMCHR@
458# if !@HAVE_WMEMCHR@
459_GL_FUNCDECL_SYS (wmemchr, wchar_t *, (const wchar_t *s, wchar_t c, size_t n)
460 _GL_ATTRIBUTE_PURE);
461# endif
462 /* On some systems, this function is defined as an overloaded function:
463 extern "C++" {
464 const wchar_t * std::wmemchr (const wchar_t *, wchar_t, size_t);
465 wchar_t * std::wmemchr (wchar_t *, wchar_t, size_t);
466 } */
467_GL_CXXALIAS_SYS_CAST2 (wmemchr,
468 wchar_t *, (const wchar_t *, wchar_t, size_t),
469 const wchar_t *, (const wchar_t *, wchar_t, size_t));
470# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
471 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
472_GL_CXXALIASWARN1 (wmemchr, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
473_GL_CXXALIASWARN1 (wmemchr, const wchar_t *,
474 (const wchar_t *s, wchar_t c, size_t n));
475# else
476_GL_CXXALIASWARN (wmemchr);
477# endif
478#elif defined GNULIB_POSIXCHECK
479# undef wmemchr
480# if HAVE_RAW_DECL_WMEMCHR
481_GL_WARN_ON_USE (wmemchr, "wmemchr is unportable - "
482 "use gnulib module wmemchr for portability");
483# endif
484#endif
485
486
487/* Compare N wide characters of S1 and S2. */
488#if @GNULIB_WMEMCMP@
489# if !@HAVE_WMEMCMP@
490_GL_FUNCDECL_SYS (wmemcmp, int,
491 (const wchar_t *s1, const wchar_t *s2, size_t n)
492 _GL_ATTRIBUTE_PURE);
493# endif
494_GL_CXXALIAS_SYS (wmemcmp, int,
495 (const wchar_t *s1, const wchar_t *s2, size_t n));
496_GL_CXXALIASWARN (wmemcmp);
497#elif defined GNULIB_POSIXCHECK
498# undef wmemcmp
499# if HAVE_RAW_DECL_WMEMCMP
500_GL_WARN_ON_USE (wmemcmp, "wmemcmp is unportable - "
501 "use gnulib module wmemcmp for portability");
502# endif
503#endif
504
505
506/* Copy N wide characters of SRC to DEST. */
507#if @GNULIB_WMEMCPY@
508# if !@HAVE_WMEMCPY@
509_GL_FUNCDECL_SYS (wmemcpy, wchar_t *,
510 (wchar_t *dest, const wchar_t *src, size_t n));
511# endif
512_GL_CXXALIAS_SYS (wmemcpy, wchar_t *,
513 (wchar_t *dest, const wchar_t *src, size_t n));
514_GL_CXXALIASWARN (wmemcpy);
515#elif defined GNULIB_POSIXCHECK
516# undef wmemcpy
517# if HAVE_RAW_DECL_WMEMCPY
518_GL_WARN_ON_USE (wmemcpy, "wmemcpy is unportable - "
519 "use gnulib module wmemcpy for portability");
520# endif
521#endif
522
523
524/* Copy N wide characters of SRC to DEST, guaranteeing correct behavior for
525 overlapping memory areas. */
526#if @GNULIB_WMEMMOVE@
527# if !@HAVE_WMEMMOVE@
528_GL_FUNCDECL_SYS (wmemmove, wchar_t *,
529 (wchar_t *dest, const wchar_t *src, size_t n));
530# endif
531_GL_CXXALIAS_SYS (wmemmove, wchar_t *,
532 (wchar_t *dest, const wchar_t *src, size_t n));
533_GL_CXXALIASWARN (wmemmove);
534#elif defined GNULIB_POSIXCHECK
535# undef wmemmove
536# if HAVE_RAW_DECL_WMEMMOVE
537_GL_WARN_ON_USE (wmemmove, "wmemmove is unportable - "
538 "use gnulib module wmemmove for portability");
539# endif
540#endif
541
542
543/* Set N wide characters of S to C. */
544#if @GNULIB_WMEMSET@
545# if !@HAVE_WMEMSET@
546_GL_FUNCDECL_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
547# endif
548_GL_CXXALIAS_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
549_GL_CXXALIASWARN (wmemset);
550#elif defined GNULIB_POSIXCHECK
551# undef wmemset
552# if HAVE_RAW_DECL_WMEMSET
553_GL_WARN_ON_USE (wmemset, "wmemset is unportable - "
554 "use gnulib module wmemset for portability");
555# endif
556#endif
557
558
559/* Return the number of wide characters in S. */
560#if @GNULIB_WCSLEN@
561# if !@HAVE_WCSLEN@
562_GL_FUNCDECL_SYS (wcslen, size_t, (const wchar_t *s) _GL_ATTRIBUTE_PURE);
563# endif
564_GL_CXXALIAS_SYS (wcslen, size_t, (const wchar_t *s));
565_GL_CXXALIASWARN (wcslen);
566#elif defined GNULIB_POSIXCHECK
567# undef wcslen
568# if HAVE_RAW_DECL_WCSLEN
569_GL_WARN_ON_USE (wcslen, "wcslen is unportable - "
570 "use gnulib module wcslen for portability");
571# endif
572#endif
573
574
575/* Return the number of wide characters in S, but at most MAXLEN. */
576#if @GNULIB_WCSNLEN@
577# if !@HAVE_WCSNLEN@
578_GL_FUNCDECL_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen)
579 _GL_ATTRIBUTE_PURE);
580# endif
581_GL_CXXALIAS_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen));
582_GL_CXXALIASWARN (wcsnlen);
583#elif defined GNULIB_POSIXCHECK
584# undef wcsnlen
585# if HAVE_RAW_DECL_WCSNLEN
586_GL_WARN_ON_USE (wcsnlen, "wcsnlen is unportable - "
587 "use gnulib module wcsnlen for portability");
588# endif
589#endif
590
591
592/* Copy SRC to DEST. */
593#if @GNULIB_WCSCPY@
594# if !@HAVE_WCSCPY@
595_GL_FUNCDECL_SYS (wcscpy, wchar_t *, (wchar_t *dest, const wchar_t *src));
596# endif
597_GL_CXXALIAS_SYS (wcscpy, wchar_t *, (wchar_t *dest, const wchar_t *src));
598_GL_CXXALIASWARN (wcscpy);
599#elif defined GNULIB_POSIXCHECK
600# undef wcscpy
601# if HAVE_RAW_DECL_WCSCPY
602_GL_WARN_ON_USE (wcscpy, "wcscpy is unportable - "
603 "use gnulib module wcscpy for portability");
604# endif
605#endif
606
607
608/* Copy SRC to DEST, returning the address of the terminating L'\0' in DEST. */
609#if @GNULIB_WCPCPY@
610# if !@HAVE_WCPCPY@
611_GL_FUNCDECL_SYS (wcpcpy, wchar_t *, (wchar_t *dest, const wchar_t *src));
612# endif
613_GL_CXXALIAS_SYS (wcpcpy, wchar_t *, (wchar_t *dest, const wchar_t *src));
614_GL_CXXALIASWARN (wcpcpy);
615#elif defined GNULIB_POSIXCHECK
616# undef wcpcpy
617# if HAVE_RAW_DECL_WCPCPY
618_GL_WARN_ON_USE (wcpcpy, "wcpcpy is unportable - "
619 "use gnulib module wcpcpy for portability");
620# endif
621#endif
622
623
624/* Copy no more than N wide characters of SRC to DEST. */
625#if @GNULIB_WCSNCPY@
626# if !@HAVE_WCSNCPY@
627_GL_FUNCDECL_SYS (wcsncpy, wchar_t *,
628 (wchar_t *dest, const wchar_t *src, size_t n));
629# endif
630_GL_CXXALIAS_SYS (wcsncpy, wchar_t *,
631 (wchar_t *dest, const wchar_t *src, size_t n));
632_GL_CXXALIASWARN (wcsncpy);
633#elif defined GNULIB_POSIXCHECK
634# undef wcsncpy
635# if HAVE_RAW_DECL_WCSNCPY
636_GL_WARN_ON_USE (wcsncpy, "wcsncpy is unportable - "
637 "use gnulib module wcsncpy for portability");
638# endif
639#endif
640
641
642/* Copy no more than N characters of SRC to DEST, returning the address of
643 the last character written into DEST. */
644#if @GNULIB_WCPNCPY@
645# if !@HAVE_WCPNCPY@
646_GL_FUNCDECL_SYS (wcpncpy, wchar_t *,
647 (wchar_t *dest, const wchar_t *src, size_t n));
648# endif
649_GL_CXXALIAS_SYS (wcpncpy, wchar_t *,
650 (wchar_t *dest, const wchar_t *src, size_t n));
651_GL_CXXALIASWARN (wcpncpy);
652#elif defined GNULIB_POSIXCHECK
653# undef wcpncpy
654# if HAVE_RAW_DECL_WCPNCPY
655_GL_WARN_ON_USE (wcpncpy, "wcpncpy is unportable - "
656 "use gnulib module wcpncpy for portability");
657# endif
658#endif
659
660
661/* Append SRC onto DEST. */
662#if @GNULIB_WCSCAT@
663# if !@HAVE_WCSCAT@
664_GL_FUNCDECL_SYS (wcscat, wchar_t *, (wchar_t *dest, const wchar_t *src));
665# endif
666_GL_CXXALIAS_SYS (wcscat, wchar_t *, (wchar_t *dest, const wchar_t *src));
667_GL_CXXALIASWARN (wcscat);
668#elif defined GNULIB_POSIXCHECK
669# undef wcscat
670# if HAVE_RAW_DECL_WCSCAT
671_GL_WARN_ON_USE (wcscat, "wcscat is unportable - "
672 "use gnulib module wcscat for portability");
673# endif
674#endif
675
676
677/* Append no more than N wide characters of SRC onto DEST. */
678#if @GNULIB_WCSNCAT@
679# if !@HAVE_WCSNCAT@
680_GL_FUNCDECL_SYS (wcsncat, wchar_t *,
681 (wchar_t *dest, const wchar_t *src, size_t n));
682# endif
683_GL_CXXALIAS_SYS (wcsncat, wchar_t *,
684 (wchar_t *dest, const wchar_t *src, size_t n));
685_GL_CXXALIASWARN (wcsncat);
686#elif defined GNULIB_POSIXCHECK
687# undef wcsncat
688# if HAVE_RAW_DECL_WCSNCAT
689_GL_WARN_ON_USE (wcsncat, "wcsncat is unportable - "
690 "use gnulib module wcsncat for portability");
691# endif
692#endif
693
694
695/* Compare S1 and S2. */
696#if @GNULIB_WCSCMP@
697# if !@HAVE_WCSCMP@
698_GL_FUNCDECL_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2)
699 _GL_ATTRIBUTE_PURE);
700# endif
701_GL_CXXALIAS_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2));
702_GL_CXXALIASWARN (wcscmp);
703#elif defined GNULIB_POSIXCHECK
704# undef wcscmp
705# if HAVE_RAW_DECL_WCSCMP
706_GL_WARN_ON_USE (wcscmp, "wcscmp is unportable - "
707 "use gnulib module wcscmp for portability");
708# endif
709#endif
710
711
712/* Compare no more than N wide characters of S1 and S2. */
713#if @GNULIB_WCSNCMP@
714# if !@HAVE_WCSNCMP@
715_GL_FUNCDECL_SYS (wcsncmp, int,
716 (const wchar_t *s1, const wchar_t *s2, size_t n)
717 _GL_ATTRIBUTE_PURE);
718# endif
719_GL_CXXALIAS_SYS (wcsncmp, int,
720 (const wchar_t *s1, const wchar_t *s2, size_t n));
721_GL_CXXALIASWARN (wcsncmp);
722#elif defined GNULIB_POSIXCHECK
723# undef wcsncmp
724# if HAVE_RAW_DECL_WCSNCMP
725_GL_WARN_ON_USE (wcsncmp, "wcsncmp is unportable - "
726 "use gnulib module wcsncmp for portability");
727# endif
728#endif
729
730
731/* Compare S1 and S2, ignoring case. */
732#if @GNULIB_WCSCASECMP@
733# if !@HAVE_WCSCASECMP@
734_GL_FUNCDECL_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2)
735 _GL_ATTRIBUTE_PURE);
736# endif
737_GL_CXXALIAS_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2));
738_GL_CXXALIASWARN (wcscasecmp);
739#elif defined GNULIB_POSIXCHECK
740# undef wcscasecmp
741# if HAVE_RAW_DECL_WCSCASECMP
742_GL_WARN_ON_USE (wcscasecmp, "wcscasecmp is unportable - "
743 "use gnulib module wcscasecmp for portability");
744# endif
745#endif
746
747
748/* Compare no more than N chars of S1 and S2, ignoring case. */
749#if @GNULIB_WCSNCASECMP@
750# if !@HAVE_WCSNCASECMP@
751_GL_FUNCDECL_SYS (wcsncasecmp, int,
752 (const wchar_t *s1, const wchar_t *s2, size_t n)
753 _GL_ATTRIBUTE_PURE);
754# endif
755_GL_CXXALIAS_SYS (wcsncasecmp, int,
756 (const wchar_t *s1, const wchar_t *s2, size_t n));
757_GL_CXXALIASWARN (wcsncasecmp);
758#elif defined GNULIB_POSIXCHECK
759# undef wcsncasecmp
760# if HAVE_RAW_DECL_WCSNCASECMP
761_GL_WARN_ON_USE (wcsncasecmp, "wcsncasecmp is unportable - "
762 "use gnulib module wcsncasecmp for portability");
763# endif
764#endif
765
766
767/* Compare S1 and S2, both interpreted as appropriate to the LC_COLLATE
768 category of the current locale. */
769#if @GNULIB_WCSCOLL@
770# if !@HAVE_WCSCOLL@
771_GL_FUNCDECL_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2));
772# endif
773_GL_CXXALIAS_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2));
774_GL_CXXALIASWARN (wcscoll);
775#elif defined GNULIB_POSIXCHECK
776# undef wcscoll
777# if HAVE_RAW_DECL_WCSCOLL
778_GL_WARN_ON_USE (wcscoll, "wcscoll is unportable - "
779 "use gnulib module wcscoll for portability");
780# endif
781#endif
782
783
784/* Transform S2 into array pointed to by S1 such that if wcscmp is applied
785 to two transformed strings the result is the as applying 'wcscoll' to the
786 original strings. */
787#if @GNULIB_WCSXFRM@
788# if !@HAVE_WCSXFRM@
789_GL_FUNCDECL_SYS (wcsxfrm, size_t, (wchar_t *s1, const wchar_t *s2, size_t n));
790# endif
791_GL_CXXALIAS_SYS (wcsxfrm, size_t, (wchar_t *s1, const wchar_t *s2, size_t n));
792_GL_CXXALIASWARN (wcsxfrm);
793#elif defined GNULIB_POSIXCHECK
794# undef wcsxfrm
795# if HAVE_RAW_DECL_WCSXFRM
796_GL_WARN_ON_USE (wcsxfrm, "wcsxfrm is unportable - "
797 "use gnulib module wcsxfrm for portability");
798# endif
799#endif
800
801
802/* Duplicate S, returning an identical malloc'd string. */
803#if @GNULIB_WCSDUP@
804# if !@HAVE_WCSDUP@
805_GL_FUNCDECL_SYS (wcsdup, wchar_t *, (const wchar_t *s));
806# endif
807_GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s));
808_GL_CXXALIASWARN (wcsdup);
809#elif defined GNULIB_POSIXCHECK
810# undef wcsdup
811# if HAVE_RAW_DECL_WCSDUP
812_GL_WARN_ON_USE (wcsdup, "wcsdup is unportable - "
813 "use gnulib module wcsdup for portability");
814# endif
815#endif
816
817
818/* Find the first occurrence of WC in WCS. */
819#if @GNULIB_WCSCHR@
820# if !@HAVE_WCSCHR@
821_GL_FUNCDECL_SYS (wcschr, wchar_t *, (const wchar_t *wcs, wchar_t wc)
822 _GL_ATTRIBUTE_PURE);
823# endif
824 /* On some systems, this function is defined as an overloaded function:
825 extern "C++" {
826 const wchar_t * std::wcschr (const wchar_t *, wchar_t);
827 wchar_t * std::wcschr (wchar_t *, wchar_t);
828 } */
829_GL_CXXALIAS_SYS_CAST2 (wcschr,
830 wchar_t *, (const wchar_t *, wchar_t),
831 const wchar_t *, (const wchar_t *, wchar_t));
832# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
833 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
834_GL_CXXALIASWARN1 (wcschr, wchar_t *, (wchar_t *wcs, wchar_t wc));
835_GL_CXXALIASWARN1 (wcschr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
836# else
837_GL_CXXALIASWARN (wcschr);
838# endif
839#elif defined GNULIB_POSIXCHECK
840# undef wcschr
841# if HAVE_RAW_DECL_WCSCHR
842_GL_WARN_ON_USE (wcschr, "wcschr is unportable - "
843 "use gnulib module wcschr for portability");
844# endif
845#endif
846
847
848/* Find the last occurrence of WC in WCS. */
849#if @GNULIB_WCSRCHR@
850# if !@HAVE_WCSRCHR@
851_GL_FUNCDECL_SYS (wcsrchr, wchar_t *, (const wchar_t *wcs, wchar_t wc)
852 _GL_ATTRIBUTE_PURE);
853# endif
854 /* On some systems, this function is defined as an overloaded function:
855 extern "C++" {
856 const wchar_t * std::wcsrchr (const wchar_t *, wchar_t);
857 wchar_t * std::wcsrchr (wchar_t *, wchar_t);
858 } */
859_GL_CXXALIAS_SYS_CAST2 (wcsrchr,
860 wchar_t *, (const wchar_t *, wchar_t),
861 const wchar_t *, (const wchar_t *, wchar_t));
862# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
863 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
864_GL_CXXALIASWARN1 (wcsrchr, wchar_t *, (wchar_t *wcs, wchar_t wc));
865_GL_CXXALIASWARN1 (wcsrchr, const wchar_t *, (const wchar_t *wcs, wchar_t wc));
866# else
867_GL_CXXALIASWARN (wcsrchr);
868# endif
869#elif defined GNULIB_POSIXCHECK
870# undef wcsrchr
871# if HAVE_RAW_DECL_WCSRCHR
872_GL_WARN_ON_USE (wcsrchr, "wcsrchr is unportable - "
873 "use gnulib module wcsrchr for portability");
874# endif
875#endif
876
877
878/* Return the length of the initial segmet of WCS which consists entirely
879 of wide characters not in REJECT. */
880#if @GNULIB_WCSCSPN@
881# if !@HAVE_WCSCSPN@
882_GL_FUNCDECL_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject)
883 _GL_ATTRIBUTE_PURE);
884# endif
885_GL_CXXALIAS_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject));
886_GL_CXXALIASWARN (wcscspn);
887#elif defined GNULIB_POSIXCHECK
888# undef wcscspn
889# if HAVE_RAW_DECL_WCSCSPN
890_GL_WARN_ON_USE (wcscspn, "wcscspn is unportable - "
891 "use gnulib module wcscspn for portability");
892# endif
893#endif
894
895
896/* Return the length of the initial segmet of WCS which consists entirely
897 of wide characters in ACCEPT. */
898#if @GNULIB_WCSSPN@
899# if !@HAVE_WCSSPN@
900_GL_FUNCDECL_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept)
901 _GL_ATTRIBUTE_PURE);
902# endif
903_GL_CXXALIAS_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept));
904_GL_CXXALIASWARN (wcsspn);
905#elif defined GNULIB_POSIXCHECK
906# undef wcsspn
907# if HAVE_RAW_DECL_WCSSPN
908_GL_WARN_ON_USE (wcsspn, "wcsspn is unportable - "
909 "use gnulib module wcsspn for portability");
910# endif
911#endif
912
913
914/* Find the first occurrence in WCS of any character in ACCEPT. */
915#if @GNULIB_WCSPBRK@
916# if !@HAVE_WCSPBRK@
917_GL_FUNCDECL_SYS (wcspbrk, wchar_t *,
918 (const wchar_t *wcs, const wchar_t *accept)
919 _GL_ATTRIBUTE_PURE);
920# endif
921 /* On some systems, this function is defined as an overloaded function:
922 extern "C++" {
923 const wchar_t * std::wcspbrk (const wchar_t *, const wchar_t *);
924 wchar_t * std::wcspbrk (wchar_t *, const wchar_t *);
925 } */
926_GL_CXXALIAS_SYS_CAST2 (wcspbrk,
927 wchar_t *, (const wchar_t *, const wchar_t *),
928 const wchar_t *, (const wchar_t *, const wchar_t *));
929# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
930 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
931_GL_CXXALIASWARN1 (wcspbrk, wchar_t *,
932 (wchar_t *wcs, const wchar_t *accept));
933_GL_CXXALIASWARN1 (wcspbrk, const wchar_t *,
934 (const wchar_t *wcs, const wchar_t *accept));
935# else
936_GL_CXXALIASWARN (wcspbrk);
937# endif
938#elif defined GNULIB_POSIXCHECK
939# undef wcspbrk
940# if HAVE_RAW_DECL_WCSPBRK
941_GL_WARN_ON_USE (wcspbrk, "wcspbrk is unportable - "
942 "use gnulib module wcspbrk for portability");
943# endif
944#endif
945
946
947/* Find the first occurrence of NEEDLE in HAYSTACK. */
948#if @GNULIB_WCSSTR@
949# if !@HAVE_WCSSTR@
950_GL_FUNCDECL_SYS (wcsstr, wchar_t *,
951 (const wchar_t *haystack, const wchar_t *needle)
952 _GL_ATTRIBUTE_PURE);
953# endif
954 /* On some systems, this function is defined as an overloaded function:
955 extern "C++" {
956 const wchar_t * std::wcsstr (const wchar_t *, const wchar_t *);
957 wchar_t * std::wcsstr (wchar_t *, const wchar_t *);
958 } */
959_GL_CXXALIAS_SYS_CAST2 (wcsstr,
960 wchar_t *, (const wchar_t *, const wchar_t *),
961 const wchar_t *, (const wchar_t *, const wchar_t *));
962# if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 10) && !defined __UCLIBC__) \
963 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
964_GL_CXXALIASWARN1 (wcsstr, wchar_t *,
965 (wchar_t *haystack, const wchar_t *needle));
966_GL_CXXALIASWARN1 (wcsstr, const wchar_t *,
967 (const wchar_t *haystack, const wchar_t *needle));
968# else
969_GL_CXXALIASWARN (wcsstr);
970# endif
971#elif defined GNULIB_POSIXCHECK
972# undef wcsstr
973# if HAVE_RAW_DECL_WCSSTR
974_GL_WARN_ON_USE (wcsstr, "wcsstr is unportable - "
975 "use gnulib module wcsstr for portability");
976# endif
977#endif
978
979
980/* Divide WCS into tokens separated by characters in DELIM. */
981#if @GNULIB_WCSTOK@
982# if !@HAVE_WCSTOK@
983_GL_FUNCDECL_SYS (wcstok, wchar_t *,
984 (wchar_t *wcs, const wchar_t *delim, wchar_t **ptr));
985# endif
986_GL_CXXALIAS_SYS (wcstok, wchar_t *,
987 (wchar_t *wcs, const wchar_t *delim, wchar_t **ptr));
988_GL_CXXALIASWARN (wcstok);
989#elif defined GNULIB_POSIXCHECK
990# undef wcstok
991# if HAVE_RAW_DECL_WCSTOK
992_GL_WARN_ON_USE (wcstok, "wcstok is unportable - "
993 "use gnulib module wcstok for portability");
994# endif
995#endif
996
997
998/* Determine number of column positions required for first N wide
999 characters (or fewer if S ends before this) in S. */
1000#if @GNULIB_WCSWIDTH@
1001# if @REPLACE_WCSWIDTH@
1002# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1003# undef wcswidth
1004# define wcswidth rpl_wcswidth
1005# endif
1006_GL_FUNCDECL_RPL (wcswidth, int, (const wchar_t *s, size_t n)
1007 _GL_ATTRIBUTE_PURE);
1008_GL_CXXALIAS_RPL (wcswidth, int, (const wchar_t *s, size_t n));
1009# else
1010# if !@HAVE_WCSWIDTH@
1011_GL_FUNCDECL_SYS (wcswidth, int, (const wchar_t *s, size_t n)
1012 _GL_ATTRIBUTE_PURE);
1013# endif
1014_GL_CXXALIAS_SYS (wcswidth, int, (const wchar_t *s, size_t n));
1015# endif
1016_GL_CXXALIASWARN (wcswidth);
1017#elif defined GNULIB_POSIXCHECK
1018# undef wcswidth
1019# if HAVE_RAW_DECL_WCSWIDTH
1020_GL_WARN_ON_USE (wcswidth, "wcswidth is unportable - "
1021 "use gnulib module wcswidth for portability");
1022# endif
1023#endif
1024
1025
1026#endif /* _@GUARD_PREFIX@_WCHAR_H */
1027#endif /* _@GUARD_PREFIX@_WCHAR_H */
428#endif 1028#endif
diff --git a/gl/wcrtomb.c b/gl/wcrtomb.c
index e7345f6..da42809 100644
--- a/gl/wcrtomb.c
+++ b/gl/wcrtomb.c
@@ -1,5 +1,5 @@
1/* Convert wide character to multibyte character. 1/* Convert wide character to multibyte character.
2 Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. 2 Copyright (C) 2008-2013 Free Software Foundation, Inc.
3 Written by Bruno Haible <bruno@clisp.org>, 2008. 3 Written by Bruno Haible <bruno@clisp.org>, 2008.
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
diff --git a/gl/wctype-h.c b/gl/wctype-h.c
new file mode 100644
index 0000000..bb5f847
--- /dev/null
+++ b/gl/wctype-h.c
@@ -0,0 +1,4 @@
1/* Normally this would be wctype.c, but that name's already taken. */
2#include <config.h>
3#define _GL_WCTYPE_INLINE _GL_EXTERN_INLINE
4#include "wctype.h"
diff --git a/gl/wctype.in.h b/gl/wctype.in.h
index 0f0859c..a7c07d1 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-2010 Free Software Foundation, Inc. 3 Copyright (C) 2006-2013 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
@@ -13,8 +13,7 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
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, write to the Free Software Foundation, 16 along with this program; if not, see <http://www.gnu.org/licenses/>. */
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 17
19/* Written by Bruno Haible and Paul Eggert. */ 18/* Written by Bruno Haible and Paul Eggert. */
20 19
@@ -26,11 +25,12 @@
26 * wctrans_t, and wctype_t are not yet implemented. 25 * wctrans_t, and wctype_t are not yet implemented.
27 */ 26 */
28 27
29#ifndef _GL_WCTYPE_H 28#ifndef _@GUARD_PREFIX@_WCTYPE_H
30 29
31#if __GNUC__ >= 3 30#if __GNUC__ >= 3
32@PRAGMA_SYSTEM_HEADER@ 31@PRAGMA_SYSTEM_HEADER@
33#endif 32#endif
33@PRAGMA_COLUMNS@
34 34
35#if @HAVE_WINT_T@ 35#if @HAVE_WINT_T@
36/* 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>.
@@ -44,6 +44,13 @@
44# include <wchar.h> 44# include <wchar.h>
45#endif 45#endif
46 46
47/* mingw has declarations of towupper and towlower in <ctype.h> as
48 well <wctype.h>. Include <ctype.h> in advance to avoid rpl_ prefix
49 being added to the declarations. */
50#ifdef __MINGW32__
51# include <ctype.h>
52#endif
53
47/* Include the original <wctype.h> if it exists. 54/* Include the original <wctype.h> if it exists.
48 BeOS 5 has the functions but no <wctype.h>. */ 55 BeOS 5 has the functions but no <wctype.h>. */
49/* The include_next requires a split double-inclusion guard. */ 56/* The include_next requires a split double-inclusion guard. */
@@ -51,13 +58,31 @@
51# @INCLUDE_NEXT@ @NEXT_WCTYPE_H@ 58# @INCLUDE_NEXT@ @NEXT_WCTYPE_H@
52#endif 59#endif
53 60
54#ifndef _GL_WCTYPE_H 61#ifndef _@GUARD_PREFIX@_WCTYPE_H
55#define _GL_WCTYPE_H 62#define _@GUARD_PREFIX@_WCTYPE_H
63
64_GL_INLINE_HEADER_BEGIN
65#ifndef _GL_WCTYPE_INLINE
66# define _GL_WCTYPE_INLINE _GL_INLINE
67#endif
56 68
57/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 69/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
58 70
59/* The definition of _GL_WARN_ON_USE is copied here. */ 71/* The definition of _GL_WARN_ON_USE is copied here. */
60 72
73/* Solaris 2.6 <wctype.h> includes <widec.h> which includes <euc.h> which
74 #defines a number of identifiers in the application namespace. Revert
75 these #defines. */
76#ifdef __sun
77# undef multibyte
78# undef eucw1
79# undef eucw2
80# undef eucw3
81# undef scrw1
82# undef scrw2
83# undef scrw3
84#endif
85
61/* Define wint_t and WEOF. (Also done in wchar.in.h.) */ 86/* Define wint_t and WEOF. (Also done in wchar.in.h.) */
62#if !@HAVE_WINT_T@ && !defined wint_t 87#if !@HAVE_WINT_T@ && !defined wint_t
63# define wint_t int 88# define wint_t int
@@ -65,153 +90,171 @@
65# define WEOF -1 90# define WEOF -1
66# endif 91# endif
67#else 92#else
93/* MSVC defines wint_t as 'unsigned short' in <crtdefs.h>.
94 This is too small: ISO C 99 section 7.24.1.(2) says that wint_t must be
95 "unchanged by default argument promotions". Override it. */
96# if defined _MSC_VER
97# if !GNULIB_defined_wint_t
98# include <crtdefs.h>
99typedef unsigned int rpl_wint_t;
100# undef wint_t
101# define wint_t rpl_wint_t
102# define GNULIB_defined_wint_t 1
103# endif
104# endif
68# ifndef WEOF 105# ifndef WEOF
69# define WEOF ((wint_t) -1) 106# define WEOF ((wint_t) -1)
70# endif 107# endif
71#endif 108#endif
72 109
73 110
111#if !GNULIB_defined_wctype_functions
112
74/* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions. 113/* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions.
75 Linux libc5 has <wctype.h> and the functions but they are broken. 114 Linux libc5 has <wctype.h> and the functions but they are broken.
76 Assume all 11 functions (all isw* except iswblank) are implemented the 115 Assume all 11 functions (all isw* except iswblank) are implemented the
77 same way, or not at all. */ 116 same way, or not at all. */
78#if ! @HAVE_ISWCNTRL@ || @REPLACE_ISWCNTRL@ 117# if ! @HAVE_ISWCNTRL@ || @REPLACE_ISWCNTRL@
79 118
80/* IRIX 5.3 has macros but no functions, its isw* macros refer to an 119/* IRIX 5.3 has macros but no functions, its isw* macros refer to an
81 undefined variable _ctmp_ and to <ctype.h> macros like _P, and they 120 undefined variable _ctmp_ and to <ctype.h> macros like _P, and they
82 refer to system functions like _iswctype that are not in the 121 refer to system functions like _iswctype that are not in the
83 standard C library. Rather than try to get ancient buggy 122 standard C library. Rather than try to get ancient buggy
84 implementations like this to work, just disable them. */ 123 implementations like this to work, just disable them. */
85# undef iswalnum 124# undef iswalnum
86# undef iswalpha 125# undef iswalpha
87# undef iswblank 126# undef iswblank
88# undef iswcntrl 127# undef iswcntrl
89# undef iswdigit 128# undef iswdigit
90# undef iswgraph 129# undef iswgraph
91# undef iswlower 130# undef iswlower
92# undef iswprint 131# undef iswprint
93# undef iswpunct 132# undef iswpunct
94# undef iswspace 133# undef iswspace
95# undef iswupper 134# undef iswupper
96# undef iswxdigit 135# undef iswxdigit
97# undef towlower 136# undef towlower
98# undef towupper 137# undef towupper
99 138
100/* Linux libc5 has <wctype.h> and the functions but they are broken. */ 139/* Linux libc5 has <wctype.h> and the functions but they are broken. */
101# if @REPLACE_ISWCNTRL@ 140# if @REPLACE_ISWCNTRL@
102# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 141# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
103# define iswalnum rpl_iswalnum 142# define iswalnum rpl_iswalnum
104# define iswalpha rpl_iswalpha 143# define iswalpha rpl_iswalpha
105# define iswblank rpl_iswblank 144# define iswblank rpl_iswblank
106# define iswcntrl rpl_iswcntrl 145# define iswcntrl rpl_iswcntrl
107# define iswdigit rpl_iswdigit 146# define iswdigit rpl_iswdigit
108# define iswgraph rpl_iswgraph 147# define iswgraph rpl_iswgraph
109# define iswlower rpl_iswlower 148# define iswlower rpl_iswlower
110# define iswprint rpl_iswprint 149# define iswprint rpl_iswprint
111# define iswpunct rpl_iswpunct 150# define iswpunct rpl_iswpunct
112# define iswspace rpl_iswspace 151# define iswspace rpl_iswspace
113# define iswupper rpl_iswupper 152# define iswupper rpl_iswupper
114# define iswxdigit rpl_iswxdigit 153# define iswxdigit rpl_iswxdigit
115# define towlower rpl_towlower 154# endif
116# define towupper rpl_towupper 155# endif
156# if @REPLACE_TOWLOWER@
157# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
158# define towlower rpl_towlower
159# define towupper rpl_towupper
160# endif
117# endif 161# endif
118# endif
119 162
120static inline int 163_GL_WCTYPE_INLINE int
121# if @REPLACE_ISWCNTRL@ 164# if @REPLACE_ISWCNTRL@
122rpl_iswalnum 165rpl_iswalnum
123# else 166# else
124iswalnum 167iswalnum
125# endif 168# endif
126 (wint_t wc) 169 (wint_t wc)
127{ 170{
128 return ((wc >= '0' && wc <= '9') 171 return ((wc >= '0' && wc <= '9')
129 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')); 172 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'));
130} 173}
131 174
132static inline int 175_GL_WCTYPE_INLINE int
133# if @REPLACE_ISWCNTRL@ 176# if @REPLACE_ISWCNTRL@
134rpl_iswalpha 177rpl_iswalpha
135# else 178# else
136iswalpha 179iswalpha
137# endif 180# endif
138 (wint_t wc) 181 (wint_t wc)
139{ 182{
140 return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'; 183 return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z';
141} 184}
142 185
143static inline int 186_GL_WCTYPE_INLINE int
144# if @REPLACE_ISWCNTRL@ 187# if @REPLACE_ISWCNTRL@
145rpl_iswblank 188rpl_iswblank
146# else 189# else
147iswblank 190iswblank
148# endif 191# endif
149 (wint_t wc) 192 (wint_t wc)
150{ 193{
151 return wc == ' ' || wc == '\t'; 194 return wc == ' ' || wc == '\t';
152} 195}
153 196
154static inline int 197_GL_WCTYPE_INLINE int
155# if @REPLACE_ISWCNTRL@ 198# if @REPLACE_ISWCNTRL@
156rpl_iswcntrl 199rpl_iswcntrl
157# else 200# else
158iswcntrl 201iswcntrl
159# endif 202# endif
160 (wint_t wc) 203 (wint_t wc)
161{ 204{
162 return (wc & ~0x1f) == 0 || wc == 0x7f; 205 return (wc & ~0x1f) == 0 || wc == 0x7f;
163} 206}
164 207
165static inline int 208_GL_WCTYPE_INLINE int
166# if @REPLACE_ISWCNTRL@ 209# if @REPLACE_ISWCNTRL@
167rpl_iswdigit 210rpl_iswdigit
168# else 211# else
169iswdigit 212iswdigit
170# endif 213# endif
171 (wint_t wc) 214 (wint_t wc)
172{ 215{
173 return wc >= '0' && wc <= '9'; 216 return wc >= '0' && wc <= '9';
174} 217}
175 218
176static inline int 219_GL_WCTYPE_INLINE int
177# if @REPLACE_ISWCNTRL@ 220# if @REPLACE_ISWCNTRL@
178rpl_iswgraph 221rpl_iswgraph
179# else 222# else
180iswgraph 223iswgraph
181# endif 224# endif
182 (wint_t wc) 225 (wint_t wc)
183{ 226{
184 return wc >= '!' && wc <= '~'; 227 return wc >= '!' && wc <= '~';
185} 228}
186 229
187static inline int 230_GL_WCTYPE_INLINE int
188# if @REPLACE_ISWCNTRL@ 231# if @REPLACE_ISWCNTRL@
189rpl_iswlower 232rpl_iswlower
190# else 233# else
191iswlower 234iswlower
192# endif 235# endif
193 (wint_t wc) 236 (wint_t wc)
194{ 237{
195 return wc >= 'a' && wc <= 'z'; 238 return wc >= 'a' && wc <= 'z';
196} 239}
197 240
198static inline int 241_GL_WCTYPE_INLINE int
199# if @REPLACE_ISWCNTRL@ 242# if @REPLACE_ISWCNTRL@
200rpl_iswprint 243rpl_iswprint
201# else 244# else
202iswprint 245iswprint
203# endif 246# endif
204 (wint_t wc) 247 (wint_t wc)
205{ 248{
206 return wc >= ' ' && wc <= '~'; 249 return wc >= ' ' && wc <= '~';
207} 250}
208 251
209static inline int 252_GL_WCTYPE_INLINE int
210# if @REPLACE_ISWCNTRL@ 253# if @REPLACE_ISWCNTRL@
211rpl_iswpunct 254rpl_iswpunct
212# else 255# else
213iswpunct 256iswpunct
214# endif 257# endif
215 (wint_t wc) 258 (wint_t wc)
216{ 259{
217 return (wc >= '!' && wc <= '~' 260 return (wc >= '!' && wc <= '~'
@@ -219,75 +262,78 @@ iswpunct
219 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'))); 262 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')));
220} 263}
221 264
222static inline int 265_GL_WCTYPE_INLINE int
223# if @REPLACE_ISWCNTRL@ 266# if @REPLACE_ISWCNTRL@
224rpl_iswspace 267rpl_iswspace
225# else 268# else
226iswspace 269iswspace
227# endif 270# endif
228 (wint_t wc) 271 (wint_t wc)
229{ 272{
230 return (wc == ' ' || wc == '\t' 273 return (wc == ' ' || wc == '\t'
231 || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r'); 274 || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r');
232} 275}
233 276
234static inline int 277_GL_WCTYPE_INLINE int
235# if @REPLACE_ISWCNTRL@ 278# if @REPLACE_ISWCNTRL@
236rpl_iswupper 279rpl_iswupper
237# else 280# else
238iswupper 281iswupper
239# endif 282# endif
240 (wint_t wc) 283 (wint_t wc)
241{ 284{
242 return wc >= 'A' && wc <= 'Z'; 285 return wc >= 'A' && wc <= 'Z';
243} 286}
244 287
245static inline int 288_GL_WCTYPE_INLINE int
246# if @REPLACE_ISWCNTRL@ 289# if @REPLACE_ISWCNTRL@
247rpl_iswxdigit 290rpl_iswxdigit
248# else 291# else
249iswxdigit 292iswxdigit
250# endif 293# endif
251 (wint_t wc) 294 (wint_t wc)
252{ 295{
253 return ((wc >= '0' && wc <= '9') 296 return ((wc >= '0' && wc <= '9')
254 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F')); 297 || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F'));
255} 298}
256 299
257static inline wint_t 300_GL_WCTYPE_INLINE wint_t
258# if @REPLACE_ISWCNTRL@ 301# if @REPLACE_TOWLOWER@
259rpl_towlower 302rpl_towlower
260# else 303# else
261towlower 304towlower
262# endif 305# endif
263 (wint_t wc) 306 (wint_t wc)
264{ 307{
265 return (wc >= 'A' && wc <= 'Z' ? wc - 'A' + 'a' : wc); 308 return (wc >= 'A' && wc <= 'Z' ? wc - 'A' + 'a' : wc);
266} 309}
267 310
268static inline wint_t 311_GL_WCTYPE_INLINE wint_t
269# if @REPLACE_ISWCNTRL@ 312# if @REPLACE_TOWLOWER@
270rpl_towupper 313rpl_towupper
271# else 314# else
272towupper 315towupper
273# endif 316# endif
274 (wint_t wc) 317 (wint_t wc)
275{ 318{
276 return (wc >= 'a' && wc <= 'z' ? wc - 'a' + 'A' : wc); 319 return (wc >= 'a' && wc <= 'z' ? wc - 'a' + 'A' : wc);
277} 320}
278 321
279#elif ! @HAVE_ISWBLANK@ 322# elif @GNULIB_ISWBLANK@ && (! @HAVE_ISWBLANK@ || @REPLACE_ISWBLANK@)
280/* Only the iswblank function is missing. */ 323/* Only the iswblank function is missing. */
281 324
282static inline int 325# if @REPLACE_ISWBLANK@
283iswblank (wint_t wc) 326# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
284{ 327# define iswblank rpl_iswblank
285 return wc == ' ' || wc == '\t'; 328# endif
286} 329_GL_FUNCDECL_RPL (iswblank, int, (wint_t wc));
330# else
331_GL_FUNCDECL_SYS (iswblank, int, (wint_t wc));
332# endif
287 333
288#endif 334# endif
289 335
290#if defined __MINGW32__ 336# if defined __MINGW32__
291 337
292/* On native Windows, wchar_t is uint16_t, and wint_t is uint32_t. 338/* On native Windows, wchar_t is uint16_t, and wint_t is uint32_t.
293 The functions towlower and towupper are implemented in the MSVCRT library 339 The functions towlower and towupper are implemented in the MSVCRT library
@@ -302,30 +348,32 @@ iswblank (wint_t wc)
302 result register. We need to fix this by adding a zero-extend from 348 result register. We need to fix this by adding a zero-extend from
303 wchar_t to wint_t after the call. */ 349 wchar_t to wint_t after the call. */
304 350
305static inline wint_t 351_GL_WCTYPE_INLINE wint_t
306rpl_towlower (wint_t wc) 352rpl_towlower (wint_t wc)
307{ 353{
308 return (wint_t) (wchar_t) towlower (wc); 354 return (wint_t) (wchar_t) towlower (wc);
309} 355}
310# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 356# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
311# define towlower rpl_towlower 357# define towlower rpl_towlower
312# endif 358# endif
313 359
314static inline wint_t 360_GL_WCTYPE_INLINE wint_t
315rpl_towupper (wint_t wc) 361rpl_towupper (wint_t wc)
316{ 362{
317 return (wint_t) (wchar_t) towupper (wc); 363 return (wint_t) (wchar_t) towupper (wc);
318} 364}
319# if !(defined __cplusplus && defined GNULIB_NAMESPACE) 365# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
320# define towupper rpl_towupper 366# define towupper rpl_towupper
321# endif 367# endif
368
369# endif /* __MINGW32__ */
322 370
323#endif /* __MINGW32__ */ 371# define GNULIB_defined_wctype_functions 1
372#endif
324 373
325#if @REPLACE_ISWCNTRL@ 374#if @REPLACE_ISWCNTRL@
326_GL_CXXALIAS_RPL (iswalnum, int, (wint_t wc)); 375_GL_CXXALIAS_RPL (iswalnum, int, (wint_t wc));
327_GL_CXXALIAS_RPL (iswalpha, int, (wint_t wc)); 376_GL_CXXALIAS_RPL (iswalpha, int, (wint_t wc));
328_GL_CXXALIAS_RPL (iswblank, int, (wint_t wc));
329_GL_CXXALIAS_RPL (iswcntrl, int, (wint_t wc)); 377_GL_CXXALIAS_RPL (iswcntrl, int, (wint_t wc));
330_GL_CXXALIAS_RPL (iswdigit, int, (wint_t wc)); 378_GL_CXXALIAS_RPL (iswdigit, int, (wint_t wc));
331_GL_CXXALIAS_RPL (iswgraph, int, (wint_t wc)); 379_GL_CXXALIAS_RPL (iswgraph, int, (wint_t wc));
@@ -338,7 +386,6 @@ _GL_CXXALIAS_RPL (iswxdigit, int, (wint_t wc));
338#else 386#else
339_GL_CXXALIAS_SYS (iswalnum, int, (wint_t wc)); 387_GL_CXXALIAS_SYS (iswalnum, int, (wint_t wc));
340_GL_CXXALIAS_SYS (iswalpha, int, (wint_t wc)); 388_GL_CXXALIAS_SYS (iswalpha, int, (wint_t wc));
341_GL_CXXALIAS_SYS (iswblank, int, (wint_t wc));
342_GL_CXXALIAS_SYS (iswcntrl, int, (wint_t wc)); 389_GL_CXXALIAS_SYS (iswcntrl, int, (wint_t wc));
343_GL_CXXALIAS_SYS (iswdigit, int, (wint_t wc)); 390_GL_CXXALIAS_SYS (iswdigit, int, (wint_t wc));
344_GL_CXXALIAS_SYS (iswgraph, int, (wint_t wc)); 391_GL_CXXALIAS_SYS (iswgraph, int, (wint_t wc));
@@ -351,7 +398,6 @@ _GL_CXXALIAS_SYS (iswxdigit, int, (wint_t wc));
351#endif 398#endif
352_GL_CXXALIASWARN (iswalnum); 399_GL_CXXALIASWARN (iswalnum);
353_GL_CXXALIASWARN (iswalpha); 400_GL_CXXALIASWARN (iswalpha);
354_GL_CXXALIASWARN (iswblank);
355_GL_CXXALIASWARN (iswcntrl); 401_GL_CXXALIASWARN (iswcntrl);
356_GL_CXXALIASWARN (iswdigit); 402_GL_CXXALIASWARN (iswdigit);
357_GL_CXXALIASWARN (iswgraph); 403_GL_CXXALIASWARN (iswgraph);
@@ -362,7 +408,55 @@ _GL_CXXALIASWARN (iswspace);
362_GL_CXXALIASWARN (iswupper); 408_GL_CXXALIASWARN (iswupper);
363_GL_CXXALIASWARN (iswxdigit); 409_GL_CXXALIASWARN (iswxdigit);
364 410
365#if @REPLACE_ISWCNTRL@ || defined __MINGW32__ 411#if @GNULIB_ISWBLANK@
412# if @REPLACE_ISWCNTRL@ || @REPLACE_ISWBLANK@
413_GL_CXXALIAS_RPL (iswblank, int, (wint_t wc));
414# else
415_GL_CXXALIAS_SYS (iswblank, int, (wint_t wc));
416# endif
417_GL_CXXALIASWARN (iswblank);
418#endif
419
420#if !@HAVE_WCTYPE_T@
421# if !GNULIB_defined_wctype_t
422typedef void * wctype_t;
423# define GNULIB_defined_wctype_t 1
424# endif
425#endif
426
427/* Get a descriptor for a wide character property. */
428#if @GNULIB_WCTYPE@
429# if !@HAVE_WCTYPE_T@
430_GL_FUNCDECL_SYS (wctype, wctype_t, (const char *name));
431# endif
432_GL_CXXALIAS_SYS (wctype, wctype_t, (const char *name));
433_GL_CXXALIASWARN (wctype);
434#elif defined GNULIB_POSIXCHECK
435# undef wctype
436# if HAVE_RAW_DECL_WCTYPE
437_GL_WARN_ON_USE (wctype, "wctype is unportable - "
438 "use gnulib module wctype for portability");
439# endif
440#endif
441
442/* Test whether a wide character has a given property.
443 The argument WC must be either a wchar_t value or WEOF.
444 The argument DESC must have been returned by the wctype() function. */
445#if @GNULIB_ISWCTYPE@
446# if !@HAVE_WCTYPE_T@
447_GL_FUNCDECL_SYS (iswctype, int, (wint_t wc, wctype_t desc));
448# endif
449_GL_CXXALIAS_SYS (iswctype, int, (wint_t wc, wctype_t desc));
450_GL_CXXALIASWARN (iswctype);
451#elif defined GNULIB_POSIXCHECK
452# undef iswctype
453# if HAVE_RAW_DECL_ISWCTYPE
454_GL_WARN_ON_USE (iswctype, "iswctype is unportable - "
455 "use gnulib module iswctype for portability");
456# endif
457#endif
458
459#if @REPLACE_TOWLOWER@ || defined __MINGW32__
366_GL_CXXALIAS_RPL (towlower, wint_t, (wint_t wc)); 460_GL_CXXALIAS_RPL (towlower, wint_t, (wint_t wc));
367_GL_CXXALIAS_RPL (towupper, wint_t, (wint_t wc)); 461_GL_CXXALIAS_RPL (towupper, wint_t, (wint_t wc));
368#else 462#else
@@ -372,6 +466,46 @@ _GL_CXXALIAS_SYS (towupper, wint_t, (wint_t wc));
372_GL_CXXALIASWARN (towlower); 466_GL_CXXALIASWARN (towlower);
373_GL_CXXALIASWARN (towupper); 467_GL_CXXALIASWARN (towupper);
374 468
469#if !@HAVE_WCTRANS_T@
470# if !GNULIB_defined_wctrans_t
471typedef void * wctrans_t;
472# define GNULIB_defined_wctrans_t 1
473# endif
474#endif
475
476/* Get a descriptor for a wide character case conversion. */
477#if @GNULIB_WCTRANS@
478# if !@HAVE_WCTRANS_T@
479_GL_FUNCDECL_SYS (wctrans, wctrans_t, (const char *name));
480# endif
481_GL_CXXALIAS_SYS (wctrans, wctrans_t, (const char *name));
482_GL_CXXALIASWARN (wctrans);
483#elif defined GNULIB_POSIXCHECK
484# undef wctrans
485# if HAVE_RAW_DECL_WCTRANS
486_GL_WARN_ON_USE (wctrans, "wctrans is unportable - "
487 "use gnulib module wctrans for portability");
488# endif
489#endif
490
491/* Perform a given case conversion on a wide character.
492 The argument WC must be either a wchar_t value or WEOF.
493 The argument DESC must have been returned by the wctrans() function. */
494#if @GNULIB_TOWCTRANS@
495# if !@HAVE_WCTRANS_T@
496_GL_FUNCDECL_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc));
497# endif
498_GL_CXXALIAS_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc));
499_GL_CXXALIASWARN (towctrans);
500#elif defined GNULIB_POSIXCHECK
501# undef towctrans
502# if HAVE_RAW_DECL_TOWCTRANS
503_GL_WARN_ON_USE (towctrans, "towctrans is unportable - "
504 "use gnulib module towctrans for portability");
505# endif
506#endif
507
508_GL_INLINE_HEADER_END
375 509
376#endif /* _GL_WCTYPE_H */ 510#endif /* _@GUARD_PREFIX@_WCTYPE_H */
377#endif /* _GL_WCTYPE_H */ 511#endif /* _@GUARD_PREFIX@_WCTYPE_H */
diff --git a/gl/write.c b/gl/write.c
deleted file mode 100644
index 3a98f24..0000000
--- a/gl/write.c
+++ /dev/null
@@ -1,62 +0,0 @@
1/* POSIX compatible write() function.
2 Copyright (C) 2008-2010 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 ((HANDLE) _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-die.c b/gl/xalloc-die.c
index 4b22040..daa403b 100644
--- a/gl/xalloc-die.c
+++ b/gl/xalloc-die.c
@@ -1,7 +1,7 @@
1/* Report a memory allocation failure and exit. 1/* Report a memory allocation failure and exit.
2 2
3 Copyright (C) 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2006, 2009, 2010 3 Copyright (C) 1997-2000, 2002-2004, 2006, 2009-2013 Free Software
4 Free Software Foundation, Inc. 4 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
@@ -33,7 +33,7 @@ xalloc_die (void)
33{ 33{
34 error (exit_failure, 0, "%s", _("memory exhausted")); 34 error (exit_failure, 0, "%s", _("memory exhausted"));
35 35
36 /* The `noreturn' cannot be given to error, since it may return if 36 /* _Noreturn cannot be given to error, since it may return if
37 its first argument is 0. To help compilers understand the 37 its first argument is 0. To help compilers understand the
38 xalloc_die does not return, call abort. Also, the abort is a 38 xalloc_die does not return, call abort. Also, the abort is a
39 safety feature if exit_failure is 0 (which shouldn't happen). */ 39 safety feature if exit_failure is 0 (which shouldn't happen). */
diff --git a/gl/xalloc-oversized.h b/gl/xalloc-oversized.h
new file mode 100644
index 0000000..a971c78
--- /dev/null
+++ b/gl/xalloc-oversized.h
@@ -0,0 +1,38 @@
1/* xalloc-oversized.h -- memory allocation size checking
2
3 Copyright (C) 1990-2000, 2003-2004, 2006-2013 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#ifndef XALLOC_OVERSIZED_H_
19# define XALLOC_OVERSIZED_H_
20
21# include <stddef.h>
22
23/* Return 1 if an array of N objects, each of size S, cannot exist due
24 to size arithmetic overflow. S must be positive and N must be
25 nonnegative. This is a macro, not a function, so that it
26 works correctly even when SIZE_MAX < N.
27
28 By gnulib convention, SIZE_MAX represents overflow in size
29 calculations, so the conservative dividend to use here is
30 SIZE_MAX - 1, since SIZE_MAX might represent an overflowed value.
31 However, malloc (SIZE_MAX) fails on all known hosts where
32 sizeof (ptrdiff_t) <= sizeof (size_t), so do not bother to test for
33 exactly-SIZE_MAX allocations on such hosts; this avoids a test and
34 branch when S is known to be 1. */
35# define xalloc_oversized(n, s) \
36 ((size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) < (n))
37
38#endif /* !XALLOC_OVERSIZED_H_ */
diff --git a/gl/xalloc.h b/gl/xalloc.h
index 6122cc5..da7c4b6 100644
--- a/gl/xalloc.h
+++ b/gl/xalloc.h
@@ -1,8 +1,6 @@
1/* xalloc.h -- malloc with out-of-memory checking 1/* xalloc.h -- malloc with out-of-memory checking
2 2
3 Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 3 Copyright (C) 1990-2000, 2003-2004, 2006-2013 Free Software Foundation, Inc.
4 2000, 2003, 2004, 2006, 2007, 2008, 2009, 2010 Free Software Foundation,
5 Inc.
6 4
7 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
8 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
@@ -18,64 +16,54 @@
18 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/>. */
19 17
20#ifndef XALLOC_H_ 18#ifndef XALLOC_H_
21# define XALLOC_H_ 19#define XALLOC_H_
22 20
23# include <stddef.h> 21#include <stddef.h>
24 22
23#include "xalloc-oversized.h"
25 24
26# ifdef __cplusplus 25_GL_INLINE_HEADER_BEGIN
27extern "C" { 26#ifndef XALLOC_INLINE
28# endif 27# define XALLOC_INLINE _GL_INLINE
28#endif
29 29
30#ifdef __cplusplus
31extern "C" {
32#endif
30 33
31# ifndef __attribute__
32# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
33# define __attribute__(x)
34# endif
35# endif
36 34
37# ifndef ATTRIBUTE_NORETURN 35#if __GNUC__ >= 3
38# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) 36# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
39# endif 37#else
38# define _GL_ATTRIBUTE_MALLOC
39#endif
40 40
41# ifndef ATTRIBUTE_MALLOC 41#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
42# if __GNUC__ >= 3 42# define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
43# define ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) 43#else
44# else 44# define _GL_ATTRIBUTE_ALLOC_SIZE(args)
45# define ATTRIBUTE_MALLOC 45#endif
46# endif
47# endif
48 46
49/* This function is always triggered when memory is exhausted. 47/* This function is always triggered when memory is exhausted.
50 It must be defined by the application, either explicitly 48 It must be defined by the application, either explicitly
51 or by using gnulib's xalloc-die module. This is the 49 or by using gnulib's xalloc-die module. This is the
52 function to call when one wants the program to die because of a 50 function to call when one wants the program to die because of a
53 memory allocation failure. */ 51 memory allocation failure. */
54extern void xalloc_die (void) ATTRIBUTE_NORETURN; 52extern _Noreturn void xalloc_die (void);
55 53
56void *xmalloc (size_t s) ATTRIBUTE_MALLOC; 54void *xmalloc (size_t s)
57void *xzalloc (size_t s) ATTRIBUTE_MALLOC; 55 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1));
58void *xcalloc (size_t n, size_t s) ATTRIBUTE_MALLOC; 56void *xzalloc (size_t s)
59void *xrealloc (void *p, size_t s); 57 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1));
58void *xcalloc (size_t n, size_t s)
59 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2));
60void *xrealloc (void *p, size_t s)
61 _GL_ATTRIBUTE_ALLOC_SIZE ((2));
60void *x2realloc (void *p, size_t *pn); 62void *x2realloc (void *p, size_t *pn);
61void *xmemdup (void const *p, size_t s) ATTRIBUTE_MALLOC; 63void *xmemdup (void const *p, size_t s)
62char *xstrdup (char const *str) ATTRIBUTE_MALLOC; 64 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((2));
63 65char *xstrdup (char const *str)
64/* Return 1 if an array of N objects, each of size S, cannot exist due 66 _GL_ATTRIBUTE_MALLOC;
65 to size arithmetic overflow. S must be positive and N must be
66 nonnegative. This is a macro, not an inline function, so that it
67 works correctly even when SIZE_MAX < N.
68
69 By gnulib convention, SIZE_MAX represents overflow in size
70 calculations, so the conservative dividend to use here is
71 SIZE_MAX - 1, since SIZE_MAX might represent an overflowed value.
72 However, malloc (SIZE_MAX) fails on all known hosts where
73 sizeof (ptrdiff_t) <= sizeof (size_t), so do not bother to test for
74 exactly-SIZE_MAX allocations on such hosts; this avoids a test and
75 branch when S is known to be 1. */
76# define xalloc_oversized(n, s) \
77 ((size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) < (n))
78
79 67
80/* In the following macros, T must be an elementary or structure/union or 68/* In the following macros, T must be an elementary or structure/union or
81 typedef'ed type, or a pointer to such a type. To apply one of the 69 typedef'ed type, or a pointer to such a type. To apply one of the
@@ -84,41 +72,31 @@ char *xstrdup (char const *str) ATTRIBUTE_MALLOC;
84 72
85/* Allocate an object of type T dynamically, with error checking. */ 73/* Allocate an object of type T dynamically, with error checking. */
86/* extern t *XMALLOC (typename t); */ 74/* extern t *XMALLOC (typename t); */
87# define XMALLOC(t) ((t *) xmalloc (sizeof (t))) 75#define XMALLOC(t) ((t *) xmalloc (sizeof (t)))
88 76
89/* Allocate memory for N elements of type T, with error checking. */ 77/* Allocate memory for N elements of type T, with error checking. */
90/* extern t *XNMALLOC (size_t n, typename t); */ 78/* extern t *XNMALLOC (size_t n, typename t); */
91# define XNMALLOC(n, t) \ 79#define XNMALLOC(n, t) \
92 ((t *) (sizeof (t) == 1 ? xmalloc (n) : xnmalloc (n, sizeof (t)))) 80 ((t *) (sizeof (t) == 1 ? xmalloc (n) : xnmalloc (n, sizeof (t))))
93 81
94/* Allocate an object of type T dynamically, with error checking, 82/* Allocate an object of type T dynamically, with error checking,
95 and zero it. */ 83 and zero it. */
96/* extern t *XZALLOC (typename t); */ 84/* extern t *XZALLOC (typename t); */
97# define XZALLOC(t) ((t *) xzalloc (sizeof (t))) 85#define XZALLOC(t) ((t *) xzalloc (sizeof (t)))
98 86
99/* Allocate memory for N elements of type T, with error checking, 87/* Allocate memory for N elements of type T, with error checking,
100 and zero it. */ 88 and zero it. */
101/* extern t *XCALLOC (size_t n, typename t); */ 89/* extern t *XCALLOC (size_t n, typename t); */
102# define XCALLOC(n, t) \ 90#define XCALLOC(n, t) \
103 ((t *) (sizeof (t) == 1 ? xzalloc (n) : xcalloc (n, sizeof (t)))) 91 ((t *) (sizeof (t) == 1 ? xzalloc (n) : xcalloc (n, sizeof (t))))
104
105 92
106# if HAVE_INLINE
107# define static_inline static inline
108# else
109void *xnmalloc (size_t n, size_t s) ATTRIBUTE_MALLOC;
110void *xnrealloc (void *p, size_t n, size_t s);
111void *x2nrealloc (void *p, size_t *pn, size_t s);
112char *xcharalloc (size_t n) ATTRIBUTE_MALLOC;
113# endif
114
115# ifdef static_inline
116 93
117/* Allocate an array of N objects, each with S bytes of memory, 94/* Allocate an array of N objects, each with S bytes of memory,
118 dynamically, with error checking. S must be nonzero. */ 95 dynamically, with error checking. S must be nonzero. */
119 96
120static_inline void *xnmalloc (size_t n, size_t s) ATTRIBUTE_MALLOC; 97XALLOC_INLINE void *xnmalloc (size_t n, size_t s)
121static_inline void * 98 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2));
99XALLOC_INLINE void *
122xnmalloc (size_t n, size_t s) 100xnmalloc (size_t n, size_t s)
123{ 101{
124 if (xalloc_oversized (n, s)) 102 if (xalloc_oversized (n, s))
@@ -129,7 +107,9 @@ xnmalloc (size_t n, size_t s)
129/* Change the size of an allocated block of memory P to an array of N 107/* Change the size of an allocated block of memory P to an array of N
130 objects each of S bytes, with error checking. S must be nonzero. */ 108 objects each of S bytes, with error checking. S must be nonzero. */
131 109
132static_inline void * 110XALLOC_INLINE void *xnrealloc (void *p, size_t n, size_t s)
111 _GL_ATTRIBUTE_ALLOC_SIZE ((2, 3));
112XALLOC_INLINE void *
133xnrealloc (void *p, size_t n, size_t s) 113xnrealloc (void *p, size_t n, size_t s)
134{ 114{
135 if (xalloc_oversized (n, s)) 115 if (xalloc_oversized (n, s))
@@ -192,7 +172,7 @@ xnrealloc (void *p, size_t n, size_t s)
192 172
193 */ 173 */
194 174
195static_inline void * 175XALLOC_INLINE void *
196x2nrealloc (void *p, size_t *pn, size_t s) 176x2nrealloc (void *p, size_t *pn, size_t s)
197{ 177{
198 size_t n = *pn; 178 size_t n = *pn;
@@ -203,9 +183,9 @@ x2nrealloc (void *p, size_t *pn, size_t s)
203 { 183 {
204 /* The approximate size to use for initial small allocation 184 /* The approximate size to use for initial small allocation
205 requests, when the invoking code specifies an old size of 185 requests, when the invoking code specifies an old size of
206 zero. 64 bytes is the largest "small" request for the 186 zero. This is the largest "small" request for the GNU C
207 GNU C library malloc. */ 187 library malloc. */
208 enum { DEFAULT_MXFAST = 64 }; 188 enum { DEFAULT_MXFAST = 64 * sizeof (size_t) / 4 };
209 189
210 n = DEFAULT_MXFAST / s; 190 n = DEFAULT_MXFAST / s;
211 n += !n; 191 n += !n;
@@ -229,16 +209,15 @@ x2nrealloc (void *p, size_t *pn, size_t s)
229/* Return a pointer to a new buffer of N bytes. This is like xmalloc, 209/* Return a pointer to a new buffer of N bytes. This is like xmalloc,
230 except it returns char *. */ 210 except it returns char *. */
231 211
232static_inline char *xcharalloc (size_t n) ATTRIBUTE_MALLOC; 212XALLOC_INLINE char *xcharalloc (size_t n)
233static_inline char * 213 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1));
214XALLOC_INLINE char *
234xcharalloc (size_t n) 215xcharalloc (size_t n)
235{ 216{
236 return XNMALLOC (n, char); 217 return XNMALLOC (n, char);
237} 218}
238 219
239# endif 220#ifdef __cplusplus
240
241# ifdef __cplusplus
242} 221}
243 222
244/* C++ does not allow conversions from void * to other pointer types 223/* C++ does not allow conversions from void * to other pointer types
@@ -275,7 +254,7 @@ xmemdup (T const *p, size_t s)
275 return (T *) xmemdup ((void const *) p, s); 254 return (T *) xmemdup ((void const *) p, s);
276} 255}
277 256
278# endif 257#endif
279 258
280 259
281#endif /* !XALLOC_H_ */ 260#endif /* !XALLOC_H_ */
diff --git a/gl/xmalloc.c b/gl/xmalloc.c
index ecce529..57e34b7 100644
--- a/gl/xmalloc.c
+++ b/gl/xmalloc.c
@@ -1,8 +1,6 @@
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, 1999, 3 Copyright (C) 1990-2000, 2002-2006, 2008-2013 Free Software Foundation, Inc.
4 2000, 2002, 2003, 2004, 2005, 2006, 2008, 2009, 2010 Free Software
5 Foundation, Inc.
6 4
7 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
8 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
@@ -19,19 +17,17 @@
19 17
20#include <config.h> 18#include <config.h>
21 19
22#if ! HAVE_INLINE 20#define XALLOC_INLINE _GL_EXTERN_INLINE
23# define static_inline 21
24#endif
25#include "xalloc.h" 22#include "xalloc.h"
26#undef static_inline
27 23
28#include <stdlib.h> 24#include <stdlib.h>
29#include <string.h> 25#include <string.h>
30 26
31/* 1 if calloc is known to be compatible with GNU calloc. This 27/* 1 if calloc is known to be compatible with GNU calloc. This
32 matters if we are not also using the calloc module, which defines 28 matters if we are not also using the calloc module, which defines
33 HAVE_CALLOC and supports the GNU API even on non-GNU platforms. */ 29 HAVE_CALLOC_GNU and supports the GNU API even on non-GNU platforms. */
34#if defined HAVE_CALLOC || defined __GLIBC__ 30#if defined HAVE_CALLOC_GNU || (defined __GLIBC__ && !defined __UCLIBC__)
35enum { HAVE_GNU_CALLOC = 1 }; 31enum { HAVE_GNU_CALLOC = 1 };
36#else 32#else
37enum { HAVE_GNU_CALLOC = 0 }; 33enum { HAVE_GNU_CALLOC = 0 };
@@ -54,8 +50,16 @@ xmalloc (size_t n)
54void * 50void *
55xrealloc (void *p, size_t n) 51xrealloc (void *p, size_t n)
56{ 52{
53 if (!n && p)
54 {
55 /* The GNU and C99 realloc behaviors disagree here. Act like
56 GNU, even if the underlying realloc is C99. */
57 free (p);
58 return NULL;
59 }
60
57 p = realloc (p, n); 61 p = realloc (p, n);
58 if (!p && n != 0) 62 if (!p && n)
59 xalloc_die (); 63 xalloc_die ();
60 return p; 64 return p;
61} 65}
diff --git a/gl/xsize.c b/gl/xsize.c
new file mode 100644
index 0000000..4b4914c
--- /dev/null
+++ b/gl/xsize.c
@@ -0,0 +1,3 @@
1#include <config.h>
2#define XSIZE_INLINE _GL_EXTERN_INLINE
3#include "xsize.h"
diff --git a/gl/xsize.h b/gl/xsize.h
index fbd6329..2922f35 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, 2008, 2009, 2010 Free Software Foundation, Inc. 3 Copyright (C) 2003, 2008-2013 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
@@ -13,8 +13,7 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
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, write to the Free Software Foundation, 16 along with this program; if not, see <http://www.gnu.org/licenses/>. */
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 17
19#ifndef _XSIZE_H 18#ifndef _XSIZE_H
20#define _XSIZE_H 19#define _XSIZE_H
@@ -28,6 +27,11 @@
28# include <stdint.h> 27# include <stdint.h>
29#endif 28#endif
30 29
30_GL_INLINE_HEADER_BEGIN
31#ifndef XSIZE_INLINE
32# define XSIZE_INLINE _GL_INLINE
33#endif
34
31/* The size of memory objects is often computed through expressions of 35/* The size of memory objects is often computed through expressions of
32 type size_t. Example: 36 type size_t. Example:
33 void* p = malloc (header_size + n * element_size). 37 void* p = malloc (header_size + n * element_size).
@@ -49,7 +53,7 @@
49 ((N) <= SIZE_MAX ? (size_t) (N) : SIZE_MAX) 53 ((N) <= SIZE_MAX ? (size_t) (N) : SIZE_MAX)
50 54
51/* Sum of two sizes, with overflow check. */ 55/* Sum of two sizes, with overflow check. */
52static inline size_t 56XSIZE_INLINE size_t
53#if __GNUC__ >= 3 57#if __GNUC__ >= 3
54__attribute__ ((__pure__)) 58__attribute__ ((__pure__))
55#endif 59#endif
@@ -60,7 +64,7 @@ xsum (size_t size1, size_t size2)
60} 64}
61 65
62/* Sum of three sizes, with overflow check. */ 66/* Sum of three sizes, with overflow check. */
63static inline size_t 67XSIZE_INLINE size_t
64#if __GNUC__ >= 3 68#if __GNUC__ >= 3
65__attribute__ ((__pure__)) 69__attribute__ ((__pure__))
66#endif 70#endif
@@ -70,7 +74,7 @@ xsum3 (size_t size1, size_t size2, size_t size3)
70} 74}
71 75
72/* Sum of four sizes, with overflow check. */ 76/* Sum of four sizes, with overflow check. */
73static inline size_t 77XSIZE_INLINE size_t
74#if __GNUC__ >= 3 78#if __GNUC__ >= 3
75__attribute__ ((__pure__)) 79__attribute__ ((__pure__))
76#endif 80#endif
@@ -80,7 +84,7 @@ xsum4 (size_t size1, size_t size2, size_t size3, size_t size4)
80} 84}
81 85
82/* Maximum of two sizes, with overflow check. */ 86/* Maximum of two sizes, with overflow check. */
83static inline size_t 87XSIZE_INLINE size_t
84#if __GNUC__ >= 3 88#if __GNUC__ >= 3
85__attribute__ ((__pure__)) 89__attribute__ ((__pure__))
86#endif 90#endif
@@ -93,7 +97,7 @@ xmax (size_t size1, size_t size2)
93 97
94/* Multiplication of a count with an element size, with overflow check. 98/* Multiplication of a count with an element size, with overflow check.
95 The count must be >= 0 and the element size must be > 0. 99 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 100 This is a macro, not a function, so that it works correctly even
97 when N is of a wider type and N > SIZE_MAX. */ 101 when N is of a wider type and N > SIZE_MAX. */
98#define xtimes(N, ELSIZE) \ 102#define xtimes(N, ELSIZE) \
99 ((N) <= SIZE_MAX / (ELSIZE) ? (size_t) (N) * (ELSIZE) : SIZE_MAX) 103 ((N) <= SIZE_MAX / (ELSIZE) ? (size_t) (N) * (ELSIZE) : SIZE_MAX)
@@ -105,4 +109,6 @@ xmax (size_t size1, size_t size2)
105#define size_in_bounds_p(SIZE) \ 109#define size_in_bounds_p(SIZE) \
106 ((SIZE) != SIZE_MAX) 110 ((SIZE) != SIZE_MAX)
107 111
112_GL_INLINE_HEADER_END
113
108#endif /* _XSIZE_H */ 114#endif /* _XSIZE_H */
diff --git a/gl/xstrndup.c b/gl/xstrndup.c
index 414f9f4..eae92d0 100644
--- a/gl/xstrndup.c
+++ b/gl/xstrndup.c
@@ -1,6 +1,6 @@
1/* Duplicate a bounded initial segment of a string, with out-of-memory 1/* Duplicate a bounded initial segment of a string, with out-of-memory
2 checking. 2 checking.
3 Copyright (C) 2003, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. 3 Copyright (C) 2003, 2006-2007, 2009-2013 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
diff --git a/gl/xstrndup.h b/gl/xstrndup.h
index 009fdb0..59673b0 100644
--- a/gl/xstrndup.h
+++ b/gl/xstrndup.h
@@ -1,6 +1,6 @@
1/* Duplicate a bounded initial segment of a string, with out-of-memory 1/* Duplicate a bounded initial segment of a string, with out-of-memory
2 checking. 2 checking.
3 Copyright (C) 2003, 2009, 2010 Free Software Foundation, Inc. 3 Copyright (C) 2003, 2009-2013 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