changeset 14517:8636d98120a9

merge to current master
author Bruce Korb <bkorb@gnu.org>
date Fri, 01 Apr 2011 08:10:58 -0700
parents f4f244f523bd (current diff) 8b5a7d072ac7 (diff)
children 04ce36b456cc
files .gitignore ChangeLog build-aux/git-version-gen gnulib-tool lib/openat-die.c lib/unictype/combining.c lib/unictype/combining.h lib/xalloc-die.c m4/dos.m4 modules/alloca-opt modules/arg-nonnull modules/argz modules/arpa_inet modules/byteswap modules/c++defs modules/ctype modules/dirent modules/errno modules/fcntl-h modules/float modules/fnmatch modules/getopt-posix modules/glob modules/iconv-h modules/iconv_open modules/inttypes modules/langinfo modules/link-warning modules/locale modules/math modules/netdb modules/netinet_in modules/poll-h modules/pthread modules/pty modules/sched modules/search modules/selinux-h modules/signal modules/spawn modules/stdarg modules/stdbool modules/stddef modules/stdint modules/stdio modules/stdlib modules/string modules/strings modules/sys_file modules/sys_ioctl modules/sys_select modules/sys_socket modules/sys_stat modules/sys_time modules/sys_times modules/sys_utsname modules/sys_wait modules/sysexits modules/termios modules/time modules/unictype/bidicategory-byname-tests modules/unictype/bidicategory-name-tests modules/unictype/bidicategory-of-tests modules/unictype/bidicategory-test-tests modules/unistd modules/unitypes modules/unused-parameter modules/warn-on-use modules/wchar modules/wctype modules/wctype-c++-tests modules/wctype-tests tests/test-wctype-c++.cc tests/test-wctype.c tests/unictype/test-combining.c
diffstat 684 files changed, 22502 insertions(+), 4273 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,2429 @@
+2011-03-31  Eric Blake  <eblake@redhat.com>
+
+	nonblocking: fix mingw test failures
+	* lib/nonblocking.c (set_nonblocking_flag): Succeed when clearing
+	non-blocking flag on regular file.
+	(get_nonblocking_flag): Set errno on invalid fd.
+	* tests/test-nonblocking.c (main): Avoid test failure on
+	directories if fchdir is not active.
+	* modules/nonblocking-tests (Depends-on): Drop unused dependency.
+
+2011-03-31  Bruno Haible  <bruno@clisp.org>
+
+	Fix bug with gl_WARN_ON_USE_PREPARE, introduced on 2011-01-23.
+	* m4/gnulib-common.m4 (gl_ASSERT_NO_GNULIB_POSIXCHECK): Hide the
+	gl_WARN_ON_USE_PREPARE definition from 'aclocal'.
+	Reported by Simon Josefsson <simon@josefsson.org>.
+
+2011-03-31  Bruno Haible  <bruno@clisp.org>
+	and Eric Blake  <eblake@redhat.com>
+
+	nonblocking: new module
+	* modules/nonblocking: New module.
+	* modules/nonblocking-tests: Likewise.
+	* lib/nonblocking.h: New file.
+	* lib/nonblocking.c: Likewise.
+	* tests/test-nonblocking.c: New test.
+	* lib/ioctl.c (ioctl) [mingw]: Update comment.
+
+2011-03-30  Bruno Haible  <bruno@clisp.org>
+
+	stdio: Avoid GCC >= 4.4 warnings when using %lld and similar on mingw.
+	* lib/stdio.in.h (_GL_ATTRIBUTE_FORMAT_PRINTF): Use 'gnu_printf' format
+	instead of 'printf' format for GCC >= 4.4.
+	(_GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM): New macro.
+	(fprintf, printf, vfprintf, vprintf): Declare with
+	_GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM when the function ends up calling
+	the system's vfprintf() function.
+	Reported by Daniel P. Berrange <berrange@redhat.com> via Eric Blake.
+
+2011-03-30  Eric Blake  <eblake@redhat.com>
+
+	passfd: fix scoping bug
+	* lib/passfd.c (sendfd, recvfd): Don't let buf go out of scope
+	before sendmsg/recvmsg.
+
+	passfd: standardize coding conventions
+	* m4/afunix.m4 (gl_SOCKET_AFUNIX): Drop check for something that
+	can be learned at compile time.
+	* lib/passfd.c (MSG_CMSG_CLOEXEC): Reduce number of in-function
+	ifdefs.
+	(sendfd, recvfd): Follow gnulib code conventions.
+
+	passfd: fix incorrect sendmsg arguments
+	* lib/passfd.c (sendfd): Avoid uninitialized msg_flags field, and
+	incorrect msg_controllen value.
+	* modules/passfd-tests (Depends-on): Check for alarm.
+	* tests/test-passfd.c (main) [HAVE_DECL_ALARM]: Avoid hanging test.
+	Reported by Bastien ROUCARIES.
+
+2011-03-30  Bruno Haible  <bruno@clisp.org>
+
+	c-strcasestr: Relicense under LGPLv2+.
+	* modules/c-strcasestr (License): Change to LGPLv2+.
+	Requested by Eric Blake, for libvirt.
+
+2011-03-30  Simon Josefsson  <simon@josefsson.org>
+
+	* users.txt: Add libidn2.  Fix libtasn1 link.
+
+2011-03-30  Jim Meyering  <meyering@redhat.com>
+
+	tests: readlink* ("",... fails with EINVAL on newer kernels
+	readlink and readlinkat have typically failed with ENOENT for
+	the invalid, empty file name,  "".  However, with the advent
+	of linux-2.6.39, they fail with EINVAL.
+	* tests/test-areadlink.h (test_areadlink): Also accept EINVAL
+	when operating on the empty file name.
+	* tests/test-readlink.h (test_readlink): Likewise.
+
+2011-03-29  Bruno Haible  <bruno@clisp.org>
+
+	Relicense some modules under LGPLv2+, for libidn2.
+	* modules/array-mergesort (License): Change to LGPLv2+.
+	* modules/c-strcaseeq (License): Likewise.
+	* modules/striconveh (License): Likewise.
+	* modules/striconveha (License): Likewise.
+	* modules/uniconv/base (License): Likewise.
+	* modules/uniconv/u8-conv-from-enc (License): Likewise.
+	* modules/uniconv/u8-strconv-from-enc (License): Likewise.
+	* modules/uniconv/u8-strconv-from-locale (License): Likewise.
+	* modules/unictype/base (License): Likewise.
+	* modules/unictype/bidiclass-of (License): Likewise.
+	* modules/unictype/category-M (License): Likewise.
+	* modules/unictype/category-none (License): Likewise.
+	* modules/unictype/category-of (License): Likewise.
+	* modules/unictype/category-test (License): Likewise.
+	* modules/unictype/category-test-withtable (License): Likewise.
+	* modules/unictype/combining-class (License): Likewise.
+	* modules/unictype/joiningtype-of (License): Likewise.
+	* modules/unictype/scripts (License): Likewise.
+	* modules/uninorm/base (License): Likewise.
+	* modules/uninorm/canonical-decomposition (License): Likewise.
+	* modules/uninorm/composition (License): Likewise.
+	* modules/uninorm/decompose-internal (License): Likewise.
+	* modules/uninorm/decomposition-table (License): Likewise.
+	* modules/uninorm/nfc (License): Likewise.
+	* modules/uninorm/nfd (License): Likewise.
+	* modules/uninorm/u32-normalize (License): Likewise.
+	* modules/unistr/base (License): Likewise.
+	* modules/unistr/u32-cpy (License): Likewise.
+	* modules/unistr/u32-mbtouc-unsafe (License): Likewise.
+	* modules/unistr/u32-to-u8 (License): Likewise.
+	* modules/unistr/u32-uctomb (License): Likewise.
+	* modules/unistr/u8-check (License): Likewise.
+	* modules/unistr/u8-mblen (License): Likewise.
+	* modules/unistr/u8-mbtouc (License): Likewise.
+	* modules/unistr/u8-mbtouc-unsafe (License): Likewise.
+	* modules/unistr/u8-mbtoucr (License): Likewise.
+	* modules/unistr/u8-prev (License): Likewise.
+	* modules/unistr/u8-strlen (License): Likewise.
+	* modules/unistr/u8-to-u32 (License): Likewise.
+	* modules/unistr/u8-uctomb (License): Likewise.
+	* modules/unitypes (License): Likewise.
+	Requested by Simon Josefsson.
+
+2011-03-29  Simon Josefsson  <simon@josefsson.org>
+
+	lib-symbol-visibility: Add a notice.
+	* modules/lib-symbol-visibility (Notice): New field.
+
+2011-03-29  Bruno Haible  <bruno@clisp.org>
+
+	getaddrinfo: Doc fix.
+	* doc/posix-functions/getaddrinfo.texi: Mention Windows problem in the
+	section "fixed in Gnulib".
+
+2011-03-28  Simon Josefsson  <simon@josefsson.org>
+
+	* doc/posix-functions/getaddrinfo.texi: Drop netdb.h discussion.
+	Reported by Bastien ROUCARIES <roucaries.bastien@gmail.com>.
+
+2011-03-26  Bruno Haible  <bruno@clisp.org>
+
+	unictype/property-byname: Reduce the number of load-time relocations.
+	* lib/unictype/pr_byname.c: Include <stdlib.h>.
+	(UC_PROPERTY_INDEX_*): New enumeration values.
+	(uc_property_byname): Convert an index from the lookup table to an
+	uc_property_t.
+	* lib/unictype/pr_byname.gperf: Store indices instead of uc_property_t
+	values.
+
+2011-03-26  Bruno Haible  <bruno@clisp.org>
+
+	unictype/property-byname: Allow omitted word separators and aliases.
+	* lib/unictype/pr_byname.gperf: Add property names without word
+	separators. Add aliases from Unicode 6.0 PropertyAliases.txt, except
+	for 'space'.
+
+2011-03-26  Bruno Haible  <bruno@clisp.org>
+
+	unictype/joininggroup-byname: Allow hyphens, omitted word separators.
+	* lib/unictype/joininggroup_byname.c (uc_joining_group_byname): Convert
+	also hyphens to space.
+	* lib/unictype/joininggroup_byname.gperf: Recognize the names also
+	without spaces.
+	* tests/unictype/test-joininggroup_byname.c (main): Add more tests.
+
+2011-03-26  Bruno Haible  <bruno@clisp.org>
+
+	unictype/joiningtype-byname: Recognize long names as well.
+	* lib/unictype.in.h (uc_joiningtype_class_byname): Allow argument to be
+	a long name.
+	* lib/unictype/joiningtype_byname.c: Include <string.h>,
+	unictype/joiningtype_byname.h.
+	(uc_joiningtype_class_byname): Use uc_joining_type_lookup.
+	* lib/unictype/joiningtype_byname.gperf: New file.
+	* modules/unictype/joiningtype-byname (Files): Add
+	lib/unictype/joiningtype_byname.gperf.
+	(Depends-on): Add gperf.
+	(Makefile.am): Add rule for generating unictype/joiningtype_byname.h.
+	* tests/unictype/test-joiningtype_byname.c (main): Test the recognition of
+	long names.
+
+	Tests for module 'unictype/joiningtype-longname'.
+	* modules/unictype/joiningtype-longname-tests: New file.
+	* tests/unictype/test-joiningtype_longname.c: New file.
+
+	New module 'unictype/joiningtype-longname'.
+	* lib/unictype.in.h (uc_joiningtype_class_long_name): New declaration.
+	* lib/unictype/joiningtype_longname.c: New file.
+	* modules/unictype/joiningtype-longname: New file.
+	* modules/unictype/joiningtype-all (Depends-on): Add
+	unictype/joiningtype-longname.
+
+2011-03-26  Bruno Haible  <bruno@clisp.org>
+
+	unictype/bidiclass-byname: Recognize long names as well.
+	* lib/unictype.in.h (uc_bidi_class_byname): Allow argument to be a long
+	name.
+	* lib/unictype/bidi_byname.c: Include <string.h>,
+	unictype/bidi_byname.h.
+	(uc_bidi_class_byname): Use uc_bidi_class_lookup.
+	* lib/unictype/bidi_byname.gperf: New file.
+	* modules/unictype/bidiclass-byname (Files): Add
+	lib/unictype/bidi_byname.gperf.
+	(Depends-on): Add gperf.
+	(Makefile.am): Add rule for generating unictype/bidi_byname.h.
+	* tests/unictype/test-bidi_byname.c (main): Test the recognition of
+	long names.
+
+	Tests for module 'unictype/bidiclass-longname'.
+	* modules/unictype/bidiclass-longname-tests: New file.
+	* tests/unictype/test-bidi_longname.c: New file.
+
+	New module 'unictype/bidiclass-longname'.
+	* lib/unictype.in.h (uc_bidi_class_long_name): New declaration.
+	* lib/unictype/bidi_longname.c: New file.
+	* modules/unictype/bidiclass-longname: New file.
+	* modules/unictype/bidiclass-all (Depends-on): Add
+	unictype/bidiclass-longname.
+
+2011-03-26  Bruno Haible  <bruno@clisp.org>
+
+	unictype/bidi*: Rename modules.
+	* modules/unictype/bidiclass-all: Renamed from
+	modules/unictype/bidicategory-all.
+	* modules/unictype/bidiclass-name: Renamed from
+	modules/unictype/bidiclass-name.
+	(Description): Update.
+	* modules/unictype/bidiclass-name-tests: Renamed from
+	modules/unictype/bidicategory-name-tests.
+	* modules/unictype/bidiclass-byname: Renamed from
+	modules/unictype/bidicategory-byname.
+	(Description): Update.
+	* modules/unictype/bidiclass-byname-tests: Renamed from
+	modules/unictype/bidicategory-byname-tests.
+	* modules/unictype/bidiclass-of: Renamed from
+	modules/unictype/bidicategory-of.
+	(Description): Update.
+	* modules/unictype/bidiclass-of-tests: Renamed from
+	modules/unictype/bidicategory-of-tests.
+	* modules/unictype/bidiclass-test: Renamed from
+	modules/unictype/bidicategory-test.
+	(Description): Update.
+	* modules/unictype/bidiclass-test-tests: Renamed from
+	modules/unictype/bidicategory-test-tests.
+	* modules/unictype/bidicategory-all: New file, a simple redirection.
+	* modules/unictype/bidicategory-name: Likewise.
+	* modules/unictype/bidicategory-byname: Likewise.
+	* modules/unictype/bidicategory-of: Likewise.
+	* modules/unictype/bidicategory-test: Likewise.
+	* modules/unictype/property-bidi-* (Dependencies): Update.
+	* lib/unictype/bidi_*.c: Update comment.
+
+2011-03-26  Bruno Haible  <bruno@clisp.org>
+
+	unictype/bidi*: Rename functions, part 2.
+	* modules/unictype/bidicategory-name (configure.ac): Update required
+	libunistring version.
+	* modules/unictype/bidicategory-byname (configure.ac): Likewise.
+
+2011-03-25  Bruno Haible  <bruno@clisp.org>
+
+	New module 'unictype/combining-class-all'.
+	* modules/unictype/combining-class-all: New file.
+
+	Tests for module 'unictype/combining-class-byname'.
+	* modules/unictype/combining-class-byname-tests: New file.
+	* tests/unictype/test-combiningclass_byname.c: New file.
+
+	New module 'unictype/combining-class-byname'.
+	* lib/unictype.in.h (uc_combining_class_byname): New declaration.
+	* lib/unictype/combiningclass_byname.c: New file.
+	* lib/unictype/combiningclass_byname.gperf: New file.
+	* modules/unictype/combining-class-byname: New file.
+
+	Tests for module 'unictype/combining-class-longname'.
+	* modules/unictype/combining-class-longname-tests: New file.
+	* tests/unictype/test-combiningclass_longname.c: New file.
+
+	New module 'unictype/combining-class-longname'.
+	* lib/unictype.in.h (uc_combining_class_long_name): New declaration.
+	* lib/unictype/combiningclass_longname.c: New file.
+	* modules/unictype/combining-class-longname: New file.
+
+	Tests for module 'unictype/combining-class-name'.
+	* modules/unictype/combining-class-name-tests: New file.
+	* tests/unictype/test-combiningclass_name.c: New file.
+
+	New module 'unictype/combining-class-name'.
+	* lib/unictype.in.h (uc_combining_class_name): New declaration.
+	* lib/unictype/combiningclass_name.c: New file.
+	* modules/unictype/combining-class-name: New file.
+
+2011-03-25  Bruno Haible  <bruno@clisp.org>
+
+	unictype/combining-class: Rename source files.
+	* lib/gen-uni-tables.c (main): Emit unictype/combiningclass.h instead
+	of unictype/combining.h.
+	* lib/unictype/combiningclass.c: Renamed from lib/unictype/combining.c.
+	Update.
+	* lib/unictype/combiningclass.h: Renamed from lib/unictype/combining.h.
+	* modules/unictype/combining-class (Description): Fix.
+	(Files, Makefile.am): Update.
+	* tests/unictype/test-combiningclass.c: Renamed from
+	tests/unictype/test-combining.c.
+	* modules/unictype/combining-class-tests (Files, Makefile.am): Update.
+
+2011-03-25  Bruno Haible  <bruno@clisp.org>
+
+	unictype: Update list of canonical combining classes.
+	* lib/unictype.in.h (UC_CCC_ATA): New enumeration value.
+
+2011-03-25  Bruno Haible  <bruno@clisp.org>
+
+	unictype/category-byname: Recognize long names as well.
+	* lib/unictype.in.h (uc_general_category_byname): Allow argument to be
+	a long name.
+	* lib/unictype/categ_byname.c: Include <stdlib.h>, <string.h>,
+	unictype/categ_byname.h.
+	(UC_CATEGORY_INDEX_*): New enumeration values.
+	(uc_general_category_byname): Use uc_general_category_lookup and
+	convert from index to value.
+	* lib/unictype/categ_byname.gperf: New file.
+	* modules/unictype/category-byname (Files): Add
+	lib/unictype/categ_byname.gperf.
+	(Depends-on): Add gperf.
+	(Makefile.am): Add rule for generating unictype/categ_byname.h.
+	* tests/unictype/test-categ_byname.c (main): Test the recognition of
+	long names.
+
+	Tests for module 'unictype/category-longname'.
+	* modules/unictype/category-longname-tests: New file.
+	* tests/unictype/test-categ_longname.c: New file.
+
+	New module 'unictype/category-longname'.
+	* lib/unictype.in.h (uc_general_category_long_name): New declaration.
+	* lib/unictype/categ_longname.c: New file.
+	* modules/unictype/category-longname: New file.
+	* modules/unictype/category-all (Depends-on): Add it.
+
+2011-03-25  Bruno Haible  <bruno@clisp.org>
+
+	Tests for module 'unictype/category-LC'.
+	* modules/unictype/category-LC-tests: New file.
+	* tests/unictype/test-categ_LC.c: New file, automatically generated.
+
+	New module 'unictype/category-LC'.
+	* lib/unictype.in.h (UC_CATEGORY_MASK_LC): New enumeration value.
+	(UC_CATEGORY_LC): New declaration.
+	(UC_CASED_LETTER): New macro.
+	* lib/gen-uni-tables.c (is_category_LC): New function.
+	(output_categories): Also handle category LC.
+	(UC_CATEGORY_MASK_LC): New enumeration value.
+	(general_category_byname): Also handle category LC.
+	* lib/unictype/categ_LC.c: New file.
+	* lib/unictype/categ_LC.h: New file, automatically generated.
+	* lib/unictype/categ_name.c (uc_general_category_name): Also handle
+	category LC.
+	* lib/unictype/categ_byname.c (uc_general_category_byname): Likewise.
+	* modules/unictype/category-LC: New file.
+	* modules/unictype/category-byname (Depends-on): Add
+	unictype/category-LC.
+	* modules/unictype/category-all (Depends-on): Likewise.
+
+2011-03-25  Eric Blake  <eblake@redhat.com>
+
+	xmalloc: revert yesterday's regression
+	* lib/xmalloc.c (xrealloc): Once again forward xrealloc(NULL,0) to
+	realloc's underlying behavior (allowing allocation of zero-size
+	objects, especially if malloc-gnu is also in use).
+
+2011-03-25  Reuben Thomas  <rrt@sc3d.org>
+
+	maint.mk: add missing version to VC-tag
+	* top/maint.mk: git tag was missing actual tag name; add it.
+
+	valgrind: do leak checking, and exit with code 1 on error (not 0)
+	* m4/valgrind-tests.m4: Add `--error-exitcode=1 --leak-check=full'
+	to VALGRIND.
+
+2010-11-30  Reuben Thomas  <rrt@sc3d.org>
+
+	posix-modules: say what it does.
+	* posix-modules: Add a line to the --help output saying what it does.
+
+2011-03-24  Paul Eggert  <eggert@cs.ucla.edu>
+
+	xmalloc: Do not leak if underlying realloc is C99 compatible.
+	* lib/xmalloc.c (xrealloc): If N is zero, call 'free' directly.
+	This avoids a leak on C99-based systems.  See
+	<http://lists.gnu.org/archive/html/bug-gnulib/2011-03/msg00243.html>.
+
+2011-03-24  Eric Blake  <eblake@redhat.com>
+
+	realloc: document portability problem
+	* doc/posix-functions/realloc.texi (realloc): Mention pitfalls of
+	passing 0 size to realloc.
+
+2011-03-23  Ben Walton  <bwalton@artsci.utoronto.ca>
+
+	doc: update users.txt
+	* users.txt: Add cvsps, tmpwatch
+
+2011-03-23  Matt Rice  <ratmice@gmail.com>
+
+	doc: update users.txt
+	* users.txt: Add gdb.
+
+2011-03-23  Jim Meyering  <meyering@redhat.com>
+
+	doc: update users.txt
+	Looking through matches up to the following URL (there are still
+	several more pages), I found several projects that use gnulib:
+	http://codesearch.google.com/codesearch?start=50&q=gnulib-cache\.m4
+	* users.txt: Add nagios plugins (nagiosplug), acct, gengetopt,
+	gmediaserver, gtkreindeer, jugtail, libunistring, mini-httpd, reindeer.
+
+2011-03-22  Bruno Haible  <bruno@clisp.org>
+
+	unictype/bidi*: Rename functions.
+	* lib/unictype.in.h (uc_bidi_class_name, uc_bidi_class_byname,
+	uc_bidi_class, uc_is_bidi_class): New declarations.
+	* lib/unictype/bidi_byname.c (uc_bidi_class_byname): Renamed from
+	uc_bidi_category_byname.
+	(uc_bidi_category_byname): New function.
+	* lib/unictype/bidi_name.c (u_bidi_class_name): Renamed from
+	u_bidi_category_name.
+	(uc_bidi_class_name): Renamed from uc_bidi_category_name.
+	(uc_bidi_category_name): New function.
+	* lib/unictype/bidi_of.c (uc_bidi_class): Renamed from
+	uc_bidi_category.
+	(uc_bidi_category): New function.
+	* lib/unictype/bidi_test.c (uc_is_bidi_class): Renamed from
+	uc_is_bidi_category. Invoke uc_bidi_class.
+	(uc_is_bidi_category): New function.
+	* tests/unictype/test-bidi_byname.c (main): Test uc_bidi_class_byname
+	instead of uc_bidi_category_byname.
+	* tests/unictype/test-bidi_name.c (main): Test uc_bidi_class_name
+	instead of uc_bidi_category_name.
+	* tests/unictype/test-bidi_of.c (main): Test uc_bidi_class instead of
+	uc_bidi_category.
+	* tests/unictype/test-bidi_test.c (main): Test uc_is_bidi_class
+	instead of uc_is_bidi_category.
+
+2011-03-21  Bruno Haible  <bruno@clisp.org>
+
+	New module 'unictype/joininggroup-all'.
+	* modules/unictype/joininggroup-all: New file.
+
+	Tests for module 'unictype/joininggroup-of'.
+	* modules/unictype/joininggroup-of-tests: New file.
+	* tests/unictype/test-joininggroup_of.c: New file.
+	* tests/unictype/test-joininggroup_of.h: New file, automatically
+	generated by gen-uni-tables.
+
+	New module 'unictype/joininggroup-of'.
+	* modules/unictype/joininggroup-of: New file.
+	* lib/unictype/joininggroup_of.c: New file.
+	* lib/unictype/joininggroup_of.h: New file, automatically generated by
+	gen-uni-tables.
+
+	Tests for module 'unictype/joininggroup-byname'.
+	* modules/unictype/joininggroup-byname-tests: New file.
+	* tests/unictype/test-joininggroup_byname.c: New file.
+
+	New module 'unictype/joininggroup-byname'.
+	* modules/unictype/joininggroup-byname: New file.
+	* lib/unictype/joininggroup_byname.c: New file.
+	* lib/unictype/joininggroup_byname.gperf: New file.
+
+	Tests for module 'unictype/joininggroup-name'.
+	* modules/unictype/joininggroup-name-tests: New file.
+	* tests/unictype/test-joininggroup_name.c: New file.
+
+	New module 'unictype/joininggroup-name'.
+	* modules/unictype/joininggroup-name: New file.
+	* lib/unictype/joininggroup_name.c: New file.
+	* lib/unictype/joininggroup_name.h: New file.
+
+	New module 'unictype/joiningtype-all'.
+	* modules/unictype/joiningtype-all: New file.
+
+	Tests for module 'unictype/joiningtype-of'.
+	* modules/unictype/joiningtype-of-tests: New file.
+	* tests/unictype/test-joiningtype_of.c: New file.
+	* tests/unictype/test-joiningtype_of.h: New file, automatically
+	generated by gen-uni-tables.
+
+	New module 'unictype/joiningtype-of'.
+	* modules/unictype/joiningtype-of: New file.
+	* lib/unictype/joiningtype_of.c: New file.
+	* lib/unictype/joiningtype_of.h: New file, automatically generated by
+	gen-uni-tables.
+
+	Tests for module 'unictype/joiningtype-byname'.
+	* modules/unictype/joiningtype-byname-tests: New file.
+	* tests/unictype/test-joiningtype_byname.c: New file.
+
+	New module 'unictype/joiningtype-byname'.
+	* modules/unictype/joiningtype-byname: New file.
+	* lib/unictype/joiningtype_byname.c: New file.
+
+	Tests for module 'unictype/joiningtype-name'.
+	* modules/unictype/joiningtype-name-tests: New file.
+	* tests/unictype/test-joiningtype_name.c: New file.
+
+	New module 'unictype/joiningtype-name'.
+	* modules/unictype/joiningtype-name: New file.
+	* lib/unictype/joiningtype_name.c: New file.
+
+	unictype: Add support for Arabic shaping properties.
+	* lib/unictype.in.h (UC_JOINING_TYPE_*): New enumeration values.
+	(uc_joining_type_name, uc_joining_type_byname, uc_joining_type): New
+	declarations.
+	(UC_JOINING_GROUP_*): New enumeration values.
+	(uc_joining_group_name, uc_joining_group_byname, uc_joining_group): New
+	declarations.
+	* lib/gen-uni-tables.c (UC_JOINING_TYPE_*): New enumeration values.
+	(unicode_joining_type): New variable.
+	(UC_JOINING_GROUP_*): New enumeration values.
+	(unicode_joining_group): New variable.
+	(fill_arabicshaping, joining_type_as_c_identifier,
+	output_joining_type_test, output_joining_type,
+	joining_group_as_c_identifier, output_joining_group_test,
+	output_joining_group): New functions.
+	(main); Add an argument denoting the ArabicShaping.txt file. Invoke
+	fill_arabicshaping and output_joining_type_test, output_joining_type,
+	output_joining_group_test, output_joining_group.
+	Reported by Simon Josefsson.
+
+2011-03-21  Jim Meyering  <meyering@redhat.com>
+
+	strftime: fix a bug in yesterday's change
+	* lib/strftime.c (add): Accommodate width's initial value of -1.
+	Otherwise, nstrftime would copy uninitialized data into
+	the result buffer.
+
+2011-03-21  Jim Meyering  <meyering@redhat.com>
+
+	tests: add strftime-tests module
+	* tests/test-strftime.c: New file.
+	* modules/strftime-tests: New module.
+
+2011-03-20  Paul Eggert  <eggert@cs.ucla.edu>
+
+	strftime: don't assume a byte count fits in 'int'
+	* lib/strftime.c (add): Don't assume first arg fits in 'int'.  I
+	found this problem by static analysis, using gcc -Wstrict-overflow
+	(GCC 4.5.2, x86-64).  This reported an optimization that depended
+	on an integer overflow having undefined behavior, but it turns out
+	that the argument is a size, which might not fit in 'int' anyway,
+
+2011-03-20  Paul Eggert  <eggert@cs.ucla.edu>
+
+	stdio: don't require ignore_value around fwrite
+
+	This patch works around libc bug 11959
+	<http://sources.redhat.com/bugzilla/show_bug.cgi?id=11959>.
+	Without this patch, applications must often write
+	ignore_value (fwrite (...)) even though the ignore_value is
+	not helpful here.  It's common to write many objects, using
+	fwrite/printf/etc., and then use ferror to detect output error.
+
+	I considered making this patch optional, but decided against it,
+	because libc is obviously being inconsistent here: there is no
+	reason libc should insist that user code must inspect fwrite
+	return's value without also insisting that it inspect printf's,
+	putchar's, etc.  If user code wants to have a strict style where
+	all these functions' values are checked (so that ferror need not
+	be checked), we could add support for that style in a new gnulib
+	module, but in the meantime it's better to be consistent and to
+	support common usage.
+
+	* lib/stdio.in.h (rpl_fwrite): Define this wrapper around fwrite,
+	to work around libc bug 11959, if __USE_FORTIFY_LEVEL indicates
+	that we are compiling in checking mode, and if not C++, and
+	if not already wrapping fwrite for some other reason.
+	(fwrite): #define to rpl_fwrite if the latter is defined.
+
+2011-03-20  Bruno Haible  <bruno@clisp.org>
+
+	verror: Fix compilation error introduced on 2011-02-13.
+	* lib/verror.h (verror, verror_at_line): Use _GL_ATTRIBUTE_FORMAT macro
+	instead of __attribute__.
+	Reported by Tom G. Christensen <tgc@jupiterrise.com>.
+
+2011-03-20  Paul Eggert  <eggert@cs.ucla.edu>
+            Bruno Haible  <bruno@clisp.org>
+
+	socklen: do not depend on sys_socket
+	While trying to modify Emacs to use gnulib's socklen module,
+	I discovered a circular dependency: socklen depends on sys_socket
+	and vice versa.  Emacs can use socklen, but it does not need
+	sys_socket because it has its own substitute for sys/socket.h.
+	* m4/socklen.m4 (gl_SOCKET_HEADERS): New macro, extracted from
+	gl_TYPE_SOCKLEN_T.
+	(gl_CHECK_SOCKET_HEADERS): New macro, taken from parts of
+	gl_PREREQ_SYS_H_SOCKET.
+	(gl_TYPE_SOCKLEN_T): Require it instead of requiring
+	gl_PREREQ_SYS_H_SOCKET.
+	* m4/sys_socket_h.m4 (gl_PREREQ_SYS_H_SOCKET): Require
+	gl_CHECK_SOCKET_HEADERS instead of doing its work ourselves.
+	* modules/socklen (Depends-on): Do not depend on sys_socket.
+	(Include): Adjust to match the code used in gl_SOCKET_HEADERS.
+
+2011-03-20  Jim Meyering  <meyering@redhat.com>
+
+	maint.mk: sort file names *after* new transformation
+	* top/maint.mk (sc_po_check): Sorting before removing the $(srcdir)/
+	prefix would have led to an unwarranted failure in GNU parted.
+	Sort after that transformation.
+
+2011-03-19  Jim Meyering  <meyering@redhat.com>
+
+	maint.mk: fix po-file syntax-check rule
+	* top/maint.mk (sc_po_check): Fix fatal typo in yesterday's change.
+	Patch by Bruno Haible.
+
+2011-03-19  Bruno Haible  <bruno@clisp.org>
+
+	socklen: Update comment.
+	* m4/socklen.m4: Update comment about platforms.
+
+2011-03-19  Paul Eggert  <eggert@cs.ucla.edu>
+            Bruno Haible  <bruno@clisp.org>
+
+	inet_ntop, inet_pton: Simplify.
+	* modules/inet_ntop (Depends-on): Remove socklen, since sys_socket is
+	documented to provide socklen_t and we already depend on sys_socket.
+	* modules/inet_pton (Depends-on): Likewise.
+	* lib/arpa_inet.in.h: Adjust comment.
+
+2011-03-19  Paul Eggert  <eggert@cs.ucla.edu>
+            Bruno Haible  <bruno@clisp.org>
+
+	netdb: Simplify.
+	* modules/netdb (Depends-on): Remove socklen, since sys_socket is
+	documented to provide socklen_t and we already depend on sys_socket.
+	* lib/netdb.in.h: Adjust comment.
+
+2011-03-19  Bruno Haible  <bruno@clisp.org>
+
+	sys_socket, netdb: Document problem with socklen_t.
+	* doc/posix-headers/sys_socket.texi: Mention lack of socklen_t on some
+	platforms.
+	* doc/posix-headers/netdb.texi: Likewise.
+
+2011-03-18  Eric Blake  <eblake@redhat.com>
+
+	maint.mk: let po check work in VPATH build
+	* top/maint.mk (po_file): Allow cfg.mk override.
+	(sc_po_check): Allow VPATH use.
+	Reported by Jiri Denemark.
+
+2011-03-16  Jim Meyering  <meyering@redhat.com>
+
+	maint.mk: allow fine-grained syntax-check exclusion via Make variables
+	Before, you would have had to create one .x-sc_ file per rule in order
+	to exempt offending files.  Now, you may instead use a Make variable --
+	usually defined in cfg.mk -- whose name identifies the affected rule.
+	* top/maint.mk (_sc_excl): Define.
+	(VC_LIST_EXCEPT): Use it to exclude names on a per-rule basis.
+	(_sc_search_regexp): When not using VC_LIST_EXCEPT, exclude here, too.
+
+2011-03-13  Bruno Haible  <bruno@clisp.org>
+
+	ignore-value tests: Avoid warnings.
+	* tests/test-ignore-value.c (_GL_ATTRIBUTE_RETURN_CHECK): Define to
+	empty for gcc < 3.4.
+
+2011-03-13  Bruno Haible  <bruno@clisp.org>
+
+	passfd: Fix link error on Solaris.
+	* modules/passfd (Description): Correct.
+	(Depends-on): Add socketlib.
+	(Link): New section.
+	* modules/passfd-tests (Makefile.am): Link test-passfd with LIBSOCKET.
+
+2011-03-13  Bruno Haible  <bruno@clisp.org>
+
+	passfd: Fix link error on AIX 5.2.
+	* m4/afunix.m4 (gl_SOCKET_AFUNIX): Define _LINUX_SOURCE_COMPAT.
+
+2011-03-13  Bruno Haible  <bruno@clisp.org>
+
+	passfd: Work around bug with CMSG_FIRSTHDR on FreeBSD 6.4.
+	* lib/sys_socket.in.h: Include <stddef.h>.
+	* m4/afunix.m4 (gl_SOCKET_AFUNIX): Include <stddef.h> before using
+	CMSG_FIRSTHDR. Remove unused variable.
+
+2011-03-13  Bruno Haible  <bruno@clisp.org>
+
+	passfd: Fix compilation error on OpenBSD.
+	* lib/passfd.c: Include <sys/uio.h>.
+
+2011-03-13  Bruno Haible  <bruno@clisp.org>
+
+	passfd test: Fix warnings.
+	* tests/test-passfd.c: Include <sys/wait.h>.
+	(main): Fix typo.
+
+2011-03-13  Bruno Haible  <bruno@clisp.org>
+
+	passfd module, part 4, tweaks.
+	* tests/test-passfd.c: Reorder includes.
+	(main): Fix perror and printf calls.
+
+2011-03-07  Bastien Roucariès  <roucaries.bastien@gmail.com>
+
+	passfd module, part 4.
+	* modules/passfd-tests: New file.
+	* tests/test-passfd.c: New file.
+
+2011-03-13  Jim Meyering  <meyering@redhat.com>
+
+	Makefile: rely on GNU make; derive syntax-check rule names
+	Rather than requiring that each sc_ rule be listed as a dependent
+	of "check", use features of GNU make to derive the list.
+	* Makefile (syntax-check-rules): Define.
+	(check): Depend on the new variable, not the hard-coded list.
+
+2011-03-13  Bastien Roucariès  <roucaries.bastien@gmail.com>
+            Bruno Haible  <bruno@clisp.org>
+
+	passfd module, part 3.
+	* lib/passfd.h (recvfd): Add a flags argument.
+	* lib/passfd.c: Include <fcntl.h>, cloexec.h.
+	(recvfd): Add a flags argument.
+	* m4/afunix.m4 (gl_SOCKET_AFUNIX): Test whether MSG_CMSG_CLOEXEC
+	exists.
+	* modules/passfd (Depends-on): Add cloexec.
+	Suggested by Eric Blake.
+
+2011-03-13  Bruno Haible  <bruno@clisp.org>
+
+	passfd module, part 2, tweaks.
+	* modules/passfd (Files): Reorder.
+	(Depends-on): Remove errno.
+	(Include): Remove <sys/socket.h>, <sys/un.h>.
+	* lib/passfd.h: Use a GPLv3+ header. Make C++ safe.
+	* lib/passfd.c: Untabify. Use a GPLv3+ header. Really include the
+	specification header. Include <sys/socket.h> always. Don't include
+	<winsock2.h>. Use "#if HAVE_..." instead of "#ifdef HAVE_...".
+	(sendfd): Clarify that it sets errno when it fails.
+	(recvfd): Fix specification.
+
+2011-03-07  Bastien Roucariès  <roucaries.bastien@gmail.com>
+
+	passfd module, part 2.
+	* modules/passfd: New file.
+	* lib/passfd.h: New file.
+	* lib/passfd.c: New file.
+
+2011-03-12  Bruno Haible  <bruno@clisp.org>
+
+	wcswidth, mbswidth: Avoid integer overflow.
+	* lib/wcswidth.c: Include <limits.h>.
+	* lib/wcswidth-impl.h (wcswidth): Avoid 'int' overflow.
+	* lib/mbswidth.c: Include <limits.h>.
+	(mbsnwidth): Avoid 'int' overflow.
+	Reported by Jim Meyering.
+
+2011-03-12  Bruno Haible  <bruno@clisp.org>
+
+	futimens, utimensat: Avoid endless recursion on Solaris 10.
+	* lib/sys_stat.in.h (futimens, utimensat): Define with rpl_ prefix on
+	Solaris.
+	Reported by Ben Walton <bwalton@artsci.utoronto.ca> via Eric Blake
+	in <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=8230>.
+
+2011-03-11  Jim Meyering  <meyering@redhat.com>
+
+	maint.mk: relax a regexp to accommodate other formatting styles
+	* top/maint.mk (sc_unmarked_diagnostics): Allow 0 or 1 space
+	between "ngettext" and the following "(".
+
+2011-03-11  Pádraig Brady <P@draigBrady.com>
+
+	maint.mk: suppress a false positive warning
+	* top/maint.mk ((sc_unmarked_diagnostics): Don't warn when
+	diagnostics are marked with ngettext.
+
+2011-03-10  Eric Blake  <eblake@redhat.com>
+
+	wchar: add explicit dependencies, for Tru64
+	* modules/mbmemcasecoll (Depends-on): Add wchar.
+	* modules/mbtowc (Depends-on): Likewise.
+	* modules/vasnprintf (Depends-on): Likewise.
+	* modules/unistdio/u-printf-args (Depends-on): Likewise.
+	* modules/wctomb (Depends-on): Likewise.
+	Reported by Peter O'Gorman.
+
+2011-03-08  Bruno Haible  <bruno@clisp.org>
+
+	passfd module, part 1, tweaks.
+	* m4/afunix.m4 (gl_SOCKET_AFUNIX): Update AC_REQUIRE invocation.
+	Improve indentation. Improve AC_MSG_CHECKING messages.
+	* m4/sockpfaf.m4 (gl_SOCKET_FAMILY_UNIX): New macro, extracted from
+	gl_SOCKET_FAMILIES.
+
+2011-03-07  Bastien Roucariès  <roucaries.bastien@gmail.com>
+
+	passfd module, part 1.
+	* m4/afunix.m4: New file.
+	* m4/sockpfaf.m4 (gl_SOCKET_FAMILIES): Also test for UNIX domain
+	sockets.
+
+2011-03-08  Bruno Haible  <bruno@clisp.org>
+
+	regex-quote: New API.
+	* lib/regex-quote.h: Include <stdbool.h>.
+	(struct regex_quote_spec): New type.
+	(regex_quote_spec_posix, regex_quote_spec_gnu, regex_quote_spec_pcre):
+	New declarations.
+	(regex_quote_length, regex_quote_copy, regex_quote): Take a
+	'const struct regex_quote_spec *' argument.
+	* lib/regex-quote.c (RE_*, PCRE_*): New macros.
+	(pcre_special): New constant.
+	(regex_quote_spec_posix, regex_quote_spec_gnu, regex_quote_spec_pcre):
+	New functions.
+	(regex_quote_length, regex_quote_copy, regex_quote): Take a
+	'const struct regex_quote_spec *' argument.
+	* modules/regex-quote (Depends-on): Add stdbool.
+	* tests/test-regex-quote.c (check): Update for new API. Add test for
+	anchored results.
+	* NEWS: Mention the API change.
+	Reported by Reuben Thomas and Eric Blake.
+
+2011-03-06  Bruno Haible  <bruno@clisp.org>
+
+	regex-quote: Fix creation of POSIX extended regular expressions.
+	* lib/regex-quote.c (ere_special): Add grouping and alternation
+	operators.
+
+2011-03-05  Bruno Haible  <bruno@clisp.org>
+
+	doc: Improve doc regarding autopoint vs. gnulib.
+	* doc/gnulib-tool.texi (gettextize and autopoint): Recommend to
+	disable autopoint while running autoreconf.
+	Suggested by Ralf Wildenhues.
+
+2011-03-05  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
+
+	Update AC_OPENMP macro for Lahey compiler on GNU/Linux.
+	* m4/openmp.m4 (AC_OPENMP): Sync from Autoconf.
+
+2011-03-03  Bruce Korb  <bkorb@gnu.org>
+
+	parse-duration: remove xalloc.h dependency
+	* lib/parse-duration.c (parse_period): handle NULL return from
+	strdup instead of calling xstrdup().
+	* modules/parse-duration: remove "xalloc" dependency
+
+2011-03-03  Matthew Booth  <mbooth@redhat.com>
+
+	bootstrap: honor m4_base when running aclocal
+	* build-aux/bootstrap: Fix hard-coded use of m4 directory name.
+
+2011-03-02  Jim Meyering  <meyering@redhat.com>
+
+	getopt-gnu: relax license from LGPLv3+ to LGPLv2+
+	* modules/getopt-gnu (License): Relax to LGPLv2+, for augeas,
+	on request from Matt Booth.
+
+2011-03-01  Eric Blake  <eblake@redhat.com>
+
+	test-link: work on Hurd
+	* tests/test-link.h (test_link): Hurd rejects linking directories
+	with EISDIR instead of the POSIX-mandated EPERM.
+
+2011-02-28  Paul Eggert  <eggert@cs.ucla.edu>
+
+	stdio: simplify by moving files to printf-posix, sigpipe
+	* m4/stdio_h.m4 (gl_STDIO_H): Do not require gl_ASM_SYMBOL_PREFIX,
+	since this symbol is needed only if printf is replaced.
+	* m4/printf-posix-rpl.m4 (gl_REPLACE_PRINTF):
+	Require gl_ASM_SYMBOL_PREFIX.
+	* modules/printf-posix (Files): Add m4/asm-underscore.m4.
+	* modules/sigpipe (Files): Likewise.  Also, add m4/stdio-write.c.
+	(Depends-on): Add 'raise'.
+	(configure.ac): Require gl_ASM_SYMBOL_PREFIX.
+	* modules/stdio (Files): Remove lib/stdio-write.c,
+	m4/asm-underscore.m4.
+	(Depends-on): Remove 'raise'.
+
+	stdio: simplify by moving gl_STDIN_LARGE_OFFSET to fseeko, ftello
+	* m4/fseeko.m4 (gl_STDIN_LARGE_OFFSET): Moved here, from ...
+	* m4/stdio_h.m4 (gl_STDIN_LARGE_OFFSET): ... here, because
+	* modules/ftello (Files): Add m4/fseeko.m4, for gl_STDIN_LARGE_OFFSET.
+
+2011-02-28  Bruno Haible  <bruno@clisp.org>
+
+	localcharset: Assume ANSI C behaviour of free().
+	* lib/localcharset.c (get_charset_aliases): Remove NULL test before
+	calling free().
+	Suggested by Simon Josefsson <simon@josefsson.org>.
+
+2011-02-28  Corinna Vinschen  <vinschen@redhat.com>  (tiny change)
+            Charles Wilson  <cygwin@cwilson.fastmail.fm>  (tiny change)
+            Bruno Haible  <bruno@clisp.org>  (tiny change)
+
+	On Cygwin, use /proc file system instead of win32 API.
+	* lib/relocatable.c: On Cygwin, use file names from /proc, rather than
+	Win32 file names.
+	(DllMain): Simplify by removing Cygwin specific code.
+	(find_shared_library_fullname): Use Linux specific implementation also
+	for Cygwin.
+	(get_shared_library_fullname): Update accordingly.
+	* lib/progreloc.c: On Cygwin, use file names from /proc, rather than
+	Win32 file names.
+	(find_executable): On Cygwin, use /proc, like on Linux. Remove previous
+	Cygwin specific code.
+
+2011-02-28  Christian Rössel  <christian.roessel@gmx.de>  (tiny change)
+	    Markus Geimer  <m.geimer@fz-juelich.de>  (tiny change)
+
+	Fix OpenMP flag detection for various Fortran compilers.
+	* m4/openmp.m4 (_AC_LANG_OPENMP(Fortran 77)): Use '!$'
+	OpenMP-conditional compilation construct, to force compile
+	failure with missing OpenMP flag.
+	(AC_OPENMP): Add flags for Cray CCE and NEC SX compilers.
+
+2011-02-25  Eric Blake  <eblake@redhat.com>
+
+	strstr: expand test coverage
+	* tests/test-strstr.c (main): Add much shorter trigger.  Fix C89
+	compilation.
+	* tests/test-memmem.c (main): Duplicate tests.
+	* tests/test-strcasestr.c (main): Likewise.
+	* tests/test-c-strcasestr.c (main): Likewise.
+
+2011-02-25  Jim Meyering  <meyering@redhat.com>
+
+	maint.mk: detect missing-NL-at-EOF, too
+	* top/maint.mk (sc_prohibit_empty_lines_at_EOF): Adjust so that
+	it also detects when a file lacks a newline at EOF.
+	(require_exactly_one_NL_at_EOF_): Renamed from
+	detect_empty_lines_at_EOF_.  I opted not to rename the rule,
+	since people may well have .x-sc_... file names tied to the
+	existing name.  Suggested by Eric Blake.
+
+2011-02-25  Paul Eggert  <eggert@cs.ucla.edu>
+
+	dirname: move m4/dos.m4 functionality into lib/dosname.h
+
+	m4/dos.m4 needs to go.  It laboriously invokes the C compiler, and
+	extracts symbols from it, puts them into config.h; but it's much
+	easier to use the symbols directly.  filename.h already does this,
+	but it disagrees with dos.m4 in some respects.  This patch
+	introduces a different include file dosname.h that packages up
+	dos.m4, and then later we can work on merging filename.h and
+	dosname.h.  Applications that need only the easy-to-configure
+	symbols should consider including dosname.h rather than dirname.h.
+	* NEWS: Mention incompatible changes.
+	* m4/dos.m4: Remove.
+	* lib/dosname.h, modules/dosname: New files.
+	* lib/dirname.h (ISSLASH, FILE_SYSTEM_PREFIX_LEN):
+	(FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE):
+	(IS_ABSOLUTE_FILE_NAME, IS_RELATIVE_FILE_NAME): Move to lib/dosname.h.
+	* lib/at-func.c, lib/at-func2.c, lib/openat.c, lib/savewd.c:
+	Include dosname.h, not dirname.h.
+	* lib/rmdir.c, lib/stat.c, lib/unlink.c, lib/unlinkat.c:
+	Include dosname.h, for definitions of symbols like ISSLASH
+	that used to be in config.h.
+	* m4/dirname.m4 (gl_DIRNAME_LGPL): Do not require gl_AC_DOS.
+	* m4/rmdir.m4 (gl_FUNC_RMDIR): Likewise.
+	* m4/stat.m4 (gl_FUNC_STAT): Likewise.
+	* m4/unlink.m4 (gl_FUNC_UNLINK): Likewise.
+	* modules/dirname-lgpl (Files): Omit m4/dos.m4.
+	* modules/rmdir (Files): Likewise.
+	* modules/stat (Files): Likewise.
+	* modules/unlink (Files): Likewise.
+	* modules/dirname-lgpl (Depends-on): Add dosname.
+	* modules/lstat (Depends-on): Likewise.
+	* modules/openat (Depends-on): Likewise.
+	* modules/rmdir (Depends-on): Likewise.
+	* modules/savewd (Depends-on): Likewise.
+	* modules/stat (Depends-on): Likewise.
+	* modules/unlink (Depends-on): Likewise.
+	* modules/openat (Depends-on): Remove dirname-lgpl.
+	* modules/savewd (Depends-on): Likewise.
+	* tests/test-dirname.c: Do not use removed symbols like
+	FILE_SYSTEM_BACKSLASH_IS_FILE_NAME_SEPARATOR.  Instead, use
+	the remaining symbols, e.g., ISSLASH ('\\').
+
+2011-02-25  Eric Blake  <eblake@redhat.com>
+
+	strstr: revert patches that introduced bug and pessimization
+	* lib/str-two-way.h: Add another reference.
+	(two_way_short_needle, two_way_long_needle): Revert changes from
+	2011-02-24; they pessimize search speed.
+	(critical_factorization): Partially revert changes from
+	2010-06-22; they violate the requirement that the left half of the
+	needle be smaller than the period of the needle.
+
+2011-02-24  Paul Eggert  <eggert@cs.ucla.edu>
+
+	filenamecat: remove unnecessary dependency on dirname-lgpl
+	* modules/filenamecat (Depends-on): Remove dirname-lgpl, as there
+	is no direct dependency, just an indirect one via filenamecat-lgpl.
+
+	remove: remove unnecessary use of m4/dos.m4
+	* m4/remove.m4 (gl_FUNC_REMOVE): Don't require gl_AC_DOS; not needed.
+	* modules/remove (FILES): Remove m4/dos.m4.
+
+	* lib/openat-proc.c: Don't include dirname.h; not needed.
+
+	backupfile: remove unnecessary use of m4/dos.m4
+	* m4/backupfile.m4 (gl_BACKUPFILE): Don't require gl_AC_DOS; none
+	of its symbols are used by the backupfile code.  backupfile.c does
+	use a symbol HAVE_DOS_FILE_NAMES, but that symbol is meant only
+	for the rare case of programs that want all their backup file
+	names to live within 8+3 limits, and dos.m4 doesn't address that.
+	* modules/backupfile (Files): Remove m4/dos.m4.
+
+2011-02-24  Jim Meyering  <meyering@redhat.com>
+
+	strstr: fix a bug whereby strstr would mistakenly return NULL
+	* lib/str-two-way.h (two_way_short_needle): Correct off-by-one error
+	in period calculation.
+	(two_way_long_needle): Likewise.
+	The original problem was reported by Mike Stump in
+	http://thread.gmane.org/gmane.comp.sysutils.autoconf.bugs/7834
+	Ralf Wildenhues provided the short needle and haystack.
+	* tests/test-strstr.c: Add Ralf's test case to trigger the bug.
+	Add a more involved test to trigger the bug in two_way_long_needle.
+
+2011-02-24  Stefano Lattarini  <stefano.lattarini@gmail.com>  (tiny change)
+
+	gnulib-tool: remove use of bold display in help screen
+	* gnulib-tool (func_usage): Do not use bold display anymore in the
+	help screen.  That was just meant to be a temporary emphasis for a
+	backward-incompatible change.
+
+2011-02-23  Bruno Haible  <bruno@clisp.org>
+
+	Fix misindentation of preprocessor directives.
+	* lib/argp-namefrob.h: Reindent preprocessor directives.
+	* lib/getopt_int.h (struct _getopt_data): Likewise.
+	* lib/progreloc.c (maybe_executable, find_executable): Likewise.
+	* lib/vasnprintf.c (decode_long_double): Likewise.
+	* tests/test-argmatch.c: Insert blank lines, for clarity.
+	* tests/test-exclude.c: Likewise.
+
+2011-02-22  Bruno Haible  <bruno@clisp.org>
+
+	ioctl: Fix for MacOS X in 64-bit mode.
+	* lib/ioctl.c (rpl_ioctl): Zero-extend, not sign-extend, the request
+	value.
+	Suggested by Eric Blake.
+	Reported by Markus Gothe <nietzsche@lysator.liu.se>.
+
+2011-02-22  Jim Meyering  <meyering@redhat.com>
+
+	maint: sc_cpp_indent_check: remove the "only in lib/" restriction
+	* Makefile (sc_cpp_indent_check): Don't limit the check to files
+	in lib/.
+
+2011-02-22  Eric Blake  <eblake@redhat.com>
+
+	maint: avoid any CDPATH issue
+	* Makefile (sc_cpp_indent_check): Anchor cd argument.
+
+	maint: adjust cpp indentation for my modules, as well
+	* Makefile (sc_cpp_indent_check): Add my name.
+	* lib/fbufmode.c: Filter through cppi.
+	* lib/fpurge.c: Likewise.
+	* lib/freadable.c: Likewise.
+	* lib/freading.c: Likewise.
+	* lib/fwritable.c: Likewise.
+	* lib/fwriting.c: Likewise.
+	* lib/sigaction.c: Likewise.
+
+2011-02-22  Jim Meyering  <meyering@redhat.com>
+
+	maint: adjust cpp indentation to reflect nesting depth
+	I.e., in a block of code that begins with an unnested "#if",
+	put one space between the "#" in column 1 and following token.
+	For example,
+	-#include <sys/vfs.h>
+	+# include <sys/vfs.h>
+	Do this only in .c files that are part of a module I maintain.
+	* lib/linkat.c: Filter through cppi.
+	* lib/nanosleep.c: Likewise.
+	* lib/openat.c: Likewise.
+	* lib/openat-die.c: Likewise.
+	* lib/dup3.c: Likewise.
+	* lib/fchownat.c: Likewise.
+	* lib/flock.c: Likewise.
+	* lib/fsync.c: Likewise.
+	* lib/fts.c: Likewise.
+	* lib/getpass.c: Likewise.
+	* lib/gettimeofday.c: Likewise.
+	* lib/userspec.c: Likewise.
+	* Makefile (sc_cpp_indent_check): New rule, to check this.
+
+2011-02-22  Bruno Haible  <bruno@clisp.org>
+
+	New module 'wctomb'.
+	* lib/stdlib.in.h (wctomb): New declaration.
+	* lib/wctomb.c: New file.
+	* lib/wctomb-impl.h: New file.
+	* m4/wctomb.m4: New file.
+	* m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Initialize GNULIB_WCTOMB,
+	REPLACE_WCTOMB.
+	* modules/stdlib (Makefile.am): Substitute GNULIB_WCTOMB,
+	REPLACE_WCTOMB.
+	* modules/wctomb: New file.
+	* tests/test-stdlib-c++.cc: Test signature of wctomb.
+	* doc/posix-functions/wctomb.texi: Mention the new module.
+	* modules/wctob (Depends-on): Add wctomb.
+
+2011-02-22  Bruno Haible  <bruno@clisp.org>
+
+	New module 'mbtowc'.
+	* lib/stdlib.in.h (mbtowc): New declaration.
+	* lib/mbtowc.c: New file.
+	* lib/mbtowc-impl.h: New file, from libutf8 with modifications.
+	* m4/mbtowc.m4: New file.
+	* m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Initialize GNULIB_MBTOWC,
+	REPLACE_MBTOWC.
+	* modules/stdlib (Makefile.am): Substitute GNULIB_MBTOWC,
+	REPLACE_MBTOWC.
+	* modules/mbtowc: New file.
+	* tests/test-stdlib-c++.cc: Test signature of mbtowc.
+	* doc/posix-functions/mbtowc.texi: Mention the new module.
+	* modules/btowc (Depends-on): Add mbtowc.
+
+2011-02-22  Bruno Haible  <bruno@clisp.org>
+
+	wcrtomb: Add more tests for native Windows platforms.
+	* tests/test-wcrtomb-w32-1.sh: New file.
+	* tests/test-wcrtomb-w32-2.sh: New file.
+	* tests/test-wcrtomb-w32-3.sh: New file.
+	* tests/test-wcrtomb-w32-4.sh: New file.
+	* tests/test-wcrtomb-w32-5.sh: New file.
+	* tests/test-wcrtomb-w32.c: New file.
+	* modules/wcrtomb-tests (Files): Add them.
+	(Makefile.am): Arrange to run these tests.
+	* tests/test-wcrtomb-w32-6.sh: New file, currently unused.
+	* tests/test-wcrtomb-w32-7.sh: New file, currently unused.
+
+2011-02-20  Bruno Haible  <bruno@clisp.org>
+
+	wcrtomb: Enhance test.
+	* tests/test-wcrtomb.c (main): Add test against bug with NULL argument.
+
+2011-02-20  Bruno Haible  <bruno@clisp.org>
+
+	mbrtowc: Tiny optimization.
+	* lib/mbrtowc.c (mbrtowc): Delay pstate assignment until it is needed.
+
+2011-02-20  Jim Meyering  <meyering@redhat.com>
+
+	test-exclude.c: remove unmatched #endif
+	* tests/test-exclude.c: Remove stray #endif, left over from
+	the change of a week ago.
+
+2011-02-19  Jim Meyering  <meyering@redhat.com>
+
+	git-version-gen: skip "-dirty" check when appropriate
+	* build-aux/git-version-gen: Don't run any git commands when the
+	version string comes from .tarball-version.  Prior to this, we
+	would run git update-index --refresh even from a just-unpacked
+	tarball directory, and that could affect a .git/ directory in a
+	parent of the build directory.  Reported by Mike Frysinger.
+
+2011-02-19  Bruno Haible  <bruno@clisp.org>
+
+	unictype/property-byname: Reduce the size of the 'data' segment.
+	* lib/unictype/pr_byname.gperf: Add gperf option '%pic'.
+
+2011-02-19  Bruno Haible  <bruno@clisp.org>
+
+	unictype/scripts: Reduce the size of the 'data' segment.
+	* lib/gen-uni-tables.c (output_scripts_byname): Emit gperf option
+	'%pic'.
+	* lib/unictype/scripts_byname.gperf: Regenerated.
+
+2011-02-19  Bruno Haible  <bruno@clisp.org>
+
+	stdint: Update documentation.
+	* doc/posix-headers/stdint.texi: Mention WCHAR_MIN, WCHAR_MAX problem.
+
+2011-02-18  Paul Eggert  <eggert@cs.ucla.edu>
+
+	stdint: omit redundant check for wchar.h
+	* m4/stdint.m4 (gl_STDINT_H): The earlier part of this macro now
+	always tests whether wchar.h exists, so remove the now-redundant test.
+
+2011-02-18  Bruno Haible  <bruno@clisp.org>
+
+	stdint: Cut dependency to module 'wchar'.
+	* lib/stdint.in.h: Include wchar.h only when HAVE_WCHAR_H is 1. Also
+	include the necessary prerequisites.
+	* m4/stdint.m4 (gl_STDINT_H): Test whether wchar.h exists.
+	* modules/stdint (Depends-on): Remove wchar.
+	(Makefile.am): Substitute HAVE_WCHAR_H.
+	This reverts part of a 2007-01-06 commit. Reported by Paul Eggert.
+
+2011-02-18  Eric Blake  <eblake@redhat.com>
+
+	longlong: skip, rather than fail, on cross-compilation
+	* m4/longlong.m4 (AC_TYPE_LONG_LONG_INT): Avoid aborting configure
+	when cross-compiling; regression from 2011-02-16.
+
+2011-02-17  Paul Eggert  <eggert@cs.ucla.edu>
+
+	* NEWS: Mention 2011-02-08 change to stdlib.
+
+2011-02-17  Bruno Haible  <bruno@clisp.org>
+
+	getloadavg: Add comments about platforms.
+	* m4/getloadavg.m4: Add comment.
+	* lib/getloadavg.c: Likewise.
+
+2011-02-17  Bruno Haible  <bruno@clisp.org>
+
+	getloadavg: Fix link error on Solaris 2.6.
+	* modules/getloadavg (Link): New section.
+	* modules/getloadavg-tests (Makefile.am): Use GETLOADAVG_LIBS for
+	linking test-getloadavg.
+	* doc/glibc-functions/getloadavg.texi: Mention that Solaris 2.6 lacks
+	getloadavg.
+
+2011-02-17  Paul Eggert  <eggert@cs.ucla.edu>
+
+	* lib/getloadavg.c (getloadavg) [sgi]: Make ldav_off of type ptrdiff_t.
+	It was 'int', but this doesn't match the IRIX 6.5 manual.
+	Suggested by Bruno Haible in
+	<http://lists.gnu.org/archive/html/bug-gnulib/2011-02/msg00207.html>.
+
+2011-02-17  Bruno Haible  <bruno@clisp.org>
+
+	havelib: Fix comments.
+	* m4/lib-link.m4 (AC_LIB_RPATH): Update comments after 2007-01-02
+	change.
+
+2011-02-17  Bruno Haible  <bruno@clisp.org>
+
+	havelib: Update config.rpath.
+	* build-aux/config.rpath: Update to match libtool.m4 from libtool-2.4.
+
+2011-02-17  Bruno Haible  <bruno@clisp.org>
+
+	getloadavg test: Add some plausibility checks.
+	* tests/test-getloadavg.c (check_avg): Print a warning when the value
+	is improbable.
+
+2011-02-16  Eric Blake  <eblake@redhat.com>
+
+	maintainer-makefile: make syntax-check a no-op from tarballs
+	* top/maint.mk (no-vc-detected): New rule.
+	(local-checks-available): Use it to avoid hanging if someone tries
+	'make syntax-check' from a tarball.  Also append to any non-syntax
+	checks already defined in cfg.mk.
+
+2011-02-16  Paul Eggert  <eggert@cs.ucla.edu>
+
+	longlong: tune, particularly for common case of c99
+
+	* m4/longlong.m4 (AC_TYPE_LONG_LONG_INT): Don't bother compiling
+	or running anything if c99, or if unsigned long long int does not
+	work.  In either case, we know the answer without further tests.
+	Do not compile _AC_TYPE_LONG_LONG_SNIPPET twice.  Instead, compile
+	it at most once, and use its results for both long long int and
+	unsigned long long int.  This is more likely to be efficient in
+	the common case where the program wants to check for both long
+	long int and unsigned long long int.
+	(AC_TYPE_UNSIGNED_LONG_LONG_INT): Don't bother compiling if c99,
+	since the answer is already known.
+
+2011-02-15  Paul Eggert  <eggert@cs.ucla.edu>
+
+	getloadavg: set errno
+	* lib/getloadavg.c: Set errno when returning -1.  If no other
+	error number looks appropriate, set it to ENOSYS if the getloadavg
+	looks like it can't possibly ever work, ENOTSUP otherwise.
+	Suggested by Bruno Haible in
+	<http://lists.gnu.org/archive/html/bug-gnulib/2011-02/msg00187.html>.
+
+	getloadavg: trim unused parts and speed up 'configure'
+	* NEWS: Document this.
+	* lib/getloadavg.c: Ignore HAVE_GETLOADAVG; this file is now
+	always compiled if getloadavg is absent.
+	Move test code to ...
+	* tests/test-getloadavg.c: New file, containing previous
+	contents of test from lib/getloadavg.c.  It also contains
+	suggestions by Bruno Haible in
+	<http://lists.gnu.org/archive/html/bug-gnulib/2011-02/msg00186.html>.
+	* modules/getloadavg-tests: New file.
+	* m4/getloadavg.m4 (gl_GETLOADAVG): Do not check for getloadavg twice.
+	Do tests in the same order as they're needed for getloadavg.c.
+	Omit setgid-related tests that generate symbols KMEM_GROUP,
+	NEET_SETGID, GETLOADAVG_PRIVILEGED; nobody seems to use those any more.
+	Do only the tests that are needed to see whether the system has
+	getloadavg, moving the other tests into ...
+	(gl_PREREQ_GETLOADAVG): ... here.  Do not define obsolete symbol
+	NLIST_NAME_UNION; nobody should be using it.  Do not define
+	symbols C_GETLOADAVG and HAVE_GETLOADAVG; they're no longer
+	relevant, as the user of this module shouldn't care how getloadavg
+	is implemented.
+
+	getloadavg: omit unused var
+	* lib/getloadavg.c (getloadavg): Omit unused local variable.
+
+2011-02-15  Jim Meyering  <meyering@redhat.com>
+
+	doc: update users.txt
+	* users.txt: Update iwhd's URL.
+
+2011-02-13  Bruno Haible  <bruno@clisp.org>
+
+	Consistent macro naming for macros that use GCC __attribute__.
+	* lib/di-set.h (_GL_ATTRIBUTE_NONNULL): Renamed from
+	_ATTRIBUTE_NONNULL_.
+	* lib/ino-map.h (_GL_ATTRIBUTE_NONNULL): Likewise.
+	* lib/hash.h (_GL_ATTRIBUTE_WUR): Renamed from ATTRIBUTE_WUR.
+	* lib/ignore-value.h (_GL_ATTRIBUTE_DEPRECATED): Renamed from
+	ATTRIBUTE_DEPRECATED.
+	* lib/openat.h (_GL_ATTRIBUTE_NORETURN): Renamed from
+	ATTRIBUTE_NORETURN.
+	* lib/sigpipe-die.h (_GL_ATTRIBUTE_NORETURN): Likewise.
+	* lib/xmemdup0.h (_GL_ATTRIBUTE_NORETURN): Likewise.
+	* lib/xstrtol.h (_GL_ATTRIBUTE_NORETURN): Likewise.
+	* lib/xalloc.h (_GL_ATTRIBUTE_NORETURN): Likewise.
+	(_GL_ATTRIBUTE_MALLOC): Renamed from ATTRIBUTE_MALLOC.
+	(_GL_ATTRIBUTE_ALLOC_SIZE): Renamed from ATTRIBUTE_ALLOC_SIZE.
+	* lib/version-etc.h (_GL_ATTRIBUTE_SENTINEL): Renamed from
+	ATTRIBUTE_SENTINEL.
+	* lib/safe-alloc.h (_GL_ATTRIBUTE_RETURN_CHECK): Renamed from
+	ATTRIBUTE_RETURN_CHECK.
+	* tests/test-ignore-value.c (_GL_ATTRIBUTE_RETURN_CHECK): Likewise.
+	* tests/test-argmatch.c (_GL_ATTRIBUTE_NORETURN): Renamed from
+	ATTRIBUTE_NORETURN.
+	* tests/test-exclude.c (_GL_ATTRIBUTE_NORETURN): Likewise.
+	Reported by Paul Eggert.
+
+2011-02-13  Bruno Haible  <bruno@clisp.org>
+
+	Don't interfere with a program's definition of __attribute__.
+	* lib/argp.h (__attribute__): Remove definition.
+	(_GL_ATTRIBUTE_FORMAT): New macro.
+	(argp_error, __argp_error, argp_failure, __argp_failure): Use it.
+	* lib/argp-fmtstream.h (__attribute__): Remove definition.
+	(_GL_ATTRIBUTE_FORMAT): New macro.
+	(__argp_fmtstream_printf, argp_fmtstream_printf): Use it.
+	* lib/argp-help.c (hol_entry_long_iterate): Use __attribute__ only for
+	GCC 3 or newer.
+	* lib/error.h (__attribute__): Remove definition.
+	(_GL_ATTRIBUTE_FORMAT): New macro.
+	(error, error_at_line): Use it.
+	* lib/hash.h (__attribute__): Remove definition.
+	(ATTRIBUTE_WUR): Update definition. Define always.
+	* lib/openat.h (__attribute__): Remove definition.
+	(ATTRIBUTE_NORETURN): Update definition. Define always.
+	* lib/sigpipe-die.h (__attribute__): Remove definition.
+	(ATTRIBUTE_NORETURN): Update definition. Define always.
+	* lib/vasnprintf.h (__attribute__): Remove definition.
+	(_GL_ATTRIBUTE_FORMAT): New macro.
+	(asnprintf, vasnprintf): Use it.
+	* lib/xalloc.h (__attribute__): Remove definition.
+	(ATTRIBUTE_NORETURN): Update definition. Define always.
+	(ATTRIBUTE_MALLOC, ATTRIBUTE_ALLOC_SIZE): Define always.
+	* lib/xmemdup0.h (__attribute__): Remove definition.
+	(ATTRIBUTE_NORETURN): Update definition. Define always.
+	* lib/xprintf.h (__attribute__): Remove definition.
+	(_GL_ATTRIBUTE_FORMAT): New macro.
+	(xprintf, xvprintf, xfprintf, xvfprintf): Use it.
+	* lib/xstrtol.h (__attribute__): Remove definition.
+	(ATTRIBUTE_NORETURN): Update definition. Define always.
+	* lib/xvasprintf.h (__attribute__): Remove definition.
+	(_GL_ATTRIBUTE_FORMAT): New macro.
+	(xasprintf, xvasprintf): Use it.
+	* tests/test-argmatch.c (__attribute__): Remove definition.
+	(ATTRIBUTE_NORETURN): Update definition. Define always.
+	* tests/test-exclude.c (__attribute__): Remove definition.
+	(ATTRIBUTE_NORETURN): Update definition. Define always.
+	Reported by Paul Eggert.
+
+2011-02-13  Bruno Haible  <bruno@clisp.org>
+
+	mbrtowc: Add more tests for native Windows platforms.
+	* tests/test-mbrtowc-w32-1.sh: New file.
+	* tests/test-mbrtowc-w32-2.sh: New file.
+	* tests/test-mbrtowc-w32-3.sh: New file.
+	* tests/test-mbrtowc-w32-4.sh: New file.
+	* tests/test-mbrtowc-w32-5.sh: New file.
+	* tests/test-mbrtowc-w32.c: New file.
+	* modules/mbrtowc-tests (Files): Add them.
+	(Makefile.am): Arrange to run these tests.
+	* tests/test-mbrtowc-w32-6.sh: New file, currently unused.
+	* tests/test-mbrtowc-w32-7.sh: New file, currently unused.
+
+2011-02-13  Bruno Haible  <bruno@clisp.org>
+
+	mbrtowc: Work around native Windows bug.
+	* m4/mbrtowc.m4 (gl_MBRTOWC_RETVAL): Detect native Windows bug. Use the
+	guess when no suitable locale for testing was found.
+	* doc/posix-functions/mbrtowc.texi: Mention the native Windows bug.
+
+2011-02-13  Bruno Haible  <bruno@clisp.org>
+
+	mbsinit: Work around mingw bug.
+	* m4/mbsinit.m4 (gl_FUNC_MBSINIT): Replace mbsinit also on mingw.
+	* lib/mbsinit.c (mbsinit): Provide an alternate definition for native
+	Windows.
+	* doc/posix-functions/mbsinit.texi: Mention the mingw bug.
+
+2011-02-13  Bruno Haible  <bruno@clisp.org>
+
+	mbsinit: Don't crash for a NULL argument.
+	* lib/mbsinit.c (mbsinit): When the argument is NULL, return 1.
+	* tests/test-mbsinit.c (mbsinit): Check this behaviour.
+
+2011-02-13  Bruno Haible  <bruno@clisp.org>
+
+	Don't interfere with a program's definition of __attribute__.
+	* lib/stdio.in.h (__attribute__): Remove definition.
+	(_GL_ATTRIBUTE_FORMAT, _GL_ATTRIBUTE_FORMAT_PRINTF): New macros.
+	(dprintf, fprintf, obstack_printf, obstack_printf, obstack_vprintf,
+	printf, snprintf, sprintf, asprintf, vasprintf, vdprintf, vfprintf,
+	vsnprintf, vsprintf): Use _GL_ATTRIBUTE_FORMAT_PRINTF.
+	* lib/string.in.h (__attribute__): Remove definition.
+	Reported by Paul Eggert.
+
+2011-02-12  Paul Eggert  <eggert@cs.ucla.edu>
+
+	stdlib: don't get in the way of non-GCC __attribute__
+	See thread starting at
+	<http://lists.gnu.org/archive/html/bug-gnulib/2011-02/msg00161.html>.
+	Revert previous stdlib change, installing the following instead:
+	* lib/stdlib.in.h (__attribute__): Remove.  We do not want
+	to get in the way of a non-GCC compiler that supports __attribute__.
+	(_GL_ATTRIBUTE_RETURN): New macro.
+	(_Exit): Use it instead of __attribute__.
+
+2011-02-12  Bruno Haible  <bruno@clisp.org>
+
+	quotearg test: Avoid test failure on mingw.
+	* tests/test-quotearg.sh: Convert the locale identifier from native
+	Windows syntax to Unix syntax.
+
+2011-02-12  Bruno Haible  <bruno@clisp.org>
+
+	setlocale: Prefer gnulib's override over libintl's override.
+	* lib/locale.in.h (GNULIB_defined_setlocale): New macro.
+	* lib/gettext.h (setlocale): Redefine to rpl_setlocale if
+	GNULIB_defined_setlocale is set.
+
+2011-02-12  Paul Eggert  <eggert@cs.ucla.edu>
+
+	stdlib: support non-GCC __attribute__
+
+	Fix a serious and tricky problem encountered when attempting to
+	add the getloadavg module to Emacs.  Emacs worked fine on RHEL
+	5.5, but it crashed due to memory corruption on Solaris 10 with
+	Sun C 5.11.  Emacs normally ORs 3-bit tags into their low-order
+	bits that are otherwise zero.  This tagging is optional inside
+	Emacs but is preferred and is used when __attribute__ ((__aligned
+	(8))) works, as it does with both recent-enough GCC and with Sun C
+	5.11.  However, Sun C 5.11 is not GCC and does not #define
+	__GNUC__ and __GNUC_MINOR__.
+
+	When I added the getloadavg module to Emacs, it brought in
+	stdlib.in.h, which contained this fragment:
+
+	   #ifndef __attribute__
+	   # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
+	   #  define __attribute__(Spec)   /* empty */
+	   # endif
+	   #endif
+
+	When files that include <stdlib.h> were compiled with Sun C 5.11,
+	the above code disabled __attribute__ ((__aligned (8))), which
+	caused variables to not be properly aligned, which eventually led
+	to the pointer corruption mentioned above.  (This was a bit hard
+	to diagnose, unfortunately.)
+
+	Several "#define __attribute__(X) /* empty */" code snippets need
+	to be eradicated from Gnulib to work with non-GCC compilers that
+	support __attribute__.  The Autoconf way to do this is to test for
+	each kind of attribute that we want support for, and selectively
+	enable that in source code.
+
+	Fix this problem just for stdlib.h, by adding a test for the
+	__noreturn__ attribute, and change stdlib.in.h to use that test
+	when needed.  This technique can be easily generalized to the
+	other *.in.h files and attributes, and a similar technique can be
+	used for *.h and *.c files.  This patch is enough to solve the
+	problem for Emacs + getloadavg, and I thought I'd publish it for
+	feedback before undertaking further, similar fixes in other
+	modules.
+
+	This patch does not arrange to #define HAVE_ATTRIBUTE_NORETURN
+	because it's not needed for stdlib.h.  It merely substitutes the
+	value directly into stdlib.h.  We may well need to #define it, or
+	similar symbols, for other modules, but it's nice to also have an
+	option to not #define it for applications like Emacs that do not
+	need it.
+
+	* lib/stdlib.in.h (__attribute__): Do not #define.
+	(_GL_ATTRIBUTE_NORETURN): New macro, which in stdlib.h needs to
+	be defined only if the _Exit module is also used.
+	* m4/_Exit.m4 (gl_FUNC__EXIT): Require gl_ATTRIBUTE_NORETURN.
+	* m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Subst
+	HAVE_ATTRIBUTE_NORETURN and default it to 1, its value on GNU
+	platforms.
+	* modules/_Exit (Files): Add m4/attribute.m4.
+	* modules/stdlib (Makefile.am): Substitute HAVE_ATTRIBUTE_NORETURN.
+	* m4/attribute.m4: New file.
+
+2011-02-12  Bruno Haible  <bruno@clisp.org>
+
+	wcsrtombs: Work around bug on native Windows.
+	* m4/wcsrtombs.m4 (gl_WCSRTOMBS_NULL): Test against mingw bug.
+	* lib/wcsrtombs.c (rpl_wcsrtombs): When dest is NULL, pass SIZE_MAX
+	instead of len.
+	* doc/posix-functions/wcsrtombs.texi: Document mingw bug.
+
+2011-02-12  Bruno Haible  <bruno@clisp.org>
+
+	mbsrtowcs: Work around bug on native Windows.
+	* m4/mbsrtowcs.m4 (gl_MBSRTOWCS_WORKS): Require gt_LOCALE_FR. Test
+	against mingw bug.
+	* doc/posix-functions/mbsrtowcs.texi: Document mingw bug.
+
+2011-02-12  Bruno Haible  <bruno@clisp.org>
+
+	Avoid setlocale bugs in tests.
+	* modules/btowc (Dependencies): Add setlocale.
+	* modules/c-strcase (Dependencies): Likewise.
+	* modules/mbmemcasecmp (Dependencies): Likewise.
+	* modules/mbmemcasecoll (Dependencies): Likewise.
+	* modules/mbrtowc (Dependencies): Likewise.
+	* modules/mbscasecmp (Dependencies): Likewise.
+	* modules/mbscasestr (Dependencies): Likewise.
+	* modules/mbschr (Dependencies): Likewise.
+	* modules/mbscspn (Dependencies): Likewise.
+	* modules/mbsinit (Dependencies): Likewise.
+	* modules/mbsncasecmp (Dependencies): Likewise.
+	* modules/mbsnrtowcs (Dependencies): Likewise.
+	* modules/mbspbrk (Dependencies): Likewise.
+	* modules/mbspcasecmp (Dependencies): Likewise.
+	* modules/mbsrchr (Dependencies): Likewise.
+	* modules/mbsrtowcs (Dependencies): Likewise.
+	* modules/mbsspn (Dependencies): Likewise.
+	* modules/mbsstr (Dependencies): Likewise.
+	* modules/nl_langinfo (Dependencies): Likewise.
+	* modules/quotearg (Dependencies): Likewise.
+	* modules/unicase/locale-language (Dependencies): Likewise.
+	* modules/unicase/ulc-casecmp (Dependencies): Likewise.
+	* modules/unicase/ulc-casecoll (Dependencies): Likewise.
+	* modules/unigbrk/ulc-grapheme-breaks (Dependencies): Likewise.
+	* modules/unistdio/u8-vasnprintf (Dependencies): Likewise.
+	* modules/unistdio/u16-vasnprintf (Dependencies): Likewise.
+	* modules/unistdio/u32-vasnprintf (Dependencies): Likewise.
+	* modules/unistdio/ulc-vasnprintf (Dependencies): Likewise.
+	* modules/uniwbrk/ulc-wordbreaks (Dependencies): Likewise.
+	* modules/vasnprintf-posix (Dependencies): Likewise.
+	* modules/wcrtomb (Dependencies): Likewise.
+	* modules/wcsnrtombs (Dependencies): Likewise.
+	* modules/wcsrtombs (Dependencies): Likewise.
+
+2011-02-12  Bruno Haible  <bruno@clisp.org>
+
+	setlocale: Workaround native Windows bug.
+	* lib/setlocale.c (rpl_setlocale): On native Windows, when setlocale
+	succeeds but sets LC_CTYPE to "C", report a failure.
+	* tests/test-setlocale2.sh: New file.
+	* tests/test-setlocale2.c: New file.
+	* modules/setlocale-tests (Files): Add the new files.
+	(Makefile.am): Enable test-setlocale2.sh test.
+	* doc/posix-functions/setlocale.texi: Mention workaround.
+
+2011-02-11  Bruno Haible  <bruno@clisp.org>
+
+	Tests for module 'setlocale'.
+	* modules/setlocale-tests: New file.
+	* tests/test-setlocale1.sh: New file.
+	* tests/test-setlocale1.c: New file.
+
+	New module 'setlocale'.
+	* lib/locale.in.h (setlocale): New declaration.
+	* lib/setlocale.c: New file, based on
+	gettext/gettext-runtime/intl/setlocale.c.
+	* m4/setlocale.m4: New file.
+	* m4/locale_h.m4 (gl_LOCALE_H): Test whether setlocale is declared.
+	(gl_LOCALE_H_DEFAULTS): Initialize GNULIB_SETLOCALE, REPLACE_SETLOCALE.
+	* modules/locale (Makefile.am): Substitute GNULIB_SETLOCALE,
+	REPLACE_SETLOCALE.
+	* modules/setlocale: New file.
+	* tests/test-locale-c++.cc: Test the declaration of setlocale.
+	* doc/posix-functions/setlocale.texi: Mention the new module.
+
+2011-02-11  Bruno Haible  <bruno@clisp.org>
+
+	Prepare for locale dependent tests on mingw.
+	* m4/locale-ar.m4 (gt_LOCALE_AR): On native Windows, don't try "ar"
+	because it has the wrong locale encoding.
+	* m4/locale-fr.m4 (gt_LOCALE_FR): On native Windows, try
+	French_France.1252 instead of "fr".
+	(gt_LOCALE_FR_UTF8): On native Windows, try French_France.65001.
+	* m4/locale-ja.m4 (gt_LOCALE_JA): On native Windows, don't try "ja"
+	because it has the wrong locale encoding.
+	* m4/locale-tr.m4 (gt_LOCALE_TR_UTF8): Require AC_CANONICAL_HOST. On
+	native Windows, try Turkish_Turkey.65001.
+	* m4/locale-zh.m4 (gt_LOCALE_ZH_CN): On native Windows, try
+	Chinese_China.54936.
+
+	Prepare for locale dependent tests on mingw.
+	* m4/locale-ar.m4 (gt_LOCALE_AR): On native Windows, call setlocale
+	differently.
+	* m4/locale-fr.m4 (gt_LOCALE_FR, gt_LOCALE_FR_UTF8): Likewise.
+	* m4/locale-ja.m4 (gt_LOCALE_JA): Likewise.
+	* m4/locale-tr.m4 (gt_LOCALE_TR_UTF8): Likewise.
+	* m4/locale-zh.m4 (gt_LOCALE_ZH_CN): Likewise.
+
+2011-02-11  Eric Blake  <eblake@redhat.com>
+
+	strptime: avoid compiler warnings
+	* lib/strptime.c (__strptime_internal) [!_NL_CURRENT]: Avoid
+	compiler warnings about dead code.
+	Reported by Daniel P. Berrange.
+
+2011-02-11  Thien-Thi Nguyen  <ttn@gnuvola.org>
+
+	doc: update users.txt
+	* users.txt: Add rcs.
+
+2011-02-10  John W. Eaton  <jwe@gnu.org>
+
+	doc: update users.txt
+	* users.txt: Add octave.
+
+2011-02-10  Jim Meyering  <meyering@redhat.com>
+
+	doc: update users.txt
+	* users.txt: Add iwhd.
+
+2011-02-09  Bruno Haible  <bruno@clisp.org>
+
+	gnulib-tool: Make copyright notice adjustment more robust.
+	* gnulib-tool (func_import): In sed_transform_main_lib_file,
+	sed_transform_build_aux_file, sed_transform_testsrelated_lib_file,
+	allow a line break to occur after "GNU" in "GNU [Lesser] General Public
+	License".
+	Reported by Glenn Morris <rgm@gnu.org> via Paul Eggert.
+
+2011-02-06  Bruno Haible  <bruno@clisp.org>
+
+	New module 'towctrans'.
+	* modules/towctrans: New file.
+	* lib/wctype.in.h (towctrans): New declaration.
+	* lib/towctrans.c: New file.
+	* lib/towctrans-impl.h: New file.
+	* m4/towctrans.m4: New file.
+	* m4/wctype_h.m4 (gl_WCTYPE_H): Test whether towctrans is declared.
+	(gl_WCTYPE_H_DEFAULTS): Initialize GNULIB_TOWCTRANS.
+	* modules/wctype-h (Makefile.am): Substitute GNULIB_TOWCTRANS.
+	* tests/test-wctype-h-c++.cc: Test the declaration of towctrans.
+	* doc/posix-functions/towctrans.texi: Mention the new module.
+
+2011-02-06  Bruno Haible  <bruno@clisp.org>
+
+	New module 'wctrans'.
+	* modules/wctrans: New file.
+	* lib/wctype.in.h (wctrans): New declaration.
+	* lib/wctrans.c: New file.
+	* lib/wctrans-impl.h: New file.
+	* m4/wctrans.m4: New file.
+	* m4/wctype_h.m4 (gl_WCTYPE_H): Test whether wctrans is declared.
+	(gl_WCTYPE_H_DEFAULTS): Initialize GNULIB_WCTRANS.
+	* modules/wctype-h (Makefile.am): Substitute GNULIB_WCTRANS.
+	* tests/test-wctype-h-c++.cc: Test the declaration of wctrans.
+	* doc/posix-functions/wctrans.texi: Mention the new module.
+
+2011-02-06  Bruno Haible  <bruno@clisp.org>
+
+	New module 'iswctype'.
+	* modules/iswctype: New file.
+	* lib/wctype.in.h (iswctype): New declaration.
+	* lib/iswctype.c: New file.
+	* lib/iswctype-impl.h: New file.
+	* m4/iswctype.m4: New file.
+	* m4/wctype_h.m4 (gl_WCTYPE_H): Test whether iswctype is declared.
+	(gl_WCTYPE_H_DEFAULTS): Initialize GNULIB_ISWCTYPE.
+	* modules/wctype-h (Makefile.am): Substitute GNULIB_ISWCTYPE.
+	* tests/test-wctype-h-c++.cc: Test the declaration of iswctype.
+	* doc/posix-functions/iswctype.texi: Mention the new module and the
+	HP-UX 11.00 problem.
+
+2011-02-06  Bruno Haible  <bruno@clisp.org>
+
+	New module 'wctype'.
+	* modules/wctype: Change to represent the wctype() substitute.
+	* lib/wctype.in.h (wctype): New declaration.
+	* lib/wctype.c: New file.
+	* lib/wctype-impl.h: New file.
+	* m4/wctype.m4: New file.
+	* m4/wctype_h.m4 (gl_WCTYPE_H): Test whether wctype is declared.
+	(gl_WCTYPE_H_DEFAULTS): Initialize GNULIB_WCTYPE.
+	* modules/wctype-h (Makefile.am): Substitute GNULIB_WCTYPE.
+	* tests/test-wctype-h-c++.cc: Test the declaration of wctype.
+	* doc/posix-functions/wctype.texi: Mention the new module and the
+	HP-UX 11.00 problem.
+
+2011-02-06  Bruno Haible  <bruno@clisp.org>
+
+	wctype-h: Ensure wctype_t and wctrans_t are defined.
+	* lib/wctype.in.h (wctype_t, wctrans_t): New type declarations.
+	* m4/wctype_h.m4 (gl_WCTYPE_H): Determine HAVE_WCTYPE_T, HAVE_WCTRANS_T.
+	(gl_WCTYPE_H_DEFAULTS): Initialize HAVE_WCTYPE_T, HAVE_WCTRANS_T.
+	* modules/wctype-h (Makefile.am): Substitute HAVE_WCTYPE_T,
+	HAVE_WCTRANS_T.
+	* tests/test-wctype-h.c: Check that wctype_t and wctrans_t are defined.
+
+2011-02-09  Paul Eggert  <eggert@cs.ucla.edu>
+
+	flock: fix license typo
+
+	* lib/flock.c: Fix typo in license.  One of the "Lesser"s was
+	omitted.
+
+2011-02-08  Bruno Haible  <bruno@clisp.org>
+
+	Split large sed scripts, for HP-UX sed.
+	* modules/math (Makefile.am): Split sed scripts around 50 sed commands,
+	to avoid HP-UX limit of 99 commands, in the near future.
+	* modules/stdlib (Makefile.am): Likewise.
+	* modules/unistd (Makefile.am): Likewise.
+	* modules/wchar (Makefile.am): Likewise.
+	Reported by Albert Chin <bug-gnulib@mlists.thewrittenword.com>.
+	Suggestion by Ralf Wildenhues <Ralf.Wildenhues@gmx.de> in
+	<http://lists.gnu.org/archive/html/bug-gnulib/2010-01/msg00216.html>.
+
+2011-02-08  Paul Eggert  <eggert@cs.ucla.edu>
+	    Bruno Haible  <bruno@clisp.org>
+
+	stdlib: improve random_r modularization
+	* lib/stdlib.in.h: Encapsulate all the stuff having to do with
+	random_r inside "#if @GNULIB_RANDOM_R@", so that it's clearer that
+	you also need the random_r module to get this material right.
+	* m4/random_r.m4 (gl_FUNC_RANDOM_R): Move check for random.h here ...
+	* m4/stdlib_h.m4 (gl_STDLIB_H): ... from here.
+	(gl_STDLIB_H_DEFAULTS): Default HAVE_RANDOM_H to 1, and AC_SUBST it.
+
+2011-02-08  Paul Eggert  <eggert@cs.ucla.edu>
+
+	stdlib: don't depend on stdint
+	* lib/stdlib.in.h: Don't include <stdint.h> merely because
+	GNULIB_POSIXCHECK is defined.  GNULIB_POSIXCHECK seems to
+	be independent of whether stdint.h is needed.
+	* m4/random_r.m4 (gl_FUNC_RANDOM_R): Check for struct random_data
+	here, instead of ...
+	* m4/stdlib_h.m4 (gl_STDLIB_H): ... here.  Applications that need
+	struct random_data should be using the random_r module, not just
+	the stdlib module (which wouldn't make sense: what package needs
+	just struct random_data without also needing random_r?).
+	* modules/stdlib (Depends-on): Remove stdint.
+
+	getloadavg: don't depend on c-strtod, cloexec, fcntl-safer
+	See the thread rooted at
+	<http://lists.gnu.org/archive/html/bug-gnulib/2011-02/msg00090.html>.
+	* lib/getloadavg.c: Do not include c-strtod.h, cloexec.h, or fcntl--.h.
+	Include <fcntl.h> only if (defined __linux__ || defined __CYGWIN__
+	|| defined SUNOS_5 || (defined LOAD_AVE_TYPE && !  defined
+	__VMS)); previously it was always included (via fcntl--.h).
+	(getloadavg): Do not use c_strtod.  Instead, approximate it by
+	hand; this is good enough for load averages.  Also, do not use
+	set_cloexec_flag; instead, use the O_CLOEXEC and F_DUPFD_CLOEXEC
+	flags directly if available and don't bother otherwise.  (Packages
+	that need the extra reliability should use the modules that define
+	these flags on older platforms that lack them.)
+	* modules/getloadavg (Depends-on): Remove c-strtod, cloexec,
+	fcntl-safer.
+
+2011-02-08  Jim Meyering  <meyering@redhat.com>
+
+	di-set.h, ino-map.h: add multiple-inclusion guard
+	Technically, the guard is required only for ino-map.h, due to its
+	INO_MAP_INSERT_FAILURE definition, but do both for consistency.
+	* lib/di-set.h: Add file-spanning #ifndef _GL_DI_SET_H.
+	* lib/ino-map.h: Likewise.
+
+2011-02-06  Bruno Haible  <bruno@clisp.org>
+
+	iswblank: Ensure declaration on glibc systems.
+	* m4/iswblank.m4 (gl_FUNC_ISWBLANK): Require gl_USE_SYSTEM_EXTENSIONS.
+	* modules/iswblank (Dependencies): Add 'extensions'.
+	* doc/posix-functions/iswblank.texi: Document the glibc problem.
+
+2011-02-06  Bruno Haible  <bruno@clisp.org>
+
+	New module 'iswblank'.
+	* lib/wctype.in.h (iswblank): Don't declare if GNULIB_ISWBLANK is 0.
+	* modules/iswblank: New file.
+	* modules/wctype-h (Files): Remove lib/iswblank.c.
+	(Makefile.am): Substitute GNULIB_ISWBLANK.
+	* m4/iswblank.m4: New file, partially extracted from m4/wctype_h.m4.
+	* m4/wctype_h.m4 (gl_WCTYPE_MODULE_INDICATOR): New macro.
+	(gl_WCTYPE_H_DEFAULTS): New macro.
+	(gl_WCTYPE_H): Require it. Remove iswblank related code.
+	* modules/iswblank-tests: New file.
+	* tests/test-iswblank.c: New file, extraced from tests/test-wctype-h.c.
+	* tests/test-wctype-h.c (main): Remove iswblank tests.
+	* tests/test-wctype-h-c++.cc: Guard the signature test of iswblank.
+	* doc/posix-functions/iswblank.texi: Mention module 'iswblank' instead
+	of 'wctype-h'.
+	* NEWS: Mention the change.
+	* modules/mbchar (Depends-on): Add iswblank.
+
+2011-02-08  Bruno Haible  <bruno@clisp.org>
+
+	di-set tests: Refactor.
+	* tests/test-di-set.c: Include di-set.h early. Include macros.h. Drop
+	unnecessary includes.
+	(ASSERT): Remove macro.
+	(main): Make C90 compliant by avoiding variable declaration after
+	statement.
+	* modules/di-set-tests (Files): Add tests/macros.h.
+
+2011-02-08  Bruno Haible  <bruno@clisp.org>
+
+	ino-map tests: Refactor.
+	* tests/test-ino-map.c: Include ino-map.h early. Include macros.h. Drop
+	unnecessary includes.
+	(ASSERT): Remove macro.
+	(main): Make C90 compliant by avoiding variable declaration after
+	statement.
+	* modules/ino-map-tests (Files): Add tests/macros.h.
+
+2011-02-08  Jim Meyering  <meyering@redhat.com>
+
+	di-set: add "const" to a cast
+	* lib/di-set.c (di_set_insert): Cast hash_insert0 argument to
+	"(void const *)", not "(void *)".  Spotted by Bruno Haible.
+
+2011-02-06  Bruno Haible  <bruno@clisp.org>
+
+	Rename module 'wctype' to 'wctype-h'.
+	* modules/wctype-h: Renamed from modules/wctype.
+	* modules/wctype: Simplyfy to a redirection to 'wctype-h'.
+	* modules/wctype-h-tests: Renamed from modules/wctype-tests.
+	(Files, Depends-on, Makefile.am): Update.
+	* modules/wctype-h-c++-tests: Renamed from modules/wctype-c++-tests.
+	(Files, Makefile.am): Update.
+	* tests/test-wctype-h.c: Renamed from tests/test-wctype.c.
+	* tests/test-wctype-h-c++.cc: Renamed from tests/test-wctype-c++.cc.
+	* doc/posix-headers/wctype.texi: Update.
+	* doc/posix-functions/iswalnum.texi: Update.
+	* doc/posix-functions/iswalpha.texi: Update.
+	* doc/posix-functions/iswblank.texi: Update.
+	* doc/posix-functions/iswcntrl.texi: Update.
+	* doc/posix-functions/iswdigit.texi: Update.
+	* doc/posix-functions/iswgraph.texi: Update.
+	* doc/posix-functions/iswlower.texi: Update.
+	* doc/posix-functions/iswprint.texi: Update.
+	* doc/posix-functions/iswpunct.texi: Update.
+	* doc/posix-functions/iswspace.texi: Update.
+	* doc/posix-functions/iswupper.texi: Update.
+	* doc/posix-functions/iswxdigit.texi: Update.
+	* doc/posix-functions/towlower.texi: Update.
+	* doc/posix-functions/towupper.texi: Update.
+	* NEWS: Mention the change.
+	* modules/fnmatch (Dependencies): Add wctype-h, remove wctype.
+	* modules/mbchar (Dependencies): Likewise.
+	* modules/mbswidth (Dependencies): Likewise.
+	* modules/quotearg (Dependencies): Likewise.
+	* modules/regex (Dependencies): Likewise.
+	* modules/wcscasecmp (Dependencies): Likewise.
+	* modules/wcsncasecmp (Dependencies): Likewise.
+	* modules/wcwidth (Dependencies): Likewise.
+
+2011-02-06  Bruno Haible  <bruno@clisp.org>
+
+	New module 'wcswidth'.
+	* modules/wcswidth: New file.
+	* lib/wchar.in.h (wcswidth): New declaration.
+	* lib/wcswidth.c: New file.
+	* lib/wcswidth-impl.h: New file, from libutf8 with modifications.
+	* m4/wcswidth.m4: New file.
+	* m4/wchar_h.m4 (gl_WCHAR_H): Test whether wcswidth is declared.
+	(gl_WCHAR_H_DEFAULTS): Initialize GNULIB_WCSWIDTH, HAVE_WCSWIDTH,
+	REPLACE_WCSWIDTH.
+	* modules/wchar (Makefile.am): Substitute GNULIB_WCSWIDTH,
+	HAVE_WCSWIDTH, REPLACE_WCSWIDTH.
+	* tests/test-wchar-c++.cc: Test the declaration of wcswidth.
+	* doc/posix-functions/wcswidth.texi: Mention the new module.
+
+2011-02-06  Bruno Haible  <bruno@clisp.org>
+
+	New module 'wcstok'.
+	* modules/wcstok: New file.
+	* lib/wchar.in.h (wcstok): New declaration.
+	* lib/wcstok.c: New file.
+	* lib/wcstok-impl.h: New file, from libutf8 with modifications.
+	* m4/wcstok.m4: New file.
+	* m4/wchar_h.m4 (gl_WCHAR_H): Test whether wcstok is declared.
+	(gl_WCHAR_H_DEFAULTS): Initialize GNULIB_WCSTOK, HAVE_WCSTOK.
+	* modules/wchar (Makefile.am): Substitute GNULIB_WCSTOK, HAVE_WCSTOK.
+	* tests/test-wchar-c++.cc: Test the declaration of wcstok.
+	* doc/posix-functions/wcstok.texi: Mention the new module.
+
+2011-02-06  Bruno Haible  <bruno@clisp.org>
+
+	New module 'wcsstr'.
+	* modules/wcsstr: New file.
+	* lib/wchar.in.h (wcsstr): New declaration.
+	* lib/wcsstr.c: New file.
+	* lib/wcsstr-impl.h: New file, from libutf8 with modifications.
+	* m4/wcsstr.m4: New file.
+	* m4/wchar_h.m4 (gl_WCHAR_H): Test whether wcsstr is declared.
+	(gl_WCHAR_H_DEFAULTS): Initialize GNULIB_WCSSTR, HAVE_WCSSTR.
+	* modules/wchar (Makefile.am): Substitute GNULIB_WCSSTR, HAVE_WCSSTR.
+	* tests/test-wchar-c++.cc: Test the declaration of wcsstr.
+	* doc/posix-functions/wcsstr.texi: Mention the new module.
+
+2011-02-06  Bruno Haible  <bruno@clisp.org>
+
+	New module 'wcspbrk'.
+	* modules/wcspbrk: New file.
+	* lib/wchar.in.h (wcspbrk): New declaration.
+	* lib/wcspbrk.c: New file.
+	* lib/wcspbrk-impl.h: New file, from libutf8 with modifications.
+	* m4/wcspbrk.m4: New file.
+	* m4/wchar_h.m4 (gl_WCHAR_H): Test whether wcspbrk is declared.
+	(gl_WCHAR_H_DEFAULTS): Initialize GNULIB_WCSPBRK, HAVE_WCSPBRK.
+	* modules/wchar (Makefile.am): Substitute GNULIB_WCSPBRK, HAVE_WCSPBRK.
+	* tests/test-wchar-c++.cc: Test the declaration of wcspbrk.
+	* doc/posix-functions/wcspbrk.texi: Mention the new module.
+
+2011-02-06  Bruno Haible  <bruno@clisp.org>
+
+	New module 'wcsspn'.
+	* modules/wcsspn: New file.
+	* lib/wchar.in.h (wcsspn): New declaration.
+	* lib/wcsspn.c: New file.
+	* lib/wcsspn-impl.h: New file, from libutf8 with modifications.
+	* m4/wcsspn.m4: New file.
+	* m4/wchar_h.m4 (gl_WCHAR_H): Test whether wcsspn is declared.
+	(gl_WCHAR_H_DEFAULTS): Initialize GNULIB_WCSSPN, HAVE_WCSSPN.
+	* modules/wchar (Makefile.am): Substitute GNULIB_WCSSPN, HAVE_WCSSPN.
+	* tests/test-wchar-c++.cc: Test the declaration of wcsspn.
+	* doc/posix-functions/wcsspn.texi: Mention the new module.
+
+2011-02-06  Bruno Haible  <bruno@clisp.org>
+
+	New module 'wcscspn'.
+	* modules/wcscspn: New file.
+	* lib/wchar.in.h (wcscspn): New declaration.
+	* lib/wcscspn.c: New file.
+	* lib/wcscspn-impl.h: New file, from libutf8 with modifications.
+	* m4/wcscspn.m4: New file.
+	* m4/wchar_h.m4 (gl_WCHAR_H): Test whether wcscspn is declared.
+	(gl_WCHAR_H_DEFAULTS): Initialize GNULIB_WCSCSPN, HAVE_WCSCSPN.
+	* modules/wchar (Makefile.am): Substitute GNULIB_WCSCSPN, HAVE_WCSCSPN.
+	* tests/test-wchar-c++.cc: Test the declaration of wcscspn.
+	* doc/posix-functions/wcscspn.texi: Mention the new module.
+
+2011-02-06  Bruno Haible  <bruno@clisp.org>
+
+	New module 'wcsrchr'.
+	* modules/wcsrchr: New file.
+	* lib/wchar.in.h (wcsrchr): New declaration.
+	* lib/wcsrchr.c: New file.
+	* lib/wcsrchr-impl.h: New file, from libutf8 with modifications.
+	* m4/wcsrchr.m4: New file.
+	* m4/wchar_h.m4 (gl_WCHAR_H): Test whether wcsrchr is declared.
+	(gl_WCHAR_H_DEFAULTS): Initialize GNULIB_WCSRCHR, HAVE_WCSRCHR.
+	* modules/wchar (Makefile.am): Substitute GNULIB_WCSRCHR, HAVE_WCSRCHR.
+	* tests/test-wchar-c++.cc: Test the declaration of wcsrchr.
+	* doc/posix-functions/wcsrchr.texi: Mention the new module.
+
+2011-02-06  Bruno Haible  <bruno@clisp.org>
+
+	New module 'wcschr'.
+	* modules/wcschr: New file.
+	* lib/wchar.in.h (wcschr): New declaration.
+	* lib/wcschr.c: New file.
+	* lib/wcschr-impl.h: New file, from libutf8 with modifications.
+	* m4/wcschr.m4: New file.
+	* m4/wchar_h.m4 (gl_WCHAR_H): Test whether wcschr is declared.
+	(gl_WCHAR_H_DEFAULTS): Initialize GNULIB_WCSCHR, HAVE_WCSCHR.
+	* modules/wchar (Makefile.am): Substitute GNULIB_WCSCHR, HAVE_WCSCHR.
+	* tests/test-wchar-c++.cc: Test the declaration of wcschr.
+	* doc/posix-functions/wcschr.texi: Mention the new module.
+
+2011-02-06  Bruno Haible  <bruno@clisp.org>
+
+	New module 'wcsdup'.
+	* modules/wcsdup: New file.
+	* lib/wchar.in.h (wcsdup): New declaration.
+	* lib/wcsdup.c: New file.
+	* lib/wcsdup-impl.h: New file, from libutf8 with modifications.
+	* m4/wcsdup.m4: New file.
+	* m4/wchar_h.m4 (gl_WCHAR_H): Test whether wcsdup is declared.
+	(gl_WCHAR_H_DEFAULTS): Initialize GNULIB_WCSDUP, HAVE_WCSDUP.
+	* modules/wchar (Makefile.am): Substitute GNULIB_WCSDUP, HAVE_WCSDUP.
+	* tests/test-wchar-c++.cc: Test the declaration of wcsdup.
+	* doc/posix-functions/wcsdup.texi: Mention the new module.
+
+2011-02-06  Bruno Haible  <bruno@clisp.org>
+
+	New module 'wcsxfrm'.
+	* modules/wcsxfrm: New file.
+	* lib/wchar.in.h (wcsxfrm): New declaration.
+	* lib/wcsxfrm.c: New file.
+	* lib/wcsxfrm-impl.h: New file.
+	* m4/wcsxfrm.m4: New file.
+	* m4/wchar_h.m4 (gl_WCHAR_H): Test whether wcsxfrm is declared.
+	(gl_WCHAR_H_DEFAULTS): Initialize GNULIB_WCSXFRM, HAVE_WCSXFRM.
+	* modules/wchar (Makefile.am): Substitute GNULIB_WCSXFRM, HAVE_WCSXFRM.
+	* tests/test-wchar-c++.cc: Test the declaration of wcsxfrm.
+	* doc/posix-functions/wcsxfrm.texi: Mention the new module.
+
+2011-02-06  Bruno Haible  <bruno@clisp.org>
+
+	New module 'wcscoll'.
+	* modules/wcscoll: New file.
+	* lib/wchar.in.h (wcscoll): New declaration.
+	* lib/wcscoll.c: New file.
+	* lib/wcscoll-impl.h: New file.
+	* m4/wcscoll.m4: New file.
+	* m4/wchar_h.m4 (gl_WCHAR_H): Test whether wcscoll is declared.
+	(gl_WCHAR_H_DEFAULTS): Initialize GNULIB_WCSCOLL, HAVE_WCSCOLL.
+	* modules/wchar (Makefile.am): Substitute GNULIB_WCSCOLL, HAVE_WCSCOLL.
+	* tests/test-wchar-c++.cc: Test the declaration of wcscoll.
+	* doc/posix-functions/wcscoll.texi: Mention the new module.
+
+2011-02-06  Bruno Haible  <bruno@clisp.org>
+
+	New module 'wcsncasecmp'.
+	* modules/wcsncasecmp: New file.
+	* lib/wchar.in.h (wcsncasecmp): New declaration.
+	* lib/wcsncasecmp.c: New file.
+	* lib/wcsncasecmp-impl.h: New file, from libutf8 with modifications.
+	* m4/wcsncasecmp.m4: New file.
+	* m4/wchar_h.m4 (gl_WCHAR_H): Test whether wcsncasecmp is declared.
+	(gl_WCHAR_H_DEFAULTS): Initialize GNULIB_WCSNCASECMP, HAVE_WCSNCASECMP.
+	* modules/wchar (Makefile.am): Substitute GNULIB_WCSNCASECMP,
+	HAVE_WCSNCASECMP.
+	* tests/test-wchar-c++.cc: Test the declaration of wcsncasecmp.
+	* doc/posix-functions/wcsncasecmp.texi: Mention the new module.
+
+2011-02-06  Bruno Haible  <bruno@clisp.org>
+
+	New module 'wcscasecmp'.
+	* modules/wcscasecmp: New file.
+	* lib/wchar.in.h (wcscasecmp): New declaration.
+	* lib/wcscasecmp.c: New file.
+	* lib/wcscasecmp-impl.h: New file, from libutf8 with modifications.
+	* m4/wcscasecmp.m4: New file.
+	* m4/wchar_h.m4 (gl_WCHAR_H): Test whether wcscasecmp is declared.
+	(gl_WCHAR_H_DEFAULTS): Initialize GNULIB_WCSCASECMP, HAVE_WCSCASECMP.
+	* modules/wchar (Makefile.am): Substitute GNULIB_WCSCASECMP,
+	HAVE_WCSCASECMP.
+	* tests/test-wchar-c++.cc: Test the declaration of wcscasecmp.
+	* doc/posix-functions/wcscasecmp.texi: Mention the new module.
+
+2011-02-05  Bruno Haible  <bruno@clisp.org>
+
+	New module 'wcsncmp'.
+	* modules/wcsncmp: New file.
+	* lib/wchar.in.h (wcsncmp): New declaration.
+	* lib/wcsncmp.c: New file.
+	* lib/wcsncmp-impl.h: New file, from libutf8 with modifications.
+	* m4/wcsncmp.m4: New file.
+	* m4/wchar_h.m4 (gl_WCHAR_H): Test whether wcsncmp is declared.
+	(gl_WCHAR_H_DEFAULTS): Initialize GNULIB_WCSNCMP, HAVE_WCSNCMP.
+	* modules/wchar (Makefile.am): Substitute GNULIB_WCSNCMP, HAVE_WCSNCMP.
+	* tests/test-wchar-c++.cc: Test the declaration of wcsncmp.
+	* doc/posix-functions/wcsncmp.texi: Mention the new module.
+
+2011-02-05  Bruno Haible  <bruno@clisp.org>
+
+	New module 'wcscmp'.
+	* modules/wcscmp: New file.
+	* lib/wchar.in.h (wcscmp): New declaration.
+	* lib/wcscmp.c: New file.
+	* lib/wcscmp-impl.h: New file, from libutf8 with modifications.
+	* m4/wcscmp.m4: New file.
+	* m4/wchar_h.m4 (gl_WCHAR_H): Test whether wcscmp is declared.
+	(gl_WCHAR_H_DEFAULTS): Initialize GNULIB_WCSCMP, HAVE_WCSCMP.
+	* modules/wchar (Makefile.am): Substitute GNULIB_WCSCMP, HAVE_WCSCMP.
+	* tests/test-wchar-c++.cc: Test the declaration of wcscmp.
+	* doc/posix-functions/wcscmp.texi: Mention the new module.
+
+2011-02-05  Bruno Haible  <bruno@clisp.org>
+
+	New module 'wcsncat'.
+	* modules/wcsncat: New file.
+	* lib/wchar.in.h (wcsncat): New declaration.
+	* lib/wcsncat.c: New file.
+	* lib/wcsncat-impl.h: New file, from libutf8 with modifications.
+	* m4/wcsncat.m4: New file.
+	* m4/wchar_h.m4 (gl_WCHAR_H): Test whether wcsncat is declared.
+	(gl_WCHAR_H_DEFAULTS): Initialize GNULIB_WCSNCAT, HAVE_WCSNCAT.
+	* modules/wchar (Makefile.am): Substitute GNULIB_WCSNCAT, HAVE_WCSNCAT.
+	* tests/test-wchar-c++.cc: Test the declaration of wcsncat.
+	* doc/posix-functions/wcsncat.texi: Mention the new module.
+
+2011-02-05  Bruno Haible  <bruno@clisp.org>
+
+	New module 'wcscat'.
+	* modules/wcscat: New file.
+	* lib/wchar.in.h (wcscat): New declaration.
+	* lib/wcscat.c: New file.
+	* lib/wcscat-impl.h: New file, from libutf8 with modifications.
+	* m4/wcscat.m4: New file.
+	* m4/wchar_h.m4 (gl_WCHAR_H): Test whether wcscat is declared.
+	(gl_WCHAR_H_DEFAULTS): Initialize GNULIB_WCSCAT, HAVE_WCSCAT.
+	* modules/wchar (Makefile.am): Substitute GNULIB_WCSCAT, HAVE_WCSCAT.
+	* tests/test-wchar-c++.cc: Test the declaration of wcscat.
+	* doc/posix-functions/wcscat.texi: Mention the new module.
+
+2011-02-05  Bruno Haible  <bruno@clisp.org>
+
+	New module 'wcpncpy'.
+	* modules/wcpncpy: New file.
+	* lib/wchar.in.h (wcpncpy): New declaration.
+	* lib/wcpncpy.c: New file.
+	* lib/wcpncpy-impl.h: New file, from libutf8 with modifications.
+	* m4/wcpncpy.m4: New file.
+	* m4/wchar_h.m4 (gl_WCHAR_H): Test whether wcpncpy is declared.
+	(gl_WCHAR_H_DEFAULTS): Initialize GNULIB_WCPNCPY, HAVE_WCPNCPY.
+	* modules/wchar (Makefile.am): Substitute GNULIB_WCPNCPY, HAVE_WCPNCPY.
+	* tests/test-wchar-c++.cc: Test the declaration of wcpncpy.
+	* doc/posix-functions/wcpncpy.texi: Mention the new module.
+
+2011-02-05  Bruno Haible  <bruno@clisp.org>
+
+	New module 'wcsncpy'.
+	* modules/wcsncpy: New file.
+	* lib/wchar.in.h (wcsncpy): New declaration.
+	* lib/wcsncpy.c: New file.
+	* lib/wcsncpy-impl.h: New file, from libutf8 with modifications.
+	* m4/wcsncpy.m4: New file.
+	* m4/wchar_h.m4 (gl_WCHAR_H): Test whether wcsncpy is declared.
+	(gl_WCHAR_H_DEFAULTS): Initialize GNULIB_WCSNCPY, HAVE_WCSNCPY.
+	* modules/wchar (Makefile.am): Substitute GNULIB_WCSNCPY, HAVE_WCSNCPY.
+	* tests/test-wchar-c++.cc: Test the declaration of wcsncpy.
+	* doc/posix-functions/wcsncpy.texi: Mention the new module.
+
+2011-02-05  Bruno Haible  <bruno@clisp.org>
+
+	New module 'wcpcpy'.
+	* modules/wcpcpy: New file.
+	* lib/wchar.in.h (wcpcpy): New declaration.
+	* lib/wcpcpy.c: New file.
+	* lib/wcpcpy-impl.h: New file, from libutf8 with modifications.
+	* m4/wcpcpy.m4: New file.
+	* m4/wchar_h.m4 (gl_WCHAR_H): Test whether wcpcpy is declared.
+	(gl_WCHAR_H_DEFAULTS): Initialize GNULIB_WCPCPY, HAVE_WCPCPY.
+	* modules/wchar (Makefile.am): Substitute GNULIB_WCPCPY, HAVE_WCPCPY.
+	* tests/test-wchar-c++.cc: Test the declaration of wcpcpy.
+	* doc/posix-functions/wcpcpy.texi: Mention the new module.
+
+2011-02-05  Bruno Haible  <bruno@clisp.org>
+
+	New module 'wcscpy'.
+	* modules/wcscpy: New file.
+	* lib/wchar.in.h (wcscpy): New declaration.
+	* lib/wcscpy.c: New file.
+	* lib/wcscpy-impl.h: New file, from libutf8 with modifications.
+	* m4/wcscpy.m4: New file.
+	* m4/wchar_h.m4 (gl_WCHAR_H): Test whether wcscpy is declared.
+	(gl_WCHAR_H_DEFAULTS): Initialize GNULIB_WCSCPY, HAVE_WCSCPY.
+	* modules/wchar (Makefile.am): Substitute GNULIB_WCSCPY, HAVE_WCSCPY.
+	* tests/test-wchar-c++.cc: Test the declaration of wcscpy.
+	* doc/posix-functions/wcscpy.texi: Mention the new module.
+
+2011-02-05  Bruno Haible  <bruno@clisp.org>
+
+	New module 'wcsnlen'.
+	* modules/wcsnlen: New file.
+	* lib/wchar.in.h (wcsnlen): New declaration.
+	* lib/wcsnlen.c: New file.
+	* lib/wcsnlen-impl.h: New file, from libutf8 with modifications.
+	* m4/wcsnlen.m4: New file.
+	* m4/wchar_h.m4 (gl_WCHAR_H): Test whether wcsnlen is declared.
+	(gl_WCHAR_H_DEFAULTS): Initialize GNULIB_WCSNLEN, HAVE_WCSNLEN.
+	* modules/wchar (Makefile.am): Substitute GNULIB_WCSNLEN, HAVE_WCSNLEN.
+	* tests/test-wchar-c++.cc: Test the declaration of wcsnlen.
+	* doc/posix-functions/wcsnlen.texi: Mention the new module.
+
+2011-02-05  Bruno Haible  <bruno@clisp.org>
+
+	New module 'wcslen'.
+	* modules/wcslen: New file.
+	* lib/wchar.in.h (wcslen): New declaration.
+	* lib/wcslen.c: New file.
+	* lib/wcslen-impl.h: New file, from libutf8 with modifications.
+	* m4/wcslen.m4: New file.
+	* m4/wchar_h.m4 (gl_WCHAR_H): Test whether wcslen is declared.
+	(gl_WCHAR_H_DEFAULTS): Initialize GNULIB_WCSLEN, HAVE_WCSLEN.
+	* modules/wchar (Makefile.am): Substitute GNULIB_WCSLEN, HAVE_WCSLEN.
+	* tests/test-wchar-c++.cc: Test the declaration of wcslen.
+	* doc/posix-functions/wcslen.texi: Mention the new module.
+
+2011-02-05  Bruno Haible  <bruno@clisp.org>
+
+	New module 'wmemset'.
+	* modules/wmemset: New file.
+	* lib/wchar.in.h (wmemset): New declaration.
+	* lib/wmemset.c: New file.
+	* lib/wmemset-impl.h: New file, from libutf8 with modifications.
+	* m4/wmemset.m4: New file.
+	* m4/wchar_h.m4 (gl_WCHAR_H): Test whether wmemset is declared.
+	(gl_WCHAR_H_DEFAULTS): Initialize GNULIB_WMEMSET, HAVE_WMEMSET.
+	* modules/wchar (Makefile.am): Substitute GNULIB_WMEMSET, HAVE_WMEMSET.
+	* tests/test-wchar-c++.cc: Test the declaration of wmemset.
+	* doc/posix-functions/wmemset.texi: Mention the new module.
+
+2011-02-05  Bruno Haible  <bruno@clisp.org>
+
+	New module 'wmemmove'.
+	* modules/wmemmove: New file.
+	* lib/wchar.in.h (wmemmove): New declaration.
+	* lib/wmemmove.c: New file.
+	* lib/wmemmove-impl.h: New file, from libutf8 with modifications.
+	* m4/wmemmove.m4: New file.
+	* m4/wchar_h.m4 (gl_WCHAR_H): Test whether wmemmove is declared.
+	(gl_WCHAR_H_DEFAULTS): Initialize GNULIB_WMEMMOVE, HAVE_WMEMMOVE.
+	* modules/wchar (Makefile.am): Substitute GNULIB_WMEMMOVE,
+	HAVE_WMEMMOVE.
+	* tests/test-wchar-c++.cc: Test the declaration of wmemmove.
+	* doc/posix-functions/wmemmove.texi: Mention the new module.
+
+2011-02-05  Bruno Haible  <bruno@clisp.org>
+
+	New module 'wmemcpy'.
+	* modules/wmemcpy: New file.
+	* lib/wchar.in.h (wmemcpy): New declaration.
+	* lib/wmemcpy.c: New file.
+	* lib/wmemcpy-impl.h: New file, from libutf8 with modifications.
+	* m4/wmemcpy.m4: New file.
+	* m4/wchar_h.m4 (gl_WCHAR_H): Test whether wmemcpy is declared.
+	(gl_WCHAR_H_DEFAULTS): Initialize GNULIB_WMEMCPY, HAVE_WMEMCPY.
+	* modules/wchar (Makefile.am): Substitute GNULIB_WMEMCPY, HAVE_WMEMCPY.
+	* tests/test-wchar-c++.cc: Test the declaration of wmemcpy.
+	* doc/posix-functions/wmemcpy.texi: Mention the new module.
+
+2011-02-05  Bruno Haible  <bruno@clisp.org>
+
+	New module 'wmemcmp'.
+	* modules/wmemcmp: New file.
+	* lib/wchar.in.h (wmemcmp): New declaration.
+	* lib/wmemcmp.c: New file.
+	* lib/wmemcmp-impl.h: New file, from libutf8 with modifications.
+	* m4/wmemcmp.m4: New file.
+	* m4/wchar_h.m4 (gl_WCHAR_H): Test whether wmemcmp is declared.
+	(gl_WCHAR_H_DEFAULTS): Initialize GNULIB_WMEMCMP, HAVE_WMEMCMP.
+	* modules/wchar (Makefile.am): Substitute GNULIB_WMEMCMP, HAVE_WMEMCMP.
+	* tests/test-wchar-c++.cc: Test the declaration of wmemcmp.
+	* doc/posix-functions/wmemcmp.texi: Mention the new module.
+
+2011-02-07  Jim Meyering  <meyering@redhat.com>
+
+	di-set, ino-map: new modules, from coreutils
+	* lib/di-set.c: New file.
+	* lib/di-set.h: Likewise.
+	* lib/ino-map.c: Likewise.
+	* lib/ino-map.h: Likewise.
+	* modules/di-set: Likewise.
+	* modules/di-set-tests: Likewise.
+	* modules/ino-map: Likewise.
+	* modules/ino-map-tests: Likewise.
+	* tests/test-di-set.c: Likewise.
+	* tests/test-ino-map.c: Likewise.
+
+2011-02-06  Paul Eggert  <eggert@cs.ucla.edu>
+
+	getloadavg: merge minor changes from Emacs
+
+	* lib/getloadavg.c (getloadavg_initialized): More-accurate comment.
+	(getloadavg): Use memset, not bzero.
+
+	2008-07-25  Chong Yidong  <cyd@stupidchicken.com>
+	* lib/getloadavg.c (nl): Rename to name_list to avoid ncurses.h
+	clash (bug#86).
+
+2010-11-14  Bruno Haible  <bruno@clisp.org>
+
+	Allow multiple gnulib generated replacements to coexist.
+	* lib/getopt.in.h (struct option): Avoid identical redefinition.
+	* lib/inttypes.in.h (imaxdiv_t): Likewise.
+	* lib/langinfo.in.h (nl_item): Likewise.
+	* lib/math.in.h (_NaN, NAN): Likewise.
+	* lib/netdb.in.h (struct addrinfo): Likewise.
+	* lib/poll.in.h (struct pollfd, nfds_t): Likewise.
+	* lib/pthread.in.h (pthread_t, pthread_attr_t, pthread_barrier_t,
+	pthread_barrierattr_t, pthread_cond_t, pthread_condattr_t,
+	pthread_key_t, pthread_mutex_t, pthread_mutexattr_t, pthread_once_t,
+	pthread_rwlock_t, pthread_rwlockattr_t, pthread_cond_destroy,
+	pthread_cond_init, pthread_cond_signal, pthread_cond_wait,
+	pthread_create, pthread_exit, pthread_join, pthread_mutexattr_destroy,
+	pthread_mutexattr_init, pthread_mutexattr_settype,
+	pthread_mutex_destroy, pthread_mutex_init, pthread_mutex_lock,
+	pthread_mutex_trylock, pthread_mutex_unlock, pthread_spinlock_t,
+	pthread_spin_init, pthread_spin_destroy, pthread_spin_lock,
+	pthread_spin_trylock, pthread_spin_unlock): Likewise.
+	* lib/sched.in.h (struct sched_param): Likewise.
+	* lib/se-selinux.in.h (security_class_t, security_context_t,
+	is_selinux_enabled, getcon, freecon, getfscreatecon, setfscreatecon,
+	matchpathcon, getfilecon, lgetfilecon, fgetfilecon, setfilecon,
+	lsetfilecon, fsetfilecon, security_check_context,
+	security_check_context_raw, setexeccon, matchpathcon_init_prefix):
+	Likewise.
+	* lib/search.in.h (VISIT, _gl_search_compar_fn, _gl_search_action_fn):
+	Likewise.
+	* lib/signal.in.h (sig_atomic_t, sigset_t, verify_NSIG_constraint,
+	_gl_function_taking_int_returning_void_t, union sigval,
+	struct siginfo_t, siginfo_t, struct sigaction): Likewise.
+	* lib/spawn.in.h (posix_spawnattr_t, posix_spawn_file_actions_t,
+	verify_POSIX_SPAWN_USEVFORK_no_overlap): Likewise.
+	* lib/stdint.in.h (gl_int8_t, gl_uint8_t, gl_int16_t, gl_uint16_t,
+	gl_int32_t, gl_uint32_t, gl_int64_t, gl_uint64_t, int_least8_t,
+	uint_least8_t, int_least16_t, uint_least16_t, int_least32_t,
+	uint_least32_t, int_least64_t, uint_least64_t, gl_int_fast8_t,
+	gl_uint_fast8_t, gl_int_fast16_t, gl_uint_fast16_t, gl_int_fast32_t,
+	gl_uint_fast32_t, int_fast64_t, uint_fast64_t, gl_intptr_t,
+	gl_uintptr_t, intmax_t, uintmax_t, _verify_intmax_size): Likewise.
+	* lib/stdio.in.h (rpl_fseek, rpl_ftell): Likewise.
+	* lib/sys_socket.in.h (sa_family_t, struct sockaddr_storage,
+	socklen_t, rpl_fd_isset): Likewise.
+	* lib/sys_stat.in.h (rpl_mkdir): Likewise.
+	* lib/sys_time.in.h (struct timeval): Likewise.
+	* lib/sys_times.in.h (struct tms): Likewise.
+	* lib/sys_utsname.in.h (struct utsname):
+	* lib/time.in.h (struct timespec, __time_t_must_be_integral): Likewise.
+	* lib/unistd.in.h (getpagesize): Likewise.
+	* lib/wchar.in.h (mbstate_t): Likewise.
+	* lib/wctype.in.h (iswalnum, iswalpha, iswblank, iswcntrl, iswdigit,
+	iswgraph, iswlower, iswprint, iswpunct, iswspace, iswupper, iswxdigit,
+	towlower, towupper): Likewise.
+	Reported by Sam Steingold <sds@gnu.org>.
+
+2011-02-05  Eric Blake  <eblake@redhat.com>
+
+	unsetenv: work around Haiku issues
+	* m4/setenv.m4 (gl_FUNC_UNSETENV): Also detect Haiku issue.
+	* doc/posix-functions/unsetenv.texi (unsetenv): Document it.
+
+2010-12-30  Bruce Korb  <bkorb@gnu.org>
+
+	libposix: avoid calling error() within libposix
+	* lib/openat-die.c: remove error module stuff when GNULIB_LIBPOSIX
+	is defined.
+
+2011-02-05  Eric Blake  <eblake@redhat.com>
+
+	strerror_r-posix: port to cygwin
+	* lib/strerror_r.c (strerror_r) [__CYGWIN__]: Add cygwin
+	implementation.
+	* m4/strerror_r.m4 (gl_FUNC_STRERROR_R): Adjust comment.
+	* tests/test-strerror_r.c (main): Fix test.
+	* doc/posix-functions/strerror_r.texi (strerror_r): Document the
+	issue.
+
+2011-02-05  Bruno Haible  <bruno@clisp.org>
+
+	New module 'wmemchr'.
+	* modules/wmemchr: New file.
+	* lib/wchar.in.h (wmemchr): New declaration.
+	* lib/wmemchr.c: New file.
+	* lib/wmemchr-impl.h: New file, from libutf8 with modifications.
+	* m4/wmemchr.m4: New file.
+	* m4/wchar_h.m4 (gl_WCHAR_H): Test whether wmemchr is declared.
+	(gl_WCHAR_H_DEFAULTS): Initialize GNULIB_WMEMCHR, HAVE_WMEMCHR.
+	* modules/wchar (Makefile.am): Substitute GNULIB_WMEMCHR, HAVE_WMEMCHR.
+	* tests/test-wchar-c++.cc: Test the declaration of wmemchr.
+	* doc/posix-functions/wmemchr.texi: Mention the new module.
+
+2011-02-04  Eric Blake  <eblake@redhat.com>
+
+	fdopendir: detect FreeBSD bug
+	* m4/fdopendir.m4 (gl_FUNC_FDOPENDIR): Detect bug.
+	* doc/posix-functions/fdopendir.texi (fdopendir): Document it.
+
+2011-02-04  Paul Eggert  <eggert@cs.ucla.edu>
+
+	stdbool: do not define HAVE_STDBOOL_H
+	* m4/stdbool.m4 (AC_CHECK_HEADER_STDBOOL): Renamed from
+	AC_HEADER_STDBOOL.  All uses changed.  Do not define
+	HAVE_STDBOOL_H, as gnulib does not need this.  This change is
+	imported from the latest Autoconf git.  It was motivated by Emacs,
+	which uses gnulib but does not need HAVE_STDBOOL_H.
+
+2011-02-04  Bruno Haible  <bruno@clisp.org>
+
+	wcsnrtombs: Prepare for new module wwcsnrtombs.
+	* lib/wcsnrtombs-impl.h: New file, extracted from lib/wcsnrtombs.c.
+	* lib/wcsnrtombs.c: Include it.
+	* modules/wcsnrtombs (Files): Add lib/wcsnrtombs-impl.h.
+
+	wcsrtombs: Prepare for new module wwcsrtombs.
+	* lib/wcsrtombs-impl.h: New file, extracted from lib/wcsrtombs.c.
+	* lib/wcsrtombs.c: Include it.
+	* modules/wcsrtombs (Files): Add lib/wcsrtombs-impl.h.
+
+	mbsnrtowcs: Prepare for new module mbsnrtowwcs.
+	* lib/mbsnrtowcs-impl.h: New file, extracted from lib/mbsnrtowcs.c.
+	* lib/mbsnrtowcs.c: Include it.
+	* modules/mbsnrtowcs (Files): Add lib/mbsnrtowcs-impl.h.
+
+	mbsrtowcs: Prepare for new module mbsrtowwcs.
+	* lib/mbsrtowcs-impl.h: New file, extracted from lib/mbsrtowcs.c.
+	* lib/mbsrtowcs.c: Include it.
+	* modules/mbsrtowcs (Files): Add lib/mbsrtowcs-impl.h.
+
+2011-02-04  Bruno Haible  <bruno@clisp.org>
+
+	vasnprintf: Reduce use of malloc for small format strings.
+	* lib/printf-args.h (N_DIRECT_ALLOC_ARGUMENTS): New macro.
+	(arguments): Add room for the first 7 arguments.
+	* lib/printf-parse.h (N_DIRECT_ALLOC_DIRECTIVES): New macro.
+	(char_directives, u8_directives, u16_directives, u32_directives): Add
+	room for the first 7 directives.
+	* lib/printf-parse.c: Include <string.h>.
+	(PRINTF_PARSE): Change memory handling code so that it uses the first
+	7 preallocated elements in an 'arguments' or 'DIRECTIVES' struct.
+	* lib/vasnprintf.c (VASNPRINTF): Update memory handling code.
+	Reported by Pádraig Brady <P@draigbrady.com>.
+
 2011-01-31  Eric Blake  <eblake@redhat.com>
 
 	dup2: work around Haiku bug
@@ -220,7 +2646,7 @@
 
 2011-01-23  Paul Eggert  <eggert@cs.ucla.edu>
 
-	Allow the user to avoid the GNULIB_TEST_* macros.
+	Allow the user to avoid the HAVE_RAW_DECL_* macros.
 	* m4/gnulib-common.m4 (gl_ASSERT_NO_GNULIB_POSIXCHECK): New macro.
 
 2011-01-23  Bruno Haible  <bruno@clisp.org>
@@ -632,6 +3058,8 @@
 	indirectly on xalloc.  This change causes the openat substitute
 	to fall back on save_cwd when memory is tight, and for save_cwd to
 	fail instead of dying when memory is tight, but that's good enough.
+	Problem and initial idea for fix reported by Bastien Roucaries in
+	<http://lists.gnu.org/archive/html/bug-gnulib/2011-01/msg00170.html>.
 
 	* lib/openat-proc.c: Include stdlib.h (for malloc), not
 	xalloc.h (for xmalloc).
--- a/Makefile
+++ b/Makefile
@@ -1,10 +1,13 @@
-# Makefile for gnulib central.
+# GNU Makefile for gnulib central.
 # Copyright (C) 2006, 2009-2011 Free Software Foundation, Inc.
 #
 # Copying and distribution of this file, with or without modification,
 # in any medium, are permitted without royalty provided the copyright
 # notice and this notice are preserved.
 
+# This Makefile requires the use of GNU make.  Some targets require
+# that you have tools like git, makeinfo and cppi installed.
+
 # Produce some files that are not stored in the repository.
 all:
 
@@ -12,11 +15,12 @@
 info html dvi pdf:
 	cd doc && $(MAKE) $@ && $(MAKE) mostlyclean
 
+# Collect the names of rules starting with `sc_'.
+syntax-check-rules := $(sort $(shell sed -n 's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p'\
+			Makefile))
+
 # Perform some platform independent checks on the gnulib code.
-check: \
-  sc_prohibit_augmenting_PATH_via_TESTS_ENVIRONMENT			\
-  sc_pragma_columns							\
-  sc_prefer_ac_check_funcs_once
+check: $(syntax-check-rules)
 
 sc_prefer_ac_check_funcs_once:
 	if test -d .git; then						\
@@ -45,6 +49,16 @@
 		 exit 1; } || :;					\
 	else :; fi
 
+# Verify that certain (for now, only Jim Meyering and Eric Blake's)
+# *.c files are consistently cpp indented.
+sc_cpp_indent_check:
+	./gnulib-tool --extract-filelist \
+            $$(cd ./modules; grep -ilrE '(meyering|blake)' .) \
+          | sort -u \
+          | grep '\.c$$' \
+          | grep -v '/getloadavg\.c$$' \
+          | xargs cppi -c
+
 # Regenerate some files that are stored in the repository.
 regen: MODULES.html
 
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,43 @@
 
 Date        Modules         Changes
 
+2011-03-08  regex-quote     The last argument is no longer an 'int cflags'
+                            but instead a pointer to a previously constructed
+                            'struct regex_quote_spec'.
+
+2011-02-25  dirname         These modules no longer put #defines for the
+            dirname-lgpl    following symbols into <config.h>: ISSLASH,
+            backupfile      FILE_SYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX,
+            lstat           FILE_SYSTEM_BACKSLASH_IS_FILE_NAME_SEPARATOR,
+            openat          FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE.
+            remove          Applications that need ISSLASH can include the new
+            rmdir           header dosname.h.
+            savewd
+            stat
+            unlink
+
+2011-02-14  getloadavg      This module no longer #defines C_GETLOADAVG or
+                            HAVE_GETLOADAVG, as the application no longer needs
+                            to worry about how getloadavg is defined.  It no
+                            longer defines the obsolete symbol NLIST_NAME_UNION
+                            (which should have been internal to the module
+                            anyway).  Also, support for setgid use has been
+                            removed, as nobody seems to be using it; thus
+                            GETLOADAVG_PRIVILEGED is no longer #defined and
+                            KMEM_GROUP and NEED_SETGID are no longer
+                            substituted for.
+
+2011-02-08  stdlib          Unless the random_r module is also used, this
+                            module no longer guarantees that the following are
+                            defined: struct random_data, RAND_MAX, random_r,
+                            srandom_r, initstate_r, setstate_r.
+
+2011-02-08  wctype-h        This module no longer provides the iswblank()
+                            function. If you need this function, you now need
+                            to request the 'iswblank' module.
+
+2011-02-07  wctype          This module is renamed to wctype-h.
+
 2011-01-18  multiarch       This no longer #defines AA_APPLE_UNIVERSAL_BUILD;
                             instead, use the shell var APPLE_UNIVERSAL_BUILD.
 
--- a/build-aux/bootstrap
+++ b/build-aux/bootstrap
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Print a version string.
-scriptversion=2011-01-21.16; # UTC
+scriptversion=2011-03-03.12; # UTC
 
 # Bootstrap this package from checked-out sources.
 
@@ -874,7 +874,7 @@
 
 for command in \
   libtool \
-  "${ACLOCAL-aclocal} --force -I m4 $ACLOCAL_FLAGS" \
+  "${ACLOCAL-aclocal} --force -I '$m4_base' $ACLOCAL_FLAGS" \
   "${AUTOCONF-autoconf} --force" \
   "${AUTOHEADER-autoheader} --force" \
   "${AUTOMAKE-automake} --add-missing --copy --force-missing"
@@ -885,7 +885,7 @@
     command="${LIBTOOLIZE-libtoolize} -c -f"
   fi
   echo "$0: $command ..."
-  $command || exit
+  eval "$command" || exit
 done
 
 
--- a/build-aux/config.guess
+++ b/build-aux/config.guess
@@ -4,7 +4,7 @@
 #   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
 #   2011 Free Software Foundation, Inc.
 
-timestamp='2011-01-23'
+timestamp='2011-02-02'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -181,7 +181,7 @@
 		fi
 		;;
 	    *)
-	        os=netbsd
+		os=netbsd
 		;;
 	esac
 	# The OS release
@@ -224,7 +224,7 @@
 		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
 		;;
 	*5.*)
-	        UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
 		;;
 	esac
 	# According to Compaq, /usr/sbin/psrinfo has been available on
@@ -299,7 +299,7 @@
 	echo s390-ibm-zvmoe
 	exit ;;
     *:OS400:*:*)
-        echo powerpc-ibm-os400
+	echo powerpc-ibm-os400
 	exit ;;
     arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
 	echo arm-acorn-riscix${UNAME_RELEASE}
@@ -398,23 +398,23 @@
     # MiNT.  But MiNT is downward compatible to TOS, so this should
     # be no problem.
     atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
-        echo m68k-atari-mint${UNAME_RELEASE}
+	echo m68k-atari-mint${UNAME_RELEASE}
 	exit ;;
     atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
 	echo m68k-atari-mint${UNAME_RELEASE}
-        exit ;;
+	exit ;;
     *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
-        echo m68k-atari-mint${UNAME_RELEASE}
+	echo m68k-atari-mint${UNAME_RELEASE}
 	exit ;;
     milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
-        echo m68k-milan-mint${UNAME_RELEASE}
-        exit ;;
+	echo m68k-milan-mint${UNAME_RELEASE}
+	exit ;;
     hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
-        echo m68k-hades-mint${UNAME_RELEASE}
-        exit ;;
+	echo m68k-hades-mint${UNAME_RELEASE}
+	exit ;;
     *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
-        echo m68k-unknown-mint${UNAME_RELEASE}
-        exit ;;
+	echo m68k-unknown-mint${UNAME_RELEASE}
+	exit ;;
     m68k:machten:*:*)
 	echo m68k-apple-machten${UNAME_RELEASE}
 	exit ;;
@@ -484,8 +484,8 @@
 	echo m88k-motorola-sysv3
 	exit ;;
     AViiON:dgux:*:*)
-        # DG/UX returns AViiON for all architectures
-        UNAME_PROCESSOR=`/usr/bin/uname -p`
+	# DG/UX returns AViiON for all architectures
+	UNAME_PROCESSOR=`/usr/bin/uname -p`
 	if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
 	then
 	    if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
@@ -498,7 +498,7 @@
 	else
 	    echo i586-dg-dgux${UNAME_RELEASE}
 	fi
- 	exit ;;
+	exit ;;
     M88*:DolphinOS:*:*)	# DolphinOS (SVR3)
 	echo m88k-dolphin-sysv3
 	exit ;;
@@ -598,52 +598,52 @@
 	    9000/[678][0-9][0-9])
 		if [ -x /usr/bin/getconf ]; then
 		    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
-                    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
-                    case "${sc_cpu_version}" in
-                      523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
-                      528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
-                      532)                      # CPU_PA_RISC2_0
-                        case "${sc_kernel_bits}" in
-                          32) HP_ARCH="hppa2.0n" ;;
-                          64) HP_ARCH="hppa2.0w" ;;
+		    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+		    case "${sc_cpu_version}" in
+		      523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+		      528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+		      532)                      # CPU_PA_RISC2_0
+			case "${sc_kernel_bits}" in
+			  32) HP_ARCH="hppa2.0n" ;;
+			  64) HP_ARCH="hppa2.0w" ;;
 			  '') HP_ARCH="hppa2.0" ;;   # HP-UX 10.20
-                        esac ;;
-                    esac
+			esac ;;
+		    esac
 		fi
 		if [ "${HP_ARCH}" = "" ]; then
 		    eval $set_cc_for_build
-		    sed 's/^              //' << EOF >$dummy.c
+		    sed 's/^		//' << EOF >$dummy.c
 
-              #define _HPUX_SOURCE
-              #include <stdlib.h>
-              #include <unistd.h>
+		#define _HPUX_SOURCE
+		#include <stdlib.h>
+		#include <unistd.h>
 
-              int main ()
-              {
-              #if defined(_SC_KERNEL_BITS)
-                  long bits = sysconf(_SC_KERNEL_BITS);
-              #endif
-                  long cpu  = sysconf (_SC_CPU_VERSION);
+		int main ()
+		{
+		#if defined(_SC_KERNEL_BITS)
+		    long bits = sysconf(_SC_KERNEL_BITS);
+		#endif
+		    long cpu  = sysconf (_SC_CPU_VERSION);
 
-                  switch (cpu)
-              	{
-              	case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
-              	case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
-              	case CPU_PA_RISC2_0:
-              #if defined(_SC_KERNEL_BITS)
-              	    switch (bits)
-              		{
-              		case 64: puts ("hppa2.0w"); break;
-              		case 32: puts ("hppa2.0n"); break;
-              		default: puts ("hppa2.0"); break;
-              		} break;
-              #else  /* !defined(_SC_KERNEL_BITS) */
-              	    puts ("hppa2.0"); break;
-              #endif
-              	default: puts ("hppa1.0"); break;
-              	}
-                  exit (0);
-              }
+		    switch (cpu)
+			{
+			case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+			case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+			case CPU_PA_RISC2_0:
+		#if defined(_SC_KERNEL_BITS)
+			    switch (bits)
+				{
+				case 64: puts ("hppa2.0w"); break;
+				case 32: puts ("hppa2.0n"); break;
+				default: puts ("hppa2.0"); break;
+				} break;
+		#else  /* !defined(_SC_KERNEL_BITS) */
+			    puts ("hppa2.0"); break;
+		#endif
+			default: puts ("hppa1.0"); break;
+			}
+		    exit (0);
+		}
 EOF
 		    (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
 		    test -z "$HP_ARCH" && HP_ARCH=hppa
@@ -734,22 +734,22 @@
 	exit ;;
     C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
 	echo c1-convex-bsd
-        exit ;;
+	exit ;;
     C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
 	if getsysinfo -f scalar_acc
 	then echo c32-convex-bsd
 	else echo c2-convex-bsd
 	fi
-        exit ;;
+	exit ;;
     C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
 	echo c34-convex-bsd
-        exit ;;
+	exit ;;
     C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
 	echo c38-convex-bsd
-        exit ;;
+	exit ;;
     C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
 	echo c4-convex-bsd
-        exit ;;
+	exit ;;
     CRAY*Y-MP:*:*:*)
 	echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
 	exit ;;
@@ -773,14 +773,14 @@
 	exit ;;
     F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
 	FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
-        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
-        FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
-        echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
-        exit ;;
+	FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+	FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+	echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+	exit ;;
     5000:UNIX_System_V:4.*:*)
-        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
-        FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
-        echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+	FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+	FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+	echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
 	exit ;;
     i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
 	echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
@@ -808,14 +808,14 @@
 	echo ${UNAME_MACHINE}-pc-mingw32
 	exit ;;
     i*:windows32*:*)
-    	# uname -m includes "-pc" on this system.
-    	echo ${UNAME_MACHINE}-mingw32
+	# uname -m includes "-pc" on this system.
+	echo ${UNAME_MACHINE}-mingw32
 	exit ;;
     i*:PW*:*)
 	echo ${UNAME_MACHINE}-pc-pw32
 	exit ;;
     *:Interix*:*)
-    	case ${UNAME_MACHINE} in
+	case ${UNAME_MACHINE} in
 	    x86)
 		echo i586-pc-interix${UNAME_RELEASE}
 		exit ;;
@@ -870,7 +870,7 @@
 	  EV6)   UNAME_MACHINE=alphaev6 ;;
 	  EV67)  UNAME_MACHINE=alphaev67 ;;
 	  EV68*) UNAME_MACHINE=alphaev68 ;;
-        esac
+	esac
 	objdump --private-headers /bin/sh | grep -q ld.so.1
 	if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
 	echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
@@ -895,7 +895,7 @@
 	echo crisv32-axis-linux-gnu
 	exit ;;
     frv:Linux:*:*)
-    	echo frv-unknown-linux-gnu
+	echo frv-unknown-linux-gnu
 	exit ;;
     i*86:Linux:*:*)
 	LIBC=gnu
@@ -963,7 +963,7 @@
 	echo ${UNAME_MACHINE}-ibm-linux
 	exit ;;
     sh64*:Linux:*:*)
-    	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
 	exit ;;
     sh*:Linux:*:*)
 	echo ${UNAME_MACHINE}-unknown-linux-gnu
@@ -981,7 +981,7 @@
 	echo x86_64-unknown-linux-gnu
 	exit ;;
     xtensa*:Linux:*:*)
-    	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
 	exit ;;
     i*86:DYNIX/ptx:4*:*)
 	# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
@@ -990,11 +990,11 @@
 	echo i386-sequent-sysv4
 	exit ;;
     i*86:UNIX_SV:4.2MP:2.*)
-        # Unixware is an offshoot of SVR4, but it has its own version
-        # number series starting with 2...
-        # I am not positive that other SVR4 systems won't match this,
+	# Unixware is an offshoot of SVR4, but it has its own version
+	# number series starting with 2...
+	# I am not positive that other SVR4 systems won't match this,
 	# I just have to hope.  -- rms.
-        # Use sysv4.2uw... so that sysv4* matches it.
+	# Use sysv4.2uw... so that sysv4* matches it.
 	echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
 	exit ;;
     i*86:OS/2:*:*)
@@ -1026,7 +1026,7 @@
 	fi
 	exit ;;
     i*86:*:5:[678]*)
-    	# UnixWare 7.x, OpenUNIX and OpenServer 6.
+	# UnixWare 7.x, OpenUNIX and OpenServer 6.
 	case `/bin/uname -X | grep "^Machine"` in
 	    *486*)	     UNAME_MACHINE=i486 ;;
 	    *Pentium)	     UNAME_MACHINE=i586 ;;
@@ -1054,13 +1054,13 @@
 	exit ;;
     pc:*:*:*)
 	# Left here for compatibility:
-        # uname -m prints for DJGPP always 'pc', but it prints nothing about
-        # the processor, so we play safe by assuming i586.
+	# uname -m prints for DJGPP always 'pc', but it prints nothing about
+	# the processor, so we play safe by assuming i586.
 	# Note: whatever this is, it MUST be the same as what config.sub
 	# prints for the "djgpp" host, or else GDB configury will decide that
 	# this is a cross-build.
 	echo i586-pc-msdosdjgpp
-        exit ;;
+	exit ;;
     Intel:Mach:3*:*)
 	echo i386-pc-mach3
 	exit ;;
@@ -1095,8 +1095,8 @@
 	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
 	  && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
     3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
-        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
-          && { echo i486-ncr-sysv4; exit; } ;;
+	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+	  && { echo i486-ncr-sysv4; exit; } ;;
     NCR*:*:4.2:* | MPRAS*:*:4.2:*)
 	OS_REL='.3'
 	test -r /etc/.relid \
@@ -1139,10 +1139,10 @@
 		echo ns32k-sni-sysv
 	fi
 	exit ;;
-    PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
-                      # says <Richard.M.Bartel@ccMail.Census.GOV>
-        echo i586-unisys-sysv4
-        exit ;;
+    PENTIUM:*:4.0*:*)	# Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+			# says <Richard.M.Bartel@ccMail.Census.GOV>
+	echo i586-unisys-sysv4
+	exit ;;
     *:UNIX_System_V:4*:FTX*)
 	# From Gerald Hewes <hewes@openmarket.com>.
 	# How about differentiating between stratus architectures? -djm
@@ -1168,11 +1168,11 @@
 	exit ;;
     R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
 	if [ -d /usr/nec ]; then
-	        echo mips-nec-sysv${UNAME_RELEASE}
+		echo mips-nec-sysv${UNAME_RELEASE}
 	else
-	        echo mips-unknown-sysv${UNAME_RELEASE}
+		echo mips-unknown-sysv${UNAME_RELEASE}
 	fi
-        exit ;;
+	exit ;;
     BeBox:BeOS:*:*)	# BeOS running on hardware made by Be, PPC only.
 	echo powerpc-be-beos
 	exit ;;
@@ -1285,13 +1285,13 @@
 	echo pdp10-unknown-its
 	exit ;;
     SEI:*:*:SEIUX)
-        echo mips-sei-seiux${UNAME_RELEASE}
+	echo mips-sei-seiux${UNAME_RELEASE}
 	exit ;;
     *:DragonFly:*:*)
 	echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
 	exit ;;
     *:*VMS:*:*)
-    	UNAME_MACHINE=`(uname -p) 2>/dev/null`
+	UNAME_MACHINE=`(uname -p) 2>/dev/null`
 	case "${UNAME_MACHINE}" in
 	    A*) echo alpha-dec-vms ; exit ;;
 	    I*) echo ia64-dec-vms ; exit ;;
@@ -1331,11 +1331,11 @@
 #include <sys/param.h>
   printf ("m68k-sony-newsos%s\n",
 #ifdef NEWSOS4
-          "4"
+	"4"
 #else
-	  ""
+	""
 #endif
-         ); exit (0);
+	); exit (0);
 #endif
 #endif
 
--- a/build-aux/config.rpath
+++ b/build-aux/config.rpath
@@ -57,13 +57,6 @@
     aix*)
       wl='-Wl,'
       ;;
-    darwin*)
-      case $cc_basename in
-        xlc*)
-          wl='-Wl,'
-          ;;
-      esac
-      ;;
     mingw* | cygwin* | pw32* | os2* | cegcc*)
       ;;
     hpux9* | hpux10* | hpux11*)
@@ -72,9 +65,7 @@
     irix5* | irix6* | nonstopux*)
       wl='-Wl,'
       ;;
-    newsos6)
-      ;;
-    linux* | k*bsd*-gnu)
+    linux* | k*bsd*-gnu | kopensolaris*-gnu)
       case $cc_basename in
         ecc*)
           wl='-Wl,'
@@ -85,17 +76,26 @@
         lf95*)
           wl='-Wl,'
           ;;
-        pgcc | pgf77 | pgf90)
+        nagfor*)
+          wl='-Wl,-Wl,,'
+          ;;
+        pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
           wl='-Wl,'
           ;;
         ccc*)
           wl='-Wl,'
           ;;
+        xl* | bgxl* | bgf* | mpixl*)
+          wl='-Wl,'
+          ;;
         como)
           wl='-lopt='
           ;;
         *)
           case `$CC -V 2>&1 | sed 5q` in
+            *Sun\ F* | *Sun*Fortran*)
+              wl=
+              ;;
             *Sun\ C*)
               wl='-Wl,'
               ;;
@@ -103,13 +103,24 @@
           ;;
       esac
       ;;
+    newsos6)
+      ;;
+    *nto* | *qnx*)
+      ;;
     osf3* | osf4* | osf5*)
       wl='-Wl,'
       ;;
     rdos*)
       ;;
     solaris*)
-      wl='-Wl,'
+      case $cc_basename in
+        f77* | f90* | f95* | sunf77* | sunf90* | sunf95*)
+          wl='-Qoption ld '
+          ;;
+        *)
+          wl='-Wl,'
+          ;;
+      esac
       ;;
     sunos4*)
       wl='-Qoption ld '
@@ -171,15 +182,14 @@
       fi
       ;;
     amigaos*)
-      hardcode_libdir_flag_spec='-L$libdir'
-      hardcode_minus_L=yes
-      # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
-      # that the semantics of dynamic libraries on AmigaOS, at least up
-      # to version 4, is to share data among multiple programs linked
-      # with the same dynamic library.  Since this doesn't match the
-      # behavior of shared libraries on other platforms, we cannot use
-      # them.
-      ld_shlibs=no
+      case "$host_cpu" in
+        powerpc)
+          ;;
+        m68k)
+          hardcode_libdir_flag_spec='-L$libdir'
+          hardcode_minus_L=yes
+          ;;
+      esac
       ;;
     beos*)
       if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
@@ -198,11 +208,13 @@
         ld_shlibs=no
       fi
       ;;
+    haiku*)
+      ;;
     interix[3-9]*)
       hardcode_direct=no
       hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
       ;;
-    gnu* | linux* | k*bsd*-gnu)
+    gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
       if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
         :
       else
@@ -325,10 +337,14 @@
       fi
       ;;
     amigaos*)
-      hardcode_libdir_flag_spec='-L$libdir'
-      hardcode_minus_L=yes
-      # see comment about different semantics on the GNU ld section
-      ld_shlibs=no
+      case "$host_cpu" in
+        powerpc)
+          ;;
+        m68k)
+          hardcode_libdir_flag_spec='-L$libdir'
+          hardcode_minus_L=yes
+          ;;
+      esac
       ;;
     bsdi[45]*)
       ;;
@@ -342,16 +358,10 @@
       ;;
     darwin* | rhapsody*)
       hardcode_direct=no
-      if test "$GCC" = yes ; then
+      if { case $cc_basename in ifort*) true;; *) test "$GCC" = yes;; esac; }; then
         :
       else
-        case $cc_basename in
-          xlc*)
-            ;;
-          *)
-            ld_shlibs=no
-            ;;
-        esac
+        ld_shlibs=no
       fi
       ;;
     dgux*)
@@ -417,6 +427,8 @@
       hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
       hardcode_libdir_separator=:
       ;;
+    *nto* | *qnx*)
+      ;;
     openbsd*)
       if test -f /usr/libexec/ld.so; then
         hardcode_direct=yes
@@ -512,7 +524,12 @@
     library_names_spec='$libname$shrext'
     ;;
   amigaos*)
-    library_names_spec='$libname.a'
+    case "$host_cpu" in
+      powerpc*)
+        library_names_spec='$libname$shrext' ;;
+      m68k)
+        library_names_spec='$libname.a' ;;
+    esac
     ;;
   beos*)
     library_names_spec='$libname$shrext'
@@ -542,6 +559,9 @@
   gnu*)
     library_names_spec='$libname$shrext'
     ;;
+  haiku*)
+    library_names_spec='$libname$shrext'
+    ;;
   hpux9* | hpux10* | hpux11*)
     case $host_cpu in
       ia64*)
@@ -577,7 +597,7 @@
     ;;
   linux*oldld* | linux*aout* | linux*coff*)
     ;;
-  linux* | k*bsd*-gnu)
+  linux* | k*bsd*-gnu | kopensolaris*-gnu)
     library_names_spec='$libname$shrext'
     ;;
   knetbsd*-gnu)
@@ -589,7 +609,7 @@
   newsos6)
     library_names_spec='$libname$shrext'
     ;;
-  nto-qnx*)
+  *nto* | *qnx*)
     library_names_spec='$libname$shrext'
     ;;
   openbsd*)
@@ -620,6 +640,9 @@
   sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
     library_names_spec='$libname$shrext'
     ;;
+  tpf*)
+    library_names_spec='$libname$shrext'
+    ;;
   uts4*)
     library_names_spec='$libname$shrext'
     ;;
--- a/build-aux/config.sub
+++ b/build-aux/config.sub
@@ -4,7 +4,7 @@
 #   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
 #   2011 Free Software Foundation, Inc.
 
-timestamp='2011-01-01'
+timestamp='2011-03-23'
 
 # This file is (in principle) common to ALL GNU software.
 # The presence of a machine in this file suggests that SOME GNU software
@@ -76,7 +76,7 @@
 GNU config.sub ($timestamp)
 
 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free
+2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free
 Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
@@ -158,8 +158,8 @@
 		os=
 		basic_machine=$1
 		;;
-        -bluegene*)
-	        os=-cnk
+	-bluegene*)
+		os=-cnk
 		;;
 	-sim | -cisco | -oki | -wec | -winbond)
 		os=
@@ -175,10 +175,10 @@
 		os=-chorusos
 		basic_machine=$1
 		;;
- 	-chorusrdb)
- 		os=-chorusrdb
+	-chorusrdb)
+		os=-chorusrdb
 		basic_machine=$1
- 		;;
+		;;
 	-hiux*)
 		os=-hiuxwe2
 		;;
@@ -288,7 +288,7 @@
 	| ns16k | ns32k \
 	| or32 \
 	| pdp10 | pdp11 | pj | pjl \
-	| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
+	| powerpc | powerpc64 | powerpc64le | powerpcle \
 	| pyramid \
 	| rx \
 	| score \
@@ -296,12 +296,12 @@
 	| sh64 | sh64le \
 	| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
 	| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
-	| spu | strongarm \
-	| tahoe | thumb | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
+	| spu \
+	| tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
 	| ubicom32 \
 	| v850 | v850e \
 	| we32k \
-	| x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
+	| x86 | xc16x | xstormy16 | xtensa \
 	| z8k | z80)
 		basic_machine=$basic_machine-unknown
 		;;
@@ -325,6 +325,18 @@
 		basic_machine=mt-unknown
 		;;
 
+	strongarm | thumb | xscale)
+		basic_machine=arm-unknown
+		;;
+
+	xscaleeb)
+		basic_machine=armeb-unknown
+		;;
+
+	xscaleel)
+		basic_machine=armel-unknown
+		;;
+
 	# We use `pc' rather than `unknown'
 	# because (1) that's what they normally are, and
 	# (2) the word "unknown" tends to confuse beginning users.
@@ -384,22 +396,22 @@
 	| none-* | np1-* | ns16k-* | ns32k-* \
 	| orion-* \
 	| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
-	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
 	| pyramid-* \
 	| romp-* | rs6000-* | rx-* \
 	| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
 	| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
 	| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
 	| sparclite-* \
-	| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
-	| tahoe-* | thumb-* \
+	| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
+	| tahoe-* \
 	| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
 	| tile-* | tilegx-* \
 	| tron-* \
 	| ubicom32-* \
 	| v850-* | v850e-* | vax-* \
 	| we32k-* \
-	| x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
+	| x86-* | x86_64-* | xc16x-* | xps100-* \
 	| xstormy16-* | xtensa*-* \
 	| ymp-* \
 	| z8k-* | z80-*)
@@ -424,7 +436,7 @@
 		basic_machine=a29k-amd
 		os=-udi
 		;;
-    	abacus)
+	abacus)
 		basic_machine=abacus-unknown
 		;;
 	adobe68k)
@@ -507,7 +519,7 @@
 		basic_machine=c90-cray
 		os=-unicos
 		;;
-        cegcc)
+	cegcc)
 		basic_machine=arm-unknown
 		os=-cegcc
 		;;
@@ -755,7 +767,7 @@
 		basic_machine=ns32k-utek
 		os=-sysv
 		;;
-        microblaze)
+	microblaze)
 		basic_machine=microblaze-xilinx
 		;;
 	mingw32)
@@ -862,10 +874,10 @@
 	np1)
 		basic_machine=np1-gould
 		;;
-        neo-tandem)
+	neo-tandem)
 		basic_machine=neo-tandem
 		;;
-        nse-tandem)
+	nse-tandem)
 		basic_machine=nse-tandem
 		;;
 	nsr-tandem)
@@ -950,9 +962,10 @@
 		;;
 	power)	basic_machine=power-ibm
 		;;
-	ppc)	basic_machine=powerpc-unknown
+	ppc | ppcbe)	basic_machine=powerpc-unknown
 		;;
-	ppc-*)	basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+	ppc-* | ppcbe-*)
+		basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
 		;;
 	ppcle | powerpclittle | ppc-le | powerpc-little)
 		basic_machine=powerpcle-unknown
@@ -1046,6 +1059,9 @@
 		basic_machine=i860-stratus
 		os=-sysv4
 		;;
+	strongarm-* | thumb-*)
+		basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
 	sun2)
 		basic_machine=m68000-sun
 		;;
@@ -1102,8 +1118,8 @@
 		basic_machine=t90-cray
 		os=-unicos
 		;;
-        # This must be matched before tile*.
-        tilegx*)
+	# This must be matched before tile*.
+	tilegx*)
 		basic_machine=tilegx-unknown
 		os=-linux-gnu
 		;;
@@ -1178,6 +1194,9 @@
 	xps | xps100)
 		basic_machine=xps100-honeywell
 		;;
+	xscale-* | xscalee[bl]-*)
+		basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'`
+		;;
 	ymp)
 		basic_machine=ymp-cray
 		os=-unicos
@@ -1275,11 +1294,11 @@
 if [ x"$os" != x"" ]
 then
 case $os in
-        # First match some system type aliases
-        # that might get confused with valid system types.
+	# First match some system type aliases
+	# that might get confused with valid system types.
 	# -solaris* is a basic system type, with this one exception.
-        -auroraux)
-	        os=-auroraux
+	-auroraux)
+		os=-auroraux
 		;;
 	-solaris1 | -solaris1.*)
 		os=`echo $os | sed -e 's|solaris1|sunos4|'`
@@ -1364,7 +1383,7 @@
 	-opened*)
 		os=-openedition
 		;;
-        -os400*)
+	-os400*)
 		os=-os400
 		;;
 	-wince*)
@@ -1413,7 +1432,7 @@
 	-sinix*)
 		os=-sysv4
 		;;
-        -tpf*)
+	-tpf*)
 		os=-tpf
 		;;
 	-triton*)
@@ -1458,8 +1477,8 @@
 	-dicos*)
 		os=-dicos
 		;;
-        -nacl*)
-	        ;;
+	-nacl*)
+		;;
 	-none)
 		;;
 	*)
@@ -1482,10 +1501,10 @@
 # system, and we'll never get to this point.
 
 case $basic_machine in
-        score-*)
+	score-*)
 		os=-elf
 		;;
-        spu-*)
+	spu-*)
 		os=-elf
 		;;
 	*-acorn)
@@ -1497,8 +1516,8 @@
 	arm*-semi)
 		os=-aout
 		;;
-        c4x-* | tic4x-*)
-        	os=-coff
+	c4x-* | tic4x-*)
+		os=-coff
 		;;
 	tic54x-*)
 		os=-coff
@@ -1534,7 +1553,7 @@
 	m68*-cisco)
 		os=-aout
 		;;
-        mep-*)
+	mep-*)
 		os=-elf
 		;;
 	mips*-cisco)
@@ -1561,7 +1580,7 @@
 	*-ibm)
 		os=-aix
 		;;
-    	*-knuth)
+	*-knuth)
 		os=-mmixware
 		;;
 	*-wec)
--- a/build-aux/git-version-gen
+++ b/build-aux/git-version-gen
@@ -1,6 +1,6 @@
 #!/bin/sh
 # Print a version string.
-scriptversion=2011-01-04.17; # UTC
+scriptversion=2011-02-19.19; # UTC
 
 # Copyright (C) 2007-2011 Free Software Foundation, Inc.
 #
@@ -80,6 +80,7 @@
 
 # Avoid meddling by environment variable of the same name.
 v=
+v_from_git=
 
 # First see if there is a tarball-only version file.
 # then try "git describe", then default.
@@ -134,24 +135,30 @@
     # Change the first '-' to a '.', so version-comparing tools work properly.
     # Remove the "g" in git describe's output string, to save a byte.
     v=`echo "$v" | sed 's/-/./;s/\(.*\)-g/\1-/'`;
+    v_from_git=1
 else
     v=UNKNOWN
 fi
 
 v=`echo "$v" |sed 's/^v//'`
 
-# Don't declare a version "dirty" merely because a time stamp has changed.
-git update-index --refresh > /dev/null 2>&1
+# Test whether to append the "-dirty" suffix only if the version
+# string we're using came from git.  I.e., skip the test if it's "UNKNOWN"
+# or if it came from .tarball-version.
+if test -n "$v_from_git"; then
+  # Don't declare a version "dirty" merely because a time stamp has changed.
+  git update-index --refresh > /dev/null 2>&1
 
-dirty=`exec 2>/dev/null;git diff-index --name-only HEAD` || dirty=
-case "$dirty" in
-    '') ;;
-    *) # Append the suffix only if there isn't one already.
-        case $v in
-          *-dirty) ;;
-          *) v="$v-dirty" ;;
-        esac ;;
-esac
+  dirty=`exec 2>/dev/null;git diff-index --name-only HEAD` || dirty=
+  case "$dirty" in
+      '') ;;
+      *) # Append the suffix only if there isn't one already.
+          case $v in
+            *-dirty) ;;
+            *) v="$v-dirty" ;;
+          esac ;;
+  esac
+fi
 
 # Omit the trailing newline, so that m4_esyscmd can use the result directly.
 echo "$v" | tr -d "$nl"
--- a/build-aux/install-sh
+++ b/build-aux/install-sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 # install - install a program, script, or datafile
 
-scriptversion=2010-02-06.18; # UTC
+scriptversion=2011-01-19.21; # UTC
 
 # This originates from X11R5 (mit/util/scripts/install.sh), which was
 # later released in X11R6 (xc/config/util/install.sh) with the
@@ -156,6 +156,10 @@
     -s) stripcmd=$stripprog;;
 
     -t) dst_arg=$2
+	# Protect names problematic for `test' and other utilities.
+	case $dst_arg in
+	  -* | [=\(\)!]) dst_arg=./$dst_arg;;
+	esac
 	shift;;
 
     -T) no_target_directory=true;;
@@ -186,6 +190,10 @@
     fi
     shift # arg
     dst_arg=$arg
+    # Protect names problematic for `test' and other utilities.
+    case $dst_arg in
+      -* | [=\(\)!]) dst_arg=./$dst_arg;;
+    esac
   done
 fi
 
@@ -232,9 +240,9 @@
 
 for src
 do
-  # Protect names starting with `-'.
+  # Protect names problematic for `test' and other utilities.
   case $src in
-    -*) src=./$src;;
+    -* | [=\(\)!]) src=./$src;;
   esac
 
   if test -n "$dir_arg"; then
@@ -256,12 +264,7 @@
       echo "$0: no destination specified." >&2
       exit 1
     fi
-
     dst=$dst_arg
-    # Protect names starting with `-'.
-    case $dst in
-      -*) dst=./$dst;;
-    esac
 
     # If destination is a directory, append the input filename; won't work
     # if double slashes aren't ignored.
@@ -389,7 +392,7 @@
 
       case $dstdir in
 	/*) prefix='/';;
-	-*) prefix='./';;
+	[-=\(\)!]*) prefix='./';;
 	*)  prefix='';;
       esac
 
@@ -407,7 +410,7 @@
 
       for d
       do
-	test -z "$d" && continue
+	test X"$d" = X && continue
 
 	prefix=$prefix$d
 	if test -d "$prefix"; then
--- a/build-aux/texinfo.tex
+++ b/build-aux/texinfo.tex
@@ -3,7 +3,7 @@
 % Load plain if necessary, i.e., if running under initex.
 \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
 %
-\def\texinfoversion{2011-02-01.10}
+\def\texinfoversion{2011-02-24.09}
 %
 % Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
 % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
@@ -158,6 +158,7 @@
 \def\spaceisspace{\catcode`\ =\spacecat}
 
 % sometimes characters are active, so we need control sequences.
+\chardef\ampChar   = `\&
 \chardef\colonChar = `\:
 \chardef\commaChar = `\,
 \chardef\dashChar  = `\-
@@ -217,7 +218,7 @@
   \tracingmacros2
   \tracingrestores1
   \showboxbreadth\maxdimen \showboxdepth\maxdimen
-  \ifx\eTeXversion\undefined\else % etex gives us more logging
+  \ifx\eTeXversion\thisisundefined\else % etex gives us more logging
     \tracingscantokens1
     \tracingifs1
     \tracinggroups1
@@ -547,7 +548,7 @@
 }
 \def\inenvironment#1{%
   \ifx#1\empty
-    out of any environment%
+    outside of any environment%
   \else
     in environment \expandafter\string#1%
   \fi
@@ -610,7 +611,7 @@
   \else\ifx\temp\offword \plainnonfrenchspacing
   \else
     \errhelp = \EMsimple
-    \errmessage{Unknown @frenchspacing option `\temp', must be on/off}%
+    \errmessage{Unknown @frenchspacing option `\temp', must be on|off}%
   \fi\fi
 }
 
@@ -1081,9 +1082,8 @@
 \newif\ifpdfmakepagedest
 
 % when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1
-% can be set).  So we test for \relax and 0 as well as \undefined,
-% borrowed from ifpdf.sty.
-\ifx\pdfoutput\undefined
+% can be set).  So we test for \relax and 0 as well as being undefined.
+\ifx\pdfoutput\thisisundefined
 \else
   \ifx\pdfoutput\relax
   \else
@@ -1515,7 +1515,7 @@
 % if we are producing pdf, and we have \pdffontattr, then define cmaps.
 % (\pdffontattr was introduced many years ago, but people still run
 % older pdftex's; it's easy to conditionalize, so we do.)
-\ifpdf \ifx\pdffontattr\undefined \else
+\ifpdf \ifx\pdffontattr\thisisundefined \else
   \begingroup
     \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
     \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
@@ -1782,7 +1782,7 @@
 % Use cm as the default font prefix.
 % To specify the font prefix, you must define \fontprefix
 % before you read in texinfo.tex.
-\ifx\fontprefix\undefined
+\ifx\fontprefix\thisisundefined
 \def\fontprefix{cm}
 \fi
 % Support font families that don't use the same naming scheme as CM.
@@ -2296,12 +2296,11 @@
 
 \let\markupsetuplqkbd \markupsetnoligaturesquoteleft
 
-% Allow an option to not replace quotes with a regular directed right
-% quote/apostrophe (char 0x27), but instead use the undirected quote
-% from cmtt (char 0x0d).  The undirected quote is ugly, so don't make it
-% the default, but it works for pasting with more pdf viewers (at least
-% evince), the lilypond developers report.  xpdf does work with the
-% regular 0x27.
+% Allow an option to not use regular directed right quote/apostrophe
+% (char 0x27), but instead the undirected quote from cmtt (char 0x0d).
+% The undirected quote is ugly, so don't make it the default, but it
+% works for pasting with more pdf viewers (at least evince), the
+% lilypond developers report.  xpdf does work with the regular 0x27.
 %
 \def\codequoteright{%
   \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax
@@ -2325,6 +2324,36 @@
   \else \char'22 \fi
 }
 
+% Commands to set the quote options.
+% 
+\parseargdef\codequoteundirected{%
+  \def\temp{#1}%
+  \ifx\temp\onword
+    \expandafter\let\csname SETtxicodequoteundirected\endcsname
+      = t%
+  \else\ifx\temp\offword
+    \expandafter\let\csname SETtxicodequoteundirected\endcsname
+      = \relax
+  \else
+    \errhelp = \EMsimple
+    \errmessage{Unknown @codequoteundirected value `\temp', must be on|off}%
+  \fi\fi
+}
+%
+\parseargdef\codequotebacktick{%
+  \def\temp{#1}%
+  \ifx\temp\onword
+    \expandafter\let\csname SETtxicodequotebacktick\endcsname
+      = t%
+  \else\ifx\temp\offword
+    \expandafter\let\csname SETtxicodequotebacktick\endcsname
+      = \relax
+  \else
+    \errhelp = \EMsimple
+    \errmessage{Unknown @codequotebacktick value `\temp', must be on|off}%
+  \fi\fi
+}
+
 % [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font.
 \def\noligaturesquoteleft{\relax\lq}
 
@@ -2491,22 +2520,8 @@
     \codex
   }
 }
-% Handle @url similarly to \code, but allows line breaks after .#?/ (only).
-{
-  \catcode`\.=\active \catcode`\#=\active
-  \catcode`\?=\active \catcode`\/=\active
-  %
-  \global\def\urefcode{\begingroup
-    \setupmarkupstyle{code}%
-    \catcode\dotChar=\active   \catcode\hashChar=\active
-    \catcode\questChar=\active \catcode\slashChar=\active
-    \let.\urefcodedot
-    \let#\urefcodehash
-    \let?\urefcodequestion
-    \let/\urefcodeslash
-    \codex
-  }
-}
+
+\def\codex #1{\tclose{#1}\endgroup}
 
 \def\realdash{-}
 \def\codedash{-\discretionary{}{}{}}
@@ -2521,25 +2536,6 @@
              \discretionary{}{}{}}%
             {\_}%
 }
-% we put a little stretch before and after the breakable chars, to help
-% line breaking of long url's.  The unequal skips make look better in
-% cmtt at least, especially for dots.
-\def\urefprestretch{\nobreak \hskip0pt plus.13em }
-\def\urefpoststretch{\allowbreak \hskip0pt plus.1em }
-\def\urefcodedot{\urefprestretch .\urefpoststretch}
-\def\urefcodehash{\urefprestretch \#\urefpoststretch}
-\def\urefcodequestion{\urefprestretch ?\urefpoststretch}
-\def\urefcodeslash{\futurelet\next\urefcodeslashfinish}
-{
-  \catcode`\/=\active
-  \global\def\urefcodeslashfinish{%
-    \urefprestretch \slashChar
-    % Allow line break only after the final / in a sequence of
-    % slashes, to avoid line break between the slashes in http://.
-    \ifx\next/\else \urefpoststretch \fi
-  }
-}
-\def\codex #1{\tclose{#1}\endgroup}
 
 % An additional complication: the above will allow breaks after, e.g.,
 % each of the four underscores in __typeof__.  This is undesirable in
@@ -2559,10 +2555,156 @@
     \allowcodebreaksfalse
   \else
     \errhelp = \EMsimple
-    \errmessage{Unknown @allowcodebreaks option `\txiarg'}%
+    \errmessage{Unknown @allowcodebreaks option `\txiarg', must be true|false}%
   \fi\fi
 }
 
+% @uref (abbreviation for `urlref') takes an optional (comma-separated)
+% second argument specifying the text to display and an optional third
+% arg as text to display instead of (rather than in addition to) the url
+% itself.  First (mandatory) arg is the url.
+% (This \urefnobreak definition isn't used now, leaving it for a while
+% for comparison.)
+\def\urefnobreak#1{\dourefnobreak #1,,,\finish}
+\def\dourefnobreak#1,#2,#3,#4\finish{\begingroup
+  \unsepspaces
+  \pdfurl{#1}%
+  \setbox0 = \hbox{\ignorespaces #3}%
+  \ifdim\wd0 > 0pt
+    \unhbox0 % third arg given, show only that
+  \else
+    \setbox0 = \hbox{\ignorespaces #2}%
+    \ifdim\wd0 > 0pt
+      \ifpdf
+        \unhbox0             % PDF: 2nd arg given, show only it
+      \else
+        \unhbox0\ (\code{#1})% DVI: 2nd arg given, show both it and url
+      \fi
+    \else
+      \code{#1}% only url given, so show it
+    \fi
+  \fi
+  \endlink
+\endgroup}
+
+% This \urefbreak definition is the active one.
+\def\urefbreak{\begingroup \urefcatcodes \dourefbreak}
+\let\uref=\urefbreak
+\def\dourefbreak#1{\urefbreakfinish #1,,,\finish}
+\def\urefbreakfinish#1,#2,#3,#4\finish{% doesn't work in @example
+  \unsepspaces
+  \pdfurl{#1}%
+  \setbox0 = \hbox{\ignorespaces #3}%
+  \ifdim\wd0 > 0pt
+    \unhbox0 % third arg given, show only that
+  \else
+    \setbox0 = \hbox{\ignorespaces #2}%
+    \ifdim\wd0 > 0pt
+      \ifpdf
+        \unhbox0             % PDF: 2nd arg given, show only it
+      \else
+        \unhbox0\ (\urefcode{#1})% DVI: 2nd arg given, show both it and url
+      \fi
+    \else
+      \urefcode{#1}% only url given, so show it
+    \fi
+  \fi
+  \endlink
+\endgroup}
+
+% Allow line breaks around only a few characters (only).
+\def\urefcatcodes{%
+  \catcode\ampChar=\active   \catcode\dotChar=\active
+  \catcode\hashChar=\active  \catcode\questChar=\active
+  \catcode\slashChar=\active
+}
+{
+  \urefcatcodes
+  %
+  \global\def\urefcode{\begingroup
+    \setupmarkupstyle{code}%
+    \urefcatcodes
+    \let&\urefcodeamp
+    \let.\urefcodedot
+    \let#\urefcodehash
+    \let?\urefcodequest
+    \let/\urefcodeslash
+    \codex
+  }
+  %
+  % By default, they are just regular characters.
+  \global\def&{\normalamp}
+  \global\def.{\normaldot}
+  \global\def#{\normalhash}
+  \global\def?{\normalquest}
+  \global\def/{\normalslash}
+}
+
+% we put a little stretch before and after the breakable chars, to help
+% line breaking of long url's.  The unequal skips make look better in
+% cmtt at least, especially for dots.
+\def\urefprestretch{\urefprebreak \hskip0pt plus.13em }
+\def\urefpoststretch{\urefpostbreak \hskip0pt plus.1em }
+%
+\def\urefcodeamp{\urefprestretch \&\urefpoststretch}
+\def\urefcodedot{\urefprestretch .\urefpoststretch}
+\def\urefcodehash{\urefprestretch \#\urefpoststretch}
+\def\urefcodequest{\urefprestretch ?\urefpoststretch}
+\def\urefcodeslash{\futurelet\next\urefcodeslashfinish}
+{
+  \catcode`\/=\active
+  \global\def\urefcodeslashfinish{%
+    \urefprestretch \slashChar
+    % Allow line break only after the final / in a sequence of
+    % slashes, to avoid line break between the slashes in http://.
+    \ifx\next/\else \urefpoststretch \fi
+  }
+}
+
+% One more complication: by default we'll break after the special
+% characters, but some people like to break before the special chars, so
+% allow that.  Also allow no breaking at all, for manual control.
+% 
+\parseargdef\urefbreakstyle{%
+  \def\txiarg{#1}%
+  \ifx\txiarg\wordnone
+    \def\urefprebreak{\nobreak}\def\urefpostbreak{\nobreak}
+  \else\ifx\txiarg\wordbefore
+    \def\urefprebreak{\allowbreak}\def\urefpostbreak{\nobreak}
+  \else\ifx\txiarg\wordafter
+    \def\urefprebreak{\nobreak}\def\urefpostbreak{\allowbreak}
+  \else
+    \errhelp = \EMsimple
+    \errmessage{Unknown @urefbreakstyle setting `\txiarg'}%
+  \fi\fi\fi
+}
+\def\wordafter{after}
+\def\wordbefore{before}
+\def\wordnone{none}
+
+\urefbreakstyle after
+
+% @url synonym for @uref, since that's how everyone uses it.
+%
+\let\url=\uref
+
+% rms does not like angle brackets --karl, 17may97.
+% So now @email is just like @uref, unless we are pdf.
+%
+%\def\email#1{\angleleft{\tt #1}\angleright}
+\ifpdf
+  \def\email#1{\doemail#1,,\finish}
+  \def\doemail#1,#2,#3\finish{\begingroup
+    \unsepspaces
+    \pdfurl{mailto:#1}%
+    \setbox0 = \hbox{\ignorespaces #2}%
+    \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
+    \endlink
+  \endgroup}
+\else
+  \let\email=\uref
+\fi
+
 % @kbd is like @code, except that if the argument is just one @key command,
 % then @kbd has no effect.
 \def\kbd#1{{\setupmarkupstyle{kbd}\def\look{#1}\expandafter\kbdfoo\look??\par}}
@@ -2580,7 +2722,7 @@
     \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
   \else
     \errhelp = \EMsimple
-    \errmessage{Unknown @kbdinputstyle option `\txiarg'}%
+    \errmessage{Unknown @kbdinputstyle setting `\txiarg'}%
   \fi\fi\fi
 }
 \def\worddistinct{distinct}
@@ -2608,79 +2750,6 @@
 \parseargdef\clickstyle{\def\click{#1}}
 \def\click{\arrow}
 
-% @uref (abbreviation for `urlref') takes an optional (comma-separated)
-% second argument specifying the text to display and an optional third
-% arg as text to display instead of (rather than in addition to) the url
-% itself.  First (mandatory) arg is the url.  Perhaps eventually put in
-% a hypertex \special here.
-%
-\def\uref#1{\douref #1,,,\finish}
-\def\douref#1,#2,#3,#4\finish{\begingroup
-  \unsepspaces
-  \pdfurl{#1}%
-  \setbox0 = \hbox{\ignorespaces #3}%
-  \ifdim\wd0 > 0pt
-    \unhbox0 % third arg given, show only that
-  \else
-    \setbox0 = \hbox{\ignorespaces #2}%
-    \ifdim\wd0 > 0pt
-      \ifpdf
-        \unhbox0             % PDF: 2nd arg given, show only it
-      \else
-        \unhbox0\ (\code{#1})% DVI: 2nd arg given, show both it and url
-      \fi
-    \else
-      \code{#1}% only url given, so show it
-    \fi
-  \fi
-  \endlink
-\endgroup}
-
-\def\nouref#1,#2,#3,#4\finish{\begingroup  % doesn't work in @example
-  \unsepspaces
-  \pdfurl{#1}%
-  \setbox0 = \hbox{\ignorespaces #3}%
-  \ifdim\wd0 > 0pt
-    \unhbox0 % third arg given, show only that
-  \else
-    \setbox0 = \hbox{\ignorespaces #2}%
-    \ifdim\wd0 > 0pt
-      \ifpdf
-        \unhbox0             % PDF: 2nd arg given, show only it
-      \else
-        % \empty at the end of \scantokens arg gets rid of
-        % trailing newline (and ultimate spurious whitespace).
-        \unhbox0\ (\urefcode{\scantokens{#1\empty}})% DVI: 2nd arg given,
-                                                    % show both it and url
-      \fi
-    \else
-      \urefcode{\scantokens{#1\empty}}% only url given, so show it
-    \fi
-  \fi
-  \endlink
-\endgroup}
-
-% @url synonym for @uref, since that's how everyone uses it.
-%
-\let\url=\uref
-
-% rms does not like angle brackets --karl, 17may97.
-% So now @email is just like @uref, unless we are pdf.
-%
-%\def\email#1{\angleleft{\tt #1}\angleright}
-\ifpdf
-  \def\email#1{\doemail#1,,\finish}
-  \def\doemail#1,#2,#3\finish{\begingroup
-    \unsepspaces
-    \pdfurl{mailto:#1}%
-    \setbox0 = \hbox{\ignorespaces #2}%
-    \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
-    \endlink
-  \endgroup}
-\else
-  \let\email=\uref
-\fi
-
 % Typeset a dimension, e.g., `in' or `pt'.  The only reason for the
 % argument is to make the input look right: @dmn{pt} instead of @dmn{}pt.
 %
@@ -3068,7 +3137,7 @@
 %  Textures 1.7.7 (preloaded format=plain 93.10.14)  (68K)  16 APR 2004 02:38
 % so we'll define it if necessary.
 %
-\ifx\Orb\undefined
+\ifx\Orb\thisisundefined
 \def\Orb{\mathhexbox20D}
 \fi
 
@@ -3343,7 +3412,7 @@
 % This produces Day Month Year style of output.
 % Only define if not already defined, in case a txi-??.tex file has set
 % up a different format (e.g., txi-cs.tex does this).
-\ifx\today\undefined
+\ifx\today\thisisundefined
 \def\today{%
   \number\day\space
   \ifcase\month
@@ -5677,6 +5746,8 @@
 %
 \def\sectionheading#1#2#3#4{%
   {%
+    \checkenv{}% should not be in an environment.
+    %
     % Switch to the right set of fonts.
     \csname #2fonts\endcsname \rmisbold
     %
@@ -6422,7 +6493,7 @@
 %
 \def\Equotation{%
   \par
-  \ifx\quotationauthor\undefined\else
+  \ifx\quotationauthor\thisisundefined\else
     % indent a bit.
     \leftline{\kern 2\leftskip \sl ---\quotationauthor}%
   \fi
@@ -6957,7 +7028,7 @@
 
 % To do this right we need a feature of e-TeX, \scantokens,
 % which we arrange to emulate with a temporary file in ordinary TeX.
-\ifx\eTeXversion\undefined
+\ifx\eTeXversion\thisisundefined
   \newwrite\macscribble
   \def\scantokens#1{%
     \toks0={#1}%
@@ -7379,6 +7450,27 @@
   \fi
 }
 
+% @xrefautosectiontitle on|off says whether @section(ing) names are used
+% automatically in xrefs, if the third arg is not explicitly specified.
+% This was provided as a "secret" @set xref-automatic-section-title
+% variable, now it's official.
+% 
+\parseargdef\xrefautomaticsectiontitle{%
+  \def\temp{#1}%
+  \ifx\temp\onword
+    \expandafter\let\csname SETxref-automatic-section-title\endcsname
+      = \empty
+  \else\ifx\temp\offword
+    \expandafter\let\csname SETxref-automatic-section-title\endcsname
+      = \relax
+  \else
+    \errhelp = \EMsimple
+    \errmessage{Unknown @xrefautomaticsectiontitle value `\temp',
+                must be on|off}%
+  \fi\fi
+}
+
+
 % @xref, @pxref, and @ref generate cross-references.  For \xrefX, #1 is
 % the node name, #2 the name of the Info cross-reference, #3 the printed
 % node name, #4 the name of the Info file, #5 the name of the printed
@@ -7395,7 +7487,7 @@
   \setbox0=\hbox{\printedrefname\unskip}%
   \ifdim \wd0 = 0pt
     % No printed node name was explicitly given.
-    \expandafter\ifx\csname SETxref-automatic-section-title\endcsname\relax
+    \expandafter\ifx\csname SETxref-automatic-section-title\endcsname \relax
       % Use the node name inside the square brackets.
       \def\printedrefname{\ignorespaces #1}%
     \else
@@ -7865,7 +7957,7 @@
   it from ftp://tug.org/tex/epsf.tex.}
 %
 \def\image#1{%
-  \ifx\epsfbox\undefined
+  \ifx\epsfbox\thisiundefined
     \ifwarnednoepsf \else
       \errhelp = \noepsfhelp
       \errmessage{epsf.tex not found, images will be ignored}%
@@ -8360,7 +8452,7 @@
   \gdef^^b9{$^1$}
   \gdef^^ba{\ordm}
   %
-  \gdef^^bb{\guilletright}
+  \gdef^^bb{\guillemetright}
   \gdef^^bc{$1\over4$}
   \gdef^^bd{$1\over2$}
   \gdef^^be{$3\over4$}
@@ -9305,24 +9397,15 @@
 \catcode`\^^? = 14
 
 % Define macros to output various characters with catcode for normal text.
-\catcode`\"=\other
-\catcode`\~=\other
-\catcode`\^=\other
-\catcode`\_=\other
-\catcode`\|=\other
-\catcode`\<=\other
-\catcode`\>=\other
-\catcode`\+=\other
-\catcode`\$=\other
-\def\normaldoublequote{"}
-\def\normaltilde{~}
-\def\normalcaret{^}
-\def\normalunderscore{_}
-\def\normalverticalbar{|}
-\def\normalless{<}
-\def\normalgreater{>}
-\def\normalplus{+}
-\def\normaldollar{$}%$ font-lock fix
+\catcode`\"=\other \def\normaldoublequote{"}
+\catcode`\$=\other \def\normaldollar{$}%$ font-lock fix
+\catcode`\+=\other \def\normalplus{+}
+\catcode`\<=\other \def\normalless{<}
+\catcode`\>=\other \def\normalgreater{>}
+\catcode`\^=\other \def\normalcaret{^}
+\catcode`\_=\other \def\normalunderscore{_}
+\catcode`\|=\other \def\normalverticalbar{|}
+\catcode`\~=\other \def\normaltilde{~}
 
 % This macro is used to make a character print one way in \tt
 % (where it can probably be output as-is), and another way in other fonts,
@@ -9415,16 +9498,16 @@
 % the literal character `\'.
 %
 @def@normalturnoffactive{%
+  @let"=@normaldoublequote
+  @let$=@normaldollar %$ font-lock fix
+  @let+=@normalplus
+  @let<=@normalless
+  @let>=@normalgreater
   @let\=@normalbackslash
-  @let"=@normaldoublequote
-  @let~=@normaltilde
   @let^=@normalcaret
   @let_=@normalunderscore
   @let|=@normalverticalbar
-  @let<=@normalless
-  @let>=@normalgreater
-  @let+=@normalplus
-  @let$=@normaldollar %$ font-lock fix
+  @let~=@normaltilde
   @markupsetuplqdefault
   @markupsetuprqdefault
   @unsepspaces
@@ -9456,10 +9539,16 @@
 % Say @foo, not \foo, in error messages.
 @escapechar = `@@
 
+% These (along with & and #) are made active for url-breaking, so need
+% active definitions as the normal characters.
+@def@normaldot{.}
+@def@normalquest{?}
+@def@normalslash{/}
+
 % These look ok in all fonts, so just make them not special.
-@catcode`@& = @other
-@catcode`@# = @other
-@catcode`@% = @other
+@catcode`@& = @other @def@normalamp{&}
+@catcode`@# = @other @def@normalhash{#}
+@catcode`@% = @other @def@normalpercent{%}
 
 @c Finally, make ` and ' active, so that txicodequoteundirected and
 @c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}.  If we
--- a/doc/gendocs_template
+++ b/doc/gendocs_template
@@ -3,12 +3,6 @@
 <!--#include virtual="/server/banner.html" -->
 <h2>%%TITLE%%</h2>
 
-<!-- This document is in XML, and xhtml 1.0 -->
-<!-- Please make sure to properly nest your tags -->
-<!-- and ensure that your final document validates -->
-<!-- consistent with W3C xhtml 1.0 and CSS standards -->
-<!-- See validator.w3.org -->
-
 <address>Free Software Foundation</address>
 <address>last updated %%DATE%%</address>
 
@@ -66,29 +60,28 @@
 <p>(This page generated by the <a href="%%SCRIPTURL%%">%%SCRIPTNAME%%
 script</a>.)</p>
 
-<!-- If needed, change the copyright block at the bottom. In general, -->
-<!-- all pages on the GNU web server should have the section about    -->
-<!-- verbatim copying.  Please do NOT remove this without talking     -->
-<!-- with the webmasters first. -->
-<!-- Please make sure the copyright date is consistent with the document -->
-<!-- and that it is like this "2001, 2002" not this "2001-2002." -->
+<!-- If needed, change the copyright block at the bottom. In general,
+     all pages on the GNU web server should have the section about
+     verbatim copying.  Please do NOT remove this without talking
+     with the webmasters first.
+     Please make sure the copyright date is consistent with the document
+     and that it is like this: "2001, 2002", not this: "2001-2002". -->
 </div><!-- for id="content", starts in the include above -->
 <!--#include virtual="/server/footer.html" -->
 <div id="footer">
 
-<p>
-Please send FSF &amp; GNU inquiries to
+<p>Please send general FSF &amp; GNU inquiries to
 <a href="mailto:gnu@gnu.org">&lt;gnu@gnu.org&gt;</a>.
 There are also <a href="/contact/">other ways to contact</a>
 the FSF.<br />
 Please send broken links and other corrections or suggestions to
-<a href="mailto:%%EMAIL%%">&lt;%%EMAIL%%&gt;</a>.
-</p>
+<a href="mailto:%%EMAIL%%">&lt;%%EMAIL%%&gt;</a>.</p>
+
+<p>Copyright &copy; 2011 Free Software Foundation, Inc.</p>
 
-<p>Copyright &copy; 2010 Free Software Foundation, Inc.</p>
-
-<p>Verbatim copying and distribution of this entire article is
-permitted in any medium, provided this notice is preserved.</p>
+<p>Verbatim copying and distribution of this entire article are
+permitted worldwide, without royalty, in any medium, provided this
+notice, and the copyright notice, are preserved.</p>
 
 </div>
 </div>
--- a/doc/gendocs_template_min
+++ b/doc/gendocs_template_min
@@ -10,12 +10,6 @@
 <link rev="made" href="webmasters@gnu.org" />
 </head>
 
-<!-- This document is in XML, and xhtml 1.0 -->
-<!-- Please make sure to properly nest your tags -->
-<!-- and ensure that your final document validates -->
-<!-- consistent with W3C xhtml 1.0 and CSS standards -->
-<!-- See validator.w3.org -->
-
 <body>
 
 <h3>%%TITLE%%</h3>
@@ -80,22 +74,21 @@
 <p>(This page generated by the <a href="%%SCRIPTURL%%">%%SCRIPTNAME%%
 script</a>.)</p>
 
-<div class="copyright">
-<p>
-Please send FSF &amp; GNU inquiries to
+<div id="footer" class="copyright">
+
+<p>Please send general FSF &amp; GNU inquiries to
 <a href="mailto:gnu@gnu.org">&lt;gnu@gnu.org&gt;</a>.
 There are also <a href="/contact/">other ways to contact</a>
 the FSF.<br />
-Please send broken links and other corrections (or suggestions) to
-<a href="mailto:%%EMAIL%%">&lt;%%EMAIL%%&gt;</a>.
-</p>
+Please send broken links and other corrections or suggestions to
+<a href="mailto:%%EMAIL%%">&lt;%%EMAIL%%&gt;</a>.</p>
 
-<p>Copyright &copy; 2010 Free Software Foundation, Inc.</p>
+<p>Copyright &copy; 2011 Free Software Foundation, Inc.</p>
 
-<p>Verbatim copying and distribution of this entire article is
-permitted in any medium, provided this notice is preserved.</p>
+<p>Verbatim copying and distribution of this entire article are
+permitted worldwide, without royalty, in any medium, provided this
+notice, and the copyright notice, are preserved.</p>
 
 </div>
-
 </body>
 </html>
--- a/doc/glibc-functions/getloadavg.texi
+++ b/doc/glibc-functions/getloadavg.texi
@@ -8,7 +8,7 @@
 @itemize
 @item
 This function is missing on some platforms:
-AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Cygwin, mingw, Interix 3.5, BeOS.
+AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 2.6, Cygwin, mingw, Interix 3.5, BeOS.
 @item
 This function is declared in @code{<sys/loadavg.h>}, not @code{<stdlib.h>},
 on some platforms:
--- a/doc/gnulib-tool.texi
+++ b/doc/gnulib-tool.texi
@@ -483,6 +483,14 @@
 were integrated into Gnulib and now mismatch the @file{po/} infrastructure.
 In this case, fetch and install the new GNU gettext release and run
 @code{gettextize} followed by @code{gnulib-tool}.
+
+@item
+When you invoke @code{autoreconf} after @code{gnulib-tool}, make sure to
+not invoke @code{autopoint} a second time, by setting the @code{AUTOPOINT}
+environment variable, like this:
+@smallexample
+$ env AUTOPOINT=true autoreconf --install
+@end smallexample
 @end enumerate
 
 
--- a/doc/posix-functions/fdopendir.texi
+++ b/doc/posix-functions/fdopendir.texi
@@ -23,6 +23,10 @@
 This function does not reject non-directory file descriptors on some
 platforms:
 GNU/Hurd.
+@item
+This function mistakenly closes non-directory file descriptors on some
+platforms:
+FreeBSD 8.1.
 @end itemize
 
 Portability problems not fixed by Gnulib:
--- a/doc/posix-functions/getaddrinfo.texi
+++ b/doc/posix-functions/getaddrinfo.texi
@@ -11,11 +11,11 @@
 @item
 This function is missing on some platforms:
 HP-UX 11.11, IRIX 6.5, OSF/1 5.1, Solaris 7, Cygwin 1.5.x, mingw, Interix 3.5, BeOS.
+@item
+On Windows, this function is declared in @code{<ws2tcpip.h>} rather than in
+@code{<netdb.h>}.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
-@item
-On Windows, this function is declared in @code{<ws2tcpip.h>} rather than in
-@code{<netdb.h>}.
 @end itemize
--- a/doc/posix-functions/iswalnum.texi
+++ b/doc/posix-functions/iswalnum.texi
@@ -4,7 +4,7 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/iswalnum.html}
 
-Gnulib module: wctype
+Gnulib module: wctype-h
 
 Portability problems fixed by Gnulib:
 @itemize
--- a/doc/posix-functions/iswalpha.texi
+++ b/doc/posix-functions/iswalpha.texi
@@ -4,7 +4,7 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/iswalpha.html}
 
-Gnulib module: wctype
+Gnulib module: wctype-h
 
 Portability problems fixed by Gnulib:
 @itemize
--- a/doc/posix-functions/iswblank.texi
+++ b/doc/posix-functions/iswblank.texi
@@ -4,7 +4,7 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/iswblank.html}
 
-Gnulib module: wctype
+Gnulib module: iswblank
 
 Portability problems fixed by Gnulib:
 @itemize
@@ -15,6 +15,9 @@
 This function is declared but not defined on some platforms:
 IRIX 6.5.30.
 @item
+This function is not declared (without @code{-D_GNU_SOURCE}) on some platforms:
+glibc 2.8.
+@item
 This function returns 0 for all possible arguments on some platforms:
 Linux libc5.
 @end itemize
--- a/doc/posix-functions/iswcntrl.texi
+++ b/doc/posix-functions/iswcntrl.texi
@@ -4,7 +4,7 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/iswcntrl.html}
 
-Gnulib module: wctype
+Gnulib module: wctype-h
 
 Portability problems fixed by Gnulib:
 @itemize
--- a/doc/posix-functions/iswctype.texi
+++ b/doc/posix-functions/iswctype.texi
@@ -4,18 +4,22 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/iswctype.html}
 
-Gnulib module: ---
+Gnulib module: iswctype
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This function is missing on some platforms:
+IRIX 5.3, Solaris 2.5.1.
+@item
+This function is declared in @code{<wchar.h>}, not in @code{<wctype.h>}, on
+some platforms:
+HP-UX 11.00.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function is missing on some platforms:
-IRIX 5.3, Solaris 2.5.1.
-@item
 On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
 @end itemize
--- a/doc/posix-functions/iswdigit.texi
+++ b/doc/posix-functions/iswdigit.texi
@@ -4,7 +4,7 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/iswdigit.html}
 
-Gnulib module: wctype
+Gnulib module: wctype-h
 
 Portability problems fixed by Gnulib:
 @itemize
--- a/doc/posix-functions/iswgraph.texi
+++ b/doc/posix-functions/iswgraph.texi
@@ -4,7 +4,7 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/iswgraph.html}
 
-Gnulib module: wctype
+Gnulib module: wctype-h
 
 Portability problems fixed by Gnulib:
 @itemize
--- a/doc/posix-functions/iswlower.texi
+++ b/doc/posix-functions/iswlower.texi
@@ -4,7 +4,7 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/iswlower.html}
 
-Gnulib module: wctype
+Gnulib module: wctype-h
 
 Portability problems fixed by Gnulib:
 @itemize
--- a/doc/posix-functions/iswprint.texi
+++ b/doc/posix-functions/iswprint.texi
@@ -4,7 +4,7 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/iswprint.html}
 
-Gnulib module: wctype
+Gnulib module: wctype-h
 
 Portability problems fixed by Gnulib:
 @itemize
--- a/doc/posix-functions/iswpunct.texi
+++ b/doc/posix-functions/iswpunct.texi
@@ -4,7 +4,7 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/iswpunct.html}
 
-Gnulib module: wctype
+Gnulib module: wctype-h
 
 Portability problems fixed by Gnulib:
 @itemize
--- a/doc/posix-functions/iswspace.texi
+++ b/doc/posix-functions/iswspace.texi
@@ -4,7 +4,7 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/iswspace.html}
 
-Gnulib module: wctype
+Gnulib module: wctype-h
 
 Portability problems fixed by Gnulib:
 @itemize
--- a/doc/posix-functions/iswupper.texi
+++ b/doc/posix-functions/iswupper.texi
@@ -4,7 +4,7 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/iswupper.html}
 
-Gnulib module: wctype
+Gnulib module: wctype-h
 
 Portability problems fixed by Gnulib:
 @itemize
--- a/doc/posix-functions/iswxdigit.texi
+++ b/doc/posix-functions/iswxdigit.texi
@@ -4,7 +4,7 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/iswxdigit.html}
 
-Gnulib module: wctype
+Gnulib module: wctype-h
 
 Portability problems fixed by Gnulib:
 @itemize
--- a/doc/posix-functions/mbrtowc.texi
+++ b/doc/posix-functions/mbrtowc.texi
@@ -30,7 +30,7 @@
 This function returns the total number of bytes that make up the multibyte
 character, not the number of bytes that were needed to complete the multibyte
 character, on some platforms:
-HP-UX 11.11, Solaris 11 2010-11.
+HP-UX 11.11, Solaris 11 2010-11, mingw.
 @item
 This function may not return 0 when parsing the NUL character on some platforms:
 Solaris 9.
--- a/doc/posix-functions/mbsinit.texi
+++ b/doc/posix-functions/mbsinit.texi
@@ -11,6 +11,9 @@
 @item
 This function is missing on some platforms:
 HP-UX 11.00, IRIX 6.5, Solaris 2.6, Interix 3.5.
+@item
+This function always returns 1, even in multibyte locales, on some platforms:
+mingw.
 @end itemize
 
 Portability problems not fixed by Gnulib:
--- a/doc/posix-functions/mbsrtowcs.texi
+++ b/doc/posix-functions/mbsrtowcs.texi
@@ -14,6 +14,9 @@
 @item
 This function does not work on some platforms:
 HP-UX 11, Solaris 11 2010-11.
+@item
+This function does not work when the first argument is NULL on some platforms:
+mingw.
 @end itemize
 
 Portability problems not fixed by Gnulib:
--- a/doc/posix-functions/mbtowc.texi
+++ b/doc/posix-functions/mbtowc.texi
@@ -4,7 +4,7 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/mbtowc.html}
 
-Gnulib module: ---
+Gnulib module: mbtowc
 
 Portability problems fixed by Gnulib:
 @itemize
--- a/doc/posix-functions/realloc.texi
+++ b/doc/posix-functions/realloc.texi
@@ -16,6 +16,19 @@
 
 Portability problems not fixed by Gnulib:
 @itemize
+@item
+It is not portable to call @code{realloc} with a size of 0.  With a
+NULL pointer argument, this is the same ambiguity as @code{malloc (0)}
+on whether a unique zero-size object is created.  With a non-NULL
+pointer argument, C99 requires that if @code{realloc (p, 0)} returns
+@code{NULL} then @code{p} is still valid.  Among implementations that
+obey C99, behavior varies on whether @code{realloc (p, 0)} always
+fails and leaves @code{p} valid, or usually succeeds and returns a
+unique zero-size object; either way, a program not suspecting these
+semantics will leak memory (either the still-valid @code{p}, or the
+non-NULL return value).  Meanwhile, several implementations violate
+C99, by always calling @code{free (p)} but returning NULL:
+glibc, Cygwin
 @end itemize
 
 Extension: Gnulib provides a module @samp{realloc-gnu} that substitutes a
--- a/doc/posix-functions/setlocale.texi
+++ b/doc/posix-functions/setlocale.texi
@@ -4,10 +4,22 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/setlocale.html}
 
-Gnulib module: ---
+Gnulib module: setlocale
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+On Windows platforms (excluding Cygwin), @code{setlocale(@var{category},NULL)}
+ignores the environment variables @code{LC_ALL}, @code{@var{category}}, and
+@code{LANG}.
+@item
+On Windows platforms (excluding Cygwin), @code{setlocale(LC_ALL,@var{name})}
+succeeds and sets the LC_CTYPE category to @samp{C} when it does not support
+the encoding, instead of failing.
+@item
+On Windows platforms (excluding Cygwin), @code{setlocale} understands different
+locale names, that are not based on ISO 639 language names and ISO 3166 country
+names.
 @end itemize
 
 Portability problems not fixed by Gnulib:
@@ -15,7 +27,6 @@
 @item
 On Cygwin 1.5.x, which doesn't have locales,
 @code{setlocale(LC_ALL,NULL)} always returns @code{"C"}.
-
 @item
 On Cygwin 1.7.0, only the charset portion of a locale designation is honored.
 @end itemize
--- a/doc/posix-functions/strerror_r.texi
+++ b/doc/posix-functions/strerror_r.texi
@@ -12,7 +12,8 @@
 This function is missing on some platforms:
 NetBSD 3.0, HP-UX 11.23, IRIX 6.5, Solaris 9, mingw.
 @item
-glibc has an incompatible version of this function.  The POSIX compliant code
+glibc and Cygwin have an incompatible version of this function.  The
+POSIX compliant code
 @smallexample
 char *s = (strerror_r (err, buf, buflen) == 0 ? buf : NULL);
 @end smallexample
--- a/doc/posix-functions/towctrans.texi
+++ b/doc/posix-functions/towctrans.texi
@@ -4,18 +4,18 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/towctrans.html}
 
-Gnulib module: ---
+Gnulib module: towctrans
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This function is missing on some platforms:
+HP-UX 11.00, IRIX 6.5, Solaris 2.5.1, mingw, Interix 3.5.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function is missing on some platforms:
-HP-UX 11.00, IRIX 6.5, Solaris 2.5.1, mingw, Interix 3.5.
-@item
 On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
 @end itemize
--- a/doc/posix-functions/towlower.texi
+++ b/doc/posix-functions/towlower.texi
@@ -4,7 +4,7 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/towlower.html}
 
-Gnulib module: wctype
+Gnulib module: wctype-h
 
 Portability problems fixed by Gnulib:
 @itemize
--- a/doc/posix-functions/towupper.texi
+++ b/doc/posix-functions/towupper.texi
@@ -4,7 +4,7 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/towupper.html}
 
-Gnulib module: wctype
+Gnulib module: wctype-h
 
 Portability problems fixed by Gnulib:
 @itemize
--- a/doc/posix-functions/unsetenv.texi
+++ b/doc/posix-functions/unsetenv.texi
@@ -25,7 +25,7 @@
 @item
 This function removes only the first value association for the given
 environment variable, not all of them, on some platforms:
-Solaris 11 2010-11.
+Solaris 11 2010-11, Haiku.
 @end itemize
 
 Portability problems not fixed by Gnulib:
--- a/doc/posix-functions/wcpcpy.texi
+++ b/doc/posix-functions/wcpcpy.texi
@@ -4,19 +4,19 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/wcpcpy.html}
 
-Gnulib module: ---
+Gnulib module: wcpcpy
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This function is missing on some platforms:
+MacOS X 10.5, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, AIX 4.3.2, HP-UX 11,
+IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x, mingw, Interix 3.5, BeOS.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function is missing on some platforms:
-MacOS X 10.5, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, AIX 4.3.2, HP-UX
-11, IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x, mingw, Interix 3.5, BeOS.
-@item
 On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
 @end itemize
--- a/doc/posix-functions/wcpncpy.texi
+++ b/doc/posix-functions/wcpncpy.texi
@@ -4,19 +4,19 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/wcpncpy.html}
 
-Gnulib module: ---
+Gnulib module: wcpncpy
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This function is missing on some platforms:
+MacOS X 10.5, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, AIX 4.3.2, HP-UX 11,
+IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x, mingw, Interix 3.5, BeOS.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function is missing on some platforms:
-MacOS X 10.5, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, AIX 4.3.2, HP-UX
-11, IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x, mingw, Interix 3.5, BeOS.
-@item
 On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
 @end itemize
--- a/doc/posix-functions/wcscasecmp.texi
+++ b/doc/posix-functions/wcscasecmp.texi
@@ -4,19 +4,19 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/wcscasecmp.html}
 
-Gnulib module: ---
+Gnulib module: wcscasecmp
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This function is missing on some platforms:
+MacOS X 10.5, FreeBSD 6.0, NetBSD 3.0, OpenBSD 3.8, AIX 4.3.2, HP-UX 11,
+IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x, mingw.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function is missing on some platforms:
-MacOS X 10.5, FreeBSD 6.0, NetBSD 3.0, OpenBSD 3.8, AIX 4.3.2, HP-UX
-11, IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x, mingw.
-@item
 On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
 @end itemize
--- a/doc/posix-functions/wcscat.texi
+++ b/doc/posix-functions/wcscat.texi
@@ -4,18 +4,18 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/wcscat.html}
 
-Gnulib module: ---
+Gnulib module: wcscat
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This function is missing on some platforms:
+IRIX 5.3, Solaris 2.5.1.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function is missing on some platforms:
-IRIX 5.3, Solaris 2.5.1.
-@item
 On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
 @end itemize
--- a/doc/posix-functions/wcschr.texi
+++ b/doc/posix-functions/wcschr.texi
@@ -4,18 +4,18 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/wcschr.html}
 
-Gnulib module: ---
+Gnulib module: wcschr
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This function is missing on some platforms:
+IRIX 5.3, Solaris 2.5.1.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function is missing on some platforms:
-IRIX 5.3, Solaris 2.5.1.
-@item
 On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
 @end itemize
--- a/doc/posix-functions/wcscmp.texi
+++ b/doc/posix-functions/wcscmp.texi
@@ -4,18 +4,18 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/wcscmp.html}
 
-Gnulib module: ---
+Gnulib module: wcscmp
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This function is missing on some platforms:
+IRIX 5.3, Solaris 2.5.1.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function is missing on some platforms:
-IRIX 5.3, Solaris 2.5.1.
-@item
 On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
 @end itemize
--- a/doc/posix-functions/wcscoll.texi
+++ b/doc/posix-functions/wcscoll.texi
@@ -4,18 +4,18 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/wcscoll.html}
 
-Gnulib module: ---
+Gnulib module: wcscoll
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This function is missing on some platforms:
+IRIX 5.3, Solaris 2.5.1.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function is missing on some platforms:
-IRIX 5.3, Solaris 2.5.1.
-@item
 On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
 @end itemize
--- a/doc/posix-functions/wcscpy.texi
+++ b/doc/posix-functions/wcscpy.texi
@@ -4,18 +4,18 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/wcscpy.html}
 
-Gnulib module: ---
+Gnulib module: wcscpy
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This function is missing on some platforms:
+IRIX 5.3, Solaris 2.5.1.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function is missing on some platforms:
-IRIX 5.3, Solaris 2.5.1.
-@item
 On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
 @end itemize
--- a/doc/posix-functions/wcscspn.texi
+++ b/doc/posix-functions/wcscspn.texi
@@ -4,18 +4,18 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/wcscspn.html}
 
-Gnulib module: ---
+Gnulib module: wcscspn
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This function is missing on some platforms:
+IRIX 5.3, Solaris 2.5.1.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function is missing on some platforms:
-IRIX 5.3, Solaris 2.5.1.
-@item
 On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
 @end itemize
--- a/doc/posix-functions/wcsdup.texi
+++ b/doc/posix-functions/wcsdup.texi
@@ -4,19 +4,19 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/wcsdup.html}
 
-Gnulib module: ---
+Gnulib module: wcsdup
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This function is missing on some platforms:
+MacOS X 10.5, FreeBSD 6.0, NetBSD 3.0, OpenBSD 3.8, AIX 4.3.2, HP-UX 11,
+IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x, BeOS.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function is missing on some platforms:
-MacOS X 10.5, FreeBSD 6.0, NetBSD 3.0, OpenBSD 3.8, AIX 4.3.2, HP-UX
-11, IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x, BeOS.
-@item
 On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
 @end itemize
--- a/doc/posix-functions/wcslen.texi
+++ b/doc/posix-functions/wcslen.texi
@@ -4,18 +4,18 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/wcslen.html}
 
-Gnulib module: ---
+Gnulib module: wcslen
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This function is missing on some platforms:
+IRIX 5.3, Solaris 2.5.1.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function is missing on some platforms:
-IRIX 5.3, Solaris 2.5.1.
-@item
 On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
 @end itemize
--- a/doc/posix-functions/wcsncasecmp.texi
+++ b/doc/posix-functions/wcsncasecmp.texi
@@ -4,19 +4,19 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/wcsncasecmp.html}
 
-Gnulib module: ---
+Gnulib module: wcsncasecmp
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This function is missing on some platforms:
+MacOS X 10.5, FreeBSD 6.0, NetBSD 3.0, OpenBSD 3.8, AIX 4.3.2, HP-UX 11,
+IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x, mingw, BeOS.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function is missing on some platforms:
-MacOS X 10.5, FreeBSD 6.0, NetBSD 3.0, OpenBSD 3.8, AIX 4.3.2, HP-UX
-11, IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x, mingw, BeOS.
-@item
 On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
 @end itemize
--- a/doc/posix-functions/wcsncat.texi
+++ b/doc/posix-functions/wcsncat.texi
@@ -4,18 +4,18 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/wcsncat.html}
 
-Gnulib module: ---
+Gnulib module: wcsncat
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This function is missing on some platforms:
+IRIX 5.3, Solaris 2.5.1.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function is missing on some platforms:
-IRIX 5.3, Solaris 2.5.1.
-@item
 On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
 @end itemize
--- a/doc/posix-functions/wcsncmp.texi
+++ b/doc/posix-functions/wcsncmp.texi
@@ -4,18 +4,18 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/wcsncmp.html}
 
-Gnulib module: ---
+Gnulib module: wcsncmp
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This function is missing on some platforms:
+IRIX 5.3, Solaris 2.5.1.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function is missing on some platforms:
-IRIX 5.3, Solaris 2.5.1.
-@item
 On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
 @end itemize
--- a/doc/posix-functions/wcsncpy.texi
+++ b/doc/posix-functions/wcsncpy.texi
@@ -4,18 +4,18 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/wcsncpy.html}
 
-Gnulib module: ---
+Gnulib module: wcsncpy
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This function is missing on some platforms:
+IRIX 5.3, Solaris 2.5.1.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function is missing on some platforms:
-IRIX 5.3, Solaris 2.5.1.
-@item
 On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
 @end itemize
--- a/doc/posix-functions/wcsnlen.texi
+++ b/doc/posix-functions/wcsnlen.texi
@@ -4,19 +4,19 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/wcsnlen.html}
 
-Gnulib module: ---
+Gnulib module: wcsnlen
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This function is missing on some platforms:
+MacOS X 10.5, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, AIX 4.3.2, HP-UX 11,
+IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x, mingw, Interix 3.5, BeOS.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function is missing on some platforms:
-MacOS X 10.5, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, AIX 4.3.2, HP-UX
-11, IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x, mingw, Interix 3.5, BeOS.
-@item
 On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
 @end itemize
--- a/doc/posix-functions/wcspbrk.texi
+++ b/doc/posix-functions/wcspbrk.texi
@@ -4,18 +4,18 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/wcspbrk.html}
 
-Gnulib module: ---
+Gnulib module: wcspbrk
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This function is missing on some platforms:
+IRIX 5.3, Solaris 2.5.1.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function is missing on some platforms:
-IRIX 5.3, Solaris 2.5.1.
-@item
 On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
 @end itemize
--- a/doc/posix-functions/wcsrchr.texi
+++ b/doc/posix-functions/wcsrchr.texi
@@ -4,18 +4,18 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/wcsrchr.html}
 
-Gnulib module: ---
+Gnulib module: wcsrchr
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This function is missing on some platforms:
+IRIX 5.3, Solaris 2.5.1.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function is missing on some platforms:
-IRIX 5.3, Solaris 2.5.1.
-@item
 On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
 @end itemize
--- a/doc/posix-functions/wcsrtombs.texi
+++ b/doc/posix-functions/wcsrtombs.texi
@@ -15,6 +15,9 @@
 This function may set the source pointer to NULL before NUL terminating the destination string on some platforms:
 OSF/1 5.1.
 @item
+This function does not ignore the length argument if the destination argument is NULL on some platforms:
+mingw.
+@item
 This function updates the source pointer also if the destination argument is NULL on some platforms:
 HP-UX 11, OSF/1 5.1.
 @end itemize
--- a/doc/posix-functions/wcsspn.texi
+++ b/doc/posix-functions/wcsspn.texi
@@ -4,18 +4,18 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/wcsspn.html}
 
-Gnulib module: ---
+Gnulib module: wcsspn
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This function is missing on some platforms:
+IRIX 5.3, Solaris 2.5.1.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function is missing on some platforms:
-IRIX 5.3, Solaris 2.5.1.
-@item
 On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
 @end itemize
--- a/doc/posix-functions/wcsstr.texi
+++ b/doc/posix-functions/wcsstr.texi
@@ -4,18 +4,18 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/wcsstr.html}
 
-Gnulib module: ---
+Gnulib module: wcsstr
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This function is missing on some platforms:
+HP-UX 11.00, IRIX 5.3, Solaris 2.6.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function is missing on some platforms:
-HP-UX 11.00, IRIX 5.3, Solaris 2.6.
-@item
 On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
 @end itemize
--- a/doc/posix-functions/wcstok.texi
+++ b/doc/posix-functions/wcstok.texi
@@ -4,18 +4,18 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/wcstok.html}
 
-Gnulib module: ---
+Gnulib module: wcstok
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This function is missing on some platforms:
+IRIX 5.3, Solaris 2.5.1, Cygwin 1.5.x.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function is missing on some platforms:
-IRIX 5.3, Solaris 2.5.1, Cygwin 1.5.x.
-@item
 On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
 @end itemize
--- a/doc/posix-functions/wcswidth.texi
+++ b/doc/posix-functions/wcswidth.texi
@@ -4,18 +4,22 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/wcswidth.html}
 
-Gnulib module: ---
+Gnulib module: wcswidth
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This function is missing on some platforms:
+OpenBSD 3.8, IRIX 5.3, Solaris 2.5.1, mingw, BeOS.
+@item
+This function handles combining characters in UTF-8 locales incorrectly on some
+platforms:
+MacOS X 10.3.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function is missing on some platforms:
-OpenBSD 3.8, IRIX 5.3, Solaris 2.5.1, mingw, BeOS.
-@item
 On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
 @end itemize
--- a/doc/posix-functions/wcsxfrm.texi
+++ b/doc/posix-functions/wcsxfrm.texi
@@ -4,18 +4,18 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/wcsxfrm.html}
 
-Gnulib module: ---
+Gnulib module: wcsxfrm
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This function is missing on some platforms:
+IRIX 5.3, Solaris 2.5.1, Cygwin 1.5.x.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function is missing on some platforms:
-IRIX 5.3, Solaris 2.5.1, Cygwin 1.5.x.
-@item
 On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
 @end itemize
--- a/doc/posix-functions/wctomb.texi
+++ b/doc/posix-functions/wctomb.texi
@@ -4,7 +4,7 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/wctomb.html}
 
-Gnulib module: ---
+Gnulib module: wctomb
 
 Portability problems fixed by Gnulib:
 @itemize
--- a/doc/posix-functions/wctrans.texi
+++ b/doc/posix-functions/wctrans.texi
@@ -4,18 +4,18 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/wctrans.html}
 
-Gnulib module: ---
+Gnulib module: wctrans
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This function is missing on some platforms:
+HP-UX 11.00, IRIX 6.5, Solaris 2.5.1, mingw, Interix 3.5.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function is missing on some platforms:
-HP-UX 11.00, IRIX 6.5, Solaris 2.5.1, mingw, Interix 3.5.
-@item
 On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
 @end itemize
--- a/doc/posix-functions/wctype.texi
+++ b/doc/posix-functions/wctype.texi
@@ -4,18 +4,22 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/wctype.html}
 
-Gnulib module: ---
+Gnulib module: wctype
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This function is missing on some platforms:
+IRIX 5.3, Solaris 2.5.1.
+@item
+This function is declared in @code{<wchar.h>}, not in @code{<wctype.h>}, on
+some platforms:
+HP-UX 11.00.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function is missing on some platforms:
-IRIX 5.3, Solaris 2.5.1, mingw.
-@item
 On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
 @end itemize
--- a/doc/posix-functions/wmemchr.texi
+++ b/doc/posix-functions/wmemchr.texi
@@ -4,18 +4,18 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/wmemchr.html}
 
-Gnulib module: ---
+Gnulib module: wmemchr
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This function is missing on some platforms:
+HP-UX 11.00, IRIX 6.5, Solaris 2.6, Interix 3.5.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function is missing on some platforms:
-HP-UX 11.00, IRIX 6.5, Solaris 2.6, Interix 3.5.
-@item
 On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
 @end itemize
--- a/doc/posix-functions/wmemcmp.texi
+++ b/doc/posix-functions/wmemcmp.texi
@@ -4,18 +4,18 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/wmemcmp.html}
 
-Gnulib module: ---
+Gnulib module: wmemcmp
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This function is missing on some platforms:
+HP-UX 11.00, IRIX 6.5, Solaris 2.6, Interix 3.5.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function is missing on some platforms:
-HP-UX 11.00, IRIX 6.5, Solaris 2.6, Interix 3.5.
-@item
 On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
 @end itemize
--- a/doc/posix-functions/wmemcpy.texi
+++ b/doc/posix-functions/wmemcpy.texi
@@ -4,18 +4,18 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/wmemcpy.html}
 
-Gnulib module: ---
+Gnulib module: wmemcpy
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This function is missing on some platforms:
+HP-UX 11.00, IRIX 6.5, Solaris 2.6, Interix 3.5.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function is missing on some platforms:
-HP-UX 11.00, IRIX 6.5, Solaris 2.6, Interix 3.5.
-@item
 On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
 @end itemize
--- a/doc/posix-functions/wmemmove.texi
+++ b/doc/posix-functions/wmemmove.texi
@@ -4,18 +4,18 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/wmemmove.html}
 
-Gnulib module: ---
+Gnulib module: wmemmove
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This function is missing on some platforms:
+HP-UX 11.00, IRIX 6.5, Solaris 2.6, Interix 3.5.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function is missing on some platforms:
-HP-UX 11.00, IRIX 6.5, Solaris 2.6, Interix 3.5.
-@item
 On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
 @end itemize
--- a/doc/posix-functions/wmemset.texi
+++ b/doc/posix-functions/wmemset.texi
@@ -4,18 +4,18 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/wmemset.html}
 
-Gnulib module: ---
+Gnulib module: wmemset
 
 Portability problems fixed by Gnulib:
 @itemize
+@item
+This function is missing on some platforms:
+HP-UX 11.00, IRIX 6.5, Solaris 2.6, Interix 3.5.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function is missing on some platforms:
-HP-UX 11.00, IRIX 6.5, Solaris 2.6, Interix 3.5.
-@item
 On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot
 accommodate all Unicode characters.
 @end itemize
--- a/doc/posix-headers/netdb.texi
+++ b/doc/posix-headers/netdb.texi
@@ -16,6 +16,10 @@
 Cygwin 1.5.x, Haiku.
 
 @item
+This header file does not define the type @code{socklen_t} on some platforms:
+HP-UX 10.20, IRIX 6.5, OSF/1 4.0, Interix 3.5, BeOS.
+
+@item
 This header file does not define @code{AI_ALL}, @code{AI_V4MAPPED},
 @code{AI_ADDRCONFIG} on some platforms:
 NetBSD 5.0.
--- a/doc/posix-headers/stdint.texi
+++ b/doc/posix-headers/stdint.texi
@@ -23,6 +23,10 @@
 The values of @code{INT8_MAX}, @code{UINT8_MAX} etc. are not usable in
 preprocessor expressions on some platforms:
 HP-UX 11.23.
+@item
+The macros @code{WCHAR_MIN} and @code{WCHAR_MAX} are not defined in
+@code{<stdint.h>} (only in @code{<wchar.h>}) on some platforms:
+Dragonfly, BSDI.
 @end itemize
 
 Portability problems not fixed by Gnulib:
--- a/doc/posix-headers/sys_socket.texi
+++ b/doc/posix-headers/sys_socket.texi
@@ -14,6 +14,9 @@
 This header file is not self-contained on some platforms: it requires
 @code{<sys/types.h>} to be included first.
 @item
+This header file does not define the type @code{socklen_t} on some platforms:
+HP-UX 10.20, IRIX 6.5, OSF/1 4.0, Interix 3.5, BeOS.
+@item
 This header file is lacking the @code{SHUT_RD}, @code{SHUT_WR},
 @code{SHUT_RDWR} macros on some platforms, despite having the @code{shutdown}
 functions:
--- a/doc/posix-headers/wctype.texi
+++ b/doc/posix-headers/wctype.texi
@@ -3,7 +3,7 @@
 
 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/basedefs/wctype.h.html}
 
-Gnulib module: wctype
+Gnulib module: wctype-h
 
 Portability problems fixed by Gnulib:
 @itemize
--- a/doc/standards.texi
+++ b/doc/standards.texi
@@ -3,7 +3,7 @@
 @setfilename standards.info
 @settitle GNU Coding Standards
 @c This date is automagically updated when you save this file:
-@set lastupdate January 27, 2011
+@set lastupdate March 28, 2011
 @c %**end of header
 
 @dircategory GNU organization
@@ -50,8 +50,8 @@
 @contents
 
 @ifnottex
-@node Top, Preface, (dir), (dir)
-@top Version
+@node Top
+@top GNU Coding Standards
 
 @insertcopying
 @end ifnottex
@@ -701,7 +701,8 @@
 @end example
 
 @noindent
-or by using the @code{mkstemps} function from libiberty.
+or by using the @code{mkstemps} function from Gnulib
+(@pxref{mkstemps,,, gnulib, Gnulib}).
 
 In bash, use @code{set -C} (long name @code{noclobber}) to avoid this
 problem.  In addition, the @code{mktemp} utility is a more general
@@ -2831,6 +2832,7 @@
 programs.  @code{doschk} also reports file names longer than 14
 characters.
 
+
 @node System Portability
 @section Portability between System Types
 @cindex portability, between system types
@@ -2912,9 +2914,9 @@
 @end example
 
 1989 Standard C requires this to work, and we know of only one
-counterexample: 64-bit programs on Microsoft Windows.  We will
-leave it to those who want to port GNU programs to that environment
-to figure out how to do it.
+counterexample: 64-bit programs on Microsoft Windows.  We will leave
+it to those who want to port GNU programs to that environment to
+figure out how to do it.
 
 Predefined file-size types like @code{off_t} are an exception: they are
 longer than @code{long} on many platforms, so code like the above won't
@@ -2945,51 +2947,6 @@
   @}
 @end example
 
-It used to be ok to not worry about the difference between pointers
-and integers when passing arguments to functions.  However, on most
-modern 64-bit machines pointers are wider than @code{int}.
-Conversely, integer types like @code{long long int} and @code{off_t}
-are wider than pointers on most modern 32-bit machines.  Hence it's
-often better nowadays to use prototypes to define functions whose
-argument types are not trivial.
-
-In particular, if functions accept varying argument counts or types
-they should be declared using prototypes containing @samp{...} and
-defined using @file{stdarg.h}.  For an example of this, please see the
-@uref{http://www.gnu.org/software/gnulib/, Gnulib} error module, which
-declares and defines the following function:
-
-@example
-/* Print a message with `fprintf (stderr, FORMAT, ...)';
-   if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
-   If STATUS is nonzero, terminate the program with `exit (STATUS)'.  */
-
-void error (int status, int errnum, const char *format, ...);
-@end example
-
-A simple way to use the Gnulib error module is to obtain the two
-source files @file{error.c} and @file{error.h} from the Gnulib library
-source code repository at
-@uref{http://git.savannah.gnu.org/@/gitweb/@/?p=gnulib.git}.
-Here's a sample use:
-
-@example
-#include "error.h"
-#include <errno.h>
-#include <stdio.h>
-
-char *program_name = "myprogram";
-
-FILE *
-xfopen (char const *name)
-@{
-  FILE *fp = fopen (name, "r");
-  if (! fp)
-    error (1, errno, "cannot read %s", name);
-  return fp;
-@}
-@end example
-
 @cindex casting pointers to integers
 Avoid casting pointers to integers if you can.  Such casts greatly
 reduce portability, and in most programs they are easy to avoid.  In the
@@ -3000,133 +2957,75 @@
 normal range of addresses you can get from @code{malloc} starts far away
 from zero.
 
+
 @node System Functions
 @section Calling System Functions
+
+@cindex C library functions, and portability
+@cindex POSIX functions, and portability
 @cindex library functions, and portability
 @cindex portability, and library functions
 
-C implementations differ substantially.  Standard C reduces but does
-not eliminate the incompatibilities; meanwhile, many GNU packages still
-support pre-standard compilers because this is not hard to do.  This
-chapter gives recommendations for how to use the more-or-less standard C
-library functions to avoid unnecessary loss of portability.
-
-@itemize @bullet
-@item
-Don't use the return value of @code{sprintf}.  It returns the number of
-characters written on some systems, but not on all systems.
-
-@item
-Be aware that @code{vfprintf} is not always available.
-
-@item
-@code{main} should be declared to return type @code{int}.  It should
-terminate either by calling @code{exit} or by returning the integer
-status code; make sure it cannot ever return an undefined value.
-
-@cindex declaration for system functions
-@item
-Don't declare system functions explicitly.
-
-Almost any declaration for a system function is wrong on some system.
-To minimize conflicts, leave it to the system header files to declare
-system functions.  If the headers don't declare a function, let it
-remain undeclared.
-
-While it may seem unclean to use a function without declaring it, in
-practice this works fine for most system library functions on the
-systems where this really happens; thus, the disadvantage is only
-theoretical.  By contrast, actual declarations have frequently caused
-actual conflicts.
-
-@item
-If you must declare a system function, don't specify the argument types.
-Use an old-style declaration, not a Standard C prototype.  The more you
-specify about the function, the more likely a conflict.
-
-@item
-In particular, don't unconditionally declare @code{malloc} or
-@code{realloc}.
-
-Most GNU programs use those functions just once, in functions
-conventionally named @code{xmalloc} and @code{xrealloc}.  These
-functions call @code{malloc} and @code{realloc}, respectively, and
-check the results.
-
-Because @code{xmalloc} and @code{xrealloc} are defined in your program,
-you can declare them in other files without any risk of type conflict.
-
-On most systems, @code{int} is the same length as a pointer; thus, the
-calls to @code{malloc} and @code{realloc} work fine.  For the few
-exceptional systems (mostly 64-bit machines), you can use
-@strong{conditionalized} declarations of @code{malloc} and
-@code{realloc}---or put these declarations in configuration files
-specific to those systems.
-
-@cindex string library functions
-@item
-The string functions require special treatment.  Some Unix systems have
-a header file @file{string.h}; others have @file{strings.h}.  Neither
-file name is portable.  There are two things you can do: use Autoconf to
-figure out which file to include, or don't include either file.
-
-@item
-If you don't include either strings file, you can't get declarations for
-the string functions from the header file in the usual way.
-
-That causes less of a problem than you might think.  The newer standard
-string functions should be avoided anyway because many systems still
-don't support them.  The string functions you can use are these:
-
-@example
-strcpy   strncpy   strcat   strncat
-strlen   strcmp    strncmp
-strchr   strrchr
-@end example
-
-The copy and concatenate functions work fine without a declaration as
-long as you don't use their values.  Using their values without a
-declaration fails on systems where the width of a pointer differs from
-the width of @code{int}, and perhaps in other cases.  It is trivial to
-avoid using their values, so do that.
-
-The compare functions and @code{strlen} work fine without a declaration
-on most systems, possibly all the ones that GNU software runs on.
-You may find it necessary to declare them @strong{conditionally} on a
-few systems.
-
-The search functions must be declared to return @code{char *}.  Luckily,
-there is no variation in the data type they return.  But there is
-variation in their names.  Some systems give these functions the names
-@code{index} and @code{rindex}; other systems use the names
-@code{strchr} and @code{strrchr}.  Some systems support both pairs of
-names, but neither pair works on all systems.
-
-You should pick a single pair of names and use it throughout your
-program.  (Nowadays, it is better to choose @code{strchr} and
-@code{strrchr} for new programs, since those are the standard
-names.)  Declare both of those names as functions returning @code{char
-*}.  On systems which don't support those names, define them as macros
-in terms of the other pair.  For example, here is what to put at the
-beginning of your file (or in a header) if you want to use the names
-@code{strchr} and @code{strrchr} throughout:
-
-@example
-#ifndef HAVE_STRCHR
-#define strchr index
-#endif
-#ifndef HAVE_STRRCHR
-#define strrchr rindex
-#endif
-
-char *strchr ();
-char *strrchr ();
-@end example
-@end itemize
-
-Here we assume that @code{HAVE_STRCHR} and @code{HAVE_STRRCHR} are
-macros defined in systems where the corresponding functions exist.
-One way to get them properly defined is to use Autoconf.
+Historically, C implementations differed substantially, and many
+systems lacked a full implementation of ANSI/ISO C89.  Nowadays,
+however, very few systems lack a C89 compiler and GNU C supports
+almost all of C99.  Similarly, most systems implement POSIX.1-1993
+libraries and tools, and many have POSIX.1-2001.
+
+Hence, there is little reason to support old C or non-POSIX systems,
+and you may want to take advantage of C99 and POSIX-1.2001 to write
+clearer, more portable, or faster code.  You should use standard
+interfaces where possible; but if GNU extensions make your program
+more maintainable, powerful, or otherwise better, don't hesitate to
+use them.  In any case, don't make your own declaration of system
+functions; that's a recipe for conflict.
+
+Despite the standards, nearly every library function has some sort of
+portability issue on some system or another.  Here are some examples:
+
+@table @code
+@item open
+Names with trailing @code{/}'s are mishandled on many platforms.
+
+@item printf
+@code{long double} may be unimplemented; floating values Infinity and
+NaN are often mishandled; output for large precisions may be
+incorrect.
+
+@item readlink
+May return @code{int} instead of @code{ssize_t}.
+
+@item scanf
+On Windows, @code{errno} is not set on failure.
+@end table
+
+@cindex Gnulib
+@uref{http://www.gnu.org/software/gnulib/, Gnulib} is a big help in
+this regard.  Gnulib provides implementations of standard interfaces
+on many of the systems that lack them, including portable
+implementations of enhanced GNU interfaces, thereby making their use
+portable, and of POSIX-1.2008 interfaces, some of which are missing
+even on up-to-date GNU systems.
+
+@findex xmalloc, in Gnulib
+@findex error messages, in Gnulib
+@findex data structures, in Gnulib
+Gnulib also provides many useful non-standard interfaces; for example,
+C implementations of standard data structures (hash tables, binary
+trees), error-checking type-safe wrappers for memory allocation
+functions (@code{xmalloc}, @code{xrealloc}), and output of error
+messages.
+
+Gnulib integrates with GNU Autoconf and Automake to remove much of the
+burden of writing portable code from the programmer: Gnulib makes your
+configure script automatically determine what features are missing and
+use the Gnulib code to supply the missing pieces.
+
+The Gnulib and Autoconf manuals have extensive sections on
+portability: @ref{Top,, Introduction, gnulib, Gnulib} and
+@pxref{Portable C and C++,,, autoconf, Autoconf}.  Please consult them
+for many more details.
+
 
 @node Internationalization
 @section Internationalization
--- a/gnulib-tool
+++ b/gnulib-tool
@@ -123,24 +123,12 @@
 # outputs to stdout the --help usage message.
 func_usage ()
 {
-  # This use of bold display can be removed on 2011-01-01.
-  if case "$TERM" in
-       xterm*) test -t 1;;
-       *) false;;
-     esac; then
-    # Assume xterm compatible escape sequences.
-    bold_on=`printf '\x1b[1m'`
-    bold_off=`printf '\x1b[0m'`
-  else
-    bold_on=
-    bold_off=
-  fi
   echo "\
 Usage: gnulib-tool --list
-       gnulib-tool --find filename${bold_on}
+       gnulib-tool --find filename
        gnulib-tool --import [module1 ... moduleN]
        gnulib-tool --add-import [module1 ... moduleN]
-       gnulib-tool --remove-import [module1 ... moduleN]${bold_off}
+       gnulib-tool --remove-import [module1 ... moduleN]
        gnulib-tool --update
        gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
        gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
@@ -165,14 +153,14 @@
 Operation modes:
 
       --list                print the available module names
-      --find                find the modules which contain the specified file${bold_on}
+      --find                find the modules which contain the specified file
       --import              import the given modules into the current package
       --add-import          augment the list of imports from gnulib into the
                             current package, by adding the given modules;
                             if no modules are specified, update the current
                             package from the current gnulib
       --remove-import       reduce the list of imports from gnulib into the
-                            current package, by removing the given modules${bold_off}
+                            current package, by removing the given modules
       --update              update the current package, restore files omitted
                             from version control
       --create-testdir      create a scratch package with the given modules
@@ -3878,11 +3866,16 @@
         yes | 3)
           sed_transform_main_lib_file=$sed_transform_main_lib_file'
             s/GNU General/GNU Lesser General/g
+            s/General Public License/Lesser General Public License/g
+            s/Lesser Lesser General Public License/Lesser General Public License/g
           '
           ;;
         2)
           sed_transform_main_lib_file=$sed_transform_main_lib_file'
             s/GNU General/GNU Lesser General/g
+            s/General Public License/Lesser General Public License/g
+            s/Lesser Lesser General Public License/Lesser General Public License/g
+
             s/version [23]\([ ,]\)/version 2.1\1/g
           '
           ;;
@@ -3892,7 +3885,11 @@
       # Update license.
       sed_transform_main_lib_file=$sed_transform_main_lib_file'
         s/GNU Lesser General/GNU General/g
+        s/Lesser General Public License/General Public License/g
+
         s/GNU Library General/GNU General/g
+        s/Library General Public License/General Public License/g
+
         s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
       '
     fi
@@ -3904,7 +3901,11 @@
     # Update license.
     sed_transform_build_aux_file=$sed_transform_build_aux_file'
       s/GNU Lesser General/GNU General/g
+      s/Lesser General Public License/General Public License/g
+
       s/GNU Library General/GNU General/g
+      s/Library General Public License/General Public License/g
+
       s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
     '
   fi
@@ -3919,7 +3920,11 @@
     # Update license.
     sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
       s/GNU Lesser General/GNU General/g
+      s/Lesser General Public License/General Public License/g
+
       s/GNU Library General/GNU General/g
+      s/Library General Public License/General Public License/g
+
       s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
     '
   fi
--- a/lib/argp-fmtstream.h
+++ b/lib/argp-fmtstream.h
@@ -28,16 +28,16 @@
 #include <string.h>
 #include <unistd.h>
 
-#ifndef __attribute__
 /* The __attribute__ feature is available in gcc versions 2.5 and later.
    The __-protected variants of the attributes 'format' and 'printf' are
    accepted by gcc versions 2.6.4 (effectively 2.7) and later.
-   We enable __attribute__ only if these are supported too, because
+   We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because
    gnulib and libintl do '#define printf __printf__' when they override
    the 'printf' function.  */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
-#  define __attribute__(Spec)   /* empty */
-# endif
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
+# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
+#else
+# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
 #endif
 
 #if    (_LIBC - 0 && !defined (USE_IN_LIBIO)) \
@@ -128,10 +128,10 @@
 
 extern ssize_t __argp_fmtstream_printf (argp_fmtstream_t __fs,
                                         const char *__fmt, ...)
-     __attribute__ ((__format__ (printf, 2, 3)));
+     _GL_ATTRIBUTE_FORMAT ((printf, 2, 3));
 extern ssize_t argp_fmtstream_printf (argp_fmtstream_t __fs,
                                       const char *__fmt, ...)
-     __attribute__ ((__format__ (printf, 2, 3)));
+     _GL_ATTRIBUTE_FORMAT ((printf, 2, 3));
 
 #if _LIBC || !defined __OPTIMIZE__
 extern int __argp_fmtstream_putc (argp_fmtstream_t __fs, int __ch);
--- a/lib/argp-help.c
+++ b/lib/argp-help.c
@@ -570,7 +570,9 @@
 }
 
 static inline int
+#if __GNUC__ >= 3
 __attribute__ ((always_inline))
+#endif
 hol_entry_long_iterate (const struct hol_entry *entry,
                         int (*func)(const struct argp_option *opt,
                                     const struct argp_option *real,
--- a/lib/argp-namefrob.h
+++ b/lib/argp-namefrob.h
@@ -100,45 +100,45 @@
 #endif
 #if defined(HAVE_DECL_FEOF_UNLOCKED) && !HAVE_DECL_FEOF_UNLOCKED
 # define feof_unlocked(x) feof (x)
-# endif
+#endif
 #if defined(HAVE_DECL_FERROR_UNLOCKED) && !HAVE_DECL_FERROR_UNLOCKED
 # define ferror_unlocked(x) ferror (x)
-# endif
+#endif
 #if defined(HAVE_DECL_FFLUSH_UNLOCKED) && !HAVE_DECL_FFLUSH_UNLOCKED
 # define fflush_unlocked(x) fflush (x)
-# endif
+#endif
 #if defined(HAVE_DECL_FGETS_UNLOCKED) && !HAVE_DECL_FGETS_UNLOCKED
 # define fgets_unlocked(x,y,z) fgets (x,y,z)
-# endif
+#endif
 #if defined(HAVE_DECL_FPUTC_UNLOCKED) && !HAVE_DECL_FPUTC_UNLOCKED
 # define fputc_unlocked(x,y) fputc (x,y)
-# endif
+#endif
 #if defined(HAVE_DECL_FPUTS_UNLOCKED) && !HAVE_DECL_FPUTS_UNLOCKED
 # define fputs_unlocked(x,y) fputs (x,y)
-# endif
+#endif
 #if defined(HAVE_DECL_FREAD_UNLOCKED) && !HAVE_DECL_FREAD_UNLOCKED
 # define fread_unlocked(w,x,y,z) fread (w,x,y,z)
-# endif
+#endif
 #if defined(HAVE_DECL_FWRITE_UNLOCKED) && !HAVE_DECL_FWRITE_UNLOCKED
 # define fwrite_unlocked(w,x,y,z) fwrite (w,x,y,z)
-# endif
+#endif
 #if defined(HAVE_DECL_GETC_UNLOCKED) && !HAVE_DECL_GETC_UNLOCKED
 # define getc_unlocked(x) getc (x)
-# endif
+#endif
 #if defined(HAVE_DECL_GETCHAR_UNLOCKED) && !HAVE_DECL_GETCHAR_UNLOCKED
 #  define getchar_unlocked() getchar ()
-# endif
+#endif
 #if defined(HAVE_DECL_PUTC_UNLOCKED) && !HAVE_DECL_PUTC_UNLOCKED
 # define putc_unlocked(x,y) putc (x,y)
-# endif
+#endif
 #if defined(HAVE_DECL_PUTCHAR_UNLOCKED) && !HAVE_DECL_PUTCHAR_UNLOCKED
 # define putchar_unlocked(x) putchar (x)
-# endif
+#endif
 
 #endif /* !_LIBC */
 
 #ifndef __set_errno
-#define __set_errno(e) (errno = (e))
+# define __set_errno(e) (errno = (e))
 #endif
 
 #if defined GNULIB_ARGP_DISABLE_DIRNAME
--- a/lib/argp.h
+++ b/lib/argp.h
@@ -34,16 +34,16 @@
 # define __NTH(fct) fct __THROW
 #endif
 
-#ifndef __attribute__
 /* The __attribute__ feature is available in gcc versions 2.5 and later.
    The __-protected variants of the attributes 'format' and 'printf' are
    accepted by gcc versions 2.6.4 (effectively 2.7) and later.
-   We enable __attribute__ only if these are supported too, because
+   We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because
    gnulib and libintl do '#define printf __printf__' when they override
    the 'printf' function.  */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
-#  define __attribute__(Spec)   /* empty */
-# endif
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
+# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
+#else
+# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
 #endif
 
 /* GCC 2.95 and later have "__restrict"; C99 compilers have
@@ -530,10 +530,10 @@
    message, then exit (1).  */
 extern void argp_error (const struct argp_state *__restrict __state,
                         const char *__restrict __fmt, ...)
-     __attribute__ ((__format__ (__printf__, 2, 3)));
+     _GL_ATTRIBUTE_FORMAT ((__printf__, 2, 3));
 extern void __argp_error (const struct argp_state *__restrict __state,
                           const char *__restrict __fmt, ...)
-     __attribute__ ((__format__ (__printf__, 2, 3)));
+     _GL_ATTRIBUTE_FORMAT ((__printf__, 2, 3));
 
 /* Similar to the standard gnu error-reporting function error(), but will
    respect the ARGP_NO_EXIT and ARGP_NO_ERRS flags in STATE, and will print
@@ -546,11 +546,11 @@
 extern void argp_failure (const struct argp_state *__restrict __state,
                           int __status, int __errnum,
                           const char *__restrict __fmt, ...)
-     __attribute__ ((__format__ (__printf__, 4, 5)));
+     _GL_ATTRIBUTE_FORMAT ((__printf__, 4, 5));
 extern void __argp_failure (const struct argp_state *__restrict __state,
                             int __status, int __errnum,
                             const char *__restrict __fmt, ...)
-     __attribute__ ((__format__ (__printf__, 4, 5)));
+     _GL_ATTRIBUTE_FORMAT ((__printf__, 4, 5));
 
 #if _LIBC || !defined __USE_EXTERN_INLINES
 /* Returns true if the option OPT is a valid short option.  */
--- a/lib/arpa_inet.in.h
+++ b/lib/arpa_inet.in.h
@@ -27,8 +27,8 @@
 # include <features.h> /* for __GLIBC__ */
 #endif
 
-/* Gnulib's sys/socket.h is responsible for pulling in winsock2.h etc
-   under MinGW.
+/* Gnulib's sys/socket.h is responsible for defining socklen_t (used below) and
+   for pulling in winsock2.h etc. under MinGW.
    But avoid namespace pollution on glibc systems.  */
 #ifndef __GLIBC__
 # include <sys/socket.h>
--- a/lib/at-func.c
+++ b/lib/at-func.c
@@ -16,7 +16,7 @@
 
 /* written by Jim Meyering */
 
-#include "dirname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */
+#include "dosname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */
 #include "openat.h"
 #include "openat-priv.h"
 #include "save-cwd.h"
--- a/lib/at-func2.c
+++ b/lib/at-func2.c
@@ -25,7 +25,7 @@
 #include <string.h>
 #include <unistd.h>
 
-#include "dirname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */
+#include "dosname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */
 #include "filenamecat.h"
 #include "openat.h"
 #include "same-inode.h"
new file mode 100644
--- /dev/null
+++ b/lib/di-set.c
@@ -0,0 +1,259 @@
+/* Set operations for device-inode pairs stored in a space-efficient manner.
+
+   Copyright 2009-2011 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 and Jim Meyering */
+
+#include <config.h>
+#include "di-set.h"
+
+#include "hash.h"
+#include "ino-map.h"
+
+#include <limits.h>
+#include <stdlib.h>
+
+/* The hash package hashes "void *", but this package wants to hash
+   integers.  Use integers that are as large as possible, but no
+   larger than void *, so that they can be cast to void * and back
+   without losing information.  */
+typedef size_t hashint;
+#define HASHINT_MAX ((hashint) -1)
+
+/* Integers represent inode numbers.  Integers in the range
+   1..(LARGE_INO_MIN-1) represent inode numbers directly.  (The hash
+   package does not work with null pointers, so inode 0 cannot be used
+   as a key.)  To find the representations of other inode numbers, map
+   them through INO_MAP.  */
+#define LARGE_INO_MIN (HASHINT_MAX / 2)
+
+/* Set operations for device-inode pairs stored in a space-efficient
+   manner.  Use a two-level hash table.  The top level hashes by
+   device number, as there are typically a small number of devices.
+   The lower level hashes by mapped inode numbers.  In the typical
+   case where the inode number is positive and small, the inode number
+   maps to itself, masquerading as a void * value; otherwise, its
+   value is the result of hashing the inode value through INO_MAP.  */
+
+/* A pair that maps a device number to a set of inode numbers.  */
+struct di_ent
+{
+  dev_t dev;
+  struct hash_table *ino_set;
+};
+
+/* A two-level hash table that manages and indexes these pairs.  */
+struct di_set
+{
+  /* Map device numbers to sets of inode number representatives.  */
+  struct hash_table *dev_map;
+
+  /* If nonnull, map large inode numbers to their small
+     representatives.  If null, there are no large inode numbers in
+     this set.  */
+  struct ino_map *ino_map;
+
+  /* Cache of the most recently allocated and otherwise-unused storage
+     for probing this table.  */
+  struct di_ent *probe;
+};
+
+/* Hash a device-inode-set entry.  */
+static size_t
+di_ent_hash (void const *x, size_t table_size)
+{
+  struct di_ent const *p = x;
+  dev_t dev = p->dev;
+
+  /* When DEV is wider than size_t, exclusive-OR the words of DEV into H.
+     This avoids loss of info, without applying % to the wider type,
+     which could be quite slow on some systems.  */
+  size_t h = dev;
+  unsigned int i;
+  unsigned int n_words = sizeof dev / sizeof h + (sizeof dev % sizeof h != 0);
+  for (i = 1; i < n_words; i++)
+    h ^= dev >> CHAR_BIT * sizeof h * i;
+
+  return h % table_size;
+}
+
+/* Return true if two device-inode-set entries are the same.  */
+static bool
+di_ent_compare (void const *x, void const *y)
+{
+  struct di_ent const *a = x;
+  struct di_ent const *b = y;
+  return a->dev == b->dev;
+}
+
+/* Free a device-inode-set entry.  */
+static void
+di_ent_free (void *v)
+{
+  struct di_ent *a = v;
+  hash_free (a->ino_set);
+  free (a);
+}
+
+/* Create a set of device-inode pairs.  Return NULL on allocation failure.  */
+struct di_set *
+di_set_alloc (void)
+{
+  struct di_set *dis = malloc (sizeof *dis);
+  if (dis)
+    {
+      enum { INITIAL_DEV_MAP_SIZE = 11 };
+      dis->dev_map = hash_initialize (INITIAL_DEV_MAP_SIZE, NULL,
+                                      di_ent_hash, di_ent_compare,
+                                      di_ent_free);
+      if (! dis->dev_map)
+        {
+          free (dis);
+          return NULL;
+        }
+      dis->ino_map = NULL;
+      dis->probe = NULL;
+    }
+
+  return dis;
+}
+
+/* Free a set of device-inode pairs.  */
+void
+di_set_free (struct di_set *dis)
+{
+  hash_free (dis->dev_map);
+  free (dis->ino_map);
+  free (dis->probe);
+  free (dis);
+}
+
+/* Hash an encoded inode number I.  */
+static size_t
+di_ino_hash (void const *i, size_t table_size)
+{
+  return (hashint) i % table_size;
+}
+
+/* Using the DIS table, map a device to a hash table that represents
+   a set of inode numbers.  Return NULL on error.  */
+static struct hash_table *
+map_device (struct di_set *dis, dev_t dev)
+{
+  /* Find space for the probe, reusing the cache if available.  */
+  struct di_ent *ent;
+  struct di_ent *probe = dis->probe;
+  if (probe)
+    {
+      /* If repeating a recent query, return the cached result.   */
+      if (probe->dev == dev)
+        return probe->ino_set;
+    }
+  else
+    {
+      dis->probe = probe = malloc (sizeof *probe);
+      if (! probe)
+        return NULL;
+    }
+
+  /* Probe for the device.  */
+  probe->dev = dev;
+  ent = hash_insert (dis->dev_map, probe);
+  if (! ent)
+    return NULL;
+
+  if (ent != probe)
+    {
+      /* Use the existing entry.  */
+      probe->ino_set = ent->ino_set;
+    }
+  else
+    {
+      enum { INITIAL_INO_SET_SIZE = 1021 };
+
+      /* Prepare to allocate a new probe next time; this one is in use.  */
+      dis->probe = NULL;
+
+      /* DEV is new; allocate an inode set for it.  */
+      probe->ino_set = hash_initialize (INITIAL_INO_SET_SIZE, NULL,
+                                        di_ino_hash, NULL, NULL);
+    }
+
+  return probe->ino_set;
+}
+
+/* Using the DIS table, map an inode number to a mapped value.
+   Return INO_MAP_INSERT_FAILURE on error.  */
+static hashint
+map_inode_number (struct di_set *dis, ino_t ino)
+{
+  if (0 < ino && ino < LARGE_INO_MIN)
+    return ino;
+
+  if (! dis->ino_map)
+    {
+      dis->ino_map = ino_map_alloc (LARGE_INO_MIN);
+      if (! dis->ino_map)
+        return INO_MAP_INSERT_FAILURE;
+    }
+
+  return ino_map_insert (dis->ino_map, ino);
+}
+
+/* Attempt to insert the DEV,INO pair into the set DIS.
+   If it matches a pair already in DIS, keep that pair and return 0.
+   Otherwise, if insertion is successful, return 1.
+   Upon any failure return -1.  */
+int
+di_set_insert (struct di_set *dis, dev_t dev, ino_t ino)
+{
+  hashint i;
+
+  /* Map the device number to a set of inodes.  */
+  struct hash_table *ino_set = map_device (dis, dev);
+  if (! ino_set)
+    return -1;
+
+  /* Map the inode number to a small representative I.  */
+  i = map_inode_number (dis, ino);
+  if (i == INO_MAP_INSERT_FAILURE)
+    return -1;
+
+  /* Put I into the inode set.  */
+  return hash_insert0 (ino_set, (void const *) i, NULL);
+}
+
+/* Look up the DEV,INO pair in the set DIS.
+   If found, return 1; if not found, return 0.
+   Upon any failure return -1.  */
+int
+di_set_lookup (struct di_set *dis, dev_t dev, ino_t ino)
+{
+  hashint i;
+
+  /* Map the device number to a set of inodes.  */
+  struct hash_table *ino_set = map_device (dis, dev);
+  if (! ino_set)
+    return -1;
+
+  /* Map the inode number to a small representative I.  */
+  i = map_inode_number (dis, ino);
+  if (i == INO_MAP_INSERT_FAILURE)
+    return -1;
+
+  /* Perform the look-up.  */
+  return !!hash_lookup (ino_set, (void const *) i);
+}
new file mode 100644
--- /dev/null
+++ b/lib/di-set.h
@@ -0,0 +1,19 @@
+#ifndef _GL_DI_SET_H
+# define _GL_DI_SET_H
+
+# include <sys/types.h>
+
+# undef _GL_ATTRIBUTE_NONNULL
+# if __GNUC__ == 3 && __GNUC_MINOR__ >= 3 || 3 < __GNUC__
+#  define _GL_ATTRIBUTE_NONNULL(m) __attribute__ ((__nonnull__ (m)))
+# else
+#  define _GL_ATTRIBUTE_NONNULL(m)
+# endif
+
+struct di_set *di_set_alloc (void);
+int di_set_insert (struct di_set *, dev_t, ino_t) _GL_ATTRIBUTE_NONNULL (1);
+void di_set_free (struct di_set *) _GL_ATTRIBUTE_NONNULL (1);
+int di_set_lookup (struct di_set *dis, dev_t dev, ino_t ino)
+  _GL_ATTRIBUTE_NONNULL (1);
+
+#endif
--- a/lib/dirname.h
+++ b/lib/dirname.h
@@ -21,44 +21,16 @@
 
 # include <stdbool.h>
 # include <stddef.h>
+# include "dosname.h"
 
 # ifndef DIRECTORY_SEPARATOR
 #  define DIRECTORY_SEPARATOR '/'
 # endif
 
-# ifndef ISSLASH
-#  define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR)
-# endif
-
-# ifndef FILE_SYSTEM_PREFIX_LEN
-#  if FILE_SYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX
-    /* This internal macro assumes ASCII, but all hosts that support drive
-       letters use ASCII.  */
-#   define _IS_DRIVE_LETTER(c) (((unsigned int) (c) | ('a' - 'A')) - 'a' \
-                                <= 'z' - 'a')
-#   define FILE_SYSTEM_PREFIX_LEN(Filename) \
-           (_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':' ? 2 : 0)
-#  else
-#   define FILE_SYSTEM_PREFIX_LEN(Filename) 0
-#  endif
-# endif
-
-# ifndef FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
-#  define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
-# endif
-
 # ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT
 #  define DOUBLE_SLASH_IS_DISTINCT_ROOT 0
 # endif
 
-# if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
-#  define IS_ABSOLUTE_FILE_NAME(F) ISSLASH ((F)[FILE_SYSTEM_PREFIX_LEN (F)])
-# else
-#  define IS_ABSOLUTE_FILE_NAME(F) \
-          (ISSLASH ((F)[0]) || 0 < FILE_SYSTEM_PREFIX_LEN (F))
-# endif
-# define IS_RELATIVE_FILE_NAME(F) (! IS_ABSOLUTE_FILE_NAME (F))
-
 # if GNULIB_DIRNAME
 char *base_name (char const *file);
 char *dir_name (char const *file);
new file mode 100644
--- /dev/null
+++ b/lib/dosname.h
@@ -0,0 +1,53 @@
+/* File names on MS-DOS/Windows systems.
+
+   Copyright (C) 2000-2001, 2004-2006, 2009-2011 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/>.
+
+   From Paul Eggert and Jim Meyering.  */
+
+#ifndef _DOSNAME_H
+#define _DOSNAME_H
+
+#if (defined _WIN32 || defined __WIN32__ ||     \
+     defined __MSDOS__ || defined __CYGWIN__ || \
+     defined __EMX__ || defined __DJGPP__)
+   /* This internal macro assumes ASCII, but all hosts that support drive
+      letters use ASCII.  */
+# define _IS_DRIVE_LETTER(C) (((unsigned int) (C) | ('a' - 'A')) - 'a'  \
+                              <= 'z' - 'a')
+# define FILE_SYSTEM_PREFIX_LEN(Filename) \
+          (_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':' ? 2 : 0)
+# ifndef __CYGWIN__
+#  define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 1
+# endif
+# define ISSLASH(C) ((C) == '/' || (C) == '\\')
+#else
+# define FILE_SYSTEM_PREFIX_LEN(Filename) 0
+# define ISSLASH(C) ((C) == '/')
+#endif
+
+#ifndef FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
+# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
+#endif
+
+#if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
+#  define IS_ABSOLUTE_FILE_NAME(F) ISSLASH ((F)[FILE_SYSTEM_PREFIX_LEN (F)])
+# else
+#  define IS_ABSOLUTE_FILE_NAME(F)                              \
+     (ISSLASH ((F)[0]) || FILE_SYSTEM_PREFIX_LEN (F) != 0)
+#endif
+#define IS_RELATIVE_FILE_NAME(F) (! IS_ABSOLUTE_FILE_NAME (F))
+
+#endif /* DOSNAME_H_ */
--- a/lib/dup3.c
+++ b/lib/dup3.c
@@ -56,10 +56,10 @@
         if (!(result < 0 && errno == ENOSYS))
           {
             have_dup3_really = 1;
-#if REPLACE_FCHDIR
+# if REPLACE_FCHDIR
             if (0 <= result)
               result = _gl_register_dup (oldfd, newfd);
-#endif
+# endif
             return result;
           }
         have_dup3_really = -1;
--- a/lib/error.h
+++ b/lib/error.h
@@ -19,16 +19,16 @@
 #ifndef _ERROR_H
 #define _ERROR_H 1
 
-#ifndef __attribute__
 /* The __attribute__ feature is available in gcc versions 2.5 and later.
    The __-protected variants of the attributes 'format' and 'printf' are
    accepted by gcc versions 2.6.4 (effectively 2.7) and later.
-   We enable __attribute__ only if these are supported too, because
+   We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because
    gnulib and libintl do '#define printf __printf__' when they override
    the 'printf' function.  */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
-#  define __attribute__(Spec)   /* empty */
-# endif
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
+# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
+#else
+# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
 #endif
 
 #ifdef __cplusplus
@@ -40,11 +40,11 @@
    If STATUS is nonzero, terminate the program with `exit (STATUS)'.  */
 
 extern void error (int __status, int __errnum, const char *__format, ...)
-     __attribute__ ((__format__ (__printf__, 3, 4)));
+     _GL_ATTRIBUTE_FORMAT ((__printf__, 3, 4));
 
 extern void error_at_line (int __status, int __errnum, const char *__fname,
                            unsigned int __lineno, const char *__format, ...)
-     __attribute__ ((__format__ (__printf__, 5, 6)));
+     _GL_ATTRIBUTE_FORMAT ((__printf__, 5, 6));
 
 /* If NULL, error will flush stdout, then print on stderr the program
    name, a colon and a space.  Otherwise, error will call this
--- a/lib/fbufmode.c
+++ b/lib/fbufmode.c
@@ -78,6 +78,6 @@
     return _IOLBF;
   return (fp->__bufsize > 0 ? _IOFBF : _IONBF);
 #else
- #error "Please port gnulib fbufmode.c to your platform! Look at the setvbuf implementation."
+# error "Please port gnulib fbufmode.c to your platform! Look at the setvbuf implementation."
 #endif
 }
--- a/lib/fchownat.c
+++ b/lib/fchownat.c
@@ -66,15 +66,15 @@
 static int
 local_lchownat (int fd, char const *file, uid_t owner, gid_t group);
 
-# define AT_FUNC_NAME local_lchownat
-# define AT_FUNC_F1 lchown
-# define AT_FUNC_POST_FILE_PARAM_DECLS , uid_t owner, gid_t group
-# define AT_FUNC_POST_FILE_ARGS        , owner, group
-# include "at-func.c"
-# undef AT_FUNC_NAME
-# undef AT_FUNC_F1
-# undef AT_FUNC_POST_FILE_PARAM_DECLS
-# undef AT_FUNC_POST_FILE_ARGS
+#  define AT_FUNC_NAME local_lchownat
+#  define AT_FUNC_F1 lchown
+#  define AT_FUNC_POST_FILE_PARAM_DECLS , uid_t owner, gid_t group
+#  define AT_FUNC_POST_FILE_ARGS        , owner, group
+#  include "at-func.c"
+#  undef AT_FUNC_NAME
+#  undef AT_FUNC_F1
+#  undef AT_FUNC_POST_FILE_PARAM_DECLS
+#  undef AT_FUNC_POST_FILE_ARGS
 
 # endif
 
--- a/lib/flock.c
+++ b/lib/flock.c
@@ -18,7 +18,7 @@
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.
 
-   You should have received a copy of the GNU General Public License
+   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>
@@ -27,13 +27,13 @@
 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
 
 /* _get_osfhandle */
-#include <io.h>
+# include <io.h>
 
 /* LockFileEx */
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
 
-#include <errno.h>
+# include <errno.h>
 
 /* Determine the current size of a file.  Because the other braindead
  * APIs we'll call need lower/upper 32 bit pairs, keep the file size
@@ -47,9 +47,9 @@
 }
 
 /* LOCKFILE_FAIL_IMMEDIATELY is undefined on some Windows systems. */
-#ifndef LOCKFILE_FAIL_IMMEDIATELY
-# define LOCKFILE_FAIL_IMMEDIATELY 1
-#endif
+# ifndef LOCKFILE_FAIL_IMMEDIATELY
+#  define LOCKFILE_FAIL_IMMEDIATELY 1
+# endif
 
 /* Acquire a lock. */
 static BOOL
@@ -160,17 +160,17 @@
 
 #else /* !Windows */
 
-#ifdef HAVE_STRUCT_FLOCK_L_TYPE
+# ifdef HAVE_STRUCT_FLOCK_L_TYPE
 /* We know how to implement flock in terms of fcntl. */
 
-#include <fcntl.h>
+#  include <fcntl.h>
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
+#  ifdef HAVE_UNISTD_H
+#   include <unistd.h>
+#  endif
 
-#include <errno.h>
-#include <string.h>
+#  include <errno.h>
+#  include <string.h>
 
 int
 flock (int fd, int operation)
@@ -211,10 +211,10 @@
   return r;
 }
 
-#else /* !HAVE_STRUCT_FLOCK_L_TYPE */
+# else /* !HAVE_STRUCT_FLOCK_L_TYPE */
 
-#error "This platform lacks flock function, and Gnulib doesn't provide a replacement. This is a bug in Gnulib."
+#  error "This platform lacks flock function, and Gnulib doesn't provide a replacement. This is a bug in Gnulib."
 
-#endif /* !HAVE_STRUCT_FLOCK_L_TYPE */
+# endif /* !HAVE_STRUCT_FLOCK_L_TYPE */
 
 #endif /* !Windows */
--- a/lib/fpurge.c
+++ b/lib/fpurge.c
@@ -130,7 +130,7 @@
   fp->__put_limit = fp->__buffer;
   return 0;
 # else
- #error "Please port gnulib fpurge.c to your platform! Look at the definitions of fflush, setvbuf and ungetc on your system, then report this to bug-gnulib."
+#  error "Please port gnulib fpurge.c to your platform! Look at the definitions of fflush, setvbuf and ungetc on your system, then report this to bug-gnulib."
 # endif
 
 #endif
--- a/lib/freadable.c
+++ b/lib/freadable.c
@@ -40,6 +40,6 @@
 #elif defined __MINT__              /* Atari FreeMiNT */
   return fp->__mode.__read;
 #else
- #error "Please port gnulib freadable.c to your platform! Look at the definition of fopen, fdopen on your system, then report this to bug-gnulib."
+# error "Please port gnulib freadable.c to your platform! Look at the definition of fopen, fdopen on your system, then report this to bug-gnulib."
 #endif
 }
--- a/lib/freading.c
+++ b/lib/freading.c
@@ -31,38 +31,38 @@
   /* Most systems provide FILE as a struct and the necessary bitmask in
      <stdio.h>, because they need it for implementing getc() and putc() as
      fast macros.  */
-#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
+# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
   return ((fp->_flags & _IO_NO_WRITES) != 0
           || ((fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0
               && fp->_IO_read_base != NULL));
-#elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */
+# elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, MacOS X, Cygwin */
   return (fp_->_flags & __SRD) != 0;
-#elif defined __EMX__               /* emx+gcc */
+# elif defined __EMX__               /* emx+gcc */
   return (fp->_flags & _IOREAD) != 0;
-#elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */
-# if defined __sun                  /* Solaris */
+# elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, OpenServer, mingw, NonStop Kernel */
+#  if defined __sun                  /* Solaris */
   return (fp->_flag & _IOREAD) != 0 && (fp->_flag & _IOWRT) == 0;
-# else
+#  else
   return (fp->_flag & _IOREAD) != 0;
-# endif
-#elif defined __UCLIBC__            /* uClibc */
+#  endif
+# elif defined __UCLIBC__            /* uClibc */
   return (fp->__modeflags & (__FLAG_READONLY | __FLAG_READING)) != 0;
-#elif defined __QNX__               /* QNX */
+# elif defined __QNX__               /* QNX */
   return ((fp->_Mode & 0x2 /* _MOPENW */) == 0
           || (fp->_Mode & 0x1000 /* _MREAD */) != 0);
-#elif defined __MINT__              /* Atari FreeMiNT */
+# elif defined __MINT__              /* Atari FreeMiNT */
   if (!fp->__mode.__write)
     return 1;
   if (!fp->__mode.__read)
     return 0;
-# ifdef _IO_CURRENTLY_GETTING /* Flag added on 2009-02-28 */
+#  ifdef _IO_CURRENTLY_GETTING /* Flag added on 2009-02-28 */
   return (fp->__flags & _IO_CURRENTLY_GETTING) != 0;
-# else
+#  else
   return (fp->__buffer < fp->__get_limit /*|| fp->__bufp == fp->__put_limit ??*/);
+#  endif
+# else
+#  error "Please port gnulib freading.c to your platform!"
 # endif
-#else
- #error "Please port gnulib freading.c to your platform!"
-#endif
 }
 
 #endif
--- a/lib/fsync.c
+++ b/lib/fsync.c
@@ -28,13 +28,13 @@
 #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
 
 /* _get_osfhandle */
-#include <io.h>
+# include <io.h>
 
 /* FlushFileBuffers */
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
 
-#include <errno.h>
+# include <errno.h>
 
 int
 fsync (int fd)
@@ -73,6 +73,6 @@
 
 #else /* !Windows */
 
-#error "This platform lacks fsync function, and Gnulib doesn't provide a replacement. This is a bug in Gnulib."
+# error "This platform lacks fsync function, and Gnulib doesn't provide a replacement. This is a bug in Gnulib."
 
 #endif /* !Windows */
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -628,7 +628,7 @@
 #if defined __linux__ \
   && HAVE_SYS_VFS_H && HAVE_FSTATFS && HAVE_STRUCT_STATFS_F_TYPE
 
-#include <sys/vfs.h>
+# include <sys/vfs.h>
 
 /* Linux-specific constants from coreutils' src/fs.h */
 # define S_MAGIC_TMPFS 0x1021994
--- a/lib/fwritable.c
+++ b/lib/fwritable.c
@@ -40,6 +40,6 @@
 #elif defined __MINT__              /* Atari FreeMiNT */
   return fp->__mode.__write;
 #else
- #error "Please port gnulib fwritable.c to your platform! Look at the definition of fopen, fdopen on your system, then report this to bug-gnulib."
+# error "Please port gnulib fwritable.c to your platform! Look at the definition of fopen, fdopen on your system, then report this to bug-gnulib."
 #endif
 }
--- a/lib/fwriting.c
+++ b/lib/fwriting.c
@@ -51,6 +51,6 @@
   return (fp->__buffer < fp->__put_limit /*|| fp->__bufp == fp->__get_limit ??*/);
 # endif
 #else
- #error "Please port gnulib fwriting.c to your platform!"
+# error "Please port gnulib fwriting.c to your platform!"
 #endif
 }
--- a/lib/gen-uni-tables.c
+++ b/lib/gen-uni-tables.c
@@ -21,6 +21,7 @@
      $ gen-uni-tables /usr/local/share/Unidata/UnicodeData.txt \
                       /usr/local/share/Unidata/PropList.txt \
                       /usr/local/share/Unidata/DerivedCoreProperties.txt \
+                      /usr/local/share/Unidata/ArabicShaping.txt \
                       /usr/local/share/Unidata/Scripts.txt \
                       /usr/local/share/Unidata/Blocks.txt \
                       /usr/local/share/Unidata/PropList-3.0.1.txt \
@@ -259,6 +260,7 @@
                              field11, field12, field13, field14);
         }
     }
+
   if (ferror (stream) || fclose (stream))
     {
       fprintf (stderr, "error reading from '%s'\n", unicodedata_filename);
@@ -280,6 +282,17 @@
 }
 
 static bool
+is_category_LC (unsigned int ch)
+{
+  /* See PropertyValueAliases.txt.  */
+  return (unicode_attributes[ch].name != NULL
+          && unicode_attributes[ch].category[0] == 'L'
+          && (unicode_attributes[ch].category[1] == 'u'
+              || unicode_attributes[ch].category[1] == 'l'
+              || unicode_attributes[ch].category[1] == 't'));
+}
+
+static bool
 is_category_Lu (unsigned int ch)
 {
   return (unicode_attributes[ch].name != NULL
@@ -803,6 +816,7 @@
   output_predicate_test ("../tests/unictype/test-categ_" #C ".c", is_category_ ## C, "uc_is_general_category (c, UC_CATEGORY_" #C ")"); \
   output_predicate ("unictype/categ_" #C ".h", is_category_ ## C, "u_categ_" #C, "Categories", version);
   CATEGORY (L)
+  CATEGORY (LC)
   CATEGORY (Lu)
   CATEGORY (Ll)
   CATEGORY (Lt)
@@ -845,6 +859,7 @@
 enum
 {
   UC_CATEGORY_MASK_L  = 0x0000001f,
+  UC_CATEGORY_MASK_LC = 0x00000007,
   UC_CATEGORY_MASK_Lu = 0x00000001,
   UC_CATEGORY_MASK_Ll = 0x00000002,
   UC_CATEGORY_MASK_Lt = 0x00000004,
@@ -894,6 +909,7 @@
         switch (category_name[1])
           {
           case '\0': return UC_CATEGORY_MASK_L;
+          case 'C': return UC_CATEGORY_MASK_LC;
           case 'u': return UC_CATEGORY_MASK_Lu;
           case 'l': return UC_CATEGORY_MASK_Ll;
           case 't': return UC_CATEGORY_MASK_Lt;
@@ -2760,6 +2776,7 @@
       for (i = i1; i <= i2; i++)
         array[i] = 1;
     }
+
   if (ferror (stream) || fclose (stream))
     {
       fprintf (stderr, "error reading from '%s'\n", proplist_filename);
@@ -3651,6 +3668,616 @@
 
 /* ========================================================================= */
 
+/* Arabic Shaping.  */
+
+enum
+{
+  UC_JOINING_TYPE_U, /* Non_Joining */
+  UC_JOINING_TYPE_T, /* Transparent */
+  UC_JOINING_TYPE_C, /* Join_Causing */
+  UC_JOINING_TYPE_L, /* Left_Joining */
+  UC_JOINING_TYPE_R, /* Right_Joining */
+  UC_JOINING_TYPE_D  /* Dual_Joining */
+};
+
+static uint8_t unicode_joining_type[0x110000];
+
+enum
+{
+  UC_JOINING_GROUP_NONE,                  /* No_Joining_Group */
+  UC_JOINING_GROUP_AIN,                   /* Ain */
+  UC_JOINING_GROUP_ALAPH,                 /* Alaph */
+  UC_JOINING_GROUP_ALEF,                  /* Alef */
+  UC_JOINING_GROUP_BEH,                   /* Beh */
+  UC_JOINING_GROUP_BETH,                  /* Beth */
+  UC_JOINING_GROUP_BURUSHASKI_YEH_BARREE, /* Burushaski_Yeh_Barree */
+  UC_JOINING_GROUP_DAL,                   /* Dal */
+  UC_JOINING_GROUP_DALATH_RISH,           /* Dalath_Rish */
+  UC_JOINING_GROUP_E,                     /* E */
+  UC_JOINING_GROUP_FARSI_YEH,             /* Farsi_Yeh */
+  UC_JOINING_GROUP_FE,                    /* Fe */
+  UC_JOINING_GROUP_FEH,                   /* Feh */
+  UC_JOINING_GROUP_FINAL_SEMKATH,         /* Final_Semkath */
+  UC_JOINING_GROUP_GAF,                   /* Gaf */
+  UC_JOINING_GROUP_GAMAL,                 /* Gamal */
+  UC_JOINING_GROUP_HAH,                   /* Hah */
+  UC_JOINING_GROUP_HE,                    /* He */
+  UC_JOINING_GROUP_HEH,                   /* Heh */
+  UC_JOINING_GROUP_HEH_GOAL,              /* Heh_Goal */
+  UC_JOINING_GROUP_HETH,                  /* Heth */
+  UC_JOINING_GROUP_KAF,                   /* Kaf */
+  UC_JOINING_GROUP_KAPH,                  /* Kaph */
+  UC_JOINING_GROUP_KHAPH,                 /* Khaph */
+  UC_JOINING_GROUP_KNOTTED_HEH,           /* Knotted_Heh */
+  UC_JOINING_GROUP_LAM,                   /* Lam */
+  UC_JOINING_GROUP_LAMADH,                /* Lamadh */
+  UC_JOINING_GROUP_MEEM,                  /* Meem */
+  UC_JOINING_GROUP_MIM,                   /* Mim */
+  UC_JOINING_GROUP_NOON,                  /* Noon */
+  UC_JOINING_GROUP_NUN,                   /* Nun */
+  UC_JOINING_GROUP_NYA,                   /* Nya */
+  UC_JOINING_GROUP_PE,                    /* Pe */
+  UC_JOINING_GROUP_QAF,                   /* Qaf */
+  UC_JOINING_GROUP_QAPH,                  /* Qaph */
+  UC_JOINING_GROUP_REH,                   /* Reh */
+  UC_JOINING_GROUP_REVERSED_PE,           /* Reversed_Pe */
+  UC_JOINING_GROUP_SAD,                   /* Sad */
+  UC_JOINING_GROUP_SADHE,                 /* Sadhe */
+  UC_JOINING_GROUP_SEEN,                  /* Seen */
+  UC_JOINING_GROUP_SEMKATH,               /* Semkath */
+  UC_JOINING_GROUP_SHIN,                  /* Shin */
+  UC_JOINING_GROUP_SWASH_KAF,             /* Swash_Kaf */
+  UC_JOINING_GROUP_SYRIAC_WAW,            /* Syriac_Waw */
+  UC_JOINING_GROUP_TAH,                   /* Tah */
+  UC_JOINING_GROUP_TAW,                   /* Taw */
+  UC_JOINING_GROUP_TEH_MARBUTA,           /* Teh_Marbuta */
+  UC_JOINING_GROUP_TEH_MARBUTA_GOAL,      /* Teh_Marbuta_Goal */
+  UC_JOINING_GROUP_TETH,                  /* Teth */
+  UC_JOINING_GROUP_WAW,                   /* Waw */
+  UC_JOINING_GROUP_YEH,                   /* Yeh */
+  UC_JOINING_GROUP_YEH_BARREE,            /* Yeh_Barree */
+  UC_JOINING_GROUP_YEH_WITH_TAIL,         /* Yeh_With_Tail */
+  UC_JOINING_GROUP_YUDH,                  /* Yudh */
+  UC_JOINING_GROUP_YUDH_HE,               /* Yudh_He */
+  UC_JOINING_GROUP_ZAIN,                  /* Zain */
+  UC_JOINING_GROUP_ZHAIN                  /* Zhain */
+};
+
+static uint8_t unicode_joining_group[0x110000];
+
+static void
+fill_arabicshaping (const char *arabicshaping_filename)
+{
+  FILE *stream;
+  unsigned int i;
+  int lineno;
+
+  stream = fopen (arabicshaping_filename, "r");
+  if (stream == NULL)
+    {
+      fprintf (stderr, "error during fopen of '%s'\n", arabicshaping_filename);
+      exit (1);
+    }
+
+  for (i = 0; i < 0x110000; i++)
+    {
+      unicode_joining_type[i] = (uint8_t)~(uint8_t)0;
+      unicode_joining_group[i] = UC_JOINING_GROUP_NONE;
+    }
+
+  lineno = 0;
+  for (;;)
+    {
+      char buf[100+1];
+      char separator1[100+1];
+      char padding1[100+1];
+      char schematic_name[100+1];
+      char separator2[100+1];
+      char padding2[100+1];
+      char joining_type_name[100+1];
+      char separator3[100+1];
+      char padding3[100+1];
+      char joining_group_name[100+1];
+      int joining_type;
+      int joining_group;
+
+      lineno++;
+      if (fscanf (stream, "%100[^\n]\n", buf) < 1)
+        break;
+
+      if (buf[0] == '\0' || buf[0] == '#')
+        continue;
+
+      if (sscanf (buf, "%X%[;]%[ ]%[^;]%[;]%[ ]%[^;]%[;]%[ ]%100[^\n]",
+                  &i, separator1, padding1, schematic_name, separator2,
+                  padding2, joining_type_name, separator3, padding3,
+                  joining_group_name) != 10)
+        {
+          fprintf (stderr, "parse error in '%s':%d\n",
+                   arabicshaping_filename, lineno);
+          exit (1);
+        }
+      if (i >= 0x110000)
+        abort ();
+
+#define TRY(name) else if (strcmp (joining_type_name, #name + 16) == 0) joining_type = name;
+      if (false) {}
+      TRY(UC_JOINING_TYPE_U)
+      TRY(UC_JOINING_TYPE_T)
+      TRY(UC_JOINING_TYPE_C)
+      TRY(UC_JOINING_TYPE_L)
+      TRY(UC_JOINING_TYPE_R)
+      TRY(UC_JOINING_TYPE_D)
+#undef TRY
+      else
+        {
+          fprintf (stderr, "unknown joining type value \"%s\" in '%s':%d\n",
+                   joining_type_name, arabicshaping_filename, lineno);
+          exit (1);
+        }
+
+      /* Remove trailing spaces.  */
+      while (joining_group_name[0] != '\0'
+             && joining_group_name[strlen (joining_group_name) - 1] == ' ')
+        joining_group_name[strlen (joining_group_name) - 1] = '\0';
+
+#define TRY(value,name) else if (strcmp (joining_group_name, name) == 0) joining_group = value;
+      if (false) {}
+      TRY(UC_JOINING_GROUP_NONE,                  "No_Joining_Group")
+      TRY(UC_JOINING_GROUP_AIN,                   "AIN")
+      TRY(UC_JOINING_GROUP_ALAPH,                 "ALAPH")
+      TRY(UC_JOINING_GROUP_ALEF,                  "ALEF")
+      TRY(UC_JOINING_GROUP_BEH,                   "BEH")
+      TRY(UC_JOINING_GROUP_BETH,                  "BETH")
+      TRY(UC_JOINING_GROUP_BURUSHASKI_YEH_BARREE, "BURUSHASKI YEH BARREE")
+      TRY(UC_JOINING_GROUP_DAL,                   "DAL")
+      TRY(UC_JOINING_GROUP_DALATH_RISH,           "DALATH RISH")
+      TRY(UC_JOINING_GROUP_E,                     "E")
+      TRY(UC_JOINING_GROUP_FARSI_YEH,             "FARSI YEH")
+      TRY(UC_JOINING_GROUP_FE,                    "FE")
+      TRY(UC_JOINING_GROUP_FEH,                   "FEH")
+      TRY(UC_JOINING_GROUP_FINAL_SEMKATH,         "FINAL SEMKATH")
+      TRY(UC_JOINING_GROUP_GAF,                   "GAF")
+      TRY(UC_JOINING_GROUP_GAMAL,                 "GAMAL")
+      TRY(UC_JOINING_GROUP_HAH,                   "HAH")
+      TRY(UC_JOINING_GROUP_HE,                    "HE")
+      TRY(UC_JOINING_GROUP_HEH,                   "HEH")
+      TRY(UC_JOINING_GROUP_HEH_GOAL,              "HEH GOAL")
+      TRY(UC_JOINING_GROUP_HETH,                  "HETH")
+      TRY(UC_JOINING_GROUP_KAF,                   "KAF")
+      TRY(UC_JOINING_GROUP_KAPH,                  "KAPH")
+      TRY(UC_JOINING_GROUP_KHAPH,                 "KHAPH")
+      TRY(UC_JOINING_GROUP_KNOTTED_HEH,           "KNOTTED HEH")
+      TRY(UC_JOINING_GROUP_LAM,                   "LAM")
+      TRY(UC_JOINING_GROUP_LAMADH,                "LAMADH")
+      TRY(UC_JOINING_GROUP_MEEM,                  "MEEM")
+      TRY(UC_JOINING_GROUP_MIM,                   "MIM")
+      TRY(UC_JOINING_GROUP_NOON,                  "NOON")
+      TRY(UC_JOINING_GROUP_NUN,                   "NUN")
+      TRY(UC_JOINING_GROUP_NYA,                   "NYA")
+      TRY(UC_JOINING_GROUP_PE,                    "PE")
+      TRY(UC_JOINING_GROUP_QAF,                   "QAF")
+      TRY(UC_JOINING_GROUP_QAPH,                  "QAPH")
+      TRY(UC_JOINING_GROUP_REH,                   "REH")
+      TRY(UC_JOINING_GROUP_REVERSED_PE,           "REVERSED PE")
+      TRY(UC_JOINING_GROUP_SAD,                   "SAD")
+      TRY(UC_JOINING_GROUP_SADHE,                 "SADHE")
+      TRY(UC_JOINING_GROUP_SEEN,                  "SEEN")
+      TRY(UC_JOINING_GROUP_SEMKATH,               "SEMKATH")
+      TRY(UC_JOINING_GROUP_SHIN,                  "SHIN")
+      TRY(UC_JOINING_GROUP_SWASH_KAF,             "SWASH KAF")
+      TRY(UC_JOINING_GROUP_SYRIAC_WAW,            "SYRIAC WAW")
+      TRY(UC_JOINING_GROUP_TAH,                   "TAH")
+      TRY(UC_JOINING_GROUP_TAW,                   "TAW")
+      TRY(UC_JOINING_GROUP_TEH_MARBUTA,           "TEH MARBUTA")
+      TRY(UC_JOINING_GROUP_TEH_MARBUTA_GOAL,      "TEH MARBUTA GOAL")
+      TRY(UC_JOINING_GROUP_TETH,                  "TETH")
+      TRY(UC_JOINING_GROUP_WAW,                   "WAW")
+      TRY(UC_JOINING_GROUP_YEH,                   "YEH")
+      TRY(UC_JOINING_GROUP_YEH_BARREE,            "YEH BARREE")
+      TRY(UC_JOINING_GROUP_YEH_WITH_TAIL,         "YEH WITH TAIL")
+      TRY(UC_JOINING_GROUP_YUDH,                  "YUDH")
+      TRY(UC_JOINING_GROUP_YUDH_HE,               "YUDH HE")
+      TRY(UC_JOINING_GROUP_ZAIN,                  "ZAIN")
+      TRY(UC_JOINING_GROUP_ZHAIN,                 "ZHAIN")
+#undef TRY
+      else
+        {
+          fprintf (stderr, "unknown joining group value \"%s\" in '%s':%d\n",
+                   joining_group_name, arabicshaping_filename, lineno);
+          exit (1);
+        }
+
+      unicode_joining_type[i] = joining_type;
+      unicode_joining_group[i] = joining_group;
+    }
+
+  if (ferror (stream) || fclose (stream))
+    {
+      fprintf (stderr, "error reading from '%s'\n", arabicshaping_filename);
+      exit (1);
+    }
+}
+
+/* Convert a Joining_Type value to a C identifier.  */
+static const char *
+joining_type_as_c_identifier (int joining_type)
+{
+#define TRY(value) if (joining_type == value) return #value;
+  TRY(UC_JOINING_TYPE_U)
+  TRY(UC_JOINING_TYPE_T)
+  TRY(UC_JOINING_TYPE_C)
+  TRY(UC_JOINING_TYPE_L)
+  TRY(UC_JOINING_TYPE_R)
+  TRY(UC_JOINING_TYPE_D)
+#undef TRY
+  abort ();
+}
+
+static void
+output_joining_type_test (const char *filename, const char *version)
+{
+  FILE *stream;
+  bool need_comma;
+  unsigned int ch;
+
+  stream = fopen (filename, "w");
+  if (stream == NULL)
+    {
+      fprintf (stderr, "cannot open '%s' for writing\n", filename);
+      exit (1);
+    }
+
+  fprintf (stream, "/* DO NOT EDIT! GENERATED AUTOMATICALLY! */\n");
+  fprintf (stream, "/* Arabic joining type of Unicode characters.  */\n");
+  fprintf (stream, "/* Generated automatically by gen-uni-tables.c for Unicode %s.  */\n",
+           version);
+
+  need_comma = false;
+  for (ch = 0; ch < 0x110000; ch++)
+    {
+      int value = unicode_joining_type[ch];
+
+      if (value != (uint8_t)~(uint8_t)0)
+        {
+          if (need_comma)
+            fprintf (stream, ",\n");
+          fprintf (stream, "    { 0x%04X, %s }", ch, joining_type_as_c_identifier (value));
+          need_comma = true;
+        }
+    }
+  if (need_comma)
+    fprintf (stream, "\n");
+
+  if (ferror (stream) || fclose (stream))
+    {
+      fprintf (stderr, "error writing to '%s'\n", filename);
+      exit (1);
+    }
+}
+
+/* Construction of sparse 3-level tables.  */
+#define TABLE joining_type_table
+#define ELEMENT uint8_t
+#define DEFAULT (uint8_t)~(uint8_t)0
+#define xmalloc malloc
+#define xrealloc realloc
+#include "3level.h"
+
+static void
+output_joining_type (const char *filename, const char *version)
+{
+  FILE *stream;
+  unsigned int ch, i;
+  struct joining_type_table t;
+  unsigned int level1_offset, level2_offset, level3_offset;
+  uint8_t *level3_packed;
+
+  stream = fopen (filename, "w");
+  if (stream == NULL)
+    {
+      fprintf (stderr, "cannot open '%s' for writing\n", filename);
+      exit (1);
+    }
+
+  fprintf (stream, "/* DO NOT EDIT! GENERATED AUTOMATICALLY! */\n");
+  fprintf (stream, "/* Arabic joining type of Unicode characters.  */\n");
+  fprintf (stream, "/* Generated automatically by gen-uni-tables.c for Unicode %s.  */\n",
+           version);
+
+  t.p = 7;
+  t.q = 9;
+  joining_type_table_init (&t);
+
+  for (ch = 0; ch < 0x110000; ch++)
+    {
+      uint8_t value = unicode_joining_type[ch];
+
+      joining_type_table_add (&t, ch, value);
+    }
+
+  joining_type_table_finalize (&t);
+
+  /* Offsets in t.result, in memory of this process.  */
+  level1_offset =
+    5 * sizeof (uint32_t);
+  level2_offset =
+    5 * sizeof (uint32_t)
+    + t.level1_size * sizeof (uint32_t);
+  level3_offset =
+    5 * sizeof (uint32_t)
+    + t.level1_size * sizeof (uint32_t)
+    + (t.level2_size << t.q) * sizeof (uint32_t);
+
+  for (i = 0; i < 5; i++)
+    fprintf (stream, "#define joining_type_header_%d %d\n", i,
+             ((uint32_t *) t.result)[i]);
+  fprintf (stream, "static const\n");
+  fprintf (stream, "struct\n");
+  fprintf (stream, "  {\n");
+  fprintf (stream, "    int level1[%zu];\n", t.level1_size);
+  fprintf (stream, "    short level2[%zu << %d];\n", t.level2_size, t.q);
+  fprintf (stream, "    unsigned char level3[%zu * %d];\n", t.level3_size,
+           (1 << t.p) * 4 / 8);
+  fprintf (stream, "  }\n");
+  fprintf (stream, "u_joining_type =\n");
+  fprintf (stream, "{\n");
+  fprintf (stream, "  {");
+  if (t.level1_size > 8)
+    fprintf (stream, "\n   ");
+  for (i = 0; i < t.level1_size; i++)
+    {
+      uint32_t offset;
+      if (i > 0 && (i % 8) == 0)
+        fprintf (stream, "\n   ");
+      offset = ((uint32_t *) (t.result + level1_offset))[i];
+      if (offset == 0)
+        fprintf (stream, " %5d", -1);
+      else
+        fprintf (stream, " %5zu",
+                 (offset - level2_offset) / sizeof (uint32_t));
+      if (i+1 < t.level1_size)
+        fprintf (stream, ",");
+    }
+  if (t.level1_size > 8)
+    fprintf (stream, "\n ");
+  fprintf (stream, " },\n");
+  fprintf (stream, "  {");
+  if (t.level2_size << t.q > 8)
+    fprintf (stream, "\n   ");
+  for (i = 0; i < t.level2_size << t.q; i++)
+    {
+      uint32_t offset;
+      if (i > 0 && (i % 8) == 0)
+        fprintf (stream, "\n   ");
+      offset = ((uint32_t *) (t.result + level2_offset))[i];
+      if (offset == 0)
+        fprintf (stream, " %5d", -1);
+      else
+        fprintf (stream, " %5zu",
+                 (offset - level3_offset) / sizeof (uint8_t));
+      if (i+1 < t.level2_size << t.q)
+        fprintf (stream, ",");
+    }
+  if (t.level2_size << t.q > 8)
+    fprintf (stream, "\n ");
+  fprintf (stream, " },\n");
+  /* Pack the level3 array.  Each entry needs 4 bits only.  */
+  level3_packed =
+    (uint8_t *) calloc ((t.level3_size << t.p) * 4 / 8, sizeof (uint8_t));
+  for (i = 0; i < t.level3_size << t.p; i++)
+    {
+      unsigned int j = (i * 4) / 8;
+      unsigned int k = (i * 4) % 8;
+      uint32_t value = ((unsigned char *) (t.result + level3_offset))[i] & 0x0f;
+      level3_packed[j] |= (value << k);
+    }
+  fprintf (stream, "  {");
+  if ((t.level3_size << t.p) * 4 / 8 > 8)
+    fprintf (stream, "\n   ");
+  for (i = 0; i < (t.level3_size << t.p) * 4 / 8; i++)
+    {
+      if (i > 0 && (i % 8) == 0)
+        fprintf (stream, "\n   ");
+      fprintf (stream, " 0x%02x", level3_packed[i]);
+      if (i+1 < (t.level3_size << t.p) * 4 / 8)
+        fprintf (stream, ",");
+    }
+  if ((t.level3_size << t.p) * 4 / 8 > 8)
+    fprintf (stream, "\n ");
+  fprintf (stream, " }\n");
+  free (level3_packed);
+  fprintf (stream, "};\n");
+
+  if (ferror (stream) || fclose (stream))
+    {
+      fprintf (stderr, "error writing to '%s'\n", filename);
+      exit (1);
+    }
+}
+
+/* Convert a Joining_Group value to a C identifier.  */
+static const char *
+joining_group_as_c_identifier (int joining_group)
+{
+#define TRY(value) if (joining_group == value) return #value;
+  TRY(UC_JOINING_GROUP_NONE)
+  TRY(UC_JOINING_GROUP_AIN)
+  TRY(UC_JOINING_GROUP_ALAPH)
+  TRY(UC_JOINING_GROUP_ALEF)
+  TRY(UC_JOINING_GROUP_BEH)
+  TRY(UC_JOINING_GROUP_BETH)
+  TRY(UC_JOINING_GROUP_BURUSHASKI_YEH_BARREE)
+  TRY(UC_JOINING_GROUP_DAL)
+  TRY(UC_JOINING_GROUP_DALATH_RISH)
+  TRY(UC_JOINING_GROUP_E)
+  TRY(UC_JOINING_GROUP_FARSI_YEH)
+  TRY(UC_JOINING_GROUP_FE)
+  TRY(UC_JOINING_GROUP_FEH)
+  TRY(UC_JOINING_GROUP_FINAL_SEMKATH)
+  TRY(UC_JOINING_GROUP_GAF)
+  TRY(UC_JOINING_GROUP_GAMAL)
+  TRY(UC_JOINING_GROUP_HAH)
+  TRY(UC_JOINING_GROUP_HE)
+  TRY(UC_JOINING_GROUP_HEH)
+  TRY(UC_JOINING_GROUP_HEH_GOAL)
+  TRY(UC_JOINING_GROUP_HETH)
+  TRY(UC_JOINING_GROUP_KAF)
+  TRY(UC_JOINING_GROUP_KAPH)
+  TRY(UC_JOINING_GROUP_KHAPH)
+  TRY(UC_JOINING_GROUP_KNOTTED_HEH)
+  TRY(UC_JOINING_GROUP_LAM)
+  TRY(UC_JOINING_GROUP_LAMADH)
+  TRY(UC_JOINING_GROUP_MEEM)
+  TRY(UC_JOINING_GROUP_MIM)
+  TRY(UC_JOINING_GROUP_NOON)
+  TRY(UC_JOINING_GROUP_NUN)
+  TRY(UC_JOINING_GROUP_NYA)
+  TRY(UC_JOINING_GROUP_PE)
+  TRY(UC_JOINING_GROUP_QAF)
+  TRY(UC_JOINING_GROUP_QAPH)
+  TRY(UC_JOINING_GROUP_REH)
+  TRY(UC_JOINING_GROUP_REVERSED_PE)
+  TRY(UC_JOINING_GROUP_SAD)
+  TRY(UC_JOINING_GROUP_SADHE)
+  TRY(UC_JOINING_GROUP_SEEN)
+  TRY(UC_JOINING_GROUP_SEMKATH)
+  TRY(UC_JOINING_GROUP_SHIN)
+  TRY(UC_JOINING_GROUP_SWASH_KAF)
+  TRY(UC_JOINING_GROUP_SYRIAC_WAW)
+  TRY(UC_JOINING_GROUP_TAH)
+  TRY(UC_JOINING_GROUP_TAW)
+  TRY(UC_JOINING_GROUP_TEH_MARBUTA)
+  TRY(UC_JOINING_GROUP_TEH_MARBUTA_GOAL)
+  TRY(UC_JOINING_GROUP_TETH)
+  TRY(UC_JOINING_GROUP_WAW)
+  TRY(UC_JOINING_GROUP_YEH)
+  TRY(UC_JOINING_GROUP_YEH_BARREE)
+  TRY(UC_JOINING_GROUP_YEH_WITH_TAIL)
+  TRY(UC_JOINING_GROUP_YUDH)
+  TRY(UC_JOINING_GROUP_YUDH_HE)
+  TRY(UC_JOINING_GROUP_ZAIN)
+  TRY(UC_JOINING_GROUP_ZHAIN)
+#undef TRY
+  abort ();
+}
+
+static void
+output_joining_group_test (const char *filename, const char *version)
+{
+  FILE *stream;
+  bool need_comma;
+  unsigned int ch;
+
+  stream = fopen (filename, "w");
+  if (stream == NULL)
+    {
+      fprintf (stderr, "cannot open '%s' for writing\n", filename);
+      exit (1);
+    }
+
+  fprintf (stream, "/* DO NOT EDIT! GENERATED AUTOMATICALLY! */\n");
+  fprintf (stream, "/* Arabic joining group of Unicode characters.  */\n");
+  fprintf (stream, "/* Generated automatically by gen-uni-tables.c for Unicode %s.  */\n",
+           version);
+
+  need_comma = false;
+  for (ch = 0; ch < 0x110000; ch++)
+    {
+      int value = unicode_joining_group[ch];
+
+      if (value != UC_JOINING_GROUP_NONE)
+        {
+          if (need_comma)
+            fprintf (stream, ",\n");
+          fprintf (stream, "    { 0x%04X, %s }", ch, joining_group_as_c_identifier (value));
+          need_comma = true;
+        }
+    }
+  if (need_comma)
+    fprintf (stream, "\n");
+
+  if (ferror (stream) || fclose (stream))
+    {
+      fprintf (stderr, "error writing to '%s'\n", filename);
+      exit (1);
+    }
+}
+
+static void
+output_joining_group (const char *filename, const char *version)
+{
+  FILE *stream;
+  unsigned int ch_min, ch_max, ch, i;
+
+  stream = fopen (filename, "w");
+  if (stream == NULL)
+    {
+      fprintf (stderr, "cannot open '%s' for writing\n", filename);
+      exit (1);
+    }
+
+  fprintf (stream, "/* DO NOT EDIT! GENERATED AUTOMATICALLY! */\n");
+  fprintf (stream, "/* Arabic joining type of Unicode characters.  */\n");
+  fprintf (stream, "/* Generated automatically by gen-uni-tables.c for Unicode %s.  */\n",
+           version);
+
+  ch_min = 0x10FFFF;
+  for (ch = 0; ch < 0x110000; ch++)
+    if (unicode_joining_group[ch] != UC_JOINING_GROUP_NONE)
+      {
+        ch_min = ch;
+        break;
+      }
+
+  ch_max = 0;
+  for (ch = 0x10FFFF; ch > 0; ch--)
+    if (unicode_joining_group[ch] != UC_JOINING_GROUP_NONE)
+      {
+        ch_max = ch;
+        break;
+      }
+
+  if (!(ch_min <= ch_max))
+    abort ();
+
+  /* If the interval [ch_min, ch_max] is too large, we should better use a
+     3-level table.  */
+  if (!(ch_max - ch_min < 0x200))
+    abort ();
+
+  fprintf (stream, "#define joining_group_header_0 0x%x\n", ch_min);
+  fprintf (stream, "static const unsigned char u_joining_group[0x%x - 0x%x] =\n",
+           ch_max + 1, ch_min);
+  fprintf (stream, "{");
+  for (i = 0; i <= ch_max - ch_min; i++)
+    {
+      const char *s;
+
+      ch = ch_min + i;
+      if ((i % 2) == 0)
+        fprintf (stream, "\n ");
+      s = joining_group_as_c_identifier (unicode_joining_group[ch]);
+      fprintf (stream, " %s", s);
+      if (i+1 <= ch_max - ch_min)
+        {
+          fprintf (stream, ",");
+          if (((i+1) % 2) != 0)
+            fprintf (stream, "%*s", 38 - (int) strlen (s), "");
+        }
+    }
+  fprintf (stream, "\n");
+  fprintf (stream, "};\n");
+
+  if (ferror (stream) || fclose (stream))
+    {
+      fprintf (stderr, "error writing to '%s'\n", filename);
+      exit (1);
+    }
+}
+
+/* ========================================================================= */
+
 /* Scripts.  */
 
 static const char *scripts[256];
@@ -3943,7 +4570,7 @@
   fprintf (stream, "/* Unicode scripts.  */\n");
   fprintf (stream, "/* Generated automatically by gen-uni-tables.c for Unicode %s.  */\n",
            version);
-  fprintf (stream, "struct named_script { const char *name; unsigned int index; };\n");
+  fprintf (stream, "struct named_script { int name; unsigned int index; };\n");
   fprintf (stream, "%%struct-type\n");
   fprintf (stream, "%%language=ANSI-C\n");
   fprintf (stream, "%%define hash-function-name scripts_hash\n");
@@ -3951,6 +4578,8 @@
   fprintf (stream, "%%readonly-tables\n");
   fprintf (stream, "%%global-table\n");
   fprintf (stream, "%%define word-array-name script_names\n");
+  fprintf (stream, "%%pic\n");
+  fprintf (stream, "%%define string-pool-name script_stringpool\n");
   fprintf (stream, "%%%%\n");
   for (s = 0; s < numscripts; s++)
     fprintf (stream, "%s, %u\n", scripts[s], s);
@@ -5251,6 +5880,7 @@
           unicode_width[i] = strdup (field1);
         }
     }
+
   if (ferror (stream) || fclose (stream))
     {
       fprintf (stderr, "error reading from '%s'\n", width_filename);
@@ -6398,6 +7028,7 @@
           unicode_org_lbp[i] = value;
         }
     }
+
   if (ferror (stream) || fclose (stream))
     {
       fprintf (stderr, "error reading from '%s'\n", linebreak_filename);
@@ -7478,6 +8109,7 @@
       for (i = i1; i <= i2; i++)
         unicode_org_gbp[i] = propvalue;
     }
+
   if (ferror (stream) || fclose (stream))
     {
       fprintf (stderr, "error reading from '%s'\n", graphemebreakproperty_filename);
@@ -9013,6 +9645,7 @@
   const char *unicodedata_filename;
   const char *proplist_filename;
   const char *derivedproplist_filename;
+  const char *arabicshaping_filename;
   const char *scripts_filename;
   const char *blocks_filename;
   const char *proplist30_filename;
@@ -9025,9 +9658,9 @@
   const char *casefolding_filename;
   const char *version;
 
-  if (argc != 15)
-    {
-      fprintf (stderr, "Usage: %s UnicodeData.txt PropList.txt DerivedCoreProperties.txt Scripts.txt Blocks.txt PropList-3.0.1.txt EastAsianWidth.txt LineBreak.txt WordBreakProperty.txt GraphemeBreakProperty.txt CompositionExclusions.txt SpecialCasing.txt CaseFolding.txt version\n",
+  if (argc != 16)
+    {
+      fprintf (stderr, "Usage: %s UnicodeData.txt PropList.txt DerivedCoreProperties.txt ArabicShaping.txt Scripts.txt Blocks.txt PropList-3.0.1.txt EastAsianWidth.txt LineBreak.txt WordBreakProperty.txt GraphemeBreakProperty.txt CompositionExclusions.txt SpecialCasing.txt CaseFolding.txt version\n",
                argv[0]);
       exit (1);
     }
@@ -9035,23 +9668,25 @@
   unicodedata_filename = argv[1];
   proplist_filename = argv[2];
   derivedproplist_filename = argv[3];
-  scripts_filename = argv[4];
-  blocks_filename = argv[5];
-  proplist30_filename = argv[6];
-  eastasianwidth_filename = argv[7];
-  linebreak_filename = argv[8];
-  wordbreakproperty_filename = argv[9];
-  graphemebreakproperty_filename = argv[10];
-  compositionexclusions_filename = argv[11];
-  specialcasing_filename = argv[12];
-  casefolding_filename = argv[13];
-  version = argv[14];
+  arabicshaping_filename = argv[4];
+  scripts_filename = argv[5];
+  blocks_filename = argv[6];
+  proplist30_filename = argv[7];
+  eastasianwidth_filename = argv[8];
+  linebreak_filename = argv[9];
+  wordbreakproperty_filename = argv[10];
+  graphemebreakproperty_filename = argv[11];
+  compositionexclusions_filename = argv[12];
+  specialcasing_filename = argv[13];
+  casefolding_filename = argv[14];
+  version = argv[15];
 
   fill_attributes (unicodedata_filename);
   clear_properties ();
   fill_properties (proplist_filename);
   fill_properties (derivedproplist_filename);
   fill_properties30 (proplist30_filename);
+  fill_arabicshaping (arabicshaping_filename);
   fill_scripts (scripts_filename);
   fill_blocks (blocks_filename);
   fill_width (eastasianwidth_filename);
@@ -9066,7 +9701,7 @@
 
   output_categories (version);
   output_category ("unictype/categ_of.h", version);
-  output_combclass ("unictype/combining.h", version);
+  output_combclass ("unictype/combiningclass.h", version);
   output_bidi_category ("unictype/bidi_of.h", version);
   output_decimal_digit_test ("../tests/unictype/test-decdigit.h", version);
   output_decimal_digit ("unictype/decdigit.h", version);
@@ -9076,6 +9711,11 @@
   output_numeric ("unictype/numeric.h", version);
   output_mirror ("unictype/mirror.h", version);
   output_properties (version);
+  output_joining_type_test ("../tests/unictype/test-joiningtype_of.h", version);
+  output_joining_type ("unictype/joiningtype_of.h", version);
+  output_joining_group_test ("../tests/unictype/test-joininggroup_of.h", version);
+  output_joining_group ("unictype/joininggroup_of.h", version);
+
   output_scripts (version);
   output_scripts_byname (version);
   output_blocks (version);
@@ -9121,6 +9761,7 @@
         /gfs/petix/Volumes/ExtData/www-archive/software/i18n/unicode/ftp.unicode.org/ArchiveVersions/6.0.0/ucd/UnicodeData.txt \
         /gfs/petix/Volumes/ExtData/www-archive/software/i18n/unicode/ftp.unicode.org/ArchiveVersions/6.0.0/ucd/PropList.txt \
         /gfs/petix/Volumes/ExtData/www-archive/software/i18n/unicode/ftp.unicode.org/ArchiveVersions/6.0.0/ucd/DerivedCoreProperties.txt \
+        /gfs/petix/Volumes/ExtData/www-archive/software/i18n/unicode/ftp.unicode.org/ArchiveVersions/6.0.0/ucd/ArabicShaping.txt \
         /gfs/petix/Volumes/ExtData/www-archive/software/i18n/unicode/ftp.unicode.org/ArchiveVersions/6.0.0/ucd/Scripts.txt \
         /gfs/petix/Volumes/ExtData/www-archive/software/i18n/unicode/ftp.unicode.org/ArchiveVersions/6.0.0/ucd/Blocks.txt \
         /gfs/petix/Volumes/ExtData/www-archive/software/i18n/unicode/ftp.unicode.org/ArchiveVersions/3.0.1/PropList-3.0.1.txt \
--- a/lib/getloadavg.c
+++ b/lib/getloadavg.c
@@ -94,11 +94,6 @@
 #include <errno.h>
 #include <stdio.h>
 
-/* Exclude all the code except the test program at the end
-   if the system has its own `getloadavg' function.  */
-
-#ifndef HAVE_GETLOADAVG
-
 # include <sys/types.h>
 
 /* Both the Emacs and non-Emacs sections want this.  Some
@@ -108,8 +103,6 @@
 #  include <sys/param.h>
 # endif
 
-# include "c-strtod.h"
-# include "cloexec.h"
 # include "intprops.h"
 
 /* The existing Emacs configuration files define a macro called
@@ -372,7 +365,6 @@
 #    endif /* NLIST_STRUCT */
 
 #    ifdef SUNOS_5
-#     include <fcntl.h>
 #     include <kvm.h>
 #     include <kstat.h>
 #    endif
@@ -461,7 +453,10 @@
 #  include <sys/dg_sys_info.h>
 # endif
 
-# include "fcntl--.h"
+# if (defined __linux__ || defined __CYGWIN__ || defined SUNOS_5        \
+      || (defined LOAD_AVE_TYPE && ! defined __VMS))
+#  include <fcntl.h>
+# endif
 
 /* Avoid static vars inside a function since in HPUX they dump as pure.  */
 
@@ -482,13 +477,13 @@
 # if !defined (HAVE_LIBKSTAT) && defined (LOAD_AVE_TYPE)
 /* File descriptor open to /dev/kmem or VMS load ave driver.  */
 static int channel;
-/* True iff channel is valid.  */
+/* True if channel is valid.  */
 static bool getloadavg_initialized;
 /* Offset in kmem to seek to read load average, or 0 means invalid.  */
 static long offset;
 
 #  if ! defined __VMS && ! defined sgi && ! defined __linux__
-static struct nlist nl[2];
+static struct nlist name_list[2];
 #  endif
 
 #  ifdef SUNOS_5
@@ -500,7 +495,7 @@
 /* Put the 1 minute, 5 minute and 15 minute load averages
    into the first NELEM elements of LOADAVG.
    Return the number written (never more than 3, but may be less than NELEM),
-   or -1 if an error occurred.  */
+   or -1 (setting errno) if an error occurred.  */
 
 int
 getloadavg (double loadavg[], int nelem)
@@ -509,18 +504,17 @@
 
 # ifdef NO_GET_LOAD_AVG
 #  define LDAV_DONE
-  /* Set errno to zero to indicate that there was no particular error;
-     this function just can't work at all on this system.  */
-  errno = 0;
+  errno = ENOSYS;
   elem = -1;
 # endif
 
-# if !defined (LDAV_DONE) && defined (HAVE_LIBKSTAT)
+# if !defined (LDAV_DONE) && defined (HAVE_LIBKSTAT)       /* Solaris <= 2.6 */
 /* Use libkstat because we don't have to be root.  */
 #  define LDAV_DONE
   kstat_ctl_t *kc;
   kstat_t *ksp;
   kstat_named_t *kn;
+  int saved_errno;
 
   kc = kstat_open ();
   if (kc == 0)
@@ -559,10 +553,13 @@
         }
     }
 
+  saved_errno = errno;
   kstat_close (kc);
+  errno = saved_errno;
 # endif /* HAVE_LIBKSTAT */
 
 # if !defined (LDAV_DONE) && defined (hpux) && defined (HAVE_PSTAT_GETDYNAMIC)
+                                                           /* HP-UX */
 /* Use pstat_getdynamic() because we don't have to be root.  */
 #  define LDAV_DONE
 #  undef LOAD_AVE_TYPE
@@ -579,7 +576,7 @@
 
 # endif /* hpux && HAVE_PSTAT_GETDYNAMIC */
 
-# if ! defined LDAV_DONE && defined HAVE_LIBPERFSTAT
+# if ! defined LDAV_DONE && defined HAVE_LIBPERFSTAT       /* AIX */
 #  define LDAV_DONE
 #  undef LOAD_AVE_TYPE
 /* Use perfstat_cpu_total because we don't have to be root. */
@@ -596,6 +593,7 @@
 # endif
 
 # if !defined (LDAV_DONE) && (defined (__linux__) || defined (__CYGWIN__))
+                                              /* Linux without glibc, Cygwin */
 #  define LDAV_DONE
 #  undef LOAD_AVE_TYPE
 
@@ -605,39 +603,54 @@
 
   char ldavgbuf[3 * (INT_STRLEN_BOUND (int) + sizeof ".00 ")];
   char const *ptr = ldavgbuf;
-  int fd, count;
+  int fd, count, saved_errno;
 
   fd = open (LINUX_LDAV_FILE, O_RDONLY);
   if (fd == -1)
     return -1;
   count = read (fd, ldavgbuf, sizeof ldavgbuf - 1);
+  saved_errno = errno;
   (void) close (fd);
+  errno = saved_errno;
   if (count <= 0)
     return -1;
   ldavgbuf[count] = '\0';
 
   for (elem = 0; elem < nelem; elem++)
     {
-      char *endptr;
-      double d;
+      double numerator = 0;
+      double denominator = 1;
 
-      errno = 0;
-      d = c_strtod (ptr, &endptr);
-      if (ptr == endptr || (d == 0 && errno != 0))
+      while (*ptr == ' ')
+        ptr++;
+
+      /* Finish if this number is missing, and report an error if all
+         were missing.  */
+      if (! ('0' <= *ptr && *ptr <= '9'))
         {
           if (elem == 0)
-            return -1;
+            {
+              errno = ENOTSUP;
+              return -1;
+            }
           break;
         }
-      loadavg[elem] = d;
-      ptr = endptr;
+
+      while ('0' <= *ptr && *ptr <= '9')
+        numerator = 10 * numerator + (*ptr++ - '0');
+
+      if (*ptr == '.')
+        for (ptr++; '0' <= *ptr && *ptr <= '9'; ptr++)
+          numerator = 10 * numerator + (*ptr - '0'), denominator *= 10;
+
+      loadavg[elem++] = numerator / denominator;
     }
 
   return elem;
 
 # endif /* __linux__ || __CYGWIN__ */
 
-# if !defined (LDAV_DONE) && defined (__NetBSD__)
+# if !defined (LDAV_DONE) && defined (__NetBSD__)          /* NetBSD < 0.9 */
 #  define LDAV_DONE
 #  undef LOAD_AVE_TYPE
 
@@ -657,7 +670,10 @@
                   &scale);
   (void) fclose (fp);
   if (count != 4)
-    return -1;
+    {
+      errno = ENOTSUP;
+      return -1;
+    }
 
   for (elem = 0; elem < nelem; elem++)
     loadavg[elem] = (double) load_ave[elem] / (double) scale;
@@ -666,7 +682,7 @@
 
 # endif /* __NetBSD__ */
 
-# if !defined (LDAV_DONE) && defined (NeXT)
+# if !defined (LDAV_DONE) && defined (NeXT)                /* NeXTStep */
 #  define LDAV_DONE
   /* The NeXT code was adapted from iscreen 3.2.  */
 
@@ -698,7 +714,10 @@
     }
 
   if (!getloadavg_initialized)
-    return -1;
+    {
+      errno = ENOTSUP;
+      return -1;
+    }
 # endif /* NeXT */
 
 # if !defined (LDAV_DONE) && defined (UMAX)
@@ -732,7 +751,7 @@
       for (i = 0; i < conf.config_maxclass; ++i)
         {
           struct class_stats stats;
-          bzero ((char *) &stats, sizeof stats);
+          memset (&stats, 0, sizeof stats);
 
           desc.sd_type = CPUTYPE_CLASS;
           desc.sd_objid = i;
@@ -825,6 +844,7 @@
 # endif /* OSF_MIPS */
 
 # if !defined (LDAV_DONE) && (defined (__MSDOS__) || defined (WINDOWS32))
+                                                           /* DJGPP */
 #  define LDAV_DONE
 
   /* A faithful emulation is going to have to be saved for a rainy day.  */
@@ -834,7 +854,7 @@
     }
 # endif  /* __MSDOS__ || WINDOWS32 */
 
-# if !defined (LDAV_DONE) && defined (OSF_ALPHA)
+# if !defined (LDAV_DONE) && defined (OSF_ALPHA)           /* OSF/1 */
 #  define LDAV_DONE
 
   struct tbl_loadavg load_ave;
@@ -846,7 +866,7 @@
          : (load_ave.tl_avenrun.l[elem] / (double) load_ave.tl_lscale));
 # endif /* OSF_ALPHA */
 
-# if ! defined LDAV_DONE && defined __VMS
+# if ! defined LDAV_DONE && defined __VMS                  /* VMS */
   /* VMS specific code -- read from the Load Ave driver.  */
 
   LOAD_AVE_TYPE load_ave[3];
@@ -883,10 +903,14 @@
     }
 
   if (!getloadavg_initialized)
-    return -1;
+    {
+      errno = ENOTSUP;
+      return -1;
+    }
 # endif /* ! defined LDAV_DONE && defined __VMS */
 
 # if ! defined LDAV_DONE && defined LOAD_AVE_TYPE && ! defined __VMS
+                                                  /* IRIX, other old systems */
 
   /* UNIX-specific code -- read the average from /dev/kmem.  */
 
@@ -899,38 +923,36 @@
     {
 #  ifndef sgi
 #   if ! defined NLIST_STRUCT || ! defined N_NAME_POINTER
-      strcpy (nl[0].n_name, LDAV_SYMBOL);
-      strcpy (nl[1].n_name, "");
+      strcpy (name_list[0].n_name, LDAV_SYMBOL);
+      strcpy (name_list[1].n_name, "");
 #   else /* NLIST_STRUCT */
 #    ifdef HAVE_STRUCT_NLIST_N_UN_N_NAME
-      nl[0].n_un.n_name = LDAV_SYMBOL;
-      nl[1].n_un.n_name = 0;
+      name_list[0].n_un.n_name = LDAV_SYMBOL;
+      name_list[1].n_un.n_name = 0;
 #    else /* not HAVE_STRUCT_NLIST_N_UN_N_NAME */
-      nl[0].n_name = LDAV_SYMBOL;
-      nl[1].n_name = 0;
+      name_list[0].n_name = LDAV_SYMBOL;
+      name_list[1].n_name = 0;
 #    endif /* not HAVE_STRUCT_NLIST_N_UN_N_NAME */
 #   endif /* NLIST_STRUCT */
 
 #   ifndef SUNOS_5
       if (
 #    if !(defined (_AIX) && !defined (ps2))
-          nlist (KERNEL_FILE, nl)
+          nlist (KERNEL_FILE, name_list)
 #    else  /* _AIX */
-          knlist (nl, 1, sizeof (nl[0]))
+          knlist (name_list, 1, sizeof (name_list[0]))
 #    endif
           >= 0)
-          /* Omit "&& nl[0].n_type != 0 " -- it breaks on Sun386i.  */
+          /* Omit "&& name_list[0].n_type != 0 " -- it breaks on Sun386i.  */
           {
 #    ifdef FIXUP_KERNEL_SYMBOL_ADDR
-            FIXUP_KERNEL_SYMBOL_ADDR (nl);
+            FIXUP_KERNEL_SYMBOL_ADDR (name_list);
 #    endif
-            offset = nl[0].n_value;
+            offset = name_list[0].n_value;
           }
 #   endif /* !SUNOS_5 */
 #  else  /* sgi */
-      int ldav_off;
-
-      ldav_off = sysmp (MP_KERNADDR, MPKA_AVENRUN);
+      ptrdiff_t ldav_off = sysmp (MP_KERNADDR, MPKA_AVENRUN);
       if (ldav_off != -1)
         offset = (long int) ldav_off & 0x7fffffff;
 #  endif /* sgi */
@@ -940,13 +962,27 @@
   if (!getloadavg_initialized)
     {
 #  ifndef SUNOS_5
-      channel = open ("/dev/kmem", O_RDONLY);
-      if (channel >= 0)
+      /* Set the channel to close on exec, so it does not
+         litter any child's descriptor table.  */
+#   ifndef O_CLOEXEC
+#    define O_CLOEXEC 0
+#   endif
+      int fd = open ("/dev/kmem", O_RDONLY | O_CLOEXEC);
+      if (0 <= fd)
         {
-          /* Set the channel to close on exec, so it does not
-             litter any child's descriptor table.  */
-          set_cloexec_flag (channel, true);
-          getloadavg_initialized = true;
+#   if F_DUPFD_CLOEXEC
+          if (fd <= STDERR_FILENO)
+            {
+              int fd1 = fcntl (fd, F_DUPFD_CLOEXEC, STDERR_FILENO + 1);
+              close (fd);
+              fd = fd1;
+            }
+#   endif
+          if (0 <= fd)
+            {
+              channel = fd;
+              getloadavg_initialized = true;
+            }
         }
 #  else /* SUNOS_5 */
       /* We pass 0 for the kernel, corefile, and swapfile names
@@ -955,8 +991,8 @@
       if (kd != 0)
         {
           /* nlist the currently running kernel.  */
-          kvm_nlist (kd, nl);
-          offset = nl[0].n_value;
+          kvm_nlist (kd, name_list);
+          offset = name_list[0].n_value;
           getloadavg_initialized = true;
         }
 #  endif /* SUNOS_5 */
@@ -985,7 +1021,10 @@
     }
 
   if (offset == 0 || !getloadavg_initialized)
-    return -1;
+    {
+      errno = ENOTSUP;
+      return -1;
+    }
 # endif /* ! defined LDAV_DONE && defined LOAD_AVE_TYPE && ! defined __VMS */
 
 # if !defined (LDAV_DONE) && defined (LOAD_AVE_TYPE) /* Including VMS.  */
@@ -1000,51 +1039,8 @@
 # endif /* !LDAV_DONE && LOAD_AVE_TYPE */
 
 # if !defined LDAV_DONE
-  /* Set errno to zero to indicate that there was no particular error;
-     this function just can't work at all on this system.  */
-  errno = 0;
+  errno = ENOSYS;
   elem = -1;
 # endif
   return elem;
 }
-
-#endif /* ! HAVE_GETLOADAVG */
-
-#ifdef TEST
-int
-main (int argc, char **argv)
-{
-  int naptime = 0;
-
-  if (argc > 1)
-    naptime = atoi (argv[1]);
-
-  while (1)
-    {
-      double avg[3];
-      int loads;
-
-      errno = 0;                /* Don't be misled if it doesn't set errno.  */
-      loads = getloadavg (avg, 3);
-      if (loads == -1)
-        {
-          perror ("Error getting load average");
-          return EXIT_FAILURE;
-        }
-      if (loads > 0)
-        printf ("1-minute: %f  ", avg[0]);
-      if (loads > 1)
-        printf ("5-minute: %f  ", avg[1]);
-      if (loads > 2)
-        printf ("15-minute: %f  ", avg[2]);
-      if (loads > 0)
-        putchar ('\n');
-
-      if (naptime == 0)
-        break;
-      sleep (naptime);
-    }
-
-  return EXIT_SUCCESS;
-}
-#endif /* TEST */
--- a/lib/getopt.in.h
+++ b/lib/getopt.in.h
@@ -181,6 +181,7 @@
    one).  For long options that have a zero `flag' field, `getopt'
    returns the contents of the `val' field.  */
 
+# if !GNULIB_defined_struct_option
 struct option
 {
   const char *name;
@@ -190,6 +191,8 @@
   int *flag;
   int val;
 };
+#  define GNULIB_defined_struct_option 1
+# endif
 
 /* Names for the values of the `has_arg' field of `struct option'.  */
 
--- a/lib/getopt_int.h
+++ b/lib/getopt_int.h
@@ -108,7 +108,7 @@
 #if defined _LIBC && defined USE_NONOPTION_FLAGS
   int __nonoption_flags_max_len;
   int __nonoption_flags_len;
-# endif
+#endif
 };
 
 /* The initializer is necessary to set OPTIND and OPTERR to their
--- a/lib/getpass.c
+++ b/lib/getpass.c
@@ -26,53 +26,53 @@
 
 #if !((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__)
 
-#include <stdbool.h>
+# include <stdbool.h>
 
-#if HAVE_DECL___FSETLOCKING && HAVE___FSETLOCKING
-# if HAVE_STDIO_EXT_H
-#  include <stdio_ext.h>
+# if HAVE_DECL___FSETLOCKING && HAVE___FSETLOCKING
+#  if HAVE_STDIO_EXT_H
+#   include <stdio_ext.h>
+#  endif
+# else
+#  define __fsetlocking(stream, type)    /* empty */
 # endif
-#else
-# define __fsetlocking(stream, type)    /* empty */
-#endif
 
-#if HAVE_TERMIOS_H
-# include <termios.h>
-#endif
+# if HAVE_TERMIOS_H
+#  include <termios.h>
+# endif
 
-#if USE_UNLOCKED_IO
-# include "unlocked-io.h"
-#else
-# if !HAVE_DECL_FFLUSH_UNLOCKED
-#  undef fflush_unlocked
-#  define fflush_unlocked(x) fflush (x)
-# endif
-# if !HAVE_DECL_FLOCKFILE
-#  undef flockfile
-#  define flockfile(x) ((void) 0)
+# if USE_UNLOCKED_IO
+#  include "unlocked-io.h"
+# else
+#  if !HAVE_DECL_FFLUSH_UNLOCKED
+#   undef fflush_unlocked
+#   define fflush_unlocked(x) fflush (x)
+#  endif
+#  if !HAVE_DECL_FLOCKFILE
+#   undef flockfile
+#   define flockfile(x) ((void) 0)
+#  endif
+#  if !HAVE_DECL_FUNLOCKFILE
+#   undef funlockfile
+#   define funlockfile(x) ((void) 0)
+#  endif
+#  if !HAVE_DECL_FPUTS_UNLOCKED
+#   undef fputs_unlocked
+#   define fputs_unlocked(str,stream) fputs (str, stream)
+#  endif
+#  if !HAVE_DECL_PUTC_UNLOCKED
+#   undef putc_unlocked
+#   define putc_unlocked(c,stream) putc (c, stream)
+#  endif
 # endif
-# if !HAVE_DECL_FUNLOCKFILE
-#  undef funlockfile
-#  define funlockfile(x) ((void) 0)
-# endif
-# if !HAVE_DECL_FPUTS_UNLOCKED
-#  undef fputs_unlocked
-#  define fputs_unlocked(str,stream) fputs (str, stream)
-# endif
-# if !HAVE_DECL_PUTC_UNLOCKED
-#  undef putc_unlocked
-#  define putc_unlocked(c,stream) putc (c, stream)
-# endif
-#endif
 
 /* It is desirable to use this bit on systems that have it.
    The only bit of terminal state we want to twiddle is echoing, which is
    done in software; there is no need to change the state of the terminal
    hardware.  */
 
-#ifndef TCSASOFT
-# define TCSASOFT 0
-#endif
+# ifndef TCSASOFT
+#  define TCSASOFT 0
+# endif
 
 static void
 call_fclose (void *arg)
@@ -112,7 +112,7 @@
   flockfile (out);
 
   /* Turn echoing off if it is on now.  */
-#if HAVE_TCGETATTR
+# if HAVE_TCGETATTR
   if (tcgetattr (fileno (in), &t) == 0)
     {
       /* Save the old one. */
@@ -121,7 +121,7 @@
       t.c_lflag &= ~(ECHO | ISIG);
       tty_changed = (tcsetattr (fileno (in), TCSAFLUSH | TCSASOFT, &t) == 0);
     }
-#endif
+# endif
 
   /* Write the prompt.  */
   fputs_unlocked (prompt, out);
@@ -158,10 +158,10 @@
     }
 
   /* Restore the original setting.  */
-#if HAVE_TCSETATTR
+# if HAVE_TCSETATTR
   if (tty_changed)
     tcsetattr (fileno (in), TCSAFLUSH | TCSASOFT, &s);
-#endif
+# endif
 
   funlockfile (out);
 
@@ -176,15 +176,15 @@
    improved by Simon Josefsson. */
 
 /* For PASS_MAX. */
-#include <limits.h>
+# include <limits.h>
 /* For _getch(). */
-#include <conio.h>
+# include <conio.h>
 /* For strdup(). */
-#include <string.h>
+# include <string.h>
 
-#ifndef PASS_MAX
-# define PASS_MAX 512
-#endif
+# ifndef PASS_MAX
+#  define PASS_MAX 512
+# endif
 
 char *
 getpass (const char *prompt)
--- a/lib/gettext.h
+++ b/lib/gettext.h
@@ -93,6 +93,12 @@
 
 #endif
 
+/* Prefer gnulib's setlocale override over libintl's setlocale override.  */
+#ifdef GNULIB_defined_setlocale
+# undef setlocale
+# define setlocale rpl_setlocale
+#endif
+
 /* A pseudo function call that serves as a marker for the automated
    extraction of messages, but does not call gettext().  The run-time
    translation is done at a different place in the code.
--- a/lib/gettimeofday.c
+++ b/lib/gettimeofday.c
@@ -40,10 +40,10 @@
 static struct tm tm_zero_buffer;
 static struct tm *localtime_buffer_addr = &tm_zero_buffer;
 
-#undef localtime
+# undef localtime
 extern struct tm *localtime (time_t const *);
 
-#undef gmtime
+# undef gmtime
 extern struct tm *gmtime (time_t const *);
 
 /* This is a wrapper for localtime.  It is used only on systems for which
@@ -79,7 +79,7 @@
 
 #if TZSET_CLOBBERS_LOCALTIME
 
-#undef tzset
+# undef tzset
 extern void tzset (void);
 
 /* This is a wrapper for tzset, for systems on which tzset may clobber
--- a/lib/hash.h
+++ b/lib/hash.h
@@ -27,15 +27,12 @@
 # include <stdio.h>
 # include <stdbool.h>
 
-/* The warn_unused_result attribute appeared first in gcc-3.4.0 */
-# ifndef __attribute__
-#  if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4)
-#   define __attribute__(x)
-#  endif
-# endif
-
-# ifndef ATTRIBUTE_WUR
-#  define ATTRIBUTE_WUR __attribute__ ((__warn_unused_result__))
+/* The __attribute__ feature is available in gcc versions 2.5 and later.
+   The warn_unused_result attribute appeared first in gcc-3.4.0.  */
+# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+#  define _GL_ATTRIBUTE_WUR __attribute__ ((__warn_unused_result__))
+# else
+#  define _GL_ATTRIBUTE_WUR /* empty */
 # endif
 
 typedef size_t (*Hash_hasher) (const void *, size_t);
@@ -81,13 +78,13 @@
 void hash_reset_tuning (Hash_tuning *);
 Hash_table *hash_initialize (size_t, const Hash_tuning *,
                              Hash_hasher, Hash_comparator,
-                             Hash_data_freer) ATTRIBUTE_WUR;
+                             Hash_data_freer) _GL_ATTRIBUTE_WUR;
 void hash_clear (Hash_table *);
 void hash_free (Hash_table *);
 
 /* Insertion and deletion.  */
-bool hash_rehash (Hash_table *, size_t) ATTRIBUTE_WUR;
-void *hash_insert (Hash_table *, const void *) ATTRIBUTE_WUR;
+bool hash_rehash (Hash_table *, size_t) _GL_ATTRIBUTE_WUR;
+void *hash_insert (Hash_table *, const void *) _GL_ATTRIBUTE_WUR;
 int hash_insert0 (Hash_table *table, const void *entry,
                   const void **matched_ent);
 void *hash_delete (Hash_table *, const void *);
--- a/lib/ignore-value.h
+++ b/lib/ignore-value.h
@@ -35,13 +35,13 @@
 #ifndef _GL_IGNORE_VALUE_H
 # define _GL_IGNORE_VALUE_H
 
-# ifndef ATTRIBUTE_DEPRECATED
+# ifndef _GL_ATTRIBUTE_DEPRECATED
 /* The __attribute__((__deprecated__)) feature
    is available in gcc versions 3.1 and newer.  */
 #  if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 1)
-#   define ATTRIBUTE_DEPRECATED /* empty */
+#   define _GL_ATTRIBUTE_DEPRECATED /* empty */
 #  else
-#   define ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__))
+#   define _GL_ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__))
 #  endif
 # endif
 
@@ -56,7 +56,7 @@
 
 /* ignore_value works for scalars, pointers and aggregates;
    deprecate ignore_ptr.  */
-static inline void ATTRIBUTE_DEPRECATED
+static inline void _GL_ATTRIBUTE_DEPRECATED
 ignore_ptr (void *p) { (void) p; } /* deprecated: use ignore_value */
 
 #endif
new file mode 100644
--- /dev/null
+++ b/lib/ino-map.c
@@ -0,0 +1,164 @@
+/* Map an ino_t inode number to a small integer.
+
+   Copyright 2009-2011 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 and Jim Meyering */
+
+#include <config.h>
+#include "ino-map.h"
+
+#include "hash.h"
+#include "verify.h"
+
+#include <limits.h>
+#include <stdlib.h>
+
+/* A pair that maps an inode number to a mapped inode number; the
+   latter is a small unique ID for the former.  */
+struct ino_map_ent
+{
+  ino_t ino;
+  size_t mapped_ino;
+};
+
+/* A table that manages and indexes these pairs.  */
+struct ino_map
+{
+  /* A table of KEY,VAL pairs, where KEY is the raw ino_t value and
+     VAL is the small number that it maps to.  */
+  struct hash_table *map;
+
+  /* The next mapped inode number to hand out.  */
+  size_t next_mapped_ino;
+
+  /* Cache of the most recently allocated and otherwise-unused storage
+     for probing the table.  */
+  struct ino_map_ent *probe;
+};
+
+/* Hash an inode map entry.  */
+static size_t
+ino_hash (void const *x, size_t table_size)
+{
+  struct ino_map_ent const *p = x;
+  ino_t ino = p->ino;
+
+  /* When INO is wider than size_t, exclusive-OR the words of INO into H.
+     This avoids loss of info, without applying % to the wider type,
+     which could be quite slow on some systems.  */
+  size_t h = ino;
+  unsigned int i;
+  unsigned int n_words = sizeof ino / sizeof h + (sizeof ino % sizeof h != 0);
+  for (i = 1; i < n_words; i++)
+    h ^= ino >> CHAR_BIT * sizeof h * i;
+
+  return h % table_size;
+}
+
+/* Return true if two inode map entries are the same.  */
+static bool
+ino_compare (void const *x, void const *y)
+{
+  struct ino_map_ent const *a = x;
+  struct ino_map_ent const *b = y;
+  return a->ino == b->ino;
+}
+
+/* Allocate an inode map that will hand out integers starting with
+   NEXT_MAPPED_INO.  Return NULL if memory is exhausted.  */
+struct ino_map *
+ino_map_alloc (size_t next_mapped_ino)
+{
+  struct ino_map *im = malloc (sizeof *im);
+
+  if (im)
+    {
+      enum { INITIAL_INO_MAP_TABLE_SIZE = 1021 };
+      im->map = hash_initialize (INITIAL_INO_MAP_TABLE_SIZE, NULL,
+                                 ino_hash, ino_compare, free);
+      if (! im->map)
+        {
+          free (im);
+          return NULL;
+        }
+      im->next_mapped_ino = next_mapped_ino;
+      im->probe = NULL;
+    }
+
+  return im;
+}
+
+/* Free an inode map.  */
+void
+ino_map_free (struct ino_map *map)
+{
+  hash_free (map->map);
+  free (map->probe);
+  free (map);
+}
+
+
+/* Insert into MAP the inode number INO if it's not there already,
+   and return its nonnegative mapped inode number.
+   If INO is already in MAP, return the existing mapped inode number.
+   Return INO_MAP_INSERT_FAILURE on memory or counter exhaustion.  */
+size_t
+ino_map_insert (struct ino_map *im, ino_t ino)
+{
+  struct ino_map_ent *ent;
+
+  /* Find space for the probe, reusing the cache if available.  */
+  struct ino_map_ent *probe = im->probe;
+  if (probe)
+    {
+      /* If repeating a recent query, return the cached result.   */
+      if (probe->ino == ino)
+        return probe->mapped_ino;
+    }
+  else
+    {
+      im->probe = probe = malloc (sizeof *probe);
+      if (! probe)
+        return INO_MAP_INSERT_FAILURE;
+    }
+
+  probe->ino = ino;
+  ent = hash_insert (im->map, probe);
+  if (! ent)
+    return INO_MAP_INSERT_FAILURE;
+
+  if (ent != probe)
+    {
+      /* Use the existing entry.  */
+      probe->mapped_ino = ent->mapped_ino;
+    }
+  else
+    {
+      /* If adding 1 to map->next_mapped_ino would cause it to
+         overflow to zero, then it must equal INO_MAP_INSERT_FAILURE,
+         which is the value that should be returned in that case.
+         Verify that this works.  */
+      verify (INO_MAP_INSERT_FAILURE + 1 == 0);
+
+      /* Prepare to allocate a new probe next time; this one is in use.  */
+      im->probe = NULL;
+
+      /* INO is new; allocate a mapped inode number for it.  */
+      probe->mapped_ino = im->next_mapped_ino++;
+    }
+
+  return probe->mapped_ino;
+}
new file mode 100644
--- /dev/null
+++ b/lib/ino-map.h
@@ -0,0 +1,19 @@
+#ifndef _GL_INO_MAP_H
+# define _GL_INO_MAP_H
+
+# include <sys/types.h>
+
+# undef _GL_ATTRIBUTE_NONNULL
+# if __GNUC__ == 3 && __GNUC_MINOR__ >= 3 || 3 < __GNUC__
+#  define _GL_ATTRIBUTE_NONNULL(m) __attribute__ ((__nonnull__ (m)))
+# else
+#  define _GL_ATTRIBUTE_NONNULL(m)
+# endif
+
+# define INO_MAP_INSERT_FAILURE ((size_t) -1)
+
+struct ino_map *ino_map_alloc (size_t);
+void ino_map_free (struct ino_map *) _GL_ATTRIBUTE_NONNULL (1);
+size_t ino_map_insert (struct ino_map *, ino_t) _GL_ATTRIBUTE_NONNULL (1);
+
+#endif
--- a/lib/inttypes.in.h
+++ b/lib/inttypes.in.h
@@ -1060,7 +1060,10 @@
 
 #if @GNULIB_IMAXDIV@
 # if !@HAVE_DECL_IMAXDIV@
+#  if !GNULIB_defined_imaxdiv_t
 typedef struct { intmax_t quot; intmax_t rem; } imaxdiv_t;
+#   define GNULIB_defined_imaxdiv_t 1
+#  endif
 extern imaxdiv_t imaxdiv (intmax_t, intmax_t);
 # endif
 #elif defined GNULIB_POSIXCHECK
--- a/lib/ioctl.c
+++ b/lib/ioctl.c
@@ -37,7 +37,9 @@
   buf = va_arg (args, void *);
   va_end (args);
 
-  return ioctl (fd, request, buf);
+  /* Cast 'request' so that when the system's ioctl function takes a 64-bit
+     request argument, the value gets zero-extended, not sign-extended.  */
+  return ioctl (fd, (unsigned int) request, buf);
 }
 
 #else /* mingw */
@@ -61,6 +63,10 @@
   buf = va_arg (args, void *);
   va_end (args);
 
+  /* We don't support FIONBIO on pipes here.  If you want to make pipe
+     fds non-blocking, use the gnulib 'nonblocking' module, until
+     gnulib implements fcntl F_GETFL / F_SETFL with O_NONBLOCK.  */
+
   sock = FD_TO_SOCKET (fd);
   r = ioctlsocket (sock, req, buf);
   if (r < 0)
new file mode 100644
--- /dev/null
+++ b/lib/iswctype-impl.h
@@ -0,0 +1,22 @@
+/* Test whether a wide character has a given property.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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/>.  */
+
+int
+iswctype (wint_t wc, wctype_t desc)
+{
+  return ((int (*) (wint_t)) desc) (wc);
+}
new file mode 100644
--- /dev/null
+++ b/lib/iswctype.c
@@ -0,0 +1,23 @@
+/* Test whether a wide character has a given property.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 <wctype.h>
+
+#include "iswctype-impl.h"
--- a/lib/langinfo.in.h
+++ b/lib/langinfo.in.h
@@ -41,7 +41,10 @@
 /* A platform that lacks <langinfo.h>.  */
 
 /* Assume that it also lacks <nl_types.h> and the nl_item type.  */
+# if !GNULIB_defined_nl_item
 typedef int nl_item;
+#  define GNULIB_defined_nl_item 1
+# endif
 
 /* nl_langinfo items of the LC_CTYPE category */
 # define CODESET     10000
--- a/lib/linkat.c
+++ b/lib/linkat.c
@@ -298,7 +298,7 @@
       return -1;
     }
 
-#if LINKAT_TRAILING_SLASH_BUG
+# if LINKAT_TRAILING_SLASH_BUG
   /* Reject trailing slashes on non-directories.  */
   {
     size_t len1 = strlen (file1);
@@ -319,7 +319,7 @@
           }
       }
   }
-#endif
+# endif
 
   if (!flag)
     return linkat (fd1, file1, fd2, file2, flag);
--- a/lib/localcharset.c
+++ b/lib/localcharset.c
@@ -228,8 +228,7 @@
                         {
                           /* Out of memory. */
                           res_size = 0;
-                          if (old_res_ptr != NULL)
-                            free (old_res_ptr);
+                          free (old_res_ptr);
                           break;
                         }
                       strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1);
--- a/lib/locale.in.h
+++ b/lib/locale.in.h
@@ -47,6 +47,27 @@
 # define LC_MESSAGES 1729
 #endif
 
+#if @GNULIB_SETLOCALE@
+# if @REPLACE_SETLOCALE@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef setlocale
+#   define setlocale rpl_setlocale
+#   define GNULIB_defined_setlocale 1
+#  endif
+_GL_FUNCDECL_RPL (setlocale, char *, (int category, const char *locale));
+_GL_CXXALIAS_RPL (setlocale, char *, (int category, const char *locale));
+# else
+_GL_CXXALIAS_SYS (setlocale, char *, (int category, const char *locale));
+# endif
+_GL_CXXALIASWARN (setlocale);
+#elif defined GNULIB_POSIXCHECK
+# undef setlocale
+# if HAVE_RAW_DECL_SETLOCALE
+_GL_WARN_ON_USE (setlocale, "setlocale works differently on native Windows - "
+                 "use gnulib module setlocale for portability");
+# endif
+#endif
+
 #if @GNULIB_DUPLOCALE@
 # if @REPLACE_DUPLOCALE@
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
--- a/lib/math.in.h
+++ b/lib/math.in.h
@@ -73,18 +73,21 @@
    it on platforms like Solaris 10, where NAN is present but defined
    as a function pointer rather than a floating point constant.  */
 #if !defined NAN || @REPLACE_NAN@
-# undef NAN
+# if !GNULIB_defined_NAN
+#  undef NAN
   /* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0.  */
-# ifdef __DECC
+#  ifdef __DECC
 static float
 _NaN ()
 {
   static float zero = 0.0f;
   return zero / zero;
 }
-#  define NAN (_NaN())
-# else
-#  define NAN (0.0f / 0.0f)
+#   define NAN (_NaN())
+#  else
+#   define NAN (0.0f / 0.0f)
+#  endif
+#  define GNULIB_defined_NAN 1
 # endif
 #endif
 
--- a/lib/mbrtowc.c
+++ b/lib/mbrtowc.c
@@ -40,9 +40,6 @@
 {
   char *pstate = (char *)ps;
 
-  if (pstate == NULL)
-    pstate = internal_state;
-
   if (s == NULL)
     {
       pwc = NULL;
@@ -54,6 +51,10 @@
     return (size_t)(-2);
 
   /* Here n > 0.  */
+
+  if (pstate == NULL)
+    pstate = internal_state;
+
   {
     size_t nstate = pstate[0];
     char buf[4];
--- a/lib/mbsinit.c
+++ b/lib/mbsinit.c
@@ -22,6 +22,18 @@
 
 #include "verify.h"
 
+#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
+
+/* On native Windows, 'mbstate_t' is defined as 'int'.  */
+
+int
+mbsinit (const mbstate_t *ps)
+{
+  return ps == NULL || *ps == 0;
+}
+
+#else
+
 /* Platforms that lack mbsinit() also lack mbrlen(), mbrtowc(), mbsrtowcs()
    and wcrtomb(), wcsrtombs().
    We assume that
@@ -43,5 +55,7 @@
 {
   const char *pstate = (const char *)ps;
 
-  return pstate[0] == 0;
+  return pstate == NULL || pstate[0] == 0;
 }
+
+#endif
new file mode 100644
--- /dev/null
+++ b/lib/mbsnrtowcs-impl.h
@@ -0,0 +1,124 @@
+/* Convert string to wide string.
+   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 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/>.  */
+
+size_t
+mbsnrtowcs (wchar_t *dest, const char **srcp, size_t srclen, size_t len, mbstate_t *ps)
+{
+  if (ps == NULL)
+    ps = &_gl_mbsrtowcs_state;
+  {
+    const char *src = *srcp;
+
+    if (dest != NULL)
+      {
+        wchar_t *destptr = dest;
+
+        for (; srclen > 0 && len > 0; destptr++, len--)
+          {
+            size_t src_avail;
+            size_t ret;
+
+            /* An optimized variant of
+               src_avail = strnlen1 (src, MIN (srclen, MB_LEN_MAX));  */
+            if (srclen == 1 || src[0] == '\0')
+              src_avail = 1;
+            else if (srclen == 2 || src[1] == '\0')
+              src_avail = 2;
+            else if (srclen == 3 || src[2] == '\0')
+              src_avail = 3;
+            else if (MB_LEN_MAX <= 4 || srclen == 4 || src[3] == '\0')
+              src_avail = 4;
+            else
+              src_avail = 4 + strnlen1 (src + 4, MIN (srclen, MB_LEN_MAX) - 4);
+
+            /* Parse the next multibyte character.  */
+            ret = mbrtowc (destptr, src, src_avail, ps);
+
+            if (ret == (size_t)(-2))
+              /* Encountered a multibyte character that extends past a '\0' byte
+                 or that is longer than MB_LEN_MAX bytes.  Cannot happen.  */
+              abort ();
+
+            if (ret == (size_t)(-1))
+              goto bad_input;
+            if (ret == 0)
+              {
+                src = NULL;
+                /* Here mbsinit (ps).  */
+                break;
+              }
+            src += ret;
+            srclen -= ret;
+          }
+
+        *srcp = src;
+        return destptr - dest;
+      }
+    else
+      {
+        /* Ignore dest and len, don't store *srcp at the end, and
+           don't clobber *ps.  */
+        mbstate_t state = *ps;
+        size_t totalcount = 0;
+
+        for (; srclen > 0; totalcount++)
+          {
+            size_t src_avail;
+            size_t ret;
+
+            /* An optimized variant of
+               src_avail = strnlen1 (src, MIN (srclen, MB_LEN_MAX));  */
+            if (srclen == 1 || src[0] == '\0')
+              src_avail = 1;
+            else if (srclen == 2 || src[1] == '\0')
+              src_avail = 2;
+            else if (srclen == 3 || src[2] == '\0')
+              src_avail = 3;
+            else if (MB_LEN_MAX <= 4 || srclen == 4 || src[3] == '\0')
+              src_avail = 4;
+            else
+              src_avail = 4 + strnlen1 (src + 4, MIN (srclen, MB_LEN_MAX) - 4);
+
+            /* Parse the next multibyte character.  */
+            ret = mbrtowc (NULL, src, src_avail, &state);
+
+            if (ret == (size_t)(-2))
+              /* Encountered a multibyte character that extends past a '\0' byte
+                 or that is longer than MB_LEN_MAX bytes.  Cannot happen.  */
+              abort ();
+
+            if (ret == (size_t)(-1))
+              goto bad_input2;
+            if (ret == 0)
+              {
+                /* Here mbsinit (&state).  */
+                break;
+              }
+            src += ret;
+            srclen -= ret;
+          }
+
+        return totalcount;
+      }
+
+   bad_input:
+    *srcp = src;
+   bad_input2:
+    errno = EILSEQ;
+    return (size_t)(-1);
+  }
+}
--- a/lib/mbsnrtowcs.c
+++ b/lib/mbsnrtowcs.c
@@ -30,110 +30,4 @@
 
 extern mbstate_t _gl_mbsrtowcs_state;
 
-size_t
-mbsnrtowcs (wchar_t *dest, const char **srcp, size_t srclen, size_t len, mbstate_t *ps)
-{
-  if (ps == NULL)
-    ps = &_gl_mbsrtowcs_state;
-  {
-    const char *src = *srcp;
-
-    if (dest != NULL)
-      {
-        wchar_t *destptr = dest;
-
-        for (; srclen > 0 && len > 0; destptr++, len--)
-          {
-            size_t src_avail;
-            size_t ret;
-
-            /* An optimized variant of
-               src_avail = strnlen1 (src, MIN (srclen, MB_LEN_MAX));  */
-            if (srclen == 1 || src[0] == '\0')
-              src_avail = 1;
-            else if (srclen == 2 || src[1] == '\0')
-              src_avail = 2;
-            else if (srclen == 3 || src[2] == '\0')
-              src_avail = 3;
-            else if (MB_LEN_MAX <= 4 || srclen == 4 || src[3] == '\0')
-              src_avail = 4;
-            else
-              src_avail = 4 + strnlen1 (src + 4, MIN (srclen, MB_LEN_MAX) - 4);
-
-            /* Parse the next multibyte character.  */
-            ret = mbrtowc (destptr, src, src_avail, ps);
-
-            if (ret == (size_t)(-2))
-              /* Encountered a multibyte character that extends past a '\0' byte
-                 or that is longer than MB_LEN_MAX bytes.  Cannot happen.  */
-              abort ();
-
-            if (ret == (size_t)(-1))
-              goto bad_input;
-            if (ret == 0)
-              {
-                src = NULL;
-                /* Here mbsinit (ps).  */
-                break;
-              }
-            src += ret;
-            srclen -= ret;
-          }
-
-        *srcp = src;
-        return destptr - dest;
-      }
-    else
-      {
-        /* Ignore dest and len, don't store *srcp at the end, and
-           don't clobber *ps.  */
-        mbstate_t state = *ps;
-        size_t totalcount = 0;
-
-        for (; srclen > 0; totalcount++)
-          {
-            size_t src_avail;
-            size_t ret;
-
-            /* An optimized variant of
-               src_avail = strnlen1 (src, MIN (srclen, MB_LEN_MAX));  */
-            if (srclen == 1 || src[0] == '\0')
-              src_avail = 1;
-            else if (srclen == 2 || src[1] == '\0')
-              src_avail = 2;
-            else if (srclen == 3 || src[2] == '\0')
-              src_avail = 3;
-            else if (MB_LEN_MAX <= 4 || srclen == 4 || src[3] == '\0')
-              src_avail = 4;
-            else
-              src_avail = 4 + strnlen1 (src + 4, MIN (srclen, MB_LEN_MAX) - 4);
-
-            /* Parse the next multibyte character.  */
-            ret = mbrtowc (NULL, src, src_avail, &state);
-
-            if (ret == (size_t)(-2))
-              /* Encountered a multibyte character that extends past a '\0' byte
-                 or that is longer than MB_LEN_MAX bytes.  Cannot happen.  */
-              abort ();
-
-            if (ret == (size_t)(-1))
-              goto bad_input2;
-            if (ret == 0)
-              {
-                /* Here mbsinit (&state).  */
-                break;
-              }
-            src += ret;
-            srclen -= ret;
-          }
-
-        return totalcount;
-      }
-
-   bad_input:
-    *srcp = src;
-   bad_input2:
-    errno = EILSEQ;
-    return (size_t)(-1);
-  }
-}
+#include "mbsnrtowcs-impl.h"
new file mode 100644
--- /dev/null
+++ b/lib/mbsrtowcs-impl.h
@@ -0,0 +1,122 @@
+/* Convert string to wide string.
+   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 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/>.  */
+
+size_t
+mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)
+{
+  if (ps == NULL)
+    ps = &_gl_mbsrtowcs_state;
+  {
+    const char *src = *srcp;
+
+    if (dest != NULL)
+      {
+        wchar_t *destptr = dest;
+
+        for (; len > 0; destptr++, len--)
+          {
+            size_t src_avail;
+            size_t ret;
+
+            /* An optimized variant of
+               src_avail = strnlen1 (src, MB_LEN_MAX);  */
+            if (src[0] == '\0')
+              src_avail = 1;
+            else if (src[1] == '\0')
+              src_avail = 2;
+            else if (src[2] == '\0')
+              src_avail = 3;
+            else if (MB_LEN_MAX <= 4 || src[3] == '\0')
+              src_avail = 4;
+            else
+              src_avail = 4 + strnlen1 (src + 4, MB_LEN_MAX - 4);
+
+            /* Parse the next multibyte character.  */
+            ret = mbrtowc (destptr, src, src_avail, ps);
+
+            if (ret == (size_t)(-2))
+              /* Encountered a multibyte character that extends past a '\0' byte
+                 or that is longer than MB_LEN_MAX bytes.  Cannot happen.  */
+              abort ();
+
+            if (ret == (size_t)(-1))
+              goto bad_input;
+            if (ret == 0)
+              {
+                src = NULL;
+                /* Here mbsinit (ps).  */
+                break;
+              }
+            src += ret;
+          }
+
+        *srcp = src;
+        return destptr - dest;
+      }
+    else
+      {
+        /* Ignore dest and len, don't store *srcp at the end, and
+           don't clobber *ps.  */
+        mbstate_t state = *ps;
+        size_t totalcount = 0;
+
+        for (;; totalcount++)
+          {
+            size_t src_avail;
+            size_t ret;
+
+            /* An optimized variant of
+               src_avail = strnlen1 (src, MB_LEN_MAX);  */
+            if (src[0] == '\0')
+              src_avail = 1;
+            else if (src[1] == '\0')
+              src_avail = 2;
+            else if (src[2] == '\0')
+              src_avail = 3;
+            else if (MB_LEN_MAX <= 4 || src[3] == '\0')
+              src_avail = 4;
+            else
+              src_avail = 4 + strnlen1 (src + 4, MB_LEN_MAX - 4);
+
+            /* Parse the next multibyte character.  */
+            ret = mbrtowc (NULL, src, src_avail, &state);
+
+            if (ret == (size_t)(-2))
+              /* Encountered a multibyte character that extends past a '\0' byte
+                 or that is longer than MB_LEN_MAX bytes.  Cannot happen.  */
+              abort ();
+
+            if (ret == (size_t)(-1))
+              goto bad_input2;
+            if (ret == 0)
+              {
+                /* Here mbsinit (&state).  */
+                break;
+              }
+            src += ret;
+          }
+
+        return totalcount;
+      }
+
+   bad_input:
+    *srcp = src;
+   bad_input2:
+    errno = EILSEQ;
+    return (size_t)(-1);
+  }
+}
--- a/lib/mbsrtowcs.c
+++ b/lib/mbsrtowcs.c
@@ -29,108 +29,4 @@
 
 extern mbstate_t _gl_mbsrtowcs_state;
 
-size_t
-mbsrtowcs (wchar_t *dest, const char **srcp, size_t len, mbstate_t *ps)
-{
-  if (ps == NULL)
-    ps = &_gl_mbsrtowcs_state;
-  {
-    const char *src = *srcp;
-
-    if (dest != NULL)
-      {
-        wchar_t *destptr = dest;
-
-        for (; len > 0; destptr++, len--)
-          {
-            size_t src_avail;
-            size_t ret;
-
-            /* An optimized variant of
-               src_avail = strnlen1 (src, MB_LEN_MAX);  */
-            if (src[0] == '\0')
-              src_avail = 1;
-            else if (src[1] == '\0')
-              src_avail = 2;
-            else if (src[2] == '\0')
-              src_avail = 3;
-            else if (MB_LEN_MAX <= 4 || src[3] == '\0')
-              src_avail = 4;
-            else
-              src_avail = 4 + strnlen1 (src + 4, MB_LEN_MAX - 4);
-
-            /* Parse the next multibyte character.  */
-            ret = mbrtowc (destptr, src, src_avail, ps);
-
-            if (ret == (size_t)(-2))
-              /* Encountered a multibyte character that extends past a '\0' byte
-                 or that is longer than MB_LEN_MAX bytes.  Cannot happen.  */
-              abort ();
-
-            if (ret == (size_t)(-1))
-              goto bad_input;
-            if (ret == 0)
-              {
-                src = NULL;
-                /* Here mbsinit (ps).  */
-                break;
-              }
-            src += ret;
-          }
-
-        *srcp = src;
-        return destptr - dest;
-      }
-    else
-      {
-        /* Ignore dest and len, don't store *srcp at the end, and
-           don't clobber *ps.  */
-        mbstate_t state = *ps;
-        size_t totalcount = 0;
-
-        for (;; totalcount++)
-          {
-            size_t src_avail;
-            size_t ret;
-
-            /* An optimized variant of
-               src_avail = strnlen1 (src, MB_LEN_MAX);  */
-            if (src[0] == '\0')
-              src_avail = 1;
-            else if (src[1] == '\0')
-              src_avail = 2;
-            else if (src[2] == '\0')
-              src_avail = 3;
-            else if (MB_LEN_MAX <= 4 || src[3] == '\0')
-              src_avail = 4;
-            else
-              src_avail = 4 + strnlen1 (src + 4, MB_LEN_MAX - 4);
-
-            /* Parse the next multibyte character.  */
-            ret = mbrtowc (NULL, src, src_avail, &state);
-
-            if (ret == (size_t)(-2))
-              /* Encountered a multibyte character that extends past a '\0' byte
-                 or that is longer than MB_LEN_MAX bytes.  Cannot happen.  */
-              abort ();
-
-            if (ret == (size_t)(-1))
-              goto bad_input2;
-            if (ret == 0)
-              {
-                /* Here mbsinit (&state).  */
-                break;
-              }
-            src += ret;
-          }
-
-        return totalcount;
-      }
-
-   bad_input:
-    *srcp = src;
-   bad_input2:
-    errno = EILSEQ;
-    return (size_t)(-1);
-  }
-}
+#include "mbsrtowcs-impl.h"
--- a/lib/mbswidth.c
+++ b/lib/mbswidth.c
@@ -35,12 +35,14 @@
 /* Get iswcntrl().  */
 #include <wctype.h>
 
+/* Get INT_MAX.  */
+#include <limits.h>
+
 /* Returns the number of columns needed to represent the multibyte
    character string pointed to by STRING.  If a non-printable character
    occurs, and MBSW_REJECT_UNPRINTABLE is specified, -1 is returned.
    With flags = MBSW_REJECT_INVALID | MBSW_REJECT_UNPRINTABLE, this is
-   the multibyte analogue of the wcswidth function.
-   If STRING is not of length < INT_MAX / 2, integer overflow can occur.  */
+   the multibyte analogue of the wcswidth function.  */
 int
 mbswidth (const char *string, int flags)
 {
@@ -50,8 +52,7 @@
 /* Returns the number of columns needed to represent the multibyte
    character string pointed to by STRING of length NBYTES.  If a
    non-printable character occurs, and MBSW_REJECT_UNPRINTABLE is
-   specified, -1 is returned.
-   If NBYTES is not < INT_MAX / 2, integer overflow can occur.  */
+   specified, -1 is returned.  */
 int
 mbsnwidth (const char *string, size_t nbytes, int flags)
 {
@@ -135,11 +136,22 @@
                     w = wcwidth (wc);
                     if (w >= 0)
                       /* A printable multibyte character.  */
-                      width += w;
+                      {
+                        if (w > INT_MAX - width)
+                          goto overflow;
+                        width += w;
+                      }
                     else
                       /* An unprintable multibyte character.  */
                       if (!(flags & MBSW_REJECT_UNPRINTABLE))
-                        width += (iswcntrl (wc) ? 0 : 1);
+                        {
+                          if (!iswcntrl (wc))
+                            {
+                              if (width == INT_MAX)
+                                goto overflow;
+                              width++;
+                            }
+                        }
                       else
                         return -1;
 
@@ -157,11 +169,25 @@
       unsigned char c = (unsigned char) *p++;
 
       if (isprint (c))
-        width++;
+        {
+          if (width == INT_MAX)
+            goto overflow;
+          width++;
+        }
       else if (!(flags & MBSW_REJECT_UNPRINTABLE))
-        width += (iscntrl (c) ? 0 : 1);
+        {
+          if (!iscntrl (c))
+            {
+              if (width == INT_MAX)
+                goto overflow;
+              width++;
+            }
+        }
       else
         return -1;
     }
   return width;
+
+ overflow:
+  return INT_MAX;
 }
new file mode 100644
--- /dev/null
+++ b/lib/mbtowc-impl.h
@@ -0,0 +1,44 @@
+/* Convert multibyte character to wide character.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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/>.  */
+
+/* We don't need a static internal state, because the encoding is not state
+   dependent, and when mbrtowc returns (size_t)(-2). we throw the result
+   away. */
+
+int
+mbtowc (wchar_t *pwc, const char *s, size_t n)
+{
+  if (s == NULL)
+    return 0;
+  else
+    {
+      mbstate_t state;
+      wchar_t wc;
+      size_t result;
+
+      memset (&state, 0, sizeof (mbstate_t));
+      result = mbrtowc (&wc, s, n, &state);
+      if (result == (size_t)-1 || result == (size_t)-2)
+        {
+          errno = EILSEQ;
+          return -1;
+        }
+      if (pwc != NULL)
+        *pwc = wc;
+      return (wc == 0 ? 0 : result);
+    }
+}
new file mode 100644
--- /dev/null
+++ b/lib/mbtowc.c
@@ -0,0 +1,26 @@
+/* Convert multibyte character to wide character.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+#include <stdlib.h>
+
+#include <errno.h>
+#include <string.h>
+#include <wchar.h>
+
+#include "mbtowc-impl.h"
--- a/lib/nanosleep.c
+++ b/lib/nanosleep.c
@@ -45,7 +45,7 @@
 int
 nanosleep (const struct timespec *requested_delay,
            struct timespec *remaining_delay)
-#undef nanosleep
+# undef nanosleep
 {
   /* nanosleep mishandles large sleeps due to internal overflow problems.
      The worst known case of this is Linux 2.6.9 with glibc 2.3.4, which
--- a/lib/netdb.in.h
+++ b/lib/netdb.in.h
@@ -37,7 +37,8 @@
 #ifndef _GL_NETDB_H
 #define _GL_NETDB_H
 
-/* Get netdb.h definitions such as struct hostent for MinGW.  */
+/* Get <netdb.h> definitions such as 'socklen_t' on IRIX 6.5 and OSF/1 4.0 and
+   'struct hostent' on MinGW.  */
 #include <sys/socket.h>
 
 /* The definition of _GL_ARG_NONNULL is copied here.  */
@@ -51,6 +52,7 @@
 
 # if !@HAVE_STRUCT_ADDRINFO@
 
+#  if !GNULIB_defined_struct_addrinfo
 /* Structure to contain information about address of a service provider.  */
 struct addrinfo
 {
@@ -63,6 +65,8 @@
   char *ai_canonname;           /* Canonical name for service location.  */
   struct addrinfo *ai_next;     /* Pointer to next in list.  */
 };
+#   define GNULIB_defined_struct_addrinfo 1
+#  endif
 # endif
 
 /* Possible values for `ai_flags' field in `addrinfo' structure.  */
new file mode 100644
--- /dev/null
+++ b/lib/nonblocking.c
@@ -0,0 +1,151 @@
+/* Non-blocking I/O for pipe or socket descriptors.
+   Copyright (C) 2011 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/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include "nonblocking.h"
+
+#include <errno.h>
+
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+/* Native Woe32 API.  */
+
+# include <sys/ioctl.h>
+# include <sys/socket.h>
+# include <unistd.h>
+
+/* Get declarations of the Win32 API functions.  */
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+
+int
+get_nonblocking_flag (int desc)
+{
+  HANDLE h = (HANDLE) _get_osfhandle (desc);
+  if (h == INVALID_HANDLE_VALUE)
+    {
+      errno = EBADF;
+      return -1;
+    }
+  if (GetFileType (h) == FILE_TYPE_PIPE)
+    {
+      /* h is a pipe or socket.  */
+      DWORD state;
+      if (GetNamedPipeHandleState (h, &state, NULL, NULL, NULL, NULL, 0))
+        /* h is a pipe.  */
+        return (state & PIPE_NOWAIT) != 0;
+      else
+        /* h is a socket.  */
+        errno = ENOSYS;
+        return -1;
+    }
+  else
+    /* Win32 does not support non-blocking on regular files.  */
+    return 0;
+}
+
+int
+set_nonblocking_flag (int desc, bool value)
+{
+  HANDLE h = (HANDLE) _get_osfhandle (desc);
+  if (h == INVALID_HANDLE_VALUE)
+    {
+      errno = EBADF;
+      return -1;
+    }
+  if (GetFileType (h) == FILE_TYPE_PIPE)
+    {
+      /* h is a pipe or socket.  */
+      DWORD state;
+      if (GetNamedPipeHandleState (h, &state, NULL, NULL, NULL, NULL, 0))
+        {
+          /* h is a pipe.  */
+          if ((state & PIPE_NOWAIT) != 0)
+            {
+              if (value)
+                return 0;
+              state &= ~PIPE_NOWAIT;
+            }
+          else
+            {
+              if (!value)
+                return 0;
+              state |= PIPE_NOWAIT;
+            }
+          if (SetNamedPipeHandleState (h, &state, NULL, NULL))
+            return 0;
+          errno = EINVAL;
+          return -1;
+        }
+      else
+        {
+          /* h is a socket.  */
+          int v = value;
+          return ioctl (desc, FIONBIO, &v);
+        }
+    }
+  else
+    {
+      /* Win32 does not support non-blocking on regular files.  */
+      if (!value)
+        return 0;
+      errno = ENOTSUP;
+      return -1;
+    }
+}
+
+#else
+/* Unix API.  */
+
+# include <fcntl.h>
+
+# if !O_NONBLOCK
+#  error Please port nonblocking to your platform
+# endif
+
+/* We don't need the gnulib replacement of fcntl() here.  */
+# undef fcntl
+
+int
+get_nonblocking_flag (int desc)
+{
+  int fcntl_flags;
+
+  fcntl_flags = fcntl (desc, F_GETFL, 0);
+  if (fcntl_flags < 0)
+    return -1;
+  return (fcntl_flags & O_NONBLOCK) != 0;
+}
+
+int
+set_nonblocking_flag (int desc, bool value)
+{
+  int fcntl_flags;
+
+  fcntl_flags = fcntl (desc, F_GETFL, 0);
+  if (fcntl_flags < 0)
+    return -1;
+  if (((fcntl_flags & O_NONBLOCK) != 0) == value)
+    return 0;
+  if (value)
+    fcntl_flags |= O_NONBLOCK;
+  else
+    fcntl_flags &= ~O_NONBLOCK;
+  return fcntl (desc, F_SETFL, fcntl_flags);
+}
+
+#endif
new file mode 100644
--- /dev/null
+++ b/lib/nonblocking.h
@@ -0,0 +1,62 @@
+/* Non-blocking I/O for pipe or socket descriptors.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef _NONBLOCKING_H
+#define _NONBLOCKING_H
+
+#include <stdbool.h>
+
+/* Non-blocking I/O is an I/O mode by which read(), write() calls avoid
+   blocking the current thread.  When non-blocking is enabled:
+   - A read() call returns -1 with errno set to EAGAIN when no data or EOF
+     information is immediately available.
+   - A write() call returns -1 with errno set to EAGAIN when it cannot
+     transport the requested amount of data (but at most one pipe buffer)
+     without blocking.
+   Non-blocking I/O is most useful for character devices, pipes, and sockets.
+   Whether it also works on regular files and block devices is platform
+   dependent.
+
+   There are three modern alternatives to non-blocking I/O:
+     - use select() or poll() followed by read() or write() if the descriptor
+       is ready,
+     - call read() or write() in separate threads,
+     - use <aio.h> interfaces.  */
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Return 1 if I/O to the descriptor DESC is currently non-blocking, 0
+   it is blocking, or -1 with errno set if fd is invalid or blocking
+   status cannot be determined (such as with sockets on mingw).  */
+extern int get_nonblocking_flag (int desc);
+
+/* Specify the non-blocking flag for the descriptor DESC.
+   Return 0 upon success, or -1 with errno set upon failure.
+   The default depends on the presence of the O_NONBLOCK flag for files
+   or pipes opened with open() or on the presence of the SOCK_NONBLOCK
+   flag for sockets.  */
+extern int set_nonblocking_flag (int desc, bool value);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _NONBLOCKING_H */
--- a/lib/openat-die.c
+++ b/lib/openat-die.c
@@ -22,8 +22,9 @@
 #include <stdlib.h>
 
 #ifndef GNULIB_LIBPOSIX
-#include "error.h"
-#endif  /* GNULIB_LIBPOSIX */
+# include "error.h"
+#endif
+
 #include "exitfail.h"
 
 #include "gettext.h"
@@ -35,7 +36,7 @@
 #ifndef GNULIB_LIBPOSIX
   error (exit_failure, errnum,
          _("unable to record current working directory"));
-#endif  /* GNULIB_LIBPOSIX */
+#endif
   /* The `noreturn' attribute cannot be applied to error, since it returns
      when its first argument is 0.  To help compilers understand that this
      function does not return, call abort.  Also, the abort is a
@@ -54,7 +55,7 @@
 #ifndef GNULIB_LIBPOSIX
   error (exit_failure, errnum,
          _("failed to return to initial working directory"));
-#endif  /* GNULIB_LIBPOSIX */
+#endif
 
   /* As above.  */
   abort ();
--- a/lib/openat-proc.c
+++ b/lib/openat-proc.c
@@ -30,7 +30,6 @@
 #include <string.h>
 #include <unistd.h>
 
-#include "dirname.h"
 #include "intprops.h"
 #include "same-inode.h"
 
--- a/lib/openat.c
+++ b/lib/openat.c
@@ -25,7 +25,7 @@
 #include <string.h>
 #include <sys/stat.h>
 
-#include "dirname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */
+#include "dosname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */
 #include "openat-priv.h"
 #include "save-cwd.h"
 
@@ -53,7 +53,7 @@
       va_end (arg);
     }
 
-#if OPEN_TRAILING_SLASH_BUG
+# if OPEN_TRAILING_SLASH_BUG
   /* If the filename ends in a slash and one of O_CREAT, O_WRONLY, O_RDWR
      is specified, then fail.
      Rationale: POSIX <http://www.opengroup.org/susv3/basedefs/xbd_chap04.html>
@@ -84,11 +84,11 @@
           return -1;
         }
     }
-#endif
+# endif
 
   fd = openat (dfd, filename, flags, mode);
 
-#if OPEN_TRAILING_SLASH_BUG
+# if OPEN_TRAILING_SLASH_BUG
   /* If the filename ends in a slash and fd does not refer to a directory,
      then fail.
      Rationale: POSIX <http://www.opengroup.org/susv3/basedefs/xbd_chap04.html>
@@ -117,7 +117,7 @@
             }
         }
     }
-#endif
+# endif
 
   return fd;
 }
--- a/lib/openat.h
+++ b/lib/openat.h
@@ -27,14 +27,10 @@
 #include <unistd.h>
 #include <stdbool.h>
 
-#ifndef __attribute__
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
-#  define __attribute__(x) /* empty */
-# endif
-#endif
-
-#ifndef ATTRIBUTE_NORETURN
-# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)
+# define _GL_ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
+#else
+# define _GL_ATTRIBUTE_NORETURN /* empty */
 #endif
 
 #if !HAVE_OPENAT
@@ -51,8 +47,8 @@
 
 #endif
 
-void openat_restore_fail (int) ATTRIBUTE_NORETURN;
-void openat_save_fail (int) ATTRIBUTE_NORETURN;
+void openat_restore_fail (int) _GL_ATTRIBUTE_NORETURN;
+void openat_save_fail (int) _GL_ATTRIBUTE_NORETURN;
 
 /* Using these function names makes application code
    slightly more readable than it would be with
--- a/lib/parse-duration.c
+++ b/lib/parse-duration.c
@@ -26,7 +26,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include "xalloc.h"
 
 #ifndef NUL
 #define NUL '\0'
@@ -381,7 +380,7 @@
 }
 
 /* Returns a substring of the given string, with spaces at the beginning and at
-   the end destructively removed.  */
+   the end destructively removed, per SNOBOL.  */
 static char *
 trim (char * pz)
 {
@@ -406,13 +405,20 @@
 static time_t
 parse_period (cch_t * in_pz)
 {
-  char * pz   = xstrdup (in_pz);
-  char * pT   = strchr (pz, 'T');
+  char * pT;
   char * ps;
+  char * pz   = strdup (in_pz);
   void * fptr = pz;
   time_t res  = 0;
 
-  if (pT != NUL)
+  if (pz == NULL)
+    {
+      errno = ENOMEM;
+      return BAD_TIME;
+    }
+
+  pT = strchr (pz, 'T');
+  if (pT != NULL)
     {
       *(pT++) = NUL;
       pz = trim (pz);
new file mode 100644
--- /dev/null
+++ b/lib/passfd.c
@@ -0,0 +1,181 @@
+/* Copyright (C) 2011 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/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include "passfd.h"
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/uio.h>
+#include <unistd.h>
+
+#include <sys/socket.h>
+#if HAVE_SYS_UN_H
+# include <sys/un.h>
+#endif
+
+#include "cloexec.h"
+
+#ifndef MSG_CMSG_CLOEXEC
+# define MSG_CMSG_CLOEXEC 0
+#endif
+
+/* sendfd sends the file descriptor fd along the socket
+   to a process calling recvfd on the other end.
+
+   Return 0 on success, or -1 with errno set in case of error.
+*/
+int
+sendfd (int sock, int fd)
+{
+  char send = 0;
+  struct iovec iov;
+  struct msghdr msg;
+#if HAVE_UNIXSOCKET_SCM_RIGHTS_BSD44_WAY
+  struct cmsghdr *cmsg;
+  char buf[CMSG_SPACE (sizeof fd)];
+#endif
+
+  /* send at least one char */
+  memset (&msg, 0, sizeof msg);
+  iov.iov_base = &send;
+  iov.iov_len = 1;
+  msg.msg_iov = &iov;
+  msg.msg_iovlen = 1;
+  msg.msg_name = NULL;
+  msg.msg_namelen = 0;
+
+#if HAVE_UNIXSOCKET_SCM_RIGHTS_BSD44_WAY
+  msg.msg_control = buf;
+  msg.msg_controllen = sizeof buf;
+  cmsg = CMSG_FIRSTHDR (&msg);
+  cmsg->cmsg_level = SOL_SOCKET;
+  cmsg->cmsg_type = SCM_RIGHTS;
+  cmsg->cmsg_len = CMSG_LEN (sizeof fd);
+  /* Initialize the payload: */
+  memcpy (CMSG_DATA (cmsg), &fd, sizeof fd);
+#elif HAVE_UNIXSOCKET_SCM_RIGHTS_BSD43_WAY
+  msg.msg_accrights = &fd;
+  msg.msg_accrightslen = sizeof fd;
+#else
+  errno = ENOSYS;
+  return -1;
+#endif
+
+  if (sendmsg (sock, &msg, 0) != iov.iov_len)
+    return -1;
+  return 0;
+}
+
+/* recvfd receives a file descriptor through the socket.
+   The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>).
+
+   Return 0 on success, or -1 with errno set in case of error.
+*/
+int
+recvfd (int sock, int flags)
+{
+  char recv = 0;
+  struct iovec iov;
+  struct msghdr msg;
+  int fd = -1;
+#if HAVE_UNIXSOCKET_SCM_RIGHTS_BSD44_WAY
+  struct cmsghdr *cmsg;
+  char buf[CMSG_SPACE (sizeof fd)];
+  int flags_recvmsg = flags & O_CLOEXEC ? MSG_CMSG_CLOEXEC : 0;
+#endif
+
+  if ((flags & ~O_CLOEXEC) != 0)
+    {
+      errno = EINVAL;
+      return -1;
+    }
+
+  /* send at least one char */
+  memset (&msg, 0, sizeof msg);
+  iov.iov_base = &recv;
+  iov.iov_len = 1;
+  msg.msg_iov = &iov;
+  msg.msg_iovlen = 1;
+  msg.msg_name = NULL;
+  msg.msg_namelen = 0;
+
+#if HAVE_UNIXSOCKET_SCM_RIGHTS_BSD44_WAY
+  msg.msg_control = buf;
+  msg.msg_controllen = sizeof buf;
+  cmsg = CMSG_FIRSTHDR (&msg);
+  cmsg->cmsg_level = SOL_SOCKET;
+  cmsg->cmsg_type = SCM_RIGHTS;
+  cmsg->cmsg_len = CMSG_LEN (sizeof fd);
+  /* Initialize the payload: */
+  memcpy (CMSG_DATA (cmsg), &fd, sizeof fd);
+  msg.msg_controllen = cmsg->cmsg_len;
+
+  if (recvmsg (sock, &msg, flags_recvmsg) < 0)
+    return -1;
+
+  cmsg = CMSG_FIRSTHDR (&msg);
+  /* be paranoiac */
+  if (cmsg == NULL || cmsg->cmsg_len != CMSG_LEN (sizeof fd)
+      || cmsg->cmsg_level != SOL_SOCKET || cmsg->cmsg_type != SCM_RIGHTS)
+    {
+      /* fake errno: at end the file is not available */
+      errno = EACCES;
+      return -1;
+    }
+
+  memcpy (&fd, CMSG_DATA (cmsg), sizeof fd);
+
+  /* set close-on-exec flag */
+  if (!MSG_CMSG_CLOEXEC && (flags & O_CLOEXEC))
+    {
+      if (set_cloexec_flag (fd, true) < 0)
+        {
+          int saved_errno = errno;
+          (void) close (fd);
+          errno = saved_errno;
+          return -1;
+        }
+    }
+
+#elif HAVE_UNIXSOCKET_SCM_RIGHTS_BSD43_WAY
+  msg.msg_accrights = &fd;
+  msg.msg_accrightslen = sizeof fd;
+  if (recvmsg (sock, &msg, 0) < 0)
+    return -1;
+
+  /* set close-on-exec flag */
+  if (flags & O_CLOEXEC)
+    {
+      if (set_cloexec_flag (fd, true) < 0)
+        {
+          int saved_errno = errno;
+          close (fd);
+          errno = saved_errno;
+          return -1;
+        }
+    }
+#else
+  errno = ENOSYS;
+#endif
+
+  return fd;
+}
new file mode 100644
--- /dev/null
+++ b/lib/passfd.h
@@ -0,0 +1,32 @@
+/* passfd.h -- definitions and prototypes for passfd.c
+
+   Copyright (C) 2011 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef PASSFD_H_
+#define PASSFD_H_ 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int sendfd (int sock, int fd);
+extern int recvfd (int sock, int flags);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--- a/lib/poll.in.h
+++ b/lib/poll.in.h
@@ -54,6 +54,8 @@
 # define POLLWRNORM  0x0100
 # define POLLWRBAND  0x0200
 
+# if !GNULIB_defined_poll_types
+
 struct pollfd
 {
   int fd;                       /* which file descriptor to poll */
@@ -63,6 +65,9 @@
 
 typedef unsigned long nfds_t;
 
+#  define GNULIB_defined_poll_types 1
+# endif
+
 /* Define INFTIM only if doing so conforms to POSIX.  */
 # if !defined (_POSIX_C_SOURCE) && !defined (_XOPEN_SOURCE)
 #  define INFTIM (-1)
--- a/lib/printf-args.h
+++ b/lib/printf-args.h
@@ -1,5 +1,5 @@
 /* Decomposed printf argument list.
-   Copyright (C) 1999, 2002-2003, 2006-2007, 2009-2011 Free Software
+   Copyright (C) 1999, 2002-2003, 2006-2007, 2011 Free Software
    Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
@@ -136,10 +136,14 @@
 }
 argument;
 
+/* Number of directly allocated arguments (no malloc() needed).  */
+#define N_DIRECT_ALLOC_ARGUMENTS 7
+
 typedef struct
 {
   size_t count;
   argument *arg;
+  argument direct_alloc_arg[N_DIRECT_ALLOC_ARGUMENTS];
 }
 arguments;
 
--- a/lib/printf-parse.c
+++ b/lib/printf-parse.c
@@ -63,6 +63,9 @@
 /* malloc(), realloc(), free().  */
 #include <stdlib.h>
 
+/* memcpy().  */
+#include <string.h>
+
 /* errno.  */
 #include <errno.h>
 
@@ -80,23 +83,20 @@
 int
 PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
 {
-  const CHAR_T *cp = format;            /* pointer into format */
+  const CHAR_T *cp = format;    /* pointer into format */
   size_t arg_posn = 0;          /* number of regular arguments consumed */
-  size_t d_allocated;                   /* allocated elements of d->dir */
-  size_t a_allocated;                   /* allocated elements of a->arg */
+  size_t d_allocated;           /* allocated elements of d->dir */
+  size_t a_allocated;           /* allocated elements of a->arg */
   size_t max_width_length = 0;
   size_t max_precision_length = 0;
 
   d->count = 0;
-  d_allocated = 1;
-  d->dir = (DIRECTIVE *) malloc (d_allocated * sizeof (DIRECTIVE));
-  if (d->dir == NULL)
-    /* Out of memory.  */
-    goto out_of_memory_1;
+  d_allocated = N_DIRECT_ALLOC_DIRECTIVES;
+  d->dir = d->direct_alloc_dir;
 
   a->count = 0;
-  a_allocated = 0;
-  a->arg = NULL;
+  a_allocated = N_DIRECT_ALLOC_ARGUMENTS;
+  a->arg = a->direct_alloc_arg;
 
 #define REGISTER_ARG(_index_,_type_) \
   {                                                                     \
@@ -113,12 +113,14 @@
         if (size_overflow_p (memory_size))                              \
           /* Overflow, would lead to out of memory.  */                 \
           goto out_of_memory;                                           \
-        memory = (argument *) (a->arg                                   \
+        memory = (argument *) (a->arg != a->direct_alloc_arg            \
                                ? realloc (a->arg, memory_size)          \
                                : malloc (memory_size));                 \
         if (memory == NULL)                                             \
           /* Out of memory.  */                                         \
           goto out_of_memory;                                           \
+        if (a->arg == a->direct_alloc_arg)                              \
+          memcpy (memory, a->arg, a->count * sizeof (argument));        \
         a->arg = memory;                                                \
       }                                                                 \
     while (a->count <= n)                                               \
@@ -588,10 +590,14 @@
               if (size_overflow_p (memory_size))
                 /* Overflow, would lead to out of memory.  */
                 goto out_of_memory;
-              memory = (DIRECTIVE *) realloc (d->dir, memory_size);
+              memory = (DIRECTIVE *) (d->dir != d->direct_alloc_dir
+                                      ? realloc (d->dir, memory_size)
+                                      : malloc (memory_size));
               if (memory == NULL)
                 /* Out of memory.  */
                 goto out_of_memory;
+              if (d->dir == d->direct_alloc_dir)
+                memcpy (memory, d->dir, d->count * sizeof (DIRECTIVE));
               d->dir = memory;
             }
         }
@@ -610,19 +616,18 @@
   return 0;
 
 error:
-  if (a->arg)
+  if (a->arg != a->direct_alloc_arg)
     free (a->arg);
-  if (d->dir)
+  if (d->dir != d->direct_alloc_dir)
     free (d->dir);
   errno = EINVAL;
   return -1;
 
 out_of_memory:
-  if (a->arg)
+  if (a->arg != a->direct_alloc_arg)
     free (a->arg);
-  if (d->dir)
+  if (d->dir != d->direct_alloc_dir)
     free (d->dir);
-out_of_memory_1:
   errno = ENOMEM;
   return -1;
 }
--- a/lib/printf-parse.h
+++ b/lib/printf-parse.h
@@ -1,5 +1,5 @@
 /* Parse printf format string.
-   Copyright (C) 1999, 2002-2003, 2005, 2007, 2009-2011 Free Software
+   Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2011 Free Software
    Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
@@ -47,6 +47,9 @@
 /* xxx_directive: A parsed directive.
    xxx_directives: A parsed format string.  */
 
+/* Number of directly allocated directives (no malloc() needed).  */
+#define N_DIRECT_ALLOC_DIRECTIVES 7
+
 /* A parsed directive.  */
 typedef struct
 {
@@ -71,6 +74,7 @@
   char_directive *dir;
   size_t max_width_length;
   size_t max_precision_length;
+  char_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES];
 }
 char_directives;
 
@@ -100,6 +104,7 @@
   u8_directive *dir;
   size_t max_width_length;
   size_t max_precision_length;
+  u8_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES];
 }
 u8_directives;
 
@@ -127,6 +132,7 @@
   u16_directive *dir;
   size_t max_width_length;
   size_t max_precision_length;
+  u16_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES];
 }
 u16_directives;
 
@@ -154,6 +160,7 @@
   u32_directive *dir;
   size_t max_width_length;
   size_t max_precision_length;
+  u32_directive direct_alloc_dir[N_DIRECT_ALLOC_DIRECTIVES];
 }
 u32_directives;
 
--- a/lib/progreloc.c
+++ b/lib/progreloc.c
@@ -34,11 +34,11 @@
 # include <mach-o/dyld.h>
 #endif
 
-#if defined _WIN32 || defined __WIN32__
+#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
 # define WIN32_NATIVE
 #endif
 
-#if defined WIN32_NATIVE || defined __CYGWIN__
+#ifdef WIN32_NATIVE
 # define WIN32_LEAN_AND_MEAN
 # include <windows.h>
 #endif
@@ -72,8 +72,8 @@
    ISSLASH(C)           tests whether C is a directory separator character.
    IS_PATH_WITH_DIR(P)  tests whether P contains a directory specification.
  */
-#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
-  /* Win32, Cygwin, OS/2, DOS */
+#if ((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__) || defined __EMX__ || defined __DJGPP__
+  /* Win32, OS/2, DOS */
 # define ISSLASH(C) ((C) == '/' || (C) == '\\')
 # define HAS_DEVICE(P) \
     ((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \
@@ -102,7 +102,7 @@
 
 #if ENABLE_RELOCATABLE
 
-#ifdef __linux__
+#if defined __linux__ || defined __CYGWIN__
 /* File descriptor of the executable.
    (Only used to verify that we find the correct executable.)  */
 static int executable_fd = -1;
@@ -112,12 +112,13 @@
 static bool
 maybe_executable (const char *filename)
 {
-  /* Woe32 lacks the access() function, but Cygwin doesn't.  */
-#if !(defined WIN32_NATIVE && !defined __CYGWIN__)
+  /* Woe32 lacks the access() function.  */
+#if !defined WIN32_NATIVE
   if (access (filename, X_OK) < 0)
     return false;
+#endif
 
-#ifdef __linux__
+#if defined __linux__ || defined __CYGWIN__
   if (executable_fd >= 0)
     {
       /* If we already have an executable_fd, check that filename points to
@@ -136,7 +137,6 @@
         }
     }
 #endif
-#endif
 
   return true;
 }
@@ -148,7 +148,12 @@
 static char *
 find_executable (const char *argv0)
 {
-#if defined WIN32_NATIVE || defined __CYGWIN__
+#if defined WIN32_NATIVE
+  /* Native Win32 only.
+     On Cygwin, it is better to use the Cygwin provided /proc interface, than
+     to use native Win32 API and cygwin_conv_to_posix_path, because it supports
+     longer file names
+     (see <http://cygwin.com/ml/cygwin/2011-01/msg00410.html>).  */
   char location[MAX_PATH];
   int length = GetModuleFileName (NULL, location, sizeof (location));
   if (length < 0)
@@ -156,32 +161,9 @@
   if (!IS_PATH_WITH_DIR (location))
     /* Shouldn't happen.  */
     return NULL;
-  {
-#if defined __CYGWIN__
-    /* cygwin-1.5.13 (2005-03-01) or newer would also allow a Linux-like
-       implementation: readlink of "/proc/self/exe".  But using the
-       result of the Win32 system call is simpler and is consistent with the
-       code in relocatable.c.  */
-    /* On Cygwin, we need to convert paths coming from Win32 system calls
-       to the Unix-like slashified notation.  */
-    static char location_as_posix_path[2 * MAX_PATH];
-    /* There's no error return defined for cygwin_conv_to_posix_path.
-       See cygwin-api/func-cygwin-conv-to-posix-path.html.
-       Does it overflow the buffer of expected size MAX_PATH or does it
-       truncate the path?  I don't know.  Let's catch both.  */
-    cygwin_conv_to_posix_path (location, location_as_posix_path);
-    location_as_posix_path[MAX_PATH - 1] = '\0';
-    if (strlen (location_as_posix_path) >= MAX_PATH - 1)
-      /* A sign of buffer overflow or path truncation.  */
-      return NULL;
-    /* Call canonicalize_file_name, because Cygwin supports symbolic links.  */
-    return canonicalize_file_name (location_as_posix_path);
-#else
-    return xstrdup (location);
-#endif
-  }
-#else /* Unix && !Cygwin */
-#ifdef __linux__
+  return xstrdup (location);
+#else /* Unix */
+# ifdef __linux__
   /* The executable is accessible as /proc/<pid>/exe.  In newer Linux
      versions, also as /proc/self/exe.  Linux >= 2.1 provides a symlink
      to the true pathname; older Linux versions give only device and ino,
@@ -205,8 +187,21 @@
         executable_fd = open (buf, O_EXEC, 0);
     }
   }
-#endif
-#if HAVE_MACH_O_DYLD_H && HAVE__NSGETEXECUTABLEPATH
+# endif
+# ifdef __CYGWIN__
+  /* The executable is accessible as /proc/<pid>/exe, at least in
+     Cygwin >= 1.5.  */
+  {
+    char *link;
+
+    link = xreadlink ("/proc/self/exe");
+    if (link != NULL)
+      return link;
+    if (executable_fd < 0)
+      executable_fd = open ("/proc/self/exe", O_EXEC, 0);
+  }
+# endif
+# if HAVE_MACH_O_DYLD_H && HAVE__NSGETEXECUTABLEPATH
   /* On MacOS X 10.2 or newer, the function
        int _NSGetExecutablePath (char *buf, uint32_t *bufsize);
      can be used to retrieve the executable's full path.  */
@@ -215,7 +210,7 @@
   if (_NSGetExecutablePath (location, &length) == 0
       && location[0] == '/')
     return canonicalize_file_name (location);
-#endif
+# endif
   /* Guess the executable's full path.  We assume the executable has been
      called via execlp() or execvp() with properly set up argv[0].  The
      login(1) convention to add a '-' prefix to argv[0] is not supported.  */
@@ -256,10 +251,10 @@
                 /* We have a path item at p, of length p_len.
                    Now concatenate the path item and argv0.  */
                 concat_name = (char *) xmalloc (p_len + strlen (argv0) + 2);
-#ifdef NO_XMALLOC
+# ifdef NO_XMALLOC
                 if (concat_name == NULL)
                   return NULL;
-#endif
+# endif
                 if (p_len == 0)
                   /* An empty PATH element designates the current directory.  */
                   strcpy (concat_name, argv0);
--- a/lib/pthread.in.h
+++ b/lib/pthread.in.h
@@ -40,6 +40,7 @@
 #include <time.h>
 
 #if ! @HAVE_PTHREAD_T@
+# if !GNULIB_defined_pthread_types
  typedef int pthread_t;
  typedef int pthread_attr_t;
  typedef int pthread_barrier_t;
@@ -52,6 +53,8 @@
  typedef int pthread_once_t;
  typedef int pthread_rwlock_t;
  typedef int pthread_rwlockattr_t;
+#  define GNULIB_defined_pthread_types 1
+# endif
 #endif
 
 #ifndef PTHREAD_COND_INITIALIZER
@@ -97,6 +100,8 @@
 
 #if ! @HAVE_PTHREAD_T@
 
+# if !GNULIB_defined_pthread_functions
+
 /* Provide substitutes for the thread functions that should work
    adequately on a single-threaded implementation, where
    pthread_create always fails.  The goal is to let programs compile
@@ -217,10 +222,15 @@
   return 0;
 }
 
+#  define GNULIB_defined_pthread_functions 1
+# endif
+
 #endif
 
 #if ! @HAVE_PTHREAD_SPINLOCK_T@
 
+# if !GNULIB_defined_pthread_spinlock_t
+
 /* Approximate spinlocks with mutexes.  */
 
 typedef pthread_mutex_t pthread_spinlock_t;
@@ -254,6 +264,10 @@
 {
   return pthread_mutex_unlock (lock);
 }
+
+#  define GNULIB_defined_pthread_spinlock_t 1
+# endif
+
 #endif
 
 #endif /* _GL_PTHREAD_H_ */
--- a/lib/regex-quote.c
+++ b/lib/regex-quote.c
@@ -29,58 +29,188 @@
 static const char bre_special[] = "$^.*[]\\";
 
 /* Characters that are special in an ERE.  */
-static const char ere_special[] = "$^.*[]\\+?()";
+static const char ere_special[] = "$^.*[]\\+?{}()|";
+
+struct regex_quote_spec
+regex_quote_spec_posix (int cflags, bool anchored)
+{
+  struct regex_quote_spec result;
+
+  strcpy (result.special, cflags != 0 ? ere_special : bre_special);
+  result.multibyte = true;
+  result.anchored = anchored;
+
+  return result;
+}
+
+/* Syntax bit values, defined in GNU <regex.h>.  We don't include it here,
+   otherwise this module would need to depend on gnulib module 'regex'.  */
+#define RE_BK_PLUS_QM    0x00000002
+#define RE_INTERVALS     0x00000200
+#define RE_LIMITED_OPS   0x00000400
+#define RE_NEWLINE_ALT   0x00000800
+#define RE_NO_BK_BRACES  0x00001000
+#define RE_NO_BK_PARENS  0x00002000
+#define RE_NO_BK_VBAR    0x00008000
+
+struct regex_quote_spec
+regex_quote_spec_gnu (unsigned long /*reg_syntax_t*/ syntax, bool anchored)
+{
+  struct regex_quote_spec result;
+  char *p;
+
+  p = result.special;
+  memcpy (p, bre_special, sizeof (bre_special) - 1);
+  p += sizeof (bre_special) - 1;
+  if ((syntax & RE_LIMITED_OPS) == 0 && (syntax & RE_BK_PLUS_QM) == 0)
+    {
+      *p++ = '+';
+      *p++ = '?';
+    }
+  if ((syntax & RE_INTERVALS) != 0 && (syntax & RE_NO_BK_BRACES) != 0)
+    {
+      *p++ = '{';
+      *p++ = '}';
+    }
+  if ((syntax & RE_NO_BK_PARENS) != 0)
+    {
+      *p++ = '(';
+      *p++ = ')';
+    }
+  if ((syntax & RE_LIMITED_OPS) == 0 && (syntax & RE_NO_BK_VBAR) != 0)
+    *p++ = '|';
+  if ((syntax & RE_NEWLINE_ALT) != 0)
+    *p++ = '\n';
+  *p = '\0';
+
+  result.multibyte = true;
+  result.anchored = anchored;
+
+  return result;
+}
+
+/* Characters that are special in a PCRE.  */
+static const char pcre_special[] = "$^.*[]\\+?{}()|";
+
+/* Options bit values, defined in <pcre.h>.  We don't include it here, because
+   it is not a standard header.  */
+#define PCRE_ANCHORED 0x00000010
+#define PCRE_EXTENDED 0x00000008
+
+struct regex_quote_spec
+regex_quote_spec_pcre (int options, bool anchored)
+{
+  struct regex_quote_spec result;
+  char *p;
+
+  p = result.special;
+  memcpy (p, bre_special, sizeof (pcre_special) - 1);
+  p += sizeof (pcre_special) - 1;
+  if (options & PCRE_EXTENDED)
+    {
+      *p++ = ' ';
+      *p++ = '\t';
+      *p++ = '\n';
+      *p++ = '\v';
+      *p++ = '\f';
+      *p++ = '\r';
+      *p++ = '#';
+    }
+  *p = '\0';
+
+  /* PCRE regular expressions consist of UTF-8 characters of options contains
+     PCRE_UTF8 and of single bytes otherwise.  */
+  result.multibyte = false;
+  /* If options contains PCRE_ANCHORED, the anchoring is implicit.  */
+  result.anchored = (options & PCRE_ANCHORED ? 0 : anchored);
+
+  return result;
+}
 
 size_t
-regex_quote_length (const char *string, int cflags)
+regex_quote_length (const char *string, const struct regex_quote_spec *spec)
 {
-  const char *special = (cflags != 0 ? ere_special : bre_special);
+  const char *special = spec->special;
   size_t length;
-  mbui_iterator_t iter;
 
   length = 0;
-  for (mbui_init (iter, string); mbui_avail (iter); mbui_advance (iter))
+  if (spec->anchored)
+    length += 2; /* for '^' at the beginning and '$' at the end */
+  if (spec->multibyte)
     {
-      /* We know that special contains only ASCII characters.  */
-      if (mb_len (mbui_cur (iter)) == 1
-          && strchr (special, * mbui_cur_ptr (iter)))
-        length += 1;
-      length += mb_len (mbui_cur (iter));
+      mbui_iterator_t iter;
+
+      for (mbui_init (iter, string); mbui_avail (iter); mbui_advance (iter))
+        {
+          /* We know that special contains only ASCII characters.  */
+          if (mb_len (mbui_cur (iter)) == 1
+              && strchr (special, * mbui_cur_ptr (iter)))
+            length += 1;
+          length += mb_len (mbui_cur (iter));
+        }
     }
+  else
+    {
+      const char *iter;
+
+      for (iter = string; *iter != '\0'; iter++)
+        {
+          if (strchr (special, *iter))
+            length += 1;
+          length += 1;
+        }
+    }
+
   return length;
 }
 
-/* Copies the quoted string to p and returns the incremented p.
-   There must be room for regex_quote_length (string, cflags) + 1 bytes at p.
- */
 char *
-regex_quote_copy (char *p, const char *string, int cflags)
+regex_quote_copy (char *p, const char *string, const struct regex_quote_spec *spec)
 {
-  const char *special = (cflags != 0 ? ere_special : bre_special);
-  mbui_iterator_t iter;
+  const char *special = spec->special;
+
+  if (spec->anchored)
+    *p++ = '^';
+  if (spec->multibyte)
+    {
+      mbui_iterator_t iter;
 
-  for (mbui_init (iter, string); mbui_avail (iter); mbui_advance (iter))
+      for (mbui_init (iter, string); mbui_avail (iter); mbui_advance (iter))
+        {
+          /* We know that special contains only ASCII characters.  */
+          if (mb_len (mbui_cur (iter)) == 1
+              && strchr (special, * mbui_cur_ptr (iter)))
+            *p++ = '\\';
+          memcpy (p, mbui_cur_ptr (iter), mb_len (mbui_cur (iter)));
+          p += mb_len (mbui_cur (iter));
+        }
+    }
+  else
     {
-      /* We know that special contains only ASCII characters.  */
-      if (mb_len (mbui_cur (iter)) == 1
-          && strchr (special, * mbui_cur_ptr (iter)))
-        *p++ = '\\';
-      memcpy (p, mbui_cur_ptr (iter), mb_len (mbui_cur (iter)));
-      p += mb_len (mbui_cur (iter));
+      const char *iter;
+
+      for (iter = string; *iter != '\0'; iter++)
+        {
+          if (strchr (special, *iter))
+            *p++ = '\\';
+          *p++ = *iter++;
+        }
     }
+  if (spec->anchored)
+    *p++ = '$';
+
   return p;
 }
 
-/* Returns the freshly allocated quoted string.  */
 char *
-regex_quote (const char *string, int cflags)
+regex_quote (const char *string, const struct regex_quote_spec *spec)
 {
-  size_t length = regex_quote_length (string, cflags);
+  size_t length = regex_quote_length (string, spec);
   char *result = XNMALLOC (length + 1, char);
   char *p;
 
   p = result;
-  p = regex_quote_copy (p, string, cflags);
+  p = regex_quote_copy (p, string, spec);
   *p = '\0';
   return result;
 }
--- a/lib/regex-quote.h
+++ b/lib/regex-quote.h
@@ -15,27 +15,74 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+#ifndef _REGEX_QUOTE_H
+#define _REGEX_QUOTE_H
+
 #include <stddef.h>
+#include <stdbool.h>
+
 
-/* regex_quote converts a literal string to a regular expression that will
-   look for this literal string.
-   cflags can be 0 or REG_EXTENDED.
+/* Specifies a quotation task for converting a fixed string to a regular
+   expression pattern.  */
+struct regex_quote_spec
+{
+  /* True if the regular expression pattern consists of multibyte characters
+     (in the encoding given by the LC_CTYPE category of the locale),
+     false if it consists of single bytes or UTF-8 characters.  */
+  unsigned int /*bool*/ multibyte : 1;
+  /* True if the regular expression pattern shall match only entire lines.  */
+  unsigned int /*bool*/ anchored : 1;
+  /* Set of characters that need to be escaped (all ASCII), as a
+     NUL-terminated string.  */
+  char special[30 + 1];
+};
+
+
+/* Creates a quotation task that produces a POSIX regular expression, that is,
+   a pattern that can be compiled with regcomp().
+   CFLAGS can be 0 or REG_EXTENDED.
    If it is 0, the result is a Basic Regular Expression (BRE)
    <http://www.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_03>.
    If it is REG_EXTENDED, the result is an Extended Regular Expression (ERE)
    <http://www.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_04>.
-   The result is not anchored; if you want it to match only complete lines,
-   you need to add "^" at the beginning of the result and "$" at the end of the
-   result.
- */
+   If ANCHORED is false, the regular expression will match substrings of lines.
+   If ANCHORED is true, it will match only complete lines,  */
+extern struct regex_quote_spec
+       regex_quote_spec_posix (int cflags, bool anchored);
+
+/* Creates a quotation task that produces a regular expression that can be
+   compiled with the GNU API function re_compile_pattern().
+   SYNTAX describes the syntax of the regular expression (such as
+   RE_SYNTAX_POSIX_BASIC, RE_SYNTAX_POSIX_EXTENDED, RE_SYNTAX_EMACS, all
+   defined in <regex.h>).  It must be the same value as 're_syntax_options'
+   at the moment of the re_compile_pattern() call.
+   If ANCHORED is false, the regular expression will match substrings of lines.
+   If ANCHORED is true, it will match only complete lines,  */
+extern struct regex_quote_spec
+       regex_quote_spec_gnu (unsigned long /*reg_syntax_t*/ syntax, bool anchored);
+
+/* Creates a quotation task that produces a PCRE regular expression, that is,
+   a pattern that can be compiled with pcre_compile().
+   OPTIONS is the same value as the second argument passed to pcre_compile().
+   If ANCHORED is false, the regular expression will match substrings of lines.
+   If ANCHORED is true, it will match only complete lines,  */
+extern struct regex_quote_spec
+       regex_quote_spec_pcre (int options, bool anchored);
+
 
 /* Returns the number of bytes needed for the quoted string.  */
-extern size_t regex_quote_length (const char *string, int cflags);
+extern size_t
+       regex_quote_length (const char *string, const struct regex_quote_spec *spec);
 
 /* Copies the quoted string to p and returns the incremented p.
-   There must be room for regex_quote_length (string, cflags) + 1 bytes at p.
- */
-extern char * regex_quote_copy (char *p, const char *string, int cflags);
+   There must be room for regex_quote_length (string, spec) + 1 bytes at p.  */
+extern char *
+       regex_quote_copy (char *p,
+                         const char *string, const struct regex_quote_spec *spec);
 
 /* Returns the freshly allocated quoted string.  */
-extern char * regex_quote (const char *string, int cflags);
+extern char *
+       regex_quote (const char *string, const struct regex_quote_spec *spec);
+
+
+#endif /* _REGEX_QUOTE_H */
--- a/lib/relocatable.c
+++ b/lib/relocatable.c
@@ -43,7 +43,7 @@
 # include "xalloc.h"
 #endif
 
-#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__
+#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
 # define WIN32_LEAN_AND_MEAN
 # include <windows.h>
 #endif
@@ -70,8 +70,8 @@
    ISSLASH(C)           tests whether C is a directory separator character.
    IS_PATH_WITH_DIR(P)  tests whether P contains a directory specification.
  */
-#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
-  /* Win32, Cygwin, OS/2, DOS */
+#if ((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__) || defined __EMX__ || defined __DJGPP__
+  /* Win32, OS/2, DOS */
 # define ISSLASH(C) ((C) == '/' || (C) == '\\')
 # define HAS_DEVICE(P) \
     ((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \
@@ -293,7 +293,12 @@
 /* Full pathname of shared library, or NULL.  */
 static char *shared_library_fullname;
 
-#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__
+#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
+/* Native Win32 only.
+   On Cygwin, it is better to use the Cygwin provided /proc interface, than
+   to use native Win32 API and cygwin_conv_to_posix_path, because it supports
+   longer file names
+   (see <http://cygwin.com/ml/cygwin/2011-01/msg00410.html>).  */
 
 /* Determine the full pathname of the shared library when it is loaded.  */
 
@@ -315,38 +320,21 @@
         /* Shouldn't happen.  */
         return FALSE;
 
-      {
-#if defined __CYGWIN__
-        /* On Cygwin, we need to convert paths coming from Win32 system calls
-           to the Unix-like slashified notation.  */
-        static char location_as_posix_path[2 * MAX_PATH];
-        /* There's no error return defined for cygwin_conv_to_posix_path.
-           See cygwin-api/func-cygwin-conv-to-posix-path.html.
-           Does it overflow the buffer of expected size MAX_PATH or does it
-           truncate the path?  I don't know.  Let's catch both.  */
-        cygwin_conv_to_posix_path (location, location_as_posix_path);
-        location_as_posix_path[MAX_PATH - 1] = '\0';
-        if (strlen (location_as_posix_path) >= MAX_PATH - 1)
-          /* A sign of buffer overflow or path truncation.  */
-          return FALSE;
-        shared_library_fullname = strdup (location_as_posix_path);
-#else
-        shared_library_fullname = strdup (location);
-#endif
-      }
+      shared_library_fullname = strdup (location);
     }
 
   return TRUE;
 }
 
-#else /* Unix except Cygwin */
+#else /* Unix */
 
 static void
 find_shared_library_fullname ()
 {
-#if defined __linux__ && (__GLIBC__ >= 2 || defined __UCLIBC__)
+#if (defined __linux__ && (__GLIBC__ >= 2 || defined __UCLIBC__)) || defined __CYGWIN__
   /* Linux has /proc/self/maps. glibc 2 and uClibc have the getline()
-     function.  */
+     function.
+     Cygwin >= 1.5 has /proc/self/maps and the getline() function too.  */
   FILE *fp;
 
   /* Open the current process' maps file.  It describes one VMA per line.  */
@@ -391,7 +379,7 @@
 #endif
 }
 
-#endif /* (WIN32 or Cygwin) / (Unix except Cygwin) */
+#endif /* WIN32 / Unix */
 
 /* Return the full pathname of the current shared library.
    Return NULL if unknown.
@@ -399,7 +387,7 @@
 static char *
 get_shared_library_fullname ()
 {
-#if !(defined _WIN32 || defined __WIN32__ || defined __CYGWIN__)
+#if !((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__)
   static bool tried_find_shared_library_fullname;
   if (!tried_find_shared_library_fullname)
     {
--- a/lib/rmdir.c
+++ b/lib/rmdir.c
@@ -23,6 +23,8 @@
 #include <errno.h>
 #include <string.h>
 
+#include "dosname.h"
+
 #undef rmdir
 
 /* Remove directory DIR.
--- a/lib/safe-alloc.h
+++ b/lib/safe-alloc.h
@@ -31,22 +31,22 @@
 # endif
 #endif
 
-# ifndef ATTRIBUTE_RETURN_CHECK
+# ifndef _GL_ATTRIBUTE_RETURN_CHECK
 #  if __GNUC_PREREQ (3, 4)
-#   define ATTRIBUTE_RETURN_CHECK __attribute__((__warn_unused_result__))
+#   define _GL_ATTRIBUTE_RETURN_CHECK __attribute__((__warn_unused_result__))
 #  else
-#   define ATTRIBUTE_RETURN_CHECK
+#   define _GL_ATTRIBUTE_RETURN_CHECK
 #  endif
 # endif
 
 /* Don't call these directly - use the macros below */
 int
 safe_alloc_alloc_n (void *ptrptr, size_t size, size_t count, int zeroed)
-  ATTRIBUTE_RETURN_CHECK;
+  _GL_ATTRIBUTE_RETURN_CHECK;
 
 int
 safe_alloc_realloc_n (void *ptrptr, size_t size, size_t count)
-  ATTRIBUTE_RETURN_CHECK;
+  _GL_ATTRIBUTE_RETURN_CHECK;
 
 /**
  * ALLOC:
--- a/lib/savewd.c
+++ b/lib/savewd.c
@@ -31,7 +31,7 @@
 #include <sys/wait.h>
 #include <unistd.h>
 
-#include "dirname.h"
+#include "dosname.h"
 #include "fcntl-safer.h"
 
 /* Save the working directory into *WD, if it hasn't been saved
--- a/lib/sched.in.h
+++ b/lib/sched.in.h
@@ -31,10 +31,13 @@
 
 #if !@HAVE_STRUCT_SCHED_PARAM@
 
+# if !GNULIB_defined_struct_sched_param
 struct sched_param
 {
   int sched_priority;
 };
+#  define GNULIB_defined_struct_sched_param 1
+# endif
 
 #endif
 
--- a/lib/se-selinux.in.h
+++ b/lib/se-selinux.in.h
@@ -33,9 +33,11 @@
 
 /* The definition of _GL_UNUSED_PARAMETER is copied here.  */
 
+#  if !GNULIB_defined_security_types
+
 typedef unsigned short security_class_t;
-#  define security_context_t char*
-#  define is_selinux_enabled() 0
+#   define security_context_t char*
+#   define is_selinux_enabled() 0
 
 static inline int getcon (security_context_t *con _GL_UNUSED_PARAMETER)
   { errno = ENOTSUP; return -1; }
@@ -88,5 +90,8 @@
      char const *prefix _GL_UNUSED_PARAMETER)
   { errno = ENOTSUP; return -1; }
 
+#   define GNULIB_defined_security_types 1
+#  endif
+
 # endif
 #endif /* _GL_SELINUX_SELINUX_H */
--- a/lib/search.in.h
+++ b/lib/search.in.h
@@ -53,6 +53,7 @@
    for details.  */
 
 # if !@HAVE_TSEARCH@
+#  if !GNULIB_defined_search_types
 typedef enum
 {
   preorder,
@@ -61,13 +62,18 @@
   leaf
 }
 VISIT;
+#   define GNULIB_defined_search_types 1
+#  endif
 # endif
 
 # ifdef __cplusplus
 extern "C" {
 # endif
+# if !GNULIB_defined_search_fn_types
 typedef int (*_gl_search_compar_fn) (const void *, const void *);
 typedef void (*_gl_search_action_fn) (const void *, VISIT, int);
+#  define GNULIB_defined_search_fn_types 1
+# endif
 # ifdef __cplusplus
 }
 # endif
new file mode 100644
--- /dev/null
+++ b/lib/setlocale.c
@@ -0,0 +1,938 @@
+/* Set the current locale.
+   Copyright (C) 2009, 2011 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2009.  */
+
+#include <config.h>
+
+/* Override setlocale() so that when the default locale is requested
+   (locale = ""), the environment variables LC_ALL, LC_*, and LANG are
+   considered.
+   Also include all the functionality from libintl's setlocale() override.  */
+
+/* Please keep this file in sync with
+   gettext/gettext-runtime/intl/setlocale.c !  */
+
+/* Specification.  */
+#include <locale.h>
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "localename.h"
+
+#if 1
+
+# undef setlocale
+
+/* Return string representation of locale category CATEGORY.  */
+static const char *
+category_to_name (int category)
+{
+  const char *retval;
+
+  switch (category)
+  {
+  case LC_COLLATE:
+    retval = "LC_COLLATE";
+    break;
+  case LC_CTYPE:
+    retval = "LC_CTYPE";
+    break;
+  case LC_MONETARY:
+    retval = "LC_MONETARY";
+    break;
+  case LC_NUMERIC:
+    retval = "LC_NUMERIC";
+    break;
+  case LC_TIME:
+    retval = "LC_TIME";
+    break;
+  case LC_MESSAGES:
+    retval = "LC_MESSAGES";
+    break;
+  default:
+    /* If you have a better idea for a default value let me know.  */
+    retval = "LC_XXX";
+  }
+
+  return retval;
+}
+
+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+
+/* The native Win32 setlocale() function expects locale names of the form
+   "German" or "German_Germany" or "DEU", but not "de" or "de_DE".  We need
+   to convert the names from the form with ISO 639 language code and ISO 3166
+   country code to the form with English names or with three-letter identifier.
+   The three-letter identifiers known by a Windows XP SP2 or SP3 are:
+     AFK  Afrikaans_South Africa.1252
+     ARA  Arabic_Saudi Arabia.1256
+     ARB  Arabic_Lebanon.1256
+     ARE  Arabic_Egypt.1256
+     ARG  Arabic_Algeria.1256
+     ARH  Arabic_Bahrain.1256
+     ARI  Arabic_Iraq.1256
+     ARJ  Arabic_Jordan.1256
+     ARK  Arabic_Kuwait.1256
+     ARL  Arabic_Libya.1256
+     ARM  Arabic_Morocco.1256
+     ARO  Arabic_Oman.1256
+     ARQ  Arabic_Qatar.1256
+     ARS  Arabic_Syria.1256
+     ART  Arabic_Tunisia.1256
+     ARU  Arabic_U.A.E..1256
+     ARY  Arabic_Yemen.1256
+     AZE  Azeri (Latin)_Azerbaijan.1254
+     BEL  Belarusian_Belarus.1251
+     BGR  Bulgarian_Bulgaria.1251
+     BSB  Bosnian_Bosnia and Herzegovina.1250
+     BSC  Bosnian (Cyrillic)_Bosnia and Herzegovina.1250  (wrong encoding!)
+     CAT  Catalan_Spain.1252
+     CHH  Chinese_Hong Kong S.A.R..950
+     CHI  Chinese_Singapore.936
+     CHS  Chinese_People's Republic of China.936
+     CHT  Chinese_Taiwan.950
+     CSY  Czech_Czech Republic.1250
+     CYM  Welsh_United Kingdom.1252
+     DAN  Danish_Denmark.1252
+     DEA  German_Austria.1252
+     DEC  German_Liechtenstein.1252
+     DEL  German_Luxembourg.1252
+     DES  German_Switzerland.1252
+     DEU  German_Germany.1252
+     ELL  Greek_Greece.1253
+     ENA  English_Australia.1252
+     ENB  English_Caribbean.1252
+     ENC  English_Canada.1252
+     ENG  English_United Kingdom.1252
+     ENI  English_Ireland.1252
+     ENJ  English_Jamaica.1252
+     ENL  English_Belize.1252
+     ENP  English_Republic of the Philippines.1252
+     ENS  English_South Africa.1252
+     ENT  English_Trinidad and Tobago.1252
+     ENU  English_United States.1252
+     ENW  English_Zimbabwe.1252
+     ENZ  English_New Zealand.1252
+     ESA  Spanish_Panama.1252
+     ESB  Spanish_Bolivia.1252
+     ESC  Spanish_Costa Rica.1252
+     ESD  Spanish_Dominican Republic.1252
+     ESE  Spanish_El Salvador.1252
+     ESF  Spanish_Ecuador.1252
+     ESG  Spanish_Guatemala.1252
+     ESH  Spanish_Honduras.1252
+     ESI  Spanish_Nicaragua.1252
+     ESL  Spanish_Chile.1252
+     ESM  Spanish_Mexico.1252
+     ESN  Spanish_Spain.1252
+     ESO  Spanish_Colombia.1252
+     ESP  Spanish_Spain.1252
+     ESR  Spanish_Peru.1252
+     ESS  Spanish_Argentina.1252
+     ESU  Spanish_Puerto Rico.1252
+     ESV  Spanish_Venezuela.1252
+     ESY  Spanish_Uruguay.1252
+     ESZ  Spanish_Paraguay.1252
+     ETI  Estonian_Estonia.1257
+     EUQ  Basque_Spain.1252
+     FAR  Farsi_Iran.1256
+     FIN  Finnish_Finland.1252
+     FOS  Faroese_Faroe Islands.1252
+     FPO  Filipino_Philippines.1252
+     FRA  French_France.1252
+     FRB  French_Belgium.1252
+     FRC  French_Canada.1252
+     FRL  French_Luxembourg.1252
+     FRM  French_Principality of Monaco.1252
+     FRS  French_Switzerland.1252
+     FYN  Frisian_Netherlands.1252
+     GLC  Galician_Spain.1252
+     HEB  Hebrew_Israel.1255
+     HRB  Croatian_Bosnia and Herzegovina.1250
+     HRV  Croatian_Croatia.1250
+     HUN  Hungarian_Hungary.1250
+     IND  Indonesian_Indonesia.1252
+     IRE  Irish_Ireland.1252
+     ISL  Icelandic_Iceland.1252
+     ITA  Italian_Italy.1252
+     ITS  Italian_Switzerland.1252
+     IUK  Inuktitut (Latin)_Canada.1252
+     JPN  Japanese_Japan.932
+     KKZ  Kazakh_Kazakhstan.1251
+     KOR  Korean_Korea.949
+     KYR  Kyrgyz_Kyrgyzstan.1251
+     LBX  Luxembourgish_Luxembourg.1252
+     LTH  Lithuanian_Lithuania.1257
+     LVI  Latvian_Latvia.1257
+     MKI  FYRO Macedonian_Former Yugoslav Republic of Macedonia.1251
+     MON  Mongolian_Mongolia.1251
+     MPD  Mapudungun_Chile.1252
+     MSB  Malay_Brunei Darussalam.1252
+     MSL  Malay_Malaysia.1252
+     MWK  Mohawk_Canada.1252
+     NLB  Dutch_Belgium.1252
+     NLD  Dutch_Netherlands.1252
+     NON  Norwegian-Nynorsk_Norway.1252
+     NOR  Norwegian (Bokmål)_Norway.1252
+     NSO  Northern Sotho_South Africa.1252
+     PLK  Polish_Poland.1250
+     PTB  Portuguese_Brazil.1252
+     PTG  Portuguese_Portugal.1252
+     QUB  Quechua_Bolivia.1252
+     QUE  Quechua_Ecuador.1252
+     QUP  Quechua_Peru.1252
+     RMC  Romansh_Switzerland.1252
+     ROM  Romanian_Romania.1250
+     RUS  Russian_Russia.1251
+     SKY  Slovak_Slovakia.1250
+     SLV  Slovenian_Slovenia.1250
+     SMA  Sami (Southern)_Norway.1252
+     SMB  Sami (Southern)_Sweden.1252
+     SME  Sami (Northern)_Norway.1252
+     SMF  Sami (Northern)_Sweden.1252
+     SMG  Sami (Northern)_Finland.1252
+     SMJ  Sami (Lule)_Norway.1252
+     SMK  Sami (Lule)_Sweden.1252
+     SMN  Sami (Inari)_Finland.1252
+     SMS  Sami (Skolt)_Finland.1252
+     SQI  Albanian_Albania.1250
+     SRB  Serbian (Cyrillic)_Serbia and Montenegro.1251
+     SRL  Serbian (Latin)_Serbia and Montenegro.1250
+     SRN  Serbian (Cyrillic)_Bosnia and Herzegovina.1251
+     SRS  Serbian (Latin)_Bosnia and Herzegovina.1250
+     SVE  Swedish_Sweden.1252
+     SVF  Swedish_Finland.1252
+     SWK  Swahili_Kenya.1252
+     THA  Thai_Thailand.874
+     TRK  Turkish_Turkey.1254
+     TSN  Tswana_South Africa.1252
+     TTT  Tatar_Russia.1251
+     UKR  Ukrainian_Ukraine.1251
+     URD  Urdu_Islamic Republic of Pakistan.1256
+     USA  English_United States.1252
+     UZB  Uzbek (Latin)_Uzbekistan.1254
+     VIT  Vietnamese_Viet Nam.1258
+     XHO  Xhosa_South Africa.1252
+     ZHH  Chinese_Hong Kong S.A.R..950
+     ZHI  Chinese_Singapore.936
+     ZHM  Chinese_Macau S.A.R..950
+     ZUL  Zulu_South Africa.1252
+ */
+
+/* Table from ISO 639 language code, optionally with country or script suffix,
+   to English name.
+   Keep in sync with the gl_locale_name_from_win32_LANGID function in
+   localename.c!  */
+struct table_entry
+{
+  const char *code;
+  const char *english;
+};
+static const struct table_entry language_table[] =
+  {
+    { "af", "Afrikaans" },
+    { "am", "Amharic" },
+    { "ar", "Arabic" },
+    { "arn", "Mapudungun" },
+    { "as", "Assamese" },
+    { "az@cyrillic", "Azeri (Cyrillic)" },
+    { "az@latin", "Azeri (Latin)" },
+    { "ba", "Bashkir" },
+    { "be", "Belarusian" },
+    { "ber", "Tamazight" },
+    { "ber@arabic", "Tamazight (Arabic)" },
+    { "ber@latin", "Tamazight (Latin)" },
+    { "bg", "Bulgarian" },
+    { "bin", "Edo" },
+    { "bn", "Bengali" },
+    { "bn_BD", "Bengali (Bangladesh)" },
+    { "bn_IN", "Bengali (India)" },
+    { "bnt", "Sutu" },
+    { "bo", "Tibetan" },
+    { "br", "Breton" },
+    { "bs", "BSB" }, /* "Bosnian (Latin)" */
+    { "bs@cyrillic", "BSC" }, /* Bosnian (Cyrillic) */
+    { "ca", "Catalan" },
+    { "chr", "Cherokee" },
+    { "co", "Corsican" },
+    { "cpe", "Hawaiian" },
+    { "cs", "Czech" },
+    { "cy", "Welsh" },
+    { "da", "Danish" },
+    { "de", "German" },
+    { "dsb", "Lower Sorbian" },
+    { "dv", "Divehi" },
+    { "el", "Greek" },
+    { "en", "English" },
+    { "es", "Spanish" },
+    { "et", "Estonian" },
+    { "eu", "Basque" },
+    { "fa", "Farsi" },
+    { "ff", "Fulfulde" },
+    { "fi", "Finnish" },
+    { "fo", "Faroese" }, /* "Faeroese" does not work */
+    { "fr", "French" },
+    { "fy", "Frisian" },
+    { "ga", "IRE" }, /* Gaelic (Ireland) */
+    { "gd", "Gaelic (Scotland)" },
+    { "gd", "Scottish Gaelic" },
+    { "gl", "Galician" },
+    { "gn", "Guarani" },
+    { "gsw", "Alsatian" },
+    { "gu", "Gujarati" },
+    { "ha", "Hausa" },
+    { "he", "Hebrew" },
+    { "hi", "Hindi" },
+    { "hr", "Croatian" },
+    { "hsb", "Upper Sorbian" },
+    { "hu", "Hungarian" },
+    { "hy", "Armenian" },
+    { "id", "Indonesian" },
+    { "ig", "Igbo" },
+    { "ii", "Yi" },
+    { "is", "Icelandic" },
+    { "it", "Italian" },
+    { "iu", "IUK" }, /* Inuktitut */
+    { "ja", "Japanese" },
+    { "ka", "Georgian" },
+    { "kk", "Kazakh" },
+    { "kl", "Greenlandic" },
+    { "km", "Cambodian" },
+    { "km", "Khmer" },
+    { "kn", "Kannada" },
+    { "ko", "Korean" },
+    { "kok", "Konkani" },
+    { "kr", "Kanuri" },
+    { "ks", "Kashmiri" },
+    { "ks_IN", "Kashmiri_India" },
+    { "ks_PK", "Kashmiri (Arabic)_Pakistan" },
+    { "ky", "Kyrgyz" },
+    { "la", "Latin" },
+    { "lb", "Luxembourgish" },
+    { "lo", "Lao" },
+    { "lt", "Lithuanian" },
+    { "lv", "Latvian" },
+    { "mi", "Maori" },
+    { "mk", "FYRO Macedonian" },
+    { "mk", "Macedonian" },
+    { "ml", "Malayalam" },
+    { "mn", "Mongolian" },
+    { "mni", "Manipuri" },
+    { "moh", "Mohawk" },
+    { "mr", "Marathi" },
+    { "ms", "Malay" },
+    { "mt", "Maltese" },
+    { "my", "Burmese" },
+    { "nb", "NOR" }, /* Norwegian Bokmål */
+    { "ne", "Nepali" },
+    { "nic", "Ibibio" },
+    { "nl", "Dutch" },
+    { "nn", "NON" }, /* Norwegian Nynorsk */
+    { "no", "Norwegian" },
+    { "nso", "Northern Sotho" },
+    { "nso", "Sepedi" },
+    { "oc", "Occitan" },
+    { "om", "Oromo" },
+    { "or", "Oriya" },
+    { "pa", "Punjabi" },
+    { "pap", "Papiamentu" },
+    { "pl", "Polish" },
+    { "prs", "Dari" },
+    { "ps", "Pashto" },
+    { "pt", "Portuguese" },
+    { "qu", "Quechua" },
+    { "qut", "K'iche'" },
+    { "rm", "Romansh" },
+    { "ro", "Romanian" },
+    { "ru", "Russian" },
+    { "rw", "Kinyarwanda" },
+    { "sa", "Sanskrit" },
+    { "sah", "Yakut" },
+    { "sd", "Sindhi" },
+    { "se", "Sami (Northern)" },
+    { "se", "Northern Sami" },
+    { "si", "Sinhalese" },
+    { "sk", "Slovak" },
+    { "sl", "Slovenian" },
+    { "sma", "Sami (Southern)" },
+    { "sma", "Southern Sami" },
+    { "smj", "Sami (Lule)" },
+    { "smj", "Lule Sami" },
+    { "smn", "Sami (Inari)" },
+    { "smn", "Inari Sami" },
+    { "sms", "Sami (Skolt)" },
+    { "sms", "Skolt Sami" },
+    { "so", "Somali" },
+    { "sq", "Albanian" },
+    { "sr", "Serbian (Latin)" },
+    { "sr@cyrillic", "SRB" }, /* Serbian (Cyrillic) */
+    { "sw", "Swahili" },
+    { "syr", "Syriac" },
+    { "ta", "Tamil" },
+    { "te", "Telugu" },
+    { "tg", "Tajik" },
+    { "th", "Thai" },
+    { "ti", "Tigrinya" },
+    { "tk", "Turkmen" },
+    { "tl", "Filipino" },
+    { "tn", "Tswana" },
+    { "tr", "Turkish" },
+    { "ts", "Tsonga" },
+    { "tt", "Tatar" },
+    { "ug", "Uighur" },
+    { "uk", "Ukrainian" },
+    { "ur", "Urdu" },
+    { "uz", "Uzbek" },
+    { "uz", "Uzbek (Latin)" },
+    { "uz@cyrillic", "Uzbek (Cyrillic)" },
+    { "ve", "Venda" },
+    { "vi", "Vietnamese" },
+    { "wen", "Sorbian" },
+    { "wo", "Wolof" },
+    { "xh", "Xhosa" },
+    { "yi", "Yiddish" },
+    { "yo", "Yoruba" },
+    { "zh", "Chinese" },
+    { "zu", "Zulu" }
+  };
+
+/* Table from ISO 3166 country code to English name.
+   Keep in sync with the gl_locale_name_from_win32_LANGID function in
+   localename.c!  */
+static const struct table_entry country_table[] =
+  {
+    { "AE", "U.A.E." },
+    { "AF", "Afghanistan" },
+    { "AL", "Albania" },
+    { "AM", "Armenia" },
+    { "AN", "Netherlands Antilles" },
+    { "AR", "Argentina" },
+    { "AT", "Austria" },
+    { "AU", "Australia" },
+    { "AZ", "Azerbaijan" },
+    { "BA", "Bosnia and Herzegovina" },
+    { "BD", "Bangladesh" },
+    { "BE", "Belgium" },
+    { "BG", "Bulgaria" },
+    { "BH", "Bahrain" },
+    { "BN", "Brunei Darussalam" },
+    { "BO", "Bolivia" },
+    { "BR", "Brazil" },
+    { "BT", "Bhutan" },
+    { "BY", "Belarus" },
+    { "BZ", "Belize" },
+    { "CA", "Canada" },
+    { "CG", "Congo" },
+    { "CH", "Switzerland" },
+    { "CI", "Cote d'Ivoire" },
+    { "CL", "Chile" },
+    { "CM", "Cameroon" },
+    { "CN", "People's Republic of China" },
+    { "CO", "Colombia" },
+    { "CR", "Costa Rica" },
+    { "CS", "Serbia and Montenegro" },
+    { "CZ", "Czech Republic" },
+    { "DE", "Germany" },
+    { "DK", "Denmark" },
+    { "DO", "Dominican Republic" },
+    { "DZ", "Algeria" },
+    { "EC", "Ecuador" },
+    { "EE", "Estonia" },
+    { "EG", "Egypt" },
+    { "ER", "Eritrea" },
+    { "ES", "Spain" },
+    { "ET", "Ethiopia" },
+    { "FI", "Finland" },
+    { "FO", "Faroe Islands" },
+    { "FR", "France" },
+    { "GB", "United Kingdom" },
+    { "GD", "Caribbean" },
+    { "GE", "Georgia" },
+    { "GL", "Greenland" },
+    { "GR", "Greece" },
+    { "GT", "Guatemala" },
+    { "HK", "Hong Kong" },
+    { "HK", "Hong Kong S.A.R." },
+    { "HN", "Honduras" },
+    { "HR", "Croatia" },
+    { "HT", "Haiti" },
+    { "HU", "Hungary" },
+    { "ID", "Indonesia" },
+    { "IE", "Ireland" },
+    { "IL", "Israel" },
+    { "IN", "India" },
+    { "IQ", "Iraq" },
+    { "IR", "Iran" },
+    { "IS", "Iceland" },
+    { "IT", "Italy" },
+    { "JM", "Jamaica" },
+    { "JO", "Jordan" },
+    { "JP", "Japan" },
+    { "KE", "Kenya" },
+    { "KG", "Kyrgyzstan" },
+    { "KH", "Cambodia" },
+    { "KR", "South Korea" },
+    { "KW", "Kuwait" },
+    { "KZ", "Kazakhstan" },
+    { "LA", "Laos" },
+    { "LB", "Lebanon" },
+    { "LI", "Liechtenstein" },
+    { "LK", "Sri Lanka" },
+    { "LT", "Lithuania" },
+    { "LU", "Luxembourg" },
+    { "LV", "Latvia" },
+    { "LY", "Libya" },
+    { "MA", "Morocco" },
+    { "MC", "Principality of Monaco" },
+    { "MD", "Moldava" },
+    { "MD", "Moldova" },
+    { "ME", "Montenegro" },
+    { "MK", "Former Yugoslav Republic of Macedonia" },
+    { "ML", "Mali" },
+    { "MM", "Myanmar" },
+    { "MN", "Mongolia" },
+    { "MO", "Macau S.A.R." },
+    { "MT", "Malta" },
+    { "MV", "Maldives" },
+    { "MX", "Mexico" },
+    { "MY", "Malaysia" },
+    { "NG", "Nigeria" },
+    { "NI", "Nicaragua" },
+    { "NL", "Netherlands" },
+    { "NO", "Norway" },
+    { "NP", "Nepal" },
+    { "NZ", "New Zealand" },
+    { "OM", "Oman" },
+    { "PA", "Panama" },
+    { "PE", "Peru" },
+    { "PH", "Philippines" },
+    { "PK", "Islamic Republic of Pakistan" },
+    { "PL", "Poland" },
+    { "PR", "Puerto Rico" },
+    { "PT", "Portugal" },
+    { "PY", "Paraguay" },
+    { "QA", "Qatar" },
+    { "RE", "Reunion" },
+    { "RO", "Romania" },
+    { "RS", "Serbia" },
+    { "RU", "Russia" },
+    { "RW", "Rwanda" },
+    { "SA", "Saudi Arabia" },
+    { "SE", "Sweden" },
+    { "SG", "Singapore" },
+    { "SI", "Slovenia" },
+    { "SK", "Slovak" },
+    { "SN", "Senegal" },
+    { "SO", "Somalia" },
+    { "SR", "Suriname" },
+    { "SV", "El Salvador" },
+    { "SY", "Syria" },
+    { "TH", "Thailand" },
+    { "TJ", "Tajikistan" },
+    { "TM", "Turkmenistan" },
+    { "TN", "Tunisia" },
+    { "TR", "Turkey" },
+    { "TT", "Trinidad and Tobago" },
+    { "TW", "Taiwan" },
+    { "TZ", "Tanzania" },
+    { "UA", "Ukraine" },
+    { "US", "United States" },
+    { "UY", "Uruguay" },
+    { "VA", "Vatican" },
+    { "VE", "Venezuela" },
+    { "VN", "Viet Nam" },
+    { "YE", "Yemen" },
+    { "ZA", "South Africa" },
+    { "ZW", "Zimbabwe" }
+  };
+
+/* Given a string STRING, find the set of indices i such that TABLE[i].code is
+   the given STRING.  It is a range [lo,hi-1].  */
+typedef struct { size_t lo; size_t hi; } range_t;
+static void
+search (const struct table_entry *table, size_t table_size, const char *string,
+        range_t *result)
+{
+  /* The table is sorted.  Perform a binary search.  */
+  size_t hi = table_size;
+  size_t lo = 0;
+  while (lo < hi)
+    {
+      /* Invariant:
+         for i < lo, strcmp (table[i].code, string) < 0,
+         for i >= hi, strcmp (table[i].code, string) > 0.  */
+      size_t mid = (hi + lo) >> 1; /* >= lo, < hi */
+      int cmp = strcmp (table[mid].code, string);
+      if (cmp < 0)
+        lo = mid + 1;
+      else if (cmp > 0)
+        hi = mid;
+      else
+        {
+          /* Found an i with
+               strcmp (language_table[i].code, string) == 0.
+             Find the entire interval of such i.  */
+          {
+            size_t i;
+
+            for (i = mid; i > lo; )
+              {
+                i--;
+                if (strcmp (table[i].code, string) < 0)
+                  {
+                    lo = i + 1;
+                    break;
+                  }
+              }
+          }
+          {
+            size_t i;
+
+            for (i = mid; i < hi; i++)
+              {
+                if (strcmp (table[i].code, string) > 0)
+                  {
+                    hi = i;
+                    break;
+                  }
+              }
+          }
+          /* The set of i with
+               strcmp (language_table[i].code, string) == 0
+             is the interval [lo, hi-1].  */
+          break;
+        }
+    }
+  result->lo = lo;
+  result->hi = hi;
+}
+
+/* Like setlocale, but accept also locale names in the form ll or ll_CC,
+   where ll is an ISO 639 language code and CC is an ISO 3166 country code.  */
+static char *
+setlocale_unixlike (int category, const char *locale)
+{
+  char *result;
+  char llCC_buf[64];
+  char ll_buf[64];
+  char CC_buf[64];
+
+  /* First, try setlocale with the original argument unchanged.  */
+  result = setlocale (category, locale);
+  if (result != NULL)
+    return result;
+
+  /* Otherwise, assume the argument is in the form
+       language[_territory][.codeset][@modifier]
+     and try to map it using the tables.  */
+  if (strlen (locale) < sizeof (llCC_buf))
+    {
+      /* Second try: Remove the codeset part.  */
+      {
+        const char *p = locale;
+        char *q = llCC_buf;
+
+        /* Copy the part before the dot.  */
+        for (; *p != '\0' && *p != '.'; p++, q++)
+          *q = *p;
+        if (*p == '.')
+          /* Skip the part up to the '@', if any.  */
+          for (; *p != '\0' && *p != '@'; p++)
+            ;
+        /* Copy the part starting with '@', if any.  */
+        for (; *p != '\0'; p++, q++)
+          *q = *p;
+        *q = '\0';
+      }
+      /* llCC_buf now contains
+           language[_territory][@modifier]
+       */
+      if (strcmp (llCC_buf, locale) != 0)
+        {
+          result = setlocale (category, llCC_buf);
+          if (result != NULL)
+            return result;
+        }
+      /* Look it up in language_table.  */
+      {
+        range_t range;
+        size_t i;
+
+        search (language_table,
+                sizeof (language_table) / sizeof (language_table[0]),
+                llCC_buf,
+                &range);
+
+        for (i = range.lo; i < range.hi; i++)
+          {
+            /* Try the replacement in language_table[i].  */
+            result = setlocale (category, language_table[i].english);
+            if (result != NULL)
+              return result;
+          }
+      }
+      /* Split language[_territory][@modifier]
+         into  ll_buf = language[@modifier]
+         and   CC_buf = territory
+       */
+      {
+        const char *underscore = strchr (llCC_buf, '_');
+        if (underscore != NULL)
+          {
+            const char *territory_start = underscore + 1;
+            const char *territory_end = strchr (territory_start, '@');
+            if (territory_end == NULL)
+              territory_end = territory_start + strlen (territory_start);
+
+            memcpy (ll_buf, llCC_buf, underscore - llCC_buf);
+            strcpy (ll_buf + (underscore - llCC_buf), territory_end);
+
+            memcpy (CC_buf, territory_start, territory_end - territory_start);
+            CC_buf[territory_end - territory_start] = '\0';
+
+            {
+              /* Look up ll_buf in language_table
+                 and CC_buf in country_table.  */
+              range_t language_range;
+
+              search (language_table,
+                      sizeof (language_table) / sizeof (language_table[0]),
+                      ll_buf,
+                      &language_range);
+              if (language_range.lo < language_range.hi)
+                {
+                  range_t country_range;
+
+                  search (country_table,
+                          sizeof (country_table) / sizeof (country_table[0]),
+                          CC_buf,
+                          &country_range);
+                  if (country_range.lo < country_range.hi)
+                    {
+                      size_t i;
+                      size_t j;
+
+                      for (i = language_range.lo; i < language_range.hi; i++)
+                        for (j = country_range.lo; j < country_range.hi; j++)
+                          {
+                            /* Concatenate the replacements.  */
+                            const char *part1 = language_table[i].english;
+                            size_t part1_len = strlen (part1);
+                            const char *part2 = country_table[j].english;
+                            size_t part2_len = strlen (part2) + 1;
+                            char buf[64+64];
+
+                            if (!(part1_len + 1 + part2_len <= sizeof (buf)))
+                              abort ();
+                            memcpy (buf, part1, part1_len);
+                            buf[part1_len] = '_';
+                            memcpy (buf + part1_len + 1, part2, part2_len);
+
+                            /* Try the concatenated replacements.  */
+                            result = setlocale (category, buf);
+                            if (result != NULL)
+                              return result;
+                          }
+                    }
+
+                  /* Try omitting the country entirely.  This may set a locale
+                     corresponding to the wrong country, but is better than
+                     failing entirely.  */
+                  {
+                    size_t i;
+
+                    for (i = language_range.lo; i < language_range.hi; i++)
+                      {
+                        /* Try only the language replacement.  */
+                        result =
+                          setlocale (category, language_table[i].english);
+                        if (result != NULL)
+                          return result;
+                      }
+                  }
+                }
+            }
+          }
+      }
+    }
+
+  /* Failed.  */
+  return NULL;
+}
+
+# else
+#  define setlocale_unixlike setlocale
+# endif
+
+# if LC_MESSAGES == 1729
+
+/* The system does not store an LC_MESSAGES locale category.  Do it here.  */
+static char lc_messages_name[64] = "C";
+
+/* Like setlocale, but support also LC_MESSAGES.  */
+static char *
+setlocale_single (int category, const char *locale)
+{
+  if (category == LC_MESSAGES)
+    {
+      if (locale != NULL)
+        {
+          lc_messages_name[sizeof (lc_messages_name) - 1] = '\0';
+          strncpy (lc_messages_name, locale, sizeof (lc_messages_name) - 1);
+        }
+      return lc_messages_name;
+    }
+  else
+    return setlocale_unixlike (category, locale);
+}
+
+# else
+#  define setlocale_single setlocale_unixlike
+# endif
+
+char *
+rpl_setlocale (int category, const char *locale)
+{
+  if (locale != NULL && locale[0] == '\0')
+    {
+      /* A request to the set the current locale to the default locale.  */
+      if (category == LC_ALL)
+        {
+          /* Set LC_CTYPE first.  Then the other categories.  */
+          static int const categories[] =
+            {
+              LC_NUMERIC,
+              LC_TIME,
+              LC_COLLATE,
+              LC_MONETARY,
+              LC_MESSAGES
+            };
+          char *saved_locale;
+          const char *base_name;
+          unsigned int i;
+
+          /* Back up the old locale, in case one of the steps fails.  */
+          saved_locale = setlocale (LC_ALL, NULL);
+          if (saved_locale == NULL)
+            return NULL;
+          saved_locale = strdup (saved_locale);
+          if (saved_locale == NULL)
+            return NULL;
+
+          /* Set LC_CTYPE category.  Set all other categories (except possibly
+             LC_MESSAGES) to the same value in the same call; this is likely to
+             save calls.  */
+          base_name =
+            gl_locale_name_environ (LC_CTYPE, category_to_name (LC_CTYPE));
+          if (base_name == NULL)
+            base_name = gl_locale_name_default ();
+
+          if (setlocale_unixlike (LC_ALL, base_name) == NULL)
+            goto fail;
+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+          /* On native Windows, setlocale(LC_ALL,...) may succeed but set the
+             LC_CTYPE category to an invalid value ("C") when it does not
+             support the specified encoding.  Report a failure instead.  */
+          if (strchr (base_name, '.') != NULL
+              && strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
+            goto fail;
+# endif
+
+          for (i = 0; i < sizeof (categories) / sizeof (categories[0]); i++)
+            {
+              int cat = categories[i];
+              const char *name;
+
+              name = gl_locale_name_environ (cat, category_to_name (cat));
+              if (name == NULL)
+                name = gl_locale_name_default ();
+
+              /* If name is the same as base_name, it has already been set
+                 through the setlocale call before the loop.  */
+              if (strcmp (name, base_name) != 0
+# if LC_MESSAGES == 1729
+                  || cat == LC_MESSAGES
+# endif
+                 )
+                if (setlocale_single (cat, name) == NULL)
+                  goto fail;
+            }
+
+          /* All steps were successful.  */
+          free (saved_locale);
+          return setlocale (LC_ALL, NULL);
+
+        fail:
+          if (saved_locale[0] != '\0') /* don't risk an endless recursion */
+            setlocale (LC_ALL, saved_locale);
+          free (saved_locale);
+          return NULL;
+        }
+      else
+        {
+          const char *name =
+            gl_locale_name_environ (category, category_to_name (category));
+          if (name == NULL)
+            name = gl_locale_name_default ();
+
+          return setlocale_single (category, name);
+        }
+    }
+  else
+    {
+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+      if (category == LC_ALL && locale != NULL && strchr (locale, '.') != NULL)
+        {
+          char *saved_locale;
+
+          /* Back up the old locale.  */
+          saved_locale = setlocale (LC_ALL, NULL);
+          if (saved_locale == NULL)
+            return NULL;
+          saved_locale = strdup (saved_locale);
+          if (saved_locale == NULL)
+            return NULL;
+
+          if (setlocale_unixlike (LC_ALL, locale) == NULL)
+            {
+              free (saved_locale);
+              return NULL;
+            }
+
+          /* On native Windows, setlocale(LC_ALL,...) may succeed but set the
+             LC_CTYPE category to an invalid value ("C") when it does not
+             support the specified encoding.  Report a failure instead.  */
+          if (strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
+            {
+              if (saved_locale[0] != '\0') /* don't risk an endless recursion */
+                setlocale (LC_ALL, saved_locale);
+              free (saved_locale);
+              return NULL;
+            }
+
+          /* It was really successful.  */
+          free (saved_locale);
+          return setlocale (LC_ALL, NULL);
+        }
+      else
+# endif
+        return setlocale_single (category, locale);
+    }
+}
+
+#endif
--- a/lib/sigaction.c
+++ b/lib/sigaction.c
@@ -142,10 +142,10 @@
       return -1;
     }
 
-  #ifdef SIGABRT_COMPAT
+#ifdef SIGABRT_COMPAT
   if (sig == SIGABRT_COMPAT)
     sig = SIGABRT;
-  #endif
+#endif
 
   /* POSIX requires sigaction() to be async-signal-safe.  In other
      words, if an asynchronous signal can occur while we are anywhere
--- a/lib/signal.in.h
+++ b/lib/signal.in.h
@@ -50,14 +50,20 @@
    '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@
+# if !GNULIB_defined_sig_atomic_t
 typedef int rpl_sig_atomic_t;
-# undef sig_atomic_t
-# define sig_atomic_t rpl_sig_atomic_t
+#  undef sig_atomic_t
+#  define sig_atomic_t rpl_sig_atomic_t
+#  define GNULIB_defined_sig_atomic_t 1
+# endif
 #endif
 
 /* A set or mask of signals.  */
 #if !@HAVE_SIGSET_T@
+# if !GNULIB_defined_sigset_t
 typedef unsigned int sigset_t;
+#  define GNULIB_defined_sigset_t 1
+# endif
 #endif
 
 
@@ -89,7 +95,10 @@
 #  endif
 
 /* This code supports only 32 signals.  */
+#  if !GNULIB_defined_verify_NSIG_constraint
 typedef int verify_NSIG_constraint[NSIG <= 32 ? 1 : -1];
+#   define GNULIB_defined_verify_NSIG_constraint 1
+#  endif
 
 # endif
 
@@ -184,7 +193,10 @@
 # ifdef __cplusplus
 extern "C" {
 # endif
+# if !GNULIB_defined_function_taking_int_returning_void_t
 typedef void (*_gl_function_taking_int_returning_void_t) (int);
+#  define GNULIB_defined_function_taking_int_returning_void_t 1
+# endif
 # ifdef __cplusplus
 }
 # endif
@@ -258,6 +270,9 @@
 # if !@HAVE_SIGACTION@
 
 #  if !@HAVE_SIGINFO_T@
+
+#   if !GNULIB_defined_siginfo_types
+
 /* Present to allow compilation, but unsupported by gnulib.  */
 union sigval
 {
@@ -279,11 +294,17 @@
   union sigval si_value;
 };
 typedef struct siginfo_t siginfo_t;
+
+#    define GNULIB_defined_siginfo_types 1
+#   endif
+
 #  endif /* !@HAVE_SIGINFO_T@ */
 
 /* We assume that platforms which lack the sigaction() function also lack
    the 'struct sigaction' type, and vice versa.  */
 
+#  if !GNULIB_defined_struct_sigaction
+
 struct sigaction
 {
   union
@@ -299,12 +320,15 @@
   /* Not all POSIX flags are supported.  */
   int sa_flags;
 };
-#  define sa_handler _sa_func._sa_handler
-#  define sa_sigaction _sa_func._sa_sigaction
+#   define sa_handler _sa_func._sa_handler
+#   define sa_sigaction _sa_func._sa_sigaction
 /* Unsupported flags are not present.  */
-#  define SA_RESETHAND 1
-#  define SA_NODEFER 2
-#  define SA_RESTART 4
+#   define SA_RESETHAND 1
+#   define SA_NODEFER 2
+#   define SA_RESTART 4
+
+#   define GNULIB_defined_struct_sigaction 1
+#  endif
 
 _GL_FUNCDECL_SYS (sigaction, int, (int, const struct sigaction *restrict,
                                    struct sigaction *restrict));
--- a/lib/sigpipe-die.h
+++ b/lib/sigpipe-die.h
@@ -47,19 +47,15 @@
 #endif
 
 
-# ifndef __attribute__
-#  if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
-#   define __attribute__(x)
-#  endif
-# endif
-
-# ifndef ATTRIBUTE_NORETURN
-#  define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
+# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)
+#  define _GL_ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
+# else
+#  define _GL_ATTRIBUTE_NORETURN /* empty */
 # endif
 
 /* Emit an error message indicating a SIGPIPE signal, and terminate the
    process with an error code.  */
-extern void sigpipe_die (void) ATTRIBUTE_NORETURN;
+extern void sigpipe_die (void) _GL_ATTRIBUTE_NORETURN;
 
 /* Install a SIGPIPE handler that invokes PREPARE_DIE and then emits an
    error message and exits.  PREPARE_DIE may be NULL, meaning a no-op.  */
--- a/lib/spawn.in.h
+++ b/lib/spawn.in.h
@@ -83,6 +83,7 @@
 # define posix_spawnattr_t rpl_posix_spawnattr_t
 #endif
 #if @REPLACE_POSIX_SPAWN@ || !@HAVE_POSIX_SPAWNATTR_T@
+# if !GNULIB_defined_posix_spawnattr_t
 typedef struct
 {
   short int _flags;
@@ -93,6 +94,8 @@
   int _policy;
   int __pad[16];
 } posix_spawnattr_t;
+#  define GNULIB_defined_posix_spawnattr_t 1
+# endif
 #endif
 
 
@@ -102,6 +105,7 @@
 # define posix_spawn_file_actions_t rpl_posix_spawn_file_actions_t
 #endif
 #if @REPLACE_POSIX_SPAWN@ || !@HAVE_POSIX_SPAWN_FILE_ACTIONS_T@
+# if !GNULIB_defined_posix_spawn_file_actions_t
 typedef struct
 {
   int _allocated;
@@ -109,6 +113,8 @@
   struct __spawn_action *_actions;
   int __pad[16];
 } posix_spawn_file_actions_t;
+#  define GNULIB_defined_posix_spawn_file_actions_t 1
+# endif
 #endif
 
 
@@ -146,6 +152,7 @@
     | POSIX_SPAWN_SETSCHEDULER                                            \
     | (POSIX_SPAWN_SETSCHEDULER > 0 ? POSIX_SPAWN_SETSCHEDULER - 1 : 0))  \
    + 1)
+#if !GNULIB_defined_verify_POSIX_SPAWN_USEVFORK_no_overlap
 typedef int verify_POSIX_SPAWN_USEVFORK_no_overlap
             [(((POSIX_SPAWN_RESETIDS | POSIX_SPAWN_SETPGROUP
                 | POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETSIGMASK
@@ -153,6 +160,8 @@
                & POSIX_SPAWN_USEVFORK)
               == 0)
              ? 1 : -1];
+# define GNULIB_defined_verify_POSIX_SPAWN_USEVFORK_no_overlap 1
+#endif
 
 
 #if @GNULIB_POSIX_SPAWN@
--- a/lib/stat.c
+++ b/lib/stat.c
@@ -37,6 +37,7 @@
 #include <limits.h>
 #include <stdbool.h>
 #include <string.h>
+#include "dosname.h"
 
 /* Store information about NAME into ST.  Work around bugs with
    trailing slashes.  Mingw has other bugs (such as st_ino always
--- a/lib/stdint.in.h
+++ b/lib/stdint.in.h
@@ -108,6 +108,8 @@
         warnings in the signed case.  */ \
      ((((zero) + 1) << ((bits) ? (bits) - 1 - (signed) : 0)) - 1) * 2 + 1)
 
+#if !GNULIB_defined_stdint_types
+
 /* 7.18.1.1. Exact-width integer types */
 
 /* Here we assume a standard architecture where the hardware integer
@@ -296,6 +298,9 @@
 typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t)
                                 ? 1 : -1];
 
+#define GNULIB_defined_stdint_types 1
+#endif /* !GNULIB_defined_stdint_types */
+
 /* 7.18.2. Limits of specified-width integer types */
 
 #if ! defined __cplusplus || defined __STDC_LIMIT_MACROS
@@ -492,7 +497,12 @@
    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)
+#if @HAVE_WCHAR_H@ && ! (defined WCHAR_MIN && defined WCHAR_MAX)
+  /* 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>
 # define _GL_JUST_INCLUDE_SYSTEM_WCHAR_H
 # include <wchar.h>
 # undef _GL_JUST_INCLUDE_SYSTEM_WCHAR_H
--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
@@ -56,18 +56,37 @@
    and eglibc 2.11.2.  */
 #include <sys/types.h>
 
-#ifndef __attribute__
 /* The __attribute__ feature is available in gcc versions 2.5 and later.
    The __-protected variants of the attributes 'format' and 'printf' are
    accepted by gcc versions 2.6.4 (effectively 2.7) and later.
-   We enable __attribute__ only if these are supported too, because
+   We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because
    gnulib and libintl do '#define printf __printf__' when they override
    the 'printf' function.  */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
-#  define __attribute__(Spec)   /* empty */
-# endif
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
+# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
+#else
+# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
 #endif
 
+/* _GL_ATTRIBUTE_FORMAT_PRINTF
+   indicates to GCC that the function takes a format string and arguments,
+   where the format string directives are the ones standardized by ISO C99
+   and POSIX.  */
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
+# define _GL_ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \
+   _GL_ATTRIBUTE_FORMAT ((__gnu_printf__, formatstring_parameter, first_argument))
+#else
+# define _GL_ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \
+   _GL_ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument))
+#endif
+
+/* _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM is like _GL_ATTRIBUTE_FORMAT_PRINTF,
+   except that it indicates to GCC that the supported format string directives
+   are the ones of the system printf(), rather than the ones standardized by
+   ISO C99 and POSIX.  */
+#define _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM(formatstring_parameter, first_argument) \
+  _GL_ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument))
+
 /* Solaris 10 declares renameat in <unistd.h>, not in <stdio.h>.  */
 /* But in any case avoid namespace pollution on glibc systems.  */
 #if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && defined __sun \
@@ -93,13 +112,13 @@
 #   define dprintf rpl_dprintf
 #  endif
 _GL_FUNCDECL_RPL (dprintf, int, (int fd, const char *format, ...)
-                                __attribute__ ((__format__ (__printf__, 2, 3)))
+                                _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
                                 _GL_ARG_NONNULL ((2)));
 _GL_CXXALIAS_RPL (dprintf, int, (int fd, const char *format, ...));
 # else
 #  if !@HAVE_DPRINTF@
 _GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *format, ...)
-                                __attribute__ ((__format__ (__printf__, 2, 3)))
+                                _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
                                 _GL_ARG_NONNULL ((2)));
 #  endif
 _GL_CXXALIAS_SYS (dprintf, int, (int fd, const char *format, ...));
@@ -189,9 +208,15 @@
 #   define fprintf rpl_fprintf
 #  endif
 #  define GNULIB_overrides_fprintf 1
+#  if @GNULIB_FPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
 _GL_FUNCDECL_RPL (fprintf, int, (FILE *fp, const char *format, ...)
-                                __attribute__ ((__format__ (__printf__, 2, 3)))
+                                _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
                                 _GL_ARG_NONNULL ((1, 2)));
+#  else
+_GL_FUNCDECL_RPL (fprintf, int, (FILE *fp, const char *format, ...)
+                                _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 3)
+                                _GL_ARG_NONNULL ((1, 2)));
+#  endif
 _GL_CXXALIAS_RPL (fprintf, int, (FILE *fp, const char *format, ...));
 # else
 _GL_CXXALIAS_SYS (fprintf, int, (FILE *fp, const char *format, ...));
@@ -367,17 +392,20 @@
    /* Provide an fseek function that is consistent with fseeko.  */
    /* In order to avoid that fseek gets defined as a macro here, the
       developer can request the 'fseek' module.  */
-#  undef fseek
-#  define fseek rpl_fseek
+#  if !GNULIB_defined_fseek_function
+#   undef fseek
+#   define fseek rpl_fseek
 static inline int _GL_ARG_NONNULL ((1))
 rpl_fseek (FILE *fp, long offset, int whence)
 {
-#  if @REPLACE_FSEEKO@
+#   if @REPLACE_FSEEKO@
   return rpl_fseeko (fp, offset, whence);
-#  else
+#   else
   return fseeko (fp, offset, whence);
+#   endif
+}
+#   define GNULIB_defined_fseek_function 1
 #  endif
-}
 # endif
 #elif defined GNULIB_POSIXCHECK
 # define _GL_FSEEK_WARN /* Category 1, above.  */
@@ -442,17 +470,20 @@
    /* Provide an ftell function that is consistent with ftello.  */
    /* In order to avoid that ftell gets defined as a macro here, the
       developer can request the 'ftell' module.  */
-#  undef ftell
-#  define ftell rpl_ftell
+#  if !GNULIB_defined_ftell_function
+#   undef ftell
+#   define ftell rpl_ftell
 static inline long _GL_ARG_NONNULL ((1))
 rpl_ftell (FILE *f)
 {
-#  if @REPLACE_FTELLO@
+#   if @REPLACE_FTELLO@
   return rpl_ftello (f);
-#  else
+#   else
   return ftello (f);
+#   endif
+}
+#   define GNULIB_defined_ftell_function 1
 #  endif
-}
 # endif
 #elif defined GNULIB_POSIXCHECK
 # define _GL_FTELL_WARN /* Category 1, above.  */
@@ -488,6 +519,23 @@
 # else
 _GL_CXXALIAS_SYS (fwrite, size_t,
                   (const void *ptr, size_t s, size_t n, FILE *stream));
+
+/* Work around glibc bug 11959
+   <http://sources.redhat.com/bugzilla/show_bug.cgi?id=11959>,
+   which sometimes causes an unwanted diagnostic for fwrite calls.
+   This affects only function declaration attributes, so it's not
+   needed for C++.  */
+#  if !defined __cplusplus && 0 < __USE_FORTIFY_LEVEL
+static inline size_t _GL_ARG_NONNULL ((1, 4))
+rpl_fwrite (const void *ptr, size_t s, size_t n, FILE *stream)
+{
+  size_t r = fwrite (ptr, s, n, stream);
+  (void) r;
+  return r;
+}
+#   undef fwrite
+#   define fwrite rpl_fwrite
+#  endif
 # endif
 _GL_CXXALIASWARN (fwrite);
 #endif
@@ -581,7 +629,7 @@
 #  endif
 _GL_FUNCDECL_RPL (obstack_printf, int,
                   (struct obstack *obs, const char *format, ...)
-                  __attribute__ ((__format__ (__printf__, 2, 3)))
+                  _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
                   _GL_ARG_NONNULL ((1, 2)));
 _GL_CXXALIAS_RPL (obstack_printf, int,
                   (struct obstack *obs, const char *format, ...));
@@ -589,7 +637,7 @@
 #  if !@HAVE_DECL_OBSTACK_PRINTF@
 _GL_FUNCDECL_SYS (obstack_printf, int,
                   (struct obstack *obs, const char *format, ...)
-                  __attribute__ ((__format__ (__printf__, 2, 3)))
+                  _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
                   _GL_ARG_NONNULL ((1, 2)));
 #  endif
 _GL_CXXALIAS_SYS (obstack_printf, int,
@@ -602,7 +650,7 @@
 #  endif
 _GL_FUNCDECL_RPL (obstack_vprintf, int,
                   (struct obstack *obs, const char *format, va_list args)
-                  __attribute__ ((__format__ (__printf__, 2, 0)))
+                  _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
                   _GL_ARG_NONNULL ((1, 2)));
 _GL_CXXALIAS_RPL (obstack_vprintf, int,
                   (struct obstack *obs, const char *format, va_list args));
@@ -610,7 +658,7 @@
 #  if !@HAVE_DECL_OBSTACK_PRINTF@
 _GL_FUNCDECL_SYS (obstack_vprintf, int,
                   (struct obstack *obs, const char *format, va_list args)
-                  __attribute__ ((__format__ (__printf__, 2, 0)))
+                  _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
                   _GL_ARG_NONNULL ((1, 2)));
 #  endif
 _GL_CXXALIAS_SYS (obstack_vprintf, int,
@@ -669,12 +717,21 @@
 /* Don't break __attribute__((format(printf,M,N))).  */
 #    define printf __printf__
 #   endif
+#   if @GNULIB_PRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
 _GL_FUNCDECL_RPL_1 (__printf__, int,
                     (const char *format, ...)
                     __asm__ (@ASM_SYMBOL_PREFIX@
                              _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf))
-                    __attribute__ ((__format__ (__printf__, 1, 2)))
+                    _GL_ATTRIBUTE_FORMAT_PRINTF (1, 2)
                     _GL_ARG_NONNULL ((1)));
+#   else
+_GL_FUNCDECL_RPL_1 (__printf__, int,
+                    (const char *format, ...)
+                    __asm__ (@ASM_SYMBOL_PREFIX@
+                             _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf))
+                    _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 2)
+                    _GL_ARG_NONNULL ((1)));
+#   endif
 _GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...));
 #  else
 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
@@ -682,7 +739,7 @@
 #   endif
 _GL_FUNCDECL_RPL (printf, int,
                   (const char *format, ...)
-                  __attribute__ ((__format__ (__printf__, 1, 2)))
+                  _GL_ATTRIBUTE_FORMAT_PRINTF (1, 2)
                   _GL_ARG_NONNULL ((1)));
 _GL_CXXALIAS_RPL (printf, int, (const char *format, ...));
 #  endif
@@ -822,7 +879,7 @@
 #  endif
 _GL_FUNCDECL_RPL (snprintf, int,
                   (char *str, size_t size, const char *format, ...)
-                  __attribute__ ((__format__ (__printf__, 3, 4)))
+                  _GL_ATTRIBUTE_FORMAT_PRINTF (3, 4)
                   _GL_ARG_NONNULL ((3)));
 _GL_CXXALIAS_RPL (snprintf, int,
                   (char *str, size_t size, const char *format, ...));
@@ -830,7 +887,7 @@
 #  if !@HAVE_DECL_SNPRINTF@
 _GL_FUNCDECL_SYS (snprintf, int,
                   (char *str, size_t size, const char *format, ...)
-                  __attribute__ ((__format__ (__printf__, 3, 4)))
+                  _GL_ATTRIBUTE_FORMAT_PRINTF (3, 4)
                   _GL_ARG_NONNULL ((3)));
 #  endif
 _GL_CXXALIAS_SYS (snprintf, int,
@@ -860,7 +917,7 @@
 #   define sprintf rpl_sprintf
 #  endif
 _GL_FUNCDECL_RPL (sprintf, int, (char *str, const char *format, ...)
-                                __attribute__ ((__format__ (__printf__, 2, 3)))
+                                _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
                                 _GL_ARG_NONNULL ((1, 2)));
 _GL_CXXALIAS_RPL (sprintf, int, (char *str, const char *format, ...));
 # else
@@ -905,7 +962,7 @@
 #  endif
 _GL_FUNCDECL_RPL (asprintf, int,
                   (char **result, const char *format, ...)
-                  __attribute__ ((__format__ (__printf__, 2, 3)))
+                  _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
                   _GL_ARG_NONNULL ((1, 2)));
 _GL_CXXALIAS_RPL (asprintf, int,
                   (char **result, const char *format, ...));
@@ -913,7 +970,7 @@
 #  if !@HAVE_VASPRINTF@
 _GL_FUNCDECL_SYS (asprintf, int,
                   (char **result, const char *format, ...)
-                  __attribute__ ((__format__ (__printf__, 2, 3)))
+                  _GL_ATTRIBUTE_FORMAT_PRINTF (2, 3)
                   _GL_ARG_NONNULL ((1, 2)));
 #  endif
 _GL_CXXALIAS_SYS (asprintf, int,
@@ -926,7 +983,7 @@
 #  endif
 _GL_FUNCDECL_RPL (vasprintf, int,
                   (char **result, const char *format, va_list args)
-                  __attribute__ ((__format__ (__printf__, 2, 0)))
+                  _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
                   _GL_ARG_NONNULL ((1, 2)));
 _GL_CXXALIAS_RPL (vasprintf, int,
                   (char **result, const char *format, va_list args));
@@ -934,7 +991,7 @@
 #  if !@HAVE_VASPRINTF@
 _GL_FUNCDECL_SYS (vasprintf, int,
                   (char **result, const char *format, va_list args)
-                  __attribute__ ((__format__ (__printf__, 2, 0)))
+                  _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
                   _GL_ARG_NONNULL ((1, 2)));
 #  endif
 _GL_CXXALIAS_SYS (vasprintf, int,
@@ -949,13 +1006,13 @@
 #   define vdprintf rpl_vdprintf
 #  endif
 _GL_FUNCDECL_RPL (vdprintf, int, (int fd, const char *format, va_list args)
-                                 __attribute__ ((__format__ (__printf__, 2, 0)))
+                                 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
                                  _GL_ARG_NONNULL ((2)));
 _GL_CXXALIAS_RPL (vdprintf, int, (int fd, const char *format, va_list args));
 # else
 #  if !@HAVE_VDPRINTF@
 _GL_FUNCDECL_SYS (vdprintf, int, (int fd, const char *format, va_list args)
-                                 __attribute__ ((__format__ (__printf__, 2, 0)))
+                                 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
                                  _GL_ARG_NONNULL ((2)));
 #  endif
 /* Need to cast, because on Solaris, the third parameter will likely be
@@ -979,9 +1036,15 @@
 #   define vfprintf rpl_vfprintf
 #  endif
 #  define GNULIB_overrides_vfprintf 1
+#  if @GNULIB_VFPRINTF_POSIX@
 _GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args)
-                                 __attribute__ ((__format__ (__printf__, 2, 0)))
+                                 _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
                                  _GL_ARG_NONNULL ((1, 2)));
+#  else
+_GL_FUNCDECL_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args)
+                                 _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (2, 0)
+                                 _GL_ARG_NONNULL ((1, 2)));
+#  endif
 _GL_CXXALIAS_RPL (vfprintf, int, (FILE *fp, const char *format, va_list args));
 # else
 /* Need to cast, because on Solaris, the third parameter is
@@ -1009,9 +1072,15 @@
 #   define vprintf rpl_vprintf
 #  endif
 #  define GNULIB_overrides_vprintf 1
+#  if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VFPRINTF_POSIX@
 _GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args)
-                                __attribute__ ((__format__ (__printf__, 1, 0)))
+                                _GL_ATTRIBUTE_FORMAT_PRINTF (1, 0)
                                 _GL_ARG_NONNULL ((1)));
+#  else
+_GL_FUNCDECL_RPL (vprintf, int, (const char *format, va_list args)
+                                _GL_ATTRIBUTE_FORMAT_PRINTF_SYSTEM (1, 0)
+                                _GL_ARG_NONNULL ((1)));
+#  endif
 _GL_CXXALIAS_RPL (vprintf, int, (const char *format, va_list args));
 # else
 /* Need to cast, because on Solaris, the second parameter is
@@ -1038,7 +1107,7 @@
 #  endif
 _GL_FUNCDECL_RPL (vsnprintf, int,
                   (char *str, size_t size, const char *format, va_list args)
-                  __attribute__ ((__format__ (__printf__, 3, 0)))
+                  _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0)
                   _GL_ARG_NONNULL ((3)));
 _GL_CXXALIAS_RPL (vsnprintf, int,
                   (char *str, size_t size, const char *format, va_list args));
@@ -1046,7 +1115,7 @@
 #  if !@HAVE_DECL_VSNPRINTF@
 _GL_FUNCDECL_SYS (vsnprintf, int,
                   (char *str, size_t size, const char *format, va_list args)
-                  __attribute__ ((__format__ (__printf__, 3, 0)))
+                  _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0)
                   _GL_ARG_NONNULL ((3)));
 #  endif
 _GL_CXXALIAS_SYS (vsnprintf, int,
@@ -1068,7 +1137,7 @@
 #  endif
 _GL_FUNCDECL_RPL (vsprintf, int,
                   (char *str, const char *format, va_list args)
-                  __attribute__ ((__format__ (__printf__, 2, 0)))
+                  _GL_ATTRIBUTE_FORMAT_PRINTF (2, 0)
                   _GL_ARG_NONNULL ((1, 2)));
 _GL_CXXALIAS_RPL (vsprintf, int,
                   (char *str, const char *format, va_list args));
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -49,21 +49,23 @@
 # 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@
 
-#if !@HAVE_STRUCT_RANDOM_DATA@ || (@GNULIB_RANDOM_R@ && !@HAVE_RANDOM_R@) \
-    || defined GNULIB_POSIXCHECK
-# include <stdint.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 whenever we need
+   'struct random_data'.  */
+# if @HAVE_RANDOM_H@
+#  include <random.h>
+# endif
 
-#if !@HAVE_STRUCT_RANDOM_DATA@
+# if !@HAVE_STRUCT_RANDOM_DATA@ || !@HAVE_RANDOM_R@
+#  include <stdint.h>
+# endif
+
+# if !@HAVE_STRUCT_RANDOM_DATA@
 /* Define 'struct random_data'.
    But allow multiple gnulib generated <stdlib.h> replacements to coexist.  */
-# if !GNULIB_defined_struct_random_data
+#  if !GNULIB_defined_struct_random_data
 struct random_data
 {
   int32_t *fptr;                /* Front pointer.  */
@@ -74,7 +76,8 @@
   int rand_sep;                 /* Distance between front and rear.  */
   int32_t *end_ptr;             /* Pointer behind state table.  */
 };
-#  define GNULIB_defined_struct_random_data 1
+#   define GNULIB_defined_struct_random_data 1
+#  endif
 # endif
 #endif
 
@@ -85,10 +88,10 @@
 # include <unistd.h>
 #endif
 
-#ifndef __attribute__
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
-#  define __attribute__(Spec)   /* empty */
-# endif
+#if 3 <= __GNUC__ || __GNUC__ == 2 && 8 <= __GNUC_MINOR__
+# define _GL_ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
+#else
+# define _GL_ATTRIBUTE_NORETURN
 #endif
 
 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
@@ -116,7 +119,7 @@
 /* Terminate the current process with the given return code, without running
    the 'atexit' handlers.  */
 # if !@HAVE__EXIT@
-_GL_FUNCDECL_SYS (_Exit, void, (int status) __attribute__ ((__noreturn__)));
+_GL_FUNCDECL_SYS (_Exit, void, (int status) _GL_ATTRIBUTE_NORETURN);
 # endif
 _GL_CXXALIAS_SYS (_Exit, void, (int status));
 _GL_CXXALIASWARN (_Exit);
@@ -271,6 +274,21 @@
                  "use gnulib module malloc-posix for portability");
 #endif
 
+/* Convert a multibyte character to a wide character.  */
+#if @GNULIB_MBTOWC@
+# if @REPLACE_MBTOWC@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef mbtowc
+#   define mbtowc rpl_mbtowc
+#  endif
+_GL_FUNCDECL_RPL (mbtowc, int, (wchar_t *pwc, const char *s, size_t n));
+_GL_CXXALIAS_RPL (mbtowc, int, (wchar_t *pwc, const char *s, size_t n));
+# else
+_GL_CXXALIAS_SYS (mbtowc, int, (wchar_t *pwc, const char *s, size_t n));
+# endif
+_GL_CXXALIASWARN (mbtowc);
+#endif
+
 #if @GNULIB_MKDTEMP@
 /* Create a unique temporary directory from TEMPLATE.
    The last six characters of TEMPLATE must be "XXXXXX";
@@ -720,6 +738,21 @@
 # endif
 #endif
 
+/* Convert a wide character to a multibyte character.  */
+#if @GNULIB_WCTOMB@
+# if @REPLACE_WCTOMB@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef wctomb
+#   define wctomb rpl_wctomb
+#  endif
+_GL_FUNCDECL_RPL (wctomb, int, (char *s, wchar_t wc));
+_GL_CXXALIAS_RPL (wctomb, int, (char *s, wchar_t wc));
+# else
+_GL_CXXALIAS_SYS (wctomb, int, (char *s, wchar_t wc));
+# endif
+_GL_CXXALIASWARN (wctomb);
+#endif
+
 
 #endif /* _GL_STDLIB_H */
 #endif /* _GL_STDLIB_H */
--- a/lib/str-two-way.h
+++ b/lib/str-two-way.h
@@ -44,14 +44,15 @@
 #include <limits.h>
 #include <stdint.h>
 
-/* We use the Two-Way string matching algorithm, which guarantees
-   linear complexity with constant space.  Additionally, for long
-   needles, we also use a bad character shift table similar to the
-   Boyer-Moore algorithm to achieve improved (potentially sub-linear)
-   performance.
+/* We use the Two-Way string matching algorithm (also known as
+   Chrochemore-Perrin), which guarantees linear complexity with
+   constant space.  Additionally, for long needles, we also use a bad
+   character shift table similar to the Boyer-Moore algorithm to
+   achieve improved (potentially sub-linear) performance.
 
-   See http://www-igm.univ-mlv.fr/~lecroq/string/node26.html#SECTION00260
-   and http://en.wikipedia.org/wiki/Boyer-Moore_string_search_algorithm
+   See http://www-igm.univ-mlv.fr/~lecroq/string/node26.html#SECTION00260,
+   http://en.wikipedia.org/wiki/Boyer-Moore_string_search_algorithm,
+   http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.34.6641&rep=rep1&type=pdf
 */
 
 /* Point at which computing a bad-byte shift table is likely to be
@@ -108,7 +109,7 @@
 critical_factorization (const unsigned char *needle, size_t needle_len,
                         size_t *period)
 {
-  /* Index of last byte of left half.  */
+  /* Index of last byte of left half, or SIZE_MAX.  */
   size_t max_suffix, max_suffix_rev;
   size_t j; /* Index into NEEDLE for current candidate suffix.  */
   size_t k; /* Offset into current period.  */
@@ -124,8 +125,8 @@
     }
 
   /* Invariants:
-     1 <= j < NEEDLE_LEN - 1
-     0 <= max_suffix{,_rev} < j
+     0 <= j < NEEDLE_LEN - 1
+     -1 <= max_suffix{,_rev} < j (treating SIZE_MAX as if it were signed)
      min(max_suffix, max_suffix_rev) < global period of NEEDLE
      1 <= p <= global period of NEEDLE
      p == global period of the substring NEEDLE[max_suffix{,_rev}+1...j]
@@ -133,8 +134,9 @@
   */
 
   /* Perform lexicographic search.  */
-  max_suffix = 0;
-  j = k = p = 1;
+  max_suffix = SIZE_MAX;
+  j = 0;
+  k = p = 1;
   while (j + k < needle_len)
     {
       a = CANON_ELEMENT (needle[j + k]);
@@ -167,8 +169,9 @@
   *period = p;
 
   /* Perform reverse lexicographic search.  */
-  max_suffix_rev = 0;
-  j = k = p = 1;
+  max_suffix_rev = SIZE_MAX;
+  j = 0;
+  k = p = 1;
   while (j + k < needle_len)
     {
       a = CANON_ELEMENT (needle[j + k]);
--- a/lib/strerror_r.c
+++ b/lib/strerror_r.c
@@ -27,7 +27,7 @@
 #if HAVE_DECL_STRERROR_R && !(__GLIBC__ >= 2 || defined __UCLIBC__) && !EXTEND_STRERROR_R
 
 /* The system's strerror_r function is OK, except that its third argument
-   is 'int', not 'size_t'.  */
+   is 'int', not 'size_t', or its return type is wrong.  */
 
 # include <limits.h>
 
@@ -61,6 +61,11 @@
     else
       ret = strerror_r (errnum, buf, buflen);
   }
+# elif defined __CYGWIN__
+  /* Cygwin only provides the glibc interface, is thread-safe, and
+     always succeeds (although it may truncate). */
+  strerror_r (errnum, buf, buflen);
+  ret = 0;
 # else
   ret = strerror_r (errnum, buf, buflen);
 # endif
--- a/lib/strftime.c
+++ b/lib/strftime.c
@@ -172,15 +172,16 @@
 #define add(n, f)                                                             \
   do                                                                          \
     {                                                                         \
-      int _n = (n);                                                           \
-      int _delta = width - _n;                                                \
-      int _incr = _n + (_delta > 0 ? _delta : 0);                             \
-      if ((size_t) _incr >= maxsize - i)                                      \
+      size_t _n = (n);                                                        \
+      size_t _w = (width < 0 ? 0 : width);                                    \
+      size_t _incr = _n < _w ? _w : _n;                                       \
+      if (_incr >= maxsize - i)                                               \
         return 0;                                                             \
       if (p)                                                                  \
         {                                                                     \
-          if (digits == 0 && _delta > 0)                                      \
+          if (digits == 0 && _n < _w)                                         \
             {                                                                 \
+              size_t _delta = width - _n;                                     \
               if (pad == L_('0'))                                             \
                 memset_zero (p, _delta);                                      \
               else                                                            \
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -37,13 +37,8 @@
 # include <wchar.h>
 #endif
 
-#ifndef __attribute__
-/* This feature is available in gcc versions 2.5 and later.  */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
-#  define __attribute__(Spec) /* empty */
-# endif
-#endif
-/* The attribute __pure__ was added in gcc 2.96.  */
+/* The __attribute__ feature is available in gcc versions 2.5 and later.
+   The attribute __pure__ was added in gcc 2.96.  */
 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
 # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
 #else
--- a/lib/strptime.c
+++ b/lib/strptime.c
@@ -251,7 +251,9 @@
   int have_mon, have_mday;
   int have_uweek, have_wweek;
   int week_no;
+#ifdef _NL_CURRENT
   size_t num_eras;
+#endif
   struct era_entry *era;
 
   have_I = is_pm = 0;
@@ -408,7 +410,9 @@
           break;
         case 'C':
           /* Match century number.  */
+#ifdef _NL_CURRENT
         match_century:
+#endif
           get_number (0, 99, 2);
           century = val;
           want_xday = 1;
@@ -644,7 +648,9 @@
           have_wday = 1;
           break;
         case 'y':
+#ifdef _NL_CURRENT
         match_year_in_century:
+#endif
           /* Match year within century.  */
           get_number (0, 99, 2);
           /* The "Year 2000: The Millennium Rollover" paper suggests that
--- a/lib/sys_socket.in.h
+++ b/lib/sys_socket.in.h
@@ -50,6 +50,10 @@
    <sys/types.h>.  */
 # include <sys/types.h>
 
+/* On FreeBSD 6.4, <sys/socket.h> defines some macros that assume that NULL
+   is defined.  */
+# include <stddef.h>
+
 /* The include_next requires a split double-inclusion guard.  */
 # @INCLUDE_NEXT@ @NEXT_SYS_SOCKET_H@
 
@@ -67,7 +71,10 @@
 /* The definition of _GL_WARN_ON_USE is copied here.  */
 
 #if !@HAVE_SA_FAMILY_T@
+# if !GNULIB_defined_sa_family_t
 typedef unsigned short  sa_family_t;
+#  define GNULIB_defined_sa_family_t 1
+# endif
 #endif
 
 #if @HAVE_STRUCT_SOCKADDR_STORAGE@
@@ -89,12 +96,16 @@
                   : alignof (__ss_aligntype))                           \
                  + sizeof (__ss_aligntype)))
 
+# if !GNULIB_defined_struct_sockaddr_storage
 struct sockaddr_storage
 {
   sa_family_t ss_family;      /* Address family, etc.  */
   __ss_aligntype __ss_align;  /* Force desired alignment.  */
   char __ss_padding[_SS_PADSIZE];
 };
+#  define GNULIB_defined_struct_sockaddr_storage 1
+# endif
+
 #endif
 
 #if @HAVE_SYS_SOCKET_H@
@@ -159,7 +170,10 @@
 #  include <sys/types.h>
 #  include <io.h>
 
+#  if !GNULIB_defined_socklen_t
 typedef int socklen_t;
+#   define GNULIB_defined_socklen_t 1
+#  endif
 
 # endif
 
@@ -167,6 +181,8 @@
 
 #if @HAVE_WINSOCK2_H@
 
+# if !GNULIB_defined_rpl_fd_isset
+
 /* Re-define FD_ISSET to avoid a WSA call while we are not using
    network sockets.  */
 static inline int
@@ -183,6 +199,9 @@
   return 0;
 }
 
+#  define GNULIB_defined_rpl_fd_isset 1
+# endif
+
 # undef FD_ISSET
 # define FD_ISSET(fd, set) rpl_fd_isset(fd, set)
 
--- a/lib/sys_stat.in.h
+++ b/lib/sys_stat.in.h
@@ -355,7 +355,11 @@
 
 
 #if @GNULIB_FUTIMENS@
-# if @REPLACE_FUTIMENS@
+/* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our futimens
+   implementation relies on futimesat, which on Solaris 10 makes an invocation
+   to futimens that is meant to invoke the libc's futimens(), not gnulib's
+   futimens().  */
+# if @REPLACE_FUTIMENS@ || (!@HAVE_FUTIMENS@ && defined __sun)
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #   undef futimens
 #   define futimens rpl_futimens
@@ -368,7 +372,9 @@
 #  endif
 _GL_CXXALIAS_SYS (futimens, int, (int fd, struct timespec const times[2]));
 # endif
+# if @HAVE_FUTIMENS@
 _GL_CXXALIASWARN (futimens);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef futimens
 # if HAVE_RAW_DECL_FUTIMENS
@@ -461,11 +467,14 @@
    which are included above.  */
 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
 
+#  if !GNULIB_defined_rpl_mkdir
 static inline int
 rpl_mkdir (char const *name, mode_t mode)
 {
   return _mkdir (name);
 }
+#   define GNULIB_defined_rpl_mkdir 1
+#  endif
 
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #   define mkdir rpl_mkdir
@@ -609,7 +618,11 @@
 
 
 #if @GNULIB_UTIMENSAT@
-# if @REPLACE_UTIMENSAT@
+/* Use the rpl_ prefix also on Solaris <= 9, because on Solaris 9 our utimensat
+   implementation relies on futimesat, which on Solaris 10 makes an invocation
+   to utimensat that is meant to invoke the libc's utimensat(), not gnulib's
+   utimensat().  */
+# if @REPLACE_UTIMENSAT@ || (!@HAVE_UTIMENSAT@ && defined __sun)
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #   undef utimensat
 #   define utimensat rpl_utimensat
@@ -628,7 +641,9 @@
 _GL_CXXALIAS_SYS (utimensat, int, (int fd, char const *name,
                                    struct timespec const times[2], int flag));
 # endif
+# if @HAVE_UTIMENSAT@
 _GL_CXXALIASWARN (utimensat);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef utimensat
 # if HAVE_RAW_DECL_UTIMENSAT
--- a/lib/sys_time.in.h
+++ b/lib/sys_time.in.h
@@ -51,11 +51,16 @@
 # endif
 
 # if ! @HAVE_STRUCT_TIMEVAL@
+
+#  if !GNULIB_defined_struct_timeval
 struct timeval
 {
   time_t tv_sec;
   long int tv_usec;
 };
+#   define GNULIB_defined_struct_timeval 1
+#  endif
+
 # endif
 
 # ifdef __cplusplus
--- a/lib/sys_times.in.h
+++ b/lib/sys_times.in.h
@@ -48,6 +48,7 @@
 # endif
 
 # if !@HAVE_STRUCT_TMS@
+#  if !GNULIB_defined_struct_tms
   /* Structure describing CPU time used by a process and its children.  */
   struct tms
   {
@@ -57,6 +58,8 @@
     clock_t tms_cutime;         /* User CPU time of dead children.  */
     clock_t tms_cstime;         /* System CPU time of dead children.  */
   };
+#   define GNULIB_defined_struct_tms 1
+#  endif
 # endif
 
 # if @GNULIB_TIMES@
--- a/lib/sys_utsname.in.h
+++ b/lib/sys_utsname.in.h
@@ -57,6 +57,7 @@
 #  define _UTSNAME_MACHINE_LENGTH _UTSNAME_LENGTH
 # endif
 
+# if !GNULIB_defined_struct_utsname
 /* Structure describing the system and machine.  */
 struct utsname
   {
@@ -73,6 +74,9 @@
     /* Name of the hardware type the system is running on.  */
     char machine[_UTSNAME_MACHINE_LENGTH];
   };
+#  define GNULIB_defined_struct_utsname 1
+# endif
+
 #endif /* !@HAVE_STRUCT_UTSNAME@ */
 
 
--- a/lib/time.in.h
+++ b/lib/time.in.h
@@ -69,13 +69,16 @@
 extern "C" {
 #   endif
 
-#   undef timespec
-#   define timespec rpl_timespec
+#   if !GNULIB_defined_struct_timespec
+#    undef timespec
+#    define timespec rpl_timespec
 struct timespec
 {
   time_t tv_sec;
   long int tv_nsec;
 };
+#    define GNULIB_defined_struct_timespec 1
+#   endif
 
 #   ifdef __cplusplus
 }
@@ -84,6 +87,7 @@
 #  endif
 # endif
 
+# if !GNULIB_defined_struct_time_t_must_be_integral
 /* Per http://austingroupbugs.net/view.php?id=327, POSIX requires
    time_t to be an integer type, even though C99 permits floating
    point.  We don't know of any implementation that uses floating
@@ -92,6 +96,8 @@
 struct __time_t_must_be_integral {
   unsigned int __floating_time_t_unsupported : (time_t) 1;
 };
+#  define GNULIB_defined_struct_time_t_must_be_integral 1
+# endif
 
 /* Sleep for at least RQTP seconds unless interrupted,  If interrupted,
    return -1 and store the remaining time into RMTP.  See
new file mode 100644
--- /dev/null
+++ b/lib/towctrans-impl.h
@@ -0,0 +1,22 @@
+/* Convert a wide character using a case mapping.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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/>.  */
+
+wint_t
+towctrans (wint_t wc, wctrans_t desc)
+{
+  return ((wint_t (*) (wint_t)) desc) (wc);
+}
new file mode 100644
--- /dev/null
+++ b/lib/towctrans.c
@@ -0,0 +1,23 @@
+/* Convert a wide character using a case mapping.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 <wctype.h>
+
+#include "towctrans-impl.h"
--- a/lib/unictype.in.h
+++ b/lib/unictype.in.h
@@ -61,6 +61,7 @@
 enum
 {
   UC_CATEGORY_MASK_L  = 0x0000001f,
+  UC_CATEGORY_MASK_LC = 0x00000007,
   UC_CATEGORY_MASK_Lu = 0x00000001,
   UC_CATEGORY_MASK_Ll = 0x00000002,
   UC_CATEGORY_MASK_Lt = 0x00000004,
@@ -101,6 +102,7 @@
 
 /* Predefined General category values.  */
 extern const uc_general_category_t UC_CATEGORY_L;
+extern const uc_general_category_t UC_CATEGORY_LC;
 extern const uc_general_category_t UC_CATEGORY_Lu;
 extern const uc_general_category_t UC_CATEGORY_Ll;
 extern const uc_general_category_t UC_CATEGORY_Lt;
@@ -142,6 +144,7 @@
 
 /* Alias names for predefined General category values.  */
 #define UC_LETTER                    UC_CATEGORY_L
+#define UC_CASED_LETTER              UC_CATEGORY_LC
 #define UC_UPPERCASE_LETTER          UC_CATEGORY_Lu
 #define UC_LOWERCASE_LETTER          UC_CATEGORY_Ll
 #define UC_TITLECASE_LETTER          UC_CATEGORY_Lt
@@ -204,7 +207,12 @@
 extern const char *
        uc_general_category_name (uc_general_category_t category);
 
-/* Return the general category given by name, e.g. "Lu".  */
+/* Return the long name of a general category.  */
+extern const char *
+       uc_general_category_long_name (uc_general_category_t category);
+
+/* Return the general category given by name, e.g. "Lu", or by long name,
+   e.g. "Uppercase Letter".  */
 extern uc_general_category_t
        uc_general_category_byname (const char *category_name);
 
@@ -237,6 +245,7 @@
   UC_CCC_VR   =   9, /* Virama */
   UC_CCC_ATBL = 200, /* Attached Below Left */
   UC_CCC_ATB  = 202, /* Attached Below */
+  UC_CCC_ATA  = 214, /* Attached Above */
   UC_CCC_ATAR = 216, /* Attached Above Right */
   UC_CCC_BL   = 218, /* Below Left */
   UC_CCC_B    = 220, /* Below */
@@ -255,9 +264,23 @@
 extern int
        uc_combining_class (ucs4_t uc);
 
+/* Return the name of a canonical combining class.  */
+extern const char *
+       uc_combining_class_name (int ccc);
+
+/* Return the long name of a canonical combining class.  */
+extern const char *
+       uc_combining_class_long_name (int ccc);
+
+/* Return the canonical combining class given by name, e.g. "BL", or by long
+   name, e.g. "Below Left".  */
+extern int
+       uc_combining_class_byname (const char *ccc_name);
+
 /* ========================================================================= */
 
-/* Field 4 of Unicode Character Database: Bidirectional category.  */
+/* Field 4 of Unicode Character Database: Bidi class.
+   Before Unicode 4.0, this field was called "Bidirectional category".  */
 
 enum
 {
@@ -282,20 +305,36 @@
   UC_BIDI_ON   /* Other Neutral */
 };
 
-/* Return the name of a bidirectional category.  */
+/* Return the name of a bidi class.  */
+extern const char *
+       uc_bidi_class_name (int bidi_class);
+/* Same; obsolete function name.  */
 extern const char *
        uc_bidi_category_name (int category);
 
-/* Return the bidirectional category given by name, e.g. "LRE".  */
+/* Return the long name of a bidi class.  */
+extern const char *
+       uc_bidi_class_long_name (int bidi_class);
+
+/* Return the bidi class given by name, e.g. "LRE", or by long name, e.g.
+   "Left-to-Right Embedding".  */
+extern int
+       uc_bidi_class_byname (const char *bidi_class_name);
+/* Same; obsolete function name.  */
 extern int
        uc_bidi_category_byname (const char *category_name);
 
-/* Return the bidirectional category of a Unicode character.  */
+/* Return the bidi class of a Unicode character.  */
+extern int
+       uc_bidi_class (ucs4_t uc);
+/* Same; obsolete function name.  */
 extern int
        uc_bidi_category (ucs4_t uc);
 
-/* Test whether a Unicode character belongs to a given bidirectional
-   category.  */
+/* Test whether a Unicode character belongs to a given bidi class.  */
+extern bool
+       uc_is_bidi_class (ucs4_t uc, int bidi_class);
+/* Same; obsolete function name.  */
 extern bool
        uc_is_bidi_category (ucs4_t uc, int category);
 
@@ -359,6 +398,117 @@
 
 /* ========================================================================= */
 
+/* Field 2 of the file ArabicShaping.txt in the Unicode Character Database.  */
+
+/* Possible joining types.  */
+enum
+{
+  UC_JOINING_TYPE_U, /* Non_Joining */
+  UC_JOINING_TYPE_T, /* Transparent */
+  UC_JOINING_TYPE_C, /* Join_Causing */
+  UC_JOINING_TYPE_L, /* Left_Joining */
+  UC_JOINING_TYPE_R, /* Right_Joining */
+  UC_JOINING_TYPE_D  /* Dual_Joining */
+};
+
+/* Return the name of a joining type.  */
+extern const char *
+       uc_joining_type_name (int joining_type);
+
+/* Return the long name of a joining type.  */
+extern const char *
+       uc_joining_type_long_name (int joining_type);
+
+/* Return the joining type given by name, e.g. "D", or by long name, e.g.
+   "Dual Joining".  */
+extern int
+       uc_joining_type_byname (const char *joining_type_name);
+
+/* Return the joining type of a Unicode character.  */
+extern int
+       uc_joining_type (ucs4_t uc);
+
+/* ========================================================================= */
+
+/* Field 3 of the file ArabicShaping.txt in the Unicode Character Database.  */
+
+/* Possible joining groups.
+   This enumeration may be extended in the future.  */
+enum
+{
+  UC_JOINING_GROUP_NONE,                  /* No_Joining_Group */
+  UC_JOINING_GROUP_AIN,                   /* Ain */
+  UC_JOINING_GROUP_ALAPH,                 /* Alaph */
+  UC_JOINING_GROUP_ALEF,                  /* Alef */
+  UC_JOINING_GROUP_BEH,                   /* Beh */
+  UC_JOINING_GROUP_BETH,                  /* Beth */
+  UC_JOINING_GROUP_BURUSHASKI_YEH_BARREE, /* Burushaski_Yeh_Barree */
+  UC_JOINING_GROUP_DAL,                   /* Dal */
+  UC_JOINING_GROUP_DALATH_RISH,           /* Dalath_Rish */
+  UC_JOINING_GROUP_E,                     /* E */
+  UC_JOINING_GROUP_FARSI_YEH,             /* Farsi_Yeh */
+  UC_JOINING_GROUP_FE,                    /* Fe */
+  UC_JOINING_GROUP_FEH,                   /* Feh */
+  UC_JOINING_GROUP_FINAL_SEMKATH,         /* Final_Semkath */
+  UC_JOINING_GROUP_GAF,                   /* Gaf */
+  UC_JOINING_GROUP_GAMAL,                 /* Gamal */
+  UC_JOINING_GROUP_HAH,                   /* Hah */
+  UC_JOINING_GROUP_HE,                    /* He */
+  UC_JOINING_GROUP_HEH,                   /* Heh */
+  UC_JOINING_GROUP_HEH_GOAL,              /* Heh_Goal */
+  UC_JOINING_GROUP_HETH,                  /* Heth */
+  UC_JOINING_GROUP_KAF,                   /* Kaf */
+  UC_JOINING_GROUP_KAPH,                  /* Kaph */
+  UC_JOINING_GROUP_KHAPH,                 /* Khaph */
+  UC_JOINING_GROUP_KNOTTED_HEH,           /* Knotted_Heh */
+  UC_JOINING_GROUP_LAM,                   /* Lam */
+  UC_JOINING_GROUP_LAMADH,                /* Lamadh */
+  UC_JOINING_GROUP_MEEM,                  /* Meem */
+  UC_JOINING_GROUP_MIM,                   /* Mim */
+  UC_JOINING_GROUP_NOON,                  /* Noon */
+  UC_JOINING_GROUP_NUN,                   /* Nun */
+  UC_JOINING_GROUP_NYA,                   /* Nya */
+  UC_JOINING_GROUP_PE,                    /* Pe */
+  UC_JOINING_GROUP_QAF,                   /* Qaf */
+  UC_JOINING_GROUP_QAPH,                  /* Qaph */
+  UC_JOINING_GROUP_REH,                   /* Reh */
+  UC_JOINING_GROUP_REVERSED_PE,           /* Reversed_Pe */
+  UC_JOINING_GROUP_SAD,                   /* Sad */
+  UC_JOINING_GROUP_SADHE,                 /* Sadhe */
+  UC_JOINING_GROUP_SEEN,                  /* Seen */
+  UC_JOINING_GROUP_SEMKATH,               /* Semkath */
+  UC_JOINING_GROUP_SHIN,                  /* Shin */
+  UC_JOINING_GROUP_SWASH_KAF,             /* Swash_Kaf */
+  UC_JOINING_GROUP_SYRIAC_WAW,            /* Syriac_Waw */
+  UC_JOINING_GROUP_TAH,                   /* Tah */
+  UC_JOINING_GROUP_TAW,                   /* Taw */
+  UC_JOINING_GROUP_TEH_MARBUTA,           /* Teh_Marbuta */
+  UC_JOINING_GROUP_TEH_MARBUTA_GOAL,      /* Teh_Marbuta_Goal */
+  UC_JOINING_GROUP_TETH,                  /* Teth */
+  UC_JOINING_GROUP_WAW,                   /* Waw */
+  UC_JOINING_GROUP_YEH,                   /* Yeh */
+  UC_JOINING_GROUP_YEH_BARREE,            /* Yeh_Barree */
+  UC_JOINING_GROUP_YEH_WITH_TAIL,         /* Yeh_With_Tail */
+  UC_JOINING_GROUP_YUDH,                  /* Yudh */
+  UC_JOINING_GROUP_YUDH_HE,               /* Yudh_He */
+  UC_JOINING_GROUP_ZAIN,                  /* Zain */
+  UC_JOINING_GROUP_ZHAIN                  /* Zhain */
+};
+
+/* Return the name of a joining group.  */
+extern const char *
+       uc_joining_group_name (int joining_group);
+
+/* Return the joining group given by name, e.g. "Teh_Marbuta".  */
+extern int
+       uc_joining_group_byname (const char *joining_group_name);
+
+/* Return the joining group of a Unicode character.  */
+extern int
+       uc_joining_group (ucs4_t uc);
+
+/* ========================================================================= */
+
 /* Common API for properties.  */
 
 /* Data type denoting a property.  This is not just a number, but rather a
--- a/lib/unictype/bidi_byname.c
+++ b/lib/unictype/bidi_byname.c
@@ -1,5 +1,5 @@
-/* Bidi categories of Unicode characters.
-   Copyright (C) 2002, 2006, 2009-2011 Free Software Foundation, Inc.
+/* Bidi classes of Unicode characters.
+   Copyright (C) 2002, 2006, 2011 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2002.
 
    This program is free software: you can redistribute it and/or modify it
@@ -20,152 +20,50 @@
 /* Specification.  */
 #include "unictype.h"
 
+#include <string.h>
+
+#include "unictype/bidi_byname.h"
+
+int
+uc_bidi_class_byname (const char *bidi_class_name)
+{
+  size_t len;
+
+  len = strlen (bidi_class_name);
+  if (len <= MAX_WORD_LENGTH)
+    {
+      char buf[MAX_WORD_LENGTH + 1];
+      const struct named_bidi_class *found;
+
+      /* Copy bidi_class_name into buf, converting '_' and '-' to ' '.  */
+      {
+        const char *p = bidi_class_name;
+        char *q = buf;
+
+        for (;; p++, q++)
+          {
+            char c = *p;
+
+            if (c == '_' || c == '-')
+              c = ' ';
+            *q = c;
+            if (c == '\0')
+              break;
+          }
+      }
+      /* Here q == buf + len.  */
+
+      /* Do a hash table lookup, with case-insensitive comparison.  */
+      found = uc_bidi_class_lookup (buf, len);
+      if (found != NULL)
+        return found->bidi_class;
+    }
+  /* Invalid bidi class name.  */
+  return -1;
+}
+
 int
 uc_bidi_category_byname (const char *category_name)
 {
-  switch (category_name[0])
-    {
-    case 'A':
-      switch (category_name[1])
-        {
-        case 'L':
-          if (category_name[2] == '\0')
-            return UC_BIDI_AL;
-          break;
-        case 'N':
-          if (category_name[2] == '\0')
-            return UC_BIDI_AN;
-          break;
-        }
-      break;
-    case 'B':
-      switch (category_name[1])
-        {
-        case '\0':
-          return UC_BIDI_B;
-        case 'N':
-          if (category_name[2] == '\0')
-            return UC_BIDI_BN;
-          break;
-        }
-      break;
-    case 'C':
-      switch (category_name[1])
-        {
-        case 'S':
-          if (category_name[2] == '\0')
-            return UC_BIDI_CS;
-          break;
-        }
-      break;
-    case 'E':
-      switch (category_name[1])
-        {
-        case 'N':
-          if (category_name[2] == '\0')
-            return UC_BIDI_EN;
-          break;
-        case 'S':
-          if (category_name[2] == '\0')
-            return UC_BIDI_ES;
-          break;
-        case 'T':
-          if (category_name[2] == '\0')
-            return UC_BIDI_ET;
-          break;
-        }
-      break;
-    case 'L':
-      switch (category_name[1])
-        {
-        case '\0':
-          return UC_BIDI_L;
-        case 'R':
-          switch (category_name[2])
-            {
-            case 'E':
-              if (category_name[3] == '\0')
-                return UC_BIDI_LRE;
-              break;
-            case 'O':
-              if (category_name[3] == '\0')
-                return UC_BIDI_LRO;
-              break;
-            }
-          break;
-        }
-      break;
-    case 'N':
-      switch (category_name[1])
-        {
-        case 'S':
-          switch (category_name[2])
-            {
-            case 'M':
-              if (category_name[3] == '\0')
-                return UC_BIDI_NSM;
-              break;
-            }
-          break;
-        }
-      break;
-    case 'O':
-      switch (category_name[1])
-        {
-        case 'N':
-          if (category_name[2] == '\0')
-            return UC_BIDI_ON;
-          break;
-        }
-      break;
-    case 'P':
-      switch (category_name[1])
-        {
-        case 'D':
-          switch (category_name[2])
-            {
-            case 'F':
-              if (category_name[3] == '\0')
-                return UC_BIDI_PDF;
-              break;
-            }
-          break;
-        }
-      break;
-    case 'R':
-      switch (category_name[1])
-        {
-        case '\0':
-          return UC_BIDI_R;
-        case 'L':
-          switch (category_name[2])
-            {
-            case 'E':
-              if (category_name[3] == '\0')
-                return UC_BIDI_RLE;
-              break;
-            case 'O':
-              if (category_name[3] == '\0')
-                return UC_BIDI_RLO;
-              break;
-            }
-          break;
-        }
-      break;
-    case 'S':
-      if (category_name[1] == '\0')
-        return UC_BIDI_S;
-      break;
-    case 'W':
-      switch (category_name[1])
-        {
-        case 'S':
-          if (category_name[2] == '\0')
-            return UC_BIDI_WS;
-          break;
-        }
-      break;
-    }
-  /* Invalid category name.  */
-  return -1;
+  return uc_bidi_class_byname (category_name);
 }
new file mode 100644
--- /dev/null
+++ b/lib/unictype/bidi_byname.gperf
@@ -0,0 +1,70 @@
+/* Bidi classes of Unicode characters.  */
+struct named_bidi_class { int name; int bidi_class; };
+%struct-type
+%ignore-case
+%language=ANSI-C
+%define hash-function-name bidi_class_hash
+%define lookup-function-name uc_bidi_class_lookup
+%readonly-tables
+%global-table
+%define word-array-name bidi_class_names
+%pic
+%define string-pool-name bidi_class_stringpool
+%%
+AL, UC_BIDI_AL
+AN, UC_BIDI_AN
+B, UC_BIDI_B
+BN, UC_BIDI_BN
+CS, UC_BIDI_CS
+EN, UC_BIDI_EN
+ES, UC_BIDI_ES
+ET, UC_BIDI_ET
+L, UC_BIDI_L
+LRE, UC_BIDI_LRE
+LRO, UC_BIDI_LRO
+NSM, UC_BIDI_NSM
+ON, UC_BIDI_ON
+PDF, UC_BIDI_PDF
+R, UC_BIDI_R
+RLE, UC_BIDI_RLE
+RLO, UC_BIDI_RLO
+S, UC_BIDI_S
+WS, UC_BIDI_WS
+Arabic Letter, UC_BIDI_AL
+ArabicLetter, UC_BIDI_AL
+Arabic Number, UC_BIDI_AN
+ArabicNumber, UC_BIDI_AN
+Paragraph Separator, UC_BIDI_B
+ParagraphSeparator, UC_BIDI_B
+Boundary Neutral, UC_BIDI_BN
+BoundaryNeutral, UC_BIDI_BN
+Common Separator, UC_BIDI_CS
+CommonSeparator, UC_BIDI_CS
+European Number, UC_BIDI_EN
+EuropeanNumber, UC_BIDI_EN
+European Separator, UC_BIDI_ES
+EuropeanSeparator, UC_BIDI_ES
+European Terminator, UC_BIDI_ET
+EuropeanTerminator, UC_BIDI_ET
+Left To Right, UC_BIDI_L
+LeftToRight, UC_BIDI_L
+Left To Right Embedding, UC_BIDI_LRE
+LeftToRightEmbedding, UC_BIDI_LRE
+Left To Right Override, UC_BIDI_LRO
+LeftToRightOverride, UC_BIDI_LRO
+Nonspacing Mark, UC_BIDI_NSM
+NonspacingMark, UC_BIDI_NSM
+Other Neutral, UC_BIDI_ON
+OtherNeutral, UC_BIDI_ON
+Pop Directional Format, UC_BIDI_PDF
+PopDirectionalFormat, UC_BIDI_PDF
+Right To Left, UC_BIDI_R
+RightToLeft, UC_BIDI_R
+Right To Left Embedding, UC_BIDI_RLE
+RightToLeftEmbedding, UC_BIDI_RLE
+Right To Left Override, UC_BIDI_RLO
+RightToLeftOverride, UC_BIDI_RLO
+Segment Separator, UC_BIDI_S
+SegmentSeparator, UC_BIDI_S
+White Space, UC_BIDI_WS
+WhiteSpace, UC_BIDI_WS
new file mode 100644
--- /dev/null
+++ b/lib/unictype/bidi_longname.c
@@ -0,0 +1,53 @@
+/* Bidi classes of Unicode characters.
+   Copyright (C) 2002, 2006, 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "unictype.h"
+
+static const char u_bidi_class_long_name[19][24] =
+{
+  "Left To Right",
+  "Left To Right Embedding",
+  "Left To Right Override",
+  "Right To Left",
+  "Arabic Letter",
+  "Right To Left Embedding",
+  "Right To Left Override",
+  "Pop Directional Format",
+  "European Number",
+  "European Separator",
+  "European Terminator",
+  "Arabic Number",
+  "Common Separator",
+  "Nonspacing Mark",
+  "Boundary Neutral",
+  "Paragraph Separator",
+  "Segment Separator",
+  "White Space",
+  "Other Neutral"
+};
+
+const char *
+uc_bidi_class_long_name (int bidi_class)
+{
+  if (bidi_class >= 0
+      && bidi_class < sizeof (u_bidi_class_long_name) / sizeof (u_bidi_class_long_name[0]))
+    return u_bidi_class_long_name[bidi_class];
+  return NULL;
+}
--- a/lib/unictype/bidi_name.c
+++ b/lib/unictype/bidi_name.c
@@ -1,5 +1,5 @@
-/* Bidi categories of Unicode characters.
-   Copyright (C) 2002, 2006, 2009-2011 Free Software Foundation, Inc.
+/* Bidi classes of Unicode characters.
+   Copyright (C) 2002, 2006, 2011 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2002.
 
    This program is free software: you can redistribute it and/or modify it
@@ -20,16 +20,22 @@
 /* Specification.  */
 #include "unictype.h"
 
-static const char u_bidi_category_name[19][4] =
+static const char u_bidi_class_name[19][4] =
 {
   "L",  "LRE", "LRO", "R",   "AL", "RLE", "RLO", "PDF", "EN", "ES",
   "ET", "AN",  "CS",  "NSM", "BN", "B",   "S",   "WS",  "ON"
 };
 
 const char *
+uc_bidi_class_name (int bidi_class)
+{
+  if (bidi_class >= 0 && bidi_class < sizeof (u_bidi_class_name) / sizeof (u_bidi_class_name[0]))
+    return u_bidi_class_name[bidi_class];
+  return NULL;
+}
+
+const char *
 uc_bidi_category_name (int category)
 {
-  if (category >= 0 && category < sizeof (u_bidi_category_name) / sizeof (u_bidi_category_name[0]))
-    return u_bidi_category_name[category];
-  return NULL;
+  return uc_bidi_class_name (category);
 }
--- a/lib/unictype/bidi_of.c
+++ b/lib/unictype/bidi_of.c
@@ -1,5 +1,5 @@
-/* Bidi categories of Unicode characters.
-   Copyright (C) 2002, 2006, 2009-2011 Free Software Foundation, Inc.
+/* Bidi classes of Unicode characters.
+   Copyright (C) 2002, 2006, 2011 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2002.
 
    This program is free software: you can redistribute it and/or modify it
@@ -24,7 +24,7 @@
 #include "bidi_of.h"
 
 int
-uc_bidi_category (ucs4_t uc)
+uc_bidi_class (ucs4_t uc)
 {
   unsigned int index1 = uc >> bidi_category_header_0;
   if (index1 < bidi_category_header_1)
@@ -50,3 +50,9 @@
     }
   return UC_BIDI_L;
 }
+
+int
+uc_bidi_category (ucs4_t uc)
+{
+  return uc_bidi_class (uc);
+}
--- a/lib/unictype/bidi_test.c
+++ b/lib/unictype/bidi_test.c
@@ -1,5 +1,5 @@
-/* Bidi categories of Unicode characters.
-   Copyright (C) 2002, 2006, 2009-2011 Free Software Foundation, Inc.
+/* Bidi classes of Unicode characters.
+   Copyright (C) 2002, 2006, 2011 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2002.
 
    This program is free software: you can redistribute it and/or modify it
@@ -21,7 +21,13 @@
 #include "unictype.h"
 
 bool
+uc_is_bidi_class (ucs4_t uc, int bidi_class)
+{
+  return (uc_bidi_class (uc) == bidi_class);
+}
+
+bool
 uc_is_bidi_category (ucs4_t uc, int category)
 {
-  return (uc_bidi_category (uc) == category);
+  return uc_is_bidi_class (uc, category);
 }
new file mode 100644
--- /dev/null
+++ b/lib/unictype/categ_LC.c
@@ -0,0 +1,27 @@
+/* Categories of Unicode characters.
+   Copyright (C) 2002, 2006-2007, 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "unictype.h"
+
+/* Define u_categ_LC table.  */
+#include "categ_LC.h"
+
+const uc_general_category_t UC_CATEGORY_LC =
+  { UC_CATEGORY_MASK_LC, 0, { &u_categ_LC } };
new file mode 100644
--- /dev/null
+++ b/lib/unictype/categ_LC.h
@@ -0,0 +1,339 @@
+/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
+/* Categories of Unicode characters.  */
+/* Generated automatically by gen-uni-tables.c for Unicode 6.0.0.  */
+#define header_0 16
+#define header_2 9
+#define header_3 127
+#define header_4 15
+static const
+struct
+  {
+    int header[1];
+    int level1[2];
+    short level2[2 << 7];
+    /*unsigned*/ int level3[14 << 4];
+  }
+u_categ_LC =
+{
+  { 2 },
+  {
+        3 * sizeof (int) / sizeof (short) +     0,
+        3 * sizeof (int) / sizeof (short) +   128
+  },
+  {
+        3 +   256 * sizeof (short) / sizeof (int) +     0,
+        3 +   256 * sizeof (short) / sizeof (int) +    16,
+        3 +   256 * sizeof (short) / sizeof (int) +    32,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+        3 +   256 * sizeof (short) / sizeof (int) +    48,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+        3 +   256 * sizeof (short) / sizeof (int) +    64,
+        3 +   256 * sizeof (short) / sizeof (int) +    80,
+        3 +   256 * sizeof (short) / sizeof (int) +    96,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+        3 +   256 * sizeof (short) / sizeof (int) +   112,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+        3 +   256 * sizeof (short) / sizeof (int) +   128,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+        3 +   256 * sizeof (short) / sizeof (int) +   144,
+       -1,
+        3 +   256 * sizeof (short) / sizeof (int) +   160,
+       -1,
+       -1,
+        3 +   256 * sizeof (short) / sizeof (int) +   176,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+        3 +   256 * sizeof (short) / sizeof (int) +   192,
+        3 +   256 * sizeof (short) / sizeof (int) +   208,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1,
+       -1
+  },
+  {
+    0x00000000, 0x00000000, 0x07FFFFFE, 0x07FFFFFE,
+    0x00000000, 0x04200400, 0xFF7FFFFF, 0xFF7FFFFF,
+    0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+    0xFFFFFFFF, 0xF7FFFFFF, 0xFFFFFFF0, 0xFFFFFFFF,
+    0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+    0xFFEFFFFF, 0x0000FFFF, 0x00000000, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x38CF0000,
+    0xFFFFD740, 0xFFFFFFFB, 0xFFFFFFFF, 0xFFBFFFFF,
+    0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+    0xFFFFFC03, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+    0xFFFFFFFF, 0xFFFE00FF, 0x007FFFFF, 0xFFFFFFFE,
+    0x000000FF, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0xFFFFFFFF, 0x0000003F, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0xFFFFFFFF, 0x00000FFF, 0x00000000, 0xFEFFFFFC,
+    0x07FFFFFF, 0x00000000, 0x00000000, 0x00000000,
+    0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+    0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+    0x3F3FFFFF, 0xFFFFFFFF, 0xAAFF3F3F, 0x3FFFFFFF,
+    0xFFFFFFFF, 0x5FDFFFFF, 0x0FCF1FDC, 0x1FDC1FFF,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x3E2FFC84, 0xF21FBD50, 0x000043E0, 0x00000000,
+    0x00000018, 0x00000000, 0x00000000, 0x00000000,
+    0xFFFFFFFF, 0xFFFF7FFF, 0x7FFFFFFF, 0xDFFFFFFF,
+    0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x0000781F,
+    0xFFFFFFFF, 0x0000003F, 0x00000000, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x00000000, 0xFFFFFFFF, 0x00003FFF,
+    0x00FFFFFF, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0xFFFFFFFC, 0xFFFFFFFF, 0xFFFEFFFF,
+    0x000378FF, 0x000003FF, 0x00000000, 0x04000000,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x00F8007F, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x07FFFFFE, 0x07FFFFFE, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0xFFFFFFFF, 0xFFFFFFFF, 0x0000FFFF, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0x00000000, 0x00000000, 0x00000000, 0x00000000,
+    0xFFFFFFFF, 0xFFFFFFFF, 0xFFDFFFFF, 0xFFFFFFFF,
+    0xDFFFFFFF, 0xEBFFDE64, 0xFFFFFFEF, 0xFFFFFFFF,
+    0xDFDFE7BF, 0x7BFFFFFF, 0xFFFDFC5F, 0xFFFFFFFF,
+    0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+    0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
+    0xFFFFFFFF, 0xFFFFFF3F, 0xF7FFFFFD, 0xF7FFFFFF,
+    0xFFDFFFFF, 0xFFDFFFFF, 0xFFFF7FFF, 0xFFFF7FFF,
+    0xFFFFFDFF, 0xFFFFFDFF, 0x00000FF7, 0x00000000
+  }
+};
--- a/lib/unictype/categ_byname.c
+++ b/lib/unictype/categ_byname.c
@@ -1,5 +1,5 @@
 /* Categories of Unicode characters.
-   Copyright (C) 2002, 2006-2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2006-2007, 2011 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2002.
 
    This program is free software: you can redistribute it and/or modify it
@@ -20,86 +20,172 @@
 /* Specification.  */
 #include "unictype.h"
 
+#include <stdlib.h>
+#include <string.h>
+
+/* Indices stored in the 'struct named_category' elements of the perfect hash
+   table.  We don't use uc_general_category_t values or their addresses
+   directly, because this would introduce load-time relocations.  */
+enum
+{
+  UC_CATEGORY_INDEX_L,
+  UC_CATEGORY_INDEX_LC,
+  UC_CATEGORY_INDEX_Lu,
+  UC_CATEGORY_INDEX_Ll,
+  UC_CATEGORY_INDEX_Lt,
+  UC_CATEGORY_INDEX_Lm,
+  UC_CATEGORY_INDEX_Lo,
+  UC_CATEGORY_INDEX_M,
+  UC_CATEGORY_INDEX_Mn,
+  UC_CATEGORY_INDEX_Mc,
+  UC_CATEGORY_INDEX_Me,
+  UC_CATEGORY_INDEX_N,
+  UC_CATEGORY_INDEX_Nd,
+  UC_CATEGORY_INDEX_Nl,
+  UC_CATEGORY_INDEX_No,
+  UC_CATEGORY_INDEX_P,
+  UC_CATEGORY_INDEX_Pc,
+  UC_CATEGORY_INDEX_Pd,
+  UC_CATEGORY_INDEX_Ps,
+  UC_CATEGORY_INDEX_Pe,
+  UC_CATEGORY_INDEX_Pi,
+  UC_CATEGORY_INDEX_Pf,
+  UC_CATEGORY_INDEX_Po,
+  UC_CATEGORY_INDEX_S,
+  UC_CATEGORY_INDEX_Sm,
+  UC_CATEGORY_INDEX_Sc,
+  UC_CATEGORY_INDEX_Sk,
+  UC_CATEGORY_INDEX_So,
+  UC_CATEGORY_INDEX_Z,
+  UC_CATEGORY_INDEX_Zs,
+  UC_CATEGORY_INDEX_Zl,
+  UC_CATEGORY_INDEX_Zp,
+  UC_CATEGORY_INDEX_C,
+  UC_CATEGORY_INDEX_Cc,
+  UC_CATEGORY_INDEX_Cf,
+  UC_CATEGORY_INDEX_Cs,
+  UC_CATEGORY_INDEX_Co,
+  UC_CATEGORY_INDEX_Cn
+};
+
+#include "unictype/categ_byname.h"
+
 uc_general_category_t
 uc_general_category_byname (const char *category_name)
 {
-  if (category_name[0] != '\0'
-      && (category_name[1] == '\0' || category_name[2] == '\0'))
-    switch (category_name[0])
+  size_t len;
+
+  len = strlen (category_name);
+  if (len <= MAX_WORD_LENGTH)
+    {
+      char buf[MAX_WORD_LENGTH + 1];
+      const struct named_category *found;
+
+      /* Copy category_name into buf, converting '_' and '-' to ' '.  */
       {
-      case 'L':
-        switch (category_name[1])
-          {
-          case '\0': return UC_CATEGORY_L;
-          case 'u': return UC_CATEGORY_Lu;
-          case 'l': return UC_CATEGORY_Ll;
-          case 't': return UC_CATEGORY_Lt;
-          case 'm': return UC_CATEGORY_Lm;
-          case 'o': return UC_CATEGORY_Lo;
-          }
-        break;
-      case 'M':
-        switch (category_name[1])
+        const char *p = category_name;
+        char *q = buf;
+
+        for (;; p++, q++)
           {
-          case '\0': return UC_CATEGORY_M;
-          case 'n': return UC_CATEGORY_Mn;
-          case 'c': return UC_CATEGORY_Mc;
-          case 'e': return UC_CATEGORY_Me;
+            char c = *p;
+
+            if (c == '_' || c == '-')
+              c = ' ';
+            *q = c;
+            if (c == '\0')
+              break;
           }
-        break;
-      case 'N':
-        switch (category_name[1])
-          {
-          case '\0': return UC_CATEGORY_N;
-          case 'd': return UC_CATEGORY_Nd;
-          case 'l': return UC_CATEGORY_Nl;
-          case 'o': return UC_CATEGORY_No;
-          }
-        break;
-      case 'P':
-        switch (category_name[1])
+      }
+      /* Here q == buf + len.  */
+
+      /* Do a hash table lookup, with case-insensitive comparison.  */
+      found = uc_general_category_lookup (buf, len);
+      if (found != NULL)
+        /* Use a 'switch' statement here, because a table would introduce
+           load-time relocations.  */
+        switch (found->category_index)
           {
-          case '\0': return UC_CATEGORY_P;
-          case 'c': return UC_CATEGORY_Pc;
-          case 'd': return UC_CATEGORY_Pd;
-          case 's': return UC_CATEGORY_Ps;
-          case 'e': return UC_CATEGORY_Pe;
-          case 'i': return UC_CATEGORY_Pi;
-          case 'f': return UC_CATEGORY_Pf;
-          case 'o': return UC_CATEGORY_Po;
-          }
-        break;
-      case 'S':
-        switch (category_name[1])
-          {
-          case '\0': return UC_CATEGORY_S;
-          case 'm': return UC_CATEGORY_Sm;
-          case 'c': return UC_CATEGORY_Sc;
-          case 'k': return UC_CATEGORY_Sk;
-          case 'o': return UC_CATEGORY_So;
+          case UC_CATEGORY_INDEX_L:
+            return UC_CATEGORY_L;
+          case UC_CATEGORY_INDEX_LC:
+            return UC_CATEGORY_LC;
+          case UC_CATEGORY_INDEX_Lu:
+            return UC_CATEGORY_Lu;
+          case UC_CATEGORY_INDEX_Ll:
+            return UC_CATEGORY_Ll;
+          case UC_CATEGORY_INDEX_Lt:
+            return UC_CATEGORY_Lt;
+          case UC_CATEGORY_INDEX_Lm:
+            return UC_CATEGORY_Lm;
+          case UC_CATEGORY_INDEX_Lo:
+            return UC_CATEGORY_Lo;
+          case UC_CATEGORY_INDEX_M:
+            return UC_CATEGORY_M;
+          case UC_CATEGORY_INDEX_Mn:
+            return UC_CATEGORY_Mn;
+          case UC_CATEGORY_INDEX_Mc:
+            return UC_CATEGORY_Mc;
+          case UC_CATEGORY_INDEX_Me:
+            return UC_CATEGORY_Me;
+          case UC_CATEGORY_INDEX_N:
+            return UC_CATEGORY_N;
+          case UC_CATEGORY_INDEX_Nd:
+            return UC_CATEGORY_Nd;
+          case UC_CATEGORY_INDEX_Nl:
+            return UC_CATEGORY_Nl;
+          case UC_CATEGORY_INDEX_No:
+            return UC_CATEGORY_No;
+          case UC_CATEGORY_INDEX_P:
+            return UC_CATEGORY_P;
+          case UC_CATEGORY_INDEX_Pc:
+            return UC_CATEGORY_Pc;
+          case UC_CATEGORY_INDEX_Pd:
+            return UC_CATEGORY_Pd;
+          case UC_CATEGORY_INDEX_Ps:
+            return UC_CATEGORY_Ps;
+          case UC_CATEGORY_INDEX_Pe:
+            return UC_CATEGORY_Pe;
+          case UC_CATEGORY_INDEX_Pi:
+            return UC_CATEGORY_Pi;
+          case UC_CATEGORY_INDEX_Pf:
+            return UC_CATEGORY_Pf;
+          case UC_CATEGORY_INDEX_Po:
+            return UC_CATEGORY_Po;
+          case UC_CATEGORY_INDEX_S:
+            return UC_CATEGORY_S;
+          case UC_CATEGORY_INDEX_Sm:
+            return UC_CATEGORY_Sm;
+          case UC_CATEGORY_INDEX_Sc:
+            return UC_CATEGORY_Sc;
+          case UC_CATEGORY_INDEX_Sk:
+            return UC_CATEGORY_Sk;
+          case UC_CATEGORY_INDEX_So:
+            return UC_CATEGORY_So;
+          case UC_CATEGORY_INDEX_Z:
+            return UC_CATEGORY_Z;
+          case UC_CATEGORY_INDEX_Zs:
+            return UC_CATEGORY_Zs;
+          case UC_CATEGORY_INDEX_Zl:
+            return UC_CATEGORY_Zl;
+          case UC_CATEGORY_INDEX_Zp:
+            return UC_CATEGORY_Zp;
+          case UC_CATEGORY_INDEX_C:
+            return UC_CATEGORY_C;
+          case UC_CATEGORY_INDEX_Cc:
+            return UC_CATEGORY_Cc;
+          case UC_CATEGORY_INDEX_Cf:
+            return UC_CATEGORY_Cf;
+          case UC_CATEGORY_INDEX_Cs:
+            return UC_CATEGORY_Cs;
+          case UC_CATEGORY_INDEX_Co:
+            return UC_CATEGORY_Co;
+          case UC_CATEGORY_INDEX_Cn:
+            return UC_CATEGORY_Cn;
+          default:
+            abort ();
           }
-        break;
-      case 'Z':
-        switch (category_name[1])
-          {
-          case '\0': return UC_CATEGORY_Z;
-          case 's': return UC_CATEGORY_Zs;
-          case 'l': return UC_CATEGORY_Zl;
-          case 'p': return UC_CATEGORY_Zp;
-          }
-        break;
-      case 'C':
-        switch (category_name[1])
-          {
-          case '\0': return UC_CATEGORY_C;
-          case 'c': return UC_CATEGORY_Cc;
-          case 'f': return UC_CATEGORY_Cf;
-          case 's': return UC_CATEGORY_Cs;
-          case 'o': return UC_CATEGORY_Co;
-          case 'n': return UC_CATEGORY_Cn;
-          }
-        break;
-      }
+    }
   /* Invalid category name.  */
   return _UC_CATEGORY_NONE;
 }
new file mode 100644
--- /dev/null
+++ b/lib/unictype/categ_byname.gperf
@@ -0,0 +1,116 @@
+/* Categories of Unicode characters.  */
+struct named_category { int name; unsigned int category_index; };
+%struct-type
+%ignore-case
+%language=ANSI-C
+%define hash-function-name general_category_hash
+%define lookup-function-name uc_general_category_lookup
+%readonly-tables
+%global-table
+%define word-array-name general_category_names
+%pic
+%define string-pool-name general_category_stringpool
+%%
+L, UC_CATEGORY_INDEX_L
+LC, UC_CATEGORY_INDEX_LC
+Lu, UC_CATEGORY_INDEX_Lu
+Ll, UC_CATEGORY_INDEX_Ll
+Lt, UC_CATEGORY_INDEX_Lt
+Lm, UC_CATEGORY_INDEX_Lm
+Lo, UC_CATEGORY_INDEX_Lo
+M, UC_CATEGORY_INDEX_M
+Mn, UC_CATEGORY_INDEX_Mn
+Mc, UC_CATEGORY_INDEX_Mc
+Me, UC_CATEGORY_INDEX_Me
+N, UC_CATEGORY_INDEX_N
+Nd, UC_CATEGORY_INDEX_Nd
+Nl, UC_CATEGORY_INDEX_Nl
+No, UC_CATEGORY_INDEX_No
+P, UC_CATEGORY_INDEX_P
+Pc, UC_CATEGORY_INDEX_Pc
+Pd, UC_CATEGORY_INDEX_Pd
+Ps, UC_CATEGORY_INDEX_Ps
+Pe, UC_CATEGORY_INDEX_Pe
+Pi, UC_CATEGORY_INDEX_Pi
+Pf, UC_CATEGORY_INDEX_Pf
+Po, UC_CATEGORY_INDEX_Po
+S, UC_CATEGORY_INDEX_S
+Sm, UC_CATEGORY_INDEX_Sm
+Sc, UC_CATEGORY_INDEX_Sc
+Sk, UC_CATEGORY_INDEX_Sk
+So, UC_CATEGORY_INDEX_So
+Z, UC_CATEGORY_INDEX_Z
+Zs, UC_CATEGORY_INDEX_Zs
+Zl, UC_CATEGORY_INDEX_Zl
+Zp, UC_CATEGORY_INDEX_Zp
+C, UC_CATEGORY_INDEX_C
+Cc, UC_CATEGORY_INDEX_Cc
+Cf, UC_CATEGORY_INDEX_Cf
+Cs, UC_CATEGORY_INDEX_Cs
+Co, UC_CATEGORY_INDEX_Co
+Cn, UC_CATEGORY_INDEX_Cn
+Letter, UC_CATEGORY_INDEX_L
+Cased Letter, UC_CATEGORY_INDEX_LC
+CasedLetter, UC_CATEGORY_INDEX_LC
+Uppercase Letter, UC_CATEGORY_INDEX_Lu
+UppercaseLetter, UC_CATEGORY_INDEX_Lu
+Lowercase Letter, UC_CATEGORY_INDEX_Ll
+LowercaseLetter, UC_CATEGORY_INDEX_Ll
+Titlecase Letter, UC_CATEGORY_INDEX_Lt
+TitlecaseLetter, UC_CATEGORY_INDEX_Lt
+Modifier Letter, UC_CATEGORY_INDEX_Lm
+ModifierLetter, UC_CATEGORY_INDEX_Lm
+Other Letter, UC_CATEGORY_INDEX_Lo
+OtherLetter, UC_CATEGORY_INDEX_Lo
+Mark, UC_CATEGORY_INDEX_M
+Nonspacing Mark, UC_CATEGORY_INDEX_Mn
+NonspacingMark, UC_CATEGORY_INDEX_Mn
+Spacing Mark, UC_CATEGORY_INDEX_Mc
+SpacingMark, UC_CATEGORY_INDEX_Mc
+Enclosing Mark, UC_CATEGORY_INDEX_Me
+EnclosingMark, UC_CATEGORY_INDEX_Me
+Number, UC_CATEGORY_INDEX_N
+Decimal Number, UC_CATEGORY_INDEX_Nd
+DecimalNumber, UC_CATEGORY_INDEX_Nd
+Letter Number, UC_CATEGORY_INDEX_Nl
+LetterNumber, UC_CATEGORY_INDEX_Nl
+Other Number, UC_CATEGORY_INDEX_No
+OtherNumber, UC_CATEGORY_INDEX_No
+Punctuation, UC_CATEGORY_INDEX_P
+Connector Punctuation, UC_CATEGORY_INDEX_Pc
+ConnectorPunctuation, UC_CATEGORY_INDEX_Pc
+Dash Punctuation, UC_CATEGORY_INDEX_Pd
+DashPunctuation, UC_CATEGORY_INDEX_Pd
+Open Punctuation, UC_CATEGORY_INDEX_Ps
+OpenPunctuation, UC_CATEGORY_INDEX_Ps
+Close Punctuation, UC_CATEGORY_INDEX_Pe
+ClosePunctuation, UC_CATEGORY_INDEX_Pe
+Initial Punctuation, UC_CATEGORY_INDEX_Pi
+InitialPunctuation, UC_CATEGORY_INDEX_Pi
+Final Punctuation, UC_CATEGORY_INDEX_Pf
+FinalPunctuation, UC_CATEGORY_INDEX_Pf
+Other Punctuation, UC_CATEGORY_INDEX_Po
+OtherPunctuation, UC_CATEGORY_INDEX_Po
+Symbol, UC_CATEGORY_INDEX_S
+Math Symbol, UC_CATEGORY_INDEX_Sm
+MathSymbol, UC_CATEGORY_INDEX_Sm
+Currency Symbol, UC_CATEGORY_INDEX_Sc
+CurrencySymbol, UC_CATEGORY_INDEX_Sc
+Modifier Symbol, UC_CATEGORY_INDEX_Sk
+ModifierSymbol, UC_CATEGORY_INDEX_Sk
+Other Symbol, UC_CATEGORY_INDEX_So
+OtherSymbol, UC_CATEGORY_INDEX_So
+Separator, UC_CATEGORY_INDEX_Z
+Space Separator, UC_CATEGORY_INDEX_Zs
+SpaceSeparator, UC_CATEGORY_INDEX_Zs
+Line Separator, UC_CATEGORY_INDEX_Zl
+LineSeparator, UC_CATEGORY_INDEX_Zl
+Paragraph Separator, UC_CATEGORY_INDEX_Zp
+ParagraphSeparator, UC_CATEGORY_INDEX_Zp
+Other, UC_CATEGORY_INDEX_C
+Control, UC_CATEGORY_INDEX_Cc
+Format, UC_CATEGORY_INDEX_Cf
+Surrogate, UC_CATEGORY_INDEX_Cs
+Private Use, UC_CATEGORY_INDEX_Co
+PrivateUse, UC_CATEGORY_INDEX_Co
+Unassigned, UC_CATEGORY_INDEX_Cn
new file mode 100644
--- /dev/null
+++ b/lib/unictype/categ_longname.c
@@ -0,0 +1,106 @@
+/* Categories of Unicode characters.
+   Copyright (C) 2002, 2006-2007, 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "unictype.h"
+
+static const char u_category_long_name[30][22] =
+{
+  "Uppercase Letter",
+  "Lowercase Letter",
+  "Titlecase Letter",
+  "Modifier Letter",
+  "Other Letter",
+  "Nonspacing Mark",
+  "Spacing Mark",
+  "Enclosing Mark",
+  "Decimal Number",
+  "Letter Number",
+  "Other Number",
+  "Connector Punctuation",
+  "Dash Punctuation",
+  "Open Punctuation",
+  "Close Punctuation",
+  "Initial Punctuation",
+  "Final Punctuation",
+  "Other Punctuation",
+  "Math Symbol",
+  "Currency Symbol",
+  "Modifier Symbol",
+  "Other Symbol",
+  "Space Separator",
+  "Line Separator",
+  "Paragraph Separator",
+  "Control",
+  "Format",
+  "Surrogate",
+  "Private Use",
+  "Unassigned"
+};
+
+const char *
+uc_general_category_long_name (uc_general_category_t category)
+{
+  uint32_t bitmask = category.bitmask;
+  /* bitmask should consist of a single bit.  */
+  if (bitmask != 0)
+    {
+      if ((bitmask & (bitmask - 1)) == 0)
+        {
+          int bit;
+          /* Take log2 using a variant of Robert Harley's method.
+             Found by Bruno Haible 1996.  */
+          uint32_t n = bitmask;
+          static const char ord2_tab[64] =
+            {
+              -1,  0,  1, 12,  2,  6, -1, 13,  3, -1,  7, -1, -1, -1, -1, 14,
+              10,  4, -1, -1,  8, -1, -1, 25, -1, -1, -1, -1, -1, 21, 27, 15,
+              31, 11,  5, -1, -1, -1, -1, -1,  9, -1, -1, 24, -1, -1, 20, 26,
+              30, -1, -1, -1, -1, 23, -1, 19, 29, -1, 22, 18, 28, 17, 16, -1
+            };
+          n += n << 4;
+          n += n << 6;
+          n = (n << 16) - n;
+          bit = ord2_tab[n >> 26];
+
+          if (bit < sizeof (u_category_long_name) / sizeof (u_category_long_name[0]))
+            return u_category_long_name[bit];
+        }
+      else
+        {
+          if (bitmask == UC_CATEGORY_MASK_L)
+            return "Letter";
+          if (bitmask == UC_CATEGORY_MASK_LC)
+            return "Cased Letter";
+          if (bitmask == UC_CATEGORY_MASK_M)
+            return "Mark";
+          if (bitmask == UC_CATEGORY_MASK_N)
+            return "Number";
+          if (bitmask == UC_CATEGORY_MASK_P)
+            return "Punctuation";
+          if (bitmask == UC_CATEGORY_MASK_S)
+            return "Symbol";
+          if (bitmask == UC_CATEGORY_MASK_Z)
+            return "Separator";
+          if (bitmask == UC_CATEGORY_MASK_C)
+            return "Other";
+        }
+    }
+  return NULL;
+}
--- a/lib/unictype/categ_name.c
+++ b/lib/unictype/categ_name.c
@@ -1,5 +1,5 @@
 /* Categories of Unicode characters.
-   Copyright (C) 2002, 2006-2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2006-2007, 2011 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2002.
 
    This program is free software: you can redistribute it and/or modify it
@@ -59,6 +59,8 @@
         {
           if (bitmask == UC_CATEGORY_MASK_L)
             return "L";
+          if (bitmask == UC_CATEGORY_MASK_LC)
+            return "LC";
           if (bitmask == UC_CATEGORY_MASK_M)
             return "M";
           if (bitmask == UC_CATEGORY_MASK_N)
deleted file mode 100644
--- a/lib/unictype/combining.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/* Combining classes of Unicode characters.
-   Copyright (C) 2002, 2006, 2009-2011 Free Software Foundation, Inc.
-   Written by Bruno Haible <bruno@clisp.org>, 2002.
-
-   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 "unictype.h"
-
-/* Define u_combclass table.  */
-#include "combining.h"
-
-int
-uc_combining_class (ucs4_t uc)
-{
-  unsigned int index1 = uc >> combclass_header_0;
-  if (index1 < combclass_header_1)
-    {
-      int lookup1 = u_combclass.level1[index1];
-      if (lookup1 >= 0)
-        {
-          unsigned int index2 = (uc >> combclass_header_2) & combclass_header_3;
-          int lookup2 = u_combclass.level2[lookup1 + index2];
-          if (lookup2 >= 0)
-            {
-              unsigned int index3 = (uc & combclass_header_4);
-              unsigned int lookup3 = u_combclass.level3[lookup2 + index3];
-
-              return lookup3;
-            }
-        }
-    }
-  return 0;
-}
deleted file mode 100644
--- a/lib/unictype/combining.h
+++ /dev/null
@@ -1,999 +0,0 @@
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
-/* Combining class of Unicode characters.  */
-/* Generated automatically by gen-uni-tables.c for Unicode 6.0.0.  */
-#define combclass_header_0 16
-#define combclass_header_1 2
-#define combclass_header_2 7
-#define combclass_header_3 511
-#define combclass_header_4 127
-static const
-struct
-  {
-    int level1[2];
-    short level2[2 << 9];
-    unsigned char level3[53 << 7];
-  }
-u_combclass =
-{
-  {     0,   512 },
-  {
-       -1,    -1,    -1,    -1,    -1,    -1,     0,    -1,
-       -1,   128,    -1,   256,   384,   512,   640,   768,
-      896,    -1,  1024,  1152,  1152,  1152,  1152,  1280,
-     1408,  1152,  1280,  1536,  1664,  1792,  1920,  2048,
-     2176,  2304,    -1,    -1,    -1,    -1,  2432,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,  2560,  2688,
-       -1,  2816,  2944,    -1,  3072,    -1,  3200,  3328,
-     3456,  3584,    -1,  3712,    -1,    -1,    -1,    -1,
-       -1,  3840,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,  3968,  4096,  4224,    -1,    -1,    -1,    -1,
-     4352,  4480,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,  4608,  4736,    -1,    -1,
-     4864,  4992,  5120,  5248,    -1,  5376,    -1,  5504,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,  5632,    -1,
-       -1,    -1,    -1,    -1,  5760,    -1,    -1,    -1,
-       -1,    -1,    -1,  5888,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,  6016,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-     6144,  6272,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,  6400,  6528,  6656,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1
-  },
-  {
-    230, 230, 230, 230, 230, 230, 230, 230,
-    230, 230, 230, 230, 230, 230, 230, 230,
-    230, 230, 230, 230, 230, 232, 220, 220,
-    220, 220, 232, 216, 220, 220, 220, 220,
-    220, 202, 202, 220, 220, 220, 220, 202,
-    202, 220, 220, 220, 220, 220, 220, 220,
-    220, 220, 220, 220,   1,   1,   1,   1,
-      1, 220, 220, 220, 220, 230, 230, 230,
-    230, 230, 230, 230, 230, 240, 230, 220,
-    220, 220, 230, 230, 230, 220, 220,   0,
-    230, 230, 230, 220, 220, 220, 220, 230,
-    232, 220, 220, 230, 233, 234, 234, 233,
-    234, 234, 233, 230, 230, 230, 230, 230,
-    230, 230, 230, 230, 230, 230, 230, 230,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0, 230, 230, 230, 230, 230,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0, 220, 230, 230, 230, 230, 220, 230,
-    230, 230, 222, 220, 230, 230, 230, 230,
-    230, 230, 220, 220, 220, 220, 220, 220,
-    230, 230, 220, 230, 230, 222, 228, 230,
-     10,  11,  12,  13,  14,  15,  16,  17,
-     18,  19,  19,  20,  21,  22,   0,  23,
-      0,  24,  25,   0, 230, 220,   0,  18,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-    230, 230, 230, 230, 230, 230, 230, 230,
-     30,  31,  32,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,  27,  28,  29,  30,  31,
-     32,  33,  34, 230, 230, 220, 220, 230,
-    230, 230, 230, 230, 220, 230, 230, 220,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-     35,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0, 230, 230,
-    230, 230, 230, 230, 230,   0,   0, 230,
-    230, 230, 230, 220, 230,   0,   0, 230,
-    230,   0, 220, 230, 230, 220,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,  36,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-    230, 220, 230, 230, 220, 230, 230, 220,
-    220, 220, 230, 220, 220, 230, 220, 230,
-    230, 230, 220, 230, 220, 230, 220, 230,
-    220, 230, 230,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0, 230, 230, 230, 230, 230,
-    230, 230, 220, 230,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0, 230, 230,
-    230, 230,   0, 230, 230, 230, 230, 230,
-    230, 230, 230, 230,   0, 230, 230, 230,
-      0, 230, 230, 230, 230, 230,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0, 220, 220, 220,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   7,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   9,   0,   0,
-      0, 230, 220, 230, 230,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   7,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   9,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   9,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   9,   0,   0,
-      0,   0,   0,   0,   0,  84,  91,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   9,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-    103, 103,   9,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-    107, 107, 107, 107,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-    118, 118,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-    122, 122, 122, 122,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-    220, 220,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0, 220,   0, 220,
-      0, 216,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0, 129, 130,   0, 132,   0,   0,   0,
-      0,   0, 130, 130, 130, 130,   0,   0,
-    130,   0, 230, 230,   9,   0, 230, 230,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0, 220,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   7,
-      0,   9,   9,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0, 220,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0, 230, 230, 230,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   9,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   9,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   9,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0, 230,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0, 228,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0, 222, 230, 220,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0, 230,
-    220,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      9,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0, 230, 230, 230,
-    230, 230, 230, 230, 230,   0,   0, 220,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   7,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   9,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0, 230, 220, 230, 230, 230,
-    230, 230, 230, 230,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   9,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   7,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   9,   9,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   7,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-    230, 230, 230,   0,   1, 220, 220, 220,
-    220, 220, 230, 230, 220, 220, 220, 220,
-    230,   0,   1,   1,   1,   1,   1,   1,
-      1,   0,   0,   0,   0, 220,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-    230, 230, 220, 230, 230, 230, 230, 230,
-    230, 230, 220, 230, 230, 234, 214, 220,
-    202, 230, 230, 230, 230, 230, 230, 230,
-    230, 230, 230, 230, 230, 230, 230, 230,
-    230, 230, 230, 230, 230, 230, 230,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0, 233, 220, 230, 220,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-    230, 230,   1,   1, 230, 230, 230, 230,
-      1,   1,   1, 230, 230,   0,   0,   0,
-      0, 230,   0,   0,   0,   1,   1, 230,
-    220, 230,   1,   1, 220, 220, 220, 220,
-    230,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0, 230,
-    230, 230,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   9,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-    230, 230, 230, 230, 230, 230, 230, 230,
-    230, 230, 230, 230, 230, 230, 230, 230,
-    230, 230, 230, 230, 230, 230, 230, 230,
-    230, 230, 230, 230, 230, 230, 230, 230,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0, 218, 228, 232, 222, 224, 224,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   8,   8,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0, 230,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0, 230, 230,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-    230, 230,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   9,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   9,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-    230, 230, 230, 230, 230, 230, 230, 230,
-    230, 230, 230, 230, 230, 230, 230, 230,
-    230, 230,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0, 220, 220, 220,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   9,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   7,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      9,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-    230,   0, 230, 230, 220,   0,   0, 230,
-    230,   0,   0,   0,   0,   0, 230, 230,
-      0, 230,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   9,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,  26,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-    230, 230, 230, 230, 230, 230, 230,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0, 220,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0, 220,   0, 230,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-    230,   1, 220,   0,   0,   0,   0,   9,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   9,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   9,   7,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0, 216, 216,   1,
-      1,   1,   0,   0,   0, 226, 216, 216,
-    216, 216, 216,   0,   0,   0,   0,   0,
-      0,   0,   0, 220, 220, 220, 220, 220,
-    220, 220, 220,   0,   0, 230, 230, 230,
-    230, 230, 220, 220,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0, 230, 230, 230, 230,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0, 230, 230, 230,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0,
-      0,   0,   0,   0,   0,   0,   0,   0
-  }
-};
new file mode 100644
--- /dev/null
+++ b/lib/unictype/combiningclass.c
@@ -0,0 +1,47 @@
+/* Combining classes of Unicode characters.
+   Copyright (C) 2002, 2006, 2009-2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2002.
+
+   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 "unictype.h"
+
+/* Define u_combclass table.  */
+#include "combiningclass.h"
+
+int
+uc_combining_class (ucs4_t uc)
+{
+  unsigned int index1 = uc >> combclass_header_0;
+  if (index1 < combclass_header_1)
+    {
+      int lookup1 = u_combclass.level1[index1];
+      if (lookup1 >= 0)
+        {
+          unsigned int index2 = (uc >> combclass_header_2) & combclass_header_3;
+          int lookup2 = u_combclass.level2[lookup1 + index2];
+          if (lookup2 >= 0)
+            {
+              unsigned int index3 = (uc & combclass_header_4);
+              unsigned int lookup3 = u_combclass.level3[lookup2 + index3];
+
+              return lookup3;
+            }
+        }
+    }
+  return 0;
+}
new file mode 100644
--- /dev/null
+++ b/lib/unictype/combiningclass.h
@@ -0,0 +1,999 @@
+/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
+/* Combining class of Unicode characters.  */
+/* Generated automatically by gen-uni-tables.c for Unicode 6.0.0.  */
+#define combclass_header_0 16
+#define combclass_header_1 2
+#define combclass_header_2 7
+#define combclass_header_3 511
+#define combclass_header_4 127
+static const
+struct
+  {
+    int level1[2];
+    short level2[2 << 9];
+    unsigned char level3[53 << 7];
+  }
+u_combclass =
+{
+  {     0,   512 },
+  {
+       -1,    -1,    -1,    -1,    -1,    -1,     0,    -1,
+       -1,   128,    -1,   256,   384,   512,   640,   768,
+      896,    -1,  1024,  1152,  1152,  1152,  1152,  1280,
+     1408,  1152,  1280,  1536,  1664,  1792,  1920,  2048,
+     2176,  2304,    -1,    -1,    -1,    -1,  2432,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,  2560,  2688,
+       -1,  2816,  2944,    -1,  3072,    -1,  3200,  3328,
+     3456,  3584,    -1,  3712,    -1,    -1,    -1,    -1,
+       -1,  3840,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,  3968,  4096,  4224,    -1,    -1,    -1,    -1,
+     4352,  4480,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,  4608,  4736,    -1,    -1,
+     4864,  4992,  5120,  5248,    -1,  5376,    -1,  5504,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,  5632,    -1,
+       -1,    -1,    -1,    -1,  5760,    -1,    -1,    -1,
+       -1,    -1,    -1,  5888,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,  6016,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+     6144,  6272,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,  6400,  6528,  6656,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1
+  },
+  {
+    230, 230, 230, 230, 230, 230, 230, 230,
+    230, 230, 230, 230, 230, 230, 230, 230,
+    230, 230, 230, 230, 230, 232, 220, 220,
+    220, 220, 232, 216, 220, 220, 220, 220,
+    220, 202, 202, 220, 220, 220, 220, 202,
+    202, 220, 220, 220, 220, 220, 220, 220,
+    220, 220, 220, 220,   1,   1,   1,   1,
+      1, 220, 220, 220, 220, 230, 230, 230,
+    230, 230, 230, 230, 230, 240, 230, 220,
+    220, 220, 230, 230, 230, 220, 220,   0,
+    230, 230, 230, 220, 220, 220, 220, 230,
+    232, 220, 220, 230, 233, 234, 234, 233,
+    234, 234, 233, 230, 230, 230, 230, 230,
+    230, 230, 230, 230, 230, 230, 230, 230,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0, 230, 230, 230, 230, 230,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0, 220, 230, 230, 230, 230, 220, 230,
+    230, 230, 222, 220, 230, 230, 230, 230,
+    230, 230, 220, 220, 220, 220, 220, 220,
+    230, 230, 220, 230, 230, 222, 228, 230,
+     10,  11,  12,  13,  14,  15,  16,  17,
+     18,  19,  19,  20,  21,  22,   0,  23,
+      0,  24,  25,   0, 230, 220,   0,  18,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+    230, 230, 230, 230, 230, 230, 230, 230,
+     30,  31,  32,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,  27,  28,  29,  30,  31,
+     32,  33,  34, 230, 230, 220, 220, 230,
+    230, 230, 230, 230, 220, 230, 230, 220,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+     35,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0, 230, 230,
+    230, 230, 230, 230, 230,   0,   0, 230,
+    230, 230, 230, 220, 230,   0,   0, 230,
+    230,   0, 220, 230, 230, 220,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,  36,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+    230, 220, 230, 230, 220, 230, 230, 220,
+    220, 220, 230, 220, 220, 230, 220, 230,
+    230, 230, 220, 230, 220, 230, 220, 230,
+    220, 230, 230,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0, 230, 230, 230, 230, 230,
+    230, 230, 220, 230,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0, 230, 230,
+    230, 230,   0, 230, 230, 230, 230, 230,
+    230, 230, 230, 230,   0, 230, 230, 230,
+      0, 230, 230, 230, 230, 230,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0, 220, 220, 220,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   7,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   9,   0,   0,
+      0, 230, 220, 230, 230,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   7,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   9,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   9,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   9,   0,   0,
+      0,   0,   0,   0,   0,  84,  91,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   9,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+    103, 103,   9,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+    107, 107, 107, 107,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+    118, 118,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+    122, 122, 122, 122,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+    220, 220,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0, 220,   0, 220,
+      0, 216,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0, 129, 130,   0, 132,   0,   0,   0,
+      0,   0, 130, 130, 130, 130,   0,   0,
+    130,   0, 230, 230,   9,   0, 230, 230,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0, 220,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   7,
+      0,   9,   9,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0, 220,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0, 230, 230, 230,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   9,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   9,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   9,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0, 230,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0, 228,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0, 222, 230, 220,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0, 230,
+    220,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      9,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0, 230, 230, 230,
+    230, 230, 230, 230, 230,   0,   0, 220,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   7,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   9,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0, 230, 220, 230, 230, 230,
+    230, 230, 230, 230,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   9,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   7,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   9,   9,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   7,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+    230, 230, 230,   0,   1, 220, 220, 220,
+    220, 220, 230, 230, 220, 220, 220, 220,
+    230,   0,   1,   1,   1,   1,   1,   1,
+      1,   0,   0,   0,   0, 220,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+    230, 230, 220, 230, 230, 230, 230, 230,
+    230, 230, 220, 230, 230, 234, 214, 220,
+    202, 230, 230, 230, 230, 230, 230, 230,
+    230, 230, 230, 230, 230, 230, 230, 230,
+    230, 230, 230, 230, 230, 230, 230,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0, 233, 220, 230, 220,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+    230, 230,   1,   1, 230, 230, 230, 230,
+      1,   1,   1, 230, 230,   0,   0,   0,
+      0, 230,   0,   0,   0,   1,   1, 230,
+    220, 230,   1,   1, 220, 220, 220, 220,
+    230,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0, 230,
+    230, 230,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   9,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+    230, 230, 230, 230, 230, 230, 230, 230,
+    230, 230, 230, 230, 230, 230, 230, 230,
+    230, 230, 230, 230, 230, 230, 230, 230,
+    230, 230, 230, 230, 230, 230, 230, 230,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0, 218, 228, 232, 222, 224, 224,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   8,   8,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0, 230,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0, 230, 230,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+    230, 230,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   9,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   9,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+    230, 230, 230, 230, 230, 230, 230, 230,
+    230, 230, 230, 230, 230, 230, 230, 230,
+    230, 230,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0, 220, 220, 220,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   9,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   7,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      9,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+    230,   0, 230, 230, 220,   0,   0, 230,
+    230,   0,   0,   0,   0,   0, 230, 230,
+      0, 230,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   9,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,  26,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+    230, 230, 230, 230, 230, 230, 230,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0, 220,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0, 220,   0, 230,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+    230,   1, 220,   0,   0,   0,   0,   9,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   9,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   9,   7,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0, 216, 216,   1,
+      1,   1,   0,   0,   0, 226, 216, 216,
+    216, 216, 216,   0,   0,   0,   0,   0,
+      0,   0,   0, 220, 220, 220, 220, 220,
+    220, 220, 220,   0,   0, 230, 230, 230,
+    230, 230, 220, 220,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0, 230, 230, 230, 230,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0, 230, 230, 230,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0,
+      0,   0,   0,   0,   0,   0,   0,   0
+  }
+};
new file mode 100644
--- /dev/null
+++ b/lib/unictype/combiningclass_byname.c
@@ -0,0 +1,63 @@
+/* Canonical combining classes of Unicode characters.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "unictype.h"
+
+#include <string.h>
+
+#include "unictype/combiningclass_byname.h"
+
+int
+uc_combining_class_byname (const char *ccc_name)
+{
+  size_t len;
+
+  len = strlen (ccc_name);
+  if (len <= MAX_WORD_LENGTH)
+    {
+      char buf[MAX_WORD_LENGTH + 1];
+      const struct named_combining_class *found;
+
+      /* Copy ccc_name into buf, converting '_' and '-' to ' '.  */
+      {
+        const char *p = ccc_name;
+        char *q = buf;
+
+        for (;; p++, q++)
+          {
+            char c = *p;
+
+            if (c == '_' || c == '-')
+              c = ' ';
+            *q = c;
+            if (c == '\0')
+              break;
+          }
+      }
+      /* Here q == buf + len.  */
+
+      /* Do a hash table lookup, with case-insensitive comparison.  */
+      found = uc_combining_class_lookup (buf, len);
+      if (found != NULL)
+        return found->combining_class;
+    }
+  /* Invalid combining class name.  */
+  return -1;
+}
new file mode 100644
--- /dev/null
+++ b/lib/unictype/combiningclass_byname.gperf
@@ -0,0 +1,66 @@
+/* Categories of Unicode characters.  */
+struct named_combining_class { int name; int combining_class; };
+%struct-type
+%ignore-case
+%language=ANSI-C
+%define hash-function-name combining_class_hash
+%define lookup-function-name uc_combining_class_lookup
+%readonly-tables
+%global-table
+%define word-array-name combining_class_names
+%pic
+%define string-pool-name combining_class_stringpool
+%%
+NR, UC_CCC_NR
+OV, UC_CCC_OV
+NK, UC_CCC_NK
+KV, UC_CCC_KV
+VR, UC_CCC_VR
+ATBL, UC_CCC_ATBL
+ATB, UC_CCC_ATB
+ATA, UC_CCC_ATA
+ATAR, UC_CCC_ATAR
+BL, UC_CCC_BL
+B, UC_CCC_B
+BR, UC_CCC_BR
+L, UC_CCC_L
+R, UC_CCC_R
+AL, UC_CCC_AL
+A, UC_CCC_A
+AR, UC_CCC_AR
+DB, UC_CCC_DB
+DA, UC_CCC_DA
+IS, UC_CCC_IS
+Not Reordered, UC_CCC_NR
+NotReordered, UC_CCC_NR
+Overlay, UC_CCC_OV
+Nukta, UC_CCC_NK
+Kana Voicing, UC_CCC_KV
+KanaVoicing, UC_CCC_KV
+Virama, UC_CCC_VR
+Attached Below Left, UC_CCC_ATBL
+AttachedBelowLeft, UC_CCC_ATBL
+Attached Below, UC_CCC_ATB
+AttachedBelow, UC_CCC_ATB
+Attached Above, UC_CCC_ATA
+AttachedAbove, UC_CCC_ATA
+Attached Above Right, UC_CCC_ATAR
+AttachedAboveRight, UC_CCC_ATAR
+Below Left, UC_CCC_BL
+BelowLeft, UC_CCC_BL
+Below, UC_CCC_B
+Below Right, UC_CCC_BR
+BelowRight, UC_CCC_BR
+Left, UC_CCC_L
+Right, UC_CCC_R
+Above Left, UC_CCC_AL
+AboveLeft, UC_CCC_AL
+Above, UC_CCC_A
+Above Right, UC_CCC_AR
+AboveRight, UC_CCC_AR
+Double Below, UC_CCC_DB
+DoubleBelow, UC_CCC_DB
+Double Above, UC_CCC_DA
+DoubleAbove, UC_CCC_DA
+Iota Subscript, UC_CCC_IS
+IotaSubscript, UC_CCC_IS
new file mode 100644
--- /dev/null
+++ b/lib/unictype/combiningclass_longname.c
@@ -0,0 +1,130 @@
+/* Canonical combining classes of Unicode characters.
+   Copyright (C) 2002, 2006-2007, 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "unictype.h"
+
+#include <stdlib.h>
+
+static const signed char u_combining_class_index_part1[10] =
+{
+   0, /* Not Reordered */
+   1, /* Overlay */
+  -1,
+  -1,
+  -1,
+  -1,
+  -1,
+   2, /* Nukta */
+   3, /* Kana Voicing */
+   4  /* Virama */
+};
+static const signed char u_combining_class_index_part2[241 - 200] =
+{
+   5, /* Attached Below Left */
+  -1,
+   6, /* Attached Below */
+  -1,
+  -1,
+  -1,
+  -1,
+  -1,
+  -1,
+  -1,
+  -1,
+  -1,
+  -1,
+  -1,
+   7, /* Attached Above */
+  -1,
+   8, /* Attached Above Right */
+  -1,
+   9, /* Below Left */
+  -1,
+  10, /* Below */
+  -1,
+  11, /* Below Right */
+  -1,
+  12, /* Left */
+  -1,
+  13, /* Right */
+  -1,
+  14, /* Above Left */
+  -1,
+  15, /* Above */
+  -1,
+  16, /* Above Right */
+  17, /* Double Below */
+  18, /* Double Above */
+  -1,
+  -1,
+  -1,
+  -1,
+  -1,
+  19  /* Iota Subscript */
+};
+
+static const char u_combining_class_long_name[20][21] =
+{
+  "Not Reordered",
+  "Overlay",
+  "Nukta",
+  "Kana Voicing",
+  "Virama",
+  "Attached Below Left",
+  "Attached Below",
+  "Attached Above",
+  "Attached Above Right",
+  "Below Left",
+  "Below",
+  "Below Right",
+  "Left",
+  "Right",
+  "Above Left",
+  "Above",
+  "Above Right",
+  "Double Below",
+  "Double Above",
+  "Iota Subscript"
+};
+
+const char *
+uc_combining_class_long_name (int ccc)
+{
+  if (ccc >= 0)
+    {
+      int index;
+
+      if (ccc < 10)
+        index = u_combining_class_index_part1[ccc];
+      else if (ccc >= 200 && ccc < 241)
+        index = u_combining_class_index_part2[ccc - 200];
+      else
+        return NULL;
+
+      if (index >= 0)
+        {
+          if (index < sizeof (u_combining_class_long_name) / sizeof (u_combining_class_long_name[0]))
+            return u_combining_class_long_name[index];
+          else
+            abort ();
+        }
+    }
+  return NULL;
+}
new file mode 100644
--- /dev/null
+++ b/lib/unictype/combiningclass_name.c
@@ -0,0 +1,130 @@
+/* Canonical combining classes of Unicode characters.
+   Copyright (C) 2002, 2006-2007, 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "unictype.h"
+
+#include <stdlib.h>
+
+static const signed char u_combining_class_index_part1[10] =
+{
+   0, /* Not Reordered */
+   1, /* Overlay */
+  -1,
+  -1,
+  -1,
+  -1,
+  -1,
+   2, /* Nukta */
+   3, /* Kana Voicing */
+   4  /* Virama */
+};
+static const signed char u_combining_class_index_part2[241 - 200] =
+{
+   5, /* Attached Below Left */
+  -1,
+   6, /* Attached Below */
+  -1,
+  -1,
+  -1,
+  -1,
+  -1,
+  -1,
+  -1,
+  -1,
+  -1,
+  -1,
+  -1,
+   7, /* Attached Above */
+  -1,
+   8, /* Attached Above Right */
+  -1,
+   9, /* Below Left */
+  -1,
+  10, /* Below */
+  -1,
+  11, /* Below Right */
+  -1,
+  12, /* Left */
+  -1,
+  13, /* Right */
+  -1,
+  14, /* Above Left */
+  -1,
+  15, /* Above */
+  -1,
+  16, /* Above Right */
+  17, /* Double Below */
+  18, /* Double Above */
+  -1,
+  -1,
+  -1,
+  -1,
+  -1,
+  19  /* Iota Subscript */
+};
+
+static const char u_combining_class_name[20][5] =
+{
+  "NR",   /* Not Reordered */
+  "OV",   /* Overlay */
+  "NK",   /* Nukta */
+  "KV",   /* Kana Voicing */
+  "VR",   /* Virama */
+  "ATBL", /* Attached Below Left */
+  "ATB",  /* Attached Below */
+  "ATA",  /* Attached Above */
+  "ATAR", /* Attached Above Right */
+  "BL",   /* Below Left */
+  "B",    /* Below */
+  "BR",   /* Below Right */
+  "L",    /* Left */
+  "R",    /* Right */
+  "AL",   /* Above Left */
+  "A",    /* Above */
+  "AR",   /* Above Right */
+  "DB",   /* Double Below */
+  "DA",   /* Double Above */
+  "IS"    /* Iota Subscript */
+};
+
+const char *
+uc_combining_class_name (int ccc)
+{
+  if (ccc >= 0)
+    {
+      int index;
+
+      if (ccc < 10)
+        index = u_combining_class_index_part1[ccc];
+      else if (ccc >= 200 && ccc < 241)
+        index = u_combining_class_index_part2[ccc - 200];
+      else
+        return NULL;
+
+      if (index >= 0)
+        {
+          if (index < sizeof (u_combining_class_name) / sizeof (u_combining_class_name[0]))
+            return u_combining_class_name[index];
+          else
+            abort ();
+        }
+    }
+  return NULL;
+}
new file mode 100644
--- /dev/null
+++ b/lib/unictype/joininggroup_byname.c
@@ -0,0 +1,63 @@
+/* Arabic joining group of Unicode characters.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "unictype.h"
+
+#include <string.h>
+
+#include "unictype/joininggroup_byname.h"
+
+int
+uc_joining_group_byname (const char *joining_group_name)
+{
+  size_t len;
+
+  len = strlen (joining_group_name);
+  if (len <= MAX_WORD_LENGTH)
+    {
+      char buf[MAX_WORD_LENGTH + 1];
+      const struct named_joining_group *found;
+
+      /* Copy joining_group_name into buf, converting '_' and '-' to ' '.  */
+      {
+        const char *p = joining_group_name;
+        char *q = buf;
+
+        for (;; p++, q++)
+          {
+            char c = *p;
+
+            if (c == '_' || c == '-')
+              c = ' ';
+            *q = c;
+            if (c == '\0')
+              break;
+          }
+      }
+      /* Here q == buf + len.  */
+
+      /* Do a hash table lookup, with case-insensitive comparison.  */
+      found = uc_joining_group_lookup (buf, len);
+      if (found != NULL)
+        return found->joining_group;
+    }
+  /* Invalid joining group name.  */
+  return -1;
+}
new file mode 100644
--- /dev/null
+++ b/lib/unictype/joininggroup_byname.gperf
@@ -0,0 +1,85 @@
+/* Arabic joining group of Unicode characters.  */
+struct named_joining_group { int name; int joining_group; };
+%struct-type
+%ignore-case
+%language=ANSI-C
+%define hash-function-name joining_group_hash
+%define lookup-function-name uc_joining_group_lookup
+%readonly-tables
+%global-table
+%define word-array-name joining_group_names
+%pic
+%define string-pool-name joining_group_stringpool
+%%
+No Joining Group, UC_JOINING_GROUP_NONE
+NoJoiningGroup, UC_JOINING_GROUP_NONE
+Ain, UC_JOINING_GROUP_AIN
+Alaph, UC_JOINING_GROUP_ALAPH
+Alef, UC_JOINING_GROUP_ALEF
+Beh, UC_JOINING_GROUP_BEH
+Beth, UC_JOINING_GROUP_BETH
+Burushaski Yeh Barree, UC_JOINING_GROUP_BURUSHASKI_YEH_BARREE
+BurushaskiYehBarree, UC_JOINING_GROUP_BURUSHASKI_YEH_BARREE
+Dal, UC_JOINING_GROUP_DAL
+Dalath Rish, UC_JOINING_GROUP_DALATH_RISH
+DalathRish, UC_JOINING_GROUP_DALATH_RISH
+E, UC_JOINING_GROUP_E
+Farsi Yeh, UC_JOINING_GROUP_FARSI_YEH
+FarsiYeh, UC_JOINING_GROUP_FARSI_YEH
+Fe, UC_JOINING_GROUP_FE
+Feh, UC_JOINING_GROUP_FEH
+Final Semkath, UC_JOINING_GROUP_FINAL_SEMKATH
+FinalSemkath, UC_JOINING_GROUP_FINAL_SEMKATH
+Gaf, UC_JOINING_GROUP_GAF
+Gamal, UC_JOINING_GROUP_GAMAL
+Hah, UC_JOINING_GROUP_HAH
+He, UC_JOINING_GROUP_HE
+Heh, UC_JOINING_GROUP_HEH
+Heh Goal, UC_JOINING_GROUP_HEH_GOAL
+HehGoal, UC_JOINING_GROUP_HEH_GOAL
+Heth, UC_JOINING_GROUP_HETH
+Kaf, UC_JOINING_GROUP_KAF
+Kaph, UC_JOINING_GROUP_KAPH
+Khaph, UC_JOINING_GROUP_KHAPH
+Knotted Heh, UC_JOINING_GROUP_KNOTTED_HEH
+KnottedHeh, UC_JOINING_GROUP_KNOTTED_HEH
+Lam, UC_JOINING_GROUP_LAM
+Lamadh, UC_JOINING_GROUP_LAMADH
+Meem, UC_JOINING_GROUP_MEEM
+Mim, UC_JOINING_GROUP_MIM
+Noon, UC_JOINING_GROUP_NOON
+Nun, UC_JOINING_GROUP_NUN
+Nya, UC_JOINING_GROUP_NYA
+Pe, UC_JOINING_GROUP_PE
+Qaf, UC_JOINING_GROUP_QAF
+Qaph, UC_JOINING_GROUP_QAPH
+Reh, UC_JOINING_GROUP_REH
+Reversed Pe, UC_JOINING_GROUP_REVERSED_PE
+ReversedPe, UC_JOINING_GROUP_REVERSED_PE
+Sad, UC_JOINING_GROUP_SAD
+Sadhe, UC_JOINING_GROUP_SADHE
+Seen, UC_JOINING_GROUP_SEEN
+Semkath, UC_JOINING_GROUP_SEMKATH
+Shin, UC_JOINING_GROUP_SHIN
+Swash Kaf, UC_JOINING_GROUP_SWASH_KAF
+SwashKaf, UC_JOINING_GROUP_SWASH_KAF
+Syriac Waw, UC_JOINING_GROUP_SYRIAC_WAW
+SyriacWaw, UC_JOINING_GROUP_SYRIAC_WAW
+Tah, UC_JOINING_GROUP_TAH
+Taw, UC_JOINING_GROUP_TAW
+Teh Marbuta, UC_JOINING_GROUP_TEH_MARBUTA
+TehMarbuta, UC_JOINING_GROUP_TEH_MARBUTA
+Teh Marbuta Goal, UC_JOINING_GROUP_TEH_MARBUTA_GOAL
+TehMarbutaGoal, UC_JOINING_GROUP_TEH_MARBUTA_GOAL
+Teth, UC_JOINING_GROUP_TETH
+Waw, UC_JOINING_GROUP_WAW
+Yeh, UC_JOINING_GROUP_YEH
+Yeh Barree, UC_JOINING_GROUP_YEH_BARREE
+YehBarree, UC_JOINING_GROUP_YEH_BARREE
+Yeh with tail, UC_JOINING_GROUP_YEH_WITH_TAIL
+YehWithTail, UC_JOINING_GROUP_YEH_WITH_TAIL
+Yudh, UC_JOINING_GROUP_YUDH
+Yudh He, UC_JOINING_GROUP_YUDH_HE
+YudhHe, UC_JOINING_GROUP_YUDH_HE
+Zain, UC_JOINING_GROUP_ZAIN
+Zhain, UC_JOINING_GROUP_ZHAIN
new file mode 100644
--- /dev/null
+++ b/lib/unictype/joininggroup_name.c
@@ -0,0 +1,55 @@
+/* Arabic joining group of Unicode characters.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "unictype.h"
+
+/* Use a string pool, rather than a two-dimensional array, because the strings
+   have very different lengths.  */
+
+struct joining_group_stringpool_t
+  {
+#define ELEM(tag,string) char tag[sizeof (string)];
+#include "unictype/joininggroup_name.h"
+#undef ELEM
+  };
+
+static const struct joining_group_stringpool_t joining_group_stringpool_contents =
+  {
+#define ELEM(tag,string) string,
+#include "unictype/joininggroup_name.h"
+#undef ELEM
+  };
+#define joining_group_stringpool ((const char *) &joining_group_stringpool_contents)
+
+static const int joining_group_index[] =
+  {
+#define ELEM(tag,string) (int)(long)&((struct joining_group_stringpool_t *)0)->tag,
+#include "unictype/joininggroup_name.h"
+#undef ELEM
+  };
+
+const char *
+uc_joining_group_name (int joining_group)
+{
+  if (joining_group >= 0
+      && joining_group < sizeof (joining_group_index) / sizeof (joining_group_index[0]))
+    return joining_group_stringpool + joining_group_index[joining_group];
+  return NULL;
+}
new file mode 100644
--- /dev/null
+++ b/lib/unictype/joininggroup_name.h
@@ -0,0 +1,74 @@
+/* Arabic joining group of Unicode characters.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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/>.  */
+
+ELEM (NONE,                  "No Joining Group")
+ELEM (AIN,                   "Ain")
+ELEM (ALAPH,                 "Alaph")
+ELEM (ALEF,                  "Alef")
+ELEM (BEH,                   "Beh")
+ELEM (BETH,                  "Beth")
+ELEM (BURUSHASKI_YEH_BARREE, "Burushaski Yeh Barree")
+ELEM (DAL,                   "Dal")
+ELEM (DALATH_RISH,           "Dalath Rish")
+ELEM (E,                     "E")
+ELEM (FARSI_YEH,             "Farsi Yeh")
+ELEM (FE,                    "Fe")
+ELEM (FEH,                   "Feh")
+ELEM (FINAL_SEMKATH,         "Final Semkath")
+ELEM (GAF,                   "Gaf")
+ELEM (GAMAL,                 "Gamal")
+ELEM (HAH,                   "Hah")
+ELEM (HE,                    "He")
+ELEM (HEH,                   "Heh")
+ELEM (HEH_GOAL,              "Heh Goal")
+ELEM (HETH,                  "Heth")
+ELEM (KAF,                   "Kaf")
+ELEM (KAPH,                  "Kaph")
+ELEM (KHAPH,                 "Khaph")
+ELEM (KNOTTED_HEH,           "Knotted Heh")
+ELEM (LAM,                   "Lam")
+ELEM (LAMADH,                "Lamadh")
+ELEM (MEEM,                  "Meem")
+ELEM (MIM,                   "Mim")
+ELEM (NOON,                  "Noon")
+ELEM (NUN,                   "Nun")
+ELEM (NYA,                   "Nya")
+ELEM (PE,                    "Pe")
+ELEM (QAF,                   "Qaf")
+ELEM (QAPH,                  "Qaph")
+ELEM (REH,                   "Reh")
+ELEM (REVERSED_PE,           "Reversed Pe")
+ELEM (SAD,                   "Sad")
+ELEM (SADHE,                 "Sadhe")
+ELEM (SEEN,                  "Seen")
+ELEM (SEMKATH,               "Semkath")
+ELEM (SHIN,                  "Shin")
+ELEM (SWASH_KAF,             "Swash Kaf")
+ELEM (SYRIAC_WAW,            "Syriac Waw")
+ELEM (TAH,                   "Tah")
+ELEM (TAW,                   "Taw")
+ELEM (TEH_MARBUTA,           "Teh Marbuta")
+ELEM (TEH_MARBUTA_GOAL,      "Teh Marbuta Goal")
+ELEM (TETH,                  "Teth")
+ELEM (WAW,                   "Waw")
+ELEM (YEH,                   "Yeh")
+ELEM (YEH_BARREE,            "Yeh Barree")
+ELEM (YEH_WITH_TAIL,         "Yeh With Tail")
+ELEM (YUDH,                  "Yudh")
+ELEM (YUDH_HE,               "Yudh He")
+ELEM (ZAIN,                  "Zain")
+ELEM (ZHAIN,                 "Zhain")
new file mode 100644
--- /dev/null
+++ b/lib/unictype/joininggroup_of.c
@@ -0,0 +1,33 @@
+/* Arabic joining group of Unicode characters.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "unictype.h"
+
+#include "unictype/joininggroup_of.h"
+
+int
+uc_joining_group (ucs4_t uc)
+{
+  if (uc >= joining_group_header_0
+      && uc < joining_group_header_0
+              + sizeof (u_joining_group) / sizeof (u_joining_group[0]))
+    return u_joining_group[uc - joining_group_header_0];
+  return UC_JOINING_GROUP_NONE;
+}
new file mode 100644
--- /dev/null
+++ b/lib/unictype/joininggroup_of.h
@@ -0,0 +1,183 @@
+/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
+/* Arabic joining type of Unicode characters.  */
+/* Generated automatically by gen-uni-tables.c for Unicode 6.0.0.  */
+#define joining_group_header_0 0x620
+static const unsigned char u_joining_group[0x780 - 0x620] =
+{
+  UC_JOINING_GROUP_YEH,                   UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_ALEF,                  UC_JOINING_GROUP_ALEF,
+  UC_JOINING_GROUP_WAW,                   UC_JOINING_GROUP_ALEF,
+  UC_JOINING_GROUP_YEH,                   UC_JOINING_GROUP_ALEF,
+  UC_JOINING_GROUP_BEH,                   UC_JOINING_GROUP_TEH_MARBUTA,
+  UC_JOINING_GROUP_BEH,                   UC_JOINING_GROUP_BEH,
+  UC_JOINING_GROUP_HAH,                   UC_JOINING_GROUP_HAH,
+  UC_JOINING_GROUP_HAH,                   UC_JOINING_GROUP_DAL,
+  UC_JOINING_GROUP_DAL,                   UC_JOINING_GROUP_REH,
+  UC_JOINING_GROUP_REH,                   UC_JOINING_GROUP_SEEN,
+  UC_JOINING_GROUP_SEEN,                  UC_JOINING_GROUP_SAD,
+  UC_JOINING_GROUP_SAD,                   UC_JOINING_GROUP_TAH,
+  UC_JOINING_GROUP_TAH,                   UC_JOINING_GROUP_AIN,
+  UC_JOINING_GROUP_AIN,                   UC_JOINING_GROUP_GAF,
+  UC_JOINING_GROUP_GAF,                   UC_JOINING_GROUP_FARSI_YEH,
+  UC_JOINING_GROUP_FARSI_YEH,             UC_JOINING_GROUP_FARSI_YEH,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_FEH,
+  UC_JOINING_GROUP_QAF,                   UC_JOINING_GROUP_KAF,
+  UC_JOINING_GROUP_LAM,                   UC_JOINING_GROUP_MEEM,
+  UC_JOINING_GROUP_NOON,                  UC_JOINING_GROUP_HEH,
+  UC_JOINING_GROUP_WAW,                   UC_JOINING_GROUP_YEH,
+  UC_JOINING_GROUP_YEH,                   UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_BEH,                   UC_JOINING_GROUP_QAF,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_ALEF,
+  UC_JOINING_GROUP_ALEF,                  UC_JOINING_GROUP_ALEF,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_ALEF,
+  UC_JOINING_GROUP_WAW,                   UC_JOINING_GROUP_WAW,
+  UC_JOINING_GROUP_YEH,                   UC_JOINING_GROUP_BEH,
+  UC_JOINING_GROUP_BEH,                   UC_JOINING_GROUP_BEH,
+  UC_JOINING_GROUP_BEH,                   UC_JOINING_GROUP_BEH,
+  UC_JOINING_GROUP_BEH,                   UC_JOINING_GROUP_BEH,
+  UC_JOINING_GROUP_BEH,                   UC_JOINING_GROUP_HAH,
+  UC_JOINING_GROUP_HAH,                   UC_JOINING_GROUP_HAH,
+  UC_JOINING_GROUP_HAH,                   UC_JOINING_GROUP_HAH,
+  UC_JOINING_GROUP_HAH,                   UC_JOINING_GROUP_HAH,
+  UC_JOINING_GROUP_DAL,                   UC_JOINING_GROUP_DAL,
+  UC_JOINING_GROUP_DAL,                   UC_JOINING_GROUP_DAL,
+  UC_JOINING_GROUP_DAL,                   UC_JOINING_GROUP_DAL,
+  UC_JOINING_GROUP_DAL,                   UC_JOINING_GROUP_DAL,
+  UC_JOINING_GROUP_DAL,                   UC_JOINING_GROUP_REH,
+  UC_JOINING_GROUP_REH,                   UC_JOINING_GROUP_REH,
+  UC_JOINING_GROUP_REH,                   UC_JOINING_GROUP_REH,
+  UC_JOINING_GROUP_REH,                   UC_JOINING_GROUP_REH,
+  UC_JOINING_GROUP_REH,                   UC_JOINING_GROUP_REH,
+  UC_JOINING_GROUP_SEEN,                  UC_JOINING_GROUP_SEEN,
+  UC_JOINING_GROUP_SEEN,                  UC_JOINING_GROUP_SAD,
+  UC_JOINING_GROUP_SAD,                   UC_JOINING_GROUP_TAH,
+  UC_JOINING_GROUP_AIN,                   UC_JOINING_GROUP_FEH,
+  UC_JOINING_GROUP_FEH,                   UC_JOINING_GROUP_FEH,
+  UC_JOINING_GROUP_FEH,                   UC_JOINING_GROUP_FEH,
+  UC_JOINING_GROUP_FEH,                   UC_JOINING_GROUP_QAF,
+  UC_JOINING_GROUP_QAF,                   UC_JOINING_GROUP_GAF,
+  UC_JOINING_GROUP_SWASH_KAF,             UC_JOINING_GROUP_GAF,
+  UC_JOINING_GROUP_KAF,                   UC_JOINING_GROUP_KAF,
+  UC_JOINING_GROUP_KAF,                   UC_JOINING_GROUP_GAF,
+  UC_JOINING_GROUP_GAF,                   UC_JOINING_GROUP_GAF,
+  UC_JOINING_GROUP_GAF,                   UC_JOINING_GROUP_GAF,
+  UC_JOINING_GROUP_GAF,                   UC_JOINING_GROUP_LAM,
+  UC_JOINING_GROUP_LAM,                   UC_JOINING_GROUP_LAM,
+  UC_JOINING_GROUP_LAM,                   UC_JOINING_GROUP_NOON,
+  UC_JOINING_GROUP_NOON,                  UC_JOINING_GROUP_NOON,
+  UC_JOINING_GROUP_NOON,                  UC_JOINING_GROUP_NYA,
+  UC_JOINING_GROUP_KNOTTED_HEH,           UC_JOINING_GROUP_HAH,
+  UC_JOINING_GROUP_TEH_MARBUTA,           UC_JOINING_GROUP_HEH_GOAL,
+  UC_JOINING_GROUP_HEH_GOAL,              UC_JOINING_GROUP_TEH_MARBUTA_GOAL,
+  UC_JOINING_GROUP_WAW,                   UC_JOINING_GROUP_WAW,
+  UC_JOINING_GROUP_WAW,                   UC_JOINING_GROUP_WAW,
+  UC_JOINING_GROUP_WAW,                   UC_JOINING_GROUP_WAW,
+  UC_JOINING_GROUP_WAW,                   UC_JOINING_GROUP_WAW,
+  UC_JOINING_GROUP_FARSI_YEH,             UC_JOINING_GROUP_YEH_WITH_TAIL,
+  UC_JOINING_GROUP_FARSI_YEH,             UC_JOINING_GROUP_WAW,
+  UC_JOINING_GROUP_YEH,                   UC_JOINING_GROUP_YEH,
+  UC_JOINING_GROUP_YEH_BARREE,            UC_JOINING_GROUP_YEH_BARREE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_TEH_MARBUTA,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_DAL,                   UC_JOINING_GROUP_REH,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_SEEN,                  UC_JOINING_GROUP_SAD,
+  UC_JOINING_GROUP_AIN,                   UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_KNOTTED_HEH,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_ALAPH,                 UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_BETH,                  UC_JOINING_GROUP_GAMAL,
+  UC_JOINING_GROUP_GAMAL,                 UC_JOINING_GROUP_DALATH_RISH,
+  UC_JOINING_GROUP_DALATH_RISH,           UC_JOINING_GROUP_HE,
+  UC_JOINING_GROUP_SYRIAC_WAW,            UC_JOINING_GROUP_ZAIN,
+  UC_JOINING_GROUP_HETH,                  UC_JOINING_GROUP_TETH,
+  UC_JOINING_GROUP_TETH,                  UC_JOINING_GROUP_YUDH,
+  UC_JOINING_GROUP_YUDH_HE,               UC_JOINING_GROUP_KAPH,
+  UC_JOINING_GROUP_LAMADH,                UC_JOINING_GROUP_MIM,
+  UC_JOINING_GROUP_NUN,                   UC_JOINING_GROUP_SEMKATH,
+  UC_JOINING_GROUP_FINAL_SEMKATH,         UC_JOINING_GROUP_E,
+  UC_JOINING_GROUP_PE,                    UC_JOINING_GROUP_REVERSED_PE,
+  UC_JOINING_GROUP_SADHE,                 UC_JOINING_GROUP_QAPH,
+  UC_JOINING_GROUP_DALATH_RISH,           UC_JOINING_GROUP_SHIN,
+  UC_JOINING_GROUP_TAW,                   UC_JOINING_GROUP_BETH,
+  UC_JOINING_GROUP_GAMAL,                 UC_JOINING_GROUP_DALATH_RISH,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_NONE,
+  UC_JOINING_GROUP_NONE,                  UC_JOINING_GROUP_ZHAIN,
+  UC_JOINING_GROUP_KHAPH,                 UC_JOINING_GROUP_FE,
+  UC_JOINING_GROUP_BEH,                   UC_JOINING_GROUP_BEH,
+  UC_JOINING_GROUP_BEH,                   UC_JOINING_GROUP_BEH,
+  UC_JOINING_GROUP_BEH,                   UC_JOINING_GROUP_BEH,
+  UC_JOINING_GROUP_BEH,                   UC_JOINING_GROUP_HAH,
+  UC_JOINING_GROUP_HAH,                   UC_JOINING_GROUP_DAL,
+  UC_JOINING_GROUP_DAL,                   UC_JOINING_GROUP_REH,
+  UC_JOINING_GROUP_SEEN,                  UC_JOINING_GROUP_AIN,
+  UC_JOINING_GROUP_AIN,                   UC_JOINING_GROUP_AIN,
+  UC_JOINING_GROUP_FEH,                   UC_JOINING_GROUP_FEH,
+  UC_JOINING_GROUP_GAF,                   UC_JOINING_GROUP_GAF,
+  UC_JOINING_GROUP_GAF,                   UC_JOINING_GROUP_MEEM,
+  UC_JOINING_GROUP_MEEM,                  UC_JOINING_GROUP_NOON,
+  UC_JOINING_GROUP_NOON,                  UC_JOINING_GROUP_NOON,
+  UC_JOINING_GROUP_LAM,                   UC_JOINING_GROUP_REH,
+  UC_JOINING_GROUP_REH,                   UC_JOINING_GROUP_SEEN,
+  UC_JOINING_GROUP_HAH,                   UC_JOINING_GROUP_HAH,
+  UC_JOINING_GROUP_SEEN,                  UC_JOINING_GROUP_REH,
+  UC_JOINING_GROUP_HAH,                   UC_JOINING_GROUP_ALEF,
+  UC_JOINING_GROUP_ALEF,                  UC_JOINING_GROUP_FARSI_YEH,
+  UC_JOINING_GROUP_FARSI_YEH,             UC_JOINING_GROUP_YEH,
+  UC_JOINING_GROUP_WAW,                   UC_JOINING_GROUP_WAW,
+  UC_JOINING_GROUP_BURUSHASKI_YEH_BARREE, UC_JOINING_GROUP_BURUSHASKI_YEH_BARREE,
+  UC_JOINING_GROUP_HAH,                   UC_JOINING_GROUP_SEEN,
+  UC_JOINING_GROUP_SEEN,                  UC_JOINING_GROUP_KAF
+};
new file mode 100644
--- /dev/null
+++ b/lib/unictype/joiningtype_byname.c
@@ -0,0 +1,63 @@
+/* Arabic joining type of Unicode characters.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "unictype.h"
+
+#include <string.h>
+
+#include "unictype/joiningtype_byname.h"
+
+int
+uc_joining_type_byname (const char *joining_type_name)
+{
+  size_t len;
+
+  len = strlen (joining_type_name);
+  if (len <= MAX_WORD_LENGTH)
+    {
+      char buf[MAX_WORD_LENGTH + 1];
+      const struct named_joining_type *found;
+
+      /* Copy joining_type_name into buf, converting '_' and '-' to ' '.  */
+      {
+        const char *p = joining_type_name;
+        char *q = buf;
+
+        for (;; p++, q++)
+          {
+            char c = *p;
+
+            if (c == '_' || c == '-')
+              c = ' ';
+            *q = c;
+            if (c == '\0')
+              break;
+          }
+      }
+      /* Here q == buf + len.  */
+
+      /* Do a hash table lookup, with case-insensitive comparison.  */
+      found = uc_joining_type_lookup (buf, len);
+      if (found != NULL)
+        return found->joining_type;
+    }
+  /* Invalid joining type name.  */
+  return -1;
+}
new file mode 100644
--- /dev/null
+++ b/lib/unictype/joiningtype_byname.gperf
@@ -0,0 +1,30 @@
+/* Arabic joining type of Unicode characters.  */
+struct named_joining_type { int name; int joining_type; };
+%struct-type
+%ignore-case
+%language=ANSI-C
+%define hash-function-name joining_type_hash
+%define lookup-function-name uc_joining_type_lookup
+%readonly-tables
+%global-table
+%define word-array-name joining_type_names
+%pic
+%define string-pool-name joining_type_stringpool
+%%
+C, UC_JOINING_TYPE_C
+D, UC_JOINING_TYPE_D
+L, UC_JOINING_TYPE_L
+R, UC_JOINING_TYPE_R
+T, UC_JOINING_TYPE_T
+U, UC_JOINING_TYPE_U
+Join Causing, UC_JOINING_TYPE_C
+JoinCausing, UC_JOINING_TYPE_C
+Dual Joining, UC_JOINING_TYPE_D
+DualJoining, UC_JOINING_TYPE_D
+Left Joining, UC_JOINING_TYPE_L
+LeftJoining, UC_JOINING_TYPE_L
+Right Joining, UC_JOINING_TYPE_R
+RightJoining, UC_JOINING_TYPE_R
+Transparent, UC_JOINING_TYPE_T
+Non Joining, UC_JOINING_TYPE_U
+NonJoining, UC_JOINING_TYPE_U
new file mode 100644
--- /dev/null
+++ b/lib/unictype/joiningtype_longname.c
@@ -0,0 +1,40 @@
+/* Arabic joining type of Unicode characters.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "unictype.h"
+
+static const char u_joining_type_long_name[6][14] =
+{
+  "Non Joining",
+  "Transparent",
+  "Join Causing",
+  "Left Joining",
+  "Right Joining",
+  "Dual Joining"
+};
+
+const char *
+uc_joining_type_long_name (int joining_type)
+{
+  if (joining_type >= 0
+      && joining_type < sizeof (u_joining_type_long_name) / sizeof (u_joining_type_long_name[0]))
+    return u_joining_type_long_name[joining_type];
+  return NULL;
+}
new file mode 100644
--- /dev/null
+++ b/lib/unictype/joiningtype_name.c
@@ -0,0 +1,35 @@
+/* Arabic joining type of Unicode characters.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "unictype.h"
+
+static const char u_joining_type_name[6][2] =
+{
+  "U", "T", "C", "L", "R", "D"
+};
+
+const char *
+uc_joining_type_name (int joining_type)
+{
+  if (joining_type >= 0
+      && joining_type < sizeof (u_joining_type_name) / sizeof (u_joining_type_name[0]))
+    return u_joining_type_name[joining_type];
+  return NULL;
+}
new file mode 100644
--- /dev/null
+++ b/lib/unictype/joiningtype_of.c
@@ -0,0 +1,54 @@
+/* Arabic joining type of Unicode characters.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "unictype.h"
+
+/* Define u_joining_type table.  */
+#include "joiningtype_of.h"
+
+int
+uc_joining_type (ucs4_t uc)
+{
+  unsigned int index1 = uc >> joining_type_header_0;
+  if (index1 < joining_type_header_1)
+    {
+      int lookup1 = u_joining_type.level1[index1];
+      if (lookup1 >= 0)
+        {
+          unsigned int index2 = (uc >> joining_type_header_2) & joining_type_header_3;
+          int lookup2 = u_joining_type.level2[lookup1 + index2];
+          if (lookup2 >= 0)
+            {
+              unsigned int index3 = (uc & joining_type_header_4) + lookup2;
+              /* level3 contains 4-bit values.  */
+              unsigned int lookup3 =
+                (u_joining_type.level3[index3>>1] >> ((index3 % 2) * 4))
+                & 0x0f;
+
+              if (lookup3 != 0x0f)
+                return lookup3;
+            }
+        }
+    }
+  if (uc_is_general_category_withtable
+       (uc, UC_CATEGORY_MASK_Mn | UC_CATEGORY_MASK_Me | UC_CATEGORY_MASK_Cf))
+    return UC_JOINING_TYPE_T;
+  return UC_JOINING_TYPE_U;
+}
new file mode 100644
--- /dev/null
+++ b/lib/unictype/joiningtype_of.h
@@ -0,0 +1,127 @@
+/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
+/* Arabic joining type of Unicode characters.  */
+/* Generated automatically by gen-uni-tables.c for Unicode 6.0.0.  */
+#define joining_type_header_0 16
+#define joining_type_header_1 1
+#define joining_type_header_2 7
+#define joining_type_header_3 511
+#define joining_type_header_4 127
+static const
+struct
+  {
+    int level1[1];
+    short level2[1 << 9];
+    unsigned char level3[5 * 64];
+  }
+u_joining_type =
+{
+  {     0 },
+  {
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,     0,   128,   256,   384,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      512,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+       -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1
+  },
+  {
+    0x00, 0x00, 0xff, 0xff, 0xf0, 0x0f, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0x05, 0x44, 0x44, 0x45, 0x45, 0x55, 0x55, 0x45,
+    0x44, 0x54, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+    0x52, 0x55, 0x55, 0x55, 0x54, 0xf5, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x55,
+    0x4f, 0x44, 0x40, 0x44, 0x55, 0x55, 0x55, 0x55,
+    0x55, 0x55, 0x55, 0x55, 0x44, 0x44, 0x44, 0x44,
+    0x44, 0x44, 0x44, 0x44, 0x44, 0x55, 0x55, 0x55,
+    0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+    0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+    0x54, 0x45, 0x44, 0x44, 0x44, 0x44, 0x45, 0x45,
+    0x55, 0x44, 0x4f, 0xff, 0xff, 0xff, 0x0f, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x44,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0x55, 0xf5, 0x5f,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xf4, 0x55, 0x45, 0x44, 0x44, 0x55, 0x55, 0x54,
+    0x55, 0x55, 0x55, 0x55, 0x54, 0x54, 0x54, 0x45,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x4f, 0x55,
+    0x55, 0x55, 0x55, 0x55, 0x45, 0x44, 0x55, 0x55,
+    0x55, 0x55, 0x55, 0x55, 0x55, 0x45, 0x54, 0x55,
+    0x45, 0x45, 0x54, 0x55, 0x44, 0x55, 0x55, 0x55,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0x55, 0x55, 0x55,
+    0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
+    0x55, 0x55, 0x55, 0x55, 0x55, 0xf5, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xf2, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x20, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+  }
+};
--- a/lib/unictype/pr_byname.c
+++ b/lib/unictype/pr_byname.c
@@ -1,5 +1,5 @@
 /* Properties of Unicode characters.
-   Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2011 Free Software Foundation, Inc.
    Written by Bruno Haible <bruno@clisp.org>, 2007.
 
    This program is free software: you can redistribute it and/or modify it
@@ -20,8 +20,110 @@
 /* Specification.  */
 #include "unictype.h"
 
+#include <stdlib.h>
 #include <string.h>
 
+/* Indices stored in the 'struct named_category' elements of the perfect hash
+   table.  We don't use uc_general_category_t values or their addresses
+   directly, because this would introduce load-time relocations.  */
+enum
+{
+  /* General.  */
+  UC_PROPERTY_INDEX_WHITE_SPACE,
+  UC_PROPERTY_INDEX_ALPHABETIC,
+  UC_PROPERTY_INDEX_OTHER_ALPHABETIC,
+  UC_PROPERTY_INDEX_NOT_A_CHARACTER,
+  UC_PROPERTY_INDEX_DEFAULT_IGNORABLE_CODE_POINT,
+  UC_PROPERTY_INDEX_OTHER_DEFAULT_IGNORABLE_CODE_POINT,
+  UC_PROPERTY_INDEX_DEPRECATED,
+  UC_PROPERTY_INDEX_LOGICAL_ORDER_EXCEPTION,
+  UC_PROPERTY_INDEX_VARIATION_SELECTOR,
+  UC_PROPERTY_INDEX_PRIVATE_USE,
+  UC_PROPERTY_INDEX_UNASSIGNED_CODE_VALUE,
+  /* Case.  */
+  UC_PROPERTY_INDEX_UPPERCASE,
+  UC_PROPERTY_INDEX_OTHER_UPPERCASE,
+  UC_PROPERTY_INDEX_LOWERCASE,
+  UC_PROPERTY_INDEX_OTHER_LOWERCASE,
+  UC_PROPERTY_INDEX_TITLECASE,
+  UC_PROPERTY_INDEX_CASED,
+  UC_PROPERTY_INDEX_CASE_IGNORABLE,
+  UC_PROPERTY_INDEX_CHANGES_WHEN_LOWERCASED,
+  UC_PROPERTY_INDEX_CHANGES_WHEN_UPPERCASED,
+  UC_PROPERTY_INDEX_CHANGES_WHEN_TITLECASED,
+  UC_PROPERTY_INDEX_CHANGES_WHEN_CASEFOLDED,
+  UC_PROPERTY_INDEX_CHANGES_WHEN_CASEMAPPED,
+  UC_PROPERTY_INDEX_SOFT_DOTTED,
+  /* Identifiers.  */
+  UC_PROPERTY_INDEX_ID_START,
+  UC_PROPERTY_INDEX_OTHER_ID_START,
+  UC_PROPERTY_INDEX_ID_CONTINUE,
+  UC_PROPERTY_INDEX_OTHER_ID_CONTINUE,
+  UC_PROPERTY_INDEX_XID_START,
+  UC_PROPERTY_INDEX_XID_CONTINUE,
+  UC_PROPERTY_INDEX_PATTERN_WHITE_SPACE,
+  UC_PROPERTY_INDEX_PATTERN_SYNTAX,
+  /* Shaping and rendering.  */
+  UC_PROPERTY_INDEX_JOIN_CONTROL,
+  UC_PROPERTY_INDEX_GRAPHEME_BASE,
+  UC_PROPERTY_INDEX_GRAPHEME_EXTEND,
+  UC_PROPERTY_INDEX_OTHER_GRAPHEME_EXTEND,
+  UC_PROPERTY_INDEX_GRAPHEME_LINK,
+  /* Bidi.  */
+  UC_PROPERTY_INDEX_BIDI_CONTROL,
+  UC_PROPERTY_INDEX_BIDI_LEFT_TO_RIGHT,
+  UC_PROPERTY_INDEX_BIDI_HEBREW_RIGHT_TO_LEFT,
+  UC_PROPERTY_INDEX_BIDI_ARABIC_RIGHT_TO_LEFT,
+  UC_PROPERTY_INDEX_BIDI_EUROPEAN_DIGIT,
+  UC_PROPERTY_INDEX_BIDI_EUR_NUM_SEPARATOR,
+  UC_PROPERTY_INDEX_BIDI_EUR_NUM_TERMINATOR,
+  UC_PROPERTY_INDEX_BIDI_ARABIC_DIGIT,
+  UC_PROPERTY_INDEX_BIDI_COMMON_SEPARATOR,
+  UC_PROPERTY_INDEX_BIDI_BLOCK_SEPARATOR,
+  UC_PROPERTY_INDEX_BIDI_SEGMENT_SEPARATOR,
+  UC_PROPERTY_INDEX_BIDI_WHITESPACE,
+  UC_PROPERTY_INDEX_BIDI_NON_SPACING_MARK,
+  UC_PROPERTY_INDEX_BIDI_BOUNDARY_NEUTRAL,
+  UC_PROPERTY_INDEX_BIDI_PDF,
+  UC_PROPERTY_INDEX_BIDI_EMBEDDING_OR_OVERRIDE,
+  UC_PROPERTY_INDEX_BIDI_OTHER_NEUTRAL,
+  /* Numeric.  */
+  UC_PROPERTY_INDEX_HEX_DIGIT,
+  UC_PROPERTY_INDEX_ASCII_HEX_DIGIT,
+  /* CJK.  */
+  UC_PROPERTY_INDEX_IDEOGRAPHIC,
+  UC_PROPERTY_INDEX_UNIFIED_IDEOGRAPH,
+  UC_PROPERTY_INDEX_RADICAL,
+  UC_PROPERTY_INDEX_IDS_BINARY_OPERATOR,
+  UC_PROPERTY_INDEX_IDS_TRINARY_OPERATOR,
+  /* Misc.  */
+  UC_PROPERTY_INDEX_ZERO_WIDTH,
+  UC_PROPERTY_INDEX_SPACE,
+  UC_PROPERTY_INDEX_NON_BREAK,
+  UC_PROPERTY_INDEX_ISO_CONTROL,
+  UC_PROPERTY_INDEX_FORMAT_CONTROL,
+  UC_PROPERTY_INDEX_DASH,
+  UC_PROPERTY_INDEX_HYPHEN,
+  UC_PROPERTY_INDEX_PUNCTUATION,
+  UC_PROPERTY_INDEX_LINE_SEPARATOR,
+  UC_PROPERTY_INDEX_PARAGRAPH_SEPARATOR,
+  UC_PROPERTY_INDEX_QUOTATION_MARK,
+  UC_PROPERTY_INDEX_SENTENCE_TERMINAL,
+  UC_PROPERTY_INDEX_TERMINAL_PUNCTUATION,
+  UC_PROPERTY_INDEX_CURRENCY_SYMBOL,
+  UC_PROPERTY_INDEX_MATH,
+  UC_PROPERTY_INDEX_OTHER_MATH,
+  UC_PROPERTY_INDEX_PAIRED_PUNCTUATION,
+  UC_PROPERTY_INDEX_LEFT_OF_PAIR,
+  UC_PROPERTY_INDEX_COMBINING,
+  UC_PROPERTY_INDEX_COMPOSITE,
+  UC_PROPERTY_INDEX_DECIMAL_DIGIT,
+  UC_PROPERTY_INDEX_NUMERIC,
+  UC_PROPERTY_INDEX_DIACRITIC,
+  UC_PROPERTY_INDEX_EXTENDER,
+  UC_PROPERTY_INDEX_IGNORABLE_CONTROL
+};
+
 /* Get gperf generated lookup function.  */
 #include "unictype/pr_byname.h"
 
@@ -53,7 +155,185 @@
     }
   found = uc_property_lookup (buf, bp - buf);
   if (found != NULL)
-    return found->property;
+    /* Use a 'switch' statement here, because a table would introduce load-time
+       relocations.  */
+    switch (found->property_index)
+      {
+      case UC_PROPERTY_INDEX_WHITE_SPACE:
+        return UC_PROPERTY_WHITE_SPACE;
+      case UC_PROPERTY_INDEX_ALPHABETIC:
+        return UC_PROPERTY_ALPHABETIC;
+      case UC_PROPERTY_INDEX_OTHER_ALPHABETIC:
+        return UC_PROPERTY_OTHER_ALPHABETIC;
+      case UC_PROPERTY_INDEX_NOT_A_CHARACTER:
+        return UC_PROPERTY_NOT_A_CHARACTER;
+      case UC_PROPERTY_INDEX_DEFAULT_IGNORABLE_CODE_POINT:
+        return UC_PROPERTY_DEFAULT_IGNORABLE_CODE_POINT;
+      case UC_PROPERTY_INDEX_OTHER_DEFAULT_IGNORABLE_CODE_POINT:
+        return UC_PROPERTY_OTHER_DEFAULT_IGNORABLE_CODE_POINT;
+      case UC_PROPERTY_INDEX_DEPRECATED:
+        return UC_PROPERTY_DEPRECATED;
+      case UC_PROPERTY_INDEX_LOGICAL_ORDER_EXCEPTION:
+        return UC_PROPERTY_LOGICAL_ORDER_EXCEPTION;
+      case UC_PROPERTY_INDEX_VARIATION_SELECTOR:
+        return UC_PROPERTY_VARIATION_SELECTOR;
+      case UC_PROPERTY_INDEX_PRIVATE_USE:
+        return UC_PROPERTY_PRIVATE_USE;
+      case UC_PROPERTY_INDEX_UNASSIGNED_CODE_VALUE:
+        return UC_PROPERTY_UNASSIGNED_CODE_VALUE;
+      case UC_PROPERTY_INDEX_UPPERCASE:
+        return UC_PROPERTY_UPPERCASE;
+      case UC_PROPERTY_INDEX_OTHER_UPPERCASE:
+        return UC_PROPERTY_OTHER_UPPERCASE;
+      case UC_PROPERTY_INDEX_LOWERCASE:
+        return UC_PROPERTY_LOWERCASE;
+      case UC_PROPERTY_INDEX_OTHER_LOWERCASE:
+        return UC_PROPERTY_OTHER_LOWERCASE;
+      case UC_PROPERTY_INDEX_TITLECASE:
+        return UC_PROPERTY_TITLECASE;
+      case UC_PROPERTY_INDEX_CASED:
+        return UC_PROPERTY_CASED;
+      case UC_PROPERTY_INDEX_CASE_IGNORABLE:
+        return UC_PROPERTY_CASE_IGNORABLE;
+      case UC_PROPERTY_INDEX_CHANGES_WHEN_LOWERCASED:
+        return UC_PROPERTY_CHANGES_WHEN_LOWERCASED;
+      case UC_PROPERTY_INDEX_CHANGES_WHEN_UPPERCASED:
+        return UC_PROPERTY_CHANGES_WHEN_UPPERCASED;
+      case UC_PROPERTY_INDEX_CHANGES_WHEN_TITLECASED:
+        return UC_PROPERTY_CHANGES_WHEN_TITLECASED;
+      case UC_PROPERTY_INDEX_CHANGES_WHEN_CASEFOLDED:
+        return UC_PROPERTY_CHANGES_WHEN_CASEFOLDED;
+      case UC_PROPERTY_INDEX_CHANGES_WHEN_CASEMAPPED:
+        return UC_PROPERTY_CHANGES_WHEN_CASEMAPPED;
+      case UC_PROPERTY_INDEX_SOFT_DOTTED:
+        return UC_PROPERTY_SOFT_DOTTED;
+      case UC_PROPERTY_INDEX_ID_START:
+        return UC_PROPERTY_ID_START;
+      case UC_PROPERTY_INDEX_OTHER_ID_START:
+        return UC_PROPERTY_OTHER_ID_START;
+      case UC_PROPERTY_INDEX_ID_CONTINUE:
+        return UC_PROPERTY_ID_CONTINUE;
+      case UC_PROPERTY_INDEX_OTHER_ID_CONTINUE:
+        return UC_PROPERTY_OTHER_ID_CONTINUE;
+      case UC_PROPERTY_INDEX_XID_START:
+        return UC_PROPERTY_XID_START;
+      case UC_PROPERTY_INDEX_XID_CONTINUE:
+        return UC_PROPERTY_XID_CONTINUE;
+      case UC_PROPERTY_INDEX_PATTERN_WHITE_SPACE:
+        return UC_PROPERTY_PATTERN_WHITE_SPACE;
+      case UC_PROPERTY_INDEX_PATTERN_SYNTAX:
+        return UC_PROPERTY_PATTERN_SYNTAX;
+      case UC_PROPERTY_INDEX_JOIN_CONTROL:
+        return UC_PROPERTY_JOIN_CONTROL;
+      case UC_PROPERTY_INDEX_GRAPHEME_BASE:
+        return UC_PROPERTY_GRAPHEME_BASE;
+      case UC_PROPERTY_INDEX_GRAPHEME_EXTEND:
+        return UC_PROPERTY_GRAPHEME_EXTEND;
+      case UC_PROPERTY_INDEX_OTHER_GRAPHEME_EXTEND:
+        return UC_PROPERTY_OTHER_GRAPHEME_EXTEND;
+      case UC_PROPERTY_INDEX_GRAPHEME_LINK:
+        return UC_PROPERTY_GRAPHEME_LINK;
+      case UC_PROPERTY_INDEX_BIDI_CONTROL:
+        return UC_PROPERTY_BIDI_CONTROL;
+      case UC_PROPERTY_INDEX_BIDI_LEFT_TO_RIGHT:
+        return UC_PROPERTY_BIDI_LEFT_TO_RIGHT;
+      case UC_PROPERTY_INDEX_BIDI_HEBREW_RIGHT_TO_LEFT:
+        return UC_PROPERTY_BIDI_HEBREW_RIGHT_TO_LEFT;
+      case UC_PROPERTY_INDEX_BIDI_ARABIC_RIGHT_TO_LEFT:
+        return UC_PROPERTY_BIDI_ARABIC_RIGHT_TO_LEFT;
+      case UC_PROPERTY_INDEX_BIDI_EUROPEAN_DIGIT:
+        return UC_PROPERTY_BIDI_EUROPEAN_DIGIT;
+      case UC_PROPERTY_INDEX_BIDI_EUR_NUM_SEPARATOR:
+        return UC_PROPERTY_BIDI_EUR_NUM_SEPARATOR;
+      case UC_PROPERTY_INDEX_BIDI_EUR_NUM_TERMINATOR:
+        return UC_PROPERTY_BIDI_EUR_NUM_TERMINATOR;
+      case UC_PROPERTY_INDEX_BIDI_ARABIC_DIGIT:
+        return UC_PROPERTY_BIDI_ARABIC_DIGIT;
+      case UC_PROPERTY_INDEX_BIDI_COMMON_SEPARATOR:
+        return UC_PROPERTY_BIDI_COMMON_SEPARATOR;
+      case UC_PROPERTY_INDEX_BIDI_BLOCK_SEPARATOR:
+        return UC_PROPERTY_BIDI_BLOCK_SEPARATOR;
+      case UC_PROPERTY_INDEX_BIDI_SEGMENT_SEPARATOR:
+        return UC_PROPERTY_BIDI_SEGMENT_SEPARATOR;
+      case UC_PROPERTY_INDEX_BIDI_WHITESPACE:
+        return UC_PROPERTY_BIDI_WHITESPACE;
+      case UC_PROPERTY_INDEX_BIDI_NON_SPACING_MARK:
+        return UC_PROPERTY_BIDI_NON_SPACING_MARK;
+      case UC_PROPERTY_INDEX_BIDI_BOUNDARY_NEUTRAL:
+        return UC_PROPERTY_BIDI_BOUNDARY_NEUTRAL;
+      case UC_PROPERTY_INDEX_BIDI_PDF:
+        return UC_PROPERTY_BIDI_PDF;
+      case UC_PROPERTY_INDEX_BIDI_EMBEDDING_OR_OVERRIDE:
+        return UC_PROPERTY_BIDI_EMBEDDING_OR_OVERRIDE;
+      case UC_PROPERTY_INDEX_BIDI_OTHER_NEUTRAL:
+        return UC_PROPERTY_BIDI_OTHER_NEUTRAL;
+      case UC_PROPERTY_INDEX_HEX_DIGIT:
+        return UC_PROPERTY_HEX_DIGIT;
+      case UC_PROPERTY_INDEX_ASCII_HEX_DIGIT:
+        return UC_PROPERTY_ASCII_HEX_DIGIT;
+      case UC_PROPERTY_INDEX_IDEOGRAPHIC:
+        return UC_PROPERTY_IDEOGRAPHIC;
+      case UC_PROPERTY_INDEX_UNIFIED_IDEOGRAPH:
+        return UC_PROPERTY_UNIFIED_IDEOGRAPH;
+      case UC_PROPERTY_INDEX_RADICAL:
+        return UC_PROPERTY_RADICAL;
+      case UC_PROPERTY_INDEX_IDS_BINARY_OPERATOR:
+        return UC_PROPERTY_IDS_BINARY_OPERATOR;
+      case UC_PROPERTY_INDEX_IDS_TRINARY_OPERATOR:
+        return UC_PROPERTY_IDS_TRINARY_OPERATOR;
+      case UC_PROPERTY_INDEX_ZERO_WIDTH:
+        return UC_PROPERTY_ZERO_WIDTH;
+      case UC_PROPERTY_INDEX_SPACE:
+        return UC_PROPERTY_SPACE;
+      case UC_PROPERTY_INDEX_NON_BREAK:
+        return UC_PROPERTY_NON_BREAK;
+      case UC_PROPERTY_INDEX_ISO_CONTROL:
+        return UC_PROPERTY_ISO_CONTROL;
+      case UC_PROPERTY_INDEX_FORMAT_CONTROL:
+        return UC_PROPERTY_FORMAT_CONTROL;
+      case UC_PROPERTY_INDEX_DASH:
+        return UC_PROPERTY_DASH;
+      case UC_PROPERTY_INDEX_HYPHEN:
+        return UC_PROPERTY_HYPHEN;
+      case UC_PROPERTY_INDEX_PUNCTUATION:
+        return UC_PROPERTY_PUNCTUATION;
+      case UC_PROPERTY_INDEX_LINE_SEPARATOR:
+        return UC_PROPERTY_LINE_SEPARATOR;
+      case UC_PROPERTY_INDEX_PARAGRAPH_SEPARATOR:
+        return UC_PROPERTY_PARAGRAPH_SEPARATOR;
+      case UC_PROPERTY_INDEX_QUOTATION_MARK:
+        return UC_PROPERTY_QUOTATION_MARK;
+      case UC_PROPERTY_INDEX_SENTENCE_TERMINAL:
+        return UC_PROPERTY_SENTENCE_TERMINAL;
+      case UC_PROPERTY_INDEX_TERMINAL_PUNCTUATION:
+        return UC_PROPERTY_TERMINAL_PUNCTUATION;
+      case UC_PROPERTY_INDEX_CURRENCY_SYMBOL:
+        return UC_PROPERTY_CURRENCY_SYMBOL;
+      case UC_PROPERTY_INDEX_MATH:
+        return UC_PROPERTY_MATH;
+      case UC_PROPERTY_INDEX_OTHER_MATH:
+        return UC_PROPERTY_OTHER_MATH;
+      case UC_PROPERTY_INDEX_PAIRED_PUNCTUATION:
+        return UC_PROPERTY_PAIRED_PUNCTUATION;
+      case UC_PROPERTY_INDEX_LEFT_OF_PAIR:
+        return UC_PROPERTY_LEFT_OF_PAIR;
+      case UC_PROPERTY_INDEX_COMBINING:
+        return UC_PROPERTY_COMBINING;
+      case UC_PROPERTY_INDEX_COMPOSITE:
+        return UC_PROPERTY_COMPOSITE;
+      case UC_PROPERTY_INDEX_DECIMAL_DIGIT:
+        return UC_PROPERTY_DECIMAL_DIGIT;
+      case UC_PROPERTY_INDEX_NUMERIC:
+        return UC_PROPERTY_NUMERIC;
+      case UC_PROPERTY_INDEX_DIACRITIC:
+        return UC_PROPERTY_DIACRITIC;
+      case UC_PROPERTY_INDEX_EXTENDER:
+        return UC_PROPERTY_EXTENDER;
+      case UC_PROPERTY_INDEX_IGNORABLE_CONTROL:
+        return UC_PROPERTY_IGNORABLE_CONTROL;
+      default:
+        abort ();
+      }
  invalid:
   return UC_PROPERTY_NONE;
 }
--- a/lib/unictype/pr_byname.gperf
+++ b/lib/unictype/pr_byname.gperf
@@ -1,4 +1,4 @@
-struct named_property { const char *name; uc_property_t property; };
+struct named_property { int name; int property_index; };
 %struct-type
 %language=ANSI-C
 %define hash-function-name properties_hash
@@ -7,90 +7,212 @@
 %readonly-tables
 %global-table
 %define word-array-name properties
+%pic
+%define string-pool-name properties_stringpool
 %%
-white_space, { &uc_is_property_white_space }
-alphabetic, { &uc_is_property_alphabetic }
-other_alphabetic, { &uc_is_property_other_alphabetic }
-not_a_character, { &uc_is_property_not_a_character }
-default_ignorable_code_point, { &uc_is_property_default_ignorable_code_point }
-other_default_ignorable_code_point, { &uc_is_property_other_default_ignorable_code_point }
-deprecated, { &uc_is_property_deprecated }
-logical_order_exception, { &uc_is_property_logical_order_exception }
-variation_selector, { &uc_is_property_variation_selector }
-private_use, { &uc_is_property_private_use }
-unassigned_code_value, { &uc_is_property_unassigned_code_value }
-uppercase, { &uc_is_property_uppercase }
-other_uppercase, { &uc_is_property_other_uppercase }
-lowercase, { &uc_is_property_lowercase }
-other_lowercase, { &uc_is_property_other_lowercase }
-titlecase, { &uc_is_property_titlecase }
-cased, { &uc_is_property_cased }
-case_ignorable, { &uc_is_property_case_ignorable }
-changes_when_lowercased, { &uc_is_property_changes_when_lowercased }
-changes_when_uppercased, { &uc_is_property_changes_when_uppercased }
-changes_when_titlecased, { &uc_is_property_changes_when_titlecased }
-changes_when_casefolded, { &uc_is_property_changes_when_casefolded }
-changes_when_casemapped, { &uc_is_property_changes_when_casemapped }
-soft_dotted, { &uc_is_property_soft_dotted }
-id_start, { &uc_is_property_id_start }
-other_id_start, { &uc_is_property_other_id_start }
-id_continue, { &uc_is_property_id_continue }
-other_id_continue, { &uc_is_property_other_id_continue }
-xid_start, { &uc_is_property_xid_start }
-xid_continue, { &uc_is_property_xid_continue }
-pattern_white_space, { &uc_is_property_pattern_white_space }
-pattern_syntax, { &uc_is_property_pattern_syntax }
-join_control, { &uc_is_property_join_control }
-grapheme_base, { &uc_is_property_grapheme_base }
-grapheme_extend, { &uc_is_property_grapheme_extend }
-other_grapheme_extend, { &uc_is_property_other_grapheme_extend }
-grapheme_link, { &uc_is_property_grapheme_link }
-bidi_control, { &uc_is_property_bidi_control }
-bidi_left_to_right, { &uc_is_property_bidi_left_to_right }
-bidi_hebrew_right_to_left, { &uc_is_property_bidi_hebrew_right_to_left }
-bidi_arabic_right_to_left, { &uc_is_property_bidi_arabic_right_to_left }
-bidi_european_digit, { &uc_is_property_bidi_european_digit }
-bidi_eur_num_separator, { &uc_is_property_bidi_eur_num_separator }
-bidi_eur_num_terminator, { &uc_is_property_bidi_eur_num_terminator }
-bidi_arabic_digit, { &uc_is_property_bidi_arabic_digit }
-bidi_common_separator, { &uc_is_property_bidi_common_separator }
-bidi_block_separator, { &uc_is_property_bidi_block_separator }
-bidi_segment_separator, { &uc_is_property_bidi_segment_separator }
-bidi_whitespace, { &uc_is_property_bidi_whitespace }
-bidi_non_spacing_mark, { &uc_is_property_bidi_non_spacing_mark }
-bidi_boundary_neutral, { &uc_is_property_bidi_boundary_neutral }
-bidi_pdf, { &uc_is_property_bidi_pdf }
-bidi_embedding_or_override, { &uc_is_property_bidi_embedding_or_override }
-bidi_other_neutral, { &uc_is_property_bidi_other_neutral }
-hex_digit, { &uc_is_property_hex_digit }
-ascii_hex_digit, { &uc_is_property_ascii_hex_digit }
-ideographic, { &uc_is_property_ideographic }
-unified_ideograph, { &uc_is_property_unified_ideograph }
-radical, { &uc_is_property_radical }
-ids_binary_operator, { &uc_is_property_ids_binary_operator }
-ids_trinary_operator, { &uc_is_property_ids_trinary_operator }
-zero_width, { &uc_is_property_zero_width }
-space, { &uc_is_property_space }
-non_break, { &uc_is_property_non_break }
-iso_control, { &uc_is_property_iso_control }
-format_control, { &uc_is_property_format_control }
-dash, { &uc_is_property_dash }
-hyphen, { &uc_is_property_hyphen }
-punctuation, { &uc_is_property_punctuation }
-line_separator, { &uc_is_property_line_separator }
-paragraph_separator, { &uc_is_property_paragraph_separator }
-quotation_mark, { &uc_is_property_quotation_mark }
-sentence_terminal, { &uc_is_property_sentence_terminal }
-terminal_punctuation, { &uc_is_property_terminal_punctuation }
-currency_symbol, { &uc_is_property_currency_symbol }
-math, { &uc_is_property_math }
-other_math, { &uc_is_property_other_math }
-paired_punctuation, { &uc_is_property_paired_punctuation }
-left_of_pair, { &uc_is_property_left_of_pair }
-combining, { &uc_is_property_combining }
-composite, { &uc_is_property_composite }
-decimal_digit, { &uc_is_property_decimal_digit }
-numeric, { &uc_is_property_numeric }
-diacritic, { &uc_is_property_diacritic }
-extender, { &uc_is_property_extender }
-ignorable_control, { &uc_is_property_ignorable_control }
+white_space, UC_PROPERTY_INDEX_WHITE_SPACE
+whitespace, UC_PROPERTY_INDEX_WHITE_SPACE
+wspace, UC_PROPERTY_INDEX_WHITE_SPACE
+alphabetic, UC_PROPERTY_INDEX_ALPHABETIC
+alpha, UC_PROPERTY_INDEX_ALPHABETIC
+other_alphabetic, UC_PROPERTY_INDEX_OTHER_ALPHABETIC
+otheralphabetic, UC_PROPERTY_INDEX_OTHER_ALPHABETIC
+oalpha, UC_PROPERTY_INDEX_OTHER_ALPHABETIC
+not_a_character, UC_PROPERTY_INDEX_NOT_A_CHARACTER
+notacharacter, UC_PROPERTY_INDEX_NOT_A_CHARACTER
+default_ignorable_code_point, UC_PROPERTY_INDEX_DEFAULT_IGNORABLE_CODE_POINT
+defaultignorablecodepoint, UC_PROPERTY_INDEX_DEFAULT_IGNORABLE_CODE_POINT
+di, UC_PROPERTY_INDEX_DEFAULT_IGNORABLE_CODE_POINT
+other_default_ignorable_code_point, UC_PROPERTY_INDEX_OTHER_DEFAULT_IGNORABLE_CODE_POINT
+otherdefaultignorablecodepoint, UC_PROPERTY_INDEX_OTHER_DEFAULT_IGNORABLE_CODE_POINT
+odi, UC_PROPERTY_INDEX_OTHER_DEFAULT_IGNORABLE_CODE_POINT
+deprecated, UC_PROPERTY_INDEX_DEPRECATED
+dep, UC_PROPERTY_INDEX_DEPRECATED
+logical_order_exception, UC_PROPERTY_INDEX_LOGICAL_ORDER_EXCEPTION
+logicalorderexception, UC_PROPERTY_INDEX_LOGICAL_ORDER_EXCEPTION
+loe, UC_PROPERTY_INDEX_LOGICAL_ORDER_EXCEPTION
+variation_selector, UC_PROPERTY_INDEX_VARIATION_SELECTOR
+variationselector, UC_PROPERTY_INDEX_VARIATION_SELECTOR
+vs, UC_PROPERTY_INDEX_VARIATION_SELECTOR
+private_use, UC_PROPERTY_INDEX_PRIVATE_USE
+privateuse, UC_PROPERTY_INDEX_PRIVATE_USE
+unassigned_code_value, UC_PROPERTY_INDEX_UNASSIGNED_CODE_VALUE
+unassignedcodevalue, UC_PROPERTY_INDEX_UNASSIGNED_CODE_VALUE
+uppercase, UC_PROPERTY_INDEX_UPPERCASE
+upper, UC_PROPERTY_INDEX_UPPERCASE
+other_uppercase, UC_PROPERTY_INDEX_OTHER_UPPERCASE
+otheruppercase, UC_PROPERTY_INDEX_OTHER_UPPERCASE
+oupper, UC_PROPERTY_INDEX_OTHER_UPPERCASE
+lowercase, UC_PROPERTY_INDEX_LOWERCASE
+lower, UC_PROPERTY_INDEX_LOWERCASE
+other_lowercase, UC_PROPERTY_INDEX_OTHER_LOWERCASE
+otherlowercase, UC_PROPERTY_INDEX_OTHER_LOWERCASE
+olower, UC_PROPERTY_INDEX_OTHER_LOWERCASE
+titlecase, UC_PROPERTY_INDEX_TITLECASE
+cased, UC_PROPERTY_INDEX_CASED
+case_ignorable, UC_PROPERTY_INDEX_CASE_IGNORABLE
+caseignorable, UC_PROPERTY_INDEX_CASE_IGNORABLE
+ci, UC_PROPERTY_INDEX_CASE_IGNORABLE
+changes_when_lowercased, UC_PROPERTY_INDEX_CHANGES_WHEN_LOWERCASED
+changeswhenlowercased, UC_PROPERTY_INDEX_CHANGES_WHEN_LOWERCASED
+cwl, UC_PROPERTY_INDEX_CHANGES_WHEN_LOWERCASED
+changes_when_uppercased, UC_PROPERTY_INDEX_CHANGES_WHEN_UPPERCASED
+changeswhenuppercased, UC_PROPERTY_INDEX_CHANGES_WHEN_UPPERCASED
+cwu, UC_PROPERTY_INDEX_CHANGES_WHEN_UPPERCASED
+changes_when_titlecased, UC_PROPERTY_INDEX_CHANGES_WHEN_TITLECASED
+changeswhentitlecased, UC_PROPERTY_INDEX_CHANGES_WHEN_TITLECASED
+cwt, UC_PROPERTY_INDEX_CHANGES_WHEN_TITLECASED
+changes_when_casefolded, UC_PROPERTY_INDEX_CHANGES_WHEN_CASEFOLDED
+changeswhencasefolded, UC_PROPERTY_INDEX_CHANGES_WHEN_CASEFOLDED
+cwcf, UC_PROPERTY_INDEX_CHANGES_WHEN_CASEFOLDED
+changes_when_casemapped, UC_PROPERTY_INDEX_CHANGES_WHEN_CASEMAPPED
+changeswhencasemapped, UC_PROPERTY_INDEX_CHANGES_WHEN_CASEMAPPED
+cwcm, UC_PROPERTY_INDEX_CHANGES_WHEN_CASEMAPPED
+soft_dotted, UC_PROPERTY_INDEX_SOFT_DOTTED
+softdotted, UC_PROPERTY_INDEX_SOFT_DOTTED
+sd, UC_PROPERTY_INDEX_SOFT_DOTTED
+id_start, UC_PROPERTY_INDEX_ID_START
+idstart, UC_PROPERTY_INDEX_ID_START
+ids, UC_PROPERTY_INDEX_ID_START
+other_id_start, UC_PROPERTY_INDEX_OTHER_ID_START
+otheridstart, UC_PROPERTY_INDEX_OTHER_ID_START
+oids, UC_PROPERTY_INDEX_OTHER_ID_START
+id_continue, UC_PROPERTY_INDEX_ID_CONTINUE
+idcontinue, UC_PROPERTY_INDEX_ID_CONTINUE
+idc, UC_PROPERTY_INDEX_ID_CONTINUE
+other_id_continue, UC_PROPERTY_INDEX_OTHER_ID_CONTINUE
+otheridcontinue, UC_PROPERTY_INDEX_OTHER_ID_CONTINUE
+oidc, UC_PROPERTY_INDEX_OTHER_ID_CONTINUE
+xid_start, UC_PROPERTY_INDEX_XID_START
+xidstart, UC_PROPERTY_INDEX_XID_START
+xids, UC_PROPERTY_INDEX_XID_START
+xid_continue, UC_PROPERTY_INDEX_XID_CONTINUE
+xidcontinue, UC_PROPERTY_INDEX_XID_CONTINUE
+xidc, UC_PROPERTY_INDEX_XID_CONTINUE
+pattern_white_space, UC_PROPERTY_INDEX_PATTERN_WHITE_SPACE
+patternwhitespace, UC_PROPERTY_INDEX_PATTERN_WHITE_SPACE
+pat_ws, UC_PROPERTY_INDEX_PATTERN_WHITE_SPACE
+patws, UC_PROPERTY_INDEX_PATTERN_WHITE_SPACE
+pattern_syntax, UC_PROPERTY_INDEX_PATTERN_SYNTAX
+patternsyntax, UC_PROPERTY_INDEX_PATTERN_SYNTAX
+pat_syn, UC_PROPERTY_INDEX_PATTERN_SYNTAX
+patsyn, UC_PROPERTY_INDEX_PATTERN_SYNTAX
+join_control, UC_PROPERTY_INDEX_JOIN_CONTROL
+joincontrol, UC_PROPERTY_INDEX_JOIN_CONTROL
+join_c, UC_PROPERTY_INDEX_JOIN_CONTROL
+joinc, UC_PROPERTY_INDEX_JOIN_CONTROL
+grapheme_base, UC_PROPERTY_INDEX_GRAPHEME_BASE
+graphemebase, UC_PROPERTY_INDEX_GRAPHEME_BASE
+gr_base, UC_PROPERTY_INDEX_GRAPHEME_BASE
+grbase, UC_PROPERTY_INDEX_GRAPHEME_BASE
+grapheme_extend, UC_PROPERTY_INDEX_GRAPHEME_EXTEND
+graphemeextend, UC_PROPERTY_INDEX_GRAPHEME_EXTEND
+gr_ext, UC_PROPERTY_INDEX_GRAPHEME_EXTEND
+grext, UC_PROPERTY_INDEX_GRAPHEME_EXTEND
+other_grapheme_extend, UC_PROPERTY_INDEX_OTHER_GRAPHEME_EXTEND
+othergraphemeextend, UC_PROPERTY_INDEX_OTHER_GRAPHEME_EXTEND
+ogr_ext, UC_PROPERTY_INDEX_OTHER_GRAPHEME_EXTEND
+ogrext, UC_PROPERTY_INDEX_OTHER_GRAPHEME_EXTEND
+grapheme_link, UC_PROPERTY_INDEX_GRAPHEME_LINK
+graphemelink, UC_PROPERTY_INDEX_GRAPHEME_LINK
+gr_link, UC_PROPERTY_INDEX_GRAPHEME_LINK
+grlink, UC_PROPERTY_INDEX_GRAPHEME_LINK
+bidi_control, UC_PROPERTY_INDEX_BIDI_CONTROL
+bidicontrol, UC_PROPERTY_INDEX_BIDI_CONTROL
+bidi_c, UC_PROPERTY_INDEX_BIDI_CONTROL
+bidic, UC_PROPERTY_INDEX_BIDI_CONTROL
+bidi_left_to_right, UC_PROPERTY_INDEX_BIDI_LEFT_TO_RIGHT
+bidilefttoright, UC_PROPERTY_INDEX_BIDI_LEFT_TO_RIGHT
+bidi_hebrew_right_to_left, UC_PROPERTY_INDEX_BIDI_HEBREW_RIGHT_TO_LEFT
+bidihebrewrighttoleft, UC_PROPERTY_INDEX_BIDI_HEBREW_RIGHT_TO_LEFT
+bidi_arabic_right_to_left, UC_PROPERTY_INDEX_BIDI_ARABIC_RIGHT_TO_LEFT
+bidiarabicrighttoleft, UC_PROPERTY_INDEX_BIDI_ARABIC_RIGHT_TO_LEFT
+bidi_european_digit, UC_PROPERTY_INDEX_BIDI_EUROPEAN_DIGIT
+bidieuropeandigit, UC_PROPERTY_INDEX_BIDI_EUROPEAN_DIGIT
+bidi_eur_num_separator, UC_PROPERTY_INDEX_BIDI_EUR_NUM_SEPARATOR
+bidieurnumseparator, UC_PROPERTY_INDEX_BIDI_EUR_NUM_SEPARATOR
+bidi_eur_num_terminator, UC_PROPERTY_INDEX_BIDI_EUR_NUM_TERMINATOR
+bidieurnumterminator, UC_PROPERTY_INDEX_BIDI_EUR_NUM_TERMINATOR
+bidi_arabic_digit, UC_PROPERTY_INDEX_BIDI_ARABIC_DIGIT
+bidiarabicdigit, UC_PROPERTY_INDEX_BIDI_ARABIC_DIGIT
+bidi_common_separator, UC_PROPERTY_INDEX_BIDI_COMMON_SEPARATOR
+bidicommonseparator, UC_PROPERTY_INDEX_BIDI_COMMON_SEPARATOR
+bidi_block_separator, UC_PROPERTY_INDEX_BIDI_BLOCK_SEPARATOR
+bidiblockseparator, UC_PROPERTY_INDEX_BIDI_BLOCK_SEPARATOR
+bidi_segment_separator, UC_PROPERTY_INDEX_BIDI_SEGMENT_SEPARATOR
+bidisegmentseparator, UC_PROPERTY_INDEX_BIDI_SEGMENT_SEPARATOR
+bidi_whitespace, UC_PROPERTY_INDEX_BIDI_WHITESPACE
+bidiwhitespace, UC_PROPERTY_INDEX_BIDI_WHITESPACE
+bidi_non_spacing_mark, UC_PROPERTY_INDEX_BIDI_NON_SPACING_MARK
+bidinonspacingmark, UC_PROPERTY_INDEX_BIDI_NON_SPACING_MARK
+bidi_boundary_neutral, UC_PROPERTY_INDEX_BIDI_BOUNDARY_NEUTRAL
+bidiboundaryneutral, UC_PROPERTY_INDEX_BIDI_BOUNDARY_NEUTRAL
+bidi_pdf, UC_PROPERTY_INDEX_BIDI_PDF
+bidipdf, UC_PROPERTY_INDEX_BIDI_PDF
+bidi_embedding_or_override, UC_PROPERTY_INDEX_BIDI_EMBEDDING_OR_OVERRIDE
+bidiembeddingoroverride, UC_PROPERTY_INDEX_BIDI_EMBEDDING_OR_OVERRIDE
+bidi_other_neutral, UC_PROPERTY_INDEX_BIDI_OTHER_NEUTRAL
+bidiotherneutral, UC_PROPERTY_INDEX_BIDI_OTHER_NEUTRAL
+hex_digit, UC_PROPERTY_INDEX_HEX_DIGIT
+hexdigit, UC_PROPERTY_INDEX_HEX_DIGIT
+hex, UC_PROPERTY_INDEX_HEX_DIGIT
+ascii_hex_digit, UC_PROPERTY_INDEX_ASCII_HEX_DIGIT
+asciihexdigit, UC_PROPERTY_INDEX_ASCII_HEX_DIGIT
+ahex, UC_PROPERTY_INDEX_ASCII_HEX_DIGIT
+ideographic, UC_PROPERTY_INDEX_IDEOGRAPHIC
+ideo, UC_PROPERTY_INDEX_IDEOGRAPHIC
+unified_ideograph, UC_PROPERTY_INDEX_UNIFIED_IDEOGRAPH
+unifiedideograph, UC_PROPERTY_INDEX_UNIFIED_IDEOGRAPH
+uideo, UC_PROPERTY_INDEX_UNIFIED_IDEOGRAPH
+radical, UC_PROPERTY_INDEX_RADICAL
+ids_binary_operator, UC_PROPERTY_INDEX_IDS_BINARY_OPERATOR
+idsbinaryoperator, UC_PROPERTY_INDEX_IDS_BINARY_OPERATOR
+idsb, UC_PROPERTY_INDEX_IDS_BINARY_OPERATOR
+ids_trinary_operator, UC_PROPERTY_INDEX_IDS_TRINARY_OPERATOR
+idstrinaryoperator, UC_PROPERTY_INDEX_IDS_TRINARY_OPERATOR
+idst, UC_PROPERTY_INDEX_IDS_TRINARY_OPERATOR
+zero_width, UC_PROPERTY_INDEX_ZERO_WIDTH
+zerowidth, UC_PROPERTY_INDEX_ZERO_WIDTH
+space, UC_PROPERTY_INDEX_SPACE
+non_break, UC_PROPERTY_INDEX_NON_BREAK
+nonbreak, UC_PROPERTY_INDEX_NON_BREAK
+iso_control, UC_PROPERTY_INDEX_ISO_CONTROL
+isocontrol, UC_PROPERTY_INDEX_ISO_CONTROL
+format_control, UC_PROPERTY_INDEX_FORMAT_CONTROL
+formatcontrol, UC_PROPERTY_INDEX_FORMAT_CONTROL
+dash, UC_PROPERTY_INDEX_DASH
+hyphen, UC_PROPERTY_INDEX_HYPHEN
+punctuation, UC_PROPERTY_INDEX_PUNCTUATION
+line_separator, UC_PROPERTY_INDEX_LINE_SEPARATOR
+lineseparator, UC_PROPERTY_INDEX_LINE_SEPARATOR
+paragraph_separator, UC_PROPERTY_INDEX_PARAGRAPH_SEPARATOR
+paragraphseparator, UC_PROPERTY_INDEX_PARAGRAPH_SEPARATOR
+quotation_mark, UC_PROPERTY_INDEX_QUOTATION_MARK
+quotationmark, UC_PROPERTY_INDEX_QUOTATION_MARK
+qmark, UC_PROPERTY_INDEX_QUOTATION_MARK
+sentence_terminal, UC_PROPERTY_INDEX_SENTENCE_TERMINAL
+sentenceterminal, UC_PROPERTY_INDEX_SENTENCE_TERMINAL
+terminal_punctuation, UC_PROPERTY_INDEX_TERMINAL_PUNCTUATION
+terminalpunctuation, UC_PROPERTY_INDEX_TERMINAL_PUNCTUATION
+term, UC_PROPERTY_INDEX_TERMINAL_PUNCTUATION
+currency_symbol, UC_PROPERTY_INDEX_CURRENCY_SYMBOL
+currencysymbol, UC_PROPERTY_INDEX_CURRENCY_SYMBOL
+math, UC_PROPERTY_INDEX_MATH
+other_math, UC_PROPERTY_INDEX_OTHER_MATH
+othermath, UC_PROPERTY_INDEX_OTHER_MATH
+omath, UC_PROPERTY_INDEX_OTHER_MATH
+paired_punctuation, UC_PROPERTY_INDEX_PAIRED_PUNCTUATION
+pairedpunctuation, UC_PROPERTY_INDEX_PAIRED_PUNCTUATION
+left_of_pair, UC_PROPERTY_INDEX_LEFT_OF_PAIR
+leftofpair, UC_PROPERTY_INDEX_LEFT_OF_PAIR
+combining, UC_PROPERTY_INDEX_COMBINING
+composite, UC_PROPERTY_INDEX_COMPOSITE
+decimal_digit, UC_PROPERTY_INDEX_DECIMAL_DIGIT
+decimaldigit, UC_PROPERTY_INDEX_DECIMAL_DIGIT
+numeric, UC_PROPERTY_INDEX_NUMERIC
+diacritic, UC_PROPERTY_INDEX_DIACRITIC
+dia, UC_PROPERTY_INDEX_DIACRITIC
+extender, UC_PROPERTY_INDEX_EXTENDER
+ext, UC_PROPERTY_INDEX_EXTENDER
+ignorable_control, UC_PROPERTY_INDEX_IGNORABLE_CONTROL
+ignorablecontrol, UC_PROPERTY_INDEX_IGNORABLE_CONTROL
--- a/lib/unictype/scripts_byname.gperf
+++ b/lib/unictype/scripts_byname.gperf
@@ -1,7 +1,7 @@
 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
 /* Unicode scripts.  */
 /* Generated automatically by gen-uni-tables.c for Unicode 6.0.0.  */
-struct named_script { const char *name; unsigned int index; };
+struct named_script { int name; unsigned int index; };
 %struct-type
 %language=ANSI-C
 %define hash-function-name scripts_hash
@@ -9,6 +9,8 @@
 %readonly-tables
 %global-table
 %define word-array-name script_names
+%pic
+%define string-pool-name script_stringpool
 %%
 Common, 0
 Latin, 1
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -796,11 +796,14 @@
 #    if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #     define getpagesize() _gl_getpagesize ()
 #    else
+#     if !GNULIB_defined_getpagesize_function
 static inline int
 getpagesize ()
 {
   return _gl_getpagesize ();
 }
+#      define GNULIB_defined_getpagesize_function 1
+#     endif
 #    endif
 #   endif
 #  endif
--- a/lib/unlink.c
+++ b/lib/unlink.c
@@ -24,6 +24,8 @@
 #include <string.h>
 #include <sys/stat.h>
 
+#include "dosname.h"
+
 #undef unlink
 
 /* Remove file NAME.
--- a/lib/unlinkat.c
+++ b/lib/unlinkat.c
@@ -26,6 +26,7 @@
 #include <string.h>
 #include <sys/stat.h>
 
+#include "dosname.h"
 #include "openat.h"
 
 #if HAVE_UNLINKAT
--- a/lib/userspec.c
+++ b/lib/userspec.c
@@ -80,7 +80,7 @@
    POSIX says that only '0' through '9' are digits.  Prefer ISDIGIT to
    isdigit unless it's important to use the locale's definition
    of `digit' even when the host does not conform to POSIX.  */
-#define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9)
+# define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9)
 
 /* Return true if STR represents an unsigned decimal integer.  */
 
--- a/lib/vasnprintf.c
+++ b/lib/vasnprintf.c
@@ -935,11 +935,11 @@
         abort ();
       m.limbs[--i] = (hi << (GMP_LIMB_BITS / 2)) | lo;
     }
-#if 0 /* On FreeBSD 6.1/x86, 'long double' numbers sometimes have excess
-         precision.  */
+#  if 0 /* On FreeBSD 6.1/x86, 'long double' numbers sometimes have excess
+           precision.  */
   if (!(y == 0.0L))
     abort ();
-#endif
+#  endif
   /* Normalise.  */
   while (m.nlimbs > 0 && m.limbs[m.nlimbs - 1] == 0)
     m.nlimbs--;
@@ -1753,8 +1753,9 @@
     return NULL;
 
 #define CLEANUP() \
-  free (d.dir);                                                         \
-  if (a.arg)                                                            \
+  if (d.dir != d.direct_alloc_dir)                                      \
+    free (d.dir);                                                       \
+  if (a.arg != a.direct_alloc_arg)                                      \
     free (a.arg);
 
   if (PRINTF_FETCHARGS (args, &a) < 0)
--- a/lib/vasnprintf.h
+++ b/lib/vasnprintf.h
@@ -24,16 +24,16 @@
 /* Get size_t.  */
 #include <stddef.h>
 
-#ifndef __attribute__
 /* The __attribute__ feature is available in gcc versions 2.5 and later.
    The __-protected variants of the attributes 'format' and 'printf' are
    accepted by gcc versions 2.6.4 (effectively 2.7) and later.
-   We enable __attribute__ only if these are supported too, because
+   We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because
    gnulib and libintl do '#define printf __printf__' when they override
    the 'printf' function.  */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
-#  define __attribute__(Spec)   /* empty */
-# endif
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
+# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
+#else
+# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
 #endif
 
 #ifdef __cplusplus
@@ -69,9 +69,9 @@
 # define vasnprintf rpl_vasnprintf
 #endif
 extern char * asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...)
-       __attribute__ ((__format__ (__printf__, 3, 4)));
+       _GL_ATTRIBUTE_FORMAT ((__printf__, 3, 4));
 extern char * vasnprintf (char *resultbuf, size_t *lengthp, const char *format, va_list args)
-       __attribute__ ((__format__ (__printf__, 3, 0)));
+       _GL_ATTRIBUTE_FORMAT ((__printf__, 3, 0));
 
 #ifdef __cplusplus
 }
--- a/lib/verror.h
+++ b/lib/verror.h
@@ -17,9 +17,10 @@
 #ifndef _VERROR_H
 #define _VERROR_H 1
 
-#include "error.h"
 #include <stdarg.h>
 
+#include "error.h" /* for _GL_ATTRIBUTE_FORMAT */
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -32,7 +33,7 @@
 
 extern void verror (int __status, int __errnum, const char *__format,
                     va_list __args)
-     __attribute__ ((__format__ (__printf__, 3, 0)));
+     _GL_ATTRIBUTE_FORMAT ((__printf__, 3, 0));
 
 /* Print a message with `vfprintf (stderr, FORMAT, ARGS)';
    if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM).
@@ -44,7 +45,7 @@
 extern void verror_at_line (int __status, int __errnum, const char *__fname,
                             unsigned int __lineno, const char *__format,
                             va_list __args)
-     __attribute__ ((__format__ (__printf__, 5, 0)));
+     _GL_ATTRIBUTE_FORMAT ((__printf__, 5, 0));
 
 #ifdef __cplusplus
 }
--- a/lib/version-etc.h
+++ b/lib/version-etc.h
@@ -23,11 +23,11 @@
 # include <stdio.h>
 
 /* The `sentinel' attribute was added in gcc 4.0.  */
-#ifndef ATTRIBUTE_SENTINEL
+#ifndef _GL_ATTRIBUTE_SENTINEL
 # if 4 <= __GNUC__
-#  define ATTRIBUTE_SENTINEL __attribute__ ((__sentinel__))
+#  define _GL_ATTRIBUTE_SENTINEL __attribute__ ((__sentinel__))
 # else
-#  define ATTRIBUTE_SENTINEL /* empty */
+#  define _GL_ATTRIBUTE_SENTINEL /* empty */
 # endif
 #endif
 
@@ -70,7 +70,7 @@
                          const char *command_name, const char *package,
                          const char *version,
                          /* const char *author1, ..., NULL */ ...)
-  ATTRIBUTE_SENTINEL;
+  _GL_ATTRIBUTE_SENTINEL;
 
 /* Display the usual `Report bugs to' stanza */
 extern void emit_bug_reporting_address (void);
--- a/lib/wchar.in.h
+++ b/lib/wchar.in.h
@@ -104,10 +104,12 @@
    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@
+# if !GNULIB_defined_mbstate_t
 typedef int rpl_mbstate_t;
-# undef mbstate_t
-# define mbstate_t rpl_mbstate_t
-# define GNULIB_defined_mbstate_t 1
+#  undef mbstate_t
+#  define mbstate_t rpl_mbstate_t
+#  define GNULIB_defined_mbstate_t 1
+# endif
 #endif
 
 
@@ -428,6 +430,493 @@
 #endif
 
 
+/* Search N wide characters of S for C.  */
+#if @GNULIB_WMEMCHR@
+# if !@HAVE_WMEMCHR@
+_GL_FUNCDECL_SYS (wmemchr, wchar_t *, (const wchar_t *s, wchar_t c, size_t n));
+# endif
+_GL_CXXALIAS_SYS (wmemchr, wchar_t *, (const wchar_t *s, wchar_t c, size_t n));
+_GL_CXXALIASWARN (wmemchr);
+#elif defined GNULIB_POSIXCHECK
+# undef wmemchr
+# if HAVE_RAW_DECL_WMEMCHR
+_GL_WARN_ON_USE (wmemchr, "wmemchr is unportable - "
+                 "use gnulib module wmemchr for portability");
+# endif
+#endif
+
+
+/* Compare N wide characters of S1 and S2.  */
+#if @GNULIB_WMEMCMP@
+# if !@HAVE_WMEMCMP@
+_GL_FUNCDECL_SYS (wmemcmp, int,
+                  (const wchar_t *s1, const wchar_t *s2, size_t n));
+# endif
+_GL_CXXALIAS_SYS (wmemcmp, int,
+                  (const wchar_t *s1, const wchar_t *s2, size_t n));
+_GL_CXXALIASWARN (wmemcmp);
+#elif defined GNULIB_POSIXCHECK
+# undef wmemcmp
+# if HAVE_RAW_DECL_WMEMCMP
+_GL_WARN_ON_USE (wmemcmp, "wmemcmp is unportable - "
+                 "use gnulib module wmemcmp for portability");
+# endif
+#endif
+
+
+/* Copy N wide characters of SRC to DEST.  */
+#if @GNULIB_WMEMCPY@
+# if !@HAVE_WMEMCPY@
+_GL_FUNCDECL_SYS (wmemcpy, wchar_t *,
+                  (wchar_t *dest, const wchar_t *src, size_t n));
+# endif
+_GL_CXXALIAS_SYS (wmemcpy, wchar_t *,
+                  (wchar_t *dest, const wchar_t *src, size_t n));
+_GL_CXXALIASWARN (wmemcpy);
+#elif defined GNULIB_POSIXCHECK
+# undef wmemcpy
+# if HAVE_RAW_DECL_WMEMCPY
+_GL_WARN_ON_USE (wmemcpy, "wmemcpy is unportable - "
+                 "use gnulib module wmemcpy for portability");
+# endif
+#endif
+
+
+/* Copy N wide characters of SRC to DEST, guaranteeing correct behavior for
+   overlapping memory areas.  */
+#if @GNULIB_WMEMMOVE@
+# if !@HAVE_WMEMMOVE@
+_GL_FUNCDECL_SYS (wmemmove, wchar_t *,
+                  (wchar_t *dest, const wchar_t *src, size_t n));
+# endif
+_GL_CXXALIAS_SYS (wmemmove, wchar_t *,
+                  (wchar_t *dest, const wchar_t *src, size_t n));
+_GL_CXXALIASWARN (wmemmove);
+#elif defined GNULIB_POSIXCHECK
+# undef wmemmove
+# if HAVE_RAW_DECL_WMEMMOVE
+_GL_WARN_ON_USE (wmemmove, "wmemmove is unportable - "
+                 "use gnulib module wmemmove for portability");
+# endif
+#endif
+
+
+/* Set N wide characters of S to C.  */
+#if @GNULIB_WMEMSET@
+# if !@HAVE_WMEMSET@
+_GL_FUNCDECL_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
+# endif
+_GL_CXXALIAS_SYS (wmemset, wchar_t *, (wchar_t *s, wchar_t c, size_t n));
+_GL_CXXALIASWARN (wmemset);
+#elif defined GNULIB_POSIXCHECK
+# undef wmemset
+# if HAVE_RAW_DECL_WMEMSET
+_GL_WARN_ON_USE (wmemset, "wmemset is unportable - "
+                 "use gnulib module wmemset for portability");
+# endif
+#endif
+
+
+/* Return the number of wide characters in S.  */
+#if @GNULIB_WCSLEN@
+# if !@HAVE_WCSLEN@
+_GL_FUNCDECL_SYS (wcslen, size_t, (const wchar_t *s));
+# endif
+_GL_CXXALIAS_SYS (wcslen, size_t, (const wchar_t *s));
+_GL_CXXALIASWARN (wcslen);
+#elif defined GNULIB_POSIXCHECK
+# undef wcslen
+# if HAVE_RAW_DECL_WCSLEN
+_GL_WARN_ON_USE (wcslen, "wcslen is unportable - "
+                 "use gnulib module wcslen for portability");
+# endif
+#endif
+
+
+/* Return the number of wide characters in S, but at most MAXLEN.  */
+#if @GNULIB_WCSNLEN@
+# if !@HAVE_WCSNLEN@
+_GL_FUNCDECL_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen));
+# endif
+_GL_CXXALIAS_SYS (wcsnlen, size_t, (const wchar_t *s, size_t maxlen));
+_GL_CXXALIASWARN (wcsnlen);
+#elif defined GNULIB_POSIXCHECK
+# undef wcsnlen
+# if HAVE_RAW_DECL_WCSNLEN
+_GL_WARN_ON_USE (wcsnlen, "wcsnlen is unportable - "
+                 "use gnulib module wcsnlen for portability");
+# endif
+#endif
+
+
+/* Copy SRC to DEST.  */
+#if @GNULIB_WCSCPY@
+# if !@HAVE_WCSCPY@
+_GL_FUNCDECL_SYS (wcscpy, wchar_t *, (wchar_t *dest, const wchar_t *src));
+# endif
+_GL_CXXALIAS_SYS (wcscpy, wchar_t *, (wchar_t *dest, const wchar_t *src));
+_GL_CXXALIASWARN (wcscpy);
+#elif defined GNULIB_POSIXCHECK
+# undef wcscpy
+# if HAVE_RAW_DECL_WCSCPY
+_GL_WARN_ON_USE (wcscpy, "wcscpy is unportable - "
+                 "use gnulib module wcscpy for portability");
+# endif
+#endif
+
+
+/* Copy SRC to DEST, returning the address of the terminating L'\0' in DEST.  */
+#if @GNULIB_WCPCPY@
+# if !@HAVE_WCPCPY@
+_GL_FUNCDECL_SYS (wcpcpy, wchar_t *, (wchar_t *dest, const wchar_t *src));
+# endif
+_GL_CXXALIAS_SYS (wcpcpy, wchar_t *, (wchar_t *dest, const wchar_t *src));
+_GL_CXXALIASWARN (wcpcpy);
+#elif defined GNULIB_POSIXCHECK
+# undef wcpcpy
+# if HAVE_RAW_DECL_WCPCPY
+_GL_WARN_ON_USE (wcpcpy, "wcpcpy is unportable - "
+                 "use gnulib module wcpcpy for portability");
+# endif
+#endif
+
+
+/* Copy no more than N wide characters of SRC to DEST.  */
+#if @GNULIB_WCSNCPY@
+# if !@HAVE_WCSNCPY@
+_GL_FUNCDECL_SYS (wcsncpy, wchar_t *,
+                  (wchar_t *dest, const wchar_t *src, size_t n));
+# endif
+_GL_CXXALIAS_SYS (wcsncpy, wchar_t *,
+                  (wchar_t *dest, const wchar_t *src, size_t n));
+_GL_CXXALIASWARN (wcsncpy);
+#elif defined GNULIB_POSIXCHECK
+# undef wcsncpy
+# if HAVE_RAW_DECL_WCSNCPY
+_GL_WARN_ON_USE (wcsncpy, "wcsncpy is unportable - "
+                 "use gnulib module wcsncpy for portability");
+# endif
+#endif
+
+
+/* Copy no more than N characters of SRC to DEST, returning the address of
+   the last character written into DEST.  */
+#if @GNULIB_WCPNCPY@
+# if !@HAVE_WCPNCPY@
+_GL_FUNCDECL_SYS (wcpncpy, wchar_t *,
+                  (wchar_t *dest, const wchar_t *src, size_t n));
+# endif
+_GL_CXXALIAS_SYS (wcpncpy, wchar_t *,
+                  (wchar_t *dest, const wchar_t *src, size_t n));
+_GL_CXXALIASWARN (wcpncpy);
+#elif defined GNULIB_POSIXCHECK
+# undef wcpncpy
+# if HAVE_RAW_DECL_WCPNCPY
+_GL_WARN_ON_USE (wcpncpy, "wcpncpy is unportable - "
+                 "use gnulib module wcpncpy for portability");
+# endif
+#endif
+
+
+/* Append SRC onto DEST.  */
+#if @GNULIB_WCSCAT@
+# if !@HAVE_WCSCAT@
+_GL_FUNCDECL_SYS (wcscat, wchar_t *, (wchar_t *dest, const wchar_t *src));
+# endif
+_GL_CXXALIAS_SYS (wcscat, wchar_t *, (wchar_t *dest, const wchar_t *src));
+_GL_CXXALIASWARN (wcscat);
+#elif defined GNULIB_POSIXCHECK
+# undef wcscat
+# if HAVE_RAW_DECL_WCSCAT
+_GL_WARN_ON_USE (wcscat, "wcscat is unportable - "
+                 "use gnulib module wcscat for portability");
+# endif
+#endif
+
+
+/* Append no more than N wide characters of SRC onto DEST.  */
+#if @GNULIB_WCSNCAT@
+# if !@HAVE_WCSNCAT@
+_GL_FUNCDECL_SYS (wcsncat, wchar_t *,
+                  (wchar_t *dest, const wchar_t *src, size_t n));
+# endif
+_GL_CXXALIAS_SYS (wcsncat, wchar_t *,
+                  (wchar_t *dest, const wchar_t *src, size_t n));
+_GL_CXXALIASWARN (wcsncat);
+#elif defined GNULIB_POSIXCHECK
+# undef wcsncat
+# if HAVE_RAW_DECL_WCSNCAT
+_GL_WARN_ON_USE (wcsncat, "wcsncat is unportable - "
+                 "use gnulib module wcsncat for portability");
+# endif
+#endif
+
+
+/* Compare S1 and S2.  */
+#if @GNULIB_WCSCMP@
+# if !@HAVE_WCSCMP@
+_GL_FUNCDECL_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2));
+# endif
+_GL_CXXALIAS_SYS (wcscmp, int, (const wchar_t *s1, const wchar_t *s2));
+_GL_CXXALIASWARN (wcscmp);
+#elif defined GNULIB_POSIXCHECK
+# undef wcscmp
+# if HAVE_RAW_DECL_WCSCMP
+_GL_WARN_ON_USE (wcscmp, "wcscmp is unportable - "
+                 "use gnulib module wcscmp for portability");
+# endif
+#endif
+
+
+/* Compare no more than N wide characters of S1 and S2.  */
+#if @GNULIB_WCSNCMP@
+# if !@HAVE_WCSNCMP@
+_GL_FUNCDECL_SYS (wcsncmp, int,
+                  (const wchar_t *s1, const wchar_t *s2, size_t n));
+# endif
+_GL_CXXALIAS_SYS (wcsncmp, int,
+                  (const wchar_t *s1, const wchar_t *s2, size_t n));
+_GL_CXXALIASWARN (wcsncmp);
+#elif defined GNULIB_POSIXCHECK
+# undef wcsncmp
+# if HAVE_RAW_DECL_WCSNCMP
+_GL_WARN_ON_USE (wcsncmp, "wcsncmp is unportable - "
+                 "use gnulib module wcsncmp for portability");
+# endif
+#endif
+
+
+/* Compare S1 and S2, ignoring case.  */
+#if @GNULIB_WCSCASECMP@
+# if !@HAVE_WCSCASECMP@
+_GL_FUNCDECL_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2));
+# endif
+_GL_CXXALIAS_SYS (wcscasecmp, int, (const wchar_t *s1, const wchar_t *s2));
+_GL_CXXALIASWARN (wcscasecmp);
+#elif defined GNULIB_POSIXCHECK
+# undef wcscasecmp
+# if HAVE_RAW_DECL_WCSCASECMP
+_GL_WARN_ON_USE (wcscasecmp, "wcscasecmp is unportable - "
+                 "use gnulib module wcscasecmp for portability");
+# endif
+#endif
+
+
+/* Compare no more than N chars of S1 and S2, ignoring case.  */
+#if @GNULIB_WCSNCASECMP@
+# if !@HAVE_WCSNCASECMP@
+_GL_FUNCDECL_SYS (wcsncasecmp, int,
+                  (const wchar_t *s1, const wchar_t *s2, size_t n));
+# endif
+_GL_CXXALIAS_SYS (wcsncasecmp, int,
+                  (const wchar_t *s1, const wchar_t *s2, size_t n));
+_GL_CXXALIASWARN (wcsncasecmp);
+#elif defined GNULIB_POSIXCHECK
+# undef wcsncasecmp
+# if HAVE_RAW_DECL_WCSNCASECMP
+_GL_WARN_ON_USE (wcsncasecmp, "wcsncasecmp is unportable - "
+                 "use gnulib module wcsncasecmp for portability");
+# endif
+#endif
+
+
+/* Compare S1 and S2, both interpreted as appropriate to the LC_COLLATE
+   category of the current locale.  */
+#if @GNULIB_WCSCOLL@
+# if !@HAVE_WCSCOLL@
+_GL_FUNCDECL_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2));
+# endif
+_GL_CXXALIAS_SYS (wcscoll, int, (const wchar_t *s1, const wchar_t *s2));
+_GL_CXXALIASWARN (wcscoll);
+#elif defined GNULIB_POSIXCHECK
+# undef wcscoll
+# if HAVE_RAW_DECL_WCSCOLL
+_GL_WARN_ON_USE (wcscoll, "wcscoll is unportable - "
+                 "use gnulib module wcscoll for portability");
+# endif
+#endif
+
+
+/* Transform S2 into array pointed to by S1 such that if wcscmp is applied
+   to two transformed strings the result is the as applying 'wcscoll' to the
+   original strings.  */
+#if @GNULIB_WCSXFRM@
+# if !@HAVE_WCSXFRM@
+_GL_FUNCDECL_SYS (wcsxfrm, size_t, (wchar_t *s1, const wchar_t *s2, size_t n));
+# endif
+_GL_CXXALIAS_SYS (wcsxfrm, size_t, (wchar_t *s1, const wchar_t *s2, size_t n));
+_GL_CXXALIASWARN (wcsxfrm);
+#elif defined GNULIB_POSIXCHECK
+# undef wcsxfrm
+# if HAVE_RAW_DECL_WCSXFRM
+_GL_WARN_ON_USE (wcsxfrm, "wcsxfrm is unportable - "
+                 "use gnulib module wcsxfrm for portability");
+# endif
+#endif
+
+
+/* Duplicate S, returning an identical malloc'd string.  */
+#if @GNULIB_WCSDUP@
+# if !@HAVE_WCSDUP@
+_GL_FUNCDECL_SYS (wcsdup, wchar_t *, (const wchar_t *s));
+# endif
+_GL_CXXALIAS_SYS (wcsdup, wchar_t *, (const wchar_t *s));
+_GL_CXXALIASWARN (wcsdup);
+#elif defined GNULIB_POSIXCHECK
+# undef wcsdup
+# if HAVE_RAW_DECL_WCSDUP
+_GL_WARN_ON_USE (wcsdup, "wcsdup is unportable - "
+                 "use gnulib module wcsdup for portability");
+# endif
+#endif
+
+
+/* Find the first occurrence of WC in WCS.  */
+#if @GNULIB_WCSCHR@
+# if !@HAVE_WCSCHR@
+_GL_FUNCDECL_SYS (wcschr, wchar_t *, (const wchar_t *wcs, wchar_t wc));
+# endif
+_GL_CXXALIAS_SYS (wcschr, wchar_t *, (const wchar_t *wcs, wchar_t wc));
+_GL_CXXALIASWARN (wcschr);
+#elif defined GNULIB_POSIXCHECK
+# undef wcschr
+# if HAVE_RAW_DECL_WCSCHR
+_GL_WARN_ON_USE (wcschr, "wcschr is unportable - "
+                 "use gnulib module wcschr for portability");
+# endif
+#endif
+
+
+/* Find the last occurrence of WC in WCS.  */
+#if @GNULIB_WCSRCHR@
+# if !@HAVE_WCSRCHR@
+_GL_FUNCDECL_SYS (wcsrchr, wchar_t *, (const wchar_t *wcs, wchar_t wc));
+# endif
+_GL_CXXALIAS_SYS (wcsrchr, wchar_t *, (const wchar_t *wcs, wchar_t wc));
+_GL_CXXALIASWARN (wcsrchr);
+#elif defined GNULIB_POSIXCHECK
+# undef wcsrchr
+# if HAVE_RAW_DECL_WCSRCHR
+_GL_WARN_ON_USE (wcsrchr, "wcsrchr is unportable - "
+                 "use gnulib module wcsrchr for portability");
+# endif
+#endif
+
+
+/* Return the length of the initial segmet of WCS which consists entirely
+   of wide characters not in REJECT.  */
+#if @GNULIB_WCSCSPN@
+# if !@HAVE_WCSCSPN@
+_GL_FUNCDECL_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject));
+# endif
+_GL_CXXALIAS_SYS (wcscspn, size_t, (const wchar_t *wcs, const wchar_t *reject));
+_GL_CXXALIASWARN (wcscspn);
+#elif defined GNULIB_POSIXCHECK
+# undef wcscspn
+# if HAVE_RAW_DECL_WCSCSPN
+_GL_WARN_ON_USE (wcscspn, "wcscspn is unportable - "
+                 "use gnulib module wcscspn for portability");
+# endif
+#endif
+
+
+/* Return the length of the initial segmet of WCS which consists entirely
+   of wide characters in ACCEPT.  */
+#if @GNULIB_WCSSPN@
+# if !@HAVE_WCSSPN@
+_GL_FUNCDECL_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept));
+# endif
+_GL_CXXALIAS_SYS (wcsspn, size_t, (const wchar_t *wcs, const wchar_t *accept));
+_GL_CXXALIASWARN (wcsspn);
+#elif defined GNULIB_POSIXCHECK
+# undef wcsspn
+# if HAVE_RAW_DECL_WCSSPN
+_GL_WARN_ON_USE (wcsspn, "wcsspn is unportable - "
+                 "use gnulib module wcsspn for portability");
+# endif
+#endif
+
+
+/* Find the first occurrence in WCS of any character in ACCEPT.  */
+#if @GNULIB_WCSPBRK@
+# if !@HAVE_WCSPBRK@
+_GL_FUNCDECL_SYS (wcspbrk, wchar_t *,
+                  (const wchar_t *wcs, const wchar_t *accept));
+# endif
+_GL_CXXALIAS_SYS (wcspbrk, wchar_t *,
+                  (const wchar_t *wcs, const wchar_t *accept));
+_GL_CXXALIASWARN (wcspbrk);
+#elif defined GNULIB_POSIXCHECK
+# undef wcspbrk
+# if HAVE_RAW_DECL_WCSPBRK
+_GL_WARN_ON_USE (wcspbrk, "wcspbrk is unportable - "
+                 "use gnulib module wcspbrk for portability");
+# endif
+#endif
+
+
+/* Find the first occurrence of NEEDLE in HAYSTACK.  */
+#if @GNULIB_WCSSTR@
+# if !@HAVE_WCSSTR@
+_GL_FUNCDECL_SYS (wcsstr, wchar_t *,
+                  (const wchar_t *haystack, const wchar_t *needle));
+# endif
+_GL_CXXALIAS_SYS (wcsstr, wchar_t *,
+                  (const wchar_t *haystack, const wchar_t *needle));
+_GL_CXXALIASWARN (wcsstr);
+#elif defined GNULIB_POSIXCHECK
+# undef wcsstr
+# if HAVE_RAW_DECL_WCSSTR
+_GL_WARN_ON_USE (wcsstr, "wcsstr is unportable - "
+                 "use gnulib module wcsstr for portability");
+# endif
+#endif
+
+
+/* Divide WCS into tokens separated by characters in DELIM.  */
+#if @GNULIB_WCSTOK@
+# if !@HAVE_WCSTOK@
+_GL_FUNCDECL_SYS (wcstok, wchar_t *,
+                  (wchar_t *wcs, const wchar_t *delim, wchar_t **ptr));
+# endif
+_GL_CXXALIAS_SYS (wcstok, wchar_t *,
+                  (wchar_t *wcs, const wchar_t *delim, wchar_t **ptr));
+_GL_CXXALIASWARN (wcstok);
+#elif defined GNULIB_POSIXCHECK
+# undef wcstok
+# if HAVE_RAW_DECL_WCSTOK
+_GL_WARN_ON_USE (wcstok, "wcstok is unportable - "
+                 "use gnulib module wcstok for portability");
+# endif
+#endif
+
+
+/* Determine number of column positions required for first N wide
+   characters (or fewer if S ends before this) in S.  */
+#if @GNULIB_WCSWIDTH@
+# if @REPLACE_WCSWIDTH@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef wcswidth
+#   define wcswidth rpl_wcswidth
+#  endif
+_GL_FUNCDECL_RPL (wcswidth, int, (const wchar_t *s, size_t n));
+_GL_CXXALIAS_RPL (wcswidth, int, (const wchar_t *s, size_t n));
+# else
+#  if !@HAVE_WCSWIDTH@
+_GL_FUNCDECL_SYS (wcswidth, int, (const wchar_t *s, size_t n));
+#  endif
+_GL_CXXALIAS_SYS (wcswidth, int, (const wchar_t *s, size_t n));
+# endif
+_GL_CXXALIASWARN (wcswidth);
+#elif defined GNULIB_POSIXCHECK
+# undef wcswidth
+# if HAVE_RAW_DECL_WCSWIDTH
+_GL_WARN_ON_USE (wcswidth, "wcswidth is unportable - "
+                 "use gnulib module wcswidth for portability");
+# endif
+#endif
+
+
 #endif /* _GL_WCHAR_H */
 #endif /* _GL_WCHAR_H */
 #endif
new file mode 100644
--- /dev/null
+++ b/lib/wcpcpy-impl.h
@@ -0,0 +1,24 @@
+/* Copy a wide string.
+   Copyright (C) 1999, 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 1999.
+
+   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/>.  */
+
+wchar_t *
+wcpcpy (wchar_t *dest, const wchar_t *src)
+{
+  for (; (*dest = *src) != (wchar_t)'\0'; src++, dest++)
+    ;
+  return dest;
+}
new file mode 100644
--- /dev/null
+++ b/lib/wcpcpy.c
@@ -0,0 +1,23 @@
+/* Copy a wide string.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "wcpcpy-impl.h"
new file mode 100644
--- /dev/null
+++ b/lib/wcpncpy-impl.h
@@ -0,0 +1,30 @@
+/* Copy a size-bounded wide string.
+   Copyright (C) 1999, 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 1999.
+
+   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/>.  */
+
+wchar_t *
+wcpncpy (wchar_t *dest, const wchar_t *src, size_t n)
+{
+  for (; n > 0 && (*dest = *src) != (wchar_t)'\0'; src++, dest++, n--)
+    ;
+
+  /* This behavior is rarely useful, but it is here for consistency with
+     wcsncpy.  */
+  for (; n > 0; n--)
+    *dest++ = (wchar_t)'\0';
+
+  return dest-1;
+}
new file mode 100644
--- /dev/null
+++ b/lib/wcpncpy.c
@@ -0,0 +1,23 @@
+/* Copy a size-bounded wide string.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "wcpncpy-impl.h"
new file mode 100644
--- /dev/null
+++ b/lib/wcscasecmp-impl.h
@@ -0,0 +1,32 @@
+/* Compare two wide strings ignoring case.
+   Copyright (C) 1999, 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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/>.  */
+
+int
+wcscasecmp (const wchar_t *s1, const wchar_t *s2)
+{
+  for (;;)
+    {
+      wchar_t wc1 = towlower (*s1++);
+      wchar_t wc2 = towlower (*s2++);
+      if (wc1 != (wchar_t)'\0' && wc1 == wc2)
+        continue;
+      /* Note that wc1 and wc2 each have at most 31 bits.  */
+      return (int)wc1 - (int)wc2;
+             /* > 0 if wc1 > wc2, < 0 if wc1 < wc2,
+                = 0 if wc1 and wc2 are both '\0'.  */
+    }
+}
new file mode 100644
--- /dev/null
+++ b/lib/wcscasecmp.c
@@ -0,0 +1,25 @@
+/* Compare two wide strings ignoring case.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 <wctype.h>
+
+#include "wcscasecmp-impl.h"
new file mode 100644
--- /dev/null
+++ b/lib/wcscat-impl.h
@@ -0,0 +1,26 @@
+/* Concatenate two wide strings.
+   Copyright (C) 1999, 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 1999.
+
+   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/>.  */
+
+wchar_t *
+wcscat (wchar_t *dest, const wchar_t *src)
+{
+  wchar_t *destptr = dest + wcslen (dest);
+
+  for (; (*destptr = *src) != (wchar_t)'\0'; src++, destptr++)
+    ;
+  return dest;
+}
new file mode 100644
--- /dev/null
+++ b/lib/wcscat.c
@@ -0,0 +1,23 @@
+/* Concatenate two wide strings.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "wcscat-impl.h"
new file mode 100644
--- /dev/null
+++ b/lib/wcschr-impl.h
@@ -0,0 +1,32 @@
+/* Search wide string for a wide character.
+   Copyright (C) 1999, 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 1999.
+
+   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/>.  */
+
+wchar_t *
+wcschr (const wchar_t *wcs, wchar_t wc)
+{
+  for (;; wcs++)
+    {
+      if (*wcs == wc)
+        break;
+      if (*wcs == (wchar_t)'\0')
+        goto notfound;
+    }
+  return (wchar_t *) wcs;
+
+ notfound:
+  return NULL;
+}
new file mode 100644
--- /dev/null
+++ b/lib/wcschr.c
@@ -0,0 +1,23 @@
+/* Search wide string for a wide character.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "wcschr-impl.h"
new file mode 100644
--- /dev/null
+++ b/lib/wcscmp-impl.h
@@ -0,0 +1,32 @@
+/* Compare two wide strings.
+   Copyright (C) 1999, 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 1999.
+
+   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/>.  */
+
+int
+wcscmp (const wchar_t *s1, const wchar_t *s2)
+{
+  for (;;)
+    {
+      wchar_t wc1 = *s1++;
+      wchar_t wc2 = *s2++;
+      if (wc1 != (wchar_t)'\0' && wc1 == wc2)
+        continue;
+      /* Note that wc1 and wc2 each have at most 31 bits.  */
+      return (int)wc1 - (int)wc2;
+             /* > 0 if wc1 > wc2, < 0 if wc1 < wc2,
+                = 0 if wc1 and wc2 are both '\0'.  */
+    }
+}
new file mode 100644
--- /dev/null
+++ b/lib/wcscmp.c
@@ -0,0 +1,23 @@
+/* Compare two wide strings.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "wcscmp-impl.h"
new file mode 100644
--- /dev/null
+++ b/lib/wcscoll-impl.h
@@ -0,0 +1,111 @@
+/* Compare two wide strings using the current locale.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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/>.  */
+
+int
+wcscoll (const wchar_t *s1, const wchar_t *s2)
+{
+  char mbbuf1[1024];
+  char mbbuf2[1024];
+  char *mbs1;
+  char *mbs2;
+
+  {
+    int saved_errno = errno;
+
+    /* Convert s1 to a multibyte string, trying to avoid malloc().  */
+    {
+      size_t ret;
+
+      ret = wcstombs (mbbuf1, s1, sizeof (mbbuf1));
+      if (ret == (size_t)-1)
+        goto failed1;
+      if (ret < sizeof (mbbuf1))
+        mbs1 = mbbuf1;
+      else
+        {
+          size_t need = wcstombs (NULL, s1, 0);
+          if (need == (size_t)-1)
+            goto failed1;
+          mbs1 = (char *) malloc (need + 1);
+          if (mbs1 == NULL)
+            goto out_of_memory1;
+          ret = wcstombs (mbs1, s1, need + 1);
+          if (ret != need)
+            abort ();
+        }
+    }
+
+    /* Convert s2 to a multibyte string, trying to avoid malloc().  */
+    {
+      size_t ret;
+
+      ret = wcstombs (mbbuf2, s2, sizeof (mbbuf2));
+      if (ret == (size_t)-1)
+        goto failed2;
+      if (ret < sizeof (mbbuf2))
+        mbs2 = mbbuf2;
+      else
+        {
+          size_t need = wcstombs (NULL, s2, 0);
+          if (need == (size_t)-1)
+            goto failed2;
+          mbs2 = (char *) malloc (need + 1);
+          if (mbs2 == NULL)
+            goto out_of_memory2;
+          ret = wcstombs (mbs2, s2, need + 1);
+          if (ret != need)
+            abort ();
+        }
+    }
+
+    /* No error so far.  */
+    errno = saved_errno;
+  }
+
+  /* Compare the two multibyte strings.  */
+  {
+    int result = strcoll (mbs1, mbs2);
+
+    if (mbs1 != mbbuf1)
+      {
+        int saved_errno = errno;
+        free (mbs1);
+        errno = saved_errno;
+      }
+    if (mbs2 != mbbuf2)
+      {
+        int saved_errno = errno;
+        free (mbs2);
+        errno = saved_errno;
+      }
+    return result;
+  }
+
+ out_of_memory2:
+  if (mbs1 != mbbuf1)
+    free (mbs1);
+ out_of_memory1:
+  errno = ENOMEM;
+  return 0;
+
+ failed2:
+  if (mbs1 != mbbuf1)
+    free (mbs1);
+ failed1:
+  errno = EILSEQ;
+  return 0;
+}
new file mode 100644
--- /dev/null
+++ b/lib/wcscoll.c
@@ -0,0 +1,27 @@
+/* Compare two wide strings using the current locale.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "wcscoll-impl.h"
new file mode 100644
--- /dev/null
+++ b/lib/wcscpy-impl.h
@@ -0,0 +1,26 @@
+/* Copy a wide string.
+   Copyright (C) 1999, 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 1999.
+
+   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/>.  */
+
+wchar_t *
+wcscpy (wchar_t *dest, const wchar_t *src)
+{
+  wchar_t *destptr = dest;
+
+  for (; (*destptr = *src) != (wchar_t)'\0'; src++, destptr++)
+    ;
+  return dest;
+}
new file mode 100644
--- /dev/null
+++ b/lib/wcscpy.c
@@ -0,0 +1,23 @@
+/* Copy a wide string.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "wcscpy-impl.h"
new file mode 100644
--- /dev/null
+++ b/lib/wcscspn-impl.h
@@ -0,0 +1,47 @@
+/* Search a wide string for any of a set of wide characters.
+   Copyright (C) 1999, 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 1999.
+
+   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/>.  */
+
+size_t
+wcscspn (const wchar_t *wcs, const wchar_t *reject)
+{
+  /* Optimize two cases.  */
+  if (reject[0] == (wchar_t)'\0')
+    return wcslen (wcs);
+
+  if (reject[1] == (wchar_t)'\0')
+    {
+      wchar_t wc = reject[0];
+      const wchar_t *ptr = wcs;
+      for (; *ptr != (wchar_t)'\0'; ptr++)
+        {
+          if (*ptr == wc)
+            break;
+        }
+      return ptr - wcs;
+    }
+
+  /* General case.  */
+  {
+    const wchar_t *ptr = wcs;
+    for (; *ptr != (wchar_t)'\0'; ptr++)
+      {
+        if (wcschr (reject, *ptr))
+          break;
+      }
+    return ptr - wcs;
+  }
+}
new file mode 100644
--- /dev/null
+++ b/lib/wcscspn.c
@@ -0,0 +1,23 @@
+/* Search a wide string for any of a set of wide characters.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "wcscspn-impl.h"
new file mode 100644
--- /dev/null
+++ b/lib/wcsdup-impl.h
@@ -0,0 +1,29 @@
+/* Duplicate a wide string.
+   Copyright (C) 1999, 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 1999.
+
+   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/>.  */
+
+wchar_t *
+wcsdup (const wchar_t *s)
+{
+  size_t n = wcslen (s) + 1;
+  wchar_t *copy = (wchar_t *) malloc (n * sizeof (wchar_t));
+  if (copy != NULL)
+    return wmemcpy (copy, s, n);
+  else
+    /* The glibc documentation does not say that errno should be set to ENOMEM
+       here.  */
+    return NULL;
+}
new file mode 100644
--- /dev/null
+++ b/lib/wcsdup.c
@@ -0,0 +1,25 @@
+/* Duplicate a wide string.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 <stdlib.h>
+
+#include "wcsdup-impl.h"
new file mode 100644
--- /dev/null
+++ b/lib/wcslen-impl.h
@@ -0,0 +1,26 @@
+/* Determine the length of a wide string.
+   Copyright (C) 1999, 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 1999.
+
+   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/>.  */
+
+size_t
+wcslen (const wchar_t *s)
+{
+  const wchar_t *ptr;
+
+  for (ptr = s; *ptr != (wchar_t)'\0'; ptr++)
+    ;
+  return ptr - s;
+}
new file mode 100644
--- /dev/null
+++ b/lib/wcslen.c
@@ -0,0 +1,23 @@
+/* Determine the length of a wide string.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "wcslen-impl.h"
new file mode 100644
--- /dev/null
+++ b/lib/wcsncasecmp-impl.h
@@ -0,0 +1,36 @@
+/* Compare two wide strings ignoring case.
+   Copyright (C) 1999, 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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/>.  */
+
+int
+wcsncasecmp (const wchar_t *s1, const wchar_t *s2, size_t n)
+{
+  for (; n > 0;)
+    {
+      wchar_t wc1 = towlower (*s1++);
+      wchar_t wc2 = towlower (*s2++);
+      if (wc1 != (wchar_t)'\0' && wc1 == wc2)
+        {
+          n--;
+          continue;
+        }
+      /* Note that wc1 and wc2 each have at most 31 bits.  */
+      return (int)wc1 - (int)wc2;
+             /* > 0 if wc1 > wc2, < 0 if wc1 < wc2,
+                = 0 if wc1 and wc2 are both '\0'.  */
+    }
+  return 0;
+}
new file mode 100644
--- /dev/null
+++ b/lib/wcsncasecmp.c
@@ -0,0 +1,25 @@
+/* Compare two wide strings ignoring case.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 <wctype.h>
+
+#include "wcsncasecmp-impl.h"
new file mode 100644
--- /dev/null
+++ b/lib/wcsncat-impl.h
@@ -0,0 +1,28 @@
+/* Append part of a wide string to a wide string.
+   Copyright (C) 1999, 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 1999.
+
+   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/>.  */
+
+wchar_t *
+wcsncat (wchar_t *dest, const wchar_t *src, size_t n)
+{
+  wchar_t *destptr = dest + wcslen (dest);
+
+  for (; n > 0 && (*destptr = *src) != (wchar_t)'\0'; src++, destptr++, n--)
+    ;
+  if (n == 0)
+    *destptr = (wchar_t)'\0';
+  return dest;
+}
new file mode 100644
--- /dev/null
+++ b/lib/wcsncat.c
@@ -0,0 +1,23 @@
+/* Append part of a wide string to a wide string.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "wcsncat-impl.h"
new file mode 100644
--- /dev/null
+++ b/lib/wcsncmp-impl.h
@@ -0,0 +1,36 @@
+/* Compare two wide strings.
+   Copyright (C) 1999, 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 1999.
+
+   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/>.  */
+
+int
+wcsncmp (const wchar_t *s1, const wchar_t *s2, size_t n)
+{
+  for (; n > 0;)
+    {
+      wchar_t wc1 = *s1++;
+      wchar_t wc2 = *s2++;
+      if (wc1 != (wchar_t)'\0' && wc1 == wc2)
+        {
+          n--;
+          continue;
+        }
+      /* Note that wc1 and wc2 each have at most 31 bits.  */
+      return (int)wc1 - (int)wc2;
+             /* > 0 if wc1 > wc2, < 0 if wc1 < wc2,
+                = 0 if wc1 and wc2 are both '\0'.  */
+    }
+  return 0;
+}
new file mode 100644
--- /dev/null
+++ b/lib/wcsncmp.c
@@ -0,0 +1,23 @@
+/* Compare two wide strings.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "wcsncmp-impl.h"
new file mode 100644
--- /dev/null
+++ b/lib/wcsncpy-impl.h
@@ -0,0 +1,32 @@
+/* Copy a size-bounded wide string.
+   Copyright (C) 1999, 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 1999.
+
+   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/>.  */
+
+wchar_t *
+wcsncpy (wchar_t *dest, const wchar_t *src, size_t n)
+{
+  wchar_t *destptr = dest;
+
+  for (; n > 0 && (*destptr = *src) != (wchar_t)'\0'; src++, destptr++, n--)
+    ;
+
+  /* This behavior is rarely useful, but it is specified by the ISO C
+     standard.  */
+  for (; n > 0; n--)
+    *destptr++ = (wchar_t)'\0';
+
+  return dest;
+}
new file mode 100644
--- /dev/null
+++ b/lib/wcsncpy.c
@@ -0,0 +1,23 @@
+/* Copy a size-bounded wide string.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "wcsncpy-impl.h"
new file mode 100644
--- /dev/null
+++ b/lib/wcsnlen-impl.h
@@ -0,0 +1,26 @@
+/* Determine the length of a size-bounded wide string.
+   Copyright (C) 1999, 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 1999.
+
+   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/>.  */
+
+size_t
+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;
+}
new file mode 100644
--- /dev/null
+++ b/lib/wcsnlen.c
@@ -0,0 +1,23 @@
+/* Determine the length of a size-bounded wide string.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "wcsnlen-impl.h"
new file mode 100644
--- /dev/null
+++ b/lib/wcsnrtombs-impl.h
@@ -0,0 +1,90 @@
+/* Convert wide string to string.
+   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 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/>.  */
+
+size_t
+wcsnrtombs (char *dest, const wchar_t **srcp, size_t srclen, size_t len, mbstate_t *ps)
+{
+  if (ps == NULL)
+    ps = &_gl_wcsrtombs_state;
+  {
+    const wchar_t *src = *srcp;
+    size_t cur_max = MB_CUR_MAX;
+    char buf[64];
+
+    if (!(cur_max <= sizeof (buf)))
+      abort ();
+
+    if (dest != NULL)
+      {
+        char *destptr = dest;
+
+        for (; srclen > 0 && len > 0; src++, srclen--)
+          {
+            wchar_t wc = *src;
+            size_t ret = wcrtomb (len >= cur_max ? destptr : buf, wc, ps);
+
+            if (ret == (size_t)(-1))
+              goto bad_input;
+            if (!(ret <= cur_max))
+              abort ();
+            if (len < ret)
+              break;
+            if (len < cur_max)
+              memcpy (destptr, buf, ret);
+            if (wc == 0)
+              {
+                src = NULL;
+                /* Here mbsinit (ps).  */
+                break;
+              }
+            destptr += ret;
+            len -= ret;
+          }
+        *srcp = src;
+        return destptr - dest;
+      }
+    else
+      {
+        /* Ignore dest and len, don't store *srcp at the end, and
+           don't clobber *ps.  */
+        mbstate_t state = *ps;
+        size_t totalcount = 0;
+
+        for (; srclen > 0; src++, srclen--)
+          {
+            wchar_t wc = *src;
+            size_t ret = wcrtomb (buf, wc, &state);
+
+            if (ret == (size_t)(-1))
+              goto bad_input2;
+            if (wc == 0)
+              {
+                /* Here mbsinit (&state).  */
+                break;
+              }
+            totalcount += ret;
+          }
+        return totalcount;
+      }
+
+   bad_input:
+    *srcp = src;
+   bad_input2:
+    errno = EILSEQ;
+    return (size_t)(-1);
+  }
+}
--- a/lib/wcsnrtombs.c
+++ b/lib/wcsnrtombs.c
@@ -27,76 +27,4 @@
 
 extern mbstate_t _gl_wcsrtombs_state;
 
-size_t
-wcsnrtombs (char *dest, const wchar_t **srcp, size_t srclen, size_t len, mbstate_t *ps)
-{
-  if (ps == NULL)
-    ps = &_gl_wcsrtombs_state;
-  {
-    const wchar_t *src = *srcp;
-    size_t cur_max = MB_CUR_MAX;
-    char buf[64];
-
-    if (!(cur_max <= sizeof (buf)))
-      abort ();
-
-    if (dest != NULL)
-      {
-        char *destptr = dest;
-
-        for (; srclen > 0 && len > 0; src++, srclen--)
-          {
-            wchar_t wc = *src;
-            size_t ret = wcrtomb (len >= cur_max ? destptr : buf, wc, ps);
-
-            if (ret == (size_t)(-1))
-              goto bad_input;
-            if (!(ret <= cur_max))
-              abort ();
-            if (len < ret)
-              break;
-            if (len < cur_max)
-              memcpy (destptr, buf, ret);
-            if (wc == 0)
-              {
-                src = NULL;
-                /* Here mbsinit (ps).  */
-                break;
-              }
-            destptr += ret;
-            len -= ret;
-          }
-        *srcp = src;
-        return destptr - dest;
-      }
-    else
-      {
-        /* Ignore dest and len, don't store *srcp at the end, and
-           don't clobber *ps.  */
-        mbstate_t state = *ps;
-        size_t totalcount = 0;
-
-        for (; srclen > 0; src++, srclen--)
-          {
-            wchar_t wc = *src;
-            size_t ret = wcrtomb (buf, wc, &state);
-
-            if (ret == (size_t)(-1))
-              goto bad_input2;
-            if (wc == 0)
-              {
-                /* Here mbsinit (&state).  */
-                break;
-              }
-            totalcount += ret;
-          }
-        return totalcount;
-      }
-
-   bad_input:
-    *srcp = src;
-   bad_input2:
-    errno = EILSEQ;
-    return (size_t)(-1);
-  }
-}
+#include "wcsnrtombs-impl.h"
new file mode 100644
--- /dev/null
+++ b/lib/wcspbrk-impl.h
@@ -0,0 +1,47 @@
+/* Search a wide string for any of a set of wide characters.
+   Copyright (C) 1999, 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 1999.
+
+   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/>.  */
+
+wchar_t *
+wcspbrk (const wchar_t *wcs, const wchar_t *accept)
+{
+  /* Optimize two cases.  */
+  if (accept[0] == (wchar_t)'\0')
+    return NULL;
+
+  if (accept[1] == (wchar_t)'\0')
+    {
+      wchar_t wc = accept[0];
+      const wchar_t *ptr = wcs;
+      for (; *ptr != (wchar_t)'\0'; ptr++)
+        {
+          if (*ptr == wc)
+            return (wchar_t *) ptr;
+        }
+      return NULL;
+    }
+
+  /* General case.  */
+  {
+    const wchar_t *ptr = wcs;
+    for (; *ptr != (wchar_t)'\0'; ptr++)
+      {
+        if (wcschr (accept, *ptr))
+          return (wchar_t *) ptr;
+      }
+    return NULL;
+  }
+}
new file mode 100644
--- /dev/null
+++ b/lib/wcspbrk.c
@@ -0,0 +1,23 @@
+/* Search a wide string for any of a set of wide characters.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "wcspbrk-impl.h"
new file mode 100644
--- /dev/null
+++ b/lib/wcsrchr-impl.h
@@ -0,0 +1,33 @@
+/* Search wide string for a wide character.
+   Copyright (C) 1999, 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 1999.
+
+   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/>.  */
+
+wchar_t *
+wcsrchr (const wchar_t *wcs, wchar_t wc)
+{
+  /* Calling wcslen and then searching from the other end would cause more
+     memory accesses.  Avoid that, at the cost of a few more comparisons.  */
+  wchar_t *result = NULL;
+
+  for (;; wcs++)
+    {
+      if (*wcs == wc)
+        result = (wchar_t *) wcs;
+      if (*wcs == (wchar_t)'\0')
+        break;
+    }
+  return result;
+}
new file mode 100644
--- /dev/null
+++ b/lib/wcsrchr.c
@@ -0,0 +1,23 @@
+/* Search wide string for a wide character.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "wcsrchr-impl.h"
new file mode 100644
--- /dev/null
+++ b/lib/wcsrtombs-impl.h
@@ -0,0 +1,90 @@
+/* Convert wide string to string.
+   Copyright (C) 2008, 2010-2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 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/>.  */
+
+size_t
+wcsrtombs (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps)
+{
+  if (ps == NULL)
+    ps = &_gl_wcsrtombs_state;
+  {
+    const wchar_t *src = *srcp;
+    size_t cur_max = MB_CUR_MAX;
+    char buf[64];
+
+    if (!(cur_max <= sizeof (buf)))
+      abort ();
+
+    if (dest != NULL)
+      {
+        char *destptr = dest;
+
+        for (; len > 0; src++)
+          {
+            wchar_t wc = *src;
+            size_t ret = wcrtomb (len >= cur_max ? destptr : buf, wc, ps);
+
+            if (ret == (size_t)(-1))
+              goto bad_input;
+            if (!(ret <= cur_max))
+              abort ();
+            if (len < ret)
+              break;
+            if (len < cur_max)
+              memcpy (destptr, buf, ret);
+            if (wc == 0)
+              {
+                src = NULL;
+                /* Here mbsinit (ps).  */
+                break;
+              }
+            destptr += ret;
+            len -= ret;
+          }
+        *srcp = src;
+        return destptr - dest;
+      }
+    else
+      {
+        /* Ignore dest and len, don't store *srcp at the end, and
+           don't clobber *ps.  */
+        mbstate_t state = *ps;
+        size_t totalcount = 0;
+
+        for (;; src++)
+          {
+            wchar_t wc = *src;
+            size_t ret = wcrtomb (buf, wc, &state);
+
+            if (ret == (size_t)(-1))
+              goto bad_input2;
+            if (wc == 0)
+              {
+                /* Here mbsinit (&state).  */
+                break;
+              }
+            totalcount += ret;
+          }
+        return totalcount;
+      }
+
+   bad_input:
+    *srcp = src;
+   bad_input2:
+    errno = EILSEQ;
+    return (size_t)(-1);
+  }
+}
--- a/lib/wcsrtombs.c
+++ b/lib/wcsrtombs.c
@@ -37,7 +37,7 @@
     {
       const wchar_t *temp_src = *srcp;
 
-      return wcsrtombs (NULL, &temp_src, len, ps);
+      return wcsrtombs (NULL, &temp_src, (size_t)-1, ps);
     }
   else
 # endif
@@ -51,78 +51,6 @@
 # include <stdlib.h>
 # include <string.h>
 
-size_t
-wcsrtombs (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps)
-{
-  if (ps == NULL)
-    ps = &_gl_wcsrtombs_state;
-  {
-    const wchar_t *src = *srcp;
-    size_t cur_max = MB_CUR_MAX;
-    char buf[64];
-
-    if (!(cur_max <= sizeof (buf)))
-      abort ();
-
-    if (dest != NULL)
-      {
-        char *destptr = dest;
-
-        for (; len > 0; src++)
-          {
-            wchar_t wc = *src;
-            size_t ret = wcrtomb (len >= cur_max ? destptr : buf, wc, ps);
-
-            if (ret == (size_t)(-1))
-              goto bad_input;
-            if (!(ret <= cur_max))
-              abort ();
-            if (len < ret)
-              break;
-            if (len < cur_max)
-              memcpy (destptr, buf, ret);
-            if (wc == 0)
-              {
-                src = NULL;
-                /* Here mbsinit (ps).  */
-                break;
-              }
-            destptr += ret;
-            len -= ret;
-          }
-        *srcp = src;
-        return destptr - dest;
-      }
-    else
-      {
-        /* Ignore dest and len, don't store *srcp at the end, and
-           don't clobber *ps.  */
-        mbstate_t state = *ps;
-        size_t totalcount = 0;
-
-        for (;; src++)
-          {
-            wchar_t wc = *src;
-            size_t ret = wcrtomb (buf, wc, &state);
-
-            if (ret == (size_t)(-1))
-              goto bad_input2;
-            if (wc == 0)
-              {
-                /* Here mbsinit (&state).  */
-                break;
-              }
-            totalcount += ret;
-          }
-        return totalcount;
-      }
-
-   bad_input:
-    *srcp = src;
-   bad_input2:
-    errno = EILSEQ;
-    return (size_t)(-1);
-  }
-}
+# include "wcsrtombs-impl.h"
 
 #endif
new file mode 100644
--- /dev/null
+++ b/lib/wcsspn-impl.h
@@ -0,0 +1,47 @@
+/* Advance in a wide string, skipping any of a set of wide characters.
+   Copyright (C) 1999, 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 1999.
+
+   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/>.  */
+
+size_t
+wcsspn (const wchar_t *wcs, const wchar_t *accept)
+{
+  /* Optimize two cases.  */
+  if (accept[0] == (wchar_t)'\0')
+    return 0;
+
+  if (accept[1] == (wchar_t)'\0')
+    {
+      wchar_t wc = accept[0];
+      const wchar_t *ptr = wcs;
+      for (; *ptr != (wchar_t)'\0'; ptr++)
+        {
+          if (*ptr != wc)
+            break;
+        }
+      return ptr - wcs;
+    }
+
+  /* General case.  */
+  {
+    const wchar_t *ptr = wcs;
+    for (; *ptr != (wchar_t)'\0'; ptr++)
+      {
+        if (!wcschr (accept, *ptr))
+          break;
+      }
+    return ptr - wcs;
+  }
+}
new file mode 100644
--- /dev/null
+++ b/lib/wcsspn.c
@@ -0,0 +1,23 @@
+/* Advance in a wide string, skipping any of a set of wide characters.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "wcsspn-impl.h"
new file mode 100644
--- /dev/null
+++ b/lib/wcsstr-impl.h
@@ -0,0 +1,51 @@
+/* Locate a substring in a wide string.
+   Copyright (C) 1999, 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 1999.
+
+   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/>.  */
+
+wchar_t *
+wcsstr (const wchar_t *haystack, const wchar_t *needle)
+{
+  wchar_t n = needle[0];
+
+  /* Is needle empty?  */
+  if (n == (wchar_t)'\0')
+    return (wchar_t *) haystack;
+
+  /* Is needle nearly empty?  */
+  if (needle[1] == (wchar_t)'\0')
+    return wcschr (haystack, n);
+
+  /* Search for needle's first character.  */
+  for (; *haystack != (wchar_t)'\0'; haystack++)
+    {
+      if (*haystack == n)
+        {
+          /* Compare with needle's remaining characters.  */
+          const wchar_t *hptr = haystack + 1;
+          const wchar_t *nptr = needle + 1;
+          for (;;)
+            {
+              if (*hptr != *nptr)
+                break;
+              hptr++; nptr++;
+              if (*nptr == (wchar_t)'\0')
+                return (wchar_t *) haystack;
+            }
+        }
+    }
+
+  return NULL;
+}
new file mode 100644
--- /dev/null
+++ b/lib/wcsstr.c
@@ -0,0 +1,23 @@
+/* Locate a substring in a wide string.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "wcsstr-impl.h"
new file mode 100644
--- /dev/null
+++ b/lib/wcstok-impl.h
@@ -0,0 +1,50 @@
+/* Split a wide string into tokens.
+   Copyright (C) 1999, 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 1999.
+
+   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/>.  */
+
+wchar_t *
+wcstok (wchar_t *wcs, const wchar_t *delim, wchar_t **ptr)
+{
+  if (wcs == NULL)
+    {
+      wcs = *ptr;
+      if (wcs == NULL)
+        return NULL; /* reminder that end of token sequence has been reached */
+    }
+
+  /* Skip leading delimiters.  */
+  wcs += wcsspn (wcs, delim);
+
+  /* Found a token?  */
+  if (*wcs == (wchar_t)'\0')
+    {
+      *ptr = NULL;
+      return NULL;
+    }
+  /* Move past the token.  */
+  {
+    wchar_t *token_end = wcspbrk (wcs, delim);
+    if (token_end)
+      {
+        /* NUL-terminate the token.  */
+        *token_end = (wchar_t)'\0';
+        *ptr = token_end + 1;
+      }
+    else
+      *ptr = NULL;
+  }
+  return wcs;
+}
new file mode 100644
--- /dev/null
+++ b/lib/wcstok.c
@@ -0,0 +1,23 @@
+/* Split a wide string into tokens.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "wcstok-impl.h"
new file mode 100644
--- /dev/null
+++ b/lib/wcswidth-impl.h
@@ -0,0 +1,43 @@
+/* Determine number of screen columns needed for a size-bounded wide string.
+   Copyright (C) 1999, 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 1999.
+
+   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/>.  */
+
+int
+wcswidth (const wchar_t *s, size_t n)
+{
+  int count = 0;
+  for (; n > 0; s++, n--)
+    {
+      wchar_t c = *s;
+      if (c == (wchar_t)'\0')
+        break;
+      {
+        int width = wcwidth (c);
+        if (width < 0)
+          goto found_nonprinting;
+        if (width > INT_MAX - count)
+          goto overflow;
+        count += width;
+      }
+    }
+  return count;
+
+ found_nonprinting:
+  return -1;
+
+ overflow:
+  return INT_MAX;
+}
new file mode 100644
--- /dev/null
+++ b/lib/wcswidth.c
@@ -0,0 +1,25 @@
+/* Determine number of screen columns needed for a size-bounded wide string.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 <limits.h>
+
+#include "wcswidth-impl.h"
new file mode 100644
--- /dev/null
+++ b/lib/wcsxfrm-impl.h
@@ -0,0 +1,96 @@
+/* Transform wide string for comparison using the current locale.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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/>.  */
+
+size_t
+wcsxfrm (wchar_t *s1, const wchar_t *s2, size_t n)
+{
+  char mbbuf2[1024];
+  char *mbs2;
+
+  {
+    int saved_errno = errno;
+    size_t result;
+
+    /* Convert s2 to a multibyte string, trying to avoid malloc().  */
+    {
+      size_t ret;
+
+      ret = wcstombs (mbbuf2, s2, sizeof (mbbuf2));
+      if (ret == (size_t)-1)
+        goto failed;
+      if (ret < sizeof (mbbuf2))
+        mbs2 = mbbuf2;
+      else
+        {
+          size_t need = wcstombs (NULL, s2, 0);
+          if (need == (size_t)-1)
+            goto failed;
+          mbs2 = (char *) malloc (need + 1);
+          if (mbs2 == NULL)
+            goto out_of_memory;
+          ret = wcstombs (mbs2, s2, need + 1);
+          if (ret != need)
+            abort ();
+        }
+    }
+
+    /* Transform the multibyte string.  */
+    errno = 0;
+    result = strxfrm ((char *)s1, mbs2, n);
+    if (errno != 0)
+      {
+        /* An error occurred.  */
+        if (mbs2 != mbbuf2)
+          {
+            saved_errno = errno;
+            free (mbs2);
+            errno = saved_errno;
+          }
+        return 0;
+      }
+
+    if (result < n)
+      {
+        /* Convert the result by mapping char[] -> wchar_t[].
+           Since strcmp() compares the elements as 'unsigned char' values,
+           whereas wcscmp() compares the elements as 'wchar_t' values, we need
+           to map 1 'unsigned char' to 1 'wchar_t'.  (We could also map 2
+           consecutive 'unsigned char' values to 1 'wchar_t' value, but this is
+           not needed.  */
+        wchar_t *wcp = s1 + n;
+        char *cp = (char *)s1 + n;
+
+        while (wcp > s1)
+          *--wcp = (wchar_t) (unsigned char) *--cp;
+      }
+
+    if (mbs2 != mbbuf2)
+      free (mbs2);
+
+    /* No error.  */
+    errno = saved_errno;
+    return result;
+  }
+
+ out_of_memory:
+  errno = ENOMEM;
+  return 0;
+
+ failed:
+  errno = EILSEQ;
+  return 0;
+}
new file mode 100644
--- /dev/null
+++ b/lib/wcsxfrm.c
@@ -0,0 +1,27 @@
+/* Transform wide string for comparison using the current locale.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "wcsxfrm-impl.h"
new file mode 100644
--- /dev/null
+++ b/lib/wctomb-impl.h
@@ -0,0 +1,34 @@
+/* Convert wide character to multibyte character.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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/>.  */
+
+int
+wctomb (char *s, wchar_t wc)
+{
+  if (s == NULL)
+    return 0;
+  else
+    {
+      mbstate_t state;
+      size_t result;
+
+      memset (&state, 0, sizeof (mbstate_t));
+      result = wcrtomb (s, wc, &state);
+      if (result == (size_t)-1)
+        return -1;
+      return result;
+    }
+}
new file mode 100644
--- /dev/null
+++ b/lib/wctomb.c
@@ -0,0 +1,25 @@
+/* Convert wide character to multibyte character.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+#include <stdlib.h>
+
+#include <string.h>
+#include <wchar.h>
+
+#include "wctomb-impl.h"
new file mode 100644
--- /dev/null
+++ b/lib/wctrans-impl.h
@@ -0,0 +1,37 @@
+/* Get descriptor for a wide character case conversion.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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/>.  */
+
+wctrans_t
+wctrans (const char *name)
+{
+  if (name[0] == 't'
+      && name[1] == 'o')
+    switch (name[2])
+      {
+      case 'l':
+        if (strcmp (name + 3, "ower") == 0)
+          return (wctrans_t) towlower;
+        break;
+      case 'u':
+        if (strcmp (name + 3, "pper") == 0)
+          return (wctrans_t) towupper;
+        break;
+      default:
+        break;
+      }
+  return NULL;
+}
new file mode 100644
--- /dev/null
+++ b/lib/wctrans.c
@@ -0,0 +1,25 @@
+/* Get descriptor for a wide character case conversion.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 <wctype.h>
+
+#include <string.h>
+
+#include "wctrans-impl.h"
new file mode 100644
--- /dev/null
+++ b/lib/wctype-impl.h
@@ -0,0 +1,96 @@
+/* Get descriptor for a wide character property.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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/>.  */
+
+wctype_t
+wctype (const char* name)
+{
+  switch (name[0])
+    {
+    case 'a':
+      switch (name[1])
+        {
+        case 'l':
+          switch (name[2])
+            {
+            case 'n':
+              if (strcmp (name + 3, "um") == 0)
+                return (wctype_t) iswalnum;
+              break;
+            case 'p':
+              if (strcmp (name + 3, "ha") == 0)
+                return (wctype_t) iswalpha;
+              break;
+            default:
+              break;
+            }
+          break;
+        default:
+          break;
+        }
+      break;
+    case 'b':
+      if (strcmp (name + 1, "lank") == 0)
+        return (wctype_t) iswblank;
+      break;
+    case 'c':
+      if (strcmp (name + 1, "ntrl") == 0)
+        return (wctype_t) iswcntrl;
+      break;
+    case 'd':
+      if (strcmp (name + 1, "igit") == 0)
+        return (wctype_t) iswdigit;
+      break;
+    case 'g':
+      if (strcmp (name + 1, "raph") == 0)
+        return (wctype_t) iswgraph;
+      break;
+    case 'l':
+      if (strcmp (name + 1, "ower") == 0)
+        return (wctype_t) iswlower;
+      break;
+    case 'p':
+      switch (name[1])
+        {
+        case 'r':
+          if (strcmp (name + 2, "int") == 0)
+            return (wctype_t) iswprint;
+          break;
+        case 'u':
+          if (strcmp (name + 2, "nct") == 0)
+            return (wctype_t) iswpunct;
+          break;
+        default:
+          break;
+        }
+      break;
+    case 's':
+      if (strcmp (name + 1, "pace") == 0)
+        return (wctype_t) iswspace;
+      break;
+    case 'u':
+      if (strcmp (name + 1, "pper") == 0)
+        return (wctype_t) iswupper;
+      break;
+    case 'x':
+      if (strcmp (name + 1, "digit") == 0)
+        return (wctype_t) iswxdigit;
+      break;
+    default:
+      break;
+    }
+  return NULL;
+}
new file mode 100644
--- /dev/null
+++ b/lib/wctype.c
@@ -0,0 +1,25 @@
+/* Get descriptor for a wide character property.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 <wctype.h>
+
+#include <string.h>
+
+#include "wctype-impl.h"
--- a/lib/wctype.in.h
+++ b/lib/wctype.in.h
@@ -72,58 +72,60 @@
 #endif
 
 
+#if !GNULIB_defined_wctype_functions
+
 /* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions.
    Linux libc5 has <wctype.h> and the functions but they are broken.
    Assume all 11 functions (all isw* except iswblank) are implemented the
    same way, or not at all.  */
-#if ! @HAVE_ISWCNTRL@ || @REPLACE_ISWCNTRL@
+# if ! @HAVE_ISWCNTRL@ || @REPLACE_ISWCNTRL@
 
 /* IRIX 5.3 has macros but no functions, its isw* macros refer to an
    undefined variable _ctmp_ and to <ctype.h> macros like _P, and they
    refer to system functions like _iswctype that are not in the
    standard C library.  Rather than try to get ancient buggy
    implementations like this to work, just disable them.  */
-# undef iswalnum
-# undef iswalpha
-# undef iswblank
-# undef iswcntrl
-# undef iswdigit
-# undef iswgraph
-# undef iswlower
-# undef iswprint
-# undef iswpunct
-# undef iswspace
-# undef iswupper
-# undef iswxdigit
-# undef towlower
-# undef towupper
+#  undef iswalnum
+#  undef iswalpha
+#  undef iswblank
+#  undef iswcntrl
+#  undef iswdigit
+#  undef iswgraph
+#  undef iswlower
+#  undef iswprint
+#  undef iswpunct
+#  undef iswspace
+#  undef iswupper
+#  undef iswxdigit
+#  undef towlower
+#  undef towupper
 
 /* Linux libc5 has <wctype.h> and the functions but they are broken.  */
-# if @REPLACE_ISWCNTRL@
-#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#   define iswalnum rpl_iswalnum
-#   define iswalpha rpl_iswalpha
-#   define iswblank rpl_iswblank
-#   define iswcntrl rpl_iswcntrl
-#   define iswdigit rpl_iswdigit
-#   define iswgraph rpl_iswgraph
-#   define iswlower rpl_iswlower
-#   define iswprint rpl_iswprint
-#   define iswpunct rpl_iswpunct
-#   define iswspace rpl_iswspace
-#   define iswupper rpl_iswupper
-#   define iswxdigit rpl_iswxdigit
-#   define towlower rpl_towlower
-#   define towupper rpl_towupper
+#  if @REPLACE_ISWCNTRL@
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#    define iswalnum rpl_iswalnum
+#    define iswalpha rpl_iswalpha
+#    define iswblank rpl_iswblank
+#    define iswcntrl rpl_iswcntrl
+#    define iswdigit rpl_iswdigit
+#    define iswgraph rpl_iswgraph
+#    define iswlower rpl_iswlower
+#    define iswprint rpl_iswprint
+#    define iswpunct rpl_iswpunct
+#    define iswspace rpl_iswspace
+#    define iswupper rpl_iswupper
+#    define iswxdigit rpl_iswxdigit
+#    define towlower rpl_towlower
+#    define towupper rpl_towupper
+#   endif
 #  endif
-# endif
 
 static inline int
-# if @REPLACE_ISWCNTRL@
+#  if @REPLACE_ISWCNTRL@
 rpl_iswalnum
-# else
+#  else
 iswalnum
-# endif
+#  endif
          (wint_t wc)
 {
   return ((wc >= '0' && wc <= '9')
@@ -131,88 +133,88 @@
 }
 
 static inline int
-# if @REPLACE_ISWCNTRL@
+#  if @REPLACE_ISWCNTRL@
 rpl_iswalpha
-# else
+#  else
 iswalpha
-# endif
+#  endif
          (wint_t wc)
 {
   return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z';
 }
 
 static inline int
-# if @REPLACE_ISWCNTRL@
+#  if @REPLACE_ISWCNTRL@
 rpl_iswblank
-# else
+#  else
 iswblank
-# endif
+#  endif
          (wint_t wc)
 {
   return wc == ' ' || wc == '\t';
 }
 
 static inline int
-# if @REPLACE_ISWCNTRL@
+#  if @REPLACE_ISWCNTRL@
 rpl_iswcntrl
-# else
+#  else
 iswcntrl
-# endif
+#  endif
         (wint_t wc)
 {
   return (wc & ~0x1f) == 0 || wc == 0x7f;
 }
 
 static inline int
-# if @REPLACE_ISWCNTRL@
+#  if @REPLACE_ISWCNTRL@
 rpl_iswdigit
-# else
+#  else
 iswdigit
-# endif
+#  endif
          (wint_t wc)
 {
   return wc >= '0' && wc <= '9';
 }
 
 static inline int
-# if @REPLACE_ISWCNTRL@
+#  if @REPLACE_ISWCNTRL@
 rpl_iswgraph
-# else
+#  else
 iswgraph
-# endif
+#  endif
          (wint_t wc)
 {
   return wc >= '!' && wc <= '~';
 }
 
 static inline int
-# if @REPLACE_ISWCNTRL@
+#  if @REPLACE_ISWCNTRL@
 rpl_iswlower
-# else
+#  else
 iswlower
-# endif
+#  endif
          (wint_t wc)
 {
   return wc >= 'a' && wc <= 'z';
 }
 
 static inline int
-# if @REPLACE_ISWCNTRL@
+#  if @REPLACE_ISWCNTRL@
 rpl_iswprint
-# else
+#  else
 iswprint
-# endif
+#  endif
          (wint_t wc)
 {
   return wc >= ' ' && wc <= '~';
 }
 
 static inline int
-# if @REPLACE_ISWCNTRL@
+#  if @REPLACE_ISWCNTRL@
 rpl_iswpunct
-# else
+#  else
 iswpunct
-# endif
+#  endif
          (wint_t wc)
 {
   return (wc >= '!' && wc <= '~'
@@ -221,11 +223,11 @@
 }
 
 static inline int
-# if @REPLACE_ISWCNTRL@
+#  if @REPLACE_ISWCNTRL@
 rpl_iswspace
-# else
+#  else
 iswspace
-# endif
+#  endif
          (wint_t wc)
 {
   return (wc == ' ' || wc == '\t'
@@ -233,22 +235,22 @@
 }
 
 static inline int
-# if @REPLACE_ISWCNTRL@
+#  if @REPLACE_ISWCNTRL@
 rpl_iswupper
-# else
+#  else
 iswupper
-# endif
+#  endif
          (wint_t wc)
 {
   return wc >= 'A' && wc <= 'Z';
 }
 
 static inline int
-# if @REPLACE_ISWCNTRL@
+#  if @REPLACE_ISWCNTRL@
 rpl_iswxdigit
-# else
+#  else
 iswxdigit
-# endif
+#  endif
           (wint_t wc)
 {
   return ((wc >= '0' && wc <= '9')
@@ -256,42 +258,42 @@
 }
 
 static inline wint_t
-# if @REPLACE_ISWCNTRL@
+#  if @REPLACE_ISWCNTRL@
 rpl_towlower
-# else
+#  else
 towlower
-# endif
+#  endif
          (wint_t wc)
 {
   return (wc >= 'A' && wc <= 'Z' ? wc - 'A' + 'a' : wc);
 }
 
 static inline wint_t
-# if @REPLACE_ISWCNTRL@
+#  if @REPLACE_ISWCNTRL@
 rpl_towupper
-# else
+#  else
 towupper
-# endif
+#  endif
          (wint_t wc)
 {
   return (wc >= 'a' && wc <= 'z' ? wc - 'a' + 'A' : wc);
 }
 
-#elif ! @HAVE_ISWBLANK@ || @REPLACE_ISWBLANK@
+# elif @GNULIB_ISWBLANK@ && (! @HAVE_ISWBLANK@ || @REPLACE_ISWBLANK@)
 /* Only the iswblank function is missing.  */
 
-# if @REPLACE_ISWBLANK@
-#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#   define iswblank rpl_iswblank
+#  if @REPLACE_ISWBLANK@
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#    define iswblank rpl_iswblank
+#   endif
+_GL_FUNCDECL_RPL (iswblank, int, (wint_t wc));
+#  else
+_GL_FUNCDECL_SYS (iswblank, int, (wint_t wc));
 #  endif
-_GL_FUNCDECL_RPL (iswblank, int, (wint_t wc));
-# else
-_GL_FUNCDECL_SYS (iswblank, int, (wint_t wc));
+
 # endif
 
-#endif
-
-#if defined __MINGW32__
+# if defined __MINGW32__
 
 /* On native Windows, wchar_t is uint16_t, and wint_t is uint32_t.
    The functions towlower and towupper are implemented in the MSVCRT library
@@ -311,25 +313,27 @@
 {
   return (wint_t) (wchar_t) towlower (wc);
 }
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#  define towlower rpl_towlower
-# endif
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define towlower rpl_towlower
+#  endif
 
 static inline wint_t
 rpl_towupper (wint_t wc)
 {
   return (wint_t) (wchar_t) towupper (wc);
 }
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#  define towupper rpl_towupper
-# endif
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define towupper rpl_towupper
+#  endif
 
-#endif /* __MINGW32__ */
+# endif /* __MINGW32__ */
+
+# define GNULIB_defined_wctype_functions 1
+#endif
 
 #if @REPLACE_ISWCNTRL@
 _GL_CXXALIAS_RPL (iswalnum, int, (wint_t wc));
 _GL_CXXALIAS_RPL (iswalpha, int, (wint_t wc));
-_GL_CXXALIAS_RPL (iswblank, int, (wint_t wc));
 _GL_CXXALIAS_RPL (iswcntrl, int, (wint_t wc));
 _GL_CXXALIAS_RPL (iswdigit, int, (wint_t wc));
 _GL_CXXALIAS_RPL (iswgraph, int, (wint_t wc));
@@ -342,11 +346,6 @@
 #else
 _GL_CXXALIAS_SYS (iswalnum, int, (wint_t wc));
 _GL_CXXALIAS_SYS (iswalpha, int, (wint_t wc));
-# if @REPLACE_ISWBLANK@
-_GL_CXXALIAS_RPL (iswblank, int, (wint_t wc));
-# else
-_GL_CXXALIAS_SYS (iswblank, int, (wint_t wc));
-# endif
 _GL_CXXALIAS_SYS (iswcntrl, int, (wint_t wc));
 _GL_CXXALIAS_SYS (iswdigit, int, (wint_t wc));
 _GL_CXXALIAS_SYS (iswgraph, int, (wint_t wc));
@@ -359,7 +358,6 @@
 #endif
 _GL_CXXALIASWARN (iswalnum);
 _GL_CXXALIASWARN (iswalpha);
-_GL_CXXALIASWARN (iswblank);
 _GL_CXXALIASWARN (iswcntrl);
 _GL_CXXALIASWARN (iswdigit);
 _GL_CXXALIASWARN (iswgraph);
@@ -370,6 +368,54 @@
 _GL_CXXALIASWARN (iswupper);
 _GL_CXXALIASWARN (iswxdigit);
 
+#if @GNULIB_ISWBLANK@
+# if @REPLACE_ISWCNTRL@ || @REPLACE_ISWBLANK@
+_GL_CXXALIAS_RPL (iswblank, int, (wint_t wc));
+# else
+_GL_CXXALIAS_SYS (iswblank, int, (wint_t wc));
+# endif
+_GL_CXXALIASWARN (iswblank);
+#endif
+
+#if !@HAVE_WCTYPE_T@
+# if !GNULIB_defined_wctype_t
+typedef void * wctype_t;
+#  define GNULIB_defined_wctype_t 1
+# endif
+#endif
+
+/* Get a descriptor for a wide character property.  */
+#if @GNULIB_WCTYPE@
+# if !@HAVE_WCTYPE_T@
+_GL_FUNCDECL_SYS (wctype, wctype_t, (const char *name));
+# endif
+_GL_CXXALIAS_SYS (wctype, wctype_t, (const char *name));
+_GL_CXXALIASWARN (wctype);
+#elif defined GNULIB_POSIXCHECK
+# undef wctype
+# if HAVE_RAW_DECL_WCTYPE
+_GL_WARN_ON_USE (wctype, "wctype is unportable - "
+                 "use gnulib module wctype for portability");
+# endif
+#endif
+
+/* Test whether a wide character has a given property.
+   The argument WC must be either a wchar_t value or WEOF.
+   The argument DESC must have been returned by the wctype() function.  */
+#if @GNULIB_ISWCTYPE@
+# if !@HAVE_WCTYPE_T@
+_GL_FUNCDECL_SYS (iswctype, int, (wint_t wc, wctype_t desc));
+# endif
+_GL_CXXALIAS_SYS (iswctype, int, (wint_t wc, wctype_t desc));
+_GL_CXXALIASWARN (iswctype);
+#elif defined GNULIB_POSIXCHECK
+# undef iswctype
+# if HAVE_RAW_DECL_ISWCTYPE
+_GL_WARN_ON_USE (iswctype, "iswctype is unportable - "
+                 "use gnulib module iswctype for portability");
+# endif
+#endif
+
 #if @REPLACE_ISWCNTRL@ || defined __MINGW32__
 _GL_CXXALIAS_RPL (towlower, wint_t, (wint_t wc));
 _GL_CXXALIAS_RPL (towupper, wint_t, (wint_t wc));
@@ -380,6 +426,45 @@
 _GL_CXXALIASWARN (towlower);
 _GL_CXXALIASWARN (towupper);
 
+#if !@HAVE_WCTRANS_T@
+# if !GNULIB_defined_wctrans_t
+typedef void * wctrans_t;
+#  define GNULIB_defined_wctrans_t 1
+# endif
+#endif
+
+/* Get a descriptor for a wide character case conversion.  */
+#if @GNULIB_WCTRANS@
+# if !@HAVE_WCTRANS_T@
+_GL_FUNCDECL_SYS (wctrans, wctrans_t, (const char *name));
+# endif
+_GL_CXXALIAS_SYS (wctrans, wctrans_t, (const char *name));
+_GL_CXXALIASWARN (wctrans);
+#elif defined GNULIB_POSIXCHECK
+# undef wctrans
+# if HAVE_RAW_DECL_WCTRANS
+_GL_WARN_ON_USE (wctrans, "wctrans is unportable - "
+                 "use gnulib module wctrans for portability");
+# endif
+#endif
+
+/* Perform a given case conversion on a wide character.
+   The argument WC must be either a wchar_t value or WEOF.
+   The argument DESC must have been returned by the wctrans() function.  */
+#if @GNULIB_TOWCTRANS@
+# if !@HAVE_WCTRANS_T@
+_GL_FUNCDECL_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc));
+# endif
+_GL_CXXALIAS_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc));
+_GL_CXXALIASWARN (towctrans);
+#elif defined GNULIB_POSIXCHECK
+# undef towctrans
+# if HAVE_RAW_DECL_TOWCTRANS
+_GL_WARN_ON_USE (towctrans, "towctrans is unportable - "
+                 "use gnulib module towctrans for portability");
+# endif
+#endif
+
 
 #endif /* _GL_WCTYPE_H */
 #endif /* _GL_WCTYPE_H */
new file mode 100644
--- /dev/null
+++ b/lib/wmemchr-impl.h
@@ -0,0 +1,27 @@
+/* Search wide character array for a wide character.
+   Copyright (C) 1999, 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 1999.
+
+   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/>.  */
+
+wchar_t *
+wmemchr (const wchar_t *s, wchar_t c, size_t n)
+{
+  for (; n > 0; s++, n--)
+    {
+      if (*s == c)
+        return (wchar_t *) s;
+    }
+  return NULL;
+}
new file mode 100644
--- /dev/null
+++ b/lib/wmemchr.c
@@ -0,0 +1,23 @@
+/* Search wide character array for a wide character.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "wmemchr-impl.h"
new file mode 100644
--- /dev/null
+++ b/lib/wmemcmp-impl.h
@@ -0,0 +1,35 @@
+/* Compare wide character arrays.
+   Copyright (C) 1999, 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 1999.
+
+   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/>.  */
+
+int
+wmemcmp (const wchar_t *s1, const wchar_t *s2, size_t n)
+{
+  for (; n > 0;)
+    {
+      wchar_t wc1 = *s1++;
+      wchar_t wc2 = *s2++;
+      if (wc1 == wc2)
+        {
+          n--;
+          continue;
+        }
+      /* Note that wc1 and wc2 each have at most 31 bits.  */
+      return (int)wc1 - (int)wc2;
+             /* > 0 if wc1 > wc2, < 0 if wc1 < wc2.  */
+    }
+  return 0;
+}
new file mode 100644
--- /dev/null
+++ b/lib/wmemcmp.c
@@ -0,0 +1,23 @@
+/* Compare wide character arrays.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "wmemcmp-impl.h"
new file mode 100644
--- /dev/null
+++ b/lib/wmemcpy-impl.h
@@ -0,0 +1,26 @@
+/* Copy wide character array.
+   Copyright (C) 1999, 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 1999.
+
+   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/>.  */
+
+wchar_t *
+wmemcpy (wchar_t *dest, const wchar_t *src, size_t n)
+{
+  wchar_t *destptr = dest;
+
+  for (; n > 0; n--)
+    *destptr++ = *src++;
+  return dest;
+}
new file mode 100644
--- /dev/null
+++ b/lib/wmemcpy.c
@@ -0,0 +1,23 @@
+/* Copy wide character array.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "wmemcpy-impl.h"
new file mode 100644
--- /dev/null
+++ b/lib/wmemmove-impl.h
@@ -0,0 +1,36 @@
+/* Copy wide character array.
+   Copyright (C) 1999, 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 1999.
+
+   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/>.  */
+
+wchar_t *
+wmemmove (wchar_t *dest, const wchar_t *src, size_t n)
+{
+  if (dest < src)
+    {
+      wchar_t *destptr = dest;
+      const wchar_t *srcptr = src;
+      for (; n > 0; n--)
+        *destptr++ = *srcptr++;
+    }
+  else if (dest > src)
+    {
+      wchar_t *destptr = dest + n - 1;
+      const wchar_t *srcptr = src + n - 1;
+      for (; n > 0; n--)
+        *destptr-- = *srcptr--;
+    }
+  return dest;
+}
new file mode 100644
--- /dev/null
+++ b/lib/wmemmove.c
@@ -0,0 +1,23 @@
+/* Copy wide character array.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "wmemmove-impl.h"
new file mode 100644
--- /dev/null
+++ b/lib/wmemset-impl.h
@@ -0,0 +1,26 @@
+/* Fill wide character array.
+   Copyright (C) 1999, 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 1999.
+
+   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/>.  */
+
+wchar_t *
+wmemset (wchar_t *s, wchar_t c, size_t n)
+{
+  wchar_t *ptr = s;
+
+  for (; n > 0; n--)
+    *ptr++ = c;
+  return s;
+}
new file mode 100644
--- /dev/null
+++ b/lib/wmemset.c
@@ -0,0 +1,23 @@
+/* Fill wide character array.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "wmemset-impl.h"
--- a/lib/xalloc.h
+++ b/lib/xalloc.h
@@ -26,30 +26,22 @@
 # endif
 
 
-# ifndef __attribute__
-#  if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
-#   define __attribute__(x)
-#  endif
-# endif
-
-# ifndef ATTRIBUTE_NORETURN
-#  define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
+# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)
+#  define _GL_ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
+# else
+#  define _GL_ATTRIBUTE_NORETURN /* empty */
 # endif
 
-# ifndef ATTRIBUTE_MALLOC
-#  if __GNUC__ >= 3
-#   define ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
-#  else
-#   define ATTRIBUTE_MALLOC
-#  endif
+# if __GNUC__ >= 3
+#  define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
+# else
+#  define _GL_ATTRIBUTE_MALLOC
 # endif
 
-# ifndef ATTRIBUTE_ALLOC_SIZE
-#  if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
-#   define ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
-#  else
-#   define ATTRIBUTE_ALLOC_SIZE(args)
-#  endif
+# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
+#  define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
+# else
+#  define _GL_ATTRIBUTE_ALLOC_SIZE(args)
 # endif
 
 /* This function is always triggered when memory is exhausted.
@@ -57,21 +49,21 @@
    or by using gnulib's xalloc-die module.  This is the
    function to call when one wants the program to die because of a
    memory allocation failure.  */
-extern void xalloc_die (void) ATTRIBUTE_NORETURN;
+extern void xalloc_die (void) _GL_ATTRIBUTE_NORETURN;
 
 void *xmalloc (size_t s)
-      ATTRIBUTE_MALLOC ATTRIBUTE_ALLOC_SIZE ((1));
+      _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1));
 void *xzalloc (size_t s)
-      ATTRIBUTE_MALLOC ATTRIBUTE_ALLOC_SIZE ((1));
+      _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1));
 void *xcalloc (size_t n, size_t s)
-      ATTRIBUTE_MALLOC ATTRIBUTE_ALLOC_SIZE ((1, 2));
+      _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2));
 void *xrealloc (void *p, size_t s)
-      ATTRIBUTE_ALLOC_SIZE ((2));
+      _GL_ATTRIBUTE_ALLOC_SIZE ((2));
 void *x2realloc (void *p, size_t *pn);
 void *xmemdup (void const *p, size_t s)
-      ATTRIBUTE_MALLOC ATTRIBUTE_ALLOC_SIZE ((2));
+      _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((2));
 char *xstrdup (char const *str)
-      ATTRIBUTE_MALLOC;
+      _GL_ATTRIBUTE_MALLOC;
 
 /* Return 1 if an array of N objects, each of size S, cannot exist due
    to size arithmetic overflow.  S must be positive and N must be
@@ -119,12 +111,12 @@
 #  define static_inline static inline
 # else
 void *xnmalloc (size_t n, size_t s)
-      ATTRIBUTE_MALLOC ATTRIBUTE_ALLOC_SIZE ((1, 2));
+      _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2));
 void *xnrealloc (void *p, size_t n, size_t s)
-      ATTRIBUTE_ALLOC_SIZE ((2, 3));
+      _GL_ATTRIBUTE_ALLOC_SIZE ((2, 3));
 void *x2nrealloc (void *p, size_t *pn, size_t s);
 char *xcharalloc (size_t n)
-      ATTRIBUTE_MALLOC ATTRIBUTE_ALLOC_SIZE ((1));
+      _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1));
 # endif
 
 # ifdef static_inline
@@ -133,7 +125,7 @@
    dynamically, with error checking.  S must be nonzero.  */
 
 static_inline void *xnmalloc (size_t n, size_t s)
-                    ATTRIBUTE_MALLOC ATTRIBUTE_ALLOC_SIZE ((1, 2));
+                    _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1, 2));
 static_inline void *
 xnmalloc (size_t n, size_t s)
 {
@@ -146,7 +138,7 @@
    objects each of S bytes, with error checking.  S must be nonzero.  */
 
 static_inline void *xnrealloc (void *p, size_t n, size_t s)
-                    ATTRIBUTE_ALLOC_SIZE ((2, 3));
+                    _GL_ATTRIBUTE_ALLOC_SIZE ((2, 3));
 static_inline void *
 xnrealloc (void *p, size_t n, size_t s)
 {
@@ -248,7 +240,7 @@
    except it returns char *.  */
 
 static_inline char *xcharalloc (size_t n)
-                    ATTRIBUTE_MALLOC ATTRIBUTE_ALLOC_SIZE ((1));
+                    _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1));
 static_inline char *
 xcharalloc (size_t n)
 {
--- a/lib/xmalloc.c
+++ b/lib/xmalloc.c
@@ -52,8 +52,16 @@
 void *
 xrealloc (void *p, size_t n)
 {
+  if (!n && p)
+    {
+      /* The GNU and C99 realloc behaviors disagree here.  Act like
+         GNU, even if the underlying realloc is C99.  */
+      free (p);
+      return NULL;
+    }
+
   p = realloc (p, n);
-  if (!p && n != 0)
+  if (!p && n)
     xalloc_die ();
   return p;
 }
--- a/lib/xmemdup0.h
+++ b/lib/xmemdup0.h
@@ -25,14 +25,10 @@
 extern "C" {
 # endif
 
-# ifndef __attribute__
-#  if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
-#   define __attribute__(x)
-#  endif
-# endif
-
-# ifndef ATTRIBUTE_NORETURN
-#  define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
+# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)
+#  define _GL_ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
+# else
+#  define _GL_ATTRIBUTE_NORETURN /* empty */
 # endif
 
 /* This function is always triggered when memory is exhausted.
@@ -40,7 +36,7 @@
    or by using gnulib's xalloc-die module.  This is the
    function to call when one wants the program to die because of a
    memory allocation failure.  */
-extern void xalloc_die (void) ATTRIBUTE_NORETURN;
+extern void xalloc_die (void) _GL_ATTRIBUTE_NORETURN;
 
 char *xmemdup0 (void const *p, size_t s);
 
--- a/lib/xprintf.h
+++ b/lib/xprintf.h
@@ -20,26 +20,26 @@
 #include <stdarg.h>
 #include <stdio.h>
 
-#ifndef __attribute__
 /* The __attribute__ feature is available in gcc versions 2.5 and later.
    The __-protected variants of the attributes 'format' and 'printf' are
    accepted by gcc versions 2.6.4 (effectively 2.7) and later.
-   We enable __attribute__ only if these are supported too, because
+   We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because
    gnulib and libintl do '#define printf __printf__' when they override
    the 'printf' function.  */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
-#  define __attribute__(Spec)   /* empty */
-# endif
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
+# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
+#else
+# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
 #endif
 
 extern int xprintf (char const *restrict format, ...)
-  __attribute__ ((__format__ (__printf__, 1, 2)));
+  _GL_ATTRIBUTE_FORMAT ((__printf__, 1, 2));
 extern int xvprintf (char const *restrict format, va_list args)
-  __attribute__ ((__format__ (__printf__, 1, 0)));
+  _GL_ATTRIBUTE_FORMAT ((__printf__, 1, 0));
 extern int xfprintf (FILE *restrict stream, char const *restrict format, ...)
-  __attribute__ ((__format__ (__printf__, 2, 3)));
+  _GL_ATTRIBUTE_FORMAT ((__printf__, 2, 3));
 extern int xvfprintf (FILE *restrict stream, char const *restrict format,
                       va_list args)
-  __attribute__ ((__format__ (__printf__, 2, 0)));
+  _GL_ATTRIBUTE_FORMAT ((__printf__, 2, 0));
 
 #endif
--- a/lib/xstrtol.h
+++ b/lib/xstrtol.h
@@ -51,14 +51,10 @@
 _DECLARE_XSTRTOL (xstrtoull, unsigned long long int)
 #endif
 
-#ifndef __attribute__
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
-#  define __attribute__(x)
-# endif
-#endif
-
-#ifndef ATTRIBUTE_NORETURN
-# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)
+# define _GL_ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
+#else
+# define _GL_ATTRIBUTE_NORETURN /* empty */
 #endif
 
 /* Report an error for an invalid integer in an option argument.
@@ -78,6 +74,6 @@
 
 void xstrtol_fatal (enum strtol_error,
                     int, char, struct option const *,
-                    char const *) ATTRIBUTE_NORETURN;
+                    char const *) _GL_ATTRIBUTE_NORETURN;
 
 #endif /* not XSTRTOL_H_ */
--- a/lib/xvasprintf.h
+++ b/lib/xvasprintf.h
@@ -20,16 +20,16 @@
 /* Get va_list.  */
 #include <stdarg.h>
 
-#ifndef __attribute__
 /* The __attribute__ feature is available in gcc versions 2.5 and later.
    The __-protected variants of the attributes 'format' and 'printf' are
    accepted by gcc versions 2.6.4 (effectively 2.7) and later.
-   We enable __attribute__ only if these are supported too, because
+   We enable _GL_ATTRIBUTE_FORMAT only if these are supported too, because
    gnulib and libintl do '#define printf __printf__' when they override
    the 'printf' function.  */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
-#  define __attribute__(Spec)   /* empty */
-# endif
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
+# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
+#else
+# define _GL_ATTRIBUTE_FORMAT(spec) /* empty */
 #endif
 
 #ifdef __cplusplus
@@ -44,9 +44,9 @@
      - [EILSEQ] error during conversion between wide and multibyte characters,
    return NULL.  */
 extern char *xasprintf (const char *format, ...)
-       __attribute__ ((__format__ (__printf__, 1, 2)));
+       _GL_ATTRIBUTE_FORMAT ((__printf__, 1, 2));
 extern char *xvasprintf (const char *format, va_list args)
-       __attribute__ ((__format__ (__printf__, 1, 0)));
+       _GL_ATTRIBUTE_FORMAT ((__printf__, 1, 0));
 
 #ifdef __cplusplus
 }
new file mode 100644
--- /dev/null
+++ b/m4/afunix.m4
@@ -0,0 +1,116 @@
+# afunix.m4 serial 6
+dnl Copyright (C) 2011 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_SOCKET_AFUNIX],
+[
+  AC_REQUIRE([gl_HEADER_SYS_SOCKET])
+  AC_REQUIRE([gl_SOCKET_FAMILY_UNIX])
+
+  AC_MSG_CHECKING([for UNIX domain sockets SCM_RIGHTS])
+  AC_CACHE_VAL([gl_cv_socket_unix_scm_rights],
+    [AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <sys/types.h>
+            #ifdef HAVE_SYS_SOCKET_H
+            #include <sys/socket.h>
+            #endif
+            #ifdef HAVE_SYS_UN_H
+            #include <sys/un.h>
+            #endif
+            #ifdef HAVE_WINSOCK2_H
+            #include <winsock2.h>
+            #endif
+          ]],
+          [[struct cmsghdr cmh;
+            cmh.cmsg_level = SOL_SOCKET;
+            cmh.cmsg_type = SCM_RIGHTS;
+            if (&cmh) return 0;
+          ]])],
+       [gl_cv_socket_unix_scm_rights=yes],
+       [gl_cv_socket_unix_scm_rights=no])
+    ])
+  AC_MSG_RESULT([$gl_cv_socket_unix_scm_rights])
+  if test $gl_cv_socket_unix_scm_rights = yes; then
+    AC_DEFINE([HAVE_UNIXSOCKET_SCM_RIGHTS], [1],
+      [Define to 1 if <sys/socket.h> defines SCM_RIGHTS.])
+  fi
+
+  dnl Persuade AIX 5.2 <sys/socket.h> to declare CMSG_SPACE, CMSG_LEN.
+  AC_DEFINE([_LINUX_SOURCE_COMPAT], [1],
+    [Define in order to get some macros on AIX systems.])
+
+  AC_MSG_CHECKING([for UNIX domain sockets SCM_RIGHTS that behave in BSD4.4 way])
+  AC_CACHE_VAL([gl_cv_socket_unix_scm_rights_bsd44_way],
+    [AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <sys/types.h>
+            #include <stddef.h>
+            #ifdef HAVE_SYS_SOCKET_H
+            #include <sys/socket.h>
+            #endif
+            #ifdef HAVE_SYS_UN_H
+            #include <sys/un.h>
+            #endif
+            #ifdef HAVE_WINSOCK2_H
+            #include <winsock2.h>
+            #endif
+            ]],
+            [[struct msghdr msg = {0};
+              struct cmsghdr *cmsg;
+              int myfds[1] = {0};
+              char buf[CMSG_SPACE (sizeof (myfds))];
+
+              msg.msg_control = buf;
+              msg.msg_controllen = sizeof buf;
+              cmsg = CMSG_FIRSTHDR (&msg);
+              cmsg->cmsg_level = SOL_SOCKET;
+              cmsg->cmsg_type = SCM_RIGHTS;
+              cmsg->cmsg_len = CMSG_LEN (sizeof (int));
+              /* fake Initialize the payload: */
+              (void) CMSG_DATA (cmsg);
+              /* Sum of the length of all control messages in the buffer: */
+              msg.msg_controllen = cmsg->cmsg_len;
+              return 0;
+            ]])],
+       [gl_cv_socket_unix_scm_rights_bsd44_way=yes],
+       [gl_cv_socket_unix_scm_rights_bsd44_way=no])
+    ])
+  AC_MSG_RESULT([$gl_cv_socket_unix_scm_rights_bsd44_way])
+  if test $gl_cv_socket_unix_scm_rights_bsd44_way = yes; then
+    AC_DEFINE([HAVE_UNIXSOCKET_SCM_RIGHTS_BSD44_WAY], [1],
+      [Define to 1 if fd can be sent/received in the BSD4.4 way.])
+  fi
+
+  AC_MSG_CHECKING([for UNIX domain sockets SCM_RIGHTS that behave in BSD4.3 way])
+  AC_CACHE_VAL([gl_cv_socket_unix_scm_rights_bsd43_way],
+    [AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <sys/types.h>
+            #ifdef HAVE_SYS_SOCKET_H
+            #include <sys/socket.h>
+            #endif
+            #ifdef HAVE_SYS_UN_H
+            #include <sys/un.h>
+            #endif
+            #ifdef HAVE_WINSOCK2_H
+            #include <winsock2.h>
+            #endif
+            ]],
+            [[struct msghdr msg;
+              int fd = 0;
+              msg.msg_accrights = &fd;
+              msg.msg_accrightslen = sizeof (fd);
+              if (&msg) return 0;
+            ]])],
+       [gl_cv_socket_unix_scm_rights_bsd43_way=yes],
+       [gl_cv_socket_unix_scm_rights_bsd43_way=no])
+    ])
+  AC_MSG_RESULT([$gl_cv_socket_unix_scm_rights_bsd43_way])
+  if test $gl_cv_socket_unix_scm_rights_bsd43_way = yes; then
+    AC_DEFINE([HAVE_UNIXSOCKET_SCM_RIGHTS_BSD43_WAY], [1],
+      [Define to 1 if fd can be sent/received in the BSD4.3 way.])
+  fi
+])
--- a/m4/backupfile.m4
+++ b/m4/backupfile.m4
@@ -1,4 +1,4 @@
-# backupfile.m4 serial 12
+# backupfile.m4 serial 13
 dnl Copyright (C) 2002-2006, 2009-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -10,7 +10,6 @@
 
   dnl Prerequisites of lib/backupfile.c.
   AC_REQUIRE([gl_CHECK_TYPE_STRUCT_DIRENT_D_INO])
-  AC_REQUIRE([gl_AC_DOS])
   AC_REQUIRE([AC_SYS_LONG_FILE_NAMES])
   AC_CHECK_FUNCS_ONCE([pathconf])
 ])
--- a/m4/dirname.m4
+++ b/m4/dirname.m4
@@ -1,4 +1,4 @@
-#serial 8   -*- autoconf -*-
+#serial 9   -*- autoconf -*-
 dnl Copyright (C) 2002-2006, 2009-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -18,7 +18,6 @@
   AC_LIBOBJ([stripslash])
 
   dnl Prerequisites of lib/dirname.h.
-  AC_REQUIRE([gl_AC_DOS])
   AC_REQUIRE([gl_DOUBLE_SLASH_ROOT])
 
   dnl No prerequisites of lib/basename-lgpl.c, lib/dirname-lgpl.c,
deleted file mode 100644
--- a/m4/dos.m4
+++ /dev/null
@@ -1,71 +0,0 @@
-#serial 11   -*- autoconf -*-
-
-# Define some macros required for proper operation of code in lib/*.c
-# on MSDOS/Windows systems.
-
-# Copyright (C) 2000-2001, 2004-2006, 2009-2011 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.
-
-# From Jim Meyering.
-
-AC_DEFUN([gl_AC_DOS],
-  [
-    AC_CACHE_CHECK([whether system is Windows or MSDOS], [ac_cv_win_or_dos],
-      [
-        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
-#if !defined _WIN32 && !defined __WIN32__ && !defined __MSDOS__ && !defined __CYGWIN__
-neither MSDOS nor Windows
-#endif]])],
-        [ac_cv_win_or_dos=yes],
-        [ac_cv_win_or_dos=no])
-      ])
-
-    if test x"$ac_cv_win_or_dos" = xyes; then
-      ac_fs_accepts_drive_letter_prefix=1
-      ac_fs_backslash_is_file_name_separator=1
-      AC_CACHE_CHECK([whether drive letter can start relative path],
-                     [ac_cv_drive_letter_can_be_relative],
-        [
-          AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
-#if defined __CYGWIN__
-drive letters are always absolute
-#endif]])],
-          [ac_cv_drive_letter_can_be_relative=yes],
-          [ac_cv_drive_letter_can_be_relative=no])
-        ])
-      if test x"$ac_cv_drive_letter_can_be_relative" = xyes; then
-        ac_fs_drive_letter_can_be_relative=1
-      else
-        ac_fs_drive_letter_can_be_relative=0
-      fi
-    else
-      ac_fs_accepts_drive_letter_prefix=0
-      ac_fs_backslash_is_file_name_separator=0
-      ac_fs_drive_letter_can_be_relative=0
-    fi
-
-    AC_DEFINE_UNQUOTED([FILE_SYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX],
-      $ac_fs_accepts_drive_letter_prefix,
-      [Define on systems for which file names may have a so-called
-       `drive letter' prefix, define this to compute the length of that
-       prefix, including the colon.])
-
-    AH_VERBATIM(ISSLASH,
-    [#if FILE_SYSTEM_BACKSLASH_IS_FILE_NAME_SEPARATOR
-# define ISSLASH(C) ((C) == '/' || (C) == '\\')
-#else
-# define ISSLASH(C) ((C) == '/')
-#endif])
-
-    AC_DEFINE_UNQUOTED([FILE_SYSTEM_BACKSLASH_IS_FILE_NAME_SEPARATOR],
-      $ac_fs_backslash_is_file_name_separator,
-      [Define if the backslash character may also serve as a file name
-       component separator.])
-
-    AC_DEFINE_UNQUOTED([FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE],
-      $ac_fs_drive_letter_can_be_relative,
-      [Define if a drive letter prefix denotes a relative path if it is
-       not followed by a file name component separator.])
-  ])
--- a/m4/fdopendir.m4
+++ b/m4/fdopendir.m4
@@ -1,4 +1,4 @@
-# serial 4
+# serial 5
 # See if we need to provide fdopendir.
 
 dnl Copyright (C) 2009-2011 Free Software Foundation, Inc.
@@ -27,12 +27,16 @@
       [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
 #include <dirent.h>
 #include <fcntl.h>
+#include <unistd.h>
 #if !HAVE_DECL_FDOPENDIR
 extern DIR *fdopendir (int);
 #endif
-]], [int fd = open ("conftest.c", O_RDONLY);
-     if (fd < 0) return 2;
-     return !!fdopendir (fd);])],
+]], [int result = 0;
+     int fd = open ("conftest.c", O_RDONLY);
+     if (fd < 0) result |= 1;
+     if (fdopendir (fd)) result |= 2;
+     if (close (fd)) result |= 4;
+     return result;])],
          [gl_cv_func_fdopendir_works=yes],
          [gl_cv_func_fdopendir_works=no],
          [gl_cv_func_fdopendir_works="guessing no"])])
--- a/m4/fseeko.m4
+++ b/m4/fseeko.m4
@@ -1,4 +1,4 @@
-# fseeko.m4 serial 10
+# fseeko.m4 serial 11
 dnl Copyright (C) 2007-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -53,3 +53,23 @@
   dnl If we are also using the fseek module, then fseek needs replacing, too.
   m4_ifdef([gl_REPLACE_FSEEK], [gl_REPLACE_FSEEK])
 ])
+
+dnl Code shared by fseeko and ftello.  Determine if large files are supported,
+dnl but stdin does not start as a large file by default.
+AC_DEFUN([gl_STDIN_LARGE_OFFSET],
+  [
+    AC_CACHE_CHECK([whether stdin defaults to large file offsets],
+      [gl_cv_var_stdin_large_offset],
+      [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]],
+[[#if defined __SL64 && defined __SCLE /* cygwin */
+  /* Cygwin 1.5.24 and earlier fail to put stdin in 64-bit mode, making
+     fseeko/ftello needlessly fail.  This bug was fixed in 1.5.25, and
+     it is easier to do a version check than building a runtime test.  */
+# include <cygwin/version.h>
+# if CYGWIN_VERSION_DLL_COMBINED < CYGWIN_VERSION_DLL_MAKE_COMBINED (1005, 25)
+  choke me
+# endif
+#endif]])],
+        [gl_cv_var_stdin_large_offset=yes],
+        [gl_cv_var_stdin_large_offset=no])])
+])
--- a/m4/getloadavg.m4
+++ b/m4/getloadavg.m4
@@ -20,90 +20,46 @@
 # Persuade glibc <stdlib.h> to declare getloadavg().
 AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
 
-gl_have_func=no # yes means we've found a way to get the load average.
-
 # Make sure getloadavg.c is where it belongs, at configure-time.
 test -f "$srcdir/$1/getloadavg.c" ||
   AC_MSG_ERROR([$srcdir/$1/getloadavg.c is missing])
 
 gl_save_LIBS=$LIBS
 
-# Check for getloadavg, but be sure not to touch the cache variable.
-(AC_CHECK_FUNC([getloadavg], [exit 0], [exit 1])) && gl_have_func=yes
-
-# On HPUX9, an unprivileged user can get load averages through this function.
-AC_CHECK_FUNCS([pstat_getdynamic])
-
-# Solaris has libkstat which does not require root.
-AC_CHECK_LIB([kstat], [kstat_open])
-test $ac_cv_lib_kstat_kstat_open = yes && gl_have_func=yes
-
-# AIX has libperfstat which does not require root
-AC_CHECK_LIB([perfstat], [perfstat_cpu_total])
-test $ac_cv_lib_perfstat_perfstat_cpu_total = yes && gl_have_func=yes
-
-# Some systems with -lutil have (and need) -lkvm as well, some do not.
-# On Solaris, -lkvm requires nlist from -lelf, so check that first
-# to get the right answer into the cache.
-# For kstat on solaris, we need to test for libelf and libkvm to force the
-# definition of SVR4 below.
-if test $gl_have_func = no; then
-  AC_CHECK_LIB([elf], [elf_begin], [LIBS="-lelf $LIBS"])
-  AC_CHECK_LIB([kvm], [kvm_open], [LIBS="-lkvm $LIBS"])
-  # Check for the 4.4BSD definition of getloadavg.
-  AC_CHECK_LIB([util], [getloadavg],
-    [LIBS="-lutil $LIBS" gl_have_func=yes gl_cv_func_getloadavg_setgid=yes])
-fi
-
-if test $gl_have_func = no; then
-  # There is a commonly available library for RS/6000 AIX.
-  # Since it is not a standard part of AIX, it might be installed locally.
-  gl_getloadavg_LIBS=$LIBS
-  LIBS="-L/usr/local/lib $LIBS"
-  AC_CHECK_LIB([getloadavg], [getloadavg],
-               [LIBS="-lgetloadavg $LIBS"], [LIBS=$gl_getloadavg_LIBS])
-fi
+# getloadvg is present in libc on glibc >= 2.2, MacOS X, FreeBSD >= 2.0,
+# NetBSD >= 0.9, OpenBSD >= 2.0, Solaris >= 7.
+AC_CHECK_FUNC([getloadavg], [],
+  [gl_have_func=no
 
-# Make sure it is really in the library, if we think we found it,
-# otherwise set up the replacement function.
-AC_CHECK_FUNCS([getloadavg], [],
-               [gl_PREREQ_GETLOADAVG])
+   # Some systems with -lutil have (and need) -lkvm as well, some do not.
+   # On Solaris, -lkvm requires nlist from -lelf, so check that first
+   # to get the right answer into the cache.
+   # For kstat on solaris, we need to test for libelf and libkvm to force the
+   # definition of SVR4 below.
+   if test $gl_have_func = no; then
+     AC_CHECK_LIB([elf], [elf_begin], [LIBS="-lelf $LIBS"])
+     AC_CHECK_LIB([kvm], [kvm_open], [LIBS="-lkvm $LIBS"])
+     # Check for the 4.4BSD definition of getloadavg.
+     AC_CHECK_LIB([util], [getloadavg],
+       [LIBS="-lutil $LIBS" gl_have_func=yes])
+   fi
 
-# Some definitions of getloadavg require that the program be installed setgid.
-AC_CACHE_CHECK([whether getloadavg requires setgid],
-               gl_cv_func_getloadavg_setgid,
-[AC_EGREP_CPP([Yowza Am I SETGID yet],
-[#define CONFIGURING_GETLOADAVG
-#include "$srcdir/$1/getloadavg.c"
-#ifdef LDAV_PRIVILEGED
-Yowza Am I SETGID yet
-#endif
-],
-              gl_cv_func_getloadavg_setgid=yes,
-              gl_cv_func_getloadavg_setgid=no)])
-if test $gl_cv_func_getloadavg_setgid = yes; then
-  NEED_SETGID=true
-  AC_DEFINE([GETLOADAVG_PRIVILEGED], [1],
-            [Define to 1 if the `getloadavg' function needs to be run setuid
-             or setgid.])
-else
-  NEED_SETGID=false
-fi
-AC_SUBST([NEED_SETGID])dnl
+   if test $gl_have_func = no; then
+     # There is a commonly available library for RS/6000 AIX.
+     # Since it is not a standard part of AIX, it might be installed locally.
+     gl_getloadavg_LIBS=$LIBS
+     LIBS="-L/usr/local/lib $LIBS"
+     AC_CHECK_LIB([getloadavg], [getloadavg],
+                  [LIBS="-lgetloadavg $LIBS" gl_have_func=yes],
+                  [LIBS=$gl_getloadavg_LIBS])
+   fi
 
-if test $gl_cv_func_getloadavg_setgid = yes; then
-  AC_CACHE_CHECK([group of /dev/kmem], [gl_cv_group_kmem],
-[ # On Solaris, /dev/kmem is a symlink.  Get info on the real file.
-  ac_ls_output=`ls -lgL /dev/kmem 2>/dev/null`
-  # If we got an error (system does not support symlinks), try without -L.
-  test -z "$ac_ls_output" && ac_ls_output=`ls -lg /dev/kmem`
-  gl_cv_group_kmem=`echo $ac_ls_output \
-    | sed -ne ['s/[	 ][	 ]*/ /g
-               s/^.[sSrwx-]* *[0-9]* *\([^0-9]*\)  *.*/\1/
-               / /s/.* //;p']`
-])
-  AC_SUBST([KMEM_GROUP], [$gl_cv_group_kmem])dnl
-fi
+   # Set up the replacement function if necessary.
+   if test $gl_have_func = no; then
+     AC_LIBOBJ([getloadavg])
+     gl_PREREQ_GETLOADAVG
+   fi])
+
 if test "x$gl_save_LIBS" = x; then
   GETLOADAVG_LIBS=$LIBS
 else
@@ -133,14 +89,30 @@
 # --------------------
 # Set up the AC_LIBOBJ replacement of `getloadavg'.
 AC_DEFUN([gl_PREREQ_GETLOADAVG],
-[AC_LIBOBJ([getloadavg])
-AC_DEFINE([C_GETLOADAVG], [1], [Define to 1 if using `getloadavg.c'.])
+[
 # Figure out what our getloadavg.c needs.
-gl_have_func=no
-AC_CHECK_HEADER([sys/dg_sys_info.h],
-[gl_have_func=yes
- AC_DEFINE([DGUX], [1], [Define to 1 for DGUX with <sys/dg_sys_info.h>.])
- AC_CHECK_LIB([dgc], [dg_sys_info])])
+
+# Solaris has libkstat which does not require root.
+AC_CHECK_LIB([kstat], [kstat_open])
+test $ac_cv_lib_kstat_kstat_open = yes && gl_have_func=yes
+
+# On HPUX9, an unprivileged user can get load averages this way.
+if test $gl_have_func = no; then
+  AC_CHECK_FUNCS([pstat_getdynamic], [gl_have_func=yes])
+fi
+
+# AIX has libperfstat which does not require root
+if test $gl_have_func = no; then
+  AC_CHECK_LIB([perfstat], [perfstat_cpu_total])
+  test $ac_cv_lib_perfstat_perfstat_cpu_total = yes && gl_have_func=yes
+fi
+
+if test $gl_have_func = no; then
+  AC_CHECK_HEADER([sys/dg_sys_info.h],
+    [gl_have_func=yes
+     AC_DEFINE([DGUX], [1], [Define to 1 for DGUX with <sys/dg_sys_info.h>.])
+     AC_CHECK_LIB([dgc], [dg_sys_info])])
+fi
 
 # We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it
 # uses stabs), but it is still SVR4.  We cannot check for <elf.h> because
@@ -171,10 +143,7 @@
 
 AC_CHECK_HEADERS([nlist.h],
 [AC_CHECK_MEMBERS([struct nlist.n_un.n_name],
-                  [AC_DEFINE([NLIST_NAME_UNION], [1],
-                             [Define to 1 if your `struct nlist' has an
-                              `n_un' member.  Obsolete, depend on
-                              `HAVE_STRUCT_NLIST_N_UN_N_NAME])], [],
+                  [], [],
                   [@%:@include <nlist.h>])
  AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <nlist.h>]],
                    [[struct nlist x;
--- a/m4/gnulib-common.m4
+++ b/m4/gnulib-common.m4
@@ -1,4 +1,4 @@
-# gnulib-common.m4 serial 23
+# gnulib-common.m4 serial 24
 dnl Copyright (C) 2007-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -109,7 +109,8 @@
 AC_DEFUN([gl_ASSERT_NO_GNULIB_POSIXCHECK],
 [
   dnl Override gl_WARN_ON_USE_PREPARE.
-  AC_DEFUN([gl_WARN_ON_USE_PREPARE], [])
+  dnl But hide this definition from 'aclocal'.
+  AC_DEFUN([gl_W][ARN_ON_USE_PREPARE], [])
 ])
 
 # gl_ASSERT_NO_GNULIB_TESTS
new file mode 100644
--- /dev/null
+++ b/m4/iswblank.m4
@@ -0,0 +1,31 @@
+# iswblank.m4 serial 2
+dnl Copyright (C) 2011 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_ISWBLANK],
+[
+  AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
+  AC_REQUIRE([gl_WCTYPE_H])
+  dnl Persuade glibc <wctype.h> to declare iswblank().
+  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+  AC_CHECK_FUNCS_ONCE([iswblank])
+  AC_CHECK_DECLS_ONCE([iswblank])
+  if test $ac_cv_func_iswblank = no; then
+    HAVE_ISWBLANK=0
+    if test $ac_cv_have_decl_iswblank = yes; then
+      REPLACE_ISWBLANK=1
+    fi
+  fi
+  if test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; then
+    dnl Redefine all of iswcntrl, ..., towupper in <wctype.h>.
+    :
+  else
+    if test $HAVE_ISWBLANK = 0 || test $REPLACE_ISWBLANK = 1; then
+      dnl Redefine only iswblank.
+      AC_LIBOBJ([iswblank])
+    fi
+  fi
+
+])
new file mode 100644
--- /dev/null
+++ b/m4/iswctype.m4
@@ -0,0 +1,14 @@
+# iswctype.m4 serial 1
+dnl Copyright (C) 2011 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_ISWCTYPE],
+[
+  AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
+  AC_REQUIRE([gl_WCTYPE_H])
+  if test $HAVE_WCTYPE_T = 0; then
+    AC_LIBOBJ([iswctype])
+  fi
+])
--- a/m4/lib-link.m4
+++ b/m4/lib-link.m4
@@ -1,4 +1,4 @@
-# lib-link.m4 serial 25 (gettext-0.18.2)
+# lib-link.m4 serial 26 (gettext-0.18.2)
 dnl Copyright (C) 2001-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -116,6 +116,8 @@
 dnl Determine the platform dependent parameters needed to use rpath:
 dnl   acl_libext,
 dnl   acl_shlibext,
+dnl   acl_libname_spec,
+dnl   acl_library_names_spec,
 dnl   acl_hardcode_libdir_flag_spec,
 dnl   acl_hardcode_libdir_separator,
 dnl   acl_hardcode_direct,
--- a/m4/locale-ar.m4
+++ b/m4/locale-ar.m4
@@ -1,4 +1,4 @@
-# locale-ar.m4 serial 2
+# locale-ar.m4 serial 3
 dnl Copyright (C) 2003, 2005-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -25,7 +25,17 @@
 char buf[16];
 int main () {
   /* Check whether the given locale name is recognized by the system.  */
+#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
+  /* On native Win32, setlocale(category, "") looks at the system settings,
+     not at the environment variables.  Also, when an encoding suffix such
+     as ".65001" or ".54936" is speficied, it succeeds but sets the LC_CTYPE
+     category of the locale to "C".  */
+  if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL
+      || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
+    return 1;
+#else
   if (setlocale (LC_ALL, "") == NULL) return 1;
+#endif
   /* Check that nl_langinfo(CODESET) is nonempty and not "ASCII" or "646"
      and ends in "6". */
 #if HAVE_LANGINFO_CODESET
@@ -47,24 +57,40 @@
 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.
-      # Values tested:
-      #   - The usual locale name:                         ar_SA
-      #   - The locale name with explicit encoding suffix: ar_SA.ISO-8859-6
-      #   - The HP-UX locale name:                         ar_SA.iso88596
-      #   - The Solaris 7 locale name:                     ar
-      # Also try ar_EG instead of ar_SA because Egypt is a large country too.
-      for gt_cv_locale_ar in ar_SA ar_SA.ISO-8859-6 ar_SA.iso88596 ar_EG ar_EG.ISO-8859-6 ar_EG.iso88596 ar none; do
-        if test $gt_cv_locale_ar = none; then
-          break
-        fi
-        if (LC_ALL=$gt_cv_locale_ar LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
-	  break
-	fi
-      done
+      case "$host_os" in
+        # Handle native Windows specially, because there setlocale() interprets
+        # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256",
+        # "fr" or "fra" as "French" or "French_France.1252",
+        # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252",
+        # "ja" as "Japanese" or "Japanese_Japan.932",
+        # and similar.
+        mingw*)
+          # Note that on native Win32, the Arabic locale is
+          # "Arabic_Saudi Arabia.1256", and CP1256 is very different from
+          # ISO-8859-6, so we cannot use it here.
+          gt_cv_locale_ar=none
+          ;;
+        *)
+          # 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.
+          # Values tested:
+          #   - The usual locale name:                         ar_SA
+          #   - The locale name with explicit encoding suffix: ar_SA.ISO-8859-6
+          #   - The HP-UX locale name:                         ar_SA.iso88596
+          #   - The Solaris 7 locale name:                     ar
+          # Also try ar_EG instead of ar_SA because Egypt is a large country too.
+          for gt_cv_locale_ar in ar_SA ar_SA.ISO-8859-6 ar_SA.iso88596 ar_EG ar_EG.ISO-8859-6 ar_EG.iso88596 ar none; do
+            if test $gt_cv_locale_ar = none; then
+              break
+            fi
+            if (LC_ALL=$gt_cv_locale_ar LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+              break
+            fi
+          done
+          ;;
+      esac
     fi
     rm -fr conftest*
   ])
--- a/m4/locale-fr.m4
+++ b/m4/locale-fr.m4
@@ -1,4 +1,4 @@
-# locale-fr.m4 serial 12
+# locale-fr.m4 serial 13
 dnl Copyright (C) 2003, 2005-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -25,7 +25,17 @@
 char buf[16];
 int main () {
   /* Check whether the given locale name is recognized by the system.  */
+#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
+  /* On native Win32, setlocale(category, "") looks at the system settings,
+     not at the environment variables.  Also, when an encoding suffix such
+     as ".65001" or ".54936" is speficied, it succeeds but sets the LC_CTYPE
+     category of the locale to "C".  */
+  if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL
+      || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
+    return 1;
+#else
   if (setlocale (LC_ALL, "") == NULL) return 1;
+#endif
   /* 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.
@@ -62,37 +72,56 @@
 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
+      case "$host_os" in
+        # Handle native Windows specially, because there setlocale() interprets
+        # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256",
+        # "fr" or "fra" as "French" or "French_France.1252",
+        # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252",
+        # "ja" as "Japanese" or "Japanese_Japan.932",
+        # and similar.
+        mingw*)
+          # Test for the native Win32 locale name.
+          if (LC_ALL=French_France.1252 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+            gt_cv_locale_fr=French_France.1252
           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
+            # None found.
+            gt_cv_locale_fr=none
+          fi
+          ;;
+        *)
+          # 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 Solaris 7 locale name.
-              if (LC_ALL=fr LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
-                gt_cv_locale_fr=fr
+              # 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
-                # None found.
-                gt_cv_locale_fr=none
+                # 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
-      fi
+          ;;
+      esac
     fi
     rm -fr conftest*
   ])
@@ -122,7 +151,17 @@
      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 (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
+  /* On native Win32, setlocale(category, "") looks at the system settings,
+     not at the environment variables.  Also, when an encoding suffix such
+     as ".65001" or ".54936" is speficied, it succeeds but sets the LC_CTYPE
+     category of the locale to "C".  */
+  if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL
+      || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
+    return 1;
+# else
   if (setlocale (LC_ALL, "") == NULL) return 1;
+# endif
   /* 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.
@@ -159,27 +198,46 @@
 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
+      case "$host_os" in
+        # Handle native Windows specially, because there setlocale() interprets
+        # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256",
+        # "fr" or "fra" as "French" or "French_France.1252",
+        # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252",
+        # "ja" as "Japanese" or "Japanese_Japan.932",
+        # and similar.
+        mingw*)
+          # Test for the hypothetical native Win32 locale name.
+          if (LC_ALL=French_France.65001 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+            gt_cv_locale_fr_utf8=French_France.65001
           else
             # None found.
             gt_cv_locale_fr_utf8=none
           fi
-        fi
-      fi
+          ;;
+        *)
+          # 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
+          ;;
+      esac
     fi
     rm -fr conftest*
   ])
--- a/m4/locale-ja.m4
+++ b/m4/locale-ja.m4
@@ -1,4 +1,4 @@
-# locale-ja.m4 serial 8
+# locale-ja.m4 serial 9
 dnl Copyright (C) 2003, 2005-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -27,7 +27,17 @@
 {
   const char *p;
   /* Check whether the given locale name is recognized by the system.  */
+#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
+  /* On native Win32, setlocale(category, "") looks at the system settings,
+     not at the environment variables.  Also, when an encoding suffix such
+     as ".65001" or ".54936" is speficied, it succeeds but sets the LC_CTYPE
+     category of the locale to "C".  */
+  if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL
+      || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
+    return 1;
+#else
   if (setlocale (LC_ALL, "") == NULL) return 1;
+#endif
   /* 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.
@@ -66,42 +76,57 @@
 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
+      case "$host_os" in
+        # Handle native Windows specially, because there setlocale() interprets
+        # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256",
+        # "fr" or "fra" as "French" or "French_France.1252",
+        # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252",
+        # "ja" as "Japanese" or "Japanese_Japan.932",
+        # and similar.
+        mingw*)
+          # Note that on native Win32, the Japanese locale is Japanese_Japan.932,
+          # and CP932 is very different from EUC-JP, so we cannot use it here.
+          gt_cv_locale_ja=none
+          ;;
+        *)
+          # 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 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
+            # 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 Solaris 7 locale name.
-              if (LC_ALL=ja LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
-                gt_cv_locale_ja=ja
+              # 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
-                # 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
+                # 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
-                  # None found.
-                  gt_cv_locale_ja=none
+                  # 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
-      fi
+          ;;
+      esac
     fi
     rm -fr conftest*
   ])
--- a/m4/locale-tr.m4
+++ b/m4/locale-tr.m4
@@ -1,4 +1,4 @@
-# locale-tr.m4 serial 6
+# locale-tr.m4 serial 7
 dnl Copyright (C) 2003, 2005-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -9,6 +9,7 @@
 dnl Determine the name of a turkish locale with UTF-8 encoding.
 AC_DEFUN([gt_LOCALE_TR_UTF8],
 [
+  AC_REQUIRE([AC_CANONICAL_HOST])
   AC_REQUIRE([AM_LANGINFO_CODESET])
   AC_CACHE_CHECK([for a turkish Unicode locale], [gt_cv_locale_tr_utf8], [
     AC_LANG_CONFTEST([AC_LANG_SOURCE([
@@ -29,7 +30,17 @@
      implement the Turkish upper-/lowercase mappings.  Therefore, let this
      program return 1 on BeOS.  */
   /* Check whether the given locale name is recognized by the system.  */
+#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
+  /* On native Win32, setlocale(category, "") looks at the system settings,
+     not at the environment variables.  Also, when an encoding suffix such
+     as ".65001" or ".54936" is speficied, it succeeds but sets the LC_CTYPE
+     category of the locale to "C".  */
+  if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL
+      || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
+    return 1;
+#else
   if (setlocale (LC_ALL, "") == NULL) return 1;
+#endif
   /* Check whether nl_langinfo(CODESET) is nonempty and not "ASCII" or "646".
      On MacOS X 10.3.5 (Darwin 7.5) in the tr_TR locale, nl_langinfo(CODESET)
      is empty, and the behaviour of Tcl 8.4 in this locale is not useful.
@@ -66,27 +77,46 @@
 changequote([,])dnl
       ])])
     if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
-      # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
-      # otherwise on MacOS X 10.3.5 the LC_TIME=C from the beginning of the
-      # configure script would override the LC_ALL setting. Likewise for
-      # LC_CTYPE, which is also set at the beginning of the configure script.
-      # Test for the usual locale name.
-      if (LC_ALL=tr_TR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
-        gt_cv_locale_tr_utf8=tr_TR
-      else
-        # Test for the locale name with explicit encoding suffix.
-        if (LC_ALL=tr_TR.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
-          gt_cv_locale_tr_utf8=tr_TR.UTF-8
-        else
-          # Test for the Solaris 7 locale name.
-          if (LC_ALL=tr.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
-            gt_cv_locale_tr_utf8=tr.UTF-8
+      case "$host_os" in
+        # Handle native Windows specially, because there setlocale() interprets
+        # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256",
+        # "fr" or "fra" as "French" or "French_France.1252",
+        # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252",
+        # "ja" as "Japanese" or "Japanese_Japan.932",
+        # and similar.
+        mingw*)
+          # Test for the hypothetical native Win32 locale name.
+          if (LC_ALL=Turkish_Turkey.65001 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+            gt_cv_locale_tr_utf8=Turkish_Turkey.65001
           else
             # None found.
             gt_cv_locale_tr_utf8=none
           fi
-        fi
-      fi
+          ;;
+        *)
+          # Setting LC_ALL is not enough. Need to set LC_TIME to empty, because
+          # otherwise on MacOS X 10.3.5 the LC_TIME=C from the beginning of the
+          # configure script would override the LC_ALL setting. Likewise for
+          # LC_CTYPE, which is also set at the beginning of the configure script.
+          # Test for the usual locale name.
+          if (LC_ALL=tr_TR LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+            gt_cv_locale_tr_utf8=tr_TR
+          else
+            # Test for the locale name with explicit encoding suffix.
+            if (LC_ALL=tr_TR.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+              gt_cv_locale_tr_utf8=tr_TR.UTF-8
+            else
+              # Test for the Solaris 7 locale name.
+              if (LC_ALL=tr.UTF-8 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+                gt_cv_locale_tr_utf8=tr.UTF-8
+              else
+                # None found.
+                gt_cv_locale_tr_utf8=none
+              fi
+            fi
+          fi
+          ;;
+      esac
     else
       gt_cv_locale_tr_utf8=none
     fi
--- a/m4/locale-zh.m4
+++ b/m4/locale-zh.m4
@@ -1,4 +1,4 @@
-# locale-zh.m4 serial 7
+# locale-zh.m4 serial 8
 dnl Copyright (C) 2003, 2005-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -28,7 +28,17 @@
 {
   const char *p;
   /* Check whether the given locale name is recognized by the system.  */
+#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
+  /* On native Win32, setlocale(category, "") looks at the system settings,
+     not at the environment variables.  Also, when an encoding suffix such
+     as ".65001" or ".54936" is speficied, it succeeds but sets the LC_CTYPE
+     category of the locale to "C".  */
+  if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL
+      || strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
+    return 1;
+#else
   if (setlocale (LC_ALL, "") == NULL) return 1;
+#endif
   /* 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.
@@ -67,22 +77,41 @@
 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
+      case "$host_os" in
+        # Handle native Windows specially, because there setlocale() interprets
+        # "ar" as "Arabic" or "Arabic_Saudi Arabia.1256",
+        # "fr" or "fra" as "French" or "French_France.1252",
+        # "ge"(!) or "deu"(!) as "German" or "German_Germany.1252",
+        # "ja" as "Japanese" or "Japanese_Japan.932",
+        # and similar.
+        mingw*)
+          # Test for the hypothetical native Win32 locale name.
+          if (LC_ALL=Chinese_China.54936 LC_TIME= LC_CTYPE= ./conftest; exit) 2>/dev/null; then
+            gt_cv_locale_zh_CN=Chinese_China.54936
+          else
+            # None found.
+            gt_cv_locale_zh_CN=none
+          fi
+          ;;
+        *)
+          # 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
+          ;;
+      esac
     else
       # If there was a link error, due to mblen(), the system is so old that
       # it certainly doesn't have a chinese locale.
--- a/m4/locale_h.m4
+++ b/m4/locale_h.m4
@@ -1,4 +1,4 @@
-# locale_h.m4 serial 12
+# locale_h.m4 serial 13
 dnl Copyright (C) 2007, 2009-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -70,7 +70,8 @@
 #if HAVE_XLOCALE_H
 # include <xlocale.h>
 #endif
-   ]], [duplocale])
+    ]],
+    [setlocale duplocale])
 ])
 
 dnl Unconditionally enables the replacement of <locale.h>.
@@ -91,8 +92,10 @@
 
 AC_DEFUN([gl_LOCALE_H_DEFAULTS],
 [
+  GNULIB_SETLOCALE=0;  AC_SUBST([GNULIB_SETLOCALE])
   GNULIB_DUPLOCALE=0;  AC_SUBST([GNULIB_DUPLOCALE])
   dnl Assume proper GNU behavior unless another module says otherwise.
   HAVE_DUPLOCALE=1;    AC_SUBST([HAVE_DUPLOCALE])
+  REPLACE_SETLOCALE=0; AC_SUBST([REPLACE_SETLOCALE])
   REPLACE_DUPLOCALE=0; AC_SUBST([REPLACE_DUPLOCALE])
 ])
--- a/m4/longlong.m4
+++ b/m4/longlong.m4
@@ -1,4 +1,4 @@
-# longlong.m4 serial 14
+# longlong.m4 serial 16
 dnl Copyright (C) 1999-2007, 2009-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -7,8 +7,8 @@
 dnl From Paul Eggert.
 
 # Define HAVE_LONG_LONG_INT if 'long long int' works.
-# This fixes a bug in Autoconf 2.61, but can be removed once we
-# assume 2.62 everywhere.
+# This fixes a bug in Autoconf 2.61, and can be faster
+# than what's in Autoconf 2.62 through 2.68.
 
 # Note: If the type 'long long int' exists but is only 32 bits large
 # (as on some very old compilers), HAVE_LONG_LONG_INT will not be
@@ -16,35 +16,39 @@
 
 AC_DEFUN([AC_TYPE_LONG_LONG_INT],
 [
+  AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
   AC_CACHE_CHECK([for long long int], [ac_cv_type_long_long_int],
-    [AC_LINK_IFELSE(
-       [_AC_TYPE_LONG_LONG_SNIPPET],
-       [dnl This catches a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004.
-        dnl If cross compiling, assume the bug isn't important, since
-        dnl nobody cross compiles for this platform as far as we know.
-        AC_RUN_IFELSE(
-          [AC_LANG_PROGRAM(
-             [[@%:@include <limits.h>
-               @%:@ifndef LLONG_MAX
-               @%:@ define HALF \
-                        (1LL << (sizeof (long long int) * CHAR_BIT - 2))
-               @%:@ define LLONG_MAX (HALF - 1 + HALF)
-               @%:@endif]],
-             [[long long int n = 1;
-               int i;
-               for (i = 0; ; i++)
-                 {
-                   long long int m = n << i;
-                   if (m >> i != n)
-                     return 1;
-                   if (LLONG_MAX / 2 < m)
-                     break;
-                 }
-               return 0;]])],
-          [ac_cv_type_long_long_int=yes],
-          [ac_cv_type_long_long_int=no],
-          [ac_cv_type_long_long_int=yes])],
-       [ac_cv_type_long_long_int=no])])
+     [ac_cv_type_long_long_int=yes
+      if test "x${ac_cv_prog_cc_c99-no}" = xno; then
+        ac_cv_type_long_long_int=$ac_cv_type_unsigned_long_long_int
+        if test $ac_cv_type_long_long_int = yes; then
+          dnl Catch a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004.
+          dnl If cross compiling, assume the bug is not important, since
+          dnl nobody cross compiles for this platform as far as we know.
+          AC_RUN_IFELSE(
+            [AC_LANG_PROGRAM(
+               [[@%:@include <limits.h>
+                 @%:@ifndef LLONG_MAX
+                 @%:@ define HALF \
+                          (1LL << (sizeof (long long int) * CHAR_BIT - 2))
+                 @%:@ define LLONG_MAX (HALF - 1 + HALF)
+                 @%:@endif]],
+               [[long long int n = 1;
+                 int i;
+                 for (i = 0; ; i++)
+                   {
+                     long long int m = n << i;
+                     if (m >> i != n)
+                       return 1;
+                     if (LLONG_MAX / 2 < m)
+                       break;
+                   }
+                 return 0;]])],
+            [],
+            [ac_cv_type_long_long_int=no],
+            [:])
+        fi
+      fi])
   if test $ac_cv_type_long_long_int = yes; then
     AC_DEFINE([HAVE_LONG_LONG_INT], [1],
       [Define to 1 if the system has the type `long long int'.])
@@ -52,8 +56,8 @@
 ])
 
 # Define HAVE_UNSIGNED_LONG_LONG_INT if 'unsigned long long int' works.
-# This fixes a bug in Autoconf 2.61, but can be removed once we
-# assume 2.62 everywhere.
+# This fixes a bug in Autoconf 2.61, and can be faster
+# than what's in Autoconf 2.62 through 2.68.
 
 # Note: If the type 'unsigned long long int' exists but is only 32 bits
 # large (as on some very old compilers), AC_TYPE_UNSIGNED_LONG_LONG_INT
@@ -64,10 +68,13 @@
 [
   AC_CACHE_CHECK([for unsigned long long int],
     [ac_cv_type_unsigned_long_long_int],
-    [AC_LINK_IFELSE(
-       [_AC_TYPE_LONG_LONG_SNIPPET],
-       [ac_cv_type_unsigned_long_long_int=yes],
-       [ac_cv_type_unsigned_long_long_int=no])])
+    [ac_cv_type_unsigned_long_long_int=yes
+     if test "x${ac_cv_prog_cc_c99-no}" = xno; then
+       AC_LINK_IFELSE(
+         [_AC_TYPE_LONG_LONG_SNIPPET],
+         [],
+         [ac_cv_type_unsigned_long_long_int=no])
+     fi])
   if test $ac_cv_type_unsigned_long_long_int = yes; then
     AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], [1],
       [Define to 1 if the system has the type `unsigned long long int'.])
--- a/m4/mbrtowc.m4
+++ b/m4/mbrtowc.m4
@@ -1,4 +1,4 @@
-# mbrtowc.m4 serial 21
+# mbrtowc.m4 serial 22
 dnl Copyright (C) 2001-2002, 2004-2005, 2008-2011 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
@@ -348,7 +348,7 @@
   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_REQUIRE([AC_CANONICAL_HOST])
   AC_CACHE_CHECK([whether mbrtowc has a correct return value],
     [gl_cv_func_mbrtowc_retval],
     [
@@ -356,13 +356,14 @@
       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" ;;
+                                   # Guess no on HP-UX, Solaris, native Windows.
+        hpux* | solaris* | mingw*) 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
+      if test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none \
+         || { case "$host_os" in mingw*) true;; *) false;; esac; }; then
         AC_RUN_IFELSE(
           [AC_LANG_SOURCE([[
 #include <locale.h>
@@ -378,6 +379,7 @@
 int main ()
 {
   int result = 0;
+  int found_some_locale = 0;
   /* This fails on Solaris.  */
   if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
     {
@@ -392,6 +394,7 @@
           if (mbrtowc (&wc, input + 2, 5, &state) != 1)
             result |= 1;
         }
+      found_some_locale = 1;
     }
   /* This fails on HP-UX 11.11.  */
   if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
@@ -407,11 +410,61 @@
           if (mbrtowc (&wc, input + 2, 5, &state) != 2)
             result |= 2;
         }
+      found_some_locale = 1;
     }
-  return result;
+  /* This fails on native Windows.  */
+  if (setlocale (LC_ALL, "Japanese_Japan.932") != NULL)
+    {
+      char input[] = "<\223\372\226\173\214\352>"; /* "<日本語>" */
+      mbstate_t state;
+      wchar_t wc;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      if (mbrtowc (&wc, input + 3, 1, &state) == (size_t)(-2))
+        {
+          input[3] = '\0';
+          if (mbrtowc (&wc, input + 4, 4, &state) != 1)
+            result |= 4;
+        }
+      found_some_locale = 1;
+    }
+  if (setlocale (LC_ALL, "Chinese_Taiwan.950") != NULL)
+    {
+      char input[] = "<\244\351\245\273\273\171>"; /* "<日本語>" */
+      mbstate_t state;
+      wchar_t wc;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      if (mbrtowc (&wc, input + 3, 1, &state) == (size_t)(-2))
+        {
+          input[3] = '\0';
+          if (mbrtowc (&wc, input + 4, 4, &state) != 1)
+            result |= 8;
+        }
+      found_some_locale = 1;
+    }
+  if (setlocale (LC_ALL, "Chinese_China.936") != NULL)
+    {
+      char input[] = "<\310\325\261\276\325\132>"; /* "<日本語>" */
+      mbstate_t state;
+      wchar_t wc;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      if (mbrtowc (&wc, input + 3, 1, &state) == (size_t)(-2))
+        {
+          input[3] = '\0';
+          if (mbrtowc (&wc, input + 4, 4, &state) != 1)
+            result |= 16;
+        }
+      found_some_locale = 1;
+    }
+  return (found_some_locale ? result : 77);
 }]])],
           [gl_cv_func_mbrtowc_retval=yes],
-          [gl_cv_func_mbrtowc_retval=no],
+          [if test $? != 77; then
+             gl_cv_func_mbrtowc_retval=no
+           fi
+          ],
           [:])
       fi
     ])
--- a/m4/mbsinit.m4
+++ b/m4/mbsinit.m4
@@ -1,4 +1,4 @@
-# mbsinit.m4 serial 4
+# mbsinit.m4 serial 5
 dnl Copyright (C) 2008, 2010-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -7,6 +7,7 @@
 AC_DEFUN([gl_FUNC_MBSINIT],
 [
   AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+  AC_REQUIRE([AC_CANONICAL_HOST])
 
   AC_REQUIRE([AC_TYPE_MBSTATE_T])
   gl_MBSTATE_T_BROKEN
@@ -17,6 +18,13 @@
   else
     if test $REPLACE_MBSTATE_T = 1; then
       REPLACE_MBSINIT=1
+    else
+      dnl On mingw, mbsinit() always returns 1, which is inappropriate for
+      dnl states produced by mbrtowc() for an incomplete multibyte character
+      dnl in multibyte locales.
+      case "$host_os" in
+        mingw*) REPLACE_MBSINIT=1 ;;
+      esac
     fi
   fi
   if test $HAVE_MBSINIT = 0 || test $REPLACE_MBSINIT = 1; then
--- a/m4/mbsrtowcs.m4
+++ b/m4/mbsrtowcs.m4
@@ -1,4 +1,4 @@
-# mbsrtowcs.m4 serial 9
+# mbsrtowcs.m4 serial 10
 dnl Copyright (C) 2008-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -39,6 +39,7 @@
 AC_DEFUN([gl_MBSRTOWCS_WORKS],
 [
   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])
@@ -50,13 +51,13 @@
       dnl is present.
 changequote(,)dnl
       case "$host_os" in
-                          # Guess no on HP-UX and Solaris.
-        hpux* | solaris*) gl_cv_func_mbsrtowcs_works="guessing no" ;;
-                          # Guess yes otherwise.
-        *)                gl_cv_func_mbsrtowcs_works="guessing yes" ;;
+                                   # Guess no on HP-UX, Solaris, mingw.
+        hpux* | solaris* | mingw*) gl_cv_func_mbsrtowcs_works="guessing no" ;;
+                                   # Guess yes otherwise.
+        *)                         gl_cv_func_mbsrtowcs_works="guessing yes" ;;
       esac
 changequote([,])dnl
-      if test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none || test $LOCALE_ZH_CN != none; then
+      if test $LOCALE_FR != none || test $LOCALE_FR_UTF8 != none || test $LOCALE_JA != none || test $LOCALE_ZH_CN != none; then
         AC_RUN_IFELSE(
           [AC_LANG_SOURCE([[
 #include <locale.h>
@@ -72,6 +73,19 @@
 int main ()
 {
   int result = 0;
+  /* Test whether the function supports a NULL destination argument.
+     This fails on native Windows.  */
+  if (setlocale (LC_ALL, "$LOCALE_FR") != NULL)
+    {
+      const char input[] = "\337er";
+      const char *src = input;
+      mbstate_t state;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      if (mbsrtowcs (NULL, &src, 1, &state) != 3
+          || src != input)
+        result |= 1;
+    }
   /* Test whether the function works when started with a conversion state
      in non-initial state.  This fails on HP-UX 11.11 and Solaris 10.  */
   if (setlocale (LC_ALL, "$LOCALE_FR_UTF8") != NULL)
@@ -85,7 +99,7 @@
           {
             const char *src = input + 2;
             if (mbsrtowcs (NULL, &src, 10, &state) != 4)
-              result |= 1;
+              result |= 2;
           }
     }
   if (setlocale (LC_ALL, "$LOCALE_JA") != NULL)
@@ -99,7 +113,7 @@
           {
             const char *src = input + 4;
             if (mbsrtowcs (NULL, &src, 10, &state) != 3)
-              result |= 2;
+              result |= 4;
           }
     }
   if (setlocale (LC_ALL, "$LOCALE_ZH_CN") != NULL)
@@ -113,7 +127,7 @@
           {
             const char *src = input + 2;
             if (mbsrtowcs (NULL, &src, 10, &state) != 4)
-              result |= 4;
+              result |= 8;
           }
     }
   return result;
new file mode 100644
--- /dev/null
+++ b/m4/mbtowc.m4
@@ -0,0 +1,23 @@
+# mbtowc.m4 serial 1
+dnl Copyright (C) 2011 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_MBTOWC],
+[
+  AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
+
+  if false; then
+    REPLACE_MBTOWC=1
+  fi
+  if test $REPLACE_MBTOWC = 1; then
+    AC_LIBOBJ([mbtowc])
+    gl_PREREQ_MBTOWC
+  fi
+])
+
+# Prerequisites of lib/mbtowc.c.
+AC_DEFUN([gl_PREREQ_MBTOWC], [
+  :
+])
--- a/m4/openmp.m4
+++ b/m4/openmp.m4
@@ -1,4 +1,4 @@
-# openmp.m4 serial 7
+# openmp.m4 serial 9
 dnl Copyright (C) 2006-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -35,7 +35,14 @@
 # _AC_LANG_OPENMP(Fortran 77)
 # ---------------------------
 m4_define([_AC_LANG_OPENMP(Fortran 77)],
-[AC_LANG_FUNC_LINK_TRY([omp_get_num_threads])])
+[
+      program main
+      implicit none
+!$    integer tid
+      tid = 42
+      call omp_set_num_threads(2)
+      end
+])
 
 # _AC_LANG_OPENMP(Fortran)
 # ---------------------------
@@ -70,12 +77,16 @@
           dnl   SGI C, PGI C         -mp
           dnl   Tru64 Compaq C       -omp
           dnl   IBM C (AIX, Linux)   -qsmp=omp
+          dnl   Cray CCE             -homp
+          dnl   NEC SX               -Popenmp
+          dnl   Lahey Fortran (Linux)  --openmp
           dnl If in this loop a compiler is passed an option that it doesn't
           dnl understand or that it misinterprets, the AC_LINK_IFELSE test
           dnl will fail (since we know that it failed without the option),
           dnl therefore the loop will continue searching for an option, and
           dnl no output file called 'penmp' or 'mp' is created.
-          for ac_option in -fopenmp -xopenmp -openmp -mp -omp -qsmp=omp; do
+          for ac_option in -fopenmp -xopenmp -openmp -mp -omp -qsmp=omp -homp \
+                           -Popenmp --openmp; do
             ac_save_[]_AC_LANG_PREFIX[]FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
             _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $ac_option"
             AC_LINK_IFELSE([_AC_LANG_OPENMP],
--- a/m4/printf-posix-rpl.m4
+++ b/m4/printf-posix-rpl.m4
@@ -1,4 +1,4 @@
-# printf-posix-rpl.m4 serial 3
+# printf-posix-rpl.m4 serial 4
 dnl Copyright (C) 2007-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -15,6 +15,7 @@
 AC_DEFUN([gl_REPLACE_PRINTF],
 [
   AC_REQUIRE([gl_STDIO_H_DEFAULTS])
+  AC_REQUIRE([gl_ASM_SYMBOL_PREFIX])
   AC_LIBOBJ([printf])
   REPLACE_PRINTF=1
   AC_DEFINE([REPLACE_PRINTF_POSIX], [1],
--- a/m4/random_r.m4
+++ b/m4/random_r.m4
@@ -1,4 +1,4 @@
-# serial 1
+# serial 3
 dnl Copyright (C) 2008-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -7,6 +7,20 @@
 AC_DEFUN([gl_FUNC_RANDOM_R],
 [
   AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
+
+  AC_CHECK_HEADERS([random.h], [], [], [AC_INCLUDES_DEFAULT])
+  if test $ac_cv_header_random_h = no; then
+    HAVE_RANDOM_H=0
+  fi
+
+  AC_CHECK_TYPES([struct random_data],
+    [], [HAVE_STRUCT_RANDOM_DATA=0],
+    [[#include <stdlib.h>
+      #if HAVE_RANDOM_H
+      # include <random.h>
+      #endif
+    ]])
+
   AC_CHECK_FUNCS([random_r])
   if test $ac_cv_func_random_r = no; then
     HAVE_RANDOM_R=0
--- a/m4/remove.m4
+++ b/m4/remove.m4
@@ -1,4 +1,4 @@
-# remove.m4 serial 1
+# remove.m4 serial 2
 dnl Copyright (C) 2009-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -7,7 +7,6 @@
 AC_DEFUN([gl_FUNC_REMOVE],
 [
   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
-  AC_REQUIRE([gl_AC_DOS])
   AC_REQUIRE([gl_STDIO_H_DEFAULTS])
   AC_REQUIRE([gl_FUNC_RMDIR])
   AC_REQUIRE([gl_FUNC_UNLINK])
--- a/m4/rmdir.m4
+++ b/m4/rmdir.m4
@@ -1,4 +1,4 @@
-# rmdir.m4 serial 9
+# rmdir.m4 serial 10
 dnl Copyright (C) 2002, 2005, 2009-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -6,7 +6,6 @@
 
 AC_DEFUN([gl_FUNC_RMDIR],
 [
-  AC_REQUIRE([gl_AC_DOS])
   AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
   dnl Detect cygwin 1.5.x bug.
   AC_CACHE_CHECK([whether rmdir works], [gl_cv_func_rmdir_works],
--- a/m4/setenv.m4
+++ b/m4/setenv.m4
@@ -1,4 +1,4 @@
-# setenv.m4 serial 20
+# setenv.m4 serial 21
 dnl Copyright (C) 2001-2004, 2006-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -97,20 +97,30 @@
     fi
 
     dnl Solaris 10 unsetenv does not remove all copies of a name.
+    dnl Haiku alpha 2 unsetenv gets confused by assignment to environ.
     dnl OpenBSD 4.7 unsetenv("") does not fail.
     AC_CACHE_CHECK([whether unsetenv obeys POSIX],
       [gl_cv_func_unsetenv_works],
       [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
        #include <stdlib.h>
        #include <errno.h>
+       extern char **environ;
       ]], [[
-       char entry[] = "b=2";
+       char entry1[] = "a=1";
+       char entry2[] = "b=2";
+       char *env[] = { entry1, entry2, NULL };
        if (putenv ((char *) "a=1")) return 1;
-       if (putenv (entry)) return 2;
-       entry[0] = 'a';
+       if (putenv (entry2)) return 2;
+       entry2[0] = 'a';
        unsetenv ("a");
        if (getenv ("a")) return 3;
        if (!unsetenv ("") || errno != EINVAL) return 4;
+       entry2[0] = 'b';
+       environ = env;
+       if (!getenv ("a")) return 5;
+       entry2[0] = 'a';
+       unsetenv ("a");
+       if (getenv ("a")) return 6;
       ]])],
       [gl_cv_func_unsetenv_works=yes], [gl_cv_func_unsetenv_works=no],
       [gl_cv_func_unsetenv_works="guessing no"])])
new file mode 100644
--- /dev/null
+++ b/m4/setlocale.m4
@@ -0,0 +1,27 @@
+# setlocale.m4 serial 1
+dnl Copyright (C) 2011 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_SETLOCALE],
+[
+  AC_REQUIRE([gl_LOCALE_H_DEFAULTS])
+  AC_REQUIRE([AC_CANONICAL_HOST])
+  case "$host_os" in
+    dnl On native Windows systems, setlocale(category,NULL) does not look at
+    dnl the environment variables LC_ALL, category, and LANG.
+    mingw*) REPLACE_SETLOCALE=1 ;;
+  esac
+  if test $REPLACE_SETLOCALE = 1; then
+    gl_REPLACE_LOCALE_H
+    AC_LIBOBJ([setlocale])
+    gl_PREREQ_SETLOCALE
+  fi
+])
+
+# Prerequisites of lib/setlocale.c.
+AC_DEFUN([gl_PREREQ_SETLOCALE],
+[
+  :
+])
--- a/m4/socklen.m4
+++ b/m4/socklen.m4
@@ -1,4 +1,4 @@
-# socklen.m4 serial 8
+# socklen.m4 serial 10
 dnl Copyright (C) 2005-2007, 2009-2011 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,15 +9,11 @@
 dnl Check for socklen_t: historically on BSD it is an int, and in
 dnl POSIX 1g it is a type of its own, but some platforms use different
 dnl types for the argument to getsockopt, getpeername, etc.:
-dnl HP-UX 10.20, IRIX 6.5, Interix 3.5, BeOS.
+dnl HP-UX 10.20, IRIX 6.5, OSF/1 4.0, Interix 3.5, BeOS.
 dnl So we have to test to find something that will work.
 
-dnl On mingw32, socklen_t is in ws2tcpip.h ('int'), so we try to find
-dnl it there first.  That file is included by gnulib's sys_socket.in.h, which
-dnl all users of this module should include.  Cygwin must not include
-dnl ws2tcpip.h.
 AC_DEFUN([gl_TYPE_SOCKLEN_T],
-  [AC_REQUIRE([gl_HEADER_SYS_SOCKET])dnl
+  [AC_REQUIRE([gl_CHECK_SOCKET_HEADERS])dnl
    AC_CHECK_TYPE([socklen_t], ,
      [AC_MSG_CHECKING([for socklen_t equivalent])
       AC_CACHE_VAL([gl_cv_socklen_t_equiv],
@@ -45,9 +41,37 @@
       AC_MSG_RESULT([$gl_cv_socklen_t_equiv])
       AC_DEFINE_UNQUOTED([socklen_t], [$gl_cv_socklen_t_equiv],
         [type to use in place of socklen_t if not defined])],
-     [#include <sys/types.h>
-      #if HAVE_SYS_SOCKET_H
-      # include <sys/socket.h>
-      #elif HAVE_WS2TCPIP_H
-      # include <ws2tcpip.h>
-      #endif])])
+     [gl_SOCKET_HEADERS])])
+
+dnl On mingw32, socklen_t is in ws2tcpip.h ('int'), so we try to find
+dnl it there too.  But on Cygwin, wc2tcpip.h must not be included.  Users
+dnl of this module should use the same include pattern as gl_SOCKET_HEADERS.
+dnl When you change this macro, keep also in sync:
+dnl   - gl_CHECK_SOCKET_HEADERS,
+dnl   - the Include section of modules/socklen.
+AC_DEFUN([gl_SOCKET_HEADERS],
+[
+/* <sys/types.h> is not needed according to POSIX, but the
+   <sys/socket.h> in i386-unknown-freebsd4.10 and
+   powerpc-apple-darwin5.5 required it. */
+#include <sys/types.h>
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#elif HAVE_WS2TCPIP_H
+# include <ws2tcpip.h>
+#endif
+])
+
+dnl Tests for the existence of the header for socket facilities.
+dnl Defines the C macros HAVE_SYS_SOCKET_H, HAVE_WS2TCPIP_H.
+dnl This macro must match gl_SOCKET_HEADERS.
+AC_DEFUN([gl_CHECK_SOCKET_HEADERS],
+  [AC_CHECK_HEADERS_ONCE([sys/socket.h])
+   if test $ac_cv_header_sys_socket_h = no; then
+     dnl We cannot use AC_CHECK_HEADERS_ONCE here, because that would make
+     dnl the check for those headers unconditional; yet cygwin reports
+     dnl that the headers are present but cannot be compiled (since on
+     dnl cygwin, all socket information should come from sys/socket.h).
+     AC_CHECK_HEADERS([ws2tcpip.h])
+   fi
+  ])
--- a/m4/sockpfaf.m4
+++ b/m4/sockpfaf.m4
@@ -1,4 +1,4 @@
-# sockpfaf.m4 serial 7
+# sockpfaf.m4 serial 8
 dnl Copyright (C) 2004, 2006, 2009-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -59,3 +59,29 @@
     AC_DEFINE([HAVE_IPV6], [1], [Define to 1 if <sys/socket.h> defines AF_INET6.])
   fi
 ])
+
+AC_DEFUN([gl_SOCKET_FAMILY_UNIX],
+[
+  AC_REQUIRE([gl_HEADER_SYS_SOCKET])
+  AC_CHECK_HEADERS_ONCE([sys/un.h])
+
+  AC_MSG_CHECKING([for UNIX domain sockets])
+  AC_CACHE_VAL([gl_cv_socket_unix],
+    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#ifdef HAVE_SYS_UN_H
+#include <sys/un.h>
+#endif
+#ifdef HAVE_WINSOCK2_H
+#include <winsock2.h>
+#endif]],
+[[int x = AF_UNIX; struct sockaddr_un y;
+ if (&x && &y) return 0;]])],
+       gl_cv_socket_unix=yes, gl_cv_socket_unix=no)])
+  AC_MSG_RESULT([$gl_cv_socket_unix])
+  if test $gl_cv_socket_unix = yes; then
+    AC_DEFINE([HAVE_UNIXSOCKET], [1], [Define to 1 if <sys/socket.h> defines AF_UNIX.])
+  fi
+])
--- a/m4/stat.m4
+++ b/m4/stat.m4
@@ -1,4 +1,4 @@
-# serial 6
+# serial 7
 
 # Copyright (C) 2009-2011 Free Software Foundation, Inc.
 #
@@ -9,7 +9,6 @@
 AC_DEFUN([gl_FUNC_STAT],
 [
   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
-  AC_REQUIRE([gl_AC_DOS])
   AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
   AC_CHECK_FUNCS_ONCE([lstat])
   dnl mingw is the only known platform where stat(".") and stat("./") differ
--- a/m4/stdbool.m4
+++ b/m4/stdbool.m4
@@ -5,13 +5,13 @@
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
 
-#serial 3
+#serial 4
 
 # Prepare for substituting <stdbool.h> if it is not supported.
 
 AC_DEFUN([AM_STDBOOL_H],
 [
-  AC_REQUIRE([AC_HEADER_STDBOOL])
+  AC_REQUIRE([AC_CHECK_HEADER_STDBOOL])
 
   # Define two additional variables used in the Makefile substitution.
 
@@ -33,11 +33,9 @@
 # AM_STDBOOL_H will be renamed to gl_STDBOOL_H in the future.
 AC_DEFUN([gl_STDBOOL_H], [AM_STDBOOL_H])
 
-# This version of the macro is needed in autoconf <= 2.67.  Autoconf has
-# it built in since 2.60, but we want the tweaks from the 2.68 version
-# to avoid rejecting xlc and clang due to relying on extensions.
+# This version of the macro is needed in autoconf <= 2.68.
 
-AC_DEFUN([AC_HEADER_STDBOOL],
+AC_DEFUN([AC_CHECK_HEADER_STDBOOL],
   [AC_CACHE_CHECK([for stdbool.h that conforms to C99],
      [ac_cv_header_stdbool_h],
      [AC_COMPILE_IFELSE(
@@ -98,6 +96,4 @@
         [ac_cv_header_stdbool_h=yes],
         [ac_cv_header_stdbool_h=no])])
    AC_CHECK_TYPES([_Bool])
-   if test $ac_cv_header_stdbool_h = yes; then
-     AC_DEFINE([HAVE_STDBOOL_H], [1], [Define to 1 if stdbool.h conforms to C99.])
-   fi])
+])
--- a/m4/stdint.m4
+++ b/m4/stdint.m4
@@ -1,4 +1,4 @@
-# stdint.m4 serial 37
+# stdint.m4 serial 39
 dnl Copyright (C) 2001-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -27,6 +27,15 @@
   fi
   AC_SUBST([HAVE_UNSIGNED_LONG_LONG_INT])
 
+  dnl Check for <wchar.h>, in the same way as gl_WCHAR_H does.
+  AC_CHECK_HEADERS_ONCE([wchar.h])
+  if test $ac_cv_header_wchar_h = yes; then
+    HAVE_WCHAR_H=1
+  else
+    HAVE_WCHAR_H=0
+  fi
+  AC_SUBST([HAVE_WCHAR_H])
+
   dnl Check for <inttypes.h>.
   dnl AC_INCLUDES_DEFAULT defines $ac_cv_header_inttypes_h.
   if test $ac_cv_header_inttypes_h = yes; then
@@ -292,10 +301,6 @@
     fi
     AC_SUBST([HAVE_SYS_BITYPES_H])
 
-    dnl Check for <wchar.h> (missing in Linux uClibc when built without wide
-    dnl character support).
-    AC_CHECK_HEADERS_ONCE([wchar.h])
-
     gl_STDINT_TYPE_PROPERTIES
     STDINT_H=stdint.h
   fi
--- a/m4/stdio_h.m4
+++ b/m4/stdio_h.m4
@@ -1,4 +1,4 @@
-# stdio_h.m4 serial 32
+# stdio_h.m4 serial 33
 dnl Copyright (C) 2007-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -8,7 +8,6 @@
 [
   AC_REQUIRE([gl_STDIO_H_DEFAULTS])
   AC_REQUIRE([AC_C_INLINE])
-  AC_REQUIRE([gl_ASM_SYMBOL_PREFIX])
   gl_NEXT_HEADERS([stdio.h])
   dnl No need to create extra modules for these functions. Everyone who uses
   dnl <stdio.h> likely needs them.
@@ -139,23 +138,3 @@
   REPLACE_VSNPRINTF=0;           AC_SUBST([REPLACE_VSNPRINTF])
   REPLACE_VSPRINTF=0;            AC_SUBST([REPLACE_VSPRINTF])
 ])
-
-dnl Code shared by fseeko and ftello.  Determine if large files are supported,
-dnl but stdin does not start as a large file by default.
-AC_DEFUN([gl_STDIN_LARGE_OFFSET],
-  [
-    AC_CACHE_CHECK([whether stdin defaults to large file offsets],
-      [gl_cv_var_stdin_large_offset],
-      [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]],
-[[#if defined __SL64 && defined __SCLE /* cygwin */
-  /* Cygwin 1.5.24 and earlier fail to put stdin in 64-bit mode, making
-     fseeko/ftello needlessly fail.  This bug was fixed in 1.5.25, and
-     it is easier to do a version check than building a runtime test.  */
-# include <cygwin/version.h>
-# if CYGWIN_VERSION_DLL_COMBINED < CYGWIN_VERSION_DLL_MAKE_COMBINED (1005, 25)
-  choke me
-# endif
-#endif]])],
-        [gl_cv_var_stdin_large_offset=yes],
-        [gl_cv_var_stdin_large_offset=no])])
-])
--- a/m4/stdlib_h.m4
+++ b/m4/stdlib_h.m4
@@ -1,4 +1,4 @@
-# stdlib_h.m4 serial 34
+# stdlib_h.m4 serial 37
 dnl Copyright (C) 2007-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -8,20 +8,6 @@
 [
   AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
   gl_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>
-      #if HAVE_RANDOM_H
-      # include <random.h>
-      #endif
-    ]])
 
   dnl Check for declarations of anything we want to poison if the
   dnl corresponding gnulib module is not in use, and which is not
@@ -58,6 +44,7 @@
   GNULIB_GETSUBOPT=0;     AC_SUBST([GNULIB_GETSUBOPT])
   GNULIB_GRANTPT=0;       AC_SUBST([GNULIB_GRANTPT])
   GNULIB_MALLOC_POSIX=0;  AC_SUBST([GNULIB_MALLOC_POSIX])
+  GNULIB_MBTOWC=0;        AC_SUBST([GNULIB_MBTOWC])
   GNULIB_MKDTEMP=0;       AC_SUBST([GNULIB_MKDTEMP])
   GNULIB_MKOSTEMP=0;      AC_SUBST([GNULIB_MKOSTEMP])
   GNULIB_MKOSTEMPS=0;     AC_SUBST([GNULIB_MKOSTEMPS])
@@ -76,6 +63,7 @@
   GNULIB_SYSTEM_POSIX=0;  AC_SUBST([GNULIB_SYSTEM_POSIX])
   GNULIB_UNLOCKPT=0;      AC_SUBST([GNULIB_UNLOCKPT])
   GNULIB_UNSETENV=0;      AC_SUBST([GNULIB_UNSETENV])
+  GNULIB_WCTOMB=0;        AC_SUBST([GNULIB_WCTOMB])
   dnl Assume proper GNU behavior unless another module says otherwise.
   HAVE__EXIT=1;              AC_SUBST([HAVE__EXIT])
   HAVE_ATOLL=1;              AC_SUBST([HAVE_ATOLL])
@@ -89,6 +77,7 @@
   HAVE_MKSTEMP=1;            AC_SUBST([HAVE_MKSTEMP])
   HAVE_MKSTEMPS=1;           AC_SUBST([HAVE_MKSTEMPS])
   HAVE_PTSNAME=1;            AC_SUBST([HAVE_PTSNAME])
+  HAVE_RANDOM_H=1;           AC_SUBST([HAVE_RANDOM_H])
   HAVE_RANDOM_R=1;           AC_SUBST([HAVE_RANDOM_R])
   HAVE_REALPATH=1;           AC_SUBST([HAVE_REALPATH])
   HAVE_RPMATCH=1;            AC_SUBST([HAVE_RPMATCH])
@@ -104,6 +93,7 @@
   REPLACE_CALLOC=0;          AC_SUBST([REPLACE_CALLOC])
   REPLACE_CANONICALIZE_FILE_NAME=0;  AC_SUBST([REPLACE_CANONICALIZE_FILE_NAME])
   REPLACE_MALLOC=0;          AC_SUBST([REPLACE_MALLOC])
+  REPLACE_MBTOWC=0;          AC_SUBST([REPLACE_MBTOWC])
   REPLACE_MKSTEMP=0;         AC_SUBST([REPLACE_MKSTEMP])
   REPLACE_PUTENV=0;          AC_SUBST([REPLACE_PUTENV])
   REPLACE_REALLOC=0;         AC_SUBST([REPLACE_REALLOC])
@@ -111,4 +101,5 @@
   REPLACE_SETENV=0;          AC_SUBST([REPLACE_SETENV])
   REPLACE_STRTOD=0;          AC_SUBST([REPLACE_STRTOD])
   REPLACE_UNSETENV=0;        AC_SUBST([REPLACE_UNSETENV])
+  REPLACE_WCTOMB=0;          AC_SUBST([REPLACE_WCTOMB])
 ])
--- a/m4/strerror_r.m4
+++ b/m4/strerror_r.m4
@@ -24,7 +24,7 @@
   if test $ac_cv_func_strerror_r = yes; then
     if test -z "$ERRNO_H"; then
       dnl The POSIX prototype is:  int strerror_r (int, char *, size_t);
-      dnl glibc's prototype:       char *strerror_r (int, char *, size_t);
+      dnl glibc, Cygwin:           char *strerror_r (int, char *, size_t);
       dnl AIX 5.1, OSF/1 5.1:      int strerror_r (int, char *, int);
       AC_CACHE_CHECK([for strerror_r with POSIX signature],
         [gl_cv_func_strerror_r_posix_signature],
--- a/m4/sys_socket_h.m4
+++ b/m4/sys_socket_h.m4
@@ -1,4 +1,4 @@
-# sys_socket_h.m4 serial 21
+# sys_socket_h.m4 serial 22
 dnl Copyright (C) 2005-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -101,17 +101,13 @@
 AC_DEFUN([gl_PREREQ_SYS_H_SOCKET],
 [
   dnl Check prerequisites of the <sys/socket.h> replacement.
+  AC_REQUIRE([gl_CHECK_SOCKET_HEADERS])
   gl_CHECK_NEXT_HEADERS([sys/socket.h])
   if test $ac_cv_header_sys_socket_h = yes; then
     HAVE_SYS_SOCKET_H=1
     HAVE_WS2TCPIP_H=0
   else
     HAVE_SYS_SOCKET_H=0
-    dnl We cannot use AC_CHECK_HEADERS_ONCE here, because that would make
-    dnl the check for those headers unconditional; yet cygwin reports
-    dnl that the headers are present but cannot be compiled (since on
-    dnl cygwin, all socket information should come from sys/socket.h).
-    AC_CHECK_HEADERS([ws2tcpip.h])
     if test $ac_cv_header_ws2tcpip_h = yes; then
       HAVE_WS2TCPIP_H=1
     else
new file mode 100644
--- /dev/null
+++ b/m4/towctrans.m4
@@ -0,0 +1,14 @@
+# towctrans.m4 serial 1
+dnl Copyright (C) 2011 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_TOWCTRANS],
+[
+  AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
+  AC_REQUIRE([gl_WCTYPE_H])
+  if test $HAVE_WCTRANS_T = 0; then
+    AC_LIBOBJ([towctrans])
+  fi
+])
--- a/m4/unlink.m4
+++ b/m4/unlink.m4
@@ -1,4 +1,4 @@
-# unlink.m4 serial 6
+# unlink.m4 serial 7
 dnl Copyright (C) 2009-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -6,7 +6,6 @@
 
 AC_DEFUN([gl_FUNC_UNLINK],
 [
-  AC_REQUIRE([gl_AC_DOS])
   AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
   AC_REQUIRE([AC_CANONICAL_HOST])
   dnl Detect FreeBSD 7.2, AIX 7.1, Solaris 9 bug.
--- a/m4/valgrind-tests.m4
+++ b/m4/valgrind-tests.m4
@@ -1,4 +1,4 @@
-# valgrind-tests.m4 serial 1
+# valgrind-tests.m4 serial 2
 dnl Copyright (C) 2008-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -23,7 +23,7 @@
 
   if test -n "$VALGRIND" && $VALGRIND -q true > /dev/null 2>&1; then
     opt_valgrind_tests=yes
-    VALGRIND="$VALGRIND -q"
+    VALGRIND="$VALGRIND -q --error-exitcode=1 --leak-check=full"
   else
     opt_valgrind_tests=no
     VALGRIND=
--- a/m4/wchar_h.m4
+++ b/m4/wchar_h.m4
@@ -7,7 +7,7 @@
 
 dnl Written by Eric Blake.
 
-# wchar_h.m4 serial 37
+# wchar_h.m4 serial 38
 
 AC_DEFUN([gl_WCHAR_H],
 [
@@ -48,8 +48,13 @@
 # include <time.h>
 #endif
 #include <wchar.h>
-    ]], [btowc wctob mbsinit mbrtowc mbrlen mbsrtowcs mbsnrtowcs wcrtomb
-    wcsrtombs wcsnrtombs wcwidth])
+    ]],
+    [btowc wctob mbsinit mbrtowc mbrlen mbsrtowcs mbsnrtowcs wcrtomb
+     wcsrtombs wcsnrtombs wcwidth wmemchr wmemcmp wmemcpy wmemmove wmemset
+     wcslen wcsnlen wcscpy wcpcpy wcsncpy wcpncpy wcscat wcsncat wcscmp
+     wcsncmp wcscasecmp wcsncasecmp wcscoll wcsxfrm wcsdup wcschr wcsrchr
+     wcscspn wcsspn wcspbrk wcsstr wcstok wcswidth
+    ])
 ])
 
 dnl Check whether <wchar.h> is usable at all.
@@ -132,17 +137,45 @@
 
 AC_DEFUN([gl_WCHAR_H_DEFAULTS],
 [
-  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])
+  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])
+  GNULIB_WMEMCHR=0;     AC_SUBST([GNULIB_WMEMCHR])
+  GNULIB_WMEMCMP=0;     AC_SUBST([GNULIB_WMEMCMP])
+  GNULIB_WMEMCPY=0;     AC_SUBST([GNULIB_WMEMCPY])
+  GNULIB_WMEMMOVE=0;    AC_SUBST([GNULIB_WMEMMOVE])
+  GNULIB_WMEMSET=0;     AC_SUBST([GNULIB_WMEMSET])
+  GNULIB_WCSLEN=0;      AC_SUBST([GNULIB_WCSLEN])
+  GNULIB_WCSNLEN=0;     AC_SUBST([GNULIB_WCSNLEN])
+  GNULIB_WCSCPY=0;      AC_SUBST([GNULIB_WCSCPY])
+  GNULIB_WCPCPY=0;      AC_SUBST([GNULIB_WCPCPY])
+  GNULIB_WCSNCPY=0;     AC_SUBST([GNULIB_WCSNCPY])
+  GNULIB_WCPNCPY=0;     AC_SUBST([GNULIB_WCPNCPY])
+  GNULIB_WCSCAT=0;      AC_SUBST([GNULIB_WCSCAT])
+  GNULIB_WCSNCAT=0;     AC_SUBST([GNULIB_WCSNCAT])
+  GNULIB_WCSCMP=0;      AC_SUBST([GNULIB_WCSCMP])
+  GNULIB_WCSNCMP=0;     AC_SUBST([GNULIB_WCSNCMP])
+  GNULIB_WCSCASECMP=0;  AC_SUBST([GNULIB_WCSCASECMP])
+  GNULIB_WCSNCASECMP=0; AC_SUBST([GNULIB_WCSNCASECMP])
+  GNULIB_WCSCOLL=0;     AC_SUBST([GNULIB_WCSCOLL])
+  GNULIB_WCSXFRM=0;     AC_SUBST([GNULIB_WCSXFRM])
+  GNULIB_WCSDUP=0;      AC_SUBST([GNULIB_WCSDUP])
+  GNULIB_WCSCHR=0;      AC_SUBST([GNULIB_WCSCHR])
+  GNULIB_WCSRCHR=0;     AC_SUBST([GNULIB_WCSRCHR])
+  GNULIB_WCSCSPN=0;     AC_SUBST([GNULIB_WCSCSPN])
+  GNULIB_WCSSPN=0;      AC_SUBST([GNULIB_WCSSPN])
+  GNULIB_WCSPBRK=0;     AC_SUBST([GNULIB_WCSPBRK])
+  GNULIB_WCSSTR=0;      AC_SUBST([GNULIB_WCSSTR])
+  GNULIB_WCSTOK=0;      AC_SUBST([GNULIB_WCSTOK])
+  GNULIB_WCSWIDTH=0;    AC_SUBST([GNULIB_WCSWIDTH])
   dnl Assume proper GNU behavior unless another module says otherwise.
   HAVE_BTOWC=1;         AC_SUBST([HAVE_BTOWC])
   HAVE_MBSINIT=1;       AC_SUBST([HAVE_MBSINIT])
@@ -153,6 +186,34 @@
   HAVE_WCRTOMB=1;       AC_SUBST([HAVE_WCRTOMB])
   HAVE_WCSRTOMBS=1;     AC_SUBST([HAVE_WCSRTOMBS])
   HAVE_WCSNRTOMBS=1;    AC_SUBST([HAVE_WCSNRTOMBS])
+  HAVE_WMEMCHR=1;       AC_SUBST([HAVE_WMEMCHR])
+  HAVE_WMEMCMP=1;       AC_SUBST([HAVE_WMEMCMP])
+  HAVE_WMEMCPY=1;       AC_SUBST([HAVE_WMEMCPY])
+  HAVE_WMEMMOVE=1;      AC_SUBST([HAVE_WMEMMOVE])
+  HAVE_WMEMSET=1;       AC_SUBST([HAVE_WMEMSET])
+  HAVE_WCSLEN=1;        AC_SUBST([HAVE_WCSLEN])
+  HAVE_WCSNLEN=1;       AC_SUBST([HAVE_WCSNLEN])
+  HAVE_WCSCPY=1;        AC_SUBST([HAVE_WCSCPY])
+  HAVE_WCPCPY=1;        AC_SUBST([HAVE_WCPCPY])
+  HAVE_WCSNCPY=1;       AC_SUBST([HAVE_WCSNCPY])
+  HAVE_WCPNCPY=1;       AC_SUBST([HAVE_WCPNCPY])
+  HAVE_WCSCAT=1;        AC_SUBST([HAVE_WCSCAT])
+  HAVE_WCSNCAT=1;       AC_SUBST([HAVE_WCSNCAT])
+  HAVE_WCSCMP=1;        AC_SUBST([HAVE_WCSCMP])
+  HAVE_WCSNCMP=1;       AC_SUBST([HAVE_WCSNCMP])
+  HAVE_WCSCASECMP=1;    AC_SUBST([HAVE_WCSCASECMP])
+  HAVE_WCSNCASECMP=1;   AC_SUBST([HAVE_WCSNCASECMP])
+  HAVE_WCSCOLL=1;       AC_SUBST([HAVE_WCSCOLL])
+  HAVE_WCSXFRM=1;       AC_SUBST([HAVE_WCSXFRM])
+  HAVE_WCSDUP=1;        AC_SUBST([HAVE_WCSDUP])
+  HAVE_WCSCHR=1;        AC_SUBST([HAVE_WCSCHR])
+  HAVE_WCSRCHR=1;       AC_SUBST([HAVE_WCSRCHR])
+  HAVE_WCSCSPN=1;       AC_SUBST([HAVE_WCSCSPN])
+  HAVE_WCSSPN=1;        AC_SUBST([HAVE_WCSSPN])
+  HAVE_WCSPBRK=1;       AC_SUBST([HAVE_WCSPBRK])
+  HAVE_WCSSTR=1;        AC_SUBST([HAVE_WCSSTR])
+  HAVE_WCSTOK=1;        AC_SUBST([HAVE_WCSTOK])
+  HAVE_WCSWIDTH=1;      AC_SUBST([HAVE_WCSWIDTH])
   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])
@@ -167,4 +228,5 @@
   REPLACE_WCSRTOMBS=0;  AC_SUBST([REPLACE_WCSRTOMBS])
   REPLACE_WCSNRTOMBS=0; AC_SUBST([REPLACE_WCSNRTOMBS])
   REPLACE_WCWIDTH=0;    AC_SUBST([REPLACE_WCWIDTH])
+  REPLACE_WCSWIDTH=0;   AC_SUBST([REPLACE_WCSWIDTH])
 ])
new file mode 100644
--- /dev/null
+++ b/m4/wcpcpy.m4
@@ -0,0 +1,15 @@
+# wcpcpy.m4 serial 1
+dnl Copyright (C) 2011 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_WCPCPY],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+  AC_CHECK_FUNCS_ONCE([wcpcpy])
+  if test $ac_cv_func_wcpcpy = no; then
+    HAVE_WCPCPY=0
+    AC_LIBOBJ([wcpcpy])
+  fi
+])
new file mode 100644
--- /dev/null
+++ b/m4/wcpncpy.m4
@@ -0,0 +1,15 @@
+# wcpncpy.m4 serial 1
+dnl Copyright (C) 2011 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_WCPNCPY],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+  AC_CHECK_FUNCS_ONCE([wcpncpy])
+  if test $ac_cv_func_wcpncpy = no; then
+    HAVE_WCPNCPY=0
+    AC_LIBOBJ([wcpncpy])
+  fi
+])
new file mode 100644
--- /dev/null
+++ b/m4/wcscasecmp.m4
@@ -0,0 +1,15 @@
+# wcscasecmp.m4 serial 1
+dnl Copyright (C) 2011 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_WCSCASECMP],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+  AC_CHECK_FUNCS_ONCE([wcscasecmp])
+  if test $ac_cv_func_wcscasecmp = no; then
+    HAVE_WCSCASECMP=0
+    AC_LIBOBJ([wcscasecmp])
+  fi
+])
new file mode 100644
--- /dev/null
+++ b/m4/wcscat.m4
@@ -0,0 +1,15 @@
+# wcscat.m4 serial 1
+dnl Copyright (C) 2011 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_WCSCAT],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+  AC_CHECK_FUNCS_ONCE([wcscat])
+  if test $ac_cv_func_wcscat = no; then
+    HAVE_WCSCAT=0
+    AC_LIBOBJ([wcscat])
+  fi
+])
new file mode 100644
--- /dev/null
+++ b/m4/wcschr.m4
@@ -0,0 +1,15 @@
+# wcschr.m4 serial 1
+dnl Copyright (C) 2011 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_WCSCHR],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+  AC_CHECK_FUNCS_ONCE([wcschr])
+  if test $ac_cv_func_wcschr = no; then
+    HAVE_WCSCHR=0
+    AC_LIBOBJ([wcschr])
+  fi
+])
new file mode 100644
--- /dev/null
+++ b/m4/wcscmp.m4
@@ -0,0 +1,15 @@
+# wcscmp.m4 serial 1
+dnl Copyright (C) 2011 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_WCSCMP],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+  AC_CHECK_FUNCS_ONCE([wcscmp])
+  if test $ac_cv_func_wcscmp = no; then
+    HAVE_WCSCMP=0
+    AC_LIBOBJ([wcscmp])
+  fi
+])
new file mode 100644
--- /dev/null
+++ b/m4/wcscoll.m4
@@ -0,0 +1,15 @@
+# wcscoll.m4 serial 1
+dnl Copyright (C) 2011 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_WCSCOLL],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+  AC_CHECK_FUNCS_ONCE([wcscoll])
+  if test $ac_cv_func_wcscoll = no; then
+    HAVE_WCSCOLL=0
+    AC_LIBOBJ([wcscoll])
+  fi
+])
new file mode 100644
--- /dev/null
+++ b/m4/wcscpy.m4
@@ -0,0 +1,15 @@
+# wcscpy.m4 serial 1
+dnl Copyright (C) 2011 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_WCSCPY],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+  AC_CHECK_FUNCS_ONCE([wcscpy])
+  if test $ac_cv_func_wcscpy = no; then
+    HAVE_WCSCPY=0
+    AC_LIBOBJ([wcscpy])
+  fi
+])
new file mode 100644
--- /dev/null
+++ b/m4/wcscspn.m4
@@ -0,0 +1,15 @@
+# wcscspn.m4 serial 1
+dnl Copyright (C) 2011 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_WCSCSPN],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+  AC_CHECK_FUNCS_ONCE([wcscspn])
+  if test $ac_cv_func_wcscspn = no; then
+    HAVE_WCSCSPN=0
+    AC_LIBOBJ([wcscspn])
+  fi
+])
new file mode 100644
--- /dev/null
+++ b/m4/wcsdup.m4
@@ -0,0 +1,15 @@
+# wcsdup.m4 serial 1
+dnl Copyright (C) 2011 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_WCSDUP],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+  AC_CHECK_FUNCS_ONCE([wcsdup])
+  if test $ac_cv_func_wcsdup = no; then
+    HAVE_WCSDUP=0
+    AC_LIBOBJ([wcsdup])
+  fi
+])
new file mode 100644
--- /dev/null
+++ b/m4/wcslen.m4
@@ -0,0 +1,15 @@
+# wcslen.m4 serial 1
+dnl Copyright (C) 2011 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_WCSLEN],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+  AC_CHECK_FUNCS_ONCE([wcslen])
+  if test $ac_cv_func_wcslen = no; then
+    HAVE_WCSLEN=0
+    AC_LIBOBJ([wcslen])
+  fi
+])
new file mode 100644
--- /dev/null
+++ b/m4/wcsncasecmp.m4
@@ -0,0 +1,15 @@
+# wcsncasecmp.m4 serial 1
+dnl Copyright (C) 2011 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_WCSNCASECMP],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+  AC_CHECK_FUNCS_ONCE([wcsncasecmp])
+  if test $ac_cv_func_wcsncasecmp = no; then
+    HAVE_WCSNCASECMP=0
+    AC_LIBOBJ([wcsncasecmp])
+  fi
+])
new file mode 100644
--- /dev/null
+++ b/m4/wcsncat.m4
@@ -0,0 +1,15 @@
+# wcsncat.m4 serial 1
+dnl Copyright (C) 2011 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_WCSNCAT],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+  AC_CHECK_FUNCS_ONCE([wcsncat])
+  if test $ac_cv_func_wcsncat = no; then
+    HAVE_WCSNCAT=0
+    AC_LIBOBJ([wcsncat])
+  fi
+])
new file mode 100644
--- /dev/null
+++ b/m4/wcsncmp.m4
@@ -0,0 +1,15 @@
+# wcsncmp.m4 serial 1
+dnl Copyright (C) 2011 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_WCSNCMP],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+  AC_CHECK_FUNCS_ONCE([wcsncmp])
+  if test $ac_cv_func_wcsncmp = no; then
+    HAVE_WCSNCMP=0
+    AC_LIBOBJ([wcsncmp])
+  fi
+])
new file mode 100644
--- /dev/null
+++ b/m4/wcsncpy.m4
@@ -0,0 +1,15 @@
+# wcsncpy.m4 serial 1
+dnl Copyright (C) 2011 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_WCSNCPY],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+  AC_CHECK_FUNCS_ONCE([wcsncpy])
+  if test $ac_cv_func_wcsncpy = no; then
+    HAVE_WCSNCPY=0
+    AC_LIBOBJ([wcsncpy])
+  fi
+])
new file mode 100644
--- /dev/null
+++ b/m4/wcsnlen.m4
@@ -0,0 +1,15 @@
+# wcsnlen.m4 serial 1
+dnl Copyright (C) 2011 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_WCSNLEN],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+  AC_CHECK_FUNCS_ONCE([wcsnlen])
+  if test $ac_cv_func_wcsnlen = no; then
+    HAVE_WCSNLEN=0
+    AC_LIBOBJ([wcsnlen])
+  fi
+])
new file mode 100644
--- /dev/null
+++ b/m4/wcspbrk.m4
@@ -0,0 +1,15 @@
+# wcspbrk.m4 serial 1
+dnl Copyright (C) 2011 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_WCSPBRK],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+  AC_CHECK_FUNCS_ONCE([wcspbrk])
+  if test $ac_cv_func_wcspbrk = no; then
+    HAVE_WCSPBRK=0
+    AC_LIBOBJ([wcspbrk])
+  fi
+])
new file mode 100644
--- /dev/null
+++ b/m4/wcsrchr.m4
@@ -0,0 +1,15 @@
+# wcsrchr.m4 serial 1
+dnl Copyright (C) 2011 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_WCSRCHR],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+  AC_CHECK_FUNCS_ONCE([wcsrchr])
+  if test $ac_cv_func_wcsrchr = no; then
+    HAVE_WCSRCHR=0
+    AC_LIBOBJ([wcsrchr])
+  fi
+])
--- a/m4/wcsrtombs.m4
+++ b/m4/wcsrtombs.m4
@@ -1,4 +1,4 @@
-# wcsrtombs.m4 serial 7
+# wcsrtombs.m4 serial 8
 dnl Copyright (C) 2008-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -123,10 +123,10 @@
       dnl is present.
 changequote(,)dnl
       case "$host_os" in
-                      # Guess no on HP-UX and OSF/1.
-        hpux* | osf*) gl_cv_func_wcsrtombs_null="guessing no" ;;
-                      # Guess yes otherwise.
-        *)            gl_cv_func_wcsrtombs_null="guessing yes" ;;
+                               # Guess no on HP-UX, OSF/1, mingw.
+        hpux* | osf* | mingw*) gl_cv_func_wcsrtombs_null="guessing no" ;;
+                               # Guess yes otherwise.
+        *)                     gl_cv_func_wcsrtombs_null="guessing yes" ;;
       esac
 changequote([,])dnl
       if test $LOCALE_FR != none; then
@@ -144,6 +144,7 @@
 #include <wchar.h>
 int main ()
 {
+  int result = 0;
   if (setlocale (LC_ALL, "$LOCALE_FR") != NULL)
     {
       const char original[] = "B\374\337er";
@@ -152,12 +153,14 @@
       if (mbstowcs (input, original, 10) == 5)
         {
           const wchar_t *src = input;
-          wcsrtombs (NULL, &src, 10, NULL);
+          size_t ret = wcsrtombs (NULL, &src, 3, NULL);
+          if (ret != 5)
+            result |= 1;
           if (src != input)
-            return 1;
+            result |= 2;
         }
     }
-  return 0;
+  return result;
 }]])],
           [gl_cv_func_wcsrtombs_null=yes],
           [gl_cv_func_wcsrtombs_null=no],
new file mode 100644
--- /dev/null
+++ b/m4/wcsspn.m4
@@ -0,0 +1,15 @@
+# wcsspn.m4 serial 1
+dnl Copyright (C) 2011 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_WCSSPN],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+  AC_CHECK_FUNCS_ONCE([wcsspn])
+  if test $ac_cv_func_wcsspn = no; then
+    HAVE_WCSSPN=0
+    AC_LIBOBJ([wcsspn])
+  fi
+])
new file mode 100644
--- /dev/null
+++ b/m4/wcsstr.m4
@@ -0,0 +1,15 @@
+# wcsstr.m4 serial 1
+dnl Copyright (C) 2011 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_WCSSTR],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+  AC_CHECK_FUNCS_ONCE([wcsstr])
+  if test $ac_cv_func_wcsstr = no; then
+    HAVE_WCSSTR=0
+    AC_LIBOBJ([wcsstr])
+  fi
+])
new file mode 100644
--- /dev/null
+++ b/m4/wcstok.m4
@@ -0,0 +1,15 @@
+# wcstok.m4 serial 1
+dnl Copyright (C) 2011 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_WCSTOK],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+  AC_CHECK_FUNCS_ONCE([wcstok])
+  if test $ac_cv_func_wcstok = no; then
+    HAVE_WCSTOK=0
+    AC_LIBOBJ([wcstok])
+  fi
+])
new file mode 100644
--- /dev/null
+++ b/m4/wcswidth.m4
@@ -0,0 +1,24 @@
+# wcswidth.m4 serial 1
+dnl Copyright (C) 2011 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_WCSWIDTH],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+  AC_REQUIRE([gl_FUNC_WCWIDTH])
+  AC_CHECK_FUNCS_ONCE([wcswidth])
+  if test $ac_cv_func_wcswidth = no; then
+    HAVE_WCSWIDTH=0
+  else
+    if test $REPLACE_WCWIDTH = 1; then
+      dnl If wcwidth needed to be replaced, wcswidth needs to be replaced
+      dnl as well.
+      REPLACE_WCSWIDTH=1
+    fi
+  fi
+  if test $HAVE_WCSWIDTH = 0 || test $REPLACE_WCSWIDTH = 1; then
+    AC_LIBOBJ([wcswidth])
+  fi
+])
new file mode 100644
--- /dev/null
+++ b/m4/wcsxfrm.m4
@@ -0,0 +1,15 @@
+# wcsxfrm.m4 serial 1
+dnl Copyright (C) 2011 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_WCSXFRM],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+  AC_CHECK_FUNCS_ONCE([wcsxfrm])
+  if test $ac_cv_func_wcsxfrm = no; then
+    HAVE_WCSXFRM=0
+    AC_LIBOBJ([wcsxfrm])
+  fi
+])
new file mode 100644
--- /dev/null
+++ b/m4/wctomb.m4
@@ -0,0 +1,23 @@
+# wctomb.m4 serial 1
+dnl Copyright (C) 2011 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_WCTOMB],
+[
+  AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
+
+  if false; then
+    REPLACE_WCTOMB=1
+  fi
+  if test $REPLACE_WCTOMB = 1; then
+    AC_LIBOBJ([wctomb])
+    gl_PREREQ_WCTOMB
+  fi
+])
+
+# Prerequisites of lib/wctomb.c.
+AC_DEFUN([gl_PREREQ_WCTOMB], [
+  :
+])
new file mode 100644
--- /dev/null
+++ b/m4/wctrans.m4
@@ -0,0 +1,14 @@
+# wctrans.m4 serial 1
+dnl Copyright (C) 2011 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_WCTRANS],
+[
+  AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
+  AC_REQUIRE([gl_WCTYPE_H])
+  if test $HAVE_WCTRANS_T = 0; then
+    AC_LIBOBJ([wctrans])
+  fi
+])
new file mode 100644
--- /dev/null
+++ b/m4/wctype.m4
@@ -0,0 +1,14 @@
+# wctype.m4 serial 1
+dnl Copyright (C) 2011 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_WCTYPE],
+[
+  AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
+  AC_REQUIRE([gl_WCTYPE_H])
+  if test $HAVE_WCTYPE_T = 0; then
+    AC_LIBOBJ([wctype])
+  fi
+])
--- a/m4/wctype_h.m4
+++ b/m4/wctype_h.m4
@@ -1,4 +1,4 @@
-# wctype_h.m4 serial 12
+# wctype_h.m4 serial 14
 
 dnl A placeholder for ISO C99 <wctype.h>, for platforms that lack it.
 
@@ -11,6 +11,7 @@
 
 AC_DEFUN([gl_WCTYPE_H],
 [
+  AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
   AC_REQUIRE([AC_PROG_CC])
   AC_REQUIRE([AC_CANONICAL_HOST])
   AC_CHECK_FUNCS_ONCE([iswcntrl])
@@ -20,21 +21,6 @@
     HAVE_ISWCNTRL=0
   fi
   AC_SUBST([HAVE_ISWCNTRL])
-  AC_CHECK_FUNCS_ONCE([iswblank])
-  AC_CHECK_DECLS_ONCE([iswblank])
-  if test $ac_cv_func_iswblank = yes; then
-    HAVE_ISWBLANK=1
-    REPLACE_ISWBLANK=0
-  else
-    HAVE_ISWBLANK=0
-    if test $ac_cv_have_decl_iswblank = yes; then
-      REPLACE_ISWBLANK=1
-    else
-      REPLACE_ISWBLANK=0
-    fi
-  fi
-  AC_SUBST([HAVE_ISWBLANK])
-  AC_SUBST([REPLACE_ISWBLANK])
 
   AC_REQUIRE([AC_C_INLINE])
 
@@ -91,10 +77,98 @@
   if test $HAVE_ISWCNTRL = 0 || test $REPLACE_ISWCNTRL = 1; then
     dnl Redefine all of iswcntrl, ..., towupper in <wctype.h>.
     :
-  else
-    if test $HAVE_ISWBLANK = 0 || test $REPLACE_ISWBLANK = 1; then
-      dnl Redefine only iswblank.
-      AC_LIBOBJ([iswblank])
-    fi
+  fi
+
+  dnl We assume that the wctype() and iswctype() functions exist if and only
+  dnl if the type wctype_t is defined in <wchar.h> or in <wctype.h> if that
+  dnl exists.
+  dnl HP-UX 11.00 declares all these in <wchar.h> and lacks <wctype.h>.
+  AC_CACHE_CHECK([for wctype_t], [gl_cv_type_wctype_t],
+    [AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[/* 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 HAVE_WCTYPE_H
+            # include <wctype.h>
+            #endif
+            wctype_t a;
+          ]],
+          [[]])],
+       [gl_cv_type_wctype_t=yes],
+       [gl_cv_type_wctype_t=no])
+    ])
+  if test $gl_cv_type_wctype_t = no; then
+    HAVE_WCTYPE_T=0
   fi
+
+  dnl We assume that the wctrans() and towctrans() functions exist if and only
+  dnl if the type wctrans_t is defined in <wctype.h>.
+  AC_CACHE_CHECK([for wctrans_t], [gl_cv_type_wctrans_t],
+    [AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[/* 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 <wctype.h>
+            wctrans_t a;
+          ]],
+          [[]])],
+       [gl_cv_type_wctrans_t=yes],
+       [gl_cv_type_wctrans_t=no])
+    ])
+  if test $gl_cv_type_wctrans_t = no; then
+    HAVE_WCTRANS_T=0
+  fi
+
+  dnl Check for declarations of anything we want to poison if the
+  dnl corresponding gnulib module is not in use.
+  gl_WARN_ON_USE_PREPARE([[
+/* 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>.  */
+#if !(defined __GLIBC__ && !defined __UCLIBC__)
+# include <stddef.h>
+# include <stdio.h>
+# include <time.h>
+# include <wchar.h>
+#endif
+#include <wctype.h>
+    ]],
+    [wctype iswctype wctrans towctrans
+    ])
 ])
+
+AC_DEFUN([gl_WCTYPE_MODULE_INDICATOR],
+[
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+  AC_REQUIRE([gl_WCTYPE_H_DEFAULTS])
+  gl_MODULE_INDICATOR_SET_VARIABLE([$1])
+  dnl Define it also as a C macro, for the benefit of the unit tests.
+  gl_MODULE_INDICATOR_FOR_TESTS([$1])
+])
+
+AC_DEFUN([gl_WCTYPE_H_DEFAULTS],
+[
+  GNULIB_ISWBLANK=0;    AC_SUBST([GNULIB_ISWBLANK])
+  GNULIB_WCTYPE=0;      AC_SUBST([GNULIB_WCTYPE])
+  GNULIB_ISWCTYPE=0;    AC_SUBST([GNULIB_ISWCTYPE])
+  GNULIB_WCTRANS=0;     AC_SUBST([GNULIB_WCTRANS])
+  GNULIB_TOWCTRANS=0;   AC_SUBST([GNULIB_TOWCTRANS])
+  dnl Assume proper GNU behavior unless another module says otherwise.
+  HAVE_ISWBLANK=1;      AC_SUBST([HAVE_ISWBLANK])
+  HAVE_WCTYPE_T=1;      AC_SUBST([HAVE_WCTYPE_T])
+  HAVE_WCTRANS_T=1;     AC_SUBST([HAVE_WCTRANS_T])
+  REPLACE_ISWBLANK=0;   AC_SUBST([REPLACE_ISWBLANK])
+])
new file mode 100644
--- /dev/null
+++ b/m4/wmemchr.m4
@@ -0,0 +1,15 @@
+# wmemchr.m4 serial 1
+dnl Copyright (C) 2011 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_WMEMCHR],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+  AC_CHECK_FUNCS_ONCE([wmemchr])
+  if test $ac_cv_func_wmemchr = no; then
+    HAVE_WMEMCHR=0
+    AC_LIBOBJ([wmemchr])
+  fi
+])
new file mode 100644
--- /dev/null
+++ b/m4/wmemcmp.m4
@@ -0,0 +1,15 @@
+# wmemcmp.m4 serial 1
+dnl Copyright (C) 2011 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_WMEMCMP],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+  AC_CHECK_FUNCS_ONCE([wmemcmp])
+  if test $ac_cv_func_wmemcmp = no; then
+    HAVE_WMEMCMP=0
+    AC_LIBOBJ([wmemcmp])
+  fi
+])
new file mode 100644
--- /dev/null
+++ b/m4/wmemcpy.m4
@@ -0,0 +1,15 @@
+# wmemcpy.m4 serial 1
+dnl Copyright (C) 2011 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_WMEMCPY],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+  AC_CHECK_FUNCS_ONCE([wmemcpy])
+  if test $ac_cv_func_wmemcpy = no; then
+    HAVE_WMEMCPY=0
+    AC_LIBOBJ([wmemcpy])
+  fi
+])
new file mode 100644
--- /dev/null
+++ b/m4/wmemmove.m4
@@ -0,0 +1,15 @@
+# wmemmove.m4 serial 1
+dnl Copyright (C) 2011 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_WMEMMOVE],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+  AC_CHECK_FUNCS_ONCE([wmemmove])
+  if test $ac_cv_func_wmemmove = no; then
+    HAVE_WMEMMOVE=0
+    AC_LIBOBJ([wmemmove])
+  fi
+])
new file mode 100644
--- /dev/null
+++ b/m4/wmemset.m4
@@ -0,0 +1,15 @@
+# wmemset.m4 serial 1
+dnl Copyright (C) 2011 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_WMEMSET],
+[
+  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
+  AC_CHECK_FUNCS_ONCE([wmemset])
+  if test $ac_cv_func_wmemset = no; then
+    HAVE_WMEMSET=0
+    AC_LIBOBJ([wmemset])
+  fi
+])
--- a/modules/array-mergesort
+++ b/modules/array-mergesort
@@ -14,7 +14,7 @@
 "array-mergesort.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
--- a/modules/backupfile
+++ b/modules/backupfile
@@ -5,7 +5,6 @@
 Files:
 lib/backupfile.h
 lib/backupfile.c
-m4/dos.m4
 m4/backupfile.m4
 
 Depends-on:
--- a/modules/btowc
+++ b/modules/btowc
@@ -8,6 +8,7 @@
 
 Depends-on:
 wchar
+mbtowc
 
 configure.ac:
 gl_FUNC_BTOWC
--- a/modules/btowc-tests
+++ b/modules/btowc-tests
@@ -8,6 +8,7 @@
 m4/codeset.m4
 
 Depends-on:
+setlocale
 
 configure.ac:
 gt_LOCALE_FR
--- a/modules/c-strcase-tests
+++ b/modules/c-strcase-tests
@@ -8,6 +8,7 @@
 m4/codeset.m4
 
 Depends-on:
+setlocale
 
 configure.ac:
 gt_LOCALE_FR
--- a/modules/c-strcaseeq
+++ b/modules/c-strcaseeq
@@ -16,7 +16,7 @@
 "c-strcaseeq.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
--- a/modules/c-strcasestr
+++ b/modules/c-strcasestr
@@ -22,7 +22,7 @@
 "c-strcasestr.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/di-set
@@ -0,0 +1,24 @@
+Description:
+manipulate sets of device-inode pairs efficiently
+
+Files:
+lib/di-set.c
+lib/di-set.h
+
+Depends-on:
+ino-map
+hash
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += di-set.c di-set.h
+
+Include:
+"di-set.h"
+
+License
+GPL
+
+Maintainer:
+Jim Meyering
new file mode 100644
--- /dev/null
+++ b/modules/di-set-tests
@@ -0,0 +1,11 @@
+Files:
+tests/test-di-set.c
+tests/macros.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-di-set
+check_PROGRAMS += test-di-set
--- a/modules/dirname-lgpl
+++ b/modules/dirname-lgpl
@@ -7,9 +7,9 @@
 lib/basename-lgpl.c
 lib/stripslash.c
 m4/dirname.m4
-m4/dos.m4
 
 Depends-on:
+dosname
 double-slash-root
 malloc-posix
 stdbool
new file mode 100644
--- /dev/null
+++ b/modules/dosname
@@ -0,0 +1,20 @@
+Description:
+Macros for porting to systems with DOS-style file names.
+
+Files:
+lib/dosname.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+
+Include:
+"dosname.h"
+
+License:
+LGPLv2+
+
+Maintainer:
+Eric Blake, Paul Eggert, Jim Meyering
--- a/modules/filenamecat
+++ b/modules/filenamecat
@@ -6,7 +6,6 @@
 m4/filenamecat.m4
 
 Depends-on:
-dirname-lgpl
 filenamecat-lgpl
 xalloc
 
--- a/modules/fnmatch
+++ b/modules/fnmatch
@@ -14,7 +14,7 @@
 alloca
 stdbool
 wchar
-wctype
+wctype-h
 memchr
 memcmp
 mbsrtowcs
--- a/modules/ftello
+++ b/modules/ftello
@@ -4,6 +4,7 @@
 Files:
 lib/ftello.c
 lib/stdio-impl.h
+m4/fseeko.m4
 m4/ftello.m4
 
 Depends-on:
--- a/modules/getloadavg
+++ b/modules/getloadavg
@@ -6,10 +6,7 @@
 m4/getloadavg.m4
 
 Depends-on:
-c-strtod
-cloexec
 extensions
-fcntl-safer
 intprops
 stdbool
 stdlib
@@ -23,6 +20,9 @@
 Include:
 <stdlib.h>
 
+Link:
+$(GETLOADAVG_LIBS)
+
 License:
 GPL
 
new file mode 100644
--- /dev/null
+++ b/modules/getloadavg-tests
@@ -0,0 +1,12 @@
+Files:
+tests/test-getloadavg.c
+tests/signature.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-getloadavg
+check_PROGRAMS += test-getloadavg
+test_getloadavg_LDADD = $(LDADD) @GETLOADAVG_LIBS@
--- a/modules/getopt-gnu
+++ b/modules/getopt-gnu
@@ -17,7 +17,7 @@
 <getopt.h>
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 all, glibc
--- a/modules/inet_ntop
+++ b/modules/inet_ntop
@@ -6,7 +6,6 @@
 m4/inet_ntop.m4
 
 Depends-on:
-socklen
 sys_socket
 arpa_inet
 errno
--- a/modules/inet_pton
+++ b/modules/inet_pton
@@ -7,7 +7,6 @@
 
 Depends-on:
 c-ctype
-socklen
 sys_socket
 arpa_inet
 errno
new file mode 100644
--- /dev/null
+++ b/modules/ino-map
@@ -0,0 +1,24 @@
+Description:
+maintain a mapping of ino_t numbers to small integers
+
+Files:
+lib/ino-map.c
+lib/ino-map.h
+
+Depends-on:
+hash
+verify
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += ino-map.c ino-map.h
+
+Include:
+"ino-map.h"
+
+License
+GPL
+
+Maintainer:
+Jim Meyering
new file mode 100644
--- /dev/null
+++ b/modules/ino-map-tests
@@ -0,0 +1,11 @@
+Files:
+tests/test-ino-map.c
+tests/macros.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-ino-map
+check_PROGRAMS += test-ino-map
new file mode 100644
--- /dev/null
+++ b/modules/iswblank
@@ -0,0 +1,25 @@
+Description:
+iswblank() function: test wide character for being blank.
+
+Files:
+lib/iswblank.c
+m4/iswblank.m4
+
+Depends-on:
+wctype-h
+extensions
+
+configure.ac:
+gl_FUNC_ISWBLANK
+gl_WCTYPE_MODULE_INDICATOR([iswblank])
+
+Makefile.am:
+
+Include:
+<wctype.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/iswblank-tests
@@ -0,0 +1,12 @@
+Files:
+tests/test-iswblank.c
+tests/macros.h
+
+Depends-on:
+wctype-h-c++-tests
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-iswblank
+check_PROGRAMS += test-iswblank
new file mode 100644
--- /dev/null
+++ b/modules/iswctype
@@ -0,0 +1,31 @@
+Description:
+iswctype() function: test whether a wide character has a given property.
+
+Status:
+obsolete
+
+Notice:
+This module is obsolete.
+
+Files:
+lib/iswctype.c
+lib/iswctype-impl.h
+m4/iswctype.m4
+
+Depends-on:
+wctype-h
+
+configure.ac:
+gl_FUNC_ISWCTYPE
+gl_WCTYPE_MODULE_INDICATOR([iswctype])
+
+Makefile.am:
+
+Include:
+<wctype.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
--- a/modules/lib-symbol-visibility
+++ b/modules/lib-symbol-visibility
@@ -1,6 +1,10 @@
 Description:
 Control of symbols exported by shared libraries.
 
+Notice:
+The value of $(CFLAG_VISIBILITY) needs to be added to the CFLAGS for the
+compilation of all sources that make up the library.
+
 Files:
 m4/visibility.m4
 
--- a/modules/locale
+++ b/modules/locale
@@ -30,9 +30,11 @@
 	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
 	      -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
 	      -e 's|@''NEXT_LOCALE_H''@|$(NEXT_LOCALE_H)|g' \
+	      -e 's|@''GNULIB_SETLOCALE''@|$(GNULIB_SETLOCALE)|g' \
 	      -e 's|@''GNULIB_DUPLOCALE''@|$(GNULIB_DUPLOCALE)|g' \
 	      -e 's|@''HAVE_DUPLOCALE''@|$(HAVE_DUPLOCALE)|g' \
 	      -e 's|@''HAVE_XLOCALE_H''@|$(HAVE_XLOCALE_H)|g' \
+	      -e 's|@''REPLACE_SETLOCALE''@|$(REPLACE_SETLOCALE)|g' \
 	      -e 's|@''REPLACE_DUPLOCALE''@|$(REPLACE_DUPLOCALE)|g' \
 	      -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
 	      -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
--- a/modules/lstat
+++ b/modules/lstat
@@ -6,6 +6,7 @@
 m4/lstat.m4
 
 Depends-on:
+dosname
 stat
 sys_stat
 
--- a/modules/math
+++ b/modules/math
@@ -60,7 +60,8 @@
 	      -e 's|@''GNULIB_TRUNC''@|$(GNULIB_TRUNC)|g' \
 	      -e 's|@''GNULIB_TRUNCF''@|$(GNULIB_TRUNCF)|g' \
 	      -e 's|@''GNULIB_TRUNCL''@|$(GNULIB_TRUNCL)|g' \
-	      -e 's|@''HAVE_ACOSL''@|$(HAVE_ACOSL)|g' \
+	      < $(srcdir)/math.in.h | \
+	  sed -e 's|@''HAVE_ACOSL''@|$(HAVE_ACOSL)|g' \
 	      -e 's|@''HAVE_ASINL''@|$(HAVE_ASINL)|g' \
 	      -e 's|@''HAVE_ATANL''@|$(HAVE_ATANL)|g' \
 	      -e 's|@''HAVE_COSL''@|$(HAVE_COSL)|g' \
@@ -94,7 +95,8 @@
 	      -e 's|@''HAVE_DECL_TRUNC''@|$(HAVE_DECL_TRUNC)|g' \
 	      -e 's|@''HAVE_DECL_TRUNCF''@|$(HAVE_DECL_TRUNCF)|g' \
 	      -e 's|@''HAVE_DECL_TRUNCL''@|$(HAVE_DECL_TRUNCL)|g' \
-	      -e 's|@''REPLACE_CEIL''@|$(REPLACE_CEIL)|g' \
+	  | \
+	  sed -e 's|@''REPLACE_CEIL''@|$(REPLACE_CEIL)|g' \
 	      -e 's|@''REPLACE_CEILF''@|$(REPLACE_CEILF)|g' \
 	      -e 's|@''REPLACE_CEILL''@|$(REPLACE_CEILL)|g' \
 	      -e 's|@''REPLACE_FLOOR''@|$(REPLACE_FLOOR)|g' \
@@ -118,8 +120,7 @@
 	      -e 's|@''REPLACE_TRUNCL''@|$(REPLACE_TRUNCL)|g' \
 	      -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
 	      -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
-	      -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
-	      < $(srcdir)/math.in.h; \
+	      -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
 	} > $@-t && \
 	mv $@-t $@
 MOSTLYCLEANFILES += math.h math.h-t
--- a/modules/mbchar
+++ b/modules/mbchar
@@ -10,7 +10,8 @@
 extensions
 stdbool
 wchar
-wctype
+wctype-h
+iswblank
 wcwidth
 memcmp
 
--- a/modules/mbmemcasecmp-tests
+++ b/modules/mbmemcasecmp-tests
@@ -11,6 +11,7 @@
 
 Depends-on:
 stdbool
+setlocale
 
 configure.ac:
 gt_LOCALE_FR
--- a/modules/mbmemcasecoll
+++ b/modules/mbmemcasecoll
@@ -13,6 +13,7 @@
 wcrtomb
 memcmp2
 memcoll
+wchar
 
 configure.ac:
 
--- a/modules/mbmemcasecoll-tests
+++ b/modules/mbmemcasecoll-tests
@@ -11,6 +11,7 @@
 
 Depends-on:
 stdbool
+setlocale
 
 configure.ac:
 gt_LOCALE_FR
--- a/modules/mbrtowc-tests
+++ b/modules/mbrtowc-tests
@@ -4,6 +4,12 @@
 tests/test-mbrtowc3.sh
 tests/test-mbrtowc4.sh
 tests/test-mbrtowc.c
+tests/test-mbrtowc-w32-1.sh
+tests/test-mbrtowc-w32-2.sh
+tests/test-mbrtowc-w32-3.sh
+tests/test-mbrtowc-w32-4.sh
+tests/test-mbrtowc-w32-5.sh
+tests/test-mbrtowc-w32.c
 tests/signature.h
 tests/macros.h
 m4/locale-fr.m4
@@ -14,6 +20,7 @@
 Depends-on:
 mbsinit
 wctob
+setlocale
 
 configure.ac:
 gt_LOCALE_FR
@@ -22,11 +29,14 @@
 gt_LOCALE_ZH_CN
 
 Makefile.am:
-TESTS += test-mbrtowc1.sh test-mbrtowc2.sh test-mbrtowc3.sh test-mbrtowc4.sh
+TESTS += \
+  test-mbrtowc1.sh test-mbrtowc2.sh test-mbrtowc3.sh test-mbrtowc4.sh \
+  test-mbrtowc-w32-1.sh test-mbrtowc-w32-2.sh test-mbrtowc-w32-3.sh \
+  test-mbrtowc-w32-4.sh test-mbrtowc-w32-5.sh
 TESTS_ENVIRONMENT += \
   LOCALE_FR='@LOCALE_FR@' \
   LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \
   LOCALE_JA='@LOCALE_JA@' \
   LOCALE_ZH_CN='@LOCALE_ZH_CN@'
-check_PROGRAMS += test-mbrtowc
+check_PROGRAMS += test-mbrtowc test-mbrtowc-w32
 
--- a/modules/mbscasecmp-tests
+++ b/modules/mbscasecmp-tests
@@ -6,6 +6,7 @@
 m4/codeset.m4
 
 Depends-on:
+setlocale
 
 configure.ac:
 gt_LOCALE_TR_UTF8
--- a/modules/mbscasestr-tests
+++ b/modules/mbscasestr-tests
@@ -13,6 +13,7 @@
 m4/codeset.m4
 
 Depends-on:
+setlocale
 
 configure.ac:
 gt_LOCALE_FR_UTF8
--- a/modules/mbschr-tests
+++ b/modules/mbschr-tests
@@ -6,6 +6,7 @@
 m4/codeset.m4
 
 Depends-on:
+setlocale
 
 configure.ac:
 gt_LOCALE_ZH_CN
--- a/modules/mbscspn-tests
+++ b/modules/mbscspn-tests
@@ -6,6 +6,7 @@
 m4/codeset.m4
 
 Depends-on:
+setlocale
 
 configure.ac:
 gt_LOCALE_FR_UTF8
--- a/modules/mbsinit-tests
+++ b/modules/mbsinit-tests
@@ -8,6 +8,7 @@
 
 Depends-on:
 mbrtowc
+setlocale
 
 configure.ac:
 gt_LOCALE_FR_UTF8
--- a/modules/mbsncasecmp-tests
+++ b/modules/mbsncasecmp-tests
@@ -6,6 +6,7 @@
 m4/codeset.m4
 
 Depends-on:
+setlocale
 
 configure.ac:
 gt_LOCALE_TR_UTF8
--- a/modules/mbsnrtowcs
+++ b/modules/mbsnrtowcs
@@ -3,6 +3,7 @@
 
 Files:
 lib/mbsnrtowcs.c
+lib/mbsnrtowcs-impl.h
 lib/mbsrtowcs-state.c
 m4/mbsnrtowcs.m4
 m4/mbstate_t.m4
--- a/modules/mbsnrtowcs-tests
+++ b/modules/mbsnrtowcs-tests
@@ -15,6 +15,7 @@
 mbrtowc
 mbsinit
 wctob
+setlocale
 
 configure.ac:
 gt_LOCALE_FR
--- a/modules/mbspbrk-tests
+++ b/modules/mbspbrk-tests
@@ -6,6 +6,7 @@
 m4/codeset.m4
 
 Depends-on:
+setlocale
 
 configure.ac:
 gt_LOCALE_FR_UTF8
--- a/modules/mbspcasecmp-tests
+++ b/modules/mbspcasecmp-tests
@@ -6,6 +6,7 @@
 m4/codeset.m4
 
 Depends-on:
+setlocale
 
 configure.ac:
 gt_LOCALE_TR_UTF8
--- a/modules/mbsrchr-tests
+++ b/modules/mbsrchr-tests
@@ -6,6 +6,7 @@
 m4/codeset.m4
 
 Depends-on:
+setlocale
 
 configure.ac:
 gt_LOCALE_ZH_CN
--- a/modules/mbsrtowcs
+++ b/modules/mbsrtowcs
@@ -3,6 +3,7 @@
 
 Files:
 lib/mbsrtowcs.c
+lib/mbsrtowcs-impl.h
 lib/mbsrtowcs-state.c
 m4/mbsrtowcs.m4
 m4/mbstate_t.m4
--- a/modules/mbsrtowcs-tests
+++ b/modules/mbsrtowcs-tests
@@ -15,6 +15,7 @@
 mbrtowc
 mbsinit
 wctob
+setlocale
 
 configure.ac:
 gt_LOCALE_FR
--- a/modules/mbsspn-tests
+++ b/modules/mbsspn-tests
@@ -6,6 +6,7 @@
 m4/codeset.m4
 
 Depends-on:
+setlocale
 
 configure.ac:
 gt_LOCALE_FR_UTF8
--- a/modules/mbsstr-tests
+++ b/modules/mbsstr-tests
@@ -10,6 +10,7 @@
 m4/codeset.m4
 
 Depends-on:
+setlocale
 
 configure.ac:
 gt_LOCALE_FR_UTF8
--- a/modules/mbswidth
+++ b/modules/mbswidth
@@ -10,7 +10,7 @@
 
 Depends-on:
 wchar
-wctype
+wctype-h
 mbrtowc
 mbsinit
 wcwidth
new file mode 100644
--- /dev/null
+++ b/modules/mbtowc
@@ -0,0 +1,27 @@
+Description:
+mbtowc() function: convert multibyte character to wide character.
+
+Files:
+lib/mbtowc.c
+lib/mbtowc-impl.h
+m4/mbtowc.m4
+
+Depends-on:
+stdlib
+mbrtowc
+wchar
+
+configure.ac:
+gl_FUNC_MBTOWC
+gl_STDLIB_MODULE_INDICATOR([mbtowc])
+
+Makefile.am:
+
+Include:
+<stdlib.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+Bruno Haible
--- a/modules/netdb
+++ b/modules/netdb
@@ -10,7 +10,6 @@
 arg-nonnull
 warn-on-use
 sys_socket
-socklen
 
 configure.ac:
 gl_HEADER_NETDB
--- a/modules/nl_langinfo-tests
+++ b/modules/nl_langinfo-tests
@@ -7,6 +7,7 @@
 
 Depends-on:
 c-strcase
+setlocale
 
 configure.ac:
 gt_LOCALE_FR
new file mode 100644
--- /dev/null
+++ b/modules/nonblocking
@@ -0,0 +1,26 @@
+Description:
+Read, set or clear the non-blocking file descriptor flag.
+
+Files:
+lib/nonblocking.c
+lib/nonblocking.h
+
+Depends-on:
+fcntl-h
+ioctl
+stdbool
+sys_socket
+
+configure.ac:
+
+Makefile.am:
+lib_SOURCES += nonblocking.c
+
+Include:
+"nonblocking.h"
+
+License:
+LGPLv2+
+
+Maintainer:
+Bruno Haible, Eric Blake
new file mode 100644
--- /dev/null
+++ b/modules/nonblocking-tests
@@ -0,0 +1,15 @@
+Files:
+tests/test-nonblocking.c
+tests/macros.h
+
+Depends-on:
+close
+pipe-posix
+socket
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-nonblocking
+check_PROGRAMS += test-nonblocking
+test_nonblocking_LDADD = $(LDADD) @LIBSOCKET@
--- a/modules/openat
+++ b/modules/openat
@@ -16,7 +16,7 @@
 m4/mode_t.m4
 
 Depends-on:
-dirname-lgpl
+dosname
 errno
 extensions
 fchdir
--- a/modules/parse-duration
+++ b/modules/parse-duration
@@ -6,7 +6,6 @@
 lib/parse-duration.c
 
 Depends-on:
-xalloc
 
 configure.ac:
 AC_REQUIRE([AC_C_INLINE])
new file mode 100644
--- /dev/null
+++ b/modules/passfd
@@ -0,0 +1,32 @@
+Description:
+Pass file descriptors along Unix domain sockets
+
+Files:
+lib/passfd.h
+lib/passfd.c
+m4/afunix.m4
+m4/sockpfaf.m4
+
+Depends-on:
+cloexec
+sys_socket
+socketlib
+extensions
+
+configure.ac:
+gl_SOCKET_AFUNIX
+
+Makefile.am:
+lib_SOURCES += passfd.c
+
+Include:
+"passfd.h"
+
+Link:
+$(LIBSOCKET)
+
+License:
+LGPLv2+
+
+Maintainer:
+Bastien ROUCARIÈS
new file mode 100644
--- /dev/null
+++ b/modules/passfd-tests
@@ -0,0 +1,13 @@
+Files:
+tests/test-passfd.c
+tests/macros.h
+
+Depends-on:
+
+configure.ac:
+AC_CHECK_DECLS_ONCE([alarm])
+
+Makefile.am:
+TESTS += test-passfd
+check_PROGRAMS += test-passfd
+test_passfd_LDADD = $(LDADD) @LIBSOCKET@
--- a/modules/printf-posix
+++ b/modules/printf-posix
@@ -11,6 +11,7 @@
 lib/printf.c
 m4/printf-posix-rpl.m4
 m4/printf.m4
+m4/asm-underscore.m4
 
 Depends-on:
 stdio
--- a/modules/quotearg
+++ b/modules/quotearg
@@ -17,7 +17,7 @@
 quotearg-simple
 stdbool
 wchar
-wctype
+wctype-h
 xalloc
 
 configure.ac:
--- a/modules/quotearg-tests
+++ b/modules/quotearg-tests
@@ -17,6 +17,7 @@
 stdint
 setenv
 unsetenv
+setlocale
 
 configure.ac:
 gt_LOCALE_FR
--- a/modules/regex
+++ b/modules/regex
@@ -28,7 +28,7 @@
 ssize_t
 wchar
 wcrtomb
-wctype
+wctype-h
 
 configure.ac:
 gl_REGEX
--- a/modules/regex-quote
+++ b/modules/regex-quote
@@ -6,6 +6,7 @@
 lib/regex-quote.c
 
 Depends-on:
+stdbool
 xalloc
 mbuiter
 
--- a/modules/remove
+++ b/modules/remove
@@ -3,7 +3,6 @@
 
 Files:
 lib/remove.c
-m4/dos.m4
 m4/remove.m4
 
 Depends-on:
--- a/modules/rmdir
+++ b/modules/rmdir
@@ -3,10 +3,10 @@
 
 Files:
 lib/rmdir.c
-m4/dos.m4
 m4/rmdir.m4
 
 Depends-on:
+dosname
 sys_stat
 unistd
 
--- a/modules/savewd
+++ b/modules/savewd
@@ -7,7 +7,7 @@
 m4/savewd.m4
 
 Depends-on:
-dirname-lgpl
+dosname
 errno
 exit
 fchdir
new file mode 100644
--- /dev/null
+++ b/modules/setlocale
@@ -0,0 +1,25 @@
+Description:
+setlocale() function: set the current locale.
+
+Files:
+lib/setlocale.c
+m4/setlocale.m4
+
+Depends-on:
+locale
+localename
+
+configure.ac:
+gl_FUNC_SETLOCALE
+gl_LOCALE_MODULE_INDICATOR([setlocale])
+
+Makefile.am:
+
+Include:
+<locale.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/setlocale-tests
@@ -0,0 +1,29 @@
+Files:
+tests/test-setlocale1.sh
+tests/test-setlocale1.c
+tests/test-setlocale2.sh
+tests/test-setlocale2.c
+tests/signature.h
+tests/macros.h
+m4/locale-fr.m4
+m4/locale-ja.m4
+m4/locale-zh.m4
+m4/codeset.m4
+
+Depends-on:
+strdup
+
+configure.ac:
+gt_LOCALE_FR
+gt_LOCALE_FR_UTF8
+gt_LOCALE_JA
+gt_LOCALE_ZH_CN
+
+Makefile.am:
+TESTS += test-setlocale1.sh test-setlocale2.sh
+TESTS_ENVIRONMENT += \
+  LOCALE_FR='@LOCALE_FR@' \
+  LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \
+  LOCALE_JA='@LOCALE_JA@' \
+  LOCALE_ZH_CN='@LOCALE_ZH_CN@'
+check_PROGRAMS += test-setlocale1 test-setlocale2
--- a/modules/sigpipe
+++ b/modules/sigpipe
@@ -8,8 +8,11 @@
 
 Files:
 m4/sigpipe.m4
+lib/stdio-write.c
+m4/asm-underscore.m4
 
 Depends-on:
+raise
 signal
 sigprocmask
 stdio
@@ -24,6 +27,7 @@
 GNULIB_SIGNAL_H_SIGPIPE=1
 dnl Define the substituted variable GNULIB_STDIO_H_SIGPIPE to 1.
 AC_REQUIRE([gl_STDIO_H_DEFAULTS])
+AC_REQUIRE([gl_ASM_SYMBOL_PREFIX])
 GNULIB_STDIO_H_SIGPIPE=1
 dnl Define the substituted variable GNULIB_UNISTD_H_SIGPIPE to 1.
 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
--- a/modules/socklen
+++ b/modules/socklen
@@ -5,7 +5,6 @@
 m4/socklen.m4
 
 Depends-on:
-sys_socket
 
 configure.ac:
 gl_TYPE_SOCKLEN_T
@@ -13,8 +12,12 @@
 Makefile.am:
 
 Include:
-<sys/types.h>
-<sys/socket.h>
+#include <sys/types.h>
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#elif HAVE_WS2TCPIP_H
+# include <ws2tcpip.h>
+#endif
 
 License:
 unlimited
--- a/modules/stat
+++ b/modules/stat
@@ -3,10 +3,10 @@
 
 Files:
 lib/stat.c
-m4/dos.m4
 m4/stat.m4
 
 Depends-on:
+dosname
 stdbool
 sys_stat
 
--- a/modules/stdint
+++ b/modules/stdint
@@ -14,7 +14,6 @@
 Depends-on:
 include_next
 multiarch
-wchar
 
 configure.ac:
 gl_STDINT_H
@@ -39,6 +38,7 @@
 	      -e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \
 	      -e 's/@''HAVE_SYS_INTTYPES_H''@/$(HAVE_SYS_INTTYPES_H)/g' \
 	      -e 's/@''HAVE_SYS_BITYPES_H''@/$(HAVE_SYS_BITYPES_H)/g' \
+	      -e 's/@''HAVE_WCHAR_H''@/$(HAVE_WCHAR_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' \
--- a/modules/stdio
+++ b/modules/stdio
@@ -3,15 +3,12 @@
 
 Files:
 lib/stdio.in.h
-lib/stdio-write.c
 m4/stdio_h.m4
-m4/asm-underscore.m4
 
 Depends-on:
 include_next
 arg-nonnull
 c++defs
-raise
 stddef
 warn-on-use
 
--- a/modules/stdlib
+++ b/modules/stdlib
@@ -10,7 +10,6 @@
 c++defs
 include_next
 stddef
-stdint
 unistd
 warn-on-use
 
@@ -39,6 +38,7 @@
 	      -e 's|@''GNULIB_GETSUBOPT''@|$(GNULIB_GETSUBOPT)|g' \
 	      -e 's|@''GNULIB_GRANTPT''@|$(GNULIB_GRANTPT)|g' \
 	      -e 's|@''GNULIB_MALLOC_POSIX''@|$(GNULIB_MALLOC_POSIX)|g' \
+	      -e 's|@''GNULIB_MBTOWC''@|$(GNULIB_MBTOWC)|g' \
 	      -e 's|@''GNULIB_MKDTEMP''@|$(GNULIB_MKDTEMP)|g' \
 	      -e 's|@''GNULIB_MKOSTEMP''@|$(GNULIB_MKOSTEMP)|g' \
 	      -e 's|@''GNULIB_MKOSTEMPS''@|$(GNULIB_MKOSTEMPS)|g' \
@@ -57,7 +57,9 @@
 	      -e 's|@''GNULIB_SYSTEM_POSIX''@|$(GNULIB_SYSTEM_POSIX)|g' \
 	      -e 's|@''GNULIB_UNLOCKPT''@|$(GNULIB_UNLOCKPT)|g' \
 	      -e 's|@''GNULIB_UNSETENV''@|$(GNULIB_UNSETENV)|g' \
-	      -e 's|@''HAVE__EXIT''@|$(HAVE__EXIT)|g' \
+	      -e 's|@''GNULIB_WCTOMB''@|$(GNULIB_WCTOMB)|g' \
+	      < $(srcdir)/stdlib.in.h | \
+	  sed -e 's|@''HAVE__EXIT''@|$(HAVE__EXIT)|g' \
 	      -e 's|@''HAVE_ATOLL''@|$(HAVE_ATOLL)|g' \
 	      -e 's|@''HAVE_CANONICALIZE_FILE_NAME''@|$(HAVE_CANONICALIZE_FILE_NAME)|g' \
 	      -e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \
@@ -84,6 +86,7 @@
 	      -e 's|@''REPLACE_CALLOC''@|$(REPLACE_CALLOC)|g' \
 	      -e 's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \
 	      -e 's|@''REPLACE_MALLOC''@|$(REPLACE_MALLOC)|g' \
+	      -e 's|@''REPLACE_MBTOWC''@|$(REPLACE_MBTOWC)|g' \
 	      -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \
 	      -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \
 	      -e 's|@''REPLACE_REALLOC''@|$(REPLACE_REALLOC)|g' \
@@ -91,10 +94,10 @@
 	      -e 's|@''REPLACE_SETENV''@|$(REPLACE_SETENV)|g' \
 	      -e 's|@''REPLACE_STRTOD''@|$(REPLACE_STRTOD)|g' \
 	      -e 's|@''REPLACE_UNSETENV''@|$(REPLACE_UNSETENV)|g' \
+	      -e 's|@''REPLACE_WCTOMB''@|$(REPLACE_WCTOMB)|g' \
 	      -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
 	      -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
-	      -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
-	      < $(srcdir)/stdlib.in.h; \
+	      -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
 	} > $@-t && \
 	mv $@-t $@
 MOSTLYCLEANFILES += stdlib.h stdlib.h-t
new file mode 100644
--- /dev/null
+++ b/modules/strftime-tests
@@ -0,0 +1,12 @@
+Files:
+tests/test-strftime.c
+tests/macros.h
+
+Depends-on:
+strftime
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-strftime
+check_PROGRAMS += test-strftime
--- a/modules/striconveh
+++ b/modules/striconveh
@@ -39,7 +39,7 @@
 $(LTLIBICONV) when linking with libtool, $(LIBICONV) otherwise
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
--- a/modules/striconveha
+++ b/modules/striconveha
@@ -22,7 +22,7 @@
 "striconveha.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/towctrans
@@ -0,0 +1,25 @@
+Description:
+towctrans() function: convert a wide character using a case mapping.
+
+Files:
+lib/towctrans.c
+lib/towctrans-impl.h
+m4/towctrans.m4
+
+Depends-on:
+wctype-h
+
+configure.ac:
+gl_FUNC_TOWCTRANS
+gl_WCTYPE_MODULE_INDICATOR([towctrans])
+
+Makefile.am:
+
+Include:
+<wctype.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
--- a/modules/unicase/locale-language-tests
+++ b/modules/unicase/locale-language-tests
@@ -9,6 +9,7 @@
 m4/codeset.m4
 
 Depends-on:
+setlocale
 
 configure.ac:
 gt_LOCALE_FR
--- a/modules/unicase/ulc-casecmp-tests
+++ b/modules/unicase/ulc-casecmp-tests
@@ -9,6 +9,7 @@
 
 Depends-on:
 uninorm/nfd
+setlocale
 
 configure.ac:
 gt_LOCALE_FR
--- a/modules/unicase/ulc-casecoll-tests
+++ b/modules/unicase/ulc-casecoll-tests
@@ -9,6 +9,7 @@
 
 Depends-on:
 uninorm/nfc
+setlocale
 
 configure.ac:
 gt_LOCALE_FR
--- a/modules/uniconv/base
+++ b/modules/uniconv/base
@@ -29,7 +29,7 @@
 "uniconv.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
--- a/modules/uniconv/u8-conv-from-enc
+++ b/modules/uniconv/u8-conv-from-enc
@@ -23,7 +23,7 @@
 "uniconv.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
--- a/modules/uniconv/u8-strconv-from-enc
+++ b/modules/uniconv/u8-strconv-from-enc
@@ -22,7 +22,7 @@
 "uniconv.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
--- a/modules/uniconv/u8-strconv-from-locale
+++ b/modules/uniconv/u8-strconv-from-locale
@@ -21,7 +21,7 @@
 "uniconv.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
--- a/modules/unictype/base
+++ b/modules/unictype/base
@@ -27,7 +27,7 @@
 "unictype.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
--- a/modules/unictype/bidicategory-all
+++ b/modules/unictype/bidicategory-all
@@ -1,14 +1,16 @@
 Description:
-Complete API for Unicode character bidi categories.
+Unicode character bidi category functions.
+
+Status:
+obsolete
+
+Notice:
+This module is obsolete. Use the module 'unictype/bidiclass-all' instead.
 
 Files:
 
 Depends-on:
-unictype/base
-unictype/bidicategory-byname
-unictype/bidicategory-name
-unictype/bidicategory-of
-unictype/bidicategory-test
+unictype/bidiclass-all
 
 configure.ac:
 
@@ -22,4 +24,3 @@
 
 Maintainer:
 Bruno Haible
-
--- a/modules/unictype/bidicategory-byname
+++ b/modules/unictype/bidicategory-byname
@@ -1,19 +1,20 @@
 Description:
 Find a Unicode character bidi category, given its name.
 
+Status:
+obsolete
+
+Notice:
+This module is obsolete. Use the module 'unictype/bidiclass-byname' instead.
+
 Files:
-lib/unictype/bidi_byname.c
 
 Depends-on:
-unictype/base
+unictype/bidiclass-byname
 
 configure.ac:
-gl_LIBUNISTRING_MODULE([0.9], [unictype/bidicategory-byname])
 
 Makefile.am:
-if LIBUNISTRING_COMPILE_UNICTYPE_BIDICATEGORY_BYNAME
-lib_SOURCES += unictype/bidi_byname.c
-endif
 
 Include:
 "unictype.h"
@@ -23,4 +24,3 @@
 
 Maintainer:
 Bruno Haible
-
deleted file mode 100644
--- a/modules/unictype/bidicategory-byname-tests
+++ /dev/null
@@ -1,13 +0,0 @@
-Files:
-tests/unictype/test-bidi_byname.c
-tests/macros.h
-
-Depends-on:
-
-configure.ac:
-
-Makefile.am:
-TESTS += test-bidi_byname
-check_PROGRAMS += test-bidi_byname
-test_bidi_byname_SOURCES = unictype/test-bidi_byname.c
-test_bidi_byname_LDADD = $(LDADD) $(LIBUNISTRING)
--- a/modules/unictype/bidicategory-name
+++ b/modules/unictype/bidicategory-name
@@ -1,19 +1,20 @@
 Description:
 Name of Unicode character bidi category.
 
+Status:
+obsolete
+
+Notice:
+This module is obsolete. Use the module 'unictype/bidiclass-name' instead.
+
 Files:
-lib/unictype/bidi_name.c
 
 Depends-on:
-unictype/base
+unictype/bidiclass-name
 
 configure.ac:
-gl_LIBUNISTRING_MODULE([0.9], [unictype/bidicategory-name])
 
 Makefile.am:
-if LIBUNISTRING_COMPILE_UNICTYPE_BIDICATEGORY_NAME
-lib_SOURCES += unictype/bidi_name.c
-endif
 
 Include:
 "unictype.h"
@@ -23,4 +24,3 @@
 
 Maintainer:
 Bruno Haible
-
deleted file mode 100644
--- a/modules/unictype/bidicategory-name-tests
+++ /dev/null
@@ -1,13 +0,0 @@
-Files:
-tests/unictype/test-bidi_name.c
-tests/macros.h
-
-Depends-on:
-
-configure.ac:
-
-Makefile.am:
-TESTS += test-bidi_name
-check_PROGRAMS += test-bidi_name
-test_bidi_name_SOURCES = unictype/test-bidi_name.c
-test_bidi_name_LDADD = $(LDADD) $(LIBUNISTRING)
--- a/modules/unictype/bidicategory-of
+++ b/modules/unictype/bidicategory-of
@@ -1,20 +1,20 @@
 Description:
 Determine bidi category of a Unicode character.
 
+Status:
+obsolete
+
+Notice:
+This module is obsolete. Use the module 'unictype/bidiclass-of' instead.
+
 Files:
-lib/unictype/bidi_of.c
-lib/unictype/bidi_of.h
 
 Depends-on:
-unictype/base
+unictype/bidiclass-of
 
 configure.ac:
-gl_LIBUNISTRING_MODULE([0.9.4], [unictype/bidicategory-of])
 
 Makefile.am:
-if LIBUNISTRING_COMPILE_UNICTYPE_BIDICATEGORY_OF
-lib_SOURCES += unictype/bidi_of.c
-endif
 
 Include:
 "unictype.h"
@@ -24,4 +24,3 @@
 
 Maintainer:
 Bruno Haible
-
deleted file mode 100644
--- a/modules/unictype/bidicategory-of-tests
+++ /dev/null
@@ -1,13 +0,0 @@
-Files:
-tests/unictype/test-bidi_of.c
-tests/macros.h
-
-Depends-on:
-
-configure.ac:
-
-Makefile.am:
-TESTS += test-bidi_of
-check_PROGRAMS += test-bidi_of
-test_bidi_of_SOURCES = unictype/test-bidi_of.c
-test_bidi_of_LDADD = $(LDADD) $(LIBUNISTRING)
--- a/modules/unictype/bidicategory-test
+++ b/modules/unictype/bidicategory-test
@@ -1,20 +1,20 @@
 Description:
 Test whether a Unicode character belongs to a given bidi category.
 
+Status:
+obsolete
+
+Notice:
+This module is obsolete. Use the module 'unictype/bidiclass-test' instead.
+
 Files:
-lib/unictype/bidi_test.c
 
 Depends-on:
-unictype/base
-unictype/bidicategory-of
+unictype/bidiclass-test
 
 configure.ac:
-gl_LIBUNISTRING_MODULE([0.9.4], [unictype/bidicategory-test])
 
 Makefile.am:
-if LIBUNISTRING_COMPILE_UNICTYPE_BIDICATEGORY_TEST
-lib_SOURCES += unictype/bidi_test.c
-endif
 
 Include:
 "unictype.h"
@@ -24,4 +24,3 @@
 
 Maintainer:
 Bruno Haible
-
deleted file mode 100644
--- a/modules/unictype/bidicategory-test-tests
+++ /dev/null
@@ -1,14 +0,0 @@
-Files:
-tests/unictype/test-bidi_test.c
-tests/macros.h
-
-Depends-on:
-unictype/bidicategory-of
-
-configure.ac:
-
-Makefile.am:
-TESTS += test-bidi_test
-check_PROGRAMS += test-bidi_test
-test_bidi_test_SOURCES = unictype/test-bidi_test.c
-test_bidi_test_LDADD = $(LDADD) $(LIBUNISTRING)
new file mode 100644
--- /dev/null
+++ b/modules/unictype/bidiclass-all
@@ -0,0 +1,25 @@
+Description:
+Complete API for Unicode character bidi categories.
+
+Files:
+
+Depends-on:
+unictype/base
+unictype/bidiclass-byname
+unictype/bidiclass-longname
+unictype/bidiclass-name
+unictype/bidiclass-of
+unictype/bidiclass-test
+
+configure.ac:
+
+Makefile.am:
+
+Include:
+"unictype.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/unictype/bidiclass-byname
@@ -0,0 +1,35 @@
+Description:
+Find a Unicode character bidi class, given its name.
+
+Files:
+lib/unictype/bidi_byname.c
+lib/unictype/bidi_byname.gperf
+
+Depends-on:
+unictype/base
+gperf
+
+configure.ac:
+gl_LIBUNISTRING_MODULE([0.9.4], [unictype/bidiclass-byname])
+
+Makefile.am:
+if LIBUNISTRING_COMPILE_UNICTYPE_BIDICLASS_BYNAME
+lib_SOURCES += unictype/bidi_byname.c
+endif
+
+unictype/bidi_byname.h: unictype/bidi_byname.gperf
+	$(GPERF) -m 10 $(srcdir)/unictype/bidi_byname.gperf > $(srcdir)/unictype/bidi_byname.h-t
+	mv $(srcdir)/unictype/bidi_byname.h-t $(srcdir)/unictype/bidi_byname.h
+BUILT_SOURCES        += unictype/bidi_byname.h
+MOSTLYCLEANFILES     += unictype/bidi_byname.h-t
+MAINTAINERCLEANFILES += unictype/bidi_byname.h
+EXTRA_DIST           += unictype/bidi_byname.h
+
+Include:
+"unictype.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/unictype/bidiclass-byname-tests
@@ -0,0 +1,13 @@
+Files:
+tests/unictype/test-bidi_byname.c
+tests/macros.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-bidi_byname
+check_PROGRAMS += test-bidi_byname
+test_bidi_byname_SOURCES = unictype/test-bidi_byname.c
+test_bidi_byname_LDADD = $(LDADD) $(LIBUNISTRING)
new file mode 100644
--- /dev/null
+++ b/modules/unictype/bidiclass-longname
@@ -0,0 +1,25 @@
+Description:
+Name of Unicode character bidi class.
+
+Files:
+lib/unictype/bidi_longname.c
+
+Depends-on:
+unictype/base
+
+configure.ac:
+gl_LIBUNISTRING_MODULE([0.9.4], [unictype/bidiclass-longname])
+
+Makefile.am:
+if LIBUNISTRING_COMPILE_UNICTYPE_BIDICLASS_LONGNAME
+lib_SOURCES += unictype/bidi_longname.c
+endif
+
+Include:
+"unictype.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/unictype/bidiclass-longname-tests
@@ -0,0 +1,13 @@
+Files:
+tests/unictype/test-bidi_longname.c
+tests/macros.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-bidi_longname
+check_PROGRAMS += test-bidi_longname
+test_bidi_longname_SOURCES = unictype/test-bidi_longname.c
+test_bidi_longname_LDADD = $(LDADD) $(LIBUNISTRING)
new file mode 100644
--- /dev/null
+++ b/modules/unictype/bidiclass-name
@@ -0,0 +1,25 @@
+Description:
+Name of Unicode character bidi class.
+
+Files:
+lib/unictype/bidi_name.c
+
+Depends-on:
+unictype/base
+
+configure.ac:
+gl_LIBUNISTRING_MODULE([0.9.4], [unictype/bidiclass-name])
+
+Makefile.am:
+if LIBUNISTRING_COMPILE_UNICTYPE_BIDICLASS_NAME
+lib_SOURCES += unictype/bidi_name.c
+endif
+
+Include:
+"unictype.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/unictype/bidiclass-name-tests
@@ -0,0 +1,13 @@
+Files:
+tests/unictype/test-bidi_name.c
+tests/macros.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-bidi_name
+check_PROGRAMS += test-bidi_name
+test_bidi_name_SOURCES = unictype/test-bidi_name.c
+test_bidi_name_LDADD = $(LDADD) $(LIBUNISTRING)
new file mode 100644
--- /dev/null
+++ b/modules/unictype/bidiclass-of
@@ -0,0 +1,26 @@
+Description:
+Determine bidi class of a Unicode character.
+
+Files:
+lib/unictype/bidi_of.c
+lib/unictype/bidi_of.h
+
+Depends-on:
+unictype/base
+
+configure.ac:
+gl_LIBUNISTRING_MODULE([0.9.4], [unictype/bidiclass-of])
+
+Makefile.am:
+if LIBUNISTRING_COMPILE_UNICTYPE_BIDICLASS_OF
+lib_SOURCES += unictype/bidi_of.c
+endif
+
+Include:
+"unictype.h"
+
+License:
+LGPLv2+
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/unictype/bidiclass-of-tests
@@ -0,0 +1,13 @@
+Files:
+tests/unictype/test-bidi_of.c
+tests/macros.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-bidi_of
+check_PROGRAMS += test-bidi_of
+test_bidi_of_SOURCES = unictype/test-bidi_of.c
+test_bidi_of_LDADD = $(LDADD) $(LIBUNISTRING)
new file mode 100644
--- /dev/null
+++ b/modules/unictype/bidiclass-test
@@ -0,0 +1,26 @@
+Description:
+Test whether a Unicode character belongs to a given bidi class.
+
+Files:
+lib/unictype/bidi_test.c
+
+Depends-on:
+unictype/base
+unictype/bidiclass-of
+
+configure.ac:
+gl_LIBUNISTRING_MODULE([0.9.4], [unictype/bidiclass-test])
+
+Makefile.am:
+if LIBUNISTRING_COMPILE_UNICTYPE_BIDICLASS_TEST
+lib_SOURCES += unictype/bidi_test.c
+endif
+
+Include:
+"unictype.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/unictype/bidiclass-test-tests
@@ -0,0 +1,14 @@
+Files:
+tests/unictype/test-bidi_test.c
+tests/macros.h
+
+Depends-on:
+unictype/bidiclass-of
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-bidi_test
+check_PROGRAMS += test-bidi_test
+test_bidi_test_SOURCES = unictype/test-bidi_test.c
+test_bidi_test_LDADD = $(LDADD) $(LIBUNISTRING)
new file mode 100644
--- /dev/null
+++ b/modules/unictype/category-LC
@@ -0,0 +1,26 @@
+Description:
+Test whether a Unicode character is of general category LC.
+
+Files:
+lib/unictype/categ_LC.c
+lib/unictype/categ_LC.h
+
+Depends-on:
+unictype/base
+
+configure.ac:
+gl_LIBUNISTRING_MODULE([0.9.4], [unictype/category-LC])
+
+Makefile.am:
+if LIBUNISTRING_COMPILE_UNICTYPE_CATEGORY_LC
+lib_SOURCES += unictype/categ_LC.c
+endif
+
+Include:
+"unictype.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/unictype/category-LC-tests
@@ -0,0 +1,16 @@
+Files:
+tests/unictype/test-categ_LC.c
+tests/unictype/test-predicate-part1.h
+tests/unictype/test-predicate-part2.h
+tests/macros.h
+
+Depends-on:
+unictype/category-test
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-categ_LC
+check_PROGRAMS += test-categ_LC
+test_categ_LC_SOURCES = unictype/test-categ_LC.c
+test_categ_LC_LDADD = $(LDADD) $(LIBUNISTRING)
--- a/modules/unictype/category-M
+++ b/modules/unictype/category-M
@@ -20,7 +20,7 @@
 "unictype.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
--- a/modules/unictype/category-all
+++ b/modules/unictype/category-all
@@ -11,6 +11,7 @@
 unictype/category-Co
 unictype/category-Cs
 unictype/category-L
+unictype/category-LC
 unictype/category-Ll
 unictype/category-Lm
 unictype/category-Lo
@@ -44,6 +45,7 @@
 unictype/category-and
 unictype/category-and-not
 unictype/category-byname
+unictype/category-longname
 unictype/category-name
 unictype/category-of
 unictype/category-or
--- a/modules/unictype/category-byname
+++ b/modules/unictype/category-byname
@@ -3,6 +3,7 @@
 
 Files:
 lib/unictype/categ_byname.c
+lib/unictype/categ_byname.gperf
 
 Depends-on:
 unictype/base
@@ -13,6 +14,7 @@
 unictype/category-Co
 unictype/category-Cs
 unictype/category-L
+unictype/category-LC
 unictype/category-Ll
 unictype/category-Lm
 unictype/category-Lo
@@ -44,6 +46,7 @@
 unictype/category-Zp
 unictype/category-Zs
 unictype/category-none
+gperf
 
 configure.ac:
 gl_LIBUNISTRING_MODULE([0.9.4], [unictype/category-byname])
@@ -53,6 +56,14 @@
 lib_SOURCES += unictype/categ_byname.c
 endif
 
+unictype/categ_byname.h: unictype/categ_byname.gperf
+	$(GPERF) -m 10 $(srcdir)/unictype/categ_byname.gperf > $(srcdir)/unictype/categ_byname.h-t
+	mv $(srcdir)/unictype/categ_byname.h-t $(srcdir)/unictype/categ_byname.h
+BUILT_SOURCES        += unictype/categ_byname.h
+MOSTLYCLEANFILES     += unictype/categ_byname.h-t
+MAINTAINERCLEANFILES += unictype/categ_byname.h
+EXTRA_DIST           += unictype/categ_byname.h
+
 Include:
 "unictype.h"
 
new file mode 100644
--- /dev/null
+++ b/modules/unictype/category-longname
@@ -0,0 +1,25 @@
+Description:
+Name of Unicode character category.
+
+Files:
+lib/unictype/categ_longname.c
+
+Depends-on:
+unictype/base
+
+configure.ac:
+gl_LIBUNISTRING_MODULE([0.9.4], [unictype/category-longname])
+
+Makefile.am:
+if LIBUNISTRING_COMPILE_UNICTYPE_CATEGORY_LONGNAME
+lib_SOURCES += unictype/categ_longname.c
+endif
+
+Include:
+"unictype.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/unictype/category-longname-tests
@@ -0,0 +1,16 @@
+Files:
+tests/unictype/test-categ_longname.c
+tests/macros.h
+
+Depends-on:
+unictype/category-or
+unictype/category-Z
+unictype/category-Nl
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-categ_longname
+check_PROGRAMS += test-categ_longname
+test_categ_longname_SOURCES = unictype/test-categ_longname.c
+test_categ_longname_LDADD = $(LDADD) $(LIBUNISTRING)
--- a/modules/unictype/category-none
+++ b/modules/unictype/category-none
@@ -19,7 +19,7 @@
 "unictype.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
--- a/modules/unictype/category-of
+++ b/modules/unictype/category-of
@@ -22,7 +22,7 @@
 "unictype.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
--- a/modules/unictype/category-test
+++ b/modules/unictype/category-test
@@ -21,7 +21,7 @@
 "unictype.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
--- a/modules/unictype/category-test-withtable
+++ b/modules/unictype/category-test-withtable
@@ -15,7 +15,7 @@
 "unictype.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
--- a/modules/unictype/combining-class
+++ b/modules/unictype/combining-class
@@ -1,9 +1,9 @@
 Description:
-Determine combining class of a Unicode character.
+Determine canonical combining class of a Unicode character.
 
 Files:
-lib/unictype/combining.c
-lib/unictype/combining.h
+lib/unictype/combiningclass.c
+lib/unictype/combiningclass.h
 
 Depends-on:
 unictype/base
@@ -13,14 +13,14 @@
 
 Makefile.am:
 if LIBUNISTRING_COMPILE_UNICTYPE_COMBINING_CLASS
-lib_SOURCES += unictype/combining.c
+lib_SOURCES += unictype/combiningclass.c
 endif
 
 Include:
 "unictype.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/unictype/combining-class-all
@@ -0,0 +1,24 @@
+Description:
+Complete API for Unicode character canonical combining classes.
+
+Files:
+
+Depends-on:
+unictype/base
+unictype/combining-class
+unictype/combining-class-byname
+unictype/combining-class-longname
+unictype/combining-class-name
+
+configure.ac:
+
+Makefile.am:
+
+Include:
+"unictype.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/unictype/combining-class-byname
@@ -0,0 +1,35 @@
+Description:
+Find a Unicode character canonical combining class, given its name.
+
+Files:
+lib/unictype/combiningclass_byname.c
+lib/unictype/combiningclass_byname.gperf
+
+Depends-on:
+unictype/base
+gperf
+
+configure.ac:
+gl_LIBUNISTRING_MODULE([0.9.4], [unictype/combining-class-byname])
+
+Makefile.am:
+if LIBUNISTRING_COMPILE_UNICTYPE_COMBINING_CLASS_BYNAME
+lib_SOURCES += unictype/combiningclass_byname.c
+endif
+
+unictype/combiningclass_byname.h: unictype/combiningclass_byname.gperf
+	$(GPERF) -m 10 $(srcdir)/unictype/combiningclass_byname.gperf > $(srcdir)/unictype/combiningclass_byname.h-t
+	mv $(srcdir)/unictype/combiningclass_byname.h-t $(srcdir)/unictype/combiningclass_byname.h
+BUILT_SOURCES        += unictype/combiningclass_byname.h
+MOSTLYCLEANFILES     += unictype/combiningclass_byname.h-t
+MAINTAINERCLEANFILES += unictype/combiningclass_byname.h
+EXTRA_DIST           += unictype/combiningclass_byname.h
+
+Include:
+"unictype.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/unictype/combining-class-byname-tests
@@ -0,0 +1,13 @@
+Files:
+tests/unictype/test-combiningclass_byname.c
+tests/macros.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-combiningclass_byname
+check_PROGRAMS += test-combiningclass_byname
+test_combiningclass_byname_SOURCES = unictype/test-combiningclass_byname.c
+test_combiningclass_byname_LDADD = $(LDADD) $(LIBUNISTRING)
new file mode 100644
--- /dev/null
+++ b/modules/unictype/combining-class-longname
@@ -0,0 +1,25 @@
+Description:
+Name of Unicode character canonical combining class.
+
+Files:
+lib/unictype/combiningclass_longname.c
+
+Depends-on:
+unictype/base
+
+configure.ac:
+gl_LIBUNISTRING_MODULE([0.9.4], [unictype/combining-class-longname])
+
+Makefile.am:
+if LIBUNISTRING_COMPILE_UNICTYPE_COMBINING_CLASS_LONGNAME
+lib_SOURCES += unictype/combiningclass_longname.c
+endif
+
+Include:
+"unictype.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/unictype/combining-class-longname-tests
@@ -0,0 +1,13 @@
+Files:
+tests/unictype/test-combiningclass_longname.c
+tests/macros.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-combiningclass_longname
+check_PROGRAMS += test-combiningclass_longname
+test_combiningclass_longname_SOURCES = unictype/test-combiningclass_longname.c
+test_combiningclass_longname_LDADD = $(LDADD) $(LIBUNISTRING)
new file mode 100644
--- /dev/null
+++ b/modules/unictype/combining-class-name
@@ -0,0 +1,25 @@
+Description:
+Name of Unicode character canonical combining class.
+
+Files:
+lib/unictype/combiningclass_name.c
+
+Depends-on:
+unictype/base
+
+configure.ac:
+gl_LIBUNISTRING_MODULE([0.9.4], [unictype/combining-class-name])
+
+Makefile.am:
+if LIBUNISTRING_COMPILE_UNICTYPE_COMBINING_CLASS_NAME
+lib_SOURCES += unictype/combiningclass_name.c
+endif
+
+Include:
+"unictype.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/unictype/combining-class-name-tests
@@ -0,0 +1,13 @@
+Files:
+tests/unictype/test-combiningclass_name.c
+tests/macros.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-combiningclass_name
+check_PROGRAMS += test-combiningclass_name
+test_combiningclass_name_SOURCES = unictype/test-combiningclass_name.c
+test_combiningclass_name_LDADD = $(LDADD) $(LIBUNISTRING)
--- a/modules/unictype/combining-class-tests
+++ b/modules/unictype/combining-class-tests
@@ -1,5 +1,5 @@
 Files:
-tests/unictype/test-combining.c
+tests/unictype/test-combiningclass.c
 tests/macros.h
 
 Depends-on:
@@ -7,7 +7,7 @@
 configure.ac:
 
 Makefile.am:
-TESTS += test-combining
-check_PROGRAMS += test-combining
-test_combining_SOURCES = unictype/test-combining.c
-test_combining_LDADD = $(LDADD) $(LIBUNISTRING)
+TESTS += test-combiningclass
+check_PROGRAMS += test-combiningclass
+test_combiningclass_SOURCES = unictype/test-combiningclass.c
+test_combiningclass_LDADD = $(LDADD) $(LIBUNISTRING)
new file mode 100644
--- /dev/null
+++ b/modules/unictype/joininggroup-all
@@ -0,0 +1,23 @@
+Description:
+Complete API for Unicode character Arabic joining groups.
+
+Files:
+
+Depends-on:
+unictype/base
+unictype/joininggroup-byname
+unictype/joininggroup-name
+unictype/joininggroup-of
+
+configure.ac:
+
+Makefile.am:
+
+Include:
+"unictype.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/unictype/joininggroup-byname
@@ -0,0 +1,35 @@
+Description:
+Find a Unicode character Arabic joining group, given its name.
+
+Files:
+lib/unictype/joininggroup_byname.c
+lib/unictype/joininggroup_byname.gperf
+
+Depends-on:
+unictype/base
+gperf
+
+configure.ac:
+gl_LIBUNISTRING_MODULE([0.9.4], [unictype/joininggroup-byname])
+
+Makefile.am:
+if LIBUNISTRING_COMPILE_UNICTYPE_JOININGGROUP_BYNAME
+lib_SOURCES += unictype/joininggroup_byname.c
+endif
+
+unictype/joininggroup_byname.h: unictype/joininggroup_byname.gperf
+	$(GPERF) -m 10 $(srcdir)/unictype/joininggroup_byname.gperf > $(srcdir)/unictype/joininggroup_byname.h-t
+	mv $(srcdir)/unictype/joininggroup_byname.h-t $(srcdir)/unictype/joininggroup_byname.h
+BUILT_SOURCES        += unictype/joininggroup_byname.h
+MOSTLYCLEANFILES     += unictype/joininggroup_byname.h-t
+MAINTAINERCLEANFILES += unictype/joininggroup_byname.h
+EXTRA_DIST           += unictype/joininggroup_byname.h
+
+Include:
+"unictype.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/unictype/joininggroup-byname-tests
@@ -0,0 +1,13 @@
+Files:
+tests/unictype/test-joininggroup_byname.c
+tests/macros.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-joininggroup_byname
+check_PROGRAMS += test-joininggroup_byname
+test_joininggroup_byname_SOURCES = unictype/test-joininggroup_byname.c
+test_joininggroup_byname_LDADD = $(LDADD) $(LIBUNISTRING)
new file mode 100644
--- /dev/null
+++ b/modules/unictype/joininggroup-name
@@ -0,0 +1,26 @@
+Description:
+Name of Unicode character Arabic joining group.
+
+Files:
+lib/unictype/joininggroup_name.c
+lib/unictype/joininggroup_name.h
+
+Depends-on:
+unictype/base
+
+configure.ac:
+gl_LIBUNISTRING_MODULE([0.9.4], [unictype/joininggroup-name])
+
+Makefile.am:
+if LIBUNISTRING_COMPILE_UNICTYPE_JOININGGROUP_NAME
+lib_SOURCES += unictype/joininggroup_name.c
+endif
+
+Include:
+"unictype.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/unictype/joininggroup-name-tests
@@ -0,0 +1,13 @@
+Files:
+tests/unictype/test-joininggroup_name.c
+tests/macros.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-joininggroup_name
+check_PROGRAMS += test-joininggroup_name
+test_joininggroup_name_SOURCES = unictype/test-joininggroup_name.c
+test_joininggroup_name_LDADD = $(LDADD) $(LIBUNISTRING)
new file mode 100644
--- /dev/null
+++ b/modules/unictype/joininggroup-of
@@ -0,0 +1,26 @@
+Description:
+Determine Arabic joining group of a Unicode character.
+
+Files:
+lib/unictype/joininggroup_of.c
+lib/unictype/joininggroup_of.h
+
+Depends-on:
+unictype/base
+
+configure.ac:
+gl_LIBUNISTRING_MODULE([0.9.4], [unictype/joininggroup-of])
+
+Makefile.am:
+if LIBUNISTRING_COMPILE_UNICTYPE_JOININGGROUP_OF
+lib_SOURCES += unictype/joininggroup_of.c
+endif
+
+Include:
+"unictype.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/unictype/joininggroup-of-tests
@@ -0,0 +1,14 @@
+Files:
+tests/unictype/test-joininggroup_of.c
+tests/unictype/test-joininggroup_of.h
+tests/macros.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-joininggroup_of
+check_PROGRAMS += test-joininggroup_of
+test_joininggroup_of_SOURCES = unictype/test-joininggroup_of.c
+test_joininggroup_of_LDADD = $(LDADD) $(LIBUNISTRING)
new file mode 100644
--- /dev/null
+++ b/modules/unictype/joiningtype-all
@@ -0,0 +1,24 @@
+Description:
+Complete API for Unicode character Arabic joining types.
+
+Files:
+
+Depends-on:
+unictype/base
+unictype/joiningtype-byname
+unictype/joiningtype-longname
+unictype/joiningtype-name
+unictype/joiningtype-of
+
+configure.ac:
+
+Makefile.am:
+
+Include:
+"unictype.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/unictype/joiningtype-byname
@@ -0,0 +1,35 @@
+Description:
+Find a Unicode character Arabic joining type, given its name.
+
+Files:
+lib/unictype/joiningtype_byname.c
+lib/unictype/joiningtype_byname.gperf
+
+Depends-on:
+unictype/base
+gperf
+
+configure.ac:
+gl_LIBUNISTRING_MODULE([0.9.4], [unictype/joiningtype-byname])
+
+Makefile.am:
+if LIBUNISTRING_COMPILE_UNICTYPE_JOININGTYPE_BYNAME
+lib_SOURCES += unictype/joiningtype_byname.c
+endif
+
+unictype/joiningtype_byname.h: unictype/joiningtype_byname.gperf
+	$(GPERF) -m 10 $(srcdir)/unictype/joiningtype_byname.gperf > $(srcdir)/unictype/joiningtype_byname.h-t
+	mv $(srcdir)/unictype/joiningtype_byname.h-t $(srcdir)/unictype/joiningtype_byname.h
+BUILT_SOURCES        += unictype/joiningtype_byname.h
+MOSTLYCLEANFILES     += unictype/joiningtype_byname.h-t
+MAINTAINERCLEANFILES += unictype/joiningtype_byname.h
+EXTRA_DIST           += unictype/joiningtype_byname.h
+
+Include:
+"unictype.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/unictype/joiningtype-byname-tests
@@ -0,0 +1,13 @@
+Files:
+tests/unictype/test-joiningtype_byname.c
+tests/macros.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-joiningtype_byname
+check_PROGRAMS += test-joiningtype_byname
+test_joiningtype_byname_SOURCES = unictype/test-joiningtype_byname.c
+test_joiningtype_byname_LDADD = $(LDADD) $(LIBUNISTRING)
new file mode 100644
--- /dev/null
+++ b/modules/unictype/joiningtype-longname
@@ -0,0 +1,25 @@
+Description:
+Name of Unicode character Arabic joining type.
+
+Files:
+lib/unictype/joiningtype_longname.c
+
+Depends-on:
+unictype/base
+
+configure.ac:
+gl_LIBUNISTRING_MODULE([0.9.4], [unictype/joiningtype-longname])
+
+Makefile.am:
+if LIBUNISTRING_COMPILE_UNICTYPE_JOININGTYPE_LONGNAME
+lib_SOURCES += unictype/joiningtype_longname.c
+endif
+
+Include:
+"unictype.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/unictype/joiningtype-longname-tests
@@ -0,0 +1,13 @@
+Files:
+tests/unictype/test-joiningtype_longname.c
+tests/macros.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-joiningtype_longname
+check_PROGRAMS += test-joiningtype_longname
+test_joiningtype_longname_SOURCES = unictype/test-joiningtype_longname.c
+test_joiningtype_longname_LDADD = $(LDADD) $(LIBUNISTRING)
new file mode 100644
--- /dev/null
+++ b/modules/unictype/joiningtype-name
@@ -0,0 +1,25 @@
+Description:
+Name of Unicode character Arabic joining type.
+
+Files:
+lib/unictype/joiningtype_name.c
+
+Depends-on:
+unictype/base
+
+configure.ac:
+gl_LIBUNISTRING_MODULE([0.9.4], [unictype/joiningtype-name])
+
+Makefile.am:
+if LIBUNISTRING_COMPILE_UNICTYPE_JOININGTYPE_NAME
+lib_SOURCES += unictype/joiningtype_name.c
+endif
+
+Include:
+"unictype.h"
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/unictype/joiningtype-name-tests
@@ -0,0 +1,13 @@
+Files:
+tests/unictype/test-joiningtype_name.c
+tests/macros.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-joiningtype_name
+check_PROGRAMS += test-joiningtype_name
+test_joiningtype_name_SOURCES = unictype/test-joiningtype_name.c
+test_joiningtype_name_LDADD = $(LDADD) $(LIBUNISTRING)
new file mode 100644
--- /dev/null
+++ b/modules/unictype/joiningtype-of
@@ -0,0 +1,27 @@
+Description:
+Determine Arabic joining type of a Unicode character.
+
+Files:
+lib/unictype/joiningtype_of.c
+lib/unictype/joiningtype_of.h
+
+Depends-on:
+unictype/base
+unictype/category-test-withtable
+
+configure.ac:
+gl_LIBUNISTRING_MODULE([0.9.4], [unictype/joiningtype-of])
+
+Makefile.am:
+if LIBUNISTRING_COMPILE_UNICTYPE_JOININGTYPE_OF
+lib_SOURCES += unictype/joiningtype_of.c
+endif
+
+Include:
+"unictype.h"
+
+License:
+LGPLv2+
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/unictype/joiningtype-of-tests
@@ -0,0 +1,14 @@
+Files:
+tests/unictype/test-joiningtype_of.c
+tests/unictype/test-joiningtype_of.h
+tests/macros.h
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-joiningtype_of
+check_PROGRAMS += test-joiningtype_of
+test_joiningtype_of_SOURCES = unictype/test-joiningtype_of.c
+test_joiningtype_of_LDADD = $(LDADD) $(LIBUNISTRING)
--- a/modules/unictype/property-bidi-arabic-digit
+++ b/modules/unictype/property-bidi-arabic-digit
@@ -8,7 +8,7 @@
 
 Depends-on:
 unictype/base
-unictype/bidicategory-of
+unictype/bidiclass-of
 
 configure.ac:
 AC_REQUIRE([AC_C_INLINE])
--- a/modules/unictype/property-bidi-arabic-right-to-left
+++ b/modules/unictype/property-bidi-arabic-right-to-left
@@ -8,7 +8,7 @@
 
 Depends-on:
 unictype/base
-unictype/bidicategory-of
+unictype/bidiclass-of
 
 configure.ac:
 AC_REQUIRE([AC_C_INLINE])
--- a/modules/unictype/property-bidi-block-separator
+++ b/modules/unictype/property-bidi-block-separator
@@ -8,7 +8,7 @@
 
 Depends-on:
 unictype/base
-unictype/bidicategory-of
+unictype/bidiclass-of
 
 configure.ac:
 AC_REQUIRE([AC_C_INLINE])
--- a/modules/unictype/property-bidi-boundary-neutral
+++ b/modules/unictype/property-bidi-boundary-neutral
@@ -8,7 +8,7 @@
 
 Depends-on:
 unictype/base
-unictype/bidicategory-of
+unictype/bidiclass-of
 
 configure.ac:
 AC_REQUIRE([AC_C_INLINE])
--- a/modules/unictype/property-bidi-common-separator
+++ b/modules/unictype/property-bidi-common-separator
@@ -8,7 +8,7 @@
 
 Depends-on:
 unictype/base
-unictype/bidicategory-of
+unictype/bidiclass-of
 
 configure.ac:
 AC_REQUIRE([AC_C_INLINE])
--- a/modules/unictype/property-bidi-control
+++ b/modules/unictype/property-bidi-control
@@ -8,7 +8,7 @@
 
 Depends-on:
 unictype/base
-unictype/bidicategory-of
+unictype/bidiclass-of
 
 configure.ac:
 AC_REQUIRE([AC_C_INLINE])
--- a/modules/unictype/property-bidi-embedding-or-override
+++ b/modules/unictype/property-bidi-embedding-or-override
@@ -8,7 +8,7 @@
 
 Depends-on:
 unictype/base
-unictype/bidicategory-of
+unictype/bidiclass-of
 
 configure.ac:
 AC_REQUIRE([AC_C_INLINE])
--- a/modules/unictype/property-bidi-eur-num-separator
+++ b/modules/unictype/property-bidi-eur-num-separator
@@ -8,7 +8,7 @@
 
 Depends-on:
 unictype/base
-unictype/bidicategory-of
+unictype/bidiclass-of
 
 configure.ac:
 AC_REQUIRE([AC_C_INLINE])
--- a/modules/unictype/property-bidi-eur-num-terminator
+++ b/modules/unictype/property-bidi-eur-num-terminator
@@ -8,7 +8,7 @@
 
 Depends-on:
 unictype/base
-unictype/bidicategory-of
+unictype/bidiclass-of
 
 configure.ac:
 AC_REQUIRE([AC_C_INLINE])
--- a/modules/unictype/property-bidi-european-digit
+++ b/modules/unictype/property-bidi-european-digit
@@ -8,7 +8,7 @@
 
 Depends-on:
 unictype/base
-unictype/bidicategory-of
+unictype/bidiclass-of
 
 configure.ac:
 AC_REQUIRE([AC_C_INLINE])
--- a/modules/unictype/property-bidi-hebrew-right-to-left
+++ b/modules/unictype/property-bidi-hebrew-right-to-left
@@ -8,7 +8,7 @@
 
 Depends-on:
 unictype/base
-unictype/bidicategory-of
+unictype/bidiclass-of
 
 configure.ac:
 AC_REQUIRE([AC_C_INLINE])
--- a/modules/unictype/property-bidi-left-to-right
+++ b/modules/unictype/property-bidi-left-to-right
@@ -8,7 +8,7 @@
 
 Depends-on:
 unictype/base
-unictype/bidicategory-of
+unictype/bidiclass-of
 
 configure.ac:
 AC_REQUIRE([AC_C_INLINE])
--- a/modules/unictype/property-bidi-non-spacing-mark
+++ b/modules/unictype/property-bidi-non-spacing-mark
@@ -8,7 +8,7 @@
 
 Depends-on:
 unictype/base
-unictype/bidicategory-of
+unictype/bidiclass-of
 
 configure.ac:
 AC_REQUIRE([AC_C_INLINE])
--- a/modules/unictype/property-bidi-other-neutral
+++ b/modules/unictype/property-bidi-other-neutral
@@ -8,7 +8,7 @@
 
 Depends-on:
 unictype/base
-unictype/bidicategory-of
+unictype/bidiclass-of
 
 configure.ac:
 AC_REQUIRE([AC_C_INLINE])
--- a/modules/unictype/property-bidi-pdf
+++ b/modules/unictype/property-bidi-pdf
@@ -8,7 +8,7 @@
 
 Depends-on:
 unictype/base
-unictype/bidicategory-of
+unictype/bidiclass-of
 
 configure.ac:
 AC_REQUIRE([AC_C_INLINE])
--- a/modules/unictype/property-bidi-segment-separator
+++ b/modules/unictype/property-bidi-segment-separator
@@ -8,7 +8,7 @@
 
 Depends-on:
 unictype/base
-unictype/bidicategory-of
+unictype/bidiclass-of
 
 configure.ac:
 AC_REQUIRE([AC_C_INLINE])
--- a/modules/unictype/property-bidi-whitespace
+++ b/modules/unictype/property-bidi-whitespace
@@ -8,7 +8,7 @@
 
 Depends-on:
 unictype/base
-unictype/bidicategory-of
+unictype/bidiclass-of
 
 configure.ac:
 AC_REQUIRE([AC_C_INLINE])
--- a/modules/unictype/scripts
+++ b/modules/unictype/scripts
@@ -30,7 +30,7 @@
 "unictype.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
--- a/modules/unigbrk/ulc-grapheme-breaks-tests
+++ b/modules/unigbrk/ulc-grapheme-breaks-tests
@@ -6,6 +6,7 @@
 m4/codeset.m4
 
 Depends-on:
+setlocale
 
 configure.ac:
 gt_LOCALE_AR
--- a/modules/uninorm/base
+++ b/modules/uninorm/base
@@ -26,7 +26,7 @@
 "uninorm.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
--- a/modules/uninorm/canonical-decomposition
+++ b/modules/uninorm/canonical-decomposition
@@ -20,7 +20,7 @@
 "uninorm.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
--- a/modules/uninorm/composition
+++ b/modules/uninorm/composition
@@ -29,7 +29,7 @@
 "uninorm.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
--- a/modules/uninorm/decompose-internal
+++ b/modules/uninorm/decompose-internal
@@ -18,7 +18,7 @@
 "uninorm/decompose-internal.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
--- a/modules/uninorm/decomposition-table
+++ b/modules/uninorm/decomposition-table
@@ -20,7 +20,7 @@
 "uninorm/decomposition-table.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
--- a/modules/uninorm/nfc
+++ b/modules/uninorm/nfc
@@ -23,7 +23,7 @@
 "uninorm.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
--- a/modules/uninorm/nfd
+++ b/modules/uninorm/nfd
@@ -21,7 +21,7 @@
 "uninorm.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
--- a/modules/uninorm/u32-normalize
+++ b/modules/uninorm/u32-normalize
@@ -27,7 +27,7 @@
 "uninorm.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
--- a/modules/unistd
+++ b/modules/unistd
@@ -109,7 +109,8 @@
 	      -e 's|@''HAVE_DECL_TTYNAME_R''@|$(HAVE_DECL_TTYNAME_R)|g' \
 	      -e 's|@''HAVE_OS_H''@|$(HAVE_OS_H)|g' \
 	      -e 's|@''HAVE_SYS_PARAM_H''@|$(HAVE_SYS_PARAM_H)|g' \
-	      -e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \
+	  | \
+	  sed -e 's|@''REPLACE_CHOWN''@|$(REPLACE_CHOWN)|g' \
 	      -e 's|@''REPLACE_CLOSE''@|$(REPLACE_CLOSE)|g' \
 	      -e 's|@''REPLACE_DUP''@|$(REPLACE_DUP)|g' \
 	      -e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \
--- a/modules/unistdio/u-printf-args
+++ b/modules/unistdio/u-printf-args
@@ -13,6 +13,7 @@
 
 Depends-on:
 unitypes
+wchar
 
 configure.ac:
 gl_PREREQ_PRINTF_ARGS
--- a/modules/unistdio/u16-vasnprintf-tests
+++ b/modules/unistdio/u16-vasnprintf-tests
@@ -15,6 +15,7 @@
 unistr/u16-cpy
 unistr/u16-strcmp
 unistr/u16-strlen
+setlocale
 
 configure.ac:
 gt_LOCALE_FR
--- a/modules/unistdio/u32-vasnprintf-tests
+++ b/modules/unistdio/u32-vasnprintf-tests
@@ -15,6 +15,7 @@
 unistr/u32-cpy
 unistr/u32-strcmp
 unistr/u32-strlen
+setlocale
 
 configure.ac:
 gt_LOCALE_FR
--- a/modules/unistdio/u8-vasnprintf-tests
+++ b/modules/unistdio/u8-vasnprintf-tests
@@ -15,6 +15,7 @@
 unistr/u8-cpy
 unistr/u8-strcmp
 unistr/u8-strlen
+setlocale
 
 configure.ac:
 gt_LOCALE_FR
--- a/modules/unistdio/ulc-vasnprintf-tests
+++ b/modules/unistdio/ulc-vasnprintf-tests
@@ -11,6 +11,7 @@
 m4/codeset.m4
 
 Depends-on:
+setlocale
 
 configure.ac:
 gt_LOCALE_FR
--- a/modules/unistr/base
+++ b/modules/unistr/base
@@ -29,7 +29,7 @@
 "unistr.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
--- a/modules/unistr/u32-cpy
+++ b/modules/unistr/u32-cpy
@@ -20,7 +20,7 @@
 "unistr.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
--- a/modules/unistr/u32-mbtouc-unsafe
+++ b/modules/unistr/u32-mbtouc-unsafe
@@ -20,7 +20,7 @@
 "unistr.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
--- a/modules/unistr/u32-to-u8
+++ b/modules/unistr/u32-to-u8
@@ -20,7 +20,7 @@
 "unistr.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
--- a/modules/unistr/u32-uctomb
+++ b/modules/unistr/u32-uctomb
@@ -20,7 +20,7 @@
 "unistr.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
--- a/modules/unistr/u8-check
+++ b/modules/unistr/u8-check
@@ -19,7 +19,7 @@
 "unistr.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
--- a/modules/unistr/u8-mblen
+++ b/modules/unistr/u8-mblen
@@ -19,7 +19,7 @@
 "unistr.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
--- a/modules/unistr/u8-mbtouc
+++ b/modules/unistr/u8-mbtouc
@@ -21,7 +21,7 @@
 "unistr.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
--- a/modules/unistr/u8-mbtouc-unsafe
+++ b/modules/unistr/u8-mbtouc-unsafe
@@ -21,7 +21,7 @@
 "unistr.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
--- a/modules/unistr/u8-mbtoucr
+++ b/modules/unistr/u8-mbtoucr
@@ -20,7 +20,7 @@
 "unistr.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
--- a/modules/unistr/u8-prev
+++ b/modules/unistr/u8-prev
@@ -19,7 +19,7 @@
 "unistr.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
--- a/modules/unistr/u8-strlen
+++ b/modules/unistr/u8-strlen
@@ -19,7 +19,7 @@
 "unistr.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
--- a/modules/unistr/u8-to-u32
+++ b/modules/unistr/u8-to-u32
@@ -20,7 +20,7 @@
 "unistr.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
--- a/modules/unistr/u8-uctomb
+++ b/modules/unistr/u8-uctomb
@@ -21,7 +21,7 @@
 "unistr.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
--- a/modules/unitypes
+++ b/modules/unitypes
@@ -29,7 +29,7 @@
 "unitypes.h"
 
 License:
-LGPL
+LGPLv2+
 
 Maintainer:
 Bruno Haible
--- a/modules/uniwbrk/ulc-wordbreaks-tests
+++ b/modules/uniwbrk/ulc-wordbreaks-tests
@@ -6,6 +6,7 @@
 m4/codeset.m4
 
 Depends-on:
+setlocale
 
 configure.ac:
 gt_LOCALE_FR
--- a/modules/unlink
+++ b/modules/unlink
@@ -3,10 +3,10 @@
 
 Files:
 lib/unlink.c
-m4/dos.m4
 m4/unlink.m4
 
 Depends-on:
+dosname
 lstat
 unistd
 
--- a/modules/vasnprintf
+++ b/modules/vasnprintf
@@ -27,6 +27,7 @@
 errno
 memchr
 verify
+wchar
 
 configure.ac:
 gl_FUNC_VASNPRINTF
--- a/modules/vasnprintf-posix-tests
+++ b/modules/vasnprintf-posix-tests
@@ -12,6 +12,7 @@
 Depends-on:
 stdint
 float
+setlocale
 
 configure.ac:
 gt_LOCALE_FR
--- a/modules/wchar
+++ b/modules/wchar
@@ -43,7 +43,36 @@
 	      -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|@''GNULIB_WMEMCHR''@|$(GNULIB_WMEMCHR)|g' \
+	      -e 's|@''GNULIB_WMEMCMP''@|$(GNULIB_WMEMCMP)|g' \
+	      -e 's|@''GNULIB_WMEMCPY''@|$(GNULIB_WMEMCPY)|g' \
+	      -e 's|@''GNULIB_WMEMMOVE''@|$(GNULIB_WMEMMOVE)|g' \
+	      -e 's|@''GNULIB_WMEMSET''@|$(GNULIB_WMEMSET)|g' \
+	      -e 's|@''GNULIB_WCSLEN''@|$(GNULIB_WCSLEN)|g' \
+	      -e 's|@''GNULIB_WCSNLEN''@|$(GNULIB_WCSNLEN)|g' \
+	      -e 's|@''GNULIB_WCSCPY''@|$(GNULIB_WCSCPY)|g' \
+	      -e 's|@''GNULIB_WCPCPY''@|$(GNULIB_WCPCPY)|g' \
+	      -e 's|@''GNULIB_WCSNCPY''@|$(GNULIB_WCSNCPY)|g' \
+	      -e 's|@''GNULIB_WCPNCPY''@|$(GNULIB_WCPNCPY)|g' \
+	      -e 's|@''GNULIB_WCSCAT''@|$(GNULIB_WCSCAT)|g' \
+	      -e 's|@''GNULIB_WCSNCAT''@|$(GNULIB_WCSNCAT)|g' \
+	      -e 's|@''GNULIB_WCSCMP''@|$(GNULIB_WCSCMP)|g' \
+	      -e 's|@''GNULIB_WCSNCMP''@|$(GNULIB_WCSNCMP)|g' \
+	      -e 's|@''GNULIB_WCSCASECMP''@|$(GNULIB_WCSCASECMP)|g' \
+	      -e 's|@''GNULIB_WCSNCASECMP''@|$(GNULIB_WCSNCASECMP)|g' \
+	      -e 's|@''GNULIB_WCSCOLL''@|$(GNULIB_WCSCOLL)|g' \
+	      -e 's|@''GNULIB_WCSXFRM''@|$(GNULIB_WCSXFRM)|g' \
+	      -e 's|@''GNULIB_WCSDUP''@|$(GNULIB_WCSDUP)|g' \
+	      -e 's|@''GNULIB_WCSCHR''@|$(GNULIB_WCSCHR)|g' \
+	      -e 's|@''GNULIB_WCSRCHR''@|$(GNULIB_WCSRCHR)|g' \
+	      -e 's|@''GNULIB_WCSCSPN''@|$(GNULIB_WCSCSPN)|g' \
+	      -e 's|@''GNULIB_WCSSPN''@|$(GNULIB_WCSSPN)|g' \
+	      -e 's|@''GNULIB_WCSPBRK''@|$(GNULIB_WCSPBRK)|g' \
+	      -e 's|@''GNULIB_WCSSTR''@|$(GNULIB_WCSSTR)|g' \
+	      -e 's|@''GNULIB_WCSTOK''@|$(GNULIB_WCSTOK)|g' \
+	      -e 's|@''GNULIB_WCSWIDTH''@|$(GNULIB_WCSWIDTH)|g' \
+	      < $(srcdir)/wchar.in.h | \
+	  sed -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' \
@@ -53,9 +82,38 @@
 	      -e 's|@''HAVE_WCRTOMB''@|$(HAVE_WCRTOMB)|g' \
 	      -e 's|@''HAVE_WCSRTOMBS''@|$(HAVE_WCSRTOMBS)|g' \
 	      -e 's|@''HAVE_WCSNRTOMBS''@|$(HAVE_WCSNRTOMBS)|g' \
+	      -e 's|@''HAVE_WMEMCHR''@|$(HAVE_WMEMCHR)|g' \
+	      -e 's|@''HAVE_WMEMCMP''@|$(HAVE_WMEMCMP)|g' \
+	      -e 's|@''HAVE_WMEMCPY''@|$(HAVE_WMEMCPY)|g' \
+	      -e 's|@''HAVE_WMEMMOVE''@|$(HAVE_WMEMMOVE)|g' \
+	      -e 's|@''HAVE_WMEMSET''@|$(HAVE_WMEMSET)|g' \
+	      -e 's|@''HAVE_WCSLEN''@|$(HAVE_WCSLEN)|g' \
+	      -e 's|@''HAVE_WCSNLEN''@|$(HAVE_WCSNLEN)|g' \
+	      -e 's|@''HAVE_WCSCPY''@|$(HAVE_WCSCPY)|g' \
+	      -e 's|@''HAVE_WCPCPY''@|$(HAVE_WCPCPY)|g' \
+	      -e 's|@''HAVE_WCSNCPY''@|$(HAVE_WCSNCPY)|g' \
+	      -e 's|@''HAVE_WCPNCPY''@|$(HAVE_WCPNCPY)|g' \
+	      -e 's|@''HAVE_WCSCAT''@|$(HAVE_WCSCAT)|g' \
+	      -e 's|@''HAVE_WCSNCAT''@|$(HAVE_WCSNCAT)|g' \
+	      -e 's|@''HAVE_WCSCMP''@|$(HAVE_WCSCMP)|g' \
+	      -e 's|@''HAVE_WCSNCMP''@|$(HAVE_WCSNCMP)|g' \
+	      -e 's|@''HAVE_WCSCASECMP''@|$(HAVE_WCSCASECMP)|g' \
+	      -e 's|@''HAVE_WCSNCASECMP''@|$(HAVE_WCSNCASECMP)|g' \
+	      -e 's|@''HAVE_WCSCOLL''@|$(HAVE_WCSCOLL)|g' \
+	      -e 's|@''HAVE_WCSXFRM''@|$(HAVE_WCSXFRM)|g' \
+	      -e 's|@''HAVE_WCSDUP''@|$(HAVE_WCSDUP)|g' \
+	      -e 's|@''HAVE_WCSCHR''@|$(HAVE_WCSCHR)|g' \
+	      -e 's|@''HAVE_WCSRCHR''@|$(HAVE_WCSRCHR)|g' \
+	      -e 's|@''HAVE_WCSCSPN''@|$(HAVE_WCSCSPN)|g' \
+	      -e 's|@''HAVE_WCSSPN''@|$(HAVE_WCSSPN)|g' \
+	      -e 's|@''HAVE_WCSPBRK''@|$(HAVE_WCSPBRK)|g' \
+	      -e 's|@''HAVE_WCSSTR''@|$(HAVE_WCSSTR)|g' \
+	      -e 's|@''HAVE_WCSTOK''@|$(HAVE_WCSTOK)|g' \
+	      -e 's|@''HAVE_WCSWIDTH''@|$(HAVE_WCSWIDTH)|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' \
+	  | \
+	  sed -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' \
@@ -67,10 +125,10 @@
 	      -e 's|@''REPLACE_WCSRTOMBS''@|$(REPLACE_WCSRTOMBS)|g' \
 	      -e 's|@''REPLACE_WCSNRTOMBS''@|$(REPLACE_WCSNRTOMBS)|g' \
 	      -e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \
+	      -e 's|@''REPLACE_WCSWIDTH''@|$(REPLACE_WCSWIDTH)|g' \
 	      -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
 	      -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
-	      -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
-	    < $(srcdir)/wchar.in.h; \
+	      -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \
 	} > $@-t && \
 	mv $@-t $@
 MOSTLYCLEANFILES += wchar.h wchar.h-t
new file mode 100644
--- /dev/null
+++ b/modules/wcpcpy
@@ -0,0 +1,31 @@
+Description:
+wcpcpy() function: copy a wide string.
+
+Status:
+obsolete
+
+Notice:
+This module is obsolete.
+
+Files:
+lib/wcpcpy.c
+lib/wcpcpy-impl.h
+m4/wcpcpy.m4
+
+Depends-on:
+wchar
+
+configure.ac:
+gl_FUNC_WCPCPY
+gl_WCHAR_MODULE_INDICATOR([wcpcpy])
+
+Makefile.am:
+
+Include:
+<wchar.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/wcpncpy
@@ -0,0 +1,25 @@
+Description:
+wcpncpy() function: copy a size-bounded wide string.
+
+Files:
+lib/wcpncpy.c
+lib/wcpncpy-impl.h
+m4/wcpncpy.m4
+
+Depends-on:
+wchar
+
+configure.ac:
+gl_FUNC_WCPNCPY
+gl_WCHAR_MODULE_INDICATOR([wcpncpy])
+
+Makefile.am:
+
+Include:
+<wchar.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
--- a/modules/wcrtomb-tests
+++ b/modules/wcrtomb-tests
@@ -1,6 +1,12 @@
 Files:
 tests/test-wcrtomb.sh
 tests/test-wcrtomb.c
+tests/test-wcrtomb-w32-1.sh
+tests/test-wcrtomb-w32-2.sh
+tests/test-wcrtomb-w32-3.sh
+tests/test-wcrtomb-w32-4.sh
+tests/test-wcrtomb-w32-5.sh
+tests/test-wcrtomb-w32.c
 tests/signature.h
 tests/macros.h
 m4/locale-fr.m4
@@ -10,6 +16,7 @@
 
 Depends-on:
 btowc
+setlocale
 
 configure.ac:
 gt_LOCALE_FR
@@ -18,11 +25,14 @@
 gt_LOCALE_ZH_CN
 
 Makefile.am:
-TESTS += test-wcrtomb.sh
+TESTS += \
+  test-wcrtomb.sh \
+  test-wcrtomb-w32-1.sh test-wcrtomb-w32-2.sh test-wcrtomb-w32-3.sh \
+  test-wcrtomb-w32-4.sh test-wcrtomb-w32-5.sh
 TESTS_ENVIRONMENT += \
   LOCALE_FR='@LOCALE_FR@' \
   LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \
   LOCALE_JA='@LOCALE_JA@' \
   LOCALE_ZH_CN='@LOCALE_ZH_CN@'
-check_PROGRAMS += test-wcrtomb
+check_PROGRAMS += test-wcrtomb test-wcrtomb-w32
 
new file mode 100644
--- /dev/null
+++ b/modules/wcscasecmp
@@ -0,0 +1,26 @@
+Description:
+wcscasecmp() function: compare two wide strings ignoring case.
+
+Files:
+lib/wcscasecmp.c
+lib/wcscasecmp-impl.h
+m4/wcscasecmp.m4
+
+Depends-on:
+wchar
+wctype-h
+
+configure.ac:
+gl_FUNC_WCSCASECMP
+gl_WCHAR_MODULE_INDICATOR([wcscasecmp])
+
+Makefile.am:
+
+Include:
+<wchar.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/wcscat
@@ -0,0 +1,31 @@
+Description:
+wcscat() function: concatenate two wide strings.
+
+Status:
+obsolete
+
+Notice:
+This module is obsolete.
+
+Files:
+lib/wcscat.c
+lib/wcscat-impl.h
+m4/wcscat.m4
+
+Depends-on:
+wchar
+
+configure.ac:
+gl_FUNC_WCSCAT
+gl_WCHAR_MODULE_INDICATOR([wcscat])
+
+Makefile.am:
+
+Include:
+<wchar.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/wcschr
@@ -0,0 +1,31 @@
+Description:
+wcschr() function: search wide string for a wide character.
+
+Status:
+obsolete
+
+Notice:
+This module is obsolete.
+
+Files:
+lib/wcschr.c
+lib/wcschr-impl.h
+m4/wcschr.m4
+
+Depends-on:
+wchar
+
+configure.ac:
+gl_FUNC_WCSCHR
+gl_WCHAR_MODULE_INDICATOR([wcschr])
+
+Makefile.am:
+
+Include:
+<wchar.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/wcscmp
@@ -0,0 +1,31 @@
+Description:
+wcscmp() function: compare two wide strings.
+
+Status:
+obsolete
+
+Notice:
+This module is obsolete.
+
+Files:
+lib/wcscmp.c
+lib/wcscmp-impl.h
+m4/wcscmp.m4
+
+Depends-on:
+wchar
+
+configure.ac:
+gl_FUNC_WCSCMP
+gl_WCHAR_MODULE_INDICATOR([wcscmp])
+
+Makefile.am:
+
+Include:
+<wchar.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/wcscoll
@@ -0,0 +1,31 @@
+Description:
+wcscoll() function: compare two wide strings using the current locale.
+
+Status:
+obsolete
+
+Notice:
+This module is obsolete.
+
+Files:
+lib/wcscoll.c
+lib/wcscoll-impl.h
+m4/wcscoll.m4
+
+Depends-on:
+wchar
+
+configure.ac:
+gl_FUNC_WCSCOLL
+gl_WCHAR_MODULE_INDICATOR([wcscoll])
+
+Makefile.am:
+
+Include:
+<wchar.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/wcscpy
@@ -0,0 +1,31 @@
+Description:
+wcscpy() function: copy a wide string.
+
+Status:
+obsolete
+
+Notice:
+This module is obsolete.
+
+Files:
+lib/wcscpy.c
+lib/wcscpy-impl.h
+m4/wcscpy.m4
+
+Depends-on:
+wchar
+
+configure.ac:
+gl_FUNC_WCSCPY
+gl_WCHAR_MODULE_INDICATOR([wcscpy])
+
+Makefile.am:
+
+Include:
+<wchar.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/wcscspn
@@ -0,0 +1,33 @@
+Description:
+wcscspn() function: search a wide string for any of a set of wide characters.
+
+Status:
+obsolete
+
+Notice:
+This module is obsolete.
+
+Files:
+lib/wcscspn.c
+lib/wcscspn-impl.h
+m4/wcscspn.m4
+
+Depends-on:
+wchar
+wcslen
+wcschr
+
+configure.ac:
+gl_FUNC_WCSCSPN
+gl_WCHAR_MODULE_INDICATOR([wcscspn])
+
+Makefile.am:
+
+Include:
+<wchar.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/wcsdup
@@ -0,0 +1,27 @@
+Description:
+wcsdup() function: duplicate a wide string.
+
+Files:
+lib/wcsdup.c
+lib/wcsdup-impl.h
+m4/wcsdup.m4
+
+Depends-on:
+wchar
+wcslen
+wmemcpy
+
+configure.ac:
+gl_FUNC_WCSDUP
+gl_WCHAR_MODULE_INDICATOR([wcsdup])
+
+Makefile.am:
+
+Include:
+<wchar.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/wcslen
@@ -0,0 +1,31 @@
+Description:
+wcslen() function: determine the length of a wide string.
+
+Status:
+obsolete
+
+Notice:
+This module is obsolete.
+
+Files:
+lib/wcslen.c
+lib/wcslen-impl.h
+m4/wcslen.m4
+
+Depends-on:
+wchar
+
+configure.ac:
+gl_FUNC_WCSLEN
+gl_WCHAR_MODULE_INDICATOR([wcslen])
+
+Makefile.am:
+
+Include:
+<wchar.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/wcsncasecmp
@@ -0,0 +1,26 @@
+Description:
+wcsncasecmp() function: compare two wide strings ignoring case.
+
+Files:
+lib/wcsncasecmp.c
+lib/wcsncasecmp-impl.h
+m4/wcsncasecmp.m4
+
+Depends-on:
+wchar
+wctype-h
+
+configure.ac:
+gl_FUNC_WCSNCASECMP
+gl_WCHAR_MODULE_INDICATOR([wcsncasecmp])
+
+Makefile.am:
+
+Include:
+<wchar.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/wcsncat
@@ -0,0 +1,31 @@
+Description:
+wcsncat() function: append part of a wide string to a wide string.
+
+Status:
+obsolete
+
+Notice:
+This module is obsolete.
+
+Files:
+lib/wcsncat.c
+lib/wcsncat-impl.h
+m4/wcsncat.m4
+
+Depends-on:
+wchar
+
+configure.ac:
+gl_FUNC_WCSNCAT
+gl_WCHAR_MODULE_INDICATOR([wcsncat])
+
+Makefile.am:
+
+Include:
+<wchar.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/wcsncmp
@@ -0,0 +1,31 @@
+Description:
+wcsncmp() function: compare two wide strings.
+
+Status:
+obsolete
+
+Notice:
+This module is obsolete.
+
+Files:
+lib/wcsncmp.c
+lib/wcsncmp-impl.h
+m4/wcsncmp.m4
+
+Depends-on:
+wchar
+
+configure.ac:
+gl_FUNC_WCSNCMP
+gl_WCHAR_MODULE_INDICATOR([wcsncmp])
+
+Makefile.am:
+
+Include:
+<wchar.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/wcsncpy
@@ -0,0 +1,31 @@
+Description:
+wcsncpy() function: copy a size-bounded wide string.
+
+Status:
+obsolete
+
+Notice:
+This module is obsolete.
+
+Files:
+lib/wcsncpy.c
+lib/wcsncpy-impl.h
+m4/wcsncpy.m4
+
+Depends-on:
+wchar
+
+configure.ac:
+gl_FUNC_WCSNCPY
+gl_WCHAR_MODULE_INDICATOR([wcsncpy])
+
+Makefile.am:
+
+Include:
+<wchar.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/wcsnlen
@@ -0,0 +1,25 @@
+Description:
+wcsnlen() function: determine the length of a size-bounded wide string.
+
+Files:
+lib/wcsnlen.c
+lib/wcsnlen-impl.h
+m4/wcsnlen.m4
+
+Depends-on:
+wchar
+
+configure.ac:
+gl_FUNC_WCSNLEN
+gl_WCHAR_MODULE_INDICATOR([wcsnlen])
+
+Makefile.am:
+
+Include:
+<wchar.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
--- a/modules/wcsnrtombs
+++ b/modules/wcsnrtombs
@@ -3,6 +3,7 @@
 
 Files:
 lib/wcsnrtombs.c
+lib/wcsnrtombs-impl.h
 lib/wcsrtombs-state.c
 m4/wcsnrtombs.m4
 m4/mbrtowc.m4
--- a/modules/wcsnrtombs-tests
+++ b/modules/wcsnrtombs-tests
@@ -12,6 +12,7 @@
 m4/codeset.m4
 
 Depends-on:
+setlocale
 
 configure.ac:
 gt_LOCALE_FR
new file mode 100644
--- /dev/null
+++ b/modules/wcspbrk
@@ -0,0 +1,32 @@
+Description:
+wcspbrk() function: search a wide string for any of a set of wide characters.
+
+Status:
+obsolete
+
+Notice:
+This module is obsolete.
+
+Files:
+lib/wcspbrk.c
+lib/wcspbrk-impl.h
+m4/wcspbrk.m4
+
+Depends-on:
+wchar
+wcschr
+
+configure.ac:
+gl_FUNC_WCSPBRK
+gl_WCHAR_MODULE_INDICATOR([wcspbrk])
+
+Makefile.am:
+
+Include:
+<wchar.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/wcsrchr
@@ -0,0 +1,31 @@
+Description:
+wcsrchr() function: search wide string for a wide character.
+
+Status:
+obsolete
+
+Notice:
+This module is obsolete.
+
+Files:
+lib/wcsrchr.c
+lib/wcsrchr-impl.h
+m4/wcsrchr.m4
+
+Depends-on:
+wchar
+
+configure.ac:
+gl_FUNC_WCSRCHR
+gl_WCHAR_MODULE_INDICATOR([wcsrchr])
+
+Makefile.am:
+
+Include:
+<wchar.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
--- a/modules/wcsrtombs
+++ b/modules/wcsrtombs
@@ -3,6 +3,7 @@
 
 Files:
 lib/wcsrtombs.c
+lib/wcsrtombs-impl.h
 lib/wcsrtombs-state.c
 m4/wcsrtombs.m4
 m4/mbrtowc.m4
--- a/modules/wcsrtombs-tests
+++ b/modules/wcsrtombs-tests
@@ -12,6 +12,7 @@
 m4/codeset.m4
 
 Depends-on:
+setlocale
 
 configure.ac:
 gt_LOCALE_FR
new file mode 100644
--- /dev/null
+++ b/modules/wcsspn
@@ -0,0 +1,32 @@
+Description:
+wcsspn() function: advance in a wide string, skipping any of a set of wide characters.
+
+Status:
+obsolete
+
+Notice:
+This module is obsolete.
+
+Files:
+lib/wcsspn.c
+lib/wcsspn-impl.h
+m4/wcsspn.m4
+
+Depends-on:
+wchar
+wcschr
+
+configure.ac:
+gl_FUNC_WCSSPN
+gl_WCHAR_MODULE_INDICATOR([wcsspn])
+
+Makefile.am:
+
+Include:
+<wchar.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/wcsstr
@@ -0,0 +1,26 @@
+Description:
+wcsstr() function: locate a substring in a wide string.
+
+Files:
+lib/wcsstr.c
+lib/wcsstr-impl.h
+m4/wcsstr.m4
+
+Depends-on:
+wchar
+wcschr
+
+configure.ac:
+gl_FUNC_WCSSTR
+gl_WCHAR_MODULE_INDICATOR([wcsstr])
+
+Makefile.am:
+
+Include:
+<wchar.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/wcstok
@@ -0,0 +1,27 @@
+Description:
+wcstok() function: split a wide string into tokens.
+
+Files:
+lib/wcstok.c
+lib/wcstok-impl.h
+m4/wcstok.m4
+
+Depends-on:
+wchar
+wcsspn
+wcspbrk
+
+configure.ac:
+gl_FUNC_WCSTOK
+gl_WCHAR_MODULE_INDICATOR([wcstok])
+
+Makefile.am:
+
+Include:
+<wchar.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/wcswidth
@@ -0,0 +1,27 @@
+Description:
+wcswidth() function: determine number of screen columns needed for a
+size-bounded wide string.
+
+Files:
+lib/wcswidth.c
+lib/wcswidth-impl.h
+m4/wcswidth.m4
+
+Depends-on:
+wchar
+wcwidth
+
+configure.ac:
+gl_FUNC_WCSWIDTH
+gl_WCHAR_MODULE_INDICATOR([wcswidth])
+
+Makefile.am:
+
+Include:
+<wchar.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/wcsxfrm
@@ -0,0 +1,26 @@
+Description:
+wcsxfrm() function: transform wide string for comparison using the current
+locale.
+
+Files:
+lib/wcsxfrm.c
+lib/wcsxfrm-impl.h
+m4/wcsxfrm.m4
+
+Depends-on:
+wchar
+
+configure.ac:
+gl_FUNC_WCSXFRM
+gl_WCHAR_MODULE_INDICATOR([wcsxfrm])
+
+Makefile.am:
+
+Include:
+<wchar.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
--- a/modules/wctob
+++ b/modules/wctob
@@ -9,6 +9,7 @@
 
 Depends-on:
 wchar
+wctomb
 
 configure.ac:
 gl_FUNC_WCTOB
new file mode 100644
--- /dev/null
+++ b/modules/wctomb
@@ -0,0 +1,27 @@
+Description:
+wctomb() function: convert wide character to multibyte character.
+
+Files:
+lib/wctomb.c
+lib/wctomb-impl.h
+m4/wctomb.m4
+
+Depends-on:
+stdlib
+wcrtomb
+wchar
+
+configure.ac:
+gl_FUNC_WCTOMB
+gl_STDLIB_MODULE_INDICATOR([wctomb])
+
+Makefile.am:
+
+Include:
+<stdlib.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/wctrans
@@ -0,0 +1,25 @@
+Description:
+wctrans() function: get descriptor for a wide character case conversion.
+
+Files:
+lib/wctrans.c
+lib/wctrans-impl.h
+m4/wctrans.m4
+
+Depends-on:
+wctype-h
+
+configure.ac:
+gl_FUNC_WCTRANS
+gl_WCTYPE_MODULE_INDICATOR([wctrans])
+
+Makefile.am:
+
+Include:
+<wctype.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
--- a/modules/wctype
+++ b/modules/wctype
@@ -1,52 +1,32 @@
 Description:
-A <wctype.h> that conforms better to C99.
+wctype() function: get descriptor for a wide character property.
+
+Status:
+obsolete
+
+Notice:
+This module is obsolete.
 
 Files:
-lib/wctype.in.h
-lib/iswblank.c
-m4/wctype_h.m4
-m4/wint_t.m4
+lib/wctype.c
+lib/wctype-impl.h
+m4/wctype.m4
 
 Depends-on:
-include_next
-c++defs
-warn-on-use
+wctype-h
+iswblank
 
 configure.ac:
-gl_WCTYPE_H
+gl_FUNC_WCTYPE
+gl_WCTYPE_MODULE_INDICATOR([wctype])
 
 Makefile.am:
-nodist_pkginclude_HEADERS += wctype.h
-
-BUILT_SOURCES += wctype.h
-
-# We need the following in order to create <wctype.h> when the system
-# doesn't have one that works with the given compiler.
-wctype.h: wctype.in.h $(CXXDEFS_H) $(WARN_ON_USE_H)
-	$(AM_V_GEN)rm -f $@-t $@ && \
-	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
-	  sed -e 's/@''HAVE_WCTYPE_H''@/$(HAVE_WCTYPE_H)/g' \
-	      -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-	      -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-	      -e 's|@''NEXT_WCTYPE_H''@|$(NEXT_WCTYPE_H)|g' \
-	      -e 's/@''HAVE_ISWBLANK''@/$(HAVE_ISWBLANK)/g' \
-	      -e 's/@''HAVE_ISWCNTRL''@/$(HAVE_ISWCNTRL)/g' \
-	      -e 's/@''HAVE_WINT_T''@/$(HAVE_WINT_T)/g' \
-	      -e 's/@''REPLACE_ISWBLANK''@/$(REPLACE_ISWBLANK)/g' \
-	      -e 's/@''REPLACE_ISWCNTRL''@/$(REPLACE_ISWCNTRL)/g' \
-	      -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-	      -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
-	      < $(srcdir)/wctype.in.h; \
-	} > $@-t && \
-	mv $@-t $@
-MOSTLYCLEANFILES += wctype.h wctype.h-t
 
 Include:
 <wctype.h>
 
 License:
-LGPLv2+
+LGPL
 
 Maintainer:
-all
+Bruno Haible
deleted file mode 100644
--- a/modules/wctype-c++-tests
+++ /dev/null
@@ -1,19 +0,0 @@
-Files:
-tests/test-wctype-c++.cc
-tests/signature.h
-
-Status:
-c++-test
-
-Depends-on:
-ansi-c++-opt
-
-configure.ac:
-
-Makefile.am:
-if ANSICXX
-TESTS += test-wctype-c++
-check_PROGRAMS += test-wctype-c++
-test_wctype_c___SOURCES = test-wctype-c++.cc
-test_wctype_c___LDADD = $(LDADD) $(LIBINTL) $(LIB_NANOSLEEP) $(LIB_EACCESS)
-endif
new file mode 100644
--- /dev/null
+++ b/modules/wctype-h
@@ -0,0 +1,56 @@
+Description:
+A <wctype.h> that conforms better to C99.
+
+Files:
+lib/wctype.in.h
+m4/wctype_h.m4
+m4/wint_t.m4
+
+Depends-on:
+include_next
+c++defs
+warn-on-use
+
+configure.ac:
+gl_WCTYPE_H
+
+Makefile.am:
+BUILT_SOURCES += wctype.h
+
+# We need the following in order to create <wctype.h> when the system
+# doesn't have one that works with the given compiler.
+wctype.h: wctype.in.h $(CXXDEFS_H) $(WARN_ON_USE_H)
+	$(AM_V_GEN)rm -f $@-t $@ && \
+	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+	  sed -e 's/@''HAVE_WCTYPE_H''@/$(HAVE_WCTYPE_H)/g' \
+	      -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+	      -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+	      -e 's|@''NEXT_WCTYPE_H''@|$(NEXT_WCTYPE_H)|g' \
+	      -e 's/@''GNULIB_ISWBLANK''@/$(GNULIB_ISWBLANK)/g' \
+	      -e 's/@''GNULIB_WCTYPE''@/$(GNULIB_WCTYPE)/g' \
+	      -e 's/@''GNULIB_ISWCTYPE''@/$(GNULIB_ISWCTYPE)/g' \
+	      -e 's/@''GNULIB_WCTRANS''@/$(GNULIB_WCTRANS)/g' \
+	      -e 's/@''GNULIB_TOWCTRANS''@/$(GNULIB_TOWCTRANS)/g' \
+	      -e 's/@''HAVE_ISWBLANK''@/$(HAVE_ISWBLANK)/g' \
+	      -e 's/@''HAVE_ISWCNTRL''@/$(HAVE_ISWCNTRL)/g' \
+	      -e 's/@''HAVE_WCTYPE_T''@/$(HAVE_WCTYPE_T)/g' \
+	      -e 's/@''HAVE_WCTRANS_T''@/$(HAVE_WCTRANS_T)/g' \
+	      -e 's/@''HAVE_WINT_T''@/$(HAVE_WINT_T)/g' \
+	      -e 's/@''REPLACE_ISWBLANK''@/$(REPLACE_ISWBLANK)/g' \
+	      -e 's/@''REPLACE_ISWCNTRL''@/$(REPLACE_ISWCNTRL)/g' \
+	      -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+	      -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+	      < $(srcdir)/wctype.in.h; \
+	} > $@-t && \
+	mv $@-t $@
+MOSTLYCLEANFILES += wctype.h wctype.h-t
+
+Include:
+<wctype.h>
+
+License:
+LGPLv2+
+
+Maintainer:
+all
new file mode 100644
--- /dev/null
+++ b/modules/wctype-h-c++-tests
@@ -0,0 +1,19 @@
+Files:
+tests/test-wctype-h-c++.cc
+tests/signature.h
+
+Status:
+c++-test
+
+Depends-on:
+ansi-c++-opt
+
+configure.ac:
+
+Makefile.am:
+if ANSICXX
+TESTS += test-wctype-h-c++
+check_PROGRAMS += test-wctype-h-c++
+test_wctype_h_c___SOURCES = test-wctype-h-c++.cc
+test_wctype_h_c___LDADD = $(LDADD) $(LIBINTL) $(LIB_NANOSLEEP) $(LIB_EACCESS)
+endif
new file mode 100644
--- /dev/null
+++ b/modules/wctype-h-tests
@@ -0,0 +1,12 @@
+Files:
+tests/test-wctype-h.c
+tests/macros.h
+
+Depends-on:
+wctype-h-c++-tests
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-wctype-h
+check_PROGRAMS += test-wctype-h
deleted file mode 100644
--- a/modules/wctype-tests
+++ /dev/null
@@ -1,12 +0,0 @@
-Files:
-tests/test-wctype.c
-tests/macros.h
-
-Depends-on:
-wctype-c++-tests
-
-configure.ac:
-
-Makefile.am:
-TESTS += test-wctype
-check_PROGRAMS += test-wctype
--- a/modules/wcwidth
+++ b/modules/wcwidth
@@ -10,7 +10,7 @@
 Depends-on:
 extensions
 wchar
-wctype
+wctype-h
 localcharset
 streq
 uniwidth/width
new file mode 100644
--- /dev/null
+++ b/modules/wmemchr
@@ -0,0 +1,25 @@
+Description:
+wmemchr() function: search wide character array for a wide character.
+
+Files:
+lib/wmemchr.c
+lib/wmemchr-impl.h
+m4/wmemchr.m4
+
+Depends-on:
+wchar
+
+configure.ac:
+gl_FUNC_WMEMCHR
+gl_WCHAR_MODULE_INDICATOR([wmemchr])
+
+Makefile.am:
+
+Include:
+<wchar.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/wmemcmp
@@ -0,0 +1,25 @@
+Description:
+wmemcmp() function: compare wide character arrays.
+
+Files:
+lib/wmemcmp.c
+lib/wmemcmp-impl.h
+m4/wmemcmp.m4
+
+Depends-on:
+wchar
+
+configure.ac:
+gl_FUNC_WMEMCMP
+gl_WCHAR_MODULE_INDICATOR([wmemcmp])
+
+Makefile.am:
+
+Include:
+<wchar.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/wmemcpy
@@ -0,0 +1,25 @@
+Description:
+wmemcpy() function: copy wide character array.
+
+Files:
+lib/wmemcpy.c
+lib/wmemcpy-impl.h
+m4/wmemcpy.m4
+
+Depends-on:
+wchar
+
+configure.ac:
+gl_FUNC_WMEMCPY
+gl_WCHAR_MODULE_INDICATOR([wmemcpy])
+
+Makefile.am:
+
+Include:
+<wchar.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/wmemmove
@@ -0,0 +1,25 @@
+Description:
+wmemmove() function: copy wide character array.
+
+Files:
+lib/wmemmove.c
+lib/wmemmove-impl.h
+m4/wmemmove.m4
+
+Depends-on:
+wchar
+
+configure.ac:
+gl_FUNC_WMEMMOVE
+gl_WCHAR_MODULE_INDICATOR([wmemmove])
+
+Makefile.am:
+
+Include:
+<wchar.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
new file mode 100644
--- /dev/null
+++ b/modules/wmemset
@@ -0,0 +1,25 @@
+Description:
+wmemset() function: fill wide character array.
+
+Files:
+lib/wmemset.c
+lib/wmemset-impl.h
+m4/wmemset.m4
+
+Depends-on:
+wchar
+
+configure.ac:
+gl_FUNC_WMEMSET
+gl_WCHAR_MODULE_INDICATOR([wmemset])
+
+Makefile.am:
+
+Include:
+<wchar.h>
+
+License:
+LGPL
+
+Maintainer:
+Bruno Haible
--- a/posix-modules
+++ b/posix-modules
@@ -26,6 +26,8 @@
   echo "\
 Usage: posix-modules
 
+Lists the gnulib modules that implement POSIX interfaces.
+
 Report bugs to <bug-gnulib@gnu.org>."
 }
 
--- a/tests/test-areadlink.h
+++ b/tests/test-areadlink.h
@@ -36,7 +36,7 @@
   ASSERT (errno == ENOENT);
   errno = 0;
   ASSERT (func ("", 1) == NULL);
-  ASSERT (errno == ENOENT);
+  ASSERT (errno == ENOENT || errno == EINVAL);
   errno = 0;
   ASSERT (func (".", 1) == NULL);
   ASSERT (errno == EINVAL);
--- a/tests/test-argmatch.c
+++ b/tests/test-argmatch.c
@@ -29,18 +29,16 @@
 /* Some packages define ARGMATCH_DIE and ARGMATCH_DIE_DECL in <config.h>, and
    thus must link with a definition of that function.  Provide it here.  */
 #ifdef ARGMATCH_DIE_DECL
-#ifndef __attribute__
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
-#  define __attribute__(x) /* empty */
-# endif
-#endif
 
-#ifndef ATTRIBUTE_NORETURN
-# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
-#endif
+# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)
+#  define _GL_ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
+# else
+#  define _GL_ATTRIBUTE_NORETURN /* empty */
+# endif
 
-ARGMATCH_DIE_DECL ATTRIBUTE_NORETURN;
+ARGMATCH_DIE_DECL _GL_ATTRIBUTE_NORETURN;
 ARGMATCH_DIE_DECL { exit (1); }
+
 #endif
 
 enum backup_type
--- a/tests/test-c-strcasestr.c
+++ b/tests/test-c-strcasestr.c
@@ -149,5 +149,93 @@
     free (haystack);
   }
 
+  {
+    /* Ensure that with a barely periodic "short" needle, c_strcasestr's
+       search does not mistakenly skip just past the match point.
+       This use of c_strcasestr would mistakenly return NULL before
+       gnulib v0.0-4927.  */
+    const char *haystack =
+      "\n"
+      "with_build_libsubdir\n"
+      "with_local_prefix\n"
+      "with_gxx_include_dir\n"
+      "with_cpp_install_dir\n"
+      "enable_generated_files_in_srcdir\n"
+      "with_gnu_ld\n"
+      "with_ld\n"
+      "with_demangler_in_ld\n"
+      "with_gnu_as\n"
+      "with_as\n"
+      "enable_largefile\n"
+      "enable_werror_always\n"
+      "enable_checking\n"
+      "enable_coverage\n"
+      "enable_gather_detailed_mem_stats\n"
+      "enable_build_with_cxx\n"
+      "with_stabs\n"
+      "enable_multilib\n"
+      "enable___cxa_atexit\n"
+      "enable_decimal_float\n"
+      "enable_fixed_point\n"
+      "enable_threads\n"
+      "enable_tls\n"
+      "enable_objc_gc\n"
+      "with_dwarf2\n"
+      "enable_shared\n"
+      "with_build_sysroot\n"
+      "with_sysroot\n"
+      "with_specs\n"
+      "with_pkgversion\n"
+      "with_bugurl\n"
+      "enable_languages\n"
+      "with_multilib_list\n";
+    const char *needle = "\n"
+      "with_GNU_ld\n";
+    const char* p = c_strcasestr (haystack, needle);
+    ASSERT (p - haystack == 114);
+  }
+
+  {
+    /* Same bug, shorter trigger.  */
+    const char *haystack = "..wi.D.";
+    const char *needle = ".d.";
+    const char* p = c_strcasestr (haystack, needle);
+    ASSERT (p - haystack == 4);
+  }
+
+  {
+    /* Like the above, but trigger the flaw in two_way_long_needle
+       by using a needle of length LONG_NEEDLE_THRESHOLD (32) or greater.
+       Rather than trying to find the right alignment manually, I've
+       arbitrarily chosen the following needle and template for the
+       haystack, and ensure that for each placement of the needle in
+       that haystack, c_strcasestr finds it.  */
+    const char *needle = "\nwith_gnu_ld-extend-to-len-32-b\n";
+    const char *h =
+      "\n"
+      "with_build_libsubdir\n"
+      "with_local_prefix\n"
+      "with_gxx_include_dir\n"
+      "with_cpp_install_dir\n"
+      "with_e_\n"
+      "..............................\n"
+      "with_FGHIJKLMNOPQRSTUVWXYZ\n"
+      "with_567890123456789\n"
+      "with_multilib_list\n";
+    size_t h_len = strlen (h);
+    char *haystack = malloc (h_len + 1);
+    size_t i;
+    ASSERT (haystack);
+    for (i = 0; i < h_len - strlen (needle); i++)
+      {
+        const char *p;
+        memcpy (haystack, h, h_len + 1);
+        memcpy (haystack + i, needle, strlen (needle) + 1);
+        p = c_strcasestr (haystack, needle);
+        ASSERT (p);
+        ASSERT (p - haystack == i);
+      }
+  }
+
   return 0;
 }
new file mode 100644
--- /dev/null
+++ b/tests/test-di-set.c
@@ -0,0 +1,53 @@
+/* Test the di-set module.
+   Copyright (C) 2010-2011 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 Jim Meyering.  */
+
+#include <config.h>
+
+#include "di-set.h"
+
+#include "macros.h"
+
+int
+main (void)
+{
+  struct di_set *dis = di_set_alloc ();
+  ASSERT (dis);
+
+  ASSERT (di_set_lookup (dis, 2, 5) == 0); /* initial lookup fails */
+  ASSERT (di_set_insert (dis, 2, 5) == 1); /* first insertion succeeds */
+  ASSERT (di_set_insert (dis, 2, 5) == 0); /* duplicate fails */
+  ASSERT (di_set_insert (dis, 3, 5) == 1); /* diff dev, duplicate inode is ok */
+  ASSERT (di_set_insert (dis, 2, 8) == 1); /* same dev, different inode is ok */
+  ASSERT (di_set_lookup (dis, 2, 5) == 1); /* now, the lookup succeeds */
+
+  /* very large (or negative) inode number */
+  ASSERT (di_set_insert (dis, 5, (ino_t) -1) == 1);
+  ASSERT (di_set_insert (dis, 5, (ino_t) -1) == 0); /* dup */
+
+  {
+    unsigned int i;
+    for (i = 0; i < 3000; i++)
+      ASSERT (di_set_insert (dis, 9, i) == 1);
+    for (i = 0; i < 3000; i++)
+      ASSERT (di_set_insert (dis, 9, i) == 0); /* duplicate fails */
+  }
+
+  di_set_free (dis);
+
+  return 0;
+}
--- a/tests/test-dirname.c
+++ b/tests/test-dirname.c
@@ -54,7 +54,7 @@
   {"",          ".",    "",     "",     "",     false,  false},
   {".",         ".",    ".",    ".",    ".",    false,  false},
   {"..",        ".",    "..",   "..",   "..",   false,  false},
-#if FILE_SYSTEM_BACKSLASH_IS_FILE_NAME_SEPARATOR
+#if ISSLASH ('\\')
   {"a\\",       ".",    "a\\",  "a\\",  "a",    true,   false},
   {"a\\b",      "a",    "b",    "b",    "a\\b", false,  false},
   {"\\",        "\\",   "",     "\\",   "\\",   false,  true},
@@ -75,7 +75,7 @@
   {"//\\",      "/",    "\\",   "\\",   "//\\", false,  true},
 # endif
 #endif
-#if FILE_SYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX
+#if ISSLASH ('\\')
 # if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
   {"c:",        "c:",   "",     "c:",   "c:",   false,  false},
   {"c:/",       "c:/",  "",     "c:/",  "c:/",  false,  true},
@@ -105,7 +105,7 @@
   {"a/b:c",     "a",    "b:c",  "./b:c","a/b:c",false,  false},
   {"a/b:c/",    "a",    "b:c/", "./b:c/","a/b:c",true,  false},
 # endif
-#else /* ! FILE_SYSTEM_ACCEPTS_DRIVE_LETTER_PREFIX */
+#else /* ! ISSLASH ('\\') */
   {"c:",        ".",    "c:",   "c:",   "c:",   false,  false},
   {"c:/",       ".",    "c:/",  "c:/",  "c:",   true,   false},
   {"c://",      ".",    "c://", "c:/",  "c:",   true,   false},
--- a/tests/test-exclude.c
+++ b/tests/test-exclude.c
@@ -63,18 +63,16 @@
 /* Some packages define ARGMATCH_DIE and ARGMATCH_DIE_DECL in <config.h>, and
    thus must link with a definition of that function.  Provide it here.  */
 #ifdef ARGMATCH_DIE_DECL
-#ifndef __attribute__
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
-#  define __attribute__(x) /* empty */
-# endif
-#endif
 
-#ifndef ATTRIBUTE_NORETURN
-# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
-#endif
+# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)
+#  define _GL_ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
+# else
+#  define _GL_ATTRIBUTE_NORETURN /* empty */
+# endif
 
-ARGMATCH_DIE_DECL ATTRIBUTE_NORETURN;
+ARGMATCH_DIE_DECL _GL_ATTRIBUTE_NORETURN;
 ARGMATCH_DIE_DECL { exit (1); }
+
 #endif
 
 int
new file mode 100644
--- /dev/null
+++ b/tests/test-getloadavg.c
@@ -0,0 +1,83 @@
+/* Test of getting load average.
+   Copyright (C) 2011 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/>.  */
+
+#include <config.h>
+
+#include <stdlib.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (getloadavg, int, (double [], int));
+
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+
+static void
+check_avg (int minutes, double avg, int printit)
+{
+  if (printit)
+    printf ("%d-minute: %f  ", minutes, avg);
+  else
+    {
+      /* Plausibility checks.  */
+      if (avg < 0.01)
+        printf ("suspiciously low %d-minute average: %f\n", minutes, avg);
+      if (avg > 1000000)
+        printf ("suspiciously high %d-minute average: %f\n", minutes, avg);
+    }
+  if (avg < 0 || avg != avg)
+    exit (minutes);
+}
+
+/* This program can also be used as a manual test, by invoking it with
+   an argument; it then prints the load average.  If the argument is
+   nonzero, the manual test repeats forever, sleeping for the stated
+   interval between each iteration.  */
+int
+main (int argc, char **argv)
+{
+  int naptime = 0;
+
+  if (argc > 1)
+    naptime = atoi (argv[1]);
+
+  while (1)
+    {
+      double avg[3];
+      int loads = getloadavg (avg, 3);
+      if (loads == -1)
+        {
+          if (! (errno == ENOSYS || errno == ENOTSUP))
+            return 1;
+          perror ("Skipping test; load average not supported");
+          return 77;
+        }
+      if (loads > 0)
+        check_avg (1, avg[0], argc > 1);
+      if (loads > 1)
+        check_avg (5, avg[1], argc > 1);
+      if (loads > 2)
+        check_avg (15, avg[1], argc > 1);
+      if (loads > 0 && argc > 1)
+        putchar ('\n');
+
+      if (naptime == 0)
+        break;
+      sleep (naptime);
+    }
+
+  return 0;
+}
--- a/tests/test-ignore-value.c
+++ b/tests/test-ignore-value.c
@@ -23,20 +23,20 @@
 
 #include <stdio.h>
 
-#ifndef ATTRIBUTE_RETURN_CHECK
-# if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 1)
-#  define ATTRIBUTE_RETURN_CHECK
+#ifndef _GL_ATTRIBUTE_RETURN_CHECK
+# if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4)
+#  define _GL_ATTRIBUTE_RETURN_CHECK
 # else
-#  define ATTRIBUTE_RETURN_CHECK __attribute__((__warn_unused_result__))
+#  define _GL_ATTRIBUTE_RETURN_CHECK __attribute__((__warn_unused_result__))
 # endif
 #endif
 
 struct s { int i; };
-static char doChar (void) ATTRIBUTE_RETURN_CHECK;
-static int doInt (void) ATTRIBUTE_RETURN_CHECK;
-static off_t doOff (void) ATTRIBUTE_RETURN_CHECK;
-static void *doPtr (void) ATTRIBUTE_RETURN_CHECK;
-static struct s doStruct (void) ATTRIBUTE_RETURN_CHECK;
+static char doChar (void) _GL_ATTRIBUTE_RETURN_CHECK;
+static int doInt (void) _GL_ATTRIBUTE_RETURN_CHECK;
+static off_t doOff (void) _GL_ATTRIBUTE_RETURN_CHECK;
+static void *doPtr (void) _GL_ATTRIBUTE_RETURN_CHECK;
+static struct s doStruct (void) _GL_ATTRIBUTE_RETURN_CHECK;
 
 static char
 doChar (void)
new file mode 100644
--- /dev/null
+++ b/tests/test-ino-map.c
@@ -0,0 +1,50 @@
+/* Test the ino-map module.
+   Copyright (C) 2010-2011 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 Jim Meyering.  */
+
+#include <config.h>
+
+#include "ino-map.h"
+
+#include "macros.h"
+
+int
+main ()
+{
+  enum { INO_MAP_INIT = 123 };
+  struct ino_map *ino_map = ino_map_alloc (INO_MAP_INIT);
+  ASSERT (ino_map != NULL);
+
+  ASSERT (ino_map_insert (ino_map, 42) == INO_MAP_INIT);
+  ASSERT (ino_map_insert (ino_map, 42) == INO_MAP_INIT);
+  ASSERT (ino_map_insert (ino_map, 398) == INO_MAP_INIT + 1);
+  ASSERT (ino_map_insert (ino_map, 398) == INO_MAP_INIT + 1);
+  ASSERT (ino_map_insert (ino_map, 0) == INO_MAP_INIT + 2);
+  ASSERT (ino_map_insert (ino_map, 0) == INO_MAP_INIT + 2);
+
+  {
+    int i;
+    for (i = 0; i < 100; i++)
+      {
+        ASSERT (ino_map_insert (ino_map, 10000 + i) == INO_MAP_INIT + 3 + i);
+      }
+  }
+
+  ino_map_free (ino_map);
+
+  return 0;
+}
new file mode 100644
--- /dev/null
+++ b/tests/test-iswblank.c
@@ -0,0 +1,35 @@
+/* Test of iswblank() function.
+   Copyright (C) 2007-2011 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/>.  */
+
+#include <config.h>
+
+#include <wctype.h>
+
+#include "macros.h"
+
+/* Check that WEOF is defined.  */
+wint_t e = WEOF;
+
+int
+main (void)
+{
+  /* Check that the function exist as a function or as a macro.  */
+  (void) iswblank (0);
+  /* Check that the isw* functions map WEOF to 0.  */
+  ASSERT (!iswblank (e));
+
+  return 0;
+}
--- a/tests/test-link.h
+++ b/tests/test-link.h
@@ -136,13 +136,15 @@
     else
       {
         /* Most everyone else.  */
-        ASSERT (errno == EPERM || errno == EACCES);
+        ASSERT (errno == EPERM || errno == EACCES || errno == EISDIR);
         errno = 0;
         ASSERT (func (BASE "d/.", BASE "c") == -1);
-        ASSERT (errno == EPERM || errno == EACCES || errno == EINVAL);
+        ASSERT (errno == EPERM || errno == EACCES || errno == EISDIR
+                || errno == EINVAL);
         errno = 0;
         ASSERT (func (BASE "d/.//", BASE "c") == -1);
-        ASSERT (errno == EPERM || errno == EACCES || errno == EINVAL);
+        ASSERT (errno == EPERM || errno == EACCES || errno == EISDIR
+                || errno == EINVAL);
       }
   }
   ASSERT (unlink (BASE "a") == 0);
--- a/tests/test-locale-c++.cc
+++ b/tests/test-locale-c++.cc
@@ -24,6 +24,10 @@
 #include "signature.h"
 
 
+#if GNULIB_TEST_SETLOCALE
+SIGNATURE_CHECK (GNULIB_NAMESPACE::setlocale, char *, (int, const char *));
+#endif
+
 #if GNULIB_TEST_DUPLOCALE && HAVE_DUPLOCALE
 SIGNATURE_CHECK (GNULIB_NAMESPACE::duplocale, locale_t, (locale_t));
 #endif
new file mode 100755
--- /dev/null
+++ b/tests/test-mbrtowc-w32-1.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+# Test a CP1252 locale.
+./test-mbrtowc-w32${EXEEXT} French_France 1252
new file mode 100755
--- /dev/null
+++ b/tests/test-mbrtowc-w32-2.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+# Test a CP1256 locale.
+./test-mbrtowc-w32${EXEEXT} "Arabic_Saudi Arabia" 1256
new file mode 100755
--- /dev/null
+++ b/tests/test-mbrtowc-w32-3.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+# Test a CP932 locale.
+./test-mbrtowc-w32${EXEEXT} Japanese_Japan 932
new file mode 100755
--- /dev/null
+++ b/tests/test-mbrtowc-w32-4.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+# Test a CP950 locale.
+./test-mbrtowc-w32${EXEEXT} Chinese_Taiwan 950
new file mode 100755
--- /dev/null
+++ b/tests/test-mbrtowc-w32-5.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+# Test a CP936 locale.
+./test-mbrtowc-w32${EXEEXT} Chinese_China 936
new file mode 100755
--- /dev/null
+++ b/tests/test-mbrtowc-w32-6.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+# This test is not enabled by default, because MSVCRT does not support and
+# will likely never support locales with MB_CUR_MAX > 2.
+
+# Test a GB18030 locale.
+./test-mbrtowc-w32${EXEEXT} Chinese_China 54936
new file mode 100755
--- /dev/null
+++ b/tests/test-mbrtowc-w32-7.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+# This test is not enabled by default, because MSVCRT does not support and
+# will likely never support locales with MB_CUR_MAX > 2.
+
+# Test some UTF-8 locales.
+./test-mbrtowc-w32${EXEEXT} French_France Japanese_Japan Chinese_Taiwan Chinese_China 65001
new file mode 100644
--- /dev/null
+++ b/tests/test-mbrtowc-w32.c
@@ -0,0 +1,735 @@
+/* Test of conversion of multibyte character to wide character.
+   Copyright (C) 2008-2011 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/>.  */
+
+#include <config.h>
+
+#include <wchar.h>
+
+#include <errno.h>
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "macros.h"
+
+#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
+
+static int
+test_one_locale (const char *name, int codepage)
+{
+  mbstate_t state;
+  wchar_t wc;
+  size_t ret;
+
+# if 1
+  /* Portable code to set the locale.  */
+  {
+    char name_with_codepage[1024];
+
+    sprintf (name_with_codepage, "%s.%d", name, codepage);
+
+    /* Set the locale.  */
+    if (setlocale (LC_ALL, name_with_codepage) == NULL)
+      return 77;
+  }
+# else
+  /* Hacky way to set a locale.codepage combination that setlocale() refuses
+     to set.  */
+  {
+    /* Codepage of the current locale, set with setlocale().
+       Not necessarily the same as GetACP().  */
+    extern __declspec(dllimport) unsigned int __lc_codepage;
+
+    /* Set the locale.  */
+    if (setlocale (LC_ALL, name) == NULL)
+      return 77;
+
+    /* Clobber the codepage and MB_CUR_MAX, both set by setlocale().  */
+    __lc_codepage = codepage;
+    switch (codepage)
+      {
+      case 1252:
+      case 1256:
+        MB_CUR_MAX = 1;
+        break;
+      case 932:
+      case 950:
+      case 936:
+        MB_CUR_MAX = 2;
+        break;
+      case 54936:
+      case 65001:
+        MB_CUR_MAX = 4;
+        break;
+      }
+
+    /* Test whether the codepage is really available.  */
+    memset (&state, '\0', sizeof (mbstate_t));
+    if (mbrtowc (&wc, " ", 1, &state) == (size_t)(-1))
+      return 77;
+  }
+# endif
+
+  /* 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));
+  }
+
+  switch (codepage)
+    {
+    case 1252:
+      /* Locale encoding is CP1252, an extension of ISO-8859-1.  */
+      {
+        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 (wc == 0x00FC);
+        ASSERT (mbsinit (&state));
+        input[1] = '\0';
+
+        /* Test support of NULL first argument.  */
+        ret = mbrtowc (NULL, input + 2, 3, &state);
+        ASSERT (ret == 1);
+        ASSERT (mbsinit (&state));
+
+        wc = (wchar_t) 0xBADFACE;
+        ret = mbrtowc (&wc, input + 2, 3, &state);
+        ASSERT (ret == 1);
+        ASSERT (wctob (wc) == (unsigned char) '\337');
+        ASSERT (wc == 0x00DF);
+        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 1256:
+      /* Locale encoding is CP1256, not the same as ISO-8859-6.  */
+      {
+        char input[] = "x\302\341\346y"; /* "xآلوy" */
+        memset (&state, '\0', sizeof (mbstate_t));
+
+        wc = (wchar_t) 0xBADFACE;
+        ret = mbrtowc (&wc, input, 1, &state);
+        ASSERT (ret == 1);
+        ASSERT (wc == 'x');
+        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) '\302');
+        ASSERT (wc == 0x0622);
+        ASSERT (mbsinit (&state));
+        input[1] = '\0';
+
+        /* Test support of NULL first argument.  */
+        ret = mbrtowc (NULL, input + 2, 3, &state);
+        ASSERT (ret == 1);
+        ASSERT (mbsinit (&state));
+
+        wc = (wchar_t) 0xBADFACE;
+        ret = mbrtowc (&wc, input + 2, 3, &state);
+        ASSERT (ret == 1);
+        ASSERT (wctob (wc) == (unsigned char) '\341');
+        ASSERT (wc == 0x0644);
+        ASSERT (mbsinit (&state));
+        input[2] = '\0';
+
+        wc = (wchar_t) 0xBADFACE;
+        ret = mbrtowc (&wc, input + 3, 2, &state);
+        ASSERT (ret == 1);
+        ASSERT (wctob (wc) == (unsigned char) '\346');
+        ASSERT (wc == 0x0648);
+        ASSERT (mbsinit (&state));
+        input[3] = '\0';
+
+        wc = (wchar_t) 0xBADFACE;
+        ret = mbrtowc (&wc, input + 4, 1, &state);
+        ASSERT (ret == 1);
+        ASSERT (wc == 'y');
+        ASSERT (mbsinit (&state));
+      }
+      return 0;
+
+    case 932:
+      /* Locale encoding is CP932, similar to Shift_JIS.  */
+      {
+        char input[] = "<\223\372\226\173\214\352>"; /* "<日本語>" */
+        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 (wc == 0x65E5);
+        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 (wc == 0x672C);
+        ASSERT (mbsinit (&state));
+        input[4] = '\0';
+
+        /* Test support of NULL first argument.  */
+        ret = mbrtowc (NULL, input + 5, 3, &state);
+        ASSERT (ret == 2);
+        ASSERT (mbsinit (&state));
+
+        wc = (wchar_t) 0xBADFACE;
+        ret = mbrtowc (&wc, input + 5, 3, &state);
+        ASSERT (ret == 2);
+        ASSERT (wctob (wc) == EOF);
+        ASSERT (wc == 0x8A9E);
+        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));
+
+        /* Test some invalid input.  */
+        memset (&state, '\0', sizeof (mbstate_t));
+        wc = (wchar_t) 0xBADFACE;
+        ret = mbrtowc (&wc, "\377", 1, &state); /* 0xFF */
+        ASSERT (ret == (size_t)-1);
+        ASSERT (errno == EILSEQ);
+
+        memset (&state, '\0', sizeof (mbstate_t));
+        wc = (wchar_t) 0xBADFACE;
+        ret = mbrtowc (&wc, "\225\377", 2, &state); /* 0x95 0xFF */
+        ASSERT (ret == (size_t)-1);
+        ASSERT (errno == EILSEQ);
+      }
+      return 0;
+
+    case 950:
+      /* Locale encoding is CP950, similar to Big5.  */
+      {
+        char input[] = "<\244\351\245\273\273\171>"; /* "<日本語>" */
+        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 (wc == 0x65E5);
+        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 (wc == 0x672C);
+        ASSERT (mbsinit (&state));
+        input[4] = '\0';
+
+        /* Test support of NULL first argument.  */
+        ret = mbrtowc (NULL, input + 5, 3, &state);
+        ASSERT (ret == 2);
+        ASSERT (mbsinit (&state));
+
+        wc = (wchar_t) 0xBADFACE;
+        ret = mbrtowc (&wc, input + 5, 3, &state);
+        ASSERT (ret == 2);
+        ASSERT (wctob (wc) == EOF);
+        ASSERT (wc == 0x8A9E);
+        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));
+
+        /* Test some invalid input.  */
+        memset (&state, '\0', sizeof (mbstate_t));
+        wc = (wchar_t) 0xBADFACE;
+        ret = mbrtowc (&wc, "\377", 1, &state); /* 0xFF */
+        ASSERT (ret == (size_t)-1);
+        ASSERT (errno == EILSEQ);
+
+        memset (&state, '\0', sizeof (mbstate_t));
+        wc = (wchar_t) 0xBADFACE;
+        ret = mbrtowc (&wc, "\225\377", 2, &state); /* 0x95 0xFF */
+        ASSERT (ret == (size_t)-1);
+        ASSERT (errno == EILSEQ);
+      }
+      return 0;
+
+    case 936:
+      /* Locale encoding is CP936 = GBK, an extension of GB2312.  */
+      {
+        char input[] = "<\310\325\261\276\325\132>"; /* "<日本語>" */
+        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 (wc == 0x65E5);
+        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 (wc == 0x672C);
+        ASSERT (mbsinit (&state));
+        input[4] = '\0';
+
+        /* Test support of NULL first argument.  */
+        ret = mbrtowc (NULL, input + 5, 3, &state);
+        ASSERT (ret == 2);
+        ASSERT (mbsinit (&state));
+
+        wc = (wchar_t) 0xBADFACE;
+        ret = mbrtowc (&wc, input + 5, 3, &state);
+        ASSERT (ret == 2);
+        ASSERT (wctob (wc) == EOF);
+        ASSERT (wc == 0x8A9E);
+        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));
+
+        /* Test some invalid input.  */
+        memset (&state, '\0', sizeof (mbstate_t));
+        wc = (wchar_t) 0xBADFACE;
+        ret = mbrtowc (&wc, "\377", 1, &state); /* 0xFF */
+        ASSERT (ret == (size_t)-1);
+        ASSERT (errno == EILSEQ);
+
+        memset (&state, '\0', sizeof (mbstate_t));
+        wc = (wchar_t) 0xBADFACE;
+        ret = mbrtowc (&wc, "\225\377", 2, &state); /* 0x95 0xFF */
+        ASSERT (ret == (size_t)-1);
+        ASSERT (errno == EILSEQ);
+      }
+      return 0;
+
+    case 54936:
+      /* Locale encoding is CP54936 = 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 (wc == 0x00FC);
+        ASSERT (mbsinit (&state));
+        input[2] = '\0';
+
+        /* Test support of NULL first argument.  */
+        ret = mbrtowc (NULL, input + 3, 6, &state);
+        ASSERT (ret == 4);
+        ASSERT (mbsinit (&state));
+
+        wc = (wchar_t) 0xBADFACE;
+        ret = mbrtowc (&wc, input + 3, 6, &state);
+        ASSERT (ret == 4);
+        ASSERT (wctob (wc) == EOF);
+        ASSERT (wc == 0x00DF);
+        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));
+
+        /* Test some invalid input.  */
+        memset (&state, '\0', sizeof (mbstate_t));
+        wc = (wchar_t) 0xBADFACE;
+        ret = mbrtowc (&wc, "\377", 1, &state); /* 0xFF */
+        ASSERT (ret == (size_t)-1);
+        ASSERT (errno == EILSEQ);
+
+        memset (&state, '\0', sizeof (mbstate_t));
+        wc = (wchar_t) 0xBADFACE;
+        ret = mbrtowc (&wc, "\225\377", 2, &state); /* 0x95 0xFF */
+        ASSERT (ret == (size_t)-1);
+        ASSERT (errno == EILSEQ);
+
+        memset (&state, '\0', sizeof (mbstate_t));
+        wc = (wchar_t) 0xBADFACE;
+        ret = mbrtowc (&wc, "\201\045", 2, &state); /* 0x81 0x25 */
+        ASSERT (ret == (size_t)-1);
+        ASSERT (errno == EILSEQ);
+
+        memset (&state, '\0', sizeof (mbstate_t));
+        wc = (wchar_t) 0xBADFACE;
+        ret = mbrtowc (&wc, "\201\060\377", 3, &state); /* 0x81 0x30 0xFF */
+        ASSERT (ret == (size_t)-1);
+        ASSERT (errno == EILSEQ);
+
+        memset (&state, '\0', sizeof (mbstate_t));
+        wc = (wchar_t) 0xBADFACE;
+        ret = mbrtowc (&wc, "\201\060\377\064", 4, &state); /* 0x81 0x30 0xFF 0x34 */
+        ASSERT (ret == (size_t)-1);
+        ASSERT (errno == EILSEQ);
+
+        memset (&state, '\0', sizeof (mbstate_t));
+        wc = (wchar_t) 0xBADFACE;
+        ret = mbrtowc (&wc, "\201\060\211\072", 4, &state); /* 0x81 0x30 0x89 0x3A */
+        ASSERT (ret == (size_t)-1);
+        ASSERT (errno == EILSEQ);
+      }
+      return 0;
+
+    case 65001:
+      /* Locale encoding is CP65001 = 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 (wc == 0x00FC);
+        ASSERT (mbsinit (&state));
+        input[2] = '\0';
+
+        /* Test support of NULL first argument.  */
+        ret = mbrtowc (NULL, input + 3, 4, &state);
+        ASSERT (ret == 2);
+        ASSERT (mbsinit (&state));
+
+        wc = (wchar_t) 0xBADFACE;
+        ret = mbrtowc (&wc, input + 3, 4, &state);
+        ASSERT (ret == 2);
+        ASSERT (wctob (wc) == EOF);
+        ASSERT (wc == 0x00DF);
+        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));
+
+        /* Test some invalid input.  */
+        memset (&state, '\0', sizeof (mbstate_t));
+        wc = (wchar_t) 0xBADFACE;
+        ret = mbrtowc (&wc, "\377", 1, &state); /* 0xFF */
+        ASSERT (ret == (size_t)-1);
+        ASSERT (errno == EILSEQ);
+
+        memset (&state, '\0', sizeof (mbstate_t));
+        wc = (wchar_t) 0xBADFACE;
+        ret = mbrtowc (&wc, "\303\300", 2, &state); /* 0xC3 0xC0 */
+        ASSERT (ret == (size_t)-1);
+        ASSERT (errno == EILSEQ);
+
+        memset (&state, '\0', sizeof (mbstate_t));
+        wc = (wchar_t) 0xBADFACE;
+        ret = mbrtowc (&wc, "\343\300", 2, &state); /* 0xE3 0xC0 */
+        ASSERT (ret == (size_t)-1);
+        ASSERT (errno == EILSEQ);
+
+        memset (&state, '\0', sizeof (mbstate_t));
+        wc = (wchar_t) 0xBADFACE;
+        ret = mbrtowc (&wc, "\343\300\200", 3, &state); /* 0xE3 0xC0 0x80 */
+        ASSERT (ret == (size_t)-1);
+        ASSERT (errno == EILSEQ);
+
+        memset (&state, '\0', sizeof (mbstate_t));
+        wc = (wchar_t) 0xBADFACE;
+        ret = mbrtowc (&wc, "\343\200\300", 3, &state); /* 0xE3 0x80 0xC0 */
+        ASSERT (ret == (size_t)-1);
+        ASSERT (errno == EILSEQ);
+
+        memset (&state, '\0', sizeof (mbstate_t));
+        wc = (wchar_t) 0xBADFACE;
+        ret = mbrtowc (&wc, "\363\300", 2, &state); /* 0xF3 0xC0 */
+        ASSERT (ret == (size_t)-1);
+        ASSERT (errno == EILSEQ);
+
+        memset (&state, '\0', sizeof (mbstate_t));
+        wc = (wchar_t) 0xBADFACE;
+        ret = mbrtowc (&wc, "\363\300\200\200", 4, &state); /* 0xF3 0xC0 0x80 0x80 */
+        ASSERT (ret == (size_t)-1);
+        ASSERT (errno == EILSEQ);
+
+        memset (&state, '\0', sizeof (mbstate_t));
+        wc = (wchar_t) 0xBADFACE;
+        ret = mbrtowc (&wc, "\363\200\300", 3, &state); /* 0xF3 0x80 0xC0 */
+        ASSERT (ret == (size_t)-1);
+        ASSERT (errno == EILSEQ);
+
+        memset (&state, '\0', sizeof (mbstate_t));
+        wc = (wchar_t) 0xBADFACE;
+        ret = mbrtowc (&wc, "\363\200\300\200", 4, &state); /* 0xF3 0x80 0xC0 0x80 */
+        ASSERT (ret == (size_t)-1);
+        ASSERT (errno == EILSEQ);
+
+        memset (&state, '\0', sizeof (mbstate_t));
+        wc = (wchar_t) 0xBADFACE;
+        ret = mbrtowc (&wc, "\363\200\200\300", 4, &state); /* 0xF3 0x80 0x80 0xC0 */
+        ASSERT (ret == (size_t)-1);
+        ASSERT (errno == EILSEQ);
+      }
+      return 0;
+
+    default:
+      return 1;
+    }
+}
+
+int
+main (int argc, char *argv[])
+{
+  int codepage = atoi (argv[argc - 1]);
+  int result;
+  int i;
+
+  result = 77;
+  for (i = 1; i < argc - 1; i++)
+    {
+      int ret = test_one_locale (argv[i], codepage);
+
+      if (ret != 77)
+        result = ret;
+    }
+
+  if (result == 77)
+    {
+      fprintf (stderr, "Skipping test: found no locale with codepage %d\n",
+               codepage);
+    }
+  return result;
+}
+
+#else
+
+int
+main (int argc, char *argv[])
+{
+  fputs ("Skipping test: not a native Windows system\n", stderr);
+  return 77;
+}
+
+#endif
--- a/tests/test-mbsinit.c
+++ b/tests/test-mbsinit.c
@@ -32,6 +32,8 @@
 {
   static mbstate_t state;
 
+  ASSERT (mbsinit (NULL));
+
   ASSERT (mbsinit (&state));
 
   if (argc > 1)
--- a/tests/test-memmem.c
+++ b/tests/test-memmem.c
@@ -202,5 +202,95 @@
     free (needle);
   }
 
+  {
+    /* Ensure that with a barely periodic "short" needle, memmem's
+       search does not mistakenly skip just past the match point.
+       This use of memmem would mistakenly return NULL before
+       gnulib v0.0-4927.  */
+    const char *haystack =
+      "\n"
+      "with_build_libsubdir\n"
+      "with_local_prefix\n"
+      "with_gxx_include_dir\n"
+      "with_cpp_install_dir\n"
+      "enable_generated_files_in_srcdir\n"
+      "with_gnu_ld\n"
+      "with_ld\n"
+      "with_demangler_in_ld\n"
+      "with_gnu_as\n"
+      "with_as\n"
+      "enable_largefile\n"
+      "enable_werror_always\n"
+      "enable_checking\n"
+      "enable_coverage\n"
+      "enable_gather_detailed_mem_stats\n"
+      "enable_build_with_cxx\n"
+      "with_stabs\n"
+      "enable_multilib\n"
+      "enable___cxa_atexit\n"
+      "enable_decimal_float\n"
+      "enable_fixed_point\n"
+      "enable_threads\n"
+      "enable_tls\n"
+      "enable_objc_gc\n"
+      "with_dwarf2\n"
+      "enable_shared\n"
+      "with_build_sysroot\n"
+      "with_sysroot\n"
+      "with_specs\n"
+      "with_pkgversion\n"
+      "with_bugurl\n"
+      "enable_languages\n"
+      "with_multilib_list\n";
+    const char *needle = "\n"
+      "with_gnu_ld\n";
+    const char* p = memmem (haystack, strlen (haystack),
+                            needle, strlen (needle));
+    ASSERT (p - haystack == 114);
+  }
+
+  {
+    /* Same bug, shorter trigger.  */
+    const char *haystack = "..wi.d.";
+    const char *needle = ".d.";
+    const char* p = memmem (haystack, strlen (haystack),
+                            needle, strlen (needle));
+    ASSERT (p - haystack == 4);
+  }
+
+  {
+    /* Like the above, but trigger the flaw in two_way_long_needle
+       by using a needle of length LONG_NEEDLE_THRESHOLD (32) or greater.
+       Rather than trying to find the right alignment manually, I've
+       arbitrarily chosen the following needle and template for the
+       haystack, and ensure that for each placement of the needle in
+       that haystack, memmem finds it.  */
+    const char *needle = "\nwith_gnu_ld-extend-to-len-32-b\n";
+    const char *h =
+      "\n"
+      "with_build_libsubdir\n"
+      "with_local_prefix\n"
+      "with_gxx_include_dir\n"
+      "with_cpp_install_dir\n"
+      "with_e_\n"
+      "..............................\n"
+      "with_FGHIJKLMNOPQRSTUVWXYZ\n"
+      "with_567890123456789\n"
+      "with_multilib_list\n";
+    size_t h_len = strlen (h);
+    char *haystack = malloc (h_len + 1);
+    size_t i;
+    ASSERT (haystack);
+    for (i = 0; i < h_len - strlen (needle); i++)
+      {
+        const char *p;
+        memcpy (haystack, h, h_len + 1);
+        memcpy (haystack + i, needle, strlen (needle) + 1);
+        p = memmem (haystack, strlen (haystack), needle, strlen (needle));
+        ASSERT (p);
+        ASSERT (p - haystack == i);
+      }
+  }
+
   return 0;
 }
new file mode 100644
--- /dev/null
+++ b/tests/test-nonblocking.c
@@ -0,0 +1,128 @@
+/* Test manipulation of non-blocking flag.
+   Copyright (C) 2011 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 <ebb9@byu.net>, 2011.  */
+
+#include <config.h>
+
+#include "nonblocking.h"
+
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/socket.h>
+#include <unistd.h>
+
+#include "macros.h"
+
+int
+main (void)
+{
+  const char *file = "test-nonblock.tmp";
+  int fd_file;
+  int fd_pipe[2];
+  int fd_sock;
+  bool sock_works = true;
+
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+  /* For now, we can't get nonblocking status of windows sockets.  */
+  sock_works = false;
+#endif
+
+  fd_file = creat (file, 0600);
+
+  /* Assume std descriptors were provided by invoker.  */
+  ASSERT (STDERR_FILENO < fd_file);
+
+  /* Test regular files; setting nonblocking on file is unspecified.  */
+  ASSERT (get_nonblocking_flag (fd_file) == 0);
+  ASSERT (set_nonblocking_flag (fd_file, false) == 0);
+  ASSERT (get_nonblocking_flag (fd_file) == 0);
+  ASSERT (close (fd_file) == 0);
+  ASSERT (unlink (file) == 0);
+
+  /* Test directories; setting nonblocking is unspecified.  */
+  fd_file = open (".", O_RDONLY);
+  if (STDERR_FILENO < fd_file)
+    {
+      /* mingw can't open directories unless fchdir module is active.  */
+      ASSERT (get_nonblocking_flag (fd_file) == 0);
+      ASSERT (set_nonblocking_flag (fd_file, false) == 0);
+      ASSERT (get_nonblocking_flag (fd_file) == 0);
+      ASSERT (close (fd_file) == 0);
+    }
+
+  /* Test pipes.  */
+  ASSERT (pipe (fd_pipe) == 0);
+  ASSERT (get_nonblocking_flag (fd_pipe[0]) == 0);
+  ASSERT (get_nonblocking_flag (fd_pipe[1]) == 0);
+  ASSERT (set_nonblocking_flag (fd_pipe[0], true) == 0);
+  ASSERT (get_nonblocking_flag (fd_pipe[0]) == 1);
+  ASSERT (get_nonblocking_flag (fd_pipe[1]) == 0);
+  ASSERT (set_nonblocking_flag (fd_pipe[1], true) == 0);
+  ASSERT (set_nonblocking_flag (fd_pipe[0], false) == 0);
+  ASSERT (get_nonblocking_flag (fd_pipe[0]) == 0);
+  ASSERT (get_nonblocking_flag (fd_pipe[1]) == 1);
+  ASSERT (close (fd_pipe[0]) == 0);
+  ASSERT (close (fd_pipe[1]) == 0);
+
+#if GNULIB_TEST_PIPE2
+  /* mingw still lacks O_NONBLOCK replacement.  */
+  ASSERT (pipe2 (fd_pipe, O_NONBLOCK) == 0);
+  ASSERT (get_nonblocking_flag (fd_pipe[0]) == !!O_NONBLOCK);
+  ASSERT (get_nonblocking_flag (fd_pipe[1]) == !!O_NONBLOCK);
+  ASSERT (close (fd_pipe[0]) == 0);
+  ASSERT (close (fd_pipe[1]) == 0);
+#endif /* GNULIB_TEST_PIPE2 */
+
+  /* Test sockets.  */
+  fd_sock = socket (AF_INET, SOCK_STREAM, 0);
+  ASSERT (get_nonblocking_flag (fd_sock) == (sock_works ? 0 : -1));
+  ASSERT (set_nonblocking_flag (fd_sock, true) == 0);
+  ASSERT (get_nonblocking_flag (fd_sock) == (sock_works ? 1 : -1));
+  ASSERT (set_nonblocking_flag (fd_sock, false) == 0);
+  ASSERT (get_nonblocking_flag (fd_sock) == (sock_works ? 0 : -1));
+  ASSERT (close (fd_sock) == 0);
+
+#if SOCK_NONBLOCK
+  fd_sock = socket (AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0);
+  ASSERT (get_nonblocking_flag (fd_sock) == (sock_works ? 1 : -1));
+  ASSERT (close (fd_sock) == 0);
+#endif /* SOCK_NONBLOCK */
+
+  /* Test error handling.  */
+  {
+    errno = 0;
+    ASSERT (get_nonblocking_flag (-1) == -1);
+    ASSERT (errno == EBADF);
+  }
+  {
+    errno = 0;
+    ASSERT (set_nonblocking_flag (-1, false) == -1);
+    ASSERT (errno == EBADF);
+  }
+  {
+    errno = 0;
+    ASSERT (set_nonblocking_flag (-1, true) == -1);
+    ASSERT (errno == EBADF);
+  }
+  {
+    errno = 0;
+    ASSERT (set_nonblocking_flag (10000000, false) == -1);
+    ASSERT (errno == EBADF);
+  }
+
+  return 0;
+}
new file mode 100644
--- /dev/null
+++ b/tests/test-passfd.c
@@ -0,0 +1,118 @@
+/* Test of passing file descriptors.
+   Copyright (C) 2011 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/>.  */
+
+#include <config.h>
+
+#include "passfd.h"
+
+#include <fcntl.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+
+#include "macros.h"
+
+int
+main ()
+{
+  int pair[2];
+  int ret;
+  pid_t pid;
+  int status;
+  int fdnull;
+  int fd;
+  struct stat st;
+
+#if HAVE_DECL_ALARM
+  /* Avoid hanging on failure.  */
+  signal (SIGALRM, SIG_DFL);
+  alarm (5);
+#endif
+
+  fdnull = open ("/dev/null", O_RDWR);
+  if (fdnull < 0)
+    {
+      perror ("Could not open /dev/null");
+      return 1;
+    }
+
+  ret = socketpair (AF_UNIX, SOCK_STREAM, 0, pair);
+  if (ret < 0)
+    {
+      perror ("socket pair failed");
+      return 2;
+    }
+
+  pid = fork ();
+  if (pid == -1)
+    {
+      perror ("fork");
+      return 3;
+    }
+  if (pid == 0)
+    {
+      ret = sendfd (pair[1], fdnull);
+      if (ret == -1)
+        {
+          perror ("sendfd");
+          return 64;
+        }
+      return 0;
+    }
+  /* father */
+  else
+    {
+      fd = recvfd (pair[0], 0);
+      if (fd == -1)
+        {
+          perror ("recvfd");
+          return 16;
+        }
+      ret = waitpid (pid, &status, 0);
+      if (ret == -1)
+        {
+          perror ("waitpid");
+          return 17;
+        }
+      ASSERT (ret == pid);
+
+      if (!WIFEXITED (status))
+        {
+          fprintf (stderr, "Child does not normally exit\n");
+          return 65;
+        }
+      ret = WEXITSTATUS (status);
+      if (ret != 0)
+        {
+          fprintf (stderr, "Send fd fail\n");
+          return ret;
+        }
+
+      /* try to stat new fd */
+      ret = fstat (fd, &st);
+      if (ret < 0)
+        {
+          perror ("fstat");
+          return 80;
+        }
+      return 0;
+    }
+}
--- a/tests/test-quotearg.sh
+++ b/tests/test-quotearg.sh
@@ -12,5 +12,15 @@
   fi
 fi
 
+# Work around a limitation of gettext() on native Windows in gettext 0.18.1:
+# the locale identifiers in the environment variables LC_ALL etc. have to
+# be in Unix conventions, not in native Window conventions.
+if test $locale = French_France.65001; then
+  locale=fr_FR.UTF-8
+fi
+if test $locale = French_France.1252; then
+  locale=fr_FR.CP1252
+fi
+
 LOCALE=$locale LOCALEDIR="$srcdir/locale" \
 ./test-quotearg${EXEEXT}
--- a/tests/test-readlink.h
+++ b/tests/test-readlink.h
@@ -38,7 +38,7 @@
   ASSERT (errno == ENOENT);
   errno = 0;
   ASSERT (func ("", buf, sizeof buf) == -1);
-  ASSERT (errno == ENOENT);
+  ASSERT (errno == ENOENT || errno == EINVAL);
   errno = 0;
   ASSERT (func (".", buf, sizeof buf) == -1);
   ASSERT (errno == EINVAL);
--- a/tests/test-regex-quote.c
+++ b/tests/test-regex-quote.c
@@ -29,18 +29,37 @@
 static void
 check (const char *literal, int cflags, const char *expected)
 {
+  struct regex_quote_spec spec;
   char *result;
   size_t length;
 
-  result = regex_quote (literal, cflags);
+  spec = regex_quote_spec_posix (cflags, false);
+  result = regex_quote (literal, &spec);
   ASSERT (strcmp (result, expected) == 0);
-  length = regex_quote_length (literal, cflags);
+  length = regex_quote_length (literal, &spec);
   ASSERT (length == strlen (result));
   free (result);
 
   result = (char *) xmalloc (1 + length + 1 + 1);
   result[0] = '^';
-  strcpy (regex_quote_copy (result + 1, literal, cflags), "$");
+  strcpy (regex_quote_copy (result + 1, literal, &spec), "$");
+  {
+    regex_t regex;
+    regmatch_t match[1];
+
+    ASSERT (regcomp (&regex, result, cflags) == 0);
+
+    ASSERT (regexec (&regex, literal, 1, match, 0) == 0);
+    ASSERT (match[0].rm_so == 0);
+    ASSERT (match[0].rm_eo == strlen (literal));
+    regfree (&regex);
+  }
+  free (result);
+
+  spec = regex_quote_spec_posix (cflags, true);
+  result = regex_quote (literal, &spec);
+  length = regex_quote_length (literal, &spec);
+  ASSERT (length == strlen (result));
   {
     regex_t regex;
     regmatch_t match[1];
new file mode 100644
--- /dev/null
+++ b/tests/test-setlocale1.c
@@ -0,0 +1,59 @@
+/* Test of setting the current locale.
+   Copyright (C) 2011 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/>.  */
+
+#include <config.h>
+
+#include <locale.h>
+
+#include "signature.h"
+SIGNATURE_CHECK (setlocale, char *, (int, const char *));
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "macros.h"
+
+int
+main (int argc, char *argv[])
+{
+  char *name1;
+  char *name2;
+
+  /* Try to set the locale by implicitly looking at the LC_ALL environment
+     variable.
+     configure should already have checked that the locale is supported.  */
+  if (setlocale (LC_ALL, "") == NULL)
+    return 1;
+
+  name1 = strdup (setlocale (LC_ALL, NULL));
+
+  /* Reset the locale.  */
+  if (setlocale (LC_ALL, "C") == NULL)
+    return 1;
+
+  /* Try to set the locale by explicitly looking at the LC_ALL environment
+     variable.
+     configure should already have checked that the locale is supported.  */
+  if (setlocale (LC_ALL, getenv ("LC_ALL")) == NULL)
+    return 1;
+
+  name2 = strdup (setlocale (LC_ALL, NULL));
+
+  /* Test that the two results are the same.  */
+  ASSERT (strcmp (name1, name2) == 0);
+
+  return 0;
+}
new file mode 100755
--- /dev/null
+++ b/tests/test-setlocale1.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+: ${LOCALE_FR=fr_FR}
+: ${LOCALE_FR_UTF8=fr_FR.UTF-8}
+: ${LOCALE_JA=ja_JP}
+: ${LOCALE_ZH_CN=zh_CN.GB18030}
+
+if test $LOCALE_FR = none && test $LOCALE_FR_UTF8 = none \
+   && test $LOCALE_JA = none && test $LOCALE_ZH_CN = none; then
+  if test -f /usr/bin/localedef; then
+    echo "Skipping test: no locale for testing is installed"
+  else
+    echo "Skipping test: no locale for testing is supported"
+  fi
+  exit 77
+fi
+
+if test $LOCALE_FR != none; then
+  LC_ALL=$LOCALE_FR      ./test-setlocale1${EXEEXT} || exit 1
+fi
+
+if test $LOCALE_FR_UTF8 != none; then
+  LC_ALL=$LOCALE_FR_UTF8 ./test-setlocale1${EXEEXT} || exit 1
+fi
+
+if test $LOCALE_JA != none; then
+  LC_ALL=$LOCALE_JA      ./test-setlocale1${EXEEXT} || exit 1
+fi
+
+if test $LOCALE_ZH_CN != none; then
+  LC_ALL=$LOCALE_ZH_CN   ./test-setlocale1${EXEEXT} || exit 1
+fi
+
+exit 0
new file mode 100644
--- /dev/null
+++ b/tests/test-setlocale2.c
@@ -0,0 +1,55 @@
+/* Test of setting the current locale.
+   Copyright (C) 2011 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/>.  */
+
+#include <config.h>
+
+#include <locale.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int
+main ()
+{
+  /* Try to set the locale by implicitly looking at the LC_ALL environment
+     variable.  */
+  if (setlocale (LC_ALL, "") != NULL)
+    /* It was successful.  Check whether LC_CTYPE is non-trivial.  */
+    if (strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
+      {
+        fprintf (stderr, "setlocale did not fail for implicit %s\n",
+                 getenv ("LC_ALL"));
+        return 1;
+      }
+
+  /* Reset the locale.  */
+  if (setlocale (LC_ALL, "C") == NULL)
+    return 1;
+
+  /* Try to set the locale by explicitly looking at the LC_ALL environment
+     variable.  */
+  if (setlocale (LC_ALL, getenv ("LC_ALL")) != NULL)
+    /* It was successful.  Check whether LC_CTYPE is non-trivial.  */
+    if (strcmp (setlocale (LC_CTYPE, NULL), "C") == 0)
+      {
+        fprintf (stderr, "setlocale did not fail for explicit %s\n",
+                 getenv ("LC_ALL"));
+        return 1;
+      }
+
+  return 0;
+}
new file mode 100755
--- /dev/null
+++ b/tests/test-setlocale2.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Test locale names with likely unsupported encoding in Unix syntax.
+for name in ar_SA.ISO-8859-1 fr_FR.CP1251 zh_TW.GB18030 zh_CN.BIG5; do
+  LC_ALL=$name ./test-setlocale2${EXEEXT} 1 || exit 1
+done
+
+# Test locale names with likely unsupported encoding in native Windows syntax.
+for name in "Arabic_Saudi Arabia.1252" "Arabic_Saudi Arabia.65001" \
+            French_France.65001 Japanese_Japan.65001 Turkish_Turkey.65001 \
+            Chinese_Taiwan.65001 Chinese_China.54936 Chinese_China.65001; do
+  LC_ALL=$name ./test-setlocale2${EXEEXT} 1 || exit 1
+done
+
+exit 0
--- a/tests/test-stdlib-c++.cc
+++ b/tests/test-stdlib-c++.cc
@@ -60,6 +60,11 @@
 SIGNATURE_CHECK (GNULIB_NAMESPACE::malloc, void *, (size_t));
 #endif
 
+#if GNULIB_TEST_MBTOWC
+SIGNATURE_CHECK (GNULIB_NAMESPACE::mbtowc, int,
+                 (wchar_t *, const char *, size_t));
+#endif
+
 #if GNULIB_TEST_MKDTEMP
 SIGNATURE_CHECK (GNULIB_NAMESPACE::mkdtemp, char *, (char *));
 #endif
@@ -147,6 +152,10 @@
 SIGNATURE_CHECK (GNULIB_NAMESPACE::unsetenv, int, (const char *));
 #endif
 
+#if GNULIB_TEST_WCTOMB
+SIGNATURE_CHECK (GNULIB_NAMESPACE::wctomb, int, (char *, wchar_t));
+#endif
+
 
 int
 main ()
--- a/tests/test-strcasestr.c
+++ b/tests/test-strcasestr.c
@@ -162,5 +162,93 @@
     free (haystack);
   }
 
+  {
+    /* Ensure that with a barely periodic "short" needle, strcasestr's
+       search does not mistakenly skip just past the match point.
+       This use of strcasestr would mistakenly return NULL before
+       gnulib v0.0-4927.  */
+    const char *haystack =
+      "\n"
+      "with_build_libsubdir\n"
+      "with_local_prefix\n"
+      "with_gxx_include_dir\n"
+      "with_cpp_install_dir\n"
+      "enable_generated_files_in_srcdir\n"
+      "with_gnu_ld\n"
+      "with_ld\n"
+      "with_demangler_in_ld\n"
+      "with_gnu_as\n"
+      "with_as\n"
+      "enable_largefile\n"
+      "enable_werror_always\n"
+      "enable_checking\n"
+      "enable_coverage\n"
+      "enable_gather_detailed_mem_stats\n"
+      "enable_build_with_cxx\n"
+      "with_stabs\n"
+      "enable_multilib\n"
+      "enable___cxa_atexit\n"
+      "enable_decimal_float\n"
+      "enable_fixed_point\n"
+      "enable_threads\n"
+      "enable_tls\n"
+      "enable_objc_gc\n"
+      "with_dwarf2\n"
+      "enable_shared\n"
+      "with_build_sysroot\n"
+      "with_sysroot\n"
+      "with_specs\n"
+      "with_pkgversion\n"
+      "with_bugurl\n"
+      "enable_languages\n"
+      "with_multilib_list\n";
+    const char *needle = "\n"
+      "with_GNU_ld\n";
+    const char* p = strcasestr (haystack, needle);
+    ASSERT (p - haystack == 114);
+  }
+
+  {
+    /* Same bug, shorter trigger.  */
+    const char *haystack = "..wi.D.";
+    const char *needle = ".d.";
+    const char* p = strcasestr (haystack, needle);
+    ASSERT (p - haystack == 4);
+  }
+
+  {
+    /* Like the above, but trigger the flaw in two_way_long_needle
+       by using a needle of length LONG_NEEDLE_THRESHOLD (32) or greater.
+       Rather than trying to find the right alignment manually, I've
+       arbitrarily chosen the following needle and template for the
+       haystack, and ensure that for each placement of the needle in
+       that haystack, strcasestr finds it.  */
+    const char *needle = "\nwith_gnu_ld-extend-to-len-32-b\n";
+    const char *h =
+      "\n"
+      "with_build_libsubdir\n"
+      "with_local_prefix\n"
+      "with_gxx_include_dir\n"
+      "with_cpp_install_dir\n"
+      "with_e_\n"
+      "..............................\n"
+      "with_FGHIJKLMNOPQRSTUVWXYZ\n"
+      "with_567890123456789\n"
+      "with_multilib_list\n";
+    size_t h_len = strlen (h);
+    char *haystack = malloc (h_len + 1);
+    size_t i;
+    ASSERT (haystack);
+    for (i = 0; i < h_len - strlen (needle); i++)
+      {
+        const char *p;
+        memcpy (haystack, h, h_len + 1);
+        memcpy (haystack + i, needle, strlen (needle) + 1);
+        p = strcasestr (haystack, needle);
+        ASSERT (p);
+        ASSERT (p - haystack == i);
+      }
+  }
+
   return 0;
 }
--- a/tests/test-strerror_r.c
+++ b/tests/test-strerror_r.c
@@ -74,8 +74,8 @@
         if (ret == 0)
           {
             /* Truncated result.  POSIX allows this, and it actually
-               happens on AIX 6.1.  */
-            ASSERT (strcmp (buf, "BADFACE") != 0);
+               happens on AIX 6.1 and Cygwin.  */
+            ASSERT ((strcmp (buf, "BADFACE") == 0) == (i == 0));
           }
         else
           {
new file mode 100644
--- /dev/null
+++ b/tests/test-strftime.c
@@ -0,0 +1,82 @@
+/* Test that posixtime works as required.
+   Copyright (C) 2011 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 Jim Meyering.  */
+
+#include <config.h>
+
+#include "strftime.h"
+
+#include <stdio.h>
+#include <time.h>
+#include <string.h>
+
+#include "macros.h"
+#define STREQ(a, b) (strcmp (a, b) == 0)
+
+struct posixtm_test
+{
+  time_t in;
+  int in_ns;
+  char const *fmt;
+  char const *exp;
+};
+
+static struct posixtm_test const T[] =
+  {
+    { 1300000000, 0,            "%F", "2011-03-13" },
+    { 0,          0,            NULL, NULL }
+  };
+
+int
+main (void)
+{
+  int fail = 0;
+  unsigned int i;
+
+  for (i = 0; T[i].fmt; i++)
+    {
+      char buf[1000];
+      time_t t = T[i].in;
+      struct tm *tm = gmtime (&t);
+      size_t n;
+      int utc = 1;
+
+      ASSERT (tm);
+
+      n = nstrftime (buf, sizeof buf, T[i].fmt, tm, utc, T[i].in_ns);
+      if (n == 0)
+        {
+          fail = 1;
+          printf ("nstrftime failed with format %s\n", T[i].fmt);
+        }
+
+      if (! STREQ (buf, T[i].exp))
+        {
+          fail = 1;
+          printf ("%s: result mismatch: got %s, expected %s\n",
+                  T[i].fmt, buf, T[i].exp);
+        }
+    }
+
+  return fail;
+}
+
+/*
+Local Variables:
+indent-tabs-mode: nil
+End:
+*/
--- a/tests/test-strstr.c
+++ b/tests/test-strstr.c
@@ -184,5 +184,94 @@
   /* Sublinear speed is only possible in memmem; strstr must examine
      every character of haystack to find its length.  */
 
+
+  {
+    /* Ensure that with a barely periodic "short" needle, strstr's
+       search does not mistakenly skip just past the match point.
+       This use of strstr would mistakenly return NULL before
+       gnulib v0.0-4927.  */
+    const char *haystack =
+      "\n"
+      "with_build_libsubdir\n"
+      "with_local_prefix\n"
+      "with_gxx_include_dir\n"
+      "with_cpp_install_dir\n"
+      "enable_generated_files_in_srcdir\n"
+      "with_gnu_ld\n"
+      "with_ld\n"
+      "with_demangler_in_ld\n"
+      "with_gnu_as\n"
+      "with_as\n"
+      "enable_largefile\n"
+      "enable_werror_always\n"
+      "enable_checking\n"
+      "enable_coverage\n"
+      "enable_gather_detailed_mem_stats\n"
+      "enable_build_with_cxx\n"
+      "with_stabs\n"
+      "enable_multilib\n"
+      "enable___cxa_atexit\n"
+      "enable_decimal_float\n"
+      "enable_fixed_point\n"
+      "enable_threads\n"
+      "enable_tls\n"
+      "enable_objc_gc\n"
+      "with_dwarf2\n"
+      "enable_shared\n"
+      "with_build_sysroot\n"
+      "with_sysroot\n"
+      "with_specs\n"
+      "with_pkgversion\n"
+      "with_bugurl\n"
+      "enable_languages\n"
+      "with_multilib_list\n";
+    const char *needle = "\n"
+      "with_gnu_ld\n";
+    const char* p = strstr (haystack, needle);
+    ASSERT (p - haystack == 114);
+  }
+
+  {
+    /* Same bug, shorter trigger.  */
+    const char *haystack = "..wi.d.";
+    const char *needle = ".d.";
+    const char* p = strstr (haystack, needle);
+    ASSERT (p - haystack == 4);
+  }
+
+  {
+    /* Like the above, but trigger the flaw in two_way_long_needle
+       by using a needle of length LONG_NEEDLE_THRESHOLD (32) or greater.
+       Rather than trying to find the right alignment manually, I've
+       arbitrarily chosen the following needle and template for the
+       haystack, and ensure that for each placement of the needle in
+       that haystack, strstr finds it.  */
+    const char *needle = "\nwith_gnu_ld-extend-to-len-32-b\n";
+    const char *h =
+      "\n"
+      "with_build_libsubdir\n"
+      "with_local_prefix\n"
+      "with_gxx_include_dir\n"
+      "with_cpp_install_dir\n"
+      "with_e_\n"
+      "..............................\n"
+      "with_FGHIJKLMNOPQRSTUVWXYZ\n"
+      "with_567890123456789\n"
+      "with_multilib_list\n";
+    size_t h_len = strlen (h);
+    char *haystack = malloc (h_len + 1);
+    size_t i;
+    ASSERT (haystack);
+    for (i = 0; i < h_len - strlen (needle); i++)
+      {
+        const char *p;
+        memcpy (haystack, h, h_len + 1);
+        memcpy (haystack + i, needle, strlen (needle) + 1);
+        p = strstr (haystack, needle);
+        ASSERT (p);
+        ASSERT (p - haystack == i);
+      }
+  }
+
   return 0;
 }
--- a/tests/test-wchar-c++.cc
+++ b/tests/test-wchar-c++.cc
@@ -75,6 +75,142 @@
 SIGNATURE_CHECK (GNULIB_NAMESPACE::wcwidth, int, (wchar_t));
 #endif
 
+#if GNULIB_TEST_WMEMCHR
+SIGNATURE_CHECK (GNULIB_NAMESPACE::wmemchr, wchar_t *,
+                 (const wchar_t *, wchar_t, size_t));
+#endif
+
+#if GNULIB_TEST_WMEMCMP
+SIGNATURE_CHECK (GNULIB_NAMESPACE::wmemcmp, int,
+                 (const wchar_t *, const wchar_t *, size_t));
+#endif
+
+#if GNULIB_TEST_WMEMCPY
+SIGNATURE_CHECK (GNULIB_NAMESPACE::wmemcpy, wchar_t *,
+                 (wchar_t *, const wchar_t *, size_t));
+#endif
+
+#if GNULIB_TEST_WMEMMOVE
+SIGNATURE_CHECK (GNULIB_NAMESPACE::wmemmove, wchar_t *,
+                 (wchar_t *, const wchar_t *, size_t));
+#endif
+
+#if GNULIB_TEST_WMEMSET
+SIGNATURE_CHECK (GNULIB_NAMESPACE::wmemset, wchar_t *,
+                 (wchar_t *, wchar_t, size_t));
+#endif
+
+#if GNULIB_TEST_WCSLEN
+SIGNATURE_CHECK (GNULIB_NAMESPACE::wcslen, size_t, (const wchar_t *));
+#endif
+
+#if GNULIB_TEST_WCSNLEN
+SIGNATURE_CHECK (GNULIB_NAMESPACE::wcsnlen, size_t, (const wchar_t *, size_t));
+#endif
+
+#if GNULIB_TEST_WCSCPY
+SIGNATURE_CHECK (GNULIB_NAMESPACE::wcscpy, wchar_t *,
+                 (wchar_t *, const wchar_t *));
+#endif
+
+#if GNULIB_TEST_WCPCPY
+SIGNATURE_CHECK (GNULIB_NAMESPACE::wcpcpy, wchar_t *,
+                 (wchar_t *, const wchar_t *));
+#endif
+
+#if GNULIB_TEST_WCSNCPY
+SIGNATURE_CHECK (GNULIB_NAMESPACE::wcsncpy, wchar_t *,
+                 (wchar_t *, const wchar_t *, size_t));
+#endif
+
+#if GNULIB_TEST_WCPNCPY
+SIGNATURE_CHECK (GNULIB_NAMESPACE::wcpncpy, wchar_t *,
+                 (wchar_t *, const wchar_t *, size_t));
+#endif
+
+#if GNULIB_TEST_WCSCAT
+SIGNATURE_CHECK (GNULIB_NAMESPACE::wcscat, wchar_t *,
+                 (wchar_t *, const wchar_t *));
+#endif
+
+#if GNULIB_TEST_WCSNCAT
+SIGNATURE_CHECK (GNULIB_NAMESPACE::wcsncat, wchar_t *,
+                 (wchar_t *, const wchar_t *, size_t));
+#endif
+
+#if GNULIB_TEST_WCSCMP
+SIGNATURE_CHECK (GNULIB_NAMESPACE::wcscmp, int,
+                 (const wchar_t *, const wchar_t *));
+#endif
+
+#if GNULIB_TEST_WCSNCMP
+SIGNATURE_CHECK (GNULIB_NAMESPACE::wcsncmp, int,
+                 (const wchar_t *, const wchar_t *, size_t));
+#endif
+
+#if GNULIB_TEST_WCSCASECMP
+SIGNATURE_CHECK (GNULIB_NAMESPACE::wcscasecmp, int,
+                 (const wchar_t *, const wchar_t *));
+#endif
+
+#if GNULIB_TEST_WCSNCASECMP
+SIGNATURE_CHECK (GNULIB_NAMESPACE::wcsncasecmp, int,
+                 (const wchar_t *, const wchar_t *, size_t));
+#endif
+
+#if GNULIB_TEST_WCSCOLL
+SIGNATURE_CHECK (GNULIB_NAMESPACE::wcscoll, int,
+                 (const wchar_t *, const wchar_t *));
+#endif
+
+#if GNULIB_TEST_WCSXFRM
+SIGNATURE_CHECK (GNULIB_NAMESPACE::wcsxfrm, size_t,
+                 (wchar_t *, const wchar_t *, size_t));
+#endif
+
+#if GNULIB_TEST_WCSDUP
+SIGNATURE_CHECK (GNULIB_NAMESPACE::wcsdup, wchar_t *, (const wchar_t *));
+#endif
+
+#if GNULIB_TEST_WCSCHR
+SIGNATURE_CHECK (GNULIB_NAMESPACE::wcschr, wchar_t *,
+                 (const wchar_t *, wchar_t));
+#endif
+
+#if GNULIB_TEST_WCSRCHR
+SIGNATURE_CHECK (GNULIB_NAMESPACE::wcsrchr, wchar_t *,
+                 (const wchar_t *, wchar_t));
+#endif
+
+#if GNULIB_TEST_WCSCSPN
+SIGNATURE_CHECK (GNULIB_NAMESPACE::wcscspn, size_t,
+                 (const wchar_t *, const wchar_t *));
+#endif
+
+#if GNULIB_TEST_WCSSPN
+SIGNATURE_CHECK (GNULIB_NAMESPACE::wcsspn, size_t,
+                 (const wchar_t *, const wchar_t *));
+#endif
+
+#if GNULIB_TEST_WCSPBRK
+SIGNATURE_CHECK (GNULIB_NAMESPACE::wcspbrk, wchar_t *,
+                 (const wchar_t *, const wchar_t *));
+#endif
+
+#if GNULIB_TEST_WCSSTR
+SIGNATURE_CHECK (GNULIB_NAMESPACE::wcsstr, wchar_t *,
+                 (const wchar_t *, const wchar_t *));
+#endif
+
+#if GNULIB_TEST_WCSTOK
+SIGNATURE_CHECK (GNULIB_NAMESPACE::wcstok, wchar_t *,
+                 (wchar_t *, const wchar_t *, wchar_t **));
+#endif
+
+#if GNULIB_TEST_WCSWIDTH
+SIGNATURE_CHECK (GNULIB_NAMESPACE::wcswidth, int, (const wchar_t *, size_t));
+#endif
+
 
 int
 main ()
new file mode 100755
--- /dev/null
+++ b/tests/test-wcrtomb-w32-1.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+# Test a CP1252 locale.
+./test-wcrtomb-w32${EXEEXT} French_France 1252
new file mode 100755
--- /dev/null
+++ b/tests/test-wcrtomb-w32-2.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+# Test a CP1256 locale.
+./test-wcrtomb-w32${EXEEXT} "Arabic_Saudi Arabia" 1256
new file mode 100755
--- /dev/null
+++ b/tests/test-wcrtomb-w32-3.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+# Test a CP932 locale.
+./test-wcrtomb-w32${EXEEXT} Japanese_Japan 932
new file mode 100755
--- /dev/null
+++ b/tests/test-wcrtomb-w32-4.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+# Test a CP950 locale.
+./test-wcrtomb-w32${EXEEXT} Chinese_Taiwan 950
new file mode 100755
--- /dev/null
+++ b/tests/test-wcrtomb-w32-5.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+# Test a CP936 locale.
+./test-wcrtomb-w32${EXEEXT} Chinese_China 936
new file mode 100755
--- /dev/null
+++ b/tests/test-wcrtomb-w32-6.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+# This test is not enabled by default, because MSVCRT does not support and
+# will likely never support locales with MB_CUR_MAX > 2.
+
+# Test a GB18030 locale.
+./test-wcrtomb-w32${EXEEXT} Chinese_China 54936
new file mode 100755
--- /dev/null
+++ b/tests/test-wcrtomb-w32-7.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+# This test is not enabled by default, because MSVCRT does not support and
+# will likely never support locales with MB_CUR_MAX > 2.
+
+# Test some UTF-8 locales.
+./test-wcrtomb-w32${EXEEXT} French_France Japanese_Japan Chinese_Taiwan Chinese_China 65001
new file mode 100644
--- /dev/null
+++ b/tests/test-wcrtomb-w32.c
@@ -0,0 +1,332 @@
+/* Test of conversion of wide character to multibyte character.
+   Copyright (C) 2008-2011 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/>.  */
+
+#include <config.h>
+
+#include <wchar.h>
+
+#include <locale.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "macros.h"
+
+#if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
+
+static int
+test_one_locale (const char *name, int codepage)
+{
+  char buf[64];
+  size_t ret;
+
+# if 1
+  /* Portable code to set the locale.  */
+  {
+    char name_with_codepage[1024];
+
+    sprintf (name_with_codepage, "%s.%d", name, codepage);
+
+    /* Set the locale.  */
+    if (setlocale (LC_ALL, name_with_codepage) == NULL)
+      return 77;
+  }
+# else
+  /* Hacky way to set a locale.codepage combination that setlocale() refuses
+     to set.  */
+  {
+    /* Codepage of the current locale, set with setlocale().
+       Not necessarily the same as GetACP().  */
+    extern __declspec(dllimport) unsigned int __lc_codepage;
+
+    /* Set the locale.  */
+    if (setlocale (LC_ALL, name) == NULL)
+      return 77;
+
+    /* Clobber the codepage and MB_CUR_MAX, both set by setlocale().  */
+    __lc_codepage = codepage;
+    switch (codepage)
+      {
+      case 1252:
+      case 1256:
+        MB_CUR_MAX = 1;
+        break;
+      case 932:
+      case 950:
+      case 936:
+        MB_CUR_MAX = 2;
+        break;
+      case 54936:
+      case 65001:
+        MB_CUR_MAX = 4;
+        break;
+      }
+
+    /* Test whether the codepage is really available.  */
+    {
+      mbstate_t state;
+      wchar_t wc;
+
+      memset (&state, '\0', sizeof (mbstate_t));
+      if (mbrtowc (&wc, " ", 1, &state) == (size_t)(-1))
+        return 77;
+    }
+  }
+# endif
+
+  /* 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;
+        }
+  }
+
+  /* Test special calling convention, passing a NULL pointer.  */
+  {
+    ret = wcrtomb (NULL, '\0', NULL);
+    ASSERT (ret == 1);
+    ret = wcrtomb (NULL, btowc ('x'), NULL);
+    ASSERT (ret == 1);
+  }
+
+  switch (codepage)
+    {
+    case 1252:
+      /* Locale encoding is CP1252, an extension of ISO-8859-1.  */
+      {
+        /* Convert "B\374\337er": "Büßer" */
+        memset (buf, 'x', 8);
+        ret = wcrtomb (buf, 0x00FC, NULL);
+        ASSERT (ret == 1);
+        ASSERT (memcmp (buf, "\374", 1) == 0);
+        ASSERT (buf[1] == 'x');
+
+        memset (buf, 'x', 8);
+        ret = wcrtomb (buf, 0x00DF, NULL);
+        ASSERT (ret == 1);
+        ASSERT (memcmp (buf, "\337", 1) == 0);
+        ASSERT (buf[1] == 'x');
+      }
+      return 0;
+
+    case 1256:
+      /* Locale encoding is CP1256, not the same as ISO-8859-6.  */
+      {
+        /* Convert "x\302\341\346y": "xآلوy" */
+        memset (buf, 'x', 8);
+        ret = wcrtomb (buf, 0x0622, NULL);
+        ASSERT (ret == 1);
+        ASSERT (memcmp (buf, "\302", 1) == 0);
+        ASSERT (buf[1] == 'x');
+
+        memset (buf, 'x', 8);
+        ret = wcrtomb (buf, 0x0644, NULL);
+        ASSERT (ret == 1);
+        ASSERT (memcmp (buf, "\341", 1) == 0);
+        ASSERT (buf[1] == 'x');
+
+        memset (buf, 'x', 8);
+        ret = wcrtomb (buf, 0x0648, NULL);
+        ASSERT (ret == 1);
+        ASSERT (memcmp (buf, "\346", 1) == 0);
+        ASSERT (buf[1] == 'x');
+      }
+      return 0;
+
+    case 932:
+      /* Locale encoding is CP932, similar to Shift_JIS.  */
+      {
+        /* Convert "<\223\372\226\173\214\352>": "<日本語>" */
+        memset (buf, 'x', 8);
+        ret = wcrtomb (buf, 0x65E5, NULL);
+        ASSERT (ret == 2);
+        ASSERT (memcmp (buf, "\223\372", 2) == 0);
+        ASSERT (buf[2] == 'x');
+
+        memset (buf, 'x', 8);
+        ret = wcrtomb (buf, 0x672C, NULL);
+        ASSERT (ret == 2);
+        ASSERT (memcmp (buf, "\226\173", 2) == 0);
+        ASSERT (buf[2] == 'x');
+
+        memset (buf, 'x', 8);
+        ret = wcrtomb (buf, 0x8A9E, NULL);
+        ASSERT (ret == 2);
+        ASSERT (memcmp (buf, "\214\352", 2) == 0);
+        ASSERT (buf[2] == 'x');
+      }
+      return 0;
+
+    case 950:
+      /* Locale encoding is CP950, similar to Big5.  */
+      {
+        /* Convert "<\244\351\245\273\273\171>": "<日本語>" */
+        memset (buf, 'x', 8);
+        ret = wcrtomb (buf, 0x65E5, NULL);
+        ASSERT (ret == 2);
+        ASSERT (memcmp (buf, "\244\351", 2) == 0);
+        ASSERT (buf[2] == 'x');
+
+        memset (buf, 'x', 8);
+        ret = wcrtomb (buf, 0x672C, NULL);
+        ASSERT (ret == 2);
+        ASSERT (memcmp (buf, "\245\273", 2) == 0);
+        ASSERT (buf[2] == 'x');
+
+        memset (buf, 'x', 8);
+        ret = wcrtomb (buf, 0x8A9E, NULL);
+        ASSERT (ret == 2);
+        ASSERT (memcmp (buf, "\273\171", 2) == 0);
+        ASSERT (buf[2] == 'x');
+      }
+      return 0;
+
+    case 936:
+      /* Locale encoding is CP936 = GBK, an extension of GB2312.  */
+      {
+        /* Convert "<\310\325\261\276\325\132>": "<日本語>" */
+        memset (buf, 'x', 8);
+        ret = wcrtomb (buf, 0x65E5, NULL);
+        ASSERT (ret == 2);
+        ASSERT (memcmp (buf, "\310\325", 2) == 0);
+        ASSERT (buf[2] == 'x');
+
+        memset (buf, 'x', 8);
+        ret = wcrtomb (buf, 0x672C, NULL);
+        ASSERT (ret == 2);
+        ASSERT (memcmp (buf, "\261\276", 2) == 0);
+        ASSERT (buf[2] == 'x');
+
+        memset (buf, 'x', 8);
+        ret = wcrtomb (buf, 0x8A9E, NULL);
+        ASSERT (ret == 2);
+        ASSERT (memcmp (buf, "\325\132", 2) == 0);
+        ASSERT (buf[2] == 'x');
+      }
+      return 0;
+
+    case 54936:
+      /* Locale encoding is CP54936 = GB18030.  */
+      {
+        /* Convert "B\250\271\201\060\211\070er": "Büßer" */
+        memset (buf, 'x', 8);
+        ret = wcrtomb (buf, 0x00FC, NULL);
+        ASSERT (ret == 2);
+        ASSERT (memcmp (buf, "\250\271", 2) == 0);
+        ASSERT (buf[2] == 'x');
+
+        memset (buf, 'x', 8);
+        ret = wcrtomb (buf, 0x00DF, NULL);
+        ASSERT (ret == 4);
+        ASSERT (memcmp (buf, "\201\060\211\070", 4) == 0);
+        ASSERT (buf[4] == 'x');
+      }
+      return 0;
+
+    case 65001:
+      /* Locale encoding is CP65001 = UTF-8.  */
+      {
+        /* Convert "B\303\274\303\237er": "Büßer" */
+        memset (buf, 'x', 8);
+        ret = wcrtomb (buf, 0x00FC, NULL);
+        ASSERT (ret == 2);
+        ASSERT (memcmp (buf, "\303\274", 2) == 0);
+        ASSERT (buf[2] == 'x');
+
+        memset (buf, 'x', 8);
+        ret = wcrtomb (buf, 0x00DF, NULL);
+        ASSERT (ret == 2);
+        ASSERT (memcmp (buf, "\303\237", 2) == 0);
+        ASSERT (buf[2] == 'x');
+      }
+      return 0;
+
+    default:
+      return 1;
+    }
+}
+
+int
+main (int argc, char *argv[])
+{
+  int codepage = atoi (argv[argc - 1]);
+  int result;
+  int i;
+
+  result = 77;
+  for (i = 1; i < argc - 1; i++)
+    {
+      int ret = test_one_locale (argv[i], codepage);
+
+      if (ret != 77)
+        result = ret;
+    }
+
+  if (result == 77)
+    {
+      fprintf (stderr, "Skipping test: found no locale with codepage %d\n",
+               codepage);
+    }
+  return result;
+}
+
+#else
+
+int
+main (int argc, char *argv[])
+{
+  fputs ("Skipping test: not a native Windows system\n", stderr);
+  return 77;
+}
+
+#endif
--- a/tests/test-wcrtomb.c
+++ b/tests/test-wcrtomb.c
@@ -105,6 +105,14 @@
         }
   }
 
+  /* Test special calling convention, passing a NULL pointer.  */
+  {
+    ret = wcrtomb (NULL, '\0', NULL);
+    ASSERT (ret == 1);
+    ret = wcrtomb (NULL, btowc ('x'), NULL);
+    ASSERT (ret == 1);
+  }
+
   if (argc > 1)
     switch (argv[1][0])
       {
deleted file mode 100644
--- a/tests/test-wctype-c++.cc
+++ /dev/null
@@ -1,47 +0,0 @@
-/* Test of <wctype.h> substitute in C++ mode.
-   Copyright (C) 2010-2011 Free Software Foundation, Inc.
-
-   This program is free software: you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-/* Written by Bruno Haible <bruno@clisp.org>, 2010.  */
-
-#define GNULIB_NAMESPACE gnulib
-#include <config.h>
-
-#include <wctype.h>
-
-#include "signature.h"
-
-
-SIGNATURE_CHECK (GNULIB_NAMESPACE::iswalnum, int, (wint_t));
-SIGNATURE_CHECK (GNULIB_NAMESPACE::iswalpha, int, (wint_t));
-SIGNATURE_CHECK (GNULIB_NAMESPACE::iswblank, int, (wint_t));
-SIGNATURE_CHECK (GNULIB_NAMESPACE::iswcntrl, int, (wint_t));
-SIGNATURE_CHECK (GNULIB_NAMESPACE::iswdigit, int, (wint_t));
-SIGNATURE_CHECK (GNULIB_NAMESPACE::iswgraph, int, (wint_t));
-SIGNATURE_CHECK (GNULIB_NAMESPACE::iswlower, int, (wint_t));
-SIGNATURE_CHECK (GNULIB_NAMESPACE::iswprint, int, (wint_t));
-SIGNATURE_CHECK (GNULIB_NAMESPACE::iswpunct, int, (wint_t));
-SIGNATURE_CHECK (GNULIB_NAMESPACE::iswspace, int, (wint_t));
-SIGNATURE_CHECK (GNULIB_NAMESPACE::iswupper, int, (wint_t));
-SIGNATURE_CHECK (GNULIB_NAMESPACE::iswxdigit, int, (wint_t));
-
-SIGNATURE_CHECK (GNULIB_NAMESPACE::towlower, wint_t, (wint_t));
-SIGNATURE_CHECK (GNULIB_NAMESPACE::towupper, wint_t, (wint_t));
-
-
-int
-main ()
-{
-}
new file mode 100644
--- /dev/null
+++ b/tests/test-wctype-h-c++.cc
@@ -0,0 +1,65 @@
+/* Test of <wctype.h> substitute in C++ mode.
+   Copyright (C) 2010-2011 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2010.  */
+
+#define GNULIB_NAMESPACE gnulib
+#include <config.h>
+
+#include <wctype.h>
+
+#include "signature.h"
+
+
+SIGNATURE_CHECK (GNULIB_NAMESPACE::iswalnum, int, (wint_t));
+SIGNATURE_CHECK (GNULIB_NAMESPACE::iswalpha, int, (wint_t));
+#if GNULIB_TEST_ISWBLANK
+SIGNATURE_CHECK (GNULIB_NAMESPACE::iswblank, int, (wint_t));
+#endif
+SIGNATURE_CHECK (GNULIB_NAMESPACE::iswcntrl, int, (wint_t));
+SIGNATURE_CHECK (GNULIB_NAMESPACE::iswdigit, int, (wint_t));
+SIGNATURE_CHECK (GNULIB_NAMESPACE::iswgraph, int, (wint_t));
+SIGNATURE_CHECK (GNULIB_NAMESPACE::iswlower, int, (wint_t));
+SIGNATURE_CHECK (GNULIB_NAMESPACE::iswprint, int, (wint_t));
+SIGNATURE_CHECK (GNULIB_NAMESPACE::iswpunct, int, (wint_t));
+SIGNATURE_CHECK (GNULIB_NAMESPACE::iswspace, int, (wint_t));
+SIGNATURE_CHECK (GNULIB_NAMESPACE::iswupper, int, (wint_t));
+SIGNATURE_CHECK (GNULIB_NAMESPACE::iswxdigit, int, (wint_t));
+
+#if GNULIB_TEST_WCTYPE
+SIGNATURE_CHECK (GNULIB_NAMESPACE::wctype, wctype_t, (const char *));
+#endif
+
+#if GNULIB_TEST_ISWCTYPE
+SIGNATURE_CHECK (GNULIB_NAMESPACE::iswctype, int, (wint_t, wctype_t));
+#endif
+
+SIGNATURE_CHECK (GNULIB_NAMESPACE::towlower, wint_t, (wint_t));
+SIGNATURE_CHECK (GNULIB_NAMESPACE::towupper, wint_t, (wint_t));
+
+#if GNULIB_TEST_WCTRANS
+SIGNATURE_CHECK (GNULIB_NAMESPACE::wctrans, wctrans_t, (const char *));
+#endif
+
+#if GNULIB_TEST_TOWCTRANS
+SIGNATURE_CHECK (GNULIB_NAMESPACE::towctrans, wint_t, (wint_t, wctrans_t));
+#endif
+
+
+int
+main ()
+{
+}
new file mode 100644
--- /dev/null
+++ b/tests/test-wctype-h.c
@@ -0,0 +1,74 @@
+/* Test of <wctype.h> substitute.
+   Copyright (C) 2007-2011 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2007.  */
+
+#include <config.h>
+
+#include <wctype.h>
+
+#include "macros.h"
+
+/* Check that the type wint_t is defined.  */
+wint_t a = 'x';
+/* Check that WEOF is defined.  */
+wint_t e = WEOF;
+
+/* Check that the type wctype_t is defined.  */
+wctype_t p;
+
+/* Check that the type wctrans_t is defined.  */
+wctrans_t q;
+
+int
+main (void)
+{
+  /* Check that the isw* functions exist as functions or as macros.  */
+  (void) iswalnum (0);
+  (void) iswalpha (0);
+  (void) iswcntrl (0);
+  (void) iswdigit (0);
+  (void) iswgraph (0);
+  (void) iswlower (0);
+  (void) iswprint (0);
+  (void) iswpunct (0);
+  (void) iswspace (0);
+  (void) iswupper (0);
+  (void) iswxdigit (0);
+
+  /* Check that the isw* functions map WEOF to 0.  */
+  ASSERT (!iswalnum (e));
+  ASSERT (!iswalpha (e));
+  ASSERT (!iswcntrl (e));
+  ASSERT (!iswdigit (e));
+  ASSERT (!iswgraph (e));
+  ASSERT (!iswlower (e));
+  ASSERT (!iswprint (e));
+  ASSERT (!iswpunct (e));
+  ASSERT (!iswspace (e));
+  ASSERT (!iswupper (e));
+  ASSERT (!iswxdigit (e));
+
+  /* Check that the tow* functions exist as functions or as macros.  */
+  (void) towlower (0);
+  (void) towupper (0);
+
+  /* Check that the tow* functions map WEOF to WEOF.  */
+  ASSERT (towlower (e) == e);
+  ASSERT (towupper (e) == e);
+
+  return 0;
+}
deleted file mode 100644
--- a/tests/test-wctype.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/* Test of <wctype.h> substitute.
-   Copyright (C) 2007-2011 Free Software Foundation, Inc.
-
-   This program is free software: you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-/* Written by Bruno Haible <bruno@clisp.org>, 2007.  */
-
-#include <config.h>
-
-#include <wctype.h>
-
-#include "macros.h"
-
-/* Check that the type wint_t is defined.  */
-wint_t a = 'x';
-/* Check that WEOF is defined.  */
-wint_t e = WEOF;
-
-int
-main (void)
-{
-  /* Check that the isw* functions exist as functions or as macros.  */
-  (void) iswalnum (0);
-  (void) iswalpha (0);
-  (void) iswblank (0);
-  (void) iswcntrl (0);
-  (void) iswdigit (0);
-  (void) iswgraph (0);
-  (void) iswlower (0);
-  (void) iswprint (0);
-  (void) iswpunct (0);
-  (void) iswspace (0);
-  (void) iswupper (0);
-  (void) iswxdigit (0);
-
-  /* Check that the isw* functions map WEOF to 0.  */
-  ASSERT (!iswalnum (e));
-  ASSERT (!iswalpha (e));
-  ASSERT (!iswblank (e));
-  ASSERT (!iswcntrl (e));
-  ASSERT (!iswdigit (e));
-  ASSERT (!iswgraph (e));
-  ASSERT (!iswlower (e));
-  ASSERT (!iswprint (e));
-  ASSERT (!iswpunct (e));
-  ASSERT (!iswspace (e));
-  ASSERT (!iswupper (e));
-  ASSERT (!iswxdigit (e));
-
-  /* Check that the tow* functions exist as functions or as macros.  */
-  (void) towlower (0);
-  (void) towupper (0);
-
-  /* Check that the tow* functions map WEOF to WEOF.  */
-  ASSERT (towlower (e) == e);
-  ASSERT (towupper (e) == e);
-
-  return 0;
-}
--- a/tests/unictype/test-bidi_byname.c
+++ b/tests/unictype/test-bidi_byname.c
@@ -1,5 +1,5 @@
 /* Test the Unicode character type functions.
-   Copyright (C) 2007-2010 Free Software Foundation, Inc.
+   Copyright (C) 2007-2011 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
@@ -25,27 +25,105 @@
 int
 main ()
 {
-  ASSERT (uc_bidi_category_byname ("L") == UC_BIDI_L);
-  ASSERT (uc_bidi_category_byname ("LRE") == UC_BIDI_LRE);
-  ASSERT (uc_bidi_category_byname ("LRO") == UC_BIDI_LRO);
-  ASSERT (uc_bidi_category_byname ("R") == UC_BIDI_R);
-  ASSERT (uc_bidi_category_byname ("AL") == UC_BIDI_AL);
-  ASSERT (uc_bidi_category_byname ("RLE") == UC_BIDI_RLE);
-  ASSERT (uc_bidi_category_byname ("RLO") == UC_BIDI_RLO);
-  ASSERT (uc_bidi_category_byname ("PDF") == UC_BIDI_PDF);
-  ASSERT (uc_bidi_category_byname ("EN") == UC_BIDI_EN);
-  ASSERT (uc_bidi_category_byname ("ES") == UC_BIDI_ES);
-  ASSERT (uc_bidi_category_byname ("ET") == UC_BIDI_ET);
-  ASSERT (uc_bidi_category_byname ("AN") == UC_BIDI_AN);
-  ASSERT (uc_bidi_category_byname ("CS") == UC_BIDI_CS);
-  ASSERT (uc_bidi_category_byname ("NSM") == UC_BIDI_NSM);
-  ASSERT (uc_bidi_category_byname ("BN") == UC_BIDI_BN);
-  ASSERT (uc_bidi_category_byname ("B") == UC_BIDI_B);
-  ASSERT (uc_bidi_category_byname ("S") == UC_BIDI_S);
-  ASSERT (uc_bidi_category_byname ("WS") == UC_BIDI_WS);
-  ASSERT (uc_bidi_category_byname ("ON") == UC_BIDI_ON);
-  ASSERT (uc_bidi_category_byname ("X") < 0);
-  ASSERT (uc_bidi_category_byname ("") < 0);
+  ASSERT (uc_bidi_class_byname ("L") == UC_BIDI_L);
+  ASSERT (uc_bidi_class_byname ("LRE") == UC_BIDI_LRE);
+  ASSERT (uc_bidi_class_byname ("LRO") == UC_BIDI_LRO);
+  ASSERT (uc_bidi_class_byname ("R") == UC_BIDI_R);
+  ASSERT (uc_bidi_class_byname ("AL") == UC_BIDI_AL);
+  ASSERT (uc_bidi_class_byname ("RLE") == UC_BIDI_RLE);
+  ASSERT (uc_bidi_class_byname ("RLO") == UC_BIDI_RLO);
+  ASSERT (uc_bidi_class_byname ("PDF") == UC_BIDI_PDF);
+  ASSERT (uc_bidi_class_byname ("EN") == UC_BIDI_EN);
+  ASSERT (uc_bidi_class_byname ("ES") == UC_BIDI_ES);
+  ASSERT (uc_bidi_class_byname ("ET") == UC_BIDI_ET);
+  ASSERT (uc_bidi_class_byname ("AN") == UC_BIDI_AN);
+  ASSERT (uc_bidi_class_byname ("CS") == UC_BIDI_CS);
+  ASSERT (uc_bidi_class_byname ("NSM") == UC_BIDI_NSM);
+  ASSERT (uc_bidi_class_byname ("BN") == UC_BIDI_BN);
+  ASSERT (uc_bidi_class_byname ("B") == UC_BIDI_B);
+  ASSERT (uc_bidi_class_byname ("S") == UC_BIDI_S);
+  ASSERT (uc_bidi_class_byname ("WS") == UC_BIDI_WS);
+  ASSERT (uc_bidi_class_byname ("ON") == UC_BIDI_ON);
+
+  ASSERT (uc_bidi_class_byname ("ARABIC LETTER") == UC_BIDI_AL);
+  ASSERT (uc_bidi_class_byname ("Arabic Letter") == UC_BIDI_AL);
+  ASSERT (uc_bidi_class_byname ("Arabic_Letter") == UC_BIDI_AL);
+  ASSERT (uc_bidi_class_byname ("ArabicLetter") == UC_BIDI_AL);
+  ASSERT (uc_bidi_class_byname ("ARABIC NUMBER") == UC_BIDI_AN);
+  ASSERT (uc_bidi_class_byname ("Arabic Number") == UC_BIDI_AN);
+  ASSERT (uc_bidi_class_byname ("Arabic_Number") == UC_BIDI_AN);
+  ASSERT (uc_bidi_class_byname ("ArabicNumber") == UC_BIDI_AN);
+  ASSERT (uc_bidi_class_byname ("PARAGRAPH SEPARATOR") == UC_BIDI_B);
+  ASSERT (uc_bidi_class_byname ("Paragraph Separator") == UC_BIDI_B);
+  ASSERT (uc_bidi_class_byname ("Paragraph_Separator") == UC_BIDI_B);
+  ASSERT (uc_bidi_class_byname ("ParagraphSeparator") == UC_BIDI_B);
+  ASSERT (uc_bidi_class_byname ("BOUNDARY NEUTRAL") == UC_BIDI_BN);
+  ASSERT (uc_bidi_class_byname ("Boundary Neutral") == UC_BIDI_BN);
+  ASSERT (uc_bidi_class_byname ("Boundary_Neutral") == UC_BIDI_BN);
+  ASSERT (uc_bidi_class_byname ("BoundaryNeutral") == UC_BIDI_BN);
+  ASSERT (uc_bidi_class_byname ("COMMON SEPARATOR") == UC_BIDI_CS);
+  ASSERT (uc_bidi_class_byname ("Common Separator") == UC_BIDI_CS);
+  ASSERT (uc_bidi_class_byname ("Common_Separator") == UC_BIDI_CS);
+  ASSERT (uc_bidi_class_byname ("CommonSeparator") == UC_BIDI_CS);
+  ASSERT (uc_bidi_class_byname ("EUROPEAN NUMBER") == UC_BIDI_EN);
+  ASSERT (uc_bidi_class_byname ("European Number") == UC_BIDI_EN);
+  ASSERT (uc_bidi_class_byname ("European_Number") == UC_BIDI_EN);
+  ASSERT (uc_bidi_class_byname ("EuropeanNumber") == UC_BIDI_EN);
+  ASSERT (uc_bidi_class_byname ("EUROPEAN SEPARATOR") == UC_BIDI_ES);
+  ASSERT (uc_bidi_class_byname ("European Separator") == UC_BIDI_ES);
+  ASSERT (uc_bidi_class_byname ("European_Separator") == UC_BIDI_ES);
+  ASSERT (uc_bidi_class_byname ("EuropeanSeparator") == UC_BIDI_ES);
+  ASSERT (uc_bidi_class_byname ("EUROPEAN TERMINATOR") == UC_BIDI_ET);
+  ASSERT (uc_bidi_class_byname ("European Terminator") == UC_BIDI_ET);
+  ASSERT (uc_bidi_class_byname ("European_Terminator") == UC_BIDI_ET);
+  ASSERT (uc_bidi_class_byname ("EuropeanTerminator") == UC_BIDI_ET);
+  ASSERT (uc_bidi_class_byname ("LEFT TO RIGHT") == UC_BIDI_L);
+  ASSERT (uc_bidi_class_byname ("Left To Right") == UC_BIDI_L);
+  ASSERT (uc_bidi_class_byname ("Left_To_Right") == UC_BIDI_L);
+  ASSERT (uc_bidi_class_byname ("LeftToRight") == UC_BIDI_L);
+  ASSERT (uc_bidi_class_byname ("LEFT TO RIGHT EMBEDDING") == UC_BIDI_LRE);
+  ASSERT (uc_bidi_class_byname ("Left To Right Embedding") == UC_BIDI_LRE);
+  ASSERT (uc_bidi_class_byname ("Left_To_Right_Embedding") == UC_BIDI_LRE);
+  ASSERT (uc_bidi_class_byname ("LeftToRightEmbedding") == UC_BIDI_LRE);
+  ASSERT (uc_bidi_class_byname ("LEFT TO RIGHT OVERRIDE") == UC_BIDI_LRO);
+  ASSERT (uc_bidi_class_byname ("Left To Right Override") == UC_BIDI_LRO);
+  ASSERT (uc_bidi_class_byname ("Left_To_Right_Override") == UC_BIDI_LRO);
+  ASSERT (uc_bidi_class_byname ("LeftToRightOverride") == UC_BIDI_LRO);
+  ASSERT (uc_bidi_class_byname ("NONSPACING MARK") == UC_BIDI_NSM);
+  ASSERT (uc_bidi_class_byname ("Nonspacing Mark") == UC_BIDI_NSM);
+  ASSERT (uc_bidi_class_byname ("Nonspacing_Mark") == UC_BIDI_NSM);
+  ASSERT (uc_bidi_class_byname ("NonspacingMark") == UC_BIDI_NSM);
+  ASSERT (uc_bidi_class_byname ("OTHER NEUTRAL") == UC_BIDI_ON);
+  ASSERT (uc_bidi_class_byname ("Other Neutral") == UC_BIDI_ON);
+  ASSERT (uc_bidi_class_byname ("Other_Neutral") == UC_BIDI_ON);
+  ASSERT (uc_bidi_class_byname ("OtherNeutral") == UC_BIDI_ON);
+  ASSERT (uc_bidi_class_byname ("POP DIRECTIONAL FORMAT") == UC_BIDI_PDF);
+  ASSERT (uc_bidi_class_byname ("Pop Directional Format") == UC_BIDI_PDF);
+  ASSERT (uc_bidi_class_byname ("Pop_Directional_Format") == UC_BIDI_PDF);
+  ASSERT (uc_bidi_class_byname ("PopDirectionalFormat") == UC_BIDI_PDF);
+  ASSERT (uc_bidi_class_byname ("RIGHT TO LEFT") == UC_BIDI_R);
+  ASSERT (uc_bidi_class_byname ("Right To Left") == UC_BIDI_R);
+  ASSERT (uc_bidi_class_byname ("Right_To_Left") == UC_BIDI_R);
+  ASSERT (uc_bidi_class_byname ("RightToLeft") == UC_BIDI_R);
+  ASSERT (uc_bidi_class_byname ("RIGHT TO LEFT EMBEDDING") == UC_BIDI_RLE);
+  ASSERT (uc_bidi_class_byname ("Right To Left Embedding") == UC_BIDI_RLE);
+  ASSERT (uc_bidi_class_byname ("Right_To_Left_Embedding") == UC_BIDI_RLE);
+  ASSERT (uc_bidi_class_byname ("RightToLeftEmbedding") == UC_BIDI_RLE);
+  ASSERT (uc_bidi_class_byname ("RIGHT TO LEFT OVERRIDE") == UC_BIDI_RLO);
+  ASSERT (uc_bidi_class_byname ("Right To Left Override") == UC_BIDI_RLO);
+  ASSERT (uc_bidi_class_byname ("Right_To_Left_Override") == UC_BIDI_RLO);
+  ASSERT (uc_bidi_class_byname ("RightToLeftOverride") == UC_BIDI_RLO);
+  ASSERT (uc_bidi_class_byname ("SEGMENT SEPARATOR") == UC_BIDI_S);
+  ASSERT (uc_bidi_class_byname ("Segment Separator") == UC_BIDI_S);
+  ASSERT (uc_bidi_class_byname ("Segment_Separator") == UC_BIDI_S);
+  ASSERT (uc_bidi_class_byname ("SegmentSeparator") == UC_BIDI_S);
+  ASSERT (uc_bidi_class_byname ("WHITE SPACE") == UC_BIDI_WS);
+  ASSERT (uc_bidi_class_byname ("White Space") == UC_BIDI_WS);
+  ASSERT (uc_bidi_class_byname ("White_Space") == UC_BIDI_WS);
+  ASSERT (uc_bidi_class_byname ("WhiteSpace") == UC_BIDI_WS);
+
+  ASSERT (uc_bidi_class_byname ("X") < 0);
+  ASSERT (uc_bidi_class_byname ("") < 0);
 
   return 0;
 }
new file mode 100644
--- /dev/null
+++ b/tests/unictype/test-bidi_longname.c
@@ -0,0 +1,50 @@
+/* Test the Unicode character type functions.
+   Copyright (C) 2011 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/>.  */
+
+#include <config.h>
+
+#include "unictype.h"
+
+#include <string.h>
+
+#include "macros.h"
+
+int
+main ()
+{
+  ASSERT (strcmp (uc_bidi_class_long_name (UC_BIDI_AL), "Arabic Letter") == 0);
+  ASSERT (strcmp (uc_bidi_class_long_name (UC_BIDI_AN), "Arabic Number") == 0);
+  ASSERT (strcmp (uc_bidi_class_long_name (UC_BIDI_B), "Paragraph Separator") == 0);
+  ASSERT (strcmp (uc_bidi_class_long_name (UC_BIDI_BN), "Boundary Neutral") == 0);
+  ASSERT (strcmp (uc_bidi_class_long_name (UC_BIDI_CS), "Common Separator") == 0);
+  ASSERT (strcmp (uc_bidi_class_long_name (UC_BIDI_EN), "European Number") == 0);
+  ASSERT (strcmp (uc_bidi_class_long_name (UC_BIDI_ES), "European Separator") == 0);
+  ASSERT (strcmp (uc_bidi_class_long_name (UC_BIDI_ET), "European Terminator") == 0);
+  ASSERT (strcmp (uc_bidi_class_long_name (UC_BIDI_L), "Left To Right") == 0);
+  ASSERT (strcmp (uc_bidi_class_long_name (UC_BIDI_LRE), "Left To Right Embedding") == 0);
+  ASSERT (strcmp (uc_bidi_class_long_name (UC_BIDI_LRO), "Left To Right Override") == 0);
+  ASSERT (strcmp (uc_bidi_class_long_name (UC_BIDI_NSM), "Nonspacing Mark") == 0);
+  ASSERT (strcmp (uc_bidi_class_long_name (UC_BIDI_ON), "Other Neutral") == 0);
+  ASSERT (strcmp (uc_bidi_class_long_name (UC_BIDI_PDF), "Pop Directional Format") == 0);
+  ASSERT (strcmp (uc_bidi_class_long_name (UC_BIDI_R), "Right To Left") == 0);
+  ASSERT (strcmp (uc_bidi_class_long_name (UC_BIDI_RLE), "Right To Left Embedding") == 0);
+  ASSERT (strcmp (uc_bidi_class_long_name (UC_BIDI_RLO), "Right To Left Override") == 0);
+  ASSERT (strcmp (uc_bidi_class_long_name (UC_BIDI_S), "Segment Separator") == 0);
+  ASSERT (strcmp (uc_bidi_class_long_name (UC_BIDI_WS), "White Space") == 0);
+  ASSERT (uc_bidi_class_long_name (-1) == NULL);
+
+  return 0;
+}
--- a/tests/unictype/test-bidi_name.c
+++ b/tests/unictype/test-bidi_name.c
@@ -1,5 +1,5 @@
 /* Test the Unicode character type functions.
-   Copyright (C) 2007-2009 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009, 2011 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
@@ -25,8 +25,8 @@
 int
 main ()
 {
-  ASSERT (strcmp (uc_bidi_category_name (UC_BIDI_NSM), "NSM") == 0);
-  ASSERT (uc_bidi_category_name (-1) == NULL);
+  ASSERT (strcmp (uc_bidi_class_name (UC_BIDI_NSM), "NSM") == 0);
+  ASSERT (uc_bidi_class_name (-1) == NULL);
 
   return 0;
 }
--- a/tests/unictype/test-bidi_of.c
+++ b/tests/unictype/test-bidi_of.c
@@ -1,5 +1,5 @@
 /* Test the Unicode character type functions.
-   Copyright (C) 2007-2009 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009, 2011 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
@@ -25,9 +25,9 @@
 int
 main ()
 {
-  ASSERT (uc_bidi_category ('x') == UC_BIDI_L);
-  ASSERT (uc_bidi_category (0x05D7) == UC_BIDI_R);
-  ASSERT (uc_bidi_category ('7') == UC_BIDI_EN);
+  ASSERT (uc_bidi_class ('x') == UC_BIDI_L);
+  ASSERT (uc_bidi_class (0x05D7) == UC_BIDI_R);
+  ASSERT (uc_bidi_class ('7') == UC_BIDI_EN);
 
   return 0;
 }
--- a/tests/unictype/test-bidi_test.c
+++ b/tests/unictype/test-bidi_test.c
@@ -1,5 +1,5 @@
 /* Test the Unicode character type functions.
-   Copyright (C) 2007-2009 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009, 2011 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
@@ -25,23 +25,23 @@
 int
 main ()
 {
-  ASSERT (uc_is_bidi_category ('x', UC_BIDI_L));
-  ASSERT (!uc_is_bidi_category ('x', UC_BIDI_R));
-  ASSERT (!uc_is_bidi_category ('x', UC_BIDI_EN));
+  ASSERT (uc_is_bidi_class ('x', UC_BIDI_L));
+  ASSERT (!uc_is_bidi_class ('x', UC_BIDI_R));
+  ASSERT (!uc_is_bidi_class ('x', UC_BIDI_EN));
 
-  ASSERT (uc_is_bidi_category (0x05D7, UC_BIDI_R));
-  ASSERT (!uc_is_bidi_category (0x05D7, UC_BIDI_L));
-  ASSERT (!uc_is_bidi_category (0x05D7, UC_BIDI_EN));
+  ASSERT (uc_is_bidi_class (0x05D7, UC_BIDI_R));
+  ASSERT (!uc_is_bidi_class (0x05D7, UC_BIDI_L));
+  ASSERT (!uc_is_bidi_class (0x05D7, UC_BIDI_EN));
 
-  ASSERT (uc_is_bidi_category ('7', UC_BIDI_EN));
-  ASSERT (!uc_is_bidi_category ('7', UC_BIDI_L));
-  ASSERT (!uc_is_bidi_category ('7', UC_BIDI_R));
+  ASSERT (uc_is_bidi_class ('7', UC_BIDI_EN));
+  ASSERT (!uc_is_bidi_class ('7', UC_BIDI_L));
+  ASSERT (!uc_is_bidi_class ('7', UC_BIDI_R));
 
   {
     unsigned int c;
 
     for (c = 0; c < 0x110000; c++)
-      ASSERT (uc_is_bidi_category (c, uc_bidi_category (c)));
+      ASSERT (uc_is_bidi_class (c, uc_bidi_class (c)));
   }
 
   return 0;
new file mode 100644
--- /dev/null
+++ b/tests/unictype/test-categ_LC.c
@@ -0,0 +1,132 @@
+/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
+/* Test the Unicode character type functions.
+   Copyright (C) 2007 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU 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 "test-predicate-part1.h"
+
+    { 0x0041, 0x005A },
+    { 0x0061, 0x007A },
+    { 0x00AA, 0x00AA },
+    { 0x00B5, 0x00B5 },
+    { 0x00BA, 0x00BA },
+    { 0x00C0, 0x00D6 },
+    { 0x00D8, 0x00F6 },
+    { 0x00F8, 0x01BA },
+    { 0x01BC, 0x01BF },
+    { 0x01C4, 0x0293 },
+    { 0x0295, 0x02AF },
+    { 0x0370, 0x0373 },
+    { 0x0376, 0x0377 },
+    { 0x037B, 0x037D },
+    { 0x0386, 0x0386 },
+    { 0x0388, 0x038A },
+    { 0x038C, 0x038C },
+    { 0x038E, 0x03A1 },
+    { 0x03A3, 0x03F5 },
+    { 0x03F7, 0x0481 },
+    { 0x048A, 0x0527 },
+    { 0x0531, 0x0556 },
+    { 0x0561, 0x0587 },
+    { 0x10A0, 0x10C5 },
+    { 0x1D00, 0x1D2B },
+    { 0x1D62, 0x1D77 },
+    { 0x1D79, 0x1D9A },
+    { 0x1E00, 0x1F15 },
+    { 0x1F18, 0x1F1D },
+    { 0x1F20, 0x1F45 },
+    { 0x1F48, 0x1F4D },
+    { 0x1F50, 0x1F57 },
+    { 0x1F59, 0x1F59 },
+    { 0x1F5B, 0x1F5B },
+    { 0x1F5D, 0x1F5D },
+    { 0x1F5F, 0x1F7D },
+    { 0x1F80, 0x1FB4 },
+    { 0x1FB6, 0x1FBC },
+    { 0x1FBE, 0x1FBE },
+    { 0x1FC2, 0x1FC4 },
+    { 0x1FC6, 0x1FCC },
+    { 0x1FD0, 0x1FD3 },
+    { 0x1FD6, 0x1FDB },
+    { 0x1FE0, 0x1FEC },
+    { 0x1FF2, 0x1FF4 },
+    { 0x1FF6, 0x1FFC },
+    { 0x2102, 0x2102 },
+    { 0x2107, 0x2107 },
+    { 0x210A, 0x2113 },
+    { 0x2115, 0x2115 },
+    { 0x2119, 0x211D },
+    { 0x2124, 0x2124 },
+    { 0x2126, 0x2126 },
+    { 0x2128, 0x2128 },
+    { 0x212A, 0x212D },
+    { 0x212F, 0x2134 },
+    { 0x2139, 0x2139 },
+    { 0x213C, 0x213F },
+    { 0x2145, 0x2149 },
+    { 0x214E, 0x214E },
+    { 0x2183, 0x2184 },
+    { 0x2C00, 0x2C2E },
+    { 0x2C30, 0x2C5E },
+    { 0x2C60, 0x2C7C },
+    { 0x2C7E, 0x2CE4 },
+    { 0x2CEB, 0x2CEE },
+    { 0x2D00, 0x2D25 },
+    { 0xA640, 0xA66D },
+    { 0xA680, 0xA697 },
+    { 0xA722, 0xA76F },
+    { 0xA771, 0xA787 },
+    { 0xA78B, 0xA78E },
+    { 0xA790, 0xA791 },
+    { 0xA7A0, 0xA7A9 },
+    { 0xA7FA, 0xA7FA },
+    { 0xFB00, 0xFB06 },
+    { 0xFB13, 0xFB17 },
+    { 0xFF21, 0xFF3A },
+    { 0xFF41, 0xFF5A },
+    { 0x10400, 0x1044F },
+    { 0x1D400, 0x1D454 },
+    { 0x1D456, 0x1D49C },
+    { 0x1D49E, 0x1D49F },
+    { 0x1D4A2, 0x1D4A2 },
+    { 0x1D4A5, 0x1D4A6 },
+    { 0x1D4A9, 0x1D4AC },
+    { 0x1D4AE, 0x1D4B9 },
+    { 0x1D4BB, 0x1D4BB },
+    { 0x1D4BD, 0x1D4C3 },
+    { 0x1D4C5, 0x1D505 },
+    { 0x1D507, 0x1D50A },
+    { 0x1D50D, 0x1D514 },
+    { 0x1D516, 0x1D51C },
+    { 0x1D51E, 0x1D539 },
+    { 0x1D53B, 0x1D53E },
+    { 0x1D540, 0x1D544 },
+    { 0x1D546, 0x1D546 },
+    { 0x1D54A, 0x1D550 },
+    { 0x1D552, 0x1D6A5 },
+    { 0x1D6A8, 0x1D6C0 },
+    { 0x1D6C2, 0x1D6DA },
+    { 0x1D6DC, 0x1D6FA },
+    { 0x1D6FC, 0x1D714 },
+    { 0x1D716, 0x1D734 },
+    { 0x1D736, 0x1D74E },
+    { 0x1D750, 0x1D76E },
+    { 0x1D770, 0x1D788 },
+    { 0x1D78A, 0x1D7A8 },
+    { 0x1D7AA, 0x1D7C2 },
+    { 0x1D7C4, 0x1D7CB }
+
+#define PREDICATE(c) uc_is_general_category (c, UC_CATEGORY_LC)
+#include "test-predicate-part2.h"
--- a/tests/unictype/test-categ_byname.c
+++ b/tests/unictype/test-categ_byname.c
@@ -1,5 +1,5 @@
 /* Test the Unicode character type functions.
-   Copyright (C) 2007-2010 Free Software Foundation, Inc.
+   Copyright (C) 2007-2011 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
@@ -38,6 +38,7 @@
 main ()
 {
   ASSERT (category_equals (uc_general_category_byname ("L"), UC_CATEGORY_L));
+  ASSERT (category_equals (uc_general_category_byname ("LC"), UC_CATEGORY_LC));
   ASSERT (category_equals (uc_general_category_byname ("Lu"), UC_CATEGORY_Lu));
   ASSERT (category_equals (uc_general_category_byname ("Ll"), UC_CATEGORY_Ll));
   ASSERT (category_equals (uc_general_category_byname ("Lt"), UC_CATEGORY_Lt));
@@ -75,6 +76,137 @@
   ASSERT (category_equals (uc_general_category_byname ("Co"), UC_CATEGORY_Co));
   ASSERT (category_equals (uc_general_category_byname ("Cn"), UC_CATEGORY_Cn));
 
+  ASSERT (category_equals (uc_general_category_byname ("LETTER"), UC_CATEGORY_L));
+  ASSERT (category_equals (uc_general_category_byname ("Letter"), UC_CATEGORY_L));
+  ASSERT (category_equals (uc_general_category_byname ("CASED LETTER"), UC_CATEGORY_LC));
+  ASSERT (category_equals (uc_general_category_byname ("Cased Letter"), UC_CATEGORY_LC));
+  ASSERT (category_equals (uc_general_category_byname ("Cased_Letter"), UC_CATEGORY_LC));
+  ASSERT (category_equals (uc_general_category_byname ("CasedLetter"), UC_CATEGORY_LC));
+  ASSERT (category_equals (uc_general_category_byname ("UPPERCASE LETTER"), UC_CATEGORY_Lu));
+  ASSERT (category_equals (uc_general_category_byname ("Uppercase Letter"), UC_CATEGORY_Lu));
+  ASSERT (category_equals (uc_general_category_byname ("Uppercase_Letter"), UC_CATEGORY_Lu));
+  ASSERT (category_equals (uc_general_category_byname ("UppercaseLetter"), UC_CATEGORY_Lu));
+  ASSERT (category_equals (uc_general_category_byname ("LOWERCASE LETTER"), UC_CATEGORY_Ll));
+  ASSERT (category_equals (uc_general_category_byname ("Lowercase Letter"), UC_CATEGORY_Ll));
+  ASSERT (category_equals (uc_general_category_byname ("Lowercase_Letter"), UC_CATEGORY_Ll));
+  ASSERT (category_equals (uc_general_category_byname ("LowercaseLetter"), UC_CATEGORY_Ll));
+  ASSERT (category_equals (uc_general_category_byname ("TITLECASE LETTER"), UC_CATEGORY_Lt));
+  ASSERT (category_equals (uc_general_category_byname ("Titlecase Letter"), UC_CATEGORY_Lt));
+  ASSERT (category_equals (uc_general_category_byname ("Titlecase_Letter"), UC_CATEGORY_Lt));
+  ASSERT (category_equals (uc_general_category_byname ("TitlecaseLetter"), UC_CATEGORY_Lt));
+  ASSERT (category_equals (uc_general_category_byname ("MODIFIER LETTER"), UC_CATEGORY_Lm));
+  ASSERT (category_equals (uc_general_category_byname ("Modifier Letter"), UC_CATEGORY_Lm));
+  ASSERT (category_equals (uc_general_category_byname ("Modifier_Letter"), UC_CATEGORY_Lm));
+  ASSERT (category_equals (uc_general_category_byname ("ModifierLetter"), UC_CATEGORY_Lm));
+  ASSERT (category_equals (uc_general_category_byname ("OTHER LETTER"), UC_CATEGORY_Lo));
+  ASSERT (category_equals (uc_general_category_byname ("Other Letter"), UC_CATEGORY_Lo));
+  ASSERT (category_equals (uc_general_category_byname ("Other_Letter"), UC_CATEGORY_Lo));
+  ASSERT (category_equals (uc_general_category_byname ("OtherLetter"), UC_CATEGORY_Lo));
+  ASSERT (category_equals (uc_general_category_byname ("MARK"), UC_CATEGORY_M));
+  ASSERT (category_equals (uc_general_category_byname ("Mark"), UC_CATEGORY_M));
+  ASSERT (category_equals (uc_general_category_byname ("NONSPACING MARK"), UC_CATEGORY_Mn));
+  ASSERT (category_equals (uc_general_category_byname ("Nonspacing Mark"), UC_CATEGORY_Mn));
+  ASSERT (category_equals (uc_general_category_byname ("Nonspacing_Mark"), UC_CATEGORY_Mn));
+  ASSERT (category_equals (uc_general_category_byname ("NonspacingMark"), UC_CATEGORY_Mn));
+  ASSERT (category_equals (uc_general_category_byname ("SPACING MARK"), UC_CATEGORY_Mc));
+  ASSERT (category_equals (uc_general_category_byname ("Spacing Mark"), UC_CATEGORY_Mc));
+  ASSERT (category_equals (uc_general_category_byname ("Spacing_Mark"), UC_CATEGORY_Mc));
+  ASSERT (category_equals (uc_general_category_byname ("SpacingMark"), UC_CATEGORY_Mc));
+  ASSERT (category_equals (uc_general_category_byname ("ENCLOSING MARK"), UC_CATEGORY_Me));
+  ASSERT (category_equals (uc_general_category_byname ("Enclosing Mark"), UC_CATEGORY_Me));
+  ASSERT (category_equals (uc_general_category_byname ("Enclosing_Mark"), UC_CATEGORY_Me));
+  ASSERT (category_equals (uc_general_category_byname ("EnclosingMark"), UC_CATEGORY_Me));
+  ASSERT (category_equals (uc_general_category_byname ("NUMBER"), UC_CATEGORY_N));
+  ASSERT (category_equals (uc_general_category_byname ("Number"), UC_CATEGORY_N));
+  ASSERT (category_equals (uc_general_category_byname ("DECIMAL NUMBER"), UC_CATEGORY_Nd));
+  ASSERT (category_equals (uc_general_category_byname ("Decimal Number"), UC_CATEGORY_Nd));
+  ASSERT (category_equals (uc_general_category_byname ("Decimal_Number"), UC_CATEGORY_Nd));
+  ASSERT (category_equals (uc_general_category_byname ("DecimalNumber"), UC_CATEGORY_Nd));
+  ASSERT (category_equals (uc_general_category_byname ("LETTER NUMBER"), UC_CATEGORY_Nl));
+  ASSERT (category_equals (uc_general_category_byname ("Letter Number"), UC_CATEGORY_Nl));
+  ASSERT (category_equals (uc_general_category_byname ("Letter_Number"), UC_CATEGORY_Nl));
+  ASSERT (category_equals (uc_general_category_byname ("LetterNumber"), UC_CATEGORY_Nl));
+  ASSERT (category_equals (uc_general_category_byname ("OTHER NUMBER"), UC_CATEGORY_No));
+  ASSERT (category_equals (uc_general_category_byname ("Other Number"), UC_CATEGORY_No));
+  ASSERT (category_equals (uc_general_category_byname ("Other_Number"), UC_CATEGORY_No));
+  ASSERT (category_equals (uc_general_category_byname ("OtherNumber"), UC_CATEGORY_No));
+  ASSERT (category_equals (uc_general_category_byname ("PUNCTUATION"), UC_CATEGORY_P));
+  ASSERT (category_equals (uc_general_category_byname ("Punctuation"), UC_CATEGORY_P));
+  ASSERT (category_equals (uc_general_category_byname ("CONNECTOR PUNCTUATION"), UC_CATEGORY_Pc));
+  ASSERT (category_equals (uc_general_category_byname ("Connector Punctuation"), UC_CATEGORY_Pc));
+  ASSERT (category_equals (uc_general_category_byname ("Connector_Punctuation"), UC_CATEGORY_Pc));
+  ASSERT (category_equals (uc_general_category_byname ("ConnectorPunctuation"), UC_CATEGORY_Pc));
+  ASSERT (category_equals (uc_general_category_byname ("DASH PUNCTUATION"), UC_CATEGORY_Pd));
+  ASSERT (category_equals (uc_general_category_byname ("Dash Punctuation"), UC_CATEGORY_Pd));
+  ASSERT (category_equals (uc_general_category_byname ("Dash_Punctuation"), UC_CATEGORY_Pd));
+  ASSERT (category_equals (uc_general_category_byname ("DashPunctuation"), UC_CATEGORY_Pd));
+  ASSERT (category_equals (uc_general_category_byname ("OPEN PUNCTUATION"), UC_CATEGORY_Ps));
+  ASSERT (category_equals (uc_general_category_byname ("Open Punctuation"), UC_CATEGORY_Ps));
+  ASSERT (category_equals (uc_general_category_byname ("Open_Punctuation"), UC_CATEGORY_Ps));
+  ASSERT (category_equals (uc_general_category_byname ("OpenPunctuation"), UC_CATEGORY_Ps));
+  ASSERT (category_equals (uc_general_category_byname ("CLOSE PUNCTUATION"), UC_CATEGORY_Pe));
+  ASSERT (category_equals (uc_general_category_byname ("Close Punctuation"), UC_CATEGORY_Pe));
+  ASSERT (category_equals (uc_general_category_byname ("Close_Punctuation"), UC_CATEGORY_Pe));
+  ASSERT (category_equals (uc_general_category_byname ("ClosePunctuation"), UC_CATEGORY_Pe));
+  ASSERT (category_equals (uc_general_category_byname ("INITIAL PUNCTUATION"), UC_CATEGORY_Pi));
+  ASSERT (category_equals (uc_general_category_byname ("Initial Punctuation"), UC_CATEGORY_Pi));
+  ASSERT (category_equals (uc_general_category_byname ("Initial_Punctuation"), UC_CATEGORY_Pi));
+  ASSERT (category_equals (uc_general_category_byname ("InitialPunctuation"), UC_CATEGORY_Pi));
+  ASSERT (category_equals (uc_general_category_byname ("FINAL PUNCTUATION"), UC_CATEGORY_Pf));
+  ASSERT (category_equals (uc_general_category_byname ("Final Punctuation"), UC_CATEGORY_Pf));
+  ASSERT (category_equals (uc_general_category_byname ("Final_Punctuation"), UC_CATEGORY_Pf));
+  ASSERT (category_equals (uc_general_category_byname ("FinalPunctuation"), UC_CATEGORY_Pf));
+  ASSERT (category_equals (uc_general_category_byname ("OTHER PUNCTUATION"), UC_CATEGORY_Po));
+  ASSERT (category_equals (uc_general_category_byname ("Other Punctuation"), UC_CATEGORY_Po));
+  ASSERT (category_equals (uc_general_category_byname ("Other_Punctuation"), UC_CATEGORY_Po));
+  ASSERT (category_equals (uc_general_category_byname ("OtherPunctuation"), UC_CATEGORY_Po));
+  ASSERT (category_equals (uc_general_category_byname ("SYMBOL"), UC_CATEGORY_S));
+  ASSERT (category_equals (uc_general_category_byname ("Symbol"), UC_CATEGORY_S));
+  ASSERT (category_equals (uc_general_category_byname ("MATH SYMBOL"), UC_CATEGORY_Sm));
+  ASSERT (category_equals (uc_general_category_byname ("Math Symbol"), UC_CATEGORY_Sm));
+  ASSERT (category_equals (uc_general_category_byname ("Math_Symbol"), UC_CATEGORY_Sm));
+  ASSERT (category_equals (uc_general_category_byname ("MathSymbol"), UC_CATEGORY_Sm));
+  ASSERT (category_equals (uc_general_category_byname ("CURRENCY SYMBOL"), UC_CATEGORY_Sc));
+  ASSERT (category_equals (uc_general_category_byname ("Currency Symbol"), UC_CATEGORY_Sc));
+  ASSERT (category_equals (uc_general_category_byname ("Currency_Symbol"), UC_CATEGORY_Sc));
+  ASSERT (category_equals (uc_general_category_byname ("CurrencySymbol"), UC_CATEGORY_Sc));
+  ASSERT (category_equals (uc_general_category_byname ("MODIFIER SYMBOL"), UC_CATEGORY_Sk));
+  ASSERT (category_equals (uc_general_category_byname ("Modifier Symbol"), UC_CATEGORY_Sk));
+  ASSERT (category_equals (uc_general_category_byname ("Modifier_Symbol"), UC_CATEGORY_Sk));
+  ASSERT (category_equals (uc_general_category_byname ("ModifierSymbol"), UC_CATEGORY_Sk));
+  ASSERT (category_equals (uc_general_category_byname ("OTHER SYMBOL"), UC_CATEGORY_So));
+  ASSERT (category_equals (uc_general_category_byname ("Other Symbol"), UC_CATEGORY_So));
+  ASSERT (category_equals (uc_general_category_byname ("Other_Symbol"), UC_CATEGORY_So));
+  ASSERT (category_equals (uc_general_category_byname ("OtherSymbol"), UC_CATEGORY_So));
+  ASSERT (category_equals (uc_general_category_byname ("SEPARATOR"), UC_CATEGORY_Z));
+  ASSERT (category_equals (uc_general_category_byname ("Separator"), UC_CATEGORY_Z));
+  ASSERT (category_equals (uc_general_category_byname ("SPACE SEPARATOR"), UC_CATEGORY_Zs));
+  ASSERT (category_equals (uc_general_category_byname ("Space Separator"), UC_CATEGORY_Zs));
+  ASSERT (category_equals (uc_general_category_byname ("Space_Separator"), UC_CATEGORY_Zs));
+  ASSERT (category_equals (uc_general_category_byname ("SpaceSeparator"), UC_CATEGORY_Zs));
+  ASSERT (category_equals (uc_general_category_byname ("LINE SEPARATOR"), UC_CATEGORY_Zl));
+  ASSERT (category_equals (uc_general_category_byname ("Line Separator"), UC_CATEGORY_Zl));
+  ASSERT (category_equals (uc_general_category_byname ("Line_Separator"), UC_CATEGORY_Zl));
+  ASSERT (category_equals (uc_general_category_byname ("LineSeparator"), UC_CATEGORY_Zl));
+  ASSERT (category_equals (uc_general_category_byname ("PARAGRAPH SEPARATOR"), UC_CATEGORY_Zp));
+  ASSERT (category_equals (uc_general_category_byname ("Paragraph Separator"), UC_CATEGORY_Zp));
+  ASSERT (category_equals (uc_general_category_byname ("Paragraph_Separator"), UC_CATEGORY_Zp));
+  ASSERT (category_equals (uc_general_category_byname ("ParagraphSeparator"), UC_CATEGORY_Zp));
+  ASSERT (category_equals (uc_general_category_byname ("OTHER"), UC_CATEGORY_C));
+  ASSERT (category_equals (uc_general_category_byname ("Other"), UC_CATEGORY_C));
+  ASSERT (category_equals (uc_general_category_byname ("CONTROL"), UC_CATEGORY_Cc));
+  ASSERT (category_equals (uc_general_category_byname ("Control"), UC_CATEGORY_Cc));
+  ASSERT (category_equals (uc_general_category_byname ("FORMAT"), UC_CATEGORY_Cf));
+  ASSERT (category_equals (uc_general_category_byname ("Format"), UC_CATEGORY_Cf));
+  ASSERT (category_equals (uc_general_category_byname ("SURROGATE"), UC_CATEGORY_Cs));
+  ASSERT (category_equals (uc_general_category_byname ("Surrogate"), UC_CATEGORY_Cs));
+  ASSERT (category_equals (uc_general_category_byname ("PRIVATE USE"), UC_CATEGORY_Co));
+  ASSERT (category_equals (uc_general_category_byname ("Private Use"), UC_CATEGORY_Co));
+  ASSERT (category_equals (uc_general_category_byname ("Private_Use"), UC_CATEGORY_Co));
+  ASSERT (category_equals (uc_general_category_byname ("PrivateUse"), UC_CATEGORY_Co));
+  ASSERT (category_equals (uc_general_category_byname ("UNASSIGNED"), UC_CATEGORY_Cn));
+  ASSERT (category_equals (uc_general_category_byname ("Unassigned"), UC_CATEGORY_Cn));
+
   uc_general_category_byname ("Nl");
 
   {
new file mode 100644
--- /dev/null
+++ b/tests/unictype/test-categ_longname.c
@@ -0,0 +1,33 @@
+/* Test the Unicode character type functions.
+   Copyright (C) 2007-2009, 2011 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/>.  */
+
+#include <config.h>
+
+#include "unictype.h"
+
+#include <string.h>
+
+#include "macros.h"
+
+int
+main ()
+{
+  ASSERT (strcmp (uc_general_category_long_name (UC_CATEGORY_Z), "Separator") == 0);
+  ASSERT (strcmp (uc_general_category_long_name (UC_CATEGORY_Nl), "Letter Number") == 0);
+  ASSERT (uc_general_category_long_name (uc_general_category_or (UC_CATEGORY_Z, UC_CATEGORY_Nl)) == NULL);
+
+  return 0;
+}
deleted file mode 100644
--- a/tests/unictype/test-combining.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Test the Unicode character type functions.
-   Copyright (C) 2007-2009 Free Software Foundation, Inc.
-
-   This program is free software: you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#include <config.h>
-
-#include "unictype.h"
-
-#include <string.h>
-
-#include "macros.h"
-
-int
-main ()
-{
-  ASSERT (uc_combining_class ('x') == UC_CCC_NR);
-  ASSERT (uc_combining_class (0x0300) == UC_CCC_A);
-  ASSERT (uc_combining_class (0x0319) == UC_CCC_B);
-  ASSERT (uc_combining_class (0x0327) == UC_CCC_ATB);
-  ASSERT (uc_combining_class (0x093C) == UC_CCC_NK);
-
-  return 0;
-}
new file mode 100644
--- /dev/null
+++ b/tests/unictype/test-combiningclass.c
@@ -0,0 +1,35 @@
+/* Test the Unicode character type functions.
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+#include "unictype.h"
+
+#include <string.h>
+
+#include "macros.h"
+
+int
+main ()
+{
+  ASSERT (uc_combining_class ('x') == UC_CCC_NR);
+  ASSERT (uc_combining_class (0x0300) == UC_CCC_A);
+  ASSERT (uc_combining_class (0x0319) == UC_CCC_B);
+  ASSERT (uc_combining_class (0x0327) == UC_CCC_ATB);
+  ASSERT (uc_combining_class (0x093C) == UC_CCC_NK);
+
+  return 0;
+}
new file mode 100644
--- /dev/null
+++ b/tests/unictype/test-combiningclass_byname.c
@@ -0,0 +1,118 @@
+/* Test the Unicode character Arabic joining group functions.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "unictype.h"
+
+#include <string.h>
+
+#include "macros.h"
+
+int
+main ()
+{
+  ASSERT (uc_combining_class_byname ("NR") == UC_CCC_NR);
+  ASSERT (uc_combining_class_byname ("OV") == UC_CCC_OV);
+  ASSERT (uc_combining_class_byname ("NK") == UC_CCC_NK);
+  ASSERT (uc_combining_class_byname ("KV") == UC_CCC_KV);
+  ASSERT (uc_combining_class_byname ("VR") == UC_CCC_VR);
+  ASSERT (uc_combining_class_byname ("ATBL") == UC_CCC_ATBL);
+  ASSERT (uc_combining_class_byname ("ATB") == UC_CCC_ATB);
+  ASSERT (uc_combining_class_byname ("ATA") == UC_CCC_ATA);
+  ASSERT (uc_combining_class_byname ("ATAR") == UC_CCC_ATAR);
+  ASSERT (uc_combining_class_byname ("BL") == UC_CCC_BL);
+  ASSERT (uc_combining_class_byname ("B") == UC_CCC_B);
+  ASSERT (uc_combining_class_byname ("BR") == UC_CCC_BR);
+  ASSERT (uc_combining_class_byname ("L") == UC_CCC_L);
+  ASSERT (uc_combining_class_byname ("R") == UC_CCC_R);
+  ASSERT (uc_combining_class_byname ("AL") == UC_CCC_AL);
+  ASSERT (uc_combining_class_byname ("A") == UC_CCC_A);
+  ASSERT (uc_combining_class_byname ("AR") == UC_CCC_AR);
+  ASSERT (uc_combining_class_byname ("DB") == UC_CCC_DB);
+  ASSERT (uc_combining_class_byname ("DA") == UC_CCC_DA);
+  ASSERT (uc_combining_class_byname ("IS") == UC_CCC_IS);
+
+  ASSERT (uc_combining_class_byname ("NOT REORDERED") == UC_CCC_NR);
+  ASSERT (uc_combining_class_byname ("Not Reordered") == UC_CCC_NR);
+  ASSERT (uc_combining_class_byname ("Not_Reordered") == UC_CCC_NR);
+  ASSERT (uc_combining_class_byname ("NotReordered") == UC_CCC_NR);
+  ASSERT (uc_combining_class_byname ("OVERLAY") == UC_CCC_OV);
+  ASSERT (uc_combining_class_byname ("Overlay") == UC_CCC_OV);
+  ASSERT (uc_combining_class_byname ("NUKTA") == UC_CCC_NK);
+  ASSERT (uc_combining_class_byname ("Nukta") == UC_CCC_NK);
+  ASSERT (uc_combining_class_byname ("KANA VOICING") == UC_CCC_KV);
+  ASSERT (uc_combining_class_byname ("Kana Voicing") == UC_CCC_KV);
+  ASSERT (uc_combining_class_byname ("Kana_Voicing") == UC_CCC_KV);
+  ASSERT (uc_combining_class_byname ("KanaVoicing") == UC_CCC_KV);
+  ASSERT (uc_combining_class_byname ("VIRAMA") == UC_CCC_VR);
+  ASSERT (uc_combining_class_byname ("Virama") == UC_CCC_VR);
+  ASSERT (uc_combining_class_byname ("ATTACHED BELOW LEFT") == UC_CCC_ATBL);
+  ASSERT (uc_combining_class_byname ("Attached Below Left") == UC_CCC_ATBL);
+  ASSERT (uc_combining_class_byname ("Attached_Below_Left") == UC_CCC_ATBL);
+  ASSERT (uc_combining_class_byname ("AttachedBelowLeft") == UC_CCC_ATBL);
+  ASSERT (uc_combining_class_byname ("ATTACHED BELOW") == UC_CCC_ATB);
+  ASSERT (uc_combining_class_byname ("Attached Below") == UC_CCC_ATB);
+  ASSERT (uc_combining_class_byname ("Attached_Below") == UC_CCC_ATB);
+  ASSERT (uc_combining_class_byname ("AttachedBelow") == UC_CCC_ATB);
+  ASSERT (uc_combining_class_byname ("ATTACHED ABOVE") == UC_CCC_ATA);
+  ASSERT (uc_combining_class_byname ("Attached Above") == UC_CCC_ATA);
+  ASSERT (uc_combining_class_byname ("Attached_Above") == UC_CCC_ATA);
+  ASSERT (uc_combining_class_byname ("AttachedAbove") == UC_CCC_ATA);
+  ASSERT (uc_combining_class_byname ("ATTACHED ABOVE RIGHT") == UC_CCC_ATAR);
+  ASSERT (uc_combining_class_byname ("Attached Above Right") == UC_CCC_ATAR);
+  ASSERT (uc_combining_class_byname ("Attached_Above_Right") == UC_CCC_ATAR);
+  ASSERT (uc_combining_class_byname ("AttachedAboveRight") == UC_CCC_ATAR);
+  ASSERT (uc_combining_class_byname ("BELOW LEFT") == UC_CCC_BL);
+  ASSERT (uc_combining_class_byname ("Below Left") == UC_CCC_BL);
+  ASSERT (uc_combining_class_byname ("Below_Left") == UC_CCC_BL);
+  ASSERT (uc_combining_class_byname ("BelowLeft") == UC_CCC_BL);
+  ASSERT (uc_combining_class_byname ("BELOW") == UC_CCC_B);
+  ASSERT (uc_combining_class_byname ("Below") == UC_CCC_B);
+  ASSERT (uc_combining_class_byname ("BELOW RIGHT") == UC_CCC_BR);
+  ASSERT (uc_combining_class_byname ("Below Right") == UC_CCC_BR);
+  ASSERT (uc_combining_class_byname ("Below_Right") == UC_CCC_BR);
+  ASSERT (uc_combining_class_byname ("BelowRight") == UC_CCC_BR);
+  ASSERT (uc_combining_class_byname ("LEFT") == UC_CCC_L);
+  ASSERT (uc_combining_class_byname ("Left") == UC_CCC_L);
+  ASSERT (uc_combining_class_byname ("RIGHT") == UC_CCC_R);
+  ASSERT (uc_combining_class_byname ("Right") == UC_CCC_R);
+  ASSERT (uc_combining_class_byname ("ABOVE LEFT") == UC_CCC_AL);
+  ASSERT (uc_combining_class_byname ("Above Left") == UC_CCC_AL);
+  ASSERT (uc_combining_class_byname ("Above_Left") == UC_CCC_AL);
+  ASSERT (uc_combining_class_byname ("AboveLeft") == UC_CCC_AL);
+  ASSERT (uc_combining_class_byname ("ABOVE") == UC_CCC_A);
+  ASSERT (uc_combining_class_byname ("ABOVE RIGHT") == UC_CCC_AR);
+  ASSERT (uc_combining_class_byname ("Above Right") == UC_CCC_AR);
+  ASSERT (uc_combining_class_byname ("Above_Right") == UC_CCC_AR);
+  ASSERT (uc_combining_class_byname ("AboveRight") == UC_CCC_AR);
+  ASSERT (uc_combining_class_byname ("DOUBLE BELOW") == UC_CCC_DB);
+  ASSERT (uc_combining_class_byname ("Double Below") == UC_CCC_DB);
+  ASSERT (uc_combining_class_byname ("Double_Below") == UC_CCC_DB);
+  ASSERT (uc_combining_class_byname ("DoubleBelow") == UC_CCC_DB);
+  ASSERT (uc_combining_class_byname ("DOUBLE ABOVE") == UC_CCC_DA);
+  ASSERT (uc_combining_class_byname ("Double Above") == UC_CCC_DA);
+  ASSERT (uc_combining_class_byname ("Double_Above") == UC_CCC_DA);
+  ASSERT (uc_combining_class_byname ("DoubleAbove") == UC_CCC_DA);
+  ASSERT (uc_combining_class_byname ("IOTA SUBSCRIPT") == UC_CCC_IS);
+  ASSERT (uc_combining_class_byname ("Iota Subscript") == UC_CCC_IS);
+  ASSERT (uc_combining_class_byname ("Iota_Subscript") == UC_CCC_IS);
+  ASSERT (uc_combining_class_byname ("IotaSubscript") == UC_CCC_IS);
+
+  return 0;
+}
new file mode 100644
--- /dev/null
+++ b/tests/unictype/test-combiningclass_longname.c
@@ -0,0 +1,53 @@
+/* Test the Unicode character type functions.
+   Copyright (C) 2011 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/>.  */
+
+#include <config.h>
+
+#include "unictype.h"
+
+#include <string.h>
+
+#include "macros.h"
+
+int
+main ()
+{
+  ASSERT (strcmp (uc_combining_class_long_name (UC_CCC_NR), "Not Reordered") == 0);
+  ASSERT (strcmp (uc_combining_class_long_name (UC_CCC_OV), "Overlay") == 0);
+  ASSERT (strcmp (uc_combining_class_long_name (UC_CCC_NK), "Nukta") == 0);
+  ASSERT (strcmp (uc_combining_class_long_name (UC_CCC_KV), "Kana Voicing") == 0);
+  ASSERT (strcmp (uc_combining_class_long_name (UC_CCC_VR), "Virama") == 0);
+  ASSERT (strcmp (uc_combining_class_long_name (UC_CCC_ATBL), "Attached Below Left") == 0);
+  ASSERT (strcmp (uc_combining_class_long_name (UC_CCC_ATB), "Attached Below") == 0);
+  ASSERT (strcmp (uc_combining_class_long_name (UC_CCC_ATA), "Attached Above") == 0);
+  ASSERT (strcmp (uc_combining_class_long_name (UC_CCC_ATAR), "Attached Above Right") == 0);
+  ASSERT (strcmp (uc_combining_class_long_name (UC_CCC_BL), "Below Left") == 0);
+  ASSERT (strcmp (uc_combining_class_long_name (UC_CCC_B), "Below") == 0);
+  ASSERT (strcmp (uc_combining_class_long_name (UC_CCC_BR), "Below Right") == 0);
+  ASSERT (strcmp (uc_combining_class_long_name (UC_CCC_L), "Left") == 0);
+  ASSERT (strcmp (uc_combining_class_long_name (UC_CCC_R), "Right") == 0);
+  ASSERT (strcmp (uc_combining_class_long_name (UC_CCC_AL), "Above Left") == 0);
+  ASSERT (strcmp (uc_combining_class_long_name (UC_CCC_A), "Above") == 0);
+  ASSERT (strcmp (uc_combining_class_long_name (UC_CCC_AR), "Above Right") == 0);
+  ASSERT (strcmp (uc_combining_class_long_name (UC_CCC_DB), "Double Below") == 0);
+  ASSERT (strcmp (uc_combining_class_long_name (UC_CCC_DA), "Double Above") == 0);
+  ASSERT (strcmp (uc_combining_class_long_name (UC_CCC_IS), "Iota Subscript") == 0);
+  ASSERT (uc_combining_class_long_name (-5) == NULL);
+  ASSERT (uc_combining_class_long_name (163) == NULL);
+  ASSERT (uc_combining_class_long_name (255) == NULL);
+
+  return 0;
+}
new file mode 100644
--- /dev/null
+++ b/tests/unictype/test-combiningclass_name.c
@@ -0,0 +1,53 @@
+/* Test the Unicode character type functions.
+   Copyright (C) 2011 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/>.  */
+
+#include <config.h>
+
+#include "unictype.h"
+
+#include <string.h>
+
+#include "macros.h"
+
+int
+main ()
+{
+  ASSERT (strcmp (uc_combining_class_name (UC_CCC_NR), "NR") == 0);
+  ASSERT (strcmp (uc_combining_class_name (UC_CCC_OV), "OV") == 0);
+  ASSERT (strcmp (uc_combining_class_name (UC_CCC_NK), "NK") == 0);
+  ASSERT (strcmp (uc_combining_class_name (UC_CCC_KV), "KV") == 0);
+  ASSERT (strcmp (uc_combining_class_name (UC_CCC_VR), "VR") == 0);
+  ASSERT (strcmp (uc_combining_class_name (UC_CCC_ATBL), "ATBL") == 0);
+  ASSERT (strcmp (uc_combining_class_name (UC_CCC_ATB), "ATB") == 0);
+  ASSERT (strcmp (uc_combining_class_name (UC_CCC_ATA), "ATA") == 0);
+  ASSERT (strcmp (uc_combining_class_name (UC_CCC_ATAR), "ATAR") == 0);
+  ASSERT (strcmp (uc_combining_class_name (UC_CCC_BL), "BL") == 0);
+  ASSERT (strcmp (uc_combining_class_name (UC_CCC_B), "B") == 0);
+  ASSERT (strcmp (uc_combining_class_name (UC_CCC_BR), "BR") == 0);
+  ASSERT (strcmp (uc_combining_class_name (UC_CCC_L), "L") == 0);
+  ASSERT (strcmp (uc_combining_class_name (UC_CCC_R), "R") == 0);
+  ASSERT (strcmp (uc_combining_class_name (UC_CCC_AL), "AL") == 0);
+  ASSERT (strcmp (uc_combining_class_name (UC_CCC_A), "A") == 0);
+  ASSERT (strcmp (uc_combining_class_name (UC_CCC_AR), "AR") == 0);
+  ASSERT (strcmp (uc_combining_class_name (UC_CCC_DB), "DB") == 0);
+  ASSERT (strcmp (uc_combining_class_name (UC_CCC_DA), "DA") == 0);
+  ASSERT (strcmp (uc_combining_class_name (UC_CCC_IS), "IS") == 0);
+  ASSERT (uc_combining_class_name (-5) == NULL);
+  ASSERT (uc_combining_class_name (163) == NULL);
+  ASSERT (uc_combining_class_name (255) == NULL);
+
+  return 0;
+}
new file mode 100644
--- /dev/null
+++ b/tests/unictype/test-joininggroup_byname.c
@@ -0,0 +1,178 @@
+/* Test the Unicode character Arabic joining group functions.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "unictype.h"
+
+#include <string.h>
+
+#include "macros.h"
+
+int
+main ()
+{
+  ASSERT (uc_joining_group_byname ("NO JOINING GROUP") == UC_JOINING_GROUP_NONE);
+  ASSERT (uc_joining_group_byname ("No Joining Group") == UC_JOINING_GROUP_NONE);
+  ASSERT (uc_joining_group_byname ("No_Joining_Group") == UC_JOINING_GROUP_NONE);
+  ASSERT (uc_joining_group_byname ("NoJoiningGroup") == UC_JOINING_GROUP_NONE);
+  ASSERT (uc_joining_group_byname ("AIN") == UC_JOINING_GROUP_AIN);
+  ASSERT (uc_joining_group_byname ("Ain") == UC_JOINING_GROUP_AIN);
+  ASSERT (uc_joining_group_byname ("ALAPH") == UC_JOINING_GROUP_ALAPH);
+  ASSERT (uc_joining_group_byname ("Alaph") == UC_JOINING_GROUP_ALAPH);
+  ASSERT (uc_joining_group_byname ("ALEF") == UC_JOINING_GROUP_ALEF);
+  ASSERT (uc_joining_group_byname ("Alef") == UC_JOINING_GROUP_ALEF);
+  ASSERT (uc_joining_group_byname ("BEH") == UC_JOINING_GROUP_BEH);
+  ASSERT (uc_joining_group_byname ("Beh") == UC_JOINING_GROUP_BEH);
+  ASSERT (uc_joining_group_byname ("BETH") == UC_JOINING_GROUP_BETH);
+  ASSERT (uc_joining_group_byname ("Beth") == UC_JOINING_GROUP_BETH);
+  ASSERT (uc_joining_group_byname ("BURUSHASKI YEH BARREE") == UC_JOINING_GROUP_BURUSHASKI_YEH_BARREE);
+  ASSERT (uc_joining_group_byname ("Burushaski Yeh Barree") == UC_JOINING_GROUP_BURUSHASKI_YEH_BARREE);
+  ASSERT (uc_joining_group_byname ("Burushaski_Yeh_Barree") == UC_JOINING_GROUP_BURUSHASKI_YEH_BARREE);
+  ASSERT (uc_joining_group_byname ("BurushaskiYehBarree") == UC_JOINING_GROUP_BURUSHASKI_YEH_BARREE);
+  ASSERT (uc_joining_group_byname ("DAL") == UC_JOINING_GROUP_DAL);
+  ASSERT (uc_joining_group_byname ("Dal") == UC_JOINING_GROUP_DAL);
+  ASSERT (uc_joining_group_byname ("DALATH RISH") == UC_JOINING_GROUP_DALATH_RISH);
+  ASSERT (uc_joining_group_byname ("Dalath Rish") == UC_JOINING_GROUP_DALATH_RISH);
+  ASSERT (uc_joining_group_byname ("Dalath_Rish") == UC_JOINING_GROUP_DALATH_RISH);
+  ASSERT (uc_joining_group_byname ("DalathRish") == UC_JOINING_GROUP_DALATH_RISH);
+  ASSERT (uc_joining_group_byname ("E") == UC_JOINING_GROUP_E);
+  ASSERT (uc_joining_group_byname ("FARSI YEH") == UC_JOINING_GROUP_FARSI_YEH);
+  ASSERT (uc_joining_group_byname ("Farsi Yeh") == UC_JOINING_GROUP_FARSI_YEH);
+  ASSERT (uc_joining_group_byname ("Farsi_Yeh") == UC_JOINING_GROUP_FARSI_YEH);
+  ASSERT (uc_joining_group_byname ("FarsiYeh") == UC_JOINING_GROUP_FARSI_YEH);
+  ASSERT (uc_joining_group_byname ("FE") == UC_JOINING_GROUP_FE);
+  ASSERT (uc_joining_group_byname ("Fe") == UC_JOINING_GROUP_FE);
+  ASSERT (uc_joining_group_byname ("FEH") == UC_JOINING_GROUP_FEH);
+  ASSERT (uc_joining_group_byname ("Feh") == UC_JOINING_GROUP_FEH);
+  ASSERT (uc_joining_group_byname ("FINAL SEMKATH") == UC_JOINING_GROUP_FINAL_SEMKATH);
+  ASSERT (uc_joining_group_byname ("Final Semkath") == UC_JOINING_GROUP_FINAL_SEMKATH);
+  ASSERT (uc_joining_group_byname ("Final_Semkath") == UC_JOINING_GROUP_FINAL_SEMKATH);
+  ASSERT (uc_joining_group_byname ("FinalSemkath") == UC_JOINING_GROUP_FINAL_SEMKATH);
+  ASSERT (uc_joining_group_byname ("GAF") == UC_JOINING_GROUP_GAF);
+  ASSERT (uc_joining_group_byname ("Gaf") == UC_JOINING_GROUP_GAF);
+  ASSERT (uc_joining_group_byname ("GAMAL") == UC_JOINING_GROUP_GAMAL);
+  ASSERT (uc_joining_group_byname ("Gamal") == UC_JOINING_GROUP_GAMAL);
+  ASSERT (uc_joining_group_byname ("HAH") == UC_JOINING_GROUP_HAH);
+  ASSERT (uc_joining_group_byname ("Hah") == UC_JOINING_GROUP_HAH);
+  ASSERT (uc_joining_group_byname ("HE") == UC_JOINING_GROUP_HE);
+  ASSERT (uc_joining_group_byname ("He") == UC_JOINING_GROUP_HE);
+  ASSERT (uc_joining_group_byname ("HEH") == UC_JOINING_GROUP_HEH);
+  ASSERT (uc_joining_group_byname ("Heh") == UC_JOINING_GROUP_HEH);
+  ASSERT (uc_joining_group_byname ("HEH GOAL") == UC_JOINING_GROUP_HEH_GOAL);
+  ASSERT (uc_joining_group_byname ("Heh Goal") == UC_JOINING_GROUP_HEH_GOAL);
+  ASSERT (uc_joining_group_byname ("Heh_Goal") == UC_JOINING_GROUP_HEH_GOAL);
+  ASSERT (uc_joining_group_byname ("HehGoal") == UC_JOINING_GROUP_HEH_GOAL);
+  ASSERT (uc_joining_group_byname ("HETH") == UC_JOINING_GROUP_HETH);
+  ASSERT (uc_joining_group_byname ("Heth") == UC_JOINING_GROUP_HETH);
+  ASSERT (uc_joining_group_byname ("KAF") == UC_JOINING_GROUP_KAF);
+  ASSERT (uc_joining_group_byname ("Kaf") == UC_JOINING_GROUP_KAF);
+  ASSERT (uc_joining_group_byname ("KAPH") == UC_JOINING_GROUP_KAPH);
+  ASSERT (uc_joining_group_byname ("Kaph") == UC_JOINING_GROUP_KAPH);
+  ASSERT (uc_joining_group_byname ("KHAPH") == UC_JOINING_GROUP_KHAPH);
+  ASSERT (uc_joining_group_byname ("Khaph") == UC_JOINING_GROUP_KHAPH);
+  ASSERT (uc_joining_group_byname ("KNOTTED HEH") == UC_JOINING_GROUP_KNOTTED_HEH);
+  ASSERT (uc_joining_group_byname ("Knotted Heh") == UC_JOINING_GROUP_KNOTTED_HEH);
+  ASSERT (uc_joining_group_byname ("Knotted_Heh") == UC_JOINING_GROUP_KNOTTED_HEH);
+  ASSERT (uc_joining_group_byname ("KnottedHeh") == UC_JOINING_GROUP_KNOTTED_HEH);
+  ASSERT (uc_joining_group_byname ("LAM") == UC_JOINING_GROUP_LAM);
+  ASSERT (uc_joining_group_byname ("Lam") == UC_JOINING_GROUP_LAM);
+  ASSERT (uc_joining_group_byname ("LAMADH") == UC_JOINING_GROUP_LAMADH);
+  ASSERT (uc_joining_group_byname ("Lamadh") == UC_JOINING_GROUP_LAMADH);
+  ASSERT (uc_joining_group_byname ("MEEM") == UC_JOINING_GROUP_MEEM);
+  ASSERT (uc_joining_group_byname ("Meem") == UC_JOINING_GROUP_MEEM);
+  ASSERT (uc_joining_group_byname ("MIM") == UC_JOINING_GROUP_MIM);
+  ASSERT (uc_joining_group_byname ("Mim") == UC_JOINING_GROUP_MIM);
+  ASSERT (uc_joining_group_byname ("NOON") == UC_JOINING_GROUP_NOON);
+  ASSERT (uc_joining_group_byname ("Noon") == UC_JOINING_GROUP_NOON);
+  ASSERT (uc_joining_group_byname ("NUN") == UC_JOINING_GROUP_NUN);
+  ASSERT (uc_joining_group_byname ("Nun") == UC_JOINING_GROUP_NUN);
+  ASSERT (uc_joining_group_byname ("NYA") == UC_JOINING_GROUP_NYA);
+  ASSERT (uc_joining_group_byname ("Nya") == UC_JOINING_GROUP_NYA);
+  ASSERT (uc_joining_group_byname ("PE") == UC_JOINING_GROUP_PE);
+  ASSERT (uc_joining_group_byname ("Pe") == UC_JOINING_GROUP_PE);
+  ASSERT (uc_joining_group_byname ("QAF") == UC_JOINING_GROUP_QAF);
+  ASSERT (uc_joining_group_byname ("Qaf") == UC_JOINING_GROUP_QAF);
+  ASSERT (uc_joining_group_byname ("QAPH") == UC_JOINING_GROUP_QAPH);
+  ASSERT (uc_joining_group_byname ("Qaph") == UC_JOINING_GROUP_QAPH);
+  ASSERT (uc_joining_group_byname ("REH") == UC_JOINING_GROUP_REH);
+  ASSERT (uc_joining_group_byname ("Reh") == UC_JOINING_GROUP_REH);
+  ASSERT (uc_joining_group_byname ("REVERSED PE") == UC_JOINING_GROUP_REVERSED_PE);
+  ASSERT (uc_joining_group_byname ("Reversed Pe") == UC_JOINING_GROUP_REVERSED_PE);
+  ASSERT (uc_joining_group_byname ("Reversed_Pe") == UC_JOINING_GROUP_REVERSED_PE);
+  ASSERT (uc_joining_group_byname ("ReversedPe") == UC_JOINING_GROUP_REVERSED_PE);
+  ASSERT (uc_joining_group_byname ("SAD") == UC_JOINING_GROUP_SAD);
+  ASSERT (uc_joining_group_byname ("Sad") == UC_JOINING_GROUP_SAD);
+  ASSERT (uc_joining_group_byname ("SADHE") == UC_JOINING_GROUP_SADHE);
+  ASSERT (uc_joining_group_byname ("Sadhe") == UC_JOINING_GROUP_SADHE);
+  ASSERT (uc_joining_group_byname ("SEEN") == UC_JOINING_GROUP_SEEN);
+  ASSERT (uc_joining_group_byname ("Seen") == UC_JOINING_GROUP_SEEN);
+  ASSERT (uc_joining_group_byname ("SEMKATH") == UC_JOINING_GROUP_SEMKATH);
+  ASSERT (uc_joining_group_byname ("Semkath") == UC_JOINING_GROUP_SEMKATH);
+  ASSERT (uc_joining_group_byname ("SHIN") == UC_JOINING_GROUP_SHIN);
+  ASSERT (uc_joining_group_byname ("Shin") == UC_JOINING_GROUP_SHIN);
+  ASSERT (uc_joining_group_byname ("SWASH KAF") == UC_JOINING_GROUP_SWASH_KAF);
+  ASSERT (uc_joining_group_byname ("Swash Kaf") == UC_JOINING_GROUP_SWASH_KAF);
+  ASSERT (uc_joining_group_byname ("Swash_Kaf") == UC_JOINING_GROUP_SWASH_KAF);
+  ASSERT (uc_joining_group_byname ("SwashKaf") == UC_JOINING_GROUP_SWASH_KAF);
+  ASSERT (uc_joining_group_byname ("SYRIAC WAW") == UC_JOINING_GROUP_SYRIAC_WAW);
+  ASSERT (uc_joining_group_byname ("Syriac Waw") == UC_JOINING_GROUP_SYRIAC_WAW);
+  ASSERT (uc_joining_group_byname ("Syriac_Waw") == UC_JOINING_GROUP_SYRIAC_WAW);
+  ASSERT (uc_joining_group_byname ("SyriacWaw") == UC_JOINING_GROUP_SYRIAC_WAW);
+  ASSERT (uc_joining_group_byname ("TAH") == UC_JOINING_GROUP_TAH);
+  ASSERT (uc_joining_group_byname ("Tah") == UC_JOINING_GROUP_TAH);
+  ASSERT (uc_joining_group_byname ("TAW") == UC_JOINING_GROUP_TAW);
+  ASSERT (uc_joining_group_byname ("Taw") == UC_JOINING_GROUP_TAW);
+  ASSERT (uc_joining_group_byname ("TEH MARBUTA") == UC_JOINING_GROUP_TEH_MARBUTA);
+  ASSERT (uc_joining_group_byname ("Teh Marbuta") == UC_JOINING_GROUP_TEH_MARBUTA);
+  ASSERT (uc_joining_group_byname ("Teh_Marbuta") == UC_JOINING_GROUP_TEH_MARBUTA);
+  ASSERT (uc_joining_group_byname ("TehMarbuta") == UC_JOINING_GROUP_TEH_MARBUTA);
+  ASSERT (uc_joining_group_byname ("TEH MARBUTA GOAL") == UC_JOINING_GROUP_TEH_MARBUTA_GOAL);
+  ASSERT (uc_joining_group_byname ("Teh Marbuta Goal") == UC_JOINING_GROUP_TEH_MARBUTA_GOAL);
+  ASSERT (uc_joining_group_byname ("Teh_Marbuta_Goal") == UC_JOINING_GROUP_TEH_MARBUTA_GOAL);
+  ASSERT (uc_joining_group_byname ("TehMarbutaGoal") == UC_JOINING_GROUP_TEH_MARBUTA_GOAL);
+  ASSERT (uc_joining_group_byname ("TETH") == UC_JOINING_GROUP_TETH);
+  ASSERT (uc_joining_group_byname ("Teth") == UC_JOINING_GROUP_TETH);
+  ASSERT (uc_joining_group_byname ("WAW") == UC_JOINING_GROUP_WAW);
+  ASSERT (uc_joining_group_byname ("Waw") == UC_JOINING_GROUP_WAW);
+  ASSERT (uc_joining_group_byname ("YEH") == UC_JOINING_GROUP_YEH);
+  ASSERT (uc_joining_group_byname ("Yeh") == UC_JOINING_GROUP_YEH);
+  ASSERT (uc_joining_group_byname ("YEH BARREE") == UC_JOINING_GROUP_YEH_BARREE);
+  ASSERT (uc_joining_group_byname ("Yeh Barree") == UC_JOINING_GROUP_YEH_BARREE);
+  ASSERT (uc_joining_group_byname ("Yeh_Barree") == UC_JOINING_GROUP_YEH_BARREE);
+  ASSERT (uc_joining_group_byname ("YehBarree") == UC_JOINING_GROUP_YEH_BARREE);
+  ASSERT (uc_joining_group_byname ("YEH WITH TAIL") == UC_JOINING_GROUP_YEH_WITH_TAIL);
+  ASSERT (uc_joining_group_byname ("Yeh with tail") == UC_JOINING_GROUP_YEH_WITH_TAIL);
+  ASSERT (uc_joining_group_byname ("Yeh_with_tail") == UC_JOINING_GROUP_YEH_WITH_TAIL);
+  ASSERT (uc_joining_group_byname ("YehWithTail") == UC_JOINING_GROUP_YEH_WITH_TAIL);
+  ASSERT (uc_joining_group_byname ("YUDH") == UC_JOINING_GROUP_YUDH);
+  ASSERT (uc_joining_group_byname ("Yudh") == UC_JOINING_GROUP_YUDH);
+  ASSERT (uc_joining_group_byname ("YUDH HE") == UC_JOINING_GROUP_YUDH_HE);
+  ASSERT (uc_joining_group_byname ("Yudh He") == UC_JOINING_GROUP_YUDH_HE);
+  ASSERT (uc_joining_group_byname ("Yudh_He") == UC_JOINING_GROUP_YUDH_HE);
+  ASSERT (uc_joining_group_byname ("YudhHe") == UC_JOINING_GROUP_YUDH_HE);
+  ASSERT (uc_joining_group_byname ("ZAIN") == UC_JOINING_GROUP_ZAIN);
+  ASSERT (uc_joining_group_byname ("Zain") == UC_JOINING_GROUP_ZAIN);
+  ASSERT (uc_joining_group_byname ("ZHAIN") == UC_JOINING_GROUP_ZHAIN);
+  ASSERT (uc_joining_group_byname ("Zhain") == UC_JOINING_GROUP_ZHAIN);
+  ASSERT (uc_joining_group_byname ("SEEN WITH 3 DOTS BELOW AND 3 DOTS ABOVE") < 0);
+  ASSERT (uc_joining_group_byname ("X") < 0);
+  ASSERT (uc_joining_group_byname ("") < 0);
+
+  return 0;
+}
new file mode 100644
--- /dev/null
+++ b/tests/unictype/test-joininggroup_name.c
@@ -0,0 +1,90 @@
+/* Test the Unicode character Arabic joining group functions.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "unictype.h"
+
+#include <string.h>
+
+#include "macros.h"
+
+int
+main ()
+{
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_NONE),                  "No Joining Group") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_AIN),                   "Ain") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_ALAPH),                 "Alaph") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_ALEF),                  "Alef") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_BEH),                   "Beh") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_BETH),                  "Beth") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_BURUSHASKI_YEH_BARREE), "Burushaski Yeh Barree") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_DAL),                   "Dal") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_DALATH_RISH),           "Dalath Rish") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_E),                     "E") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_FARSI_YEH),             "Farsi Yeh") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_FE),                    "Fe") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_FEH),                   "Feh") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_FINAL_SEMKATH),         "Final Semkath") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_GAF),                   "Gaf") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_GAMAL),                 "Gamal") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_HAH),                   "Hah") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_HE),                    "He") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_HEH),                   "Heh") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_HEH_GOAL),              "Heh Goal") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_HETH),                  "Heth") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_KAF),                   "Kaf") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_KAPH),                  "Kaph") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_KHAPH),                 "Khaph") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_KNOTTED_HEH),           "Knotted Heh") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_LAM),                   "Lam") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_LAMADH),                "Lamadh") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_MEEM),                  "Meem") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_MIM),                   "Mim") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_NOON),                  "Noon") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_NUN),                   "Nun") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_NYA),                   "Nya") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_PE),                    "Pe") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_QAF),                   "Qaf") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_QAPH),                  "Qaph") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_REH),                   "Reh") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_REVERSED_PE),           "Reversed Pe") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_SAD),                   "Sad") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_SADHE),                 "Sadhe") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_SEEN),                  "Seen") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_SEMKATH),               "Semkath") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_SHIN),                  "Shin") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_SWASH_KAF),             "Swash Kaf") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_SYRIAC_WAW),            "Syriac Waw") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_TAH),                   "Tah") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_TAW),                   "Taw") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_TEH_MARBUTA),           "Teh Marbuta") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_TEH_MARBUTA_GOAL),      "Teh Marbuta Goal") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_TETH),                  "Teth") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_WAW),                   "Waw") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_YEH),                   "Yeh") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_YEH_BARREE),            "Yeh Barree") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_YEH_WITH_TAIL),         "Yeh With Tail") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_YUDH),                  "Yudh") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_YUDH_HE),               "Yudh He") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_ZAIN),                  "Zain") == 0);
+  ASSERT (strcmp (uc_joining_group_name (UC_JOINING_GROUP_ZHAIN),                 "Zhain") == 0);
+  ASSERT (uc_joining_group_name (-1) == NULL);
+
+  return 0;
+}
new file mode 100644
--- /dev/null
+++ b/tests/unictype/test-joininggroup_of.c
@@ -0,0 +1,52 @@
+/* Test the Unicode character Arabic joining group functions.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "unictype.h"
+
+#include <string.h>
+
+#include "macros.h"
+
+typedef struct { ucs4_t ch; int value; } pair_t;
+
+static const pair_t mapping[] =
+  {
+#include "test-joininggroup_of.h"
+  };
+
+int
+main ()
+{
+  unsigned int c;
+  size_t i;
+
+  c = 0;
+  for (i = 0; i < SIZEOF (mapping); i++)
+    {
+      for (; c < mapping[i].ch; c++)
+        ASSERT (uc_joining_group (c) == UC_JOINING_GROUP_NONE);
+      ASSERT (uc_joining_group (c) == mapping[i].value);
+      c++;
+    }
+  for (; c < 0x110000; c++)
+    ASSERT (uc_joining_group (c) == UC_JOINING_GROUP_NONE);
+
+  return 0;
+}
new file mode 100644
--- /dev/null
+++ b/tests/unictype/test-joininggroup_of.h
@@ -0,0 +1,233 @@
+/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
+/* Arabic joining group of Unicode characters.  */
+/* Generated automatically by gen-uni-tables.c for Unicode 6.0.0.  */
+    { 0x0620, UC_JOINING_GROUP_YEH },
+    { 0x0622, UC_JOINING_GROUP_ALEF },
+    { 0x0623, UC_JOINING_GROUP_ALEF },
+    { 0x0624, UC_JOINING_GROUP_WAW },
+    { 0x0625, UC_JOINING_GROUP_ALEF },
+    { 0x0626, UC_JOINING_GROUP_YEH },
+    { 0x0627, UC_JOINING_GROUP_ALEF },
+    { 0x0628, UC_JOINING_GROUP_BEH },
+    { 0x0629, UC_JOINING_GROUP_TEH_MARBUTA },
+    { 0x062A, UC_JOINING_GROUP_BEH },
+    { 0x062B, UC_JOINING_GROUP_BEH },
+    { 0x062C, UC_JOINING_GROUP_HAH },
+    { 0x062D, UC_JOINING_GROUP_HAH },
+    { 0x062E, UC_JOINING_GROUP_HAH },
+    { 0x062F, UC_JOINING_GROUP_DAL },
+    { 0x0630, UC_JOINING_GROUP_DAL },
+    { 0x0631, UC_JOINING_GROUP_REH },
+    { 0x0632, UC_JOINING_GROUP_REH },
+    { 0x0633, UC_JOINING_GROUP_SEEN },
+    { 0x0634, UC_JOINING_GROUP_SEEN },
+    { 0x0635, UC_JOINING_GROUP_SAD },
+    { 0x0636, UC_JOINING_GROUP_SAD },
+    { 0x0637, UC_JOINING_GROUP_TAH },
+    { 0x0638, UC_JOINING_GROUP_TAH },
+    { 0x0639, UC_JOINING_GROUP_AIN },
+    { 0x063A, UC_JOINING_GROUP_AIN },
+    { 0x063B, UC_JOINING_GROUP_GAF },
+    { 0x063C, UC_JOINING_GROUP_GAF },
+    { 0x063D, UC_JOINING_GROUP_FARSI_YEH },
+    { 0x063E, UC_JOINING_GROUP_FARSI_YEH },
+    { 0x063F, UC_JOINING_GROUP_FARSI_YEH },
+    { 0x0641, UC_JOINING_GROUP_FEH },
+    { 0x0642, UC_JOINING_GROUP_QAF },
+    { 0x0643, UC_JOINING_GROUP_KAF },
+    { 0x0644, UC_JOINING_GROUP_LAM },
+    { 0x0645, UC_JOINING_GROUP_MEEM },
+    { 0x0646, UC_JOINING_GROUP_NOON },
+    { 0x0647, UC_JOINING_GROUP_HEH },
+    { 0x0648, UC_JOINING_GROUP_WAW },
+    { 0x0649, UC_JOINING_GROUP_YEH },
+    { 0x064A, UC_JOINING_GROUP_YEH },
+    { 0x066E, UC_JOINING_GROUP_BEH },
+    { 0x066F, UC_JOINING_GROUP_QAF },
+    { 0x0671, UC_JOINING_GROUP_ALEF },
+    { 0x0672, UC_JOINING_GROUP_ALEF },
+    { 0x0673, UC_JOINING_GROUP_ALEF },
+    { 0x0675, UC_JOINING_GROUP_ALEF },
+    { 0x0676, UC_JOINING_GROUP_WAW },
+    { 0x0677, UC_JOINING_GROUP_WAW },
+    { 0x0678, UC_JOINING_GROUP_YEH },
+    { 0x0679, UC_JOINING_GROUP_BEH },
+    { 0x067A, UC_JOINING_GROUP_BEH },
+    { 0x067B, UC_JOINING_GROUP_BEH },
+    { 0x067C, UC_JOINING_GROUP_BEH },
+    { 0x067D, UC_JOINING_GROUP_BEH },
+    { 0x067E, UC_JOINING_GROUP_BEH },
+    { 0x067F, UC_JOINING_GROUP_BEH },
+    { 0x0680, UC_JOINING_GROUP_BEH },
+    { 0x0681, UC_JOINING_GROUP_HAH },
+    { 0x0682, UC_JOINING_GROUP_HAH },
+    { 0x0683, UC_JOINING_GROUP_HAH },
+    { 0x0684, UC_JOINING_GROUP_HAH },
+    { 0x0685, UC_JOINING_GROUP_HAH },
+    { 0x0686, UC_JOINING_GROUP_HAH },
+    { 0x0687, UC_JOINING_GROUP_HAH },
+    { 0x0688, UC_JOINING_GROUP_DAL },
+    { 0x0689, UC_JOINING_GROUP_DAL },
+    { 0x068A, UC_JOINING_GROUP_DAL },
+    { 0x068B, UC_JOINING_GROUP_DAL },
+    { 0x068C, UC_JOINING_GROUP_DAL },
+    { 0x068D, UC_JOINING_GROUP_DAL },
+    { 0x068E, UC_JOINING_GROUP_DAL },
+    { 0x068F, UC_JOINING_GROUP_DAL },
+    { 0x0690, UC_JOINING_GROUP_DAL },
+    { 0x0691, UC_JOINING_GROUP_REH },
+    { 0x0692, UC_JOINING_GROUP_REH },
+    { 0x0693, UC_JOINING_GROUP_REH },
+    { 0x0694, UC_JOINING_GROUP_REH },
+    { 0x0695, UC_JOINING_GROUP_REH },
+    { 0x0696, UC_JOINING_GROUP_REH },
+    { 0x0697, UC_JOINING_GROUP_REH },
+    { 0x0698, UC_JOINING_GROUP_REH },
+    { 0x0699, UC_JOINING_GROUP_REH },
+    { 0x069A, UC_JOINING_GROUP_SEEN },
+    { 0x069B, UC_JOINING_GROUP_SEEN },
+    { 0x069C, UC_JOINING_GROUP_SEEN },
+    { 0x069D, UC_JOINING_GROUP_SAD },
+    { 0x069E, UC_JOINING_GROUP_SAD },
+    { 0x069F, UC_JOINING_GROUP_TAH },
+    { 0x06A0, UC_JOINING_GROUP_AIN },
+    { 0x06A1, UC_JOINING_GROUP_FEH },
+    { 0x06A2, UC_JOINING_GROUP_FEH },
+    { 0x06A3, UC_JOINING_GROUP_FEH },
+    { 0x06A4, UC_JOINING_GROUP_FEH },
+    { 0x06A5, UC_JOINING_GROUP_FEH },
+    { 0x06A6, UC_JOINING_GROUP_FEH },
+    { 0x06A7, UC_JOINING_GROUP_QAF },
+    { 0x06A8, UC_JOINING_GROUP_QAF },
+    { 0x06A9, UC_JOINING_GROUP_GAF },
+    { 0x06AA, UC_JOINING_GROUP_SWASH_KAF },
+    { 0x06AB, UC_JOINING_GROUP_GAF },
+    { 0x06AC, UC_JOINING_GROUP_KAF },
+    { 0x06AD, UC_JOINING_GROUP_KAF },
+    { 0x06AE, UC_JOINING_GROUP_KAF },
+    { 0x06AF, UC_JOINING_GROUP_GAF },
+    { 0x06B0, UC_JOINING_GROUP_GAF },
+    { 0x06B1, UC_JOINING_GROUP_GAF },
+    { 0x06B2, UC_JOINING_GROUP_GAF },
+    { 0x06B3, UC_JOINING_GROUP_GAF },
+    { 0x06B4, UC_JOINING_GROUP_GAF },
+    { 0x06B5, UC_JOINING_GROUP_LAM },
+    { 0x06B6, UC_JOINING_GROUP_LAM },
+    { 0x06B7, UC_JOINING_GROUP_LAM },
+    { 0x06B8, UC_JOINING_GROUP_LAM },
+    { 0x06B9, UC_JOINING_GROUP_NOON },
+    { 0x06BA, UC_JOINING_GROUP_NOON },
+    { 0x06BB, UC_JOINING_GROUP_NOON },
+    { 0x06BC, UC_JOINING_GROUP_NOON },
+    { 0x06BD, UC_JOINING_GROUP_NYA },
+    { 0x06BE, UC_JOINING_GROUP_KNOTTED_HEH },
+    { 0x06BF, UC_JOINING_GROUP_HAH },
+    { 0x06C0, UC_JOINING_GROUP_TEH_MARBUTA },
+    { 0x06C1, UC_JOINING_GROUP_HEH_GOAL },
+    { 0x06C2, UC_JOINING_GROUP_HEH_GOAL },
+    { 0x06C3, UC_JOINING_GROUP_TEH_MARBUTA_GOAL },
+    { 0x06C4, UC_JOINING_GROUP_WAW },
+    { 0x06C5, UC_JOINING_GROUP_WAW },
+    { 0x06C6, UC_JOINING_GROUP_WAW },
+    { 0x06C7, UC_JOINING_GROUP_WAW },
+    { 0x06C8, UC_JOINING_GROUP_WAW },
+    { 0x06C9, UC_JOINING_GROUP_WAW },
+    { 0x06CA, UC_JOINING_GROUP_WAW },
+    { 0x06CB, UC_JOINING_GROUP_WAW },
+    { 0x06CC, UC_JOINING_GROUP_FARSI_YEH },
+    { 0x06CD, UC_JOINING_GROUP_YEH_WITH_TAIL },
+    { 0x06CE, UC_JOINING_GROUP_FARSI_YEH },
+    { 0x06CF, UC_JOINING_GROUP_WAW },
+    { 0x06D0, UC_JOINING_GROUP_YEH },
+    { 0x06D1, UC_JOINING_GROUP_YEH },
+    { 0x06D2, UC_JOINING_GROUP_YEH_BARREE },
+    { 0x06D3, UC_JOINING_GROUP_YEH_BARREE },
+    { 0x06D5, UC_JOINING_GROUP_TEH_MARBUTA },
+    { 0x06EE, UC_JOINING_GROUP_DAL },
+    { 0x06EF, UC_JOINING_GROUP_REH },
+    { 0x06FA, UC_JOINING_GROUP_SEEN },
+    { 0x06FB, UC_JOINING_GROUP_SAD },
+    { 0x06FC, UC_JOINING_GROUP_AIN },
+    { 0x06FF, UC_JOINING_GROUP_KNOTTED_HEH },
+    { 0x0710, UC_JOINING_GROUP_ALAPH },
+    { 0x0712, UC_JOINING_GROUP_BETH },
+    { 0x0713, UC_JOINING_GROUP_GAMAL },
+    { 0x0714, UC_JOINING_GROUP_GAMAL },
+    { 0x0715, UC_JOINING_GROUP_DALATH_RISH },
+    { 0x0716, UC_JOINING_GROUP_DALATH_RISH },
+    { 0x0717, UC_JOINING_GROUP_HE },
+    { 0x0718, UC_JOINING_GROUP_SYRIAC_WAW },
+    { 0x0719, UC_JOINING_GROUP_ZAIN },
+    { 0x071A, UC_JOINING_GROUP_HETH },
+    { 0x071B, UC_JOINING_GROUP_TETH },
+    { 0x071C, UC_JOINING_GROUP_TETH },
+    { 0x071D, UC_JOINING_GROUP_YUDH },
+    { 0x071E, UC_JOINING_GROUP_YUDH_HE },
+    { 0x071F, UC_JOINING_GROUP_KAPH },
+    { 0x0720, UC_JOINING_GROUP_LAMADH },
+    { 0x0721, UC_JOINING_GROUP_MIM },
+    { 0x0722, UC_JOINING_GROUP_NUN },
+    { 0x0723, UC_JOINING_GROUP_SEMKATH },
+    { 0x0724, UC_JOINING_GROUP_FINAL_SEMKATH },
+    { 0x0725, UC_JOINING_GROUP_E },
+    { 0x0726, UC_JOINING_GROUP_PE },
+    { 0x0727, UC_JOINING_GROUP_REVERSED_PE },
+    { 0x0728, UC_JOINING_GROUP_SADHE },
+    { 0x0729, UC_JOINING_GROUP_QAPH },
+    { 0x072A, UC_JOINING_GROUP_DALATH_RISH },
+    { 0x072B, UC_JOINING_GROUP_SHIN },
+    { 0x072C, UC_JOINING_GROUP_TAW },
+    { 0x072D, UC_JOINING_GROUP_BETH },
+    { 0x072E, UC_JOINING_GROUP_GAMAL },
+    { 0x072F, UC_JOINING_GROUP_DALATH_RISH },
+    { 0x074D, UC_JOINING_GROUP_ZHAIN },
+    { 0x074E, UC_JOINING_GROUP_KHAPH },
+    { 0x074F, UC_JOINING_GROUP_FE },
+    { 0x0750, UC_JOINING_GROUP_BEH },
+    { 0x0751, UC_JOINING_GROUP_BEH },
+    { 0x0752, UC_JOINING_GROUP_BEH },
+    { 0x0753, UC_JOINING_GROUP_BEH },
+    { 0x0754, UC_JOINING_GROUP_BEH },
+    { 0x0755, UC_JOINING_GROUP_BEH },
+    { 0x0756, UC_JOINING_GROUP_BEH },
+    { 0x0757, UC_JOINING_GROUP_HAH },
+    { 0x0758, UC_JOINING_GROUP_HAH },
+    { 0x0759, UC_JOINING_GROUP_DAL },
+    { 0x075A, UC_JOINING_GROUP_DAL },
+    { 0x075B, UC_JOINING_GROUP_REH },
+    { 0x075C, UC_JOINING_GROUP_SEEN },
+    { 0x075D, UC_JOINING_GROUP_AIN },
+    { 0x075E, UC_JOINING_GROUP_AIN },
+    { 0x075F, UC_JOINING_GROUP_AIN },
+    { 0x0760, UC_JOINING_GROUP_FEH },
+    { 0x0761, UC_JOINING_GROUP_FEH },
+    { 0x0762, UC_JOINING_GROUP_GAF },
+    { 0x0763, UC_JOINING_GROUP_GAF },
+    { 0x0764, UC_JOINING_GROUP_GAF },
+    { 0x0765, UC_JOINING_GROUP_MEEM },
+    { 0x0766, UC_JOINING_GROUP_MEEM },
+    { 0x0767, UC_JOINING_GROUP_NOON },
+    { 0x0768, UC_JOINING_GROUP_NOON },
+    { 0x0769, UC_JOINING_GROUP_NOON },
+    { 0x076A, UC_JOINING_GROUP_LAM },
+    { 0x076B, UC_JOINING_GROUP_REH },
+    { 0x076C, UC_JOINING_GROUP_REH },
+    { 0x076D, UC_JOINING_GROUP_SEEN },
+    { 0x076E, UC_JOINING_GROUP_HAH },
+    { 0x076F, UC_JOINING_GROUP_HAH },
+    { 0x0770, UC_JOINING_GROUP_SEEN },
+    { 0x0771, UC_JOINING_GROUP_REH },
+    { 0x0772, UC_JOINING_GROUP_HAH },
+    { 0x0773, UC_JOINING_GROUP_ALEF },
+    { 0x0774, UC_JOINING_GROUP_ALEF },
+    { 0x0775, UC_JOINING_GROUP_FARSI_YEH },
+    { 0x0776, UC_JOINING_GROUP_FARSI_YEH },
+    { 0x0777, UC_JOINING_GROUP_YEH },
+    { 0x0778, UC_JOINING_GROUP_WAW },
+    { 0x0779, UC_JOINING_GROUP_WAW },
+    { 0x077A, UC_JOINING_GROUP_BURUSHASKI_YEH_BARREE },
+    { 0x077B, UC_JOINING_GROUP_BURUSHASKI_YEH_BARREE },
+    { 0x077C, UC_JOINING_GROUP_HAH },
+    { 0x077D, UC_JOINING_GROUP_SEEN },
+    { 0x077E, UC_JOINING_GROUP_SEEN },
+    { 0x077F, UC_JOINING_GROUP_KAF }
new file mode 100644
--- /dev/null
+++ b/tests/unictype/test-joiningtype_byname.c
@@ -0,0 +1,64 @@
+/* Test the Unicode character Arabic joining type functions.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "unictype.h"
+
+#include <string.h>
+
+#include "macros.h"
+
+int
+main ()
+{
+  ASSERT (uc_joining_type_byname ("U") == UC_JOINING_TYPE_U);
+  ASSERT (uc_joining_type_byname ("T") == UC_JOINING_TYPE_T);
+  ASSERT (uc_joining_type_byname ("C") == UC_JOINING_TYPE_C);
+  ASSERT (uc_joining_type_byname ("L") == UC_JOINING_TYPE_L);
+  ASSERT (uc_joining_type_byname ("R") == UC_JOINING_TYPE_R);
+  ASSERT (uc_joining_type_byname ("D") == UC_JOINING_TYPE_D);
+
+  ASSERT (uc_joining_type_byname ("JOIN CAUSING") == UC_JOINING_TYPE_C);
+  ASSERT (uc_joining_type_byname ("Join Causing") == UC_JOINING_TYPE_C);
+  ASSERT (uc_joining_type_byname ("Join_Causing") == UC_JOINING_TYPE_C);
+  ASSERT (uc_joining_type_byname ("JoinCausing") == UC_JOINING_TYPE_C);
+  ASSERT (uc_joining_type_byname ("DUAL JOINING") == UC_JOINING_TYPE_D);
+  ASSERT (uc_joining_type_byname ("Dual Joining") == UC_JOINING_TYPE_D);
+  ASSERT (uc_joining_type_byname ("Dual_Joining") == UC_JOINING_TYPE_D);
+  ASSERT (uc_joining_type_byname ("DualJoining") == UC_JOINING_TYPE_D);
+  ASSERT (uc_joining_type_byname ("LEFT JOINING") == UC_JOINING_TYPE_L);
+  ASSERT (uc_joining_type_byname ("Left Joining") == UC_JOINING_TYPE_L);
+  ASSERT (uc_joining_type_byname ("Left_Joining") == UC_JOINING_TYPE_L);
+  ASSERT (uc_joining_type_byname ("LeftJoining") == UC_JOINING_TYPE_L);
+  ASSERT (uc_joining_type_byname ("RIGHT JOINING") == UC_JOINING_TYPE_R);
+  ASSERT (uc_joining_type_byname ("Right Joining") == UC_JOINING_TYPE_R);
+  ASSERT (uc_joining_type_byname ("Right_Joining") == UC_JOINING_TYPE_R);
+  ASSERT (uc_joining_type_byname ("RightJoining") == UC_JOINING_TYPE_R);
+  ASSERT (uc_joining_type_byname ("TRANSPARENT") == UC_JOINING_TYPE_T);
+  ASSERT (uc_joining_type_byname ("Transparent") == UC_JOINING_TYPE_T);
+  ASSERT (uc_joining_type_byname ("NON JOINING") == UC_JOINING_TYPE_U);
+  ASSERT (uc_joining_type_byname ("Non Joining") == UC_JOINING_TYPE_U);
+  ASSERT (uc_joining_type_byname ("Non_Joining") == UC_JOINING_TYPE_U);
+  ASSERT (uc_joining_type_byname ("NonJoining") == UC_JOINING_TYPE_U);
+
+  ASSERT (uc_joining_type_byname ("X") < 0);
+  ASSERT (uc_joining_type_byname ("") < 0);
+
+  return 0;
+}
new file mode 100644
--- /dev/null
+++ b/tests/unictype/test-joiningtype_longname.c
@@ -0,0 +1,39 @@
+/* Test the Unicode character Arabic joining type functions.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "unictype.h"
+
+#include <string.h>
+
+#include "macros.h"
+
+int
+main ()
+{
+  ASSERT (strcmp (uc_joining_type_long_name (UC_JOINING_TYPE_U), "Non Joining") == 0);
+  ASSERT (strcmp (uc_joining_type_long_name (UC_JOINING_TYPE_T), "Transparent") == 0);
+  ASSERT (strcmp (uc_joining_type_long_name (UC_JOINING_TYPE_C), "Join Causing") == 0);
+  ASSERT (strcmp (uc_joining_type_long_name (UC_JOINING_TYPE_L), "Left Joining") == 0);
+  ASSERT (strcmp (uc_joining_type_long_name (UC_JOINING_TYPE_R), "Right Joining") == 0);
+  ASSERT (strcmp (uc_joining_type_long_name (UC_JOINING_TYPE_D), "Dual Joining") == 0);
+  ASSERT (uc_joining_type_long_name (-1) == NULL);
+
+  return 0;
+}
new file mode 100644
--- /dev/null
+++ b/tests/unictype/test-joiningtype_name.c
@@ -0,0 +1,39 @@
+/* Test the Unicode character Arabic joining type functions.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "unictype.h"
+
+#include <string.h>
+
+#include "macros.h"
+
+int
+main ()
+{
+  ASSERT (strcmp (uc_joining_type_name (UC_JOINING_TYPE_U), "U") == 0);
+  ASSERT (strcmp (uc_joining_type_name (UC_JOINING_TYPE_T), "T") == 0);
+  ASSERT (strcmp (uc_joining_type_name (UC_JOINING_TYPE_C), "C") == 0);
+  ASSERT (strcmp (uc_joining_type_name (UC_JOINING_TYPE_L), "L") == 0);
+  ASSERT (strcmp (uc_joining_type_name (UC_JOINING_TYPE_R), "R") == 0);
+  ASSERT (strcmp (uc_joining_type_name (UC_JOINING_TYPE_D), "D") == 0);
+  ASSERT (uc_joining_type_name (-1) == NULL);
+
+  return 0;
+}
new file mode 100644
--- /dev/null
+++ b/tests/unictype/test-joiningtype_of.c
@@ -0,0 +1,65 @@
+/* Test the Unicode character Arabic joining type functions.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Written by Bruno Haible <bruno@clisp.org>, 2011.
+
+   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 "unictype.h"
+
+#include <string.h>
+
+#include "macros.h"
+
+typedef struct { ucs4_t ch; int value; } pair_t;
+
+static const pair_t mapping[] =
+  {
+#include "test-joiningtype_of.h"
+  };
+
+int
+main ()
+{
+  unsigned int c;
+  size_t i;
+
+  c = 0;
+  for (i = 0; i < SIZEOF (mapping); i++)
+    {
+      for (; c < mapping[i].ch; c++)
+        ASSERT (uc_joining_type (c) == UC_JOINING_TYPE_U
+                || uc_joining_type (c) == UC_JOINING_TYPE_T);
+      ASSERT (uc_joining_type (c) == mapping[i].value);
+      c++;
+    }
+  for (; c < 0x110000; c++)
+    ASSERT (uc_joining_type (c) == UC_JOINING_TYPE_U
+            || uc_joining_type (c) == UC_JOINING_TYPE_T);
+
+  /* Test distinction between U and T.  */
+  ASSERT (uc_joining_type (0x060C) == UC_JOINING_TYPE_U);
+  ASSERT (uc_joining_type (0x060D) == UC_JOINING_TYPE_U);
+  ASSERT (uc_joining_type (0x060E) == UC_JOINING_TYPE_U);
+  ASSERT (uc_joining_type (0x060F) == UC_JOINING_TYPE_U);
+  ASSERT (uc_joining_type (0x0610) == UC_JOINING_TYPE_T);
+  ASSERT (uc_joining_type (0x0611) == UC_JOINING_TYPE_T);
+  ASSERT (uc_joining_type (0x0612) == UC_JOINING_TYPE_T);
+  ASSERT (uc_joining_type (0x0613) == UC_JOINING_TYPE_T);
+  ASSERT (uc_joining_type (0x0614) == UC_JOINING_TYPE_T);
+
+  return 0;
+}
new file mode 100644
--- /dev/null
+++ b/tests/unictype/test-joiningtype_of.h
@@ -0,0 +1,279 @@
+/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
+/* Arabic joining type of Unicode characters.  */
+/* Generated automatically by gen-uni-tables.c for Unicode 6.0.0.  */
+    { 0x0600, UC_JOINING_TYPE_U },
+    { 0x0601, UC_JOINING_TYPE_U },
+    { 0x0602, UC_JOINING_TYPE_U },
+    { 0x0603, UC_JOINING_TYPE_U },
+    { 0x0608, UC_JOINING_TYPE_U },
+    { 0x060B, UC_JOINING_TYPE_U },
+    { 0x0620, UC_JOINING_TYPE_D },
+    { 0x0621, UC_JOINING_TYPE_U },
+    { 0x0622, UC_JOINING_TYPE_R },
+    { 0x0623, UC_JOINING_TYPE_R },
+    { 0x0624, UC_JOINING_TYPE_R },
+    { 0x0625, UC_JOINING_TYPE_R },
+    { 0x0626, UC_JOINING_TYPE_D },
+    { 0x0627, UC_JOINING_TYPE_R },
+    { 0x0628, UC_JOINING_TYPE_D },
+    { 0x0629, UC_JOINING_TYPE_R },
+    { 0x062A, UC_JOINING_TYPE_D },
+    { 0x062B, UC_JOINING_TYPE_D },
+    { 0x062C, UC_JOINING_TYPE_D },
+    { 0x062D, UC_JOINING_TYPE_D },
+    { 0x062E, UC_JOINING_TYPE_D },
+    { 0x062F, UC_JOINING_TYPE_R },
+    { 0x0630, UC_JOINING_TYPE_R },
+    { 0x0631, UC_JOINING_TYPE_R },
+    { 0x0632, UC_JOINING_TYPE_R },
+    { 0x0633, UC_JOINING_TYPE_D },
+    { 0x0634, UC_JOINING_TYPE_D },
+    { 0x0635, UC_JOINING_TYPE_D },
+    { 0x0636, UC_JOINING_TYPE_D },
+    { 0x0637, UC_JOINING_TYPE_D },
+    { 0x0638, UC_JOINING_TYPE_D },
+    { 0x0639, UC_JOINING_TYPE_D },
+    { 0x063A, UC_JOINING_TYPE_D },
+    { 0x063B, UC_JOINING_TYPE_D },
+    { 0x063C, UC_JOINING_TYPE_D },
+    { 0x063D, UC_JOINING_TYPE_D },
+    { 0x063E, UC_JOINING_TYPE_D },
+    { 0x063F, UC_JOINING_TYPE_D },
+    { 0x0640, UC_JOINING_TYPE_C },
+    { 0x0641, UC_JOINING_TYPE_D },
+    { 0x0642, UC_JOINING_TYPE_D },
+    { 0x0643, UC_JOINING_TYPE_D },
+    { 0x0644, UC_JOINING_TYPE_D },
+    { 0x0645, UC_JOINING_TYPE_D },
+    { 0x0646, UC_JOINING_TYPE_D },
+    { 0x0647, UC_JOINING_TYPE_D },
+    { 0x0648, UC_JOINING_TYPE_R },
+    { 0x0649, UC_JOINING_TYPE_D },
+    { 0x064A, UC_JOINING_TYPE_D },
+    { 0x066E, UC_JOINING_TYPE_D },
+    { 0x066F, UC_JOINING_TYPE_D },
+    { 0x0671, UC_JOINING_TYPE_R },
+    { 0x0672, UC_JOINING_TYPE_R },
+    { 0x0673, UC_JOINING_TYPE_R },
+    { 0x0674, UC_JOINING_TYPE_U },
+    { 0x0675, UC_JOINING_TYPE_R },
+    { 0x0676, UC_JOINING_TYPE_R },
+    { 0x0677, UC_JOINING_TYPE_R },
+    { 0x0678, UC_JOINING_TYPE_D },
+    { 0x0679, UC_JOINING_TYPE_D },
+    { 0x067A, UC_JOINING_TYPE_D },
+    { 0x067B, UC_JOINING_TYPE_D },
+    { 0x067C, UC_JOINING_TYPE_D },
+    { 0x067D, UC_JOINING_TYPE_D },
+    { 0x067E, UC_JOINING_TYPE_D },
+    { 0x067F, UC_JOINING_TYPE_D },
+    { 0x0680, UC_JOINING_TYPE_D },
+    { 0x0681, UC_JOINING_TYPE_D },
+    { 0x0682, UC_JOINING_TYPE_D },
+    { 0x0683, UC_JOINING_TYPE_D },
+    { 0x0684, UC_JOINING_TYPE_D },
+    { 0x0685, UC_JOINING_TYPE_D },
+    { 0x0686, UC_JOINING_TYPE_D },
+    { 0x0687, UC_JOINING_TYPE_D },
+    { 0x0688, UC_JOINING_TYPE_R },
+    { 0x0689, UC_JOINING_TYPE_R },
+    { 0x068A, UC_JOINING_TYPE_R },
+    { 0x068B, UC_JOINING_TYPE_R },
+    { 0x068C, UC_JOINING_TYPE_R },
+    { 0x068D, UC_JOINING_TYPE_R },
+    { 0x068E, UC_JOINING_TYPE_R },
+    { 0x068F, UC_JOINING_TYPE_R },
+    { 0x0690, UC_JOINING_TYPE_R },
+    { 0x0691, UC_JOINING_TYPE_R },
+    { 0x0692, UC_JOINING_TYPE_R },
+    { 0x0693, UC_JOINING_TYPE_R },
+    { 0x0694, UC_JOINING_TYPE_R },
+    { 0x0695, UC_JOINING_TYPE_R },
+    { 0x0696, UC_JOINING_TYPE_R },
+    { 0x0697, UC_JOINING_TYPE_R },
+    { 0x0698, UC_JOINING_TYPE_R },
+    { 0x0699, UC_JOINING_TYPE_R },
+    { 0x069A, UC_JOINING_TYPE_D },
+    { 0x069B, UC_JOINING_TYPE_D },
+    { 0x069C, UC_JOINING_TYPE_D },
+    { 0x069D, UC_JOINING_TYPE_D },
+    { 0x069E, UC_JOINING_TYPE_D },
+    { 0x069F, UC_JOINING_TYPE_D },
+    { 0x06A0, UC_JOINING_TYPE_D },
+    { 0x06A1, UC_JOINING_TYPE_D },
+    { 0x06A2, UC_JOINING_TYPE_D },
+    { 0x06A3, UC_JOINING_TYPE_D },
+    { 0x06A4, UC_JOINING_TYPE_D },
+    { 0x06A5, UC_JOINING_TYPE_D },
+    { 0x06A6, UC_JOINING_TYPE_D },
+    { 0x06A7, UC_JOINING_TYPE_D },
+    { 0x06A8, UC_JOINING_TYPE_D },
+    { 0x06A9, UC_JOINING_TYPE_D },
+    { 0x06AA, UC_JOINING_TYPE_D },
+    { 0x06AB, UC_JOINING_TYPE_D },
+    { 0x06AC, UC_JOINING_TYPE_D },
+    { 0x06AD, UC_JOINING_TYPE_D },
+    { 0x06AE, UC_JOINING_TYPE_D },
+    { 0x06AF, UC_JOINING_TYPE_D },
+    { 0x06B0, UC_JOINING_TYPE_D },
+    { 0x06B1, UC_JOINING_TYPE_D },
+    { 0x06B2, UC_JOINING_TYPE_D },
+    { 0x06B3, UC_JOINING_TYPE_D },
+    { 0x06B4, UC_JOINING_TYPE_D },
+    { 0x06B5, UC_JOINING_TYPE_D },
+    { 0x06B6, UC_JOINING_TYPE_D },
+    { 0x06B7, UC_JOINING_TYPE_D },
+    { 0x06B8, UC_JOINING_TYPE_D },
+    { 0x06B9, UC_JOINING_TYPE_D },
+    { 0x06BA, UC_JOINING_TYPE_D },
+    { 0x06BB, UC_JOINING_TYPE_D },
+    { 0x06BC, UC_JOINING_TYPE_D },
+    { 0x06BD, UC_JOINING_TYPE_D },
+    { 0x06BE, UC_JOINING_TYPE_D },
+    { 0x06BF, UC_JOINING_TYPE_D },
+    { 0x06C0, UC_JOINING_TYPE_R },
+    { 0x06C1, UC_JOINING_TYPE_D },
+    { 0x06C2, UC_JOINING_TYPE_D },
+    { 0x06C3, UC_JOINING_TYPE_R },
+    { 0x06C4, UC_JOINING_TYPE_R },
+    { 0x06C5, UC_JOINING_TYPE_R },
+    { 0x06C6, UC_JOINING_TYPE_R },
+    { 0x06C7, UC_JOINING_TYPE_R },
+    { 0x06C8, UC_JOINING_TYPE_R },
+    { 0x06C9, UC_JOINING_TYPE_R },
+    { 0x06CA, UC_JOINING_TYPE_R },
+    { 0x06CB, UC_JOINING_TYPE_R },
+    { 0x06CC, UC_JOINING_TYPE_D },
+    { 0x06CD, UC_JOINING_TYPE_R },
+    { 0x06CE, UC_JOINING_TYPE_D },
+    { 0x06CF, UC_JOINING_TYPE_R },
+    { 0x06D0, UC_JOINING_TYPE_D },
+    { 0x06D1, UC_JOINING_TYPE_D },
+    { 0x06D2, UC_JOINING_TYPE_R },
+    { 0x06D3, UC_JOINING_TYPE_R },
+    { 0x06D5, UC_JOINING_TYPE_R },
+    { 0x06DD, UC_JOINING_TYPE_U },
+    { 0x06EE, UC_JOINING_TYPE_R },
+    { 0x06EF, UC_JOINING_TYPE_R },
+    { 0x06FA, UC_JOINING_TYPE_D },
+    { 0x06FB, UC_JOINING_TYPE_D },
+    { 0x06FC, UC_JOINING_TYPE_D },
+    { 0x06FF, UC_JOINING_TYPE_D },
+    { 0x0710, UC_JOINING_TYPE_R },
+    { 0x0712, UC_JOINING_TYPE_D },
+    { 0x0713, UC_JOINING_TYPE_D },
+    { 0x0714, UC_JOINING_TYPE_D },
+    { 0x0715, UC_JOINING_TYPE_R },
+    { 0x0716, UC_JOINING_TYPE_R },
+    { 0x0717, UC_JOINING_TYPE_R },
+    { 0x0718, UC_JOINING_TYPE_R },
+    { 0x0719, UC_JOINING_TYPE_R },
+    { 0x071A, UC_JOINING_TYPE_D },
+    { 0x071B, UC_JOINING_TYPE_D },
+    { 0x071C, UC_JOINING_TYPE_D },
+    { 0x071D, UC_JOINING_TYPE_D },
+    { 0x071E, UC_JOINING_TYPE_R },
+    { 0x071F, UC_JOINING_TYPE_D },
+    { 0x0720, UC_JOINING_TYPE_D },
+    { 0x0721, UC_JOINING_TYPE_D },
+    { 0x0722, UC_JOINING_TYPE_D },
+    { 0x0723, UC_JOINING_TYPE_D },
+    { 0x0724, UC_JOINING_TYPE_D },
+    { 0x0725, UC_JOINING_TYPE_D },
+    { 0x0726, UC_JOINING_TYPE_D },
+    { 0x0727, UC_JOINING_TYPE_D },
+    { 0x0728, UC_JOINING_TYPE_R },
+    { 0x0729, UC_JOINING_TYPE_D },
+    { 0x072A, UC_JOINING_TYPE_R },
+    { 0x072B, UC_JOINING_TYPE_D },
+    { 0x072C, UC_JOINING_TYPE_R },
+    { 0x072D, UC_JOINING_TYPE_D },
+    { 0x072E, UC_JOINING_TYPE_D },
+    { 0x072F, UC_JOINING_TYPE_R },
+    { 0x074D, UC_JOINING_TYPE_R },
+    { 0x074E, UC_JOINING_TYPE_D },
+    { 0x074F, UC_JOINING_TYPE_D },
+    { 0x0750, UC_JOINING_TYPE_D },
+    { 0x0751, UC_JOINING_TYPE_D },
+    { 0x0752, UC_JOINING_TYPE_D },
+    { 0x0753, UC_JOINING_TYPE_D },
+    { 0x0754, UC_JOINING_TYPE_D },
+    { 0x0755, UC_JOINING_TYPE_D },
+    { 0x0756, UC_JOINING_TYPE_D },
+    { 0x0757, UC_JOINING_TYPE_D },
+    { 0x0758, UC_JOINING_TYPE_D },
+    { 0x0759, UC_JOINING_TYPE_R },
+    { 0x075A, UC_JOINING_TYPE_R },
+    { 0x075B, UC_JOINING_TYPE_R },
+    { 0x075C, UC_JOINING_TYPE_D },
+    { 0x075D, UC_JOINING_TYPE_D },
+    { 0x075E, UC_JOINING_TYPE_D },
+    { 0x075F, UC_JOINING_TYPE_D },
+    { 0x0760, UC_JOINING_TYPE_D },
+    { 0x0761, UC_JOINING_TYPE_D },
+    { 0x0762, UC_JOINING_TYPE_D },
+    { 0x0763, UC_JOINING_TYPE_D },
+    { 0x0764, UC_JOINING_TYPE_D },
+    { 0x0765, UC_JOINING_TYPE_D },
+    { 0x0766, UC_JOINING_TYPE_D },
+    { 0x0767, UC_JOINING_TYPE_D },
+    { 0x0768, UC_JOINING_TYPE_D },
+    { 0x0769, UC_JOINING_TYPE_D },
+    { 0x076A, UC_JOINING_TYPE_D },
+    { 0x076B, UC_JOINING_TYPE_R },
+    { 0x076C, UC_JOINING_TYPE_R },
+    { 0x076D, UC_JOINING_TYPE_D },
+    { 0x076E, UC_JOINING_TYPE_D },
+    { 0x076F, UC_JOINING_TYPE_D },
+    { 0x0770, UC_JOINING_TYPE_D },
+    { 0x0771, UC_JOINING_TYPE_R },
+    { 0x0772, UC_JOINING_TYPE_D },
+    { 0x0773, UC_JOINING_TYPE_R },
+    { 0x0774, UC_JOINING_TYPE_R },
+    { 0x0775, UC_JOINING_TYPE_D },
+    { 0x0776, UC_JOINING_TYPE_D },
+    { 0x0777, UC_JOINING_TYPE_D },
+    { 0x0778, UC_JOINING_TYPE_R },
+    { 0x0779, UC_JOINING_TYPE_R },
+    { 0x077A, UC_JOINING_TYPE_D },
+    { 0x077B, UC_JOINING_TYPE_D },
+    { 0x077C, UC_JOINING_TYPE_D },
+    { 0x077D, UC_JOINING_TYPE_D },
+    { 0x077E, UC_JOINING_TYPE_D },
+    { 0x077F, UC_JOINING_TYPE_D },
+    { 0x07CA, UC_JOINING_TYPE_D },
+    { 0x07CB, UC_JOINING_TYPE_D },
+    { 0x07CC, UC_JOINING_TYPE_D },
+    { 0x07CD, UC_JOINING_TYPE_D },
+    { 0x07CE, UC_JOINING_TYPE_D },
+    { 0x07CF, UC_JOINING_TYPE_D },
+    { 0x07D0, UC_JOINING_TYPE_D },
+    { 0x07D1, UC_JOINING_TYPE_D },
+    { 0x07D2, UC_JOINING_TYPE_D },
+    { 0x07D3, UC_JOINING_TYPE_D },
+    { 0x07D4, UC_JOINING_TYPE_D },
+    { 0x07D5, UC_JOINING_TYPE_D },
+    { 0x07D6, UC_JOINING_TYPE_D },
+    { 0x07D7, UC_JOINING_TYPE_D },
+    { 0x07D8, UC_JOINING_TYPE_D },
+    { 0x07D9, UC_JOINING_TYPE_D },
+    { 0x07DA, UC_JOINING_TYPE_D },
+    { 0x07DB, UC_JOINING_TYPE_D },
+    { 0x07DC, UC_JOINING_TYPE_D },
+    { 0x07DD, UC_JOINING_TYPE_D },
+    { 0x07DE, UC_JOINING_TYPE_D },
+    { 0x07DF, UC_JOINING_TYPE_D },
+    { 0x07E0, UC_JOINING_TYPE_D },
+    { 0x07E1, UC_JOINING_TYPE_D },
+    { 0x07E2, UC_JOINING_TYPE_D },
+    { 0x07E3, UC_JOINING_TYPE_D },
+    { 0x07E4, UC_JOINING_TYPE_D },
+    { 0x07E5, UC_JOINING_TYPE_D },
+    { 0x07E6, UC_JOINING_TYPE_D },
+    { 0x07E7, UC_JOINING_TYPE_D },
+    { 0x07E8, UC_JOINING_TYPE_D },
+    { 0x07E9, UC_JOINING_TYPE_D },
+    { 0x07EA, UC_JOINING_TYPE_D },
+    { 0x07FA, UC_JOINING_TYPE_C },
+    { 0x200C, UC_JOINING_TYPE_U },
+    { 0x200D, UC_JOINING_TYPE_C }
--- a/top/maint.mk
+++ b/top/maint.mk
@@ -33,7 +33,7 @@
 
 GIT = git
 VC = $(GIT)
-VC-tag = git tag -s -m '$(VERSION)' -u '$(gpg_key_ID)'
+VC-tag = git tag -s -m '$(VERSION)' 'v$(VERSION)' -u '$(gpg_key_ID)'
 
 VC_LIST = $(build_aux)/vc-list-files -C $(srcdir)
 
@@ -57,11 +57,13 @@
 # In order to be able to consistently filter "."-relative names,
 # (i.e., with no $(srcdir) prefix), this definition is careful to
 # remove any $(srcdir) prefix, and to restore what it removes.
+_sc_excl = \
+  $(if $(exclude_file_name_regexp--$@),$(exclude_file_name_regexp--$@),^$$)
 VC_LIST_EXCEPT = \
   $(VC_LIST) | sed 's|^$(_dot_escaped_srcdir)/||' \
 	| if test -f $(srcdir)/.x-$@; then grep -vEf $(srcdir)/.x-$@; \
 	  else grep -Ev -e "$${VC_LIST_EXCEPT_DEFAULT-ChangeLog}"; fi \
-	| grep -Ev -e '$(VC_LIST_ALWAYS_EXCLUDE_REGEX)' \
+	| grep -Ev -e '($(VC_LIST_ALWAYS_EXCLUDE_REGEX)|$(_sc_excl))' \
 	$(_prepend_srcdir_prefix)
 
 ifeq ($(origin prev_version_file), undefined)
@@ -126,8 +128,13 @@
 			$(srcdir)/$(ME) $(_cfg_mk)))
 .PHONY: $(syntax-check-rules)
 
-local-checks-available = \
-  $(syntax-check-rules)
+ifeq ($(shell $(VC_LIST) >/dev/null 2>&1; echo $$?),0)
+local-checks-available += $(syntax-check-rules)
+else
+local-checks-available += no-vc-detected
+no-vc-detected:
+	@echo "No version control files detected; skipping syntax check"
+endif
 .PHONY: $(local-checks-available)
 
 # Arrange to print the name of each syntax-checking rule just before running it.
@@ -191,6 +198,16 @@
 #  halt
 #
 #     Message to display before to halting execution.
+#
+# Finally, you may exempt files based on an ERE matching file names.
+# For example, to exempt from the sc_space_tab check all files with the
+# .diff suffix, set this Make variable:
+#
+# exclude_file_name_regexp--sc_space_tab = \.diff$
+#
+# Note that while this functionality is mostly inherited via VC_LIST_EXCEPT,
+# when filtering by name via in_files, we explicitly filter out matching
+# names here as well.
 
 # By default, _sc_search_regexp does not ignore case.
 export ignore_case =
@@ -228,7 +245,8 @@
 									\
    : Filter by file name;						\
    if test -n "$$in_files"; then					\
-     files=$$(find $(srcdir) | grep -E "$$in_files");			\
+     files=$$(find $(srcdir) | grep -E "$$in_files"			\
+              | grep -Ev '$(exclude_file_name_regexp--$@)');		\
    else									\
      files=$$($(VC_LIST_EXCEPT));					\
      if test -n "$$in_vc_files"; then					\
@@ -654,7 +672,7 @@
 sc_unmarked_diagnostics:
 	@grep -nE							\
 	    '\<error *\([^"]*"[^"]*[a-z]{3}' $$($(VC_LIST_EXCEPT))	\
-	  | grep -v '_''(' &&						\
+	  | grep -Ev '(_|ngettext ?)\(' &&				\
 	  { echo '$(ME): found unmarked diagnostic(s)' 1>&2;		\
 	    exit 1; } || :
 
@@ -773,17 +791,22 @@
 #   perl -ln -0777 -e '/\n(\n+)$/ and print "$ARGV: ".length $1' ...
 # but that would be far less efficient, reading the entire contents
 # of each file, rather than just the last two bytes of each.
+# In addition, while the code below detects both blank lines and a missing
+# newline at EOF, the above detects only the former.
 #
 # This is a perl script that is expected to be the single-quoted argument
 # to a command-line "-le".  The remaining arguments are file names.
-# Print the name of each file that ends in two or more newline bytes.
+# Print the name of each file that ends in exactly one newline byte.
+# I.e., warn if there are blank lines (2 or more newlines), or if the
+# last byte is not a newline.  However, currently we don't complain
+# about any file that contains exactly one byte.
 # Exit nonzero if at least one such file is found, otherwise, exit 0.
 # Warn about, but otherwise ignore open failure.  Ignore seek/read failure.
 #
 # Use this if you want to remove trailing empty lines from selected files:
 #   perl -pi -0777 -e 's/\n\n+$/\n/' files...
 #
-detect_empty_lines_at_EOF_ =						\
+require_exactly_one_NL_at_EOF_ =					\
   foreach my $$f (@ARGV)						\
     {									\
       open F, "<", $$f or (warn "failed to open $$f: $$!\n"), next;	\
@@ -793,12 +816,14 @@
       defined $$p and $$p = sysread F, $$last_two_bytes, 2;		\
       close F;								\
       $$c = "ignore read failure";					\
-      $$p && $$last_two_bytes eq "\n\n" and (print $$f), $$fail=1;	\
+      $$p && ($$last_two_bytes eq "\n\n"				\
+              || substr ($$last_two_bytes,1) ne "\n")			\
+          and (print $$f), $$fail=1;					\
     }									\
   END { exit defined $$fail }
 sc_prohibit_empty_lines_at_EOF:
-	@perl -le '$(detect_empty_lines_at_EOF_)' $$($(VC_LIST_EXCEPT))	\
-          || { echo '$(ME): the above files end with empty line(s)'     \
+	@perl -le '$(require_exactly_one_NL_at_EOF_)' $$($(VC_LIST_EXCEPT)) \
+          || { echo '$(ME): empty line(s) or no newline at EOF' 	\
 		1>&2; exit 1; } || :;					\
 
 # Make sure we don't use st_blocks.  Use ST_NBLOCKS instead.
@@ -930,13 +955,13 @@
 apply the above patch\n'
 
 # Verify that all source files using _() are listed in po/POTFILES.in.
-po_file = po/POTFILES.in
+po_file ?= $(srcdir)/po/POTFILES.in
 sc_po_check:
 	@if test -f $(po_file); then					\
 	  grep -E -v '^(#|$$)' $(po_file)				\
 	    | grep -v '^src/false\.c$$' | sort > $@-1;			\
 	  files=;							\
-	  for file in $$($(VC_LIST_EXCEPT)) lib/*.[ch]; do		\
+	  for file in $$($(VC_LIST_EXCEPT)) $(srcdir)/lib/*.[ch]; do	\
 	    test -r $$file || continue;					\
 	    case $$file in						\
 	      *.m4|*.mk) continue ;;					\
@@ -951,7 +976,7 @@
 	    files="$$files $$file";					\
 	  done;								\
 	  grep -E -l '\b(N?_|gettext *)\([^)"]*("|$$)' $$files		\
-	    | sort -u > $@-2;						\
+	    | sed 's|^$(_dot_escaped_srcdir)/||' | sort -u > $@-2;	\
 	  diff -u -L $(po_file) -L $(po_file) $@-1 $@-2			\
 	    || { printf '$(ME): '$(fix_po_file_diag) 1>&2; exit 1; };	\
 	  rm -f $@-1 $@-2;						\
--- a/users.txt
+++ b/users.txt
@@ -3,6 +3,7 @@
   CSSC            http://git.savannah.gnu.org/cgit/cssc.git
   Net::CDP        http://search.cpan.org/src/MCHAPMAN/Net-CDP-0.09/libcdp/
   OPeNDAP         http://scm.opendap.org:8090/svn/trunk/
+  acct            http://cvs.sv.gnu.org/viewcvs/acct/acct/
   anubis          http://cvs.sv.gnu.org/viewcvs/anubis/anubis/
   augeas          http://augeas.net/
   autobuild       http://josefsson.org/autobuild/
@@ -11,11 +12,15 @@
   coreutils       http://git.sv.gnu.org/gitweb/?p=coreutils.git
   cpio            http://cvs.sv.gnu.org/viewcvs/cpio/cpio/
   cvs             http://cvs.sv.gnu.org/viewcvs/cvs/ccvs/
+  cvsps           http://sourceforge.net/projects/cvsps/
   diffutils       http://git.sv.gnu.org/cgit/diffutils.git/
   febootstrap     http://people.redhat.com/~rjones/febootstrap/
   findutils       http://cvs.sv.gnu.org/viewcvs/findutils/findutils/
   gcal            http://git.savannah.gnu.org/gitweb/?p=gcal.git
+  gdb             http://sourceware.org/git/?p=gdb.git;a=summary
   gettext         http://cvs.sv.gnu.org/viewcvs/gettext/gettext/
+  gengetopt       http://git.sv.gnu.org/gitweb/?p=gengetopt.git
+  gmediaserver    http://cvs.sv.gnu.org/viewvc/gmediaserver/gmediaserver/
   gnuit           http://www.gnu.org/software/gnuit/
                   http://git.savannah.gnu.org/gitweb/?p=gnuit.git
   gnutls          http://cvs.gnupg.org/cgi-bin/viewcvs.cgi/gnutls/?root=GNU+TLS+Library
@@ -24,6 +29,7 @@
   gpg             http://cvs.gnupg.org/cgi-bin/viewcvs.cgi/trunk/
   gsasl           http://git.sv.gnu.org/gitweb/?p=gsasl.git
   gss             http://git.sv.gnu.org/gitweb/?p=gss.git
+  gtkreindeer     http://git.sv.gnu.org/gitweb/?p=gtkreindeer.git
   gtk-vnc         http://gtk-vnc.codemonkey.ws/hg/outgoing.hg
   grep            http://git.sv.gnu.org/cgit/grep.git/
   guile           http://cvs.sv.gnu.org/viewvc/guile/guile/guile-core/
@@ -32,6 +38,8 @@
   hivex           http://git.annexia.org/?p=hivex.git
   icoutils        http://riva.ucam.org/svn/cjwatson/src/debian/icoutils/trunk/icoutils/
   inetutils       http://cvs.sv.gnu.org/viewcvs/inetutils/inetutils/
+  iwhd            http://git.fedorahosted.org/git/?p=iwhd.git
+  jugtail         http://cvs.savannah.gnu.org/viewvc/?root=jugtail
   jwhois          http://cvs.sv.gnu.org/viewvc/jwhois/jwhois/
   libdap          http://scm.opendap.org:8090/svn/trunk/libdap/
   libffcall       http://savannah.gnu.org/projects/libffcall/
@@ -39,12 +47,13 @@
   libguestfs      http://libguestfs.org/
   libiconv        http://libiconv.cvs.sourceforge.net/libiconv/libiconv/
   libidn          http://git.sv.gnu.org/gitweb/?p=libidn.git
+  libidn2         http://josefsson.org/libidn2/
   libksba         http://cvs.gnupg.org/cgi-bin/viewcvs.cgi/trunk/?root=KSBA
   libntlm         http://git.josefsson.org/?p=libntlm.git;a=summary
   libprelude      https://trac.prelude-ids.org/browser/trunk/libprelude/
   libpreludedb    https://trac.prelude-ids.org/browser/trunk/libpreludedb/
-  libtasn1        http://cvs.gnupg.org/cgi-bin/viewcvs.cgi/libtasn1/?root=GNU+TLS+Library
-                  http://repo.or.cz/w/libtasn1.git
+  libtasn1        http://git.savannah.gnu.org/gitweb/?p=libtasn1.git
+  libunistring    http://git.sv.gnu.org/gitweb/?p=libunistring.git
   libvirt         http://libvirt.org/
                   http://git.et.redhat.com/?p=libvirt.git;a=summary
   m4              http://git.sv.gnu.org/gitweb/?p=m4.git;a=summary
@@ -52,11 +61,14 @@
   mailutils       http://cvs.sv.gnu.org/viewcvs/mailutils/mailutils/
   man-db          http://www.chiark.greenend.org.uk/~cjwatson/bzr/man-db/trunk/
   miktex          https://svn.sourceforge.net/svnroot/miktex/miktex/trunk
+  mini-httpd      http://git.sv.gnu.org/gitweb/?p=mini-httpd.git
   msmtp           http://msmtp.cvs.sourceforge.net/msmtp/msmtp/
   myserver        http://git.sv.gnu.org/gitweb/?p=myserver.git;a=summary
+  nagios-plugins  http://nagiosplug.git.sourceforge.net/
   netcf           http://fedorahosted.org/netcf/
   newts           http://svn.arete.cc/newts/trunk/
   OATH Toolkit    http://www.nongnu.org/oath-toolkit/
+  octave          http://hg.savannah.gnu.org/hgweb/octave/
   parted          http://git.debian.org/?p=parted/parted.git;a=summary
   patch           http://git.sv.gnu.org/gitweb/?p=patch.git
   prelude-lml     https://trac.prelude-ids.org/browser/trunk/prelude-lml/
@@ -64,11 +76,14 @@
   pspp            http://git.sv.gnu.org/gitweb/?p=pspp.git
   radius          http://cvs.sv.gnu.org/viewcvs/radius/radius/
   recutils        http://git.savannah.gnu.org/gitweb/?p=recutils.git
+  reindeer        http://git.sv.gnu.org/gitweb/?p=reindeer.git
+  rcs             http://git.savannah.gnu.org/cgit/rcs.git
   sed             http://cvs.savannah.gnu.org/viewcvs/sed/?root=sed
   sharutils       http://cvs.savannah.gnu.org/viewvc/sharutils/sharutils/
   shishi          http://git.sv.gnu.org/gitweb/?p=shishi.git
   tar             http://cvs.sv.gnu.org/viewcvs/tar/tar/
   texinfo         http://cvs.sv.gnu.org/viewcvs/texinfo/texinfo/
+  tmpwatch        https://fedorahosted.org/tmpwatch/
   vc-dwim         http://git.sv.gnu.org/gitweb/?p=vc-dwim.git
   wget            http://hg.addictivecode.org/wget/mainline/
   wydawca         http://svn.gnu.org.ua/viewvc/wydawca/trunk/