r11123 - in libprelude/trunk/libmissing: . doc glthread m4 tests

[email protected]
Newsgroups gmane.comp.security.ids.prelude.cvs
Message-ID <[email protected]>
Author: yoann
Date: 2009-04-07 09:51:35 +0200 (Tue, 07 Apr 2009)
New Revision: 11123

Added:
   libprelude/trunk/libmissing/btowc.c
   libprelude/trunk/libmissing/close-hook.c
   libprelude/trunk/libmissing/close-hook.h
   libprelude/trunk/libmissing/doc/
   libprelude/trunk/libmissing/doc/relocatable.texi
   libprelude/trunk/libmissing/m4/00gnulib.m4
   libprelude/trunk/libmissing/m4/btowc.m4
   libprelude/trunk/libmissing/m4/hostent.m4
   libprelude/trunk/libmissing/m4/locale-fr.m4
   libprelude/trunk/libmissing/m4/locale-ja.m4
   libprelude/trunk/libmissing/m4/locale-zh.m4
   libprelude/trunk/libmissing/m4/mbrtowc.m4
   libprelude/trunk/libmissing/m4/mbsinit.m4
   libprelude/trunk/libmissing/m4/multiarch.m4
   libprelude/trunk/libmissing/m4/select.m4
   libprelude/trunk/libmissing/m4/servent.m4
   libprelude/trunk/libmissing/m4/ungetc.m4
   libprelude/trunk/libmissing/m4/wcrtomb.m4
   libprelude/trunk/libmissing/m4/wctob.m4
   libprelude/trunk/libmissing/mbrtowc.c
   libprelude/trunk/libmissing/mbsinit.c
   libprelude/trunk/libmissing/select.c
   libprelude/trunk/libmissing/streq.h
   libprelude/trunk/libmissing/tests/test-btowc.c
   libprelude/trunk/libmissing/tests/test-btowc1.sh
   libprelude/trunk/libmissing/tests/test-btowc2.sh
   libprelude/trunk/libmissing/tests/test-fseeko2.sh
   libprelude/trunk/libmissing/tests/test-mbrtowc.c
   libprelude/trunk/libmissing/tests/test-mbrtowc1.sh
   libprelude/trunk/libmissing/tests/test-mbrtowc2.sh
   libprelude/trunk/libmissing/tests/test-mbrtowc3.sh
   libprelude/trunk/libmissing/tests/test-mbrtowc4.sh
   libprelude/trunk/libmissing/tests/test-mbsinit.c
   libprelude/trunk/libmissing/tests/test-mbsinit.sh
   libprelude/trunk/libmissing/tests/test-signal.c
   libprelude/trunk/libmissing/tests/test-wcrtomb.c
   libprelude/trunk/libmissing/tests/test-wcrtomb.sh
   libprelude/trunk/libmissing/tests/w32sock.h
   libprelude/trunk/libmissing/tests/wctob.c
   libprelude/trunk/libmissing/verify.h
   libprelude/trunk/libmissing/wcrtomb.c
Removed:
   libprelude/trunk/libmissing/tests/verify.h
   libprelude/trunk/libmissing/winsock-select.c
Modified:
   libprelude/trunk/libmissing/Makefile.am
   libprelude/trunk/libmissing/arpa_inet.in.h
   libprelude/trunk/libmissing/close.c
   libprelude/trunk/libmissing/config.charset
   libprelude/trunk/libmissing/fopen.c
   libprelude/trunk/libmissing/fseeko.c
   libprelude/trunk/libmissing/gai_strerror.c
   libprelude/trunk/libmissing/gettimeofday.c
   libprelude/trunk/libmissing/glthread/threadlib.c
   libprelude/trunk/libmissing/ioctl.c
   libprelude/trunk/libmissing/localcharset.c
   libprelude/trunk/libmissing/m4/alloca.m4
   libprelude/trunk/libmissing/m4/close.m4
   libprelude/trunk/libmissing/m4/codeset.m4
   libprelude/trunk/libmissing/m4/errno_h.m4
   libprelude/trunk/libmissing/m4/extensions.m4
   libprelude/trunk/libmissing/m4/fopen.m4
   libprelude/trunk/libmissing/m4/getaddrinfo.m4
   libprelude/trunk/libmissing/m4/getline.m4
   libprelude/trunk/libmissing/m4/getpass.m4
   libprelude/trunk/libmissing/m4/gettimeofday.m4
   libprelude/trunk/libmissing/m4/glibc21.m4
   libprelude/trunk/libmissing/m4/gnulib-cache.m4
   libprelude/trunk/libmissing/m4/gnulib-common.m4
   libprelude/trunk/libmissing/m4/gnulib-comp.m4
   libprelude/trunk/libmissing/m4/include_next.m4
   libprelude/trunk/libmissing/m4/inet_ntop.m4
   libprelude/trunk/libmissing/m4/inet_pton.m4
   libprelude/trunk/libmissing/m4/intmax_t.m4
   libprelude/trunk/libmissing/m4/inttypes_h.m4
   libprelude/trunk/libmissing/m4/lib-ld.m4
   libprelude/trunk/libmissing/m4/lib-link.m4
   libprelude/trunk/libmissing/m4/localcharset.m4
   libprelude/trunk/libmissing/m4/lock.m4
   libprelude/trunk/libmissing/m4/longlong.m4
   libprelude/trunk/libmissing/m4/malloc.m4
   libprelude/trunk/libmissing/m4/mbstate_t.m4
   libprelude/trunk/libmissing/m4/memmem.m4
   libprelude/trunk/libmissing/m4/minmax.m4
   libprelude/trunk/libmissing/m4/mktime.m4
   libprelude/trunk/libmissing/m4/netdb_h.m4
   libprelude/trunk/libmissing/m4/pathmax.m4
   libprelude/trunk/libmissing/m4/poll.m4
   libprelude/trunk/libmissing/m4/printf.m4
   libprelude/trunk/libmissing/m4/realloc.m4
   libprelude/trunk/libmissing/m4/regex.m4
   libprelude/trunk/libmissing/m4/relocatable-lib.m4
   libprelude/trunk/libmissing/m4/signal_h.m4
   libprelude/trunk/libmissing/m4/signalblocking.m4
   libprelude/trunk/libmissing/m4/size_max.m4
   libprelude/trunk/libmissing/m4/sockets.m4
   libprelude/trunk/libmissing/m4/sockpfaf.m4
   libprelude/trunk/libmissing/m4/stdbool.m4
   libprelude/trunk/libmissing/m4/stdint.m4
   libprelude/trunk/libmissing/m4/stdint_h.m4
   libprelude/trunk/libmissing/m4/stdio_h.m4
   libprelude/trunk/libmissing/m4/stdlib_h.m4
   libprelude/trunk/libmissing/m4/strcase.m4
   libprelude/trunk/libmissing/m4/strdup.m4
   libprelude/trunk/libmissing/m4/strndup.m4
   libprelude/trunk/libmissing/m4/strnlen.m4
   libprelude/trunk/libmissing/m4/strptime.m4
   libprelude/trunk/libmissing/m4/strsep.m4
   libprelude/trunk/libmissing/m4/sys_select_h.m4
   libprelude/trunk/libmissing/m4/threadlib.m4
   libprelude/trunk/libmissing/m4/timegm.m4
   libprelude/trunk/libmissing/m4/tm_gmtoff.m4
   libprelude/trunk/libmissing/m4/unistd_h.m4
   libprelude/trunk/libmissing/m4/vasnprintf.m4
   libprelude/trunk/libmissing/m4/wchar.m4
   libprelude/trunk/libmissing/m4/wchar_t.m4
   libprelude/trunk/libmissing/m4/wint_t.m4
   libprelude/trunk/libmissing/m4/xsize.m4
   libprelude/trunk/libmissing/m4/yield.m4
   libprelude/trunk/libmissing/netdb.in.h
   libprelude/trunk/libmissing/pathmax.h
   libprelude/trunk/libmissing/poll.c
   libprelude/trunk/libmissing/regcomp.c
   libprelude/trunk/libmissing/regex_internal.c
   libprelude/trunk/libmissing/regex_internal.h
   libprelude/trunk/libmissing/regexec.c
   libprelude/trunk/libmissing/setsockopt.c
   libprelude/trunk/libmissing/signal.in.h
   libprelude/trunk/libmissing/stdint.in.h
   libprelude/trunk/libmissing/stdio.in.h
   libprelude/trunk/libmissing/stdlib.in.h
   libprelude/trunk/libmissing/strerror.c
   libprelude/trunk/libmissing/sys_select.in.h
   libprelude/trunk/libmissing/sys_socket.in.h
   libprelude/trunk/libmissing/sys_stat.in.h
   libprelude/trunk/libmissing/sys_time.in.h
   libprelude/trunk/libmissing/tests/Makefile.am
   libprelude/trunk/libmissing/tests/sockets.c
   libprelude/trunk/libmissing/tests/sockets.h
   libprelude/trunk/libmissing/tests/test-fseeko.c
   libprelude/trunk/libmissing/tests/test-getaddrinfo.c
   libprelude/trunk/libmissing/tests/test-lock.c
   libprelude/trunk/libmissing/tests/test-poll.c
   libprelude/trunk/libmissing/tests/test-select-in.sh
   libprelude/trunk/libmissing/tests/test-select-out.sh
   libprelude/trunk/libmissing/tests/test-sockets.c
   libprelude/trunk/libmissing/tests/test-tls.c
   libprelude/trunk/libmissing/tests/test-unistd.c
   libprelude/trunk/libmissing/unistd.in.h
   libprelude/trunk/libmissing/vasnprintf.c
   libprelude/trunk/libmissing/wchar.in.h
   libprelude/trunk/libmissing/wctype.in.h
Log:
Update GnuLib code.

Modified: libprelude/trunk/libmissing/Makefile.am
===================================================================
--- libprelude/trunk/libmissing/Makefile.am	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/Makefile.am	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,6 +1,6 @@
 ## DO NOT EDIT! GENERATED AUTOMATICALLY!
 ## Process this file with automake to produce Makefile.in.
-# Copyright (C) 2002-2008 Free Software Foundation, Inc.
+# Copyright (C) 2002-2009 Free Software Foundation, Inc.
 #
 # This file is free software, distributed under the terms of the GNU
 # General Public License.  As a special exception to the GNU General
@@ -29,6 +29,7 @@
 EXTRA_DIST += m4/gnulib-cache.m4
 
 AM_CPPFLAGS =
+AM_CFLAGS =
 
 noinst_LTLIBRARIES += libmissing.la
 
@@ -113,6 +114,15 @@
 
 ## end   gnulib module bind
 
+## begin gnulib module btowc
+
+
+EXTRA_DIST += btowc.c
+
+EXTRA_libmissing_la_SOURCES += btowc.c
+
+## end   gnulib module btowc
+
 ## begin gnulib module c-ctype
 
 libmissing_la_SOURCES += c-ctype.h c-ctype.c
@@ -122,12 +132,20 @@
 ## begin gnulib module close
 
 
-EXTRA_DIST += close.c w32sock.h
+EXTRA_DIST += close.c
 
 EXTRA_libmissing_la_SOURCES += close.c
 
 ## end   gnulib module close
 
+## begin gnulib module close-hook
+
+libmissing_la_SOURCES += close-hook.c
+
+EXTRA_DIST += close-hook.h
+
+## end   gnulib module close-hook
+
 ## begin gnulib module cond
 
 libmissing_la_SOURCES += glthread/cond.h glthread/cond.c
@@ -427,13 +445,27 @@
 charset_alias = $(DESTDIR)$(libdir)/charset.alias
 charset_tmp = $(DESTDIR)$(libdir)/charset.tmp
 install-exec-local: all-local
-	test $(GLIBC21) != no || $(mkinstalldirs) $(DESTDIR)$(libdir)
+	if test $(GLIBC21) = no; then \
+	  case '$(host_os)' in \
+	    darwin[56]*) \
+	      need_charset_alias=true ;; \
+	    darwin* | cygwin* | mingw* | pw32* | cegcc*) \
+	      need_charset_alias=false ;; \
+	    *) \
+	      need_charset_alias=true ;; \
+	  esac ; \
+	else \
+	  need_charset_alias=false ; \
+	fi ; \
+	if $$need_charset_alias; then \
+	  $(mkinstalldirs) $(DESTDIR)$(libdir) ; \
+	fi ; \
 	if test -f $(charset_alias); then \
 	  sed -f ref-add.sed $(charset_alias) > $(charset_tmp) ; \
 	  $(INSTALL_DATA) $(charset_tmp) $(charset_alias) ; \
 	  rm -f $(charset_tmp) ; \
 	else \
-	  if test $(GLIBC21) = no; then \
+	  if $$need_charset_alias; then \
 	    sed -f ref-add.sed charset.alias > $(charset_tmp) ; \
 	    $(INSTALL_DATA) $(charset_tmp) $(charset_alias) ; \
 	    rm -f $(charset_tmp) ; \
@@ -502,6 +534,24 @@
 
 ## end   gnulib module malloc-posix
 
+## begin gnulib module mbrtowc
+
+
+EXTRA_DIST += mbrtowc.c
+
+EXTRA_libmissing_la_SOURCES += mbrtowc.c
+
+## end   gnulib module mbrtowc
+
+## begin gnulib module mbsinit
+
+
+EXTRA_DIST += mbsinit.c
+
+EXTRA_libmissing_la_SOURCES += mbsinit.c
+
+## end   gnulib module mbsinit
+
 ## begin gnulib module memmem-simple
 
 
@@ -644,9 +694,9 @@
 ## begin gnulib module select
 
 
-EXTRA_DIST += winsock-select.c
+EXTRA_DIST += select.c
 
-EXTRA_libmissing_la_SOURCES += winsock-select.c
+EXTRA_libmissing_la_SOURCES += select.c
 
 ## end   gnulib module select
 
@@ -679,6 +729,7 @@
 	      -e 's|@''HAVE_SIGINFO_T''@|$(HAVE_SIGINFO_T)|g' \
 	      -e 's|@''HAVE_SIGACTION''@|$(HAVE_SIGACTION)|g' \
 	      -e 's|@''HAVE_STRUCT_SIGACTION_SA_SIGACTION''@|$(HAVE_STRUCT_SIGACTION_SA_SIGACTION)|g' \
+	      -e 's|@''HAVE_TYPE_VOLATILE_SIG_ATOMIC_T''@|$(HAVE_TYPE_VOLATILE_SIG_ATOMIC_T)|g' \
 	      -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
 	      < $(srcdir)/signal.in.h; \
 	} > $@-t
@@ -768,6 +819,7 @@
 	      -e 's/@''HAVE_SYS_BITYPES_H''@/$(HAVE_SYS_BITYPES_H)/g' \
 	      -e 's/@''HAVE_LONG_LONG_INT''@/$(HAVE_LONG_LONG_INT)/g' \
 	      -e 's/@''HAVE_UNSIGNED_LONG_LONG_INT''@/$(HAVE_UNSIGNED_LONG_LONG_INT)/g' \
+	      -e 's/@''APPLE_UNIVERSAL_BUILD''@/$(APPLE_UNIVERSAL_BUILD)/g' \
 	      -e 's/@''BITSIZEOF_PTRDIFF_T''@/$(BITSIZEOF_PTRDIFF_T)/g' \
 	      -e 's/@''PTRDIFF_T_SUFFIX''@/$(PTRDIFF_T_SUFFIX)/g' \
 	      -e 's/@''BITSIZEOF_SIG_ATOMIC_T''@/$(BITSIZEOF_SIG_ATOMIC_T)/g' \
@@ -814,6 +866,8 @@
 	      -e 's|@''GNULIB_VPRINTF_POSIX''@|$(GNULIB_VPRINTF_POSIX)|g' \
 	      -e 's|@''GNULIB_VSNPRINTF''@|$(GNULIB_VSNPRINTF)|g' \
 	      -e 's|@''GNULIB_VSPRINTF_POSIX''@|$(GNULIB_VSPRINTF_POSIX)|g' \
+	      -e 's|@''GNULIB_DPRINTF''@|$(GNULIB_DPRINTF)|g' \
+	      -e 's|@''GNULIB_VDPRINTF''@|$(GNULIB_VDPRINTF)|g' \
 	      -e 's|@''GNULIB_VASPRINTF''@|$(GNULIB_VASPRINTF)|g' \
 	      -e 's|@''GNULIB_OBSTACK_PRINTF''@|$(GNULIB_OBSTACK_PRINTF)|g' \
 	      -e 's|@''GNULIB_OBSTACK_PRINTF_POSIX''@|$(GNULIB_OBSTACK_PRINTF_POSIX)|g' \
@@ -846,6 +900,10 @@
 	      -e 's|@''HAVE_DECL_VSNPRINTF''@|$(HAVE_DECL_VSNPRINTF)|g' \
 	      -e 's|@''REPLACE_SPRINTF''@|$(REPLACE_SPRINTF)|g' \
 	      -e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \
+	      -e 's|@''HAVE_DPRINTF''@|$(HAVE_DPRINTF)|g' \
+	      -e 's|@''REPLACE_DPRINTF''@|$(REPLACE_DPRINTF)|g' \
+	      -e 's|@''HAVE_VDPRINTF''@|$(HAVE_VDPRINTF)|g' \
+	      -e 's|@''REPLACE_VDPRINTF''@|$(REPLACE_VDPRINTF)|g' \
 	      -e 's|@''HAVE_VASPRINTF''@|$(HAVE_VASPRINTF)|g' \
 	      -e 's|@''REPLACE_VASPRINTF''@|$(REPLACE_VASPRINTF)|g' \
 	      -e 's|@''HAVE_DECL_OBSTACK_PRINTF''@|$(HAVE_DECL_OBSTACK_PRINTF)|g' \
@@ -886,6 +944,7 @@
 	  sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
 	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
 	      -e 's|@''NEXT_STDLIB_H''@|$(NEXT_STDLIB_H)|g' \
+	      -e 's|@''HAVE_RANDOM_H''@|$(HAVE_RANDOM_H)|g' \
 	      -e 's|@''GNULIB_MALLOC_POSIX''@|$(GNULIB_MALLOC_POSIX)|g' \
 	      -e 's|@''GNULIB_REALLOC_POSIX''@|$(GNULIB_REALLOC_POSIX)|g' \
 	      -e 's|@''GNULIB_CALLOC_POSIX''@|$(GNULIB_CALLOC_POSIX)|g' \
@@ -968,6 +1027,13 @@
 
 ## end   gnulib module strdup-posix
 
+## begin gnulib module streq
+
+
+EXTRA_DIST += streq.h
+
+## end   gnulib module streq
+
 ## begin gnulib module strerror
 
 
@@ -1158,6 +1224,7 @@
 	      -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 's|@''REPLACE_SELECT''@|$(REPLACE_SELECT)|g' \
 	      -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
 	      < $(srcdir)/sys_select.in.h; \
 	} > $@-t
@@ -1367,6 +1434,7 @@
 	      -e 's|@''GNULIB_GETPAGESIZE''@|$(GNULIB_GETPAGESIZE)|g' \
 	      -e 's|@''GNULIB_GETUSERSHELL''@|$(GNULIB_GETUSERSHELL)|g' \
 	      -e 's|@''GNULIB_LCHOWN''@|$(GNULIB_LCHOWN)|g' \
+	      -e 's|@''GNULIB_LINK''@|$(GNULIB_LINK)|g' \
 	      -e 's|@''GNULIB_LSEEK''@|$(GNULIB_LSEEK)|g' \
 	      -e 's|@''GNULIB_READLINK''@|$(GNULIB_READLINK)|g' \
 	      -e 's|@''GNULIB_SLEEP''@|$(GNULIB_SLEEP)|g' \
@@ -1381,6 +1449,7 @@
 	      -e 's|@''HAVE_GETHOSTNAME''@|$(HAVE_GETHOSTNAME)|g' \
 	      -e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \
 	      -e 's|@''HAVE_GETUSERSHELL''@|$(HAVE_GETUSERSHELL)|g' \
+	      -e 's|@''HAVE_LINK''@|$(HAVE_LINK)|g' \
 	      -e 's|@''HAVE_READLINK''@|$(HAVE_READLINK)|g' \
 	      -e 's|@''HAVE_SLEEP''@|$(HAVE_SLEEP)|g' \
 	      -e 's|@''HAVE_DECL_ENVIRON''@|$(HAVE_DECL_ENVIRON)|g' \
@@ -1415,6 +1484,12 @@
 
 ## end   gnulib module vasnprintf
 
+## begin gnulib module verify
+
+libmissing_la_SOURCES += verify.h
+
+## end   gnulib module verify
+
 ## begin gnulib module vsnprintf
 
 
@@ -1436,10 +1511,40 @@
 	  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|@''HAVE_WCHAR_H''@|$(HAVE_WCHAR_H)|g' \
+	      -e 's|@''GNULIB_BTOWC''@|$(GNULIB_BTOWC)|g' \
+	      -e 's|@''GNULIB_WCTOB''@|$(GNULIB_WCTOB)|g' \
+	      -e 's|@''GNULIB_MBSINIT''@|$(GNULIB_MBSINIT)|g' \
+	      -e 's|@''GNULIB_MBRTOWC''@|$(GNULIB_MBRTOWC)|g' \
+	      -e 's|@''GNULIB_MBRLEN''@|$(GNULIB_MBRLEN)|g' \
+	      -e 's|@''GNULIB_MBSRTOWCS''@|$(GNULIB_MBSRTOWCS)|g' \
+	      -e 's|@''GNULIB_MBSNRTOWCS''@|$(GNULIB_MBSNRTOWCS)|g' \
+	      -e 's|@''GNULIB_WCRTOMB''@|$(GNULIB_WCRTOMB)|g' \
+	      -e 's|@''GNULIB_WCSRTOMBS''@|$(GNULIB_WCSRTOMBS)|g' \
+	      -e 's|@''GNULIB_WCSNRTOMBS''@|$(GNULIB_WCSNRTOMBS)|g' \
 	      -e 's|@''GNULIB_WCWIDTH''@|$(GNULIB_WCWIDTH)|g' \
-	      -e 's/@''HAVE_WINT_T''@/$(HAVE_WINT_T)/g' \
+	      -e 's|@''HAVE_WINT_T''@|$(HAVE_WINT_T)|g' \
+	      -e 's|@''HAVE_BTOWC''@|$(HAVE_BTOWC)|g' \
+	      -e 's|@''HAVE_MBSINIT''@|$(HAVE_MBSINIT)|g' \
+	      -e 's|@''HAVE_MBRTOWC''@|$(HAVE_MBRTOWC)|g' \
+	      -e 's|@''HAVE_MBRLEN''@|$(HAVE_MBRLEN)|g' \
+	      -e 's|@''HAVE_MBSRTOWCS''@|$(HAVE_MBSRTOWCS)|g' \
+	      -e 's|@''HAVE_MBSNRTOWCS''@|$(HAVE_MBSNRTOWCS)|g' \
+	      -e 's|@''HAVE_WCRTOMB''@|$(HAVE_WCRTOMB)|g' \
+	      -e 's|@''HAVE_WCSRTOMBS''@|$(HAVE_WCSRTOMBS)|g' \
+	      -e 's|@''HAVE_WCSNRTOMBS''@|$(HAVE_WCSNRTOMBS)|g' \
+	      -e 's|@''HAVE_DECL_WCTOB''@|$(HAVE_DECL_WCTOB)|g' \
 	      -e 's|@''HAVE_DECL_WCWIDTH''@|$(HAVE_DECL_WCWIDTH)|g' \
+	      -e 's|@''REPLACE_MBSTATE_T''@|$(REPLACE_MBSTATE_T)|g' \
+	      -e 's|@''REPLACE_BTOWC''@|$(REPLACE_BTOWC)|g' \
+	      -e 's|@''REPLACE_WCTOB''@|$(REPLACE_WCTOB)|g' \
+	      -e 's|@''REPLACE_MBSINIT''@|$(REPLACE_MBSINIT)|g' \
+	      -e 's|@''REPLACE_MBRTOWC''@|$(REPLACE_MBRTOWC)|g' \
+	      -e 's|@''REPLACE_MBRLEN''@|$(REPLACE_MBRLEN)|g' \
+	      -e 's|@''REPLACE_MBSRTOWCS''@|$(REPLACE_MBSRTOWCS)|g' \
+	      -e 's|@''REPLACE_MBSNRTOWCS''@|$(REPLACE_MBSNRTOWCS)|g' \
+	      -e 's|@''REPLACE_WCRTOMB''@|$(REPLACE_WCRTOMB)|g' \
+	      -e 's|@''REPLACE_WCSRTOMBS''@|$(REPLACE_WCSRTOMBS)|g' \
 	      -e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \
 	      -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
 	    < $(srcdir)/wchar.in.h; \
@@ -1451,6 +1556,15 @@
 
 ## end   gnulib module wchar
 
+## begin gnulib module wcrtomb
+
+
+EXTRA_DIST += wcrtomb.c
+
+EXTRA_libmissing_la_SOURCES += wcrtomb.c
+
+## end   gnulib module wcrtomb
+
 ## begin gnulib module wctype
 
 BUILT_SOURCES += $(WCTYPE_H)

Modified: libprelude/trunk/libmissing/arpa_inet.in.h
===================================================================
--- libprelude/trunk/libmissing/arpa_inet.in.h	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/arpa_inet.in.h	2009-04-07 07:51:35 UTC (rev 11123)
@@ -38,6 +38,10 @@
 
 /* The definition of GL_LINK_WARNING is copied here.  */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #if @GNULIB_INET_NTOP@
 # if !@HAVE_DECL_INET_NTOP@
 /* Converts an internet address from internal format to a printable,
@@ -78,5 +82,9 @@
    inet_pton (af, src, dst))
 #endif
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _GL_ARPA_INET_H */
 #endif /* _GL_ARPA_INET_H */

Copied: libprelude/trunk/libmissing/btowc.c (from rev 11101, libprelude/trunk/libmissing/setsockopt.c)
===================================================================
--- libprelude/trunk/libmissing/btowc.c	                        (rev 0)
+++ libprelude/trunk/libmissing/btowc.c	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,38 @@
+/* Convert unibyte character to wide character.
+   Copyright (C) 2008 Free Software Foundation, Inc.
+   Written by Bruno Haible <[email protected]>, 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 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <wchar.h>
+
+#include <stdio.h>
+
+wint_t
+btowc (int c)
+{
+  if (c != EOF)
+    {
+      char buf[1];
+      wchar_t wc;
+
+      buf[0] = c;
+      if (mbtowc (&wc, buf, 1) >= 0)
+	return wc;
+    }
+  return WEOF;
+}

Added: libprelude/trunk/libmissing/close-hook.c
===================================================================
--- libprelude/trunk/libmissing/close-hook.c	                        (rev 0)
+++ libprelude/trunk/libmissing/close-hook.c	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,91 @@
+/* Hook for making the close() function extensible.
+   Copyright (C) 2009 Free Software Foundation, Inc.
+   Written by Bruno Haible <[email protected]>, 2009.
+
+   This program is free software: you can redistribute it and/or modify it
+   under the terms of the GNU Lesser General Public License as published
+   by the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include "close-hook.h"
+
+#include <stdlib.h>
+#include <unistd.h>
+
+#undef close
+
+
+/* Currently, this entire code is only needed for the handling of sockets
+   on native Windows platforms.  */
+#if WINDOWS_SOCKETS
+
+/* The first and last link in the doubly linked list.
+   Initially the list is empty.  */
+static struct close_hook anchor = { &anchor, &anchor, NULL };
+
+int
+execute_close_hooks (int fd, const struct close_hook *remaining_list)
+{
+  if (remaining_list == &anchor)
+    /* End of list reached.  */
+    return close (fd);
+  else
+    return remaining_list->private_fn (fd, remaining_list->private_next);
+}
+
+int
+execute_all_close_hooks (int fd)
+{
+  return execute_close_hooks (fd, anchor.private_next);
+}
+
+void
+register_close_hook (close_hook_fn hook, struct close_hook *link)
+{
+  if (link->private_next == NULL && link->private_prev == NULL)
+    {
+      /* Add the link to the doubly linked list.  */
+      link->private_next = anchor.private_next;
+      link->private_prev = &anchor;
+      link->private_fn = hook;
+      anchor.private_next->private_prev = link;
+      anchor.private_next = link;
+    }
+  else
+    {
+      /* The link is already in use.  */
+      if (link->private_fn != hook)
+	abort ();
+    }
+}
+
+void
+unregister_close_hook (struct close_hook *link)
+{
+  struct close_hook *next = link->private_next;
+  struct close_hook *prev = link->private_prev;
+
+  if (next != NULL && prev != NULL)
+    {
+      /* The link is in use.  Remove it from the doubly linked list.  */
+      prev->private_next = next;
+      next->private_prev = prev;
+      /* Clear the link, to mark it unused.  */
+      link->private_next = NULL;
+      link->private_prev = NULL;
+      link->private_fn = NULL;
+    }
+}
+
+#endif

Added: libprelude/trunk/libmissing/close-hook.h
===================================================================
--- libprelude/trunk/libmissing/close-hook.h	                        (rev 0)
+++ libprelude/trunk/libmissing/close-hook.h	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,72 @@
+/* Hook for making the close() function extensible.
+   Copyright (C) 2009 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify it
+   under the terms of the GNU Lesser General Public License as published
+   by the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+
+#ifndef CLOSE_HOOK_H
+#define CLOSE_HOOK_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Currently, this entire code is only needed for the handling of sockets
+   on native Windows platforms.  */
+#if WINDOWS_SOCKETS
+
+
+/* An element of the list of close hooks.
+   The fields of this structure are considered private.  */
+struct close_hook
+{
+  /* Doubly linked list.  */
+  struct close_hook *private_next;
+  struct close_hook *private_prev;
+  /* Function that treats the types of FD that it knows about and calls
+     execute_close_hooks (FD, REMAINING_LIST) as a fallback.  */
+  int (*private_fn) (int fd, const struct close_hook *remaining_list);
+};
+
+/* This type of function closes FD, applying special knowledge for the FD
+   types it knows about, and calls execute_close_hooks (FD, REMAINING_LIST)
+   for the other FD types.  */
+typedef int (*close_hook_fn) (int fd, const struct close_hook *remaining_list);
+
+/* Execute the close hooks in REMAINING_LIST.
+   Return 0 or -1, like close() would do.  */
+extern int execute_close_hooks (int fd, const struct close_hook *remaining_list);
+
+/* Execute all close hooks.
+   Return 0 or -1, like close() would do.  */
+extern int execute_all_close_hooks (int fd);
+
+/* Add a function to the list of close hooks.
+   The LINK variable points to a piece of memory which is guaranteed to be
+   accessible until the corresponding call to unregister_close_hook.  */
+extern void register_close_hook (close_hook_fn hook, struct close_hook *link);
+
+/* Removes a function from the list of close hooks.  */
+extern void unregister_close_hook (struct close_hook *link);
+
+
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CLOSE_HOOK_H */

Modified: libprelude/trunk/libmissing/close.c
===================================================================
--- libprelude/trunk/libmissing/close.c	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/close.c	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
 /* close replacement.
-   Copyright (C) 2008 Free Software Foundation, Inc.
+   Copyright (C) 2008-2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -19,56 +19,16 @@
 /* Specification.  */
 #include <unistd.h>
 
-#if GNULIB_SYS_SOCKET
-# define WIN32_LEAN_AND_MEAN
-# include <sys/socket.h>
-#endif
+#include "close-hook.h"
 
-#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);
+#if WINDOWS_SOCKETS
+  int retval = execute_all_close_hooks (fd);
 #else
   int retval = close (fd);
 #endif

Modified: libprelude/trunk/libmissing/config.charset
===================================================================
--- libprelude/trunk/libmissing/config.charset	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/config.charset	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,7 +1,7 @@
 #! /bin/sh
 # Output a system dependent table of character encoding aliases.
 #
-#   Copyright (C) 2000-2004, 2006-2008 Free Software Foundation, Inc.
+#   Copyright (C) 2000-2004, 2006-2009 Free Software Foundation, Inc.
 #
 #   This program is free software; you can redistribute it and/or modify
 #   it under the terms of the GNU Lesser General Public License as published by
@@ -63,12 +63,13 @@
 #   CP922                       aix
 #   CP932                       aix woe32 dos
 #   CP943                       aix
-#   CP949                       osf woe32 dos
+#   CP949                       osf darwin woe32 dos
 #   CP950                       woe32 dos
 #   CP1046                      aix
 #   CP1124                      aix
 #   CP1125                      dos
 #   CP1129                      aix
+#   CP1131                      darwin
 #   CP1250                      woe32
 #   CP1251                      glibc solaris netbsd openbsd darwin woe32
 #   CP1252                      aix woe32
@@ -82,15 +83,17 @@
 #   EUC-KR                  Y   glibc aix hpux irix osf solaris freebsd netbsd darwin
 #   EUC-TW                      glibc aix hpux irix osf solaris netbsd
 #   BIG5                    Y   glibc aix hpux osf solaris freebsd netbsd darwin
-#   BIG5-HKSCS                  glibc solaris
-#   GBK                         glibc aix osf solaris woe32 dos
-#   GB18030                     glibc solaris netbsd
+#   BIG5-HKSCS                  glibc solaris darwin
+#   GBK                         glibc aix osf solaris darwin woe32 dos
+#   GB18030                     glibc solaris netbsd darwin
 #   SHIFT_JIS               Y   hpux osf solaris freebsd netbsd darwin
 #   JOHAB                       glibc solaris woe32
 #   TIS-620                     glibc aix hpux osf solaris
 #   VISCII                  Y   glibc
 #   TCVN5712-1                  glibc
+#   ARMSCII-8                   glibc darwin
 #   GEORGIAN-PS                 glibc
+#   PT154                       glibc
 #   HP-ROMAN8                   hpux
 #   HP-ARABIC8                  hpux
 #   HP-GREEK8                   hpux
@@ -449,7 +452,8 @@
 	echo "ko_KR.EUC EUC-KR"
 	;;
     darwin*)
-	# Darwin 7.5 has nl_langinfo(CODESET), but it is useless:
+	# Darwin 7.5 has nl_langinfo(CODESET), but sometimes its value is
+	# useless:
 	# - It returns the empty string when LANG is set to a locale of the
 	#   form ll_CC, although ll_CC/LC_CTYPE is a symlink to an UTF-8
 	#   LC_CTYPE file.
@@ -476,6 +480,36 @@
 	# minimize the use of decomposed Unicode. Unfortunately, through the
 	# Darwin file system, decomposed UTF-8 strings are leaked into user
 	# space nevertheless.
+	# Then there are also the locales with encodings other than US-ASCII
+	# and UTF-8. These locales can be occasionally useful to users (e.g.
+	# when grepping through ISO-8859-1 encoded text files), when all their
+	# file names are in US-ASCII.
+	echo "ISO8859-1 ISO-8859-1"
+	echo "ISO8859-2 ISO-8859-2"
+	echo "ISO8859-4 ISO-8859-4"
+	echo "ISO8859-5 ISO-8859-5"
+	echo "ISO8859-7 ISO-8859-7"
+	echo "ISO8859-9 ISO-8859-9"
+	echo "ISO8859-13 ISO-8859-13"
+	echo "ISO8859-15 ISO-8859-15"
+	echo "KOI8-R KOI8-R"
+	echo "KOI8-U KOI8-U"
+	echo "CP866 CP866"
+	echo "CP949 CP949"
+	echo "CP1131 CP1131"
+	echo "CP1251 CP1251"
+	echo "eucCN GB2312"
+	echo "GB2312 GB2312"
+	echo "eucJP EUC-JP"
+	echo "eucKR EUC-KR"
+	echo "Big5 BIG5"
+	echo "Big5HKSCS BIG5-HKSCS"
+	echo "GBK GBK"
+	echo "GB18030 GB18030"
+	echo "SJIS SHIFT_JIS"
+	echo "ARMSCII-8 ARMSCII-8"
+	echo "PT154 PT154"
+	#echo "ISCII-DEV ?"
 	echo "* UTF-8"
 	;;
     beos* | haiku*)

Added: libprelude/trunk/libmissing/doc/relocatable.texi
===================================================================
--- libprelude/trunk/libmissing/doc/relocatable.texi	                        (rev 0)
+++ libprelude/trunk/libmissing/doc/relocatable.texi	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,62 @@
+@node Enabling Relocatability
+@section Enabling Relocatability
+
+It has been a pain for many users of GNU packages for a long time that
+packages are not relocatable.  It means a user cannot copy a program,
+installed by another user on the same machine, to his home directory,
+and have it work correctly (including i18n).  So many users need to go
+through @code{configure; make; make install} with all its
+dependencies, options, and hurdles.
+
+Red Hat, Debian, and similar package systems solve the ``ease of
+installation'' problem, but they hardwire path names, usually to
+@file{/usr} or @file{/usr/local}.  This means that users need root
+privileges to install a binary package, and prevents installing two
+different versions of the same binary package.
+
+A relocatable program can be moved or copied to a different location
+on the filesystem.  It is possible to make symlinks to the installed
+and moved programs, and invoke them through the symlink. It is
+possible to do the same thing with a hard link @emph{only} if the hard
+link file is in the same directory as the real program.
+
+To configure a program to be relocatable, add
+@option{--enable-relocatable} to the @command{configure} command line.
+
+On some OSes the executables remember the location of shared libraries
+and prefer them over any other search path.  Therefore, such an
+executable will look for its shared libraries first in the original
+installation directory and only then in the current installation
+directory.  Thus, for reliability, it is best to also give a
+@option{--prefix} option pointing to a directory that does not exist
+now and which never will be created, e.g.@:
+@option{--prefix=/nonexistent}.  You may use
+@code{DESTDIR=@var{dest-dir}} on the @command{make} command line to
+avoid installing into that directory.
+
+We do not recommend using a prefix writable by unprivileged users
+(e.g.@: @file{/tmp/inst$$}) because such a directory can be recreated
+by an unprivileged user after the original directory has been removed.
+We also do not recommend prefixes that might be behind an automounter
+(e.g.@: @file{$HOME/inst$$}) because of the performance impact of
+directory searching.
+
+Here's a sample installation run that takes into account all these
+recommendations:
+
+@example
+./configure --enable-relocatable --prefix=/nonexistent
+make
+make install DESTDIR=/tmp/inst$$
+@end example
+
+Installation with @option{--enable-relocatable} will not work for
+setuid or setgid executables, because such executables search only
+system library paths for security reasons.  Also, installation with
+@option{--enable-relocatable} might not work on OpenBSD, when the
+package contains shared libraries and libtool versions 1.5.xx are used.
+
+The runtime penalty and size penalty are negligible on GNU/Linux (just
+one system call more when an executable is launched), and small on
+other systems (the wrapper program just sets an environment variable
+and executes the real program).

Modified: libprelude/trunk/libmissing/fopen.c
===================================================================
--- libprelude/trunk/libmissing/fopen.c	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/fopen.c	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
 /* Open a stream to a file.
-   Copyright (C) 2007-2008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -36,6 +36,8 @@
 #include <fcntl.h>
 #include <string.h>
 #include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 
 FILE *
 rpl_fopen (const char *filename, const char *mode)

Modified: libprelude/trunk/libmissing/fseeko.c
===================================================================
--- libprelude/trunk/libmissing/fseeko.c	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/fseeko.c	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
 /* An fseeko() function that, together with fflush(), is POSIX compliant.
-   Copyright (C) 2007-2008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -82,11 +82,23 @@
   if ((fp->_Mode & _MWRITE ? fp->_Next == fp->_Buf : fp->_Next == fp->_Rend)
       && fp->_Rback == fp->_Back + sizeof (fp->_Back)
       && fp->_Rsave == NULL)
+#elif defined __MINT__              /* Atari FreeMiNT */
+  if (fp->__bufp == fp->__buffer
+      && fp->__get_limit == fp->__bufp
+      && fp->__put_limit == fp->__bufp
+      && !fp->__pushed_back)
 #else
   #error "Please port gnulib fseeko.c to your platform! Look at the code in fpurge.c, then report this to bug-gnulib."
 #endif
     {
-      off_t pos = lseek (fileno (fp), offset, whence);
+      /* We get here when an fflush() call immediately preceded this one.  We
+	 know there are no buffers.
+	 POSIX requires us to modify the file descriptor's position.
+	 But we cannot position beyond end of file here.  */
+      off_t pos =
+	lseek (fileno (fp),
+	       whence == SEEK_END && offset > 0 ? 0 : offset,
+	       whence);
       if (pos == -1)
 	{
 #if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */
@@ -94,20 +106,25 @@
 #endif
 	  return -1;
 	}
-      else
-	{
-#if defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */
-	  fp_->_offset = pos;
-	  fp_->_flags |= __SOFF;
-	  fp_->_flags &= ~__SEOF;
+
+#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+      fp->_flags &= ~_IO_EOF_SEEN;
+#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */
+      fp_->_offset = pos;
+      fp_->_flags |= __SOFF;
+      fp_->_flags &= ~__SEOF;
 #elif defined __EMX__               /* emx+gcc */
-          fp->_flags &= ~_IOEOF;
+      fp->_flags &= ~_IOEOF;
 #elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw */
-          fp->_flag &= ~_IOEOF;
+      fp->_flag &= ~_IOEOF;
+#elif defined __MINT__              /* Atari FreeMiNT */
+      fp->__offset = pos;
+      fp->__eof = 0;
 #endif
-	  return 0;
-	}
+      /* If we were not requested to position beyond end of file, we're
+	 done.  */
+      if (!(whence == SEEK_END && offset > 0))
+	return 0;
     }
-  else
-    return fseeko (fp, offset, whence);
+  return fseeko (fp, offset, whence);
 }

Modified: libprelude/trunk/libmissing/gai_strerror.c
===================================================================
--- libprelude/trunk/libmissing/gai_strerror.c	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/gai_strerror.c	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 2001, 2002, 2004, 2005, 2006, 2008 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 2001, 2002, 2004, 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Philip Blundell <[email protected]>, 1997.
 
@@ -50,7 +50,7 @@
     { EAI_SOCKTYPE, N_("ai_socktype not supported") },
     { EAI_SYSTEM, N_("System error") },
     { EAI_OVERFLOW, N_("Argument buffer too small") },
-#ifdef __USE_GNU
+#ifdef EAI_INPROGRESS
     { EAI_INPROGRESS, N_("Processing request in progress") },
     { EAI_CANCELED, N_("Request canceled") },
     { EAI_NOTCANCELED, N_("Request not canceled") },

Modified: libprelude/trunk/libmissing/gettimeofday.c
===================================================================
--- libprelude/trunk/libmissing/gettimeofday.c	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/gettimeofday.c	2009-04-07 07:51:35 UTC (rev 11123)
@@ -41,6 +41,12 @@
 static struct tm tm_zero_buffer;
 static struct tm *localtime_buffer_addr = &tm_zero_buffer;
 
+#undef localtime
+extern struct tm *localtime (time_t const *);
+
+#undef gmtime
+extern struct tm *gmtime (time_t const *);
+
 /* This is a wrapper for localtime.  It is used only on systems for which
    gettimeofday clobbers the static buffer used for localtime's result.
 
@@ -50,8 +56,6 @@
 struct tm *
 rpl_localtime (time_t const *timep)
 {
-#undef localtime
-  extern struct tm *localtime (time_t const *);
   struct tm *tm = localtime (timep);
 
   if (localtime_buffer_addr == &tm_zero_buffer)
@@ -64,8 +68,6 @@
 struct tm *
 rpl_gmtime (time_t const *timep)
 {
-#undef gmtime
-  extern struct tm *gmtime (time_t const *);
   struct tm *tm = gmtime (timep);
 
   if (localtime_buffer_addr == &tm_zero_buffer)
@@ -77,14 +79,15 @@
 #endif /* GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME */
 
 #if TZSET_CLOBBERS_LOCALTIME
+
+#undef tzset
+extern void tzset (void);
+
 /* This is a wrapper for tzset, for systems on which tzset may clobber
    the static buffer used for localtime's result.  */
 void
 rpl_tzset (void)
 {
-#undef tzset
-  extern void tzset (void);
-
   /* Save and restore the contents of the buffer used for localtime's
      result around the call to tzset.  */
   struct tm save = *localtime_buffer_addr;

Modified: libprelude/trunk/libmissing/glthread/threadlib.c
===================================================================
--- libprelude/trunk/libmissing/glthread/threadlib.c	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/glthread/threadlib.c	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
 /* Multithreading primitives.
-   Copyright (C) 2005-2008 Free Software Foundation, Inc.
+   Copyright (C) 2005-2009 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -26,6 +26,7 @@
 /* Use the POSIX threads library.  */
 
 # include <pthread.h>
+# include <stdlib.h>
 
 # if PTHREAD_IN_USE_DETECTION_HARD
 
@@ -67,3 +68,7 @@
 #endif
 
 /* ========================================================================= */
+
+/* This declaration is solely to ensure that after preprocessing
+   this file is never empty.  */
+typedef int dummy;

Modified: libprelude/trunk/libmissing/ioctl.c
===================================================================
--- libprelude/trunk/libmissing/ioctl.c	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/ioctl.c	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,6 +1,6 @@
 /* ioctl.c --- wrappers for Windows ioctl function
 
-   Copyright (C) 2008 Free Software Foundation, Inc.
+   Copyright (C) 2008, 2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -19,6 +19,8 @@
 
 #include <config.h>
 
+#include <sys/ioctl.h>
+
 #include <stdarg.h>
 
 #define WIN32_LEAN_AND_MEAN

Modified: libprelude/trunk/libmissing/localcharset.c
===================================================================
--- libprelude/trunk/libmissing/localcharset.c	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/localcharset.c	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,6 +1,6 @@
 /* Determine a canonical name for the current locale's character encoding.
 
-   Copyright (C) 2000-2006, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2000-2006, 2008-2009 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -28,6 +28,10 @@
 #include <string.h>
 #include <stdlib.h>
 
+#if defined __APPLE__ && defined __MACH__ && HAVE_LANGINFO_CODESET
+# define DARWIN7 /* Darwin 7 or newer, i.e. MacOS X 10.3 or newer */
+#endif
+
 #if defined _WIN32 || defined __WIN32__
 # define WIN32_NATIVE
 #endif
@@ -112,7 +116,7 @@
   cp = charset_aliases;
   if (cp == NULL)
     {
-#if !(defined VMS || defined WIN32_NATIVE || defined __CYGWIN__)
+#if !(defined DARWIN7 || defined VMS || defined WIN32_NATIVE || defined __CYGWIN__)
       FILE *fp;
       const char *dir;
       const char *base = "charset.alias";
@@ -213,6 +217,39 @@
 
 #else
 
+# if defined DARWIN7
+      /* To avoid the trouble of installing a file that is shared by many
+	 GNU packages -- many packaging systems have problems with this --,
+	 simply inline the aliases here.  */
+      cp = "ISO8859-1" "\0" "ISO-8859-1" "\0"
+	   "ISO8859-2" "\0" "ISO-8859-2" "\0"
+	   "ISO8859-4" "\0" "ISO-8859-4" "\0"
+	   "ISO8859-5" "\0" "ISO-8859-5" "\0"
+	   "ISO8859-7" "\0" "ISO-8859-7" "\0"
+	   "ISO8859-9" "\0" "ISO-8859-9" "\0"
+	   "ISO8859-13" "\0" "ISO-8859-13" "\0"
+	   "ISO8859-15" "\0" "ISO-8859-15" "\0"
+	   "KOI8-R" "\0" "KOI8-R" "\0"
+	   "KOI8-U" "\0" "KOI8-U" "\0"
+	   "CP866" "\0" "CP866" "\0"
+	   "CP949" "\0" "CP949" "\0"
+	   "CP1131" "\0" "CP1131" "\0"
+	   "CP1251" "\0" "CP1251" "\0"
+	   "eucCN" "\0" "GB2312" "\0"
+	   "GB2312" "\0" "GB2312" "\0"
+	   "eucJP" "\0" "EUC-JP" "\0"
+	   "eucKR" "\0" "EUC-KR" "\0"
+	   "Big5" "\0" "BIG5" "\0"
+	   "Big5HKSCS" "\0" "BIG5-HKSCS" "\0"
+	   "GBK" "\0" "GBK" "\0"
+	   "GB18030" "\0" "GB18030" "\0"
+	   "SJIS" "\0" "SHIFT_JIS" "\0"
+	   "ARMSCII-8" "\0" "ARMSCII-8" "\0"
+	   "PT154" "\0" "PT154" "\0"
+	 /*"ISCII-DEV" "\0" "?" "\0"*/
+	   "*" "\0" "UTF-8" "\0";
+# endif
+
 # if defined VMS
       /* To avoid the troubles of an extra file charset.alias_vms in the
 	 sources of many GNU packages, simply inline the aliases here.  */

Added: libprelude/trunk/libmissing/m4/00gnulib.m4
===================================================================
--- libprelude/trunk/libmissing/m4/00gnulib.m4	                        (rev 0)
+++ libprelude/trunk/libmissing/m4/00gnulib.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,30 @@
+# 00gnulib.m4 serial 2
+dnl Copyright (C) 2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl This file must be named something that sorts before all other
+dnl gnulib-provided .m4 files.  It is needed until such time as we can
+dnl assume Autoconf 2.64, with its improved AC_DEFUN_ONCE semantics.
+
+# AC_DEFUN_ONCE([NAME], VALUE)
+# ----------------------------
+# Define NAME to expand to VALUE on the first use (whether by direct
+# expansion, or by AC_REQUIRE), and to nothing on all subsequent uses.
+# Avoid bugs in AC_REQUIRE in Autoconf 2.63 and earlier.  This
+# definition is slower than the version in Autoconf 2.64, because it
+# can only use interfaces that existed since 2.59; but it achieves the
+# same effect.  Quoting is necessary to avoid confusing Automake.
+m4_version_prereq([2.63.263], [],
+[m4_define([AC][_DEFUN_ONCE],
+  [AC][_DEFUN([$1],
+    [AC_REQUIRE([_gl_DEFUN_ONCE([$1])],
+      [m4_indir([_gl_DEFUN_ONCE([$1])])])])]dnl
+[AC][_DEFUN([_gl_DEFUN_ONCE([$1])], [$2])])])
+
+# gl_00GNULIB
+# -----------
+# Witness macro that this file has been included.  Needed to force
+# Automake to include this file prior to all other gnulib .m4 files.
+AC_DEFUN([gl_00GNULIB])

Modified: libprelude/trunk/libmissing/m4/alloca.m4
===================================================================
--- libprelude/trunk/libmissing/m4/alloca.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/alloca.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# alloca.m4 serial 8
-dnl Copyright (C) 2002-2004, 2006, 2007 Free Software Foundation, Inc.
+# alloca.m4 serial 9
+dnl Copyright (C) 2002-2004, 2006, 2007, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -26,7 +26,7 @@
     ])
     if test $gl_cv_rpl_alloca = yes; then
       dnl OK, alloca can be implemented through a compiler built-in.
-      AC_DEFINE([HAVE_ALLOCA], 1,
+      AC_DEFINE([HAVE_ALLOCA], [1],
         [Define to 1 if you have 'alloca' after including <alloca.h>,
          a header that may be supplied by this distribution.])
       ALLOCA_H=alloca.h

Added: libprelude/trunk/libmissing/m4/btowc.m4
===================================================================
--- libprelude/trunk/libmissing/m4/btowc.m4	                        (rev 0)
+++ libprelude/trunk/libmissing/m4/btowc.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,68 @@
+# btowc.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_FUNC_BTOWC],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+
+  AC_CHECK_FUNCS_ONCE([btowc])
+  if test $ac_cv_func_btowc = no; then
+    HAVE_BTOWC=0
+  else
+
+    dnl IRIX 6.5 btowc(EOF) is 0xFF, not WEOF.
+    AC_REQUIRE([AC_PROG_CC])
+    AC_REQUIRE([gt_LOCALE_FR])
+    AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+    AC_CACHE_CHECK([whether btowc(EOF) is correct],
+      [gl_cv_func_btowc_eof],
+      [
+        dnl Initial guess, used when cross-compiling or when no suitable locale
+        dnl is present.
+changequote(,)dnl
+        case "$host_os" in
+                 # Guess no on IRIX.
+          irix*) gl_cv_func_btowc_eof="guessing no" ;;
+                 # Guess yes otherwise.
+          *)     gl_cv_func_btowc_eof="guessing yes" ;;
+        esac
+changequote([,])dnl
+        if test $LOCALE_FR != none; then
+          AC_TRY_RUN([
+#include <locale.h>
+#include <stdio.h>
+#include <string.h>
+#include <wchar.h>
+int main ()
+{
+  if (setlocale (LC_ALL, "$LOCALE_FR") != NULL)
+    {
+      if (btowc (EOF) != WEOF)
+        return 1;
+    }
+  return 0;
+}],
+            [gl_cv_func_btowc_eof=yes],
+            [gl_cv_func_btowc_eof=no],
+            [])
+        fi
+      ])
+    case "$gl_cv_func_btowc_eof" in
+      *yes) ;;
+      *) REPLACE_BTOWC=1 ;;
+    esac
+  fi
+  if test $HAVE_BTOWC = 0 || test $REPLACE_BTOWC = 1; then
+    gl_REPLACE_WCHAR_H
+    AC_LIBOBJ([btowc])
+    gl_PREREQ_BTOWC
+  fi
+])
+
+# Prerequisites of lib/btowc.c.
+AC_DEFUN([gl_PREREQ_BTOWC], [
+  :
+])

Modified: libprelude/trunk/libmissing/m4/close.m4
===================================================================
--- libprelude/trunk/libmissing/m4/close.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/close.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# close.m4 serial 2
-dnl Copyright (C) 2008 Free Software Foundation, Inc.
+# close.m4 serial 3
+dnl Copyright (C) 2008-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.

Modified: libprelude/trunk/libmissing/m4/codeset.m4
===================================================================
--- libprelude/trunk/libmissing/m4/codeset.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/codeset.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# codeset.m4 serial 2 (gettext-0.16)
-dnl Copyright (C) 2000-2002, 2006 Free Software Foundation, Inc.
+# codeset.m4 serial 4 (gettext-0.18)
+dnl Copyright (C) 2000-2002, 2006, 2008, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -8,14 +8,14 @@
 
 AC_DEFUN([AM_LANGINFO_CODESET],
 [
-  AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
+  AC_CACHE_CHECK([for nl_langinfo and CODESET], [am_cv_langinfo_codeset],
     [AC_TRY_LINK([#include <langinfo.h>],
       [char* cs = nl_langinfo(CODESET); return !cs;],
-      am_cv_langinfo_codeset=yes,
-      am_cv_langinfo_codeset=no)
+      [am_cv_langinfo_codeset=yes],
+      [am_cv_langinfo_codeset=no])
     ])
   if test $am_cv_langinfo_codeset = yes; then
-    AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
+    AC_DEFINE([HAVE_LANGINFO_CODESET], [1],
       [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
   fi
 ])

Modified: libprelude/trunk/libmissing/m4/errno_h.m4
===================================================================
--- libprelude/trunk/libmissing/m4/errno_h.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/errno_h.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,21 +1,15 @@
-# errno_h.m4 serial 1
-dnl Copyright (C) 2004, 2006, 2008 Free Software Foundation, Inc.
+# errno_h.m4 serial 4
+dnl Copyright (C) 2004, 2006, 2008, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
 
-AC_DEFUN([gl_HEADER_ERRNO_H],
+dnl This macro must pass through AC_REQUIRE (never directly invoke it).
+AC_DEFUN_ONCE([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,[
+  AC_CACHE_CHECK([for complete errno.h], [gl_cv_header_errno_h_complete], [
+    AC_EGREP_CPP([booboo],[
 #include <errno.h>
 #if !defined ENOMSG
 booboo
@@ -70,7 +64,7 @@
 [
   if test -n "$ERRNO_H"; then
     AC_CACHE_CHECK([for ]$1[ value], [gl_cv_header_errno_h_]$1, [
-      AC_EGREP_CPP(yes,[
+      AC_EGREP_CPP([yes],[
 #include <errno.h>
 #ifdef ]$1[
 yes
@@ -79,7 +73,7 @@
       [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,[
+        AC_EGREP_CPP([yes],[
 #define _XOPEN_SOURCE_EXTENDED 1
 #include <errno.h>
 #ifdef ]$1[
@@ -111,3 +105,9 @@
     AC_SUBST($1[_VALUE])
   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])])
+])

Modified: libprelude/trunk/libmissing/m4/extensions.m4
===================================================================
--- libprelude/trunk/libmissing/m4/extensions.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/extensions.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,7 +1,7 @@
-# serial 5  -*- Autoconf -*-
+# serial 8  -*- Autoconf -*-
 # Enable extensions on systems that normally disable them.
 
-# Copyright (C) 2003, 2006-2008 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2006-2009 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -20,10 +20,12 @@
 # AC_DEFINE.  The goal here is to define all known feature-enabling
 # macros, then, if reports of conflicts are made, disable macros that
 # cause problems on some platforms (such as __EXTENSIONS__).
-AC_DEFUN([AC_USE_SYSTEM_EXTENSIONS],
+AC_DEFUN_ONCE([AC_USE_SYSTEM_EXTENSIONS],
 [AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
 AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
 
+  AC_REQUIRE([AC_CANONICAL_HOST])
+
   AC_CHECK_HEADER([minix/config.h], [MINIX=yes], [MINIX=])
   if test "$MINIX" = yes; then
     AC_DEFINE([_POSIX_SOURCE], [1],
@@ -36,6 +38,16 @@
       [Define to 1 if on MINIX.])
   fi
 
+  dnl HP-UX 11.11 defines mbstate_t only if _XOPEN_SOURCE is defined to 500,
+  dnl regardless of whether the flags -Ae or _D_HPUX_SOURCE=1 are already
+  dnl provided.
+  case "$host_os" in
+    hpux*)
+      AC_DEFINE([_XOPEN_SOURCE], [500],
+        [Define to 500 only on HP-UX.])
+      ;;
+  esac
+
   AH_VERBATIM([__EXTENSIONS__],
 [/* Enable extensions on AIX 3, Interix.  */
 #ifndef _ALL_SOURCE
@@ -78,5 +90,15 @@
 # ------------------------
 # Enable extensions on systems that normally disable them,
 # typically due to standards-conformance issues.
-AC_DEFUN([gl_USE_SYSTEM_EXTENSIONS],
-  [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])])
+AC_DEFUN_ONCE([gl_USE_SYSTEM_EXTENSIONS],
+[
+  dnl Require this macro before AC_USE_SYSTEM_EXTENSIONS.
+  dnl gnulib does not need it. But if it gets required by third-party macros
+  dnl after AC_USE_SYSTEM_EXTENSIONS is required, autoconf 2.62..2.63 emit a
+  dnl warning: "AC_COMPILE_IFELSE was called before AC_USE_SYSTEM_EXTENSIONS".
+  dnl Note: We can do this only for one of the macros AC_AIX, AC_GNU_SOURCE,
+  dnl AC_MINIX. If people still use AC_AIX or AC_MINIX, they are out of luck.
+  AC_REQUIRE([AC_GNU_SOURCE])
+
+  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+])

Modified: libprelude/trunk/libmissing/m4/fopen.m4
===================================================================
--- libprelude/trunk/libmissing/m4/fopen.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/fopen.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# fopen.m4 serial 3
-dnl Copyright (C) 2007-2008 Free Software Foundation, Inc.
+# fopen.m4 serial 5
+dnl Copyright (C) 2007-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -10,8 +10,10 @@
   AC_REQUIRE([AC_CANONICAL_HOST])
   case "$host_os" in
     mingw* | pw*)
+      dnl Replace fopen, for handling of "/dev/null".
       REPLACE_FOPEN=1
-      AC_LIBOBJ([fopen])
+      dnl fopen on mingw also has the trailing slash bug.
+      gl_cv_func_fopen_slash="guessing no"
       ;;
     *)
       dnl fopen("foo/", "w") should not create a file when the file name has a
@@ -37,17 +39,19 @@
             ])
           rm -f conftest.sl
         ])
-      case "$gl_cv_func_fopen_slash" in
-        *no)
-          AC_DEFINE([FOPEN_TRAILING_SLASH_BUG], 1,
-            [Define to 1 if fopen() fails to recognize a trailing slash.])
-          REPLACE_FOPEN=1
-          AC_LIBOBJ([fopen])
-          gl_PREREQ_FOPEN
-          ;;
-      esac
       ;;
   esac
+  case "$gl_cv_func_fopen_slash" in
+    *no)
+      AC_DEFINE([FOPEN_TRAILING_SLASH_BUG], [1],
+        [Define to 1 if fopen() fails to recognize a trailing slash.])
+      REPLACE_FOPEN=1
+      ;;
+  esac
+  if test $REPLACE_FOPEN = 1; then
+    AC_LIBOBJ([fopen])
+    gl_PREREQ_FOPEN
+  fi
 ])
 
 # Prerequisites of lib/fopen.c.

Modified: libprelude/trunk/libmissing/m4/getaddrinfo.m4
===================================================================
--- libprelude/trunk/libmissing/m4/getaddrinfo.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/getaddrinfo.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# getaddrinfo.m4 serial 17
-dnl Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# getaddrinfo.m4 serial 20
+dnl Copyright (C) 2004-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -9,8 +9,21 @@
   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])
+  GETADDRINFO_LIB=
+  gai_saved_LIBS="$LIBS"
 
-  AC_SEARCH_LIBS(getaddrinfo, [nsl socket])
+  dnl Where is getaddrinfo()?
+  dnl - On Solaris, it is in libsocket.
+  dnl - On Haiku, it is in libnetwork.
+  dnl - On BeOS, it is in libnet.
+  dnl - On native Windows, it is in ws2_32.dll.
+  dnl - Otherwise it is in libc.
+  AC_SEARCH_LIBS([getaddrinfo], [socket network net],
+    [if test "$ac_cv_search_getaddrinfo" != "none required"; then
+       GETADDRINFO_LIB="$ac_cv_search_getaddrinfo"
+     fi])
+  LIBS="$gai_saved_LIBS $GETADDRINFO_LIB"
+
   AC_CACHE_CHECK([for getaddrinfo], [gl_cv_func_getaddrinfo], [
     AC_TRY_LINK([
 #include <sys/types.h>
@@ -25,7 +38,7 @@
       [gl_cv_func_getaddrinfo=yes],
       [gl_cv_func_getaddrinfo=no])])
   if test $gl_cv_func_getaddrinfo = no; then
-    AC_CACHE_CHECK(for getaddrinfo in ws2tcpip.h and -lws2_32,
+    AC_CACHE_CHECK([for getaddrinfo in ws2tcpip.h and -lws2_32],
 		   gl_cv_w32_getaddrinfo, [
       gl_cv_w32_getaddrinfo=no
       am_save_LIBS="$LIBS"
@@ -36,11 +49,13 @@
 #endif
 #include <stddef.h>
 ], [getaddrinfo(NULL, NULL, NULL, NULL);], gl_cv_w32_getaddrinfo=yes)
-    LIBS="$am_save_LIBS"])
+      LIBS="$am_save_LIBS"
+    ])
     if test "$gl_cv_w32_getaddrinfo" = "yes"; then
-      LIBS="$LIBS -lws2_32"
+      GETADDRINFO_LIB="-lws2_32"
+      LIBS="$gai_saved_LIBS $GETADDRINFO_LIB"
     else
-      AC_LIBOBJ(getaddrinfo)
+      AC_LIBOBJ([getaddrinfo])
     fi
   fi
 
@@ -65,35 +80,22 @@
         [gl_cv_func_gai_strerror=yes],
         [gl_cv_func_gai_strerror=no])])
   if test $gl_cv_func_gai_strerror = no; then
-    AC_LIBOBJ(gai_strerror)
+    AC_LIBOBJ([gai_strerror])
   fi
 
+  LIBS="$gai_saved_LIBS"
+
   gl_PREREQ_GETADDRINFO
+
+  AC_SUBST([GETADDRINFO_LIB])
 ])
 
 # Prerequisites of lib/netdb.in.h and lib/getaddrinfo.c.
 AC_DEFUN([gl_PREREQ_GETADDRINFO], [
   AC_REQUIRE([gl_NETDB_H_DEFAULTS])
   AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
-  AC_SEARCH_LIBS(gethostbyname, [inet nsl])
-  AC_SEARCH_LIBS(getservbyname, [inet nsl socket xnet])
-  AC_CHECK_FUNCS(gethostbyname,, [
-    AC_CACHE_CHECK(for gethostbyname in winsock2.h and -lws2_32,
-		   gl_cv_w32_gethostbyname, [
-      gl_cv_w32_gethostbyname=no
-      am_save_LIBS="$LIBS"
-      LIBS="$LIBS -lws2_32"
-      AC_TRY_LINK([
-#ifdef HAVE_WINSOCK2_H
-#include <winsock2.h>
-#endif
-#include <stddef.h>
-], [gethostbyname(NULL);], gl_cv_w32_gethostbyname=yes)
-    LIBS="$am_save_LIBS"])
-    if test "$gl_cv_w32_gethostbyname" = "yes"; then
-      LIBS="$LIBS -lws2_32"
-    fi
-    ])
+  AC_REQUIRE([gl_HOSTENT]) dnl for HOSTENT_LIB
+  AC_REQUIRE([gl_SERVENT]) dnl for SERVENT_LIB
   AC_REQUIRE([AC_C_RESTRICT])
   AC_REQUIRE([gl_SOCKET_FAMILIES])
   AC_REQUIRE([gl_HEADER_SYS_SOCKET])
@@ -104,7 +106,7 @@
   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_HEADERS_ONCE([netinet/in.h])
 
   AC_CHECK_DECLS([getaddrinfo, freeaddrinfo, gai_strerror, getnameinfo],,,[
   /* sys/types.h is not needed according to POSIX, but the
@@ -149,4 +151,16 @@
   if test $ac_cv_type_struct_addrinfo = no; then
     HAVE_STRUCT_ADDRINFO=0
   fi
+
+  dnl Append $HOSTENT_LIB to GETADDRINFO_LIB, avoiding gratuitous duplicates.
+  case " $GETADDRINFO_LIB " in
+    *" $HOSTENT_LIB "*) ;;
+    *) GETADDRINFO_LIB="$GETADDRINFO_LIB $HOSTENT_LIB" ;;
+  esac
+
+  dnl Append $SERVENT_LIB to GETADDRINFO_LIB, avoiding gratuitous duplicates.
+  case " $GETADDRINFO_LIB " in
+    *" $SERVENT_LIB "*) ;;
+    *) GETADDRINFO_LIB="$GETADDRINFO_LIB $SERVENT_LIB" ;;
+  esac
 ])

Modified: libprelude/trunk/libmissing/m4/getline.m4
===================================================================
--- libprelude/trunk/libmissing/m4/getline.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/getline.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,7 +1,6 @@
-# getline.m4 serial 18
+# getline.m4 serial 19
 
-dnl Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007 Free
-dnl Software Foundation, Inc.
+dnl Copyright (C) 1998-2003, 2005-2007, 2009 Free Software Foundation, Inc.
 dnl
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -10,7 +9,7 @@
 AC_PREREQ([2.59])
 
 dnl See if there's a working, system-supplied version of the getline function.
-dnl We can't just do AC_REPLACE_FUNCS(getline) because some systems
+dnl We can't just do AC_REPLACE_FUNCS([getline]) because some systems
 dnl have a function by that name in -linet that doesn't have anything
 dnl to do with the function we need.
 AC_DEFUN([gl_FUNC_GETLINE],
@@ -23,12 +22,12 @@
   AC_CHECK_DECLS_ONCE([getline])
 
   gl_getline_needs_run_time_check=no
-  AC_CHECK_FUNC(getline,
+  AC_CHECK_FUNC([getline],
 		dnl Found it in some library.  Verify that it works.
 		gl_getline_needs_run_time_check=yes,
 		am_cv_func_working_getline=no)
   if test $gl_getline_needs_run_time_check = yes; then
-    AC_CACHE_CHECK([for working getline function], am_cv_func_working_getline,
+    AC_CACHE_CHECK([for working getline function], [am_cv_func_working_getline],
     [echo fooN |tr -d '\012'|tr N '\012' > conftest.data
     AC_TRY_RUN([
 #    include <stdio.h>

Modified: libprelude/trunk/libmissing/m4/getpass.m4
===================================================================
--- libprelude/trunk/libmissing/m4/getpass.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/getpass.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# getpass.m4 serial 10
-dnl Copyright (C) 2002-2003, 2005-2006 Free Software Foundation, Inc.
+# getpass.m4 serial 11
+dnl Copyright (C) 2002-2003, 2005-2006, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -7,8 +7,8 @@
 # Provide a getpass() function if the system doesn't have it.
 AC_DEFUN([gl_FUNC_GETPASS],
 [
-  AC_REPLACE_FUNCS(getpass)
-  AC_CHECK_DECLS_ONCE(getpass)
+  AC_REPLACE_FUNCS([getpass])
+  AC_CHECK_DECLS_ONCE([getpass])
   if test $ac_cv_func_getpass = no; then
     gl_PREREQ_GETPASS
   fi
@@ -18,9 +18,9 @@
 # arbitrary length (not just 8 bytes as on HP-UX).
 AC_DEFUN([gl_FUNC_GETPASS_GNU],
 [
-  AC_CHECK_DECLS_ONCE(getpass)
+  AC_CHECK_DECLS_ONCE([getpass])
   dnl TODO: Detect when GNU getpass() is already found in glibc.
-  AC_LIBOBJ(getpass)
+  AC_LIBOBJ([getpass])
   gl_PREREQ_GETPASS
   dnl We must choose a different name for our function, since on ELF systems
   dnl an unusable getpass() in libc.so would override our getpass() if it is
@@ -31,8 +31,8 @@
 
 # Prerequisites of lib/getpass.c.
 AC_DEFUN([gl_PREREQ_GETPASS], [
-  AC_CHECK_HEADERS_ONCE(stdio_ext.h termios.h)
-  AC_CHECK_FUNCS_ONCE(__fsetlocking tcgetattr tcsetattr)
+  AC_CHECK_HEADERS_ONCE([stdio_ext.h termios.h])
+  AC_CHECK_FUNCS_ONCE([__fsetlocking tcgetattr tcsetattr])
   AC_CHECK_DECLS([__fsetlocking],,,
     [#include <stdio.h>
      #if HAVE_STDIO_EXT_H

Modified: libprelude/trunk/libmissing/m4/gettimeofday.m4
===================================================================
--- libprelude/trunk/libmissing/m4/gettimeofday.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/gettimeofday.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,6 +1,6 @@
-#serial 11
+# serial 12
 
-# Copyright (C) 2001, 2002, 2003, 2005, 2007 Free Software Foundation, Inc.
+# Copyright (C) 2001-2003, 2005, 2007, 2009 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -34,7 +34,7 @@
     REPLACE_GETTIMEOFDAY=1
     SYS_TIME_H=sys/time.h
     if test $gl_cv_func_gettimeofday_clobber != yes; then
-      AC_LIBOBJ(gettimeofday)
+      AC_LIBOBJ([gettimeofday])
       gl_PREREQ_GETTIMEOFDAY
     fi
   fi
@@ -80,13 +80,13 @@
    REPLACE_GETTIMEOFDAY=1
    SYS_TIME_H=sys/time.h
    gl_GETTIMEOFDAY_REPLACE_LOCALTIME
-   AC_DEFINE([GETTIMEOFDAY_CLOBBERS_LOCALTIME], 1,
+   AC_DEFINE([GETTIMEOFDAY_CLOBBERS_LOCALTIME], [1],
      [Define if gettimeofday clobbers the localtime buffer.])
  fi
 ])
 
 AC_DEFUN([gl_GETTIMEOFDAY_REPLACE_LOCALTIME], [
-  AC_LIBOBJ(gettimeofday)
+  AC_LIBOBJ([gettimeofday])
   gl_PREREQ_GETTIMEOFDAY
   AC_DEFINE([gmtime], [rpl_gmtime],
     [Define to rpl_gmtime if the replacement function should be used.])

Modified: libprelude/trunk/libmissing/m4/glibc21.m4
===================================================================
--- libprelude/trunk/libmissing/m4/glibc21.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/glibc21.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# glibc21.m4 serial 3
-dnl Copyright (C) 2000-2002, 2004 Free Software Foundation, Inc.
+# glibc21.m4 serial 4
+dnl Copyright (C) 2000-2002, 2004, 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.
@@ -9,8 +9,8 @@
 
 AC_DEFUN([gl_GLIBC21],
   [
-    AC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer,
-      ac_cv_gnu_library_2_1,
+    AC_CACHE_CHECK([whether we are using the GNU C Library 2.1 or newer],
+      [ac_cv_gnu_library_2_1],
       [AC_EGREP_CPP([Lucky GNU user],
 	[
 #include <features.h>
@@ -20,11 +20,11 @@
  #endif
 #endif
 	],
-	ac_cv_gnu_library_2_1=yes,
-	ac_cv_gnu_library_2_1=no)
+	[ac_cv_gnu_library_2_1=yes],
+	[ac_cv_gnu_library_2_1=no])
       ]
     )
-    AC_SUBST(GLIBC21)
+    AC_SUBST([GLIBC21])
     GLIBC21="$ac_cv_gnu_library_2_1"
   ]
 )

Modified: libprelude/trunk/libmissing/m4/gnulib-cache.m4
===================================================================
--- libprelude/trunk/libmissing/m4/gnulib-cache.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/gnulib-cache.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,4 +1,4 @@
-# Copyright (C) 2002-2008 Free Software Foundation, Inc.
+# Copyright (C) 2002-2009 Free Software Foundation, Inc.
 #
 # This file is free software, distributed under the terms of the GNU
 # General Public License.  As a special exception to the GNU General

Modified: libprelude/trunk/libmissing/m4/gnulib-common.m4
===================================================================
--- libprelude/trunk/libmissing/m4/gnulib-common.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/gnulib-common.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# gnulib-common.m4 serial 6
-dnl Copyright (C) 2007-2008 Free Software Foundation, Inc.
+# gnulib-common.m4 serial 11
+dnl Copyright (C) 2007-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -8,6 +8,7 @@
 # is expanded unconditionally through gnulib-tool magic.
 AC_DEFUN([gl_COMMON], [
   dnl Use AC_REQUIRE here, so that the code is expanded once only.
+  AC_REQUIRE([gl_00GNULIB])
   AC_REQUIRE([gl_COMMON_BODY])
 ])
 AC_DEFUN([gl_COMMON_BODY], [
@@ -52,7 +53,7 @@
 # is a backport of autoconf-2.60's AC_PROG_MKDIR_P.
 # Remove this macro when we can assume autoconf >= 2.60.
 m4_ifdef([AC_PROG_MKDIR_P], [], [
-  AC_DEFUN([AC_PROG_MKDIR_P],
+  AC_DEFUN_ONCE([AC_PROG_MKDIR_P],
     [AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake
      MKDIR_P='$(mkdir_p)'
      AC_SUBST([MKDIR_P])])])
@@ -63,7 +64,7 @@
 # works.
 # This definition can be removed once autoconf >= 2.62 can be assumed.
 AC_DEFUN([AC_C_RESTRICT],
-[AC_CACHE_CHECK([for C/C++ restrict keyword], ac_cv_c_restrict,
+[AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict],
   [ac_cv_c_restrict=no
    # The order here caters to the fact that C++ does not require restrict.
    for ac_kw in __restrict __restrict__ _Restrict restrict; do
@@ -99,3 +100,25 @@
    *)  AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;;
  esac
 ])
+
+# gl_BIGENDIAN
+# is like AC_C_BIGENDIAN, except that it can be AC_REQUIREd.
+# Note that AC_REQUIRE([AC_C_BIGENDIAN]) does not work reliably because some
+# macros invoke AC_C_BIGENDIAN with arguments.
+AC_DEFUN([gl_BIGENDIAN],
+[
+  AC_C_BIGENDIAN
+])
+
+# gl_CACHE_VAL_SILENT(cache-id, command-to-set-it)
+# is like AC_CACHE_VAL(cache-id, command-to-set-it), except that it does not
+# output a spurious "(cached)" mark in the midst of other configure output.
+# This macro should be used instead of AC_CACHE_VAL when it is not surrounded
+# by an AC_MSG_CHECKING/AC_MSG_RESULT pair.
+AC_DEFUN([gl_CACHE_VAL_SILENT],
+[
+  saved_as_echo_n="$as_echo_n"
+  as_echo_n=':'
+  AC_CACHE_VAL([$1], [$2])
+  as_echo_n="$saved_as_echo_n"
+])

Modified: libprelude/trunk/libmissing/m4/gnulib-comp.m4
===================================================================
--- libprelude/trunk/libmissing/m4/gnulib-comp.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/gnulib-comp.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
 # DO NOT EDIT! GENERATED AUTOMATICALLY!
-# Copyright (C) 2002-2008 Free Software Foundation, Inc.
+# Copyright (C) 2002-2009 Free Software Foundation, Inc.
 #
 # This file is free software, distributed under the terms of the GNU
 # General Public License.  As a special exception to the GNU General
@@ -26,7 +26,6 @@
   m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable
   AC_REQUIRE([AC_PROG_RANLIB])
   AC_REQUIRE([AM_PROG_CC_C_O])
-  AC_REQUIRE([AC_GNU_SOURCE])
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
   AC_REQUIRE([AC_FUNC_FSEEKO])
   gl_THREADLIB_EARLY
@@ -62,6 +61,8 @@
     AC_LIBOBJ([bind])
   fi
   gl_SYS_SOCKET_MODULE_INDICATOR([bind])
+  gl_FUNC_BTOWC
+  gl_WCHAR_MODULE_INDICATOR([btowc])
   gl_FUNC_CLOSE
   gl_UNISTD_MODULE_INDICATOR([close])
   gl_COND
@@ -72,7 +73,7 @@
   gl_SYS_SOCKET_MODULE_INDICATOR([connect])
   gl_FUNC_DUP2
   gl_UNISTD_MODULE_INDICATOR([dup2])
-  gl_HEADER_ERRNO_H
+  AC_REQUIRE([gl_HEADER_ERRNO_H])
   gl_FUNC_FCLOSE
   gl_STDIO_MODULE_INDICATOR([fclose])
   gl_FLOAT_H
@@ -96,6 +97,7 @@
   AC_SUBST([LIBINTL])
   AC_SUBST([LTLIBINTL])
   gl_FUNC_GETTIMEOFDAY
+  gl_HOSTENT
   gl_INET_NTOP
   gl_ARPA_INET_MODULE_INDICATOR([inet_ntop])
   gl_INET_PTON
@@ -122,11 +124,16 @@
   AC_DEFINE([GNULIB_MALLOC_GNU], 1, [Define to indicate the 'malloc' module.])
   gl_FUNC_MALLOC_POSIX
   gl_STDLIB_MODULE_INDICATOR([malloc-posix])
+  gl_FUNC_MBRTOWC
+  gl_WCHAR_MODULE_INDICATOR([mbrtowc])
+  gl_FUNC_MBSINIT
+  gl_WCHAR_MODULE_INDICATOR([mbsinit])
   gl_FUNC_MEMMEM
   gl_FUNC_MEMMEM_SIMPLE
   gl_STRING_MODULE_INDICATOR([memmem])
   gl_MINMAX
   gl_FUNC_MKTIME
+  AC_REQUIRE([gl_MULTIARCH])
   gl_HEADER_NETDB
   gl_HEADER_NETINET_IN
   AC_PROG_MKDIR_P
@@ -138,11 +145,9 @@
   gl_STDLIB_MODULE_INDICATOR([realloc-posix])
   gl_REGEX
   gl_RELOCATABLE_LIBRARY
-  AC_REQUIRE([gl_HEADER_SYS_SELECT])
-  if test "$ac_cv_header_winsock2_h" = yes; then
-    AC_LIBOBJ([winsock-select])
-  fi
+  gl_FUNC_SELECT
   gl_SYS_SELECT_MODULE_INDICATOR([select])
+  gl_SERVENT
   AC_REQUIRE([gl_HEADER_SYS_SOCKET])
   if test "$ac_cv_header_winsock2_h" = yes; then
     AC_LIBOBJ([setsockopt])
@@ -191,7 +196,6 @@
   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
@@ -209,6 +213,8 @@
   gl_FUNC_VSNPRINTF
   gl_STDIO_MODULE_INDICATOR([vsnprintf])
   gl_WCHAR_H
+  gl_FUNC_WCRTOMB
+  gl_WCHAR_MODULE_INDICATOR([wcrtomb])
   gl_WCTYPE_H
   gl_FUNC_WRITE
   gl_UNISTD_MODULE_INDICATOR([write])
@@ -252,6 +258,14 @@
   m4_pushdef([gltests_LIBSOURCES_DIR], [])
   gl_COMMON
   gl_source_base='libmissing/tests'
+  gt_LOCALE_FR
+  gt_LOCALE_FR_UTF8
+  gl_FUNC_UNGETC_WORKS
+  gt_LOCALE_FR
+  gt_LOCALE_FR_UTF8
+  gt_LOCALE_JA
+  gt_LOCALE_ZH_CN
+  gt_LOCALE_FR_UTF8
   AC_CHECK_DECLS_ONCE([alarm])
   AC_CHECK_HEADERS_ONCE([unistd.h sys/wait.h])
   AC_CHECK_HEADERS_ONCE([unistd.h sys/wait.h])
@@ -260,6 +274,12 @@
   gt_TYPE_WINT_T
   AC_CHECK_DECLS_ONCE([alarm])
   AC_CHECK_FUNCS([shutdown])
+  gt_LOCALE_FR
+  gt_LOCALE_FR_UTF8
+  gt_LOCALE_JA
+  gt_LOCALE_ZH_CN
+  gl_FUNC_WCTOB
+  gl_WCHAR_MODULE_INDICATOR([wctob])
   gl_YIELD
   m4_ifval(gltests_LIBSOURCES_LIST, [
     m4_syscmd([test ! -d ]m4_defn([gltests_LIBSOURCES_DIR])[ ||
@@ -361,8 +381,11 @@
   lib/arpa_inet.in.h
   lib/asnprintf.c
   lib/bind.c
+  lib/btowc.c
   lib/c-ctype.c
   lib/c-ctype.h
+  lib/close-hook.c
+  lib/close-hook.h
   lib/close.c
   lib/config.charset
   lib/connect.c
@@ -402,6 +425,8 @@
   lib/localcharset.h
   lib/lseek.c
   lib/malloc.c
+  lib/mbrtowc.c
+  lib/mbsinit.c
   lib/memmem.c
   lib/minmax.h
   lib/mktime.c
@@ -426,6 +451,7 @@
   lib/regexec.c
   lib/relocatable.c
   lib/relocatable.h
+  lib/select.c
   lib/setsockopt.c
   lib/signal.in.h
   lib/sigprocmask.c
@@ -443,6 +469,7 @@
   lib/strcasecmp.c
   lib/strcasestr.c
   lib/strdup.c
+  lib/streq.h
   lib/strerror.c
   lib/string.in.h
   lib/strings.in.h
@@ -464,15 +491,18 @@
   lib/unistd.in.h
   lib/vasnprintf.c
   lib/vasnprintf.h
+  lib/verify.h
   lib/vsnprintf.c
   lib/w32sock.h
   lib/wchar.in.h
+  lib/wcrtomb.c
   lib/wctype.in.h
-  lib/winsock-select.c
   lib/write.c
   lib/xsize.h
+  m4/00gnulib.m4
   m4/alloca.m4
   m4/arpa_inet_h.m4
+  m4/btowc.m4
   m4/close.m4
   m4/codeset.m4
   m4/cond.m4
@@ -491,6 +521,7 @@
   m4/gettimeofday.m4
   m4/glibc21.m4
   m4/gnulib-common.m4
+  m4/hostent.m4
   m4/include_next.m4
   m4/inet_ntop.m4
   m4/inet_pton.m4
@@ -500,14 +531,20 @@
   m4/lib-link.m4
   m4/lib-prefix.m4
   m4/localcharset.m4
+  m4/locale-fr.m4
+  m4/locale-ja.m4
+  m4/locale-zh.m4
   m4/lock.m4
   m4/longlong.m4
   m4/lseek.m4
   m4/malloc.m4
+  m4/mbrtowc.m4
+  m4/mbsinit.m4
   m4/mbstate_t.m4
   m4/memmem.m4
   m4/minmax.m4
   m4/mktime.m4
+  m4/multiarch.m4
   m4/netdb_h.m4
   m4/netinet_in_h.m4
   m4/onceonly.m4
@@ -518,6 +555,8 @@
   m4/realloc.m4
   m4/regex.m4
   m4/relocatable-lib.m4
+  m4/select.m4
+  m4/servent.m4
   m4/signal_h.m4
   m4/signalblocking.m4
   m4/size_max.m4
@@ -555,11 +594,14 @@
   m4/tls.m4
   m4/tm_gmtoff.m4
   m4/uname.m4
+  m4/ungetc.m4
   m4/unistd_h.m4
   m4/vasnprintf.m4
   m4/vsnprintf.m4
   m4/wchar.m4
   m4/wchar_t.m4
+  m4/wcrtomb.m4
+  m4/wctob.m4
   m4/wctype.m4
   m4/wint_t.m4
   m4/write.m4
@@ -567,12 +609,16 @@
   m4/yield.m4
   tests/test-alloca-opt.c
   tests/test-arpa_inet.c
+  tests/test-btowc.c
+  tests/test-btowc1.sh
+  tests/test-btowc2.sh
   tests/test-c-ctype.c
   tests/test-cond.c
   tests/test-errno.c
   tests/test-fopen.c
   tests/test-fseeko.c
   tests/test-fseeko.sh
+  tests/test-fseeko2.sh
   tests/test-getaddrinfo.c
   tests/test-getdelim.c
   tests/test-getline.c
@@ -580,6 +626,13 @@
   tests/test-lock.c
   tests/test-lseek.c
   tests/test-lseek.sh
+  tests/test-mbrtowc.c
+  tests/test-mbrtowc1.sh
+  tests/test-mbrtowc2.sh
+  tests/test-mbrtowc3.sh
+  tests/test-mbrtowc4.sh
+  tests/test-mbsinit.c
+  tests/test-mbsinit.sh
   tests/test-memmem.c
   tests/test-netdb.c
   tests/test-netinet_in.c
@@ -591,6 +644,7 @@
   tests/test-select-out.sh
   tests/test-select-stdin.c
   tests/test-select.c
+  tests/test-signal.c
   tests/test-sleep.c
   tests/test-snprintf.c
   tests/test-sockets.c
@@ -612,9 +666,12 @@
   tests/test-vasnprintf.c
   tests/test-vsnprintf.c
   tests/test-wchar.c
+  tests/test-wcrtomb.c
+  tests/test-wcrtomb.sh
   tests/test-wctype.c
   tests=lib/glthread/yield.h
   tests=lib/sockets.c
   tests=lib/sockets.h
-  tests=lib/verify.h
+  tests=lib/w32sock.h
+  tests=lib/wctob.c
 ])

Added: libprelude/trunk/libmissing/m4/hostent.m4
===================================================================
--- libprelude/trunk/libmissing/m4/hostent.m4	                        (rev 0)
+++ libprelude/trunk/libmissing/m4/hostent.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,45 @@
+# hostent.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_HOSTENT],
+[
+  dnl Where are gethostent(), sethostent(), endhostent(), gethostbyname(),
+  dnl gethostbyaddr() defined?
+  dnl - On Solaris, they are in libnsl. Ignore libxnet.
+  dnl - On Haiku, they are in libnetwork.
+  dnl - On BeOS, they are in libnet.
+  dnl - On native Windows, they are in ws2_32.dll.
+  dnl - Otherwise they are in libc.
+  AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
+  HOSTENT_LIB=
+  gl_saved_libs="$LIBS"
+  AC_SEARCH_LIBS([gethostbyname], [nsl network net],
+    [if test "$ac_cv_search_gethostbyname" != "none required"; then
+       HOSTENT_LIB="$ac_cv_search_gethostbyname"
+     fi])
+  LIBS="$gl_saved_libs"
+  if test -z "$HOSTENT_LIB"; then
+    AC_CHECK_FUNCS([gethostbyname], , [
+      AC_CACHE_CHECK([for gethostbyname in winsock2.h and -lws2_32],
+        [gl_cv_w32_gethostbyname],
+        [gl_cv_w32_gethostbyname=no
+         gl_save_LIBS="$LIBS"
+         LIBS="$LIBS -lws2_32"
+         AC_TRY_LINK([
+#ifdef HAVE_WINSOCK2_H
+#include <winsock2.h>
+#endif
+#include <stddef.h>
+], [gethostbyname(NULL);], [gl_cv_w32_gethostbyname=yes])
+         LIBS="$gl_save_LIBS"
+        ])
+      if test "$gl_cv_w32_gethostbyname" = "yes"; then
+        HOSTENT_LIB="-lws2_32"
+      fi
+    ])
+  fi
+  AC_SUBST([HOSTENT_LIB])
+])

Modified: libprelude/trunk/libmissing/m4/include_next.m4
===================================================================
--- libprelude/trunk/libmissing/m4/include_next.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/include_next.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# include_next.m4 serial 9
-dnl Copyright (C) 2006-2008 Free Software Foundation, Inc.
+# include_next.m4 serial 12
+dnl Copyright (C) 2006-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -11,6 +11,10 @@
 dnl INCLUDE_NEXT expands to 'include_next' if the compiler supports it, or to
 dnl 'include' otherwise.
 dnl
+dnl INCLUDE_NEXT_AS_FIRST_DIRECTIVE expands to 'include_next' if the compiler
+dnl supports it in the special case that it is the first include directive in
+dnl the given file, or to '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
@@ -26,13 +30,28 @@
   AC_LANG_PREPROC_REQUIRE()
   AC_CACHE_CHECK([whether the preprocessor supports 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
+    [rm -rf conftestd1a conftestd1b conftestd2
+     mkdir conftestd1a conftestd1b conftestd2
+     dnl IBM C 9.0, 10.1 (original versions, prior to the 2009-01 updates) on
+     dnl AIX 6.1 support include_next when used as first preprocessor directive
+     dnl in a file, but not when preceded by another include directive. Check
+     dnl for this bug by including <stdio.h>.
+     dnl Additionally, with this same compiler, include_next is a no-op when
+     dnl used in a header file that was included by specifying its absolute
+     dnl file name. Despite these two bugs, include_next is used in the
+     dnl compiler's <math.h>. By virtue of the second bug, we need to use
+     dnl include_next as well in this case.
+     cat <<EOF > conftestd1a/conftest.h
 #define DEFINED_IN_CONFTESTD1
+#include_next <conftest.h>
+#ifdef DEFINED_IN_CONFTESTD2
+int foo;
+#else
+#error "include_next doesn't work"
+#endif
+EOF
+     cat <<EOF > conftestd1b/conftest.h
+#define DEFINED_IN_CONFTESTD1
 #include <stdio.h>
 #include_next <conftest.h>
 #ifdef DEFINED_IN_CONFTESTD2
@@ -47,24 +66,36 @@
 #endif
 #define DEFINED_IN_CONFTESTD2
 EOF
-     save_CPPFLAGS="$CPPFLAGS"
-     CPPFLAGS="$CPPFLAGS -Iconftestd1 -Iconftestd2"
+     gl_save_CPPFLAGS="$CPPFLAGS"
+     CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1b -Iconftestd2"
      AC_COMPILE_IFELSE([#include <conftest.h>],
        [gl_cv_have_include_next=yes],
-       [gl_cv_have_include_next=no])
-     CPPFLAGS="$save_CPPFLAGS"
-     rm -rf conftestd1 conftestd2
+       [CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1a -Iconftestd2"
+        AC_COMPILE_IFELSE([#include <conftest.h>],
+          [gl_cv_have_include_next=buggy],
+          [gl_cv_have_include_next=no])
+       ])
+     CPPFLAGS="$gl_save_CPPFLAGS"
+     rm -rf conftestd1a conftestd1b conftestd2
     ])
   PRAGMA_SYSTEM_HEADER=
   if test $gl_cv_have_include_next = yes; then
     INCLUDE_NEXT=include_next
+    INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next
     if test -n "$GCC"; then
       PRAGMA_SYSTEM_HEADER='#pragma GCC system_header'
     fi
   else
-    INCLUDE_NEXT=include
+    if test $gl_cv_have_include_next = buggy; then
+      INCLUDE_NEXT=include
+      INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next
+    else
+      INCLUDE_NEXT=include
+      INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include
+    fi
   fi
   AC_SUBST([INCLUDE_NEXT])
+  AC_SUBST([INCLUDE_NEXT_AS_FIRST_DIRECTIVE])
   AC_SUBST([PRAGMA_SYSTEM_HEADER])
 ])
 

Modified: libprelude/trunk/libmissing/m4/inet_ntop.m4
===================================================================
--- libprelude/trunk/libmissing/m4/inet_ntop.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/inet_ntop.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# inet_ntop.m4 serial 7
-dnl Copyright (C) 2005, 2006, 2008 Free Software Foundation, Inc.
+# inet_ntop.m4 serial 8
+dnl Copyright (C) 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -11,7 +11,7 @@
 
   gl_REPLACE_ARPA_INET_H
 
-  AC_REPLACE_FUNCS(inet_ntop)
+  AC_REPLACE_FUNCS([inet_ntop])
   gl_PREREQ_INET_NTOP
 ])
 

Modified: libprelude/trunk/libmissing/m4/inet_pton.m4
===================================================================
--- libprelude/trunk/libmissing/m4/inet_pton.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/inet_pton.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# inet_pton.m4 serial 6
-dnl Copyright (C) 2006, 2008 Free Software Foundation, Inc.
+# inet_pton.m4 serial 7
+dnl Copyright (C) 2006, 2008, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -11,7 +11,7 @@
 
   gl_REPLACE_ARPA_INET_H
 
-  AC_REPLACE_FUNCS(inet_pton)
+  AC_REPLACE_FUNCS([inet_pton])
   gl_PREREQ_INET_PTON
 ])
 

Modified: libprelude/trunk/libmissing/m4/intmax_t.m4
===================================================================
--- libprelude/trunk/libmissing/m4/intmax_t.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/intmax_t.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,12 +1,12 @@
-# intmax_t.m4 serial 6
-dnl Copyright (C) 1997-2004, 2006-2007 Free Software Foundation, Inc.
+# intmax_t.m4 serial 7
+dnl Copyright (C) 1997-2004, 2006-2007, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
 
 dnl From Paul Eggert.
 
-AC_PREREQ(2.13)
+AC_PREREQ([2.13])
 
 # Define intmax_t to 'long' or 'long long'
 # if it is not already defined in <stdint.h> or <inttypes.h>.
@@ -22,10 +22,10 @@
     test $ac_cv_type_long_long_int = yes \
       && ac_type='long long' \
       || ac_type='long'
-    AC_DEFINE_UNQUOTED(intmax_t, $ac_type,
+    AC_DEFINE_UNQUOTED([intmax_t], [$ac_type],
      [Define to long or long long if <inttypes.h> and <stdint.h> don't define.])
   else
-    AC_DEFINE(HAVE_INTMAX_T, 1,
+    AC_DEFINE([HAVE_INTMAX_T], [1],
       [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.])
   fi
 ])
@@ -36,7 +36,7 @@
 [
   AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
   AC_REQUIRE([gl_AC_HEADER_STDINT_H])
-  AC_CACHE_CHECK(for intmax_t, gt_cv_c_intmax_t,
+  AC_CACHE_CHECK([for intmax_t], [gt_cv_c_intmax_t],
     [AC_TRY_COMPILE([
 #include <stddef.h>
 #include <stdlib.h>
@@ -48,14 +48,14 @@
 #endif
 ], [intmax_t x = -1; return !x;], gt_cv_c_intmax_t=yes, gt_cv_c_intmax_t=no)])
   if test $gt_cv_c_intmax_t = yes; then
-    AC_DEFINE(HAVE_INTMAX_T, 1,
+    AC_DEFINE([HAVE_INTMAX_T], [1],
       [Define if you have the 'intmax_t' type in <stdint.h> or <inttypes.h>.])
   else
     AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
     test $ac_cv_type_long_long_int = yes \
       && ac_type='long long' \
       || ac_type='long'
-    AC_DEFINE_UNQUOTED(intmax_t, $ac_type,
+    AC_DEFINE_UNQUOTED([intmax_t], [$ac_type],
      [Define to long or long long if <stdint.h> and <inttypes.h> don't define.])
   fi
 ])

Modified: libprelude/trunk/libmissing/m4/inttypes_h.m4
===================================================================
--- libprelude/trunk/libmissing/m4/inttypes_h.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/inttypes_h.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# inttypes_h.m4 serial 7
-dnl Copyright (C) 1997-2004, 2006 Free Software Foundation, Inc.
+# inttypes_h.m4 serial 9
+dnl Copyright (C) 1997-2004, 2006, 2008, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -11,15 +11,15 @@
 
 AC_DEFUN([gl_AC_HEADER_INTTYPES_H],
 [
-  AC_CACHE_CHECK([for inttypes.h], gl_cv_header_inttypes_h,
+  AC_CACHE_CHECK([for inttypes.h], [gl_cv_header_inttypes_h],
   [AC_TRY_COMPILE(
     [#include <sys/types.h>
 #include <inttypes.h>],
     [uintmax_t i = (uintmax_t) -1; return !i;],
-    gl_cv_header_inttypes_h=yes,
-    gl_cv_header_inttypes_h=no)])
+    [gl_cv_header_inttypes_h=yes],
+    [gl_cv_header_inttypes_h=no])])
   if test $gl_cv_header_inttypes_h = yes; then
-    AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H_WITH_UINTMAX, 1,
+    AC_DEFINE_UNQUOTED([HAVE_INTTYPES_H_WITH_UINTMAX], [1],
       [Define if <inttypes.h> exists, doesn't clash with <sys/types.h>,
        and declares uintmax_t. ])
   fi

Modified: libprelude/trunk/libmissing/m4/lib-ld.m4
===================================================================
--- libprelude/trunk/libmissing/m4/lib-ld.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/lib-ld.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# lib-ld.m4 serial 3 (gettext-0.13)
-dnl Copyright (C) 1996-2003 Free Software Foundation, Inc.
+# lib-ld.m4 serial 4 (gettext-0.18)
+dnl Copyright (C) 1996-2003, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -10,7 +10,7 @@
 
 dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no.
 AC_DEFUN([AC_LIB_PROG_LD_GNU],
-[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld,
+[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], [acl_cv_prog_gnu_ld],
 [# I'd rather use --version here, but apparently some GNU ld's only accept -v.
 case `$LD -v 2>&1 </dev/null` in
 *GNU* | *'with BFD'*)
@@ -23,7 +23,7 @@
 
 dnl From libtool-1.4. Sets the variable LD.
 AC_DEFUN([AC_LIB_PROG_LD],
-[AC_ARG_WITH(gnu-ld,
+[AC_ARG_WITH([gnu-ld],
 [  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]],
 test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
 AC_REQUIRE([AC_PROG_CC])dnl
@@ -77,7 +77,7 @@
 else
   AC_MSG_CHECKING([for non-GNU ld])
 fi
-AC_CACHE_VAL(acl_cv_path_LD,
+AC_CACHE_VAL([acl_cv_path_LD],
 [if test -z "$LD"; then
   IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
   for ac_dir in $PATH; do
@@ -101,9 +101,9 @@
 fi])
 LD="$acl_cv_path_LD"
 if test -n "$LD"; then
-  AC_MSG_RESULT($LD)
+  AC_MSG_RESULT([$LD])
 else
-  AC_MSG_RESULT(no)
+  AC_MSG_RESULT([no])
 fi
 test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
 AC_LIB_PROG_LD_GNU

Modified: libprelude/trunk/libmissing/m4/lib-link.m4
===================================================================
--- libprelude/trunk/libmissing/m4/lib-link.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/lib-link.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,12 +1,12 @@
-# lib-link.m4 serial 16 (gettext-0.18)
-dnl Copyright (C) 2001-2008 Free Software Foundation, Inc.
+# lib-link.m4 serial 18 (gettext-0.18)
+dnl Copyright (C) 2001-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
 
 dnl From Bruno Haible.
 
-AC_PREREQ(2.54)
+AC_PREREQ([2.54])
 
 dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
 dnl the libraries corresponding to explicit and implicit dependencies.
@@ -114,7 +114,7 @@
   AC_REQUIRE([AC_LIB_PROG_LD])            dnl we use $LD, $with_gnu_ld
   AC_REQUIRE([AC_CANONICAL_HOST])         dnl we use $host
   AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
-  AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [
+  AC_CACHE_CHECK([for shared library run path origin], [acl_cv_rpath], [
     CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
     ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
     . ./conftest.sh
@@ -131,7 +131,7 @@
   acl_hardcode_direct="$acl_cv_hardcode_direct"
   acl_hardcode_minus_L="$acl_cv_hardcode_minus_L"
   dnl Determine whether the user wants rpath handling at all.
-  AC_ARG_ENABLE(rpath,
+  AC_ARG_ENABLE([rpath],
     [  --disable-rpath         do not hardcode runtime library paths],
     :, enable_rpath=yes)
 ])
@@ -446,12 +446,16 @@
             case "$found_dir" in
               */$acl_libdirstem | */$acl_libdirstem/)
                 basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'`
-                LIB[]NAME[]_PREFIX="$basedir"
+                if test "$name" = '$1'; then
+                  LIB[]NAME[]_PREFIX="$basedir"
+                fi
                 additional_includedir="$basedir/include"
                 ;;
               */$acl_libdirstem2 | */$acl_libdirstem2/)
                 basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'`
-                LIB[]NAME[]_PREFIX="$basedir"
+                if test "$name" = '$1'; then
+                  LIB[]NAME[]_PREFIX="$basedir"
+                fi
                 additional_includedir="$basedir/include"
                 ;;
             esac

Modified: libprelude/trunk/libmissing/m4/localcharset.m4
===================================================================
--- libprelude/trunk/libmissing/m4/localcharset.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/localcharset.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# localcharset.m4 serial 5
-dnl Copyright (C) 2002, 2004, 2006 Free Software Foundation, Inc.
+# localcharset.m4 serial 6
+dnl Copyright (C) 2002, 2004, 2006, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -8,7 +8,7 @@
 [
   dnl Prerequisites of lib/localcharset.c.
   AC_REQUIRE([AM_LANGINFO_CODESET])
-  AC_CHECK_DECLS_ONCE(getc_unlocked)
+  AC_CHECK_DECLS_ONCE([getc_unlocked])
 
   dnl Prerequisites of the lib/Makefile.am snippet.
   AC_REQUIRE([AC_CANONICAL_HOST])

Added: libprelude/trunk/libmissing/m4/locale-fr.m4
===================================================================
--- libprelude/trunk/libmissing/m4/locale-fr.m4	                        (rev 0)
+++ libprelude/trunk/libmissing/m4/locale-fr.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,185 @@
+# locale-fr.m4 serial 11
+dnl Copyright (C) 2003, 2005-2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Bruno Haible.
+
+dnl Determine the name of a french locale with traditional encoding.
+AC_DEFUN([gt_LOCALE_FR],
+[
+  AC_REQUIRE([AC_CANONICAL_HOST])
+  AC_REQUIRE([AM_LANGINFO_CODESET])
+  AC_CACHE_CHECK([for a traditional french locale], [gt_cv_locale_fr], [
+    AC_LANG_CONFTEST([AC_LANG_SOURCE([
+changequote(,)dnl
+#include <locale.h>
+#include <time.h>
+#if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+struct tm t;
+char buf[16];
+int main () {
+  /* Check whether the given locale name is recognized by the system.  */
+  if (setlocale (LC_ALL, "") == NULL) return 1;
+  /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
+     On MacOS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
+     is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
+     On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "646". In this situation,
+     some unit tests fail.  */
+#if HAVE_LANGINFO_CODESET
+  {
+    const char *cs = nl_langinfo (CODESET);
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0)
+      return 1;
+  }
+#endif
+#ifdef __CYGWIN__
+  /* On Cygwin, avoid locale names without encoding suffix, because the
+     locale_charset() function relies on the encoding suffix.  Note that
+     LC_ALL is set on the command line.  */
+  if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
+#endif
+  /* Check whether in the abbreviation of the second month, the second
+     character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is only
+     one byte long. This excludes the UTF-8 encoding.  */
+  t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
+  if (strftime (buf, sizeof (buf), "%b", &t) < 3 || buf[2] != 'v') return 1;
+  /* Check whether the decimal separator is a comma.
+     On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
+     are nl_langinfo(RADIXCHAR) are both ".".  */
+  if (localeconv () ->decimal_point[0] != ',') return 1;
+  return 0;
+}
+changequote([,])dnl
+      ])])
+    if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
+      # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
+      # otherwise on MacOS X 10.3.5 the LC_TIME=C from the beginning of the
+      # configure script would override the LC_ALL setting. Likewise for
+      # LC_CTYPE, which is also set at the beginning of the configure script.
+      # Test for the usual locale name.
+      if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+        gt_cv_locale_fr=fr_FR
+      else
+        # Test for the locale name with explicit encoding suffix.
+        if (LC_ALL=fr_FR.ISO-8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+          gt_cv_locale_fr=fr_FR.ISO-8859-1
+        else
+          # Test for the AIX, OSF/1, FreeBSD, NetBSD, OpenBSD locale name.
+          if (LC_ALL=fr_FR.ISO8859-1 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+            gt_cv_locale_fr=fr_FR.ISO8859-1
+          else
+            # Test for the HP-UX locale name.
+            if (LC_ALL=fr_FR.iso88591 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+              gt_cv_locale_fr=fr_FR.iso88591
+            else
+              # Test for the Solaris 7 locale name.
+              if (LC_ALL=fr LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                gt_cv_locale_fr=fr
+              else
+                # None found.
+                gt_cv_locale_fr=none
+              fi
+            fi
+          fi
+        fi
+      fi
+    fi
+    rm -fr conftest*
+  ])
+  LOCALE_FR=$gt_cv_locale_fr
+  AC_SUBST([LOCALE_FR])
+])
+
+dnl Determine the name of a french locale with UTF-8 encoding.
+AC_DEFUN([gt_LOCALE_FR_UTF8],
+[
+  AC_REQUIRE([AM_LANGINFO_CODESET])
+  AC_CACHE_CHECK([for a french Unicode locale], [gt_cv_locale_fr_utf8], [
+    AC_LANG_CONFTEST([AC_LANG_SOURCE([
+changequote(,)dnl
+#include <locale.h>
+#include <time.h>
+#if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+struct tm t;
+char buf[16];
+int main () {
+  /* On BeOS and Haiku, locales are not implemented in libc.  Rather, libintl
+     imitates locale dependent behaviour by looking at the environment
+     variables, and all locales use the UTF-8 encoding.  */
+#if !(defined __BEOS__ || defined __HAIKU__)
+  /* Check whether the given locale name is recognized by the system.  */
+  if (setlocale (LC_ALL, "") == NULL) return 1;
+  /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
+     On MacOS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
+     is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
+     On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "646". In this situation,
+     some unit tests fail.  */
+# if HAVE_LANGINFO_CODESET
+  {
+    const char *cs = nl_langinfo (CODESET);
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0)
+      return 1;
+  }
+# endif
+# ifdef __CYGWIN__
+  /* On Cygwin, avoid locale names without encoding suffix, because the
+     locale_charset() function relies on the encoding suffix.  Note that
+     LC_ALL is set on the command line.  */
+  if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
+# endif
+  /* Check whether in the abbreviation of the second month, the second
+     character (should be U+00E9: LATIN SMALL LETTER E WITH ACUTE) is
+     two bytes long, with UTF-8 encoding.  */
+  t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
+  if (strftime (buf, sizeof (buf), "%b", &t) < 4
+      || buf[1] != (char) 0xc3 || buf[2] != (char) 0xa9 || buf[3] != 'v')
+    return 1;
+#endif
+  /* Check whether the decimal separator is a comma.
+     On NetBSD 3.0 in the fr_FR.ISO8859-1 locale, localeconv()->decimal_point
+     are nl_langinfo(RADIXCHAR) are both ".".  */
+  if (localeconv () ->decimal_point[0] != ',') return 1;
+  return 0;
+}
+changequote([,])dnl
+      ])])
+    if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
+      # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
+      # otherwise on MacOS X 10.3.5 the LC_TIME=C from the beginning of the
+      # configure script would override the LC_ALL setting. Likewise for
+      # LC_CTYPE, which is also set at the beginning of the configure script.
+      # Test for the usual locale name.
+      if (LC_ALL=fr_FR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+        gt_cv_locale_fr_utf8=fr_FR
+      else
+        # Test for the locale name with explicit encoding suffix.
+        if (LC_ALL=fr_FR.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+          gt_cv_locale_fr_utf8=fr_FR.UTF-8
+        else
+          # Test for the Solaris 7 locale name.
+          if (LC_ALL=fr.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+            gt_cv_locale_fr_utf8=fr.UTF-8
+          else
+            # None found.
+            gt_cv_locale_fr_utf8=none
+          fi
+        fi
+      fi
+    fi
+    rm -fr conftest*
+  ])
+  LOCALE_FR_UTF8=$gt_cv_locale_fr_utf8
+  AC_SUBST([LOCALE_FR_UTF8])
+])

Added: libprelude/trunk/libmissing/m4/locale-ja.m4
===================================================================
--- libprelude/trunk/libmissing/m4/locale-ja.m4	                        (rev 0)
+++ libprelude/trunk/libmissing/m4/locale-ja.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,107 @@
+# locale-ja.m4 serial 7
+dnl Copyright (C) 2003, 2005-2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Bruno Haible.
+
+dnl Determine the name of a japanese locale with EUC-JP encoding.
+AC_DEFUN([gt_LOCALE_JA],
+[
+  AC_REQUIRE([AC_CANONICAL_HOST])
+  AC_REQUIRE([AM_LANGINFO_CODESET])
+  AC_CACHE_CHECK([for a traditional japanese locale], [gt_cv_locale_ja], [
+    AC_LANG_CONFTEST([AC_LANG_SOURCE([
+changequote(,)dnl
+#include <locale.h>
+#include <time.h>
+#if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+struct tm t;
+char buf[16];
+int main ()
+{
+  const char *p;
+  /* Check whether the given locale name is recognized by the system.  */
+  if (setlocale (LC_ALL, "") == NULL) return 1;
+  /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
+     On MacOS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
+     is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
+     On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "646". In this situation,
+     some unit tests fail.  */
+#if HAVE_LANGINFO_CODESET
+  {
+    const char *cs = nl_langinfo (CODESET);
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0)
+      return 1;
+  }
+#endif
+#ifdef __CYGWIN__
+  /* On Cygwin, avoid locale names without encoding suffix, because the
+     locale_charset() function relies on the encoding suffix.  Note that
+     LC_ALL is set on the command line.  */
+  if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
+#endif
+  /* Check whether MB_CUR_MAX is > 1.  This excludes the dysfunctional locales
+     on Cygwin 1.5.x.  */
+  if (MB_CUR_MAX == 1)
+    return 1;
+  /* Check whether in a month name, no byte in the range 0x80..0x9F occurs.
+     This excludes the UTF-8 encoding.  */
+  t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
+  if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1;
+  for (p = buf; *p != '\0'; p++)
+    if ((unsigned char) *p >= 0x80 && (unsigned char) *p < 0xa0)
+      return 1;
+  return 0;
+}
+changequote([,])dnl
+      ])])
+    if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
+      # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
+      # otherwise on MacOS X 10.3.5 the LC_TIME=C from the beginning of the
+      # configure script would override the LC_ALL setting. Likewise for
+      # LC_CTYPE, which is also set at the beginning of the configure script.
+      # Test for the AIX locale name.
+      if (LC_ALL=ja_JP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+        gt_cv_locale_ja=ja_JP
+      else
+        # Test for the locale name with explicit encoding suffix.
+        if (LC_ALL=ja_JP.EUC-JP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+          gt_cv_locale_ja=ja_JP.EUC-JP
+        else
+          # Test for the HP-UX, OSF/1, NetBSD locale name.
+          if (LC_ALL=ja_JP.eucJP LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+            gt_cv_locale_ja=ja_JP.eucJP
+          else
+            # Test for the IRIX, FreeBSD locale name.
+            if (LC_ALL=ja_JP.EUC LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+              gt_cv_locale_ja=ja_JP.EUC
+            else
+              # Test for the Solaris 7 locale name.
+              if (LC_ALL=ja LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                gt_cv_locale_ja=ja
+              else
+                # Special test for NetBSD 1.6.
+                if test -f /usr/share/locale/ja_JP.eucJP/LC_CTYPE; then
+                  gt_cv_locale_ja=ja_JP.eucJP
+                else
+                  # None found.
+                  gt_cv_locale_ja=none
+                fi
+              fi
+            fi
+          fi
+        fi
+      fi
+    fi
+    rm -fr conftest*
+  ])
+  LOCALE_JA=$gt_cv_locale_ja
+  AC_SUBST([LOCALE_JA])
+])

Added: libprelude/trunk/libmissing/m4/locale-zh.m4
===================================================================
--- libprelude/trunk/libmissing/m4/locale-zh.m4	                        (rev 0)
+++ libprelude/trunk/libmissing/m4/locale-zh.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,92 @@
+# locale-zh.m4 serial 6
+dnl Copyright (C) 2003, 2005-2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Bruno Haible.
+
+dnl Determine the name of a chinese locale with GB18030 encoding.
+AC_DEFUN([gt_LOCALE_ZH_CN],
+[
+  AC_REQUIRE([AC_CANONICAL_HOST])
+  AC_REQUIRE([AM_LANGINFO_CODESET])
+  AC_CACHE_CHECK([for a transitional chinese locale], [gt_cv_locale_zh_CN], [
+    AC_LANG_CONFTEST([AC_LANG_SOURCE([
+changequote(,)dnl
+#include <locale.h>
+#include <stdlib.h>
+#include <time.h>
+#if HAVE_LANGINFO_CODESET
+# include <langinfo.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+struct tm t;
+char buf[16];
+int main ()
+{
+  const char *p;
+  /* Check whether the given locale name is recognized by the system.  */
+  if (setlocale (LC_ALL, "") == NULL) return 1;
+  /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
+     On MacOS X 10.3.5 (Darwin 7.5) in the fr_FR locale, nl_langinfo(CODESET)
+     is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
+     On OpenBSD 4.0, when an unsupported locale is specified, setlocale()
+     succeeds but then nl_langinfo(CODESET) is "646". In this situation,
+     some unit tests fail.  */
+#if HAVE_LANGINFO_CODESET
+  {
+    const char *cs = nl_langinfo (CODESET);
+    if (cs[0] == '\0' || strcmp (cs, "ASCII") == 0 || strcmp (cs, "646") == 0)
+      return 1;
+  }
+#endif
+#ifdef __CYGWIN__
+  /* On Cygwin, avoid locale names without encoding suffix, because the
+     locale_charset() function relies on the encoding suffix.  Note that
+     LC_ALL is set on the command line.  */
+  if (strchr (getenv ("LC_ALL"), '.') == NULL) return 1;
+#endif
+  /* Check whether in a month name, no byte in the range 0x80..0x9F occurs.
+     This excludes the UTF-8 encoding.  */
+  t.tm_year = 1975 - 1900; t.tm_mon = 2 - 1; t.tm_mday = 4;
+  if (strftime (buf, sizeof (buf), "%B", &t) < 2) return 1;
+  for (p = buf; *p != '\0'; p++)
+    if ((unsigned char) *p >= 0x80 && (unsigned char) *p < 0xa0)
+      return 1;
+  /* Check whether a typical GB18030 multibyte sequence is recognized as a
+     single wide character.  This excludes the GB2312 and GBK encodings.  */
+  if (mblen ("\203\062\332\066", 5) != 4)
+    return 1;
+  return 0;
+}
+changequote([,])dnl
+      ])])
+    if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
+      # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
+      # otherwise on MacOS X 10.3.5 the LC_TIME=C from the beginning of the
+      # configure script would override the LC_ALL setting. Likewise for
+      # LC_CTYPE, which is also set at the beginning of the configure script.
+      # Test for the locale name without encoding suffix.
+      if (LC_ALL=zh_CN LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+        gt_cv_locale_zh_CN=zh_CN
+      else
+        # Test for the locale name with explicit encoding suffix.
+        if (LC_ALL=zh_CN.GB18030 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+          gt_cv_locale_zh_CN=zh_CN.GB18030
+        else
+          # None found.
+          gt_cv_locale_zh_CN=none
+        fi
+      fi
+    else
+      # If there was a link error, due to mblen(), the system is so old that
+      # it certainly doesn't have a chinese locale.
+      gt_cv_locale_zh_CN=none
+    fi
+    rm -fr conftest*
+  ])
+  LOCALE_ZH_CN=$gt_cv_locale_zh_CN
+  AC_SUBST([LOCALE_ZH_CN])
+])

Modified: libprelude/trunk/libmissing/m4/lock.m4
===================================================================
--- libprelude/trunk/libmissing/m4/lock.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/lock.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# lock.m4 serial 9 (gettext-0.18)
-dnl Copyright (C) 2005-2008 Free Software Foundation, Inc.
+# lock.m4 serial 10 (gettext-0.18)
+dnl Copyright (C) 2005-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -13,7 +13,7 @@
     # 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,
+      [AC_DEFINE([HAVE_PTHREAD_RWLOCK], [1],
          [Define if the POSIX multithreading library has read/write locks.])],
       [],
       [#include <pthread.h>])
@@ -25,7 +25,7 @@
 int x = (int)PTHREAD_MUTEX_RECURSIVE;
 return !x;
 #endif],
-      [AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE], 1,
+      [AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE], [1],
          [Define if the <pthread.h> defines PTHREAD_MUTEX_RECURSIVE.])])
   fi
   gl_PREREQ_LOCK

Modified: libprelude/trunk/libmissing/m4/longlong.m4
===================================================================
--- libprelude/trunk/libmissing/m4/longlong.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/longlong.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# longlong.m4 serial 13
-dnl Copyright (C) 1999-2007 Free Software Foundation, Inc.
+# longlong.m4 serial 14
+dnl Copyright (C) 1999-2007, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -46,7 +46,7 @@
 	  [ac_cv_type_long_long_int=yes])],
        [ac_cv_type_long_long_int=no])])
   if test $ac_cv_type_long_long_int = yes; then
-    AC_DEFINE([HAVE_LONG_LONG_INT], 1,
+    AC_DEFINE([HAVE_LONG_LONG_INT], [1],
       [Define to 1 if the system has the type `long long int'.])
   fi
 ])
@@ -69,7 +69,7 @@
        [ac_cv_type_unsigned_long_long_int=yes],
        [ac_cv_type_unsigned_long_long_int=no])])
   if test $ac_cv_type_unsigned_long_long_int = yes; then
-    AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], 1,
+    AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], [1],
       [Define to 1 if the system has the type `unsigned long long int'.])
   fi
 ])

Modified: libprelude/trunk/libmissing/m4/malloc.m4
===================================================================
--- libprelude/trunk/libmissing/m4/malloc.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/malloc.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# malloc.m4 serial 8
-dnl Copyright (C) 2007 Free Software Foundation, Inc.
+# malloc.m4 serial 9
+dnl Copyright (C) 2007, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -13,7 +13,7 @@
   AC_REQUIRE([gl_CHECK_MALLOC_POSIX])
   if test $gl_cv_func_malloc_posix = yes; then
     HAVE_MALLOC_POSIX=1
-    AC_DEFINE([HAVE_MALLOC_POSIX], 1,
+    AC_DEFINE([HAVE_MALLOC_POSIX], [1],
       [Define if the 'malloc' function is POSIX compliant.])
   else
     AC_LIBOBJ([malloc])

Added: libprelude/trunk/libmissing/m4/mbrtowc.m4
===================================================================
--- libprelude/trunk/libmissing/m4/mbrtowc.m4	                        (rev 0)
+++ libprelude/trunk/libmissing/m4/mbrtowc.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,382 @@
+# mbrtowc.m4 serial 14
+dnl Copyright (C) 2001-2002, 2004-2005, 2008, 2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_MBRTOWC],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+
+  AC_REQUIRE([AC_TYPE_MBSTATE_T])
+  gl_MBSTATE_T_BROKEN
+  if test $REPLACE_MBSTATE_T = 1; then
+    REPLACE_MBRTOWC=1
+  fi
+  AC_CHECK_FUNCS_ONCE([mbrtowc])
+  if test $ac_cv_func_mbrtowc = no; then
+    HAVE_MBRTOWC=0
+  fi
+  if test $HAVE_MBRTOWC != 0 && test $REPLACE_MBRTOWC != 1; then
+    gl_MBRTOWC_NULL_ARG
+    gl_MBRTOWC_RETVAL
+    gl_MBRTOWC_NUL_RETVAL
+    case "$gl_cv_func_mbrtowc_null_arg" in
+      *yes) ;;
+      *) AC_DEFINE([MBRTOWC_NULL_ARG_BUG], [1],
+           [Define if the mbrtowc function has the NULL string argument bug.])
+         REPLACE_MBRTOWC=1
+         ;;
+    esac
+    case "$gl_cv_func_mbrtowc_retval" in
+      *yes) ;;
+      *) AC_DEFINE([MBRTOWC_RETVAL_BUG], [1],
+           [Define if the mbrtowc function returns a wrong return value.])
+         REPLACE_MBRTOWC=1
+         ;;
+    esac
+    case "$gl_cv_func_mbrtowc_nul_retval" in
+      *yes) ;;
+      *) AC_DEFINE([MBRTOWC_NUL_RETVAL_BUG], [1],
+           [Define if the mbrtowc function does not return 0 for a NUL character.])
+         REPLACE_MBRTOWC=1
+         ;;
+    esac
+  fi
+  if test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1; then
+    gl_REPLACE_WCHAR_H
+    AC_LIBOBJ([mbrtowc])
+    gl_PREREQ_MBRTOWC
+  fi
+])
+
+dnl Test whether mbsinit() and mbrtowc() need to be overridden in a way that
+dnl redefines the semantics of the given mbstate_t type.
+dnl Result is REPLACE_MBSTATE_T.
+dnl When this is set to 1, we replace both mbsinit() and mbrtowc(), in order to
+dnl avoid inconsistencies.
+
+AC_DEFUN([gl_MBSTATE_T_BROKEN],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+
+  AC_REQUIRE([AC_TYPE_MBSTATE_T])
+  AC_CHECK_FUNCS_ONCE([mbsinit])
+  AC_CHECK_FUNCS_ONCE([mbrtowc])
+  if test $ac_cv_func_mbsinit = yes && test $ac_cv_func_mbrtowc = yes; then
+    gl_MBRTOWC_INCOMPLETE_STATE
+    gl_MBRTOWC_SANITYCHECK
+    REPLACE_MBSTATE_T=0
+    case "$gl_cv_func_mbrtowc_incomplete_state" in
+      *yes) ;;
+      *) REPLACE_MBSTATE_T=1 ;;
+    esac
+    case "$gl_cv_func_mbrtowc_sanitycheck" in
+      *yes) ;;
+      *) REPLACE_MBSTATE_T=1 ;;
+    esac
+  else
+    REPLACE_MBSTATE_T=1
+  fi
+  if test $REPLACE_MBSTATE_T = 1; then
+    gl_REPLACE_WCHAR_H
+  fi
+])
+
+dnl Test whether mbrtowc puts the state into non-initial state when parsing an
+dnl incomplete multibyte character.
+dnl Result is gl_cv_func_mbrtowc_incomplete_state.
+
+AC_DEFUN([gl_MBRTOWC_INCOMPLETE_STATE],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([gt_LOCALE_JA])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CACHE_CHECK([whether mbrtowc handles incomplete characters],
+    [gl_cv_func_mbrtowc_incomplete_state],
+    [
+      dnl Initial guess, used when cross-compiling or when no suitable locale
+      dnl is present.
+changequote(,)dnl
+      case "$host_os" in
+              # Guess no on AIX and OSF/1.
+        osf*) gl_cv_func_mbrtowc_incomplete_state="guessing no" ;;
+              # Guess yes otherwise.
+        *)    gl_cv_func_mbrtowc_incomplete_state="guessing yes" ;;
+      esac
+changequote([,])dnl
+      if test $LOCALE_JA != none; then
+        AC_TRY_RUN([
+#include <locale.h>
+#include <string.h>
+#include <wchar.h>
+int main ()
+{
+  if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
+    {
+      const char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */
+      mbstate_t state;
+      wchar_t wc;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2))
+        if (mbsinit (&state))
+          return 1;
+    }
+  return 0;
+}],
+          [gl_cv_func_mbrtowc_incomplete_state=yes],
+          [gl_cv_func_mbrtowc_incomplete_state=no],
+          [])
+      fi
+    ])
+])
+
+dnl Test whether mbrtowc works not worse than mbtowc.
+dnl Result is gl_cv_func_mbrtowc_sanitycheck.
+
+AC_DEFUN([gl_MBRTOWC_SANITYCHECK],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([gt_LOCALE_ZH_CN])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CACHE_CHECK([whether mbrtowc works as well as mbtowc],
+    [gl_cv_func_mbrtowc_sanitycheck],
+    [
+      dnl Initial guess, used when cross-compiling or when no suitable locale
+      dnl is present.
+changequote(,)dnl
+      case "$host_os" in
+                    # Guess no on Solaris 8.
+        solaris2.8) gl_cv_func_mbrtowc_sanitycheck="guessing no" ;;
+                    # Guess yes otherwise.
+        *)          gl_cv_func_mbrtowc_sanitycheck="guessing yes" ;;
+      esac
+changequote([,])dnl
+      if test $LOCALE_ZH_CN != none; then
+        AC_TRY_RUN([
+#include <locale.h>
+#include <string.h>
+#include <wchar.h>
+int main ()
+{
+  /* This fails on Solaris 8:
+     mbrtowc returns 2, and sets wc to 0x00F0.
+     mbtowc returns 4 (correct) and sets wc to 0x5EDC.  */
+  if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
+    {
+      char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */
+      mbstate_t state;
+      wchar_t wc;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      if (mbrtowc (&wc, input + 3, 6, &state) != 4
+          && mbtowc (&wc, input + 3, 6) == 4)
+        return 1;
+    }
+  return 0;
+}],
+          [gl_cv_func_mbrtowc_sanitycheck=yes],
+          [gl_cv_func_mbrtowc_sanitycheck=no],
+          [])
+      fi
+    ])
+])
+
+dnl Test whether mbrtowc supports a NULL string argument correctly.
+dnl Result is gl_cv_func_mbrtowc_null_arg.
+
+AC_DEFUN([gl_MBRTOWC_NULL_ARG],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([gt_LOCALE_FR_UTF8])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CACHE_CHECK([whether mbrtowc handles a NULL string argument],
+    [gl_cv_func_mbrtowc_null_arg],
+    [
+      dnl Initial guess, used when cross-compiling or when no suitable locale
+      dnl is present.
+changequote(,)dnl
+      case "$host_os" in
+              # Guess no on OSF/1.
+        osf*) gl_cv_func_mbrtowc_null_arg="guessing no" ;;
+              # Guess yes otherwise.
+        *)    gl_cv_func_mbrtowc_null_arg="guessing yes" ;;
+      esac
+changequote([,])dnl
+      if test $LOCALE_FR_UTF8 != none; then
+        AC_TRY_RUN([
+#include <locale.h>
+#include <string.h>
+#include <wchar.h>
+int main ()
+{
+  if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
+    {
+      mbstate_t state;
+      wchar_t wc;
+      int ret;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      wc = (wchar_t) 0xBADFACE;
+      mbrtowc (&wc, NULL, 5, &state);
+      /* Check that wc was not modified.  */
+      if (wc != (wchar_t) 0xBADFACE)
+        return 1;
+    }
+  return 0;
+}], [gl_cv_func_mbrtowc_null_arg=yes], [gl_cv_func_mbrtowc_null_arg=no], [])
+      fi
+    ])
+])
+
+dnl Test whether mbrtowc, when parsing the end of a multibyte character,
+dnl correctly returns the number of bytes that were needed to complete the
+dnl character (not the total number of bytes of the multibyte character).
+dnl Result is gl_cv_func_mbrtowc_retval.
+
+AC_DEFUN([gl_MBRTOWC_RETVAL],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([gt_LOCALE_FR_UTF8])
+  AC_REQUIRE([gt_LOCALE_JA])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CACHE_CHECK([whether mbrtowc has a correct return value],
+    [gl_cv_func_mbrtowc_retval],
+    [
+      dnl Initial guess, used when cross-compiling or when no suitable locale
+      dnl is present.
+changequote(,)dnl
+      case "$host_os" in
+                          # Guess no on HP-UX and Solaris.
+        hpux* | solaris*) gl_cv_func_mbrtowc_retval="guessing no" ;;
+                          # Guess yes otherwise.
+        *)                gl_cv_func_mbrtowc_retval="guessing yes" ;;
+      esac
+changequote([,])dnl
+      if test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none; then
+        AC_TRY_RUN([
+#include <locale.h>
+#include <string.h>
+#include <wchar.h>
+int main ()
+{
+  /* This fails on Solaris.  */
+  if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
+    {
+      char input[] = "B\303\274\303\237er"; /* "Büßer" */
+      mbstate_t state;
+      wchar_t wc;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2))
+        {
+          input[1] = '\0';
+          if (mbrtowc (&wc, input + 2, 5, &state) != 1)
+            return 1;
+        }
+    }
+  /* This fails on HP-UX 11.11.  */
+  if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
+    {
+      char input[] = "B\217\253\344\217\251\316er"; /* "Büßer" */
+      mbstate_t state;
+      wchar_t wc;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      if (mbrtowc (&wc, input + 1, 1, &state) == (size_t)(-2))
+        {
+          input[1] = '\0';
+          if (mbrtowc (&wc, input + 2, 5, &state) != 2)
+            return 1;
+        }
+    }
+  return 0;
+}],
+          [gl_cv_func_mbrtowc_retval=yes],
+          [gl_cv_func_mbrtowc_retval=no],
+          [])
+      fi
+    ])
+])
+
+dnl Test whether mbrtowc, when parsing a NUL character, correctly returns 0.
+dnl Result is gl_cv_func_mbrtowc_nul_retval.
+
+AC_DEFUN([gl_MBRTOWC_NUL_RETVAL],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([gt_LOCALE_ZH_CN])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CACHE_CHECK([whether mbrtowc returns 0 when parsing a NUL character],
+    [gl_cv_func_mbrtowc_nul_retval],
+    [
+      dnl Initial guess, used when cross-compiling or when no suitable locale
+      dnl is present.
+changequote(,)dnl
+      case "$host_os" in
+                       # Guess no on Solaris 8 and 9.
+        solaris2.[89]) gl_cv_func_mbrtowc_nul_retval="guessing no" ;;
+                       # Guess yes otherwise.
+        *)             gl_cv_func_mbrtowc_nul_retval="guessing yes" ;;
+      esac
+changequote([,])dnl
+      if test $LOCALE_ZH_CN != none; then
+        AC_TRY_RUN([
+#include <locale.h>
+#include <string.h>
+#include <wchar.h>
+int main ()
+{
+  /* This fails on Solaris 8 and 9.  */
+  if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
+    {
+      mbstate_t state;
+      wchar_t wc;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      if (mbrtowc (&wc, "", 1, &state) != 0)
+        return 1;
+    }
+  return 0;
+}],
+          [gl_cv_func_mbrtowc_nul_retval=yes],
+          [gl_cv_func_mbrtowc_nul_retval=no],
+          [])
+      fi
+    ])
+])
+
+# Prerequisites of lib/mbrtowc.c.
+AC_DEFUN([gl_PREREQ_MBRTOWC], [
+  :
+])
+
+
+dnl From Paul Eggert
+
+dnl This override of an autoconf macro can be removed when autoconf 2.60 or
+dnl newer can be assumed everywhere.
+
+m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.60]),[-1],[
+AC_DEFUN([AC_FUNC_MBRTOWC],
+[
+  dnl Same as AC_FUNC_MBRTOWC in autoconf-2.60.
+  AC_CACHE_CHECK([whether mbrtowc and mbstate_t are properly declared],
+    gl_cv_func_mbrtowc,
+    [AC_LINK_IFELSE(
+       [AC_LANG_PROGRAM(
+            [[#include <wchar.h>]],
+            [[wchar_t wc;
+              char const s[] = "";
+              size_t n = 1;
+              mbstate_t state;
+              return ! (sizeof state && (mbrtowc) (&wc, s, n, &state));]])],
+       gl_cv_func_mbrtowc=yes,
+       gl_cv_func_mbrtowc=no)])
+  if test $gl_cv_func_mbrtowc = yes; then
+    AC_DEFINE([HAVE_MBRTOWC], [1],
+      [Define to 1 if mbrtowc and mbstate_t are properly declared.])
+  fi
+])
+])

Added: libprelude/trunk/libmissing/m4/mbsinit.m4
===================================================================
--- libprelude/trunk/libmissing/m4/mbsinit.m4	                        (rev 0)
+++ libprelude/trunk/libmissing/m4/mbsinit.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,30 @@
+# mbsinit.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_FUNC_MBSINIT],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+
+  AC_REQUIRE([AC_TYPE_MBSTATE_T])
+  gl_MBSTATE_T_BROKEN
+  if test $REPLACE_MBSTATE_T = 1; then
+    REPLACE_MBSINIT=1
+  fi
+  AC_CHECK_FUNCS_ONCE([mbsinit])
+  if test $ac_cv_func_mbsinit = no; then
+    HAVE_MBSINIT=0
+  fi
+  if test $HAVE_MBSINIT = 0 || test $REPLACE_MBSINIT = 1; then
+    gl_REPLACE_WCHAR_H
+    AC_LIBOBJ([mbsinit])
+    gl_PREREQ_MBSINIT
+  fi
+])
+
+# Prerequisites of lib/mbsinit.c.
+AC_DEFUN([gl_PREREQ_MBSINIT], [
+  :
+])

Modified: libprelude/trunk/libmissing/m4/mbstate_t.m4
===================================================================
--- libprelude/trunk/libmissing/m4/mbstate_t.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/mbstate_t.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# mbstate_t.m4 serial 10
-dnl Copyright (C) 2000-2002, 2008 Free Software Foundation, Inc.
+# mbstate_t.m4 serial 12
+dnl Copyright (C) 2000-2002, 2008, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -13,7 +13,10 @@
 # AC_TYPE_MBSTATE_T
 # -----------------
 AC_DEFUN([AC_TYPE_MBSTATE_T],
-  [AC_CACHE_CHECK([for mbstate_t], ac_cv_type_mbstate_t,
+[
+   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) dnl for HP-UX 11.11
+
+   AC_CACHE_CHECK([for mbstate_t], [ac_cv_type_mbstate_t],
      [AC_COMPILE_IFELSE(
 	[AC_LANG_PROGRAM(
 	   [AC_INCLUDES_DEFAULT[
@@ -22,9 +25,10 @@
 	[ac_cv_type_mbstate_t=yes],
 	[ac_cv_type_mbstate_t=no])])
    if test $ac_cv_type_mbstate_t = yes; then
-     AC_DEFINE([HAVE_MBSTATE_T], 1,
+     AC_DEFINE([HAVE_MBSTATE_T], [1],
 	       [Define to 1 if <wchar.h> declares mbstate_t.])
    else
-     AC_DEFINE([mbstate_t], int,
+     AC_DEFINE([mbstate_t], [int],
 	       [Define to a type if <wchar.h> does not define.])
-   fi])
+   fi
+])

Modified: libprelude/trunk/libmissing/m4/memmem.m4
===================================================================
--- libprelude/trunk/libmissing/m4/memmem.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/memmem.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# memmem.m4 serial 13
-dnl Copyright (C) 2002, 2003, 2004, 2007, 2008 Free Software Foundation, Inc.
+# memmem.m4 serial 14
+dnl Copyright (C) 2002, 2003, 2004, 2007, 2008, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -11,8 +11,8 @@
   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
 
   AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
-  AC_REPLACE_FUNCS(memmem)
-  AC_CHECK_DECLS_ONCE(memmem)
+  AC_REPLACE_FUNCS([memmem])
+  AC_CHECK_DECLS_ONCE([memmem])
   if test $ac_cv_have_decl_memmem = no; then
     HAVE_DECL_MEMMEM=0
   fi

Modified: libprelude/trunk/libmissing/m4/minmax.m4
===================================================================
--- libprelude/trunk/libmissing/m4/minmax.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/minmax.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,10 +1,10 @@
-# minmax.m4 serial 2
-dnl Copyright (C) 2005 Free Software Foundation, Inc.
+# minmax.m4 serial 3
+dnl Copyright (C) 2005, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
 
-AC_PREREQ(2.52)
+AC_PREREQ([2.52])
 
 AC_DEFUN([gl_MINMAX],
 [

Modified: libprelude/trunk/libmissing/m4/mktime.m4
===================================================================
--- libprelude/trunk/libmissing/m4/mktime.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/mktime.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-#serial 13
-dnl Copyright (C) 2002, 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
+# serial 15
+dnl Copyright (C) 2002-2003, 2005-2007, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -13,9 +13,16 @@
 # AC_FUNC_MKTIME
 # --------------
 AC_DEFUN([AC_FUNC_MKTIME],
-[AC_CHECK_HEADERS_ONCE(unistd.h)
-AC_CHECK_FUNCS_ONCE(alarm)
-AC_CACHE_CHECK([for working mktime], ac_cv_func_working_mktime,
+[AC_CHECK_HEADERS_ONCE([unistd.h])
+AC_CHECK_FUNCS_ONCE([alarm])
+AC_REQUIRE([gl_MULTIARCH])
+if test $APPLE_UNIVERSAL_BUILD = 1; then
+  # A universal build on Apple MacOS X platforms.
+  # The test result would be 'yes' in 32-bit mode and 'no' in 64-bit mode.
+  # But we need a configuration result that is valid in both modes.
+  ac_cv_func_working_mktime=no
+fi
+AC_CACHE_CHECK([for working mktime], [ac_cv_func_working_mktime],
 [AC_RUN_IFELSE([AC_LANG_SOURCE(
 [[/* Test program from Paul Eggert and Tony Leneis.  */
 #include <limits.h>
@@ -68,16 +75,14 @@
 }
 
 static int
-mktime_test1 (now)
-     time_t now;
+mktime_test1 (time_t now)
 {
   struct tm *lt;
   return ! (lt = localtime (&now)) || mktime (lt) == now;
 }
 
 static int
-mktime_test (now)
-     time_t now;
+mktime_test (time_t now)
 {
   return (mktime_test1 (now)
 	  && mktime_test1 ((time_t) (time_t_max - now))
@@ -101,8 +106,7 @@
 }
 
 static int
-bigtime_test (j)
-     int j;
+bigtime_test (int j)
 {
   struct tm tm;
   time_t now;
@@ -212,9 +216,9 @@
 AC_DEFUN([gl_FUNC_MKTIME],
 [
   AC_FUNC_MKTIME
-  dnl Note: AC_FUNC_MKTIME does AC_LIBOBJ(mktime).
+  dnl Note: AC_FUNC_MKTIME does AC_LIBOBJ([mktime]).
   if test $ac_cv_func_working_mktime = no; then
-    AC_DEFINE(mktime, rpl_mktime,
+    AC_DEFINE([mktime], [rpl_mktime],
       [Define to rpl_mktime if the replacement function should be used.])
     gl_PREREQ_MKTIME
   fi

Added: libprelude/trunk/libmissing/m4/multiarch.m4
===================================================================
--- libprelude/trunk/libmissing/m4/multiarch.m4	                        (rev 0)
+++ libprelude/trunk/libmissing/m4/multiarch.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,66 @@
+# multiarch.m4 serial 4
+dnl Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+# Determine whether the compiler is or may be producing universal binaries.
+#
+# On MacOS X 10.5 and later systems, the user can create libraries and
+# executables that work on multiple system types--known as "fat" or
+# "universal" binaries--by specifying multiple '-arch' options to the
+# compiler but only a single '-arch' option to the preprocessor.  Like
+# this:
+#
+#     ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+#                 CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+#                 CPP="gcc -E" CXXCPP="g++ -E"
+#
+# Detect this situation and set the macro AA_APPLE_UNIVERSAL_BUILD at the
+# beginning of config.h and set APPLE_UNIVERSAL_BUILD accordingly.
+
+dnl This macro must pass through AC_REQUIRE (never directly invoke it).
+AC_DEFUN_ONCE([gl_MULTIARCH],
+[
+  dnl Code similar to autoconf-2.63 AC_C_BIGENDIAN.
+  gl_cv_c_multiarch=no
+  AC_COMPILE_IFELSE(
+    [AC_LANG_SOURCE(
+      [[#ifndef __APPLE_CC__
+         not a universal capable compiler
+        #endif
+        typedef int dummy;
+      ]])],
+    [
+     dnl Check for potential -arch flags.  It is not universal unless
+     dnl there are at least two -arch flags with different values.
+     arch=
+     prev=
+     for word in ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}; do
+       if test -n "$prev"; then
+         case $word in
+           i?86 | x86_64 | ppc | ppc64)
+             if test -z "$arch" || test "$arch" = "$word"; then
+               arch="$word"
+             else
+               gl_cv_c_multiarch=yes
+             fi
+             ;;
+         esac
+         prev=
+       else
+         if test "x$word" = "x-arch"; then
+           prev=arch
+         fi
+       fi
+     done
+    ])
+  if test $gl_cv_c_multiarch = yes; then
+    AC_DEFINE([AA_APPLE_UNIVERSAL_BUILD], [1],
+      [Define if the compiler is building for multiple architectures of Apple platforms at once.])
+    APPLE_UNIVERSAL_BUILD=1
+  else
+    APPLE_UNIVERSAL_BUILD=0
+  fi
+  AC_SUBST([APPLE_UNIVERSAL_BUILD])
+])

Modified: libprelude/trunk/libmissing/m4/netdb_h.m4
===================================================================
--- libprelude/trunk/libmissing/m4/netdb_h.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/netdb_h.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,4 +1,4 @@
-# netdb_h.m4 serial 4
+# netdb_h.m4 serial 5
 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,
@@ -9,8 +9,14 @@
   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>]])
+    AC_COMPILE_IFELSE(
+      [AC_LANG_PROGRAM([[
+         #include <netdb.h>
+         struct addrinfo a;
+         int b = EAI_OVERFLOW;
+         int c = AI_NUMERICSERV;
+       ]])],
+      [NETDB_H=''], [NETDB_H='netdb.h'])
     HAVE_NETDB_H=1
   else
     NETDB_H='netdb.h'

Modified: libprelude/trunk/libmissing/m4/pathmax.m4
===================================================================
--- libprelude/trunk/libmissing/m4/pathmax.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/pathmax.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# pathmax.m4 serial 6
-dnl Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc.
+# pathmax.m4 serial 8
+dnl Copyright (C) 2002, 2003, 2005, 2006, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -7,5 +7,6 @@
 AC_DEFUN([gl_PATHMAX],
 [
   dnl Prerequisites of lib/pathmax.h.
-  AC_CHECK_HEADERS_ONCE(sys/param.h)
+  AC_CHECK_FUNCS_ONCE([pathconf])
+  AC_CHECK_HEADERS_ONCE([sys/param.h])
 ])

Modified: libprelude/trunk/libmissing/m4/poll.m4
===================================================================
--- libprelude/trunk/libmissing/m4/poll.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/poll.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,16 +1,16 @@
-# poll.m4 serial 7
-dnl Copyright (c) 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
+# poll.m4 serial 8
+dnl Copyright (c) 2003, 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
 
 AC_DEFUN([gl_FUNC_POLL],
 [
-  AC_CHECK_HEADERS(poll.h)
+  AC_CHECK_HEADERS([poll.h])
   if test "$ac_cv_header_poll_h" = no; then
     gl_cv_func_poll=no
   else
-    AC_CHECK_FUNC(poll,
+    AC_CHECK_FUNC([poll],
       [# Check whether poll() works on special files (like /dev/null) and
        # and ttys (like /dev/tty). On MacOS X 10.4.0 and AIX 5.3, it doesn't.
        AC_TRY_RUN([
@@ -51,12 +51,12 @@
 ], [gl_cv_func_poll=no], [gl_cv_func_poll=yes])])])
   fi
   if test $gl_cv_func_poll = yes; then
-    AC_DEFINE([HAVE_POLL], 1,
+    AC_DEFINE([HAVE_POLL], [1],
       [Define to 1 if you have the 'poll' function and it works.])
     POLL_H=
   else
-    AC_LIBOBJ(poll)
-    AC_DEFINE(poll, rpl_poll,
+    AC_LIBOBJ([poll])
+    AC_DEFINE([poll], [rpl_poll],
       [Define to poll if the replacement function should be used.])
     gl_PREREQ_POLL
     POLL_H=poll.h
@@ -67,5 +67,5 @@
 # Prerequisites of lib/poll.c.
 AC_DEFUN([gl_PREREQ_POLL],
 [
-  AC_CHECK_HEADERS_ONCE(sys/ioctl.h sys/filio.h)
+  AC_CHECK_HEADERS_ONCE([sys/ioctl.h sys/filio.h])
 ])

Modified: libprelude/trunk/libmissing/m4/printf.m4
===================================================================
--- libprelude/trunk/libmissing/m4/printf.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/printf.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# printf.m4 serial 24
-dnl Copyright (C) 2003, 2007-2008 Free Software Foundation, Inc.
+# printf.m4 serial 33
+dnl Copyright (C) 2003, 2007-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -125,7 +125,8 @@
 ])
 
 dnl Test whether the *printf family of functions supports infinite and NaN
-dnl 'double' arguments in the %f, %e, %g directives. (ISO C99, POSIX:2001)
+dnl 'double' arguments and negative zero arguments in the %f, %e, %g
+dnl directives. (ISO C99, POSIX:2001)
 dnl Result is gl_cv_func_printf_infinite.
 
 AC_DEFUN([gl_PRINTF_INFINITE],
@@ -156,6 +157,13 @@
     }
   return 0;
 }
+static int
+have_minus_zero ()
+{
+  static double plus_zero = 0.0;
+  double minus_zero = - plus_zero;
+  return memcmp (&plus_zero, &minus_zero, sizeof (double)) != 0;
+}
 static char buf[10000];
 static double zero = 0.0;
 int main ()
@@ -187,6 +195,11 @@
   if (sprintf (buf, "%g", zero / zero) < 0
       || !strisnan (buf, 0, strlen (buf)))
     return 1;
+  /* This test fails on HP-UX 10.20.  */
+  if (have_minus_zero ())
+    if (sprintf (buf, "%g", - zero) < 0
+        || strcmp (buf, "-0") != 0)
+    return 1;
   return 0;
 }], [gl_cv_func_printf_infinite=yes], [gl_cv_func_printf_infinite=no],
       [
@@ -225,12 +238,12 @@
 [
   AC_REQUIRE([gl_PRINTF_LONG_DOUBLE])
   AC_REQUIRE([AC_PROG_CC])
-  AC_REQUIRE([AC_C_BIGENDIAN])
+  AC_REQUIRE([gl_BIGENDIAN])
   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
   dnl The user can set or unset the variable gl_printf_safe to indicate
   dnl that he wishes a safe handling of non-IEEE-754 'long double' values.
   if test -n "$gl_printf_safe"; then
-    AC_DEFINE([CHECK_PRINTF_SAFE], 1,
+    AC_DEFINE([CHECK_PRINTF_SAFE], [1],
       [Define if you wish *printf() functions that have a safe handling of
        non-IEEE-754 'long double' values.])
   fi
@@ -545,7 +558,7 @@
   if (sprintf (buf, "%F", 1.0 / 0.0) < 0
       || (strcmp (buf, "INF") != 0 && strcmp (buf, "INFINITY") != 0))
     return 1;
-  /* This catches a Cygwin 2007 bug.  */
+  /* This catches a Cygwin 1.5.x bug.  */
   if (sprintf (buf, "%.F", 1234.0) < 0
       || strcmp (buf, "1234") != 0)
     return 1;
@@ -612,6 +625,84 @@
     ])
 ])
 
+dnl Test whether the *printf family of functions supports the %ls format
+dnl directive and in particular, when a precision is specified, whether
+dnl the functions stop converting the wide string argument when the number
+dnl of bytes that have been produced by this conversion equals or exceeds
+dnl the precision.
+dnl Result is gl_cv_func_printf_directive_ls.
+
+AC_DEFUN([gl_PRINTF_DIRECTIVE_LS],
+[
+  AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_CACHE_CHECK([whether printf supports the 'ls' directive],
+    [gl_cv_func_printf_directive_ls],
+    [
+      AC_TRY_RUN([
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
+   included before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+#include <string.h>
+int main ()
+{
+  char buf[100];
+  /* Test whether %ls works at all.
+     This test fails on OpenBSD 4.0, IRIX 6.5, Solaris 2.6, Haiku, but not on
+     Cygwin 1.5.  */
+  {
+    static const wchar_t wstring[] = { 'a', 'b', 'c', 0 };
+    buf[0] = '\0';
+    if (sprintf (buf, "%ls", wstring) < 0
+        || strcmp (buf, "abc") != 0)
+      return 1;
+  }
+  /* This test fails on IRIX 6.5, Solaris 2.6, Cygwin 1.5, Haiku (with an
+     assertion failure inside libc), but not on OpenBSD 4.0.  */
+  {
+    static const wchar_t wstring[] = { 'a', 0 };
+    buf[0] = '\0';
+    if (sprintf (buf, "%ls", wstring) < 0
+        || strcmp (buf, "a") != 0)
+      return 1;
+  }
+  /* Test whether precisions in %ls are supported as specified in ISO C 99
+     section 7.19.6.1:
+       "If a precision is specified, no more than that many bytes are written
+        (including shift sequences, if any), and the array shall contain a
+        null wide character if, to equal the multibyte character sequence
+        length given by the precision, the function would need to access a
+        wide character one past the end of the array."
+     This test fails on Solaris 10.  */
+  {
+    static const wchar_t wstring[] = { 'a', 'b', (wchar_t) 0xfdfdfdfd, 0 };
+    buf[0] = '\0';
+    if (sprintf (buf, "%.2ls", wstring) < 0
+        || strcmp (buf, "ab") != 0)
+      return 1;
+  }
+  return 0;
+}], [gl_cv_func_printf_directive_ls=yes], [gl_cv_func_printf_directive_ls=no],
+      [
+changequote(,)dnl
+       case "$host_os" in
+         openbsd*)        gl_cv_func_printf_directive_ls="guessing no";;
+         irix*)           gl_cv_func_printf_directive_ls="guessing no";;
+         solaris*)        gl_cv_func_printf_directive_ls="guessing no";;
+         cygwin*)         gl_cv_func_printf_directive_ls="guessing no";;
+         beos* | haiku*)  gl_cv_func_printf_directive_ls="guessing no";;
+         *)               gl_cv_func_printf_directive_ls="guessing yes";;
+       esac
+changequote([,])dnl
+      ])
+    ])
+])
+
 dnl Test whether the *printf family of functions supports POSIX/XSI format
 dnl strings with positions. (POSIX:2001)
 dnl Result is gl_cv_func_printf_positions.
@@ -811,13 +902,15 @@
 AC_DEFUN([gl_PRINTF_ENOMEM],
 [
   AC_REQUIRE([AC_PROG_CC])
+  AC_REQUIRE([gl_MULTIARCH])
   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
   AC_CACHE_CHECK([whether printf survives out-of-memory conditions],
     [gl_cv_func_printf_enomem],
     [
       gl_cv_func_printf_enomem="guessing no"
       if test "$cross_compiling" = no; then
-        AC_LANG_CONFTEST([AC_LANG_SOURCE([
+        if test $APPLE_UNIVERSAL_BUILD = 0; then
+          AC_LANG_CONFTEST([AC_LANG_SOURCE([
 ]GL_NOCRASH[
 changequote(,)dnl
 #include <stdio.h>
@@ -866,21 +959,27 @@
 }
 changequote([,])dnl
           ])])
-        if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
-          (./conftest
-           result=$?
-           if test $result != 0 && test $result != 77; then result=1; fi
-           exit $result
-          ) >/dev/null 2>/dev/null
-          case $? in
-            0) gl_cv_func_printf_enomem="yes" ;;
-            77) gl_cv_func_printf_enomem="guessing no" ;;
-            *) gl_cv_func_printf_enomem="no" ;;
-          esac
+          if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
+            (./conftest
+             result=$?
+             if test $result != 0 && test $result != 77; then result=1; fi
+             exit $result
+            ) >/dev/null 2>/dev/null
+            case $? in
+              0) gl_cv_func_printf_enomem="yes" ;;
+              77) gl_cv_func_printf_enomem="guessing no" ;;
+              *) gl_cv_func_printf_enomem="no" ;;
+            esac
+          else
+            gl_cv_func_printf_enomem="guessing no"
+          fi
+          rm -fr conftest*
         else
+          dnl A universal build on Apple MacOS X platforms.
+          dnl The result would be 'no' in 32-bit mode and 'yes' in 64-bit mode.
+          dnl But we need a configuration result that is valid in both modes.
           gl_cv_func_printf_enomem="guessing no"
         fi
-        rm -fr conftest*
       fi
       if test "$gl_cv_func_printf_enomem" = "guessing no"; then
 changequote(,)dnl
@@ -1134,7 +1233,7 @@
 #include <stdio.h>
 int main()
 {
-  static char buf[8] = "DEADBEEF";
+  static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' };
   snprintf (buf, 1, "%d", 12345);
   return buf[1] != 'E';
 }],
@@ -1152,7 +1251,7 @@
 dnl     #include <stdio.h>
 dnl     int main()
 dnl     {
-dnl       static char buf[8] = "DEADBEEF";
+dnl       static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' };
 dnl       snprintf (buf, 0, "%d", 12345);
 dnl       return buf[0] != 'D';
 dnl     }
@@ -1173,7 +1272,7 @@
 dnl     }
 dnl     int main()
 dnl     {
-dnl       static char buf[8] = "DEADBEEF";
+dnl       static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' };
 dnl       my_snprintf (buf, 0, "%d", 12345);
 dnl       return buf[0] != 'D';
 dnl     }
@@ -1201,7 +1300,7 @@
 }
 int main()
 {
-  static char buf[8] = "DEADBEEF";
+  static char buf[8] = { 'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F' };
   my_snprintf (buf, 0, "%d", 12345);
   return buf[0] != 'D';
 }],
@@ -1253,18 +1352,19 @@
 dnl 5 = gl_PRINTF_DIRECTIVE_A
 dnl 6 = gl_PRINTF_DIRECTIVE_F
 dnl 7 = gl_PRINTF_DIRECTIVE_N
-dnl 8 = gl_PRINTF_POSITIONS
-dnl 9 = gl_PRINTF_FLAG_GROUPING
-dnl 10 = gl_PRINTF_FLAG_LEFTADJUST
-dnl 11 = gl_PRINTF_FLAG_ZERO
-dnl 12 = gl_PRINTF_PRECISION
-dnl 13 = gl_PRINTF_ENOMEM
-dnl 14 = gl_SNPRINTF_PRESENCE
-dnl 15 = gl_SNPRINTF_TRUNCATION_C99
-dnl 16 = gl_SNPRINTF_RETVAL_C99
-dnl 17 = gl_SNPRINTF_DIRECTIVE_N
-dnl 18 = gl_SNPRINTF_SIZE1
-dnl 19 = gl_VSNPRINTF_ZEROSIZE_C99
+dnl 8 = gl_PRINTF_DIRECTIVE_LS
+dnl 9 = gl_PRINTF_POSITIONS
+dnl 10 = gl_PRINTF_FLAG_GROUPING
+dnl 11 = gl_PRINTF_FLAG_LEFTADJUST
+dnl 12 = gl_PRINTF_FLAG_ZERO
+dnl 13 = gl_PRINTF_PRECISION
+dnl 14 = gl_PRINTF_ENOMEM
+dnl 15 = gl_SNPRINTF_PRESENCE
+dnl 16 = gl_SNPRINTF_TRUNCATION_C99
+dnl 17 = gl_SNPRINTF_RETVAL_C99
+dnl 18 = gl_SNPRINTF_DIRECTIVE_N
+dnl 19 = gl_SNPRINTF_SIZE1
+dnl 20 = gl_VSNPRINTF_ZEROSIZE_C99
 dnl
 dnl 1 = checking whether printf supports size specifiers as in C99...
 dnl 2 = checking whether printf supports 'long double' arguments...
@@ -1273,42 +1373,44 @@
 dnl 5 = checking whether printf supports the 'a' and 'A' directives...
 dnl 6 = checking whether printf supports the 'F' directive...
 dnl 7 = checking whether printf supports the 'n' directive...
-dnl 8 = checking whether printf supports POSIX/XSI format strings with positions...
-dnl 9 = checking whether printf supports the grouping flag...
-dnl 10 = checking whether printf supports the left-adjust flag correctly...
-dnl 11 = checking whether printf supports the zero flag correctly...
-dnl 12 = checking whether printf supports large precisions...
-dnl 13 = checking whether printf survives out-of-memory conditions...
-dnl 14 = checking for snprintf...
-dnl 15 = checking whether snprintf truncates the result as in C99...
-dnl 16 = checking whether snprintf returns a byte count as in C99...
-dnl 17 = checking whether snprintf fully supports the 'n' directive...
-dnl 18 = checking whether snprintf respects a size of 1...
-dnl 19 = checking whether vsnprintf respects a zero size as in C99...
+dnl 8 = checking whether printf supports the 'ls' directive...
+dnl 9 = checking whether printf supports POSIX/XSI format strings with positions...
+dnl 10 = checking whether printf supports the grouping flag...
+dnl 11 = checking whether printf supports the left-adjust flag correctly...
+dnl 12 = checking whether printf supports the zero flag correctly...
+dnl 13 = checking whether printf supports large precisions...
+dnl 14 = checking whether printf survives out-of-memory conditions...
+dnl 15 = checking for snprintf...
+dnl 16 = checking whether snprintf truncates the result as in C99...
+dnl 17 = checking whether snprintf returns a byte count as in C99...
+dnl 18 = checking whether snprintf fully supports the 'n' directive...
+dnl 19 = checking whether snprintf respects a size of 1...
+dnl 20 = checking whether vsnprintf respects a zero size as in C99...
 dnl
 dnl . = yes, # = no.
 dnl
-dnl                                  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19
-dnl   glibc 2.5                      .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
-dnl   glibc 2.3.6                    .  .  .  .  #  .  .  .  .  .  .  .  .  .  .  .  .  .  .
-dnl   FreeBSD 5.4, 6.1               .  .  .  .  #  .  .  .  .  .  #  .  #  .  .  .  .  .  .
-dnl   MacOS X 10.3.9                 .  .  .  .  #  .  .  .  .  .  #  .  #  .  .  .  .  .  .
-dnl   OpenBSD 3.9, 4.0               .  .  #  #  #  #  .  .  #  .  #  .  #  .  .  .  .  .  .
-dnl   Cygwin 2007 (= Cygwin 1.5.24)  .  .  .  .  #  #  .  .  .  ?  #  ?  ?  .  .  .  .  .  .
-dnl   Cygwin 2006 (= Cygwin 1.5.19)  #  .  .  .  #  #  .  .  #  ?  #  ?  ?  .  .  .  .  .  .
-dnl   Solaris 10                     .  .  #  #  #  .  .  .  .  .  #  .  .  .  .  .  .  .  .
-dnl   Solaris 2.6 ... 9              #  .  #  #  #  #  .  .  .  .  #  .  .  .  .  .  .  .  .
-dnl   Solaris 2.5.1                  #  .  #  #  #  #  .  .  .  .  #  .  .  #  #  #  #  #  #
-dnl   AIX 5.2                        .  .  #  #  #  .  .  .  .  .  #  .  .  .  .  .  .  .  .
-dnl   AIX 4.3.2, 5.1                 #  .  #  #  #  #  .  .  .  .  #  .  .  .  .  .  .  .  .
-dnl   HP-UX 11.31                    .  .  .  .  #  .  .  .  .  .  #  .  .  .  .  #  #  .  .
-dnl   HP-UX 11.{00,11,23}            #  .  .  .  #  #  .  .  .  .  #  .  .  .  .  #  #  .  #
-dnl   HP-UX 10.20                    #  .  .  .  #  #  .  .  .  #  #  .  .  .  .  #  #  ?  #
-dnl   IRIX 6.5                       #  .  #  #  #  #  .  .  .  .  #  .  .  .  .  #  .  .  .
-dnl   OSF/1 5.1                      #  .  #  #  #  #  .  .  .  .  #  .  .  .  .  #  .  .  #
-dnl   OSF/1 4.0d                     #  .  #  #  #  #  .  .  .  .  #  .  .  #  #  #  #  #  #
-dnl   NetBSD 4.0                     .  ?  ?  ?  ?  ?  .  .  ?  ?  ?  ?  ?  .  .  .  ?  ?  ?
-dnl   NetBSD 3.0                     .  .  .  .  #  #  .  #  #  ?  #  .  #  .  .  .  .  .  .
-dnl   Haiku                          .  .  .  #  #  #  .  .  .  .  .  .  ?  .  .  .  .  .  .
-dnl   BeOS                           #  #  .  #  #  #  .  #  .  ?  .  #  ?  .  .  .  .  .  .
-dnl   mingw                          #  #  #  #  #  #  .  #  #  .  #  #  ?  .  #  #  #  .  .
+dnl                                  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20
+dnl   glibc 2.5                      .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
+dnl   glibc 2.3.6                    .  .  .  .  #  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .
+dnl   FreeBSD 5.4, 6.1               .  .  .  .  #  .  .  .  .  .  .  #  .  #  .  .  .  .  .  .
+dnl   MacOS X 10.3.9                 .  .  .  .  #  .  .  .  .  .  .  #  .  #  .  .  .  .  .  .
+dnl   OpenBSD 3.9, 4.0               .  .  #  #  #  #  .  #  .  #  .  #  .  #  .  .  .  .  .  .
+dnl   Cygwin 1.7.0 (2009)            .  .  .  #  .  .  .  ?  .  .  .  .  .  ?  .  .  .  .  .  .
+dnl   Cygwin 1.5.25 (2008)           .  .  .  #  #  .  .  #  .  .  .  .  .  #  .  .  .  .  .  .
+dnl   Cygwin 1.5.19 (2006)           #  .  .  #  #  #  .  #  .  #  .  #  #  #  .  .  .  .  .  .
+dnl   Solaris 10                     .  .  #  #  #  .  .  #  .  .  .  #  .  .  .  .  .  .  .  .
+dnl   Solaris 2.6 ... 9              #  .  #  #  #  #  .  #  .  .  .  #  .  .  .  .  .  .  .  .
+dnl   Solaris 2.5.1                  #  .  #  #  #  #  .  #  .  .  .  #  .  .  #  #  #  #  #  #
+dnl   AIX 5.2                        .  .  #  #  #  .  .  .  .  .  .  #  .  .  .  .  .  .  .  .
+dnl   AIX 4.3.2, 5.1                 #  .  #  #  #  #  .  .  .  .  .  #  .  .  .  .  .  .  .  .
+dnl   HP-UX 11.31                    .  .  .  .  #  .  .  .  .  .  .  #  .  .  .  .  #  #  .  .
+dnl   HP-UX 11.{00,11,23}            #  .  .  .  #  #  .  .  .  .  .  #  .  .  .  .  #  #  .  #
+dnl   HP-UX 10.20                    #  .  #  .  #  #  .  ?  .  .  #  #  .  .  .  .  #  #  ?  #
+dnl   IRIX 6.5                       #  .  #  #  #  #  .  #  .  .  .  #  .  .  .  .  #  .  .  .
+dnl   OSF/1 5.1                      #  .  #  #  #  #  .  .  .  .  .  #  .  .  .  .  #  .  .  #
+dnl   OSF/1 4.0d                     #  .  #  #  #  #  .  .  .  .  .  #  .  .  #  #  #  #  #  #
+dnl   NetBSD 4.0                     .  ?  ?  ?  ?  ?  .  ?  .  ?  ?  ?  ?  ?  .  .  .  ?  ?  ?
+dnl   NetBSD 3.0                     .  .  .  .  #  #  .  ?  #  #  ?  #  .  #  .  .  .  .  .  .
+dnl   Haiku                          .  .  .  #  #  #  .  #  .  .  .  .  .  ?  .  .  .  .  .  .
+dnl   BeOS                           #  #  .  #  #  #  .  ?  #  .  ?  .  #  ?  .  .  .  .  .  .
+dnl   mingw                          #  #  #  #  #  #  .  .  #  #  .  #  #  ?  .  #  #  #  .  .

Modified: libprelude/trunk/libmissing/m4/realloc.m4
===================================================================
--- libprelude/trunk/libmissing/m4/realloc.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/realloc.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# realloc.m4 serial 8
-dnl Copyright (C) 2007 Free Software Foundation, Inc.
+# realloc.m4 serial 9
+dnl Copyright (C) 2007, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -13,7 +13,7 @@
   AC_REQUIRE([gl_CHECK_MALLOC_POSIX])
   if test $gl_cv_func_malloc_posix = yes; then
     HAVE_REALLOC_POSIX=1
-    AC_DEFINE([HAVE_REALLOC_POSIX], 1,
+    AC_DEFINE([HAVE_REALLOC_POSIX], [1],
       [Define if the 'realloc' function is POSIX compliant.])
   else
     AC_LIBOBJ([realloc])

Modified: libprelude/trunk/libmissing/m4/regex.m4
===================================================================
--- libprelude/trunk/libmissing/m4/regex.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/regex.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,7 +1,7 @@
-#serial 52
+# serial 54
 
 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
-# 2006, 2007, 2008 Free Software Foundation, Inc.
+# 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -18,12 +18,9 @@
 
   AC_ARG_WITH([included-regex],
     [AS_HELP_STRING([--without-included-regex],
-		    [don't compile regex; this is the default on 32-bit
-		     systems with recent-enough versions of the GNU C
-		     Library (use with caution on other systems).
-		     On systems with 64-bit ptrdiff_t and 32-bit int,
-		     --with-included-regex is the default, in case
-		     regex functions operate on very long strings (>2GB)])])
+		    [don't compile regex; this is the default on systems
+		     with recent-enough versions of the GNU C Library
+		     (use with caution on other systems).])])
 
   case $with_included_regex in #(
   yes|no) ac_use_included_regex=$with_included_regex
@@ -175,7 +172,7 @@
   esac
 
   if test $ac_use_included_regex = yes; then
-    AC_DEFINE([_REGEX_LARGE_OFFSETS], 1,
+    AC_DEFINE([_REGEX_LARGE_OFFSETS], [1],
       [Define if you want regoff_t to be at least as wide POSIX requires.])
     AC_DEFINE([re_syntax_options], [rpl_re_syntax_options],
       [Define to rpl_re_syntax_options if the replacement should be used.])
@@ -219,6 +216,6 @@
   AC_REQUIRE([AC_C_RESTRICT])
   AC_REQUIRE([AC_TYPE_MBSTATE_T])
   AC_CHECK_HEADERS([libintl.h])
-  AC_CHECK_FUNCS_ONCE([isblank iswctype mbrtowc wcrtomb wcscoll])
+  AC_CHECK_FUNCS_ONCE([isblank iswctype wcscoll])
   AC_CHECK_DECLS([isblank], [], [], [#include <ctype.h>])
 ])

Modified: libprelude/trunk/libmissing/m4/relocatable-lib.m4
===================================================================
--- libprelude/trunk/libmissing/m4/relocatable-lib.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/relocatable-lib.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# relocatable-lib.m4 serial 3
-dnl Copyright (C) 2003, 2005-2007 Free Software Foundation, Inc.
+# relocatable-lib.m4 serial 4
+dnl Copyright (C) 2003, 2005-2007, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -26,7 +26,7 @@
   AC_DEFINE_UNQUOTED([INSTALLPREFIX], ["${reloc_final_prefix}"],
     [Define to the value of ${prefix}, as a string.])
   if test $RELOCATABLE = yes; then
-    AC_DEFINE([ENABLE_RELOCATABLE], 1,
+    AC_DEFINE([ENABLE_RELOCATABLE], [1],
       [Define to 1 if the package shall run at any location in the filesystem.])
   fi
 ])
@@ -42,7 +42,7 @@
 AC_DEFUN([gl_RELOCATABLE_NOP],
 [
   AC_MSG_CHECKING([whether to activate relocatable installation])
-  AC_ARG_ENABLE(relocatable,
+  AC_ARG_ENABLE([relocatable],
     [  --enable-relocatable    install a package that can be moved in the filesystem],
     [if test "$enableval" != no; then
        RELOCATABLE=yes
@@ -50,7 +50,7 @@
        RELOCATABLE=no
      fi
     ], RELOCATABLE=no)
-  AC_SUBST(RELOCATABLE)
+  AC_SUBST([RELOCATABLE])
   AC_MSG_RESULT([$RELOCATABLE])
 ])
 

Added: libprelude/trunk/libmissing/m4/select.m4
===================================================================
--- libprelude/trunk/libmissing/m4/select.m4	                        (rev 0)
+++ libprelude/trunk/libmissing/m4/select.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,52 @@
+# select.m4 serial 1
+dnl Copyright (C) 2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_SELECT],
+[
+  AC_REQUIRE([gl_HEADER_SYS_SELECT])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  if test "$ac_cv_header_winsock2_h" = yes; then
+    AC_LIBOBJ([select])
+  else
+    dnl On Interix 3.5, select(0, NULL, NULL, NULL, timeout) fails with error
+    dnl EFAULT.
+    AC_CHECK_HEADERS_ONCE([sys/select.h])
+    AC_CACHE_CHECK([whether select supports a 0 argument],
+      [gl_cv_func_select_supports0],
+      [
+        AC_TRY_RUN([
+#include <sys/types.h>
+#include <sys/time.h>
+#if HAVE_SYS_SELECT_H
+#include <sys/select.h>
+#endif
+int main ()
+{
+  struct timeval timeout;
+  timeout.tv_sec = 0;
+  timeout.tv_usec = 5;
+  return select (0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &timeout) < 0;
+}], [gl_cv_func_select_supports0=yes], [gl_cv_func_select_supports0=no],
+          [
+changequote(,)dnl
+           case "$host_os" in
+                       # Guess no on Interix.
+             interix*) gl_cv_func_select_supports0="guessing no";;
+                       # Guess yes otherwise.
+             *)        gl_cv_func_select_supports0="guessing yes";;
+           esac
+changequote([,])dnl
+          ])
+      ])
+    case "$gl_cv_func_select_supports0" in
+      *yes) ;;
+      *)
+        REPLACE_SELECT=1
+        AC_LIBOBJ([select])
+        ;;
+    esac
+  fi
+])

Added: libprelude/trunk/libmissing/m4/servent.m4
===================================================================
--- libprelude/trunk/libmissing/m4/servent.m4	                        (rev 0)
+++ libprelude/trunk/libmissing/m4/servent.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,47 @@
+# servent.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_SERVENT],
+[
+  dnl Where are getservent(), setservent(), endservent(), getservbyname(),
+  dnl getservbyport() defined?
+  dnl Where are getprotoent(), setprotoent(), endprotoent(), getprotobyname(),
+  dnl getprotobynumber() defined?
+  dnl - On Solaris, they are in libsocket. Ignore libxnet.
+  dnl - On Haiku, they are in libnetwork.
+  dnl - On BeOS, they are in libnet.
+  dnl - On native Windows, they are in ws2_32.dll.
+  dnl - Otherwise they are in libc.
+  AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl for HAVE_SYS_SOCKET_H, HAVE_WINSOCK2_H
+  SERVENT_LIB=
+  gl_saved_libs="$LIBS"
+  AC_SEARCH_LIBS([getservbyname], [socket network net],
+    [if test "$ac_cv_search_getservbyname" != "none required"; then
+       SERVENT_LIB="$ac_cv_search_getservbyname"
+     fi])
+  LIBS="$gl_saved_libs"
+  if test -z "$SERVENT_LIB"; then
+    AC_CHECK_FUNCS([getservbyname], , [
+      AC_CACHE_CHECK([for getservbyname in winsock2.h and -lws2_32],
+        [gl_cv_w32_getservbyname],
+        [gl_cv_w32_getservbyname=no
+         gl_save_LIBS="$LIBS"
+         LIBS="$LIBS -lws2_32"
+         AC_TRY_LINK([
+#ifdef HAVE_WINSOCK2_H
+#include <winsock2.h>
+#endif
+#include <stddef.h>
+], [getservbyname(NULL,NULL);], [gl_cv_w32_getservbyname=yes])
+         LIBS="$gl_save_LIBS"
+        ])
+      if test "$gl_cv_w32_getservbyname" = "yes"; then
+        SERVENT_LIB="-lws2_32"
+      fi
+    ])
+  fi
+  AC_SUBST([SERVENT_LIB])
+])

Modified: libprelude/trunk/libmissing/m4/signal_h.m4
===================================================================
--- libprelude/trunk/libmissing/m4/signal_h.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/signal_h.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# signal_h.m4 serial 6
-dnl Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+# signal_h.m4 serial 7
+dnl Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -8,6 +8,12 @@
 [
   AC_REQUIRE([gl_SIGNAL_H_DEFAULTS])
   gl_CHECK_NEXT_HEADERS([signal.h])
+# AIX declares sig_atomic_t to already include volatile, and C89 compilers
+# then choke on 'volatile sig_atomic_t'.  C99 requires that it compile.
+  AC_CHECK_TYPE([volatile sig_atomic_t], [],
+    [HAVE_TYPE_VOLATILE_SIG_ATOMIC_T=0], [[
+#include <signal.h>
+    ]])
 ])
 
 AC_DEFUN([gl_SIGNAL_MODULE_INDICATOR],
@@ -29,4 +35,6 @@
   HAVE_SIGACTION=1;            AC_SUBST([HAVE_SIGACTION])
   HAVE_STRUCT_SIGACTION_SA_SIGACTION=1;
                                AC_SUBST([HAVE_STRUCT_SIGACTION_SA_SIGACTION])
+  HAVE_TYPE_VOLATILE_SIG_ATOMIC_T=1;
+                               AC_SUBST([HAVE_TYPE_VOLATILE_SIG_ATOMIC_T])
 ])

Modified: libprelude/trunk/libmissing/m4/signalblocking.m4
===================================================================
--- libprelude/trunk/libmissing/m4/signalblocking.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/signalblocking.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# signalblocking.m4 serial 9
-dnl Copyright (C) 2001-2002, 2006-2008 Free Software Foundation, Inc.
+# signalblocking.m4 serial 10
+dnl Copyright (C) 2001-2002, 2006-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -13,9 +13,9 @@
 [
   AC_REQUIRE([gl_SIGNAL_H_DEFAULTS])
   signals_not_posix=
-  AC_EGREP_HEADER(sigset_t, signal.h, , signals_not_posix=1)
+  AC_EGREP_HEADER([sigset_t], [signal.h], , [signals_not_posix=1])
   if test -z "$signals_not_posix"; then
-    AC_CHECK_FUNC(sigprocmask, [gl_cv_func_sigprocmask=1])
+    AC_CHECK_FUNC([sigprocmask], [gl_cv_func_sigprocmask=1])
   fi
   if test -z "$gl_cv_func_sigprocmask"; then
     HAVE_POSIX_SIGNALBLOCKING=0

Modified: libprelude/trunk/libmissing/m4/size_max.m4
===================================================================
--- libprelude/trunk/libmissing/m4/size_max.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/size_max.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# size_max.m4 serial 6
-dnl Copyright (C) 2003, 2005-2006 Free Software Foundation, Inc.
+# size_max.m4 serial 7
+dnl Copyright (C) 2003, 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,
 dnl with or without modifications, as long as this notice is preserved.
@@ -8,7 +8,7 @@
 
 AC_DEFUN([gl_SIZE_MAX],
 [
-  AC_CHECK_HEADERS(stdint.h)
+  AC_CHECK_HEADERS([stdint.h])
   dnl First test whether the system already has SIZE_MAX.
   AC_MSG_CHECKING([for SIZE_MAX])
   AC_CACHE_VAL([gl_cv_size_max], [
@@ -21,16 +21,16 @@
 #ifdef SIZE_MAX
 Found it
 #endif
-], gl_cv_size_max=yes)
+], [gl_cv_size_max=yes])
     if test -z "$gl_cv_size_max"; then
       dnl Define it ourselves. Here we assume that the type 'size_t' is not wider
       dnl than the type 'unsigned long'. Try hard to find a definition that can
       dnl be used in a preprocessor #if, i.e. doesn't contain a cast.
       AC_COMPUTE_INT([size_t_bits_minus_1], [sizeof (size_t) * CHAR_BIT - 1],
         [#include <stddef.h>
-#include <limits.h>], size_t_bits_minus_1=)
+#include <limits.h>], [size_t_bits_minus_1=])
       AC_COMPUTE_INT([fits_in_uint], [sizeof (size_t) <= sizeof (unsigned int)],
-        [#include <stddef.h>], fits_in_uint=)
+        [#include <stddef.h>], [fits_in_uint=])
       if test -n "$size_t_bits_minus_1" && test -n "$fits_in_uint"; then
         if test $fits_in_uint = 1; then
           dnl Even though SIZE_MAX fits in an unsigned int, it must be of type
@@ -38,7 +38,7 @@
           AC_TRY_COMPILE([#include <stddef.h>
             extern size_t foo;
             extern unsigned long foo;
-            ], [], fits_in_uint=0)
+            ], [], [fits_in_uint=0])
         fi
         dnl We cannot use 'expr' to simplify this expression, because 'expr'
         dnl works only with 'long' integers in the host environment, while we

Modified: libprelude/trunk/libmissing/m4/sockets.m4
===================================================================
--- libprelude/trunk/libmissing/m4/sockets.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/sockets.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,11 +1,13 @@
-# sockets.m4 serial 2
-dnl Copyright (C) 2008 Free Software Foundation, Inc.
+# sockets.m4 serial 5
+dnl Copyright (C) 2008, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
 
 AC_DEFUN([gl_SOCKETS],
 [
+  AC_REQUIRE([AC_C_INLINE])
+
   gl_PREREQ_SYS_H_WINSOCK2 dnl for HAVE_WINSOCK2_H
   LIBSOCKET=
   if test $HAVE_WINSOCK2_H = 1; then
@@ -26,14 +28,16 @@
       LIBS="$gl_save_LIBS"
     ])
     if test "$gl_cv_func_wsastartup" = "yes"; then
-      AC_DEFINE([WINDOWS_SOCKETS], 1, [Define if WSAStartup is needed.])
+      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
+    dnl Haiku has most socket functions in libnetwork.
+    dnl BeOS has most socket functions in libnet.
+    AC_CACHE_CHECK([for library containing setsockopt], [gl_cv_lib_socket], [
+      gl_cv_lib_socket=
       AC_TRY_LINK([extern
 #ifdef __cplusplus
 "C"
@@ -41,18 +45,39 @@
 char setsockopt();], [setsockopt();],
         [],
         [gl_save_LIBS="$LIBS"
-         LIBS="$LIBS -lsocket"
+         LIBS="$gl_save_LIBS -lsocket"
          AC_TRY_LINK([extern
 #ifdef __cplusplus
 "C"
 #endif
 char setsockopt();], [setsockopt();],
-           [gl_cv_lib_socket=yes])
+           [gl_cv_lib_socket="-lsocket"])
+         if test -z "$gl_cv_lib_socket"; then
+           LIBS="$gl_save_LIBS -lnetwork"
+           AC_TRY_LINK([extern
+#ifdef __cplusplus
+"C"
+#endif
+char setsockopt();], [setsockopt();],
+             [gl_cv_lib_socket="-lnetwork"])
+           if test -z "$gl_cv_lib_socket"; then
+             LIBS="$gl_save_LIBS -lnet"
+             AC_TRY_LINK([extern
+#ifdef __cplusplus
+"C"
+#endif
+char setsockopt();], [setsockopt();],
+               [gl_cv_lib_socket="-lnet"])
+           fi
+         fi
          LIBS="$gl_save_LIBS"
         ])
+      if test -z "$gl_cv_lib_socket"; then
+        gl_cv_lib_socket="none needed"
+      fi
     ])
-    if test $gl_cv_lib_socket = yes; then
-      LIBSOCKET='-lsocket'
+    if test "$gl_cv_lib_socket" != "none needed"; then
+      LIBSOCKET="$gl_cv_lib_socket"
     fi
   fi
   AC_SUBST([LIBSOCKET])

Modified: libprelude/trunk/libmissing/m4/sockpfaf.m4
===================================================================
--- libprelude/trunk/libmissing/m4/sockpfaf.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/sockpfaf.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# sockpfaf.m4 serial 5
-dnl Copyright (C) 2004, 2006 Free Software Foundation, Inc.
+# sockpfaf.m4 serial 6
+dnl Copyright (C) 2004, 2006, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -16,8 +16,8 @@
   AC_REQUIRE([gl_HEADER_SYS_SOCKET])
   AC_CHECK_HEADERS_ONCE([netinet/in.h])
 
-  AC_MSG_CHECKING(for IPv4 sockets)
-  AC_CACHE_VAL(gl_cv_socket_ipv4,
+  AC_MSG_CHECKING([for IPv4 sockets])
+  AC_CACHE_VAL([gl_cv_socket_ipv4],
     [AC_TRY_COMPILE([#include <sys/types.h>
 #ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
@@ -31,13 +31,13 @@
 [int x = AF_INET; struct in_addr y; struct sockaddr_in z;
  if (&x && &y && &z) return 0;],
        gl_cv_socket_ipv4=yes, gl_cv_socket_ipv4=no)])
-  AC_MSG_RESULT($gl_cv_socket_ipv4)
+  AC_MSG_RESULT([$gl_cv_socket_ipv4])
   if test $gl_cv_socket_ipv4 = yes; then
-    AC_DEFINE(HAVE_IPV4, 1, [Define to 1 if <sys/socket.h> defines AF_INET.])
+    AC_DEFINE([HAVE_IPV4], [1], [Define to 1 if <sys/socket.h> defines AF_INET.])
   fi
 
-  AC_MSG_CHECKING(for IPv6 sockets)
-  AC_CACHE_VAL(gl_cv_socket_ipv6,
+  AC_MSG_CHECKING([for IPv6 sockets])
+  AC_CACHE_VAL([gl_cv_socket_ipv6],
     [AC_TRY_COMPILE([#include <sys/types.h>
 #ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
@@ -51,8 +51,8 @@
 [int x = AF_INET6; struct in6_addr y; struct sockaddr_in6 z;
  if (&x && &y && &z) return 0;],
        gl_cv_socket_ipv6=yes, gl_cv_socket_ipv6=no)])
-  AC_MSG_RESULT($gl_cv_socket_ipv6)
+  AC_MSG_RESULT([$gl_cv_socket_ipv6])
   if test $gl_cv_socket_ipv6 = yes; then
-    AC_DEFINE(HAVE_IPV6, 1, [Define to 1 if <sys/socket.h> defines AF_INET6.])
+    AC_DEFINE([HAVE_IPV6], [1], [Define to 1 if <sys/socket.h> defines AF_INET6.])
   fi
 ])

Modified: libprelude/trunk/libmissing/m4/stdbool.m4
===================================================================
--- libprelude/trunk/libmissing/m4/stdbool.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/stdbool.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,6 +1,6 @@
 # Check for stdbool.h that conforms to C99.
 
-dnl Copyright (C) 2002-2006 Free Software Foundation, Inc.
+dnl Copyright (C) 2002-2006, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -111,5 +111,5 @@
 	[ac_cv_header_stdbool_h=no])])
    AC_CHECK_TYPES([_Bool])
    if test $ac_cv_header_stdbool_h = yes; then
-     AC_DEFINE(HAVE_STDBOOL_H, 1, [Define to 1 if stdbool.h conforms to C99.])
+     AC_DEFINE([HAVE_STDBOOL_H], [1], [Define to 1 if stdbool.h conforms to C99.])
    fi])

Modified: libprelude/trunk/libmissing/m4/stdint.m4
===================================================================
--- libprelude/trunk/libmissing/m4/stdint.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/stdint.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# stdint.m4 serial 31
-dnl Copyright (C) 2001-2008 Free Software Foundation, Inc.
+# stdint.m4 serial 34
+dnl Copyright (C) 2001-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -9,7 +9,7 @@
 
 AC_DEFUN([gl_STDINT_H],
 [
-  AC_PREREQ(2.59)dnl
+  AC_PREREQ([2.59])dnl
 
   dnl Check for long long int and unsigned long long int.
   AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
@@ -201,7 +201,75 @@
   int check_size: (size_t) -1 == SIZE_MAX ? 1 : -1;
 };
          ]])],
-         [gl_cv_header_working_stdint_h=yes])])
+         [dnl Determine whether the various *_MIN, *_MAX macros are usable
+          dnl in preprocessor expression. We could do it by compiling a test
+          dnl program for each of these macros. It is faster to run a program
+          dnl that inspects the macro expansion.
+          dnl This detects a bug on HP-UX 11.23/ia64.
+          AC_RUN_IFELSE([
+            AC_LANG_PROGRAM([[
+#define __STDC_LIMIT_MACROS 1 /* to make it work also in C++ mode */
+#define __STDC_CONSTANT_MACROS 1 /* to make it work also in C++ mode */
+#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
+#include <stdint.h>
+]
+gl_STDINT_INCLUDES
+[
+#include <stdio.h>
+#include <string.h>
+#define MVAL(macro) MVAL1(macro)
+#define MVAL1(expression) #expression
+static const char *macro_values[] =
+  {
+#ifdef INT8_MAX
+    MVAL (INT8_MAX),
+#endif
+#ifdef INT16_MAX
+    MVAL (INT16_MAX),
+#endif
+#ifdef INT32_MAX
+    MVAL (INT32_MAX),
+#endif
+#ifdef INT64_MAX
+    MVAL (INT64_MAX),
+#endif
+#ifdef UINT8_MAX
+    MVAL (UINT8_MAX),
+#endif
+#ifdef UINT16_MAX
+    MVAL (UINT16_MAX),
+#endif
+#ifdef UINT32_MAX
+    MVAL (UINT32_MAX),
+#endif
+#ifdef UINT64_MAX
+    MVAL (UINT64_MAX),
+#endif
+    NULL
+  };
+]], [[
+  const char **mv;
+  for (mv = macro_values; *mv != NULL; mv++)
+    {
+      const char *value = *mv;
+      /* Test whether it looks like a cast expression.  */
+      if (strncmp (value, "((unsigned int)"/*)*/, 15) == 0
+          || strncmp (value, "((unsigned short)"/*)*/, 17) == 0
+          || strncmp (value, "((unsigned char)"/*)*/, 16) == 0
+          || strncmp (value, "((int)"/*)*/, 6) == 0
+          || strncmp (value, "((signed short)"/*)*/, 15) == 0
+          || strncmp (value, "((signed char)"/*)*/, 14) == 0)
+        return 1;
+    }
+  return 0;
+]])],
+              [gl_cv_header_working_stdint_h=yes],
+              [],
+              [dnl When cross-compiling, assume it works.
+               gl_cv_header_working_stdint_h=yes
+              ])
+         ])
+      ])
   fi
   if test "$gl_cv_header_working_stdint_h" = yes; then
     STDINT_H=
@@ -229,7 +297,7 @@
     gl_STDINT_TYPE_PROPERTIES
     STDINT_H=stdint.h
   fi
-  AC_SUBST(STDINT_H)
+  AC_SUBST([STDINT_H])
 ])
 
 dnl gl_STDINT_BITSIZEOF(TYPES, INCLUDES)
@@ -292,7 +360,7 @@
     eval result=\$gl_cv_type_${gltype}_signed
     GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`
     if test "$result" = yes; then
-      AC_DEFINE_UNQUOTED([HAVE_SIGNED_${GLTYPE}], 1)
+      AC_DEFINE_UNQUOTED([HAVE_SIGNED_${GLTYPE}], [1])
       eval HAVE_SIGNED_${GLTYPE}=1
     else
       eval HAVE_SIGNED_${GLTYPE}=0
@@ -348,7 +416,7 @@
     eval result=\$gl_cv_type_${gltype}_suffix
     test "$result" = no && result=
     eval ${GLTYPE}_SUFFIX=\$result
-    AC_DEFINE_UNQUOTED([${GLTYPE}_SUFFIX], $result)
+    AC_DEFINE_UNQUOTED([${GLTYPE}_SUFFIX], [$result])
   done
   m4_foreach_w([gltype], [$1],
     [AC_SUBST(translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX])])
@@ -373,13 +441,22 @@
 dnl of interest to stdint.in.h.
 AC_DEFUN([gl_STDINT_TYPE_PROPERTIES],
 [
-  gl_STDINT_BITSIZEOF([ptrdiff_t sig_atomic_t size_t wchar_t wint_t],
+  AC_REQUIRE([gl_MULTIARCH])
+  if test $APPLE_UNIVERSAL_BUILD = 0; then
+    gl_STDINT_BITSIZEOF([ptrdiff_t size_t],
+      [gl_STDINT_INCLUDES])
+  fi
+  gl_STDINT_BITSIZEOF([sig_atomic_t wchar_t wint_t],
     [gl_STDINT_INCLUDES])
   gl_CHECK_TYPES_SIGNED([sig_atomic_t wchar_t wint_t],
     [gl_STDINT_INCLUDES])
   gl_cv_type_ptrdiff_t_signed=yes
   gl_cv_type_size_t_signed=no
-  gl_INTEGER_TYPE_SUFFIX([ptrdiff_t sig_atomic_t size_t wchar_t wint_t],
+  if test $APPLE_UNIVERSAL_BUILD = 0; then
+    gl_INTEGER_TYPE_SUFFIX([ptrdiff_t size_t],
+      [gl_STDINT_INCLUDES])
+  fi
+  gl_INTEGER_TYPE_SUFFIX([sig_atomic_t wchar_t wint_t],
     [gl_STDINT_INCLUDES])
 ])
 

Modified: libprelude/trunk/libmissing/m4/stdint_h.m4
===================================================================
--- libprelude/trunk/libmissing/m4/stdint_h.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/stdint_h.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# stdint_h.m4 serial 6
-dnl Copyright (C) 1997-2004, 2006 Free Software Foundation, Inc.
+# stdint_h.m4 serial 8
+dnl Copyright (C) 1997-2004, 2006, 2008, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -11,15 +11,15 @@
 
 AC_DEFUN([gl_AC_HEADER_STDINT_H],
 [
-  AC_CACHE_CHECK([for stdint.h], gl_cv_header_stdint_h,
+  AC_CACHE_CHECK([for stdint.h], [gl_cv_header_stdint_h],
   [AC_TRY_COMPILE(
     [#include <sys/types.h>
 #include <stdint.h>],
     [uintmax_t i = (uintmax_t) -1; return !i;],
-    gl_cv_header_stdint_h=yes,
-    gl_cv_header_stdint_h=no)])
+    [gl_cv_header_stdint_h=yes],
+    [gl_cv_header_stdint_h=no])])
   if test $gl_cv_header_stdint_h = yes; then
-    AC_DEFINE_UNQUOTED(HAVE_STDINT_H_WITH_UINTMAX, 1,
+    AC_DEFINE_UNQUOTED([HAVE_STDINT_H_WITH_UINTMAX], [1],
       [Define if <stdint.h> exists, doesn't clash with <sys/types.h>,
        and declares uintmax_t. ])
   fi

Modified: libprelude/trunk/libmissing/m4/stdio_h.m4
===================================================================
--- libprelude/trunk/libmissing/m4/stdio_h.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/stdio_h.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# stdio_h.m4 serial 14
-dnl Copyright (C) 2007-2008 Free Software Foundation, Inc.
+# stdio_h.m4 serial 15
+dnl Copyright (C) 2007-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -53,6 +53,8 @@
   GNULIB_VPRINTF_POSIX=0;        AC_SUBST([GNULIB_VPRINTF_POSIX])
   GNULIB_VSNPRINTF=0;            AC_SUBST([GNULIB_VSNPRINTF])
   GNULIB_VSPRINTF_POSIX=0;       AC_SUBST([GNULIB_VSPRINTF_POSIX])
+  GNULIB_DPRINTF=0;              AC_SUBST([GNULIB_DPRINTF])
+  GNULIB_VDPRINTF=0;             AC_SUBST([GNULIB_VDPRINTF])
   GNULIB_VASPRINTF=0;            AC_SUBST([GNULIB_VASPRINTF])
   GNULIB_OBSTACK_PRINTF=0;       AC_SUBST([GNULIB_OBSTACK_PRINTF])
   GNULIB_OBSTACK_PRINTF_POSIX=0; AC_SUBST([GNULIB_OBSTACK_PRINTF_POSIX])
@@ -86,6 +88,10 @@
   HAVE_DECL_VSNPRINTF=1;         AC_SUBST([HAVE_DECL_VSNPRINTF])
   REPLACE_SPRINTF=0;             AC_SUBST([REPLACE_SPRINTF])
   REPLACE_VSPRINTF=0;            AC_SUBST([REPLACE_VSPRINTF])
+  HAVE_DPRINTF=1;                AC_SUBST([HAVE_DPRINTF])
+  REPLACE_DPRINTF=0;             AC_SUBST([REPLACE_DPRINTF])
+  HAVE_VDPRINTF=1;               AC_SUBST([HAVE_VDPRINTF])
+  REPLACE_VDPRINTF=0;            AC_SUBST([REPLACE_VDPRINTF])
   HAVE_VASPRINTF=1;              AC_SUBST([HAVE_VASPRINTF])
   REPLACE_VASPRINTF=0;           AC_SUBST([REPLACE_VASPRINTF])
   HAVE_DECL_OBSTACK_PRINTF=1;    AC_SUBST([HAVE_DECL_OBSTACK_PRINTF])

Modified: libprelude/trunk/libmissing/m4/stdlib_h.m4
===================================================================
--- libprelude/trunk/libmissing/m4/stdlib_h.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/stdlib_h.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# stdlib_h.m4 serial 13
-dnl Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+# stdlib_h.m4 serial 15
+dnl Copyright (C) 2007-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -8,9 +8,20 @@
 [
   AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
   gl_CHECK_NEXT_HEADERS([stdlib.h])
+  AC_CHECK_HEADERS([random.h], [], [], [AC_INCLUDES_DEFAULT])
+  if test $ac_cv_header_random_h = yes; then
+    HAVE_RANDOM_H=1
+  else
+    HAVE_RANDOM_H=0
+  fi
+  AC_SUBST([HAVE_RANDOM_H])
   AC_CHECK_TYPES([struct random_data],
     [], [HAVE_STRUCT_RANDOM_DATA=0],
-    [[#include <stdlib.h>]])
+    [[#include <stdlib.h>
+      #if HAVE_RANDOM_H
+      # include <random.h>
+      #endif
+    ]])
 ])
 
 AC_DEFUN([gl_STDLIB_MODULE_INDICATOR],

Modified: libprelude/trunk/libmissing/m4/strcase.m4
===================================================================
--- libprelude/trunk/libmissing/m4/strcase.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/strcase.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# strcase.m4 serial 9
-dnl Copyright (C) 2002, 2005-2008 Free Software Foundation, Inc.
+# strcase.m4 serial 10
+dnl Copyright (C) 2002, 2005-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -13,7 +13,7 @@
 AC_DEFUN([gl_FUNC_STRCASECMP],
 [
   AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS])
-  AC_REPLACE_FUNCS(strcasecmp)
+  AC_REPLACE_FUNCS([strcasecmp])
   if test $ac_cv_func_strcasecmp = no; then
     HAVE_STRCASECMP=0
     gl_PREREQ_STRCASECMP
@@ -23,11 +23,11 @@
 AC_DEFUN([gl_FUNC_STRNCASECMP],
 [
   AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS])
-  AC_REPLACE_FUNCS(strncasecmp)
+  AC_REPLACE_FUNCS([strncasecmp])
   if test $ac_cv_func_strncasecmp = no; then
     gl_PREREQ_STRNCASECMP
   fi
-  AC_CHECK_DECLS(strncasecmp)
+  AC_CHECK_DECLS([strncasecmp])
   if test $ac_cv_have_decl_strncasecmp = no; then
     HAVE_DECL_STRNCASECMP=0
   fi

Modified: libprelude/trunk/libmissing/m4/strdup.m4
===================================================================
--- libprelude/trunk/libmissing/m4/strdup.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/strdup.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,6 +1,6 @@
-# strdup.m4 serial 10
+# strdup.m4 serial 11
 
-dnl Copyright (C) 2002-2008 Free Software Foundation, Inc.
+dnl Copyright (C) 2002-2009 Free Software Foundation, Inc.
 
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -9,8 +9,8 @@
 AC_DEFUN([gl_FUNC_STRDUP],
 [
   AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
-  AC_REPLACE_FUNCS(strdup)
-  AC_CHECK_DECLS_ONCE(strdup)
+  AC_REPLACE_FUNCS([strdup])
+  AC_CHECK_DECLS_ONCE([strdup])
   if test $ac_cv_have_decl_strdup = no; then
     HAVE_DECL_STRDUP=0
   fi
@@ -25,9 +25,9 @@
     REPLACE_STRDUP=1
     AC_LIBOBJ([strdup])
   else
-    AC_REPLACE_FUNCS(strdup)
+    AC_REPLACE_FUNCS([strdup])
   fi
-  AC_CHECK_DECLS_ONCE(strdup)
+  AC_CHECK_DECLS_ONCE([strdup])
   if test $ac_cv_have_decl_strdup = no; then
     HAVE_DECL_STRDUP=0
   fi

Modified: libprelude/trunk/libmissing/m4/strndup.m4
===================================================================
--- libprelude/trunk/libmissing/m4/strndup.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/strndup.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# strndup.m4 serial 15
-dnl Copyright (C) 2002-2003, 2005-2008 Free Software Foundation, Inc.
+# strndup.m4 serial 16
+dnl Copyright (C) 2002-2003, 2005-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -16,7 +16,7 @@
   fi
 
   # AIX 4.3.3, AIX 5.1 have a function that fails to add the terminating '\0'.
-  AC_CACHE_CHECK([for working strndup], gl_cv_func_strndup,
+  AC_CACHE_CHECK([for working strndup], [gl_cv_func_strndup],
     [AC_RUN_IFELSE([
        AC_LANG_PROGRAM([[#include <string.h>
 			 #include <stdlib.h>]], [[
@@ -40,7 +40,7 @@
              [gl_cv_func_strndup=yes])],
           [gl_cv_func_strndup=no])])])
   if test $gl_cv_func_strndup = yes; then
-    AC_DEFINE([HAVE_STRNDUP], 1,
+    AC_DEFINE([HAVE_STRNDUP], [1],
       [Define if you have the strndup() function and it works.])
   else
     HAVE_STRNDUP=0

Modified: libprelude/trunk/libmissing/m4/strnlen.m4
===================================================================
--- libprelude/trunk/libmissing/m4/strnlen.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/strnlen.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# strnlen.m4 serial 9
-dnl Copyright (C) 2002-2003, 2005-2007 Free Software Foundation, Inc.
+# strnlen.m4 serial 10
+dnl Copyright (C) 2002-2003, 2005-2007, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -20,8 +20,8 @@
     # This is necessary because automake-1.6.1 doesn't understand
     # that the above use of AC_FUNC_STRNLEN means we may have to use
     # lib/strnlen.c.
-    #AC_LIBOBJ(strnlen)
-    AC_DEFINE(strnlen, rpl_strnlen,
+    #AC_LIBOBJ([strnlen])
+    AC_DEFINE([strnlen], [rpl_strnlen],
       [Define to rpl_strnlen if the replacement function should be used.])
     gl_PREREQ_STRNLEN
   fi

Modified: libprelude/trunk/libmissing/m4/strptime.m4
===================================================================
--- libprelude/trunk/libmissing/m4/strptime.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/strptime.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# strptime.m4 serial 4
-dnl Copyright (C) 2007 Free Software Foundation, Inc.
+# strptime.m4 serial 5
+dnl Copyright (C) 2007, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -8,7 +8,7 @@
 [
   AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
   AC_REQUIRE([AC_C_RESTRICT])
-  AC_REPLACE_FUNCS(strptime)
+  AC_REPLACE_FUNCS([strptime])
   AC_REQUIRE([gl_TM_GMTOFF])
   if test $ac_cv_func_strptime = yes; then
     REPLACE_STRPTIME=0

Modified: libprelude/trunk/libmissing/m4/strsep.m4
===================================================================
--- libprelude/trunk/libmissing/m4/strsep.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/strsep.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# strsep.m4 serial 8
-dnl Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc.
+# strsep.m4 serial 9
+dnl Copyright (C) 2002, 2003, 2004, 2007, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -13,7 +13,7 @@
   AC_REQUIRE([AC_C_RESTRICT])
 
   AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
-  AC_REPLACE_FUNCS(strsep)
+  AC_REPLACE_FUNCS([strsep])
   if test $ac_cv_func_strsep = no; then
     HAVE_STRSEP=0
     gl_PREREQ_STRSEP

Modified: libprelude/trunk/libmissing/m4/sys_select_h.m4
===================================================================
--- libprelude/trunk/libmissing/m4/sys_select_h.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/sys_select_h.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# sys_select_h.m4 serial 6
-dnl Copyright (C) 2006-2008 Free Software Foundation, Inc.
+# sys_select_h.m4 serial 7
+dnl Copyright (C) 2006-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -42,4 +42,6 @@
 AC_DEFUN([gl_SYS_SELECT_H_DEFAULTS],
 [
   GNULIB_SELECT=0; AC_SUBST([GNULIB_SELECT])
+  dnl Assume proper GNU behavior unless another module says otherwise.
+  REPLACE_SELECT=0; AC_SUBST([REPLACE_SELECT])
 ])

Modified: libprelude/trunk/libmissing/m4/threadlib.m4
===================================================================
--- libprelude/trunk/libmissing/m4/threadlib.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/threadlib.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# threadlib.m4 serial 1 (gettext-0.18)
-dnl Copyright (C) 2005-2008 Free Software Foundation, Inc.
+# threadlib.m4 serial 3 (gettext-0.18)
+dnl Copyright (C) 2005-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -45,7 +45,7 @@
     [AC_REQUIRE([AC_GNU_SOURCE])])
   dnl Check for multithreading.
   m4_divert_text([DEFAULTS], [gl_use_threads_default=])
-  AC_ARG_ENABLE(threads,
+  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],
@@ -104,7 +104,8 @@
     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)
+      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)
@@ -122,7 +123,7 @@
         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,
+          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
@@ -130,19 +131,19 @@
              # pthread_create will actually create a thread.
              case "$host_os" in
                solaris* | hpux*)
-                 AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], 1,
+                 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,
+          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,
+            AC_CHECK_LIB([c_r], [pthread_kill],
               [gl_have_pthread=yes
                LIBTHREAD=-lc_r LTLIBTHREAD=-lc_r
                LIBMULTITHREAD=-lc_r LTLIBMULTITHREAD=-lc_r])
@@ -150,11 +151,11 @@
         fi
         if test -n "$gl_have_pthread"; then
           gl_threads_api=posix
-          AC_DEFINE([USE_POSIX_THREADS], 1,
+          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,
+              AC_DEFINE([USE_POSIX_THREADS_WEAK], [1],
                 [Define if references to the POSIX multithreading library should be made weak.])
               LIBTHREAD=
               LTLIBTHREAD=
@@ -179,10 +180,10 @@
           LTLIBTHREAD=-lthread
           LIBMULTITHREAD="$LIBTHREAD"
           LTLIBMULTITHREAD="$LTLIBTHREAD"
-          AC_DEFINE([USE_SOLARIS_THREADS], 1,
+          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,
+            AC_DEFINE([USE_SOLARIS_THREADS_WEAK], [1],
               [Define if references to the old Solaris multithreading library should be made weak.])
             LIBTHREAD=
             LTLIBTHREAD=
@@ -192,11 +193,11 @@
     fi
     if test "$gl_use_threads" = pth; then
       gl_save_CPPFLAGS="$CPPFLAGS"
-      AC_LIB_LINKFLAGS(pth)
+      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)
+      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
@@ -204,11 +205,11 @@
         LTLIBTHREAD="$LTLIBPTH"
         LIBMULTITHREAD="$LIBTHREAD"
         LTLIBMULTITHREAD="$LTLIBTHREAD"
-        AC_DEFINE([USE_PTH_THREADS], 1,
+        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,
+            AC_DEFINE([USE_PTH_THREADS_WEAK], [1],
               [Define if references to the GNU Pth multithreading library should be made weak.])
             LIBTHREAD=
             LTLIBTHREAD=
@@ -226,7 +227,7 @@
              esac
            }; then
           gl_threads_api=win32
-          AC_DEFINE([USE_WIN32_THREADS], 1,
+          AC_DEFINE([USE_WIN32_THREADS], [1],
             [Define if the Win32 multithreading API can be used.])
         fi
       fi
@@ -234,10 +235,10 @@
   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_SUBST([LIBTHREAD])
+  AC_SUBST([LTLIBTHREAD])
+  AC_SUBST([LIBMULTITHREAD])
+  AC_SUBST([LTLIBMULTITHREAD])
 ])
 
 AC_DEFUN([gl_THREADLIB],

Modified: libprelude/trunk/libmissing/m4/timegm.m4
===================================================================
--- libprelude/trunk/libmissing/m4/timegm.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/timegm.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# timegm.m4 serial 5
-dnl Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+# timegm.m4 serial 6
+dnl Copyright (C) 2003, 2007, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -13,7 +13,7 @@
     AC_LIBOBJ([timegm])
     ac_cv_func_timegm=no
   else
-    AC_REPLACE_FUNCS(timegm)
+    AC_REPLACE_FUNCS([timegm])
   fi
   REPLACE_TIMEGM=1
   if test $ac_cv_func_timegm = yes; then
@@ -29,7 +29,7 @@
   AC_REQUIRE([gl_TIME_R])
   AC_REQUIRE([gl_FUNC_MKTIME])
   if test $ac_cv_func_working_mktime = yes; then
-    AC_CHECK_FUNC(__mktime_internal, ,
+    AC_CHECK_FUNC([__mktime_internal], ,
       [# mktime works but it doesn't export __mktime_internal,
        # so we need to substitute our own mktime implementation.
        AC_LIBOBJ([mktime])

Modified: libprelude/trunk/libmissing/m4/tm_gmtoff.m4
===================================================================
--- libprelude/trunk/libmissing/m4/tm_gmtoff.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/tm_gmtoff.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# tm_gmtoff.m4 serial 2
-dnl Copyright (C) 2002 Free Software Foundation, Inc.
+# tm_gmtoff.m4 serial 3
+dnl Copyright (C) 2002, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -7,7 +7,7 @@
 AC_DEFUN([gl_TM_GMTOFF],
 [
  AC_CHECK_MEMBER([struct tm.tm_gmtoff],
-                 [AC_DEFINE(HAVE_TM_GMTOFF, 1,
+                 [AC_DEFINE([HAVE_TM_GMTOFF], [1],
                             [Define if struct tm has the tm_gmtoff member.])],
                  ,
                  [#include <time.h>])

Added: libprelude/trunk/libmissing/m4/ungetc.m4
===================================================================
--- libprelude/trunk/libmissing/m4/ungetc.m4	                        (rev 0)
+++ libprelude/trunk/libmissing/m4/ungetc.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,36 @@
+# ungetc.m4 serial 1
+dnl Copyright (C) 2009 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN_ONCE([gl_FUNC_UNGETC_WORKS],
+[
+  AC_REQUIRE([AC_PROG_CC])
+
+  AC_CACHE_CHECK([whether ungetc works on arbitrary bytes],
+    [gl_cv_func_ungetc_works],
+    [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+#include <stdio.h>
+      ]], [FILE *f; long l;
+	   if (!(f = fopen ("conftest.tmp", "w+"))) return 1;
+	   if (fputs ("abc", f) < 0) return 2;
+	   rewind (f);
+	   if (fgetc (f) != 'a') return 3;
+	   if (fgetc (f) != 'b') return 4;
+	   if (ungetc ('d', f) != 'd') return 5;
+	   if (ftell (f) != 1) return 6;
+	   if (fgetc (f) != 'd') return 7;
+	   if (ftell (f) != 2) return 8;
+	   if (fseek (f, 0, SEEK_CUR) != 0) return 9;
+	   if (ftell (f) != 2) return 10;
+	   if (fgetc (f) != 'c') return 11;
+	   fclose (f); remove ("conftest.tmp");])],
+	[gl_cv_func_ungetc_works=yes], [gl_cv_func_ungetc_works=no],
+	[gl_cv_func_ungetc_works='guessing no'])
+    ])
+  if test "$gl_cv_func_ungetc_works" != yes; then
+    AC_DEFINE([FUNC_UNGETC_BROKEN], [1],
+      [Define to 1 if ungetc is broken when used on arbitrary bytes.])
+  fi
+])

Modified: libprelude/trunk/libmissing/m4/unistd_h.m4
===================================================================
--- libprelude/trunk/libmissing/m4/unistd_h.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/unistd_h.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# unistd_h.m4 serial 16
-dnl Copyright (C) 2006-2008 Free Software Foundation, Inc.
+# unistd_h.m4 serial 17
+dnl Copyright (C) 2006-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -48,6 +48,7 @@
   GNULIB_GETPAGESIZE=0;      AC_SUBST([GNULIB_GETPAGESIZE])
   GNULIB_GETUSERSHELL=0;     AC_SUBST([GNULIB_GETUSERSHELL])
   GNULIB_LCHOWN=0;           AC_SUBST([GNULIB_LCHOWN])
+  GNULIB_LINK=0;             AC_SUBST([GNULIB_LINK])
   GNULIB_LSEEK=0;            AC_SUBST([GNULIB_LSEEK])
   GNULIB_READLINK=0;         AC_SUBST([GNULIB_READLINK])
   GNULIB_SLEEP=0;            AC_SUBST([GNULIB_SLEEP])
@@ -63,6 +64,7 @@
   HAVE_GETHOSTNAME=1;     AC_SUBST([HAVE_GETHOSTNAME])
   HAVE_GETPAGESIZE=1;     AC_SUBST([HAVE_GETPAGESIZE])
   HAVE_GETUSERSHELL=1;    AC_SUBST([HAVE_GETUSERSHELL])
+  HAVE_LINK=1;            AC_SUBST([HAVE_LINK])
   HAVE_READLINK=1;        AC_SUBST([HAVE_READLINK])
   HAVE_SLEEP=1;           AC_SUBST([HAVE_SLEEP])
   HAVE_DECL_ENVIRON=1;    AC_SUBST([HAVE_DECL_ENVIRON])

Modified: libprelude/trunk/libmissing/m4/vasnprintf.m4
===================================================================
--- libprelude/trunk/libmissing/m4/vasnprintf.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/vasnprintf.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# vasnprintf.m4 serial 25
-dnl Copyright (C) 2002-2004, 2006-2008 Free Software Foundation, Inc.
+# vasnprintf.m4 serial 28
+dnl Copyright (C) 2002-2004, 2006-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -20,7 +20,7 @@
   AC_LIBOBJ([printf-parse])
   AC_LIBOBJ([asnprintf])
   if test $ac_cv_func_vasnprintf = yes; then
-    AC_DEFINE([REPLACE_VASNPRINTF], 1,
+    AC_DEFINE([REPLACE_VASNPRINTF], [1],
       [Define if vasnprintf exists but is overridden by gnulib.])
   fi
   gl_PREREQ_PRINTF_ARGS
@@ -58,7 +58,7 @@
   AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
   AC_REQUIRE([gt_TYPE_WCHAR_T])
   AC_REQUIRE([gt_TYPE_WINT_T])
-  AC_CHECK_FUNCS(snprintf wcslen)
+  AC_CHECK_FUNCS([snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb])
   dnl Use the _snprintf function only if it is declared (because on NetBSD it
   dnl is defined as a weak alias of snprintf; we prefer to use the latter).
   AC_CHECK_DECLS([_snprintf], , , [#include <stdio.h>])
@@ -73,7 +73,7 @@
     *yes)
       ;;
     *)
-      AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], 1,
+      AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1],
         [Define if the vasnprintf implementation needs special code for
          'long double' arguments.])
       ;;
@@ -89,7 +89,7 @@
     *yes)
       ;;
     *)
-      AC_DEFINE([NEED_PRINTF_INFINITE_DOUBLE], 1,
+      AC_DEFINE([NEED_PRINTF_INFINITE_DOUBLE], [1],
         [Define if the vasnprintf implementation needs special code for
          infinite 'double' arguments.])
       ;;
@@ -110,7 +110,7 @@
         *yes)
           ;;
         *)
-          AC_DEFINE([NEED_PRINTF_INFINITE_LONG_DOUBLE], 1,
+          AC_DEFINE([NEED_PRINTF_INFINITE_LONG_DOUBLE], [1],
             [Define if the vasnprintf implementation needs special code for
              infinite 'long double' arguments.])
           ;;
@@ -127,7 +127,7 @@
     *yes)
       ;;
     *)
-      AC_DEFINE([NEED_PRINTF_DIRECTIVE_A], 1,
+      AC_DEFINE([NEED_PRINTF_DIRECTIVE_A], [1],
         [Define if the vasnprintf implementation needs special code for
          the 'a' and 'A' directives.])
       AC_CHECK_FUNCS([nl_langinfo])
@@ -143,13 +143,28 @@
     *yes)
       ;;
     *)
-      AC_DEFINE([NEED_PRINTF_DIRECTIVE_F], 1,
+      AC_DEFINE([NEED_PRINTF_DIRECTIVE_F], [1],
         [Define if the vasnprintf implementation needs special code for
          the 'F' directive.])
       ;;
   esac
 ])
 
+# Extra prerequisites of lib/vasnprintf.c for supporting the 'ls' directive.
+AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_LS],
+[
+  AC_REQUIRE([gl_PRINTF_DIRECTIVE_LS])
+  case "$gl_cv_func_printf_directive_ls" in
+    *yes)
+      ;;
+    *)
+      AC_DEFINE([NEED_PRINTF_DIRECTIVE_LS], [1],
+        [Define if the vasnprintf implementation needs special code for
+         the 'ls' directive.])
+      ;;
+  esac
+])
+
 # Extra prerequisites of lib/vasnprintf.c for supporting the ' flag.
 AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_GROUPING],
 [
@@ -158,7 +173,7 @@
     *yes)
       ;;
     *)
-      AC_DEFINE([NEED_PRINTF_FLAG_GROUPING], 1,
+      AC_DEFINE([NEED_PRINTF_FLAG_GROUPING], [1],
         [Define if the vasnprintf implementation needs special code for the
          ' flag.])
       ;;
@@ -173,7 +188,7 @@
     *yes)
       ;;
     *)
-      AC_DEFINE([NEED_PRINTF_FLAG_LEFTADJUST], 1,
+      AC_DEFINE([NEED_PRINTF_FLAG_LEFTADJUST], [1],
         [Define if the vasnprintf implementation needs special code for the
          '-' flag.])
       ;;
@@ -188,7 +203,7 @@
     *yes)
       ;;
     *)
-      AC_DEFINE([NEED_PRINTF_FLAG_ZERO], 1,
+      AC_DEFINE([NEED_PRINTF_FLAG_ZERO], [1],
         [Define if the vasnprintf implementation needs special code for the
          0 flag.])
       ;;
@@ -203,13 +218,13 @@
     *yes)
       ;;
     *)
-      AC_DEFINE([NEED_PRINTF_UNBOUNDED_PRECISION], 1,
+      AC_DEFINE([NEED_PRINTF_UNBOUNDED_PRECISION], [1],
         [Define if the vasnprintf implementation needs special code for
          supporting large precisions without arbitrary bounds.])
-      AC_DEFINE([NEED_PRINTF_DOUBLE], 1,
+      AC_DEFINE([NEED_PRINTF_DOUBLE], [1],
         [Define if the vasnprintf implementation needs special code for
          'double' arguments.])
-      AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], 1,
+      AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1],
         [Define if the vasnprintf implementation needs special code for
          'long double' arguments.])
       ;;
@@ -225,13 +240,13 @@
     *yes)
       ;;
     *)
-      AC_DEFINE([NEED_PRINTF_ENOMEM], 1,
+      AC_DEFINE([NEED_PRINTF_ENOMEM], [1],
         [Define if the vasnprintf implementation needs special code for
          surviving out-of-memory conditions.])
-      AC_DEFINE([NEED_PRINTF_DOUBLE], 1,
+      AC_DEFINE([NEED_PRINTF_DOUBLE], [1],
         [Define if the vasnprintf implementation needs special code for
          'double' arguments.])
-      AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], 1,
+      AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1],
         [Define if the vasnprintf implementation needs special code for
          'long double' arguments.])
       ;;
@@ -247,6 +262,7 @@
   gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE
   gl_PREREQ_VASNPRINTF_DIRECTIVE_A
   gl_PREREQ_VASNPRINTF_DIRECTIVE_F
+  gl_PREREQ_VASNPRINTF_DIRECTIVE_LS
   gl_PREREQ_VASNPRINTF_FLAG_GROUPING
   gl_PREREQ_VASNPRINTF_FLAG_LEFTADJUST
   gl_PREREQ_VASNPRINTF_FLAG_ZERO

Modified: libprelude/trunk/libmissing/m4/wchar.m4
===================================================================
--- libprelude/trunk/libmissing/m4/wchar.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/wchar.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -7,7 +7,7 @@
 
 dnl Written by Eric Blake.
 
-# wchar.m4 serial 6
+# wchar.m4 serial 22
 
 AC_DEFUN([gl_WCHAR_H],
 [
@@ -61,9 +61,39 @@
 
 AC_DEFUN([gl_WCHAR_H_DEFAULTS],
 [
-  GNULIB_WCWIDTH=0; AC_SUBST([GNULIB_WCWIDTH])
+  GNULIB_BTOWC=0;      AC_SUBST([GNULIB_BTOWC])
+  GNULIB_WCTOB=0;      AC_SUBST([GNULIB_WCTOB])
+  GNULIB_MBSINIT=0;    AC_SUBST([GNULIB_MBSINIT])
+  GNULIB_MBRTOWC=0;    AC_SUBST([GNULIB_MBRTOWC])
+  GNULIB_MBRLEN=0;     AC_SUBST([GNULIB_MBRLEN])
+  GNULIB_MBSRTOWCS=0;  AC_SUBST([GNULIB_MBSRTOWCS])
+  GNULIB_MBSNRTOWCS=0; AC_SUBST([GNULIB_MBSNRTOWCS])
+  GNULIB_WCRTOMB=0;    AC_SUBST([GNULIB_WCRTOMB])
+  GNULIB_WCSRTOMBS=0;  AC_SUBST([GNULIB_WCSRTOMBS])
+  GNULIB_WCSNRTOMBS=0; AC_SUBST([GNULIB_WCSNRTOMBS])
+  GNULIB_WCWIDTH=0;    AC_SUBST([GNULIB_WCWIDTH])
   dnl Assume proper GNU behavior unless another module says otherwise.
+  HAVE_BTOWC=1;        AC_SUBST([HAVE_BTOWC])
+  HAVE_MBSINIT=1;      AC_SUBST([HAVE_MBSINIT])
+  HAVE_MBRTOWC=1;      AC_SUBST([HAVE_MBRTOWC])
+  HAVE_MBRLEN=1;       AC_SUBST([HAVE_MBRLEN])
+  HAVE_MBSRTOWCS=1;    AC_SUBST([HAVE_MBSRTOWCS])
+  HAVE_MBSNRTOWCS=1;   AC_SUBST([HAVE_MBSNRTOWCS])
+  HAVE_WCRTOMB=1;      AC_SUBST([HAVE_WCRTOMB])
+  HAVE_WCSRTOMBS=1;    AC_SUBST([HAVE_WCSRTOMBS])
+  HAVE_WCSNRTOMBS=1;   AC_SUBST([HAVE_WCSNRTOMBS])
+  HAVE_DECL_WCTOB=1;   AC_SUBST([HAVE_DECL_WCTOB])
   HAVE_DECL_WCWIDTH=1; AC_SUBST([HAVE_DECL_WCWIDTH])
+  REPLACE_MBSTATE_T=0; AC_SUBST([REPLACE_MBSTATE_T])
+  REPLACE_BTOWC=0;     AC_SUBST([REPLACE_BTOWC])
+  REPLACE_WCTOB=0;     AC_SUBST([REPLACE_WCTOB])
+  REPLACE_MBSINIT=0;   AC_SUBST([REPLACE_MBSINIT])
+  REPLACE_MBRTOWC=0;   AC_SUBST([REPLACE_MBRTOWC])
+  REPLACE_MBRLEN=0;    AC_SUBST([REPLACE_MBRLEN])
+  REPLACE_MBSRTOWCS=0; AC_SUBST([REPLACE_MBSRTOWCS])
+  REPLACE_MBSNRTOWCS=0;AC_SUBST([REPLACE_MBSNRTOWCS])
+  REPLACE_WCRTOMB=0;   AC_SUBST([REPLACE_WCRTOMB])
+  REPLACE_WCSRTOMBS=0; AC_SUBST([REPLACE_WCSRTOMBS])
   REPLACE_WCWIDTH=0;   AC_SUBST([REPLACE_WCWIDTH])
   WCHAR_H='';          AC_SUBST([WCHAR_H])
 ])

Modified: libprelude/trunk/libmissing/m4/wchar_t.m4
===================================================================
--- libprelude/trunk/libmissing/m4/wchar_t.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/wchar_t.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# wchar_t.m4 serial 1 (gettext-0.12)
-dnl Copyright (C) 2002-2003 Free Software Foundation, Inc.
+# wchar_t.m4 serial 3 (gettext-0.18)
+dnl Copyright (C) 2002-2003, 2008, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -10,11 +10,11 @@
 
 AC_DEFUN([gt_TYPE_WCHAR_T],
 [
-  AC_CACHE_CHECK([for wchar_t], gt_cv_c_wchar_t,
+  AC_CACHE_CHECK([for wchar_t], [gt_cv_c_wchar_t],
     [AC_TRY_COMPILE([#include <stddef.h>
        wchar_t foo = (wchar_t)'\0';], ,
-       gt_cv_c_wchar_t=yes, gt_cv_c_wchar_t=no)])
+       [gt_cv_c_wchar_t=yes], [gt_cv_c_wchar_t=no])])
   if test $gt_cv_c_wchar_t = yes; then
-    AC_DEFINE(HAVE_WCHAR_T, 1, [Define if you have the 'wchar_t' type.])
+    AC_DEFINE([HAVE_WCHAR_T], [1], [Define if you have the 'wchar_t' type.])
   fi
 ])

Added: libprelude/trunk/libmissing/m4/wcrtomb.m4
===================================================================
--- libprelude/trunk/libmissing/m4/wcrtomb.m4	                        (rev 0)
+++ libprelude/trunk/libmissing/m4/wcrtomb.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,88 @@
+# wcrtomb.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_WCRTOMB],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+
+  AC_REQUIRE([AC_TYPE_MBSTATE_T])
+  AC_CHECK_FUNCS_ONCE([wcrtomb])
+  if test $ac_cv_func_wcrtomb = no; then
+    HAVE_WCRTOMB=0
+  else
+
+    dnl On OSF/1 5.1 and Solaris 10, wcrtomb (NULL, 0, NULL) sometimes
+    dnl returns 0 instead of 1.
+    AC_REQUIRE([AC_PROG_CC])
+    AC_REQUIRE([gt_LOCALE_FR])
+    AC_REQUIRE([gt_LOCALE_FR_UTF8])
+    AC_REQUIRE([gt_LOCALE_JA])
+    AC_REQUIRE([gt_LOCALE_ZH_CN])
+    AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+    AC_CACHE_CHECK([whether wcrtomb return value is correct],
+      [gl_cv_func_wcrtomb_retval],
+      [
+        dnl Initial guess, used when cross-compiling or when no suitable locale
+        dnl is present.
+changequote(,)dnl
+        case "$host_os" in
+                           # Guess no on OSF/1 and Solaris.
+          osf* | solaris*) gl_cv_func_wcrtomb_retval="guessing no" ;;
+                           # Guess yes otherwise.
+          *)               gl_cv_func_wcrtomb_retval="guessing yes" ;;
+        esac
+changequote([,])dnl
+        if test $LOCALE_FR != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none || test $LOCALE_ZH_CN != none; then
+          AC_TRY_RUN([
+#include <locale.h>
+#include <stdio.h>
+#include <string.h>
+#include <wchar.h>
+int main ()
+{
+  if (setlocale (LC_ALL, "$LOCALE_FR") != NULL)
+    {
+      if (wcrtomb (NULL, 0, NULL) != 1)
+        return 1;
+    }
+  if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
+    {
+      if (wcrtomb (NULL, 0, NULL) != 1)
+        return 1;
+    }
+  if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
+    {
+      if (wcrtomb (NULL, 0, NULL) != 1)
+        return 1;
+    }
+  if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
+    {
+      if (wcrtomb (NULL, 0, NULL) != 1)
+        return 1;
+    }
+  return 0;
+}],
+            [gl_cv_func_wcrtomb_retval=yes],
+            [gl_cv_func_wcrtomb_retval=no],
+            [])
+        fi
+      ])
+    case "$gl_cv_func_wcrtomb_retval" in
+      *yes) ;;
+      *) REPLACE_WCRTOMB=1 ;;
+    esac
+  fi
+  if test $HAVE_WCRTOMB = 0 || test $REPLACE_WCRTOMB = 1; then
+    gl_REPLACE_WCHAR_H
+    AC_LIBOBJ([wcrtomb])
+    gl_PREREQ_WCRTOMB
+  fi
+])
+
+# Prerequisites of lib/wcrtomb.c.
+AC_DEFUN([gl_PREREQ_WCRTOMB], [
+  :
+])

Added: libprelude/trunk/libmissing/m4/wctob.m4
===================================================================
--- libprelude/trunk/libmissing/m4/wctob.m4	                        (rev 0)
+++ libprelude/trunk/libmissing/m4/wctob.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,91 @@
+# wctob.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_FUNC_WCTOB],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+
+  AC_CHECK_FUNCS_ONCE([wctob])
+  if test $ac_cv_func_wctob = no; then
+    HAVE_DECL_WCTOB=0
+    gl_REPLACE_WCHAR_H
+    AC_LIBOBJ([wctob])
+    gl_PREREQ_WCTOB
+  else
+
+    dnl Solaris 9 has the wctob() function but it does not work.
+    AC_REQUIRE([AC_PROG_CC])
+    AC_REQUIRE([gt_LOCALE_FR])
+    AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+    AC_CACHE_CHECK([whether wctob works],
+      [gl_cv_func_wctob_works],
+      [
+        dnl Initial guess, used when cross-compiling or when no suitable locale
+        dnl is present.
+changequote(,)dnl
+        case "$host_os" in
+            # Guess no on Solaris <= 9.
+          solaris2.[1-9] | solaris2.[1-9].*)
+            gl_cv_func_wctob_works="guessing no" ;;
+            # Guess yes otherwise.
+          *) gl_cv_func_wctob_works="guessing yes" ;;
+        esac
+changequote([,])dnl
+        if test $LOCALE_FR != none; then
+          AC_TRY_RUN([
+#include <locale.h>
+#include <string.h>
+#include <wchar.h>
+int main ()
+{
+  if (setlocale (LC_ALL, "$LOCALE_FR") != NULL)
+    {
+      wchar_t wc;
+
+      if (mbtowc (&wc, "\374", 1) == 1)
+        if (wctob (wc) != (unsigned char) '\374')
+          return 1;
+    }
+  return 0;
+}],
+            [gl_cv_func_wctob_works=yes],
+            [gl_cv_func_wctob_works=no],
+            [])
+        fi
+      ])
+    case "$gl_cv_func_wctob_works" in
+      *yes) ;;
+      *) REPLACE_WCTOB=1 ;;
+    esac
+    if test $REPLACE_WCTOB = 1; then
+      gl_REPLACE_WCHAR_H
+      AC_LIBOBJ([wctob])
+      gl_PREREQ_WCTOB
+    else
+
+      dnl IRIX 6.5 has the wctob() function but does not declare it.
+      AC_CHECK_DECLS([wctob], [], [], [
+/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
+   <wchar.h>.
+   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be included
+   before <wchar.h>.  */
+#include <stddef.h>
+#include <stdio.h>
+#include <time.h>
+#include <wchar.h>
+])
+      if test $ac_cv_have_decl_wctob != yes; then
+        HAVE_DECL_WCTOB=0
+        gl_REPLACE_WCHAR_H
+      fi
+    fi
+  fi
+])
+
+# Prerequisites of lib/wctob.c.
+AC_DEFUN([gl_PREREQ_WCTOB], [
+  :
+])

Modified: libprelude/trunk/libmissing/m4/wint_t.m4
===================================================================
--- libprelude/trunk/libmissing/m4/wint_t.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/wint_t.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# wint_t.m4 serial 2 (gettext-0.17)
-dnl Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+# wint_t.m4 serial 4 (gettext-0.18)
+dnl Copyright (C) 2003, 2007-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -10,7 +10,7 @@
 
 AC_DEFUN([gt_TYPE_WINT_T],
 [
-  AC_CACHE_CHECK([for wint_t], gt_cv_c_wint_t,
+  AC_CACHE_CHECK([for wint_t], [gt_cv_c_wint_t],
     [AC_TRY_COMPILE([
 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
    <wchar.h>.
@@ -21,8 +21,8 @@
 #include <time.h>
 #include <wchar.h>
        wint_t foo = (wchar_t)'\0';], ,
-       gt_cv_c_wint_t=yes, gt_cv_c_wint_t=no)])
+       [gt_cv_c_wint_t=yes], [gt_cv_c_wint_t=no])])
   if test $gt_cv_c_wint_t = yes; then
-    AC_DEFINE(HAVE_WINT_T, 1, [Define if you have the 'wint_t' type.])
+    AC_DEFINE([HAVE_WINT_T], [1], [Define if you have the 'wint_t' type.])
   fi
 ])

Modified: libprelude/trunk/libmissing/m4/xsize.m4
===================================================================
--- libprelude/trunk/libmissing/m4/xsize.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/xsize.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# xsize.m4 serial 3
-dnl Copyright (C) 2003-2004 Free Software Foundation, Inc.
+# xsize.m4 serial 4
+dnl Copyright (C) 2003-2004, 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.
@@ -9,5 +9,5 @@
   dnl Prerequisites of lib/xsize.h.
   AC_REQUIRE([gl_SIZE_MAX])
   AC_REQUIRE([AC_C_INLINE])
-  AC_CHECK_HEADERS(stdint.h)
+  AC_CHECK_HEADERS([stdint.h])
 ])

Modified: libprelude/trunk/libmissing/m4/yield.m4
===================================================================
--- libprelude/trunk/libmissing/m4/yield.m4	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/m4/yield.m4	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
-# yield.m4 serial 1
-dnl Copyright (C) 2005-2008 Free Software Foundation, Inc.
+# yield.m4 serial 2
+dnl Copyright (C) 2005-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -11,9 +11,9 @@
   YIELD_LIB=
   if test $gl_threads_api = posix; then
     dnl Solaris has sched_yield in librt, not in libpthread or libc.
-    AC_CHECK_LIB(rt, sched_yield, [YIELD_LIB=-lrt],
+    AC_CHECK_LIB([rt], [sched_yield], [YIELD_LIB=-lrt],
       [dnl Solaris 2.5.1, 2.6 has sched_yield in libposix4, not librt.
-       AC_CHECK_LIB(posix4, sched_yield, [YIELD_LIB=-lposix4])])
+       AC_CHECK_LIB([posix4], [sched_yield], [YIELD_LIB=-lposix4])])
   fi
   AC_SUBST([YIELD_LIB])
 ])

Added: libprelude/trunk/libmissing/mbrtowc.c
===================================================================
--- libprelude/trunk/libmissing/mbrtowc.c	                        (rev 0)
+++ libprelude/trunk/libmissing/mbrtowc.c	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,386 @@
+/* Convert multibyte character to wide character.
+   Copyright (C) 1999-2002, 2005-2009 Free Software Foundation, Inc.
+   Written by Bruno Haible <[email protected]>, 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 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <wchar.h>
+
+#if GNULIB_defined_mbstate_t
+/* Implement mbrtowc() on top of mbtowc().  */
+
+# include <errno.h>
+# include <stdlib.h>
+
+# include "localcharset.h"
+# include "streq.h"
+# include "verify.h"
+
+
+verify (sizeof (mbstate_t) >= 4);
+
+static char internal_state[4];
+
+size_t
+mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
+{
+  char *pstate = (char *)ps;
+
+  if (pstate == NULL)
+    pstate = internal_state;
+
+  if (s == NULL)
+    {
+      pwc = NULL;
+      s = "";
+      n = 1;
+    }
+
+  if (n == 0)
+    return (size_t)(-2);
+
+  /* Here n > 0.  */
+  {
+    size_t nstate = pstate[0];
+    char buf[4];
+    const char *p;
+    size_t m;
+
+    switch (nstate)
+      {
+      case 0:
+	p = s;
+	m = n;
+	break;
+      case 3:
+	buf[2] = pstate[3];
+	/*FALLTHROUGH*/
+      case 2:
+	buf[1] = pstate[2];
+	/*FALLTHROUGH*/
+      case 1:
+	buf[0] = pstate[1];
+	p = buf;
+	m = nstate;
+	buf[m++] = s[0];
+	if (n >= 2 && m < 4)
+	  {
+	    buf[m++] = s[1];
+	    if (n >= 3 && m < 4)
+	      buf[m++] = s[2];
+	  }
+	break;
+      default:
+	errno = EINVAL;
+	return (size_t)(-1);
+      }
+
+    /* Here m > 0.  */
+
+# if __GLIBC__
+    /* Work around bug <http://sourceware.org/bugzilla/show_bug.cgi?id=9674> */
+    mbtowc (NULL, NULL, 0);
+# endif
+    {
+      int res = mbtowc (pwc, p, m);
+
+      if (res >= 0)
+	{
+	  if (pwc != NULL && ((*pwc == 0) != (res == 0)))
+	    abort ();
+	  if (nstate >= (res > 0 ? res : 1))
+	    abort ();
+	  res -= nstate;
+	  pstate[0] = 0;
+	  return res;
+	}
+
+      /* mbtowc does not distinguish between invalid and incomplete multibyte
+	 sequences.  But mbrtowc needs to make this distinction.
+	 There are two possible approaches:
+	   - Use iconv() and its return value.
+	   - Use built-in knowledge about the possible encodings.
+	 Given the low quality of implementation of iconv() on the systems that
+	 lack mbrtowc(), we use the second approach.
+	 The possible encodings are:
+	   - 8-bit encodings,
+	   - EUC-JP, EUC-KR, GB2312, EUC-TW, BIG5, GB18030, SJIS,
+	   - UTF-8.
+	 Use specialized code for each.  */
+      if (m >= 4 || m >= MB_CUR_MAX)
+	goto invalid;
+      /* Here MB_CUR_MAX > 1 and 0 < m < 4.  */
+      {
+	const char *encoding = locale_charset ();
+
+	if (STREQ (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0))
+	  {
+	    /* Cf. unistr/u8-mblen.c.  */
+	    unsigned char c = (unsigned char) p[0];
+
+	    if (c >= 0xc2)
+	      {
+		if (c < 0xe0)
+		  {
+		    if (m == 1)
+		      goto incomplete;
+		  }
+		else if (c < 0xf0)
+		  {
+		    if (m == 1)
+		      goto incomplete;
+		    if (m == 2)
+		      {
+			unsigned char c2 = (unsigned char) p[1];
+
+			if ((c2 ^ 0x80) < 0x40
+			    && (c >= 0xe1 || c2 >= 0xa0)
+			    && (c != 0xed || c2 < 0xa0))
+			  goto incomplete;
+		      }
+		  }
+		else if (c <= 0xf4)
+		  {
+		    if (m == 1)
+		      goto incomplete;
+		    else /* m == 2 || m == 3 */
+		      {
+			unsigned char c2 = (unsigned char) p[1];
+
+			if ((c2 ^ 0x80) < 0x40
+			    && (c >= 0xf1 || c2 >= 0x90)
+			    && (c < 0xf4 || (c == 0xf4 && c2 < 0x90)))
+			  {
+			    if (m == 2)
+			      goto incomplete;
+			    else /* m == 3 */
+			      {
+				unsigned char c3 = (unsigned char) p[2];
+
+				if ((c3 ^ 0x80) < 0x40)
+				  goto incomplete;
+			      }
+			  }
+		      }
+		  }
+	      }
+	    goto invalid;
+	  }
+
+	/* As a reference for this code, you can use the GNU libiconv
+	   implementation.  Look for uses of the RET_TOOFEW macro.  */
+
+	if (STREQ (encoding, "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0))
+	  {
+	    if (m == 1)
+	      {
+		unsigned char c = (unsigned char) p[0];
+
+		if ((c >= 0xa1 && c < 0xff) || c == 0x8e || c == 0x8f)
+		  goto incomplete;
+	      }
+	    if (m == 2)
+	      {
+		unsigned char c = (unsigned char) p[0];
+
+		if (c == 0x8f)
+		  {
+		    unsigned char c2 = (unsigned char) p[1];
+
+		    if (c2 >= 0xa1 && c2 < 0xff)
+		      goto incomplete;
+		  }
+	      }
+	    goto invalid;
+	  }
+	if (STREQ (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
+	    || STREQ (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0)
+	    || STREQ (encoding, "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0))
+	  {
+	    if (m == 1)
+	      {
+		unsigned char c = (unsigned char) p[0];
+
+		if (c >= 0xa1 && c < 0xff)
+		  goto incomplete;
+	      }
+	    goto invalid;
+	  }
+	if (STREQ (encoding, "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0))
+	  {
+	    if (m == 1)
+	      {
+		unsigned char c = (unsigned char) p[0];
+
+		if ((c >= 0xa1 && c < 0xff) || c == 0x8e)
+		  goto incomplete;
+	      }
+	    else /* m == 2 || m == 3 */
+	      {
+		unsigned char c = (unsigned char) p[0];
+
+		if (c == 0x8e)
+		  goto incomplete;
+	      }
+	    goto invalid;
+	  }
+	if (STREQ (encoding, "GB18030", 'G', 'B', '1', '8', '0', '3', '0', 0, 0))
+	  {
+	    if (m == 1)
+	      {
+		unsigned char c = (unsigned char) p[0];
+
+		if ((c >= 0x90 && c <= 0xe3) || (c >= 0xf8 && c <= 0xfe))
+		  goto incomplete;
+	      }
+	    else /* m == 2 || m == 3 */
+	      {
+		unsigned char c = (unsigned char) p[0];
+
+		if (c >= 0x90 && c <= 0xe3)
+		  {
+		    unsigned char c2 = (unsigned char) p[1];
+
+		    if (c2 >= 0x30 && c2 <= 0x39)
+		      {
+			if (m == 2)
+			  goto incomplete;
+			else /* m == 3 */
+			  {
+			    unsigned char c3 = (unsigned char) p[2];
+
+			    if (c3 >= 0x81 && c3 <= 0xfe)
+			      goto incomplete;
+			  }
+		      }
+		  }
+	      }
+	    goto invalid;
+	  }
+	if (STREQ (encoding, "SJIS", 'S', 'J', 'I', 'S', 0, 0, 0, 0, 0))
+	  {
+	    if (m == 1)
+	      {
+		unsigned char c = (unsigned char) p[0];
+
+		if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xea)
+		    || (c >= 0xf0 && c <= 0xf9))
+		  goto incomplete;
+	      }
+	    goto invalid;
+	  }
+
+	/* An unknown multibyte encoding.  */
+	goto incomplete;
+      }
+
+     incomplete:
+      {
+	size_t k = nstate;
+	/* Here 0 <= k < m < 4.  */
+	pstate[++k] = s[0];
+	if (k < m)
+	  {
+	    pstate[++k] = s[1];
+	    if (k < m)
+	      pstate[++k] = s[2];
+	  }
+	if (k != m)
+	  abort ();
+      }
+      pstate[0] = m;
+      return (size_t)(-2);
+
+     invalid:
+      errno = EILSEQ;
+      /* The conversion state is undefined, says POSIX.  */
+      return (size_t)(-1);
+    }
+  }
+}
+
+#else
+/* Override the system's mbrtowc() function.  */
+
+# undef mbrtowc
+
+size_t
+rpl_mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
+{
+# if MBRTOWC_NULL_ARG_BUG || MBRTOWC_RETVAL_BUG
+  if (s == NULL)
+    {
+      pwc = NULL;
+      s = "";
+      n = 1;
+    }
+# endif
+
+# if MBRTOWC_RETVAL_BUG
+  {
+    static mbstate_t internal_state;
+
+    /* Override mbrtowc's internal state.  We can not call mbsinit() on the
+       hidden internal state, but we can call it on our variable.  */
+    if (ps == NULL)
+      ps = &internal_state;
+
+    if (!mbsinit (ps))
+      {
+	/* Parse the rest of the multibyte character byte for byte.  */
+	size_t count = 0;
+	for (; n > 0; s++, n--)
+	  {
+	    wchar_t wc;
+	    size_t ret = mbrtowc (&wc, s, 1, ps);
+
+	    if (ret == (size_t)(-1))
+	      return (size_t)(-1);
+	    count++;
+	    if (ret != (size_t)(-2))
+	      {
+		/* The multibyte character has been completed.  */
+		if (pwc != NULL)
+		  *pwc = wc;
+		return (wc == 0 ? 0 : count);
+	      }
+	  }
+	return (size_t)(-2);
+      }
+  }
+# endif
+
+# if MBRTOWC_NUL_RETVAL_BUG
+  {
+    wchar_t wc;
+    size_t ret = mbrtowc (&wc, s, n, ps);
+
+    if (ret != (size_t)(-1) && ret != (size_t)(-2))
+      {
+	if (pwc != NULL)
+	  *pwc = wc;
+	if (wc == 0)
+	  ret = 0;
+      }
+    return ret;
+  }
+# else
+  return mbrtowc (pwc, s, n, ps);
+# endif
+}
+
+#endif

Added: libprelude/trunk/libmissing/mbsinit.c
===================================================================
--- libprelude/trunk/libmissing/mbsinit.c	                        (rev 0)
+++ libprelude/trunk/libmissing/mbsinit.c	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,47 @@
+/* Test for initial conversion state.
+   Copyright (C) 2008 Free Software Foundation, Inc.
+   Written by Bruno Haible <[email protected]>, 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 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <wchar.h>
+
+#include "verify.h"
+
+/* Platforms that lack mbsinit() also lack mbrlen(), mbrtowc(), mbsrtowcs()
+   and wcrtomb(), wcsrtombs().
+   We assume that
+     - sizeof (mbstate_t) >= 4,
+     - only stateless encodings are supported (such as UTF-8 and EUC-JP, but
+       not ISO-2022 variants),
+     - for each encoding, the number of bytes for a wide character is <= 4.
+       (This maximum is attained for UTF-8, GB18030, EUC-TW.)
+   We define the meaning of mbstate_t as follows:
+     - In mb -> wc direction, mbstate_t's first byte contains the number of
+       buffered bytes (in the range 0..3), followed by up to 3 buffered bytes.
+     - In wc -> mb direction, mbstate_t contains no information. In other
+       words, it is always in the initial state.  */
+
+verify (sizeof (mbstate_t) >= 4);
+
+int
+mbsinit (const mbstate_t *ps)
+{
+  const char *pstate = (const char *)ps;
+
+  return pstate[0] == 0;
+}

Modified: libprelude/trunk/libmissing/netdb.in.h
===================================================================
--- libprelude/trunk/libmissing/netdb.in.h	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/netdb.in.h	2009-04-07 07:51:35 UTC (rev 11123)
@@ -36,12 +36,6 @@
 #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>
 
@@ -112,7 +106,7 @@
 # endif
 
 # ifndef EAI_OVERFLOW
-/* Not defined on mingw32. */
+/* Not defined on mingw32 and Haiku. */
 #  define EAI_OVERFLOW	  -12	/* Argument buffer overflow.  */
 # endif
 # ifndef EAI_ADDRFAMILY
@@ -184,7 +178,5 @@
 
 #endif /* @GNULIB_GETADDRINFO@ */
 
-#endif /* HAVE_NETDB_H */
-
 #endif /* _GL_NETDB_H */
 #endif /* _GL_NETDB_H */

Modified: libprelude/trunk/libmissing/pathmax.h
===================================================================
--- libprelude/trunk/libmissing/pathmax.h	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/pathmax.h	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
 /* Define PATH_MAX somehow.  Requires sys/types.h.
-   Copyright (C) 1992, 1999, 2001, 2003, 2005 Free Software Foundation, Inc.
+   Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -26,7 +26,7 @@
 #  define _POSIX_PATH_MAX 256
 # endif
 
-# if !defined PATH_MAX && defined _PC_PATH_MAX
+# if !defined PATH_MAX && defined _PC_PATH_MAX && defined HAVE_PATHCONF
 #  define PATH_MAX (pathconf ("/", _PC_PATH_MAX) < 1 ? 1024 \
 		    : pathconf ("/", _PC_PATH_MAX))
 # endif

Modified: libprelude/trunk/libmissing/poll.c
===================================================================
--- libprelude/trunk/libmissing/poll.c	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/poll.c	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,7 +1,7 @@
 /* Emulation for poll(2)
    Contributed by Paolo Bonzini.
 
-   Copyright 2001, 2002, 2003, 2006, 2007, 2008 Free Software Foundation, Inc.
+   Copyright 2001-2003, 2006-2009 Free Software Foundation, Inc.
 
    This file is part of gnulib.
 
@@ -19,6 +19,11 @@
    with this program; if not, write to the Free Software Foundation,
    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
 
+/* Tell gcc not to warn about the (nfd < 0) tests, below.  */
+#if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__
+# pragma GCC diagnostic ignored "-Wtype-limits"
+#endif
+
 #include <config.h>
 #include <alloca.h>
 
@@ -29,35 +34,35 @@
 #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>
+# 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>
+# 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>
+# include <sys/ioctl.h>
 #endif
 #ifdef HAVE_SYS_FILIO_H
-#include <sys/filio.h>
+# include <sys/filio.h>
 #endif
 
 #include <time.h>
 
 #ifndef INFTIM
-#define INFTIM (-1)
+# define INFTIM (-1)
 #endif
 
 /* BeOS does not have MSG_PEEK.  */
 #ifndef MSG_PEEK
-#define MSG_PEEK 0
+# define MSG_PEEK 0
 #endif
 
 #ifdef WIN32_NATIVE
@@ -92,9 +97,9 @@
 typedef DWORD (WINAPI *PNtQueryInformationFile)
 	 (HANDLE, IO_STATUS_BLOCK *, VOID *, ULONG, FILE_INFORMATION_CLASS);
 
-#ifndef PIPE_BUF
-#define PIPE_BUF	512
-#endif
+# ifndef PIPE_BUF
+#  define PIPE_BUF	512
+# endif
 
 /* Compute revents values for file handle H.  */
 
@@ -234,7 +239,7 @@
       int r;
       int socket_errno;
 
-#if defined __MACH__ && defined __APPLE__
+# 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
@@ -243,11 +248,11 @@
       socket_errno = (r < 0) ? errno : 0;
       if (r == 0 || socket_errno == ENOTSOCK)
 	ioctl (fd, FIONREAD, &r);
-#else
+# else
       char data[64];
       r = recv (fd, data, sizeof (data), MSG_PEEK);
       socket_errno = (r < 0) ? errno : 0;
-#endif
+# endif
       if (r == 0)
 	happened |= POLLHUP;
 
@@ -288,7 +293,7 @@
   int maxfd, rc;
   nfds_t i;
 
-#ifdef _SC_OPEN_MAX
+# ifdef _SC_OPEN_MAX
   static int sc_open_max = -1;
 
   if (nfd < 0
@@ -299,15 +304,15 @@
       errno = EINVAL;
       return -1;
     }
-#else /* !_SC_OPEN_MAX */
-#ifdef OPEN_MAX
+# else /* !_SC_OPEN_MAX */
+#  ifdef OPEN_MAX
   if (nfd < 0 || nfd > OPEN_MAX)
     {
       errno = EINVAL;
       return -1;
     }
-#endif /* OPEN_MAX -- else, no check is needed */
-#endif /* !_SC_OPEN_MAX */
+#  endif /* OPEN_MAX -- else, no check is needed */
+# endif /* !_SC_OPEN_MAX */
 
   /* EFAULT is not necessary to implement, but let's do it in the
      simplest case. */
@@ -404,8 +409,7 @@
   fd_set rfds, wfds, xfds;
   BOOL poll_again;
   MSG msg;
-  char sockbuf[256];
-  int rc;
+  int rc = 0;
   nfds_t i;
 
   if (nfd < 0 || timeout < -1)
@@ -426,7 +430,6 @@
   /* 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;

Modified: libprelude/trunk/libmissing/regcomp.c
===================================================================
--- libprelude/trunk/libmissing/regcomp.c	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/regcomp.c	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,6 @@
 /* Extended regular expression matching and search library.
-   Copyright (C) 2002,2003,2004,2005,2006,2007,2008 Free Software Foundation, Inc.
+   Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009
+   Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Isamu Hasegawa <[email protected]>.
 
@@ -333,8 +334,8 @@
 		     && dfa->nodes[node].mb_partial)
 		*p++ = dfa->nodes[node].opr.c;
 	      memset (&state, '\0', sizeof (state));
-	      if (mbrtowc (&wc, (const char *) buf, p - buf,
-			   &state) == p - buf
+	      if (__mbrtowc (&wc, (const char *) buf, p - buf,
+			     &state) == p - buf
 		  && (__wcrtomb ((char *) buf, towlower (wc), &state)
 		      != (size_t) -1))
 		re_set_fastmap (fastmap, false, buf[0]);
@@ -356,45 +357,65 @@
 #ifdef RE_ENABLE_I18N
       else if (type == COMPLEX_BRACKET)
 	{
+	  re_charset_t *cset = dfa->nodes[node].opr.mbcset;
 	  Idx i;
-	  re_charset_t *cset = dfa->nodes[node].opr.mbcset;
-	  if (cset->non_match || cset->ncoll_syms || cset->nequiv_classes
-	      || cset->nranges || cset->nchar_classes)
-	    {
+
 # ifdef _LIBC
-	      if (_NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES) != 0)
+	  /* See if we have to try all bytes which start multiple collation
+	     elements.
+	     e.g. In da_DK, we want to catch 'a' since "aa" is a valid
+		  collation element, and don't catch 'b' since 'b' is
+		  the only collation element which starts from 'b' (and
+		  it is caught by SIMPLE_BRACKET).  */
+	      if (_NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES) != 0
+		  && (cset->ncoll_syms || cset->nranges))
 		{
-		  /* In this case we want to catch the bytes which are
-		     the first byte of any collation elements.
-		     e.g. In da_DK, we want to catch 'a' since "aa"
-			  is a valid collation element, and don't catch
-			  'b' since 'b' is the only collation element
-			  which starts from 'b'.  */
 		  const int32_t *table = (const int32_t *)
 		    _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB);
 		  for (i = 0; i < SBC_MAX; ++i)
 		    if (table[i] < 0)
 		      re_set_fastmap (fastmap, icase, i);
 		}
-# else
-	      if (dfa->mb_cur_max > 1)
-		for (i = 0; i < SBC_MAX; ++i)
-		  if (__btowc (i) == WEOF)
-		    re_set_fastmap (fastmap, icase, i);
-# endif /* not _LIBC */
+# endif /* _LIBC */
+
+	  /* See if we have to start the match at all multibyte characters,
+	     i.e. where we would not find an invalid sequence.  This only
+	     applies to multibyte character sets; for single byte character
+	     sets, the SIMPLE_BRACKET again suffices.  */
+	  if (dfa->mb_cur_max > 1
+	      && (cset->nchar_classes || cset->non_match
+# ifdef _LIBC
+		  || cset->nequiv_classes
+# endif /* _LIBC */
+		 ))
+	    {
+	      unsigned char c = 0;
+	      do
+		{
+		  mbstate_t mbs;
+		  memset (&mbs, 0, sizeof (mbs));
+		  if (__mbrtowc (NULL, (char *) &c, 1, &mbs) == (size_t) -2)
+		    re_set_fastmap (fastmap, false, (int) c);
+		}
+	      while (++c != 0);
 	    }
-	  for (i = 0; i < cset->nmbchars; ++i)
+
+	  else
 	    {
-	      char buf[256];
-	      mbstate_t state;
-	      memset (&state, '\0', sizeof (state));
-	      if (__wcrtomb (buf, cset->mbchars[i], &state) != (size_t) -1)
-		re_set_fastmap (fastmap, icase, *(unsigned char *) buf);
-	      if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1)
+	      /* ... Else catch all bytes which can start the mbchars.  */
+	      for (i = 0; i < cset->nmbchars; ++i)
 		{
-		  if (__wcrtomb (buf, towlower (cset->mbchars[i]), &state)
-		      != (size_t) -1)
-		    re_set_fastmap (fastmap, false, *(unsigned char *) buf);
+		  char buf[256];
+		  mbstate_t state;
+		  memset (&state, '\0', sizeof (state));
+		  if (__wcrtomb (buf, cset->mbchars[i], &state) != (size_t) -1)
+		    re_set_fastmap (fastmap, icase, *(unsigned char *) buf);
+		  if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1)
+		    {
+		      if (__wcrtomb (buf, towlower (cset->mbchars[i]), &state)
+			  != (size_t) -1)
+			re_set_fastmap (fastmap, false, *(unsigned char *) buf);
+		    }
 		}
 	    }
 	}

Modified: libprelude/trunk/libmissing/regex_internal.c
===================================================================
--- libprelude/trunk/libmissing/regex_internal.c	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/regex_internal.c	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,6 +1,6 @@
 /* Extended regular expression matching and search library.
-   Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software
-   Foundation, Inc.
+   Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+   Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Isamu Hasegawa <[email protected]>.
 
@@ -236,7 +236,7 @@
 	}
       else
 	p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + byte_idx;
-      mbclen = mbrtowc (&wc, p, remain_len, &pstr->cur_state);
+      mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state);
       if (BE (mbclen == (size_t) -2, 0))
 	{
 	  /* The buffer doesn't have enough space, finish to build.  */
@@ -306,9 +306,9 @@
 
 	  remain_len = end_idx - byte_idx;
 	  prev_st = pstr->cur_state;
-	  mbclen = mbrtowc (&wc,
-			    ((const char *) pstr->raw_mbs + pstr->raw_mbs_idx
-			     + byte_idx), remain_len, &pstr->cur_state);
+	  mbclen = __mbrtowc (&wc,
+			      ((const char *) pstr->raw_mbs + pstr->raw_mbs_idx
+			       + byte_idx), remain_len, &pstr->cur_state);
 	  if (BE (mbclen < (size_t) -2, 1))
 	    {
 	      wchar_t wcu = wc;
@@ -376,7 +376,7 @@
 	  }
 	else
 	  p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + src_idx;
-	mbclen = mbrtowc (&wc, p, remain_len, &pstr->cur_state);
+	mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state);
 	if (BE (mbclen < (size_t) -2, 1))
 	  {
 	    wchar_t wcu = wc;
@@ -499,8 +499,8 @@
       Idx remain_len;
       remain_len = pstr->len - rawbuf_idx;
       prev_st = pstr->cur_state;
-      mbclen = mbrtowc (&wc2, (const char *) pstr->raw_mbs + rawbuf_idx,
-			remain_len, &pstr->cur_state);
+      mbclen = __mbrtowc (&wc2, (const char *) pstr->raw_mbs + rawbuf_idx,
+			  remain_len, &pstr->cur_state);
       if (BE (mbclen == (size_t) -2 || mbclen == (size_t) -1 || mbclen == 0, 0))
 	{
 	  /* We treat these cases as a single byte character.  */
@@ -687,10 +687,10 @@
 	}
       else
 	{
+#ifdef RE_ENABLE_I18N
 	  /* No, skip all characters until IDX.  */
 	  Idx prev_valid_len = pstr->valid_len;
 
-#ifdef RE_ENABLE_I18N
 	  if (BE (pstr->offsets_needed, 0))
 	    {
 	      pstr->len = pstr->raw_len - idx + offset;
@@ -745,8 +745,8 @@
 			  /* XXX Don't use mbrtowc, we know which conversion
 			     to use (UTF-8 -> UCS4).  */
 			  memset (&cur_state, 0, sizeof (cur_state));
-			  mbclen = mbrtowc (&wc2, (const char *) p, mlen,
-					    &cur_state);
+			  mbclen = __mbrtowc (&wc2, (const char *) p, mlen,
+					      &cur_state);
 			  if (raw + offset - p <= mbclen
 			      && mbclen < (size_t) -2)
 			    {

Modified: libprelude/trunk/libmissing/regex_internal.h
===================================================================
--- libprelude/trunk/libmissing/regex_internal.h	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/regex_internal.h	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,6 @@
 /* Extended regular expression matching and search library.
-   Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+   Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Isamu Hasegawa <[email protected]>.
 
@@ -84,7 +85,7 @@
 # define SIZE_MAX ((size_t) -1)
 #endif
 
-#if (defined MB_CUR_MAX && HAVE_LOCALE_H && HAVE_WCTYPE_H && HAVE_ISWCTYPE && HAVE_WCRTOMB && HAVE_MBRTOWC && HAVE_WCSCOLL) || _LIBC
+#if (defined MB_CUR_MAX && HAVE_LOCALE_H && HAVE_WCTYPE_H && HAVE_ISWCTYPE && HAVE_WCSCOLL) || _LIBC
 # define RE_ENABLE_I18N
 #endif
 
@@ -115,6 +116,7 @@
 # define __iswctype iswctype
 # define __btowc btowc
 # define __wcrtomb wcrtomb
+# define __mbrtowc mbrtowc
 # define __regfree regfree
 # define attribute_hidden
 #endif /* not _LIBC */
@@ -182,10 +184,6 @@
 # if BITSET_WORD_BITS <= SBC_MAX
 #  error "Invalid SBC_MAX"
 # endif
-#elif BITSET_WORD_MAX == (0xffffffff + 2) * 0xffffffff
-/* Work around a bug in 64-bit PGC (before version 6.1-2), where the
-   preprocessor mishandles large unsigned values as if they were signed.  */
-# define BITSET_WORD_BITS 64
 #else
 # error "Add case for new bitset_word_t size"
 #endif

Modified: libprelude/trunk/libmissing/regexec.c
===================================================================
--- libprelude/trunk/libmissing/regexec.c	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/regexec.c	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,6 +1,6 @@
 /* Extended regular expression matching and search library.
-   Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation,
-   Inc.
+   Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+   Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Isamu Hasegawa <[email protected]>.
 
@@ -1045,6 +1045,11 @@
       re_node_set_free (&sctx.limits);
       if (BE (ret != REG_NOERROR, 0))
 	goto free_return;
+      if (sifted_states[0] == NULL)
+	{
+	  ret = REG_NOMATCH;
+	  goto free_return;
+	}
     }
   re_free (mctx->state_log);
   mctx->state_log = sifted_states;
@@ -3079,7 +3084,9 @@
   const re_dfa_t *const dfa = mctx->dfa;
   bool ok;
   Idx cur_idx;
+#ifdef RE_ENABLE_I18N
   reg_errcode_t err = REG_NOERROR;
+#endif
   re_node_set union_set;
   re_node_set_init_empty (&union_set);
   for (cur_idx = 0; cur_idx < cur_nodes->nelem; ++cur_idx)

Copied: libprelude/trunk/libmissing/select.c (from rev 11101, libprelude/trunk/libmissing/winsock-select.c)
===================================================================
--- libprelude/trunk/libmissing/select.c	                        (rev 0)
+++ libprelude/trunk/libmissing/select.c	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,446 @@
+/* Emulation for select(2)
+   Contributed by Paolo Bonzini.
+
+   Copyright 2008-2009 Free Software Foundation, Inc.
+
+   This file is part of gnulib.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License along
+   with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#include <config.h>
+#include <alloca.h>
+
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+/* Native Win32.  */
+
+#include <sys/types.h>
+#include <stdbool.h>
+#include <errno.h>
+#include <limits.h>
+
+#include <winsock2.h>
+#include <windows.h>
+#include <io.h>
+#include <stdio.h>
+#include <conio.h>
+#include <time.h>
+
+struct bitset {
+  unsigned char in[FD_SETSIZE / CHAR_BIT];
+  unsigned char out[FD_SETSIZE / CHAR_BIT];
+};
+
+/* 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 output fd_sets for libc descriptor FD (whose Win32 handle is H).  */
+
+static int
+win32_poll_handle (HANDLE h, int fd, struct bitset *rbits, struct bitset *wbits,
+		   struct bitset *xbits)
+{
+  BOOL read, write, except;
+  int i, ret;
+  INPUT_RECORD *irbuffer;
+  DWORD avail, nbuffer;
+  BOOL bRet;
+  IO_STATUS_BLOCK iosb;
+  FILE_PIPE_LOCAL_INFORMATION fpli;
+  static PNtQueryInformationFile NtQueryInformationFile;
+  static BOOL once_only;
+
+  read = write = except = FALSE;
+  switch (GetFileType (h))
+    {
+    case FILE_TYPE_DISK:
+      read = TRUE;
+      write = TRUE;
+      break;
+
+    case FILE_TYPE_PIPE:
+      if (!once_only)
+	{
+	  NtQueryInformationFile = (PNtQueryInformationFile)
+	    GetProcAddress (GetModuleHandle ("ntdll.dll"),
+			    "NtQueryInformationFile");
+	  once_only = TRUE;
+	}
+
+      if (PeekNamedPipe (h, NULL, 0, NULL, &avail, NULL) != 0)
+	{
+	  if (avail)
+	    read = TRUE;
+	}
+
+      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))
+	    write = TRUE;
+	}
+      break;
+
+    case FILE_TYPE_CHAR:
+      ret = WaitForSingleObject (h, 0);
+      write = TRUE;
+      if (ret == WAIT_OBJECT_0)
+        {
+	  nbuffer = avail = 0;
+	  bRet = GetNumberOfConsoleInputEvents (h, &nbuffer);
+	  if (!bRet || nbuffer == 0)
+	    except = TRUE;
+
+	  irbuffer = (INPUT_RECORD *) alloca (nbuffer * sizeof (INPUT_RECORD));
+	  bRet = PeekConsoleInput (h, irbuffer, nbuffer, &avail);
+	  if (!bRet || avail == 0)
+	    except = TRUE;
+
+	  for (i = 0; i < avail; i++)
+	    if (irbuffer[i].EventType == KEY_EVENT)
+	      read = TRUE;
+	}
+      break;
+
+    default:
+      ret = WaitForSingleObject (h, 0);
+      write = TRUE;
+      if (ret == WAIT_OBJECT_0)
+        read = TRUE;
+
+      break;
+    }
+
+  ret = 0;
+  if (read && (rbits->in[fd / CHAR_BIT] & (1 << (fd & (CHAR_BIT - 1)))))
+    {
+      rbits->out[fd / CHAR_BIT] |= (1 << (fd & (CHAR_BIT - 1)));
+      ret++;
+    }
+
+  if (write && (wbits->in[fd / CHAR_BIT] & (1 << (fd & (CHAR_BIT - 1)))))
+    {
+      wbits->out[fd / CHAR_BIT] |= (1 << (fd & (CHAR_BIT - 1)));
+      ret++;
+    }
+
+  if (except && (xbits->in[fd / CHAR_BIT] & (1 << (fd & (CHAR_BIT - 1)))))
+    {
+      xbits->out[fd / CHAR_BIT] |= (1 << (fd & (CHAR_BIT - 1)));
+      ret++;
+    }
+
+  return ret;
+}
+
+int
+rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds,
+            struct timeval *timeout)
+{
+  static struct timeval tv0;
+  static HANDLE hEvent;
+  HANDLE h, handle_array[FD_SETSIZE + 2];
+  fd_set handle_rfds, handle_wfds, handle_xfds;
+  struct bitset rbits, wbits, xbits;
+  unsigned char anyfds_in[FD_SETSIZE / CHAR_BIT];
+  DWORD ret, wait_timeout, nhandles, nsock;
+  MSG msg;
+  int i, fd, rc;
+
+  if (nfds > FD_SETSIZE)
+    nfds = FD_SETSIZE;
+
+  if (!timeout)
+    wait_timeout = INFINITE;
+  else
+    {
+      wait_timeout = timeout->tv_sec + timeout->tv_usec / 1000;
+
+      /* select is also used as a portable usleep.  */
+      if (!rfds && !wfds && !xfds)
+        {
+          Sleep (wait_timeout);
+          return 0;
+        }
+    }
+
+  if (!hEvent)
+    hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
+
+  handle_array[0] = hEvent;
+  nhandles = 1;
+  nsock = 0;
+
+  /* Copy descriptors to bitsets.  */
+  memset (&rbits, 0, sizeof (rbits));
+  memset (&wbits, 0, sizeof (wbits));
+  memset (&xbits, 0, sizeof (xbits));
+  memset (anyfds_in, 0, sizeof (anyfds_in));
+  if (rfds)
+    for (i = 0; i < rfds->fd_count; i++)
+      {
+        fd = rfds->fd_array[i];
+        rbits.in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1));
+        anyfds_in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1));
+      }
+  else
+    rfds = (fd_set *) alloca (sizeof (fd_set));
+
+  if (wfds)
+    for (i = 0; i < wfds->fd_count; i++)
+      {
+        fd = wfds->fd_array[i];
+        wbits.in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1));
+        anyfds_in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1));
+      }
+  else
+    wfds = (fd_set *) alloca (sizeof (fd_set));
+
+  if (xfds)
+    for (i = 0; i < xfds->fd_count; i++)
+      {
+        fd = xfds->fd_array[i];
+        xbits.in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1));
+        anyfds_in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1));
+      }
+  else
+    xfds = (fd_set *) alloca (sizeof (fd_set));
+
+  /* Zero all the fd_sets, including the application's.  */
+  FD_ZERO (rfds);
+  FD_ZERO (wfds);
+  FD_ZERO (xfds);
+  FD_ZERO (&handle_rfds);
+  FD_ZERO (&handle_wfds);
+  FD_ZERO (&handle_xfds);
+
+  /* Classify handles.  Create fd sets for sockets, poll the others. */
+  for (i = 0; i < nfds; i++)
+    {
+      WSANETWORKEVENTS ev;
+
+      if ((anyfds_in[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))) == 0)
+	continue;
+
+      h = (HANDLE) _get_osfhandle (i);
+      if (!h)
+        {
+	  errno = EBADF;
+	  return -1;
+        }
+
+      /* 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, but we
+	     need to map descriptors to handles.  */
+          if (rbits.in[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1))))
+	    {
+              requested |= FD_READ | FD_ACCEPT;
+	      FD_SET ((SOCKET) h, rfds);
+	      FD_SET ((SOCKET) h, &handle_rfds);
+	    }
+          if (wbits.in[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1))))
+	    {
+              requested |= FD_WRITE | FD_CONNECT;
+	      FD_SET ((SOCKET) h, wfds);
+	      FD_SET ((SOCKET) h, &handle_wfds);
+	    }
+          if (xbits.in[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1))))
+	    {
+              requested |= FD_OOB;
+	      FD_SET ((SOCKET) h, xfds);
+	      FD_SET ((SOCKET) h, &handle_xfds);
+	    }
+
+          WSAEventSelect ((SOCKET) h, hEvent, requested);
+	  nsock++;
+        }
+      else
+        {
+          handle_array[nhandles++] = h;
+
+	  /* Poll now.  If we get an event, do not wait below.  */
+          if (wait_timeout != 0
+	      && win32_poll_handle (h, i, &rbits, &wbits, &xbits))
+	    wait_timeout = 0;
+        }
+    }
+
+  if (wait_timeout == 0 || nsock == 0)
+    rc = 0;
+  else
+    {
+      /* See if we need to wait in the loop below.  If any select is ready,
+         do MsgWaitForMultipleObjects anyway to dispatch messages, but
+         no need to call select again.  */
+      rc = select (0, &handle_rfds, &handle_wfds, &handle_xfds, &tv0);
+      if (rc == 0)
+	{
+	  /* Restore the fd_sets for the other select we do below.  */
+          memcpy (&handle_rfds, rfds, sizeof (fd_set));
+          memcpy (&handle_wfds, wfds, sizeof (fd_set));
+          memcpy (&handle_xfds, xfds, sizeof (fd_set));
+	}
+      else
+        wait_timeout = 0;
+    }
+
+  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 we haven't done it yet, check the status of the sockets.  */
+  if (rc == 0 && nsock > 0)
+    rc = select (0, &handle_rfds, &handle_wfds, &handle_xfds, &tv0);
+
+  /* Now fill in the results.  */
+  FD_ZERO (rfds);
+  FD_ZERO (wfds);
+  FD_ZERO (xfds);
+
+  /* Place a sentinel at the end of the array.  */
+  handle_array[nhandles] = NULL;
+  nhandles = 1;
+  for (i = 0; i < nfds; i++)
+    {
+      if ((anyfds_in[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))) == 0)
+	continue;
+
+      h = (HANDLE) _get_osfhandle (i);
+      if (h != handle_array[nhandles])
+	{
+	  /* Perform handle->descriptor mapping.  Don't update rc, as these
+	     results are counted in the return value of Winsock's select.  */
+          WSAEventSelect ((SOCKET) h, NULL, 0);
+          if (FD_ISSET (h, &handle_rfds))
+            FD_SET (i, rfds);
+          if (FD_ISSET (h, &handle_wfds))
+            FD_SET (i, wfds);
+          if (FD_ISSET (h, &handle_xfds))
+            FD_SET (i, xfds);
+	}
+      else
+        {
+          /* Not a socket.  */
+          nhandles++;
+          win32_poll_handle (h, i, &rbits, &wbits, &xbits);
+          if (rbits.out[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1))))
+            {
+	      rc++;
+	      FD_SET (i, rfds);
+	    }
+          if (wbits.out[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1))))
+            {
+	      rc++;
+	      FD_SET (i, wfds);
+	    }
+          if (xbits.out[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1))))
+            {
+	      rc++;
+	      FD_SET (i, xfds);
+	    }
+        }
+    }
+
+  return rc;
+}
+
+#else /* ! Native Win32.  */
+
+#include <sys/select.h>
+
+#undef select
+
+int
+rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds,
+            struct timeval *timeout)
+{
+  /* Interix 3.5 has a bug: it does not support nfds == 0.  */
+  if (nfds == 0)
+    {
+      nfds = 1;
+      rfds = NULL;
+      wfds = NULL;
+      xfds = NULL;
+    }
+  return select (nfds, rfds, wfds, xfds, timeout);
+}
+
+#endif

Modified: libprelude/trunk/libmissing/setsockopt.c
===================================================================
--- libprelude/trunk/libmissing/setsockopt.c	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/setsockopt.c	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,6 +1,6 @@
 /* setsockopt.c --- wrappers for Windows setsockopt function
 
-   Copyright (C) 2008 Free Software Foundation, Inc.
+   Copyright (C) 2008-2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -23,16 +23,31 @@
 /* Get winsock2.h. */
 #include <sys/socket.h>
 
+/* Get struct timeval. */
+#include <sys/time.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)
+rpl_setsockopt (int fd, int level, int optname, const void *optval, socklen_t optlen)
 {
+  int r;
   SOCKET sock = FD_TO_SOCKET (fd);
-  int r = setsockopt (sock, level, optname, optval, optlen);
+
+  if (level == SOL_SOCKET && (optname == SO_RCVTIMEO || optname == SO_SNDTIMEO))
+    {
+      const struct timeval *tv = optval;
+      int milliseconds = tv->tv_sec * 1000 + tv->tv_usec / 1000;
+      r = setsockopt (sock, level, optname, &milliseconds, sizeof (int));
+    }
+  else
+    {
+      r = setsockopt (sock, level, optname, optval, optlen);
+    }
+
   if (r < 0)
     set_winsock_errno ();
 

Modified: libprelude/trunk/libmissing/signal.in.h
===================================================================
--- libprelude/trunk/libmissing/signal.in.h	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/signal.in.h	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,6 +1,6 @@
 /* A GNU-like <signal.h>.
 
-   Copyright (C) 2006-2008 Free Software Foundation, Inc.
+   Copyright (C) 2006-2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -41,6 +41,15 @@
    Also, mingw defines sigset_t not in <signal.h>, but in <sys/types.h>.  */
 #include <sys/types.h>
 
+/* On AIX, sig_atomic_t already includes volatile.  C99 requires that
+   'volatile sig_atomic_t' ignore the extra modifier, but C89 did not.
+   Hence, redefine this to a non-volatile type as needed.  */
+#if ! @HAVE_TYPE_VOLATILE_SIG_ATOMIC_T@
+typedef int rpl_sig_atomic_t;
+# undef sig_atomic_t
+# define sig_atomic_t rpl_sig_atomic_t
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif

Modified: libprelude/trunk/libmissing/stdint.in.h
===================================================================
--- libprelude/trunk/libmissing/stdint.in.h	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/stdint.in.h	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2002, 2004-2008 Free Software Foundation, Inc.
+/* Copyright (C) 2001-2002, 2004-2009 Free Software Foundation, Inc.
    Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood.
    This file is part of gnulib.
 
@@ -89,15 +89,6 @@
 # include <sys/bitypes.h>
 #endif
 
-#if ! defined __cplusplus || defined __STDC_CONSTANT_MACROS
-
-/* Get WCHAR_MIN, WCHAR_MAX.  */
-# if ! (defined WCHAR_MIN && defined WCHAR_MAX)
-#  include <wchar.h>
-# endif
-
-#endif
-
 #undef _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
 
 /* Minimum and maximum values for a integer type under the usual assumption.
@@ -122,46 +113,58 @@
 
 #undef int8_t
 #undef uint8_t
-#define int8_t signed char
-#define uint8_t unsigned char
+typedef signed char gl_int8_t;
+typedef unsigned char gl_uint8_t;
+#define int8_t gl_int8_t
+#define uint8_t gl_uint8_t
 
 #undef int16_t
 #undef uint16_t
-#define int16_t short int
-#define uint16_t unsigned short int
+typedef short int gl_int16_t;
+typedef unsigned short int gl_uint16_t;
+#define int16_t gl_int16_t
+#define uint16_t gl_uint16_t
 
 #undef int32_t
 #undef uint32_t
-#define int32_t int
-#define uint32_t unsigned int
+typedef int gl_int32_t;
+typedef unsigned int gl_uint32_t;
+#define int32_t gl_int32_t
+#define uint32_t gl_uint32_t
 
 /* Do not undefine int64_t if gnulib is not being used with 64-bit
    types, since otherwise it breaks platforms like Tandem/NSK.  */
 #if LONG_MAX >> 31 >> 31 == 1
 # undef int64_t
-# define int64_t long int
+typedef long int gl_int64_t;
+# define int64_t gl_int64_t
 # define GL_INT64_T
 #elif defined _MSC_VER
 # undef int64_t
-# define int64_t __int64
+typedef __int64 gl_int64_t;
+# define int64_t gl_int64_t
 # define GL_INT64_T
 #elif @HAVE_LONG_LONG_INT@
 # undef int64_t
-# define int64_t long long int
+typedef long long int gl_int64_t;
+# define int64_t gl_int64_t
 # define GL_INT64_T
 #endif
 
 #if ULONG_MAX >> 31 >> 31 >> 1 == 1
 # undef uint64_t
-# define uint64_t unsigned long int
+typedef unsigned long int gl_uint64_t;
+# define uint64_t gl_uint64_t
 # define GL_UINT64_T
 #elif defined _MSC_VER
 # undef uint64_t
-# define uint64_t unsigned __int64
+typedef unsigned __int64 gl_uint64_t;
+# define uint64_t gl_uint64_t
 # define GL_UINT64_T
 #elif @HAVE_UNSIGNED_LONG_LONG_INT@
 # undef uint64_t
-# define uint64_t unsigned long long int
+typedef unsigned long long int gl_uint64_t;
+# define uint64_t gl_uint64_t
 # define GL_UINT64_T
 #endif
 
@@ -216,12 +219,18 @@
 #undef uint_fast32_t
 #undef int_fast64_t
 #undef uint_fast64_t
-#define int_fast8_t long int
-#define uint_fast8_t unsigned int_fast8_t
-#define int_fast16_t long int
-#define uint_fast16_t unsigned int_fast16_t
-#define int_fast32_t long int
-#define uint_fast32_t unsigned int_fast32_t
+typedef long int gl_int_fast8_t;
+typedef unsigned long int gl_uint_fast8_t;
+typedef long int gl_int_fast16_t;
+typedef unsigned long int gl_uint_fast16_t;
+typedef long int gl_int_fast32_t;
+typedef unsigned long int gl_uint_fast32_t;
+#define int_fast8_t gl_int_fast8_t
+#define uint_fast8_t gl_uint_fast8_t
+#define int_fast16_t gl_int_fast16_t
+#define uint_fast16_t gl_uint_fast16_t
+#define int_fast32_t gl_int_fast32_t
+#define uint_fast32_t gl_uint_fast32_t
 #ifdef GL_INT64_T
 # define int_fast64_t int64_t
 #endif
@@ -233,8 +242,10 @@
 
 #undef intptr_t
 #undef uintptr_t
-#define intptr_t long int
-#define uintptr_t unsigned long int
+typedef long int gl_intptr_t;
+typedef unsigned long int gl_uintptr_t;
+#define intptr_t gl_intptr_t
+#define uintptr_t gl_uintptr_t
 
 /* 7.18.1.5. Greatest-width integer types */
 
@@ -243,20 +254,24 @@
 
 #undef intmax_t
 #if @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1
-# define intmax_t long long int
+typedef long long int gl_intmax_t;
+# define intmax_t gl_intmax_t
 #elif defined GL_INT64_T
 # define intmax_t int64_t
 #else
-# define intmax_t long int
+typedef long int gl_intmax_t;
+# define intmax_t gl_intmax_t
 #endif
 
 #undef uintmax_t
 #if @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1
-# define uintmax_t unsigned long long int
+typedef unsigned long long int gl_uintmax_t;
+# define uintmax_t gl_uintmax_t
 #elif defined GL_UINT64_T
 # define uintmax_t uint64_t
 #else
-# define uintmax_t unsigned long int
+typedef unsigned long int gl_uintmax_t;
+# define uintmax_t gl_uintmax_t
 #endif
 
 /* Verify that intmax_t and uintmax_t have the same size.  Too much code
@@ -419,10 +434,20 @@
 /* ptrdiff_t limits */
 #undef PTRDIFF_MIN
 #undef PTRDIFF_MAX
-#define PTRDIFF_MIN  \
-   _STDINT_MIN (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@)
-#define PTRDIFF_MAX  \
-   _STDINT_MAX (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@)
+#if @APPLE_UNIVERSAL_BUILD@
+# ifdef _LP64
+#  define PTRDIFF_MIN  _STDINT_MIN (1, 64, 0l)
+#  define PTRDIFF_MAX  _STDINT_MAX (1, 64, 0l)
+# else
+#  define PTRDIFF_MIN  _STDINT_MIN (1, 32, 0)
+#  define PTRDIFF_MAX  _STDINT_MAX (1, 32, 0)
+# endif
+#else
+# define PTRDIFF_MIN  \
+    _STDINT_MIN (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@)
+# define PTRDIFF_MAX  \
+    _STDINT_MAX (1, @BITSIZEOF_PTRDIFF_T@, 0@PTRDIFF_T_SUFFIX@)
+#endif
 
 /* sig_atomic_t limits */
 #undef SIG_ATOMIC_MIN
@@ -437,9 +462,26 @@
 
 /* size_t limit */
 #undef SIZE_MAX
-#define SIZE_MAX  _STDINT_MAX (0, @BITSIZEOF_SIZE_T@, 0@SIZE_T_SUFFIX@)
+#if @APPLE_UNIVERSAL_BUILD@
+# ifdef _LP64
+#  define SIZE_MAX  _STDINT_MAX (0, 64, 0ul)
+# else
+#  define SIZE_MAX  _STDINT_MAX (0, 32, 0ul)
+# endif
+#else
+# define SIZE_MAX  _STDINT_MAX (0, @BITSIZEOF_SIZE_T@, 0@SIZE_T_SUFFIX@)
+#endif
 
 /* wchar_t limits */
+/* Get WCHAR_MIN, WCHAR_MAX.
+   This include is not on the top, above, because on OSF/1 4.0 we have a sequence of nested
+   includes <wchar.h> -> <stdio.h> -> <getopt.h> -> <stdlib.h>, and the latter includes
+   <stdint.h> and assumes its types are already defined.  */
+#if ! (defined WCHAR_MIN && defined WCHAR_MAX)
+# define _GL_JUST_INCLUDE_SYSTEM_WCHAR_H
+# include <wchar.h>
+# undef _GL_JUST_INCLUDE_SYSTEM_WCHAR_H
+#endif
 #undef WCHAR_MIN
 #undef WCHAR_MAX
 #define WCHAR_MIN  \

Modified: libprelude/trunk/libmissing/stdio.in.h
===================================================================
--- libprelude/trunk/libmissing/stdio.in.h	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/stdio.in.h	2009-04-07 07:51:35 UTC (rev 11123)
@@ -216,6 +216,38 @@
      vsprintf (b, f, a))
 #endif
 
+#if @GNULIB_DPRINTF@
+# if @REPLACE_DPRINTF@
+#  define dprintf rpl_dprintf
+# endif
+# if @REPLACE_DPRINTF@ || !@HAVE_DPRINTF@
+extern int dprintf (int fd, const char *format, ...)
+       __attribute__ ((__format__ (__printf__, 2, 3)));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef dprintf
+# define dprintf(d,f,a) \
+    (GL_LINK_WARNING ("dprintf is unportable - " \
+                      "use gnulib module dprintf for portability"), \
+     dprintf (d, f, a))
+#endif
+
+#if @GNULIB_VDPRINTF@
+# if @REPLACE_VDPRINTF@
+#  define vdprintf rpl_vdprintf
+# endif
+# if @REPLACE_VDPRINTF@ || !@HAVE_VDPRINTF@
+extern int vdprintf (int fd, const char *format, va_list args)
+       __attribute__ ((__format__ (__printf__, 2, 0)));
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef vdprintf
+# define vdprintf(d,f,a) \
+    (GL_LINK_WARNING ("vdprintf is unportable - " \
+                      "use gnulib module vdprintf for portability"), \
+     vdprintf (d, f, a))
+#endif
+
 #if @GNULIB_VASPRINTF@
 # if @REPLACE_VASPRINTF@
 #  define asprintf rpl_asprintf

Modified: libprelude/trunk/libmissing/stdlib.in.h
===================================================================
--- libprelude/trunk/libmissing/stdlib.in.h	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/stdlib.in.h	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,6 +1,6 @@
 /* A GNU-like <stdlib.h>.
 
-   Copyright (C) 1995, 2001-2004, 2006-2008 Free Software Foundation, Inc.
+   Copyright (C) 1995, 2001-2004, 2006-2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -41,6 +41,12 @@
 # include <sys/loadavg.h>
 #endif
 
+/* OSF/1 5.1 declares 'struct random_data' in <random.h>, which is included
+   from <stdlib.h> if _REENTRANT is defined.  Include it always.  */
+#if @HAVE_RANDOM_H@
+# include <random.h>
+#endif
+
 #if @GNULIB_RANDOM_R@ || !@HAVE_STRUCT_RANDOM_DATA@
 # include <stdint.h>
 #endif
@@ -52,8 +58,8 @@
   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.  */
+  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

Added: libprelude/trunk/libmissing/streq.h
===================================================================
--- libprelude/trunk/libmissing/streq.h	                        (rev 0)
+++ libprelude/trunk/libmissing/streq.h	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,176 @@
+/* Optimized string comparison.
+   Copyright (C) 2001-2002, 2007 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify it
+   under the terms of the GNU Lesser General Public License as published
+   by the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Bruno Haible <[email protected]>.  */
+
+#ifndef _GL_STREQ_H
+#define _GL_STREQ_H
+
+#include <string.h>
+
+/* STREQ allows to optimize string comparison with a small literal string.
+     STREQ (s, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
+   is semantically equivalent to
+     strcmp (s, "EUC-KR") == 0
+   just faster.  */
+
+/* Help GCC to generate good code for string comparisons with
+   immediate strings. */
+#if defined (__GNUC__) && defined (__OPTIMIZE__)
+
+static inline int
+streq9 (const char *s1, const char *s2)
+{
+  return strcmp (s1 + 9, s2 + 9) == 0;
+}
+
+static inline int
+streq8 (const char *s1, const char *s2, char s28)
+{
+  if (s1[8] == s28)
+    {
+      if (s28 == 0)
+        return 1;
+      else
+        return streq9 (s1, s2);
+    }
+  else
+    return 0;
+}
+
+static inline int
+streq7 (const char *s1, const char *s2, char s27, char s28)
+{
+  if (s1[7] == s27)
+    {
+      if (s27 == 0)
+        return 1;
+      else
+        return streq8 (s1, s2, s28);
+    }
+  else
+    return 0;
+}
+
+static inline int
+streq6 (const char *s1, const char *s2, char s26, char s27, char s28)
+{
+  if (s1[6] == s26)
+    {
+      if (s26 == 0)
+        return 1;
+      else
+        return streq7 (s1, s2, s27, s28);
+    }
+  else
+    return 0;
+}
+
+static inline int
+streq5 (const char *s1, const char *s2, char s25, char s26, char s27, char s28)
+{
+  if (s1[5] == s25)
+    {
+      if (s25 == 0)
+        return 1;
+      else
+        return streq6 (s1, s2, s26, s27, s28);
+    }
+  else
+    return 0;
+}
+
+static inline int
+streq4 (const char *s1, const char *s2, char s24, char s25, char s26, char s27, char s28)
+{
+  if (s1[4] == s24)
+    {
+      if (s24 == 0)
+        return 1;
+      else
+        return streq5 (s1, s2, s25, s26, s27, s28);
+    }
+  else
+    return 0;
+}
+
+static inline int
+streq3 (const char *s1, const char *s2, char s23, char s24, char s25, char s26, char s27, char s28)
+{
+  if (s1[3] == s23)
+    {
+      if (s23 == 0)
+        return 1;
+      else
+        return streq4 (s1, s2, s24, s25, s26, s27, s28);
+    }
+  else
+    return 0;
+}
+
+static inline int
+streq2 (const char *s1, const char *s2, char s22, char s23, char s24, char s25, char s26, char s27, char s28)
+{
+  if (s1[2] == s22)
+    {
+      if (s22 == 0)
+        return 1;
+      else
+        return streq3 (s1, s2, s23, s24, s25, s26, s27, s28);
+    }
+  else
+    return 0;
+}
+
+static inline int
+streq1 (const char *s1, const char *s2, char s21, char s22, char s23, char s24, char s25, char s26, char s27, char s28)
+{
+  if (s1[1] == s21)
+    {
+      if (s21 == 0)
+        return 1;
+      else
+        return streq2 (s1, s2, s22, s23, s24, s25, s26, s27, s28);
+    }
+  else
+    return 0;
+}
+
+static inline int
+streq0 (const char *s1, const char *s2, char s20, char s21, char s22, char s23, char s24, char s25, char s26, char s27, char s28)
+{
+  if (s1[0] == s20)
+    {
+      if (s20 == 0)
+        return 1;
+      else
+        return streq1 (s1, s2, s21, s22, s23, s24, s25, s26, s27, s28);
+    }
+  else
+    return 0;
+}
+
+#define STREQ(s1,s2,s20,s21,s22,s23,s24,s25,s26,s27,s28) \
+  streq0 (s1, s2, s20, s21, s22, s23, s24, s25, s26, s27, s28)
+
+#else
+
+#define STREQ(s1,s2,s20,s21,s22,s23,s24,s25,s26,s27,s28) \
+  (strcmp (s1, s2) == 0)
+
+#endif
+
+#endif /* _GL_STREQ_H */

Modified: libprelude/trunk/libmissing/strerror.c
===================================================================
--- libprelude/trunk/libmissing/strerror.c	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/strerror.c	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,6 +1,6 @@
 /* strerror.c --- POSIX compatible system error routine
 
-   Copyright (C) 2007-2008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -40,94 +40,133 @@
 char *
 rpl_strerror (int n)
 {
+  char const *msg = NULL;
   /* These error messages are taken from glibc/sysdeps/gnu/errlist.c.  */
   switch (n)
     {
 # if GNULIB_defined_ETXTBSY
     case ETXTBSY:
-      return "Text file busy";
+      msg = "Text file busy";
+      break;
 # endif
 
 # if GNULIB_defined_ESOCK /* native Windows platforms */
     /* EWOULDBLOCK is the same as EAGAIN.  */
     case EINPROGRESS:
-      return "Operation now in progress";
+      msg = "Operation now in progress";
+      break;
     case EALREADY:
-      return "Operation already in progress";
+      msg = "Operation already in progress";
+      break;
     case ENOTSOCK:
-      return "Socket operation on non-socket";
+      msg = "Socket operation on non-socket";
+      break;
     case EDESTADDRREQ:
-      return "Destination address required";
+      msg = "Destination address required";
+      break;
     case EMSGSIZE:
-      return "Message too long";
+      msg = "Message too long";
+      break;
     case EPROTOTYPE:
-      return "Protocol wrong type for socket";
+      msg = "Protocol wrong type for socket";
+      break;
     case ENOPROTOOPT:
-      return "Protocol not available";
+      msg = "Protocol not available";
+      break;
     case EPROTONOSUPPORT:
-      return "Protocol not supported";
+      msg = "Protocol not supported";
+      break;
     case ESOCKTNOSUPPORT:
-      return "Socket type not supported";
+      msg = "Socket type not supported";
+      break;
     case EOPNOTSUPP:
-      return "Operation not supported";
+      msg = "Operation not supported";
+      break;
     case EPFNOSUPPORT:
-      return "Protocol family not supported";
+      msg = "Protocol family not supported";
+      break;
     case EAFNOSUPPORT:
-      return "Address family not supported by protocol";
+      msg = "Address family not supported by protocol";
+      break;
     case EADDRINUSE:
-      return "Address already in use";
+      msg = "Address already in use";
+      break;
     case EADDRNOTAVAIL:
-      return "Cannot assign requested address";
+      msg = "Cannot assign requested address";
+      break;
     case ENETDOWN:
-      return "Network is down";
+      msg = "Network is down";
+      break;
     case ENETUNREACH:
-      return "Network is unreachable";
+      msg = "Network is unreachable";
+      break;
     case ENETRESET:
-      return "Network dropped connection on reset";
+      msg = "Network dropped connection on reset";
+      break;
     case ECONNABORTED:
-      return "Software caused connection abort";
+      msg = "Software caused connection abort";
+      break;
     case ECONNRESET:
-      return "Connection reset by peer";
+      msg = "Connection reset by peer";
+      break;
     case ENOBUFS:
-      return "No buffer space available";
+      msg = "No buffer space available";
+      break;
     case EISCONN:
-      return "Transport endpoint is already connected";
+      msg = "Transport endpoint is already connected";
+      break;
     case ENOTCONN:
-      return "Transport endpoint is not connected";
+      msg = "Transport endpoint is not connected";
+      break;
     case ESHUTDOWN:
-      return "Cannot send after transport endpoint shutdown";
+      msg = "Cannot send after transport endpoint shutdown";
+      break;
     case ETOOMANYREFS:
-      return "Too many references: cannot splice";
+      msg = "Too many references: cannot splice";
+      break;
     case ETIMEDOUT:
-      return "Connection timed out";
+      msg = "Connection timed out";
+      break;
     case ECONNREFUSED:
-      return "Connection refused";
+      msg = "Connection refused";
+      break;
     case ELOOP:
-      return "Too many levels of symbolic links";
+      msg = "Too many levels of symbolic links";
+      break;
     case EHOSTDOWN:
-      return "Host is down";
+      msg = "Host is down";
+      break;
     case EHOSTUNREACH:
-      return "No route to host";
+      msg = "No route to host";
+      break;
     case EPROCLIM:
-      return "Too many processes";
+      msg = "Too many processes";
+      break;
     case EUSERS:
-      return "Too many users";
+      msg = "Too many users";
+      break;
     case EDQUOT:
-      return "Disk quota exceeded";
+      msg = "Disk quota exceeded";
+      break;
     case ESTALE:
-      return "Stale NFS file handle";
+      msg = "Stale NFS file handle";
+      break;
     case EREMOTE:
-      return "Object is remote";
+      msg = "Object is remote";
+      break;
 #  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";
+      msg = "Overlapped operation aborted";
+      break;
     case WSA_IO_INCOMPLETE:
-      return "Overlapped I/O event object not in signaled state";
+      msg = "Overlapped I/O event object not in signaled state";
+      break;
     case WSA_IO_PENDING:
-      return "Overlapped operations will complete later";
+      msg = "Overlapped operations will complete later";
+      break;
     /* WSAEINTR maps to EINTR */
     /* WSAEBADF maps to EBADF */
     /* WSAEACCES maps to EACCES */
@@ -172,98 +211,127 @@
     /* WSAESTALE is ESTALE */
     /* WSAEREMOTE is EREMOTE */
     case WSASYSNOTREADY:
-      return "Network subsystem is unavailable";
+      msg = "Network subsystem is unavailable";
+      break;
     case WSAVERNOTSUPPORTED:
-      return "Winsock.dll version out of range";
+      msg = "Winsock.dll version out of range";
+      break;
     case WSANOTINITIALISED:
-      return "Successful WSAStartup not yet performed";
+      msg = "Successful WSAStartup not yet performed";
+      break;
     case WSAEDISCON:
-      return "Graceful shutdown in progress";
+      msg = "Graceful shutdown in progress";
+      break;
     case WSAENOMORE: case WSA_E_NO_MORE:
-      return "No more results";
+      msg = "No more results";
+      break;
     case WSAECANCELLED: case WSA_E_CANCELLED:
-      return "Call was canceled";
+      msg = "Call was canceled";
+      break;
     case WSAEINVALIDPROCTABLE:
-      return "Procedure call table is invalid";
+      msg = "Procedure call table is invalid";
+      break;
     case WSAEINVALIDPROVIDER:
-      return "Service provider is invalid";
+      msg = "Service provider is invalid";
+      break;
     case WSAEPROVIDERFAILEDINIT:
-      return "Service provider failed to initialize";
+      msg = "Service provider failed to initialize";
+      break;
     case WSASYSCALLFAILURE:
-      return "System call failure";
+      msg = "System call failure";
+      break;
     case WSASERVICE_NOT_FOUND:
-      return "Service not found";
+      msg = "Service not found";
+      break;
     case WSATYPE_NOT_FOUND:
-      return "Class type not found";
+      msg = "Class type not found";
+      break;
     case WSAEREFUSED:
-      return "Database query was refused";
+      msg = "Database query was refused";
+      break;
     case WSAHOST_NOT_FOUND:
-      return "Host not found";
+      msg = "Host not found";
+      break;
     case WSATRY_AGAIN:
-      return "Nonauthoritative host not found";
+      msg = "Nonauthoritative host not found";
+      break;
     case WSANO_RECOVERY:
-      return "Nonrecoverable error";
+      msg = "Nonrecoverable error";
+      break;
     case WSANO_DATA:
-      return "Valid name, no data record of requested type";
+      msg = "Valid name, no data record of requested type";
+      break;
     /* WSA_QOS_* omitted */
 #  endif
 # endif
 
 # if GNULIB_defined_ENOMSG
     case ENOMSG:
-      return "No message of desired type";
+      msg = "No message of desired type";
+      break;
 # endif
 
 # if GNULIB_defined_EIDRM
     case EIDRM:
-      return "Identifier removed";
+      msg = "Identifier removed";
+      break;
 # endif
 
 # if GNULIB_defined_ENOLINK
     case ENOLINK:
-      return "Link has been severed";
+      msg = "Link has been severed";
+      break;
 # endif
 
 # if GNULIB_defined_EPROTO
     case EPROTO:
-      return "Protocol error";
+      msg = "Protocol error";
+      break;
 # endif
 
 # if GNULIB_defined_EMULTIHOP
     case EMULTIHOP:
-      return "Multihop attempted";
+      msg = "Multihop attempted";
+      break;
 # endif
 
 # if GNULIB_defined_EBADMSG
     case EBADMSG:
-      return "Bad message";
+      msg = "Bad message";
+      break;
 # endif
 
 # if GNULIB_defined_EOVERFLOW
     case EOVERFLOW:
-      return "Value too large for defined data type";
+      msg = "Value too large for defined data type";
+      break;
 # endif
 
 # if GNULIB_defined_ENOTSUP
     case ENOTSUP:
-      return "Not supported";
+      msg = "Not supported";
+      break;
 # endif
 
 # if GNULIB_defined_
     case ECANCELED:
-      return "Operation canceled";
+      msg = "Operation canceled";
+      break;
 # endif
     }
 
+  if (msg)
+    return (char *) msg;
+
   {
     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;
+	static char msg_buf[sizeof fmt + INT_STRLEN_BOUND (n)];
+	sprintf (msg_buf, fmt, n);
+	return msg_buf;
       }
 
     return result;

Modified: libprelude/trunk/libmissing/sys_select.in.h
===================================================================
--- libprelude/trunk/libmissing/sys_select.in.h	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/sys_select.in.h	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
 /* Substitute for <sys/select.h>.
-   Copyright (C) 2007-2008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -15,14 +15,28 @@
    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
+
+/* On OSF/1, <sys/types.h> and <sys/time.h> include <sys/select.h>.
+   Simply delegate to the system's header in this case.  */
+#if @HAVE_SYS_SELECT_H@ && defined __osf__ && (defined _SYS_TYPES_H_ && !defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TYPES_H) && defined _OSF_SOURCE
+
+# define _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TYPES_H
+# @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
+
+#elif @HAVE_SYS_SELECT_H@ && defined __osf__ && (defined _SYS_TIME_H_ && !defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H) && defined _OSF_SOURCE
+
+# define _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H
+# @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
+
+#else
+
 #ifndef _GL_SYS_SELECT_H
 
 #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>
@@ -52,7 +66,7 @@
 # endif
 
 # if @GNULIB_SELECT@
-#  if @HAVE_WINSOCK2_H@
+#  if @HAVE_WINSOCK2_H@ || @REPLACE_SELECT@
 #   undef select
 #   define select rpl_select
 extern int rpl_select (int, fd_set *, fd_set *, fd_set *, struct timeval *);
@@ -76,3 +90,4 @@
 
 #endif /* _GL_SYS_SELECT_H */
 #endif /* _GL_SYS_SELECT_H */
+#endif /* OSF/1 */

Modified: libprelude/trunk/libmissing/sys_socket.in.h
===================================================================
--- libprelude/trunk/libmissing/sys_socket.in.h	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/sys_socket.in.h	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,6 +1,6 @@
 /* Provide a sys/socket header file for systems lacking it (read: MinGW)
    and for systems where it is incomplete.
-   Copyright (C) 2005-2008 Free Software Foundation, Inc.
+   Copyright (C) 2005-2009 Free Software Foundation, Inc.
    Written by Simon Josefsson.
 
    This program is free software; you can redistribute it and/or modify
@@ -256,7 +256,7 @@
 #  if @HAVE_WINSOCK2_H@
 #   undef getsockopt
 #   define getsockopt		rpl_getsockopt
-extern int rpl_getsockopt (int, int, int, void *, int *);
+extern int rpl_getsockopt (int, int, int, void *, socklen_t *);
 #  endif
 # elif @HAVE_WINSOCK2_H@
 #  undef getsockopt
@@ -358,7 +358,7 @@
 #  if @HAVE_WINSOCK2_H@
 #   undef setsockopt
 #   define setsockopt		rpl_setsockopt
-extern int rpl_setsockopt (int, int, int, const void *, int);
+extern int rpl_setsockopt (int, int, int, const void *, socklen_t);
 #  endif
 # elif @HAVE_WINSOCK2_H@
 #  undef setsockopt

Modified: libprelude/trunk/libmissing/sys_stat.in.h
===================================================================
--- libprelude/trunk/libmissing/sys_stat.in.h	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/sys_stat.in.h	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
 /* Provide a more complete sys/stat header file.
-   Copyright (C) 2005-2008 Free Software Foundation, Inc.
+   Copyright (C) 2005-2009 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -35,6 +35,9 @@
 
 #ifndef _GL_SYS_STAT_H
 
+/* Get nlink_t.  */
+#include <sys/types.h>
+
 /* The include_next requires a split double-inclusion guard.  */
 #@INCLUDE_NEXT@ @NEXT_SYS_STAT_H@
 

Modified: libprelude/trunk/libmissing/sys_time.in.h
===================================================================
--- libprelude/trunk/libmissing/sys_time.in.h	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/sys_time.in.h	2009-04-07 07:51:35 UTC (rev 11123)
@@ -39,6 +39,10 @@
 #  include <time.h>
 # endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 # if ! @HAVE_STRUCT_TIMEVAL@
 struct timeval
 {
@@ -53,4 +57,8 @@
 int gettimeofday (struct timeval *restrict, void *restrict);
 # endif
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* _GL_SYS_TIME_H */

Modified: libprelude/trunk/libmissing/tests/Makefile.am
===================================================================
--- libprelude/trunk/libmissing/tests/Makefile.am	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/tests/Makefile.am	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,6 +1,6 @@
 ## DO NOT EDIT! GENERATED AUTOMATICALLY!
 ## Process this file with automake to produce Makefile.in.
-# Copyright (C) 2002-2008 Free Software Foundation, Inc.
+# Copyright (C) 2002-2009 Free Software Foundation, Inc.
 #
 # This file is free software, distributed under the terms of the GNU
 # General Public License.  As a special exception to the GNU General
@@ -60,6 +60,16 @@
 
 ## end   gnulib module arpa_inet-tests
 
+## begin gnulib module btowc-tests
+
+TESTS += test-btowc1.sh test-btowc2.sh
+TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' LOCALE_FR='@LOCALE_FR@' LOCALE_FR_UTF8='@LOCALE_FR_UTF8@'
+check_PROGRAMS += test-btowc
+
+EXTRA_DIST += test-btowc1.sh test-btowc2.sh test-btowc.c
+
+## end   gnulib module btowc-tests
+
 ## begin gnulib module c-ctype-tests
 
 TESTS += test-c-ctype
@@ -98,10 +108,10 @@
 
 ## begin gnulib module fseeko-tests
 
-TESTS += test-fseeko.sh
+TESTS += test-fseeko.sh test-fseeko2.sh
 TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='$(srcdir)'
 check_PROGRAMS += test-fseeko
-EXTRA_DIST += test-fseeko.c test-fseeko.sh
+EXTRA_DIST += test-fseeko.c test-fseeko.sh test-fseeko2.sh
 
 ## end   gnulib module fseeko-tests
 
@@ -109,7 +119,7 @@
 
 TESTS += test-getaddrinfo
 check_PROGRAMS += test-getaddrinfo
-test_getaddrinfo_LDADD = $(LDADD) @LIBINTL@
+test_getaddrinfo_LDADD = $(LDADD) @GETADDRINFO_LIB@ @LIBINTL@
 
 EXTRA_DIST += test-getaddrinfo.c
 
@@ -160,6 +170,31 @@
 
 ## end   gnulib module lseek-tests
 
+## begin gnulib module mbrtowc-tests
+
+TESTS += test-mbrtowc1.sh test-mbrtowc2.sh test-mbrtowc3.sh test-mbrtowc4.sh
+TESTS_ENVIRONMENT += \
+  EXEEXT='@EXEEXT@' \
+  LOCALE_FR='@LOCALE_FR@' \
+  LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \
+  LOCALE_JA='@LOCALE_JA@' \
+  LOCALE_ZH_CN='@LOCALE_ZH_CN@'
+check_PROGRAMS += test-mbrtowc
+
+EXTRA_DIST += test-mbrtowc1.sh test-mbrtowc2.sh test-mbrtowc3.sh test-mbrtowc4.sh test-mbrtowc.c
+
+## end   gnulib module mbrtowc-tests
+
+## begin gnulib module mbsinit-tests
+
+TESTS += test-mbsinit.sh
+TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' LOCALE_FR_UTF8='@LOCALE_FR_UTF8@'
+check_PROGRAMS += test-mbsinit
+
+EXTRA_DIST += test-mbsinit.sh test-mbsinit.c
+
+## end   gnulib module mbsinit-tests
+
 ## begin gnulib module memmem-tests
 
 TESTS += test-memmem
@@ -219,6 +254,15 @@
 
 ## end   gnulib module select-tests
 
+## begin gnulib module signal-tests
+
+TESTS += test-signal
+check_PROGRAMS += test-signal
+
+EXTRA_DIST += test-signal.c
+
+## end   gnulib module signal-tests
+
 ## begin gnulib module sleep-tests
 
 TESTS += test-sleep
@@ -241,6 +285,8 @@
 
 libtests_a_SOURCES += sockets.h sockets.c
 
+EXTRA_DIST += w32sock.h
+
 ## end   gnulib module sockets
 
 ## begin gnulib module sockets-tests
@@ -396,12 +442,6 @@
 
 ## end   gnulib module vasnprintf-tests
 
-## begin gnulib module verify
-
-libtests_a_SOURCES += verify.h
-
-## end   gnulib module verify
-
 ## begin gnulib module vsnprintf-tests
 
 TESTS += test-vsnprintf
@@ -420,6 +460,30 @@
 
 ## end   gnulib module wchar-tests
 
+## begin gnulib module wcrtomb-tests
+
+TESTS += test-wcrtomb.sh
+TESTS_ENVIRONMENT += \
+  EXEEXT='@EXEEXT@' \
+  LOCALE_FR='@LOCALE_FR@' \
+  LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \
+  LOCALE_JA='@LOCALE_JA@' \
+  LOCALE_ZH_CN='@LOCALE_ZH_CN@'
+check_PROGRAMS += test-wcrtomb
+
+EXTRA_DIST += test-wcrtomb.sh test-wcrtomb.c
+
+## end   gnulib module wcrtomb-tests
+
+## begin gnulib module wctob
+
+
+EXTRA_DIST += wctob.c
+
+EXTRA_libtests_a_SOURCES += wctob.c
+
+## end   gnulib module wctob
+
 ## begin gnulib module wctype-tests
 
 TESTS += test-wctype

Modified: libprelude/trunk/libmissing/tests/sockets.c
===================================================================
--- libprelude/trunk/libmissing/tests/sockets.c	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/tests/sockets.c	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,6 +1,6 @@
 /* sockets.c --- wrappers for Windows socket functions
 
-   Copyright (C) 2008 Free Software Foundation, Inc.
+   Copyright (C) 2008-2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -19,11 +19,58 @@
 
 #include <config.h>
 
+/* Specification.  */
+#include "sockets.h"
+
+#if WINDOWS_SOCKETS
+
 /* This includes winsock2.h on MinGW. */
 #include <sys/socket.h>
 
-#include "sockets.h"
+#include "close-hook.h"
 
+/* Get set_winsock_errno, FD_TO_SOCKET etc. */
+#include "w32sock.h"
+
+static int
+close_fd_maybe_socket (int fd, const struct close_hook *remaining_list)
+{
+  SOCKET sock;
+  WSANETWORKEVENTS ev;
+
+  /* Test whether fd refers to a socket.  */
+  sock = FD_TO_SOCKET (fd);
+  ev.lNetworkEvents = 0xDEADBEEF;
+  WSAEnumNetworkEvents (sock, NULL, &ev);
+  if (ev.lNetworkEvents != 0xDEADBEEF)
+    {
+      /* fd refers to a socket.  */
+      /* FIXME: other applications, like squid, use an undocumented
+	 _free_osfhnd free function.  But this is not enough: The 'osfile'
+	 flags for fd also needs to be cleared, but it is hard to access it.
+	 Instead, here we just close twice the file descriptor.  */
+      if (closesocket (sock))
+	{
+	  set_winsock_errno ();
+	  return -1;
+	}
+      else
+	{
+	  /* This call frees the file descriptor and does a
+	     CloseHandle ((HANDLE) _get_osfhandle (fd)), which fails.  */
+	  _close (fd);
+	  return 0;
+	}
+    }
+  else
+    /* Some other type of file descriptor.  */
+    return execute_close_hooks (fd, remaining_list);
+}
+
+static struct close_hook close_sockets_hook;
+
+#endif
+
 int
 gl_sockets_startup (int version)
 {
@@ -37,6 +84,8 @@
 
   if (data.wVersion < version)
     return 2;
+
+  register_close_hook (close_fd_maybe_socket, &close_sockets_hook);
 #endif
 
   return 0;
@@ -48,6 +97,8 @@
 #if WINDOWS_SOCKETS
   int err;
 
+  unregister_close_hook (&close_sockets_hook);
+
   err = WSACleanup ();
   if (err != 0)
     return 1;

Modified: libprelude/trunk/libmissing/tests/sockets.h
===================================================================
--- libprelude/trunk/libmissing/tests/sockets.h	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/tests/sockets.h	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,6 +1,6 @@
 /* sockets.h - wrappers for Windows socket functions
 
-   Copyright (C) 2008 Free Software Foundation, Inc.
+   Copyright (C) 2008, 2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -29,4 +29,23 @@
 int gl_sockets_startup (int version);
 int gl_sockets_cleanup (void);
 
-#endif
+/* This function is useful it you create a socket using gnulib's
+   Winsock wrappers but needs to pass on the socket handle to some
+   other library that only accepts sockets. */
+#if WINDOWS_SOCKETS
+
+#include <sys/socket.h>
+
+static inline SOCKET
+gl_fd_to_handle (int fd)
+{
+  return _get_osfhandle (fd);
+}
+
+#else
+
+#define gl_fd_to_handle(x) (x)
+
+#endif /* WINDOWS_SOCKETS */
+
+#endif /* SOCKETS_H */

Added: libprelude/trunk/libmissing/tests/test-btowc.c
===================================================================
--- libprelude/trunk/libmissing/tests/test-btowc.c	                        (rev 0)
+++ libprelude/trunk/libmissing/tests/test-btowc.c	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,71 @@
+/* Test of conversion of unibyte character to wide character.
+   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 <[email protected]>, 2008.  */
+
+#include <config.h>
+
+#include <wchar.h>
+
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define ASSERT(expr) \
+  do									     \
+    {									     \
+      if (!(expr))							     \
+        {								     \
+          fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+          fflush (stderr);						     \
+          abort ();							     \
+        }								     \
+    }									     \
+  while (0)
+
+int
+main (int argc, char *argv[])
+{
+  int c;
+
+  /* configure should already have checked that the locale is supported.  */
+  if (setlocale (LC_ALL, "") == NULL)
+    return 1;
+
+  ASSERT (btowc (EOF) == WEOF);
+
+  if (argc > 1)
+    switch (argv[1][0])
+      {
+      case '1':
+	/* Locale encoding is ISO-8859-1 or ISO-8859-15.  */
+	for (c = 0; c < 0x80; c++)
+	  ASSERT (btowc (c) == c);
+	for (c = 0xA0; c < 0x100; c++)
+	  ASSERT (btowc (c) != WEOF);
+	return 0;
+
+      case '2':
+	/* Locale encoding is UTF-8.  */
+	for (c = 0; c < 0x80; c++)
+	  ASSERT (btowc (c) == c);
+	for (c = 0x80; c < 0x100; c++)
+	  ASSERT (btowc (c) == WEOF);
+	return 0;
+      }
+
+  return 1;
+}

Added: libprelude/trunk/libmissing/tests/test-btowc1.sh
===================================================================
--- libprelude/trunk/libmissing/tests/test-btowc1.sh	                        (rev 0)
+++ libprelude/trunk/libmissing/tests/test-btowc1.sh	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Test in an ISO-8859-1 or ISO-8859-15 locale.
+: ${LOCALE_FR=fr_FR}
+if test $LOCALE_FR = none; then
+  if test -f /usr/bin/localedef; then
+    echo "Skipping test: no traditional french locale is installed"
+  else
+    echo "Skipping test: no traditional french locale is supported"
+  fi
+  exit 77
+fi
+
+LC_ALL=$LOCALE_FR \
+./test-btowc${EXEEXT} 1


Property changes on: libprelude/trunk/libmissing/tests/test-btowc1.sh
___________________________________________________________________
Name: svn:executable
   + *

Added: libprelude/trunk/libmissing/tests/test-btowc2.sh
===================================================================
--- libprelude/trunk/libmissing/tests/test-btowc2.sh	                        (rev 0)
+++ libprelude/trunk/libmissing/tests/test-btowc2.sh	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Test whether a specific UTF-8 locale is installed.
+: ${LOCALE_FR_UTF8=fr_FR.UTF-8}
+if test $LOCALE_FR_UTF8 = none; then
+  if test -f /usr/bin/localedef; then
+    echo "Skipping test: no french Unicode locale is installed"
+  else
+    echo "Skipping test: no french Unicode locale is supported"
+  fi
+  exit 77
+fi
+
+LC_ALL=$LOCALE_FR_UTF8 \
+./test-btowc${EXEEXT} 2


Property changes on: libprelude/trunk/libmissing/tests/test-btowc2.sh
___________________________________________________________________
Name: svn:executable
   + *

Modified: libprelude/trunk/libmissing/tests/test-fseeko.c
===================================================================
--- libprelude/trunk/libmissing/tests/test-fseeko.c	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/tests/test-fseeko.c	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
 /* Test of fseeko() function.
-   Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -33,6 +33,10 @@
     }									     \
   while (0)
 
+#ifndef FUNC_UNGETC_BROKEN
+# define FUNC_UNGETC_BROKEN 0
+#endif
+
 int
 main (int argc, char **argv)
 {
@@ -50,10 +54,19 @@
       ASSERT (ch == '#');
       ASSERT (ungetc (ch, stdin) == ch);
       ASSERT (fseeko (stdin, 2, SEEK_SET) == 0);
-      /* Test that fseek discards random ungetc data.  */
       ch = fgetc (stdin);
       ASSERT (ch == '/');
-      ASSERT (ungetc (ch ^ 0xff, stdin) == (ch ^ 0xff));
+      if (2 < argc)
+        {
+          if (FUNC_UNGETC_BROKEN)
+            {
+              fputs ("Skipping test: ungetc cannot handle arbitrary bytes\n",
+                     stderr);
+              return 77;
+            }
+          /* Test that fseek discards random ungetc data.  */
+          ASSERT (ungetc (ch ^ 0xff, stdin) == (ch ^ 0xff));
+        }
       ASSERT (fseeko (stdin, 0, SEEK_END) == 0);
       ASSERT (fgetc (stdin) == EOF);
       /* Test that fseek resets end-of-file marker.  */

Added: libprelude/trunk/libmissing/tests/test-fseeko2.sh
===================================================================
--- libprelude/trunk/libmissing/tests/test-fseeko2.sh	                        (rev 0)
+++ libprelude/trunk/libmissing/tests/test-fseeko2.sh	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+exec ./test-fseeko${EXEEXT} 1 2 < "$srcdir/test-fseeko2.sh"


Property changes on: libprelude/trunk/libmissing/tests/test-fseeko2.sh
___________________________________________________________________
Name: svn:executable
   + *

Modified: libprelude/trunk/libmissing/tests/test-getaddrinfo.c
===================================================================
--- libprelude/trunk/libmissing/tests/test-getaddrinfo.c	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/tests/test-getaddrinfo.c	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,6 +1,6 @@
 /* Test the getaddrinfo module.
 
-   Copyright (C) 2006-2008 Free Software Foundation, Inc.
+   Copyright (C) 2006-2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -19,7 +19,9 @@
 
 #include <config.h>
 #include <netdb.h>
+
 #include <arpa/inet.h>
+#include <errno.h>
 #include <netinet/in.h>
 #include <stdio.h>
 #include <string.h>
@@ -45,10 +47,16 @@
 int simple (char *host, char *service)
 {
   char buf[BUFSIZ];
+  static int skip = 0;
   struct addrinfo hints;
   struct addrinfo *ai0, *ai;
   int res;
+  int err;
 
+  /* Once we skipped the test, do not try anything else */
+  if (skip)
+    return 0;
+
   dbgprintf ("Finding %s service %s...\n", host, service);
 
   /* This initializes "hints" but does not use it.  Is there a reason
@@ -59,23 +67,36 @@
   hints.ai_socktype = SOCK_STREAM;
 
   res = getaddrinfo (host, service, 0, &ai0);
+  err = errno;
 
   dbgprintf ("res %d: %s\n", res, gai_strerror (res));
 
   if (res != 0)
     {
+      /* EAI_AGAIN is returned if no network is available. Don't fail
+	 the test merely because someone is down the country on their
+	 in-law's farm. */
+      if (res == EAI_AGAIN)
+	{
+	  skip++;
+	  fprintf (stderr, "skipping getaddrinfo test: no network?\n");
+	  return 77;
+	}
       /* IRIX reports EAI_NONAME for "https".  Don't fail the test
 	 merely because of this.  */
       if (res == EAI_NONAME)
 	return 0;
       /* Solaris reports EAI_SERVICE for "http" and "https".  Don't
-         fail the test merely because of this.  */
+	 fail the test merely because of this.  */
       if (res == EAI_SERVICE)
 	return 0;
       /* AIX reports EAI_NODATA for "https".  Don't fail the test
 	 merely because of this.  */
       if (res == EAI_NODATA)
 	return 0;
+      /* Provide details if errno was set.  */
+      if (res == EAI_SYSTEM)
+	dbgprintf ("system error: %s\n", strerror (err));
 
       return 1;
     }

Modified: libprelude/trunk/libmissing/tests/test-lock.c
===================================================================
--- libprelude/trunk/libmissing/tests/test-lock.c	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/tests/test-lock.c	2009-04-07 07:51:35 UTC (rev 11123)
@@ -125,6 +125,9 @@
     abort ();
 }
 
+
+/* ------------------- Test normal (non-recursive) locks ------------------- */
+
 /* Test normal locks by having several bank accounts and several threads
    which shuffle around money between the accounts and another thread
    checking that all the money is still there.  */
@@ -187,7 +190,7 @@
   return NULL;
 }
 
-void
+static void
 test_lock (void)
 {
   int i;
@@ -212,6 +215,9 @@
   check_accounts ();
 }
 
+
+/* ----------------- Test read-write (non-recursive) locks ----------------- */
+
 /* Test read-write locks by having several bank accounts and several threads
    which shuffle around money between the accounts and several other threads
    that check that all the money is still there.  */
@@ -268,7 +274,7 @@
   return NULL;
 }
 
-void
+static void
 test_rwlock (void)
 {
   int i;
@@ -295,6 +301,9 @@
   check_accounts ();
 }
 
+
+/* -------------------------- Test recursive locks -------------------------- */
+
 /* Test recursive locks by having several bank accounts and several threads
    which shuffle around money between the accounts (recursively) and another
    thread checking that all the money is still there.  */
@@ -367,7 +376,7 @@
   return NULL;
 }
 
-void
+static void
 test_recursive_lock (void)
 {
   int i;
@@ -392,6 +401,9 @@
   check_accounts ();
 }
 
+
+/* ------------------------ Test once-only execution ------------------------ */
+
 /* Test once-only execution by having several threads attempt to grab a
    once-only task simultaneously (triggered by releasing a read-write lock).  */
 
@@ -453,7 +465,7 @@
   return NULL;
 }
 
-void
+static void
 test_once (void)
 {
   int i, repeat;
@@ -538,6 +550,9 @@
     gl_thread_join (threads[i], NULL);
 }
 
+
+/* -------------------------------------------------------------------------- */
+
 int
 main ()
 {

Added: libprelude/trunk/libmissing/tests/test-mbrtowc.c
===================================================================
--- libprelude/trunk/libmissing/tests/test-mbrtowc.c	                        (rev 0)
+++ libprelude/trunk/libmissing/tests/test-mbrtowc.c	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,330 @@
+/* Test of conversion of multibyte character to wide character.
+   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 <[email protected]>, 2008.  */
+
+#include <config.h>
+
+#include <wchar.h>
+
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define ASSERT(expr) \
+  do									     \
+    {									     \
+      if (!(expr))							     \
+        {								     \
+          fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+          fflush (stderr);						     \
+          abort ();							     \
+        }								     \
+    }									     \
+  while (0)
+
+int
+main (int argc, char *argv[])
+{
+  mbstate_t state;
+  wchar_t wc;
+  size_t ret;
+
+  /* configure should already have checked that the locale is supported.  */
+  if (setlocale (LC_ALL, "") == NULL)
+    return 1;
+
+  /* Test zero-length input.  */
+  {
+    memset (&state, '\0', sizeof (mbstate_t));
+    wc = (wchar_t) 0xBADFACE;
+    ret = mbrtowc (&wc, "x", 0, &state);
+    /* gnulib's implementation returns (size_t)(-2).
+       The AIX 5.1 implementation returns (size_t)(-1).
+       glibc's implementation returns 0.  */
+    ASSERT (ret == (size_t)(-2) || ret == (size_t)(-1) || ret == 0);
+    ASSERT (mbsinit (&state));
+  }
+
+  /* Test NUL byte input.  */
+  {
+    memset (&state, '\0', sizeof (mbstate_t));
+    wc = (wchar_t) 0xBADFACE;
+    ret = mbrtowc (&wc, "", 1, &state);
+    ASSERT (ret == 0);
+    ASSERT (wc == 0);
+    ASSERT (mbsinit (&state));
+    ret = mbrtowc (NULL, "", 1, &state);
+    ASSERT (ret == 0);
+    ASSERT (mbsinit (&state));
+  }
+
+  /* Test single-byte input.  */
+  {
+    int c;
+    char buf[1];
+
+    memset (&state, '\0', sizeof (mbstate_t));
+    for (c = 0; c < 0x100; c++)
+      switch (c)
+	{
+	case '\t': case '\v': case '\f':
+	case ' ': case '!': case '"': case '#': case '%':
+	case '&': case '\'': case '(': case ')': case '*':
+	case '+': case ',': case '-': case '.': case '/':
+	case '0': case '1': case '2': case '3': case '4':
+	case '5': case '6': case '7': case '8': case '9':
+	case ':': case ';': case '<': case '=': case '>':
+	case '?':
+	case 'A': case 'B': case 'C': case 'D': case 'E':
+	case 'F': case 'G': case 'H': case 'I': case 'J':
+	case 'K': case 'L': case 'M': case 'N': case 'O':
+	case 'P': case 'Q': case 'R': case 'S': case 'T':
+	case 'U': case 'V': case 'W': case 'X': case 'Y':
+	case 'Z':
+	case '[': case '\\': case ']': case '^': case '_':
+	case 'a': case 'b': case 'c': case 'd': case 'e':
+	case 'f': case 'g': case 'h': case 'i': case 'j':
+	case 'k': case 'l': case 'm': case 'n': case 'o':
+	case 'p': case 'q': case 'r': case 's': case 't':
+	case 'u': case 'v': case 'w': case 'x': case 'y':
+	case 'z': case '{': case '|': case '}': case '~':
+	  /* c is in the ISO C "basic character set".  */
+	  buf[0] = c;
+	  wc = (wchar_t) 0xBADFACE;
+	  ret = mbrtowc (&wc, buf, 1, &state);
+	  ASSERT (ret == 1);
+	  ASSERT (wc == c);
+	  ASSERT (mbsinit (&state));
+	  ret = mbrtowc (NULL, buf, 1, &state);
+	  ASSERT (ret == 1);
+	  ASSERT (mbsinit (&state));
+	  break;
+	}
+  }
+
+  /* Test special calling convention, passing a NULL pointer.  */
+  {
+    memset (&state, '\0', sizeof (mbstate_t));
+    wc = (wchar_t) 0xBADFACE;
+    ret = mbrtowc (&wc, NULL, 5, &state);
+    ASSERT (ret == 0);
+    ASSERT (wc == (wchar_t) 0xBADFACE);
+    ASSERT (mbsinit (&state));
+  }
+
+  if (argc > 1)
+    switch (argv[1][0])
+      {
+      case '1':
+	/* Locale encoding is ISO-8859-1 or ISO-8859-15.  */
+	{
+	  char input[] = "B\374\337er"; /* "Büßer" */
+	  memset (&state, '\0', sizeof (mbstate_t));
+
+	  wc = (wchar_t) 0xBADFACE;
+	  ret = mbrtowc (&wc, input, 1, &state);
+	  ASSERT (ret == 1);
+	  ASSERT (wc == 'B');
+	  ASSERT (mbsinit (&state));
+	  input[0] = '\0';
+
+	  wc = (wchar_t) 0xBADFACE;
+	  ret = mbrtowc (&wc, input + 1, 1, &state);
+	  ASSERT (ret == 1);
+	  ASSERT (wctob (wc) == (unsigned char) '\374');
+	  ASSERT (mbsinit (&state));
+	  input[1] = '\0';
+
+	  wc = (wchar_t) 0xBADFACE;
+	  ret = mbrtowc (&wc, input + 2, 3, &state);
+	  ASSERT (ret == 1);
+	  ASSERT (wctob (wc) == (unsigned char) '\337');
+	  ASSERT (mbsinit (&state));
+	  input[2] = '\0';
+
+	  wc = (wchar_t) 0xBADFACE;
+	  ret = mbrtowc (&wc, input + 3, 2, &state);
+	  ASSERT (ret == 1);
+	  ASSERT (wc == 'e');
+	  ASSERT (mbsinit (&state));
+	  input[3] = '\0';
+
+	  wc = (wchar_t) 0xBADFACE;
+	  ret = mbrtowc (&wc, input + 4, 1, &state);
+	  ASSERT (ret == 1);
+	  ASSERT (wc == 'r');
+	  ASSERT (mbsinit (&state));
+	}
+	return 0;
+
+      case '2':
+	/* Locale encoding is UTF-8.  */
+	{
+	  char input[] = "B\303\274\303\237er"; /* "Büßer" */
+	  memset (&state, '\0', sizeof (mbstate_t));
+
+	  wc = (wchar_t) 0xBADFACE;
+	  ret = mbrtowc (&wc, input, 1, &state);
+	  ASSERT (ret == 1);
+	  ASSERT (wc == 'B');
+	  ASSERT (mbsinit (&state));
+	  input[0] = '\0';
+
+	  wc = (wchar_t) 0xBADFACE;
+	  ret = mbrtowc (&wc, input + 1, 1, &state);
+	  ASSERT (ret == (size_t)(-2));
+	  ASSERT (wc == (wchar_t) 0xBADFACE);
+	  ASSERT (!mbsinit (&state));
+	  input[1] = '\0';
+
+	  wc = (wchar_t) 0xBADFACE;
+	  ret = mbrtowc (&wc, input + 2, 5, &state);
+	  ASSERT (ret == 1);
+	  ASSERT (wctob (wc) == EOF);
+	  ASSERT (mbsinit (&state));
+	  input[2] = '\0';
+
+	  wc = (wchar_t) 0xBADFACE;
+	  ret = mbrtowc (&wc, input + 3, 4, &state);
+	  ASSERT (ret == 2);
+	  ASSERT (wctob (wc) == EOF);
+	  ASSERT (mbsinit (&state));
+	  input[3] = '\0';
+	  input[4] = '\0';
+
+	  wc = (wchar_t) 0xBADFACE;
+	  ret = mbrtowc (&wc, input + 5, 2, &state);
+	  ASSERT (ret == 1);
+	  ASSERT (wc == 'e');
+	  ASSERT (mbsinit (&state));
+	  input[5] = '\0';
+
+	  wc = (wchar_t) 0xBADFACE;
+	  ret = mbrtowc (&wc, input + 6, 1, &state);
+	  ASSERT (ret == 1);
+	  ASSERT (wc == 'r');
+	  ASSERT (mbsinit (&state));
+	}
+	return 0;
+
+      case '3':
+	/* Locale encoding is EUC-JP.  */
+	{
+	  char input[] = "<\306\374\313\334\270\354>"; /* "<日本語>" */
+	  memset (&state, '\0', sizeof (mbstate_t));
+
+	  wc = (wchar_t) 0xBADFACE;
+	  ret = mbrtowc (&wc, input, 1, &state);
+	  ASSERT (ret == 1);
+	  ASSERT (wc == '<');
+	  ASSERT (mbsinit (&state));
+	  input[0] = '\0';
+
+	  wc = (wchar_t) 0xBADFACE;
+	  ret = mbrtowc (&wc, input + 1, 2, &state);
+	  ASSERT (ret == 2);
+	  ASSERT (wctob (wc) == EOF);
+	  ASSERT (mbsinit (&state));
+	  input[1] = '\0';
+	  input[2] = '\0';
+
+	  wc = (wchar_t) 0xBADFACE;
+	  ret = mbrtowc (&wc, input + 3, 1, &state);
+	  ASSERT (ret == (size_t)(-2));
+	  ASSERT (wc == (wchar_t) 0xBADFACE);
+	  ASSERT (!mbsinit (&state));
+	  input[3] = '\0';
+
+	  wc = (wchar_t) 0xBADFACE;
+	  ret = mbrtowc (&wc, input + 4, 4, &state);
+	  ASSERT (ret == 1);
+	  ASSERT (wctob (wc) == EOF);
+	  ASSERT (mbsinit (&state));
+	  input[4] = '\0';
+
+	  wc = (wchar_t) 0xBADFACE;
+	  ret = mbrtowc (&wc, input + 5, 3, &state);
+	  ASSERT (ret == 2);
+	  ASSERT (wctob (wc) == EOF);
+	  ASSERT (mbsinit (&state));
+	  input[5] = '\0';
+	  input[6] = '\0';
+
+	  wc = (wchar_t) 0xBADFACE;
+	  ret = mbrtowc (&wc, input + 7, 1, &state);
+	  ASSERT (ret == 1);
+	  ASSERT (wc == '>');
+	  ASSERT (mbsinit (&state));
+	}
+	return 0;
+
+      case '4':
+	/* Locale encoding is GB18030.  */
+	{
+	  char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */
+	  memset (&state, '\0', sizeof (mbstate_t));
+
+	  wc = (wchar_t) 0xBADFACE;
+	  ret = mbrtowc (&wc, input, 1, &state);
+	  ASSERT (ret == 1);
+	  ASSERT (wc == 'B');
+	  ASSERT (mbsinit (&state));
+	  input[0] = '\0';
+
+	  wc = (wchar_t) 0xBADFACE;
+	  ret = mbrtowc (&wc, input + 1, 1, &state);
+	  ASSERT (ret == (size_t)(-2));
+	  ASSERT (wc == (wchar_t) 0xBADFACE);
+	  ASSERT (!mbsinit (&state));
+	  input[1] = '\0';
+
+	  wc = (wchar_t) 0xBADFACE;
+	  ret = mbrtowc (&wc, input + 2, 7, &state);
+	  ASSERT (ret == 1);
+	  ASSERT (wctob (wc) == EOF);
+	  ASSERT (mbsinit (&state));
+	  input[2] = '\0';
+
+	  wc = (wchar_t) 0xBADFACE;
+	  ret = mbrtowc (&wc, input + 3, 6, &state);
+	  ASSERT (ret == 4);
+	  ASSERT (wctob (wc) == EOF);
+	  ASSERT (mbsinit (&state));
+	  input[3] = '\0';
+	  input[4] = '\0';
+	  input[5] = '\0';
+	  input[6] = '\0';
+
+	  wc = (wchar_t) 0xBADFACE;
+	  ret = mbrtowc (&wc, input + 7, 2, &state);
+	  ASSERT (ret == 1);
+	  ASSERT (wc == 'e');
+	  ASSERT (mbsinit (&state));
+	  input[5] = '\0';
+
+	  wc = (wchar_t) 0xBADFACE;
+	  ret = mbrtowc (&wc, input + 8, 1, &state);
+	  ASSERT (ret == 1);
+	  ASSERT (wc == 'r');
+	  ASSERT (mbsinit (&state));
+	}
+	return 0;
+      }
+
+  return 1;
+}

Added: libprelude/trunk/libmissing/tests/test-mbrtowc1.sh
===================================================================
--- libprelude/trunk/libmissing/tests/test-mbrtowc1.sh	                        (rev 0)
+++ libprelude/trunk/libmissing/tests/test-mbrtowc1.sh	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Test in an ISO-8859-1 or ISO-8859-15 locale.
+: ${LOCALE_FR=fr_FR}
+if test $LOCALE_FR = none; then
+  if test -f /usr/bin/localedef; then
+    echo "Skipping test: no traditional french locale is installed"
+  else
+    echo "Skipping test: no traditional french locale is supported"
+  fi
+  exit 77
+fi
+
+LC_ALL=$LOCALE_FR \
+./test-mbrtowc${EXEEXT} 1


Property changes on: libprelude/trunk/libmissing/tests/test-mbrtowc1.sh
___________________________________________________________________
Name: svn:executable
   + *

Added: libprelude/trunk/libmissing/tests/test-mbrtowc2.sh
===================================================================
--- libprelude/trunk/libmissing/tests/test-mbrtowc2.sh	                        (rev 0)
+++ libprelude/trunk/libmissing/tests/test-mbrtowc2.sh	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Test whether a specific UTF-8 locale is installed.
+: ${LOCALE_FR_UTF8=fr_FR.UTF-8}
+if test $LOCALE_FR_UTF8 = none; then
+  if test -f /usr/bin/localedef; then
+    echo "Skipping test: no french Unicode locale is installed"
+  else
+    echo "Skipping test: no french Unicode locale is supported"
+  fi
+  exit 77
+fi
+
+LC_ALL=$LOCALE_FR_UTF8 \
+./test-mbrtowc${EXEEXT} 2


Property changes on: libprelude/trunk/libmissing/tests/test-mbrtowc2.sh
___________________________________________________________________
Name: svn:executable
   + *

Added: libprelude/trunk/libmissing/tests/test-mbrtowc3.sh
===================================================================
--- libprelude/trunk/libmissing/tests/test-mbrtowc3.sh	                        (rev 0)
+++ libprelude/trunk/libmissing/tests/test-mbrtowc3.sh	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Test whether a specific EUC-JP locale is installed.
+: ${LOCALE_JA=ja_JP}
+if test $LOCALE_JA = none; then
+  if test -f /usr/bin/localedef; then
+    echo "Skipping test: no traditional japanese locale is installed"
+  else
+    echo "Skipping test: no traditional japanese locale is supported"
+  fi
+  exit 77
+fi
+
+LC_ALL=$LOCALE_JA \
+./test-mbrtowc${EXEEXT} 3


Property changes on: libprelude/trunk/libmissing/tests/test-mbrtowc3.sh
___________________________________________________________________
Name: svn:executable
   + *

Added: libprelude/trunk/libmissing/tests/test-mbrtowc4.sh
===================================================================
--- libprelude/trunk/libmissing/tests/test-mbrtowc4.sh	                        (rev 0)
+++ libprelude/trunk/libmissing/tests/test-mbrtowc4.sh	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Test whether a specific GB18030 locale is installed.
+: ${LOCALE_ZH_CN=zh_CN.GB18030}
+if test $LOCALE_ZH_CN = none; then
+  if test -f /usr/bin/localedef; then
+    echo "Skipping test: no transitional chinese locale is installed"
+  else
+    echo "Skipping test: no transitional chinese locale is supported"
+  fi
+  exit 77
+fi
+
+LC_ALL=$LOCALE_ZH_CN \
+./test-mbrtowc${EXEEXT} 4


Property changes on: libprelude/trunk/libmissing/tests/test-mbrtowc4.sh
___________________________________________________________________
Name: svn:executable
   + *

Added: libprelude/trunk/libmissing/tests/test-mbsinit.c
===================================================================
--- libprelude/trunk/libmissing/tests/test-mbsinit.c	                        (rev 0)
+++ libprelude/trunk/libmissing/tests/test-mbsinit.c	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,62 @@
+/* Test of test for initial conversion state.
+   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 <[email protected]>, 2008.  */
+
+#include <config.h>
+
+#include <wchar.h>
+
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#define ASSERT(expr) \
+  do									     \
+    {									     \
+      if (!(expr))							     \
+        {								     \
+          fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+          fflush (stderr);						     \
+          abort ();							     \
+        }								     \
+    }									     \
+  while (0)
+
+int
+main (int argc, char *argv[])
+{
+  static mbstate_t state;
+
+  ASSERT (mbsinit (&state));
+
+  if (argc > 1)
+    {
+      static const char input[1] = "\303";
+      wchar_t wc;
+      size_t ret;
+
+      /* configure should already have checked that the locale is supported.  */
+      if (setlocale (LC_ALL, "") == NULL)
+	return 1;
+
+      ret = mbrtowc (&wc, input, 1, &state);
+      ASSERT (ret == (size_t)(-2));
+      ASSERT (!mbsinit (&state));
+    }
+
+  return 0;
+}

Added: libprelude/trunk/libmissing/tests/test-mbsinit.sh
===================================================================
--- libprelude/trunk/libmissing/tests/test-mbsinit.sh	                        (rev 0)
+++ libprelude/trunk/libmissing/tests/test-mbsinit.sh	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Test whether a specific UTF-8 locale is installed.
+: ${LOCALE_FR_UTF8=fr_FR.UTF-8}
+if test $LOCALE_FR_UTF8 = none; then
+  if test -f /usr/bin/localedef; then
+    echo "Skipping test: no french Unicode locale is installed"
+  else
+    echo "Skipping test: no french Unicode locale is supported"
+  fi
+  exit 77
+fi
+
+LC_ALL=$LOCALE_FR_UTF8 \
+./test-mbsinit${EXEEXT}


Property changes on: libprelude/trunk/libmissing/tests/test-mbsinit.sh
___________________________________________________________________
Name: svn:executable
   + *

Modified: libprelude/trunk/libmissing/tests/test-poll.c
===================================================================
--- libprelude/trunk/libmissing/tests/test-poll.c	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/tests/test-poll.c	2009-04-07 07:51:35 UTC (rev 11123)
@@ -368,10 +368,8 @@
 #endif
 
   result = test (test_connect_first, "Unconnected socket test");
-#if ! defined(__OpenBSD__)
   result += test (test_socket_pair, "Connected sockets test");
   result += test (test_accept_first, "General socket test with fork");
-#endif
   result += test (test_pipe, "Pipe test");
 
   exit (result);

Modified: libprelude/trunk/libmissing/tests/test-select-in.sh
===================================================================
--- libprelude/trunk/libmissing/tests/test-select-in.sh	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/tests/test-select-in.sh	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,6 +1,9 @@
 #!/bin/sh
 # Test select() on file descriptors opened for reading.
 
+# This test is known to fail on Solaris 2.6 and older, due to its handling
+# of /dev/null.
+
 tmpfiles=""
 trap 'rm -fr $tmpfiles' 1 2 3 15
 
@@ -23,6 +26,7 @@
 test `cat t-select-in.tmp` = "1" || exit 1
 
 # Special files.
+# This part of the test is known to fail on Solaris 2.6 and older.
 
 rm -f t-select-in.tmp
 ./test-select-fd${EXEEXT} r 0 t-select-in.tmp < /dev/null

Modified: libprelude/trunk/libmissing/tests/test-select-out.sh
===================================================================
--- libprelude/trunk/libmissing/tests/test-select-out.sh	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/tests/test-select-out.sh	2009-04-07 07:51:35 UTC (rev 11123)
@@ -14,13 +14,15 @@
 
 # Pipes.
 
-#rm -f t-select-out.tmp
-#( { echo abc; ./test-select-fd${EXEEXT} w 1 t-select-out.tmp; } | { sleep 1; cat; } ) > /dev/null
-#test `cat t-select-out.tmp` = "0" || exit 1
+if false; then # This test fails on some platforms.
+  rm -f t-select-out.tmp
+  ( { echo abc; ./test-select-fd${EXEEXT} w 1 t-select-out.tmp; } | { sleep 1; cat; } ) > /dev/null
+  test `cat t-select-out.tmp` = "0" || exit 1
+fi
 
-#rm -f t-select-out.tmp
-#( { sleep 1; echo abc; ./test-select-fd${EXEEXT} w 1 t-select-out.tmp; } | cat) > /dev/null
-#test `cat t-select-out.tmp` = "1" || exit 1
+rm -f t-select-out.tmp
+( { sleep 1; echo abc; ./test-select-fd${EXEEXT} w 1 t-select-out.tmp; } | cat) > /dev/null
+test `cat t-select-out.tmp` = "1" || exit 1
 
 # Special files.
 

Copied: libprelude/trunk/libmissing/tests/test-signal.c (from rev 11101, libprelude/trunk/libmissing/tests/sockets.h)
===================================================================
--- libprelude/trunk/libmissing/tests/test-signal.c	                        (rev 0)
+++ libprelude/trunk/libmissing/tests/test-signal.c	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,28 @@
+/* Test of <signal.h> substitute.
+   Copyright (C) 2009 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Eric Blake <[email protected]>, 2009.  */
+
+#include <config.h>
+
+#include <signal.h>
+
+volatile sig_atomic_t s;
+
+int main ()
+{
+  return s;
+}

Modified: libprelude/trunk/libmissing/tests/test-sockets.c
===================================================================
--- libprelude/trunk/libmissing/tests/test-sockets.c	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/tests/test-sockets.c	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008 Free Software Foundation
+ * Copyright (C) 2008, 2009 Free Software Foundation
  * Written by Simon Josefsson.
  *
  * This program is free software: you can redistribute it and/or modify
@@ -40,5 +40,7 @@
       return 1;
     }
 
+  (void) gl_fd_to_handle (0);
+
   return 0;
 }

Modified: libprelude/trunk/libmissing/tests/test-tls.c
===================================================================
--- libprelude/trunk/libmissing/tests/test-tls.c	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/tests/test-tls.c	2009-04-07 07:51:35 UTC (rev 11123)
@@ -75,6 +75,9 @@
     yield ();
 }
 
+
+/* ----------------------- Test thread-local storage ----------------------- */
+
 #define KEYS_COUNT 4
 
 static gl_tls_key_t mykeys[KEYS_COUNT];
@@ -146,7 +149,7 @@
   return NULL;
 }
 
-void
+static void
 test_tls (void)
 {
   int pass, i;
@@ -175,6 +178,9 @@
     }
 }
 
+
+/* -------------------------------------------------------------------------- */
+
 int
 main ()
 {

Modified: libprelude/trunk/libmissing/tests/test-unistd.c
===================================================================
--- libprelude/trunk/libmissing/tests/test-unistd.c	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/tests/test-unistd.c	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
 /* Test of <unistd.h> substitute.
-   Copyright (C) 2007 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -23,6 +23,12 @@
 /* Check that the various SEEK_* macros are defined.  */
 int sk[] = { SEEK_CUR, SEEK_END, SEEK_SET };
 
+/* Check that the various *_FILENO macros are defined.  */
+#if ! (defined STDIN_FILENO                                     \
+       && (STDIN_FILENO + STDOUT_FILENO + STDERR_FILENO == 3))
+missing or broken *_FILENO macros
+#endif
+
 /* Check that the types are all defined.  */
 size_t t1;
 ssize_t t2;

Added: libprelude/trunk/libmissing/tests/test-wcrtomb.c
===================================================================
--- libprelude/trunk/libmissing/tests/test-wcrtomb.c	                        (rev 0)
+++ libprelude/trunk/libmissing/tests/test-wcrtomb.c	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,162 @@
+/* Test of conversion of wide character to multibyte character.
+   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 <[email protected]>, 2008.  */
+
+#include <config.h>
+
+#include <wchar.h>
+
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define ASSERT(expr) \
+  do									     \
+    {									     \
+      if (!(expr))							     \
+        {								     \
+          fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+          fflush (stderr);						     \
+          abort ();							     \
+        }								     \
+    }									     \
+  while (0)
+
+/* Check the multibyte character s[0..n-1].  */
+static void
+check_character (const char *s, size_t n)
+{
+  wchar_t wc;
+  char buf[64];
+  int iret;
+  size_t ret;
+
+  wc = (wchar_t) 0xBADFACE;
+  iret = mbtowc (&wc, s, n);
+  ASSERT (iret == n);
+
+  ret = wcrtomb (buf, wc, NULL);
+  ASSERT (ret == n);
+  ASSERT (memcmp (buf, s, n) == 0);
+
+  /* Test special calling convention, passing a NULL pointer.  */
+  ret = wcrtomb (NULL, wc, NULL);
+  ASSERT (ret == 1);
+}
+
+int
+main (int argc, char *argv[])
+{
+  char buf[64];
+  size_t ret;
+
+  /* configure should already have checked that the locale is supported.  */
+  if (setlocale (LC_ALL, "") == NULL)
+    return 1;
+
+  /* Test NUL character.  */
+  {
+    buf[0] = 'x';
+    ret = wcrtomb (buf, 0, NULL);
+    ASSERT (ret == 1);
+    ASSERT (buf[0] == '\0');
+  }
+
+  /* Test single bytes.  */
+  {
+    int c;
+
+    for (c = 0; c < 0x100; c++)
+      switch (c)
+	{
+	case '\t': case '\v': case '\f':
+	case ' ': case '!': case '"': case '#': case '%':
+	case '&': case '\'': case '(': case ')': case '*':
+	case '+': case ',': case '-': case '.': case '/':
+	case '0': case '1': case '2': case '3': case '4':
+	case '5': case '6': case '7': case '8': case '9':
+	case ':': case ';': case '<': case '=': case '>':
+	case '?':
+	case 'A': case 'B': case 'C': case 'D': case 'E':
+	case 'F': case 'G': case 'H': case 'I': case 'J':
+	case 'K': case 'L': case 'M': case 'N': case 'O':
+	case 'P': case 'Q': case 'R': case 'S': case 'T':
+	case 'U': case 'V': case 'W': case 'X': case 'Y':
+	case 'Z':
+	case '[': case '\\': case ']': case '^': case '_':
+	case 'a': case 'b': case 'c': case 'd': case 'e':
+	case 'f': case 'g': case 'h': case 'i': case 'j':
+	case 'k': case 'l': case 'm': case 'n': case 'o':
+	case 'p': case 'q': case 'r': case 's': case 't':
+	case 'u': case 'v': case 'w': case 'x': case 'y':
+	case 'z': case '{': case '|': case '}': case '~':
+	  /* c is in the ISO C "basic character set".  */
+	  ret = wcrtomb (buf, btowc (c), NULL);
+	  ASSERT (ret == 1);
+	  ASSERT (buf[0] == (char) c);
+	  break;
+	}
+  }
+
+  if (argc > 1)
+    switch (argv[1][0])
+      {
+      case '1':
+	/* Locale encoding is ISO-8859-1 or ISO-8859-15.  */
+	{
+	  const char input[] = "B\374\337er"; /* "Büßer" */
+
+	  check_character (input + 1, 1);
+	  check_character (input + 2, 1);
+	}
+	return 0;
+
+      case '2':
+	/* Locale encoding is UTF-8.  */
+	{
+	  const char input[] = "B\303\274\303\237er"; /* "Büßer" */
+
+	  check_character (input + 1, 2);
+	  check_character (input + 3, 2);
+	}
+	return 0;
+
+      case '3':
+	/* Locale encoding is EUC-JP.  */
+	{
+	  const char input[] = "<\306\374\313\334\270\354>"; /* "<日本語>" */
+
+	  check_character (input + 1, 2);
+	  check_character (input + 3, 2);
+	  check_character (input + 5, 2);
+	}
+	return 0;
+
+      case '4':
+	/* Locale encoding is GB18030.  */
+	{
+	  const char input[] = "B\250\271\201\060\211\070er"; /* "Büßer" */
+
+	  check_character (input + 1, 2);
+	  check_character (input + 3, 4);
+	}
+	return 0;
+      }
+
+  return 1;
+}

Added: libprelude/trunk/libmissing/tests/test-wcrtomb.sh
===================================================================
--- libprelude/trunk/libmissing/tests/test-wcrtomb.sh	                        (rev 0)
+++ libprelude/trunk/libmissing/tests/test-wcrtomb.sh	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+# Test in an ISO-8859-1 or ISO-8859-15 locale.
+: ${LOCALE_FR=fr_FR}
+if test $LOCALE_FR != none; then
+  LC_ALL=$LOCALE_FR \
+  ./test-wcrtomb${EXEEXT} 1 \
+  || exit 1
+fi
+
+# Test whether a specific UTF-8 locale is installed.
+: ${LOCALE_FR_UTF8=fr_FR.UTF-8}
+if test $LOCALE_FR_UTF8 != none; then
+  LC_ALL=$LOCALE_FR_UTF8 \
+  ./test-wcrtomb${EXEEXT} 2 \
+  || exit 1
+fi
+
+# Test whether a specific EUC-JP locale is installed.
+: ${LOCALE_JA=ja_JP}
+if test $LOCALE_JA != none; then
+  LC_ALL=$LOCALE_JA \
+  ./test-wcrtomb${EXEEXT} 3 \
+  || exit 1
+fi
+
+# Test whether a specific GB18030 locale is installed.
+: ${LOCALE_ZH_CN=zh_CN.GB18030}
+if test $LOCALE_ZH_CN != none; then
+  LC_ALL=$LOCALE_ZH_CN \
+  ./test-wcrtomb${EXEEXT} 4 \
+  || exit 1
+fi
+
+exit 0


Property changes on: libprelude/trunk/libmissing/tests/test-wcrtomb.sh
___________________________________________________________________
Name: svn:executable
   + *

Deleted: libprelude/trunk/libmissing/tests/verify.h
===================================================================
--- libprelude/trunk/libmissing/tests/verify.h	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/tests/verify.h	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,140 +0,0 @@
-/* Compile-time assert-like macros.
-
-   Copyright (C) 2005, 2006 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, Bruno Haible, and Jim Meyering.  */
-
-#ifndef VERIFY_H
-# define VERIFY_H 1
-
-/* Each of these macros verifies that its argument R is nonzero.  To
-   be portable, R should be an integer constant expression.  Unlike
-   assert (R), there is no run-time overhead.
-
-   There are two macros, since no single macro can be used in all
-   contexts in C.  verify_true (R) is for scalar contexts, including
-   integer constant expression contexts.  verify (R) is for declaration
-   contexts, e.g., the top level.
-
-   Symbols ending in "__" are private to this header.
-
-   The code below uses several ideas.
-
-   * The first step is ((R) ? 1 : -1).  Given an expression R, of
-     integral or boolean or floating-point type, this yields an
-     expression of integral type, whose value is later verified to be
-     constant and nonnegative.
-
-   * Next this expression W is wrapped in a type
-     struct verify_type__ { unsigned int verify_error_if_negative_size__: W; }.
-     If W is negative, this yields a compile-time error.  No compiler can
-     deal with a bit-field of negative size.
-
-     One might think that an array size check would have the same
-     effect, that is, that the type struct { unsigned int dummy[W]; }
-     would work as well.  However, inside a function, some compilers
-     (such as C++ compilers and GNU C) allow local parameters and
-     variables inside array size expressions.  With these compilers,
-     an array size check would not properly diagnose this misuse of
-     the verify macro:
-
-       void function (int n) { verify (n < 0); }
-
-   * For the verify macro, the struct verify_type__ will need to
-     somehow be embedded into a declaration.  To be portable, this
-     declaration must declare an object, a constant, a function, or a
-     typedef name.  If the declared entity uses the type directly,
-     such as in
-
-       struct dummy {...};
-       typedef struct {...} dummy;
-       extern struct {...} *dummy;
-       extern void dummy (struct {...} *);
-       extern struct {...} *dummy (void);
-
-     two uses of the verify macro would yield colliding declarations
-     if the entity names are not disambiguated.  A workaround is to
-     attach the current line number to the entity name:
-
-       #define GL_CONCAT0(x, y) x##y
-       #define GL_CONCAT(x, y) GL_CONCAT0 (x, y)
-       extern struct {...} * GL_CONCAT(dummy,__LINE__);
-
-     But this has the problem that two invocations of verify from
-     within the same macro would collide, since the __LINE__ value
-     would be the same for both invocations.
-
-     A solution is to use the sizeof operator.  It yields a number,
-     getting rid of the identity of the type.  Declarations like
-
-       extern int dummy [sizeof (struct {...})];
-       extern void dummy (int [sizeof (struct {...})]);
-       extern int (*dummy (void)) [sizeof (struct {...})];
-
-     can be repeated.
-
-   * Should the implementation use a named struct or an unnamed struct?
-     Which of the following alternatives can be used?
-
-       extern int dummy [sizeof (struct {...})];
-       extern int dummy [sizeof (struct verify_type__ {...})];
-       extern void dummy (int [sizeof (struct {...})]);
-       extern void dummy (int [sizeof (struct verify_type__ {...})]);
-       extern int (*dummy (void)) [sizeof (struct {...})];
-       extern int (*dummy (void)) [sizeof (struct verify_type__ {...})];
-
-     In the second and sixth case, the struct type is exported to the
-     outer scope; two such declarations therefore collide.  GCC warns
-     about the first, third, and fourth cases.  So the only remaining
-     possibility is the fifth case:
-
-       extern int (*dummy (void)) [sizeof (struct {...})];
-
-   * This implementation exploits the fact that GCC does not warn about
-     the last declaration mentioned above.  If a future version of GCC
-     introduces a warning for this, the problem could be worked around
-     by using code specialized to GCC, e.g.,:
-
-       #if 4 <= __GNUC__
-       # define verify(R) \
-	   extern int (* verify_function__ (void)) \
-		      [__builtin_constant_p (R) && (R) ? 1 : -1]
-       #endif
-
-   * In C++, any struct definition inside sizeof is invalid.
-     Use a template type to work around the problem.  */
-
-
-/* Verify requirement R at compile-time, as an integer constant expression.
-   Return 1.  */
-
-# ifdef __cplusplus
-template <int w>
-  struct verify_type__ { unsigned int verify_error_if_negative_size__: w; };
-#  define verify_true(R) \
-     (!!sizeof (verify_type__<(R) ? 1 : -1>))
-# else
-#  define verify_true(R) \
-     (!!sizeof \
-      (struct { unsigned int verify_error_if_negative_size__: (R) ? 1 : -1; }))
-# endif
-
-/* Verify requirement R at compile-time, as a declaration without a
-   trailing ';'.  */
-
-# define verify(R) extern int (* verify_function__ (void)) [verify_true (R)]
-
-#endif

Added: libprelude/trunk/libmissing/tests/w32sock.h
===================================================================
--- libprelude/trunk/libmissing/tests/w32sock.h	                        (rev 0)
+++ libprelude/trunk/libmissing/tests/w32sock.h	2009-04-07 07:51:35 UTC (rev 11123)
@@ -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;
+    }
+}

Copied: libprelude/trunk/libmissing/tests/wctob.c (from rev 11101, libprelude/trunk/libmissing/tests/sockets.h)
===================================================================
--- libprelude/trunk/libmissing/tests/wctob.c	                        (rev 0)
+++ libprelude/trunk/libmissing/tests/wctob.c	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,37 @@
+/* Convert wide character to unibyte character.
+   Copyright (C) 2008 Free Software Foundation, Inc.
+   Written by Bruno Haible <[email protected]>, 2008.
+
+   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>
+
+/* Specification.  */
+#include <wchar.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+wctob (wint_t wc)
+{
+  char buf[64];
+
+  if (!(MB_CUR_MAX <= sizeof (buf)))
+    abort ();
+  if (wctomb (buf, wc) == 1)
+    return (unsigned char) buf[0];
+  else
+    return EOF;
+}

Modified: libprelude/trunk/libmissing/unistd.in.h
===================================================================
--- libprelude/trunk/libmissing/unistd.in.h	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/unistd.in.h	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
 /* Substitute for and wrapper around <unistd.h>.
-   Copyright (C) 2003-2008 Free Software Foundation, Inc.
+   Copyright (C) 2003-2009 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -29,12 +29,13 @@
 #ifndef _GL_UNISTD_H
 #define _GL_UNISTD_H
 
-/* mingw doesn't define the SEEK_* macros in <unistd.h>.  */
+/* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>.  */
 #if !(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET)
 # include <stdio.h>
 #endif
 
 /* mingw fails to declare _exit in <unistd.h>.  */
+/* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>.  */
 #include <stdlib.h>
 
 #if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
@@ -86,6 +87,17 @@
 /* The definition of GL_LINK_WARNING is copied here.  */
 
 
+/* OS/2 EMX lacks these macros.  */
+#ifndef STDIN_FILENO
+# define STDIN_FILENO 0
+#endif
+#ifndef STDOUT_FILENO
+# define STDOUT_FILENO 1
+#endif
+#ifndef STDERR_FILENO
+# define STDERR_FILENO 2
+#endif
+
 /* Declare overridden functions.  */
 
 #ifdef __cplusplus
@@ -119,10 +131,6 @@
 
 
 #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
@@ -474,6 +482,23 @@
 #endif
 
 
+#if @GNULIB_LINK@
+/* Create a new hard link for an existing file.
+   Return 0 if successful, otherwise -1 and errno set.
+   See POSIX:2001 specification
+   <http://www.opengroup.org/susv3xsh/link.html>.  */
+# if !@HAVE_LINK@
+extern int link (const char *path1, const char *path2);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef link
+# define link(path1,path2) \
+    (GL_LINK_WARNING ("link is unportable - " \
+                      "use gnulib module link for portability"), \
+     link (path1, path2))
+#endif
+
+
 #if @GNULIB_LSEEK@
 # if @REPLACE_LSEEK@
 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.

Modified: libprelude/trunk/libmissing/vasnprintf.c
===================================================================
--- libprelude/trunk/libmissing/vasnprintf.c	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/vasnprintf.c	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,5 +1,5 @@
 /* vsprintf with automatic memory allocation.
-   Copyright (C) 1999, 2002-2008 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2002-2009 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -117,29 +117,6 @@
 # include "fpucw.h"
 #endif
 
-#if HAVE_WCHAR_T
-# if HAVE_WCSLEN
-#  define local_wcslen wcslen
-# else
-   /* Solaris 2.5.1 has wcslen() in a separate library libw.so. To avoid
-      a dependency towards this library, here is a local substitute.
-      Define this substitute only once, even if this file is included
-      twice in the same compilation unit.  */
-#  ifndef local_wcslen_defined
-#   define local_wcslen_defined 1
-static size_t
-local_wcslen (const wchar_t *s)
-{
-  const wchar_t *ptr;
-
-  for (ptr = s; *ptr != (wchar_t) 0; ptr++)
-    ;
-  return ptr - s;
-}
-#  endif
-# endif
-#endif
-
 /* Default parameters.  */
 #ifndef VASNPRINTF
 # if WIDE_CHAR_VERSION
@@ -152,6 +129,7 @@
 #  define DIRECTIVES wchar_t_directives
 #  define PRINTF_PARSE wprintf_parse
 #  define DCHAR_CPY wmemcpy
+#  define DCHAR_SET wmemset
 # else
 #  define VASNPRINTF vasnprintf
 #  define FCHAR_T char
@@ -162,6 +140,7 @@
 #  define DIRECTIVES char_directives
 #  define PRINTF_PARSE printf_parse
 #  define DCHAR_CPY memcpy
+#  define DCHAR_SET memset
 # endif
 #endif
 #if WIDE_CHAR_VERSION
@@ -215,6 +194,64 @@
 #undef remainder
 #define remainder rem
 
+#if !USE_SNPRINTF && !WIDE_CHAR_VERSION
+# if (HAVE_STRNLEN && !defined _AIX)
+#  define local_strnlen strnlen
+# else
+#  ifndef local_strnlen_defined
+#   define local_strnlen_defined 1
+static size_t
+local_strnlen (const char *string, size_t maxlen)
+{
+  const char *end = memchr (string, '\0', maxlen);
+  return end ? (size_t) (end - string) : maxlen;
+}
+#  endif
+# endif
+#endif
+
+#if (!USE_SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && HAVE_WCHAR_T && (WIDE_CHAR_VERSION || DCHAR_IS_TCHAR)
+# if HAVE_WCSLEN
+#  define local_wcslen wcslen
+# else
+   /* Solaris 2.5.1 has wcslen() in a separate library libw.so. To avoid
+      a dependency towards this library, here is a local substitute.
+      Define this substitute only once, even if this file is included
+      twice in the same compilation unit.  */
+#  ifndef local_wcslen_defined
+#   define local_wcslen_defined 1
+static size_t
+local_wcslen (const wchar_t *s)
+{
+  const wchar_t *ptr;
+
+  for (ptr = s; *ptr != (wchar_t) 0; ptr++)
+    ;
+  return ptr - s;
+}
+#  endif
+# endif
+#endif
+
+#if !USE_SNPRINTF && HAVE_WCHAR_T && WIDE_CHAR_VERSION
+# if HAVE_WCSNLEN
+#  define local_wcsnlen wcsnlen
+# else
+#  ifndef local_wcsnlen_defined
+#   define local_wcsnlen_defined 1
+static size_t
+local_wcsnlen (const wchar_t *s, size_t maxlen)
+{
+  const wchar_t *ptr;
+
+  for (ptr = s; maxlen > 0 && *ptr != (wchar_t) 0; ptr++, maxlen--)
+    ;
+  return ptr - s;
+}
+#  endif
+# endif
+#endif
+
 #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
@@ -376,7 +413,7 @@
        Normalise [q[m-1],...,q[0]], yields q.
      If m>=n>1, perform a multiple-precision division:
        We have a/b < beta^(m-n+1).
-       s:=intDsize-1-(hightest bit in b[n-1]), 0<=s<intDsize.
+       s:=intDsize-1-(highest bit in b[n-1]), 0<=s<intDsize.
        Shift a and b left by s bits, copying them. r:=a.
        r=[r[m],...,r[0]], b=[b[n-1],...,b[0]] with b[n-1]>=beta/2.
        For j=m-n,...,0: {Here 0 <= r < b*beta^(j+1).}
@@ -2066,6 +2103,523 @@
 		  }
 	      }
 #endif
+#if (!USE_SNPRINTF || (NEED_PRINTF_DIRECTIVE_LS && !defined IN_LIBINTL)) && HAVE_WCHAR_T
+	    else if (dp->conversion == 's'
+# if WIDE_CHAR_VERSION
+		     && a.arg[dp->arg_index].type != TYPE_WIDE_STRING
+# else
+		     && a.arg[dp->arg_index].type == TYPE_WIDE_STRING
+# endif
+		    )
+	      {
+		/* The normal handling of the 's' directive below requires
+		   allocating a temporary buffer.  The determination of its
+		   length (tmp_length), in the case when a precision is
+		   specified, below requires a conversion between a char[]
+		   string and a wchar_t[] wide string.  It could be done, but
+		   we have no guarantee that the implementation of sprintf will
+		   use the exactly same algorithm.  Without this guarantee, it
+		   is possible to have buffer overrun bugs.  In order to avoid
+		   such bugs, we implement the entire processing of the 's'
+		   directive ourselves.  */
+		int flags = dp->flags;
+		int has_width;
+		size_t width;
+		int has_precision;
+		size_t precision;
+
+		has_width = 0;
+		width = 0;
+		if (dp->width_start != dp->width_end)
+		  {
+		    if (dp->width_arg_index != ARG_NONE)
+		      {
+			int arg;
+
+			if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
+			  abort ();
+			arg = a.arg[dp->width_arg_index].a.a_int;
+			if (arg < 0)
+			  {
+			    /* "A negative field width is taken as a '-' flag
+			        followed by a positive field width."  */
+			    flags |= FLAG_LEFT;
+			    width = (unsigned int) (-arg);
+			  }
+			else
+			  width = arg;
+		      }
+		    else
+		      {
+			const FCHAR_T *digitp = dp->width_start;
+
+			do
+			  width = xsum (xtimes (width, 10), *digitp++ - '0');
+			while (digitp != dp->width_end);
+		      }
+		    has_width = 1;
+		  }
+
+		has_precision = 0;
+		precision = 6;
+		if (dp->precision_start != dp->precision_end)
+		  {
+		    if (dp->precision_arg_index != ARG_NONE)
+		      {
+			int arg;
+
+			if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
+			  abort ();
+			arg = a.arg[dp->precision_arg_index].a.a_int;
+			/* "A negative precision is taken as if the precision
+			    were omitted."  */
+			if (arg >= 0)
+			  {
+			    precision = arg;
+			    has_precision = 1;
+			  }
+		      }
+		    else
+		      {
+			const FCHAR_T *digitp = dp->precision_start + 1;
+
+			precision = 0;
+			while (digitp != dp->precision_end)
+			  precision = xsum (xtimes (precision, 10), *digitp++ - '0');
+			has_precision = 1;
+		      }
+		  }
+
+# if WIDE_CHAR_VERSION
+		/* %s in vasnwprintf.  See the specification of fwprintf.  */
+		{
+		  const char *arg = a.arg[dp->arg_index].a.a_string;
+		  const char *arg_end;
+		  size_t characters;
+
+		  if (has_precision)
+		    {
+		      /* Use only as many bytes as needed to produce PRECISION
+			 wide characters, from the left.  */
+#  if HAVE_MBRTOWC
+		      mbstate_t state;
+		      memset (&state, '\0', sizeof (mbstate_t));
+#  endif
+		      arg_end = arg;
+		      characters = 0;
+		      for (; precision > 0; precision--)
+			{
+			  int count;
+#  if HAVE_MBRTOWC
+			  count = mbrlen (arg_end, MB_CUR_MAX, &state);
+#  else
+			  count = mblen (arg_end, MB_CUR_MAX);
+#  endif
+			  if (count == 0)
+			    /* Found the terminating NUL.  */
+			    break;
+			  if (count < 0)
+			    {
+			      /* Invalid or incomplete multibyte character.  */
+			      if (!(result == resultbuf || result == NULL))
+				free (result);
+			      if (buf_malloced != NULL)
+				free (buf_malloced);
+			      CLEANUP ();
+			      errno = EILSEQ;
+			      return NULL;
+			    }
+			  arg_end += count;
+			  characters++;
+			}
+		    }
+		  else if (has_width)
+		    {
+		      /* Use the entire string, and count the number of wide
+			 characters.  */
+#  if HAVE_MBRTOWC
+		      mbstate_t state;
+		      memset (&state, '\0', sizeof (mbstate_t));
+#  endif
+		      arg_end = arg;
+		      characters = 0;
+		      for (;;)
+			{
+			  int count;
+#  if HAVE_MBRTOWC
+			  count = mbrlen (arg_end, MB_CUR_MAX, &state);
+#  else
+			  count = mblen (arg_end, MB_CUR_MAX);
+#  endif
+			  if (count == 0)
+			    /* Found the terminating NUL.  */
+			    break;
+			  if (count < 0)
+			    {
+			      /* Invalid or incomplete multibyte character.  */
+			      if (!(result == resultbuf || result == NULL))
+				free (result);
+			      if (buf_malloced != NULL)
+				free (buf_malloced);
+			      CLEANUP ();
+			      errno = EILSEQ;
+			      return NULL;
+			    }
+			  arg_end += count;
+			  characters++;
+			}
+		    }
+		  else
+		    {
+		      /* Use the entire string.  */
+		      arg_end = arg + strlen (arg);
+		      /* The number of characters doesn't matter.  */
+		      characters = 0;
+		    }
+
+		  if (has_width && width > characters
+		      && !(dp->flags & FLAG_LEFT))
+		    {
+		      size_t n = width - characters;
+		      ENSURE_ALLOCATION (xsum (length, n));
+		      DCHAR_SET (result + length, ' ', n);
+		      length += n;
+		    }
+
+		  if (has_precision || has_width)
+		    {
+		      /* We know the number of wide characters in advance.  */
+		      size_t remaining;
+#  if HAVE_MBRTOWC
+		      mbstate_t state;
+		      memset (&state, '\0', sizeof (mbstate_t));
+#  endif
+		      ENSURE_ALLOCATION (xsum (length, characters));
+		      for (remaining = characters; remaining > 0; remaining--)
+			{
+			  wchar_t wc;
+			  int count;
+#  if HAVE_MBRTOWC
+			  count = mbrtowc (&wc, arg, arg_end - arg, &state);
+#  else
+			  count = mbtowc (&wc, arg, arg_end - arg);
+#  endif
+			  if (count <= 0)
+			    /* mbrtowc not consistent with mbrlen, or mbtowc
+			       not consistent with mblen.  */
+			    abort ();
+			  result[length++] = wc;
+			  arg += count;
+			}
+		      if (!(arg == arg_end))
+			abort ();
+		    }
+		  else
+		    {
+#  if HAVE_MBRTOWC
+		      mbstate_t state;
+		      memset (&state, '\0', sizeof (mbstate_t));
+#  endif
+		      while (arg < arg_end)
+			{
+			  wchar_t wc;
+			  int count;
+#  if HAVE_MBRTOWC
+			  count = mbrtowc (&wc, arg, arg_end - arg, &state);
+#  else
+			  count = mbtowc (&wc, arg, arg_end - arg);
+#  endif
+			  if (count <= 0)
+			    /* mbrtowc not consistent with mbrlen, or mbtowc
+			       not consistent with mblen.  */
+			    abort ();
+			  ENSURE_ALLOCATION (xsum (length, 1));
+			  result[length++] = wc;
+			  arg += count;
+			}
+		    }
+
+		  if (has_width && width > characters
+		      && (dp->flags & FLAG_LEFT))
+		    {
+		      size_t n = width - characters;
+		      ENSURE_ALLOCATION (xsum (length, n));
+		      DCHAR_SET (result + length, ' ', n);
+		      length += n;
+		    }
+		}
+# else
+		/* %ls in vasnprintf.  See the specification of fprintf.  */
+		{
+		  const wchar_t *arg = a.arg[dp->arg_index].a.a_wide_string;
+		  const wchar_t *arg_end;
+		  size_t characters;
+#  if !DCHAR_IS_TCHAR
+		  /* This code assumes that TCHAR_T is 'char'.  */
+		  typedef int TCHAR_T_verify[2 * (sizeof (TCHAR_T) == 1) - 1];
+		  TCHAR_T *tmpsrc;
+		  DCHAR_T *tmpdst;
+		  size_t tmpdst_len;
+#  endif
+		  size_t w;
+
+		  if (has_precision)
+		    {
+		      /* Use only as many wide characters as needed to produce
+			 at most PRECISION bytes, from the left.  */
+#  if HAVE_WCRTOMB
+		      mbstate_t state;
+		      memset (&state, '\0', sizeof (mbstate_t));
+#  endif
+		      arg_end = arg;
+		      characters = 0;
+		      while (precision > 0)
+			{
+			  char buf[64]; /* Assume MB_CUR_MAX <= 64.  */
+			  int count;
+
+			  if (*arg_end == 0)
+			    /* Found the terminating null wide character.  */
+			    break;
+#  if HAVE_WCRTOMB
+			  count = wcrtomb (buf, *arg_end, &state);
+#  else
+			  count = wctomb (buf, *arg_end);
+#  endif
+			  if (count < 0)
+			    {
+			      /* Cannot convert.  */
+			      if (!(result == resultbuf || result == NULL))
+				free (result);
+			      if (buf_malloced != NULL)
+				free (buf_malloced);
+			      CLEANUP ();
+			      errno = EILSEQ;
+			      return NULL;
+			    }
+			  if (precision < count)
+			    break;
+			  arg_end++;
+			  characters += count;
+			  precision -= count;
+			}
+		    }
+#  if DCHAR_IS_TCHAR
+		  else if (has_width)
+#  else
+		  else
+#  endif
+		    {
+		      /* Use the entire string, and count the number of
+			 bytes.  */
+#  if HAVE_WCRTOMB
+		      mbstate_t state;
+		      memset (&state, '\0', sizeof (mbstate_t));
+#  endif
+		      arg_end = arg;
+		      characters = 0;
+		      for (;;)
+			{
+			  char buf[64]; /* Assume MB_CUR_MAX <= 64.  */
+			  int count;
+
+			  if (*arg_end == 0)
+			    /* Found the terminating null wide character.  */
+			    break;
+#  if HAVE_WCRTOMB
+			  count = wcrtomb (buf, *arg_end, &state);
+#  else
+			  count = wctomb (buf, *arg_end);
+#  endif
+			  if (count < 0)
+			    {
+			      /* Cannot convert.  */
+			      if (!(result == resultbuf || result == NULL))
+				free (result);
+			      if (buf_malloced != NULL)
+				free (buf_malloced);
+			      CLEANUP ();
+			      errno = EILSEQ;
+			      return NULL;
+			    }
+			  arg_end++;
+			  characters += count;
+			}
+		    }
+#  if DCHAR_IS_TCHAR
+		  else
+		    {
+		      /* Use the entire string.  */
+		      arg_end = arg + local_wcslen (arg);
+		      /* The number of bytes doesn't matter.  */
+		      characters = 0;
+		    }
+#  endif
+
+#  if !DCHAR_IS_TCHAR
+		  /* Convert the string into a piece of temporary memory.  */
+		  tmpsrc = (TCHAR_T *) malloc (characters * sizeof (TCHAR_T));
+		  if (tmpsrc == NULL)
+		    goto out_of_memory;
+		  {
+		    TCHAR_T *tmpptr = tmpsrc;
+		    size_t remaining;
+#   if HAVE_WCRTOMB
+		    mbstate_t state;
+		    memset (&state, '\0', sizeof (mbstate_t));
+#   endif
+		    for (remaining = characters; remaining > 0; )
+		      {
+			char buf[64]; /* Assume MB_CUR_MAX <= 64.  */
+			int count;
+
+			if (*arg == 0)
+			  abort ();
+#   if HAVE_WCRTOMB
+			count = wcrtomb (buf, *arg, &state);
+#   else
+			count = wctomb (buf, *arg);
+#   endif
+			if (count <= 0)
+			  /* Inconsistency.  */
+			  abort ();
+			memcpy (tmpptr, buf, count);
+			tmpptr += count;
+			arg++;
+			remaining -= count;
+		      }
+		    if (!(arg == arg_end))
+		      abort ();
+		  }
+
+		  /* Convert from TCHAR_T[] to DCHAR_T[].  */
+		  tmpdst = NULL;
+		  tmpdst_len = 0;
+		  if (DCHAR_CONV_FROM_ENCODING (locale_charset (),
+						iconveh_question_mark,
+						tmpsrc, characters,
+						NULL,
+						&tmpdst, &tmpdst_len)
+		      < 0)
+		    {
+		      int saved_errno = errno;
+		      free (tmpsrc);
+		      if (!(result == resultbuf || result == NULL))
+			free (result);
+		      if (buf_malloced != NULL)
+			free (buf_malloced);
+		      CLEANUP ();
+		      errno = saved_errno;
+		      return NULL;
+		    }
+		  free (tmpsrc);
+#  endif
+
+		  if (has_width)
+		    {
+#  if ENABLE_UNISTDIO
+		      /* Outside POSIX, it's preferrable to compare the width
+			 against the number of _characters_ of the converted
+			 value.  */
+		      w = DCHAR_MBSNLEN (result + length, characters);
+#  else
+		      /* The width is compared against the number of _bytes_
+			 of the converted value, says POSIX.  */
+		      w = characters;
+#  endif
+		    }
+		  else
+		    /* w doesn't matter.  */
+		    w = 0;
+
+		  if (has_width && width > w
+		      && !(dp->flags & FLAG_LEFT))
+		    {
+		      size_t n = width - w;
+		      ENSURE_ALLOCATION (xsum (length, n));
+		      DCHAR_SET (result + length, ' ', n);
+		      length += n;
+		    }
+
+#  if DCHAR_IS_TCHAR
+		  if (has_precision || has_width)
+		    {
+		      /* We know the number of bytes in advance.  */
+		      size_t remaining;
+#   if HAVE_WCRTOMB
+		      mbstate_t state;
+		      memset (&state, '\0', sizeof (mbstate_t));
+#   endif
+		      ENSURE_ALLOCATION (xsum (length, characters));
+		      for (remaining = characters; remaining > 0; )
+			{
+			  char buf[64]; /* Assume MB_CUR_MAX <= 64.  */
+			  int count;
+
+			  if (*arg == 0)
+			    abort ();
+#   if HAVE_WCRTOMB
+			  count = wcrtomb (buf, *arg, &state);
+#   else
+			  count = wctomb (buf, *arg);
+#   endif
+			  if (count <= 0)
+			    /* Inconsistency.  */
+			    abort ();
+			  memcpy (result + length, buf, count);
+			  length += count;
+			  arg++;
+			  remaining -= count;
+			}
+		      if (!(arg == arg_end))
+			abort ();
+		    }
+		  else
+		    {
+#   if HAVE_WCRTOMB
+		      mbstate_t state;
+		      memset (&state, '\0', sizeof (mbstate_t));
+#   endif
+		      while (arg < arg_end)
+			{
+			  char buf[64]; /* Assume MB_CUR_MAX <= 64.  */
+			  int count;
+
+			  if (*arg == 0)
+			    abort ();
+#   if HAVE_WCRTOMB
+			  count = wcrtomb (buf, *arg, &state);
+#   else
+			  count = wctomb (buf, *arg);
+#   endif
+			  if (count <= 0)
+			    /* Inconsistency.  */
+			    abort ();
+			  ENSURE_ALLOCATION (xsum (length, count));
+			  memcpy (result + length, buf, count);
+			  length += count;
+			  arg++;
+			}
+		    }
+#  else
+		  ENSURE_ALLOCATION (xsum (length, tmpdst_len));
+		  DCHAR_CPY (result + length, tmpdst, tmpdst_len);
+		  free (tmpdst);
+		  length += tmpdst_len;
+#  endif
+
+		  if (has_width && width > w
+		      && (dp->flags & FLAG_LEFT))
+		    {
+		      size_t n = width - w;
+		      ENSURE_ALLOCATION (xsum (length, n));
+		      DCHAR_SET (result + length, ' ', n);
+		      length += n;
+		    }
+		}
+	      }
+# endif
+#endif
 #if (NEED_PRINTF_DIRECTIVE_A || NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE) && !defined IN_LIBINTL
 	    else if ((dp->conversion == 'a' || dp->conversion == 'A')
 # if !(NEED_PRINTF_DIRECTIVE_A || (NEED_PRINTF_LONG_DOUBLE && NEED_PRINTF_DOUBLE))
@@ -4032,16 +4586,64 @@
 # if HAVE_WCHAR_T
 		      if (type == TYPE_WIDE_STRING)
 			{
-			  tmp_length =
-			    local_wcslen (a.arg[dp->arg_index].a.a_wide_string);
+#  if WIDE_CHAR_VERSION
+			  /* ISO C says about %ls in fwprintf:
+			       "If the precision is not specified or is greater
+				than the size of the array, the array shall
+				contain a null wide character."
+			     So if there is a precision, we must not use
+			     wcslen.  */
+			  const wchar_t *arg =
+			    a.arg[dp->arg_index].a.a_wide_string;
 
-#  if !WIDE_CHAR_VERSION
-			  tmp_length = xtimes (tmp_length, MB_CUR_MAX);
+			  if (has_precision)
+			    tmp_length = local_wcsnlen (arg, precision);
+			  else
+			    tmp_length = local_wcslen (arg);
+#  else
+			  /* ISO C says about %ls in fprintf:
+			       "If a precision is specified, no more than that
+				many bytes are written (including shift
+				sequences, if any), and the array shall contain
+				a null wide character if, to equal the
+				multibyte character sequence length given by
+				the precision, the function would need to
+				access a wide character one past the end of the
+				array."
+			     So if there is a precision, we must not use
+			     wcslen.  */
+			  /* This case has already been handled above.  */
+			  abort ();
 #  endif
 			}
 		      else
 # endif
-			tmp_length = strlen (a.arg[dp->arg_index].a.a_string);
+			{
+# if WIDE_CHAR_VERSION
+			  /* ISO C says about %s in fwprintf:
+			       "If the precision is not specified or is greater
+				than the size of the converted array, the
+				converted array shall contain a null wide
+				character."
+			     So if there is a precision, we must not use
+			     strlen.  */
+			  /* This case has already been handled above.  */
+			  abort ();
+# else
+			  /* ISO C says about %s in fprintf:
+			       "If the precision is not specified or greater
+				than the size of the array, the array shall
+				contain a null character."
+			     So if there is a precision, we must not use
+			     strlen.  */
+			  const char *arg = a.arg[dp->arg_index].a.a_string;
+
+			  if (has_precision)
+			    tmp_length = local_strnlen (arg, precision);
+			  else
+			    tmp_length = strlen (arg);
+# endif
+			}
 		      break;
 
 		    case 'p':

Copied: libprelude/trunk/libmissing/verify.h (from rev 11101, libprelude/trunk/libmissing/tests/verify.h)
===================================================================
--- libprelude/trunk/libmissing/verify.h	                        (rev 0)
+++ libprelude/trunk/libmissing/verify.h	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,140 @@
+/* Compile-time assert-like macros.
+
+   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Paul Eggert, Bruno Haible, and Jim Meyering.  */
+
+#ifndef VERIFY_H
+# define VERIFY_H 1
+
+/* Each of these macros verifies that its argument R is nonzero.  To
+   be portable, R should be an integer constant expression.  Unlike
+   assert (R), there is no run-time overhead.
+
+   There are two macros, since no single macro can be used in all
+   contexts in C.  verify_true (R) is for scalar contexts, including
+   integer constant expression contexts.  verify (R) is for declaration
+   contexts, e.g., the top level.
+
+   Symbols ending in "__" are private to this header.
+
+   The code below uses several ideas.
+
+   * The first step is ((R) ? 1 : -1).  Given an expression R, of
+     integral or boolean or floating-point type, this yields an
+     expression of integral type, whose value is later verified to be
+     constant and nonnegative.
+
+   * Next this expression W is wrapped in a type
+     struct verify_type__ { unsigned int verify_error_if_negative_size__: W; }.
+     If W is negative, this yields a compile-time error.  No compiler can
+     deal with a bit-field of negative size.
+
+     One might think that an array size check would have the same
+     effect, that is, that the type struct { unsigned int dummy[W]; }
+     would work as well.  However, inside a function, some compilers
+     (such as C++ compilers and GNU C) allow local parameters and
+     variables inside array size expressions.  With these compilers,
+     an array size check would not properly diagnose this misuse of
+     the verify macro:
+
+       void function (int n) { verify (n < 0); }
+
+   * For the verify macro, the struct verify_type__ will need to
+     somehow be embedded into a declaration.  To be portable, this
+     declaration must declare an object, a constant, a function, or a
+     typedef name.  If the declared entity uses the type directly,
+     such as in
+
+       struct dummy {...};
+       typedef struct {...} dummy;
+       extern struct {...} *dummy;
+       extern void dummy (struct {...} *);
+       extern struct {...} *dummy (void);
+
+     two uses of the verify macro would yield colliding declarations
+     if the entity names are not disambiguated.  A workaround is to
+     attach the current line number to the entity name:
+
+       #define GL_CONCAT0(x, y) x##y
+       #define GL_CONCAT(x, y) GL_CONCAT0 (x, y)
+       extern struct {...} * GL_CONCAT(dummy,__LINE__);
+
+     But this has the problem that two invocations of verify from
+     within the same macro would collide, since the __LINE__ value
+     would be the same for both invocations.
+
+     A solution is to use the sizeof operator.  It yields a number,
+     getting rid of the identity of the type.  Declarations like
+
+       extern int dummy [sizeof (struct {...})];
+       extern void dummy (int [sizeof (struct {...})]);
+       extern int (*dummy (void)) [sizeof (struct {...})];
+
+     can be repeated.
+
+   * Should the implementation use a named struct or an unnamed struct?
+     Which of the following alternatives can be used?
+
+       extern int dummy [sizeof (struct {...})];
+       extern int dummy [sizeof (struct verify_type__ {...})];
+       extern void dummy (int [sizeof (struct {...})]);
+       extern void dummy (int [sizeof (struct verify_type__ {...})]);
+       extern int (*dummy (void)) [sizeof (struct {...})];
+       extern int (*dummy (void)) [sizeof (struct verify_type__ {...})];
+
+     In the second and sixth case, the struct type is exported to the
+     outer scope; two such declarations therefore collide.  GCC warns
+     about the first, third, and fourth cases.  So the only remaining
+     possibility is the fifth case:
+
+       extern int (*dummy (void)) [sizeof (struct {...})];
+
+   * This implementation exploits the fact that GCC does not warn about
+     the last declaration mentioned above.  If a future version of GCC
+     introduces a warning for this, the problem could be worked around
+     by using code specialized to GCC, e.g.,:
+
+       #if 4 <= __GNUC__
+       # define verify(R) \
+	   extern int (* verify_function__ (void)) \
+		      [__builtin_constant_p (R) && (R) ? 1 : -1]
+       #endif
+
+   * In C++, any struct definition inside sizeof is invalid.
+     Use a template type to work around the problem.  */
+
+
+/* Verify requirement R at compile-time, as an integer constant expression.
+   Return 1.  */
+
+# ifdef __cplusplus
+template <int w>
+  struct verify_type__ { unsigned int verify_error_if_negative_size__: w; };
+#  define verify_true(R) \
+     (!!sizeof (verify_type__<(R) ? 1 : -1>))
+# else
+#  define verify_true(R) \
+     (!!sizeof \
+      (struct { unsigned int verify_error_if_negative_size__: (R) ? 1 : -1; }))
+# endif
+
+/* Verify requirement R at compile-time, as a declaration without a
+   trailing ';'.  */
+
+# define verify(R) extern int (* verify_function__ (void)) [verify_true (R)]
+
+#endif

Modified: libprelude/trunk/libmissing/wchar.in.h
===================================================================
--- libprelude/trunk/libmissing/wchar.in.h	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/wchar.in.h	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,6 +1,6 @@
 /* A substitute for ISO C99 <wchar.h>, for platforms that have issues.
 
-   Copyright (C) 2007-2008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -30,8 +30,18 @@
 @PRAGMA_SYSTEM_HEADER@
 #endif
 
-#ifdef __need_mbstate_t
-/* Special invocation convention inside uClibc header files.  */
+#if defined __need_mbstate_t || (defined __hpux && ((defined _INTTYPES_INCLUDED && !defined strtoimax) || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H)) || defined _GL_ALREADY_INCLUDING_WCHAR_H
+/* Special invocation convention:
+   - Inside uClibc header files.
+   - On HP-UX 11.00 we have a sequence of nested includes
+     <wchar.h> -> <stdlib.h> -> <stdint.h>, and the latter includes <wchar.h>,
+     once indirectly <stdint.h> -> <sys/types.h> -> <inttypes.h> -> <wchar.h>
+     and once directly.  In both situations 'wint_t' is not yet defined,
+     therefore we cannot provide the function overrides; instead include only
+     the system's <wchar.h>.
+   - On IRIX 6.5, similarly, we have an include <wchar.h> -> <wctype.h>, and
+     the latter includes <wchar.h>.  But here, we have no way to detect whether
+     <wctype.h> is completely included or is still being included.  */
 
 #@INCLUDE_NEXT@ @NEXT_WCHAR_H@
 
@@ -40,6 +50,8 @@
 
 #ifndef _GL_WCHAR_H
 
+#define _GL_ALREADY_INCLUDING_WCHAR_H
+
 /* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
    <wchar.h>.
    BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
@@ -55,6 +67,8 @@
 # @INCLUDE_NEXT@ @NEXT_WCHAR_H@
 #endif
 
+#undef _GL_ALREADY_INCLUDING_WCHAR_H
+
 #ifndef _GL_WCHAR_H
 #define _GL_WCHAR_H
 
@@ -68,9 +82,200 @@
 /* Define wint_t.  (Also done in wctype.in.h.)  */
 #if !@HAVE_WINT_T@ && !defined wint_t
 # define wint_t int
+# ifndef WEOF
+#  define WEOF -1
+# endif
 #endif
 
 
+/* Override mbstate_t if it is too small.
+   On IRIX 6.5, sizeof (mbstate_t) == 1, which is not sufficient for
+   implementing mbrtowc for encodings like UTF-8.  */
+#if !(@HAVE_MBSINIT@ && @HAVE_MBRTOWC@) || @REPLACE_MBSTATE_T@
+typedef int rpl_mbstate_t;
+# undef mbstate_t
+# define mbstate_t rpl_mbstate_t
+# define GNULIB_defined_mbstate_t 1
+#endif
+
+
+/* Convert a single-byte character to a wide character.  */
+#if @GNULIB_BTOWC@
+# if @REPLACE_BTOWC@
+#  undef btowc
+#  define btowc rpl_btowc
+# endif
+# if !@HAVE_BTOWC@ || @REPLACE_BTOWC@
+extern wint_t btowc (int c);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef btowc
+# define btowc(c) \
+    (GL_LINK_WARNING ("btowc is unportable - " \
+                      "use gnulib module btowc for portability"), \
+     btowc (c))
+#endif
+
+
+/* Convert a wide character to a single-byte character.  */
+#if @GNULIB_WCTOB@
+# if @REPLACE_WCTOB@
+#  undef wctob
+#  define wctob rpl_wctob
+# endif
+# if (!defined wctob && !@HAVE_DECL_WCTOB@) || @REPLACE_WCTOB@
+/* wctob is provided by gnulib, or wctob exists but is not declared.  */
+extern int wctob (wint_t wc);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef wctob
+# define wctob(w) \
+    (GL_LINK_WARNING ("wctob is unportable - " \
+                      "use gnulib module wctob for portability"), \
+     wctob (w))
+#endif
+
+
+/* Test whether *PS is in the initial state.  */
+#if @GNULIB_MBSINIT@
+# if @REPLACE_MBSINIT@
+#  undef mbsinit
+#  define mbsinit rpl_mbsinit
+# endif
+# if !@HAVE_MBSINIT@ || @REPLACE_MBSINIT@
+extern int mbsinit (const mbstate_t *ps);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef mbsinit
+# define mbsinit(p) \
+    (GL_LINK_WARNING ("mbsinit is unportable - " \
+                      "use gnulib module mbsinit for portability"), \
+     mbsinit (p))
+#endif
+
+
+/* Convert a multibyte character to a wide character.  */
+#if @GNULIB_MBRTOWC@
+# if @REPLACE_MBRTOWC@
+#  undef mbrtowc
+#  define mbrtowc rpl_mbrtowc
+# endif
+# if !@HAVE_MBRTOWC@ || @REPLACE_MBRTOWC@
+extern size_t mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef mbrtowc
+# define mbrtowc(w,s,n,p) \
+    (GL_LINK_WARNING ("mbrtowc is unportable - " \
+                      "use gnulib module mbrtowc for portability"), \
+     mbrtowc (w, s, n, p))
+#endif
+
+
+/* Recognize a multibyte character.  */
+#if @GNULIB_MBRLEN@
+# if @REPLACE_MBRLEN@
+#  undef mbrlen
+#  define mbrlen rpl_mbrlen
+# endif
+# if !@HAVE_MBRLEN@ || @REPLACE_MBRLEN@
+extern size_t mbrlen (const char *s, size_t n, mbstate_t *ps);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef mbrlen
+# define mbrlen(s,n,p) \
+    (GL_LINK_WARNING ("mbrlen is unportable - " \
+                      "use gnulib module mbrlen for portability"), \
+     mbrlen (s, n, p))
+#endif
+
+
+/* Convert a string to a wide string.  */
+#if @GNULIB_MBSRTOWCS@
+# if @REPLACE_MBSRTOWCS@
+#  undef mbsrtowcs
+#  define mbsrtowcs rpl_mbsrtowcs
+# endif
+# if !@HAVE_MBSRTOWCS@ || @REPLACE_MBSRTOWCS@
+extern size_t mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef mbsrtowcs
+# define mbsrtowcs(d,s,l,p) \
+    (GL_LINK_WARNING ("mbsrtowcs is unportable - " \
+                      "use gnulib module mbsrtowcs for portability"), \
+     mbsrtowcs (d, s, l, p))
+#endif
+
+
+/* Convert a string to a wide string.  */
+#if @GNULIB_MBSNRTOWCS@
+# if @REPLACE_MBSNRTOWCS@
+#  undef mbsnrtowcs
+#  define mbsnrtowcs rpl_mbsnrtowcs
+# endif
+# if !@HAVE_MBSNRTOWCS@ || @REPLACE_MBSNRTOWCS@
+extern size_t mbsnrtowcs (wchar_t *dest, const char **srcp, size_t srclen, size_t len, mbstate_t *ps);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef mbsnrtowcs
+# define mbsnrtowcs(d,s,n,l,p) \
+    (GL_LINK_WARNING ("mbsnrtowcs is unportable - " \
+                      "use gnulib module mbsnrtowcs for portability"), \
+     mbsnrtowcs (d, s, n, l, p))
+#endif
+
+
+/* Convert a wide character to a multibyte character.  */
+#if @GNULIB_WCRTOMB@
+# if @REPLACE_WCRTOMB@
+#  undef wcrtomb
+#  define wcrtomb rpl_wcrtomb
+# endif
+# if !@HAVE_WCRTOMB@ || @REPLACE_WCRTOMB@
+extern size_t wcrtomb (char *s, wchar_t wc, mbstate_t *ps);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef wcrtomb
+# define wcrtomb(s,w,p) \
+    (GL_LINK_WARNING ("wcrtomb is unportable - " \
+                      "use gnulib module wcrtomb for portability"), \
+     wcrtomb (s, w, p))
+#endif
+
+
+/* Convert a wide string to a string.  */
+#if @GNULIB_WCSRTOMBS@
+# if @REPLACE_WCSRTOMBS@
+#  undef wcsrtombs
+#  define wcsrtombs rpl_wcsrtombs
+# endif
+# if !@HAVE_WCSRTOMBS@ || @REPLACE_WCSRTOMBS@
+extern size_t wcsrtombs (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef wcsrtombs
+# define wcsrtombs(d,s,l,p) \
+    (GL_LINK_WARNING ("wcsrtombs is unportable - " \
+                      "use gnulib module wcsrtombs for portability"), \
+     wcsrtombs (d, s, l, p))
+#endif
+
+
+/* Convert a wide string to a string.  */
+#if @GNULIB_WCSNRTOMBS@
+# if !@HAVE_WCSNRTOMBS@
+extern size_t wcsnrtombs (char *dest, const wchar_t **srcp, size_t srclen, size_t len, mbstate_t *ps);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef wcsnrtombs
+# define wcsnrtombs(d,s,n,l,p) \
+    (GL_LINK_WARNING ("wcsnrtombs is unportable - " \
+                      "use gnulib module wcsnrtombs for portability"), \
+     wcsnrtombs (d, s, n, l, p))
+#endif
+
+
 /* Return the number of screen columns needed for WC.  */
 #if @GNULIB_WCWIDTH@
 # if @REPLACE_WCWIDTH@

Copied: libprelude/trunk/libmissing/wcrtomb.c (from rev 11101, libprelude/trunk/libmissing/setsockopt.c)
===================================================================
--- libprelude/trunk/libmissing/wcrtomb.c	                        (rev 0)
+++ libprelude/trunk/libmissing/wcrtomb.c	2009-04-07 07:51:35 UTC (rev 11123)
@@ -0,0 +1,53 @@
+/* Convert wide character to multibyte character.
+   Copyright (C) 2008 Free Software Foundation, Inc.
+   Written by Bruno Haible <[email protected]>, 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 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <wchar.h>
+
+#include <errno.h>
+#include <stdlib.h>
+
+
+size_t
+wcrtomb (char *s, wchar_t wc, mbstate_t *ps)
+{
+  /* This implementation of wcrtomb on top of wctomb() supports only
+     stateless encodings.  ps must be in the initial state.  */
+  if (ps != NULL && !mbsinit (ps))
+    {
+      errno = EINVAL;
+      return (size_t)(-1);
+    }
+
+  if (s == NULL)
+    /* We know the NUL wide character corresponds to the NUL character.  */
+    return 1;
+  else
+    {
+      int ret = wctomb (s, wc);
+
+      if (ret >= 0)
+	return ret;
+      else
+	{
+	  errno = EILSEQ;
+	  return (size_t)(-1);
+	}
+    }
+}

Modified: libprelude/trunk/libmissing/wctype.in.h
===================================================================
--- libprelude/trunk/libmissing/wctype.in.h	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/wctype.in.h	2009-04-07 07:51:35 UTC (rev 11123)
@@ -57,6 +57,9 @@
 /* Define wint_t.  (Also done in wchar.in.h.)  */
 #if !@HAVE_WINT_T@ && !defined wint_t
 # define wint_t int
+# ifndef WEOF
+#  define WEOF -1
+# endif
 #endif
 
 /* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions.

Deleted: libprelude/trunk/libmissing/winsock-select.c
===================================================================
--- libprelude/trunk/libmissing/winsock-select.c	2009-04-06 16:47:04 UTC (rev 11122)
+++ libprelude/trunk/libmissing/winsock-select.c	2009-04-07 07:51:35 UTC (rev 11123)
@@ -1,423 +0,0 @@
-/* Emulation for select(2)
-   Contributed by Paolo Bonzini.
-
-   Copyright 2008 Free Software Foundation, Inc.
-
-   This file is part of gnulib.
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU Lesser General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
-   any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public License along
-   with this program; if not, write to the Free Software Foundation,
-   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
-
-#include <config.h>
-#include <alloca.h>
-
-#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-#include <sys/types.h>
-#include <stdbool.h>
-#include <errno.h>
-#include <limits.h>
-
-#include <winsock2.h>
-#include <windows.h>
-#include <io.h>
-#include <stdio.h>
-#include <conio.h>
-#include <time.h>
-
-struct bitset {
-  unsigned char in[FD_SETSIZE / CHAR_BIT];
-  unsigned char out[FD_SETSIZE / CHAR_BIT];
-};
-
-/* 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 output fd_sets for libc descriptor FD (whose Win32 handle is H).  */
-
-static int
-win32_poll_handle (HANDLE h, int fd, struct bitset *rbits, struct bitset *wbits,
-		   struct bitset *xbits)
-{
-  BOOL read, write, except;
-  int i, ret;
-  INPUT_RECORD *irbuffer;
-  DWORD avail, nbuffer;
-  BOOL bRet;
-  IO_STATUS_BLOCK iosb;
-  FILE_PIPE_LOCAL_INFORMATION fpli;
-  static PNtQueryInformationFile NtQueryInformationFile;
-  static BOOL once_only;
-
-  read = write = except = FALSE;
-  switch (GetFileType (h))
-    {
-    case FILE_TYPE_DISK:
-      read = TRUE;
-      write = TRUE;
-      break;
-
-    case FILE_TYPE_PIPE:
-      if (!once_only)
-	{
-	  NtQueryInformationFile = (PNtQueryInformationFile)
-	    GetProcAddress (GetModuleHandle ("ntdll.dll"),
-			    "NtQueryInformationFile");
-	  once_only = TRUE;
-	}
-
-      if (PeekNamedPipe (h, NULL, 0, NULL, &avail, NULL) != 0)
-	{
-	  if (avail)
-	    read = TRUE;
-	}
-
-      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))
-	    write = TRUE;
-	}
-      break;
-
-    case FILE_TYPE_CHAR:
-      ret = WaitForSingleObject (h, 0);
-      write = TRUE;
-      if (ret == WAIT_OBJECT_0)
-        {
-	  nbuffer = avail = 0;
-	  bRet = GetNumberOfConsoleInputEvents (h, &nbuffer);
-	  if (!bRet || nbuffer == 0)
-	    except = TRUE;
-
-	  irbuffer = (INPUT_RECORD *) alloca (nbuffer * sizeof (INPUT_RECORD));
-	  bRet = PeekConsoleInput (h, irbuffer, nbuffer, &avail);
-	  if (!bRet || avail == 0)
-	    except = TRUE;
-
-	  for (i = 0; i < avail; i++)
-	    if (irbuffer[i].EventType == KEY_EVENT)
-	      read = TRUE;
-	}
-      break;
-
-    default:
-      ret = WaitForSingleObject (h, 0);
-      write = TRUE;
-      if (ret == WAIT_OBJECT_0)
-        read = TRUE;
-
-      break;
-    }
-
-  ret = 0;
-  if (read && (rbits->in[fd / CHAR_BIT] & (1 << (fd & (CHAR_BIT - 1)))))
-    {
-      rbits->out[fd / CHAR_BIT] |= (1 << (fd & (CHAR_BIT - 1)));
-      ret++;
-    }
-
-  if (write && (wbits->in[fd / CHAR_BIT] & (1 << (fd & (CHAR_BIT - 1)))))
-    {
-      wbits->out[fd / CHAR_BIT] |= (1 << (fd & (CHAR_BIT - 1)));
-      ret++;
-    }
-
-  if (except && (xbits->in[fd / CHAR_BIT] & (1 << (fd & (CHAR_BIT - 1)))))
-    {
-      xbits->out[fd / CHAR_BIT] |= (1 << (fd & (CHAR_BIT - 1)));
-      ret++;
-    }
-
-  return ret;
-}
-
-int
-rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds,
-            struct timeval *timeout)
-{
-  static struct timeval tv0;
-  static HANDLE hEvent;
-  HANDLE h, handle_array[FD_SETSIZE + 2];
-  fd_set handle_rfds, handle_wfds, handle_xfds;
-  struct bitset rbits, wbits, xbits;
-  unsigned char anyfds_in[FD_SETSIZE / CHAR_BIT];
-  DWORD ret, wait_timeout, nhandles, nsock;
-  MSG msg;
-  int i, fd, rc;
-
-  if (nfds > FD_SETSIZE)
-    nfds = FD_SETSIZE;
-
-  if (!timeout)
-    wait_timeout = INFINITE;
-  else
-    {
-      wait_timeout = timeout->tv_sec + timeout->tv_usec / 1000;
-
-      /* select is also used as a portable usleep.  */
-      if (!rfds && !wfds && !xfds)
-        {
-          Sleep (wait_timeout);
-          return 0;
-        }
-    }
-
-  if (!hEvent)
-    hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
-
-  handle_array[0] = hEvent;
-  nhandles = 1;
-  nsock = 0;
-
-  /* Copy descriptors to bitsets.  */
-  memset (&rbits, 0, sizeof (rbits));
-  memset (&wbits, 0, sizeof (wbits));
-  memset (&xbits, 0, sizeof (xbits));
-  memset (anyfds_in, 0, sizeof (anyfds_in));
-  if (rfds)
-    for (i = 0; i < rfds->fd_count; i++)
-      {
-        fd = rfds->fd_array[i];
-        rbits.in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1));
-        anyfds_in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1));
-      }
-  else
-    rfds = (fd_set *) alloca (sizeof (fd_set));
-
-  if (wfds)
-    for (i = 0; i < wfds->fd_count; i++)
-      {
-        fd = wfds->fd_array[i];
-        wbits.in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1));
-        anyfds_in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1));
-      }
-  else
-    wfds = (fd_set *) alloca (sizeof (fd_set));
-
-  if (xfds)
-    for (i = 0; i < xfds->fd_count; i++)
-      {
-        fd = xfds->fd_array[i];
-        xbits.in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1));
-        anyfds_in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1));
-      }
-  else
-    xfds = (fd_set *) alloca (sizeof (fd_set));
-
-  /* Zero all the fd_sets, including the application's.  */
-  FD_ZERO (rfds);
-  FD_ZERO (wfds);
-  FD_ZERO (xfds);
-  FD_ZERO (&handle_rfds);
-  FD_ZERO (&handle_wfds);
-  FD_ZERO (&handle_xfds);
-
-  /* Classify handles.  Create fd sets for sockets, poll the others. */
-  for (i = 0; i < nfds; i++)
-    {
-      WSANETWORKEVENTS ev;
-
-      if ((anyfds_in[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))) == 0)
-	continue;
-
-      h = (HANDLE) _get_osfhandle (i);
-      if (!h)
-        {
-	  errno = EBADF;
-	  return -1;
-        }
-
-      /* 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, but we
-	     need to map descriptors to handles.  */
-          if (rbits.in[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1))))
-	    {
-              requested |= FD_READ | FD_ACCEPT;
-	      FD_SET ((SOCKET) h, rfds);
-	      FD_SET ((SOCKET) h, &handle_rfds);
-	    }
-          if (wbits.in[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1))))
-	    {
-              requested |= FD_WRITE | FD_CONNECT;
-	      FD_SET ((SOCKET) h, wfds);
-	      FD_SET ((SOCKET) h, &handle_wfds);
-	    }
-          if (xbits.in[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1))))
-	    {
-              requested |= FD_OOB;
-	      FD_SET ((SOCKET) h, xfds);
-	      FD_SET ((SOCKET) h, &handle_xfds);
-	    }
-
-          WSAEventSelect ((SOCKET) h, hEvent, requested);
-	  nsock++;
-        }
-      else
-        {
-          handle_array[nhandles++] = h;
-
-	  /* Poll now.  If we get an event, do not wait below.  */
-          if (wait_timeout != 0
-	      && win32_poll_handle (h, i, &rbits, &wbits, &xbits))
-	    wait_timeout = 0;
-        }
-    }
-
-  if (wait_timeout == 0 || nsock == 0)
-    rc = 0;
-  else
-    {
-      /* See if we need to wait in the loop below.  If any select is ready,
-         do MsgWaitForMultipleObjects anyway to dispatch messages, but
-         no need to call select again.  */
-      rc = select (0, &handle_rfds, &handle_wfds, &handle_xfds, &tv0);
-      if (rc == 0)
-	{
-	  /* Restore the fd_sets for the other select we do below.  */
-          memcpy (&handle_rfds, rfds, sizeof (fd_set));
-          memcpy (&handle_wfds, wfds, sizeof (fd_set));
-          memcpy (&handle_xfds, xfds, sizeof (fd_set));
-	}
-      else
-        wait_timeout = 0;
-    }
-
-  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 we haven't done it yet, check the status of the sockets.  */
-  if (rc == 0 && nsock > 0)
-    rc = select (0, &handle_rfds, &handle_wfds, &handle_xfds, &tv0);
-
-  /* Now fill in the results.  */
-  FD_ZERO (rfds);
-  FD_ZERO (wfds);
-  FD_ZERO (xfds);
-
-  /* Place a sentinel at the end of the array.  */
-  handle_array[nhandles] = NULL;
-  nhandles = 1;
-  for (i = 0; i < nfds; i++)
-    {
-      if ((anyfds_in[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))) == 0)
-	continue;
-
-      h = (HANDLE) _get_osfhandle (i);
-      if (h != handle_array[nhandles])
-	{
-	  /* Perform handle->descriptor mapping.  Don't update rc, as these
-	     results are counted in the return value of Winsock's select.  */
-          WSAEventSelect ((SOCKET) h, NULL, 0);
-          if (FD_ISSET (h, &handle_rfds))
-            FD_SET (i, rfds);
-          if (FD_ISSET (h, &handle_wfds))
-            FD_SET (i, wfds);
-          if (FD_ISSET (h, &handle_xfds))
-            FD_SET (i, xfds);
-	}
-      else
-        {
-          /* Not a socket.  */
-          nhandles++;
-          win32_poll_handle (h, i, &rbits, &wbits, &xbits);
-          if (rbits.out[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1))))
-            {
-	      rc++;
-	      FD_SET (i, rfds);
-	    }
-          if (wbits.out[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1))))
-            {
-	      rc++;
-	      FD_SET (i, wfds);
-	    }
-          if (xbits.out[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1))))
-            {
-	      rc++;
-	      FD_SET (i, xfds);
-	    }
-        }
-    }
-
-  return rc;
-}
-
-#endif /* Native Win32.  */

_______________________________________________
Prelude-cvslog site list
[email protected]
http://lists.prelude-ids.org/mailman/listinfo/prelude-cvslog
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.