prelude-lml/master: Support for character encoding and convertion to UTF-8

[email protected] Mon, 11 Jan 2010 17:51:03 +0100 (CET)
Newsgroups gmane.comp.security.ids.prelude.cvs
Message-ID <[email protected]>
commit 5745fc15c77da8e42f9f44775de1fb920bfed368
Author: Yoann Vandoorselaere <[email protected]>
Date:   Wed Dec 30 16:43:57 2009 +0100

    Support for character encoding and convertion to UTF-8
    
    The [format] configuration section now allow an optional character set to
    be specified. In case the section handle multiple files, it is permitted
    to set the option several time:
    
    [format=syslog]
    charset = ISO8859-1
    file = file1
    file = file2
    charset = UTF-8
    file = file3
    
    When the character set is not specified, the implementation will attempt to
    detect the character set used for a given file. In case the detection fail,
    the system default will be used.
    
    Log entry are now converted to UTF-8 before processing. This fixes a problem
    where user could see incorrect characters in reported alert, since they were
    carrying data that could involve differents character set.
    
    At the PCRE matching level, it has been decided that UTF-8 support is enabled
    only for rules that specifically use UTF-8 within their 'regex' part due to the
    high CPU costs required for UTF-8 strings processing.
    
    Note that this shouldn't be a problem since most log entry use ASCII for the
    static part of the log. Part of a log that might use specific character encoding
    are the 'dynamic' part of a reported log entry (example: the reported username).
    
    Character set encoding conversion is done using libicu if available, or iconv in
    case it isn't. A libiconv replacement is also provided through libmissing in case
    none of them is available. Please note that character set detection is only
    supported using the libICU backend.


========================================

 arg-nonnull.h                         |   26 +
 config.rpath                          |  672 +++
 configure.in                          |   14 +-
 libmissing/Makefile.am                |  515 ++-
 libmissing/alloca.c                   |  154 +-
 libmissing/alloca.in.h                |    4 +-
 libmissing/arpa_inet.in.h             |   19 +-
 libmissing/asnprintf.c                |    2 +-
 libmissing/bind.c                     |    2 +-
 libmissing/close-hook.c               |    2 +-
 libmissing/close.c                    |    2 +-
 libmissing/config.charset             | 1114 +++---
 libmissing/dirent.in.h                |   46 +-
 libmissing/dirfd.c                    |    2 +-
 libmissing/fclose.c                   |    2 +-
 libmissing/float+.h                   |    2 +-
 libmissing/float.in.h                 |    2 +-
 libmissing/fnmatch.c                  |  202 +-
 libmissing/fnmatch.in.h               |   35 +-
 libmissing/fnmatch_loop.c             | 1878 ++++----
 libmissing/getaddrinfo.c              |  171 +-
 libmissing/getlogin_r.c               |    2 +-
 libmissing/getpagesize.c              |   39 -
 libmissing/getpeername.c              |    2 +-
 libmissing/gettext.h                  |   28 +-
 libmissing/glob-libc.h                |  106 +-
 libmissing/glob.c                     | 1731 ++++----
 libmissing/glob.in.h                  |    6 +-
 libmissing/inet_ntop.c                |   92 +-
 libmissing/langinfo.in.h              |  162 +
 libmissing/localcharset.c             |  480 ++-
 libmissing/localcharset.h             |    2 +-
 libmissing/m4/arpa_inet_h.m4          |    2 +-
 libmissing/m4/close.m4                |    9 +-
 libmissing/m4/d-type.m4               |   16 +-
 libmissing/m4/dirent_h.m4             |   23 +-
 libmissing/m4/dirfd.m4                |   40 +-
 libmissing/m4/extensions.m4           |   20 +-
 libmissing/m4/fclose.m4               |    8 +-
 libmissing/m4/fcntl-o.m4              |   81 +
 libmissing/m4/float_h.m4              |    2 +-
 libmissing/m4/getaddrinfo.m4          |   23 +-
 libmissing/m4/getlogin_r.m4           |    2 +-
 libmissing/m4/getpagesize.m4          |   29 -
 libmissing/m4/glibc21.m4              |   10 +-
 libmissing/m4/glob.m4                 |    6 +-
 libmissing/m4/gnulib-cache.m4         |    4 +-
 libmissing/m4/gnulib-common.m4        |   23 +-
 libmissing/m4/gnulib-comp.m4          |   71 +-
 libmissing/m4/gnulib-tool.m4          |    2 +-
 libmissing/m4/hostent.m4              |    2 +-
 libmissing/m4/iconv.m4                |  180 +
 libmissing/m4/include_next.m4         |   78 +-
 libmissing/m4/inet_ntop.m4            |   17 +-
 libmissing/m4/langinfo_h.m4           |   76 +
 libmissing/m4/lib-ld.m4               |  110 +
 libmissing/m4/lib-link.m4             |  764 ++++
 libmissing/m4/lib-prefix.m4           |  224 +
 libmissing/m4/localcharset.m4         |    3 +-
 libmissing/m4/locale-tr.m4            |   97 +
 libmissing/m4/longlong.m4             |   64 +-
 libmissing/m4/mbsinit.m4              |    2 +-
 libmissing/m4/mbstate_t.m4            |   18 +-
 libmissing/m4/memchr.m4               |   10 +-
 libmissing/m4/mktime.m4               |   64 +-
 libmissing/m4/netdb_h.m4              |    2 +-
 libmissing/m4/netinet_in_h.m4         |    2 +-
 libmissing/m4/nl_langinfo.m4          |   29 +
 libmissing/m4/onceonly.m4             |    3 +-
 libmissing/m4/pathmax.m4              |    2 +-
 libmissing/m4/servent.m4              |    2 +-
 libmissing/m4/sigaction.m4            |    2 +-
 libmissing/m4/sleep.m4                |   37 +-
 libmissing/m4/snprintf.m4             |    2 +-
 libmissing/m4/sockets.m4              |   90 +
 libmissing/m4/socklen.m4              |   40 +-
 libmissing/m4/sockpfaf.m4             |   18 +-
 libmissing/m4/stdbool.m4              |  138 +-
 libmissing/m4/stddef_h.m4             |   45 +
 libmissing/m4/stdint.m4               |   12 +-
 libmissing/m4/stdio_h.m4              |  111 +-
 libmissing/m4/stdlib_h.m4             |   27 +-
 libmissing/m4/strerror.m4             |    2 +-
 libmissing/m4/string_h.m4             |   54 +-
 libmissing/m4/strings_h.m4            |    2 +-
 libmissing/m4/sys_select_h.m4         |   33 +-
 libmissing/m4/sys_socket_h.m4         |    6 +-
 libmissing/m4/sys_stat_h.m4           |   56 +-
 libmissing/m4/sys_time_h.m4           |   14 +-
 libmissing/m4/time_h.m4               |   22 +-
 libmissing/m4/time_r.m4               |   20 +-
 libmissing/m4/unistd_h.m4             |   47 +-
 libmissing/m4/wchar.m4                |   58 +-
 libmissing/m4/wctype.m4               |   32 +-
 libmissing/m4/xsize.m4                |    2 +-
 libmissing/malloc.c                   |    2 +-
 libmissing/mbrtowc.c                  |  472 +-
 libmissing/mbsinit.c                  |    2 +-
 libmissing/mbsrtowcs.c                |  168 +-
 libmissing/memchr.c                   |   26 +-
 libmissing/mempcpy.c                  |    2 +-
 libmissing/mktime-internal.h          |    4 +
 libmissing/mktime.c                   |  378 +-
 libmissing/netdb.in.h                 |   88 +-
 libmissing/netinet_in.in.h            |    2 +-
 libmissing/nl_langinfo.c              |  260 ++
 libmissing/pathmax.h                  |    5 +-
 libmissing/printf-args.c              |  211 +-
 libmissing/printf-args.h              |   55 +-
 libmissing/printf-parse.c             |  940 ++--
 libmissing/printf-parse.h             |   21 +-
 libmissing/recvfrom.c                 |    8 +-
 libmissing/ref-add.sin                |    2 +-
 libmissing/ref-del.sin                |    2 +-
 libmissing/sig-handler.h              |    2 +-
 libmissing/sigaction.c                |    4 +-
 libmissing/signal.in.h                |   14 +-
 libmissing/sigprocmask.c              |  158 +-
 libmissing/size_max.h                 |    2 +-
 libmissing/sleep.c                    |   33 +-
 libmissing/snprintf.c                 |   12 +-
 libmissing/socket.c                   |   10 +-
 libmissing/sockets.c                  |  118 +
 libmissing/sockets.h                  |   51 +
 libmissing/stdbool.in.h               |    2 +-
 libmissing/stddef.in.h                |   86 +
 libmissing/stdint.in.h                |    8 +-
 libmissing/stdio-write.c              |   48 +-
 libmissing/stdio.in.h                 |  731 ++--
 libmissing/stdlib.in.h                |  297 +-
 libmissing/strcasecmp.c               |    4 +-
 libmissing/streq.h                    |    2 +-
 libmissing/string.in.h                |  121 +-
 libmissing/strings.in.h               |   10 +-
 libmissing/strncasecmp.c              |    4 +-
 libmissing/strnlen1.c                 |    2 +-
 libmissing/strnlen1.h                 |    2 +-
 libmissing/strptime.c                 | 1616 ++++----
 libmissing/strsep.c                   |    2 +-
 libmissing/sys_select.in.h            |   14 +-
 libmissing/sys_socket.in.h            |   93 +-
 libmissing/sys_stat.in.h              |  237 +-
 libmissing/sys_time.in.h              |    7 +-
 libmissing/tests/Makefile.am          |  194 +-
 libmissing/tests/c-ctype.c            |  396 ++
 libmissing/tests/c-ctype.h            |  295 ++
 libmissing/tests/c-strcase.h          |   56 +
 libmissing/tests/c-strcasecmp.c       |   57 +
 libmissing/tests/c-strncasecmp.c      |   57 +
 libmissing/tests/dummy.c              |   42 -
 libmissing/tests/intprops.h           |   50 +-
 libmissing/tests/macros.h             |   64 +
 libmissing/tests/signature.h          |   48 +
 libmissing/tests/strerror.c           |    8 +-
 libmissing/tests/test-alloca-opt.c    |    2 +-
 libmissing/tests/test-arpa_inet.c     |    4 +-
 libmissing/tests/test-c-ctype.c       |  386 ++
 libmissing/tests/test-c-strcase.sh    |   21 +
 libmissing/tests/test-c-strcasecmp.c  |   65 +
 libmissing/tests/test-c-strncasecmp.c |   79 +
 libmissing/tests/test-dirent.c        |   32 +
 libmissing/tests/test-errno.c         |    2 +-
 libmissing/tests/test-fnmatch.c       |   19 +-
 libmissing/tests/test-getaddrinfo.c   |   81 +-
 libmissing/tests/test-glob.c          |   20 +-
 libmissing/tests/test-iconv.c         |  148 +
 libmissing/tests/test-inet_ntop.c     |   56 +
 libmissing/tests/test-langinfo.c      |   92 +
 libmissing/tests/test-mbrtowc.c       |  461 +-
 libmissing/tests/test-mbsinit.c       |   23 +-
 libmissing/tests/test-mbsrtowcs.c     |  435 +-
 libmissing/tests/test-memchr.c        |   69 +-
 libmissing/tests/test-netdb.c         |    2 +-
 libmissing/tests/test-netinet_in.c    |    4 +-
 libmissing/tests/test-nl_langinfo.c   |  115 +
 libmissing/tests/test-nl_langinfo.sh  |   17 +
 libmissing/tests/test-sigaction.c     |   32 +-
 libmissing/tests/test-signal.c        |    3 +-
 libmissing/tests/test-sleep.c         |   45 +-
 libmissing/tests/test-snprintf.c      |   46 +-
 libmissing/tests/test-sockets.c       |   46 +
 libmissing/tests/test-stdbool.c       |    2 +-
 libmissing/tests/test-stddef.c        |   38 +
 libmissing/tests/test-stdint.c        |    4 +-
 libmissing/tests/test-stdio.c         |    2 +-
 libmissing/tests/test-stdlib.c        |    2 +-
 libmissing/tests/test-strerror.c      |   24 +-
 libmissing/tests/test-string.c        |    2 +-
 libmissing/tests/test-strings.c       |    2 +-
 libmissing/tests/test-sys_select.c    |    9 +-
 libmissing/tests/test-sys_socket.c    |    4 +-
 libmissing/tests/test-sys_stat.c      |   29 +-
 libmissing/tests/test-sys_time.c      |    4 +-
 libmissing/tests/test-time.c          |   10 +-
 libmissing/tests/test-unistd.c        |    2 +-
 libmissing/tests/test-vasnprintf.c    |   23 +-
 libmissing/tests/test-wchar.c         |   10 +-
 libmissing/tests/test-wctype.c        |   32 +-
 libmissing/tests/wctob.c              |    2 +-
 libmissing/tests/zerosize-ptr.h       |    8 +-
 libmissing/time.in.h                  |   34 +-
 libmissing/time_r.c                   |    2 +-
 libmissing/unistd.in.h                |  428 ++-
 libmissing/vasnprintf.c               | 8035 +++++++++++++++++----------------
 libmissing/vasnprintf.h               |    2 +-
 libmissing/verify.h                   |    6 +-
 libmissing/w32sock.h                  |    3 +-
 libmissing/wchar.in.h                 |   14 +-
 libmissing/wctype.in.h                |   59 +-
 libmissing/xsize.h                    |    2 +-
 link-warning.h                        |   29 +-
 m4/ac_check_icu.m4                    |   68 +
 plugins/pcre/rule-regex.c             |   23 +-
 src/Makefile.am                       |    7 +-
 src/include/Makefile.am               |    1 +
 src/include/lml-charset.h             |   32 +
 src/include/lml-options.h             |    3 +
 src/include/log-entry.h               |    2 +-
 src/include/log-source.h              |    4 +-
 src/lml-charset.c                     |  264 ++
 src/lml-options.c                     |   80 +-
 src/log-entry.c                       |    9 +-
 src/log-source.c                      |   68 +-
 src/prelude-lml.c                     |   10 +-
 224 files changed, 18521 insertions(+), 11289 deletions(-)

========================================

diff --git a/arg-nonnull.h b/arg-nonnull.h
new file mode 100644
index 0000000..24ad6b5
--- /dev/null
+++ b/arg-nonnull.h
@@ -0,0 +1,26 @@
+/* A C macro for declaring that specific arguments must not be NULL.
+   Copyright (C) 2009 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published
+   by the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
+   that the values passed as arguments n, ..., m must be non-NULL pointers.
+   n = 1 stands for the first argument, n = 2 for the second argument etc.  */
+#ifndef _GL_ARG_NONNULL
+# if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
+#  define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
+# else
+#  define _GL_ARG_NONNULL(params)
+# endif
+#endif
diff --git a/config.rpath b/config.rpath
new file mode 100755
index 0000000..20778aa
--- /dev/null
+++ b/config.rpath
@@ -0,0 +1,672 @@
+#! /bin/sh
+# Output a system dependent set of variables, describing how to set the
+# run time search path of shared libraries in an executable.
+#
+#   Copyright 1996-2009 Free Software Foundation, Inc.
+#   Taken from GNU libtool, 2001
+#   Originally by Gordon Matzigkeit <[email protected]>, 1996
+#
+#   This file is free software; the Free Software Foundation gives
+#   unlimited permission to copy and/or distribute it, with or without
+#   modifications, as long as this notice is preserved.
+#
+# The first argument passed to this file is the canonical host specification,
+#    CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or
+#    CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld
+# should be set by the caller.
+#
+# The set of defined variables is at the end of this script.
+
+# Known limitations:
+# - On IRIX 6.5 with CC="cc", the run time search patch must not be longer
+#   than 256 bytes, otherwise the compiler driver will dump core. The only
+#   known workaround is to choose shorter directory names for the build
+#   directory and/or the installation directory.
+
+# All known linkers require a `.a' archive for static linking (except MSVC,
+# which needs '.lib').
+libext=a
+shrext=.so
+
+host="$1"
+host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+
+# Code taken from libtool.m4's _LT_CC_BASENAME.
+
+for cc_temp in $CC""; do
+  case $cc_temp in
+    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`echo "$cc_temp" | sed -e 's%^.*/%%'`
+
+# Code taken from libtool.m4's _LT_COMPILER_PIC.
+
+wl=
+if test "$GCC" = yes; then
+  wl='-Wl,'
+else
+  case "$host_os" in
+    aix*)
+      wl='-Wl,'
+      ;;
+    darwin*)
+      case $cc_basename in
+        xlc*)
+          wl='-Wl,'
+          ;;
+      esac
+      ;;
+    mingw* | cygwin* | pw32* | os2* | cegcc*)
+      ;;
+    hpux9* | hpux10* | hpux11*)
+      wl='-Wl,'
+      ;;
+    irix5* | irix6* | nonstopux*)
+      wl='-Wl,'
+      ;;
+    newsos6)
+      ;;
+    linux* | k*bsd*-gnu)
+      case $cc_basename in
+        ecc*)
+          wl='-Wl,'
+          ;;
+        icc* | ifort*)
+          wl='-Wl,'
+          ;;
+        lf95*)
+          wl='-Wl,'
+          ;;
+        pgcc | pgf77 | pgf90)
+          wl='-Wl,'
+          ;;
+        ccc*)
+          wl='-Wl,'
+          ;;
+        como)
+          wl='-lopt='
+          ;;
+        *)
+          case `$CC -V 2>&1 | sed 5q` in
+            *Sun\ C*)
+              wl='-Wl,'
+              ;;
+          esac
+          ;;
+      esac
+      ;;
+    osf3* | osf4* | osf5*)
+      wl='-Wl,'
+      ;;
+    rdos*)
+      ;;
+    solaris*)
+      wl='-Wl,'
+      ;;
+    sunos4*)
+      wl='-Qoption ld '
+      ;;
+    sysv4 | sysv4.2uw2* | sysv4.3*)
+      wl='-Wl,'
+      ;;
+    sysv4*MP*)
+      ;;
+    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+      wl='-Wl,'
+      ;;
+    unicos*)
+      wl='-Wl,'
+      ;;
+    uts4*)
+      ;;
+  esac
+fi
+
+# Code taken from libtool.m4's _LT_LINKER_SHLIBS.
+
+hardcode_libdir_flag_spec=
+hardcode_libdir_separator=
+hardcode_direct=no
+hardcode_minus_L=no
+
+case "$host_os" in
+  cygwin* | mingw* | pw32* | cegcc*)
+    # FIXME: the MSVC++ port hasn't been tested in a loooong time
+    # When not using gcc, we currently assume that we are using
+    # Microsoft Visual C++.
+    if test "$GCC" != yes; then
+      with_gnu_ld=no
+    fi
+    ;;
+  interix*)
+    # we just hope/assume this is gcc and not c89 (= MSVC++)
+    with_gnu_ld=yes
+    ;;
+  openbsd*)
+    with_gnu_ld=no
+    ;;
+esac
+
+ld_shlibs=yes
+if test "$with_gnu_ld" = yes; then
+  # Set some defaults for GNU ld with shared library support. These
+  # are reset later if shared libraries are not supported. Putting them
+  # here allows them to be overridden if necessary.
+  # Unlike libtool, we use -rpath here, not --rpath, since the documented
+  # option of GNU ld is called -rpath, not --rpath.
+  hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+  case "$host_os" in
+    aix[3-9]*)
+      # On AIX/PPC, the GNU linker is very broken
+      if test "$host_cpu" != ia64; then
+        ld_shlibs=no
+      fi
+      ;;
+    amigaos*)
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_minus_L=yes
+      # Samuel A. Falvo II <[email protected]> reports
+      # that the semantics of dynamic libraries on AmigaOS, at least up
+      # to version 4, is to share data among multiple programs linked
+      # with the same dynamic library.  Since this doesn't match the
+      # behavior of shared libraries on other platforms, we cannot use
+      # them.
+      ld_shlibs=no
+      ;;
+    beos*)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+        :
+      else
+        ld_shlibs=no
+      fi
+      ;;
+    cygwin* | mingw* | pw32* | cegcc*)
+      # hardcode_libdir_flag_spec is actually meaningless, as there is
+      # no search path for DLLs.
+      hardcode_libdir_flag_spec='-L$libdir'
+      if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
+        :
+      else
+        ld_shlibs=no
+      fi
+      ;;
+    interix[3-9]*)
+      hardcode_direct=no
+      hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+      ;;
+    gnu* | linux* | k*bsd*-gnu)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+        :
+      else
+        ld_shlibs=no
+      fi
+      ;;
+    netbsd*)
+      ;;
+    solaris*)
+      if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
+        ld_shlibs=no
+      elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+        :
+      else
+        ld_shlibs=no
+      fi
+      ;;
+    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+      case `$LD -v 2>&1` in
+        *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
+          ld_shlibs=no
+          ;;
+        *)
+          if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+            hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
+          else
+            ld_shlibs=no
+          fi
+          ;;
+      esac
+      ;;
+    sunos4*)
+      hardcode_direct=yes
+      ;;
+    *)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+        :
+      else
+        ld_shlibs=no
+      fi
+      ;;
+  esac
+  if test "$ld_shlibs" = no; then
+    hardcode_libdir_flag_spec=
+  fi
+else
+  case "$host_os" in
+    aix3*)
+      # Note: this linker hardcodes the directories in LIBPATH if there
+      # are no directories specified by -L.
+      hardcode_minus_L=yes
+      if test "$GCC" = yes; then
+        # Neither direct hardcoding nor static linking is supported with a
+        # broken collect2.
+        hardcode_direct=unsupported
+      fi
+      ;;
+    aix[4-9]*)
+      if test "$host_cpu" = ia64; then
+        # On IA64, the linker does run time linking by default, so we don't
+        # have to do anything special.
+        aix_use_runtimelinking=no
+      else
+        aix_use_runtimelinking=no
+        # Test if we are trying to use run time linking or normal
+        # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+        # need to do runtime linking.
+        case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
+          for ld_flag in $LDFLAGS; do
+            if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+              aix_use_runtimelinking=yes
+              break
+            fi
+          done
+          ;;
+        esac
+      fi
+      hardcode_direct=yes
+      hardcode_libdir_separator=':'
+      if test "$GCC" = yes; then
+        case $host_os in aix4.[012]|aix4.[012].*)
+          collect2name=`${CC} -print-prog-name=collect2`
+          if test -f "$collect2name" && \
+            strings "$collect2name" | grep resolve_lib_name >/dev/null
+          then
+            # We have reworked collect2
+            :
+          else
+            # We have old collect2
+            hardcode_direct=unsupported
+            hardcode_minus_L=yes
+            hardcode_libdir_flag_spec='-L$libdir'
+            hardcode_libdir_separator=
+          fi
+          ;;
+        esac
+      fi
+      # Begin _LT_AC_SYS_LIBPATH_AIX.
+      echo 'int main () { return 0; }' > conftest.c
+      ${CC} ${LDFLAGS} conftest.c -o conftest
+      aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
+}'`
+      if test -z "$aix_libpath"; then
+        aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
+}'`
+      fi
+      if test -z "$aix_libpath"; then
+        aix_libpath="/usr/lib:/lib"
+      fi
+      rm -f conftest.c conftest
+      # End _LT_AC_SYS_LIBPATH_AIX.
+      if test "$aix_use_runtimelinking" = yes; then
+        hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+      else
+        if test "$host_cpu" = ia64; then
+          hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
+        else
+          hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+        fi
+      fi
+      ;;
+    amigaos*)
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_minus_L=yes
+      # see comment about different semantics on the GNU ld section
+      ld_shlibs=no
+      ;;
+    bsdi[45]*)
+      ;;
+    cygwin* | mingw* | pw32* | cegcc*)
+      # When not using gcc, we currently assume that we are using
+      # Microsoft Visual C++.
+      # hardcode_libdir_flag_spec is actually meaningless, as there is
+      # no search path for DLLs.
+      hardcode_libdir_flag_spec=' '
+      libext=lib
+      ;;
+    darwin* | rhapsody*)
+      hardcode_direct=no
+      if test "$GCC" = yes ; then
+        :
+      else
+        case $cc_basename in
+          xlc*)
+            ;;
+          *)
+            ld_shlibs=no
+            ;;
+        esac
+      fi
+      ;;
+    dgux*)
+      hardcode_libdir_flag_spec='-L$libdir'
+      ;;
+    freebsd1*)
+      ld_shlibs=no
+      ;;
+    freebsd2.2*)
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_direct=yes
+      ;;
+    freebsd2*)
+      hardcode_direct=yes
+      hardcode_minus_L=yes
+      ;;
+    freebsd* | dragonfly*)
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_direct=yes
+      ;;
+    hpux9*)
+      hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+      hardcode_libdir_separator=:
+      hardcode_direct=yes
+      # hardcode_minus_L: Not really in the search PATH,
+      # but as the default location of the library.
+      hardcode_minus_L=yes
+      ;;
+    hpux10*)
+      if test "$with_gnu_ld" = no; then
+        hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+        hardcode_libdir_separator=:
+        hardcode_direct=yes
+        # hardcode_minus_L: Not really in the search PATH,
+        # but as the default location of the library.
+        hardcode_minus_L=yes
+      fi
+      ;;
+    hpux11*)
+      if test "$with_gnu_ld" = no; then
+        hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+        hardcode_libdir_separator=:
+        case $host_cpu in
+          hppa*64*|ia64*)
+            hardcode_direct=no
+            ;;
+          *)
+            hardcode_direct=yes
+            # hardcode_minus_L: Not really in the search PATH,
+            # but as the default location of the library.
+            hardcode_minus_L=yes
+            ;;
+        esac
+      fi
+      ;;
+    irix5* | irix6* | nonstopux*)
+      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator=:
+      ;;
+    netbsd*)
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_direct=yes
+      ;;
+    newsos6)
+      hardcode_direct=yes
+      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator=:
+      ;;
+    openbsd*)
+      if test -f /usr/libexec/ld.so; then
+        hardcode_direct=yes
+        if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+          hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+        else
+          case "$host_os" in
+            openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
+              hardcode_libdir_flag_spec='-R$libdir'
+              ;;
+            *)
+              hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+              ;;
+          esac
+        fi
+      else
+        ld_shlibs=no
+      fi
+      ;;
+    os2*)
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_minus_L=yes
+      ;;
+    osf3*)
+      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator=:
+      ;;
+    osf4* | osf5*)
+      if test "$GCC" = yes; then
+        hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      else
+        # Both cc and cxx compiler support -rpath directly
+        hardcode_libdir_flag_spec='-rpath $libdir'
+      fi
+      hardcode_libdir_separator=:
+      ;;
+    solaris*)
+      hardcode_libdir_flag_spec='-R$libdir'
+      ;;
+    sunos4*)
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_direct=yes
+      hardcode_minus_L=yes
+      ;;
+    sysv4)
+      case $host_vendor in
+        sni)
+          hardcode_direct=yes # is this really true???
+          ;;
+        siemens)
+          hardcode_direct=no
+          ;;
+        motorola)
+          hardcode_direct=no #Motorola manual says yes, but my tests say they lie
+          ;;
+      esac
+      ;;
+    sysv4.3*)
+      ;;
+    sysv4*MP*)
+      if test -d /usr/nec; then
+        ld_shlibs=yes
+      fi
+      ;;
+    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
+      ;;
+    sysv5* | sco3.2v5* | sco5v6*)
+      hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
+      hardcode_libdir_separator=':'
+      ;;
+    uts4*)
+      hardcode_libdir_flag_spec='-L$libdir'
+      ;;
+    *)
+      ld_shlibs=no
+      ;;
+  esac
+fi
+
+# Check dynamic linker characteristics
+# Code taken from libtool.m4's _LT_SYS_DYNAMIC_LINKER.
+# Unlike libtool.m4, here we don't care about _all_ names of the library, but
+# only about the one the linker finds when passed -lNAME. This is the last
+# element of library_names_spec in libtool.m4, or possibly two of them if the
+# linker has special search rules.
+library_names_spec=      # the last element of library_names_spec in libtool.m4
+libname_spec='lib$name'
+case "$host_os" in
+  aix3*)
+    library_names_spec='$libname.a'
+    ;;
+  aix[4-9]*)
+    library_names_spec='$libname$shrext'
+    ;;
+  amigaos*)
+    library_names_spec='$libname.a'
+    ;;
+  beos*)
+    library_names_spec='$libname$shrext'
+    ;;
+  bsdi[45]*)
+    library_names_spec='$libname$shrext'
+    ;;
+  cygwin* | mingw* | pw32* | cegcc*)
+    shrext=.dll
+    library_names_spec='$libname.dll.a $libname.lib'
+    ;;
+  darwin* | rhapsody*)
+    shrext=.dylib
+    library_names_spec='$libname$shrext'
+    ;;
+  dgux*)
+    library_names_spec='$libname$shrext'
+    ;;
+  freebsd1*)
+    ;;
+  freebsd* | dragonfly*)
+    case "$host_os" in
+      freebsd[123]*)
+        library_names_spec='$libname$shrext$versuffix' ;;
+      *)
+        library_names_spec='$libname$shrext' ;;
+    esac
+    ;;
+  gnu*)
+    library_names_spec='$libname$shrext'
+    ;;
+  hpux9* | hpux10* | hpux11*)
+    case $host_cpu in
+      ia64*)
+        shrext=.so
+        ;;
+      hppa*64*)
+        shrext=.sl
+        ;;
+      *)
+        shrext=.sl
+        ;;
+    esac
+    library_names_spec='$libname$shrext'
+    ;;
+  interix[3-9]*)
+    library_names_spec='$libname$shrext'
+    ;;
+  irix5* | irix6* | nonstopux*)
+    library_names_spec='$libname$shrext'
+    case "$host_os" in
+      irix5* | nonstopux*)
+        libsuff= shlibsuff=
+        ;;
+      *)
+        case $LD in
+          *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;;
+          *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;;
+          *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;;
+          *) libsuff= shlibsuff= ;;
+        esac
+        ;;
+    esac
+    ;;
+  linux*oldld* | linux*aout* | linux*coff*)
+    ;;
+  linux* | k*bsd*-gnu)
+    library_names_spec='$libname$shrext'
+    ;;
+  knetbsd*-gnu)
+    library_names_spec='$libname$shrext'
+    ;;
+  netbsd*)
+    library_names_spec='$libname$shrext'
+    ;;
+  newsos6)
+    library_names_spec='$libname$shrext'
+    ;;
+  nto-qnx*)
+    library_names_spec='$libname$shrext'
+    ;;
+  openbsd*)
+    library_names_spec='$libname$shrext$versuffix'
+    ;;
+  os2*)
+    libname_spec='$name'
+    shrext=.dll
+    library_names_spec='$libname.a'
+    ;;
+  osf3* | osf4* | osf5*)
+    library_names_spec='$libname$shrext'
+    ;;
+  rdos*)
+    ;;
+  solaris*)
+    library_names_spec='$libname$shrext'
+    ;;
+  sunos4*)
+    library_names_spec='$libname$shrext$versuffix'
+    ;;
+  sysv4 | sysv4.3*)
+    library_names_spec='$libname$shrext'
+    ;;
+  sysv4*MP*)
+    library_names_spec='$libname$shrext'
+    ;;
+  sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+    library_names_spec='$libname$shrext'
+    ;;
+  uts4*)
+    library_names_spec='$libname$shrext'
+    ;;
+esac
+
+sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
+escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"`
+shlibext=`echo "$shrext" | sed -e 's,^\.,,'`
+escaped_libname_spec=`echo "X$libname_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
+escaped_library_names_spec=`echo "X$library_names_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
+escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
+
+LC_ALL=C sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <<EOF
+
+# How to pass a linker flag through the compiler.
+wl="$escaped_wl"
+
+# Static library suffix (normally "a").
+libext="$libext"
+
+# Shared library suffix (normally "so").
+shlibext="$shlibext"
+
+# Format of library name prefix.
+libname_spec="$escaped_libname_spec"
+
+# Library names that the linker finds when passed -lNAME.
+library_names_spec="$escaped_library_names_spec"
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist.
+hardcode_libdir_flag_spec="$escaped_hardcode_libdir_flag_spec"
+
+# Whether we need a single -rpath flag with a separated argument.
+hardcode_libdir_separator="$hardcode_libdir_separator"
+
+# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the
+# resulting binary.
+hardcode_direct="$hardcode_direct"
+
+# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
+# resulting binary.
+hardcode_minus_L="$hardcode_minus_L"
+
+EOF
diff --git a/configure.in b/configure.in
index 2b627bf..e3c51ad 100644
--- a/configure.in
+++ b/configure.in
@@ -92,6 +92,17 @@ AM_PATH_LIBPRELUDE(0.9.8, ,
 
 
 dnl **************************************************
+dnl * Check for libICU                               *
+dnl **************************************************
+
+PKG_CHECK_MODULES([ICU], [icu >= 3.0], [enable_icu=yes],
+                  [AC_CHECK_ICU(3.8, enable_icu=yes, enable_icu=no)])
+if test x$enable_icu = xyes; then
+        AC_DEFINE_UNQUOTED(HAVE_LIBICU, , Tell whether libicu is available for encoding convertion)
+fi
+
+
+dnl **************************************************
 dnl * Check for PCRE                                 *
 dnl **************************************************
 
@@ -201,4 +212,5 @@ AC_OUTPUT
 
 echo
 echo "*** Dumping configuration ***"
-echo "    - Enable unsupported rulesets:        : $enable_unsupported_rulesets"
+echo "    - Favor libICU over Iconv    : $enable_icu"
+echo "    - Enable unsupported rulesets: $enable_unsupported_rulesets"
diff --git a/libmissing/Makefile.am b/libmissing/Makefile.am
index 019bf32..ad5117b 100644
--- a/libmissing/Makefile.am
+++ b/libmissing/Makefile.am
@@ -9,7 +9,7 @@
 # the same distribution terms as the rest of that program.
 #
 # Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --dir=. --lib=libmissing --source-base=libmissing --m4-base=libmissing/m4 --doc-base=libmissing/doc --tests-base=libmissing/tests --aux-dir=. --with-tests --lgpl --libtool --macro-prefix=gl --no-vc-files bind close fnmatch-gnu getaddrinfo glob inet_ntop mktime pathmax recvfrom servent sigaction sleep snprintf socket socklen strptime strsep sys_select
+# Reproduce by: gnulib-tool --import --dir=. --lib=libmissing --source-base=libmissing --m4-base=libmissing/m4 --doc-base=libmissing/doc --tests-base=libmissing/tests --aux-dir=. --with-tests --lgpl --libtool --macro-prefix=gl --no-vc-files bind close fnmatch-gnu getaddrinfo glob iconv inet_ntop mktime nl_langinfo pathmax recvfrom servent sigaction sleep snprintf socket socklen strptime strsep sys_select
 
 AUTOMAKE_OPTIONS = 1.5 gnits
 
@@ -64,9 +64,10 @@ BUILT_SOURCES += $(ALLOCA_H)
 # We need the following in order to create <alloca.h> when the system
 # doesn't have one that works with the given compiler.
 alloca.h: alloca.in.h
+	$(AM_V_GEN)rm -f $@-t $@ && \
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
 	  cat $(srcdir)/alloca.in.h; \
-	} > $@-t
+	} > $@-t && \
 	mv -f $@-t $@
 MOSTLYCLEANFILES += alloca.h alloca.h-t
 
@@ -74,15 +75,39 @@ EXTRA_DIST += alloca.in.h
 
 ## end   gnulib module alloca-opt
 
+## begin gnulib module arg-nonnull
+
+# The BUILT_SOURCES created by this Makefile snippet are not used via #include
+# statements but through direct file reference. Therefore this snippet must be
+# present in all Makefile.am that need it. This is ensured by the applicability
+# 'all' defined above.
+
+BUILT_SOURCES += arg-nonnull.h
+# The arg-nonnull.h that gets inserted into generated .h files is the same as
+# build-aux/arg-nonnull.h, except that it has the copyright header cut off.
+arg-nonnull.h: $(top_srcdir)/./arg-nonnull.h
+	$(AM_V_GEN)rm -f $@-t $@ && \
+	sed -n -e '/GL_ARG_NONNULL/,$$p' \
+	  < $(top_srcdir)/./arg-nonnull.h \
+	  > $@-t && \
+	mv $@-t $@
+MOSTLYCLEANFILES += arg-nonnull.h arg-nonnull.h-t
+
+ARG_NONNULL_H=arg-nonnull.h
+
+EXTRA_DIST += $(top_srcdir)/./arg-nonnull.h
+
+## end   gnulib module arg-nonnull
+
 ## begin gnulib module arpa_inet
 
 BUILT_SOURCES += $(ARPA_INET_H)
 
 # We need the following in order to create <arpa/inet.h> when the system
 # doesn't have one.
-arpa/inet.h: arpa_inet.in.h
-	@MKDIR_P@ arpa
-	rm -f $@-t $@
+arpa/inet.h: arpa_inet.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
+	$(AM_V_at)$(MKDIR_P) arpa
+	$(AM_V_GEN)rm -f $@-t $@ && \
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
 	  sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
 	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
@@ -93,8 +118,9 @@ arpa/inet.h: arpa_inet.in.h
 	      -e 's|@''HAVE_DECL_INET_NTOP''@|$(HAVE_DECL_INET_NTOP)|g' \
 	      -e 's|@''HAVE_DECL_INET_PTON''@|$(HAVE_DECL_INET_PTON)|g' \
 	      -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+	      -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
 	      < $(srcdir)/arpa_inet.in.h; \
-	} > $@-t
+	} > $@-t && \
 	mv $@-t $@
 MOSTLYCLEANFILES += arpa/inet.h arpa/inet.h-t
 MOSTLYCLEANDIRS += arpa
@@ -149,7 +175,7 @@ EXTRA_DIST += close-hook.h
 # The Automake-defined pkg* macros are appended, in the order
 # listed in the Automake 1.10a+ documentation.
 configmake.h: Makefile
-	rm -f $@-t
+	$(AM_V_GEN)rm -f $@-t && \
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
 	  echo '#define PREFIX "$(prefix)"'; \
 	  echo '#define EXEC_PREFIX "$(exec_prefix)"'; \
@@ -178,7 +204,7 @@ configmake.h: Makefile
 	  echo '#define PKGINCLUDEDIR "$(pkgincludedir)"'; \
 	  echo '#define PKGLIBDIR "$(pkglibdir)"'; \
 	  echo '#define PKGLIBEXECDIR "$(pkglibexecdir)"'; \
-	} | sed '/""/d' > $@-t
+	} | sed '/""/d' > $@-t && \
 	if test -f $@ && cmp $@-t $@ > /dev/null; then \
 	  rm -f $@-t; \
 	else \
@@ -196,22 +222,27 @@ BUILT_SOURCES += $(DIRENT_H)
 
 # We need the following in order to create <dirent.h> when the system
 # doesn't have one that works with the given compiler.
-dirent.h: dirent.in.h
-	rm -f $@-t $@
+dirent.h: dirent.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
+	$(AM_V_GEN)rm -f $@-t $@ && \
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
 	  sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
 	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
 	      -e 's|@''NEXT_DIRENT_H''@|$(NEXT_DIRENT_H)|g' \
 	      -e 's|@''GNULIB_DIRFD''@|$(GNULIB_DIRFD)|g' \
+	      -e 's|@''GNULIB_FDOPENDIR''@|$(GNULIB_FDOPENDIR)|g' \
 	      -e 's|@''GNULIB_SCANDIR''@|$(GNULIB_SCANDIR)|g' \
 	      -e 's|@''GNULIB_ALPHASORT''@|$(GNULIB_ALPHASORT)|g' \
 	      -e 's|@''HAVE_DECL_DIRFD''@|$(HAVE_DECL_DIRFD)|g' \
+	      -e 's|@''HAVE_FDOPENDIR''@|$(HAVE_FDOPENDIR)|g' \
 	      -e 's|@''HAVE_SCANDIR''@|$(HAVE_SCANDIR)|g' \
 	      -e 's|@''HAVE_ALPHASORT''@|$(HAVE_ALPHASORT)|g' \
-	      -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \
+	      -e 's|@''REPLACE_CLOSEDIR''@|$(REPLACE_CLOSEDIR)|g' \
+	      -e 's|@''REPLACE_FDOPENDIR''@|$(REPLACE_FDOPENDIR)|g' \
+	      -e 's|@''REPLACE_OPENDIR''@|$(REPLACE_OPENDIR)|g' \
 	      -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+	      -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
 	      < $(srcdir)/dirent.in.h; \
-	} > $@-t
+	} > $@-t && \
 	mv $@-t $@
 MOSTLYCLEANFILES += dirent.h dirent.h-t
 
@@ -235,7 +266,7 @@ BUILT_SOURCES += $(ERRNO_H)
 # We need the following in order to create <errno.h> when the system
 # doesn't have one that is POSIX compliant.
 errno.h: errno.in.h
-	rm -f $@-t $@
+	$(AM_V_GEN)rm -f $@-t $@ && \
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
 	  sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
 	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
@@ -247,7 +278,7 @@ errno.h: errno.in.h
 	      -e 's|@''EOVERFLOW_HIDDEN''@|$(EOVERFLOW_HIDDEN)|g' \
 	      -e 's|@''EOVERFLOW_VALUE''@|$(EOVERFLOW_VALUE)|g' \
 	      < $(srcdir)/errno.in.h; \
-	} > $@-t
+	} > $@-t && \
 	mv $@-t $@
 MOSTLYCLEANFILES += errno.h errno.h-t
 
@@ -271,13 +302,13 @@ BUILT_SOURCES += $(FLOAT_H)
 # We need the following in order to create <float.h> when the system
 # doesn't have one that works with the given compiler.
 float.h: float.in.h
-	rm -f $@-t $@
+	$(AM_V_GEN)rm -f $@-t $@ && \
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
 	  sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
 	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
 	      -e 's|@''NEXT_FLOAT_H''@|$(NEXT_FLOAT_H)|g' \
 	      < $(srcdir)/float.in.h; \
-	} > $@-t
+	} > $@-t && \
 	mv $@-t $@
 MOSTLYCLEANFILES += float.h float.h-t
 
@@ -291,10 +322,12 @@ BUILT_SOURCES += $(FNMATCH_H)
 
 # We need the following in order to create <fnmatch.h> when the system
 # doesn't have one that supports the required API.
-fnmatch.h: fnmatch.in.h
+fnmatch.h: fnmatch.in.h $(ARG_NONNULL_H)
+	$(AM_V_GEN)rm -f $@-t $@ && \
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
-	  cat $(srcdir)/fnmatch.in.h; \
-	} > $@-t
+	  sed -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+	      < $(srcdir)/fnmatch.in.h; \
+	} > $@-t && \
 	mv -f $@-t $@
 MOSTLYCLEANFILES += fnmatch.h fnmatch.h-t
 
@@ -322,15 +355,6 @@ EXTRA_libmissing_la_SOURCES += getlogin_r.c
 
 ## end   gnulib module getlogin_r
 
-## begin gnulib module getpagesize
-
-
-EXTRA_DIST += getpagesize.c
-
-EXTRA_libmissing_la_SOURCES += getpagesize.c
-
-## end   gnulib module getpagesize
-
 ## begin gnulib module getpeername
 
 
@@ -352,11 +376,13 @@ BUILT_SOURCES += $(GLOB_H)
 
 # We need the following in order to create <glob.h> when the system
 # doesn't have one that works with the given compiler.
-glob.h: glob.in.h
+glob.h: glob.in.h $(ARG_NONNULL_H)
+	$(AM_V_GEN)rm -f $@-t $@ && \
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
 	  sed -e 's|@''HAVE_SYS_CDEFS_H''@|$(HAVE_SYS_CDEFS_H)|g' \
+	      -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
 	      < $(srcdir)/glob.in.h; \
-	} > $@-t
+	} > $@-t && \
 	mv -f $@-t $@
 MOSTLYCLEANFILES += glob.h glob.h-t
 
@@ -366,6 +392,13 @@ EXTRA_libmissing_la_SOURCES += glob.c
 
 ## end   gnulib module glob
 
+## begin gnulib module havelib
+
+
+EXTRA_DIST += $(top_srcdir)/./config.rpath
+
+## end   gnulib module havelib
+
 ## begin gnulib module inet_ntop
 
 
@@ -375,9 +408,53 @@ EXTRA_libmissing_la_SOURCES += inet_ntop.c
 
 ## end   gnulib module inet_ntop
 
+## begin gnulib module langinfo
+
+BUILT_SOURCES += $(LANGINFO_H)
+
+# We need the following in order to create an empty placeholder for
+# <langinfo.h> when the system doesn't have one.
+langinfo.h: langinfo.in.h $(LINK_WARNING_H)
+	$(AM_V_GEN)rm -f $@-t $@ && \
+	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+	  sed -e 's|@''HAVE_LANGINFO_H''@|$(HAVE_LANGINFO_H)|g' \
+	      -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+	      -e 's|@''NEXT_LANGINFO_H''@|$(NEXT_LANGINFO_H)|g' \
+	      -e 's|@''GNULIB_NL_LANGINFO''@|$(GNULIB_NL_LANGINFO)|g' \
+	      -e 's|@''HAVE_LANGINFO_CODESET''@|$(HAVE_LANGINFO_CODESET)|g' \
+	      -e 's|@''HAVE_LANGINFO_ERA''@|$(HAVE_LANGINFO_ERA)|g' \
+	      -e 's|@''HAVE_NL_LANGINFO''@|$(HAVE_NL_LANGINFO)|g' \
+	      -e 's|@''REPLACE_NL_LANGINFO''@|$(REPLACE_NL_LANGINFO)|g' \
+	      -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+	      < $(srcdir)/langinfo.in.h; \
+	} > $@-t && \
+	mv $@-t $@
+MOSTLYCLEANFILES += langinfo.h langinfo.h-t
+
+EXTRA_DIST += langinfo.in.h
+
+## end   gnulib module langinfo
+
 ## begin gnulib module link-warning
 
-LINK_WARNING_H=$(top_srcdir)/./link-warning.h
+# The BUILT_SOURCES created by this Makefile snippet are not used via #include
+# statements but through direct file reference. Therefore this snippet must be
+# present in all Makefile.am that need it. This is ensured by the applicability
+# 'all' defined above.
+
+BUILT_SOURCES += link-warning.h
+# The link-warning.h that gets inserted into generated .h files is the same as
+# build-aux/link-warning.h, except that it has the copyright header cut off.
+link-warning.h: $(top_srcdir)/./link-warning.h
+	$(AM_V_GEN)rm -f $@-t $@ && \
+	sed -n -e '/GL_LINK_WARNING/,$$p' \
+	  < $(top_srcdir)/./link-warning.h \
+	  > $@-t && \
+	mv $@-t $@
+MOSTLYCLEANFILES += link-warning.h link-warning.h-t
+
+LINK_WARNING_H=link-warning.h
 
 EXTRA_DIST += $(top_srcdir)/./link-warning.h
 
@@ -441,14 +518,14 @@ uninstall-localcharset: all-local
 	fi
 
 charset.alias: config.charset
-	rm -f t-$@ $@
-	$(SHELL) $(srcdir)/config.charset '$(host)' > t-$@
+	$(AM_V_GEN)rm -f t-$@ $@ && \
+	$(SHELL) $(srcdir)/config.charset '$(host)' > t-$@ && \
 	mv t-$@ $@
 
 SUFFIXES += .sed .sin
 .sin.sed:
-	rm -f t-$@ $@
-	sed -e '/^#/d' -e 's/@''PACKAGE''@/$(PACKAGE)/g' $< > t-$@
+	$(AM_V_GEN)rm -f t-$@ $@ && \
+	sed -e '/^#/d' -e 's/@''PACKAGE''@/$(PACKAGE)/g' $< > t-$@ && \
 	mv t-$@ $@
 
 CLEANFILES += charset.alias ref-add.sed ref-del.sed
@@ -514,7 +591,7 @@ EXTRA_libmissing_la_SOURCES += mempcpy.c
 ## begin gnulib module mktime
 
 
-EXTRA_DIST += mktime.c
+EXTRA_DIST += mktime-internal.h mktime.c
 
 EXTRA_libmissing_la_SOURCES += mktime.c
 
@@ -526,8 +603,8 @@ BUILT_SOURCES += $(NETDB_H)
 
 # We need the following in order to create <netdb.h> when the system
 # doesn't have one that works with the given compiler.
-netdb.h: netdb.in.h
-	rm -f $@-t $@
+netdb.h: netdb.in.h $(ARG_NONNULL_H)
+	$(AM_V_GEN)rm -f $@-t $@ && \
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
 	  sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
 	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
@@ -539,8 +616,9 @@ netdb.h: netdb.in.h
 	      -e 's|@''HAVE_DECL_GAI_STRERROR''@|$(HAVE_DECL_GAI_STRERROR)|g' \
 	      -e 's|@''HAVE_DECL_GETADDRINFO''@|$(HAVE_DECL_GETADDRINFO)|g' \
 	      -e 's|@''HAVE_DECL_GETNAMEINFO''@|$(HAVE_DECL_GETNAMEINFO)|g' \
+	      -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
 	      < $(srcdir)/netdb.in.h; \
-	} > $@-t
+	} > $@-t && \
 	mv $@-t $@
 MOSTLYCLEANFILES += netdb.h netdb.h-t
 
@@ -555,15 +633,15 @@ BUILT_SOURCES += $(NETINET_IN_H)
 # We need the following in order to create <netinet/in.h> when the system
 # doesn't have one.
 netinet/in.h: netinet_in.in.h
-	@MKDIR_P@ netinet
-	rm -f $@-t $@
+	$(AM_V_at)$(MKDIR_P) netinet
+	$(AM_V_GEN)rm -f $@-t $@ && \
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
 	  sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
 	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
 	      -e 's|@''NEXT_NETINET_IN_H''@|$(NEXT_NETINET_IN_H)|g' \
 	      -e 's|@''HAVE_NETINET_IN_H''@|$(HAVE_NETINET_IN_H)|g' \
 	      < $(srcdir)/netinet_in.in.h; \
-	} > $@-t
+	} > $@-t && \
 	mv $@-t $@
 MOSTLYCLEANFILES += netinet/in.h netinet/in.h-t
 MOSTLYCLEANDIRS += netinet
@@ -572,6 +650,15 @@ EXTRA_DIST += netinet_in.in.h
 
 ## end   gnulib module netinet_in
 
+## begin gnulib module nl_langinfo
+
+
+EXTRA_DIST += nl_langinfo.c
+
+EXTRA_libmissing_la_SOURCES += nl_langinfo.c
+
+## end   gnulib module nl_langinfo
+
 ## begin gnulib module pathmax
 
 
@@ -603,8 +690,8 @@ BUILT_SOURCES += signal.h
 
 # We need the following in order to create <signal.h> when the system
 # doesn't have a complete one.
-signal.h: signal.in.h
-	rm -f $@-t $@
+signal.h: signal.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
+	$(AM_V_GEN)rm -f $@-t $@ && \
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
 	  sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
 	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
@@ -619,8 +706,9 @@ signal.h: signal.in.h
 	      -e 's|@''HAVE_STRUCT_SIGACTION_SA_SIGACTION''@|$(HAVE_STRUCT_SIGACTION_SA_SIGACTION)|g' \
 	      -e 's|@''HAVE_TYPE_VOLATILE_SIG_ATOMIC_T''@|$(HAVE_TYPE_VOLATILE_SIG_ATOMIC_T)|g' \
 	      -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+	      -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
 	      < $(srcdir)/signal.in.h; \
-	} > $@-t
+	} > $@-t && \
 	mv $@-t $@
 MOSTLYCLEANFILES += signal.h signal.h-t
 
@@ -670,6 +758,14 @@ EXTRA_libmissing_la_SOURCES += socket.c
 
 ## end   gnulib module socket
 
+## begin gnulib module sockets
+
+libmissing_la_SOURCES += sockets.h sockets.c
+
+EXTRA_DIST += w32sock.h
+
+## end   gnulib module sockets
+
 ## begin gnulib module stdbool
 
 BUILT_SOURCES += $(STDBOOL_H)
@@ -677,10 +773,10 @@ BUILT_SOURCES += $(STDBOOL_H)
 # We need the following in order to create <stdbool.h> when the system
 # doesn't have one that works.
 stdbool.h: stdbool.in.h
-	rm -f $@-t $@
+	$(AM_V_GEN)rm -f $@-t $@ && \
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
 	  sed -e 's/@''HAVE__BOOL''@/$(HAVE__BOOL)/g' < $(srcdir)/stdbool.in.h; \
-	} > $@-t
+	} > $@-t && \
 	mv $@-t $@
 MOSTLYCLEANFILES += stdbool.h stdbool.h-t
 
@@ -688,6 +784,29 @@ EXTRA_DIST += stdbool.in.h
 
 ## end   gnulib module stdbool
 
+## begin gnulib module stddef
+
+BUILT_SOURCES += $(STDDEF_H)
+
+# We need the following in order to create <stddef.h> when the system
+# doesn't have one that works with the given compiler.
+stddef.h: stddef.in.h
+	$(AM_V_GEN)rm -f $@-t $@ && \
+	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+	  sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+	      -e 's|@''NEXT_STDDEF_H''@|$(NEXT_STDDEF_H)|g' \
+	      -e 's|@''HAVE_WCHAR_T''@|$(HAVE_WCHAR_T)|g' \
+	      -e 's|@''REPLACE_NULL''@|$(REPLACE_NULL)|g' \
+	      < $(srcdir)/stddef.in.h; \
+	} > $@-t && \
+	mv $@-t $@
+MOSTLYCLEANFILES += stddef.h stddef.h-t
+
+EXTRA_DIST += stddef.in.h
+
+## end   gnulib module stddef
+
 ## begin gnulib module stdint
 
 BUILT_SOURCES += $(STDINT_H)
@@ -695,7 +814,7 @@ BUILT_SOURCES += $(STDINT_H)
 # We need the following in order to create <stdint.h> when the system
 # doesn't have one that works with the given compiler.
 stdint.h: stdint.in.h
-	rm -f $@-t $@
+	$(AM_V_GEN)rm -f $@-t $@ && \
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
 	  sed -e 's/@''HAVE_STDINT_H''@/$(HAVE_STDINT_H)/g' \
 	      -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -722,7 +841,7 @@ stdint.h: stdint.in.h
 	      -e 's/@''HAVE_SIGNED_WINT_T''@/$(HAVE_SIGNED_WINT_T)/g' \
 	      -e 's/@''WINT_T_SUFFIX''@/$(WINT_T_SUFFIX)/g' \
 	      < $(srcdir)/stdint.in.h; \
-	} > $@-t
+	} > $@-t && \
 	mv $@-t $@
 MOSTLYCLEANFILES += stdint.h stdint.h-t
 
@@ -736,84 +855,94 @@ BUILT_SOURCES += stdio.h
 
 # We need the following in order to create <stdio.h> when the system
 # doesn't have one that works with the given compiler.
-stdio.h: stdio.in.h
-	rm -f $@-t $@
+stdio.h: stdio.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
+	$(AM_V_GEN)rm -f $@-t $@ && \
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
 	  sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
 	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
 	      -e 's|@''NEXT_STDIO_H''@|$(NEXT_STDIO_H)|g' \
-	      -e 's|@''GNULIB_FPRINTF''@|$(GNULIB_FPRINTF)|g' \
-	      -e 's|@''GNULIB_FPRINTF_POSIX''@|$(GNULIB_FPRINTF_POSIX)|g' \
-	      -e 's|@''GNULIB_PRINTF''@|$(GNULIB_PRINTF)|g' \
-	      -e 's|@''GNULIB_PRINTF_POSIX''@|$(GNULIB_PRINTF_POSIX)|g' \
-	      -e 's|@''GNULIB_SNPRINTF''@|$(GNULIB_SNPRINTF)|g' \
-	      -e 's|@''GNULIB_SPRINTF_POSIX''@|$(GNULIB_SPRINTF_POSIX)|g' \
-	      -e 's|@''GNULIB_VFPRINTF''@|$(GNULIB_VFPRINTF)|g' \
-	      -e 's|@''GNULIB_VFPRINTF_POSIX''@|$(GNULIB_VFPRINTF_POSIX)|g' \
-	      -e 's|@''GNULIB_VPRINTF''@|$(GNULIB_VPRINTF)|g' \
-	      -e 's|@''GNULIB_VPRINTF_POSIX''@|$(GNULIB_VPRINTF_POSIX)|g' \
-	      -e 's|@''GNULIB_VSNPRINTF''@|$(GNULIB_VSNPRINTF)|g' \
-	      -e 's|@''GNULIB_VSPRINTF_POSIX''@|$(GNULIB_VSPRINTF_POSIX)|g' \
 	      -e 's|@''GNULIB_DPRINTF''@|$(GNULIB_DPRINTF)|g' \
-	      -e 's|@''GNULIB_VDPRINTF''@|$(GNULIB_VDPRINTF)|g' \
-	      -e 's|@''GNULIB_VASPRINTF''@|$(GNULIB_VASPRINTF)|g' \
-	      -e 's|@''GNULIB_OBSTACK_PRINTF''@|$(GNULIB_OBSTACK_PRINTF)|g' \
-	      -e 's|@''GNULIB_OBSTACK_PRINTF_POSIX''@|$(GNULIB_OBSTACK_PRINTF_POSIX)|g' \
+	      -e 's|@''GNULIB_FCLOSE''@|$(GNULIB_FCLOSE)|g' \
+	      -e 's|@''GNULIB_FFLUSH''@|$(GNULIB_FFLUSH)|g' \
 	      -e 's|@''GNULIB_FOPEN''@|$(GNULIB_FOPEN)|g' \
+	      -e 's|@''GNULIB_FPRINTF''@|$(GNULIB_FPRINTF)|g' \
+	      -e 's|@''GNULIB_FPRINTF_POSIX''@|$(GNULIB_FPRINTF_POSIX)|g' \
+	      -e 's|@''GNULIB_FPURGE''@|$(GNULIB_FPURGE)|g' \
+	      -e 's|@''GNULIB_FPUTC''@|$(GNULIB_FPUTC)|g' \
+	      -e 's|@''GNULIB_FPUTS''@|$(GNULIB_FPUTS)|g' \
 	      -e 's|@''GNULIB_FREOPEN''@|$(GNULIB_FREOPEN)|g' \
 	      -e 's|@''GNULIB_FSEEK''@|$(GNULIB_FSEEK)|g' \
 	      -e 's|@''GNULIB_FSEEKO''@|$(GNULIB_FSEEKO)|g' \
 	      -e 's|@''GNULIB_FTELL''@|$(GNULIB_FTELL)|g' \
 	      -e 's|@''GNULIB_FTELLO''@|$(GNULIB_FTELLO)|g' \
-	      -e 's|@''GNULIB_FFLUSH''@|$(GNULIB_FFLUSH)|g' \
-	      -e 's|@''GNULIB_FPURGE''@|$(GNULIB_FPURGE)|g' \
-	      -e 's|@''GNULIB_FCLOSE''@|$(GNULIB_FCLOSE)|g' \
-	      -e 's|@''GNULIB_FPUTC''@|$(GNULIB_FPUTC)|g' \
-	      -e 's|@''GNULIB_PUTC''@|$(GNULIB_PUTC)|g' \
-	      -e 's|@''GNULIB_PUTCHAR''@|$(GNULIB_PUTCHAR)|g' \
-	      -e 's|@''GNULIB_FPUTS''@|$(GNULIB_FPUTS)|g' \
-	      -e 's|@''GNULIB_PUTS''@|$(GNULIB_PUTS)|g' \
 	      -e 's|@''GNULIB_FWRITE''@|$(GNULIB_FWRITE)|g' \
 	      -e 's|@''GNULIB_GETDELIM''@|$(GNULIB_GETDELIM)|g' \
 	      -e 's|@''GNULIB_GETLINE''@|$(GNULIB_GETLINE)|g' \
+	      -e 's|@''GNULIB_OBSTACK_PRINTF''@|$(GNULIB_OBSTACK_PRINTF)|g' \
+	      -e 's|@''GNULIB_OBSTACK_PRINTF_POSIX''@|$(GNULIB_OBSTACK_PRINTF_POSIX)|g' \
 	      -e 's|@''GNULIB_PERROR''@|$(GNULIB_PERROR)|g' \
+	      -e 's|@''GNULIB_POPEN''@|$(GNULIB_POPEN)|g' \
+	      -e 's|@''GNULIB_PRINTF''@|$(GNULIB_PRINTF)|g' \
+	      -e 's|@''GNULIB_PRINTF_POSIX''@|$(GNULIB_PRINTF_POSIX)|g' \
+	      -e 's|@''GNULIB_PUTC''@|$(GNULIB_PUTC)|g' \
+	      -e 's|@''GNULIB_PUTCHAR''@|$(GNULIB_PUTCHAR)|g' \
+	      -e 's|@''GNULIB_PUTS''@|$(GNULIB_PUTS)|g' \
+	      -e 's|@''GNULIB_REMOVE''@|$(GNULIB_REMOVE)|g' \
+	      -e 's|@''GNULIB_RENAME''@|$(GNULIB_RENAME)|g' \
+	      -e 's|@''GNULIB_RENAMEAT''@|$(GNULIB_RENAMEAT)|g' \
+	      -e 's|@''GNULIB_SNPRINTF''@|$(GNULIB_SNPRINTF)|g' \
+	      -e 's|@''GNULIB_SPRINTF_POSIX''@|$(GNULIB_SPRINTF_POSIX)|g' \
 	      -e 's|@''GNULIB_STDIO_H_SIGPIPE''@|$(GNULIB_STDIO_H_SIGPIPE)|g' \
-	      -e 's|@''REPLACE_STDIO_WRITE_FUNCS''@|$(REPLACE_STDIO_WRITE_FUNCS)|g' \
-	      -e 's|@''REPLACE_FPRINTF''@|$(REPLACE_FPRINTF)|g' \
-	      -e 's|@''REPLACE_VFPRINTF''@|$(REPLACE_VFPRINTF)|g' \
-	      -e 's|@''REPLACE_PRINTF''@|$(REPLACE_PRINTF)|g' \
-	      -e 's|@''REPLACE_VPRINTF''@|$(REPLACE_VPRINTF)|g' \
-	      -e 's|@''REPLACE_SNPRINTF''@|$(REPLACE_SNPRINTF)|g' \
+	      -e 's|@''GNULIB_VASPRINTF''@|$(GNULIB_VASPRINTF)|g' \
+	      -e 's|@''GNULIB_VDPRINTF''@|$(GNULIB_VDPRINTF)|g' \
+	      -e 's|@''GNULIB_VFPRINTF''@|$(GNULIB_VFPRINTF)|g' \
+	      -e 's|@''GNULIB_VFPRINTF_POSIX''@|$(GNULIB_VFPRINTF_POSIX)|g' \
+	      -e 's|@''GNULIB_VPRINTF''@|$(GNULIB_VPRINTF)|g' \
+	      -e 's|@''GNULIB_VPRINTF_POSIX''@|$(GNULIB_VPRINTF_POSIX)|g' \
+	      -e 's|@''GNULIB_VSNPRINTF''@|$(GNULIB_VSNPRINTF)|g' \
+	      -e 's|@''GNULIB_VSPRINTF_POSIX''@|$(GNULIB_VSPRINTF_POSIX)|g' \
+	      -e 's|@''HAVE_DECL_FPURGE''@|$(HAVE_DECL_FPURGE)|g' \
+	      -e 's|@''HAVE_DECL_GETDELIM''@|$(HAVE_DECL_GETDELIM)|g' \
+	      -e 's|@''HAVE_DECL_GETLINE''@|$(HAVE_DECL_GETLINE)|g' \
+	      -e 's|@''HAVE_DECL_OBSTACK_PRINTF''@|$(HAVE_DECL_OBSTACK_PRINTF)|g' \
 	      -e 's|@''HAVE_DECL_SNPRINTF''@|$(HAVE_DECL_SNPRINTF)|g' \
-	      -e 's|@''REPLACE_VSNPRINTF''@|$(REPLACE_VSNPRINTF)|g' \
 	      -e 's|@''HAVE_DECL_VSNPRINTF''@|$(HAVE_DECL_VSNPRINTF)|g' \
-	      -e 's|@''REPLACE_SPRINTF''@|$(REPLACE_SPRINTF)|g' \
-	      -e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \
 	      -e 's|@''HAVE_DPRINTF''@|$(HAVE_DPRINTF)|g' \
-	      -e 's|@''REPLACE_DPRINTF''@|$(REPLACE_DPRINTF)|g' \
-	      -e 's|@''HAVE_VDPRINTF''@|$(HAVE_VDPRINTF)|g' \
-	      -e 's|@''REPLACE_VDPRINTF''@|$(REPLACE_VDPRINTF)|g' \
+	      -e 's|@''HAVE_RENAMEAT''@|$(HAVE_RENAMEAT)|g' \
 	      -e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \
-	      -e 's|@''REPLACE_VASPRINTF''@|$(REPLACE_VASPRINTF)|g' \
-	      -e 's|@''HAVE_DECL_OBSTACK_PRINTF''@|$(HAVE_DECL_OBSTACK_PRINTF)|g' \
-	      -e 's|@''REPLACE_OBSTACK_PRINTF''@|$(REPLACE_OBSTACK_PRINTF)|g' \
+	      -e 's|@''HAVE_VDPRINTF''@|$(HAVE_VDPRINTF)|g' \
+	      -e 's|@''REPLACE_DPRINTF''@|$(REPLACE_DPRINTF)|g' \
+	      -e 's|@''REPLACE_FCLOSE''@|$(REPLACE_FCLOSE)|g' \
+	      -e 's|@''REPLACE_FFLUSH''@|$(REPLACE_FFLUSH)|g' \
 	      -e 's|@''REPLACE_FOPEN''@|$(REPLACE_FOPEN)|g' \
+	      -e 's|@''REPLACE_FPRINTF''@|$(REPLACE_FPRINTF)|g' \
+	      -e 's|@''REPLACE_FPURGE''@|$(REPLACE_FPURGE)|g' \
 	      -e 's|@''REPLACE_FREOPEN''@|$(REPLACE_FREOPEN)|g' \
-	      -e 's|@''REPLACE_FSEEKO''@|$(REPLACE_FSEEKO)|g' \
 	      -e 's|@''REPLACE_FSEEK''@|$(REPLACE_FSEEK)|g' \
-	      -e 's|@''REPLACE_FTELLO''@|$(REPLACE_FTELLO)|g' \
+	      -e 's|@''REPLACE_FSEEKO''@|$(REPLACE_FSEEKO)|g' \
 	      -e 's|@''REPLACE_FTELL''@|$(REPLACE_FTELL)|g' \
-	      -e 's|@''REPLACE_FFLUSH''@|$(REPLACE_FFLUSH)|g' \
-	      -e 's|@''REPLACE_FPURGE''@|$(REPLACE_FPURGE)|g' \
-	      -e 's|@''HAVE_DECL_FPURGE''@|$(HAVE_DECL_FPURGE)|g' \
-	      -e 's|@''REPLACE_FCLOSE''@|$(REPLACE_FCLOSE)|g' \
-	      -e 's|@''HAVE_DECL_GETDELIM''@|$(HAVE_DECL_GETDELIM)|g' \
-	      -e 's|@''HAVE_DECL_GETLINE''@|$(HAVE_DECL_GETLINE)|g' \
+	      -e 's|@''REPLACE_FTELLO''@|$(REPLACE_FTELLO)|g' \
 	      -e 's|@''REPLACE_GETLINE''@|$(REPLACE_GETLINE)|g' \
+	      -e 's|@''REPLACE_OBSTACK_PRINTF''@|$(REPLACE_OBSTACK_PRINTF)|g' \
 	      -e 's|@''REPLACE_PERROR''@|$(REPLACE_PERROR)|g' \
+	      -e 's|@''REPLACE_POPEN''@|$(REPLACE_POPEN)|g' \
+	      -e 's|@''REPLACE_PRINTF''@|$(REPLACE_PRINTF)|g' \
+	      -e 's|@''REPLACE_REMOVE''@|$(REPLACE_REMOVE)|g' \
+	      -e 's|@''REPLACE_RENAME''@|$(REPLACE_RENAME)|g' \
+	      -e 's|@''REPLACE_RENAMEAT''@|$(REPLACE_RENAMEAT)|g' \
+	      -e 's|@''REPLACE_SNPRINTF''@|$(REPLACE_SNPRINTF)|g' \
+	      -e 's|@''REPLACE_SPRINTF''@|$(REPLACE_SPRINTF)|g' \
+	      -e 's|@''REPLACE_STDIO_WRITE_FUNCS''@|$(REPLACE_STDIO_WRITE_FUNCS)|g' \
+	      -e 's|@''REPLACE_VASPRINTF''@|$(REPLACE_VASPRINTF)|g' \
+	      -e 's|@''REPLACE_VDPRINTF''@|$(REPLACE_VDPRINTF)|g' \
+	      -e 's|@''REPLACE_VFPRINTF''@|$(REPLACE_VFPRINTF)|g' \
+	      -e 's|@''REPLACE_VPRINTF''@|$(REPLACE_VPRINTF)|g' \
+	      -e 's|@''REPLACE_VSNPRINTF''@|$(REPLACE_VSNPRINTF)|g' \
+	      -e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \
 	      -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+	      -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
 	      < $(srcdir)/stdio.in.h; \
-	} > $@-t
+	} > $@-t && \
 	mv $@-t $@
 MOSTLYCLEANFILES += stdio.h stdio.h-t
 
@@ -829,23 +958,27 @@ BUILT_SOURCES += stdlib.h
 
 # We need the following in order to create <stdlib.h> when the system
 # doesn't have one that works with the given compiler.
-stdlib.h: stdlib.in.h
-	rm -f $@-t $@
+stdlib.h: stdlib.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
+	$(AM_V_GEN)rm -f $@-t $@ && \
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
 	  sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
 	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
 	      -e 's|@''NEXT_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \
-	      -e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \
-	      -e 's|@''GNULIB_MALLOC_POSIX''@|$(GNULIB_MALLOC_POSIX)|g' \
-	      -e 's|@''GNULIB_REALLOC_POSIX''@|$(GNULIB_REALLOC_POSIX)|g' \
-	      -e 's|@''GNULIB_CALLOC_POSIX''@|$(GNULIB_CALLOC_POSIX)|g' \
 	      -e 's|@''GNULIB_ATOLL''@|$(GNULIB_ATOLL)|g' \
+	      -e 's|@''GNULIB_CALLOC_POSIX''@|$(GNULIB_CALLOC_POSIX)|g' \
+	      -e 's|@''GNULIB_CANONICALIZE_FILE_NAME''@|$(GNULIB_CANONICALIZE_FILE_NAME)|g' \
 	      -e 's|@''GNULIB_GETLOADAVG''@|$(GNULIB_GETLOADAVG)|g' \
 	      -e 's|@''GNULIB_GETSUBOPT''@|$(GNULIB_GETSUBOPT)|g' \
+	      -e 's|@''GNULIB_MALLOC_POSIX''@|$(GNULIB_MALLOC_POSIX)|g' \
 	      -e 's|@''GNULIB_MKDTEMP''@|$(GNULIB_MKDTEMP)|g' \
+	      -e 's|@''GNULIB_MKOSTEMP''@|$(GNULIB_MKOSTEMP)|g' \
+	      -e 's|@''GNULIB_MKOSTEMPS''@|$(GNULIB_MKOSTEMPS)|g' \
 	      -e 's|@''GNULIB_MKSTEMP''@|$(GNULIB_MKSTEMP)|g' \
+	      -e 's|@''GNULIB_MKSTEMPS''@|$(GNULIB_MKSTEMPS)|g' \
 	      -e 's|@''GNULIB_PUTENV''@|$(GNULIB_PUTENV)|g' \
 	      -e 's|@''GNULIB_RANDOM_R''@|$(GNULIB_RANDOM_R)|g' \
+	      -e 's|@''GNULIB_REALLOC_POSIX''@|$(GNULIB_REALLOC_POSIX)|g' \
+	      -e 's|@''GNULIB_REALPATH''@|$(GNULIB_REALPATH)|g' \
 	      -e 's|@''GNULIB_RPMATCH''@|$(GNULIB_RPMATCH)|g' \
 	      -e 's|@''GNULIB_SETENV''@|$(GNULIB_SETENV)|g' \
 	      -e 's|@''GNULIB_STRTOD''@|$(GNULIB_STRTOD)|g' \
@@ -854,11 +987,18 @@ stdlib.h: stdlib.in.h
 	      -e 's|@''GNULIB_UNSETENV''@|$(GNULIB_UNSETENV)|g' \
 	      -e 's|@''HAVE_ATOLL''@|$(HAVE_ATOLL)|g' \
 	      -e 's|@''HAVE_CALLOC_POSIX''@|$(HAVE_CALLOC_POSIX)|g' \
+	      -e 's|@''HAVE_CANONICALIZE_FILE_NAME''@|$(HAVE_CANONICALIZE_FILE_NAME)|g' \
+	      -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \
 	      -e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \
 	      -e 's|@''HAVE_MALLOC_POSIX''@|$(HAVE_MALLOC_POSIX)|g' \
 	      -e 's|@''HAVE_MKDTEMP''@|$(HAVE_MKDTEMP)|g' \
-	      -e 's|@''HAVE_REALLOC_POSIX''@|$(HAVE_REALLOC_POSIX)|g' \
+	      -e 's|@''HAVE_MKOSTEMP''@|$(HAVE_MKOSTEMP)|g' \
+	      -e 's|@''HAVE_MKOSTEMPS''@|$(HAVE_MKOSTEMPS)|g' \
+	      -e 's|@''HAVE_MKSTEMPS''@|$(HAVE_MKSTEMPS)|g' \
+	      -e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \
 	      -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \
+	      -e 's|@''HAVE_REALLOC_POSIX''@|$(HAVE_REALLOC_POSIX)|g' \
+	      -e 's|@''HAVE_REALPATH''@|$(HAVE_REALPATH)|g' \
 	      -e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \
 	      -e 's|@''HAVE_SETENV''@|$(HAVE_SETENV)|g' \
 	      -e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \
@@ -867,14 +1007,17 @@ stdlib.h: stdlib.in.h
 	      -e 's|@''HAVE_STRUCT_RANDOM_DATA''@|$(HAVE_STRUCT_RANDOM_DATA)|g' \
 	      -e 's|@''HAVE_SYS_LOADAVG_H''@|$(HAVE_SYS_LOADAVG_H)|g' \
 	      -e 's|@''HAVE_UNSETENV''@|$(HAVE_UNSETENV)|g' \
-	      -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \
+	      -e 's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \
 	      -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \
 	      -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \
+	      -e 's|@''REPLACE_REALPATH''@|$(REPLACE_REALPATH)|g' \
+	      -e 's|@''REPLACE_SETENV''@|$(REPLACE_SETENV)|g' \
 	      -e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \
-	      -e 's|@''VOID_UNSETENV''@|$(VOID_UNSETENV)|g' \
+	      -e 's|@''REPLACE_UNSETENV''@|$(REPLACE_UNSETENV)|g' \
 	      -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+	      -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
 	      < $(srcdir)/stdlib.in.h; \
-	} > $@-t
+	} > $@-t && \
 	mv $@-t $@
 MOSTLYCLEANFILES += stdlib.h stdlib.h-t
 
@@ -904,8 +1047,8 @@ BUILT_SOURCES += string.h
 
 # We need the following in order to create <string.h> when the system
 # doesn't have one that works with the given compiler.
-string.h: string.in.h
-	rm -f $@-t $@
+string.h: string.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
+	$(AM_V_GEN)rm -f $@-t $@ && \
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
 	  sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
 	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
@@ -951,7 +1094,6 @@ string.h: string.in.h
 	      -e 's|@''HAVE_STPNCPY''@|$(HAVE_STPNCPY)|g' \
 	      -e 's|@''HAVE_STRCHRNUL''@|$(HAVE_STRCHRNUL)|g' \
 	      -e 's|@''HAVE_DECL_STRDUP''@|$(HAVE_DECL_STRDUP)|g' \
-	      -e 's|@''HAVE_STRNDUP''@|$(HAVE_STRNDUP)|g' \
 	      -e 's|@''HAVE_DECL_STRNDUP''@|$(HAVE_DECL_STRNDUP)|g' \
 	      -e 's|@''HAVE_DECL_STRNLEN''@|$(HAVE_DECL_STRNLEN)|g' \
 	      -e 's|@''HAVE_STRPBRK''@|$(HAVE_STRPBRK)|g' \
@@ -967,10 +1109,14 @@ string.h: string.in.h
 	      -e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \
 	      -e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \
 	      -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \
+	      -e 's|@''REPLACE_STRNDUP''@|$(REPLACE_STRNDUP)|g' \
 	      -e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \
+	      -e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \
+	      -e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \
 	      -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+	      -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
 	      < $(srcdir)/string.in.h; \
-	} > $@-t
+	} > $@-t && \
 	mv $@-t $@
 MOSTLYCLEANFILES += string.h string.h-t
 
@@ -984,8 +1130,8 @@ BUILT_SOURCES += strings.h
 
 # We need the following in order to create <strings.h> when the system
 # doesn't have one that works with the given compiler.
-strings.h: strings.in.h
-	rm -f $@-t $@
+strings.h: strings.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
+	$(AM_V_GEN)rm -f $@-t $@ && \
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
 	  sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
 	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
@@ -993,8 +1139,9 @@ strings.h: strings.in.h
 	      -e 's|@''HAVE_STRCASECMP''@|$(HAVE_STRCASECMP)|g' \
 	      -e 's|@''HAVE_DECL_STRNCASECMP''@|$(HAVE_DECL_STRNCASECMP)|g' \
 	      -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+	      -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
 	      < $(srcdir)/strings.in.h; \
-	} > $@-t
+	} > $@-t && \
 	mv $@-t $@
 MOSTLYCLEANFILES += strings.h strings.h-t
 
@@ -1032,9 +1179,9 @@ BUILT_SOURCES += $(SYS_SELECT_H)
 
 # We need the following in order to create <sys/select.h> when the system
 # doesn't have one that works with the given compiler.
-sys/select.h: sys_select.in.h
-	@MKDIR_P@ sys
-	rm -f $@-t $@
+sys/select.h: sys_select.in.h $(LINK_WARNING_H)
+	$(AM_V_at)$(MKDIR_P) sys
+	$(AM_V_GEN)rm -f $@-t $@ && \
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
 	  sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
 	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
@@ -1045,7 +1192,7 @@ sys/select.h: sys_select.in.h
 	      -e 's|@''REPLACE_SELECT''@|$(REPLACE_SELECT)|g' \
 	      -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
 	      < $(srcdir)/sys_select.in.h; \
-	} > $@-t
+	} > $@-t && \
 	mv $@-t $@
 MOSTLYCLEANFILES += sys/select.h sys/select.h-t
 MOSTLYCLEANDIRS += sys
@@ -1060,8 +1207,9 @@ BUILT_SOURCES += $(SYS_SOCKET_H)
 
 # We need the following in order to create <sys/socket.h> when the system
 # doesn't have one that works with the given compiler.
-sys/socket.h: sys_socket.in.h
-	@MKDIR_P@ sys
+sys/socket.h: sys_socket.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
+	$(AM_V_at)$(MKDIR_P) sys
+	$(AM_V_GEN)rm -f $@-t $@ && \
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
 	  sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
 	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
@@ -1082,13 +1230,16 @@ sys/socket.h: sys_socket.in.h
 	      -e 's|@''GNULIB_SENDTO''@|$(GNULIB_SENDTO)|g' \
 	      -e 's|@''GNULIB_SETSOCKOPT''@|$(GNULIB_SETSOCKOPT)|g' \
 	      -e 's|@''GNULIB_SHUTDOWN''@|$(GNULIB_SHUTDOWN)|g' \
+	      -e 's|@''GNULIB_ACCEPT4''@|$(GNULIB_ACCEPT4)|g' \
 	      -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \
 	      -e 's|@''HAVE_WS2TCPIP_H''@|$(HAVE_WS2TCPIP_H)|g' \
 	      -e 's|@''HAVE_STRUCT_SOCKADDR_STORAGE''@|$(HAVE_STRUCT_SOCKADDR_STORAGE)|g' \
 	      -e 's|@''HAVE_SA_FAMILY_T''@|$(HAVE_SA_FAMILY_T)|g' \
+	      -e 's|@''HAVE_ACCEPT4''@|$(HAVE_ACCEPT4)|g' \
 	      -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+	      -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
 	      < $(srcdir)/sys_socket.in.h; \
-	} > $@-t
+	} > $@-t && \
 	mv -f $@-t $@
 MOSTLYCLEANFILES += sys/socket.h sys/socket.h-t
 MOSTLYCLEANDIRS += sys
@@ -1099,26 +1250,53 @@ EXTRA_DIST += sys_socket.in.h
 
 ## begin gnulib module sys_stat
 
-BUILT_SOURCES += $(SYS_STAT_H)
+BUILT_SOURCES += sys/stat.h
 
 # We need the following in order to create <sys/stat.h> when the system
 # has one that is incomplete.
-sys/stat.h: sys_stat.in.h
-	@MKDIR_P@ sys
-	rm -f $@-t $@
+sys/stat.h: sys_stat.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
+	$(AM_V_at)$(MKDIR_P) sys
+	$(AM_V_GEN)rm -f $@-t $@ && \
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
 	  sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
 	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
 	      -e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \
+	      -e 's|@''GNULIB_FCHMODAT''@|$(GNULIB_FCHMODAT)|g' \
+	      -e 's|@''GNULIB_FSTATAT''@|$(GNULIB_FSTATAT)|g' \
+	      -e 's|@''GNULIB_FUTIMENS''@|$(GNULIB_FUTIMENS)|g' \
 	      -e 's|@''GNULIB_LCHMOD''@|$(GNULIB_LCHMOD)|g' \
 	      -e 's|@''GNULIB_LSTAT''@|$(GNULIB_LSTAT)|g' \
+	      -e 's|@''GNULIB_MKDIRAT''@|$(GNULIB_MKDIRAT)|g' \
+	      -e 's|@''GNULIB_MKFIFO''@|$(GNULIB_MKFIFO)|g' \
+	      -e 's|@''GNULIB_MKFIFOAT''@|$(GNULIB_MKFIFOAT)|g' \
+	      -e 's|@''GNULIB_MKNOD''@|$(GNULIB_MKNOD)|g' \
+	      -e 's|@''GNULIB_MKNODAT''@|$(GNULIB_MKNODAT)|g' \
+	      -e 's|@''GNULIB_STAT''@|$(GNULIB_STAT)|g' \
+	      -e 's|@''GNULIB_UTIMENSAT''@|$(GNULIB_UTIMENSAT)|g' \
+	      -e 's|@''HAVE_FCHMODAT''@|$(HAVE_FCHMODAT)|g' \
+	      -e 's|@''HAVE_FSTATAT''@|$(HAVE_FSTATAT)|g' \
+	      -e 's|@''HAVE_FUTIMENS''@|$(HAVE_FUTIMENS)|g' \
 	      -e 's|@''HAVE_LCHMOD''@|$(HAVE_LCHMOD)|g' \
 	      -e 's|@''HAVE_LSTAT''@|$(HAVE_LSTAT)|g' \
+	      -e 's|@''HAVE_MKDIRAT''@|$(HAVE_MKDIRAT)|g' \
+	      -e 's|@''HAVE_MKFIFO''@|$(HAVE_MKFIFO)|g' \
+	      -e 's|@''HAVE_MKFIFOAT''@|$(HAVE_MKFIFOAT)|g' \
+	      -e 's|@''HAVE_MKNOD''@|$(HAVE_MKNOD)|g' \
+	      -e 's|@''HAVE_MKNODAT''@|$(HAVE_MKNODAT)|g' \
+	      -e 's|@''HAVE_UTIMENSAT''@|$(HAVE_UTIMENSAT)|g' \
+	      -e 's|@''REPLACE_FSTAT''@|$(REPLACE_FSTAT)|g' \
+	      -e 's|@''REPLACE_FSTATAT''@|$(REPLACE_FSTATAT)|g' \
+	      -e 's|@''REPLACE_FUTIMENS''@|$(REPLACE_FUTIMENS)|g' \
 	      -e 's|@''REPLACE_LSTAT''@|$(REPLACE_LSTAT)|g' \
 	      -e 's|@''REPLACE_MKDIR''@|$(REPLACE_MKDIR)|g' \
+	      -e 's|@''REPLACE_MKFIFO''@|$(REPLACE_MKFIFO)|g' \
+	      -e 's|@''REPLACE_MKNOD''@|$(REPLACE_MKNOD)|g' \
+	      -e 's|@''REPLACE_STAT''@|$(REPLACE_STAT)|g' \
+	      -e 's|@''REPLACE_UTIMENSAT''@|$(REPLACE_UTIMENSAT)|g' \
 	      -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+	      -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
 	      < $(srcdir)/sys_stat.in.h; \
-	} > $@-t
+	} > $@-t && \
 	mv $@-t $@
 MOSTLYCLEANFILES += sys/stat.h sys/stat.h-t
 MOSTLYCLEANDIRS += sys
@@ -1133,9 +1311,9 @@ BUILT_SOURCES += $(SYS_TIME_H)
 
 # We need the following in order to create <sys/time.h> when the system
 # doesn't have one that works with the given compiler.
-sys/time.h: sys_time.in.h
-	@MKDIR_P@ sys
-	rm -f $@-t $@
+sys/time.h: sys_time.in.h $(ARG_NONNULL_H)
+	$(AM_V_at)$(MKDIR_P) sys
+	$(AM_V_GEN)rm -f $@-t $@ && \
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
 	  sed -e 's/@''HAVE_SYS_TIME_H''@/$(HAVE_SYS_TIME_H)/g' \
 	      -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -1143,8 +1321,9 @@ sys/time.h: sys_time.in.h
 	      -e 's|@''NEXT_SYS_TIME_H''@|$(NEXT_SYS_TIME_H)|g' \
 	      -e 's/@''REPLACE_GETTIMEOFDAY''@/$(REPLACE_GETTIMEOFDAY)/g' \
 	      -e 's/@''HAVE_STRUCT_TIMEVAL''@/$(HAVE_STRUCT_TIMEVAL)/g' \
+	      -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
 	      < $(srcdir)/sys_time.in.h; \
-	} > $@-t
+	} > $@-t && \
 	mv $@-t $@
 MOSTLYCLEANFILES += sys/time.h sys/time.h-t
 
@@ -1158,20 +1337,22 @@ BUILT_SOURCES += time.h
 
 # We need the following in order to create <time.h> when the system
 # doesn't have one that works with the given compiler.
-time.h: time.in.h
-	rm -f $@-t $@
+time.h: time.in.h $(ARG_NONNULL_H)
+	$(AM_V_GEN)rm -f $@-t $@ && \
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
 	  sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
 	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
 	      -e 's|@NEXT_TIME_H''@|$(NEXT_TIME_H)|g' \
 	      -e 's|@REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \
+	      -e 's|@REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \
 	      -e 's|@REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \
 	      -e 's|@REPLACE_STRPTIME''@|$(REPLACE_STRPTIME)|g' \
 	      -e 's|@REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \
 	      -e 's|@SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
 	      -e 's|@TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
+	      -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
 	      < $(srcdir)/time.in.h; \
-	} > $@-t
+	} > $@-t && \
 	mv $@-t $@
 MOSTLYCLEANFILES += time.h time.h-t
 
@@ -1194,8 +1375,8 @@ BUILT_SOURCES += unistd.h
 
 # We need the following in order to create an empty placeholder for
 # <unistd.h> when the system doesn't have one.
-unistd.h: unistd.in.h
-	rm -f $@-t $@
+unistd.h: unistd.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
+	$(AM_V_GEN)rm -f $@-t $@ && \
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
 	  sed -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \
 	      -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -1204,53 +1385,98 @@ unistd.h: unistd.in.h
 	      -e 's|@''GNULIB_CHOWN''@|$(GNULIB_CHOWN)|g' \
 	      -e 's|@''GNULIB_CLOSE''@|$(GNULIB_CLOSE)|g' \
 	      -e 's|@''GNULIB_DUP2''@|$(GNULIB_DUP2)|g' \
+	      -e 's|@''GNULIB_DUP3''@|$(GNULIB_DUP3)|g' \
 	      -e 's|@''GNULIB_ENVIRON''@|$(GNULIB_ENVIRON)|g' \
 	      -e 's|@''GNULIB_EUIDACCESS''@|$(GNULIB_EUIDACCESS)|g' \
+	      -e 's|@''GNULIB_FACCESSAT''@|$(GNULIB_FACCESSAT)|g' \
 	      -e 's|@''GNULIB_FCHDIR''@|$(GNULIB_FCHDIR)|g' \
+	      -e 's|@''GNULIB_FCHOWNAT''@|$(GNULIB_FCHOWNAT)|g' \
 	      -e 's|@''GNULIB_FSYNC''@|$(GNULIB_FSYNC)|g' \
 	      -e 's|@''GNULIB_FTRUNCATE''@|$(GNULIB_FTRUNCATE)|g' \
 	      -e 's|@''GNULIB_GETCWD''@|$(GNULIB_GETCWD)|g' \
 	      -e 's|@''GNULIB_GETDOMAINNAME''@|$(GNULIB_GETDOMAINNAME)|g' \
 	      -e 's|@''GNULIB_GETDTABLESIZE''@|$(GNULIB_GETDTABLESIZE)|g' \
+	      -e 's|@''GNULIB_GETGROUPS''@|$(GNULIB_GETGROUPS)|g' \
 	      -e 's|@''GNULIB_GETHOSTNAME''@|$(GNULIB_GETHOSTNAME)|g' \
 	      -e 's|@''GNULIB_GETLOGIN_R''@|$(GNULIB_GETLOGIN_R)|g' \
 	      -e 's|@''GNULIB_GETPAGESIZE''@|$(GNULIB_GETPAGESIZE)|g' \
 	      -e 's|@''GNULIB_GETUSERSHELL''@|$(GNULIB_GETUSERSHELL)|g' \
 	      -e 's|@''GNULIB_LCHOWN''@|$(GNULIB_LCHOWN)|g' \
 	      -e 's|@''GNULIB_LINK''@|$(GNULIB_LINK)|g' \
+	      -e 's|@''GNULIB_LINKAT''@|$(GNULIB_LINKAT)|g' \
 	      -e 's|@''GNULIB_LSEEK''@|$(GNULIB_LSEEK)|g' \
+	      -e 's|@''GNULIB_PIPE2''@|$(GNULIB_PIPE2)|g' \
+	      -e 's|@''GNULIB_PREAD''@|$(GNULIB_PREAD)|g' \
 	      -e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \
+	      -e 's|@''GNULIB_READLINKAT''@|$(GNULIB_READLINKAT)|g' \
+	      -e 's|@''GNULIB_RMDIR''@|$(GNULIB_RMDIR)|g' \
 	      -e 's|@''GNULIB_SLEEP''@|$(GNULIB_SLEEP)|g' \
+	      -e 's|@''GNULIB_SYMLINK''@|$(GNULIB_SYMLINK)|g' \
+	      -e 's|@''GNULIB_SYMLINKAT''@|$(GNULIB_SYMLINKAT)|g' \
+	      -e 's|@''GNULIB_UNISTD_H_GETOPT''@|$(GNULIB_UNISTD_H_GETOPT)|g' \
 	      -e 's|@''GNULIB_UNISTD_H_SIGPIPE''@|$(GNULIB_UNISTD_H_SIGPIPE)|g' \
+	      -e 's|@''GNULIB_UNLINK''@|$(GNULIB_UNLINK)|g' \
+	      -e 's|@''GNULIB_UNLINKAT''@|$(GNULIB_UNLINKAT)|g' \
+	      -e 's|@''GNULIB_USLEEP''@|$(GNULIB_USLEEP)|g' \
 	      -e 's|@''GNULIB_WRITE''@|$(GNULIB_WRITE)|g' \
+	      -e 's|@''HAVE_CHOWN''@|$(HAVE_CHOWN)|g' \
 	      -e 's|@''HAVE_DUP2''@|$(HAVE_DUP2)|g' \
+	      -e 's|@''HAVE_DUP3''@|$(HAVE_DUP3)|g' \
 	      -e 's|@''HAVE_EUIDACCESS''@|$(HAVE_EUIDACCESS)|g' \
+	      -e 's|@''HAVE_FACCESSAT''@|$(HAVE_FACCESSAT)|g' \
+	      -e 's|@''HAVE_FCHOWNAT''@|$(HAVE_FCHOWNAT)|g' \
 	      -e 's|@''HAVE_FSYNC''@|$(HAVE_FSYNC)|g' \
 	      -e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \
 	      -e 's|@''HAVE_GETDOMAINNAME''@|$(HAVE_GETDOMAINNAME)|g' \
 	      -e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \
+	      -e 's|@''HAVE_GETGROUPS''@|$(HAVE_GETGROUPS)|g' \
 	      -e 's|@''HAVE_GETHOSTNAME''@|$(HAVE_GETHOSTNAME)|g' \
 	      -e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \
 	      -e 's|@''HAVE_GETUSERSHELL''@|$(HAVE_GETUSERSHELL)|g' \
+	      -e 's|@''HAVE_LCHOWN''@|$(HAVE_LCHOWN)|g' \
 	      -e 's|@''HAVE_LINK''@|$(HAVE_LINK)|g' \
+	      -e 's|@''HAVE_LINKAT''@|$(HAVE_LINKAT)|g' \
+	      -e 's|@''HAVE_PIPE2''@|$(HAVE_PIPE2)|g' \
+	      -e 's|@''HAVE_PREAD''@|$(HAVE_PREAD)|g' \
 	      -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \
+	      -e 's|@''HAVE_READLINKAT''@|$(HAVE_READLINKAT)|g' \
 	      -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \
+	      -e 's|@''HAVE_SYMLINK''@|$(HAVE_SYMLINK)|g' \
+	      -e 's|@''HAVE_SYMLINKAT''@|$(HAVE_SYMLINKAT)|g' \
+	      -e 's|@''HAVE_UNLINKAT''@|$(HAVE_UNLINKAT)|g' \
+	      -e 's|@''HAVE_USLEEP''@|$(HAVE_USLEEP)|g' \
 	      -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \
 	      -e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \
 	      -e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \
 	      -e 's|@''HAVE_SYS_PARAM_H''@|$(HAVE_SYS_PARAM_H)|g' \
 	      -e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \
 	      -e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \
+	      -e 's|@''REPLACE_DUP''@|$(REPLACE_DUP)|g' \
+	      -e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \
 	      -e 's|@''REPLACE_FCHDIR''@|$(REPLACE_FCHDIR)|g' \
+	      -e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \
 	      -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \
+	      -e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \
 	      -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \
 	      -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \
+	      -e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \
+	      -e 's|@''REPLACE_LINKAT''@|$(REPLACE_LINKAT)|g' \
 	      -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \
+	      -e 's|@''REPLACE_PREAD''@|$(REPLACE_PREAD)|g' \
+	      -e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \
+	      -e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \
+	      -e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \
+	      -e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \
+	      -e 's|@''REPLACE_UNLINK''@|$(REPLACE_UNLINK)|g' \
+	      -e 's|@''REPLACE_UNLINKAT''@|$(REPLACE_UNLINKAT)|g' \
+	      -e 's|@''REPLACE_USLEEP''@|$(REPLACE_USLEEP)|g' \
 	      -e 's|@''REPLACE_WRITE''@|$(REPLACE_WRITE)|g' \
 	      -e 's|@''UNISTD_H_HAVE_WINSOCK2_H''@|$(UNISTD_H_HAVE_WINSOCK2_H)|g' \
+	      -e 's|@''UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS''@|$(UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS)|g' \
 	      -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+	      -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
 	      < $(srcdir)/unistd.in.h; \
-	} > $@-t
+	} > $@-t && \
 	mv $@-t $@
 MOSTLYCLEANFILES += unistd.h unistd.h-t
 
@@ -1279,8 +1505,8 @@ BUILT_SOURCES += $(WCHAR_H)
 
 # We need the following in order to create <wchar.h> when the system
 # version does not work standalone.
-wchar.h: wchar.in.h
-	rm -f $@-t $@
+wchar.h: wchar.in.h $(LINK_WARNING_H) $(ARG_NONNULL_H)
+	$(AM_V_GEN)rm -f $@-t $@ && \
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
 	  sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
 	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
@@ -1322,8 +1548,9 @@ wchar.h: wchar.in.h
 	      -e 's|@''REPLACE_WCSNRTOMBS''@|$(REPLACE_WCSNRTOMBS)|g' \
 	      -e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \
 	      -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+	      -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
 	    < $(srcdir)/wchar.in.h; \
-	} > $@-t
+	} > $@-t && \
 	mv $@-t $@
 MOSTLYCLEANFILES += wchar.h wchar.h-t
 
@@ -1338,7 +1565,7 @@ BUILT_SOURCES += $(WCTYPE_H)
 # We need the following in order to create <wctype.h> when the system
 # doesn't have one that works with the given compiler.
 wctype.h: wctype.in.h
-	rm -f $@-t $@
+	$(AM_V_GEN)rm -f $@-t $@ && \
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
 	  sed -e 's/@''HAVE_WCTYPE_H''@/$(HAVE_WCTYPE_H)/g' \
 	      -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
@@ -1348,7 +1575,7 @@ wctype.h: wctype.in.h
 	      -e 's/@''HAVE_WINT_T''@/$(HAVE_WINT_T)/g' \
 	      -e 's/@''REPLACE_ISWCNTRL''@/$(REPLACE_ISWCNTRL)/g' \
 	      < $(srcdir)/wctype.in.h; \
-	} > $@-t
+	} > $@-t && \
 	mv $@-t $@
 MOSTLYCLEANFILES += wctype.h wctype.h-t
 
@@ -1370,5 +1597,3 @@ mostlyclean-local: mostlyclean-generic
 	  fi; \
 	done; \
 	:
-
--include $(top_srcdir)/git.mk
diff --git a/libmissing/alloca.c b/libmissing/alloca.c
index 3a1f4e2..b652765 100644
--- a/libmissing/alloca.c
+++ b/libmissing/alloca.c
@@ -81,37 +81,37 @@ long i00afunc ();
    STACK_DIRECTION = 0 => direction of growth unknown  */
 
 #  ifndef STACK_DIRECTION
-#   define STACK_DIRECTION	0	/* Direction unknown.  */
+#   define STACK_DIRECTION      0       /* Direction unknown.  */
 #  endif
 
 #  if STACK_DIRECTION != 0
 
-#   define STACK_DIR	STACK_DIRECTION	/* Known at compile-time.  */
+#   define STACK_DIR    STACK_DIRECTION /* Known at compile-time.  */
 
 #  else /* STACK_DIRECTION == 0; need run-time code.  */
 
-static int stack_dir;		/* 1 or -1 once known.  */
-#   define STACK_DIR	stack_dir
+static int stack_dir;           /* 1 or -1 once known.  */
+#   define STACK_DIR    stack_dir
 
 static void
 find_stack_direction (void)
 {
-  static char *addr = NULL;	/* Address of first `dummy', once known.  */
-  auto char dummy;		/* To get stack address.  */
+  static char *addr = NULL;     /* Address of first `dummy', once known.  */
+  auto char dummy;              /* To get stack address.  */
 
   if (addr == NULL)
-    {				/* Initial entry.  */
+    {                           /* Initial entry.  */
       addr = ADDRESS_FUNCTION (dummy);
 
-      find_stack_direction ();	/* Recurse once.  */
+      find_stack_direction ();  /* Recurse once.  */
     }
   else
     {
       /* Second entry.  */
       if (ADDRESS_FUNCTION (dummy) > addr)
-	stack_dir = 1;		/* Stack grew upward.  */
+        stack_dir = 1;          /* Stack grew upward.  */
       else
-	stack_dir = -1;		/* Stack grew downward.  */
+        stack_dir = -1;         /* Stack grew downward.  */
     }
 }
 
@@ -124,21 +124,21 @@ find_stack_direction (void)
    It is very important that sizeof(header) agree with malloc
    alignment chunk size.  The following default should work okay.  */
 
-#  ifndef	ALIGN_SIZE
-#   define ALIGN_SIZE	sizeof(double)
+#  ifndef       ALIGN_SIZE
+#   define ALIGN_SIZE   sizeof(double)
 #  endif
 
 typedef union hdr
 {
-  char align[ALIGN_SIZE];	/* To force sizeof(header).  */
+  char align[ALIGN_SIZE];       /* To force sizeof(header).  */
   struct
     {
-      union hdr *next;		/* For chaining headers.  */
-      char *deep;		/* For stack depth measure.  */
+      union hdr *next;          /* For chaining headers.  */
+      char *deep;               /* For stack depth measure.  */
     } h;
 } header;
 
-static header *last_alloca_header = NULL;	/* -> last alloca header.  */
+static header *last_alloca_header = NULL;       /* -> last alloca header.  */
 
 /* Return a pointer to at least SIZE bytes of storage,
    which will be automatically reclaimed upon exit from
@@ -150,11 +150,11 @@ static header *last_alloca_header = NULL;	/* -> last alloca header.  */
 void *
 alloca (size_t size)
 {
-  auto char probe;		/* Probes stack depth: */
+  auto char probe;              /* Probes stack depth: */
   register char *depth = ADDRESS_FUNCTION (probe);
 
 #  if STACK_DIRECTION == 0
-  if (STACK_DIR == 0)		/* Unknown growth direction.  */
+  if (STACK_DIR == 0)           /* Unknown growth direction.  */
     find_stack_direction ();
 #  endif
 
@@ -162,7 +162,7 @@ alloca (size_t size)
      was allocated from deeper in the stack than currently.  */
 
   {
-    register header *hp;	/* Traverses linked list.  */
+    register header *hp;        /* Traverses linked list.  */
 
 #  ifdef emacs
     BLOCK_INPUT;
@@ -170,18 +170,18 @@ alloca (size_t size)
 
     for (hp = last_alloca_header; hp != NULL;)
       if ((STACK_DIR > 0 && hp->h.deep > depth)
-	  || (STACK_DIR < 0 && hp->h.deep < depth))
-	{
-	  register header *np = hp->h.next;
+          || (STACK_DIR < 0 && hp->h.deep < depth))
+        {
+          register header *np = hp->h.next;
 
-	  free (hp);		/* Collect garbage.  */
+          free (hp);            /* Collect garbage.  */
 
-	  hp = np;		/* -> next header.  */
-	}
+          hp = np;              /* -> next header.  */
+        }
       else
-	break;			/* Rest are not deeper.  */
+        break;                  /* Rest are not deeper.  */
 
-    last_alloca_header = hp;	/* -> last valid storage.  */
+    last_alloca_header = hp;    /* -> last valid storage.  */
 
 #  ifdef emacs
     UNBLOCK_INPUT;
@@ -189,7 +189,7 @@ alloca (size_t size)
   }
 
   if (size == 0)
-    return NULL;		/* No allocation required.  */
+    return NULL;                /* No allocation required.  */
 
   /* Allocate combined header + user data storage.  */
 
@@ -229,10 +229,10 @@ alloca (size_t size)
 /* Stack structures for CRAY-1, CRAY X-MP, and CRAY Y-MP */
 struct stack_control_header
   {
-    long shgrow:32;		/* Number of times stack has grown.  */
-    long shaseg:32;		/* Size of increments to stack.  */
-    long shhwm:32;		/* High water mark of stack.  */
-    long shsize:32;		/* Current size of stack (all segments).  */
+    long shgrow:32;             /* Number of times stack has grown.  */
+    long shaseg:32;             /* Size of increments to stack.  */
+    long shhwm:32;              /* High water mark of stack.  */
+    long shsize:32;             /* Current size of stack (all segments).  */
   };
 
 /* The stack segment linkage control information occurs at
@@ -244,21 +244,21 @@ struct stack_control_header
 
 struct stack_segment_linkage
   {
-    long ss[0200];		/* 0200 overflow words.  */
-    long sssize:32;		/* Number of words in this segment.  */
-    long ssbase:32;		/* Offset to stack base.  */
+    long ss[0200];              /* 0200 overflow words.  */
+    long sssize:32;             /* Number of words in this segment.  */
+    long ssbase:32;             /* Offset to stack base.  */
     long:32;
-    long sspseg:32;		/* Offset to linkage control of previous
-				   segment of stack.  */
+    long sspseg:32;             /* Offset to linkage control of previous
+                                   segment of stack.  */
     long:32;
-    long sstcpt:32;		/* Pointer to task common address block.  */
-    long sscsnm;		/* Private control structure number for
-				   microtasking.  */
-    long ssusr1;		/* Reserved for user.  */
-    long ssusr2;		/* Reserved for user.  */
-    long sstpid;		/* Process ID for pid based multi-tasking.  */
-    long ssgvup;		/* Pointer to multitasking thread giveup.  */
-    long sscray[7];		/* Reserved for Cray Research.  */
+    long sstcpt:32;             /* Pointer to task common address block.  */
+    long sscsnm;                /* Private control structure number for
+                                   microtasking.  */
+    long ssusr1;                /* Reserved for user.  */
+    long ssusr2;                /* Reserved for user.  */
+    long sstpid;                /* Process ID for pid based multi-tasking.  */
+    long ssgvup;                /* Pointer to multitasking thread giveup.  */
+    long sscray[7];             /* Reserved for Cray Research.  */
     long ssa0;
     long ssa1;
     long ssa2;
@@ -282,27 +282,27 @@ struct stack_segment_linkage
    returned by the STKSTAT library routine.  */
 struct stk_stat
   {
-    long now;			/* Current total stack size.  */
-    long maxc;			/* Amount of contiguous space which would
-				   be required to satisfy the maximum
-				   stack demand to date.  */
-    long high_water;		/* Stack high-water mark.  */
-    long overflows;		/* Number of stack overflow ($STKOFEN) calls.  */
-    long hits;			/* Number of internal buffer hits.  */
-    long extends;		/* Number of block extensions.  */
-    long stko_mallocs;		/* Block allocations by $STKOFEN.  */
-    long underflows;		/* Number of stack underflow calls ($STKRETN).  */
-    long stko_free;		/* Number of deallocations by $STKRETN.  */
-    long stkm_free;		/* Number of deallocations by $STKMRET.  */
-    long segments;		/* Current number of stack segments.  */
-    long maxs;			/* Maximum number of stack segments so far.  */
-    long pad_size;		/* Stack pad size.  */
-    long current_address;	/* Current stack segment address.  */
-    long current_size;		/* Current stack segment size.  This
-				   number is actually corrupted by STKSTAT to
-				   include the fifteen word trailer area.  */
-    long initial_address;	/* Address of initial segment.  */
-    long initial_size;		/* Size of initial segment.  */
+    long now;                   /* Current total stack size.  */
+    long maxc;                  /* Amount of contiguous space which would
+                                   be required to satisfy the maximum
+                                   stack demand to date.  */
+    long high_water;            /* Stack high-water mark.  */
+    long overflows;             /* Number of stack overflow ($STKOFEN) calls.  */
+    long hits;                  /* Number of internal buffer hits.  */
+    long extends;               /* Number of block extensions.  */
+    long stko_mallocs;          /* Block allocations by $STKOFEN.  */
+    long underflows;            /* Number of stack underflow calls ($STKRETN).  */
+    long stko_free;             /* Number of deallocations by $STKRETN.  */
+    long stkm_free;             /* Number of deallocations by $STKMRET.  */
+    long segments;              /* Current number of stack segments.  */
+    long maxs;                  /* Maximum number of stack segments so far.  */
+    long pad_size;              /* Stack pad size.  */
+    long current_address;       /* Current stack segment address.  */
+    long current_size;          /* Current stack segment size.  This
+                                   number is actually corrupted by STKSTAT to
+                                   include the fifteen word trailer area.  */
+    long initial_address;       /* Address of initial segment.  */
+    long initial_size;          /* Size of initial segment.  */
   };
 
 /* The following structure describes the data structure which trails
@@ -311,13 +311,13 @@ struct stk_stat
 
 struct stk_trailer
   {
-    long this_address;		/* Address of this block.  */
-    long this_size;		/* Size of this block (does not include
-				   this trailer).  */
+    long this_address;          /* Address of this block.  */
+    long this_size;             /* Size of this block (does not include
+                                   this trailer).  */
     long unknown2;
     long unknown3;
-    long link;			/* Address of trailer block of previous
-				   segment.  */
+    long link;                  /* Address of trailer block of previous
+                                   segment.  */
     long unknown5;
     long unknown6;
     long unknown7;
@@ -355,8 +355,8 @@ i00afunc (long *address)
   /* Set up the iteration.  */
 
   trailer = (struct stk_trailer *) (status.current_address
-				    + status.current_size
-				    - 15);
+                                    + status.current_size
+                                    - 15);
 
   /* There must be at least one stack segment.  Therefore it is
      a fatal error if "trailer" is null.  */
@@ -371,10 +371,10 @@ i00afunc (long *address)
       block = (long *) trailer->this_address;
       size = trailer->this_size;
       if (block == 0 || size == 0)
-	abort ();
+        abort ();
       trailer = (struct stk_trailer *) trailer->link;
       if ((block <= address) && (address < (block + size)))
-	break;
+        break;
     }
 
   /* Set the result to the offset in this segment and add the sizes
@@ -390,7 +390,7 @@ i00afunc (long *address)
   do
     {
       if (trailer->this_size <= 0)
-	abort ();
+        abort ();
       result += trailer->this_size;
       trailer = (struct stk_trailer *) trailer->link;
     }
@@ -453,7 +453,7 @@ i00afunc (long address)
       fprintf (stderr, "%011o %011o %011o\n", this_segment, address, stkl);
 #    endif
       if (pseg == 0)
-	break;
+        break;
       stkl = stkl - pseg;
       ssptr = (struct stack_segment_linkage *) stkl;
       size = ssptr->sssize;
diff --git a/libmissing/alloca.in.h b/libmissing/alloca.in.h
index 3d4f88b..eeca595 100644
--- a/libmissing/alloca.in.h
+++ b/libmissing/alloca.in.h
@@ -1,7 +1,7 @@
 /* Memory allocation on the stack.
 
-   Copyright (C) 1995, 1999, 2001-2004, 2006-2008 Free Software
-   Foundation, Inc.
+   Copyright (C) 1995, 1999, 2001-2004, 2006-2009 Free Software Foundation,
+   Inc.
 
    This program is free software; you can redistribute it and/or modify it
    under the terms of the GNU Lesser General Public License as published
diff --git a/libmissing/arpa_inet.in.h b/libmissing/arpa_inet.in.h
index 85ea0d0..d4dee01 100644
--- a/libmissing/arpa_inet.in.h
+++ b/libmissing/arpa_inet.in.h
@@ -1,6 +1,6 @@
 /* A GNU-like <arpa/inet.h>.
 
-   Copyright (C) 2005-2006, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2005-2006, 2008-2009 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -19,8 +19,11 @@
 #ifndef _GL_ARPA_INET_H
 
 /* Gnulib's sys/socket.h is responsible for pulling in winsock2.h etc
-   under MinGW. */
-#include <sys/socket.h>
+   under MinGW.
+   But avoid namespace pollution on glibc systems.  */
+#ifndef __GLIBC__
+# include <sys/socket.h>
+#endif
 
 #if @HAVE_ARPA_INET_H@
 
@@ -38,6 +41,8 @@
 
 /* The definition of GL_LINK_WARNING is copied here.  */
 
+/* The definition of _GL_ARG_NONNULL is copied here.  */
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -60,7 +65,8 @@ extern "C" {
    For more details, see the POSIX:2001 specification
    <http://www.opengroup.org/susv3xsh/inet_ntop.html>.  */
 extern const char *inet_ntop (int af, const void *restrict src,
-			      char *restrict dst, socklen_t cnt);
+                              char *restrict dst, socklen_t cnt)
+     _GL_ARG_NONNULL ((2, 3));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef inet_ntop
@@ -72,13 +78,14 @@ extern const char *inet_ntop (int af, const void *restrict src,
 
 #if @GNULIB_INET_PTON@
 # if !@HAVE_DECL_INET_PTON@
-extern int inet_pton (int af, const char *restrict src, void *restrict dst);
+extern int inet_pton (int af, const char *restrict src, void *restrict dst)
+     _GL_ARG_NONNULL ((2, 3));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef inet_pton
 # define inet_pton(af,src,dst) \
   (GL_LINK_WARNING ("inet_pton is unportable - " \
-		    "use gnulib module inet_pton for portability"), \
+                    "use gnulib module inet_pton for portability"), \
    inet_pton (af, src, dst))
 #endif
 
diff --git a/libmissing/asnprintf.c b/libmissing/asnprintf.c
index 3b374a2..ba4d1f4 100644
--- a/libmissing/asnprintf.c
+++ b/libmissing/asnprintf.c
@@ -1,5 +1,5 @@
 /* Formatted output to strings.
-   Copyright (C) 1999, 2002, 2006 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2002, 2006, 2009 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/libmissing/bind.c b/libmissing/bind.c
index 8cd88db..84f3916 100644
--- a/libmissing/bind.c
+++ b/libmissing/bind.c
@@ -1,6 +1,6 @@
 /* bind.c --- wrappers for Windows bind function
 
-   Copyright (C) 2008 Free Software Foundation, Inc.
+   Copyright (C) 2008, 2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/libmissing/close-hook.c b/libmissing/close-hook.c
index afe8e56..427629a 100644
--- a/libmissing/close-hook.c
+++ b/libmissing/close-hook.c
@@ -66,7 +66,7 @@ register_close_hook (close_hook_fn hook, struct close_hook *link)
     {
       /* The link is already in use.  */
       if (link->private_fn != hook)
-	abort ();
+        abort ();
     }
 }
 
diff --git a/libmissing/close.c b/libmissing/close.c
index 9671aca..5266d41 100644
--- a/libmissing/close.c
+++ b/libmissing/close.c
@@ -33,7 +33,7 @@ rpl_close (int fd)
   int retval = close (fd);
 #endif
 
-#ifdef FCHDIR_REPLACEMENT
+#if REPLACE_FCHDIR
   if (retval >= 0)
     _gl_unregister_fd (fd);
 #endif
diff --git a/libmissing/config.charset b/libmissing/config.charset
old mode 100755
new mode 100644
index c1a7f5d..217bef1
--- a/libmissing/config.charset
+++ b/libmissing/config.charset
@@ -123,561 +123,561 @@ echo "# It was automatically generated from config.charset."
 # List of references, updated during installation:
 echo "# Packages using this file: "
 case "$os" in
-    linux-gnulibc1*)
-	# Linux libc5 doesn't have nl_langinfo(CODESET); therefore
-	# localcharset.c falls back to using the full locale name
-	# from the environment variables.
-	echo "C ASCII"
-	echo "POSIX ASCII"
-	for l in af af_ZA ca ca_ES da da_DK de de_AT de_BE de_CH de_DE de_LU \
-	         en en_AU en_BW en_CA en_DK en_GB en_IE en_NZ en_US en_ZA \
-	         en_ZW es es_AR es_BO es_CL es_CO es_DO es_EC es_ES es_GT \
-	         es_HN es_MX es_PA es_PE es_PY es_SV es_US es_UY es_VE et \
-	         et_EE eu eu_ES fi fi_FI fo fo_FO fr fr_BE fr_CA fr_CH fr_FR \
-	         fr_LU ga ga_IE gl gl_ES id id_ID in in_ID is is_IS it it_CH \
-	         it_IT kl kl_GL nl nl_BE nl_NL no no_NO pt pt_BR pt_PT sv \
-	         sv_FI sv_SE; do
-	  echo "$l ISO-8859-1"
-	  echo "$l.iso-8859-1 ISO-8859-1"
-	  echo "$l.iso-8859-15 ISO-8859-15"
-	  echo "$l.iso-8859-15@euro ISO-8859-15"
-	  echo "$l@euro ISO-8859-15"
-	  echo "$l.cp-437 CP437"
-	  echo "$l.cp-850 CP850"
-	  echo "$l.cp-1252 CP1252"
-	  echo "$l.cp-1252@euro CP1252"
-	  #echo "$l.atari-st ATARI-ST" # not a commonly used encoding
-	  echo "$l.utf-8 UTF-8"
-	  echo "$l.utf-8@euro UTF-8"
-	done
-	for l in cs cs_CZ hr hr_HR hu hu_HU pl pl_PL ro ro_RO sk sk_SK sl \
-	         sl_SI sr sr_CS sr_YU; do
-	  echo "$l ISO-8859-2"
-	  echo "$l.iso-8859-2 ISO-8859-2"
-	  echo "$l.cp-852 CP852"
-	  echo "$l.cp-1250 CP1250"
-	  echo "$l.utf-8 UTF-8"
-	done
-	for l in mk mk_MK ru ru_RU; do
-	  echo "$l ISO-8859-5"
-	  echo "$l.iso-8859-5 ISO-8859-5"
-	  echo "$l.koi8-r KOI8-R"
-	  echo "$l.cp-866 CP866"
-	  echo "$l.cp-1251 CP1251"
-	  echo "$l.utf-8 UTF-8"
-	done
-	for l in ar ar_SA; do
-	  echo "$l ISO-8859-6"
-	  echo "$l.iso-8859-6 ISO-8859-6"
-	  echo "$l.cp-864 CP864"
-	  #echo "$l.cp-868 CP868" # not a commonly used encoding
-	  echo "$l.cp-1256 CP1256"
-	  echo "$l.utf-8 UTF-8"
-	done
-	for l in el el_GR gr gr_GR; do
-	  echo "$l ISO-8859-7"
-	  echo "$l.iso-8859-7 ISO-8859-7"
-	  echo "$l.cp-869 CP869"
-	  echo "$l.cp-1253 CP1253"
-	  echo "$l.cp-1253@euro CP1253"
-	  echo "$l.utf-8 UTF-8"
-	  echo "$l.utf-8@euro UTF-8"
-	done
-	for l in he he_IL iw iw_IL; do
-	  echo "$l ISO-8859-8"
-	  echo "$l.iso-8859-8 ISO-8859-8"
-	  echo "$l.cp-862 CP862"
-	  echo "$l.cp-1255 CP1255"
-	  echo "$l.utf-8 UTF-8"
-	done
-	for l in tr tr_TR; do
-	  echo "$l ISO-8859-9"
-	  echo "$l.iso-8859-9 ISO-8859-9"
-	  echo "$l.cp-857 CP857"
-	  echo "$l.cp-1254 CP1254"
-	  echo "$l.utf-8 UTF-8"
-	done
-	for l in lt lt_LT lv lv_LV; do
-	  #echo "$l BALTIC" # not a commonly used encoding, wrong encoding name
-	  echo "$l ISO-8859-13"
-	done
-	for l in ru_UA uk uk_UA; do
-	  echo "$l KOI8-U"
-	done
-	for l in zh zh_CN; do
-	  #echo "$l GB_2312-80" # not a commonly used encoding, wrong encoding name
-	  echo "$l GB2312"
-	done
-	for l in ja ja_JP ja_JP.EUC; do
-	  echo "$l EUC-JP"
-	done
-	for l in ko ko_KR; do
-	  echo "$l EUC-KR"
-	done
-	for l in th th_TH; do
-	  echo "$l TIS-620"
-	done
-	for l in fa fa_IR; do
-	  #echo "$l ISIRI-3342" # a broken encoding
-	  echo "$l.utf-8 UTF-8"
-	done
-	;;
-    linux* | *-gnu*)
-	# With glibc-2.1 or newer, we don't need any canonicalization,
-	# because glibc has iconv and both glibc and libiconv support all
-	# GNU canonical names directly. Therefore, the Makefile does not
-	# need to install the alias file at all.
-	# The following applies only to glibc-2.0.x and older libcs.
-	echo "ISO_646.IRV:1983 ASCII"
-	;;
-    aix*)
-	echo "ISO8859-1 ISO-8859-1"
-	echo "ISO8859-2 ISO-8859-2"
-	echo "ISO8859-5 ISO-8859-5"
-	echo "ISO8859-6 ISO-8859-6"
-	echo "ISO8859-7 ISO-8859-7"
-	echo "ISO8859-8 ISO-8859-8"
-	echo "ISO8859-9 ISO-8859-9"
-	echo "ISO8859-15 ISO-8859-15"
-	echo "IBM-850 CP850"
-	echo "IBM-856 CP856"
-	echo "IBM-921 ISO-8859-13"
-	echo "IBM-922 CP922"
-	echo "IBM-932 CP932"
-	echo "IBM-943 CP943"
-	echo "IBM-1046 CP1046"
-	echo "IBM-1124 CP1124"
-	echo "IBM-1129 CP1129"
-	echo "IBM-1252 CP1252"
-	echo "IBM-eucCN GB2312"
-	echo "IBM-eucJP EUC-JP"
-	echo "IBM-eucKR EUC-KR"
-	echo "IBM-eucTW EUC-TW"
-	echo "big5 BIG5"
-	echo "GBK GBK"
-	echo "TIS-620 TIS-620"
-	echo "UTF-8 UTF-8"
-	;;
-    hpux*)
-	echo "iso88591 ISO-8859-1"
-	echo "iso88592 ISO-8859-2"
-	echo "iso88595 ISO-8859-5"
-	echo "iso88596 ISO-8859-6"
-	echo "iso88597 ISO-8859-7"
-	echo "iso88598 ISO-8859-8"
-	echo "iso88599 ISO-8859-9"
-	echo "iso885915 ISO-8859-15"
-	echo "roman8 HP-ROMAN8"
-	echo "arabic8 HP-ARABIC8"
-	echo "greek8 HP-GREEK8"
-	echo "hebrew8 HP-HEBREW8"
-	echo "turkish8 HP-TURKISH8"
-	echo "kana8 HP-KANA8"
-	echo "tis620 TIS-620"
-	echo "big5 BIG5"
-	echo "eucJP EUC-JP"
-	echo "eucKR EUC-KR"
-	echo "eucTW EUC-TW"
-	echo "hp15CN GB2312"
-	#echo "ccdc ?" # what is this?
-	echo "SJIS SHIFT_JIS"
-	echo "utf8 UTF-8"
-	;;
-    irix*)
-	echo "ISO8859-1 ISO-8859-1"
-	echo "ISO8859-2 ISO-8859-2"
-	echo "ISO8859-5 ISO-8859-5"
-	echo "ISO8859-7 ISO-8859-7"
-	echo "ISO8859-9 ISO-8859-9"
-	echo "eucCN GB2312"
-	echo "eucJP EUC-JP"
-	echo "eucKR EUC-KR"
-	echo "eucTW EUC-TW"
-	;;
-    osf*)
-	echo "ISO8859-1 ISO-8859-1"
-	echo "ISO8859-2 ISO-8859-2"
-	echo "ISO8859-4 ISO-8859-4"
-	echo "ISO8859-5 ISO-8859-5"
-	echo "ISO8859-7 ISO-8859-7"
-	echo "ISO8859-8 ISO-8859-8"
-	echo "ISO8859-9 ISO-8859-9"
-	echo "ISO8859-15 ISO-8859-15"
-	echo "cp850 CP850"
-	echo "big5 BIG5"
-	echo "dechanyu DEC-HANYU"
-	echo "dechanzi GB2312"
-	echo "deckanji DEC-KANJI"
-	echo "deckorean EUC-KR"
-	echo "eucJP EUC-JP"
-	echo "eucKR EUC-KR"
-	echo "eucTW EUC-TW"
-	echo "GBK GBK"
-	echo "KSC5601 CP949"
-	echo "sdeckanji EUC-JP"
-	echo "SJIS SHIFT_JIS"
-	echo "TACTIS TIS-620"
-	echo "UTF-8 UTF-8"
-	;;
-    solaris*)
-	echo "646 ASCII"
-	echo "ISO8859-1 ISO-8859-1"
-	echo "ISO8859-2 ISO-8859-2"
-	echo "ISO8859-3 ISO-8859-3"
-	echo "ISO8859-4 ISO-8859-4"
-	echo "ISO8859-5 ISO-8859-5"
-	echo "ISO8859-6 ISO-8859-6"
-	echo "ISO8859-7 ISO-8859-7"
-	echo "ISO8859-8 ISO-8859-8"
-	echo "ISO8859-9 ISO-8859-9"
-	echo "ISO8859-15 ISO-8859-15"
-	echo "koi8-r KOI8-R"
-	echo "ansi-1251 CP1251"
-	echo "BIG5 BIG5"
-	echo "Big5-HKSCS BIG5-HKSCS"
-	echo "gb2312 GB2312"
-	echo "GBK GBK"
-	echo "GB18030 GB18030"
-	echo "cns11643 EUC-TW"
-	echo "5601 EUC-KR"
-	echo "ko_KR.johap92 JOHAB"
-	echo "eucJP EUC-JP"
-	echo "PCK SHIFT_JIS"
-	echo "TIS620.2533 TIS-620"
-	#echo "sun_eu_greek ?" # what is this?
-	echo "UTF-8 UTF-8"
-	;;
-    freebsd* | os2*)
-	# FreeBSD 4.2 doesn't have nl_langinfo(CODESET); therefore
-	# localcharset.c falls back to using the full locale name
-	# from the environment variables.
-	# Likewise for OS/2. OS/2 has XFree86 just like FreeBSD. Just
-	# reuse FreeBSD's locale data for OS/2.
-	echo "C ASCII"
-	echo "US-ASCII ASCII"
-	for l in la_LN lt_LN; do
-	  echo "$l.ASCII ASCII"
-	done
-	for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \
-	         fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT la_LN \
-	         lt_LN nl_BE nl_NL no_NO pt_PT sv_SE; do
-	  echo "$l.ISO_8859-1 ISO-8859-1"
-	  echo "$l.DIS_8859-15 ISO-8859-15"
-	done
-	for l in cs_CZ hr_HR hu_HU la_LN lt_LN pl_PL sl_SI; do
-	  echo "$l.ISO_8859-2 ISO-8859-2"
-	done
-	for l in la_LN lt_LT; do
-	  echo "$l.ISO_8859-4 ISO-8859-4"
-	done
-	for l in ru_RU ru_SU; do
-	  echo "$l.KOI8-R KOI8-R"
-	  echo "$l.ISO_8859-5 ISO-8859-5"
-	  echo "$l.CP866 CP866"
-	done
-	echo "uk_UA.KOI8-U KOI8-U"
-	echo "zh_TW.BIG5 BIG5"
-	echo "zh_TW.Big5 BIG5"
-	echo "zh_CN.EUC GB2312"
-	echo "ja_JP.EUC EUC-JP"
-	echo "ja_JP.SJIS SHIFT_JIS"
-	echo "ja_JP.Shift_JIS SHIFT_JIS"
-	echo "ko_KR.EUC EUC-KR"
-	;;
-    netbsd*)
-	echo "646 ASCII"
-	echo "ISO8859-1 ISO-8859-1"
-	echo "ISO8859-2 ISO-8859-2"
-	echo "ISO8859-4 ISO-8859-4"
-	echo "ISO8859-5 ISO-8859-5"
-	echo "ISO8859-7 ISO-8859-7"
-	echo "ISO8859-13 ISO-8859-13"
-	echo "ISO8859-15 ISO-8859-15"
-	echo "eucCN GB2312"
-	echo "eucJP EUC-JP"
-	echo "eucKR EUC-KR"
-	echo "eucTW EUC-TW"
-	echo "BIG5 BIG5"
-	echo "SJIS SHIFT_JIS"
-	;;
-    openbsd*)
-	echo "646 ASCII"
-	echo "ISO8859-1 ISO-8859-1"
-	echo "ISO8859-2 ISO-8859-2"
-	echo "ISO8859-4 ISO-8859-4"
-	echo "ISO8859-5 ISO-8859-5"
-	echo "ISO8859-7 ISO-8859-7"
-	echo "ISO8859-13 ISO-8859-13"
-	echo "ISO8859-15 ISO-8859-15"
-	;;
-    darwin[56]*)
-	# Darwin 6.8 doesn't have nl_langinfo(CODESET); therefore
-	# localcharset.c falls back to using the full locale name
-	# from the environment variables.
-	echo "C ASCII"
-	for l in en_AU en_CA en_GB en_US la_LN; do
-	  echo "$l.US-ASCII ASCII"
-	done
-	for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \
-	         fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT nl_BE \
-	         nl_NL no_NO pt_PT sv_SE; do
-	  echo "$l ISO-8859-1"
-	  echo "$l.ISO8859-1 ISO-8859-1"
-	  echo "$l.ISO8859-15 ISO-8859-15"
-	done
-	for l in la_LN; do
-	  echo "$l.ISO8859-1 ISO-8859-1"
-	  echo "$l.ISO8859-15 ISO-8859-15"
-	done
-	for l in cs_CZ hr_HR hu_HU la_LN pl_PL sl_SI; do
-	  echo "$l.ISO8859-2 ISO-8859-2"
-	done
-	for l in la_LN lt_LT; do
-	  echo "$l.ISO8859-4 ISO-8859-4"
-	done
-	for l in ru_RU; do
-	  echo "$l.KOI8-R KOI8-R"
-	  echo "$l.ISO8859-5 ISO-8859-5"
-	  echo "$l.CP866 CP866"
-	done
-	for l in bg_BG; do
-	  echo "$l.CP1251 CP1251"
-	done
-	echo "uk_UA.KOI8-U KOI8-U"
-	echo "zh_TW.BIG5 BIG5"
-	echo "zh_TW.Big5 BIG5"
-	echo "zh_CN.EUC GB2312"
-	echo "ja_JP.EUC EUC-JP"
-	echo "ja_JP.SJIS SHIFT_JIS"
-	echo "ko_KR.EUC EUC-KR"
-	;;
-    darwin*)
-	# Darwin 7.5 has nl_langinfo(CODESET), but sometimes its value is
-	# useless:
-	# - It returns the empty string when LANG is set to a locale of the
-	#   form ll_CC, although ll_CC/LC_CTYPE is a symlink to an UTF-8
-	#   LC_CTYPE file.
-	# - The environment variables LANG, LC_CTYPE, LC_ALL are not set by
-	#   the system; nl_langinfo(CODESET) returns "US-ASCII" in this case.
-	# - The documentation says:
-	#     "... all code that calls BSD system routines should ensure
-	#      that the const *char parameters of these routines are in UTF-8
-	#      encoding. All BSD system functions expect their string
-	#      parameters to be in UTF-8 encoding and nothing else."
-	#   It also says
-	#     "An additional caveat is that string parameters for files,
-	#      paths, and other file-system entities must be in canonical
-	#      UTF-8. In a canonical UTF-8 Unicode string, all decomposable
-	#      characters are decomposed ..."
-	#   but this is not true: You can pass non-decomposed UTF-8 strings
-	#   to file system functions, and it is the OS which will convert
-	#   them to decomposed UTF-8 before accessing the file system.
-	# - The Apple Terminal application displays UTF-8 by default.
-	# - However, other applications are free to use different encodings:
-	#   - xterm uses ISO-8859-1 by default.
-	#   - TextEdit uses MacRoman by default.
-	# We prefer UTF-8 over decomposed UTF-8-MAC because one should
-	# minimize the use of decomposed Unicode. Unfortunately, through the
-	# Darwin file system, decomposed UTF-8 strings are leaked into user
-	# space nevertheless.
-	# Then there are also the locales with encodings other than US-ASCII
-	# and UTF-8. These locales can be occasionally useful to users (e.g.
-	# when grepping through ISO-8859-1 encoded text files), when all their
-	# file names are in US-ASCII.
-	echo "ISO8859-1 ISO-8859-1"
-	echo "ISO8859-2 ISO-8859-2"
-	echo "ISO8859-4 ISO-8859-4"
-	echo "ISO8859-5 ISO-8859-5"
-	echo "ISO8859-7 ISO-8859-7"
-	echo "ISO8859-9 ISO-8859-9"
-	echo "ISO8859-13 ISO-8859-13"
-	echo "ISO8859-15 ISO-8859-15"
-	echo "KOI8-R KOI8-R"
-	echo "KOI8-U KOI8-U"
-	echo "CP866 CP866"
-	echo "CP949 CP949"
-	echo "CP1131 CP1131"
-	echo "CP1251 CP1251"
-	echo "eucCN GB2312"
-	echo "GB2312 GB2312"
-	echo "eucJP EUC-JP"
-	echo "eucKR EUC-KR"
-	echo "Big5 BIG5"
-	echo "Big5HKSCS BIG5-HKSCS"
-	echo "GBK GBK"
-	echo "GB18030 GB18030"
-	echo "SJIS SHIFT_JIS"
-	echo "ARMSCII-8 ARMSCII-8"
-	echo "PT154 PT154"
-	#echo "ISCII-DEV ?"
-	echo "* UTF-8"
-	;;
-    beos* | haiku*)
-	# BeOS and Haiku have a single locale, and it has UTF-8 encoding.
-	echo "* UTF-8"
-	;;
-    msdosdjgpp*)
-	# DJGPP 2.03 doesn't have nl_langinfo(CODESET); therefore
-	# localcharset.c falls back to using the full locale name
-	# from the environment variables.
-	echo "#"
-	echo "# The encodings given here may not all be correct."
-	echo "# If you find that the encoding given for your language and"
-	echo "# country is not the one your DOS machine actually uses, just"
-	echo "# correct it in this file, and send a mail to"
-	echo "# Juan Manuel Guerrero <[email protected]>"
-	echo "# and Bruno Haible <[email protected]>."
-	echo "#"
-	echo "C ASCII"
-	# ISO-8859-1 languages
-	echo "ca CP850"
-	echo "ca_ES CP850"
-	echo "da CP865"    # not CP850 ??
-	echo "da_DK CP865" # not CP850 ??
-	echo "de CP850"
-	echo "de_AT CP850"
-	echo "de_CH CP850"
-	echo "de_DE CP850"
-	echo "en CP850"
-	echo "en_AU CP850" # not CP437 ??
-	echo "en_CA CP850"
-	echo "en_GB CP850"
-	echo "en_NZ CP437"
-	echo "en_US CP437"
-	echo "en_ZA CP850" # not CP437 ??
-	echo "es CP850"
-	echo "es_AR CP850"
-	echo "es_BO CP850"
-	echo "es_CL CP850"
-	echo "es_CO CP850"
-	echo "es_CR CP850"
-	echo "es_CU CP850"
-	echo "es_DO CP850"
-	echo "es_EC CP850"
-	echo "es_ES CP850"
-	echo "es_GT CP850"
-	echo "es_HN CP850"
-	echo "es_MX CP850"
-	echo "es_NI CP850"
-	echo "es_PA CP850"
-	echo "es_PY CP850"
-	echo "es_PE CP850"
-	echo "es_SV CP850"
-	echo "es_UY CP850"
-	echo "es_VE CP850"
-	echo "et CP850"
-	echo "et_EE CP850"
-	echo "eu CP850"
-	echo "eu_ES CP850"
-	echo "fi CP850"
-	echo "fi_FI CP850"
-	echo "fr CP850"
-	echo "fr_BE CP850"
-	echo "fr_CA CP850"
-	echo "fr_CH CP850"
-	echo "fr_FR CP850"
-	echo "ga CP850"
-	echo "ga_IE CP850"
-	echo "gd CP850"
-	echo "gd_GB CP850"
-	echo "gl CP850"
-	echo "gl_ES CP850"
-	echo "id CP850"    # not CP437 ??
-	echo "id_ID CP850" # not CP437 ??
-	echo "is CP861"    # not CP850 ??
-	echo "is_IS CP861" # not CP850 ??
-	echo "it CP850"
-	echo "it_CH CP850"
-	echo "it_IT CP850"
-	echo "lt CP775"
-	echo "lt_LT CP775"
-	echo "lv CP775"
-	echo "lv_LV CP775"
-	echo "nb CP865"    # not CP850 ??
-	echo "nb_NO CP865" # not CP850 ??
-	echo "nl CP850"
-	echo "nl_BE CP850"
-	echo "nl_NL CP850"
-	echo "nn CP865"    # not CP850 ??
-	echo "nn_NO CP865" # not CP850 ??
-	echo "no CP865"    # not CP850 ??
-	echo "no_NO CP865" # not CP850 ??
-	echo "pt CP850"
-	echo "pt_BR CP850"
-	echo "pt_PT CP850"
-	echo "sv CP850"
-	echo "sv_SE CP850"
-	# ISO-8859-2 languages
-	echo "cs CP852"
-	echo "cs_CZ CP852"
-	echo "hr CP852"
-	echo "hr_HR CP852"
-	echo "hu CP852"
-	echo "hu_HU CP852"
-	echo "pl CP852"
-	echo "pl_PL CP852"
-	echo "ro CP852"
-	echo "ro_RO CP852"
-	echo "sk CP852"
-	echo "sk_SK CP852"
-	echo "sl CP852"
-	echo "sl_SI CP852"
-	echo "sq CP852"
-	echo "sq_AL CP852"
-	echo "sr CP852"    # CP852 or CP866 or CP855 ??
-	echo "sr_CS CP852" # CP852 or CP866 or CP855 ??
-	echo "sr_YU CP852" # CP852 or CP866 or CP855 ??
-	# ISO-8859-3 languages
-	echo "mt CP850"
-	echo "mt_MT CP850"
-	# ISO-8859-5 languages
-	echo "be CP866"
-	echo "be_BE CP866"
-	echo "bg CP866"    # not CP855 ??
-	echo "bg_BG CP866" # not CP855 ??
-	echo "mk CP866"    # not CP855 ??
-	echo "mk_MK CP866" # not CP855 ??
-	echo "ru CP866"
-	echo "ru_RU CP866"
-	echo "uk CP1125"
-	echo "uk_UA CP1125"
-	# ISO-8859-6 languages
-	echo "ar CP864"
-	echo "ar_AE CP864"
-	echo "ar_DZ CP864"
-	echo "ar_EG CP864"
-	echo "ar_IQ CP864"
-	echo "ar_IR CP864"
-	echo "ar_JO CP864"
-	echo "ar_KW CP864"
-	echo "ar_MA CP864"
-	echo "ar_OM CP864"
-	echo "ar_QA CP864"
-	echo "ar_SA CP864"
-	echo "ar_SY CP864"
-	# ISO-8859-7 languages
-	echo "el CP869"
-	echo "el_GR CP869"
-	# ISO-8859-8 languages
-	echo "he CP862"
-	echo "he_IL CP862"
-	# ISO-8859-9 languages
-	echo "tr CP857"
-	echo "tr_TR CP857"
-	# Japanese
-	echo "ja CP932"
-	echo "ja_JP CP932"
-	# Chinese
-	echo "zh_CN GBK"
-	echo "zh_TW CP950" # not CP938 ??
-	# Korean
-	echo "kr CP949"    # not CP934 ??
-	echo "kr_KR CP949" # not CP934 ??
-	# Thai
-	echo "th CP874"
-	echo "th_TH CP874"
-	# Other
-	echo "eo CP850"
-	echo "eo_EO CP850"
-	;;
+  linux-gnulibc1*)
+    # Linux libc5 doesn't have nl_langinfo(CODESET); therefore
+    # localcharset.c falls back to using the full locale name
+    # from the environment variables.
+    echo "C ASCII"
+    echo "POSIX ASCII"
+    for l in af af_ZA ca ca_ES da da_DK de de_AT de_BE de_CH de_DE de_LU \
+             en en_AU en_BW en_CA en_DK en_GB en_IE en_NZ en_US en_ZA \
+             en_ZW es es_AR es_BO es_CL es_CO es_DO es_EC es_ES es_GT \
+             es_HN es_MX es_PA es_PE es_PY es_SV es_US es_UY es_VE et \
+             et_EE eu eu_ES fi fi_FI fo fo_FO fr fr_BE fr_CA fr_CH fr_FR \
+             fr_LU ga ga_IE gl gl_ES id id_ID in in_ID is is_IS it it_CH \
+             it_IT kl kl_GL nl nl_BE nl_NL no no_NO pt pt_BR pt_PT sv \
+             sv_FI sv_SE; do
+      echo "$l ISO-8859-1"
+      echo "$l.iso-8859-1 ISO-8859-1"
+      echo "$l.iso-8859-15 ISO-8859-15"
+      echo "$l.iso-8859-15@euro ISO-8859-15"
+      echo "$l@euro ISO-8859-15"
+      echo "$l.cp-437 CP437"
+      echo "$l.cp-850 CP850"
+      echo "$l.cp-1252 CP1252"
+      echo "$l.cp-1252@euro CP1252"
+      #echo "$l.atari-st ATARI-ST" # not a commonly used encoding
+      echo "$l.utf-8 UTF-8"
+      echo "$l.utf-8@euro UTF-8"
+    done
+    for l in cs cs_CZ hr hr_HR hu hu_HU pl pl_PL ro ro_RO sk sk_SK sl \
+             sl_SI sr sr_CS sr_YU; do
+      echo "$l ISO-8859-2"
+      echo "$l.iso-8859-2 ISO-8859-2"
+      echo "$l.cp-852 CP852"
+      echo "$l.cp-1250 CP1250"
+      echo "$l.utf-8 UTF-8"
+    done
+    for l in mk mk_MK ru ru_RU; do
+      echo "$l ISO-8859-5"
+      echo "$l.iso-8859-5 ISO-8859-5"
+      echo "$l.koi8-r KOI8-R"
+      echo "$l.cp-866 CP866"
+      echo "$l.cp-1251 CP1251"
+      echo "$l.utf-8 UTF-8"
+    done
+    for l in ar ar_SA; do
+      echo "$l ISO-8859-6"
+      echo "$l.iso-8859-6 ISO-8859-6"
+      echo "$l.cp-864 CP864"
+      #echo "$l.cp-868 CP868" # not a commonly used encoding
+      echo "$l.cp-1256 CP1256"
+      echo "$l.utf-8 UTF-8"
+    done
+    for l in el el_GR gr gr_GR; do
+      echo "$l ISO-8859-7"
+      echo "$l.iso-8859-7 ISO-8859-7"
+      echo "$l.cp-869 CP869"
+      echo "$l.cp-1253 CP1253"
+      echo "$l.cp-1253@euro CP1253"
+      echo "$l.utf-8 UTF-8"
+      echo "$l.utf-8@euro UTF-8"
+    done
+    for l in he he_IL iw iw_IL; do
+      echo "$l ISO-8859-8"
+      echo "$l.iso-8859-8 ISO-8859-8"
+      echo "$l.cp-862 CP862"
+      echo "$l.cp-1255 CP1255"
+      echo "$l.utf-8 UTF-8"
+    done
+    for l in tr tr_TR; do
+      echo "$l ISO-8859-9"
+      echo "$l.iso-8859-9 ISO-8859-9"
+      echo "$l.cp-857 CP857"
+      echo "$l.cp-1254 CP1254"
+      echo "$l.utf-8 UTF-8"
+    done
+    for l in lt lt_LT lv lv_LV; do
+      #echo "$l BALTIC" # not a commonly used encoding, wrong encoding name
+      echo "$l ISO-8859-13"
+    done
+    for l in ru_UA uk uk_UA; do
+      echo "$l KOI8-U"
+    done
+    for l in zh zh_CN; do
+      #echo "$l GB_2312-80" # not a commonly used encoding, wrong encoding name
+      echo "$l GB2312"
+    done
+    for l in ja ja_JP ja_JP.EUC; do
+      echo "$l EUC-JP"
+    done
+    for l in ko ko_KR; do
+      echo "$l EUC-KR"
+    done
+    for l in th th_TH; do
+      echo "$l TIS-620"
+    done
+    for l in fa fa_IR; do
+      #echo "$l ISIRI-3342" # a broken encoding
+      echo "$l.utf-8 UTF-8"
+    done
+    ;;
+  linux* | *-gnu*)
+    # With glibc-2.1 or newer, we don't need any canonicalization,
+    # because glibc has iconv and both glibc and libiconv support all
+    # GNU canonical names directly. Therefore, the Makefile does not
+    # need to install the alias file at all.
+    # The following applies only to glibc-2.0.x and older libcs.
+    echo "ISO_646.IRV:1983 ASCII"
+    ;;
+  aix*)
+    echo "ISO8859-1 ISO-8859-1"
+    echo "ISO8859-2 ISO-8859-2"
+    echo "ISO8859-5 ISO-8859-5"
+    echo "ISO8859-6 ISO-8859-6"
+    echo "ISO8859-7 ISO-8859-7"
+    echo "ISO8859-8 ISO-8859-8"
+    echo "ISO8859-9 ISO-8859-9"
+    echo "ISO8859-15 ISO-8859-15"
+    echo "IBM-850 CP850"
+    echo "IBM-856 CP856"
+    echo "IBM-921 ISO-8859-13"
+    echo "IBM-922 CP922"
+    echo "IBM-932 CP932"
+    echo "IBM-943 CP943"
+    echo "IBM-1046 CP1046"
+    echo "IBM-1124 CP1124"
+    echo "IBM-1129 CP1129"
+    echo "IBM-1252 CP1252"
+    echo "IBM-eucCN GB2312"
+    echo "IBM-eucJP EUC-JP"
+    echo "IBM-eucKR EUC-KR"
+    echo "IBM-eucTW EUC-TW"
+    echo "big5 BIG5"
+    echo "GBK GBK"
+    echo "TIS-620 TIS-620"
+    echo "UTF-8 UTF-8"
+    ;;
+  hpux*)
+    echo "iso88591 ISO-8859-1"
+    echo "iso88592 ISO-8859-2"
+    echo "iso88595 ISO-8859-5"
+    echo "iso88596 ISO-8859-6"
+    echo "iso88597 ISO-8859-7"
+    echo "iso88598 ISO-8859-8"
+    echo "iso88599 ISO-8859-9"
+    echo "iso885915 ISO-8859-15"
+    echo "roman8 HP-ROMAN8"
+    echo "arabic8 HP-ARABIC8"
+    echo "greek8 HP-GREEK8"
+    echo "hebrew8 HP-HEBREW8"
+    echo "turkish8 HP-TURKISH8"
+    echo "kana8 HP-KANA8"
+    echo "tis620 TIS-620"
+    echo "big5 BIG5"
+    echo "eucJP EUC-JP"
+    echo "eucKR EUC-KR"
+    echo "eucTW EUC-TW"
+    echo "hp15CN GB2312"
+    #echo "ccdc ?" # what is this?
+    echo "SJIS SHIFT_JIS"
+    echo "utf8 UTF-8"
+    ;;
+  irix*)
+    echo "ISO8859-1 ISO-8859-1"
+    echo "ISO8859-2 ISO-8859-2"
+    echo "ISO8859-5 ISO-8859-5"
+    echo "ISO8859-7 ISO-8859-7"
+    echo "ISO8859-9 ISO-8859-9"
+    echo "eucCN GB2312"
+    echo "eucJP EUC-JP"
+    echo "eucKR EUC-KR"
+    echo "eucTW EUC-TW"
+    ;;
+  osf*)
+    echo "ISO8859-1 ISO-8859-1"
+    echo "ISO8859-2 ISO-8859-2"
+    echo "ISO8859-4 ISO-8859-4"
+    echo "ISO8859-5 ISO-8859-5"
+    echo "ISO8859-7 ISO-8859-7"
+    echo "ISO8859-8 ISO-8859-8"
+    echo "ISO8859-9 ISO-8859-9"
+    echo "ISO8859-15 ISO-8859-15"
+    echo "cp850 CP850"
+    echo "big5 BIG5"
+    echo "dechanyu DEC-HANYU"
+    echo "dechanzi GB2312"
+    echo "deckanji DEC-KANJI"
+    echo "deckorean EUC-KR"
+    echo "eucJP EUC-JP"
+    echo "eucKR EUC-KR"
+    echo "eucTW EUC-TW"
+    echo "GBK GBK"
+    echo "KSC5601 CP949"
+    echo "sdeckanji EUC-JP"
+    echo "SJIS SHIFT_JIS"
+    echo "TACTIS TIS-620"
+    echo "UTF-8 UTF-8"
+    ;;
+  solaris*)
+    echo "646 ASCII"
+    echo "ISO8859-1 ISO-8859-1"
+    echo "ISO8859-2 ISO-8859-2"
+    echo "ISO8859-3 ISO-8859-3"
+    echo "ISO8859-4 ISO-8859-4"
+    echo "ISO8859-5 ISO-8859-5"
+    echo "ISO8859-6 ISO-8859-6"
+    echo "ISO8859-7 ISO-8859-7"
+    echo "ISO8859-8 ISO-8859-8"
+    echo "ISO8859-9 ISO-8859-9"
+    echo "ISO8859-15 ISO-8859-15"
+    echo "koi8-r KOI8-R"
+    echo "ansi-1251 CP1251"
+    echo "BIG5 BIG5"
+    echo "Big5-HKSCS BIG5-HKSCS"
+    echo "gb2312 GB2312"
+    echo "GBK GBK"
+    echo "GB18030 GB18030"
+    echo "cns11643 EUC-TW"
+    echo "5601 EUC-KR"
+    echo "ko_KR.johap92 JOHAB"
+    echo "eucJP EUC-JP"
+    echo "PCK SHIFT_JIS"
+    echo "TIS620.2533 TIS-620"
+    #echo "sun_eu_greek ?" # what is this?
+    echo "UTF-8 UTF-8"
+    ;;
+  freebsd* | os2*)
+    # FreeBSD 4.2 doesn't have nl_langinfo(CODESET); therefore
+    # localcharset.c falls back to using the full locale name
+    # from the environment variables.
+    # Likewise for OS/2. OS/2 has XFree86 just like FreeBSD. Just
+    # reuse FreeBSD's locale data for OS/2.
+    echo "C ASCII"
+    echo "US-ASCII ASCII"
+    for l in la_LN lt_LN; do
+      echo "$l.ASCII ASCII"
+    done
+    for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \
+             fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT la_LN \
+             lt_LN nl_BE nl_NL no_NO pt_PT sv_SE; do
+      echo "$l.ISO_8859-1 ISO-8859-1"
+      echo "$l.DIS_8859-15 ISO-8859-15"
+    done
+    for l in cs_CZ hr_HR hu_HU la_LN lt_LN pl_PL sl_SI; do
+      echo "$l.ISO_8859-2 ISO-8859-2"
+    done
+    for l in la_LN lt_LT; do
+      echo "$l.ISO_8859-4 ISO-8859-4"
+    done
+    for l in ru_RU ru_SU; do
+      echo "$l.KOI8-R KOI8-R"
+      echo "$l.ISO_8859-5 ISO-8859-5"
+      echo "$l.CP866 CP866"
+    done
+    echo "uk_UA.KOI8-U KOI8-U"
+    echo "zh_TW.BIG5 BIG5"
+    echo "zh_TW.Big5 BIG5"
+    echo "zh_CN.EUC GB2312"
+    echo "ja_JP.EUC EUC-JP"
+    echo "ja_JP.SJIS SHIFT_JIS"
+    echo "ja_JP.Shift_JIS SHIFT_JIS"
+    echo "ko_KR.EUC EUC-KR"
+    ;;
+  netbsd*)
+    echo "646 ASCII"
+    echo "ISO8859-1 ISO-8859-1"
+    echo "ISO8859-2 ISO-8859-2"
+    echo "ISO8859-4 ISO-8859-4"
+    echo "ISO8859-5 ISO-8859-5"
+    echo "ISO8859-7 ISO-8859-7"
+    echo "ISO8859-13 ISO-8859-13"
+    echo "ISO8859-15 ISO-8859-15"
+    echo "eucCN GB2312"
+    echo "eucJP EUC-JP"
+    echo "eucKR EUC-KR"
+    echo "eucTW EUC-TW"
+    echo "BIG5 BIG5"
+    echo "SJIS SHIFT_JIS"
+    ;;
+  openbsd*)
+    echo "646 ASCII"
+    echo "ISO8859-1 ISO-8859-1"
+    echo "ISO8859-2 ISO-8859-2"
+    echo "ISO8859-4 ISO-8859-4"
+    echo "ISO8859-5 ISO-8859-5"
+    echo "ISO8859-7 ISO-8859-7"
+    echo "ISO8859-13 ISO-8859-13"
+    echo "ISO8859-15 ISO-8859-15"
+    ;;
+  darwin[56]*)
+    # Darwin 6.8 doesn't have nl_langinfo(CODESET); therefore
+    # localcharset.c falls back to using the full locale name
+    # from the environment variables.
+    echo "C ASCII"
+    for l in en_AU en_CA en_GB en_US la_LN; do
+      echo "$l.US-ASCII ASCII"
+    done
+    for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \
+             fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT nl_BE \
+             nl_NL no_NO pt_PT sv_SE; do
+      echo "$l ISO-8859-1"
+      echo "$l.ISO8859-1 ISO-8859-1"
+      echo "$l.ISO8859-15 ISO-8859-15"
+    done
+    for l in la_LN; do
+      echo "$l.ISO8859-1 ISO-8859-1"
+      echo "$l.ISO8859-15 ISO-8859-15"
+    done
+    for l in cs_CZ hr_HR hu_HU la_LN pl_PL sl_SI; do
+      echo "$l.ISO8859-2 ISO-8859-2"
+    done
+    for l in la_LN lt_LT; do
+      echo "$l.ISO8859-4 ISO-8859-4"
+    done
+    for l in ru_RU; do
+      echo "$l.KOI8-R KOI8-R"
+      echo "$l.ISO8859-5 ISO-8859-5"
+      echo "$l.CP866 CP866"
+    done
+    for l in bg_BG; do
+      echo "$l.CP1251 CP1251"
+    done
+    echo "uk_UA.KOI8-U KOI8-U"
+    echo "zh_TW.BIG5 BIG5"
+    echo "zh_TW.Big5 BIG5"
+    echo "zh_CN.EUC GB2312"
+    echo "ja_JP.EUC EUC-JP"
+    echo "ja_JP.SJIS SHIFT_JIS"
+    echo "ko_KR.EUC EUC-KR"
+    ;;
+  darwin*)
+    # Darwin 7.5 has nl_langinfo(CODESET), but sometimes its value is
+    # useless:
+    # - It returns the empty string when LANG is set to a locale of the
+    #   form ll_CC, although ll_CC/LC_CTYPE is a symlink to an UTF-8
+    #   LC_CTYPE file.
+    # - The environment variables LANG, LC_CTYPE, LC_ALL are not set by
+    #   the system; nl_langinfo(CODESET) returns "US-ASCII" in this case.
+    # - The documentation says:
+    #     "... all code that calls BSD system routines should ensure
+    #      that the const *char parameters of these routines are in UTF-8
+    #      encoding. All BSD system functions expect their string
+    #      parameters to be in UTF-8 encoding and nothing else."
+    #   It also says
+    #     "An additional caveat is that string parameters for files,
+    #      paths, and other file-system entities must be in canonical
+    #      UTF-8. In a canonical UTF-8 Unicode string, all decomposable
+    #      characters are decomposed ..."
+    #   but this is not true: You can pass non-decomposed UTF-8 strings
+    #   to file system functions, and it is the OS which will convert
+    #   them to decomposed UTF-8 before accessing the file system.
+    # - The Apple Terminal application displays UTF-8 by default.
+    # - However, other applications are free to use different encodings:
+    #   - xterm uses ISO-8859-1 by default.
+    #   - TextEdit uses MacRoman by default.
+    # We prefer UTF-8 over decomposed UTF-8-MAC because one should
+    # minimize the use of decomposed Unicode. Unfortunately, through the
+    # Darwin file system, decomposed UTF-8 strings are leaked into user
+    # space nevertheless.
+    # Then there are also the locales with encodings other than US-ASCII
+    # and UTF-8. These locales can be occasionally useful to users (e.g.
+    # when grepping through ISO-8859-1 encoded text files), when all their
+    # file names are in US-ASCII.
+    echo "ISO8859-1 ISO-8859-1"
+    echo "ISO8859-2 ISO-8859-2"
+    echo "ISO8859-4 ISO-8859-4"
+    echo "ISO8859-5 ISO-8859-5"
+    echo "ISO8859-7 ISO-8859-7"
+    echo "ISO8859-9 ISO-8859-9"
+    echo "ISO8859-13 ISO-8859-13"
+    echo "ISO8859-15 ISO-8859-15"
+    echo "KOI8-R KOI8-R"
+    echo "KOI8-U KOI8-U"
+    echo "CP866 CP866"
+    echo "CP949 CP949"
+    echo "CP1131 CP1131"
+    echo "CP1251 CP1251"
+    echo "eucCN GB2312"
+    echo "GB2312 GB2312"
+    echo "eucJP EUC-JP"
+    echo "eucKR EUC-KR"
+    echo "Big5 BIG5"
+    echo "Big5HKSCS BIG5-HKSCS"
+    echo "GBK GBK"
+    echo "GB18030 GB18030"
+    echo "SJIS SHIFT_JIS"
+    echo "ARMSCII-8 ARMSCII-8"
+    echo "PT154 PT154"
+    #echo "ISCII-DEV ?"
+    echo "* UTF-8"
+    ;;
+  beos* | haiku*)
+    # BeOS and Haiku have a single locale, and it has UTF-8 encoding.
+    echo "* UTF-8"
+    ;;
+  msdosdjgpp*)
+    # DJGPP 2.03 doesn't have nl_langinfo(CODESET); therefore
+    # localcharset.c falls back to using the full locale name
+    # from the environment variables.
+    echo "#"
+    echo "# The encodings given here may not all be correct."
+    echo "# If you find that the encoding given for your language and"
+    echo "# country is not the one your DOS machine actually uses, just"
+    echo "# correct it in this file, and send a mail to"
+    echo "# Juan Manuel Guerrero <[email protected]>"
+    echo "# and Bruno Haible <[email protected]>."
+    echo "#"
+    echo "C ASCII"
+    # ISO-8859-1 languages
+    echo "ca CP850"
+    echo "ca_ES CP850"
+    echo "da CP865"    # not CP850 ??
+    echo "da_DK CP865" # not CP850 ??
+    echo "de CP850"
+    echo "de_AT CP850"
+    echo "de_CH CP850"
+    echo "de_DE CP850"
+    echo "en CP850"
+    echo "en_AU CP850" # not CP437 ??
+    echo "en_CA CP850"
+    echo "en_GB CP850"
+    echo "en_NZ CP437"
+    echo "en_US CP437"
+    echo "en_ZA CP850" # not CP437 ??
+    echo "es CP850"
+    echo "es_AR CP850"
+    echo "es_BO CP850"
+    echo "es_CL CP850"
+    echo "es_CO CP850"
+    echo "es_CR CP850"
+    echo "es_CU CP850"
+    echo "es_DO CP850"
+    echo "es_EC CP850"
+    echo "es_ES CP850"
+    echo "es_GT CP850"
+    echo "es_HN CP850"
+    echo "es_MX CP850"
+    echo "es_NI CP850"
+    echo "es_PA CP850"
+    echo "es_PY CP850"
+    echo "es_PE CP850"
+    echo "es_SV CP850"
+    echo "es_UY CP850"
+    echo "es_VE CP850"
+    echo "et CP850"
+    echo "et_EE CP850"
+    echo "eu CP850"
+    echo "eu_ES CP850"
+    echo "fi CP850"
+    echo "fi_FI CP850"
+    echo "fr CP850"
+    echo "fr_BE CP850"
+    echo "fr_CA CP850"
+    echo "fr_CH CP850"
+    echo "fr_FR CP850"
+    echo "ga CP850"
+    echo "ga_IE CP850"
+    echo "gd CP850"
+    echo "gd_GB CP850"
+    echo "gl CP850"
+    echo "gl_ES CP850"
+    echo "id CP850"    # not CP437 ??
+    echo "id_ID CP850" # not CP437 ??
+    echo "is CP861"    # not CP850 ??
+    echo "is_IS CP861" # not CP850 ??
+    echo "it CP850"
+    echo "it_CH CP850"
+    echo "it_IT CP850"
+    echo "lt CP775"
+    echo "lt_LT CP775"
+    echo "lv CP775"
+    echo "lv_LV CP775"
+    echo "nb CP865"    # not CP850 ??
+    echo "nb_NO CP865" # not CP850 ??
+    echo "nl CP850"
+    echo "nl_BE CP850"
+    echo "nl_NL CP850"
+    echo "nn CP865"    # not CP850 ??
+    echo "nn_NO CP865" # not CP850 ??
+    echo "no CP865"    # not CP850 ??
+    echo "no_NO CP865" # not CP850 ??
+    echo "pt CP850"
+    echo "pt_BR CP850"
+    echo "pt_PT CP850"
+    echo "sv CP850"
+    echo "sv_SE CP850"
+    # ISO-8859-2 languages
+    echo "cs CP852"
+    echo "cs_CZ CP852"
+    echo "hr CP852"
+    echo "hr_HR CP852"
+    echo "hu CP852"
+    echo "hu_HU CP852"
+    echo "pl CP852"
+    echo "pl_PL CP852"
+    echo "ro CP852"
+    echo "ro_RO CP852"
+    echo "sk CP852"
+    echo "sk_SK CP852"
+    echo "sl CP852"
+    echo "sl_SI CP852"
+    echo "sq CP852"
+    echo "sq_AL CP852"
+    echo "sr CP852"    # CP852 or CP866 or CP855 ??
+    echo "sr_CS CP852" # CP852 or CP866 or CP855 ??
+    echo "sr_YU CP852" # CP852 or CP866 or CP855 ??
+    # ISO-8859-3 languages
+    echo "mt CP850"
+    echo "mt_MT CP850"
+    # ISO-8859-5 languages
+    echo "be CP866"
+    echo "be_BE CP866"
+    echo "bg CP866"    # not CP855 ??
+    echo "bg_BG CP866" # not CP855 ??
+    echo "mk CP866"    # not CP855 ??
+    echo "mk_MK CP866" # not CP855 ??
+    echo "ru CP866"
+    echo "ru_RU CP866"
+    echo "uk CP1125"
+    echo "uk_UA CP1125"
+    # ISO-8859-6 languages
+    echo "ar CP864"
+    echo "ar_AE CP864"
+    echo "ar_DZ CP864"
+    echo "ar_EG CP864"
+    echo "ar_IQ CP864"
+    echo "ar_IR CP864"
+    echo "ar_JO CP864"
+    echo "ar_KW CP864"
+    echo "ar_MA CP864"
+    echo "ar_OM CP864"
+    echo "ar_QA CP864"
+    echo "ar_SA CP864"
+    echo "ar_SY CP864"
+    # ISO-8859-7 languages
+    echo "el CP869"
+    echo "el_GR CP869"
+    # ISO-8859-8 languages
+    echo "he CP862"
+    echo "he_IL CP862"
+    # ISO-8859-9 languages
+    echo "tr CP857"
+    echo "tr_TR CP857"
+    # Japanese
+    echo "ja CP932"
+    echo "ja_JP CP932"
+    # Chinese
+    echo "zh_CN GBK"
+    echo "zh_TW CP950" # not CP938 ??
+    # Korean
+    echo "kr CP949"    # not CP934 ??
+    echo "kr_KR CP949" # not CP934 ??
+    # Thai
+    echo "th CP874"
+    echo "th_TH CP874"
+    # Other
+    echo "eo CP850"
+    echo "eo_EO CP850"
+    ;;
 esac
diff --git a/libmissing/dirent.in.h b/libmissing/dirent.in.h
index f15a8a3..2628eab 100644
--- a/libmissing/dirent.in.h
+++ b/libmissing/dirent.in.h
@@ -28,6 +28,8 @@
 
 /* The definition of GL_LINK_WARNING is copied here.  */
 
+/* The definition of _GL_ARG_NONNULL is copied here.  */
+
 
 #ifdef __cplusplus
 extern "C" {
@@ -35,20 +37,16 @@ extern "C" {
 
 /* Declare overridden functions.  */
 
-#if @REPLACE_FCHDIR@
-# define opendir rpl_opendir
-extern DIR * opendir (const char *);
+#if @REPLACE_CLOSEDIR@
 # define closedir rpl_closedir
-extern int closedir (DIR *);
+extern int closedir (DIR *) _GL_ARG_NONNULL ((1));
 #endif
 
-/* Declare other POSIX functions.  */
-
 #if @GNULIB_DIRFD@
 # if !@HAVE_DECL_DIRFD@ && !defined dirfd
 /* Return the file descriptor associated with the given directory stream,
    or -1 if none exists.  */
-extern int dirfd (DIR const *dir);
+extern int dirfd (DIR *dir) _GL_ARG_NONNULL ((1));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef dirfd
@@ -58,6 +56,32 @@ extern int dirfd (DIR const *dir);
      dirfd (d))
 #endif
 
+#if @GNULIB_FDOPENDIR@
+# if @REPLACE_FDOPENDIR@
+#  undef fdopendir
+#  define fdopendir rpl_fdopendir
+# endif
+# if !@HAVE_FDOPENDIR@ || @REPLACE_FDOPENDIR@
+/* Open a directory stream visiting the given directory file
+   descriptor.  Return NULL and set errno if fd is not visiting a
+   directory.  On success, this function consumes fd (it will be
+   implicitly closed either by this function or by a subsequent
+   closedir).  */
+extern DIR *fdopendir (int fd);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef fdopendir
+# define fdopendir(f) \
+    (GL_LINK_WARNING ("fdopendir is unportable - " \
+                      "use gnulib module fdopendir for portability"), \
+     fdopendir (f))
+#endif
+
+#if @REPLACE_OPENDIR@
+# define opendir rpl_opendir
+extern DIR * opendir (const char *) _GL_ARG_NONNULL ((1));
+#endif
+
 #if @GNULIB_SCANDIR@
 /* Scan the directory DIR, calling FILTER on each directory entry.
    Entries for which FILTER returns nonzero are individually malloc'd,
@@ -65,8 +89,9 @@ extern int dirfd (DIR const *dir);
    *NAMELIST.  Returns the number of entries selected, or -1 on error.  */
 # if !@HAVE_SCANDIR@
 extern int scandir (const char *dir, struct dirent ***namelist,
-		    int (*filter) (const struct dirent *),
-		    int (*cmp) (const struct dirent **, const struct dirent **));
+                    int (*filter) (const struct dirent *),
+                    int (*cmp) (const struct dirent **, const struct dirent **))
+     _GL_ARG_NONNULL ((1, 2, 4));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef scandir
@@ -79,7 +104,8 @@ extern int scandir (const char *dir, struct dirent ***namelist,
 #if @GNULIB_ALPHASORT@
 /* Compare two 'struct dirent' entries alphabetically.  */
 # if !@HAVE_ALPHASORT@
-extern int alphasort (const struct dirent **, const struct dirent **);
+extern int alphasort (const struct dirent **, const struct dirent **)
+     _GL_ARG_NONNULL ((1, 2));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef alphasort
diff --git a/libmissing/dirfd.c b/libmissing/dirfd.c
index 6c430c2..73d03af 100644
--- a/libmissing/dirfd.c
+++ b/libmissing/dirfd.c
@@ -23,7 +23,7 @@
 #include <errno.h>
 
 int
-dirfd (DIR const *dir_p)
+dirfd (DIR *dir_p)
 {
   int fd = DIR_TO_FD (dir_p);
   if (fd == -1)
diff --git a/libmissing/fclose.c b/libmissing/fclose.c
index 32554b9..e305c0c 100644
--- a/libmissing/fclose.c
+++ b/libmissing/fclose.c
@@ -1,5 +1,5 @@
 /* fclose replacement.
-   Copyright (C) 2008 Free Software Foundation, Inc.
+   Copyright (C) 2008, 2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/libmissing/float+.h b/libmissing/float+.h
index 2288e3d..9317ab7 100644
--- a/libmissing/float+.h
+++ b/libmissing/float+.h
@@ -1,5 +1,5 @@
 /* Supplemental information about the floating-point formats.
-   Copyright (C) 2007 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009 Free Software Foundation, Inc.
    Written by Bruno Haible <[email protected]>, 2007.
 
    This program is free software; you can redistribute it and/or modify
diff --git a/libmissing/float.in.h b/libmissing/float.in.h
index 63d55f8..df36639 100644
--- a/libmissing/float.in.h
+++ b/libmissing/float.in.h
@@ -1,6 +1,6 @@
 /* A correct <float.h>.
 
-   Copyright (C) 2007-2008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/libmissing/fnmatch.c b/libmissing/fnmatch.c
index 6efe8a0..06a97a2 100644
--- a/libmissing/fnmatch.c
+++ b/libmissing/fnmatch.c
@@ -1,5 +1,5 @@
 /* Copyright (C) 1991,1992,1993,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2009
-	Free Software Foundation, Inc.
+        Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -21,7 +21,7 @@
 
 /* Enable GNU extensions in fnmatch.h.  */
 #ifndef _GNU_SOURCE
-# define _GNU_SOURCE	1
+# define _GNU_SOURCE    1
 #endif
 
 #if ! defined __builtin_expect && __GNUC__ < 3
@@ -109,25 +109,25 @@ extern int fnmatch (const char *pattern, const char *string, int flags);
 #  endif
 
 #  ifdef _LIBC
-#   define ISWCTYPE(WC, WT)	__iswctype (WC, WT)
+#   define ISWCTYPE(WC, WT)     __iswctype (WC, WT)
 #  else
-#   define ISWCTYPE(WC, WT)	iswctype (WC, WT)
+#   define ISWCTYPE(WC, WT)     iswctype (WC, WT)
 #  endif
 
 #  if (HAVE_MBSTATE_T && HAVE_MBSRTOWCS) || _LIBC
 /* In this case we are implementing the multibyte character handling.  */
-#   define HANDLE_MULTIBYTE	1
+#   define HANDLE_MULTIBYTE     1
 #  endif
 
 # else
 #  define CHAR_CLASS_MAX_LENGTH  6 /* Namely, `xdigit'.  */
 
-#  define IS_CHAR_CLASS(string)						      \
-   (STREQ (string, "alpha") || STREQ (string, "upper")			      \
-    || STREQ (string, "lower") || STREQ (string, "digit")		      \
-    || STREQ (string, "alnum") || STREQ (string, "xdigit")		      \
-    || STREQ (string, "space") || STREQ (string, "print")		      \
-    || STREQ (string, "punct") || STREQ (string, "graph")		      \
+#  define IS_CHAR_CLASS(string)                                               \
+   (STREQ (string, "alpha") || STREQ (string, "upper")                        \
+    || STREQ (string, "lower") || STREQ (string, "digit")                     \
+    || STREQ (string, "alnum") || STREQ (string, "xdigit")                    \
+    || STREQ (string, "space") || STREQ (string, "print")                     \
+    || STREQ (string, "punct") || STREQ (string, "graph")                     \
     || STREQ (string, "cntrl") || STREQ (string, "blank"))
 # endif
 
@@ -145,17 +145,17 @@ static int posixly_correct;
 
 /* Note that this evaluates C many times.  */
 # define FOLD(c) ((flags & FNM_CASEFOLD) ? tolower (c) : (c))
-# define CHAR	char
-# define UCHAR	unsigned char
-# define INT	int
-# define FCT	internal_fnmatch
-# define EXT	ext_match
-# define END	end_pattern
-# define L_(CS)	CS
+# define CHAR   char
+# define UCHAR  unsigned char
+# define INT    int
+# define FCT    internal_fnmatch
+# define EXT    ext_match
+# define END    end_pattern
+# define L_(CS) CS
 # ifdef _LIBC
-#  define BTOWC(C)	__btowc (C)
+#  define BTOWC(C)      __btowc (C)
 # else
-#  define BTOWC(C)	btowc (C)
+#  define BTOWC(C)      btowc (C)
 # endif
 # define STRLEN(S) strlen (S)
 # define STRCAT(D, S) strcat (D, S)
@@ -175,14 +175,14 @@ static int posixly_correct;
 
 # if HANDLE_MULTIBYTE
 #  define FOLD(c) ((flags & FNM_CASEFOLD) ? towlower (c) : (c))
-#  define CHAR	wchar_t
-#  define UCHAR	wint_t
-#  define INT	wint_t
-#  define FCT	internal_fnwmatch
-#  define EXT	ext_wmatch
-#  define END	end_wpattern
-#  define L_(CS)	L##CS
-#  define BTOWC(C)	(C)
+#  define CHAR  wchar_t
+#  define UCHAR wint_t
+#  define INT   wint_t
+#  define FCT   internal_fnwmatch
+#  define EXT   ext_wmatch
+#  define END   end_wpattern
+#  define L_(CS)        L##CS
+#  define BTOWC(C)      (C)
 #  ifdef _LIBC
 #   define STRLEN(S) __wcslen (S)
 #   define STRCAT(D, S) __wcscat (D, S)
@@ -218,40 +218,40 @@ is_char_class (const wchar_t *wcs)
       /* Test for a printable character from the portable character set.  */
 #  ifdef _LIBC
       if (*wcs < 0x20 || *wcs > 0x7e
-	  || *wcs == 0x24 || *wcs == 0x40 || *wcs == 0x60)
-	return (wctype_t) 0;
+          || *wcs == 0x24 || *wcs == 0x40 || *wcs == 0x60)
+        return (wctype_t) 0;
 #  else
       switch (*wcs)
-	{
-	case L' ': case L'!': case L'"': case L'#': case L'%':
-	case L'&': case L'\'': case L'(': case L')': case L'*':
-	case L'+': case L',': case L'-': case L'.': case L'/':
-	case L'0': case L'1': case L'2': case L'3': case L'4':
-	case L'5': case L'6': case L'7': case L'8': case L'9':
-	case L':': case L';': case L'<': case L'=': case L'>':
-	case L'?':
-	case L'A': case L'B': case L'C': case L'D': case L'E':
-	case L'F': case L'G': case L'H': case L'I': case L'J':
-	case L'K': case L'L': case L'M': case L'N': case L'O':
-	case L'P': case L'Q': case L'R': case L'S': case L'T':
-	case L'U': case L'V': case L'W': case L'X': case L'Y':
-	case L'Z':
-	case L'[': case L'\\': case L']': case L'^': case L'_':
-	case L'a': case L'b': case L'c': case L'd': case L'e':
-	case L'f': case L'g': case L'h': case L'i': case L'j':
-	case L'k': case L'l': case L'm': case L'n': case L'o':
-	case L'p': case L'q': case L'r': case L's': case L't':
-	case L'u': case L'v': case L'w': case L'x': case L'y':
-	case L'z': case L'{': case L'|': case L'}': case L'~':
-	  break;
-	default:
-	  return (wctype_t) 0;
-	}
+        {
+        case L' ': case L'!': case L'"': case L'#': case L'%':
+        case L'&': case L'\'': case L'(': case L')': case L'*':
+        case L'+': case L',': case L'-': case L'.': case L'/':
+        case L'0': case L'1': case L'2': case L'3': case L'4':
+        case L'5': case L'6': case L'7': case L'8': case L'9':
+        case L':': case L';': case L'<': case L'=': case L'>':
+        case L'?':
+        case L'A': case L'B': case L'C': case L'D': case L'E':
+        case L'F': case L'G': case L'H': case L'I': case L'J':
+        case L'K': case L'L': case L'M': case L'N': case L'O':
+        case L'P': case L'Q': case L'R': case L'S': case L'T':
+        case L'U': case L'V': case L'W': case L'X': case L'Y':
+        case L'Z':
+        case L'[': case L'\\': case L']': case L'^': case L'_':
+        case L'a': case L'b': case L'c': case L'd': case L'e':
+        case L'f': case L'g': case L'h': case L'i': case L'j':
+        case L'k': case L'l': case L'm': case L'n': case L'o':
+        case L'p': case L'q': case L'r': case L's': case L't':
+        case L'u': case L'v': case L'w': case L'x': case L'y':
+        case L'z': case L'{': case L'|': case L'}': case L'~':
+          break;
+        default:
+          return (wctype_t) 0;
+        }
 #  endif
 
       /* Avoid overrunning the buffer.  */
       if (cp == s + CHAR_CLASS_MAX_LENGTH)
-	return (wctype_t) 0;
+        return (wctype_t) 0;
 
       *cp++ = (char) *wcs++;
     }
@@ -287,58 +287,58 @@ fnmatch (const char *pattern, const char *string, int flags)
       int res;
 
       /* Calculate the size needed to convert the strings to
-	 wide characters.  */
+         wide characters.  */
       memset (&ps, '\0', sizeof (ps));
       patsize = mbsrtowcs (NULL, &pattern, 0, &ps) + 1;
       if (__builtin_expect (patsize != 0, 1))
-	{
-	  assert (mbsinit (&ps));
-	  strsize = mbsrtowcs (NULL, &string, 0, &ps) + 1;
-	  if (__builtin_expect (strsize != 0, 1))
-	    {
-	      assert (mbsinit (&ps));
-	      totsize = patsize + strsize;
-	      if (__builtin_expect (! (patsize <= totsize
-				       && totsize <= SIZE_MAX / sizeof (wchar_t)),
-				    0))
-		{
-		  errno = ENOMEM;
-		  return -1;
-		}
-
-	      /* Allocate room for the wide characters.  */
-	      if (__builtin_expect (totsize < ALLOCA_LIMIT, 1))
-		wpattern = (wchar_t *) alloca (totsize * sizeof (wchar_t));
-	      else
-		{
-		  wpattern = malloc (totsize * sizeof (wchar_t));
-		  if (__builtin_expect (! wpattern, 0))
-		    {
-		      errno = ENOMEM;
-		      return -1;
-		    }
-		}
-	      wstring = wpattern + patsize;
-
-	      /* Convert the strings into wide characters.  */
-	      mbsrtowcs (wpattern, &pattern, patsize, &ps);
-	      assert (mbsinit (&ps));
-	      mbsrtowcs (wstring, &string, strsize, &ps);
-
-	      res = internal_fnwmatch (wpattern, wstring, wstring + strsize - 1,
-				       flags & FNM_PERIOD, flags);
-
-	      if (__builtin_expect (! (totsize < ALLOCA_LIMIT), 0))
-		free (wpattern);
-	      return res;
-	    }
-	}
+        {
+          assert (mbsinit (&ps));
+          strsize = mbsrtowcs (NULL, &string, 0, &ps) + 1;
+          if (__builtin_expect (strsize != 0, 1))
+            {
+              assert (mbsinit (&ps));
+              totsize = patsize + strsize;
+              if (__builtin_expect (! (patsize <= totsize
+                                       && totsize <= SIZE_MAX / sizeof (wchar_t)),
+                                    0))
+                {
+                  errno = ENOMEM;
+                  return -1;
+                }
+
+              /* Allocate room for the wide characters.  */
+              if (__builtin_expect (totsize < ALLOCA_LIMIT, 1))
+                wpattern = (wchar_t *) alloca (totsize * sizeof (wchar_t));
+              else
+                {
+                  wpattern = malloc (totsize * sizeof (wchar_t));
+                  if (__builtin_expect (! wpattern, 0))
+                    {
+                      errno = ENOMEM;
+                      return -1;
+                    }
+                }
+              wstring = wpattern + patsize;
+
+              /* Convert the strings into wide characters.  */
+              mbsrtowcs (wpattern, &pattern, patsize, &ps);
+              assert (mbsinit (&ps));
+              mbsrtowcs (wstring, &string, strsize, &ps);
+
+              res = internal_fnwmatch (wpattern, wstring, wstring + strsize - 1,
+                                       flags & FNM_PERIOD, flags);
+
+              if (__builtin_expect (! (totsize < ALLOCA_LIMIT), 0))
+                free (wpattern);
+              return res;
+            }
+        }
     }
 
 # endif /* HANDLE_MULTIBYTE */
 
   return internal_fnmatch (pattern, string, string + strlen (string),
-			   flags & FNM_PERIOD, flags);
+                           flags & FNM_PERIOD, flags);
 }
 
 # ifdef _LIBC
@@ -351,4 +351,4 @@ compat_symbol (libc, __fnmatch_old, fnmatch, GLIBC_2_0);
 libc_hidden_ver (__fnmatch, fnmatch)
 # endif
 
-#endif	/* _LIBC or not __GNU_LIBRARY__.  */
+#endif  /* _LIBC or not __GNU_LIBRARY__.  */
diff --git a/libmissing/fnmatch.in.h b/libmissing/fnmatch.in.h
index a0ccf22..5436004 100644
--- a/libmissing/fnmatch.in.h
+++ b/libmissing/fnmatch.in.h
@@ -1,5 +1,5 @@
 /* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2001, 2002, 2003,
-   2005, 2007 Free Software Foundation, Inc.
+   2005, 2007, 2009 Free Software Foundation, Inc.
 
    This file is part of the GNU C Library.
 
@@ -17,8 +17,10 @@
    along with this program; if not, write to the Free Software Foundation,
    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
-#ifndef	_FNMATCH_H
-#define	_FNMATCH_H	1
+#ifndef _FNMATCH_H
+#define _FNMATCH_H      1
+
+/* The definition of _GL_ARG_NONNULL is copied here.  */
 
 #ifdef __cplusplus
 extern "C" {
@@ -26,37 +28,38 @@ extern "C" {
 
 /* We #undef these before defining them because some losing systems
    (HP-UX A.08.07 for example) define these in <unistd.h>.  */
-#undef	FNM_PATHNAME
-#undef	FNM_NOESCAPE
-#undef	FNM_PERIOD
+#undef  FNM_PATHNAME
+#undef  FNM_NOESCAPE
+#undef  FNM_PERIOD
 
 /* Bits set in the FLAGS argument to `fnmatch'.  */
-#define	FNM_PATHNAME	(1 << 0) /* No wildcard can ever match `/'.  */
-#define	FNM_NOESCAPE	(1 << 1) /* Backslashes don't quote special chars.  */
-#define	FNM_PERIOD	(1 << 2) /* Leading `.' is matched only explicitly.  */
+#define FNM_PATHNAME    (1 << 0) /* No wildcard can ever match `/'.  */
+#define FNM_NOESCAPE    (1 << 1) /* Backslashes don't quote special chars.  */
+#define FNM_PERIOD      (1 << 2) /* Leading `.' is matched only explicitly.  */
 
 #if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 2 || defined _GNU_SOURCE
-# define FNM_FILE_NAME	 FNM_PATHNAME	/* Preferred GNU name.  */
-# define FNM_LEADING_DIR (1 << 3)	/* Ignore `/...' after a match.  */
-# define FNM_CASEFOLD	 (1 << 4)	/* Compare without regard to case.  */
-# define FNM_EXTMATCH	 (1 << 5)	/* Use ksh-like extended matching. */
+# define FNM_FILE_NAME   FNM_PATHNAME   /* Preferred GNU name.  */
+# define FNM_LEADING_DIR (1 << 3)       /* Ignore `/...' after a match.  */
+# define FNM_CASEFOLD    (1 << 4)       /* Compare without regard to case.  */
+# define FNM_EXTMATCH    (1 << 5)       /* Use ksh-like extended matching. */
 #endif
 
 /* Value returned by `fnmatch' if STRING does not match PATTERN.  */
-#define	FNM_NOMATCH	1
+#define FNM_NOMATCH     1
 
 /* This value is returned if the implementation does not support
    `fnmatch'.  Since this is not the case here it will never be
    returned but the conformance test suites still require the symbol
    to be defined.  */
 #ifdef _XOPEN_SOURCE
-# define FNM_NOSYS	(-1)
+# define FNM_NOSYS      (-1)
 #endif
 
 /* Match NAME against the file name pattern PATTERN,
    returning zero if it matches, FNM_NOMATCH if not.  */
 extern int fnmatch (const char *__pattern, const char *__name,
-		    int __flags);
+                    int __flags)
+     _GL_ARG_NONNULL ((1, 2));
 
 #ifdef __cplusplus
 }
diff --git a/libmissing/fnmatch_loop.c b/libmissing/fnmatch_loop.c
index 95f7a56..33b8159 100644
--- a/libmissing/fnmatch_loop.c
+++ b/libmissing/fnmatch_loop.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991,1992,1993,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006
+/* Copyright (C) 1991,1992,1993,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2009
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -19,7 +19,7 @@
 /* Match STRING against the file name pattern PATTERN, returning zero if
    it matches, nonzero if not.  */
 static int EXT (INT opt, const CHAR *pattern, const CHAR *string,
-		const CHAR *string_end, bool no_leading_period, int flags)
+                const CHAR *string_end, bool no_leading_period, int flags)
      internal_function;
 static const CHAR *END (const CHAR *patternp) internal_function;
 
@@ -46,310 +46,310 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
       c = FOLD (c);
 
       switch (c)
-	{
-	case L_('?'):
-	  if (__builtin_expect (flags & FNM_EXTMATCH, 0) && *p == '(')
-	    {
-	      int res;
-
-	      res = EXT (c, p, n, string_end, no_leading_period,
-			 flags);
-	      if (res != -1)
-		return res;
-	    }
-
-	  if (n == string_end)
-	    return FNM_NOMATCH;
-	  else if (*n == L_('/') && (flags & FNM_FILE_NAME))
-	    return FNM_NOMATCH;
-	  else if (*n == L_('.') && no_leading_period)
-	    return FNM_NOMATCH;
-	  break;
-
-	case L_('\\'):
-	  if (!(flags & FNM_NOESCAPE))
-	    {
-	      c = *p++;
-	      if (c == L_('\0'))
-		/* Trailing \ loses.  */
-		return FNM_NOMATCH;
-	      c = FOLD (c);
-	    }
-	  if (n == string_end || FOLD ((UCHAR) *n) != c)
-	    return FNM_NOMATCH;
-	  break;
-
-	case L_('*'):
-	  if (__builtin_expect (flags & FNM_EXTMATCH, 0) && *p == '(')
-	    {
-	      int res;
-
-	      res = EXT (c, p, n, string_end, no_leading_period,
-			 flags);
-	      if (res != -1)
-		return res;
-	    }
-
-	  if (n != string_end && *n == L_('.') && no_leading_period)
-	    return FNM_NOMATCH;
-
-	  for (c = *p++; c == L_('?') || c == L_('*'); c = *p++)
-	    {
-	      if (*p == L_('(') && (flags & FNM_EXTMATCH) != 0)
-		{
-		  const CHAR *endp = END (p);
-		  if (endp != p)
-		    {
-		      /* This is a pattern.  Skip over it.  */
-		      p = endp;
-		      continue;
-		    }
-		}
-
-	      if (c == L_('?'))
-		{
-		  /* A ? needs to match one character.  */
-		  if (n == string_end)
-		    /* There isn't another character; no match.  */
-		    return FNM_NOMATCH;
-		  else if (*n == L_('/')
-			   && __builtin_expect (flags & FNM_FILE_NAME, 0))
-		    /* A slash does not match a wildcard under
-		       FNM_FILE_NAME.  */
-		    return FNM_NOMATCH;
-		  else
-		    /* One character of the string is consumed in matching
-		       this ? wildcard, so *??? won't match if there are
-		       less than three characters.  */
-		    ++n;
-		}
-	    }
-
-	  if (c == L_('\0'))
-	    /* The wildcard(s) is/are the last element of the pattern.
-	       If the name is a file name and contains another slash
-	       this means it cannot match, unless the FNM_LEADING_DIR
-	       flag is set.  */
-	    {
-	      int result = (flags & FNM_FILE_NAME) == 0 ? 0 : FNM_NOMATCH;
-
-	      if (flags & FNM_FILE_NAME)
-		{
-		  if (flags & FNM_LEADING_DIR)
-		    result = 0;
-		  else
-		    {
-		      if (MEMCHR (n, L_('/'), string_end - n) == NULL)
-			result = 0;
-		    }
-		}
-
-	      return result;
-	    }
-	  else
-	    {
-	      const CHAR *endp;
-
-	      endp = MEMCHR (n, (flags & FNM_FILE_NAME) ? L_('/') : L_('\0'),
-			     string_end - n);
-	      if (endp == NULL)
-		endp = string_end;
-
-	      if (c == L_('[')
-		  || (__builtin_expect (flags & FNM_EXTMATCH, 0) != 0
-		      && (c == L_('@') || c == L_('+') || c == L_('!'))
-		      && *p == L_('(')))
-		{
-		  int flags2 = ((flags & FNM_FILE_NAME)
-				? flags : (flags & ~FNM_PERIOD));
-		  bool no_leading_period2 = no_leading_period;
-
-		  for (--p; n < endp; ++n, no_leading_period2 = false)
-		    if (FCT (p, n, string_end, no_leading_period2, flags2)
-			== 0)
-		      return 0;
-		}
-	      else if (c == L_('/') && (flags & FNM_FILE_NAME))
-		{
-		  while (n < string_end && *n != L_('/'))
-		    ++n;
-		  if (n < string_end && *n == L_('/')
-		      && (FCT (p, n + 1, string_end, flags & FNM_PERIOD, flags)
-			  == 0))
-		    return 0;
-		}
-	      else
-		{
-		  int flags2 = ((flags & FNM_FILE_NAME)
-				? flags : (flags & ~FNM_PERIOD));
-		  int no_leading_period2 = no_leading_period;
-
-		  if (c == L_('\\') && !(flags & FNM_NOESCAPE))
-		    c = *p;
-		  c = FOLD (c);
-		  for (--p; n < endp; ++n, no_leading_period2 = false)
-		    if (FOLD ((UCHAR) *n) == c
-			&& (FCT (p, n, string_end, no_leading_period2, flags2)
-			    == 0))
-		      return 0;
-		}
-	    }
-
-	  /* If we come here no match is possible with the wildcard.  */
-	  return FNM_NOMATCH;
-
-	case L_('['):
-	  {
-	    /* Nonzero if the sense of the character class is inverted.  */
-	    register bool not;
-	    CHAR cold;
-	    UCHAR fn;
-
-	    if (posixly_correct == 0)
-	      posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1;
-
-	    if (n == string_end)
-	      return FNM_NOMATCH;
-
-	    if (*n == L_('.') && no_leading_period)
-	      return FNM_NOMATCH;
-
-	    if (*n == L_('/') && (flags & FNM_FILE_NAME))
-	      /* `/' cannot be matched.  */
-	      return FNM_NOMATCH;
-
-	    not = (*p == L_('!') || (posixly_correct < 0 && *p == L_('^')));
-	    if (not)
-	      ++p;
-
-	    fn = FOLD ((UCHAR) *n);
-
-	    c = *p++;
-	    for (;;)
-	      {
-		if (!(flags & FNM_NOESCAPE) && c == L_('\\'))
-		  {
-		    if (*p == L_('\0'))
-		      return FNM_NOMATCH;
-		    c = FOLD ((UCHAR) *p);
-		    ++p;
-
-		    goto normal_bracket;
-		  }
-		else if (c == L_('[') && *p == L_(':'))
-		  {
-		    /* Leave room for the null.  */
-		    CHAR str[CHAR_CLASS_MAX_LENGTH + 1];
-		    size_t c1 = 0;
+        {
+        case L_('?'):
+          if (__builtin_expect (flags & FNM_EXTMATCH, 0) && *p == '(')
+            {
+              int res;
+
+              res = EXT (c, p, n, string_end, no_leading_period,
+                         flags);
+              if (res != -1)
+                return res;
+            }
+
+          if (n == string_end)
+            return FNM_NOMATCH;
+          else if (*n == L_('/') && (flags & FNM_FILE_NAME))
+            return FNM_NOMATCH;
+          else if (*n == L_('.') && no_leading_period)
+            return FNM_NOMATCH;
+          break;
+
+        case L_('\\'):
+          if (!(flags & FNM_NOESCAPE))
+            {
+              c = *p++;
+              if (c == L_('\0'))
+                /* Trailing \ loses.  */
+                return FNM_NOMATCH;
+              c = FOLD (c);
+            }
+          if (n == string_end || FOLD ((UCHAR) *n) != c)
+            return FNM_NOMATCH;
+          break;
+
+        case L_('*'):
+          if (__builtin_expect (flags & FNM_EXTMATCH, 0) && *p == '(')
+            {
+              int res;
+
+              res = EXT (c, p, n, string_end, no_leading_period,
+                         flags);
+              if (res != -1)
+                return res;
+            }
+
+          if (n != string_end && *n == L_('.') && no_leading_period)
+            return FNM_NOMATCH;
+
+          for (c = *p++; c == L_('?') || c == L_('*'); c = *p++)
+            {
+              if (*p == L_('(') && (flags & FNM_EXTMATCH) != 0)
+                {
+                  const CHAR *endp = END (p);
+                  if (endp != p)
+                    {
+                      /* This is a pattern.  Skip over it.  */
+                      p = endp;
+                      continue;
+                    }
+                }
+
+              if (c == L_('?'))
+                {
+                  /* A ? needs to match one character.  */
+                  if (n == string_end)
+                    /* There isn't another character; no match.  */
+                    return FNM_NOMATCH;
+                  else if (*n == L_('/')
+                           && __builtin_expect (flags & FNM_FILE_NAME, 0))
+                    /* A slash does not match a wildcard under
+                       FNM_FILE_NAME.  */
+                    return FNM_NOMATCH;
+                  else
+                    /* One character of the string is consumed in matching
+                       this ? wildcard, so *??? won't match if there are
+                       less than three characters.  */
+                    ++n;
+                }
+            }
+
+          if (c == L_('\0'))
+            /* The wildcard(s) is/are the last element of the pattern.
+               If the name is a file name and contains another slash
+               this means it cannot match, unless the FNM_LEADING_DIR
+               flag is set.  */
+            {
+              int result = (flags & FNM_FILE_NAME) == 0 ? 0 : FNM_NOMATCH;
+
+              if (flags & FNM_FILE_NAME)
+                {
+                  if (flags & FNM_LEADING_DIR)
+                    result = 0;
+                  else
+                    {
+                      if (MEMCHR (n, L_('/'), string_end - n) == NULL)
+                        result = 0;
+                    }
+                }
+
+              return result;
+            }
+          else
+            {
+              const CHAR *endp;
+
+              endp = MEMCHR (n, (flags & FNM_FILE_NAME) ? L_('/') : L_('\0'),
+                             string_end - n);
+              if (endp == NULL)
+                endp = string_end;
+
+              if (c == L_('[')
+                  || (__builtin_expect (flags & FNM_EXTMATCH, 0) != 0
+                      && (c == L_('@') || c == L_('+') || c == L_('!'))
+                      && *p == L_('(')))
+                {
+                  int flags2 = ((flags & FNM_FILE_NAME)
+                                ? flags : (flags & ~FNM_PERIOD));
+                  bool no_leading_period2 = no_leading_period;
+
+                  for (--p; n < endp; ++n, no_leading_period2 = false)
+                    if (FCT (p, n, string_end, no_leading_period2, flags2)
+                        == 0)
+                      return 0;
+                }
+              else if (c == L_('/') && (flags & FNM_FILE_NAME))
+                {
+                  while (n < string_end && *n != L_('/'))
+                    ++n;
+                  if (n < string_end && *n == L_('/')
+                      && (FCT (p, n + 1, string_end, flags & FNM_PERIOD, flags)
+                          == 0))
+                    return 0;
+                }
+              else
+                {
+                  int flags2 = ((flags & FNM_FILE_NAME)
+                                ? flags : (flags & ~FNM_PERIOD));
+                  int no_leading_period2 = no_leading_period;
+
+                  if (c == L_('\\') && !(flags & FNM_NOESCAPE))
+                    c = *p;
+                  c = FOLD (c);
+                  for (--p; n < endp; ++n, no_leading_period2 = false)
+                    if (FOLD ((UCHAR) *n) == c
+                        && (FCT (p, n, string_end, no_leading_period2, flags2)
+                            == 0))
+                      return 0;
+                }
+            }
+
+          /* If we come here no match is possible with the wildcard.  */
+          return FNM_NOMATCH;
+
+        case L_('['):
+          {
+            /* Nonzero if the sense of the character class is inverted.  */
+            register bool not;
+            CHAR cold;
+            UCHAR fn;
+
+            if (posixly_correct == 0)
+              posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1;
+
+            if (n == string_end)
+              return FNM_NOMATCH;
+
+            if (*n == L_('.') && no_leading_period)
+              return FNM_NOMATCH;
+
+            if (*n == L_('/') && (flags & FNM_FILE_NAME))
+              /* `/' cannot be matched.  */
+              return FNM_NOMATCH;
+
+            not = (*p == L_('!') || (posixly_correct < 0 && *p == L_('^')));
+            if (not)
+              ++p;
+
+            fn = FOLD ((UCHAR) *n);
+
+            c = *p++;
+            for (;;)
+              {
+                if (!(flags & FNM_NOESCAPE) && c == L_('\\'))
+                  {
+                    if (*p == L_('\0'))
+                      return FNM_NOMATCH;
+                    c = FOLD ((UCHAR) *p);
+                    ++p;
+
+                    goto normal_bracket;
+                  }
+                else if (c == L_('[') && *p == L_(':'))
+                  {
+                    /* Leave room for the null.  */
+                    CHAR str[CHAR_CLASS_MAX_LENGTH + 1];
+                    size_t c1 = 0;
 #if defined _LIBC || WIDE_CHAR_SUPPORT
-		    wctype_t wt;
+                    wctype_t wt;
 #endif
-		    const CHAR *startp = p;
-
-		    for (;;)
-		      {
-			if (c1 == CHAR_CLASS_MAX_LENGTH)
-			  /* The name is too long and therefore the pattern
-			     is ill-formed.  */
-			  return FNM_NOMATCH;
-
-			c = *++p;
-			if (c == L_(':') && p[1] == L_(']'))
-			  {
-			    p += 2;
-			    break;
-			  }
-			if (c < L_('a') || c >= L_('z'))
-			  {
-			    /* This cannot possibly be a character class name.
-			       Match it as a normal range.  */
-			    p = startp;
-			    c = L_('[');
-			    goto normal_bracket;
-			  }
-			str[c1++] = c;
-		      }
-		    str[c1] = L_('\0');
+                    const CHAR *startp = p;
+
+                    for (;;)
+                      {
+                        if (c1 == CHAR_CLASS_MAX_LENGTH)
+                          /* The name is too long and therefore the pattern
+                             is ill-formed.  */
+                          return FNM_NOMATCH;
+
+                        c = *++p;
+                        if (c == L_(':') && p[1] == L_(']'))
+                          {
+                            p += 2;
+                            break;
+                          }
+                        if (c < L_('a') || c >= L_('z'))
+                          {
+                            /* This cannot possibly be a character class name.
+                               Match it as a normal range.  */
+                            p = startp;
+                            c = L_('[');
+                            goto normal_bracket;
+                          }
+                        str[c1++] = c;
+                      }
+                    str[c1] = L_('\0');
 
 #if defined _LIBC || WIDE_CHAR_SUPPORT
-		    wt = IS_CHAR_CLASS (str);
-		    if (wt == 0)
-		      /* Invalid character class name.  */
-		      return FNM_NOMATCH;
+                    wt = IS_CHAR_CLASS (str);
+                    if (wt == 0)
+                      /* Invalid character class name.  */
+                      return FNM_NOMATCH;
 
 # if defined _LIBC && ! WIDE_CHAR_VERSION
-		    /* The following code is glibc specific but does
-		       there a good job in speeding up the code since
-		       we can avoid the btowc() call.  */
-		    if (_ISCTYPE ((UCHAR) *n, wt))
-		      goto matched;
+                    /* The following code is glibc specific but does
+                       there a good job in speeding up the code since
+                       we can avoid the btowc() call.  */
+                    if (_ISCTYPE ((UCHAR) *n, wt))
+                      goto matched;
 # else
-		    if (ISWCTYPE (BTOWC ((UCHAR) *n), wt))
-		      goto matched;
+                    if (ISWCTYPE (BTOWC ((UCHAR) *n), wt))
+                      goto matched;
 # endif
 #else
-		    if ((STREQ (str, L_("alnum")) && isalnum ((UCHAR) *n))
-			|| (STREQ (str, L_("alpha")) && isalpha ((UCHAR) *n))
-			|| (STREQ (str, L_("blank")) && isblank ((UCHAR) *n))
-			|| (STREQ (str, L_("cntrl")) && iscntrl ((UCHAR) *n))
-			|| (STREQ (str, L_("digit")) && isdigit ((UCHAR) *n))
-			|| (STREQ (str, L_("graph")) && isgraph ((UCHAR) *n))
-			|| (STREQ (str, L_("lower")) && islower ((UCHAR) *n))
-			|| (STREQ (str, L_("print")) && isprint ((UCHAR) *n))
-			|| (STREQ (str, L_("punct")) && ispunct ((UCHAR) *n))
-			|| (STREQ (str, L_("space")) && isspace ((UCHAR) *n))
-			|| (STREQ (str, L_("upper")) && isupper ((UCHAR) *n))
-			|| (STREQ (str, L_("xdigit")) && isxdigit ((UCHAR) *n)))
-		      goto matched;
+                    if ((STREQ (str, L_("alnum")) && isalnum ((UCHAR) *n))
+                        || (STREQ (str, L_("alpha")) && isalpha ((UCHAR) *n))
+                        || (STREQ (str, L_("blank")) && isblank ((UCHAR) *n))
+                        || (STREQ (str, L_("cntrl")) && iscntrl ((UCHAR) *n))
+                        || (STREQ (str, L_("digit")) && isdigit ((UCHAR) *n))
+                        || (STREQ (str, L_("graph")) && isgraph ((UCHAR) *n))
+                        || (STREQ (str, L_("lower")) && islower ((UCHAR) *n))
+                        || (STREQ (str, L_("print")) && isprint ((UCHAR) *n))
+                        || (STREQ (str, L_("punct")) && ispunct ((UCHAR) *n))
+                        || (STREQ (str, L_("space")) && isspace ((UCHAR) *n))
+                        || (STREQ (str, L_("upper")) && isupper ((UCHAR) *n))
+                        || (STREQ (str, L_("xdigit")) && isxdigit ((UCHAR) *n)))
+                      goto matched;
 #endif
-		    c = *p++;
-		  }
+                    c = *p++;
+                  }
 #ifdef _LIBC
-		else if (c == L_('[') && *p == L_('='))
-		  {
-		    UCHAR str[1];
-		    uint32_t nrules =
-		      _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
-		    const CHAR *startp = p;
-
-		    c = *++p;
-		    if (c == L_('\0'))
-		      {
-			p = startp;
-			c = L_('[');
-			goto normal_bracket;
-		      }
-		    str[0] = c;
-
-		    c = *++p;
-		    if (c != L_('=') || p[1] != L_(']'))
-		      {
-			p = startp;
-			c = L_('[');
-			goto normal_bracket;
-		      }
-		    p += 2;
-
-		    if (nrules == 0)
-		      {
-			if ((UCHAR) *n == str[0])
-			  goto matched;
-		      }
-		    else
-		      {
-			const int32_t *table;
+                else if (c == L_('[') && *p == L_('='))
+                  {
+                    UCHAR str[1];
+                    uint32_t nrules =
+                      _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
+                    const CHAR *startp = p;
+
+                    c = *++p;
+                    if (c == L_('\0'))
+                      {
+                        p = startp;
+                        c = L_('[');
+                        goto normal_bracket;
+                      }
+                    str[0] = c;
+
+                    c = *++p;
+                    if (c != L_('=') || p[1] != L_(']'))
+                      {
+                        p = startp;
+                        c = L_('[');
+                        goto normal_bracket;
+                      }
+                    p += 2;
+
+                    if (nrules == 0)
+                      {
+                        if ((UCHAR) *n == str[0])
+                          goto matched;
+                      }
+                    else
+                      {
+                        const int32_t *table;
 # if WIDE_CHAR_VERSION
-			const int32_t *weights;
-			const int32_t *extra;
+                        const int32_t *weights;
+                        const int32_t *extra;
 # else
-			const unsigned char *weights;
-			const unsigned char *extra;
+                        const unsigned char *weights;
+                        const unsigned char *extra;
 # endif
-			const int32_t *indirect;
-			int32_t idx;
-			const UCHAR *cp = (const UCHAR *) str;
+                        const int32_t *indirect;
+                        int32_t idx;
+                        const UCHAR *cp = (const UCHAR *) str;
 
-			/* This #include defines a local function!  */
+                        /* This #include defines a local function!  */
 # if WIDE_CHAR_VERSION
 #  include <locale/weightwc.h>
 # else
@@ -357,605 +357,605 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
 # endif
 
 # if WIDE_CHAR_VERSION
-			table = (const int32_t *)
-			  _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEWC);
-			weights = (const int32_t *)
-			  _NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTWC);
-			extra = (const int32_t *)
-			  _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAWC);
-			indirect = (const int32_t *)
-			  _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTWC);
+                        table = (const int32_t *)
+                          _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEWC);
+                        weights = (const int32_t *)
+                          _NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTWC);
+                        extra = (const int32_t *)
+                          _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAWC);
+                        indirect = (const int32_t *)
+                          _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTWC);
 # else
-			table = (const int32_t *)
-			  _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB);
-			weights = (const unsigned char *)
-			  _NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTMB);
-			extra = (const unsigned char *)
-			  _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB);
-			indirect = (const int32_t *)
-			  _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB);
+                        table = (const int32_t *)
+                          _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB);
+                        weights = (const unsigned char *)
+                          _NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTMB);
+                        extra = (const unsigned char *)
+                          _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB);
+                        indirect = (const int32_t *)
+                          _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB);
 # endif
 
-			idx = findidx (&cp);
-			if (idx != 0)
-			  {
-			    /* We found a table entry.  Now see whether the
-			       character we are currently at has the same
-			       equivalance class value.  */
-			    int len = weights[idx];
-			    int32_t idx2;
-			    const UCHAR *np = (const UCHAR *) n;
-
-			    idx2 = findidx (&np);
-			    if (idx2 != 0 && len == weights[idx2])
-			      {
-				int cnt = 0;
-
-				while (cnt < len
-				       && (weights[idx + 1 + cnt]
-					   == weights[idx2 + 1 + cnt]))
-				  ++cnt;
-
-				if (cnt == len)
-				  goto matched;
-			      }
-			  }
-		      }
-
-		    c = *p++;
-		  }
+                        idx = findidx (&cp);
+                        if (idx != 0)
+                          {
+                            /* We found a table entry.  Now see whether the
+                               character we are currently at has the same
+                               equivalance class value.  */
+                            int len = weights[idx];
+                            int32_t idx2;
+                            const UCHAR *np = (const UCHAR *) n;
+
+                            idx2 = findidx (&np);
+                            if (idx2 != 0 && len == weights[idx2])
+                              {
+                                int cnt = 0;
+
+                                while (cnt < len
+                                       && (weights[idx + 1 + cnt]
+                                           == weights[idx2 + 1 + cnt]))
+                                  ++cnt;
+
+                                if (cnt == len)
+                                  goto matched;
+                              }
+                          }
+                      }
+
+                    c = *p++;
+                  }
 #endif
-		else if (c == L_('\0'))
-		  /* [ (unterminated) loses.  */
-		  return FNM_NOMATCH;
-		else
-		  {
-		    bool is_range = false;
+                else if (c == L_('\0'))
+                  /* [ (unterminated) loses.  */
+                  return FNM_NOMATCH;
+                else
+                  {
+                    bool is_range = false;
 
 #ifdef _LIBC
-		    bool is_seqval = false;
-
-		    if (c == L_('[') && *p == L_('.'))
-		      {
-			uint32_t nrules =
-			  _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
-			const CHAR *startp = p;
-			size_t c1 = 0;
-
-			while (1)
-			  {
-			    c = *++p;
-			    if (c == L_('.') && p[1] == L_(']'))
-			      {
-				p += 2;
-				break;
-			      }
-			    if (c == '\0')
-			      return FNM_NOMATCH;
-			    ++c1;
-			  }
-
-			/* We have to handling the symbols differently in
-			   ranges since then the collation sequence is
-			   important.  */
-			is_range = *p == L_('-') && p[1] != L_('\0');
-
-			if (nrules == 0)
-			  {
-			    /* There are no names defined in the collation
-			       data.  Therefore we only accept the trivial
-			       names consisting of the character itself.  */
-			    if (c1 != 1)
-			      return FNM_NOMATCH;
-
-			    if (!is_range && *n == startp[1])
-			      goto matched;
-
-			    cold = startp[1];
-			    c = *p++;
-			  }
-			else
-			  {
-			    int32_t table_size;
-			    const int32_t *symb_table;
+                    bool is_seqval = false;
+
+                    if (c == L_('[') && *p == L_('.'))
+                      {
+                        uint32_t nrules =
+                          _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
+                        const CHAR *startp = p;
+                        size_t c1 = 0;
+
+                        while (1)
+                          {
+                            c = *++p;
+                            if (c == L_('.') && p[1] == L_(']'))
+                              {
+                                p += 2;
+                                break;
+                              }
+                            if (c == '\0')
+                              return FNM_NOMATCH;
+                            ++c1;
+                          }
+
+                        /* We have to handling the symbols differently in
+                           ranges since then the collation sequence is
+                           important.  */
+                        is_range = *p == L_('-') && p[1] != L_('\0');
+
+                        if (nrules == 0)
+                          {
+                            /* There are no names defined in the collation
+                               data.  Therefore we only accept the trivial
+                               names consisting of the character itself.  */
+                            if (c1 != 1)
+                              return FNM_NOMATCH;
+
+                            if (!is_range && *n == startp[1])
+                              goto matched;
+
+                            cold = startp[1];
+                            c = *p++;
+                          }
+                        else
+                          {
+                            int32_t table_size;
+                            const int32_t *symb_table;
 # ifdef WIDE_CHAR_VERSION
-			    char str[c1];
-			    size_t strcnt;
+                            char str[c1];
+                            size_t strcnt;
 # else
 #  define str (startp + 1)
 # endif
-			    const unsigned char *extra;
-			    int32_t idx;
-			    int32_t elem;
-			    int32_t second;
-			    int32_t hash;
+                            const unsigned char *extra;
+                            int32_t idx;
+                            int32_t elem;
+                            int32_t second;
+                            int32_t hash;
 
 # ifdef WIDE_CHAR_VERSION
-			    /* We have to convert the name to a single-byte
-			       string.  This is possible since the names
-			       consist of ASCII characters and the internal
-			       representation is UCS4.  */
-			    for (strcnt = 0; strcnt < c1; ++strcnt)
-			      str[strcnt] = startp[1 + strcnt];
+                            /* We have to convert the name to a single-byte
+                               string.  This is possible since the names
+                               consist of ASCII characters and the internal
+                               representation is UCS4.  */
+                            for (strcnt = 0; strcnt < c1; ++strcnt)
+                              str[strcnt] = startp[1 + strcnt];
 # endif
 
-			    table_size =
-			      _NL_CURRENT_WORD (LC_COLLATE,
-						_NL_COLLATE_SYMB_HASH_SIZEMB);
-			    symb_table = (const int32_t *)
-			      _NL_CURRENT (LC_COLLATE,
-					   _NL_COLLATE_SYMB_TABLEMB);
-			    extra = (const unsigned char *)
-			      _NL_CURRENT (LC_COLLATE,
-					   _NL_COLLATE_SYMB_EXTRAMB);
-
-			    /* Locate the character in the hashing table.  */
-			    hash = elem_hash (str, c1);
-
-			    idx = 0;
-			    elem = hash % table_size;
-			    if (symb_table[2 * elem] != 0)
-			      {
-				second = hash % (table_size - 2) + 1;
-
-				do
-				  {
-				    /* First compare the hashing value.  */
-				    if (symb_table[2 * elem] == hash
-					&& (c1
-					    == extra[symb_table[2 * elem + 1]])
-					&& memcmp (str,
-						   &extra[symb_table[2 * elem
-								     + 1]
-							  + 1], c1) == 0)
-				      {
-					/* Yep, this is the entry.  */
-					idx = symb_table[2 * elem + 1];
-					idx += 1 + extra[idx];
-					break;
-				      }
-
-				    /* Next entry.  */
-				    elem += second;
-				  }
-				while (symb_table[2 * elem] != 0);
-			      }
-
-			    if (symb_table[2 * elem] != 0)
-			      {
-				/* Compare the byte sequence but only if
-				   this is not part of a range.  */
+                            table_size =
+                              _NL_CURRENT_WORD (LC_COLLATE,
+                                                _NL_COLLATE_SYMB_HASH_SIZEMB);
+                            symb_table = (const int32_t *)
+                              _NL_CURRENT (LC_COLLATE,
+                                           _NL_COLLATE_SYMB_TABLEMB);
+                            extra = (const unsigned char *)
+                              _NL_CURRENT (LC_COLLATE,
+                                           _NL_COLLATE_SYMB_EXTRAMB);
+
+                            /* Locate the character in the hashing table.  */
+                            hash = elem_hash (str, c1);
+
+                            idx = 0;
+                            elem = hash % table_size;
+                            if (symb_table[2 * elem] != 0)
+                              {
+                                second = hash % (table_size - 2) + 1;
+
+                                do
+                                  {
+                                    /* First compare the hashing value.  */
+                                    if (symb_table[2 * elem] == hash
+                                        && (c1
+                                            == extra[symb_table[2 * elem + 1]])
+                                        && memcmp (str,
+                                                   &extra[symb_table[2 * elem
+                                                                     + 1]
+                                                          + 1], c1) == 0)
+                                      {
+                                        /* Yep, this is the entry.  */
+                                        idx = symb_table[2 * elem + 1];
+                                        idx += 1 + extra[idx];
+                                        break;
+                                      }
+
+                                    /* Next entry.  */
+                                    elem += second;
+                                  }
+                                while (symb_table[2 * elem] != 0);
+                              }
+
+                            if (symb_table[2 * elem] != 0)
+                              {
+                                /* Compare the byte sequence but only if
+                                   this is not part of a range.  */
 # ifdef WIDE_CHAR_VERSION
-				int32_t *wextra;
+                                int32_t *wextra;
 
-				idx += 1 + extra[idx];
-				/* Adjust for the alignment.  */
-				idx = (idx + 3) & ~3;
+                                idx += 1 + extra[idx];
+                                /* Adjust for the alignment.  */
+                                idx = (idx + 3) & ~3;
 
-				wextra = (int32_t *) &extra[idx + 4];
+                                wextra = (int32_t *) &extra[idx + 4];
 # endif
 
-				if (! is_range)
-				  {
+                                if (! is_range)
+                                  {
 # ifdef WIDE_CHAR_VERSION
-				    for (c1 = 0;
-					 (int32_t) c1 < wextra[idx];
-					 ++c1)
-				      if (n[c1] != wextra[1 + c1])
-					break;
-
-				    if ((int32_t) c1 == wextra[idx])
-				      goto matched;
+                                    for (c1 = 0;
+                                         (int32_t) c1 < wextra[idx];
+                                         ++c1)
+                                      if (n[c1] != wextra[1 + c1])
+                                        break;
+
+                                    if ((int32_t) c1 == wextra[idx])
+                                      goto matched;
 # else
-				    for (c1 = 0; c1 < extra[idx]; ++c1)
-				      if (n[c1] != extra[1 + c1])
-					break;
+                                    for (c1 = 0; c1 < extra[idx]; ++c1)
+                                      if (n[c1] != extra[1 + c1])
+                                        break;
 
-				    if (c1 == extra[idx])
-				      goto matched;
+                                    if (c1 == extra[idx])
+                                      goto matched;
 # endif
-				  }
+                                  }
 
-				/* Get the collation sequence value.  */
-				is_seqval = true;
+                                /* Get the collation sequence value.  */
+                                is_seqval = true;
 # ifdef WIDE_CHAR_VERSION
-				cold = wextra[1 + wextra[idx]];
+                                cold = wextra[1 + wextra[idx]];
 # else
-				/* Adjust for the alignment.  */
-				idx += 1 + extra[idx];
-				idx = (idx + 3) & ~4;
-				cold = *((int32_t *) &extra[idx]);
+                                /* Adjust for the alignment.  */
+                                idx += 1 + extra[idx];
+                                idx = (idx + 3) & ~4;
+                                cold = *((int32_t *) &extra[idx]);
 # endif
 
-				c = *p++;
-			      }
-			    else if (c1 == 1)
-			      {
-				/* No valid character.  Match it as a
-				   single byte.  */
-				if (!is_range && *n == str[0])
-				  goto matched;
-
-				cold = str[0];
-				c = *p++;
-			      }
-			    else
-			      return FNM_NOMATCH;
-			  }
-		      }
-		    else
+                                c = *p++;
+                              }
+                            else if (c1 == 1)
+                              {
+                                /* No valid character.  Match it as a
+                                   single byte.  */
+                                if (!is_range && *n == str[0])
+                                  goto matched;
+
+                                cold = str[0];
+                                c = *p++;
+                              }
+                            else
+                              return FNM_NOMATCH;
+                          }
+                      }
+                    else
 # undef str
 #endif
-		      {
-			c = FOLD (c);
-		      normal_bracket:
+                      {
+                        c = FOLD (c);
+                      normal_bracket:
 
-			/* We have to handling the symbols differently in
-			   ranges since then the collation sequence is
-			   important.  */
-			is_range = (*p == L_('-') && p[1] != L_('\0')
-				    && p[1] != L_(']'));
+                        /* We have to handling the symbols differently in
+                           ranges since then the collation sequence is
+                           important.  */
+                        is_range = (*p == L_('-') && p[1] != L_('\0')
+                                    && p[1] != L_(']'));
 
-			if (!is_range && c == fn)
-			  goto matched;
+                        if (!is_range && c == fn)
+                          goto matched;
 
 #if _LIBC
-			/* This is needed if we goto normal_bracket; from
-			   outside of is_seqval's scope.  */
-			is_seqval = false;
+                        /* This is needed if we goto normal_bracket; from
+                           outside of is_seqval's scope.  */
+                        is_seqval = false;
 #endif
 
-			cold = c;
-			c = *p++;
-		      }
+                        cold = c;
+                        c = *p++;
+                      }
 
-		    if (c == L_('-') && *p != L_(']'))
-		      {
+                    if (c == L_('-') && *p != L_(']'))
+                      {
 #if _LIBC
-			/* We have to find the collation sequence
-			   value for C.  Collation sequence is nothing
-			   we can regularly access.  The sequence
-			   value is defined by the order in which the
-			   definitions of the collation values for the
-			   various characters appear in the source
-			   file.  A strange concept, nowhere
-			   documented.  */
-			uint32_t fcollseq;
-			uint32_t lcollseq;
-			UCHAR cend = *p++;
+                        /* We have to find the collation sequence
+                           value for C.  Collation sequence is nothing
+                           we can regularly access.  The sequence
+                           value is defined by the order in which the
+                           definitions of the collation values for the
+                           various characters appear in the source
+                           file.  A strange concept, nowhere
+                           documented.  */
+                        uint32_t fcollseq;
+                        uint32_t lcollseq;
+                        UCHAR cend = *p++;
 
 # ifdef WIDE_CHAR_VERSION
-			/* Search in the `names' array for the characters.  */
-			fcollseq = __collseq_table_lookup (collseq, fn);
-			if (fcollseq == ~((uint32_t) 0))
-			  /* XXX We don't know anything about the character
-			     we are supposed to match.  This means we are
-			     failing.  */
-			  goto range_not_matched;
-
-			if (is_seqval)
-			  lcollseq = cold;
-			else
-			  lcollseq = __collseq_table_lookup (collseq, cold);
+                        /* Search in the `names' array for the characters.  */
+                        fcollseq = __collseq_table_lookup (collseq, fn);
+                        if (fcollseq == ~((uint32_t) 0))
+                          /* XXX We don't know anything about the character
+                             we are supposed to match.  This means we are
+                             failing.  */
+                          goto range_not_matched;
+
+                        if (is_seqval)
+                          lcollseq = cold;
+                        else
+                          lcollseq = __collseq_table_lookup (collseq, cold);
 # else
-			fcollseq = collseq[fn];
-			lcollseq = is_seqval ? cold : collseq[(UCHAR) cold];
+                        fcollseq = collseq[fn];
+                        lcollseq = is_seqval ? cold : collseq[(UCHAR) cold];
 # endif
 
-			is_seqval = false;
-			if (cend == L_('[') && *p == L_('.'))
-			  {
-			    uint32_t nrules =
-			      _NL_CURRENT_WORD (LC_COLLATE,
-						_NL_COLLATE_NRULES);
-			    const CHAR *startp = p;
-			    size_t c1 = 0;
-
-			    while (1)
-			      {
-				c = *++p;
-				if (c == L_('.') && p[1] == L_(']'))
-				  {
-				    p += 2;
-				    break;
-				  }
-				if (c == '\0')
-				  return FNM_NOMATCH;
-				++c1;
-			      }
-
-			    if (nrules == 0)
-			      {
-				/* There are no names defined in the
-				   collation data.  Therefore we only
-				   accept the trivial names consisting
-				   of the character itself.  */
-				if (c1 != 1)
-				  return FNM_NOMATCH;
-
-				cend = startp[1];
-			      }
-			    else
-			      {
-				int32_t table_size;
-				const int32_t *symb_table;
+                        is_seqval = false;
+                        if (cend == L_('[') && *p == L_('.'))
+                          {
+                            uint32_t nrules =
+                              _NL_CURRENT_WORD (LC_COLLATE,
+                                                _NL_COLLATE_NRULES);
+                            const CHAR *startp = p;
+                            size_t c1 = 0;
+
+                            while (1)
+                              {
+                                c = *++p;
+                                if (c == L_('.') && p[1] == L_(']'))
+                                  {
+                                    p += 2;
+                                    break;
+                                  }
+                                if (c == '\0')
+                                  return FNM_NOMATCH;
+                                ++c1;
+                              }
+
+                            if (nrules == 0)
+                              {
+                                /* There are no names defined in the
+                                   collation data.  Therefore we only
+                                   accept the trivial names consisting
+                                   of the character itself.  */
+                                if (c1 != 1)
+                                  return FNM_NOMATCH;
+
+                                cend = startp[1];
+                              }
+                            else
+                              {
+                                int32_t table_size;
+                                const int32_t *symb_table;
 # ifdef WIDE_CHAR_VERSION
-				char str[c1];
-				size_t strcnt;
+                                char str[c1];
+                                size_t strcnt;
 # else
 #  define str (startp + 1)
 # endif
-				const unsigned char *extra;
-				int32_t idx;
-				int32_t elem;
-				int32_t second;
-				int32_t hash;
+                                const unsigned char *extra;
+                                int32_t idx;
+                                int32_t elem;
+                                int32_t second;
+                                int32_t hash;
 
 # ifdef WIDE_CHAR_VERSION
-				/* We have to convert the name to a single-byte
-				   string.  This is possible since the names
-				   consist of ASCII characters and the internal
-				   representation is UCS4.  */
-				for (strcnt = 0; strcnt < c1; ++strcnt)
-				  str[strcnt] = startp[1 + strcnt];
+                                /* We have to convert the name to a single-byte
+                                   string.  This is possible since the names
+                                   consist of ASCII characters and the internal
+                                   representation is UCS4.  */
+                                for (strcnt = 0; strcnt < c1; ++strcnt)
+                                  str[strcnt] = startp[1 + strcnt];
 # endif
 
-				table_size =
-				  _NL_CURRENT_WORD (LC_COLLATE,
-						    _NL_COLLATE_SYMB_HASH_SIZEMB);
-				symb_table = (const int32_t *)
-				  _NL_CURRENT (LC_COLLATE,
-					       _NL_COLLATE_SYMB_TABLEMB);
-				extra = (const unsigned char *)
-				  _NL_CURRENT (LC_COLLATE,
-					       _NL_COLLATE_SYMB_EXTRAMB);
-
-				/* Locate the character in the hashing
+                                table_size =
+                                  _NL_CURRENT_WORD (LC_COLLATE,
+                                                    _NL_COLLATE_SYMB_HASH_SIZEMB);
+                                symb_table = (const int32_t *)
+                                  _NL_CURRENT (LC_COLLATE,
+                                               _NL_COLLATE_SYMB_TABLEMB);
+                                extra = (const unsigned char *)
+                                  _NL_CURRENT (LC_COLLATE,
+                                               _NL_COLLATE_SYMB_EXTRAMB);
+
+                                /* Locate the character in the hashing
                                    table.  */
-				hash = elem_hash (str, c1);
-
-				idx = 0;
-				elem = hash % table_size;
-				if (symb_table[2 * elem] != 0)
-				  {
-				    second = hash % (table_size - 2) + 1;
-
-				    do
-				      {
-					/* First compare the hashing value.  */
-					if (symb_table[2 * elem] == hash
-					    && (c1
-						== extra[symb_table[2 * elem + 1]])
-					    && memcmp (str,
-						       &extra[symb_table[2 * elem + 1]
-							      + 1], c1) == 0)
-					  {
-					    /* Yep, this is the entry.  */
-					    idx = symb_table[2 * elem + 1];
-					    idx += 1 + extra[idx];
-					    break;
-					  }
-
-					/* Next entry.  */
-					elem += second;
-				      }
-				    while (symb_table[2 * elem] != 0);
-				  }
-
-				if (symb_table[2 * elem] != 0)
-				  {
-				    /* Compare the byte sequence but only if
-				       this is not part of a range.  */
+                                hash = elem_hash (str, c1);
+
+                                idx = 0;
+                                elem = hash % table_size;
+                                if (symb_table[2 * elem] != 0)
+                                  {
+                                    second = hash % (table_size - 2) + 1;
+
+                                    do
+                                      {
+                                        /* First compare the hashing value.  */
+                                        if (symb_table[2 * elem] == hash
+                                            && (c1
+                                                == extra[symb_table[2 * elem + 1]])
+                                            && memcmp (str,
+                                                       &extra[symb_table[2 * elem + 1]
+                                                              + 1], c1) == 0)
+                                          {
+                                            /* Yep, this is the entry.  */
+                                            idx = symb_table[2 * elem + 1];
+                                            idx += 1 + extra[idx];
+                                            break;
+                                          }
+
+                                        /* Next entry.  */
+                                        elem += second;
+                                      }
+                                    while (symb_table[2 * elem] != 0);
+                                  }
+
+                                if (symb_table[2 * elem] != 0)
+                                  {
+                                    /* Compare the byte sequence but only if
+                                       this is not part of a range.  */
 # ifdef WIDE_CHAR_VERSION
-				    int32_t *wextra;
+                                    int32_t *wextra;
 
-				    idx += 1 + extra[idx];
-				    /* Adjust for the alignment.  */
-				    idx = (idx + 3) & ~4;
+                                    idx += 1 + extra[idx];
+                                    /* Adjust for the alignment.  */
+                                    idx = (idx + 3) & ~4;
 
-				    wextra = (int32_t *) &extra[idx + 4];
+                                    wextra = (int32_t *) &extra[idx + 4];
 # endif
-				    /* Get the collation sequence value.  */
-				    is_seqval = true;
+                                    /* Get the collation sequence value.  */
+                                    is_seqval = true;
 # ifdef WIDE_CHAR_VERSION
-				    cend = wextra[1 + wextra[idx]];
+                                    cend = wextra[1 + wextra[idx]];
 # else
-				    /* Adjust for the alignment.  */
-				    idx += 1 + extra[idx];
-				    idx = (idx + 3) & ~4;
-				    cend = *((int32_t *) &extra[idx]);
+                                    /* Adjust for the alignment.  */
+                                    idx += 1 + extra[idx];
+                                    idx = (idx + 3) & ~4;
+                                    cend = *((int32_t *) &extra[idx]);
 # endif
-				  }
-				else if (symb_table[2 * elem] != 0 && c1 == 1)
-				  {
-				    cend = str[0];
-				    c = *p++;
-				  }
-				else
-				  return FNM_NOMATCH;
-			      }
+                                  }
+                                else if (symb_table[2 * elem] != 0 && c1 == 1)
+                                  {
+                                    cend = str[0];
+                                    c = *p++;
+                                  }
+                                else
+                                  return FNM_NOMATCH;
+                              }
 # undef str
-			  }
-			else
-			  {
-			    if (!(flags & FNM_NOESCAPE) && cend == L_('\\'))
-			      cend = *p++;
-			    if (cend == L_('\0'))
-			      return FNM_NOMATCH;
-			    cend = FOLD (cend);
-			  }
-
-			/* XXX It is not entirely clear to me how to handle
-			   characters which are not mentioned in the
-			   collation specification.  */
-			if (
+                          }
+                        else
+                          {
+                            if (!(flags & FNM_NOESCAPE) && cend == L_('\\'))
+                              cend = *p++;
+                            if (cend == L_('\0'))
+                              return FNM_NOMATCH;
+                            cend = FOLD (cend);
+                          }
+
+                        /* XXX It is not entirely clear to me how to handle
+                           characters which are not mentioned in the
+                           collation specification.  */
+                        if (
 # ifdef WIDE_CHAR_VERSION
-			    lcollseq == 0xffffffff ||
+                            lcollseq == 0xffffffff ||
 # endif
-			    lcollseq <= fcollseq)
-			  {
-			    /* We have to look at the upper bound.  */
-			    uint32_t hcollseq;
-
-			    if (is_seqval)
-			      hcollseq = cend;
-			    else
-			      {
+                            lcollseq <= fcollseq)
+                          {
+                            /* We have to look at the upper bound.  */
+                            uint32_t hcollseq;
+
+                            if (is_seqval)
+                              hcollseq = cend;
+                            else
+                              {
 # ifdef WIDE_CHAR_VERSION
-				hcollseq =
-				  __collseq_table_lookup (collseq, cend);
-				if (hcollseq == ~((uint32_t) 0))
-				  {
-				    /* Hum, no information about the upper
-				       bound.  The matching succeeds if the
-				       lower bound is matched exactly.  */
-				    if (lcollseq != fcollseq)
-				      goto range_not_matched;
-
-				    goto matched;
-				  }
+                                hcollseq =
+                                  __collseq_table_lookup (collseq, cend);
+                                if (hcollseq == ~((uint32_t) 0))
+                                  {
+                                    /* Hum, no information about the upper
+                                       bound.  The matching succeeds if the
+                                       lower bound is matched exactly.  */
+                                    if (lcollseq != fcollseq)
+                                      goto range_not_matched;
+
+                                    goto matched;
+                                  }
 # else
-				hcollseq = collseq[cend];
+                                hcollseq = collseq[cend];
 # endif
-			      }
+                              }
 
-			    if (lcollseq <= hcollseq && fcollseq <= hcollseq)
-			      goto matched;
-			  }
+                            if (lcollseq <= hcollseq && fcollseq <= hcollseq)
+                              goto matched;
+                          }
 # ifdef WIDE_CHAR_VERSION
-		      range_not_matched:
+                      range_not_matched:
 # endif
 #else
-			/* We use a boring value comparison of the character
-			   values.  This is better than comparing using
-			   `strcoll' since the latter would have surprising
-			   and sometimes fatal consequences.  */
-			UCHAR cend = *p++;
-
-			if (!(flags & FNM_NOESCAPE) && cend == L_('\\'))
-			  cend = *p++;
-			if (cend == L_('\0'))
-			  return FNM_NOMATCH;
-
-			/* It is a range.  */
-			if (cold <= fn && fn <= cend)
-			  goto matched;
+                        /* We use a boring value comparison of the character
+                           values.  This is better than comparing using
+                           `strcoll' since the latter would have surprising
+                           and sometimes fatal consequences.  */
+                        UCHAR cend = *p++;
+
+                        if (!(flags & FNM_NOESCAPE) && cend == L_('\\'))
+                          cend = *p++;
+                        if (cend == L_('\0'))
+                          return FNM_NOMATCH;
+
+                        /* It is a range.  */
+                        if (cold <= fn && fn <= cend)
+                          goto matched;
 #endif
 
-			c = *p++;
-		      }
-		  }
-
-		if (c == L_(']'))
-		  break;
-	      }
-
-	    if (!not)
-	      return FNM_NOMATCH;
-	    break;
-
-	  matched:
-	    /* Skip the rest of the [...] that already matched.  */
-	    do
-	      {
-	      ignore_next:
-		c = *p++;
-
-		if (c == L_('\0'))
-		  /* [... (unterminated) loses.  */
-		  return FNM_NOMATCH;
-
-		if (!(flags & FNM_NOESCAPE) && c == L_('\\'))
-		  {
-		    if (*p == L_('\0'))
-		      return FNM_NOMATCH;
-		    /* XXX 1003.2d11 is unclear if this is right.  */
-		    ++p;
-		  }
-		else if (c == L_('[') && *p == L_(':'))
-		  {
-		    int c1 = 0;
-		    const CHAR *startp = p;
-
-		    while (1)
-		      {
-			c = *++p;
-			if (++c1 == CHAR_CLASS_MAX_LENGTH)
-			  return FNM_NOMATCH;
-
-			if (*p == L_(':') && p[1] == L_(']'))
-			  break;
-
-			if (c < L_('a') || c >= L_('z'))
-			  {
-			    p = startp;
-			    goto ignore_next;
-			  }
-		      }
-		    p += 2;
-		    c = *p++;
-		  }
-		else if (c == L_('[') && *p == L_('='))
-		  {
-		    c = *++p;
-		    if (c == L_('\0'))
-		      return FNM_NOMATCH;
-		    c = *++p;
-		    if (c != L_('=') || p[1] != L_(']'))
-		      return FNM_NOMATCH;
-		    p += 2;
-		    c = *p++;
-		  }
-		else if (c == L_('[') && *p == L_('.'))
-		  {
-		    ++p;
-		    while (1)
-		      {
-			c = *++p;
-			if (c == '\0')
-			  return FNM_NOMATCH;
-
-			if (*p == L_('.') && p[1] == L_(']'))
-			  break;
-		      }
-		    p += 2;
-		    c = *p++;
-		  }
-	      }
-	    while (c != L_(']'));
-	    if (not)
-	      return FNM_NOMATCH;
-	  }
-	  break;
-
-	case L_('+'):
-	case L_('@'):
-	case L_('!'):
-	  if (__builtin_expect (flags & FNM_EXTMATCH, 0) && *p == '(')
-	    {
-	      int res;
-
-	      res = EXT (c, p, n, string_end, no_leading_period, flags);
-	      if (res != -1)
-		return res;
-	    }
-	  goto normal_match;
-
-	case L_('/'):
-	  if (NO_LEADING_PERIOD (flags))
-	    {
-	      if (n == string_end || c != (UCHAR) *n)
-		return FNM_NOMATCH;
-
-	      new_no_leading_period = true;
-	      break;
-	    }
-	  /* FALLTHROUGH */
-	default:
-	normal_match:
-	  if (n == string_end || c != FOLD ((UCHAR) *n))
-	    return FNM_NOMATCH;
-	}
+                        c = *p++;
+                      }
+                  }
+
+                if (c == L_(']'))
+                  break;
+              }
+
+            if (!not)
+              return FNM_NOMATCH;
+            break;
+
+          matched:
+            /* Skip the rest of the [...] that already matched.  */
+            do
+              {
+              ignore_next:
+                c = *p++;
+
+                if (c == L_('\0'))
+                  /* [... (unterminated) loses.  */
+                  return FNM_NOMATCH;
+
+                if (!(flags & FNM_NOESCAPE) && c == L_('\\'))
+                  {
+                    if (*p == L_('\0'))
+                      return FNM_NOMATCH;
+                    /* XXX 1003.2d11 is unclear if this is right.  */
+                    ++p;
+                  }
+                else if (c == L_('[') && *p == L_(':'))
+                  {
+                    int c1 = 0;
+                    const CHAR *startp = p;
+
+                    while (1)
+                      {
+                        c = *++p;
+                        if (++c1 == CHAR_CLASS_MAX_LENGTH)
+                          return FNM_NOMATCH;
+
+                        if (*p == L_(':') && p[1] == L_(']'))
+                          break;
+
+                        if (c < L_('a') || c >= L_('z'))
+                          {
+                            p = startp;
+                            goto ignore_next;
+                          }
+                      }
+                    p += 2;
+                    c = *p++;
+                  }
+                else if (c == L_('[') && *p == L_('='))
+                  {
+                    c = *++p;
+                    if (c == L_('\0'))
+                      return FNM_NOMATCH;
+                    c = *++p;
+                    if (c != L_('=') || p[1] != L_(']'))
+                      return FNM_NOMATCH;
+                    p += 2;
+                    c = *p++;
+                  }
+                else if (c == L_('[') && *p == L_('.'))
+                  {
+                    ++p;
+                    while (1)
+                      {
+                        c = *++p;
+                        if (c == '\0')
+                          return FNM_NOMATCH;
+
+                        if (*p == L_('.') && p[1] == L_(']'))
+                          break;
+                      }
+                    p += 2;
+                    c = *p++;
+                  }
+              }
+            while (c != L_(']'));
+            if (not)
+              return FNM_NOMATCH;
+          }
+          break;
+
+        case L_('+'):
+        case L_('@'):
+        case L_('!'):
+          if (__builtin_expect (flags & FNM_EXTMATCH, 0) && *p == '(')
+            {
+              int res;
+
+              res = EXT (c, p, n, string_end, no_leading_period, flags);
+              if (res != -1)
+                return res;
+            }
+          goto normal_match;
+
+        case L_('/'):
+          if (NO_LEADING_PERIOD (flags))
+            {
+              if (n == string_end || c != (UCHAR) *n)
+                return FNM_NOMATCH;
+
+              new_no_leading_period = true;
+              break;
+            }
+          /* FALLTHROUGH */
+        default:
+        normal_match:
+          if (n == string_end || c != FOLD ((UCHAR) *n))
+            return FNM_NOMATCH;
+        }
 
       no_leading_period = new_no_leading_period;
       ++n;
@@ -984,25 +984,25 @@ END (const CHAR *pattern)
       return pattern;
     else if (*p == L_('['))
       {
-	/* Handle brackets special.  */
-	if (posixly_correct == 0)
-	  posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1;
-
-	/* Skip the not sign.  We have to recognize it because of a possibly
-	   following ']'.  */
-	if (*++p == L_('!') || (posixly_correct < 0 && *p == L_('^')))
-	  ++p;
-	/* A leading ']' is recognized as such.  */
-	if (*p == L_(']'))
-	  ++p;
-	/* Skip over all characters of the list.  */
-	while (*p != L_(']'))
-	  if (*p++ == L_('\0'))
-	    /* This is no valid pattern.  */
-	    return pattern;
+        /* Handle brackets special.  */
+        if (posixly_correct == 0)
+          posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1;
+
+        /* Skip the not sign.  We have to recognize it because of a possibly
+           following ']'.  */
+        if (*++p == L_('!') || (posixly_correct < 0 && *p == L_('^')))
+          ++p;
+        /* A leading ']' is recognized as such.  */
+        if (*p == L_(']'))
+          ++p;
+        /* Skip over all characters of the list.  */
+        while (*p != L_(']'))
+          if (*p++ == L_('\0'))
+            /* This is no valid pattern.  */
+            return pattern;
       }
     else if ((*p == L_('?') || *p == L_('*') || *p == L_('+') || *p == L_('@')
-	      || *p == L_('!')) && p[1] == L_('('))
+              || *p == L_('!')) && p[1] == L_('('))
       p = END (p + 1);
     else if (*p == L_(')'))
       break;
@@ -1037,63 +1037,63 @@ EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end,
       return -1;
     else if (*p == L_('['))
       {
-	/* Handle brackets special.  */
-	if (posixly_correct == 0)
-	  posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1;
-
-	/* Skip the not sign.  We have to recognize it because of a possibly
-	   following ']'.  */
-	if (*++p == L_('!') || (posixly_correct < 0 && *p == L_('^')))
-	  ++p;
-	/* A leading ']' is recognized as such.  */
-	if (*p == L_(']'))
-	  ++p;
-	/* Skip over all characters of the list.  */
-	while (*p != L_(']'))
-	  if (*p++ == L_('\0'))
-	    /* This is no valid pattern.  */
-	    return -1;
+        /* Handle brackets special.  */
+        if (posixly_correct == 0)
+          posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1;
+
+        /* Skip the not sign.  We have to recognize it because of a possibly
+           following ']'.  */
+        if (*++p == L_('!') || (posixly_correct < 0 && *p == L_('^')))
+          ++p;
+        /* A leading ']' is recognized as such.  */
+        if (*p == L_(']'))
+          ++p;
+        /* Skip over all characters of the list.  */
+        while (*p != L_(']'))
+          if (*p++ == L_('\0'))
+            /* This is no valid pattern.  */
+            return -1;
       }
     else if ((*p == L_('?') || *p == L_('*') || *p == L_('+') || *p == L_('@')
-	      || *p == L_('!')) && p[1] == L_('('))
+              || *p == L_('!')) && p[1] == L_('('))
       /* Remember the nesting level.  */
       ++level;
     else if (*p == L_(')'))
       {
-	if (level-- == 0)
-	  {
-	    /* This means we found the end of the pattern.  */
+        if (level-- == 0)
+          {
+            /* This means we found the end of the pattern.  */
 #define NEW_PATTERN \
-	    struct patternlist *newp;					      \
-	    size_t plen;						      \
-	    size_t plensize;						      \
-	    size_t newpsize;						      \
-									      \
-	    plen = (opt == L_('?') || opt == L_('@')			      \
-		    ? pattern_len					      \
-		    : p - startp + 1);					      \
-	    plensize = plen * sizeof (CHAR);				      \
-	    newpsize = offsetof (struct patternlist, str) + plensize;	      \
-	    if ((size_t) -1 / sizeof (CHAR) < plen			      \
-		|| newpsize < offsetof (struct patternlist, str)	      \
-		|| ALLOCA_LIMIT <= newpsize)				      \
-	      return -1;						      \
-	    newp = (struct patternlist *) alloca (newpsize);		      \
-	    *((CHAR *) MEMPCPY (newp->str, startp, p - startp)) = L_('\0');    \
-	    newp->next = NULL;						      \
-	    *lastp = newp;						      \
-	    lastp = &newp->next
-	    NEW_PATTERN;
-	    break;
-	  }
+            struct patternlist *newp;                                         \
+            size_t plen;                                                      \
+            size_t plensize;                                                  \
+            size_t newpsize;                                                  \
+                                                                              \
+            plen = (opt == L_('?') || opt == L_('@')                          \
+                    ? pattern_len                                             \
+                    : p - startp + 1UL);                                      \
+            plensize = plen * sizeof (CHAR);                                  \
+            newpsize = offsetof (struct patternlist, str) + plensize;         \
+            if ((size_t) -1 / sizeof (CHAR) < plen                            \
+                || newpsize < offsetof (struct patternlist, str)              \
+                || ALLOCA_LIMIT <= newpsize)                                  \
+              return -1;                                                      \
+            newp = (struct patternlist *) alloca (newpsize);                  \
+            *((CHAR *) MEMPCPY (newp->str, startp, p - startp)) = L_('\0');    \
+            newp->next = NULL;                                                \
+            *lastp = newp;                                                    \
+            lastp = &newp->next
+            NEW_PATTERN;
+            break;
+          }
       }
     else if (*p == L_('|'))
       {
-	if (level == 0)
-	  {
-	    NEW_PATTERN;
-	    startp = p + 1;
-	  }
+        if (level == 0)
+          {
+            NEW_PATTERN;
+            startp = p + 1;
+          }
       }
   assert (list != NULL);
   assert (p[-1] == L_(')'));
@@ -1103,36 +1103,36 @@ EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end,
     {
     case L_('*'):
       if (FCT (p, string, string_end, no_leading_period, flags) == 0)
-	return 0;
+        return 0;
       /* FALLTHROUGH */
 
     case L_('+'):
       do
-	{
-	  for (rs = string; rs <= string_end; ++rs)
-	    /* First match the prefix with the current pattern with the
-	       current pattern.  */
-	    if (FCT (list->str, string, rs, no_leading_period,
-		     flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD) == 0
-		/* This was successful.  Now match the rest with the rest
-		   of the pattern.  */
-		&& (FCT (p, rs, string_end,
-			 rs == string
-			 ? no_leading_period
-			 : rs[-1] == '/' && NO_LEADING_PERIOD (flags),
-			 flags & FNM_FILE_NAME
-			 ? flags : flags & ~FNM_PERIOD) == 0
-		    /* This didn't work.  Try the whole pattern.  */
-		    || (rs != string
-			&& FCT (pattern - 1, rs, string_end,
-				rs == string
-				? no_leading_period
-				: rs[-1] == '/' && NO_LEADING_PERIOD (flags),
-				flags & FNM_FILE_NAME
-				? flags : flags & ~FNM_PERIOD) == 0)))
-	      /* It worked.  Signal success.  */
-	      return 0;
-	}
+        {
+          for (rs = string; rs <= string_end; ++rs)
+            /* First match the prefix with the current pattern with the
+               current pattern.  */
+            if (FCT (list->str, string, rs, no_leading_period,
+                     flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD) == 0
+                /* This was successful.  Now match the rest with the rest
+                   of the pattern.  */
+                && (FCT (p, rs, string_end,
+                         rs == string
+                         ? no_leading_period
+                         : rs[-1] == '/' && NO_LEADING_PERIOD (flags),
+                         flags & FNM_FILE_NAME
+                         ? flags : flags & ~FNM_PERIOD) == 0
+                    /* This didn't work.  Try the whole pattern.  */
+                    || (rs != string
+                        && FCT (pattern - 1, rs, string_end,
+                                rs == string
+                                ? no_leading_period
+                                : rs[-1] == '/' && NO_LEADING_PERIOD (flags),
+                                flags & FNM_FILE_NAME
+                                ? flags : flags & ~FNM_PERIOD) == 0)))
+              /* It worked.  Signal success.  */
+              return 0;
+        }
       while ((list = list->next) != NULL);
 
       /* None of the patterns lead to a match.  */
@@ -1140,20 +1140,20 @@ EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end,
 
     case L_('?'):
       if (FCT (p, string, string_end, no_leading_period, flags) == 0)
-	return 0;
+        return 0;
       /* FALLTHROUGH */
 
     case L_('@'):
       do
-	/* I cannot believe it but `strcat' is actually acceptable
-	   here.  Match the entire string with the prefix from the
-	   pattern list and the rest of the pattern following the
-	   pattern list.  */
-	if (FCT (STRCAT (list->str, p), string, string_end,
-		 no_leading_period,
-		 flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD) == 0)
-	  /* It worked.  Signal success.  */
-	  return 0;
+        /* I cannot believe it but `strcat' is actually acceptable
+           here.  Match the entire string with the prefix from the
+           pattern list and the rest of the pattern following the
+           pattern list.  */
+        if (FCT (STRCAT (list->str, p), string, string_end,
+                 no_leading_period,
+                 flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD) == 0)
+          /* It worked.  Signal success.  */
+          return 0;
       while ((list = list->next) != NULL);
 
       /* None of the patterns lead to a match.  */
@@ -1161,28 +1161,28 @@ EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end,
 
     case L_('!'):
       for (rs = string; rs <= string_end; ++rs)
-	{
-	  struct patternlist *runp;
-
-	  for (runp = list; runp != NULL; runp = runp->next)
-	    if (FCT (runp->str, string, rs,  no_leading_period,
-		     flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD) == 0)
-	      break;
-
-	  /* If none of the patterns matched see whether the rest does.  */
-	  if (runp == NULL
-	      && (FCT (p, rs, string_end,
-		       rs == string
-		       ? no_leading_period
-		       : rs[-1] == '/' && NO_LEADING_PERIOD (flags),
-		       flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD)
-		  == 0))
-	    /* This is successful.  */
-	    return 0;
-	}
+        {
+          struct patternlist *runp;
+
+          for (runp = list; runp != NULL; runp = runp->next)
+            if (FCT (runp->str, string, rs,  no_leading_period,
+                     flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD) == 0)
+              break;
+
+          /* If none of the patterns matched see whether the rest does.  */
+          if (runp == NULL
+              && (FCT (p, rs, string_end,
+                       rs == string
+                       ? no_leading_period
+                       : rs[-1] == '/' && NO_LEADING_PERIOD (flags),
+                       flags & FNM_FILE_NAME ? flags : flags & ~FNM_PERIOD)
+                  == 0))
+            /* This is successful.  */
+            return 0;
+        }
 
       /* None of the patterns together with the rest of the pattern
-	 lead to a match.  */
+         lead to a match.  */
       return FNM_NOMATCH;
 
     default:
diff --git a/libmissing/getaddrinfo.c b/libmissing/getaddrinfo.c
index 45366a5..cb75181 100644
--- a/libmissing/getaddrinfo.c
+++ b/libmissing/getaddrinfo.c
@@ -1,6 +1,5 @@
 /* Get address information (partial implementation).
-   Copyright (C) 1997, 2001, 2002, 2004, 2005, 2006, 2007, 2008 Free Software
-   Foundation, Inc.
+   Copyright (C) 1997, 2001-2002, 2004-2009 Free Software Foundation, Inc.
    Contributed by Simon Josefsson <[email protected]>.
 
    This program is free software; you can redistribute it and/or modify
@@ -19,6 +18,10 @@
 
 #include <config.h>
 
+/* Don't use __attribute__ __nonnull__ in this compilation unit.  Otherwise gcc
+   optimizes away the sa == NULL test below.  */
+#define _GL_ARG_NONNULL(params)
+
 #include <netdb.h>
 
 #if HAVE_NETINET_IN_H
@@ -58,12 +61,12 @@
 
 #ifdef WIN32_NATIVE
 typedef int (WSAAPI *getaddrinfo_func) (const char*, const char*,
-					const struct addrinfo*,
-					struct addrinfo**);
+                                        const struct addrinfo*,
+                                        struct addrinfo**);
 typedef void (WSAAPI *freeaddrinfo_func) (struct addrinfo*);
 typedef int (WSAAPI *getnameinfo_func) (const struct sockaddr*,
-					socklen_t, char*, DWORD,
-					char*, DWORD, int);
+                                        socklen_t, char*, DWORD,
+                                        char*, DWORD, int);
 
 static getaddrinfo_func getaddrinfo_ptr = NULL;
 static freeaddrinfo_func freeaddrinfo_ptr = NULL;
@@ -123,9 +126,9 @@ validate_family (int family)
    socket addresses. */
 int
 getaddrinfo (const char *restrict nodename,
-	     const char *restrict servname,
-	     const struct addrinfo *restrict hints,
-	     struct addrinfo **restrict res)
+             const char *restrict servname,
+             const struct addrinfo *restrict hints,
+             struct addrinfo **restrict res)
 {
   struct addrinfo *tmp;
   int port = 0;
@@ -165,7 +168,7 @@ getaddrinfo (const char *restrict nodename,
   if (!nodename)
     {
       if (!(hints->ai_flags & AI_PASSIVE))
-	return EAI_NONAME;
+        return EAI_NONAME;
 
 #ifdef HAVE_IPV6
       nodename = (hints->ai_family == AF_INET6) ? "::" : "0.0.0.0";
@@ -178,24 +181,24 @@ getaddrinfo (const char *restrict nodename,
     {
       struct servent *se = NULL;
       const char *proto =
-	(hints && hints->ai_socktype == SOCK_DGRAM) ? "udp" : "tcp";
+        (hints && hints->ai_socktype == SOCK_DGRAM) ? "udp" : "tcp";
 
       if (hints == NULL || !(hints->ai_flags & AI_NUMERICSERV))
-	/* FIXME: Use getservbyname_r if available. */
-	se = getservbyname (servname, proto);
+        /* FIXME: Use getservbyname_r if available. */
+        se = getservbyname (servname, proto);
 
       if (!se)
-	{
-	  char *c;
-	  if (!(*servname >= '0' && *servname <= '9'))
-	    return EAI_NONAME;
-	  port = strtoul (servname, &c, 10);
-	  if (*c || port > 0xffff)
-	    return EAI_NONAME;
-	  port = htons (port);
-	}
+        {
+          char *c;
+          if (!(*servname >= '0' && *servname <= '9'))
+            return EAI_NONAME;
+          port = strtoul (servname, &c, 10);
+          if (*c || port > 0xffff)
+            return EAI_NONAME;
+          port = htons (port);
+        }
       else
-	port = se->s_port;
+        port = se->s_port;
     }
 
   /* FIXME: Use gethostbyname_r if available. */
@@ -230,23 +233,23 @@ getaddrinfo (const char *restrict nodename,
 #if HAVE_IPV6
     case PF_INET6:
       {
-	struct v6_pair *p = storage;
-	struct sockaddr_in6 *sinp = &p->sockaddr_in6;
-	tmp = &p->addrinfo;
+        struct v6_pair *p = storage;
+        struct sockaddr_in6 *sinp = &p->sockaddr_in6;
+        tmp = &p->addrinfo;
 
-	if (port)
-	  sinp->sin6_port = port;
+        if (port)
+          sinp->sin6_port = port;
 
-	if (he->h_length != sizeof (sinp->sin6_addr))
-	  {
-	    free (storage);
-	    return EAI_SYSTEM; /* FIXME: Better return code?  Set errno? */
-	  }
+        if (he->h_length != sizeof (sinp->sin6_addr))
+          {
+            free (storage);
+            return EAI_SYSTEM; /* FIXME: Better return code?  Set errno? */
+          }
 
-	memcpy (&sinp->sin6_addr, he->h_addr_list[0], sizeof sinp->sin6_addr);
+        memcpy (&sinp->sin6_addr, he->h_addr_list[0], sizeof sinp->sin6_addr);
 
-	tmp->ai_addr = (struct sockaddr *) sinp;
-	tmp->ai_addrlen = sizeof *sinp;
+        tmp->ai_addr = (struct sockaddr *) sinp;
+        tmp->ai_addrlen = sizeof *sinp;
       }
       break;
 #endif
@@ -254,23 +257,23 @@ getaddrinfo (const char *restrict nodename,
 #if HAVE_IPV4
     case PF_INET:
       {
-	struct v4_pair *p = storage;
-	struct sockaddr_in *sinp = &p->sockaddr_in;
-	tmp = &p->addrinfo;
+        struct v4_pair *p = storage;
+        struct sockaddr_in *sinp = &p->sockaddr_in;
+        tmp = &p->addrinfo;
 
-	if (port)
-	  sinp->sin_port = port;
+        if (port)
+          sinp->sin_port = port;
 
-	if (he->h_length != sizeof (sinp->sin_addr))
-	  {
-	    free (storage);
-	    return EAI_SYSTEM; /* FIXME: Better return code?  Set errno? */
-	  }
+        if (he->h_length != sizeof (sinp->sin_addr))
+          {
+            free (storage);
+            return EAI_SYSTEM; /* FIXME: Better return code?  Set errno? */
+          }
 
-	memcpy (&sinp->sin_addr, he->h_addr_list[0], sizeof sinp->sin_addr);
+        memcpy (&sinp->sin_addr, he->h_addr_list[0], sizeof sinp->sin_addr);
 
-	tmp->ai_addr = (struct sockaddr *) sinp;
-	tmp->ai_addrlen = sizeof *sinp;
+        tmp->ai_addr = (struct sockaddr *) sinp;
+        tmp->ai_addrlen = sizeof *sinp;
       }
       break;
 #endif
@@ -284,16 +287,16 @@ getaddrinfo (const char *restrict nodename,
     {
       const char *cn;
       if (he->h_name)
-	cn = he->h_name;
+        cn = he->h_name;
       else
-	cn = nodename;
+        cn = nodename;
 
       tmp->ai_canonname = strdup (cn);
       if (!tmp->ai_canonname)
-	{
-	  free (storage);
-	  return EAI_MEMORY;
-	}
+        {
+          free (storage);
+          return EAI_MEMORY;
+        }
     }
 
   tmp->ai_protocol = (hints) ? hints->ai_protocol : 0;
@@ -349,14 +352,14 @@ freeaddrinfo (struct addrinfo *ai)
 }
 
 int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen,
-		char *restrict node, socklen_t nodelen,
-		char *restrict service, socklen_t servicelen,
-		int flags)
+                char *restrict node, socklen_t nodelen,
+                char *restrict service, socklen_t servicelen,
+                int flags)
 {
 #ifdef WIN32_NATIVE
   if (use_win32_p ())
     return getnameinfo_ptr (sa, salen, node, nodelen,
-			    service, servicelen, flags);
+                            service, servicelen, flags);
 #endif
 
   /* FIXME: Support other flags. */
@@ -373,13 +376,13 @@ int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen,
 #if HAVE_IPV4
     case AF_INET:
       if (salen < sizeof (struct sockaddr_in))
-	return EAI_FAMILY;
+        return EAI_FAMILY;
       break;
 #endif
 #if HAVE_IPV6
     case AF_INET6:
       if (salen < sizeof (struct sockaddr_in6))
-	return EAI_FAMILY;
+        return EAI_FAMILY;
       break;
 #endif
     default:
@@ -389,28 +392,28 @@ int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen,
   if (node && nodelen > 0 && flags & NI_NUMERICHOST)
     {
       switch (sa->sa_family)
-	{
+        {
 #if HAVE_IPV4
-	case AF_INET:
-	  if (!inet_ntop (AF_INET,
-			  &(((const struct sockaddr_in *) sa)->sin_addr),
-			  node, nodelen))
-	    return EAI_SYSTEM;
-	  break;
+        case AF_INET:
+          if (!inet_ntop (AF_INET,
+                          &(((const struct sockaddr_in *) sa)->sin_addr),
+                          node, nodelen))
+            return EAI_SYSTEM;
+          break;
 #endif
 
 #if HAVE_IPV6
-	case AF_INET6:
-	  if (!inet_ntop (AF_INET6,
-			  &(((const struct sockaddr_in6 *) sa)->sin6_addr),
-			  node, nodelen))
-	    return EAI_SYSTEM;
-	  break;
+        case AF_INET6:
+          if (!inet_ntop (AF_INET6,
+                          &(((const struct sockaddr_in6 *) sa)->sin6_addr),
+                          node, nodelen))
+            return EAI_SYSTEM;
+          break;
 #endif
 
-	default:
-	  return EAI_FAMILY;
-	}
+        default:
+          return EAI_FAMILY;
+        }
     }
 
   if (service && servicelen > 0 && flags & NI_NUMERICSERV)
@@ -422,13 +425,13 @@ int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen,
 #if HAVE_IPV6
       case AF_INET6:
 #endif
-	{
-	  unsigned short int port
-	    = ntohs (((const struct sockaddr_in *) sa)->sin_port);
-	  if (servicelen <= snprintf (service, servicelen, "%u", port))
-	    return EAI_OVERFLOW;
-	}
-	break;
+        {
+          unsigned short int port
+            = ntohs (((const struct sockaddr_in *) sa)->sin_port);
+          if (servicelen <= snprintf (service, servicelen, "%u", port))
+            return EAI_OVERFLOW;
+        }
+        break;
       }
 
   return 0;
diff --git a/libmissing/getlogin_r.c b/libmissing/getlogin_r.c
index 5123de3..17b5a63 100644
--- a/libmissing/getlogin_r.c
+++ b/libmissing/getlogin_r.c
@@ -1,6 +1,6 @@
 /* Provide a working getlogin_r for systems which lack it.
 
-   Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/libmissing/getpagesize.c b/libmissing/getpagesize.c
deleted file mode 100644
index 82238df..0000000
--- a/libmissing/getpagesize.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/* getpagesize emulation for systems where it cannot be done in a C macro.
-
-   Copyright (C) 2007 Free Software Foundation, Inc.
-
-   This program is free software: you can redistribute it and/or modify
-   it under the terms of the GNU Lesser General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-/* Written by Bruno Haible and Martin Lambers.  */
-
-#include <config.h>
-
-/* Specification. */
-#include <unistd.h>
-
-/* This implementation is only for native Win32 systems.  */
-#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-
-# define WIN32_LEAN_AND_MEAN
-# include <windows.h>
-
-int
-getpagesize (void)
-{
-  SYSTEM_INFO system_info;
-  GetSystemInfo (&system_info);
-  return system_info.dwPageSize;
-}
-
-#endif
diff --git a/libmissing/getpeername.c b/libmissing/getpeername.c
index a54263e..efb78a0 100644
--- a/libmissing/getpeername.c
+++ b/libmissing/getpeername.c
@@ -1,6 +1,6 @@
 /* getpeername.c --- wrappers for Windows getpeername function
 
-   Copyright (C) 2008 Free Software Foundation, Inc.
+   Copyright (C) 2008, 2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/libmissing/gettext.h b/libmissing/gettext.h
index 72c8727..3d7d08c 100644
--- a/libmissing/gettext.h
+++ b/libmissing/gettext.h
@@ -140,8 +140,8 @@ inline
 #endif
 static const char *
 pgettext_aux (const char *domain,
-	      const char *msg_ctxt_id, const char *msgid,
-	      int category)
+              const char *msg_ctxt_id, const char *msgid,
+              int category)
 {
   const char *translation = dcgettext (domain, msg_ctxt_id, category);
   if (translation == msg_ctxt_id)
@@ -159,9 +159,9 @@ inline
 #endif
 static const char *
 npgettext_aux (const char *domain,
-	       const char *msg_ctxt_id, const char *msgid,
-	       const char *msgid_plural, unsigned long int n,
-	       int category)
+               const char *msg_ctxt_id, const char *msgid,
+               const char *msgid_plural, unsigned long int n,
+               int category)
 {
   const char *translation =
     dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
@@ -199,8 +199,8 @@ inline
 #endif
 static const char *
 dcpgettext_expr (const char *domain,
-		 const char *msgctxt, const char *msgid,
-		 int category)
+                 const char *msgctxt, const char *msgid,
+                 int category)
 {
   size_t msgctxt_len = strlen (msgctxt) + 1;
   size_t msgid_len = strlen (msgid) + 1;
@@ -222,10 +222,10 @@ dcpgettext_expr (const char *domain,
       translation = dcgettext (domain, msg_ctxt_id, category);
 #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
       if (msg_ctxt_id != buf)
-	free (msg_ctxt_id);
+        free (msg_ctxt_id);
 #endif
       if (translation != msg_ctxt_id)
-	return translation;
+        return translation;
     }
   return msgid;
 }
@@ -244,9 +244,9 @@ inline
 #endif
 static const char *
 dcnpgettext_expr (const char *domain,
-		  const char *msgctxt, const char *msgid,
-		  const char *msgid_plural, unsigned long int n,
-		  int category)
+                  const char *msgctxt, const char *msgid,
+                  const char *msgid_plural, unsigned long int n,
+                  int category)
 {
   size_t msgctxt_len = strlen (msgctxt) + 1;
   size_t msgid_len = strlen (msgid) + 1;
@@ -268,10 +268,10 @@ dcnpgettext_expr (const char *domain,
       translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
 #if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
       if (msg_ctxt_id != buf)
-	free (msg_ctxt_id);
+        free (msg_ctxt_id);
 #endif
       if (!(translation == msg_ctxt_id || translation == msgid_plural))
-	return translation;
+        return translation;
     }
   return (n == 1 ? msgid : msgid_plural);
 }
diff --git a/libmissing/glob-libc.h b/libmissing/glob-libc.h
index 26a131a..377df01 100644
--- a/libmissing/glob-libc.h
+++ b/libmissing/glob-libc.h
@@ -1,23 +1,21 @@
-/* Copyright (C) 1991,92,95-98,2000,2001,2004-2007 Free Software Foundation, Inc.
+/* Copyright (C) 1991,92,95-98,2000,2001,2004-2007, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
 
-   The GNU C Library is distributed in the hope that it will be useful,
+   This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
 
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef	_GLOB_H
-#define	_GLOB_H	1
+#ifndef _GLOB_H
+#define _GLOB_H 1
 
 #ifndef __GLOB_GNULIB
 # include <sys/cdefs.h>
@@ -61,39 +59,39 @@ typedef __SIZE_TYPE__ size_t;
 #endif
 
 /* Bits set in the FLAGS argument to `glob'.  */
-#define	GLOB_ERR	(1 << 0)/* Return on read errors.  */
-#define	GLOB_MARK	(1 << 1)/* Append a slash to each name.  */
-#define	GLOB_NOSORT	(1 << 2)/* Don't sort the names.  */
-#define	GLOB_DOOFFS	(1 << 3)/* Insert PGLOB->gl_offs NULLs.  */
-#define	GLOB_NOCHECK	(1 << 4)/* If nothing matches, return the pattern.  */
-#define	GLOB_APPEND	(1 << 5)/* Append to results of a previous call.  */
-#define	GLOB_NOESCAPE	(1 << 6)/* Backslashes don't quote metacharacters.  */
-#define	GLOB_PERIOD	(1 << 7)/* Leading `.' can be matched by metachars.  */
+#define GLOB_ERR        (1 << 0)/* Return on read errors.  */
+#define GLOB_MARK       (1 << 1)/* Append a slash to each name.  */
+#define GLOB_NOSORT     (1 << 2)/* Don't sort the names.  */
+#define GLOB_DOOFFS     (1 << 3)/* Insert PGLOB->gl_offs NULLs.  */
+#define GLOB_NOCHECK    (1 << 4)/* If nothing matches, return the pattern.  */
+#define GLOB_APPEND     (1 << 5)/* Append to results of a previous call.  */
+#define GLOB_NOESCAPE   (1 << 6)/* Backslashes don't quote metacharacters.  */
+#define GLOB_PERIOD     (1 << 7)/* Leading `.' can be matched by metachars.  */
 
 #if !defined __USE_POSIX2 || defined __USE_BSD || defined __USE_GNU
-# define GLOB_MAGCHAR	 (1 << 8)/* Set in gl_flags if any metachars seen.  */
+# define GLOB_MAGCHAR    (1 << 8)/* Set in gl_flags if any metachars seen.  */
 # define GLOB_ALTDIRFUNC (1 << 9)/* Use gl_opendir et al functions.  */
-# define GLOB_BRACE	 (1 << 10)/* Expand "{a,b}" to "a" "b".  */
-# define GLOB_NOMAGIC	 (1 << 11)/* If no magic chars, return the pattern.  */
-# define GLOB_TILDE	 (1 << 12)/* Expand ~user and ~ to home directories. */
-# define GLOB_ONLYDIR	 (1 << 13)/* Match only directories.  */
+# define GLOB_BRACE      (1 << 10)/* Expand "{a,b}" to "a" "b".  */
+# define GLOB_NOMAGIC    (1 << 11)/* If no magic chars, return the pattern.  */
+# define GLOB_TILDE      (1 << 12)/* Expand ~user and ~ to home directories. */
+# define GLOB_ONLYDIR    (1 << 13)/* Match only directories.  */
 # define GLOB_TILDE_CHECK (1 << 14)/* Like GLOB_TILDE but return an error
-				      if the user name is not available.  */
-# define __GLOB_FLAGS	(GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \
-			 GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND|     \
-			 GLOB_PERIOD|GLOB_ALTDIRFUNC|GLOB_BRACE|     \
-			 GLOB_NOMAGIC|GLOB_TILDE|GLOB_ONLYDIR|GLOB_TILDE_CHECK)
+                                      if the user name is not available.  */
+# define __GLOB_FLAGS   (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \
+                         GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND|     \
+                         GLOB_PERIOD|GLOB_ALTDIRFUNC|GLOB_BRACE|     \
+                         GLOB_NOMAGIC|GLOB_TILDE|GLOB_ONLYDIR|GLOB_TILDE_CHECK)
 #else
-# define __GLOB_FLAGS	(GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \
-			 GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND|     \
-			 GLOB_PERIOD)
+# define __GLOB_FLAGS   (GLOB_ERR|GLOB_MARK|GLOB_NOSORT|GLOB_DOOFFS| \
+                         GLOB_NOESCAPE|GLOB_NOCHECK|GLOB_APPEND|     \
+                         GLOB_PERIOD)
 #endif
 
 /* Error returns from `glob'.  */
-#define	GLOB_NOSPACE	1	/* Ran out of memory.  */
-#define	GLOB_ABORTED	2	/* Read error.  */
-#define	GLOB_NOMATCH	3	/* No matches found.  */
-#define GLOB_NOSYS	4	/* Not implemented.  */
+#define GLOB_NOSPACE    1       /* Ran out of memory.  */
+#define GLOB_ABORTED    2       /* Read error.  */
+#define GLOB_NOMATCH    3       /* No matches found.  */
+#define GLOB_NOSYS      4       /* Not implemented.  */
 #ifdef __USE_GNU
 /* Previous versions of this file defined GLOB_ABEND instead of
    GLOB_ABORTED.  Provide a compatibility definition here.  */
@@ -106,10 +104,10 @@ struct stat;
 #endif
 typedef struct
   {
-    __size_t gl_pathc;		/* Count of paths matched by the pattern.  */
-    char **gl_pathv;		/* List of matched pathnames.  */
-    __size_t gl_offs;		/* Slots to reserve in `gl_pathv'.  */
-    int gl_flags;		/* Set to FLAGS, maybe | GLOB_MAGCHAR.  */
+    __size_t gl_pathc;          /* Count of paths matched by the pattern.  */
+    char **gl_pathv;            /* List of matched pathnames.  */
+    __size_t gl_offs;           /* Slots to reserve in `gl_pathv'.  */
+    int gl_flags;               /* Set to FLAGS, maybe | GLOB_MAGCHAR.  */
 
     /* If the GLOB_ALTDIRFUNC flag is set, the following functions
        are used instead of the normal file access functions.  */
@@ -174,26 +172,27 @@ typedef struct
    Otherwise, `glob' returns zero.  */
 #if !defined __USE_FILE_OFFSET64 || __GNUC__ < 2 || defined __GLOB_GNULIB
 extern int glob (const char *_Restrict_ __pattern, int __flags,
-		 int (*__errfunc) (const char *, int),
-		 glob_t *_Restrict_ __pglob) __THROW;
+                 int (*__errfunc) (const char *, int),
+                 glob_t *_Restrict_ __pglob) __THROW _GL_ARG_NONNULL ((1, 4));
 
 /* Free storage allocated in PGLOB by a previous `glob' call.  */
-extern void globfree (glob_t *__pglob) __THROW;
+extern void globfree (glob_t *__pglob) __THROW _GL_ARG_NONNULL ((1));
 #else
 extern int __REDIRECT_NTH (glob, (const char *_Restrict_ __pattern,
-				  int __flags,
-				  int (*__errfunc) (const char *, int),
-				  glob_t *_Restrict_ __pglob), glob64);
+                                  int __flags,
+                                  int (*__errfunc) (const char *, int),
+                                  glob_t *_Restrict_ __pglob), glob64);
 
 extern void __REDIRECT_NTH (globfree, (glob_t *__pglob), globfree64);
 #endif
 
 #if defined __USE_LARGEFILE64 && !defined __GLOB_GNULIB
 extern int glob64 (const char *_Restrict_ __pattern, int __flags,
-		   int (*__errfunc) (const char *, int),
-		   glob64_t *_Restrict_ __pglob) __THROW;
+                   int (*__errfunc) (const char *, int),
+                   glob64_t *_Restrict_ __pglob)
+     __THROW _GL_ARG_NONNULL ((1, 4));
 
-extern void globfree64 (glob64_t *__pglob) __THROW;
+extern void globfree64 (glob64_t *__pglob) __THROW _GL_ARG_NONNULL ((1));
 #endif
 
 
@@ -203,7 +202,8 @@ extern void globfree64 (glob64_t *__pglob) __THROW;
 
    This function is not part of the interface specified by POSIX.2
    but several programs want to use it.  */
-extern int glob_pattern_p (const char *__pattern, int __quote) __THROW;
+extern int glob_pattern_p (const char *__pattern, int __quote)
+     __THROW _GL_ARG_NONNULL ((1));
 #endif
 
 __END_DECLS
diff --git a/libmissing/glob.c b/libmissing/glob.c
index 40cc9b3..f5c3d67 100644
--- a/libmissing/glob.c
+++ b/libmissing/glob.c
@@ -1,26 +1,28 @@
-/* Copyright (C) 1991-2002, 2003, 2004, 2005, 2006, 2007, 2008
+/* Copyright (C) 1991-2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
 
-   The GNU C Library is distributed in the hope that it will be useful,
+   This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
 
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #ifndef _LIBC
 # include <config.h>
 #endif
 
+/* Don't use __attribute__ __nonnull__ in this compilation unit.  Otherwise gcc
+   optimizes away the pattern == NULL || pglob == NULL tests below.  */
+#define _GL_ARG_NONNULL(params)
+
 #include <glob.h>
 
 #include <errno.h>
@@ -34,7 +36,7 @@
 
 #include <stdbool.h>
 
-#include <stdio.h>		/* Needed on stupid SunOS for assert.  */
+#include <stdio.h>              /* Needed on stupid SunOS for assert.  */
 
 #if !defined _LIBC || !defined GLOB_ONLY_P
 
@@ -69,20 +71,20 @@
    HAVE_STRUCT_DIRENT_D_TYPE plays the same role in GNULIB.  */
 #if defined _DIRENT_HAVE_D_TYPE || defined HAVE_STRUCT_DIRENT_D_TYPE
 /* True if the directory entry D must be of type T.  */
-# define DIRENT_MUST_BE(d, t)	((d)->d_type == (t))
+# define DIRENT_MUST_BE(d, t)   ((d)->d_type == (t))
 
 /* True if the directory entry D might be a symbolic link.  */
 # define DIRENT_MIGHT_BE_SYMLINK(d) \
     ((d)->d_type == DT_UNKNOWN || (d)->d_type == DT_LNK)
 
 /* True if the directory entry D might be a directory.  */
-# define DIRENT_MIGHT_BE_DIR(d)	 \
+# define DIRENT_MIGHT_BE_DIR(d)  \
     ((d)->d_type == DT_DIR || DIRENT_MIGHT_BE_SYMLINK (d))
 
 #else /* !HAVE_D_TYPE */
-# define DIRENT_MUST_BE(d, t)		false
-# define DIRENT_MIGHT_BE_SYMLINK(d)	true
-# define DIRENT_MIGHT_BE_DIR(d)		true
+# define DIRENT_MUST_BE(d, t)           false
+# define DIRENT_MIGHT_BE_SYMLINK(d)     true
+# define DIRENT_MIGHT_BE_DIR(d)         true
 #endif /* HAVE_D_TYPE */
 
 /* If the system has the `struct dirent64' type we use it internally.  */
@@ -102,8 +104,8 @@
 # endif
 
 # define CONVERT_DIRENT_DIRENT64(d64, d32) \
-  memcpy ((d64)->d_name, (d32)->d_name, _D_EXACT_NAMLEN (d32) + 1);	      \
-  CONVERT_D_INO (d64, d32)						      \
+  memcpy ((d64)->d_name, (d32)->d_name, _D_EXACT_NAMLEN (d32) + 1);           \
+  CONVERT_D_INO (d64, d32)                                                    \
   CONVERT_D_TYPE (d64, d32)
 #endif
 
@@ -139,29 +141,29 @@
 # ifndef __stat64
 #  define __stat64(fname, buf) __xstat64 (_STAT_VER, fname, buf)
 # endif
-# define struct_stat64		struct stat64
+# define struct_stat64          struct stat64
 #else /* !_LIBC */
-# define __stat64(fname, buf)	stat (fname, buf)
+# define __stat64(fname, buf)   stat (fname, buf)
 # define __fxstatat64(_, d, f, st, flag) fstatat (d, f, st, flag)
-# define struct_stat64		struct stat
-# define __stat(fname, buf)	stat (fname, buf)
-# define __alloca		alloca
-# define __readdir		readdir
-# define __readdir64		readdir64
-# define __glob_pattern_p	glob_pattern_p
+# define struct_stat64          struct stat
+# define __stat(fname, buf)     stat (fname, buf)
+# define __alloca               alloca
+# define __readdir              readdir
+# define __readdir64            readdir64
+# define __glob_pattern_p       glob_pattern_p
 #endif /* _LIBC */
 
 #include <fnmatch.h>
 
 #ifdef _SC_GETPW_R_SIZE_MAX
-# define GETPW_R_SIZE_MAX()	sysconf (_SC_GETPW_R_SIZE_MAX)
+# define GETPW_R_SIZE_MAX()     sysconf (_SC_GETPW_R_SIZE_MAX)
 #else
-# define GETPW_R_SIZE_MAX()	(-1)
+# define GETPW_R_SIZE_MAX()     (-1)
 #endif
 #ifdef _SC_LOGIN_NAME_MAX
-# define GET_LOGIN_NAME_MAX()	sysconf (_SC_LOGIN_NAME_MAX)
+# define GET_LOGIN_NAME_MAX()   sysconf (_SC_LOGIN_NAME_MAX)
 #else
-# define GET_LOGIN_NAME_MAX()	(-1)
+# define GET_LOGIN_NAME_MAX()   (-1)
 #endif
 
 static const char *next_brace_sub (const char *begin, int flags) __THROW;
@@ -186,7 +188,10 @@ static const char *next_brace_sub (const char *begin, int flags) __THROW;
 
 #ifndef _LIBC
 /* The results of opendir() in this file are not used with dirfd and fchdir,
-   therefore save some unnecessary work in fchdir.c.  */
+   and we do not leak fds to any single-threaded code that could use stdio,
+   therefore save some unnecessary recursion in fchdir.c and opendir_safer.c.
+   FIXME - if the kernel ever adds support for multi-thread safety for
+   avoiding standard fds, then we should use opendir_safer.  */
 # undef opendir
 # undef closedir
 
@@ -203,8 +208,8 @@ static const char *next_brace_sub (const char *begin, int flags) __THROW;
 #endif
 
 static int glob_in_dir (const char *pattern, const char *directory,
-			int flags, int (*errfunc) (const char *, int),
-			glob_t *pglob);
+                        int flags, int (*errfunc) (const char *, int),
+                        glob_t *pglob);
 extern int __glob_pattern_type (const char *pattern, int quote)
     attribute_hidden;
 
@@ -221,17 +226,17 @@ next_brace_sub (const char *cp, int flags)
   while (*cp != '\0')
     if ((flags & GLOB_NOESCAPE) == 0 && *cp == '\\')
       {
-	if (*++cp == '\0')
-	  break;
-	++cp;
+        if (*++cp == '\0')
+          break;
+        ++cp;
       }
     else
       {
-	if ((*cp == '}' && depth-- == 0) || (*cp == ',' && depth == 0))
-	  break;
+        if ((*cp == '}' && depth-- == 0) || (*cp == ',' && depth == 0))
+          break;
 
-	if (*cp++ == '{')
-	  depth++;
+        if (*cp++ == '{')
+          depth++;
       }
 
   return *cp != '\0' ? cp : NULL;
@@ -282,145 +287,145 @@ glob (pattern, flags, errfunc, pglob)
       const char *begin;
 
       if (flags & GLOB_NOESCAPE)
-	begin = strchr (pattern, '{');
+        begin = strchr (pattern, '{');
       else
-	{
-	  begin = pattern;
-	  while (1)
-	    {
-	      if (*begin == '\0')
-		{
-		  begin = NULL;
-		  break;
-		}
-
-	      if (*begin == '\\' && begin[1] != '\0')
-		++begin;
-	      else if (*begin == '{')
-		break;
-
-	      ++begin;
-	    }
-	}
+        {
+          begin = pattern;
+          while (1)
+            {
+              if (*begin == '\0')
+                {
+                  begin = NULL;
+                  break;
+                }
+
+              if (*begin == '\\' && begin[1] != '\0')
+                ++begin;
+              else if (*begin == '{')
+                break;
+
+              ++begin;
+            }
+        }
 
       if (begin != NULL)
-	{
-	  /* Allocate working buffer large enough for our work.  Note that
-	    we have at least an opening and closing brace.  */
-	  size_t firstc;
-	  char *alt_start;
-	  const char *p;
-	  const char *next;
-	  const char *rest;
-	  size_t rest_len;
+        {
+          /* Allocate working buffer large enough for our work.  Note that
+            we have at least an opening and closing brace.  */
+          size_t firstc;
+          char *alt_start;
+          const char *p;
+          const char *next;
+          const char *rest;
+          size_t rest_len;
 #ifdef __GNUC__
-	  char onealt[strlen (pattern) - 1];
+          char onealt[strlen (pattern) - 1];
 #else
-	  char *onealt = malloc (strlen (pattern) - 1);
-	  if (onealt == NULL)
-	    {
-	      if (!(flags & GLOB_APPEND))
-		{
-		  pglob->gl_pathc = 0;
-		  pglob->gl_pathv = NULL;
-		}
-	      return GLOB_NOSPACE;
-	    }
+          char *onealt = malloc (strlen (pattern) - 1);
+          if (onealt == NULL)
+            {
+              if (!(flags & GLOB_APPEND))
+                {
+                  pglob->gl_pathc = 0;
+                  pglob->gl_pathv = NULL;
+                }
+              return GLOB_NOSPACE;
+            }
 #endif
 
-	  /* We know the prefix for all sub-patterns.  */
-	  alt_start = mempcpy (onealt, pattern, begin - pattern);
+          /* We know the prefix for all sub-patterns.  */
+          alt_start = mempcpy (onealt, pattern, begin - pattern);
 
-	  /* Find the first sub-pattern and at the same time find the
-	     rest after the closing brace.  */
-	  next = next_brace_sub (begin + 1, flags);
-	  if (next == NULL)
-	    {
-	      /* It is an invalid expression.  */
+          /* Find the first sub-pattern and at the same time find the
+             rest after the closing brace.  */
+          next = next_brace_sub (begin + 1, flags);
+          if (next == NULL)
+            {
+              /* It is an invalid expression.  */
 #ifndef __GNUC__
-	      free (onealt);
+              free (onealt);
 #endif
-	      return glob (pattern, flags & ~GLOB_BRACE, errfunc, pglob);
-	    }
-
-	  /* Now find the end of the whole brace expression.  */
-	  rest = next;
-	  while (*rest != '}')
-	    {
-	      rest = next_brace_sub (rest + 1, flags);
-	      if (rest == NULL)
-		{
-		  /* It is an invalid expression.  */
+              return glob (pattern, flags & ~GLOB_BRACE, errfunc, pglob);
+            }
+
+          /* Now find the end of the whole brace expression.  */
+          rest = next;
+          while (*rest != '}')
+            {
+              rest = next_brace_sub (rest + 1, flags);
+              if (rest == NULL)
+                {
+                  /* It is an invalid expression.  */
 #ifndef __GNUC__
-		  free (onealt);
+                  free (onealt);
 #endif
-		  return glob (pattern, flags & ~GLOB_BRACE, errfunc, pglob);
-		}
-	    }
-	  /* Please note that we now can be sure the brace expression
-	     is well-formed.  */
-	  rest_len = strlen (++rest) + 1;
-
-	  /* We have a brace expression.  BEGIN points to the opening {,
-	     NEXT points past the terminator of the first element, and END
-	     points past the final }.  We will accumulate result names from
-	     recursive runs for each brace alternative in the buffer using
-	     GLOB_APPEND.  */
-
-	  if (!(flags & GLOB_APPEND))
-	    {
-	      /* This call is to set a new vector, so clear out the
-		 vector so we can append to it.  */
-	      pglob->gl_pathc = 0;
-	      pglob->gl_pathv = NULL;
-	    }
-	  firstc = pglob->gl_pathc;
-
-	  p = begin + 1;
-	  while (1)
-	    {
-	      int result;
-
-	      /* Construct the new glob expression.  */
-	      mempcpy (mempcpy (alt_start, p, next - p), rest, rest_len);
-
-	      result = glob (onealt,
-			     ((flags & ~(GLOB_NOCHECK | GLOB_NOMAGIC))
-			      | GLOB_APPEND), errfunc, pglob);
-
-	      /* If we got an error, return it.  */
-	      if (result && result != GLOB_NOMATCH)
-		{
+                  return glob (pattern, flags & ~GLOB_BRACE, errfunc, pglob);
+                }
+            }
+          /* Please note that we now can be sure the brace expression
+             is well-formed.  */
+          rest_len = strlen (++rest) + 1;
+
+          /* We have a brace expression.  BEGIN points to the opening {,
+             NEXT points past the terminator of the first element, and END
+             points past the final }.  We will accumulate result names from
+             recursive runs for each brace alternative in the buffer using
+             GLOB_APPEND.  */
+
+          if (!(flags & GLOB_APPEND))
+            {
+              /* This call is to set a new vector, so clear out the
+                 vector so we can append to it.  */
+              pglob->gl_pathc = 0;
+              pglob->gl_pathv = NULL;
+            }
+          firstc = pglob->gl_pathc;
+
+          p = begin + 1;
+          while (1)
+            {
+              int result;
+
+              /* Construct the new glob expression.  */
+              mempcpy (mempcpy (alt_start, p, next - p), rest, rest_len);
+
+              result = glob (onealt,
+                             ((flags & ~(GLOB_NOCHECK | GLOB_NOMAGIC))
+                              | GLOB_APPEND), errfunc, pglob);
+
+              /* If we got an error, return it.  */
+              if (result && result != GLOB_NOMATCH)
+                {
 #ifndef __GNUC__
-		  free (onealt);
+                  free (onealt);
 #endif
-		  if (!(flags & GLOB_APPEND))
-		    {
-		      globfree (pglob);
-		      pglob->gl_pathc = 0;
-		    }
-		  return result;
-		}
-
-	      if (*next == '}')
-		/* We saw the last entry.  */
-		break;
-
-	      p = next + 1;
-	      next = next_brace_sub (p, flags);
-	      assert (next != NULL);
-	    }
+                  if (!(flags & GLOB_APPEND))
+                    {
+                      globfree (pglob);
+                      pglob->gl_pathc = 0;
+                    }
+                  return result;
+                }
+
+              if (*next == '}')
+                /* We saw the last entry.  */
+                break;
+
+              p = next + 1;
+              next = next_brace_sub (p, flags);
+              assert (next != NULL);
+            }
 
 #ifndef __GNUC__
-	  free (onealt);
+          free (onealt);
 #endif
 
-	  if (pglob->gl_pathc != firstc)
-	    /* We found some entries.  */
-	    return 0;
-	  else if (!(flags & (GLOB_NOCHECK|GLOB_NOMAGIC)))
-	    return GLOB_NOMATCH;
-	}
+          if (pglob->gl_pathc != firstc)
+            /* We found some entries.  */
+            return 0;
+          else if (!(flags & (GLOB_NOCHECK|GLOB_NOMAGIC)))
+            return GLOB_NOMATCH;
+        }
     }
 
   /* Find the filename.  */
@@ -437,31 +442,31 @@ glob (pattern, flags, errfunc, pglob)
   if (filename == NULL)
     {
       /* This can mean two things: a simple name or "~name".  The latter
-	 case is nothing but a notation for a directory.  */
+         case is nothing but a notation for a directory.  */
       if ((flags & (GLOB_TILDE|GLOB_TILDE_CHECK)) && pattern[0] == '~')
-	{
-	  dirname = pattern;
-	  dirlen = strlen (pattern);
-
-	  /* Set FILENAME to NULL as a special flag.  This is ugly but
-	     other solutions would require much more code.  We test for
-	     this special case below.  */
-	  filename = NULL;
-	}
+        {
+          dirname = pattern;
+          dirlen = strlen (pattern);
+
+          /* Set FILENAME to NULL as a special flag.  This is ugly but
+             other solutions would require much more code.  We test for
+             this special case below.  */
+          filename = NULL;
+        }
       else
-	{
-	  filename = pattern;
+        {
+          filename = pattern;
 #ifdef _AMIGA
-	  dirname = "";
+          dirname = "";
 #else
-	  dirname = ".";
+          dirname = ".";
 #endif
-	  dirlen = 0;
-	}
+          dirlen = 0;
+        }
     }
   else if (filename == pattern
-	   || (filename == pattern + 1 && pattern[0] == '\\'
-	       && (flags & GLOB_NOESCAPE) == 0))
+           || (filename == pattern + 1 && pattern[0] == '\\'
+               && (flags & GLOB_NOESCAPE) == 0))
     {
       /* "/pattern" or "\\/pattern".  */
       dirname = "/";
@@ -474,21 +479,21 @@ glob (pattern, flags, errfunc, pglob)
       dirlen = filename - pattern;
 #if defined __MSDOS__ || defined WINDOWS32
       if (*filename == ':'
-	  || (filename > pattern + 1 && filename[-1] == ':'))
-	{
-	  char *drive_spec;
-
-	  ++dirlen;
-	  drive_spec = __alloca (dirlen + 1);
-	  *((char *) mempcpy (drive_spec, pattern, dirlen)) = '\0';
-	  /* For now, disallow wildcards in the drive spec, to
-	     prevent infinite recursion in glob.  */
-	  if (__glob_pattern_p (drive_spec, !(flags & GLOB_NOESCAPE)))
-	    return GLOB_NOMATCH;
-	  /* If this is "d:pattern", we need to copy `:' to DIRNAME
-	     as well.  If it's "d:/pattern", don't remove the slash
-	     from "d:/", since "d:" and "d:/" are not the same.*/
-	}
+          || (filename > pattern + 1 && filename[-1] == ':'))
+        {
+          char *drive_spec;
+
+          ++dirlen;
+          drive_spec = __alloca (dirlen + 1);
+          *((char *) mempcpy (drive_spec, pattern, dirlen)) = '\0';
+          /* For now, disallow wildcards in the drive spec, to
+             prevent infinite recursion in glob.  */
+          if (__glob_pattern_p (drive_spec, !(flags & GLOB_NOESCAPE)))
+            return GLOB_NOMATCH;
+          /* If this is "d:pattern", we need to copy `:' to DIRNAME
+             as well.  If it's "d:/pattern", don't remove the slash
+             from "d:/", since "d:" and "d:/" are not the same.*/
+        }
 #endif
       newp = __alloca (dirlen + 1);
       *((char *) mempcpy (newp, pattern, dirlen)) = '\0';
@@ -498,41 +503,41 @@ glob (pattern, flags, errfunc, pglob)
       if (filename[0] == '\0'
 #if defined __MSDOS__ || defined WINDOWS32
           && dirname[dirlen - 1] != ':'
-	  && (dirlen < 3 || dirname[dirlen - 2] != ':'
-	      || dirname[dirlen - 1] != '/')
+          && (dirlen < 3 || dirname[dirlen - 2] != ':'
+              || dirname[dirlen - 1] != '/')
 #endif
-	  && dirlen > 1)
-	/* "pattern/".  Expand "pattern", appending slashes.  */
-	{
-	  int orig_flags = flags;
-	  int val;
-	  if (!(flags & GLOB_NOESCAPE) && dirname[dirlen - 1] == '\\')
-	    {
-	      /* "pattern\\/".  Remove the final backslash if it hasn't
-		 been quoted.  */
-	      char *p = (char *) &dirname[dirlen - 1];
-
-	      while (p > dirname && p[-1] == '\\') --p;
-	      if ((&dirname[dirlen] - p) & 1)
-		{
-		  *(char *) &dirname[--dirlen] = '\0';
-		  flags &= ~(GLOB_NOCHECK | GLOB_NOMAGIC);
-		}
-	    }
-	  val = glob (dirname, flags | GLOB_MARK, errfunc, pglob);
-	  if (val == 0)
-	    pglob->gl_flags = ((pglob->gl_flags & ~GLOB_MARK)
-			       | (flags & GLOB_MARK));
-	  else if (val == GLOB_NOMATCH && flags != orig_flags)
-	    {
-	      /* Make sure globfree (&dirs); is a nop.  */
-	      dirs.gl_pathv = NULL;
-	      flags = orig_flags;
-	      oldcount = pglob->gl_pathc + pglob->gl_offs;
-	      goto no_matches;
-	    }
-	  return val;
-	}
+          && dirlen > 1)
+        /* "pattern/".  Expand "pattern", appending slashes.  */
+        {
+          int orig_flags = flags;
+          int val;
+          if (!(flags & GLOB_NOESCAPE) && dirname[dirlen - 1] == '\\')
+            {
+              /* "pattern\\/".  Remove the final backslash if it hasn't
+                 been quoted.  */
+              char *p = (char *) &dirname[dirlen - 1];
+
+              while (p > dirname && p[-1] == '\\') --p;
+              if ((&dirname[dirlen] - p) & 1)
+                {
+                  *(char *) &dirname[--dirlen] = '\0';
+                  flags &= ~(GLOB_NOCHECK | GLOB_NOMAGIC);
+                }
+            }
+          val = glob (dirname, flags | GLOB_MARK, errfunc, pglob);
+          if (val == 0)
+            pglob->gl_flags = ((pglob->gl_flags & ~GLOB_MARK)
+                               | (flags & GLOB_MARK));
+          else if (val == GLOB_NOMATCH && flags != orig_flags)
+            {
+              /* Make sure globfree (&dirs); is a nop.  */
+              dirs.gl_pathv = NULL;
+              flags = orig_flags;
+              oldcount = pglob->gl_pathc + pglob->gl_offs;
+              goto no_matches;
+            }
+          return val;
+        }
     }
 
   if (!(flags & GLOB_APPEND))
@@ -541,15 +546,15 @@ glob (pattern, flags, errfunc, pglob)
       if (!(flags & GLOB_DOOFFS))
         pglob->gl_pathv = NULL;
       else
-	{
-	  size_t i;
-	  pglob->gl_pathv = malloc ((pglob->gl_offs + 1) * sizeof (char *));
-	  if (pglob->gl_pathv == NULL)
-	    return GLOB_NOSPACE;
-
-	  for (i = 0; i <= pglob->gl_offs; ++i)
-	    pglob->gl_pathv[i] = NULL;
-	}
+        {
+          size_t i;
+          pglob->gl_pathv = malloc ((pglob->gl_offs + 1) * sizeof (char *));
+          if (pglob->gl_pathv == NULL)
+            return GLOB_NOSPACE;
+
+          for (i = 0; i <= pglob->gl_offs; ++i)
+            pglob->gl_pathv[i] = NULL;
+        }
     }
 
   oldcount = pglob->gl_pathc + pglob->gl_offs;
@@ -557,235 +562,235 @@ glob (pattern, flags, errfunc, pglob)
   if ((flags & (GLOB_TILDE|GLOB_TILDE_CHECK)) && dirname[0] == '~')
     {
       if (dirname[1] == '\0' || dirname[1] == '/'
-	  || (!(flags & GLOB_NOESCAPE) && dirname[1] == '\\'
-	      && (dirname[2] == '\0' || dirname[2] == '/')))
-	{
-	  /* Look up home directory.  */
-	  const char *home_dir = getenv ("HOME");
+          || (!(flags & GLOB_NOESCAPE) && dirname[1] == '\\'
+              && (dirname[2] == '\0' || dirname[2] == '/')))
+        {
+          /* Look up home directory.  */
+          const char *home_dir = getenv ("HOME");
 # ifdef _AMIGA
-	  if (home_dir == NULL || home_dir[0] == '\0')
-	    home_dir = "SYS:";
+          if (home_dir == NULL || home_dir[0] == '\0')
+            home_dir = "SYS:";
 # else
 #  ifdef WINDOWS32
-	  /* Windows NT defines HOMEDRIVE and HOMEPATH.  But give preference
-	     to HOME, because the user can change HOME.  */
-	  if (home_dir == NULL || home_dir[0] == '\0')
-	    {
-	      const char *home_drive = getenv ("HOMEDRIVE");
-	      const char *home_path = getenv ("HOMEPATH");
-
-	      if (home_drive != NULL && home_path != NULL)
-		{
-		  size_t home_drive_len = strlen (home_drive);
-		  size_t home_path_len = strlen (home_path);
-		  char *mem = alloca (home_drive_len + home_path_len + 1);
-
-		  memcpy (mem, home_drive, home_drive_len);
-		  memcpy (mem + home_drive_len, home_path, home_path_len + 1);
-		  home_dir = mem;
-		}
-	      else
-		home_dir = "c:/users/default"; /* poor default */
-	    }
+          /* Windows NT defines HOMEDRIVE and HOMEPATH.  But give preference
+             to HOME, because the user can change HOME.  */
+          if (home_dir == NULL || home_dir[0] == '\0')
+            {
+              const char *home_drive = getenv ("HOMEDRIVE");
+              const char *home_path = getenv ("HOMEPATH");
+
+              if (home_drive != NULL && home_path != NULL)
+                {
+                  size_t home_drive_len = strlen (home_drive);
+                  size_t home_path_len = strlen (home_path);
+                  char *mem = alloca (home_drive_len + home_path_len + 1);
+
+                  memcpy (mem, home_drive, home_drive_len);
+                  memcpy (mem + home_drive_len, home_path, home_path_len + 1);
+                  home_dir = mem;
+                }
+              else
+                home_dir = "c:/users/default"; /* poor default */
+            }
 #  else
-	  if (home_dir == NULL || home_dir[0] == '\0')
-	    {
-	      int success;
-	      char *name;
-	      size_t buflen = GET_LOGIN_NAME_MAX () + 1;
-
-	      if (buflen == 0)
-		/* `sysconf' does not support _SC_LOGIN_NAME_MAX.  Try
-		   a moderate value.  */
-		buflen = 20;
-	      name = __alloca (buflen);
-
-	      success = getlogin_r (name, buflen) == 0;
-	      if (success)
-		{
-		  struct passwd *p;
+          if (home_dir == NULL || home_dir[0] == '\0')
+            {
+              int success;
+              char *name;
+              size_t buflen = GET_LOGIN_NAME_MAX () + 1;
+
+              if (buflen == 0)
+                /* `sysconf' does not support _SC_LOGIN_NAME_MAX.  Try
+                   a moderate value.  */
+                buflen = 20;
+              name = __alloca (buflen);
+
+              success = getlogin_r (name, buflen) == 0;
+              if (success)
+                {
+                  struct passwd *p;
 #   if defined HAVE_GETPWNAM_R || defined _LIBC
-		  long int pwbuflen = GETPW_R_SIZE_MAX ();
-		  char *pwtmpbuf;
-		  struct passwd pwbuf;
-		  int save = errno;
+                  long int pwbuflen = GETPW_R_SIZE_MAX ();
+                  char *pwtmpbuf;
+                  struct passwd pwbuf;
+                  int save = errno;
 
 #    ifndef _LIBC
-		  if (pwbuflen == -1)
-		    /* `sysconf' does not support _SC_GETPW_R_SIZE_MAX.
-		       Try a moderate value.  */
-		    pwbuflen = 1024;
+                  if (pwbuflen == -1)
+                    /* `sysconf' does not support _SC_GETPW_R_SIZE_MAX.
+                       Try a moderate value.  */
+                    pwbuflen = 1024;
 #    endif
-		  pwtmpbuf = __alloca (pwbuflen);
-
-		  while (getpwnam_r (name, &pwbuf, pwtmpbuf, pwbuflen, &p)
-			 != 0)
-		    {
-		      if (errno != ERANGE)
-			{
-			  p = NULL;
-			  break;
-			}
+                  pwtmpbuf = __alloca (pwbuflen);
+
+                  while (getpwnam_r (name, &pwbuf, pwtmpbuf, pwbuflen, &p)
+                         != 0)
+                    {
+                      if (errno != ERANGE)
+                        {
+                          p = NULL;
+                          break;
+                        }
 #    ifdef _LIBC
-		      pwtmpbuf = extend_alloca (pwtmpbuf, pwbuflen,
-						2 * pwbuflen);
+                      pwtmpbuf = extend_alloca (pwtmpbuf, pwbuflen,
+                                                2 * pwbuflen);
 #    else
-		      pwbuflen *= 2;
-		      pwtmpbuf = __alloca (pwbuflen);
+                      pwbuflen *= 2;
+                      pwtmpbuf = __alloca (pwbuflen);
 #    endif
-		      __set_errno (save);
-		    }
+                      __set_errno (save);
+                    }
 #   else
-		  p = getpwnam (name);
+                  p = getpwnam (name);
 #   endif
-		  if (p != NULL)
-		    home_dir = p->pw_dir;
-		}
-	    }
-	  if (home_dir == NULL || home_dir[0] == '\0')
-	    {
-	      if (flags & GLOB_TILDE_CHECK)
-		return GLOB_NOMATCH;
-	      else
-		home_dir = "~"; /* No luck.  */
-	    }
+                  if (p != NULL)
+                    home_dir = p->pw_dir;
+                }
+            }
+          if (home_dir == NULL || home_dir[0] == '\0')
+            {
+              if (flags & GLOB_TILDE_CHECK)
+                return GLOB_NOMATCH;
+              else
+                home_dir = "~"; /* No luck.  */
+            }
 #  endif /* WINDOWS32 */
 # endif
-	  /* Now construct the full directory.  */
-	  if (dirname[1] == '\0')
-	    {
-	      dirname = home_dir;
-	      dirlen = strlen (dirname);
-	    }
-	  else
-	    {
-	      char *newp;
-	      size_t home_len = strlen (home_dir);
-	      newp = __alloca (home_len + dirlen);
-	      mempcpy (mempcpy (newp, home_dir, home_len),
-		       &dirname[1], dirlen);
-	      dirname = newp;
-	      dirlen += home_len - 1;
-	    }
-	  dirname_modified = 1;
-	}
+          /* Now construct the full directory.  */
+          if (dirname[1] == '\0')
+            {
+              dirname = home_dir;
+              dirlen = strlen (dirname);
+            }
+          else
+            {
+              char *newp;
+              size_t home_len = strlen (home_dir);
+              newp = __alloca (home_len + dirlen);
+              mempcpy (mempcpy (newp, home_dir, home_len),
+                       &dirname[1], dirlen);
+              dirname = newp;
+              dirlen += home_len - 1;
+            }
+          dirname_modified = 1;
+        }
 # if !defined _AMIGA && !defined WINDOWS32
       else
-	{
-	  char *end_name = strchr (dirname, '/');
-	  const char *user_name;
-	  const char *home_dir;
-	  char *unescape = NULL;
-
-	  if (!(flags & GLOB_NOESCAPE))
-	    {
-	      if (end_name == NULL)
-		{
-		  unescape = strchr (dirname, '\\');
-		  if (unescape)
-		    end_name = strchr (unescape, '\0');
-		}
-	      else
-		unescape = memchr (dirname, '\\', end_name - dirname);
-	    }
-	  if (end_name == NULL)
-	    user_name = dirname + 1;
-	  else
-	    {
-	      char *newp;
-	      newp = __alloca (end_name - dirname);
-	      *((char *) mempcpy (newp, dirname + 1, end_name - dirname))
-		= '\0';
-	      if (unescape != NULL)
-		{
-		  char *p = mempcpy (newp, dirname + 1,
-				     unescape - dirname - 1);
-		  char *q = unescape;
-		  while (*q != '\0')
-		    {
-		      if (*q == '\\')
-			{
-			  if (q[1] == '\0')
-			    {
-			      /* "~fo\\o\\" unescape to user_name "foo\\",
-				 but "~fo\\o\\/" unescape to user_name
-				 "foo".  */
-			      if (filename == NULL)
-				*p++ = '\\';
-			      break;
-			    }
-			  ++q;
-			}
-		      *p++ = *q++;
-		    }
-		  *p = '\0';
-		}
-	      else
-		*((char *) mempcpy (newp, dirname + 1, end_name - dirname))
-		  = '\0';
-	      user_name = newp;
-	    }
-
-	  /* Look up specific user's home directory.  */
-	  {
-	    struct passwd *p;
+        {
+          char *end_name = strchr (dirname, '/');
+          const char *user_name;
+          const char *home_dir;
+          char *unescape = NULL;
+
+          if (!(flags & GLOB_NOESCAPE))
+            {
+              if (end_name == NULL)
+                {
+                  unescape = strchr (dirname, '\\');
+                  if (unescape)
+                    end_name = strchr (unescape, '\0');
+                }
+              else
+                unescape = memchr (dirname, '\\', end_name - dirname);
+            }
+          if (end_name == NULL)
+            user_name = dirname + 1;
+          else
+            {
+              char *newp;
+              newp = __alloca (end_name - dirname);
+              *((char *) mempcpy (newp, dirname + 1, end_name - dirname))
+                = '\0';
+              if (unescape != NULL)
+                {
+                  char *p = mempcpy (newp, dirname + 1,
+                                     unescape - dirname - 1);
+                  char *q = unescape;
+                  while (*q != '\0')
+                    {
+                      if (*q == '\\')
+                        {
+                          if (q[1] == '\0')
+                            {
+                              /* "~fo\\o\\" unescape to user_name "foo\\",
+                                 but "~fo\\o\\/" unescape to user_name
+                                 "foo".  */
+                              if (filename == NULL)
+                                *p++ = '\\';
+                              break;
+                            }
+                          ++q;
+                        }
+                      *p++ = *q++;
+                    }
+                  *p = '\0';
+                }
+              else
+                *((char *) mempcpy (newp, dirname + 1, end_name - dirname))
+                  = '\0';
+              user_name = newp;
+            }
+
+          /* Look up specific user's home directory.  */
+          {
+            struct passwd *p;
 #  if defined HAVE_GETPWNAM_R || defined _LIBC
-	    long int buflen = GETPW_R_SIZE_MAX ();
-	    char *pwtmpbuf;
-	    struct passwd pwbuf;
-	    int save = errno;
+            long int buflen = GETPW_R_SIZE_MAX ();
+            char *pwtmpbuf;
+            struct passwd pwbuf;
+            int save = errno;
 
 #   ifndef _LIBC
-	    if (buflen == -1)
-	      /* `sysconf' does not support _SC_GETPW_R_SIZE_MAX.  Try a
-		 moderate value.  */
-	      buflen = 1024;
+            if (buflen == -1)
+              /* `sysconf' does not support _SC_GETPW_R_SIZE_MAX.  Try a
+                 moderate value.  */
+              buflen = 1024;
 #   endif
-	    pwtmpbuf = __alloca (buflen);
-
-	    while (getpwnam_r (user_name, &pwbuf, pwtmpbuf, buflen, &p) != 0)
-	      {
-		if (errno != ERANGE)
-		  {
-		    p = NULL;
-		    break;
-		  }
+            pwtmpbuf = __alloca (buflen);
+
+            while (getpwnam_r (user_name, &pwbuf, pwtmpbuf, buflen, &p) != 0)
+              {
+                if (errno != ERANGE)
+                  {
+                    p = NULL;
+                    break;
+                  }
 #   ifdef _LIBC
-		pwtmpbuf = extend_alloca (pwtmpbuf, buflen, 2 * buflen);
+                pwtmpbuf = extend_alloca (pwtmpbuf, buflen, 2 * buflen);
 #   else
-		buflen *= 2;
-		pwtmpbuf = __alloca (buflen);
+                buflen *= 2;
+                pwtmpbuf = __alloca (buflen);
 #   endif
-		__set_errno (save);
-	      }
+                __set_errno (save);
+              }
 #  else
-	    p = getpwnam (user_name);
+            p = getpwnam (user_name);
 #  endif
-	    if (p != NULL)
-	      home_dir = p->pw_dir;
-	    else
-	      home_dir = NULL;
-	  }
-	  /* If we found a home directory use this.  */
-	  if (home_dir != NULL)
-	    {
-	      char *newp;
-	      size_t home_len = strlen (home_dir);
-	      size_t rest_len = end_name == NULL ? 0 : strlen (end_name);
-	      newp = __alloca (home_len + rest_len + 1);
-	      *((char *) mempcpy (mempcpy (newp, home_dir, home_len),
-				  end_name, rest_len)) = '\0';
-	      dirname = newp;
-	      dirlen = home_len + rest_len;
-	      dirname_modified = 1;
-	    }
-	  else
-	    if (flags & GLOB_TILDE_CHECK)
-	      /* We have to regard it as an error if we cannot find the
-		 home directory.  */
-	      return GLOB_NOMATCH;
-	}
-# endif	/* Not Amiga && not WINDOWS32.  */
+            if (p != NULL)
+              home_dir = p->pw_dir;
+            else
+              home_dir = NULL;
+          }
+          /* If we found a home directory use this.  */
+          if (home_dir != NULL)
+            {
+              char *newp;
+              size_t home_len = strlen (home_dir);
+              size_t rest_len = end_name == NULL ? 0 : strlen (end_name);
+              newp = __alloca (home_len + rest_len + 1);
+              *((char *) mempcpy (mempcpy (newp, home_dir, home_len),
+                                  end_name, rest_len)) = '\0';
+              dirname = newp;
+              dirlen = home_len + rest_len;
+              dirname_modified = 1;
+            }
+          else
+            if (flags & GLOB_TILDE_CHECK)
+              /* We have to regard it as an error if we cannot find the
+                 home directory.  */
+              return GLOB_NOMATCH;
+        }
+# endif /* Not Amiga && not WINDOWS32.  */
     }
 
   /* Now test whether we looked for "~" or "~NAME".  In this case we
@@ -797,48 +802,48 @@ glob (pattern, flags, errfunc, pglob)
 
       /* Return the directory if we don't check for error or if it exists.  */
       if ((flags & GLOB_NOCHECK)
-	  || (((__builtin_expect (flags & GLOB_ALTDIRFUNC, 0))
-	       ? ((*pglob->gl_stat) (dirname, &st) == 0
-		  && S_ISDIR (st.st_mode))
-	       : (__stat64 (dirname, &st64) == 0 && S_ISDIR (st64.st_mode)))))
-	{
-	  int newcount = pglob->gl_pathc + pglob->gl_offs;
-	  char **new_gl_pathv;
-
-	  new_gl_pathv
-	    = realloc (pglob->gl_pathv, (newcount + 1 + 1) * sizeof (char *));
-	  if (new_gl_pathv == NULL)
-	    {
-	    nospace:
-	      free (pglob->gl_pathv);
-	      pglob->gl_pathv = NULL;
-	      pglob->gl_pathc = 0;
-	      return GLOB_NOSPACE;
-	    }
-	  pglob->gl_pathv = new_gl_pathv;
-
-	  if (flags & GLOB_MARK)
-	    {
-	      char *p;
-	      pglob->gl_pathv[newcount] = malloc (dirlen + 2);
-	      if (pglob->gl_pathv[newcount] == NULL)
-		goto nospace;
-	      p = mempcpy (pglob->gl_pathv[newcount], dirname, dirlen);
-	      p[0] = '/';
-	      p[1] = '\0';
-	    }
-	  else
-	    {
-	      pglob->gl_pathv[newcount] = strdup (dirname);
-	      if (pglob->gl_pathv[newcount] == NULL)
-		goto nospace;
-	    }
-	  pglob->gl_pathv[++newcount] = NULL;
-	  ++pglob->gl_pathc;
-	  pglob->gl_flags = flags;
-
-	  return 0;
-	}
+          || (((__builtin_expect (flags & GLOB_ALTDIRFUNC, 0))
+               ? ((*pglob->gl_stat) (dirname, &st) == 0
+                  && S_ISDIR (st.st_mode))
+               : (__stat64 (dirname, &st64) == 0 && S_ISDIR (st64.st_mode)))))
+        {
+          int newcount = pglob->gl_pathc + pglob->gl_offs;
+          char **new_gl_pathv;
+
+          new_gl_pathv
+            = realloc (pglob->gl_pathv, (newcount + 1 + 1) * sizeof (char *));
+          if (new_gl_pathv == NULL)
+            {
+            nospace:
+              free (pglob->gl_pathv);
+              pglob->gl_pathv = NULL;
+              pglob->gl_pathc = 0;
+              return GLOB_NOSPACE;
+            }
+          pglob->gl_pathv = new_gl_pathv;
+
+          if (flags & GLOB_MARK)
+            {
+              char *p;
+              pglob->gl_pathv[newcount] = malloc (dirlen + 2);
+              if (pglob->gl_pathv[newcount] == NULL)
+                goto nospace;
+              p = mempcpy (pglob->gl_pathv[newcount], dirname, dirlen);
+              p[0] = '/';
+              p[1] = '\0';
+            }
+          else
+            {
+              pglob->gl_pathv[newcount] = strdup (dirname);
+              if (pglob->gl_pathv[newcount] == NULL)
+                goto nospace;
+            }
+          pglob->gl_pathv[++newcount] = NULL;
+          ++pglob->gl_pathc;
+          pglob->gl_flags = flags;
+
+          return 0;
+        }
 
       /* Not found.  */
       return GLOB_NOMATCH;
@@ -853,137 +858,137 @@ glob (pattern, flags, errfunc, pglob)
   if (meta & 5)
     {
       /* The directory name contains metacharacters, so we
-	 have to glob for the directory, and then glob for
-	 the pattern in each directory found.  */
+         have to glob for the directory, and then glob for
+         the pattern in each directory found.  */
       size_t i;
 
       if (!(flags & GLOB_NOESCAPE) && dirlen > 0 && dirname[dirlen - 1] == '\\')
-	{
-	  /* "foo\\/bar".  Remove the final backslash from dirname
-	     if it has not been quoted.  */
-	  char *p = (char *) &dirname[dirlen - 1];
+        {
+          /* "foo\\/bar".  Remove the final backslash from dirname
+             if it has not been quoted.  */
+          char *p = (char *) &dirname[dirlen - 1];
 
-	  while (p > dirname && p[-1] == '\\') --p;
-	  if ((&dirname[dirlen] - p) & 1)
-	    *(char *) &dirname[--dirlen] = '\0';
-	}
+          while (p > dirname && p[-1] == '\\') --p;
+          if ((&dirname[dirlen] - p) & 1)
+            *(char *) &dirname[--dirlen] = '\0';
+        }
 
       if (__builtin_expect ((flags & GLOB_ALTDIRFUNC) != 0, 0))
-	{
-	  /* Use the alternative access functions also in the recursive
-	     call.  */
-	  dirs.gl_opendir = pglob->gl_opendir;
-	  dirs.gl_readdir = pglob->gl_readdir;
-	  dirs.gl_closedir = pglob->gl_closedir;
-	  dirs.gl_stat = pglob->gl_stat;
-	  dirs.gl_lstat = pglob->gl_lstat;
-	}
+        {
+          /* Use the alternative access functions also in the recursive
+             call.  */
+          dirs.gl_opendir = pglob->gl_opendir;
+          dirs.gl_readdir = pglob->gl_readdir;
+          dirs.gl_closedir = pglob->gl_closedir;
+          dirs.gl_stat = pglob->gl_stat;
+          dirs.gl_lstat = pglob->gl_lstat;
+        }
 
       status = glob (dirname,
-		     ((flags & (GLOB_ERR | GLOB_NOESCAPE
-				| GLOB_ALTDIRFUNC))
-		      | GLOB_NOSORT | GLOB_ONLYDIR),
-		     errfunc, &dirs);
+                     ((flags & (GLOB_ERR | GLOB_NOESCAPE
+                                | GLOB_ALTDIRFUNC))
+                      | GLOB_NOSORT | GLOB_ONLYDIR),
+                     errfunc, &dirs);
       if (status != 0)
-	{
-	  if ((flags & GLOB_NOCHECK) == 0 || status != GLOB_NOMATCH)
-	    return status;
-	  goto no_matches;
-	}
+        {
+          if ((flags & GLOB_NOCHECK) == 0 || status != GLOB_NOMATCH)
+            return status;
+          goto no_matches;
+        }
 
       /* We have successfully globbed the preceding directory name.
-	 For each name we found, call glob_in_dir on it and FILENAME,
-	 appending the results to PGLOB.  */
+         For each name we found, call glob_in_dir on it and FILENAME,
+         appending the results to PGLOB.  */
       for (i = 0; i < dirs.gl_pathc; ++i)
-	{
-	  int old_pathc;
-
-#ifdef	SHELL
-	  {
-	    /* Make globbing interruptible in the bash shell. */
-	    extern int interrupt_state;
-
-	    if (interrupt_state)
-	      {
-		globfree (&dirs);
-		return GLOB_ABORTED;
-	      }
-	  }
+        {
+          int old_pathc;
+
+#ifdef SHELL
+          {
+            /* Make globbing interruptible in the bash shell. */
+            extern int interrupt_state;
+
+            if (interrupt_state)
+              {
+                globfree (&dirs);
+                return GLOB_ABORTED;
+              }
+          }
 #endif /* SHELL.  */
 
-	  old_pathc = pglob->gl_pathc;
-	  status = glob_in_dir (filename, dirs.gl_pathv[i],
-				((flags | GLOB_APPEND)
-				 & ~(GLOB_NOCHECK | GLOB_NOMAGIC)),
-				errfunc, pglob);
-	  if (status == GLOB_NOMATCH)
-	    /* No matches in this directory.  Try the next.  */
-	    continue;
-
-	  if (status != 0)
-	    {
-	      globfree (&dirs);
-	      globfree (pglob);
-	      pglob->gl_pathc = 0;
-	      return status;
-	    }
-
-	  /* Stick the directory on the front of each name.  */
-	  if (prefix_array (dirs.gl_pathv[i],
-			    &pglob->gl_pathv[old_pathc + pglob->gl_offs],
-			    pglob->gl_pathc - old_pathc))
-	    {
-	      globfree (&dirs);
-	      globfree (pglob);
-	      pglob->gl_pathc = 0;
-	      return GLOB_NOSPACE;
-	    }
-	}
+          old_pathc = pglob->gl_pathc;
+          status = glob_in_dir (filename, dirs.gl_pathv[i],
+                                ((flags | GLOB_APPEND)
+                                 & ~(GLOB_NOCHECK | GLOB_NOMAGIC)),
+                                errfunc, pglob);
+          if (status == GLOB_NOMATCH)
+            /* No matches in this directory.  Try the next.  */
+            continue;
+
+          if (status != 0)
+            {
+              globfree (&dirs);
+              globfree (pglob);
+              pglob->gl_pathc = 0;
+              return status;
+            }
+
+          /* Stick the directory on the front of each name.  */
+          if (prefix_array (dirs.gl_pathv[i],
+                            &pglob->gl_pathv[old_pathc + pglob->gl_offs],
+                            pglob->gl_pathc - old_pathc))
+            {
+              globfree (&dirs);
+              globfree (pglob);
+              pglob->gl_pathc = 0;
+              return GLOB_NOSPACE;
+            }
+        }
 
       flags |= GLOB_MAGCHAR;
 
       /* We have ignored the GLOB_NOCHECK flag in the `glob_in_dir' calls.
-	 But if we have not found any matching entry and the GLOB_NOCHECK
-	 flag was set we must return the input pattern itself.  */
+         But if we have not found any matching entry and the GLOB_NOCHECK
+         flag was set we must return the input pattern itself.  */
       if (pglob->gl_pathc + pglob->gl_offs == oldcount)
-	{
-	no_matches:
-	  /* No matches.  */
-	  if (flags & GLOB_NOCHECK)
-	    {
-	      int newcount = pglob->gl_pathc + pglob->gl_offs;
-	      char **new_gl_pathv;
-
-	      new_gl_pathv = realloc (pglob->gl_pathv,
-				      (newcount + 2) * sizeof (char *));
-	      if (new_gl_pathv == NULL)
-		{
-		  globfree (&dirs);
-		  return GLOB_NOSPACE;
-		}
-	      pglob->gl_pathv = new_gl_pathv;
-
-	      pglob->gl_pathv[newcount] = strdup (pattern);
-	      if (pglob->gl_pathv[newcount] == NULL)
-		{
-		  globfree (&dirs);
-		  globfree (pglob);
-		  pglob->gl_pathc = 0;
-		  return GLOB_NOSPACE;
-		}
-
-	      ++pglob->gl_pathc;
-	      ++newcount;
-
-	      pglob->gl_pathv[newcount] = NULL;
-	      pglob->gl_flags = flags;
-	    }
-	  else
-	    {
-	      globfree (&dirs);
-	      return GLOB_NOMATCH;
-	    }
-	}
+        {
+        no_matches:
+          /* No matches.  */
+          if (flags & GLOB_NOCHECK)
+            {
+              int newcount = pglob->gl_pathc + pglob->gl_offs;
+              char **new_gl_pathv;
+
+              new_gl_pathv = realloc (pglob->gl_pathv,
+                                      (newcount + 2) * sizeof (char *));
+              if (new_gl_pathv == NULL)
+                {
+                  globfree (&dirs);
+                  return GLOB_NOSPACE;
+                }
+              pglob->gl_pathv = new_gl_pathv;
+
+              pglob->gl_pathv[newcount] = strdup (pattern);
+              if (pglob->gl_pathv[newcount] == NULL)
+                {
+                  globfree (&dirs);
+                  globfree (pglob);
+                  pglob->gl_pathc = 0;
+                  return GLOB_NOSPACE;
+                }
+
+              ++pglob->gl_pathc;
+              ++newcount;
+
+              pglob->gl_pathv[newcount] = NULL;
+              pglob->gl_flags = flags;
+            }
+          else
+            {
+              globfree (&dirs);
+              return GLOB_NOMATCH;
+            }
+        }
 
       globfree (&dirs);
     }
@@ -993,54 +998,54 @@ glob (pattern, flags, errfunc, pglob)
       int orig_flags = flags;
 
       if (meta & 2)
-	{
-	  char *p = strchr (dirname, '\\'), *q;
-	  /* We need to unescape the dirname string.  It is certainly
-	     allocated by alloca, as otherwise filename would be NULL
-	     or dirname wouldn't contain backslashes.  */
-	  q = p;
-	  do
-	    {
-	      if (*p == '\\')
-		{
-		  *q = *++p;
-		  --dirlen;
-		}
-	      else
-		*q = *p;
-	      ++q;
-	    }
-	  while (*p++ != '\0');
-	  dirname_modified = 1;
-	}
+        {
+          char *p = strchr (dirname, '\\'), *q;
+          /* We need to unescape the dirname string.  It is certainly
+             allocated by alloca, as otherwise filename would be NULL
+             or dirname wouldn't contain backslashes.  */
+          q = p;
+          do
+            {
+              if (*p == '\\')
+                {
+                  *q = *++p;
+                  --dirlen;
+                }
+              else
+                *q = *p;
+              ++q;
+            }
+          while (*p++ != '\0');
+          dirname_modified = 1;
+        }
       if (dirname_modified)
-	flags &= ~(GLOB_NOCHECK | GLOB_NOMAGIC);
+        flags &= ~(GLOB_NOCHECK | GLOB_NOMAGIC);
       status = glob_in_dir (filename, dirname, flags, errfunc, pglob);
       if (status != 0)
-	{
-	  if (status == GLOB_NOMATCH && flags != orig_flags
-	      && pglob->gl_pathc + pglob->gl_offs == oldcount)
-	    {
-	      /* Make sure globfree (&dirs); is a nop.  */
-	      dirs.gl_pathv = NULL;
-	      flags = orig_flags;
-	      goto no_matches;
-	    }
-	  return status;
-	}
+        {
+          if (status == GLOB_NOMATCH && flags != orig_flags
+              && pglob->gl_pathc + pglob->gl_offs == oldcount)
+            {
+              /* Make sure globfree (&dirs); is a nop.  */
+              dirs.gl_pathv = NULL;
+              flags = orig_flags;
+              goto no_matches;
+            }
+          return status;
+        }
 
       if (dirlen > 0)
-	{
-	  /* Stick the directory on the front of each name.  */
-	  if (prefix_array (dirname,
-			    &pglob->gl_pathv[old_pathc + pglob->gl_offs],
-			    pglob->gl_pathc - old_pathc))
-	    {
-	      globfree (pglob);
-	      pglob->gl_pathc = 0;
-	      return GLOB_NOSPACE;
-	    }
-	}
+        {
+          /* Stick the directory on the front of each name.  */
+          if (prefix_array (dirname,
+                            &pglob->gl_pathv[old_pathc + pglob->gl_offs],
+                            pglob->gl_pathc - old_pathc))
+            {
+              globfree (pglob);
+              pglob->gl_pathc = 0;
+              return GLOB_NOSPACE;
+            }
+        }
     }
 
   if (flags & GLOB_MARK)
@@ -1051,31 +1056,31 @@ glob (pattern, flags, errfunc, pglob)
       struct_stat64 st64;
 
       for (i = oldcount; i < pglob->gl_pathc + pglob->gl_offs; ++i)
-	if ((__builtin_expect (flags & GLOB_ALTDIRFUNC, 0)
-	     ? ((*pglob->gl_stat) (pglob->gl_pathv[i], &st) == 0
-		&& S_ISDIR (st.st_mode))
-	     : (__stat64 (pglob->gl_pathv[i], &st64) == 0
-		&& S_ISDIR (st64.st_mode))))
-	  {
- 	    size_t len = strlen (pglob->gl_pathv[i]) + 2;
-	    char *new = realloc (pglob->gl_pathv[i], len);
- 	    if (new == NULL)
-	      {
-		globfree (pglob);
-		pglob->gl_pathc = 0;
-		return GLOB_NOSPACE;
-	      }
-	    strcpy (&new[len - 2], "/");
-	    pglob->gl_pathv[i] = new;
-	  }
+        if ((__builtin_expect (flags & GLOB_ALTDIRFUNC, 0)
+             ? ((*pglob->gl_stat) (pglob->gl_pathv[i], &st) == 0
+                && S_ISDIR (st.st_mode))
+             : (__stat64 (pglob->gl_pathv[i], &st64) == 0
+                && S_ISDIR (st64.st_mode))))
+          {
+            size_t len = strlen (pglob->gl_pathv[i]) + 2;
+            char *new = realloc (pglob->gl_pathv[i], len);
+            if (new == NULL)
+              {
+                globfree (pglob);
+                pglob->gl_pathc = 0;
+                return GLOB_NOSPACE;
+              }
+            strcpy (&new[len - 2], "/");
+            pglob->gl_pathv[i] = new;
+          }
     }
 
   if (!(flags & GLOB_NOSORT))
     {
       /* Sort the vector.  */
       qsort (&pglob->gl_pathv[oldcount],
-	     pglob->gl_pathc + pglob->gl_offs - oldcount,
-	     sizeof (char *), collated_compare);
+             pglob->gl_pathc + pglob->gl_offs - oldcount,
+             sizeof (char *), collated_compare);
     }
 
   return 0;
@@ -1096,8 +1101,8 @@ globfree (pglob)
     {
       size_t i;
       for (i = 0; i < pglob->gl_pathc; ++i)
-	if (pglob->gl_pathv[pglob->gl_offs + i] != NULL)
-	  free (pglob->gl_pathv[pglob->gl_offs + i]);
+        if (pglob->gl_pathv[pglob->gl_offs + i] != NULL)
+          free (pglob->gl_pathv[pglob->gl_offs + i]);
       free (pglob->gl_pathv);
       pglob->gl_pathv = NULL;
     }
@@ -1148,14 +1153,14 @@ prefix_array (const char *dirname, char **array, size_t n)
   else if (dirlen > 1)
     {
       if (dirname[dirlen - 1] == '/' && dirname[dirlen - 2] == ':')
-	/* DIRNAME is "d:/".  Don't prepend the slash from DIRNAME.  */
-	--dirlen;
+        /* DIRNAME is "d:/".  Don't prepend the slash from DIRNAME.  */
+        --dirlen;
       else if (dirname[dirlen - 1] == ':')
-	{
-	  /* DIRNAME is "d:".  Use `:' instead of `/'.  */
-	  --dirlen;
-	  sep_char = ':';
-	}
+        {
+          /* DIRNAME is "d:".  Use `:' instead of `/'.  */
+          --dirlen;
+          sep_char = ':';
+        }
     }
 #endif
 
@@ -1164,16 +1169,16 @@ prefix_array (const char *dirname, char **array, size_t n)
       size_t eltlen = strlen (array[i]) + 1;
       char *new = malloc (dirlen + 1 + eltlen);
       if (new == NULL)
-	{
-	  while (i > 0)
-	    free (array[--i]);
-	  return 1;
-	}
+        {
+          while (i > 0)
+            free (array[--i]);
+          return 1;
+        }
 
       {
-	char *endp = mempcpy (new, dirname, dirlen);
-	*endp++ = DIRSEP_CHAR;
-	mempcpy (endp, array[i], eltlen);
+        char *endp = mempcpy (new, dirname, dirlen);
+        *endp++ = DIRSEP_CHAR;
+        mempcpy (endp, array[i], eltlen);
       }
       free (array[i]);
       array[i] = new;
@@ -1198,25 +1203,25 @@ __glob_pattern_type (pattern, quote)
       {
       case '?':
       case '*':
-	return 1;
+        return 1;
 
       case '\\':
-	if (quote)
-	  {
-	    if (p[1] != '\0')
-	      ++p;
-	    ret |= 2;
-	  }
-	break;
+        if (quote)
+          {
+            if (p[1] != '\0')
+              ++p;
+            ret |= 2;
+          }
+        break;
 
       case '[':
-	ret |= 4;
-	break;
+        ret |= 4;
+        break;
 
       case ']':
-	if (ret & 4)
-	  return 1;
-	break;
+        if (ret & 4)
+          return 1;
+        break;
       }
 
   return ret;
@@ -1245,18 +1250,18 @@ weak_alias (__glob_pattern_p, glob_pattern_p)
 static int
 __attribute_noinline__
 link_exists2_p (const char *dir, size_t dirlen, const char *fname,
-		glob_t *pglob
+                glob_t *pglob
 # if !defined _LIBC && !HAVE_FSTATAT
-		, int flags
+                , int flags
 # endif
-		)
+                )
 {
   size_t fnamelen = strlen (fname);
   char *fullname = __alloca (dirlen + 1 + fnamelen + 1);
   struct stat st;
 
   mempcpy (mempcpy (mempcpy (fullname, dir, dirlen), "/", 1),
-	   fname, fnamelen + 1);
+           fname, fnamelen + 1);
 
 # if !defined _LIBC && !HAVE_FSTATAT
   if (__builtin_expect ((flags & GLOB_ALTDIRFUNC) == 0, 1))
@@ -1271,7 +1276,7 @@ link_exists2_p (const char *dir, size_t dirlen, const char *fname,
 /* Return true if DIR/FNAME exists.  */
 static int
 link_exists_p (int dfd, const char *dir, size_t dirlen, const char *fname,
-	       glob_t *pglob, int flags)
+               glob_t *pglob, int flags)
 {
 # if defined _LIBC || HAVE_FSTATAT
   if (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0))
@@ -1294,8 +1299,8 @@ link_exists_p (int dfd, const char *dir, size_t dirlen, const char *fname,
    The GLOB_APPEND flag is assumed to be set (always appends).  */
 static int
 glob_in_dir (const char *pattern, const char *directory, int flags,
-	     int (*errfunc) (const char *, int),
-	     glob_t *pglob)
+             int (*errfunc) (const char *, int),
+             glob_t *pglob)
 {
   size_t dirlen = strlen (directory);
   void *stream = NULL;
@@ -1323,135 +1328,135 @@ glob_in_dir (const char *pattern, const char *directory, int flags,
   if (meta == 0 && (flags & (GLOB_NOCHECK|GLOB_NOMAGIC)))
     {
       /* We need not do any tests.  The PATTERN contains no meta
-	 characters and we must not return an error therefore the
-	 result will always contain exactly one name.  */
+         characters and we must not return an error therefore the
+         result will always contain exactly one name.  */
       flags |= GLOB_NOCHECK;
     }
   else if (meta == 0)
     {
       /* Since we use the normal file functions we can also use stat()
-	 to verify the file is there.  */
+         to verify the file is there.  */
       struct stat st;
       struct_stat64 st64;
       size_t patlen = strlen (pattern);
       char *fullname = __alloca (dirlen + 1 + patlen + 1);
 
       mempcpy (mempcpy (mempcpy (fullname, directory, dirlen),
-			"/", 1),
-	       pattern, patlen + 1);
+                        "/", 1),
+               pattern, patlen + 1);
       if ((__builtin_expect (flags & GLOB_ALTDIRFUNC, 0)
-	   ? (*pglob->gl_stat) (fullname, &st)
-	   : __stat64 (fullname, &st64)) == 0)
-	/* We found this file to be existing.  Now tell the rest
-	   of the function to copy this name into the result.  */
-	flags |= GLOB_NOCHECK;
+           ? (*pglob->gl_stat) (fullname, &st)
+           : __stat64 (fullname, &st64)) == 0)
+        /* We found this file to be existing.  Now tell the rest
+           of the function to copy this name into the result.  */
+        flags |= GLOB_NOCHECK;
     }
   else
     {
       stream = (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0)
-		? (*pglob->gl_opendir) (directory)
-		: opendir (directory));
+                ? (*pglob->gl_opendir) (directory)
+                : opendir (directory));
       if (stream == NULL)
-	{
-	  if (errno != ENOTDIR
-	      && ((errfunc != NULL && (*errfunc) (directory, errno))
-		  || (flags & GLOB_ERR)))
-	    return GLOB_ABORTED;
-	}
+        {
+          if (errno != ENOTDIR
+              && ((errfunc != NULL && (*errfunc) (directory, errno))
+                  || (flags & GLOB_ERR)))
+            return GLOB_ABORTED;
+        }
       else
-	{
-	  int dfd = (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0)
-		     ? -1 : dirfd ((DIR *) stream));
-	  int fnm_flags = ((!(flags & GLOB_PERIOD) ? FNM_PERIOD : 0)
-			   | ((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0)
+        {
+          int dfd = (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0)
+                     ? -1 : dirfd ((DIR *) stream));
+          int fnm_flags = ((!(flags & GLOB_PERIOD) ? FNM_PERIOD : 0)
+                           | ((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0)
 #if defined _AMIGA || defined VMS
-			   | FNM_CASEFOLD
+                           | FNM_CASEFOLD
 #endif
-			   );
-	  flags |= GLOB_MAGCHAR;
+                           );
+          flags |= GLOB_MAGCHAR;
 
-	  while (1)
-	    {
-	      const char *name;
-	      size_t len;
+          while (1)
+            {
+              const char *name;
+              size_t len;
 #if defined _LIBC && !defined COMPILE_GLOB64
-	      struct dirent64 *d;
-	      union
-		{
-		  struct dirent64 d64;
-		  char room [offsetof (struct dirent64, d_name[0])
-			     + NAME_MAX + 1];
-		}
-	      d64buf;
-
-	      if (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0))
-		{
-		  struct dirent *d32 = (*pglob->gl_readdir) (stream);
-		  if (d32 != NULL)
-		    {
-		      CONVERT_DIRENT_DIRENT64 (&d64buf.d64, d32);
-		      d = &d64buf.d64;
-		    }
-		  else
-		    d = NULL;
-		}
-	      else
-		d = __readdir64 (stream);
+              struct dirent64 *d;
+              union
+                {
+                  struct dirent64 d64;
+                  char room [offsetof (struct dirent64, d_name[0])
+                             + NAME_MAX + 1];
+                }
+              d64buf;
+
+              if (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0))
+                {
+                  struct dirent *d32 = (*pglob->gl_readdir) (stream);
+                  if (d32 != NULL)
+                    {
+                      CONVERT_DIRENT_DIRENT64 (&d64buf.d64, d32);
+                      d = &d64buf.d64;
+                    }
+                  else
+                    d = NULL;
+                }
+              else
+                d = __readdir64 (stream);
 #else
-	      struct dirent *d = (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0)
-				  ? ((struct dirent *)
-				     (*pglob->gl_readdir) (stream))
-				  : __readdir (stream));
+              struct dirent *d = (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0)
+                                  ? ((struct dirent *)
+                                     (*pglob->gl_readdir) (stream))
+                                  : __readdir (stream));
 #endif
-	      if (d == NULL)
-		break;
-	      if (! REAL_DIR_ENTRY (d))
-		continue;
-
-	      /* If we shall match only directories use the information
-		 provided by the dirent call if possible.  */
-	      if ((flags & GLOB_ONLYDIR) && !DIRENT_MIGHT_BE_DIR (d))
-		continue;
-
-	      name = d->d_name;
-
-	      if (fnmatch (pattern, name, fnm_flags) == 0)
-		{
-		  /* If the file we found is a symlink we have to
-		     make sure the target file exists.  */
-		  if (!DIRENT_MIGHT_BE_SYMLINK (d)
-		      || link_exists_p (dfd, directory, dirlen, name, pglob,
-					flags))
-		    {
-		      if (cur == names->count)
-			{
-			  struct globnames *newnames;
-			  size_t count = names->count * 2;
-			  size_t size = (sizeof (struct globnames)
-					 + ((count - INITIAL_COUNT)
-					    * sizeof (char *)));
-			  allocasize += size;
-			  if (__libc_use_alloca (allocasize))
-			    newnames = names_alloca = __alloca (size);
-			  else if ((newnames = malloc (size))
-				   == NULL)
-			    goto memory_error;
-			  newnames->count = count;
-			  newnames->next = names;
-			  names = newnames;
-			  cur = 0;
-			}
-		      len = _D_EXACT_NAMLEN (d);
-		      names->name[cur] = malloc (len + 1);
-		      if (names->name[cur] == NULL)
-			goto memory_error;
-		      *((char *) mempcpy (names->name[cur++], name, len))
-			= '\0';
-		      ++nfound;
-		    }
-		}
-	    }
-	}
+              if (d == NULL)
+                break;
+              if (! REAL_DIR_ENTRY (d))
+                continue;
+
+              /* If we shall match only directories use the information
+                 provided by the dirent call if possible.  */
+              if ((flags & GLOB_ONLYDIR) && !DIRENT_MIGHT_BE_DIR (d))
+                continue;
+
+              name = d->d_name;
+
+              if (fnmatch (pattern, name, fnm_flags) == 0)
+                {
+                  /* If the file we found is a symlink we have to
+                     make sure the target file exists.  */
+                  if (!DIRENT_MIGHT_BE_SYMLINK (d)
+                      || link_exists_p (dfd, directory, dirlen, name, pglob,
+                                        flags))
+                    {
+                      if (cur == names->count)
+                        {
+                          struct globnames *newnames;
+                          size_t count = names->count * 2;
+                          size_t size = (sizeof (struct globnames)
+                                         + ((count - INITIAL_COUNT)
+                                            * sizeof (char *)));
+                          allocasize += size;
+                          if (__libc_use_alloca (allocasize))
+                            newnames = names_alloca = __alloca (size);
+                          else if ((newnames = malloc (size))
+                                   == NULL)
+                            goto memory_error;
+                          newnames->count = count;
+                          newnames->next = names;
+                          names = newnames;
+                          cur = 0;
+                        }
+                      len = _D_EXACT_NAMLEN (d);
+                      names->name[cur] = malloc (len + 1);
+                      if (names->name[cur] == NULL)
+                        goto memory_error;
+                      *((char *) mempcpy (names->name[cur++], name, len))
+                        = '\0';
+                      ++nfound;
+                    }
+                }
+            }
+        }
     }
 
   if (nfound == 0 && (flags & GLOB_NOCHECK))
@@ -1460,7 +1465,7 @@ glob_in_dir (const char *pattern, const char *directory, int flags,
       nfound = 1;
       names->name[cur] = malloc (len + 1);
       if (names->name[cur] == NULL)
-	goto memory_error;
+        goto memory_error;
       *((char *) mempcpy (names->name[cur++], pattern, len)) = '\0';
     }
 
@@ -1468,79 +1473,79 @@ glob_in_dir (const char *pattern, const char *directory, int flags,
   if (nfound != 0)
     {
       char **new_gl_pathv
-	= realloc (pglob->gl_pathv,
-		   (pglob->gl_pathc + pglob->gl_offs + nfound + 1)
-		   * sizeof (char *));
+        = realloc (pglob->gl_pathv,
+                   (pglob->gl_pathc + pglob->gl_offs + nfound + 1)
+                   * sizeof (char *));
       result = 0;
 
       if (new_gl_pathv == NULL)
-	{
-	memory_error:
-	  while (1)
-	    {
-	      struct globnames *old = names;
-	      size_t i;
-	      for (i = 0; i < cur; ++i)
-		free (names->name[i]);
-	      names = names->next;
-	      /* NB: we will not leak memory here if we exit without
-		 freeing the current block assigned to OLD.  At least
-		 the very first block is always allocated on the stack
-		 and this is the block assigned to OLD here.  */
-	      if (names == NULL)
-		{
-		  assert (old == &init_names);
-		  break;
-		}
-	      cur = names->count;
-	      if (old == names_alloca)
-		names_alloca = names;
-	      else
-		free (old);
-	    }
-	  result = GLOB_NOSPACE;
-	}
+        {
+        memory_error:
+          while (1)
+            {
+              struct globnames *old = names;
+              size_t i;
+              for (i = 0; i < cur; ++i)
+                free (names->name[i]);
+              names = names->next;
+              /* NB: we will not leak memory here if we exit without
+                 freeing the current block assigned to OLD.  At least
+                 the very first block is always allocated on the stack
+                 and this is the block assigned to OLD here.  */
+              if (names == NULL)
+                {
+                  assert (old == &init_names);
+                  break;
+                }
+              cur = names->count;
+              if (old == names_alloca)
+                names_alloca = names;
+              else
+                free (old);
+            }
+          result = GLOB_NOSPACE;
+        }
       else
-	{
-	  while (1)
-	    {
-	      struct globnames *old = names;
-	      size_t i;
-	      for (i = 0; i < cur; ++i)
-		new_gl_pathv[pglob->gl_offs + pglob->gl_pathc++]
-		  = names->name[i];
-	      names = names->next;
-	      /* NB: we will not leak memory here if we exit without
-		 freeing the current block assigned to OLD.  At least
-		 the very first block is always allocated on the stack
-		 and this is the block assigned to OLD here.  */
-	      if (names == NULL)
-		{
-		  assert (old == &init_names);
-		  break;
-		}
-	      cur = names->count;
-	      if (old == names_alloca)
-		names_alloca = names;
-	      else
-		free (old);
-	    }
-
-	  pglob->gl_pathv = new_gl_pathv;
-
-	  pglob->gl_pathv[pglob->gl_offs + pglob->gl_pathc] = NULL;
-
-	  pglob->gl_flags = flags;
-	}
+        {
+          while (1)
+            {
+              struct globnames *old = names;
+              size_t i;
+              for (i = 0; i < cur; ++i)
+                new_gl_pathv[pglob->gl_offs + pglob->gl_pathc++]
+                  = names->name[i];
+              names = names->next;
+              /* NB: we will not leak memory here if we exit without
+                 freeing the current block assigned to OLD.  At least
+                 the very first block is always allocated on the stack
+                 and this is the block assigned to OLD here.  */
+              if (names == NULL)
+                {
+                  assert (old == &init_names);
+                  break;
+                }
+              cur = names->count;
+              if (old == names_alloca)
+                names_alloca = names;
+              else
+                free (old);
+            }
+
+          pglob->gl_pathv = new_gl_pathv;
+
+          pglob->gl_pathv[pglob->gl_offs + pglob->gl_pathc] = NULL;
+
+          pglob->gl_flags = flags;
+        }
     }
 
   if (stream != NULL)
     {
       save = errno;
       if (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0))
-	(*pglob->gl_closedir) (stream);
+        (*pglob->gl_closedir) (stream);
       else
-	closedir (stream);
+        closedir (stream);
       __set_errno (save);
     }
 
diff --git a/libmissing/glob.in.h b/libmissing/glob.in.h
index e3dc892..7e16a82 100644
--- a/libmissing/glob.in.h
+++ b/libmissing/glob.in.h
@@ -1,6 +1,6 @@
 /* glob.h -- Find a path matching a pattern.
 
-   Copyright (C) 2005-2007 Free Software Foundation, Inc.
+   Copyright (C) 2005-2007, 2009 Free Software Foundation, Inc.
 
    Written by Derek Price <[email protected]> & Paul Eggert <[email protected]>
 
@@ -40,8 +40,10 @@
 # define __THROW
 #endif
 
+/* The definition of _GL_ARG_NONNULL is copied here.  */
+
 #ifndef __size_t
-# define __size_t	size_t
+# define __size_t       size_t
 #endif
 #ifndef __USE_GNU
 # define __USE_GNU    1
diff --git a/libmissing/inet_ntop.c b/libmissing/inet_ntop.c
index e5ef8f5..08ac7d4 100644
--- a/libmissing/inet_ntop.c
+++ b/libmissing/inet_ntop.c
@@ -1,6 +1,6 @@
 /* inet_ntop.c -- convert IPv4 and IPv6 addresses from binary to text form
 
-   Copyright (C) 2005, 2006, 2008  Free Software Foundation, Inc.
+   Copyright (C) 2005, 2006, 2008, 2009  Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -42,10 +42,6 @@
 #include <string.h>
 #include <errno.h>
 
-#ifndef EAFNOSUPPORT
-# define EAFNOSUPPORT EINVAL
-#endif
-
 #define NS_IN6ADDRSZ 16
 #define NS_INT16SZ 2
 
@@ -63,15 +59,15 @@ static const char *inet_ntop6 (const unsigned char *src, char *dst, socklen_t si
 
 /* char *
  * inet_ntop(af, src, dst, size)
- *	convert a network format address to presentation format.
+ *      convert a network format address to presentation format.
  * return:
- *	pointer to presentation format address (`dst'), or NULL (see errno).
+ *      pointer to presentation format address (`dst'), or NULL (see errno).
  * author:
- *	Paul Vixie, 1996.
+ *      Paul Vixie, 1996.
  */
 const char *
 inet_ntop (int af, const void *restrict src,
-	   char *restrict dst, socklen_t cnt)
+           char *restrict dst, socklen_t cnt)
 {
   switch (af)
     {
@@ -94,14 +90,14 @@ inet_ntop (int af, const void *restrict src,
 
 /* const char *
  * inet_ntop4(src, dst, size)
- *	format an IPv4 address
+ *      format an IPv4 address
  * return:
- *	`dst' (as a const)
+ *      `dst' (as a const)
  * notes:
- *	(1) uses no statics
- *	(2) takes a u_char* not an in_addr as input
+ *      (1) uses no statics
+ *      (2) takes a u_char* not an in_addr as input
  * author:
- *	Paul Vixie, 1996.
+ *      Paul Vixie, 1996.
  */
 static const char *
 inet_ntop4 (const unsigned char *src, char *dst, socklen_t size)
@@ -126,9 +122,9 @@ inet_ntop4 (const unsigned char *src, char *dst, socklen_t size)
 
 /* const char *
  * inet_ntop6(src, dst, size)
- *	convert IPv6 binary address into presentation (printable) format
+ *      convert IPv6 binary address into presentation (printable) format
  * author:
- *	Paul Vixie, 1996.
+ *      Paul Vixie, 1996.
  */
 static const char *
 inet_ntop6 (const unsigned char *src, char *dst, socklen_t size)
@@ -161,26 +157,26 @@ inet_ntop6 (const unsigned char *src, char *dst, socklen_t size)
   for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++)
     {
       if (words[i] == 0)
-	{
-	  if (cur.base == -1)
-	    cur.base = i, cur.len = 1;
-	  else
-	    cur.len++;
-	}
+        {
+          if (cur.base == -1)
+            cur.base = i, cur.len = 1;
+          else
+            cur.len++;
+        }
       else
-	{
-	  if (cur.base != -1)
-	    {
-	      if (best.base == -1 || cur.len > best.len)
-		best = cur;
-	      cur.base = -1;
-	    }
-	}
+        {
+          if (cur.base != -1)
+            {
+              if (best.base == -1 || cur.len > best.len)
+                best = cur;
+              cur.base = -1;
+            }
+        }
     }
   if (cur.base != -1)
     {
       if (best.base == -1 || cur.len > best.len)
-	best = cur;
+        best = cur;
     }
   if (best.base != -1 && best.len < 2)
     best.base = -1;
@@ -193,28 +189,28 @@ inet_ntop6 (const unsigned char *src, char *dst, socklen_t size)
     {
       /* Are we inside the best run of 0x00's? */
       if (best.base != -1 && i >= best.base && i < (best.base + best.len))
-	{
-	  if (i == best.base)
-	    *tp++ = ':';
-	  continue;
-	}
+        {
+          if (i == best.base)
+            *tp++ = ':';
+          continue;
+        }
       /* Are we following an initial run of 0x00s or any real hex? */
       if (i != 0)
-	*tp++ = ':';
+        *tp++ = ':';
       /* Is this address an encapsulated IPv4? */
       if (i == 6 && best.base == 0 &&
-	  (best.len == 6 || (best.len == 5 && words[5] == 0xffff)))
-	{
-	  if (!inet_ntop4 (src + 12, tp, sizeof tmp - (tp - tmp)))
-	    return (NULL);
-	  tp += strlen (tp);
-	  break;
-	}
+          (best.len == 6 || (best.len == 5 && words[5] == 0xffff)))
+        {
+          if (!inet_ntop4 (src + 12, tp, sizeof tmp - (tp - tmp)))
+            return (NULL);
+          tp += strlen (tp);
+          break;
+        }
       {
-	int len = sprintf (tp, "%x", words[i]);
-	if (len < 0)
-	  return NULL;
-	tp += len;
+        int len = sprintf (tp, "%x", words[i]);
+        if (len < 0)
+          return NULL;
+        tp += len;
       }
     }
   /* Was it a trailing run of 0x00's? */
diff --git a/libmissing/langinfo.in.h b/libmissing/langinfo.in.h
new file mode 100644
index 0000000..e76bffa
--- /dev/null
+++ b/libmissing/langinfo.in.h
@@ -0,0 +1,162 @@
+/* Substitute for and wrapper around <langinfo.h>.
+   Copyright (C) 2009 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+/*
+ * POSIX <langinfo.h> for platforms that lack it or have an incomplete one.
+ * <http://www.opengroup.org/onlinepubs/9699919799/basedefs/langinfo.h.html>
+ */
+
+#ifndef _GL_LANGINFO_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+
+/* The include_next requires a split double-inclusion guard.  */
+#if @HAVE_LANGINFO_H@
+# @INCLUDE_NEXT@ @NEXT_LANGINFO_H@
+#endif
+
+#ifndef _GL_LANGINFO_H
+#define _GL_LANGINFO_H
+
+
+#if !@HAVE_LANGINFO_H@
+
+/* A platform that lacks <langinfo.h>.  */
+
+/* Assume that it also lacks <nl_types.h> and the nl_item type.  */
+typedef int nl_item;
+
+/* nl_langinfo items of the LC_CTYPE category */
+# define CODESET     10000
+/* nl_langinfo items of the LC_NUMERIC category */
+# define RADIXCHAR   10001
+# define THOUSEP     10002
+/* nl_langinfo items of the LC_TIME category */
+# define D_T_FMT     10003
+# define D_FMT       10004
+# define T_FMT       10005
+# define T_FMT_AMPM  10006
+# define AM_STR      10007
+# define PM_STR      10008
+# define DAY_1       10009
+# define DAY_2       (DAY_1 + 1)
+# define DAY_3       (DAY_1 + 2)
+# define DAY_4       (DAY_1 + 3)
+# define DAY_5       (DAY_1 + 4)
+# define DAY_6       (DAY_1 + 5)
+# define DAY_7       (DAY_1 + 6)
+# define ABDAY_1     10016
+# define ABDAY_2     (ABDAY_1 + 1)
+# define ABDAY_3     (ABDAY_1 + 2)
+# define ABDAY_4     (ABDAY_1 + 3)
+# define ABDAY_5     (ABDAY_1 + 4)
+# define ABDAY_6     (ABDAY_1 + 5)
+# define ABDAY_7     (ABDAY_1 + 6)
+# define MON_1       10023
+# define MON_2       (MON_1 + 1)
+# define MON_3       (MON_1 + 2)
+# define MON_4       (MON_1 + 3)
+# define MON_5       (MON_1 + 4)
+# define MON_6       (MON_1 + 5)
+# define MON_7       (MON_1 + 6)
+# define MON_8       (MON_1 + 7)
+# define MON_9       (MON_1 + 8)
+# define MON_10      (MON_1 + 9)
+# define MON_11      (MON_1 + 10)
+# define MON_12      (MON_1 + 11)
+# define ABMON_1     10035
+# define ABMON_2     (ABMON_1 + 1)
+# define ABMON_3     (ABMON_1 + 2)
+# define ABMON_4     (ABMON_1 + 3)
+# define ABMON_5     (ABMON_1 + 4)
+# define ABMON_6     (ABMON_1 + 5)
+# define ABMON_7     (ABMON_1 + 6)
+# define ABMON_8     (ABMON_1 + 7)
+# define ABMON_9     (ABMON_1 + 8)
+# define ABMON_10    (ABMON_1 + 9)
+# define ABMON_11    (ABMON_1 + 10)
+# define ABMON_12    (ABMON_1 + 11)
+# define ERA         10047
+# define ERA_D_FMT   10048
+# define ERA_D_T_FMT 10049
+# define ERA_T_FMT   10050
+# define ALT_DIGITS  10051
+/* nl_langinfo items of the LC_MONETARY category */
+# define CRNCYSTR    10052
+/* nl_langinfo items of the LC_MESSAGES category */
+# define YESEXPR     10053
+# define NOEXPR      10054
+
+#else
+
+/* A platform that has <langinfo.h>.  */
+
+# if !@HAVE_LANGINFO_CODESET@
+#  define CODESET     10000
+#  define GNULIB_defined_CODESET 1
+# endif
+
+# if !@HAVE_LANGINFO_ERA@
+#  define ERA         10047
+#  define ERA_D_FMT   10048
+#  define ERA_D_T_FMT 10049
+#  define ERA_T_FMT   10050
+#  define ALT_DIGITS  10051
+#  define GNULIB_defined_ERA 1
+# endif
+
+#endif
+
+/* The definition of GL_LINK_WARNING is copied here.  */
+
+/* Declare overridden functions.  */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Return a piece of locale dependent information.
+   Note: The difference between nl_langinfo (CODESET) and locale_charset ()
+   is that the latter normalizes the encoding names to GNU conventions.  */
+
+#if @GNULIB_NL_LANGINFO@
+# if @REPLACE_NL_LANGINFO@
+#  undef nl_langinfo
+#  define nl_langinfo rpl_nl_langinfo
+# endif
+# if !@HAVE_NL_LANGINFO@ || @REPLACE_NL_LANGINFO@
+extern char *nl_langinfo (nl_item item);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef nl_langinfo
+# define nl_langinfo(i)                      \
+    (GL_LINK_WARNING ("nl_langinfo is not portable - " \
+                      "use gnulib module nl_langinfo for portability"), \
+     nl_langinfo (i))
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* _GL_LANGINFO_H */
+#endif /* _GL_LANGINFO_H */
diff --git a/libmissing/localcharset.c b/libmissing/localcharset.c
index 93da170..14359fc 100644
--- a/libmissing/localcharset.c
+++ b/libmissing/localcharset.c
@@ -23,6 +23,7 @@
 /* Specification.  */
 #include "localcharset.h"
 
+#include <fcntl.h>
 #include <stddef.h>
 #include <stdio.h>
 #include <string.h>
@@ -44,6 +45,7 @@
 #endif
 
 #if !defined WIN32_NATIVE
+# include <unistd.h>
 # if HAVE_LANGINFO_CODESET
 #  include <langinfo.h>
 # else
@@ -75,6 +77,11 @@
 # include "configmake.h"
 #endif
 
+/* Define O_NOFOLLOW to 0 on platforms where it does not exist.  */
+#ifndef O_NOFOLLOW
+# define O_NOFOLLOW 0
+#endif
+
 #if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
   /* Win32, Cygwin, OS/2, DOS */
 # define ISSLASH(C) ((C) == '/' || (C) == '\\')
@@ -117,192 +124,219 @@ get_charset_aliases (void)
   if (cp == NULL)
     {
 #if !(defined DARWIN7 || defined VMS || defined WIN32_NATIVE || defined __CYGWIN__)
-      FILE *fp;
       const char *dir;
       const char *base = "charset.alias";
       char *file_name;
 
       /* Make it possible to override the charset.alias location.  This is
-	 necessary for running the testsuite before "make install".  */
+         necessary for running the testsuite before "make install".  */
       dir = getenv ("CHARSETALIASDIR");
       if (dir == NULL || dir[0] == '\0')
-	dir = relocate (LIBDIR);
+        dir = relocate (LIBDIR);
 
       /* Concatenate dir and base into freshly allocated file_name.  */
       {
-	size_t dir_len = strlen (dir);
-	size_t base_len = strlen (base);
-	int add_slash = (dir_len > 0 && !ISSLASH (dir[dir_len - 1]));
-	file_name = (char *) malloc (dir_len + add_slash + base_len + 1);
-	if (file_name != NULL)
-	  {
-	    memcpy (file_name, dir, dir_len);
-	    if (add_slash)
-	      file_name[dir_len] = DIRECTORY_SEPARATOR;
-	    memcpy (file_name + dir_len + add_slash, base, base_len + 1);
-	  }
+        size_t dir_len = strlen (dir);
+        size_t base_len = strlen (base);
+        int add_slash = (dir_len > 0 && !ISSLASH (dir[dir_len - 1]));
+        file_name = (char *) malloc (dir_len + add_slash + base_len + 1);
+        if (file_name != NULL)
+          {
+            memcpy (file_name, dir, dir_len);
+            if (add_slash)
+              file_name[dir_len] = DIRECTORY_SEPARATOR;
+            memcpy (file_name + dir_len + add_slash, base, base_len + 1);
+          }
       }
 
-      if (file_name == NULL || (fp = fopen (file_name, "r")) == NULL)
-	/* Out of memory or file not found, treat it as empty.  */
-	cp = "";
+      if (file_name == NULL)
+        /* Out of memory.  Treat the file as empty.  */
+        cp = "";
       else
-	{
-	  /* Parse the file's contents.  */
-	  char *res_ptr = NULL;
-	  size_t res_size = 0;
-
-	  for (;;)
-	    {
-	      int c;
-	      char buf1[50+1];
-	      char buf2[50+1];
-	      size_t l1, l2;
-	      char *old_res_ptr;
-
-	      c = getc (fp);
-	      if (c == EOF)
-		break;
-	      if (c == '\n' || c == ' ' || c == '\t')
-		continue;
-	      if (c == '#')
-		{
-		  /* Skip comment, to end of line.  */
-		  do
-		    c = getc (fp);
-		  while (!(c == EOF || c == '\n'));
-		  if (c == EOF)
-		    break;
-		  continue;
-		}
-	      ungetc (c, fp);
-	      if (fscanf (fp, "%50s %50s", buf1, buf2) < 2)
-		break;
-	      l1 = strlen (buf1);
-	      l2 = strlen (buf2);
-	      old_res_ptr = res_ptr;
-	      if (res_size == 0)
-		{
-		  res_size = l1 + 1 + l2 + 1;
-		  res_ptr = (char *) malloc (res_size + 1);
-		}
-	      else
-		{
-		  res_size += l1 + 1 + l2 + 1;
-		  res_ptr = (char *) realloc (res_ptr, res_size + 1);
-		}
-	      if (res_ptr == NULL)
-		{
-		  /* Out of memory. */
-		  res_size = 0;
-		  if (old_res_ptr != NULL)
-		    free (old_res_ptr);
-		  break;
-		}
-	      strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1);
-	      strcpy (res_ptr + res_size - (l2 + 1), buf2);
-	    }
-	  fclose (fp);
-	  if (res_size == 0)
-	    cp = "";
-	  else
-	    {
-	      *(res_ptr + res_size) = '\0';
-	      cp = res_ptr;
-	    }
-	}
-
-      if (file_name != NULL)
-	free (file_name);
+        {
+          int fd;
+
+          /* Open the file.  Reject symbolic links on platforms that support
+             O_NOFOLLOW.  This is a security feature.  Without it, an attacker
+             could retrieve parts of the contents (namely, the tail of the
+             first line that starts with "* ") of an arbitrary file by placing
+             a symbolic link to that file under the name "charset.alias" in
+             some writable directory and defining the environment variable
+             CHARSETALIASDIR to point to that directory.  */
+          fd = open (file_name,
+                     O_RDONLY | (HAVE_WORKING_O_NOFOLLOW ? O_NOFOLLOW : 0));
+          if (fd < 0)
+            /* File not found.  Treat it as empty.  */
+            cp = "";
+          else
+            {
+              FILE *fp;
+
+              fp = fdopen (fd, "r");
+              if (fp == NULL)
+                {
+                  /* Out of memory.  Treat the file as empty.  */
+                  close (fd);
+                  cp = "";
+                }
+              else
+                {
+                  /* Parse the file's contents.  */
+                  char *res_ptr = NULL;
+                  size_t res_size = 0;
+
+                  for (;;)
+                    {
+                      int c;
+                      char buf1[50+1];
+                      char buf2[50+1];
+                      size_t l1, l2;
+                      char *old_res_ptr;
+
+                      c = getc (fp);
+                      if (c == EOF)
+                        break;
+                      if (c == '\n' || c == ' ' || c == '\t')
+                        continue;
+                      if (c == '#')
+                        {
+                          /* Skip comment, to end of line.  */
+                          do
+                            c = getc (fp);
+                          while (!(c == EOF || c == '\n'));
+                          if (c == EOF)
+                            break;
+                          continue;
+                        }
+                      ungetc (c, fp);
+                      if (fscanf (fp, "%50s %50s", buf1, buf2) < 2)
+                        break;
+                      l1 = strlen (buf1);
+                      l2 = strlen (buf2);
+                      old_res_ptr = res_ptr;
+                      if (res_size == 0)
+                        {
+                          res_size = l1 + 1 + l2 + 1;
+                          res_ptr = (char *) malloc (res_size + 1);
+                        }
+                      else
+                        {
+                          res_size += l1 + 1 + l2 + 1;
+                          res_ptr = (char *) realloc (res_ptr, res_size + 1);
+                        }
+                      if (res_ptr == NULL)
+                        {
+                          /* Out of memory. */
+                          res_size = 0;
+                          if (old_res_ptr != NULL)
+                            free (old_res_ptr);
+                          break;
+                        }
+                      strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1);
+                      strcpy (res_ptr + res_size - (l2 + 1), buf2);
+                    }
+                  fclose (fp);
+                  if (res_size == 0)
+                    cp = "";
+                  else
+                    {
+                      *(res_ptr + res_size) = '\0';
+                      cp = res_ptr;
+                    }
+                }
+            }
+
+          free (file_name);
+        }
 
 #else
 
 # if defined DARWIN7
       /* To avoid the trouble of installing a file that is shared by many
-	 GNU packages -- many packaging systems have problems with this --,
-	 simply inline the aliases here.  */
+         GNU packages -- many packaging systems have problems with this --,
+         simply inline the aliases here.  */
       cp = "ISO8859-1" "\0" "ISO-8859-1" "\0"
-	   "ISO8859-2" "\0" "ISO-8859-2" "\0"
-	   "ISO8859-4" "\0" "ISO-8859-4" "\0"
-	   "ISO8859-5" "\0" "ISO-8859-5" "\0"
-	   "ISO8859-7" "\0" "ISO-8859-7" "\0"
-	   "ISO8859-9" "\0" "ISO-8859-9" "\0"
-	   "ISO8859-13" "\0" "ISO-8859-13" "\0"
-	   "ISO8859-15" "\0" "ISO-8859-15" "\0"
-	   "KOI8-R" "\0" "KOI8-R" "\0"
-	   "KOI8-U" "\0" "KOI8-U" "\0"
-	   "CP866" "\0" "CP866" "\0"
-	   "CP949" "\0" "CP949" "\0"
-	   "CP1131" "\0" "CP1131" "\0"
-	   "CP1251" "\0" "CP1251" "\0"
-	   "eucCN" "\0" "GB2312" "\0"
-	   "GB2312" "\0" "GB2312" "\0"
-	   "eucJP" "\0" "EUC-JP" "\0"
-	   "eucKR" "\0" "EUC-KR" "\0"
-	   "Big5" "\0" "BIG5" "\0"
-	   "Big5HKSCS" "\0" "BIG5-HKSCS" "\0"
-	   "GBK" "\0" "GBK" "\0"
-	   "GB18030" "\0" "GB18030" "\0"
-	   "SJIS" "\0" "SHIFT_JIS" "\0"
-	   "ARMSCII-8" "\0" "ARMSCII-8" "\0"
-	   "PT154" "\0" "PT154" "\0"
-	 /*"ISCII-DEV" "\0" "?" "\0"*/
-	   "*" "\0" "UTF-8" "\0";
+           "ISO8859-2" "\0" "ISO-8859-2" "\0"
+           "ISO8859-4" "\0" "ISO-8859-4" "\0"
+           "ISO8859-5" "\0" "ISO-8859-5" "\0"
+           "ISO8859-7" "\0" "ISO-8859-7" "\0"
+           "ISO8859-9" "\0" "ISO-8859-9" "\0"
+           "ISO8859-13" "\0" "ISO-8859-13" "\0"
+           "ISO8859-15" "\0" "ISO-8859-15" "\0"
+           "KOI8-R" "\0" "KOI8-R" "\0"
+           "KOI8-U" "\0" "KOI8-U" "\0"
+           "CP866" "\0" "CP866" "\0"
+           "CP949" "\0" "CP949" "\0"
+           "CP1131" "\0" "CP1131" "\0"
+           "CP1251" "\0" "CP1251" "\0"
+           "eucCN" "\0" "GB2312" "\0"
+           "GB2312" "\0" "GB2312" "\0"
+           "eucJP" "\0" "EUC-JP" "\0"
+           "eucKR" "\0" "EUC-KR" "\0"
+           "Big5" "\0" "BIG5" "\0"
+           "Big5HKSCS" "\0" "BIG5-HKSCS" "\0"
+           "GBK" "\0" "GBK" "\0"
+           "GB18030" "\0" "GB18030" "\0"
+           "SJIS" "\0" "SHIFT_JIS" "\0"
+           "ARMSCII-8" "\0" "ARMSCII-8" "\0"
+           "PT154" "\0" "PT154" "\0"
+         /*"ISCII-DEV" "\0" "?" "\0"*/
+           "*" "\0" "UTF-8" "\0";
 # endif
 
 # if defined VMS
       /* To avoid the troubles of an extra file charset.alias_vms in the
-	 sources of many GNU packages, simply inline the aliases here.  */
+         sources of many GNU packages, simply inline the aliases here.  */
       /* The list of encodings is taken from the OpenVMS 7.3-1 documentation
-	 "Compaq C Run-Time Library Reference Manual for OpenVMS systems"
-	 section 10.7 "Handling Different Character Sets".  */
+         "Compaq C Run-Time Library Reference Manual for OpenVMS systems"
+         section 10.7 "Handling Different Character Sets".  */
       cp = "ISO8859-1" "\0" "ISO-8859-1" "\0"
-	   "ISO8859-2" "\0" "ISO-8859-2" "\0"
-	   "ISO8859-5" "\0" "ISO-8859-5" "\0"
-	   "ISO8859-7" "\0" "ISO-8859-7" "\0"
-	   "ISO8859-8" "\0" "ISO-8859-8" "\0"
-	   "ISO8859-9" "\0" "ISO-8859-9" "\0"
-	   /* Japanese */
-	   "eucJP" "\0" "EUC-JP" "\0"
-	   "SJIS" "\0" "SHIFT_JIS" "\0"
-	   "DECKANJI" "\0" "DEC-KANJI" "\0"
-	   "SDECKANJI" "\0" "EUC-JP" "\0"
-	   /* Chinese */
-	   "eucTW" "\0" "EUC-TW" "\0"
-	   "DECHANYU" "\0" "DEC-HANYU" "\0"
-	   "DECHANZI" "\0" "GB2312" "\0"
-	   /* Korean */
-	   "DECKOREAN" "\0" "EUC-KR" "\0";
+           "ISO8859-2" "\0" "ISO-8859-2" "\0"
+           "ISO8859-5" "\0" "ISO-8859-5" "\0"
+           "ISO8859-7" "\0" "ISO-8859-7" "\0"
+           "ISO8859-8" "\0" "ISO-8859-8" "\0"
+           "ISO8859-9" "\0" "ISO-8859-9" "\0"
+           /* Japanese */
+           "eucJP" "\0" "EUC-JP" "\0"
+           "SJIS" "\0" "SHIFT_JIS" "\0"
+           "DECKANJI" "\0" "DEC-KANJI" "\0"
+           "SDECKANJI" "\0" "EUC-JP" "\0"
+           /* Chinese */
+           "eucTW" "\0" "EUC-TW" "\0"
+           "DECHANYU" "\0" "DEC-HANYU" "\0"
+           "DECHANZI" "\0" "GB2312" "\0"
+           /* Korean */
+           "DECKOREAN" "\0" "EUC-KR" "\0";
 # endif
 
 # if defined WIN32_NATIVE || defined __CYGWIN__
       /* To avoid the troubles of installing a separate file in the same
-	 directory as the DLL and of retrieving the DLL's directory at
-	 runtime, simply inline the aliases here.  */
+         directory as the DLL and of retrieving the DLL's directory at
+         runtime, simply inline the aliases here.  */
 
       cp = "CP936" "\0" "GBK" "\0"
-	   "CP1361" "\0" "JOHAB" "\0"
-	   "CP20127" "\0" "ASCII" "\0"
-	   "CP20866" "\0" "KOI8-R" "\0"
-	   "CP20936" "\0" "GB2312" "\0"
-	   "CP21866" "\0" "KOI8-RU" "\0"
-	   "CP28591" "\0" "ISO-8859-1" "\0"
-	   "CP28592" "\0" "ISO-8859-2" "\0"
-	   "CP28593" "\0" "ISO-8859-3" "\0"
-	   "CP28594" "\0" "ISO-8859-4" "\0"
-	   "CP28595" "\0" "ISO-8859-5" "\0"
-	   "CP28596" "\0" "ISO-8859-6" "\0"
-	   "CP28597" "\0" "ISO-8859-7" "\0"
-	   "CP28598" "\0" "ISO-8859-8" "\0"
-	   "CP28599" "\0" "ISO-8859-9" "\0"
-	   "CP28605" "\0" "ISO-8859-15" "\0"
-	   "CP38598" "\0" "ISO-8859-8" "\0"
-	   "CP51932" "\0" "EUC-JP" "\0"
-	   "CP51936" "\0" "GB2312" "\0"
-	   "CP51949" "\0" "EUC-KR" "\0"
-	   "CP51950" "\0" "EUC-TW" "\0"
-	   "CP54936" "\0" "GB18030" "\0"
-	   "CP65001" "\0" "UTF-8" "\0";
+           "CP1361" "\0" "JOHAB" "\0"
+           "CP20127" "\0" "ASCII" "\0"
+           "CP20866" "\0" "KOI8-R" "\0"
+           "CP20936" "\0" "GB2312" "\0"
+           "CP21866" "\0" "KOI8-RU" "\0"
+           "CP28591" "\0" "ISO-8859-1" "\0"
+           "CP28592" "\0" "ISO-8859-2" "\0"
+           "CP28593" "\0" "ISO-8859-3" "\0"
+           "CP28594" "\0" "ISO-8859-4" "\0"
+           "CP28595" "\0" "ISO-8859-5" "\0"
+           "CP28596" "\0" "ISO-8859-6" "\0"
+           "CP28597" "\0" "ISO-8859-7" "\0"
+           "CP28598" "\0" "ISO-8859-8" "\0"
+           "CP28599" "\0" "ISO-8859-9" "\0"
+           "CP28605" "\0" "ISO-8859-15" "\0"
+           "CP38598" "\0" "ISO-8859-8" "\0"
+           "CP51932" "\0" "EUC-JP" "\0"
+           "CP51936" "\0" "GB2312" "\0"
+           "CP51949" "\0" "EUC-KR" "\0"
+           "CP51950" "\0" "EUC-TW" "\0"
+           "CP54936" "\0" "GB18030" "\0"
+           "CP65001" "\0" "UTF-8" "\0";
 # endif
 #endif
 
@@ -335,7 +369,7 @@ locale_charset (void)
   codeset = nl_langinfo (CODESET);
 
 #  ifdef __CYGWIN__
-  /* Cygwin 2006 does not have locales.  nl_langinfo (CODESET) always
+  /* Cygwin 1.5.x does not have locales.  nl_langinfo (CODESET) always
      returns "US-ASCII".  As long as this is not fixed, return the suffix
      of the locale name from the environment variables (if present) or
      the codepage as a number.  */
@@ -346,36 +380,46 @@ locale_charset (void)
 
       locale = getenv ("LC_ALL");
       if (locale == NULL || locale[0] == '\0')
-	{
-	  locale = getenv ("LC_CTYPE");
-	  if (locale == NULL || locale[0] == '\0')
-	    locale = getenv ("LANG");
-	}
+        {
+          locale = getenv ("LC_CTYPE");
+          if (locale == NULL || locale[0] == '\0')
+            locale = getenv ("LANG");
+        }
       if (locale != NULL && locale[0] != '\0')
-	{
-	  /* If the locale name contains an encoding after the dot, return
-	     it.  */
-	  const char *dot = strchr (locale, '.');
-
-	  if (dot != NULL)
-	    {
-	      const char *modifier;
-
-	      dot++;
-	      /* Look for the possible @... trailer and remove it, if any.  */
-	      modifier = strchr (dot, '@');
-	      if (modifier == NULL)
-		return dot;
-	      if (modifier - dot < sizeof (buf))
-		{
-		  memcpy (buf, dot, modifier - dot);
-		  buf [modifier - dot] = '\0';
-		  return buf;
-		}
-	    }
-	}
-
-      /* Woe32 has a function returning the locale's codepage as a number.  */
+        {
+          /* If the locale name contains an encoding after the dot, return
+             it.  */
+          const char *dot = strchr (locale, '.');
+
+          if (dot != NULL)
+            {
+              const char *modifier;
+
+              dot++;
+              /* Look for the possible @... trailer and remove it, if any.  */
+              modifier = strchr (dot, '@');
+              if (modifier == NULL)
+                return dot;
+              if (modifier - dot < sizeof (buf))
+                {
+                  memcpy (buf, dot, modifier - dot);
+                  buf [modifier - dot] = '\0';
+                  return buf;
+                }
+            }
+        }
+
+      /* Woe32 has a function returning the locale's codepage as a number:
+         GetACP().  This encoding is used by Cygwin, unless the user has set
+         the environment variable CYGWIN=codepage:oem (which very few people
+         do).
+         Output directed to console windows needs to be converted (to
+         GetOEMCP() if the console is using a raster font, or to
+         GetConsoleOutputCP() if it is using a TrueType font).  Cygwin does
+         this conversion transparently (see winsup/cygwin/fhandler_console.cc),
+         converting to GetConsoleOutputCP().  This leads to correct results,
+         except when SetConsoleOutputCP has been called and a raster font is
+         in use.  */
       sprintf (buf, "CP%u", GetACP ());
       codeset = buf;
     }
@@ -397,11 +441,11 @@ locale_charset (void)
     {
       locale = getenv ("LC_ALL");
       if (locale == NULL || locale[0] == '\0')
-	{
-	  locale = getenv ("LC_CTYPE");
-	  if (locale == NULL || locale[0] == '\0')
-	    locale = getenv ("LANG");
-	}
+        {
+          locale = getenv ("LC_CTYPE");
+          if (locale == NULL || locale[0] == '\0')
+            locale = getenv ("LANG");
+        }
     }
 
   /* On some old systems, one used to set locale = "iso8859_1". On others,
@@ -415,7 +459,13 @@ locale_charset (void)
 
   static char buf[2 + 10 + 1];
 
-  /* Woe32 has a function returning the locale's codepage as a number.  */
+  /* Woe32 has a function returning the locale's codepage as a number:
+     GetACP().
+     When the output goes to a console window, it needs to be provided in
+     GetOEMCP() encoding if the console is using a raster font, or in
+     GetConsoleOutputCP() encoding if it is using a TrueType font.
+     But in GUI programs and for output sent to files and pipes, GetACP()
+     encoding is the best bet.  */
   sprintf (buf, "CP%u", GetACP ());
   codeset = buf;
 
@@ -433,7 +483,7 @@ locale_charset (void)
     {
       locale = getenv ("LC_CTYPE");
       if (locale == NULL || locale[0] == '\0')
-	locale = getenv ("LANG");
+        locale = getenv ("LANG");
     }
   if (locale != NULL && locale[0] != '\0')
     {
@@ -441,21 +491,21 @@ locale_charset (void)
       const char *dot = strchr (locale, '.');
 
       if (dot != NULL)
-	{
-	  const char *modifier;
-
-	  dot++;
-	  /* Look for the possible @... trailer and remove it, if any.  */
-	  modifier = strchr (dot, '@');
-	  if (modifier == NULL)
-	    return dot;
-	  if (modifier - dot < sizeof (buf))
-	    {
-	      memcpy (buf, dot, modifier - dot);
-	      buf [modifier - dot] = '\0';
-	      return buf;
-	    }
-	}
+        {
+          const char *modifier;
+
+          dot++;
+          /* Look for the possible @... trailer and remove it, if any.  */
+          modifier = strchr (dot, '@');
+          if (modifier == NULL)
+            return dot;
+          if (modifier - dot < sizeof (buf))
+            {
+              memcpy (buf, dot, modifier - dot);
+              buf [modifier - dot] = '\0';
+              return buf;
+            }
+        }
 
       /* Resolve through the charset.alias file.  */
       codeset = locale;
@@ -464,12 +514,12 @@ locale_charset (void)
     {
       /* OS/2 has a function returning the locale's codepage as a number.  */
       if (DosQueryCp (sizeof (cp), cp, &cplen))
-	codeset = "";
+        codeset = "";
       else
-	{
-	  sprintf (buf, "CP%u", cp[0]);
-	  codeset = buf;
-	}
+        {
+          sprintf (buf, "CP%u", cp[0]);
+          codeset = buf;
+        }
     }
 
 #endif
@@ -483,10 +533,10 @@ locale_charset (void)
        *aliases != '\0';
        aliases += strlen (aliases) + 1, aliases += strlen (aliases) + 1)
     if (strcmp (codeset, aliases) == 0
-	|| (aliases[0] == '*' && aliases[1] == '\0'))
+        || (aliases[0] == '*' && aliases[1] == '\0'))
       {
-	codeset = aliases + strlen (aliases) + 1;
-	break;
+        codeset = aliases + strlen (aliases) + 1;
+        break;
       }
 
   /* Don't return an empty string.  GNU libc and GNU libiconv interpret
diff --git a/libmissing/localcharset.h b/libmissing/localcharset.h
index 1772a50..941b658 100644
--- a/libmissing/localcharset.h
+++ b/libmissing/localcharset.h
@@ -1,5 +1,5 @@
 /* Determine a canonical name for the current locale's character encoding.
-   Copyright (C) 2000-2003 Free Software Foundation, Inc.
+   Copyright (C) 2000-2003, 2009 Free Software Foundation, Inc.
    This file is part of the GNU CHARSET Library.
 
    This program is free software; you can redistribute it and/or modify
diff --git a/libmissing/m4/arpa_inet_h.m4 b/libmissing/m4/arpa_inet_h.m4
index a6e63df..c97b1a8 100644
--- a/libmissing/m4/arpa_inet_h.m4
+++ b/libmissing/m4/arpa_inet_h.m4
@@ -1,5 +1,5 @@
 # arpa_inet_h.m4 serial 5
-dnl Copyright (C) 2006, 2008 Free Software Foundation, Inc.
+dnl Copyright (C) 2006, 2008, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/libmissing/m4/close.m4 b/libmissing/m4/close.m4
index b1189f5..fdcc96b 100644
--- a/libmissing/m4/close.m4
+++ b/libmissing/m4/close.m4
@@ -1,4 +1,4 @@
-# close.m4 serial 3
+# close.m4 serial 5
 dnl Copyright (C) 2008-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -9,6 +9,9 @@ AC_DEFUN([gl_FUNC_CLOSE],
   m4_ifdef([gl_PREREQ_SYS_H_WINSOCK2], [
     gl_PREREQ_SYS_H_WINSOCK2
     if test $UNISTD_H_HAVE_WINSOCK2_H = 1; then
+      dnl Even if the 'socket' module is not used here, another part of the
+      dnl application may use it and pass file descriptors that refer to
+      dnl sockets to the close() function. So enable the support for sockets.
       gl_REPLACE_CLOSE
     fi
   ])
@@ -17,9 +20,7 @@ AC_DEFUN([gl_FUNC_CLOSE],
 AC_DEFUN([gl_REPLACE_CLOSE],
 [
   AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
-  if test $REPLACE_CLOSE != 1; then
-    AC_LIBOBJ([close])
-  fi
   REPLACE_CLOSE=1
+  AC_LIBOBJ([close])
   gl_REPLACE_FCLOSE
 ])
diff --git a/libmissing/m4/d-type.m4 b/libmissing/m4/d-type.m4
index 7e99f9c..bceeb95 100644
--- a/libmissing/m4/d-type.m4
+++ b/libmissing/m4/d-type.m4
@@ -1,4 +1,4 @@
-# serial 10
+# serial 11
 
 dnl From Jim Meyering.
 dnl
@@ -13,16 +13,14 @@ dnl
 
 AC_DEFUN([gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE],
   [AC_CACHE_CHECK([for d_type member in directory struct],
-		  gl_cv_struct_dirent_d_type,
-     [AC_TRY_LINK(dnl
-       [
+                  gl_cv_struct_dirent_d_type,
+     [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
 #include <sys/types.h>
 #include <dirent.h>
-       ],
-       [struct dirent dp; dp.d_type = 0;],
-
-       gl_cv_struct_dirent_d_type=yes,
-       gl_cv_struct_dirent_d_type=no)
+         ]],
+         [[struct dirent dp; dp.d_type = 0;]])],
+       [gl_cv_struct_dirent_d_type=yes],
+       [gl_cv_struct_dirent_d_type=no])
      ]
    )
    if test $gl_cv_struct_dirent_d_type = yes; then
diff --git a/libmissing/m4/dirent_h.m4 b/libmissing/m4/dirent_h.m4
index e507e3d..481212b 100644
--- a/libmissing/m4/dirent_h.m4
+++ b/libmissing/m4/dirent_h.m4
@@ -1,4 +1,4 @@
-# dirent_h.m4 serial 4
+# dirent_h.m4 serial 7
 dnl Copyright (C) 2008-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -12,6 +12,8 @@ AC_DEFUN([gl_DIRENT_H],
   dnl once only, before all statements that occur in other macros.
   AC_REQUIRE([gl_DIRENT_H_DEFAULTS])
 
+  dnl Execute this unconditionally, because DIRENT_H may be set by other
+  dnl modules, after this code is executed.
   gl_CHECK_NEXT_HEADERS([dirent.h])
 ])
 
@@ -32,12 +34,17 @@ AC_DEFUN([gl_DIRENT_MODULE_INDICATOR],
 AC_DEFUN([gl_DIRENT_H_DEFAULTS],
 [
   AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) dnl for REPLACE_FCHDIR
-  GNULIB_DIRFD=0;     AC_SUBST([GNULIB_DIRFD])
-  GNULIB_SCANDIR=0;   AC_SUBST([GNULIB_SCANDIR])
-  GNULIB_ALPHASORT=0; AC_SUBST([GNULIB_ALPHASORT])
+  GNULIB_DIRFD=0;       AC_SUBST([GNULIB_DIRFD])
+  GNULIB_FDOPENDIR=0;   AC_SUBST([GNULIB_FDOPENDIR])
+  GNULIB_SCANDIR=0;     AC_SUBST([GNULIB_SCANDIR])
+  GNULIB_ALPHASORT=0;   AC_SUBST([GNULIB_ALPHASORT])
   dnl Assume proper GNU behavior unless another module says otherwise.
-  HAVE_DECL_DIRFD=1; AC_SUBST([HAVE_DECL_DIRFD])
-  HAVE_SCANDIR=1;    AC_SUBST([HAVE_SCANDIR])
-  HAVE_ALPHASORT=1;  AC_SUBST([HAVE_ALPHASORT])
-  DIRENT_H='';       AC_SUBST([DIRENT_H])
+  HAVE_DECL_DIRFD=1;    AC_SUBST([HAVE_DECL_DIRFD])
+  HAVE_FDOPENDIR=1;     AC_SUBST([HAVE_FDOPENDIR])
+  HAVE_SCANDIR=1;       AC_SUBST([HAVE_SCANDIR])
+  HAVE_ALPHASORT=1;     AC_SUBST([HAVE_ALPHASORT])
+  REPLACE_CLOSEDIR=0;   AC_SUBST([REPLACE_CLOSEDIR])
+  REPLACE_FDOPENDIR=0;  AC_SUBST([REPLACE_FDOPENDIR])
+  REPLACE_OPENDIR=0;    AC_SUBST([REPLACE_OPENDIR])
+  DIRENT_H='';          AC_SUBST([DIRENT_H])
 ])
diff --git a/libmissing/m4/dirfd.m4 b/libmissing/m4/dirfd.m4
index 5f845f5..fe0975d 100644
--- a/libmissing/m4/dirfd.m4
+++ b/libmissing/m4/dirfd.m4
@@ -1,4 +1,4 @@
-# serial 16   -*- Autoconf -*-
+# serial 17   -*- Autoconf -*-
 
 dnl Find out how to get the file descriptor associated with an open DIR*.
 
@@ -46,34 +46,34 @@ AC_DEFUN([gl_FUNC_DIRFD],
       = no,no,no; then
     AC_REPLACE_FUNCS([dirfd])
     AC_CACHE_CHECK(
-	      [how to get the file descriptor associated with an open DIR*],
-		   gl_cv_sys_dir_fd_member_name,
+              [how to get the file descriptor associated with an open DIR*],
+                   gl_cv_sys_dir_fd_member_name,
       [
-	dirfd_save_CFLAGS=$CFLAGS
-	for ac_expr in d_fd dd_fd; do
+        dirfd_save_CFLAGS=$CFLAGS
+        for ac_expr in d_fd dd_fd; do
 
-	  CFLAGS="$CFLAGS -DDIR_FD_MEMBER_NAME=$ac_expr"
-	  AC_TRY_COMPILE(
-	    [#include <sys/types.h>
-	     #include <dirent.h>],
-	    [DIR *dir_p = opendir("."); (void) dir_p->DIR_FD_MEMBER_NAME;],
-	    dir_fd_found=yes
-	  )
-	  CFLAGS=$dirfd_save_CFLAGS
-	  test "$dir_fd_found" = yes && break
-	done
-	test "$dir_fd_found" = yes || ac_expr=no_such_member
+          CFLAGS="$CFLAGS -DDIR_FD_MEMBER_NAME=$ac_expr"
+          AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+             #include <sys/types.h>
+             #include <dirent.h>]],
+            [[DIR *dir_p = opendir("."); (void) dir_p->DIR_FD_MEMBER_NAME;]])],
+            [dir_fd_found=yes]
+          )
+          CFLAGS=$dirfd_save_CFLAGS
+          test "$dir_fd_found" = yes && break
+        done
+        test "$dir_fd_found" = yes || ac_expr=no_such_member
 
-	gl_cv_sys_dir_fd_member_name=$ac_expr
+        gl_cv_sys_dir_fd_member_name=$ac_expr
       ]
     )
     if test $gl_cv_sys_dir_fd_member_name != no_such_member; then
       AC_DEFINE_UNQUOTED([DIR_FD_MEMBER_NAME],
-	$gl_cv_sys_dir_fd_member_name,
-	[the name of the file descriptor member of DIR])
+        $gl_cv_sys_dir_fd_member_name,
+        [the name of the file descriptor member of DIR])
     fi
     AH_VERBATIM(DIR_TO_FD,
-		[#ifdef DIR_FD_MEMBER_NAME
+                [#ifdef DIR_FD_MEMBER_NAME
 # define DIR_TO_FD(Dir_p) ((Dir_p)->DIR_FD_MEMBER_NAME)
 #else
 # define DIR_TO_FD(Dir_p) -1
diff --git a/libmissing/m4/extensions.m4 b/libmissing/m4/extensions.m4
index ba6d5e1..ac19b36 100644
--- a/libmissing/m4/extensions.m4
+++ b/libmissing/m4/extensions.m4
@@ -1,4 +1,4 @@
-# serial 8  -*- Autoconf -*-
+# serial 9  -*- Autoconf -*-
 # Enable extensions on systems that normally disable them.
 
 # Copyright (C) 2003, 2006-2009 Free Software Foundation, Inc.
@@ -12,6 +12,20 @@
 # enough in this area it's likely we'll need to redefine
 # AC_USE_SYSTEM_EXTENSIONS for quite some time.
 
+# If autoconf reports a warning
+#     warning: AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS
+# or  warning: AC_RUN_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS
+# the fix is
+#   1) to ensure that AC_USE_SYSTEM_EXTENSIONS is never directly invoked
+#      but always AC_REQUIREd,
+#   2) to ensure that for each occurrence of
+#        AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+#      or
+#        AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+#      the corresponding gnulib module description has 'extensions' among
+#      its dependencies. This will ensure that the gl_USE_SYSTEM_EXTENSIONS
+#      invocation occurs in gl_EARLY, not in gl_INIT.
+
 # AC_USE_SYSTEM_EXTENSIONS
 # ------------------------
 # Enable extensions on systems that normally disable them,
@@ -74,8 +88,8 @@ AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
     [ac_cv_safe_to_define___extensions__],
     [AC_COMPILE_IFELSE(
        [AC_LANG_PROGRAM([[
-#	  define __EXTENSIONS__ 1
-	  ]AC_INCLUDES_DEFAULT])],
+#         define __EXTENSIONS__ 1
+          ]AC_INCLUDES_DEFAULT])],
        [ac_cv_safe_to_define___extensions__=yes],
        [ac_cv_safe_to_define___extensions__=no])])
   test $ac_cv_safe_to_define___extensions__ = yes &&
diff --git a/libmissing/m4/fclose.m4 b/libmissing/m4/fclose.m4
index d10c104..ab2986f 100644
--- a/libmissing/m4/fclose.m4
+++ b/libmissing/m4/fclose.m4
@@ -1,5 +1,5 @@
-# fclose.m4 serial 1
-dnl Copyright (C) 2008 Free Software Foundation, Inc.
+# fclose.m4 serial 2
+dnl Copyright (C) 2008-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -11,8 +11,6 @@ AC_DEFUN([gl_FUNC_FCLOSE],
 AC_DEFUN([gl_REPLACE_FCLOSE],
 [
   AC_REQUIRE([gl_STDIO_H_DEFAULTS])
-  if test $REPLACE_FCLOSE != 1; then
-    AC_LIBOBJ([fclose])
-  fi
   REPLACE_FCLOSE=1
+  AC_LIBOBJ([fclose])
 ])
diff --git a/libmissing/m4/fcntl-o.m4 b/libmissing/m4/fcntl-o.m4
new file mode 100644
index 0000000..10d564c
--- /dev/null
+++ b/libmissing/m4/fcntl-o.m4
@@ -0,0 +1,81 @@
+# fcntl-o.m4 serial 1
+dnl Copyright (C) 2006, 2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl Written by Paul Eggert.
+
+# Test whether the flags O_NOATIME and O_NOFOLLOW actually work.
+# Define HAVE_WORKING_O_NOATIME to 1 if O_NOATIME works, or to 0 otherwise.
+# Define HAVE_WORKING_O_NOFOLLOW to 1 if O_NOFOLLOW works, or to 0 otherwise.
+AC_DEFUN([gl_FCNTL_O_FLAGS],
+[
+  dnl Persuade glibc <fcntl.h> to define O_NOATIME and O_NOFOLLOW.
+  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+  AC_CACHE_CHECK([for working fcntl.h], [gl_cv_header_working_fcntl_h],
+    [AC_RUN_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <sys/types.h>
+           #include <sys/stat.h>
+           #include <unistd.h>
+           #include <fcntl.h>
+           #ifndef O_NOATIME
+            #define O_NOATIME 0
+           #endif
+           #ifndef O_NOFOLLOW
+            #define O_NOFOLLOW 0
+           #endif
+           static int const constants[] =
+            {
+              O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND,
+              O_NONBLOCK, O_SYNC, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY
+            };
+          ]],
+          [[
+            int status = !constants;
+            {
+              static char const sym[] = "conftest.sym";
+              if (symlink (".", sym) != 0
+                  || close (open (sym, O_RDONLY | O_NOFOLLOW)) == 0)
+                status |= 32;
+              unlink (sym);
+            }
+            {
+              static char const file[] = "confdefs.h";
+              int fd = open (file, O_RDONLY | O_NOATIME);
+              char c;
+              struct stat st0, st1;
+              if (fd < 0
+                  || fstat (fd, &st0) != 0
+                  || sleep (1) != 0
+                  || read (fd, &c, 1) != 1
+                  || close (fd) != 0
+                  || stat (file, &st1) != 0
+                  || st0.st_atime != st1.st_atime)
+                status |= 64;
+            }
+            return status;]])],
+       [gl_cv_header_working_fcntl_h=yes],
+       [case $? in #(
+        32) gl_cv_header_working_fcntl_h='no (bad O_NOFOLLOW)';; #(
+        64) gl_cv_header_working_fcntl_h='no (bad O_NOATIME)';; #(
+        96) gl_cv_header_working_fcntl_h='no (bad O_NOATIME, O_NOFOLLOW)';; #(
+         *) gl_cv_header_working_fcntl_h='no';;
+        esac],
+       [gl_cv_header_working_fcntl_h=cross-compiling])])
+
+  case $gl_cv_header_working_fcntl_h in #(
+  *O_NOATIME* | no | cross-compiling) ac_val=0;; #(
+  *) ac_val=1;;
+  esac
+  AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOATIME], [$ac_val],
+    [Define to 1 if O_NOATIME works.])
+
+  case $gl_cv_header_working_fcntl_h in #(
+  *O_NOFOLLOW* | no | cross-compiling) ac_val=0;; #(
+  *) ac_val=1;;
+  esac
+  AC_DEFINE_UNQUOTED([HAVE_WORKING_O_NOFOLLOW], [$ac_val],
+    [Define to 1 if O_NOFOLLOW works.])
+])
diff --git a/libmissing/m4/float_h.m4 b/libmissing/m4/float_h.m4
index d36e3a4..6cdc3f1 100644
--- a/libmissing/m4/float_h.m4
+++ b/libmissing/m4/float_h.m4
@@ -1,5 +1,5 @@
 # float_h.m4 serial 3
-dnl Copyright (C) 2007 Free Software Foundation, Inc.
+dnl Copyright (C) 2007, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/libmissing/m4/getaddrinfo.m4 b/libmissing/m4/getaddrinfo.m4
index 4088671..4445072 100644
--- a/libmissing/m4/getaddrinfo.m4
+++ b/libmissing/m4/getaddrinfo.m4
@@ -1,4 +1,4 @@
-# getaddrinfo.m4 serial 20
+# getaddrinfo.m4 serial 22
 dnl Copyright (C) 2004-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -25,7 +25,7 @@ AC_DEFUN([gl_GETADDRINFO],
   LIBS="$gai_saved_LIBS $GETADDRINFO_LIB"
 
   AC_CACHE_CHECK([for getaddrinfo], [gl_cv_func_getaddrinfo], [
-    AC_TRY_LINK([
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([[
 #include <sys/types.h>
 #ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
@@ -34,21 +34,21 @@ AC_DEFUN([gl_GETADDRINFO],
 #include <netdb.h>
 #endif
 #include <stddef.h>
-], [getaddrinfo("", "", NULL, NULL);],
+]], [[getaddrinfo("", "", NULL, NULL);]])],
       [gl_cv_func_getaddrinfo=yes],
       [gl_cv_func_getaddrinfo=no])])
   if test $gl_cv_func_getaddrinfo = no; then
     AC_CACHE_CHECK([for getaddrinfo in ws2tcpip.h and -lws2_32],
-		   gl_cv_w32_getaddrinfo, [
+                   gl_cv_w32_getaddrinfo, [
       gl_cv_w32_getaddrinfo=no
       am_save_LIBS="$LIBS"
       LIBS="$LIBS -lws2_32"
-      AC_TRY_LINK([
+      AC_LINK_IFELSE([AC_LANG_PROGRAM([[
 #ifdef HAVE_WS2TCPIP_H
 #include <ws2tcpip.h>
 #endif
 #include <stddef.h>
-], [getaddrinfo(NULL, NULL, NULL, NULL);], gl_cv_w32_getaddrinfo=yes)
+]], [[getaddrinfo(NULL, NULL, NULL, NULL);]])], [gl_cv_w32_getaddrinfo=yes])
       LIBS="$am_save_LIBS"
     ])
     if test "$gl_cv_w32_getaddrinfo" = "yes"; then
@@ -64,7 +64,7 @@ AC_DEFUN([gl_GETADDRINFO],
   # header included somehow.
   AC_CACHE_CHECK([for gai_strerror (possibly via ws2tcpip.h)],
     gl_cv_func_gai_strerror, [
-      AC_TRY_LINK([
+      AC_LINK_IFELSE([AC_LANG_PROGRAM([[
 #include <sys/types.h>
 #ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
@@ -76,7 +76,7 @@ AC_DEFUN([gl_GETADDRINFO],
 #include <ws2tcpip.h>
 #endif
 #include <stddef.h>
-], [gai_strerror (NULL);],
+]], [[gai_strerror (NULL);]])],
         [gl_cv_func_gai_strerror=yes],
         [gl_cv_func_gai_strerror=no])])
   if test $gl_cv_func_gai_strerror = no; then
@@ -96,6 +96,7 @@ AC_DEFUN([gl_PREREQ_GETADDRINFO], [
   AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
   AC_REQUIRE([gl_HOSTENT]) dnl for HOSTENT_LIB
   AC_REQUIRE([gl_SERVENT]) dnl for SERVENT_LIB
+  AC_REQUIRE([gl_INET_NTOP]) dnl for INET_NTOP_LIB
   AC_REQUIRE([AC_C_RESTRICT])
   AC_REQUIRE([gl_SOCKET_FAMILIES])
   AC_REQUIRE([gl_HEADER_SYS_SOCKET])
@@ -163,4 +164,10 @@ AC_DEFUN([gl_PREREQ_GETADDRINFO], [
     *" $SERVENT_LIB "*) ;;
     *) GETADDRINFO_LIB="$GETADDRINFO_LIB $SERVENT_LIB" ;;
   esac
+
+  dnl Append $INET_NTOP_LIB to GETADDRINFO_LIB, avoiding gratuitous duplicates.
+  case " $GETADDRINFO_LIB " in
+    *" $INET_NTOP_LIB "*) ;;
+    *) GETADDRINFO_LIB="$GETADDRINFO_LIB $INET_NTOP_LIB" ;;
+  esac
 ])
diff --git a/libmissing/m4/getlogin_r.m4 b/libmissing/m4/getlogin_r.m4
index 8e5a2a3..eaa8caf 100644
--- a/libmissing/m4/getlogin_r.m4
+++ b/libmissing/m4/getlogin_r.m4
@@ -1,6 +1,6 @@
 #serial 4
 
-# Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
+# Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
diff --git a/libmissing/m4/getpagesize.m4 b/libmissing/m4/getpagesize.m4
deleted file mode 100644
index 0d07a3a..0000000
--- a/libmissing/m4/getpagesize.m4
+++ /dev/null
@@ -1,29 +0,0 @@
-# getpagesize.m4 serial 7
-dnl Copyright (C) 2002, 2004-2005, 2007 Free Software Foundation, Inc.
-dnl This file is free software; the Free Software Foundation
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-AC_DEFUN([gl_FUNC_GETPAGESIZE],
-[
-  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
-  AC_REQUIRE([AC_CANONICAL_HOST])
-  AC_CHECK_FUNCS([getpagesize])
-  if test $ac_cv_func_getpagesize = no; then
-    HAVE_GETPAGESIZE=0
-    AC_CHECK_HEADERS([OS.h])
-    if test $ac_cv_header_OS_h = yes; then
-      HAVE_OS_H=1
-    fi
-    AC_CHECK_HEADERS([sys/param.h])
-    if test $ac_cv_header_sys_param_h = yes; then
-      HAVE_SYS_PARAM_H=1
-    fi
-  fi
-  case "$host_os" in
-    mingw*)
-      REPLACE_GETPAGESIZE=1
-      AC_LIBOBJ([getpagesize])
-      ;;
-  esac
-])
diff --git a/libmissing/m4/glibc21.m4 b/libmissing/m4/glibc21.m4
index 93fbf47..2d36015 100644
--- a/libmissing/m4/glibc21.m4
+++ b/libmissing/m4/glibc21.m4
@@ -1,5 +1,5 @@
 # glibc21.m4 serial 4
-dnl Copyright (C) 2000-2002, 2004, 2008 Free Software Foundation, Inc.
+dnl Copyright (C) 2000-2002, 2004, 2008-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -12,16 +12,16 @@ AC_DEFUN([gl_GLIBC21],
     AC_CACHE_CHECK([whether we are using the GNU C Library 2.1 or newer],
       [ac_cv_gnu_library_2_1],
       [AC_EGREP_CPP([Lucky GNU user],
-	[
+        [
 #include <features.h>
 #ifdef __GNU_LIBRARY__
  #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
   Lucky GNU user
  #endif
 #endif
-	],
-	[ac_cv_gnu_library_2_1=yes],
-	[ac_cv_gnu_library_2_1=no])
+        ],
+        [ac_cv_gnu_library_2_1=yes],
+        [ac_cv_gnu_library_2_1=no])
       ]
     )
     AC_SUBST([GLIBC21])
diff --git a/libmissing/m4/glob.m4 b/libmissing/m4/glob.m4
index bc3e67c..18d0efa 100644
--- a/libmissing/m4/glob.m4
+++ b/libmissing/m4/glob.m4
@@ -1,5 +1,5 @@
 # glob.m4 serial 10
-dnl Copyright (C) 2005-2007 Free Software Foundation, Inc.
+dnl Copyright (C) 2005-2007, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -27,8 +27,8 @@ AC_DEFUN([gl_GLOB],
 [     AC_COMPILE_IFELSE(
 [[#include <gnu-versions.h>
 char a[_GNU_GLOB_INTERFACE_VERSION == 1 ? 1 : -1];]],
-	[gl_cv_gnu_glob_interface_version_1=yes],
-	[gl_cv_gnu_glob_interface_version_1=no])])
+        [gl_cv_gnu_glob_interface_version_1=yes],
+        [gl_cv_gnu_glob_interface_version_1=no])])
 
     if test "$gl_cv_gnu_glob_interface_version_1" = "no"; then
       GLOB_H=glob.h
diff --git a/libmissing/m4/gnulib-cache.m4 b/libmissing/m4/gnulib-cache.m4
index 8f26ddc..d41ea3b 100644
--- a/libmissing/m4/gnulib-cache.m4
+++ b/libmissing/m4/gnulib-cache.m4
@@ -15,7 +15,7 @@
 
 
 # Specification in the form of a command-line invocation:
-#   gnulib-tool --import --dir=. --lib=libmissing --source-base=libmissing --m4-base=libmissing/m4 --doc-base=libmissing/doc --tests-base=libmissing/tests --aux-dir=. --with-tests --lgpl --libtool --macro-prefix=gl --no-vc-files bind close fnmatch-gnu getaddrinfo glob inet_ntop mktime pathmax recvfrom servent sigaction sleep snprintf socket socklen strptime strsep sys_select
+#   gnulib-tool --import --dir=. --lib=libmissing --source-base=libmissing --m4-base=libmissing/m4 --doc-base=libmissing/doc --tests-base=libmissing/tests --aux-dir=. --with-tests --lgpl --libtool --macro-prefix=gl --no-vc-files bind close fnmatch-gnu getaddrinfo glob iconv inet_ntop mktime nl_langinfo pathmax recvfrom servent sigaction sleep snprintf socket socklen strptime strsep sys_select
 
 # Specification in the form of a few gnulib-tool.m4 macro invocations:
 gl_LOCAL_DIR([])
@@ -25,8 +25,10 @@ gl_MODULES([
   fnmatch-gnu
   getaddrinfo
   glob
+  iconv
   inet_ntop
   mktime
+  nl_langinfo
   pathmax
   recvfrom
   servent
diff --git a/libmissing/m4/gnulib-common.m4 b/libmissing/m4/gnulib-common.m4
index c8fda20..63c6300 100644
--- a/libmissing/m4/gnulib-common.m4
+++ b/libmissing/m4/gnulib-common.m4
@@ -23,14 +23,17 @@ AC_DEFUN([gl_COMMON_BODY], [
 # define __GNUC_STDC_INLINE__ 1
 #endif])
   AH_VERBATIM([unused_parameter],
-[/* Define as a marker that can be attached to function parameter declarations
-   for parameters that are not used.  This helps to reduce warnings, such as
-   from GCC -Wunused-parameter.  */
+[/* Define as a marker that can be attached to declarations that might not
+    be used.  This helps to reduce warnings, such as from
+    GCC -Wunused-parameter.  */
 #if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
-# define _UNUSED_PARAMETER_ __attribute__ ((__unused__))
+# define _GL_UNUSED __attribute__ ((__unused__))
 #else
-# define _UNUSED_PARAMETER_
+# define _GL_UNUSED
 #endif
+/* The name _UNUSED_PARAMETER_ is an earlier spelling, although the name
+   is a misnomer outside of parameter lists.  */
+#define _UNUSED_PARAMETER_ _GL_UNUSED
 ])
 ])
 
@@ -70,13 +73,13 @@ AC_DEFUN([AC_C_RESTRICT],
    for ac_kw in __restrict __restrict__ _Restrict restrict; do
      AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
       [[typedef int * int_ptr;
-	int foo (int_ptr $ac_kw ip) {
-	return ip[0];
+        int foo (int_ptr $ac_kw ip) {
+        return ip[0];
        }]],
       [[int s[1];
-	int * $ac_kw t = s;
-	t[0] = 0;
-	return foo(t)]])],
+        int * $ac_kw t = s;
+        t[0] = 0;
+        return foo(t)]])],
       [ac_cv_c_restrict=$ac_kw])
      test "$ac_cv_c_restrict" != no && break
    done
diff --git a/libmissing/m4/gnulib-comp.m4 b/libmissing/m4/gnulib-comp.m4
index 0be0ee1..a948c8f 100644
--- a/libmissing/m4/gnulib-comp.m4
+++ b/libmissing/m4/gnulib-comp.m4
@@ -42,7 +42,7 @@ AC_DEFUN([gl_INIT],
   gl_COMMON
   gl_source_base='libmissing'
 changequote(,)dnl
-LTALLOCA=`echo "$ALLOCA" | sed 's/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'`
+LTALLOCA=`echo "$ALLOCA" | sed -e 's/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'`
 changequote([, ])dnl
 AC_SUBST([LTALLOCA])
   gl_FUNC_ALLOCA
@@ -69,8 +69,6 @@ AC_SUBST([LTALLOCA])
   gl_NETDB_MODULE_INDICATOR([getaddrinfo])
   gl_GETLOGIN_R
   gl_UNISTD_MODULE_INDICATOR([getlogin_r])
-  gl_FUNC_GETPAGESIZE
-  gl_UNISTD_MODULE_INDICATOR([getpagesize])
   AC_REQUIRE([gl_HEADER_SYS_SOCKET])
   if test "$ac_cv_header_winsock2_h" = yes; then
     AC_LIBOBJ([getpeername])
@@ -80,8 +78,10 @@ AC_SUBST([LTALLOCA])
   AC_SUBST([LTLIBINTL])
   gl_GLOB
   gl_HOSTENT
+  AM_ICONV
   gl_INET_NTOP
   gl_ARPA_INET_MODULE_INDICATOR([inet_ntop])
+  gl_LANGINFO_H
   gl_LOCALCHARSET
   LOCALCHARSET_TESTS_ENVIRONMENT="CHARSETALIASDIR=\"\$(top_builddir)/$gl_source_base\""
   AC_SUBST([LOCALCHARSET_TESTS_ENVIRONMENT])
@@ -102,6 +102,8 @@ AC_SUBST([LTALLOCA])
   gl_HEADER_NETDB
   gl_HEADER_NETINET_IN
   AC_PROG_MKDIR_P
+  gl_FUNC_NL_LANGINFO
+  gl_LANGINFO_MODULE_INDICATOR([nl_langinfo])
   gl_PATHMAX
   AC_REQUIRE([gl_HEADER_SYS_SOCKET])
   if test "$ac_cv_header_winsock2_h" = yes; then
@@ -123,9 +125,20 @@ AC_SUBST([LTALLOCA])
   if test "$ac_cv_header_winsock2_h" = yes; then
     AC_LIBOBJ([socket])
   fi
+  # When this module is used, sockets may actually occur as file descriptors,
+  # hence it is worth warning if the modules 'close' and 'ioctl' are not used.
+  m4_ifdef([gl_UNISTD_H_DEFAULTS], [AC_REQUIRE([gl_UNISTD_H_DEFAULTS])])
+  m4_ifdef([gl_SYS_IOCTL_H_DEFAULTS], [AC_REQUIRE([gl_SYS_IOCTL_H_DEFAULTS])])
+  AC_REQUIRE([gl_PREREQ_SYS_H_WINSOCK2])
+  if test "$ac_cv_header_winsock2_h" = yes; then
+    UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=1
+    SYS_IOCTL_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=1
+  fi
   gl_SYS_SOCKET_MODULE_INDICATOR([socket])
+  gl_SOCKETS
   gl_TYPE_SOCKLEN_T
   AM_STDBOOL_H
+  gl_STDDEF_H
   gl_STDINT_H
   gl_STDIO_H
   gl_STDLIB_H
@@ -172,7 +185,7 @@ AC_SUBST([LTALLOCA])
     if test -n "$gl_LIBOBJS"; then
       # Remove the extension.
       sed_drop_objext='s/\.o$//;s/\.obj$//'
-      for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed "$sed_drop_objext" | sort | uniq`; do
+      for i in `for i in $gl_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do
         gl_libobjs="$gl_libobjs $i.$ac_objext"
         gl_ltlibobjs="$gl_ltlibobjs $i.lo"
       done
@@ -190,6 +203,9 @@ AC_SUBST([LTALLOCA])
   gl_COMMON
   gl_source_base='libmissing/tests'
   gt_LOCALE_FR
+  gt_LOCALE_TR_UTF8
+  AC_C_BIGENDIAN
+  gt_LOCALE_FR
   gt_LOCALE_FR_UTF8
   gt_LOCALE_JA
   gt_LOCALE_ZH_CN
@@ -198,11 +214,14 @@ AC_SUBST([LTALLOCA])
   gt_LOCALE_FR_UTF8
   gt_LOCALE_JA
   gt_LOCALE_ZH_CN
+  gt_LOCALE_FR
+  gt_LOCALE_FR_UTF8
+  AC_CHECK_DECLS_ONCE([alarm])
   gt_TYPE_WCHAR_T
   gt_TYPE_WINT_T
   gl_FUNC_STRERROR
   gl_STRING_MODULE_INDICATOR([strerror])
-  AC_CHECK_FUNCS([shutdown])
+  AC_CHECK_FUNCS_ONCE([shutdown])
   gl_FUNC_WCTOB
   gl_WCHAR_MODULE_INDICATOR([wctob])
   m4_ifval(gltests_LIBSOURCES_LIST, [
@@ -227,7 +246,7 @@ AC_SUBST([LTALLOCA])
     if test -n "$gltests_LIBOBJS"; then
       # Remove the extension.
       sed_drop_objext='s/\.o$//;s/\.obj$//'
-      for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed "$sed_drop_objext" | sort | uniq`; do
+      for i in `for i in $gltests_LIBOBJS; do echo "$i"; done | sed -e "$sed_drop_objext" | sort | uniq`; do
         gltests_libobjs="$gltests_libobjs $i.$ac_objext"
         gltests_ltlibobjs="$gltests_ltlibobjs $i.lo"
       done
@@ -296,6 +315,8 @@ AC_DEFUN([gltests_LIBSOURCES], [
 # This macro records the list of files which have been installed by
 # gnulib-tool and may be removed by future gnulib-tool invocations.
 AC_DEFUN([gl_FILE_LIST], [
+  build-aux/arg-nonnull.h
+  build-aux/config.rpath
   build-aux/link-warning.h
   lib/alignof.h
   lib/alloca.c
@@ -319,13 +340,13 @@ AC_DEFUN([gl_FILE_LIST], [
   lib/gai_strerror.c
   lib/getaddrinfo.c
   lib/getlogin_r.c
-  lib/getpagesize.c
   lib/getpeername.c
   lib/gettext.h
   lib/glob-libc.h
   lib/glob.c
   lib/glob.in.h
   lib/inet_ntop.c
+  lib/langinfo.in.h
   lib/localcharset.c
   lib/localcharset.h
   lib/malloc.c
@@ -336,9 +357,11 @@ AC_DEFUN([gl_FILE_LIST], [
   lib/memchr.c
   lib/memchr.valgrind
   lib/mempcpy.c
+  lib/mktime-internal.h
   lib/mktime.c
   lib/netdb.in.h
   lib/netinet_in.in.h
+  lib/nl_langinfo.c
   lib/pathmax.h
   lib/printf-args.c
   lib/printf-args.h
@@ -355,7 +378,10 @@ AC_DEFUN([gl_FILE_LIST], [
   lib/sleep.c
   lib/snprintf.c
   lib/socket.c
+  lib/sockets.c
+  lib/sockets.h
   lib/stdbool.in.h
+  lib/stddef.in.h
   lib/stdint.in.h
   lib/stdio-write.c
   lib/stdio.in.h
@@ -394,22 +420,28 @@ AC_DEFUN([gl_FILE_LIST], [
   m4/errno_h.m4
   m4/extensions.m4
   m4/fclose.m4
+  m4/fcntl-o.m4
   m4/float_h.m4
   m4/fnmatch.m4
   m4/getaddrinfo.m4
   m4/getlogin_r.m4
-  m4/getpagesize.m4
   m4/glibc21.m4
   m4/glob.m4
   m4/gnulib-common.m4
   m4/hostent.m4
+  m4/iconv.m4
   m4/include_next.m4
   m4/inet_ntop.m4
   m4/intmax_t.m4
   m4/inttypes_h.m4
+  m4/langinfo_h.m4
+  m4/lib-ld.m4
+  m4/lib-link.m4
+  m4/lib-prefix.m4
   m4/localcharset.m4
   m4/locale-fr.m4
   m4/locale-ja.m4
+  m4/locale-tr.m4
   m4/locale-zh.m4
   m4/longlong.m4
   m4/malloc.m4
@@ -424,6 +456,7 @@ AC_DEFUN([gl_FILE_LIST], [
   m4/multiarch.m4
   m4/netdb_h.m4
   m4/netinet_in_h.m4
+  m4/nl_langinfo.m4
   m4/onceonly.m4
   m4/pathmax.m4
   m4/printf.m4
@@ -434,9 +467,11 @@ AC_DEFUN([gl_FILE_LIST], [
   m4/size_max.m4
   m4/sleep.m4
   m4/snprintf.m4
+  m4/sockets.m4
   m4/socklen.m4
   m4/sockpfaf.m4
   m4/stdbool.m4
+  m4/stddef_h.m4
   m4/stdint.m4
   m4/stdint_h.m4
   m4/stdio_h.m4
@@ -462,13 +497,23 @@ AC_DEFUN([gl_FILE_LIST], [
   m4/wctype.m4
   m4/wint_t.m4
   m4/xsize.m4
+  tests/macros.h
+  tests/signature.h
   tests/test-alignof.c
   tests/test-alloca-opt.c
   tests/test-arpa_inet.c
+  tests/test-c-ctype.c
+  tests/test-c-strcase.sh
+  tests/test-c-strcasecmp.c
+  tests/test-c-strncasecmp.c
+  tests/test-dirent.c
   tests/test-errno.c
   tests/test-fnmatch.c
   tests/test-getaddrinfo.c
   tests/test-glob.c
+  tests/test-iconv.c
+  tests/test-inet_ntop.c
+  tests/test-langinfo.c
   tests/test-mbrtowc.c
   tests/test-mbrtowc1.sh
   tests/test-mbrtowc2.sh
@@ -484,11 +529,15 @@ AC_DEFUN([gl_FILE_LIST], [
   tests/test-memchr.c
   tests/test-netdb.c
   tests/test-netinet_in.c
+  tests/test-nl_langinfo.c
+  tests/test-nl_langinfo.sh
   tests/test-sigaction.c
   tests/test-signal.c
   tests/test-sleep.c
   tests/test-snprintf.c
+  tests/test-sockets.c
   tests/test-stdbool.c
+  tests/test-stddef.c
   tests/test-stdint.c
   tests/test-stdio.c
   tests/test-stdlib.c
@@ -505,7 +554,11 @@ AC_DEFUN([gl_FILE_LIST], [
   tests/test-wchar.c
   tests/test-wctype.c
   tests/zerosize-ptr.h
-  tests=lib/dummy.c
+  tests=lib/c-ctype.c
+  tests=lib/c-ctype.h
+  tests=lib/c-strcase.h
+  tests=lib/c-strcasecmp.c
+  tests=lib/c-strncasecmp.c
   tests=lib/intprops.h
   tests=lib/strerror.c
   tests=lib/wctob.c
diff --git a/libmissing/m4/gnulib-tool.m4 b/libmissing/m4/gnulib-tool.m4
index 4438d48..03b75a9 100644
--- a/libmissing/m4/gnulib-tool.m4
+++ b/libmissing/m4/gnulib-tool.m4
@@ -1,5 +1,5 @@
 # gnulib-tool.m4 serial 2
-dnl Copyright (C) 2004-2005 Free Software Foundation, Inc.
+dnl Copyright (C) 2004-2005, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/libmissing/m4/hostent.m4 b/libmissing/m4/hostent.m4
index 4a96af7..ca16a74 100644
--- a/libmissing/m4/hostent.m4
+++ b/libmissing/m4/hostent.m4
@@ -1,5 +1,5 @@
 # hostent.m4 serial 1
-dnl Copyright (C) 2008 Free Software Foundation, Inc.
+dnl Copyright (C) 2008, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/libmissing/m4/iconv.m4 b/libmissing/m4/iconv.m4
new file mode 100644
index 0000000..ce21b0b
--- /dev/null
+++ b/libmissing/m4/iconv.m4
@@ -0,0 +1,180 @@
+# iconv.m4 serial AM8 (gettext-0.18)
+dnl Copyright (C) 2000-2002, 2007-2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Bruno Haible.
+
+AC_DEFUN([AM_ICONV_LINKFLAGS_BODY],
+[
+  dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
+  AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
+  AC_REQUIRE([AC_LIB_RPATH])
+
+  dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
+  dnl accordingly.
+  AC_LIB_LINKFLAGS_BODY([iconv])
+])
+
+AC_DEFUN([AM_ICONV_LINK],
+[
+  dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
+  dnl those with the standalone portable GNU libiconv installed).
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+
+  dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
+  dnl accordingly.
+  AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
+
+  dnl Add $INCICONV to CPPFLAGS before performing the following checks,
+  dnl because if the user has installed libiconv and not disabled its use
+  dnl via --without-libiconv-prefix, he wants to use it. The first
+  dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed.
+  am_save_CPPFLAGS="$CPPFLAGS"
+  AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
+
+  AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [
+    am_cv_func_iconv="no, consider installing GNU libiconv"
+    am_cv_lib_iconv=no
+    AC_TRY_LINK([#include <stdlib.h>
+#include <iconv.h>],
+      [iconv_t cd = iconv_open("","");
+       iconv(cd,NULL,NULL,NULL,NULL);
+       iconv_close(cd);],
+      [am_cv_func_iconv=yes])
+    if test "$am_cv_func_iconv" != yes; then
+      am_save_LIBS="$LIBS"
+      LIBS="$LIBS $LIBICONV"
+      AC_TRY_LINK([#include <stdlib.h>
+#include <iconv.h>],
+        [iconv_t cd = iconv_open("","");
+         iconv(cd,NULL,NULL,NULL,NULL);
+         iconv_close(cd);],
+        [am_cv_lib_iconv=yes]
+        [am_cv_func_iconv=yes])
+      LIBS="$am_save_LIBS"
+    fi
+  ])
+  if test "$am_cv_func_iconv" = yes; then
+    AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [
+      dnl This tests against bugs in AIX 5.1 and HP-UX 11.11.
+      am_save_LIBS="$LIBS"
+      if test $am_cv_lib_iconv = yes; then
+        LIBS="$LIBS $LIBICONV"
+      fi
+      AC_TRY_RUN([
+#include <iconv.h>
+#include <string.h>
+int main ()
+{
+  /* Test against AIX 5.1 bug: Failures are not distinguishable from successful
+     returns.  */
+  {
+    iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8");
+    if (cd_utf8_to_88591 != (iconv_t)(-1))
+      {
+        static const char input[] = "\342\202\254"; /* EURO SIGN */
+        char buf[10];
+        const char *inptr = input;
+        size_t inbytesleft = strlen (input);
+        char *outptr = buf;
+        size_t outbytesleft = sizeof (buf);
+        size_t res = iconv (cd_utf8_to_88591,
+                            (char **) &inptr, &inbytesleft,
+                            &outptr, &outbytesleft);
+        if (res == 0)
+          return 1;
+      }
+  }
+#if 0 /* This bug could be worked around by the caller.  */
+  /* Test against HP-UX 11.11 bug: Positive return value instead of 0.  */
+  {
+    iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591");
+    if (cd_88591_to_utf8 != (iconv_t)(-1))
+      {
+        static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
+        char buf[50];
+        const char *inptr = input;
+        size_t inbytesleft = strlen (input);
+        char *outptr = buf;
+        size_t outbytesleft = sizeof (buf);
+        size_t res = iconv (cd_88591_to_utf8,
+                            (char **) &inptr, &inbytesleft,
+                            &outptr, &outbytesleft);
+        if ((int)res > 0)
+          return 1;
+      }
+  }
+#endif
+  /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is
+     provided.  */
+  if (/* Try standardized names.  */
+      iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1)
+      /* Try IRIX, OSF/1 names.  */
+      && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1)
+      /* Try AIX names.  */
+      && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1)
+      /* Try HP-UX names.  */
+      && iconv_open ("utf8", "eucJP") == (iconv_t)(-1))
+    return 1;
+  return 0;
+}], [am_cv_func_iconv_works=yes], [am_cv_func_iconv_works=no],
+        [case "$host_os" in
+           aix* | hpux*) am_cv_func_iconv_works="guessing no" ;;
+           *)            am_cv_func_iconv_works="guessing yes" ;;
+         esac])
+      LIBS="$am_save_LIBS"
+    ])
+    case "$am_cv_func_iconv_works" in
+      *no) am_func_iconv=no am_cv_lib_iconv=no ;;
+      *)   am_func_iconv=yes ;;
+    esac
+  else
+    am_func_iconv=no am_cv_lib_iconv=no
+  fi
+  if test "$am_func_iconv" = yes; then
+    AC_DEFINE([HAVE_ICONV], [1],
+      [Define if you have the iconv() function and it works.])
+  fi
+  if test "$am_cv_lib_iconv" = yes; then
+    AC_MSG_CHECKING([how to link with libiconv])
+    AC_MSG_RESULT([$LIBICONV])
+  else
+    dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV
+    dnl either.
+    CPPFLAGS="$am_save_CPPFLAGS"
+    LIBICONV=
+    LTLIBICONV=
+  fi
+  AC_SUBST([LIBICONV])
+  AC_SUBST([LTLIBICONV])
+])
+
+AC_DEFUN([AM_ICONV],
+[
+  AM_ICONV_LINK
+  if test "$am_cv_func_iconv" = yes; then
+    AC_MSG_CHECKING([for iconv declaration])
+    AC_CACHE_VAL([am_cv_proto_iconv], [
+      AC_TRY_COMPILE([
+#include <stdlib.h>
+#include <iconv.h>
+extern
+#ifdef __cplusplus
+"C"
+#endif
+#if defined(__STDC__) || defined(__cplusplus)
+size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
+#else
+size_t iconv();
+#endif
+], [], [am_cv_proto_iconv_arg1=""], [am_cv_proto_iconv_arg1="const"])
+      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);"])
+    am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
+    AC_MSG_RESULT([
+         $am_cv_proto_iconv])
+    AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1],
+      [Define as const if the declaration of iconv() needs const.])
+  fi
+])
diff --git a/libmissing/m4/include_next.m4 b/libmissing/m4/include_next.m4
index 5e22ded..2e6273f 100644
--- a/libmissing/m4/include_next.m4
+++ b/libmissing/m4/include_next.m4
@@ -109,11 +109,11 @@ EOF
 # be
 # '"///usr/include/foo.h"', or whatever other absolute file name is suitable.
 # That way, a header file with the following line:
-#	#@INCLUDE_NEXT@ @NEXT_FOO_H@
+#       #@INCLUDE_NEXT@ @NEXT_FOO_H@
 # or
-#	#@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_FOO_H@
+#       #@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_FOO_H@
 # behaves (after sed substitution) as if it contained
-#	#include_next <foo.h>
+#       #include_next <foo.h>
 # even if the compiler does not support include_next.
 # The three "///" are to pacify Sun C 5.8, which otherwise would say
 # "warning: #include of /usr/include/... may be non-portable".
@@ -129,46 +129,46 @@ AC_DEFUN([gl_CHECK_NEXT_HEADERS],
 
   m4_foreach_w([gl_HEADER_NAME], [$1],
     [AS_VAR_PUSHDEF([gl_next_header],
-		    [gl_cv_next_]m4_defn([gl_HEADER_NAME]))
+                    [gl_cv_next_]m4_defn([gl_HEADER_NAME]))
      if test $gl_cv_have_include_next = yes; then
        AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
      else
        AC_CACHE_CHECK(
-	 [absolute name of <]m4_defn([gl_HEADER_NAME])[>],
-	 m4_defn([gl_next_header]),
-	 [AS_VAR_PUSHDEF([gl_header_exists],
-			 [ac_cv_header_]m4_defn([gl_HEADER_NAME]))
-	  if test AS_VAR_GET(gl_header_exists) = yes; then
-	    AC_LANG_CONFTEST(
-	      [AC_LANG_SOURCE(
-		 [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]]
-	       )])
-	    dnl AIX "xlc -E" and "cc -E" omit #line directives for header files
-	    dnl that contain only a #include of other header files and no
-	    dnl non-comment tokens of their own. This leads to a failure to
-	    dnl detect the absolute name of <dirent.h>, <signal.h>, <poll.h>
-	    dnl and others. The workaround is to force preservation of comments
-	    dnl through option -C. This ensures all necessary #line directives
-	    dnl are present. GCC supports option -C as well.
-	    case "$host_os" in
-	      aix*) gl_absname_cpp="$ac_cpp -C" ;;
-	      *)    gl_absname_cpp="$ac_cpp" ;;
-	    esac
-	    dnl eval is necessary to expand gl_absname_cpp.
-	    dnl Ultrix and Pyramid sh refuse to redirect output of eval,
-	    dnl so use subshell.
-	    AS_VAR_SET([gl_next_header],
-	      ['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
-	       sed -n '\#/]m4_defn([gl_HEADER_NAME])[#{
-		 s#.*"\(.*/]m4_defn([gl_HEADER_NAME])[\)".*#\1#
-		 s#^/[^/]#//&#
-		 p
-		 q
-	       }'`'"'])
-	  else
-	    AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
-	  fi
-	  AS_VAR_POPDEF([gl_header_exists])])
+         [absolute name of <]m4_defn([gl_HEADER_NAME])[>],
+         m4_defn([gl_next_header]),
+         [AS_VAR_PUSHDEF([gl_header_exists],
+                         [ac_cv_header_]m4_defn([gl_HEADER_NAME]))
+          if test AS_VAR_GET(gl_header_exists) = yes; then
+            AC_LANG_CONFTEST(
+              [AC_LANG_SOURCE(
+                 [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]]
+               )])
+            dnl AIX "xlc -E" and "cc -E" omit #line directives for header files
+            dnl that contain only a #include of other header files and no
+            dnl non-comment tokens of their own. This leads to a failure to
+            dnl detect the absolute name of <dirent.h>, <signal.h>, <poll.h>
+            dnl and others. The workaround is to force preservation of comments
+            dnl through option -C. This ensures all necessary #line directives
+            dnl are present. GCC supports option -C as well.
+            case "$host_os" in
+              aix*) gl_absname_cpp="$ac_cpp -C" ;;
+              *)    gl_absname_cpp="$ac_cpp" ;;
+            esac
+            dnl eval is necessary to expand gl_absname_cpp.
+            dnl Ultrix and Pyramid sh refuse to redirect output of eval,
+            dnl so use subshell.
+            AS_VAR_SET([gl_next_header],
+              ['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
+               sed -n '\#/]m4_defn([gl_HEADER_NAME])[#{
+                 s#.*"\(.*/]m4_defn([gl_HEADER_NAME])[\)".*#\1#
+                 s#^/[^/]#//&#
+                 p
+                 q
+               }'`'"'])
+          else
+            AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
+          fi
+          AS_VAR_POPDEF([gl_header_exists])])
      fi
      AC_SUBST(
        AS_TR_CPP([NEXT_]m4_defn([gl_HEADER_NAME])),
diff --git a/libmissing/m4/inet_ntop.m4 b/libmissing/m4/inet_ntop.m4
index 2bbdca1..2a8ff20 100644
--- a/libmissing/m4/inet_ntop.m4
+++ b/libmissing/m4/inet_ntop.m4
@@ -1,4 +1,4 @@
-# inet_ntop.m4 serial 9
+# inet_ntop.m4 serial 11
 dnl Copyright (C) 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -11,17 +11,18 @@ AC_DEFUN([gl_INET_NTOP],
 
   gl_REPLACE_ARPA_INET_H
 
-  dnl The AC_SEARCH_LIBS call is a hack to persuade the Solaris 8 linker to
-  dnl find inet_ntop.
-  dnl
-  dnl It is the responsibility of gl_INET_NTOP's caller to arrange for
-  dnl -lnsl if it is needed.  Normally -lnsl is not needed on Solaris 8,
-  dnl since inet_ntop is needed only by getaddrinfo, and getaddrinfo
-  dnl isn't built on Solaris 8.
+  dnl Most platforms that provide inet_ntop define it in libc.
+  dnl Solaris 8..10 provide inet_ntop in libnsl instead.
   gl_save_LIBS=$LIBS
   AC_SEARCH_LIBS([inet_ntop], [nsl], [],
     [AC_REPLACE_FUNCS([inet_ntop])])
   LIBS=$gl_save_LIBS
+  INET_NTOP_LIB=
+  if test "$ac_cv_search_inet_ntop" != "no" &&
+     test "$ac_cv_search_inet_ntop" != "none required"; then
+    INET_NTOP_LIB="$ac_cv_search_inet_ntop"
+  fi
+  AC_SUBST([INET_NTOP_LIB])
 
   gl_PREREQ_INET_NTOP
 ])
diff --git a/libmissing/m4/langinfo_h.m4 b/libmissing/m4/langinfo_h.m4
new file mode 100644
index 0000000..4975734
--- /dev/null
+++ b/libmissing/m4/langinfo_h.m4
@@ -0,0 +1,76 @@
+# langinfo_h.m4 serial 1
+dnl Copyright (C) 2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_LANGINFO_H],
+[
+  AC_REQUIRE([gl_LANGINFO_H_DEFAULTS])
+
+  dnl Persuade glibc-2.0.6 <langinfo.h> to define CODESET.
+  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
+  gl_CHECK_NEXT_HEADERS([langinfo.h])
+
+  dnl Determine whether <langinfo.h> exists. It is missing on mingw and BeOS.
+  HAVE_LANGINFO_CODESET=0
+  HAVE_LANGINFO_ERA=0
+  AC_CHECK_HEADERS_ONCE([langinfo.h])
+  if test $ac_cv_header_langinfo_h = yes; then
+    HAVE_LANGINFO_H=1
+    dnl Determine what <langinfo.h> defines. CODESET and ERA etc. are missing
+    dnl on OpenBSD 3.8.
+    AC_CACHE_CHECK([whether langinfo.h defines CODESET],
+      [gl_cv_header_langinfo_codeset],
+      [AC_COMPILE_IFELSE(
+         [AC_LANG_PROGRAM([[#include <langinfo.h>
+int a = CODESET;
+]])],
+         [gl_cv_header_langinfo_codeset=yes],
+         [gl_cv_header_langinfo_codeset=no])
+      ])
+    if test $gl_cv_header_langinfo_codeset = yes; then
+      HAVE_LANGINFO_CODESET=1
+    fi
+    AC_CACHE_CHECK([whether langinfo.h defines ERA],
+      [gl_cv_header_langinfo_era],
+      [AC_COMPILE_IFELSE(
+         [AC_LANG_PROGRAM([[#include <langinfo.h>
+int a = ERA;
+]])],
+         [gl_cv_header_langinfo_era=yes],
+         [gl_cv_header_langinfo_era=no])
+      ])
+    if test $gl_cv_header_langinfo_era = yes; then
+      HAVE_LANGINFO_ERA=1
+    fi
+  else
+    HAVE_LANGINFO_H=0
+  fi
+  AC_SUBST([HAVE_LANGINFO_H])
+  AC_SUBST([HAVE_LANGINFO_CODESET])
+  AC_SUBST([HAVE_LANGINFO_ERA])
+
+  if test $HAVE_LANGINFO_H = 1 && test $HAVE_LANGINFO_CODESET = 1 && test $HAVE_LANGINFO_ERA = 1; then
+    LANGINFO_H=
+  else
+    LANGINFO_H='langinfo.h'
+  fi
+  AC_SUBST([LANGINFO_H])
+])
+
+AC_DEFUN([gl_LANGINFO_MODULE_INDICATOR],
+[
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+  AC_REQUIRE([gl_LANGINFO_H_DEFAULTS])
+  GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
+])
+
+AC_DEFUN([gl_LANGINFO_H_DEFAULTS],
+[
+  GNULIB_NL_LANGINFO=0;  AC_SUBST([GNULIB_NL_LANGINFO])
+  dnl Assume proper GNU behavior unless another module says otherwise.
+  HAVE_NL_LANGINFO=1;    AC_SUBST([HAVE_NL_LANGINFO])
+  REPLACE_NL_LANGINFO=0; AC_SUBST([REPLACE_NL_LANGINFO])
+])
diff --git a/libmissing/m4/lib-ld.m4 b/libmissing/m4/lib-ld.m4
new file mode 100644
index 0000000..4b4db07
--- /dev/null
+++ b/libmissing/m4/lib-ld.m4
@@ -0,0 +1,110 @@
+# lib-ld.m4 serial 4 (gettext-0.18)
+dnl Copyright (C) 1996-2003, 2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl Subroutines of libtool.m4,
+dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision
+dnl with libtool.m4.
+
+dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no.
+AC_DEFUN([AC_LIB_PROG_LD_GNU],
+[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], [acl_cv_prog_gnu_ld],
+[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+  acl_cv_prog_gnu_ld=yes ;;
+*)
+  acl_cv_prog_gnu_ld=no ;;
+esac])
+with_gnu_ld=$acl_cv_prog_gnu_ld
+])
+
+dnl From libtool-1.4. Sets the variable LD.
+AC_DEFUN([AC_LIB_PROG_LD],
+[AC_ARG_WITH([gnu-ld],
+[  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]],
+test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+# Prepare PATH_SEPARATOR.
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  echo "#! /bin/sh" >conf$$.sh
+  echo  "exit 0"   >>conf$$.sh
+  chmod +x conf$$.sh
+  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+    PATH_SEPARATOR=';'
+  else
+    PATH_SEPARATOR=:
+  fi
+  rm -f conf$$.sh
+fi
+ac_prog=ld
+if test "$GCC" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  AC_MSG_CHECKING([for ld used by GCC])
+  case $host in
+  *-*-mingw*)
+    # gcc leaves a trailing carriage return which upsets mingw
+    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+  *)
+    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+  esac
+  case $ac_prog in
+    # Accept absolute paths.
+    [[\\/]* | [A-Za-z]:[\\/]*)]
+      [re_direlt='/[^/][^/]*/\.\./']
+      # Canonicalize the path of ld
+      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
+      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+        ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+  "")
+    # If it fails, then pretend we aren't using GCC.
+    ac_prog=ld
+    ;;
+  *)
+    # If it is relative, then search for the first ld in PATH.
+    with_gnu_ld=unknown
+    ;;
+  esac
+elif test "$with_gnu_ld" = yes; then
+  AC_MSG_CHECKING([for GNU ld])
+else
+  AC_MSG_CHECKING([for non-GNU ld])
+fi
+AC_CACHE_VAL([acl_cv_path_LD],
+[if test -z "$LD"; then
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
+  for ac_dir in $PATH; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      acl_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some GNU ld's only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in
+      *GNU* | *'with BFD'*)
+        test "$with_gnu_ld" != no && break ;;
+      *)
+        test "$with_gnu_ld" != yes && break ;;
+      esac
+    fi
+  done
+  IFS="$ac_save_ifs"
+else
+  acl_cv_path_LD="$LD" # Let the user override the test with a path.
+fi])
+LD="$acl_cv_path_LD"
+if test -n "$LD"; then
+  AC_MSG_RESULT([$LD])
+else
+  AC_MSG_RESULT([no])
+fi
+test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
+AC_LIB_PROG_LD_GNU
+])
diff --git a/libmissing/m4/lib-link.m4 b/libmissing/m4/lib-link.m4
new file mode 100644
index 0000000..2f8b7ff
--- /dev/null
+++ b/libmissing/m4/lib-link.m4
@@ -0,0 +1,764 @@
+# lib-link.m4 serial 20 (gettext-0.18)
+dnl Copyright (C) 2001-2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Bruno Haible.
+
+AC_PREREQ([2.54])
+
+dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
+dnl the libraries corresponding to explicit and implicit dependencies.
+dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
+dnl augments the CPPFLAGS variable.
+dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
+dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
+AC_DEFUN([AC_LIB_LINKFLAGS],
+[
+  AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
+  AC_REQUIRE([AC_LIB_RPATH])
+  pushdef([Name],[translit([$1],[./-], [___])])
+  pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
+                                [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
+  AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
+    AC_LIB_LINKFLAGS_BODY([$1], [$2])
+    ac_cv_lib[]Name[]_libs="$LIB[]NAME"
+    ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
+    ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
+    ac_cv_lib[]Name[]_prefix="$LIB[]NAME[]_PREFIX"
+  ])
+  LIB[]NAME="$ac_cv_lib[]Name[]_libs"
+  LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs"
+  INC[]NAME="$ac_cv_lib[]Name[]_cppflags"
+  LIB[]NAME[]_PREFIX="$ac_cv_lib[]Name[]_prefix"
+  AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
+  AC_SUBST([LIB]NAME)
+  AC_SUBST([LTLIB]NAME)
+  AC_SUBST([LIB]NAME[_PREFIX])
+  dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
+  dnl results of this search when this library appears as a dependency.
+  HAVE_LIB[]NAME=yes
+  popdef([NAME])
+  popdef([Name])
+])
+
+dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode, [missing-message])
+dnl searches for libname and the libraries corresponding to explicit and
+dnl implicit dependencies, together with the specified include files and
+dnl the ability to compile and link the specified testcode. The missing-message
+dnl defaults to 'no' and may contain additional hints for the user.
+dnl If found, it sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME}
+dnl and LTLIB${NAME} variables and augments the CPPFLAGS variable, and
+dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs
+dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty.
+dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
+dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
+AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
+[
+  AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
+  AC_REQUIRE([AC_LIB_RPATH])
+  pushdef([Name],[translit([$1],[./-], [___])])
+  pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
+                                [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
+
+  dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
+  dnl accordingly.
+  AC_LIB_LINKFLAGS_BODY([$1], [$2])
+
+  dnl Add $INC[]NAME to CPPFLAGS before performing the following checks,
+  dnl because if the user has installed lib[]Name and not disabled its use
+  dnl via --without-lib[]Name-prefix, he wants to use it.
+  ac_save_CPPFLAGS="$CPPFLAGS"
+  AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
+
+  AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
+    ac_save_LIBS="$LIBS"
+    LIBS="$LIBS $LIB[]NAME"
+    AC_TRY_LINK([$3], [$4],
+      [ac_cv_lib[]Name=yes],
+      [ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])'])
+    LIBS="$ac_save_LIBS"
+  ])
+  if test "$ac_cv_lib[]Name" = yes; then
+    HAVE_LIB[]NAME=yes
+    AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the lib][$1 library.])
+    AC_MSG_CHECKING([how to link with lib[]$1])
+    AC_MSG_RESULT([$LIB[]NAME])
+  else
+    HAVE_LIB[]NAME=no
+    dnl If $LIB[]NAME didn't lead to a usable library, we don't need
+    dnl $INC[]NAME either.
+    CPPFLAGS="$ac_save_CPPFLAGS"
+    LIB[]NAME=
+    LTLIB[]NAME=
+    LIB[]NAME[]_PREFIX=
+  fi
+  AC_SUBST([HAVE_LIB]NAME)
+  AC_SUBST([LIB]NAME)
+  AC_SUBST([LTLIB]NAME)
+  AC_SUBST([LIB]NAME[_PREFIX])
+  popdef([NAME])
+  popdef([Name])
+])
+
+dnl Determine the platform dependent parameters needed to use rpath:
+dnl   acl_libext,
+dnl   acl_shlibext,
+dnl   acl_hardcode_libdir_flag_spec,
+dnl   acl_hardcode_libdir_separator,
+dnl   acl_hardcode_direct,
+dnl   acl_hardcode_minus_L.
+AC_DEFUN([AC_LIB_RPATH],
+[
+  dnl Tell automake >= 1.10 to complain if config.rpath is missing.
+  m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])])
+  AC_REQUIRE([AC_PROG_CC])                dnl we use $CC, $GCC, $LDFLAGS
+  AC_REQUIRE([AC_LIB_PROG_LD])            dnl we use $LD, $with_gnu_ld
+  AC_REQUIRE([AC_CANONICAL_HOST])         dnl we use $host
+  AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
+  AC_CACHE_CHECK([for shared library run path origin], [acl_cv_rpath], [
+    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
+    ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
+    . ./conftest.sh
+    rm -f ./conftest.sh
+    acl_cv_rpath=done
+  ])
+  wl="$acl_cv_wl"
+  acl_libext="$acl_cv_libext"
+  acl_shlibext="$acl_cv_shlibext"
+  acl_libname_spec="$acl_cv_libname_spec"
+  acl_library_names_spec="$acl_cv_library_names_spec"
+  acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
+  acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
+  acl_hardcode_direct="$acl_cv_hardcode_direct"
+  acl_hardcode_minus_L="$acl_cv_hardcode_minus_L"
+  dnl Determine whether the user wants rpath handling at all.
+  AC_ARG_ENABLE([rpath],
+    [  --disable-rpath         do not hardcode runtime library paths],
+    :, enable_rpath=yes)
+])
+
+dnl AC_LIB_FROMPACKAGE(name, package)
+dnl declares that libname comes from the given package. The configure file
+dnl will then not have a --with-libname-prefix option but a
+dnl --with-package-prefix option. Several libraries can come from the same
+dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar
+dnl macro call that searches for libname.
+AC_DEFUN([AC_LIB_FROMPACKAGE],
+[
+  pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
+                                [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
+  define([acl_frompackage_]NAME, [$2])
+  popdef([NAME])
+  pushdef([PACK],[$2])
+  pushdef([PACKUP],[translit(PACK,[abcdefghijklmnopqrstuvwxyz./-],
+                                  [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
+  define([acl_libsinpackage_]PACKUP,
+    m4_ifdef([acl_libsinpackage_]PACKUP, [acl_libsinpackage_]PACKUP[[, ]],)[lib$1])
+  popdef([PACKUP])
+  popdef([PACK])
+])
+
+dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
+dnl the libraries corresponding to explicit and implicit dependencies.
+dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
+dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found
+dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
+AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
+[
+  AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
+  pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
+                                [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
+  pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])])
+  pushdef([PACKUP],[translit(PACK,[abcdefghijklmnopqrstuvwxyz./-],
+                                  [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
+  pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])])
+  dnl Autoconf >= 2.61 supports dots in --with options.
+  pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[translit(PACK,[.],[_])],PACK)])
+  dnl By default, look in $includedir and $libdir.
+  use_additional=yes
+  AC_LIB_WITH_FINAL_PREFIX([
+    eval additional_includedir=\"$includedir\"
+    eval additional_libdir=\"$libdir\"
+  ])
+  AC_ARG_WITH(P_A_C_K[-prefix],
+[[  --with-]]P_A_C_K[[-prefix[=DIR]  search for ]PACKLIBS[ in DIR/include and DIR/lib
+  --without-]]P_A_C_K[[-prefix     don't search for ]PACKLIBS[ in includedir and libdir]],
+[
+    if test "X$withval" = "Xno"; then
+      use_additional=no
+    else
+      if test "X$withval" = "X"; then
+        AC_LIB_WITH_FINAL_PREFIX([
+          eval additional_includedir=\"$includedir\"
+          eval additional_libdir=\"$libdir\"
+        ])
+      else
+        additional_includedir="$withval/include"
+        additional_libdir="$withval/$acl_libdirstem"
+        if test "$acl_libdirstem2" != "$acl_libdirstem" \
+           && ! test -d "$withval/$acl_libdirstem"; then
+          additional_libdir="$withval/$acl_libdirstem2"
+        fi
+      fi
+    fi
+])
+  dnl Search the library and its dependencies in $additional_libdir and
+  dnl $LDFLAGS. Using breadth-first-seach.
+  LIB[]NAME=
+  LTLIB[]NAME=
+  INC[]NAME=
+  LIB[]NAME[]_PREFIX=
+  dnl HAVE_LIB${NAME} is an indicator that LIB${NAME}, LTLIB${NAME} have been
+  dnl computed. So it has to be reset here.
+  HAVE_LIB[]NAME=
+  rpathdirs=
+  ltrpathdirs=
+  names_already_handled=
+  names_next_round='$1 $2'
+  while test -n "$names_next_round"; do
+    names_this_round="$names_next_round"
+    names_next_round=
+    for name in $names_this_round; do
+      already_handled=
+      for n in $names_already_handled; do
+        if test "$n" = "$name"; then
+          already_handled=yes
+          break
+        fi
+      done
+      if test -z "$already_handled"; then
+        names_already_handled="$names_already_handled $name"
+        dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
+        dnl or AC_LIB_HAVE_LINKFLAGS call.
+        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
+        eval value=\"\$HAVE_LIB$uppername\"
+        if test -n "$value"; then
+          if test "$value" = yes; then
+            eval value=\"\$LIB$uppername\"
+            test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
+            eval value=\"\$LTLIB$uppername\"
+            test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
+          else
+            dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
+            dnl that this library doesn't exist. So just drop it.
+            :
+          fi
+        else
+          dnl Search the library lib$name in $additional_libdir and $LDFLAGS
+          dnl and the already constructed $LIBNAME/$LTLIBNAME.
+          found_dir=
+          found_la=
+          found_so=
+          found_a=
+          eval libname=\"$acl_libname_spec\"    # typically: libname=lib$name
+          if test -n "$acl_shlibext"; then
+            shrext=".$acl_shlibext"             # typically: shrext=.so
+          else
+            shrext=
+          fi
+          if test $use_additional = yes; then
+            dir="$additional_libdir"
+            dnl The same code as in the loop below:
+            dnl First look for a shared library.
+            if test -n "$acl_shlibext"; then
+              if test -f "$dir/$libname$shrext"; then
+                found_dir="$dir"
+                found_so="$dir/$libname$shrext"
+              else
+                if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
+                  ver=`(cd "$dir" && \
+                        for f in "$libname$shrext".*; do echo "$f"; done \
+                        | sed -e "s,^$libname$shrext\\\\.,," \
+                        | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
+                        | sed 1q ) 2>/dev/null`
+                  if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
+                    found_dir="$dir"
+                    found_so="$dir/$libname$shrext.$ver"
+                  fi
+                else
+                  eval library_names=\"$acl_library_names_spec\"
+                  for f in $library_names; do
+                    if test -f "$dir/$f"; then
+                      found_dir="$dir"
+                      found_so="$dir/$f"
+                      break
+                    fi
+                  done
+                fi
+              fi
+            fi
+            dnl Then look for a static library.
+            if test "X$found_dir" = "X"; then
+              if test -f "$dir/$libname.$acl_libext"; then
+                found_dir="$dir"
+                found_a="$dir/$libname.$acl_libext"
+              fi
+            fi
+            if test "X$found_dir" != "X"; then
+              if test -f "$dir/$libname.la"; then
+                found_la="$dir/$libname.la"
+              fi
+            fi
+          fi
+          if test "X$found_dir" = "X"; then
+            for x in $LDFLAGS $LTLIB[]NAME; do
+              AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
+              case "$x" in
+                -L*)
+                  dir=`echo "X$x" | sed -e 's/^X-L//'`
+                  dnl First look for a shared library.
+                  if test -n "$acl_shlibext"; then
+                    if test -f "$dir/$libname$shrext"; then
+                      found_dir="$dir"
+                      found_so="$dir/$libname$shrext"
+                    else
+                      if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
+                        ver=`(cd "$dir" && \
+                              for f in "$libname$shrext".*; do echo "$f"; done \
+                              | sed -e "s,^$libname$shrext\\\\.,," \
+                              | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
+                              | sed 1q ) 2>/dev/null`
+                        if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
+                          found_dir="$dir"
+                          found_so="$dir/$libname$shrext.$ver"
+                        fi
+                      else
+                        eval library_names=\"$acl_library_names_spec\"
+                        for f in $library_names; do
+                          if test -f "$dir/$f"; then
+                            found_dir="$dir"
+                            found_so="$dir/$f"
+                            break
+                          fi
+                        done
+                      fi
+                    fi
+                  fi
+                  dnl Then look for a static library.
+                  if test "X$found_dir" = "X"; then
+                    if test -f "$dir/$libname.$acl_libext"; then
+                      found_dir="$dir"
+                      found_a="$dir/$libname.$acl_libext"
+                    fi
+                  fi
+                  if test "X$found_dir" != "X"; then
+                    if test -f "$dir/$libname.la"; then
+                      found_la="$dir/$libname.la"
+                    fi
+                  fi
+                  ;;
+              esac
+              if test "X$found_dir" != "X"; then
+                break
+              fi
+            done
+          fi
+          if test "X$found_dir" != "X"; then
+            dnl Found the library.
+            LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
+            if test "X$found_so" != "X"; then
+              dnl Linking with a shared library. We attempt to hardcode its
+              dnl directory into the executable's runpath, unless it's the
+              dnl standard /usr/lib.
+              if test "$enable_rpath" = no \
+                 || test "X$found_dir" = "X/usr/$acl_libdirstem" \
+                 || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then
+                dnl No hardcoding is needed.
+                LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
+              else
+                dnl Use an explicit option to hardcode DIR into the resulting
+                dnl binary.
+                dnl Potentially add DIR to ltrpathdirs.
+                dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
+                haveit=
+                for x in $ltrpathdirs; do
+                  if test "X$x" = "X$found_dir"; then
+                    haveit=yes
+                    break
+                  fi
+                done
+                if test -z "$haveit"; then
+                  ltrpathdirs="$ltrpathdirs $found_dir"
+                fi
+                dnl The hardcoding into $LIBNAME is system dependent.
+                if test "$acl_hardcode_direct" = yes; then
+                  dnl Using DIR/libNAME.so during linking hardcodes DIR into the
+                  dnl resulting binary.
+                  LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
+                else
+                  if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
+                    dnl Use an explicit option to hardcode DIR into the resulting
+                    dnl binary.
+                    LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
+                    dnl Potentially add DIR to rpathdirs.
+                    dnl The rpathdirs will be appended to $LIBNAME at the end.
+                    haveit=
+                    for x in $rpathdirs; do
+                      if test "X$x" = "X$found_dir"; then
+                        haveit=yes
+                        break
+                      fi
+                    done
+                    if test -z "$haveit"; then
+                      rpathdirs="$rpathdirs $found_dir"
+                    fi
+                  else
+                    dnl Rely on "-L$found_dir".
+                    dnl But don't add it if it's already contained in the LDFLAGS
+                    dnl or the already constructed $LIBNAME
+                    haveit=
+                    for x in $LDFLAGS $LIB[]NAME; do
+                      AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
+                      if test "X$x" = "X-L$found_dir"; then
+                        haveit=yes
+                        break
+                      fi
+                    done
+                    if test -z "$haveit"; then
+                      LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
+                    fi
+                    if test "$acl_hardcode_minus_L" != no; then
+                      dnl FIXME: Not sure whether we should use
+                      dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
+                      dnl here.
+                      LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
+                    else
+                      dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH
+                      dnl here, because this doesn't fit in flags passed to the
+                      dnl compiler. So give up. No hardcoding. This affects only
+                      dnl very old systems.
+                      dnl FIXME: Not sure whether we should use
+                      dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
+                      dnl here.
+                      LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
+                    fi
+                  fi
+                fi
+              fi
+            else
+              if test "X$found_a" != "X"; then
+                dnl Linking with a static library.
+                LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
+              else
+                dnl We shouldn't come here, but anyway it's good to have a
+                dnl fallback.
+                LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
+              fi
+            fi
+            dnl Assume the include files are nearby.
+            additional_includedir=
+            case "$found_dir" in
+              */$acl_libdirstem | */$acl_libdirstem/)
+                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'`
+                if test "$name" = '$1'; then
+                  LIB[]NAME[]_PREFIX="$basedir"
+                fi
+                additional_includedir="$basedir/include"
+                ;;
+              */$acl_libdirstem2 | */$acl_libdirstem2/)
+                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'`
+                if test "$name" = '$1'; then
+                  LIB[]NAME[]_PREFIX="$basedir"
+                fi
+                additional_includedir="$basedir/include"
+                ;;
+            esac
+            if test "X$additional_includedir" != "X"; then
+              dnl Potentially add $additional_includedir to $INCNAME.
+              dnl But don't add it
+              dnl   1. if it's the standard /usr/include,
+              dnl   2. if it's /usr/local/include and we are using GCC on Linux,
+              dnl   3. if it's already present in $CPPFLAGS or the already
+              dnl      constructed $INCNAME,
+              dnl   4. if it doesn't exist as a directory.
+              if test "X$additional_includedir" != "X/usr/include"; then
+                haveit=
+                if test "X$additional_includedir" = "X/usr/local/include"; then
+                  if test -n "$GCC"; then
+                    case $host_os in
+                      linux* | gnu* | k*bsd*-gnu) haveit=yes;;
+                    esac
+                  fi
+                fi
+                if test -z "$haveit"; then
+                  for x in $CPPFLAGS $INC[]NAME; do
+                    AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
+                    if test "X$x" = "X-I$additional_includedir"; then
+                      haveit=yes
+                      break
+                    fi
+                  done
+                  if test -z "$haveit"; then
+                    if test -d "$additional_includedir"; then
+                      dnl Really add $additional_includedir to $INCNAME.
+                      INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
+                    fi
+                  fi
+                fi
+              fi
+            fi
+            dnl Look for dependencies.
+            if test -n "$found_la"; then
+              dnl Read the .la file. It defines the variables
+              dnl dlname, library_names, old_library, dependency_libs, current,
+              dnl age, revision, installed, dlopen, dlpreopen, libdir.
+              save_libdir="$libdir"
+              case "$found_la" in
+                */* | *\\*) . "$found_la" ;;
+                *) . "./$found_la" ;;
+              esac
+              libdir="$save_libdir"
+              dnl We use only dependency_libs.
+              for dep in $dependency_libs; do
+                case "$dep" in
+                  -L*)
+                    additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
+                    dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
+                    dnl But don't add it
+                    dnl   1. if it's the standard /usr/lib,
+                    dnl   2. if it's /usr/local/lib and we are using GCC on Linux,
+                    dnl   3. if it's already present in $LDFLAGS or the already
+                    dnl      constructed $LIBNAME,
+                    dnl   4. if it doesn't exist as a directory.
+                    if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \
+                       && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then
+                      haveit=
+                      if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \
+                         || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then
+                        if test -n "$GCC"; then
+                          case $host_os in
+                            linux* | gnu* | k*bsd*-gnu) haveit=yes;;
+                          esac
+                        fi
+                      fi
+                      if test -z "$haveit"; then
+                        haveit=
+                        for x in $LDFLAGS $LIB[]NAME; do
+                          AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
+                          if test "X$x" = "X-L$additional_libdir"; then
+                            haveit=yes
+                            break
+                          fi
+                        done
+                        if test -z "$haveit"; then
+                          if test -d "$additional_libdir"; then
+                            dnl Really add $additional_libdir to $LIBNAME.
+                            LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
+                          fi
+                        fi
+                        haveit=
+                        for x in $LDFLAGS $LTLIB[]NAME; do
+                          AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
+                          if test "X$x" = "X-L$additional_libdir"; then
+                            haveit=yes
+                            break
+                          fi
+                        done
+                        if test -z "$haveit"; then
+                          if test -d "$additional_libdir"; then
+                            dnl Really add $additional_libdir to $LTLIBNAME.
+                            LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
+                          fi
+                        fi
+                      fi
+                    fi
+                    ;;
+                  -R*)
+                    dir=`echo "X$dep" | sed -e 's/^X-R//'`
+                    if test "$enable_rpath" != no; then
+                      dnl Potentially add DIR to rpathdirs.
+                      dnl The rpathdirs will be appended to $LIBNAME at the end.
+                      haveit=
+                      for x in $rpathdirs; do
+                        if test "X$x" = "X$dir"; then
+                          haveit=yes
+                          break
+                        fi
+                      done
+                      if test -z "$haveit"; then
+                        rpathdirs="$rpathdirs $dir"
+                      fi
+                      dnl Potentially add DIR to ltrpathdirs.
+                      dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
+                      haveit=
+                      for x in $ltrpathdirs; do
+                        if test "X$x" = "X$dir"; then
+                          haveit=yes
+                          break
+                        fi
+                      done
+                      if test -z "$haveit"; then
+                        ltrpathdirs="$ltrpathdirs $dir"
+                      fi
+                    fi
+                    ;;
+                  -l*)
+                    dnl Handle this in the next round.
+                    names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
+                    ;;
+                  *.la)
+                    dnl Handle this in the next round. Throw away the .la's
+                    dnl directory; it is already contained in a preceding -L
+                    dnl option.
+                    names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
+                    ;;
+                  *)
+                    dnl Most likely an immediate library name.
+                    LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
+                    LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
+                    ;;
+                esac
+              done
+            fi
+          else
+            dnl Didn't find the library; assume it is in the system directories
+            dnl known to the linker and runtime loader. (All the system
+            dnl directories known to the linker should also be known to the
+            dnl runtime loader, otherwise the system is severely misconfigured.)
+            LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
+            LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
+          fi
+        fi
+      fi
+    done
+  done
+  if test "X$rpathdirs" != "X"; then
+    if test -n "$acl_hardcode_libdir_separator"; then
+      dnl Weird platform: only the last -rpath option counts, the user must
+      dnl pass all path elements in one option. We can arrange that for a
+      dnl single library, but not when more than one $LIBNAMEs are used.
+      alldirs=
+      for found_dir in $rpathdirs; do
+        alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir"
+      done
+      dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl.
+      acl_save_libdir="$libdir"
+      libdir="$alldirs"
+      eval flag=\"$acl_hardcode_libdir_flag_spec\"
+      libdir="$acl_save_libdir"
+      LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
+    else
+      dnl The -rpath options are cumulative.
+      for found_dir in $rpathdirs; do
+        acl_save_libdir="$libdir"
+        libdir="$found_dir"
+        eval flag=\"$acl_hardcode_libdir_flag_spec\"
+        libdir="$acl_save_libdir"
+        LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
+      done
+    fi
+  fi
+  if test "X$ltrpathdirs" != "X"; then
+    dnl When using libtool, the option that works for both libraries and
+    dnl executables is -R. The -R options are cumulative.
+    for found_dir in $ltrpathdirs; do
+      LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
+    done
+  fi
+  popdef([P_A_C_K])
+  popdef([PACKLIBS])
+  popdef([PACKUP])
+  popdef([PACK])
+  popdef([NAME])
+])
+
+dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
+dnl unless already present in VAR.
+dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
+dnl contains two or three consecutive elements that belong together.
+AC_DEFUN([AC_LIB_APPENDTOVAR],
+[
+  for element in [$2]; do
+    haveit=
+    for x in $[$1]; do
+      AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
+      if test "X$x" = "X$element"; then
+        haveit=yes
+        break
+      fi
+    done
+    if test -z "$haveit"; then
+      [$1]="${[$1]}${[$1]:+ }$element"
+    fi
+  done
+])
+
+dnl For those cases where a variable contains several -L and -l options
+dnl referring to unknown libraries and directories, this macro determines the
+dnl necessary additional linker options for the runtime path.
+dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL])
+dnl sets LDADDVAR to linker options needed together with LIBSVALUE.
+dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed,
+dnl otherwise linking without libtool is assumed.
+AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
+[
+  AC_REQUIRE([AC_LIB_RPATH])
+  AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
+  $1=
+  if test "$enable_rpath" != no; then
+    if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
+      dnl Use an explicit option to hardcode directories into the resulting
+      dnl binary.
+      rpathdirs=
+      next=
+      for opt in $2; do
+        if test -n "$next"; then
+          dir="$next"
+          dnl No need to hardcode the standard /usr/lib.
+          if test "X$dir" != "X/usr/$acl_libdirstem" \
+             && test "X$dir" != "X/usr/$acl_libdirstem2"; then
+            rpathdirs="$rpathdirs $dir"
+          fi
+          next=
+        else
+          case $opt in
+            -L) next=yes ;;
+            -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'`
+                 dnl No need to hardcode the standard /usr/lib.
+                 if test "X$dir" != "X/usr/$acl_libdirstem" \
+                    && test "X$dir" != "X/usr/$acl_libdirstem2"; then
+                   rpathdirs="$rpathdirs $dir"
+                 fi
+                 next= ;;
+            *) next= ;;
+          esac
+        fi
+      done
+      if test "X$rpathdirs" != "X"; then
+        if test -n ""$3""; then
+          dnl libtool is used for linking. Use -R options.
+          for dir in $rpathdirs; do
+            $1="${$1}${$1:+ }-R$dir"
+          done
+        else
+          dnl The linker is used for linking directly.
+          if test -n "$acl_hardcode_libdir_separator"; then
+            dnl Weird platform: only the last -rpath option counts, the user
+            dnl must pass all path elements in one option.
+            alldirs=
+            for dir in $rpathdirs; do
+              alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir"
+            done
+            acl_save_libdir="$libdir"
+            libdir="$alldirs"
+            eval flag=\"$acl_hardcode_libdir_flag_spec\"
+            libdir="$acl_save_libdir"
+            $1="$flag"
+          else
+            dnl The -rpath options are cumulative.
+            for dir in $rpathdirs; do
+              acl_save_libdir="$libdir"
+              libdir="$dir"
+              eval flag=\"$acl_hardcode_libdir_flag_spec\"
+              libdir="$acl_save_libdir"
+              $1="${$1}${$1:+ }$flag"
+            done
+          fi
+        fi
+      fi
+    fi
+  fi
+  AC_SUBST([$1])
+])
diff --git a/libmissing/m4/lib-prefix.m4 b/libmissing/m4/lib-prefix.m4
new file mode 100644
index 0000000..4b7ee33
--- /dev/null
+++ b/libmissing/m4/lib-prefix.m4
@@ -0,0 +1,224 @@
+# lib-prefix.m4 serial 7 (gettext-0.18)
+dnl Copyright (C) 2001-2005, 2008-2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Bruno Haible.
+
+dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and
+dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't
+dnl require excessive bracketing.
+ifdef([AC_HELP_STRING],
+[AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])],
+[AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])])
+
+dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed
+dnl to access previously installed libraries. The basic assumption is that
+dnl a user will want packages to use other packages he previously installed
+dnl with the same --prefix option.
+dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate
+dnl libraries, but is otherwise very convenient.
+AC_DEFUN([AC_LIB_PREFIX],
+[
+  AC_BEFORE([$0], [AC_LIB_LINKFLAGS])
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([AC_CANONICAL_HOST])
+  AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
+  AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
+  dnl By default, look in $includedir and $libdir.
+  use_additional=yes
+  AC_LIB_WITH_FINAL_PREFIX([
+    eval additional_includedir=\"$includedir\"
+    eval additional_libdir=\"$libdir\"
+  ])
+  AC_LIB_ARG_WITH([lib-prefix],
+[  --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib
+  --without-lib-prefix    don't search for libraries in includedir and libdir],
+[
+    if test "X$withval" = "Xno"; then
+      use_additional=no
+    else
+      if test "X$withval" = "X"; then
+        AC_LIB_WITH_FINAL_PREFIX([
+          eval additional_includedir=\"$includedir\"
+          eval additional_libdir=\"$libdir\"
+        ])
+      else
+        additional_includedir="$withval/include"
+        additional_libdir="$withval/$acl_libdirstem"
+      fi
+    fi
+])
+  if test $use_additional = yes; then
+    dnl Potentially add $additional_includedir to $CPPFLAGS.
+    dnl But don't add it
+    dnl   1. if it's the standard /usr/include,
+    dnl   2. if it's already present in $CPPFLAGS,
+    dnl   3. if it's /usr/local/include and we are using GCC on Linux,
+    dnl   4. if it doesn't exist as a directory.
+    if test "X$additional_includedir" != "X/usr/include"; then
+      haveit=
+      for x in $CPPFLAGS; do
+        AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
+        if test "X$x" = "X-I$additional_includedir"; then
+          haveit=yes
+          break
+        fi
+      done
+      if test -z "$haveit"; then
+        if test "X$additional_includedir" = "X/usr/local/include"; then
+          if test -n "$GCC"; then
+            case $host_os in
+              linux* | gnu* | k*bsd*-gnu) haveit=yes;;
+            esac
+          fi
+        fi
+        if test -z "$haveit"; then
+          if test -d "$additional_includedir"; then
+            dnl Really add $additional_includedir to $CPPFLAGS.
+            CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir"
+          fi
+        fi
+      fi
+    fi
+    dnl Potentially add $additional_libdir to $LDFLAGS.
+    dnl But don't add it
+    dnl   1. if it's the standard /usr/lib,
+    dnl   2. if it's already present in $LDFLAGS,
+    dnl   3. if it's /usr/local/lib and we are using GCC on Linux,
+    dnl   4. if it doesn't exist as a directory.
+    if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then
+      haveit=
+      for x in $LDFLAGS; do
+        AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
+        if test "X$x" = "X-L$additional_libdir"; then
+          haveit=yes
+          break
+        fi
+      done
+      if test -z "$haveit"; then
+        if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then
+          if test -n "$GCC"; then
+            case $host_os in
+              linux*) haveit=yes;;
+            esac
+          fi
+        fi
+        if test -z "$haveit"; then
+          if test -d "$additional_libdir"; then
+            dnl Really add $additional_libdir to $LDFLAGS.
+            LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir"
+          fi
+        fi
+      fi
+    fi
+  fi
+])
+
+dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix,
+dnl acl_final_exec_prefix, containing the values to which $prefix and
+dnl $exec_prefix will expand at the end of the configure script.
+AC_DEFUN([AC_LIB_PREPARE_PREFIX],
+[
+  dnl Unfortunately, prefix and exec_prefix get only finally determined
+  dnl at the end of configure.
+  if test "X$prefix" = "XNONE"; then
+    acl_final_prefix="$ac_default_prefix"
+  else
+    acl_final_prefix="$prefix"
+  fi
+  if test "X$exec_prefix" = "XNONE"; then
+    acl_final_exec_prefix='${prefix}'
+  else
+    acl_final_exec_prefix="$exec_prefix"
+  fi
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
+  prefix="$acl_save_prefix"
+])
+
+dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the
+dnl variables prefix and exec_prefix bound to the values they will have
+dnl at the end of the configure script.
+AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX],
+[
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  $1
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+])
+
+dnl AC_LIB_PREPARE_MULTILIB creates
+dnl - a variable acl_libdirstem, containing the basename of the libdir, either
+dnl   "lib" or "lib64" or "lib/64",
+dnl - a variable acl_libdirstem2, as a secondary possible value for
+dnl   acl_libdirstem, either the same as acl_libdirstem or "lib/sparcv9" or
+dnl   "lib/amd64".
+AC_DEFUN([AC_LIB_PREPARE_MULTILIB],
+[
+  dnl There is no formal standard regarding lib and lib64.
+  dnl On glibc systems, the current practice is that on a system supporting
+  dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under
+  dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. We determine
+  dnl the compiler's default mode by looking at the compiler's library search
+  dnl path. If at least one of its elements ends in /lib64 or points to a
+  dnl directory whose absolute pathname ends in /lib64, we assume a 64-bit ABI.
+  dnl Otherwise we use the default, namely "lib".
+  dnl On Solaris systems, the current practice is that on a system supporting
+  dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under
+  dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or
+  dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib.
+  AC_REQUIRE([AC_CANONICAL_HOST])
+  acl_libdirstem=lib
+  acl_libdirstem2=
+  case "$host_os" in
+    solaris*)
+      dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment
+      dnl <http://docs.sun.com/app/docs/doc/816-5138/dev-env?l=en&a=view>.
+      dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link."
+      dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the
+      dnl symlink is missing, so we set acl_libdirstem2 too.
+      AC_CACHE_CHECK([for 64-bit host], [gl_cv_solaris_64bit],
+        [AC_EGREP_CPP([sixtyfour bits], [
+#ifdef _LP64
+sixtyfour bits
+#endif
+           ], [gl_cv_solaris_64bit=yes], [gl_cv_solaris_64bit=no])
+        ])
+      if test $gl_cv_solaris_64bit = yes; then
+        acl_libdirstem=lib/64
+        case "$host_cpu" in
+          sparc*)        acl_libdirstem2=lib/sparcv9 ;;
+          i*86 | x86_64) acl_libdirstem2=lib/amd64 ;;
+        esac
+      fi
+      ;;
+    *)
+      searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'`
+      if test -n "$searchpath"; then
+        acl_save_IFS="${IFS= 	}"; IFS=":"
+        for searchdir in $searchpath; do
+          if test -d "$searchdir"; then
+            case "$searchdir" in
+              */lib64/ | */lib64 ) acl_libdirstem=lib64 ;;
+              */../ | */.. )
+                # Better ignore directories of this form. They are misleading.
+                ;;
+              *) searchdir=`cd "$searchdir" && pwd`
+                 case "$searchdir" in
+                   */lib64 ) acl_libdirstem=lib64 ;;
+                 esac ;;
+            esac
+          fi
+        done
+        IFS="$acl_save_IFS"
+      fi
+      ;;
+  esac
+  test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem"
+])
diff --git a/libmissing/m4/localcharset.m4 b/libmissing/m4/localcharset.m4
index e960104..90b9403 100644
--- a/libmissing/m4/localcharset.m4
+++ b/libmissing/m4/localcharset.m4
@@ -1,4 +1,4 @@
-# localcharset.m4 serial 6
+# localcharset.m4 serial 7
 dnl Copyright (C) 2002, 2004, 2006, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -8,6 +8,7 @@ AC_DEFUN([gl_LOCALCHARSET],
 [
   dnl Prerequisites of lib/localcharset.c.
   AC_REQUIRE([AM_LANGINFO_CODESET])
+  AC_REQUIRE([gl_FCNTL_O_FLAGS])
   AC_CHECK_DECLS_ONCE([getc_unlocked])
 
   dnl Prerequisites of the lib/Makefile.am snippet.
diff --git a/libmissing/m4/locale-tr.m4 b/libmissing/m4/locale-tr.m4
new file mode 100644
index 0000000..6162f65
--- /dev/null
+++ b/libmissing/m4/locale-tr.m4
@@ -0,0 +1,97 @@
+# locale-tr.m4 serial 6
+dnl Copyright (C) 2003, 2005-2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Bruno Haible.
+
+dnl Determine the name of a turkish locale with UTF-8 encoding.
+AC_DEFUN([gt_LOCALE_TR_UTF8],
+[
+  AC_REQUIRE([AM_LANGINFO_CODESET])
+  AC_CACHE_CHECK([for a turkish Unicode locale], [gt_cv_locale_tr_utf8], [
+    AC_LANG_CONFTEST([AC_LANG_SOURCE([
+changequote(,)dnl
+#include <locale.h>
+#include <time.h>
+#if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+struct tm t;
+char buf[16];
+int main () {
+  /* On BeOS, locales are not implemented in libc.  Rather, libintl
+     imitates locale dependent behaviour by looking at the environment
+     variables, and all locales use the UTF-8 encoding.  But BeOS does not
+     implement the Turkish upper-/lowercase mappings.  Therefore, let this
+     program return 1 on BeOS.  */
+  /* Check whether the given locale name is recognized by the system.  */
+  if (setlocale (LC_ALL, "") == NULL) return 1;
+  /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
+     On MacOS X 10.3.5 (Darwin 7.5) in the tr_TR locale, nl_langinfo(CODESET)
+     is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
+     On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "646". In this situation,
+     some unit tests fail.  */
+#if HAVE_LANGINFO_CODESET
+  {
+    const char *cs = nl_langinfo (CODESET);
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0)
+      return 1;
+  }
+#endif
+#ifdef __CYGWIN__
+  /* On Cygwin, avoid locale names without encoding suffix, because the
+     locale_charset() function relies on the encoding suffix.  Note that
+     LC_ALL is set on the command line.  */
+  if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
+#endif
+  /* Check whether in the abbreviation of the eighth month, the second
+     character (should be U+011F: LATIN SMALL LETTER G WITH BREVE) is
+     two bytes long, with UTF-8 encoding.  */
+  t.tm_year = 1992 - 1900; t.tm_mon = 8 - 1; t.tm_mday = 19;
+  if (strftime (buf, sizeof (buf), "%b", &t) < 4
+      || buf[1] != (char) 0xc4 || buf[2] != (char) 0x9f)
+    return 1;
+  /* Check whether the upper-/lowercase mappings are as expected for
+     Turkish.  */
+  if (towupper ('i') != 0x0130 || towlower (0x0130) != 'i'
+      || towupper(0x0131) != 'I' || towlower ('I') != 0x0131)
+    return 1;
+  return 0;
+}
+changequote([,])dnl
+      ])])
+    if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
+      # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
+      # otherwise on MacOS X 10.3.5 the LC_TIME=C from the beginning of the
+      # configure script would override the LC_ALL setting. Likewise for
+      # LC_CTYPE, which is also set at the beginning of the configure script.
+      # Test for the usual locale name.
+      if (LC_ALL=tr_TR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+        gt_cv_locale_tr_utf8=tr_TR
+      else
+        # Test for the locale name with explicit encoding suffix.
+        if (LC_ALL=tr_TR.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+          gt_cv_locale_tr_utf8=tr_TR.UTF-8
+        else
+          # Test for the Solaris 7 locale name.
+          if (LC_ALL=tr.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+            gt_cv_locale_tr_utf8=tr.UTF-8
+          else
+            # None found.
+            gt_cv_locale_tr_utf8=none
+          fi
+        fi
+      fi
+    else
+      gt_cv_locale_tr_utf8=none
+    fi
+    rm -fr conftest*
+  ])
+  LOCALE_TR_UTF8=$gt_cv_locale_tr_utf8
+  AC_SUBST([LOCALE_TR_UTF8])
+])
diff --git a/libmissing/m4/longlong.m4 b/libmissing/m4/longlong.m4
index eedc8d5..6d17ea3 100644
--- a/libmissing/m4/longlong.m4
+++ b/libmissing/m4/longlong.m4
@@ -20,30 +20,30 @@ AC_DEFUN([AC_TYPE_LONG_LONG_INT],
     [AC_LINK_IFELSE(
        [_AC_TYPE_LONG_LONG_SNIPPET],
        [dnl This catches a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004.
-	dnl If cross compiling, assume the bug isn't important, since
-	dnl nobody cross compiles for this platform as far as we know.
-	AC_RUN_IFELSE(
-	  [AC_LANG_PROGRAM(
-	     [[@%:@include <limits.h>
-	       @%:@ifndef LLONG_MAX
-	       @%:@ define HALF \
-			(1LL << (sizeof (long long int) * CHAR_BIT - 2))
-	       @%:@ define LLONG_MAX (HALF - 1 + HALF)
-	       @%:@endif]],
-	     [[long long int n = 1;
-	       int i;
-	       for (i = 0; ; i++)
-		 {
-		   long long int m = n << i;
-		   if (m >> i != n)
-		     return 1;
-		   if (LLONG_MAX / 2 < m)
-		     break;
-		 }
-	       return 0;]])],
-	  [ac_cv_type_long_long_int=yes],
-	  [ac_cv_type_long_long_int=no],
-	  [ac_cv_type_long_long_int=yes])],
+        dnl If cross compiling, assume the bug isn't important, since
+        dnl nobody cross compiles for this platform as far as we know.
+        AC_RUN_IFELSE(
+          [AC_LANG_PROGRAM(
+             [[@%:@include <limits.h>
+               @%:@ifndef LLONG_MAX
+               @%:@ define HALF \
+                        (1LL << (sizeof (long long int) * CHAR_BIT - 2))
+               @%:@ define LLONG_MAX (HALF - 1 + HALF)
+               @%:@endif]],
+             [[long long int n = 1;
+               int i;
+               for (i = 0; ; i++)
+                 {
+                   long long int m = n << i;
+                   if (m >> i != n)
+                     return 1;
+                   if (LLONG_MAX / 2 < m)
+                     break;
+                 }
+               return 0;]])],
+          [ac_cv_type_long_long_int=yes],
+          [ac_cv_type_long_long_int=no],
+          [ac_cv_type_long_long_int=yes])],
        [ac_cv_type_long_long_int=no])])
   if test $ac_cv_type_long_long_int = yes; then
     AC_DEFINE([HAVE_LONG_LONG_INT], [1],
@@ -83,24 +83,24 @@ AC_DEFUN([_AC_TYPE_LONG_LONG_SNIPPET],
 [
   AC_LANG_PROGRAM(
     [[/* For now, do not test the preprocessor; as of 2007 there are too many
-	 implementations with broken preprocessors.  Perhaps this can
-	 be revisited in 2012.  In the meantime, code should not expect
-	 #if to work with literals wider than 32 bits.  */
+         implementations with broken preprocessors.  Perhaps this can
+         be revisited in 2012.  In the meantime, code should not expect
+         #if to work with literals wider than 32 bits.  */
       /* Test literals.  */
       long long int ll = 9223372036854775807ll;
       long long int nll = -9223372036854775807LL;
       unsigned long long int ull = 18446744073709551615ULL;
       /* Test constant expressions.   */
       typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll)
-		     ? 1 : -1)];
+                     ? 1 : -1)];
       typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1
-		     ? 1 : -1)];
+                     ? 1 : -1)];
       int i = 63;]],
     [[/* Test availability of runtime routines for shift and division.  */
       long long int llmax = 9223372036854775807ll;
       unsigned long long int ullmax = 18446744073709551615ull;
       return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i)
-	      | (llmax / ll) | (llmax % ll)
-	      | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i)
-	      | (ullmax / ull) | (ullmax % ull));]])
+              | (llmax / ll) | (llmax % ll)
+              | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i)
+              | (ullmax / ull) | (ullmax % ull));]])
 ])
diff --git a/libmissing/m4/mbsinit.m4 b/libmissing/m4/mbsinit.m4
index 03b055c..25b21c2 100644
--- a/libmissing/m4/mbsinit.m4
+++ b/libmissing/m4/mbsinit.m4
@@ -1,5 +1,5 @@
 # mbsinit.m4 serial 3
-dnl Copyright (C) 2008 Free Software Foundation, Inc.
+dnl Copyright (C) 2008, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/libmissing/m4/mbstate_t.m4 b/libmissing/m4/mbstate_t.m4
index d4ec6f0..6930f21 100644
--- a/libmissing/m4/mbstate_t.m4
+++ b/libmissing/m4/mbstate_t.m4
@@ -1,5 +1,5 @@
 # mbstate_t.m4 serial 12
-dnl Copyright (C) 2000-2002, 2008, 2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2000-2002, 2008-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -18,17 +18,17 @@ AC_DEFUN([AC_TYPE_MBSTATE_T],
 
    AC_CACHE_CHECK([for mbstate_t], [ac_cv_type_mbstate_t],
      [AC_COMPILE_IFELSE(
-	[AC_LANG_PROGRAM(
-	   [AC_INCLUDES_DEFAULT[
-#	    include <wchar.h>]],
-	   [[mbstate_t x; return sizeof x;]])],
-	[ac_cv_type_mbstate_t=yes],
-	[ac_cv_type_mbstate_t=no])])
+        [AC_LANG_PROGRAM(
+           [AC_INCLUDES_DEFAULT[
+#           include <wchar.h>]],
+           [[mbstate_t x; return sizeof x;]])],
+        [ac_cv_type_mbstate_t=yes],
+        [ac_cv_type_mbstate_t=no])])
    if test $ac_cv_type_mbstate_t = yes; then
      AC_DEFINE([HAVE_MBSTATE_T], [1],
-	       [Define to 1 if <wchar.h> declares mbstate_t.])
+               [Define to 1 if <wchar.h> declares mbstate_t.])
    else
      AC_DEFINE([mbstate_t], [int],
-	       [Define to a type if <wchar.h> does not define.])
+               [Define to a type if <wchar.h> does not define.])
    fi
 ])
diff --git a/libmissing/m4/memchr.m4 b/libmissing/m4/memchr.m4
index 1194bac..a96d114 100644
--- a/libmissing/m4/memchr.m4
+++ b/libmissing/m4/memchr.m4
@@ -1,5 +1,5 @@
 # memchr.m4 serial 7
-dnl Copyright (C) 2002, 2003, 2004, 2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2002-2004, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -53,11 +53,11 @@ AC_DEFUN_ONCE([gl_FUNC_MEMCHR],
     {
       int pagesize = getpagesize ();
       char *two_pages =
-	(char *) mmap (NULL, 2 * pagesize, PROT_READ | PROT_WRITE,
-		       flags, fd, 0);
+        (char *) mmap (NULL, 2 * pagesize, PROT_READ | PROT_WRITE,
+                       flags, fd, 0);
       if (two_pages != (char *)(-1)
-	  && mprotect (two_pages + pagesize, pagesize, PROT_NONE) == 0)
-	fence = two_pages + pagesize;
+          && mprotect (two_pages + pagesize, pagesize, PROT_NONE) == 0)
+        fence = two_pages + pagesize;
     }
 #endif
   if (fence)
diff --git a/libmissing/m4/mktime.m4 b/libmissing/m4/mktime.m4
index 1e926e8..bea8782 100644
--- a/libmissing/m4/mktime.m4
+++ b/libmissing/m4/mktime.m4
@@ -85,8 +85,8 @@ static int
 mktime_test (time_t now)
 {
   return (mktime_test1 (now)
-	  && mktime_test1 ((time_t) (time_t_max - now))
-	  && mktime_test1 ((time_t) (time_t_min + now)));
+          && mktime_test1 ((time_t) (time_t_max - now))
+          && mktime_test1 ((time_t) (time_t_min + now)));
 }
 
 static int
@@ -116,17 +116,17 @@ bigtime_test (int j)
     {
       struct tm *lt = localtime (&now);
       if (! (lt
-	     && lt->tm_year == tm.tm_year
-	     && lt->tm_mon == tm.tm_mon
-	     && lt->tm_mday == tm.tm_mday
-	     && lt->tm_hour == tm.tm_hour
-	     && lt->tm_min == tm.tm_min
-	     && lt->tm_sec == tm.tm_sec
-	     && lt->tm_yday == tm.tm_yday
-	     && lt->tm_wday == tm.tm_wday
-	     && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst)
-		  == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst))))
-	return 0;
+             && lt->tm_year == tm.tm_year
+             && lt->tm_mon == tm.tm_mon
+             && lt->tm_mday == tm.tm_mday
+             && lt->tm_hour == tm.tm_hour
+             && lt->tm_min == tm.tm_min
+             && lt->tm_sec == tm.tm_sec
+             && lt->tm_yday == tm.tm_yday
+             && lt->tm_wday == tm.tm_wday
+             && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst)
+                  == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst))))
+        return 0;
     }
   return 1;
 }
@@ -158,7 +158,7 @@ year_2050_test ()
      to the correct answer that we can assume the discrepancy is
      due to leap seconds.  */
   return (t == (time_t) -1
-	  || (0 < t && answer - 120 <= t && t <= answer + 120));
+          || (0 < t && answer - 120 <= t && t <= answer + 120));
 }
 
 int
@@ -176,7 +176,7 @@ main ()
     {
       t = (time_t_max << 1) + 1;
       if (t <= time_t_max)
-	break;
+        break;
       time_t_max = t;
     }
   time_t_min = - ((time_t) ~ (time_t) 0 == (time_t) -1) - time_t_max;
@@ -185,29 +185,29 @@ main ()
   for (i = 0; i < N_STRINGS; i++)
     {
       if (tz_strings[i])
-	putenv (tz_strings[i]);
+        putenv (tz_strings[i]);
 
       for (t = 0; t <= time_t_max - delta; t += delta)
-	if (! mktime_test (t))
-	  return 1;
+        if (! mktime_test (t))
+          return 1;
       if (! (mktime_test ((time_t) 1)
-	     && mktime_test ((time_t) (60 * 60))
-	     && mktime_test ((time_t) (60 * 60 * 24))))
-	return 1;
+             && mktime_test ((time_t) (60 * 60))
+             && mktime_test ((time_t) (60 * 60 * 24))))
+        return 1;
 
       for (j = 1; ; j <<= 1)
-	if (! bigtime_test (j))
-	  return 1;
-	else if (INT_MAX / 2 < j)
-	  break;
+        if (! bigtime_test (j))
+          return 1;
+        else if (INT_MAX / 2 < j)
+          break;
       if (! bigtime_test (INT_MAX))
-	return 1;
+        return 1;
     }
   return ! (irix_6_4_bug () && spring_forward_gap () && year_2050_test ());
 }]])],
-	       [ac_cv_func_working_mktime=yes],
-	       [ac_cv_func_working_mktime=no],
-	       [ac_cv_func_working_mktime=no])])
+               [ac_cv_func_working_mktime=yes],
+               [ac_cv_func_working_mktime=no],
+               [ac_cv_func_working_mktime=no])])
 if test $ac_cv_func_working_mktime = no; then
   AC_LIBOBJ([mktime])
 fi
@@ -215,12 +215,14 @@ fi
 
 AC_DEFUN([gl_FUNC_MKTIME],
 [
+  AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
   AC_FUNC_MKTIME
   dnl Note: AC_FUNC_MKTIME does AC_LIBOBJ([mktime]).
   if test $ac_cv_func_working_mktime = no; then
-    AC_DEFINE([mktime], [rpl_mktime],
-      [Define to rpl_mktime if the replacement function should be used.])
+    REPLACE_MKTIME=1
     gl_PREREQ_MKTIME
+  else
+    REPLACE_MKTIME=0
   fi
 ])
 
diff --git a/libmissing/m4/netdb_h.m4 b/libmissing/m4/netdb_h.m4
index 5a12251..6cc2cfc 100644
--- a/libmissing/m4/netdb_h.m4
+++ b/libmissing/m4/netdb_h.m4
@@ -1,5 +1,5 @@
 # netdb_h.m4 serial 5
-dnl Copyright (C) 2008 Free Software Foundation, Inc.
+dnl Copyright (C) 2008, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/libmissing/m4/netinet_in_h.m4 b/libmissing/m4/netinet_in_h.m4
index 47fd9cc..a690b8d 100644
--- a/libmissing/m4/netinet_in_h.m4
+++ b/libmissing/m4/netinet_in_h.m4
@@ -1,5 +1,5 @@
 # netinet_in_h.m4 serial 4
-dnl Copyright (C) 2006-2008 Free Software Foundation, Inc.
+dnl Copyright (C) 2006-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/libmissing/m4/nl_langinfo.m4 b/libmissing/m4/nl_langinfo.m4
new file mode 100644
index 0000000..2855d0f
--- /dev/null
+++ b/libmissing/m4/nl_langinfo.m4
@@ -0,0 +1,29 @@
+# nl_langinfo.m4 serial 1
+dnl Copyright (C) 2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_NL_LANGINFO],
+[
+  AC_REQUIRE([gl_LANGINFO_H_DEFAULTS])
+  AC_REQUIRE([gl_LANGINFO_H])
+  if test $HAVE_LANGINFO_H = 1; then
+    AC_CHECK_FUNCS_ONCE([nl_langinfo])
+  else
+    ac_cv_func_nl_langinfo=no
+  fi
+  if test $ac_cv_func_nl_langinfo = yes; then
+    if test $HAVE_LANGINFO_CODESET = 1 && test $HAVE_LANGINFO_ERA = 1; then
+      :
+    else
+      REPLACE_NL_LANGINFO=1
+      AC_DEFINE([REPLACE_NL_LANGINFO], [1],
+        [Define if nl_langinfo exists but is overridden by gnulib.])
+      AC_LIBOBJ([nl_langinfo])
+    fi
+  else
+    HAVE_NL_LANGINFO=0
+    AC_LIBOBJ([nl_langinfo])
+  fi
+])
diff --git a/libmissing/m4/onceonly.m4 b/libmissing/m4/onceonly.m4
index 108cd6c..2998ab2 100644
--- a/libmissing/m4/onceonly.m4
+++ b/libmissing/m4/onceonly.m4
@@ -1,5 +1,6 @@
 # onceonly.m4 serial 6
-dnl Copyright (C) 2002-2003, 2005-2006, 2008 Free Software Foundation, Inc.
+dnl Copyright (C) 2002-2003, 2005-2006, 2008-2009 Free Software Foundation,
+dnl Inc.
 dnl This file is free software, distributed under the terms of the GNU
 dnl General Public License.  As a special exception to the GNU General
 dnl Public License, this file may be distributed as part of a program
diff --git a/libmissing/m4/pathmax.m4 b/libmissing/m4/pathmax.m4
index 4651801..f2a975c 100644
--- a/libmissing/m4/pathmax.m4
+++ b/libmissing/m4/pathmax.m4
@@ -1,5 +1,5 @@
 # pathmax.m4 serial 8
-dnl Copyright (C) 2002, 2003, 2005, 2006, 2009 Free Software Foundation, Inc.
+dnl Copyright (C) 2002-2003, 2005-2006, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/libmissing/m4/servent.m4 b/libmissing/m4/servent.m4
index 242f9e3..3ddc610 100644
--- a/libmissing/m4/servent.m4
+++ b/libmissing/m4/servent.m4
@@ -1,5 +1,5 @@
 # servent.m4 serial 1
-dnl Copyright (C) 2008 Free Software Foundation, Inc.
+dnl Copyright (C) 2008, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/libmissing/m4/sigaction.m4 b/libmissing/m4/sigaction.m4
index 3a3ed9f..770479a 100644
--- a/libmissing/m4/sigaction.m4
+++ b/libmissing/m4/sigaction.m4
@@ -1,5 +1,5 @@
 # sigaction.m4 serial 5
-dnl Copyright (C) 2008 Free Software Foundation, Inc.
+dnl Copyright (C) 2008, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/libmissing/m4/sleep.m4 b/libmissing/m4/sleep.m4
index 474ba07..c59b383 100644
--- a/libmissing/m4/sleep.m4
+++ b/libmissing/m4/sleep.m4
@@ -1,5 +1,5 @@
-# sleep.m4 serial 2
-dnl Copyright (C) 2007-2008 Free Software Foundation, Inc.
+# sleep.m4 serial 3
+dnl Copyright (C) 2007-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -13,12 +13,37 @@ AC_DEFUN([gl_FUNC_SLEEP],
   dnl it takes the number of milliseconds as argument and returns void.
   dnl mingw does not declare this function.
   AC_CHECK_DECLS([sleep], , , [#include <unistd.h>])
+  AC_CHECK_FUNCS_ONCE([sleep])
   if test $ac_cv_have_decl_sleep != yes; then
     HAVE_SLEEP=0
     AC_LIBOBJ([sleep])
-    gl_PREREQ_SLEEP
+  else
+    dnl Cygwin 1.5.x has a bug where sleep can't exceed 49.7 days.
+    AC_CACHE_CHECK([for working sleep], [gl_cv_func_sleep_works],
+      [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+#include <errno.h>
+#include <unistd.h>
+#include <signal.h>
+static void
+handle_alarm (int sig)
+{
+  if (sig != SIGALRM)
+    _exit (2);
+}
+]], [[
+    /* Failure to compile this test due to missing alarm is okay,
+       since all such platforms (mingw) also lack sleep.  */
+    unsigned int pentecost = 50 * 24 * 60 * 60; /* 50 days.  */
+    unsigned int remaining;
+    signal (SIGALRM, handle_alarm);
+    alarm (1);
+    remaining = sleep (pentecost);
+    return !(pentecost - 10 < remaining && remaining <= pentecost);]])],
+      [gl_cv_func_sleep_works=yes], [gl_cv_func_sleep_works=no],
+      [gl_cv_func_sleep_works="guessing no"])])
+    if test "$gl_cv_func_sleep_works" != yes; then
+      REPLACE_SLEEP=1
+      AC_LIBOBJ([sleep])
+    fi
   fi
 ])
-
-# Prerequisites of lib/sleep.c.
-AC_DEFUN([gl_PREREQ_SLEEP], [:])
diff --git a/libmissing/m4/snprintf.m4 b/libmissing/m4/snprintf.m4
index 6021786..df705f4 100644
--- a/libmissing/m4/snprintf.m4
+++ b/libmissing/m4/snprintf.m4
@@ -1,5 +1,5 @@
 # snprintf.m4 serial 5
-dnl Copyright (C) 2002-2004, 2007-2008 Free Software Foundation, Inc.
+dnl Copyright (C) 2002-2004, 2007-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/libmissing/m4/sockets.m4 b/libmissing/m4/sockets.m4
new file mode 100644
index 0000000..3edc010
--- /dev/null
+++ b/libmissing/m4/sockets.m4
@@ -0,0 +1,90 @@
+# sockets.m4 serial 6
+dnl Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_SOCKETS],
+[
+  AC_REQUIRE([AC_C_INLINE])
+
+  gl_PREREQ_SYS_H_WINSOCK2 dnl for HAVE_WINSOCK2_H
+  LIBSOCKET=
+  if test $HAVE_WINSOCK2_H = 1; then
+    dnl Native Windows API (not Cygwin).
+    AC_CACHE_CHECK([if we need to call WSAStartup in winsock2.h and -lws2_32],
+                   [gl_cv_func_wsastartup], [
+      gl_save_LIBS="$LIBS"
+      LIBS="$LIBS -lws2_32"
+      AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+#ifdef HAVE_WINSOCK2_H
+# include <winsock2.h>
+#endif]], [[
+          WORD wVersionRequested = MAKEWORD(1, 1);
+          WSADATA wsaData;
+          int err = WSAStartup(wVersionRequested, &wsaData);
+          WSACleanup ();]])],
+        gl_cv_func_wsastartup=yes, gl_cv_func_wsastartup=no)
+      LIBS="$gl_save_LIBS"
+    ])
+    if test "$gl_cv_func_wsastartup" = "yes"; then
+      AC_DEFINE([WINDOWS_SOCKETS], [1], [Define if WSAStartup is needed.])
+      LIBSOCKET='-lws2_32'
+    fi
+  else
+    dnl Unix API.
+    dnl Solaris has most socket functions in libsocket.
+    dnl Haiku has most socket functions in libnetwork.
+    dnl BeOS has most socket functions in libnet.
+    AC_CACHE_CHECK([for library containing setsockopt], [gl_cv_lib_socket], [
+      gl_cv_lib_socket=
+      AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern
+#ifdef __cplusplus
+"C"
+#endif
+char setsockopt();]], [[setsockopt();]])],
+        [],
+        [gl_save_LIBS="$LIBS"
+         LIBS="$gl_save_LIBS -lsocket"
+         AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern
+#ifdef __cplusplus
+"C"
+#endif
+char setsockopt();]], [[setsockopt();]])],
+           [gl_cv_lib_socket="-lsocket"])
+         if test -z "$gl_cv_lib_socket"; then
+           LIBS="$gl_save_LIBS -lnetwork"
+           AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern
+#ifdef __cplusplus
+"C"
+#endif
+char setsockopt();]], [[setsockopt();]])],
+             [gl_cv_lib_socket="-lnetwork"])
+           if test -z "$gl_cv_lib_socket"; then
+             LIBS="$gl_save_LIBS -lnet"
+             AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern
+#ifdef __cplusplus
+"C"
+#endif
+char setsockopt();]], [[setsockopt();]])],
+               [gl_cv_lib_socket="-lnet"])
+           fi
+         fi
+         LIBS="$gl_save_LIBS"
+        ])
+      if test -z "$gl_cv_lib_socket"; then
+        gl_cv_lib_socket="none needed"
+      fi
+    ])
+    if test "$gl_cv_lib_socket" != "none needed"; then
+      LIBSOCKET="$gl_cv_lib_socket"
+    fi
+  fi
+  AC_SUBST([LIBSOCKET])
+  gl_PREREQ_SOCKETS
+])
+
+# Prerequisites of lib/sockets.c.
+AC_DEFUN([gl_PREREQ_SOCKETS], [
+  :
+])
diff --git a/libmissing/m4/socklen.m4 b/libmissing/m4/socklen.m4
index b755757..36436ed 100644
--- a/libmissing/m4/socklen.m4
+++ b/libmissing/m4/socklen.m4
@@ -1,5 +1,5 @@
-# socklen.m4 serial 6
-dnl Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
+# socklen.m4 serial 7
+dnl Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -20,30 +20,30 @@ AC_DEFUN([gl_TYPE_SOCKLEN_T],
    AC_CHECK_TYPE([socklen_t], ,
      [AC_MSG_CHECKING([for socklen_t equivalent])
       AC_CACHE_VAL([gl_cv_socklen_t_equiv],
-	[# Systems have either "struct sockaddr *" or
-	 # "void *" as the second argument to getpeername
-	 gl_cv_socklen_t_equiv=
-	 for arg2 in "struct sockaddr" void; do
-	   for t in int size_t "unsigned int" "long int" "unsigned long int"; do
-	     AC_TRY_COMPILE(
-	       [#include <sys/types.h>
-		#include <sys/socket.h>
+        [# Systems have either "struct sockaddr *" or
+         # "void *" as the second argument to getpeername
+         gl_cv_socklen_t_equiv=
+         for arg2 in "struct sockaddr" void; do
+           for t in int size_t "unsigned int" "long int" "unsigned long int"; do
+             AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+                 [[#include <sys/types.h>
+                   #include <sys/socket.h>
 
-		int getpeername (int, $arg2 *, $t *);],
-	       [$t len;
-		getpeername (0, 0, &len);],
-	       [gl_cv_socklen_t_equiv="$t"])
-	     test "$gl_cv_socklen_t_equiv" != "" && break
-	   done
-	   test "$gl_cv_socklen_t_equiv" != "" && break
-	 done
+                   int getpeername (int, $arg2 *, $t *);]],
+                 [[$t len;
+                  getpeername (0, 0, &len);]])],
+               [gl_cv_socklen_t_equiv="$t"])
+             test "$gl_cv_socklen_t_equiv" != "" && break
+           done
+           test "$gl_cv_socklen_t_equiv" != "" && break
+         done
       ])
       if test "$gl_cv_socklen_t_equiv" = ""; then
-	AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
+        AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
       fi
       AC_MSG_RESULT([$gl_cv_socklen_t_equiv])
       AC_DEFINE_UNQUOTED([socklen_t], [$gl_cv_socklen_t_equiv],
-	[type to use in place of socklen_t if not defined])],
+        [type to use in place of socklen_t if not defined])],
      [#include <sys/types.h>
       #if HAVE_SYS_SOCKET_H
       # include <sys/socket.h>
diff --git a/libmissing/m4/sockpfaf.m4 b/libmissing/m4/sockpfaf.m4
index 99ea06f..bbdfabc 100644
--- a/libmissing/m4/sockpfaf.m4
+++ b/libmissing/m4/sockpfaf.m4
@@ -1,4 +1,4 @@
-# sockpfaf.m4 serial 6
+# sockpfaf.m4 serial 7
 dnl Copyright (C) 2004, 2006, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -18,7 +18,7 @@ AC_DEFUN([gl_SOCKET_FAMILIES],
 
   AC_MSG_CHECKING([for IPv4 sockets])
   AC_CACHE_VAL([gl_cv_socket_ipv4],
-    [AC_TRY_COMPILE([#include <sys/types.h>
+    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
 #ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
 #endif
@@ -27,9 +27,9 @@ AC_DEFUN([gl_SOCKET_FAMILIES],
 #endif
 #ifdef HAVE_WINSOCK2_H
 #include <winsock2.h>
-#endif],
-[int x = AF_INET; struct in_addr y; struct sockaddr_in z;
- if (&x && &y && &z) return 0;],
+#endif]],
+[[int x = AF_INET; struct in_addr y; struct sockaddr_in z;
+ if (&x && &y && &z) return 0;]])],
        gl_cv_socket_ipv4=yes, gl_cv_socket_ipv4=no)])
   AC_MSG_RESULT([$gl_cv_socket_ipv4])
   if test $gl_cv_socket_ipv4 = yes; then
@@ -38,7 +38,7 @@ AC_DEFUN([gl_SOCKET_FAMILIES],
 
   AC_MSG_CHECKING([for IPv6 sockets])
   AC_CACHE_VAL([gl_cv_socket_ipv6],
-    [AC_TRY_COMPILE([#include <sys/types.h>
+    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
 #ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
 #endif
@@ -47,9 +47,9 @@ AC_DEFUN([gl_SOCKET_FAMILIES],
 #endif
 #ifdef HAVE_WINSOCK2_H
 #include <winsock2.h>
-#endif],
-[int x = AF_INET6; struct in6_addr y; struct sockaddr_in6 z;
- if (&x && &y && &z) return 0;],
+#endif]],
+[[int x = AF_INET6; struct in6_addr y; struct sockaddr_in6 z;
+ if (&x && &y && &z) return 0;]])],
        gl_cv_socket_ipv6=yes, gl_cv_socket_ipv6=no)])
   AC_MSG_RESULT([$gl_cv_socket_ipv6])
   if test $gl_cv_socket_ipv6 = yes; then
diff --git a/libmissing/m4/stdbool.m4 b/libmissing/m4/stdbool.m4
index 57c804a..5e22d7a 100644
--- a/libmissing/m4/stdbool.m4
+++ b/libmissing/m4/stdbool.m4
@@ -38,77 +38,77 @@ AC_DEFUN([AC_HEADER_STDBOOL],
   [AC_CACHE_CHECK([for stdbool.h that conforms to C99],
      [ac_cv_header_stdbool_h],
      [AC_TRY_COMPILE(
-	[
-	  #include <stdbool.h>
-	  #ifndef bool
-	   "error: bool is not defined"
-	  #endif
-	  #ifndef false
-	   "error: false is not defined"
-	  #endif
-	  #if false
-	   "error: false is not 0"
-	  #endif
-	  #ifndef true
-	   "error: true is not defined"
-	  #endif
-	  #if true != 1
-	   "error: true is not 1"
-	  #endif
-	  #ifndef __bool_true_false_are_defined
-	   "error: __bool_true_false_are_defined is not defined"
-	  #endif
+        [
+          #include <stdbool.h>
+          #ifndef bool
+           "error: bool is not defined"
+          #endif
+          #ifndef false
+           "error: false is not defined"
+          #endif
+          #if false
+           "error: false is not 0"
+          #endif
+          #ifndef true
+           "error: true is not defined"
+          #endif
+          #if true != 1
+           "error: true is not 1"
+          #endif
+          #ifndef __bool_true_false_are_defined
+           "error: __bool_true_false_are_defined is not defined"
+          #endif
 
-	  struct s { _Bool s: 1; _Bool t; } s;
+          struct s { _Bool s: 1; _Bool t; } s;
 
-	  char a[true == 1 ? 1 : -1];
-	  char b[false == 0 ? 1 : -1];
-	  char c[__bool_true_false_are_defined == 1 ? 1 : -1];
-	  char d[(bool) 0.5 == true ? 1 : -1];
-	  bool e = &s;
-	  char f[(_Bool) 0.0 == false ? 1 : -1];
-	  char g[true];
-	  char h[sizeof (_Bool)];
-	  char i[sizeof s.t];
-	  enum { j = false, k = true, l = false * true, m = true * 256 };
-	  _Bool n[m];
-	  char o[sizeof n == m * sizeof n[0] ? 1 : -1];
-	  char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
-	  #if defined __xlc__ || defined __GNUC__
-	   /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0
-	      reported by James Lemley on 2005-10-05; see
-	      http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
-	      This test is not quite right, since xlc is allowed to
-	      reject this program, as the initializer for xlcbug is
-	      not one of the forms that C requires support for.
-	      However, doing the test right would require a run-time
-	      test, and that would make cross-compilation harder.
-	      Let us hope that IBM fixes the xlc bug, and also adds
-	      support for this kind of constant expression.  In the
-	      meantime, this test will reject xlc, which is OK, since
-	      our stdbool.h substitute should suffice.  We also test
-	      this with GCC, where it should work, to detect more
-	      quickly whether someone messes up the test in the
-	      future.  */
-	   char digs[] = "0123456789";
-	   int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1);
-	  #endif
-	  /* Catch a bug in an HP-UX C compiler.  See
-	     http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
-	     http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
-	   */
-	  _Bool q = true;
-	  _Bool *pq = &q;
-	],
-	[
-	  *pq |= q;
-	  *pq |= ! q;
-	  /* Refer to every declared value, to avoid compiler optimizations.  */
-	  return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
-		  + !m + !n + !o + !p + !q + !pq);
-	],
-	[ac_cv_header_stdbool_h=yes],
-	[ac_cv_header_stdbool_h=no])])
+          char a[true == 1 ? 1 : -1];
+          char b[false == 0 ? 1 : -1];
+          char c[__bool_true_false_are_defined == 1 ? 1 : -1];
+          char d[(bool) 0.5 == true ? 1 : -1];
+          bool e = &s;
+          char f[(_Bool) 0.0 == false ? 1 : -1];
+          char g[true];
+          char h[sizeof (_Bool)];
+          char i[sizeof s.t];
+          enum { j = false, k = true, l = false * true, m = true * 256 };
+          _Bool n[m];
+          char o[sizeof n == m * sizeof n[0] ? 1 : -1];
+          char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
+          #if defined __xlc__ || defined __GNUC__
+           /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0
+              reported by James Lemley on 2005-10-05; see
+              http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
+              This test is not quite right, since xlc is allowed to
+              reject this program, as the initializer for xlcbug is
+              not one of the forms that C requires support for.
+              However, doing the test right would require a run-time
+              test, and that would make cross-compilation harder.
+              Let us hope that IBM fixes the xlc bug, and also adds
+              support for this kind of constant expression.  In the
+              meantime, this test will reject xlc, which is OK, since
+              our stdbool.h substitute should suffice.  We also test
+              this with GCC, where it should work, to detect more
+              quickly whether someone messes up the test in the
+              future.  */
+           char digs[] = "0123456789";
+           int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1);
+          #endif
+          /* Catch a bug in an HP-UX C compiler.  See
+             http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
+             http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
+           */
+          _Bool q = true;
+          _Bool *pq = &q;
+        ],
+        [
+          *pq |= q;
+          *pq |= ! q;
+          /* Refer to every declared value, to avoid compiler optimizations.  */
+          return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
+                  + !m + !n + !o + !p + !q + !pq);
+        ],
+        [ac_cv_header_stdbool_h=yes],
+        [ac_cv_header_stdbool_h=no])])
    AC_CHECK_TYPES([_Bool])
    if test $ac_cv_header_stdbool_h = yes; then
      AC_DEFINE([HAVE_STDBOOL_H], [1], [Define to 1 if stdbool.h conforms to C99.])
diff --git a/libmissing/m4/stddef_h.m4 b/libmissing/m4/stddef_h.m4
new file mode 100644
index 0000000..682e9c6
--- /dev/null
+++ b/libmissing/m4/stddef_h.m4
@@ -0,0 +1,45 @@
+dnl A placeholder for POSIX 2008 <stddef.h>, for platforms that have issues.
+# stddef_h.m4 serial 1
+dnl Copyright (C) 2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_STDDEF_H],
+[
+  AC_REQUIRE([gl_STDDEF_H_DEFAULTS])
+  AC_REQUIRE([gt_TYPE_WCHAR_T])
+  if test $gt_cv_c_wchar_t = no; then
+    HAVE_WCHAR_T=0
+    STDDEF_H=stddef.h
+  fi
+  AC_CACHE_CHECK([whether NULL can be used in arbitrary expressions],
+    [gl_cv_decl_null_works],
+    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stddef.h>
+      int test[2 * (sizeof NULL == sizeof (void *)) -1];
+]])],
+      [gl_cv_decl_null_works=yes],
+      [gl_cv_decl_null_works=no])])
+  if test $gl_cv_decl_null_works = no; then
+    REPLACE_NULL=1
+    STDDEF_H=stddef.h
+  fi
+  if test -n "$STDDEF_H"; then
+    gl_CHECK_NEXT_HEADERS([stddef.h])
+  fi
+])
+
+AC_DEFUN([gl_STDDEF_MODULE_INDICATOR],
+[
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+  AC_REQUIRE([gl_STDDEF_H_DEFAULTS])
+  GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
+])
+
+AC_DEFUN([gl_STDDEF_H_DEFAULTS],
+[
+  dnl Assume proper GNU behavior unless another module says otherwise.
+  REPLACE_NULL=0;                AC_SUBST([REPLACE_NULL])
+  HAVE_WCHAR_T=1;                AC_SUBST([HAVE_WCHAR_T])
+  STDDEF_H='';                   AC_SUBST([STDDEF_H])
+])
diff --git a/libmissing/m4/stdint.m4 b/libmissing/m4/stdint.m4
index a2e8bdd..819d629 100644
--- a/libmissing/m4/stdint.m4
+++ b/libmissing/m4/stdint.m4
@@ -396,12 +396,12 @@ AC_DEFUN([gl_INTEGER_TYPE_SUFFIX],
        for glsuf in "$glsufu" ${glsufu}l ${glsufu}ll ${glsufu}i64; do
          case $glsuf in
            '')  gltype1='int';;
-           l)	gltype1='long int';;
-           ll)	gltype1='long long int';;
-           i64)	gltype1='__int64';;
-           u)	gltype1='unsigned int';;
-           ul)	gltype1='unsigned long int';;
-           ull)	gltype1='unsigned long long int';;
+           l)   gltype1='long int';;
+           ll)  gltype1='long long int';;
+           i64) gltype1='__int64';;
+           u)   gltype1='unsigned int';;
+           ul)  gltype1='unsigned long int';;
+           ull) gltype1='unsigned long long int';;
            ui64)gltype1='unsigned __int64';;
          esac
          AC_COMPILE_IFELSE(
diff --git a/libmissing/m4/stdio_h.m4 b/libmissing/m4/stdio_h.m4
index fcbe68f..c690565 100644
--- a/libmissing/m4/stdio_h.m4
+++ b/libmissing/m4/stdio_h.m4
@@ -1,4 +1,4 @@
-# stdio_h.m4 serial 16
+# stdio_h.m4 serial 22
 dnl Copyright (C) 2007-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -41,78 +41,85 @@ AC_DEFUN([gl_STDIO_MODULE_INDICATOR],
 
 AC_DEFUN([gl_STDIO_H_DEFAULTS],
 [
-  GNULIB_FPRINTF=0;              AC_SUBST([GNULIB_FPRINTF])
-  GNULIB_FPRINTF_POSIX=0;        AC_SUBST([GNULIB_FPRINTF_POSIX])
-  GNULIB_PRINTF=0;               AC_SUBST([GNULIB_PRINTF])
-  GNULIB_PRINTF_POSIX=0;         AC_SUBST([GNULIB_PRINTF_POSIX])
-  GNULIB_SNPRINTF=0;             AC_SUBST([GNULIB_SNPRINTF])
-  GNULIB_SPRINTF_POSIX=0;        AC_SUBST([GNULIB_SPRINTF_POSIX])
-  GNULIB_VFPRINTF=0;             AC_SUBST([GNULIB_VFPRINTF])
-  GNULIB_VFPRINTF_POSIX=0;       AC_SUBST([GNULIB_VFPRINTF_POSIX])
-  GNULIB_VPRINTF=0;              AC_SUBST([GNULIB_VPRINTF])
-  GNULIB_VPRINTF_POSIX=0;        AC_SUBST([GNULIB_VPRINTF_POSIX])
-  GNULIB_VSNPRINTF=0;            AC_SUBST([GNULIB_VSNPRINTF])
-  GNULIB_VSPRINTF_POSIX=0;       AC_SUBST([GNULIB_VSPRINTF_POSIX])
   GNULIB_DPRINTF=0;              AC_SUBST([GNULIB_DPRINTF])
-  GNULIB_VDPRINTF=0;             AC_SUBST([GNULIB_VDPRINTF])
-  GNULIB_VASPRINTF=0;            AC_SUBST([GNULIB_VASPRINTF])
-  GNULIB_OBSTACK_PRINTF=0;       AC_SUBST([GNULIB_OBSTACK_PRINTF])
-  GNULIB_OBSTACK_PRINTF_POSIX=0; AC_SUBST([GNULIB_OBSTACK_PRINTF_POSIX])
+  GNULIB_FCLOSE=0;               AC_SUBST([GNULIB_FCLOSE])
+  GNULIB_FFLUSH=0;               AC_SUBST([GNULIB_FFLUSH])
   GNULIB_FOPEN=0;                AC_SUBST([GNULIB_FOPEN])
+  GNULIB_FPRINTF=0;              AC_SUBST([GNULIB_FPRINTF])
+  GNULIB_FPRINTF_POSIX=0;        AC_SUBST([GNULIB_FPRINTF_POSIX])
+  GNULIB_FPURGE=0;               AC_SUBST([GNULIB_FPURGE])
+  GNULIB_FPUTC=0;                AC_SUBST([GNULIB_FPUTC])
+  GNULIB_FPUTS=0;                AC_SUBST([GNULIB_FPUTS])
   GNULIB_FREOPEN=0;              AC_SUBST([GNULIB_FREOPEN])
   GNULIB_FSEEK=0;                AC_SUBST([GNULIB_FSEEK])
   GNULIB_FSEEKO=0;               AC_SUBST([GNULIB_FSEEKO])
   GNULIB_FTELL=0;                AC_SUBST([GNULIB_FTELL])
   GNULIB_FTELLO=0;               AC_SUBST([GNULIB_FTELLO])
-  GNULIB_FFLUSH=0;               AC_SUBST([GNULIB_FFLUSH])
-  GNULIB_FPURGE=0;               AC_SUBST([GNULIB_FPURGE])
-  GNULIB_FCLOSE=0;               AC_SUBST([GNULIB_FCLOSE])
-  GNULIB_FPUTC=0;                AC_SUBST([GNULIB_FPUTC])
-  GNULIB_PUTC=0;                 AC_SUBST([GNULIB_PUTC])
-  GNULIB_PUTCHAR=0;              AC_SUBST([GNULIB_PUTCHAR])
-  GNULIB_FPUTS=0;                AC_SUBST([GNULIB_FPUTS])
-  GNULIB_PUTS=0;                 AC_SUBST([GNULIB_PUTS])
   GNULIB_FWRITE=0;               AC_SUBST([GNULIB_FWRITE])
   GNULIB_GETDELIM=0;             AC_SUBST([GNULIB_GETDELIM])
   GNULIB_GETLINE=0;              AC_SUBST([GNULIB_GETLINE])
+  GNULIB_OBSTACK_PRINTF=0;       AC_SUBST([GNULIB_OBSTACK_PRINTF])
+  GNULIB_OBSTACK_PRINTF_POSIX=0; AC_SUBST([GNULIB_OBSTACK_PRINTF_POSIX])
   GNULIB_PERROR=0;               AC_SUBST([GNULIB_PERROR])
+  GNULIB_POPEN=0;                AC_SUBST([GNULIB_POPEN])
+  GNULIB_PRINTF=0;               AC_SUBST([GNULIB_PRINTF])
+  GNULIB_PRINTF_POSIX=0;         AC_SUBST([GNULIB_PRINTF_POSIX])
+  GNULIB_PUTC=0;                 AC_SUBST([GNULIB_PUTC])
+  GNULIB_PUTCHAR=0;              AC_SUBST([GNULIB_PUTCHAR])
+  GNULIB_PUTS=0;                 AC_SUBST([GNULIB_PUTS])
+  GNULIB_REMOVE=0;               AC_SUBST([GNULIB_REMOVE])
+  GNULIB_RENAME=0;               AC_SUBST([GNULIB_RENAME])
+  GNULIB_RENAMEAT=0;             AC_SUBST([GNULIB_RENAMEAT])
+  GNULIB_SNPRINTF=0;             AC_SUBST([GNULIB_SNPRINTF])
+  GNULIB_SPRINTF_POSIX=0;        AC_SUBST([GNULIB_SPRINTF_POSIX])
   GNULIB_STDIO_H_SIGPIPE=0;      AC_SUBST([GNULIB_STDIO_H_SIGPIPE])
+  GNULIB_VASPRINTF=0;            AC_SUBST([GNULIB_VASPRINTF])
+  GNULIB_VDPRINTF=0;             AC_SUBST([GNULIB_VDPRINTF])
+  GNULIB_VFPRINTF=0;             AC_SUBST([GNULIB_VFPRINTF])
+  GNULIB_VFPRINTF_POSIX=0;       AC_SUBST([GNULIB_VFPRINTF_POSIX])
+  GNULIB_VPRINTF=0;              AC_SUBST([GNULIB_VPRINTF])
+  GNULIB_VPRINTF_POSIX=0;        AC_SUBST([GNULIB_VPRINTF_POSIX])
+  GNULIB_VSNPRINTF=0;            AC_SUBST([GNULIB_VSNPRINTF])
+  GNULIB_VSPRINTF_POSIX=0;       AC_SUBST([GNULIB_VSPRINTF_POSIX])
   dnl Assume proper GNU behavior unless another module says otherwise.
-  REPLACE_STDIO_WRITE_FUNCS=0;   AC_SUBST([REPLACE_STDIO_WRITE_FUNCS])
-  REPLACE_FPRINTF=0;             AC_SUBST([REPLACE_FPRINTF])
-  REPLACE_VFPRINTF=0;            AC_SUBST([REPLACE_VFPRINTF])
-  REPLACE_PRINTF=0;              AC_SUBST([REPLACE_PRINTF])
-  REPLACE_VPRINTF=0;             AC_SUBST([REPLACE_VPRINTF])
-  REPLACE_SNPRINTF=0;            AC_SUBST([REPLACE_SNPRINTF])
+  HAVE_DECL_FPURGE=1;            AC_SUBST([HAVE_DECL_FPURGE])
+  HAVE_DECL_GETDELIM=1;          AC_SUBST([HAVE_DECL_GETDELIM])
+  HAVE_DECL_GETLINE=1;           AC_SUBST([HAVE_DECL_GETLINE])
+  HAVE_DECL_OBSTACK_PRINTF=1;    AC_SUBST([HAVE_DECL_OBSTACK_PRINTF])
   HAVE_DECL_SNPRINTF=1;          AC_SUBST([HAVE_DECL_SNPRINTF])
-  REPLACE_VSNPRINTF=0;           AC_SUBST([REPLACE_VSNPRINTF])
   HAVE_DECL_VSNPRINTF=1;         AC_SUBST([HAVE_DECL_VSNPRINTF])
-  REPLACE_SPRINTF=0;             AC_SUBST([REPLACE_SPRINTF])
-  REPLACE_VSPRINTF=0;            AC_SUBST([REPLACE_VSPRINTF])
   HAVE_DPRINTF=1;                AC_SUBST([HAVE_DPRINTF])
-  REPLACE_DPRINTF=0;             AC_SUBST([REPLACE_DPRINTF])
-  HAVE_VDPRINTF=1;               AC_SUBST([HAVE_VDPRINTF])
-  REPLACE_VDPRINTF=0;            AC_SUBST([REPLACE_VDPRINTF])
+  HAVE_RENAMEAT=1;               AC_SUBST([HAVE_RENAMEAT])
   HAVE_VASPRINTF=1;              AC_SUBST([HAVE_VASPRINTF])
-  REPLACE_VASPRINTF=0;           AC_SUBST([REPLACE_VASPRINTF])
-  HAVE_DECL_OBSTACK_PRINTF=1;    AC_SUBST([HAVE_DECL_OBSTACK_PRINTF])
-  REPLACE_OBSTACK_PRINTF=0;      AC_SUBST([REPLACE_OBSTACK_PRINTF])
+  HAVE_VDPRINTF=1;               AC_SUBST([HAVE_VDPRINTF])
+  REPLACE_DPRINTF=0;             AC_SUBST([REPLACE_DPRINTF])
+  REPLACE_FCLOSE=0;              AC_SUBST([REPLACE_FCLOSE])
+  REPLACE_FFLUSH=0;              AC_SUBST([REPLACE_FFLUSH])
   REPLACE_FOPEN=0;               AC_SUBST([REPLACE_FOPEN])
+  REPLACE_FPRINTF=0;             AC_SUBST([REPLACE_FPRINTF])
+  REPLACE_FPURGE=0;              AC_SUBST([REPLACE_FPURGE])
   REPLACE_FREOPEN=0;             AC_SUBST([REPLACE_FREOPEN])
-  HAVE_FSEEKO=1;                 AC_SUBST([HAVE_FSEEKO])
-  REPLACE_FSEEKO=0;              AC_SUBST([REPLACE_FSEEKO])
   REPLACE_FSEEK=0;               AC_SUBST([REPLACE_FSEEK])
-  HAVE_FTELLO=1;                 AC_SUBST([HAVE_FTELLO])
-  REPLACE_FTELLO=0;              AC_SUBST([REPLACE_FTELLO])
+  REPLACE_FSEEKO=0;              AC_SUBST([REPLACE_FSEEKO])
   REPLACE_FTELL=0;               AC_SUBST([REPLACE_FTELL])
-  REPLACE_FFLUSH=0;              AC_SUBST([REPLACE_FFLUSH])
-  REPLACE_FPURGE=0;              AC_SUBST([REPLACE_FPURGE])
-  HAVE_DECL_FPURGE=1;            AC_SUBST([HAVE_DECL_FPURGE])
-  REPLACE_FCLOSE=0;              AC_SUBST([REPLACE_FCLOSE])
-  HAVE_DECL_GETDELIM=1;          AC_SUBST([HAVE_DECL_GETDELIM])
-  HAVE_DECL_GETLINE=1;           AC_SUBST([HAVE_DECL_GETLINE])
+  REPLACE_FTELLO=0;              AC_SUBST([REPLACE_FTELLO])
   REPLACE_GETLINE=0;             AC_SUBST([REPLACE_GETLINE])
+  REPLACE_OBSTACK_PRINTF=0;      AC_SUBST([REPLACE_OBSTACK_PRINTF])
   REPLACE_PERROR=0;              AC_SUBST([REPLACE_PERROR])
+  REPLACE_POPEN=0;               AC_SUBST([REPLACE_POPEN])
+  REPLACE_PRINTF=0;              AC_SUBST([REPLACE_PRINTF])
+  REPLACE_REMOVE=0;              AC_SUBST([REPLACE_REMOVE])
+  REPLACE_RENAME=0;              AC_SUBST([REPLACE_RENAME])
+  REPLACE_RENAMEAT=0;            AC_SUBST([REPLACE_RENAMEAT])
+  REPLACE_SNPRINTF=0;            AC_SUBST([REPLACE_SNPRINTF])
+  REPLACE_SPRINTF=0;             AC_SUBST([REPLACE_SPRINTF])
+  REPLACE_STDIO_WRITE_FUNCS=0;   AC_SUBST([REPLACE_STDIO_WRITE_FUNCS])
+  REPLACE_VASPRINTF=0;           AC_SUBST([REPLACE_VASPRINTF])
+  REPLACE_VDPRINTF=0;            AC_SUBST([REPLACE_VDPRINTF])
+  REPLACE_VFPRINTF=0;            AC_SUBST([REPLACE_VFPRINTF])
+  REPLACE_VPRINTF=0;             AC_SUBST([REPLACE_VPRINTF])
+  REPLACE_VSNPRINTF=0;           AC_SUBST([REPLACE_VSNPRINTF])
+  REPLACE_VSPRINTF=0;            AC_SUBST([REPLACE_VSPRINTF])
 ])
 
 dnl Code shared by fseeko and ftello.  Determine if large files are supported,
@@ -131,6 +138,6 @@ AC_DEFUN([gl_STDIN_LARGE_OFFSET],
   choke me
 # endif
 #endif]])],
-	[gl_cv_var_stdin_large_offset=yes],
-	[gl_cv_var_stdin_large_offset=no])])
+        [gl_cv_var_stdin_large_offset=yes],
+        [gl_cv_var_stdin_large_offset=no])])
 ])
diff --git a/libmissing/m4/stdlib_h.m4 b/libmissing/m4/stdlib_h.m4
index b295f16..10e010e 100644
--- a/libmissing/m4/stdlib_h.m4
+++ b/libmissing/m4/stdlib_h.m4
@@ -1,4 +1,4 @@
-# stdlib_h.m4 serial 15
+# stdlib_h.m4 serial 21
 dnl Copyright (C) 2007-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -33,16 +33,21 @@ AC_DEFUN([gl_STDLIB_MODULE_INDICATOR],
 
 AC_DEFUN([gl_STDLIB_H_DEFAULTS],
 [
-  GNULIB_MALLOC_POSIX=0;  AC_SUBST([GNULIB_MALLOC_POSIX])
-  GNULIB_REALLOC_POSIX=0; AC_SUBST([GNULIB_REALLOC_POSIX])
-  GNULIB_CALLOC_POSIX=0;  AC_SUBST([GNULIB_CALLOC_POSIX])
   GNULIB_ATOLL=0;         AC_SUBST([GNULIB_ATOLL])
+  GNULIB_CALLOC_POSIX=0;  AC_SUBST([GNULIB_CALLOC_POSIX])
+  GNULIB_CANONICALIZE_FILE_NAME=0;  AC_SUBST([GNULIB_CANONICALIZE_FILE_NAME])
   GNULIB_GETLOADAVG=0;    AC_SUBST([GNULIB_GETLOADAVG])
   GNULIB_GETSUBOPT=0;     AC_SUBST([GNULIB_GETSUBOPT])
+  GNULIB_MALLOC_POSIX=0;  AC_SUBST([GNULIB_MALLOC_POSIX])
   GNULIB_MKDTEMP=0;       AC_SUBST([GNULIB_MKDTEMP])
+  GNULIB_MKOSTEMP=0;      AC_SUBST([GNULIB_MKOSTEMP])
+  GNULIB_MKOSTEMPS=0;     AC_SUBST([GNULIB_MKOSTEMPS])
   GNULIB_MKSTEMP=0;       AC_SUBST([GNULIB_MKSTEMP])
+  GNULIB_MKSTEMPS=0;      AC_SUBST([GNULIB_MKSTEMPS])
   GNULIB_PUTENV=0;        AC_SUBST([GNULIB_PUTENV])
   GNULIB_RANDOM_R=0;      AC_SUBST([GNULIB_RANDOM_R])
+  GNULIB_REALLOC_POSIX=0; AC_SUBST([GNULIB_REALLOC_POSIX])
+  GNULIB_REALPATH=0;      AC_SUBST([GNULIB_REALPATH])
   GNULIB_RPMATCH=0;       AC_SUBST([GNULIB_RPMATCH])
   GNULIB_SETENV=0;        AC_SUBST([GNULIB_SETENV])
   GNULIB_STRTOD=0;        AC_SUBST([GNULIB_STRTOD])
@@ -52,11 +57,17 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
   dnl Assume proper GNU behavior unless another module says otherwise.
   HAVE_ATOLL=1;              AC_SUBST([HAVE_ATOLL])
   HAVE_CALLOC_POSIX=1;       AC_SUBST([HAVE_CALLOC_POSIX])
+  HAVE_CANONICALIZE_FILE_NAME=1;  AC_SUBST([HAVE_CANONICALIZE_FILE_NAME])
+  HAVE_DECL_GETLOADAVG=1;    AC_SUBST([HAVE_DECL_GETLOADAVG])
   HAVE_GETSUBOPT=1;          AC_SUBST([HAVE_GETSUBOPT])
   HAVE_MALLOC_POSIX=1;       AC_SUBST([HAVE_MALLOC_POSIX])
   HAVE_MKDTEMP=1;            AC_SUBST([HAVE_MKDTEMP])
-  HAVE_REALLOC_POSIX=1;      AC_SUBST([HAVE_REALLOC_POSIX])
+  HAVE_MKOSTEMP=1;           AC_SUBST([HAVE_MKOSTEMP])
+  HAVE_MKOSTEMPS=1;          AC_SUBST([HAVE_MKOSTEMPS])
+  HAVE_MKSTEMPS=1;           AC_SUBST([HAVE_MKSTEMPS])
   HAVE_RANDOM_R=1;           AC_SUBST([HAVE_RANDOM_R])
+  HAVE_REALLOC_POSIX=1;      AC_SUBST([HAVE_REALLOC_POSIX])
+  HAVE_REALPATH=1;           AC_SUBST([HAVE_REALPATH])
   HAVE_RPMATCH=1;            AC_SUBST([HAVE_RPMATCH])
   HAVE_SETENV=1;             AC_SUBST([HAVE_SETENV])
   HAVE_STRTOD=1;             AC_SUBST([HAVE_STRTOD])
@@ -65,9 +76,11 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
   HAVE_STRUCT_RANDOM_DATA=1; AC_SUBST([HAVE_STRUCT_RANDOM_DATA])
   HAVE_SYS_LOADAVG_H=0;      AC_SUBST([HAVE_SYS_LOADAVG_H])
   HAVE_UNSETENV=1;           AC_SUBST([HAVE_UNSETENV])
-  HAVE_DECL_GETLOADAVG=1;    AC_SUBST([HAVE_DECL_GETLOADAVG])
+  REPLACE_CANONICALIZE_FILE_NAME=0;  AC_SUBST([REPLACE_CANONICALIZE_FILE_NAME])
   REPLACE_MKSTEMP=0;         AC_SUBST([REPLACE_MKSTEMP])
   REPLACE_PUTENV=0;          AC_SUBST([REPLACE_PUTENV])
+  REPLACE_REALPATH=0;        AC_SUBST([REPLACE_REALPATH])
+  REPLACE_SETENV=0;          AC_SUBST([REPLACE_SETENV])
   REPLACE_STRTOD=0;          AC_SUBST([REPLACE_STRTOD])
-  VOID_UNSETENV=0;           AC_SUBST([VOID_UNSETENV])
+  REPLACE_UNSETENV=0;        AC_SUBST([REPLACE_UNSETENV])
 ])
diff --git a/libmissing/m4/strerror.m4 b/libmissing/m4/strerror.m4
index 8c16ca9..44e69ef 100644
--- a/libmissing/m4/strerror.m4
+++ b/libmissing/m4/strerror.m4
@@ -1,5 +1,5 @@
 # strerror.m4 serial 9
-dnl Copyright (C) 2002, 2007-2008 Free Software Foundation, Inc.
+dnl Copyright (C) 2002, 2007-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/libmissing/m4/string_h.m4 b/libmissing/m4/string_h.m4
index 11f09c8..e870534 100644
--- a/libmissing/m4/string_h.m4
+++ b/libmissing/m4/string_h.m4
@@ -5,7 +5,7 @@
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 7
+# serial 9
 
 # Written by Paul Eggert.
 
@@ -66,29 +66,31 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
   GNULIB_STRSIGNAL=0;   AC_SUBST([GNULIB_STRSIGNAL])
   GNULIB_STRVERSCMP=0;   AC_SUBST([GNULIB_STRVERSCMP])
   dnl Assume proper GNU behavior unless another module says otherwise.
-  HAVE_DECL_MEMMEM=1;		AC_SUBST([HAVE_DECL_MEMMEM])
-  HAVE_MEMPCPY=1;		AC_SUBST([HAVE_MEMPCPY])
-  HAVE_DECL_MEMRCHR=1;		AC_SUBST([HAVE_DECL_MEMRCHR])
-  HAVE_RAWMEMCHR=1;		AC_SUBST([HAVE_RAWMEMCHR])
-  HAVE_STPCPY=1;		AC_SUBST([HAVE_STPCPY])
-  HAVE_STPNCPY=1;		AC_SUBST([HAVE_STPNCPY])
-  HAVE_STRCHRNUL=1;		AC_SUBST([HAVE_STRCHRNUL])
-  HAVE_DECL_STRDUP=1;		AC_SUBST([HAVE_DECL_STRDUP])
-  HAVE_STRNDUP=1;		AC_SUBST([HAVE_STRNDUP])
-  HAVE_DECL_STRNDUP=1;		AC_SUBST([HAVE_DECL_STRNDUP])
-  HAVE_DECL_STRNLEN=1;		AC_SUBST([HAVE_DECL_STRNLEN])
-  HAVE_STRPBRK=1;		AC_SUBST([HAVE_STRPBRK])
-  HAVE_STRSEP=1;		AC_SUBST([HAVE_STRSEP])
-  HAVE_STRCASESTR=1;		AC_SUBST([HAVE_STRCASESTR])
-  HAVE_DECL_STRTOK_R=1;		AC_SUBST([HAVE_DECL_STRTOK_R])
-  HAVE_DECL_STRERROR=1;		AC_SUBST([HAVE_DECL_STRERROR])
-  HAVE_DECL_STRSIGNAL=1;	AC_SUBST([HAVE_DECL_STRSIGNAL])
-  HAVE_STRVERSCMP=1;		AC_SUBST([HAVE_STRVERSCMP])
-  REPLACE_MEMCHR=0;		AC_SUBST([REPLACE_MEMCHR])
-  REPLACE_MEMMEM=0;		AC_SUBST([REPLACE_MEMMEM])
-  REPLACE_STRDUP=0;		AC_SUBST([REPLACE_STRDUP])
-  REPLACE_STRSTR=0;		AC_SUBST([REPLACE_STRSTR])
-  REPLACE_STRCASESTR=0;		AC_SUBST([REPLACE_STRCASESTR])
-  REPLACE_STRERROR=0;		AC_SUBST([REPLACE_STRERROR])
-  REPLACE_STRSIGNAL=0;		AC_SUBST([REPLACE_STRSIGNAL])
+  HAVE_DECL_MEMMEM=1;           AC_SUBST([HAVE_DECL_MEMMEM])
+  HAVE_MEMPCPY=1;               AC_SUBST([HAVE_MEMPCPY])
+  HAVE_DECL_MEMRCHR=1;          AC_SUBST([HAVE_DECL_MEMRCHR])
+  HAVE_RAWMEMCHR=1;             AC_SUBST([HAVE_RAWMEMCHR])
+  HAVE_STPCPY=1;                AC_SUBST([HAVE_STPCPY])
+  HAVE_STPNCPY=1;               AC_SUBST([HAVE_STPNCPY])
+  HAVE_STRCHRNUL=1;             AC_SUBST([HAVE_STRCHRNUL])
+  HAVE_DECL_STRDUP=1;           AC_SUBST([HAVE_DECL_STRDUP])
+  HAVE_DECL_STRNDUP=1;          AC_SUBST([HAVE_DECL_STRNDUP])
+  HAVE_DECL_STRNLEN=1;          AC_SUBST([HAVE_DECL_STRNLEN])
+  HAVE_STRPBRK=1;               AC_SUBST([HAVE_STRPBRK])
+  HAVE_STRSEP=1;                AC_SUBST([HAVE_STRSEP])
+  HAVE_STRCASESTR=1;            AC_SUBST([HAVE_STRCASESTR])
+  HAVE_DECL_STRTOK_R=1;         AC_SUBST([HAVE_DECL_STRTOK_R])
+  HAVE_DECL_STRERROR=1;         AC_SUBST([HAVE_DECL_STRERROR])
+  HAVE_DECL_STRSIGNAL=1;        AC_SUBST([HAVE_DECL_STRSIGNAL])
+  HAVE_STRVERSCMP=1;            AC_SUBST([HAVE_STRVERSCMP])
+  REPLACE_MEMCHR=0;             AC_SUBST([REPLACE_MEMCHR])
+  REPLACE_MEMMEM=0;             AC_SUBST([REPLACE_MEMMEM])
+  REPLACE_STRDUP=0;             AC_SUBST([REPLACE_STRDUP])
+  REPLACE_STRSTR=0;             AC_SUBST([REPLACE_STRSTR])
+  REPLACE_STRCASESTR=0;         AC_SUBST([REPLACE_STRCASESTR])
+  REPLACE_STRERROR=0;           AC_SUBST([REPLACE_STRERROR])
+  REPLACE_STRNDUP=0;            AC_SUBST([REPLACE_STRNDUP])
+  REPLACE_STRSIGNAL=0;          AC_SUBST([REPLACE_STRSIGNAL])
+  REPLACE_STRTOK_R=0;           AC_SUBST([REPLACE_STRTOK_R])
+  UNDEFINE_STRTOK_R=0;          AC_SUBST([UNDEFINE_STRTOK_R])
 ])
diff --git a/libmissing/m4/strings_h.m4 b/libmissing/m4/strings_h.m4
index 03ac182..de0e0a6 100644
--- a/libmissing/m4/strings_h.m4
+++ b/libmissing/m4/strings_h.m4
@@ -1,6 +1,6 @@
 # Configure a replacement for <string.h>.
 
-# Copyright (C) 2007 Free Software Foundation, Inc.
+# Copyright (C) 2007, 2009 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
diff --git a/libmissing/m4/sys_select_h.m4 b/libmissing/m4/sys_select_h.m4
index c48be2c..991c7b7 100644
--- a/libmissing/m4/sys_select_h.m4
+++ b/libmissing/m4/sys_select_h.m4
@@ -1,4 +1,4 @@
-# sys_select_h.m4 serial 7
+# sys_select_h.m4 serial 8
 dnl Copyright (C) 2006-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -11,10 +11,39 @@ AC_DEFUN([gl_HEADER_SYS_SELECT],
   AC_CACHE_CHECK([whether <sys/select.h> is self-contained],
     [gl_cv_header_sys_select_h_selfcontained],
     [
+      dnl Test against two bugs:
+      dnl 1. On many platforms, <sys/select.h> assumes prior inclusion of
+      dnl    <sys/types.h>.
+      dnl 2. On OSF/1 4.0, <sys/select.h> provides only a forward declaration
+      dnl    of 'struct timeval', and no definition of this type.
       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/select.h>]],
-					 [[struct timeval b;]])],
+                                         [[struct timeval b;]])],
         [gl_cv_header_sys_select_h_selfcontained=yes],
         [gl_cv_header_sys_select_h_selfcontained=no])
+      dnl Test against another bug:
+      dnl 3. On Solaris 10, <sys/select.h> provides an FD_ZERO implementation
+      dnl    that relies on memset(), but without including <string.h>.
+      if test $gl_cv_header_sys_select_h_selfcontained = yes; then
+        AC_COMPILE_IFELSE(
+          [AC_LANG_PROGRAM([[#include <sys/select.h>]],
+                           [[int memset; int bzero;]])
+          ],
+          [AC_LINK_IFELSE(
+             [AC_LANG_PROGRAM([[#include <sys/select.h>]], [[
+                  #undef memset
+                  #define memset nonexistent_memset
+                  extern void *memset (void *, int, unsigned long);
+                  #undef bzero
+                  #define bzero nonexistent_bzero
+                  extern void bzero (void *, unsigned long);
+                  fd_set fds;
+                  FD_ZERO (&fds);
+                ]])
+             ],
+             [],
+             [gl_cv_header_sys_select_h_selfcontained=no])
+          ])
+      fi
     ])
   if test $gl_cv_header_sys_select_h_selfcontained = yes; then
     SYS_SELECT_H=''
diff --git a/libmissing/m4/sys_socket_h.m4 b/libmissing/m4/sys_socket_h.m4
index 74e8110..e864b2c 100644
--- a/libmissing/m4/sys_socket_h.m4
+++ b/libmissing/m4/sys_socket_h.m4
@@ -1,4 +1,4 @@
-# sys_socket_h.m4 serial 12
+# sys_socket_h.m4 serial 13
 dnl Copyright (C) 2005-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -92,7 +92,7 @@ AC_DEFUN([gl_PREREQ_SYS_H_SOCKET],
   AC_SUBST([HAVE_WS2TCPIP_H])
 ])
 
-# Common prerequisites of of the <sys/socket.h> replacement and of the
+# Common prerequisites of the <sys/socket.h> replacement and of the
 # <sys/select.h> replacement.
 # Sets and substitutes HAVE_WINSOCK2_H.
 AC_DEFUN([gl_PREREQ_SYS_H_WINSOCK2],
@@ -140,6 +140,8 @@ AC_DEFUN([gl_SYS_SOCKET_H_DEFAULTS],
   GNULIB_SENDTO=0;      AC_SUBST([GNULIB_SENDTO])
   GNULIB_SETSOCKOPT=0;  AC_SUBST([GNULIB_SETSOCKOPT])
   GNULIB_SHUTDOWN=0;    AC_SUBST([GNULIB_SHUTDOWN])
+  GNULIB_ACCEPT4=0;     AC_SUBST([GNULIB_ACCEPT4])
   HAVE_STRUCT_SOCKADDR_STORAGE=1; AC_SUBST([HAVE_STRUCT_SOCKADDR_STORAGE])
   HAVE_SA_FAMILY_T=1;   AC_SUBST([HAVE_SA_FAMILY_T])
+  HAVE_ACCEPT4=1;       AC_SUBST([HAVE_ACCEPT4])
 ])
diff --git a/libmissing/m4/sys_stat_h.m4 b/libmissing/m4/sys_stat_h.m4
index 20c82ed..838cf48 100644
--- a/libmissing/m4/sys_stat_h.m4
+++ b/libmissing/m4/sys_stat_h.m4
@@ -1,26 +1,16 @@
-# sys_stat_h.m4 serial 10   -*- Autoconf -*-
-dnl Copyright (C) 2006-2008 Free Software Foundation, Inc.
+# sys_stat_h.m4 serial 21   -*- Autoconf -*-
+dnl Copyright (C) 2006-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
 
 dnl From Eric Blake.
-dnl Test whether <sys/stat.h> contains lstat and mkdir or must be substituted.
+dnl Provide a GNU-like <sys/stat.h>.
 
 AC_DEFUN([gl_HEADER_SYS_STAT_H],
 [
   AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
 
-  dnl Check for lstat.  Systems that lack it (mingw) also lack symlinks, so
-  dnl stat is a good replacement.
-  AC_CHECK_FUNCS_ONCE([lstat])
-  if test $ac_cv_func_lstat = yes; then
-    HAVE_LSTAT=1
-  else
-    HAVE_LSTAT=0
-  fi
-  AC_SUBST([HAVE_LSTAT])
-
   dnl For the mkdir substitute.
   AC_REQUIRE([AC_C_INLINE])
 
@@ -28,8 +18,6 @@ AC_DEFUN([gl_HEADER_SYS_STAT_H],
   AC_REQUIRE([AC_HEADER_STAT])
 
   gl_CHECK_NEXT_HEADERS([sys/stat.h])
-  SYS_STAT_H='sys/stat.h'
-  AC_SUBST([SYS_STAT_H])
 
   dnl Define types that are supposed to be defined in <sys/types.h> or
   dnl <sys/stat.h>.
@@ -50,10 +38,38 @@ AC_DEFUN([gl_SYS_STAT_MODULE_INDICATOR],
 
 AC_DEFUN([gl_SYS_STAT_H_DEFAULTS],
 [
-  GNULIB_LCHMOD=0; AC_SUBST([GNULIB_LCHMOD])
-  GNULIB_LSTAT=0;  AC_SUBST([GNULIB_LSTAT])
+  AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) dnl for REPLACE_FCHDIR
+  GNULIB_FCHMODAT=0;    AC_SUBST([GNULIB_FCHMODAT])
+  GNULIB_FSTATAT=0;     AC_SUBST([GNULIB_FSTATAT])
+  GNULIB_FUTIMENS=0;    AC_SUBST([GNULIB_FUTIMENS])
+  GNULIB_LCHMOD=0;      AC_SUBST([GNULIB_LCHMOD])
+  GNULIB_LSTAT=0;       AC_SUBST([GNULIB_LSTAT])
+  GNULIB_MKDIRAT=0;     AC_SUBST([GNULIB_MKDIRAT])
+  GNULIB_MKFIFO=0;      AC_SUBST([GNULIB_MKFIFO])
+  GNULIB_MKFIFOAT=0;    AC_SUBST([GNULIB_MKFIFOAT])
+  GNULIB_MKNOD=0;       AC_SUBST([GNULIB_MKNOD])
+  GNULIB_MKNODAT=0;     AC_SUBST([GNULIB_MKNODAT])
+  GNULIB_STAT=0;        AC_SUBST([GNULIB_STAT])
+  GNULIB_UTIMENSAT=0;   AC_SUBST([GNULIB_UTIMENSAT])
   dnl Assume proper GNU behavior unless another module says otherwise.
-  HAVE_LCHMOD=1;   AC_SUBST([HAVE_LCHMOD])
-  REPLACE_LSTAT=0; AC_SUBST([REPLACE_LSTAT])
-  REPLACE_MKDIR=0; AC_SUBST([REPLACE_MKDIR])
+  HAVE_FCHMODAT=1;      AC_SUBST([HAVE_FCHMODAT])
+  HAVE_FSTATAT=1;       AC_SUBST([HAVE_FSTATAT])
+  HAVE_FUTIMENS=1;      AC_SUBST([HAVE_FUTIMENS])
+  HAVE_LCHMOD=1;        AC_SUBST([HAVE_LCHMOD])
+  HAVE_LSTAT=1;         AC_SUBST([HAVE_LSTAT])
+  HAVE_MKDIRAT=1;       AC_SUBST([HAVE_MKDIRAT])
+  HAVE_MKFIFO=1;        AC_SUBST([HAVE_MKFIFO])
+  HAVE_MKFIFOAT=1;      AC_SUBST([HAVE_MKFIFOAT])
+  HAVE_MKNOD=1;         AC_SUBST([HAVE_MKNOD])
+  HAVE_MKNODAT=1;       AC_SUBST([HAVE_MKNODAT])
+  HAVE_UTIMENSAT=1;     AC_SUBST([HAVE_UTIMENSAT])
+  REPLACE_FSTAT=0;      AC_SUBST([REPLACE_FSTAT])
+  REPLACE_FSTATAT=0;    AC_SUBST([REPLACE_FSTATAT])
+  REPLACE_FUTIMENS=0;   AC_SUBST([REPLACE_FUTIMENS])
+  REPLACE_LSTAT=0;      AC_SUBST([REPLACE_LSTAT])
+  REPLACE_MKDIR=0;      AC_SUBST([REPLACE_MKDIR])
+  REPLACE_MKFIFO=0;     AC_SUBST([REPLACE_MKFIFO])
+  REPLACE_MKNOD=0;      AC_SUBST([REPLACE_MKNOD])
+  REPLACE_STAT=0;       AC_SUBST([REPLACE_STAT])
+  REPLACE_UTIMENSAT=0;  AC_SUBST([REPLACE_UTIMENSAT])
 ])
diff --git a/libmissing/m4/sys_time_h.m4 b/libmissing/m4/sys_time_h.m4
index 13ac576..10fab8e 100644
--- a/libmissing/m4/sys_time_h.m4
+++ b/libmissing/m4/sys_time_h.m4
@@ -1,6 +1,6 @@
 # Configure a replacement for <sys/time.h>.
 
-# Copyright (C) 2007 Free Software Foundation, Inc.
+# Copyright (C) 2007, 2009 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -30,12 +30,12 @@ AC_DEFUN([gl_HEADER_SYS_TIME_H_BODY],
   AC_CACHE_CHECK([for struct timeval], [gl_cv_sys_struct_timeval],
     [AC_COMPILE_IFELSE(
        [AC_LANG_PROGRAM(
-	  [[#if HAVE_SYS_TIME_H
-	     #include <sys/time.h>
-	    #endif
-	    #include <time.h>
-	  ]],
-	  [[static struct timeval x; x.tv_sec = x.tv_usec;]])],
+          [[#if HAVE_SYS_TIME_H
+             #include <sys/time.h>
+            #endif
+            #include <time.h>
+          ]],
+          [[static struct timeval x; x.tv_sec = x.tv_usec;]])],
        [gl_cv_sys_struct_timeval=yes],
        [gl_cv_sys_struct_timeval=no])])
   if test $gl_cv_sys_struct_timeval = yes; then
diff --git a/libmissing/m4/time_h.m4 b/libmissing/m4/time_h.m4
index d42a635..c038b17 100644
--- a/libmissing/m4/time_h.m4
+++ b/libmissing/m4/time_h.m4
@@ -1,7 +1,6 @@
 # Configure a more-standard replacement for <time.h>.
 
-# Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006, 2007 Free Software
-# Foundation, Inc.
+# Copyright (C) 2000-2001, 2003-2007, 2009 Free Software Foundation, Inc.
 
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -30,6 +29,7 @@ AC_DEFUN([gl_HEADER_TIME_H_DEFAULTS],
   dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK;
   dnl this lets maintainers check for portability.
   REPLACE_LOCALTIME_R=GNULIB_PORTCHECK;  AC_SUBST([REPLACE_LOCALTIME_R])
+  REPLACE_MKTIME=GNULIB_PORTCHECK;       AC_SUBST([REPLACE_MKTIME])
   REPLACE_NANOSLEEP=GNULIB_PORTCHECK;    AC_SUBST([REPLACE_NANOSLEEP])
   REPLACE_STRPTIME=GNULIB_PORTCHECK;     AC_SUBST([REPLACE_STRPTIME])
   REPLACE_TIMEGM=GNULIB_PORTCHECK;       AC_SUBST([REPLACE_TIMEGM])
@@ -45,9 +45,9 @@ AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
     [gl_cv_sys_struct_timespec_in_time_h],
     [AC_COMPILE_IFELSE(
        [AC_LANG_PROGRAM(
-	  [[#include <time.h>
-	  ]],
-	  [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
+          [[#include <time.h>
+          ]],
+          [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
        [gl_cv_sys_struct_timespec_in_time_h=yes],
        [gl_cv_sys_struct_timespec_in_time_h=no])])
 
@@ -59,12 +59,12 @@ AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
     AC_CACHE_CHECK([for struct timespec in <sys/time.h>],
       [gl_cv_sys_struct_timespec_in_sys_time_h],
       [AC_COMPILE_IFELSE(
-	 [AC_LANG_PROGRAM(
-	    [[#include <sys/time.h>
-	    ]],
-	    [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
-	 [gl_cv_sys_struct_timespec_in_sys_time_h=yes],
-	 [gl_cv_sys_struct_timespec_in_sys_time_h=no])])
+         [AC_LANG_PROGRAM(
+            [[#include <sys/time.h>
+            ]],
+            [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
+         [gl_cv_sys_struct_timespec_in_sys_time_h=yes],
+         [gl_cv_sys_struct_timespec_in_sys_time_h=no])])
     if test $gl_cv_sys_struct_timespec_in_sys_time_h = yes; then
       SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=1
     fi
diff --git a/libmissing/m4/time_r.m4 b/libmissing/m4/time_r.m4
index c871b56..de22db9 100644
--- a/libmissing/m4/time_r.m4
+++ b/libmissing/m4/time_r.m4
@@ -1,6 +1,6 @@
 dnl Reentrant time functions like localtime_r.
 
-dnl Copyright (C) 2003, 2006, 2007, 2008 Free Software Foundation, Inc.
+dnl Copyright (C) 2003, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -17,15 +17,15 @@ AC_DEFUN([gl_TIME_R],
 
   AC_CACHE_CHECK([whether localtime_r is compatible with its POSIX signature],
     [gl_cv_time_r_posix],
-    [AC_TRY_COMPILE(
-       [#include <time.h>],
-       [/* We don't need to append 'restrict's to the argument types,
-	   even though the POSIX signature has the 'restrict's,
-	   since C99 says they can't affect type compatibility.  */
-	struct tm * (*ptr) (time_t const *, struct tm *) = localtime_r;
-        if (ptr) return 0;
-        /* Check the return type is a pointer.  On HP-UX 10 it is 'int'.  */
-        *localtime_r (0, 0);],
+    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+         [[#include <time.h>]],
+         [[/* We don't need to append 'restrict's to the argument types,
+              even though the POSIX signature has the 'restrict's,
+              since C99 says they can't affect type compatibility.  */
+           struct tm * (*ptr) (time_t const *, struct tm *) = localtime_r;
+           if (ptr) return 0;
+           /* Check the return type is a pointer.  On HP-UX 10 it is 'int'.  */
+           *localtime_r (0, 0);]])],
        [gl_cv_time_r_posix=yes],
        [gl_cv_time_r_posix=no])])
   if test $gl_cv_time_r_posix = yes; then
diff --git a/libmissing/m4/unistd_h.m4 b/libmissing/m4/unistd_h.m4
index ff9a4ea..cb50d50 100644
--- a/libmissing/m4/unistd_h.m4
+++ b/libmissing/m4/unistd_h.m4
@@ -1,4 +1,4 @@
-# unistd_h.m4 serial 17
+# unistd_h.m4 serial 36
 dnl Copyright (C) 2006-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -35,49 +35,94 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
   GNULIB_CHOWN=0;            AC_SUBST([GNULIB_CHOWN])
   GNULIB_CLOSE=0;            AC_SUBST([GNULIB_CLOSE])
   GNULIB_DUP2=0;             AC_SUBST([GNULIB_DUP2])
+  GNULIB_DUP3=0;             AC_SUBST([GNULIB_DUP3])
   GNULIB_ENVIRON=0;          AC_SUBST([GNULIB_ENVIRON])
   GNULIB_EUIDACCESS=0;       AC_SUBST([GNULIB_EUIDACCESS])
+  GNULIB_FACCESSAT=0;        AC_SUBST([GNULIB_FACCESSAT])
   GNULIB_FCHDIR=0;           AC_SUBST([GNULIB_FCHDIR])
+  GNULIB_FCHOWNAT=0;         AC_SUBST([GNULIB_FCHOWNAT])
   GNULIB_FSYNC=0;            AC_SUBST([GNULIB_FSYNC])
   GNULIB_FTRUNCATE=0;        AC_SUBST([GNULIB_FTRUNCATE])
   GNULIB_GETCWD=0;           AC_SUBST([GNULIB_GETCWD])
   GNULIB_GETDOMAINNAME=0;    AC_SUBST([GNULIB_GETDOMAINNAME])
   GNULIB_GETDTABLESIZE=0;    AC_SUBST([GNULIB_GETDTABLESIZE])
+  GNULIB_GETGROUPS=0;        AC_SUBST([GNULIB_GETGROUPS])
   GNULIB_GETHOSTNAME=0;      AC_SUBST([GNULIB_GETHOSTNAME])
   GNULIB_GETLOGIN_R=0;       AC_SUBST([GNULIB_GETLOGIN_R])
   GNULIB_GETPAGESIZE=0;      AC_SUBST([GNULIB_GETPAGESIZE])
   GNULIB_GETUSERSHELL=0;     AC_SUBST([GNULIB_GETUSERSHELL])
   GNULIB_LCHOWN=0;           AC_SUBST([GNULIB_LCHOWN])
   GNULIB_LINK=0;             AC_SUBST([GNULIB_LINK])
+  GNULIB_LINKAT=0;           AC_SUBST([GNULIB_LINKAT])
   GNULIB_LSEEK=0;            AC_SUBST([GNULIB_LSEEK])
+  GNULIB_PIPE2=0;            AC_SUBST([GNULIB_PIPE2])
+  GNULIB_PREAD=0;            AC_SUBST([GNULIB_PREAD])
   GNULIB_READLINK=0;         AC_SUBST([GNULIB_READLINK])
+  GNULIB_READLINKAT=0;       AC_SUBST([GNULIB_READLINKAT])
+  GNULIB_RMDIR=0;            AC_SUBST([GNULIB_RMDIR])
   GNULIB_SLEEP=0;            AC_SUBST([GNULIB_SLEEP])
+  GNULIB_SYMLINK=0;          AC_SUBST([GNULIB_SYMLINK])
+  GNULIB_SYMLINKAT=0;        AC_SUBST([GNULIB_SYMLINKAT])
+  GNULIB_UNISTD_H_GETOPT=0;  AC_SUBST([GNULIB_UNISTD_H_GETOPT])
   GNULIB_UNISTD_H_SIGPIPE=0; AC_SUBST([GNULIB_UNISTD_H_SIGPIPE])
+  GNULIB_UNLINK=0;           AC_SUBST([GNULIB_UNLINK])
+  GNULIB_UNLINKAT=0;         AC_SUBST([GNULIB_UNLINKAT])
+  GNULIB_USLEEP=0;           AC_SUBST([GNULIB_USLEEP])
   GNULIB_WRITE=0;            AC_SUBST([GNULIB_WRITE])
   dnl Assume proper GNU behavior unless another module says otherwise.
+  HAVE_CHOWN=1;           AC_SUBST([HAVE_CHOWN])
   HAVE_DUP2=1;            AC_SUBST([HAVE_DUP2])
+  HAVE_DUP3=1;            AC_SUBST([HAVE_DUP3])
   HAVE_EUIDACCESS=1;      AC_SUBST([HAVE_EUIDACCESS])
+  HAVE_FACCESSAT=1;       AC_SUBST([HAVE_FACCESSAT])
+  HAVE_FCHOWNAT=1;        AC_SUBST([HAVE_FCHOWNAT])
   HAVE_FSYNC=1;           AC_SUBST([HAVE_FSYNC])
   HAVE_FTRUNCATE=1;       AC_SUBST([HAVE_FTRUNCATE])
   HAVE_GETDOMAINNAME=1;   AC_SUBST([HAVE_GETDOMAINNAME])
   HAVE_GETDTABLESIZE=1;   AC_SUBST([HAVE_GETDTABLESIZE])
+  HAVE_GETGROUPS=1;       AC_SUBST([HAVE_GETGROUPS])
   HAVE_GETHOSTNAME=1;     AC_SUBST([HAVE_GETHOSTNAME])
   HAVE_GETPAGESIZE=1;     AC_SUBST([HAVE_GETPAGESIZE])
   HAVE_GETUSERSHELL=1;    AC_SUBST([HAVE_GETUSERSHELL])
+  HAVE_LCHOWN=1;          AC_SUBST([HAVE_LCHOWN])
   HAVE_LINK=1;            AC_SUBST([HAVE_LINK])
+  HAVE_LINKAT=1;          AC_SUBST([HAVE_LINKAT])
+  HAVE_PIPE2=1;           AC_SUBST([HAVE_PIPE2])
+  HAVE_PREAD=1;           AC_SUBST([HAVE_PREAD])
   HAVE_READLINK=1;        AC_SUBST([HAVE_READLINK])
+  HAVE_READLINKAT=1;      AC_SUBST([HAVE_READLINKAT])
   HAVE_SLEEP=1;           AC_SUBST([HAVE_SLEEP])
+  HAVE_SYMLINK=1;         AC_SUBST([HAVE_SYMLINK])
+  HAVE_SYMLINKAT=1;       AC_SUBST([HAVE_SYMLINKAT])
   HAVE_DECL_ENVIRON=1;    AC_SUBST([HAVE_DECL_ENVIRON])
   HAVE_DECL_GETLOGIN_R=1; AC_SUBST([HAVE_DECL_GETLOGIN_R])
   HAVE_OS_H=0;            AC_SUBST([HAVE_OS_H])
   HAVE_SYS_PARAM_H=0;     AC_SUBST([HAVE_SYS_PARAM_H])
+  HAVE_UNLINKAT=1;        AC_SUBST([HAVE_UNLINKAT])
+  HAVE_USLEEP=1;          AC_SUBST([HAVE_USLEEP])
   REPLACE_CHOWN=0;        AC_SUBST([REPLACE_CHOWN])
   REPLACE_CLOSE=0;        AC_SUBST([REPLACE_CLOSE])
+  REPLACE_DUP=0;          AC_SUBST([REPLACE_DUP])
+  REPLACE_DUP2=0;         AC_SUBST([REPLACE_DUP2])
   REPLACE_FCHDIR=0;       AC_SUBST([REPLACE_FCHDIR])
+  REPLACE_FCHOWNAT=0;     AC_SUBST([REPLACE_FCHOWNAT])
   REPLACE_GETCWD=0;       AC_SUBST([REPLACE_GETCWD])
+  REPLACE_GETGROUPS=0;    AC_SUBST([REPLACE_GETGROUPS])
   REPLACE_GETPAGESIZE=0;  AC_SUBST([REPLACE_GETPAGESIZE])
   REPLACE_LCHOWN=0;       AC_SUBST([REPLACE_LCHOWN])
+  REPLACE_LINK=0;         AC_SUBST([REPLACE_LINK])
+  REPLACE_LINKAT=0;       AC_SUBST([REPLACE_LINKAT])
   REPLACE_LSEEK=0;        AC_SUBST([REPLACE_LSEEK])
+  REPLACE_PREAD=0;        AC_SUBST([REPLACE_PREAD])
+  REPLACE_READLINK=0;     AC_SUBST([REPLACE_READLINK])
+  REPLACE_RMDIR=0;        AC_SUBST([REPLACE_RMDIR])
+  REPLACE_SLEEP=0;        AC_SUBST([REPLACE_SLEEP])
+  REPLACE_SYMLINK=0;      AC_SUBST([REPLACE_SYMLINK])
+  REPLACE_UNLINK=0;       AC_SUBST([REPLACE_UNLINK])
+  REPLACE_UNLINKAT=0;     AC_SUBST([REPLACE_UNLINKAT])
+  REPLACE_USLEEP=0;       AC_SUBST([REPLACE_USLEEP])
   REPLACE_WRITE=0;        AC_SUBST([REPLACE_WRITE])
   UNISTD_H_HAVE_WINSOCK2_H=0; AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H])
+  UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=0;
+                           AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS])
 ])
diff --git a/libmissing/m4/wchar.m4 b/libmissing/m4/wchar.m4
index 2e52a82..ad19376 100644
--- a/libmissing/m4/wchar.m4
+++ b/libmissing/m4/wchar.m4
@@ -7,11 +7,12 @@ dnl with or without modifications, as long as this notice is preserved.
 
 dnl Written by Eric Blake.
 
-# wchar.m4 serial 23
+# wchar.m4 serial 27
 
 AC_DEFUN([gl_WCHAR_H],
 [
   AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+  AC_REQUIRE([gl_WCHAR_H_INLINE_OK])
   AC_CACHE_CHECK([whether <wchar.h> is standalone],
     [gl_cv_header_wchar_h_standalone],
     [AC_COMPILE_IFELSE([[#include <wchar.h>
@@ -27,7 +28,10 @@ wchar_t w;]],
   fi
   AC_SUBST([HAVE_WINT_T])
 
-  if test $gl_cv_header_wchar_h_standalone != yes || test $gt_cv_c_wint_t != yes; then
+  dnl If <stddef.h> is replaced, then <wchar.h> must also be replaced.
+  AC_REQUIRE([gl_STDDEF_H])
+
+  if test $gl_cv_header_wchar_h_standalone != yes || test $gt_cv_c_wint_t != yes || test -n "$STDDEF_H"; then
     WCHAR_H=wchar.h
   fi
 
@@ -42,9 +46,59 @@ wchar_t w;]],
     HAVE_WCHAR_H=0
   fi
   AC_SUBST([HAVE_WCHAR_H])
+  dnl Execute this unconditionally, because WCHAR_H may be set by other
+  dnl modules, after this code is executed.
   gl_CHECK_NEXT_HEADERS([wchar.h])
 ])
 
+dnl Check whether <wchar.h> is usable at all.
+AC_DEFUN([gl_WCHAR_H_INLINE_OK],
+[
+  dnl Test whether <wchar.h> suffers due to the transition from '__inline' to
+  dnl 'gnu_inline'. See <http://sourceware.org/bugzilla/show_bug.cgi?id=4022>
+  dnl and <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42440>. In summary,
+  dnl glibc version 2.5 or older, together with gcc version 4.3 or newer and
+  dnl the option -std=c99 or -std=gnu99, leads to a broken <wchar.h>.
+  AC_CACHE_CHECK([whether <wchar.h> uses 'inline' correctly],
+    [gl_cv_header_wchar_h_correct_inline],
+    [gl_cv_header_wchar_h_correct_inline=yes
+     AC_LANG_CONFTEST([
+       AC_LANG_SOURCE([[#define wcstod renamed_wcstod
+#include <wchar.h>
+extern int zero (void);
+int main () { return zero(); }
+]])])
+     if AC_TRY_EVAL([ac_compile]); then
+       mv conftest.$ac_objext conftest1.$ac_objext
+       AC_LANG_CONFTEST([
+         AC_LANG_SOURCE([[#define wcstod renamed_wcstod
+#include <wchar.h>
+int zero (void) { return 0; }
+]])])
+       if AC_TRY_EVAL([ac_compile]); then
+         mv conftest.$ac_objext conftest2.$ac_objext
+         if $CC -o conftest$ac_exeext $CFLAGS $LDFLAGS conftest1.$ac_objext conftest2.$ac_objext $LIBS >&AS_MESSAGE_LOG_FD 2>&1; then
+           :
+         else
+           gl_cv_header_wchar_h_correct_inline=no
+         fi
+       fi
+     fi
+     rm -f conftest1.$ac_objext conftest2.$ac_objext conftest$ac_exeext
+    ])
+  if test $gl_cv_header_wchar_h_correct_inline = no; then
+    AC_MSG_ERROR([<wchar.h> cannot be used with this compiler ($CC $CFLAGS $CPPFLAGS).
+This is a known interoperability problem of glibc <= 2.5 with gcc >= 4.3 in
+C99 mode. You have four options:
+  - Add the flag -fgnu89-inline to CC and reconfigure, or
+  - Fix your include files, using parts of
+    <http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=b037a293a48718af30d706c2e18c929d0e69a621>, or
+  - Use a gcc version older than 4.3, or
+  - Don't use the flags -std=c99 or -std=gnu99.
+Configuration aborted.])
+  fi
+])
+
 dnl Unconditionally enables the replacement of <wchar.h>.
 AC_DEFUN([gl_REPLACE_WCHAR_H],
 [
diff --git a/libmissing/m4/wctype.m4 b/libmissing/m4/wctype.m4
index 6a1b6f0..b611ebb 100644
--- a/libmissing/m4/wctype.m4
+++ b/libmissing/m4/wctype.m4
@@ -1,8 +1,8 @@
-# wctype.m4 serial 2
+# wctype.m4 serial 4
 
 dnl A placeholder for ISO C99 <wctype.h>, for platforms that lack it.
 
-dnl Copyright (C) 2006-2008 Free Software Foundation, Inc.
+dnl Copyright (C) 2006-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -12,6 +12,7 @@ dnl Written by Paul Eggert.
 AC_DEFUN([gl_WCTYPE_H],
 [
   AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([AC_CANONICAL_HOST])
   AC_CHECK_FUNCS_ONCE([iswcntrl])
   if test $ac_cv_func_iswcntrl = yes; then
     HAVE_ISWCNTRL=1
@@ -37,22 +38,31 @@ AC_DEFUN([gl_WCTYPE_H],
       dnl The other functions are likely broken in the same way.
       AC_CACHE_CHECK([whether iswcntrl works], [gl_cv_func_iswcntrl_works],
         [
-          AC_TRY_RUN([#include <stddef.h>
-                      #include <stdio.h>
-                      #include <time.h>
-                      #include <wchar.h>
-                      #include <wctype.h>
-                      int main () { return iswprint ('x') == 0; }],
+          AC_RUN_IFELSE([AC_LANG_SOURCE([[
+                            #include <stddef.h>
+                            #include <stdio.h>
+                            #include <time.h>
+                            #include <wchar.h>
+                            #include <wctype.h>
+                            int main () { return iswprint ('x') == 0; }]])],
             [gl_cv_func_iswcntrl_works=yes], [gl_cv_func_iswcntrl_works=no],
-            [AC_TRY_COMPILE([#include <stdlib.h>
+            [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
                           #if __GNU_LIBRARY__ == 1
                           Linux libc5 i18n is broken.
-                          #endif], [],
+                          #endif]], [])],
               [gl_cv_func_iswcntrl_works=yes], [gl_cv_func_iswcntrl_works=no])
             ])
         ])
       if test $gl_cv_func_iswcntrl_works = yes; then
-        WCTYPE_H=
+        case "$host_os" in
+          mingw*)
+            dnl On mingw, towlower and towupper return random high 16 bits.
+            ;;
+          *)
+            dnl iswcntrl works. towlower and towupper work as well.
+            WCTYPE_H=
+            ;;
+        esac
       fi
     fi
     dnl Compute NEXT_WCTYPE_H even if WCTYPE_H is empty,
diff --git a/libmissing/m4/xsize.m4 b/libmissing/m4/xsize.m4
index 631893c..af293de 100644
--- a/libmissing/m4/xsize.m4
+++ b/libmissing/m4/xsize.m4
@@ -1,5 +1,5 @@
 # xsize.m4 serial 4
-dnl Copyright (C) 2003-2004, 2008 Free Software Foundation, Inc.
+dnl Copyright (C) 2003-2004, 2008-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/libmissing/malloc.c b/libmissing/malloc.c
index 9111c7a..fcb8e72 100644
--- a/libmissing/malloc.c
+++ b/libmissing/malloc.c
@@ -1,6 +1,6 @@
 /* malloc() function that is glibc compatible.
 
-   Copyright (C) 1997, 1998, 2006, 2007 Free Software Foundation, Inc.
+   Copyright (C) 1997-1998, 2006-2007, 2009 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/libmissing/mbrtowc.c b/libmissing/mbrtowc.c
index 7b528e8..e8b26e2 100644
--- a/libmissing/mbrtowc.c
+++ b/libmissing/mbrtowc.c
@@ -63,30 +63,30 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
     switch (nstate)
       {
       case 0:
-	p = s;
-	m = n;
-	break;
+        p = s;
+        m = n;
+        break;
       case 3:
-	buf[2] = pstate[3];
-	/*FALLTHROUGH*/
+        buf[2] = pstate[3];
+        /*FALLTHROUGH*/
       case 2:
-	buf[1] = pstate[2];
-	/*FALLTHROUGH*/
+        buf[1] = pstate[2];
+        /*FALLTHROUGH*/
       case 1:
-	buf[0] = pstate[1];
-	p = buf;
-	m = nstate;
-	buf[m++] = s[0];
-	if (n >= 2 && m < 4)
-	  {
-	    buf[m++] = s[1];
-	    if (n >= 3 && m < 4)
-	      buf[m++] = s[2];
-	  }
-	break;
+        buf[0] = pstate[1];
+        p = buf;
+        m = nstate;
+        buf[m++] = s[0];
+        if (n >= 2 && m < 4)
+          {
+            buf[m++] = s[1];
+            if (n >= 3 && m < 4)
+              buf[m++] = s[2];
+          }
+        break;
       default:
-	errno = EINVAL;
-	return (size_t)(-1);
+        errno = EINVAL;
+        return (size_t)(-1);
       }
 
     /* Here m > 0.  */
@@ -99,208 +99,208 @@ mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
       int res = mbtowc (pwc, p, m);
 
       if (res >= 0)
-	{
-	  if (pwc != NULL && ((*pwc == 0) != (res == 0)))
-	    abort ();
-	  if (nstate >= (res > 0 ? res : 1))
-	    abort ();
-	  res -= nstate;
-	  pstate[0] = 0;
-	  return res;
-	}
+        {
+          if (pwc != NULL && ((*pwc == 0) != (res == 0)))
+            abort ();
+          if (nstate >= (res > 0 ? res : 1))
+            abort ();
+          res -= nstate;
+          pstate[0] = 0;
+          return res;
+        }
 
       /* mbtowc does not distinguish between invalid and incomplete multibyte
-	 sequences.  But mbrtowc needs to make this distinction.
-	 There are two possible approaches:
-	   - Use iconv() and its return value.
-	   - Use built-in knowledge about the possible encodings.
-	 Given the low quality of implementation of iconv() on the systems that
-	 lack mbrtowc(), we use the second approach.
-	 The possible encodings are:
-	   - 8-bit encodings,
-	   - EUC-JP, EUC-KR, GB2312, EUC-TW, BIG5, GB18030, SJIS,
-	   - UTF-8.
-	 Use specialized code for each.  */
+         sequences.  But mbrtowc needs to make this distinction.
+         There are two possible approaches:
+           - Use iconv() and its return value.
+           - Use built-in knowledge about the possible encodings.
+         Given the low quality of implementation of iconv() on the systems that
+         lack mbrtowc(), we use the second approach.
+         The possible encodings are:
+           - 8-bit encodings,
+           - EUC-JP, EUC-KR, GB2312, EUC-TW, BIG5, GB18030, SJIS,
+           - UTF-8.
+         Use specialized code for each.  */
       if (m >= 4 || m >= MB_CUR_MAX)
-	goto invalid;
+        goto invalid;
       /* Here MB_CUR_MAX > 1 and 0 < m < 4.  */
       {
-	const char *encoding = locale_charset ();
-
-	if (STREQ (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0))
-	  {
-	    /* Cf. unistr/u8-mblen.c.  */
-	    unsigned char c = (unsigned char) p[0];
-
-	    if (c >= 0xc2)
-	      {
-		if (c < 0xe0)
-		  {
-		    if (m == 1)
-		      goto incomplete;
-		  }
-		else if (c < 0xf0)
-		  {
-		    if (m == 1)
-		      goto incomplete;
-		    if (m == 2)
-		      {
-			unsigned char c2 = (unsigned char) p[1];
-
-			if ((c2 ^ 0x80) < 0x40
-			    && (c >= 0xe1 || c2 >= 0xa0)
-			    && (c != 0xed || c2 < 0xa0))
-			  goto incomplete;
-		      }
-		  }
-		else if (c <= 0xf4)
-		  {
-		    if (m == 1)
-		      goto incomplete;
-		    else /* m == 2 || m == 3 */
-		      {
-			unsigned char c2 = (unsigned char) p[1];
-
-			if ((c2 ^ 0x80) < 0x40
-			    && (c >= 0xf1 || c2 >= 0x90)
-			    && (c < 0xf4 || (c == 0xf4 && c2 < 0x90)))
-			  {
-			    if (m == 2)
-			      goto incomplete;
-			    else /* m == 3 */
-			      {
-				unsigned char c3 = (unsigned char) p[2];
-
-				if ((c3 ^ 0x80) < 0x40)
-				  goto incomplete;
-			      }
-			  }
-		      }
-		  }
-	      }
-	    goto invalid;
-	  }
-
-	/* As a reference for this code, you can use the GNU libiconv
-	   implementation.  Look for uses of the RET_TOOFEW macro.  */
-
-	if (STREQ (encoding, "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0))
-	  {
-	    if (m == 1)
-	      {
-		unsigned char c = (unsigned char) p[0];
-
-		if ((c >= 0xa1 && c < 0xff) || c == 0x8e || c == 0x8f)
-		  goto incomplete;
-	      }
-	    if (m == 2)
-	      {
-		unsigned char c = (unsigned char) p[0];
-
-		if (c == 0x8f)
-		  {
-		    unsigned char c2 = (unsigned char) p[1];
-
-		    if (c2 >= 0xa1 && c2 < 0xff)
-		      goto incomplete;
-		  }
-	      }
-	    goto invalid;
-	  }
-	if (STREQ (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
-	    || STREQ (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0)
-	    || STREQ (encoding, "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0))
-	  {
-	    if (m == 1)
-	      {
-		unsigned char c = (unsigned char) p[0];
-
-		if (c >= 0xa1 && c < 0xff)
-		  goto incomplete;
-	      }
-	    goto invalid;
-	  }
-	if (STREQ (encoding, "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0))
-	  {
-	    if (m == 1)
-	      {
-		unsigned char c = (unsigned char) p[0];
-
-		if ((c >= 0xa1 && c < 0xff) || c == 0x8e)
-		  goto incomplete;
-	      }
-	    else /* m == 2 || m == 3 */
-	      {
-		unsigned char c = (unsigned char) p[0];
-
-		if (c == 0x8e)
-		  goto incomplete;
-	      }
-	    goto invalid;
-	  }
-	if (STREQ (encoding, "GB18030", 'G', 'B', '1', '8', '0', '3', '0', 0, 0))
-	  {
-	    if (m == 1)
-	      {
-		unsigned char c = (unsigned char) p[0];
-
-		if ((c >= 0x90 && c <= 0xe3) || (c >= 0xf8 && c <= 0xfe))
-		  goto incomplete;
-	      }
-	    else /* m == 2 || m == 3 */
-	      {
-		unsigned char c = (unsigned char) p[0];
-
-		if (c >= 0x90 && c <= 0xe3)
-		  {
-		    unsigned char c2 = (unsigned char) p[1];
-
-		    if (c2 >= 0x30 && c2 <= 0x39)
-		      {
-			if (m == 2)
-			  goto incomplete;
-			else /* m == 3 */
-			  {
-			    unsigned char c3 = (unsigned char) p[2];
-
-			    if (c3 >= 0x81 && c3 <= 0xfe)
-			      goto incomplete;
-			  }
-		      }
-		  }
-	      }
-	    goto invalid;
-	  }
-	if (STREQ (encoding, "SJIS", 'S', 'J', 'I', 'S', 0, 0, 0, 0, 0))
-	  {
-	    if (m == 1)
-	      {
-		unsigned char c = (unsigned char) p[0];
-
-		if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xea)
-		    || (c >= 0xf0 && c <= 0xf9))
-		  goto incomplete;
-	      }
-	    goto invalid;
-	  }
-
-	/* An unknown multibyte encoding.  */
-	goto incomplete;
+        const char *encoding = locale_charset ();
+
+        if (STREQ (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0))
+          {
+            /* Cf. unistr/u8-mblen.c.  */
+            unsigned char c = (unsigned char) p[0];
+
+            if (c >= 0xc2)
+              {
+                if (c < 0xe0)
+                  {
+                    if (m == 1)
+                      goto incomplete;
+                  }
+                else if (c < 0xf0)
+                  {
+                    if (m == 1)
+                      goto incomplete;
+                    if (m == 2)
+                      {
+                        unsigned char c2 = (unsigned char) p[1];
+
+                        if ((c2 ^ 0x80) < 0x40
+                            && (c >= 0xe1 || c2 >= 0xa0)
+                            && (c != 0xed || c2 < 0xa0))
+                          goto incomplete;
+                      }
+                  }
+                else if (c <= 0xf4)
+                  {
+                    if (m == 1)
+                      goto incomplete;
+                    else /* m == 2 || m == 3 */
+                      {
+                        unsigned char c2 = (unsigned char) p[1];
+
+                        if ((c2 ^ 0x80) < 0x40
+                            && (c >= 0xf1 || c2 >= 0x90)
+                            && (c < 0xf4 || (c == 0xf4 && c2 < 0x90)))
+                          {
+                            if (m == 2)
+                              goto incomplete;
+                            else /* m == 3 */
+                              {
+                                unsigned char c3 = (unsigned char) p[2];
+
+                                if ((c3 ^ 0x80) < 0x40)
+                                  goto incomplete;
+                              }
+                          }
+                      }
+                  }
+              }
+            goto invalid;
+          }
+
+        /* As a reference for this code, you can use the GNU libiconv
+           implementation.  Look for uses of the RET_TOOFEW macro.  */
+
+        if (STREQ (encoding, "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0))
+          {
+            if (m == 1)
+              {
+                unsigned char c = (unsigned char) p[0];
+
+                if ((c >= 0xa1 && c < 0xff) || c == 0x8e || c == 0x8f)
+                  goto incomplete;
+              }
+            if (m == 2)
+              {
+                unsigned char c = (unsigned char) p[0];
+
+                if (c == 0x8f)
+                  {
+                    unsigned char c2 = (unsigned char) p[1];
+
+                    if (c2 >= 0xa1 && c2 < 0xff)
+                      goto incomplete;
+                  }
+              }
+            goto invalid;
+          }
+        if (STREQ (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
+            || STREQ (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0)
+            || STREQ (encoding, "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0))
+          {
+            if (m == 1)
+              {
+                unsigned char c = (unsigned char) p[0];
+
+                if (c >= 0xa1 && c < 0xff)
+                  goto incomplete;
+              }
+            goto invalid;
+          }
+        if (STREQ (encoding, "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0))
+          {
+            if (m == 1)
+              {
+                unsigned char c = (unsigned char) p[0];
+
+                if ((c >= 0xa1 && c < 0xff) || c == 0x8e)
+                  goto incomplete;
+              }
+            else /* m == 2 || m == 3 */
+              {
+                unsigned char c = (unsigned char) p[0];
+
+                if (c == 0x8e)
+                  goto incomplete;
+              }
+            goto invalid;
+          }
+        if (STREQ (encoding, "GB18030", 'G', 'B', '1', '8', '0', '3', '0', 0, 0))
+          {
+            if (m == 1)
+              {
+                unsigned char c = (unsigned char) p[0];
+
+                if ((c >= 0x90 && c <= 0xe3) || (c >= 0xf8 && c <= 0xfe))
+                  goto incomplete;
+              }
+            else /* m == 2 || m == 3 */
+              {
+                unsigned char c = (unsigned char) p[0];
+
+                if (c >= 0x90 && c <= 0xe3)
+                  {
+                    unsigned char c2 = (unsigned char) p[1];
+
+                    if (c2 >= 0x30 && c2 <= 0x39)
+                      {
+                        if (m == 2)
+                          goto incomplete;
+                        else /* m == 3 */
+                          {
+                            unsigned char c3 = (unsigned char) p[2];
+
+                            if (c3 >= 0x81 && c3 <= 0xfe)
+                              goto incomplete;
+                          }
+                      }
+                  }
+              }
+            goto invalid;
+          }
+        if (STREQ (encoding, "SJIS", 'S', 'J', 'I', 'S', 0, 0, 0, 0, 0))
+          {
+            if (m == 1)
+              {
+                unsigned char c = (unsigned char) p[0];
+
+                if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xea)
+                    || (c >= 0xf0 && c <= 0xf9))
+                  goto incomplete;
+              }
+            goto invalid;
+          }
+
+        /* An unknown multibyte encoding.  */
+        goto incomplete;
       }
 
      incomplete:
       {
-	size_t k = nstate;
-	/* Here 0 <= k < m < 4.  */
-	pstate[++k] = s[0];
-	if (k < m)
-	  {
-	    pstate[++k] = s[1];
-	    if (k < m)
-	      pstate[++k] = s[2];
-	  }
-	if (k != m)
-	  abort ();
+        size_t k = nstate;
+        /* Here 0 <= k < m < 4.  */
+        pstate[++k] = s[0];
+        if (k < m)
+          {
+            pstate[++k] = s[1];
+            if (k < m)
+              pstate[++k] = s[2];
+          }
+        if (k != m)
+          abort ();
       }
       pstate[0] = m;
       return (size_t)(-2);
@@ -341,25 +341,25 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
 
     if (!mbsinit (ps))
       {
-	/* Parse the rest of the multibyte character byte for byte.  */
-	size_t count = 0;
-	for (; n > 0; s++, n--)
-	  {
-	    wchar_t wc;
-	    size_t ret = mbrtowc (&wc, s, 1, ps);
-
-	    if (ret == (size_t)(-1))
-	      return (size_t)(-1);
-	    count++;
-	    if (ret != (size_t)(-2))
-	      {
-		/* The multibyte character has been completed.  */
-		if (pwc != NULL)
-		  *pwc = wc;
-		return (wc == 0 ? 0 : count);
-	      }
-	  }
-	return (size_t)(-2);
+        /* Parse the rest of the multibyte character byte for byte.  */
+        size_t count = 0;
+        for (; n > 0; s++, n--)
+          {
+            wchar_t wc;
+            size_t ret = mbrtowc (&wc, s, 1, ps);
+
+            if (ret == (size_t)(-1))
+              return (size_t)(-1);
+            count++;
+            if (ret != (size_t)(-2))
+              {
+                /* The multibyte character has been completed.  */
+                if (pwc != NULL)
+                  *pwc = wc;
+                return (wc == 0 ? 0 : count);
+              }
+          }
+        return (size_t)(-2);
       }
   }
 # endif
@@ -371,10 +371,10 @@ rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
 
     if (ret != (size_t)(-1) && ret != (size_t)(-2))
       {
-	if (pwc != NULL)
-	  *pwc = wc;
-	if (wc == 0)
-	  ret = 0;
+        if (pwc != NULL)
+          *pwc = wc;
+        if (wc == 0)
+          ret = 0;
       }
     return ret;
   }
diff --git a/libmissing/mbsinit.c b/libmissing/mbsinit.c
index 7495794..f152eec 100644
--- a/libmissing/mbsinit.c
+++ b/libmissing/mbsinit.c
@@ -1,5 +1,5 @@
 /* Test for initial conversion state.
-   Copyright (C) 2008 Free Software Foundation, Inc.
+   Copyright (C) 2008, 2009 Free Software Foundation, Inc.
    Written by Bruno Haible <[email protected]>, 2008.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/libmissing/mbsrtowcs.c b/libmissing/mbsrtowcs.c
index 66427ab..49dbc5a 100644
--- a/libmissing/mbsrtowcs.c
+++ b/libmissing/mbsrtowcs.c
@@ -1,5 +1,5 @@
 /* Convert string to wide string.
-   Copyright (C) 2008 Free Software Foundation, Inc.
+   Copyright (C) 2008, 2009 Free Software Foundation, Inc.
    Written by Bruno Haible <[email protected]>, 2008.
 
    This program is free software: you can redistribute it and/or modify
@@ -39,92 +39,92 @@ mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)
 
     if (dest != NULL)
       {
-	wchar_t *destptr = dest;
-
-	for (; len > 0; destptr++, len--)
-	  {
-	    size_t src_avail;
-	    size_t ret;
-
-	    /* An optimized variant of
-	       src_avail = strnlen1 (src, MB_LEN_MAX);  */
-	    if (src[0] == '\0')
-	      src_avail = 1;
-	    else if (src[1] == '\0')
-	      src_avail = 2;
-	    else if (src[2] == '\0')
-	      src_avail = 3;
-	    else if (MB_LEN_MAX <= 4 || src[3] == '\0')
-	      src_avail = 4;
-	    else
-	      src_avail = 4 + strnlen1 (src + 4, MB_LEN_MAX - 4);
-
-	    /* Parse the next multibyte character.  */
-	    ret = mbrtowc (destptr, src, src_avail, ps);
-
-	    if (ret == (size_t)(-2))
-	      /* Encountered a multibyte character that extends past a '\0' byte
-		 or that is longer than MB_LEN_MAX bytes.  Cannot happen.  */
-	      abort ();
-
-	    if (ret == (size_t)(-1))
-	      goto bad_input;
-	    if (ret == 0)
-	      {
-		src = NULL;
-		/* Here mbsinit (ps).  */
-		break;
-	      }
-	    src += ret;
-	  }
-
-	*srcp = src;
-	return destptr - dest;
+        wchar_t *destptr = dest;
+
+        for (; len > 0; destptr++, len--)
+          {
+            size_t src_avail;
+            size_t ret;
+
+            /* An optimized variant of
+               src_avail = strnlen1 (src, MB_LEN_MAX);  */
+            if (src[0] == '\0')
+              src_avail = 1;
+            else if (src[1] == '\0')
+              src_avail = 2;
+            else if (src[2] == '\0')
+              src_avail = 3;
+            else if (MB_LEN_MAX <= 4 || src[3] == '\0')
+              src_avail = 4;
+            else
+              src_avail = 4 + strnlen1 (src + 4, MB_LEN_MAX - 4);
+
+            /* Parse the next multibyte character.  */
+            ret = mbrtowc (destptr, src, src_avail, ps);
+
+            if (ret == (size_t)(-2))
+              /* Encountered a multibyte character that extends past a '\0' byte
+                 or that is longer than MB_LEN_MAX bytes.  Cannot happen.  */
+              abort ();
+
+            if (ret == (size_t)(-1))
+              goto bad_input;
+            if (ret == 0)
+              {
+                src = NULL;
+                /* Here mbsinit (ps).  */
+                break;
+              }
+            src += ret;
+          }
+
+        *srcp = src;
+        return destptr - dest;
       }
     else
       {
-	/* Ignore dest and len, don't store *srcp at the end, and
-	   don't clobber *ps.  */
-	mbstate_t state = *ps;
-	size_t totalcount = 0;
-
-	for (;; totalcount++)
-	  {
-	    size_t src_avail;
-	    size_t ret;
-
-	    /* An optimized variant of
-	       src_avail = strnlen1 (src, MB_LEN_MAX);  */
-	    if (src[0] == '\0')
-	      src_avail = 1;
-	    else if (src[1] == '\0')
-	      src_avail = 2;
-	    else if (src[2] == '\0')
-	      src_avail = 3;
-	    else if (MB_LEN_MAX <= 4 || src[3] == '\0')
-	      src_avail = 4;
-	    else
-	      src_avail = 4 + strnlen1 (src + 4, MB_LEN_MAX - 4);
-
-	    /* Parse the next multibyte character.  */
-	    ret = mbrtowc (NULL, src, src_avail, &state);
-
-	    if (ret == (size_t)(-2))
-	      /* Encountered a multibyte character that extends past a '\0' byte
-		 or that is longer than MB_LEN_MAX bytes.  Cannot happen.  */
-	      abort ();
-
-	    if (ret == (size_t)(-1))
-	      goto bad_input2;
-	    if (ret == 0)
-	      {
-		/* Here mbsinit (&state).  */
-		break;
-	      }
-	    src += ret;
-	  }
-
-	return totalcount;
+        /* Ignore dest and len, don't store *srcp at the end, and
+           don't clobber *ps.  */
+        mbstate_t state = *ps;
+        size_t totalcount = 0;
+
+        for (;; totalcount++)
+          {
+            size_t src_avail;
+            size_t ret;
+
+            /* An optimized variant of
+               src_avail = strnlen1 (src, MB_LEN_MAX);  */
+            if (src[0] == '\0')
+              src_avail = 1;
+            else if (src[1] == '\0')
+              src_avail = 2;
+            else if (src[2] == '\0')
+              src_avail = 3;
+            else if (MB_LEN_MAX <= 4 || src[3] == '\0')
+              src_avail = 4;
+            else
+              src_avail = 4 + strnlen1 (src + 4, MB_LEN_MAX - 4);
+
+            /* Parse the next multibyte character.  */
+            ret = mbrtowc (NULL, src, src_avail, &state);
+
+            if (ret == (size_t)(-2))
+              /* Encountered a multibyte character that extends past a '\0' byte
+                 or that is longer than MB_LEN_MAX bytes.  Cannot happen.  */
+              abort ();
+
+            if (ret == (size_t)(-1))
+              goto bad_input2;
+            if (ret == 0)
+              {
+                /* Here mbsinit (&state).  */
+                break;
+              }
+            src += ret;
+          }
+
+        return totalcount;
       }
 
    bad_input:
diff --git a/libmissing/memchr.c b/libmissing/memchr.c
index 3ea1d5b..92efa41 100644
--- a/libmissing/memchr.c
+++ b/libmissing/memchr.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1993, 1996, 1997, 1999, 2000, 2003, 2004, 2006, 2008
+/* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2009
    Free Software Foundation, Inc.
 
    Based on strlen implementation by Torbjorn Granlund ([email protected]),
@@ -97,15 +97,15 @@ __memchr (void const *s, int c_in, size_t n)
       repeated_one |= repeated_one << 31 << 1;
       repeated_c |= repeated_c << 31 << 1;
       if (8 < sizeof (longword))
-	{
-	  size_t i;
-
-	  for (i = 64; i < sizeof (longword) * 8; i *= 2)
-	    {
-	      repeated_one |= repeated_one << i;
-	      repeated_c |= repeated_c << i;
-	    }
-	}
+        {
+          size_t i;
+
+          for (i = 64; i < sizeof (longword) * 8; i *= 2)
+            {
+              repeated_one |= repeated_one << i;
+              repeated_c |= repeated_c << i;
+            }
+        }
     }
 
   /* Instead of the traditional loop which tests each byte, we will test a
@@ -144,8 +144,8 @@ __memchr (void const *s, int c_in, size_t n)
       longword longword1 = *longword_ptr ^ repeated_c;
 
       if ((((longword1 - repeated_one) & ~longword1)
-	   & (repeated_one << 7)) != 0)
-	break;
+           & (repeated_one << 7)) != 0)
+        break;
       longword_ptr++;
       n -= sizeof (longword);
     }
@@ -162,7 +162,7 @@ __memchr (void const *s, int c_in, size_t n)
   for (; n > 0; --n, ++char_ptr)
     {
       if (*char_ptr == c)
-	return (void *) char_ptr;
+        return (void *) char_ptr;
     }
 
   return NULL;
diff --git a/libmissing/mempcpy.c b/libmissing/mempcpy.c
index b89d4b3..e78c0ff 100644
--- a/libmissing/mempcpy.c
+++ b/libmissing/mempcpy.c
@@ -1,5 +1,5 @@
 /* Copy memory area and return pointer after last written byte.
-   Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2007, 2009 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/libmissing/mktime-internal.h b/libmissing/mktime-internal.h
new file mode 100644
index 0000000..4287acf
--- /dev/null
+++ b/libmissing/mktime-internal.h
@@ -0,0 +1,4 @@
+#include <time.h>
+time_t mktime_internal (struct tm *,
+                        struct tm * (*) (time_t const *, struct tm *),
+                        time_t *);
diff --git a/libmissing/mktime.c b/libmissing/mktime.c
index b642d85..f6f6bde 100644
--- a/libmissing/mktime.c
+++ b/libmissing/mktime.c
@@ -1,5 +1,5 @@
 /* Convert a `struct tm' to a time_t value.
-   Copyright (C) 1993-1999, 2002-2005, 2006, 2007 Free Software Foundation, Inc.
+   Copyright (C) 1993-1999, 2002-2007, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Paul Eggert <[email protected]>.
 
@@ -36,7 +36,7 @@
 
 #include <limits.h>
 
-#include <string.h>		/* For the real memcpy prototype.  */
+#include <string.h>             /* For the real memcpy prototype.  */
 
 #if DEBUG
 # include <stdio.h>
@@ -55,9 +55,9 @@
    implementations (e.g., UNICOS 9.0 on a Cray Y-MP EL) don't shift
    right in the usual way when A < 0, so SHR falls back on division if
    ordinary A >> B doesn't seem to be the usual signed shift.  */
-#define SHR(a, b)	\
-  (-1 >> 1 == -1	\
-   ? (a) >> (b)		\
+#define SHR(a, b)       \
+  (-1 >> 1 == -1        \
+   ? (a) >> (b)         \
    : (a) / (1 << (b)) - ((a) % (1 << (b)) < 0))
 
 /* The extra casts in the following macros work around compiler bugs,
@@ -84,14 +84,14 @@
    your host.  */
 #define TYPE_MINIMUM(t) \
   ((t) (! TYPE_SIGNED (t) \
-	? (t) 0 \
-	: TYPE_SIGNED_MAGNITUDE (t) \
-	? ~ (t) 0 \
-	: ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))
+        ? (t) 0 \
+        : TYPE_SIGNED_MAGNITUDE (t) \
+        ? ~ (t) 0 \
+        : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))
 #define TYPE_MAXIMUM(t) \
   ((t) (! TYPE_SIGNED (t) \
-	? (t) -1 \
-	: ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))))
+        ? (t) -1 \
+        : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))))
 
 #ifndef TIME_T_MIN
 # define TIME_T_MIN TYPE_MINIMUM (time_t)
@@ -123,7 +123,7 @@ leapyear (long int year)
   return
     ((year & 3) == 0
      && (year % 100 != 0
-	 || ((year / 100) & 3) == (- (TM_YEAR_BASE / 100) & 3)));
+         || ((year / 100) & 3) == (- (TM_YEAR_BASE / 100) & 3)));
 }
 
 /* How many days come before each month (0-12).  */
@@ -147,6 +147,7 @@ const unsigned short int __mon_yday[2][13] =
 # undef __localtime_r
 # define __localtime_r localtime_r
 # define __mktime_internal mktime_internal
+# include "mktime-internal.h"
 #endif
 
 /* Return an integer value measuring (YEAR1-YDAY1 HOUR1:MIN1:SEC1) -
@@ -162,11 +163,14 @@ const unsigned short int __mon_yday[2][13] =
 
 static inline time_t
 ydhms_diff (long int year1, long int yday1, int hour1, int min1, int sec1,
-	    int year0, int yday0, int hour0, int min0, int sec0)
+            int year0, int yday0, int hour0, int min0, int sec0)
 {
   verify (C99_integer_division, -1 / 2 == 0);
+#if 0 /* This assertion fails on 32-bit systems with 64-bit time_t, such as
+         NetBSD 5 on i386.  */
   verify (long_int_year_and_yday_are_wide_enough,
-	  INT_MAX <= LONG_MAX / 2 || TIME_T_MAX <= UINT_MAX);
+          INT_MAX <= LONG_MAX / 2 || TIME_T_MAX <= UINT_MAX);
+#endif
 
   /* Compute intervening leap days correctly even if year is negative.
      Take care to avoid integer overflow here.  */
@@ -198,16 +202,16 @@ ydhms_diff (long int year1, long int yday1, int hour1, int min1, int sec1,
    yield a value equal to *T.  */
 static time_t
 guess_time_tm (long int year, long int yday, int hour, int min, int sec,
-	       const time_t *t, const struct tm *tp)
+               const time_t *t, const struct tm *tp)
 {
   if (tp)
     {
       time_t d = ydhms_diff (year, yday, hour, min, sec,
-			     tp->tm_year, tp->tm_yday,
-			     tp->tm_hour, tp->tm_min, tp->tm_sec);
+                             tp->tm_year, tp->tm_yday,
+                             tp->tm_hour, tp->tm_min, tp->tm_sec);
       time_t t1 = *t + d;
       if ((t1 < *t) == (TYPE_SIGNED (time_t) ? d < 0 : TIME_T_MAX / 2 < d))
-	return t1;
+        return t1;
     }
 
   /* Overflow occurred one way or another.  Return the nearest result
@@ -216,8 +220,8 @@ guess_time_tm (long int year, long int yday, int hour, int min, int sec,
      match; and don't oscillate between two values, as that would
      confuse the spring-forward gap detector.  */
   return (*t < TIME_T_MIDPOINT
-	  ? (*t <= TIME_T_MIN + 1 ? *t + 1 : TIME_T_MIN)
-	  : (TIME_T_MAX - 1 <= *t ? *t - 1 : TIME_T_MAX));
+          ? (*t <= TIME_T_MIN + 1 ? *t + 1 : TIME_T_MIN)
+          : (TIME_T_MAX - 1 <= *t ? *t - 1 : TIME_T_MAX));
 }
 
 /* Use CONVERT to convert *T to a broken down time in *TP.
@@ -225,7 +229,7 @@ guess_time_tm (long int year, long int yday, int hour, int min, int sec,
    it is the nearest in-range value and then convert that.  */
 static struct tm *
 ranged_convert (struct tm *(*convert) (const time_t *, struct tm *),
-		time_t *t, struct tm *tp)
+                time_t *t, struct tm *tp)
 {
   struct tm *r = convert (t, tp);
 
@@ -235,27 +239,27 @@ ranged_convert (struct tm *(*convert) (const time_t *, struct tm *),
       time_t ok = 0;
 
       /* BAD is a known unconvertible time_t, and OK is a known good one.
-	 Use binary search to narrow the range between BAD and OK until
-	 they differ by 1.  */
+         Use binary search to narrow the range between BAD and OK until
+         they differ by 1.  */
       while (bad != ok + (bad < 0 ? -1 : 1))
-	{
-	  time_t mid = *t = (bad < 0
-			     ? bad + ((ok - bad) >> 1)
-			     : ok + ((bad - ok) >> 1));
-	  r = convert (t, tp);
-	  if (r)
-	    ok = mid;
-	  else
-	    bad = mid;
-	}
+        {
+          time_t mid = *t = (bad < 0
+                             ? bad + ((ok - bad) >> 1)
+                             : ok + ((bad - ok) >> 1));
+          r = convert (t, tp);
+          if (r)
+            ok = mid;
+          else
+            bad = mid;
+        }
 
       if (!r && ok)
-	{
-	  /* The last conversion attempt failed;
-	     revert to the most recent successful attempt.  */
-	  *t = ok;
-	  r = convert (t, tp);
-	}
+        {
+          /* The last conversion attempt failed;
+             revert to the most recent successful attempt.  */
+          *t = ok;
+          r = convert (t, tp);
+        }
     }
 
   return r;
@@ -270,8 +274,8 @@ ranged_convert (struct tm *(*convert) (const time_t *, struct tm *),
    This function is external because it is used also by timegm.c.  */
 time_t
 __mktime_internal (struct tm *tp,
-		   struct tm *(*convert) (const time_t *, struct tm *),
-		   time_t *offset)
+                   struct tm *(*convert) (const time_t *, struct tm *),
+                   time_t *offset)
 {
   time_t t, gt, t0, t1, t2;
   struct tm tm;
@@ -292,7 +296,7 @@ __mktime_internal (struct tm *tp,
   int year_requested = tp->tm_year;
   /* Normalize the value.  */
   int isdst = ((tp->tm_isdst >> (8 * sizeof (tp->tm_isdst) - 1))
-	       | (tp->tm_isdst != 0));
+               | (tp->tm_isdst != 0));
 
   /* 1 if the previous probe was DST.  */
   int dst2;
@@ -312,8 +316,8 @@ __mktime_internal (struct tm *tp,
   /* Calculate day of year from year, month, and day of month.
      The result need not be in range.  */
   int mon_yday = ((__mon_yday[leapyear (year)]
-		   [mon_remainder + 12 * negative_mon_remainder])
-		  - 1);
+                   [mon_remainder + 12 * negative_mon_remainder])
+                  - 1);
   long int lmday = mday;
   long int yday = mon_yday + lmday;
 
@@ -324,33 +328,33 @@ __mktime_internal (struct tm *tp,
   if (LEAP_SECONDS_POSSIBLE)
     {
       /* Handle out-of-range seconds specially,
-	 since ydhms_tm_diff assumes every minute has 60 seconds.  */
+         since ydhms_tm_diff assumes every minute has 60 seconds.  */
       if (sec < 0)
-	sec = 0;
+        sec = 0;
       if (59 < sec)
-	sec = 59;
+        sec = 59;
     }
 
   /* Invert CONVERT by probing.  First assume the same offset as last
      time.  */
 
   t0 = ydhms_diff (year, yday, hour, min, sec,
-		   EPOCH_YEAR - TM_YEAR_BASE, 0, 0, 0, - guessed_offset);
+                   EPOCH_YEAR - TM_YEAR_BASE, 0, 0, 0, - guessed_offset);
 
   if (TIME_T_MAX / INT_MAX / 366 / 24 / 60 / 60 < 3)
     {
       /* time_t isn't large enough to rule out overflows, so check
-	 for major overflows.  A gross check suffices, since if t0
-	 has overflowed, it is off by a multiple of TIME_T_MAX -
-	 TIME_T_MIN + 1.  So ignore any component of the difference
-	 that is bounded by a small value.  */
+         for major overflows.  A gross check suffices, since if t0
+         has overflowed, it is off by a multiple of TIME_T_MAX -
+         TIME_T_MIN + 1.  So ignore any component of the difference
+         that is bounded by a small value.  */
 
       /* Approximate log base 2 of the number of time units per
-	 biennium.  A biennium is 2 years; use this unit instead of
-	 years to avoid integer overflow.  For example, 2 average
-	 Gregorian years are 2 * 365.2425 * 24 * 60 * 60 seconds,
-	 which is 63113904 seconds, and rint (log2 (63113904)) is
-	 26.  */
+         biennium.  A biennium is 2 years; use this unit instead of
+         years to avoid integer overflow.  For example, 2 average
+         Gregorian years are 2 * 365.2425 * 24 * 60 * 60 seconds,
+         which is 63113904 seconds, and rint (log2 (63113904)) is
+         26.  */
       int ALOG2_SECONDS_PER_BIENNIUM = 26;
       int ALOG2_MINUTES_PER_BIENNIUM = 20;
       int ALOG2_HOURS_PER_BIENNIUM = 14;
@@ -358,64 +362,64 @@ __mktime_internal (struct tm *tp,
       int LOG2_YEARS_PER_BIENNIUM = 1;
 
       int approx_requested_biennia =
-	(SHR (year_requested, LOG2_YEARS_PER_BIENNIUM)
-	 - SHR (EPOCH_YEAR - TM_YEAR_BASE, LOG2_YEARS_PER_BIENNIUM)
-	 + SHR (mday, ALOG2_DAYS_PER_BIENNIUM)
-	 + SHR (hour, ALOG2_HOURS_PER_BIENNIUM)
-	 + SHR (min, ALOG2_MINUTES_PER_BIENNIUM)
-	 + (LEAP_SECONDS_POSSIBLE
-	    ? 0
-	    : SHR (sec, ALOG2_SECONDS_PER_BIENNIUM)));
+        (SHR (year_requested, LOG2_YEARS_PER_BIENNIUM)
+         - SHR (EPOCH_YEAR - TM_YEAR_BASE, LOG2_YEARS_PER_BIENNIUM)
+         + SHR (mday, ALOG2_DAYS_PER_BIENNIUM)
+         + SHR (hour, ALOG2_HOURS_PER_BIENNIUM)
+         + SHR (min, ALOG2_MINUTES_PER_BIENNIUM)
+         + (LEAP_SECONDS_POSSIBLE
+            ? 0
+            : SHR (sec, ALOG2_SECONDS_PER_BIENNIUM)));
 
       int approx_biennia = SHR (t0, ALOG2_SECONDS_PER_BIENNIUM);
       int diff = approx_biennia - approx_requested_biennia;
       int abs_diff = diff < 0 ? - diff : diff;
 
       /* IRIX 4.0.5 cc miscaculates TIME_T_MIN / 3: it erroneously
-	 gives a positive value of 715827882.  Setting a variable
-	 first then doing math on it seems to work.
-	 ([email protected]) */
+         gives a positive value of 715827882.  Setting a variable
+         first then doing math on it seems to work.
+         ([email protected]) */
       time_t time_t_max = TIME_T_MAX;
       time_t time_t_min = TIME_T_MIN;
       time_t overflow_threshold =
-	(time_t_max / 3 - time_t_min / 3) >> ALOG2_SECONDS_PER_BIENNIUM;
+        (time_t_max / 3 - time_t_min / 3) >> ALOG2_SECONDS_PER_BIENNIUM;
 
       if (overflow_threshold < abs_diff)
-	{
-	  /* Overflow occurred.  Try repairing it; this might work if
-	     the time zone offset is enough to undo the overflow.  */
-	  time_t repaired_t0 = -1 - t0;
-	  approx_biennia = SHR (repaired_t0, ALOG2_SECONDS_PER_BIENNIUM);
-	  diff = approx_biennia - approx_requested_biennia;
-	  abs_diff = diff < 0 ? - diff : diff;
-	  if (overflow_threshold < abs_diff)
-	    return -1;
-	  guessed_offset += repaired_t0 - t0;
-	  t0 = repaired_t0;
-	}
+        {
+          /* Overflow occurred.  Try repairing it; this might work if
+             the time zone offset is enough to undo the overflow.  */
+          time_t repaired_t0 = -1 - t0;
+          approx_biennia = SHR (repaired_t0, ALOG2_SECONDS_PER_BIENNIUM);
+          diff = approx_biennia - approx_requested_biennia;
+          abs_diff = diff < 0 ? - diff : diff;
+          if (overflow_threshold < abs_diff)
+            return -1;
+          guessed_offset += repaired_t0 - t0;
+          t0 = repaired_t0;
+        }
     }
 
   /* Repeatedly use the error to improve the guess.  */
 
   for (t = t1 = t2 = t0, dst2 = 0;
        (gt = guess_time_tm (year, yday, hour, min, sec, &t,
-			    ranged_convert (convert, &t, &tm)),
-	t != gt);
+                            ranged_convert (convert, &t, &tm)),
+        t != gt);
        t1 = t2, t2 = t, t = gt, dst2 = tm.tm_isdst != 0)
     if (t == t1 && t != t2
-	&& (tm.tm_isdst < 0
-	    || (isdst < 0
-		? dst2 <= (tm.tm_isdst != 0)
-		: (isdst != 0) != (tm.tm_isdst != 0))))
+        && (tm.tm_isdst < 0
+            || (isdst < 0
+                ? dst2 <= (tm.tm_isdst != 0)
+                : (isdst != 0) != (tm.tm_isdst != 0))))
       /* We can't possibly find a match, as we are oscillating
-	 between two values.  The requested time probably falls
-	 within a spring-forward gap of size GT - T.  Follow the common
-	 practice in this case, which is to return a time that is GT - T
-	 away from the requested time, preferring a time whose
-	 tm_isdst differs from the requested value.  (If no tm_isdst
-	 was requested and only one of the two values has a nonzero
-	 tm_isdst, prefer that value.)  In practice, this is more
-	 useful than returning -1.  */
+         between two values.  The requested time probably falls
+         within a spring-forward gap of size GT - T.  Follow the common
+         practice in this case, which is to return a time that is GT - T
+         away from the requested time, preferring a time whose
+         tm_isdst differs from the requested value.  (If no tm_isdst
+         was requested and only one of the two values has a nonzero
+         tm_isdst, prefer that value.)  In practice, this is more
+         useful than returning -1.  */
       goto offset_found;
     else if (--remaining_probes == 0)
       return -1;
@@ -425,52 +429,52 @@ __mktime_internal (struct tm *tp,
   if (isdst != tm.tm_isdst && 0 <= isdst && 0 <= tm.tm_isdst)
     {
       /* tm.tm_isdst has the wrong value.  Look for a neighboring
-	 time with the right value, and use its UTC offset.
+         time with the right value, and use its UTC offset.
 
-	 Heuristic: probe the adjacent timestamps in both directions,
-	 looking for the desired isdst.  This should work for all real
-	 time zone histories in the tz database.  */
+         Heuristic: probe the adjacent timestamps in both directions,
+         looking for the desired isdst.  This should work for all real
+         time zone histories in the tz database.  */
 
       /* Distance between probes when looking for a DST boundary.  In
-	 tzdata2003a, the shortest period of DST is 601200 seconds
-	 (e.g., America/Recife starting 2000-10-08 01:00), and the
-	 shortest period of non-DST surrounded by DST is 694800
-	 seconds (Africa/Tunis starting 1943-04-17 01:00).  Use the
-	 minimum of these two values, so we don't miss these short
-	 periods when probing.  */
+         tzdata2003a, the shortest period of DST is 601200 seconds
+         (e.g., America/Recife starting 2000-10-08 01:00), and the
+         shortest period of non-DST surrounded by DST is 694800
+         seconds (Africa/Tunis starting 1943-04-17 01:00).  Use the
+         minimum of these two values, so we don't miss these short
+         periods when probing.  */
       int stride = 601200;
 
       /* The longest period of DST in tzdata2003a is 536454000 seconds
-	 (e.g., America/Jujuy starting 1946-10-01 01:00).  The longest
-	 period of non-DST is much longer, but it makes no real sense
-	 to search for more than a year of non-DST, so use the DST
-	 max.  */
+         (e.g., America/Jujuy starting 1946-10-01 01:00).  The longest
+         period of non-DST is much longer, but it makes no real sense
+         to search for more than a year of non-DST, so use the DST
+         max.  */
       int duration_max = 536454000;
 
       /* Search in both directions, so the maximum distance is half
-	 the duration; add the stride to avoid off-by-1 problems.  */
+         the duration; add the stride to avoid off-by-1 problems.  */
       int delta_bound = duration_max / 2 + stride;
 
       int delta, direction;
 
       for (delta = stride; delta < delta_bound; delta += stride)
-	for (direction = -1; direction <= 1; direction += 2)
-	  {
-	    time_t ot = t + delta * direction;
-	    if ((ot < t) == (direction < 0))
-	      {
-		struct tm otm;
-		ranged_convert (convert, &ot, &otm);
-		if (otm.tm_isdst == isdst)
-		  {
-		    /* We found the desired tm_isdst.
-		       Extrapolate back to the desired time.  */
-		    t = guess_time_tm (year, yday, hour, min, sec, &ot, &otm);
-		    ranged_convert (convert, &t, &tm);
-		    goto offset_found;
-		  }
-	      }
-	  }
+        for (direction = -1; direction <= 1; direction += 2)
+          {
+            time_t ot = t + delta * direction;
+            if ((ot < t) == (direction < 0))
+              {
+                struct tm otm;
+                ranged_convert (convert, &ot, &otm);
+                if (otm.tm_isdst == isdst)
+                  {
+                    /* We found the desired tm_isdst.
+                       Extrapolate back to the desired time.  */
+                    t = guess_time_tm (year, yday, hour, min, sec, &ot, &otm);
+                    ranged_convert (convert, &t, &tm);
+                    goto offset_found;
+                  }
+              }
+          }
     }
 
  offset_found:
@@ -479,14 +483,14 @@ __mktime_internal (struct tm *tp,
   if (LEAP_SECONDS_POSSIBLE && sec_requested != tm.tm_sec)
     {
       /* Adjust time to reflect the tm_sec requested, not the normalized value.
-	 Also, repair any damage from a false match due to a leap second.  */
+         Also, repair any damage from a false match due to a leap second.  */
       int sec_adjustment = (sec == 0 && tm.tm_sec == 60) - sec;
       t1 = t + sec_requested;
       t2 = t1 + sec_adjustment;
       if (((t1 < t) != (sec_requested < 0))
-	  | ((t2 < t1) != (sec_adjustment < 0))
-	  | ! convert (&t2, &tm))
-	return -1;
+          | ((t2 < t1) != (sec_adjustment < 0))
+          | ! convert (&t2, &tm))
+        return -1;
       t = t2;
     }
 
@@ -530,13 +534,13 @@ static int
 not_equal_tm (const struct tm *a, const struct tm *b)
 {
   return ((a->tm_sec ^ b->tm_sec)
-	  | (a->tm_min ^ b->tm_min)
-	  | (a->tm_hour ^ b->tm_hour)
-	  | (a->tm_mday ^ b->tm_mday)
-	  | (a->tm_mon ^ b->tm_mon)
-	  | (a->tm_year ^ b->tm_year)
-	  | (a->tm_yday ^ b->tm_yday)
-	  | (a->tm_isdst ^ b->tm_isdst));
+          | (a->tm_min ^ b->tm_min)
+          | (a->tm_hour ^ b->tm_hour)
+          | (a->tm_mday ^ b->tm_mday)
+          | (a->tm_mon ^ b->tm_mon)
+          | (a->tm_year ^ b->tm_year)
+          | (a->tm_yday ^ b->tm_yday)
+          | (a->tm_isdst ^ b->tm_isdst));
 }
 
 static void
@@ -544,9 +548,9 @@ print_tm (const struct tm *tp)
 {
   if (tp)
     printf ("%04d-%02d-%02d %02d:%02d:%02d yday %03d wday %d isdst %d",
-	    tp->tm_year + TM_YEAR_BASE, tp->tm_mon + 1, tp->tm_mday,
-	    tp->tm_hour, tp->tm_min, tp->tm_sec,
-	    tp->tm_yday, tp->tm_wday, tp->tm_isdst);
+            tp->tm_year + TM_YEAR_BASE, tp->tm_mon + 1, tp->tm_mday,
+            tp->tm_hour, tp->tm_min, tp->tm_sec,
+            tp->tm_yday, tp->tm_wday, tp->tm_isdst);
   else
     printf ("0");
 }
@@ -578,11 +582,11 @@ main (int argc, char **argv)
 
   if ((argc == 3 || argc == 4)
       && (sscanf (argv[1], "%d-%d-%d%c",
-		  &tm.tm_year, &tm.tm_mon, &tm.tm_mday, &trailer)
-	  == 3)
+                  &tm.tm_year, &tm.tm_mon, &tm.tm_mday, &trailer)
+          == 3)
       && (sscanf (argv[2], "%d:%d:%d%c",
-		  &tm.tm_hour, &tm.tm_min, &tm.tm_sec, &trailer)
-	  == 3))
+                  &tm.tm_hour, &tm.tm_min, &tm.tm_sec, &trailer)
+          == 3))
     {
       tm.tm_year -= TM_YEAR_BASE;
       tm.tm_mon--;
@@ -591,10 +595,10 @@ main (int argc, char **argv)
       tl = mktime (&tmk);
       lt = localtime (&tl);
       if (lt)
-	{
-	  tml = *lt;
-	  lt = &tml;
-	}
+        {
+          tml = *lt;
+          lt = &tml;
+        }
       printf ("mktime returns %ld == ", (long int) tl);
       print_tm (&tmk);
       printf ("\n");
@@ -607,51 +611,51 @@ main (int argc, char **argv)
       time_t to = atol (argv[3]);
 
       if (argc == 4)
-	for (tl = from; by < 0 ? to <= tl : tl <= to; tl = tl1)
-	  {
-	    lt = localtime (&tl);
-	    if (lt)
-	      {
-		tmk = tml = *lt;
-		tk = mktime (&tmk);
-		status |= check_result (tk, tmk, tl, &tml);
-	      }
-	    else
-	      {
-		printf ("localtime (%ld) yields 0\n", (long int) tl);
-		status = 1;
-	      }
-	    tl1 = tl + by;
-	    if ((tl1 < tl) != (by < 0))
-	      break;
-	  }
+        for (tl = from; by < 0 ? to <= tl : tl <= to; tl = tl1)
+          {
+            lt = localtime (&tl);
+            if (lt)
+              {
+                tmk = tml = *lt;
+                tk = mktime (&tmk);
+                status |= check_result (tk, tmk, tl, &tml);
+              }
+            else
+              {
+                printf ("localtime (%ld) yields 0\n", (long int) tl);
+                status = 1;
+              }
+            tl1 = tl + by;
+            if ((tl1 < tl) != (by < 0))
+              break;
+          }
       else
-	for (tl = from; by < 0 ? to <= tl : tl <= to; tl = tl1)
-	  {
-	    /* Null benchmark.  */
-	    lt = localtime (&tl);
-	    if (lt)
-	      {
-		tmk = tml = *lt;
-		tk = tl;
-		status |= check_result (tk, tmk, tl, &tml);
-	      }
-	    else
-	      {
-		printf ("localtime (%ld) yields 0\n", (long int) tl);
-		status = 1;
-	      }
-	    tl1 = tl + by;
-	    if ((tl1 < tl) != (by < 0))
-	      break;
-	  }
+        for (tl = from; by < 0 ? to <= tl : tl <= to; tl = tl1)
+          {
+            /* Null benchmark.  */
+            lt = localtime (&tl);
+            if (lt)
+              {
+                tmk = tml = *lt;
+                tk = tl;
+                status |= check_result (tk, tmk, tl, &tml);
+              }
+            else
+              {
+                printf ("localtime (%ld) yields 0\n", (long int) tl);
+                status = 1;
+              }
+            tl1 = tl + by;
+            if ((tl1 < tl) != (by < 0))
+              break;
+          }
     }
   else
     printf ("Usage:\
 \t%s YYYY-MM-DD HH:MM:SS [ISDST] # Test given time.\n\
 \t%s FROM BY TO # Test values FROM, FROM+BY, ..., TO.\n\
 \t%s FROM BY TO - # Do not test those values (for benchmark).\n",
-	    argv[0], argv[0], argv[0]);
+            argv[0], argv[0], argv[0]);
 
   return status;
 }
diff --git a/libmissing/netdb.in.h b/libmissing/netdb.in.h
index ce9f237..2762cb3 100644
--- a/libmissing/netdb.in.h
+++ b/libmissing/netdb.in.h
@@ -1,5 +1,5 @@
 /* Provide a netdb.h header file for systems lacking it (read: MinGW).
-   Copyright (C) 2008 Free Software Foundation, Inc.
+   Copyright (C) 2008-2009 Free Software Foundation, Inc.
    Written by Simon Josefsson.
 
    This program is free software; you can redistribute it and/or modify
@@ -39,6 +39,8 @@
 /* Get netdb.h definitions such as struct hostent for MinGW.  */
 #include <sys/socket.h>
 
+/* The definition of _GL_ARG_NONNULL is copied here.  */
+
 /* Declarations for a platform that lacks <netdb.h>, or where it is
    incomplete.  */
 
@@ -49,26 +51,26 @@
 /* Structure to contain information about address of a service provider.  */
 struct addrinfo
 {
-  int ai_flags;			/* Input flags.  */
-  int ai_family;		/* Protocol family for socket.  */
-  int ai_socktype;		/* Socket type.  */
-  int ai_protocol;		/* Protocol for socket.  */
-  socklen_t ai_addrlen;		/* Length of socket address.  */
-  struct sockaddr *ai_addr;	/* Socket address for socket.  */
-  char *ai_canonname;		/* Canonical name for service location.  */
-  struct addrinfo *ai_next;	/* Pointer to next in list.  */
+  int ai_flags;                 /* Input flags.  */
+  int ai_family;                /* Protocol family for socket.  */
+  int ai_socktype;              /* Socket type.  */
+  int ai_protocol;              /* Protocol for socket.  */
+  socklen_t ai_addrlen;         /* Length of socket address.  */
+  struct sockaddr *ai_addr;     /* Socket address for socket.  */
+  char *ai_canonname;           /* Canonical name for service location.  */
+  struct addrinfo *ai_next;     /* Pointer to next in list.  */
 };
 # endif
 
 /* Possible values for `ai_flags' field in `addrinfo' structure.  */
 # ifndef AI_PASSIVE
-#  define AI_PASSIVE	0x0001	/* Socket address is intended for `bind'.  */
+#  define AI_PASSIVE    0x0001  /* Socket address is intended for `bind'.  */
 # endif
 # ifndef AI_CANONNAME
-#  define AI_CANONNAME	0x0002	/* Request for canonical name.  */
+#  define AI_CANONNAME  0x0002  /* Request for canonical name.  */
 # endif
 # ifndef AI_NUMERICSERV
-#  define AI_NUMERICSERV	0x0400	/* Don't use name resolution.  */
+#  define AI_NUMERICSERV        0x0400  /* Don't use name resolution.  */
 # endif
 
 # if 0
@@ -78,24 +80,24 @@ struct addrinfo
    define them.
 
    If they are restored, be sure to protect the definitions with #ifndef.  */
-#  define AI_NUMERICHOST	0x0004	/* Don't use name resolution.  */
-#  define AI_V4MAPPED	0x0008	/* IPv4 mapped addresses are acceptable.  */
-#  define AI_ALL		0x0010	/* Return IPv4 mapped and IPv6 addresses.  */
-#  define AI_ADDRCONFIG	0x0020	/* Use configuration of this host to choose
-				   returned address type..  */
+#  define AI_NUMERICHOST        0x0004  /* Don't use name resolution.  */
+#  define AI_V4MAPPED   0x0008  /* IPv4 mapped addresses are acceptable.  */
+#  define AI_ALL                0x0010  /* Return IPv4 mapped and IPv6 addresses.  */
+#  define AI_ADDRCONFIG 0x0020  /* Use configuration of this host to choose
+                                   returned address type..  */
 # endif /* 0 */
 
 /* Error values for `getaddrinfo' function.  */
 # ifndef EAI_BADFLAGS
-#  define EAI_BADFLAGS	  -1	/* Invalid value for `ai_flags' field.  */
-#  define EAI_NONAME	  -2	/* NAME or SERVICE is unknown.  */
-#  define EAI_AGAIN	  -3	/* Temporary failure in name resolution.  */
-#  define EAI_FAIL	  -4	/* Non-recoverable failure in name res.  */
-#  define EAI_NODATA	  -5	/* No address associated with NAME.  */
-#  define EAI_FAMILY	  -6	/* `ai_family' not supported.  */
-#  define EAI_SOCKTYPE	  -7	/* `ai_socktype' not supported.  */
-#  define EAI_SERVICE	  -8	/* SERVICE not supported for `ai_socktype'.  */
-#  define EAI_MEMORY	  -10	/* Memory allocation failure.  */
+#  define EAI_BADFLAGS    -1    /* Invalid value for `ai_flags' field.  */
+#  define EAI_NONAME      -2    /* NAME or SERVICE is unknown.  */
+#  define EAI_AGAIN       -3    /* Temporary failure in name resolution.  */
+#  define EAI_FAIL        -4    /* Non-recoverable failure in name res.  */
+#  define EAI_NODATA      -5    /* No address associated with NAME.  */
+#  define EAI_FAMILY      -6    /* `ai_family' not supported.  */
+#  define EAI_SOCKTYPE    -7    /* `ai_socktype' not supported.  */
+#  define EAI_SERVICE     -8    /* SERVICE not supported for `ai_socktype'.  */
+#  define EAI_MEMORY      -10   /* Memory allocation failure.  */
 # endif
 
 /* Since EAI_NODATA is deprecated by RFC3493, some systems (at least
@@ -107,15 +109,15 @@ struct addrinfo
 
 # ifndef EAI_OVERFLOW
 /* Not defined on mingw32 and Haiku. */
-#  define EAI_OVERFLOW	  -12	/* Argument buffer overflow.  */
+#  define EAI_OVERFLOW    -12   /* Argument buffer overflow.  */
 # endif
 # ifndef EAI_ADDRFAMILY
 /* Not defined on mingw32. */
-#  define EAI_ADDRFAMILY  -9	/* Address family for NAME not supported.  */
+#  define EAI_ADDRFAMILY  -9    /* Address family for NAME not supported.  */
 # endif
 # ifndef EAI_SYSTEM
 /* Not defined on mingw32. */
-#  define EAI_SYSTEM	  -11	/* System error returned in `errno'.  */
+#  define EAI_SYSTEM      -11   /* System error returned in `errno'.  */
 # endif
 
 # if 0
@@ -124,12 +126,12 @@ struct addrinfo
 
    If they are restored, be sure to protect the definitions with #ifndef.  */
 #  ifndef EAI_INPROGRESS
-#   define EAI_INPROGRESS	-100	/* Processing request in progress.  */
-#   define EAI_CANCELED		-101	/* Request canceled.  */
-#   define EAI_NOTCANCELED	-102	/* Request not canceled.  */
-#   define EAI_ALLDONE		-103	/* All requests done.  */
-#   define EAI_INTR		-104	/* Interrupted by a signal.  */
-#   define EAI_IDN_ENCODE	-105	/* IDN encoding failed.  */
+#   define EAI_INPROGRESS       -100    /* Processing request in progress.  */
+#   define EAI_CANCELED         -101    /* Request canceled.  */
+#   define EAI_NOTCANCELED      -102    /* Request not canceled.  */
+#   define EAI_ALLDONE          -103    /* All requests done.  */
+#   define EAI_INTR             -104    /* Interrupted by a signal.  */
+#   define EAI_IDN_ENCODE       -105    /* IDN encoding failed.  */
 #  endif
 # endif
 
@@ -139,16 +141,17 @@ struct addrinfo
    For more details, see the POSIX:2001 specification
    <http://www.opengroup.org/susv3xsh/getaddrinfo.html>.  */
 extern int getaddrinfo (const char *restrict nodename,
-			const char *restrict servname,
-			const struct addrinfo *restrict hints,
-			struct addrinfo **restrict res);
+                        const char *restrict servname,
+                        const struct addrinfo *restrict hints,
+                        struct addrinfo **restrict res)
+     _GL_ARG_NONNULL ((4));
 # endif
 
 # if !@HAVE_DECL_FREEADDRINFO@
 /* Free `addrinfo' structure AI including associated storage.
    For more details, see the POSIX:2001 specification
    <http://www.opengroup.org/susv3xsh/getaddrinfo.html>.  */
-extern void freeaddrinfo (struct addrinfo *ai);
+extern void freeaddrinfo (struct addrinfo *ai) _GL_ARG_NONNULL ((1));
 # endif
 
 # if !@HAVE_DECL_GAI_STRERROR@
@@ -163,9 +166,10 @@ extern const char *gai_strerror (int ecode);
    For more details, see the POSIX:2001 specification
    <http://www.opengroup.org/susv3xsh/getnameinfo.html>.  */
 extern int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen,
-		       char *restrict node, socklen_t nodelen,
-		       char *restrict service, socklen_t servicelen,
-		       int flags);
+                       char *restrict node, socklen_t nodelen,
+                       char *restrict service, socklen_t servicelen,
+                       int flags)
+     _GL_ARG_NONNULL ((1));
 # endif
 
 /* Possible flags for getnameinfo.  */
diff --git a/libmissing/netinet_in.in.h b/libmissing/netinet_in.in.h
index 8c94f6a..6b134d4 100644
--- a/libmissing/netinet_in.in.h
+++ b/libmissing/netinet_in.in.h
@@ -1,5 +1,5 @@
 /* Substitute for <netinet/in.h>.
-   Copyright (C) 2007-2008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/libmissing/nl_langinfo.c b/libmissing/nl_langinfo.c
new file mode 100644
index 0000000..741bb0b
--- /dev/null
+++ b/libmissing/nl_langinfo.c
@@ -0,0 +1,260 @@
+/* nl_langinfo() replacement: query locale dependent information.
+
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <langinfo.h>
+
+#if REPLACE_NL_LANGINFO
+
+/* Override nl_langinfo with support for added nl_item values.  */
+
+# include <locale.h>
+# include <string.h>
+
+# undef nl_langinfo
+
+char *
+rpl_nl_langinfo (nl_item item)
+{
+  switch (item)
+    {
+# if GNULIB_defined_CODESET
+    case CODESET:
+      {
+        const char *locale;
+        static char buf[2 + 10 + 1];
+
+        locale = setlocale (LC_CTYPE, NULL);
+        if (locale != NULL && locale[0] != '\0')
+          {
+            /* If the locale name contains an encoding after the dot, return
+               it.  */
+            const char *dot = strchr (locale, '.');
+
+            if (dot != NULL)
+              {
+                const char *modifier;
+
+                dot++;
+                /* Look for the possible @... trailer and remove it, if any.  */
+                modifier = strchr (dot, '@');
+                if (modifier == NULL)
+                  return dot;
+                if (modifier - dot < sizeof (buf))
+                  {
+                    memcpy (buf, dot, modifier - dot);
+                    buf [modifier - dot] = '\0';
+                    return buf;
+                  }
+              }
+          }
+        return "";
+      }
+# endif
+# if GNULIB_defined_ERA
+    case ERA:
+      /* The format is not standardized.  In glibc it is a sequence of strings
+         of the form "direction:offset:start_date:end_date:era_name:era_format"
+         with an empty string at the end.  */
+      return "";
+    case ERA_D_FMT:
+      /* The %Ex conversion in strftime behaves like %x if the locale does not
+         have an alternative time format.  */
+      item = D_FMT;
+      break;
+    case ERA_D_T_FMT:
+      /* The %Ec conversion in strftime behaves like %c if the locale does not
+         have an alternative time format.  */
+      item = D_T_FMT;
+      break;
+    case ERA_T_FMT:
+      /* The %EX conversion in strftime behaves like %X if the locale does not
+         have an alternative time format.  */
+      item = T_FMT;
+      break;
+    case ALT_DIGITS:
+      /* The format is not standardized.  In glibc it is a sequence of 10
+         strings, appended in memory.  */
+      return "\0\0\0\0\0\0\0\0\0\0";
+# endif
+    default:
+      break;
+    }
+  return nl_langinfo (item);
+}
+
+#else
+
+/* Provide nl_langinfo from scratch.  */
+
+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+
+/* Native Windows platforms.  */
+
+#  define WIN32_LEAN_AND_MEAN  /* avoid including junk */
+#  include <windows.h>
+
+#  include <stdio.h>
+
+# else
+
+/* An old Unix platform without locales, such as Linux libc5 or BeOS.  */
+
+# endif
+
+# include <locale.h>
+
+char *
+nl_langinfo (nl_item item)
+{
+  switch (item)
+    {
+    /* nl_langinfo items of the LC_CTYPE category */
+    case CODESET:
+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+      {
+        static char buf[2 + 10 + 1];
+
+        /* Woe32 has a function returning the locale's codepage as a number.  */
+        sprintf (buf, "CP%u", GetACP ());
+        return buf;
+      }
+# elif defined __BEOS__
+      return "UTF-8";
+# else
+      return "ISO-8859-1";
+# endif
+    /* nl_langinfo items of the LC_NUMERIC category */
+    case RADIXCHAR:
+      return localeconv () ->decimal_point;
+    case THOUSEP:
+      return localeconv () ->thousands_sep;
+    /* nl_langinfo items of the LC_TIME category.
+       TODO: Really use the locale.  */
+    case D_T_FMT:
+    case ERA_D_T_FMT:
+      return "%a %b %e %H:%M:%S %Y";
+    case D_FMT:
+    case ERA_D_FMT:
+      return "%m/%d/%y";
+    case T_FMT:
+    case ERA_T_FMT:
+      return "%H:%M:%S";
+    case T_FMT_AMPM:
+      return "%I:%M:%S %p";
+    case AM_STR:
+      return "AM";
+    case PM_STR:
+      return "PM";
+    case DAY_1:
+      return "Sunday";
+    case DAY_2:
+      return "Monday";
+    case DAY_3:
+      return "Tuesday";
+    case DAY_4:
+      return "Wednesday";
+    case DAY_5:
+      return "Thursday";
+    case DAY_6:
+      return "Friday";
+    case DAY_7:
+      return "Saturday";
+    case ABDAY_1:
+      return "Sun";
+    case ABDAY_2:
+      return "Mon";
+    case ABDAY_3:
+      return "Tue";
+    case ABDAY_4:
+      return "Wed";
+    case ABDAY_5:
+      return "Thu";
+    case ABDAY_6:
+      return "Fri";
+    case ABDAY_7:
+      return "Sat";
+    case MON_1:
+      return "January";
+    case MON_2:
+      return "February";
+    case MON_3:
+      return "March";
+    case MON_4:
+      return "April";
+    case MON_5:
+      return "May";
+    case MON_6:
+      return "June";
+    case MON_7:
+      return "July";
+    case MON_8:
+      return "August";
+    case MON_9:
+      return "September";
+    case MON_10:
+      return "October";
+    case MON_11:
+      return "November";
+    case MON_12:
+      return "December";
+    case ABMON_1:
+      return "Jan";
+    case ABMON_2:
+      return "Feb";
+    case ABMON_3:
+      return "Mar";
+    case ABMON_4:
+      return "Apr";
+    case ABMON_5:
+      return "May";
+    case ABMON_6:
+      return "Jun";
+    case ABMON_7:
+      return "Jul";
+    case ABMON_8:
+      return "Aug";
+    case ABMON_9:
+      return "Sep";
+    case ABMON_10:
+      return "Oct";
+    case ABMON_11:
+      return "Nov";
+    case ABMON_12:
+      return "Dec";
+    case ERA:
+      return "";
+    case ALT_DIGITS:
+      return "\0\0\0\0\0\0\0\0\0\0";
+    /* nl_langinfo items of the LC_MONETARY category
+       TODO: Really use the locale. */
+    case CRNCYSTR:
+      return "-";
+    /* nl_langinfo items of the LC_MESSAGES category
+       TODO: Really use the locale. */
+    case YESEXPR:
+      return "^[yY]";
+    case NOEXPR:
+      return "^[nN]";
+    default:
+      return "";
+    }
+}
+
+#endif
diff --git a/libmissing/pathmax.h b/libmissing/pathmax.h
index a5d4335..61ccf07 100644
--- a/libmissing/pathmax.h
+++ b/libmissing/pathmax.h
@@ -1,5 +1,6 @@
 /* Define PATH_MAX somehow.  Requires sys/types.h.
-   Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009 Free Software Foundation, Inc.
+   Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009 Free Software Foundation,
+   Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -28,7 +29,7 @@
 
 # if !defined PATH_MAX && defined _PC_PATH_MAX && defined HAVE_PATHCONF
 #  define PATH_MAX (pathconf ("/", _PC_PATH_MAX) < 1 ? 1024 \
-		    : pathconf ("/", _PC_PATH_MAX))
+                    : pathconf ("/", _PC_PATH_MAX))
 # endif
 
 /* Don't include sys/param.h if it already has been.  */
diff --git a/libmissing/printf-args.c b/libmissing/printf-args.c
index c31d204..921931c 100644
--- a/libmissing/printf-args.c
+++ b/libmissing/printf-args.c
@@ -1,5 +1,6 @@
 /* Decomposed printf argument list.
-   Copyright (C) 1999, 2002-2003, 2005-2007 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2002-2003, 2005-2007, 2009 Free Software
+   Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -42,146 +43,146 @@ PRINTF_FETCHARGS (va_list args, arguments *a)
     switch (ap->type)
       {
       case TYPE_SCHAR:
-	ap->a.a_schar = va_arg (args, /*signed char*/ int);
-	break;
+        ap->a.a_schar = va_arg (args, /*signed char*/ int);
+        break;
       case TYPE_UCHAR:
-	ap->a.a_uchar = va_arg (args, /*unsigned char*/ int);
-	break;
+        ap->a.a_uchar = va_arg (args, /*unsigned char*/ int);
+        break;
       case TYPE_SHORT:
-	ap->a.a_short = va_arg (args, /*short*/ int);
-	break;
+        ap->a.a_short = va_arg (args, /*short*/ int);
+        break;
       case TYPE_USHORT:
-	ap->a.a_ushort = va_arg (args, /*unsigned short*/ int);
-	break;
+        ap->a.a_ushort = va_arg (args, /*unsigned short*/ int);
+        break;
       case TYPE_INT:
-	ap->a.a_int = va_arg (args, int);
-	break;
+        ap->a.a_int = va_arg (args, int);
+        break;
       case TYPE_UINT:
-	ap->a.a_uint = va_arg (args, unsigned int);
-	break;
+        ap->a.a_uint = va_arg (args, unsigned int);
+        break;
       case TYPE_LONGINT:
-	ap->a.a_longint = va_arg (args, long int);
-	break;
+        ap->a.a_longint = va_arg (args, long int);
+        break;
       case TYPE_ULONGINT:
-	ap->a.a_ulongint = va_arg (args, unsigned long int);
-	break;
+        ap->a.a_ulongint = va_arg (args, unsigned long int);
+        break;
 #if HAVE_LONG_LONG_INT
       case TYPE_LONGLONGINT:
-	ap->a.a_longlongint = va_arg (args, long long int);
-	break;
+        ap->a.a_longlongint = va_arg (args, long long int);
+        break;
       case TYPE_ULONGLONGINT:
-	ap->a.a_ulonglongint = va_arg (args, unsigned long long int);
-	break;
+        ap->a.a_ulonglongint = va_arg (args, unsigned long long int);
+        break;
 #endif
       case TYPE_DOUBLE:
-	ap->a.a_double = va_arg (args, double);
-	break;
+        ap->a.a_double = va_arg (args, double);
+        break;
       case TYPE_LONGDOUBLE:
-	ap->a.a_longdouble = va_arg (args, long double);
-	break;
+        ap->a.a_longdouble = va_arg (args, long double);
+        break;
       case TYPE_CHAR:
-	ap->a.a_char = va_arg (args, int);
-	break;
+        ap->a.a_char = va_arg (args, int);
+        break;
 #if HAVE_WINT_T
       case TYPE_WIDE_CHAR:
-	/* Although ISO C 99 7.24.1.(2) says that wint_t is "unchanged by
-	   default argument promotions", this is not the case in mingw32,
-	   where wint_t is 'unsigned short'.  */
-	ap->a.a_wide_char =
-	  (sizeof (wint_t) < sizeof (int)
-	   ? va_arg (args, int)
-	   : va_arg (args, wint_t));
-	break;
+        /* Although ISO C 99 7.24.1.(2) says that wint_t is "unchanged by
+           default argument promotions", this is not the case in mingw32,
+           where wint_t is 'unsigned short'.  */
+        ap->a.a_wide_char =
+          (sizeof (wint_t) < sizeof (int)
+           ? (wint_t) va_arg (args, int)
+           : va_arg (args, wint_t));
+        break;
 #endif
       case TYPE_STRING:
-	ap->a.a_string = va_arg (args, const char *);
-	/* A null pointer is an invalid argument for "%s", but in practice
-	   it occurs quite frequently in printf statements that produce
-	   debug output.  Use a fallback in this case.  */
-	if (ap->a.a_string == NULL)
-	  ap->a.a_string = "(NULL)";
-	break;
+        ap->a.a_string = va_arg (args, const char *);
+        /* A null pointer is an invalid argument for "%s", but in practice
+           it occurs quite frequently in printf statements that produce
+           debug output.  Use a fallback in this case.  */
+        if (ap->a.a_string == NULL)
+          ap->a.a_string = "(NULL)";
+        break;
 #if HAVE_WCHAR_T
       case TYPE_WIDE_STRING:
-	ap->a.a_wide_string = va_arg (args, const wchar_t *);
-	/* A null pointer is an invalid argument for "%ls", but in practice
-	   it occurs quite frequently in printf statements that produce
-	   debug output.  Use a fallback in this case.  */
-	if (ap->a.a_wide_string == NULL)
-	  {
-	    static const wchar_t wide_null_string[] =
-	      {
-		(wchar_t)'(',
-		(wchar_t)'N', (wchar_t)'U', (wchar_t)'L', (wchar_t)'L',
-		(wchar_t)')',
-		(wchar_t)0
-	      };
-	    ap->a.a_wide_string = wide_null_string;
-	  }
-	break;
+        ap->a.a_wide_string = va_arg (args, const wchar_t *);
+        /* A null pointer is an invalid argument for "%ls", but in practice
+           it occurs quite frequently in printf statements that produce
+           debug output.  Use a fallback in this case.  */
+        if (ap->a.a_wide_string == NULL)
+          {
+            static const wchar_t wide_null_string[] =
+              {
+                (wchar_t)'(',
+                (wchar_t)'N', (wchar_t)'U', (wchar_t)'L', (wchar_t)'L',
+                (wchar_t)')',
+                (wchar_t)0
+              };
+            ap->a.a_wide_string = wide_null_string;
+          }
+        break;
 #endif
       case TYPE_POINTER:
-	ap->a.a_pointer = va_arg (args, void *);
-	break;
+        ap->a.a_pointer = va_arg (args, void *);
+        break;
       case TYPE_COUNT_SCHAR_POINTER:
-	ap->a.a_count_schar_pointer = va_arg (args, signed char *);
-	break;
+        ap->a.a_count_schar_pointer = va_arg (args, signed char *);
+        break;
       case TYPE_COUNT_SHORT_POINTER:
-	ap->a.a_count_short_pointer = va_arg (args, short *);
-	break;
+        ap->a.a_count_short_pointer = va_arg (args, short *);
+        break;
       case TYPE_COUNT_INT_POINTER:
-	ap->a.a_count_int_pointer = va_arg (args, int *);
-	break;
+        ap->a.a_count_int_pointer = va_arg (args, int *);
+        break;
       case TYPE_COUNT_LONGINT_POINTER:
-	ap->a.a_count_longint_pointer = va_arg (args, long int *);
-	break;
+        ap->a.a_count_longint_pointer = va_arg (args, long int *);
+        break;
 #if HAVE_LONG_LONG_INT
       case TYPE_COUNT_LONGLONGINT_POINTER:
-	ap->a.a_count_longlongint_pointer = va_arg (args, long long int *);
-	break;
+        ap->a.a_count_longlongint_pointer = va_arg (args, long long int *);
+        break;
 #endif
 #if ENABLE_UNISTDIO
       /* The unistdio extensions.  */
       case TYPE_U8_STRING:
-	ap->a.a_u8_string = va_arg (args, const uint8_t *);
-	/* A null pointer is an invalid argument for "%U", but in practice
-	   it occurs quite frequently in printf statements that produce
-	   debug output.  Use a fallback in this case.  */
-	if (ap->a.a_u8_string == NULL)
-	  {
-	    static const uint8_t u8_null_string[] =
-	      { '(', 'N', 'U', 'L', 'L', ')', 0 };
-	    ap->a.a_u8_string = u8_null_string;
-	  }
-	break;
+        ap->a.a_u8_string = va_arg (args, const uint8_t *);
+        /* A null pointer is an invalid argument for "%U", but in practice
+           it occurs quite frequently in printf statements that produce
+           debug output.  Use a fallback in this case.  */
+        if (ap->a.a_u8_string == NULL)
+          {
+            static const uint8_t u8_null_string[] =
+              { '(', 'N', 'U', 'L', 'L', ')', 0 };
+            ap->a.a_u8_string = u8_null_string;
+          }
+        break;
       case TYPE_U16_STRING:
-	ap->a.a_u16_string = va_arg (args, const uint16_t *);
-	/* A null pointer is an invalid argument for "%lU", but in practice
-	   it occurs quite frequently in printf statements that produce
-	   debug output.  Use a fallback in this case.  */
-	if (ap->a.a_u16_string == NULL)
-	  {
-	    static const uint16_t u16_null_string[] =
-	      { '(', 'N', 'U', 'L', 'L', ')', 0 };
-	    ap->a.a_u16_string = u16_null_string;
-	  }
-	break;
+        ap->a.a_u16_string = va_arg (args, const uint16_t *);
+        /* A null pointer is an invalid argument for "%lU", but in practice
+           it occurs quite frequently in printf statements that produce
+           debug output.  Use a fallback in this case.  */
+        if (ap->a.a_u16_string == NULL)
+          {
+            static const uint16_t u16_null_string[] =
+              { '(', 'N', 'U', 'L', 'L', ')', 0 };
+            ap->a.a_u16_string = u16_null_string;
+          }
+        break;
       case TYPE_U32_STRING:
-	ap->a.a_u32_string = va_arg (args, const uint32_t *);
-	/* A null pointer is an invalid argument for "%llU", but in practice
-	   it occurs quite frequently in printf statements that produce
-	   debug output.  Use a fallback in this case.  */
-	if (ap->a.a_u32_string == NULL)
-	  {
-	    static const uint32_t u32_null_string[] =
-	      { '(', 'N', 'U', 'L', 'L', ')', 0 };
-	    ap->a.a_u32_string = u32_null_string;
-	  }
-	break;
+        ap->a.a_u32_string = va_arg (args, const uint32_t *);
+        /* A null pointer is an invalid argument for "%llU", but in practice
+           it occurs quite frequently in printf statements that produce
+           debug output.  Use a fallback in this case.  */
+        if (ap->a.a_u32_string == NULL)
+          {
+            static const uint32_t u32_null_string[] =
+              { '(', 'N', 'U', 'L', 'L', ')', 0 };
+            ap->a.a_u32_string = u32_null_string;
+          }
+        break;
 #endif
       default:
-	/* Unknown type.  */
-	return -1;
+        /* Unknown type.  */
+        return -1;
       }
   return 0;
 }
diff --git a/libmissing/printf-args.h b/libmissing/printf-args.h
index 4c68f11..38dfb43 100644
--- a/libmissing/printf-args.h
+++ b/libmissing/printf-args.h
@@ -1,5 +1,6 @@
 /* Decomposed printf argument list.
-   Copyright (C) 1999, 2002-2003, 2006-2007 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2002-2003, 2006-2007, 2009 Free Software Foundation,
+   Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -93,42 +94,42 @@ typedef struct
   arg_type type;
   union
   {
-    signed char			a_schar;
-    unsigned char		a_uchar;
-    short			a_short;
-    unsigned short		a_ushort;
-    int				a_int;
-    unsigned int		a_uint;
-    long int			a_longint;
-    unsigned long int		a_ulongint;
+    signed char                 a_schar;
+    unsigned char               a_uchar;
+    short                       a_short;
+    unsigned short              a_ushort;
+    int                         a_int;
+    unsigned int                a_uint;
+    long int                    a_longint;
+    unsigned long int           a_ulongint;
 #if HAVE_LONG_LONG_INT
-    long long int		a_longlongint;
-    unsigned long long int	a_ulonglongint;
+    long long int               a_longlongint;
+    unsigned long long int      a_ulonglongint;
 #endif
-    float			a_float;
-    double			a_double;
-    long double			a_longdouble;
-    int				a_char;
+    float                       a_float;
+    double                      a_double;
+    long double                 a_longdouble;
+    int                         a_char;
 #if HAVE_WINT_T
-    wint_t			a_wide_char;
+    wint_t                      a_wide_char;
 #endif
-    const char*			a_string;
+    const char*                 a_string;
 #if HAVE_WCHAR_T
-    const wchar_t*		a_wide_string;
+    const wchar_t*              a_wide_string;
 #endif
-    void*			a_pointer;
-    signed char *		a_count_schar_pointer;
-    short *			a_count_short_pointer;
-    int *			a_count_int_pointer;
-    long int *			a_count_longint_pointer;
+    void*                       a_pointer;
+    signed char *               a_count_schar_pointer;
+    short *                     a_count_short_pointer;
+    int *                       a_count_int_pointer;
+    long int *                  a_count_longint_pointer;
 #if HAVE_LONG_LONG_INT
-    long long int *		a_count_longlongint_pointer;
+    long long int *             a_count_longlongint_pointer;
 #endif
 #if ENABLE_UNISTDIO
     /* The unistdio extensions.  */
-    const uint8_t *		a_u8_string;
-    const uint16_t *		a_u16_string;
-    const uint32_t *		a_u32_string;
+    const uint8_t *             a_u8_string;
+    const uint16_t *            a_u16_string;
+    const uint32_t *            a_u32_string;
 #endif
   }
   a;
diff --git a/libmissing/printf-parse.c b/libmissing/printf-parse.c
index 85c454b..22872ca 100644
--- a/libmissing/printf-parse.c
+++ b/libmissing/printf-parse.c
@@ -1,5 +1,5 @@
 /* Formatted output to strings.
-   Copyright (C) 1999-2000, 2002-2003, 2006-2008 Free Software Foundation, Inc.
+   Copyright (C) 1999-2000, 2002-2003, 2006-2009 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -80,10 +80,10 @@ STATIC
 int
 PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
 {
-  const CHAR_T *cp = format;		/* pointer into format */
-  size_t arg_posn = 0;		/* number of regular arguments consumed */
-  size_t d_allocated;			/* allocated elements of d->dir */
-  size_t a_allocated;			/* allocated elements of a->arg */
+  const CHAR_T *cp = format;            /* pointer into format */
+  size_t arg_posn = 0;          /* number of regular arguments consumed */
+  size_t d_allocated;                   /* allocated elements of d->dir */
+  size_t a_allocated;                   /* allocated elements of a->arg */
   size_t max_width_length = 0;
   size_t max_precision_length = 0;
 
@@ -99,501 +99,501 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
   a->arg = NULL;
 
 #define REGISTER_ARG(_index_,_type_) \
-  {									\
-    size_t n = (_index_);						\
-    if (n >= a_allocated)						\
-      {									\
-	size_t memory_size;						\
-	argument *memory;						\
-									\
-	a_allocated = xtimes (a_allocated, 2);				\
-	if (a_allocated <= n)						\
-	  a_allocated = xsum (n, 1);					\
-	memory_size = xtimes (a_allocated, sizeof (argument));		\
-	if (size_overflow_p (memory_size))				\
-	  /* Overflow, would lead to out of memory.  */			\
-	  goto out_of_memory;						\
-	memory = (argument *) (a->arg					\
-			       ? realloc (a->arg, memory_size)		\
-			       : malloc (memory_size));			\
-	if (memory == NULL)						\
-	  /* Out of memory.  */						\
-	  goto out_of_memory;						\
-	a->arg = memory;						\
-      }									\
-    while (a->count <= n)						\
-      a->arg[a->count++].type = TYPE_NONE;				\
-    if (a->arg[n].type == TYPE_NONE)					\
-      a->arg[n].type = (_type_);					\
-    else if (a->arg[n].type != (_type_))				\
-      /* Ambiguous type for positional argument.  */			\
-      goto error;							\
+  {                                                                     \
+    size_t n = (_index_);                                               \
+    if (n >= a_allocated)                                               \
+      {                                                                 \
+        size_t memory_size;                                             \
+        argument *memory;                                               \
+                                                                        \
+        a_allocated = xtimes (a_allocated, 2);                          \
+        if (a_allocated <= n)                                           \
+          a_allocated = xsum (n, 1);                                    \
+        memory_size = xtimes (a_allocated, sizeof (argument));          \
+        if (size_overflow_p (memory_size))                              \
+          /* Overflow, would lead to out of memory.  */                 \
+          goto out_of_memory;                                           \
+        memory = (argument *) (a->arg                                   \
+                               ? realloc (a->arg, memory_size)          \
+                               : malloc (memory_size));                 \
+        if (memory == NULL)                                             \
+          /* Out of memory.  */                                         \
+          goto out_of_memory;                                           \
+        a->arg = memory;                                                \
+      }                                                                 \
+    while (a->count <= n)                                               \
+      a->arg[a->count++].type = TYPE_NONE;                              \
+    if (a->arg[n].type == TYPE_NONE)                                    \
+      a->arg[n].type = (_type_);                                        \
+    else if (a->arg[n].type != (_type_))                                \
+      /* Ambiguous type for positional argument.  */                    \
+      goto error;                                                       \
   }
 
   while (*cp != '\0')
     {
       CHAR_T c = *cp++;
       if (c == '%')
-	{
-	  size_t arg_index = ARG_NONE;
-	  DIRECTIVE *dp = &d->dir[d->count]; /* pointer to next directive */
-
-	  /* Initialize the next directive.  */
-	  dp->dir_start = cp - 1;
-	  dp->flags = 0;
-	  dp->width_start = NULL;
-	  dp->width_end = NULL;
-	  dp->width_arg_index = ARG_NONE;
-	  dp->precision_start = NULL;
-	  dp->precision_end = NULL;
-	  dp->precision_arg_index = ARG_NONE;
-	  dp->arg_index = ARG_NONE;
-
-	  /* Test for positional argument.  */
-	  if (*cp >= '0' && *cp <= '9')
-	    {
-	      const CHAR_T *np;
-
-	      for (np = cp; *np >= '0' && *np <= '9'; np++)
-		;
-	      if (*np == '$')
-		{
-		  size_t n = 0;
-
-		  for (np = cp; *np >= '0' && *np <= '9'; np++)
-		    n = xsum (xtimes (n, 10), *np - '0');
-		  if (n == 0)
-		    /* Positional argument 0.  */
-		    goto error;
-		  if (size_overflow_p (n))
-		    /* n too large, would lead to out of memory later.  */
-		    goto error;
-		  arg_index = n - 1;
-		  cp = np + 1;
-		}
-	    }
-
-	  /* Read the flags.  */
-	  for (;;)
-	    {
-	      if (*cp == '\'')
-		{
-		  dp->flags |= FLAG_GROUP;
-		  cp++;
-		}
-	      else if (*cp == '-')
-		{
-		  dp->flags |= FLAG_LEFT;
-		  cp++;
-		}
-	      else if (*cp == '+')
-		{
-		  dp->flags |= FLAG_SHOWSIGN;
-		  cp++;
-		}
-	      else if (*cp == ' ')
-		{
-		  dp->flags |= FLAG_SPACE;
-		  cp++;
-		}
-	      else if (*cp == '#')
-		{
-		  dp->flags |= FLAG_ALT;
-		  cp++;
-		}
-	      else if (*cp == '0')
-		{
-		  dp->flags |= FLAG_ZERO;
-		  cp++;
-		}
-	      else
-		break;
-	    }
-
-	  /* Parse the field width.  */
-	  if (*cp == '*')
-	    {
-	      dp->width_start = cp;
-	      cp++;
-	      dp->width_end = cp;
-	      if (max_width_length < 1)
-		max_width_length = 1;
-
-	      /* Test for positional argument.  */
-	      if (*cp >= '0' && *cp <= '9')
-		{
-		  const CHAR_T *np;
-
-		  for (np = cp; *np >= '0' && *np <= '9'; np++)
-		    ;
-		  if (*np == '$')
-		    {
-		      size_t n = 0;
-
-		      for (np = cp; *np >= '0' && *np <= '9'; np++)
-			n = xsum (xtimes (n, 10), *np - '0');
-		      if (n == 0)
-			/* Positional argument 0.  */
-			goto error;
-		      if (size_overflow_p (n))
-			/* n too large, would lead to out of memory later.  */
-			goto error;
-		      dp->width_arg_index = n - 1;
-		      cp = np + 1;
-		    }
-		}
-	      if (dp->width_arg_index == ARG_NONE)
-		{
-		  dp->width_arg_index = arg_posn++;
-		  if (dp->width_arg_index == ARG_NONE)
-		    /* arg_posn wrapped around.  */
-		    goto error;
-		}
-	      REGISTER_ARG (dp->width_arg_index, TYPE_INT);
-	    }
-	  else if (*cp >= '0' && *cp <= '9')
-	    {
-	      size_t width_length;
-
-	      dp->width_start = cp;
-	      for (; *cp >= '0' && *cp <= '9'; cp++)
-		;
-	      dp->width_end = cp;
-	      width_length = dp->width_end - dp->width_start;
-	      if (max_width_length < width_length)
-		max_width_length = width_length;
-	    }
-
-	  /* Parse the precision.  */
-	  if (*cp == '.')
-	    {
-	      cp++;
-	      if (*cp == '*')
-		{
-		  dp->precision_start = cp - 1;
-		  cp++;
-		  dp->precision_end = cp;
-		  if (max_precision_length < 2)
-		    max_precision_length = 2;
-
-		  /* Test for positional argument.  */
-		  if (*cp >= '0' && *cp <= '9')
-		    {
-		      const CHAR_T *np;
-
-		      for (np = cp; *np >= '0' && *np <= '9'; np++)
-			;
-		      if (*np == '$')
-			{
-			  size_t n = 0;
-
-			  for (np = cp; *np >= '0' && *np <= '9'; np++)
-			    n = xsum (xtimes (n, 10), *np - '0');
-			  if (n == 0)
-			    /* Positional argument 0.  */
-			    goto error;
-			  if (size_overflow_p (n))
-			    /* n too large, would lead to out of memory
-			       later.  */
-			    goto error;
-			  dp->precision_arg_index = n - 1;
-			  cp = np + 1;
-			}
-		    }
-		  if (dp->precision_arg_index == ARG_NONE)
-		    {
-		      dp->precision_arg_index = arg_posn++;
-		      if (dp->precision_arg_index == ARG_NONE)
-			/* arg_posn wrapped around.  */
-			goto error;
-		    }
-		  REGISTER_ARG (dp->precision_arg_index, TYPE_INT);
-		}
-	      else
-		{
-		  size_t precision_length;
-
-		  dp->precision_start = cp - 1;
-		  for (; *cp >= '0' && *cp <= '9'; cp++)
-		    ;
-		  dp->precision_end = cp;
-		  precision_length = dp->precision_end - dp->precision_start;
-		  if (max_precision_length < precision_length)
-		    max_precision_length = precision_length;
-		}
-	    }
-
-	  {
-	    arg_type type;
-
-	    /* Parse argument type/size specifiers.  */
-	    {
-	      int flags = 0;
-
-	      for (;;)
-		{
-		  if (*cp == 'h')
-		    {
-		      flags |= (1 << (flags & 1));
-		      cp++;
-		    }
-		  else if (*cp == 'L')
-		    {
-		      flags |= 4;
-		      cp++;
-		    }
-		  else if (*cp == 'l')
-		    {
-		      flags += 8;
-		      cp++;
-		    }
-		  else if (*cp == 'j')
-		    {
-		      if (sizeof (intmax_t) > sizeof (long))
-			{
-			  /* intmax_t = long long */
-			  flags += 16;
-			}
-		      else if (sizeof (intmax_t) > sizeof (int))
-			{
-			  /* intmax_t = long */
-			  flags += 8;
-			}
-		      cp++;
-		    }
-		  else if (*cp == 'z' || *cp == 'Z')
-		    {
-		      /* 'z' is standardized in ISO C 99, but glibc uses 'Z'
-			 because the warning facility in gcc-2.95.2 understands
-			 only 'Z' (see gcc-2.95.2/gcc/c-common.c:1784).  */
-		      if (sizeof (size_t) > sizeof (long))
-			{
-			  /* size_t = long long */
-			  flags += 16;
-			}
-		      else if (sizeof (size_t) > sizeof (int))
-			{
-			  /* size_t = long */
-			  flags += 8;
-			}
-		      cp++;
-		    }
-		  else if (*cp == 't')
-		    {
-		      if (sizeof (ptrdiff_t) > sizeof (long))
-			{
-			  /* ptrdiff_t = long long */
-			  flags += 16;
-			}
-		      else if (sizeof (ptrdiff_t) > sizeof (int))
-			{
-			  /* ptrdiff_t = long */
-			  flags += 8;
-			}
-		      cp++;
-		    }
+        {
+          size_t arg_index = ARG_NONE;
+          DIRECTIVE *dp = &d->dir[d->count]; /* pointer to next directive */
+
+          /* Initialize the next directive.  */
+          dp->dir_start = cp - 1;
+          dp->flags = 0;
+          dp->width_start = NULL;
+          dp->width_end = NULL;
+          dp->width_arg_index = ARG_NONE;
+          dp->precision_start = NULL;
+          dp->precision_end = NULL;
+          dp->precision_arg_index = ARG_NONE;
+          dp->arg_index = ARG_NONE;
+
+          /* Test for positional argument.  */
+          if (*cp >= '0' && *cp <= '9')
+            {
+              const CHAR_T *np;
+
+              for (np = cp; *np >= '0' && *np <= '9'; np++)
+                ;
+              if (*np == '$')
+                {
+                  size_t n = 0;
+
+                  for (np = cp; *np >= '0' && *np <= '9'; np++)
+                    n = xsum (xtimes (n, 10), *np - '0');
+                  if (n == 0)
+                    /* Positional argument 0.  */
+                    goto error;
+                  if (size_overflow_p (n))
+                    /* n too large, would lead to out of memory later.  */
+                    goto error;
+                  arg_index = n - 1;
+                  cp = np + 1;
+                }
+            }
+
+          /* Read the flags.  */
+          for (;;)
+            {
+              if (*cp == '\'')
+                {
+                  dp->flags |= FLAG_GROUP;
+                  cp++;
+                }
+              else if (*cp == '-')
+                {
+                  dp->flags |= FLAG_LEFT;
+                  cp++;
+                }
+              else if (*cp == '+')
+                {
+                  dp->flags |= FLAG_SHOWSIGN;
+                  cp++;
+                }
+              else if (*cp == ' ')
+                {
+                  dp->flags |= FLAG_SPACE;
+                  cp++;
+                }
+              else if (*cp == '#')
+                {
+                  dp->flags |= FLAG_ALT;
+                  cp++;
+                }
+              else if (*cp == '0')
+                {
+                  dp->flags |= FLAG_ZERO;
+                  cp++;
+                }
+              else
+                break;
+            }
+
+          /* Parse the field width.  */
+          if (*cp == '*')
+            {
+              dp->width_start = cp;
+              cp++;
+              dp->width_end = cp;
+              if (max_width_length < 1)
+                max_width_length = 1;
+
+              /* Test for positional argument.  */
+              if (*cp >= '0' && *cp <= '9')
+                {
+                  const CHAR_T *np;
+
+                  for (np = cp; *np >= '0' && *np <= '9'; np++)
+                    ;
+                  if (*np == '$')
+                    {
+                      size_t n = 0;
+
+                      for (np = cp; *np >= '0' && *np <= '9'; np++)
+                        n = xsum (xtimes (n, 10), *np - '0');
+                      if (n == 0)
+                        /* Positional argument 0.  */
+                        goto error;
+                      if (size_overflow_p (n))
+                        /* n too large, would lead to out of memory later.  */
+                        goto error;
+                      dp->width_arg_index = n - 1;
+                      cp = np + 1;
+                    }
+                }
+              if (dp->width_arg_index == ARG_NONE)
+                {
+                  dp->width_arg_index = arg_posn++;
+                  if (dp->width_arg_index == ARG_NONE)
+                    /* arg_posn wrapped around.  */
+                    goto error;
+                }
+              REGISTER_ARG (dp->width_arg_index, TYPE_INT);
+            }
+          else if (*cp >= '0' && *cp <= '9')
+            {
+              size_t width_length;
+
+              dp->width_start = cp;
+              for (; *cp >= '0' && *cp <= '9'; cp++)
+                ;
+              dp->width_end = cp;
+              width_length = dp->width_end - dp->width_start;
+              if (max_width_length < width_length)
+                max_width_length = width_length;
+            }
+
+          /* Parse the precision.  */
+          if (*cp == '.')
+            {
+              cp++;
+              if (*cp == '*')
+                {
+                  dp->precision_start = cp - 1;
+                  cp++;
+                  dp->precision_end = cp;
+                  if (max_precision_length < 2)
+                    max_precision_length = 2;
+
+                  /* Test for positional argument.  */
+                  if (*cp >= '0' && *cp <= '9')
+                    {
+                      const CHAR_T *np;
+
+                      for (np = cp; *np >= '0' && *np <= '9'; np++)
+                        ;
+                      if (*np == '$')
+                        {
+                          size_t n = 0;
+
+                          for (np = cp; *np >= '0' && *np <= '9'; np++)
+                            n = xsum (xtimes (n, 10), *np - '0');
+                          if (n == 0)
+                            /* Positional argument 0.  */
+                            goto error;
+                          if (size_overflow_p (n))
+                            /* n too large, would lead to out of memory
+                               later.  */
+                            goto error;
+                          dp->precision_arg_index = n - 1;
+                          cp = np + 1;
+                        }
+                    }
+                  if (dp->precision_arg_index == ARG_NONE)
+                    {
+                      dp->precision_arg_index = arg_posn++;
+                      if (dp->precision_arg_index == ARG_NONE)
+                        /* arg_posn wrapped around.  */
+                        goto error;
+                    }
+                  REGISTER_ARG (dp->precision_arg_index, TYPE_INT);
+                }
+              else
+                {
+                  size_t precision_length;
+
+                  dp->precision_start = cp - 1;
+                  for (; *cp >= '0' && *cp <= '9'; cp++)
+                    ;
+                  dp->precision_end = cp;
+                  precision_length = dp->precision_end - dp->precision_start;
+                  if (max_precision_length < precision_length)
+                    max_precision_length = precision_length;
+                }
+            }
+
+          {
+            arg_type type;
+
+            /* Parse argument type/size specifiers.  */
+            {
+              int flags = 0;
+
+              for (;;)
+                {
+                  if (*cp == 'h')
+                    {
+                      flags |= (1 << (flags & 1));
+                      cp++;
+                    }
+                  else if (*cp == 'L')
+                    {
+                      flags |= 4;
+                      cp++;
+                    }
+                  else if (*cp == 'l')
+                    {
+                      flags += 8;
+                      cp++;
+                    }
+                  else if (*cp == 'j')
+                    {
+                      if (sizeof (intmax_t) > sizeof (long))
+                        {
+                          /* intmax_t = long long */
+                          flags += 16;
+                        }
+                      else if (sizeof (intmax_t) > sizeof (int))
+                        {
+                          /* intmax_t = long */
+                          flags += 8;
+                        }
+                      cp++;
+                    }
+                  else if (*cp == 'z' || *cp == 'Z')
+                    {
+                      /* 'z' is standardized in ISO C 99, but glibc uses 'Z'
+                         because the warning facility in gcc-2.95.2 understands
+                         only 'Z' (see gcc-2.95.2/gcc/c-common.c:1784).  */
+                      if (sizeof (size_t) > sizeof (long))
+                        {
+                          /* size_t = long long */
+                          flags += 16;
+                        }
+                      else if (sizeof (size_t) > sizeof (int))
+                        {
+                          /* size_t = long */
+                          flags += 8;
+                        }
+                      cp++;
+                    }
+                  else if (*cp == 't')
+                    {
+                      if (sizeof (ptrdiff_t) > sizeof (long))
+                        {
+                          /* ptrdiff_t = long long */
+                          flags += 16;
+                        }
+                      else if (sizeof (ptrdiff_t) > sizeof (int))
+                        {
+                          /* ptrdiff_t = long */
+                          flags += 8;
+                        }
+                      cp++;
+                    }
 #if defined __APPLE__ && defined __MACH__
-		  /* On MacOS X 10.3, PRIdMAX is defined as "qd".
-		     We cannot change it to "lld" because PRIdMAX must also
-		     be understood by the system's printf routines.  */
-		  else if (*cp == 'q')
-		    {
-		      if (64 / 8 > sizeof (long))
-			{
-			  /* int64_t = long long */
-			  flags += 16;
-			}
-		      else
-			{
-			  /* int64_t = long */
-			  flags += 8;
-			}
-		      cp++;
-		    }
+                  /* On MacOS X 10.3, PRIdMAX is defined as "qd".
+                     We cannot change it to "lld" because PRIdMAX must also
+                     be understood by the system's printf routines.  */
+                  else if (*cp == 'q')
+                    {
+                      if (64 / 8 > sizeof (long))
+                        {
+                          /* int64_t = long long */
+                          flags += 16;
+                        }
+                      else
+                        {
+                          /* int64_t = long */
+                          flags += 8;
+                        }
+                      cp++;
+                    }
 #endif
 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-		  /* On native Win32, PRIdMAX is defined as "I64d".
-		     We cannot change it to "lld" because PRIdMAX must also
-		     be understood by the system's printf routines.  */
-		  else if (*cp == 'I' && cp[1] == '6' && cp[2] == '4')
-		    {
-		      if (64 / 8 > sizeof (long))
-			{
-			  /* __int64 = long long */
-			  flags += 16;
-			}
-		      else
-			{
-			  /* __int64 = long */
-			  flags += 8;
-			}
-		      cp += 3;
-		    }
+                  /* On native Win32, PRIdMAX is defined as "I64d".
+                     We cannot change it to "lld" because PRIdMAX must also
+                     be understood by the system's printf routines.  */
+                  else if (*cp == 'I' && cp[1] == '6' && cp[2] == '4')
+                    {
+                      if (64 / 8 > sizeof (long))
+                        {
+                          /* __int64 = long long */
+                          flags += 16;
+                        }
+                      else
+                        {
+                          /* __int64 = long */
+                          flags += 8;
+                        }
+                      cp += 3;
+                    }
 #endif
-		  else
-		    break;
-		}
-
-	      /* Read the conversion character.  */
-	      c = *cp++;
-	      switch (c)
-		{
-		case 'd': case 'i':
+                  else
+                    break;
+                }
+
+              /* Read the conversion character.  */
+              c = *cp++;
+              switch (c)
+                {
+                case 'd': case 'i':
 #if HAVE_LONG_LONG_INT
-		  /* If 'long long' exists and is larger than 'long':  */
-		  if (flags >= 16 || (flags & 4))
-		    type = TYPE_LONGLONGINT;
-		  else
+                  /* If 'long long' exists and is larger than 'long':  */
+                  if (flags >= 16 || (flags & 4))
+                    type = TYPE_LONGLONGINT;
+                  else
 #endif
-		  /* If 'long long' exists and is the same as 'long', we parse
-		     "lld" into TYPE_LONGINT.  */
-		  if (flags >= 8)
-		    type = TYPE_LONGINT;
-		  else if (flags & 2)
-		    type = TYPE_SCHAR;
-		  else if (flags & 1)
-		    type = TYPE_SHORT;
-		  else
-		    type = TYPE_INT;
-		  break;
-		case 'o': case 'u': case 'x': case 'X':
+                  /* If 'long long' exists and is the same as 'long', we parse
+                     "lld" into TYPE_LONGINT.  */
+                  if (flags >= 8)
+                    type = TYPE_LONGINT;
+                  else if (flags & 2)
+                    type = TYPE_SCHAR;
+                  else if (flags & 1)
+                    type = TYPE_SHORT;
+                  else
+                    type = TYPE_INT;
+                  break;
+                case 'o': case 'u': case 'x': case 'X':
 #if HAVE_LONG_LONG_INT
-		  /* If 'long long' exists and is larger than 'long':  */
-		  if (flags >= 16 || (flags & 4))
-		    type = TYPE_ULONGLONGINT;
-		  else
+                  /* If 'long long' exists and is larger than 'long':  */
+                  if (flags >= 16 || (flags & 4))
+                    type = TYPE_ULONGLONGINT;
+                  else
 #endif
-		  /* If 'unsigned long long' exists and is the same as
-		     'unsigned long', we parse "llu" into TYPE_ULONGINT.  */
-		  if (flags >= 8)
-		    type = TYPE_ULONGINT;
-		  else if (flags & 2)
-		    type = TYPE_UCHAR;
-		  else if (flags & 1)
-		    type = TYPE_USHORT;
-		  else
-		    type = TYPE_UINT;
-		  break;
-		case 'f': case 'F': case 'e': case 'E': case 'g': case 'G':
-		case 'a': case 'A':
-		  if (flags >= 16 || (flags & 4))
-		    type = TYPE_LONGDOUBLE;
-		  else
-		    type = TYPE_DOUBLE;
-		  break;
-		case 'c':
-		  if (flags >= 8)
+                  /* If 'unsigned long long' exists and is the same as
+                     'unsigned long', we parse "llu" into TYPE_ULONGINT.  */
+                  if (flags >= 8)
+                    type = TYPE_ULONGINT;
+                  else if (flags & 2)
+                    type = TYPE_UCHAR;
+                  else if (flags & 1)
+                    type = TYPE_USHORT;
+                  else
+                    type = TYPE_UINT;
+                  break;
+                case 'f': case 'F': case 'e': case 'E': case 'g': case 'G':
+                case 'a': case 'A':
+                  if (flags >= 16 || (flags & 4))
+                    type = TYPE_LONGDOUBLE;
+                  else
+                    type = TYPE_DOUBLE;
+                  break;
+                case 'c':
+                  if (flags >= 8)
 #if HAVE_WINT_T
-		    type = TYPE_WIDE_CHAR;
+                    type = TYPE_WIDE_CHAR;
 #else
-		    goto error;
+                    goto error;
 #endif
-		  else
-		    type = TYPE_CHAR;
-		  break;
+                  else
+                    type = TYPE_CHAR;
+                  break;
 #if HAVE_WINT_T
-		case 'C':
-		  type = TYPE_WIDE_CHAR;
-		  c = 'c';
-		  break;
+                case 'C':
+                  type = TYPE_WIDE_CHAR;
+                  c = 'c';
+                  break;
 #endif
-		case 's':
-		  if (flags >= 8)
+                case 's':
+                  if (flags >= 8)
 #if HAVE_WCHAR_T
-		    type = TYPE_WIDE_STRING;
+                    type = TYPE_WIDE_STRING;
 #else
-		    goto error;
+                    goto error;
 #endif
-		  else
-		    type = TYPE_STRING;
-		  break;
+                  else
+                    type = TYPE_STRING;
+                  break;
 #if HAVE_WCHAR_T
-		case 'S':
-		  type = TYPE_WIDE_STRING;
-		  c = 's';
-		  break;
+                case 'S':
+                  type = TYPE_WIDE_STRING;
+                  c = 's';
+                  break;
 #endif
-		case 'p':
-		  type = TYPE_POINTER;
-		  break;
-		case 'n':
+                case 'p':
+                  type = TYPE_POINTER;
+                  break;
+                case 'n':
 #if HAVE_LONG_LONG_INT
-		  /* If 'long long' exists and is larger than 'long':  */
-		  if (flags >= 16 || (flags & 4))
-		    type = TYPE_COUNT_LONGLONGINT_POINTER;
-		  else
+                  /* If 'long long' exists and is larger than 'long':  */
+                  if (flags >= 16 || (flags & 4))
+                    type = TYPE_COUNT_LONGLONGINT_POINTER;
+                  else
 #endif
-		  /* If 'long long' exists and is the same as 'long', we parse
-		     "lln" into TYPE_COUNT_LONGINT_POINTER.  */
-		  if (flags >= 8)
-		    type = TYPE_COUNT_LONGINT_POINTER;
-		  else if (flags & 2)
-		    type = TYPE_COUNT_SCHAR_POINTER;
-		  else if (flags & 1)
-		    type = TYPE_COUNT_SHORT_POINTER;
-		  else
-		    type = TYPE_COUNT_INT_POINTER;
-		  break;
+                  /* If 'long long' exists and is the same as 'long', we parse
+                     "lln" into TYPE_COUNT_LONGINT_POINTER.  */
+                  if (flags >= 8)
+                    type = TYPE_COUNT_LONGINT_POINTER;
+                  else if (flags & 2)
+                    type = TYPE_COUNT_SCHAR_POINTER;
+                  else if (flags & 1)
+                    type = TYPE_COUNT_SHORT_POINTER;
+                  else
+                    type = TYPE_COUNT_INT_POINTER;
+                  break;
 #if ENABLE_UNISTDIO
-		/* The unistdio extensions.  */
-		case 'U':
-		  if (flags >= 16)
-		    type = TYPE_U32_STRING;
-		  else if (flags >= 8)
-		    type = TYPE_U16_STRING;
-		  else
-		    type = TYPE_U8_STRING;
-		  break;
+                /* The unistdio extensions.  */
+                case 'U':
+                  if (flags >= 16)
+                    type = TYPE_U32_STRING;
+                  else if (flags >= 8)
+                    type = TYPE_U16_STRING;
+                  else
+                    type = TYPE_U8_STRING;
+                  break;
 #endif
-		case '%':
-		  type = TYPE_NONE;
-		  break;
-		default:
-		  /* Unknown conversion character.  */
-		  goto error;
-		}
-	    }
-
-	    if (type != TYPE_NONE)
-	      {
-		dp->arg_index = arg_index;
-		if (dp->arg_index == ARG_NONE)
-		  {
-		    dp->arg_index = arg_posn++;
-		    if (dp->arg_index == ARG_NONE)
-		      /* arg_posn wrapped around.  */
-		      goto error;
-		  }
-		REGISTER_ARG (dp->arg_index, type);
-	      }
-	    dp->conversion = c;
-	    dp->dir_end = cp;
-	  }
-
-	  d->count++;
-	  if (d->count >= d_allocated)
-	    {
-	      size_t memory_size;
-	      DIRECTIVE *memory;
-
-	      d_allocated = xtimes (d_allocated, 2);
-	      memory_size = xtimes (d_allocated, sizeof (DIRECTIVE));
-	      if (size_overflow_p (memory_size))
-		/* Overflow, would lead to out of memory.  */
-		goto out_of_memory;
-	      memory = (DIRECTIVE *) realloc (d->dir, memory_size);
-	      if (memory == NULL)
-		/* Out of memory.  */
-		goto out_of_memory;
-	      d->dir = memory;
-	    }
-	}
+                case '%':
+                  type = TYPE_NONE;
+                  break;
+                default:
+                  /* Unknown conversion character.  */
+                  goto error;
+                }
+            }
+
+            if (type != TYPE_NONE)
+              {
+                dp->arg_index = arg_index;
+                if (dp->arg_index == ARG_NONE)
+                  {
+                    dp->arg_index = arg_posn++;
+                    if (dp->arg_index == ARG_NONE)
+                      /* arg_posn wrapped around.  */
+                      goto error;
+                  }
+                REGISTER_ARG (dp->arg_index, type);
+              }
+            dp->conversion = c;
+            dp->dir_end = cp;
+          }
+
+          d->count++;
+          if (d->count >= d_allocated)
+            {
+              size_t memory_size;
+              DIRECTIVE *memory;
+
+              d_allocated = xtimes (d_allocated, 2);
+              memory_size = xtimes (d_allocated, sizeof (DIRECTIVE));
+              if (size_overflow_p (memory_size))
+                /* Overflow, would lead to out of memory.  */
+                goto out_of_memory;
+              memory = (DIRECTIVE *) realloc (d->dir, memory_size);
+              if (memory == NULL)
+                /* Out of memory.  */
+                goto out_of_memory;
+              d->dir = memory;
+            }
+        }
 #if CHAR_T_ONLY_ASCII
       else if (!c_isascii (c))
-	{
-	  /* Non-ASCII character.  Not supported.  */
-	  goto error;
-	}
+        {
+          /* Non-ASCII character.  Not supported.  */
+          goto error;
+        }
 #endif
     }
   d->dir[d->count].dir_start = cp;
diff --git a/libmissing/printf-parse.h b/libmissing/printf-parse.h
index 0a496cb..19d4e3d 100644
--- a/libmissing/printf-parse.h
+++ b/libmissing/printf-parse.h
@@ -1,5 +1,6 @@
 /* Parse printf format string.
-   Copyright (C) 1999, 2002-2003, 2005, 2007 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2002-2003, 2005, 2007, 2009 Free Software Foundation,
+   Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -26,15 +27,15 @@
 
 
 /* Flags */
-#define FLAG_GROUP	 1	/* ' flag */
-#define FLAG_LEFT	 2	/* - flag */
-#define FLAG_SHOWSIGN	 4	/* + flag */
-#define FLAG_SPACE	 8	/* space flag */
-#define FLAG_ALT	16	/* # flag */
-#define FLAG_ZERO	32
+#define FLAG_GROUP       1      /* ' flag */
+#define FLAG_LEFT        2      /* - flag */
+#define FLAG_SHOWSIGN    4      /* + flag */
+#define FLAG_SPACE       8      /* space flag */
+#define FLAG_ALT        16      /* # flag */
+#define FLAG_ZERO       32
 
 /* arg_index value indicating that no argument is consumed.  */
-#define ARG_NONE	(~(size_t)0)
+#define ARG_NONE        (~(size_t)0)
 
 /* xxx_directive: A parsed directive.
    xxx_directives: A parsed format string.  */
@@ -163,10 +164,10 @@ extern int
        u8_printf_parse (const uint8_t *format, u8_directives *d, arguments *a);
 extern int
        u16_printf_parse (const uint16_t *format, u16_directives *d,
-			 arguments *a);
+                         arguments *a);
 extern int
        u32_printf_parse (const uint32_t *format, u32_directives *d,
-			 arguments *a);
+                         arguments *a);
 #else
 # ifdef STATIC
 STATIC
diff --git a/libmissing/recvfrom.c b/libmissing/recvfrom.c
index 770183d..9f55d75 100644
--- a/libmissing/recvfrom.c
+++ b/libmissing/recvfrom.c
@@ -1,6 +1,6 @@
 /* recvfrom.c --- wrappers for Windows recvfrom function
 
-   Copyright (C) 2008 Free Software Foundation, Inc.
+   Copyright (C) 2008-2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -30,9 +30,9 @@
 
 int
 rpl_recvfrom (int fd, void *buf, int len, int flags, struct sockaddr *from,
-	      int *fromlen)
+              int *fromlen)
 {
-  int frombufsize = *fromlen;
+  int frombufsize = (from != NULL ? *fromlen : 0);
   SOCKET sock = FD_TO_SOCKET (fd);
   int r = recvfrom (sock, buf, len, flags, from, fromlen);
 
@@ -41,7 +41,7 @@ rpl_recvfrom (int fd, void *buf, int len, int flags, struct sockaddr *from,
 
   /* Winsock recvfrom() only returns a valid 'from' when the socket is
      connectionless.  POSIX gives a valid 'from' for all types of sockets.  */
-  else if (*fromlen == frombufsize)
+  else if (from != NULL && *fromlen == frombufsize)
     rpl_getpeername (fd, from, fromlen);
 
   return r;
diff --git a/libmissing/ref-add.sin b/libmissing/ref-add.sin
index 3acdcc8..71ab221 100644
--- a/libmissing/ref-add.sin
+++ b/libmissing/ref-add.sin
@@ -1,6 +1,6 @@
 # Add this package to a list of references stored in a text file.
 #
-#   Copyright (C) 2000 Free Software Foundation, Inc.
+#   Copyright (C) 2000, 2009 Free Software Foundation, Inc.
 #
 #   This program is free software; you can redistribute it and/or modify
 #   it under the terms of the GNU Lesser General Public License as published by
diff --git a/libmissing/ref-del.sin b/libmissing/ref-del.sin
index 7923d06..6c0b1de 100644
--- a/libmissing/ref-del.sin
+++ b/libmissing/ref-del.sin
@@ -1,6 +1,6 @@
 # Remove this package from a list of references stored in a text file.
 #
-#   Copyright (C) 2000 Free Software Foundation, Inc.
+#   Copyright (C) 2000, 2009 Free Software Foundation, Inc.
 #
 #   This program is free software; you can redistribute it and/or modify
 #   it under the terms of the GNU Lesser General Public License as published by
diff --git a/libmissing/sig-handler.h b/libmissing/sig-handler.h
index 6a3c162..41077f3 100644
--- a/libmissing/sig-handler.h
+++ b/libmissing/sig-handler.h
@@ -1,6 +1,6 @@
 /* Convenience declarations when working with <signal.h>.
 
-   Copyright (C) 2008 Free Software Foundation, Inc.
+   Copyright (C) 2008, 2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/libmissing/sigaction.c b/libmissing/sigaction.c
index 9727f58..4e77f32 100644
--- a/libmissing/sigaction.c
+++ b/libmissing/sigaction.c
@@ -1,5 +1,5 @@
 /* POSIX compatible signal blocking.
-   Copyright (C) 2008 Free Software Foundation, Inc.
+   Copyright (C) 2008, 2009 Free Software Foundation, Inc.
    Written by Eric Blake <[email protected]>, 2008.
 
    This program is free software: you can redistribute it and/or modify
@@ -91,7 +91,7 @@ sigaction_handler (int sig)
     {
       /* Unexpected situation; be careful to avoid recursive abort.  */
       if (sig == SIGABRT)
-	signal (SIGABRT, SIG_DFL);
+        signal (SIGABRT, SIG_DFL);
       abort ();
     }
 
diff --git a/libmissing/signal.in.h b/libmissing/signal.in.h
index 6dc922d..1dc5e3e 100644
--- a/libmissing/signal.in.h
+++ b/libmissing/signal.in.h
@@ -37,6 +37,8 @@
 
 /* The definition of GL_LINK_WARNING is copied here.  */
 
+/* The definition of _GL_ARG_NONNULL is copied here.  */
+
 /* Define pid_t, uid_t.
    Also, mingw defines sigset_t not in <signal.h>, but in <sys/types.h>.  */
 #include <sys/types.h>
@@ -82,22 +84,22 @@ typedef unsigned int sigset_t;
 # endif
 
 /* Test whether a given signal is contained in a signal set.  */
-extern int sigismember (const sigset_t *set, int sig);
+extern int sigismember (const sigset_t *set, int sig) _GL_ARG_NONNULL ((1));
 
 /* Initialize a signal set to the empty set.  */
-extern int sigemptyset (sigset_t *set);
+extern int sigemptyset (sigset_t *set) _GL_ARG_NONNULL ((1));
 
 /* Add a signal to a signal set.  */
-extern int sigaddset (sigset_t *set, int sig);
+extern int sigaddset (sigset_t *set, int sig) _GL_ARG_NONNULL ((1));
 
 /* Remove a signal from a signal set.  */
-extern int sigdelset (sigset_t *set, int sig);
+extern int sigdelset (sigset_t *set, int sig) _GL_ARG_NONNULL ((1));
 
 /* Fill a signal set with all possible signals.  */
-extern int sigfillset (sigset_t *set);
+extern int sigfillset (sigset_t *set) _GL_ARG_NONNULL ((1));
 
 /* Return the set of those blocked signals that are pending.  */
-extern int sigpending (sigset_t *set);
+extern int sigpending (sigset_t *set) _GL_ARG_NONNULL ((1));
 
 /* If OLD_SET is not NULL, put the current set of blocked signals in *OLD_SET.
    Then, if SET is not NULL, affect the current set of blocked signals by
diff --git a/libmissing/sigprocmask.c b/libmissing/sigprocmask.c
index b46d4f3..45e594e 100644
--- a/libmissing/sigprocmask.c
+++ b/libmissing/sigprocmask.c
@@ -1,5 +1,5 @@
 /* POSIX compatible signal blocking.
-   Copyright (C) 2006-2008 Free Software Foundation, Inc.
+   Copyright (C) 2006-2009 Free Software Foundation, Inc.
    Written by Bruno Haible <[email protected]>, 2006.
 
    This program is free software: you can redistribute it and/or modify
@@ -72,9 +72,9 @@ ext_signal (int sig, handler_t handler)
     {
     case SIGPIPE:
       {
-	handler_t old_handler = SIGPIPE_handler;
-	SIGPIPE_handler = handler;
-	return old_handler;
+        handler_t old_handler = SIGPIPE_handler;
+        SIGPIPE_handler = handler;
+        return old_handler;
       }
     default: /* System defined signal */
       return signal (sig, handler);
@@ -90,7 +90,7 @@ sigismember (const sigset_t *set, int sig)
     {
       #ifdef SIGABRT_COMPAT
       if (sig == SIGABRT_COMPAT)
-	sig = SIGABRT;
+        sig = SIGABRT;
       #endif
 
       return (*set >> sig) & 1;
@@ -113,7 +113,7 @@ sigaddset (sigset_t *set, int sig)
     {
       #ifdef SIGABRT_COMPAT
       if (sig == SIGABRT_COMPAT)
-	sig = SIGABRT;
+        sig = SIGABRT;
       #endif
 
       *set |= 1U << sig;
@@ -133,7 +133,7 @@ sigdelset (sigset_t *set, int sig)
     {
       #ifdef SIGABRT_COMPAT
       if (sig == SIGABRT_COMPAT)
-	sig = SIGABRT;
+        sig = SIGABRT;
       #endif
 
       *set &= ~(1U << sig);
@@ -204,60 +204,60 @@ sigprocmask (int operation, const sigset_t *set, sigset_t *old_set)
       sigset_t to_block;
 
       switch (operation)
-	{
-	case SIG_BLOCK:
-	  new_blocked_set = blocked_set | *set;
-	  break;
-	case SIG_SETMASK:
-	  new_blocked_set = *set;
-	  break;
-	case SIG_UNBLOCK:
-	  new_blocked_set = blocked_set & ~*set;
-	  break;
-	default:
-	  errno = EINVAL;
-	  return -1;
-	}
+        {
+        case SIG_BLOCK:
+          new_blocked_set = blocked_set | *set;
+          break;
+        case SIG_SETMASK:
+          new_blocked_set = *set;
+          break;
+        case SIG_UNBLOCK:
+          new_blocked_set = blocked_set & ~*set;
+          break;
+        default:
+          errno = EINVAL;
+          return -1;
+        }
       to_unblock = blocked_set & ~new_blocked_set;
       to_block = new_blocked_set & ~blocked_set;
 
       if (to_block != 0)
-	{
-	  int sig;
-
-	  for (sig = 0; sig < NSIG; sig++)
-	    if ((to_block >> sig) & 1)
-	      {
-		pending_array[sig] = 0;
-		if ((old_handlers[sig] = signal (sig, blocked_handler)) != SIG_ERR)
-		  blocked_set |= 1U << sig;
-	      }
-	}
+        {
+          int sig;
+
+          for (sig = 0; sig < NSIG; sig++)
+            if ((to_block >> sig) & 1)
+              {
+                pending_array[sig] = 0;
+                if ((old_handlers[sig] = signal (sig, blocked_handler)) != SIG_ERR)
+                  blocked_set |= 1U << sig;
+              }
+        }
 
       if (to_unblock != 0)
-	{
-	  sig_atomic_t received[NSIG];
-	  int sig;
-
-	  for (sig = 0; sig < NSIG; sig++)
-	    if ((to_unblock >> sig) & 1)
-	      {
-		if (signal (sig, old_handlers[sig]) != blocked_handler)
-		  /* The application changed a signal handler while the signal
-		     was blocked, bypassing our rpl_signal replacement.
-		     We don't support this.  */
-		  abort ();
-		received[sig] = pending_array[sig];
-		blocked_set &= ~(1U << sig);
-		pending_array[sig] = 0;
-	      }
-	    else
-	      received[sig] = 0;
-
-	  for (sig = 0; sig < NSIG; sig++)
-	    if (received[sig])
-	      raise (sig);
-	}
+        {
+          sig_atomic_t received[NSIG];
+          int sig;
+
+          for (sig = 0; sig < NSIG; sig++)
+            if ((to_unblock >> sig) & 1)
+              {
+                if (signal (sig, old_handlers[sig]) != blocked_handler)
+                  /* The application changed a signal handler while the signal
+                     was blocked, bypassing our rpl_signal replacement.
+                     We don't support this.  */
+                  abort ();
+                received[sig] = pending_array[sig];
+                blocked_set &= ~(1U << sig);
+                pending_array[sig] = 0;
+              }
+            else
+              received[sig] = 0;
+
+          for (sig = 0; sig < NSIG; sig++)
+            if (received[sig])
+              raise (sig);
+        }
     }
   return 0;
 }
@@ -274,26 +274,26 @@ rpl_signal (int sig, handler_t handler)
     {
       #ifdef SIGABRT_COMPAT
       if (sig == SIGABRT_COMPAT)
-	sig = SIGABRT;
+        sig = SIGABRT;
       #endif
 
       if (blocked_set & (1U << sig))
-	{
-	  /* POSIX states that sigprocmask and signal are both
-	     async-signal-safe.  This is not true of our
-	     implementation - there is a slight data race where an
-	     asynchronous interrupt on signal A can occur after we
-	     install blocked_handler but before we have updated
-	     old_handlers for signal B, such that handler A can see
-	     stale information if it calls signal(B).  Oh well -
-	     signal handlers really shouldn't try to manipulate the
-	     installed handlers of unrelated signals.  */
-	  handler_t result = old_handlers[sig];
-	  old_handlers[sig] = handler;
-	  return result;
-	}
+        {
+          /* POSIX states that sigprocmask and signal are both
+             async-signal-safe.  This is not true of our
+             implementation - there is a slight data race where an
+             asynchronous interrupt on signal A can occur after we
+             install blocked_handler but before we have updated
+             old_handlers for signal B, such that handler A can see
+             stale information if it calls signal(B).  Oh well -
+             signal handlers really shouldn't try to manipulate the
+             installed handlers of unrelated signals.  */
+          handler_t result = old_handlers[sig];
+          old_handlers[sig] = handler;
+          return result;
+        }
       else
-	return signal (sig, handler);
+        return signal (sig, handler);
     }
   else
     {
@@ -312,15 +312,15 @@ rpl_raise (int sig)
     {
     case SIGPIPE:
       if (blocked_set & (1U << sig))
-	pending_array[sig] = 1;
+        pending_array[sig] = 1;
       else
-	{
-	  handler_t handler = SIGPIPE_handler;
-	  if (handler == SIG_DFL)
-	    exit (128 + SIGPIPE);
-	  else if (handler != SIG_IGN)
-	    (*handler) (sig);
-	}
+        {
+          handler_t handler = SIGPIPE_handler;
+          if (handler == SIG_DFL)
+            exit (128 + SIGPIPE);
+          else if (handler != SIG_IGN)
+            (*handler) (sig);
+        }
       return 0;
     default: /* System defined signal */
       return raise (sig);
diff --git a/libmissing/size_max.h b/libmissing/size_max.h
index 419d73a..a2c27d3 100644
--- a/libmissing/size_max.h
+++ b/libmissing/size_max.h
@@ -1,5 +1,5 @@
 /* size_max.h -- declare SIZE_MAX through system headers
-   Copyright (C) 2005-2006 Free Software Foundation, Inc.
+   Copyright (C) 2005-2006, 2009 Free Software Foundation, Inc.
    Written by Simon Josefsson.
 
    This program is free software; you can redistribute it and/or modify
diff --git a/libmissing/sleep.c b/libmissing/sleep.c
index 0fa74b4..bbeadb4 100644
--- a/libmissing/sleep.c
+++ b/libmissing/sleep.c
@@ -1,5 +1,5 @@
 /* Pausing execution of the current thread.
-   Copyright (C) 2007 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009 Free Software Foundation, Inc.
    Written by Bruno Haible <[email protected]>, 2007.
 
    This program is free software: you can redistribute it and/or modify
@@ -20,6 +20,10 @@
 /* Specification.  */
 #include <unistd.h>
 
+#include <limits.h>
+
+#include "verify.h"
+
 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
 
 # define WIN32_LEAN_AND_MEAN  /* avoid including junk */
@@ -39,7 +43,32 @@ sleep (unsigned int seconds)
   return remaining;
 }
 
-#else
+#elif HAVE_SLEEP
+
+# undef sleep
+
+/* Guarantee unlimited sleep and a reasonable return value.  Cygwin
+   1.5.x rejects attempts to sleep more than 49.7 days (2**32
+   milliseconds), but uses uninitialized memory which results in a
+   garbage answer.  */
+unsigned int
+rpl_sleep (unsigned int seconds)
+{
+  /* This requires int larger than 16 bits.  */
+  verify (UINT_MAX / 49 / 24 / 60 / 60);
+  const unsigned int limit = 49 * 24 * 60 * 60;
+  while (limit < seconds)
+    {
+      unsigned int result;
+      seconds -= limit;
+      result = sleep (limit);
+      if (result)
+        return seconds + result;
+    }
+  return sleep (seconds);
+}
+
+#else /* !HAVE_SLEEP */
 
  #error "Please port gnulib sleep.c to your platform, possibly using usleep() or select(), then report this to bug-gnulib."
 
diff --git a/libmissing/snprintf.c b/libmissing/snprintf.c
index c41bff9..f07d66e 100644
--- a/libmissing/snprintf.c
+++ b/libmissing/snprintf.c
@@ -1,5 +1,5 @@
 /* Formatted output to strings.
-   Copyright (C) 2004, 2006-2008 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2006-2009 Free Software Foundation, Inc.
    Written by Simon Josefsson and Paul Eggert.
 
    This program is free software; you can redistribute it and/or modify
@@ -53,11 +53,11 @@ snprintf (char *str, size_t size, const char *format, ...)
   if (output != str)
     {
       if (size)
-	{
-	  size_t pruned_len = (len < size ? len : size - 1);
-	  memcpy (str, output, pruned_len);
-	  str[pruned_len] = '\0';
-	}
+        {
+          size_t pruned_len = (len < size ? len : size - 1);
+          memcpy (str, output, pruned_len);
+          str[pruned_len] = '\0';
+        }
 
       free (output);
     }
diff --git a/libmissing/socket.c b/libmissing/socket.c
index 9585309..e8107bd 100644
--- a/libmissing/socket.c
+++ b/libmissing/socket.c
@@ -1,6 +1,6 @@
 /* socket.c --- wrappers for Windows socket function
 
-   Copyright (C) 2008 Free Software Foundation, Inc.
+   Copyright (C) 2008-2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -26,12 +26,18 @@
 /* Get set_winsock_errno, FD_TO_SOCKET etc. */
 #include "w32sock.h"
 
+#include "sockets.h"
+
 int
 rpl_socket (int domain, int type, int protocol)
 {
+  SOCKET fh;
+
+  gl_sockets_startup (SOCKETS_1_1);
+
   /* We have to use WSASocket() to create non-overlapped IO sockets.
      Overlapped IO sockets cannot be used with read/write.  */
-  SOCKET fh = WSASocket (domain, type, protocol, NULL, 0, 0);
+  fh = WSASocket (domain, type, protocol, NULL, 0, 0);
 
   if (fh == INVALID_SOCKET)
     {
diff --git a/libmissing/sockets.c b/libmissing/sockets.c
new file mode 100644
index 0000000..30605f2
--- /dev/null
+++ b/libmissing/sockets.c
@@ -0,0 +1,118 @@
+/* sockets.c --- wrappers for Windows socket functions
+
+   Copyright (C) 2008-2009 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Simon Josefsson */
+
+#include <config.h>
+
+/* Specification.  */
+#include "sockets.h"
+
+#if WINDOWS_SOCKETS
+
+/* This includes winsock2.h on MinGW. */
+# include <sys/socket.h>
+
+# include "close-hook.h"
+
+/* Get set_winsock_errno, FD_TO_SOCKET etc. */
+# include "w32sock.h"
+
+static int
+close_fd_maybe_socket (int fd, const struct close_hook *remaining_list)
+{
+  SOCKET sock;
+  WSANETWORKEVENTS ev;
+
+  /* Test whether fd refers to a socket.  */
+  sock = FD_TO_SOCKET (fd);
+  ev.lNetworkEvents = 0xDEADBEEF;
+  WSAEnumNetworkEvents (sock, NULL, &ev);
+  if (ev.lNetworkEvents != 0xDEADBEEF)
+    {
+      /* fd refers to a socket.  */
+      /* FIXME: other applications, like squid, use an undocumented
+         _free_osfhnd free function.  But this is not enough: The 'osfile'
+         flags for fd also needs to be cleared, but it is hard to access it.
+         Instead, here we just close twice the file descriptor.  */
+      if (closesocket (sock))
+        {
+          set_winsock_errno ();
+          return -1;
+        }
+      else
+        {
+          /* This call frees the file descriptor and does a
+             CloseHandle ((HANDLE) _get_osfhandle (fd)), which fails.  */
+          _close (fd);
+          return 0;
+        }
+    }
+  else
+    /* Some other type of file descriptor.  */
+    return execute_close_hooks (fd, remaining_list);
+}
+
+static struct close_hook close_sockets_hook;
+
+static int initialized_sockets_version /* = 0 */;
+
+#endif /* WINDOWS_SOCKETS */
+
+int
+gl_sockets_startup (int version _GL_UNUSED)
+{
+#if WINDOWS_SOCKETS
+  if (version > initialized_sockets_version)
+    {
+      WSADATA data;
+      int err;
+
+      err = WSAStartup (version, &data);
+      if (err != 0)
+        return 1;
+
+      if (data.wVersion < version)
+        return 2;
+
+      if (initialized_sockets_version == 0)
+        register_close_hook (close_fd_maybe_socket, &close_sockets_hook);
+
+      initialized_sockets_version = version;
+    }
+#endif
+
+  return 0;
+}
+
+int
+gl_sockets_cleanup (void)
+{
+#if WINDOWS_SOCKETS
+  int err;
+
+  initialized_sockets_version = 0;
+
+  unregister_close_hook (&close_sockets_hook);
+
+  err = WSACleanup ();
+  if (err != 0)
+    return 1;
+#endif
+
+  return 0;
+}
diff --git a/libmissing/sockets.h b/libmissing/sockets.h
new file mode 100644
index 0000000..ed2de22
--- /dev/null
+++ b/libmissing/sockets.h
@@ -0,0 +1,51 @@
+/* sockets.h - wrappers for Windows socket functions
+
+   Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Simon Josefsson */
+
+#ifndef SOCKETS_H
+# define SOCKETS_H 1
+
+#define SOCKETS_1_0 0x100  /* don't use - does not work on Windows XP */
+#define SOCKETS_1_1 0x101
+#define SOCKETS_2_0 0x200  /* don't use - does not work on Windows XP */
+#define SOCKETS_2_1 0x201
+#define SOCKETS_2_2 0x202
+
+int gl_sockets_startup (int version);
+int gl_sockets_cleanup (void);
+
+/* This function is useful it you create a socket using gnulib's
+   Winsock wrappers but needs to pass on the socket handle to some
+   other library that only accepts sockets. */
+#if WINDOWS_SOCKETS
+
+#include <sys/socket.h>
+
+static inline SOCKET
+gl_fd_to_handle (int fd)
+{
+  return _get_osfhandle (fd);
+}
+
+#else
+
+#define gl_fd_to_handle(x) (x)
+
+#endif /* WINDOWS_SOCKETS */
+
+#endif /* SOCKETS_H */
diff --git a/libmissing/stdbool.in.h b/libmissing/stdbool.in.h
index 3390484..f4059af 100644
--- a/libmissing/stdbool.in.h
+++ b/libmissing/stdbool.in.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2003, 2006-2008 Free Software Foundation, Inc.
+/* Copyright (C) 2001-2003, 2006-2009 Free Software Foundation, Inc.
    Written by Bruno Haible <[email protected]>, 2001.
 
    This program is free software; you can redistribute it and/or modify
diff --git a/libmissing/stddef.in.h b/libmissing/stddef.in.h
new file mode 100644
index 0000000..dacc83d
--- /dev/null
+++ b/libmissing/stddef.in.h
@@ -0,0 +1,86 @@
+/* A substitute for POSIX 2008 <stddef.h>, for platforms that have issues.
+
+   Copyright (C) 2009 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+/* Written by Eric Blake.  */
+
+/*
+ * POSIX 2008 <stddef.h> for platforms that have issues.
+ * <http://www.opengroup.org/susv3xbd/stddef.h.html>
+ */
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+
+#if defined __need_wchar_t || defined __need_size_t  \
+  || defined __need_ptrdiff_t || defined __need_NULL \
+  || defined __need_wint_t
+/* Special invocation convention inside gcc header files.  In
+   particular, gcc provides a version of <stddef.h> that blindly
+   redefines NULL even when __need_wint_t was defined, even though
+   wint_t is not normally provided by <stddef.h>.  Hence, we must
+   remember if special invocation has ever been used to obtain wint_t,
+   in which case we need to clean up NULL yet again.  */
+
+# if !(defined _GL_STDDEF_H && defined _GL_STDDEF_WINT_T)
+#  ifdef __need_wint_t
+#   undef _GL_STDDEF_H
+#   define _GL_STDDEF_WINT_T
+#  endif
+#  @INCLUDE_NEXT@ @NEXT_STDDEF_H@
+# endif
+
+#else
+/* Normal invocation convention.  */
+
+# ifndef _GL_STDDEF_H
+
+/* The include_next requires a split double-inclusion guard.  */
+
+#  @INCLUDE_NEXT@ @NEXT_STDDEF_H@
+
+#  ifndef _GL_STDDEF_H
+#   define _GL_STDDEF_H
+
+/* On NetBSD 5.0, the definition of NULL lacks proper parentheses.  */
+#if @REPLACE_NULL@
+# undef NULL
+# ifdef __cplusplus
+   /* ISO C++ says that the macro NULL must expand to an integer constant
+      expression, hence '((void *) 0)' is not allowed in C++.  */
+#  if __GNUG__ >= 3
+    /* GNU C++ has a __null macro that behaves like an integer ('int' or
+       'long') but has the same size as a pointer.  Use that, to avoid
+       warnings.  */
+#   define NULL __null
+#  else
+#   define NULL 0L
+#  endif
+# else
+#  define NULL ((void *) 0)
+# endif
+#endif
+
+/* Some platforms lack wchar_t.  */
+#if !@HAVE_WCHAR_T@
+# define wchar_t int
+#endif
+
+#  endif /* _GL_STDDEF_H */
+# endif /* _GL_STDDEF_H */
+#endif /* __need_XXX */
diff --git a/libmissing/stdint.in.h b/libmissing/stdint.in.h
index 11a2117..36e6469 100644
--- a/libmissing/stdint.in.h
+++ b/libmissing/stdint.in.h
@@ -102,8 +102,8 @@
   ((signed) \
    ? ~ _STDINT_MIN (signed, bits, zero) \
    : /* The expression for the unsigned case.  The subtraction of (signed) \
-	is a nop in the unsigned case and avoids "signed integer overflow" \
-	warnings in the signed case.  */ \
+        is a nop in the unsigned case and avoids "signed integer overflow" \
+        warnings in the signed case.  */ \
      ((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1)
 
 /* 7.18.1.1. Exact-width integer types */
@@ -454,10 +454,10 @@ typedef int _verify_intmax_size[2 * (sizeof (intmax_t) == sizeof (uintmax_t)) -
 #undef SIG_ATOMIC_MAX
 #define SIG_ATOMIC_MIN  \
    _STDINT_MIN (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \
-		0@SIG_ATOMIC_T_SUFFIX@)
+                0@SIG_ATOMIC_T_SUFFIX@)
 #define SIG_ATOMIC_MAX  \
    _STDINT_MAX (@HAVE_SIGNED_SIG_ATOMIC_T@, @BITSIZEOF_SIG_ATOMIC_T@, \
-		0@SIG_ATOMIC_T_SUFFIX@)
+                0@SIG_ATOMIC_T_SUFFIX@)
 
 
 /* size_t limit */
diff --git a/libmissing/stdio-write.c b/libmissing/stdio-write.c
index 8f275ff..7b26c78 100644
--- a/libmissing/stdio-write.c
+++ b/libmissing/stdio-write.c
@@ -1,5 +1,5 @@
 /* POSIX compatible FILE stream write function.
-   Copyright (C) 2008 Free Software Foundation, Inc.
+   Copyright (C) 2008-2009 Free Software Foundation, Inc.
    Written by Bruno Haible <[email protected]>, 2008.
 
    This program is free software: you can redistribute it and/or modify
@@ -39,30 +39,31 @@
 #  include <windows.h>
 
 #  define CALL_WITH_SIGPIPE_EMULATION(RETTYPE, EXPRESSION, FAILED) \
-  if (ferror (stream))							      \
-    return (EXPRESSION);						      \
-  else									      \
-    {									      \
-      RETTYPE ret;							      \
-      SetLastError (0);							      \
-      ret = (EXPRESSION);						      \
+  if (ferror (stream))                                                        \
+    return (EXPRESSION);                                                      \
+  else                                                                        \
+    {                                                                         \
+      RETTYPE ret;                                                            \
+      SetLastError (0);                                                       \
+      ret = (EXPRESSION);                                                     \
       if (FAILED && GetLastError () == ERROR_NO_DATA && ferror (stream))      \
-	{								      \
-	  int fd = fileno (stream);					      \
-	  if (fd >= 0							      \
-	      && GetFileType ((HANDLE) _get_osfhandle (fd)) == FILE_TYPE_PIPE)\
-	    {								      \
-	      /* Try to raise signal SIGPIPE.  */			      \
-	      raise (SIGPIPE);						      \
-	      /* If it is currently blocked or ignored, change errno from     \
-		 EINVAL to EPIPE.  */					      \
-	      errno = EPIPE;						      \
-	    }								      \
-	}								      \
-      return ret;							      \
+        {                                                                     \
+          int fd = fileno (stream);                                           \
+          if (fd >= 0                                                         \
+              && GetFileType ((HANDLE) _get_osfhandle (fd)) == FILE_TYPE_PIPE)\
+            {                                                                 \
+              /* Try to raise signal SIGPIPE.  */                             \
+              raise (SIGPIPE);                                                \
+              /* If it is currently blocked or ignored, change errno from     \
+                 EINVAL to EPIPE.  */                                         \
+              errno = EPIPE;                                                  \
+            }                                                                 \
+        }                                                                     \
+      return ret;                                                             \
     }
 
 #  if !REPLACE_PRINTF_POSIX /* avoid collision with printf.c */
+#   if !DEPENDS_ON_LIBINTL /* avoid collision with intl/printf.c */
 int
 printf (const char *format, ...)
 {
@@ -75,6 +76,7 @@ printf (const char *format, ...)
 
   return retval;
 }
+#   endif
 #  endif
 
 #  if !REPLACE_FPRINTF_POSIX /* avoid collision with fprintf.c */
@@ -92,7 +94,7 @@ fprintf (FILE *stream, const char *format, ...)
 }
 #  endif
 
-#  if !REPLACE_VFPRINTF_POSIX /* avoid collision with vprintf.c */
+#  if !REPLACE_VPRINTF_POSIX /* avoid collision with vprintf.c */
 int
 vprintf (const char *format, va_list args)
 {
@@ -100,7 +102,7 @@ vprintf (const char *format, va_list args)
 }
 #  endif
 
-#  if !REPLACE_VPRINTF_POSIX /* avoid collision with vfprintf.c */
+#  if !REPLACE_VFPRINTF_POSIX /* avoid collision with vfprintf.c */
 int
 vfprintf (FILE *stream, const char *format, va_list args)
 #undef vfprintf
diff --git a/libmissing/stdio.in.h b/libmissing/stdio.in.h
index ae681fc..29629fd 100644
--- a/libmissing/stdio.in.h
+++ b/libmissing/stdio.in.h
@@ -39,10 +39,11 @@
 #include <stdarg.h>
 #include <stddef.h>
 
-#if (@GNULIB_FSEEKO@ && @REPLACE_FSEEKO@) \
-  || (@GNULIB_FTELLO@ && @REPLACE_FTELLO@) \
-  || (@GNULIB_GETDELIM@ && !@HAVE_DECL_GETDELIM@) \
-  || (@GNULIB_GETLINE@ && (!@HAVE_DECL_GETLINE@ || @REPLACE_GETLINE@))
+#if ((@GNULIB_FSEEKO@ && @REPLACE_FSEEKO@) \
+     || (@GNULIB_FTELLO@ && @REPLACE_FTELLO@) \
+     || (@GNULIB_GETDELIM@ && !@HAVE_DECL_GETDELIM@) \
+     || (@GNULIB_GETLINE@ && (!@HAVE_DECL_GETLINE@ || @REPLACE_GETLINE@)) \
+     || defined GNULIB_POSIXCHECK)
 /* Get off_t and ssize_t.  */
 # include <sys/types.h>
 #endif
@@ -63,233 +64,70 @@
 
 /* The definition of GL_LINK_WARNING is copied here.  */
 
+/* The definition of _GL_ARG_NONNULL is copied here.  */
+
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-
-#if @GNULIB_FPRINTF_POSIX@
-# if @REPLACE_FPRINTF@
-#  define fprintf rpl_fprintf
-extern int fprintf (FILE *fp, const char *format, ...)
-       __attribute__ ((__format__ (__printf__, 2, 3)));
-# endif
-#elif @GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
-# define fprintf rpl_fprintf
-extern int fprintf (FILE *fp, const char *format, ...)
-       __attribute__ ((__format__ (__printf__, 2, 3)));
-#elif defined GNULIB_POSIXCHECK
-# undef fprintf
-# define fprintf \
-    (GL_LINK_WARNING ("fprintf is not always POSIX compliant - " \
-                      "use gnulib module fprintf-posix for portable " \
-                      "POSIX compliance"), \
-     fprintf)
-#endif
-
-#if @GNULIB_VFPRINTF_POSIX@
-# if @REPLACE_VFPRINTF@
-#  define vfprintf rpl_vfprintf
-extern int vfprintf (FILE *fp, const char *format, va_list args)
-       __attribute__ ((__format__ (__printf__, 2, 0)));
-# endif
-#elif @GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
-# define vfprintf rpl_vfprintf
-extern int vfprintf (FILE *fp, const char *format, va_list args)
-       __attribute__ ((__format__ (__printf__, 2, 0)));
-#elif defined GNULIB_POSIXCHECK
-# undef vfprintf
-# define vfprintf(s,f,a) \
-    (GL_LINK_WARNING ("vfprintf is not always POSIX compliant - " \
-                      "use gnulib module vfprintf-posix for portable " \
-                      "POSIX compliance"), \
-     vfprintf (s, f, a))
-#endif
-
-#if @GNULIB_PRINTF_POSIX@
-# if @REPLACE_PRINTF@
-/* Don't break __attribute__((format(printf,M,N))).  */
-#  define printf __printf__
-extern int printf (const char *format, ...)
-       __attribute__ ((__format__ (__printf__, 1, 2)));
-# endif
-#elif @GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
-/* Don't break __attribute__((format(printf,M,N))).  */
-# define printf __printf__
-extern int printf (const char *format, ...)
-       __attribute__ ((__format__ (__printf__, 1, 2)));
-#elif defined GNULIB_POSIXCHECK
-# undef printf
-# define printf \
-    (GL_LINK_WARNING ("printf is not always POSIX compliant - " \
-                      "use gnulib module printf-posix for portable " \
-                      "POSIX compliance"), \
-     printf)
-/* Don't break __attribute__((format(printf,M,N))).  */
-# define format(kind,m,n) format (__##kind##__, m, n)
-# define __format__(kind,m,n) __format__ (__##kind##__, m, n)
-# define ____printf____ __printf__
-# define ____scanf____ __scanf__
-# define ____strftime____ __strftime__
-# define ____strfmon____ __strfmon__
-#endif
-
-#if @GNULIB_VPRINTF_POSIX@
-# if @REPLACE_VPRINTF@
-#  define vprintf rpl_vprintf
-extern int vprintf (const char *format, va_list args)
-       __attribute__ ((__format__ (__printf__, 1, 0)));
-# endif
-#elif @GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
-# define vprintf rpl_vprintf
-extern int vprintf (const char *format, va_list args)
-       __attribute__ ((__format__ (__printf__, 1, 0)));
-#elif defined GNULIB_POSIXCHECK
-# undef vprintf
-# define vprintf(f,a) \
-    (GL_LINK_WARNING ("vprintf is not always POSIX compliant - " \
-                      "use gnulib module vprintf-posix for portable " \
-                      "POSIX compliance"), \
-     vprintf (f, a))
-#endif
-
-#if @GNULIB_SNPRINTF@
-# if @REPLACE_SNPRINTF@
-#  define snprintf rpl_snprintf
-# endif
-# if @REPLACE_SNPRINTF@ || !@HAVE_DECL_SNPRINTF@
-extern int snprintf (char *str, size_t size, const char *format, ...)
-       __attribute__ ((__format__ (__printf__, 3, 4)));
-# endif
-#elif defined GNULIB_POSIXCHECK
-# undef snprintf
-# define snprintf \
-    (GL_LINK_WARNING ("snprintf is unportable - " \
-                      "use gnulib module snprintf for portability"), \
-     snprintf)
-#endif
-
-#if @GNULIB_VSNPRINTF@
-# if @REPLACE_VSNPRINTF@
-#  define vsnprintf rpl_vsnprintf
-# endif
-# if @REPLACE_VSNPRINTF@ || !@HAVE_DECL_VSNPRINTF@
-extern int vsnprintf (char *str, size_t size, const char *format, va_list args)
-       __attribute__ ((__format__ (__printf__, 3, 0)));
-# endif
-#elif defined GNULIB_POSIXCHECK
-# undef vsnprintf
-# define vsnprintf(b,s,f,a) \
-    (GL_LINK_WARNING ("vsnprintf is unportable - " \
-                      "use gnulib module vsnprintf for portability"), \
-     vsnprintf (b, s, f, a))
-#endif
-
-#if @GNULIB_SPRINTF_POSIX@
-# if @REPLACE_SPRINTF@
-#  define sprintf rpl_sprintf
-extern int sprintf (char *str, const char *format, ...)
-       __attribute__ ((__format__ (__printf__, 2, 3)));
-# endif
-#elif defined GNULIB_POSIXCHECK
-# undef sprintf
-# define sprintf \
-    (GL_LINK_WARNING ("sprintf is not always POSIX compliant - " \
-                      "use gnulib module sprintf-posix for portable " \
-                      "POSIX compliance"), \
-     sprintf)
-#endif
-
-#if @GNULIB_VSPRINTF_POSIX@
-# if @REPLACE_VSPRINTF@
-#  define vsprintf rpl_vsprintf
-extern int vsprintf (char *str, const char *format, va_list args)
-       __attribute__ ((__format__ (__printf__, 2, 0)));
-# endif
-#elif defined GNULIB_POSIXCHECK
-# undef vsprintf
-# define vsprintf(b,f,a) \
-    (GL_LINK_WARNING ("vsprintf is not always POSIX compliant - " \
-                      "use gnulib module vsprintf-posix for portable " \
-                      "POSIX compliance"), \
-     vsprintf (b, f, a))
-#endif
-
 #if @GNULIB_DPRINTF@
 # if @REPLACE_DPRINTF@
 #  define dprintf rpl_dprintf
 # endif
 # if @REPLACE_DPRINTF@ || !@HAVE_DPRINTF@
 extern int dprintf (int fd, const char *format, ...)
-       __attribute__ ((__format__ (__printf__, 2, 3)));
+       __attribute__ ((__format__ (__printf__, 2, 3))) _GL_ARG_NONNULL ((2));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef dprintf
-# define dprintf(d,f,a) \
+# define dprintf \
     (GL_LINK_WARNING ("dprintf is unportable - " \
                       "use gnulib module dprintf for portability"), \
-     dprintf (d, f, a))
+     dprintf)
 #endif
 
-#if @GNULIB_VDPRINTF@
-# if @REPLACE_VDPRINTF@
-#  define vdprintf rpl_vdprintf
-# endif
-# if @REPLACE_VDPRINTF@ || !@HAVE_VDPRINTF@
-extern int vdprintf (int fd, const char *format, va_list args)
-       __attribute__ ((__format__ (__printf__, 2, 0)));
+#if @GNULIB_FCLOSE@
+# if @REPLACE_FCLOSE@
+#  define fclose rpl_fclose
+  /* Close STREAM and its underlying file descriptor.  */
+extern int fclose (FILE *stream) _GL_ARG_NONNULL ((1));
 # endif
 #elif defined GNULIB_POSIXCHECK
-# undef vdprintf
-# define vdprintf(d,f,a) \
-    (GL_LINK_WARNING ("vdprintf is unportable - " \
-                      "use gnulib module vdprintf for portability"), \
-     vdprintf (d, f, a))
-#endif
-
-#if @GNULIB_VASPRINTF@
-# if @REPLACE_VASPRINTF@
-#  define asprintf rpl_asprintf
-#  define vasprintf rpl_vasprintf
-# endif
-# if @REPLACE_VASPRINTF@ || !@HAVE_VASPRINTF@
-  /* Write formatted output to a string dynamically allocated with malloc().
-     If the memory allocation succeeds, store the address of the string in
-     *RESULT and return the number of resulting bytes, excluding the trailing
-     NUL.  Upon memory allocation error, or some other error, return -1.  */
-  extern int asprintf (char **result, const char *format, ...)
-    __attribute__ ((__format__ (__printf__, 2, 3)));
-  extern int vasprintf (char **result, const char *format, va_list args)
-    __attribute__ ((__format__ (__printf__, 2, 0)));
-# endif
+# undef fclose
+# define fclose(f) \
+   (GL_LINK_WARNING ("fclose is not always POSIX compliant - " \
+                     "use gnulib module fclose for portable " \
+                     "POSIX compliance"), \
+    fclose (f))
 #endif
 
-#if @GNULIB_OBSTACK_PRINTF@
-# if @REPLACE_OBSTACK_PRINTF@
-#  define obstack_printf rpl_osbtack_printf
-#  define obstack_vprintf rpl_obstack_vprintf
-# endif
-# if @REPLACE_OBSTACK_PRINTF@ || !@HAVE_DECL_OBSTACK_PRINTF@
-  struct obstack;
-  /* Grow an obstack with formatted output.  Return the number of
-     bytes added to OBS.  No trailing nul byte is added, and the
-     object should be closed with obstack_finish before use.  Upon
-     memory allocation error, call obstack_alloc_failed_handler.  Upon
-     other error, return -1.  */
-  extern int obstack_printf (struct obstack *obs, const char *format, ...)
-    __attribute__ ((__format__ (__printf__, 2, 3)));
-  extern int obstack_vprintf (struct obstack *obs, const char *format,
-			      va_list args)
-    __attribute__ ((__format__ (__printf__, 2, 0)));
+#if @GNULIB_FFLUSH@
+# if @REPLACE_FFLUSH@
+#  define fflush rpl_fflush
+  /* Flush all pending data on STREAM according to POSIX rules.  Both
+     output and seekable input streams are supported.
+     Note! LOSS OF DATA can occur if fflush is applied on an input stream
+     that is _not_seekable_ or on an update stream that is _not_seekable_
+     and in which the most recent operation was input.  Seekability can
+     be tested with lseek(fileno(fp),0,SEEK_CUR).  */
+  extern int fflush (FILE *gl_stream);
 # endif
+#elif defined GNULIB_POSIXCHECK
+# undef fflush
+# define fflush(f) \
+   (GL_LINK_WARNING ("fflush is not always POSIX compliant - " \
+                     "use gnulib module fflush for portable " \
+                     "POSIX compliance"), \
+    fflush (f))
 #endif
 
 #if @GNULIB_FOPEN@
 # if @REPLACE_FOPEN@
 #  undef fopen
 #  define fopen rpl_fopen
-extern FILE * fopen (const char *filename, const char *mode);
+extern FILE * fopen (const char *filename, const char *mode)
+     _GL_ARG_NONNULL ((1, 2));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef fopen
@@ -299,11 +137,66 @@ extern FILE * fopen (const char *filename, const char *mode);
     fopen (f, m))
 #endif
 
+#if @GNULIB_FPRINTF_POSIX@
+# if @REPLACE_FPRINTF@
+#  define fprintf rpl_fprintf
+extern int fprintf (FILE *fp, const char *format, ...)
+       __attribute__ ((__format__ (__printf__, 2, 3)))
+       _GL_ARG_NONNULL ((1, 2));
+# endif
+#elif @GNULIB_FPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
+# define fprintf rpl_fprintf
+extern int fprintf (FILE *fp, const char *format, ...)
+       __attribute__ ((__format__ (__printf__, 2, 3)))
+       _GL_ARG_NONNULL ((1, 2));
+#elif defined GNULIB_POSIXCHECK
+# undef fprintf
+# define fprintf \
+    (GL_LINK_WARNING ("fprintf is not always POSIX compliant - " \
+                      "use gnulib module fprintf-posix for portable " \
+                      "POSIX compliance"), \
+     fprintf)
+#endif
+
+#if @GNULIB_FPURGE@
+# if @REPLACE_FPURGE@
+#  define fpurge rpl_fpurge
+# endif
+# if @REPLACE_FPURGE@ || !@HAVE_DECL_FPURGE@
+  /* Discard all pending buffered I/O data on STREAM.
+     STREAM must not be wide-character oriented.
+     When discarding pending output, the file position is set back to where it
+     was before the write calls.  When discarding pending input, the file
+     position is advanced to match the end of the previously read input.
+     Return 0 if successful.  Upon error, return -1 and set errno.  */
+  extern int fpurge (FILE *gl_stream) _GL_ARG_NONNULL ((1));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef fpurge
+# define fpurge(f) \
+   (GL_LINK_WARNING ("fpurge is not always present - " \
+                     "use gnulib module fpurge for portability"), \
+    fpurge (f))
+#endif
+
+#if @GNULIB_FPUTC@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
+# undef fputc
+# define fputc rpl_fputc
+extern int fputc (int c, FILE *stream) _GL_ARG_NONNULL ((2));
+#endif
+
+#if @GNULIB_FPUTS@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
+# undef fputs
+# define fputs rpl_fputs
+extern int fputs (const char *string, FILE *stream) _GL_ARG_NONNULL ((1, 2));
+#endif
+
 #if @GNULIB_FREOPEN@
 # if @REPLACE_FREOPEN@
 #  undef freopen
 #  define freopen rpl_freopen
-extern FILE * freopen (const char *filename, const char *mode, FILE *stream);
+extern FILE * freopen (const char *filename, const char *mode, FILE *stream)
+     _GL_ARG_NONNULL ((2, 3));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef freopen
@@ -313,24 +206,8 @@ extern FILE * freopen (const char *filename, const char *mode, FILE *stream);
     freopen (f, m, s))
 #endif
 
-#if @GNULIB_FSEEKO@
-# if @REPLACE_FSEEKO@
-/* Provide fseek, fseeko functions that are aware of a preceding
-   fflush(), and which detect pipes.  */
-#  define fseeko rpl_fseeko
-extern int fseeko (FILE *fp, off_t offset, int whence);
-#  define fseek(fp, offset, whence) fseeko (fp, (off_t)(offset), whence)
-# endif
-#elif defined GNULIB_POSIXCHECK
-# undef fseeko
-# define fseeko(f,o,w) \
-   (GL_LINK_WARNING ("fseeko is unportable - " \
-                     "use gnulib module fseeko for portability"), \
-    fseeko (f, o, w))
-#endif
-
 #if @GNULIB_FSEEK@ && @REPLACE_FSEEK@
-extern int rpl_fseek (FILE *fp, long offset, int whence);
+extern int rpl_fseek (FILE *fp, long offset, int whence) _GL_ARG_NONNULL ((1));
 # undef fseek
 # if defined GNULIB_POSIXCHECK
 #  define fseek(f,o,w) \
@@ -351,22 +228,31 @@ extern int rpl_fseek (FILE *fp, long offset, int whence);
 # endif
 #endif
 
-#if @GNULIB_FTELLO@
-# if @REPLACE_FTELLO@
-#  define ftello rpl_ftello
-extern off_t ftello (FILE *fp);
-#  define ftell(fp) ftello (fp)
+#if @GNULIB_FSEEKO@
+# if @REPLACE_FSEEKO@
+/* Provide fseek, fseeko functions that are aware of a preceding
+   fflush(), and which detect pipes.  */
+#  define fseeko rpl_fseeko
+extern int fseeko (FILE *fp, off_t offset, int whence) _GL_ARG_NONNULL ((1));
+#  if !@GNULIB_FSEEK@
+#   undef fseek
+#   define fseek(f,o,w) \
+     (GL_LINK_WARNING ("fseek cannot handle files larger than 4 GB " \
+                       "on 32-bit platforms - " \
+                       "use fseeko function for handling of large files"), \
+      fseeko (f, o, w))
+#  endif
 # endif
 #elif defined GNULIB_POSIXCHECK
-# undef ftello
-# define ftello(f) \
-   (GL_LINK_WARNING ("ftello is unportable - " \
-                     "use gnulib module ftello for portability"), \
-    ftello (f))
+# undef fseeko
+# define fseeko(f,o,w) \
+   (GL_LINK_WARNING ("fseeko is unportable - " \
+                     "use gnulib module fseeko for portability"), \
+    fseeko (f, o, w))
 #endif
 
 #if @GNULIB_FTELL@ && @REPLACE_FTELL@
-extern long rpl_ftell (FILE *fp);
+extern long rpl_ftell (FILE *fp) _GL_ARG_NONNULL ((1));
 # undef ftell
 # if GNULIB_POSIXCHECK
 #  define ftell(f) \
@@ -387,93 +273,32 @@ extern long rpl_ftell (FILE *fp);
 # endif
 #endif
 
-#if @GNULIB_FFLUSH@
-# if @REPLACE_FFLUSH@
-#  define fflush rpl_fflush
-  /* Flush all pending data on STREAM according to POSIX rules.  Both
-     output and seekable input streams are supported.
-     Note! LOSS OF DATA can occur if fflush is applied on an input stream
-     that is _not_seekable_ or on an update stream that is _not_seekable_
-     and in which the most recent operation was input.  Seekability can
-     be tested with lseek(fileno(fp),0,SEEK_CUR).  */
-  extern int fflush (FILE *gl_stream);
-# endif
-#elif defined GNULIB_POSIXCHECK
-# undef fflush
-# define fflush(f) \
-   (GL_LINK_WARNING ("fflush is not always POSIX compliant - " \
-                     "use gnulib module fflush for portable " \
-                     "POSIX compliance"), \
-    fflush (f))
-#endif
-
-#if @GNULIB_FPURGE@
-# if @REPLACE_FPURGE@
-#  define fpurge rpl_fpurge
-# endif
-# if @REPLACE_FPURGE@ || !@HAVE_DECL_FPURGE@
-  /* Discard all pending buffered I/O data on STREAM.
-     STREAM must not be wide-character oriented.
-     Return 0 if successful.  Upon error, return -1 and set errno.  */
-  extern int fpurge (FILE *gl_stream);
-# endif
-#elif defined GNULIB_POSIXCHECK
-# undef fpurge
-# define fpurge(f) \
-   (GL_LINK_WARNING ("fpurge is not always present - " \
-                     "use gnulib module fpurge for portability"), \
-    fpurge (f))
-#endif
-
-#if @GNULIB_FCLOSE@
-# if @REPLACE_FCLOSE@
-#  define fclose rpl_fclose
-  /* Close STREAM and its underlying file descriptor.  */
-extern int fclose (FILE *stream);
+#if @GNULIB_FTELLO@
+# if @REPLACE_FTELLO@
+#  define ftello rpl_ftello
+extern off_t ftello (FILE *fp) _GL_ARG_NONNULL ((1));
+#  if !@GNULIB_FTELL@
+#   undef ftell
+#   define ftell(f) \
+     (GL_LINK_WARNING ("ftell cannot handle files larger than 4 GB " \
+                       "on 32-bit platforms - " \
+                       "use ftello function for handling of large files"), \
+      ftello (f))
+#  endif
 # endif
 #elif defined GNULIB_POSIXCHECK
-# undef fclose
-# define fclose(f) \
-   (GL_LINK_WARNING ("fclose is not always POSIX compliant - " \
-                     "use gnulib module fclose for portable " \
-                     "POSIX compliance"), \
-    fclose (f))
-#endif
-
-#if @GNULIB_FPUTC@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
-# undef fputc
-# define fputc rpl_fputc
-extern int fputc (int c, FILE *stream);
-#endif
-
-#if @GNULIB_PUTC@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
-# undef putc
-# define putc rpl_fputc
-extern int putc (int c, FILE *stream);
-#endif
-
-#if @GNULIB_PUTCHAR@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
-# undef putchar
-# define putchar rpl_putchar
-extern int putchar (int c);
-#endif
-
-#if @GNULIB_FPUTS@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
-# undef fputs
-# define fputs rpl_fputs
-extern int fputs (const char *string, FILE *stream);
-#endif
-
-#if @GNULIB_PUTS@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
-# undef puts
-# define puts rpl_puts
-extern int puts (const char *string);
+# undef ftello
+# define ftello(f) \
+   (GL_LINK_WARNING ("ftello is unportable - " \
+                     "use gnulib module ftello for portability"), \
+    ftello (f))
 #endif
 
 #if @GNULIB_FWRITE@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
 # undef fwrite
 # define fwrite rpl_fwrite
-extern size_t fwrite (const void *ptr, size_t s, size_t n, FILE *stream);
+extern size_t fwrite (const void *ptr, size_t s, size_t n, FILE *stream)
+     _GL_ARG_NONNULL ((1, 4));
 #endif
 
 #if @GNULIB_GETDELIM@
@@ -485,13 +310,14 @@ extern size_t fwrite (const void *ptr, size_t s, size_t n, FILE *stream);
    Return the number of bytes read and stored at *LINEPTR (not including the
    NUL terminator), or -1 on error or EOF.  */
 extern ssize_t getdelim (char **lineptr, size_t *linesize, int delimiter,
-			 FILE *stream);
+                         FILE *stream)
+     _GL_ARG_NONNULL ((1, 2, 4));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef getdelim
-# define getdelim(l, s, d, f)					    \
-  (GL_LINK_WARNING ("getdelim is unportable - "			    \
-		    "use gnulib module getdelim for portability"),  \
+# define getdelim(l, s, d, f)                                       \
+  (GL_LINK_WARNING ("getdelim is unportable - "                     \
+                    "use gnulib module getdelim for portability"),  \
    getdelim (l, s, d, f))
 #endif
 
@@ -507,16 +333,37 @@ extern ssize_t getdelim (char **lineptr, size_t *linesize, int delimiter,
    bytes of space.  It is realloc'd as necessary.
    Return the number of bytes read and stored at *LINEPTR (not including the
    NUL terminator), or -1 on error or EOF.  */
-extern ssize_t getline (char **lineptr, size_t *linesize, FILE *stream);
+extern ssize_t getline (char **lineptr, size_t *linesize, FILE *stream)
+     _GL_ARG_NONNULL ((1, 2, 3));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef getline
-# define getline(l, s, f)						\
-  (GL_LINK_WARNING ("getline is unportable - "				\
-		    "use gnulib module getline for portability"),	\
+# define getline(l, s, f)                                               \
+  (GL_LINK_WARNING ("getline is unportable - "                          \
+                    "use gnulib module getline for portability"),       \
    getline (l, s, f))
 #endif
 
+#if @GNULIB_OBSTACK_PRINTF@
+# if @REPLACE_OBSTACK_PRINTF@
+#  define obstack_printf rpl_osbtack_printf
+#  define obstack_vprintf rpl_obstack_vprintf
+# endif
+# if @REPLACE_OBSTACK_PRINTF@ || !@HAVE_DECL_OBSTACK_PRINTF@
+  struct obstack;
+  /* Grow an obstack with formatted output.  Return the number of
+     bytes added to OBS.  No trailing nul byte is added, and the
+     object should be closed with obstack_finish before use.  Upon
+     memory allocation error, call obstack_alloc_failed_handler.  Upon
+     other error, return -1.  */
+  extern int obstack_printf (struct obstack *obs, const char *format, ...)
+    __attribute__ ((__format__ (__printf__, 2, 3))) _GL_ARG_NONNULL ((1, 2));
+  extern int obstack_vprintf (struct obstack *obs, const char *format,
+                              va_list args)
+    __attribute__ ((__format__ (__printf__, 2, 0))) _GL_ARG_NONNULL ((1, 2));
+# endif
+#endif
+
 #if @GNULIB_PERROR@
 # if @REPLACE_PERROR@
 #  define perror rpl_perror
@@ -533,6 +380,252 @@ extern void perror (const char *string);
      perror (s))
 #endif
 
+#if @GNULIB_POPEN@
+# if @REPLACE_POPEN@
+#  undef popen
+#  define popen rpl_popen
+extern FILE *popen (const char *cmd, const char *mode)
+     _GL_ARG_NONNULL ((1, 2));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef popen
+# define popen(c,m) \
+   (GL_LINK_WARNING ("popen is buggy on some platforms - " \
+                     "use gnulib module popen or pipe for more portability"), \
+    popen (c, m))
+#endif
+
+#if @GNULIB_PRINTF_POSIX@
+# if @REPLACE_PRINTF@
+/* Don't break __attribute__((format(printf,M,N))).  */
+#  define printf __printf__
+extern int printf (const char *format, ...)
+       __attribute__ ((__format__ (__printf__, 1, 2))) _GL_ARG_NONNULL ((1));
+# endif
+#elif @GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
+/* Don't break __attribute__((format(printf,M,N))).  */
+# define printf __printf__
+extern int printf (const char *format, ...)
+       __attribute__ ((__format__ (__printf__, 1, 2))) _GL_ARG_NONNULL ((1));
+#elif defined GNULIB_POSIXCHECK
+# undef printf
+# define printf \
+    (GL_LINK_WARNING ("printf is not always POSIX compliant - " \
+                      "use gnulib module printf-posix for portable " \
+                      "POSIX compliance"), \
+     printf)
+/* Don't break __attribute__((format(printf,M,N))).  */
+# define format(kind,m,n) format (__##kind##__, m, n)
+# define __format__(kind,m,n) __format__ (__##kind##__, m, n)
+# define ____printf____ __printf__
+# define ____scanf____ __scanf__
+# define ____strftime____ __strftime__
+# define ____strfmon____ __strfmon__
+#endif
+
+#if @GNULIB_PUTC@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
+# undef putc
+# define putc rpl_fputc
+extern int putc (int c, FILE *stream) _GL_ARG_NONNULL ((2));
+#endif
+
+#if @GNULIB_PUTCHAR@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
+# undef putchar
+# define putchar rpl_putchar
+extern int putchar (int c);
+#endif
+
+#if @GNULIB_PUTS@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
+# undef puts
+# define puts rpl_puts
+extern int puts (const char *string) _GL_ARG_NONNULL ((1));
+#endif
+
+#if @GNULIB_REMOVE@
+# if @REPLACE_REMOVE@
+#  undef remove
+#  define remove rpl_remove
+extern int remove (const char *name) _GL_ARG_NONNULL ((1));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef remove
+# define remove(n)                                         \
+   (GL_LINK_WARNING ("remove cannot handle directories on some platforms - " \
+                     "use gnulib module remove for more portability"), \
+    remove (n))
+#endif
+
+#if @GNULIB_RENAME@
+# if @REPLACE_RENAME@
+#  undef rename
+#  define rename rpl_rename
+extern int rename (const char *old_filename, const char *new_filename)
+     _GL_ARG_NONNULL ((1, 2));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef rename
+# define rename(o,n)                                       \
+   (GL_LINK_WARNING ("rename is buggy on some platforms - " \
+                     "use gnulib module rename for more portability"), \
+    rename (o, n))
+#endif
+
+#if @GNULIB_RENAMEAT@
+# if @REPLACE_RENAMEAT@
+#  undef renameat
+#  define renameat rpl_renameat
+# endif
+# if !@HAVE_RENAMEAT@ || @REPLACE_RENAMEAT@
+extern int renameat (int fd1, char const *file1, int fd2, char const *file2)
+     _GL_ARG_NONNULL ((2, 4));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef renameat
+# define renameat(d1,f1,d2,f2)             \
+    (GL_LINK_WARNING ("renameat is not portable - " \
+                      "use gnulib module renameat for portability"), \
+     renameat (d1, f1, d2, f2))
+#endif
+
+#if @GNULIB_SNPRINTF@
+# if @REPLACE_SNPRINTF@
+#  define snprintf rpl_snprintf
+# endif
+# if @REPLACE_SNPRINTF@ || !@HAVE_DECL_SNPRINTF@
+extern int snprintf (char *str, size_t size, const char *format, ...)
+       __attribute__ ((__format__ (__printf__, 3, 4)))
+       _GL_ARG_NONNULL ((3));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef snprintf
+# define snprintf \
+    (GL_LINK_WARNING ("snprintf is unportable - " \
+                      "use gnulib module snprintf for portability"), \
+     snprintf)
+#endif
+
+#if @GNULIB_SPRINTF_POSIX@
+# if @REPLACE_SPRINTF@
+#  define sprintf rpl_sprintf
+extern int sprintf (char *str, const char *format, ...)
+       __attribute__ ((__format__ (__printf__, 2, 3)))
+       _GL_ARG_NONNULL ((1, 2));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef sprintf
+# define sprintf \
+    (GL_LINK_WARNING ("sprintf is not always POSIX compliant - " \
+                      "use gnulib module sprintf-posix for portable " \
+                      "POSIX compliance"), \
+     sprintf)
+#endif
+
+#if @GNULIB_VASPRINTF@
+# if @REPLACE_VASPRINTF@
+#  define asprintf rpl_asprintf
+#  define vasprintf rpl_vasprintf
+# endif
+# if @REPLACE_VASPRINTF@ || !@HAVE_VASPRINTF@
+  /* Write formatted output to a string dynamically allocated with malloc().
+     If the memory allocation succeeds, store the address of the string in
+     *RESULT and return the number of resulting bytes, excluding the trailing
+     NUL.  Upon memory allocation error, or some other error, return -1.  */
+  extern int asprintf (char **result, const char *format, ...)
+    __attribute__ ((__format__ (__printf__, 2, 3))) _GL_ARG_NONNULL ((1, 2));
+  extern int vasprintf (char **result, const char *format, va_list args)
+    __attribute__ ((__format__ (__printf__, 2, 0))) _GL_ARG_NONNULL ((1, 2));
+# endif
+#endif
+
+#if @GNULIB_VDPRINTF@
+# if @REPLACE_VDPRINTF@
+#  define vdprintf rpl_vdprintf
+# endif
+# if @REPLACE_VDPRINTF@ || !@HAVE_VDPRINTF@
+extern int vdprintf (int fd, const char *format, va_list args)
+       __attribute__ ((__format__ (__printf__, 2, 0))) _GL_ARG_NONNULL ((2));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef vdprintf
+# define vdprintf(d,f,a) \
+    (GL_LINK_WARNING ("vdprintf is unportable - " \
+                      "use gnulib module vdprintf for portability"), \
+     vdprintf (d, f, a))
+#endif
+
+#if @GNULIB_VFPRINTF_POSIX@
+# if @REPLACE_VFPRINTF@
+#  define vfprintf rpl_vfprintf
+extern int vfprintf (FILE *fp, const char *format, va_list args)
+       __attribute__ ((__format__ (__printf__, 2, 0)))
+       _GL_ARG_NONNULL ((1, 2));
+# endif
+#elif @GNULIB_VFPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
+# define vfprintf rpl_vfprintf
+extern int vfprintf (FILE *fp, const char *format, va_list args)
+       __attribute__ ((__format__ (__printf__, 2, 0)))
+       _GL_ARG_NONNULL ((1, 2));
+#elif defined GNULIB_POSIXCHECK
+# undef vfprintf
+# define vfprintf(s,f,a) \
+    (GL_LINK_WARNING ("vfprintf is not always POSIX compliant - " \
+                      "use gnulib module vfprintf-posix for portable " \
+                      "POSIX compliance"), \
+     vfprintf (s, f, a))
+#endif
+
+#if @GNULIB_VPRINTF_POSIX@
+# if @REPLACE_VPRINTF@
+#  define vprintf rpl_vprintf
+extern int vprintf (const char *format, va_list args)
+       __attribute__ ((__format__ (__printf__, 1, 0))) _GL_ARG_NONNULL ((1));
+# endif
+#elif @GNULIB_VPRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && @GNULIB_STDIO_H_SIGPIPE@
+# define vprintf rpl_vprintf
+extern int vprintf (const char *format, va_list args)
+       __attribute__ ((__format__ (__printf__, 1, 0))) _GL_ARG_NONNULL ((1));
+#elif defined GNULIB_POSIXCHECK
+# undef vprintf
+# define vprintf(f,a) \
+    (GL_LINK_WARNING ("vprintf is not always POSIX compliant - " \
+                      "use gnulib module vprintf-posix for portable " \
+                      "POSIX compliance"), \
+     vprintf (f, a))
+#endif
+
+#if @GNULIB_VSNPRINTF@
+# if @REPLACE_VSNPRINTF@
+#  define vsnprintf rpl_vsnprintf
+# endif
+# if @REPLACE_VSNPRINTF@ || !@HAVE_DECL_VSNPRINTF@
+extern int vsnprintf (char *str, size_t size, const char *format, va_list args)
+       __attribute__ ((__format__ (__printf__, 3, 0)))
+       _GL_ARG_NONNULL ((3));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef vsnprintf
+# define vsnprintf(b,s,f,a) \
+    (GL_LINK_WARNING ("vsnprintf is unportable - " \
+                      "use gnulib module vsnprintf for portability"), \
+     vsnprintf (b, s, f, a))
+#endif
+
+#if @GNULIB_VSPRINTF_POSIX@
+# if @REPLACE_VSPRINTF@
+#  define vsprintf rpl_vsprintf
+extern int vsprintf (char *str, const char *format, va_list args)
+       __attribute__ ((__format__ (__printf__, 2, 0)))
+       _GL_ARG_NONNULL ((1, 2));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef vsprintf
+# define vsprintf(b,f,a) \
+    (GL_LINK_WARNING ("vsprintf is not always POSIX compliant - " \
+                      "use gnulib module vsprintf-posix for portable " \
+                      "POSIX compliance"), \
+     vsprintf (b, f, a))
+#endif
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/libmissing/stdlib.in.h b/libmissing/stdlib.in.h
index 23325b5..058cf1d 100644
--- a/libmissing/stdlib.in.h
+++ b/libmissing/stdlib.in.h
@@ -35,9 +35,11 @@
 #ifndef _GL_STDLIB_H
 #define _GL_STDLIB_H
 
+/* NetBSD 5.0 mis-defines NULL.  */
+#include <stddef.h>
 
 /* Solaris declares getloadavg() in <sys/loadavg.h>.  */
-#if @GNULIB_GETLOADAVG@ && @HAVE_SYS_LOADAVG_H@
+#if (@GNULIB_GETLOADAVG@ || defined GNULIB_POSIXCHECK) && @HAVE_SYS_LOADAVG_H@
 # include <sys/loadavg.h>
 #endif
 
@@ -47,25 +49,35 @@
 # include <random.h>
 #endif
 
-#if @GNULIB_RANDOM_R@ || !@HAVE_STRUCT_RANDOM_DATA@
+#if !@HAVE_STRUCT_RANDOM_DATA@ || (@GNULIB_RANDOM_R@ && !@HAVE_RANDOM_R@) \
+    || defined GNULIB_POSIXCHECK
 # include <stdint.h>
 #endif
 
 #if !@HAVE_STRUCT_RANDOM_DATA@
 struct random_data
 {
-  int32_t *fptr;		/* Front pointer.  */
-  int32_t *rptr;		/* Rear pointer.  */
-  int32_t *state;		/* Array of state values.  */
-  int rand_type;		/* Type of random number generator.  */
-  int rand_deg;			/* Degree of random number generator.  */
-  int rand_sep;			/* Distance between front and rear.  */
-  int32_t *end_ptr;		/* Pointer behind state table.  */
+  int32_t *fptr;                /* Front pointer.  */
+  int32_t *rptr;                /* Rear pointer.  */
+  int32_t *state;               /* Array of state values.  */
+  int rand_type;                /* Type of random number generator.  */
+  int rand_deg;                 /* Degree of random number generator.  */
+  int rand_sep;                 /* Distance between front and rear.  */
+  int32_t *end_ptr;             /* Pointer behind state table.  */
 };
 #endif
 
+#if (@GNULIB_MKSTEMP@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__
+/* On MacOS X 10.3, only <unistd.h> declares mkstemp.  */
+/* On Cygwin 1.7.1, only <unistd.h> declares getsubopt.  */
+/* But avoid namespace pollution on glibc systems.  */
+# include <unistd.h>
+#endif
+
 /* The definition of GL_LINK_WARNING is copied here.  */
 
+/* The definition of _GL_ARG_NONNULL is copied here.  */
+
 
 /* Some systems do not define EXIT_*, despite otherwise supporting C89.  */
 #ifndef EXIT_SUCCESS
@@ -85,37 +97,20 @@ struct random_data
 extern "C" {
 #endif
 
-
-#if @GNULIB_MALLOC_POSIX@
-# if !@HAVE_MALLOC_POSIX@
-#  undef malloc
-#  define malloc rpl_malloc
-extern void * malloc (size_t size);
-# endif
-#elif defined GNULIB_POSIXCHECK
-# undef malloc
-# define malloc(s) \
-    (GL_LINK_WARNING ("malloc is not POSIX compliant everywhere - " \
-                      "use gnulib module malloc-posix for portability"), \
-     malloc (s))
-#endif
-
-
-#if @GNULIB_REALLOC_POSIX@
-# if !@HAVE_REALLOC_POSIX@
-#  undef realloc
-#  define realloc rpl_realloc
-extern void * realloc (void *ptr, size_t size);
+#if @GNULIB_ATOLL@
+# if !@HAVE_ATOLL@
+/* Parse a signed decimal integer.
+   Returns the value of the integer.  Errors are not detected.  */
+extern long long atoll (const char *string) _GL_ARG_NONNULL ((1));
 # endif
 #elif defined GNULIB_POSIXCHECK
-# undef realloc
-# define realloc(p,s) \
-    (GL_LINK_WARNING ("realloc is not POSIX compliant everywhere - " \
-                      "use gnulib module realloc-posix for portability"), \
-     realloc (p, s))
+# undef atoll
+# define atoll(s) \
+    (GL_LINK_WARNING ("atoll is unportable - " \
+                      "use gnulib module atoll for portability"), \
+     atoll (s))
 #endif
 
-
 #if @GNULIB_CALLOC_POSIX@
 # if !@HAVE_CALLOC_POSIX@
 #  undef calloc
@@ -130,29 +125,28 @@ extern void * calloc (size_t nmemb, size_t size);
      calloc (n, s))
 #endif
 
-
-#if @GNULIB_ATOLL@
-# if !@HAVE_ATOLL@
-/* Parse a signed decimal integer.
-   Returns the value of the integer.  Errors are not detected.  */
-extern long long atoll (const char *string);
+#if @GNULIB_CANONICALIZE_FILE_NAME@
+# if @REPLACE_CANONICALIZE_FILE_NAME@
+#  define canonicalize_file_name rpl_canonicalize_file_name
+# endif
+# if !@HAVE_CANONICALIZE_FILE_NAME@ || @REPLACE_CANONICALIZE_FILE_NAME@
+extern char *canonicalize_file_name (const char *name) _GL_ARG_NONNULL ((1));
 # endif
 #elif defined GNULIB_POSIXCHECK
-# undef atoll
-# define atoll(s) \
-    (GL_LINK_WARNING ("atoll is unportable - " \
-                      "use gnulib module atoll for portability"), \
-     atoll (s))
+# undef canonicalize_file_name
+# define canonicalize_file_name(n)                        \
+    (GL_LINK_WARNING ("canonicalize_file_name is unportable - " \
+                      "use gnulib module canonicalize-lgpl for portability"), \
+     canonicalize_file_name (n))
 #endif
 
-
 #if @GNULIB_GETLOADAVG@
 # if !@HAVE_DECL_GETLOADAVG@
 /* Store max(NELEM,3) load average numbers in LOADAVG[].
    The three numbers are the load average of the last 1 minute, the last 5
    minutes, and the last 15 minutes, respectively.
    LOADAVG is an array of NELEM numbers.  */
-extern int getloadavg (double loadavg[], int nelem);
+extern int getloadavg (double loadavg[], int nelem) _GL_ARG_NONNULL ((1));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef getloadavg
@@ -162,7 +156,6 @@ extern int getloadavg (double loadavg[], int nelem);
      getloadavg (l, n))
 #endif
 
-
 #if @GNULIB_GETSUBOPT@
 /* Assuming *OPTIONP is a comma separated list of elements of the form
    "token" or "token=value", getsubopt parses the first of these elements.
@@ -176,7 +169,8 @@ extern int getloadavg (double loadavg[], int nelem);
    For more details see the POSIX:2001 specification.
    http://www.opengroup.org/susv3xsh/getsubopt.html */
 # if !@HAVE_GETSUBOPT@
-extern int getsubopt (char **optionp, char *const *tokens, char **valuep);
+extern int getsubopt (char **optionp, char *const *tokens, char **valuep)
+     _GL_ARG_NONNULL ((1, 2, 3));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef getsubopt
@@ -186,6 +180,19 @@ extern int getsubopt (char **optionp, char *const *tokens, char **valuep);
      getsubopt (o, t, v))
 #endif
 
+#if @GNULIB_MALLOC_POSIX@
+# if !@HAVE_MALLOC_POSIX@
+#  undef malloc
+#  define malloc rpl_malloc
+extern void * malloc (size_t size);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef malloc
+# define malloc(s) \
+    (GL_LINK_WARNING ("malloc is not POSIX compliant everywhere - " \
+                      "use gnulib module malloc-posix for portability"), \
+     malloc (s))
+#endif
 
 #if @GNULIB_MKDTEMP@
 # if !@HAVE_MKDTEMP@
@@ -194,7 +201,7 @@ extern int getsubopt (char **optionp, char *const *tokens, char **valuep);
    they are replaced with a string that makes the directory name unique.
    Returns TEMPLATE, or a null pointer if it cannot get a unique name.
    The directory is created mode 700.  */
-extern char * mkdtemp (char * /*template*/);
+extern char * mkdtemp (char * /*template*/) _GL_ARG_NONNULL ((1));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef mkdtemp
@@ -204,6 +211,55 @@ extern char * mkdtemp (char * /*template*/);
      mkdtemp (t))
 #endif
 
+#if @GNULIB_MKOSTEMP@
+# if !@HAVE_MKOSTEMP@
+/* Create a unique temporary file from TEMPLATE.
+   The last six characters of TEMPLATE must be "XXXXXX";
+   they are replaced with a string that makes the file name unique.
+   The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
+   and O_TEXT, O_BINARY (defined in "binary-io.h").
+   The file is then created, with the specified flags, ensuring it didn't exist
+   before.
+   The file is created read-write (mask at least 0600 & ~umask), but it may be
+   world-readable and world-writable (mask 0666 & ~umask), depending on the
+   implementation.
+   Returns the open file descriptor if successful, otherwise -1 and errno
+   set.  */
+extern int mkostemp (char * /*template*/, int /*flags*/) _GL_ARG_NONNULL ((1));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef mkostemp
+# define mkostemp(t,f) \
+    (GL_LINK_WARNING ("mkostemp is unportable - " \
+                      "use gnulib module mkostemp for portability"), \
+     mkostemp (t, f))
+#endif
+
+#if @GNULIB_MKOSTEMPS@
+# if !@HAVE_MKOSTEMPS@
+/* Create a unique temporary file from TEMPLATE.
+   The last six characters of TEMPLATE before a suffix of length
+   SUFFIXLEN must be "XXXXXX";
+   they are replaced with a string that makes the file name unique.
+   The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
+   and O_TEXT, O_BINARY (defined in "binary-io.h").
+   The file is then created, with the specified flags, ensuring it didn't exist
+   before.
+   The file is created read-write (mask at least 0600 & ~umask), but it may be
+   world-readable and world-writable (mask 0666 & ~umask), depending on the
+   implementation.
+   Returns the open file descriptor if successful, otherwise -1 and errno
+   set.  */
+extern int mkostemps (char * /*template*/, int /*suffixlen*/, int /*flags*/)
+     _GL_ARG_NONNULL ((1));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef mkostemps
+# define mkostemps(t,s,f)                          \
+    (GL_LINK_WARNING ("mkostemps is unportable - " \
+                      "use gnulib module mkostemps for portability"), \
+     mkostemps (t, s, f))
+#endif
 
 #if @GNULIB_MKSTEMP@
 # if @REPLACE_MKSTEMP@
@@ -217,10 +273,7 @@ extern char * mkdtemp (char * /*template*/);
    Returns the open file descriptor if successful, otherwise -1 and errno
    set.  */
 #  define mkstemp rpl_mkstemp
-extern int mkstemp (char * /*template*/);
-# else
-/* On MacOS X 10.3, only <unistd.h> declares mkstemp.  */
-#  include <unistd.h>
+extern int mkstemp (char * /*template*/) _GL_ARG_NONNULL ((1));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef mkstemp
@@ -230,16 +283,37 @@ extern int mkstemp (char * /*template*/);
      mkstemp (t))
 #endif
 
+#if @GNULIB_MKSTEMPS@
+# if !@HAVE_MKSTEMPS@
+/* Create a unique temporary file from TEMPLATE.
+   The last six characters of TEMPLATE prior to a suffix of length
+   SUFFIXLEN must be "XXXXXX";
+   they are replaced with a string that makes the file name unique.
+   The file is then created, ensuring it didn't exist before.
+   The file is created read-write (mask at least 0600 & ~umask), but it may be
+   world-readable and world-writable (mask 0666 & ~umask), depending on the
+   implementation.
+   Returns the open file descriptor if successful, otherwise -1 and errno
+   set.  */
+extern int mkstemps (char * /*template*/, int /*suffixlen*/)
+     _GL_ARG_NONNULL ((1));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef mkstemps
+# define mkstemps(t,s)                             \
+    (GL_LINK_WARNING ("mkstemps is unportable - " \
+                      "use gnulib module mkstemps for portability"), \
+     mkstemps (t, s))
+#endif
 
 #if @GNULIB_PUTENV@
 # if @REPLACE_PUTENV@
 #  undef putenv
 #  define putenv rpl_putenv
-extern int putenv (char *string);
+extern int putenv (char *string) _GL_ARG_NONNULL ((1));
 # endif
 #endif
 
-
 #if @GNULIB_RANDOM_R@
 # if !@HAVE_RANDOM_R@
 
@@ -247,41 +321,73 @@ extern int putenv (char *string);
 #   define RAND_MAX 2147483647
 #  endif
 
-int srandom_r (unsigned int seed, struct random_data *rand_state);
+int srandom_r (unsigned int seed, struct random_data *rand_state)
+     _GL_ARG_NONNULL ((2));
 int initstate_r (unsigned int seed, char *buf, size_t buf_size,
-		 struct random_data *rand_state);
-int setstate_r (char *arg_state, struct random_data *rand_state);
-int random_r (struct random_data *buf, int32_t *result);
+                 struct random_data *rand_state)
+     _GL_ARG_NONNULL ((2, 4));
+int setstate_r (char *arg_state, struct random_data *rand_state)
+     _GL_ARG_NONNULL ((1, 2));
+int random_r (struct random_data *buf, int32_t *result)
+     _GL_ARG_NONNULL ((1, 2));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef random_r
-# define random_r(b,r)				  \
+# define random_r(b,r)                            \
     (GL_LINK_WARNING ("random_r is unportable - " \
                       "use gnulib module random_r for portability"), \
      random_r (b,r))
 # undef initstate_r
-# define initstate_r(s,b,sz,r)			     \
+# define initstate_r(s,b,sz,r)                       \
     (GL_LINK_WARNING ("initstate_r is unportable - " \
                       "use gnulib module random_r for portability"), \
      initstate_r (s,b,sz,r))
 # undef srandom_r
-# define srandom_r(s,r)				   \
+# define srandom_r(s,r)                            \
     (GL_LINK_WARNING ("srandom_r is unportable - " \
                       "use gnulib module random_r for portability"), \
      srandom_r (s,r))
 # undef setstate_r
-# define setstate_r(a,r)				    \
+# define setstate_r(a,r)                                    \
     (GL_LINK_WARNING ("setstate_r is unportable - " \
                       "use gnulib module random_r for portability"), \
      setstate_r (a,r))
 #endif
 
+#if @GNULIB_REALLOC_POSIX@
+# if !@HAVE_REALLOC_POSIX@
+#  undef realloc
+#  define realloc rpl_realloc
+extern void * realloc (void *ptr, size_t size);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef realloc
+# define realloc(p,s) \
+    (GL_LINK_WARNING ("realloc is not POSIX compliant everywhere - " \
+                      "use gnulib module realloc-posix for portability"), \
+     realloc (p, s))
+#endif
+
+#if @GNULIB_REALPATH@
+# if @REPLACE_REALPATH@
+#  define realpath rpl_realpath
+# endif
+# if !@HAVE_REALPATH@ || @REPLACE_REALPATH@
+extern char *realpath (const char *name, char *resolved) _GL_ARG_NONNULL ((1));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef realpath
+# define realpath(n,r)                        \
+    (GL_LINK_WARNING ("realpath is unportable - use gnulib module " \
+                      "canonicalize or canonicalize-lgpl for portability"), \
+     realpath (n, r))
+#endif
 
 #if @GNULIB_RPMATCH@
 # if !@HAVE_RPMATCH@
 /* Test a user response to a question.
    Return 1 if it is affirmative, 0 if it is negative, or -1 if not clear.  */
-extern int rpmatch (const char *response);
+extern int rpmatch (const char *response) _GL_ARG_NONNULL ((1));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef rpmatch
@@ -291,37 +397,32 @@ extern int rpmatch (const char *response);
      rpmatch (r))
 #endif
 
-
 #if @GNULIB_SETENV@
-# if !@HAVE_SETENV@
+# if @REPLACE_SETENV@
+#  undef setenv
+#  define setenv rpl_setenv
+# endif
+# if !@HAVE_SETENV@ || @REPLACE_SETENV@
 /* Set NAME to VALUE in the environment.
    If REPLACE is nonzero, overwrite an existing value.  */
-extern int setenv (const char *name, const char *value, int replace);
-# endif
-#endif
-
-
-#if @GNULIB_UNSETENV@
-# if @HAVE_UNSETENV@
-#  if @VOID_UNSETENV@
-/* On some systems, unsetenv() returns void.
-   This is the case for MacOS X 10.3, FreeBSD 4.8, NetBSD 1.6, OpenBSD 3.4.  */
-#   define unsetenv(name) ((unsetenv)(name), 0)
-#  endif
-# else
-/* Remove the variable NAME from the environment.  */
-extern int unsetenv (const char *name);
+extern int setenv (const char *name, const char *value, int replace)
+     _GL_ARG_NONNULL ((1));
 # endif
+#elif defined GNULIB_POSIXCHECK
+# undef setenv
+# define setenv(n,v,o)                                                  \
+    (GL_LINK_WARNING ("setenv is unportable - "                         \
+                      "use gnulib module setenv for portability"),      \
+     setenv (n, v, o))
 #endif
 
-
 #if @GNULIB_STRTOD@
 # if @REPLACE_STRTOD@
 #  define strtod rpl_strtod
 # endif
 # if !@HAVE_STRTOD@ || @REPLACE_STRTOD@
  /* Parse a double from STRING, updating ENDP if appropriate.  */
-extern double strtod (const char *str, char **endp);
+extern double strtod (const char *str, char **endp) _GL_ARG_NONNULL ((1));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef strtod
@@ -331,7 +432,6 @@ extern double strtod (const char *str, char **endp);
      strtod (s, e))
 #endif
 
-
 #if @GNULIB_STRTOLL@
 # if !@HAVE_STRTOLL@
 /* Parse a signed integer whose textual representation starts at STRING.
@@ -342,7 +442,8 @@ extern double strtod (const char *str, char **endp);
    stored in *ENDPTR.
    Upon overflow, the return value is LLONG_MAX or LLONG_MIN, and errno is set
    to ERANGE.  */
-extern long long strtoll (const char *string, char **endptr, int base);
+extern long long strtoll (const char *string, char **endptr, int base)
+     _GL_ARG_NONNULL ((1));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef strtoll
@@ -352,7 +453,6 @@ extern long long strtoll (const char *string, char **endptr, int base);
      strtoll (s, e, b))
 #endif
 
-
 #if @GNULIB_STRTOULL@
 # if !@HAVE_STRTOULL@
 /* Parse an unsigned integer whose textual representation starts at STRING.
@@ -363,7 +463,8 @@ extern long long strtoll (const char *string, char **endptr, int base);
    stored in *ENDPTR.
    Upon overflow, the return value is ULLONG_MAX, and errno is set to
    ERANGE.  */
-extern unsigned long long strtoull (const char *string, char **endptr, int base);
+extern unsigned long long strtoull (const char *string, char **endptr, int base)
+     _GL_ARG_NONNULL ((1));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef strtoull
@@ -373,6 +474,22 @@ extern unsigned long long strtoull (const char *string, char **endptr, int base)
      strtoull (s, e, b))
 #endif
 
+#if @GNULIB_UNSETENV@
+# if @REPLACE_UNSETENV@
+#  undef unsetenv
+#  define unsetenv rpl_unsetenv
+# endif
+# if !@HAVE_UNSETENV@ || @REPLACE_UNSETENV@
+/* Remove the variable NAME from the environment.  */
+extern int unsetenv (const char *name) _GL_ARG_NONNULL ((1));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef unsetenv
+# define unsetenv(n)                                                    \
+    (GL_LINK_WARNING ("unsetenv is unportable - "                       \
+                      "use gnulib module unsetenv for portability"),    \
+     unsetenv (n))
+#endif
 
 #ifdef __cplusplus
 }
diff --git a/libmissing/strcasecmp.c b/libmissing/strcasecmp.c
index 7081325..fc3acc2 100644
--- a/libmissing/strcasecmp.c
+++ b/libmissing/strcasecmp.c
@@ -1,5 +1,5 @@
 /* Case-insensitive string comparison function.
-   Copyright (C) 1998-1999, 2005-2007 Free Software Foundation, Inc.
+   Copyright (C) 1998-1999, 2005-2007, 2009 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -46,7 +46,7 @@ strcasecmp (const char *s1, const char *s2)
       c2 = TOLOWER (*p2);
 
       if (c1 == '\0')
-	break;
+        break;
 
       ++p1;
       ++p2;
diff --git a/libmissing/streq.h b/libmissing/streq.h
index 1b4b1c5..393f6d9 100644
--- a/libmissing/streq.h
+++ b/libmissing/streq.h
@@ -1,5 +1,5 @@
 /* Optimized string comparison.
-   Copyright (C) 2001-2002, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2001-2002, 2007, 2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify it
    under the terms of the GNU Lesser General Public License as published
diff --git a/libmissing/string.in.h b/libmissing/string.in.h
index fe11425..7a0a9a2 100644
--- a/libmissing/string.in.h
+++ b/libmissing/string.in.h
@@ -28,6 +28,8 @@
 #ifndef _GL_STRING_H
 #define _GL_STRING_H
 
+/* NetBSD 5.0 mis-defines NULL.  */
+#include <stddef.h>
 
 #ifndef __attribute__
 /* This feature is available in gcc versions 2.5 and later.  */
@@ -43,6 +45,8 @@
 
 /* The definition of GL_LINK_WARNING is copied here.  */
 
+/* The definition of _GL_ARG_NONNULL is copied here.  */
+
 
 #ifdef __cplusplus
 extern "C" {
@@ -54,7 +58,7 @@ extern "C" {
 # if @REPLACE_MEMCHR@
 #  define memchr rpl_memchr
 extern void *memchr (void const *__s, int __c, size_t __n)
-  __attribute__ ((__pure__));
+     __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef memchr
@@ -71,8 +75,8 @@ extern void *memchr (void const *__s, int __c, size_t __n)
 # endif
 # if ! @HAVE_DECL_MEMMEM@ || @REPLACE_MEMMEM@
 extern void *memmem (void const *__haystack, size_t __haystack_len,
-		     void const *__needle, size_t __needle_len)
-  __attribute__ ((__pure__));
+                     void const *__needle, size_t __needle_len)
+     __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 3));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef memmem
@@ -88,7 +92,8 @@ extern void *memmem (void const *__haystack, size_t __haystack_len,
 #if @GNULIB_MEMPCPY@
 # if ! @HAVE_MEMPCPY@
 extern void *mempcpy (void *restrict __dest, void const *restrict __src,
-		      size_t __n);
+                      size_t __n)
+     _GL_ARG_NONNULL ((1, 2));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef mempcpy
@@ -102,7 +107,7 @@ extern void *mempcpy (void *restrict __dest, void const *restrict __src,
 #if @GNULIB_MEMRCHR@
 # if ! @HAVE_DECL_MEMRCHR@
 extern void *memrchr (void const *, int, size_t)
-  __attribute__ ((__pure__));
+     __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef memrchr
@@ -118,7 +123,7 @@ extern void *memrchr (void const *, int, size_t)
 #if @GNULIB_RAWMEMCHR@
 # if ! @HAVE_RAWMEMCHR@
 extern void *rawmemchr (void const *__s, int __c_in)
-  __attribute__ ((__pure__));
+     __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef rawmemchr
@@ -131,7 +136,8 @@ extern void *rawmemchr (void const *__s, int __c_in)
 /* Copy SRC to DST, returning the address of the terminating '\0' in DST.  */
 #if @GNULIB_STPCPY@
 # if ! @HAVE_STPCPY@
-extern char *stpcpy (char *restrict __dst, char const *restrict __src);
+extern char *stpcpy (char *restrict __dst, char const *restrict __src)
+     _GL_ARG_NONNULL ((1, 2));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef stpcpy
@@ -147,7 +153,8 @@ extern char *stpcpy (char *restrict __dst, char const *restrict __src);
 # if ! @HAVE_STPNCPY@
 #  define stpncpy gnu_stpncpy
 extern char *stpncpy (char *restrict __dst, char const *restrict __src,
-		      size_t __n);
+                      size_t __n)
+     _GL_ARG_NONNULL ((1, 2));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef stpncpy
@@ -172,7 +179,7 @@ extern char *stpncpy (char *restrict __dst, char const *restrict __src,
 #if @GNULIB_STRCHRNUL@
 # if ! @HAVE_STRCHRNUL@
 extern char *strchrnul (char const *__s, int __c_in)
-  __attribute__ ((__pure__));
+     __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef strchrnul
@@ -189,7 +196,7 @@ extern char *strchrnul (char const *__s, int __c_in)
 #  define strdup rpl_strdup
 # endif
 # if !(@HAVE_DECL_STRDUP@ || defined strdup) || @REPLACE_STRDUP@
-extern char *strdup (char const *__s);
+extern char *strdup (char const *__s) _GL_ARG_NONNULL ((1));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef strdup
@@ -201,12 +208,12 @@ extern char *strdup (char const *__s);
 
 /* Return a newly allocated copy of at most N bytes of STRING.  */
 #if @GNULIB_STRNDUP@
-# if ! @HAVE_STRNDUP@
+# if @REPLACE_STRNDUP@
 #  undef strndup
 #  define strndup rpl_strndup
 # endif
-# if ! @HAVE_STRNDUP@ || ! @HAVE_DECL_STRNDUP@
-extern char *strndup (char const *__string, size_t __n);
+# if @REPLACE_STRNDUP@ || ! @HAVE_DECL_STRNDUP@
+extern char *strndup (char const *__string, size_t __n) _GL_ARG_NONNULL ((1));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef strndup
@@ -222,7 +229,7 @@ extern char *strndup (char const *__string, size_t __n);
 #if @GNULIB_STRNLEN@
 # if ! @HAVE_DECL_STRNLEN@
 extern size_t strnlen (char const *__string, size_t __maxlen)
-  __attribute__ ((__pure__));
+     __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef strnlen
@@ -249,7 +256,7 @@ extern size_t strnlen (char const *__string, size_t __maxlen)
 #if @GNULIB_STRPBRK@
 # if ! @HAVE_STRPBRK@
 extern char *strpbrk (char const *__s, char const *__accept)
-  __attribute__ ((__pure__));
+     __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2));
 # endif
 # if defined GNULIB_POSIXCHECK
 /* strpbrk() assumes the second argument is a list of single-byte characters.
@@ -311,7 +318,8 @@ extern char *strpbrk (char const *__s, char const *__accept)
    See also strtok_r().  */
 #if @GNULIB_STRSEP@
 # if ! @HAVE_STRSEP@
-extern char *strsep (char **restrict __stringp, char const *restrict __delim);
+extern char *strsep (char **restrict __stringp, char const *restrict __delim)
+     _GL_ARG_NONNULL ((1, 2));
 # endif
 # if defined GNULIB_POSIXCHECK
 #  undef strsep
@@ -332,8 +340,8 @@ extern char *strsep (char **restrict __stringp, char const *restrict __delim);
 #if @GNULIB_STRSTR@
 # if @REPLACE_STRSTR@
 #  define strstr rpl_strstr
-char *strstr (const char *haystack, const char *needle)
-  __attribute__ ((__pure__));
+extern char *strstr (const char *haystack, const char *needle)
+     __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2));
 # endif
 #elif defined GNULIB_POSIXCHECK
 /* strstr() does not work with multibyte strings if the locale encoding is
@@ -358,7 +366,7 @@ char *strstr (const char *haystack, const char *needle)
 # endif
 # if ! @HAVE_STRCASESTR@ || @REPLACE_STRCASESTR@
 extern char *strcasestr (const char *haystack, const char *needle)
-  __attribute__ ((__pure__));
+     __attribute__ ((__pure__)) _GL_ARG_NONNULL ((1, 2));
 # endif
 #elif defined GNULIB_POSIXCHECK
 /* strcasestr() does not work with multibyte strings:
@@ -377,12 +385,12 @@ extern char *strcasestr (const char *haystack, const char *needle)
 /* Parse S into tokens separated by characters in DELIM.
    If S is NULL, the saved pointer in SAVE_PTR is used as
    the next starting point.  For example:
-	char s[] = "-abc-=-def";
-	char *sp;
-	x = strtok_r(s, "-", &sp);	// x = "abc", sp = "=-def"
-	x = strtok_r(NULL, "-=", &sp);	// x = "def", sp = NULL
-	x = strtok_r(NULL, "=", &sp);	// x = NULL
-		// s = "abc\0-def\0"
+        char s[] = "-abc-=-def";
+        char *sp;
+        x = strtok_r(s, "-", &sp);      // x = "abc", sp = "=-def"
+        x = strtok_r(NULL, "-=", &sp);  // x = "def", sp = NULL
+        x = strtok_r(NULL, "=", &sp);   // x = NULL
+                // s = "abc\0-def\0"
 
    This is a variant of strtok() that is multithread-safe.
 
@@ -397,9 +405,16 @@ extern char *strcasestr (const char *haystack, const char *needle)
 
    See also strsep().  */
 #if @GNULIB_STRTOK_R@
-# if ! @HAVE_DECL_STRTOK_R@
+# if @REPLACE_STRTOK_R@
+#  undef strtok_r
+#  define strtok_r rpl_strtok_r
+# elif @UNDEFINE_STRTOK_R@
+#  undef strtok_r
+# endif
+# if ! @HAVE_DECL_STRTOK_R@ || @REPLACE_STRTOK_R@
 extern char *strtok_r (char *restrict s, char const *restrict delim,
-		       char **restrict save_ptr);
+                       char **restrict save_ptr)
+     _GL_ARG_NONNULL ((2, 3));
 # endif
 # if defined GNULIB_POSIXCHECK
 #  undef strtok_r
@@ -424,13 +439,13 @@ extern char *strtok_r (char *restrict s, char const *restrict delim,
 #if @GNULIB_MBSLEN@
 /* Return the number of multibyte characters in the character string STRING.
    This considers multibyte characters, unlike strlen, which counts bytes.  */
-extern size_t mbslen (const char *string);
+extern size_t mbslen (const char *string) _GL_ARG_NONNULL ((1));
 #endif
 
 #if @GNULIB_MBSNLEN@
 /* Return the number of multibyte characters in the character string starting
    at STRING and ending at STRING + LEN.  */
-extern size_t mbsnlen (const char *string, size_t len);
+extern size_t mbsnlen (const char *string, size_t len) _GL_ARG_NONNULL ((1));
 #endif
 
 #if @GNULIB_MBSCHR@
@@ -439,7 +454,7 @@ extern size_t mbsnlen (const char *string, size_t len);
    Unlike strchr(), this function works correctly in multibyte locales with
    encodings such as GB18030.  */
 # define mbschr rpl_mbschr /* avoid collision with HP-UX function */
-extern char * mbschr (const char *string, int c);
+extern char * mbschr (const char *string, int c) _GL_ARG_NONNULL ((1));
 #endif
 
 #if @GNULIB_MBSRCHR@
@@ -448,7 +463,7 @@ extern char * mbschr (const char *string, int c);
    Unlike strrchr(), this function works correctly in multibyte locales with
    encodings such as GB18030.  */
 # define mbsrchr rpl_mbsrchr /* avoid collision with HP-UX function */
-extern char * mbsrchr (const char *string, int c);
+extern char * mbsrchr (const char *string, int c) _GL_ARG_NONNULL ((1));
 #endif
 
 #if @GNULIB_MBSSTR@
@@ -456,7 +471,8 @@ extern char * mbsrchr (const char *string, int c);
    string HAYSTACK.  Return NULL if NEEDLE is not found in HAYSTACK.
    Unlike strstr(), this function works correctly in multibyte locales with
    encodings different from UTF-8.  */
-extern char * mbsstr (const char *haystack, const char *needle);
+extern char * mbsstr (const char *haystack, const char *needle)
+     _GL_ARG_NONNULL ((1, 2));
 #endif
 
 #if @GNULIB_MBSCASECMP@
@@ -466,7 +482,8 @@ extern char * mbsstr (const char *haystack, const char *needle);
    Note: This function may, in multibyte locales, return 0 for strings of
    different lengths!
    Unlike strcasecmp(), this function works correctly in multibyte locales.  */
-extern int mbscasecmp (const char *s1, const char *s2);
+extern int mbscasecmp (const char *s1, const char *s2)
+     _GL_ARG_NONNULL ((1, 2));
 #endif
 
 #if @GNULIB_MBSNCASECMP@
@@ -479,7 +496,8 @@ extern int mbscasecmp (const char *s1, const char *s2);
    of different lengths!
    Unlike strncasecmp(), this function works correctly in multibyte locales.
    But beware that N is not a byte count but a character count!  */
-extern int mbsncasecmp (const char *s1, const char *s2, size_t n);
+extern int mbsncasecmp (const char *s1, const char *s2, size_t n)
+     _GL_ARG_NONNULL ((1, 2));
 #endif
 
 #if @GNULIB_MBSPCASECMP@
@@ -492,7 +510,8 @@ extern int mbsncasecmp (const char *s1, const char *s2, size_t n);
    smaller length than PREFIX!
    Unlike strncasecmp(), this function works correctly in multibyte
    locales.  */
-extern char * mbspcasecmp (const char *string, const char *prefix);
+extern char * mbspcasecmp (const char *string, const char *prefix)
+     _GL_ARG_NONNULL ((1, 2));
 #endif
 
 #if @GNULIB_MBSCASESTR@
@@ -501,7 +520,8 @@ extern char * mbspcasecmp (const char *string, const char *prefix);
    Note: This function may, in multibyte locales, return success even if
    strlen (haystack) < strlen (needle) !
    Unlike strcasestr(), this function works correctly in multibyte locales.  */
-extern char * mbscasestr (const char *haystack, const char *needle);
+extern char * mbscasestr (const char *haystack, const char *needle)
+     _GL_ARG_NONNULL ((1, 2));
 #endif
 
 #if @GNULIB_MBSCSPN@
@@ -510,7 +530,8 @@ extern char * mbscasestr (const char *haystack, const char *needle);
    beginning of the string to this occurrence, or to the end of the string
    if none exists.
    Unlike strcspn(), this function works correctly in multibyte locales.  */
-extern size_t mbscspn (const char *string, const char *accept);
+extern size_t mbscspn (const char *string, const char *accept)
+     _GL_ARG_NONNULL ((1, 2));
 #endif
 
 #if @GNULIB_MBSPBRK@
@@ -519,7 +540,8 @@ extern size_t mbscspn (const char *string, const char *accept);
    exists.
    Unlike strpbrk(), this function works correctly in multibyte locales.  */
 # define mbspbrk rpl_mbspbrk /* avoid collision with HP-UX function */
-extern char * mbspbrk (const char *string, const char *accept);
+extern char * mbspbrk (const char *string, const char *accept)
+     _GL_ARG_NONNULL ((1, 2));
 #endif
 
 #if @GNULIB_MBSSPN@
@@ -528,7 +550,8 @@ extern char * mbspbrk (const char *string, const char *accept);
    beginning of the string to this occurrence, or to the end of the string
    if none exists.
    Unlike strspn(), this function works correctly in multibyte locales.  */
-extern size_t mbsspn (const char *string, const char *reject);
+extern size_t mbsspn (const char *string, const char *reject)
+     _GL_ARG_NONNULL ((1, 2));
 #endif
 
 #if @GNULIB_MBSSEP@
@@ -546,7 +569,8 @@ extern size_t mbsspn (const char *string, const char *reject);
    Caveat: The identity of the delimiting character is lost.
 
    See also mbstok_r().  */
-extern char * mbssep (char **stringp, const char *delim);
+extern char * mbssep (char **stringp, const char *delim)
+     _GL_ARG_NONNULL ((1, 2));
 #endif
 
 #if @GNULIB_MBSTOK_R@
@@ -554,19 +578,20 @@ extern char * mbssep (char **stringp, const char *delim);
    the character string DELIM.
    If STRING is NULL, the saved pointer in SAVE_PTR is used as
    the next starting point.  For example:
-	char s[] = "-abc-=-def";
-	char *sp;
-	x = mbstok_r(s, "-", &sp);	// x = "abc", sp = "=-def"
-	x = mbstok_r(NULL, "-=", &sp);	// x = "def", sp = NULL
-	x = mbstok_r(NULL, "=", &sp);	// x = NULL
-		// s = "abc\0-def\0"
+        char s[] = "-abc-=-def";
+        char *sp;
+        x = mbstok_r(s, "-", &sp);      // x = "abc", sp = "=-def"
+        x = mbstok_r(NULL, "-=", &sp);  // x = "def", sp = NULL
+        x = mbstok_r(NULL, "=", &sp);   // x = NULL
+                // s = "abc\0-def\0"
 
    Caveat: It modifies the original string.
    Caveat: These functions cannot be used on constant strings.
    Caveat: The identity of the delimiting character is lost.
 
    See also mbssep().  */
-extern char * mbstok_r (char *string, const char *delim, char **save_ptr);
+extern char * mbstok_r (char *string, const char *delim, char **save_ptr)
+     _GL_ARG_NONNULL ((2, 3));
 #endif
 
 /* Map any int, typically from errno, into an error message.  */
@@ -601,7 +626,7 @@ extern char *strsignal (int __sig);
 
 #if @GNULIB_STRVERSCMP@
 # if !@HAVE_STRVERSCMP@
-extern int strverscmp (const char *, const char *);
+extern int strverscmp (const char *, const char *) _GL_ARG_NONNULL ((1, 2));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef strverscmp
diff --git a/libmissing/strings.in.h b/libmissing/strings.in.h
index bd767de..8e2b95c 100644
--- a/libmissing/strings.in.h
+++ b/libmissing/strings.in.h
@@ -1,6 +1,6 @@
 /* A substitute <strings.h>.
 
-   Copyright (C) 2007-2008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -31,6 +31,8 @@
 
 /* The definition of GL_LINK_WARNING is copied here.  */
 
+/* The definition of _GL_ARG_NONNULL is copied here.  */
+
 
 #ifdef __cplusplus
 extern "C" {
@@ -42,7 +44,8 @@ extern "C" {
    than S2.
    Note: This function does not work in multibyte locales.  */
 #if ! @HAVE_STRCASECMP@
-extern int strcasecmp (char const *s1, char const *s2);
+extern int strcasecmp (char const *s1, char const *s2)
+     _GL_ARG_NONNULL ((1, 2));
 #endif
 #if defined GNULIB_POSIXCHECK
 /* strcasecmp() does not work with multibyte strings:
@@ -64,7 +67,8 @@ extern int strcasecmp (char const *s1, char const *s2);
    lexicographically less than, equal to or greater than S2.
    Note: This function cannot work correctly in multibyte locales.  */
 #if ! @HAVE_DECL_STRNCASECMP@
-extern int strncasecmp (char const *s1, char const *s2, size_t n);
+extern int strncasecmp (char const *s1, char const *s2, size_t n)
+     _GL_ARG_NONNULL ((1, 2));
 #endif
 #if defined GNULIB_POSIXCHECK
 /* strncasecmp() does not work with multibyte strings:
diff --git a/libmissing/strncasecmp.c b/libmissing/strncasecmp.c
index 3386ce2..4a2eb1e 100644
--- a/libmissing/strncasecmp.c
+++ b/libmissing/strncasecmp.c
@@ -1,5 +1,5 @@
 /* strncasecmp.c -- case insensitive string comparator
-   Copyright (C) 1998-1999, 2005-2007 Free Software Foundation, Inc.
+   Copyright (C) 1998-1999, 2005-2007, 2009 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -46,7 +46,7 @@ strncasecmp (const char *s1, const char *s2, size_t n)
       c2 = TOLOWER (*p2);
 
       if (--n == 0 || c1 == '\0')
-	break;
+        break;
 
       ++p1;
       ++p2;
diff --git a/libmissing/strnlen1.c b/libmissing/strnlen1.c
index 0b678e9..b01dee0 100644
--- a/libmissing/strnlen1.c
+++ b/libmissing/strnlen1.c
@@ -1,5 +1,5 @@
 /* Find the length of STRING + 1, but scan at most MAXLEN bytes.
-   Copyright (C) 2005-2006 Free Software Foundation, Inc.
+   Copyright (C) 2005-2006, 2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/libmissing/strnlen1.h b/libmissing/strnlen1.h
index 1171781..3698fec 100644
--- a/libmissing/strnlen1.h
+++ b/libmissing/strnlen1.h
@@ -1,5 +1,5 @@
 /* Find the length of STRING + 1, but scan at most MAXLEN bytes.
-   Copyright (C) 2005 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/libmissing/strptime.c b/libmissing/strptime.c
index e364d5e..0172f7b 100644
--- a/libmissing/strptime.c
+++ b/libmissing/strptime.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2004, 2005, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    This program is free software; you can redistribute it and/or modify
@@ -43,9 +43,9 @@ enum ptime_locale_status { not, loc, raw };
 #define match_char(ch1, ch2) if (ch1 != ch2) return NULL
 #if defined _LIBC && defined __GNUC__ && __GNUC__ >= 2
 # define match_string(cs1, s2) \
-  ({ size_t len = strlen (cs1);						      \
-     int result = __strncasecmp_l ((cs1), (s2), len, locale) == 0;	      \
-     if (result) (s2) += len;						      \
+  ({ size_t len = strlen (cs1);                                               \
+     int result = __strncasecmp_l ((cs1), (s2), len, locale) == 0;            \
+     if (result) (s2) += len;                                                 \
      result; })
 #else
 /* Oh come on.  Get a reasonable compiler.  */
@@ -55,52 +55,52 @@ enum ptime_locale_status { not, loc, raw };
 /* We intentionally do not use isdigit() for testing because this will
    lead to problems with the wide character version.  */
 #define get_number(from, to, n) \
-  do {									      \
-    int __n = n;							      \
-    val = 0;								      \
-    while (*rp == ' ')							      \
-      ++rp;								      \
-    if (*rp < '0' || *rp > '9')						      \
-      return NULL;							      \
-    do {								      \
-      val *= 10;							      \
-      val += *rp++ - '0';						      \
-    } while (--__n > 0 && val * 10 <= to && *rp >= '0' && *rp <= '9');	      \
-    if (val < from || val > to)						      \
-      return NULL;							      \
+  do {                                                                        \
+    int __n = n;                                                              \
+    val = 0;                                                                  \
+    while (*rp == ' ')                                                        \
+      ++rp;                                                                   \
+    if (*rp < '0' || *rp > '9')                                               \
+      return NULL;                                                            \
+    do {                                                                      \
+      val *= 10;                                                              \
+      val += *rp++ - '0';                                                     \
+    } while (--__n > 0 && val * 10 <= to && *rp >= '0' && *rp <= '9');        \
+    if (val < from || val > to)                                               \
+      return NULL;                                                            \
   } while (0)
 #ifdef _NL_CURRENT
 # define get_alt_number(from, to, n) \
-  ({									      \
-     __label__ do_normal;						      \
-									      \
-     if (*decided != raw)						      \
-       {								      \
-	 val = _nl_parse_alt_digit (&rp HELPER_LOCALE_ARG);		      \
-	 if (val == -1 && *decided != loc)				      \
-	   {								      \
-	     *decided = loc;						      \
-	     goto do_normal;						      \
-	   }								      \
-	if (val < from || val > to)					      \
-	  return NULL;							      \
-       }								      \
-     else								      \
-       {								      \
-       do_normal:							      \
-	 get_number (from, to, n);					      \
-       }								      \
-    0;									      \
+  ({                                                                          \
+     __label__ do_normal;                                                     \
+                                                                              \
+     if (*decided != raw)                                                     \
+       {                                                                      \
+         val = _nl_parse_alt_digit (&rp HELPER_LOCALE_ARG);                   \
+         if (val == -1 && *decided != loc)                                    \
+           {                                                                  \
+             *decided = loc;                                                  \
+             goto do_normal;                                                  \
+           }                                                                  \
+        if (val < from || val > to)                                           \
+          return NULL;                                                        \
+       }                                                                      \
+     else                                                                     \
+       {                                                                      \
+       do_normal:                                                             \
+         get_number (from, to, n);                                            \
+       }                                                                      \
+    0;                                                                        \
   })
 #else
 # define get_alt_number(from, to, n) \
-  /* We don't have the alternate representation.  */			      \
+  /* We don't have the alternate representation.  */                          \
   get_number(from, to, n)
 #endif
 #define recursive(new_fmt) \
-  (*(new_fmt) != '\0'							      \
-   && (rp = __strptime_internal (rp, (new_fmt), tm,			      \
-				 decided, era_cnt LOCALE_ARG)) != NULL)
+  (*(new_fmt) != '\0'                                                         \
+   && (rp = __strptime_internal (rp, (new_fmt), tm,                           \
+                                 decided, era_cnt LOCALE_ARG)) != NULL)
 
 
 #ifdef _LIBC
@@ -162,7 +162,7 @@ static const unsigned short int __mon_yday[2][13] =
    function gets as an additional argument the locale which has to be
    used.  To access the values we have to redefine the _NL_CURRENT
    macro.  */
-# define strptime		__strptime_l
+# define strptime               __strptime_l
 # undef _NL_CURRENT
 # define _NL_CURRENT(category, item) \
   (current->values[_NL_ITEM_INDEX (item)].string)
@@ -190,7 +190,7 @@ static const unsigned short int __mon_yday[2][13] =
 #ifndef __isleap
 /* Nonzero if YEAR is a leap year (every 4 years,
    except every 100th isn't, and every 400th is).  */
-# define __isleap(year)	\
+# define __isleap(year) \
   ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
 #endif
 
@@ -203,12 +203,12 @@ day_of_the_week (struct tm *tm)
      the weekday.  */
   int corr_year = 1900 + tm->tm_year - (tm->tm_mon < 2);
   int wday = (-473
-	      + (365 * (tm->tm_year - 70))
-	      + (corr_year / 4)
-	      - ((corr_year / 4) / 25) + ((corr_year / 4) % 25 < 0)
-	      + (((corr_year / 4) / 25) / 4)
-	      + __mon_yday[0][tm->tm_mon]
-	      + tm->tm_mday - 1);
+              + (365 * (tm->tm_year - 70))
+              + (corr_year / 4)
+              - ((corr_year / 4) / 25) + ((corr_year / 4) % 25 < 0)
+              + (((corr_year / 4) / 25) / 4)
+              + __mon_yday[0][tm->tm_mon]
+              + tm->tm_mday - 1);
   tm->tm_wday = ((wday % 7) + 7) % 7;
 }
 
@@ -217,7 +217,7 @@ static void
 day_of_the_year (struct tm *tm)
 {
   tm->tm_yday = (__mon_yday[__isleap (1900 + tm->tm_year)][tm->tm_mon]
-		 + (tm->tm_mday - 1));
+                 + (tm->tm_mday - 1));
 }
 
 
@@ -266,22 +266,22 @@ __strptime_internal (rp, fmt, tm, decided, era_cnt LOCALE_PARAM)
   while (*fmt != '\0')
     {
       /* A white space in the format string matches 0 more or white
-	 space in the input string.  */
+         space in the input string.  */
       if (ISSPACE (*fmt))
-	{
-	  while (ISSPACE (*rp))
-	    ++rp;
-	  ++fmt;
-	  continue;
-	}
+        {
+          while (ISSPACE (*rp))
+            ++rp;
+          ++fmt;
+          continue;
+        }
 
       /* Any character but `%' must be matched by the same character
-	 in the iput string.  */
+         in the iput string.  */
       if (*fmt != '%')
-	{
-	  match_char (*fmt++, *rp++);
-	  continue;
-	}
+        {
+          match_char (*fmt++, *rp++);
+          continue;
+        }
 
       ++fmt;
 #ifndef _NL_CURRENT
@@ -293,729 +293,729 @@ __strptime_internal (rp, fmt, tm, decided, era_cnt LOCALE_PARAM)
       rp_backup = rp;
 
       switch (*fmt++)
-	{
-	case '%':
-	  /* Match the `%' character itself.  */
-	  match_char ('%', *rp++);
-	  break;
-	case 'a':
-	case 'A':
-	  /* Match day of week.  */
-	  for (cnt = 0; cnt < 7; ++cnt)
-	    {
+        {
+        case '%':
+          /* Match the `%' character itself.  */
+          match_char ('%', *rp++);
+          break;
+        case 'a':
+        case 'A':
+          /* Match day of week.  */
+          for (cnt = 0; cnt < 7; ++cnt)
+            {
 #ifdef _NL_CURRENT
-	      if (*decided !=raw)
-		{
-		  if (match_string (_NL_CURRENT (LC_TIME, DAY_1 + cnt), rp))
-		    {
-		      if (*decided == not
-			  && strcmp (_NL_CURRENT (LC_TIME, DAY_1 + cnt),
-				     weekday_name[cnt]))
-			*decided = loc;
-		      break;
-		    }
-		  if (match_string (_NL_CURRENT (LC_TIME, ABDAY_1 + cnt), rp))
-		    {
-		      if (*decided == not
-			  && strcmp (_NL_CURRENT (LC_TIME, ABDAY_1 + cnt),
-				     ab_weekday_name[cnt]))
-			*decided = loc;
-		      break;
-		    }
-		}
+              if (*decided !=raw)
+                {
+                  if (match_string (_NL_CURRENT (LC_TIME, DAY_1 + cnt), rp))
+                    {
+                      if (*decided == not
+                          && strcmp (_NL_CURRENT (LC_TIME, DAY_1 + cnt),
+                                     weekday_name[cnt]))
+                        *decided = loc;
+                      break;
+                    }
+                  if (match_string (_NL_CURRENT (LC_TIME, ABDAY_1 + cnt), rp))
+                    {
+                      if (*decided == not
+                          && strcmp (_NL_CURRENT (LC_TIME, ABDAY_1 + cnt),
+                                     ab_weekday_name[cnt]))
+                        *decided = loc;
+                      break;
+                    }
+                }
 #endif
-	      if (*decided != loc
-		  && (match_string (weekday_name[cnt], rp)
-		      || match_string (ab_weekday_name[cnt], rp)))
-		{
-		  *decided = raw;
-		  break;
-		}
-	    }
-	  if (cnt == 7)
-	    /* Does not match a weekday name.  */
-	    return NULL;
-	  tm->tm_wday = cnt;
-	  have_wday = 1;
-	  break;
-	case 'b':
-	case 'B':
-	case 'h':
-	  /* Match month name.  */
-	  for (cnt = 0; cnt < 12; ++cnt)
-	    {
+              if (*decided != loc
+                  && (match_string (weekday_name[cnt], rp)
+                      || match_string (ab_weekday_name[cnt], rp)))
+                {
+                  *decided = raw;
+                  break;
+                }
+            }
+          if (cnt == 7)
+            /* Does not match a weekday name.  */
+            return NULL;
+          tm->tm_wday = cnt;
+          have_wday = 1;
+          break;
+        case 'b':
+        case 'B':
+        case 'h':
+          /* Match month name.  */
+          for (cnt = 0; cnt < 12; ++cnt)
+            {
 #ifdef _NL_CURRENT
-	      if (*decided !=raw)
-		{
-		  if (match_string (_NL_CURRENT (LC_TIME, MON_1 + cnt), rp))
-		    {
-		      if (*decided == not
-			  && strcmp (_NL_CURRENT (LC_TIME, MON_1 + cnt),
-				     month_name[cnt]))
-			*decided = loc;
-		      break;
-		    }
-		  if (match_string (_NL_CURRENT (LC_TIME, ABMON_1 + cnt), rp))
-		    {
-		      if (*decided == not
-			  && strcmp (_NL_CURRENT (LC_TIME, ABMON_1 + cnt),
-				     ab_month_name[cnt]))
-			*decided = loc;
-		      break;
-		    }
-		}
+              if (*decided !=raw)
+                {
+                  if (match_string (_NL_CURRENT (LC_TIME, MON_1 + cnt), rp))
+                    {
+                      if (*decided == not
+                          && strcmp (_NL_CURRENT (LC_TIME, MON_1 + cnt),
+                                     month_name[cnt]))
+                        *decided = loc;
+                      break;
+                    }
+                  if (match_string (_NL_CURRENT (LC_TIME, ABMON_1 + cnt), rp))
+                    {
+                      if (*decided == not
+                          && strcmp (_NL_CURRENT (LC_TIME, ABMON_1 + cnt),
+                                     ab_month_name[cnt]))
+                        *decided = loc;
+                      break;
+                    }
+                }
 #endif
-	      if (match_string (month_name[cnt], rp)
-		  || match_string (ab_month_name[cnt], rp))
-		{
-		  *decided = raw;
-		  break;
-		}
-	    }
-	  if (cnt == 12)
-	    /* Does not match a month name.  */
-	    return NULL;
-	  tm->tm_mon = cnt;
-	  want_xday = 1;
-	  break;
-	case 'c':
-	  /* Match locale's date and time format.  */
+              if (match_string (month_name[cnt], rp)
+                  || match_string (ab_month_name[cnt], rp))
+                {
+                  *decided = raw;
+                  break;
+                }
+            }
+          if (cnt == 12)
+            /* Does not match a month name.  */
+            return NULL;
+          tm->tm_mon = cnt;
+          want_xday = 1;
+          break;
+        case 'c':
+          /* Match locale's date and time format.  */
 #ifdef _NL_CURRENT
-	  if (*decided != raw)
-	    {
-	      if (!recursive (_NL_CURRENT (LC_TIME, D_T_FMT)))
-		{
-		  if (*decided == loc)
-		    return NULL;
-		  else
-		    rp = rp_backup;
-		}
-	      else
-		{
-		  if (*decided == not &&
-		      strcmp (_NL_CURRENT (LC_TIME, D_T_FMT), HERE_D_T_FMT))
-		    *decided = loc;
-		  want_xday = 1;
-		  break;
-		}
-	      *decided = raw;
-	    }
+          if (*decided != raw)
+            {
+              if (!recursive (_NL_CURRENT (LC_TIME, D_T_FMT)))
+                {
+                  if (*decided == loc)
+                    return NULL;
+                  else
+                    rp = rp_backup;
+                }
+              else
+                {
+                  if (*decided == not &&
+                      strcmp (_NL_CURRENT (LC_TIME, D_T_FMT), HERE_D_T_FMT))
+                    *decided = loc;
+                  want_xday = 1;
+                  break;
+                }
+              *decided = raw;
+            }
 #endif
-	  if (!recursive (HERE_D_T_FMT))
-	    return NULL;
-	  want_xday = 1;
-	  break;
-	case 'C':
-	  /* Match century number.  */
-	match_century:
-	  get_number (0, 99, 2);
-	  century = val;
-	  want_xday = 1;
-	  break;
-	case 'd':
-	case 'e':
-	  /* Match day of month.  */
-	  get_number (1, 31, 2);
-	  tm->tm_mday = val;
-	  have_mday = 1;
-	  want_xday = 1;
-	  break;
-	case 'F':
-	  if (!recursive ("%Y-%m-%d"))
-	    return NULL;
-	  want_xday = 1;
-	  break;
-	case 'x':
+          if (!recursive (HERE_D_T_FMT))
+            return NULL;
+          want_xday = 1;
+          break;
+        case 'C':
+          /* Match century number.  */
+        match_century:
+          get_number (0, 99, 2);
+          century = val;
+          want_xday = 1;
+          break;
+        case 'd':
+        case 'e':
+          /* Match day of month.  */
+          get_number (1, 31, 2);
+          tm->tm_mday = val;
+          have_mday = 1;
+          want_xday = 1;
+          break;
+        case 'F':
+          if (!recursive ("%Y-%m-%d"))
+            return NULL;
+          want_xday = 1;
+          break;
+        case 'x':
 #ifdef _NL_CURRENT
-	  if (*decided != raw)
-	    {
-	      if (!recursive (_NL_CURRENT (LC_TIME, D_FMT)))
-		{
-		  if (*decided == loc)
-		    return NULL;
-		  else
-		    rp = rp_backup;
-		}
-	      else
-		{
-		  if (*decided == not
-		      && strcmp (_NL_CURRENT (LC_TIME, D_FMT), HERE_D_FMT))
-		    *decided = loc;
-		  want_xday = 1;
-		  break;
-		}
-	      *decided = raw;
-	    }
+          if (*decided != raw)
+            {
+              if (!recursive (_NL_CURRENT (LC_TIME, D_FMT)))
+                {
+                  if (*decided == loc)
+                    return NULL;
+                  else
+                    rp = rp_backup;
+                }
+              else
+                {
+                  if (*decided == not
+                      && strcmp (_NL_CURRENT (LC_TIME, D_FMT), HERE_D_FMT))
+                    *decided = loc;
+                  want_xday = 1;
+                  break;
+                }
+              *decided = raw;
+            }
 #endif
-	  /* Fall through.  */
-	case 'D':
-	  /* Match standard day format.  */
-	  if (!recursive (HERE_D_FMT))
-	    return NULL;
-	  want_xday = 1;
-	  break;
-	case 'k':
-	case 'H':
-	  /* Match hour in 24-hour clock.  */
-	  get_number (0, 23, 2);
-	  tm->tm_hour = val;
-	  have_I = 0;
-	  break;
-	case 'l':
-	  /* Match hour in 12-hour clock.  GNU extension.  */
-	case 'I':
-	  /* Match hour in 12-hour clock.  */
-	  get_number (1, 12, 2);
-	  tm->tm_hour = val % 12;
-	  have_I = 1;
-	  break;
-	case 'j':
-	  /* Match day number of year.  */
-	  get_number (1, 366, 3);
-	  tm->tm_yday = val - 1;
-	  have_yday = 1;
-	  break;
-	case 'm':
-	  /* Match number of month.  */
-	  get_number (1, 12, 2);
-	  tm->tm_mon = val - 1;
-	  have_mon = 1;
-	  want_xday = 1;
-	  break;
-	case 'M':
-	  /* Match minute.  */
-	  get_number (0, 59, 2);
-	  tm->tm_min = val;
-	  break;
-	case 'n':
-	case 't':
-	  /* Match any white space.  */
-	  while (ISSPACE (*rp))
-	    ++rp;
-	  break;
-	case 'p':
-	  /* Match locale's equivalent of AM/PM.  */
+          /* Fall through.  */
+        case 'D':
+          /* Match standard day format.  */
+          if (!recursive (HERE_D_FMT))
+            return NULL;
+          want_xday = 1;
+          break;
+        case 'k':
+        case 'H':
+          /* Match hour in 24-hour clock.  */
+          get_number (0, 23, 2);
+          tm->tm_hour = val;
+          have_I = 0;
+          break;
+        case 'l':
+          /* Match hour in 12-hour clock.  GNU extension.  */
+        case 'I':
+          /* Match hour in 12-hour clock.  */
+          get_number (1, 12, 2);
+          tm->tm_hour = val % 12;
+          have_I = 1;
+          break;
+        case 'j':
+          /* Match day number of year.  */
+          get_number (1, 366, 3);
+          tm->tm_yday = val - 1;
+          have_yday = 1;
+          break;
+        case 'm':
+          /* Match number of month.  */
+          get_number (1, 12, 2);
+          tm->tm_mon = val - 1;
+          have_mon = 1;
+          want_xday = 1;
+          break;
+        case 'M':
+          /* Match minute.  */
+          get_number (0, 59, 2);
+          tm->tm_min = val;
+          break;
+        case 'n':
+        case 't':
+          /* Match any white space.  */
+          while (ISSPACE (*rp))
+            ++rp;
+          break;
+        case 'p':
+          /* Match locale's equivalent of AM/PM.  */
 #ifdef _NL_CURRENT
-	  if (*decided != raw)
-	    {
-	      if (match_string (_NL_CURRENT (LC_TIME, AM_STR), rp))
-		{
-		  if (strcmp (_NL_CURRENT (LC_TIME, AM_STR), HERE_AM_STR))
-		    *decided = loc;
-		  break;
-		}
-	      if (match_string (_NL_CURRENT (LC_TIME, PM_STR), rp))
-		{
-		  if (strcmp (_NL_CURRENT (LC_TIME, PM_STR), HERE_PM_STR))
-		    *decided = loc;
-		  is_pm = 1;
-		  break;
-		}
-	      *decided = raw;
-	    }
+          if (*decided != raw)
+            {
+              if (match_string (_NL_CURRENT (LC_TIME, AM_STR), rp))
+                {
+                  if (strcmp (_NL_CURRENT (LC_TIME, AM_STR), HERE_AM_STR))
+                    *decided = loc;
+                  break;
+                }
+              if (match_string (_NL_CURRENT (LC_TIME, PM_STR), rp))
+                {
+                  if (strcmp (_NL_CURRENT (LC_TIME, PM_STR), HERE_PM_STR))
+                    *decided = loc;
+                  is_pm = 1;
+                  break;
+                }
+              *decided = raw;
+            }
 #endif
-	  if (!match_string (HERE_AM_STR, rp))
-	    {
-	      if (match_string (HERE_PM_STR, rp))
-		is_pm = 1;
-	      else
-		return NULL;
-	    }
-	  break;
-	case 'r':
+          if (!match_string (HERE_AM_STR, rp))
+            {
+              if (match_string (HERE_PM_STR, rp))
+                is_pm = 1;
+              else
+                return NULL;
+            }
+          break;
+        case 'r':
 #ifdef _NL_CURRENT
-	  if (*decided != raw)
-	    {
-	      if (!recursive (_NL_CURRENT (LC_TIME, T_FMT_AMPM)))
-		{
-		  if (*decided == loc)
-		    return NULL;
-		  else
-		    rp = rp_backup;
-		}
-	      else
-		{
-		  if (*decided == not &&
-		      strcmp (_NL_CURRENT (LC_TIME, T_FMT_AMPM),
-			      HERE_T_FMT_AMPM))
-		    *decided = loc;
-		  break;
-		}
-	      *decided = raw;
-	    }
+          if (*decided != raw)
+            {
+              if (!recursive (_NL_CURRENT (LC_TIME, T_FMT_AMPM)))
+                {
+                  if (*decided == loc)
+                    return NULL;
+                  else
+                    rp = rp_backup;
+                }
+              else
+                {
+                  if (*decided == not &&
+                      strcmp (_NL_CURRENT (LC_TIME, T_FMT_AMPM),
+                              HERE_T_FMT_AMPM))
+                    *decided = loc;
+                  break;
+                }
+              *decided = raw;
+            }
 #endif
-	  if (!recursive (HERE_T_FMT_AMPM))
-	    return NULL;
-	  break;
-	case 'R':
-	  if (!recursive ("%H:%M"))
-	    return NULL;
-	  break;
-	case 's':
-	  {
-	    /* The number of seconds may be very high so we cannot use
-	       the `get_number' macro.  Instead read the number
-	       character for character and construct the result while
-	       doing this.  */
-	    time_t secs = 0;
-	    if (*rp < '0' || *rp > '9')
-	      /* We need at least one digit.  */
-	      return NULL;
-
-	    do
-	      {
-		secs *= 10;
-		secs += *rp++ - '0';
-	      }
-	    while (*rp >= '0' && *rp <= '9');
-
-	    if (localtime_r (&secs, tm) == NULL)
-	      /* Error in function.  */
-	      return NULL;
-	  }
-	  break;
-	case 'S':
-	  get_number (0, 61, 2);
-	  tm->tm_sec = val;
-	  break;
-	case 'X':
+          if (!recursive (HERE_T_FMT_AMPM))
+            return NULL;
+          break;
+        case 'R':
+          if (!recursive ("%H:%M"))
+            return NULL;
+          break;
+        case 's':
+          {
+            /* The number of seconds may be very high so we cannot use
+               the `get_number' macro.  Instead read the number
+               character for character and construct the result while
+               doing this.  */
+            time_t secs = 0;
+            if (*rp < '0' || *rp > '9')
+              /* We need at least one digit.  */
+              return NULL;
+
+            do
+              {
+                secs *= 10;
+                secs += *rp++ - '0';
+              }
+            while (*rp >= '0' && *rp <= '9');
+
+            if (localtime_r (&secs, tm) == NULL)
+              /* Error in function.  */
+              return NULL;
+          }
+          break;
+        case 'S':
+          get_number (0, 61, 2);
+          tm->tm_sec = val;
+          break;
+        case 'X':
 #ifdef _NL_CURRENT
-	  if (*decided != raw)
-	    {
-	      if (!recursive (_NL_CURRENT (LC_TIME, T_FMT)))
-		{
-		  if (*decided == loc)
-		    return NULL;
-		  else
-		    rp = rp_backup;
-		}
-	      else
-		{
-		  if (strcmp (_NL_CURRENT (LC_TIME, T_FMT), HERE_T_FMT))
-		    *decided = loc;
-		  break;
-		}
-	      *decided = raw;
-	    }
+          if (*decided != raw)
+            {
+              if (!recursive (_NL_CURRENT (LC_TIME, T_FMT)))
+                {
+                  if (*decided == loc)
+                    return NULL;
+                  else
+                    rp = rp_backup;
+                }
+              else
+                {
+                  if (strcmp (_NL_CURRENT (LC_TIME, T_FMT), HERE_T_FMT))
+                    *decided = loc;
+                  break;
+                }
+              *decided = raw;
+            }
 #endif
-	  /* Fall through.  */
-	case 'T':
-	  if (!recursive (HERE_T_FMT))
-	    return NULL;
-	  break;
-	case 'u':
-	  get_number (1, 7, 1);
-	  tm->tm_wday = val % 7;
-	  have_wday = 1;
-	  break;
-	case 'g':
-	  get_number (0, 99, 2);
-	  /* XXX This cannot determine any field in TM.  */
-	  break;
-	case 'G':
-	  if (*rp < '0' || *rp > '9')
-	    return NULL;
-	  /* XXX Ignore the number since we would need some more
-	     information to compute a real date.  */
-	  do
-	    ++rp;
-	  while (*rp >= '0' && *rp <= '9');
-	  break;
-	case 'U':
-	  get_number (0, 53, 2);
-	  week_no = val;
-	  have_uweek = 1;
-	  break;
-	case 'W':
-	  get_number (0, 53, 2);
-	  week_no = val;
-	  have_wweek = 1;
-	  break;
-	case 'V':
-	  get_number (0, 53, 2);
-	  /* XXX This cannot determine any field in TM without some
-	     information.  */
-	  break;
-	case 'w':
-	  /* Match number of weekday.  */
-	  get_number (0, 6, 1);
-	  tm->tm_wday = val;
-	  have_wday = 1;
-	  break;
-	case 'y':
-	match_year_in_century:
-	  /* Match year within century.  */
-	  get_number (0, 99, 2);
-	  /* The "Year 2000: The Millennium Rollover" paper suggests that
-	     values in the range 69-99 refer to the twentieth century.  */
-	  tm->tm_year = val >= 69 ? val : val + 100;
-	  /* Indicate that we want to use the century, if specified.  */
-	  want_century = 1;
-	  want_xday = 1;
-	  break;
-	case 'Y':
-	  /* Match year including century number.  */
-	  get_number (0, 9999, 4);
-	  tm->tm_year = val - 1900;
-	  want_century = 0;
-	  want_xday = 1;
-	  break;
-	case 'Z':
-	  /* XXX How to handle this?  */
-	  break;
-	case 'z':
-	  /* We recognize two formats: if two digits are given, these
-	     specify hours.  If fours digits are used, minutes are
-	     also specified.  */
-	  {
-	    bool neg;
-	    int n;
-
-	    val = 0;
-	    while (*rp == ' ')
-	      ++rp;
-	    if (*rp != '+' && *rp != '-')
-	      return NULL;
-	    neg = *rp++ == '-';
-	    n = 0;
-	    while (n < 4 && *rp >= '0' && *rp <= '9')
-	      {
-		val = val * 10 + *rp++ - '0';
-		++n;
-	      }
-	    if (n == 2)
-	      val *= 100;
-	    else if (n != 4)
-	      /* Only two or four digits recognized.  */
-	      return NULL;
-	    else
-	      {
-		/* We have to convert the minutes into decimal.  */
-		if (val % 100 >= 60)
-		  return NULL;
-		val = (val / 100) * 100 + ((val % 100) * 50) / 30;
-	      }
-	    if (val > 1200)
-	      return NULL;
+          /* Fall through.  */
+        case 'T':
+          if (!recursive (HERE_T_FMT))
+            return NULL;
+          break;
+        case 'u':
+          get_number (1, 7, 1);
+          tm->tm_wday = val % 7;
+          have_wday = 1;
+          break;
+        case 'g':
+          get_number (0, 99, 2);
+          /* XXX This cannot determine any field in TM.  */
+          break;
+        case 'G':
+          if (*rp < '0' || *rp > '9')
+            return NULL;
+          /* XXX Ignore the number since we would need some more
+             information to compute a real date.  */
+          do
+            ++rp;
+          while (*rp >= '0' && *rp <= '9');
+          break;
+        case 'U':
+          get_number (0, 53, 2);
+          week_no = val;
+          have_uweek = 1;
+          break;
+        case 'W':
+          get_number (0, 53, 2);
+          week_no = val;
+          have_wweek = 1;
+          break;
+        case 'V':
+          get_number (0, 53, 2);
+          /* XXX This cannot determine any field in TM without some
+             information.  */
+          break;
+        case 'w':
+          /* Match number of weekday.  */
+          get_number (0, 6, 1);
+          tm->tm_wday = val;
+          have_wday = 1;
+          break;
+        case 'y':
+        match_year_in_century:
+          /* Match year within century.  */
+          get_number (0, 99, 2);
+          /* The "Year 2000: The Millennium Rollover" paper suggests that
+             values in the range 69-99 refer to the twentieth century.  */
+          tm->tm_year = val >= 69 ? val : val + 100;
+          /* Indicate that we want to use the century, if specified.  */
+          want_century = 1;
+          want_xday = 1;
+          break;
+        case 'Y':
+          /* Match year including century number.  */
+          get_number (0, 9999, 4);
+          tm->tm_year = val - 1900;
+          want_century = 0;
+          want_xday = 1;
+          break;
+        case 'Z':
+          /* XXX How to handle this?  */
+          break;
+        case 'z':
+          /* We recognize two formats: if two digits are given, these
+             specify hours.  If fours digits are used, minutes are
+             also specified.  */
+          {
+            bool neg;
+            int n;
+
+            val = 0;
+            while (*rp == ' ')
+              ++rp;
+            if (*rp != '+' && *rp != '-')
+              return NULL;
+            neg = *rp++ == '-';
+            n = 0;
+            while (n < 4 && *rp >= '0' && *rp <= '9')
+              {
+                val = val * 10 + *rp++ - '0';
+                ++n;
+              }
+            if (n == 2)
+              val *= 100;
+            else if (n != 4)
+              /* Only two or four digits recognized.  */
+              return NULL;
+            else
+              {
+                /* We have to convert the minutes into decimal.  */
+                if (val % 100 >= 60)
+                  return NULL;
+                val = (val / 100) * 100 + ((val % 100) * 50) / 30;
+              }
+            if (val > 1200)
+              return NULL;
 #if defined _LIBC || HAVE_TM_GMTOFF
-	    tm->tm_gmtoff = (val * 3600) / 100;
-	    if (neg)
-	      tm->tm_gmtoff = -tm->tm_gmtoff;
+            tm->tm_gmtoff = (val * 3600) / 100;
+            if (neg)
+              tm->tm_gmtoff = -tm->tm_gmtoff;
 #endif
-	  }
-	  break;
-	case 'E':
+          }
+          break;
+        case 'E':
 #ifdef _NL_CURRENT
-	  switch (*fmt++)
-	    {
-	    case 'c':
-	      /* Match locale's alternate date and time format.  */
-	      if (*decided != raw)
-		{
-		  const char *fmt = _NL_CURRENT (LC_TIME, ERA_D_T_FMT);
-
-		  if (*fmt == '\0')
-		    fmt = _NL_CURRENT (LC_TIME, D_T_FMT);
-
-		  if (!recursive (fmt))
-		    {
-		      if (*decided == loc)
-			return NULL;
-		      else
-			rp = rp_backup;
-		    }
-		  else
-		    {
-		      if (strcmp (fmt, HERE_D_T_FMT))
-			*decided = loc;
-		      want_xday = 1;
-		      break;
-		    }
-		  *decided = raw;
-		}
-	      /* The C locale has no era information, so use the
-		 normal representation.  */
-	      if (!recursive (HERE_D_T_FMT))
-		return NULL;
-	      want_xday = 1;
-	      break;
-	    case 'C':
-	      if (*decided != raw)
-		{
-		  if (era_cnt >= 0)
-		    {
-		      era = _nl_select_era_entry (era_cnt HELPER_LOCALE_ARG);
-		      if (era != NULL && match_string (era->era_name, rp))
-			{
-			  *decided = loc;
-			  break;
-			}
-		      else
-			return NULL;
-		    }
-
-		  num_eras = _NL_CURRENT_WORD (LC_TIME,
-					       _NL_TIME_ERA_NUM_ENTRIES);
-		  for (era_cnt = 0; era_cnt < (int) num_eras;
-		       ++era_cnt, rp = rp_backup)
-		    {
-		      era = _nl_select_era_entry (era_cnt
-						  HELPER_LOCALE_ARG);
-		      if (era != NULL && match_string (era->era_name, rp))
-			{
-			  *decided = loc;
-			  break;
-			}
-		    }
-		  if (era_cnt != (int) num_eras)
-		    break;
-
-		  era_cnt = -1;
-		  if (*decided == loc)
-		    return NULL;
-
-		  *decided = raw;
-		}
-	      /* The C locale has no era information, so use the
-		 normal representation.  */
-	      goto match_century;
- 	    case 'y':
-	      if (*decided != raw)
-		{
-		  get_number(0, 9999, 4);
-		  tm->tm_year = val;
-		  want_era = 1;
-		  want_xday = 1;
-		  want_century = 1;
-
-		  if (era_cnt >= 0)
-		    {
-		      assert (*decided == loc);
-
-		      era = _nl_select_era_entry (era_cnt HELPER_LOCALE_ARG);
-		      bool match = false;
-		      if (era != NULL)
-			{
-			  int delta = ((tm->tm_year - era->offset)
-				       * era->absolute_direction);
-			  match = (delta >= 0
-				   && delta < (((int64_t) era->stop_date[0]
-						- (int64_t) era->start_date[0])
-					       * era->absolute_direction));
-			}
-		      if (! match)
-			return NULL;
-
-		      break;
-		    }
-
-		  num_eras = _NL_CURRENT_WORD (LC_TIME,
-					       _NL_TIME_ERA_NUM_ENTRIES);
-		  for (era_cnt = 0; era_cnt < (int) num_eras; ++era_cnt)
-		    {
-		      era = _nl_select_era_entry (era_cnt
-						  HELPER_LOCALE_ARG);
-		      if (era != NULL)
-			{
-			  int delta = ((tm->tm_year - era->offset)
-				       * era->absolute_direction);
-			  if (delta >= 0
-			      && delta < (((int64_t) era->stop_date[0]
-					   - (int64_t) era->start_date[0])
-					  * era->absolute_direction))
-			    {
-			      *decided = loc;
-			      break;
-			    }
-			}
-		    }
-		  if (era_cnt != (int) num_eras)
-		    break;
-
-		  era_cnt = -1;
-		  if (*decided == loc)
-		    return NULL;
-
-		  *decided = raw;
-		}
-
-	      goto match_year_in_century;
-	    case 'Y':
-	      if (*decided != raw)
-		{
-		  num_eras = _NL_CURRENT_WORD (LC_TIME,
-					       _NL_TIME_ERA_NUM_ENTRIES);
-		  for (era_cnt = 0; era_cnt < (int) num_eras;
-		       ++era_cnt, rp = rp_backup)
-		    {
-		      era = _nl_select_era_entry (era_cnt HELPER_LOCALE_ARG);
-		      if (era != NULL && recursive (era->era_format))
-			break;
-		    }
-		  if (era_cnt == (int) num_eras)
-		    {
-		      era_cnt = -1;
-		      if (*decided == loc)
-			return NULL;
-		      else
-			rp = rp_backup;
-		    }
-		  else
-		    {
-		      *decided = loc;
-		      era_cnt = -1;
-		      break;
-		    }
-
-		  *decided = raw;
-		}
-	      get_number (0, 9999, 4);
-	      tm->tm_year = val - 1900;
-	      want_century = 0;
-	      want_xday = 1;
-	      break;
-	    case 'x':
-	      if (*decided != raw)
-		{
-		  const char *fmt = _NL_CURRENT (LC_TIME, ERA_D_FMT);
-
-		  if (*fmt == '\0')
-		    fmt = _NL_CURRENT (LC_TIME, D_FMT);
-
-		  if (!recursive (fmt))
-		    {
-		      if (*decided == loc)
-			return NULL;
-		      else
-			rp = rp_backup;
-		    }
-		  else
-		    {
-		      if (strcmp (fmt, HERE_D_FMT))
-			*decided = loc;
-		      break;
-		    }
-		  *decided = raw;
-		}
-	      if (!recursive (HERE_D_FMT))
-		return NULL;
-	      break;
-	    case 'X':
-	      if (*decided != raw)
-		{
-		  const char *fmt = _NL_CURRENT (LC_TIME, ERA_T_FMT);
-
-		  if (*fmt == '\0')
-		    fmt = _NL_CURRENT (LC_TIME, T_FMT);
-
-		  if (!recursive (fmt))
-		    {
-		      if (*decided == loc)
-			return NULL;
-		      else
-			rp = rp_backup;
-		    }
-		  else
-		    {
-		      if (strcmp (fmt, HERE_T_FMT))
-			*decided = loc;
-		      break;
-		    }
-		  *decided = raw;
-		}
-	      if (!recursive (HERE_T_FMT))
-		return NULL;
-	      break;
-	    default:
-	      return NULL;
-	    }
-	  break;
+          switch (*fmt++)
+            {
+            case 'c':
+              /* Match locale's alternate date and time format.  */
+              if (*decided != raw)
+                {
+                  const char *fmt = _NL_CURRENT (LC_TIME, ERA_D_T_FMT);
+
+                  if (*fmt == '\0')
+                    fmt = _NL_CURRENT (LC_TIME, D_T_FMT);
+
+                  if (!recursive (fmt))
+                    {
+                      if (*decided == loc)
+                        return NULL;
+                      else
+                        rp = rp_backup;
+                    }
+                  else
+                    {
+                      if (strcmp (fmt, HERE_D_T_FMT))
+                        *decided = loc;
+                      want_xday = 1;
+                      break;
+                    }
+                  *decided = raw;
+                }
+              /* The C locale has no era information, so use the
+                 normal representation.  */
+              if (!recursive (HERE_D_T_FMT))
+                return NULL;
+              want_xday = 1;
+              break;
+            case 'C':
+              if (*decided != raw)
+                {
+                  if (era_cnt >= 0)
+                    {
+                      era = _nl_select_era_entry (era_cnt HELPER_LOCALE_ARG);
+                      if (era != NULL && match_string (era->era_name, rp))
+                        {
+                          *decided = loc;
+                          break;
+                        }
+                      else
+                        return NULL;
+                    }
+
+                  num_eras = _NL_CURRENT_WORD (LC_TIME,
+                                               _NL_TIME_ERA_NUM_ENTRIES);
+                  for (era_cnt = 0; era_cnt < (int) num_eras;
+                       ++era_cnt, rp = rp_backup)
+                    {
+                      era = _nl_select_era_entry (era_cnt
+                                                  HELPER_LOCALE_ARG);
+                      if (era != NULL && match_string (era->era_name, rp))
+                        {
+                          *decided = loc;
+                          break;
+                        }
+                    }
+                  if (era_cnt != (int) num_eras)
+                    break;
+
+                  era_cnt = -1;
+                  if (*decided == loc)
+                    return NULL;
+
+                  *decided = raw;
+                }
+              /* The C locale has no era information, so use the
+                 normal representation.  */
+              goto match_century;
+            case 'y':
+              if (*decided != raw)
+                {
+                  get_number(0, 9999, 4);
+                  tm->tm_year = val;
+                  want_era = 1;
+                  want_xday = 1;
+                  want_century = 1;
+
+                  if (era_cnt >= 0)
+                    {
+                      assert (*decided == loc);
+
+                      era = _nl_select_era_entry (era_cnt HELPER_LOCALE_ARG);
+                      bool match = false;
+                      if (era != NULL)
+                        {
+                          int delta = ((tm->tm_year - era->offset)
+                                       * era->absolute_direction);
+                          match = (delta >= 0
+                                   && delta < (((int64_t) era->stop_date[0]
+                                                - (int64_t) era->start_date[0])
+                                               * era->absolute_direction));
+                        }
+                      if (! match)
+                        return NULL;
+
+                      break;
+                    }
+
+                  num_eras = _NL_CURRENT_WORD (LC_TIME,
+                                               _NL_TIME_ERA_NUM_ENTRIES);
+                  for (era_cnt = 0; era_cnt < (int) num_eras; ++era_cnt)
+                    {
+                      era = _nl_select_era_entry (era_cnt
+                                                  HELPER_LOCALE_ARG);
+                      if (era != NULL)
+                        {
+                          int delta = ((tm->tm_year - era->offset)
+                                       * era->absolute_direction);
+                          if (delta >= 0
+                              && delta < (((int64_t) era->stop_date[0]
+                                           - (int64_t) era->start_date[0])
+                                          * era->absolute_direction))
+                            {
+                              *decided = loc;
+                              break;
+                            }
+                        }
+                    }
+                  if (era_cnt != (int) num_eras)
+                    break;
+
+                  era_cnt = -1;
+                  if (*decided == loc)
+                    return NULL;
+
+                  *decided = raw;
+                }
+
+              goto match_year_in_century;
+            case 'Y':
+              if (*decided != raw)
+                {
+                  num_eras = _NL_CURRENT_WORD (LC_TIME,
+                                               _NL_TIME_ERA_NUM_ENTRIES);
+                  for (era_cnt = 0; era_cnt < (int) num_eras;
+                       ++era_cnt, rp = rp_backup)
+                    {
+                      era = _nl_select_era_entry (era_cnt HELPER_LOCALE_ARG);
+                      if (era != NULL && recursive (era->era_format))
+                        break;
+                    }
+                  if (era_cnt == (int) num_eras)
+                    {
+                      era_cnt = -1;
+                      if (*decided == loc)
+                        return NULL;
+                      else
+                        rp = rp_backup;
+                    }
+                  else
+                    {
+                      *decided = loc;
+                      era_cnt = -1;
+                      break;
+                    }
+
+                  *decided = raw;
+                }
+              get_number (0, 9999, 4);
+              tm->tm_year = val - 1900;
+              want_century = 0;
+              want_xday = 1;
+              break;
+            case 'x':
+              if (*decided != raw)
+                {
+                  const char *fmt = _NL_CURRENT (LC_TIME, ERA_D_FMT);
+
+                  if (*fmt == '\0')
+                    fmt = _NL_CURRENT (LC_TIME, D_FMT);
+
+                  if (!recursive (fmt))
+                    {
+                      if (*decided == loc)
+                        return NULL;
+                      else
+                        rp = rp_backup;
+                    }
+                  else
+                    {
+                      if (strcmp (fmt, HERE_D_FMT))
+                        *decided = loc;
+                      break;
+                    }
+                  *decided = raw;
+                }
+              if (!recursive (HERE_D_FMT))
+                return NULL;
+              break;
+            case 'X':
+              if (*decided != raw)
+                {
+                  const char *fmt = _NL_CURRENT (LC_TIME, ERA_T_FMT);
+
+                  if (*fmt == '\0')
+                    fmt = _NL_CURRENT (LC_TIME, T_FMT);
+
+                  if (!recursive (fmt))
+                    {
+                      if (*decided == loc)
+                        return NULL;
+                      else
+                        rp = rp_backup;
+                    }
+                  else
+                    {
+                      if (strcmp (fmt, HERE_T_FMT))
+                        *decided = loc;
+                      break;
+                    }
+                  *decided = raw;
+                }
+              if (!recursive (HERE_T_FMT))
+                return NULL;
+              break;
+            default:
+              return NULL;
+            }
+          break;
 #else
-	  /* We have no information about the era format.  Just use
-	     the normal format.  */
-	  if (*fmt != 'c' && *fmt != 'C' && *fmt != 'y' && *fmt != 'Y'
-	      && *fmt != 'x' && *fmt != 'X')
-	    /* This is an illegal format.  */
-	    return NULL;
-
-	  goto start_over;
+          /* We have no information about the era format.  Just use
+             the normal format.  */
+          if (*fmt != 'c' && *fmt != 'C' && *fmt != 'y' && *fmt != 'Y'
+              && *fmt != 'x' && *fmt != 'X')
+            /* This is an illegal format.  */
+            return NULL;
+
+          goto start_over;
 #endif
-	case 'O':
-	  switch (*fmt++)
-	    {
-	    case 'd':
-	    case 'e':
-	      /* Match day of month using alternate numeric symbols.  */
-	      get_alt_number (1, 31, 2);
-	      tm->tm_mday = val;
-	      have_mday = 1;
-	      want_xday = 1;
-	      break;
-	    case 'H':
-	      /* Match hour in 24-hour clock using alternate numeric
-		 symbols.  */
-	      get_alt_number (0, 23, 2);
-	      tm->tm_hour = val;
-	      have_I = 0;
-	      break;
-	    case 'I':
-	      /* Match hour in 12-hour clock using alternate numeric
-		 symbols.  */
-	      get_alt_number (1, 12, 2);
-	      tm->tm_hour = val % 12;
-	      have_I = 1;
-	      break;
-	    case 'm':
-	      /* Match month using alternate numeric symbols.  */
-	      get_alt_number (1, 12, 2);
-	      tm->tm_mon = val - 1;
-	      have_mon = 1;
-	      want_xday = 1;
-	      break;
-	    case 'M':
-	      /* Match minutes using alternate numeric symbols.  */
-	      get_alt_number (0, 59, 2);
-	      tm->tm_min = val;
-	      break;
-	    case 'S':
-	      /* Match seconds using alternate numeric symbols.  */
-	      get_alt_number (0, 61, 2);
-	      tm->tm_sec = val;
-	      break;
-	    case 'U':
-	      get_alt_number (0, 53, 2);
-	      week_no = val;
-	      have_uweek = 1;
-	      break;
-	    case 'W':
-	      get_alt_number (0, 53, 2);
-	      week_no = val;
-	      have_wweek = 1;
-	      break;
-	    case 'V':
-	      get_alt_number (0, 53, 2);
-	      /* XXX This cannot determine any field in TM without
-		 further information.  */
-	      break;
-	    case 'w':
-	      /* Match number of weekday using alternate numeric symbols.  */
-	      get_alt_number (0, 6, 1);
-	      tm->tm_wday = val;
-	      have_wday = 1;
-	      break;
-	    case 'y':
-	      /* Match year within century using alternate numeric symbols.  */
-	      get_alt_number (0, 99, 2);
-	      tm->tm_year = val >= 69 ? val : val + 100;
-	      want_xday = 1;
-	      break;
-	    default:
-	      return NULL;
-	    }
-	  break;
-	default:
-	  return NULL;
-	}
+        case 'O':
+          switch (*fmt++)
+            {
+            case 'd':
+            case 'e':
+              /* Match day of month using alternate numeric symbols.  */
+              get_alt_number (1, 31, 2);
+              tm->tm_mday = val;
+              have_mday = 1;
+              want_xday = 1;
+              break;
+            case 'H':
+              /* Match hour in 24-hour clock using alternate numeric
+                 symbols.  */
+              get_alt_number (0, 23, 2);
+              tm->tm_hour = val;
+              have_I = 0;
+              break;
+            case 'I':
+              /* Match hour in 12-hour clock using alternate numeric
+                 symbols.  */
+              get_alt_number (1, 12, 2);
+              tm->tm_hour = val % 12;
+              have_I = 1;
+              break;
+            case 'm':
+              /* Match month using alternate numeric symbols.  */
+              get_alt_number (1, 12, 2);
+              tm->tm_mon = val - 1;
+              have_mon = 1;
+              want_xday = 1;
+              break;
+            case 'M':
+              /* Match minutes using alternate numeric symbols.  */
+              get_alt_number (0, 59, 2);
+              tm->tm_min = val;
+              break;
+            case 'S':
+              /* Match seconds using alternate numeric symbols.  */
+              get_alt_number (0, 61, 2);
+              tm->tm_sec = val;
+              break;
+            case 'U':
+              get_alt_number (0, 53, 2);
+              week_no = val;
+              have_uweek = 1;
+              break;
+            case 'W':
+              get_alt_number (0, 53, 2);
+              week_no = val;
+              have_wweek = 1;
+              break;
+            case 'V':
+              get_alt_number (0, 53, 2);
+              /* XXX This cannot determine any field in TM without
+                 further information.  */
+              break;
+            case 'w':
+              /* Match number of weekday using alternate numeric symbols.  */
+              get_alt_number (0, 6, 1);
+              tm->tm_wday = val;
+              have_wday = 1;
+              break;
+            case 'y':
+              /* Match year within century using alternate numeric symbols.  */
+              get_alt_number (0, 99, 2);
+              tm->tm_year = val >= 69 ? val : val + 100;
+              want_xday = 1;
+              break;
+            default:
+              return NULL;
+            }
+          break;
+        default:
+          return NULL;
+        }
     }
 
   if (have_I && is_pm)
@@ -1024,10 +1024,10 @@ __strptime_internal (rp, fmt, tm, decided, era_cnt LOCALE_PARAM)
   if (century != -1)
     {
       if (want_century)
-	tm->tm_year = tm->tm_year % 100 + (century - 19) * 100;
+        tm->tm_year = tm->tm_year % 100 + (century - 19) * 100;
       else
-	/* Only the century, but not the year.  Strange, but so be it.  */
-	tm->tm_year = (century - 19) * 100;
+        /* Only the century, but not the year.  Strange, but so be it.  */
+        tm->tm_year = (century - 19) * 100;
     }
 
   if (era_cnt != -1)
@@ -1035,40 +1035,40 @@ __strptime_internal (rp, fmt, tm, decided, era_cnt LOCALE_PARAM)
 #ifdef _NL_CURRENT
       era = _nl_select_era_entry (era_cnt HELPER_LOCALE_ARG);
       if (era == NULL)
-	return NULL;
+        return NULL;
       if (want_era)
-	tm->tm_year = (era->start_date[0]
-		       + ((tm->tm_year - era->offset)
-			  * era->absolute_direction));
+        tm->tm_year = (era->start_date[0]
+                       + ((tm->tm_year - era->offset)
+                          * era->absolute_direction));
       else
-	/* Era start year assumed.  */
-	tm->tm_year = era->start_date[0];
+        /* Era start year assumed.  */
+        tm->tm_year = era->start_date[0];
 #endif
     }
   else
     if (want_era)
       {
-	/* No era found but we have seen an E modifier.  Rectify some
-	   values.  */
-	if (want_century && century == -1 && tm->tm_year < 69)
-	  tm->tm_year += 100;
+        /* No era found but we have seen an E modifier.  Rectify some
+           values.  */
+        if (want_century && century == -1 && tm->tm_year < 69)
+          tm->tm_year += 100;
       }
 
   if (want_xday && !have_wday)
     {
       if ( !(have_mon && have_mday) && have_yday)
-	{
-	  /* We don't have tm_mon and/or tm_mday, compute them.  */
-	  int t_mon = 0;
-	  while (__mon_yday[__isleap(1900 + tm->tm_year)][t_mon] <= tm->tm_yday)
-	      t_mon++;
-	  if (!have_mon)
-	      tm->tm_mon = t_mon - 1;
-	  if (!have_mday)
-	      tm->tm_mday =
-		(tm->tm_yday
-		 - __mon_yday[__isleap(1900 + tm->tm_year)][t_mon - 1] + 1);
-	}
+        {
+          /* We don't have tm_mon and/or tm_mday, compute them.  */
+          int t_mon = 0;
+          while (__mon_yday[__isleap(1900 + tm->tm_year)][t_mon] <= tm->tm_yday)
+              t_mon++;
+          if (!have_mon)
+              tm->tm_mon = t_mon - 1;
+          if (!have_mday)
+              tm->tm_mday =
+                (tm->tm_yday
+                 - __mon_yday[__isleap(1900 + tm->tm_year)][t_mon - 1] + 1);
+        }
       day_of_the_week (tm);
     }
 
@@ -1086,28 +1086,28 @@ __strptime_internal (rp, fmt, tm, decided, era_cnt LOCALE_PARAM)
       tm->tm_mon = 0;
       day_of_the_week (tm);
       if (have_mday)
-	tm->tm_mday = save_mday;
+        tm->tm_mday = save_mday;
       if (have_mon)
-	tm->tm_mon = save_mon;
+        tm->tm_mon = save_mon;
 
       if (!have_yday)
-	tm->tm_yday = ((7 - (tm->tm_wday - w_offset)) % 7
-		       + (week_no - 1) *7
-		       + save_wday - w_offset);
+        tm->tm_yday = ((7 - (tm->tm_wday - w_offset)) % 7
+                       + (week_no - 1) *7
+                       + save_wday - w_offset);
 
       if (!have_mday || !have_mon)
-	{
-	  int t_mon = 0;
-	  while (__mon_yday[__isleap(1900 + tm->tm_year)][t_mon]
-		 <= tm->tm_yday)
-	    t_mon++;
-	  if (!have_mon)
-	    tm->tm_mon = t_mon - 1;
-	  if (!have_mday)
-	      tm->tm_mday =
-		(tm->tm_yday
-		 - __mon_yday[__isleap(1900 + tm->tm_year)][t_mon - 1] + 1);
-	}
+        {
+          int t_mon = 0;
+          while (__mon_yday[__isleap(1900 + tm->tm_year)][t_mon]
+                 <= tm->tm_yday)
+            t_mon++;
+          if (!have_mon)
+            tm->tm_mon = t_mon - 1;
+          if (!have_mday)
+              tm->tm_mday =
+                (tm->tm_yday
+                 - __mon_yday[__isleap(1900 + tm->tm_year)][t_mon - 1] + 1);
+        }
 
       tm->tm_wday = save_wday;
     }
diff --git a/libmissing/strsep.c b/libmissing/strsep.c
index 82809eb..f71b810 100644
--- a/libmissing/strsep.c
+++ b/libmissing/strsep.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2004, 2007, 2009 Free Software Foundation, Inc.
 
    Written by Yoann Vandoorselaere <[email protected]>.
 
diff --git a/libmissing/sys_select.in.h b/libmissing/sys_select.in.h
index e80db7b..336894c 100644
--- a/libmissing/sys_select.in.h
+++ b/libmissing/sys_select.in.h
@@ -42,8 +42,18 @@
 # include <sys/types.h>
 
 /* On OSF/1 4.0, <sys/select.h> provides only a forward declaration
-   of 'struct timeval', and no definition of this type..  */
-# include <sys/time.h>
+   of 'struct timeval', and no definition of this type.
+   But avoid namespace pollution on glibc systems.  */
+# ifndef __GLIBC__
+#  include <sys/time.h>
+# endif
+
+/* On Solaris 10, <sys/select.h> provides an FD_ZERO implementation
+   that relies on memset(), but without including <string.h>.
+   But avoid namespace pollution on glibc systems.  */
+# ifndef __GLIBC__
+#  include <string.h>
+# endif
 
 /* The include_next requires a split double-inclusion guard.  */
 # @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
diff --git a/libmissing/sys_socket.in.h b/libmissing/sys_socket.in.h
index 67b926e..1d46175 100644
--- a/libmissing/sys_socket.in.h
+++ b/libmissing/sys_socket.in.h
@@ -43,6 +43,8 @@
 #ifndef _GL_SYS_SOCKET_H
 #define _GL_SYS_SOCKET_H
 
+/* The definition of _GL_ARG_NONNULL is copied here.  */
+
 #if !@HAVE_SA_FAMILY_T@
 typedef unsigned short  sa_family_t;
 #endif
@@ -54,10 +56,10 @@ typedef unsigned short  sa_family_t;
 # define __ss_aligntype unsigned long int
 # define _SS_SIZE 256
 # define _SS_PADSIZE \
-    (_SS_SIZE - ((sizeof (sa_family_t) >= alignof (__ss_aligntype)	\
-		  ? sizeof (sa_family_t)				\
-		  : alignof (__ss_aligntype))				\
-		 + sizeof (__ss_aligntype)))
+    (_SS_SIZE - ((sizeof (sa_family_t) >= alignof (__ss_aligntype)      \
+                  ? sizeof (sa_family_t)                                \
+                  : alignof (__ss_aligntype))                           \
+                 + sizeof (__ss_aligntype)))
 
 struct sockaddr_storage
 {
@@ -177,7 +179,7 @@ rpl_fd_isset (SOCKET fd, fd_set * set)
 # if @GNULIB_SOCKET@
 #  if @HAVE_WINSOCK2_H@
 #   undef socket
-#   define socket		rpl_socket
+#   define socket               rpl_socket
 extern int rpl_socket (int, int, int protocol);
 #  endif
 # elif @HAVE_WINSOCK2_H@
@@ -194,8 +196,8 @@ extern int rpl_socket (int, int, int protocol);
 # if @GNULIB_CONNECT@
 #  if @HAVE_WINSOCK2_H@
 #   undef connect
-#   define connect		rpl_connect
-extern int rpl_connect (int, struct sockaddr *, int);
+#   define connect              rpl_connect
+extern int rpl_connect (int, struct sockaddr *, int) _GL_ARG_NONNULL ((2));
 #  endif
 # elif @HAVE_WINSOCK2_H@
 #  undef connect
@@ -211,7 +213,7 @@ extern int rpl_connect (int, struct sockaddr *, int);
 # if @GNULIB_ACCEPT@
 #  if @HAVE_WINSOCK2_H@
 #   undef accept
-#   define accept		rpl_accept
+#   define accept               rpl_accept
 extern int rpl_accept (int, struct sockaddr *, int *);
 #  endif
 # elif @HAVE_WINSOCK2_H@
@@ -228,8 +230,8 @@ extern int rpl_accept (int, struct sockaddr *, int *);
 # if @GNULIB_BIND@
 #  if @HAVE_WINSOCK2_H@
 #   undef bind
-#   define bind			rpl_bind
-extern int rpl_bind (int, struct sockaddr *, int);
+#   define bind                 rpl_bind
+extern int rpl_bind (int, struct sockaddr *, int) _GL_ARG_NONNULL ((2));
 #  endif
 # elif @HAVE_WINSOCK2_H@
 #  undef bind
@@ -245,8 +247,9 @@ extern int rpl_bind (int, struct sockaddr *, int);
 # if @GNULIB_GETPEERNAME@
 #  if @HAVE_WINSOCK2_H@
 #   undef getpeername
-#   define getpeername		rpl_getpeername
-extern int rpl_getpeername (int, struct sockaddr *, int *);
+#   define getpeername          rpl_getpeername
+extern int rpl_getpeername (int, struct sockaddr *, int *)
+     _GL_ARG_NONNULL ((2, 3));
 #  endif
 # elif @HAVE_WINSOCK2_H@
 #  undef getpeername
@@ -262,8 +265,9 @@ extern int rpl_getpeername (int, struct sockaddr *, int *);
 # if @GNULIB_GETSOCKNAME@
 #  if @HAVE_WINSOCK2_H@
 #   undef getsockname
-#   define getsockname		rpl_getsockname
-extern int rpl_getsockname (int, struct sockaddr *, int *);
+#   define getsockname          rpl_getsockname
+extern int rpl_getsockname (int, struct sockaddr *, int *)
+     _GL_ARG_NONNULL ((2, 3));
 #  endif
 # elif @HAVE_WINSOCK2_H@
 #  undef getsockname
@@ -279,8 +283,9 @@ extern int rpl_getsockname (int, struct sockaddr *, int *);
 # if @GNULIB_GETSOCKOPT@
 #  if @HAVE_WINSOCK2_H@
 #   undef getsockopt
-#   define getsockopt		rpl_getsockopt
-extern int rpl_getsockopt (int, int, int, void *, socklen_t *);
+#   define getsockopt           rpl_getsockopt
+extern int rpl_getsockopt (int, int, int, void *, socklen_t *)
+     _GL_ARG_NONNULL ((4, 5));
 #  endif
 # elif @HAVE_WINSOCK2_H@
 #  undef getsockopt
@@ -296,7 +301,7 @@ extern int rpl_getsockopt (int, int, int, void *, socklen_t *);
 # if @GNULIB_LISTEN@
 #  if @HAVE_WINSOCK2_H@
 #   undef listen
-#   define listen		rpl_listen
+#   define listen               rpl_listen
 extern int rpl_listen (int, int);
 #  endif
 # elif @HAVE_WINSOCK2_H@
@@ -313,8 +318,8 @@ extern int rpl_listen (int, int);
 # if @GNULIB_RECV@
 #  if @HAVE_WINSOCK2_H@
 #   undef recv
-#   define recv			rpl_recv
-extern int rpl_recv (int, void *, int, int);
+#   define recv                 rpl_recv
+extern int rpl_recv (int, void *, int, int) _GL_ARG_NONNULL ((2));
 #  endif
 # elif @HAVE_WINSOCK2_H@
 #  undef recv
@@ -330,8 +335,8 @@ extern int rpl_recv (int, void *, int, int);
 # if @GNULIB_SEND@
 #  if @HAVE_WINSOCK2_H@
 #   undef send
-#   define send			rpl_send
-extern int rpl_send (int, const void *, int, int);
+#   define send                 rpl_send
+extern int rpl_send (int, const void *, int, int) _GL_ARG_NONNULL ((2));
 #  endif
 # elif @HAVE_WINSOCK2_H@
 #  undef send
@@ -347,8 +352,9 @@ extern int rpl_send (int, const void *, int, int);
 # if @GNULIB_RECVFROM@
 #  if @HAVE_WINSOCK2_H@
 #   undef recvfrom
-#   define recvfrom		rpl_recvfrom
-extern int rpl_recvfrom (int, void *, int, int, struct sockaddr *, int *);
+#   define recvfrom             rpl_recvfrom
+extern int rpl_recvfrom (int, void *, int, int, struct sockaddr *, int *)
+     _GL_ARG_NONNULL ((2));
 #  endif
 # elif @HAVE_WINSOCK2_H@
 #  undef recvfrom
@@ -364,8 +370,9 @@ extern int rpl_recvfrom (int, void *, int, int, struct sockaddr *, int *);
 # if @GNULIB_SENDTO@
 #  if @HAVE_WINSOCK2_H@
 #   undef sendto
-#   define sendto		rpl_sendto
-extern int rpl_sendto (int, const void *, int, int, struct sockaddr *, int);
+#   define sendto               rpl_sendto
+extern int rpl_sendto (int, const void *, int, int, struct sockaddr *, int)
+     _GL_ARG_NONNULL ((2));
 #  endif
 # elif @HAVE_WINSOCK2_H@
 #  undef sendto
@@ -381,8 +388,9 @@ extern int rpl_sendto (int, const void *, int, int, struct sockaddr *, int);
 # if @GNULIB_SETSOCKOPT@
 #  if @HAVE_WINSOCK2_H@
 #   undef setsockopt
-#   define setsockopt		rpl_setsockopt
-extern int rpl_setsockopt (int, int, int, const void *, socklen_t);
+#   define setsockopt           rpl_setsockopt
+extern int rpl_setsockopt (int, int, int, const void *, socklen_t)
+     _GL_ARG_NONNULL ((4));
 #  endif
 # elif @HAVE_WINSOCK2_H@
 #  undef setsockopt
@@ -398,7 +406,7 @@ extern int rpl_setsockopt (int, int, int, const void *, socklen_t);
 # if @GNULIB_SHUTDOWN@
 #  if @HAVE_WINSOCK2_H@
 #   undef shutdown
-#   define shutdown		rpl_shutdown
+#   define shutdown             rpl_shutdown
 extern int rpl_shutdown (int, int);
 #  endif
 # elif @HAVE_WINSOCK2_H@
@@ -414,7 +422,7 @@ extern int rpl_shutdown (int, int);
 
 # if @HAVE_WINSOCK2_H@
 #  undef select
-#  define select		select_used_without_including_sys_select_h
+#  define select                select_used_without_including_sys_select_h
 # endif
 
 # ifdef __cplusplus
@@ -423,5 +431,32 @@ extern int rpl_shutdown (int, int);
 
 #endif /* HAVE_SYS_SOCKET_H */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if @GNULIB_ACCEPT4@
+/* Accept a connection on a socket, with specific opening flags.
+   The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
+   and O_TEXT, O_BINARY (defined in "binary-io.h").
+   See also the Linux man page at
+   <http://www.kernel.org/doc/man-pages/online/pages/man2/accept4.2.html>.  */
+# if @HAVE_ACCEPT4@
+#  define accept4 rpl_accept4
+# endif
+extern int accept4 (int sockfd, struct sockaddr *addr, socklen_t *addrlen,
+                    int flags);
+#elif defined GNULIB_POSIXCHECK
+# undef accept4
+# define accept4(s,a,l,f) \
+    (GL_LINK_WARNING ("accept4 is unportable - " \
+                      "use gnulib module accept4 for portability"), \
+     accept4 (s, a, l, f))
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _GL_SYS_SOCKET_H */
 #endif /* _GL_SYS_SOCKET_H */
diff --git a/libmissing/sys_stat.in.h b/libmissing/sys_stat.in.h
index 270fce5..0db3c4d 100644
--- a/libmissing/sys_stat.in.h
+++ b/libmissing/sys_stat.in.h
@@ -38,6 +38,9 @@
 /* Get nlink_t.  */
 #include <sys/types.h>
 
+/* Get struct timespec.  */
+#include <time.h>
+
 /* The include_next requires a split double-inclusion guard.  */
 #@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
 
@@ -46,6 +49,8 @@
 
 /* The definition of GL_LINK_WARNING is copied here.  */
 
+/* The definition of _GL_ARG_NONNULL is copied here.  */
+
 /* Before doing "#define mkdir rpl_mkdir" below, we need to include all
    headers that may declare mkdir().  */
 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
@@ -278,12 +283,98 @@
 # define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
 #endif
 
+/* Macros for futimens and utimensat.  */
+#ifndef UTIME_NOW
+# define UTIME_NOW (-1)
+# define UTIME_OMIT (-2)
+#endif
+
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 
+#if @GNULIB_FCHMODAT@
+# if !@HAVE_FCHMODAT@
+extern int fchmodat (int fd, char const *file, mode_t mode, int flag)
+     _GL_ARG_NONNULL ((2));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef fchmodat
+# define fchmodat(d,n,m,f)                         \
+    (GL_LINK_WARNING ("fchmodat is not portable - " \
+                      "use gnulib module openat for portability"), \
+     fchmodat (d, n, m, f))
+#endif
+
+
+#if @REPLACE_FSTAT@
+# define fstat rpl_fstat
+extern int fstat (int fd, struct stat *buf) _GL_ARG_NONNULL ((2));
+#endif
+
+
+#if @GNULIB_FSTATAT@
+# if @REPLACE_FSTATAT@
+#  undef fstatat
+#  define fstatat rpl_fstatat
+# endif
+# if !@HAVE_FSTATAT@ || @REPLACE_FSTATAT@
+extern int fstatat (int fd, char const *name, struct stat *st, int flags)
+     _GL_ARG_NONNULL ((2, 3));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef fstatat
+# define fstatat(d,n,s,f)                         \
+    (GL_LINK_WARNING ("fstatat is not portable - " \
+                      "use gnulib module openat for portability"), \
+     fstatat (d, n, s, f))
+#endif
+
+
+#if @GNULIB_FUTIMENS@
+# if @REPLACE_FUTIMENS@
+#  undef futimens
+#  define futimens rpl_futimens
+# endif
+# if !@HAVE_FUTIMENS@ || @REPLACE_FUTIMENS@
+extern int futimens (int fd, struct timespec const times[2]);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef futimens
+# define futimens(f,t)                         \
+    (GL_LINK_WARNING ("futimens is not portable - " \
+                      "use gnulib module futimens for portability"), \
+     futimens (f, t))
+#endif
+
+
+#if @GNULIB_LCHMOD@
+/* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME
+   denotes a symbolic link.  */
+# if !@HAVE_LCHMOD@
+/* The lchmod replacement follows symbolic links.  Callers should take
+   this into account; lchmod should be applied only to arguments that
+   are known to not be symbolic links.  On hosts that lack lchmod,
+   this can lead to race conditions between the check and the
+   invocation of lchmod, but we know of no workarounds that are
+   reliable in general.  You might try requesting support for lchmod
+   from your operating system supplier.  */
+#  define lchmod chmod
+# endif
+# if 0 /* assume already declared */
+extern int lchmod (const char *filename, mode_t mode) _GL_ARG_NONNULL ((1));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef lchmod
+# define lchmod(f,m) \
+    (GL_LINK_WARNING ("lchmod is unportable - " \
+                      "use gnulib module lchmod for portability"), \
+     lchmod (f, m))
+#endif
+
+
 #if @GNULIB_LSTAT@
 # if ! @HAVE_LSTAT@
 /* mingw does not support symlinks, therefore it does not have lstat.  But
@@ -292,13 +383,14 @@ extern "C" {
 # elif @REPLACE_LSTAT@
 #  undef lstat
 #  define lstat rpl_lstat
-extern int rpl_lstat (const char *name, struct stat *buf);
+extern int rpl_lstat (const char *name, struct stat *buf)
+     _GL_ARG_NONNULL ((1, 2));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef lstat
-# define lstat(p,b)							\
-  (GL_LINK_WARNING ("lstat is unportable - "				\
-		    "use gnulib module lstat for portability"),		\
+# define lstat(p,b)                                                     \
+  (GL_LINK_WARNING ("lstat is unportable - "                            \
+                    "use gnulib module lstat for portability"),         \
    lstat (p, b))
 #endif
 
@@ -306,7 +398,7 @@ extern int rpl_lstat (const char *name, struct stat *buf);
 #if @REPLACE_MKDIR@
 # undef mkdir
 # define mkdir rpl_mkdir
-extern int mkdir (char const *name, mode_t mode);
+extern int mkdir (char const *name, mode_t mode) _GL_ARG_NONNULL ((1));
 #else
 /* mingw's _mkdir() function has 1 argument, but we pass 2 arguments.
    Additionally, it declares _mkdir (and depending on compile flags, an
@@ -324,30 +416,125 @@ rpl_mkdir (char const *name, mode_t mode)
 #endif
 
 
-/* Declare BSD extensions.  */
+#if @GNULIB_MKDIRAT@
+# if !@HAVE_MKDIRAT@
+extern int mkdirat (int fd, char const *file, mode_t mode)
+     _GL_ARG_NONNULL ((2));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef mkdirat
+# define mkdirat(d,n,m)                         \
+    (GL_LINK_WARNING ("mkdirat is not portable - " \
+                      "use gnulib module openat for portability"), \
+     mkdirat (d, n, m))
+#endif
 
-#if @GNULIB_LCHMOD@
-/* Change the mode of FILENAME to MODE, without dereferencing it if FILENAME
-   denotes a symbolic link.  */
-# if !@HAVE_LCHMOD@
-/* The lchmod replacement follows symbolic links.  Callers should take
-   this into account; lchmod should be applied only to arguments that
-   are known to not be symbolic links.  On hosts that lack lchmod,
-   this can lead to race conditions between the check and the
-   invocation of lchmod, but we know of no workarounds that are
-   reliable in general.  You might try requesting support for lchmod
-   from your operating system supplier.  */
-#  define lchmod chmod
+
+#if @GNULIB_MKFIFO@
+# if @REPLACE_MKFIFO@
+#  undef mkfifo
+#  define mkfifo rpl_mkfifo
 # endif
-# if 0 /* assume already declared */
-extern int lchmod (const char *filename, mode_t mode);
+# if !@HAVE_MKFIFO@ || @REPLACE_MKFIFO@
+extern int mkfifo (char const *file, mode_t mode) _GL_ARG_NONNULL ((1));
 # endif
 #elif defined GNULIB_POSIXCHECK
-# undef lchmod
-# define lchmod(f,m) \
-    (GL_LINK_WARNING ("lchmod is unportable - " \
-                      "use gnulib module lchmod for portability"), \
-     lchmod (f, m))
+# undef mkfifo
+# define mkfifo(n,m)                                                    \
+    (GL_LINK_WARNING ("mkfifo is not portable - "                       \
+                      "use gnulib module mkfifo for portability"),      \
+     mkfifo (n, m))
+#endif
+
+
+#if @GNULIB_MKFIFOAT@
+# if !@HAVE_MKFIFOAT@
+extern int mkfifoat (int fd, char const *file, mode_t mode)
+     _GL_ARG_NONNULL ((2));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef mkfifoat
+# define mkfifoat(d,n,m)                                     \
+    (GL_LINK_WARNING ("mkfifoat is not portable - " \
+                      "use gnulib module mkfifoat for portability"), \
+     mkfifoat (d, n, m))
+#endif
+
+
+#if @GNULIB_MKNOD@
+# if @REPLACE_MKNOD@
+#  undef mknod
+#  define mknod rpl_mknod
+# endif
+# if !@HAVE_MKNOD@ || @REPLACE_MKNOD@
+extern int mknod (char const *file, mode_t mode, dev_t dev)
+     _GL_ARG_NONNULL ((1));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef mknod
+# define mknod(n,m,d)                                                   \
+    (GL_LINK_WARNING ("mknod is not portable - "                        \
+                      "use gnulib module mknod for portability"),       \
+     mknod (n, m, d))
+#endif
+
+
+#if @GNULIB_MKNODAT@
+# if !@HAVE_MKNODAT@
+extern int mknodat (int fd, char const *file, mode_t mode, dev_t dev)
+     _GL_ARG_NONNULL ((2));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef mknodat
+# define mknodat(f,n,m,d)                            \
+    (GL_LINK_WARNING ("mknodat is not portable - " \
+                      "use gnulib module mkfifoat for portability"), \
+     mknodat (f, n, m, d))
+#endif
+
+
+#if @GNULIB_STAT@
+# if @REPLACE_STAT@
+/* We can't use the object-like #define stat rpl_stat, because of
+   struct stat.  This means that rpl_stat will not be used if the user
+   does (stat)(a,b).  Oh well.  */
+#  undef stat
+#  ifdef _LARGE_FILES
+    /* With _LARGE_FILES defined, AIX (only) defines stat to stat64,
+       so we have to replace stat64() instead of stat(). */
+#   define stat stat64
+#   undef stat64
+#   define stat64(name, st) rpl_stat (name, st)
+#  else /* !_LARGE_FILES */
+#   define stat(name, st) rpl_stat (name, st)
+#  endif /* !_LARGE_FILES */
+extern int stat (const char *name, struct stat *buf) _GL_ARG_NONNULL ((1, 2));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef stat
+# define stat(p,b)                                                      \
+  (GL_LINK_WARNING ("stat is unportable - "                             \
+                    "use gnulib module stat for portability"),          \
+   stat (p, b))
+#endif
+
+
+#if @GNULIB_UTIMENSAT@
+# if @REPLACE_UTIMENSAT@
+#  undef utimensat
+#  define utimensat rpl_utimensat
+# endif
+# if !@HAVE_UTIMENSAT@ || @REPLACE_UTIMENSAT@
+   extern int utimensat (int fd, char const *name,
+                         struct timespec const times[2], int flag)
+        _GL_ARG_NONNULL ((2));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef utimensat
+# define utimensat(d,n,t,f)                          \
+    (GL_LINK_WARNING ("utimensat is not portable - " \
+                      "use gnulib module utimensat for portability"), \
+     utimensat (d, n, t, f))
 #endif
 
 
diff --git a/libmissing/sys_time.in.h b/libmissing/sys_time.in.h
index 44f9b59..f4befee 100644
--- a/libmissing/sys_time.in.h
+++ b/libmissing/sys_time.in.h
@@ -1,6 +1,6 @@
 /* Provide a more complete sys/time.h.
 
-   Copyright (C) 2007-2008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -39,6 +39,8 @@
 #  include <time.h>
 # endif
 
+/* The definition of _GL_ARG_NONNULL is copied here.  */
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -54,7 +56,8 @@ struct timeval
 # if @REPLACE_GETTIMEOFDAY@
 #  undef gettimeofday
 #  define gettimeofday rpl_gettimeofday
-int gettimeofday (struct timeval *restrict, void *restrict);
+extern int gettimeofday (struct timeval *restrict, void *restrict)
+     _GL_ARG_NONNULL ((1));
 # endif
 
 #ifdef __cplusplus
diff --git a/libmissing/tests/Makefile.am b/libmissing/tests/Makefile.am
index 178e68b..cd188fb 100644
--- a/libmissing/tests/Makefile.am
+++ b/libmissing/tests/Makefile.am
@@ -14,6 +14,7 @@ AUTOMAKE_OPTIONS = 1.5 foreign
 
 SUBDIRS =
 TESTS =
+XFAIL_TESTS =
 TESTS_ENVIRONMENT =
 noinst_PROGRAMS =
 check_PROGRAMS =
@@ -60,15 +61,76 @@ EXTRA_DIST += test-alloca-opt.c
 
 ## end   gnulib module alloca-opt-tests
 
+## begin gnulib module arg-nonnull
+
+# The BUILT_SOURCES created by this Makefile snippet are not used via #include
+# statements but through direct file reference. Therefore this snippet must be
+# present in all Makefile.am that need it. This is ensured by the applicability
+# 'all' defined above.
+
+BUILT_SOURCES += arg-nonnull.h
+# The arg-nonnull.h that gets inserted into generated .h files is the same as
+# build-aux/arg-nonnull.h, except that it has the copyright header cut off.
+arg-nonnull.h: $(top_srcdir)/./arg-nonnull.h
+	$(AM_V_GEN)rm -f $@-t $@ && \
+	sed -n -e '/GL_ARG_NONNULL/,$$p' \
+	  < $(top_srcdir)/./arg-nonnull.h \
+	  > $@-t && \
+	mv $@-t $@
+MOSTLYCLEANFILES += arg-nonnull.h arg-nonnull.h-t
+
+ARG_NONNULL_H=arg-nonnull.h
+
+EXTRA_DIST += $(top_srcdir)/./arg-nonnull.h
+
+## end   gnulib module arg-nonnull
+
 ## begin gnulib module arpa_inet-tests
 
 TESTS += test-arpa_inet
 check_PROGRAMS += test-arpa_inet
-
 EXTRA_DIST += test-arpa_inet.c
 
 ## end   gnulib module arpa_inet-tests
 
+## begin gnulib module c-ctype
+
+libtests_a_SOURCES += c-ctype.h c-ctype.c
+
+## end   gnulib module c-ctype
+
+## begin gnulib module c-ctype-tests
+
+TESTS += test-c-ctype
+check_PROGRAMS += test-c-ctype
+
+EXTRA_DIST += test-c-ctype.c macros.h
+
+## end   gnulib module c-ctype-tests
+
+## begin gnulib module c-strcase
+
+libtests_a_SOURCES += c-strcase.h c-strcasecmp.c c-strncasecmp.c
+
+## end   gnulib module c-strcase
+
+## begin gnulib module c-strcase-tests
+
+TESTS += test-c-strcase.sh
+TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' LOCALE_FR='@LOCALE_FR@' LOCALE_TR_UTF8='@LOCALE_TR_UTF8@'
+check_PROGRAMS += test-c-strcasecmp test-c-strncasecmp
+EXTRA_DIST += test-c-strcase.sh test-c-strcasecmp.c test-c-strncasecmp.c macros.h
+
+## end   gnulib module c-strcase-tests
+
+## begin gnulib module dirent-tests
+
+TESTS += test-dirent
+check_PROGRAMS += test-dirent
+EXTRA_DIST += test-dirent.c
+
+## end   gnulib module dirent-tests
+
 ## begin gnulib module errno-tests
 
 TESTS += test-errno
@@ -82,7 +144,7 @@ EXTRA_DIST += test-errno.c
 
 TESTS += test-fnmatch
 check_PROGRAMS += test-fnmatch
-EXTRA_DIST += test-fnmatch.c
+EXTRA_DIST += test-fnmatch.c signature.h macros.h
 
 ## end   gnulib module fnmatch-tests
 
@@ -91,8 +153,7 @@ EXTRA_DIST += test-fnmatch.c
 TESTS += test-getaddrinfo
 check_PROGRAMS += test-getaddrinfo
 test_getaddrinfo_LDADD = $(LDADD) @GETADDRINFO_LIB@ @LIBINTL@
-
-EXTRA_DIST += test-getaddrinfo.c
+EXTRA_DIST += signature.h test-getaddrinfo.c
 
 ## end   gnulib module getaddrinfo-tests
 
@@ -100,10 +161,29 @@ EXTRA_DIST += test-getaddrinfo.c
 
 TESTS += test-glob
 check_PROGRAMS += test-glob
-EXTRA_DIST += test-glob.c
+EXTRA_DIST += test-glob.c signature.h macros.h
 
 ## end   gnulib module glob-tests
 
+## begin gnulib module iconv-tests
+
+TESTS += test-iconv
+check_PROGRAMS += test-iconv
+test_iconv_LDADD = $(LDADD) @LIBICONV@
+
+EXTRA_DIST += test-iconv.c signature.h macros.h
+
+## end   gnulib module iconv-tests
+
+## begin gnulib module inet_ntop-tests
+
+TESTS += test-inet_ntop
+check_PROGRAMS += test-inet_ntop
+test_inet_ntop_LDADD = $(LDADD) @INET_NTOP_LIB@
+EXTRA_DIST += test-inet_ntop.c signature.h macros.h
+
+## end   gnulib module inet_ntop-tests
+
 ## begin gnulib module intprops
 
 
@@ -111,6 +191,38 @@ EXTRA_DIST += intprops.h
 
 ## end   gnulib module intprops
 
+## begin gnulib module langinfo-tests
+
+TESTS += test-langinfo
+check_PROGRAMS += test-langinfo
+EXTRA_DIST += test-langinfo.c
+
+## end   gnulib module langinfo-tests
+
+## begin gnulib module link-warning
+
+# The BUILT_SOURCES created by this Makefile snippet are not used via #include
+# statements but through direct file reference. Therefore this snippet must be
+# present in all Makefile.am that need it. This is ensured by the applicability
+# 'all' defined above.
+
+BUILT_SOURCES += link-warning.h
+# The link-warning.h that gets inserted into generated .h files is the same as
+# build-aux/link-warning.h, except that it has the copyright header cut off.
+link-warning.h: $(top_srcdir)/./link-warning.h
+	$(AM_V_GEN)rm -f $@-t $@ && \
+	sed -n -e '/GL_LINK_WARNING/,$$p' \
+	  < $(top_srcdir)/./link-warning.h \
+	  > $@-t && \
+	mv $@-t $@
+MOSTLYCLEANFILES += link-warning.h link-warning.h-t
+
+LINK_WARNING_H=link-warning.h
+
+EXTRA_DIST += $(top_srcdir)/./link-warning.h
+
+## end   gnulib module link-warning
+
 ## begin gnulib module mbrtowc-tests
 
 TESTS += test-mbrtowc1.sh test-mbrtowc2.sh test-mbrtowc3.sh test-mbrtowc4.sh
@@ -122,7 +234,7 @@ TESTS_ENVIRONMENT += \
   LOCALE_ZH_CN='@LOCALE_ZH_CN@'
 check_PROGRAMS += test-mbrtowc
 
-EXTRA_DIST += test-mbrtowc1.sh test-mbrtowc2.sh test-mbrtowc3.sh test-mbrtowc4.sh test-mbrtowc.c
+EXTRA_DIST += test-mbrtowc1.sh test-mbrtowc2.sh test-mbrtowc3.sh test-mbrtowc4.sh test-mbrtowc.c signature.h macros.h
 
 ## end   gnulib module mbrtowc-tests
 
@@ -132,7 +244,7 @@ TESTS += test-mbsinit.sh
 TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' LOCALE_FR_UTF8='@LOCALE_FR_UTF8@'
 check_PROGRAMS += test-mbsinit
 
-EXTRA_DIST += test-mbsinit.sh test-mbsinit.c
+EXTRA_DIST += test-mbsinit.sh test-mbsinit.c signature.h macros.h
 
 ## end   gnulib module mbsinit-tests
 
@@ -147,7 +259,7 @@ TESTS_ENVIRONMENT += \
   LOCALE_ZH_CN='@LOCALE_ZH_CN@'
 check_PROGRAMS += test-mbsrtowcs
 
-EXTRA_DIST += test-mbsrtowcs1.sh test-mbsrtowcs2.sh test-mbsrtowcs3.sh test-mbsrtowcs4.sh test-mbsrtowcs.c
+EXTRA_DIST += test-mbsrtowcs1.sh test-mbsrtowcs2.sh test-mbsrtowcs3.sh test-mbsrtowcs4.sh test-mbsrtowcs.c signature.h macros.h
 
 ## end   gnulib module mbsrtowcs-tests
 
@@ -155,7 +267,7 @@ EXTRA_DIST += test-mbsrtowcs1.sh test-mbsrtowcs2.sh test-mbsrtowcs3.sh test-mbsr
 
 TESTS += test-memchr
 check_PROGRAMS += test-memchr
-EXTRA_DIST += test-memchr.c zerosize-ptr.h
+EXTRA_DIST += test-memchr.c zerosize-ptr.h signature.h macros.h
 
 ## end   gnulib module memchr-tests
 
@@ -163,7 +275,6 @@ EXTRA_DIST += test-memchr.c zerosize-ptr.h
 
 TESTS += test-netdb
 check_PROGRAMS += test-netdb
-
 EXTRA_DIST += test-netdb.c
 
 ## end   gnulib module netdb-tests
@@ -172,16 +283,24 @@ EXTRA_DIST += test-netdb.c
 
 TESTS += test-netinet_in
 check_PROGRAMS += test-netinet_in
-
 EXTRA_DIST += test-netinet_in.c
 
 ## end   gnulib module netinet_in-tests
 
+## begin gnulib module nl_langinfo-tests
+
+TESTS += test-nl_langinfo.sh
+TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' LOCALE_FR='@LOCALE_FR@' LOCALE_FR_UTF8='@LOCALE_FR_UTF8@'
+check_PROGRAMS += test-nl_langinfo
+EXTRA_DIST += test-nl_langinfo.sh test-nl_langinfo.c signature.h macros.h
+
+## end   gnulib module nl_langinfo-tests
+
 ## begin gnulib module sigaction-tests
 
 TESTS += test-sigaction
 check_PROGRAMS += test-sigaction
-EXTRA_DIST += test-sigaction.c
+EXTRA_DIST += test-sigaction.c signature.h macros.h
 
 ## end   gnulib module sigaction-tests
 
@@ -189,7 +308,6 @@ EXTRA_DIST += test-sigaction.c
 
 TESTS += test-signal
 check_PROGRAMS += test-signal
-
 EXTRA_DIST += test-signal.c
 
 ## end   gnulib module signal-tests
@@ -198,8 +316,7 @@ EXTRA_DIST += test-signal.c
 
 TESTS += test-sleep
 check_PROGRAMS += test-sleep
-
-EXTRA_DIST += test-sleep.c
+EXTRA_DIST += test-sleep.c signature.h macros.h
 
 ## end   gnulib module sleep-tests
 
@@ -208,24 +325,39 @@ EXTRA_DIST += test-sleep.c
 TESTS += test-snprintf
 check_PROGRAMS += test-snprintf
 
-EXTRA_DIST += test-snprintf.c
+EXTRA_DIST += test-snprintf.c signature.h macros.h
 
 ## end   gnulib module snprintf-tests
 
+## begin gnulib module sockets-tests
+
+TESTS += test-sockets
+check_PROGRAMS += test-sockets
+test_sockets_LDADD = $(LDADD) @LIBSOCKET@
+EXTRA_DIST += test-sockets.c
+
+## end   gnulib module sockets-tests
+
 ## begin gnulib module stdbool-tests
 
 TESTS += test-stdbool
 check_PROGRAMS += test-stdbool
-
 EXTRA_DIST += test-stdbool.c
 
 ## end   gnulib module stdbool-tests
 
+## begin gnulib module stddef-tests
+
+TESTS += test-stddef
+check_PROGRAMS += test-stddef
+EXTRA_DIST += test-stddef.c
+
+## end   gnulib module stddef-tests
+
 ## begin gnulib module stdint-tests
 
 TESTS += test-stdint
 check_PROGRAMS += test-stdint
-
 EXTRA_DIST += test-stdint.c
 
 ## end   gnulib module stdint-tests
@@ -234,7 +366,6 @@ EXTRA_DIST += test-stdint.c
 
 TESTS += test-stdio
 check_PROGRAMS += test-stdio
-
 EXTRA_DIST += test-stdio.c
 
 ## end   gnulib module stdio-tests
@@ -243,7 +374,6 @@ EXTRA_DIST += test-stdio.c
 
 TESTS += test-stdlib
 check_PROGRAMS += test-stdlib
-
 EXTRA_DIST += test-stdlib.c
 
 ## end   gnulib module stdlib-tests
@@ -261,7 +391,7 @@ EXTRA_libtests_a_SOURCES += strerror.c
 
 TESTS += test-strerror
 check_PROGRAMS += test-strerror
-EXTRA_DIST += test-strerror.c
+EXTRA_DIST += test-strerror.c signature.h macros.h
 
 ## end   gnulib module strerror-tests
 
@@ -269,7 +399,6 @@ EXTRA_DIST += test-strerror.c
 
 TESTS += test-string
 check_PROGRAMS += test-string
-
 EXTRA_DIST += test-string.c
 
 ## end   gnulib module string-tests
@@ -278,7 +407,6 @@ EXTRA_DIST += test-string.c
 
 TESTS += test-strings
 check_PROGRAMS += test-strings
-
 EXTRA_DIST += test-strings.c
 
 ## end   gnulib module strings-tests
@@ -287,7 +415,6 @@ EXTRA_DIST += test-strings.c
 
 TESTS += test-sys_select
 check_PROGRAMS += test-sys_select
-
 EXTRA_DIST += test-sys_select.c
 
 ## end   gnulib module sys_select-tests
@@ -296,7 +423,6 @@ EXTRA_DIST += test-sys_select.c
 
 TESTS += test-sys_socket
 check_PROGRAMS += test-sys_socket
-
 EXTRA_DIST += test-sys_socket.c
 
 ## end   gnulib module sys_socket-tests
@@ -305,7 +431,6 @@ EXTRA_DIST += test-sys_socket.c
 
 TESTS += test-sys_stat
 check_PROGRAMS += test-sys_stat
-
 EXTRA_DIST += test-sys_stat.c
 
 ## end   gnulib module sys_stat-tests
@@ -314,7 +439,6 @@ EXTRA_DIST += test-sys_stat.c
 
 TESTS += test-sys_time
 check_PROGRAMS += test-sys_time
-
 EXTRA_DIST += test-sys_time.c
 
 ## end   gnulib module sys_time-tests
@@ -323,7 +447,6 @@ EXTRA_DIST += test-sys_time.c
 
 TESTS += test-time
 check_PROGRAMS += test-time
-
 EXTRA_DIST += test-time.c
 
 ## end   gnulib module time-tests
@@ -332,7 +455,6 @@ EXTRA_DIST += test-time.c
 
 TESTS += test-unistd
 check_PROGRAMS += test-unistd
-
 EXTRA_DIST += test-unistd.c
 
 ## end   gnulib module unistd-tests
@@ -342,7 +464,7 @@ EXTRA_DIST += test-unistd.c
 TESTS += test-vasnprintf
 check_PROGRAMS += test-vasnprintf
 
-EXTRA_DIST += test-vasnprintf.c
+EXTRA_DIST += test-vasnprintf.c macros.h
 
 ## end   gnulib module vasnprintf-tests
 
@@ -350,7 +472,6 @@ EXTRA_DIST += test-vasnprintf.c
 
 TESTS += test-wchar
 check_PROGRAMS += test-wchar
-
 EXTRA_DIST += test-wchar.c
 
 ## end   gnulib module wchar-tests
@@ -368,17 +489,10 @@ EXTRA_libtests_a_SOURCES += wctob.c
 
 TESTS += test-wctype
 check_PROGRAMS += test-wctype
-
-EXTRA_DIST += test-wctype.c
+EXTRA_DIST += test-wctype.c macros.h
 
 ## end   gnulib module wctype-tests
 
-## begin gnulib module dummy
-
-libtests_a_SOURCES += dummy.c
-
-## end   gnulib module dummy
-
 # Clean up after Solaris cc.
 clean-local:
 	rm -rf SunWS_cache
@@ -390,5 +504,3 @@ mostlyclean-local: mostlyclean-generic
 	  fi; \
 	done; \
 	:
-
--include $(top_srcdir)/git.mk
diff --git a/libmissing/tests/c-ctype.c b/libmissing/tests/c-ctype.c
new file mode 100644
index 0000000..1442d87
--- /dev/null
+++ b/libmissing/tests/c-ctype.c
@@ -0,0 +1,396 @@
+/* Character handling in C locale.
+
+   Copyright 2000-2003, 2006, 2009 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software Foundation,
+Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#include <config.h>
+
+/* Specification.  */
+#define NO_C_CTYPE_MACROS
+#include "c-ctype.h"
+
+/* The function isascii is not locale dependent. Its use in EBCDIC is
+   questionable. */
+bool
+c_isascii (int c)
+{
+  return (c >= 0x00 && c <= 0x7f);
+}
+
+bool
+c_isalnum (int c)
+{
+#if C_CTYPE_CONSECUTIVE_DIGITS \
+    && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
+#if C_CTYPE_ASCII
+  return ((c >= '0' && c <= '9')
+          || ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z'));
+#else
+  return ((c >= '0' && c <= '9')
+          || (c >= 'A' && c <= 'Z')
+          || (c >= 'a' && c <= 'z'));
+#endif
+#else
+  switch (c)
+    {
+    case '0': case '1': case '2': case '3': case '4': case '5':
+    case '6': case '7': case '8': case '9':
+    case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+    case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
+    case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
+    case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
+    case 'Y': case 'Z':
+    case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+    case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
+    case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
+    case 's': case 't': case 'u': case 'v': case 'w': case 'x':
+    case 'y': case 'z':
+      return 1;
+    default:
+      return 0;
+    }
+#endif
+}
+
+bool
+c_isalpha (int c)
+{
+#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
+#if C_CTYPE_ASCII
+  return ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z');
+#else
+  return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'));
+#endif
+#else
+  switch (c)
+    {
+    case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+    case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
+    case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
+    case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
+    case 'Y': case 'Z':
+    case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+    case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
+    case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
+    case 's': case 't': case 'u': case 'v': case 'w': case 'x':
+    case 'y': case 'z':
+      return 1;
+    default:
+      return 0;
+    }
+#endif
+}
+
+bool
+c_isblank (int c)
+{
+  return (c == ' ' || c == '\t');
+}
+
+bool
+c_iscntrl (int c)
+{
+#if C_CTYPE_ASCII
+  return ((c & ~0x1f) == 0 || c == 0x7f);
+#else
+  switch (c)
+    {
+    case ' ': case '!': case '"': case '#': case '$': case '%':
+    case '&': case '\'': case '(': case ')': case '*': case '+':
+    case ',': case '-': case '.': case '/':
+    case '0': case '1': case '2': case '3': case '4': case '5':
+    case '6': case '7': case '8': case '9':
+    case ':': case ';': case '<': case '=': case '>': case '?':
+    case '@':
+    case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+    case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
+    case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
+    case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
+    case 'Y': case 'Z':
+    case '[': case '\\': case ']': case '^': case '_': case '`':
+    case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+    case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
+    case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
+    case 's': case 't': case 'u': case 'v': case 'w': case 'x':
+    case 'y': case 'z':
+    case '{': case '|': case '}': case '~':
+      return 0;
+    default:
+      return 1;
+    }
+#endif
+}
+
+bool
+c_isdigit (int c)
+{
+#if C_CTYPE_CONSECUTIVE_DIGITS
+  return (c >= '0' && c <= '9');
+#else
+  switch (c)
+    {
+    case '0': case '1': case '2': case '3': case '4': case '5':
+    case '6': case '7': case '8': case '9':
+      return 1;
+    default:
+      return 0;
+    }
+#endif
+}
+
+bool
+c_islower (int c)
+{
+#if C_CTYPE_CONSECUTIVE_LOWERCASE
+  return (c >= 'a' && c <= 'z');
+#else
+  switch (c)
+    {
+    case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+    case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
+    case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
+    case 's': case 't': case 'u': case 'v': case 'w': case 'x':
+    case 'y': case 'z':
+      return 1;
+    default:
+      return 0;
+    }
+#endif
+}
+
+bool
+c_isgraph (int c)
+{
+#if C_CTYPE_ASCII
+  return (c >= '!' && c <= '~');
+#else
+  switch (c)
+    {
+    case '!': case '"': case '#': case '$': case '%': case '&':
+    case '\'': case '(': case ')': case '*': case '+': case ',':
+    case '-': case '.': case '/':
+    case '0': case '1': case '2': case '3': case '4': case '5':
+    case '6': case '7': case '8': case '9':
+    case ':': case ';': case '<': case '=': case '>': case '?':
+    case '@':
+    case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+    case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
+    case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
+    case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
+    case 'Y': case 'Z':
+    case '[': case '\\': case ']': case '^': case '_': case '`':
+    case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+    case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
+    case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
+    case 's': case 't': case 'u': case 'v': case 'w': case 'x':
+    case 'y': case 'z':
+    case '{': case '|': case '}': case '~':
+      return 1;
+    default:
+      return 0;
+    }
+#endif
+}
+
+bool
+c_isprint (int c)
+{
+#if C_CTYPE_ASCII
+  return (c >= ' ' && c <= '~');
+#else
+  switch (c)
+    {
+    case ' ': case '!': case '"': case '#': case '$': case '%':
+    case '&': case '\'': case '(': case ')': case '*': case '+':
+    case ',': case '-': case '.': case '/':
+    case '0': case '1': case '2': case '3': case '4': case '5':
+    case '6': case '7': case '8': case '9':
+    case ':': case ';': case '<': case '=': case '>': case '?':
+    case '@':
+    case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+    case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
+    case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
+    case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
+    case 'Y': case 'Z':
+    case '[': case '\\': case ']': case '^': case '_': case '`':
+    case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+    case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
+    case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
+    case 's': case 't': case 'u': case 'v': case 'w': case 'x':
+    case 'y': case 'z':
+    case '{': case '|': case '}': case '~':
+      return 1;
+    default:
+      return 0;
+    }
+#endif
+}
+
+bool
+c_ispunct (int c)
+{
+#if C_CTYPE_ASCII
+  return ((c >= '!' && c <= '~')
+          && !((c >= '0' && c <= '9')
+               || ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'Z')));
+#else
+  switch (c)
+    {
+    case '!': case '"': case '#': case '$': case '%': case '&':
+    case '\'': case '(': case ')': case '*': case '+': case ',':
+    case '-': case '.': case '/':
+    case ':': case ';': case '<': case '=': case '>': case '?':
+    case '@':
+    case '[': case '\\': case ']': case '^': case '_': case '`':
+    case '{': case '|': case '}': case '~':
+      return 1;
+    default:
+      return 0;
+    }
+#endif
+}
+
+bool
+c_isspace (int c)
+{
+  return (c == ' ' || c == '\t'
+          || c == '\n' || c == '\v' || c == '\f' || c == '\r');
+}
+
+bool
+c_isupper (int c)
+{
+#if C_CTYPE_CONSECUTIVE_UPPERCASE
+  return (c >= 'A' && c <= 'Z');
+#else
+  switch (c)
+    {
+    case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+    case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
+    case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
+    case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
+    case 'Y': case 'Z':
+      return 1;
+    default:
+      return 0;
+    }
+#endif
+}
+
+bool
+c_isxdigit (int c)
+{
+#if C_CTYPE_CONSECUTIVE_DIGITS \
+    && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
+#if C_CTYPE_ASCII
+  return ((c >= '0' && c <= '9')
+          || ((c & ~0x20) >= 'A' && (c & ~0x20) <= 'F'));
+#else
+  return ((c >= '0' && c <= '9')
+          || (c >= 'A' && c <= 'F')
+          || (c >= 'a' && c <= 'f'));
+#endif
+#else
+  switch (c)
+    {
+    case '0': case '1': case '2': case '3': case '4': case '5':
+    case '6': case '7': case '8': case '9':
+    case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+    case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+      return 1;
+    default:
+      return 0;
+    }
+#endif
+}
+
+int
+c_tolower (int c)
+{
+#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
+  return (c >= 'A' && c <= 'Z' ? c - 'A' + 'a' : c);
+#else
+  switch (c)
+    {
+    case 'A': return 'a';
+    case 'B': return 'b';
+    case 'C': return 'c';
+    case 'D': return 'd';
+    case 'E': return 'e';
+    case 'F': return 'f';
+    case 'G': return 'g';
+    case 'H': return 'h';
+    case 'I': return 'i';
+    case 'J': return 'j';
+    case 'K': return 'k';
+    case 'L': return 'l';
+    case 'M': return 'm';
+    case 'N': return 'n';
+    case 'O': return 'o';
+    case 'P': return 'p';
+    case 'Q': return 'q';
+    case 'R': return 'r';
+    case 'S': return 's';
+    case 'T': return 't';
+    case 'U': return 'u';
+    case 'V': return 'v';
+    case 'W': return 'w';
+    case 'X': return 'x';
+    case 'Y': return 'y';
+    case 'Z': return 'z';
+    default: return c;
+    }
+#endif
+}
+
+int
+c_toupper (int c)
+{
+#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
+  return (c >= 'a' && c <= 'z' ? c - 'a' + 'A' : c);
+#else
+  switch (c)
+    {
+    case 'a': return 'A';
+    case 'b': return 'B';
+    case 'c': return 'C';
+    case 'd': return 'D';
+    case 'e': return 'E';
+    case 'f': return 'F';
+    case 'g': return 'G';
+    case 'h': return 'H';
+    case 'i': return 'I';
+    case 'j': return 'J';
+    case 'k': return 'K';
+    case 'l': return 'L';
+    case 'm': return 'M';
+    case 'n': return 'N';
+    case 'o': return 'O';
+    case 'p': return 'P';
+    case 'q': return 'Q';
+    case 'r': return 'R';
+    case 's': return 'S';
+    case 't': return 'T';
+    case 'u': return 'U';
+    case 'v': return 'V';
+    case 'w': return 'W';
+    case 'x': return 'X';
+    case 'y': return 'Y';
+    case 'z': return 'Z';
+    default: return c;
+    }
+#endif
+}
diff --git a/libmissing/tests/c-ctype.h b/libmissing/tests/c-ctype.h
new file mode 100644
index 0000000..5bcd1b7
--- /dev/null
+++ b/libmissing/tests/c-ctype.h
@@ -0,0 +1,295 @@
+/* Character handling in C locale.
+
+   These functions work like the corresponding functions in <ctype.h>,
+   except that they have the C (POSIX) locale hardwired, whereas the
+   <ctype.h> functions' behaviour depends on the current locale set via
+   setlocale.
+
+   Copyright (C) 2000-2003, 2006, 2008-2009 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software Foundation,
+Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#ifndef C_CTYPE_H
+#define C_CTYPE_H
+
+#include <stdbool.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* The functions defined in this file assume the "C" locale and a character
+   set without diacritics (ASCII-US or EBCDIC-US or something like that).
+   Even if the "C" locale on a particular system is an extension of the ASCII
+   character set (like on BeOS, where it is UTF-8, or on AmigaOS, where it
+   is ISO-8859-1), the functions in this file recognize only the ASCII
+   characters.  */
+
+
+/* Check whether the ASCII optimizations apply. */
+
+/* ANSI C89 (and ISO C99 5.2.1.3 too) already guarantees that
+   '0', '1', ..., '9' have consecutive integer values.  */
+#define C_CTYPE_CONSECUTIVE_DIGITS 1
+
+#if ('A' <= 'Z') \
+    && ('A' + 1 == 'B') && ('B' + 1 == 'C') && ('C' + 1 == 'D') \
+    && ('D' + 1 == 'E') && ('E' + 1 == 'F') && ('F' + 1 == 'G') \
+    && ('G' + 1 == 'H') && ('H' + 1 == 'I') && ('I' + 1 == 'J') \
+    && ('J' + 1 == 'K') && ('K' + 1 == 'L') && ('L' + 1 == 'M') \
+    && ('M' + 1 == 'N') && ('N' + 1 == 'O') && ('O' + 1 == 'P') \
+    && ('P' + 1 == 'Q') && ('Q' + 1 == 'R') && ('R' + 1 == 'S') \
+    && ('S' + 1 == 'T') && ('T' + 1 == 'U') && ('U' + 1 == 'V') \
+    && ('V' + 1 == 'W') && ('W' + 1 == 'X') && ('X' + 1 == 'Y') \
+    && ('Y' + 1 == 'Z')
+#define C_CTYPE_CONSECUTIVE_UPPERCASE 1
+#endif
+
+#if ('a' <= 'z') \
+    && ('a' + 1 == 'b') && ('b' + 1 == 'c') && ('c' + 1 == 'd') \
+    && ('d' + 1 == 'e') && ('e' + 1 == 'f') && ('f' + 1 == 'g') \
+    && ('g' + 1 == 'h') && ('h' + 1 == 'i') && ('i' + 1 == 'j') \
+    && ('j' + 1 == 'k') && ('k' + 1 == 'l') && ('l' + 1 == 'm') \
+    && ('m' + 1 == 'n') && ('n' + 1 == 'o') && ('o' + 1 == 'p') \
+    && ('p' + 1 == 'q') && ('q' + 1 == 'r') && ('r' + 1 == 's') \
+    && ('s' + 1 == 't') && ('t' + 1 == 'u') && ('u' + 1 == 'v') \
+    && ('v' + 1 == 'w') && ('w' + 1 == 'x') && ('x' + 1 == 'y') \
+    && ('y' + 1 == 'z')
+#define C_CTYPE_CONSECUTIVE_LOWERCASE 1
+#endif
+
+#if (' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
+    && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
+    && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
+    && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
+    && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
+    && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
+    && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
+    && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
+    && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
+    && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
+    && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
+    && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
+    && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
+    && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
+    && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
+    && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
+    && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
+    && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
+    && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
+    && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
+    && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
+    && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
+    && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)
+/* The character set is ASCII or one of its variants or extensions, not EBCDIC.
+   Testing the value of '\n' and '\r' is not relevant.  */
+#define C_CTYPE_ASCII 1
+#endif
+
+
+/* Function declarations. */
+
+/* Unlike the functions in <ctype.h>, which require an argument in the range
+   of the 'unsigned char' type, the functions here operate on values that are
+   in the 'unsigned char' range or in the 'char' range.  In other words,
+   when you have a 'char' value, you need to cast it before using it as
+   argument to a <ctype.h> function:
+
+         const char *s = ...;
+         if (isalpha ((unsigned char) *s)) ...
+
+   but you don't need to cast it for the functions defined in this file:
+
+         const char *s = ...;
+         if (c_isalpha (*s)) ...
+ */
+
+extern bool c_isascii (int c); /* not locale dependent */
+
+extern bool c_isalnum (int c);
+extern bool c_isalpha (int c);
+extern bool c_isblank (int c);
+extern bool c_iscntrl (int c);
+extern bool c_isdigit (int c);
+extern bool c_islower (int c);
+extern bool c_isgraph (int c);
+extern bool c_isprint (int c);
+extern bool c_ispunct (int c);
+extern bool c_isspace (int c);
+extern bool c_isupper (int c);
+extern bool c_isxdigit (int c);
+
+extern int c_tolower (int c);
+extern int c_toupper (int c);
+
+
+#if defined __GNUC__ && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__ && !defined NO_C_CTYPE_MACROS
+
+/* ASCII optimizations. */
+
+#undef c_isascii
+#define c_isascii(c) \
+  ({ int __c = (c); \
+     (__c >= 0x00 && __c <= 0x7f); \
+   })
+
+#if C_CTYPE_CONSECUTIVE_DIGITS \
+    && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
+#if C_CTYPE_ASCII
+#undef c_isalnum
+#define c_isalnum(c) \
+  ({ int __c = (c); \
+     ((__c >= '0' && __c <= '9') \
+      || ((__c & ~0x20) >= 'A' && (__c & ~0x20) <= 'Z')); \
+   })
+#else
+#undef c_isalnum
+#define c_isalnum(c) \
+  ({ int __c = (c); \
+     ((__c >= '0' && __c <= '9') \
+      || (__c >= 'A' && __c <= 'Z') \
+      || (__c >= 'a' && __c <= 'z')); \
+   })
+#endif
+#endif
+
+#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
+#if C_CTYPE_ASCII
+#undef c_isalpha
+#define c_isalpha(c) \
+  ({ int __c = (c); \
+     ((__c & ~0x20) >= 'A' && (__c & ~0x20) <= 'Z'); \
+   })
+#else
+#undef c_isalpha
+#define c_isalpha(c) \
+  ({ int __c = (c); \
+     ((__c >= 'A' && __c <= 'Z') || (__c >= 'a' && __c <= 'z')); \
+   })
+#endif
+#endif
+
+#undef c_isblank
+#define c_isblank(c) \
+  ({ int __c = (c); \
+     (__c == ' ' || __c == '\t'); \
+   })
+
+#if C_CTYPE_ASCII
+#undef c_iscntrl
+#define c_iscntrl(c) \
+  ({ int __c = (c); \
+     ((__c & ~0x1f) == 0 || __c == 0x7f); \
+   })
+#endif
+
+#if C_CTYPE_CONSECUTIVE_DIGITS
+#undef c_isdigit
+#define c_isdigit(c) \
+  ({ int __c = (c); \
+     (__c >= '0' && __c <= '9'); \
+   })
+#endif
+
+#if C_CTYPE_CONSECUTIVE_LOWERCASE
+#undef c_islower
+#define c_islower(c) \
+  ({ int __c = (c); \
+     (__c >= 'a' && __c <= 'z'); \
+   })
+#endif
+
+#if C_CTYPE_ASCII
+#undef c_isgraph
+#define c_isgraph(c) \
+  ({ int __c = (c); \
+     (__c >= '!' && __c <= '~'); \
+   })
+#endif
+
+#if C_CTYPE_ASCII
+#undef c_isprint
+#define c_isprint(c) \
+  ({ int __c = (c); \
+     (__c >= ' ' && __c <= '~'); \
+   })
+#endif
+
+#if C_CTYPE_ASCII
+#undef c_ispunct
+#define c_ispunct(c) \
+  ({ int _c = (c); \
+     (c_isgraph (_c) && ! c_isalnum (_c)); \
+   })
+#endif
+
+#undef c_isspace
+#define c_isspace(c) \
+  ({ int __c = (c); \
+     (__c == ' ' || __c == '\t' \
+      || __c == '\n' || __c == '\v' || __c == '\f' || __c == '\r'); \
+   })
+
+#if C_CTYPE_CONSECUTIVE_UPPERCASE
+#undef c_isupper
+#define c_isupper(c) \
+  ({ int __c = (c); \
+     (__c >= 'A' && __c <= 'Z'); \
+   })
+#endif
+
+#if C_CTYPE_CONSECUTIVE_DIGITS \
+    && C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
+#if C_CTYPE_ASCII
+#undef c_isxdigit
+#define c_isxdigit(c) \
+  ({ int __c = (c); \
+     ((__c >= '0' && __c <= '9') \
+      || ((__c & ~0x20) >= 'A' && (__c & ~0x20) <= 'F')); \
+   })
+#else
+#undef c_isxdigit
+#define c_isxdigit(c) \
+  ({ int __c = (c); \
+     ((__c >= '0' && __c <= '9') \
+      || (__c >= 'A' && __c <= 'F') \
+      || (__c >= 'a' && __c <= 'f')); \
+   })
+#endif
+#endif
+
+#if C_CTYPE_CONSECUTIVE_UPPERCASE && C_CTYPE_CONSECUTIVE_LOWERCASE
+#undef c_tolower
+#define c_tolower(c) \
+  ({ int __c = (c); \
+     (__c >= 'A' && __c <= 'Z' ? __c - 'A' + 'a' : __c); \
+   })
+#undef c_toupper
+#define c_toupper(c) \
+  ({ int __c = (c); \
+     (__c >= 'a' && __c <= 'z' ? __c - 'a' + 'A' : __c); \
+   })
+#endif
+
+#endif /* optimizing for speed */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* C_CTYPE_H */
diff --git a/libmissing/tests/c-strcase.h b/libmissing/tests/c-strcase.h
new file mode 100644
index 0000000..a83573e
--- /dev/null
+++ b/libmissing/tests/c-strcase.h
@@ -0,0 +1,56 @@
+/* Case-insensitive string comparison functions in C locale.
+   Copyright (C) 1995-1996, 2001, 2003, 2005, 2009 Free Software Foundation,
+   Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#ifndef C_STRCASE_H
+#define C_STRCASE_H
+
+#include <stddef.h>
+
+
+/* The functions defined in this file assume the "C" locale and a character
+   set without diacritics (ASCII-US or EBCDIC-US or something like that).
+   Even if the "C" locale on a particular system is an extension of the ASCII
+   character set (like on BeOS, where it is UTF-8, or on AmigaOS, where it
+   is ISO-8859-1), the functions in this file recognize only the ASCII
+   characters.  More precisely, one of the string arguments must be an ASCII
+   string; the other one can also contain non-ASCII characters (but then
+   the comparison result will be nonzero).  */
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Compare strings S1 and S2, ignoring case, returning less than, equal to or
+   greater than zero if S1 is lexicographically less than, equal to or greater
+   than S2.  */
+extern int c_strcasecmp (const char *s1, const char *s2);
+
+/* Compare no more than N characters of strings S1 and S2, ignoring case,
+   returning less than, equal to or greater than zero if S1 is
+   lexicographically less than, equal to or greater than S2.  */
+extern int c_strncasecmp (const char *s1, const char *s2, size_t n);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* C_STRCASE_H */
diff --git a/libmissing/tests/c-strcasecmp.c b/libmissing/tests/c-strcasecmp.c
new file mode 100644
index 0000000..b80302e
--- /dev/null
+++ b/libmissing/tests/c-strcasecmp.c
@@ -0,0 +1,57 @@
+/* c-strcasecmp.c -- case insensitive string comparator in C locale
+   Copyright (C) 1998-1999, 2005-2006, 2009 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include "c-strcase.h"
+
+#include <limits.h>
+
+#include "c-ctype.h"
+
+int
+c_strcasecmp (const char *s1, const char *s2)
+{
+  register const unsigned char *p1 = (const unsigned char *) s1;
+  register const unsigned char *p2 = (const unsigned char *) s2;
+  unsigned char c1, c2;
+
+  if (p1 == p2)
+    return 0;
+
+  do
+    {
+      c1 = c_tolower (*p1);
+      c2 = c_tolower (*p2);
+
+      if (c1 == '\0')
+        break;
+
+      ++p1;
+      ++p2;
+    }
+  while (c1 == c2);
+
+  if (UCHAR_MAX <= INT_MAX)
+    return c1 - c2;
+  else
+    /* On machines where 'char' and 'int' are types of the same size, the
+       difference of two 'unsigned char' values - including the sign bit -
+       doesn't fit in an 'int'.  */
+    return (c1 > c2 ? 1 : c1 < c2 ? -1 : 0);
+}
diff --git a/libmissing/tests/c-strncasecmp.c b/libmissing/tests/c-strncasecmp.c
new file mode 100644
index 0000000..2b9b562
--- /dev/null
+++ b/libmissing/tests/c-strncasecmp.c
@@ -0,0 +1,57 @@
+/* c-strncasecmp.c -- case insensitive string comparator in C locale
+   Copyright (C) 1998-1999, 2005-2006, 2009 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include "c-strcase.h"
+
+#include <limits.h>
+
+#include "c-ctype.h"
+
+int
+c_strncasecmp (const char *s1, const char *s2, size_t n)
+{
+  register const unsigned char *p1 = (const unsigned char *) s1;
+  register const unsigned char *p2 = (const unsigned char *) s2;
+  unsigned char c1, c2;
+
+  if (p1 == p2 || n == 0)
+    return 0;
+
+  do
+    {
+      c1 = c_tolower (*p1);
+      c2 = c_tolower (*p2);
+
+      if (--n == 0 || c1 == '\0')
+        break;
+
+      ++p1;
+      ++p2;
+    }
+  while (c1 == c2);
+
+  if (UCHAR_MAX <= INT_MAX)
+    return c1 - c2;
+  else
+    /* On machines where 'char' and 'int' are types of the same size, the
+       difference of two 'unsigned char' values - including the sign bit -
+       doesn't fit in an 'int'.  */
+    return (c1 > c2 ? 1 : c1 < c2 ? -1 : 0);
+}
diff --git a/libmissing/tests/dummy.c b/libmissing/tests/dummy.c
deleted file mode 100644
index ccb5c26..0000000
--- a/libmissing/tests/dummy.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/* A dummy file, to prevent empty libraries from breaking builds.
-   Copyright (C) 2004, 2007 Free Software Foundation, Inc.
-
-   This program is free software: you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-/* Some systems, reportedly OpenBSD and Mac OS X, refuse to create
-   libraries without any object files.  You might get an error like:
-
-   > ar cru .libs/libgl.a
-   > ar: no archive members specified
-
-   Compiling this file, and adding its object file to the library, will
-   prevent the library from being empty.  */
-
-/* Some systems, such as Solaris with cc 5.0, refuse to work with libraries
-   that don't export any symbol.  You might get an error like:
-
-   > cc ... libgnu.a
-   > ild: (bad file) garbled symbol table in archive ../gllib/libgnu.a
-
-   Compiling this file, and adding its object file to the library, will
-   prevent the library from exporting no symbols.  */
-
-#ifdef __sun
-/* This declaration ensures that the library will export at least 1 symbol.  */
-int gl_dummy_symbol;
-#else
-/* This declaration is solely to ensure that after preprocessing
-   this file is never empty.  */
-typedef int dummy;
-#endif
diff --git a/libmissing/tests/intprops.h b/libmissing/tests/intprops.h
index 002161e..a0f4669 100644
--- a/libmissing/tests/intprops.h
+++ b/libmissing/tests/intprops.h
@@ -1,6 +1,7 @@
 /* intprops.h -- properties of integer types
 
-   Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2001, 2002, 2003, 2004, 2005, 2009 Free Software
+   Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -17,40 +18,43 @@
 
 /* Written by Paul Eggert.  */
 
-#include <limits.h>
+#ifndef GL_INTPROPS_H
+# define GL_INTPROPS_H
+
+# include <limits.h>
 
 /* The extra casts in the following macros work around compiler bugs,
    e.g., in Cray C 5.0.3.0.  */
 
 /* True if the arithmetic type T is an integer type.  bool counts as
    an integer.  */
-#define TYPE_IS_INTEGER(t) ((t) 1.5 == 1)
+# define TYPE_IS_INTEGER(t) ((t) 1.5 == 1)
 
 /* True if negative values of the signed integer type T use two's
    complement, ones' complement, or signed magnitude representation,
    respectively.  Much GNU code assumes two's complement, but some
    people like to be portable to all possible C hosts.  */
-#define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1)
-#define TYPE_ONES_COMPLEMENT(t) ((t) ~ (t) 0 == 0)
-#define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1)
+# define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1)
+# define TYPE_ONES_COMPLEMENT(t) ((t) ~ (t) 0 == 0)
+# define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1)
 
 /* True if the arithmetic type T is signed.  */
-#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
+# define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
 
 /* The maximum and minimum values for the integer type T.  These
    macros have undefined behavior if T is signed and has padding bits.
    If this is a problem for you, please let us know how to fix it for
    your host.  */
-#define TYPE_MINIMUM(t) \
+# define TYPE_MINIMUM(t) \
   ((t) (! TYPE_SIGNED (t) \
-	? (t) 0 \
-	: TYPE_SIGNED_MAGNITUDE (t) \
-	? ~ (t) 0 \
-	: ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))
-#define TYPE_MAXIMUM(t) \
+        ? (t) 0 \
+        : TYPE_SIGNED_MAGNITUDE (t) \
+        ? ~ (t) 0 \
+        : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))
+# define TYPE_MAXIMUM(t) \
   ((t) (! TYPE_SIGNED (t) \
-	? (t) -1 \
-	: ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))))
+        ? (t) -1 \
+        : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))))
 
 /* Return zero if T can be determined to be an unsigned type.
    Otherwise, return 1.
@@ -58,20 +62,22 @@
    tighter bound.  Otherwise, it overestimates the true bound by one byte
    when applied to unsigned types of size 2, 4, 16, ... bytes.
    The symbol signed_type_or_expr__ is private to this header file.  */
-#if __GNUC__ >= 2
-# define signed_type_or_expr__(t) TYPE_SIGNED (__typeof__ (t))
-#else
-# define signed_type_or_expr__(t) 1
-#endif
+# if __GNUC__ >= 2
+#  define signed_type_or_expr__(t) TYPE_SIGNED (__typeof__ (t))
+# else
+#  define signed_type_or_expr__(t) 1
+# endif
 
 /* Bound on length of the string representing an integer type or expression T.
    Subtract 1 for the sign bit if T is signed; log10 (2.0) < 146/485;
    add 1 for integer division truncation; add 1 more for a minus sign
    if needed.  */
-#define INT_STRLEN_BOUND(t) \
+# define INT_STRLEN_BOUND(t) \
   ((sizeof (t) * CHAR_BIT - signed_type_or_expr__ (t)) * 146 / 485 \
    + signed_type_or_expr__ (t) + 1)
 
 /* Bound on buffer size needed to represent an integer type or expression T,
    including the terminating null.  */
-#define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1)
+# define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1)
+
+#endif /* GL_INTPROPS_H */
diff --git a/libmissing/tests/macros.h b/libmissing/tests/macros.h
new file mode 100644
index 0000000..b29378e
--- /dev/null
+++ b/libmissing/tests/macros.h
@@ -0,0 +1,64 @@
+/* Common macros used by gnulib tests.
+   Copyright (C) 2006-2009 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+
+/* This file contains macros that are used by many gnulib tests.
+   Put here only frequently used macros, say, used by 10 tests or more.  */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+/* Define ASSERT_STREAM before including this file if ASSERT must
+   target a stream other than stderr.  */
+#ifndef ASSERT_STREAM
+# define ASSERT_STREAM stderr
+#endif
+
+/* ASSERT (condition);
+   verifies that the specified condition is fulfilled.  If not, a message
+   is printed to ASSERT_STREAM if defined (defaulting to stderr if
+   undefined) and the program is terminated with an error code.
+
+   This macro has the following properties:
+     - The programmer specifies the expected condition, not the failure
+       condition.  This simplifies thinking.
+     - The condition is tested always, regardless of compilation flags.
+       (Unlike the macro from <assert.h>.)
+     - On Unix platforms, the tester can debug the test program with a
+       debugger (provided core dumps are enabled: "ulimit -c unlimited").
+     - For the sake of platforms where no debugger is available (such as
+       some mingw systems), an error message is printed on the error
+       stream that includes the source location of the ASSERT invocation.
+ */
+#define ASSERT(expr) \
+  do                                                                         \
+    {                                                                        \
+      if (!(expr))                                                           \
+        {                                                                    \
+          fprintf (ASSERT_STREAM, "%s:%d: assertion failed\n",               \
+                   __FILE__, __LINE__);                                      \
+          fflush (ASSERT_STREAM);                                            \
+          abort ();                                                          \
+        }                                                                    \
+    }                                                                        \
+  while (0)
+
+/* SIZEOF (array)
+   returns the number of elements of an array.  It works for arrays that are
+   declared outside functions and for local variables of array type.  It does
+   *not* work for function parameters of array type, because they are actually
+   parameters of pointer type.  */
+#define SIZEOF(array) (sizeof (array) / sizeof (array[0]))
diff --git a/libmissing/tests/signature.h b/libmissing/tests/signature.h
new file mode 100644
index 0000000..bf1bb86
--- /dev/null
+++ b/libmissing/tests/signature.h
@@ -0,0 +1,48 @@
+/* Macro for checking that a function declaration is compliant.
+   Copyright (C) 2009 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef SIGNATURE_CHECK
+
+/* Check that the function FN takes the specified arguments ARGS with
+   a return type of RET.  This header is designed to be included after
+   <config.h> and the one system header that is supposed to contain
+   the function being checked, but prior to any other system headers
+   that are necessary for the unit test.  Therefore, this file does
+   not include any system headers, nor reference anything outside of
+   the macro arguments.  For an example, if foo.h should provide:
+
+   extern int foo (char, float);
+
+   then the unit test named test-foo.c would start out with:
+
+   #include <config.h>
+   #include <foo.h>
+   #include "signature.h"
+   SIGNATURE_CHECK (foo, int, (char, float));
+   #include <other.h>
+   ...
+*/
+# define SIGNATURE_CHECK(fn, ret, args) \
+  SIGNATURE_CHECK1 (fn, ret, args, __LINE__)
+
+/* Necessary to allow multiple SIGNATURE_CHECK lines in a unit test.
+   Note that the checks must not occupy the same line.  */
+# define SIGNATURE_CHECK1(fn, ret, args, id) \
+  SIGNATURE_CHECK2 (fn, ret, args, id) /* macroexpand line */
+# define SIGNATURE_CHECK2(fn, ret, args, id) \
+  static ret (* _GL_UNUSED signature_check ## id) args = fn
+
+#endif /* SIGNATURE_CHECK */
diff --git a/libmissing/tests/strerror.c b/libmissing/tests/strerror.c
index dfe6c25..fa0ed14 100644
--- a/libmissing/tests/strerror.c
+++ b/libmissing/tests/strerror.c
@@ -334,10 +334,10 @@ rpl_strerror (int n)
 
     if (result == NULL || result[0] == '\0')
       {
-	static char const fmt[] = "Unknown error (%d)";
-	static char msg_buf[sizeof fmt + INT_STRLEN_BOUND (n)];
-	sprintf (msg_buf, fmt, n);
-	return msg_buf;
+        static char const fmt[] = "Unknown error (%d)";
+        static char msg_buf[sizeof fmt + INT_STRLEN_BOUND (n)];
+        sprintf (msg_buf, fmt, n);
+        return msg_buf;
       }
 
     return result;
diff --git a/libmissing/tests/test-alloca-opt.c b/libmissing/tests/test-alloca-opt.c
index 68d906d..fe10802 100644
--- a/libmissing/tests/test-alloca-opt.c
+++ b/libmissing/tests/test-alloca-opt.c
@@ -1,5 +1,5 @@
 /* Test of optional automatic memory allocation.
-   Copyright (C) 2005, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2007, 2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
diff --git a/libmissing/tests/test-arpa_inet.c b/libmissing/tests/test-arpa_inet.c
index fc2d8ba..1e2479f 100644
--- a/libmissing/tests/test-arpa_inet.c
+++ b/libmissing/tests/test-arpa_inet.c
@@ -1,5 +1,5 @@
 /* Test of <arpa/inet.h> substitute.
-   Copyright (C) 2007 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -21,7 +21,7 @@
 #include <arpa/inet.h>
 
 int
-main ()
+main (void)
 {
   return 0;
 }
diff --git a/libmissing/tests/test-c-ctype.c b/libmissing/tests/test-c-ctype.c
new file mode 100644
index 0000000..9580966
--- /dev/null
+++ b/libmissing/tests/test-c-ctype.c
@@ -0,0 +1,386 @@
+/* Test of character handling in C locale.
+   Copyright (C) 2005, 2007-2009 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Bruno Haible <[email protected]>, 2005.  */
+
+#include <config.h>
+
+#include "c-ctype.h"
+
+#include <locale.h>
+
+#include "macros.h"
+
+static void
+test_all (void)
+{
+  int c;
+
+  for (c = -0x80; c < 0x100; c++)
+    {
+      ASSERT (c_isascii (c) == (c >= 0 && c < 0x80));
+
+      switch (c)
+        {
+        case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+        case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
+        case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
+        case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
+        case 'Y': case 'Z':
+        case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+        case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
+        case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
+        case 's': case 't': case 'u': case 'v': case 'w': case 'x':
+        case 'y': case 'z':
+        case '0': case '1': case '2': case '3': case '4': case '5':
+        case '6': case '7': case '8': case '9':
+          ASSERT (c_isalnum (c) == 1);
+          break;
+        default:
+          ASSERT (c_isalnum (c) == 0);
+          break;
+        }
+
+      switch (c)
+        {
+        case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+        case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
+        case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
+        case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
+        case 'Y': case 'Z':
+        case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+        case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
+        case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
+        case 's': case 't': case 'u': case 'v': case 'w': case 'x':
+        case 'y': case 'z':
+          ASSERT (c_isalpha (c) == 1);
+          break;
+        default:
+          ASSERT (c_isalpha (c) == 0);
+          break;
+        }
+
+      switch (c)
+        {
+        case '\t': case ' ':
+          ASSERT (c_isblank (c) == 1);
+          break;
+        default:
+          ASSERT (c_isblank (c) == 0);
+          break;
+        }
+
+      ASSERT (c_iscntrl (c) == ((c >= 0 && c < 0x20) || c == 0x7f));
+
+      switch (c)
+        {
+        case '0': case '1': case '2': case '3': case '4': case '5':
+        case '6': case '7': case '8': case '9':
+          ASSERT (c_isdigit (c) == 1);
+          break;
+        default:
+          ASSERT (c_isdigit (c) == 0);
+          break;
+        }
+
+      switch (c)
+        {
+        case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+        case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
+        case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
+        case 's': case 't': case 'u': case 'v': case 'w': case 'x':
+        case 'y': case 'z':
+          ASSERT (c_islower (c) == 1);
+          break;
+        default:
+          ASSERT (c_islower (c) == 0);
+          break;
+        }
+
+      ASSERT (c_isgraph (c) == ((c >= 0x20 && c < 0x7f) && c != ' '));
+
+      ASSERT (c_isprint (c) == (c >= 0x20 && c < 0x7f));
+
+      ASSERT (c_ispunct (c) == (c_isgraph (c) && !c_isalnum (c)));
+
+      switch (c)
+        {
+        case ' ': case '\t': case '\n': case '\v': case '\f': case '\r':
+          ASSERT (c_isspace (c) == 1);
+          break;
+        default:
+          ASSERT (c_isspace (c) == 0);
+          break;
+        }
+
+      switch (c)
+        {
+        case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+        case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
+        case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
+        case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
+        case 'Y': case 'Z':
+          ASSERT (c_isupper (c) == 1);
+          break;
+        default:
+          ASSERT (c_isupper (c) == 0);
+          break;
+        }
+
+      switch (c)
+        {
+        case '0': case '1': case '2': case '3': case '4': case '5':
+        case '6': case '7': case '8': case '9':
+        case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+        case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+          ASSERT (c_isxdigit (c) == 1);
+          break;
+        default:
+          ASSERT (c_isxdigit (c) == 0);
+          break;
+        }
+
+      switch (c)
+        {
+        case 'A':
+          ASSERT (c_tolower (c) == 'a');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'B':
+          ASSERT (c_tolower (c) == 'b');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'C':
+          ASSERT (c_tolower (c) == 'c');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'D':
+          ASSERT (c_tolower (c) == 'd');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'E':
+          ASSERT (c_tolower (c) == 'e');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'F':
+          ASSERT (c_tolower (c) == 'f');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'G':
+          ASSERT (c_tolower (c) == 'g');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'H':
+          ASSERT (c_tolower (c) == 'h');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'I':
+          ASSERT (c_tolower (c) == 'i');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'J':
+          ASSERT (c_tolower (c) == 'j');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'K':
+          ASSERT (c_tolower (c) == 'k');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'L':
+          ASSERT (c_tolower (c) == 'l');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'M':
+          ASSERT (c_tolower (c) == 'm');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'N':
+          ASSERT (c_tolower (c) == 'n');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'O':
+          ASSERT (c_tolower (c) == 'o');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'P':
+          ASSERT (c_tolower (c) == 'p');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'Q':
+          ASSERT (c_tolower (c) == 'q');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'R':
+          ASSERT (c_tolower (c) == 'r');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'S':
+          ASSERT (c_tolower (c) == 's');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'T':
+          ASSERT (c_tolower (c) == 't');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'U':
+          ASSERT (c_tolower (c) == 'u');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'V':
+          ASSERT (c_tolower (c) == 'v');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'W':
+          ASSERT (c_tolower (c) == 'w');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'X':
+          ASSERT (c_tolower (c) == 'x');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'Y':
+          ASSERT (c_tolower (c) == 'y');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'Z':
+          ASSERT (c_tolower (c) == 'z');
+          ASSERT (c_toupper (c) == c);
+          break;
+        case 'a':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'A');
+          break;
+        case 'b':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'B');
+          break;
+        case 'c':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'C');
+          break;
+        case 'd':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'D');
+          break;
+        case 'e':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'E');
+          break;
+        case 'f':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'F');
+          break;
+        case 'g':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'G');
+          break;
+        case 'h':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'H');
+          break;
+        case 'i':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'I');
+          break;
+        case 'j':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'J');
+          break;
+        case 'k':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'K');
+          break;
+        case 'l':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'L');
+          break;
+        case 'm':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'M');
+          break;
+        case 'n':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'N');
+          break;
+        case 'o':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'O');
+          break;
+        case 'p':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'P');
+          break;
+        case 'q':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'Q');
+          break;
+        case 'r':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'R');
+          break;
+        case 's':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'S');
+          break;
+        case 't':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'T');
+          break;
+        case 'u':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'U');
+          break;
+        case 'v':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'V');
+          break;
+        case 'w':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'W');
+          break;
+        case 'x':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'X');
+          break;
+        case 'y':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'Y');
+          break;
+        case 'z':
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == 'Z');
+          break;
+        default:
+          ASSERT (c_tolower (c) == c);
+          ASSERT (c_toupper (c) == c);
+          break;
+        }
+    }
+}
+
+int
+main ()
+{
+  test_all ();
+
+  setlocale (LC_ALL, "de_DE");
+  test_all ();
+
+  setlocale (LC_ALL, "ja_JP.EUC-JP");
+  test_all ();
+
+  return 0;
+}
diff --git a/libmissing/tests/test-c-strcase.sh b/libmissing/tests/test-c-strcase.sh
new file mode 100755
index 0000000..5fcf906
--- /dev/null
+++ b/libmissing/tests/test-c-strcase.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+# Test in the C locale.
+./test-c-strcasecmp${EXEEXT} || exit 1
+./test-c-strncasecmp${EXEEXT} || exit 1
+
+# Test in an ISO-8859-1 or ISO-8859-15 locale.
+: ${LOCALE_FR=fr_FR}
+if test $LOCALE_FR != none; then
+  LC_ALL=$LOCALE_FR ./test-c-strcasecmp${EXEEXT} locale || exit 1
+  LC_ALL=$LOCALE_FR ./test-c-strncasecmp${EXEEXT} locale || exit 1
+fi
+
+# Test in a Turkish UTF-8 locale.
+: ${LOCALE_TR_UTF8=tr_TR.UTF-8}
+if test $LOCALE_TR_UTF8 != none; then
+  LC_ALL=$LOCALE_TR_UTF8 ./test-c-strcasecmp${EXEEXT} locale || exit 1
+  LC_ALL=$LOCALE_TR_UTF8 ./test-c-strncasecmp${EXEEXT} locale || exit 1
+fi
+
+exit 0
diff --git a/libmissing/tests/test-c-strcasecmp.c b/libmissing/tests/test-c-strcasecmp.c
new file mode 100644
index 0000000..cfa5e12
--- /dev/null
+++ b/libmissing/tests/test-c-strcasecmp.c
@@ -0,0 +1,65 @@
+/* Test of case-insensitive string comparison function.
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Bruno Haible <[email protected]>, 2007.  */
+
+#include <config.h>
+
+#include "c-strcase.h"
+
+#include <locale.h>
+#include <string.h>
+
+#include "macros.h"
+
+int
+main (int argc, char *argv[])
+{
+  if (argc > 1)
+    {
+      /* configure should already have checked that the locale is supported.  */
+      if (setlocale (LC_ALL, "") == NULL)
+        return 1;
+    }
+
+  ASSERT (c_strcasecmp ("paragraph", "Paragraph") == 0);
+
+  ASSERT (c_strcasecmp ("paragrapH", "parAgRaph") == 0);
+
+  ASSERT (c_strcasecmp ("paragraph", "paraLyzed") < 0);
+  ASSERT (c_strcasecmp ("paraLyzed", "paragraph") > 0);
+
+  ASSERT (c_strcasecmp ("para", "paragraph") < 0);
+  ASSERT (c_strcasecmp ("paragraph", "para") > 0);
+
+  /* The following tests shows how c_strcasecmp() is different from
+     strcasecmp().  */
+
+  ASSERT (c_strcasecmp ("\311mile", "\351mile") < 0);
+  ASSERT (c_strcasecmp ("\351mile", "\311mile") > 0);
+
+  /* The following tests shows how c_strcasecmp() is different from
+     mbscasecmp().  */
+
+  ASSERT (c_strcasecmp ("\303\266zg\303\274r", "\303\226ZG\303\234R") > 0); /* özgür */
+  ASSERT (c_strcasecmp ("\303\226ZG\303\234R", "\303\266zg\303\274r") < 0); /* özgür */
+
+  /* This test shows how strings of different size cannot compare equal.  */
+  ASSERT (c_strcasecmp ("turkish", "TURK\304\260SH") < 0);
+  ASSERT (c_strcasecmp ("TURK\304\260SH", "turkish") > 0);
+
+  return 0;
+}
diff --git a/libmissing/tests/test-c-strncasecmp.c b/libmissing/tests/test-c-strncasecmp.c
new file mode 100644
index 0000000..b993cf9
--- /dev/null
+++ b/libmissing/tests/test-c-strncasecmp.c
@@ -0,0 +1,79 @@
+/* Test of case-insensitive string comparison function.
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Bruno Haible <[email protected]>, 2007.  */
+
+#include <config.h>
+
+#include "c-strcase.h"
+
+#include <locale.h>
+#include <string.h>
+
+#include "macros.h"
+
+int
+main (int argc, char *argv[])
+{
+  if (argc > 1)
+    {
+      /* configure should already have checked that the locale is supported.  */
+      if (setlocale (LC_ALL, "") == NULL)
+        return 1;
+    }
+
+  ASSERT (c_strncasecmp ("paragraph", "Paragraph", 1000000) == 0);
+  ASSERT (c_strncasecmp ("paragraph", "Paragraph", 9) == 0);
+
+  ASSERT (c_strncasecmp ("paragrapH", "parAgRaph", 1000000) == 0);
+  ASSERT (c_strncasecmp ("paragrapH", "parAgRaph", 9) == 0);
+
+  ASSERT (c_strncasecmp ("paragraph", "paraLyzed", 10) < 0);
+  ASSERT (c_strncasecmp ("paragraph", "paraLyzed", 9) < 0);
+  ASSERT (c_strncasecmp ("paragraph", "paraLyzed", 5) < 0);
+  ASSERT (c_strncasecmp ("paragraph", "paraLyzed", 4) == 0);
+  ASSERT (c_strncasecmp ("paraLyzed", "paragraph", 10) > 0);
+  ASSERT (c_strncasecmp ("paraLyzed", "paragraph", 9) > 0);
+  ASSERT (c_strncasecmp ("paraLyzed", "paragraph", 5) > 0);
+  ASSERT (c_strncasecmp ("paraLyzed", "paragraph", 4) == 0);
+
+  ASSERT (c_strncasecmp ("para", "paragraph", 10) < 0);
+  ASSERT (c_strncasecmp ("para", "paragraph", 9) < 0);
+  ASSERT (c_strncasecmp ("para", "paragraph", 5) < 0);
+  ASSERT (c_strncasecmp ("para", "paragraph", 4) == 0);
+  ASSERT (c_strncasecmp ("paragraph", "para", 10) > 0);
+  ASSERT (c_strncasecmp ("paragraph", "para", 9) > 0);
+  ASSERT (c_strncasecmp ("paragraph", "para", 5) > 0);
+  ASSERT (c_strncasecmp ("paragraph", "para", 4) == 0);
+
+  /* The following tests shows how c_strncasecmp() is different from
+     strncasecmp().  */
+
+  ASSERT (c_strncasecmp ("\311mily", "\351mile", 4) < 0);
+  ASSERT (c_strncasecmp ("\351mile", "\311mily", 4) > 0);
+
+  /* The following tests shows how c_strncasecmp() is different from
+     mbsncasecmp().  */
+
+  ASSERT (c_strncasecmp ("\303\266zg\303\274r", "\303\226ZG\303\234R", 99) > 0); /* özgür */
+  ASSERT (c_strncasecmp ("\303\226ZG\303\234R", "\303\266zg\303\274r", 99) < 0); /* özgür */
+
+  /* This test shows how strings of different size cannot compare equal.  */
+  ASSERT (c_strncasecmp ("turkish", "TURK\304\260SH", 7) < 0);
+  ASSERT (c_strncasecmp ("TURK\304\260SH", "turkish", 7) > 0);
+
+  return 0;
+}
diff --git a/libmissing/tests/test-dirent.c b/libmissing/tests/test-dirent.c
new file mode 100644
index 0000000..716b201
--- /dev/null
+++ b/libmissing/tests/test-dirent.c
@@ -0,0 +1,32 @@
+/* Test of <dirent.h> substitute.
+   Copyright (C) 2009 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Eric Blake <[email protected]>, 2009.  */
+
+#include <config.h>
+
+#include <dirent.h>
+
+/* Check for existence of required types.  */
+static DIR *dir _GL_UNUSED;
+static struct dirent d;
+static ino_t i;
+
+int
+main (void)
+{
+  return d.d_name[0] + i;
+}
diff --git a/libmissing/tests/test-errno.c b/libmissing/tests/test-errno.c
index 4642027..754ec13 100644
--- a/libmissing/tests/test-errno.c
+++ b/libmissing/tests/test-errno.c
@@ -1,5 +1,5 @@
 /* Test of <errno.h> substitute.
-   Copyright (C) 2008 Free Software Foundation, Inc.
+   Copyright (C) 2008, 2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
diff --git a/libmissing/tests/test-fnmatch.c b/libmissing/tests/test-fnmatch.c
index 9d0aaae..6cd2d8a 100644
--- a/libmissing/tests/test-fnmatch.c
+++ b/libmissing/tests/test-fnmatch.c
@@ -20,21 +20,10 @@
 
 #include <fnmatch.h>
 
-#include <stdio.h>
-#include <stdlib.h>
-
-#define ASSERT(expr)							\
-  do									\
-    {									\
-      if (!(expr))							\
-	{								\
-	  fprintf (stderr, "%s:%d: assertion failed\n",			\
-		   __FILE__, __LINE__);					\
-	  fflush (stderr);						\
-	  abort ();							\
-	}								\
-    }									\
-  while (0)
+#include "signature.h"
+SIGNATURE_CHECK (fnmatch, int, (char const *, char const *, int));
+
+#include "macros.h"
 
 int
 main ()
diff --git a/libmissing/tests/test-getaddrinfo.c b/libmissing/tests/test-getaddrinfo.c
index eeea3f7..a7e2381 100644
--- a/libmissing/tests/test-getaddrinfo.c
+++ b/libmissing/tests/test-getaddrinfo.c
@@ -18,8 +18,16 @@
 /* Written by Simon Josefsson.  */
 
 #include <config.h>
+
 #include <netdb.h>
 
+#include "signature.h"
+SIGNATURE_CHECK (freeaddrinfo, void, (struct addrinfo *));
+SIGNATURE_CHECK (gai_strerror, char const *, (int));
+SIGNATURE_CHECK (getaddrinfo, int, (char const *, char const *,
+                                    struct addrinfo const *,
+                                    struct addrinfo **));
+
 #include <arpa/inet.h>
 #include <errno.h>
 #include <netinet/in.h>
@@ -44,7 +52,8 @@
 # define EAI_SERVICE 0
 #endif
 
-int simple (char *host, char *service)
+static int
+simple (char const *host, char const *service)
 {
   char buf[BUFSIZ];
   static int skip = 0;
@@ -74,29 +83,31 @@ int simple (char *host, char *service)
   if (res != 0)
     {
       /* EAI_AGAIN is returned if no network is available. Don't fail
-	 the test merely because someone is down the country on their
-	 in-law's farm. */
+         the test merely because someone is down the country on their
+         in-law's farm. */
       if (res == EAI_AGAIN)
-	{
-	  skip++;
-	  fprintf (stderr, "skipping getaddrinfo test: no network?\n");
-	  return 77;
-	}
+        {
+          skip++;
+          fprintf (stderr, "skipping getaddrinfo test: no network?\n");
+          return 77;
+        }
       /* IRIX reports EAI_NONAME for "https".  Don't fail the test
-	 merely because of this.  */
+         merely because of this.  */
       if (res == EAI_NONAME)
-	return 0;
+        return 0;
       /* Solaris reports EAI_SERVICE for "http" and "https".  Don't
-	 fail the test merely because of this.  */
+         fail the test merely because of this.  */
       if (res == EAI_SERVICE)
-	return 0;
+        return 0;
+#ifdef EAI_NODATA
       /* AIX reports EAI_NODATA for "https".  Don't fail the test
-	 merely because of this.  */
+         merely because of this.  */
       if (res == EAI_NODATA)
-	return 0;
+        return 0;
+#endif
       /* Provide details if errno was set.  */
       if (res == EAI_SYSTEM)
-	dbgprintf ("system error: %s\n", strerror (err));
+        dbgprintf ("system error: %s\n", strerror (err));
 
       return 1;
     }
@@ -109,27 +120,27 @@ int simple (char *host, char *service)
       dbgprintf ("\tprotocol %x\n", ai->ai_protocol);
       dbgprintf ("\taddrlen %ld: ", (unsigned long) ai->ai_addrlen);
       dbgprintf ("\tFound %s\n",
-		 inet_ntop (ai->ai_family,
-			    &((struct sockaddr_in *)
-			      ai->ai_addr)->sin_addr,
-			    buf, sizeof (buf) - 1));
+                 inet_ntop (ai->ai_family,
+                            &((struct sockaddr_in *)
+                              ai->ai_addr)->sin_addr,
+                            buf, sizeof (buf) - 1));
       if (ai->ai_canonname)
-	dbgprintf ("\tFound %s...\n", ai->ai_canonname);
+        dbgprintf ("\tFound %s...\n", ai->ai_canonname);
 
       {
-	char ipbuf[BUFSIZ];
-	char portbuf[BUFSIZ];
-
-	res = getnameinfo (ai->ai_addr, ai->ai_addrlen,
-			   ipbuf, sizeof (ipbuf) - 1,
-			   portbuf, sizeof (portbuf) - 1,
-			   NI_NUMERICHOST|NI_NUMERICSERV);
-	dbgprintf ("\t\tgetnameinfo %d: %s\n", res, gai_strerror (res));
-	if (res == 0)
-	  {
-	    dbgprintf ("\t\tip %s\n", ipbuf);
-	    dbgprintf ("\t\tport %s\n", portbuf);
-	  }
+        char ipbuf[BUFSIZ];
+        char portbuf[BUFSIZ];
+
+        res = getnameinfo (ai->ai_addr, ai->ai_addrlen,
+                           ipbuf, sizeof (ipbuf) - 1,
+                           portbuf, sizeof (portbuf) - 1,
+                           NI_NUMERICHOST|NI_NUMERICSERV);
+        dbgprintf ("\t\tgetnameinfo %d: %s\n", res, gai_strerror (res));
+        if (res == 0)
+          {
+            dbgprintf ("\t\tip %s\n", ipbuf);
+            dbgprintf ("\t\tport %s\n", portbuf);
+          }
       }
 
     }
@@ -163,8 +174,8 @@ int main (void)
 
     if (data.wVersion < requested)
       {
-	WSACleanup ();
-	return 2;
+        WSACleanup ();
+        return 2;
       }
   }
 #endif
diff --git a/libmissing/tests/test-glob.c b/libmissing/tests/test-glob.c
index fc5ec30..f8d132e 100644
--- a/libmissing/tests/test-glob.c
+++ b/libmissing/tests/test-glob.c
@@ -20,22 +20,14 @@
 
 #include <glob.h>
 
-#include <stdio.h>
-#include <stdlib.h>
+#include "signature.h"
+SIGNATURE_CHECK (glob, int, (char const *, int, int (*) (char const *, int),
+                             glob_t *));
+SIGNATURE_CHECK (globfree, void, (glob_t *));
+
 #include <string.h>
 
-#define ASSERT(expr)							\
-  do									\
-    {									\
-      if (!(expr))							\
-	{								\
-	  fprintf (stderr, "%s:%d: assertion failed\n",			\
-		   __FILE__, __LINE__);					\
-	  fflush (stderr);						\
-	  abort ();							\
-	}								\
-    }									\
-  while (0)
+#include "macros.h"
 
 #define GL_NO_SUCH_FILE "/gnulib-magic-does-not-exist"
 
diff --git a/libmissing/tests/test-iconv.c b/libmissing/tests/test-iconv.c
new file mode 100644
index 0000000..66db918
--- /dev/null
+++ b/libmissing/tests/test-iconv.c
@@ -0,0 +1,148 @@
+/* Test of character set conversion.
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Bruno Haible <[email protected]>, 2007.  */
+
+#include <config.h>
+
+#if HAVE_ICONV
+# include <iconv.h>
+
+# ifndef ICONV_CONST
+#  define ICONV_CONST /* empty */
+# endif
+
+#include "signature.h"
+SIGNATURE_CHECK (iconv, size_t, (iconv_t, ICONV_CONST char **, size_t *,
+                                 char **, size_t *));
+SIGNATURE_CHECK (iconv_close, int, (iconv_t x));
+SIGNATURE_CHECK (iconv_open, iconv_t, (char const *, char const *));
+
+#endif
+
+#include <errno.h>
+#include <string.h>
+
+#include "macros.h"
+
+int
+main ()
+{
+#if HAVE_ICONV
+  /* Assume that iconv() supports at least the encodings ASCII, ISO-8859-1,
+     and UTF-8.  */
+  iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1");
+  iconv_t cd_utf8_to_88591 = iconv_open ("ISO-8859-1", "UTF-8");
+
+  ASSERT (cd_88591_to_utf8 != (iconv_t)(-1));
+  ASSERT (cd_utf8_to_88591 != (iconv_t)(-1));
+
+  /* Test conversion from ISO-8859-1 to UTF-8 with no errors.  */
+  {
+    static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
+    static const char expected[] = "\303\204rger mit b\303\266sen B\303\274bchen ohne Augenma\303\237";
+    char buf[50];
+    const char *inptr = input;
+    size_t inbytesleft = strlen (input);
+    char *outptr = buf;
+    size_t outbytesleft = sizeof (buf);
+    size_t res = iconv (cd_88591_to_utf8,
+                        (ICONV_CONST char **) &inptr, &inbytesleft,
+                        &outptr, &outbytesleft);
+    ASSERT (res == 0 && inbytesleft == 0);
+    ASSERT (outptr == buf + strlen (expected));
+    ASSERT (memcmp (buf, expected, strlen (expected)) == 0);
+  }
+
+  /* Test conversion from ISO-8859-1 to UTF-8 with E2BIG.  */
+  {
+    static const char input[] = "\304";
+    static char buf[2] = { (char)0xDE, (char)0xAD };
+    const char *inptr = input;
+    size_t inbytesleft = 1;
+    char *outptr = buf;
+    size_t outbytesleft = 1;
+    size_t res = iconv (cd_88591_to_utf8,
+                        (ICONV_CONST char **) &inptr, &inbytesleft,
+                        &outptr, &outbytesleft);
+    ASSERT (res == (size_t)(-1) && errno == E2BIG);
+    ASSERT (inbytesleft == 1);
+    ASSERT (outbytesleft == 1);
+    ASSERT ((unsigned char) buf[1] == 0xAD);
+    ASSERT ((unsigned char) buf[0] == 0xDE);
+  }
+
+  /* Test conversion from UTF-8 to ISO-8859-1 with no errors.  */
+  {
+    static const char input[] = "\303\204rger mit b\303\266sen B\303\274bchen ohne Augenma\303\237";
+    static const char expected[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
+    char buf[50];
+    const char *inptr = input;
+    size_t inbytesleft = strlen (input);
+    char *outptr = buf;
+    size_t outbytesleft = sizeof (buf);
+    size_t res = iconv (cd_utf8_to_88591,
+                        (ICONV_CONST char **) &inptr, &inbytesleft,
+                        &outptr, &outbytesleft);
+    ASSERT (res == 0 && inbytesleft == 0);
+    ASSERT (outptr == buf + strlen (expected));
+    ASSERT (memcmp (buf, expected, strlen (expected)) == 0);
+  }
+
+  /* Test conversion from UTF-8 to ISO-8859-1 with EILSEQ.  */
+  {
+    static const char input[] = "\342\202\254"; /* EURO SIGN */
+    char buf[10];
+    const char *inptr = input;
+    size_t inbytesleft = strlen (input);
+    char *outptr = buf;
+    size_t outbytesleft = sizeof (buf);
+    size_t res = iconv (cd_utf8_to_88591,
+                        (ICONV_CONST char **) &inptr, &inbytesleft,
+                        &outptr, &outbytesleft);
+    if (res == (size_t)(-1))
+      {
+        ASSERT (errno == EILSEQ);
+        ASSERT (inbytesleft == strlen (input) && outptr == buf);
+      }
+    else
+      {
+        ASSERT (res == 1);
+        ASSERT (inbytesleft == 0);
+      }
+  }
+
+  /* Test conversion from UTF-8 to ISO-8859-1 with EINVAL.  */
+  {
+    static const char input[] = "\342";
+    char buf[10];
+    const char *inptr = input;
+    size_t inbytesleft = 1;
+    char *outptr = buf;
+    size_t outbytesleft = sizeof (buf);
+    size_t res = iconv (cd_utf8_to_88591,
+                        (ICONV_CONST char **) &inptr, &inbytesleft,
+                        &outptr, &outbytesleft);
+    ASSERT (res == (size_t)(-1) && errno == EINVAL);
+    ASSERT (inbytesleft == 1 && outptr == buf);
+  }
+
+  iconv_close (cd_88591_to_utf8);
+  iconv_close (cd_utf8_to_88591);
+#endif
+
+  return 0;
+}
diff --git a/libmissing/tests/test-inet_ntop.c b/libmissing/tests/test-inet_ntop.c
new file mode 100644
index 0000000..d424b72
--- /dev/null
+++ b/libmissing/tests/test-inet_ntop.c
@@ -0,0 +1,56 @@
+/* Test of inet_ntop function.
+   Copyright (C) 2009 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Bruno Haible <[email protected]>, 2009.  */
+
+#include <config.h>
+
+#include <arpa/inet.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (inet_ntop, char const *, (int, void const *, char *,
+                                           socklen_t));
+
+#include <netinet/in.h>
+#include <sys/socket.h>
+#include <string.h>
+
+#include "macros.h"
+
+int
+main (void)
+{
+#if defined AF_INET /* HAVE_IPV4 */
+  {
+    struct in_addr internal;
+    char printable[16];
+    const char *result;
+
+    /* This machine was for a long time known as
+       ma2s2.mathematik.uni-karlsruhe.de.  */
+# ifdef WORDS_BIGENDIAN
+    internal.s_addr = 0x810D7302;
+# else
+    internal.s_addr = 0x02730D81;
+# endif
+    result = inet_ntop (AF_INET, &internal, printable, sizeof (printable));
+    ASSERT (result != NULL);
+    ASSERT (strcmp (result, "129.13.115.2") == 0);
+  }
+#endif
+
+  return 0;
+}
diff --git a/libmissing/tests/test-langinfo.c b/libmissing/tests/test-langinfo.c
new file mode 100644
index 0000000..9f0608f
--- /dev/null
+++ b/libmissing/tests/test-langinfo.c
@@ -0,0 +1,92 @@
+/* Test of <langinfo.h> substitute.
+   Copyright (C) 2009 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Bruno Haible <[email protected]>, 2009.  */
+
+#include <config.h>
+
+#include <langinfo.h>
+
+/* Check that all the nl_item values are defined.  */
+int items[] =
+  {
+    /* nl_langinfo items of the LC_CTYPE category */
+    CODESET,
+    /* nl_langinfo items of the LC_NUMERIC category */
+    RADIXCHAR,
+    THOUSEP,
+    /* nl_langinfo items of the LC_TIME category */
+    D_T_FMT,
+    D_FMT,
+    T_FMT,
+    T_FMT_AMPM,
+    AM_STR,
+    PM_STR,
+    DAY_1,
+    DAY_2,
+    DAY_3,
+    DAY_4,
+    DAY_5,
+    DAY_6,
+    DAY_7,
+    ABDAY_1,
+    ABDAY_2,
+    ABDAY_3,
+    ABDAY_4,
+    ABDAY_5,
+    ABDAY_6,
+    ABDAY_7,
+    MON_1,
+    MON_2,
+    MON_3,
+    MON_4,
+    MON_5,
+    MON_6,
+    MON_7,
+    MON_8,
+    MON_9,
+    MON_10,
+    MON_11,
+    MON_12,
+    ABMON_1,
+    ABMON_2,
+    ABMON_3,
+    ABMON_4,
+    ABMON_5,
+    ABMON_6,
+    ABMON_7,
+    ABMON_8,
+    ABMON_9,
+    ABMON_10,
+    ABMON_11,
+    ABMON_12,
+    ERA,
+    ERA_D_FMT,
+    ERA_D_T_FMT,
+    ERA_T_FMT,
+    ALT_DIGITS,
+    /* nl_langinfo items of the LC_MONETARY category */
+    CRNCYSTR,
+    /* nl_langinfo items of the LC_MESSAGES category */
+    YESEXPR,
+    NOEXPR
+  };
+
+int
+main (void)
+{
+  return 0;
+}
diff --git a/libmissing/tests/test-mbrtowc.c b/libmissing/tests/test-mbrtowc.c
index 8f1f1be..d84bafe 100644
--- a/libmissing/tests/test-mbrtowc.c
+++ b/libmissing/tests/test-mbrtowc.c
@@ -1,5 +1,5 @@
 /* Test of conversion of multibyte character to wide character.
-   Copyright (C) 2008 Free Software Foundation, Inc.
+   Copyright (C) 2008, 2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -20,22 +20,15 @@
 
 #include <wchar.h>
 
+#include "signature.h"
+SIGNATURE_CHECK (mbrtowc, size_t, (wchar_t *, char const *, size_t,
+                                   mbstate_t *));
+
 #include <locale.h>
 #include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
 
-#define ASSERT(expr) \
-  do									     \
-    {									     \
-      if (!(expr))							     \
-        {								     \
-          fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
-          fflush (stderr);						     \
-          abort ();							     \
-        }								     \
-    }									     \
-  while (0)
+#include "macros.h"
 
 int
 main (int argc, char *argv[])
@@ -81,40 +74,40 @@ main (int argc, char *argv[])
     memset (&state, '\0', sizeof (mbstate_t));
     for (c = 0; c < 0x100; c++)
       switch (c)
-	{
-	case '\t': case '\v': case '\f':
-	case ' ': case '!': case '"': case '#': case '%':
-	case '&': case '\'': case '(': case ')': case '*':
-	case '+': case ',': case '-': case '.': case '/':
-	case '0': case '1': case '2': case '3': case '4':
-	case '5': case '6': case '7': case '8': case '9':
-	case ':': case ';': case '<': case '=': case '>':
-	case '?':
-	case 'A': case 'B': case 'C': case 'D': case 'E':
-	case 'F': case 'G': case 'H': case 'I': case 'J':
-	case 'K': case 'L': case 'M': case 'N': case 'O':
-	case 'P': case 'Q': case 'R': case 'S': case 'T':
-	case 'U': case 'V': case 'W': case 'X': case 'Y':
-	case 'Z':
-	case '[': case '\\': case ']': case '^': case '_':
-	case 'a': case 'b': case 'c': case 'd': case 'e':
-	case 'f': case 'g': case 'h': case 'i': case 'j':
-	case 'k': case 'l': case 'm': case 'n': case 'o':
-	case 'p': case 'q': case 'r': case 's': case 't':
-	case 'u': case 'v': case 'w': case 'x': case 'y':
-	case 'z': case '{': case '|': case '}': case '~':
-	  /* c is in the ISO C "basic character set".  */
-	  buf[0] = c;
-	  wc = (wchar_t) 0xBADFACE;
-	  ret = mbrtowc (&wc, buf, 1, &state);
-	  ASSERT (ret == 1);
-	  ASSERT (wc == c);
-	  ASSERT (mbsinit (&state));
-	  ret = mbrtowc (NULL, buf, 1, &state);
-	  ASSERT (ret == 1);
-	  ASSERT (mbsinit (&state));
-	  break;
-	}
+        {
+        case '\t': case '\v': case '\f':
+        case ' ': case '!': case '"': case '#': case '%':
+        case '&': case '\'': case '(': case ')': case '*':
+        case '+': case ',': case '-': case '.': case '/':
+        case '0': case '1': case '2': case '3': case '4':
+        case '5': case '6': case '7': case '8': case '9':
+        case ':': case ';': case '<': case '=': case '>':
+        case '?':
+        case 'A': case 'B': case 'C': case 'D': case 'E':
+        case 'F': case 'G': case 'H': case 'I': case 'J':
+        case 'K': case 'L': case 'M': case 'N': case 'O':
+        case 'P': case 'Q': case 'R': case 'S': case 'T':
+        case 'U': case 'V': case 'W': case 'X': case 'Y':
+        case 'Z':
+        case '[': case '\\': case ']': case '^': case '_':
+        case 'a': case 'b': case 'c': case 'd': case 'e':
+        case 'f': case 'g': case 'h': case 'i': case 'j':
+        case 'k': case 'l': case 'm': case 'n': case 'o':
+        case 'p': case 'q': case 'r': case 's': case 't':
+        case 'u': case 'v': case 'w': case 'x': case 'y':
+        case 'z': case '{': case '|': case '}': case '~':
+          /* c is in the ISO C "basic character set".  */
+          buf[0] = c;
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, buf, 1, &state);
+          ASSERT (ret == 1);
+          ASSERT (wc == c);
+          ASSERT (mbsinit (&state));
+          ret = mbrtowc (NULL, buf, 1, &state);
+          ASSERT (ret == 1);
+          ASSERT (mbsinit (&state));
+          break;
+        }
   }
 
   /* Test special calling convention, passing a NULL pointer.  */
@@ -131,199 +124,199 @@ main (int argc, char *argv[])
     switch (argv[1][0])
       {
       case '1':
-	/* Locale encoding is ISO-8859-1 or ISO-8859-15.  */
-	{
-	  char input[] = "B\374\337er"; /* "Büßer" */
-	  memset (&state, '\0', sizeof (mbstate_t));
-
-	  wc = (wchar_t) 0xBADFACE;
-	  ret = mbrtowc (&wc, input, 1, &state);
-	  ASSERT (ret == 1);
-	  ASSERT (wc == 'B');
-	  ASSERT (mbsinit (&state));
-	  input[0] = '\0';
-
-	  wc = (wchar_t) 0xBADFACE;
-	  ret = mbrtowc (&wc, input + 1, 1, &state);
-	  ASSERT (ret == 1);
-	  ASSERT (wctob (wc) == (unsigned char) '\374');
-	  ASSERT (mbsinit (&state));
-	  input[1] = '\0';
-
-	  wc = (wchar_t) 0xBADFACE;
-	  ret = mbrtowc (&wc, input + 2, 3, &state);
-	  ASSERT (ret == 1);
-	  ASSERT (wctob (wc) == (unsigned char) '\337');
-	  ASSERT (mbsinit (&state));
-	  input[2] = '\0';
-
-	  wc = (wchar_t) 0xBADFACE;
-	  ret = mbrtowc (&wc, input + 3, 2, &state);
-	  ASSERT (ret == 1);
-	  ASSERT (wc == 'e');
-	  ASSERT (mbsinit (&state));
-	  input[3] = '\0';
-
-	  wc = (wchar_t) 0xBADFACE;
-	  ret = mbrtowc (&wc, input + 4, 1, &state);
-	  ASSERT (ret == 1);
-	  ASSERT (wc == 'r');
-	  ASSERT (mbsinit (&state));
-	}
-	return 0;
+        /* Locale encoding is ISO-8859-1 or ISO-8859-15.  */
+        {
+          char input[] = "B\374\337er"; /* "Büßer" */
+          memset (&state, '\0', sizeof (mbstate_t));
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input, 1, &state);
+          ASSERT (ret == 1);
+          ASSERT (wc == 'B');
+          ASSERT (mbsinit (&state));
+          input[0] = '\0';
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input + 1, 1, &state);
+          ASSERT (ret == 1);
+          ASSERT (wctob (wc) == (unsigned char) '\374');
+          ASSERT (mbsinit (&state));
+          input[1] = '\0';
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input + 2, 3, &state);
+          ASSERT (ret == 1);
+          ASSERT (wctob (wc) == (unsigned char) '\337');
+          ASSERT (mbsinit (&state));
+          input[2] = '\0';
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input + 3, 2, &state);
+          ASSERT (ret == 1);
+          ASSERT (wc == 'e');
+          ASSERT (mbsinit (&state));
+          input[3] = '\0';
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input + 4, 1, &state);
+          ASSERT (ret == 1);
+          ASSERT (wc == 'r');
+          ASSERT (mbsinit (&state));
+        }
+        return 0;
 
       case '2':
-	/* Locale encoding is UTF-8.  */
-	{
-	  char input[] = "B\303\274\303\237er"; /* "Büßer" */
-	  memset (&state, '\0', sizeof (mbstate_t));
-
-	  wc = (wchar_t) 0xBADFACE;
-	  ret = mbrtowc (&wc, input, 1, &state);
-	  ASSERT (ret == 1);
-	  ASSERT (wc == 'B');
-	  ASSERT (mbsinit (&state));
-	  input[0] = '\0';
-
-	  wc = (wchar_t) 0xBADFACE;
-	  ret = mbrtowc (&wc, input + 1, 1, &state);
-	  ASSERT (ret == (size_t)(-2));
-	  ASSERT (wc == (wchar_t) 0xBADFACE);
-	  ASSERT (!mbsinit (&state));
-	  input[1] = '\0';
-
-	  wc = (wchar_t) 0xBADFACE;
-	  ret = mbrtowc (&wc, input + 2, 5, &state);
-	  ASSERT (ret == 1);
-	  ASSERT (wctob (wc) == EOF);
-	  ASSERT (mbsinit (&state));
-	  input[2] = '\0';
-
-	  wc = (wchar_t) 0xBADFACE;
-	  ret = mbrtowc (&wc, input + 3, 4, &state);
-	  ASSERT (ret == 2);
-	  ASSERT (wctob (wc) == EOF);
-	  ASSERT (mbsinit (&state));
-	  input[3] = '\0';
-	  input[4] = '\0';
-
-	  wc = (wchar_t) 0xBADFACE;
-	  ret = mbrtowc (&wc, input + 5, 2, &state);
-	  ASSERT (ret == 1);
-	  ASSERT (wc == 'e');
-	  ASSERT (mbsinit (&state));
-	  input[5] = '\0';
-
-	  wc = (wchar_t) 0xBADFACE;
-	  ret = mbrtowc (&wc, input + 6, 1, &state);
-	  ASSERT (ret == 1);
-	  ASSERT (wc == 'r');
-	  ASSERT (mbsinit (&state));
-	}
-	return 0;
+        /* Locale encoding is UTF-8.  */
+        {
+          char input[] = "B\303\274\303\237er"; /* "Büßer" */
+          memset (&state, '\0', sizeof (mbstate_t));
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input, 1, &state);
+          ASSERT (ret == 1);
+          ASSERT (wc == 'B');
+          ASSERT (mbsinit (&state));
+          input[0] = '\0';
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input + 1, 1, &state);
+          ASSERT (ret == (size_t)(-2));
+          ASSERT (wc == (wchar_t) 0xBADFACE);
+          ASSERT (!mbsinit (&state));
+          input[1] = '\0';
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input + 2, 5, &state);
+          ASSERT (ret == 1);
+          ASSERT (wctob (wc) == EOF);
+          ASSERT (mbsinit (&state));
+          input[2] = '\0';
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input + 3, 4, &state);
+          ASSERT (ret == 2);
+          ASSERT (wctob (wc) == EOF);
+          ASSERT (mbsinit (&state));
+          input[3] = '\0';
+          input[4] = '\0';
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input + 5, 2, &state);
+          ASSERT (ret == 1);
+          ASSERT (wc == 'e');
+          ASSERT (mbsinit (&state));
+          input[5] = '\0';
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input + 6, 1, &state);
+          ASSERT (ret == 1);
+          ASSERT (wc == 'r');
+          ASSERT (mbsinit (&state));
+        }
+        return 0;
 
       case '3':
-	/* Locale encoding is EUC-JP.  */
-	{
-	  char input[] = "<\306\374\313\334\270\354>"; /* "<日本語>" */
-	  memset (&state, '\0', sizeof (mbstate_t));
-
-	  wc = (wchar_t) 0xBADFACE;
-	  ret = mbrtowc (&wc, input, 1, &state);
-	  ASSERT (ret == 1);
-	  ASSERT (wc == '<');
-	  ASSERT (mbsinit (&state));
-	  input[0] = '\0';
-
-	  wc = (wchar_t) 0xBADFACE;
-	  ret = mbrtowc (&wc, input + 1, 2, &state);
-	  ASSERT (ret == 2);
-	  ASSERT (wctob (wc) == EOF);
-	  ASSERT (mbsinit (&state));
-	  input[1] = '\0';
-	  input[2] = '\0';
-
-	  wc = (wchar_t) 0xBADFACE;
-	  ret = mbrtowc (&wc, input + 3, 1, &state);
-	  ASSERT (ret == (size_t)(-2));
-	  ASSERT (wc == (wchar_t) 0xBADFACE);
-	  ASSERT (!mbsinit (&state));
-	  input[3] = '\0';
-
-	  wc = (wchar_t) 0xBADFACE;
-	  ret = mbrtowc (&wc, input + 4, 4, &state);
-	  ASSERT (ret == 1);
-	  ASSERT (wctob (wc) == EOF);
-	  ASSERT (mbsinit (&state));
-	  input[4] = '\0';
-
-	  wc = (wchar_t) 0xBADFACE;
-	  ret = mbrtowc (&wc, input + 5, 3, &state);
-	  ASSERT (ret == 2);
-	  ASSERT (wctob (wc) == EOF);
-	  ASSERT (mbsinit (&state));
-	  input[5] = '\0';
-	  input[6] = '\0';
-
-	  wc = (wchar_t) 0xBADFACE;
-	  ret = mbrtowc (&wc, input + 7, 1, &state);
-	  ASSERT (ret == 1);
-	  ASSERT (wc == '>');
-	  ASSERT (mbsinit (&state));
-	}
-	return 0;
+        /* Locale encoding is EUC-JP.  */
+        {
+          char input[] = "<\306\374\313\334\270\354>"; /* "<日本語>" */
+          memset (&state, '\0', sizeof (mbstate_t));
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input, 1, &state);
+          ASSERT (ret == 1);
+          ASSERT (wc == '<');
+          ASSERT (mbsinit (&state));
+          input[0] = '\0';
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input + 1, 2, &state);
+          ASSERT (ret == 2);
+          ASSERT (wctob (wc) == EOF);
+          ASSERT (mbsinit (&state));
+          input[1] = '\0';
+          input[2] = '\0';
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input + 3, 1, &state);
+          ASSERT (ret == (size_t)(-2));
+          ASSERT (wc == (wchar_t) 0xBADFACE);
+          ASSERT (!mbsinit (&state));
+          input[3] = '\0';
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input + 4, 4, &state);
+          ASSERT (ret == 1);
+          ASSERT (wctob (wc) == EOF);
+          ASSERT (mbsinit (&state));
+          input[4] = '\0';
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input + 5, 3, &state);
+          ASSERT (ret == 2);
+          ASSERT (wctob (wc) == EOF);
+          ASSERT (mbsinit (&state));
+          input[5] = '\0';
+          input[6] = '\0';
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input + 7, 1, &state);
+          ASSERT (ret == 1);
+          ASSERT (wc == '>');
+          ASSERT (mbsinit (&state));
+        }
+        return 0;
 
       case '4':
-	/* Locale encoding is GB18030.  */
-	{
-	  char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */
-	  memset (&state, '\0', sizeof (mbstate_t));
-
-	  wc = (wchar_t) 0xBADFACE;
-	  ret = mbrtowc (&wc, input, 1, &state);
-	  ASSERT (ret == 1);
-	  ASSERT (wc == 'B');
-	  ASSERT (mbsinit (&state));
-	  input[0] = '\0';
-
-	  wc = (wchar_t) 0xBADFACE;
-	  ret = mbrtowc (&wc, input + 1, 1, &state);
-	  ASSERT (ret == (size_t)(-2));
-	  ASSERT (wc == (wchar_t) 0xBADFACE);
-	  ASSERT (!mbsinit (&state));
-	  input[1] = '\0';
-
-	  wc = (wchar_t) 0xBADFACE;
-	  ret = mbrtowc (&wc, input + 2, 7, &state);
-	  ASSERT (ret == 1);
-	  ASSERT (wctob (wc) == EOF);
-	  ASSERT (mbsinit (&state));
-	  input[2] = '\0';
-
-	  wc = (wchar_t) 0xBADFACE;
-	  ret = mbrtowc (&wc, input + 3, 6, &state);
-	  ASSERT (ret == 4);
-	  ASSERT (wctob (wc) == EOF);
-	  ASSERT (mbsinit (&state));
-	  input[3] = '\0';
-	  input[4] = '\0';
-	  input[5] = '\0';
-	  input[6] = '\0';
-
-	  wc = (wchar_t) 0xBADFACE;
-	  ret = mbrtowc (&wc, input + 7, 2, &state);
-	  ASSERT (ret == 1);
-	  ASSERT (wc == 'e');
-	  ASSERT (mbsinit (&state));
-	  input[5] = '\0';
-
-	  wc = (wchar_t) 0xBADFACE;
-	  ret = mbrtowc (&wc, input + 8, 1, &state);
-	  ASSERT (ret == 1);
-	  ASSERT (wc == 'r');
-	  ASSERT (mbsinit (&state));
-	}
-	return 0;
+        /* Locale encoding is GB18030.  */
+        {
+          char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */
+          memset (&state, '\0', sizeof (mbstate_t));
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input, 1, &state);
+          ASSERT (ret == 1);
+          ASSERT (wc == 'B');
+          ASSERT (mbsinit (&state));
+          input[0] = '\0';
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input + 1, 1, &state);
+          ASSERT (ret == (size_t)(-2));
+          ASSERT (wc == (wchar_t) 0xBADFACE);
+          ASSERT (!mbsinit (&state));
+          input[1] = '\0';
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input + 2, 7, &state);
+          ASSERT (ret == 1);
+          ASSERT (wctob (wc) == EOF);
+          ASSERT (mbsinit (&state));
+          input[2] = '\0';
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input + 3, 6, &state);
+          ASSERT (ret == 4);
+          ASSERT (wctob (wc) == EOF);
+          ASSERT (mbsinit (&state));
+          input[3] = '\0';
+          input[4] = '\0';
+          input[5] = '\0';
+          input[6] = '\0';
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input + 7, 2, &state);
+          ASSERT (ret == 1);
+          ASSERT (wc == 'e');
+          ASSERT (mbsinit (&state));
+          input[5] = '\0';
+
+          wc = (wchar_t) 0xBADFACE;
+          ret = mbrtowc (&wc, input + 8, 1, &state);
+          ASSERT (ret == 1);
+          ASSERT (wc == 'r');
+          ASSERT (mbsinit (&state));
+        }
+        return 0;
       }
 
   return 1;
diff --git a/libmissing/tests/test-mbsinit.c b/libmissing/tests/test-mbsinit.c
index 5d4c9c3..e72086d 100644
--- a/libmissing/tests/test-mbsinit.c
+++ b/libmissing/tests/test-mbsinit.c
@@ -1,5 +1,5 @@
 /* Test of test for initial conversion state.
-   Copyright (C) 2008 Free Software Foundation, Inc.
+   Copyright (C) 2008, 2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -20,21 +20,12 @@
 
 #include <wchar.h>
 
+#include "signature.h"
+SIGNATURE_CHECK (mbsinit, int, (const mbstate_t *));
+
 #include <locale.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#define ASSERT(expr) \
-  do									     \
-    {									     \
-      if (!(expr))							     \
-        {								     \
-          fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
-          fflush (stderr);						     \
-          abort ();							     \
-        }								     \
-    }									     \
-  while (0)
+
+#include "macros.h"
 
 int
 main (int argc, char *argv[])
@@ -51,7 +42,7 @@ main (int argc, char *argv[])
 
       /* configure should already have checked that the locale is supported.  */
       if (setlocale (LC_ALL, "") == NULL)
-	return 1;
+        return 1;
 
       ret = mbrtowc (&wc, input, 1, &state);
       ASSERT (ret == (size_t)(-2));
diff --git a/libmissing/tests/test-mbsrtowcs.c b/libmissing/tests/test-mbsrtowcs.c
index 81e67c1..4447f2c 100644
--- a/libmissing/tests/test-mbsrtowcs.c
+++ b/libmissing/tests/test-mbsrtowcs.c
@@ -1,5 +1,5 @@
 /* Test of conversion of string to wide string.
-   Copyright (C) 2008 Free Software Foundation, Inc.
+   Copyright (C) 2008, 2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -20,22 +20,15 @@
 
 #include <wchar.h>
 
+#include "signature.h"
+SIGNATURE_CHECK (mbsrtowcs, size_t, (wchar_t *, char const **, size_t,
+                                     mbstate_t *));
+
 #include <locale.h>
 #include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
 
-#define ASSERT(expr) \
-  do									     \
-    {									     \
-      if (!(expr))							     \
-        {								     \
-          fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
-          fflush (stderr);						     \
-          abort ();							     \
-        }								     \
-    }									     \
-  while (0)
+#include "macros.h"
 
 int
 main (int argc, char *argv[])
@@ -84,214 +77,214 @@ main (int argc, char *argv[])
       int unlimited;
 
       for (unlimited = 0; unlimited < 2; unlimited++)
-	{
-	  #define BUFSIZE 10
-	  wchar_t buf[BUFSIZE];
-	  const char *src;
-	  mbstate_t temp_state;
-
-	  {
-	    size_t i;
-	    for (i = 0; i < BUFSIZE; i++)
-	      buf[i] = (wchar_t) 0xBADFACE;
-	  }
-
-	  switch (argv[1][0])
-	    {
-	    case '1':
-	      /* Locale encoding is ISO-8859-1 or ISO-8859-15.  */
-	      {
-		char input[] = "B\374\337er"; /* "Büßer" */
-		memset (&state, '\0', sizeof (mbstate_t));
-
-		wc = (wchar_t) 0xBADFACE;
-		ret = mbrtowc (&wc, input, 1, &state);
-		ASSERT (ret == 1);
-		ASSERT (wc == 'B');
-		ASSERT (mbsinit (&state));
-		input[0] = '\0';
-
-		wc = (wchar_t) 0xBADFACE;
-		ret = mbrtowc (&wc, input + 1, 1, &state);
-		ASSERT (ret == 1);
-		ASSERT (wctob (wc) == (unsigned char) '\374');
-		ASSERT (mbsinit (&state));
-		input[1] = '\0';
-
-		src = input + 2;
-		temp_state = state;
-		ret = mbsrtowcs (NULL, &src, unlimited ? BUFSIZE : 1, &temp_state);
-		ASSERT (ret == 3);
-		ASSERT (src == input + 2);
-		ASSERT (mbsinit (&state));
-
-		src = input + 2;
-		ret = mbsrtowcs (buf, &src, unlimited ? BUFSIZE : 1, &state);
-		ASSERT (ret == (unlimited ? 3 : 1));
-		ASSERT (src == (unlimited ? NULL : input + 3));
-		ASSERT (wctob (buf[0]) == (unsigned char) '\337');
-		if (unlimited)
-		  {
-		    ASSERT (buf[1] == 'e');
-		    ASSERT (buf[2] == 'r');
-		    ASSERT (buf[3] == 0);
-		    ASSERT (buf[4] == (wchar_t) 0xBADFACE);
-		  }
-		else
-		  ASSERT (buf[1] == (wchar_t) 0xBADFACE);
-		ASSERT (mbsinit (&state));
-	      }
-	      break;
-
-	    case '2':
-	      /* Locale encoding is UTF-8.  */
-	      {
-		char input[] = "B\303\274\303\237er"; /* "Büßer" */
-		memset (&state, '\0', sizeof (mbstate_t));
-
-		wc = (wchar_t) 0xBADFACE;
-		ret = mbrtowc (&wc, input, 1, &state);
-		ASSERT (ret == 1);
-		ASSERT (wc == 'B');
-		ASSERT (mbsinit (&state));
-		input[0] = '\0';
-
-		wc = (wchar_t) 0xBADFACE;
-		ret = mbrtowc (&wc, input + 1, 1, &state);
-		ASSERT (ret == (size_t)(-2));
-		ASSERT (wc == (wchar_t) 0xBADFACE);
-		ASSERT (!mbsinit (&state));
-		input[1] = '\0';
-
-		src = input + 2;
-		temp_state = state;
-		ret = mbsrtowcs (NULL, &src, unlimited ? BUFSIZE : 2, &temp_state);
-		ASSERT (ret == 4);
-		ASSERT (src == input + 2);
-		ASSERT (!mbsinit (&state));
-
-		src = input + 2;
-		ret = mbsrtowcs (buf, &src, unlimited ? BUFSIZE : 2, &state);
-		ASSERT (ret == (unlimited ? 4 : 2));
-		ASSERT (src == (unlimited ? NULL : input + 5));
-		ASSERT (wctob (buf[0]) == EOF);
-		ASSERT (wctob (buf[1]) == EOF);
-		if (unlimited)
-		  {
-		    ASSERT (buf[2] == 'e');
-		    ASSERT (buf[3] == 'r');
-		    ASSERT (buf[4] == 0);
-		    ASSERT (buf[5] == (wchar_t) 0xBADFACE);
-		  }
-		else
-		  ASSERT (buf[2] == (wchar_t) 0xBADFACE);
-		ASSERT (mbsinit (&state));
-	      }
-	      break;
-
-	    case '3':
-	      /* Locale encoding is EUC-JP.  */
-	      {
-		char input[] = "<\306\374\313\334\270\354>"; /* "<日本語>" */
-		memset (&state, '\0', sizeof (mbstate_t));
-
-		wc = (wchar_t) 0xBADFACE;
-		ret = mbrtowc (&wc, input, 1, &state);
-		ASSERT (ret == 1);
-		ASSERT (wc == '<');
-		ASSERT (mbsinit (&state));
-		input[0] = '\0';
-
-		wc = (wchar_t) 0xBADFACE;
-		ret = mbrtowc (&wc, input + 1, 2, &state);
-		ASSERT (ret == 2);
-		ASSERT (wctob (wc) == EOF);
-		ASSERT (mbsinit (&state));
-		input[1] = '\0';
-		input[2] = '\0';
-
-		wc = (wchar_t) 0xBADFACE;
-		ret = mbrtowc (&wc, input + 3, 1, &state);
-		ASSERT (ret == (size_t)(-2));
-		ASSERT (wc == (wchar_t) 0xBADFACE);
-		ASSERT (!mbsinit (&state));
-		input[3] = '\0';
-
-		src = input + 4;
-		temp_state = state;
-		ret = mbsrtowcs (NULL, &src, unlimited ? BUFSIZE : 2, &temp_state);
-		ASSERT (ret == 3);
-		ASSERT (src == input + 4);
-		ASSERT (!mbsinit (&state));
-
-		src = input + 4;
-		ret = mbsrtowcs (buf, &src, unlimited ? BUFSIZE : 2, &state);
-		ASSERT (ret == (unlimited ? 3 : 2));
-		ASSERT (src == (unlimited ? NULL : input + 7));
-		ASSERT (wctob (buf[0]) == EOF);
-		ASSERT (wctob (buf[1]) == EOF);
-		if (unlimited)
-		  {
-		    ASSERT (buf[2] == '>');
-		    ASSERT (buf[3] == 0);
-		    ASSERT (buf[4] == (wchar_t) 0xBADFACE);
-		  }
-		else
-		  ASSERT (buf[2] == (wchar_t) 0xBADFACE);
-		ASSERT (mbsinit (&state));
-	      }
-	      break;
-
-	    case '4':
-	      /* Locale encoding is GB18030.  */
-	      {
-		char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */
-		memset (&state, '\0', sizeof (mbstate_t));
-
-		wc = (wchar_t) 0xBADFACE;
-		ret = mbrtowc (&wc, input, 1, &state);
-		ASSERT (ret == 1);
-		ASSERT (wc == 'B');
-		ASSERT (mbsinit (&state));
-		input[0] = '\0';
-
-		wc = (wchar_t) 0xBADFACE;
-		ret = mbrtowc (&wc, input + 1, 1, &state);
-		ASSERT (ret == (size_t)(-2));
-		ASSERT (wc == (wchar_t) 0xBADFACE);
-		ASSERT (!mbsinit (&state));
-		input[1] = '\0';
-
-		src = input + 2;
-		temp_state = state;
-		ret = mbsrtowcs (NULL, &src, unlimited ? BUFSIZE : 2, &temp_state);
-		ASSERT (ret == 4);
-		ASSERT (src == input + 2);
-		ASSERT (!mbsinit (&state));
-
-		src = input + 2;
-		ret = mbsrtowcs (buf, &src, unlimited ? BUFSIZE : 2, &state);
-		ASSERT (ret == (unlimited ? 4 : 2));
-		ASSERT (src == (unlimited ? NULL : input + 7));
-		ASSERT (wctob (buf[0]) == EOF);
-		ASSERT (wctob (buf[1]) == EOF);
-		if (unlimited)
-		  {
-		    ASSERT (buf[2] == 'e');
-		    ASSERT (buf[3] == 'r');
-		    ASSERT (buf[4] == 0);
-		    ASSERT (buf[5] == (wchar_t) 0xBADFACE);
-		  }
-		else
-		  ASSERT (buf[2] == (wchar_t) 0xBADFACE);
-		ASSERT (mbsinit (&state));
-	      }
-	      break;
-
-	    default:
-	      return 1;
-	    }
-	}
+        {
+          #define BUFSIZE 10
+          wchar_t buf[BUFSIZE];
+          const char *src;
+          mbstate_t temp_state;
+
+          {
+            size_t i;
+            for (i = 0; i < BUFSIZE; i++)
+              buf[i] = (wchar_t) 0xBADFACE;
+          }
+
+          switch (argv[1][0])
+            {
+            case '1':
+              /* Locale encoding is ISO-8859-1 or ISO-8859-15.  */
+              {
+                char input[] = "B\374\337er"; /* "Büßer" */
+                memset (&state, '\0', sizeof (mbstate_t));
+
+                wc = (wchar_t) 0xBADFACE;
+                ret = mbrtowc (&wc, input, 1, &state);
+                ASSERT (ret == 1);
+                ASSERT (wc == 'B');
+                ASSERT (mbsinit (&state));
+                input[0] = '\0';
+
+                wc = (wchar_t) 0xBADFACE;
+                ret = mbrtowc (&wc, input + 1, 1, &state);
+                ASSERT (ret == 1);
+                ASSERT (wctob (wc) == (unsigned char) '\374');
+                ASSERT (mbsinit (&state));
+                input[1] = '\0';
+
+                src = input + 2;
+                temp_state = state;
+                ret = mbsrtowcs (NULL, &src, unlimited ? BUFSIZE : 1, &temp_state);
+                ASSERT (ret == 3);
+                ASSERT (src == input + 2);
+                ASSERT (mbsinit (&state));
+
+                src = input + 2;
+                ret = mbsrtowcs (buf, &src, unlimited ? BUFSIZE : 1, &state);
+                ASSERT (ret == (unlimited ? 3 : 1));
+                ASSERT (src == (unlimited ? NULL : input + 3));
+                ASSERT (wctob (buf[0]) == (unsigned char) '\337');
+                if (unlimited)
+                  {
+                    ASSERT (buf[1] == 'e');
+                    ASSERT (buf[2] == 'r');
+                    ASSERT (buf[3] == 0);
+                    ASSERT (buf[4] == (wchar_t) 0xBADFACE);
+                  }
+                else
+                  ASSERT (buf[1] == (wchar_t) 0xBADFACE);
+                ASSERT (mbsinit (&state));
+              }
+              break;
+
+            case '2':
+              /* Locale encoding is UTF-8.  */
+              {
+                char input[] = "B\303\274\303\237er"; /* "Büßer" */
+                memset (&state, '\0', sizeof (mbstate_t));
+
+                wc = (wchar_t) 0xBADFACE;
+                ret = mbrtowc (&wc, input, 1, &state);
+                ASSERT (ret == 1);
+                ASSERT (wc == 'B');
+                ASSERT (mbsinit (&state));
+                input[0] = '\0';
+
+                wc = (wchar_t) 0xBADFACE;
+                ret = mbrtowc (&wc, input + 1, 1, &state);
+                ASSERT (ret == (size_t)(-2));
+                ASSERT (wc == (wchar_t) 0xBADFACE);
+                ASSERT (!mbsinit (&state));
+                input[1] = '\0';
+
+                src = input + 2;
+                temp_state = state;
+                ret = mbsrtowcs (NULL, &src, unlimited ? BUFSIZE : 2, &temp_state);
+                ASSERT (ret == 4);
+                ASSERT (src == input + 2);
+                ASSERT (!mbsinit (&state));
+
+                src = input + 2;
+                ret = mbsrtowcs (buf, &src, unlimited ? BUFSIZE : 2, &state);
+                ASSERT (ret == (unlimited ? 4 : 2));
+                ASSERT (src == (unlimited ? NULL : input + 5));
+                ASSERT (wctob (buf[0]) == EOF);
+                ASSERT (wctob (buf[1]) == EOF);
+                if (unlimited)
+                  {
+                    ASSERT (buf[2] == 'e');
+                    ASSERT (buf[3] == 'r');
+                    ASSERT (buf[4] == 0);
+                    ASSERT (buf[5] == (wchar_t) 0xBADFACE);
+                  }
+                else
+                  ASSERT (buf[2] == (wchar_t) 0xBADFACE);
+                ASSERT (mbsinit (&state));
+              }
+              break;
+
+            case '3':
+              /* Locale encoding is EUC-JP.  */
+              {
+                char input[] = "<\306\374\313\334\270\354>"; /* "<日本語>" */
+                memset (&state, '\0', sizeof (mbstate_t));
+
+                wc = (wchar_t) 0xBADFACE;
+                ret = mbrtowc (&wc, input, 1, &state);
+                ASSERT (ret == 1);
+                ASSERT (wc == '<');
+                ASSERT (mbsinit (&state));
+                input[0] = '\0';
+
+                wc = (wchar_t) 0xBADFACE;
+                ret = mbrtowc (&wc, input + 1, 2, &state);
+                ASSERT (ret == 2);
+                ASSERT (wctob (wc) == EOF);
+                ASSERT (mbsinit (&state));
+                input[1] = '\0';
+                input[2] = '\0';
+
+                wc = (wchar_t) 0xBADFACE;
+                ret = mbrtowc (&wc, input + 3, 1, &state);
+                ASSERT (ret == (size_t)(-2));
+                ASSERT (wc == (wchar_t) 0xBADFACE);
+                ASSERT (!mbsinit (&state));
+                input[3] = '\0';
+
+                src = input + 4;
+                temp_state = state;
+                ret = mbsrtowcs (NULL, &src, unlimited ? BUFSIZE : 2, &temp_state);
+                ASSERT (ret == 3);
+                ASSERT (src == input + 4);
+                ASSERT (!mbsinit (&state));
+
+                src = input + 4;
+                ret = mbsrtowcs (buf, &src, unlimited ? BUFSIZE : 2, &state);
+                ASSERT (ret == (unlimited ? 3 : 2));
+                ASSERT (src == (unlimited ? NULL : input + 7));
+                ASSERT (wctob (buf[0]) == EOF);
+                ASSERT (wctob (buf[1]) == EOF);
+                if (unlimited)
+                  {
+                    ASSERT (buf[2] == '>');
+                    ASSERT (buf[3] == 0);
+                    ASSERT (buf[4] == (wchar_t) 0xBADFACE);
+                  }
+                else
+                  ASSERT (buf[2] == (wchar_t) 0xBADFACE);
+                ASSERT (mbsinit (&state));
+              }
+              break;
+
+            case '4':
+              /* Locale encoding is GB18030.  */
+              {
+                char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */
+                memset (&state, '\0', sizeof (mbstate_t));
+
+                wc = (wchar_t) 0xBADFACE;
+                ret = mbrtowc (&wc, input, 1, &state);
+                ASSERT (ret == 1);
+                ASSERT (wc == 'B');
+                ASSERT (mbsinit (&state));
+                input[0] = '\0';
+
+                wc = (wchar_t) 0xBADFACE;
+                ret = mbrtowc (&wc, input + 1, 1, &state);
+                ASSERT (ret == (size_t)(-2));
+                ASSERT (wc == (wchar_t) 0xBADFACE);
+                ASSERT (!mbsinit (&state));
+                input[1] = '\0';
+
+                src = input + 2;
+                temp_state = state;
+                ret = mbsrtowcs (NULL, &src, unlimited ? BUFSIZE : 2, &temp_state);
+                ASSERT (ret == 4);
+                ASSERT (src == input + 2);
+                ASSERT (!mbsinit (&state));
+
+                src = input + 2;
+                ret = mbsrtowcs (buf, &src, unlimited ? BUFSIZE : 2, &state);
+                ASSERT (ret == (unlimited ? 4 : 2));
+                ASSERT (src == (unlimited ? NULL : input + 7));
+                ASSERT (wctob (buf[0]) == EOF);
+                ASSERT (wctob (buf[1]) == EOF);
+                if (unlimited)
+                  {
+                    ASSERT (buf[2] == 'e');
+                    ASSERT (buf[3] == 'r');
+                    ASSERT (buf[4] == 0);
+                    ASSERT (buf[5] == (wchar_t) 0xBADFACE);
+                  }
+                else
+                  ASSERT (buf[2] == (wchar_t) 0xBADFACE);
+                ASSERT (mbsinit (&state));
+              }
+              break;
+
+            default:
+              return 1;
+            }
+        }
 
       return 0;
     }
diff --git a/libmissing/tests/test-memchr.c b/libmissing/tests/test-memchr.c
index 1124f8b..5d31e76 100644
--- a/libmissing/tests/test-memchr.c
+++ b/libmissing/tests/test-memchr.c
@@ -19,29 +19,20 @@
 
 #include <string.h>
 
-#include <stdio.h>
+#include "signature.h"
+SIGNATURE_CHECK (memchr, void *, (void const *, int, size_t));
+
 #include <stdlib.h>
 
 #include "zerosize-ptr.h"
-
-#define ASSERT(expr) \
-  do									     \
-    {									     \
-      if (!(expr))							     \
-	{								     \
-	  fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
-	  fflush (stderr);						     \
-	  abort ();							     \
-	}								     \
-    }									     \
-  while (0)
+#include "macros.h"
 
 /* Calculating void * + int is not portable, so this wrapper converts
    to char * to make the tests easier to write.  */
 #define MEMCHR (char *) memchr
 
 int
-main ()
+main (void)
 {
   size_t n = 0x100000;
   char *input = malloc (n);
@@ -76,7 +67,7 @@ main ()
     size_t repeat = 10000;
     for (; repeat > 0; repeat--)
       {
-	ASSERT (MEMCHR (input, 'c', n) == input + 2);
+        ASSERT (MEMCHR (input, 'c', n) == input + 2);
       }
   }
 
@@ -85,12 +76,12 @@ main ()
     int i, j;
     for (i = 0; i < 32; i++)
       {
-	for (j = 0; j < 256; j++)
-	  input[i + j] = j;
-	for (j = 0; j < 256; j++)
-	  {
-	    ASSERT (MEMCHR (input + i, j, 256) == input + i + j);
-	  }
+        for (j = 0; j < 256; j++)
+          input[i + j] = j;
+        for (j = 0; j < 256; j++)
+          {
+            ASSERT (MEMCHR (input + i, j, 256) == input + i + j);
+          }
       }
   }
 
@@ -102,25 +93,23 @@ main ()
 
     if (page_boundary != NULL)
       {
-	int n;
-
-	for (n = 1; n <= 500; n++)
-	  {
-	    char *mem = page_boundary - n;
-	    memset (mem, 'X', n);
-	    ASSERT (MEMCHR (mem, 'U', n) == NULL);
-
-	    {
-	      int i;
-
-	      for (i = 0; i < n; i++)
-		{
-		  mem[i] = 'U';
-		  ASSERT (MEMCHR (mem, 'U', 4000) == mem + i);
-		  mem[i] = 'X';
-		}
-	    }
-	  }
+        for (n = 1; n <= 500; n++)
+          {
+            char *mem = page_boundary - n;
+            memset (mem, 'X', n);
+            ASSERT (MEMCHR (mem, 'U', n) == NULL);
+
+            {
+              size_t i;
+
+              for (i = 0; i < n; i++)
+                {
+                  mem[i] = 'U';
+                  ASSERT (MEMCHR (mem, 'U', 4000) == mem + i);
+                  mem[i] = 'X';
+                }
+            }
+          }
       }
   }
 
diff --git a/libmissing/tests/test-netdb.c b/libmissing/tests/test-netdb.c
index cde9105..9202c74 100644
--- a/libmissing/tests/test-netdb.c
+++ b/libmissing/tests/test-netdb.c
@@ -1,5 +1,5 @@
 /* Test of <netdb.h> substitute.
-   Copyright (C) 2007-2008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
diff --git a/libmissing/tests/test-netinet_in.c b/libmissing/tests/test-netinet_in.c
index b195719..5a61557 100644
--- a/libmissing/tests/test-netinet_in.c
+++ b/libmissing/tests/test-netinet_in.c
@@ -1,5 +1,5 @@
 /* Test of <netinet/in.h> substitute.
-   Copyright (C) 2007 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -21,7 +21,7 @@
 #include <netinet/in.h>
 
 int
-main ()
+main (void)
 {
   return 0;
 }
diff --git a/libmissing/tests/test-nl_langinfo.c b/libmissing/tests/test-nl_langinfo.c
new file mode 100644
index 0000000..4a79b50
--- /dev/null
+++ b/libmissing/tests/test-nl_langinfo.c
@@ -0,0 +1,115 @@
+/* Test of nl_langinfo replacement.
+   Copyright (C) 2009 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Bruno Haible <[email protected]>, 2009.  */
+
+#include <config.h>
+
+#include <langinfo.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (nl_langinfo, char *, (nl_item));
+
+#include <locale.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "c-strcase.h"
+#include "macros.h"
+
+int
+main (int argc, char *argv[])
+{
+  int pass = atoi (argv[1]);
+  /* pass    locale
+      0        C
+      1        traditional French locale
+      2        French UTF-8 locale
+   */
+
+  setlocale (LC_ALL, "");
+
+  /* nl_langinfo items of the LC_CTYPE category */
+  ASSERT (strlen (nl_langinfo (CODESET)) > 0);
+  if (pass == 2)
+    {
+      const char *codeset = nl_langinfo (CODESET);
+      ASSERT (c_strcasecmp (codeset, "UTF-8") == 0 || c_strcasecmp (codeset, "UTF8") == 0);
+    }
+  /* nl_langinfo items of the LC_NUMERIC category */
+  ASSERT (strlen (nl_langinfo (RADIXCHAR)) > 0);
+  ASSERT (strlen (nl_langinfo (THOUSEP)) >= 0);
+  /* nl_langinfo items of the LC_TIME category */
+  ASSERT (strlen (nl_langinfo (D_T_FMT)) > 0);
+  ASSERT (strlen (nl_langinfo (D_FMT)) > 0);
+  ASSERT (strlen (nl_langinfo (T_FMT)) > 0);
+  ASSERT (strlen (nl_langinfo (T_FMT_AMPM)) >= (pass == 0 ? 1 : 0));
+  ASSERT (strlen (nl_langinfo (AM_STR)) >= (pass == 0 ? 1 : 0));
+  ASSERT (strlen (nl_langinfo (PM_STR)) >= (pass == 0 ? 1 : 0));
+  ASSERT (strlen (nl_langinfo (DAY_1)) > 0);
+  ASSERT (strlen (nl_langinfo (DAY_2)) > 0);
+  ASSERT (strlen (nl_langinfo (DAY_3)) > 0);
+  ASSERT (strlen (nl_langinfo (DAY_4)) > 0);
+  ASSERT (strlen (nl_langinfo (DAY_5)) > 0);
+  ASSERT (strlen (nl_langinfo (DAY_6)) > 0);
+  ASSERT (strlen (nl_langinfo (DAY_7)) > 0);
+  ASSERT (strlen (nl_langinfo (ABDAY_1)) > 0);
+  ASSERT (strlen (nl_langinfo (ABDAY_2)) > 0);
+  ASSERT (strlen (nl_langinfo (ABDAY_3)) > 0);
+  ASSERT (strlen (nl_langinfo (ABDAY_4)) > 0);
+  ASSERT (strlen (nl_langinfo (ABDAY_5)) > 0);
+  ASSERT (strlen (nl_langinfo (ABDAY_6)) > 0);
+  ASSERT (strlen (nl_langinfo (ABDAY_7)) > 0);
+  ASSERT (strlen (nl_langinfo (MON_1)) > 0);
+  ASSERT (strlen (nl_langinfo (MON_2)) > 0);
+  ASSERT (strlen (nl_langinfo (MON_3)) > 0);
+  ASSERT (strlen (nl_langinfo (MON_4)) > 0);
+  ASSERT (strlen (nl_langinfo (MON_5)) > 0);
+  ASSERT (strlen (nl_langinfo (MON_6)) > 0);
+  ASSERT (strlen (nl_langinfo (MON_7)) > 0);
+  ASSERT (strlen (nl_langinfo (MON_8)) > 0);
+  ASSERT (strlen (nl_langinfo (MON_9)) > 0);
+  ASSERT (strlen (nl_langinfo (MON_10)) > 0);
+  ASSERT (strlen (nl_langinfo (MON_11)) > 0);
+  ASSERT (strlen (nl_langinfo (MON_12)) > 0);
+  ASSERT (strlen (nl_langinfo (ABMON_1)) > 0);
+  ASSERT (strlen (nl_langinfo (ABMON_2)) > 0);
+  ASSERT (strlen (nl_langinfo (ABMON_3)) > 0);
+  ASSERT (strlen (nl_langinfo (ABMON_4)) > 0);
+  ASSERT (strlen (nl_langinfo (ABMON_5)) > 0);
+  ASSERT (strlen (nl_langinfo (ABMON_6)) > 0);
+  ASSERT (strlen (nl_langinfo (ABMON_7)) > 0);
+  ASSERT (strlen (nl_langinfo (ABMON_8)) > 0);
+  ASSERT (strlen (nl_langinfo (ABMON_9)) > 0);
+  ASSERT (strlen (nl_langinfo (ABMON_10)) > 0);
+  ASSERT (strlen (nl_langinfo (ABMON_11)) > 0);
+  ASSERT (strlen (nl_langinfo (ABMON_12)) > 0);
+  ASSERT (strlen (nl_langinfo (ERA)) >= 0);
+  ASSERT (strlen (nl_langinfo (ERA_D_FMT)) >= 0);
+  ASSERT (strlen (nl_langinfo (ERA_D_T_FMT)) >= 0);
+  ASSERT (strlen (nl_langinfo (ERA_T_FMT)) >= 0);
+  ASSERT (nl_langinfo (ALT_DIGITS) != NULL);
+  /* nl_langinfo items of the LC_MONETARY category */
+  {
+    const char *currency = nl_langinfo (CRNCYSTR);
+    ASSERT (strlen (currency) >= (pass > 0 ? 1 : 0));
+  }
+  /* nl_langinfo items of the LC_MESSAGES category */
+  ASSERT (strlen (nl_langinfo (YESEXPR)) > 0);
+  ASSERT (strlen (nl_langinfo (NOEXPR)) > 0);
+
+  return 0;
+}
diff --git a/libmissing/tests/test-nl_langinfo.sh b/libmissing/tests/test-nl_langinfo.sh
new file mode 100755
index 0000000..3168f42
--- /dev/null
+++ b/libmissing/tests/test-nl_langinfo.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+LC_ALL=C ./test-nl_langinfo${EXEEXT} 0 || exit 1
+
+# Test whether a specific traditional locale is installed.
+: ${LOCALE_FR=fr_FR}
+if test $LOCALE_FR != none; then
+  LC_ALL=$LOCALE_FR ./test-nl_langinfo${EXEEXT} 1 || exit 1
+fi
+
+# Test whether a specific UTF-8 locale is installed.
+: ${LOCALE_FR_UTF8=fr_FR.UTF-8}
+if test $LOCALE_FR_UTF8 != none; then
+  LC_ALL=$LOCALE_FR_UTF8 ./test-nl_langinfo${EXEEXT} 2 || exit 1
+fi
+
+exit 0
diff --git a/libmissing/tests/test-sigaction.c b/libmissing/tests/test-sigaction.c
index c06e6f7..d219f02 100644
--- a/libmissing/tests/test-sigaction.c
+++ b/libmissing/tests/test-sigaction.c
@@ -1,5 +1,5 @@
 /* Test of sigaction() function.
-   Copyright (C) 2008 Free Software Foundation, Inc.
+   Copyright (C) 2008, 2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -20,21 +20,13 @@
 
 #include <signal.h>
 
-#include <stdio.h>
-#include <stdlib.h>
-
-#define ASSERT(expr) \
-  do									     \
-    {									     \
-      if (!(expr))							     \
-        {								     \
-          fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
-          fflush (stderr);						     \
-          signal (SIGABRT, SIG_DFL);					     \
-          abort ();							     \
-        }								     \
-    }									     \
-  while (0)
+#include "signature.h"
+SIGNATURE_CHECK (sigaction, int, (int, struct sigaction const *,
+                                  struct sigaction *));
+
+#include <stddef.h>
+
+#include "macros.h"
 
 #ifndef SA_NOCLDSTOP
 # define SA_NOCLDSTOP 0
@@ -53,7 +45,7 @@
    provide other flags as extensions, such as SA_RESTORER, that we
    must ignore in this test.  */
 #define MASK_SA_FLAGS (SA_NOCLDSTOP | SA_ONSTACK | SA_RESETHAND | SA_RESTART \
-		       | SA_SIGINFO | SA_NOCLDWAIT | SA_NODEFER)
+                       | SA_SIGINFO | SA_NOCLDWAIT | SA_NODEFER)
 
 /* This test is unsafe in the presence of an asynchronous SIGABRT,
    because we install a signal-handler that is intentionally not
@@ -77,8 +69,8 @@ handler (int sig)
       break;
     case 1:
       /* This assertion fails on glibc-2.3.6 systems with LinuxThreads,
-	 when this program is linked with -lpthread, due to the sigaction()
-	 override in libpthread.so.  */
+         when this program is linked with -lpthread, due to the sigaction()
+         override in libpthread.so.  */
 #if !defined __GLIBC__
       ASSERT (sa.sa_handler == SIG_DFL);
 #endif
@@ -89,7 +81,7 @@ handler (int sig)
 }
 
 int
-main (int argc, char *argv[])
+main (void)
 {
   struct sigaction sa;
   struct sigaction old_sa;
diff --git a/libmissing/tests/test-signal.c b/libmissing/tests/test-signal.c
index 4bc13ab..5154f4e 100644
--- a/libmissing/tests/test-signal.c
+++ b/libmissing/tests/test-signal.c
@@ -22,7 +22,8 @@
 
 volatile sig_atomic_t s;
 
-int main ()
+int
+main (void)
 {
   return s;
 }
diff --git a/libmissing/tests/test-sleep.c b/libmissing/tests/test-sleep.c
index ed5a5a0..3bb2de6 100644
--- a/libmissing/tests/test-sleep.c
+++ b/libmissing/tests/test-sleep.c
@@ -1,5 +1,5 @@
 /* Test of sleep() function.
-   Copyright (C) 2007-2008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -20,28 +20,39 @@
 
 #include <unistd.h>
 
-#include <stdio.h>
-#include <stdlib.h>
-
-#define ASSERT(expr) \
-  do									     \
-    {									     \
-      if (!(expr))							     \
-        {								     \
-          fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
-          fflush (stderr);						     \
-          abort ();							     \
-        }								     \
-    }									     \
-  while (0)
+#include "signature.h"
+SIGNATURE_CHECK (sleep, unsigned int, (unsigned int));
+
+#include <signal.h>
+
+#include "macros.h"
+
+#if HAVE_DECL_ALARM
+static void
+handle_alarm (int sig)
+{
+  if (sig != SIGALRM)
+    _exit (1);
+}
+#endif
 
 int
-main()
+main (void)
 {
   ASSERT (sleep (1) <= 1);
 
   ASSERT (sleep (0) == 0);
 
+#if HAVE_DECL_ALARM
+  {
+    const unsigned int pentecost = 50 * 24 * 60 * 60; /* 50 days.  */
+    unsigned int remaining;
+    signal (SIGALRM, handle_alarm);
+    alarm (1);
+    remaining = sleep (pentecost);
+    ASSERT (pentecost - 10 < remaining && remaining <= pentecost);
+  }
+#endif
+
   return 0;
 }
-
diff --git a/libmissing/tests/test-snprintf.c b/libmissing/tests/test-snprintf.c
index 790c999..3780786 100644
--- a/libmissing/tests/test-snprintf.c
+++ b/libmissing/tests/test-snprintf.c
@@ -1,5 +1,5 @@
 /* Test of snprintf() function.
-   Copyright (C) 2007-2008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -20,20 +20,12 @@
 
 #include <stdio.h>
 
-#include <stdlib.h>
+#include "signature.h"
+SIGNATURE_CHECK (snprintf, int, (char *, size_t, char const *, ...));
+
 #include <string.h>
 
-#define ASSERT(expr) \
-  do									     \
-    {									     \
-      if (!(expr))							     \
-        {								     \
-          fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
-          fflush (stderr);						     \
-          abort ();							     \
-        }								     \
-    }									     \
-  while (0)
+#include "macros.h"
 
 int
 main (int argc, char *argv[])
@@ -47,25 +39,25 @@ main (int argc, char *argv[])
       memcpy (buf, "DEADBEEF", 8);
       retval = snprintf (buf, size, "%d", 12345);
       if (size < 6)
-	{
+        {
 #if CHECK_SNPRINTF_POSIX
-	  ASSERT (retval < 0 || retval >= size);
+          ASSERT (retval < 0 || retval >= size);
 #endif
-	  if (size > 0)
-	    {
-	      ASSERT (memcmp (buf, "12345", size - 1) == 0);
-	      ASSERT (buf[size - 1] == '\0' || buf[size - 1] == '0' + size);
-	    }
+          if (size > 0)
+            {
+              ASSERT (memcmp (buf, "12345", size - 1) == 0);
+              ASSERT (buf[size - 1] == '\0' || buf[size - 1] == '0' + size);
+            }
 #if !CHECK_SNPRINTF_POSIX
-	  if (size > 0)
+          if (size > 0)
 #endif
-	    ASSERT (memcmp (buf + size, "DEADBEEF" + size, 8 - size) == 0);
-	}
+            ASSERT (memcmp (buf + size, "DEADBEEF" + size, 8 - size) == 0);
+        }
       else
-	{
-	  ASSERT (retval == 5);
-	  ASSERT (memcmp (buf, "12345\0EF", 8) == 0);
-	}
+        {
+          ASSERT (retval == 5);
+          ASSERT (memcmp (buf, "12345\0EF", 8) == 0);
+        }
     }
 
   return 0;
diff --git a/libmissing/tests/test-sockets.c b/libmissing/tests/test-sockets.c
new file mode 100644
index 0000000..2d25964
--- /dev/null
+++ b/libmissing/tests/test-sockets.c
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2008, 2009 Free Software Foundation
+ * Written by Simon Josefsson.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+#include <stdio.h>
+
+#include "sockets.h"
+
+int
+main (void)
+{
+  int err;
+
+  err = gl_sockets_startup (SOCKETS_1_1);
+  if (err != 0)
+    {
+      printf ("wsastartup failed %d\n", err);
+      return 1;
+    }
+
+  err = gl_sockets_cleanup ();
+  if (err != 0)
+    {
+      printf ("wsacleanup failed %d\n", err);
+      return 1;
+    }
+
+  (void) gl_fd_to_handle (0);
+
+  return 0;
+}
diff --git a/libmissing/tests/test-stdbool.c b/libmissing/tests/test-stdbool.c
index 30d5321..360375c 100644
--- a/libmissing/tests/test-stdbool.c
+++ b/libmissing/tests/test-stdbool.c
@@ -1,5 +1,5 @@
 /* Test of <stdbool.h> substitute.
-   Copyright (C) 2002-2007 Free Software Foundation, Inc.
+   Copyright (C) 2002-2007, 2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
diff --git a/libmissing/tests/test-stddef.c b/libmissing/tests/test-stddef.c
new file mode 100644
index 0000000..c0a7515
--- /dev/null
+++ b/libmissing/tests/test-stddef.c
@@ -0,0 +1,38 @@
+/* Test of <stddef.h> substitute.
+   Copyright (C) 2009 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Eric Blake <[email protected]>, 2009.  */
+
+#include <config.h>
+
+#include <stddef.h>
+
+#include "verify.h"
+
+/* Check that appropriate types are defined.  */
+wchar_t a = 'c';
+ptrdiff_t b = 1;
+size_t c = 2;
+
+/* Check that NULL can be passed through varargs as a pointer type,
+   per POSIX 2008.  */
+verify (sizeof NULL == sizeof (void *));
+
+int
+main (void)
+{
+  return 0;
+}
diff --git a/libmissing/tests/test-stdint.c b/libmissing/tests/test-stdint.c
index a2bf42a..4e9b362 100644
--- a/libmissing/tests/test-stdint.c
+++ b/libmissing/tests/test-stdint.c
@@ -1,5 +1,5 @@
 /* Test of <stdint.h> substitute.
-   Copyright (C) 2006-2008 Free Software Foundation, Inc.
+   Copyright (C) 2006-2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -354,7 +354,7 @@ verify_same_types (UINTMAX_C (17), (uintmax_t)0 + 0);
 
 
 int
-main ()
+main (void)
 {
   return 0;
 }
diff --git a/libmissing/tests/test-stdio.c b/libmissing/tests/test-stdio.c
index dcfe38d..3f2f067 100644
--- a/libmissing/tests/test-stdio.c
+++ b/libmissing/tests/test-stdio.c
@@ -30,7 +30,7 @@ int sk[] = { SEEK_CUR, SEEK_END, SEEK_SET };
 verify (sizeof NULL == sizeof (void *));
 
 int
-main ()
+main (void)
 {
   return 0;
 }
diff --git a/libmissing/tests/test-stdlib.c b/libmissing/tests/test-stdlib.c
index ae46ba1..fad5cf4 100644
--- a/libmissing/tests/test-stdlib.c
+++ b/libmissing/tests/test-stdlib.c
@@ -29,7 +29,7 @@ int exitcode;
 verify (sizeof NULL == sizeof (void *));
 
 int
-main ()
+main (void)
 {
   /* Check that some macros are defined and different integer constants.  */
   switch (exitcode)
diff --git a/libmissing/tests/test-strerror.c b/libmissing/tests/test-strerror.c
index 3d9814d..99c3c5f 100644
--- a/libmissing/tests/test-strerror.c
+++ b/libmissing/tests/test-strerror.c
@@ -1,5 +1,5 @@
 /* Test of strerror() function.
-   Copyright (C) 2007-2008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -19,25 +19,17 @@
 
 #include <config.h>
 
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
 
-#define ASSERT(expr) \
-  do									     \
-    {									     \
-      if (!(expr))							     \
-        {								     \
-          fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
-          fflush (stderr);						     \
-          abort ();							     \
-        }								     \
-    }									     \
-  while (0)
+#include "signature.h"
+SIGNATURE_CHECK (strerror, char *, (int));
+
+#include <errno.h>
+
+#include "macros.h"
 
 int
-main (int argc, char **argv)
+main (void)
 {
   char *str;
 
diff --git a/libmissing/tests/test-string.c b/libmissing/tests/test-string.c
index fe53cd9..69df747 100644
--- a/libmissing/tests/test-string.c
+++ b/libmissing/tests/test-string.c
@@ -27,7 +27,7 @@
 verify (sizeof NULL == sizeof (void *));
 
 int
-main ()
+main (void)
 {
   return 0;
 }
diff --git a/libmissing/tests/test-strings.c b/libmissing/tests/test-strings.c
index 81e7362..2a09475 100644
--- a/libmissing/tests/test-strings.c
+++ b/libmissing/tests/test-strings.c
@@ -1,5 +1,5 @@
 /* Test of <strings.h> substitute.
-   Copyright (C) 2007 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
diff --git a/libmissing/tests/test-sys_select.c b/libmissing/tests/test-sys_select.c
index 6449daf..aef8941 100644
--- a/libmissing/tests/test-sys_select.c
+++ b/libmissing/tests/test-sys_select.c
@@ -1,5 +1,5 @@
 /* Test of <sys/select.h> substitute.
-   Copyright (C) 2007-2008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -24,7 +24,12 @@
 struct timeval t1;
 
 int
-main ()
+main (void)
 {
+  /* Check that FD_ZERO can be used.  This should not yield a warning
+     such as "warning: implicit declaration of function 'memset'".  */
+  fd_set fds;
+  FD_ZERO (&fds);
+
   return 0;
 }
diff --git a/libmissing/tests/test-sys_socket.c b/libmissing/tests/test-sys_socket.c
index 3d946a8..606708d 100644
--- a/libmissing/tests/test-sys_socket.c
+++ b/libmissing/tests/test-sys_socket.c
@@ -28,7 +28,7 @@ int a[] = { SHUT_RD, SHUT_WR, SHUT_RDWR };
 #endif
 
 int
-main ()
+main (void)
 {
   struct sockaddr_storage x;
   sa_family_t i;
@@ -47,7 +47,7 @@ main ()
     }
 
   x.ss_family = 42;
-  i = 4711;
+  i = 42;
 
   return 0;
 }
diff --git a/libmissing/tests/test-sys_stat.c b/libmissing/tests/test-sys_stat.c
index 4b5eb76..4a85c9f 100644
--- a/libmissing/tests/test-sys_stat.c
+++ b/libmissing/tests/test-sys_stat.c
@@ -1,5 +1,5 @@
 /* Test of <sys/stat.h> substitute.
-   Copyright (C) 2007-2008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -253,11 +253,36 @@ verify (!S_ISWHT (S_IFLNK));
 verify (!S_ISWHT (S_IFSOCK));
 #endif
 
+/* POSIX 2008 requires traditional encoding of permission constants.  */
+verify (S_IRWXU == 00700);
+verify (S_IRUSR == 00400);
+verify (S_IWUSR == 00200);
+verify (S_IXUSR == 00100);
+verify (S_IRWXG == 00070);
+verify (S_IRGRP == 00040);
+verify (S_IWGRP == 00020);
+verify (S_IXGRP == 00010);
+verify (S_IRWXO == 00007);
+verify (S_IROTH == 00004);
+verify (S_IWOTH == 00002);
+verify (S_IXOTH == 00001);
+verify (S_ISUID == 04000);
+verify (S_ISGID == 02000);
+verify (S_ISVTX == 01000);
+
+#if ((0 <= UTIME_NOW && UTIME_NOW < 1000000000)           \
+     || (0 <= UTIME_OMIT && UTIME_OMIT < 1000000000)      \
+     || UTIME_NOW == UTIME_OMIT)
+invalid UTIME macros
+#endif
+
 /* Check the existence of some types.  */
 nlink_t t1;
 
+struct timespec t2;
+
 int
-main ()
+main (void)
 {
   return 0;
 }
diff --git a/libmissing/tests/test-sys_time.c b/libmissing/tests/test-sys_time.c
index bae4108..74f35ac 100644
--- a/libmissing/tests/test-sys_time.c
+++ b/libmissing/tests/test-sys_time.c
@@ -1,5 +1,5 @@
 /* Test of <sys/time.h> substitute.
-   Copyright (C) 2007 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -23,7 +23,7 @@
 struct timeval a;
 
 int
-main ()
+main (void)
 {
   return 0;
 }
diff --git a/libmissing/tests/test-time.c b/libmissing/tests/test-time.c
index 9238ac4..4afa3b3 100644
--- a/libmissing/tests/test-time.c
+++ b/libmissing/tests/test-time.c
@@ -1,5 +1,5 @@
 /* Test of <time.h> substitute.
-   Copyright (C) 2007 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -20,10 +20,16 @@
 
 #include <time.h>
 
+#include "verify.h"
+
 struct timespec a;
 
+/* Check that NULL can be passed through varargs as a pointer type,
+   per POSIX 2008.  */
+verify (sizeof NULL == sizeof (void *));
+
 int
-main ()
+main (void)
 {
   return 0;
 }
diff --git a/libmissing/tests/test-unistd.c b/libmissing/tests/test-unistd.c
index 129367b..dd907f4 100644
--- a/libmissing/tests/test-unistd.c
+++ b/libmissing/tests/test-unistd.c
@@ -50,7 +50,7 @@ intptr_t t8;
 #endif
 
 int
-main ()
+main (void)
 {
   return 0;
 }
diff --git a/libmissing/tests/test-vasnprintf.c b/libmissing/tests/test-vasnprintf.c
index 2f3f890..2f7f0db 100644
--- a/libmissing/tests/test-vasnprintf.c
+++ b/libmissing/tests/test-vasnprintf.c
@@ -1,5 +1,5 @@
 /* Test of vasnprintf() and asnprintf() functions.
-   Copyright (C) 2007-2008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -21,21 +21,10 @@
 #include "vasnprintf.h"
 
 #include <stdarg.h>
-#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
-#define ASSERT(expr) \
-  do									     \
-    {									     \
-      if (!(expr))							     \
-        {								     \
-          fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
-          fflush (stderr);						     \
-          abort ();							     \
-        }								     \
-    }									     \
-  while (0)
+#include "macros.h"
 
 static char *
 my_asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...)
@@ -77,10 +66,10 @@ test_vasnprintf ()
       ASSERT (strcmp (result, "12345") == 0);
       ASSERT (length == 5);
       if (size < 6)
-	ASSERT (result != buf);
+        ASSERT (result != buf);
       ASSERT (memcmp (buf + size, "DEADBEEF" + size, 8 - size) == 0);
       if (result != buf)
-	free (result);
+        free (result);
     }
 }
 
@@ -112,10 +101,10 @@ test_asnprintf ()
       ASSERT (strcmp (result, "12345") == 0);
       ASSERT (length == 5);
       if (size < 6)
-	ASSERT (result != buf);
+        ASSERT (result != buf);
       ASSERT (memcmp (buf + size, "DEADBEEF" + size, 8 - size) == 0);
       if (result != buf)
-	free (result);
+        free (result);
     }
 }
 
diff --git a/libmissing/tests/test-wchar.c b/libmissing/tests/test-wchar.c
index 19da7d9..2e60bb8 100644
--- a/libmissing/tests/test-wchar.c
+++ b/libmissing/tests/test-wchar.c
@@ -1,5 +1,5 @@
 /* Test of <wchar.h> substitute.
-   Copyright (C) 2007-2008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -20,12 +20,18 @@
 
 #include <wchar.h>
 
+#include "verify.h"
+
 /* Check that the types wchar_t and wint_t are defined.  */
 wchar_t a = 'c';
 wint_t b = 'x';
 
+/* Check that NULL can be passed through varargs as a pointer type,
+   per POSIX 2008.  */
+verify (sizeof NULL == sizeof (void *));
+
 int
-main ()
+main (void)
 {
   return 0;
 }
diff --git a/libmissing/tests/test-wctype.c b/libmissing/tests/test-wctype.c
index c2d8601..fd801d1 100644
--- a/libmissing/tests/test-wctype.c
+++ b/libmissing/tests/test-wctype.c
@@ -1,5 +1,5 @@
 /* Test of <wctype.h> substitute.
-   Copyright (C) 2007-2008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -20,11 +20,15 @@
 
 #include <wctype.h>
 
+#include "macros.h"
+
 /* Check that the type wint_t is defined.  */
 wint_t a = 'x';
+/* Check that WEOF is defined.  */
+wint_t e = WEOF;
 
 int
-main ()
+main (void)
 {
   /* Check that the isw* functions exist as functions or as macros.  */
   (void) iswalnum (0);
@@ -42,5 +46,29 @@ main ()
   (void) iswupper (0);
   (void) iswxdigit (0);
 
+  /* Check that the isw* functions map WEOF to 0.  */
+  ASSERT (!iswalnum (e));
+  ASSERT (!iswalpha (e));
+#if 0 /* not portable: missing on mingw */
+  ASSERT (!iswblank (e));
+#endif
+  ASSERT (!iswcntrl (e));
+  ASSERT (!iswdigit (e));
+  ASSERT (!iswgraph (e));
+  ASSERT (!iswlower (e));
+  ASSERT (!iswprint (e));
+  ASSERT (!iswpunct (e));
+  ASSERT (!iswspace (e));
+  ASSERT (!iswupper (e));
+  ASSERT (!iswxdigit (e));
+
+  /* Check that the tow* functions exist as functions or as macros.  */
+  (void) towlower (0);
+  (void) towupper (0);
+
+  /* Check that the tow* functions map WEOF to WEOF.  */
+  ASSERT (towlower (e) == e);
+  ASSERT (towupper (e) == e);
+
   return 0;
 }
diff --git a/libmissing/tests/wctob.c b/libmissing/tests/wctob.c
index 4fa71b0..c8381db 100644
--- a/libmissing/tests/wctob.c
+++ b/libmissing/tests/wctob.c
@@ -1,5 +1,5 @@
 /* Convert wide character to unibyte character.
-   Copyright (C) 2008 Free Software Foundation, Inc.
+   Copyright (C) 2008, 2009 Free Software Foundation, Inc.
    Written by Bruno Haible <[email protected]>, 2008.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/libmissing/tests/zerosize-ptr.h b/libmissing/tests/zerosize-ptr.h
index a38a2cf..399d019 100644
--- a/libmissing/tests/zerosize-ptr.h
+++ b/libmissing/tests/zerosize-ptr.h
@@ -57,11 +57,11 @@ zerosize_ptr (void)
     {
       int pagesize = getpagesize ();
       char *two_pages =
-	(char *) mmap (NULL, 2 * pagesize, PROT_READ | PROT_WRITE,
-		       flags, fd, 0);
+        (char *) mmap (NULL, 2 * pagesize, PROT_READ | PROT_WRITE,
+                       flags, fd, 0);
       if (two_pages != (char *)(-1)
-	  && mprotect (two_pages + pagesize, pagesize, PROT_NONE) == 0)
-	return two_pages + pagesize;
+          && mprotect (two_pages + pagesize, pagesize, PROT_NONE) == 0)
+        return two_pages + pagesize;
     }
 #endif
   return NULL;
diff --git a/libmissing/time.in.h b/libmissing/time.in.h
index 7da429a..eb35cc2 100644
--- a/libmissing/time.in.h
+++ b/libmissing/time.in.h
@@ -1,6 +1,6 @@
 /* A more-standard <time.h>.
 
-   Copyright (C) 2007-2008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -37,6 +37,11 @@
 
 # @INCLUDE_NEXT@ @NEXT_TIME_H@
 
+/* NetBSD 5.0 mis-defines NULL.  */
+#include <stddef.h>
+
+/* The definition of _GL_ARG_NONNULL is copied here.  */
+
 # ifdef __cplusplus
 extern "C" {
 # endif
@@ -63,7 +68,14 @@ struct timespec
    <http://www.opengroup.org/susv3xsh/nanosleep.html>.  */
 # if @REPLACE_NANOSLEEP@
 #  define nanosleep rpl_nanosleep
-int nanosleep (struct timespec const *__rqtp, struct timespec *__rmtp);
+extern int nanosleep (struct timespec const *__rqtp, struct timespec *__rmtp)
+     _GL_ARG_NONNULL ((1));
+# endif
+
+/* Return the 'time_t' representation of TP and normalize TP.  */
+# if @REPLACE_MKTIME@
+#  define mktime rpl_mktime
+extern time_t mktime (struct tm *__tp) _GL_ARG_NONNULL ((1));
 # endif
 
 /* Convert TIMER to RESULT, assuming local time and UTC respectively.  See
@@ -74,10 +86,12 @@ int nanosleep (struct timespec const *__rqtp, struct timespec *__rmtp);
 #  define localtime_r rpl_localtime_r
 #  undef gmtime_r
 #  define gmtime_r rpl_gmtime_r
-struct tm *localtime_r (time_t const *restrict __timer,
-			struct tm *restrict __result);
-struct tm *gmtime_r (time_t const *restrict __timer,
-		     struct tm *restrict __result);
+extern struct tm *localtime_r (time_t const *restrict __timer,
+                               struct tm *restrict __result)
+     _GL_ARG_NONNULL ((1, 2));
+extern struct tm *gmtime_r (time_t const *restrict __timer,
+                            struct tm *restrict __result)
+     _GL_ARG_NONNULL ((1, 2));
 # endif
 
 /* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store
@@ -86,15 +100,17 @@ struct tm *gmtime_r (time_t const *restrict __timer,
 # if @REPLACE_STRPTIME@
 #  undef strptime
 #  define strptime rpl_strptime
-char *strptime (char const *restrict __buf, char const *restrict __format,
-		struct tm *restrict __tm);
+extern char *strptime (char const *restrict __buf,
+                       char const *restrict __format,
+                       struct tm *restrict __tm)
+     _GL_ARG_NONNULL ((1, 2, 3));
 # endif
 
 /* Convert TM to a time_t value, assuming UTC.  */
 # if @REPLACE_TIMEGM@
 #  undef timegm
 #  define timegm rpl_timegm
-time_t timegm (struct tm *__tm);
+extern time_t timegm (struct tm *__tm) _GL_ARG_NONNULL ((1));
 # endif
 
 /* Encourage applications to avoid unsafe functions that can overrun
diff --git a/libmissing/time_r.c b/libmissing/time_r.c
index 90dcf00..08579c3 100644
--- a/libmissing/time_r.c
+++ b/libmissing/time_r.c
@@ -1,6 +1,6 @@
 /* Reentrant time functions like localtime_r.
 
-   Copyright (C) 2003, 2006, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2006, 2007, 2009 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/libmissing/unistd.in.h b/libmissing/unistd.in.h
index 2e42c0b..0796dfd 100644
--- a/libmissing/unistd.in.h
+++ b/libmissing/unistd.in.h
@@ -29,63 +29,97 @@
 #ifndef _GL_UNISTD_H
 #define _GL_UNISTD_H
 
+/* NetBSD 5.0 mis-defines NULL.  Also get size_t.  */
+#include <stddef.h>
+
 /* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>.  */
-#if !(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET)
+/* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>.  */
+/* But avoid namespace pollution on glibc systems.  */
+#if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
+     || (@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK)) \
+    && ! defined __GLIBC__
 # include <stdio.h>
 #endif
 
+/* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>.  */
+/* But avoid namespace pollution on glibc systems.  */
+#if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__
+# include <fcntl.h>
+#endif
+
 /* mingw fails to declare _exit in <unistd.h>.  */
 /* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>.  */
-#include <stdlib.h>
+/* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>.  */
+/* But avoid namespace pollution on glibc systems.  */
+#ifndef __GLIBC__
+# include <stdlib.h>
+#endif
 
-#if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
+/* mingw declares getcwd in <io.h>, not in <unistd.h>.  */
+#if ((@GNULIB_GETCWD@ || defined GNULIB_POSIXCHECK) \
+     && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
+# include <io.h>
+#endif
+
+#if ((@GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@)   \
+     || (@GNULIB_READLINK@ && (!@HAVE_READLINK@ || @REPLACE_READLINK@)) \
+     || (@GNULIB_READLINKAT@ && !@HAVE_READLINKAT@) \
+     || defined GNULIB_POSIXCHECK)
 /* Get ssize_t.  */
 # include <sys/types.h>
 #endif
 
+/* Get getopt(), optarg, optind, opterr, optopt.
+   But avoid namespace pollution on glibc systems.  */
+#if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
+# include <getopt.h>
+#endif
+
 #if @GNULIB_GETHOSTNAME@
 /* Get all possible declarations of gethostname().  */
 # if @UNISTD_H_HAVE_WINSOCK2_H@
 #  include <winsock2.h>
 #  if !defined _GL_SYS_SOCKET_H
 #   undef socket
-#   define socket		socket_used_without_including_sys_socket_h
+#   define socket               socket_used_without_including_sys_socket_h
 #   undef connect
-#   define connect		connect_used_without_including_sys_socket_h
+#   define connect              connect_used_without_including_sys_socket_h
 #   undef accept
-#   define accept		accept_used_without_including_sys_socket_h
+#   define accept               accept_used_without_including_sys_socket_h
 #   undef bind
-#   define bind			bind_used_without_including_sys_socket_h
+#   define bind                 bind_used_without_including_sys_socket_h
 #   undef getpeername
-#   define getpeername		getpeername_used_without_including_sys_socket_h
+#   define getpeername          getpeername_used_without_including_sys_socket_h
 #   undef getsockname
-#   define getsockname		getsockname_used_without_including_sys_socket_h
+#   define getsockname          getsockname_used_without_including_sys_socket_h
 #   undef getsockopt
-#   define getsockopt		getsockopt_used_without_including_sys_socket_h
+#   define getsockopt           getsockopt_used_without_including_sys_socket_h
 #   undef listen
-#   define listen		listen_used_without_including_sys_socket_h
+#   define listen               listen_used_without_including_sys_socket_h
 #   undef recv
-#   define recv			recv_used_without_including_sys_socket_h
+#   define recv                 recv_used_without_including_sys_socket_h
 #   undef send
-#   define send			send_used_without_including_sys_socket_h
+#   define send                 send_used_without_including_sys_socket_h
 #   undef recvfrom
-#   define recvfrom		recvfrom_used_without_including_sys_socket_h
+#   define recvfrom             recvfrom_used_without_including_sys_socket_h
 #   undef sendto
-#   define sendto		sendto_used_without_including_sys_socket_h
+#   define sendto               sendto_used_without_including_sys_socket_h
 #   undef setsockopt
-#   define setsockopt		setsockopt_used_without_including_sys_socket_h
+#   define setsockopt           setsockopt_used_without_including_sys_socket_h
 #   undef shutdown
-#   define shutdown		shutdown_used_without_including_sys_socket_h
+#   define shutdown             shutdown_used_without_including_sys_socket_h
 #  endif
 #  if !defined _GL_SYS_SELECT_H
 #   undef select
-#   define select		select_used_without_including_sys_select_h
+#   define select               select_used_without_including_sys_select_h
 #  endif
 # endif
 #endif
 
 /* The definition of GL_LINK_WARNING is copied here.  */
 
+/* The definition of _GL_ARG_NONNULL is copied here.  */
+
 
 /* OS/2 EMX lacks these macros.  */
 #ifndef STDIN_FILENO
@@ -98,6 +132,15 @@
 # define STDERR_FILENO 2
 #endif
 
+/* Ensure *_OK macros exist.  */
+#ifndef F_OK
+# define F_OK 0
+# define X_OK 1
+# define W_OK 2
+# define R_OK 4
+#endif
+
+
 /* Declare overridden functions.  */
 
 #ifdef __cplusplus
@@ -107,18 +150,17 @@ extern "C" {
 
 #if @GNULIB_CHOWN@
 # if @REPLACE_CHOWN@
-#  ifndef REPLACE_CHOWN
-#   define REPLACE_CHOWN 1
-#  endif
-#  if REPLACE_CHOWN
+#  undef chown
+#  define chown rpl_chown
+# endif
+# if !@HAVE_CHOWN@ || @REPLACE_CHOWN@
 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
    to GID (if GID is not -1).  Follow symbolic links.
    Return 0 if successful, otherwise -1 and errno set.
    See the POSIX:2001 specification
    <http://www.opengroup.org/susv3xsh/chown.html>.  */
-#   define chown rpl_chown
-extern int chown (const char *file, uid_t uid, gid_t gid);
-#  endif
+extern int chown (const char *file, uid_t uid, gid_t gid)
+     _GL_ARG_NONNULL ((1));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef chown
@@ -137,7 +179,7 @@ extern int chown (const char *file, uid_t uid, gid_t gid);
 #  define close rpl_close
 extern int close (int);
 # endif
-#elif @UNISTD_H_HAVE_WINSOCK2_H@
+#elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
 # undef close
 # define close close_used_without_requesting_gnulib_module_close
 #elif defined GNULIB_POSIXCHECK
@@ -149,11 +191,20 @@ extern int close (int);
 #endif
 
 
+#if @REPLACE_DUP@
+# define dup rpl_dup
+extern int dup (int);
+#endif
+
+
 #if @GNULIB_DUP2@
-# if !@HAVE_DUP2@
+# if @REPLACE_DUP2@
+#  define dup2 rpl_dup2
+# endif
+# if !@HAVE_DUP2@ || @REPLACE_DUP2@
 /* Copy the file descriptor OLDFD into file descriptor NEWFD.  Do nothing if
    NEWFD = OLDFD, otherwise close NEWFD first if it is open.
-   Return 0 if successful, otherwise -1 and errno set.
+   Return newfd if successful, otherwise -1 and errno set.
    See the POSIX:2001 specification
    <http://www.opengroup.org/susv3xsh/dup2.html>.  */
 extern int dup2 (int oldfd, int newfd);
@@ -167,6 +218,28 @@ extern int dup2 (int oldfd, int newfd);
 #endif
 
 
+#if @GNULIB_DUP3@
+/* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
+   specified flags.
+   The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
+   and O_TEXT, O_BINARY (defined in "binary-io.h").
+   Close NEWFD first if it is open.
+   Return newfd if successful, otherwise -1 and errno set.
+   See the Linux man page at
+   <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>.  */
+# if @HAVE_DUP3@
+#  define dup3 rpl_dup3
+# endif
+extern int dup3 (int oldfd, int newfd, int flags);
+#elif defined GNULIB_POSIXCHECK
+# undef dup3
+# define dup3(o,n,f) \
+    (GL_LINK_WARNING ("dup3 is unportable - " \
+                      "use gnulib module dup3 for portability"), \
+     dup3 (o, n, f))
+#endif
+
+
 #if @GNULIB_ENVIRON@
 # if !@HAVE_DECL_ENVIRON@
 /* Set of environment variables and values.  An array of strings of the form
@@ -189,9 +262,9 @@ extern char **environ;
 
 #if @GNULIB_EUIDACCESS@
 # if !@HAVE_EUIDACCESS@
-/* Like access(), except that is uses the effective user id and group id of
+/* Like access(), except that it uses the effective user id and group id of
    the current process.  */
-extern int euidaccess (const char *filename, int mode);
+extern int euidaccess (const char *filename, int mode) _GL_ARG_NONNULL ((1));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef euidaccess
@@ -202,9 +275,22 @@ extern int euidaccess (const char *filename, int mode);
 #endif
 
 
+#if @GNULIB_FACCESSAT@
+# if !@HAVE_FACCESSAT@
+extern int faccessat (int fd, char const *file, int mode, int flag)
+     _GL_ARG_NONNULL ((2));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef faccessat
+# define faccessat(d,n,m,f)                         \
+    (GL_LINK_WARNING ("faccessat is not portable - " \
+                      "use gnulib module faccessat for portability"), \
+     faccessat (d, n, m, f))
+#endif
+
+
 #if @GNULIB_FCHDIR@
 # if @REPLACE_FCHDIR@
-
 /* Change the process' current working directory to the directory on which
    the given file descriptor is open.
    Return 0 if successful, otherwise -1 and errno set.
@@ -212,10 +298,12 @@ extern int euidaccess (const char *filename, int mode);
    <http://www.opengroup.org/susv3xsh/fchdir.html>.  */
 extern int fchdir (int /*fd*/);
 
-#  define dup rpl_dup
-extern int dup (int);
-#  define dup2 rpl_dup2
-extern int dup2 (int, int);
+/* Gnulib internal hooks needed to maintain the fchdir metadata.  */
+extern int _gl_register_fd (int fd, const char *filename)
+     _GL_ARG_NONNULL ((2));
+extern void _gl_unregister_fd (int fd);
+extern int _gl_register_dup (int oldfd, int newfd);
+extern const char *_gl_directory_name (int fd);
 
 # endif
 #elif defined GNULIB_POSIXCHECK
@@ -227,6 +315,24 @@ extern int dup2 (int, int);
 #endif
 
 
+#if @GNULIB_FCHOWNAT@
+# if @REPLACE_FCHOWNAT@
+#  undef fchownat
+#  define fchownat rpl_fchownat
+# endif
+# if !@HAVE_FCHOWNAT@ || @REPLACE_FCHOWNAT@
+extern int fchownat (int fd, char const *file, uid_t owner, gid_t group, int flag)
+     _GL_ARG_NONNULL ((2));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef fchownat
+# define fchownat(d,n,o,g,f)                        \
+    (GL_LINK_WARNING ("fchownat is not portable - " \
+                      "use gnulib module openat for portability"), \
+     fchownat (d, n, o, g, f))
+#endif
+
+
 #if @GNULIB_FSYNC@
 /* Synchronize changes to a file.
    Return 0 if successful, otherwise -1 and errno set.
@@ -262,9 +368,6 @@ extern int ftruncate (int fd, off_t length);
 
 
 #if @GNULIB_GETCWD@
-/* Include the headers that might declare getcwd so that they will not
-   cause confusion if included after this file.  */
-# include <stdlib.h>
 # if @REPLACE_GETCWD@
 /* Get the name of the current working directory, and put it in SIZE bytes
    of BUF.
@@ -300,7 +403,7 @@ extern char * getcwd (char *buf, size_t size);
    If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
    Return 0 if successful, otherwise set errno and return -1.  */
 # if !@HAVE_GETDOMAINNAME@
-extern int getdomainname(char *name, size_t len);
+extern int getdomainname(char *name, size_t len) _GL_ARG_NONNULL ((1));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef getdomainname
@@ -313,7 +416,8 @@ extern int getdomainname(char *name, size_t len);
 
 #if @GNULIB_GETDTABLESIZE@
 # if !@HAVE_GETDTABLESIZE@
-/* Return the maximum number of file descriptors in the current process.  */
+/* Return the maximum number of file descriptors in the current process.
+   In POSIX, this is same as sysconf (_SC_OPEN_MAX).  */
 extern int getdtablesize (void);
 # endif
 #elif defined GNULIB_POSIXCHECK
@@ -325,6 +429,28 @@ extern int getdtablesize (void);
 #endif
 
 
+#if @GNULIB_GETGROUPS@
+# if @REPLACE_GETGROUPS@
+#  undef getgroups
+#  define getgroups rpl_getgroups
+# endif
+# if !@HAVE_GETGROUPS@ || @REPLACE_GETGROUPS@
+/* Return the supplemental groups that the current process belongs to.
+   It is unspecified whether the effective group id is in the list.
+   If N is 0, return the group count; otherwise, N describes how many
+   entries are available in GROUPS.  Return -1 and set errno if N is
+   not 0 and not large enough.  Fails with ENOSYS on some systems.  */
+int getgroups (int n, gid_t *groups);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef getgroups
+# define getgroups(n,g)                                                 \
+    (GL_LINK_WARNING ("getgroups is unportable - "                      \
+                      "use gnulib module getgroups for portability"),   \
+     getgroups (n, g))
+#endif
+
+
 #if @GNULIB_GETHOSTNAME@
 /* Return the standard host name of the machine.
    WARNING! The host name may or may not be fully qualified.
@@ -338,7 +464,7 @@ extern int getdtablesize (void);
 #  define gethostname rpl_gethostname
 # endif
 # if @UNISTD_H_HAVE_WINSOCK2_H@ || !@HAVE_GETHOSTNAME@
-extern int gethostname(char *name, size_t len);
+extern int gethostname(char *name, size_t len) _GL_ARG_NONNULL ((1));
 # endif
 #elif @UNISTD_H_HAVE_WINSOCK2_H@
 # undef gethostname
@@ -363,8 +489,7 @@ extern int gethostname(char *name, size_t len);
    See <http://www.opengroup.org/susv3xsh/getlogin.html>.
  */
 # if !@HAVE_DECL_GETLOGIN_R@
-#  include <stddef.h>
-extern int getlogin_r (char *name, size_t size);
+extern int getlogin_r (char *name, size_t size) _GL_ARG_NONNULL ((1));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef getlogin_r
@@ -465,13 +590,17 @@ extern void endusershell (void);
 
 #if @GNULIB_LCHOWN@
 # if @REPLACE_LCHOWN@
+#  undef lchown
+#  define lchown rpl_lchown
+# endif
+# if !@HAVE_LCHOWN@ || @REPLACE_LCHOWN@
 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
    to GID (if GID is not -1).  Do not follow symbolic links.
    Return 0 if successful, otherwise -1 and errno set.
    See the POSIX:2001 specification
    <http://www.opengroup.org/susv3xsh/lchown.html>.  */
-#  define lchown rpl_lchown
-extern int lchown (char const *file, uid_t owner, gid_t group);
+extern int lchown (char const *file, uid_t owner, gid_t group)
+     _GL_ARG_NONNULL ((1));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef lchown
@@ -483,12 +612,16 @@ extern int lchown (char const *file, uid_t owner, gid_t group);
 
 
 #if @GNULIB_LINK@
+# if @REPLACE_LINK@
+#  define link rpl_link
+# endif
 /* Create a new hard link for an existing file.
    Return 0 if successful, otherwise -1 and errno set.
    See POSIX:2001 specification
    <http://www.opengroup.org/susv3xsh/link.html>.  */
-# if !@HAVE_LINK@
-extern int link (const char *path1, const char *path2);
+# if !@HAVE_LINK@ || @REPLACE_LINK@
+extern int link (const char *path1, const char *path2)
+     _GL_ARG_NONNULL ((1, 2));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef link
@@ -498,6 +631,26 @@ extern int link (const char *path1, const char *path2);
      link (path1, path2))
 #endif
 
+#if @GNULIB_LINKAT@
+# if @REPLACE_LINKAT@
+#  undef linkat
+#  define linkat rpl_linkat
+# endif
+/* Create a new hard link for an existing file, relative to two
+   directories.  FLAG controls whether symlinks are followed.
+   Return 0 if successful, otherwise -1 and errno set.  */
+# if !@HAVE_LINKAT@ || @REPLACE_LINKAT@
+extern int linkat (int fd1, const char *path1, int fd2, const char *path2,
+                   int flag)
+     _GL_ARG_NONNULL ((2, 4));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef linkat
+# define link(f1,path1,f2,path2,f)              \
+    (GL_LINK_WARNING ("linkat is unportable - " \
+                      "use gnulib module linkat for portability"), \
+     linkat (f1, path1, f2, path2,f))
+#endif
 
 #if @GNULIB_LSEEK@
 # if @REPLACE_LSEEK@
@@ -517,15 +670,61 @@ extern int link (const char *path1, const char *path2);
 #endif
 
 
+#if @GNULIB_PIPE2@
+/* Create a pipe, applying the given flags when opening the read-end of the
+   pipe and the write-end of the pipe.
+   The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
+   and O_TEXT, O_BINARY (defined in "binary-io.h").
+   Store the read-end as fd[0] and the write-end as fd[1].
+   Return 0 upon success, or -1 with errno set upon failure.
+   See also the Linux man page at
+   <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>.  */
+# if @HAVE_PIPE2@
+#  define pipe2 rpl_pipe2
+# endif
+extern int pipe2 (int fd[2], int flags) _GL_ARG_NONNULL ((1));
+#elif defined GNULIB_POSIXCHECK
+# undef pipe2
+# define pipe2(f,o) \
+    (GL_LINK_WARNING ("pipe2 is unportable - " \
+                      "use gnulib module pipe2 for portability"), \
+     pipe2 (f, o))
+#endif
+
+
+#if @GNULIB_PREAD@
+# if @REPLACE_PREAD@
+#  define pread rpl_pread
+# endif
+/* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
+   Return the number of bytes placed into BUF if successful, otherwise
+   set errno and return -1.  0 indicates EOF.  See the POSIX:2001
+   specification <http://www.opengroup.org/susv3xsh/pread.html>.  */
+# if !@HAVE_PREAD@ || @REPLACE_PREAD@
+  extern ssize_t pread (int fd, void *buf, size_t bufsize, off_t offset)
+       _GL_ARG_NONNULL ((2));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef pread
+# define pread(f,b,s,o)                        \
+    (GL_LINK_WARNING ("pread is unportable - " \
+                      "use gnulib module pread for portability"), \
+     pread (f, b, s, o))
+#endif
+
+
 #if @GNULIB_READLINK@
+# if @REPLACE_READLINK@
+#  define readlink rpl_readlink
+# endif
 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
    bytes of it into BUF.  Return the number of bytes placed into BUF if
    successful, otherwise -1 and errno set.
    See the POSIX:2001 specification
    <http://www.opengroup.org/susv3xsh/readlink.html>.  */
-# if !@HAVE_READLINK@
-#  include <stddef.h>
-extern int readlink (const char *file, char *buf, size_t bufsize);
+# if !@HAVE_READLINK@ || @REPLACE_READLINK@
+extern ssize_t readlink (const char *file, char *buf, size_t bufsize)
+     _GL_ARG_NONNULL ((1, 2));
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef readlink
@@ -536,12 +735,45 @@ extern int readlink (const char *file, char *buf, size_t bufsize);
 #endif
 
 
+#if @GNULIB_READLINKAT@
+# if !@HAVE_READLINKAT@
+extern ssize_t readlinkat (int fd, char const *file, char *buf, size_t len)
+     _GL_ARG_NONNULL ((2, 3));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef readlinkat
+# define readlinkat(d,n,b,l)                         \
+    (GL_LINK_WARNING ("readlinkat is not portable - " \
+                      "use gnulib module symlinkat for portability"), \
+     readlinkat (d, n, b, l))
+#endif
+
+
+#if @GNULIB_RMDIR@
+# if @REPLACE_RMDIR@
+#  define rmdir rpl_rmdir
+/* Remove the directory DIR.  */
+extern int rmdir (char const *name) _GL_ARG_NONNULL ((1));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef rmdir
+# define rmdir(n) \
+    (GL_LINK_WARNING ("rmdir is unportable - " \
+                      "use gnulib module rmdir for portability"), \
+     rmdir (n))
+#endif
+
+
 #if @GNULIB_SLEEP@
+# if @REPLACE_SLEEP@
+#  undef sleep
+#  define sleep rpl_sleep
+# endif
 /* Pause the execution of the current thread for N seconds.
    Returns the number of seconds left to sleep.
    See the POSIX:2001 specification
    <http://www.opengroup.org/susv3xsh/sleep.html>.  */
-# if !@HAVE_SLEEP@
+# if !@HAVE_SLEEP@ || @REPLACE_SLEEP@
 extern unsigned int sleep (unsigned int n);
 # endif
 #elif defined GNULIB_POSIXCHECK
@@ -553,19 +785,99 @@ extern unsigned int sleep (unsigned int n);
 #endif
 
 
+#if @GNULIB_SYMLINK@
+# if @REPLACE_SYMLINK@
+#  undef symlink
+#  define symlink rpl_symlink
+# endif
+# if !@HAVE_SYMLINK@ || @REPLACE_SYMLINK@
+extern int symlink (char const *contents, char const *file)
+     _GL_ARG_NONNULL ((1, 2));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef symlink
+# define symlink(c,n)                        \
+    (GL_LINK_WARNING ("symlink is not portable - " \
+                      "use gnulib module symlink for portability"), \
+     symlink (c, n))
+#endif
+
+
+#if @GNULIB_SYMLINKAT@
+# if !@HAVE_SYMLINKAT@
+extern int symlinkat (char const *contents, int fd, char const *file)
+     _GL_ARG_NONNULL ((1, 3));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef symlinkat
+# define symlinkat(c,d,n)                            \
+    (GL_LINK_WARNING ("symlinkat is not portable - " \
+                      "use gnulib module symlinkat for portability"), \
+     symlinkat (c, d, n))
+#endif
+
+
+#if @GNULIB_UNLINK@
+# if @REPLACE_UNLINK@
+#  undef unlink
+#  define unlink rpl_unlink
+extern int unlink (char const *file) _GL_ARG_NONNULL ((1));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef unlink
+# define unlink(n)                         \
+    (GL_LINK_WARNING ("unlink is not portable - " \
+                      "use gnulib module unlink for portability"), \
+     unlink (n))
+#endif
+
+
+#if @GNULIB_UNLINKAT@
+# if @REPLACE_UNLINKAT@
+#  undef unlinkat
+#  define unlinkat rpl_unlinkat
+# endif
+# if !@HAVE_UNLINKAT@ || @REPLACE_UNLINKAT@
+extern int unlinkat (int fd, char const *file, int flag) _GL_ARG_NONNULL ((2));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef unlinkat
+# define unlinkat(d,n,f)                         \
+    (GL_LINK_WARNING ("unlinkat is not portable - " \
+                      "use gnulib module openat for portability"), \
+     unlinkat (d, n, f))
+#endif
+
+
+#if @GNULIB_USLEEP@
+# if @REPLACE_USLEEP@
+#  undef usleep
+#  define usleep rpl_usleep
+# endif
+# if !@HAVE_USLEEP@ || @REPLACE_USLEEP@
+/* Pause the execution of the current thread for N microseconds.
+   Returns 0 on completion, or -1 on range error.
+   See the POSIX:2001 specification
+   <http://www.opengroup.org/susv3xsh/sleep.html>.  */
+extern int usleep (useconds_t n);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef usleep
+# define usleep(n) \
+    (GL_LINK_WARNING ("usleep is unportable - " \
+                      "use gnulib module usleep for portability"), \
+     usleep (n))
+#endif
+
+
 #if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
    See the POSIX:2001 specification
    <http://www.opengroup.org/susv3xsh/write.html>.  */
 # undef write
 # define write rpl_write
-extern ssize_t write (int fd, const void *buf, size_t count);
-#endif
-
-
-#ifdef FCHDIR_REPLACEMENT
-/* gnulib internal function.  */
-extern void _gl_unregister_fd (int fd);
+extern ssize_t write (int fd, const void *buf, size_t count)
+     _GL_ARG_NONNULL ((2));
 #endif
 
 
diff --git a/libmissing/vasnprintf.c b/libmissing/vasnprintf.c
index c620b4c..e218500 100644
--- a/libmissing/vasnprintf.c
+++ b/libmissing/vasnprintf.c
@@ -67,13 +67,13 @@
 # endif
 #endif
 
-#include <locale.h>	/* localeconv() */
-#include <stdio.h>	/* snprintf(), sprintf() */
-#include <stdlib.h>	/* abort(), malloc(), realloc(), free() */
-#include <string.h>	/* memcpy(), strlen() */
-#include <errno.h>	/* errno */
-#include <limits.h>	/* CHAR_BIT */
-#include <float.h>	/* DBL_MAX_EXP, LDBL_MAX_EXP */
+#include <locale.h>     /* localeconv() */
+#include <stdio.h>      /* snprintf(), sprintf() */
+#include <stdlib.h>     /* abort(), malloc(), realloc(), free() */
+#include <string.h>     /* memcpy(), strlen() */
+#include <errno.h>      /* errno */
+#include <limits.h>     /* CHAR_BIT */
+#include <float.h>      /* DBL_MAX_EXP, LDBL_MAX_EXP */
 #if HAVE_NL_LANGINFO
 # include <langinfo.h>
 #endif
@@ -257,14 +257,14 @@ local_wcsnlen (const wchar_t *s, size_t maxlen)
 # ifndef decimal_point_char_defined
 #  define decimal_point_char_defined 1
 static char
-decimal_point_char ()
+decimal_point_char (void)
 {
   const char *point;
   /* Determine it in a multithread-safe way.  We know nl_langinfo is
-     multithread-safe on glibc systems, but is not required to be multithread-
-     safe by POSIX.  sprintf(), however, is multithread-safe.  localeconv()
-     is rarely multithread-safe.  */
-#  if HAVE_NL_LANGINFO && __GLIBC__
+     multithread-safe on glibc systems and MacOS X systems, but is not required
+     to be multithread-safe by POSIX.  sprintf(), however, is multithread-safe.
+     localeconv() is rarely multithread-safe.  */
+#  if HAVE_NL_LANGINFO && (__GLIBC__ || (defined __APPLE__ && defined __MACH__))
   point = nl_langinfo (RADIXCHAR);
 #  elif 1
   char pointbuf[5];
@@ -364,26 +364,26 @@ multiply (mpn_t src1, mpn_t src2, mpn_t *dest)
       dlen = len1 + len2;
       dp = (mp_limb_t *) malloc (dlen * sizeof (mp_limb_t));
       if (dp == NULL)
-	return NULL;
+        return NULL;
       for (k = len2; k > 0; )
-	dp[--k] = 0;
+        dp[--k] = 0;
       for (i = 0; i < len1; i++)
-	{
-	  mp_limb_t digit1 = p1[i];
-	  mp_twolimb_t carry = 0;
-	  for (j = 0; j < len2; j++)
-	    {
-	      mp_limb_t digit2 = p2[j];
-	      carry += (mp_twolimb_t) digit1 * (mp_twolimb_t) digit2;
-	      carry += dp[i + j];
-	      dp[i + j] = (mp_limb_t) carry;
-	      carry = carry >> GMP_LIMB_BITS;
-	    }
-	  dp[i + len2] = (mp_limb_t) carry;
-	}
+        {
+          mp_limb_t digit1 = p1[i];
+          mp_twolimb_t carry = 0;
+          for (j = 0; j < len2; j++)
+            {
+              mp_limb_t digit2 = p2[j];
+              carry += (mp_twolimb_t) digit1 * (mp_twolimb_t) digit2;
+              carry += dp[i + j];
+              dp[i + j] = (mp_limb_t) carry;
+              carry = carry >> GMP_LIMB_BITS;
+            }
+          dp[i + len2] = (mp_limb_t) carry;
+        }
       /* Normalise.  */
       while (dlen > 0 && dp[dlen - 1] == 0)
-	dlen--;
+        dlen--;
       dest->nlimbs = dlen;
       dest->limbs = dp;
     }
@@ -477,12 +477,12 @@ divide (mpn_t a, mpn_t b, mpn_t *q)
   for (;;)
     {
       if (b_len == 0)
-	/* Division by zero.  */
-	abort ();
+        /* Division by zero.  */
+        abort ();
       if (b_ptr[b_len - 1] == 0)
-	b_len--;
+        b_len--;
       else
-	break;
+        break;
     }
 
   /* Here m = a_len >= 0 and n = b_len > 0.  */
@@ -499,261 +499,261 @@ divide (mpn_t a, mpn_t b, mpn_t *q)
   else if (b_len == 1)
     {
       /* n=1: single precision division.
-	 beta^(m-1) <= a < beta^m  ==>  beta^(m-2) <= a/b < beta^m  */
+         beta^(m-1) <= a < beta^m  ==>  beta^(m-2) <= a/b < beta^m  */
       r_ptr = roomptr;
       q_ptr = roomptr + 1;
       {
-	mp_limb_t den = b_ptr[0];
-	mp_limb_t remainder = 0;
-	const mp_limb_t *sourceptr = a_ptr + a_len;
-	mp_limb_t *destptr = q_ptr + a_len;
-	size_t count;
-	for (count = a_len; count > 0; count--)
-	  {
-	    mp_twolimb_t num =
-	      ((mp_twolimb_t) remainder << GMP_LIMB_BITS) | *--sourceptr;
-	    *--destptr = num / den;
-	    remainder = num % den;
-	  }
-	/* Normalise and store r.  */
-	if (remainder > 0)
-	  {
-	    r_ptr[0] = remainder;
-	    r_len = 1;
-	  }
-	else
-	  r_len = 0;
-	/* Normalise q.  */
-	q_len = a_len;
-	if (q_ptr[q_len - 1] == 0)
-	  q_len--;
+        mp_limb_t den = b_ptr[0];
+        mp_limb_t remainder = 0;
+        const mp_limb_t *sourceptr = a_ptr + a_len;
+        mp_limb_t *destptr = q_ptr + a_len;
+        size_t count;
+        for (count = a_len; count > 0; count--)
+          {
+            mp_twolimb_t num =
+              ((mp_twolimb_t) remainder << GMP_LIMB_BITS) | *--sourceptr;
+            *--destptr = num / den;
+            remainder = num % den;
+          }
+        /* Normalise and store r.  */
+        if (remainder > 0)
+          {
+            r_ptr[0] = remainder;
+            r_len = 1;
+          }
+        else
+          r_len = 0;
+        /* Normalise q.  */
+        q_len = a_len;
+        if (q_ptr[q_len - 1] == 0)
+          q_len--;
       }
     }
   else
     {
       /* n>1: multiple precision division.
-	 beta^(m-1) <= a < beta^m, beta^(n-1) <= b < beta^n  ==>
-	 beta^(m-n-1) <= a/b < beta^(m-n+1).  */
+         beta^(m-1) <= a < beta^m, beta^(n-1) <= b < beta^n  ==>
+         beta^(m-n-1) <= a/b < beta^(m-n+1).  */
       /* Determine s.  */
       size_t s;
       {
-	mp_limb_t msd = b_ptr[b_len - 1]; /* = b[n-1], > 0 */
-	s = 31;
-	if (msd >= 0x10000)
-	  {
-	    msd = msd >> 16;
-	    s -= 16;
-	  }
-	if (msd >= 0x100)
-	  {
-	    msd = msd >> 8;
-	    s -= 8;
-	  }
-	if (msd >= 0x10)
-	  {
-	    msd = msd >> 4;
-	    s -= 4;
-	  }
-	if (msd >= 0x4)
-	  {
-	    msd = msd >> 2;
-	    s -= 2;
-	  }
-	if (msd >= 0x2)
-	  {
-	    msd = msd >> 1;
-	    s -= 1;
-	  }
+        mp_limb_t msd = b_ptr[b_len - 1]; /* = b[n-1], > 0 */
+        s = 31;
+        if (msd >= 0x10000)
+          {
+            msd = msd >> 16;
+            s -= 16;
+          }
+        if (msd >= 0x100)
+          {
+            msd = msd >> 8;
+            s -= 8;
+          }
+        if (msd >= 0x10)
+          {
+            msd = msd >> 4;
+            s -= 4;
+          }
+        if (msd >= 0x4)
+          {
+            msd = msd >> 2;
+            s -= 2;
+          }
+        if (msd >= 0x2)
+          {
+            msd = msd >> 1;
+            s -= 1;
+          }
       }
       /* 0 <= s < GMP_LIMB_BITS.
-	 Copy b, shifting it left by s bits.  */
+         Copy b, shifting it left by s bits.  */
       if (s > 0)
-	{
-	  tmp_roomptr = (mp_limb_t *) malloc (b_len * sizeof (mp_limb_t));
-	  if (tmp_roomptr == NULL)
-	    {
-	      free (roomptr);
-	      return NULL;
-	    }
-	  {
-	    const mp_limb_t *sourceptr = b_ptr;
-	    mp_limb_t *destptr = tmp_roomptr;
-	    mp_twolimb_t accu = 0;
-	    size_t count;
-	    for (count = b_len; count > 0; count--)
-	      {
-		accu += (mp_twolimb_t) *sourceptr++ << s;
-		*destptr++ = (mp_limb_t) accu;
-		accu = accu >> GMP_LIMB_BITS;
-	      }
-	    /* accu must be zero, since that was how s was determined.  */
-	    if (accu != 0)
-	      abort ();
-	  }
-	  b_ptr = tmp_roomptr;
-	}
+        {
+          tmp_roomptr = (mp_limb_t *) malloc (b_len * sizeof (mp_limb_t));
+          if (tmp_roomptr == NULL)
+            {
+              free (roomptr);
+              return NULL;
+            }
+          {
+            const mp_limb_t *sourceptr = b_ptr;
+            mp_limb_t *destptr = tmp_roomptr;
+            mp_twolimb_t accu = 0;
+            size_t count;
+            for (count = b_len; count > 0; count--)
+              {
+                accu += (mp_twolimb_t) *sourceptr++ << s;
+                *destptr++ = (mp_limb_t) accu;
+                accu = accu >> GMP_LIMB_BITS;
+              }
+            /* accu must be zero, since that was how s was determined.  */
+            if (accu != 0)
+              abort ();
+          }
+          b_ptr = tmp_roomptr;
+        }
       /* Copy a, shifting it left by s bits, yields r.
-	 Memory layout:
-	 At the beginning: r = roomptr[0..a_len],
-	 at the end: r = roomptr[0..b_len-1], q = roomptr[b_len..a_len]  */
+         Memory layout:
+         At the beginning: r = roomptr[0..a_len],
+         at the end: r = roomptr[0..b_len-1], q = roomptr[b_len..a_len]  */
       r_ptr = roomptr;
       if (s == 0)
-	{
-	  memcpy (r_ptr, a_ptr, a_len * sizeof (mp_limb_t));
-	  r_ptr[a_len] = 0;
-	}
+        {
+          memcpy (r_ptr, a_ptr, a_len * sizeof (mp_limb_t));
+          r_ptr[a_len] = 0;
+        }
       else
-	{
-	  const mp_limb_t *sourceptr = a_ptr;
-	  mp_limb_t *destptr = r_ptr;
-	  mp_twolimb_t accu = 0;
-	  size_t count;
-	  for (count = a_len; count > 0; count--)
-	    {
-	      accu += (mp_twolimb_t) *sourceptr++ << s;
-	      *destptr++ = (mp_limb_t) accu;
-	      accu = accu >> GMP_LIMB_BITS;
-	    }
-	  *destptr++ = (mp_limb_t) accu;
-	}
+        {
+          const mp_limb_t *sourceptr = a_ptr;
+          mp_limb_t *destptr = r_ptr;
+          mp_twolimb_t accu = 0;
+          size_t count;
+          for (count = a_len; count > 0; count--)
+            {
+              accu += (mp_twolimb_t) *sourceptr++ << s;
+              *destptr++ = (mp_limb_t) accu;
+              accu = accu >> GMP_LIMB_BITS;
+            }
+          *destptr++ = (mp_limb_t) accu;
+        }
       q_ptr = roomptr + b_len;
       q_len = a_len - b_len + 1; /* q will have m-n+1 limbs */
       {
-	size_t j = a_len - b_len; /* m-n */
-	mp_limb_t b_msd = b_ptr[b_len - 1]; /* b[n-1] */
-	mp_limb_t b_2msd = b_ptr[b_len - 2]; /* b[n-2] */
-	mp_twolimb_t b_msdd = /* b[n-1]*beta+b[n-2] */
-	  ((mp_twolimb_t) b_msd << GMP_LIMB_BITS) | b_2msd;
-	/* Division loop, traversed m-n+1 times.
-	   j counts down, b is unchanged, beta/2 <= b[n-1] < beta.  */
-	for (;;)
-	  {
-	    mp_limb_t q_star;
-	    mp_limb_t c1;
-	    if (r_ptr[j + b_len] < b_msd) /* r[j+n] < b[n-1] ? */
-	      {
-		/* Divide r[j+n]*beta+r[j+n-1] by b[n-1], no overflow.  */
-		mp_twolimb_t num =
-		  ((mp_twolimb_t) r_ptr[j + b_len] << GMP_LIMB_BITS)
-		  | r_ptr[j + b_len - 1];
-		q_star = num / b_msd;
-		c1 = num % b_msd;
-	      }
-	    else
-	      {
-		/* Overflow, hence r[j+n]*beta+r[j+n-1] >= beta*b[n-1].  */
-		q_star = (mp_limb_t)~(mp_limb_t)0; /* q* = beta-1 */
-		/* Test whether r[j+n]*beta+r[j+n-1] - (beta-1)*b[n-1] >= beta
-		   <==> r[j+n]*beta+r[j+n-1] + b[n-1] >= beta*b[n-1]+beta
-		   <==> b[n-1] < floor((r[j+n]*beta+r[j+n-1]+b[n-1])/beta)
-		        {<= beta !}.
-		   If yes, jump directly to the subtraction loop.
-		   (Otherwise, r[j+n]*beta+r[j+n-1] - (beta-1)*b[n-1] < beta
-		    <==> floor((r[j+n]*beta+r[j+n-1]+b[n-1])/beta) = b[n-1] ) */
-		if (r_ptr[j + b_len] > b_msd
-		    || (c1 = r_ptr[j + b_len - 1] + b_msd) < b_msd)
-		  /* r[j+n] >= b[n-1]+1 or
-		     r[j+n] = b[n-1] and the addition r[j+n-1]+b[n-1] gives a
-		     carry.  */
-		  goto subtract;
-	      }
-	    /* q_star = q*,
-	       c1 = (r[j+n]*beta+r[j+n-1]) - q* * b[n-1] (>=0, <beta).  */
-	    {
-	      mp_twolimb_t c2 = /* c1*beta+r[j+n-2] */
-		((mp_twolimb_t) c1 << GMP_LIMB_BITS) | r_ptr[j + b_len - 2];
-	      mp_twolimb_t c3 = /* b[n-2] * q* */
-		(mp_twolimb_t) b_2msd * (mp_twolimb_t) q_star;
-	      /* While c2 < c3, increase c2 and decrease c3.
-		 Consider c3-c2.  While it is > 0, decrease it by
-		 b[n-1]*beta+b[n-2].  Because of b[n-1]*beta+b[n-2] >= beta^2/2
-		 this can happen only twice.  */
-	      if (c3 > c2)
-		{
-		  q_star = q_star - 1; /* q* := q* - 1 */
-		  if (c3 - c2 > b_msdd)
-		    q_star = q_star - 1; /* q* := q* - 1 */
-		}
-	    }
-	    if (q_star > 0)
-	      subtract:
-	      {
-		/* Subtract r := r - b * q* * beta^j.  */
-		mp_limb_t cr;
-		{
-		  const mp_limb_t *sourceptr = b_ptr;
-		  mp_limb_t *destptr = r_ptr + j;
-		  mp_twolimb_t carry = 0;
-		  size_t count;
-		  for (count = b_len; count > 0; count--)
-		    {
-		      /* Here 0 <= carry <= q*.  */
-		      carry =
-			carry
-			+ (mp_twolimb_t) q_star * (mp_twolimb_t) *sourceptr++
-			+ (mp_limb_t) ~(*destptr);
-		      /* Here 0 <= carry <= beta*q* + beta-1.  */
-		      *destptr++ = ~(mp_limb_t) carry;
-		      carry = carry >> GMP_LIMB_BITS; /* <= q* */
-		    }
-		  cr = (mp_limb_t) carry;
-		}
-		/* Subtract cr from r_ptr[j + b_len], then forget about
-		   r_ptr[j + b_len].  */
-		if (cr > r_ptr[j + b_len])
-		  {
-		    /* Subtraction gave a carry.  */
-		    q_star = q_star - 1; /* q* := q* - 1 */
-		    /* Add b back.  */
-		    {
-		      const mp_limb_t *sourceptr = b_ptr;
-		      mp_limb_t *destptr = r_ptr + j;
-		      mp_limb_t carry = 0;
-		      size_t count;
-		      for (count = b_len; count > 0; count--)
-			{
-			  mp_limb_t source1 = *sourceptr++;
-			  mp_limb_t source2 = *destptr;
-			  *destptr++ = source1 + source2 + carry;
-			  carry =
-			    (carry
-			     ? source1 >= (mp_limb_t) ~source2
-			     : source1 > (mp_limb_t) ~source2);
-			}
-		    }
-		    /* Forget about the carry and about r[j+n].  */
-		  }
-	      }
-	    /* q* is determined.  Store it as q[j].  */
-	    q_ptr[j] = q_star;
-	    if (j == 0)
-	      break;
-	    j--;
-	  }
+        size_t j = a_len - b_len; /* m-n */
+        mp_limb_t b_msd = b_ptr[b_len - 1]; /* b[n-1] */
+        mp_limb_t b_2msd = b_ptr[b_len - 2]; /* b[n-2] */
+        mp_twolimb_t b_msdd = /* b[n-1]*beta+b[n-2] */
+          ((mp_twolimb_t) b_msd << GMP_LIMB_BITS) | b_2msd;
+        /* Division loop, traversed m-n+1 times.
+           j counts down, b is unchanged, beta/2 <= b[n-1] < beta.  */
+        for (;;)
+          {
+            mp_limb_t q_star;
+            mp_limb_t c1;
+            if (r_ptr[j + b_len] < b_msd) /* r[j+n] < b[n-1] ? */
+              {
+                /* Divide r[j+n]*beta+r[j+n-1] by b[n-1], no overflow.  */
+                mp_twolimb_t num =
+                  ((mp_twolimb_t) r_ptr[j + b_len] << GMP_LIMB_BITS)
+                  | r_ptr[j + b_len - 1];
+                q_star = num / b_msd;
+                c1 = num % b_msd;
+              }
+            else
+              {
+                /* Overflow, hence r[j+n]*beta+r[j+n-1] >= beta*b[n-1].  */
+                q_star = (mp_limb_t)~(mp_limb_t)0; /* q* = beta-1 */
+                /* Test whether r[j+n]*beta+r[j+n-1] - (beta-1)*b[n-1] >= beta
+                   <==> r[j+n]*beta+r[j+n-1] + b[n-1] >= beta*b[n-1]+beta
+                   <==> b[n-1] < floor((r[j+n]*beta+r[j+n-1]+b[n-1])/beta)
+                        {<= beta !}.
+                   If yes, jump directly to the subtraction loop.
+                   (Otherwise, r[j+n]*beta+r[j+n-1] - (beta-1)*b[n-1] < beta
+                    <==> floor((r[j+n]*beta+r[j+n-1]+b[n-1])/beta) = b[n-1] ) */
+                if (r_ptr[j + b_len] > b_msd
+                    || (c1 = r_ptr[j + b_len - 1] + b_msd) < b_msd)
+                  /* r[j+n] >= b[n-1]+1 or
+                     r[j+n] = b[n-1] and the addition r[j+n-1]+b[n-1] gives a
+                     carry.  */
+                  goto subtract;
+              }
+            /* q_star = q*,
+               c1 = (r[j+n]*beta+r[j+n-1]) - q* * b[n-1] (>=0, <beta).  */
+            {
+              mp_twolimb_t c2 = /* c1*beta+r[j+n-2] */
+                ((mp_twolimb_t) c1 << GMP_LIMB_BITS) | r_ptr[j + b_len - 2];
+              mp_twolimb_t c3 = /* b[n-2] * q* */
+                (mp_twolimb_t) b_2msd * (mp_twolimb_t) q_star;
+              /* While c2 < c3, increase c2 and decrease c3.
+                 Consider c3-c2.  While it is > 0, decrease it by
+                 b[n-1]*beta+b[n-2].  Because of b[n-1]*beta+b[n-2] >= beta^2/2
+                 this can happen only twice.  */
+              if (c3 > c2)
+                {
+                  q_star = q_star - 1; /* q* := q* - 1 */
+                  if (c3 - c2 > b_msdd)
+                    q_star = q_star - 1; /* q* := q* - 1 */
+                }
+            }
+            if (q_star > 0)
+              subtract:
+              {
+                /* Subtract r := r - b * q* * beta^j.  */
+                mp_limb_t cr;
+                {
+                  const mp_limb_t *sourceptr = b_ptr;
+                  mp_limb_t *destptr = r_ptr + j;
+                  mp_twolimb_t carry = 0;
+                  size_t count;
+                  for (count = b_len; count > 0; count--)
+                    {
+                      /* Here 0 <= carry <= q*.  */
+                      carry =
+                        carry
+                        + (mp_twolimb_t) q_star * (mp_twolimb_t) *sourceptr++
+                        + (mp_limb_t) ~(*destptr);
+                      /* Here 0 <= carry <= beta*q* + beta-1.  */
+                      *destptr++ = ~(mp_limb_t) carry;
+                      carry = carry >> GMP_LIMB_BITS; /* <= q* */
+                    }
+                  cr = (mp_limb_t) carry;
+                }
+                /* Subtract cr from r_ptr[j + b_len], then forget about
+                   r_ptr[j + b_len].  */
+                if (cr > r_ptr[j + b_len])
+                  {
+                    /* Subtraction gave a carry.  */
+                    q_star = q_star - 1; /* q* := q* - 1 */
+                    /* Add b back.  */
+                    {
+                      const mp_limb_t *sourceptr = b_ptr;
+                      mp_limb_t *destptr = r_ptr + j;
+                      mp_limb_t carry = 0;
+                      size_t count;
+                      for (count = b_len; count > 0; count--)
+                        {
+                          mp_limb_t source1 = *sourceptr++;
+                          mp_limb_t source2 = *destptr;
+                          *destptr++ = source1 + source2 + carry;
+                          carry =
+                            (carry
+                             ? source1 >= (mp_limb_t) ~source2
+                             : source1 > (mp_limb_t) ~source2);
+                        }
+                    }
+                    /* Forget about the carry and about r[j+n].  */
+                  }
+              }
+            /* q* is determined.  Store it as q[j].  */
+            q_ptr[j] = q_star;
+            if (j == 0)
+              break;
+            j--;
+          }
       }
       r_len = b_len;
       /* Normalise q.  */
       if (q_ptr[q_len - 1] == 0)
-	q_len--;
+        q_len--;
 # if 0 /* Not needed here, since we need r only to compare it with b/2, and
-	  b is shifted left by s bits.  */
+          b is shifted left by s bits.  */
       /* Shift r right by s bits.  */
       if (s > 0)
-	{
-	  mp_limb_t ptr = r_ptr + r_len;
-	  mp_twolimb_t accu = 0;
-	  size_t count;
-	  for (count = r_len; count > 0; count--)
-	    {
-	      accu = (mp_twolimb_t) (mp_limb_t) accu << GMP_LIMB_BITS;
-	      accu += (mp_twolimb_t) *--ptr << (GMP_LIMB_BITS - s);
-	      *ptr = (mp_limb_t) (accu >> GMP_LIMB_BITS);
-	    }
-	}
+        {
+          mp_limb_t ptr = r_ptr + r_len;
+          mp_twolimb_t accu = 0;
+          size_t count;
+          for (count = r_len; count > 0; count--)
+            {
+              accu = (mp_twolimb_t) (mp_limb_t) accu << GMP_LIMB_BITS;
+              accu += (mp_twolimb_t) *--ptr << (GMP_LIMB_BITS - s);
+              *ptr = (mp_limb_t) (accu >> GMP_LIMB_BITS);
+            }
+        }
 # endif
       /* Normalise r.  */
       while (r_len > 0 && r_ptr[r_len - 1] == 0)
-	r_len--;
+        r_len--;
     }
   /* Compare r << 1 with b.  */
   if (r_len > b_len)
@@ -762,17 +762,17 @@ divide (mpn_t a, mpn_t b, mpn_t *q)
     size_t i;
     for (i = b_len;;)
       {
-	mp_limb_t r_i =
-	  (i <= r_len && i > 0 ? r_ptr[i - 1] >> (GMP_LIMB_BITS - 1) : 0)
-	  | (i < r_len ? r_ptr[i] << 1 : 0);
-	mp_limb_t b_i = (i < b_len ? b_ptr[i] : 0);
-	if (r_i > b_i)
-	  goto increment_q;
-	if (r_i < b_i)
-	  goto keep_q;
-	if (i == 0)
-	  break;
-	i--;
+        mp_limb_t r_i =
+          (i <= r_len && i > 0 ? r_ptr[i - 1] >> (GMP_LIMB_BITS - 1) : 0)
+          | (i < r_len ? r_ptr[i] << 1 : 0);
+        mp_limb_t b_i = (i < b_len ? b_ptr[i] : 0);
+        if (r_i > b_i)
+          goto increment_q;
+        if (r_i < b_i)
+          goto keep_q;
+        if (i == 0)
+          break;
+        i--;
       }
   }
   if (q_len > 0 && ((q_ptr[0] & 1) != 0))
@@ -781,8 +781,8 @@ divide (mpn_t a, mpn_t b, mpn_t *q)
     {
       size_t i;
       for (i = 0; i < q_len; i++)
-	if (++(q_ptr[i]) != 0)
-	  goto keep_q;
+        if (++(q_ptr[i]) != 0)
+          goto keep_q;
       q_ptr[q_len++] = 1;
     }
   keep_q:
@@ -811,36 +811,36 @@ convert_to_decimal (mpn_t a, size_t extra_zeroes)
     {
       char *d_ptr = c_ptr;
       for (; extra_zeroes > 0; extra_zeroes--)
-	*d_ptr++ = '0';
+        *d_ptr++ = '0';
       while (a_len > 0)
-	{
-	  /* Divide a by 10^9, in-place.  */
-	  mp_limb_t remainder = 0;
-	  mp_limb_t *ptr = a_ptr + a_len;
-	  size_t count;
-	  for (count = a_len; count > 0; count--)
-	    {
-	      mp_twolimb_t num =
-		((mp_twolimb_t) remainder << GMP_LIMB_BITS) | *--ptr;
-	      *ptr = num / 1000000000;
-	      remainder = num % 1000000000;
-	    }
-	  /* Store the remainder as 9 decimal digits.  */
-	  for (count = 9; count > 0; count--)
-	    {
-	      *d_ptr++ = '0' + (remainder % 10);
-	      remainder = remainder / 10;
-	    }
-	  /* Normalize a.  */
-	  if (a_ptr[a_len - 1] == 0)
-	    a_len--;
-	}
+        {
+          /* Divide a by 10^9, in-place.  */
+          mp_limb_t remainder = 0;
+          mp_limb_t *ptr = a_ptr + a_len;
+          size_t count;
+          for (count = a_len; count > 0; count--)
+            {
+              mp_twolimb_t num =
+                ((mp_twolimb_t) remainder << GMP_LIMB_BITS) | *--ptr;
+              *ptr = num / 1000000000;
+              remainder = num % 1000000000;
+            }
+          /* Store the remainder as 9 decimal digits.  */
+          for (count = 9; count > 0; count--)
+            {
+              *d_ptr++ = '0' + (remainder % 10);
+              remainder = remainder / 10;
+            }
+          /* Normalize a.  */
+          if (a_ptr[a_len - 1] == 0)
+            a_len--;
+        }
       /* Remove leading zeroes.  */
       while (d_ptr > c_ptr && d_ptr[-1] == '0')
-	d_ptr--;
+        d_ptr--;
       /* But keep at least one zero.  */
       if (d_ptr == c_ptr)
-	*d_ptr++ = '0';
+        *d_ptr++ = '0';
       /* Terminate the string.  */
       *d_ptr = '\0';
     }
@@ -885,12 +885,12 @@ decode_long_double (long double x, int *ep, mpn_t *mp)
       hi = (int) y;
       y -= hi;
       if (!(y >= 0.0L && y < 1.0L))
-	abort ();
+        abort ();
       y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2);
       lo = (int) y;
       y -= lo;
       if (!(y >= 0.0L && y < 1.0L))
-	abort ();
+        abort ();
       m.limbs[LDBL_MANT_BIT / GMP_LIMB_BITS] = (hi << (GMP_LIMB_BITS / 2)) | lo;
     }
 #   else
@@ -900,7 +900,7 @@ decode_long_double (long double x, int *ep, mpn_t *mp)
       d = (int) y;
       y -= d;
       if (!(y >= 0.0L && y < 1.0L))
-	abort ();
+        abort ();
       m.limbs[LDBL_MANT_BIT / GMP_LIMB_BITS] = d;
     }
 #   endif
@@ -912,12 +912,12 @@ decode_long_double (long double x, int *ep, mpn_t *mp)
       hi = (int) y;
       y -= hi;
       if (!(y >= 0.0L && y < 1.0L))
-	abort ();
+        abort ();
       y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2);
       lo = (int) y;
       y -= lo;
       if (!(y >= 0.0L && y < 1.0L))
-	abort ();
+        abort ();
       m.limbs[--i] = (hi << (GMP_LIMB_BITS / 2)) | lo;
     }
 #if 0 /* On FreeBSD 6.1/x86, 'long double' numbers sometimes have excess
@@ -973,12 +973,12 @@ decode_double (double x, int *ep, mpn_t *mp)
       hi = (int) y;
       y -= hi;
       if (!(y >= 0.0 && y < 1.0))
-	abort ();
+        abort ();
       y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2);
       lo = (int) y;
       y -= lo;
       if (!(y >= 0.0 && y < 1.0))
-	abort ();
+        abort ();
       m.limbs[DBL_MANT_BIT / GMP_LIMB_BITS] = (hi << (GMP_LIMB_BITS / 2)) | lo;
     }
 #   else
@@ -988,7 +988,7 @@ decode_double (double x, int *ep, mpn_t *mp)
       d = (int) y;
       y -= d;
       if (!(y >= 0.0 && y < 1.0))
-	abort ();
+        abort ();
       m.limbs[DBL_MANT_BIT / GMP_LIMB_BITS] = d;
     }
 #   endif
@@ -1000,12 +1000,12 @@ decode_double (double x, int *ep, mpn_t *mp)
       hi = (int) y;
       y -= hi;
       if (!(y >= 0.0 && y < 1.0))
-	abort ();
+        abort ();
       y *= (mp_limb_t) 1 << (GMP_LIMB_BITS / 2);
       lo = (int) y;
       y -= lo;
       if (!(y >= 0.0 && y < 1.0))
-	abort ();
+        abort ();
       m.limbs[--i] = (hi << (GMP_LIMB_BITS / 2)) | lo;
     }
   if (!(y == 0.0))
@@ -1063,8 +1063,8 @@ scale10_round_decimal_decoded (int e, mpn_t m, void *memory, int n)
   abs_n = (n >= 0 ? n : -n);
   abs_s = (s >= 0 ? s : -s);
   pow5_ptr = (mp_limb_t *) malloc (((int)(abs_n * (2.322f / GMP_LIMB_BITS)) + 1
-				    + abs_s / GMP_LIMB_BITS + 1)
-				   * sizeof (mp_limb_t));
+                                    + abs_s / GMP_LIMB_BITS + 1)
+                                   * sizeof (mp_limb_t));
   if (pow5_ptr == NULL)
     {
       free (memory);
@@ -1077,26 +1077,26 @@ scale10_round_decimal_decoded (int e, mpn_t m, void *memory, int n)
   if (abs_n > 0)
     {
       static mp_limb_t const small_pow5[13 + 1] =
-	{
-	  1, 5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625,
-	  48828125, 244140625, 1220703125
-	};
+        {
+          1, 5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625,
+          48828125, 244140625, 1220703125
+        };
       unsigned int n13;
       for (n13 = 0; n13 <= abs_n; n13 += 13)
-	{
-	  mp_limb_t digit1 = small_pow5[n13 + 13 <= abs_n ? 13 : abs_n - n13];
-	  size_t j;
-	  mp_twolimb_t carry = 0;
-	  for (j = 0; j < pow5_len; j++)
-	    {
-	      mp_limb_t digit2 = pow5_ptr[j];
-	      carry += (mp_twolimb_t) digit1 * (mp_twolimb_t) digit2;
-	      pow5_ptr[j] = (mp_limb_t) carry;
-	      carry = carry >> GMP_LIMB_BITS;
-	    }
-	  if (carry > 0)
-	    pow5_ptr[pow5_len++] = (mp_limb_t) carry;
-	}
+        {
+          mp_limb_t digit1 = small_pow5[n13 + 13 <= abs_n ? 13 : abs_n - n13];
+          size_t j;
+          mp_twolimb_t carry = 0;
+          for (j = 0; j < pow5_len; j++)
+            {
+              mp_limb_t digit2 = pow5_ptr[j];
+              carry += (mp_twolimb_t) digit1 * (mp_twolimb_t) digit2;
+              pow5_ptr[j] = (mp_limb_t) carry;
+              carry = carry >> GMP_LIMB_BITS;
+            }
+          if (carry > 0)
+            pow5_ptr[pow5_len++] = (mp_limb_t) carry;
+        }
     }
   s_limbs = abs_s / GMP_LIMB_BITS;
   s_bits = abs_s % GMP_LIMB_BITS;
@@ -1104,129 +1104,129 @@ scale10_round_decimal_decoded (int e, mpn_t m, void *memory, int n)
     {
       /* Multiply with 2^|s|.  */
       if (s_bits > 0)
-	{
-	  mp_limb_t *ptr = pow5_ptr;
-	  mp_twolimb_t accu = 0;
-	  size_t count;
-	  for (count = pow5_len; count > 0; count--)
-	    {
-	      accu += (mp_twolimb_t) *ptr << s_bits;
-	      *ptr++ = (mp_limb_t) accu;
-	      accu = accu >> GMP_LIMB_BITS;
-	    }
-	  if (accu > 0)
-	    {
-	      *ptr = (mp_limb_t) accu;
-	      pow5_len++;
-	    }
-	}
+        {
+          mp_limb_t *ptr = pow5_ptr;
+          mp_twolimb_t accu = 0;
+          size_t count;
+          for (count = pow5_len; count > 0; count--)
+            {
+              accu += (mp_twolimb_t) *ptr << s_bits;
+              *ptr++ = (mp_limb_t) accu;
+              accu = accu >> GMP_LIMB_BITS;
+            }
+          if (accu > 0)
+            {
+              *ptr = (mp_limb_t) accu;
+              pow5_len++;
+            }
+        }
       if (s_limbs > 0)
-	{
-	  size_t count;
-	  for (count = pow5_len; count > 0;)
-	    {
-	      count--;
-	      pow5_ptr[s_limbs + count] = pow5_ptr[count];
-	    }
-	  for (count = s_limbs; count > 0;)
-	    {
-	      count--;
-	      pow5_ptr[count] = 0;
-	    }
-	  pow5_len += s_limbs;
-	}
+        {
+          size_t count;
+          for (count = pow5_len; count > 0;)
+            {
+              count--;
+              pow5_ptr[s_limbs + count] = pow5_ptr[count];
+            }
+          for (count = s_limbs; count > 0;)
+            {
+              count--;
+              pow5_ptr[count] = 0;
+            }
+          pow5_len += s_limbs;
+        }
       pow5.limbs = pow5_ptr;
       pow5.nlimbs = pow5_len;
       if (n >= 0)
-	{
-	  /* Multiply m with pow5.  No division needed.  */
-	  z_memory = multiply (m, pow5, &z);
-	}
+        {
+          /* Multiply m with pow5.  No division needed.  */
+          z_memory = multiply (m, pow5, &z);
+        }
       else
-	{
-	  /* Divide m by pow5 and round.  */
-	  z_memory = divide (m, pow5, &z);
-	}
+        {
+          /* Divide m by pow5 and round.  */
+          z_memory = divide (m, pow5, &z);
+        }
     }
   else
     {
       pow5.limbs = pow5_ptr;
       pow5.nlimbs = pow5_len;
       if (n >= 0)
-	{
-	  /* n >= 0, s < 0.
-	     Multiply m with pow5, then divide by 2^|s|.  */
-	  mpn_t numerator;
-	  mpn_t denominator;
-	  void *tmp_memory;
-	  tmp_memory = multiply (m, pow5, &numerator);
-	  if (tmp_memory == NULL)
-	    {
-	      free (pow5_ptr);
-	      free (memory);
-	      return NULL;
-	    }
-	  /* Construct 2^|s|.  */
-	  {
-	    mp_limb_t *ptr = pow5_ptr + pow5_len;
-	    size_t i;
-	    for (i = 0; i < s_limbs; i++)
-	      ptr[i] = 0;
-	    ptr[s_limbs] = (mp_limb_t) 1 << s_bits;
-	    denominator.limbs = ptr;
-	    denominator.nlimbs = s_limbs + 1;
-	  }
-	  z_memory = divide (numerator, denominator, &z);
-	  free (tmp_memory);
-	}
+        {
+          /* n >= 0, s < 0.
+             Multiply m with pow5, then divide by 2^|s|.  */
+          mpn_t numerator;
+          mpn_t denominator;
+          void *tmp_memory;
+          tmp_memory = multiply (m, pow5, &numerator);
+          if (tmp_memory == NULL)
+            {
+              free (pow5_ptr);
+              free (memory);
+              return NULL;
+            }
+          /* Construct 2^|s|.  */
+          {
+            mp_limb_t *ptr = pow5_ptr + pow5_len;
+            size_t i;
+            for (i = 0; i < s_limbs; i++)
+              ptr[i] = 0;
+            ptr[s_limbs] = (mp_limb_t) 1 << s_bits;
+            denominator.limbs = ptr;
+            denominator.nlimbs = s_limbs + 1;
+          }
+          z_memory = divide (numerator, denominator, &z);
+          free (tmp_memory);
+        }
       else
-	{
-	  /* n < 0, s > 0.
-	     Multiply m with 2^s, then divide by pow5.  */
-	  mpn_t numerator;
-	  mp_limb_t *num_ptr;
-	  num_ptr = (mp_limb_t *) malloc ((m.nlimbs + s_limbs + 1)
-					  * sizeof (mp_limb_t));
-	  if (num_ptr == NULL)
-	    {
-	      free (pow5_ptr);
-	      free (memory);
-	      return NULL;
-	    }
-	  {
-	    mp_limb_t *destptr = num_ptr;
-	    {
-	      size_t i;
-	      for (i = 0; i < s_limbs; i++)
-		*destptr++ = 0;
-	    }
-	    if (s_bits > 0)
-	      {
-		const mp_limb_t *sourceptr = m.limbs;
-		mp_twolimb_t accu = 0;
-		size_t count;
-		for (count = m.nlimbs; count > 0; count--)
-		  {
-		    accu += (mp_twolimb_t) *sourceptr++ << s_bits;
-		    *destptr++ = (mp_limb_t) accu;
-		    accu = accu >> GMP_LIMB_BITS;
-		  }
-		if (accu > 0)
-		  *destptr++ = (mp_limb_t) accu;
-	      }
-	    else
-	      {
-		const mp_limb_t *sourceptr = m.limbs;
-		size_t count;
-		for (count = m.nlimbs; count > 0; count--)
-		  *destptr++ = *sourceptr++;
-	      }
-	    numerator.limbs = num_ptr;
-	    numerator.nlimbs = destptr - num_ptr;
-	  }
-	  z_memory = divide (numerator, pow5, &z);
-	  free (num_ptr);
-	}
+        {
+          /* n < 0, s > 0.
+             Multiply m with 2^s, then divide by pow5.  */
+          mpn_t numerator;
+          mp_limb_t *num_ptr;
+          num_ptr = (mp_limb_t *) malloc ((m.nlimbs + s_limbs + 1)
+                                          * sizeof (mp_limb_t));
+          if (num_ptr == NULL)
+            {
+              free (pow5_ptr);
+              free (memory);
+              return NULL;
+            }
+          {
+            mp_limb_t *destptr = num_ptr;
+            {
+              size_t i;
+              for (i = 0; i < s_limbs; i++)
+                *destptr++ = 0;
+            }
+            if (s_bits > 0)
+              {
+                const mp_limb_t *sourceptr = m.limbs;
+                mp_twolimb_t accu = 0;
+                size_t count;
+                for (count = m.nlimbs; count > 0; count--)
+                  {
+                    accu += (mp_twolimb_t) *sourceptr++ << s_bits;
+                    *destptr++ = (mp_limb_t) accu;
+                    accu = accu >> GMP_LIMB_BITS;
+                  }
+                if (accu > 0)
+                  *destptr++ = (mp_limb_t) accu;
+              }
+            else
+              {
+                const mp_limb_t *sourceptr = m.limbs;
+                size_t count;
+                for (count = m.nlimbs; count > 0; count--)
+                  *destptr++ = *sourceptr++;
+              }
+            numerator.limbs = num_ptr;
+            numerator.nlimbs = destptr - num_ptr;
+          }
+          z_memory = divide (numerator, pow5, &z);
+          free (num_ptr);
+        }
     }
   free (pow5_ptr);
   free (memory);
@@ -1298,35 +1298,35 @@ floorlog10l (long double x)
   if (y < 0.5L)
     {
       while (y < (1.0L / (1 << (GMP_LIMB_BITS / 2)) / (1 << (GMP_LIMB_BITS / 2))))
-	{
-	  y *= 1.0L * (1 << (GMP_LIMB_BITS / 2)) * (1 << (GMP_LIMB_BITS / 2));
-	  exp -= GMP_LIMB_BITS;
-	}
+        {
+          y *= 1.0L * (1 << (GMP_LIMB_BITS / 2)) * (1 << (GMP_LIMB_BITS / 2));
+          exp -= GMP_LIMB_BITS;
+        }
       if (y < (1.0L / (1 << 16)))
-	{
-	  y *= 1.0L * (1 << 16);
-	  exp -= 16;
-	}
+        {
+          y *= 1.0L * (1 << 16);
+          exp -= 16;
+        }
       if (y < (1.0L / (1 << 8)))
-	{
-	  y *= 1.0L * (1 << 8);
-	  exp -= 8;
-	}
+        {
+          y *= 1.0L * (1 << 8);
+          exp -= 8;
+        }
       if (y < (1.0L / (1 << 4)))
-	{
-	  y *= 1.0L * (1 << 4);
-	  exp -= 4;
-	}
+        {
+          y *= 1.0L * (1 << 4);
+          exp -= 4;
+        }
       if (y < (1.0L / (1 << 2)))
-	{
-	  y *= 1.0L * (1 << 2);
-	  exp -= 2;
-	}
+        {
+          y *= 1.0L * (1 << 2);
+          exp -= 2;
+        }
       if (y < (1.0L / (1 << 1)))
-	{
-	  y *= 1.0L * (1 << 1);
-	  exp -= 1;
-	}
+        {
+          y *= 1.0L * (1 << 1);
+          exp -= 1;
+        }
     }
   if (!(y >= 0.5L && y < 1.0L))
     abort ();
@@ -1389,35 +1389,35 @@ floorlog10 (double x)
   if (y < 0.5)
     {
       while (y < (1.0 / (1 << (GMP_LIMB_BITS / 2)) / (1 << (GMP_LIMB_BITS / 2))))
-	{
-	  y *= 1.0 * (1 << (GMP_LIMB_BITS / 2)) * (1 << (GMP_LIMB_BITS / 2));
-	  exp -= GMP_LIMB_BITS;
-	}
+        {
+          y *= 1.0 * (1 << (GMP_LIMB_BITS / 2)) * (1 << (GMP_LIMB_BITS / 2));
+          exp -= GMP_LIMB_BITS;
+        }
       if (y < (1.0 / (1 << 16)))
-	{
-	  y *= 1.0 * (1 << 16);
-	  exp -= 16;
-	}
+        {
+          y *= 1.0 * (1 << 16);
+          exp -= 16;
+        }
       if (y < (1.0 / (1 << 8)))
-	{
-	  y *= 1.0 * (1 << 8);
-	  exp -= 8;
-	}
+        {
+          y *= 1.0 * (1 << 8);
+          exp -= 8;
+        }
       if (y < (1.0 / (1 << 4)))
-	{
-	  y *= 1.0 * (1 << 4);
-	  exp -= 4;
-	}
+        {
+          y *= 1.0 * (1 << 4);
+          exp -= 4;
+        }
       if (y < (1.0 / (1 << 2)))
-	{
-	  y *= 1.0 * (1 << 2);
-	  exp -= 2;
-	}
+        {
+          y *= 1.0 * (1 << 2);
+          exp -= 2;
+        }
       if (y < (1.0 / (1 << 1)))
-	{
-	  y *= 1.0 * (1 << 1);
-	  exp -= 1;
-	}
+        {
+          y *= 1.0 * (1 << 1);
+          exp -= 1;
+        }
     }
   if (!(y >= 0.5 && y < 1.0))
     abort ();
@@ -1476,7 +1476,7 @@ is_borderline (const char *digits, size_t precision)
 
 DCHAR_T *
 VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
-	    const FCHAR_T *format, va_list args)
+            const FCHAR_T *format, va_list args)
 {
   DIRECTIVES d;
   arguments a;
@@ -1486,8 +1486,8 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
     return NULL;
 
 #define CLEANUP() \
-  free (d.dir);								\
-  if (a.arg)								\
+  free (d.dir);                                                         \
+  if (a.arg)                                                            \
     free (a.arg);
 
   if (PRINTF_FETCHARGS (args, &a) < 0)
@@ -1516,30 +1516,30 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
 #if HAVE_ALLOCA
     if (buf_neededlength < 4000 / sizeof (TCHAR_T))
       {
-	buf = (TCHAR_T *) alloca (buf_neededlength * sizeof (TCHAR_T));
-	buf_malloced = NULL;
+        buf = (TCHAR_T *) alloca (buf_neededlength * sizeof (TCHAR_T));
+        buf_malloced = NULL;
       }
     else
 #endif
       {
-	size_t buf_memsize = xtimes (buf_neededlength, sizeof (TCHAR_T));
-	if (size_overflow_p (buf_memsize))
-	  goto out_of_memory_1;
-	buf = (TCHAR_T *) malloc (buf_memsize);
-	if (buf == NULL)
-	  goto out_of_memory_1;
-	buf_malloced = buf;
+        size_t buf_memsize = xtimes (buf_neededlength, sizeof (TCHAR_T));
+        if (size_overflow_p (buf_memsize))
+          goto out_of_memory_1;
+        buf = (TCHAR_T *) malloc (buf_memsize);
+        if (buf == NULL)
+          goto out_of_memory_1;
+        buf_malloced = buf;
       }
 
     if (resultbuf != NULL)
       {
-	result = resultbuf;
-	allocated = *lengthp;
+        result = resultbuf;
+        allocated = *lengthp;
       }
     else
       {
-	result = NULL;
-	allocated = 0;
+        result = NULL;
+        allocated = 0;
       }
     length = 0;
     /* Invariants:
@@ -1549,3881 +1549,3881 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
     /* Ensures that allocated >= needed.  Aborts through a jump to
        out_of_memory if needed is SIZE_MAX or otherwise too big.  */
 #define ENSURE_ALLOCATION(needed) \
-    if ((needed) > allocated)						     \
-      {									     \
-	size_t memory_size;						     \
-	DCHAR_T *memory;						     \
-									     \
-	allocated = (allocated > 0 ? xtimes (allocated, 2) : 12);	     \
-	if ((needed) > allocated)					     \
-	  allocated = (needed);						     \
-	memory_size = xtimes (allocated, sizeof (DCHAR_T));		     \
-	if (size_overflow_p (memory_size))				     \
-	  goto out_of_memory;						     \
-	if (result == resultbuf || result == NULL)			     \
-	  memory = (DCHAR_T *) malloc (memory_size);			     \
-	else								     \
-	  memory = (DCHAR_T *) realloc (result, memory_size);		     \
-	if (memory == NULL)						     \
-	  goto out_of_memory;						     \
-	if (result == resultbuf && length > 0)				     \
-	  DCHAR_CPY (memory, result, length);				     \
-	result = memory;						     \
+    if ((needed) > allocated)                                                \
+      {                                                                      \
+        size_t memory_size;                                                  \
+        DCHAR_T *memory;                                                     \
+                                                                             \
+        allocated = (allocated > 0 ? xtimes (allocated, 2) : 12);            \
+        if ((needed) > allocated)                                            \
+          allocated = (needed);                                              \
+        memory_size = xtimes (allocated, sizeof (DCHAR_T));                  \
+        if (size_overflow_p (memory_size))                                   \
+          goto out_of_memory;                                                \
+        if (result == resultbuf || result == NULL)                           \
+          memory = (DCHAR_T *) malloc (memory_size);                         \
+        else                                                                 \
+          memory = (DCHAR_T *) realloc (result, memory_size);                \
+        if (memory == NULL)                                                  \
+          goto out_of_memory;                                                \
+        if (result == resultbuf && length > 0)                               \
+          DCHAR_CPY (memory, result, length);                                \
+        result = memory;                                                     \
       }
 
     for (cp = format, i = 0, dp = &d.dir[0]; ; cp = dp->dir_end, i++, dp++)
       {
-	if (cp != dp->dir_start)
-	  {
-	    size_t n = dp->dir_start - cp;
-	    size_t augmented_length = xsum (length, n);
-
-	    ENSURE_ALLOCATION (augmented_length);
-	    /* This copies a piece of FCHAR_T[] into a DCHAR_T[].  Here we
-	       need that the format string contains only ASCII characters
-	       if FCHAR_T and DCHAR_T are not the same type.  */
-	    if (sizeof (FCHAR_T) == sizeof (DCHAR_T))
-	      {
-		DCHAR_CPY (result + length, (const DCHAR_T *) cp, n);
-		length = augmented_length;
-	      }
-	    else
-	      {
-		do
-		  result[length++] = (unsigned char) *cp++;
-		while (--n > 0);
-	      }
-	  }
-	if (i == d.count)
-	  break;
-
-	/* Execute a single directive.  */
-	if (dp->conversion == '%')
-	  {
-	    size_t augmented_length;
-
-	    if (!(dp->arg_index == ARG_NONE))
-	      abort ();
-	    augmented_length = xsum (length, 1);
-	    ENSURE_ALLOCATION (augmented_length);
-	    result[length] = '%';
-	    length = augmented_length;
-	  }
-	else
-	  {
-	    if (!(dp->arg_index != ARG_NONE))
-	      abort ();
-
-	    if (dp->conversion == 'n')
-	      {
-		switch (a.arg[dp->arg_index].type)
-		  {
-		  case TYPE_COUNT_SCHAR_POINTER:
-		    *a.arg[dp->arg_index].a.a_count_schar_pointer = length;
-		    break;
-		  case TYPE_COUNT_SHORT_POINTER:
-		    *a.arg[dp->arg_index].a.a_count_short_pointer = length;
-		    break;
-		  case TYPE_COUNT_INT_POINTER:
-		    *a.arg[dp->arg_index].a.a_count_int_pointer = length;
-		    break;
-		  case TYPE_COUNT_LONGINT_POINTER:
-		    *a.arg[dp->arg_index].a.a_count_longint_pointer = length;
-		    break;
+        if (cp != dp->dir_start)
+          {
+            size_t n = dp->dir_start - cp;
+            size_t augmented_length = xsum (length, n);
+
+            ENSURE_ALLOCATION (augmented_length);
+            /* This copies a piece of FCHAR_T[] into a DCHAR_T[].  Here we
+               need that the format string contains only ASCII characters
+               if FCHAR_T and DCHAR_T are not the same type.  */
+            if (sizeof (FCHAR_T) == sizeof (DCHAR_T))
+              {
+                DCHAR_CPY (result + length, (const DCHAR_T *) cp, n);
+                length = augmented_length;
+              }
+            else
+              {
+                do
+                  result[length++] = (unsigned char) *cp++;
+                while (--n > 0);
+              }
+          }
+        if (i == d.count)
+          break;
+
+        /* Execute a single directive.  */
+        if (dp->conversion == '%')
+          {
+            size_t augmented_length;
+
+            if (!(dp->arg_index == ARG_NONE))
+              abort ();
+            augmented_length = xsum (length, 1);
+            ENSURE_ALLOCATION (augmented_length);
+            result[length] = '%';
+            length = augmented_length;
+          }
+        else
+          {
+            if (!(dp->arg_index != ARG_NONE))
+              abort ();
+
+            if (dp->conversion == 'n')
+              {
+                switch (a.arg[dp->arg_index].type)
+                  {
+                  case TYPE_COUNT_SCHAR_POINTER:
+                    *a.arg[dp->arg_index].a.a_count_schar_pointer = length;
+                    break;
+                  case TYPE_COUNT_SHORT_POINTER:
+                    *a.arg[dp->arg_index].a.a_count_short_pointer = length;
+                    break;
+                  case TYPE_COUNT_INT_POINTER:
+                    *a.arg[dp->arg_index].a.a_count_int_pointer = length;
+                    break;
+                  case TYPE_COUNT_LONGINT_POINTER:
+                    *a.arg[dp->arg_index].a.a_count_longint_pointer = length;
+                    break;
 #if HAVE_LONG_LONG_INT
-		  case TYPE_COUNT_LONGLONGINT_POINTER:
-		    *a.arg[dp->arg_index].a.a_count_longlongint_pointer = length;
-		    break;
+                  case TYPE_COUNT_LONGLONGINT_POINTER:
+                    *a.arg[dp->arg_index].a.a_count_longlongint_pointer = length;
+                    break;
 #endif
-		  default:
-		    abort ();
-		  }
-	      }
+                  default:
+                    abort ();
+                  }
+              }
 #if ENABLE_UNISTDIO
-	    /* The unistdio extensions.  */
-	    else if (dp->conversion == 'U')
-	      {
-		arg_type type = a.arg[dp->arg_index].type;
-		int flags = dp->flags;
-		int has_width;
-		size_t width;
-		int has_precision;
-		size_t precision;
-
-		has_width = 0;
-		width = 0;
-		if (dp->width_start != dp->width_end)
-		  {
-		    if (dp->width_arg_index != ARG_NONE)
-		      {
-			int arg;
-
-			if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
-			  abort ();
-			arg = a.arg[dp->width_arg_index].a.a_int;
-			if (arg < 0)
-			  {
-			    /* "A negative field width is taken as a '-' flag
-			        followed by a positive field width."  */
-			    flags |= FLAG_LEFT;
-			    width = (unsigned int) (-arg);
-			  }
-			else
-			  width = arg;
-		      }
-		    else
-		      {
-			const FCHAR_T *digitp = dp->width_start;
-
-			do
-			  width = xsum (xtimes (width, 10), *digitp++ - '0');
-			while (digitp != dp->width_end);
-		      }
-		    has_width = 1;
-		  }
-
-		has_precision = 0;
-		precision = 0;
-		if (dp->precision_start != dp->precision_end)
-		  {
-		    if (dp->precision_arg_index != ARG_NONE)
-		      {
-			int arg;
-
-			if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
-			  abort ();
-			arg = a.arg[dp->precision_arg_index].a.a_int;
-			/* "A negative precision is taken as if the precision
-			    were omitted."  */
-			if (arg >= 0)
-			  {
-			    precision = arg;
-			    has_precision = 1;
-			  }
-		      }
-		    else
-		      {
-			const FCHAR_T *digitp = dp->precision_start + 1;
-
-			precision = 0;
-			while (digitp != dp->precision_end)
-			  precision = xsum (xtimes (precision, 10), *digitp++ - '0');
-			has_precision = 1;
-		      }
-		  }
-
-		switch (type)
-		  {
-		  case TYPE_U8_STRING:
-		    {
-		      const uint8_t *arg = a.arg[dp->arg_index].a.a_u8_string;
-		      const uint8_t *arg_end;
-		      size_t characters;
-
-		      if (has_precision)
-			{
-			  /* Use only PRECISION characters, from the left.  */
-			  arg_end = arg;
-			  characters = 0;
-			  for (; precision > 0; precision--)
-			    {
-			      int count = u8_strmblen (arg_end);
-			      if (count == 0)
-				break;
-			      if (count < 0)
-				{
-				  if (!(result == resultbuf || result == NULL))
-				    free (result);
-				  if (buf_malloced != NULL)
-				    free (buf_malloced);
-				  CLEANUP ();
-				  errno = EILSEQ;
-				  return NULL;
-				}
-			      arg_end += count;
-			      characters++;
-			    }
-			}
-		      else if (has_width)
-			{
-			  /* Use the entire string, and count the number of
-			     characters.  */
-			  arg_end = arg;
-			  characters = 0;
-			  for (;;)
-			    {
-			      int count = u8_strmblen (arg_end);
-			      if (count == 0)
-				break;
-			      if (count < 0)
-				{
-				  if (!(result == resultbuf || result == NULL))
-				    free (result);
-				  if (buf_malloced != NULL)
-				    free (buf_malloced);
-				  CLEANUP ();
-				  errno = EILSEQ;
-				  return NULL;
-				}
-			      arg_end += count;
-			      characters++;
-			    }
-			}
-		      else
-			{
-			  /* Use the entire string.  */
-			  arg_end = arg + u8_strlen (arg);
-			  /* The number of characters doesn't matter.  */
-			  characters = 0;
-			}
-
-		      if (has_width && width > characters
-			  && !(dp->flags & FLAG_LEFT))
-			{
-			  size_t n = width - characters;
-			  ENSURE_ALLOCATION (xsum (length, n));
-			  DCHAR_SET (result + length, ' ', n);
-			  length += n;
-			}
+            /* The unistdio extensions.  */
+            else if (dp->conversion == 'U')
+              {
+                arg_type type = a.arg[dp->arg_index].type;
+                int flags = dp->flags;
+                int has_width;
+                size_t width;
+                int has_precision;
+                size_t precision;
+
+                has_width = 0;
+                width = 0;
+                if (dp->width_start != dp->width_end)
+                  {
+                    if (dp->width_arg_index != ARG_NONE)
+                      {
+                        int arg;
+
+                        if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
+                          abort ();
+                        arg = a.arg[dp->width_arg_index].a.a_int;
+                        if (arg < 0)
+                          {
+                            /* "A negative field width is taken as a '-' flag
+                                followed by a positive field width."  */
+                            flags |= FLAG_LEFT;
+                            width = (unsigned int) (-arg);
+                          }
+                        else
+                          width = arg;
+                      }
+                    else
+                      {
+                        const FCHAR_T *digitp = dp->width_start;
+
+                        do
+                          width = xsum (xtimes (width, 10), *digitp++ - '0');
+                        while (digitp != dp->width_end);
+                      }
+                    has_width = 1;
+                  }
+
+                has_precision = 0;
+                precision = 0;
+                if (dp->precision_start != dp->precision_end)
+                  {
+                    if (dp->precision_arg_index != ARG_NONE)
+                      {
+                        int arg;
+
+                        if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
+                          abort ();
+                        arg = a.arg[dp->precision_arg_index].a.a_int;
+                        /* "A negative precision is taken as if the precision
+                            were omitted."  */
+                        if (arg >= 0)
+                          {
+                            precision = arg;
+                            has_precision = 1;
+                          }
+                      }
+                    else
+                      {
+                        const FCHAR_T *digitp = dp->precision_start + 1;
+
+                        precision = 0;
+                        while (digitp != dp->precision_end)
+                          precision = xsum (xtimes (precision, 10), *digitp++ - '0');
+                        has_precision = 1;
+                      }
+                  }
+
+                switch (type)
+                  {
+                  case TYPE_U8_STRING:
+                    {
+                      const uint8_t *arg = a.arg[dp->arg_index].a.a_u8_string;
+                      const uint8_t *arg_end;
+                      size_t characters;
+
+                      if (has_precision)
+                        {
+                          /* Use only PRECISION characters, from the left.  */
+                          arg_end = arg;
+                          characters = 0;
+                          for (; precision > 0; precision--)
+                            {
+                              int count = u8_strmblen (arg_end);
+                              if (count == 0)
+                                break;
+                              if (count < 0)
+                                {
+                                  if (!(result == resultbuf || result == NULL))
+                                    free (result);
+                                  if (buf_malloced != NULL)
+                                    free (buf_malloced);
+                                  CLEANUP ();
+                                  errno = EILSEQ;
+                                  return NULL;
+                                }
+                              arg_end += count;
+                              characters++;
+                            }
+                        }
+                      else if (has_width)
+                        {
+                          /* Use the entire string, and count the number of
+                             characters.  */
+                          arg_end = arg;
+                          characters = 0;
+                          for (;;)
+                            {
+                              int count = u8_strmblen (arg_end);
+                              if (count == 0)
+                                break;
+                              if (count < 0)
+                                {
+                                  if (!(result == resultbuf || result == NULL))
+                                    free (result);
+                                  if (buf_malloced != NULL)
+                                    free (buf_malloced);
+                                  CLEANUP ();
+                                  errno = EILSEQ;
+                                  return NULL;
+                                }
+                              arg_end += count;
+                              characters++;
+                            }
+                        }
+                      else
+                        {
+                          /* Use the entire string.  */
+                          arg_end = arg + u8_strlen (arg);