[libvirt] [PATCH 07/17] updates from gnulib

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Jim Meyering <meyering@xxxxxxxxxx>

---
 .cvsignore                                      |   39 +-
 .gitignore                                      |   39 +-
 examples/domain-events/events-c/.cvsignore      |    3 +
 examples/domain-events/events-c/.gitignore      |    3 +
 gnulib/lib/.cvsignore                           |    3 +-
 gnulib/lib/.gitignore                           |    3 +-
 gnulib/lib/Makefile.am                          |  303 +++++++++++++-
 gnulib/lib/alloca.c                             |  489 +++++++++++++++++++++++
 gnulib/lib/arpa_inet.in.h                       |    6 +
 gnulib/lib/c-ctype.h                            |   17 +-
 gnulib/lib/close.c                              |   82 ++++
 gnulib/lib/connect.c                            |   47 +++
 gnulib/lib/errno.in.h                           |  155 +++++++
 gnulib/lib/fclose.c                             |   47 +++
 gnulib/lib/float.in.h                           |    6 +-
 gnulib/lib/gai_strerror.c                       |    7 +-
 gnulib/lib/getaddrinfo.c                        |   18 +-
 gnulib/lib/getaddrinfo.h                        |  163 --------
 gnulib/lib/getdelim.c                           |   15 +-
 gnulib/lib/gethostname.c                        |   56 +++
 gnulib/lib/intprops.h                           |    2 +-
 gnulib/lib/lstat.c                              |   82 ++++
 gnulib/lib/netdb.in.h                           |  190 +++++++++
 gnulib/lib/netinet_in.in.h                      |    6 +-
 gnulib/lib/perror.c                             |   35 ++
 gnulib/lib/poll.c                               |  439 ++++++++++++++++++---
 gnulib/lib/recv.c                               |   40 ++
 gnulib/lib/send.c                               |   40 ++
 gnulib/lib/setsockopt.c                         |   40 ++
 gnulib/lib/socket.c                             |   43 ++
 gnulib/lib/stdint.in.h                          |    5 +-
 gnulib/lib/stdio-write.c                        |  148 +++++++
 gnulib/lib/stdio.in.h                           |   90 +++++
 gnulib/lib/stdlib.in.h                          |  137 +++++++
 gnulib/lib/strerror.c                           |  273 +++++++++++++
 gnulib/lib/string.in.h                          |   22 +-
 gnulib/lib/sys_select.in.h                      |   37 ++-
 gnulib/lib/sys_socket.in.h                      |  311 ++++++++++++++-
 gnulib/lib/sys_stat.in.h                        |   61 +++-
 gnulib/lib/sys_time.in.h                        |    6 +-
 gnulib/lib/unistd.in.h                          |  219 ++++++++++-
 gnulib/lib/vasnprintf.c                         |   82 ++++-
 gnulib/lib/w32sock.h                            |   62 +++
 gnulib/lib/wchar.in.h                           |   10 +
 gnulib/m4/arpa_inet_h.m4                        |    9 +-
 gnulib/m4/close.m4                              |   25 ++
 gnulib/m4/eoverflow.m4                          |   70 ----
 gnulib/m4/errno_h.m4                            |  113 ++++++
 gnulib/m4/fclose.m4                             |   18 +
 gnulib/m4/getaddrinfo.m4                        |   16 +-
 gnulib/m4/getdelim.m4                           |    1 +
 gnulib/m4/gethostname.m4                        |   21 +
 gnulib/m4/gnulib-cache.m4                       |   11 +-
 gnulib/m4/gnulib-common.m4                      |   12 +-
 gnulib/m4/gnulib-comp.m4                        |  124 ++++++-
 gnulib/m4/include_next.m4                       |   32 ++-
 gnulib/m4/inet_ntop.m4                          |    5 +-
 gnulib/m4/inet_pton.m4                          |    5 +-
 gnulib/m4/lib-link.m4                           |   27 +-
 gnulib/m4/lib-prefix.m4                         |   88 +++--
 gnulib/m4/lock.m4                               |  330 +---------------
 gnulib/m4/lstat.m4                              |   23 +
 gnulib/m4/netdb_h.m4                            |   33 ++
 gnulib/m4/perror.m4                             |   17 +
 gnulib/m4/posix-shell.m4                        |    6 +-
 gnulib/m4/sockets.m4                            |   65 +++
 gnulib/m4/stdio_h.m4                            |  132 ++++---
 gnulib/m4/stdlib_h.m4                           |   43 ++-
 gnulib/m4/strdup.m4                             |   22 +-
 gnulib/m4/strerror.m4                           |   68 ++++
 gnulib/m4/string_h.m4                           |   11 +-
 gnulib/m4/sys_ioctl_h.m4                        |   60 +++
 gnulib/m4/sys_select_h.m4                       |   20 +-
 gnulib/m4/sys_socket_h.m4                       |   63 +++-
 gnulib/m4/sys_stat_h.m4                         |    6 +-
 gnulib/m4/threadlib.m4                          |  312 +++++++++++++++
 gnulib/m4/unistd_h.m4                           |   44 ++-
 gnulib/m4/wchar.m4                              |   25 +-
 gnulib/tests/.cvsignore                         |   13 +-
 gnulib/tests/.gitignore                         |   11 +-
 gnulib/tests/Makefile.am                        |  145 ++++++-
 gnulib/tests/{test-EOVERFLOW.c => accept.c}     |   30 +-
 gnulib/tests/{test-EOVERFLOW.c => bind.c}       |   26 +-
 gnulib/tests/dummy.c                            |   42 --
 gnulib/tests/intprops.h                         |   77 ----
 gnulib/tests/{test-EOVERFLOW.c => ioctl.c}      |   35 ++-
 gnulib/tests/{test-EOVERFLOW.c => listen.c}     |   26 +-
 gnulib/tests/{test-EOVERFLOW.c => sockets.c}    |   39 ++-
 gnulib/tests/{test-EOVERFLOW.c => sockets.h}    |   26 +-
 gnulib/tests/sys_ioctl.in.h                     |   70 ++++
 gnulib/tests/test-EOVERFLOW                     |  Bin 0 -> 6680 bytes
 gnulib/tests/test-errno.c                       |  117 ++++++
 gnulib/tests/test-getaddrinfo.c                 |    2 +-
 gnulib/tests/test-gethostname.c                 |   54 +++
 gnulib/tests/{test-EOVERFLOW.c => test-lstat.c} |   21 +-
 gnulib/tests/{test-EOVERFLOW.c => test-netdb.c} |   19 +-
 gnulib/tests/test-perror.c                      |   34 ++
 gnulib/tests/test-perror.sh                     |   27 ++
 gnulib/tests/test-poll.c                        |  376 +++++++++++++++++
 gnulib/tests/test-sockets.c                     |   44 ++
 gnulib/tests/test-strerror.c                    |   65 +++
 gnulib/tests/test-sys_select.c                  |    5 +-
 gnulib/tests/test-vc-list-files-cvs.sh          |    3 +-
 gnulib/tests/test-vc-list-files-git.sh          |    3 +-
 gnulib/tests/test-wchar.c                       |    6 +-
 gnulib/tests/w32sock.h                          |   62 +++
 106 files changed, 6037 insertions(+), 1079 deletions(-)
 create mode 100644 examples/domain-events/events-c/.cvsignore
 create mode 100644 examples/domain-events/events-c/.gitignore
 create mode 100644 gnulib/lib/alloca.c
 create mode 100644 gnulib/lib/close.c
 create mode 100644 gnulib/lib/connect.c
 create mode 100644 gnulib/lib/errno.in.h
 create mode 100644 gnulib/lib/fclose.c
 delete mode 100644 gnulib/lib/getaddrinfo.h
 create mode 100644 gnulib/lib/gethostname.c
 create mode 100644 gnulib/lib/lstat.c
 create mode 100644 gnulib/lib/netdb.in.h
 create mode 100644 gnulib/lib/perror.c
 create mode 100644 gnulib/lib/recv.c
 create mode 100644 gnulib/lib/send.c
 create mode 100644 gnulib/lib/setsockopt.c
 create mode 100644 gnulib/lib/socket.c
 create mode 100644 gnulib/lib/stdio-write.c
 create mode 100644 gnulib/lib/strerror.c
 create mode 100644 gnulib/lib/w32sock.h
 create mode 100644 gnulib/m4/close.m4
 delete mode 100644 gnulib/m4/eoverflow.m4
 create mode 100644 gnulib/m4/errno_h.m4
 create mode 100644 gnulib/m4/fclose.m4
 create mode 100644 gnulib/m4/gethostname.m4
 create mode 100644 gnulib/m4/lstat.m4
 create mode 100644 gnulib/m4/netdb_h.m4
 create mode 100644 gnulib/m4/perror.m4
 create mode 100644 gnulib/m4/sockets.m4
 create mode 100644 gnulib/m4/strerror.m4
 create mode 100644 gnulib/m4/sys_ioctl_h.m4
 create mode 100644 gnulib/m4/threadlib.m4
 copy gnulib/tests/{test-EOVERFLOW.c => accept.c} (60%)
 copy gnulib/tests/{test-EOVERFLOW.c => bind.c} (63%)
 delete mode 100644 gnulib/tests/dummy.c
 delete mode 100644 gnulib/tests/intprops.h
 copy gnulib/tests/{test-EOVERFLOW.c => ioctl.c} (58%)
 copy gnulib/tests/{test-EOVERFLOW.c => listen.c} (64%)
 copy gnulib/tests/{test-EOVERFLOW.c => sockets.c} (60%)
 copy gnulib/tests/{test-EOVERFLOW.c => sockets.h} (67%)
 create mode 100644 gnulib/tests/sys_ioctl.in.h
 create mode 100755 gnulib/tests/test-EOVERFLOW
 create mode 100644 gnulib/tests/test-errno.c
 create mode 100644 gnulib/tests/test-gethostname.c
 copy gnulib/tests/{test-EOVERFLOW.c => test-lstat.c} (73%)
 rename gnulib/tests/{test-EOVERFLOW.c => test-netdb.c} (68%)
 create mode 100644 gnulib/tests/test-perror.c
 create mode 100755 gnulib/tests/test-perror.sh
 create mode 100644 gnulib/tests/test-poll.c
 create mode 100644 gnulib/tests/test-sockets.c
 create mode 100644 gnulib/tests/test-strerror.c
 create mode 100644 gnulib/tests/w32sock.h

diff --git a/.cvsignore b/.cvsignore
index eded526..ecb8bf0 100644
--- a/.cvsignore
+++ b/.cvsignore
@@ -1,32 +1,37 @@
+*.a
+*.o
+*.orig
+*.rej
+*~
 .git
+ABOUT-NLS
+COPYING
+INSTALL
 Makefile
+Makefile.in
 aclocal.m4
 autom4te.cache
-stamp-h.in
-Makefile.in
-configure
 config.cache
+config.guess
 config.h
 config.h.in
 config.log
+config.rpath
 config.status
-config.guess
 config.sub
-config.rpath
-stamp-h
-stamp-h1
+configure
+coverage
 libtool
-ltconfig
-update.log
+libvirt-*.tar.gz
 libvirt.pc
 libvirt.spec
-mingw32-libvirt.spec
-COPYING
-m4
-ABOUT-NLS
-coverage
-results.log
-libvirt-*.tar.gz
-INSTALL
+ltconfig
 ltmain.sh
+m4
+mingw32-libvirt.spec
 mkinstalldirs
+results.log
+stamp-h
+stamp-h.in
+stamp-h1
+update.log
diff --git a/.gitignore b/.gitignore
index eded526..ecb8bf0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,32 +1,37 @@
+*.a
+*.o
+*.orig
+*.rej
+*~
 .git
+ABOUT-NLS
+COPYING
+INSTALL
 Makefile
+Makefile.in
 aclocal.m4
 autom4te.cache
-stamp-h.in
-Makefile.in
-configure
 config.cache
+config.guess
 config.h
 config.h.in
 config.log
+config.rpath
 config.status
-config.guess
 config.sub
-config.rpath
-stamp-h
-stamp-h1
+configure
+coverage
 libtool
-ltconfig
-update.log
+libvirt-*.tar.gz
 libvirt.pc
 libvirt.spec
-mingw32-libvirt.spec
-COPYING
-m4
-ABOUT-NLS
-coverage
-results.log
-libvirt-*.tar.gz
-INSTALL
+ltconfig
 ltmain.sh
+m4
+mingw32-libvirt.spec
 mkinstalldirs
+results.log
+stamp-h
+stamp-h.in
+stamp-h1
+update.log
diff --git a/examples/domain-events/events-c/.cvsignore b/examples/domain-events/events-c/.cvsignore
new file mode 100644
index 0000000..33cd5d8
--- /dev/null
+++ b/examples/domain-events/events-c/.cvsignore
@@ -0,0 +1,3 @@
+.deps
+.libs
+event-test
diff --git a/examples/domain-events/events-c/.gitignore b/examples/domain-events/events-c/.gitignore
new file mode 100644
index 0000000..33cd5d8
--- /dev/null
+++ b/examples/domain-events/events-c/.gitignore
@@ -0,0 +1,3 @@
+.deps
+.libs
+event-test
diff --git a/gnulib/lib/.cvsignore b/gnulib/lib/.cvsignore
index 2849ca9..3b403bf 100644
--- a/gnulib/lib/.cvsignore
+++ b/gnulib/lib/.cvsignore
@@ -6,12 +6,13 @@ Makefile
 Makefile.in
 alloca.h
 arpa_inet.h
+errno.h
 float.h
+netdb.h
 netinet_in.h
 poll.h
 stdbool.h
 stdint.h
-stdio-impl.h
 stdio.h
 stdlib.h
 string.h
diff --git a/gnulib/lib/.gitignore b/gnulib/lib/.gitignore
index 2849ca9..3b403bf 100644
--- a/gnulib/lib/.gitignore
+++ b/gnulib/lib/.gitignore
@@ -6,12 +6,13 @@ Makefile
 Makefile.in
 alloca.h
 arpa_inet.h
+errno.h
 float.h
+netdb.h
 netinet_in.h
 poll.h
 stdbool.h
 stdint.h
-stdio-impl.h
 stdio.h
 stdlib.h
 string.h
diff --git a/gnulib/lib/Makefile.am b/gnulib/lib/Makefile.am
index 3a7ba31..47d515d 100644
--- a/gnulib/lib/Makefile.am
+++ b/gnulib/lib/Makefile.am
@@ -9,10 +9,11 @@
 # the same distribution terms as the rest of that program.
 #
 # Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gnulib/lib --m4-base=gnulib/m4 --doc-base=doc --aux-dir=build-aux --with-tests --lgpl=2 --libtool --macro-prefix=gl c-ctype getaddrinfo getpass gettext inet_pton mkstemp mktempd physmem poll posix-shell strndup strsep sys_stat useless-if-before-free vasprintf vc-list-files verify
+# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=gnulib/lib --m4-base=gnulib/m4 --doc-base=doc --tests-base=gnulib/tests --aux-dir=build-aux --with-tests --lgpl=2 --libtool --macro-prefix=gl c-ctype close connect getaddrinfo gethostname getpass gettext inet_pton mkstemp mktempd perror physmem poll posix-shell recv send setsockopt socket strerror strndup strsep sys_stat useless-if-before-free vasprintf vc-list-files verify

 AUTOMAKE_OPTIONS = 1.5 gnits

+SUBDIRS =
 noinst_HEADERS =
 noinst_LIBRARIES =
 noinst_LTLIBRARIES =
@@ -35,6 +36,17 @@ libgnu_la_DEPENDENCIES = $(gl_LTLIBOBJS)
 EXTRA_libgnu_la_SOURCES =
 libgnu_la_LDFLAGS = $(AM_LDFLAGS)

+## begin gnulib module alloca
+
+
+EXTRA_DIST += alloca.c
+
+EXTRA_libgnu_la_SOURCES += alloca.c
+
+libgnu_la_LIBADD += @LTALLOCA@
+libgnu_la_DEPENDENCIES += @LTALLOCA@
+## end   gnulib module alloca
+
 ## begin gnulib module alloca-opt

 BUILT_SOURCES += $(ALLOCA_H)
@@ -62,13 +74,15 @@ arpa/inet.h:
 	@MKDIR_P@ arpa
 	rm -f $@-t $@
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
-	  sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \
+	  sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
 	      -e 's|@''NEXT_ARPA_INET_H''@|$(NEXT_ARPA_INET_H)|g' \
 	      -e 's|@''HAVE_ARPA_INET_H''@|$(HAVE_ARPA_INET_H)|g' \
 	      -e 's|@''GNULIB_INET_NTOP''@|$(GNULIB_INET_NTOP)|g' \
 	      -e 's|@''GNULIB_INET_PTON''@|$(GNULIB_INET_PTON)|g' \
 	      -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)' \
 	      < $(srcdir)/arpa_inet.in.h; \
 	} > $@-t
 	mv $@-t $@
@@ -85,6 +99,60 @@ libgnu_la_SOURCES += c-ctype.h c-ctype.c

 ## end   gnulib module c-ctype

+## begin gnulib module close
+
+
+EXTRA_DIST += close.c
+
+EXTRA_libgnu_la_SOURCES += close.c
+
+## end   gnulib module close
+
+## begin gnulib module connect
+
+
+EXTRA_DIST += connect.c w32sock.h
+
+EXTRA_libgnu_la_SOURCES += connect.c
+
+## end   gnulib module connect
+
+## begin gnulib module errno
+
+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 $@
+	{ 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_ERRNO_H''@|$(NEXT_ERRNO_H)|g' \
+	      -e 's|@''EMULTIHOP_HIDDEN''@|$(EMULTIHOP_HIDDEN)|g' \
+	      -e 's|@''EMULTIHOP_VALUE''@|$(EMULTIHOP_VALUE)|g' \
+	      -e 's|@''ENOLINK_HIDDEN''@|$(ENOLINK_HIDDEN)|g' \
+	      -e 's|@''ENOLINK_VALUE''@|$(ENOLINK_VALUE)|g' \
+	      -e 's|@''EOVERFLOW_HIDDEN''@|$(EOVERFLOW_HIDDEN)|g' \
+	      -e 's|@''EOVERFLOW_VALUE''@|$(EOVERFLOW_VALUE)|g' \
+	      < $(srcdir)/errno.in.h; \
+	} > $@-t
+	mv $@-t $@
+MOSTLYCLEANFILES += errno.h errno.h-t
+
+EXTRA_DIST += errno.in.h
+
+## end   gnulib module errno
+
+## begin gnulib module fclose
+
+
+EXTRA_DIST += fclose.c
+
+EXTRA_libgnu_la_SOURCES += fclose.c
+
+## end   gnulib module fclose
+
 ## begin gnulib module float

 BUILT_SOURCES += $(FLOAT_H)
@@ -94,7 +162,8 @@ BUILT_SOURCES += $(FLOAT_H)
 float.h: float.in.h
 	rm -f $@-t $@
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
-	  sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \
+	  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
@@ -117,7 +186,7 @@ EXTRA_libgnu_la_SOURCES += fseeko.c
 ## begin gnulib module getaddrinfo


-EXTRA_DIST += gai_strerror.c getaddrinfo.c getaddrinfo.h
+EXTRA_DIST += gai_strerror.c getaddrinfo.c

 EXTRA_libgnu_la_SOURCES += gai_strerror.c getaddrinfo.c

@@ -132,6 +201,15 @@ EXTRA_libgnu_la_SOURCES += getdelim.c

 ## end   gnulib module getdelim

+## begin gnulib module gethostname
+
+
+EXTRA_DIST += gethostname.c
+
+EXTRA_libgnu_la_SOURCES += gethostname.c
+
+## end   gnulib module gethostname
+
 ## begin gnulib module getline


@@ -206,6 +284,13 @@ EXTRA_libgnu_la_SOURCES += inet_pton.c

 ## end   gnulib module inet_pton

+## begin gnulib module intprops
+
+
+EXTRA_DIST += intprops.h
+
+## end   gnulib module intprops
+
 ## begin gnulib module link-warning

 LINK_WARNING_H=$(top_srcdir)/build-aux/link-warning.h
@@ -223,6 +308,15 @@ EXTRA_libgnu_la_SOURCES += lseek.c

 ## end   gnulib module lseek

+## begin gnulib module lstat
+
+
+EXTRA_DIST += lstat.c
+
+EXTRA_libgnu_la_SOURCES += lstat.c
+
+## end   gnulib module lstat
+
 ## begin gnulib module malloc-posix


@@ -248,6 +342,29 @@ EXTRA_DIST += $(top_srcdir)/build-aux/mktempd

 ## end   gnulib module mktempd

+## begin gnulib module netdb
+
+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 $@
+	{ 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_NETDB_H''@|$(NEXT_NETDB_H)|g' \
+	      -e 's|@''HAVE_NETDB_H''@|$(HAVE_NETDB_H)|g' \
+	      -e 's|@''GNULIB_GETADDRINFO''@|$(GNULIB_GETADDRINFO)|g' \
+	      < $(srcdir)/netdb.in.h; \
+	} > $@-t
+	mv $@-t $@
+MOSTLYCLEANFILES += netdb.h netdb.h-t
+
+EXTRA_DIST += netdb.in.h
+
+## end   gnulib module netdb
+
 ## begin gnulib module netinet_in

 BUILT_SOURCES += $(NETINET_IN_H)
@@ -258,7 +375,8 @@ netinet/in.h: netinet_in.in.h
 	@MKDIR_P@ netinet
 	rm -f $@-t $@
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
-	  sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \
+	  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; \
@@ -271,6 +389,15 @@ EXTRA_DIST += netinet_in.in.h

 ## end   gnulib module netinet_in

+## begin gnulib module perror
+
+
+EXTRA_DIST += perror.c
+
+EXTRA_libgnu_la_SOURCES += perror.c
+
+## end   gnulib module perror
+
 ## begin gnulib module physmem


@@ -323,6 +450,33 @@ EXTRA_libgnu_la_SOURCES += realloc.c

 ## end   gnulib module realloc-posix

+## begin gnulib module recv
+
+
+EXTRA_DIST += recv.c w32sock.h
+
+EXTRA_libgnu_la_SOURCES += recv.c
+
+## end   gnulib module recv
+
+## begin gnulib module send
+
+
+EXTRA_DIST += send.c w32sock.h
+
+EXTRA_libgnu_la_SOURCES += send.c
+
+## end   gnulib module send
+
+## begin gnulib module setsockopt
+
+
+EXTRA_DIST += setsockopt.c w32sock.h
+
+EXTRA_libgnu_la_SOURCES += setsockopt.c
+
+## end   gnulib module setsockopt
+
 ## begin gnulib module size_max

 libgnu_la_SOURCES += size_max.h
@@ -338,6 +492,15 @@ EXTRA_libgnu_la_SOURCES += snprintf.c

 ## end   gnulib module snprintf

+## begin gnulib module socket
+
+
+EXTRA_DIST += socket.c w32sock.h
+
+EXTRA_libgnu_la_SOURCES += socket.c
+
+## end   gnulib module socket
+
 ## begin gnulib module stdbool

 BUILT_SOURCES += $(STDBOOL_H)
@@ -366,7 +529,8 @@ stdint.h: stdint.in.h
 	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' \
+	      -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
 	      -e 's|@''NEXT_STDINT_H''@|$(NEXT_STDINT_H)|g' \
 	      -e 's/@''HAVE_SYS_TYPES_H''@/$(HAVE_SYS_TYPES_H)/g' \
 	      -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \
@@ -405,19 +569,24 @@ BUILT_SOURCES += stdio.h
 stdio.h: stdio.in.h
 	rm -f $@-t $@
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
-	  sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \
+	  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_OBSTACK_PRINTF''@|$(GNULIB_OBSTACK_PRINTF)|g' \
-	      -e 's|@''GNULIB_OBSTACK_PRINTF_POSIX''@|$(GNULIB_OBSTACK_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_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_FOPEN''@|$(GNULIB_FOPEN)|g' \
 	      -e 's|@''GNULIB_FREOPEN''@|$(GNULIB_FREOPEN)|g' \
 	      -e 's|@''GNULIB_FSEEK''@|$(GNULIB_FSEEK)|g' \
@@ -425,8 +594,18 @@ stdio.h: stdio.in.h
 	      -e 's|@''GNULIB_FTELL''@|$(GNULIB_FTELL)|g' \
 	      -e 's|@''GNULIB_FTELLO''@|$(GNULIB_FTELLO)|g' \
 	      -e 's|@''GNULIB_FFLUSH''@|$(GNULIB_FFLUSH)|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_PERROR''@|$(GNULIB_PERROR)|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' \
@@ -439,6 +618,8 @@ stdio.h: stdio.in.h
 	      -e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|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|@''REPLACE_FOPEN''@|$(REPLACE_FOPEN)|g' \
 	      -e 's|@''REPLACE_FREOPEN''@|$(REPLACE_FREOPEN)|g' \
 	      -e 's|@''REPLACE_FSEEKO''@|$(REPLACE_FSEEKO)|g' \
@@ -446,18 +627,20 @@ stdio.h: stdio.in.h
 	      -e 's|@''REPLACE_FTELLO''@|$(REPLACE_FTELLO)|g' \
 	      -e 's|@''REPLACE_FTELL''@|$(REPLACE_FTELL)|g' \
 	      -e 's|@''REPLACE_FFLUSH''@|$(REPLACE_FFLUSH)|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_GETLINE''@|$(REPLACE_GETLINE)|g' \
-	      -e 's|@''HAVE_DECL_OBSTACK_PRINTF''@|$(HAVE_DECL_OBSTACK_PRINTF)|g' \
-	      -e 's|@''REPLACE_OBSTACK_PRINTF''@|$(REPLACE_OBSTACK_PRINTF)|g' \
+	      -e 's|@''REPLACE_PERROR''@|$(REPLACE_PERROR)|g' \
 	      -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
 	      < $(srcdir)/stdio.in.h; \
 	} > $@-t
 	mv $@-t $@
 MOSTLYCLEANFILES += stdio.h stdio.h-t

-EXTRA_DIST += stdio.in.h
+EXTRA_DIST += stdio-write.c stdio.in.h
+
+EXTRA_libgnu_la_SOURCES += stdio-write.c

 ## end   gnulib module stdio

@@ -470,28 +653,41 @@ BUILT_SOURCES += stdlib.h
 stdlib.h: stdlib.in.h
 	rm -f $@-t $@
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
-	  sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \
+	  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|@''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_GETLOADAVG''@|$(GNULIB_GETLOADAVG)|g' \
 	      -e 's|@''GNULIB_GETSUBOPT''@|$(GNULIB_GETSUBOPT)|g' \
 	      -e 's|@''GNULIB_MKDTEMP''@|$(GNULIB_MKDTEMP)|g' \
 	      -e 's|@''GNULIB_MKSTEMP''@|$(GNULIB_MKSTEMP)|g' \
 	      -e 's|@''GNULIB_PUTENV''@|$(GNULIB_PUTENV)|g' \
+	      -e 's|@''GNULIB_RANDOM_R''@|$(GNULIB_RANDOM_R)|g' \
 	      -e 's|@''GNULIB_RPMATCH''@|$(GNULIB_RPMATCH)|g' \
 	      -e 's|@''GNULIB_SETENV''@|$(GNULIB_SETENV)|g' \
 	      -e 's|@''GNULIB_STRTOD''@|$(GNULIB_STRTOD)|g' \
+	      -e 's|@''GNULIB_STRTOLL''@|$(GNULIB_STRTOLL)|g' \
+	      -e 's|@''GNULIB_STRTOULL''@|$(GNULIB_STRTOULL)|g' \
 	      -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_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_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \
 	      -e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \
 	      -e 's|@''HAVE_SETENV''@|$(HAVE_SETENV)|g' \
 	      -e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \
+	      -e 's|@''HAVE_STRTOLL''@|$(HAVE_STRTOLL)|g' \
+	      -e 's|@''HAVE_STRTOULL''@|$(HAVE_STRTOULL)|g' \
+	      -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_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \
 	      -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \
 	      -e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \
@@ -506,14 +702,23 @@ EXTRA_DIST += stdlib.in.h

 ## end   gnulib module stdlib

-## begin gnulib module strdup
+## begin gnulib module strdup-posix


 EXTRA_DIST += strdup.c

 EXTRA_libgnu_la_SOURCES += strdup.c

-## end   gnulib module strdup
+## end   gnulib module strdup-posix
+
+## begin gnulib module strerror
+
+
+EXTRA_DIST += strerror.c
+
+EXTRA_libgnu_la_SOURCES += strerror.c
+
+## end   gnulib module strerror

 ## begin gnulib module string

@@ -524,7 +729,8 @@ BUILT_SOURCES += string.h
 string.h: string.in.h
 	rm -f $@-t $@
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
-	  sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \
+	  sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
 	      -e 's|@''NEXT_STRING_H''@|$(NEXT_STRING_H)|g' \
 	      -e 's|@''GNULIB_MBSLEN''@|$(GNULIB_MBSLEN)|g' \
 	      -e 's|@''GNULIB_MBSNLEN''@|$(GNULIB_MBSNLEN)|g' \
@@ -557,6 +763,7 @@ string.h: string.in.h
 	      -e 's|@''GNULIB_STRTOK_R''@|$(GNULIB_STRTOK_R)|g' \
 	      -e 's|@''GNULIB_STRERROR''@|$(GNULIB_STRERROR)|g' \
 	      -e 's|@''GNULIB_STRSIGNAL''@|$(GNULIB_STRSIGNAL)|g' \
+	      -e 's|@''GNULIB_STRVERSCMP''@|$(GNULIB_STRVERSCMP)|g' \
 	      -e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \
 	      -e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \
 	      -e 's|@''HAVE_DECL_MEMRCHR''@|$(HAVE_DECL_MEMRCHR)|g' \
@@ -574,8 +781,10 @@ string.h: string.in.h
 	      -e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \
 	      -e 's|@''HAVE_DECL_STRERROR''@|$(HAVE_DECL_STRERROR)|g' \
 	      -e 's|@''HAVE_DECL_STRSIGNAL''@|$(HAVE_DECL_STRSIGNAL)|g' \
+	      -e 's|@''HAVE_STRVERSCMP''@|$(HAVE_STRVERSCMP)|g' \
 	      -e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \
 	      -e 's|@''REPLACE_STRCASESTR''@|$(REPLACE_STRCASESTR)|g' \
+	      -e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \
 	      -e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \
 	      -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \
 	      -e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \
@@ -635,9 +844,13 @@ sys/select.h: sys_select.in.h
 	@MKDIR_P@ sys
 	rm -f $@-t $@
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
-	  sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \
+	  sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
 	      -e 's|@''NEXT_SYS_SELECT_H''@|$(NEXT_SYS_SELECT_H)|g' \
 	      -e 's|@''HAVE_SYS_SELECT_H''@|$(HAVE_SYS_SELECT_H)|g' \
+	      -e 's|@''GNULIB_SELECT''@|$(GNULIB_SELECT)|g' \
+	      -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \
+	      -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
 	      < $(srcdir)/sys_select.in.h; \
 	} > $@-t
 	mv $@-t $@
@@ -657,11 +870,28 @@ BUILT_SOURCES += $(SYS_SOCKET_H)
 sys/socket.h: sys_socket.in.h
 	@MKDIR_P@ sys
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
-	  sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \
+	  sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
 	      -e 's|@''NEXT_SYS_SOCKET_H''@|$(NEXT_SYS_SOCKET_H)|g' \
 	      -e 's|@''HAVE_SYS_SOCKET_H''@|$(HAVE_SYS_SOCKET_H)|g' \
+	      -e 's|@''GNULIB_CLOSE''@|$(GNULIB_CLOSE)|g' \
+	      -e 's|@''GNULIB_SOCKET''@|$(GNULIB_SOCKET)|g' \
+	      -e 's|@''GNULIB_CONNECT''@|$(GNULIB_CONNECT)|g' \
+	      -e 's|@''GNULIB_ACCEPT''@|$(GNULIB_ACCEPT)|g' \
+	      -e 's|@''GNULIB_BIND''@|$(GNULIB_BIND)|g' \
+	      -e 's|@''GNULIB_GETPEERNAME''@|$(GNULIB_GETPEERNAME)|g' \
+	      -e 's|@''GNULIB_GETSOCKNAME''@|$(GNULIB_GETSOCKNAME)|g' \
+	      -e 's|@''GNULIB_GETSOCKOPT''@|$(GNULIB_GETSOCKOPT)|g' \
+	      -e 's|@''GNULIB_LISTEN''@|$(GNULIB_LISTEN)|g' \
+	      -e 's|@''GNULIB_RECV''@|$(GNULIB_RECV)|g' \
+	      -e 's|@''GNULIB_SEND''@|$(GNULIB_SEND)|g' \
+	      -e 's|@''GNULIB_RECVFROM''@|$(GNULIB_RECVFROM)|g' \
+	      -e 's|@''GNULIB_SENDTO''@|$(GNULIB_SENDTO)|g' \
+	      -e 's|@''GNULIB_SETSOCKOPT''@|$(GNULIB_SETSOCKOPT)|g' \
+	      -e 's|@''GNULIB_SHUTDOWN''@|$(GNULIB_SHUTDOWN)|g' \
 	      -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \
 	      -e 's|@''HAVE_WS2TCPIP_H''@|$(HAVE_WS2TCPIP_H)|g' \
+	      -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
 	      < $(srcdir)/sys_socket.in.h; \
 	} > $@-t
 	mv -f $@-t $@
@@ -682,10 +912,16 @@ sys/stat.h: sys_stat.in.h
 	@MKDIR_P@ sys
 	rm -f $@-t $@
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
-	  sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \
+	  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_LCHMOD''@|$(GNULIB_LCHMOD)|g' \
+	      -e 's|@''GNULIB_LSTAT''@|$(GNULIB_LSTAT)|g' \
+	      -e 's|@''HAVE_LCHMOD''@|$(HAVE_LCHMOD)|g' \
 	      -e 's|@''HAVE_LSTAT''@|$(HAVE_LSTAT)|g' \
+	      -e 's|@''REPLACE_LSTAT''@|$(REPLACE_LSTAT)|g' \
 	      -e 's|@''REPLACE_MKDIR''@|$(REPLACE_MKDIR)|g' \
+	      -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
 	      < $(srcdir)/sys_stat.in.h; \
 	} > $@-t
 	mv $@-t $@
@@ -707,7 +943,8 @@ sys/time.h: sys_time.in.h
 	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' \
+	      -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
 	      -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' \
@@ -739,23 +976,39 @@ unistd.h: unistd.in.h
 	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' \
+	      -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
 	      -e 's|@''NEXT_UNISTD_H''@|$(NEXT_UNISTD_H)|g' \
 	      -e 's|@''GNULIB_CHOWN''@|$(GNULIB_CHOWN)|g' \
+	      -e 's|@''GNULIB_CLOSE''@|$(GNULIB_CLOSE)|g' \
 	      -e 's|@''GNULIB_DUP2''@|$(GNULIB_DUP2)|g' \
 	      -e 's|@''GNULIB_ENVIRON''@|$(GNULIB_ENVIRON)|g' \
+	      -e 's|@''GNULIB_EUIDACCESS''@|$(GNULIB_EUIDACCESS)|g' \
 	      -e 's|@''GNULIB_FCHDIR''@|$(GNULIB_FCHDIR)|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_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_LSEEK''@|$(GNULIB_LSEEK)|g' \
 	      -e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \
 	      -e 's|@''GNULIB_SLEEP''@|$(GNULIB_SLEEP)|g' \
+	      -e 's|@''GNULIB_UNISTD_H_SIGPIPE''@|$(GNULIB_UNISTD_H_SIGPIPE)|g' \
+	      -e 's|@''GNULIB_WRITE''@|$(GNULIB_WRITE)|g' \
 	      -e 's|@''HAVE_DUP2''@|$(HAVE_DUP2)|g' \
+	      -e 's|@''HAVE_EUIDACCESS''@|$(HAVE_EUIDACCESS)|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_GETHOSTNAME''@|$(HAVE_GETHOSTNAME)|g' \
 	      -e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \
+	      -e 's|@''HAVE_GETUSERSHELL''@|$(HAVE_GETUSERSHELL)|g' \
 	      -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \
 	      -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \
 	      -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \
@@ -763,11 +1016,15 @@ unistd.h: unistd.in.h
 	      -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_FCHDIR''@|$(REPLACE_FCHDIR)|g' \
 	      -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \
 	      -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \
 	      -e 's|@''REPLACE_LCHOWN''@|$(REPLACE_LCHOWN)|g' \
 	      -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \
+	      -e 's|@''REPLACE_WRITE''@|$(REPLACE_WRITE)|g' \
+	      -e 's|@''UNISTD_H_HAVE_WINSOCK2_H''@|$(UNISTD_H_HAVE_WINSOCK2_H)|g' \
+	      -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
 	      < $(srcdir)/unistd.in.h; \
 	} > $@-t
 	mv $@-t $@
@@ -824,10 +1081,12 @@ BUILT_SOURCES += $(WCHAR_H)
 wchar.h: wchar.in.h
 	rm -f $@-t $@
 	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
-	  sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \
+	  sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
 	      -e 's|@''NEXT_WCHAR_H''@|$(NEXT_WCHAR_H)|g' \
 	      -e 's/@''HAVE_WCHAR_H''@/$(HAVE_WCHAR_H)/g' \
 	      -e 's|@''GNULIB_WCWIDTH''@|$(GNULIB_WCWIDTH)|g' \
+	      -e 's/@''HAVE_WINT_T''@/$(HAVE_WINT_T)/g' \
 	      -e 's|@''HAVE_DECL_WCWIDTH''@|$(HAVE_DECL_WCWIDTH)|g' \
 	      -e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \
 	      -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
diff --git a/gnulib/lib/alloca.c b/gnulib/lib/alloca.c
new file mode 100644
index 0000000..f9e1ce7
--- /dev/null
+++ b/gnulib/lib/alloca.c
@@ -0,0 +1,489 @@
+/* alloca.c -- allocate automatically reclaimed memory
+   (Mostly) portable public-domain implementation -- D A Gwyn
+
+   This implementation of the PWB library alloca function,
+   which is used to allocate space off the run-time stack so
+   that it is automatically reclaimed upon procedure exit,
+   was inspired by discussions with J. Q. Johnson of Cornell.
+   J.Otto Tennant <jot@xxxxxxxx> contributed the Cray support.
+
+   There are some preprocessor constants that can
+   be defined when compiling for your specific system, for
+   improved efficiency; however, the defaults should be okay.
+
+   The general concept of this implementation is to keep
+   track of all alloca-allocated blocks, and reclaim any
+   that are found to be deeper in the stack than the current
+   invocation.  This heuristic does not reclaim storage as
+   soon as it becomes invalid, but it will do so eventually.
+
+   As a special case, alloca(0) reclaims storage without
+   allocating any.  It is a good idea to use alloca(0) in
+   your main control loop, etc. to force garbage collection.  */
+
+#include <config.h>
+
+#include <alloca.h>
+
+#include <string.h>
+#include <stdlib.h>
+
+#ifdef emacs
+# include "lisp.h"
+# include "blockinput.h"
+# ifdef EMACS_FREE
+#  undef free
+#  define free EMACS_FREE
+# endif
+#else
+# define memory_full() abort ()
+#endif
+
+/* If compiling with GCC 2, this file's not needed.  */
+#if !defined (__GNUC__) || __GNUC__ < 2
+
+/* If someone has defined alloca as a macro,
+   there must be some other way alloca is supposed to work.  */
+# ifndef alloca
+
+#  ifdef emacs
+#   ifdef static
+/* actually, only want this if static is defined as ""
+   -- this is for usg, in which emacs must undefine static
+   in order to make unexec workable
+   */
+#    ifndef STACK_DIRECTION
+you
+lose
+-- must know STACK_DIRECTION at compile-time
+/* Using #error here is not wise since this file should work for
+   old and obscure compilers.  */
+#    endif /* STACK_DIRECTION undefined */
+#   endif /* static */
+#  endif /* emacs */
+
+/* If your stack is a linked list of frames, you have to
+   provide an "address metric" ADDRESS_FUNCTION macro.  */
+
+#  if defined (CRAY) && defined (CRAY_STACKSEG_END)
+long i00afunc ();
+#   define ADDRESS_FUNCTION(arg) (char *) i00afunc (&(arg))
+#  else
+#   define ADDRESS_FUNCTION(arg) &(arg)
+#  endif
+
+/* Define STACK_DIRECTION if you know the direction of stack
+   growth for your system; otherwise it will be automatically
+   deduced at run-time.
+
+   STACK_DIRECTION > 0 => grows toward higher addresses
+   STACK_DIRECTION < 0 => grows toward lower addresses
+   STACK_DIRECTION = 0 => direction of growth unknown  */
+
+#  ifndef STACK_DIRECTION
+#   define STACK_DIRECTION	0	/* Direction unknown.  */
+#  endif
+
+#  if STACK_DIRECTION != 0
+
+#   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 void
+find_stack_direction (void)
+{
+  static char *addr = NULL;	/* Address of first `dummy', once known.  */
+  auto char dummy;		/* To get stack address.  */
+
+  if (addr == NULL)
+    {				/* Initial entry.  */
+      addr = ADDRESS_FUNCTION (dummy);
+
+      find_stack_direction ();	/* Recurse once.  */
+    }
+  else
+    {
+      /* Second entry.  */
+      if (ADDRESS_FUNCTION (dummy) > addr)
+	stack_dir = 1;		/* Stack grew upward.  */
+      else
+	stack_dir = -1;		/* Stack grew downward.  */
+    }
+}
+
+#  endif /* STACK_DIRECTION == 0 */
+
+/* An "alloca header" is used to:
+   (a) chain together all alloca'ed blocks;
+   (b) keep track of stack depth.
+
+   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)
+#  endif
+
+typedef union hdr
+{
+  char align[ALIGN_SIZE];	/* To force sizeof(header).  */
+  struct
+    {
+      union hdr *next;		/* For chaining headers.  */
+      char *deep;		/* For stack depth measure.  */
+    } h;
+} 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
+   the procedure that called alloca.  Originally, this space
+   was supposed to be taken from the current stack frame of the
+   caller, but that method cannot be made to work for some
+   implementations of C, for example under Gould's UTX/32.  */
+
+void *
+alloca (size_t size)
+{
+  auto char probe;		/* Probes stack depth: */
+  register char *depth = ADDRESS_FUNCTION (probe);
+
+#  if STACK_DIRECTION == 0
+  if (STACK_DIR == 0)		/* Unknown growth direction.  */
+    find_stack_direction ();
+#  endif
+
+  /* Reclaim garbage, defined as all alloca'd storage that
+     was allocated from deeper in the stack than currently.  */
+
+  {
+    register header *hp;	/* Traverses linked list.  */
+
+#  ifdef emacs
+    BLOCK_INPUT;
+#  endif
+
+    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;
+
+	  free (hp);		/* Collect garbage.  */
+
+	  hp = np;		/* -> next header.  */
+	}
+      else
+	break;			/* Rest are not deeper.  */
+
+    last_alloca_header = hp;	/* -> last valid storage.  */
+
+#  ifdef emacs
+    UNBLOCK_INPUT;
+#  endif
+  }
+
+  if (size == 0)
+    return NULL;		/* No allocation required.  */
+
+  /* Allocate combined header + user data storage.  */
+
+  {
+    /* Address of header.  */
+    register header *new;
+
+    size_t combined_size = sizeof (header) + size;
+    if (combined_size < sizeof (header))
+      memory_full ();
+
+    new = malloc (combined_size);
+
+    if (! new)
+      memory_full ();
+
+    new->h.next = last_alloca_header;
+    new->h.deep = depth;
+
+    last_alloca_header = new;
+
+    /* User storage begins just after header.  */
+
+    return (void *) (new + 1);
+  }
+}
+
+#  if defined (CRAY) && defined (CRAY_STACKSEG_END)
+
+#   ifdef DEBUG_I00AFUNC
+#    include <stdio.h>
+#   endif
+
+#   ifndef CRAY_STACK
+#    define CRAY_STACK
+#    ifndef CRAY2
+/* 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).  */
+  };
+
+/* The stack segment linkage control information occurs at
+   the high-address end of a stack segment.  (The stack
+   grows from low addresses to high addresses.)  The initial
+   part of the stack segment linkage control information is
+   0200 (octal) words.  This provides for register storage
+   for the routine which overflows the stack.  */
+
+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:32;
+    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 ssa0;
+    long ssa1;
+    long ssa2;
+    long ssa3;
+    long ssa4;
+    long ssa5;
+    long ssa6;
+    long ssa7;
+    long sss0;
+    long sss1;
+    long sss2;
+    long sss3;
+    long sss4;
+    long sss5;
+    long sss6;
+    long sss7;
+  };
+
+#    else /* CRAY2 */
+/* The following structure defines the vector of words
+   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.  */
+  };
+
+/* The following structure describes the data structure which trails
+   any stack segment.  I think that the description in 'asdef' is
+   out of date.  I only describe the parts that I am sure about.  */
+
+struct stk_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 unknown5;
+    long unknown6;
+    long unknown7;
+    long unknown8;
+    long unknown9;
+    long unknown10;
+    long unknown11;
+    long unknown12;
+    long unknown13;
+    long unknown14;
+  };
+
+#    endif /* CRAY2 */
+#   endif /* not CRAY_STACK */
+
+#   ifdef CRAY2
+/* Determine a "stack measure" for an arbitrary ADDRESS.
+   I doubt that "lint" will like this much.  */
+
+static long
+i00afunc (long *address)
+{
+  struct stk_stat status;
+  struct stk_trailer *trailer;
+  long *block, size;
+  long result = 0;
+
+  /* We want to iterate through all of the segments.  The first
+     step is to get the stack status structure.  We could do this
+     more quickly and more directly, perhaps, by referencing the
+     $LM00 common block, but I know that this works.  */
+
+  STKSTAT (&status);
+
+  /* Set up the iteration.  */
+
+  trailer = (struct stk_trailer *) (status.current_address
+				    + status.current_size
+				    - 15);
+
+  /* There must be at least one stack segment.  Therefore it is
+     a fatal error if "trailer" is null.  */
+
+  if (trailer == 0)
+    abort ();
+
+  /* Discard segments that do not contain our argument address.  */
+
+  while (trailer != 0)
+    {
+      block = (long *) trailer->this_address;
+      size = trailer->this_size;
+      if (block == 0 || size == 0)
+	abort ();
+      trailer = (struct stk_trailer *) trailer->link;
+      if ((block <= address) && (address < (block + size)))
+	break;
+    }
+
+  /* Set the result to the offset in this segment and add the sizes
+     of all predecessor segments.  */
+
+  result = address - block;
+
+  if (trailer == 0)
+    {
+      return result;
+    }
+
+  do
+    {
+      if (trailer->this_size <= 0)
+	abort ();
+      result += trailer->this_size;
+      trailer = (struct stk_trailer *) trailer->link;
+    }
+  while (trailer != 0);
+
+  /* We are done.  Note that if you present a bogus address (one
+     not in any segment), you will get a different number back, formed
+     from subtracting the address of the first block.  This is probably
+     not what you want.  */
+
+  return (result);
+}
+
+#   else /* not CRAY2 */
+/* Stack address function for a CRAY-1, CRAY X-MP, or CRAY Y-MP.
+   Determine the number of the cell within the stack,
+   given the address of the cell.  The purpose of this
+   routine is to linearize, in some sense, stack addresses
+   for alloca.  */
+
+static long
+i00afunc (long address)
+{
+  long stkl = 0;
+
+  long size, pseg, this_segment, stack;
+  long result = 0;
+
+  struct stack_segment_linkage *ssptr;
+
+  /* Register B67 contains the address of the end of the
+     current stack segment.  If you (as a subprogram) store
+     your registers on the stack and find that you are past
+     the contents of B67, you have overflowed the segment.
+
+     B67 also points to the stack segment linkage control
+     area, which is what we are really interested in.  */
+
+  stkl = CRAY_STACKSEG_END ();
+  ssptr = (struct stack_segment_linkage *) stkl;
+
+  /* If one subtracts 'size' from the end of the segment,
+     one has the address of the first word of the segment.
+
+     If this is not the first segment, 'pseg' will be
+     nonzero.  */
+
+  pseg = ssptr->sspseg;
+  size = ssptr->sssize;
+
+  this_segment = stkl - size;
+
+  /* It is possible that calling this routine itself caused
+     a stack overflow.  Discard stack segments which do not
+     contain the target address.  */
+
+  while (!(this_segment <= address && address <= stkl))
+    {
+#    ifdef DEBUG_I00AFUNC
+      fprintf (stderr, "%011o %011o %011o\n", this_segment, address, stkl);
+#    endif
+      if (pseg == 0)
+	break;
+      stkl = stkl - pseg;
+      ssptr = (struct stack_segment_linkage *) stkl;
+      size = ssptr->sssize;
+      pseg = ssptr->sspseg;
+      this_segment = stkl - size;
+    }
+
+  result = address - this_segment;
+
+  /* If you subtract pseg from the current end of the stack,
+     you get the address of the previous stack segment's end.
+     This seems a little convoluted to me, but I'll bet you save
+     a cycle somewhere.  */
+
+  while (pseg != 0)
+    {
+#    ifdef DEBUG_I00AFUNC
+      fprintf (stderr, "%011o %011o\n", pseg, size);
+#    endif
+      stkl = stkl - pseg;
+      ssptr = (struct stack_segment_linkage *) stkl;
+      size = ssptr->sssize;
+      pseg = ssptr->sspseg;
+      result += size;
+    }
+  return (result);
+}
+
+#   endif /* not CRAY2 */
+#  endif /* CRAY */
+
+# endif /* no alloca */
+#endif /* not GCC version 2.1 */
diff --git a/gnulib/lib/arpa_inet.in.h b/gnulib/lib/arpa_inet.in.h
index 1dc7e90..ec5ae72 100644
--- a/gnulib/lib/arpa_inet.in.h
+++ b/gnulib/lib/arpa_inet.in.h
@@ -24,6 +24,10 @@

 #if @HAVE_ARPA_INET_H@

+# if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+# endif
+
 /* The include_next requires a split double-inclusion guard.  */
 # @INCLUDE_NEXT@ @NEXT_ARPA_INET_H@

@@ -32,6 +36,8 @@
 #ifndef _GL_ARPA_INET_H
 #define _GL_ARPA_INET_H

+/* The definition of GL_LINK_WARNING is copied here.  */
+
 #if @GNULIB_INET_NTOP@
 # if !@HAVE_DECL_INET_NTOP@
 /* Converts an internet address from internal format to a printable,
diff --git a/gnulib/lib/c-ctype.h b/gnulib/lib/c-ctype.h
index 1bd76a0..2bce9d1 100644
--- a/gnulib/lib/c-ctype.h
+++ b/gnulib/lib/c-ctype.h
@@ -5,7 +5,7 @@
    <ctype.h> functions' behaviour depends on the current locale set via
    setlocale.

-   Copyright (C) 2000-2003, 2006 Free Software Foundation, Inc.
+   Copyright (C) 2000-2003, 2006, 2008 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
@@ -103,6 +103,21 @@ extern "C" {

 /* 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);
diff --git a/gnulib/lib/close.c b/gnulib/lib/close.c
new file mode 100644
index 0000000..14243e4
--- /dev/null
+++ b/gnulib/lib/close.c
@@ -0,0 +1,82 @@
+/* close replacement.
+   Copyright (C) 2008 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.1 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 <unistd.h>
+
+#if GNULIB_SYS_SOCKET
+# define WIN32_LEAN_AND_MEAN
+# include <sys/socket.h>
+#endif
+
+#if HAVE__GL_CLOSE_FD_MAYBE_SOCKET
+
+/* Get set_winsock_errno, FD_TO_SOCKET etc. */
+#include "w32sock.h"
+
+static int
+_gl_close_fd_maybe_socket (int fd)
+{
+  SOCKET sock = FD_TO_SOCKET (fd);
+  WSANETWORKEVENTS ev;
+
+  ev.lNetworkEvents = 0xDEADBEEF;
+  WSAEnumNetworkEvents (sock, NULL, &ev);
+  if (ev.lNetworkEvents != 0xDEADBEEF)
+    {
+      /* 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
+    return _close (fd);
+}
+#endif
+
+/* Override close() to call into other gnulib modules.  */
+
+int
+rpl_close (int fd)
+#undef close
+{
+#if HAVE__GL_CLOSE_FD_MAYBE_SOCKET
+  int retval = _gl_close_fd_maybe_socket (fd);
+#else
+  int retval = close (fd);
+#endif
+
+#ifdef FCHDIR_REPLACEMENT
+  if (retval >= 0)
+    _gl_unregister_fd (fd);
+#endif
+
+  return retval;
+}
diff --git a/gnulib/lib/connect.c b/gnulib/lib/connect.c
new file mode 100644
index 0000000..54aa2f5
--- /dev/null
+++ b/gnulib/lib/connect.c
@@ -0,0 +1,47 @@
+/* connect.c --- wrappers for Windows connect function
+
+   Copyright (C) 2008 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.1 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 Paolo Bonzini */
+
+#include <config.h>
+
+#define WIN32_LEAN_AND_MEAN
+/* Get winsock2.h. */
+#include <sys/socket.h>
+
+/* Get set_winsock_errno, FD_TO_SOCKET etc. */
+#include "w32sock.h"
+
+#undef connect
+
+int
+rpl_connect (int fd, struct sockaddr *sockaddr, int len)
+{
+  SOCKET sock = FD_TO_SOCKET (fd);
+  int r = connect (sock, sockaddr, len);
+  if (r < 0)
+    {
+      /* EINPROGRESS is not returned by WinSock 2.0; for backwards
+	 compatibility, connect(2) uses EWOULDBLOCK.  */
+      if (WSAGetLastError () == WSAEWOULDBLOCK)
+	WSASetLastError (WSAEINPROGRESS);
+
+      set_winsock_errno ();
+    }
+
+  return r;
+}
diff --git a/gnulib/lib/errno.in.h b/gnulib/lib/errno.in.h
new file mode 100644
index 0000000..1dd67a1
--- /dev/null
+++ b/gnulib/lib/errno.in.h
@@ -0,0 +1,155 @@
+/* A POSIX-like <errno.h>.
+
+   Copyright (C) 2008 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.1, 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.  */
+
+#ifndef _GL_ERRNO_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+
+/* The include_next requires a split double-inclusion guard.  */
+#@INCLUDE_NEXT@ @NEXT_ERRNO_H@
+
+#ifndef _GL_ERRNO_H
+#define _GL_ERRNO_H
+
+
+/* On native Windows platforms, many macros are not defined.  */
+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+
+/* POSIX says that EAGAIN and EWOULDBLOCK may have the same value.  */
+#  define EWOULDBLOCK     EAGAIN
+
+/* Values >= 100 seem safe to use.  */
+#  define ETXTBSY   100
+#  define GNULIB_defined_ETXTBSY 1
+
+/* These are intentionally the same values as the WSA* error numbers, defined
+   in <winsock2.h>.  */
+#  define EINPROGRESS     10036
+#  define EALREADY        10037
+#  define ENOTSOCK        10038
+#  define EDESTADDRREQ    10039
+#  define EMSGSIZE        10040
+#  define EPROTOTYPE      10041
+#  define ENOPROTOOPT     10042
+#  define EPROTONOSUPPORT 10043
+#  define ESOCKTNOSUPPORT 10044  /* not required by POSIX */
+#  define EOPNOTSUPP      10045
+#  define EPFNOSUPPORT    10046  /* not required by POSIX */
+#  define EAFNOSUPPORT    10047
+#  define EADDRINUSE      10048
+#  define EADDRNOTAVAIL   10049
+#  define ENETDOWN        10050
+#  define ENETUNREACH     10051
+#  define ENETRESET       10052
+#  define ECONNABORTED    10053
+#  define ECONNRESET      10054
+#  define ENOBUFS         10055
+#  define EISCONN         10056
+#  define ENOTCONN        10057
+#  define ESHUTDOWN       10058  /* not required by POSIX */
+#  define ETOOMANYREFS    10059  /* not required by POSIX */
+#  define ETIMEDOUT       10060
+#  define ECONNREFUSED    10061
+#  define ELOOP           10062
+#  define EHOSTDOWN       10064  /* not required by POSIX */
+#  define EHOSTUNREACH    10065
+#  define EPROCLIM        10067  /* not required by POSIX */
+#  define EUSERS          10068  /* not required by POSIX */
+#  define EDQUOT          10069
+#  define ESTALE          10070
+#  define EREMOTE         10071  /* not required by POSIX */
+#  define GNULIB_defined_ESOCK 1
+
+# endif
+
+
+/* On OSF/1 5.1, when _XOPEN_SOURCE_EXTENDED is not defined, the macros
+   EMULTIHOP, ENOLINK, EOVERFLOW are not defined.  */
+# if @EMULTIHOP_HIDDEN@
+#  define EMULTIHOP @EMULTIHOP_VALUE@
+#  define GNULIB_defined_EMULTIHOP 1
+# endif
+# if @ENOLINK_HIDDEN@
+#  define ENOLINK   @ENOLINK_VALUE@
+#  define GNULIB_defined_ENOLINK 1
+# endif
+# if @EOVERFLOW_HIDDEN@
+#  define EOVERFLOW @EOVERFLOW_VALUE@
+#  define GNULIB_defined_EOVERFLOW 1
+# endif
+
+
+/* On OpenBSD 4.0 and on native Windows, the macros ENOMSG, EIDRM, ENOLINK,
+   EPROTO, EMULTIHOP, EBADMSG, EOVERFLOW, ENOTSUP, ECANCELED are not defined.
+   Define them here.  Values >= 2000 seem safe to use: Solaris ESTALE = 151,
+   HP-UX EWOULDBLOCK = 246, IRIX EDQUOT = 1133.
+
+   Note: When one of these systems defines some of these macros some day,
+   binaries will have to be recompiled so that they recognizes the new
+   errno values from the system.  */
+
+# ifndef ENOMSG
+#  define ENOMSG    2000
+#  define GNULIB_defined_ENOMSG 1
+# endif
+
+# ifndef EIDRM
+#  define EIDRM     2001
+#  define GNULIB_defined_EIDRM 1
+# endif
+
+# ifndef ENOLINK
+#  define ENOLINK   2002
+#  define GNULIB_defined_ENOLINK 1
+# endif
+
+# ifndef EPROTO
+#  define EPROTO    2003
+#  define GNULIB_defined_EPROTO 1
+# endif
+
+# ifndef EMULTIHOP
+#  define EMULTIHOP 2004
+#  define GNULIB_defined_EMULTIHOP 1
+# endif
+
+# ifndef EBADMSG
+#  define EBADMSG   2005
+#  define GNULIB_defined_EBADMSG 1
+# endif
+
+# ifndef EOVERFLOW
+#  define EOVERFLOW 2006
+#  define GNULIB_defined_EOVERFLOW 1
+# endif
+
+# ifndef ENOTSUP
+#  define ENOTSUP   2007
+#  define GNULIB_defined_ENOTSUP 1
+# endif
+
+# ifndef ECANCELED
+#  define ECANCELED 2008
+#  define GNULIB_defined_ECANCELED 1
+# endif
+
+
+#endif /* _GL_ERRNO_H */
+#endif /* _GL_ERRNO_H */
diff --git a/gnulib/lib/fclose.c b/gnulib/lib/fclose.c
new file mode 100644
index 0000000..cab8610
--- /dev/null
+++ b/gnulib/lib/fclose.c
@@ -0,0 +1,47 @@
+/* fclose replacement.
+   Copyright (C) 2008 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.1 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 <stdio.h>
+
+#include <errno.h>
+#include <unistd.h>
+
+/* Override fclose() to call the overridden close().  */
+
+int
+rpl_fclose (FILE *fp)
+#undef fclose
+{
+  int saved_errno = 0;
+
+  if (fflush (fp))
+    saved_errno = errno;
+
+  if (close (fileno (fp)) < 0 && saved_errno == 0)
+    saved_errno = errno;
+
+  fclose (fp); /* will fail with errno = EBADF */
+
+  if (saved_errno != 0)
+    {
+      errno = saved_errno;
+      return EOF;
+    }
+  return 0;
+}
diff --git a/gnulib/lib/float.in.h b/gnulib/lib/float.in.h
index 1984fd7..1600d05 100644
--- a/gnulib/lib/float.in.h
+++ b/gnulib/lib/float.in.h
@@ -1,6 +1,6 @@
 /* A correct <float.h>.

-   Copyright (C) 2007 Free Software Foundation, Inc.
+   Copyright (C) 2007-2008 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
@@ -17,6 +17,10 @@

 #ifndef _GL_FLOAT_H

+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+
 /* The include_next requires a split double-inclusion guard.  */
 #@INCLUDE_NEXT@ @NEXT_FLOAT_H@

diff --git a/gnulib/lib/gai_strerror.c b/gnulib/lib/gai_strerror.c
index 496ff58..51d39d7 100644
--- a/gnulib/lib/gai_strerror.c
+++ b/gnulib/lib/gai_strerror.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 2001, 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 2001, 2002, 2004, 2005, 2006, 2008 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Philip Blundell <pjb27@xxxxxxxxx>, 1997.

@@ -18,13 +18,10 @@

 #ifndef _LIBC
 # include <config.h>
-# include "getaddrinfo.h"
 #endif

 #include <stdio.h>
-#ifdef HAVE_NETDB_H
-# include <netdb.h>
-#endif
+#include <netdb.h>

 #ifdef _LIBC
 # include <libintl.h>
diff --git a/gnulib/lib/getaddrinfo.c b/gnulib/lib/getaddrinfo.c
index 6066a8e..84b6af6 100644
--- a/gnulib/lib/getaddrinfo.c
+++ b/gnulib/lib/getaddrinfo.c
@@ -19,7 +19,7 @@

 #include <config.h>

-#include "getaddrinfo.h"
+#include <netdb.h>

 #if HAVE_NETINET_IN_H
 # include <netinet/in.h>
@@ -301,6 +301,22 @@ getaddrinfo (const char *restrict nodename,
   tmp->ai_addr->sa_family = he->h_addrtype;
   tmp->ai_family = he->h_addrtype;

+#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
+  switch (he->h_addrtype)
+    {
+#if HAVE_IPV4
+    case AF_INET:
+      tmp->ai_addr->sa_len = sizeof (struct sockaddr_in);
+      break;
+#endif
+#if HAVE_IPV6
+    case AF_INET6:
+      tmp->ai_addr->sa_len = sizeof (struct sockaddr_in6);
+      break;
+#endif
+    }
+#endif
+
   /* FIXME: If more than one address, create linked list of addrinfo's. */

   *res = tmp;
diff --git a/gnulib/lib/getaddrinfo.h b/gnulib/lib/getaddrinfo.h
deleted file mode 100644
index 12f473b..0000000
--- a/gnulib/lib/getaddrinfo.h
+++ /dev/null
@@ -1,163 +0,0 @@
-/* Get address information.
-   Copyright (C) 1996-2002, 2003, 2004, 2005, 2006, 2008
-                 Free Software Foundation, Inc.
-   Contributed by Simon Josefsson <simon@xxxxxxxxxxxxx>.
-
-   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.1, 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.  */
-
-#ifndef GETADDRINFO_H
-#define GETADDRINFO_H
-
-/* sys/socket.h in i386-unknown-freebsd4.10 and
-   powerpc-apple-darwin5.5 require sys/types.h, so include it first.
-   Then we'll also get 'socklen_t' and 'struct sockaddr' which are
-   used below. */
-#include <sys/types.h>
-/* Get all getaddrinfo related declarations, if available.  */
-#include <sys/socket.h>
-#ifdef HAVE_NETDB_H
-# include <netdb.h>
-#endif
-
-#ifndef HAVE_STRUCT_ADDRINFO
-
-/* 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.  */
-};
-#endif
-
-/* Possible values for `ai_flags' field in `addrinfo' structure.  */
-#ifndef AI_PASSIVE
-# define AI_PASSIVE	0x0001	/* Socket address is intended for `bind'.  */
-#endif
-#ifndef AI_CANONNAME
-# define AI_CANONNAME	0x0002	/* Request for canonical name.  */
-#endif
-#ifndef AI_NUMERICSERV
-# define AI_NUMERICSERV	0x0400	/* Don't use name resolution.  */
-#endif
-
-#if 0
-/* The commented out definitions below are not yet implemented in the
-   GNULIB getaddrinfo() replacement, so are not yet needed and may, in fact,
-   cause conflicts on systems with a getaddrinfo() function which does not
-   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..  */
-#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.  */
-#endif
-
-/* Since EAI_NODATA is deprecated by RFC3493, some systems (at least
-   FreeBSD, which does define EAI_BADFLAGS) have removed the definition
-   in favor of EAI_NONAME.  */
-#if !defined EAI_NODATA && defined EAI_NONAME
-# define EAI_NODATA EAI_NONAME
-#endif
-
-#ifndef EAI_OVERFLOW
-/* Not defined on mingw32. */
-# 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.  */
-#endif
-#ifndef EAI_SYSTEM
-/* Not defined on mingw32. */
-# define EAI_SYSTEM	  -11	/* System error returned in `errno'.  */
-#endif
-
-#ifdef __USE_GNU
-# 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.  */
-# endif
-#endif
-
-#if !HAVE_DECL_GETADDRINFO
-/* Translate name of a service location and/or a service name to set of
-   socket addresses.
-   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);
-#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);
-#endif
-
-#if !HAVE_DECL_GAI_STRERROR
-/* Convert error return from getaddrinfo() to a string.
-   For more details, see the POSIX:2001 specification
-   <http://www.opengroup.org/susv3xsh/gai_strerror.html>.  */
-extern const char *gai_strerror (int ecode);
-#endif
-
-#if !HAVE_DECL_GETNAMEINFO
-/* Convert socket address to printable node and service names.
-   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);
-
-#endif
-
-/* Possible flags for getnameinfo.  */
-#ifndef NI_NUMERICHOST
-# define NI_NUMERICHOST 1
-#endif
-#ifndef NI_NUMERICSERV
-# define NI_NUMERICSERV 2
-#endif
-
-#endif /* GETADDRINFO_H */
diff --git a/gnulib/lib/getdelim.c b/gnulib/lib/getdelim.c
index b37538a..c905b69 100644
--- a/gnulib/lib/getdelim.c
+++ b/gnulib/lib/getdelim.c
@@ -33,13 +33,18 @@
 #ifndef SSIZE_MAX
 # define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
 #endif
-#if !HAVE_FLOCKFILE
+
+#if USE_UNLOCKED_IO
+# include "unlocked-io.h"
+# define getc_maybe_unlocked(fp)	getc(fp)
+#elif !HAVE_FLOCKFILE || !HAVE_FUNLOCKFILE || !HAVE_DECL_GETC_UNLOCKED
 # undef flockfile
-# define flockfile(x) ((void) 0)
-#endif
-#if !HAVE_FUNLOCKFILE
 # undef funlockfile
+# define flockfile(x) ((void) 0)
 # define funlockfile(x) ((void) 0)
+# define getc_maybe_unlocked(fp)	getc(fp)
+#else
+# define getc_maybe_unlocked(fp)	getc_unlocked(fp)
 #endif

 /* Read up to (and including) a DELIMITER from FP into *LINEPTR (and
@@ -79,7 +84,7 @@ getdelim (char **lineptr, size_t *n, int delimiter, FILE *fp)
     {
       int i;

-      i = getc (fp);
+      i = getc_maybe_unlocked (fp);
       if (i == EOF)
 	{
 	  result = -1;
diff --git a/gnulib/lib/gethostname.c b/gnulib/lib/gethostname.c
new file mode 100644
index 0000000..87175a2
--- /dev/null
+++ b/gnulib/lib/gethostname.c
@@ -0,0 +1,56 @@
+/* gethostname emulation for SysV and POSIX.1.
+
+   Copyright (C) 1992, 2003, 2006, 2008 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.1 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/>.  */
+
+/* David MacKenzie <djm@xxxxxxxxxxxxxx> */
+
+#include <config.h>
+
+/* Specification.  */
+#include <unistd.h>
+
+#ifdef HAVE_UNAME
+# include <sys/utsname.h>
+#endif
+
+#include <string.h>
+
+/* Put up to LEN chars of the host name into NAME.
+   Null terminate it if the name is shorter than LEN.
+   Return 0 if ok, -1 if error.  */
+
+#include <stddef.h>
+
+int
+gethostname (char *name, size_t len)
+{
+#ifdef HAVE_UNAME
+  struct utsname uts;
+
+  if (uname (&uts) == -1)
+    return -1;
+  if (len > sizeof (uts.nodename))
+    {
+      /* More space than we need is available.  */
+      name[sizeof (uts.nodename)] = '\0';
+      len = sizeof (uts.nodename);
+    }
+  strncpy (name, uts.nodename, len);
+#else
+  strcpy (name, "");		/* Hardcode your system name if you want.  */
+#endif
+  return 0;
+}
diff --git a/gnulib/lib/intprops.h b/gnulib/lib/intprops.h
index 2319dd8..b6b7723 100644
--- a/gnulib/lib/intprops.h
+++ b/gnulib/lib/intprops.h
@@ -4,7 +4,7 @@

    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
+   the Free Software Foundation; either version 2.1 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
diff --git a/gnulib/lib/lstat.c b/gnulib/lib/lstat.c
new file mode 100644
index 0000000..3d1bca8
--- /dev/null
+++ b/gnulib/lib/lstat.c
@@ -0,0 +1,82 @@
+/* Work around a bug of lstat on some systems
+
+   Copyright (C) 1997-1999, 2000-2006, 2008 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.1 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 Jim Meyering */
+
+#include <config.h>
+
+/* Get the original definition of open.  It might be defined as a macro.  */
+#define __need_system_sys_stat_h
+#include <sys/types.h>
+#include <sys/stat.h>
+#undef __need_system_sys_stat_h
+
+static inline int
+orig_lstat (const char *filename, struct stat *buf)
+{
+  return lstat (filename, buf);
+}
+
+/* Specification.  */
+#include <sys/stat.h>
+
+#include <string.h>
+#include <errno.h>
+
+/* lstat works differently on Linux and Solaris systems.  POSIX (see
+   `pathname resolution' in the glossary) requires that programs like
+   `ls' take into consideration the fact that FILE has a trailing slash
+   when FILE is a symbolic link.  On Linux and Solaris 10 systems, the
+   lstat function already has the desired semantics (in treating
+   `lstat ("symlink/", sbuf)' just like `lstat ("symlink/.", sbuf)',
+   but on Solaris 9 and earlier it does not.
+
+   If FILE has a trailing slash and specifies a symbolic link,
+   then use stat() to get more info on the referent of FILE.
+   If the referent is a non-directory, then set errno to ENOTDIR
+   and return -1.  Otherwise, return stat's result.  */
+
+int
+rpl_lstat (const char *file, struct stat *sbuf)
+{
+  size_t len;
+  int lstat_result = orig_lstat (file, sbuf);
+
+  if (lstat_result != 0 || !S_ISLNK (sbuf->st_mode))
+    return lstat_result;
+
+  len = strlen (file);
+  if (len == 0 || file[len - 1] != '/')
+    return 0;
+
+  /* FILE refers to a symbolic link and the name ends with a slash.
+     Call stat() to get info about the link's referent.  */
+
+  /* If stat fails, then we do the same.  */
+  if (stat (file, sbuf) != 0)
+    return -1;
+
+  /* If FILE references a directory, return 0.  */
+  if (S_ISDIR (sbuf->st_mode))
+    return 0;
+
+  /* Here, we know stat succeeded and FILE references a non-directory.
+     But it was specified via a name including a trailing slash.
+     Fail with errno set to ENOTDIR to indicate the contradiction.  */
+  errno = ENOTDIR;
+  return -1;
+}
diff --git a/gnulib/lib/netdb.in.h b/gnulib/lib/netdb.in.h
new file mode 100644
index 0000000..9ceb98d
--- /dev/null
+++ b/gnulib/lib/netdb.in.h
@@ -0,0 +1,190 @@
+/* Provide a netdb.h header file for systems lacking it (read: MinGW).
+   Copyright (C) 2008 Free Software Foundation, Inc.
+   Written by Simon Josefsson.
+
+   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.1, 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.  */
+
+/* This file is supposed to be used on platforms that lack <netdb.h>.
+   It is intended to provide definitions and prototypes needed by an
+   application.  */
+
+#ifndef _GL_NETDB_H
+
+#if @HAVE_NETDB_H@
+
+# if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+# endif
+
+/* The include_next requires a split double-inclusion guard.  */
+# @INCLUDE_NEXT@ @NEXT_NETDB_H@
+
+#endif
+
+#ifndef _GL_NETDB_H
+#define _GL_NETDB_H
+
+#if @HAVE_NETDB_H@ && HAVE_STRUCT_ADDRINFO
+
+/* Declarations for a platform that has <netdb.h>.  */
+
+#else
+
+/* Get netdb.h definitions such as struct hostent for MinGW.  */
+#include <sys/socket.h>
+
+/* Declarations for a platform that lacks <netdb.h>, or where it is
+   incomplete.  */
+
+#if @GNULIB_GETADDRINFO@
+
+# ifndef HAVE_STRUCT_ADDRINFO
+
+/* 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.  */
+};
+# endif
+
+/* Possible values for `ai_flags' field in `addrinfo' structure.  */
+# ifndef AI_PASSIVE
+#  define AI_PASSIVE	0x0001	/* Socket address is intended for `bind'.  */
+# endif
+# ifndef AI_CANONNAME
+#  define AI_CANONNAME	0x0002	/* Request for canonical name.  */
+# endif
+# ifndef AI_NUMERICSERV
+#  define AI_NUMERICSERV	0x0400	/* Don't use name resolution.  */
+# endif
+
+# if 0
+/* The commented out definitions below are not yet implemented in the
+   GNULIB getaddrinfo() replacement, so are not yet needed and may, in fact,
+   cause conflicts on systems with a getaddrinfo() function which does not
+   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..  */
+# 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.  */
+# endif
+
+/* Since EAI_NODATA is deprecated by RFC3493, some systems (at least
+   FreeBSD, which does define EAI_BADFLAGS) have removed the definition
+   in favor of EAI_NONAME.  */
+# if !defined EAI_NODATA && defined EAI_NONAME
+#  define EAI_NODATA EAI_NONAME
+# endif
+
+# ifndef EAI_OVERFLOW
+/* Not defined on mingw32. */
+#  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.  */
+# endif
+# ifndef EAI_SYSTEM
+/* Not defined on mingw32. */
+#  define EAI_SYSTEM	  -11	/* System error returned in `errno'.  */
+# endif
+
+# if 0
+/* The commented out definitions below are not yet implemented in the
+   GNULIB getaddrinfo() replacement, so are not yet needed.
+
+   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.  */
+#  endif
+# endif
+
+# if !HAVE_DECL_GETADDRINFO
+/* Translate name of a service location and/or a service name to set of
+   socket addresses.
+   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);
+# 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);
+# endif
+
+# if !HAVE_DECL_GAI_STRERROR
+/* Convert error return from getaddrinfo() to a string.
+   For more details, see the POSIX:2001 specification
+   <http://www.opengroup.org/susv3xsh/gai_strerror.html>.  */
+extern const char *gai_strerror (int ecode);
+# endif
+
+# if !HAVE_DECL_GETNAMEINFO
+/* Convert socket address to printable node and service names.
+   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);
+# endif
+
+/* Possible flags for getnameinfo.  */
+# ifndef NI_NUMERICHOST
+#  define NI_NUMERICHOST 1
+# endif
+# ifndef NI_NUMERICSERV
+#  define NI_NUMERICSERV 2
+# endif
+
+#endif /* @GNULIB_GETADDRINFO@ */
+
+#endif /* HAVE_NETDB_H */
+
+#endif /* _GL_NETDB_H */
+#endif /* _GL_NETDB_H */
diff --git a/gnulib/lib/netinet_in.in.h b/gnulib/lib/netinet_in.in.h
index 74d60e4..7c2b68f 100644
--- a/gnulib/lib/netinet_in.in.h
+++ b/gnulib/lib/netinet_in.in.h
@@ -1,5 +1,5 @@
 /* Substitute for <netinet/in.h>.
-   Copyright (C) 2007 Free Software Foundation, Inc.
+   Copyright (C) 2007-2008 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,6 +19,10 @@

 #if @HAVE_NETINET_IN_H@

+# if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+# endif
+
 /* On many platforms, <netinet/in.h> assumes prior inclusion of
    <sys/types.h>.  */
 # include <sys/types.h>
diff --git a/gnulib/lib/perror.c b/gnulib/lib/perror.c
new file mode 100644
index 0000000..f5f137e
--- /dev/null
+++ b/gnulib/lib/perror.c
@@ -0,0 +1,35 @@
+/* Print a message describing error code.
+   Copyright (C) 2008 Free Software Foundation, Inc.
+   Written by Bruno Haible and Simon Josefsson.
+
+   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.1 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 <stdio.h>
+
+#include <errno.h>
+#include <string.h>
+
+void
+perror (const char *string)
+{
+  const char *errno_description = strerror (errno);
+
+  if (string != NULL && *string != '\0')
+    fprintf (stderr, "%s: %s\n", string, errno_description);
+  else
+    fprintf (stderr, "%s\n", errno_description);
+}
diff --git a/gnulib/lib/poll.c b/gnulib/lib/poll.c
index b84cad3..87ddf3c 100644
--- a/gnulib/lib/poll.c
+++ b/gnulib/lib/poll.c
@@ -20,14 +20,27 @@
    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */

 #include <config.h>
+#include <alloca.h>

 #include <sys/types.h>
 #include "poll.h"
 #include <errno.h>
 #include <limits.h>
+#include <assert.h>
+
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+#define WIN32_NATIVE
+#include <winsock2.h>
+#include <windows.h>
+#include <io.h>
+#include <stdio.h>
+#include <conio.h>
+#else
+#include <sys/time.h>
 #include <sys/socket.h>
 #include <sys/select.h>
 #include <unistd.h>
+#endif

 #ifdef HAVE_SYS_IOCTL_H
 #include <sys/ioctl.h>
@@ -36,7 +49,6 @@
 #include <sys/filio.h>
 #endif

-#include <sys/time.h>
 #include <time.h>

 #ifndef INFTIM
@@ -48,12 +60,228 @@
 #define MSG_PEEK 0
 #endif

+#ifdef WIN32_NATIVE
+
+/* Declare data structures for ntdll functions.  */
+typedef struct _FILE_PIPE_LOCAL_INFORMATION {
+  ULONG NamedPipeType;
+  ULONG NamedPipeConfiguration;
+  ULONG MaximumInstances;
+  ULONG CurrentInstances;
+  ULONG InboundQuota;
+  ULONG ReadDataAvailable;
+  ULONG OutboundQuota;
+  ULONG WriteQuotaAvailable;
+  ULONG NamedPipeState;
+  ULONG NamedPipeEnd;
+} FILE_PIPE_LOCAL_INFORMATION, *PFILE_PIPE_LOCAL_INFORMATION;
+
+typedef struct _IO_STATUS_BLOCK
+{
+  union {
+    DWORD Status;
+    PVOID Pointer;
+  } u;
+  ULONG_PTR Information;
+} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
+
+typedef enum _FILE_INFORMATION_CLASS {
+  FilePipeLocalInformation = 24
+} FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;
+
+typedef DWORD (WINAPI *PNtQueryInformationFile)
+	 (HANDLE, IO_STATUS_BLOCK *, VOID *, ULONG, FILE_INFORMATION_CLASS);
+
+#ifndef PIPE_BUF
+#define PIPE_BUF	512
+#endif
+
+/* Compute revents values for file handle H.  */
+
+static int
+win32_compute_revents (HANDLE h, int sought)
+{
+  int i, ret, happened;
+  INPUT_RECORD *irbuffer;
+  DWORD avail, nbuffer;
+  BOOL bRet;
+  IO_STATUS_BLOCK iosb;
+  FILE_PIPE_LOCAL_INFORMATION fpli;
+  static PNtQueryInformationFile NtQueryInformationFile;
+  static BOOL once_only;
+
+  switch (GetFileType (h))
+    {
+    case FILE_TYPE_PIPE:
+      if (!once_only)
+	{
+	  NtQueryInformationFile = (PNtQueryInformationFile)
+	    GetProcAddress (GetModuleHandle ("ntdll.dll"),
+			    "NtQueryInformationFile");
+	  once_only = TRUE;
+	}
+
+      happened = 0;
+      if (PeekNamedPipe (h, NULL, 0, NULL, &avail, NULL) != 0)
+	{
+	  if (avail)
+	    happened |= sought & (POLLIN | POLLRDNORM);
+	}
+
+      else
+	{
+	  /* It was the write-end of the pipe.  Check if it is writable.
+	     If NtQueryInformationFile fails, optimistically assume the pipe is
+	     writable.  This could happen on Win9x, where NtQueryInformationFile
+	     is not available, or if we inherit a pipe that doesn't permit
+	     FILE_READ_ATTRIBUTES access on the write end (I think this should
+	     not happen since WinXP SP2; WINE seems fine too).  Otherwise,
+	     ensure that enough space is available for atomic writes.  */
+          memset (&iosb, 0, sizeof (iosb));
+          memset (&fpli, 0, sizeof (fpli));
+
+          if (!NtQueryInformationFile
+              || NtQueryInformationFile (h, &iosb, &fpli, sizeof (fpli),
+				         FilePipeLocalInformation)
+	      || fpli.WriteQuotaAvailable >= PIPE_BUF
+	      || (fpli.OutboundQuota < PIPE_BUF &&
+	          fpli.WriteQuotaAvailable == fpli.OutboundQuota))
+	    happened |= sought & (POLLOUT | POLLWRNORM | POLLWRBAND);
+	}
+      return happened;
+
+    case FILE_TYPE_CHAR:
+      ret = WaitForSingleObject (h, 0);
+      if (ret == WAIT_OBJECT_0)
+        {
+	  nbuffer = avail = 0;
+	  bRet = GetNumberOfConsoleInputEvents (h, &nbuffer);
+	  if (!bRet || nbuffer == 0)
+	    return POLLHUP;
+
+	  irbuffer = (INPUT_RECORD *) alloca (nbuffer * sizeof (INPUT_RECORD));
+	  bRet = PeekConsoleInput (h, irbuffer, nbuffer, &avail);
+	  if (!bRet || avail == 0)
+	    return POLLHUP;
+
+	  for (i = 0; i < avail; i++)
+	    if (irbuffer[i].EventType == KEY_EVENT)
+	      return sought & ~(POLLPRI | POLLRDBAND);
+	}
+      break;
+
+    default:
+      ret = WaitForSingleObject (h, 0);
+      if (ret == WAIT_OBJECT_0)
+        return sought & ~(POLLPRI | POLLRDBAND);
+
+      break;
+    }
+
+  return sought & (POLLOUT | POLLWRNORM | POLLWRBAND);
+}
+
+/* Convert fd_sets returned by select into revents values.  */
+
+static int
+win32_compute_revents_socket (SOCKET h, int sought, long lNetworkEvents)
+{
+  int happened = 0;
+
+  if ((lNetworkEvents & (FD_READ | FD_ACCEPT | FD_CLOSE)) == FD_ACCEPT)
+    happened |= (POLLIN | POLLRDNORM) & sought;
+
+  else if (lNetworkEvents & (FD_READ | FD_ACCEPT | FD_CLOSE))
+    {
+      int r, error;
+
+      char data[64];
+      WSASetLastError (0);
+      r = recv (h, data, sizeof (data), MSG_PEEK);
+      error = WSAGetLastError ();
+      WSASetLastError (0);
+
+      if (r > 0 || error == WSAENOTCONN)
+        happened |= (POLLIN | POLLRDNORM) & sought;
+
+      /* Distinguish hung-up sockets from other errors.  */
+      else if (r == 0 || error == WSAESHUTDOWN || error == WSAECONNRESET
+	       || error == WSAECONNABORTED || error == WSAENETRESET)
+        happened |= POLLHUP;
+
+      else
+        happened |= POLLERR;
+    }
+
+  if (lNetworkEvents & (FD_WRITE | FD_CONNECT))
+    happened |= (POLLOUT | POLLWRNORM | POLLWRBAND) & sought;
+
+  if (lNetworkEvents & FD_OOB)
+    happened |= (POLLPRI | POLLRDBAND) & sought;
+
+  return happened;
+}
+
+#else /* !MinGW */
+
+/* Convert select(2) returned fd_sets into poll(2) revents values.  */
+static int
+compute_revents (int fd, int sought, fd_set *rfds, fd_set *wfds, fd_set *efds)
+{
+  int happened = 0;
+  if (FD_ISSET (fd, rfds))
+    {
+      int r;
+      int socket_errno;
+
+#if defined __MACH__ && defined __APPLE__
+      /* There is a bug in Mac OS X that causes it to ignore MSG_PEEK
+         for some kinds of descriptors.  Detect if this descriptor is a
+         connected socket, a server socket, or something else using a
+         0-byte recv, and use ioctl(2) to detect POLLHUP.  */
+      r = recv (fd, NULL, 0, MSG_PEEK);
+      socket_errno = (r < 0) ? errno : 0;
+      if (r == 0 || socket_errno == ENOTSOCK)
+	ioctl (fd, FIONREAD, &r);
+#else
+      char data[64];
+      r = recv (fd, data, sizeof (data), MSG_PEEK);
+      socket_errno = (r < 0) ? errno : 0;
+#endif
+      if (r == 0)
+	happened |= POLLHUP;
+
+      /* If the event happened on an unconnected server socket,
+         that's fine. */
+      else if (r > 0 || ( /* (r == -1) && */ socket_errno == ENOTCONN))
+	happened |= (POLLIN | POLLRDNORM) & sought;
+
+      /* Distinguish hung-up sockets from other errors.  */
+      else if (socket_errno == ESHUTDOWN || socket_errno == ECONNRESET
+	       || socket_errno == ECONNABORTED || socket_errno == ENETRESET)
+	happened |= POLLHUP;
+
+      else
+	happened |= POLLERR;
+    }
+
+  if (FD_ISSET (fd, wfds))
+    happened |= (POLLOUT | POLLWRNORM | POLLWRBAND) & sought;
+
+  if (FD_ISSET (fd, efds))
+    happened |= (POLLPRI | POLLRDBAND) & sought;
+
+  return happened;
+}
+#endif /* !MinGW */
+
 int
 poll (pfd, nfd, timeout)
      struct pollfd *pfd;
      nfds_t nfd;
      int timeout;
 {
+#ifndef WIN32_NATIVE
   fd_set rfds, wfds, efds;
   struct timeval tv;
   struct timeval *ptv;
@@ -137,16 +365,11 @@ poll (pfd, nfd, timeout)
 			       | POLLWRNORM | POLLWRBAND)))
 	{
 	  maxfd = pfd[i].fd;
-
-	  /* Windows use a linear array of sockets (of size FD_SETSIZE). The
-	     descriptor value is not used to address the array.  */
-#if defined __CYGWIN__ || (!defined _WIN32 && !defined __WIN32__)
 	  if (maxfd > FD_SETSIZE)
 	    {
 	      errno = EOVERFLOW;
 	      return -1;
 	    }
-#endif
 	}
     }

@@ -162,55 +385,179 @@ poll (pfd, nfd, timeout)
       pfd[i].revents = 0;
     else
       {
-	int happened = 0, sought = pfd[i].events;
-	if (FD_ISSET (pfd[i].fd, &rfds))
+        int happened = compute_revents (pfd[i].fd, pfd[i].events,
+                                        &rfds, &wfds, &efds);
+	if (happened)
 	  {
-	    int r;
-	    int socket_errno;
+	    pfd[i].revents = happened;
+	    rc++;
+	  }
+      }

-#if defined __MACH__ && defined __APPLE__
-	    /* There is a bug in Mac OS X that causes it to ignore MSG_PEEK
-	       for some kinds of descriptors.  Detect if this descriptor is a
-	       connected socket, a server socket, or something else using a
-	       0-byte recv, and use ioctl(2) to detect POLLHUP.  */
-	    r = recv (pfd[i].fd, NULL, 0, MSG_PEEK);
-	    socket_errno = (r < 0) ? errno : 0;
-	    if (r == 0 || socket_errno == ENOTSOCK)
-	      ioctl(pfd[i].fd, FIONREAD, &r);
+  return rc;
 #else
-	    char data[64];
-	    r = recv (pfd[i].fd, data, sizeof (data), MSG_PEEK);
-	    socket_errno = (r < 0) ? errno : 0;
-#endif
-	    if (r == 0)
-	      happened |= POLLHUP;
+  static struct timeval tv0;
+  static HANDLE hEvent;
+  WSANETWORKEVENTS ev;
+  HANDLE h, handle_array[FD_SETSIZE + 2];
+  DWORD ret, wait_timeout, nhandles;
+  fd_set rfds, wfds, xfds;
+  BOOL poll_again;
+  MSG msg;
+  char sockbuf[256];
+  int rc;
+  nfds_t i;

-	    /* If the event happened on an unconnected server socket,
-	       that's fine. */
-	    else if (r > 0 || ( /* (r == -1) && */ socket_errno == ENOTCONN))
-	      happened |= (POLLIN | POLLRDNORM) & sought;
+  if (nfd < 0 || timeout < -1)
+    {
+      errno = EINVAL;
+      return -1;
+    }

-	    /* Distinguish hung-up sockets from other errors.  */
-	    else if (socket_errno == ESHUTDOWN || socket_errno == ECONNRESET
-		     || socket_errno == ECONNABORTED || socket_errno == ENETRESET)
-	      happened |= POLLHUP;
+  if (!hEvent)
+    hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);

-	    else
-	      happened |= POLLERR;
-	  }
+  handle_array[0] = hEvent;
+  nhandles = 1;
+  FD_ZERO (&rfds);
+  FD_ZERO (&wfds);
+  FD_ZERO (&xfds);

-	if (FD_ISSET (pfd[i].fd, &wfds))
-	  happened |= (POLLOUT | POLLWRNORM | POLLWRBAND) & sought;
+  /* Classify socket handles and create fd sets. */
+  for (i = 0; i < nfd; i++)
+    {
+      size_t optlen = sizeof(sockbuf);
+      pfd[i].revents = 0;
+      if (pfd[i].fd < 0)
+        continue;
+      if (!(pfd[i].events & (POLLIN | POLLRDNORM |
+                             POLLOUT | POLLWRNORM | POLLWRBAND)))
+	continue;

-	if (FD_ISSET (pfd[i].fd, &efds))
-	  happened |= (POLLPRI | POLLRDBAND) & sought;
+      h = (HANDLE) _get_osfhandle (pfd[i].fd);
+      assert (h != NULL);

-	if (happened)
-	  {
-	    pfd[i].revents = happened;
-	    rc++;
-	  }
-      }
+      /* Under Wine, it seems that getsockopt returns 0 for pipes too.
+	 WSAEnumNetworkEvents instead distinguishes the two correctly.  */
+      ev.lNetworkEvents = 0xDEADBEEF;
+      WSAEnumNetworkEvents ((SOCKET) h, NULL, &ev);
+      if (ev.lNetworkEvents != 0xDEADBEEF)
+        {
+          int requested = FD_CLOSE;
+
+          /* see above; socket handles are mapped onto select.  */
+          if (pfd[i].events & (POLLIN | POLLRDNORM))
+	    {
+              requested |= FD_READ | FD_ACCEPT;
+	      FD_SET ((SOCKET) h, &rfds);
+	    }
+          if (pfd[i].events & (POLLOUT | POLLWRNORM | POLLWRBAND))
+	    {
+              requested |= FD_WRITE | FD_CONNECT;
+	      FD_SET ((SOCKET) h, &wfds);
+	    }
+          if (pfd[i].events & (POLLPRI | POLLRDBAND))
+	    {
+              requested |= FD_OOB;
+	      FD_SET ((SOCKET) h, &xfds);
+	    }
+
+          if (requested)
+            WSAEventSelect ((SOCKET) h, hEvent, requested);
+        }
+      else
+        {
+          handle_array[nhandles++] = h;
+
+	  /* Poll now.  If we get an event, do not poll again.  */
+          pfd[i].revents = win32_compute_revents (h, pfd[i].events);
+          if (pfd[i].revents)
+	    wait_timeout = 0;
+        }
+    }
+
+  if (select (0, &rfds, &wfds, &xfds, &tv0) > 0)
+    {
+      /* Do MsgWaitForMultipleObjects anyway to dispatch messages, but
+	 no need to call select again.  */
+      poll_again = FALSE;
+      wait_timeout = 0;
+    }
+  else
+    {
+      poll_again = TRUE;
+      if (timeout == INFTIM)
+        wait_timeout = INFINITE;
+      else
+        wait_timeout = timeout;
+    }
+
+  for (;;)
+    {
+      ret = MsgWaitForMultipleObjects (nhandles, handle_array, FALSE,
+				       wait_timeout, QS_ALLINPUT);
+
+      if (ret == WAIT_OBJECT_0 + nhandles)
+	{
+          /* new input of some other kind */
+	  BOOL bRet;
+          while ((bRet = PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) != 0)
+            {
+              TranslateMessage (&msg);
+              DispatchMessage (&msg);
+            }
+	}
+      else
+	break;
+    }
+
+  if (poll_again)
+    select (0, &rfds, &wfds, &xfds, &tv0);
+
+  /* Place a sentinel at the end of the array.  */
+  handle_array[nhandles] = NULL;
+  nhandles = 1;
+  for (i = 0; i < nfd; i++)
+    {
+      int happened;
+
+      if (pfd[i].fd < 0)
+        continue;
+      if (!(pfd[i].events & (POLLIN | POLLRDNORM |
+                             POLLOUT | POLLWRNORM | POLLWRBAND)))
+	continue;
+
+      h = (HANDLE) _get_osfhandle (pfd[i].fd);
+      if (h != handle_array[nhandles])
+        {
+          /* It's a socket.  */
+          WSAEnumNetworkEvents ((SOCKET) h, NULL, &ev);
+	  WSAEventSelect ((SOCKET) h, 0, 0);
+
+	  /* If we're lucky, WSAEnumNetworkEvents already provided a way
+	     to distinguish FD_READ and FD_ACCEPT; this saves a recv later.  */
+	  if (FD_ISSET ((SOCKET) h, &rfds)
+	      && !(ev.lNetworkEvents & (FD_READ | FD_ACCEPT)))
+	    ev.lNetworkEvents |= FD_READ | FD_ACCEPT;
+	  if (FD_ISSET ((SOCKET) h, &wfds))
+	    ev.lNetworkEvents |= FD_WRITE | FD_CONNECT;
+	  if (FD_ISSET ((SOCKET) h, &xfds))
+	    ev.lNetworkEvents |= FD_OOB;
+
+          happened = win32_compute_revents_socket ((SOCKET) h, pfd[i].events,
+						   ev.lNetworkEvents);
+        }
+      else
+        {
+          /* Not a socket.  */
+          nhandles++;
+          happened = win32_compute_revents (h, pfd[i].events);
+        }
+
+       if ((pfd[i].revents |= happened) != 0)
+        rc++;
+    }

   return rc;
+#endif
 }
diff --git a/gnulib/lib/recv.c b/gnulib/lib/recv.c
new file mode 100644
index 0000000..699e68d
--- /dev/null
+++ b/gnulib/lib/recv.c
@@ -0,0 +1,40 @@
+/* recv.c --- wrappers for Windows recv function
+
+   Copyright (C) 2008 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.1 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 Paolo Bonzini */
+
+#include <config.h>
+
+#define WIN32_LEAN_AND_MEAN
+/* Get winsock2.h. */
+#include <sys/socket.h>
+
+/* Get set_winsock_errno, FD_TO_SOCKET etc. */
+#include "w32sock.h"
+
+#undef recv
+
+int
+rpl_recv (int fd, void *buf, int len, int flags)
+{
+  SOCKET sock = FD_TO_SOCKET (fd);
+  int r = recv (sock, buf, len, flags);
+  if (r < 0)
+    set_winsock_errno ();
+
+  return r;
+}
diff --git a/gnulib/lib/send.c b/gnulib/lib/send.c
new file mode 100644
index 0000000..b314b11
--- /dev/null
+++ b/gnulib/lib/send.c
@@ -0,0 +1,40 @@
+/* send.c --- wrappers for Windows send function
+
+   Copyright (C) 2008 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.1 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 Paolo Bonzini */
+
+#include <config.h>
+
+#define WIN32_LEAN_AND_MEAN
+/* Get winsock2.h. */
+#include <sys/socket.h>
+
+/* Get set_winsock_errno, FD_TO_SOCKET etc. */
+#include "w32sock.h"
+
+#undef send
+
+int
+rpl_send (int fd, const void *buf, int len, int flags)
+{
+  SOCKET sock = FD_TO_SOCKET (fd);
+  int r = send (sock, buf, len, flags);
+  if (r < 0)
+    set_winsock_errno ();
+
+  return r;
+}
diff --git a/gnulib/lib/setsockopt.c b/gnulib/lib/setsockopt.c
new file mode 100644
index 0000000..931b07b
--- /dev/null
+++ b/gnulib/lib/setsockopt.c
@@ -0,0 +1,40 @@
+/* setsockopt.c --- wrappers for Windows setsockopt function
+
+   Copyright (C) 2008 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.1 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 Paolo Bonzini */
+
+#include <config.h>
+
+#define WIN32_LEAN_AND_MEAN
+/* Get winsock2.h. */
+#include <sys/socket.h>
+
+/* Get set_winsock_errno, FD_TO_SOCKET etc. */
+#include "w32sock.h"
+
+#undef setsockopt
+
+int
+rpl_setsockopt (int fd, int level, int optname, const void *optval, int optlen)
+{
+  SOCKET sock = FD_TO_SOCKET (fd);
+  int r = setsockopt (sock, level, optname, optval, optlen);
+  if (r < 0)
+    set_winsock_errno ();
+
+  return r;
+}
diff --git a/gnulib/lib/socket.c b/gnulib/lib/socket.c
new file mode 100644
index 0000000..93367c6
--- /dev/null
+++ b/gnulib/lib/socket.c
@@ -0,0 +1,43 @@
+/* socket.c --- wrappers for Windows socket function
+
+   Copyright (C) 2008 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.1 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 Paolo Bonzini */
+
+#include <config.h>
+
+#define WIN32_LEAN_AND_MEAN
+/* Get winsock2.h. */
+#include <sys/socket.h>
+
+/* Get set_winsock_errno, FD_TO_SOCKET etc. */
+#include "w32sock.h"
+
+int
+rpl_socket (int domain, int type, int protocol)
+{
+  /* 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);
+
+  if (fh == INVALID_SOCKET)
+    {
+      set_winsock_errno ();
+      return -1;
+    }
+  else
+    return SOCKET_TO_FD (fh);
+}
diff --git a/gnulib/lib/stdint.in.h b/gnulib/lib/stdint.in.h
index fbe39c5..5170dc1 100644
--- a/gnulib/lib/stdint.in.h
+++ b/gnulib/lib/stdint.in.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2002, 2004-2007 Free Software Foundation, Inc.
+/* Copyright (C) 2001-2002, 2004-2008 Free Software Foundation, Inc.
    Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood.
    This file is part of gnulib.

@@ -49,6 +49,9 @@
      in <inttypes.h> would reinclude us, skipping our contents because
      _GL_STDINT_H is defined.
      The include_next requires a split double-inclusion guard.  */
+# if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+# endif
 # @INCLUDE_NEXT@ @NEXT_STDINT_H@
 #endif

diff --git a/gnulib/lib/stdio-write.c b/gnulib/lib/stdio-write.c
new file mode 100644
index 0000000..0abcfc4
--- /dev/null
+++ b/gnulib/lib/stdio-write.c
@@ -0,0 +1,148 @@
+/* POSIX compatible FILE stream write function.
+   Copyright (C) 2008 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@xxxxxxxxx>, 2008.
+
+   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.1 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 <stdio.h>
+
+/* Replace these functions only if module 'sigpipe' is requested.  */
+#if GNULIB_SIGPIPE
+
+/* On native Windows platforms, SIGPIPE does not exist.  When write() is
+   called on a pipe with no readers, WriteFile() fails with error
+   GetLastError() = ERROR_NO_DATA, and write() in consequence fails with
+   error EINVAL.  This write() function is at the basis of the function
+   which flushes the buffer of a FILE stream.  */
+
+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+
+#  include <errno.h>
+#  include <signal.h>
+#  include <io.h>
+
+#  define WIN32_LEAN_AND_MEAN  /* avoid including junk */
+#  include <windows.h>
+
+#  define CALL_WITH_SIGPIPE_EMULATION(RETTYPE, EXPRESSION, FAILED) \
+  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;							      \
+    }
+
+#  if !REPLACE_PRINTF_POSIX /* avoid collision with printf.c */
+int
+printf (const char *format, ...)
+{
+  int retval;
+  va_list args;
+
+  va_start (args, format);
+  retval = vfprintf (stdout, format, args);
+  va_end (args);
+
+  return retval;
+}
+#  endif
+
+#  if !REPLACE_FPRINTF_POSIX /* avoid collision with fprintf.c */
+int
+fprintf (FILE *stream, const char *format, ...)
+{
+  int retval;
+  va_list args;
+
+  va_start (args, format);
+  retval = vfprintf (stream, format, args);
+  va_end (args);
+
+  return retval;
+}
+#  endif
+
+#  if !REPLACE_VFPRINTF_POSIX /* avoid collision with vprintf.c */
+int
+vprintf (const char *format, va_list args)
+{
+  return vfprintf (stdout, format, args);
+}
+#  endif
+
+#  if !REPLACE_VPRINTF_POSIX /* avoid collision with vfprintf.c */
+int
+vfprintf (FILE *stream, const char *format, va_list args)
+#undef vfprintf
+{
+  CALL_WITH_SIGPIPE_EMULATION (int, vfprintf (stream, format, args), ret == EOF)
+}
+#  endif
+
+int
+putchar (int c)
+{
+  return fputc (c, stdout);
+}
+
+int
+fputc (int c, FILE *stream)
+#undef fputc
+{
+  CALL_WITH_SIGPIPE_EMULATION (int, fputc (c, stream), ret == EOF)
+}
+
+int
+fputs (const char *string, FILE *stream)
+#undef fputs
+{
+  CALL_WITH_SIGPIPE_EMULATION (int, fputs (string, stream), ret == EOF)
+}
+
+int
+puts (const char *string)
+#undef puts
+{
+  FILE *stream = stdout;
+  CALL_WITH_SIGPIPE_EMULATION (int, puts (string), ret == EOF)
+}
+
+size_t
+fwrite (const void *ptr, size_t s, size_t n, FILE *stream)
+#undef fwrite
+{
+  CALL_WITH_SIGPIPE_EMULATION (size_t, fwrite (ptr, s, n, stream), ret < n)
+}
+
+# endif
+#endif
diff --git a/gnulib/lib/stdio.in.h b/gnulib/lib/stdio.in.h
index ea4df7c..3b61879 100644
--- a/gnulib/lib/stdio.in.h
+++ b/gnulib/lib/stdio.in.h
@@ -16,6 +16,10 @@
    along with this program; if not, write to the Free Software Foundation,
    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */

+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+
 #if defined __need_FILE || defined __need___FILE
 /* Special invocation convention inside glibc header files.  */

@@ -71,6 +75,10 @@ extern "C" {
 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 \
@@ -86,6 +94,10 @@ extern int fprintf (FILE *fp, const char *format, ...)
 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) \
@@ -102,6 +114,11 @@ extern int vfprintf (FILE *fp, const char *format, va_list args)
 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 \
@@ -124,6 +141,10 @@ extern int printf (const char *format, ...)
 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) \
@@ -234,6 +255,7 @@ extern int vsprintf (char *str, const char *format, va_list args)

 #if @GNULIB_FOPEN@
 # if @REPLACE_FOPEN@
+#  undef fopen
 #  define fopen rpl_fopen
 extern FILE * fopen (const char *filename, const char *mode);
 # endif
@@ -247,6 +269,7 @@ extern FILE * fopen (const char *filename, const char *mode);

 #if @GNULIB_FREOPEN@
 # if @REPLACE_FREOPEN@
+#  undef freopen
 #  define freopen rpl_freopen
 extern FILE * freopen (const char *filename, const char *mode, FILE *stream);
 # endif
@@ -352,6 +375,57 @@ extern long rpl_ftell (FILE *fp);
     fflush (f))
 #endif

+#if @GNULIB_FCLOSE@
+# if @REPLACE_FCLOSE@
+#  define fclose rpl_fclose
+  /* Close STREAM and its underlying file descriptor.  */
+extern int fclose (FILE *stream);
+# 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);
+#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);
+#endif
+
 #if @GNULIB_GETDELIM@
 # if !@HAVE_DECL_GETDELIM@
 /* Read input, up to (and including) the next occurrence of DELIMITER, from
@@ -393,6 +467,22 @@ extern ssize_t getline (char **lineptr, size_t *linesize, FILE *stream);
    getline (l, s, f))
 #endif

+#if @GNULIB_PERROR@
+# if @REPLACE_PERROR@
+#  define perror rpl_perror
+/* Print a message to standard error, describing the value of ERRNO,
+   (if STRING is not NULL and not empty) prefixed with STRING and ": ",
+   and terminated with a newline.  */
+extern void perror (const char *string);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef perror
+# define perror(s) \
+    (GL_LINK_WARNING ("perror is not always POSIX compliant - " \
+                      "use gnulib module perror for portability"), \
+     perror (s))
+#endif
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/gnulib/lib/stdlib.in.h b/gnulib/lib/stdlib.in.h
index fc6004c..e28c151 100644
--- a/gnulib/lib/stdlib.in.h
+++ b/gnulib/lib/stdlib.in.h
@@ -15,6 +15,10 @@
    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/>.  */

+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+
 #if defined __need_malloc_and_calloc
 /* Special invocation convention inside glibc header files.  */

@@ -32,6 +36,28 @@
 #define _GL_STDLIB_H


+/* Solaris declares getloadavg() in <sys/loadavg.h>.  */
+#if @GNULIB_GETLOADAVG@ && @HAVE_SYS_LOADAVG_H@
+# include <sys/loadavg.h>
+#endif
+
+#if @GNULIB_RANDOM_R@ || !@HAVE_STRUCT_RANDOM_DATA@
+# 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.  */
+};
+#endif
+
 /* The definition of GL_LINK_WARNING is copied here.  */


@@ -99,6 +125,38 @@ extern void * calloc (size_t nmemb, size_t size);
 #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);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef atoll
+# define atoll(s) \
+    (GL_LINK_WARNING ("atoll is unportable - " \
+                      "use gnulib module atoll for portability"), \
+     atoll (s))
+#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);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef getloadavg
+# define getloadavg(l,n) \
+    (GL_LINK_WARNING ("getloadavg is not portable - " \
+                      "use gnulib module getloadavg for portability"), \
+     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,6 +234,43 @@ extern int putenv (char *string);
 #endif


+#if @GNULIB_RANDOM_R@
+# if !@HAVE_RANDOM_R@
+
+#  ifndef RAND_MAX
+#   define RAND_MAX 2147483647
+#  endif
+
+int srandom_r (unsigned int seed, struct random_data *rand_state);
+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);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef random_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)			     \
+    (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)				   \
+    (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)				    \
+    (GL_LINK_WARNING ("setstate_r is unportable - " \
+                      "use gnulib module random_r for portability"), \
+     setstate_r (a,r))
+#endif
+
+
 #if @GNULIB_RPMATCH@
 # if !@HAVE_RPMATCH@
 /* Test a user response to a question.
@@ -231,6 +326,48 @@ extern double strtod (const char *str, char **endp);
 #endif


+#if @GNULIB_STRTOLL@
+# if !@HAVE_STRTOLL@
+/* Parse a signed integer whose textual representation starts at STRING.
+   The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
+   it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
+   "0x").
+   If ENDPTR is not NULL, the address of the first byte after the integer is
+   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);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef strtoll
+# define strtoll(s,e,b) \
+    (GL_LINK_WARNING ("strtoll is unportable - " \
+                      "use gnulib module strtoll for portability"), \
+     strtoll (s, e, b))
+#endif
+
+
+#if @GNULIB_STRTOULL@
+# if !@HAVE_STRTOULL@
+/* Parse an unsigned integer whose textual representation starts at STRING.
+   The integer is expected to be in base BASE (2 <= BASE <= 36); if BASE == 0,
+   it may be decimal or octal (with prefix "0") or hexadecimal (with prefix
+   "0x").
+   If ENDPTR is not NULL, the address of the first byte after the integer is
+   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);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef strtoull
+# define strtoull(s,e,b) \
+    (GL_LINK_WARNING ("strtoull is unportable - " \
+                      "use gnulib module strtoull for portability"), \
+     strtoull (s, e, b))
+#endif
+
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/gnulib/lib/strerror.c b/gnulib/lib/strerror.c
new file mode 100644
index 0000000..a8e98be
--- /dev/null
+++ b/gnulib/lib/strerror.c
@@ -0,0 +1,273 @@
+/* strerror.c --- POSIX compatible system error routine
+
+   Copyright (C) 2007-2008 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.1 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>
+
+#include <string.h>
+
+#if REPLACE_STRERROR
+
+# include <errno.h>
+# include <stdio.h>
+
+# if GNULIB_defined_ESOCK /* native Windows platforms */
+#  if HAVE_WINSOCK2_H
+#   include <winsock2.h>
+#  endif
+# endif
+
+# include "intprops.h"
+
+# undef strerror
+# if ! HAVE_DECL_STRERROR
+#  define strerror(n) NULL
+# endif
+
+char *
+rpl_strerror (int n)
+{
+  /* These error messages are taken from glibc/sysdeps/gnu/errlist.c.  */
+  switch (n)
+    {
+# if GNULIB_defined_ETXTBSY
+    case ETXTBSY:
+      return "Text file busy";
+# endif
+
+# if GNULIB_defined_ESOCK /* native Windows platforms */
+    /* EWOULDBLOCK is the same as EAGAIN.  */
+    case EINPROGRESS:
+      return "Operation now in progress";
+    case EALREADY:
+      return "Operation already in progress";
+    case ENOTSOCK:
+      return "Socket operation on non-socket";
+    case EDESTADDRREQ:
+      return "Destination address required";
+    case EMSGSIZE:
+      return "Message too long";
+    case EPROTOTYPE:
+      return "Protocol wrong type for socket";
+    case ENOPROTOOPT:
+      return "Protocol not available";
+    case EPROTONOSUPPORT:
+      return "Protocol not supported";
+    case ESOCKTNOSUPPORT:
+      return "Socket type not supported";
+    case EOPNOTSUPP:
+      return "Operation not supported";
+    case EPFNOSUPPORT:
+      return "Protocol family not supported";
+    case EAFNOSUPPORT:
+      return "Address family not supported by protocol";
+    case EADDRINUSE:
+      return "Address already in use";
+    case EADDRNOTAVAIL:
+      return "Cannot assign requested address";
+    case ENETDOWN:
+      return "Network is down";
+    case ENETUNREACH:
+      return "Network is unreachable";
+    case ENETRESET:
+      return "Network dropped connection on reset";
+    case ECONNABORTED:
+      return "Software caused connection abort";
+    case ECONNRESET:
+      return "Connection reset by peer";
+    case ENOBUFS:
+      return "No buffer space available";
+    case EISCONN:
+      return "Transport endpoint is already connected";
+    case ENOTCONN:
+      return "Transport endpoint is not connected";
+    case ESHUTDOWN:
+      return "Cannot send after transport endpoint shutdown";
+    case ETOOMANYREFS:
+      return "Too many references: cannot splice";
+    case ETIMEDOUT:
+      return "Connection timed out";
+    case ECONNREFUSED:
+      return "Connection refused";
+    case ELOOP:
+      return "Too many levels of symbolic links";
+    case EHOSTDOWN:
+      return "Host is down";
+    case EHOSTUNREACH:
+      return "No route to host";
+    case EPROCLIM:
+      return "Too many processes";
+    case EUSERS:
+      return "Too many users";
+    case EDQUOT:
+      return "Disk quota exceeded";
+    case ESTALE:
+      return "Stale NFS file handle";
+    case EREMOTE:
+      return "Object is remote";
+#  if HAVE_WINSOCK2_H
+    /* WSA_INVALID_HANDLE maps to EBADF */
+    /* WSA_NOT_ENOUGH_MEMORY maps to ENOMEM */
+    /* WSA_INVALID_PARAMETER maps to EINVAL */
+    case WSA_OPERATION_ABORTED:
+      return "Overlapped operation aborted";
+    case WSA_IO_INCOMPLETE:
+      return "Overlapped I/O event object not in signaled state";
+    case WSA_IO_PENDING:
+      return "Overlapped operations will complete later";
+    /* WSAEINTR maps to EINTR */
+    /* WSAEBADF maps to EBADF */
+    /* WSAEACCES maps to EACCES */
+    /* WSAEFAULT maps to EFAULT */
+    /* WSAEINVAL maps to EINVAL */
+    /* WSAEMFILE maps to EMFILE */
+    /* WSAEWOULDBLOCK maps to EWOULDBLOCK */
+    /* WSAEINPROGRESS is EINPROGRESS */
+    /* WSAEALREADY is EALREADY */
+    /* WSAENOTSOCK is ENOTSOCK */
+    /* WSAEDESTADDRREQ is EDESTADDRREQ */
+    /* WSAEMSGSIZE is EMSGSIZE */
+    /* WSAEPROTOTYPE is EPROTOTYPE */
+    /* WSAENOPROTOOPT is ENOPROTOOPT */
+    /* WSAEPROTONOSUPPORT is EPROTONOSUPPORT */
+    /* WSAESOCKTNOSUPPORT is ESOCKTNOSUPPORT */
+    /* WSAEOPNOTSUPP is EOPNOTSUPP */
+    /* WSAEPFNOSUPPORT is EPFNOSUPPORT */
+    /* WSAEAFNOSUPPORT is EAFNOSUPPORT */
+    /* WSAEADDRINUSE is EADDRINUSE */
+    /* WSAEADDRNOTAVAIL is EADDRNOTAVAIL */
+    /* WSAENETDOWN is ENETDOWN */
+    /* WSAENETUNREACH is ENETUNREACH */
+    /* WSAENETRESET is ENETRESET */
+    /* WSAECONNABORTED is ECONNABORTED */
+    /* WSAECONNRESET is ECONNRESET */
+    /* WSAENOBUFS is ENOBUFS */
+    /* WSAEISCONN is EISCONN */
+    /* WSAENOTCONN is ENOTCONN */
+    /* WSAESHUTDOWN is ESHUTDOWN */
+    /* WSAETOOMANYREFS is ETOOMANYREFS */
+    /* WSAETIMEDOUT is ETIMEDOUT */
+    /* WSAECONNREFUSED is ECONNREFUSED */
+    /* WSAELOOP is ELOOP */
+    /* WSAENAMETOOLONG maps to ENAMETOOLONG */
+    /* WSAEHOSTDOWN is EHOSTDOWN */
+    /* WSAEHOSTUNREACH is EHOSTUNREACH */
+    /* WSAENOTEMPTY maps to ENOTEMPTY */
+    /* WSAEPROCLIM is EPROCLIM */
+    /* WSAEUSERS is EUSERS */
+    /* WSAEDQUOT is EDQUOT */
+    /* WSAESTALE is ESTALE */
+    /* WSAEREMOTE is EREMOTE */
+    case WSASYSNOTREADY:
+      return "Network subsystem is unavailable";
+    case WSAVERNOTSUPPORTED:
+      return "Winsock.dll version out of range";
+    case WSANOTINITIALISED:
+      return "Successful WSAStartup not yet performed";
+    case WSAEDISCON:
+      return "Graceful shutdown in progress";
+    case WSAENOMORE: case WSA_E_NO_MORE:
+      return "No more results";
+    case WSAECANCELLED: case WSA_E_CANCELLED:
+      return "Call was canceled";
+    case WSAEINVALIDPROCTABLE:
+      return "Procedure call table is invalid";
+    case WSAEINVALIDPROVIDER:
+      return "Service provider is invalid";
+    case WSAEPROVIDERFAILEDINIT:
+      return "Service provider failed to initialize";
+    case WSASYSCALLFAILURE:
+      return "System call failure";
+    case WSASERVICE_NOT_FOUND:
+      return "Service not found";
+    case WSATYPE_NOT_FOUND:
+      return "Class type not found";
+    case WSAEREFUSED:
+      return "Database query was refused";
+    case WSAHOST_NOT_FOUND:
+      return "Host not found";
+    case WSATRY_AGAIN:
+      return "Nonauthoritative host not found";
+    case WSANO_RECOVERY:
+      return "Nonrecoverable error";
+    case WSANO_DATA:
+      return "Valid name, no data record of requested type";
+    /* WSA_QOS_* omitted */
+#  endif
+# endif
+
+# if GNULIB_defined_ENOMSG
+    case ENOMSG:
+      return "No message of desired type";
+# endif
+
+# if GNULIB_defined_EIDRM
+    case EIDRM:
+      return "Identifier removed";
+# endif
+
+# if GNULIB_defined_ENOLINK
+    case ENOLINK:
+      return "Link has been severed";
+# endif
+
+# if GNULIB_defined_EPROTO
+    case EPROTO:
+      return "Protocol error";
+# endif
+
+# if GNULIB_defined_EMULTIHOP
+    case EMULTIHOP:
+      return "Multihop attempted";
+# endif
+
+# if GNULIB_defined_EBADMSG
+    case EBADMSG:
+      return "Bad message";
+# endif
+
+# if GNULIB_defined_EOVERFLOW
+    case EOVERFLOW:
+      return "Value too large for defined data type";
+# endif
+
+# if GNULIB_defined_ENOTSUP
+    case ENOTSUP:
+      return "Not supported";
+# endif
+
+# if GNULIB_defined_
+    case ECANCELED:
+      return "Operation canceled";
+# endif
+    }
+
+  {
+    char *result = strerror (n);
+
+    if (result == NULL || result[0] == '\0')
+      {
+	static char const fmt[] = "Unknown error (%d)";
+	static char mesg[sizeof fmt + INT_STRLEN_BOUND (n)];
+	sprintf (mesg, fmt, n);
+	return mesg;
+      }
+
+    return result;
+  }
+}
+
+#endif
diff --git a/gnulib/lib/string.in.h b/gnulib/lib/string.in.h
index e1086ca..0a6fb85 100644
--- a/gnulib/lib/string.in.h
+++ b/gnulib/lib/string.in.h
@@ -18,6 +18,10 @@

 #ifndef _GL_STRING_H

+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+
 /* The include_next requires a split double-inclusion guard.  */
 #@INCLUDE_NEXT@ @NEXT_STRING_H@

@@ -165,7 +169,11 @@ extern char *strchrnul (char const *__s, int __c_in)

 /* Duplicate S, returning an identical malloc'd string.  */
 #if @GNULIB_STRDUP@
-# if ! @HAVE_DECL_STRDUP@ && ! defined strdup
+# if @REPLACE_STRDUP@
+#  undef strdup
+#  define strdup rpl_strdup
+# endif
+# if !(@HAVE_DECL_STRDUP@ || defined strdup) || @REPLACE_STRDUP@
 extern char *strdup (char const *__s);
 # endif
 #elif defined GNULIB_POSIXCHECK
@@ -576,6 +584,18 @@ extern char *strsignal (int __sig);
      strsignal (a))
 #endif

+#if @GNULIB_STRVERSCMP@
+# if !@HAVE_STRVERSCMP@
+extern int strverscmp (const char *, const char *);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef strverscmp
+# define strverscmp(a, b) \
+    (GL_LINK_WARNING ("strverscmp is unportable - " \
+                      "use gnulib module strverscmp for portability"), \
+     strverscmp (a, b))
+#endif
+

 #ifdef __cplusplus
 }
diff --git a/gnulib/lib/sys_select.in.h b/gnulib/lib/sys_select.in.h
index b35bf66..f427dcc 100644
--- a/gnulib/lib/sys_select.in.h
+++ b/gnulib/lib/sys_select.in.h
@@ -1,5 +1,5 @@
 /* Substitute for <sys/select.h>.
-   Copyright (C) 2007 Free Software Foundation, Inc.
+   Copyright (C) 2007-2008 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,10 +19,18 @@

 #if @HAVE_SYS_SELECT_H@

+# if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+# endif
+
 /* On many platforms, <sys/select.h> assumes prior inclusion of
    <sys/types.h>.  */
 # 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>
+
 /* The include_next requires a split double-inclusion guard.  */
 # @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@

@@ -37,6 +45,33 @@

 # include <sys/socket.h>

+/* The definition of GL_LINK_WARNING is copied here.  */
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+# if @GNULIB_SELECT@
+#  if @HAVE_WINSOCK2_H@
+#   undef select
+#   define select rpl_select
+extern int rpl_select (int, fd_set *, fd_set *, fd_set *, struct timeval *);
+#  endif
+# elif @HAVE_WINSOCK2_H@
+#  undef select
+#  define select select_used_without_requesting_gnulib_module_select
+# elif defined GNULIB_POSIXCHECK
+#  undef select
+#  define select(n,r,w,e,t) \
+     (GL_LINK_WARNING ("select is not always POSIX compliant - " \
+                       "use gnulib module select for portability"), \
+      select (n, r, w, e, t))
+# endif
+
+# ifdef __cplusplus
+}
+# endif
+
 #endif

 #endif /* _GL_SYS_SELECT_H */
diff --git a/gnulib/lib/sys_socket.in.h b/gnulib/lib/sys_socket.in.h
index 4f58089..c8247e9 100644
--- a/gnulib/lib/sys_socket.in.h
+++ b/gnulib/lib/sys_socket.in.h
@@ -27,6 +27,10 @@

 #if @HAVE_SYS_SOCKET_H@

+# if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+# endif
+
 /* On many platforms, <sys/socket.h> assumes prior inclusion of
    <sys/types.h>.  */
 # include <sys/types.h>
@@ -56,6 +60,10 @@

 #else

+# ifdef __CYGWIN__
+#  error "Cygwin does have a sys/socket.h, doesn't it?!?"
+# endif
+
 /* A platform that lacks <sys/socket.h>.

    Currently only MinGW is supported.  See the gnulib manual regarding
@@ -92,23 +100,300 @@
 #  define SHUT_RDWR SD_BOTH
 # endif

-# if defined _WIN32 || defined __WIN32__
-#  define ENOTSOCK                WSAENOTSOCK
-#  define EADDRINUSE              WSAEADDRINUSE
-#  define ENETRESET               WSAENETRESET
-#  define ECONNABORTED            WSAECONNABORTED
-#  define ECONNRESET              WSAECONNRESET
-#  define ENOTCONN                WSAENOTCONN
-#  define ESHUTDOWN               WSAESHUTDOWN
+/* The definition of GL_LINK_WARNING is copied here.  */
+
+# if @HAVE_WINSOCK2_H@
+/* Include headers needed by the emulation code.  */
+#  include <sys/types.h>
+#  include <io.h>
+
+typedef int socklen_t;
+
+# endif
+
+# ifdef __cplusplus
+extern "C" {
 # endif

-# if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
-#  define setsockopt(a,b,c,d,e) rpl_setsockopt(a,b,c,d,e)
+# if @HAVE_WINSOCK2_H@
+
+/* Re-define FD_ISSET to avoid a WSA call while we are not using
+   network sockets.  */
 static inline int
-rpl_setsockopt(int socket, int level, int optname, const void *optval,
-	       socklen_t optlen)
+rpl_fd_isset (SOCKET fd, fd_set * set)
 {
-  return (setsockopt)(socket, level, optname, optval, optlen);
+  u_int i;
+  if (set == NULL)
+    return 0;
+
+  for (i = 0; i < set->fd_count; i++)
+    if (set->fd_array[i] == fd)
+      return 1;
+
+  return 0;
+}
+
+#  undef FD_ISSET
+#  define FD_ISSET(fd, set) rpl_fd_isset(fd, set)
+
+# endif
+
+/* Wrap everything else to use libc file descriptors for sockets.  */
+
+# if @HAVE_WINSOCK2_H@ && !defined _GL_UNISTD_H
+#  undef close
+#  define close close_used_without_including_unistd_h
+# endif
+
+# if @HAVE_WINSOCK2_H@ && !defined _GL_UNISTD_H
+#  undef gethostname
+#  define gethostname gethostname_used_without_including_unistd_h
+# endif
+
+# if @GNULIB_SOCKET@
+#  if @HAVE_WINSOCK2_H@
+#   undef socket
+#   define socket		rpl_socket
+extern int rpl_socket (int, int, int protocol);
+#  endif
+# elif @HAVE_WINSOCK2_H@
+#  undef socket
+#  define socket socket_used_without_requesting_gnulib_module_socket
+# elif defined GNULIB_POSIXCHECK
+#  undef socket
+#  define socket(d,t,p) \
+     (GL_LINK_WARNING ("socket is not always POSIX compliant - " \
+                       "use gnulib module socket for portability"), \
+      socket (d, t, p))
+# endif
+
+# if @GNULIB_CONNECT@
+#  if @HAVE_WINSOCK2_H@
+#   undef connect
+#   define connect		rpl_connect
+extern int rpl_connect (int, struct sockaddr *, int);
+#  endif
+# elif @HAVE_WINSOCK2_H@
+#  undef connect
+#  define connect socket_used_without_requesting_gnulib_module_connect
+# elif defined GNULIB_POSIXCHECK
+#  undef connect
+#  define connect(s,a,l) \
+     (GL_LINK_WARNING ("connect is not always POSIX compliant - " \
+                       "use gnulib module connect for portability"), \
+      connect (s, a, l))
+# endif
+
+# if @GNULIB_ACCEPT@
+#  if @HAVE_WINSOCK2_H@
+#   undef accept
+#   define accept		rpl_accept
+extern int rpl_accept (int, struct sockaddr *, int *);
+#  endif
+# elif @HAVE_WINSOCK2_H@
+#  undef accept
+#  define accept accept_used_without_requesting_gnulib_module_accept
+# elif defined GNULIB_POSIXCHECK
+#  undef accept
+#  define accept(s,a,l) \
+     (GL_LINK_WARNING ("accept is not always POSIX compliant - " \
+                       "use gnulib module accept for portability"), \
+      accept (s, a, l))
+# endif
+
+# if @GNULIB_BIND@
+#  if @HAVE_WINSOCK2_H@
+#   undef bind
+#   define bind			rpl_bind
+extern int rpl_bind (int, struct sockaddr *, int);
+#  endif
+# elif @HAVE_WINSOCK2_H@
+#  undef bind
+#  define bind bind_used_without_requesting_gnulib_module_bind
+# elif defined GNULIB_POSIXCHECK
+#  undef bind
+#  define bind(s,a,l) \
+     (GL_LINK_WARNING ("bind is not always POSIX compliant - " \
+                       "use gnulib module bind for portability"), \
+      bind (s, a, l))
+# endif
+
+# if @GNULIB_GETPEERNAME@
+#  if @HAVE_WINSOCK2_H@
+#   undef getpeername
+#   define getpeername		rpl_getpeername
+extern int rpl_getpeername (int, struct sockaddr *, int *);
+#  endif
+# elif @HAVE_WINSOCK2_H@
+#  undef getpeername
+#  define getpeername getpeername_used_without_requesting_gnulib_module_getpeername
+# elif defined GNULIB_POSIXCHECK
+#  undef getpeername
+#  define getpeername(s,a,l) \
+     (GL_LINK_WARNING ("getpeername is not always POSIX compliant - " \
+                       "use gnulib module getpeername for portability"), \
+      getpeername (s, a, l))
+# endif
+
+# if @GNULIB_GETSOCKNAME@
+#  if @HAVE_WINSOCK2_H@
+#   undef getsockname
+#   define getsockname		rpl_getsockname
+extern int rpl_getsockname (int, struct sockaddr *, int *);
+#  endif
+# elif @HAVE_WINSOCK2_H@
+#  undef getsockname
+#  define getsockname getsockname_used_without_requesting_gnulib_module_getsockname
+# elif defined GNULIB_POSIXCHECK
+#  undef getsockname
+#  define getsockname(s,a,l) \
+     (GL_LINK_WARNING ("getsockname is not always POSIX compliant - " \
+                       "use gnulib module getsockname for portability"), \
+      getsockname (s, a, l))
+# endif
+
+# if @GNULIB_GETSOCKOPT@
+#  if @HAVE_WINSOCK2_H@
+#   undef getsockopt
+#   define getsockopt		rpl_getsockopt
+extern int rpl_getsockopt (int, int, int, void *, int *);
+#  endif
+# elif @HAVE_WINSOCK2_H@
+#  undef getsockopt
+#  define getsockopt getsockopt_used_without_requesting_gnulib_module_getsockopt
+# elif defined GNULIB_POSIXCHECK
+#  undef getsockopt
+#  define getsockopt(s,lvl,o,v,l) \
+     (GL_LINK_WARNING ("getsockopt is not always POSIX compliant - " \
+                       "use gnulib module getsockopt for portability"), \
+      getsockopt (s, lvl, o, v, l))
+# endif
+
+# if @GNULIB_LISTEN@
+#  if @HAVE_WINSOCK2_H@
+#   undef listen
+#   define listen		rpl_listen
+extern int rpl_listen (int, int);
+#  endif
+# elif @HAVE_WINSOCK2_H@
+#  undef listen
+#  define listen listen_used_without_requesting_gnulib_module_listen
+# elif defined GNULIB_POSIXCHECK
+#  undef listen
+#  define listen(s,b) \
+     (GL_LINK_WARNING ("listen is not always POSIX compliant - " \
+                       "use gnulib module listen for portability"), \
+      listen (s, b))
+# endif
+
+# if @GNULIB_RECV@
+#  if @HAVE_WINSOCK2_H@
+#   undef recv
+#   define recv			rpl_recv
+extern int rpl_recv (int, void *, int, int);
+#  endif
+# elif @HAVE_WINSOCK2_H@
+#  undef recv
+#  define recv recv_used_without_requesting_gnulib_module_recv
+# elif defined GNULIB_POSIXCHECK
+#  undef recv
+#  define recv(s,b,n,f) \
+     (GL_LINK_WARNING ("recv is not always POSIX compliant - " \
+                       "use gnulib module recv for portability"), \
+      recv (s, b, n, f))
+# endif
+
+# if @GNULIB_SEND@
+#  if @HAVE_WINSOCK2_H@
+#   undef send
+#   define send			rpl_send
+extern int rpl_send (int, const void *, int, int);
+#  endif
+# elif @HAVE_WINSOCK2_H@
+#  undef send
+#  define send send_used_without_requesting_gnulib_module_send
+# elif defined GNULIB_POSIXCHECK
+#  undef send
+#  define send(s,b,n,f) \
+     (GL_LINK_WARNING ("send is not always POSIX compliant - " \
+                       "use gnulib module send for portability"), \
+      send (s, b, n, f))
+# endif
+
+# if @GNULIB_RECVFROM@
+#  if @HAVE_WINSOCK2_H@
+#   undef recvfrom
+#   define recvfrom		rpl_recvfrom
+extern int rpl_recvfrom (int, void *, int, int, struct sockaddr *, int *);
+#  endif
+# elif @HAVE_WINSOCK2_H@
+#  undef recvfrom
+#  define recvfrom recvfrom_used_without_requesting_gnulib_module_recvfrom
+# elif defined GNULIB_POSIXCHECK
+#  undef recvfrom
+#  define recvfrom(s,b,n,f,a,l) \
+     (GL_LINK_WARNING ("recvfrom is not always POSIX compliant - " \
+                       "use gnulib module recvfrom for portability"), \
+      recvfrom (s, b, n, f, a, l))
+# endif
+
+# 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);
+#  endif
+# elif @HAVE_WINSOCK2_H@
+#  undef sendto
+#  define sendto sendto_used_without_requesting_gnulib_module_sendto
+# elif defined GNULIB_POSIXCHECK
+#  undef sendto
+#  define sendto(s,b,n,f,a,l) \
+     (GL_LINK_WARNING ("sendto is not always POSIX compliant - " \
+                       "use gnulib module sendto for portability"), \
+      sendto (s, b, n, f, a, l))
+# endif
+
+# if @GNULIB_SETSOCKOPT@
+#  if @HAVE_WINSOCK2_H@
+#   undef setsockopt
+#   define setsockopt		rpl_setsockopt
+extern int rpl_setsockopt (int, int, int, const void *, int);
+#  endif
+# elif @HAVE_WINSOCK2_H@
+#  undef setsockopt
+#  define setsockopt setsockopt_used_without_requesting_gnulib_module_setsockopt
+# elif defined GNULIB_POSIXCHECK
+#  undef setsockopt
+#  define setsockopt(s,lvl,o,v,l) \
+     (GL_LINK_WARNING ("setsockopt is not always POSIX compliant - " \
+                       "use gnulib module setsockopt for portability"), \
+      setsockopt (s, lvl, o, v, l))
+# endif
+
+# if @GNULIB_SHUTDOWN@
+#  if @HAVE_WINSOCK2_H@
+#   undef shutdown
+#   define shutdown		rpl_shutdown
+extern int rpl_shutdown (int, int);
+#  endif
+# elif @HAVE_WINSOCK2_H@
+#  undef shutdown
+#  define shutdown shutdown_used_without_requesting_gnulib_module_shutdown
+# elif defined GNULIB_POSIXCHECK
+#  undef shutdown
+#  define shutdown(s,h) \
+     (GL_LINK_WARNING ("shutdown is not always POSIX compliant - " \
+                       "use gnulib module shutdown for portability"), \
+      shutdown (s, h))
+# endif
+
+# if @HAVE_WINSOCK2_H@
+#  undef select
+#  define select		select_used_without_including_sys_select_h
+# endif
+
+# ifdef __cplusplus
 }
 # endif

diff --git a/gnulib/lib/sys_stat.in.h b/gnulib/lib/sys_stat.in.h
index 1ffefa1..9eac5f4 100644
--- a/gnulib/lib/sys_stat.in.h
+++ b/gnulib/lib/sys_stat.in.h
@@ -1,5 +1,5 @@
 /* Provide a more complete sys/stat header file.
-   Copyright (C) 2006-2008 Free Software Foundation, Inc.
+   Copyright (C) 2005-2008 Free Software Foundation, Inc.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -21,6 +21,18 @@
    incomplete.  It is intended to provide definitions and prototypes
    needed by an application.  Start with what the system provides.  */

+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+
+#if defined __need_system_sys_stat_h
+/* Special invocation convention.  */
+
+#@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
+
+#else
+/* Normal invocation convention.  */
+
 #ifndef _GL_SYS_STAT_H

 /* The include_next requires a split double-inclusion guard.  */
@@ -29,6 +41,8 @@
 #ifndef _GL_SYS_STAT_H
 #define _GL_SYS_STAT_H

+/* The definition of GL_LINK_WARNING 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__
@@ -261,12 +275,25 @@
 # define S_IRWXUGO (S_IRWXU | S_IRWXG | S_IRWXO)
 #endif

+#if @GNULIB_LSTAT@
+# if ! @HAVE_LSTAT@
 /* mingw does not support symlinks, therefore it does not have lstat.  But
    without links, stat does just fine.  */
-#if ! @HAVE_LSTAT@
-# define lstat stat
+#  define lstat stat
+# elif @REPLACE_LSTAT@
+#  undef lstat
+#  define lstat rpl_lstat
+extern int rpl_lstat (const char *name, struct stat *buf);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef lstat
+# define lstat(p,b)							\
+  (GL_LINK_WARNING ("lstat is unportable - "				\
+		    "use gnulib module lstat for portability"),		\
+   lstat (p, b))
 #endif

+
 #if @REPLACE_MKDIR@
 # undef mkdir
 # define mkdir rpl_mkdir
@@ -287,5 +314,33 @@ rpl_mkdir (char const *name, mode_t mode)
 # endif
 #endif

+
+/* Declare BSD extensions.  */
+
+#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);
+# 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
+
 #endif /* _GL_SYS_STAT_H */
 #endif /* _GL_SYS_STAT_H */
+#endif
diff --git a/gnulib/lib/sys_time.in.h b/gnulib/lib/sys_time.in.h
index d97c08b..2b4bfdd 100644
--- a/gnulib/lib/sys_time.in.h
+++ b/gnulib/lib/sys_time.in.h
@@ -1,6 +1,6 @@
 /* Provide a more complete sys/time.h.

-   Copyright (C) 2007 Free Software Foundation, Inc.
+   Copyright (C) 2007-2008 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
@@ -18,6 +18,10 @@

 /* Written by Paul Eggert.  */

+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+
 #if defined _GL_SYS_TIME_H

 /* Simply delegate to the system's header, without adding anything.  */
diff --git a/gnulib/lib/unistd.in.h b/gnulib/lib/unistd.in.h
index 1021d41..8bc3abf 100644
--- a/gnulib/lib/unistd.in.h
+++ b/gnulib/lib/unistd.in.h
@@ -1,5 +1,5 @@
 /* Substitute for and wrapper around <unistd.h>.
-   Copyright (C) 2004-2008 Free Software Foundation, Inc.
+   Copyright (C) 2003-2008 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
@@ -17,6 +17,10 @@

 #ifndef _GL_UNISTD_H

+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+
 /* The include_next requires a split double-inclusion guard.  */
 #if @HAVE_UNISTD_H@
 # @INCLUDE_NEXT@ @NEXT_UNISTD_H@
@@ -33,6 +37,52 @@
 /* mingw fails to declare _exit in <unistd.h>.  */
 #include <stdlib.h>

+#if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
+/* Get ssize_t.  */
+# include <sys/types.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
+#   undef connect
+#   define connect		connect_used_without_including_sys_socket_h
+#   undef accept
+#   define accept		accept_used_without_including_sys_socket_h
+#   undef bind
+#   define bind			bind_used_without_including_sys_socket_h
+#   undef getpeername
+#   define getpeername		getpeername_used_without_including_sys_socket_h
+#   undef getsockname
+#   define getsockname		getsockname_used_without_including_sys_socket_h
+#   undef getsockopt
+#   define getsockopt		getsockopt_used_without_including_sys_socket_h
+#   undef listen
+#   define listen		listen_used_without_including_sys_socket_h
+#   undef recv
+#   define recv			recv_used_without_including_sys_socket_h
+#   undef send
+#   define send			send_used_without_including_sys_socket_h
+#   undef recvfrom
+#   define recvfrom		recvfrom_used_without_including_sys_socket_h
+#   undef sendto
+#   define sendto		sendto_used_without_including_sys_socket_h
+#   undef setsockopt
+#   define setsockopt		setsockopt_used_without_including_sys_socket_h
+#   undef shutdown
+#   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
+#  endif
+# endif
+#endif
+
 /* The definition of GL_LINK_WARNING is copied here.  */


@@ -68,6 +118,29 @@ extern int chown (const char *file, uid_t uid, gid_t gid);
 #endif


+#if @GNULIB_CLOSE@
+# if @UNISTD_H_HAVE_WINSOCK2_H@
+/* Need a gnulib internal function.  */
+#  define HAVE__GL_CLOSE_FD_MAYBE_SOCKET 1
+# endif
+# if @REPLACE_CLOSE@
+/* Automatically included by modules that need a replacement for close.  */
+#  undef close
+#  define close rpl_close
+extern int close (int);
+# endif
+#elif @UNISTD_H_HAVE_WINSOCK2_H@
+# undef close
+# define close close_used_without_requesting_gnulib_module_close
+#elif defined GNULIB_POSIXCHECK
+# undef close
+# define close(f) \
+    (GL_LINK_WARNING ("close does not portably work on sockets - " \
+                      "use gnulib module close for portability"), \
+     close (f))
+#endif
+
+
 #if @GNULIB_DUP2@
 # if !@HAVE_DUP2@
 /* Copy the file descriptor OLDFD into file descriptor NEWFD.  Do nothing if
@@ -106,6 +179,21 @@ extern char **environ;
 #endif


+#if @GNULIB_EUIDACCESS@
+# if !@HAVE_EUIDACCESS@
+/* Like access(), except that is uses the effective user id and group id of
+   the current process.  */
+extern int euidaccess (const char *filename, int mode);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef euidaccess
+# define euidaccess(f,m) \
+    (GL_LINK_WARNING ("euidaccess is unportable - " \
+                      "use gnulib module euidaccess for portability"), \
+     euidaccess (f, m))
+#endif
+
+
 #if @GNULIB_FCHDIR@
 # if @REPLACE_FCHDIR@

@@ -116,8 +204,6 @@ extern char **environ;
    <http://www.opengroup.org/susv3xsh/fchdir.html>.  */
 extern int fchdir (int /*fd*/);

-#  define close rpl_close
-extern int close (int);
 #  define dup rpl_dup
 extern int dup (int);
 #  define dup2 rpl_dup2
@@ -133,6 +219,23 @@ extern int dup2 (int, int);
 #endif


+#if @GNULIB_FSYNC@
+/* Synchronize changes to a file.
+   Return 0 if successful, otherwise -1 and errno set.
+   See POSIX:2001 specification
+   <http://www.opengroup.org/susv3xsh/fsync.html>.  */
+# if !@HAVE_FSYNC@
+extern int fsync (int fd);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef fsync
+# define fsync(fd) \
+    (GL_LINK_WARNING ("fsync is unportable - " \
+                      "use gnulib module fsync for portability"), \
+     fsync (fd))
+#endif
+
+
 #if @GNULIB_FTRUNCATE@
 # if !@HAVE_FTRUNCATE@
 /* Change the size of the file to which FD is opened to become equal to LENGTH.
@@ -177,6 +280,70 @@ extern char * getcwd (char *buf, size_t size);
 #endif


+#if @GNULIB_GETDOMAINNAME@
+/* Return the NIS domain name of the machine.
+   WARNING! The NIS domain name is unrelated to the fully qualified host name
+            of the machine.  It is also unrelated to email addresses.
+   WARNING! The NIS domain name is usually the empty string or "(none)" when
+            not using NIS.
+
+   Put up to LEN bytes of the NIS domain name into NAME.
+   Null terminate it if the name is shorter than LEN.
+   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);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef getdomainname
+# define getdomainname(n,l) \
+    (GL_LINK_WARNING ("getdomainname is unportable - " \
+                      "use gnulib module getdomainname for portability"), \
+     getdomainname (n, l))
+#endif
+
+
+#if @GNULIB_GETDTABLESIZE@
+# if !@HAVE_GETDTABLESIZE@
+/* Return the maximum number of file descriptors in the current process.  */
+extern int getdtablesize (void);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef getdtablesize
+# define getdtablesize() \
+    (GL_LINK_WARNING ("getdtablesize is unportable - " \
+                      "use gnulib module getdtablesize for portability"), \
+     getdtablesize ())
+#endif
+
+
+#if @GNULIB_GETHOSTNAME@
+/* Return the standard host name of the machine.
+   WARNING! The host name may or may not be fully qualified.
+
+   Put up to LEN bytes of the host name into NAME.
+   Null terminate it if the name is shorter than LEN.
+   If the host name is longer than LEN, set errno = EINVAL and return -1.
+   Return 0 if successful, otherwise set errno and return -1.  */
+# if @UNISTD_H_HAVE_WINSOCK2_H@
+#  undef gethostname
+#  define gethostname rpl_gethostname
+# endif
+# if @UNISTD_H_HAVE_WINSOCK2_H@ || !@HAVE_GETHOSTNAME@
+extern int gethostname(char *name, size_t len);
+# endif
+#elif @UNISTD_H_HAVE_WINSOCK2_H@
+# undef gethostname
+# define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
+#elif defined GNULIB_POSIXCHECK
+# undef gethostname
+# define gethostname(n,l) \
+    (GL_LINK_WARNING ("gethostname is unportable - " \
+                      "use gnulib module gethostname for portability"), \
+     gethostname (n, l))
+#endif
+
+
 #if @GNULIB_GETLOGIN_R@
 /* Copies the user's login name to NAME.
    The array pointed to by NAME has room for SIZE bytes.
@@ -258,6 +425,36 @@ extern int getpagesize (void);
 #endif


+#if @GNULIB_GETUSERSHELL@
+# if !@HAVE_GETUSERSHELL@
+/* Return the next valid login shell on the system, or NULL when the end of
+   the list has been reached.  */
+extern char *getusershell (void);
+/* Rewind to pointer that is advanced at each getusershell() call.  */
+extern void setusershell (void);
+/* Free the pointer that is advanced at each getusershell() call and
+   associated resources.  */
+extern void endusershell (void);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef getusershell
+# define getusershell() \
+    (GL_LINK_WARNING ("getusershell is unportable - " \
+                      "use gnulib module getusershell for portability"), \
+     getusershell ())
+# undef setusershell
+# define setusershell() \
+    (GL_LINK_WARNING ("setusershell is unportable - " \
+                      "use gnulib module getusershell for portability"), \
+     setusershell ())
+# undef endusershell
+# define endusershell() \
+    (GL_LINK_WARNING ("endusershell is unportable - " \
+                      "use gnulib module getusershell for portability"), \
+     endusershell ())
+#endif
+
+
 #if @GNULIB_LCHOWN@
 # if @REPLACE_LCHOWN@
 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
@@ -331,6 +528,22 @@ extern unsigned int sleep (unsigned int 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);
+#endif
+
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/gnulib/lib/vasnprintf.c b/gnulib/lib/vasnprintf.c
index 495f9ad..f1e6ac6 100644
--- a/gnulib/lib/vasnprintf.c
+++ b/gnulib/lib/vasnprintf.c
@@ -215,7 +215,7 @@ local_wcslen (const wchar_t *s)
 #undef remainder
 #define remainder rem

-#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && !defined IN_LIBINTL
+#if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_INFINITE_LONG_DOUBLE || NEED_PRINTF_DOUBLE || NEED_PRINTF_INFINITE_DOUBLE) && !defined IN_LIBINTL
 /* Determine the decimal-point character according to the current locale.  */
 # ifndef decimal_point_char_defined
 #  define decimal_point_char_defined 1
@@ -255,11 +255,11 @@ is_infinite_or_zero (double x)

 #if NEED_PRINTF_INFINITE_LONG_DOUBLE && !NEED_PRINTF_LONG_DOUBLE && !defined IN_LIBINTL

-/* Equivalent to !isfinite(x), but does not require libm.  */
+/* Equivalent to !isfinite(x) || x == 0, but does not require libm.  */
 static int
-is_infinitel (long double x)
+is_infinite_or_zerol (long double x)
 {
-  return isnanl (x) || (x + x == x && x != 0.0L);
+  return isnanl (x) || x + x == x;
 }

 #endif
@@ -2578,8 +2578,10 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
 # elif NEED_PRINTF_INFINITE_LONG_DOUBLE
 			 || (a.arg[dp->arg_index].type == TYPE_LONGDOUBLE
 			     /* Some systems produce wrong output for Inf,
-				-Inf, and NaN.  */
-			     && is_infinitel (a.arg[dp->arg_index].a.a_longdouble))
+				-Inf, and NaN.  Some systems in this category
+				(IRIX 5.3) also do so for -0.0.  Therefore we
+				treat this case here as well.  */
+			     && is_infinite_or_zerol (a.arg[dp->arg_index].a.a_longdouble))
 # endif
 			))
 	      {
@@ -2661,9 +2663,11 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,

 		/* POSIX specifies the default precision to be 6 for %f, %F,
 		   %e, %E, but not for %g, %G.  Implementations appear to use
-		   the same default precision also for %g, %G.  */
+		   the same default precision also for %g, %G.  But for %a, %A,
+		   the default precision is 0.  */
 		if (!has_precision)
-		  precision = 6;
+		  if (!(dp->conversion == 'a' || dp->conversion == 'A'))
+		    precision = 6;

 		/* Allocate a temporary buffer of sufficient size.  */
 # if NEED_PRINTF_DOUBLE && NEED_PRINTF_LONG_DOUBLE
@@ -3139,7 +3143,65 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
 			      abort ();
 #  else
 			    /* arg is finite.  */
-			    abort ();
+			    if (!(arg == 0.0L))
+			      abort ();
+
+			    pad_ptr = p;
+
+			    if (dp->conversion == 'f' || dp->conversion == 'F')
+			      {
+				*p++ = '0';
+				if ((flags & FLAG_ALT) || precision > 0)
+				  {
+				    *p++ = decimal_point_char ();
+				    for (; precision > 0; precision--)
+				      *p++ = '0';
+				  }
+			      }
+			    else if (dp->conversion == 'e' || dp->conversion == 'E')
+			      {
+				*p++ = '0';
+				if ((flags & FLAG_ALT) || precision > 0)
+				  {
+				    *p++ = decimal_point_char ();
+				    for (; precision > 0; precision--)
+				      *p++ = '0';
+				  }
+				*p++ = dp->conversion; /* 'e' or 'E' */
+				*p++ = '+';
+				*p++ = '0';
+				*p++ = '0';
+			      }
+			    else if (dp->conversion == 'g' || dp->conversion == 'G')
+			      {
+				*p++ = '0';
+				if (flags & FLAG_ALT)
+				  {
+				    size_t ndigits =
+				      (precision > 0 ? precision - 1 : 0);
+				    *p++ = decimal_point_char ();
+				    for (; ndigits > 0; --ndigits)
+				      *p++ = '0';
+				  }
+			      }
+			    else if (dp->conversion == 'a' || dp->conversion == 'A')
+			      {
+				*p++ = '0';
+				*p++ = dp->conversion - 'A' + 'X';
+				pad_ptr = p;
+				*p++ = '0';
+				if ((flags & FLAG_ALT) || precision > 0)
+				  {
+				    *p++ = decimal_point_char ();
+				    for (; precision > 0; precision--)
+				      *p++ = '0';
+				  }
+				*p++ = dp->conversion - 'A' + 'P';
+				*p++ = '+';
+				*p++ = '0';
+			      }
+			    else
+			      abort ();
 #  endif
 			  }

@@ -4176,7 +4238,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp,
 		      abort ();
 		    prefixes[prefix_count++] = a.arg[dp->width_arg_index].a.a_int;
 		  }
-		if (dp->precision_arg_index != ARG_NONE)
+		if (!prec_ourselves && dp->precision_arg_index != ARG_NONE)
 		  {
 		    if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
 		      abort ();
diff --git a/gnulib/lib/w32sock.h b/gnulib/lib/w32sock.h
new file mode 100644
index 0000000..12977f7
--- /dev/null
+++ b/gnulib/lib/w32sock.h
@@ -0,0 +1,62 @@
+/* w32sock.h --- internal auxilliary functions for Windows socket functions
+
+   Copyright (C) 2008 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.1 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 Paolo Bonzini */
+
+#include <errno.h>
+
+/* Get O_RDWR and O_BINARY.  */
+#include <fcntl.h>
+
+/* Get _get_osfhandle() and _open_osfhandle().  */
+#include <io.h>
+
+#define FD_TO_SOCKET(fd)   ((SOCKET) _get_osfhandle ((fd)))
+#define SOCKET_TO_FD(fh)   (_open_osfhandle ((long) (fh), O_RDWR | O_BINARY))
+
+static inline void
+set_winsock_errno (void)
+{
+  int err = WSAGetLastError ();
+  WSASetLastError (0);
+
+  /* Map some WSAE* errors to the runtime library's error codes.  */
+  switch (err)
+    {
+    case WSA_INVALID_HANDLE:
+      errno = EBADF;
+      break;
+    case WSA_NOT_ENOUGH_MEMORY:
+      errno = ENOMEM;
+      break;
+    case WSA_INVALID_PARAMETER:
+      errno = EINVAL;
+      break;
+    case WSAEWOULDBLOCK:
+      errno = EWOULDBLOCK;
+      break;
+    case WSAENAMETOOLONG:
+      errno = ENAMETOOLONG;
+      break;
+    case WSAENOTEMPTY:
+      errno = ENOTEMPTY;
+      break;
+    default:
+      errno = (err > 10000 && err < 10025) ? err - 10000 : err;
+      break;
+    }
+}
diff --git a/gnulib/lib/wchar.in.h b/gnulib/lib/wchar.in.h
index 7358871..652ca6e 100644
--- a/gnulib/lib/wchar.in.h
+++ b/gnulib/lib/wchar.in.h
@@ -26,6 +26,10 @@
  * the declaration of wcwidth().
  */

+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+
 #ifdef __need_mbstate_t
 /* Special invocation convention inside uClibc header files.  */

@@ -61,6 +65,12 @@ extern "C" {
 #endif


+/* Define wint_t.  (Also done in wctype.in.h.)  */
+#if !@HAVE_WINT_T@ && !defined wint_t
+# define wint_t int
+#endif
+
+
 /* Return the number of screen columns needed for WC.  */
 #if @GNULIB_WCWIDTH@
 # if @REPLACE_WCWIDTH@
diff --git a/gnulib/m4/arpa_inet_h.m4 b/gnulib/m4/arpa_inet_h.m4
index 20bd3bc..a6e63df 100644
--- a/gnulib/m4/arpa_inet_h.m4
+++ b/gnulib/m4/arpa_inet_h.m4
@@ -1,4 +1,4 @@
-# arpa_inet_h.m4 serial 4
+# arpa_inet_h.m4 serial 5
 dnl Copyright (C) 2006, 2008 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,6 +25,13 @@ AC_DEFUN([gl_HEADER_ARPA_INET],
   gl_CHECK_NEXT_HEADERS([arpa/inet.h])
 ])

+dnl Unconditionally enables the replacement of <arpa/inet.h>.
+AC_DEFUN([gl_REPLACE_ARPA_INET_H],
+[
+  AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS])
+  ARPA_INET_H='arpa/inet.h'
+])
+
 AC_DEFUN([gl_ARPA_INET_MODULE_INDICATOR],
 [
   dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
diff --git a/gnulib/m4/close.m4 b/gnulib/m4/close.m4
new file mode 100644
index 0000000..fcc9fb1
--- /dev/null
+++ b/gnulib/m4/close.m4
@@ -0,0 +1,25 @@
+# close.m4 serial 2
+dnl Copyright (C) 2008 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_CLOSE],
+[
+  m4_ifdef([gl_PREREQ_SYS_H_WINSOCK2], [
+    gl_PREREQ_SYS_H_WINSOCK2
+    if test $UNISTD_H_HAVE_WINSOCK2_H = 1; then
+      gl_REPLACE_CLOSE
+    fi
+  ])
+])
+
+AC_DEFUN([gl_REPLACE_CLOSE],
+[
+  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+  if test $REPLACE_CLOSE != 1; then
+    AC_LIBOBJ([close])
+  fi
+  REPLACE_CLOSE=1
+  gl_REPLACE_FCLOSE
+])
diff --git a/gnulib/m4/eoverflow.m4 b/gnulib/m4/eoverflow.m4
deleted file mode 100644
index 3bffd10..0000000
--- a/gnulib/m4/eoverflow.m4
+++ /dev/null
@@ -1,70 +0,0 @@
-# eoverflow.m4 serial 2
-dnl Copyright (C) 2004, 2006 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.
-
-# The EOVERFLOW errno value ought to be defined in <errno.h>, according to
-# POSIX.  But some systems (like AIX 3) don't define it, and some systems
-# (like OSF/1) define it when _XOPEN_SOURCE_EXTENDED is defined.
-
-# Define EOVERFLOW as a C macro and as a substituted macro in such a way that
-# 1. on all systems, after inclusion of <errno.h>, EOVERFLOW is usable,
-# 2. on systems where EOVERFLOW is defined elsewhere, we use the same numeric
-#    value.
-
-AC_DEFUN([gl_EOVERFLOW],
-[
-  AC_REQUIRE([AC_PROG_CC])dnl
-
-  AC_CACHE_CHECK([for EOVERFLOW], ac_cv_decl_EOVERFLOW, [
-    AC_EGREP_CPP(yes,[
-#include <errno.h>
-#ifdef EOVERFLOW
-yes
-#endif
-      ], have_eoverflow=1)
-    if test -n "$have_eoverflow"; then
-      dnl EOVERFLOW exists in <errno.h>. Don't need to define EOVERFLOW ourselves.
-      ac_cv_decl_EOVERFLOW=yes
-    else
-      AC_EGREP_CPP(yes,[
-#define _XOPEN_SOURCE_EXTENDED 1
-#include <errno.h>
-#ifdef EOVERFLOW
-yes
-#endif
-        ], have_eoverflow=1)
-      if test -n "$have_eoverflow"; then
-        dnl EOVERFLOW exists but is hidden.
-        dnl Define it to the same value.
-        AC_COMPUTE_INT([ac_cv_decl_EOVERFLOW], [EOVERFLOW], [
-#define _XOPEN_SOURCE_EXTENDED 1
-#include <errno.h>
-/* The following two lines are a workaround against an autoconf-2.52 bug.  */
-#include <stdio.h>
-#include <stdlib.h>
-])
-      else
-        dnl EOVERFLOW isn't defined by the system. Define EOVERFLOW ourselves, but
-        dnl don't define it as EINVAL, because snprintf() callers want to
-        dnl distinguish EINVAL and EOVERFLOW.
-        ac_cv_decl_EOVERFLOW=E2BIG
-      fi
-    fi
-  ])
-  if test "$ac_cv_decl_EOVERFLOW" != yes; then
-    AC_DEFINE_UNQUOTED([EOVERFLOW], [$ac_cv_decl_EOVERFLOW],
-                       [Define as good substitute value for EOVERFLOW.])
-    EOVERFLOW="$ac_cv_decl_EOVERFLOW"
-    AC_SUBST(EOVERFLOW)
-  fi
-])
-
-dnl Autoconf >= 2.61 has AC_COMPUTE_INT built-in.
-dnl Remove this when we can assume autoconf >= 2.61.
-m4_ifdef([AC_COMPUTE_INT], [], [
-  AC_DEFUN([AC_COMPUTE_INT], [_AC_COMPUTE_INT([$2],[$1],[$3],[$4])])
-])
diff --git a/gnulib/m4/errno_h.m4 b/gnulib/m4/errno_h.m4
new file mode 100644
index 0000000..b5af078
--- /dev/null
+++ b/gnulib/m4/errno_h.m4
@@ -0,0 +1,113 @@
+# errno_h.m4 serial 1
+dnl Copyright (C) 2004, 2006, 2008 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_HEADER_ERRNO_H],
+[
+  dnl Use AC_REQUIRE here, so that the default behavior below is expanded
+  dnl once only, before all statements that occur in other macros.
+  AC_REQUIRE([gl_HEADER_ERRNO_H_BODY])
+])
+
+AC_DEFUN([gl_HEADER_ERRNO_H_BODY],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_CACHE_CHECK([for complete errno.h], gl_cv_header_errno_h_complete, [
+    AC_EGREP_CPP(booboo,[
+#include <errno.h>
+#if !defined ENOMSG
+booboo
+#endif
+#if !defined EIDRM
+booboo
+#endif
+#if !defined ENOLINK
+booboo
+#endif
+#if !defined EPROTO
+booboo
+#endif
+#if !defined EMULTIHOP
+booboo
+#endif
+#if !defined EBADMSG
+booboo
+#endif
+#if !defined EOVERFLOW
+booboo
+#endif
+#if !defined ENOTSUP
+booboo
+#endif
+#if !defined ECANCELED
+booboo
+#endif
+      ],
+      [gl_cv_header_errno_h_complete=no],
+      [gl_cv_header_errno_h_complete=yes])
+  ])
+  if test $gl_cv_header_errno_h_complete = yes; then
+    ERRNO_H=''
+  else
+    gl_CHECK_NEXT_HEADERS([errno.h])
+    ERRNO_H='errno.h'
+  fi
+  AC_SUBST([ERRNO_H])
+  gl_REPLACE_ERRNO_VALUE([EMULTIHOP])
+  gl_REPLACE_ERRNO_VALUE([ENOLINK])
+  gl_REPLACE_ERRNO_VALUE([EOVERFLOW])
+])
+
+# Assuming $1 = EOVERFLOW.
+# The EOVERFLOW errno value ought to be defined in <errno.h>, according to
+# POSIX.  But some systems (like OpenBSD 4.0 or AIX 3) don't define it, and
+# some systems (like OSF/1) define it when _XOPEN_SOURCE_EXTENDED is defined.
+# Check for the value of EOVERFLOW.
+# Set the variables EOVERFLOW_HIDDEN and EOVERFLOW_VALUE.
+AC_DEFUN([gl_REPLACE_ERRNO_VALUE],
+[
+  if test -n "$ERRNO_H"; then
+    AC_CACHE_CHECK([for ]$1[ value], [gl_cv_header_errno_h_]$1, [
+      AC_EGREP_CPP(yes,[
+#include <errno.h>
+#ifdef ]$1[
+yes
+#endif
+      ],
+      [gl_cv_header_errno_h_]$1[=yes],
+      [gl_cv_header_errno_h_]$1[=no])
+      if test $gl_cv_header_errno_h_]$1[ = no; then
+        AC_EGREP_CPP(yes,[
+#define _XOPEN_SOURCE_EXTENDED 1
+#include <errno.h>
+#ifdef ]$1[
+yes
+#endif
+          ], [gl_cv_header_errno_h_]$1[=hidden])
+        if test $gl_cv_header_errno_h_]$1[ = hidden; then
+          dnl The macro exists but is hidden.
+          dnl Define it to the same value.
+          AC_COMPUTE_INT([gl_cv_header_errno_h_]$1, $1, [
+#define _XOPEN_SOURCE_EXTENDED 1
+#include <errno.h>
+/* The following two lines are a workaround against an autoconf-2.52 bug.  */
+#include <stdio.h>
+#include <stdlib.h>
+])
+        fi
+      fi
+    ])
+    case $gl_cv_header_errno_h_]$1[ in
+      yes | no)
+        ]$1[_HIDDEN=0; ]$1[_VALUE=
+        ;;
+      *)
+        ]$1[_HIDDEN=1; ]$1[_VALUE="$gl_cv_header_errno_h_]$1["
+        ;;
+    esac
+    AC_SUBST($1[_HIDDEN])
+    AC_SUBST($1[_VALUE])
+  fi
+])
diff --git a/gnulib/m4/fclose.m4 b/gnulib/m4/fclose.m4
new file mode 100644
index 0000000..d10c104
--- /dev/null
+++ b/gnulib/m4/fclose.m4
@@ -0,0 +1,18 @@
+# fclose.m4 serial 1
+dnl Copyright (C) 2008 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_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
+])
diff --git a/gnulib/m4/getaddrinfo.m4 b/gnulib/m4/getaddrinfo.m4
index 5d36c19..c184c6f 100644
--- a/gnulib/m4/getaddrinfo.m4
+++ b/gnulib/m4/getaddrinfo.m4
@@ -1,5 +1,5 @@
-# getaddrinfo.m4 serial 15
-dnl Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+# getaddrinfo.m4 serial 16
+dnl Copyright (C) 2004, 2005, 2006, 2007, 2008 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.
@@ -7,10 +7,9 @@ dnl with or without modifications, as long as this notice is preserved.
 AC_DEFUN([gl_GETADDRINFO],
 [
   AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
+  AC_REQUIRE([gl_HEADER_NETDB])dnl for HAVE_NETDB_H
   AC_MSG_NOTICE([checking how to do getaddrinfo, freeaddrinfo and getnameinfo])

-  AC_CHECK_HEADERS_ONCE(netdb.h)
-
   AC_SEARCH_LIBS(getaddrinfo, [nsl socket])
   AC_CACHE_CHECK([for getaddrinfo], [gl_cv_func_getaddrinfo], [
     AC_TRY_LINK([
@@ -72,7 +71,7 @@ AC_DEFUN([gl_GETADDRINFO],
   gl_PREREQ_GETADDRINFO
 ])

-# Prerequisites of lib/getaddrinfo.h and lib/getaddrinfo.c.
+# Prerequisites of lib/getaddrinfo.c.
 AC_DEFUN([gl_PREREQ_GETADDRINFO], [
   AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
   AC_SEARCH_LIBS(gethostbyname, [inet nsl])
@@ -99,7 +98,12 @@ AC_DEFUN([gl_PREREQ_GETADDRINFO], [
   AC_REQUIRE([gl_HEADER_SYS_SOCKET])
   AC_REQUIRE([AC_C_INLINE])
   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
-  AC_CHECK_HEADERS_ONCE(netinet/in.h netdb.h)
+
+  dnl Including sys/socket.h is wrong for Windows, but Windows does not
+  dnl have sa_len so the result is correct anyway.
+  AC_CHECK_MEMBERS([struct sockaddr.sa_len], , , [#include <sys/socket.h>])
+
+  AC_CHECK_HEADERS_ONCE(netinet/in.h)
   AC_CHECK_DECLS([getaddrinfo, freeaddrinfo, gai_strerror, getnameinfo],,,[
   /* sys/types.h is not needed according to POSIX, but the
      sys/socket.h in i386-unknown-freebsd4.10 and
diff --git a/gnulib/m4/getdelim.m4 b/gnulib/m4/getdelim.m4
index 18b96be..7760f82 100644
--- a/gnulib/m4/getdelim.m4
+++ b/gnulib/m4/getdelim.m4
@@ -31,4 +31,5 @@ AC_DEFUN([gl_FUNC_GETDELIM],
 AC_DEFUN([gl_PREREQ_GETDELIM],
 [
   AC_CHECK_FUNCS([flockfile funlockfile])
+  AC_CHECK_DECLS([getc_unlocked])
 ])
diff --git a/gnulib/m4/gethostname.m4 b/gnulib/m4/gethostname.m4
new file mode 100644
index 0000000..217f9c1
--- /dev/null
+++ b/gnulib/m4/gethostname.m4
@@ -0,0 +1,21 @@
+# gethostname.m4 serial 4
+dnl Copyright (C) 2002, 2008 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_GETHOSTNAME],
+[
+  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+  gl_PREREQ_SYS_H_WINSOCK2
+  AC_REPLACE_FUNCS(gethostname)
+  if test $ac_cv_func_gethostname = no; then
+    HAVE_GETHOSTNAME=0
+    gl_PREREQ_GETHOSTNAME
+  fi
+])
+
+# Prerequisites of lib/gethostname.c.
+AC_DEFUN([gl_PREREQ_GETHOSTNAME], [
+  AC_CHECK_FUNCS(uname)
+])
diff --git a/gnulib/m4/gnulib-cache.m4 b/gnulib/m4/gnulib-cache.m4
index ac9e993..d635f85 100644
--- a/gnulib/m4/gnulib-cache.m4
+++ b/gnulib/m4/gnulib-cache.m4
@@ -15,21 +15,30 @@


 # Specification in the form of a command-line invocation:
-#   gnulib-tool --import --dir=. --lib=libgnu --source-base=gnulib/lib --m4-base=gnulib/m4 --doc-base=doc --aux-dir=build-aux --with-tests --lgpl=2 --libtool --macro-prefix=gl c-ctype getaddrinfo getpass gettext inet_pton mkstemp mktempd physmem poll posix-shell strndup strsep sys_stat useless-if-before-free vasprintf vc-list-files verify
+#   gnulib-tool --import --dir=. --lib=libgnu --source-base=gnulib/lib --m4-base=gnulib/m4 --doc-base=doc --tests-base=gnulib/tests --aux-dir=build-aux --with-tests --lgpl=2 --libtool --macro-prefix=gl c-ctype close connect getaddrinfo gethostname getpass gettext inet_pton mkstemp mktempd perror physmem poll posix-shell recv send setsockopt socket strerror strndup strsep sys_stat useless-if-before-free vasprintf vc-list-files verify

 # Specification in the form of a few gnulib-tool.m4 macro invocations:
 gl_LOCAL_DIR([])
 gl_MODULES([
   c-ctype
+  close
+  connect
   getaddrinfo
+  gethostname
   getpass
   gettext
   inet_pton
   mkstemp
   mktempd
+  perror
   physmem
   poll
   posix-shell
+  recv
+  send
+  setsockopt
+  socket
+  strerror
   strndup
   strsep
   sys_stat
diff --git a/gnulib/m4/gnulib-common.m4 b/gnulib/m4/gnulib-common.m4
index 34d91c7..c73db14 100644
--- a/gnulib/m4/gnulib-common.m4
+++ b/gnulib/m4/gnulib-common.m4
@@ -1,4 +1,4 @@
-# gnulib-common.m4 serial 5
+# gnulib-common.m4 serial 6
 dnl Copyright (C) 2007-2008 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -21,6 +21,16 @@ AC_DEFUN([gl_COMMON_BODY], [
 #if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined __cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__
 # 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.  */
+#if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
+# define _UNUSED_PARAMETER_ __attribute__ ((__unused__))
+#else
+# define _UNUSED_PARAMETER_
+#endif
+])
 ])

 # gl_MODULE_INDICATOR([modulename])
diff --git a/gnulib/m4/gnulib-comp.m4 b/gnulib/m4/gnulib-comp.m4
index dbbaaa6..895ab2a 100644
--- a/gnulib/m4/gnulib-comp.m4
+++ b/gnulib/m4/gnulib-comp.m4
@@ -43,16 +43,32 @@ AC_DEFUN([gl_INIT],
   m4_pushdef([gl_LIBSOURCES_DIR], [])
   gl_COMMON
   gl_source_base='gnulib/lib'
-  gl_EOVERFLOW
+changequote(,)dnl
+LTALLOCA=`echo "$ALLOCA" | sed 's/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'`
+changequote([, ])dnl
+AC_SUBST([LTALLOCA])
   gl_FUNC_ALLOCA
   gl_HEADER_ARPA_INET
   AC_PROG_MKDIR_P
+  gl_FUNC_CLOSE
+  gl_UNISTD_MODULE_INDICATOR([close])
+  AC_REQUIRE([gl_HEADER_SYS_SOCKET])
+  if test "$ac_cv_header_winsock2_h" = yes; then
+    AC_LIBOBJ([connect])
+  fi
+  gl_SYS_SOCKET_MODULE_INDICATOR([connect])
+  gl_HEADER_ERRNO_H
+  gl_FUNC_FCLOSE
+  gl_STDIO_MODULE_INDICATOR([fclose])
   gl_FLOAT_H
   gl_FUNC_FSEEKO
   gl_STDIO_MODULE_INDICATOR([fseeko])
   gl_GETADDRINFO
+  gl_NETDB_MODULE_INDICATOR([getaddrinfo])
   gl_FUNC_GETDELIM
   gl_STDIO_MODULE_INDICATOR([getdelim])
+  gl_FUNC_GETHOSTNAME
+  gl_UNISTD_MODULE_INDICATOR([gethostname])
   gl_FUNC_GETLINE
   gl_STDIO_MODULE_INDICATOR([getline])
   gl_FUNC_GETPASS
@@ -67,27 +83,54 @@ AC_DEFUN([gl_INIT],
   gl_ARPA_INET_MODULE_INDICATOR([inet_pton])
   gl_FUNC_LSEEK
   gl_UNISTD_MODULE_INDICATOR([lseek])
+  gl_FUNC_LSTAT
+  gl_SYS_STAT_MODULE_INDICATOR([lstat])
   gl_FUNC_MALLOC_POSIX
   gl_STDLIB_MODULE_INDICATOR([malloc-posix])
   gl_FUNC_MKSTEMP
   gl_STDLIB_MODULE_INDICATOR([mkstemp])
+  gl_HEADER_NETDB
   gl_HEADER_NETINET_IN
   AC_PROG_MKDIR_P
+  gl_FUNC_PERROR
+  gl_STRING_MODULE_INDICATOR([perror])
   gl_PHYSMEM
   gl_FUNC_POLL
   gl_POSIX_SHELL
   gl_FUNC_REALLOC_POSIX
   gl_STDLIB_MODULE_INDICATOR([realloc-posix])
+  AC_REQUIRE([gl_HEADER_SYS_SOCKET])
+  if test "$ac_cv_header_winsock2_h" = yes; then
+    AC_LIBOBJ([recv])
+  fi
+  gl_SYS_SOCKET_MODULE_INDICATOR([recv])
+  AC_REQUIRE([gl_HEADER_SYS_SOCKET])
+  if test "$ac_cv_header_winsock2_h" = yes; then
+    AC_LIBOBJ([send])
+  fi
+  gl_SYS_SOCKET_MODULE_INDICATOR([send])
+  AC_REQUIRE([gl_HEADER_SYS_SOCKET])
+  if test "$ac_cv_header_winsock2_h" = yes; then
+    AC_LIBOBJ([setsockopt])
+  fi
+  gl_SYS_SOCKET_MODULE_INDICATOR([setsockopt])
   gl_SIZE_MAX
   gl_FUNC_SNPRINTF
   gl_STDIO_MODULE_INDICATOR([snprintf])
+  AC_REQUIRE([gl_HEADER_SYS_SOCKET])
+  if test "$ac_cv_header_winsock2_h" = yes; then
+    AC_LIBOBJ([socket])
+  fi
+  gl_SYS_SOCKET_MODULE_INDICATOR([socket])
   gl_TYPE_SOCKLEN_T
   AM_STDBOOL_H
   gl_STDINT_H
   gl_STDIO_H
   gl_STDLIB_H
-  gl_FUNC_STRDUP
+  gl_FUNC_STRDUP_POSIX
   gl_STRING_MODULE_INDICATOR([strdup])
+  gl_FUNC_STRERROR
+  gl_STRING_MODULE_INDICATOR([strerror])
   gl_HEADER_STRING_H
   gl_FUNC_STRNDUP
   gl_STRING_MODULE_INDICATOR([strndup])
@@ -100,6 +143,7 @@ AC_DEFUN([gl_INIT],
   gl_HEADER_SYS_SELECT
   AC_PROG_MKDIR_P
   gl_HEADER_SYS_SOCKET
+  gl_MODULE_INDICATOR([sys_socket])
   AC_PROG_MKDIR_P
   gl_HEADER_SYS_STAT_H
   AC_PROG_MKDIR_P
@@ -154,8 +198,34 @@ AC_DEFUN([gl_INIT],
   m4_pushdef([gltests_LIBSOURCES_DIR], [])
   gl_COMMON
   gl_source_base='gnulib/tests'
+  AC_REQUIRE([gl_HEADER_SYS_SOCKET])
+  if test "$ac_cv_header_winsock2_h" = yes; then
+    AC_LIBOBJ([accept])
+  fi
+  gl_SYS_SOCKET_MODULE_INDICATOR([accept])
+  AC_REQUIRE([gl_HEADER_SYS_SOCKET])
+  if test "$ac_cv_header_winsock2_h" = yes; then
+    AC_LIBOBJ([bind])
+  fi
+  gl_SYS_SOCKET_MODULE_INDICATOR([bind])
+  AC_REQUIRE([gl_HEADER_SYS_SOCKET])
+  if test "$ac_cv_header_winsock2_h" = yes; then
+    AC_LIBOBJ([ioctl])
+    gl_REPLACE_SYS_IOCTL_H
+  fi
+  gl_SYS_IOCTL_MODULE_INDICATOR([ioctl])
+  gl_MODULE_INDICATOR([ioctl])
+  AC_REQUIRE([gl_HEADER_SYS_SOCKET])
+  if test "$ac_cv_header_winsock2_h" = yes; then
+    AC_LIBOBJ([listen])
+  fi
+  gl_SYS_SOCKET_MODULE_INDICATOR([listen])
+  AC_CHECK_HEADERS_ONCE([unistd.h sys/wait.h])
+  gl_SOCKETS
   gt_TYPE_WCHAR_T
   gt_TYPE_WINT_T
+  gl_SYS_IOCTL_H
+  AC_PROG_MKDIR_P
   AC_CHECK_FUNCS([shutdown])
   abs_aux_dir=`cd "$ac_aux_dir"; pwd`
   AC_SUBST([abs_aux_dir])
@@ -255,19 +325,24 @@ AC_DEFUN([gl_FILE_LIST], [
   build-aux/mktempd
   build-aux/useless-if-before-free
   build-aux/vc-list-files
+  lib/alloca.c
   lib/alloca.in.h
   lib/arpa_inet.in.h
   lib/asnprintf.c
   lib/asprintf.c
   lib/c-ctype.c
   lib/c-ctype.h
+  lib/close.c
+  lib/connect.c
+  lib/errno.in.h
+  lib/fclose.c
   lib/float+.h
   lib/float.in.h
   lib/fseeko.c
   lib/gai_strerror.c
   lib/getaddrinfo.c
-  lib/getaddrinfo.h
   lib/getdelim.c
+  lib/gethostname.c
   lib/getline.c
   lib/getpass.c
   lib/getpass.h
@@ -275,10 +350,14 @@ AC_DEFUN([gl_FILE_LIST], [
   lib/gettimeofday.c
   lib/inet_ntop.c
   lib/inet_pton.c
+  lib/intprops.h
   lib/lseek.c
+  lib/lstat.c
   lib/malloc.c
   lib/mkstemp.c
+  lib/netdb.in.h
   lib/netinet_in.in.h
+  lib/perror.c
   lib/physmem.c
   lib/physmem.h
   lib/poll.c
@@ -288,14 +367,20 @@ AC_DEFUN([gl_FILE_LIST], [
   lib/printf-parse.c
   lib/printf-parse.h
   lib/realloc.c
+  lib/recv.c
+  lib/send.c
+  lib/setsockopt.c
   lib/size_max.h
   lib/snprintf.c
+  lib/socket.c
   lib/stdbool.in.h
   lib/stdint.in.h
   lib/stdio-impl.h
+  lib/stdio-write.c
   lib/stdio.in.h
   lib/stdlib.in.h
   lib/strdup.c
+  lib/strerror.c
   lib/string.in.h
   lib/strndup.c
   lib/strnlen.c
@@ -312,17 +397,21 @@ AC_DEFUN([gl_FILE_LIST], [
   lib/vasnprintf.h
   lib/vasprintf.c
   lib/verify.h
+  lib/w32sock.h
   lib/wchar.in.h
   lib/xsize.h
   m4/alloca.m4
   m4/arpa_inet_h.m4
+  m4/close.m4
   m4/codeset.m4
-  m4/eoverflow.m4
+  m4/errno_h.m4
   m4/extensions.m4
+  m4/fclose.m4
   m4/float_h.m4
   m4/fseeko.m4
   m4/getaddrinfo.m4
   m4/getdelim.m4
+  m4/gethostname.m4
   m4/getline.m4
   m4/getpass.m4
   m4/gettext.m4
@@ -349,11 +438,14 @@ AC_DEFUN([gl_FILE_LIST], [
   m4/lock.m4
   m4/longlong.m4
   m4/lseek.m4
+  m4/lstat.m4
   m4/malloc.m4
   m4/mkstemp.m4
+  m4/netdb_h.m4
   m4/netinet_in_h.m4
   m4/nls.m4
   m4/onceonly.m4
+  m4/perror.m4
   m4/physmem.m4
   m4/po.m4
   m4/poll.m4
@@ -364,6 +456,7 @@ AC_DEFUN([gl_FILE_LIST], [
   m4/realloc.m4
   m4/size_max.m4
   m4/snprintf.m4
+  m4/sockets.m4
   m4/socklen.m4
   m4/sockpfaf.m4
   m4/stdbool.m4
@@ -372,16 +465,19 @@ AC_DEFUN([gl_FILE_LIST], [
   m4/stdio_h.m4
   m4/stdlib_h.m4
   m4/strdup.m4
+  m4/strerror.m4
   m4/string_h.m4
   m4/strndup.m4
   m4/strnlen.m4
   m4/strpbrk.m4
   m4/strsep.m4
+  m4/sys_ioctl_h.m4
   m4/sys_select_h.m4
   m4/sys_socket_h.m4
   m4/sys_stat_h.m4
   m4/sys_time_h.m4
   m4/tempname.m4
+  m4/threadlib.m4
   m4/uintmax_t.m4
   m4/unistd_h.m4
   m4/vasnprintf.m4
@@ -391,24 +487,32 @@ AC_DEFUN([gl_FILE_LIST], [
   m4/wchar_t.m4
   m4/wint_t.m4
   m4/xsize.m4
-  tests/test-EOVERFLOW.c
   tests/test-alloca-opt.c
   tests/test-arpa_inet.c
   tests/test-c-ctype.c
+  tests/test-errno.c
   tests/test-fseeko.c
   tests/test-fseeko.sh
   tests/test-getaddrinfo.c
   tests/test-getdelim.c
+  tests/test-gethostname.c
   tests/test-getline.c
   tests/test-gettimeofday.c
   tests/test-lseek.c
   tests/test-lseek.sh
+  tests/test-lstat.c
+  tests/test-netdb.c
   tests/test-netinet_in.c
+  tests/test-perror.c
+  tests/test-perror.sh
+  tests/test-poll.c
   tests/test-snprintf.c
+  tests/test-sockets.c
   tests/test-stdbool.c
   tests/test-stdint.c
   tests/test-stdio.c
   tests/test-stdlib.c
+  tests/test-strerror.c
   tests/test-string.c
   tests/test-sys_select.c
   tests/test-sys_socket.c
@@ -420,6 +524,12 @@ AC_DEFUN([gl_FILE_LIST], [
   tests/test-vc-list-files-cvs.sh
   tests/test-vc-list-files-git.sh
   tests/test-wchar.c
-  tests=lib/dummy.c
-  tests=lib/intprops.h
+  tests=lib/accept.c
+  tests=lib/bind.c
+  tests=lib/ioctl.c
+  tests=lib/listen.c
+  tests=lib/sockets.c
+  tests=lib/sockets.h
+  tests=lib/sys_ioctl.in.h
+  tests=lib/w32sock.h
 ])
diff --git a/gnulib/m4/include_next.m4 b/gnulib/m4/include_next.m4
index a842e2a..b6e4d3a 100644
--- a/gnulib/m4/include_next.m4
+++ b/gnulib/m4/include_next.m4
@@ -1,4 +1,4 @@
-# include_next.m4 serial 6
+# include_next.m4 serial 8
 dnl Copyright (C) 2006-2008 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -6,6 +6,21 @@ dnl with or without modifications, as long as this notice is preserved.

 dnl From Paul Eggert and Derek Price.

+dnl Sets INCLUDE_NEXT and PRAGMA_SYSTEM_HEADER.
+dnl
+dnl INCLUDE_NEXT expands to 'include_next' if the compiler supports it, or to
+dnl 'include' otherwise.
+dnl
+dnl PRAGMA_SYSTEM_HEADER can be used in files that contain #include_next,
+dnl so as to avoid GCC warnings when the gcc option -pedantic is used.
+dnl '#pragma GCC system_header' has the same effect as if the file was found
+dnl through the include search path specified with '-isystem' options (as
+dnl opposed to the search path specified with '-I' options). Namely, gcc
+dnl does not warn about some things, and on some systems (Solaris and Interix)
+dnl __STDC__ evaluates to 0 instead of to 1. The latter is an undesired side
+dnl effect; we are therefore careful to use 'defined __STDC__' or '1' instead
+dnl of plain '__STDC__'.
+
 AC_DEFUN([gl_INCLUDE_NEXT],
 [
   AC_LANG_PREPROC_REQUIRE()
@@ -13,8 +28,12 @@ AC_DEFUN([gl_INCLUDE_NEXT],
     [gl_cv_have_include_next],
     [rm -rf conftestd1 conftestd2
      mkdir conftestd1 conftestd2
+     dnl The include of <stdio.h> is because IBM C 9.0 on AIX 6.1 supports
+     dnl include_next when used as first preprocessor directive in a file,
+     dnl but not when preceded by another include directive.
      cat <<EOF > conftestd1/conftest.h
 #define DEFINED_IN_CONFTESTD1
+#include <stdio.h>
 #include_next <conftest.h>
 #ifdef DEFINED_IN_CONFTESTD2
 int foo;
@@ -36,18 +55,17 @@ EOF
      CPPFLAGS="$save_CPPFLAGS"
      rm -rf conftestd1 conftestd2
     ])
+  PRAGMA_SYSTEM_HEADER=
   if test $gl_cv_have_include_next = yes; then
-
-    dnl FIXME: Remove HAVE_INCLUDE_NEXT and update everything that uses it
-    dnl to use @INCLUDE_NEXT@ instead.
-    AC_DEFINE([HAVE_INCLUDE_NEXT], 1,
-	      [Define if your compiler supports the #include_next directive.])
-
     INCLUDE_NEXT=include_next
+    if test -n "$GCC"; then
+      PRAGMA_SYSTEM_HEADER='#pragma GCC system_header'
+    fi
   else
     INCLUDE_NEXT=include
   fi
   AC_SUBST([INCLUDE_NEXT])
+  AC_SUBST([PRAGMA_SYSTEM_HEADER])
 ])

 # gl_CHECK_NEXT_HEADERS(HEADER1 HEADER2 ...)
diff --git a/gnulib/m4/inet_ntop.m4 b/gnulib/m4/inet_ntop.m4
index 25a3ee9..6f87306 100644
--- a/gnulib/m4/inet_ntop.m4
+++ b/gnulib/m4/inet_ntop.m4
@@ -1,4 +1,4 @@
-# inet_ntop.m4 serial 6
+# inet_ntop.m4 serial 7
 dnl Copyright (C) 2005, 2006, 2008 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,8 +9,7 @@ AC_DEFUN([gl_INET_NTOP],
   dnl Persuade Solaris <arpa/inet.h> to declare inet_ntop.
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])

-  AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS])
-  ARPA_INET_H='arpa/inet.h'
+  gl_REPLACE_ARPA_INET_H

   AC_REPLACE_FUNCS(inet_ntop)
   gl_PREREQ_INET_NTOP
diff --git a/gnulib/m4/inet_pton.m4 b/gnulib/m4/inet_pton.m4
index a72cd23..06331e9 100644
--- a/gnulib/m4/inet_pton.m4
+++ b/gnulib/m4/inet_pton.m4
@@ -1,4 +1,4 @@
-# inet_pton.m4 serial 5
+# inet_pton.m4 serial 6
 dnl Copyright (C) 2006, 2008 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,8 +9,7 @@ AC_DEFUN([gl_INET_PTON],
   dnl Persuade Solaris <arpa/inet.h> to declare inet_pton.
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])

-  AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS])
-  ARPA_INET_H='arpa/inet.h'
+  gl_REPLACE_ARPA_INET_H

   AC_REPLACE_FUNCS(inet_pton)
   gl_PREREQ_INET_PTON
diff --git a/gnulib/m4/lib-link.m4 b/gnulib/m4/lib-link.m4
index 1602895..7e07a42 100644
--- a/gnulib/m4/lib-link.m4
+++ b/gnulib/m4/lib-link.m4
@@ -1,4 +1,4 @@
-# lib-link.m4 serial 15 (gettext-0.18)
+# lib-link.m4 serial 16 (gettext-0.18)
 dnl Copyright (C) 2001-2008 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -194,6 +194,10 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
       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
 ])
@@ -352,7 +356,9 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
               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"; then
+              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
@@ -443,6 +449,11 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
                 LIB[]NAME[]_PREFIX="$basedir"
                 additional_includedir="$basedir/include"
                 ;;
+              */$acl_libdirstem2 | */$acl_libdirstem2/)
+                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'`
+                LIB[]NAME[]_PREFIX="$basedir"
+                additional_includedir="$basedir/include"
+                ;;
             esac
             if test "X$additional_includedir" != "X"; then
               dnl Potentially add $additional_includedir to $INCNAME.
@@ -501,9 +512,11 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
                     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"; then
+                    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"; then
+                      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;;
@@ -684,7 +697,8 @@ AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
         if test -n "$next"; then
           dir="$next"
           dnl No need to hardcode the standard /usr/lib.
-          if test "X$dir" != "X/usr/$acl_libdirstem"; then
+          if test "X$dir" != "X/usr/$acl_libdirstem" \
+             && test "X$dir" != "X/usr/$acl_libdirstem2"; then
             rpathdirs="$rpathdirs $dir"
           fi
           next=
@@ -693,7 +707,8 @@ AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
             -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"; then
+                 if test "X$dir" != "X/usr/$acl_libdirstem" \
+                    && test "X$dir" != "X/usr/$acl_libdirstem2"; then
                    rpathdirs="$rpathdirs $dir"
                  fi
                  next= ;;
diff --git a/gnulib/m4/lib-prefix.m4 b/gnulib/m4/lib-prefix.m4
index a8684e1..3bdc0fc 100644
--- a/gnulib/m4/lib-prefix.m4
+++ b/gnulib/m4/lib-prefix.m4
@@ -1,5 +1,5 @@
-# lib-prefix.m4 serial 5 (gettext-0.15)
-dnl Copyright (C) 2001-2005 Free Software Foundation, Inc.
+# lib-prefix.m4 serial 6 (gettext-0.18)
+dnl Copyright (C) 2001-2005, 2008 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.
@@ -153,33 +153,69 @@ AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX],
   prefix="$acl_save_prefix"
 ])

-dnl AC_LIB_PREPARE_MULTILIB creates a variable acl_libdirstem, containing
-dnl the basename of the libdir, either "lib" or "lib64".
+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. The current
-  dnl practice is that on a system supporting 32-bit and 64-bit instruction
-  dnl sets or ABIs, 64-bit libraries go under $prefix/lib64 and 32-bit
-  dnl libraries go under $prefix/lib. We determine the compiler's default
-  dnl mode by looking at the compiler's library search path. If at least
-  dnl of its elements ends in /lib64 or points to a directory whose absolute
-  dnl pathname ends in /lib64, we assume a 64-bit ABI. Otherwise we use the
-  dnl default, namely "lib".
+  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
-  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 ;;
-          *) searchdir=`cd "$searchdir" && pwd`
-             case "$searchdir" in
-               */lib64 ) acl_libdirstem=lib64 ;;
-             esac ;;
+  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
-    done
-    IFS="$acl_save_IFS"
-  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 ;;
+              *) 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/gnulib/m4/lock.m4 b/gnulib/m4/lock.m4
index d590289..9fec570 100644
--- a/gnulib/m4/lock.m4
+++ b/gnulib/m4/lock.m4
@@ -1,4 +1,4 @@
-# lock.m4 serial 8 (gettext-0.18)
+# lock.m4 serial 9 (gettext-0.18)
 dnl Copyright (C) 2005-2008 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -6,261 +6,28 @@ dnl with or without modifications, as long as this notice is preserved.

 dnl From Bruno Haible.

-dnl gl_LOCK
-dnl -------
-dnl Tests for a multithreading library to be used.
-dnl Defines at most one of the macros USE_POSIX_THREADS, USE_SOLARIS_THREADS,
-dnl USE_PTH_THREADS, USE_WIN32_THREADS
-dnl Sets the variables LIBTHREAD and LTLIBTHREAD to the linker options for use
-dnl in a Makefile (LIBTHREAD for use without libtool, LTLIBTHREAD for use with
-dnl libtool).
-dnl Sets the variables LIBMULTITHREAD and LTLIBMULTITHREAD similarly, for
-dnl programs that really need multithread functionality. The difference
-dnl between LIBTHREAD and LIBMULTITHREAD is that on platforms supporting weak
-dnl symbols, typically LIBTHREAD="" whereas LIBMULTITHREAD="-lpthread".
-dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for
-dnl multithread-safe programs.
-
-AC_DEFUN([gl_LOCK_EARLY],
-[
-  AC_REQUIRE([gl_LOCK_EARLY_BODY])
-])
-
-dnl The guts of gl_LOCK_EARLY. Needs to be expanded only once.
-
-AC_DEFUN([gl_LOCK_EARLY_BODY],
-[
-  dnl Ordering constraints: This macro modifies CPPFLAGS in a way that
-  dnl influences the result of the autoconf tests that test for *_unlocked
-  dnl declarations, on AIX 5 at least. Therefore it must come early.
-  AC_BEFORE([$0], [gl_FUNC_GLIBC_UNLOCKED_IO])dnl
-  AC_BEFORE([$0], [gl_ARGP])dnl
-
-  AC_REQUIRE([AC_CANONICAL_HOST])
-  dnl _GNU_SOURCE is needed for pthread_rwlock_t on glibc systems.
-  dnl AC_USE_SYSTEM_EXTENSIONS was introduced in autoconf 2.60 and obsoletes
-  dnl AC_GNU_SOURCE.
-  m4_ifdef([AC_USE_SYSTEM_EXTENSIONS],
-    [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])],
-    [AC_REQUIRE([AC_GNU_SOURCE])])
-  dnl Check for multithreading.
-  m4_divert_text([DEFAULTS], [gl_use_threads_default=])
-  AC_ARG_ENABLE(threads,
-AC_HELP_STRING([--enable-threads={posix|solaris|pth|win32}], [specify multithreading API])
-AC_HELP_STRING([--disable-threads], [build without multithread safety]),
-    [gl_use_threads=$enableval],
-    [if test -n "$gl_use_threads_default"; then
-       gl_use_threads="$gl_use_threads_default"
-     else
-       case "$host_os" in
-         dnl Disable multithreading by default on OSF/1, because it interferes
-         dnl with fork()/exec(): When msgexec is linked with -lpthread, its
-         dnl child process gets an endless segmentation fault inside execvp().
-         osf*) gl_use_threads=no ;;
-         *)    gl_use_threads=yes ;;
-       esac
-     fi
-    ])
-  if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then
-    # For using <pthread.h>:
-    case "$host_os" in
-      osf*)
-        # On OSF/1, the compiler needs the flag -D_REENTRANT so that it
-        # groks <pthread.h>. cc also understands the flag -pthread, but
-        # we don't use it because 1. gcc-2.95 doesn't understand -pthread,
-        # 2. putting a flag into CPPFLAGS that has an effect on the linker
-        # causes the AC_TRY_LINK test below to succeed unexpectedly,
-        # leading to wrong values of LIBTHREAD and LTLIBTHREAD.
-        CPPFLAGS="$CPPFLAGS -D_REENTRANT"
-        ;;
-    esac
-    # Some systems optimize for single-threaded programs by default, and
-    # need special flags to disable these optimizations. For example, the
-    # definition of 'errno' in <errno.h>.
-    case "$host_os" in
-      aix* | freebsd*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;;
-      solaris*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;;
-    esac
-  fi
-])
-
-dnl The guts of gl_LOCK. Needs to be expanded only once.
-
-AC_DEFUN([gl_LOCK_BODY],
+AC_DEFUN([gl_LOCK],
 [
-  AC_REQUIRE([gl_LOCK_EARLY_BODY])
-  gl_threads_api=none
-  LIBTHREAD=
-  LTLIBTHREAD=
-  LIBMULTITHREAD=
-  LTLIBMULTITHREAD=
-  if test "$gl_use_threads" != no; then
-    dnl Check whether the compiler and linker support weak declarations.
-    AC_MSG_CHECKING([whether imported symbols can be declared weak])
-    gl_have_weak=no
-    AC_TRY_LINK([extern void xyzzy ();
-#pragma weak xyzzy], [xyzzy();], [gl_have_weak=yes])
-    AC_MSG_RESULT([$gl_have_weak])
-    if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then
-      # On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that
-      # it groks <pthread.h>. It's added above, in gl_LOCK_EARLY_BODY.
-      AC_CHECK_HEADER(pthread.h, gl_have_pthread_h=yes, gl_have_pthread_h=no)
-      if test "$gl_have_pthread_h" = yes; then
-        # Other possible tests:
-        #   -lpthreads (FSU threads, PCthreads)
-        #   -lgthreads
-        gl_have_pthread=
-        # Test whether both pthread_mutex_lock and pthread_mutexattr_init exist
-        # in libc. IRIX 6.5 has the first one in both libc and libpthread, but
-        # the second one only in libpthread, and lock.c needs it.
-        AC_TRY_LINK([#include <pthread.h>],
-          [pthread_mutex_lock((pthread_mutex_t*)0);
-           pthread_mutexattr_init((pthread_mutexattr_t*)0);],
-          [gl_have_pthread=yes])
-        # Test for libpthread by looking for pthread_kill. (Not pthread_self,
-        # since it is defined as a macro on OSF/1.)
-        if test -n "$gl_have_pthread"; then
-          # The program links fine without libpthread. But it may actually
-          # need to link with libpthread in order to create multiple threads.
-          AC_CHECK_LIB(pthread, pthread_kill,
-            [LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread
-             # On Solaris and HP-UX, most pthread functions exist also in libc.
-             # Therefore pthread_in_use() needs to actually try to create a
-             # thread: pthread_create from libc will fail, whereas
-             # pthread_create will actually create a thread.
-             case "$host_os" in
-               solaris* | hpux*)
-                 AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], 1,
-                   [Define if the pthread_in_use() detection is hard.])
-             esac
-            ])
-        else
-          # Some library is needed. Try libpthread and libc_r.
-          AC_CHECK_LIB(pthread, pthread_kill,
-            [gl_have_pthread=yes
-             LIBTHREAD=-lpthread LTLIBTHREAD=-lpthread
-             LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread])
-          if test -z "$gl_have_pthread"; then
-            # For FreeBSD 4.
-            AC_CHECK_LIB(c_r, pthread_kill,
-              [gl_have_pthread=yes
-               LIBTHREAD=-lc_r LTLIBTHREAD=-lc_r
-               LIBMULTITHREAD=-lc_r LTLIBMULTITHREAD=-lc_r])
-          fi
-        fi
-        if test -n "$gl_have_pthread"; then
-          gl_threads_api=posix
-          AC_DEFINE([USE_POSIX_THREADS], 1,
-            [Define if the POSIX multithreading library can be used.])
-          if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then
-            if test $gl_have_weak = yes; then
-              AC_DEFINE([USE_POSIX_THREADS_WEAK], 1,
-                [Define if references to the POSIX multithreading library should be made weak.])
-              LIBTHREAD=
-              LTLIBTHREAD=
-            fi
-          fi
-          # OSF/1 4.0 and MacOS X 10.1 lack the pthread_rwlock_t type and the
-          # pthread_rwlock_* functions.
-          AC_CHECK_TYPE([pthread_rwlock_t],
-            [AC_DEFINE([HAVE_PTHREAD_RWLOCK], 1,
-               [Define if the POSIX multithreading library has read/write locks.])],
-            [],
-            [#include <pthread.h>])
-          # glibc defines PTHREAD_MUTEX_RECURSIVE as enum, not as a macro.
-          AC_TRY_COMPILE([#include <pthread.h>],
-            [#if __FreeBSD__ == 4
+  AC_REQUIRE([gl_THREADLIB])
+  if test "$gl_threads_api" = posix; then
+    # OSF/1 4.0 and MacOS X 10.1 lack the pthread_rwlock_t type and the
+    # pthread_rwlock_* functions.
+    AC_CHECK_TYPE([pthread_rwlock_t],
+      [AC_DEFINE([HAVE_PTHREAD_RWLOCK], 1,
+         [Define if the POSIX multithreading library has read/write locks.])],
+      [],
+      [#include <pthread.h>])
+    # glibc defines PTHREAD_MUTEX_RECURSIVE as enum, not as a macro.
+    AC_TRY_COMPILE([#include <pthread.h>],
+      [#if __FreeBSD__ == 4
 error "No, in FreeBSD 4.0 recursive mutexes actually don't work."
 #else
 int x = (int)PTHREAD_MUTEX_RECURSIVE;
 return !x;
 #endif],
-            [AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE], 1,
-               [Define if the <pthread.h> defines PTHREAD_MUTEX_RECURSIVE.])])
-        fi
-      fi
-    fi
-    if test -z "$gl_have_pthread"; then
-      if test "$gl_use_threads" = yes || test "$gl_use_threads" = solaris; then
-        gl_have_solaristhread=
-        gl_save_LIBS="$LIBS"
-        LIBS="$LIBS -lthread"
-        AC_TRY_LINK([#include <thread.h>
-#include <synch.h>],
-          [thr_self();],
-          [gl_have_solaristhread=yes])
-        LIBS="$gl_save_LIBS"
-        if test -n "$gl_have_solaristhread"; then
-          gl_threads_api=solaris
-          LIBTHREAD=-lthread
-          LTLIBTHREAD=-lthread
-          LIBMULTITHREAD="$LIBTHREAD"
-          LTLIBMULTITHREAD="$LTLIBTHREAD"
-          AC_DEFINE([USE_SOLARIS_THREADS], 1,
-            [Define if the old Solaris multithreading library can be used.])
-          if test $gl_have_weak = yes; then
-            AC_DEFINE([USE_SOLARIS_THREADS_WEAK], 1,
-              [Define if references to the old Solaris multithreading library should be made weak.])
-            LIBTHREAD=
-            LTLIBTHREAD=
-          fi
-        fi
-      fi
-    fi
-    if test "$gl_use_threads" = pth; then
-      gl_save_CPPFLAGS="$CPPFLAGS"
-      AC_LIB_LINKFLAGS(pth)
-      gl_have_pth=
-      gl_save_LIBS="$LIBS"
-      LIBS="$LIBS -lpth"
-      AC_TRY_LINK([#include <pth.h>], [pth_self();], gl_have_pth=yes)
-      LIBS="$gl_save_LIBS"
-      if test -n "$gl_have_pth"; then
-        gl_threads_api=pth
-        LIBTHREAD="$LIBPTH"
-        LTLIBTHREAD="$LTLIBPTH"
-        LIBMULTITHREAD="$LIBTHREAD"
-        LTLIBMULTITHREAD="$LTLIBTHREAD"
-        AC_DEFINE([USE_PTH_THREADS], 1,
-          [Define if the GNU Pth multithreading library can be used.])
-        if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then
-          if test $gl_have_weak = yes; then
-            AC_DEFINE([USE_PTH_THREADS_WEAK], 1,
-              [Define if references to the GNU Pth multithreading library should be made weak.])
-            LIBTHREAD=
-            LTLIBTHREAD=
-          fi
-        fi
-      else
-        CPPFLAGS="$gl_save_CPPFLAGS"
-      fi
-    fi
-    if test -z "$gl_have_pthread"; then
-      if test "$gl_use_threads" = yes || test "$gl_use_threads" = win32; then
-        if { case "$host_os" in
-               mingw*) true;;
-               *) false;;
-             esac
-           }; then
-          gl_threads_api=win32
-          AC_DEFINE([USE_WIN32_THREADS], 1,
-            [Define if the Win32 multithreading API can be used.])
-        fi
-      fi
-    fi
+      [AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE], 1,
+         [Define if the <pthread.h> defines PTHREAD_MUTEX_RECURSIVE.])])
   fi
-  AC_MSG_CHECKING([for multithread API to use])
-  AC_MSG_RESULT([$gl_threads_api])
-  AC_SUBST(LIBTHREAD)
-  AC_SUBST(LTLIBTHREAD)
-  AC_SUBST(LIBMULTITHREAD)
-  AC_SUBST(LTLIBMULTITHREAD)
-])
-
-AC_DEFUN([gl_LOCK],
-[
-  AC_REQUIRE([gl_LOCK_EARLY])
-  AC_REQUIRE([gl_LOCK_BODY])
   gl_PREREQ_LOCK
 ])

@@ -268,68 +35,3 @@ AC_DEFUN([gl_LOCK],
 AC_DEFUN([gl_PREREQ_LOCK], [
   AC_REQUIRE([AC_C_INLINE])
 ])
-
-
-dnl gl_DISABLE_THREADS
-dnl ------------------
-dnl Sets the gl_LOCK default so that threads are not used by default.
-dnl The user can still override it at installation time, by using the
-dnl configure option '--enable-threads'.
-
-AC_DEFUN([gl_DISABLE_THREADS], [
-  m4_divert_text([INIT_PREPARE], [gl_use_threads_default=no])
-])
-
-
-dnl Survey of platforms:
-dnl
-dnl Platform          Available   Compiler    Supports   test-lock
-dnl                   flavours    option      weak       result
-dnl ---------------   ---------   ---------   --------   ---------
-dnl Linux 2.4/glibc   posix       -lpthread       Y      OK
-dnl
-dnl GNU Hurd/glibc    posix
-dnl
-dnl FreeBSD 5.3       posix       -lc_r           Y
-dnl                   posix       -lkse ?         Y
-dnl                   posix       -lpthread ?     Y
-dnl                   posix       -lthr           Y
-dnl
-dnl FreeBSD 5.2       posix       -lc_r           Y
-dnl                   posix       -lkse           Y
-dnl                   posix       -lthr           Y
-dnl
-dnl FreeBSD 4.0,4.10  posix       -lc_r           Y      OK
-dnl
-dnl NetBSD 1.6        --
-dnl
-dnl OpenBSD 3.4       posix       -lpthread       Y      OK
-dnl
-dnl MacOS X 10.[123]  posix       -lpthread       Y      OK
-dnl
-dnl Solaris 7,8,9     posix       -lpthread       Y      Sol 7,8: 0.0; Sol 9: OK
-dnl                   solaris     -lthread        Y      Sol 7,8: 0.0; Sol 9: OK
-dnl
-dnl HP-UX 11          posix       -lpthread       N (cc) OK
-dnl                                               Y (gcc)
-dnl
-dnl IRIX 6.5          posix       -lpthread       Y      0.5
-dnl
-dnl AIX 4.3,5.1       posix       -lpthread       N      AIX 4: 0.5; AIX 5: OK
-dnl
-dnl OSF/1 4.0,5.1     posix       -pthread (cc)   N      OK
-dnl                               -lpthread (gcc) Y
-dnl
-dnl Cygwin            posix       -lpthread       Y      OK
-dnl
-dnl Any of the above  pth         -lpth                  0.0
-dnl
-dnl Mingw             win32                       N      OK
-dnl
-dnl BeOS 5            --
-dnl
-dnl The test-lock result shows what happens if in test-lock.c EXPLICIT_YIELD is
-dnl turned off:
-dnl   OK if all three tests terminate OK,
-dnl   0.5 if the first test terminates OK but the second one loops endlessly,
-dnl   0.0 if the first test already loops endlessly.
diff --git a/gnulib/m4/lstat.m4 b/gnulib/m4/lstat.m4
new file mode 100644
index 0000000..9ac109f
--- /dev/null
+++ b/gnulib/m4/lstat.m4
@@ -0,0 +1,23 @@
+#serial 17
+
+# Copyright (C) 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008
+# 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.
+
+dnl From Jim Meyering.
+
+AC_DEFUN([gl_FUNC_LSTAT],
+[
+  AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
+  AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
+  dnl Note: AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK does AC_LIBOBJ(lstat).
+  if test $ac_cv_func_lstat_dereferences_slashed_symlink = no; then
+    REPLACE_LSTAT=1
+  fi
+  # Prerequisites of lib/lstat.c.
+  AC_REQUIRE([AC_C_INLINE])
+  :
+])
diff --git a/gnulib/m4/netdb_h.m4 b/gnulib/m4/netdb_h.m4
new file mode 100644
index 0000000..bbe166f
--- /dev/null
+++ b/gnulib/m4/netdb_h.m4
@@ -0,0 +1,33 @@
+# netdb_h.m4 serial 3
+dnl Copyright (C) 2008 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_HEADER_NETDB],
+[
+  AC_REQUIRE([gl_NETDB_H_DEFAULTS])
+  gl_CHECK_NEXT_HEADERS([netdb.h])
+  if test $ac_cv_header_netdb_h = yes; then
+    AC_CHECK_TYPES([struct addrinfo], [NETDB_H=''], [NETDB_H='netdb.h'],
+                   [[#include <netdb.h>]])
+    HAVE_NETDB_H=1
+  else
+    NETDB_H='netdb.h'
+    HAVE_NETDB_H=0
+  fi
+  AC_SUBST([HAVE_NETDB_H])
+  AC_SUBST([NETDB_H])
+])
+
+AC_DEFUN([gl_NETDB_MODULE_INDICATOR],
+[
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+  AC_REQUIRE([gl_NETDB_H_DEFAULTS])
+  GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
+])
+
+AC_DEFUN([gl_NETDB_H_DEFAULTS],
+[
+  GNULIB_GETADDRINFO=0; AC_SUBST([GNULIB_GETADDRINFO])
+])
diff --git a/gnulib/m4/perror.m4 b/gnulib/m4/perror.m4
new file mode 100644
index 0000000..fb37fd0
--- /dev/null
+++ b/gnulib/m4/perror.m4
@@ -0,0 +1,17 @@
+# perror.m4 serial 1
+dnl Copyright (C) 2008 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_PERROR],
+[
+  AC_REQUIRE([gl_STDIO_H_DEFAULTS])
+  AC_REQUIRE([gl_HEADER_ERRNO_H])
+  if test -n "$ERRNO_H"; then
+    dnl The system's perror() cannot know about the new errno values we add
+    dnl to <errno.h>. Replace it.
+    REPLACE_PERROR=1
+    AC_LIBOBJ([perror])
+  fi
+])
diff --git a/gnulib/m4/posix-shell.m4 b/gnulib/m4/posix-shell.m4
index 7f3b1e9..4c56193 100644
--- a/gnulib/m4/posix-shell.m4
+++ b/gnulib/m4/posix-shell.m4
@@ -31,12 +31,16 @@ AC_DEFUN([gl_POSIX_SHELL],
        func_ret_failure () {
 	 return 1
        }
+       subshell_umask_sanity () {
+	 (umask 22; (umask 0); test $(umask) -eq 22)
+       }
        test "[$](echo foo)" = foo &&
        func_success &&
        ! func_failure &&
        func_ret_success &&
        ! func_ret_failure &&
-       (set x && func_ret_success y && test x = "[$]1")
+       (set x && func_ret_success y && test x = "[$]1") &&
+       subshell_umask_sanity
      '
      for gl_cv_posix_shell in \
 	 "$CONFIG_SHELL" "$SHELL" /bin/sh /bin/bash /bin/ksh /bin/sh5 no; do
diff --git a/gnulib/m4/sockets.m4 b/gnulib/m4/sockets.m4
new file mode 100644
index 0000000..c7bd664
--- /dev/null
+++ b/gnulib/m4/sockets.m4
@@ -0,0 +1,65 @@
+# sockets.m4 serial 2
+dnl Copyright (C) 2008 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],
+[
+  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_TRY_LINK([
+#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.
+    AC_CACHE_CHECK([whether setsockopt requires -lsocket], [gl_cv_lib_socket], [
+      gl_cv_lib_socket=no
+      AC_TRY_LINK([extern
+#ifdef __cplusplus
+"C"
+#endif
+char setsockopt();], [setsockopt();],
+        [],
+        [gl_save_LIBS="$LIBS"
+         LIBS="$LIBS -lsocket"
+         AC_TRY_LINK([extern
+#ifdef __cplusplus
+"C"
+#endif
+char setsockopt();], [setsockopt();],
+           [gl_cv_lib_socket=yes])
+         LIBS="$gl_save_LIBS"
+        ])
+    ])
+    if test $gl_cv_lib_socket = yes; then
+      LIBSOCKET='-lsocket'
+    fi
+  fi
+  AC_SUBST([LIBSOCKET])
+  gl_PREREQ_SOCKETS
+])
+
+# Prerequisites of lib/sockets.c.
+AC_DEFUN([gl_PREREQ_SOCKETS], [
+  :
+])
diff --git a/gnulib/m4/stdio_h.m4 b/gnulib/m4/stdio_h.m4
index 4980f9e..60b4bd7 100644
--- a/gnulib/m4/stdio_h.m4
+++ b/gnulib/m4/stdio_h.m4
@@ -1,4 +1,4 @@
-# stdio_h.m4 serial 11
+# stdio_h.m4 serial 14
 dnl Copyright (C) 2007-2008 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,28 @@ AC_DEFUN([gl_STDIO_H],
 [
   AC_REQUIRE([gl_STDIO_H_DEFAULTS])
   gl_CHECK_NEXT_HEADERS([stdio.h])
+  dnl No need to create extra modules for these functions. Everyone who uses
+  dnl <stdio.h> likely needs them.
+  GNULIB_FPRINTF=1
+  GNULIB_PRINTF=1
+  GNULIB_VFPRINTF=1
+  GNULIB_VPRINTF=1
+  GNULIB_FPUTC=1
+  GNULIB_PUTC=1
+  GNULIB_PUTCHAR=1
+  GNULIB_FPUTS=1
+  GNULIB_PUTS=1
+  GNULIB_FWRITE=1
+  dnl This ifdef is just an optimization, to avoid performing a configure
+  dnl check whose result is not used. It does not make the test of
+  dnl GNULIB_STDIO_H_SIGPIPE or GNULIB_SIGPIPE redundant.
+  m4_ifdef([gl_SIGNAL_SIGPIPE], [
+    gl_SIGNAL_SIGPIPE
+    if test $gl_cv_header_signal_h_SIGPIPE != yes; then
+      REPLACE_STDIO_WRITE_FUNCS=1
+      AC_LIBOBJ([stdio-write])
+    fi
+  ])
 ])

 AC_DEFUN([gl_STDIO_MODULE_INDICATOR],
@@ -19,53 +41,69 @@ AC_DEFUN([gl_STDIO_MODULE_INDICATOR],

 AC_DEFUN([gl_STDIO_H_DEFAULTS],
 [
-  GNULIB_FPRINTF_POSIX=0;  AC_SUBST([GNULIB_FPRINTF_POSIX])
-  GNULIB_PRINTF_POSIX=0;   AC_SUBST([GNULIB_PRINTF_POSIX])
-  GNULIB_OBSTACK_PRINTF=0; AC_SUBST([GNULIB_OBSTACK_PRINTF])
-  GNULIB_OBSTACK_PRINTF_POSIX=0;  AC_SUBST([GNULIB_OBSTACK_PRINTF_POSIX])
-  GNULIB_SNPRINTF=0;       AC_SUBST([GNULIB_SNPRINTF])
-  GNULIB_SPRINTF_POSIX=0;  AC_SUBST([GNULIB_SPRINTF_POSIX])
-  GNULIB_VFPRINTF_POSIX=0; AC_SUBST([GNULIB_VFPRINTF_POSIX])
-  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_VASPRINTF=0;      AC_SUBST([GNULIB_VASPRINTF])
-  GNULIB_FOPEN=0;          AC_SUBST([GNULIB_FOPEN])
-  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_GETDELIM=0;       AC_SUBST([GNULIB_GETDELIM])
-  GNULIB_GETLINE=0;        AC_SUBST([GNULIB_GETLINE])
+  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_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_FOPEN=0;                AC_SUBST([GNULIB_FOPEN])
+  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_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_PERROR=0;               AC_SUBST([GNULIB_PERROR])
+  GNULIB_STDIO_H_SIGPIPE=0;      AC_SUBST([GNULIB_STDIO_H_SIGPIPE])
   dnl Assume proper GNU behavior unless another module says otherwise.
-  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_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_VASPRINTF=1;        AC_SUBST([HAVE_VASPRINTF])
-  REPLACE_VASPRINTF=0;     AC_SUBST([REPLACE_VASPRINTF])
-  REPLACE_FOPEN=0;         AC_SUBST([REPLACE_FOPEN])
-  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_FTELL=0;         AC_SUBST([REPLACE_FTELL])
-  REPLACE_FFLUSH=0;        AC_SUBST([REPLACE_FFLUSH])
-  HAVE_DECL_GETDELIM=1;    AC_SUBST([HAVE_DECL_GETDELIM])
-  HAVE_DECL_GETLINE=1;     AC_SUBST([HAVE_DECL_GETLINE])
-  REPLACE_GETLINE=0;       AC_SUBST([REPLACE_GETLINE])
-  HAVE_DECL_OBSTACK_PRINTF=1;     AC_SUBST([HAVE_DECL_OBSTACK_PRINTF])
-  REPLACE_OBSTACK_PRINTF=0;       AC_SUBST([REPLACE_OBSTACK_PRINTF])
+  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_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_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])
+  REPLACE_FOPEN=0;               AC_SUBST([REPLACE_FOPEN])
+  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_FTELL=0;               AC_SUBST([REPLACE_FTELL])
+  REPLACE_FFLUSH=0;              AC_SUBST([REPLACE_FFLUSH])
+  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_GETLINE=0;             AC_SUBST([REPLACE_GETLINE])
+  REPLACE_PERROR=0;              AC_SUBST([REPLACE_PERROR])
 ])

 dnl Code shared by fseeko and ftello.  Determine if large files are supported,
diff --git a/gnulib/m4/stdlib_h.m4 b/gnulib/m4/stdlib_h.m4
index 95e679f..582db13 100644
--- a/gnulib/m4/stdlib_h.m4
+++ b/gnulib/m4/stdlib_h.m4
@@ -1,4 +1,4 @@
-# stdlib_h.m4 serial 7
+# stdlib_h.m4 serial 13
 dnl Copyright (C) 2007, 2008 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,9 @@ AC_DEFUN([gl_STDLIB_H],
 [
   AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
   gl_CHECK_NEXT_HEADERS([stdlib.h])
+  AC_CHECK_TYPES([struct random_data],
+    [], [HAVE_STRUCT_RANDOM_DATA=0],
+    [[#include <stdlib.h>]])
 ])

 AC_DEFUN([gl_STDLIB_MODULE_INDICATOR],
@@ -22,26 +25,38 @@ 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_GETLOADAVG=0;    AC_SUBST([GNULIB_GETLOADAVG])
   GNULIB_GETSUBOPT=0;     AC_SUBST([GNULIB_GETSUBOPT])
   GNULIB_MKDTEMP=0;       AC_SUBST([GNULIB_MKDTEMP])
   GNULIB_MKSTEMP=0;       AC_SUBST([GNULIB_MKSTEMP])
   GNULIB_PUTENV=0;        AC_SUBST([GNULIB_PUTENV])
+  GNULIB_RANDOM_R=0;      AC_SUBST([GNULIB_RANDOM_R])
   GNULIB_RPMATCH=0;       AC_SUBST([GNULIB_RPMATCH])
   GNULIB_SETENV=0;        AC_SUBST([GNULIB_SETENV])
   GNULIB_STRTOD=0;        AC_SUBST([GNULIB_STRTOD])
+  GNULIB_STRTOLL=0;       AC_SUBST([GNULIB_STRTOLL])
+  GNULIB_STRTOULL=0;      AC_SUBST([GNULIB_STRTOULL])
   GNULIB_UNSETENV=0;      AC_SUBST([GNULIB_UNSETENV])
   dnl Assume proper GNU behavior unless another module says otherwise.
-  HAVE_CALLOC_POSIX=1;    AC_SUBST([HAVE_CALLOC_POSIX])
-  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_RPMATCH=1;         AC_SUBST([HAVE_RPMATCH])
-  HAVE_SETENV=1;          AC_SUBST([HAVE_SETENV])
-  HAVE_STRTOD=1;          AC_SUBST([HAVE_STRTOD])
-  HAVE_UNSETENV=1;        AC_SUBST([HAVE_UNSETENV])
-  REPLACE_MKSTEMP=0;      AC_SUBST([REPLACE_MKSTEMP])
-  REPLACE_PUTENV=0;       AC_SUBST([REPLACE_PUTENV])
-  REPLACE_STRTOD=0;       AC_SUBST([REPLACE_STRTOD])
-  VOID_UNSETENV=0;        AC_SUBST([VOID_UNSETENV])
+  HAVE_ATOLL=1;              AC_SUBST([HAVE_ATOLL])
+  HAVE_CALLOC_POSIX=1;       AC_SUBST([HAVE_CALLOC_POSIX])
+  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_RANDOM_R=1;           AC_SUBST([HAVE_RANDOM_R])
+  HAVE_RPMATCH=1;            AC_SUBST([HAVE_RPMATCH])
+  HAVE_SETENV=1;             AC_SUBST([HAVE_SETENV])
+  HAVE_STRTOD=1;             AC_SUBST([HAVE_STRTOD])
+  HAVE_STRTOLL=1;            AC_SUBST([HAVE_STRTOLL])
+  HAVE_STRTOULL=1;           AC_SUBST([HAVE_STRTOULL])
+  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_MKSTEMP=0;         AC_SUBST([REPLACE_MKSTEMP])
+  REPLACE_PUTENV=0;          AC_SUBST([REPLACE_PUTENV])
+  REPLACE_STRTOD=0;          AC_SUBST([REPLACE_STRTOD])
+  VOID_UNSETENV=0;           AC_SUBST([VOID_UNSETENV])
 ])
diff --git a/gnulib/m4/strdup.m4 b/gnulib/m4/strdup.m4
index 8796e9e..0537def 100644
--- a/gnulib/m4/strdup.m4
+++ b/gnulib/m4/strdup.m4
@@ -1,7 +1,6 @@
-# strdup.m4 serial 9
+# strdup.m4 serial 10

-dnl Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software
-dnl Foundation, Inc.
+dnl Copyright (C) 2002-2008 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,5 +17,22 @@ AC_DEFUN([gl_FUNC_STRDUP],
   gl_PREREQ_STRDUP
 ])

+AC_DEFUN([gl_FUNC_STRDUP_POSIX],
+[
+  AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
+  AC_REQUIRE([gl_CHECK_MALLOC_POSIX])
+  if test $gl_cv_func_malloc_posix != yes; then
+    REPLACE_STRDUP=1
+    AC_LIBOBJ([strdup])
+  else
+    AC_REPLACE_FUNCS(strdup)
+  fi
+  AC_CHECK_DECLS_ONCE(strdup)
+  if test $ac_cv_have_decl_strdup = no; then
+    HAVE_DECL_STRDUP=0
+  fi
+  gl_PREREQ_STRDUP
+])
+
 # Prerequisites of lib/strdup.c.
 AC_DEFUN([gl_PREREQ_STRDUP], [:])
diff --git a/gnulib/m4/strerror.m4 b/gnulib/m4/strerror.m4
new file mode 100644
index 0000000..8c16ca9
--- /dev/null
+++ b/gnulib/m4/strerror.m4
@@ -0,0 +1,68 @@
+# strerror.m4 serial 9
+dnl Copyright (C) 2002, 2007-2008 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_STRERROR],
+[
+  AC_REQUIRE([gl_FUNC_STRERROR_SEPARATE])
+  if test $REPLACE_STRERROR = 1; then
+    AC_LIBOBJ([strerror])
+    AC_DEFINE_UNQUOTED([REPLACE_STRERROR], [$REPLACE_STRERROR],
+      [Define this to 1 if strerror is broken.])
+  fi
+])
+
+# Like gl_FUNC_STRERROR, except prepare for separate compilation (no AC_LIBOBJ).
+AC_DEFUN([gl_FUNC_STRERROR_SEPARATE],
+[
+  AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
+  AC_REQUIRE([gl_HEADER_ERRNO_H])
+  if test -z "$ERRNO_H"; then
+    AC_CACHE_CHECK([for working strerror function],
+     [gl_cv_func_working_strerror],
+     [AC_RUN_IFELSE(
+        [AC_LANG_PROGRAM(
+           [[#include <string.h>
+           ]],
+           [[return !*strerror (-2);]])],
+        [gl_cv_func_working_strerror=yes],
+        [gl_cv_func_working_strerror=no],
+        [dnl Assume crossbuild works if it compiles.
+         AC_COMPILE_IFELSE(
+           [AC_LANG_PROGRAM(
+              [[#include <string.h>
+              ]],
+              [[return !*strerror (-2);]])],
+           [gl_cv_func_working_strerror=yes],
+           [gl_cv_func_working_strerror=no])
+      ])
+    ])
+    if test $gl_cv_func_working_strerror = no; then
+      dnl The system's strerror() fails to return a string for out-of-range
+      dnl integers. Replace it.
+      REPLACE_STRERROR=1
+    fi
+  else
+    dnl The system's strerror() cannot know about the new errno values we add
+    dnl to <errno.h>. Replace it.
+    REPLACE_STRERROR=1
+  fi
+  if test $REPLACE_STRERROR = 1; then
+    gl_PREREQ_STRERROR
+  fi
+])
+
+# Prerequisites of lib/strerror.c.
+AC_DEFUN([gl_PREREQ_STRERROR], [
+  AC_CHECK_DECLS([strerror])
+  AC_CHECK_HEADERS_ONCE([sys/socket.h])
+  if test $ac_cv_header_sys_socket_h != yes; then
+    dnl We cannot use AC_CHECK_HEADERS_ONCE here, because that would make
+    dnl the check for those headers unconditional; yet cygwin reports
+    dnl that the headers are present but cannot be compiled (since on
+    dnl cygwin, all socket information should come from sys/socket.h).
+    AC_CHECK_HEADERS([winsock2.h])
+  fi
+])
diff --git a/gnulib/m4/string_h.m4 b/gnulib/m4/string_h.m4
index 7143690..2d5553c 100644
--- a/gnulib/m4/string_h.m4
+++ b/gnulib/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 4
+# serial 6

 # Written by Paul Eggert.

@@ -63,6 +63,7 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
   GNULIB_MBSTOK_R=0;    AC_SUBST([GNULIB_MBSTOK_R])
   GNULIB_STRERROR=0;    AC_SUBST([GNULIB_STRERROR])
   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])
@@ -81,9 +82,11 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
   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])
-  REPLACE_STRERROR=0;		AC_SUBST([REPLACE_STRERROR])
-  REPLACE_STRSIGNAL=0;		AC_SUBST([REPLACE_STRSIGNAL])
+  HAVE_STRVERSCMP=1;		AC_SUBST([HAVE_STRVERSCMP])
   REPLACE_MEMMEM=0;		AC_SUBST([REPLACE_MEMMEM])
-  REPLACE_STRCASESTR=0;		AC_SUBST([REPLACE_STRCASESTR])
+  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])
 ])
diff --git a/gnulib/m4/sys_ioctl_h.m4 b/gnulib/m4/sys_ioctl_h.m4
new file mode 100644
index 0000000..5488039
--- /dev/null
+++ b/gnulib/m4/sys_ioctl_h.m4
@@ -0,0 +1,60 @@
+# sys_ioctl_h.m4 serial 1
+dnl Copyright (C) 2008 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 Bruno Haible.
+
+AC_DEFUN([gl_SYS_IOCTL_H],
+[
+  dnl Use AC_REQUIRE here, so that the default behavior below is expanded
+  dnl once only, before all statements that occur in other macros.
+  AC_REQUIRE([gl_SYS_IOCTL_H_DEFAULTS])
+
+  AC_CHECK_HEADERS_ONCE([sys/ioctl.h])
+  if test $ac_cv_header_sys_ioctl_h = yes; then
+    HAVE_SYS_IOCTL_H=1
+    dnl Test whether <sys/ioctl.h> declares ioctl(), or whether some other
+    dnl header file, such as <unistd.h> or <stropts.h>, is needed for that.
+    AC_CACHE_CHECK([whether <sys/ioctl.h> declares ioctl],
+      [gl_cv_decl_ioctl_in_sys_ioctl_h],
+      [AC_CHECK_DECL([ioctl],
+         [gl_cv_decl_ioctl_in_sys_ioctl_h=yes],
+         [gl_cv_decl_ioctl_in_sys_ioctl_h=no],
+         [#include <sys/ioctl.h>])
+      ])
+    if test $gl_cv_decl_ioctl_in_sys_ioctl_h != yes; then
+      SYS_IOCTL_H='sys/ioctl.h'
+    fi
+  else
+    HAVE_SYS_IOCTL_H=0
+    SYS_IOCTL_H='sys/ioctl.h'
+  fi
+  AC_SUBST([HAVE_SYS_IOCTL_H])
+  dnl Execute this unconditionally, because SYS_IOCTL_H may be set by other
+  dnl modules, after this code is executed.
+  gl_CHECK_NEXT_HEADERS([sys/ioctl.h])
+])
+
+dnl Unconditionally enables the replacement of <sys/ioctl.h>.
+AC_DEFUN([gl_REPLACE_SYS_IOCTL_H],
+[
+  AC_REQUIRE([gl_SYS_IOCTL_H_DEFAULTS])
+  SYS_IOCTL_H='sys/ioctl.h'
+])
+
+AC_DEFUN([gl_SYS_IOCTL_MODULE_INDICATOR],
+[
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+  AC_REQUIRE([gl_SYS_IOCTL_H_DEFAULTS])
+  GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
+])
+
+AC_DEFUN([gl_SYS_IOCTL_H_DEFAULTS],
+[
+  GNULIB_IOCTL=0;         AC_SUBST([GNULIB_IOCTL])
+  dnl Assume proper GNU behavior unless another module says otherwise.
+  SYS_IOCTL_H_HAVE_WINSOCK2_H=0; AC_SUBST([SYS_IOCTL_H_HAVE_WINSOCK2_H])
+  SYS_IOCTL_H='';                AC_SUBST([SYS_IOCTL_H])
+])
diff --git a/gnulib/m4/sys_select_h.m4 b/gnulib/m4/sys_select_h.m4
index 8d1c36c..c537e79 100644
--- a/gnulib/m4/sys_select_h.m4
+++ b/gnulib/m4/sys_select_h.m4
@@ -1,4 +1,4 @@
-# sys_select_h.m4 serial 4
+# sys_select_h.m4 serial 6
 dnl Copyright (C) 2006-2008 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -6,10 +6,13 @@ dnl with or without modifications, as long as this notice is preserved.

 AC_DEFUN([gl_HEADER_SYS_SELECT],
 [
+  AC_REQUIRE([gl_HEADER_SYS_SOCKET])
+  AC_REQUIRE([gl_SYS_SELECT_H_DEFAULTS])
   AC_CACHE_CHECK([whether <sys/select.h> is self-contained],
     [gl_cv_header_sys_select_h_selfcontained],
     [
-      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/select.h>]], [[]])],
+      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/select.h>]],
+					 [[struct timeval b;]])],
         [gl_cv_header_sys_select_h_selfcontained=yes],
         [gl_cv_header_sys_select_h_selfcontained=no])
     ])
@@ -24,6 +27,19 @@ AC_DEFUN([gl_HEADER_SYS_SELECT],
       HAVE_SYS_SELECT_H=0
     fi
     AC_SUBST([HAVE_SYS_SELECT_H])
+    gl_PREREQ_SYS_H_WINSOCK2
   fi
   AC_SUBST([SYS_SELECT_H])
 ])
+
+AC_DEFUN([gl_SYS_SELECT_MODULE_INDICATOR],
+[
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+  AC_REQUIRE([gl_SYS_SELECT_H_DEFAULTS])
+  GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
+])
+
+AC_DEFUN([gl_SYS_SELECT_H_DEFAULTS],
+[
+  GNULIB_SELECT=0; AC_SUBST([GNULIB_SELECT])
+])
diff --git a/gnulib/m4/sys_socket_h.m4 b/gnulib/m4/sys_socket_h.m4
index 2e4e2f6..85a0ace 100644
--- a/gnulib/m4/sys_socket_h.m4
+++ b/gnulib/m4/sys_socket_h.m4
@@ -1,4 +1,4 @@
-# sys_socket_h.m4 serial 6
+# sys_socket_h.m4 serial 12
 dnl Copyright (C) 2005-2008 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 @@ dnl From Simon Josefsson.

 AC_DEFUN([gl_HEADER_SYS_SOCKET],
 [
+  AC_REQUIRE([gl_SYS_SOCKET_H_DEFAULTS])
   AC_REQUIRE([AC_C_INLINE])

   AC_CACHE_CHECK([whether <sys/socket.h> is self-contained],
@@ -44,7 +45,6 @@ AC_DEFUN([gl_HEADER_SYS_SOCKET],
     gl_CHECK_NEXT_HEADERS([sys/socket.h])
     if test $ac_cv_header_sys_socket_h = yes; then
       HAVE_SYS_SOCKET_H=1
-      HAVE_WINSOCK2_H=0
       HAVE_WS2TCPIP_H=0
     else
       HAVE_SYS_SOCKET_H=0
@@ -52,21 +52,66 @@ AC_DEFUN([gl_HEADER_SYS_SOCKET],
       dnl the check for those headers unconditional; yet cygwin reports
       dnl that the headers are present but cannot be compiled (since on
       dnl cygwin, all socket information should come from sys/socket.h).
-      AC_CHECK_HEADERS([winsock2.h ws2tcpip.h])
-      if test $ac_cv_header_winsock2_h = yes; then
-        HAVE_WINSOCK2_H=1
-      else
-        HAVE_WINSOCK2_H=0
-      fi
+      AC_CHECK_HEADERS([ws2tcpip.h])
       if test $ac_cv_header_ws2tcpip_h = yes; then
         HAVE_WS2TCPIP_H=1
       else
         HAVE_WS2TCPIP_H=0
       fi
     fi
+    gl_PREREQ_SYS_H_WINSOCK2
     AC_SUBST([HAVE_SYS_SOCKET_H])
-    AC_SUBST([HAVE_WINSOCK2_H])
     AC_SUBST([HAVE_WS2TCPIP_H])
   fi
   AC_SUBST([SYS_SOCKET_H])
 ])
+
+# Common prerequisites of 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],
+[
+  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_CHECK_HEADERS_ONCE([sys/socket.h])
+  if test $ac_cv_header_sys_socket_h != yes; then
+    dnl We cannot use AC_CHECK_HEADERS_ONCE here, because that would make
+    dnl the check for those headers unconditional; yet cygwin reports
+    dnl that the headers are present but cannot be compiled (since on
+    dnl cygwin, all socket information should come from sys/socket.h).
+    AC_CHECK_HEADERS([winsock2.h])
+  fi
+  if test "$ac_cv_header_winsock2_h" = yes; then
+    HAVE_WINSOCK2_H=1
+    UNISTD_H_HAVE_WINSOCK2_H=1
+    SYS_IOCTL_H_HAVE_WINSOCK2_H=1
+  else
+    HAVE_WINSOCK2_H=0
+  fi
+  AC_SUBST([HAVE_WINSOCK2_H])
+])
+
+AC_DEFUN([gl_SYS_SOCKET_MODULE_INDICATOR],
+[
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+  AC_REQUIRE([gl_SYS_SOCKET_H_DEFAULTS])
+  GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
+])
+
+AC_DEFUN([gl_SYS_SOCKET_H_DEFAULTS],
+[
+  GNULIB_SOCKET=0;      AC_SUBST([GNULIB_SOCKET])
+  GNULIB_CONNECT=0;     AC_SUBST([GNULIB_CONNECT])
+  GNULIB_ACCEPT=0;      AC_SUBST([GNULIB_ACCEPT])
+  GNULIB_BIND=0;        AC_SUBST([GNULIB_BIND])
+  GNULIB_GETPEERNAME=0; AC_SUBST([GNULIB_GETPEERNAME])
+  GNULIB_GETSOCKNAME=0; AC_SUBST([GNULIB_GETSOCKNAME])
+  GNULIB_GETSOCKOPT=0;  AC_SUBST([GNULIB_GETSOCKOPT])
+  GNULIB_LISTEN=0;      AC_SUBST([GNULIB_LISTEN])
+  GNULIB_RECV=0;        AC_SUBST([GNULIB_RECV])
+  GNULIB_SEND=0;        AC_SUBST([GNULIB_SEND])
+  GNULIB_RECVFROM=0;    AC_SUBST([GNULIB_RECVFROM])
+  GNULIB_SENDTO=0;      AC_SUBST([GNULIB_SENDTO])
+  GNULIB_SETSOCKOPT=0;  AC_SUBST([GNULIB_SETSOCKOPT])
+  GNULIB_SHUTDOWN=0;    AC_SUBST([GNULIB_SHUTDOWN])
+])
diff --git a/gnulib/m4/sys_stat_h.m4 b/gnulib/m4/sys_stat_h.m4
index cfe8011..20c82ed 100644
--- a/gnulib/m4/sys_stat_h.m4
+++ b/gnulib/m4/sys_stat_h.m4
@@ -1,4 +1,4 @@
-# sys_stat_h.m4 serial 8   -*- Autoconf -*-
+# sys_stat_h.m4 serial 10   -*- Autoconf -*-
 dnl Copyright (C) 2006-2008 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -50,6 +50,10 @@ 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])
   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])
 ])
diff --git a/gnulib/m4/threadlib.m4 b/gnulib/m4/threadlib.m4
new file mode 100644
index 0000000..3a8655e
--- /dev/null
+++ b/gnulib/m4/threadlib.m4
@@ -0,0 +1,312 @@
+# threadlib.m4 serial 1 (gettext-0.18)
+dnl Copyright (C) 2005-2008 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 gl_THREADLIB
+dnl ------------
+dnl Tests for a multithreading library to be used.
+dnl Defines at most one of the macros USE_POSIX_THREADS, USE_SOLARIS_THREADS,
+dnl USE_PTH_THREADS, USE_WIN32_THREADS
+dnl Sets the variables LIBTHREAD and LTLIBTHREAD to the linker options for use
+dnl in a Makefile (LIBTHREAD for use without libtool, LTLIBTHREAD for use with
+dnl libtool).
+dnl Sets the variables LIBMULTITHREAD and LTLIBMULTITHREAD similarly, for
+dnl programs that really need multithread functionality. The difference
+dnl between LIBTHREAD and LIBMULTITHREAD is that on platforms supporting weak
+dnl symbols, typically LIBTHREAD="" whereas LIBMULTITHREAD="-lpthread".
+dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for
+dnl multithread-safe programs.
+
+AC_DEFUN([gl_THREADLIB_EARLY],
+[
+  AC_REQUIRE([gl_THREADLIB_EARLY_BODY])
+])
+
+dnl The guts of gl_THREADLIB_EARLY. Needs to be expanded only once.
+
+AC_DEFUN([gl_THREADLIB_EARLY_BODY],
+[
+  dnl Ordering constraints: This macro modifies CPPFLAGS in a way that
+  dnl influences the result of the autoconf tests that test for *_unlocked
+  dnl declarations, on AIX 5 at least. Therefore it must come early.
+  AC_BEFORE([$0], [gl_FUNC_GLIBC_UNLOCKED_IO])dnl
+  AC_BEFORE([$0], [gl_ARGP])dnl
+
+  AC_REQUIRE([AC_CANONICAL_HOST])
+  dnl _GNU_SOURCE is needed for pthread_rwlock_t on glibc systems.
+  dnl AC_USE_SYSTEM_EXTENSIONS was introduced in autoconf 2.60 and obsoletes
+  dnl AC_GNU_SOURCE.
+  m4_ifdef([AC_USE_SYSTEM_EXTENSIONS],
+    [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])],
+    [AC_REQUIRE([AC_GNU_SOURCE])])
+  dnl Check for multithreading.
+  m4_divert_text([DEFAULTS], [gl_use_threads_default=])
+  AC_ARG_ENABLE(threads,
+AC_HELP_STRING([--enable-threads={posix|solaris|pth|win32}], [specify multithreading API])
+AC_HELP_STRING([--disable-threads], [build without multithread safety]),
+    [gl_use_threads=$enableval],
+    [if test -n "$gl_use_threads_default"; then
+       gl_use_threads="$gl_use_threads_default"
+     else
+       case "$host_os" in
+         dnl Disable multithreading by default on OSF/1, because it interferes
+         dnl with fork()/exec(): When msgexec is linked with -lpthread, its
+         dnl child process gets an endless segmentation fault inside execvp().
+         osf*) gl_use_threads=no ;;
+         *)    gl_use_threads=yes ;;
+       esac
+     fi
+    ])
+  if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then
+    # For using <pthread.h>:
+    case "$host_os" in
+      osf*)
+        # On OSF/1, the compiler needs the flag -D_REENTRANT so that it
+        # groks <pthread.h>. cc also understands the flag -pthread, but
+        # we don't use it because 1. gcc-2.95 doesn't understand -pthread,
+        # 2. putting a flag into CPPFLAGS that has an effect on the linker
+        # causes the AC_TRY_LINK test below to succeed unexpectedly,
+        # leading to wrong values of LIBTHREAD and LTLIBTHREAD.
+        CPPFLAGS="$CPPFLAGS -D_REENTRANT"
+        ;;
+    esac
+    # Some systems optimize for single-threaded programs by default, and
+    # need special flags to disable these optimizations. For example, the
+    # definition of 'errno' in <errno.h>.
+    case "$host_os" in
+      aix* | freebsd*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;;
+      solaris*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;;
+    esac
+  fi
+])
+
+dnl The guts of gl_THREADLIB. Needs to be expanded only once.
+
+AC_DEFUN([gl_THREADLIB_BODY],
+[
+  AC_REQUIRE([gl_THREADLIB_EARLY_BODY])
+  gl_threads_api=none
+  LIBTHREAD=
+  LTLIBTHREAD=
+  LIBMULTITHREAD=
+  LTLIBMULTITHREAD=
+  if test "$gl_use_threads" != no; then
+    dnl Check whether the compiler and linker support weak declarations.
+    AC_MSG_CHECKING([whether imported symbols can be declared weak])
+    gl_have_weak=no
+    AC_TRY_LINK([extern void xyzzy ();
+#pragma weak xyzzy], [xyzzy();], [gl_have_weak=yes])
+    AC_MSG_RESULT([$gl_have_weak])
+    if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then
+      # On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that
+      # it groks <pthread.h>. It's added above, in gl_THREADLIB_EARLY_BODY.
+      AC_CHECK_HEADER(pthread.h, gl_have_pthread_h=yes, gl_have_pthread_h=no)
+      if test "$gl_have_pthread_h" = yes; then
+        # Other possible tests:
+        #   -lpthreads (FSU threads, PCthreads)
+        #   -lgthreads
+        gl_have_pthread=
+        # Test whether both pthread_mutex_lock and pthread_mutexattr_init exist
+        # in libc. IRIX 6.5 has the first one in both libc and libpthread, but
+        # the second one only in libpthread, and lock.c needs it.
+        AC_TRY_LINK([#include <pthread.h>],
+          [pthread_mutex_lock((pthread_mutex_t*)0);
+           pthread_mutexattr_init((pthread_mutexattr_t*)0);],
+          [gl_have_pthread=yes])
+        # Test for libpthread by looking for pthread_kill. (Not pthread_self,
+        # since it is defined as a macro on OSF/1.)
+        if test -n "$gl_have_pthread"; then
+          # The program links fine without libpthread. But it may actually
+          # need to link with libpthread in order to create multiple threads.
+          AC_CHECK_LIB(pthread, pthread_kill,
+            [LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread
+             # On Solaris and HP-UX, most pthread functions exist also in libc.
+             # Therefore pthread_in_use() needs to actually try to create a
+             # thread: pthread_create from libc will fail, whereas
+             # pthread_create will actually create a thread.
+             case "$host_os" in
+               solaris* | hpux*)
+                 AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], 1,
+                   [Define if the pthread_in_use() detection is hard.])
+             esac
+            ])
+        else
+          # Some library is needed. Try libpthread and libc_r.
+          AC_CHECK_LIB(pthread, pthread_kill,
+            [gl_have_pthread=yes
+             LIBTHREAD=-lpthread LTLIBTHREAD=-lpthread
+             LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread])
+          if test -z "$gl_have_pthread"; then
+            # For FreeBSD 4.
+            AC_CHECK_LIB(c_r, pthread_kill,
+              [gl_have_pthread=yes
+               LIBTHREAD=-lc_r LTLIBTHREAD=-lc_r
+               LIBMULTITHREAD=-lc_r LTLIBMULTITHREAD=-lc_r])
+          fi
+        fi
+        if test -n "$gl_have_pthread"; then
+          gl_threads_api=posix
+          AC_DEFINE([USE_POSIX_THREADS], 1,
+            [Define if the POSIX multithreading library can be used.])
+          if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then
+            if test $gl_have_weak = yes; then
+              AC_DEFINE([USE_POSIX_THREADS_WEAK], 1,
+                [Define if references to the POSIX multithreading library should be made weak.])
+              LIBTHREAD=
+              LTLIBTHREAD=
+            fi
+          fi
+        fi
+      fi
+    fi
+    if test -z "$gl_have_pthread"; then
+      if test "$gl_use_threads" = yes || test "$gl_use_threads" = solaris; then
+        gl_have_solaristhread=
+        gl_save_LIBS="$LIBS"
+        LIBS="$LIBS -lthread"
+        AC_TRY_LINK([#include <thread.h>
+#include <synch.h>],
+          [thr_self();],
+          [gl_have_solaristhread=yes])
+        LIBS="$gl_save_LIBS"
+        if test -n "$gl_have_solaristhread"; then
+          gl_threads_api=solaris
+          LIBTHREAD=-lthread
+          LTLIBTHREAD=-lthread
+          LIBMULTITHREAD="$LIBTHREAD"
+          LTLIBMULTITHREAD="$LTLIBTHREAD"
+          AC_DEFINE([USE_SOLARIS_THREADS], 1,
+            [Define if the old Solaris multithreading library can be used.])
+          if test $gl_have_weak = yes; then
+            AC_DEFINE([USE_SOLARIS_THREADS_WEAK], 1,
+              [Define if references to the old Solaris multithreading library should be made weak.])
+            LIBTHREAD=
+            LTLIBTHREAD=
+          fi
+        fi
+      fi
+    fi
+    if test "$gl_use_threads" = pth; then
+      gl_save_CPPFLAGS="$CPPFLAGS"
+      AC_LIB_LINKFLAGS(pth)
+      gl_have_pth=
+      gl_save_LIBS="$LIBS"
+      LIBS="$LIBS -lpth"
+      AC_TRY_LINK([#include <pth.h>], [pth_self();], gl_have_pth=yes)
+      LIBS="$gl_save_LIBS"
+      if test -n "$gl_have_pth"; then
+        gl_threads_api=pth
+        LIBTHREAD="$LIBPTH"
+        LTLIBTHREAD="$LTLIBPTH"
+        LIBMULTITHREAD="$LIBTHREAD"
+        LTLIBMULTITHREAD="$LTLIBTHREAD"
+        AC_DEFINE([USE_PTH_THREADS], 1,
+          [Define if the GNU Pth multithreading library can be used.])
+        if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then
+          if test $gl_have_weak = yes; then
+            AC_DEFINE([USE_PTH_THREADS_WEAK], 1,
+              [Define if references to the GNU Pth multithreading library should be made weak.])
+            LIBTHREAD=
+            LTLIBTHREAD=
+          fi
+        fi
+      else
+        CPPFLAGS="$gl_save_CPPFLAGS"
+      fi
+    fi
+    if test -z "$gl_have_pthread"; then
+      if test "$gl_use_threads" = yes || test "$gl_use_threads" = win32; then
+        if { case "$host_os" in
+               mingw*) true;;
+               *) false;;
+             esac
+           }; then
+          gl_threads_api=win32
+          AC_DEFINE([USE_WIN32_THREADS], 1,
+            [Define if the Win32 multithreading API can be used.])
+        fi
+      fi
+    fi
+  fi
+  AC_MSG_CHECKING([for multithread API to use])
+  AC_MSG_RESULT([$gl_threads_api])
+  AC_SUBST(LIBTHREAD)
+  AC_SUBST(LTLIBTHREAD)
+  AC_SUBST(LIBMULTITHREAD)
+  AC_SUBST(LTLIBMULTITHREAD)
+])
+
+AC_DEFUN([gl_THREADLIB],
+[
+  AC_REQUIRE([gl_THREADLIB_EARLY])
+  AC_REQUIRE([gl_THREADLIB_BODY])
+])
+
+
+dnl gl_DISABLE_THREADS
+dnl ------------------
+dnl Sets the gl_THREADLIB default so that threads are not used by default.
+dnl The user can still override it at installation time, by using the
+dnl configure option '--enable-threads'.
+
+AC_DEFUN([gl_DISABLE_THREADS], [
+  m4_divert_text([INIT_PREPARE], [gl_use_threads_default=no])
+])
+
+
+dnl Survey of platforms:
+dnl
+dnl Platform          Available   Compiler    Supports   test-lock
+dnl                   flavours    option      weak       result
+dnl ---------------   ---------   ---------   --------   ---------
+dnl Linux 2.4/glibc   posix       -lpthread       Y      OK
+dnl
+dnl GNU Hurd/glibc    posix
+dnl
+dnl FreeBSD 5.3       posix       -lc_r           Y
+dnl                   posix       -lkse ?         Y
+dnl                   posix       -lpthread ?     Y
+dnl                   posix       -lthr           Y
+dnl
+dnl FreeBSD 5.2       posix       -lc_r           Y
+dnl                   posix       -lkse           Y
+dnl                   posix       -lthr           Y
+dnl
+dnl FreeBSD 4.0,4.10  posix       -lc_r           Y      OK
+dnl
+dnl NetBSD 1.6        --
+dnl
+dnl OpenBSD 3.4       posix       -lpthread       Y      OK
+dnl
+dnl MacOS X 10.[123]  posix       -lpthread       Y      OK
+dnl
+dnl Solaris 7,8,9     posix       -lpthread       Y      Sol 7,8: 0.0; Sol 9: OK
+dnl                   solaris     -lthread        Y      Sol 7,8: 0.0; Sol 9: OK
+dnl
+dnl HP-UX 11          posix       -lpthread       N (cc) OK
+dnl                                               Y (gcc)
+dnl
+dnl IRIX 6.5          posix       -lpthread       Y      0.5
+dnl
+dnl AIX 4.3,5.1       posix       -lpthread       N      AIX 4: 0.5; AIX 5: OK
+dnl
+dnl OSF/1 4.0,5.1     posix       -pthread (cc)   N      OK
+dnl                               -lpthread (gcc) Y
+dnl
+dnl Cygwin            posix       -lpthread       Y      OK
+dnl
+dnl Any of the above  pth         -lpth                  0.0
+dnl
+dnl Mingw             win32                       N      OK
+dnl
+dnl BeOS 5            --
+dnl
+dnl The test-lock result shows what happens if in test-lock.c EXPLICIT_YIELD is
+dnl turned off:
+dnl   OK if all three tests terminate OK,
+dnl   0.5 if the first test terminates OK but the second one loops endlessly,
+dnl   0.0 if the first test already loops endlessly.
diff --git a/gnulib/m4/unistd_h.m4 b/gnulib/m4/unistd_h.m4
index e8ccab1..5685273 100644
--- a/gnulib/m4/unistd_h.m4
+++ b/gnulib/m4/unistd_h.m4
@@ -1,4 +1,4 @@
-# unistd_h.m4 serial 11
+# unistd_h.m4 serial 16
 dnl Copyright (C) 2006-2008 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -32,22 +32,37 @@ AC_DEFUN([gl_UNISTD_MODULE_INDICATOR],

 AC_DEFUN([gl_UNISTD_H_DEFAULTS],
 [
-  GNULIB_CHOWN=0;         AC_SUBST([GNULIB_CHOWN])
-  GNULIB_DUP2=0;          AC_SUBST([GNULIB_DUP2])
-  GNULIB_ENVIRON=0;       AC_SUBST([GNULIB_ENVIRON])
-  GNULIB_FCHDIR=0;        AC_SUBST([GNULIB_FCHDIR])
-  GNULIB_FTRUNCATE=0;     AC_SUBST([GNULIB_FTRUNCATE])
-  GNULIB_GETCWD=0;        AC_SUBST([GNULIB_GETCWD])
-  GNULIB_GETLOGIN_R=0;    AC_SUBST([GNULIB_GETLOGIN_R])
-  GNULIB_GETPAGESIZE=0;   AC_SUBST([GNULIB_GETPAGESIZE])
-  GNULIB_LCHOWN=0;        AC_SUBST([GNULIB_LCHOWN])
-  GNULIB_LSEEK=0;         AC_SUBST([GNULIB_LSEEK])
-  GNULIB_READLINK=0;      AC_SUBST([GNULIB_READLINK])
-  GNULIB_SLEEP=0;         AC_SUBST([GNULIB_SLEEP])
+  GNULIB_CHOWN=0;            AC_SUBST([GNULIB_CHOWN])
+  GNULIB_CLOSE=0;            AC_SUBST([GNULIB_CLOSE])
+  GNULIB_DUP2=0;             AC_SUBST([GNULIB_DUP2])
+  GNULIB_ENVIRON=0;          AC_SUBST([GNULIB_ENVIRON])
+  GNULIB_EUIDACCESS=0;       AC_SUBST([GNULIB_EUIDACCESS])
+  GNULIB_FCHDIR=0;           AC_SUBST([GNULIB_FCHDIR])
+  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_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_LSEEK=0;            AC_SUBST([GNULIB_LSEEK])
+  GNULIB_READLINK=0;         AC_SUBST([GNULIB_READLINK])
+  GNULIB_SLEEP=0;            AC_SUBST([GNULIB_SLEEP])
+  GNULIB_UNISTD_H_SIGPIPE=0; AC_SUBST([GNULIB_UNISTD_H_SIGPIPE])
+  GNULIB_WRITE=0;            AC_SUBST([GNULIB_WRITE])
   dnl Assume proper GNU behavior unless another module says otherwise.
   HAVE_DUP2=1;            AC_SUBST([HAVE_DUP2])
+  HAVE_EUIDACCESS=1;      AC_SUBST([HAVE_EUIDACCESS])
+  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_GETHOSTNAME=1;     AC_SUBST([HAVE_GETHOSTNAME])
   HAVE_GETPAGESIZE=1;     AC_SUBST([HAVE_GETPAGESIZE])
+  HAVE_GETUSERSHELL=1;    AC_SUBST([HAVE_GETUSERSHELL])
   HAVE_READLINK=1;        AC_SUBST([HAVE_READLINK])
   HAVE_SLEEP=1;           AC_SUBST([HAVE_SLEEP])
   HAVE_DECL_ENVIRON=1;    AC_SUBST([HAVE_DECL_ENVIRON])
@@ -55,9 +70,12 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
   HAVE_OS_H=0;            AC_SUBST([HAVE_OS_H])
   HAVE_SYS_PARAM_H=0;     AC_SUBST([HAVE_SYS_PARAM_H])
   REPLACE_CHOWN=0;        AC_SUBST([REPLACE_CHOWN])
+  REPLACE_CLOSE=0;        AC_SUBST([REPLACE_CLOSE])
   REPLACE_FCHDIR=0;       AC_SUBST([REPLACE_FCHDIR])
   REPLACE_GETCWD=0;       AC_SUBST([REPLACE_GETCWD])
   REPLACE_GETPAGESIZE=0;  AC_SUBST([REPLACE_GETPAGESIZE])
   REPLACE_LCHOWN=0;       AC_SUBST([REPLACE_LCHOWN])
   REPLACE_LSEEK=0;        AC_SUBST([REPLACE_LSEEK])
+  REPLACE_WRITE=0;        AC_SUBST([REPLACE_WRITE])
+  UNISTD_H_HAVE_WINSOCK2_H=0; AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H])
 ])
diff --git a/gnulib/m4/wchar.m4 b/gnulib/m4/wchar.m4
index 70b1248..5c923fa 100644
--- a/gnulib/m4/wchar.m4
+++ b/gnulib/m4/wchar.m4
@@ -1,13 +1,13 @@
 dnl A placeholder for ISO C99 <wchar.h>, for platforms that have issues.

-dnl Copyright (C) 2007 Free Software Foundation, Inc.
+dnl Copyright (C) 2007-2008 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 Eric Blake.

-# wchar.m4 serial 4
+# wchar.m4 serial 6

 AC_DEFUN([gl_WCHAR_H],
 [
@@ -18,7 +18,16 @@ AC_DEFUN([gl_WCHAR_H],
 wchar_t w;]],
       [gl_cv_header_wchar_h_standalone=yes],
       [gl_cv_header_wchar_h_standalone=no])])
-  if test $gl_cv_header_wchar_h_standalone != yes; then
+
+  AC_REQUIRE([gt_TYPE_WINT_T])
+  if test $gt_cv_c_wint_t = yes; then
+    HAVE_WINT_T=1
+  else
+    HAVE_WINT_T=0
+  fi
+  AC_SUBST([HAVE_WINT_T])
+
+  if test $gl_cv_header_wchar_h_standalone != yes || test $gt_cv_c_wint_t != yes; then
     WCHAR_H=wchar.h
   fi

@@ -36,6 +45,13 @@ wchar_t w;]],
   gl_CHECK_NEXT_HEADERS([wchar.h])
 ])

+dnl Unconditionally enables the replacement of <wchar.h>.
+AC_DEFUN([gl_REPLACE_WCHAR_H],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+  WCHAR_H=wchar.h
+])
+
 AC_DEFUN([gl_WCHAR_MODULE_INDICATOR],
 [
   dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
@@ -49,6 +65,5 @@ AC_DEFUN([gl_WCHAR_H_DEFAULTS],
   dnl Assume proper GNU behavior unless another module says otherwise.
   HAVE_DECL_WCWIDTH=1; AC_SUBST([HAVE_DECL_WCWIDTH])
   REPLACE_WCWIDTH=0;   AC_SUBST([REPLACE_WCWIDTH])
-  WCHAR_H=
-  AC_SUBST([WCHAR_H])
+  WCHAR_H='';          AC_SUBST([WCHAR_H])
 ])
diff --git a/gnulib/tests/.cvsignore b/gnulib/tests/.cvsignore
index 5b93dc2..f561064 100644
--- a/gnulib/tests/.cvsignore
+++ b/gnulib/tests/.cvsignore
@@ -4,17 +4,27 @@ Makefile
 Makefile.in
 test-alloca-opt
 test-arpa_inet
+test-c-ctype
+test-errno
 test-fseeko
 test-getaddrinfo
 test-getdelim
+test-gethostname
 test-getline
+test-gettimeofday
 test-lseek
+test-lstat
+test-netdb
 test-netinet_in
+test-perror
+test-poll
 test-snprintf
+test-sockets
 test-stdbool
 test-stdint
 test-stdio
 test-stdlib
+test-strerror
 test-string
 test-sys_select
 test-sys_socket
@@ -24,6 +34,3 @@ test-unistd
 test-vasnprintf
 test-vasprintf
 test-wchar
-test-EOVERFLOW.c
-test-EOVERFLOW
-test-c-ctype
diff --git a/gnulib/tests/.gitignore b/gnulib/tests/.gitignore
index 5b93dc2..c41f6a2 100644
--- a/gnulib/tests/.gitignore
+++ b/gnulib/tests/.gitignore
@@ -4,17 +4,25 @@ Makefile
 Makefile.in
 test-alloca-opt
 test-arpa_inet
+test-c-ctype
+test-errno
 test-fseeko
 test-getaddrinfo
 test-getdelim
 test-getline
+test-gettimeofday
 test-lseek
+test-netdb
 test-netinet_in
+test-perror
+test-poll
 test-snprintf
+test-sockets
 test-stdbool
 test-stdint
 test-stdio
 test-stdlib
+test-strerror
 test-string
 test-sys_select
 test-sys_socket
@@ -24,6 +32,3 @@ test-unistd
 test-vasnprintf
 test-vasprintf
 test-wchar
-test-EOVERFLOW.c
-test-EOVERFLOW
-test-c-ctype
diff --git a/gnulib/tests/Makefile.am b/gnulib/tests/Makefile.am
index 6995840..36195f6 100644
--- a/gnulib/tests/Makefile.am
+++ b/gnulib/tests/Makefile.am
@@ -42,13 +42,14 @@ libtests_a_DEPENDENCIES = $(gltests_LIBOBJS)
 EXTRA_libtests_a_SOURCES =
 AM_LIBTOOLFLAGS = --preserve-dup-deps

-## begin gnulib module EOVERFLOW-tests
+## begin gnulib module accept

-TESTS += test-EOVERFLOW
-check_PROGRAMS += test-EOVERFLOW
-EXTRA_DIST += test-EOVERFLOW.c

-## end   gnulib module EOVERFLOW-tests
+EXTRA_DIST += accept.c w32sock.h
+
+EXTRA_libtests_a_SOURCES += accept.c
+
+## end   gnulib module accept

 ## begin gnulib module alloca-opt-tests

@@ -68,6 +69,15 @@ EXTRA_DIST += test-arpa_inet.c

 ## end   gnulib module arpa_inet-tests

+## begin gnulib module bind
+
+
+EXTRA_DIST += bind.c w32sock.h
+
+EXTRA_libtests_a_SOURCES += bind.c
+
+## end   gnulib module bind
+
 ## begin gnulib module c-ctype-tests

 TESTS += test-c-ctype
@@ -77,6 +87,15 @@ EXTRA_DIST += test-c-ctype.c

 ## end   gnulib module c-ctype-tests

+## begin gnulib module errno-tests
+
+TESTS += test-errno
+check_PROGRAMS += test-errno
+
+EXTRA_DIST += test-errno.c
+
+## end   gnulib module errno-tests
+
 ## begin gnulib module fseeko-tests

 TESTS += test-fseeko.sh
@@ -105,6 +124,14 @@ EXTRA_DIST += test-getdelim.c

 ## end   gnulib module getdelim-tests

+## begin gnulib module gethostname-tests
+
+TESTS += test-gethostname
+check_PROGRAMS += test-gethostname
+EXTRA_DIST += test-gethostname.c
+
+## end   gnulib module gethostname-tests
+
 ## begin gnulib module getline-tests

 TESTS += test-getline
@@ -123,12 +150,23 @@ EXTRA_DIST += test-gettimeofday.c

 ## end   gnulib module gettimeofday-tests

-## begin gnulib module intprops
+## begin gnulib module ioctl
+
+
+EXTRA_DIST += ioctl.c w32sock.h
+
+EXTRA_libtests_a_SOURCES += ioctl.c
+
+## end   gnulib module ioctl

+## begin gnulib module listen

-EXTRA_DIST += intprops.h

-## end   gnulib module intprops
+EXTRA_DIST += listen.c w32sock.h
+
+EXTRA_libtests_a_SOURCES += listen.c
+
+## end   gnulib module listen

 ## begin gnulib module lseek-tests

@@ -139,6 +177,23 @@ EXTRA_DIST += test-lseek.c test-lseek.sh

 ## end   gnulib module lseek-tests

+## begin gnulib module lstat-tests
+
+TESTS += test-lstat
+check_PROGRAMS += test-lstat
+EXTRA_DIST += test-lstat.c
+
+## end   gnulib module lstat-tests
+
+## begin gnulib module netdb-tests
+
+TESTS += test-netdb
+check_PROGRAMS += test-netdb
+
+EXTRA_DIST += test-netdb.c
+
+## end   gnulib module netdb-tests
+
 ## begin gnulib module netinet_in-tests

 TESTS += test-netinet_in
@@ -148,6 +203,24 @@ EXTRA_DIST += test-netinet_in.c

 ## end   gnulib module netinet_in-tests

+## begin gnulib module perror-tests
+
+TESTS += test-perror.sh
+TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='$(srcdir)'
+check_PROGRAMS += test-perror
+EXTRA_DIST += test-perror.c test-perror.sh
+
+## end   gnulib module perror-tests
+
+## begin gnulib module poll-tests
+
+TESTS += test-poll
+check_PROGRAMS += test-poll
+test_poll_LDADD = $(LDADD) @LIBSOCKET@
+EXTRA_DIST += test-poll.c
+
+## end   gnulib module poll-tests
+
 ## begin gnulib module snprintf-tests

 TESTS += test-snprintf
@@ -157,6 +230,21 @@ EXTRA_DIST += test-snprintf.c

 ## end   gnulib module snprintf-tests

+## begin gnulib module sockets
+
+libtests_a_SOURCES += sockets.h sockets.c
+
+## end   gnulib module sockets
+
+## 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
@@ -193,6 +281,14 @@ EXTRA_DIST += test-stdlib.c

 ## end   gnulib module stdlib-tests

+## begin gnulib module strerror-tests
+
+TESTS += test-strerror
+check_PROGRAMS += test-strerror
+EXTRA_DIST += test-strerror.c
+
+## end   gnulib module strerror-tests
+
 ## begin gnulib module string-tests

 TESTS += test-string
@@ -202,6 +298,33 @@ EXTRA_DIST += test-string.c

 ## end   gnulib module string-tests

+## begin gnulib module sys_ioctl
+
+BUILT_SOURCES += $(SYS_IOCTL_H)
+
+# We need the following in order to create <sys/ioctl.h> when the system
+# does not have a complete one.
+sys/ioctl.h: sys_ioctl.in.h
+	@MKDIR_P@ sys
+	rm -f $@-t $@
+	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+	  sed -e 's|@''HAVE_SYS_IOCTL_H''@|$(HAVE_SYS_IOCTL_H)|g' \
+	      -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+	      -e 's|@''NEXT_SYS_IOCTL_H''@|$(NEXT_SYS_IOCTL_H)|g' \
+	      -e 's|@''GNULIB_IOCTL''@|$(GNULIB_IOCTL)|g' \
+	      -e 's|@''SYS_IOCTL_H_HAVE_WINSOCK2_H''@|$(SYS_IOCTL_H_HAVE_WINSOCK2_H)|g' \
+	      -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
+	      < $(srcdir)/sys_ioctl.in.h; \
+	} > $@-t
+	mv $@-t $@
+MOSTLYCLEANFILES += sys/ioctl.h sys/ioctl.h-t
+MOSTLYCLEANDIRS += sys
+
+EXTRA_DIST += sys_ioctl.in.h
+
+## end   gnulib module sys_ioctl
+
 ## begin gnulib module sys_select-tests

 TESTS += test-sys_select
@@ -283,12 +406,6 @@ EXTRA_DIST += test-wchar.c

 ## end   gnulib module wchar-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
diff --git a/gnulib/tests/test-EOVERFLOW.c b/gnulib/tests/accept.c
similarity index 60%
copy from gnulib/tests/test-EOVERFLOW.c
copy to gnulib/tests/accept.c
index 0e5cc09..ae46537 100644
--- a/gnulib/tests/test-EOVERFLOW.c
+++ b/gnulib/tests/accept.c
@@ -1,4 +1,5 @@
-/* Test of EOVERFLOW macro.
+/* accept.c --- wrappers for Windows accept function
+
    Copyright (C) 2008 Free Software Foundation, Inc.

    This program is free software: you can redistribute it and/or modify
@@ -14,19 +15,28 @@
    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 Paolo Bonzini */
+
 #include <config.h>

-#include <errno.h>
+#define WIN32_LEAN_AND_MEAN
+/* Get winsock2.h. */
+#include <sys/socket.h>

-/* Check that it can be used as an initializer outside of a function.  */
-static int err = EOVERFLOW;
+/* Get set_winsock_errno, FD_TO_SOCKET etc. */
+#include "w32sock.h"
+
+#undef accept

 int
-main ()
+rpl_accept (int fd, struct sockaddr *addr, int *addrlen)
 {
-  /* snprintf() callers want to distinguish EINVAL and EOVERFLOW.  */
-  if (err == EINVAL)
-    return 1;
-
-  return 0;
+  SOCKET fh = accept (FD_TO_SOCKET (fd), addr, addrlen);
+  if (fh == INVALID_SOCKET)
+    {
+      set_winsock_errno ();
+      return -1;
+    }
+  else
+    return SOCKET_TO_FD (fh);
 }
diff --git a/gnulib/tests/test-EOVERFLOW.c b/gnulib/tests/bind.c
similarity index 63%
copy from gnulib/tests/test-EOVERFLOW.c
copy to gnulib/tests/bind.c
index 0e5cc09..108a239 100644
--- a/gnulib/tests/test-EOVERFLOW.c
+++ b/gnulib/tests/bind.c
@@ -1,4 +1,5 @@
-/* Test of EOVERFLOW macro.
+/* bind.c --- wrappers for Windows bind function
+
    Copyright (C) 2008 Free Software Foundation, Inc.

    This program is free software: you can redistribute it and/or modify
@@ -14,19 +15,26 @@
    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 Paolo Bonzini */
+
 #include <config.h>

-#include <errno.h>
+#define WIN32_LEAN_AND_MEAN
+/* Get winsock2.h. */
+#include <sys/socket.h>
+
+/* Get set_winsock_errno, FD_TO_SOCKET etc. */
+#include "w32sock.h"

-/* Check that it can be used as an initializer outside of a function.  */
-static int err = EOVERFLOW;
+#undef bind

 int
-main ()
+rpl_bind (int fd, struct sockaddr *sockaddr, int len)
 {
-  /* snprintf() callers want to distinguish EINVAL and EOVERFLOW.  */
-  if (err == EINVAL)
-    return 1;
+  SOCKET sock = FD_TO_SOCKET (fd);
+  int r = bind (sock, sockaddr, len);
+  if (r < 0)
+    set_winsock_errno ();

-  return 0;
+  return r;
 }
diff --git a/gnulib/tests/dummy.c b/gnulib/tests/dummy.c
deleted file mode 100644
index ccb5c26..0000000
--- a/gnulib/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/gnulib/tests/intprops.h b/gnulib/tests/intprops.h
deleted file mode 100644
index 002161e..0000000
--- a/gnulib/tests/intprops.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* intprops.h -- properties of integer types
-
-   Copyright (C) 2001, 2002, 2003, 2004, 2005 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 Paul Eggert.  */
-
-#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)
-
-/* 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)
-
-/* True if the arithmetic type T is signed.  */
-#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) \
-  ((t) (! TYPE_SIGNED (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))))
-
-/* Return zero if T can be determined to be an unsigned type.
-   Otherwise, return 1.
-   When compiling with GCC, INT_STRLEN_BOUND uses this macro to obtain a
-   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
-
-/* 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) \
-  ((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)
diff --git a/gnulib/tests/test-EOVERFLOW.c b/gnulib/tests/ioctl.c
similarity index 58%
copy from gnulib/tests/test-EOVERFLOW.c
copy to gnulib/tests/ioctl.c
index 0e5cc09..a23d363 100644
--- a/gnulib/tests/test-EOVERFLOW.c
+++ b/gnulib/tests/ioctl.c
@@ -1,4 +1,5 @@
-/* Test of EOVERFLOW macro.
+/* ioctl.c --- wrappers for Windows ioctl function
+
    Copyright (C) 2008 Free Software Foundation, Inc.

    This program is free software: you can redistribute it and/or modify
@@ -14,19 +15,35 @@
    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 Paolo Bonzini */
+
 #include <config.h>

-#include <errno.h>
+#include <stdarg.h>
+
+#define WIN32_LEAN_AND_MEAN
+/* Get winsock2.h. */
+#include <sys/socket.h>

-/* Check that it can be used as an initializer outside of a function.  */
-static int err = EOVERFLOW;
+/* Get set_winsock_errno, FD_TO_SOCKET etc. */
+#include "w32sock.h"

 int
-main ()
+rpl_ioctl (int fd, int req, ...)
 {
-  /* snprintf() callers want to distinguish EINVAL and EOVERFLOW.  */
-  if (err == EINVAL)
-    return 1;
+  void *buf;
+  va_list args;
+  SOCKET sock;
+  int r;
+
+  va_start (args, req);
+  buf = va_arg (args, void *);
+  va_end (args);
+
+  sock = FD_TO_SOCKET (fd);
+  r = ioctlsocket (sock, req, buf);
+  if (r < 0)
+    set_winsock_errno ();

-  return 0;
+  return r;
 }
diff --git a/gnulib/tests/test-EOVERFLOW.c b/gnulib/tests/listen.c
similarity index 64%
copy from gnulib/tests/test-EOVERFLOW.c
copy to gnulib/tests/listen.c
index 0e5cc09..49e0a08 100644
--- a/gnulib/tests/test-EOVERFLOW.c
+++ b/gnulib/tests/listen.c
@@ -1,4 +1,5 @@
-/* Test of EOVERFLOW macro.
+/* listen.c --- wrappers for Windows listen function
+
    Copyright (C) 2008 Free Software Foundation, Inc.

    This program is free software: you can redistribute it and/or modify
@@ -14,19 +15,26 @@
    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 Paolo Bonzini */
+
 #include <config.h>

-#include <errno.h>
+#define WIN32_LEAN_AND_MEAN
+/* Get winsock2.h. */
+#include <sys/socket.h>
+
+/* Get set_winsock_errno, FD_TO_SOCKET etc. */
+#include "w32sock.h"

-/* Check that it can be used as an initializer outside of a function.  */
-static int err = EOVERFLOW;
+#undef listen

 int
-main ()
+rpl_listen (int fd, int backlog)
 {
-  /* snprintf() callers want to distinguish EINVAL and EOVERFLOW.  */
-  if (err == EINVAL)
-    return 1;
+  SOCKET sock = FD_TO_SOCKET (fd);
+  int r = listen (sock, backlog);
+  if (r < 0)
+    set_winsock_errno ();

-  return 0;
+  return r;
 }
diff --git a/gnulib/tests/test-EOVERFLOW.c b/gnulib/tests/sockets.c
similarity index 60%
copy from gnulib/tests/test-EOVERFLOW.c
copy to gnulib/tests/sockets.c
index 0e5cc09..658119e 100644
--- a/gnulib/tests/test-EOVERFLOW.c
+++ b/gnulib/tests/sockets.c
@@ -1,4 +1,5 @@
-/* Test of EOVERFLOW macro.
+/* sockets.c --- wrappers for Windows socket functions
+
    Copyright (C) 2008 Free Software Foundation, Inc.

    This program is free software: you can redistribute it and/or modify
@@ -14,19 +15,43 @@
    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 Simon Josefsson */
+
 #include <config.h>

-#include <errno.h>
+/* This includes winsock2.h on MinGW. */
+#include <sys/socket.h>
+
+#include "sockets.h"
+
+int
+gl_sockets_startup (int version)
+{
+#if WINDOWS_SOCKETS
+  WSADATA data;
+  int err;
+
+  err = WSAStartup (version, &data);
+  if (err != 0)
+    return 1;
+
+  if (data.wVersion < version)
+    return 2;
+#endif

-/* Check that it can be used as an initializer outside of a function.  */
-static int err = EOVERFLOW;
+  return 0;
+}

 int
-main ()
+gl_sockets_cleanup (void)
 {
-  /* snprintf() callers want to distinguish EINVAL and EOVERFLOW.  */
-  if (err == EINVAL)
+#if WINDOWS_SOCKETS
+  int err;
+
+  err = WSACleanup ();
+  if (err != 0)
     return 1;
+#endif

   return 0;
 }
diff --git a/gnulib/tests/test-EOVERFLOW.c b/gnulib/tests/sockets.h
similarity index 67%
copy from gnulib/tests/test-EOVERFLOW.c
copy to gnulib/tests/sockets.h
index 0e5cc09..3ab16a0 100644
--- a/gnulib/tests/test-EOVERFLOW.c
+++ b/gnulib/tests/sockets.h
@@ -1,4 +1,5 @@
-/* Test of EOVERFLOW macro.
+/* sockets.h - wrappers for Windows socket functions
+
    Copyright (C) 2008 Free Software Foundation, Inc.

    This program is free software: you can redistribute it and/or modify
@@ -14,19 +15,18 @@
    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>
+/* Written by Simon Josefsson */

-#include <errno.h>
+#ifndef SOCKETS_H
+# define SOCKETS_H 1

-/* Check that it can be used as an initializer outside of a function.  */
-static int err = EOVERFLOW;
+#define SOCKETS_1_0 0x100
+#define SOCKETS_1_1 0x101
+#define SOCKETS_2_0 0x200
+#define SOCKETS_2_1 0x201
+#define SOCKETS_2_2 0x202

-int
-main ()
-{
-  /* snprintf() callers want to distinguish EINVAL and EOVERFLOW.  */
-  if (err == EINVAL)
-    return 1;
+int gl_sockets_startup (int version);
+int gl_sockets_cleanup (void);

-  return 0;
-}
+#endif
diff --git a/gnulib/tests/sys_ioctl.in.h b/gnulib/tests/sys_ioctl.in.h
new file mode 100644
index 0000000..65c2c4a
--- /dev/null
+++ b/gnulib/tests/sys_ioctl.in.h
@@ -0,0 +1,70 @@
+/* Substitute for and wrapper around <sys/ioctl.h>.
+   Copyright (C) 2008 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 _GL_SYS_IOCTL_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+
+/* The include_next requires a split double-inclusion guard.  */
+#if @HAVE_SYS_IOCTL_H@
+# @INCLUDE_NEXT@ @NEXT_SYS_IOCTL_H@
+#endif
+
+#ifndef _GL_SYS_IOCTL_H
+#define _GL_SYS_IOCTL_H
+
+/* AIX 5.1 and Solaris 10 declare ioctl() in <unistd.h> and in <stropts.h>,
+   but not in <sys/ioctl.h>.  */
+#include <unistd.h>
+
+/* The definition of GL_LINK_WARNING is copied here.  */
+
+
+/* Declare overridden functions.  */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#if @GNULIB_IOCTL@
+# if @SYS_IOCTL_H_HAVE_WINSOCK2_H@
+#  undef ioctl
+#  define ioctl rpl_ioctl
+extern int ioctl (int fd, int request, ... /* {void *,char *} arg */);
+# endif
+#elif @SYS_IOCTL_H_HAVE_WINSOCK2_H@
+# undef ioctl
+# define ioctl ioctl_used_without_requesting_gnulib_module_ioctl
+#elif defined GNULIB_POSIXCHECK
+# undef ioctl
+# define ioctl(f,c,a) \
+    (GL_LINK_WARNING ("ioctl does not portably work on sockets - " \
+                      "use gnulib module ioctl for portability"), \
+     ioctl (f, c, a))
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* _GL_SYS_IOCTL_H */
+#endif /* _GL_SYS_IOCTL_H */
diff --git a/gnulib/tests/test-EOVERFLOW b/gnulib/tests/test-EOVERFLOW
new file mode 100755
index 0000000000000000000000000000000000000000..ea3a8a27290fea9dd71beab276a9180b71a4847b
GIT binary patch
literal 6680
zcmcIoU2Ggz6+Zjp*eP!8n3%YUQAX-Ua*#aT7{_sdz}SxM*|3d`<3ON=*^PH>Z?)dF
zcE(`?MYV7XTDfkGctPT!72*K|4|zdU0*OQ>MBym~ghCNeg+!SCpj3cr9@^!cJLlLl
zvvxqBUdwy#`R@77J@?+Z=g!=xhSMX_NCc!r;p0HsV%$)W_Y0uCPpORcLlYSAK{x=r
z5NW`FL$#3fY9g<&YmrTC7eg7RdX#~v;Z<06dK!q72uV_ZTgBk2Cp#NGRU}5P0OC=s
z8n<hW8HI~%<v28nhk2wD&t#s-Jdu~lF&2?BJ{lYSce20EsDT>k1_}1QCCQe`_+2+g
z^#XOOq!Ew_r2&W(-lveq6t=j(kT@SH<S+E~K2pea7xKl0N_VBdue+~TcS?GXioX@z
z&=5z@oKp^EK6bNvT1TprKkDDVHas;zHdH89;`3AzR9E&PqSc`Q5AT2<N4yOlg!8+M
z0PFJ#4?s$}h`+7yRxP<Z6KMP@<3<QC?O=Zr@iuq>%(#IyU%~mT*hR-Jm2H~E59>*=
zteLq|(Q@2u*|jXNPG7Vp?3ujd+U21_)^ThHtm%9)4;KEofF9=E*|MF@k%J`ZQ&j6i
zM^tA=bJ=_mEIXHVv)FLKaXcKMVh%>rslg$uNAJ;(No*0E`w0KhnnvI(HqrW0SvZi#
zWsJhtJry>ZGO9*vD(gr<2hR_!p*(wpn@evrtv`m9_1Ea<8gk5~pEs@5j(sPtLGAE&
z@werWfi==+iSpN1Yqi?ZH&fM@zhG8xn@e}@jZdboUs-H0z`TBSRf+2b6zkW~@E@zI
z)Q7p;Fn|usXRf%>+D+BPs=u5wt9Q?m;o`}0w1b6DzSQ5C0du+iG|{?~q+H#InJedO
z=80FF!!3svDHwBQFk)644x>?R-!)~m+`gYECtfMv{zXF!s}bt%u^VgC)6;s(p{I!k
z=gg&(Z$~tAP`&FOc!?m2t@URHc9g2F-599-nZ|u%ZFN<(qV$))lQ*9~vsy^pN>`su
zY?v$EUq;92m6I-sYA*3=8XMQsRX1_ZtUjK=(ZA83KJv~$_1#qUpXSwfVyWtH)}422
zHS?J_-Oi)Gr+(Ab+v)1xPF3F?sO|fcxwIBBPrP1!&0Kywfm2yXw5FGHiH<bZwDhu@
z=t?g?nMmR=`z6fH`NWC8hda|;+Nik?{Y1mjwH!KygI#*P3D;pcMhy#Z@eFxuwO*oF
z=qaFQ2%o-#v5#svK`I~Ml70;9`%o58CQ#Ch(*CCs`O*YLDy@-Nb7RvgK1_tuSwPQ&
zKhK5j4~Fbt#1J?IlUtQHdr^K1@hSnQpO1cR*YqA^sqwkkO8nUd!h8k8QbnM!F1YNG
zupD9o!D-J?Y4*fs{&<je$zyTWji{k&64!Xl(`61S-2Q;F0{A9NIj%ccZ)Yh&tpO>#
zpJk53Ugout3Hw<lIo}E1!MdC$!k6<wbewKVrLe*A<2))|=H(vicetIqd(VZO<Kd1j
z^0>k{j1CQbMC-!i@QBun*}X^WNhbS`CX>gtt_eG*nOWDvyZesdsri2xCza=9Px6@7
zWmo3ya(>P(y4ga#+xNoq{^Qb}OLK1a0_cug_T;S8@<lw>=0Pu(Tw5O)Om(~28PI35
z&MfG;OGPAl(k+8NQ(Vw5+GQtSDh3n_+sbw!O9ZaX7hKTQ@u<6Y1?%d-)XODx{^|Ct
zHC@im+16|hxuStSh3Bw?9eU!4DQrZa*}41_c346;_@gV|o*z6$kyM(asjgf4{{=XR
zBzneWe?inh4GRO5)BHvDgJ2J1h4z~8<^56KD>X4>DS1QSqgbKbA$%ihpax(t(66+u
zvt0JE_@VbJ$|b_DL=DscDh%9Gn%4)#E_~VdpFoUqjqoLZjdKE$e8p}8?;3=S;y>jI
z;Y)tF!~8ZTO1xqxauVAq_lPd}XM_0~^J$L!@iPolSRvoSmwea39m+VR|M2+dLVU@e
z$!+*F&td)-5u>;y-^=@^8RDafDiVk2Wvux58P01NHq^wBrSRpw@GBwyBJ&s7@D@4u
z72yfAgcX1Pa=xAC0qqe(meRk#bVd_j)_Hc9p_*oyAGQ}=<Tscv>sMgDd|xG$x2+%H
z3GzaSzsmeo?*CaaWGU+>@b{U|j~jk}W>k}Whlb}X%)cDs)0-)kBp<;4iT`7?rTLTo
z4dxrn5BC?=e~Mfhs_^B!l<(ooy#DfjB7BMKTBv{duGnBhu}3piL>Ku>ME&v0`-=ML
z#5PT_wtj>s^4Hkp=WG1FqwV%M5~p|&p6I{B3SlyS`EE@9m;65>m#0WvDk=PiP-94i
zy}rKv4vz5)-(UP7*28?#<=OX}W_Uy0<b|Vis2l%f{F2vbm@;-hKgkB`p$<c;pHf$k
zQM6HG8$7ysPvUQkVI)S>@I$H|gE*c?+u;o$=Z&8f!zWtKks#i<`F<M2n?Uk@5Z?`w
z&x80j_X21T!;@6<Z_vJZ^S&*J*WYVUdkpq~<iVhQ3*H+Uen{10_?0ht%ikEor%Uot
z5O2f$lJP^T9)tIT<PU#i48P7KF9h-S&3l9({(;T!jv&4tWPb+n4v>8p#2@mjs_s4S
z&G5sx5on`*6vum?0Eh}b_mOSp;X?|qpND>h*U!T+;!*snyBX@2u0$fR6~F9{Cm8SN
zd?fp>!hVbf18ZAlr}&>n6N<kpv|ir1*9skt#+DPTdFNSu{6D}pieC#oKUWdoZr*-{
zcqCfCj_Zg+bT4#<;`!GOcr#8&BwGLcv?H!T{qvw9-iC25^883{O9~#E|KrLJbsj7u
zJK&#Fe(LvKM&Uspq&<cBUf+I<v&nOaw{8>vx5+-bAG&zm#pCxB-Uf78<u5-%oW@Jn
zVN|N>7l1C<w!6oCnQ<fJ|F=8X|AGC}y$TgN>#5vU_%?ZLDqAS{?lWPk>^klO-e67P
zE#%PT*o2i%ot>m>PU}=aJ3ZuU%9X5{Lg_-bV5v_tE4xqu{Op=9*sh(^`;y0dfEuiP
zu0mQbcwcw9g}J#)($DajQ>vShiGfFlEzzhOsc-e7z5`V+uI;$p!(*Qwo)}4weTJeQ
zO^*!@q^+@$k+Z{-*5trodYGc8k4-CEE@v;P8`S`yu5!UT_1QB6kEVuzz8&TE)w`md
zau)bXmrZ?BcK<8j@D;CN`0sM9)EIV@%NMN$$IfAtfv$5-$(qd;a|K&wUuHtx8&go~
Q6T0rYn6Ht&D`jQ!Z=>`m&;S4c

literal 0
HcmV?d00001

diff --git a/gnulib/tests/test-errno.c b/gnulib/tests/test-errno.c
new file mode 100644
index 0000000..4642027
--- /dev/null
+++ b/gnulib/tests/test-errno.c
@@ -0,0 +1,117 @@
+/* Test of <errno.h> substitute.
+   Copyright (C) 2008 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 <bruno@xxxxxxxxx>, 2008.  */
+
+#include <config.h>
+
+#include <errno.h>
+
+/* Verify that the POSIX mandated errno values exist and can be used as
+   initializers outside of a function.
+   The variable names happen to match the Linux/x86 error numbers.  */
+int e1 = EPERM;
+int e2 = ENOENT;
+int e3 = ESRCH;
+int e4 = EINTR;
+int e5 = EIO;
+int e6 = ENXIO;
+int e7 = E2BIG;
+int e8 = ENOEXEC;
+int e9 = EBADF;
+int e10 = ECHILD;
+int e11 = EAGAIN;
+int e11a = EWOULDBLOCK;
+int e12 = ENOMEM;
+int e13 = EACCES;
+int e14 = EFAULT;
+int e16 = EBUSY;
+int e17 = EEXIST;
+int e18 = EXDEV;
+int e19 = ENODEV;
+int e20 = ENOTDIR;
+int e21 = EISDIR;
+int e22 = EINVAL;
+int e23 = ENFILE;
+int e24 = EMFILE;
+int e25 = ENOTTY;
+int e26 = ETXTBSY;
+int e27 = EFBIG;
+int e28 = ENOSPC;
+int e29 = ESPIPE;
+int e30 = EROFS;
+int e31 = EMLINK;
+int e32 = EPIPE;
+int e33 = EDOM;
+int e34 = ERANGE;
+int e35 = EDEADLK;
+int e36 = ENAMETOOLONG;
+int e37 = ENOLCK;
+int e38 = ENOSYS;
+int e39 = ENOTEMPTY;
+int e40 = ELOOP;
+int e42 = ENOMSG;
+int e43 = EIDRM;
+int e67 = ENOLINK;
+int e71 = EPROTO;
+int e72 = EMULTIHOP;
+int e74 = EBADMSG;
+int e75 = EOVERFLOW;
+int e84 = EILSEQ;
+int e88 = ENOTSOCK;
+int e89 = EDESTADDRREQ;
+int e90 = EMSGSIZE;
+int e91 = EPROTOTYPE;
+int e92 = ENOPROTOOPT;
+int e93 = EPROTONOSUPPORT;
+int e95 = EOPNOTSUPP;
+int e95a = ENOTSUP;
+int e97 = EAFNOSUPPORT;
+int e98 = EADDRINUSE;
+int e99 = EADDRNOTAVAIL;
+int e100 = ENETDOWN;
+int e101 = ENETUNREACH;
+int e102 = ENETRESET;
+int e103 = ECONNABORTED;
+int e104 = ECONNRESET;
+int e105 = ENOBUFS;
+int e106 = EISCONN;
+int e107 = ENOTCONN;
+int e110 = ETIMEDOUT;
+int e111 = ECONNREFUSED;
+int e113 = EHOSTUNREACH;
+int e114 = EALREADY;
+int e115 = EINPROGRESS;
+int e116 = ESTALE;
+int e122 = EDQUOT;
+int e125 = ECANCELED;
+
+/* Don't verify that these errno values are all different, except for possibly
+   EWOULDBLOCK == EAGAIN.  Even Linux/x86 does not pass this check: it has
+   ENOTSUP == EOPNOTSUPP.  */
+
+int
+main ()
+{
+  /* Verify that errno can be assigned.  */
+  errno = EOVERFLOW;
+
+  /* snprintf() callers want to distinguish EINVAL and EOVERFLOW.  */
+  if (errno == EINVAL)
+    return 1;
+
+  return 0;
+}
diff --git a/gnulib/tests/test-getaddrinfo.c b/gnulib/tests/test-getaddrinfo.c
index bfdb9cf..a887cb1 100644
--- a/gnulib/tests/test-getaddrinfo.c
+++ b/gnulib/tests/test-getaddrinfo.c
@@ -18,7 +18,7 @@
 /* Written by Simon Josefsson.  */

 #include <config.h>
-#include "getaddrinfo.h"
+#include <netdb.h>
 #include <arpa/inet.h>
 #include <netinet/in.h>
 #include <stdio.h>
diff --git a/gnulib/tests/test-gethostname.c b/gnulib/tests/test-gethostname.c
new file mode 100644
index 0000000..ef50953
--- /dev/null
+++ b/gnulib/tests/test-gethostname.c
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2008 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 <unistd.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+
+#define NOHOSTNAME "magic-gnulib-test-string"
+
+int
+main (int argc, char *argv[])
+{
+  char buf[2500];
+  int rc;
+
+  strcpy (buf, NOHOSTNAME);
+
+  rc = gethostname (buf, sizeof (buf));
+
+  if (rc != 0)
+    {
+      printf ("gethostname failed, rc %d errno %d\n", rc, errno);
+      return 1;
+    }
+
+  if (strcmp (buf, NOHOSTNAME) == 0)
+    {
+      printf ("gethostname left buffer untouched.\n");
+      return 1;
+    }
+
+  if (argc > 1)
+    printf ("hostname: %s\n", buf);
+
+  return 0;
+}
diff --git a/gnulib/tests/test-EOVERFLOW.c b/gnulib/tests/test-lstat.c
similarity index 73%
copy from gnulib/tests/test-EOVERFLOW.c
copy to gnulib/tests/test-lstat.c
index 0e5cc09..1a0a0f2 100644
--- a/gnulib/tests/test-EOVERFLOW.c
+++ b/gnulib/tests/test-lstat.c
@@ -1,4 +1,4 @@
-/* Test of EOVERFLOW macro.
+/* Test of lstat() function.
    Copyright (C) 2008 Free Software Foundation, Inc.

    This program is free software: you can redistribute it and/or modify
@@ -14,19 +14,24 @@
    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 Simon Josefsson, 2008.  */
+
 #include <config.h>

-#include <errno.h>
+#include <sys/stat.h>

-/* Check that it can be used as an initializer outside of a function.  */
-static int err = EOVERFLOW;
+#include <stdio.h>

 int
-main ()
+main (int argc, char **argv)
 {
-  /* snprintf() callers want to distinguish EINVAL and EOVERFLOW.  */
-  if (err == EINVAL)
-    return 1;
+  struct stat buf;
+
+  if (lstat ("/", &buf) != 0)
+    {
+      perror ("lstat");
+      return 1;
+    }

   return 0;
 }
diff --git a/gnulib/tests/test-EOVERFLOW.c b/gnulib/tests/test-netdb.c
similarity index 68%
rename from gnulib/tests/test-EOVERFLOW.c
rename to gnulib/tests/test-netdb.c
index 0e5cc09..cde9105 100644
--- a/gnulib/tests/test-EOVERFLOW.c
+++ b/gnulib/tests/test-netdb.c
@@ -1,5 +1,5 @@
-/* Test of EOVERFLOW macro.
-   Copyright (C) 2008 Free Software Foundation, Inc.
+/* Test of <netdb.h> substitute.
+   Copyright (C) 2007-2008 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
@@ -14,19 +14,16 @@
    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>
+/* Written by Simon Josefsson <simon@xxxxxxxxxxxxx>, 2008.  */

-#include <errno.h>
+#include <config.h>
+#include <netdb.h>

-/* Check that it can be used as an initializer outside of a function.  */
-static int err = EOVERFLOW;
+/* Check that the 'struct hostent' type is defined.  */
+struct hostent t1;

 int
-main ()
+main (void)
 {
-  /* snprintf() callers want to distinguish EINVAL and EOVERFLOW.  */
-  if (err == EINVAL)
-    return 1;
-
   return 0;
 }
diff --git a/gnulib/tests/test-perror.c b/gnulib/tests/test-perror.c
new file mode 100644
index 0000000..2faa8ae
--- /dev/null
+++ b/gnulib/tests/test-perror.c
@@ -0,0 +1,34 @@
+/* Test of perror() function.
+   Copyright (C) 2008 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>
+
+#include <stdio.h>
+
+#include <errno.h>
+
+int
+main (int argc, char **argv)
+{
+  const char *prefix = (argc > 1 ? argv[1] : NULL);
+
+  errno = EACCES;    perror (prefix);
+  errno = ETIMEDOUT; perror (prefix);
+  errno = EOVERFLOW; perror (prefix);
+
+  return 0;
+}
diff --git a/gnulib/tests/test-perror.sh b/gnulib/tests/test-perror.sh
new file mode 100755
index 0000000..f2c8fdc
--- /dev/null
+++ b/gnulib/tests/test-perror.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+tmpfiles=""
+trap 'rm -fr $tmpfiles' 1 2 3 15
+
+# Test NULL prefix. Result should not contain a number.
+tmpfiles="$tmpfiles t-perror.tmp"
+./test-perror${EXEEXT} 2>&1 >/dev/null | LC_ALL=C tr -d '\r' > t-perror.tmp
+if grep '[0-9]' t-perror.tmp > /dev/null; then
+  rm -fr $tmpfiles; exit 1
+fi
+
+# Test empty prefix. Result should be the same.
+tmpfiles="$tmpfiles t-perror1.tmp"
+./test-perror${EXEEXT} '' 2>&1 >/dev/null | LC_ALL=C tr -d '\r' > t-perror1.tmp
+diff t-perror.tmp t-perror1.tmp
+test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+
+# Test non-empty prefix.
+tmpfiles="$tmpfiles t-perror2.tmp t-perror3.tmp"
+./test-perror${EXEEXT} 'foo' 2>&1 >/dev/null | LC_ALL=C tr -d '\r' > t-perror3.tmp
+sed -e 's/^/foo: /' < t-perror.tmp > t-perror2.tmp
+diff t-perror2.tmp t-perror3.tmp
+test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+
+rm -fr $tmpfiles
+exit 0
diff --git a/gnulib/tests/test-poll.c b/gnulib/tests/test-poll.c
new file mode 100644
index 0000000..77b06d9
--- /dev/null
+++ b/gnulib/tests/test-poll.c
@@ -0,0 +1,376 @@
+/* Test of poll() function.
+   Copyright (C) 2008 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.  */
+
+/* Written by Paolo Bonzini.  */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <poll.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include "sockets.h"
+
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+# define WIN32_NATIVE
+#endif
+
+#ifdef WIN32_NATIVE
+#include <io.h>
+#define pipe(x) _pipe(x, 256, O_BINARY)
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#endif
+
+#ifndef SO_REUSEPORT
+#define SO_REUSEPORT    SO_REUSEADDR
+#endif
+
+#define TEST_PORT	12345
+
+
+/* Minimal testing infrastructure.  */
+
+static int failures;
+
+static void
+failed (const char *reason)
+{
+  if (++failures > 1)
+    printf ("  ");
+  printf ("failed (%s)\n", reason);
+}
+
+static int
+test (void (*fn) (void), const char *msg)
+{
+  failures = 0;
+  printf ("%s... ", msg);
+  fflush (stdout);
+  fn ();
+
+  if (!failures)
+    printf ("passed\n");
+
+  return failures;
+}
+
+
+/* Funny socket code.  */
+
+static int
+open_server_socket ()
+{
+  int s, x;
+  struct sockaddr_in ia;
+
+  s = socket (AF_INET, SOCK_STREAM, 0);
+
+  memset (&ia, 0, sizeof (ia));
+  ia.sin_family = AF_INET;
+  inet_pton (AF_INET, "127.0.0.1", &ia.sin_addr);
+  ia.sin_port = htons (TEST_PORT);
+  if (bind (s, (struct sockaddr *) &ia, sizeof (ia)) < 0)
+    {
+      perror ("bind");
+      exit (77);
+    }
+
+  x = 1;
+  setsockopt (s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof (x));
+
+  if (listen (s, 1) < 0)
+    {
+      perror ("listen");
+      exit (77);
+    }
+
+  return s;
+}
+
+static int
+connect_to_socket (int blocking)
+{
+  int s;
+  struct sockaddr_in ia;
+
+  s = socket (AF_INET, SOCK_STREAM, 0);
+
+  memset (&ia, 0, sizeof (ia));
+  ia.sin_family = AF_INET;
+  inet_pton (AF_INET, "127.0.0.1", &ia.sin_addr);
+  ia.sin_port = htons (TEST_PORT);
+
+  if (!blocking)
+    {
+#ifdef WIN32_NATIVE
+      unsigned long iMode = 1;
+      ioctl (s, FIONBIO, (char *) &iMode);
+
+#elif defined F_GETFL
+      int oldflags = fcntl (s, F_GETFL, NULL);
+
+      if (!(oldflags & O_NONBLOCK))
+        fcntl (s, F_SETFL, oldflags | O_NONBLOCK);
+#endif
+    }
+
+  if (connect (s, (struct sockaddr *) &ia, sizeof (ia)) < 0
+      && (blocking || errno != EINPROGRESS))
+    {
+      perror ("connect");
+      exit (77);
+    }
+
+  return s;
+}
+
+
+/* A slightly more convenient interface to poll(2).  */
+
+static int
+poll1 (int fd, int ev, int time)
+{
+  struct pollfd pfd;
+  int r;
+
+  pfd.fd = fd;
+  pfd.events = ev;
+  pfd.revents = 0;
+  r = poll (&pfd, 1, time);
+  if (r < 0)
+    return r;
+
+  if (pfd.revents & ~(POLLHUP | POLLERR | POLLNVAL | ev))
+    failed ("invalid flag combination (unrequested events)");
+
+  return pfd.revents;
+}
+
+static int
+poll1_nowait (int fd, int ev)
+{
+  return poll1 (fd, ev, 0);
+}
+
+static int
+poll1_wait (int fd, int ev)
+{
+  return poll1 (fd, ev, -1);
+}
+
+
+/* Test poll(2) for TTYs.  */
+
+#ifdef INTERACTIVE
+static void
+test_tty (void)
+{
+  if (poll1_nowait (0, POLLIN | POLLRDNORM) != 0)
+    failed ("can read");
+  if (poll1_nowait (0, POLLOUT) == 0)
+    failed ("cannot write");
+
+  if (poll1_wait (0, POLLIN | POLLRDNORM) == 0)
+    failed ("return with infinite timeout");
+
+  getchar ();
+  if (poll1_nowait (0, POLLIN | POLLRDNORM) != 0)
+    failed ("can read after getc");
+}
+#endif
+
+
+/* Test poll(2) for unconnected nonblocking sockets.  */
+
+static void
+test_connect_first (void)
+{
+  int s = open_server_socket ();
+  struct sockaddr_in ia;
+  socklen_t addrlen;
+
+  int c1, c2;
+
+  if (poll1_nowait (s, POLLIN | POLLRDNORM | POLLRDBAND) != 0)
+    failed ("can read, socket not connected");
+
+  c1 = connect_to_socket (false);
+
+  if (poll1_wait (s, POLLIN | POLLRDNORM | POLLRDBAND) != (POLLIN | POLLRDNORM))
+    failed ("expecting POLLIN | POLLRDNORM on passive socket");
+  if (poll1_nowait (s, POLLIN | POLLRDBAND) != POLLIN)
+    failed ("expecting POLLIN on passive socket");
+  if (poll1_nowait (s, POLLRDNORM | POLLRDBAND) != POLLRDNORM)
+    failed ("expecting POLLRDNORM on passive socket");
+
+  addrlen = sizeof (ia);
+  c2 = accept (s, (struct sockaddr *) &ia, &addrlen);
+  close (s);
+  close (c1);
+  close (c2);
+}
+
+
+/* Test poll(2) for unconnected blocking sockets.  */
+
+static void
+test_accept_first (void)
+{
+#ifndef WIN32_NATIVE
+  int s = open_server_socket ();
+  struct sockaddr_in ia;
+  socklen_t addrlen;
+  char buf[3];
+  int c, pid;
+
+  pid = fork ();
+  if (pid < 0)
+    return;
+
+  if (pid == 0)
+    {
+      addrlen = sizeof (ia);
+      c = accept (s, (struct sockaddr *) &ia, &addrlen);
+      close (s);
+      write (c, "foo", 3);
+      read (c, buf, 3);
+      shutdown (c, SHUT_RD);
+      close (c);
+      exit (0);
+    }
+  else
+    {
+      close (s);
+      c = connect_to_socket (true);
+      if (poll1_nowait (c, POLLOUT | POLLWRNORM | POLLRDBAND)
+	  != (POLLOUT | POLLWRNORM))
+        failed ("cannot write after blocking connect");
+      write (c, "foo", 3);
+      wait (&pid);
+      if (poll1_wait (c, POLLIN) != POLLIN)
+        failed ("cannot read data left in the socket by closed process");
+      read (c, buf, 3);
+      write (c, "foo", 3);
+      if ((poll1_wait (c, POLLIN | POLLOUT) & (POLLHUP | POLLERR)) == 0)
+        failed ("expecting POLLHUP after shutdown");
+      close (c);
+    }
+#endif
+}
+
+
+/* Common code for pipes and connected sockets.  */
+
+static void
+test_pair (int rd, int wd)
+{
+  char buf[3];
+  if (poll1_wait (wd, POLLIN | POLLRDNORM | POLLOUT | POLLWRNORM | POLLRDBAND)
+      != (POLLOUT | POLLWRNORM))
+    failed ("expecting POLLOUT | POLLWRNORM before writing");
+  if (poll1_nowait (wd, POLLIN | POLLRDNORM | POLLOUT | POLLRDBAND) != POLLOUT)
+    failed ("expecting POLLOUT before writing");
+  if (poll1_nowait (wd, POLLIN | POLLRDNORM | POLLWRNORM | POLLRDBAND)
+      != POLLWRNORM)
+    failed ("expecting POLLWRNORM before writing");
+
+  write (wd, "foo", 3);
+  if (poll1_wait (rd, POLLIN | POLLRDNORM) != (POLLIN | POLLRDNORM))
+    failed ("expecting POLLIN | POLLRDNORM after writing");
+  if (poll1_nowait (rd, POLLIN) != POLLIN)
+    failed ("expecting POLLIN after writing");
+  if (poll1_nowait (rd, POLLRDNORM) != POLLRDNORM)
+    failed ("expecting POLLRDNORM after writing");
+
+  read (rd, buf, 3);
+}
+
+
+/* Test poll(2) on connected sockets.  */
+
+static void
+test_socket_pair (void)
+{
+  struct sockaddr_in ia;
+
+  socklen_t addrlen = sizeof (ia);
+  int s = open_server_socket ();
+  int c1 = connect_to_socket (false);
+  int c2 = accept (s, (struct sockaddr *) &ia, &addrlen);
+
+  close (s);
+
+  test_pair (c1, c2);
+  close (c1);
+  write (c2, "foo", 3);
+  if ((poll1_nowait (c2, POLLIN | POLLOUT) & (POLLHUP | POLLERR)) == 0)
+    failed ("expecting POLLHUP after shutdown");
+
+  close (c2);
+}
+
+
+/* Test poll(2) on pipes.  */
+
+static void
+test_pipe (void)
+{
+  int fd[2];
+
+  pipe (fd);
+  test_pair (fd[0], fd[1]);
+  close (fd[0]);
+  if ((poll1_wait (fd[1], POLLIN | POLLOUT) & (POLLHUP | POLLERR)) == 0)
+    failed ("expecting POLLHUP after shutdown");
+
+  close (fd[1]);
+}
+
+
+/* Do them all.  */
+
+int
+main ()
+{
+  int result;
+
+  gl_sockets_startup (SOCKETS_1_1);
+
+#ifdef INTERACTIVE
+  printf ("Please press Enter\n");
+  test (test_tty, "TTY");
+#endif
+
+  result = test (test_connect_first, "Unconnected socket test");
+  result += test (test_socket_pair, "Connected sockets test");
+  result += test (test_accept_first, "General socket test with fork");
+  result += test (test_pipe, "Pipe test");
+
+  exit (result);
+}
diff --git a/gnulib/tests/test-sockets.c b/gnulib/tests/test-sockets.c
new file mode 100644
index 0000000..514409d
--- /dev/null
+++ b/gnulib/tests/test-sockets.c
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2008 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 (int argc, char *argv[])
+{
+  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;
+    }
+
+  return 0;
+}
diff --git a/gnulib/tests/test-strerror.c b/gnulib/tests/test-strerror.c
new file mode 100644
index 0000000..3d9814d
--- /dev/null
+++ b/gnulib/tests/test-strerror.c
@@ -0,0 +1,65 @@
+/* Test of strerror() function.
+   Copyright (C) 2007-2008 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.  */
+
+/* Written by Eric Blake <ebb9@xxxxxxx>, 2007.  */
+
+#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)
+
+int
+main (int argc, char **argv)
+{
+  char *str;
+
+  str = strerror (EACCES);
+  ASSERT (str);
+  ASSERT (*str);
+
+  str = strerror (ETIMEDOUT);
+  ASSERT (str);
+  ASSERT (*str);
+
+  str = strerror (EOVERFLOW);
+  ASSERT (str);
+  ASSERT (*str);
+
+  str = strerror (0);
+  ASSERT (str);
+  ASSERT (*str);
+
+  str = strerror (-3);
+  ASSERT (str);
+  ASSERT (*str);
+
+  return 0;
+}
diff --git a/gnulib/tests/test-sys_select.c b/gnulib/tests/test-sys_select.c
index 6c3547a..6449daf 100644
--- a/gnulib/tests/test-sys_select.c
+++ b/gnulib/tests/test-sys_select.c
@@ -1,5 +1,5 @@
 /* Test of <sys/select.h> substitute.
-   Copyright (C) 2007 Free Software Foundation, Inc.
+   Copyright (C) 2007-2008 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,6 +20,9 @@

 #include <sys/select.h>

+/* Check that the 'struct timeval' type is defined.  */
+struct timeval t1;
+
 int
 main ()
 {
diff --git a/gnulib/tests/test-vc-list-files-cvs.sh b/gnulib/tests/test-vc-list-files-cvs.sh
index c87267c..12c9366 100755
--- a/gnulib/tests/test-vc-list-files-cvs.sh
+++ b/gnulib/tests/test-vc-list-files-cvs.sh
@@ -45,7 +45,8 @@ for i in with-cvsu without; do
   mkdir $tmpdir && cd $tmpdir &&
     # without cvs, skip the test
     # The double use of 'exit' is needed for the reference to $? inside the trap.
-    { ( cvs -Q -d "$repo" init ) > /dev/null 2>&1 || { (exit 77); exit 77; }; } &&
+    { ( cvs -Q -d "$repo" init ) > /dev/null 2>&1 \
+      || { echo "Skipping test: cvs not found in PATH"; (exit 77); exit 77; }; } &&
     mkdir w && cd w &&
     mkdir d &&
     touch d/a b c &&
diff --git a/gnulib/tests/test-vc-list-files-git.sh b/gnulib/tests/test-vc-list-files-git.sh
index ac50971..a42aec1 100755
--- a/gnulib/tests/test-vc-list-files-git.sh
+++ b/gnulib/tests/test-vc-list-files-git.sh
@@ -32,7 +32,8 @@ fail=1
 mkdir $tmpdir && cd $tmpdir &&
   # without git, skip the test
   # The double use of 'exit' is needed for the reference to $? inside the trap.
-  { ( git init -q ) > /dev/null 2>&1 || { (exit 77); exit 77; }; } &&
+  { ( git init -q ) > /dev/null 2>&1 \
+    || { echo "Skipping test: git not found in PATH"; (exit 77); exit 77; }; } &&
   mkdir d &&
   touch d/a b c &&
   git add . > /dev/null &&
diff --git a/gnulib/tests/test-wchar.c b/gnulib/tests/test-wchar.c
index 85b15b5..19da7d9 100644
--- a/gnulib/tests/test-wchar.c
+++ b/gnulib/tests/test-wchar.c
@@ -1,5 +1,5 @@
 /* Test of <wchar.h> substitute.
-   Copyright (C) 2007 Free Software Foundation, Inc.
+   Copyright (C) 2007-2008 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,6 +20,10 @@

 #include <wchar.h>

+/* Check that the types wchar_t and wint_t are defined.  */
+wchar_t a = 'c';
+wint_t b = 'x';
+
 int
 main ()
 {
diff --git a/gnulib/tests/w32sock.h b/gnulib/tests/w32sock.h
new file mode 100644
index 0000000..0622985
--- /dev/null
+++ b/gnulib/tests/w32sock.h
@@ -0,0 +1,62 @@
+/* w32sock.h --- internal auxilliary functions for Windows socket functions
+
+   Copyright (C) 2008 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 Paolo Bonzini */
+
+#include <errno.h>
+
+/* Get O_RDWR and O_BINARY.  */
+#include <fcntl.h>
+
+/* Get _get_osfhandle() and _open_osfhandle().  */
+#include <io.h>
+
+#define FD_TO_SOCKET(fd)   ((SOCKET) _get_osfhandle ((fd)))
+#define SOCKET_TO_FD(fh)   (_open_osfhandle ((long) (fh), O_RDWR | O_BINARY))
+
+static inline void
+set_winsock_errno (void)
+{
+  int err = WSAGetLastError ();
+  WSASetLastError (0);
+
+  /* Map some WSAE* errors to the runtime library's error codes.  */
+  switch (err)
+    {
+    case WSA_INVALID_HANDLE:
+      errno = EBADF;
+      break;
+    case WSA_NOT_ENOUGH_MEMORY:
+      errno = ENOMEM;
+      break;
+    case WSA_INVALID_PARAMETER:
+      errno = EINVAL;
+      break;
+    case WSAEWOULDBLOCK:
+      errno = EWOULDBLOCK;
+      break;
+    case WSAENAMETOOLONG:
+      errno = ENAMETOOLONG;
+      break;
+    case WSAENOTEMPTY:
+      errno = ENOTEMPTY;
+      break;
+    default:
+      errno = (err > 10000 && err < 10025) ? err - 10000 : err;
+      break;
+    }
+}
-- 
1.6.0.3.756.gb776d

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]